static char *sccsid
= "@(#)files.c 4.9 (Berkeley) 84/03/21";
/* UNIX DEPENDENT PROCEDURES */
/* DEFAULT RULES FOR UNIX */
".SUFFIXES : .L .out .o .c .f .e .r .y .yr .ye .l .s .z .x .t .h .cl",
".SUFFIXES : .out .o .c .F .f .e .r .y .yr .ye .l .s .cl .p",
#if defined(vax) || defined(sun)
"\t$(CC) $(CFLAGS) -c $<",
"\t$(PC) $(PFLAGS) -c $<",
"\t$(FC) $(RFLAGS) $(EFLAGS) $(FFLAGS) -c $<",
"\t$(YACC) $(YFLAGS) $<",
"\t$(CC) $(CFLAGS) -c y.tab.c",
"\t$(YACCR) $(YFLAGS) $<",
"\t$(RC) $(RFLAGS) -c y.tab.r",
"\t$(YACCE) $(YFLAGS) $<",
"\t$(EC) $(RFLAGS) -c y.tab.e",
"\t$(CC) $(CFLAGS) -c lex.yy.c",
"\t$(YACC) $(YFLAGS) $<",
"\t$(YACCR) $(YFLAGS) $<",
"\t$(YACCE) $(YFLAGS) $<",
"\t$(SCOMP) $(SCFLAGS) $<",
"\t$(SCOMP) $(SCFLAGS) -c $<",
"\t$(SCOMP) $(SCFLAGS) -t $<",
"\t$(CMDICT) $(CMFLAGS) $<",
"\t$(CMDICT) $(CMFLAGS) -c $<",
".s.out .c.out .o.out :",
"\t$(CC) $(CFLAGS) $< $(LOADLIBES) -o $@",
".f.out .F.out .r.out .e.out :",
"\t$(FC) $(EFLAGS) $(RFLAGS) $(FFLAGS) $< $(LOADLIBES) -o $@",
"\t$(YACC) $(YFLAGS) $<",
"\t$(CC) $(CFLAGS) y.tab.c $(LOADLIBES) -ly -o $@",
"\t$(CC) $(CFLAGS) lex.yy.c $(LOADLIBES) -ll -o $@",
TIMETYPE
exists(filename
)
for(s
= filename
; *s
!='\0' && *s
!='(' ; ++s
)
return(lookarch(filename
));
if (stat(filename
, &buf
) < 0)
else return(buf
.st_mtime
);
FSTATIC
char nbuf
[MAXNAMLEN
+ 1];
FSTATIC
char *nbufend
= &nbuf
[MAXNAMLEN
];
struct depblock
*srchdir(pat
, mkchain
, nextdbl
)
register char *pat
; /* pattern to be matched in directory */
int mkchain
; /* nonzero if results to be remembered */
struct depblock
*nextdbl
; /* final value for chain */
char *dirname
, *dirpref
, *endir
, *filepat
, *p
, temp
[100];
char fullname
[100], *p1
, *p2
;
struct depblock
*thisdbl
;
for(patp
=firstpat
; patp
; patp
= patp
->nxtpattern
)
if(! unequal(pat
, patp
->patval
)) return(0);
patp
->nxtpattern
= firstpat
;
patp
->patval
= copys(pat
);
for(p
=pat
; *p
!='\0'; ++p
)
dirpref
= concat(dirname
, "/", temp
);
for(od
= firstod
; od
; od
= od
->nxtopendir
)
if(! unequal(dirname
, od
->dirn
) )
rewinddir(dirf
); /* start over at the beginning */
od
->nxtopendir
= firstod
;
od
->dirn
= copys(dirname
);
fcntl(dirf
->dd_fd
, F_SETFD
, 1);
fprintf(stderr
, "Directory %s: ", dirname
);
else for (dptr
= readdir(dirf
); dptr
!= NULL
; dptr
= readdir(dirf
))
while( (p2
<nbufend
) && (*p2
++ = *p1
++)!='\0' )
if( amatch(nbuf
,filepat
) )
concat(dirpref
,nbuf
,fullname
);
if( (q
=srchname(fullname
)) ==0)
q
= makename(copys(fullname
));
thisdbl
= ALLOC(depblock
);
thisdbl
->nxtdepblock
= nextdbl
;
if(endir
!= 0) *endir
= '/';
/* stolen from glob through find */
return(amatch(++s
, ++p
));
k
|= (lc
<= scc
) & (scc
<= (cc
=p
[1]) ) ;
if(scc
) return(amatch(++s
, ++p
));
if (amatch(s
++,p
)) return(1);
int meteron
= 0; /* default: metering off */
struct passwd
*pwd
, *getpwuid();
if(file
==0 || meteron
==0) return;
pwd
= getpwuid(getuid());
if( (mout
=fopen(file
,"a")) != NULL
)
fprintf(mout
,"User %s, %s\n",pwd
->pw_name
,p
+4);
/* look inside archives for notations a(b) and a((b))
a(b) is file member b in archive a
a((b)) is entry point _b in object archive a
static struct exec objhead
;
static struct nlist objentry
;
TIMETYPE
lookarch(filename
)
char *p
, *q
, *send
, s
[MAXNAMLEN
+ 1];
int i
, nc
, nsym
, objarch
;
for(p
= filename
; *p
!= '(' ; ++p
)
for( q
= s
; q
<send
&& *p
!='\0' && *p
!=')' ; *q
++ = *p
++ )
nsym
= objhead
.a_syms
/ sizeof(objentry
);
fread( (char *) &objentry
, sizeof(objentry
),1,arfd
);
if( (objentry
.n_type
& N_EXT
)
&& ((objentry
.n_type
& ~N_EXT
) || objentry
.n_value
)
&& eqstr(objentry
.n_un
.n_name
,s
,nc
))
else if( eqstr(arfname
, s
, nc
))
fatal1("cannot open %s", f
);
fread( (char *) &word
, sizeof(word
), 1, arfd
);
fread(magic
, SARMAG
, 1, arfd
);
if( ! eqstr(magic
, ARMAG
, SARMAG
) )
fatal1("%s is not an archive", f
);
arpos
+= (arflen
+ 1) & ~1L; /* round archived file length up to even */
fread( (char *) &arhead
, sizeof(arhead
), 1, arfd
);
arflen
= atol(arhead
.ar_size
);
arfdate
= atol(arhead
.ar_date
);
arfdate
= arhead
.ar_date
;
strncpy(arfname
, arhead
.ar_name
, sizeof(arhead
.ar_name
));
fread( (char *) &objhead
, sizeof(objhead
), 1, arfd
);
fatal1("%s is not an object module", arfname
);
skip
= objhead
.a_text
+ objhead
.a_data
;
#if defined(vax) || defined(sun)
skip
+= objhead
.a_trsize
+ objhead
.a_drsize
;