Java Examples for com.sun.jna.ptr.LongByReference
The following java examples will help you to understand the usage of com.sun.jna.ptr.LongByReference. These source code samples are taken from different open source projects.
Example 1
Project: intellij-community-master File: NativeFileManager.java View source code |
public static List<Process> getProcessesUsing(File file) {
List<Process> processes = new LinkedList<>();
// If the DLL was not present (XP or other OS), do not try to find it again.
if (ourFailed) {
return processes;
}
try {
IntByReference session = new IntByReference();
char[] sessionKey = new char[Win32RestartManager.CCH_RM_SESSION_KEY + 1];
int error = Win32RestartManager.INSTANCE.RmStartSession(session, 0, sessionKey);
if (error != 0) {
Runner.logger().warn("Unable to start restart manager session");
return processes;
}
StringArray resources = new StringArray(new WString[] { new WString(file.toString()) });
error = Win32RestartManager.INSTANCE.RmRegisterResources(session.getValue(), 1, resources, 0, Pointer.NULL, 0, null);
if (error != 0) {
Runner.logger().warn("Unable to register restart manager resource " + file.getAbsolutePath());
return processes;
}
IntByReference procInfoNeeded = new IntByReference();
Win32RestartManager.RmProcessInfo info = new Win32RestartManager.RmProcessInfo();
Win32RestartManager.RmProcessInfo[] infos = (Win32RestartManager.RmProcessInfo[]) info.toArray(MAX_PROCESSES);
IntByReference procInfo = new IntByReference(infos.length);
error = Win32RestartManager.INSTANCE.RmGetList(session.getValue(), procInfoNeeded, procInfo, info, new LongByReference());
if (error != 0) {
Runner.logger().warn("Unable to get the list of processes using " + file.getAbsolutePath());
return processes;
}
for (int i = 0; i < procInfo.getValue(); i++) {
processes.add(new Process(infos[i].Process.dwProcessId, new String(infos[i].strAppName).trim()));
}
Win32RestartManager.INSTANCE.RmEndSession(session.getValue());
} catch (Throwable t) {
ourFailed = true;
}
return processes;
}
Example 2
Project: Java-Thread-Affinity-master File: WindowsJNAAffinity.java View source code |
@Override public BitSet getAffinity() { final CLibrary lib = CLibrary.INSTANCE; final LongByReference cpuset1 = new LongByReference(0); final LongByReference cpuset2 = new LongByReference(0); try { final int ret = lib.GetProcessAffinityMask(-1, cpuset1, cpuset2); // https://msdn.microsoft.com/en-us/library/windows/desktop/ms683213%28v=vs.85%29.aspx if (ret <= 0) { throw new IllegalStateException("GetProcessAffinityMask(( -1 ), &(" + cpuset1 + "), &(" + cpuset2 + ") ) return " + ret); } long[] longs = new long[1]; longs[0] = cpuset1.getValue(); return BitSet.valueOf(longs); } catch (Exception e) { LOGGER.error(e.getMessage(), e); } return new BitSet(); }
Example 3
Project: sheepit-client-master File: GPU.java View source code |
public static boolean generate() { devices = new LinkedList<GPUDevice>(); OS os = OS.getOS(); String path = os.getCUDALib(); if (path == null) { System.out.println("GPU::generate no CUDA lib path found"); return false; } CUDA cudalib = null; try { cudalib = (CUDA) Native.loadLibrary(path, CUDA.class); } catch (java.lang.UnsatisfiedLinkError e) { System.out.println("GPU::generate failed to load CUDA lib (path: " + path + ")"); return false; } catch (java.lang.ExceptionInInitializerError e) { System.out.println("GPU::generate ExceptionInInitializerError " + e); return false; } catch (Exception e) { System.out.println("GPU::generate generic exception " + e); return false; } int result = CUresult.CUDA_ERROR_UNKNOWN; result = cudalib.cuInit(0); if (result != CUresult.CUDA_SUCCESS) { System.out.println("GPU::generate cuInit failed (ret: " + result + ")"); if (result == CUresult.CUDA_ERROR_UNKNOWN) { System.out.println("If you are running Linux, this error is usually due to nvidia kernel module 'nvidia_uvm' not loaded."); System.out.println("Relaunch the application as root or load the module."); System.out.println("Most of time it does fix the issue."); } return false; } if (result == CUresult.CUDA_ERROR_NO_DEVICE) { return false; } IntByReference count = new IntByReference(); result = cudalib.cuDeviceGetCount(count); if (result != CUresult.CUDA_SUCCESS) { System.out.println("GPU::generate cuDeviceGetCount failed (ret: " + CUresult.stringFor(result) + ")"); return false; } for (int num = 0; num < count.getValue(); num++) { byte name[] = new byte[256]; result = cudalib.cuDeviceGetName(name, 256, num); if (result != CUresult.CUDA_SUCCESS) { System.out.println("GPU::generate cuDeviceGetName failed (ret: " + CUresult.stringFor(result) + ")"); continue; } LongByReference ram = new LongByReference(); try { result = cudalib.cuDeviceTotalMem_v2(ram, num); } catch (UnsatisfiedLinkError e) { result = cudalib.cuDeviceTotalMem(ram, num); } if (result != CUresult.CUDA_SUCCESS) { System.out.println("GPU::generate cuDeviceTotalMem failed (ret: " + CUresult.stringFor(result) + ")"); return false; } devices.add(new GPUDevice(new String(name).trim(), ram.getValue(), "CUDA_" + Integer.toString(num))); } return true; }
Example 4
Project: floe2-master File: PosixJNAAffinity.java View source code |
/** * Returns the affinity mask using JNA call to the clibrary. * @param pid pid of the process to get the affinity mask. 0 implies, * current thread/process. * @return the affinity mask. */ @Override public long getAffinity(final int pid) { final CLibrary lib = CLibrary.INSTANCE; //TODO: for systems with 64+ cores... final LongByReference cpuset = new LongByReference(0L); try { final int ret = lib.sched_getaffinity(pid, Long.SIZE / BYTE_SIZE, cpuset); if (ret < 0) { throw new IllegalStateException("sched_getaffinity((" + Long.SIZE / BYTE_SIZE + ") , &(" + cpuset + ") ) return " + ret); } return cpuset.getValue(); } catch (LastErrorException e) { if (e.getErrorCode() != MASK_ERROR) { throw new IllegalStateException("sched_getaffinity((" + Long.SIZE / BYTE_SIZE + ") , &(" + cpuset + ") ) errorNo=" + e.getErrorCode(), e); } } final IntByReference cpuset32 = new IntByReference(0); try { final int ret = lib.sched_getaffinity(pid, Integer.SIZE / BYTE_SIZE, cpuset32); if (ret < 0) { throw new IllegalStateException("sched_getaffinity((" + Integer.SIZE / BYTE_SIZE + ") , &(" + cpuset32 + ") ) return " + ret); } return cpuset32.getValue() & LONG_MASK; } catch (LastErrorException e) { throw new IllegalStateException("sched_getaffinity((" + Integer.SIZE / BYTE_SIZE + ") , &(" + cpuset32 + ") ) errorNo=" + e.getErrorCode(), e); } }
Example 5
Project: gst1-java-core-master File: AppSrc.java View source code |
public void getLatency(long[] minmax) { LongByReference minRef = new LongByReference(); LongByReference maxRef = new LongByReference(); gst().gst_app_src_get_latency(this, minRef, minRef); if ((minmax == null) || (minmax.length != 2)) minmax = new long[2]; minmax[0] = minRef.getValue(); minmax[1] = maxRef.getValue(); }
Example 6
Project: gstreamer-java-master File: AppSrc.java View source code |
public void getLatency(long[] minmax) { LongByReference minRef = new LongByReference(); LongByReference maxRef = new LongByReference(); gst().gst_app_src_get_latency(this, minRef, minRef); if ((minmax == null) || (minmax.length != 2)) minmax = new long[2]; minmax[0] = minRef.getValue(); minmax[1] = maxRef.getValue(); }
Example 7
Project: gstreamer1.x-java-master File: AppSrc.java View source code |
public void getLatency(long[] minmax) { LongByReference minRef = new LongByReference(); LongByReference maxRef = new LongByReference(); gst().gst_app_src_get_latency(this, minRef, minRef); if ((minmax == null) || (minmax.length != 2)) minmax = new long[2]; minmax[0] = minRef.getValue(); minmax[1] = maxRef.getValue(); }
Example 8
Project: jhllib-master File: ManagedCallImpl.java View source code |
public long itemGetSizeOnDiskEx(DirectoryItem item) { LongByReference temp = new LongByReference(); boolean success = lib.itemGetSizeOnDiskEx(item, temp); if (success) { return temp.getValue(); } else { logger.error("Failed getting size-on-disk for DirectoryItem: {} ", this.itemGetPath(item)); return -1; } }
Example 9
Project: jna-master File: StructureTest.java View source code |
private void testAlignStruct(int index) { AlignmentTest lib = Native.loadLibrary("testlib", AlignmentTest.class); try { IntByReference offset = new IntByReference(); LongByReference value = new LongByReference(); Class<?> cls = Class.forName(getClass().getName() + "$TestStructure" + index); Structure s = (Structure) cls.newInstance(); int result = lib.testStructureAlignment(s, index, offset, value); assertEquals("Wrong native value at field " + result + "=0x" + Long.toHexString(value.getValue()) + " (actual native field offset=" + offset.getValue() + ") in " + s, -2, result); } catch (Exception e) { throw new Error(e); } }
Example 10
Project: ps3mediaserver-master File: WinUtils.java View source code |
/* (non-Javadoc) * @see net.pms.io.SystemUtils#getDiskLabel(java.io.File) */ @Override public String getDiskLabel(File f) { String driveName; try { driveName = f.getCanonicalPath().substring(0, 2) + "\\"; char[] lpRootPathName_chars = new char[4]; for (int i = 0; i < 3; i++) { lpRootPathName_chars[i] = driveName.charAt(i); } lpRootPathName_chars[3] = '\0'; int nVolumeNameSize = 256; CharBuffer lpVolumeNameBuffer_char = CharBuffer.allocate(nVolumeNameSize); LongByReference lpVolumeSerialNumber = new LongByReference(); LongByReference lpMaximumComponentLength = new LongByReference(); LongByReference lpFileSystemFlags = new LongByReference(); int nFileSystemNameSize = 256; CharBuffer lpFileSystemNameBuffer_char = CharBuffer.allocate(nFileSystemNameSize); boolean result2 = Kernel32.INSTANCE.GetVolumeInformationW(lpRootPathName_chars, lpVolumeNameBuffer_char, nVolumeNameSize, lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer_char, nFileSystemNameSize); if (!result2) { return null; } String diskLabel = charString2String(lpVolumeNameBuffer_char); return diskLabel; } catch (Exception e) { return null; } }
Example 11
Project: che-master File: CgroupOOMDetector.java View source code |
@Override public void run() { final String cf = containerCgroup + "cgroup.event_control"; final String oomf = containerCgroup + "memory.oom_control"; int efd = -1; int oomfd = -1; try { if ((efd = cLib.eventfd(0, 1)) == -1) { LOG.error("Unable create a file descriptor for event notification"); return; } int cfd; if ((cfd = cLib.open(cf, CLibrary.O_WRONLY)) == -1) { LOG.error("Unable open event control file '{}' for write", cf); return; } if ((oomfd = cLib.open(oomf, CLibrary.O_RDONLY)) == -1) { LOG.error("Unable open OOM event file '{}' for read", oomf); return; } final byte[] data = String.format("%d %d", efd, oomfd).getBytes(); if (cLib.write(cfd, data, data.length) != data.length) { LOG.error("Unable write event control data to file '{}'", cf); return; } if (cLib.close(cfd) == -1) { LOG.error("Error closing of event control file '{}'", cf); return; } final LongByReference eventHolder = new LongByReference(); if (cLib.eventfd_read(efd, eventHolder) == 0) { if (stopped) { return; } LOG.warn("OOM event received for container '{}'", container); if (readCgroupValue("memory.failcnt") > 0) { try { containerLogProcessor.process(new LogMessage(LogMessage.Type.DOCKER, "[ERROR] The processes in this machine need more RAM. This machine started with " + Size.toHumanSize(memory))); containerLogProcessor.process(new LogMessage(LogMessage.Type.DOCKER, "[ERROR] Create a new machine configuration that allocates additional RAM or increase" + " the workspace RAM limit in the user dashboard.")); } catch (/*IOException*/ Exception e) { LOG.warn(e.getMessage(), e); } } } } finally { if (!stopped) { stopDetection(container); } close(oomfd); close(efd); } }
Example 12
Project: che-plugins-master File: CgroupOOMDetector.java View source code |
@Override public void run() { final String cf = containerCgroup + "cgroup.event_control"; final String oomf = containerCgroup + "memory.oom_control"; int efd = -1; int oomfd = -1; try { if ((efd = cLib.eventfd(0, 1)) == -1) { LOG.error("Unable create a file descriptor for event notification"); return; } int cfd; if ((cfd = cLib.open(cf, CLibrary.O_WRONLY)) == -1) { LOG.error("Unable open event control file '{}' for write", cf); return; } if ((oomfd = cLib.open(oomf, CLibrary.O_RDONLY)) == -1) { LOG.error("Unable open OOM event file '{}' for read", oomf); return; } final byte[] data = String.format("%d %d", efd, oomfd).getBytes(); if (cLib.write(cfd, data, data.length) != data.length) { LOG.error("Unable write event control data to file '{}'", cf); return; } if (cLib.close(cfd) == -1) { LOG.error("Error closing of event control file '{}'", cf); return; } final LongByReference eventHolder = new LongByReference(); if (cLib.eventfd_read(efd, eventHolder) == 0) { if (stopped) { return; } LOG.warn("OOM event received for container '{}'", container); if (readCgroupValue("memory.failcnt") > 0) { try { containerLogProcessor.process(new LogMessage(LogMessage.Type.DOCKER, "[ERROR] The processes in this machine need more RAM. This machine started with " + Size.toHumanSize(memory))); containerLogProcessor.process(new LogMessage(LogMessage.Type.DOCKER, "[ERROR] Create a new machine configuration that allocates additional RAM or increase" + " the workspace RAM limit in the user dashboard.")); } catch (/*IOException*/ Exception e) { LOG.warn(e.getMessage(), e); } } } } finally { if (!stopped) { stopDetection(container); } close(oomfd); close(efd); } }
Example 13
Project: DevTools-master File: CgroupOOMDetector.java View source code |
@Override public void run() { final String cf = containerCgroup + "cgroup.event_control"; final String oomf = containerCgroup + "memory.oom_control"; int efd = -1; int oomfd = -1; try { if ((efd = cLib.eventfd(0, 1)) == -1) { LOG.error("Unable create a file descriptor for event notification"); return; } int cfd; if ((cfd = cLib.open(cf, CLibrary.O_WRONLY)) == -1) { LOG.error("Unable open event control file '{}' for write", cf); return; } if ((oomfd = cLib.open(oomf, CLibrary.O_RDONLY)) == -1) { LOG.error("Unable open OOM event file '{}' for read", oomf); return; } final byte[] data = String.format("%d %d", efd, oomfd).getBytes(); if (cLib.write(cfd, data, data.length) != data.length) { LOG.error("Unable write event control data to file '{}'", cf); return; } if (cLib.close(cfd) == -1) { LOG.error("Error closing of event control file '{}'", cf); return; } final LongByReference eventHolder = new LongByReference(); if (cLib.eventfd_read(efd, eventHolder) == 0) { if (stopped) { return; } LOG.warn("OOM event received for container '{}'", container); if (readCgroupValue("memory.failcnt") > 0) { try { containerLogProcessor.process(new LogMessage(LogMessage.Type.DOCKER, "[ERROR] The processes in this machine need more RAM. This machine started with " + Size.toHumanSize(memory))); containerLogProcessor.process(new LogMessage(LogMessage.Type.DOCKER, "[ERROR] Create a new machine configuration that allocates additional RAM or increase" + " the workspace RAM limit in the user dashboard.")); } catch (/*IOException*/ Exception e) { LOG.warn(e.getMessage(), e); } } } } finally { if (!stopped) { stopDetection(container); } close(oomfd); close(efd); } }
Example 14
Project: oshi-master File: WmiUtil.java View source code |
/** * Enumerate the results of a WMI query. This method is called while results * are still being retrieved and may iterate in the forward direction only. * * @param values * A map to hold the results of the query using the property as * the key, and placing each enumerated result in a * (common-index) list for each property * @param enumerator * The enumerator with the results * @param properties * Comma-delimited list of properties to retrieve * @param propertyTypes * An array of property types matching the properties or a single * property type which will be used for all properties * @param svc * The WbemServices object */ private static void enumerateProperties(Map<String, List<Object>> values, EnumWbemClassObject enumerator, String[] properties, ValueType[] propertyTypes, WbemServices svc) { if (propertyTypes.length > 1 && properties.length != propertyTypes.length) { throw new IllegalArgumentException("Property type array size must be 1 or equal to properties array size."); } // Step 7: ------------------------------------------------- // Get the data from the query in step 6 ------------------- PointerByReference pclsObj = new PointerByReference(); LongByReference uReturn = new LongByReference(0L); while (enumerator.getPointer() != Pointer.NULL) { HRESULT hres = enumerator.Next(new NativeLong(EnumWbemClassObject.WBEM_INFINITE), new NativeLong(1), pclsObj, uReturn); // Requested 1; if 0 objects returned, we're done if (0L == uReturn.getValue() || COMUtils.FAILED(hres)) { // release it here. return; } VARIANT.ByReference vtProp = new VARIANT.ByReference(); // Get the value of the properties WbemClassObject clsObj = new WbemClassObject(pclsObj.getValue()); for (int p = 0; p < properties.length; p++) { String property = properties[p]; hres = clsObj.Get(new BSTR(property), new NativeLong(0L), vtProp, null, null); ValueType propertyType = propertyTypes.length > 1 ? propertyTypes[p] : propertyTypes[0]; switch(propertyType) { case STRING: values.get(property).add(vtProp.getValue() == null ? "unknown" : vtProp.stringValue()); break; // uint16 == VT_I4, a 32-bit number case UINT16: values.get(property).add(vtProp.getValue() == null ? 0L : vtProp.intValue()); break; // WMI Uint32s will return as longs case UINT32: values.get(property).add(vtProp.getValue() == null ? 0L : vtProp.longValue()); break; // letting this method do the parsing case UINT64: values.get(property).add(vtProp.getValue() == null ? 0L : ParseUtil.parseLongOrDefault(vtProp.stringValue(), 0L)); break; case FLOAT: values.get(property).add(vtProp.getValue() == null ? 0f : vtProp.floatValue()); break; case DATETIME: // Read a string in format 20160513072950.782000-420 and // parse to a long representing ms since eopch values.get(property).add(vtProp.getValue() == null ? 0L : ParseUtil.cimDateTimeToMillis(vtProp.stringValue())); break; case BOOLEAN: values.get(property).add(vtProp.getValue() == null ? 0L : vtProp.booleanValue()); break; case PROCESS_GETOWNER: // Win32_Process object GetOwner method String owner = FormatUtil.join("\\", execMethod(svc, vtProp.stringValue(), "GetOwner", "Domain", "User")); values.get(propertyType.name()).add("\\".equals(owner) ? "N/A" : owner); break; case PROCESS_GETOWNERSID: // Win32_Process object GetOwnerSid method String[] ownerSid = execMethod(svc, vtProp.stringValue(), "GetOwnerSid", "Sid"); values.get(propertyType.name()).add(ownerSid.length < 1 ? "" : ownerSid[0]); break; default: // added something to the enum without adding it here. Tsk. throw new IllegalArgumentException("Unimplemented enum type: " + propertyType.toString()); } OleAuto.INSTANCE.VariantClear(vtProp); } clsObj.Release(); } }
Example 15
Project: Tank-master File: WindowsProxy.java View source code |
public static ProxySettings getProxySettings() { if (available != null) throw new RuntimeException("Unable to initialise JNA libraries", available); INTERNET_PER_CONN_OPTION opt = new INTERNET_PER_CONN_OPTION(); INTERNET_PER_CONN_OPTION[] options = (INTERNET_PER_CONN_OPTION[]) opt.toArray(5); options[0].dwOption = WinInet.INTERNET_PER_CONN_FLAGS; options[1].dwOption = WinInet.INTERNET_PER_CONN_PROXY_SERVER; options[2].dwOption = WinInet.INTERNET_PER_CONN_PROXY_BYPASS; options[3].dwOption = WinInet.INTERNET_PER_CONN_AUTOCONFIG_URL; options[4].dwOption = WinInet.INTERNET_PER_CONN_AUTODISCOVERY_FLAGS; for (int i = 0; i < options.length; i++) options[i].write(); INTERNET_PER_CONN_OPTION_LIST list = new INTERNET_PER_CONN_OPTION_LIST(); list.dwOptionCount = options.length; list.dwOptionError = 0; list.pOptions = options[0].getPointer(); list.dwSize = list.size(); list.write(); LongByReference size = new LongByReference(list.size()); boolean result = wininet.InternetQueryOptionA(null, WinInet.INTERNET_OPTION_PER_CONNECTION_OPTION, list.getPointer(), size); if (!result) { System.out.println("Error: " + kernel32.GetLastError()); System.out.println("Option error: " + list.dwOptionError); return null; } else { ProxySettings settings = new ProxySettings(); list.read(); for (int i = 0; i < options.length; i++) { switch(options[i].dwOption) { case WinInet.INTERNET_PER_CONN_FLAGS: settings.flags = getInt(options[i]); break; case WinInet.INTERNET_PER_CONN_PROXY_SERVER: settings.proxyServer = getString(options[i]); break; case WinInet.INTERNET_PER_CONN_PROXY_BYPASS: settings.proxyBypass = getString(options[i]); break; case WinInet.INTERNET_PER_CONN_AUTOCONFIG_URL: settings.autoConfigUrl = getString(options[i]); break; case WinInet.INTERNET_PER_CONN_AUTODISCOVERY_FLAGS: settings.autoDiscoveryFlags = getInt(options[i]); break; } } return settings; } }
Example 16
Project: UniversalMediaServer-master File: WinUtils.java View source code |
/* (non-Javadoc) * @see net.pms.io.SystemUtils#getDiskLabel(java.io.File) */ @Override public String getDiskLabel(File f) { String driveName; try { driveName = f.getCanonicalPath().substring(0, 2) + "\\"; char[] lpRootPathName_chars = new char[4]; for (int i = 0; i < 3; i++) { lpRootPathName_chars[i] = driveName.charAt(i); } lpRootPathName_chars[3] = '\0'; int nVolumeNameSize = 256; CharBuffer lpVolumeNameBuffer_char = CharBuffer.allocate(nVolumeNameSize); LongByReference lpVolumeSerialNumber = new LongByReference(); LongByReference lpMaximumComponentLength = new LongByReference(); LongByReference lpFileSystemFlags = new LongByReference(); int nFileSystemNameSize = 256; CharBuffer lpFileSystemNameBuffer_char = CharBuffer.allocate(nFileSystemNameSize); boolean result2 = Kernel32.INSTANCE.GetVolumeInformationW(lpRootPathName_chars, lpVolumeNameBuffer_char, nVolumeNameSize, lpVolumeSerialNumber, lpMaximumComponentLength, lpFileSystemFlags, lpFileSystemNameBuffer_char, nFileSystemNameSize); if (!result2) { return null; } String diskLabel = charString2String(lpVolumeNameBuffer_char); return diskLabel; } catch (Exception e) { return null; } }
Example 17
Project: basic-algorithm-operations-master File: IEProxy.java View source code |
/** * Invokes WinInet.InternetQueryOptionA to obtain Windows Proxy Settings * * @return a {@link ProxySettings} object containing the extracted values * @throws LastErrorException * if there is an error retrieving the settings */ public static ProxySettings getProxySettings() throws LastErrorException { if (available != null) throw new RuntimeException("Unable to initialise JNA libraries", available); INTERNET_PER_CONN_OPTION.ByReference optRef = new INTERNET_PER_CONN_OPTION.ByReference(); INTERNET_PER_CONN_OPTION[] options = (INTERNET_PER_CONN_OPTION[]) optRef.toArray(5); options[0].dwOption = WinInet.INTERNET_PER_CONN_FLAGS; options[1].dwOption = WinInet.INTERNET_PER_CONN_PROXY_SERVER; options[2].dwOption = WinInet.INTERNET_PER_CONN_PROXY_BYPASS; options[3].dwOption = WinInet.INTERNET_PER_CONN_AUTOCONFIG_URL; options[4].dwOption = WinInet.INTERNET_PER_CONN_AUTODISCOVERY_FLAGS; for (int i = 0; i < options.length; i++) options[i].write(); INTERNET_PER_CONN_OPTION_LIST list = new INTERNET_PER_CONN_OPTION_LIST(); list.dwOptionCount = options.length; list.dwOptionError = 0; list.pOptions = optRef; list.dwSize = list.size(); list.write(); LongByReference size = new LongByReference(list.size()); boolean result = wininet.InternetQueryOptionA(null, WinInet.INTERNET_OPTION_PER_CONNECTION_OPTION, list.getPointer(), size); if (!result) { System.out.println("Error: " + Native.getLastError()); System.out.println("Option error: " + list.dwOptionError); return null; } else { ProxySettings settings = new ProxySettings(); list.read(); for (int i = 0; i < options.length; i++) { switch(options[i].dwOption) { case WinInet.INTERNET_PER_CONN_FLAGS: settings.flags = getInt(options[i]); break; case WinInet.INTERNET_PER_CONN_PROXY_SERVER: settings.proxyServer = getString(options[i]); break; case WinInet.INTERNET_PER_CONN_PROXY_BYPASS: settings.proxyBypass = getString(options[i]); break; case WinInet.INTERNET_PER_CONN_AUTOCONFIG_URL: settings.autoConfigUrl = getString(options[i]); break; case WinInet.INTERNET_PER_CONN_AUTODISCOVERY_FLAGS: settings.autoDiscoveryFlags = getInt(options[i]); break; } } return settings; } }
Example 18
Project: jmonkeyengine-master File: OpenVR.java View source code |
@Override
public boolean initialize() {
logger.config("Initializing OpenVR system...");
hmdErrorStore = new IntByReference();
vrsystemFunctions = null;
JOpenVRLibrary.VR_InitInternal(hmdErrorStore, JOpenVRLibrary.EVRApplicationType.EVRApplicationType_VRApplication_Scene);
if (hmdErrorStore.getValue() == 0) {
vrsystemFunctions = new VR_IVRSystem_FnTable(JOpenVRLibrary.VR_GetGenericInterface(JOpenVRLibrary.IVRSystem_Version, hmdErrorStore).getPointer());
}
if (vrsystemFunctions == null || hmdErrorStore.getValue() != 0) {
logger.severe("OpenVR Initialize Result: " + JOpenVRLibrary.VR_GetVRInitErrorAsEnglishDescription(hmdErrorStore.getValue()).getString(0));
logger.severe("Initializing OpenVR system [FAILED]");
return false;
} else {
logger.config("OpenVR initialized & VR connected.");
vrsystemFunctions.setAutoSynch(false);
vrsystemFunctions.read();
tlastVsync = new FloatByReference();
_tframeCount = new LongByReference();
hmdDisplayFrequency = IntBuffer.allocate(1);
hmdDisplayFrequency.put((int) JOpenVRLibrary.ETrackedDeviceProperty.ETrackedDeviceProperty_Prop_DisplayFrequency_Float);
hmdTrackedDevicePoseReference = new TrackedDevicePose_t.ByReference();
hmdTrackedDevicePoses = (TrackedDevicePose_t[]) hmdTrackedDevicePoseReference.toArray(JOpenVRLibrary.k_unMaxTrackedDeviceCount);
poseMatrices = new Matrix4f[JOpenVRLibrary.k_unMaxTrackedDeviceCount];
for (int i = 0; i < poseMatrices.length; i++) poseMatrices[i] = new Matrix4f();
timePerFrame = 1.0 / hmdDisplayFrequency.get(0);
// disable all this stuff which kills performance
hmdTrackedDevicePoseReference.setAutoRead(false);
hmdTrackedDevicePoseReference.setAutoWrite(false);
hmdTrackedDevicePoseReference.setAutoSynch(false);
for (int i = 0; i < JOpenVRLibrary.k_unMaxTrackedDeviceCount; i++) {
hmdTrackedDevicePoses[i].setAutoRead(false);
hmdTrackedDevicePoses[i].setAutoWrite(false);
hmdTrackedDevicePoses[i].setAutoSynch(false);
}
// init controllers for the first time
VRinput = new OpenVRInput(environment);
VRinput.init();
VRinput.updateConnectedControllers();
// init bounds & chaperone info
VRBounds.init();
logger.config("Initializing OpenVR system [SUCCESS]");
initSuccess = true;
return true;
}
}
Example 19
Project: OWASP-Proxy-master File: WindowsProxy.java View source code |
/** * Invokes WinInet.InternetQueryOptionA to obtain Windows Proxy Settings * * @return a {@link ProxySettings} object containing the extracted values * @throws LastErrorException * if there is an error retrieving the settings */ public static ProxySettings getProxySettings() throws LastErrorException { if (available != null) throw new RuntimeException("Unable to initialise JNA libraries", available); INTERNET_PER_CONN_OPTION.ByReference optRef = new INTERNET_PER_CONN_OPTION.ByReference(); INTERNET_PER_CONN_OPTION[] options = (INTERNET_PER_CONN_OPTION[]) optRef.toArray(5); options[0].dwOption = WinInet.INTERNET_PER_CONN_FLAGS; options[1].dwOption = WinInet.INTERNET_PER_CONN_PROXY_SERVER; options[2].dwOption = WinInet.INTERNET_PER_CONN_PROXY_BYPASS; options[3].dwOption = WinInet.INTERNET_PER_CONN_AUTOCONFIG_URL; options[4].dwOption = WinInet.INTERNET_PER_CONN_AUTODISCOVERY_FLAGS; for (int i = 0; i < options.length; i++) options[i].write(); INTERNET_PER_CONN_OPTION_LIST list = new INTERNET_PER_CONN_OPTION_LIST(); list.dwOptionCount = options.length; list.dwOptionError = 0; list.pOptions = optRef; list.dwSize = list.size(); list.write(); LongByReference size = new LongByReference(list.size()); boolean result = wininet.InternetQueryOptionA(null, WinInet.INTERNET_OPTION_PER_CONNECTION_OPTION, list.getPointer(), size); if (!result) { System.out.println("Error: " + Native.getLastError()); System.out.println("Option error: " + list.dwOptionError); return null; } else { ProxySettings settings = new ProxySettings(); list.read(); for (int i = 0; i < options.length; i++) { switch(options[i].dwOption) { case WinInet.INTERNET_PER_CONN_FLAGS: settings.flags = getInt(options[i]); break; case WinInet.INTERNET_PER_CONN_PROXY_SERVER: settings.proxyServer = getString(options[i]); break; case WinInet.INTERNET_PER_CONN_PROXY_BYPASS: settings.proxyBypass = getString(options[i]); break; case WinInet.INTERNET_PER_CONN_AUTOCONFIG_URL: settings.autoConfigUrl = getString(options[i]); break; case WinInet.INTERNET_PER_CONN_AUTODISCOVERY_FLAGS: settings.autoDiscoveryFlags = getInt(options[i]); break; } } return settings; } }
Example 20
Project: muCommander-master File: LocalFile.java View source code |
/** * Uses platform dependent functions to retrieve the total and free space on the volume where this file resides. * * @return a {totalSpace, freeSpace} long array, both values can be <code>null</code> if the information could not * be retrieved. * @throws IOException if an I/O error occurred */ protected long[] getNativeVolumeInfo() throws IOException { BufferedReader br = null; String absPath = getAbsolutePath(); long dfInfo[] = new long[] { -1, -1 }; try { // OS is Windows if (IS_WINDOWS) { // Use the Kernel32 DLL if it is available if (Kernel32.isAvailable()) { // Retrieves the total and free space information using the GetDiskFreeSpaceEx function of the // Kernel32 API. LongByReference totalSpaceLBR = new LongByReference(); LongByReference freeSpaceLBR = new LongByReference(); if (Kernel32.getInstance().GetDiskFreeSpaceEx(absPath, null, totalSpaceLBR, freeSpaceLBR)) { dfInfo[0] = totalSpaceLBR.getValue(); dfInfo[1] = freeSpaceLBR.getValue(); } else { LOGGER.warn("Call to GetDiskFreeSpaceEx failed, absPath={}", absPath); } } else // appear briefly every time this method is called (See ticket #63). if (OsVersion.WINDOWS_NT.isCurrentOrHigher()) { // 'dir' command returns free space on the last line Process process = Runtime.getRuntime().exec((OsVersion.getCurrent().compareTo(OsVersion.WINDOWS_NT) >= 0 ? "cmd /c" : "command.com /c") + " dir \"" + absPath + "\""); // Check that the process was correctly started if (process != null) { br = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; String lastLine = null; // Retrieves last line of dir while ((line = br.readLine()) != null) { if (!line.trim().equals("")) lastLine = line; } // 6 Rep(s) 14 767 521 792 octets libres if (lastLine != null) { StringTokenizer st = new StringTokenizer(lastLine, " \t\n\r\f,."); // Discard first token st.nextToken(); // Concatenates as many contiguous groups of numbers String token; String freeSpace = ""; while (st.hasMoreTokens()) { token = st.nextToken(); char c = token.charAt(0); if (c >= '0' && c <= '9') freeSpace += token; else if (!freeSpace.equals("")) break; } dfInfo[1] = Long.parseLong(freeSpace); } } } } else if (OsFamily.getCurrent().isUnixBased()) { // Parses the output of 'df -P -k "filePath"' command on UNIX-based systems to retrieve free and total space information // 'df -P -k' returns totals in block of 1K = 1024 bytes, -P uses the POSIX output format, ensures that line won't break Process process = Runtime.getRuntime().exec(new String[] { "df", "-P", "-k", absPath }, null, file); // Check that the process was correctly started if (process != null) { br = new BufferedReader(new InputStreamReader(process.getInputStream())); // Discard the first line ("Filesystem 1K-blocks Used Avail Capacity Mounted on"); br.readLine(); String line = br.readLine(); // Sample lines: // /dev/disk0s2 116538416 109846712 6179704 95% / // automount -fstab [202] 0 0 0 100% /automount/Servers // /dev/disk2s2 2520 1548 972 61% /Volumes/muCommander 0.8 // We're interested in the '1K-blocks' and 'Avail' fields (only). // The 'Filesystem' and 'Mounted On' fields can contain spaces (e.g. 'automount -fstab [202]' and // '/Volumes/muCommander 0.8' resp.) and therefore be made of several tokens. A stable way to // determine the position of the fields we're interested in is to look for the last token that // starts with a '/' character which should necessarily correspond to the first token of the // 'Mounted on' field. The '1K-blocks' and 'Avail' fields are 4 and 2 tokens away from it // respectively. // Start by tokenizing the whole line Vector<String> tokenV = new Vector<String>(); if (line != null) { StringTokenizer st = new StringTokenizer(line); while (st.hasMoreTokens()) tokenV.add(st.nextToken()); } int nbTokens = tokenV.size(); if (nbTokens < 6) { // This shouldn't normally happen LOGGER.warn("Failed to parse output of df -k {} line={}", absPath, line); return dfInfo; } // Find the last token starting with '/' int pos = nbTokens - 1; while (!tokenV.elementAt(pos).startsWith("/")) { if (pos == 0) { // This shouldn't normally happen LOGGER.warn("Failed to parse output of df -k {} line={}", absPath, line); return dfInfo; } --pos; } // '1-blocks' field (total space) dfInfo[0] = Long.parseLong(tokenV.elementAt(pos - 4)) * 1024; // 'Avail' field (free space) dfInfo[1] = Long.parseLong(tokenV.elementAt(pos - 2)) * 1024; } // // Retrieves the total and free space information using the POSIX statvfs function // POSIX.STATVFSSTRUCT struct = new POSIX.STATVFSSTRUCT(); // if(POSIX.INSTANCE.statvfs(absPath, struct)==0) { // dfInfo[0] = struct.f_blocks * (long)struct.f_frsize; // dfInfo[1] = struct.f_bfree * (long)struct.f_frsize; // } } } finally { if (br != null) try { br.close(); } catch (IOException e) { } } return dfInfo; }
Example 21
Project: Couverjure-master File: StructureTest.java View source code |
private void testAlignStruct(int index) { AlignmentTest lib = (AlignmentTest) Native.loadLibrary("testlib", AlignmentTest.class); try { IntByReference offset = new IntByReference(); LongByReference value = new LongByReference(); Class cls = Class.forName(getClass().getName() + "$TestStructure" + index); Structure s = (Structure) cls.newInstance(); int result = lib.testStructureAlignment(s, index, offset, value); assertEquals("Wrong native value at field " + result + "=0x" + Long.toHexString(value.getValue()) + " (actual native field offset=" + offset.getValue() + ") in " + s, -2, result); } catch (Exception e) { throw new Error(e); } }
Example 22
Project: jna-mirror-master File: StructureTest.java View source code |
private void testAlignStruct(int index) { AlignmentTest lib = (AlignmentTest) Native.loadLibrary("testlib", AlignmentTest.class); try { IntByReference offset = new IntByReference(); LongByReference value = new LongByReference(); Class cls = Class.forName(getClass().getName() + "$TestStructure" + index); Structure s = (Structure) cls.newInstance(); int result = lib.testStructureAlignment(s, index, offset, value); assertEquals("Wrong native value at field " + result + "=0x" + Long.toHexString(value.getValue()) + " (actual native field offset=" + offset.getValue() + ") in " + s, -2, result); } catch (Exception e) { throw new Error(e); } }
Example 23
Project: JNAerator-master File: TypeConversion.java View source code |
public void initTypes() {
result.prim("void", JavaPrim.Void);
result.prim("VOID", JavaPrim.Void);
result.prim("UTF32Char", JavaPrim.Int);
result.prim("unichar", JavaPrim.Char);
result.prim("int64_t", JavaPrim.Long);
result.prim("uint64_t", JavaPrim.Long);
result.prim("u_int64_t", JavaPrim.Long);
result.prim("long long", JavaPrim.Long);
result.prim("long long int", JavaPrim.Long);
result.prim("long int", JavaPrim.Int);
result.prim("LONGLONG", JavaPrim.Long);
result.prim("ULONGLONG", JavaPrim.Long);
result.prim("INT", JavaPrim.Int);
result.prim("UINT", JavaPrim.Int);
result.prim("SHORT", JavaPrim.Short);
result.prim("USHORT", JavaPrim.Short);
result.prim("CHAR", JavaPrim.Byte);
result.prim("byte", JavaPrim.Byte);
result.prim("BYTE", JavaPrim.Byte);
result.prim("UBYTE", JavaPrim.Byte);
result.prim("DOUBLE", JavaPrim.Double);
result.prim("FLOAT", JavaPrim.Float);
result.prim("WORD", JavaPrim.Short);
result.prim("DWORD", JavaPrim.Int);
result.prim("DWORD64", JavaPrim.Long);
result.prim("LONG64", JavaPrim.Long);
result.prim("UInt64", JavaPrim.Long);
result.prim("SInt64", JavaPrim.Long);
result.prim("__int64", JavaPrim.Long);
result.prim("__int64_t", JavaPrim.Long);
result.prim("int32_t", JavaPrim.Int);
result.prim("uint32_t", JavaPrim.Int);
result.prim("__int32_t", JavaPrim.Int);
result.prim("__uint32_t", JavaPrim.Int);
result.prim("u_int32_t", JavaPrim.Int);
result.prim("uint32", JavaPrim.Int);
result.prim("int32", JavaPrim.Int);
result.prim("int", JavaPrim.Int);
//prim("NSUInteger", JavaPrim.NativeSize);
//prim("NSInteger", JavaPrim.NativeSize);
result.prim("SInt32", JavaPrim.Int);
result.prim("UInt32", JavaPrim.Int);
result.prim("GLint", JavaPrim.Int);
result.prim("GLuint", JavaPrim.Int);
result.prim("GLenum", JavaPrim.Int);
result.prim("GLsizei", JavaPrim.Int);
result.prim("__int32", JavaPrim.Int);
result.prim("NSInteger", JavaPrim.NSInteger);
result.prim("NSUInteger", JavaPrim.NSUInteger);
result.prim("CGFloat", JavaPrim.CGFloat);
JavaPrim longPrim = result.config.gccLong ? JavaPrim.NativeSize : JavaPrim.NativeLong;
result.prim("long", longPrim);
result.prim("LONG", longPrim);
result.prim("ULONG", longPrim);
result.prim("time_t", JavaPrim.NativeTime);
JavaPrim sizePrim = result.config.sizeAsLong ? longPrim : JavaPrim.NativeSize;
result.prim("size_t", sizePrim);
result.prim("ptrdiff_t", sizePrim);
result.prim("__darwin_size_t", JavaPrim.NativeSize);
result.prim("complex double", JavaPrim.ComplexDouble);
result.prim("int16_t", JavaPrim.Short);
result.prim("uint16_t", JavaPrim.Short);
result.prim("__int16_t", JavaPrim.Short);
result.prim("__uint16_t", JavaPrim.Short);
result.prim("u_int16_t", JavaPrim.Short);
result.prim("uint16", JavaPrim.Short);
result.prim("int16", JavaPrim.Short);
result.prim("SInt16", JavaPrim.Short);
result.prim("UInt16", JavaPrim.Short);
result.prim("short", JavaPrim.Short);
result.prim("WCHAR", JavaPrim.Short);
result.prim("wchar_t", result.config.wcharAsShort ? JavaPrim.Short : JavaPrim.Char);
result.prim("__int16", JavaPrim.Short);
result.prim("int8_t", JavaPrim.Byte);
result.prim("uint8_t", JavaPrim.Byte);
result.prim("u_int8_t", JavaPrim.Byte);
result.prim("__uint8_t", JavaPrim.Byte);
result.prim("__int8_t", JavaPrim.Byte);
result.prim("SInt8", JavaPrim.Byte);
result.prim("UInt8", JavaPrim.Byte);
result.prim("char", JavaPrim.Byte);
result.prim("unsigned char", JavaPrim.Byte);
result.prim("__unsigned char", JavaPrim.Byte);
result.prim("signed char", JavaPrim.Byte);
result.prim("__signed char", JavaPrim.Byte);
result.prim("SignedByte", JavaPrim.Byte);
result.prim("__int8", JavaPrim.Byte);
result.prim("float", JavaPrim.Float);
result.prim("NSFloat", JavaPrim.Float);
result.prim("CGFloat", JavaPrim.Float);
result.prim("double_t", JavaPrim.Double);
result.prim("double", JavaPrim.Double);
result.prim("NSDouble", JavaPrim.Double);
result.prim("CGDouble", JavaPrim.Double);
JavaPrim cppBoolType = getCppBoolMappingType();
result.prim("bool", cppBoolType);
result.prim("Boolean", cppBoolType);
result.prim("boolean_t", cppBoolType);
primToByReference.put(JavaPrim.Int, IntByReference.class);
primToByReference.put(JavaPrim.Char, (Class) CharByReference.class);
primToByReference.put(JavaPrim.Short, ShortByReference.class);
primToByReference.put(JavaPrim.Byte, ByteByReference.class);
primToByReference.put(JavaPrim.Long, LongByReference.class);
primToByReference.put(JavaPrim.Float, FloatByReference.class);
primToByReference.put(JavaPrim.Double, DoubleByReference.class);
primToByReference.put(JavaPrim.NativeLong, NativeLongByReference.class);
primToByReference.put(JavaPrim.NativeSize, (Class) NativeSizeByReference.class);
primToByReference.put(JavaPrim.NSInteger, (Class) NativeSizeByReference.class);
primToByReference.put(JavaPrim.NSUInteger, (Class) NativeSizeByReference.class);
primToByReference.put(JavaPrim.CGFloat, CGFloatByReference.class);
//primsByReference.put(JavaPrim.Void, PointerByReference.class);
for (Class<?> c : primToByReference.values()) {
byReferenceClassesNames.add(c.getName());
}
// byReferenceClassesNames.add(PointerByReference.class.getName());
primToGlobal.put(JavaPrim.Int, GlobalInt.class);
primToGlobal.put(JavaPrim.Char, GlobalChar.class);
primToGlobal.put(JavaPrim.Short, GlobalShort.class);
primToGlobal.put(JavaPrim.Byte, GlobalByte.class);
primToGlobal.put(JavaPrim.Long, GlobalLong.class);
primToGlobal.put(JavaPrim.Float, GlobalFloat.class);
primToGlobal.put(JavaPrim.Double, GlobalDouble.class);
primToGlobal.put(JavaPrim.NativeLong, GlobalNativeLong.class);
primToGlobal.put(JavaPrim.NativeSize, GlobalNativeSize.class);
primToGlobal.put(JavaPrim.NSInteger, GlobalNativeSize.class);
primToGlobal.put(JavaPrim.NSUInteger, GlobalNativeSize.class);
primToGlobal.put(JavaPrim.CGFloat, GlobalCGFloat.class);
primToBuffer.put(JavaPrim.Int, IntBuffer.class);
primToBuffer.put(JavaPrim.Char, CharBuffer.class);
primToBuffer.put(JavaPrim.Short, ShortBuffer.class);
primToBuffer.put(JavaPrim.Byte, ByteBuffer.class);
primToBuffer.put(JavaPrim.Long, LongBuffer.class);
primToBuffer.put(JavaPrim.Float, FloatBuffer.class);
primToBuffer.put(JavaPrim.Double, DoubleBuffer.class);
//primToBuffer.put(JavaPrim.NativeLong, NativeLongByReference.class);
TypeRef pInt = new TypeRef.Pointer(new Primitive("int"), Declarator.PointerStyle.Pointer);
result.addManualTypeDef("intptr_t", pInt);
result.addManualTypeDef("uintptr_t", pInt);
// TODO: Add a windows failsafe mode that defines all the typedefs needed:
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx
// TypeRef pVoid = new TypeRef.Pointer(new Primitive("void"), Declarator.PointerStyle.Pointer);
// result.addManualTypeDef("PVOID", pVoid);
// result.addManualTypeDef("LPVOID", pVoid);
// result.addManualTypeDef("LPCVOID", pVoid);
}
Example 24
Project: yajsw-master File: WindowsXPProcess.java View source code |
/** * Gets the total cpu. * * @return the total cpu */ public long getTotalCPU() { long result = -1; if (!isRunning()) return -1; LongByReference lpCreationTime = new LongByReference(); LongByReference lpExitTime = new LongByReference(); LongByReference lpKernelTime = new LongByReference(); LongByReference lpUserTime = new LongByReference(); if (MyKernel32.INSTANCE.GetProcessTimes(_processInformation.hProcess, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime)) result = lpUserTime.getValue() + lpKernelTime.getValue(); return result; }
Example 25
Project: yajsw-maven-master File: WindowsXPProcess.java View source code |
/** * Gets the total cpu. * * @return the total cpu */ public long getTotalCPU() { long result = -1; if (!isRunning()) return -1; LongByReference lpCreationTime = new LongByReference(); LongByReference lpExitTime = new LongByReference(); LongByReference lpKernelTime = new LongByReference(); LongByReference lpUserTime = new LongByReference(); if (MyKernel32.INSTANCE.GetProcessTimes(_processInformation.hProcess, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime)) result = lpUserTime.getValue() + lpKernelTime.getValue(); return result; }
Example 26
Project: yajsw-maven-mk2-master File: WindowsXPProcess.java View source code |
/** * Gets the total cpu. * * @return the total cpu */ public long getTotalCPU() { long result = -1; if (!isRunning()) return -1; LongByReference lpCreationTime = new LongByReference(); LongByReference lpExitTime = new LongByReference(); LongByReference lpKernelTime = new LongByReference(); LongByReference lpUserTime = new LongByReference(); if (MyKernel32.INSTANCE.GetProcessTimes(_processInformation.hProcess, lpCreationTime, lpExitTime, lpKernelTime, lpUserTime)) result = lpUserTime.getValue() + lpKernelTime.getValue(); return result; }
Example 27
Project: java-uia-bridge-master File: MSAAObject.java View source code |
public int getChildCount() { /*LongByReference lng = new LongByReference(); iAccessible.Get_accChildCount(lng); return lng.getValue();*/ Variant v = Dispatch.get(dispatch, "accChildCount"); return v.getInt(); }
Example 28
Project: vlcj-master File: AbstractCallbackMedia.java View source code |
@Override
public int open(Pointer opaque, PointerByReference datap, LongByReference sizep) {
logger.debug("open()");
sizep.setValue(onGetSize());
return onOpen() ? SUCCESS : ERROR;
}
Example 29
Project: vlove-master File: Connect.java View source code |
/** * Get the version of a connection. * * @see <a * href="http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetLibVersion">Libvirt * Documentation</a> * @param conn * the connection to use. * @return -1 in case of failure, versions have the format major * 1,000,000 * + minor * 1,000 + release. */ public static long connectionVersion(Connect conn) { LongByReference libVer = new LongByReference(); int result = Libvirt.INSTANCE.virConnectGetLibVersion(conn.VCP, libVer); return result != -1 ? libVer.getValue() : -1; }