xref: /onnv-gate/usr/src/cmd/cmd-inet/usr.bin/rdist/defs.h (revision 634:263e46dc023d)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * Copyright (c) 1983 Regents of the University of California.
30Sstevel@tonic-gate  * All rights reserved.
40Sstevel@tonic-gate  *
50Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
60Sstevel@tonic-gate  * provided that the above copyright notice and this paragraph are
70Sstevel@tonic-gate  * duplicated in all such forms and that any documentation,
80Sstevel@tonic-gate  * advertising materials, and other materials related to such
90Sstevel@tonic-gate  * distribution and use acknowledge that the software was developed
100Sstevel@tonic-gate  * by the University of California, Berkeley.  The name of the
110Sstevel@tonic-gate  * University may not be used to endorse or promote products derived
120Sstevel@tonic-gate  * from this software without specific prior written permission.
130Sstevel@tonic-gate  *
14*634Sdp  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
15*634Sdp  * Use is subject to license terms.
160Sstevel@tonic-gate  */
17*634Sdp 
18*634Sdp #ifndef	_DEFS_H
19*634Sdp #define	_DEFS_H
20*634Sdp 
210Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
220Sstevel@tonic-gate 
23*634Sdp #ifdef __cplusplus
24*634Sdp extern "C" {
25*634Sdp #endif
26*634Sdp 
270Sstevel@tonic-gate #include <stdio.h>
280Sstevel@tonic-gate #include <ctype.h>
290Sstevel@tonic-gate #include <errno.h>
300Sstevel@tonic-gate #include <pwd.h>
310Sstevel@tonic-gate #include <grp.h>
320Sstevel@tonic-gate #include <dirent.h>
33*634Sdp #include <strings.h>
340Sstevel@tonic-gate #include <sys/types.h>
350Sstevel@tonic-gate #include <sys/param.h>
360Sstevel@tonic-gate #include <sys/stat.h>
370Sstevel@tonic-gate #include <sys/time.h>
380Sstevel@tonic-gate #include <netinet/in.h>
390Sstevel@tonic-gate 
400Sstevel@tonic-gate /*
410Sstevel@tonic-gate  * The version number should be changed whenever the protocol changes.
420Sstevel@tonic-gate  */
43*634Sdp #define	VERSION	 3
440Sstevel@tonic-gate 
450Sstevel@tonic-gate #define	MAILCMD	 "/usr/lib/sendmail -oi -t"
460Sstevel@tonic-gate 
470Sstevel@tonic-gate 	/* defines for yacc */
48*634Sdp #define	EQUAL	1
49*634Sdp #define	LP	2
50*634Sdp #define	RP	3
51*634Sdp #define	SM	4
52*634Sdp #define	ARROW	5
53*634Sdp #define	COLON	6
54*634Sdp #define	DCOLON	7
55*634Sdp #define	NAME	8
56*634Sdp #define	STRING	9
57*634Sdp #define	INSTALL	10
58*634Sdp #define	NOTIFY	11
59*634Sdp #define	EXCEPT	12
60*634Sdp #define	PATTERN	13
61*634Sdp #define	SPECIAL	14
62*634Sdp #define	OPTION	15
630Sstevel@tonic-gate 
640Sstevel@tonic-gate 	/* lexical definitions */
650Sstevel@tonic-gate #define	QUOTE 	0200		/* used internally for quoted characters */
660Sstevel@tonic-gate #define	TRIM	0177		/* Mask to strip quote bit */
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	/* table sizes */
69*634Sdp #define	HASHSIZE	1021
70*634Sdp #define	INMAX	3500
710Sstevel@tonic-gate #define	LINESIZE	BUFSIZ
720Sstevel@tonic-gate 
730Sstevel@tonic-gate 	/* option flags */
74*634Sdp #define	VERIFY	0x1
75*634Sdp #define	WHOLE	0x2
76*634Sdp #define	YOUNGER	0x4
77*634Sdp #define	COMPARE	0x8
78*634Sdp #define	REMOVE	0x10
79*634Sdp #define	FOLLOW	0x20
80*634Sdp #define	IGNLNKS	0x40
810Sstevel@tonic-gate #define	OBITS "\020\1VERIFY\2WHOLE\3YOUNGER\4COMPARE\5REMOVE\6FOLLOW\7IGNLNKS"
820Sstevel@tonic-gate 
830Sstevel@tonic-gate 	/* expand type definitions */
84*634Sdp #define	E_VARS	0x1
85*634Sdp #define	E_SHELL	0x2
86*634Sdp #define	E_TILDE	0x4
87*634Sdp #define	E_ALL	0x7
880Sstevel@tonic-gate 
890Sstevel@tonic-gate 	/* actions for lookup() */
90*634Sdp #define	LOOKUP	0
91*634Sdp #define	INSERT	1
92*634Sdp #define	REPLACE	2
930Sstevel@tonic-gate 
94*634Sdp #define	ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
950Sstevel@tonic-gate 
96*634Sdp #define	ALLOC(x) (struct x *)malloc(sizeof (struct x))
970Sstevel@tonic-gate 
980Sstevel@tonic-gate struct namelist {	/* for making lists of strings */
990Sstevel@tonic-gate 	char	*n_name;
1000Sstevel@tonic-gate 	struct	namelist *n_next;
1010Sstevel@tonic-gate };
1020Sstevel@tonic-gate 
1030Sstevel@tonic-gate struct subcmd {
1040Sstevel@tonic-gate 	short	sc_type;	/* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */
1050Sstevel@tonic-gate 	short	sc_options;
1060Sstevel@tonic-gate 	char	*sc_name;
1070Sstevel@tonic-gate 	struct	namelist *sc_args;
1080Sstevel@tonic-gate 	struct	subcmd *sc_next;
1090Sstevel@tonic-gate };
1100Sstevel@tonic-gate 
1110Sstevel@tonic-gate struct cmd {
1120Sstevel@tonic-gate 	int	c_type;		/* type - ARROW,DCOLON */
1130Sstevel@tonic-gate 	char	*c_name;	/* hostname or time stamp file name */
1140Sstevel@tonic-gate 	char	*c_label;	/* label for partial update */
1150Sstevel@tonic-gate 	struct	namelist *c_files;
1160Sstevel@tonic-gate 	struct	subcmd *c_cmds;
1170Sstevel@tonic-gate 	struct	cmd *c_next;
1180Sstevel@tonic-gate };
1190Sstevel@tonic-gate 
1200Sstevel@tonic-gate struct linkbuf {
1210Sstevel@tonic-gate 	ino_t	inum;
1220Sstevel@tonic-gate 	dev_t	devnum;
1230Sstevel@tonic-gate 	int	count;
1240Sstevel@tonic-gate 	char	pathname[LINESIZE];
1250Sstevel@tonic-gate 	char	target[LINESIZE];
1260Sstevel@tonic-gate 	struct	linkbuf *nextp;
1270Sstevel@tonic-gate };
1280Sstevel@tonic-gate 
1290Sstevel@tonic-gate extern int debug;		/* debugging flag */
1300Sstevel@tonic-gate extern int nflag;		/* NOP flag, don't execute commands */
1310Sstevel@tonic-gate extern int qflag;		/* Quiet. don't print messages */
1320Sstevel@tonic-gate extern int options;		/* global options */
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate extern int nerrs;		/* number of errors seen */
1350Sstevel@tonic-gate extern int rem;			/* remote file descriptor */
1360Sstevel@tonic-gate extern int iamremote;		/* acting as remote server */
1370Sstevel@tonic-gate extern char Tmpfile[];		/* file name for logging changes */
1380Sstevel@tonic-gate extern struct linkbuf *ihead;	/* list of files with more than one link */
1390Sstevel@tonic-gate extern struct passwd *pw;	/* pointer to static area used by getpwent */
1400Sstevel@tonic-gate extern struct group *gr;	/* pointer to static area used by getgrent */
1410Sstevel@tonic-gate extern char host[];		/* host name of master copy */
1420Sstevel@tonic-gate extern char buf[];		/* general purpose buffer */
1430Sstevel@tonic-gate 
1440Sstevel@tonic-gate char *makestr();
1450Sstevel@tonic-gate struct namelist *makenl();
1460Sstevel@tonic-gate struct subcmd *makesubcmd();
1470Sstevel@tonic-gate struct namelist *lookup();
1480Sstevel@tonic-gate struct namelist *expand();
1490Sstevel@tonic-gate char *exptilde();
1500Sstevel@tonic-gate char *printb();
1510Sstevel@tonic-gate void sendrem();
152*634Sdp 
153*634Sdp #ifdef __cplusplus
154*634Sdp }
155*634Sdp #endif
156*634Sdp 
157*634Sdp #endif	/* _DEFS_H */
158