|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T i
Length: 4496 (0x1190)
Types: TextFile
Names: »init_tai.c«
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
└─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z«
└─⟦e5a54fb17⟧
└─⟦this⟧ »pp-5.0/Lib/tai/init_tai.c«
/* init_tai.c: tailoring initialisation */
# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Lib/tai/RCS/init_tai.c,v 5.0 90/09/20 16:16:22 pp Exp Locker: pp $";
# endif
/*
* $Header: /cs/research/pp/hubris/pp-beta/Lib/tai/RCS/init_tai.c,v 5.0 90/09/20 16:16:22 pp Exp Locker: pp $
*
* $Log: init_tai.c,v $
* Revision 5.0 90/09/20 16:16:22 pp
* rcsforce : 5.0 public release
*
*/
#include "head.h"
#include <sys/stat.h>
#include <isode/tailor.h>
#define MAXTAIARGS 100
#define COMMENTCHAR '#'
extern char *pptailor,
*isodelogpath,
*tbldfldir,
*logdfldir;
int pptailor_size;
static void tai_size ();
typedef int (*PF[])();
static char *getlines();
static void pp_tailor_export ();
extern void pp_log_init ();
extern void err_abrt ();
extern void pp_log_export ();
extern void siginit ();
/* --------------------- Begin Routines -------------------------------- */
int tai_init (pf, name)
PF pf;
char *name;
{
FILE *fp;
char buf[8192],
*args[MAXTAIARGS],
*rname;
int ac,
done,
pfc;
if (rname = rindex (name, '/'))
rname ++;
if (rname == NULLCP || *rname == 0)
rname = name;
isodetailor (rname, 0);
ll_hdinit (pp_log_oper, rname);
ll_hdinit (pp_log_stat, rname);
ll_hdinit (pp_log_norm, rname);
siginit();
pp_log_init ();
(void) sprintf (buf, "%s/", logdfldir);
isodelogpath = strdup (buf);
tai_size();
if ((fp = fopen (pptailor, "r")) == NULL)
err_abrt (RP_FIO,
"Lib/init_tai.c: Cannot open tailor file '%s'",
pptailor);
while (getlines (buf, sizeof buf, fp) != NULL) {
if (buf[0] == '\0' || buf[0] == COMMENTCHAR || buf[0] == '\n')
continue;
PP_DBG (("tailor line='%s'", buf));
if ((ac = sstr2arg (buf, MAXTAIARGS, args, " \t,")) == NOTOK)
err_abrt (RP_MECH,
"Lib/init_tai.c: too many tailor parameters");
if (ac <= 1)
continue;
if (sys_tai (ac, args) == OK)
continue;
done = 0;
if (pf != 0) {
for (pfc = 0 ; pf[pfc] != 0 ; pfc++)
if ((*pf[pfc]) (ac, args) == OK) {
done = 1;
break;
}
}
if (!done && lexequ (rname, args[0]) == 0) {
PP_TRACE (("Adding tailor %s for %s",
args[1], rname));
sys_tai (ac - 1, &args[1]);
}
}
(void) fclose (fp);
pp_tailor_export ();
return OK;
}
/* --------------------- Static Routines ------------------------------- */
static void pp_tailor_export ()
{
extern char *cmddfldir, *chndfldir, *formdfldir,
*quedfldir, *aquedir, *mquedir, *tquedir,
*ppdbm, *wrndfldir;
extern char *dupfpath();
char buf[BUFSIZ];
if (isodelogpath)
free (isodelogpath);
#if ISODE >= 62
isodexport (NULLCP);
#else
isodexport ();
#endif
(void) sprintf (buf, "%s/", logdfldir);
isodelogpath = strdup (buf);
chndfldir = dupfpath (cmddfldir, chndfldir);
formdfldir = dupfpath (cmddfldir, formdfldir);
/* aquedir = dupfpath (quedfldir, aquedir);
mquedir = dupfpath (quedfldir, mquedir);
tquedir = dupfpath (quedfldir, tquedir); */
ppdbm = dupfpath (tbldfldir, ppdbm);
wrndfldir = dupfpath (tbldfldir, wrndfldir);
pp_log_export ();
}
static char *getlines (bp, size, fp)
char *bp;
int size;
FILE *fp;
{
char *p;
int count, n, c;
p = bp; /* leave bp pointing to start */
count = size;
while (1) { /* loop until end of folding */
if (fgets (p, count, fp) == NULL) { /* get one line */
if (p != bp)
return bp; /* input on previous lines */
else return NULL;
}
n = strlen (p) - 1; /* not including new line */
count -= n;
p += n;
*p = '\0'; /* null over new line character */
/* this relies on the leading space/tab on following
folded lines to separate next parameter */
while (1) { /* look at first char on next line */
ungetc ( (c = getc(fp)), fp);
if (c == COMMENTCHAR) {
/* to allow for comment WITHIN folded line */
/* rather than allocate another buffer ... */
if (fgets (p, count, fp) == NULL) {
/* Can't happen. Still... */
if (p != bp)
return bp;
else return NULL;
}
else {
/* throw it away */
*p = '\0';
}
}
else {
break;
}
}
if (c != ' ' && c != '\t') /* not folded */
return bp;
/* folded - carry on looking */
if (count <= 0) /* no room ! */
return bp;
}
}
/* -- gets the tailor file size so that the correct memory is allocated -- */
static void tai_size()
{
struct stat st_rec;
if (stat (pptailor, &st_rec) == NOTOK)
pptailor_size = BUFSIZ;
else pptailor_size = st_rec.st_size;
}