001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: package org.apache.tomcat.jni;
019:
020: /** Procattr
021: *
022: * @author Mladen Turk
023: * @version $Revision: 467222 $, $Date: 2006-10-24 05:17:11 +0200 (mar., 24 oct. 2006) $
024: */
025:
026: public class Procattr {
027:
028: /**
029: * Create and initialize a new procattr variable
030: * @param cont The pool to use
031: * @return The newly created procattr.
032: */
033: public static native long create(long cont) throws Error;
034:
035: /**
036: * Determine if any of stdin, stdout, or stderr should be linked to pipes
037: * when starting a child process.
038: * @param attr The procattr we care about.
039: * @param in Should stdin be a pipe back to the parent?
040: * @param out Should stdout be a pipe back to the parent?
041: * @param err Should stderr be a pipe back to the parent?
042: */
043: public static native int ioSet(long attr, int in, int out, int err);
044:
045: /**
046: * Set the child_in and/or parent_in values to existing apr_file_t values.
047: * <br />
048: * This is NOT a required initializer function. This is
049: * useful if you have already opened a pipe (or multiple files)
050: * that you wish to use, perhaps persistently across multiple
051: * process invocations - such as a log file. You can save some
052: * extra function calls by not creating your own pipe since this
053: * creates one in the process space for you.
054: * @param attr The procattr we care about.
055: * @param in apr_file_t value to use as child_in. Must be a valid file.
056: * @param parent apr_file_t value to use as parent_in. Must be a valid file.
057: */
058: public static native int childInSet(long attr, long in, long parent);
059:
060: /**
061: * Set the child_out and parent_out values to existing apr_file_t values.
062: * <br />
063: * This is NOT a required initializer function. This is
064: * useful if you have already opened a pipe (or multiple files)
065: * that you wish to use, perhaps persistently across multiple
066: * process invocations - such as a log file.
067: * @param attr The procattr we care about.
068: * @param out apr_file_t value to use as child_out. Must be a valid file.
069: * @param parent apr_file_t value to use as parent_out. Must be a valid file.
070: */
071: public static native int childOutSet(long attr, long out,
072: long parent);
073:
074: /**
075: * Set the child_err and parent_err values to existing apr_file_t values.
076: * <br />
077: * This is NOT a required initializer function. This is
078: * useful if you have already opened a pipe (or multiple files)
079: * that you wish to use, perhaps persistently across multiple
080: * process invocations - such as a log file.
081: * @param attr The procattr we care about.
082: * @param err apr_file_t value to use as child_err. Must be a valid file.
083: * @param parent apr_file_t value to use as parent_err. Must be a valid file.
084: */
085: public static native int childErrSet(long attr, long err,
086: long parent);
087:
088: /**
089: * Set which directory the child process should start executing in.
090: * @param attr The procattr we care about.
091: * @param dir Which dir to start in. By default, this is the same dir as
092: * the parent currently resides in, when the createprocess call
093: * is made.
094: */
095: public static native int dirSet(long attr, String dir);
096:
097: /**
098: * Set what type of command the child process will call.
099: * @param attr The procattr we care about.
100: * @param cmd The type of command. One of:
101: * <PRE>
102: * APR_SHELLCMD -- Anything that the shell can handle
103: * APR_PROGRAM -- Executable program (default)
104: * APR_PROGRAM_ENV -- Executable program, copy environment
105: * APR_PROGRAM_PATH -- Executable program on PATH, copy env
106: * </PRE>
107: */
108: public static native int cmdtypeSet(long attr, int cmd);
109:
110: /**
111: * Determine if the child should start in detached state.
112: * @param attr The procattr we care about.
113: * @param detach Should the child start in detached state? Default is no.
114: */
115: public static native int detachSet(long attr, int detach);
116:
117: /**
118: * Specify that apr_proc_create() should do whatever it can to report
119: * failures to the caller of apr_proc_create(), rather than find out in
120: * the child.
121: * @param attr The procattr describing the child process to be created.
122: * @param chk Flag to indicate whether or not extra work should be done
123: * to try to report failures to the caller.
124: * <br />
125: * This flag only affects apr_proc_create() on platforms where
126: * fork() is used. This leads to extra overhead in the calling
127: * process, but that may help the application handle such
128: * errors more gracefully.
129: */
130: public static native int errorCheckSet(long attr, int chk);
131:
132: /**
133: * Determine if the child should start in its own address space or using the
134: * current one from its parent
135: * @param attr The procattr we care about.
136: * @param addrspace Should the child start in its own address space? Default
137: * is no on NetWare and yes on other platforms.
138: */
139: public static native int addrspaceSet(long attr, int addrspace);
140:
141: /**
142: * Specify an error function to be called in the child process if APR
143: * encounters an error in the child prior to running the specified program.
144: * @param attr The procattr describing the child process to be created.
145: * @param pool The the pool to use.
146: * @param o The Object to call in the child process.
147: * <br />
148: * At the present time, it will only be called from apr_proc_create()
149: * on platforms where fork() is used. It will never be called on other
150: * platforms, on those platforms apr_proc_create() will return the error
151: * in the parent process rather than invoke the callback in the now-forked
152: * child process.
153: */
154: public static native void errfnSet(long attr, long pool, Object o);
155:
156: /**
157: * Set the username used for running process
158: * @param attr The procattr we care about.
159: * @param username The username used
160: * @param password User password if needed. Password is needed on WIN32
161: * or any other platform having
162: * APR_PROCATTR_USER_SET_REQUIRES_PASSWORD set.
163: */
164: public static native int userSet(long attr, String username,
165: String password);
166:
167: /**
168: * Set the group used for running process
169: * @param attr The procattr we care about.
170: * @param groupname The group name used
171: */
172: public static native int groupSet(long attr, String groupname);
173:
174: }
|