1*11a8fa6cSceastha /* 2*11a8fa6cSceastha * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 3*11a8fa6cSceastha * Use is subject to license terms. 4*11a8fa6cSceastha */ 5*11a8fa6cSceastha 67c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 77c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 87c478bd9Sstevel@tonic-gate 97c478bd9Sstevel@tonic-gate /* 107c478bd9Sstevel@tonic-gate * Copyright (c) 1980 Regents of the University of California. 117c478bd9Sstevel@tonic-gate * All rights reserved. The Berkeley software License Agreement 127c478bd9Sstevel@tonic-gate * specifies the terms and conditions for redistribution. 137c478bd9Sstevel@tonic-gate */ 147c478bd9Sstevel@tonic-gate 157c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 167c478bd9Sstevel@tonic-gate 177c478bd9Sstevel@tonic-gate #include <stdio.h> 187c478bd9Sstevel@tonic-gate #include <sys/types.h> 197c478bd9Sstevel@tonic-gate #include <sys/stat.h> 207c478bd9Sstevel@tonic-gate 217c478bd9Sstevel@tonic-gate extern char *soutput, *tagout, usedir[]; 227c478bd9Sstevel@tonic-gate union ptr { 237c478bd9Sstevel@tonic-gate unsigned *a; 247c478bd9Sstevel@tonic-gate long *b; 257c478bd9Sstevel@tonic-gate }; 267c478bd9Sstevel@tonic-gate 27*11a8fa6cSceastha void 28*11a8fa6cSceastha result(unsigned *mptr, int nf, FILE *fc) 297c478bd9Sstevel@tonic-gate { 307c478bd9Sstevel@tonic-gate int i, c; 317c478bd9Sstevel@tonic-gate char *s; 327c478bd9Sstevel@tonic-gate long lp; 337c478bd9Sstevel@tonic-gate extern int iflong; 347c478bd9Sstevel@tonic-gate char res[100]; 357c478bd9Sstevel@tonic-gate union ptr master; 367c478bd9Sstevel@tonic-gate 377c478bd9Sstevel@tonic-gate if (iflong) { 387c478bd9Sstevel@tonic-gate master.b = (long *)mptr; 39*11a8fa6cSceastha } else { 407c478bd9Sstevel@tonic-gate master.a = mptr; 417c478bd9Sstevel@tonic-gate } 427c478bd9Sstevel@tonic-gate 43*11a8fa6cSceastha for (i = 0; i < nf; i++) { 447c478bd9Sstevel@tonic-gate lp = iflong ? master.b[i] : master.a[i]; 457c478bd9Sstevel@tonic-gate fseek(fc, lp, 0); 467c478bd9Sstevel@tonic-gate fgets(res, 100, fc); 477c478bd9Sstevel@tonic-gate for (s = res; c = *s; s++) 48*11a8fa6cSceastha if (c == ';') { 497c478bd9Sstevel@tonic-gate *s = 0; 507c478bd9Sstevel@tonic-gate break; 517c478bd9Sstevel@tonic-gate } 52*11a8fa6cSceastha if (tagout != 0) { 537c478bd9Sstevel@tonic-gate if (res[0] == '/' || usedir[0] == 0) 547c478bd9Sstevel@tonic-gate sprintf(tagout, "%s", res); 557c478bd9Sstevel@tonic-gate else 567c478bd9Sstevel@tonic-gate sprintf(tagout, "%s/%s", usedir, res); 577c478bd9Sstevel@tonic-gate while (*tagout) tagout++; 58*11a8fa6cSceastha } else { 597c478bd9Sstevel@tonic-gate if (res[0] != '/' || usedir[0] == 0) 607c478bd9Sstevel@tonic-gate printf("%s/", usedir); 617c478bd9Sstevel@tonic-gate printf("%s\n", res); 627c478bd9Sstevel@tonic-gate } 637c478bd9Sstevel@tonic-gate } 647c478bd9Sstevel@tonic-gate } 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate long 677c478bd9Sstevel@tonic-gate gdate(f) 687c478bd9Sstevel@tonic-gate FILE *f; 697c478bd9Sstevel@tonic-gate { 707c478bd9Sstevel@tonic-gate struct stat sb; 717c478bd9Sstevel@tonic-gate fstat(fileno(f), &sb); 727c478bd9Sstevel@tonic-gate return (sb . st_mtime); 737c478bd9Sstevel@tonic-gate } 74