xref: /original-bsd/usr.bin/rdist/defs.h (revision d45fc766)
1 /*
2  * Copyright (c) 1983, 1993
3  *	The Regents of the University of California.  All rights reserved.
4  *
5  * %sccs.include.redist.c%
6  *
7  *	@(#)defs.h	8.1 (Berkeley) 06/09/93
8  */
9 
10 #include <sys/param.h>
11 #include <sys/dir.h>
12 #include <sys/stat.h>
13 #include <sys/time.h>
14 #include <sys/file.h>
15 
16 #include <netinet/in.h>
17 
18 #include <errno.h>
19 #include <pwd.h>
20 #include <grp.h>
21 #include <stdio.h>
22 #include <ctype.h>
23 #include <unistd.h>
24 #include <string.h>
25 #include <stdlib.h>
26 #include "pathnames.h"
27 
28 /*
29  * The version number should be changed whenever the protocol changes.
30  */
31 #define VERSION	 3
32 
33 	/* defines for yacc */
34 #define EQUAL	1
35 #define LP	2
36 #define RP	3
37 #define SM	4
38 #define ARROW	5
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
46 #define PATTERN	13
47 #define SPECIAL	14
48 #define OPTION	15
49 
50 	/* lexical definitions */
51 #define	QUOTE 	0200		/* used internally for quoted characters */
52 #define	TRIM	0177		/* Mask to strip quote bit */
53 
54 	/* table sizes */
55 #define HASHSIZE	1021
56 #define INMAX	3500
57 
58 	/* option flags */
59 #define VERIFY	0x1
60 #define WHOLE	0x2
61 #define YOUNGER	0x4
62 #define COMPARE	0x8
63 #define REMOVE	0x10
64 #define FOLLOW	0x20
65 #define IGNLNKS	0x40
66 
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 
73 	/* actions for lookup() */
74 #define LOOKUP	0
75 #define INSERT	1
76 #define REPLACE	2
77 
78 #define ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
79 
80 #define ALLOC(x) (struct x *) malloc(sizeof(struct x))
81 
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;
93 };
94 
95 struct cmd {
96 	int	c_type;		/* type - ARROW,DCOLON */
97 	char	*c_name;	/* hostname or time stamp file name */
98 	char	*c_label;	/* label for partial update */
99 	struct	namelist *c_files;
100 	struct	subcmd *c_cmds;
101 	struct	cmd *c_next;
102 };
103 
104 struct linkbuf {
105 	ino_t	inum;
106 	dev_t	devnum;
107 	int	count;
108 	char	pathname[BUFSIZ];
109 	char	target[BUFSIZ];
110 	struct	linkbuf *nextp;
111 };
112 
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 */
116 extern int options;		/* global options */
117 
118 extern int nerrs;		/* number of errors seen */
119 extern int rem;			/* remote file descriptor */
120 extern int iamremote;		/* acting as remote server */
121 extern char tempfile[];		/* file name for logging changes */
122 extern struct linkbuf *ihead;	/* list of files with more than one link */
123 extern struct passwd *pw;	/* pointer to static area used by getpwent */
124 extern struct group *gr;	/* pointer to static area used by getgrent */
125 extern char host[];		/* host name of master copy */
126 extern char buf[];		/* general purpose buffer */
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));
155