File D:\maven-qcr-plugin-testsunitaires\qcr4java\jenkins-master\target\site\qc\core\src\main\java\hudson\util\jna\GNUCLibrary.java.html

1 /*
2 * The MIT License
3 *
4 * Copyright (c) 2004-2009, Sun Microsystems, Inc., Kohsuke Kawaguchi
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
23 */
24 package hudson.util.jna;
25
26 import com.sun.jna.Library;
27 import com.sun.jna.StringArray;
28 import com.sun.jna.Pointer;
29 import com.sun.jna.Native;
30 import com.sun.jna.Memory;
31 import com.sun.jna.NativeLong;
32 import com.sun.jna.ptr.IntByReference;
33 import org.jvnet.libpam.impl.CLibrary.passwd;
34
35 /**
36 * GNU C library.
37 *
38 * <p>
39 * Not available on all platforms (such as Linux/PPC, IBM mainframe, etc.), so the caller should recover gracefully
40 * in case of {@link LinkageError}. See HUDSON-4820.
41 *
42 * @author Kohsuke Kawaguchi
43 */
44 public interface GNUCLibrary extends Library {
45 int fork();
46 int kill(int pid, int signum);
47 int setsid();
48 int umask(int mask);
49 int getpid();
50 int geteuid();
51 int getegid();
52 int getppid();
53 int chdir(String dir);
54 int getdtablesize();
55
56 int execv(String file, StringArray args);
57 int setenv(String name, String value,int replace);
58 int unsetenv(String name);
59 void perror(String msg);
60 String strerror(int errno);
61
62 passwd getpwuid(int uid);
63
64 int fcntl(int fd, int command);
65 int fcntl(int fd, int command, int flags);
66
67 // obtained from Linux. Needs to be checked if these values are portable.
68 int F_GETFD = 1;
69 int F_SETFD = 2;
70 int FD_CLOEXEC = 1;
71
72 int chown(String fileName, int uid, int gid);
73 int chmod(String fileName, int i);
74
75 int dup(int old);
76 int dup2(int old, int _new);
77 int close(int fd);
78
79 // see http://www.gnu.org/s/libc/manual/html_node/Renaming-Files.html
80 int rename(String oldname, String newname);
81
82
83 // this is listed in http://developer.apple.com/DOCUMENTATION/Darwin/Reference/ManPages/man3/sysctlbyname.3.html
84 // but not in http://www.gnu.org/software/libc/manual/html_node/System-Parameters.html#index-sysctl-3493
85 // perhaps it is only supported on BSD?
86 int sysctlbyname(String name, Pointer oldp, IntByReference oldlenp, Pointer newp, IntByReference newlen);
87
88 int sysctl(int[] mib, int nameLen, Pointer oldp, IntByReference oldlenp, Pointer newp, IntByReference newlen);
89
90 int sysctlnametomib(String name, Pointer mibp, IntByReference size);
91
92 /**
93 * Creates a symlink.
94 *
95 * See http://linux.die.net/man/3/symlink
96 */
97 int symlink(String oldname, String newname);
98
99 /**
100 * Read a symlink. The name will be copied into the specified memory, and returns the number of
101 * bytes copied. The string is not null-terminated.
102 *
103 * @return
104 * if the return value equals size, the caller needs to retry with a bigger buffer.
105 * If -1, error.
106 */
107 int readlink(String filename, Memory buffer, NativeLong size);
108
109 GNUCLibrary LIBC = (GNUCLibrary) Native.loadLibrary("c",GNUCLibrary.class);
110 }
111