Back to index

glibc  2.9
Functions
nsap_addr.c File Reference
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <ctype.h>
#include <resolv.h>

Go to the source code of this file.

Functions

static char xtob (int c)
u_int inet_nsap_addr (const char *ascii, u_char *binary, int maxlen)
char * inet_nsap_ntoa (int binlen, const u_char *binary, char *ascii)

Function Documentation

u_int inet_nsap_addr ( const char *  ascii,
u_char binary,
int  maxlen 
)

Definition at line 39 of file nsap_addr.c.

                                                              {
       u_char c, nib;
       u_int len = 0;

       while ((c = *ascii++) != '\0' && len < (u_int)maxlen) {
              if (c == '.' || c == '+' || c == '/')
                     continue;
              if (!isascii(c))
                     return (0);
              c = toupper(c);
              if (isxdigit(c)) {
                     nib = xtob(c);
                     c = *ascii++;
                     if (c != '\0') {
                            c = toupper(c);
                            if (isxdigit(c)) {
                                   *binary++ = (nib << 4) | xtob(c);
                                   len++;
                            } else
                                   return (0);
                     }
                     else
                            return (0);
              }
              else
                     return (0);
       }
       return (len);
}

Here is the call graph for this function:

char* inet_nsap_ntoa ( int  binlen,
const u_char binary,
char *  ascii 
)

Definition at line 70 of file nsap_addr.c.

                                                              {
       int nib;
       int i;
       static char tmpbuf[255*2 + 128];
       char *start;

       if (ascii)
              start = ascii;
       else {
              ascii = tmpbuf;
              start = tmpbuf;
       }

       if (binlen > 255)
              binlen = 255;

       for (i = 0; i < binlen; i++) {
              nib = *binary >> 4;
              *ascii++ = nib + (nib < 10 ? '0' : '7');
              nib = *binary++ & 0x0f;
              *ascii++ = nib + (nib < 10 ? '0' : '7');
              if (((i % 2) == 0 && (i + 1) < binlen))
                     *ascii++ = '.';
       }
       *ascii = '\0';
       return (start);
}

Here is the caller graph for this function:

static char xtob ( int  c) [static]

Definition at line 34 of file nsap_addr.c.

            {
       return (c - (((c >= '0') && (c <= '9')) ? '0' : '7'));
}

Here is the caller graph for this function: