|
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 a
Length: 3382 (0xd36) Types: TextFile Names: »alias.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─⟦this⟧ »EUUGD11/euug-87hel/sec8/mcp/src/alias.c«
#include <stdio.h> #include <ctype.h> #include "sysdep.h" #ifdef SENDMAIL #include "mem.h" #include "macros.h" #include "lists.h" #include "alias.h" #include "sort.h" extern addr acskip(); #define alskip acskip extern struct list AliasList; static struct alias aka; static FILE *alf = NULL; static FILE *bindf = NULL; static char line[BUFSIZ]; setalent() { if (alf == NULL) { alf = fopen(ALIASFILE, "r"); if (alf == NULL) { perr(ALIASFILE); goodbye(1); } } rewind(alf); if (bindf == NULL) { bindf = fopen(ALBIND, "r"); if (bindf == NULL) { perr(ALBIND); goodbye(1); } } rewind(bindf); return; } endalent() { if (alf != NULL) { (void) fclose(alf); alf = NULL; } if (bindf != NULL) { (void) fclose(bindf); bindf = NULL; } return; } static int getch() { int c; for (;;) { c = getc(alf); if (c == '#') { while ((c = getc(alf)) != '\n' && c != EOF) ; return c; } break; } return c; } struct alias * getalent() { int c; register int i = 0; register struct list *q; static char name[MEDIUM_BUF], address[LONG_BUF]; flexaddr p, oldp; int quoteopen = 0; zerolist(&aka.al_addresses); zerolist(&aka.al_groups); zerolist(&aka.al_classes); zerolist(&aka.al_sigs); aka.al_name = (char *)0; while ((c = getch()) != EOF) { if (c == '\n') if (aka.al_name) { c = getch(); if (!isspace(c) || c == '\n') { (void) ungetc(c, alf); break; } else continue; } else continue; if (isspace(c) && !quoteopen) continue; if (c == '"') quoteopen = !quoteopen; if (!aka.al_name) { if (c == ':') { name[i] = '\0'; aka.al_name = name; i = 0; } else name[i++] = (char) c; continue; } if (c == ',' && i != 0) { address[i] = '\0'; strlistadd(&aka.al_addresses, address); i = 0; } else if (c == ',' && i == 0) continue; else address[i++] = (char) c; } if (!aka.al_name) return (struct alias *) 0; address[i] = '\0'; if (i > 0) strlistadd(&aka.al_addresses, address); sort_list(&aka.al_addresses, pstrcmp); /* * Now get the group, class, and sig bindings */ p.p_cp = fgets(line, BUFSIZ, bindf); if (!p.p_cp) { err1("getalent(): %s: unexpected EOF", ALBIND); err1("getalent(): %s corrupted, gagging... returning 0", ALBIND); return (struct alias *) 0; } p.p_ap = alskip(p.p_ap, ':'); if (!eq(line, aka.al_name)) { err("getalent(): alias name mismatch"); err1("getalent(): %s corrupted, gagging... returning 0", ALBIND); return (struct alias *) 0; } (void) alskip(p.p_ap, '\n'); oldp.p_ap = p.p_ap; q = &aka.al_groups; while( *p.p_cp && *p.p_cp != ':' ) { oldp.p_ap = p.p_ap; p.p_ap = alskip(p.p_ap,','); strlistadd(q, oldp.p_cp); } sort_list(q, pstrcmp); p.p_cp++; q = &aka.al_classes; while( *p.p_cp && *p.p_cp != ':' ) { oldp.p_ap = p.p_ap; p.p_ap = alskip(p.p_ap,','); strlistadd(q, oldp.p_cp); } sort_list(q, pstrcmp); p.p_cp++; q = &aka.al_sigs; while( *p.p_cp && *p.p_cp != ':' ) { oldp.p_ap = p.p_ap; p.p_ap = alskip(p.p_ap,','); strlistadd(q, oldp.p_cp); } sort_list(q, pstrcmp); return &aka; } struct alias * getalnam(name) char *name; { int found; register int indx; indx = search_list(&AliasList, name, saliascmp, &found); if (found) return (struct alias *) AliasList.l_list[indx]; return (struct alias *) 0; } #endif