defs.h revision 1.1 1 1.1 cgd /*
2 1.1 cgd * Copyright (c) 1983 Regents of the University of California.
3 1.1 cgd * All rights reserved.
4 1.1 cgd *
5 1.1 cgd * Redistribution and use in source and binary forms, with or without
6 1.1 cgd * modification, are permitted provided that the following conditions
7 1.1 cgd * are met:
8 1.1 cgd * 1. Redistributions of source code must retain the above copyright
9 1.1 cgd * notice, this list of conditions and the following disclaimer.
10 1.1 cgd * 2. Redistributions in binary form must reproduce the above copyright
11 1.1 cgd * notice, this list of conditions and the following disclaimer in the
12 1.1 cgd * documentation and/or other materials provided with the distribution.
13 1.1 cgd * 3. All advertising materials mentioning features or use of this software
14 1.1 cgd * must display the following acknowledgement:
15 1.1 cgd * This product includes software developed by the University of
16 1.1 cgd * California, Berkeley and its contributors.
17 1.1 cgd * 4. Neither the name of the University nor the names of its contributors
18 1.1 cgd * may be used to endorse or promote products derived from this software
19 1.1 cgd * without specific prior written permission.
20 1.1 cgd *
21 1.1 cgd * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1 cgd * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1 cgd * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1 cgd * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1 cgd * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1 cgd * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1 cgd * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1 cgd * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1 cgd * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1 cgd * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1 cgd * SUCH DAMAGE.
32 1.1 cgd *
33 1.1 cgd * @(#)defs.h 5.9 (Berkeley) 8/27/90
34 1.1 cgd */
35 1.1 cgd
36 1.1 cgd #include <sys/param.h>
37 1.1 cgd #include <sys/dir.h>
38 1.1 cgd #include <sys/stat.h>
39 1.1 cgd #include <sys/time.h>
40 1.1 cgd #include <sys/file.h>
41 1.1 cgd #include <netinet/in.h>
42 1.1 cgd #include <stdio.h>
43 1.1 cgd #include <ctype.h>
44 1.1 cgd #include <errno.h>
45 1.1 cgd #include <pwd.h>
46 1.1 cgd #include <grp.h>
47 1.1 cgd #include "pathnames.h"
48 1.1 cgd
49 1.1 cgd /*
50 1.1 cgd * The version number should be changed whenever the protocol changes.
51 1.1 cgd */
52 1.1 cgd #define VERSION 3
53 1.1 cgd
54 1.1 cgd /* defines for yacc */
55 1.1 cgd #define EQUAL 1
56 1.1 cgd #define LP 2
57 1.1 cgd #define RP 3
58 1.1 cgd #define SM 4
59 1.1 cgd #define ARROW 5
60 1.1 cgd #define COLON 6
61 1.1 cgd #define DCOLON 7
62 1.1 cgd #define NAME 8
63 1.1 cgd #define STRING 9
64 1.1 cgd #define INSTALL 10
65 1.1 cgd #define NOTIFY 11
66 1.1 cgd #define EXCEPT 12
67 1.1 cgd #define PATTERN 13
68 1.1 cgd #define SPECIAL 14
69 1.1 cgd #define OPTION 15
70 1.1 cgd
71 1.1 cgd /* lexical definitions */
72 1.1 cgd #define QUOTE 0200 /* used internally for quoted characters */
73 1.1 cgd #define TRIM 0177 /* Mask to strip quote bit */
74 1.1 cgd
75 1.1 cgd /* table sizes */
76 1.1 cgd #define HASHSIZE 1021
77 1.1 cgd #define INMAX 3500
78 1.1 cgd
79 1.1 cgd /* option flags */
80 1.1 cgd #define VERIFY 0x1
81 1.1 cgd #define WHOLE 0x2
82 1.1 cgd #define YOUNGER 0x4
83 1.1 cgd #define COMPARE 0x8
84 1.1 cgd #define REMOVE 0x10
85 1.1 cgd #define FOLLOW 0x20
86 1.1 cgd #define IGNLNKS 0x40
87 1.1 cgd
88 1.1 cgd /* expand type definitions */
89 1.1 cgd #define E_VARS 0x1
90 1.1 cgd #define E_SHELL 0x2
91 1.1 cgd #define E_TILDE 0x4
92 1.1 cgd #define E_ALL 0x7
93 1.1 cgd
94 1.1 cgd /* actions for lookup() */
95 1.1 cgd #define LOOKUP 0
96 1.1 cgd #define INSERT 1
97 1.1 cgd #define REPLACE 2
98 1.1 cgd
99 1.1 cgd #define ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
100 1.1 cgd
101 1.1 cgd #define ALLOC(x) (struct x *) malloc(sizeof(struct x))
102 1.1 cgd
103 1.1 cgd struct namelist { /* for making lists of strings */
104 1.1 cgd char *n_name;
105 1.1 cgd struct namelist *n_next;
106 1.1 cgd };
107 1.1 cgd
108 1.1 cgd struct subcmd {
109 1.1 cgd short sc_type; /* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */
110 1.1 cgd short sc_options;
111 1.1 cgd char *sc_name;
112 1.1 cgd struct namelist *sc_args;
113 1.1 cgd struct subcmd *sc_next;
114 1.1 cgd };
115 1.1 cgd
116 1.1 cgd struct cmd {
117 1.1 cgd int c_type; /* type - ARROW,DCOLON */
118 1.1 cgd char *c_name; /* hostname or time stamp file name */
119 1.1 cgd char *c_label; /* label for partial update */
120 1.1 cgd struct namelist *c_files;
121 1.1 cgd struct subcmd *c_cmds;
122 1.1 cgd struct cmd *c_next;
123 1.1 cgd };
124 1.1 cgd
125 1.1 cgd struct linkbuf {
126 1.1 cgd ino_t inum;
127 1.1 cgd dev_t devnum;
128 1.1 cgd int count;
129 1.1 cgd char pathname[BUFSIZ];
130 1.1 cgd char target[BUFSIZ];
131 1.1 cgd struct linkbuf *nextp;
132 1.1 cgd };
133 1.1 cgd
134 1.1 cgd extern int debug; /* debugging flag */
135 1.1 cgd extern int nflag; /* NOP flag, don't execute commands */
136 1.1 cgd extern int qflag; /* Quiet. don't print messages */
137 1.1 cgd extern int options; /* global options */
138 1.1 cgd
139 1.1 cgd extern int nerrs; /* number of errors seen */
140 1.1 cgd extern int rem; /* remote file descriptor */
141 1.1 cgd extern int iamremote; /* acting as remote server */
142 1.1 cgd extern char tempfile[]; /* file name for logging changes */
143 1.1 cgd extern struct linkbuf *ihead; /* list of files with more than one link */
144 1.1 cgd extern struct passwd *pw; /* pointer to static area used by getpwent */
145 1.1 cgd extern struct group *gr; /* pointer to static area used by getgrent */
146 1.1 cgd extern char host[]; /* host name of master copy */
147 1.1 cgd extern char buf[]; /* general purpose buffer */
148 1.1 cgd extern int errno; /* system error number */
149 1.1 cgd
150 1.1 cgd char *makestr();
151 1.1 cgd struct namelist *makenl();
152 1.1 cgd struct subcmd *makesubcmd();
153 1.1 cgd struct namelist *lookup();
154 1.1 cgd struct namelist *expand();
155 1.1 cgd char *exptilde();
156 1.1 cgd char *malloc();
157 1.1 cgd char *rindex();
158 1.1 cgd char *index();
159