[0001] [0002] [0003] [0004] [0005] [0006] [0007] [0008] [0009] [0010] [0011] [0012] [0013] [0014] [0015] [0016] [0017] [0018] [0019] [0020] [0021] [0022] [0023] [0024] [0025] [0026] [0027] [0028] [0029] [0030] [0031] [0032] [0033] [0034] [0035] [0036] [0037] [0038] [0039] [0040] [0041] [0042] [0043] [0044] [0045] [0046] [0047] [0048] [0049] [0050] [0051] [0052] [0053] [0054] [0055] [0056] [0057] [0058] [0059] [0060] [0061] [0062] [0063] [0064] [0065] [0066] [0067] [0068] [0069] [0070] [0071] [0072] [0073] [0074] [0075] [0076] [0077] [0078] [0079] [0080] [0081] [0082] [0083] [0084] [0085] [0086] [0087] [0088] [0089] [0090] [0091] [0092] [0093] [0094] [0095] [0096] [0097] [0098] [0099] [0100] [0101] [0102] [0103] [0104] [0105] [0106] [0107] [0108] [0109] [0110] [0111] [0112] [0113] [0114] [0115] [0116] [0117] [0118] [0119] [0120] [0121] [0122] [0123] [0124] [0125] [0126] [0127] [0128] [0129] [0130] [0131] [0132] [0133] [0134] [0135] [0136] [0137] [0138] [0139] [0140] [0141] [0142] [0143] [0144] [0145] [0146] [0147] [0148] [0149] [0150] [0151] [0152] [0153] [0154] [0155] [0156] [0157] [0158] [0159] [0160] [0161] [0162] [0163] [0164] [0165] [0166] [0167] [0168] [0169] [0170] [0171] [0172] [0173] [0174] [0175] [0176] [0177] [0178] [0179] [0180] [0181] [0182] [0183] [0184] [0185] [0186] [0187] [0188] [0189] [0190] [0191] [0192] [0193] [0194] [0195] [0196] [0197] [0198] [0199] [0200] [0201] [0202] [0203] [0204] [0205] [0206] [0207] [0208] [0209] [0210] [0211] [0212] [0213] [0214] [0215] [0216] [0217] [0218] [0219] [0220] [0221] [0222] [0223] [0224] [0225] [0226] [0227] [0228] [0229] [0230] [0231] [0232] [0233] [0234] [0235] [0236] [0237] [0238] [0239] [0240] [0241] [0242] [0243] [0244] [0245] [0246] [0247] [0248] [0249] [0250] [0251] [0252] [0253] [0254] [0255] [0256] [0257] [0258] [0259] [0260] [0261] [0262] [0263] [0264] [0265] [0266] [0267] [0268] [0269] [0270] [0271] [0272] [0273] [0274] [0275] [0276] [0277] [0278] [0279] [0280] [0281] [0282] [0283] [0284] [0285] [0286] [0287] [0288] [0289] [0290] [0291] [0292] [0293] [0294] [0295] [0296] [0297] [0298] [0299] [0300] [0301] [0302] [0303] [0304] [0305] [0306] [0307] [0308] [0309] [0310] [0311] [0312] [0313] [0314] [0315] [0316] [0317] [0318] [0319] [0320] [0321] [0322] [0323] [0324] [0325] [0326] [0327] [0328] [0329] [0330] [0331] [0332] [0333] [0334] [0335] [0336] [0337] [0338] [0339] [0340] [0341] [0342] [0343] [0344] [0345] [0346] [0347] [0348] [0349] [0350] [0351] [0352] [0353] [0354] [0355] [0356] [0357] [0358] [0359] [0360] [0361] [0362] [0363] [0364] [0365] [0366] [0367] [0368] [0369] [0370] [0371] [0372] [0373] [0374] [0375] [0376] [0377] [0378] [0379] [0380] [0381] [0382] [0383] [0384] [0385] [0386] [0387] [0388] [0389] [0390] [0391] [0392] [0393] [0394] [0395] [0396] [0397] [0398] [0399] [0400] [0401] [0402] [0403] [0404] [0405] [0406] [0407] [0408] [0409] [0410] [0411] [0412] [0413] [0414] [0415] [0416] [0417] [0418] [0419] [0420] [0421] [0422] [0423] [0424] [0425] [0426] [0427] [0428] [0429] [0430] [0431] [0432] [0433] [0434] [0435] [0436] [0437] [0438] [0439] [0440] [0441] [0442] [0443] [0444] [0445] [0446] [0447] [0448] [0449] [0450]
/*****************************************************************************/ /* DCL.h */ /*****************************************************************************/ #ifndef DCL_H_LOADED #define DCL_H_LOADED 1 #include "wasd.h" /* number of times a 'not activated' script is retried */ #define DCL_MAX_SCRIPT_RETRY 5 /* number of times a script can output an ENDOFFILE */ #define DCL_SCRIPT_MAX_ENDOFFILE 50 /* location of script scratch area */ #define DCL_HTTPD_SCRATCH "?WASD_SCRATCH:\0HT_SCRATCH:\0" /* no world or group access */ #define DCL_PROCESS_MBX_PROT_MASK 0xff00 /* minimum/maximum size of buffer for DCL/CLI strings */ #define DCL_COMMAND_MIN_SIZE 256 #define DCL_COMMAND_MAX_SIZE 2048 #define DCL_TASK_TYPE_NONE 0 #define DCL_TASK_TYPE_CLI 1 #define DCL_TASK_TYPE_CGI_SCRIPT 2 #define DCL_TASK_TYPE_CGIPLUS_SCRIPT 3 #define DCL_TASK_TYPE_RTE_SCRIPT 4 #define DCL_FIND_SCRIPT_BEGIN 1 #define DCL_FIND_SCRIPT_COM 2 #define DCL_FIND_SCRIPT_CLD 3 #define DCL_FIND_SCRIPT_EXE 4 #define DCL_FIND_SCRIPT_RUNTIME 5 /* used as a lifetime sentinal */ #define DCL_DO_NOT_DISTURB -1 #define DCL_WEBSOCKET_DND -2 /* if CGIplus/RTE idle life time not configured default to one hour */ #define DCL_CGIPLUS_LIFETIME 60 * 60 /* used to indicate a sys$delprc() has been queued against the process */ #define DCL_RUNDOWN_DELPRC -1 #define DCL_MAILBOX_DEVNAM_MAX 10 /* see algorithm description with function DclScriptProctor() */ #define PROCTOR_FAIL_BASE 3 #define PROCTOR_FAIL_AT 25 #define PROCTOR_FAIL_NOW 81 /**************/ /* structures */ /**************/ #pragma __member_alignment __save #pragma nomember_alignment typedef struct DclCrePrcTermStruct DCL_CREPRC_TERM; struct DclCrePrcTermStruct { unsigned short int acc$w_msgtyp; unsigned short int acc$w_msgsiz; unsigned int acc$l_finalsts; unsigned int acc$l_pid; unsigned int acc$l_jobid; unsigned int acc$q_termtime [2]; char acc$t_account [8]; char acc$t_username [12]; unsigned int acc$l_cputim; unsigned int acc$l_pageflts; unsigned int acc$l_pgflpeak; unsigned int acc$l_wspeak; unsigned int acc$l_biocnt; unsigned int acc$l_diocnt; unsigned int acc$l_volumes; unsigned int acc$q_login [2]; unsigned int acc$l_owner; }; typedef struct DclJpiItemStruct DCL_JPI_ITEM; struct DclJpiItemStruct { unsigned short buf_len; unsigned short item; unsigned char *buf_addr; unsigned short *short_ret_len; }; #pragma member_alignment typedef struct DclScriptNameCacheStruct DCL_SCRIPT_NAME_ENTRY; struct DclScriptNameCacheStruct { LIST_ENTRY DclListEntry; int /* number of times "hit" since last cache file name load */ HitCount; int64 /* last time loaded/hit */ LastTime64; char /* the full searched-for script file name */ ResFileName [ODS_MAX_FILE_NAME_LENGTH+1], /* the mapped script file name returned after mapping */ ScriptFileName [ODS_MAX_FILE_NAME_LENGTH+1], /* the name of any run-time engine or RTE engine */ ScriptRunTime [ODS_MAX_FILE_NAME_LENGTH+1]; }; typedef struct DclTaskStruct DCL_TASK; struct DclTaskStruct { LIST_ENTRY DclListEntry; BOOL /* add a newline to each record from a script process */ AddNewline, /* record-by-record output from DCL, flush immediately */ BufferRecords, /* build <LF> or <CR><LF> delimited records from single bytes */ BuildRecords, /* script has indicated to send CGI variables in one structure */ CgiPlusVarStruct, /* client-read: strip client I/O records of carriage-control */ ClientReadStripCrLf, /* output is text (plain or html) */ ContentTypeText, /* indicate it's a detached not process */ CrePrcDetachProcess, /* absorb login meassages etc., with detached script processes */ CrePrcDetachStarting, /* when the task completes the process is deleted */ DeleteProcess, /* grant the identifier that marks this is a WASD script process */ DetachedGrantId, /* DclFindScript() is currently using the structure */ FindScript, /* use a $FORCEX to rundown the script */ ForceImageExit, /* indicates a $FORCEX has been issued to the process */ ForceImageExitIssued, /* indicates an asynchronous $GETJPI is still outstanding */ ForceImageExitGetJpi, /* process has had /PARSE=EXTENDED set */ ProcessParseExtended, /* there is an outstanding $GETJPI getting the CPU time consumed */ ScriptCpuTimGetJpi, /* process read data/variables (i.e. became active) */ ScriptProcessActivated, /* process provided response (i.e. sent some output) */ ScriptProcessResponded, /* send script output to the bit-bucket while WATCHing */ WatchNonCgiCompliant; int /* */ AgentUsageCount, /* set only by a CGI callout */ BitBucketTimeout, /* number of times the CGIplus script has been used */ CgiPlusUsageCount, /* size of storage when reading directly from client to HTTP$INPUT */ ClientReadBufferSize, /* network write has returned an error status */ ClientWriteErrorCount, /* remaining content in POST script */ ContentLength, /* current length of DCL command */ DclCommandLength, /* size of DCL command buffer */ DclCommandSize, /* buffer the end of script output (end of file) sentinal */ FindScriptRunTimeIdx, /* flag */ FindScriptState, /* point at which we lose patience and $DELRPC it anyhow */ ForceImageExitSecond, /* last time task was used as an HTTPd tick second */ LastUsedSecond, /* used by the DclSupervisor() to time tasks out */ LifeTimeSecond, /* non-zero indicates a proctored script */ ProctorProcess, /* count of I/Os CGIplus variables reads still outstanding */ QueuedCgiPlusIn, /* count of network/client->HTTP$INPUT reads still outstanding */ QueuedClientRead, /* count of I/Os between HTTPd and client still outstanding */ QueuedClientOutput, /* count of HTTP$INPUT reads still outstanding */ QueuedHttpInput, /* count of I/Os between process and HTTPd still outstanding */ QueuedSysCommand, /* when the count of I/Os is considered task finished */ QueuedSysCommandAllowed, /* count of I/Os between process and HTTPd still outstanding */ QueuedSysOutput, /* when building records from single bytes */ SysOutputBuildCount, /* SYS$OUTPUT end-of-files are ignored, ensure the script behaves */ SysOutputEndOfFileCount, /* size of DCL process' SYS$OUTPUT buffer */ SysOutputSize, /* whether it's a command, CGI script, agent, etc. */ TaskType, /* non-zero then task is currently running-down */ TaskRunDown, /* total number of times the task slot was used */ TotalUsageCount, /* copied from request structure for WATCHing purposes */ WatchItem, /* number of process has been a zombie */ ZombieCount; unsigned short /* channel to process' CGIPLUSIN mailbox */ CgiPlusInChannel, /* channel to process' sys$creprc() termination mailbox */ CrePrcTermMbxChannel, /* device unit of sys$creprc() termination mailbox */ CrePrcTermMbxUnit, /* channel to process' HTTP$INPUT mailbox */ HttpInputChannel, /* channel to process' SYS$INPUT mailbox */ SysCommandChannel, /* channel to process' SYS$OUTPUT mailbox */ SysOutputChannel, /* some are easier :^) to report via sys$output status */ ViaSysOutputStatus; unsigned long /* process name includes PID */ ProcessNamePid, /* process' PID */ ScriptProcessPid; int64 /* last time CGIplus script was used */ LastUsedTime64; char /* storage for when reading directly from client to HTTP$INPUT */ *ClientReadBufferPtr, /* content pointer in POST script */ *ContentPtr, /* storage for DCL command */ *DclCommandPtr, /* points to the file name being used in parse/search */ *FindScriptFileNamePtr, /* points to a string denoting how the script is invoked */ *ScriptRunTimePtr, /* heap storage for buffering process' SYS$OUTPUT */ *SysOutputPtr; char /* device name of process' CGIPLUSIN mailbox */ CgiPlusInDevName [DCL_MAILBOX_DEVNAM_MAX+1], /* device name of sys$creprc() process termination mailbox */ CrePrcTermMbxDevName [DCL_MAILBOX_DEVNAM_MAX+1], /* user name persona the sys$creprc() process created under */ CrePrcUserName [13], /* device name of process' HTTP input mailbox */ HttpInputDevName [DCL_MAILBOX_DEVNAM_MAX+1], /* process name when scripting */ PrcNamActive [16], /* default process name */ PrcNamDefault [16], /* the name of the script file being executed */ ScriptFileName [ODS_MAX_FILE_NAME_LENGTH+1], /* script name (path) */ ScriptName [SCRIPT_NAME_SIZE], /* the name of any run-time engine or RTE engine */ ScriptRunTime [ODS_MAX_FILE_NAME_LENGTH+1], /* device name of process' input mailbox */ SysCommandDevName [DCL_MAILBOX_DEVNAM_MAX+1], /* device name of process' output mailbox */ SysOutputDevName [DCL_MAILBOX_DEVNAM_MAX+1]; /* sentinal I/O sequences */ int /* length of the detached-script-output sequence */ CgiBelLength, /* length of the end-of-file (output) sequence */ CgiEofLength, /* length of the agent end-of-text sequence */ CgiEotLength, /* length of the "escape" sequence */ CgiEscLength; char /* beginning of detached-script-output sequence */ CgiBel [32], /* end-of-file (output) sequence */ CgiEof [32], /* agent end-of-text sequence */ CgiEot [32], /* CGI "escape" sequence */ CgiEsc [32]; IO_SB CgiPlusInIOsb, CrePrcTermMbxIOsb, HttpInputIOsb, SysCommandIOsb, SysOutputIOsb; /* sys$creprc() process termination accounting record */ struct DclCrePrcTermStruct CrePrcTermRecord; /* string descriptors for the various mailbox device names */ struct dsc$descriptor_s CgiPlusInDevNameDsc; struct dsc$descriptor_s CrePrcTermMbxDevNameDsc; struct dsc$descriptor_s HttpInputDevNameDsc; struct dsc$descriptor_s SysCommandDevNameDsc; struct dsc$descriptor_s SysOutputDevNameDsc; /* used with memory buffer global section */ uint MemBufSize; int64 MemBufCount64; BOOL MemBufInProgress; char MemBufGblSecName [32+1]; void *MemBufGblSecPtr; /* item list used for getting image name */ char JpiImagName [128]; unsigned short JpiImagNameLength; IO_SB JpiImagNameIOsb; DCL_JPI_ITEM JpiImagNameItem [3]; /* item list, etc. for controlling CPU time consumed */ unsigned long JpiCpuTim, ScriptCpuMax, ScriptCpuTimMax; IO_SB JpiCpuTimIOsb; DCL_JPI_ITEM JpiCpuTimItem [3]; /* MD5 hash of mapped path (used with RTEs) */ MD5_HASH Md5HashPath; /* pointer to proctor entry */ PROCTOR_STRUCT *ProctorPtr; /* "on-disk structure" when finding a script file */ ODS_STRUCT SearchOds; /* pointer a request using this DCL task structure */ REQUEST_STRUCT *RequestPtr; /* pointer to function, for specifying an "escape" processing function */ REQUEST_AST CalloutFunction; /* pointer to function, for specifying the next task */ REQUEST_AST NextTaskFunction; }; #pragma member_alignment __restore /***********************/ /* function prototypes */ /***********************/ /* NOTE ... pointers to request structure! */ DclAllocateTask (REQUEST_STRUCT*, int, char*, int, char*, char*, char*); DclBegin (REQUEST_STRUCT*, REQUEST_AST, char*, char*, char*, char*, char*, REQUEST_AST); DclBeginScript (DCL_TASK*); /* NOTE ... pointer to request structure! */ DclCalloutQio (REQUEST_STRUCT*, char*, int); DclCalloutResume (REQUEST_STRUCT*); DclCalloutDefault (REQUEST_STRUCT*); int DclAnotherSysOutput (DCL_TASK*); DclCgiPlusInAst (DCL_TASK*); DclCgiPlusLifeTimeAst (DCL_TASK*); void DclCleanupScratch (struct FAB*); DclCgiPlusBodyAst (DCL_TASK*); DclClientReadAst (REQUEST_STRUCT*); DclClientReadHttpInputAst (DCL_TASK*); int DclCgiScriptSysCommand (DCL_TASK*); int DclCgiPlusScriptCgiPlusIn (DCL_TASK*); DclCreateMailboxes (DCL_TASK*); DclCreateScriptProcess (DCL_TASK*, char*, int); void DclDeleteMailboxes (DCL_TASK*); int DclDeleteProcess (DCL_TASK*); DclDeallocateTask (DCL_TASK*); int DclDelPrc (DCL_TASK*); DclEscapeInProgress (DCL_TASK*); DclFindScript (DCL_TASK*); DclFindScriptEnd (DCL_TASK*, BOOL); DclFindScriptParseAst (DCL_TASK*); DclFindScriptSearchAst (DCL_TASK*); char* DclGetPrcNam (ulong); DclHttpInput (REQUEST_STRUCT*); DclHttpInputAst (DCL_TASK*); struct dsc$descriptor_s* DclNameProcess (DCL_TASK*); DclQioSysCommand (DCL_TASK*, char*, int); DclQioCgiPlusIn (DCL_TASK*, char*, int); DclQioSysOutput (DCL_TASK*); DclTaskRunDown (DCL_TASK*); /* NOTE ... pointer to request structure! */ DclRequestEnd (REQUEST_STRUCT*); DclSysOutputToClientAst (REQUEST_STRUCT*); DclPlusScriptSysCommand (DCL_TASK*); DclPlusScriptSysCgiPlusIn (DCL_TASK*); DclPurgeScriptNameCache (); DclPurgeCgiPlusScripts (REQUEST_STRUCT*, REQUEST_AST, BOOL); DclForceImageExit (DCL_TASK*); DclForceImageExitAst (DCL_TASK*); DclSysCommandAst (DCL_TASK*); DclSearchScriptNameCache (DCL_TASK*, REQUEST_STRUCT*); DclScriptCpuTim (DCL_TASK*); DclScriptCpuTimAst (DCL_TASK*); DclScriptProcessCompletionAST (DCL_TASK*); DclScriptProctor (); DclScriptProctorReportFail (PROCTOR_STRUCT*, char*, ...); DclScriptProctorAgent (REQUEST_STRUCT*); DclScriptProctorAgentAst (REQUEST_STRUCT*); DclScriptProctorAst (REQUEST_STRUCT*); REQUEST_STRUCT* DclFauxRequest (REQUEST_STRUCT*, char*, REQUEST_AST); DclSupervisor (int); DclSysOutputHeader (DCL_TASK*); DclSysOutputLocation (DCL_TASK*); DclSysOutputAst (DCL_TASK*); DclSysOutputWaitAst (DCL_TASK*); DclSetZombieLifeTime (DCL_TASK*); DclUpdateScriptNameCache (DCL_TASK*); DclZombieLifeTimeAst (DCL_TASK*); void DclScriptingReport (REQUEST_STRUCT*); void DclPeekReport (REQUEST_STRUCT*); void DclCountScriptProcess (); char* DclControlPurgeScriptProcesses (BOOL, char*, char*, char*); /* memory buffer module */ char* DclMemBufBegin (DCL_TASK*, char*); int DclMemBufCreate (DCL_TASK*, int); int DclMemBufDelete (DCL_TASK*); char* DclMemBufEnd (DCL_TASK*, char*); char* DclMemBufWrite (DCL_TASK*, char*); void DclMemBufWriteAst (DCL_TASK*); #endif /* DCL_H_LOADED */ /*****************************************************************************/