Home | History | Annotate | Line # | Download | only in rdist
defs.h revision 1.12
      1  1.12  christos /*	$NetBSD: defs.h,v 1.12 1998/12/19 20:32:17 christos Exp $	*/
      2   1.7   thorpej 
      3   1.1       cgd /*
      4   1.5       cgd  * Copyright (c) 1983, 1993
      5   1.5       cgd  *	The Regents of the University of California.  All rights reserved.
      6   1.1       cgd  *
      7   1.1       cgd  * Redistribution and use in source and binary forms, with or without
      8   1.1       cgd  * modification, are permitted provided that the following conditions
      9   1.1       cgd  * are met:
     10   1.1       cgd  * 1. Redistributions of source code must retain the above copyright
     11   1.1       cgd  *    notice, this list of conditions and the following disclaimer.
     12   1.1       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     13   1.1       cgd  *    notice, this list of conditions and the following disclaimer in the
     14   1.1       cgd  *    documentation and/or other materials provided with the distribution.
     15   1.1       cgd  * 3. All advertising materials mentioning features or use of this software
     16   1.1       cgd  *    must display the following acknowledgement:
     17   1.1       cgd  *	This product includes software developed by the University of
     18   1.1       cgd  *	California, Berkeley and its contributors.
     19   1.1       cgd  * 4. Neither the name of the University nor the names of its contributors
     20   1.1       cgd  *    may be used to endorse or promote products derived from this software
     21   1.1       cgd  *    without specific prior written permission.
     22   1.1       cgd  *
     23   1.1       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     24   1.1       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     25   1.1       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     26   1.1       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     27   1.1       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     28   1.1       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     29   1.1       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     30   1.1       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     31   1.1       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     32   1.1       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     33   1.1       cgd  * SUCH DAMAGE.
     34   1.1       cgd  *
     35   1.5       cgd  *	from: @(#)defs.h	8.1 (Berkeley) 6/9/93
     36   1.1       cgd  */
     37   1.1       cgd 
     38   1.1       cgd #include <sys/param.h>
     39   1.1       cgd #include <sys/stat.h>
     40   1.1       cgd #include <sys/time.h>
     41   1.1       cgd #include <sys/file.h>
     42   1.5       cgd 
     43   1.1       cgd #include <netinet/in.h>
     44   1.5       cgd 
     45   1.5       cgd #include <stdio.h>
     46   1.5       cgd #include <ctype.h>
     47   1.5       cgd #include <unistd.h>
     48   1.5       cgd #include <string.h>
     49   1.5       cgd #include <stdlib.h>
     50  1.12  christos #include <dirent.h>
     51  1.11    kleink #include <time.h>
     52   1.8       mrg 
     53   1.1       cgd #include "pathnames.h"
     54   1.1       cgd 
     55   1.1       cgd /*
     56   1.1       cgd  * The version number should be changed whenever the protocol changes.
     57   1.1       cgd  */
     58   1.1       cgd #define VERSION	 3
     59   1.1       cgd 
     60   1.1       cgd 	/* defines for yacc */
     61   1.1       cgd #define EQUAL	1
     62   1.1       cgd #define LP	2
     63   1.1       cgd #define RP	3
     64   1.1       cgd #define SM	4
     65   1.1       cgd #define ARROW	5
     66   1.1       cgd #define COLON	6
     67   1.1       cgd #define DCOLON	7
     68   1.1       cgd #define NAME	8
     69   1.1       cgd #define STRING	9
     70   1.1       cgd #define INSTALL	10
     71   1.1       cgd #define NOTIFY	11
     72   1.1       cgd #define EXCEPT	12
     73   1.1       cgd #define PATTERN	13
     74   1.1       cgd #define SPECIAL	14
     75   1.1       cgd #define OPTION	15
     76   1.1       cgd 
     77   1.1       cgd 	/* lexical definitions */
     78   1.1       cgd #define	QUOTE 	0200		/* used internally for quoted characters */
     79   1.1       cgd #define	TRIM	0177		/* Mask to strip quote bit */
     80   1.1       cgd 
     81   1.1       cgd 	/* table sizes */
     82   1.1       cgd #define HASHSIZE	1021
     83   1.1       cgd #define INMAX	3500
     84   1.1       cgd 
     85   1.1       cgd 	/* option flags */
     86   1.1       cgd #define VERIFY	0x1
     87   1.1       cgd #define WHOLE	0x2
     88   1.1       cgd #define YOUNGER	0x4
     89   1.1       cgd #define COMPARE	0x8
     90   1.1       cgd #define REMOVE	0x10
     91   1.1       cgd #define FOLLOW	0x20
     92   1.1       cgd #define IGNLNKS	0x40
     93   1.1       cgd 
     94   1.1       cgd 	/* expand type definitions */
     95   1.1       cgd #define E_VARS	0x1
     96   1.1       cgd #define E_SHELL	0x2
     97   1.1       cgd #define E_TILDE	0x4
     98   1.1       cgd #define E_ALL	0x7
     99   1.1       cgd 
    100   1.1       cgd 	/* actions for lookup() */
    101   1.1       cgd #define LOOKUP	0
    102   1.1       cgd #define INSERT	1
    103   1.1       cgd #define REPLACE	2
    104   1.1       cgd 
    105   1.1       cgd #define ALLOC(x) (struct x *) malloc(sizeof(struct x))
    106   1.1       cgd 
    107   1.1       cgd struct namelist {	/* for making lists of strings */
    108   1.1       cgd 	char	*n_name;
    109   1.1       cgd 	struct	namelist *n_next;
    110   1.1       cgd };
    111   1.1       cgd 
    112   1.1       cgd struct subcmd {
    113   1.1       cgd 	short	sc_type;	/* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */
    114   1.1       cgd 	short	sc_options;
    115   1.1       cgd 	char	*sc_name;
    116   1.1       cgd 	struct	namelist *sc_args;
    117   1.1       cgd 	struct	subcmd *sc_next;
    118   1.1       cgd };
    119   1.1       cgd 
    120   1.1       cgd struct cmd {
    121   1.1       cgd 	int	c_type;		/* type - ARROW,DCOLON */
    122   1.1       cgd 	char	*c_name;	/* hostname or time stamp file name */
    123   1.1       cgd 	char	*c_label;	/* label for partial update */
    124   1.1       cgd 	struct	namelist *c_files;
    125   1.1       cgd 	struct	subcmd *c_cmds;
    126   1.1       cgd 	struct	cmd *c_next;
    127   1.1       cgd };
    128   1.1       cgd 
    129   1.1       cgd struct linkbuf {
    130   1.1       cgd 	ino_t	inum;
    131   1.1       cgd 	dev_t	devnum;
    132   1.1       cgd 	int	count;
    133   1.1       cgd 	char	pathname[BUFSIZ];
    134   1.1       cgd 	char	target[BUFSIZ];
    135   1.1       cgd 	struct	linkbuf *nextp;
    136   1.1       cgd };
    137   1.1       cgd 
    138   1.1       cgd extern int debug;		/* debugging flag */
    139   1.1       cgd extern int nflag;		/* NOP flag, don't execute commands */
    140   1.1       cgd extern int qflag;		/* Quiet. don't print messages */
    141   1.1       cgd extern int options;		/* global options */
    142   1.1       cgd 
    143   1.1       cgd extern int nerrs;		/* number of errors seen */
    144   1.1       cgd extern int rem;			/* remote file descriptor */
    145   1.1       cgd extern int iamremote;		/* acting as remote server */
    146   1.1       cgd extern char tempfile[];		/* file name for logging changes */
    147   1.1       cgd extern struct linkbuf *ihead;	/* list of files with more than one link */
    148   1.9   mycroft extern char host[];		/* host name of master copy */
    149   1.9   mycroft extern char buf[BUFSIZ];	/* general purpose buffer */
    150   1.9   mycroft 
    151   1.1       cgd extern struct passwd *pw;	/* pointer to static area used by getpwent */
    152   1.1       cgd extern struct group *gr;	/* pointer to static area used by getgrent */
    153   1.9   mycroft extern uid_t userid;		/* user's user ID */
    154   1.9   mycroft extern gid_t groupid;		/* user's group ID */
    155   1.1       cgd 
    156   1.5       cgd int	 any __P((int, char *));
    157   1.5       cgd char	*colon __P((char *));
    158   1.5       cgd void	 cleanup __P((int));
    159   1.5       cgd void	 define __P((char *));
    160   1.5       cgd void	 docmds __P((char **, int, char **));
    161   1.5       cgd void	 error __P((const char *, ...));
    162   1.5       cgd int	 except __P((char *));
    163   1.5       cgd struct namelist *
    164   1.5       cgd 	 expand __P((struct namelist *, int));
    165   1.5       cgd char	*exptilde __P((char [], char *));
    166   1.5       cgd void	 fatal __P((const char *, ...));
    167   1.5       cgd int	 inlist __P((struct namelist *, char *));
    168   1.5       cgd void	 insert __P((char *,
    169   1.5       cgd 	    struct namelist *, struct namelist *, struct subcmd *));
    170   1.5       cgd void	 install __P((char *, char *, int, int));
    171   1.5       cgd void	 log __P((FILE *, const char *, ...));
    172   1.5       cgd struct namelist *
    173   1.5       cgd 	 lookup __P((char *, int, struct namelist *));
    174   1.5       cgd void	 lostconn __P((int));
    175   1.5       cgd struct namelist *
    176   1.5       cgd 	 makenl __P((char *));
    177   1.5       cgd struct subcmd *
    178   1.5       cgd 	 makesubcmd __P((int));
    179   1.5       cgd void	 prnames __P((struct namelist *));
    180   1.5       cgd void	 server __P((void));
    181   1.5       cgd void	 yyerror __P((char *));
    182   1.5       cgd int	 yyparse __P((void));
    183