- All Superinterfaces:
com.sun.jna.Library
public interface LibC
extends com.sun.jna.Library
Minimal interface to the standard "C" library.
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.sun.jna.Library
com.sun.jna.Library.Handler -
Field Summary
FieldsFields inherited from interface com.sun.jna.Library
OPTION_ALLOW_OBJECTS, OPTION_CALLING_CONVENTION, OPTION_CLASSLOADER, OPTION_FUNCTION_MAPPER, OPTION_INVOCATION_MAPPER, OPTION_OPEN_FLAGS, OPTION_STRING_ENCODING, OPTION_STRUCTURE_ALIGNMENT, OPTION_TYPE_MAPPER -
Method Summary
Modifier and TypeMethodDescriptionintClosest Windows equivalent tosetenv(String, String, int).intgetpid()Get the current process id.intmlock(com.sun.jna.Pointer addr, com.sun.jna.NativeLong length) Locks (pins) parts of virtual address space into RAM so it can not be swapped out.intmunlock(com.sun.jna.Pointer addr, com.sun.jna.NativeLong length) Unlock previously locked memory.intChange or add an evironment variable.intUnset an environment variable.intvsnprintf(ByteBuffer str, int size, String format, com.sun.jna.Pointer args) Format a string with a variable arguments list into a fixed size buffer.
-
Field Details
-
INSTANCE
Native library instance.
-
-
Method Details
-
vsnprintf
Format a string with a variable arguments list into a fixed size buffer.The resultant string will be truncated to the size of the buffer if it would otherwise exceed it.
For example, if the buffer has a capacity of 10 this is a maximum of 9 characters plus a null terminator for a total capacity of 10. This means if 10 characters are required, the buffer capacity must be 11 to accommodate the null terminator.
- Parameters:
str- buffersize- capacity of the buffer, including space for a null terminatorformat- format stringargs- format arguments- Returns:
- length of the formatted string, which may exceed the capacity of the buffer, or less than zero on error
-
mlock
int mlock(com.sun.jna.Pointer addr, com.sun.jna.NativeLong length) Locks (pins) parts of virtual address space into RAM so it can not be swapped out.- Parameters:
addr- address pointerlength- length- Returns:
- 0 if successful; -1 if not, setting
errnoto an error code
-
munlock
int munlock(com.sun.jna.Pointer addr, com.sun.jna.NativeLong length) Unlock previously locked memory.- Parameters:
addr- address pointerlength- length- Returns:
- 0 if successful; -1 if not, setting
errnoto an error code
-
setenv
Change or add an evironment variable.The value strings are copied (natively).
Not available on Windows.
- Parameters:
name- name of environment variablevalue- value of the environment variableoverwrite- non-zero to replace any existing value- Returns:
- 0 if successful; -1 if not, setting
errnoto an error code
-
unsetenv
Unset an environment variable.Not available on Windows.
- Parameters:
name- name of environment variable- Returns:
- 0 if successful; -1 if not, setting
errnoto an error code
-
getpid
int getpid()Get the current process id.Not available on Windows.
- Returns:
- process id
-
_putenv
Closest Windows equivalent tosetenv(String, String, int).Note that after setting an environment variable, it will not show up via System#getenv even if it was successfully set.
Use with case, it is not guaranteed to be thread-safe.
Only available on Windows.
- Parameters:
envstring- variable and value to set, in the format "variable=value", without quotes.- Returns:
- zero on success, non-zero on error
-