aboutsummaryrefslogtreecommitdiff
path: root/tests/nbody-java/native_java_net_InetAddress.c
blob: beac4439985411f6b26b18343b5071af0e033155 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include "xmlvm.h"
#include "java_net_InetAddress.h"


//XMLVM_BEGIN_NATIVE_IMPLEMENTATION
#include "xmlvm-util.h"
#include "xmlvm-sock.h"
#include "java_net_UnknownHostException.h"
//XMLVM_END_NATIVE_IMPLEMENTATION

void java_net_InetAddress_oneTimeInitialization___boolean(JAVA_BOOLEAN n1)
{
    //XMLVM_BEGIN_NATIVE[java_net_InetAddress_oneTimeInitialization___boolean]
    //XMLVM_END_NATIVE
}

JAVA_OBJECT java_net_InetAddress_getAliasesByNameImpl___java_lang_String(JAVA_OBJECT n1)
{
    //XMLVM_BEGIN_NATIVE[java_net_InetAddress_getAliasesByNameImpl___java_lang_String]
    XMLVM_UNIMPLEMENTED_NATIVE_METHOD();
    //XMLVM_END_NATIVE
}

JAVA_OBJECT java_net_InetAddress_getHostByAddrImpl___byte_1ARRAY(JAVA_OBJECT n1)
{
    //XMLVM_BEGIN_NATIVE[java_net_InetAddress_getHostByAddrImpl___byte_1ARRAY]
    org_xmlvm_runtime_XMLVMArray* addr = n1;
    I_32 result = 0;
    hysockaddr_struct in_addr;
    U_32 length;
    char hostName[OSNIMAXHOST];
    JAVA_ARRAY_BYTE ipaddr[HYSOCK_INADDR6_LEN];
    int address_family = HYADDR_FAMILY_AFINET4;
    length = addr->fields.org_xmlvm_runtime_XMLVMArray.length_;
    
    /* If it's a valid length for an IP address then do the work */
    if (length == HYSOCK_INADDR6_LEN || length == HYSOCK_INADDR_LEN)
    {
        
        if (length == HYSOCK_INADDR6_LEN)
        {
            address_family = HYADDR_FAMILY_AFINET6;
        }
        
        JAVA_ARRAY_BYTE* addrData = (JAVA_ARRAY_BYTE*) addr->fields.org_xmlvm_runtime_XMLVMArray.array_;
        XMLVM_MEMCPY(ipaddr, addrData, length);
        hysock_sockaddr_init6 (&in_addr, (U_8 *) ipaddr, length,
                               (I_16) address_family, 0, 0, 0, NULL);
        result =
        hysock_getnameinfo (&in_addr, sizeof (in_addr.addr), hostName,
                            OSNIMAXHOST, 0);
        if (0 == result)
        {
            return newJavaNetInetAddressGenericBS (ipaddr, length, hostName, 0);
        }
    }

    XMLVM_THROW_WITH_CSTRING(java_net_UnknownHostException, netLookupErrorString(result))
    
    return JAVA_NULL;
    //XMLVM_END_NATIVE
}

JAVA_INT java_net_InetAddress_inetAddrImpl___java_lang_String(JAVA_OBJECT n1)
{
    //XMLVM_BEGIN_NATIVE[java_net_InetAddress_inetAddrImpl___java_lang_String]
    XMLVM_UNIMPLEMENTED_NATIVE_METHOD();
    //XMLVM_END_NATIVE
}

JAVA_OBJECT java_net_InetAddress_inetNtoaImpl___int(JAVA_INT n1)
{
    //XMLVM_BEGIN_NATIVE[java_net_InetAddress_inetNtoaImpl___int]
    XMLVM_UNIMPLEMENTED_NATIVE_METHOD();
    //XMLVM_END_NATIVE
}

JAVA_OBJECT java_net_InetAddress_getHostByNameImpl___java_lang_String_boolean(JAVA_OBJECT n1, JAVA_BOOLEAN n2)
{
    //XMLVM_BEGIN_NATIVE[java_net_InetAddress_getHostByNameImpl___java_lang_String_boolean]
    XMLVM_UNIMPLEMENTED_NATIVE_METHOD();
    //XMLVM_END_NATIVE
}

JAVA_OBJECT java_net_InetAddress_getHostNameImpl__()
{
    //XMLVM_BEGIN_NATIVE[java_net_InetAddress_getHostNameImpl__]
    XMLVM_UNIMPLEMENTED_NATIVE_METHOD();
    //XMLVM_END_NATIVE
}