Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions | Variables
str2addr.c File Reference
#include "nspr.h"
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Defines

#define DEFAULT_IPV4_ADDR_STR   "207.200.73.41"

Functions

int main (int argc, char **argv)
 The Xalan testcases app.

Variables

static unsigned char default_ipv4_addr [] = {207, 200, 73, 41}

Define Documentation

#define DEFAULT_IPV4_ADDR_STR   "207.200.73.41"

Definition at line 49 of file str2addr.c.


Function Documentation

int main ( int  argc,
char **  argv 
)

The Xalan testcases app.

Definition at line 54 of file str2addr.c.

{
    PRNetAddr addr;
    const char *addrStr;
    unsigned char *bytes;
    int idx;

    addrStr = DEFAULT_IPV4_ADDR_STR;
    if (PR_StringToNetAddr(addrStr, &addr) == PR_FAILURE) {
        fprintf(stderr, "PR_StringToNetAddr failed\n");
        exit(1);
    }
    if (addr.inet.family != PR_AF_INET) {
        fprintf(stderr, "addr.inet.family should be %d but is %d\n",
                PR_AF_INET, addr.inet.family);
        exit(1);
    }
    bytes = (unsigned char *) &addr.inet.ip;
    for (idx = 0; idx < 4; idx++) {
        if (bytes[idx] != default_ipv4_addr[idx]) {
            fprintf(stderr, "byte %d of IPv4 addr should be %d but is %d\n",
                    idx, default_ipv4_addr[idx], bytes[idx]);
            exit(1);
        }
    }

    printf("PASS\n");
    return 0;
}

Here is the call graph for this function:


Variable Documentation

unsigned char default_ipv4_addr[] = {207, 200, 73, 41} [static]

Definition at line 52 of file str2addr.c.