|
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 w
Length: 2159 (0x86f) Types: TextFile Names: »whatis.c«
└─⟦87ddcff64⟧ Bits:30001253 CPHDIST85 Tape, 1985 Autumn Conference Copenhagen └─⟦this⟧ »cph85dist/rman/daemon/whatis.c«
#ifndef lint static char RCSid[] = "$Header: whatis.c,v 1.4 85/07/24 10:39:13 broome Exp $"; #endif /* * $Log: whatis.c,v $ * Revision 1.4 85/07/24 10:39:13 broome * * * Revision 1.3 85/07/06 16:56:13 broome * * Revision 1.2 85/07/03 17:34:41 broome */ #include "response.h" #include <stdio.h> #define LIST "/usr/lib/whatis" #define DELIMS " \t\n\r,\"\'-()" /* word delimiters */ int key; /*ARGSUSED*/ whatis (argc, argv) int argc; char **argv; { extern int debug; register FILE *fp; register char *b; char buf[512]; char *nextword(); char word[80]; int found = 0; argv++; if ((fp = fopen (LIST, "r")) == NULL) { printf ("%d cannot open %s\r\n", ERR_NOFILE, LIST); (void) fflush (stdout); return; } while (fgets (buf, 512, fp)) { key = 0; b = buf; while (b = nextword (b, word)) { if (debug) printf ("|%s|", word); if (strcmp (word, *argv) == 0) { /* word matches arg */ if (found == 0) printf ("%d information for \"%s\" on the way.\r\n", OK_COMING, *argv); printf ("%s", buf); found++; break; } if (key == 1) /* went through all the keywords */ break; } } if (!found) printf ("%d %s: not found.\n", ERR_NOENT, *argv); else puts (".\r"); (void) fflush (stdout); } /* * Get the next word from the line and put it into `word', return * the advanced line pointer (NULL if at end of the line). */ char *nextword (buf, word) char *buf, *word; { register char *i = word; if (!buf || !*buf) return ((char *) 0); while (*buf && any (*buf, DELIMS) == 0) /* get this word */ *i++ = *buf++; *i = '\0'; while (*buf && any (*buf, DELIMS)) { /* skip over to next word */ if (*buf == '(') /*)*/ /* at end of keyword list */ key = 1; buf++; } return (buf); }