1 | /* |
---|
2 | * $Source: /afs/dev.mit.edu/source/repository/athena/etc/track/track.h,v $ |
---|
3 | * $Header: /afs/dev.mit.edu/source/repository/athena/etc/track/track.h,v 4.4 1988-09-19 20:27:40 don Exp $ |
---|
4 | */ |
---|
5 | |
---|
6 | #ifndef lint |
---|
7 | static char *rcsid_track_h = "$Header: /afs/dev.mit.edu/source/repository/athena/etc/track/track.h,v 4.4 1988-09-19 20:27:40 don Exp $"; |
---|
8 | #endif lint |
---|
9 | |
---|
10 | #include "bellcore-copyright.h" |
---|
11 | #include "mit-copyright.h" |
---|
12 | |
---|
13 | #include <sys/types.h> |
---|
14 | #include <sys/time.h> |
---|
15 | #include <sys/stat.h> |
---|
16 | #include <sys/dir.h> |
---|
17 | #include <sys/param.h> |
---|
18 | #include <sys/file.h> |
---|
19 | #include <ctype.h> |
---|
20 | #include <signal.h> |
---|
21 | #include <stdio.h> |
---|
22 | |
---|
23 | /* Default working directory - under to- or from- root */ |
---|
24 | #define DEF_WORKDIR "/etc/athena/lib" |
---|
25 | |
---|
26 | /* Default administrator */ |
---|
27 | #define DEF_ADM "don" |
---|
28 | |
---|
29 | /* Default binary directory - under real root */ |
---|
30 | #define DEF_BINDIR "/etc/athena" |
---|
31 | |
---|
32 | /* Default root for source of transfer */ |
---|
33 | #define DEF_FROMROOT "/srvd" |
---|
34 | |
---|
35 | /* Default subscription list */ |
---|
36 | #define DEF_LOG "/usr/adm/TRACKLOG" |
---|
37 | |
---|
38 | /* Default root for destination of transfer: "" == root. */ |
---|
39 | #define DEF_TOROOT "" |
---|
40 | |
---|
41 | /* Default subscription list */ |
---|
42 | #define DEF_SUB "sys_rvd" |
---|
43 | |
---|
44 | /* Default directory containing subscription lists under working dir */ |
---|
45 | #define DEF_SLISTDIR "slists" |
---|
46 | |
---|
47 | /* Default directory containing stat files under working dir */ |
---|
48 | #define DEF_STATDIR "stats" |
---|
49 | |
---|
50 | /* Default directory containing lock files under real root */ |
---|
51 | #define DEF_LOCKDIR "/tmp" |
---|
52 | |
---|
53 | /* Default global exceptions: filenames shouldn't contain whitespace */ |
---|
54 | #define DEF_EXCEPT { "#*", "*~", "*\t*", "* *", "*\n*" } |
---|
55 | |
---|
56 | /* Default shell */ |
---|
57 | #define DEF_SHELL "/bin/sh" |
---|
58 | |
---|
59 | /* Default command to set a shell variable */ |
---|
60 | #define DEF_SETCMD "" |
---|
61 | |
---|
62 | #define BUFLEN 1024 |
---|
63 | #define BLOCKSIZE 1024 |
---|
64 | #define LINELEN 256 |
---|
65 | #define MAXLINES 300 |
---|
66 | #define WORDLEN 20 |
---|
67 | #define WORDMAX 128 |
---|
68 | #define ENTRYMAX 256 |
---|
69 | #define STACKMAX 50 |
---|
70 | |
---|
71 | #define CNT 0 |
---|
72 | #define ROOT 1 |
---|
73 | #define NAME 2 |
---|
74 | |
---|
75 | typedef struct currentness { |
---|
76 | char name[ LINELEN]; |
---|
77 | unsigned int cksum; |
---|
78 | char link[ LINELEN]; |
---|
79 | struct stat sbuf; |
---|
80 | } Currentness; |
---|
81 | |
---|
82 | typedef struct statline { |
---|
83 | char sortkey[ LINELEN]; |
---|
84 | char line[ LINELEN]; |
---|
85 | } Statline ; |
---|
86 | |
---|
87 | extern Statline *statfilebufs; |
---|
88 | extern int cur_line; |
---|
89 | extern FILE *statfile; |
---|
90 | |
---|
91 | /* NEXT is defined weirdly, |
---|
92 | * so that it can appear as an lvalue. |
---|
93 | */ |
---|
94 | #define FLAG( list_elt) (((char *)( list_elt))[-1]) |
---|
95 | #define PNEXT( list_elt) ((List_element **)&((char *)( list_elt))[-5]) |
---|
96 | #define NEXT( list_elt) *PNEXT( list_elt) |
---|
97 | #define TEXT( list_elt) ((char*)(list_elt)) |
---|
98 | #define NORMALCASE ((char) 0) |
---|
99 | #define FORCE_LINK ((char)-1) |
---|
100 | #define DONT_TRACK ((char) 1) |
---|
101 | |
---|
102 | typedef struct list_element { |
---|
103 | struct list_element *next; |
---|
104 | char flag; |
---|
105 | char first_char[1]; |
---|
106 | } List_element; |
---|
107 | |
---|
108 | /* XXX: if shift field is negative, the table field contains a linked-list. |
---|
109 | * if shift is positive, the table is a hash-table. |
---|
110 | * this enables justshow() to dump an incompletely-parsed subscription-list. |
---|
111 | * LIST() macro should only be used when adding list-elts during parsing. |
---|
112 | */ |
---|
113 | #define LIST( tbl) ( (tbl).shift--, (List_element**)&(tbl).table) |
---|
114 | typedef struct Tbl { |
---|
115 | List_element **table; |
---|
116 | short shift; |
---|
117 | } Table; |
---|
118 | |
---|
119 | typedef struct entry { |
---|
120 | char sortkey[ LINELEN]; |
---|
121 | int keylen; |
---|
122 | int followlink; |
---|
123 | char *fromfile; |
---|
124 | char *tofile; |
---|
125 | char *cmpfile; |
---|
126 | Currentness currency; |
---|
127 | Table names; |
---|
128 | List_element *patterns; |
---|
129 | char *cmdbuf; |
---|
130 | } Entry ; |
---|
131 | extern Entry entries[]; |
---|
132 | |
---|
133 | extern int errno; |
---|
134 | extern int cksumflag; |
---|
135 | extern int forceflag; |
---|
136 | extern int ignore_prots; |
---|
137 | extern int incl_devs; |
---|
138 | extern int nopullflag; |
---|
139 | extern int parseflag; |
---|
140 | extern int quietflag; |
---|
141 | extern int uflag; |
---|
142 | extern int verboseflag; |
---|
143 | extern int writeflag; |
---|
144 | extern int entnum; |
---|
145 | extern int entrycnt; |
---|
146 | extern unsigned stackmax; |
---|
147 | extern unsigned maxlines; |
---|
148 | |
---|
149 | #define IS_LIST 1 |
---|
150 | #define NO_LIST 0 |
---|
151 | |
---|
152 | #define LOCK_TIME ((long)(60 * 60 * 6)) /* amount of time to let a lockfile |
---|
153 | sit before trying again |
---|
154 | i.e. 6 hours */ |
---|
155 | extern char binarydir[]; |
---|
156 | extern char fromroot[]; |
---|
157 | extern char toroot[]; |
---|
158 | extern char twdir[]; |
---|
159 | extern char cwd[]; |
---|
160 | extern char subfilename[]; |
---|
161 | extern char logfilepath[]; |
---|
162 | extern char subfilepath[]; |
---|
163 | extern char prgname[]; |
---|
164 | extern FILE *logfile; |
---|
165 | extern int debug; |
---|
166 | |
---|
167 | #define DO_CLOBBER 1 |
---|
168 | #define NO_CLOBBER 0 |
---|
169 | extern int clobber; |
---|
170 | |
---|
171 | /* parser stuff */ |
---|
172 | extern char wordbuf[]; |
---|
173 | extern char linebuf[]; |
---|
174 | extern FILE *yyin,*yyout; |
---|
175 | |
---|
176 | #define TYPE( statbuf) ((statbuf).st_mode & S_IFMT) |
---|
177 | #define MODE( statbuf) ((statbuf).st_mode & 07777) |
---|
178 | #define TIME( statbuf) ((statbuf).st_mtime) |
---|
179 | #define UID( statbuf) ((statbuf).st_uid) |
---|
180 | #define GID( statbuf) ((statbuf).st_gid) |
---|
181 | #define RDEV( statbuf) ((statbuf).st_rdev) |
---|
182 | |
---|
183 | extern int access(); |
---|
184 | |
---|
185 | extern char errmsg[]; |
---|
186 | char *gets(),*calloc(),*malloc(),*realloc(),*re_comp(); |
---|
187 | char *index(),*rindex(),*strcat(),*strncat(),*strcpy(),*strncpy(); |
---|
188 | int strcmp(),strncmp(),strlen(); |
---|
189 | long time(); |
---|
190 | |
---|
191 | int stat(), lstat(); |
---|
192 | extern int (*statf)(); |
---|
193 | extern char *statn; |
---|
194 | |
---|
195 | /* track's internal functions which need decl's */ |
---|
196 | |
---|
197 | extern Entry *clear_ent(); |
---|
198 | |
---|
199 | extern FILE *opensubfile(); |
---|
200 | |
---|
201 | extern List_element *add_list_elt(); |
---|
202 | extern List_element **lookup(); |
---|
203 | |
---|
204 | extern char *dec_statfile(); |
---|
205 | extern char *goodname(); |
---|
206 | extern char **initpath(); |
---|
207 | extern char *next_def_except(); |
---|
208 | extern char *re_conv(); |
---|
209 | extern char *resolve(); |
---|
210 | |
---|
211 | extern int entrycmp(), statlinecmp(); |
---|
212 | extern unsigned long hash(); |
---|
213 | extern unsigned in_cksum(); |
---|
214 | |
---|
215 | extern struct currentness *dec_entry(); |
---|
216 | extern struct currentness *get_cmp_currency(); |
---|
217 | |
---|
218 | #define SIGN( i) (((i) > 0)? 1 : ((i)? -1 : 0)) |
---|
219 | |
---|
220 | /* make a sortkey out of a pathname. |
---|
221 | * because several printing characters, notably '.', |
---|
222 | * come before '/' in the standard ascii sort-order, |
---|
223 | * we need a non-standard sorting order: |
---|
224 | * /etc |
---|
225 | * /etc/blah |
---|
226 | * /etc/whoop |
---|
227 | * /etc.athena ... |
---|
228 | * this requires that slashes get mapped to low-ranking |
---|
229 | * non-printing characters, for the purposes of the sort. |
---|
230 | * this macro allows us to do it fast. |
---|
231 | */ |
---|
232 | #define KEYCPY( key, name) \ |
---|
233 | {char *k,*p; k=key; for (p=name;*p;p++) *k++ = (*p=='/') ? '\001' : *p; *k= *p;} |
---|