61 |
* Function to return the local hostname |
* Function to return the local hostname |
62 |
*/ |
*/ |
63 |
JNIEXPORT jstring JNICALL |
JNIEXPORT jstring JNICALL |
64 |
Java_java_net_InetAddress_getLocalHostname(JNIEnv *env, jclass class) |
Java_java_net_InetAddress_getLocalHostname(JNIEnv *env, |
65 |
|
jclass class |
66 |
|
__attribute__ ((__unused__))) |
67 |
{ |
{ |
68 |
char hostname[256]; |
char hostname[256]; |
69 |
int result; |
int result; |
93 |
* Returns the value of the special IP address INADDR_ANY |
* Returns the value of the special IP address INADDR_ANY |
94 |
*/ |
*/ |
95 |
JNIEXPORT jarray JNICALL |
JNIEXPORT jarray JNICALL |
96 |
Java_java_net_InetAddress_lookupInaddrAny(JNIEnv *env, jclass class) |
Java_java_net_InetAddress_lookupInaddrAny(JNIEnv *env, |
97 |
|
jclass class |
98 |
|
__attribute__ ((__unused__))) |
99 |
{ |
{ |
100 |
jarray IParray; |
jarray IParray; |
101 |
jbyte *octets; |
jbyte *octets; |
139 |
* in as a byte array |
* in as a byte array |
140 |
*/ |
*/ |
141 |
JNIEXPORT jstring JNICALL |
JNIEXPORT jstring JNICALL |
142 |
Java_java_net_InetAddress_getHostByAddr(JNIEnv *env, jclass class, jarray arr) |
Java_java_net_InetAddress_getHostByAddr(JNIEnv *env, |
143 |
|
jclass class |
144 |
|
__attribute__ ((__unused__)), |
145 |
|
jarray arr) |
146 |
{ |
{ |
147 |
#ifndef WITHOUT_NETWORK |
#ifndef WITHOUT_NETWORK |
148 |
jbyte *octets; |
jbyte *octets; |
200 |
/*************************************************************************/ |
/*************************************************************************/ |
201 |
|
|
202 |
JNIEXPORT jobjectArray JNICALL |
JNIEXPORT jobjectArray JNICALL |
203 |
Java_java_net_InetAddress_getHostByName(JNIEnv *env, jclass class, jstring host) |
Java_java_net_InetAddress_getHostByName(JNIEnv *env, |
204 |
|
jclass class |
205 |
|
__attribute__ ((__unused__)), |
206 |
|
jstring host) |
207 |
{ |
{ |
208 |
#ifndef WITHOUT_NETWORK |
#ifndef WITHOUT_NETWORK |
209 |
const char *hostname; |
const char *hostname; |
216 |
int i; |
int i; |
217 |
jbyte *octets; |
jbyte *octets; |
218 |
jarray ret_octets; |
jarray ret_octets; |
219 |
|
int max_addresses; |
220 |
|
|
221 |
assert(env!=NULL); |
assert(env!=NULL); |
222 |
assert((*env)!=NULL); |
assert((*env)!=NULL); |
229 |
return (jobjectArray)NULL; |
return (jobjectArray)NULL; |
230 |
} |
} |
231 |
|
|
232 |
/* Look up the host */ |
max_addresses = sizeof(addresses) / sizeof(addresses[0]); |
233 |
TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_NAME(hostname, |
TARGET_NATIVE_NETWORK_GET_HOSTNAME_BY_NAME(hostname, |
234 |
addresses, |
addresses, |
235 |
sizeof(addresses)/sizeof(addresses[0]), |
max_addresses, |
236 |
addresses_count, |
addresses_count, |
237 |
result |
result); |
|
); |
|
238 |
if (result != TARGET_NATIVE_OK) |
if (result != TARGET_NATIVE_OK) |
239 |
{ |
{ |
240 |
JCL_ThrowException(env, UNKNOWN_HOST_EXCEPTION, (char*)hostname); |
JCL_ThrowException(env, UNKNOWN_HOST_EXCEPTION, (char*)hostname); |