# 2.11BSD#431 - /usr/src/libexec/tcpd/misc.c

##### Functions

    dot_quad_addr     X
    split_at          X
    xgets             X

##### Macros

    INADDR_NONE       X

       1:  /*
       2:   * Misc routines that are used by tcpd and by tcpdchk.
       3:   *
       4:   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
       5:   */
       6:
       7: #ifndef lint
       8: static char sccsic[] = "@(#) misc.c 1.1 94/12/28 17:42:31";
       9: #endif
      10:
      11: #include <sys/types.h>
      12: #include <sys/param.h>
      13: #include <netinet/in.h>
      14: #include <arpa/inet.h>
      15: #include <stdio.h>
      16: #include <string.h>
      17:
      18: #include "tcpd.h"
      19:
      20: extern char *fgets();
      21:
      22: #ifndef INADDR_NONE
      23: #define INADDR_NONE (-1)        /* XXX should be 0xffffffff */
      24: #endif
      25:
      26: /* xgets - fgets() with backslash-newline stripping */
      27:
      28: char   *xgets(ptr, len, fp)
      29: char   *ptr;
      30: int     len;
      31: FILE   *fp;
      32: {
      33:     int     got;
      34:     char   *start = ptr;
      35:
      36:     while (fgets(ptr, len, fp)) {
      37:     got = strlen(ptr);
      38:     if (got >= 1 && ptr[got - 1] == '\n') {
      39:         tcpd_context.line++;
      40:         if (got >= 2 && ptr[got - 2] == '\\') {
      41:         got -= 2;
      42:         ptr += got;
      43:         len -= got;
      44:         ptr[0] = 0;
      45:         } else {
      46:         return (start);
      47:         }
      48:     }
      49:     }
      50:     return (ptr > start ? start : 0);
      51: }
      52:
      53: /* split_at - break string at delimiter or return NULL */
      54:
      55: char   *split_at(string, delimiter)
      56: char   *string;
      57: int     delimiter;
      58: {
      59:     char   *cp;
      60:
      61:     if ((cp = strchr(string, delimiter)) != 0)
      62:     *cp++ = 0;
      63:     return (cp);
      64: }
      65:
      66: /* dot_quad_addr - convert dotted quad to internal form */
      67:
      68: unsigned long dot_quad_addr(str)
      69: char   *str;
      70: {
      71:     int     in_run = 0;
      72:     int     runs = 0;
      73:     char   *cp = str;
      74:
      75:     /* Count the number of runs of non-dot characters. */
      76:
      77:     while (*cp) {
      78:     if (*cp == '.') {
      79:         in_run = 0;
      80:     } else if (in_run == 0) {
      81:         in_run = 1;
      82:         runs++;
      83:     }
      84:     cp++;
      85:     }
      86:     return (runs == 4 ? inet_addr(str) : INADDR_NONE);
      87: }

#### Defined functions

dot_quad_addr defined in line 68; used 8 times

- in /usr/src/libexec/tcpd/hosts_access.c line 314-317(3)
- in /usr/src/libexec/tcpd/scaffold.c line 90
- in /usr/src/libexec/tcpd/tcpd.h line 77
- in /usr/src/libexec/tcpd/tcpdchk.c line 411-412(2)
- in /usr/src/libexec/tcpd/tcpdmatch.c line 193

split_at defined in line 55; used 16 times

- in /usr/src/libexec/tcpd/hosts_access.c line 145-149(2), 210, 226, 267
- in /usr/src/libexec/tcpd/options.c line 232, 272, 548
- in /usr/src/libexec/tcpd/tcpd.h line 76
- in /usr/src/libexec/tcpd/tcpdchk.c line 204-208(2), 291, 319, 410
- in /usr/src/libexec/tcpd/tcpdmatch.c line 100, 113

xgets defined in line 28; used 4 times

- in /usr/src/libexec/tcpd/hosts_access.c line 138
- in /usr/src/libexec/tcpd/inetcf.c line 105
- in /usr/src/libexec/tcpd/tcpd.h line 75
- in /usr/src/libexec/tcpd/tcpdchk.c line 197

#### Defined variables

sccsic defined in line 8; never used

#### Defined macros

INADDR_NONE defined in line 23; used 2 times

- in line 22, 86

Last modified: 1994-12-28 Generated: 2016-12-26 | Generated by src2html V0.67 page hit count: 552 |