1: #ifndef lint
   2: static char *sccsid = "@(#)annobib.c	4.1 (Berkeley) 5/6/83";
   3: #endif
   4: 
   5: /*
   6:  * This program has been replaced by "refer -B" (bibliography mode),
   7:  * but is included here for backward compatiblity.
   8:  */
   9: 
  10: #include <stdio.h>
  11: 
  12: int noanno = 0;     /* option to suppress .AP from %X field */
  13: 
  14: main(argc, argv)    /* format (annotated) bibliography for n/troff */
  15: int argc;
  16: char *argv[];
  17: {
  18:     FILE *fp, *fopen();
  19: 
  20:     if (argv[1][0] == '-' && argv[1][1] == 'x')
  21:     {
  22:         noanno = 1;
  23:         argv++; argc--;
  24:     }
  25:     if (argc == 1)
  26:     {
  27:         annobib(stdin);
  28:         exit(0);
  29:     }
  30:     while (--argc > 0)
  31:     {
  32:         if ((fp = fopen(*++argv, "r")) == NULL)
  33:         {
  34:             perror(*argv);
  35:             exit(1);
  36:         }
  37:         annobib(fp);
  38:         fclose(fp);
  39:     }
  40:     exit(0);
  41: }
  42: 
  43: annobib(fp)     /* prepare bibliography for refer bare mode */
  44: FILE *fp;
  45: {
  46:     char line[BUFSIZ];
  47:     int begun, ended;
  48: 
  49:     begun = 0;
  50:     ended = 1;
  51:     while (fgets(line, BUFSIZ, fp))
  52:     {
  53:         if (line[0] == '%' && line[1] == 'X' && !noanno)
  54:         {
  55:             zap_x(line);
  56:             printf(".]\n.AP\n%s", line);
  57:             ended = 1;
  58:             begun = 0;
  59:         }
  60:         else if (line[0] == '%')
  61:         {
  62:             if (!begun)
  63:             {
  64:                 puts(".[");
  65:                 begun = 1;
  66:                 ended = 0;
  67:             }
  68:             fputs(line, stdout);
  69:         }
  70:         else if (line[0] == '\n')
  71:         {
  72:             if (!ended)
  73:             {
  74:                 puts(".]");
  75:                 ended = 1;
  76:                 begun = 0;
  77:             }
  78:         }
  79:         else
  80:             fputs(line, stdout);
  81:     }
  82:     if (!ended)
  83:         puts(".]");
  84: }
  85: 
  86: zap_x(line)     /* take %X annotation flag out of line */
  87: char line[];
  88: {
  89:     register int i, j;
  90: 
  91:     for (i = 3, j = 0; line[i] != NULL; i++, j++)
  92:         line[j] = line[i];
  93:     line[j] = NULL;
  94:     return;
  95: }

Defined functions

annobib defined in line 43; used 2 times
main defined in line 14; never used
zap_x defined in line 86; used 1 times
  • in line 55

Defined variables

noanno defined in line 12; used 2 times
sccsid defined in line 2; never used
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2327
Valid CSS Valid XHTML 1.0 Strict