#include "cgi.h"
Include dependency graph for console.c:
Go to the source code of this file.
Functions | |
static char * | JSSQLEscape (ScriptEnvironment *Env, char *cmd, int argc, char **argv, CGINameValue *Params) |
int | CGImain (char *argv0, CGINameValue *Params, EZSSTREAM *htmlout) |
|
You need to write this function in your program. The return value is zero for success, nonzero otherwise. Check that argc is nonzero before you attempt to access argv! Progname holds the traditional argv[0] so you can figure out where your program is running from. IsCGI is 1 if you're running from a web shell, or 0 if from the cmd line.
Definition at line 40 of file console.c. References ScriptObject::data, DeleteNVP(), HTMLWriteL(), JSEval(), JSGetEnv(), JSHasRecord(), JSHTMLEscape(), JSIndexOf(), JSPrint(), JSRandom(), JSReport(), JSSQLEscape(), JSstrlen(), JSsubstr(), JSTimeStamp(), JStoFixed(), JSToNumber(), NewNVP(), PrintScriptError(), and RunScript(). 00041 { 00042 char cmdline[1024]; 00043 CGINameValue * nvp = NewNVP(16); 00044 int ret; 00045 ScriptFunction Functions[] = 00046 {{"print",10,(ScriptFunctionCall)*JSPrint}, 00047 {"write",10,(ScriptFunctionCall)*JSPrint}, 00048 {"eval",1,(ScriptFunctionCall)*JSEval}, 00049 {"timestamp",0,(ScriptFunctionCall)*JSTimeStamp}, 00050 {"toFixed",2,(ScriptFunctionCall)*JStoFixed}, 00051 {"escape",1,(ScriptFunctionCall)*JSHTMLEscape}, 00052 {"escapeSQL",1,(ScriptFunctionCall)*JSSQLEscape}, 00053 {"subStr",3,(ScriptFunctionCall)*JSsubstr}, 00054 {"indexOf",4,(ScriptFunctionCall)*JSIndexOf}, 00055 {"length",1,(ScriptFunctionCall)*JSstrlen}, 00056 {"hasRecord",1,(ScriptFunctionCall)*JSHasRecord}, 00057 {"runReport",8,(ScriptFunctionCall)*JSReport}, 00058 {"number",1,(ScriptFunctionCall)*JSToNumber}, 00059 {"environment",1,(ScriptFunctionCall)*JSGetEnv}, 00060 {"toNumber",1,(ScriptFunctionCall)*JSToNumber}, 00061 {"random",1,(ScriptFunctionCall)*JSRandom}, 00062 {0,0,0}}; 00063 ScriptObject Objects[] = 00064 {{"data",0}, 00065 {0,0}}; 00066 ScriptEnvironment Env; 00067 00068 memset(&Env,0,sizeof(Env)); 00069 Env.Functions = Functions; 00070 Env.Objects = Objects; 00071 Env.htmlout = htmlout; 00072 Env.argv0 = argv0; 00073 Env.F2 = 0; 00074 00075 Objects[0].data=0; 00076 00077 ret = RunScript(&Env,stdin,nvp); 00078 if (ret > 0) 00079 { 00080 HTMLWriteL(htmlout,"***",3); 00081 PrintScriptError(htmlout,&Env, 0, ret); 00082 HTMLWriteL(htmlout,"***",3); 00083 } 00084 00085 DeleteNVP(nvp); 00086 return 0; 00087 }
|
|
Definition at line 3 of file console.c. References CGIMALLOC, and NULL. Referenced by CGImain(), and ODBCRunScript(). 00004 { 00005 size_t i=0,j=0; 00006 char *in; 00007 char *out; 00008 char *extra = NULL;; 00009 if (argc == 0) return NULL; 00010 00011 in = argv[0]; 00012 out = CGIMALLOC(1 + (strlen(in) * 2)); 00013 if (argc > 1) extra = argv[1]; 00014 00015 while (in[i]) 00016 { 00017 if (in[i] == '\'') 00018 { 00019 out[j++] = '\''; 00020 out[j++] = '\''; 00021 } 00022 else if (strchr("\t\r\n",in[i])) 00023 { 00024 out[j++] = ' '; 00025 } 00026 else if (extra && strchr(extra,in[i])) 00027 { 00028 out[j++] = '\\'; 00029 out[j++] = in[i]; 00030 } 00031 else out[j++] = in[i]; 00032 00033 i++; 00034 } 00035 00036 out[j]=0; 00037 return out; 00038 }
|