Annotation of xinu/sys/dgparse.c, revision 1.1.1.1

1.1       root        1: /* dgparse.c - dgparse */
                      2: 
                      3: #include <conf.h>
                      4: #include <kernel.h>
                      5: #include <network.h>
                      6: #include "/usr/include/ctype.h"
                      7: 
                      8: /*------------------------------------------------------------------------
                      9:  *  dgparse  -  parse foreign address specification; get IP and port #s
                     10:  *------------------------------------------------------------------------
                     11:  */
                     12: dgparse(dgptr, fspec)
                     13: struct dgblk   *dgptr;
                     14: char   *fspec;
                     15: {
                     16:        int     i, byte;
                     17:        char    ch;
                     18:        char    *ipptr;
                     19: 
                     20:        if (fspec == ANYFPORT) {
                     21:                dgptr->dg_fport = 0;
                     22:                return(OK);
                     23:        }
                     24: 
                     25:        /* parse forms like 192.5.48.30:3 into (ip-address,udp-port) */
                     26: 
                     27:        ipptr = (char *) dgptr->dg_faddr;
                     28:        for (i=0 ; i<4 ; i++) {
                     29:                byte = 0;
                     30:                while ( isdigit(ch = *fspec++) )
                     31:                        byte = 10*byte + (ch - '0');
                     32:                if (byte > 256 || (i<3 && ch!='.') )
                     33:                        return(SYSERR);
                     34:                *ipptr++ = (char)byte;
                     35:        }
                     36:        if (ch != ':')
                     37:                return(SYSERR);
                     38:        i = 0;
                     39:        while ( isdigit(ch = *fspec++) )
                     40:                i = 10*i + (ch - '0');
                     41:        if (i==0 || ch!='\0')
                     42:                return(SYSERR);
                     43:        dgptr->dg_fport = i;
                     44:        return(OK);
                     45: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.