1/* uucnfi.h 2 Internal header file for the uuconf package. 3 4 Copyright (C) 1992, 1993, 1994, 1995 Ian Lance Taylor 5 6 This file is part of the Taylor UUCP uuconf library. 7 8 This library is free software; you can redistribute it and/or 9 modify it under the terms of the GNU Library General Public License 10 as published by the Free Software Foundation; either version 2 of 11 the License, or (at your option) any later version. 12 13 This library is distributed in the hope that it will be useful, but 14 WITHOUT ANY WARRANTY; without even the implied warranty of 15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 Library General Public License for more details. 17 18 You should have received a copy of the GNU Library General Public 19 License along with this library; if not, write to the Free Software 20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. 21 22 The author of the program may be contacted at ian@airs.com. 23 */ 24 25/* This is the internal header file for the uuconf package. It should 26 not be included by anything other than the uuconf code itself. */ 27 28/* Get all the general definitions. */ 29#include "uucp.h" 30 31/* Get the uuconf header file itself. */ 32#include "uuconf.h" 33 34/* We need the system dependent header file. */ 35#include "syshdr.h" 36 37/* This is the generic information structure. This holds all the 38 per-thread global information needed by the uuconf code. The 39 per-process global information is held in an sprocess structure, 40 which this structure points to. This permits the code to not have 41 any global variables at all. */ 42 43struct sglobal 44{ 45 /* A pointer to the per-process global information. */ 46 struct sprocess *qprocess; 47 /* A memory block in which all the memory for these fields is 48 allocated. */ 49 pointer pblock; 50 /* The value of errno after an error. */ 51 int ierrno; 52 /* The filename for which an error occurred. */ 53 const char *zfilename; 54 /* The line number at which an error occurred. */ 55 int ilineno; 56}; 57 58/* This is the per-process information structure. This essentially 59 holds all the global variables used by uuconf. */ 60 61struct sprocess 62{ 63 /* The name of the local machine. This will be NULL if it is not 64 specified in a configuration file. */ 65 const char *zlocalname; 66 /* The spool directory. */ 67 const char *zspooldir; 68 /* The default public directory. */ 69 const char *zpubdir; 70 /* The lock directory. */ 71 const char *zlockdir; 72 /* The log file. */ 73 const char *zlogfile; 74 /* The statistics file. */ 75 const char *zstatsfile; 76 /* The debugging file. */ 77 const char *zdebugfile; 78 /* The default debugging level. */ 79 const char *zdebug; 80 /* Whether login information should be stripped. */ 81 boolean fstrip_login; 82 /* Whether protocol information should be stripped. */ 83 boolean fstrip_proto; 84 /* The maximum number of simultaneously executing uuxqts. */ 85 int cmaxuuxqts; 86 /* How often to spawn a uuxqt process. */ 87 const char *zrunuuxqt; 88 /* Whether we are reading the V2 configuration files. */ 89 boolean fv2; 90 /* Whether we are reading the HDB configuration files. */ 91 boolean fhdb; 92 /* The names of the dialcode files. */ 93 char **pzdialcodefiles; 94 /* Timetables. These are in pairs. The first element is the name, 95 the second is the time string. */ 96 char **pztimetables; 97 98 /* Taylor UUCP config file name. */ 99 char *zconfigfile; 100 /* Taylor UUCP sys file names. */ 101 char **pzsysfiles; 102 /* Taylor UUCP port file names. */ 103 char **pzportfiles; 104 /* Taylor UUCP dial file names. */ 105 char **pzdialfiles; 106 /* Taylor UUCP passwd file names. */ 107 char **pzpwdfiles; 108 /* Taylor UUCP call file names. */ 109 char **pzcallfiles; 110 /* List of "unknown" commands from config file. */ 111 struct sunknown *qunknown; 112 /* Whether the Taylor UUCP system information locations have been 113 read. */ 114 boolean fread_syslocs; 115 /* Taylor UUCP system information locations. */ 116 struct stsysloc *qsyslocs; 117 /* Taylor UUCP validation restrictions. */ 118 struct svalidate *qvalidate; 119 /* Whether the "myname" command is used in a Taylor UUCP file. */ 120 boolean fuses_myname; 121 122 /* V2 system file name (L.sys). */ 123 char *zv2systems; 124 /* V2 device file name (L-devices). */ 125 char *zv2devices; 126 /* V2 user permissions file name (USERFILE). */ 127 char *zv2userfile; 128 /* V2 user permitted commands file (L.cmds). */ 129 char *zv2cmds; 130 131 /* HDB system file names (Systems). */ 132 char **pzhdb_systems; 133 /* HDB device file names (Devices). */ 134 char **pzhdb_devices; 135 /* HDB dialer file names (Dialers). */ 136 char **pzhdb_dialers; 137 /* Whether the HDB Permissions file has been read. */ 138 boolean fhdb_read_permissions; 139 /* The HDB Permissions file entries. */ 140 struct shpermissions *qhdb_permissions; 141}; 142 143/* This structure is used to hold the "unknown" commands from the 144 Taylor UUCP config file before they have been parsed. */ 145 146struct sunknown 147{ 148 /* Next element in linked list. */ 149 struct sunknown *qnext; 150 /* Line number in config file. */ 151 int ilineno; 152 /* Number of arguments. */ 153 int cargs; 154 /* Arguments. */ 155 char **pzargs; 156}; 157 158/* This structure is used to hold the locations of systems within the 159 Taylor UUCP sys files. */ 160 161struct stsysloc 162{ 163 /* Next element in linked list. */ 164 struct stsysloc *qnext; 165 /* System name. */ 166 const char *zname; 167 /* Whether system is an alias or a real system. If this is an 168 alias, the real system is the next entry in the linked list which 169 is not an alias. */ 170 boolean falias; 171 /* File name (one of the sys files). */ 172 const char *zfile; 173 /* Open file. */ 174 FILE *e; 175 /* Location within file (from ftell). */ 176 long iloc; 177 /* Line number within file. */ 178 int ilineno; 179}; 180 181/* This structure is used to hold validation restrictions. This is a 182 list of machines which are permitted to use a particular login 183 name. If a machine logs in, and there is no called login entry for 184 it, the login name and machine name must be passed to 185 uuconf_validate to confirm that either there is no entry for this 186 login name or that the machine name appears on the entry. */ 187 188struct svalidate 189{ 190 /* Next element in linked list. */ 191 struct svalidate *qnext; 192 /* Login name. */ 193 const char *zlogname; 194 /* NULL terminated list of machine names. */ 195 char **pzmachines; 196}; 197 198/* This structure is used to hold a linked list of HDB Permissions 199 file entries. */ 200 201struct shpermissions 202{ 203 /* Next entry in linked list. */ 204 struct shpermissions *qnext; 205 /* NULL terminated array of LOGNAME values. */ 206 char **pzlogname; 207 /* NULL terminated array of MACHINE values. */ 208 char **pzmachine; 209 /* Boolean REQUEST value. */ 210 int frequest; 211 /* Boolean SENDFILES value ("call" is taken as "no"). */ 212 int fsendfiles; 213 /* NULL terminated array of READ values. */ 214 char **pzread; 215 /* NULL terminated array of WRITE values. */ 216 char **pzwrite; 217 /* Boolean CALLBACK value. */ 218 int fcallback; 219 /* NULL terminated array of COMMANDS values. */ 220 char **pzcommands; 221 /* NULL terminated array of VALIDATE values. */ 222 char **pzvalidate; 223 /* String MYNAME value. */ 224 char *zmyname; 225 /* String PUBDIR value. */ 226 const char *zpubdir; 227 /* NULL terminated array of ALIAS values. */ 228 char **pzalias; 229}; 230 231/* This structure is used to build reentrant uuconf_cmdtab tables. 232 The ioff field is either (size_t) -1 or an offsetof macro. The 233 table is then copied into a uuconf_cmdtab, except that offsets of 234 (size_t) -1 are converted to pvar elements of NULL, and other 235 offsets are converted to an offset off some base address. */ 236 237struct cmdtab_offset 238{ 239 const char *zcmd; 240 int itype; 241 size_t ioff; 242 uuconf_cmdtabfn pifn; 243}; 244 245/* A value in a uuconf_system structure which holds the address of 246 this special variable is known to be uninitialized. */ 247extern char *_uuconf_unset; 248 249/* Internal function to read a system from the Taylor UUCP 250 configuration files. This does not apply the basic defaults. */ 251extern int _uuconf_itaylor_system_internal P((struct sglobal *qglobal, 252 const char *zsystem, 253 struct uuconf_system *qsys)); 254 255/* Read the system locations and validation information from the 256 Taylor UUCP configuration files. This sets the qsyslocs, 257 qvalidate, and fread_syslocs elements of the global structure. */ 258extern int _uuconf_iread_locations P((struct sglobal *qglobal)); 259 260/* Process a command for a port from a Taylor UUCP file. */ 261extern int _uuconf_iport_cmd P((struct sglobal *qglobal, int argc, 262 char **argv, struct uuconf_port *qport)); 263 264/* Process a command for a dialer from a Taylor UUCP file. */ 265extern int _uuconf_idialer_cmd P((struct sglobal *qglobal, int argc, 266 char **argv, 267 struct uuconf_dialer *qdialer)); 268 269/* Process a command for a chat script from a Taylor UUCP file; this 270 is also called for HDB or V2 files, with a made up command. */ 271extern int _uuconf_ichat_cmd P((struct sglobal *qglobal, int argc, 272 char **argv, struct uuconf_chat *qchat, 273 pointer pblock)); 274 275/* Process a protocol-parameter command from a Taylor UUCP file. */ 276extern int _uuconf_iadd_proto_param P((struct sglobal *qglobal, 277 int argc, char **argv, 278 struct uuconf_proto_param **pq, 279 pointer pblock)); 280 281/* Handle a "seven-bit", "reliable", or "half-duplex" command from a 282 Taylor UUCP port or dialer file. The pvar field should point to 283 the ireliable element of the structure. */ 284extern int _uuconf_iseven_bit P((pointer pglobal, int argc, char **argv, 285 pointer pvar, pointer pinfo)); 286extern int _uuconf_ireliable P((pointer pglobal, int argc, char **argv, 287 pointer pvar, pointer pinfo)); 288extern int _uuconf_ihalf_duplex P((pointer pglobal, int argc, char **argv, 289 pointer pvar, pointer pinfo)); 290 291/* Internal function to read a system from the V2 configuration files. 292 This does not apply the basic defaults. */ 293extern int _uuconf_iv2_system_internal P((struct sglobal *qglobal, 294 const char *zsystem, 295 struct uuconf_system *qsys)); 296 297/* Internal function to read a system from the HDB configuration 298 files. This does not apply the basic defaults. */ 299extern int _uuconf_ihdb_system_internal P((struct sglobal *qglobal, 300 const char *zsystem, 301 struct uuconf_system *qsys)); 302 303/* Read the HDB Permissions file. */ 304extern int _uuconf_ihread_permissions P((struct sglobal *qglobal)); 305 306/* Initialize the global information structure. */ 307extern int _uuconf_iinit_global P((struct sglobal **pqglobal)); 308 309/* Clear system information. */ 310extern void _uuconf_uclear_system P((struct uuconf_system *qsys)); 311 312/* Default unset aspects of one system to the contents of another. */ 313extern int _uuconf_isystem_default P((struct sglobal *qglobal, 314 struct uuconf_system *q, 315 struct uuconf_system *qdefault, 316 boolean faddalternates)); 317 318/* Put in the basic system defaults. */ 319extern int _uuconf_isystem_basic_default P((struct sglobal *qglobal, 320 struct uuconf_system *qsys)); 321 322/* Clear port information. */ 323extern void _uuconf_uclear_port P((struct uuconf_port *qport)); 324 325/* Clear dialer information. */ 326extern void _uuconf_uclear_dialer P((struct uuconf_dialer *qdialer)); 327 328/* Add a timetable. */ 329extern int _uuconf_itimetable P((pointer pglobal, int argc, char **argv, 330 pointer pvar, pointer pinfo)); 331 332/* Parse a time string. */ 333extern int _uuconf_itime_parse P((struct sglobal *qglobal, char *ztime, 334 long ival, int cretry, 335 int (*picmp) P((long, long)), 336 struct uuconf_timespan **pqspan, 337 pointer pblock)); 338 339/* A grade comparison function to pass to _uuconf_itime_parse. */ 340extern int _uuconf_itime_grade_cmp P((long, long)); 341 342/* Parse a debugging string. */ 343 344extern int _uuconf_idebug_cmd P((struct sglobal *qglobal, 345 char **pzdebug, int argc, 346 char **argv, pointer pblock)); 347 348/* Add a string to a NULL terminated list of strings. */ 349extern int _uuconf_iadd_string P((struct sglobal *qglobal, 350 char *zadd, boolean fcopy, 351 boolean fdupcheck, char ***ppzstrings, 352 pointer pblock)); 353 354/* Parse a string into a boolean value. */ 355extern int _uuconf_iboolean P((struct sglobal *qglobal, const char *zval, 356 int *pi)); 357 358/* Parse a string into an integer value. The argument p is either an 359 int * or a long *, according to the argument fint. */ 360extern int _uuconf_iint P((struct sglobal *qglobal, const char *zval, 361 pointer p, boolean fint)); 362 363/* Turn a cmdtab_offset table into a uuconf_cmdtab table. */ 364extern void _uuconf_ucmdtab_base P((const struct cmdtab_offset *qoff, 365 size_t celes, char *pbase, 366 struct uuconf_cmdtab *qset)); 367 368/* Merge two memory blocks into one. This cannot fail. */ 369extern pointer _uuconf_pmalloc_block_merge P((pointer, pointer)); 370 371/* A wrapper for getline that continues lines if they end in a 372 backslash. It needs qglobal so that it can increment ilineno 373 correctly. */ 374extern int _uuconf_getline P((struct sglobal *qglobal, 375 char **, size_t *, FILE *)); 376 377/* Split a string into tokens. */ 378extern int _uuconf_istrsplit P((char *zline, int bsep, 379 char ***ppzsplit, size_t *csplit)); 380