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

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