| OLD | NEW |
| (Empty) |
| 1 /* | |
| 2 * Licensed to the Apache Software Foundation (ASF) under one or more | |
| 3 * contributor license agreements. See the NOTICE file distributed with | |
| 4 * this work for additional information regarding copyright ownership. | |
| 5 * The ASF licenses this file to You under the Apache License, Version 2.0 | |
| 6 * (the "License"); you may not use this file except in compliance with | |
| 7 * the License. You may obtain a copy of the License at | |
| 8 * | |
| 9 * http://www.apache.org/licenses/LICENSE-2.0 | |
| 10 * | |
| 11 * Unless required by applicable law or agreed to in writing, software | |
| 12 * distributed under the License is distributed on an "AS IS" BASIS, | |
| 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 14 * See the License for the specific language governing permissions and | |
| 15 * limitations under the License. | |
| 16 */ | |
| 17 | |
| 18 package org.apache.tomcat.jni; | |
| 19 | |
| 20 /** OS | |
| 21 * | |
| 22 * @author Mladen Turk | |
| 23 */ | |
| 24 public class OS { | |
| 25 | |
| 26 /* OS Enums */ | |
| 27 private static final int UNIX = 1; | |
| 28 private static final int NETWARE = 2; | |
| 29 private static final int WIN32 = 3; | |
| 30 private static final int WIN64 = 4; | |
| 31 private static final int LINUX = 5; | |
| 32 private static final int SOLARIS = 6; | |
| 33 private static final int BSD = 7; | |
| 34 private static final int MACOSX = 8; | |
| 35 | |
| 36 public static final int LOG_EMERG = 1; | |
| 37 public static final int LOG_ERROR = 2; | |
| 38 public static final int LOG_NOTICE = 3; | |
| 39 public static final int LOG_WARN = 4; | |
| 40 public static final int LOG_INFO = 5; | |
| 41 public static final int LOG_DEBUG = 6; | |
| 42 | |
| 43 /** | |
| 44 * Check for OS type. | |
| 45 * @param type OS type to test. | |
| 46 */ | |
| 47 private static native boolean is(int type); | |
| 48 | |
| 49 public static final boolean IS_UNIX = is(UNIX); | |
| 50 public static final boolean IS_NETWARE = is(NETWARE); | |
| 51 public static final boolean IS_WIN32 = is(WIN32); | |
| 52 public static final boolean IS_WIN64 = is(WIN64); | |
| 53 public static final boolean IS_LINUX = is(LINUX); | |
| 54 public static final boolean IS_SOLARIS = is(SOLARIS); | |
| 55 public static final boolean IS_BSD = is(BSD); | |
| 56 public static final boolean IS_MACOSX = is(MACOSX); | |
| 57 | |
| 58 /** | |
| 59 * Get the name of the system default character set. | |
| 60 * @param pool the pool to allocate the name from, if needed | |
| 61 */ | |
| 62 public static native String defaultEncoding(long pool); | |
| 63 | |
| 64 /** | |
| 65 * Get the name of the current locale character set. | |
| 66 * Defers to apr_os_default_encoding if the current locale's | |
| 67 * data can't be retrieved on this system. | |
| 68 * @param pool the pool to allocate the name from, if needed | |
| 69 */ | |
| 70 public static native String localeEncoding(long pool); | |
| 71 | |
| 72 /** | |
| 73 * Generate random bytes. | |
| 74 * @param buf Buffer to fill with random bytes | |
| 75 * @param len Length of buffer in bytes | |
| 76 */ | |
| 77 public static native int random(byte [] buf, int len); | |
| 78 | |
| 79 /** | |
| 80 * Gather system info. | |
| 81 * <PRE> | |
| 82 * On exit the inf array will be filled with: | |
| 83 * inf[0] - Total usable main memory size | |
| 84 * inf[1] - Available memory size | |
| 85 * inf[2] - Total page file/swap space size | |
| 86 * inf[3] - Page file/swap space still available | |
| 87 * inf[4] - Amount of shared memory | |
| 88 * inf[5] - Memory used by buffers | |
| 89 * inf[6] - Memory Load | |
| 90 * | |
| 91 * inf[7] - Idle Time in microseconds | |
| 92 * inf[8] - Kernel Time in microseconds | |
| 93 * inf[9] - User Time in microseconds | |
| 94 * | |
| 95 * inf[10] - Process creation time (apr_time_t) | |
| 96 * inf[11] - Process Kernel Time in microseconds | |
| 97 * inf[12] - Process User Time in microseconds | |
| 98 * | |
| 99 * inf[13] - Current working set size. | |
| 100 * inf[14] - Peak working set size. | |
| 101 * inf[15] - Number of page faults. | |
| 102 * </PRE> | |
| 103 * @param inf array that will be filled with system information. | |
| 104 * Array length must be at least 16. | |
| 105 */ | |
| 106 public static native int info(long [] inf); | |
| 107 | |
| 108 /** | |
| 109 * Expand environment variables. | |
| 110 * @param str String to expand | |
| 111 * @return Expanded string with replaced environment variables. | |
| 112 */ | |
| 113 public static native String expand(String str); | |
| 114 | |
| 115 /** | |
| 116 * Initialize system logging. | |
| 117 * @param domain String that will be prepended to every message | |
| 118 */ | |
| 119 public static native void sysloginit(String domain); | |
| 120 | |
| 121 /** | |
| 122 * Log message. | |
| 123 * @param level Log message severity. See LOG_XXX enums. | |
| 124 * @param message Message to log | |
| 125 */ | |
| 126 public static native void syslog(int level, String message); | |
| 127 | |
| 128 } | |
| OLD | NEW |