Back to index

glibc  2.9
Defines | Functions
inet_neta.c File Reference
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Defines

#define SPRINTF(x)   ((size_t)sprintf x)

Functions

char * inet_neta (u_int32_t src, char *dst, size_t size)

Define Documentation

#define SPRINTF (   x)    ((size_t)sprintf x)

Definition at line 34 of file inet_neta.c.


Function Documentation

char* inet_neta ( u_int32_t  src,
char *  dst,
size_t  size 
)

Definition at line 49 of file inet_neta.c.

{
       char *odst = dst;
       char *tp;

       while (src & 0xffffffff) {
              u_char b = (src & 0xff000000) >> 24;

              src <<= 8;
              if (b) {
                     if (size < sizeof "255.")
                            goto emsgsize;
                     tp = dst;
                     dst += SPRINTF((dst, "%u", b));
                     if (src != 0L) {
                            *dst++ = '.';
                            *dst = '\0';
                     }
                     size -= (size_t)(dst - tp);
              }
       }
       if (dst == odst) {
              if (size < sizeof "0.0.0.0")
                     goto emsgsize;
              strcpy(dst, "0.0.0.0");
       }
       return (odst);

 emsgsize:
       __set_errno (EMSGSIZE);
       return (NULL);
}

Here is the call graph for this function: