Commit | Line | Data |
---|---|---|
7172eb74 | 1 | /* |
6412e026 KB |
2 | * Copyright (c) 1983, 1993 |
3 | * The Regents of the University of California. All rights reserved. | |
7172eb74 | 4 | * |
6d936b27 | 5 | * %sccs.include.redist.c% |
0718fb71 | 6 | * |
6412e026 | 7 | * @(#)defs.h 8.1 (Berkeley) %G% |
7172eb74 | 8 | */ |
ca9611a8 | 9 | |
55669d5b | 10 | #include <sys/param.h> |
ca9611a8 RC |
11 | #include <sys/dir.h> |
12 | #include <sys/stat.h> | |
13 | #include <sys/time.h> | |
567e65c3 | 14 | #include <sys/file.h> |
a94625d9 | 15 | |
ca9611a8 | 16 | #include <netinet/in.h> |
a94625d9 | 17 | |
aecff29a KB |
18 | #include <errno.h> |
19 | #include <pwd.h> | |
20 | #include <grp.h> | |
a94625d9 KB |
21 | #include <stdio.h> |
22 | #include <ctype.h> | |
23 | #include <unistd.h> | |
24 | #include <string.h> | |
25 | #include <stdlib.h> | |
567e65c3 | 26 | #include "pathnames.h" |
ca9611a8 | 27 | |
9b81f83a | 28 | /* |
0fccdfef | 29 | * The version number should be changed whenever the protocol changes. |
9b81f83a | 30 | */ |
a3e6fd64 | 31 | #define VERSION 3 |
9b81f83a | 32 | |
ca9611a8 | 33 | /* defines for yacc */ |
d1dee8e8 RC |
34 | #define EQUAL 1 |
35 | #define LP 2 | |
36 | #define RP 3 | |
37 | #define SM 4 | |
38 | #define ARROW 5 | |
86d7a5c5 RC |
39 | #define COLON 6 |
40 | #define DCOLON 7 | |
41 | #define NAME 8 | |
42 | #define STRING 9 | |
43 | #define INSTALL 10 | |
44 | #define NOTIFY 11 | |
45 | #define EXCEPT 12 | |
4085f36f RC |
46 | #define PATTERN 13 |
47 | #define SPECIAL 14 | |
48 | #define OPTION 15 | |
82572cb6 RC |
49 | |
50 | /* lexical definitions */ | |
51 | #define QUOTE 0200 /* used internally for quoted characters */ | |
52 | #define TRIM 0177 /* Mask to strip quote bit */ | |
ca9611a8 RC |
53 | |
54 | /* table sizes */ | |
d1dee8e8 RC |
55 | #define HASHSIZE 1021 |
56 | #define INMAX 3500 | |
82572cb6 | 57 | |
3024eb6f | 58 | /* option flags */ |
d1dee8e8 RC |
59 | #define VERIFY 0x1 |
60 | #define WHOLE 0x2 | |
61 | #define YOUNGER 0x4 | |
024fde5b | 62 | #define COMPARE 0x8 |
e8109cf8 | 63 | #define REMOVE 0x10 |
a3e6fd64 RC |
64 | #define FOLLOW 0x20 |
65 | #define IGNLNKS 0x40 | |
d1dee8e8 | 66 | |
d6bccb44 RC |
67 | /* expand type definitions */ |
68 | #define E_VARS 0x1 | |
69 | #define E_SHELL 0x2 | |
70 | #define E_TILDE 0x4 | |
71 | #define E_ALL 0x7 | |
72 | ||
0fccdfef RC |
73 | /* actions for lookup() */ |
74 | #define LOOKUP 0 | |
75 | #define INSERT 1 | |
76 | #define REPLACE 2 | |
77 | ||
d1dee8e8 | 78 | #define ISDIR(m) (((m) & S_IFMT) == S_IFDIR) |
ca9611a8 RC |
79 | |
80 | #define ALLOC(x) (struct x *) malloc(sizeof(struct x)) | |
81 | ||
0fccdfef RC |
82 | struct namelist { /* for making lists of strings */ |
83 | char *n_name; | |
84 | struct namelist *n_next; | |
85 | }; | |
86 | ||
87 | struct subcmd { | |
88 | short sc_type; /* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */ | |
89 | short sc_options; | |
90 | char *sc_name; | |
91 | struct namelist *sc_args; | |
92 | struct subcmd *sc_next; | |
ca9611a8 RC |
93 | }; |
94 | ||
0fccdfef RC |
95 | struct cmd { |
96 | int c_type; /* type - ARROW,DCOLON */ | |
97 | char *c_name; /* hostname or time stamp file name */ | |
86d7a5c5 | 98 | char *c_label; /* label for partial update */ |
0fccdfef RC |
99 | struct namelist *c_files; |
100 | struct subcmd *c_cmds; | |
101 | struct cmd *c_next; | |
102 | }; | |
a3e6fd64 RC |
103 | |
104 | struct linkbuf { | |
105 | ino_t inum; | |
106 | dev_t devnum; | |
107 | int count; | |
108 | char pathname[BUFSIZ]; | |
ac288309 | 109 | char target[BUFSIZ]; |
a3e6fd64 RC |
110 | struct linkbuf *nextp; |
111 | }; | |
112 | ||
ca9611a8 RC |
113 | extern int debug; /* debugging flag */ |
114 | extern int nflag; /* NOP flag, don't execute commands */ | |
115 | extern int qflag; /* Quiet. don't print messages */ | |
f7770429 | 116 | extern int options; /* global options */ |
ca9611a8 | 117 | |
0fccdfef | 118 | extern int nerrs; /* number of errors seen */ |
ca9611a8 RC |
119 | extern int rem; /* remote file descriptor */ |
120 | extern int iamremote; /* acting as remote server */ | |
e385b216 | 121 | extern char tempfile[]; /* file name for logging changes */ |
a3e6fd64 | 122 | extern struct linkbuf *ihead; /* list of files with more than one link */ |
e8109cf8 RC |
123 | extern struct passwd *pw; /* pointer to static area used by getpwent */ |
124 | extern struct group *gr; /* pointer to static area used by getgrent */ | |
ca9611a8 | 125 | extern char host[]; /* host name of master copy */ |
ca9611a8 | 126 | extern char buf[]; /* general purpose buffer */ |
a94625d9 KB |
127 | |
128 | int any __P((int, char *)); | |
129 | char *colon __P((char *)); | |
130 | void cleanup __P((int)); | |
131 | void define __P((char *)); | |
132 | void docmds __P((char **, int, char **)); | |
133 | void error __P((const char *, ...)); | |
134 | int except __P((char *)); | |
135 | struct namelist * | |
136 | expand __P((struct namelist *, int)); | |
137 | char *exptilde __P((char [], char *)); | |
138 | void fatal __P((const char *, ...)); | |
139 | int inlist __P((struct namelist *, char *)); | |
140 | void insert __P((char *, | |
141 | struct namelist *, struct namelist *, struct subcmd *)); | |
142 | void install __P((char *, char *, int, int)); | |
143 | void log __P((FILE *, const char *, ...)); | |
144 | struct namelist * | |
145 | lookup __P((char *, int, struct namelist *)); | |
146 | void lostconn __P((int)); | |
147 | struct namelist * | |
148 | makenl __P((char *)); | |
149 | struct subcmd * | |
150 | makesubcmd __P((int)); | |
151 | void prnames __P((struct namelist *)); | |
152 | void server __P((void)); | |
153 | void yyerror __P((char *)); | |
154 | int yyparse __P((void)); |