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