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 21*ace1a5f1Sdp #ifdef __cplusplus 22*ace1a5f1Sdp extern "C" { 23*ace1a5f1Sdp #endif 24*ace1a5f1Sdp 257c478bd9Sstevel@tonic-gate #include <stdio.h> 267c478bd9Sstevel@tonic-gate #include <ctype.h> 277c478bd9Sstevel@tonic-gate #include <errno.h> 287c478bd9Sstevel@tonic-gate #include <pwd.h> 297c478bd9Sstevel@tonic-gate #include <grp.h> 307c478bd9Sstevel@tonic-gate #include <dirent.h> 31*ace1a5f1Sdp #include <strings.h> 327c478bd9Sstevel@tonic-gate #include <sys/types.h> 337c478bd9Sstevel@tonic-gate #include <sys/param.h> 347c478bd9Sstevel@tonic-gate #include <sys/stat.h> 357c478bd9Sstevel@tonic-gate #include <sys/time.h> 367c478bd9Sstevel@tonic-gate #include <netinet/in.h> 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate /* 397c478bd9Sstevel@tonic-gate * The version number should be changed whenever the protocol changes. 407c478bd9Sstevel@tonic-gate */ 41*ace1a5f1Sdp #define VERSION 3 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate #define MAILCMD "/usr/lib/sendmail -oi -t" 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* defines for yacc */ 46*ace1a5f1Sdp #define EQUAL 1 47*ace1a5f1Sdp #define LP 2 48*ace1a5f1Sdp #define RP 3 49*ace1a5f1Sdp #define SM 4 50*ace1a5f1Sdp #define ARROW 5 51*ace1a5f1Sdp #define COLON 6 52*ace1a5f1Sdp #define DCOLON 7 53*ace1a5f1Sdp #define NAME 8 54*ace1a5f1Sdp #define STRING 9 55*ace1a5f1Sdp #define INSTALL 10 56*ace1a5f1Sdp #define NOTIFY 11 57*ace1a5f1Sdp #define EXCEPT 12 58*ace1a5f1Sdp #define PATTERN 13 59*ace1a5f1Sdp #define SPECIAL 14 60*ace1a5f1Sdp #define OPTION 15 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate /* lexical definitions */ 637c478bd9Sstevel@tonic-gate #define QUOTE 0200 /* used internally for quoted characters */ 647c478bd9Sstevel@tonic-gate #define TRIM 0177 /* Mask to strip quote bit */ 657c478bd9Sstevel@tonic-gate 667c478bd9Sstevel@tonic-gate /* table sizes */ 67*ace1a5f1Sdp #define HASHSIZE 1021 68*ace1a5f1Sdp #define INMAX 3500 697c478bd9Sstevel@tonic-gate #define LINESIZE BUFSIZ 707c478bd9Sstevel@tonic-gate 717c478bd9Sstevel@tonic-gate /* option flags */ 72*ace1a5f1Sdp #define VERIFY 0x1 73*ace1a5f1Sdp #define WHOLE 0x2 74*ace1a5f1Sdp #define YOUNGER 0x4 75*ace1a5f1Sdp #define COMPARE 0x8 76*ace1a5f1Sdp #define REMOVE 0x10 77*ace1a5f1Sdp #define FOLLOW 0x20 78*ace1a5f1Sdp #define IGNLNKS 0x40 797c478bd9Sstevel@tonic-gate #define OBITS "\020\1VERIFY\2WHOLE\3YOUNGER\4COMPARE\5REMOVE\6FOLLOW\7IGNLNKS" 807c478bd9Sstevel@tonic-gate 817c478bd9Sstevel@tonic-gate /* expand type definitions */ 82*ace1a5f1Sdp #define E_VARS 0x1 83*ace1a5f1Sdp #define E_SHELL 0x2 84*ace1a5f1Sdp #define E_TILDE 0x4 85*ace1a5f1Sdp #define E_ALL 0x7 867c478bd9Sstevel@tonic-gate 877c478bd9Sstevel@tonic-gate /* actions for lookup() */ 88*ace1a5f1Sdp #define LOOKUP 0 89*ace1a5f1Sdp #define INSERT 1 90*ace1a5f1Sdp #define REPLACE 2 917c478bd9Sstevel@tonic-gate 92*ace1a5f1Sdp #define ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 937c478bd9Sstevel@tonic-gate 94*ace1a5f1Sdp #define ALLOC(x) (struct x *)malloc(sizeof (struct x)) 957c478bd9Sstevel@tonic-gate 967c478bd9Sstevel@tonic-gate struct namelist { /* for making lists of strings */ 977c478bd9Sstevel@tonic-gate char *n_name; 987c478bd9Sstevel@tonic-gate struct namelist *n_next; 997c478bd9Sstevel@tonic-gate }; 1007c478bd9Sstevel@tonic-gate 1017c478bd9Sstevel@tonic-gate struct subcmd { 1027c478bd9Sstevel@tonic-gate short sc_type; /* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */ 1037c478bd9Sstevel@tonic-gate short sc_options; 1047c478bd9Sstevel@tonic-gate char *sc_name; 1057c478bd9Sstevel@tonic-gate struct namelist *sc_args; 1067c478bd9Sstevel@tonic-gate struct subcmd *sc_next; 1077c478bd9Sstevel@tonic-gate }; 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate struct cmd { 1107c478bd9Sstevel@tonic-gate int c_type; /* type - ARROW,DCOLON */ 1117c478bd9Sstevel@tonic-gate char *c_name; /* hostname or time stamp file name */ 1127c478bd9Sstevel@tonic-gate char *c_label; /* label for partial update */ 1137c478bd9Sstevel@tonic-gate struct namelist *c_files; 1147c478bd9Sstevel@tonic-gate struct subcmd *c_cmds; 1157c478bd9Sstevel@tonic-gate struct cmd *c_next; 1167c478bd9Sstevel@tonic-gate }; 1177c478bd9Sstevel@tonic-gate 1187c478bd9Sstevel@tonic-gate struct linkbuf { 1197c478bd9Sstevel@tonic-gate ino_t inum; 1207c478bd9Sstevel@tonic-gate dev_t devnum; 1217c478bd9Sstevel@tonic-gate int count; 1227c478bd9Sstevel@tonic-gate char pathname[LINESIZE]; 1237c478bd9Sstevel@tonic-gate char target[LINESIZE]; 1247c478bd9Sstevel@tonic-gate struct linkbuf *nextp; 1257c478bd9Sstevel@tonic-gate }; 1267c478bd9Sstevel@tonic-gate 1277c478bd9Sstevel@tonic-gate extern int debug; /* debugging flag */ 1287c478bd9Sstevel@tonic-gate extern int nflag; /* NOP flag, don't execute commands */ 1297c478bd9Sstevel@tonic-gate extern int qflag; /* Quiet. don't print messages */ 1307c478bd9Sstevel@tonic-gate extern int options; /* global options */ 1317c478bd9Sstevel@tonic-gate 1327c478bd9Sstevel@tonic-gate extern int nerrs; /* number of errors seen */ 1337c478bd9Sstevel@tonic-gate extern int rem; /* remote file descriptor */ 1347c478bd9Sstevel@tonic-gate extern int iamremote; /* acting as remote server */ 1357c478bd9Sstevel@tonic-gate extern char Tmpfile[]; /* file name for logging changes */ 1367c478bd9Sstevel@tonic-gate extern struct linkbuf *ihead; /* list of files with more than one link */ 1377c478bd9Sstevel@tonic-gate extern struct passwd *pw; /* pointer to static area used by getpwent */ 1387c478bd9Sstevel@tonic-gate extern struct group *gr; /* pointer to static area used by getgrent */ 1397c478bd9Sstevel@tonic-gate extern char host[]; /* host name of master copy */ 1407c478bd9Sstevel@tonic-gate extern char buf[]; /* general purpose buffer */ 1417c478bd9Sstevel@tonic-gate 1427c478bd9Sstevel@tonic-gate char *makestr(); 1437c478bd9Sstevel@tonic-gate struct namelist *makenl(); 1447c478bd9Sstevel@tonic-gate struct subcmd *makesubcmd(); 1457c478bd9Sstevel@tonic-gate struct namelist *lookup(); 1467c478bd9Sstevel@tonic-gate struct namelist *expand(); 1477c478bd9Sstevel@tonic-gate char *exptilde(); 1487c478bd9Sstevel@tonic-gate char *printb(); 1497c478bd9Sstevel@tonic-gate void sendrem(); 150*ace1a5f1Sdp 151*ace1a5f1Sdp #ifdef __cplusplus 152*ace1a5f1Sdp } 153*ace1a5f1Sdp #endif 154*ace1a5f1Sdp 155*ace1a5f1Sdp #endif /* _DEFS_H */ 156