/* ** Name: FWrite_Fenc ** ** Decription: ** An encoding description for the following file. Stored for use in ** the furture. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS FParm_Fenc (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; i4 remain = linelen - *pos; char* p = line + *pos; char* enc = NULL; i4 i=0; if ((err = GAlloc (&enc, remain + 1, FALSE)) == GSTAT_OK) { load->encode = enc; while (CMwhite(p)) { CMbyteinc(i,p); CMnext(p); } while (i < remain) { CMbyteinc(i,p); CMcpyinc (p, enc); } load->state = US_FPARM; } *pos += i; return (err); }
size_t STtrmnwhite_DB( char *string, size_t max_len) { register char *p = string; register char *nw = p; register char *end = p + max_len; /* ** after the loop, nw points to the first character beyond ** the last non-white character. Done this way because you ** can't reverse scan a string with CM efficiently */ while (p < end && *p != EOS) { if (!CMwhite(p)) { CMnext(p); nw = p; } else CMnext(p); } { register size_t nwl = nw - string; if (nwl < max_len) *nw = EOS; return nwl; } }
/*{ ** Name: cus_trmwhite - Trim trailing white space. ** ** Description: ** Used by the parser facility for trimming trailing white space ** in character texts residing in memory. The text may be null terminated ** but doesn't have to be. This is the reason why the length argument ** is passed along with the buffer pointer. This routine is currently ** only used in calls to psf_error to make text presented to recipients ** of error messages more user friendly. ** ** Inputs: ** len Max length to be scanned for white space ** bufp Pointer to the buf holding char data ** (does not have to be null terminated) ** Outputs: ** Returns: ** Length Length of non-white part of the string ** ** Exceptions: ** None. ** ** Side Effects: ** None. ** ** History: ** 11-apr-87 (stec) ** written ** 16-apr-87 (stec) ** changed a little. ** Addressed performance and Kanji issues. ** 02-may-1990 (fred) ** Revamped to trim trailing white space from an arbitrary string. ** Previously, it was assumed that trailing white space started ** with the first bit o' white space from the beginning. The routine ** will now trim from the end back. This was necessitated for BLOB ** support which is the first case of a datatype name with an embedded ** blank (standard name - 'long varchar'). ** 25-mar-93 (rickh) ** Moved here from PSFTRMWH.C and renamed with a cuf prefix. */ i4 cus_trmwhite( u_i4 len, char *bufp) { register char *ep; /* pointer to end of buffer (one beyond) */ register char *p; register char *save_p; if (!bufp) { return (0); } p = bufp; save_p = p; ep = p + (int)len; for (; (p < ep) && (*p != EOS); ) { if (!CMwhite(p)) save_p = CMnext(p); else CMnext(p); } return ((i4)(save_p - bufp)); }
/* ** Name: File_Mime ** ** Decription: ** The mime type of the following file. Extracted an saved for use in ** in the future. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS File_Mime (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; i4 remain = linelen - *pos; char* p = line + *pos; char* mime = NULL; i4 i=0; if ((err = GAlloc (&mime, remain + 1, FALSE)) == GSTAT_OK) { load->type = mime; while ((remain > 0) && CMwhite(p)) { CMbyteinc(i,p); CMnext(p); } while (i < remain) { CMbyteinc(i,p); CMcpyinc (p, mime); } load->state = US_FPARM; } *pos += i; return (err); }
/*{ ** Name: RPgetwords - parse a string into words ** ** Description: ** RPgetwords() is similar to the CL STgetwords(), but allows ** for the specification of word delimiters. Consecutive word ** delimiters in the parse string result in blank words. The character ** that follows the last non-white space character of each word is ** replaced by the EOS character. ** ** Inputs: ** delims - pointer to string of delimiters ** string - pointer to string to be parsed ** wordcount - size of 'wordarray' ** ** Outputs: ** wordcount - number of words found ** wordarray - array of character pointers holding starting address ** of each word. ** ** Returns: ** none ** ** Side effects: ** Words in 'string' are terminated with EOS. **/ void RPgetwords( char *delims, char *string, i4 *wordcount, char **wordarray) { i4 count = 0; char **org; char *p; org = wordarray; while (count < *wordcount) { *wordarray++ = string; ++count; p = string; while (*string != EOS && STindex(delims, string, 0) == NULL) { if (!CMwhite(string)) p = string; CMnext(string); } if (p < string && !CMwhite(p)) CMnext(p); if (*string == EOS) { *p = EOS; break; } *p = EOS; CMnext(string); } if (count < *wordcount) org[count] = NULL; *wordcount = count; }
static i4 yylex( FILE *input ) { char *pscan; if( yygetline( input ) != OK ) return( tEOF ); /* Unless the -C flag was specified, blank out all of the comments */ pscan = infile->yytext; while (pass_comments == FALSE && *pscan != EOS) { if (infile->yycomment == TRUE) { /* Look for the 'end comment' identifier */ if (STbcompare(pscan,2,ERx("*/"),2,FALSE) == 0) { /* Blank out the 'end comment' characters */ CMcpychar(ERx(" "), pscan); CMnext(pscan); CMcpychar(ERx(" "), pscan); /* Remember that the comment has ended */ infile->yycomment = FALSE; } /* Blank out non-whitespace characters of the comment */ else if (!CMwhite(pscan)) { CMcpychar(ERx(" "), pscan); } /* Whitespace chars are skipped, this lets \n thru */ } /* Look for the 'begin comment' identifier */ else if (STbcompare(pscan,2,ERx("/*"),2,FALSE) == 0) { /* Blank out the 'begin comment' characters */ CMcpychar(ERx(" "), pscan); CMnext(pscan); CMcpychar(ERx(" "), pscan); infile->yycomment = TRUE; } CMnext(pscan); /* Continue the scan with the next character */ } if( is_history(infile->yytext ) == OK) { return( tHISTORY ); } if( *infile->yytext == '#' ) return( tDIRECTIVE ); return( tSOURCE ); }
char *FIND_SEPstring(char *token,char *string) { i4 token_len ; i4 string_len ; char *cp = NULL ; char *pp = NULL ; char *tp = NULL ; if (token == NULL || *token == EOS) { if (tracing&TRACE_PARM) SIfprintf(traceptr,ERx("FIND_SEPstring> token is null\n")); return (NULL); } if (string == NULL || *string == EOS) { if (tracing&TRACE_PARM) SIfprintf(traceptr,ERx("FIND_SEPstring> string is null\n")); return (NULL); } string_len = STlength(string); if ((token_len = STlength(token)) < string_len) { if (tracing&TRACE_PARM) SIfprintf(traceptr ,ERx("FIND_SEPstring> token <%s> is too small (%d chars)\n") ,token,token_len); return (NULL); } for (tp = token, cp = NULL, pp = NULL ; (*tp != EOS)&&(cp == NULL)&&(token_len-- >= string_len) ; CMnext(tp)) { if ((STbcompare(tp, string_len, string, string_len, TRUE) == 0) &&((pp == NULL)||CMoper(pp)||CMwhite(pp))) { cp = tp; } pp = tp; } return (cp); }
/*{ ** Name: psq_parseqry - Parse a query and return a data structure ** ** INTERNAL PSF call format: status = psq_parseqry(&psq_cb, &sess_cb); ** ** EXTERNAL call format: status = psq_call(PSQ_PARSEQRY, &psq_cb, &sess_cb); ** ** Description: ** This function will parse a query in QSF memory. It will return a ** data structure (such as a query tree), and a code telling what kind of ** query was just parsed (e.g. a copy statement). This code will be ** called the "query mode". For qrymod definitions, it will store a ** modified version of the query text in QSF, for later insertion in the ** iiqrytext system relation. ** ** This function will check the syntax of each statement, and will perform ** some semantic validations. The syntax checking will be rather simple: ** each statement will either be right or wrong, and a syntax error will ** cause the whole go block to be aborted. Semantic checks will be more ** complicated; some of them will cause warnings (which will allow the ** statement to continue), and some will cause errors (causing the ** statement to be aborted). It should be noted that the semantic checks ** will not be the same in the Jupiter version as in previous versions; ** in the Jupiter version, for instance, the parser won't check for whether ** the statement is valid inside a multi-query transaction. ** ** Sometimes it will be found that the definition of a view, permit, or ** integrity is out of date. When this happens, this function will return ** an error status saying so, and an id for finding the query text in the ** iiqrytext relation, so that the definition can be re-parsed and ** re-stored. Accordingly, this function has an option by which one can ** tell it to get the query text out of the iiqrytext relation instead of ** QSF. ** ** When a statement is parsed that creates a new cursor, the parser will ** assign a cursor id to the cursor, create a cursor control block ** containing information about the cursor, and return the cursor id inside ** with the query tree representing the cursor. This cursor id will be ** used throughout the session to uniquely identify the cursor. When a ** "close cursor" statement is parsed, the parser will deallocate the ** control block associated with the cursor. ** ** The parser will automatically apply view, permit, and integrity ** processing to any data manipulation query it parses. This will not ** require a separate call to the parser. ** ** Multi-statement go blocks are no longer allowed, as they used to be in ** previous versions. This parser can handle only one statement at a time. ** ** Inputs: ** psq_cb ** .psq_qid A unique identifier for getting the ** query text from QSF. ** .psq_iiqrytext TRUE means to get the query text from ** the iiqrytext relation, not QSF. ** .psq_txtid Query text id key into iiqrytext ** relation; used only if above is true. ** sess_cb Pointer to the session control block ** ** Outputs: ** psq_cb ** .psq_qlang The language of the query text. ** .psq_mode The query mode (a code telling what ** kind of query was just parsed). ** .psq_result QSF id for the data structure produced ** (query tree, or control block stored as ** QEP). ** .psq_txtid Query text id key into iiqrytext ** relation; filled in if some qrymod ** object needs redefining. ** .psq_mnyfmt Set on a "set money_format" or ** "set money_prec" statement ** .psq_dtefmt Set on a "set date_format" statement ** .psq_decimal Set on a "set decimal" statement ** .psq_error Standard error block ** E_PS0000_OK Success ** E_PS0001_USER_ERROR Mistake by user ** E_PS0002_INTERNAL_ERROR Internal inconsistency inside PSF ** E_PS0B01_OUTDATED_VIEW View out of date; must re-define ** E_PS0B02_OUTDATED_PERMIT Permit out of date; must re-define ** E_PS0B03_OUTDATED_INTEG Integrity out of date; must re-def. ** E_PS0B04_CANT_GET_TEXT Can't get query text ** .psq_txtout QSF id for the create procedure stmt to ** be stored in the system catalog. ** ** Returns: ** E_DB_OK Function completed normally. ** E_DB_WARN Function completed with warning(s) ** E_DB_ERROR Function failed; non-catastrophic error ** E_DB_FATAL Function failed; catastrophic error ** Exceptions: ** none ** ** Side Effects: ** Stores query tree or control block in QSF. ** Can open a cursor. ** ** History: ** 01-oct-85 (jeff) ** written ** 19-sep-86 (daved) ** end of qry should point to last char. This char should be a space. ** this makes the scanner's job easier ** 27-jan-87 (daved) ** add the printqry set command. ** 02-oct-87 (stec) ** Removed pss_journaling flag initialization; ** must be initialized in psqbgnses.c ** 19-jan-88 (stec) ** Changed initialization od pst_resloc. ** 25-may-88 (stec) ** Made changes in connection with DB procedures. ** QSF object of QP type has to be destroyed if ** translate_or_define worked for CREATE PROCEDURE. ** 23-aug-88 (stec) ** Initialize qso_handle in QSO_OBIDs in psq_cb. ** 21-apr-89 (neil) ** Extracted some initialization (psq_cbinit) from psq_parseqry to ** allow it to be called from other routines as well. ** 11-dec-89 (ralph) ** Change interface to QSO for dbprocs ** 12-sep-90 (teresa) ** fix faulty pss_retry logic. ** 15-jun-92 (barbara) ** Sybil merge. Pass in sess control block to pst_clrrng. ** 23-nov-92 (barbara) ** For Star, accept range statement as the one and only allowable ** QUEL statement. This is to support old FE's which use the range ** statement as a quick way to ascertain table existence. FEs of ** >= 6.5 vintage use a table_resolve() function, so at some point ** we can remove the QUEL range table statement support for Star. ** 24-nov-92 (ralph) ** CREATE SCHEMA: ** Initialize pss_prvgoval ** 22-dec-92 (rblumer) ** clean up after pss_tchain2 just like pss_tchain. ** 25-may-93 (rog) ** Move clean-up/exit code into psq_cbreturn() and then call it. ** 11-oct-93 (swm) ** Bug #56448 ** Declared trbuf for psf_display() to pass to TRformat. ** TRformat removes `\n' chars, so to ensure that psf_scctrace() ** outputs a logical line (which it is supposed to do), we allocate ** a buffer with one extra char for NL and will hide it from TRformat ** by specifying length of 1 byte less. The NL char will be inserted ** at the end of the message by psf_scctrace(). ** 16-mar-94 (andre) ** if performing an internal PSF retry and trace point ps129 (same as *8 SET PRINTQRY) is set, instead of redisplaying the query we will *8 tell the user that we are retrying the last query. ** 28-feb-2005 (wanfr01) ** Bug 64899, INGSRV87 ** Add stack overflow handler for TRU64. ** 17-mar-06 (dougi) ** Init pss_hintcount to 0 for optimizer hints project. ** 23-june-06 (dougi) ** Init pss_stmtno to 1 for procedure debugging. ** 05-sep-06 (toumi01) ** Init pss_stmtno to 0 (to match new "help procedure" numbering) ** lest we point, PC register like, to the _following_ statement. ** 15-Sep-2008 (kibro01) b120571 ** Use same session ID as available in iimonitor ** 16-Sep-2008 (kibro01) b120571 ** Remove compilation error from cast of sessid ** 16-Feb-2009 (kibro01) b121674 ** Add version to SESSION BEGINS message in sc930 and give out ** data type of parameters. ** 10-Jul-2009 (kibro01) b122299 ** Increase the version number due to dates being printed out now. ** 15-Jul-2009 (kibro01) b122172 ** Change QUERY or QUEL to REQUERY or REQUEL when a DB procedure is ** reparsed due to being invalidated. ** 23-Jul-2009 (kibro01) b122172 ** Separate the print_qry_buffer logic to avoid stack size problems. ** 3-Aug-2009 (kibro01) b122393 ** Use print_qry_buffer_ptr to avoid inlining. ** 4-Aug-2009 (kibro01) b122172 ** Allow REQUERY/REQUEL through even if the RECREATE flag is set so ** we get the useful debug output. ** 28-Oct-2009 (maspa05) b122725 ** ult_print_tracefile now uses integer constants instead of string ** for type parameter - SC930_LTYPE_PARM instead of "PARM" and so on ** Also moved function definitions for SC930 tracing to ulf.h ** The functions involved were - ult_always_trace, ult_open_tracefile ** ult_print_tracefile and ult_close_tracefile */ DB_STATUS psq_parseqry( register PSQ_CB *psq_cb, register PSS_SESBLK *sess_cb) { DB_STATUS status; DB_STATUS ret_val; QSF_RCB qsf_rb; i4 err_code; PSQ_QDESC *qdesc; i4 val1 = 0; i4 val2 = 0; i4 i; char trbuf[PSF_MAX_TEXT + 1]; /* last char for `\n' */ if ((status = psq_cbinit(psq_cb, sess_cb)) != E_DB_OK) return (status); /* ** The following is particular to queries that must be parsed. ** Get query text from QSF and put it in session control block ** Initialize the qbuf, nextchar, prevtok, and bgnstmt pointers */ qsf_rb.qsf_type = QSFRB_CB; qsf_rb.qsf_ascii_id = QSFRB_ASCII_ID; qsf_rb.qsf_length = sizeof(qsf_rb); qsf_rb.qsf_owner = (PTR)DB_PSF_ID; qsf_rb.qsf_sid = sess_cb->pss_sessid; qsf_rb.qsf_obj_id.qso_handle = psq_cb->psq_qid; status = qsf_call(QSO_INFO, &qsf_rb); if (DB_FAILURE_MACRO(status)) { (VOID) psf_error(E_PS0B04_CANT_GET_TEXT, 0L, PSF_CALLERR, &err_code, &psq_cb->psq_error, 0); return (E_DB_ERROR); } qdesc = (PSQ_QDESC*) qsf_rb.qsf_root; /* print the qry buffer as long as this isn't a retry ** - although allow through the RECREATE case since it's useful ** for debugging to log reparsing an object */ if ((ult_always_trace() & SC930_TRACE) && ( ((sess_cb->pss_retry & PSS_REFRESH_CACHE)==0) || (sess_cb->pss_dbp_flags & PSS_RECREATE) != 0 ) ) { (*print_qry_buffer_ptr)(psq_cb, qdesc, sess_cb); } if (ult_check_macro(&sess_cb->pss_trace, PSS_PRINT_QRY_TRACE, &val1, &val2)) { if (psf_in_retry(sess_cb, psq_cb)) { psf_display(psf_scctrace, 0, trbuf, sizeof(trbuf) - 1, "\n...retrying last query...\n"); } else { psf_display(psf_scctrace, 0, trbuf, sizeof(trbuf) - 1, "\nQUERY BUFFER:\n"); psf_display(psf_scctrace, 0, trbuf, sizeof(trbuf) - 1, "%.#s\n", qdesc->psq_qrysize, qdesc->psq_qrytext); psf_display(psf_scctrace, 0, trbuf, sizeof(trbuf) - 1, "\nQUERY PARAMETERS:\n"); for (i = 0; i < qdesc->psq_dnum; i++) { psf_display(psf_scctrace, 0, trbuf, sizeof(trbuf) - 1, "Parameter : %d\n", i); adu_2prvalue(psf_relay, qdesc->psq_qrydata[i]); psf_display(psf_scctrace, 0, trbuf, sizeof(trbuf) - 1, "\n"); } } } sess_cb->pss_bgnstmt = (u_char*) qdesc->psq_qrytext; sess_cb->pss_prvgoval = (u_char*) NULL; sess_cb->pss_prvtok = (u_char*) qdesc->psq_qrytext; sess_cb->pss_qbuf = (u_char*) qdesc->psq_qrytext; sess_cb->pss_nxtchar = (u_char*) qdesc->psq_qrytext; sess_cb->pss_endbuf = sess_cb->pss_qbuf + qdesc->psq_qrysize - 1; sess_cb->pss_dmax = qdesc->psq_dnum; sess_cb->pss_qrydata = qdesc->psq_qrydata; *sess_cb->pss_endbuf = ' '; sess_cb->pss_lineno = 1; /* Start out at line one */ sess_cb->pss_stmtno = 0; /* and statement at zero */ sess_cb->pss_dval = 0; sess_cb->pss_hintcount = 0; psl_yinit(sess_cb); if (psq_cb->psq_qlang == DB_QUEL) { if (sess_cb->pss_distrib & DB_3_DDB_SESS) { char *c; char *r = "range"; /* skip leading white space chars, if any */ for (c = qdesc->psq_qrytext; c <= (char *) sess_cb->pss_endbuf && CMwhite(c); CMnext(c) ) ; /* compare the first word with "range" */ for (; *r != EOS && c <= (char *) sess_cb->pss_endbuf && !CMcmpnocase(c,r); CMnext(c), CMnext(r) ) ; /* ** we will go on to parse this statement iff ** 1) first non-white chars are "range" AND ** 2) 'e' is followed by a white space */ if (*r != EOS || c >= (char *) sess_cb->pss_endbuf || !CMwhite(c)) { (VOID) psf_error(5212L, 0L, PSF_USERERR, &err_code, &psq_cb->psq_error,0); return(E_DB_ERROR); } } sess_cb->pss_parser = pslparse; } else { sess_cb->pss_parser = pslsparse; } IIEXtry { status = (*sess_cb->pss_parser)(sess_cb, psq_cb); } IIEXcatch(pthread_stackovf_e) { (VOID) psf_error(5212L, 0L, PSF_USERERR, &err_code, &psq_cb->psq_error,0); } IIEXendtry ret_val = psq_cbreturn(psq_cb, sess_cb, status); return (ret_val); }
static bool pp_eval_boolexp( char **strptr, char *goal ) { bool boolval[2]; i4 notval[2]; i4 oper = OPER_NONE; i4 curval = 0; i4 maxval; i4 goalfound = FALSE; char *parser = *strptr; bool rtn; notval[0] = notval[1] = 0; maxval = (sizeof(boolval) / sizeof(boolval[0])) - 1; while (goalfound == FALSE) { /* Are we through yet? */ if( CMcmpcase( parser, goal ) == 0 ) { goalfound = TRUE; CMnext(parser); } /* If the string is empty then bail out */ else if( STlength( parser ) == 0) break; /* Have we exhausted our parsing capabilities? */ else if (curval > maxval) break; /* If this is white space then just skip over it */ else if( CMwhite( parser )) CMnext( parser ); /* Is this an end to a parenthetical expression? */ /* its not our goal, but it could be someones */ else if( CMcmpcase( parser, ERx(")") ) == 0 && *goal != EOS) { goalfound = TRUE; break; } /* Is this a NOT (!) to reverse the value of next boolean? */ else if( CMcmpcase( parser, ERx("!") ) == 0 ) { /* Use the xor operator to toggle, allows for !(!val) */ notval[curval] ^= 1; CMnext(parser); } /* Is this a parenthetical expression? */ else if( CMcmpcase( parser,ERx("(") ) == 0) { CMnext(parser); boolval[curval++] = pp_eval_boolexp(&parser, ERx(")")); } /* Is this an AND (&&) operator? */ else if( STbcompare( parser, 2, ERx("&&"), 2, 0 ) == 0) { if (oper != OPER_NONE) { SIfprintf( stderr, E_YAPP001 ); SIfprintf( stderr, E_YAPP00F ); yydump(); } oper = OPER_AND; CMnext(parser); CMnext(parser); boolval[curval++] = pp_eval_boolexp(&parser, ERx("\n")); } /* Is this an OR (||) operator? */ else if( STbcompare( parser, 2, ERx("||"), 2, 0 ) == 0) { if (oper != OPER_NONE) { SIfprintf( stderr, E_YAPP001 ); SIfprintf( stderr, E_YAPP011 ); yydump(); } oper = OPER_OR; CMnext(parser); CMnext(parser); boolval[curval++] = pp_eval_boolexp(&parser, ERx("\n")); } /* Is this the defined() preprocessor macro? */ else if( STbcompare( parser, 7, ERx("defined"), 7, 0 ) == 0 ) { char defsym[MAX_SYMLEN + 1]; char *defptr; /* Initialize the symbol name */ STcopy(ERx(""), defsym); /* Try and find the beginning '(' */ while (STlength(parser) > 0 && CMcmpcase(parser, ERx("(") ) != 0) CMnext(parser); /* Skip over the open parenthesis, ( */ if (STlength(parser) != 0) CMnext(parser); /* Skip over any whitespace following '(' */ while (STlength(parser) > 0 && CMwhite(parser)) CMnext(parser); /* Save the name of the symbol to look up */ defptr = defsym; while (STlength(parser) > 0 && CMcmpcase(parser, ERx(")") ) != 0 && !CMwhite(parser)) { CMcpychar(parser, defptr); CMnext(parser); CMnext(defptr); } *defptr = EOS; /* Try and find the ending ')' */ while (STlength(parser) > 0 && CMcmpcase(parser, ERx(")") ) != 0) CMnext(parser); /* Skip over the closed parenthesis, ) */ if (STlength(parser) != 0) CMnext(parser); /* Make sure there was something in the parenthesis */ if (STlength(defsym) == 0) { SIfprintf( stderr, E_YAPP001 ); SIfprintf( stderr, E_YAPP013 ); yydump(); } boolval[curval++] = (is_defined(defsym, NULL) == OK); } /* Thats all we know how to parse, gotta bail out */ else { SIfprintf( stderr, E_YAPP001 ); SIfprintf( stderr, E_YAPP014 ); yydump(); } } /* Did we ultimately fail to evaluate the expression? */ if (*goal == EOS && goalfound == FALSE) { SIfprintf( stderr, E_YAPP001 ); SIfprintf( stderr, E_YAPP015 ); yydump(); } /* Now make sure something was specified in the current expression */ if (curval == 0) { SIfprintf( stderr, E_YAPP001 ); SIfprintf( stderr, E_YAPP016 ); yydump(); } /* If an operator is found make sure it had an object to operate on */ if (oper != OPER_NONE && curval <= maxval) { SIfprintf( stderr, E_YAPP001 ); SIfprintf( stderr, E_YAPP017 ); yydump(); } /* Save the current location in parse string */ *strptr = parser; /* Resolve the highest precedence NOT operators */ if (curval > 0 && notval[0] == 1) boolval[0] = !boolval[0]; if (curval > 1 && notval[1] == 1) boolval[1] = !boolval[1]; /* Resolve the final expression */ switch (oper) { case OPER_OR: rtn = boolval[0] || boolval[1]; break; case OPER_AND: rtn = boolval[0] && boolval[1]; break; default: rtn = boolval[0]; break; } return rtn; }
static u_i4 pp_directive( FILE *input, STACK_FRAME *stack , bool ifdef ) { i4 n, len; char *words[ MAX_LINE / 2 ], *temp, *p; char *parse_val, *parse_end; STACK_FRAME stack_frame; bool def_dir; u_i4 rtn = NONE; stack_frame.prev = stack; stack_frame.display_mode = TRUE; p = temp = STalloc( infile->yytext ); CMnext( p ); n = sizeof( words ); STgetwords( p, &n, words ); /* process the directive, watch out for the empty directive */ if (n == 0) { ; /* empty directive */ } else if( STequal( words[ 0 ], ERx( "define" ) ) != 0 ) { /* If a symbol was specified look for the value to give it */ if (n > 1) { /* Scan for the 'define' keyword */ parse_val = infile->yytext; CMnext(parse_val); /* Skip over the '#' */ while (CMwhite(parse_val)) CMnext(parse_val); /* Scan past the 'define' keyword */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Scan over white space separating 'define' */ /* keyword and the specified symbol name */ while (CMwhite(parse_val)) CMnext(parse_val); /* Skip over the symbol name */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Skip over white space after the symbol name */ while (CMwhite(parse_val)) CMnext(parse_val); /* At this point we have scanned to the beginning */ /* of the defined value for the symbol, Trim off */ /* any trailing white space */ STtrmwhite(parse_val); /* Define value found, could be the empty string, "" */ if( active( &stack_frame ) ) { define( words[ 1 ], parse_val, FALSE ); } } rtn = DEFINE; } else if( active( &stack_frame ) && STequal( words[ 0 ], ERx( "undef" ) ) != 0 ) { if (n > 1) { undefine( words[ 1 ] ); } rtn = UNDEF; } else if( STequal( words[ 0 ], ERx( "if" ) ) != 0 ) { /* If an expression was specified look for its evaluation */ if (n > 1) { /* Scan for the 'if' keyword */ parse_val = infile->yytext; CMnext(parse_val); /* Skip over the '#' */ while (CMwhite(parse_val)) CMnext(parse_val); /* Scan past the 'if' keyword */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Scan over white space separating 'if' */ /* keyword and the expression */ while (CMwhite(parse_val)) CMnext(parse_val); /* At this point we have scanned to the beginning */ /* of the expression.*/ if( active( &stack_frame ) ) { /* Evaluate boolean expression found */ stack_frame.display_mode = pp_eval_boolexp( &parse_val, ERx("") ); } (void) pp_input( input, &stack_frame, TRUE ); } rtn = IF; } else if( STequal( words[ 0 ], ERx( "ifdef" ) ) != 0 ) { if( active(&stack_frame) && is_defined(words[1], NULL) == OK) { stack_frame.display_mode = TRUE; } else stack_frame.display_mode = FALSE; (void) pp_input( input, &stack_frame, TRUE ); rtn = IFDEF; } else if( STequal( words[ 0 ], ERx( "ifndef" ) ) != 0 ) { if( active(&stack_frame) && is_defined(words[1], NULL) != OK) { stack_frame.display_mode = TRUE; } else stack_frame.display_mode = FALSE; (void) pp_input( input, &stack_frame, TRUE ); rtn = IFNDEF; } else if( STequal( words[ 0 ], ERx( "else" ) ) != 0 ) { if( !ifdef ) { SIfprintf( stderr, E_YAPP007 ); yydump(); } stack_frame.prev->display_mode = ( stack_frame.prev->display_mode == TRUE ) ? FALSE : TRUE; rtn = ELSE; } else if( STequal( words[ 0 ], ERx( "endif" ) ) != 0 ) { rtn = ENDIF; } else if( STequal( words[ 0 ], ERx( "include" ) ) != 0 ) { /* Look for the include filename */ if (n > 1) { /* Scan for the 'include' keyword */ parse_val = infile->yytext; CMnext(parse_val); /* Skip over the '#' */ while (CMwhite(parse_val)) CMnext(parse_val); /* Scan past the include keyword */ while (!CMwhite(parse_val)) CMnext(parse_val); /* Scan over white space separating 'include' */ /* keyword and the specified filename */ while (CMwhite(parse_val)) CMnext(parse_val); /* At this point were expecting "file" or <file> */ /* remember the character which ends the filename */ def_dir = TRUE; if (CMcmpcase(parse_val, ERx("\"")) == 0) { parse_end = ERx("\""); } else if (CMcmpcase(parse_val, ERx("<")) == 0) { parse_end = ERx(">"); def_dir = FALSE; } else { parse_end = ERx(""); } /* Save the include file name in the temp string. */ /* Note, this overwrites the parsed words of the */ /* record since but these are no longer needed. */ p = temp; CMnext(parse_val); while (*parse_val != EOS) { if (CMcmpcase(parse_val, parse_end) == 0) { /* Terminate the file name and call */ /* pp_file to process the file. */ STcopy(ERx(""), p); pp_file(stack, temp, def_dir); break; } CMcpychar(parse_val, p); CMnext(parse_val); CMnext(p); } } rtn = DEFINE; } /* display everthing but legal directives */ if (rtn == NONE && active( &stack_frame ) ) yyputline( infile->yytext ); MEfree( temp ); return( rtn ); }
main(int argc, char **argv) { char *value = NULL; char *host, *server_type, *command_line; char *server_location, *env, *arguments; u_i4 command_line_length; char config_string[256]; char iidbms[256]; STARTUPINFO si; PROCESS_INFORMATION ProcessInfo; BOOL Status; SECURITY_ATTRIBUTES sa; HANDLE hRead, hWrite; HANDLE hStdout; char buffer[512]; DWORD bufferl = sizeof(buffer); DWORD pipe_size = 0; /* Use default buffer size */ DWORD datal = 0; bool havequote, failed = FALSE; MEadvise( ME_INGRES_ALLOC ); switch (argc) { case 1: server_type = ERx("dbms"); server_location = ERx("*"); break; case 2: server_type = argv[1]; server_location = ERx("*"); break; default: server_type = argv[1]; if (STcompare(server_type, "recovery") == 0) server_location = ERx("*"); else server_location = argv[2]; break; } get_sys_dependencies(); /* ** Get the host name, formally used iipmhost. */ host = PMhost(); /* ** Build the string we will search for in the config.dat file. */ STprintf( config_string, ERx("%s.%s.%s.%s.image_name"), SystemCfgPrefix, host, server_type, server_location ); /* ** Get set up for the PMget call. */ PMinit(); if( PMload( NULL, (PM_ERR_FUNC *)NULL ) != OK ) PCexit( FAIL ); /* ** Go search config.dat for a match on the string we just built. */ PMget( config_string, &value ); if ( value == NULL ) { NMgtAt( SystemLocationVariable, &env ); if (STcompare(server_type, "recovery") == 0) { STprintf(iidbms, ERx("%s\\%s\\bin\\%sdbms"), env, SystemLocationSubdirectory, SystemCfgPrefix); } else { STprintf(iidbms, ERx("%s\\%s\\bin\\%s%s"), env, SystemLocationSubdirectory, SystemCfgPrefix, server_type); } } else if ( *value == '/' || *value == '\\' || (*(value+1) == ':' && *(value+2) == '\\') ) { /* Must be a qualified path name */ STcopy( value, iidbms ); } else { NMgtAt( SystemLocationVariable, &env ); STprintf( iidbms, ERx("%s\\%s\\bin\\%s"), env, SystemLocationSubdirectory, value ); } /* ** Initialize the startinfo structure. */ ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); /* ** Get the original command line. */ arguments = GetCommandLine(); havequote = FALSE; while (*arguments != '\0' && *arguments != '\n') { if ( *arguments == '"' ) havequote = (havequote) ? FALSE : TRUE; if ( CMwhite(arguments) && havequote == FALSE ) break; arguments++; } /* ** Put together a command line to create a process with. ** - 4 blank separators, quotes, null termination */ command_line_length = STlength(arguments) + STlength(iidbms) + STlength(iirun) + 6 + 1; if((command_line = (char *) MEreqmem(0, command_line_length, TRUE, NULL)) == NULL) { error(ERx("Request for memory failed"),NULL); } STprintf( command_line, "%s \"%s\" %s", iirun, iidbms, arguments ); /* ** Save standard out's handle, to be restored later. */ hStdout = GetStdHandle(STD_OUTPUT_HANDLE); /* ** Initialize the security attributes structure that will ** be used to make the pipe handles inheritable. */ sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; /* Make object inheritable */ /* ** Define a anonymous pipe to catch the server's startup message. */ if((Status = CreatePipe(&hRead,&hWrite,&sa,pipe_size)) != TRUE) { error(ERx("CreatePipe failed"),ERx("error code = ")); } SetStdHandle(STD_OUTPUT_HANDLE,hWrite); /* ** Initialize the security attributes structure that will ** be used to make the pipe handles inheritable. */ sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; /* Make object inheritable */ /* ** Initialize the startup information structure. */ ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); /* ** Start it up. */ /* ** Start iirun which will start the server. */ if ((Status = CreateProcess(NULL,command_line,&sa,NULL,TRUE, HIGH_PRIORITY_CLASS, NULL, NULL,&si,&ProcessInfo)) != TRUE) { DWORD dwError = GetLastError(); switch(dwError) { case ERROR_ACCESS_DENIED: error(ERROR_REQ_PRIVILEGE, ERx("")); break; case ERROR_ELEVATION_REQUIRED: error(ERROR_DENIED_PRIVILEGE, ERROR_REQ_ELEVATION); break; default: error(ERx("CreateProcess failed"),ERx("error code = ")); break; } } SetStdHandle(STD_OUTPUT_HANDLE,hStdout); for (;;) { char *tmpptr; if((Status = ReadFile(hRead,&buffer,bufferl,&datal,NULL)) != TRUE) { error(ERx("ReadFile failed"),ERx("error code = ")); } buffer[datal] = '\0'; if ((tmpptr = STstrindex(buffer, "PASS\n", 0, FALSE))) { *tmpptr = '\0'; if (STlength(buffer)) SIfprintf(stdout, "%s", buffer); break; } SIfprintf(stdout, "%s", buffer); if ((tmpptr = STstrindex(buffer, bad_msg, 0, FALSE))) { *tmpptr = '\0'; if (STlength(buffer)) SIfprintf(stdout, "%s", buffer); failed = TRUE; break; } } /* ** Close handles since we don't need them anymore. */ CloseHandle(ProcessInfo.hThread); CloseHandle(ProcessInfo.hProcess); CloseHandle(hRead); CloseHandle(hWrite); if (failed && STscompare(server_type, STlength(server_type), "gcb", 3) != 0 && STscompare(server_type, STlength(server_type), "gcc", 3) != 0 && STscompare(server_type, STlength(server_type), "jdbc", 4) != 0) { SIfprintf( stderr,"\n%s: server would not start.\n", iirundbms ); SIfprintf(stderr, " %s must be set in your environment.\n", SystemLocationVariable ); SIfprintf(stderr, " Has the csinstall program been run?\n"); SIfprintf(stderr, " %s_DATABASE, %s_CHECKPOINT, %s_JOURNAL and %s_DUMP\n", SystemVarPrefix, SystemVarPrefix, SystemVarPrefix, SystemVarPrefix ); SIfprintf(stderr, " must also be set. See %s_CONFIG\\symbol.tbl.\n", SystemVarPrefix ); SIfprintf(stderr, " Check the file '%%%s%%\\%s\\files\\errlog.log'\n", SystemLocationVariable, SystemLocationSubdirectory ); SIfprintf(stderr, " for more details concerning internal errors.\n"); SIfprintf(stderr, " See your Installation and Operation Guide for more\n"); SIfprintf(stderr, " information concerning server startup.\n"); PCexit(FAIL); } else { PCexit(OK); } }
static STATUS ns_scanner( char *queryText, API_PARSE *parse ) { char *in, *token; STATUS status = OK; /* ** Each token in the query text, excluding ** comments, is extracted and saved. One ** token is processed each time through loop. */ for( in = queryText, parse->field_count = 0; ; parse->field_count++ ) { /* ** Skip white space preceding token. */ for( ; CMwhite( in ) && *in != EOS; CMnext( in ) ); /* ** Have we found the end of the query, ** or the start of a comment? If so, ** we be done. Also, check for field ** overflow at this point. */ if ( *in == EOS || *in == '#' ) break; if ( parse->field_count >= API_FIELD_MAX ) { status = E_AP0010_INVALID_COLUMN_COUNT; break; } /* ** Find end of token. */ for( token = in; ! CMwhite( in ) && *in != EOS && *in != '#'; CMnext( in ) ); /* ** Save token in parser info. All tokens marked ** as text for now, parameter markers will be ** identified during field validation. */ if ( (in - token) >= API_NS_MAX_LEN ) { status = E_AP0011_INVALID_PARAM_VALUE; break; } MEcopy( (PTR)token, (in - token), (PTR)parse->fields[ parse->field_count ] ); parse->fields[ parse->field_count ][ in - token ] = EOS; parse->parameter[ parse->field_count ] = API_FV_TEXT; } return( status ); }
/*{ ** Name: psq_rptqry_text - add a piece of text to the text chain for a repeat ** query ** ** Description: Add a piece of text to the text chain for a repeat query. It is ** imperative that text of all repeat queries be stored in a ** uniform fashion so that comparing two stored query texts would ** serve as a reliable indicator of their sameness. Each piece ** will be preceeded with a blank except for a PERIOD. Neither the ** piece consisting of PERIOD nor the following piece will be ** preceeded with a blank. ** ** Inputs: ** header Pointer to chain header ** piece Pointer to piece of text ** size Size of piece ** result Place to put pointer to new piece ** err_blk Filled in if an error happens ** ** Outputs: ** result Filled in with pointer to chain element ** err_blk Filled in if an error happens ** Returns: ** E_DB_OK Success ** E_DB_ERROR Non-catastrophic failure ** E_DB_FATAL Catastrophic failure ** Exceptions: ** none ** ** Side Effects: ** Allocates memory ** ** History: ** 24-jan-90 (andre) ** Plagiarized from psq_tadd(). ** 28-jan-91 (andre) ** Do not insert a space if a piece is immediately following a piece ** consisting of a $. */ DB_STATUS psq_rptqry_text( PTR header, u_char *piece, i4 size, PTR *result, DB_ERROR *err_blk) { PSQ_THEAD *hp = (PSQ_THEAD *) header; PSQ_TEXT *tp; i4 err_code; bool leading_blank; char *txt; DB_STATUS status; /* ** Allocate enough space for PSQ_TEXT structure containing piece: ** all pieces will be preceeded with a blank with the following exceptions: ** - piece consisting of PERIOD will not be preceeeded with a blank; ** - piece which immediately follows a piece consisting of PERIOD; ** - piece starting with a "white" character will not be preceeded with a ** blank; ** - piece which immediately follows a piece consisting of $ (preceeded by ** a blank which was inserted by this function) */ if ( size == CMbytecnt(".") && !CMcmpcase(piece, ".") || CMwhite(piece)) { /* ** piece consists of a period or starts with a "white" character - no ** leading blanks will be added */ leading_blank = FALSE; } else if ( hp->psq_last != (PSQ_TEXT *) NULL && (( hp->psq_last->psq_psize == CMbytecnt(".") && !CMcmpcase(hp->psq_last->psq_tval, ".") ) || ( hp->psq_last->psq_psize == CMbytecnt(" ") + CMbytecnt("$") && !CMcmpcase(hp->psq_last->psq_tval, " ") && !CMcmpcase((hp->psq_last->psq_tval + CMbytecnt(" ")), "$") ) ) ) { /* ** previous piece consists of a period or of a $ preceeded by a blank ** inserted by this function - no leading blanks will be added */ leading_blank = FALSE; } else { /* insert a blank before the piece */ leading_blank = TRUE; } hp->psq_tmem.ulm_psize = (leading_blank) ? size + sizeof(PSQ_TEXT) - 1 + CMbytecnt(" ") : size + sizeof(PSQ_TEXT) - 1; if ((status = ulm_palloc(&hp->psq_tmem)) != E_DB_OK) { if (hp->psq_tmem.ulm_error.err_code == E_UL0005_NOMEM) { (VOID) psf_error(E_PS0F02_MEMORY_FULL, 0L, PSF_CALLERR, &err_code, err_blk, 0); } else { (VOID) psf_error(E_PS0371_ALLOC_TEXT_CHAIN, hp->psq_tmem.ulm_error.err_code, PSF_INTERR, &err_code, err_blk, 0); } return (status); } *result = hp->psq_tmem.ulm_pptr; tp = (PSQ_TEXT*) *result; /* Fill in text piece */ txt = (char *) tp->psq_tval; /* insert a leading blank if necessary */ if (leading_blank) { CMcpychar(" ", txt); txt += CMbytecnt(" "); } MEcopy((char *) piece, size, txt); tp->psq_psize = (leading_blank) ? size + CMbytecnt(" ") : size; /* Hook it up to the chain */ tp->psq_next = (PSQ_TEXT *) NULL; if (hp->psq_last != (PSQ_TEXT *) NULL) { hp->psq_last->psq_next = tp; tp->psq_prev = hp->psq_last; } else { tp->psq_prev = NULL; } hp->psq_last = tp; if (hp->psq_first == (PSQ_TEXT *) NULL) hp->psq_first = tp; /* Add in the length to the total for the chain */ hp->psq_tsize += tp->psq_psize; return (E_DB_OK); }
i4 yylex() { bool pattern; bool component; bool keyword; char *keyhead; char yytext[ SI_MAX_TXT_REC + 1 ]; i4 yyleng; /* skip whitespace and comments */ while( CMwhite( yyp ) || *yyp == EOS || *yyp == '-' ) { /* check for comment */ if( *yyp == '-' ) { if( STbcompare( yyp, 2, ERx( "--" ), 2, FALSE ) == 0 ) { while( *yyp != EOS ) CMnext( yyp ); } else break; } if( *yyp == EOS ) { if( SIgetrec( yybuf, sizeof( yybuf ), yyin ) != OK && yywrap() ) { return( 0 ); } else { yyp = yybuf; ++yylineno; } } else CMnext( yyp ); } /* check for a SYMBOL, PATTERN or keyword */ yyleng = 0; pattern = FALSE; keyword = TRUE; keyhead = yyp; while( CMalpha( yyp ) || *yyp == '%' || *yyp == '$' || *yyp == '*' ) { /* check for component of legal SYMBOL or PATTERN */ component = FALSE; /* check for single-character component */ switch( *yyp ) { case '%': pattern = TRUE; case '*': case '$': component = TRUE; ++yyleng; CMnext( yyp ); if( *yyp == '.' ) { ++yyleng; CMnext( yyp ); keyword = FALSE; continue; } else if( CMalpha( yyp ) ) yyerror(); continue; } while( CMalpha( yyp ) || CMdigit( yyp ) || *yyp == '_' || *yyp == '-' ) { ++yyleng; CMnext( yyp ); component = TRUE; } if( component ) { if( *yyp == '.' ) { ++yyleng; CMnext( yyp ); keyword = FALSE; continue; } continue; } } /* check for uneaten '.' */ if( *yyp == '.' ) yyerror(); if( yyleng > 0 ) { /* A keyword, SYMBOL or PATTERN was scanned */ char *p; i4 i; /* put NULL-terminated copy in yytext */ STlcopy( keyhead, yytext, yyleng ); for( p = yytext, i = 0; i <= yyleng; CMnext( p ), i++ ); *p = EOS; /* check for keywords */ if( CMalpha( keyhead) && keyword ) { if( STequal( ERx( "IF" ), yytext ) != 0 ) return( IF ); if( STequal( ERx( "ELSE" ), yytext ) != 0 ) return( ELSE ); if( STequal( ERx( "ELSEIF" ), yytext ) != 0 ) return( ELSEIF ); if( STequal( ERx( "ENDIF" ), yytext ) != 0 ) return( ENDIF ); if( STequal( ERx( "MIN" ), yytext ) != 0 ) return( MIN ); if( STequal( ERx( "MAX" ), yytext ) != 0 ) return( MAX ); if( STequal( ERx( "VALID" ), yytext ) != 0 ) return( VALID ); if( STequal( ERx( "PRIME" ), yytext ) != 0 ) return( PRIME ); if( STequal( ERx( "SIGNED_INT" ), yytext ) != 0 ) return( SIGNED_INT ); if( STequal( ERx( "DECIMAL" ), yytext ) != 0 ) return( DECIMAL ); if( STequal( ERx( "SIZETYPE" ), yytext ) != 0 ) return( SIZETYPE ); if( STequal( ERx( "POWER2" ), yytext ) != 0 ) return( POWER2 ); if( STequal( ERx( "REQUIRES" ), yytext ) != 0 ) return( REQUIRES ); if( STequal( ERx( "UNDEFINED" ), yytext ) != 0 ) return( UNDEFINED ); if( STequal( ERx( "SUM" ), yytext ) != 0 ) { yylval.integer = SUM; return( SUM ); } if( STequal( ERx( "ON" ), yytext ) != 0 ) { yylval.real = 1; return( BOOL_CON ); } if( STequal( ERx( "OFF" ), yytext ) != 0 ) { yylval.real = 0; return( BOOL_CON ); } if( STequal( ERx( "IS" ), yytext ) != 0 ) { yylval.string = STalloc( yytext ); return( COMPARE_OP ); } if( STequal( ERx( "DIRECTORY" ), yytext ) != 0 ) return( DIRECTORY ); if( STequal( ERx( "FILE" ), yytext ) != 0 ) return( FILESPEC ); } /* valid SYMBOL or PATTERN */ yylval.string = STalloc( yytext ); if( pattern ) return( PATTERN ); /* don't accept a single '*' as SYMBOL */ if( yyleng != 1 || *yytext != '*' ) return( SYMBOL ); /* push '*' back onto the input stream */ CMprev( yyp, yybuf ); } /* check for EXEC_TEXT, STR_CON, or EXEC_TEXT_STR */ if( *yyp == '`' || *yyp == '"' ) { int exec_str = 0; char *initstr = yyp; char *p = yyp, *text, *yyprev; if ( *yyp == '"' ) { CMnext( yyp ); if ( *yyp == '`' ) { CMnext( p ); exec_str = 1; } else yyp = p; } for( yyleng = 0, CMnext( yyp ), yyprev = ERx( "" ); *yyp != *p || *yyprev == '\\'; yyprev = ( *yyprev == EOS ) ? yyp : CMnext( yyprev ), CMnext( yyp ), ++yyleng ) { if( *yyp == *p && *yyprev == '\\' ) { /* remove escape character */ char *p1, *p2; for( p1 = p2 = yyprev, CMprev( p1, p ); p1 >= p; CMprev( p1, p ), CMprev( p2, p ) ) { CMcpychar( p1, p2 ); } --yyleng; CMnext( p ); } if( *yyp == EOS ) yyerror(); } CMnext( yyp ); if ( exec_str ) { if ( *yyp == '"' ) CMnext( yyp ); else { /* keep scanning to final '"' */ p = initstr; exec_str = 0; yyleng++; for( ; *yyp != *p || *yyprev == '\\'; yyprev = ( *yyprev == EOS ) ? yyp : CMnext( yyprev ), CMnext( yyp ), ++yyleng ) { if( *yyp == EOS ) yyerror(); } } } text = p; CMnext( text ); STlcopy( text, yytext, yyleng ); yytext[ yyleng ] = EOS; yylval.string = STalloc( yytext ); if( *p == '`' ) { if ( exec_str ) return( EXEC_TEXT_STR ); return( EXEC_TEXT ); } return( STR_CON ); } /* check for NUM_CON */ yyleng = 0; if( *yyp == '-' || CMdigit( yyp ) ) { f8 factor; char *p = yyp; if( *yyp == '-' ) { ++yyleng; factor = -1; CMnext( yyp ); } else factor = 1; if( !CMdigit( yyp ) ) CMprev( yyp, yybuf ); else { if( *yyp == '-' ) { CMnext( yyp ); } else factor = 1; while( CMdigit( yyp ) ) { ++yyleng; CMnext( yyp ); } if( *yyp == '.' ) { ++yyleng; CMnext( yyp ); if( !CMdigit( yyp ) ) yyerror(); while( CMdigit( yyp ) ) { ++yyleng; CMnext( yyp ); } } else if( *yyp == 'K' || *yyp == 'M' ) { ++yyleng; CMnext( yyp ); } STlcopy( p, yytext, yyleng ); yytext[ yyleng ] = EOS; if( yytext[ yyleng - 1 ] == 'K' ) { factor = 1024; yytext[ yyleng - 1 ] = EOS; } else if( yytext[ yyleng - 1 ] == 'M' ) { factor = 1048576; yytext[ yyleng - 1 ] = EOS; } CVaf( yytext, ERx( '.' ), &yylval.real ); yylval.real *= factor; return( NUM_CON ); } } if( STbcompare( yyp, 2, ERx( ">=" ), 2, FALSE ) == 0 ) { yylval.string = STalloc( ERx( ">=" ) ); CMnext( yyp ); CMnext( yyp ); return( COMPARE_OP ); } if( STbcompare( yyp, 2, ERx( "<=" ), 2, FALSE ) == 0 ) { yylval.string = STalloc( ERx( "<=" ) ); CMnext( yyp ); CMnext( yyp ); return( COMPARE_OP ); } /* check for COMPARE_OP */ if( STbcompare( yyp, 1, ERx( "<" ), 1, FALSE ) == 0 ) { yylval.string = STalloc( ERx( "<" ) ); CMnext( yyp ); return( COMPARE_OP ); } if( STbcompare( yyp, 1, ERx( ">" ), 1, FALSE ) == 0 ) { yylval.string = STalloc( ERx( ">" ) ); CMnext( yyp ); return( COMPARE_OP ); } if( STbcompare( yyp, 2, ERx( "==" ), 2, FALSE ) == 0 ) { yylval.string = STalloc( ERx( "==" ) ); CMnext( yyp ); CMnext( yyp ); return( COMPARE_OP ); } /* check for characters which get passed directly */ switch( *yyp ) { char *p; case '(': case ')': case '[': case ']': case '{': case '}': case ':': case ';': case ',': case '=': p = yyp; CMnext( yyp ); return( *p ); case '+': yylval.string = STalloc( ERx( "+" ) ); CMnext( yyp ); return( *yylval.string ); case '-': yylval.string = STalloc( ERx( "-" ) ); CMnext( yyp ); return( *yylval.string ); case '*': yylval.string = STalloc( ERx( "*" ) ); CMnext( yyp ); return( *yylval.string ); case '/': yylval.string = STalloc( ERx( "/" ) ); CMnext( yyp ); return( *yylval.string ); } /* check for LOGIC_OP */ if( STbcompare( yyp, 3, ERx( "&&" ), 3, FALSE ) == 0 ) { yylval.string = STalloc( ERx( "&&" ) ); CMnext( yyp ); CMnext( yyp ); return( LOGIC_OP ); } if( STbcompare( yyp, 3, ERx( "||" ), 3, FALSE ) == 0 ) { yylval.string = STalloc( ERx( "||" ) ); CMnext( yyp ); CMnext( yyp ); return( LOGIC_OP ); } /* anything else is an error */ yyerror(); }
/* ** Name: Disp_Fname ** ** Decription: ** Takes the string ** content-disposition: form-data; name="xxxx" filename="yyyy" ** opens an ice temporary file and sets items in the variable string ** as xxxx=icetempfile. ** ** Inputs: ** sess ice session structure ** line pointer to the current line ** linelen length of the line ** ** Outputs: ** pos number of characters handled. ** ** Return: ** GSTAT_OK success ** other failure ** ** History: ** 23-Oct-98 (fanra01) ** Created. */ static GSTATUS Disp_Fname (WTS_SESSION* sess, char* line, i4 linelen, i4 * pos) { GSTATUS err = GSTAT_OK; PWTS_UPLOAD load= sess->load; char* p = line + *pos; char* name; i4 remain = linelen - *pos; i4 i = 0; i4 j = 0; UPLOADED_FILE* upload; if (STbcompare ("name", 4, p, 0, TRUE) == 0) { /* ** Find the first quote after name */ while ((*p != '\"') && (i < remain)) { CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); /* skip the quote */ CMnext(p); name= p; while ((*p != '\"') && (i < remain)) { j+=CMbytecnt(p); CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); CMnext(p); /* skip the quote */ while ((*p != ';') && (i < remain)) { CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); CMnext(p); /* skip the semi colon */ /* ** Allocate space for the variable name a '=' character and an EOS */ if ((err = GAlloc (&load->varname, j+2, FALSE)) == GSTAT_OK) { MEfill (j+2, 0, load->varname); MECOPY_VAR_MACRO (name, j, load->varname); STcat (load->varname, "="); } while (CMwhite(p) && (i < remain)) { CMbyteinc(i, p); CMnext(p); } if (STbcompare ("filename", 8, p, 0, TRUE) == 0) { /* ** Find the first quote after filename */ while ((*p != '\"') && (i < remain)) { CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); CMnext(p); /* skip the quote */ name= p; while ((*p != '\"') && (i < remain)) { j+=CMbytecnt(p); CMbyteinc(i,p); CMnext(p); } CMbyteinc(i,p); CMnext(p); /* skip the quote */ /* ** Allocate space for the filename and an EOS */ if ((err = GAlloc (&load->filename, j+1, FALSE)) == GSTAT_OK) { MEfill (j+1, 0, load->filename); MECOPY_VAR_MACRO (name, j, load->filename); asct_trace( ASCT_LOG )( ASCT_TRACE_PARAMS, "Upload session=%s file=%s", ((sess->act_session != NULL) ? ((sess->act_session->user_session) ? sess->act_session->user_session->name : "None") : "None"), load->filename ); } *pos += i; err = G_ME_REQ_MEM(0, upload, UPLOADED_FILE, 1); if (err == GSTAT_OK) { bool status; err = WCSRequest( 0, NULL, SYSTEM_ID, NULL, WSF_ICE_SUFFIX, &upload->file, &status); if (err == GSTAT_OK) { CLEAR_STATUS(WCSLoaded(upload->file, TRUE)); err = WCSOpen (upload->file, "w", SI_BIN, 0); if (err == GSTAT_OK) { i4 nlen = STlength (load->varname); i4 flen = STlength(upload->file->info->path); err = GAlloc(&load->icefname, flen + 1, FALSE); if (err == GSTAT_OK) { MECOPY_VAR_MACRO( upload->file->info->path, flen, load->icefname); err = GAlloc((PTR*)&sess->variable, sess->vlen + nlen + flen + 2, TRUE); if (err == GSTAT_OK && sess->variable != NULL) { if (sess->vlen > 0) { sess->variable[sess->vlen++] = '&'; } MECOPY_VAR_MACRO(load->varname, nlen, sess->variable + sess->vlen); sess->vlen += nlen; if (flen) { MECOPY_VAR_MACRO(load->icefname, flen, sess->variable + sess->vlen); sess->vlen += flen; upload->next = sess->list; sess->list = upload; } sess->variable[sess->vlen] = EOS; } } } else { CLEAR_STATUS(WCSRelease(&upload->file)); } } } load->state = US_FILE; } else { HandlerException (sess, line, linelen, pos); } } else { HandlerException (sess, line, linelen, pos); } return (err); }
/* ** Name: ** ** Decription: ** ** Inputs: ** load ** buf ** len ** ** Outputs: ** count ** ** Return: ** ** History: ** 23-Oct-98 (fanra01) ** Created. ** 01-Feb-1999 (fanra01) ** Add data length parameter to determine incomplete messages. ** 27-Apr-1999 (fanra01) ** Update the incomplete message handling to account for '--' ** characters that don't define a boundary. */ static i4 getstrevent (PWTS_UPLOAD load, char *buf, i4 len, i4 datalen, i4 * count) { i4 eventnum = 0; i4 i; i4 j; char* p = buf; i4 pos = 0; i4 boundlen; if ((buf[0]=='-') && (buf[1] == '-')) { /* ** If the remaining string is less than the length of boundary string ** there is likely more to follow. Set the event for a partial ** boundary. */ boundlen = STlength(load->end); if ((boundlen < datalen) && (STbcompare (load->end, boundlen, p, 0, TRUE) == 0)) { eventnum = UE_EBOUND; pos+=STlength(load->end); } else { boundlen = STlength(load->start); if ((boundlen < datalen) && (STbcompare (load->start, boundlen, p, 0, TRUE) == 0)) { eventnum = UE_SBOUND; pos+=STlength(load->start); } else { if (datalen < boundlen) { eventnum = UE_PBOUND; } } } } if ((eventnum == 0) && (*p) && (STbcompare (ERx("content-"), 8, p, 0, TRUE) == 0)) { pos+=8; p+=pos; /* ** Scan list of content attributes */ for (i=0; (attribute[i] != NULL) && (eventnum == 0); i++) { if ((STbcompare (attribute[i], STlength(attribute[i]), p, 0, TRUE)) == 0) { p += STlength(attribute[i]); pos+=STlength(attribute[i]); /* ** Ensure we don't go beyond the line */ while ((pos < len) && CMwhite(p)) { CMbyteinc(pos, p); CMnext(p); } switch (i) { case A_TYPE: if ((STbcompare (ERx("multipart/mixed"), 15, p, 0, TRUE)) == 0) { pos+=15; p += 15; eventnum = UE_EMBED; } else { eventnum = UE_MIME; } break; case A_DISP: for (j=0; (disptype[j] != NULL) && (eventnum == 0); j++) { if ((STbcompare (disptype[j], STlength(disptype[j]), p, 0, TRUE)) == 0) { pos+=STlength(disptype[j]); p += STlength(disptype[j]); /* ** Ensure we don't go beyond the line */ while ((pos < len) && CMwhite(p)) { CMbyteinc(pos, p); CMnext(p); } switch (j) { case D_FORM: if (STstrindex(p, "filename=", len - pos, TRUE) !=NULL) { eventnum = UE_FNAME; } else { eventnum = UE_FORM; } break; case D_ATTACH: eventnum = UE_FNAME; break; } } } if (eventnum == 0) eventnum = UE_EXCEPT; break; case A_ENC: eventnum = UE_FENC; break; } } } if (eventnum == 0) eventnum = UE_EXCEPT; } else { if (eventnum == 0) { /* ** Unnamed line - determine event on previous state */ switch (load->state) { case US_VAL: eventnum = UE_VALUE; break; case US_FWRITE: eventnum = UE_FVALUE; break; default: eventnum = UE_EXCEPT; break; } } } *count+=pos; return (eventnum); }