2362N/A * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 2362N/A * published by the Free Software Foundation. Oracle designates this 0N/A * particular file as subject to the "Classpath" exception as provided 2362N/A * by Oracle in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 0N/A * This is a primitive bootstrapping utility for executing Java CGI 0N/A * programs, specifically Java RMI's CGI HTTP forwarding mechanism 0N/A * It executes the Java interpreter with options to define 0N/A * properties corresponding to the environment variables set by the 0N/A * CGI 1.0 specification and runs the target class. 0N/A * The following assumptions are made: 0N/A * - the Java interpreter can be located by the system 0N/A * - for RMI 1.1 prebeta release, the target class can be located 0N/A * using the system CLASSPATH variable 0N/A/* name of Java interpreter executable */ 0N/A/* name of Java class to execute with interpreter */ 0N/A/* names of environment variables set in CGI 1.0 interface */ 0N/A "GATEWAY_INTERFACE",
0N/A/* file static functions */ 0N/A * Program entry point: set up arguments and invoke Java interpreter. 0N/A int i;
/* loop index variable */ 0N/A char **
args;
/* array to store arguments to interpreter */ 0N/A int n = 0;
/* next index to fill in argument array */ 0N/A /* allocate space for argument list */ 0N/A args = (
char **)
/* allocate space for: */ 0N/A +
1 /* class name */ 0N/A +
1)
/* terminating NULL */ 0N/A /* first argument: name of java interpreter */ 0N/A /* next arguments: define CGI variables as properties to Java VM */ 0N/A char *
buffer;
/* buffer to store argument string */ 0N/A +
2)
/* "\"" and terminating '\0' */ 0N/A /* construct property definition parameter */ 0N/A /* last argument: name of class to execute */ 0N/A /* if exec call returns, there was an error */ 0N/A * Return primitive error message to server because of some failure in 0N/A * this program. (This could be embellished to an HTML formatted error 0N/A * NOTE: CGI 1.0 spec uses "\n" (unlike "\r\n" 0N/A * for HTTP 1.0) for line termination