1*50348693Sjmc /* $OpenBSD: client.h,v 1.4 2021/06/22 20:19:28 jmc Exp $ */ 2e06ba677Sguenther 3e06ba677Sguenther #ifndef __CLIENT_H__ 4e06ba677Sguenther #define __CLIENT_H__ 5e06ba677Sguenther /* 6e06ba677Sguenther * Copyright (c) 1983 Regents of the University of California. 7e06ba677Sguenther * All rights reserved. 8e06ba677Sguenther * 9e06ba677Sguenther * Redistribution and use in source and binary forms, with or without 10e06ba677Sguenther * modification, are permitted provided that the following conditions 11e06ba677Sguenther * are met: 12e06ba677Sguenther * 1. Redistributions of source code must retain the above copyright 13e06ba677Sguenther * notice, this list of conditions and the following disclaimer. 14e06ba677Sguenther * 2. Redistributions in binary form must reproduce the above copyright 15e06ba677Sguenther * notice, this list of conditions and the following disclaimer in the 16e06ba677Sguenther * documentation and/or other materials provided with the distribution. 17e06ba677Sguenther * 3. Neither the name of the University nor the names of its contributors 18e06ba677Sguenther * may be used to endorse or promote products derived from this software 19e06ba677Sguenther * without specific prior written permission. 20e06ba677Sguenther * 21e06ba677Sguenther * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22e06ba677Sguenther * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23e06ba677Sguenther * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24e06ba677Sguenther * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25e06ba677Sguenther * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26e06ba677Sguenther * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27e06ba677Sguenther * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28e06ba677Sguenther * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29e06ba677Sguenther * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30e06ba677Sguenther * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31e06ba677Sguenther * SUCH DAMAGE. 32e06ba677Sguenther */ 33e06ba677Sguenther 34e06ba677Sguenther /* 35e06ba677Sguenther * $From: defs.h,v 1.6 2001/03/12 18:16:30 kim Exp $ 36e06ba677Sguenther * @(#)defs.h 5.2 (Berkeley) 3/20/86 37e06ba677Sguenther */ 38e06ba677Sguenther 39e06ba677Sguenther #include <sys/stat.h> 40e06ba677Sguenther #include <regex.h> 41e06ba677Sguenther #include <stdio.h> 42e06ba677Sguenther 43e06ba677Sguenther #include "defs.h" 44e06ba677Sguenther 45e06ba677Sguenther /* lexical definitions */ 461e1ef4e9Sotto #define QUOTECHAR 160U /* quote next character */ 47e06ba677Sguenther 48e06ba677Sguenther /* table sizes */ 49e06ba677Sguenther #define HASHSIZE 1021 50e06ba677Sguenther #define INMAX 3500 51e06ba677Sguenther 52e06ba677Sguenther /* expand type definitions */ 53e06ba677Sguenther #define E_VARS 0x1 54e06ba677Sguenther #define E_SHELL 0x2 55e06ba677Sguenther #define E_TILDE 0x4 56e06ba677Sguenther #define E_ALL 0x7 57e06ba677Sguenther 58e06ba677Sguenther /* actions for lookup() */ 59e06ba677Sguenther #define LOOKUP 0 60e06ba677Sguenther #define INSERT 1 61e06ba677Sguenther #define REPLACE 2 62e06ba677Sguenther 63b9846a0eSmmcc #define ALLOC(x) xmalloc(sizeof(struct x)) 64e06ba677Sguenther #define A(s) ((s) ? s : "<null>") 65e06ba677Sguenther 66e06ba677Sguenther 67e06ba677Sguenther #define COMMENT_CHAR '#' /* Config file comment char */ 68e06ba677Sguenther 69e06ba677Sguenther 70e06ba677Sguenther /* 71e06ba677Sguenther * Name list 72e06ba677Sguenther */ 73e06ba677Sguenther struct namelist { /* for making lists of strings */ 74e06ba677Sguenther char *n_name; 75e06ba677Sguenther regex_t *n_regex; 76e06ba677Sguenther struct namelist *n_next; 77e06ba677Sguenther }; 78e06ba677Sguenther 79e06ba677Sguenther /* 80e06ba677Sguenther * Sub command structure 81e06ba677Sguenther */ 82e06ba677Sguenther struct subcmd { 83e06ba677Sguenther short sc_type; /* type - INSTALL,NOTIFY,EXCEPT,SPECIAL */ 84e06ba677Sguenther opt_t sc_options; 85e06ba677Sguenther char *sc_name; 86e06ba677Sguenther struct namelist *sc_args; 87e06ba677Sguenther struct subcmd *sc_next; 88e06ba677Sguenther }; 89e06ba677Sguenther 90e06ba677Sguenther /* 91e06ba677Sguenther * Cmd flags 92e06ba677Sguenther */ 93e06ba677Sguenther #define CMD_ASSIGNED 0x01 /* This entry has been assigned */ 94e06ba677Sguenther #define CMD_CONNFAILED 0x02 /* Connection failed */ 95e06ba677Sguenther #define CMD_NOCHKNFS 0x04 /* Disable NFS checks */ 96e06ba677Sguenther 97e06ba677Sguenther /* 98e06ba677Sguenther * General command structure 99e06ba677Sguenther */ 100e06ba677Sguenther struct cmd { 101e06ba677Sguenther int c_type; /* type - ARROW,DCOLON */ 102e06ba677Sguenther int c_flags; /* flags - CMD_USED,CMD_FAILED */ 103e06ba677Sguenther char *c_name; /* hostname or time stamp file name */ 104e06ba677Sguenther char *c_label; /* label for partial update */ 105e06ba677Sguenther struct namelist *c_files; 106e06ba677Sguenther struct subcmd *c_cmds; 107e06ba677Sguenther struct cmd *c_next; 108e06ba677Sguenther }; 109e06ba677Sguenther 110e06ba677Sguenther /* 111e06ba677Sguenther * Hard link buffer information 112e06ba677Sguenther */ 113e06ba677Sguenther struct linkbuf { 114e06ba677Sguenther ino_t inum; 115e06ba677Sguenther dev_t devnum; 116e06ba677Sguenther int count; 117e06ba677Sguenther char *pathname; 118e06ba677Sguenther char *src; 119e06ba677Sguenther char *target; 120e06ba677Sguenther struct linkbuf *nextp; 121e06ba677Sguenther }; 122e06ba677Sguenther 123e06ba677Sguenther extern char *path_remsh; /* Remote shell command */ 124e06ba677Sguenther extern char host[]; /* Host name of master copy */ 125e06ba677Sguenther extern char **realargv; /* Real argv */ 126e06ba677Sguenther extern char *homedir; /* User's $HOME */ 127e06ba677Sguenther extern int do_fork; /* Should we do fork()'ing */ 128e06ba677Sguenther extern int nflag; /* NOP flag, don't execute commands */ 129e06ba677Sguenther extern int realargc; /* Real argc */ 130e06ba677Sguenther extern int setjmp_ok; /* setjmp/longjmp flag */ 131e06ba677Sguenther extern int maxchildren; /* Max active children */ 132e06ba677Sguenther extern int64_t min_freespace; /* Min filesys free space */ 133e06ba677Sguenther extern int64_t min_freefiles; /* Min filesys free # files */ 134e06ba677Sguenther extern struct linkbuf *ihead; /* list of files with more than one link */ 135e06ba677Sguenther extern struct subcmd *subcmds;/* list of sub-commands for current cmd */ 136e06ba677Sguenther extern struct namelist *filelist; /* list of source files */ 137e06ba677Sguenther extern struct cmd *cmds; /* Initialized by yyparse() */ 138e06ba677Sguenther 139e06ba677Sguenther extern char target[BUFSIZ]; /* target/source directory name */ 140e06ba677Sguenther extern char *ptarget; /* pointer to end of target name */ 141e06ba677Sguenther extern int activechildren; /* Number of active children */ 142e06ba677Sguenther extern int amchild; /* This PID is a child */ 143e06ba677Sguenther extern char *path_rdistd; 144e06ba677Sguenther extern char *remotemsglist; 145e06ba677Sguenther 146e06ba677Sguenther /* 147e06ba677Sguenther * Our own declarations. 148e06ba677Sguenther */ 149e06ba677Sguenther 150e06ba677Sguenther /* child.c */ 151e06ba677Sguenther void waitup(void); 152e06ba677Sguenther int spawn(struct cmd *, struct cmd *); 153e06ba677Sguenther 154e06ba677Sguenther /* client.c */ 155e06ba677Sguenther char *remfilename(char *, char *, char *, char *, int); 156e06ba677Sguenther int inlist(struct namelist *, char *); 157e06ba677Sguenther void runcmdspecial(struct cmd *, opt_t); 158e06ba677Sguenther int checkfilename(char *); 159e06ba677Sguenther void freelinkinfo(struct linkbuf *); 160e06ba677Sguenther int install(char *, char *, int, int , opt_t); 161e06ba677Sguenther 162e06ba677Sguenther /* distopt.c */ 163e06ba677Sguenther int parsedistopts(char *, opt_t *, int); 164e06ba677Sguenther char *getondistoptlist(opt_t); 165e06ba677Sguenther 166e06ba677Sguenther /* docmd.c */ 167e06ba677Sguenther void markassigned(struct cmd *, struct cmd *); 168e06ba677Sguenther int okname(char *); 169e06ba677Sguenther int except(char *); 170e06ba677Sguenther void docmds(struct namelist *, int, char **); 171e06ba677Sguenther 172e06ba677Sguenther /* expand.c */ 173e06ba677Sguenther struct namelist *expand(struct namelist *, int); 174e06ba677Sguenther u_char *xstrchr(u_char *, int); 175e06ba677Sguenther void expstr(u_char *); 176e06ba677Sguenther void expsh(u_char *); 177e06ba677Sguenther void matchdir(char *); 178e06ba677Sguenther int execbrc(u_char *, u_char *); 179e06ba677Sguenther int match(char *, char *); 180e06ba677Sguenther int amatch(char *, u_char *); 181e06ba677Sguenther 182e06ba677Sguenther /* gram.c */ 183e06ba677Sguenther int yylex(void); 184e06ba677Sguenther int any(int, char *); 185e06ba677Sguenther void insert(char *, struct namelist *, struct namelist *, struct subcmd *); 186e06ba677Sguenther void append(char *, struct namelist *, char *, struct subcmd *); 187e06ba677Sguenther void yyerror(char *); 188e06ba677Sguenther struct namelist *makenl(char *); 189e06ba677Sguenther struct subcmd *makesubcmd(int); 190e06ba677Sguenther int yyparse(void); 191e06ba677Sguenther 192e06ba677Sguenther /* isexec.c */ 193e06ba677Sguenther int isexec(char *, struct stat *); 194e06ba677Sguenther 195e06ba677Sguenther /* lookup.c */ 196e06ba677Sguenther void define(char *); 197e06ba677Sguenther struct namelist *lookup(char *, int, struct namelist *); 198e06ba677Sguenther 199e06ba677Sguenther /* rdist.c */ 200e06ba677Sguenther FILE *opendist(char *); 201e06ba677Sguenther void docmdargs(int, char *[]); 202e06ba677Sguenther char *getnlstr(struct namelist *); 203e06ba677Sguenther 204e06ba677Sguenther #endif /* __CLIENT_H__ */ 205