Author: jfrederic.clere(a)jboss.com
Date: 2007-10-01 03:10:19 -0400 (Mon, 01 Oct 2007)
New Revision: 1064
Modified:
trunk/sight/native/os/solaris/network.c
Log:
That the same than the linux one.
Modified: trunk/sight/native/os/solaris/network.c
===================================================================
--- trunk/sight/native/os/solaris/network.c 2007-09-30 15:03:08 UTC (rev 1063)
+++ trunk/sight/native/os/solaris/network.c 2007-10-01 07:10:19 UTC (rev 1064)
@@ -30,6 +30,8 @@
#include "sight_types.h"
#include "sight_private.h"
+#include <unistd.h>
+
/*
* Network
*/
@@ -79,8 +81,63 @@
jlong pool)
{
- UNREFERENCED_STDARGS;
- UNREFERENCED(thiz);
- UNREFERENCED(pool);
+ int i;
+ sight_arr_t *tdns;
+ char buf[SIGHT_SBUFFER_SIZ];
+ char *pd;
+ jsize len = 0, idx = 0;
+ UNREFERENCED_O;
+
+ if (gethostname(buf, SIGHT_SBUFFER_LEN)) {
+ throwAprException(_E, apr_get_os_error());
+ return;
+ }
+ if ((pd = strchr(buf, '.'))) {
+ *pd++ = '\0';
+ SET_IFIELD_S(0000, thiz, buf);
+ SET_IFIELD_S(0001, thiz, pd);
+ }
+ else {
+ /* Use domainname if hostname misses dot */
+ SET_IFIELD_S(0000, thiz, buf);
+ if (getdomainname(buf, SIGHT_SBUFFER_LEN)) {
+ throwAprException(_E, apr_get_os_error());
+ return;
+ }
+ SET_IFIELD_S(0001, thiz, buf);
+ }
+ if ((tdns = sight_arr_rload("/etc/resolv.conf"))) {
+ for (i = 0; i < tdns->siz; i++) {
+ if (strstr(tdns->arr[i], "nameserver")) {
+ len++;
+ }
+ }
+ if (len) {
+ jobject addr;
+ jobjectArray aaddr;
+ aaddr = sight_new_netaddr_array(_E, _O, len);
+ if (!aaddr || (*_E)->ExceptionCheck(_E)) {
+ goto cleanup;
+ }
+ for (i = 0; i < tdns->siz; i++) {
+ if ((pd = strstr(tdns->arr[i], "nameserver"))) {
+ pd += 10;
+ addr = sight_new_netaddr_class(_E, _O);
+ if (!addr || (*_E)->ExceptionCheck(_E)) {
+ goto cleanup;
+ }
+ sight_netaddr_set_addr(_E, addr, sight_trim(pd));
+ sight_netaddr_set_family(_E, addr, AF_INET);
+ (*_E)->SetObjectArrayElement(_E, aaddr, idx++, addr);
+ (*_E)->DeleteLocalRef(_E, addr);
+ }
+ }
+ SET_IFIELD_O(0002, thiz, aaddr);
+ (*_E)->DeleteLocalRef(_E, aaddr);
+ }
+ }
+cleanup:
+ if (tdns)
+ sight_arr_free(tdns);
}
Show replies by date