public hostent gethostbyname(String arg0) { Pointer var0 = Pointer.createStringBuffer(arg0); int result0 = gethostbynamePtr.call1(var0); hostent result = (hostent) Function.returnStruct(hostent.class, result0); var0.free(); return result; }
/** * Look up a native libray named "name". Load if not loaded. Name can be a path or a libray name. * The Library will be looked up in a platform-dependant manor. * * @param name short library name, full file name, or path to the library file * @return NativeLibrary */ public static NativeLibrary getInstance(String name) { String nativeName = nativeLibraryName(name); Pointer name0 = Pointer.createStringBuffer(nativeName); if (DEBUG) { VM.print("Calling DLOPEN on "); VM.println(name); } int result = VM.execSyncIO( ChannelConstants.DLOPEN, name0.address().toUWord().toInt(), 0, 0, 0, 0, 0, null, null); Address r = Address.fromPrimitive(result); name0.free(); if (r.isZero()) { throw new RuntimeException("Can't open library " + name + ". OS Error: " + errorStr()); } return new NativeLibrary(name, r); }
/** * Close the library, as in dlclose. * * @throws RuntimeException if dlcose fails */ public void dispose() { if (closed || ptr.isZero()) { throw new RuntimeException("closed or RTLD_DEFAULT"); } if (DEBUG) { VM.print("Calling DLCLOSE on "); VM.println(name); } Pointer name0 = Pointer.createStringBuffer(name); int result = VM.execSyncIO( ChannelConstants.DLCLOSE, ptr.toUWord().toInt(), 0, 0, 0, 0, 0, 0, null, null); name0.free(); if (result != 0) { throw new RuntimeException("Error on dlclose: " + errorStr()); } closed = true; }
/** * getFunction a symbol's address by name (warpper around dlsym) * * @param name * @return Address of symbol */ private Address getSymbolAddress(String name) { if (closed) { throw new IllegalStateException("closed"); } if (DEBUG) { VM.print("Calling DLSYM on "); VM.println(name); } Pointer name0 = Pointer.createStringBuffer(name); int result = VM.execSyncIO( ChannelConstants.DLSYM, ptr.toUWord().toInt(), name0.address().toUWord().toInt(), 0, 0, 0, 0, null, null); name0.free(); return Address.fromPrimitive(result); }