com.sun.jna.platform.unix.LibCAPI Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jna-platform Show documentation
Show all versions of jna-platform Show documentation
Java Native Access Platform
/* Copyright (c) 2015 Goldstein Lyor, All Rights Reserved
*
* The contents of this file is dual-licensed under 2
* alternative Open Source/Free licenses: LGPL 2.1 or later and
* Apache License 2.0. (starting with JNA version 4.0.0).
*
* You can freely decide which license you want to apply to
* the project.
*
* You may obtain a copy of the LGPL License at:
*
* http://www.gnu.org/licenses/licenses.html
*
* A copy is also included in the downloadable source code package
* containing JNA, in file "LGPL2.1".
*
* You may obtain a copy of the Apache License at:
*
* http://www.apache.org/licenses/
*
* A copy is also included in the downloadable source code package
* containing JNA, in file "AL2.0".
*/
package com.sun.jna.platform.unix;
/**
* Note: we are using this "intermediate" API in order to allow
* Linux-like O/S-es to implement the same API, but maybe using a different
* library name
* @author Lyor Goldstein
*/
public interface LibCAPI extends Reboot, Resource {
// see man(2) get/set uid/gid
int getuid();
int geteuid();
int getgid();
int getegid();
int setuid(int uid);
int seteuid(int uid);
int setgid(int gid);
int setegid(int gid);
// see man(2) get/set hostname
int HOST_NAME_MAX = 255; // not including the '\0'
/**
* @deprecated use com.sun.jna.platform.unix.LibCAPI.gethostname(byte[], int)
*/
@Deprecated
int gethostname(char[] name, int len);
/**
* @deprecated use com.sun.jna.platform.unix.LibCAPI.sethostname(String, int)
*/
@Deprecated
int sethostname(char[] name, int len);
int gethostname(byte[] name, int len);
int sethostname(String name, int len);
// see man(2) get/set domainname
/**
* @deprecated use com.sun.jna.platform.unix.LibCAPI.getdomainname(byte[], int)
*/
@Deprecated
int getdomainname(char[] name, int len);
/**
* @deprecated use com.sun.jna.platform.unix.LibCAPI.setdomainname(String, int)
*/
@Deprecated
int setdomainname(char[] name, int len);
int getdomainname(byte[] name, int len);
int setdomainname(String name, int len);
/**
* @param name Environment variable name
* @return Returns the value in the environment, or {@code null} if there
* is no match for the name
* @see getenv(3)
*/
String getenv(String name);
/**
* Update or add a variable in the environment of the calling process.
* @param name Environment variable name
* @param value Required value
* @param overwrite If the environment variable already exists and the
* value of {@code overwrite} is non-zero, the function shall return
* success and the environment shall be updated. If the environment
* variable already exists and the value of {@code overwrite} is zero, the
* function shall return success and the environment shall remain unchanged.
* @return Upon successful completion, zero shall be returned. Otherwise,
* -1 shall be returned, {@code errno} set to indicate the error, and the
* environment shall be unchanged
* @see getenv(3)
*/
int setenv(String name, String value, int overwrite);
/**
* @param name Environment variable name - If the named variable does not
* exist in the current environment, the environment shall be unchanged
* and the function is considered to have completed successfully.
* @return Upon successful completion, zero shall be returned. Otherwise,
* -1 shall be returned, {@code errno} set to indicate the error, and the
* environment shall be unchanged
* @see getenv(3)
*/
int unsetenv(String name);
/**
* The getloadavg() function returns the number of processes in the system
* run queue averaged over various periods of time. Up to nelem samples are
* retrieved and assigned to successive elements of loadavg[]. The system
* imposes a maximum of 3 samples, representing averages over the last 1, 5,
* and 15 minutes, respectively.
* @param loadavg An array of doubles which will be filled with the results
* @param nelem Number of samples to return
* @return If the load average was unobtainable, -1 is returned; otherwise,
* the number of samples actually retrieved is returned.
* @see getloadavg(3)
*/
int getloadavg(double[] loadavg, int nelem);
}