|
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 - downloadIndex: ┃ T c ┃
Length: 3908 (0xf44) Types: TextFile Names: »config.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen └─ ⟦this⟧ »cph85dist/rman/daemon/config.c«
/* * Copyright (c) 1985 Jonathan C. Broome and The Regents of the * University of California. * * This software may be freely redistributed without licensing * provided that this copyright notice remains intact and no profit * is gained through any redistribution. * * Please report any bug fixes or modifications to the author at: * * broome@ucb-vax.berkeley.edu * or: * ...!ucbvax!broome * * The author and the Regents assume no liability for any damages * or loss of revenue caused directly or indirectly by the use of * this software. */ #ifndef lint static char RCSid[] = "$Header: config.c,v 1.4 85/08/27 18:46:06 broome Exp $"; #endif /* * $Log: config.c,v $ * Revision 1.4 85/08/27 15:16:26 broome * Last cleanup before release. * * Revision 1.3 85/08/04 16:31:12 broome * Rewrote most of the code to make it much less obscure, also faster. * * Revision 1.2 85/07/06 16:56:24 broome * * Revision 1.1 85/07/05 18:19:16 broome * Initial revision */ #include "defs.h" /* * Read in the configuration file, parse into sections and suffixes. */ config (file) char *file; { FILE *fp; char line[512]; char **argv = (char **) 0; int d = 0; int s; int iscont; int suffs; /* number of suffixes given */ SEC *sec = (SEC *) 0; SEC *seclast = (SEC *) 0; DIR *dir, *dirlast = (DIR *) 0; DIR *dup, *isdup(); if ((fp = fopen (file, "r")) == (FILE *) 0) { fprintf (stderr, "cannot open config file "); perror (file); exit (1); } while (getline (line, 512, fp)) { iscont = (*line == ' '); /* continuation line begins with a space */ if ((suffs = parse (line, &argv)) == 0) continue; if (streql (argv[0], "type") == 0) { /* beginning of new cpu type */ addtype (argv[1]); /* save the pointers */ continue; } if (!iscont) { /* not a continuation line - need new section */ if (sec) sec->dirs[d] = (DIR *) 0; /* null-term last list of dirs */ d = 0; sec = (SEC *) malloc (sizeof (SEC)); /* malloc section */ if (sections == (SEC *) 0) /* and add to list */ sections = sec; /* first one? */ else seclast->next = sec; sec->next = (SEC *) 0; /* nothing after it */ seclast = sec; /* keep track of last one in list */ sec->name = strsave (*argv++); /* save this section name */ suffs--; } if (dup = isdup (*argv)) { /* this element already exists */ sec->dirs[d++] = dup; /* point section to existing dir */ continue; } dir = (DIR *) malloc (sizeof (DIR)); dir->man = strsave (*argv++); dir->cat = strsave (*argv++); suffs -= 2; sec->dirs[d++] = dir; if (dirs == (DIR *) 0) dirs = dir; else dirlast->next = dir; dir->next = (DIR *) 0; dirlast = dir; dir->suff = (char **) malloc (sizeof (char **) * (suffs + 1)); for (s = 0; *argv; s++) dir->suff[s] = strsave (*argv++); dir->suff[s] = (char *) 0; } (void) fclose (fp); if (dirs || sections) /* save last type */ addtype ((char *) 0); (void) parse ("", &argv); /* free up argv memory */ } /* * Check to see if an entry for this directory already exists. * If so, return a pointer to it, else return (DIR *) 0. */ DIR * isdup (path) char *path; { register DIR *dir; for (dir = dirs; dir; dir = dir->next) if (eq (dir->man, path)) return (dir); return ((DIR *) 0); }