xref: /original-bsd/usr.bin/rdist/defs.h (revision 83e03edb)
1 /*
2  * Copyright (c) 1983 Regents of the University of California.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms are permitted
6  * provided that the above copyright notice and this paragraph are
7  * duplicated in all such forms and that any documentation,
8  * advertising materials, and other materials related to such
9  * distribution and use acknowledge that the software was developed
10  * by the University of California, Berkeley.  The name of the
11  * University may not be used to endorse or promote products derived
12  * from this software without specific prior written permission.
13  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  *	@(#)defs.h	5.4 (Berkeley) 06/29/88
18  */
19 
20 #include <stdio.h>
21 #include <ctype.h>
22 #include <errno.h>
23 #include <pwd.h>
24 #include <grp.h>
25 #include <sys/param.h>
26 #include <sys/dir.h>
27 #include <sys/stat.h>
28 #include <sys/time.h>
29 #include <netinet/in.h>
30 
31 /*
32  * The version number should be changed whenever the protocol changes.
33  */
34 #define VERSION	 3
35 
36 #define	MAILCMD	 "/usr/lib/sendmail -oi -t"
37 
38 	/* defines for yacc */
39 #define EQUAL	1
40 #define LP	2
41 #define RP	3
42 #define SM	4
43 #define ARROW	5
44 #define COLON	6
45 #define DCOLON	7
46 #define NAME	8
47 #define STRING	9
48 #define INSTALL	10
49 #define NOTIFY	11
50 #define EXCEPT	12
51 #define PATTERN	13
52 #define SPECIAL	14
53 #define OPTION	15
54 
55 	/* lexical definitions */
56 #define	QUOTE 	0200		/* used internally for quoted characters */
57 #define	TRIM	0177		/* Mask to strip quote bit */
58 
59 	/* table sizes */
60 #define HASHSIZE	1021
61 #define INMAX	3500
62 
63 	/* option flags */
64 #define VERIFY	0x1
65 #define WHOLE	0x2
66 #define YOUNGER	0x4
67 #define COMPARE	0x8
68 #define REMOVE	0x10
69 #define FOLLOW	0x20
70 #define IGNLNKS	0x40
71 
72 	/* expand type definitions */
73 #define E_VARS	0x1
74 #define E_SHELL	0x2
75 #define E_TILDE	0x4
76 #define E_ALL	0x7
77 
78 	/* actions for lookup() */
79 #define LOOKUP	0
80 #define INSERT	1
81 #define REPLACE	2
82 
83 #define ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
84 
85 #define ALLOC(x) (struct x *) malloc(sizeof(struct x))
86 
87 struct namelist {	/* for making lists of strings */
88 	char	*n_name;
89 	struct	namelist *n_next;
90 };
91 
92 struct subcmd {
93 	short	sc_type;	/* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */
94 	short	sc_options;
95 	char	*sc_name;
96 	struct	namelist *sc_args;
97 	struct	subcmd *sc_next;
98 };
99 
100 struct cmd {
101 	int	c_type;		/* type - ARROW,DCOLON */
102 	char	*c_name;	/* hostname or time stamp file name */
103 	char	*c_label;	/* label for partial update */
104 	struct	namelist *c_files;
105 	struct	subcmd *c_cmds;
106 	struct	cmd *c_next;
107 };
108 
109 struct linkbuf {
110 	ino_t	inum;
111 	dev_t	devnum;
112 	int	count;
113 	char	pathname[BUFSIZ];
114 	char	target[BUFSIZ];
115 	struct	linkbuf *nextp;
116 };
117 
118 extern int debug;		/* debugging flag */
119 extern int nflag;		/* NOP flag, don't execute commands */
120 extern int qflag;		/* Quiet. don't print messages */
121 extern int options;		/* global options */
122 
123 extern int nerrs;		/* number of errors seen */
124 extern int rem;			/* remote file descriptor */
125 extern int iamremote;		/* acting as remote server */
126 extern char tmpfile[];		/* file name for logging changes */
127 extern struct linkbuf *ihead;	/* list of files with more than one link */
128 extern struct passwd *pw;	/* pointer to static area used by getpwent */
129 extern struct group *gr;	/* pointer to static area used by getgrent */
130 extern char host[];		/* host name of master copy */
131 extern char buf[];		/* general purpose buffer */
132 extern int errno;		/* system error number */
133 extern char *sys_errlist[];
134 
135 char *makestr();
136 struct namelist *makenl();
137 struct subcmd *makesubcmd();
138 struct namelist *lookup();
139 struct namelist *expand();
140 char *exptilde();
141 char *malloc();
142 char *rindex();
143 char *index();
144