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