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