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