# 2.11BSD#431 - /usr/src/usr.bin/uucp/cfgets.c

##### Functions

    cfgets            X
    main              X

##### Macros

    COMMENT           X
    CONTINUE          X
    EOLN              X
    EOS               X

       1: #ifndef lint
       2: static char sccsid[] = "@(#)cfgets.c	5.3 (Berkeley) 6/19/85";
       3: #endif
       4:
       5: /*
       6:  * get nonblank, non-comment, (possibly continued) line. Alan S. Watt
       7:  */
       8:
       9: #include <stdio.h>
      10: #define COMMENT     '#'
      11: #define CONTINUE    '\\'
      12: #define EOLN        '\n'
      13: #define EOS     '\0'
      14:
      15: /*LINTLIBRARY*/
      16:
      17: char *
      18: cfgets(buf, siz, fil)
      19: register char *buf;
      20: int siz;
      21: FILE *fil;
      22: {
      23:     register char *s;
      24:     register i, c, len;
      25:     char *fgets();
      26:
      27:     for (i=0,s=buf; i = (fgets(s, siz-i, fil) != NULL); i = s - buf) {
      28:
      29:         /* get last character of line */
      30:         c = s[len = (strlen(s) - 1)];
      31:
      32:         /* skip comments; make sure end of comment line seen */
      33:         if (*s == COMMENT) {
      34:             while (c != EOLN && c != EOF)
      35:                 c = getc(fil);
      36:             *s = EOS;
      37:         }
      38:
      39:         /* skip blank lines */
      40:         else if (*s != EOLN) {
      41:             s += len;
      42:
      43:             /* continue lines ending with CONTINUE */
      44:             if (c != EOLN || *--s != CONTINUE)
      45:                 break;
      46:         }
      47:     }
      48:
      49:     return i ? buf : NULL;
      50: }
      51:
      52: #ifdef TEST
      53: main()
      54: {
      55:     char buf[512];
      56:
      57:     while (cfgets(buf, sizeof buf, stdin))
      58:         fputs(buf, stdout);
      59: }
      60: #endif TEST

#### Defined functions

cfgets defined in line 17; used 11 times

- in line 57
- in /usr/src/usr.bin/uucp/chkpth.c line 102
- in /usr/src/usr.bin/uucp/conn.c line 321, 349, 385
- in /usr/src/usr.bin/uucp/gnsys.c line 89
- in /usr/src/usr.bin/uucp/uucp.h line 398
- in /usr/src/usr.bin/uucp/uuname.c line 55
- in /usr/src/usr.bin/uucp/uuxqt.c line 127
- in /usr/src/usr.bin/uucp/versys.c line 41, 83

main defined in line 53; never used

#### Defined variables

sccsid defined in line 2; never used

#### Defined macros

COMMENT defined in line 10; used 1 times

- in line 33

CONTINUE defined in line 11; used 1 times

- in line 44

EOLN defined in line 12; used 3 times

- in line 34, 40-44(2)

EOS defined in line 13; used 1 times

- in line 36

Last modified: 1987-02-17 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 559 |