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