home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / uucp / Uucp.framework / uuconf.subproj / uucnfi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-10-10  |  13.0 KB  |  381 lines

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