xref: /titanic_51/usr/src/cmd/cmd-inet/usr.bin/rdist/defs.h (revision ace1a5f11236a072fca1b5e0ea1416a083a9f2aa)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * Copyright (c) 1983 Regents of the University of California.
37c478bd9Sstevel@tonic-gate  * All rights reserved.
47c478bd9Sstevel@tonic-gate  *
57c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
67c478bd9Sstevel@tonic-gate  * provided that the above copyright notice and this paragraph are
77c478bd9Sstevel@tonic-gate  * duplicated in all such forms and that any documentation,
87c478bd9Sstevel@tonic-gate  * advertising materials, and other materials related to such
97c478bd9Sstevel@tonic-gate  * distribution and use acknowledge that the software was developed
107c478bd9Sstevel@tonic-gate  * by the University of California, Berkeley.  The name of the
117c478bd9Sstevel@tonic-gate  * University may not be used to endorse or promote products derived
127c478bd9Sstevel@tonic-gate  * from this software without specific prior written permission.
137c478bd9Sstevel@tonic-gate  *
14*ace1a5f1Sdp  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
15*ace1a5f1Sdp  * Use is subject to license terms.
167c478bd9Sstevel@tonic-gate  */
17*ace1a5f1Sdp 
18*ace1a5f1Sdp #ifndef	_DEFS_H
19*ace1a5f1Sdp #define	_DEFS_H
20*ace1a5f1Sdp 
217c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
227c478bd9Sstevel@tonic-gate 
23*ace1a5f1Sdp #ifdef __cplusplus
24*ace1a5f1Sdp extern "C" {
25*ace1a5f1Sdp #endif
26*ace1a5f1Sdp 
277c478bd9Sstevel@tonic-gate #include <stdio.h>
287c478bd9Sstevel@tonic-gate #include <ctype.h>
297c478bd9Sstevel@tonic-gate #include <errno.h>
307c478bd9Sstevel@tonic-gate #include <pwd.h>
317c478bd9Sstevel@tonic-gate #include <grp.h>
327c478bd9Sstevel@tonic-gate #include <dirent.h>
33*ace1a5f1Sdp #include <strings.h>
347c478bd9Sstevel@tonic-gate #include <sys/types.h>
357c478bd9Sstevel@tonic-gate #include <sys/param.h>
367c478bd9Sstevel@tonic-gate #include <sys/stat.h>
377c478bd9Sstevel@tonic-gate #include <sys/time.h>
387c478bd9Sstevel@tonic-gate #include <netinet/in.h>
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate /*
417c478bd9Sstevel@tonic-gate  * The version number should be changed whenever the protocol changes.
427c478bd9Sstevel@tonic-gate  */
437c478bd9Sstevel@tonic-gate #define	VERSION	 3
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate #define	MAILCMD	 "/usr/lib/sendmail -oi -t"
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate 	/* defines for yacc */
487c478bd9Sstevel@tonic-gate #define	EQUAL	1
497c478bd9Sstevel@tonic-gate #define	LP	2
507c478bd9Sstevel@tonic-gate #define	RP	3
517c478bd9Sstevel@tonic-gate #define	SM	4
527c478bd9Sstevel@tonic-gate #define	ARROW	5
537c478bd9Sstevel@tonic-gate #define	COLON	6
547c478bd9Sstevel@tonic-gate #define	DCOLON	7
557c478bd9Sstevel@tonic-gate #define	NAME	8
567c478bd9Sstevel@tonic-gate #define	STRING	9
577c478bd9Sstevel@tonic-gate #define	INSTALL	10
587c478bd9Sstevel@tonic-gate #define	NOTIFY	11
597c478bd9Sstevel@tonic-gate #define	EXCEPT	12
607c478bd9Sstevel@tonic-gate #define	PATTERN	13
617c478bd9Sstevel@tonic-gate #define	SPECIAL	14
627c478bd9Sstevel@tonic-gate #define	OPTION	15
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate 	/* lexical definitions */
657c478bd9Sstevel@tonic-gate #define	QUOTE 	0200		/* used internally for quoted characters */
667c478bd9Sstevel@tonic-gate #define	TRIM	0177		/* Mask to strip quote bit */
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 	/* table sizes */
697c478bd9Sstevel@tonic-gate #define	HASHSIZE	1021
707c478bd9Sstevel@tonic-gate #define	INMAX	3500
717c478bd9Sstevel@tonic-gate #define	LINESIZE	BUFSIZ
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate 	/* option flags */
747c478bd9Sstevel@tonic-gate #define	VERIFY	0x1
757c478bd9Sstevel@tonic-gate #define	WHOLE	0x2
767c478bd9Sstevel@tonic-gate #define	YOUNGER	0x4
777c478bd9Sstevel@tonic-gate #define	COMPARE	0x8
787c478bd9Sstevel@tonic-gate #define	REMOVE	0x10
797c478bd9Sstevel@tonic-gate #define	FOLLOW	0x20
807c478bd9Sstevel@tonic-gate #define	IGNLNKS	0x40
817c478bd9Sstevel@tonic-gate #define	OBITS "\020\1VERIFY\2WHOLE\3YOUNGER\4COMPARE\5REMOVE\6FOLLOW\7IGNLNKS"
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate 	/* expand type definitions */
847c478bd9Sstevel@tonic-gate #define	E_VARS	0x1
857c478bd9Sstevel@tonic-gate #define	E_SHELL	0x2
867c478bd9Sstevel@tonic-gate #define	E_TILDE	0x4
877c478bd9Sstevel@tonic-gate #define	E_ALL	0x7
887c478bd9Sstevel@tonic-gate 
897c478bd9Sstevel@tonic-gate 	/* actions for lookup() */
907c478bd9Sstevel@tonic-gate #define	LOOKUP	0
917c478bd9Sstevel@tonic-gate #define	INSERT	1
927c478bd9Sstevel@tonic-gate #define	REPLACE	2
937c478bd9Sstevel@tonic-gate 
947c478bd9Sstevel@tonic-gate #define	ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
957c478bd9Sstevel@tonic-gate 
967c478bd9Sstevel@tonic-gate #define	ALLOC(x) (struct x *)malloc(sizeof (struct x))
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate struct namelist {	/* for making lists of strings */
997c478bd9Sstevel@tonic-gate 	char	*n_name;
1007c478bd9Sstevel@tonic-gate 	struct	namelist *n_next;
1017c478bd9Sstevel@tonic-gate };
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate struct subcmd {
1047c478bd9Sstevel@tonic-gate 	short	sc_type;	/* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */
1057c478bd9Sstevel@tonic-gate 	short	sc_options;
1067c478bd9Sstevel@tonic-gate 	char	*sc_name;
1077c478bd9Sstevel@tonic-gate 	struct	namelist *sc_args;
1087c478bd9Sstevel@tonic-gate 	struct	subcmd *sc_next;
1097c478bd9Sstevel@tonic-gate };
1107c478bd9Sstevel@tonic-gate 
1117c478bd9Sstevel@tonic-gate struct cmd {
1127c478bd9Sstevel@tonic-gate 	int	c_type;		/* type - ARROW,DCOLON */
1137c478bd9Sstevel@tonic-gate 	char	*c_name;	/* hostname or time stamp file name */
1147c478bd9Sstevel@tonic-gate 	char	*c_label;	/* label for partial update */
1157c478bd9Sstevel@tonic-gate 	struct	namelist *c_files;
1167c478bd9Sstevel@tonic-gate 	struct	subcmd *c_cmds;
1177c478bd9Sstevel@tonic-gate 	struct	cmd *c_next;
1187c478bd9Sstevel@tonic-gate };
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate struct linkbuf {
1217c478bd9Sstevel@tonic-gate 	ino_t	inum;
1227c478bd9Sstevel@tonic-gate 	dev_t	devnum;
1237c478bd9Sstevel@tonic-gate 	int	count;
1247c478bd9Sstevel@tonic-gate 	char	pathname[LINESIZE];
1257c478bd9Sstevel@tonic-gate 	char	target[LINESIZE];
1267c478bd9Sstevel@tonic-gate 	struct	linkbuf *nextp;
1277c478bd9Sstevel@tonic-gate };
1287c478bd9Sstevel@tonic-gate 
1297c478bd9Sstevel@tonic-gate extern int debug;		/* debugging flag */
1307c478bd9Sstevel@tonic-gate extern int nflag;		/* NOP flag, don't execute commands */
1317c478bd9Sstevel@tonic-gate extern int qflag;		/* Quiet. don't print messages */
1327c478bd9Sstevel@tonic-gate extern int options;		/* global options */
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate extern int nerrs;		/* number of errors seen */
1357c478bd9Sstevel@tonic-gate extern int rem;			/* remote file descriptor */
1367c478bd9Sstevel@tonic-gate extern int iamremote;		/* acting as remote server */
1377c478bd9Sstevel@tonic-gate extern char Tmpfile[];		/* file name for logging changes */
1387c478bd9Sstevel@tonic-gate extern struct linkbuf *ihead;	/* list of files with more than one link */
1397c478bd9Sstevel@tonic-gate extern struct passwd *pw;	/* pointer to static area used by getpwent */
1407c478bd9Sstevel@tonic-gate extern struct group *gr;	/* pointer to static area used by getgrent */
1417c478bd9Sstevel@tonic-gate extern char host[];		/* host name of master copy */
1427c478bd9Sstevel@tonic-gate extern char buf[];		/* general purpose buffer */
1437c478bd9Sstevel@tonic-gate 
1447c478bd9Sstevel@tonic-gate char *makestr();
1457c478bd9Sstevel@tonic-gate struct namelist *makenl();
1467c478bd9Sstevel@tonic-gate struct subcmd *makesubcmd();
1477c478bd9Sstevel@tonic-gate struct namelist *lookup();
1487c478bd9Sstevel@tonic-gate struct namelist *expand();
1497c478bd9Sstevel@tonic-gate char *exptilde();
1507c478bd9Sstevel@tonic-gate char *printb();
1517c478bd9Sstevel@tonic-gate void sendrem();
152*ace1a5f1Sdp 
153*ace1a5f1Sdp #ifdef __cplusplus
154*ace1a5f1Sdp }
155*ace1a5f1Sdp #endif
156*ace1a5f1Sdp 
157*ace1a5f1Sdp #endif	/* _DEFS_H */
158