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