source: trunk/athena/etc/track/track.h @ 12251

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