Initialize for reading Taylor UUCP configuration files.
Copyright (C) 1992 Ian Lance Taylor
This file is part of the Taylor UUCP uuconf library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License
as published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
const char _uuconf_tinit_rcsid
[] = "$Id: tinit.c,v 1.1 1993/08/04 19:35:14 jtc Exp $";
static int itset_default
P((struct sglobal
*qglobal
, char ***ppzvar
,
static int itadd
P((pointer pglobal
, int argc
, char **argv
, pointer pvar
,
static int itunknown
P((pointer pglobal
, int argc
, char **argv
, pointer pvar
,
static int itprogram
P((pointer pglobal
, int argc
, char **argv
, pointer pvar
,
static const struct cmdtab_offset asCmds
[] =
{ "nodename", UUCONF_CMDTABTYPE_STRING
,
offsetof (struct sprocess
, zlocalname
), NULL
},
{ "hostname", UUCONF_CMDTABTYPE_STRING
,
offsetof (struct sprocess
, zlocalname
), NULL
},
{ "uuname", UUCONF_CMDTABTYPE_STRING
,
offsetof (struct sprocess
, zlocalname
), NULL
},
{ "spool", UUCONF_CMDTABTYPE_STRING
,
offsetof (struct sprocess
, zspooldir
), NULL
},
{ "pubdir", UUCONF_CMDTABTYPE_STRING
,
offsetof (struct sprocess
, zpubdir
), NULL
},
{ "lockdir", UUCONF_CMDTABTYPE_STRING
,
offsetof (struct sprocess
, zlockdir
), NULL
},
{ "logfile", UUCONF_CMDTABTYPE_STRING
,
offsetof (struct sprocess
, zlogfile
), NULL
},
{ "statfile", UUCONF_CMDTABTYPE_STRING
,
offsetof (struct sprocess
, zstatsfile
), NULL
},
{ "debugfile", UUCONF_CMDTABTYPE_STRING
,
offsetof (struct sprocess
, zdebugfile
), NULL
},
{ "debug", UUCONF_CMDTABTYPE_STRING
,
offsetof (struct sprocess
, zdebug
), NULL
},
{ "max-uuxqts", UUCONF_CMDTABTYPE_INT
,
offsetof (struct sprocess
, cmaxuuxqts
), NULL
},
{ "sysfile", UUCONF_CMDTABTYPE_FN
| 0,
offsetof (struct sprocess
, pzsysfiles
), itadd
},
{ "portfile", UUCONF_CMDTABTYPE_FN
| 0,
offsetof (struct sprocess
, pzportfiles
), itadd
},
{ "dialfile", UUCONF_CMDTABTYPE_FN
| 0,
offsetof (struct sprocess
, pzdialfiles
), itadd
},
{ "dialcodefile", UUCONF_CMDTABTYPE_FN
| 0,
offsetof (struct sprocess
, pzdialcodefiles
), itadd
},
{ "callfile", UUCONF_CMDTABTYPE_FN
| 0,
offsetof (struct sprocess
, pzcallfiles
), itadd
},
{ "passwdfile", UUCONF_CMDTABTYPE_FN
| 0,
offsetof (struct sprocess
, pzpwdfiles
), itadd
},
{ "unknown", UUCONF_CMDTABTYPE_FN
, offsetof (struct sprocess
, qunknown
),
{ "v2-files", UUCONF_CMDTABTYPE_BOOLEAN
,
offsetof (struct sprocess
, fv2
), NULL
},
{ "hdb-files", UUCONF_CMDTABTYPE_BOOLEAN
,
offsetof (struct sprocess
, fhdb
), NULL
},
{ "bnu-files", UUCONF_CMDTABTYPE_BOOLEAN
,
offsetof (struct sprocess
, fhdb
), NULL
},
{ "timetable", UUCONF_CMDTABTYPE_FN
| 3,
offsetof (struct sprocess
, pztimetables
), _uuconf_itimetable
},
#define CCMDS (sizeof asCmds / sizeof asCmds[0])
/* This structure is used to pass information into the command table
/* A pointer to the command table being used, passed to isystem so
it can call uuconf_cmd_args. */
struct uuconf_cmdtab
*qcmds
;
/* Initialize the routines which read the Taylor UUCP configuration
uuconf_taylor_init (ppglobal
, zprogram
, zname
)
struct sglobal
**pqglobal
= (struct sglobal
**) ppglobal
;
iret
= _uuconf_iinit_global (pqglobal
);
if (iret
!= UUCONF_SUCCESS
)
csize
= strlen (zname
) + 1;
zcopy
= uuconf_malloc (qglobal
->pblock
, csize
);
return UUCONF_MALLOC_FAILED
| UUCONF_ERROR_ERRNO
;
memcpy ((pointer
) zcopy
, (pointer
) zname
, csize
);
zcopy
= uuconf_malloc (qglobal
->pblock
,
sizeof NEWCONFIGLIB
+ sizeof CONFIGFILE
- 1);
return UUCONF_MALLOC_FAILED
| UUCONF_ERROR_ERRNO
;
memcpy ((pointer
) zcopy
, (pointer
) NEWCONFIGLIB
,
sizeof NEWCONFIGLIB
- 1);
memcpy ((pointer
) (zcopy
+ sizeof NEWCONFIGLIB
- 1),
(pointer
) CONFIGFILE
, sizeof CONFIGFILE
);
qglobal
->qprocess
->zconfigfile
= zcopy
;
qglobal
->zfilename
= zcopy
;
return (UUCONF_FOPEN_FAILED
| UUCONF_ERROR_FILENAME
);
/* There is no config file, so just use the default values. */
struct uuconf_cmdtab as
[CCMDS
];
_uuconf_ucmdtab_base (asCmds
, CCMDS
, (char *) qglobal
->qprocess
,
iret
= uuconf_cmd_file (qglobal
, e
, as
, (pointer
) &si
, itprogram
,
UUCONF_CMDTABFLAG_BACKSLASH
,
if (iret
!= UUCONF_SUCCESS
)
qglobal
->zfilename
= zcopy
;
return iret
| UUCONF_ERROR_FILENAME
;
/* Get the defaults for the file names. */
iret
= itset_default (qglobal
, &qglobal
->qprocess
->pzsysfiles
, SYSFILE
);
if (iret
!= UUCONF_SUCCESS
)
iret
= itset_default (qglobal
, &qglobal
->qprocess
->pzportfiles
, PORTFILE
);
if (iret
!= UUCONF_SUCCESS
)
iret
= itset_default (qglobal
, &qglobal
->qprocess
->pzdialfiles
, DIALFILE
);
if (iret
!= UUCONF_SUCCESS
)
iret
= itset_default (qglobal
, &qglobal
->qprocess
->pzdialcodefiles
,
if (iret
!= UUCONF_SUCCESS
)
iret
= itset_default (qglobal
, &qglobal
->qprocess
->pzpwdfiles
, PASSWDFILE
);
if (iret
!= UUCONF_SUCCESS
)
iret
= itset_default (qglobal
, &qglobal
->qprocess
->pzcallfiles
, CALLFILE
);
if (iret
!= UUCONF_SUCCESS
)
/* Add new strings to a variable. */
itadd (pglobal
, argc
, argv
, pvar
, pinfo
)
struct sglobal
*qglobal
= (struct sglobal
*) pglobal
;
char ***ppz
= (char ***) pvar
;
iret
= _uuconf_iadd_string (qglobal
, NULL
, FALSE
, FALSE
, ppz
,
if (iret
!= UUCONF_SUCCESS
)
for (i
= 1; i
< argc
; i
++)
iret
= _uuconf_iadd_string (qglobal
, argv
[i
], TRUE
, FALSE
, ppz
,
if (iret
!= UUCONF_SUCCESS
)
return UUCONF_CMDTABRET_CONTINUE
;
/* Handle an "unknown" command. We accumulate this into a linked
list, and only parse them later in uuconf_unknown_system_info. */
itunknown (pglobal
, argc
, argv
, pvar
, pinfo
)
struct sglobal
*qglobal
= (struct sglobal
*) pglobal
;
struct sunknown
**pq
= (struct sunknown
**) pvar
;
q
= (struct sunknown
*) uuconf_malloc (qglobal
->pblock
,
sizeof (struct sunknown
));
return (UUCONF_MALLOC_FAILED
| UUCONF_CMDTABRET_EXIT
);
q
->ilineno
= qglobal
->ilineno
;
q
->pzargs
= (char **) uuconf_malloc (qglobal
->pblock
,
(argc
- 1) * sizeof (char *));
return (UUCONF_MALLOC_FAILED
| UUCONF_CMDTABRET_EXIT
);
memcpy ((pointer
) q
->pzargs
, (pointer
) (argv
+ 1),
(argc
- 1) * sizeof (char *));
return UUCONF_CMDTABRET_KEEP
;
/* If we encounter an unknown command, see if it is the program with
which we were invoked. If it was, pass the remaining arguments
back through the table. */
itprogram (pglobal
, argc
, argv
, pvar
, pinfo
)
struct sglobal
*qglobal
= (struct sglobal
*) pglobal
;
struct sinfo
*qinfo
= (struct sinfo
*) pinfo
;
|| strcasecmp (qinfo
->zname
, argv
[0]) != 0)
return UUCONF_CMDTABRET_CONTINUE
;
return uuconf_cmd_args (pglobal
, argc
- 1, argv
+ 1, qinfo
->qcmds
,
(pointer
) NULL
, (uuconf_cmdtabfn
) NULL
, 0,
/* If a filename was not set by the configuration file, add in the
itset_default (qglobal
, ppzvar
, zfile
)
zadd
= (char *) uuconf_malloc (qglobal
->pblock
,
sizeof NEWCONFIGLIB
+ clen
);
return UUCONF_MALLOC_FAILED
| UUCONF_ERROR_ERRNO
;
memcpy ((pointer
) zadd
, (pointer
) NEWCONFIGLIB
, sizeof NEWCONFIGLIB
- 1);
memcpy ((pointer
) (zadd
+ sizeof NEWCONFIGLIB
- 1), (pointer
) zfile
,
return _uuconf_iadd_string (qglobal
, zadd
, FALSE
, FALSE
, ppzvar
,