/*{ ** Name: CXset_context - Set the CX node "context". ** ** Description: ** ** If configured for clusters, the CX "context" determines ** what node the calling utility is bound to. That is, ** what directory is used when mapping shared segments, how ** file names are "decorated", and It determines the default ** PM hostname, and if running NUMA clusters, the host name ** override. ** ** Inputs: ** host - Node name or host name for the context. ** If NULL, value from PHhost is used. ** rad - If running NUMA clusters, 1st argument must be the host ** name, (or NULL), and a node name is constructed from ** the hostname(PMhost)/rad pair as "R<radid>_<hostname>" ** If not running NUMA clusters, this must be zero. ** ** Outputs: ** none. ** ** Returns: ** OK - Context was set. ** E_CL2C2F_CX_E_BADRAD - Rad value out of range. ** E_CL2C42_CX_E_NOT_CONFIGURED - Node or RAD not configured ** as part of the cluster. ** ** Exceptions: ** none ** ** Side Effects: ** Important & plentyful, see description. ** ** History: ** 16-sep-2002 (devjo01) ** Created. */ STATUS CXset_context( char * host, i4 rad ) { # define HOST_PM_IDX 1 STATUS status = OK; CX_NODE_INFO *pni; char namebuf[ CX_MAX_NODE_NAME_LEN + 1 ]; do { if ( !host ) { host = CXhost_name(); } if ( CXcluster_configured() ) { pni = CXnode_info( host, rad ); if ( NULL == pni ) { status = E_CL2C42_CX_E_NOT_CONFIGURED; break; } namebuf[CX_MAX_NODE_NAME_LEN] = '\0'; STlcopy( pni->cx_node_name, namebuf, CX_MAX_NODE_NAME_LEN ); CVlower( namebuf ); STcopy(namebuf, cx_saved_node_name); if ( pni->cx_host_name_l && ( pni->cx_host_name_l != pni->cx_node_name_l || 0 != STxcompare( pni->cx_node_name, pni->cx_node_name_l, pni->cx_host_name, pni->cx_host_name_l, TRUE, FALSE ) ) ) { STlcopy( pni->cx_host_name, namebuf, CX_MAX_NODE_NAME_LEN ); CVlower( namebuf ); PMsetDefault( HOST_PM_IDX, namebuf ); } else { PMsetDefault( HOST_PM_IDX, namebuf ); } if ( 0 != pni->cx_rad_id ) CX_Proc_CB.cx_numa_user_rad = pni->cx_rad_id; CX_Proc_CB.cx_numa_cluster_rad = pni->cx_rad_id; } else { PMsetDefault( HOST_PM_IDX, host ); if ( 0 != rad ) CX_Proc_CB.cx_numa_user_rad = rad; } } while (0); return status; } /* CXset_context */
bool adu_1monthcheck( char *input, i4 *output) { i4 month; /* month can be an integer, or an alphanumeric code */ if (CVal(input, &month) == OK) { *output = month; return (month < 1 || month > MONTHS_PER_YR); } else { const ADU_DATENAME *d; _VOID_ CVlower(input); d = adu_monthname_lookup(input,STlength(input)); if (d == NULL) { *output = 0; return 1; } *output = d->d_value; return (d->d_class != 'm'); /* TWISTED LOGIC! */ } }
bool r_srt_set() { /* internal declarations */ register SORT *srt; /* fast ptr to SORT array */ i4 sequence; /* sort sequence number */ ATTRIB ordinal; /* attribute ordinal */ bool noerr = TRUE; /* abort if error in sort vars */ /* start of routine */ En_n_sorted = En_scount; if (En_n_sorted < 1) { /* no sort attributes specified */ En_n_sorted = 0; return(noerr); } /* no sort attributes specified */ /* go through the database lines and convert */ for(sequence=1,srt=Ptr_sort_top; sequence<=En_n_sorted; srt++,sequence++) { CVlower(srt->sort_break); CVlower(srt->sort_direct); if ((ordinal=r_mtch_att(srt->sort_attid)) < 0) { /* attribute not in data relation */ r_error(0x06, NONFATAL, srt->sort_attid, NULL); noerr = FALSE; continue; } /* attribute not in data relation */ srt->sort_ordinal = ordinal; } if (!noerr) { En_n_sorted = 0; return(noerr); } return(noerr); }
/*{ ** Name: CXhost_name - Get host name for current machine. ** ** Description: ** ** This is just a wrapper for PMhost, which assures that ** the name is not more than CX_MAX_NODE_NAME_LEN characters ** long and is entirely lower case. ** ** Inputs: ** none ** ** Outputs: ** none ** ** Returns: ** Address of cached host name. ** ** Exceptions: ** none ** ** Side Effects: ** none. ** ** History: ** 01-oct-2001 (devjo01) ** Created. ** 17-dec-2004 (devjo01) ** Correct 'cx_saved_node_name' ref to intended 'cx_hostname'. */ char * CXhost_name() { static char cx_hostname[CX_MAX_HOST_NAME_LEN] = { '\0', }; if ( '\0' == cx_hostname[0] ) { STlcopy( PMhost(), cx_hostname, CX_MAX_HOST_NAME_LEN ); CVlower(cx_hostname); } return cx_hostname; } /* CXhost_name */
void FEapply_date_format(ADF_CB *cb, char *date_format) { i4 date_fmt; CVlower(date_format); /* Use common function for date formats (kibro01) b119318 */ date_fmt = adu_date_format(date_format); if (date_fmt == -1) { IIUGerr(E_UG0020_BadDateFormat, 0, 1, (PTR)date_format); /* default is "us" */ } else { cb->adf_dfmt = date_fmt; } }
/*{ ** Name: aboslver - Initialize the OSL version. ** ** Description: ** Initialize the OSL version. On most OS this is a noop. On VMS ** check to capability settings. If either OSL/QUEL or OSL/SQL are ** enabled, then it is new OSL. ** ** History: ** 19-jun-1987 (Joe) ** Initial Version */ aboslver() { # ifdef VMS char *cp; osNewVersion = 1; /* ** Some VMS customers may have old version of OSL. ** Want a way to test, so allow a logical name to set. */ NMgtAt(ERx("II_OSL_VERSION"), &cp); if (cp != NULL) { CVlower(cp); osNewVersion = !(*cp == 'o'); } # else osNewVersion = 1; # endif /* VMS */ }
/* ** Name: IILQasAdfcbChange ** ** Description: ** Change the date_format on the fly. ** ** Multiple sessions are stored as a linked list of session control ** blocks. However, there always exists a static default session block. ** A static ADF control block is set up for the static default session ** block while ADF control blocks for each session in the link list ** are dynamically allocated. ** This routine only changes the current session date format and ** the default session date format. ** Inputs: ** Date_format string. ** ** Outputs: ** None. ** ** Returns: ** STATUS ** OK - ADF Control Block was succesfully allocated. ** FAIL - Failed to allocate an ADF Control Block. ** ** Side Effects: ** Changes the ADF control block date format for the current session (and ** NOTE: this function is not called anywhere internally and probably ** shouldn't be. Set date_format works properly from SQL tm now. This ** function is left here in case any sites still use it. ** for the default saved session). You must issue a set date_format ** statement to change the back-end date format. Otherwise all insert, ** update date will be messed up. ** ** History: ** 05-jun-1997 (nanpr01) ** Written on request for karl schendel. ** 16-jun-1997 (nanpr01) ** Take out the dmy, mdy and ymd support since they are not supported ** in set date_format command. ** 24-Jun-1999 (shero03) ** Support ISO4 date. ** 18-Oct-2007 (kibro01) b119318 ** Use a common function in adu to determine valid date formats */ STATUS IILQasAdfcbChange(char *date_format) { II_THR_CB *thr_cb = IILQthThread(); II_LBQ_CB *IIlbqcb = thr_cb->ii_th_session; II_LBQ_CB *def = &thr_cb->ii_th_defsess; if (date_format != NULL) { i4 date_value; CVlower(date_format); date_value = adu_date_format(date_format); if (date_value == -1) return(E_DB_ERROR); IIlbqcb->ii_lq_adf->adf_dfmt = date_value; def->ii_lq_adf->adf_dfmt = date_value; } return(E_DB_OK); }
/*{ ** Name: CXget_context - Parse command arguments for NUMA args. ** ** Description: ** ** One particularly ugly requirement of NUMA clusters, is the need ** to specify the target context of certain commands that ** normally could easily determine a default context by themselves. ** ** E.g. 'lockstat' run on any node of a non-NUMA cluster "knows" ** implicitly that the current node corresponds to the current host. ** ** However, in a NUMA cluster, this happy state, no longer applies. ** If our sysadm logs onto a node which is configured into two or ** more virtual NUMA nodes, there is no way for 'lockstat', etc., ** to guess which of the virtual nodes is the target for the Ingres ** tool. ** ** We try to make a virtue of this neccesity by centralizing the ** parsing needed for these commands and in passing pick up a ** generalized way of setting processor affinity for Ingres tools. ** ** Two types of arguments are checked here: ** '-rad' is a RAD spec, in which the host machine is implicitly ** the local machine. ** ** '-node' may refer to either a local RAD by its node name or ** node alias, or to a node anywhere in thr cluster if CX_NSC_NODE_GLOBAL ** is set. ** ** Both arguments can be in the form -arg=value, or -arg value. ** ** The users input is checked against the following rules: ** ** R1: If NOT running clusters, '-node' parameter will always ** cause an error. ** ** R2: Only one of either "-node" or "-rad" is allowed. ** ** R3: If "-rad" is present, value must correspond to a valid RAD. ** ** R4: If "-node" is present, it must be a valid node, or node alias. ** ** R4a: If CX_NSC_NODE_GLOBAL is not set, node must match local host ** name or be hosted (virtual nodes only) by local host. ** ** R5: If not otherwise specified, and running NUMA clusters, ** RAD value is taken from environment variable II_DEFAULT_RAD. ** ** R6: If running NUMA clusters, and CX_NSC_RAD_OPTIONAL is not ** set, an error will be reported if context is not set by a ** valid -rad, or -node, or II_DEFAULT_RAD value. ** ** R7: If rules R2-R6 are not violated, and CX_NSC_CONSUME is set, ** and an matching parameter or parameter pair was provided, ** the parameters are removed from the argument vector, and ** the argument count is adjusted. ** ** R8: If CX_NSC_SET_CONTEXT is set, and not running NUMA clusters, ** and a valid RAD value was provided with an explicit '-rad' ** argument, CXnuma_bind_to_rad is called to set process affinity ** to the specified RAD. ** ** R9: If CX_NSC_SET_CONTEXT is set, running NUMA clusters, or ** if a valid '-node' parameter was supplied, CXset_cluster ** is called for the specified node. ** ** R10: If CX_NSC_REPORT_ERRS is set, and an error occurred, ** message is sent to stdout. ** ** If all appropriate rules are met, then OK is returned. ** Caller should be set up to catch and complain about any ** extra invalid parameters. ** ** If outbuf is not NULL, node name if copied out if status = ** OK, else error message text is copies out. In both cases ** only a max of outlen chars are returned, including an EOS. ** ** Inputs: ** ** pargc - Address of integer holding # of arg strings. ** ** argv - Array of string pointers to argument values. ** ** flags - Flag bits OR'ed together. Valid flags are: ** ** CX_NSC_REPORT_ERRS - Emit any error message to stdout. ** ** CX_NSC_NODE_GLOBAL - Allow node argument to refer to ** Nodes outside the current host. ** ** CX_NSC_CONSUME - Eat any -rad/-node args & values if OK. ** ** CX_NSC_IGNORE_NODE - Ignore '-node' params in scan. ** ** CX_NSC_SET_CONTEXT - Set CX context based on good params. ** ** CX_NSC_RAD_OPTIONAL - Don't fail if NUMA & RAD not set. ** If running NUMA clusters, only ** set this in combination with ** CX_NSC_SET_CONTEXT if you are sure ** that shared memory won't be accessed, ** and all you need is to retreive the ** context later (e.g. iirun). ** ** outbuf - buffer to receive nodename, or error message text. ** ** outlen - limit to # bytes copied to outbuf. ** ** Outputs: ** ** *pargc - decremented by if argument(s) are consumed. ** ** argv - Adjused to remove consumed argument(s). ** ** outbuf - Holds '\0' terminated string with either nodename ** or error message depending on status. ** ** Returns: ** OK - All is well. ** E_CL2C40_CX_E_BAD_PARAMETER - Bad params values, ** or bad combination ** of parameters. ** E_CL2C43_CX_E_REMOTE_NODE - Node specified was not on ** current host machine. ** E_CL2C2F_CX_E_BADRAD - Rad value out of range. ** E_CL2C42_CX_E_NOT_CONFIGURED - Node or RAD not configured ** as part of a cluster. ** E_CL2C41_CX_E_MUST_SET_RAD - Running NUMA clusters, ** and no argument, or ** environment variable, set ** the RAD context. ** ** Exceptions: ** none ** ** Side Effects: ** See CXnuma_bind_to_rad(), if called with a '-rad' ** argument outside a NUMA cluster, else see ** CXset_context(). ** ** Notes: ** Typically in a NUMA cluster configuration, the target RAD ** information is needed very early in the applications logic, ** since it cannot implicitly determine the virtual node it ** is intended to be running on. ** ** History: ** 18-sep-2002 (devjo01) ** Created. */ STATUS CXget_context( i4 *pargc, char *argv[], i4 flags, char *outbuf, i4 outlen ) { STATUS status = OK; CX_NODE_INFO *pni = NULL; bool numa; i4 arg, radarg = 0, nodearg = 0, badarg = 0; i4 target_rad; i4 argstokill = 1; char *pvalue = NULL, *argp, *host; char lclbuf[256]; i4 erargc; ER_ARGUMENT erargs[2]; host = CXhost_name(); do { /* Scan passed arguments for "-rad" & "-node" */ for ( arg = 1; arg < *pargc; arg++ ) { argp = argv[arg]; if ( '-' != *argp ) continue; if ( 0 == STxcompare(argp, 4, ERx( "-rad" ), 4, FALSE, FALSE) ) { if ( radarg || nodearg ) { /* R2 */ badarg = arg; break; } radarg = arg; if ( *(argp + 4) == '=' ) { pvalue = argp + 5; } else if ( '\0' != *(argp + 4) || (arg >= (*pargc - 1)) ) { /* R3 */ badarg = arg; break; } else { /* Next argument must be a valid RAD ID */ pvalue = argv[++arg]; argstokill = 2; } if ( '\0' == *pvalue ) { /* R3 */ badarg = radarg; break; } if ( OK != CVan( pvalue, &target_rad ) || target_rad <= 0 ) { /* R3 */ badarg = arg; break; } } else if ( !(CX_NSC_IGNORE_NODE & flags) && 0 == STxcompare(argp, 5, ERx( "-node" ), 5, FALSE, FALSE ) ) { if ( radarg || nodearg ) { /* R2 */ badarg = arg; break; } nodearg = arg; if ( *(argp + 5) == '=' ) { pvalue = argp + 6; } else if ( ('\0' != *(argp + 5)) || (arg >= (*pargc - 1)) ) { /* R4 */ badarg = arg; break; } else { /* Next argument must be a node ID */ pvalue = argv[++arg]; argstokill = 2; } if ( '\0' == *pvalue ) { /* R4 */ badarg = nodearg; break; } } } /* end for */ /* If bad syntax seen, scram & fail */ if ( badarg ) { status = E_CL2C40_CX_E_BAD_PARAMETER; erargc = 1; erargs[0].er_size = 0; erargs[0].er_value = (PTR)argv[badarg]; break; } numa = CXnuma_cluster_configured(); /* If no explicit parameters seen, try default */ if ( numa && !pvalue && !(flags & CX_NSC_RAD_OPTIONAL) ) { /* R5 */ argp = ERx( "II_DEFAULT_RAD" ); pvalue = getenv( argp ); if ( pvalue && ( ( '\0' == *pvalue ) || OK != CVan(pvalue, &target_rad) ) ) pvalue = NULL; } /* Got a value either from command line or environment */ if ( pvalue ) { if ( nodearg ) { if ( CXcluster_configured() ) { pni = CXnode_info(pvalue, 0); if ( pni ) { /* If can't be global, make sure its local */ if ( !(flags & CX_NSC_NODE_GLOBAL) && !( ( 0 == STxcompare( host, 0, pni->cx_node_name, pni->cx_node_name_l, TRUE, FALSE ) ) || ( ( 0 != pni->cx_host_name_l ) && ( 0 == STxcompare( host, 0, pni->cx_host_name, pni->cx_host_name_l, TRUE, FALSE ) ) ) ) ) { /* Node must be local and was not. (R4a) */ status = E_CL2C43_CX_E_REMOTE_NODE; erargc = 2; erargs[0].er_size = 0; erargs[0].er_value = (PTR)argv[0]; erargs[1].er_size = pni->cx_host_name_l; erargs[1].er_value = (PTR)(pni->cx_host_name); break; } } } } else if ( numa ) { pni = CXnode_info(host, target_rad); } else if ( target_rad > CXnuma_rad_count() ) { if ( !(flags & CX_NSC_RAD_OPTIONAL) ) { /* R3 */ status = E_CL2C2F_CX_E_BADRAD; erargc = 0; break; } target_rad = 0; } if ( ( numa || nodearg ) && ( NULL == pni ) ) { /* Requested node/rad not configured */ /* R3, R4 */ if ( !argp ) argp = argv[radarg+nodearg]; status = E_CL2C42_CX_E_NOT_CONFIGURED; erargc = 1; erargs[0].er_size = 0; erargs[0].er_value = (PTR)argp; break; } } else { if ( numa && !(flags & CX_NSC_RAD_OPTIONAL) ) { /* If required argument missing, scram & fail */ status = E_CL2C41_CX_E_MUST_SET_RAD; erargc = 1; erargs[0].er_size = 0; erargs[0].er_value = (PTR)argv[0]; break; } } if ( (flags & CX_NSC_CONSUME) && (radarg || nodearg) ) { for ( arg = radarg + nodearg + argstokill; arg < *pargc; arg++ ) { argv[arg-argstokill] = argv[arg]; } *pargc = *pargc - argstokill; argv[*pargc] = NULL; } } while (0); if ( OK == status ) { lclbuf[CX_MAX_NODE_NAME_LEN] = '\0'; if ( NULL == pni ) { (void)STlcopy(host, lclbuf, CX_MAX_NODE_NAME_LEN); } else { (void)STlcopy(pni->cx_node_name, lclbuf, CX_MAX_NODE_NAME_LEN); } CVlower( lclbuf ); if ( flags & CX_NSC_SET_CONTEXT ) { if ( !numa && 0 != target_rad ) { (void)CXnuma_bind_to_rad( target_rad ); } (void)CXset_context(lclbuf, 0); } } if ( OK != status ) { cx_fmt_msg( status, lclbuf, sizeof(lclbuf), erargc, erargs ); if ( flags & CX_NSC_REPORT_ERRS ) (void)SIprintf( "\n%s\n", lclbuf ); } if ( outbuf ) { STlcopy( lclbuf, outbuf, outlen - 1 ); *(outbuf + outlen - 1) = '\0'; } return status; } /*CXget_context*/
STATUS s_lrem_set() { char *b; char *bend; i4 pos; i4 n; i4 length; # ifdef UNIX char word[OOLONGREMSIZE+1]; # else char word[MAXCMD+1]; # endif i4 code; i4 count; char *save_Tokchar; char long_remark[OOLONGREMSIZE+1]; i4 rtn_char; /* dummy variable for sgskip */ if (St_lr_given) { s_error(0x3A9, NONFATAL, NULL); s_cmd_skip(); return FAIL; } if (Cact_ren == NULL) { s_error(0x38A, FATAL, NULL); } St_lr_given = TRUE; /* skip leading white space */ s_g_skip(TRUE, &rtn_char); /* handle rest of remark up to the .ENDREMARK */ code = S_ERROR; b = long_remark; bend = b + OOLONGREMSIZE; for (;;) { while (*Tokchar != '\n' && *Tokchar != EOS) { if (*Tokchar == '.' && CMalpha(Tokchar+1)) { /* check for .ENDREMARK */ save_Tokchar = Tokchar; Tokchar++; r_gt_word(word); CVlower(word); code = s_get_scode(word); if (code == S_ENDREMARK) { break; } else { Tokchar = save_Tokchar; } } if (b <= bend-CMbytecnt(Tokchar)) { if (*Tokchar == '\t') { /* if tab, replace it with the one blank */ *b = ' '; b++; Tokchar++; } else { CMcpyinc(Tokchar, b); } } else { CMnext(Tokchar); } } if (code == S_ENDREMARK) { *b = EOS; Cact_ren->ren_longrem = STalloc(long_remark); break; } else { if (b < bend) { *b++ = ' '; } count = s_next_line(); if (count == 0) { /* ERROR: EOF in middle of remark */ s_error(0x3A3, FATAL, NULL); break; } } } return OK; }
bool rFqur_set() { /* internal declarations */ i4 sequence; /* current seq in QUR array */ register QUR *qur; /* fast ptr to QUR array */ i4 rfq_parse_state; /* ** Scanning state for where ** clause. */ i4 type; /* Token type returned */ bool rfq_error; /* TRUE if parse error occurs*/ i4 ord; /* ordinal of attribute */ COPT *copt; /* Copt structure */ char *qual; /* Pointer to qualification */ char *n_qual; /* ** Pointer to qualification ** after skip to any parens ** for JoinDef */ char chk_char; /* ** Hold current char to check ** for comments. */ char rvar[FE_UNRML_MAXNAME+1]; /* Range Var name in where */ char attname[FE_UNRML_MAXNAME+1]; /* Attribute name in where */ char ColName[FE_MAXNAME+1]; /* RBF Internal column name */ FE_RSLV_NAME rfq_ferslv; /* ** Work struct to decompose ** compound identifiers. */ /* start of routine */ # ifdef xRTR1 if (TRgettrace(200,0)) { SIprintf(ERx("rFqur_set: entry.\r\n")); } # endif qual = NULL; for (sequence = 1,qur = Ptr_qur_arr; sequence <= En_qcount; qur++,sequence++) { CVlower(qur->qur_section); if (STcompare(qur->qur_section,NAM_WHERE) == 0) { _VOID_ rfNextQueryLine(&qual, qur->qur_text); } } /* ** If we are here when creating a new report, we don't have ** any selection criteria to look for. */ if (qual == NULL) { return(TRUE); } if (*qual == EOS) { _VOID_ MEfree((PTR)qual); return(TRUE); } /* ** If the source of data is a JoinDef, we need to skip over ** the part of the qualification that defines the join. So, find ** any open parenthesis - if none, then no selection criteria exist. ** Otherwise, reset the qual pointer to the open parens. */ n_qual = qual; if ((En_SrcTyp == JDRepSrc) && ((n_qual = STindex(qual,ERx("("),0)) == NULL)) { return(TRUE); } r_g_set(n_qual); rfq_error = FALSE; rfq_parse_state = FIND_OPAREN; /* ** Note that the parse state won't change until we first see ** an open parens. */ while ((!rfq_error) && ((type = r_g_skip()) != TK_ENDSTRING)) { switch(type) { case(TK_ALPHA): case(TK_QUOTE): if (type == TK_QUOTE) { /* ** Check for QUEL string constant first, ** then check for disallowed delimited ** identifier. */ if (En_qlang == FEDMLQUEL) { _VOID_ MEfree((PTR)r_g_string( TK_QUOTE)); break; } else if (!Rbf_xns_given) { rfq_error = TRUE; break; } } rfq_ferslv.name = r_g_ident(TRUE); /* ** Handle the relation operator 'LIKE' if ** that's what we're looking for. Note that ** for it to be a valid identifier, it would have ** to be in quotes! */ if ((rfq_parse_state == FIND_GREATER) && (STbcompare(rfq_ferslv.name, STlength(rfq_ferslv.name), ERx("like"), STlength(ERx("like")),TRUE) == 0)) { rfq_parse_state = FIND_OPAREN; _VOID_ MEfree((PTR)rfq_ferslv.name); break; } /* ** Handle the start of the UNION SELECT clause - ** it means that we're all done. However, unless the ** state is FIND_OPAREN, then we have an error which ** the subsequent identifier check will catch (failed ** for the identifier being a reserved word). Note ** that for it to be a valid identifier, it would have ** to be in quotes! */ if ((rfq_parse_state == FIND_OPAREN) && (STbcompare(rfq_ferslv.name, STlength(rfq_ferslv.name), ERx("union"), STlength(ERx("union")),TRUE) == 0)) { _VOID_ MEfree((PTR)rfq_ferslv.name); _VOID_ MEfree((PTR)qual); return(TRUE); } /* ** Keep skipping unless we're looking for an ** identifier. This will handle LOGICALS like ** AND, OR, etc., as well as right side expressions. */ if (rfq_parse_state != FIND_IDENT) { _VOID_ MEfree((PTR)rfq_ferslv.name); break; } rfq_ferslv.name_dest = &attname[0]; rfq_ferslv.owner_dest = &rvar[0]; rfq_ferslv.is_nrml = FALSE; FE_decompose(&rfq_ferslv); if ((IIUGdlm_ChkdlmBEobject(rfq_ferslv.name_dest, rfq_ferslv.name_dest, rfq_ferslv.is_nrml) == UI_BOGUS_ID) || ((rfq_ferslv.owner_spec) && (IIUGdlm_ChkdlmBEobject(rfq_ferslv.owner_dest, rfq_ferslv.owner_dest, rfq_ferslv.is_nrml) == UI_BOGUS_ID))) { rfq_error = TRUE; _VOID_ MEfree((PTR)rfq_ferslv.name); break; } if (En_SrcTyp == JDRepSrc) { if (!r_JDMaintAttrList(JD_ATT_GET_ATTR_NAME, &rvar[0],&attname[0], &ColName[0])) { /* ** Why doesn't this result in the fatal error ** that a parse failure would? The 6.4 version ** would actually fail here if a UNION SELECT ** was present and return - rFdisplay() does ** not check the return code. Since we now ** handle the end of the WHERE clause in a more ** sane manner, maybe this should be a fatal ** error ... */ _VOID_ MEfree((PTR)rfq_ferslv.name); _VOID_ MEfree((PTR)qual); return(FALSE); } STcopy(&ColName[0],&attname[0]); } ord = r_mtch_att(&attname[0]); if (ord < 0) { /* Bad attribute name */ IIUGerr(E_RF003A_rFqur_set__Bad_attrib, UG_ERR_FATAL,1,&attname[0]); } /* ** Set the column options of the attribute. We assume ** its a value until/unless we find a range indicator. */ copt = rFgt_copt(ord); copt->copt_select = 'v'; rfq_parse_state = FIND_GREATER; _VOID_ MEfree((PTR)rfq_ferslv.name); break; case(TK_OPAREN): CMnext(Tokchar); /* Skip the paren */ if (rfq_parse_state == FIND_OPAREN) { rfq_parse_state = FIND_IDENT; break; } /* ** Ignore open parens unless we're specifically ** looking for them. This handles instances of ** min(), max(), etc. */ break; case(TK_CPAREN): CMnext(Tokchar); /* Skip the paren */ if ((rfq_parse_state == FIND_CPAREN) && (copt != (COPT *)NULL) && (copt->copt_select == 'r')) { rfq_parse_state = FIND_2CPAREN; copt = (COPT *)NULL; break; } if (rfq_parse_state == FIND_2CPAREN) { rfq_parse_state = FIND_OPAREN; break; } /* ** Ignore closing parens unless we're specifically ** looking for them. This also handles instances of ** min(), max(), etc. */ break; case(TK_EQUALS): case(TK_RELOP): CMnext(Tokchar); /* Skip the relation operator */ /* ** Handle '!=', '>=', '<=' compound operators */ if (*Tokchar == '=') { CMnext(Tokchar); } if (rfq_parse_state == FIND_GREATER) { if (type == TK_RELOP) { /* Must be a range of values */ copt->copt_select = 'r'; rfq_parse_state = FIND_CPAREN; } else { rfq_parse_state = FIND_OPAREN; } } break; case(TK_SQUOTE): CMnext(Tokchar); /* ** Handle single quoted string values atomically so ** we don't get confused by their containing parens, ** etc. */ _VOID_ MEfree((PTR)r_g_string(TK_SQUOTE)); break; case(TK_DOLLAR): CMnext(Tokchar); /* ** Handle variables independently from identifiers so ** we don't get confused by something like '$like'. ** Additionally, allow compound constructs so we don't ** get confused by something like "$abc.columnname". ** Note that this compound construct should only result ** from user modifications, and is detrimental only ** when the state is FIND_IDENT - we won't assign any ** ColumnOptions to columnname. */ _VOID_ MEfree((PTR)r_g_ident(TRUE)); break; default: /* ** We should only really be here if we see the start ** of a comment ... */ chk_char = *Tokchar; CMnext(Tokchar); if ((chk_char == '/') && (*Tokchar == '*')) { /* ** Note the implication that a comment may not ** "interrupt" the WHERE clause. If we ** allowed one to, then we'd have to add ** comment recognition to the entire parse ** loop to avoid being confused! */ _VOID_ MEfree((PTR)qual); return(TRUE); } break; } } if ((rfq_error) || (rfq_parse_state != FIND_OPAREN)) { IIUGerr(E_RF003B_rFqur_set__Bad_where_,UG_ERR_FATAL,0); } _VOID_ MEfree((PTR)qual); return(TRUE); }
/*{ ** Name: scs_monitor - Implement the SCS part of the monitor task ** ** Description: ** This routine is called ala the regular thread processing routine. ** It parses its input, decides what to do, and returns the output. ** ** The commmands completely interpreted here are: ** ** set server shut (CS_CLOSE) ** Disallow new connections, shutdown when ** last current session exits. ** ** remove SESSION ** New improved "safe" version, acts the same ** as front-end exiting and dropping GCA connection. ** ** kill SESSION ** Signal CS_KILL_EVENT to a user session actively ** running a query. ** ** NEW: ** set server closed ** Disallow new regular user sessions. ** ** set server open ** Reallow new regular user sessions. Cancel ** any pending 'set server shut' shutdown. ** ** show server listen ** ** crash session SESSIONID ** ** Commands partially handled here and partially in CSmonitor are: ** ** stop server (CS_KILL) ** Kill user sessions, shutdown when they're gone. ** ** stop server conditional (CS_COND_CLOSE) ** Shutdown if no sessions, which never works because ** this session always exists. ** ** crash server (CS_CRASH) ** Take the server down immediately. ** ** All other commands are passed to CSmonitor for handling. ** ** Inputs: ** mode Mode of operation ** CS_INPUT, _OUPUT, ... ** scb Sessions control block to monitor ** *command Text of the command ** powerful Is this user powerful ** output_fcn Function to call to perform the output. ** This routine will be called as ** (*output_fcn)(newline_present, ** length, ** buffer) ** where buffer is the length character ** output string, and newline_present ** indicates whether a newline needs to ** be added to the end of the string. ** ** Outputs: ** next_mode As above. ** Returns: ** OK ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 26-Jul-1993 (daveb) ** created. ** 15-Sep-1993 (daveb) ** ifdef out all but drop connection for now. ** 1-Nov-1993 (daveb) ** Match LRC proposal. Drop becomes remove, remove becomes kill. ** 10-Nov-1993 (daveb) ** Match approved proposal. Kill becomes "crash session SESSIONID" ** 15-dec-93 (robf) ** Add prototype "broadcast" message request. ** 4-mar-94 (robf) ** Add initial security auditing to iimonitor events. ** 12-dec-1996 (canor01) ** Add support for sampler thread. ** 24-Apr-2003 (jenjo02) ** Added "kill" command to abort eligible queries ** while leaving the session intact, SIR 110141. ** 17-Sep-2004 (schka24) ** Manual fix to remove command so that it fires. ** 05-may-2005 (horda03) Bug 114453/INGSRV 3290 ** For server/session changes log the command. ** 22-may-2007 (horda03) Bug 117966 ** Log the command before calling CSmonitor, as ** the CS could be crashing the server. ** 23-Sep-2009 (hanal04) Bug 115316 ** Added "SHOW SERVER CAPABILITIES". */ static STATUS scs_monitor( i4 mode, CS_SCB *scb, i4 *nmode, char *command, i4 powerful, i4 (*output_fcn)(PTR, i4, char *) ) { STATUS ret_stat; char buf[81]; bool completely_done; PTR ptr_scb; SCD_SCB *an_scb; i4 log_cmd = 0; i4 local_error; SCD_SCB *my_scb = (SCD_SCB*)scb; *nmode = CS_EXCHANGE; completely_done = FALSE; ret_stat = OK; switch (mode) { case CS_INITIATE: *nmode = CS_INPUT; break; case CS_TERMINATE: break; case CS_INPUT: CVlower(command); if (STscompare("setservershut", 0, command, 0) == 0) { /* Audit log the attempt here? */ if (!powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser status required to stop servers"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX274D_SET_SERVER_SHUT ); } else /* disallow regular listens, exit when last conn exits */ { Sc_main_cb->sc_listen_mask = (SC_LSN_TERM_IDLE |SC_LSN_SPECIAL_OK) ; TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Server will stop. %d. sessions remaining", Sc_main_cb->sc_current_conns ); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX274D_SET_SERVER_SHUT ); log_cmd = 1; } completely_done = TRUE; } else if (STscompare("setserverclosed", 0, command, 0) == 0) { /* Audit log the attempt here? */ if (!powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser status required to disable connections"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX2748_SET_SERVER_CLOSED ); } else /* Disallow regular listens */ { if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX2748_SET_SERVER_CLOSED ); Sc_main_cb->sc_listen_mask &= (~SC_LSN_REGULAR_OK); TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "User connections now disabled" ); log_cmd = 1; } completely_done = TRUE; } else if (STscompare("setserveropen", 0, command, 0) == 0) { /* Audit log the attempt here? */ if (!powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser status required to enable connections"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX2749_SET_SERVER_OPEN ); } else /* allow all listens, cancel any impending shutdown */ { Sc_main_cb->sc_listen_mask = (SC_LSN_REGULAR_OK | SC_LSN_SPECIAL_OK); TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "User connections now allowed" ); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX2749_SET_SERVER_OPEN ); log_cmd = 1; } completely_done = TRUE; } else if (STncasecmp("broadcast", command, 9) == 0) { /* Audit log the attempt here? */ if (!powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser status required to broadcast messages"); } else { /* ** Broadcast the message to any connected sessions */ scs_scan_scbs(scs_broadcast_mesg, (PTR)(command+10)); } completely_done = TRUE; } else if (STscompare("stopserverconditional", 0, command, 0) == 0 || STscompare("stopserver", 0, command, 0) == 0 || STscompare("crashserver", 0, command, 0) == 0 ) { /* Audit log the attempt here? */ if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, powerful? SXF_A_CONTROL|SXF_A_SUCCESS: SXF_A_CONTROL|SXF_A_FAIL, /* Action */ I_SX274A_STOP_SERVER ); log_cmd = powerful; } else if (STscompare("showservercapabilities", 0, command, 0) == 0) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "%v", SC_CAPABILITIES_FLAGS, Sc_main_cb->sc_capabilities ); completely_done = TRUE; } else if (STscompare("showserverlisten", 0, command, 0) == 0) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "%s", Sc_main_cb->sc_listen_mask & SC_LSN_REGULAR_OK ? "OPEN" : "CLOSED" ); completely_done = TRUE; } else if (STscompare("showservershutdown", 0, command, 0) == 0) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "%s", Sc_main_cb->sc_listen_mask & SC_LSN_TERM_IDLE ? "PENDING" : "OPEN" ); completely_done = TRUE; } # ifdef NOT_SUPPORTED else if (STscompare("showconnections", 0, command, 0) == 0 ) { scs_scan_scbs( scs_show_func, (PTR)&powerful ); completely_done = TRUE; } else if (STscompare("show connection", 15, command, 15) == 0 ) { completely_done = TRUE; STzapblank(command, command); if (CVaxptr(command + 14, &ptr_scb) || !scs_is_user_scb( (an_scb = (SCD_SCB *)ptr_scb) ) ) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Invalid connection id"); break; } scs_show_func( an_scb, &powerful ); } # endif else if (STscompare("remove", 6, command, 6) == 0) { completely_done = TRUE; STzapblank(command, command); if (CVaxptr(command + 6, &ptr_scb) || scb == NULL || !scs_is_user_scb( (an_scb = (SCD_SCB *)ptr_scb) ) || an_scb == my_scb ) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Invalid session id"); break; } if ((MEcmp(an_scb->cs_scb.cs_username, scb->cs_username, sizeof(scb->cs_username))) && !powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser or owner status required to remove session"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX274B_REMOVE_SESSION ); break; } if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX274B_REMOVE_SESSION ); scs_remove_sess( an_scb ); TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p removed", an_scb); log_cmd = 1; } else if (STscompare("crash session", 13, command, 13) == 0) { completely_done = TRUE; STzapblank(command, command); if (CVaxptr(command + 12, &ptr_scb) || scb == NULL || !scs_is_user_scb( (an_scb = (SCD_SCB *)ptr_scb) ) || an_scb == my_scb ) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Invalid session id"); break; } if ((MEcmp(an_scb->cs_scb.cs_username, scb->cs_username, sizeof(scb->cs_username))) && !powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser or owner status required to crash session"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX274C_CRASH_SESSION ); break; } if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX274C_CRASH_SESSION ); scs_crash_sess( an_scb ); TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p crashed", an_scb); log_cmd = 1; } else if (STscompare("kill", 4, command, 4) == 0) { completely_done = TRUE; STzapblank(command, command); if (CVaxptr(command + 4, &ptr_scb) || scb == NULL || !scs_is_user_scb( (an_scb = (SCD_SCB *)ptr_scb) ) || an_scb == my_scb ) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Invalid session id"); } else if ((MEcmp(an_scb->cs_scb.cs_username, scb->cs_username, sizeof(scb->cs_username))) && !powerful) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Superuser or owner status required to kill query"); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_FAIL, I_SX2755_KILL_QUERY ); } else switch ( an_scb->scb_sscb.sscb_qmode ) { case 0: TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p is not executing a query", an_scb); break; /* Honor only "meaningful" types of queries: */ case PSQ_RETRIEVE: case PSQ_RETINTO: case PSQ_APPEND: case PSQ_REPLACE: case PSQ_DELETE: case PSQ_COPY: case PSQ_MODIFY: case PSQ_EXECQRY: case PSQ_EXCURS: case PSQ_CALLPROC: case PSQ_REPCURS: case PSQ_RETCURS: case PSQ_EXEDBP: case PSQ_REGPROC: case PSQ_DDEXECPROC: case PSQ_CREATE: if ( an_scb->scb_sscb.sscb_force_abort || an_scb->scb_sscb.sscb_interrupt ) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p query already aborting", an_scb); } else { scs_kill_query( an_scb ); if ( Sc_main_cb->sc_capabilities & SC_C_C2SECURE ) scs_mon_audit((SCD_SCB*)scb, SXF_A_CONTROL|SXF_A_SUCCESS, I_SX2755_KILL_QUERY ); TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p query killed", an_scb); } break; default: TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "Session %p query cannot be killed", an_scb); break; } } # ifdef NOT_SUPPORTED else if (STscompare("help", 0, command, 0) == 0) { TRformat(output_fcn, 1, buf, sizeof(buf) - 1, "SCS monitor commands:\nset server shut\nset server closed\nset server open\nshow server listen\nshow server shutdown\nremove SESSION\ncrash session SESSION\n\nCS monitor commands:\n"); } # endif else if (! CS_is_mt()) /* OS Thread version will start an OS thread in the CS */ if ((STscompare("start sampling", 14, command, 14) == 0)) { if (!powerful) { TRformat(output_fcn, (i4 *) 1, buf, sizeof(buf)-1, "Superuser status required to start sampling.", 0L); } else { GCA_LS_PARMS local_crb; CL_ERR_DESC errdesc; local_crb.gca_status = 0; local_crb.gca_assoc_id = 0; local_crb.gca_size_advise = 0; local_crb.gca_user_name = "<Sampler Thread>"; local_crb.gca_account_name = 0; local_crb.gca_access_point_identifier = "NONE"; local_crb.gca_application_id = 0; /* set up all the CS control blocks for the sampler */ ret_stat = CSmonitor( mode, scb, nmode, command, powerful, output_fcn ); if ( ret_stat == OK ) ret_stat = CSadd_thread(CS_LIM_PRIORITY-1, (PTR) &local_crb, SCS_SSAMPLER, (CS_SID*)NULL, &errdesc); if (ret_stat) { TRformat(output_fcn, (i4 *) 1, buf, sizeof(buf)-1, "Sampling failed to start."); } } } /* log the command before calling CSmonitor(), as the server could be left in an ** unknown state if the command CRASH SERVER or STOP SERVER are used */ if (log_cmd) { ule_format( I_SC051E_IIMONITOR_CMD, 0, ULE_LOG, NULL, 0, 0, 0, &local_error, 3, STlength(command), command, DB_OWN_MAXNAME, &((SCD_SCB *)scb)->scb_sscb.sscb_ics.ics_rusername, sizeof(DB_TERM_NAME), &((SCD_SCB *)scb)->scb_sscb.sscb_ics.ics_terminal, 0, 0); } if( !completely_done ) ret_stat = CSmonitor( mode, scb, nmode, command, powerful, output_fcn ); break; case CS_OUTPUT: break; } return( ret_stat ); }
VOID r_p_begin() { /* internal declarations */ char *aname; /* name of found attribute */ char *delim; i4 type; /* token type */ /* start of routine */ if ((type = r_g_skip()) != TK_ENDSTRING) { switch (type) { case(TK_ALPHA): aname = r_g_name(); CVlower(aname); /* for begin rbfaggs strip agg # */ /* nop for others */ switch(r_gt_code(aname)) { case(C_WITHIN): r_p_within(); break; case(C_BLOCK): r_p_flag(P_BLOCK); break; case(C_FF): /* for the hell of it */ r_p_flag(P_FF); break; case(C_UL): /* for the hell of it */ r_p_flag(P_UL); break; /* the rest are RBF internal commands */ case(C_RBFAGGS): /* start of aggs */ r_p_flag(P_RBFAGGS); break; case(C_RBFFIELD): /* start of field */ r_p_flag(P_RBFFIELD); break; case(C_RBFHEAD): /* start of column head */ r_p_flag(P_RBFHEAD); break; case(C_RBFPBOT): /* start of page bottom */ r_p_flag(P_RBFPBOT); break; case(C_RBFPTOP): /* start of page top */ r_p_flag(P_RBFPTOP); break; case(C_RBFSETUP): /* start of report setup */ r_p_flag(P_RBFSETUP); break; case(C_RBFTITLE): /* start of report title */ r_p_flag(P_RBFTITLE); break; case(C_RBFTRIM): /* start of trim */ r_p_flag(P_RBFTRIM); break; default: r_p_flag(P_NOOP); break; } break; default: r_p_flag(P_NOOP); break; } return; } /* only a plain old .BEGIN will get here */ Cact_tcmd->tcmd_code = P_BEGIN; return; }
VOID do_crack_cmd(i4 argc, char **argv) { i4 i; i4 argc_remain; i4 obj_params; bool rn_params; bool bogus_param; bool all_param; OOID del_obj_type; STATUS c; char *with_ptr; char *user_flag; char *group_flag; char *pwd_flag; char *tmp_ptr; FE_DEL *fd; FE_DEL *prev_fd; char pr_buf[256]; /* Holds any current prompt */ /* ** Default to no wildcard expansion and no specified object type. ** Indicate no names seen yet on command line, and no bogus ** parameters. Indicate no object type specifications (there ** should never be more than one). ** Track remaining command line parameters. */ Dobj_wildcard = FALSE; del_obj_type = OC_UNDEFINED; obj_params = 0; rn_params = FALSE; bogus_param = FALSE; all_param = FALSE; argc_remain = argc - 1; /* Bypass argv[0] - the program name! */ Dobj_database = NULL; /* assume no database name b66456 */ i = 1; /* First pull out any flags */ while (i < argc) { if (*(argv[i]) == '-') /* Flag found. Set and clear out */ { switch(*(argv[i] + 1)) { case('r'): case('R'): CVlower((argv[i] + 1)); if (STcompare((argv[i] + 1),DO_RPT_FLAG) == 0) { del_obj_type = OC_REPORT; Dobj_pr_str = ERget(F_DE0008_Rep); obj_params++; } else { bogus_param = TRUE; } break; case('f'): case('F'): CVlower((argv[i] + 1)); if (STcompare((argv[i] + 1),DO_FORM_FLAG) == 0) { del_obj_type = OC_FORM; Dobj_pr_str = ERget(F_DE0004_Form); obj_params++; } else { bogus_param = TRUE; } break; case('j'): case('J'): CVlower((argv[i] + 1)); if (STcompare((argv[i] + 1),DO_JD_FLAG) == 0) { del_obj_type = OC_JOINDEF; Dobj_pr_str = ERget(F_DE0006_Jdef); obj_params++; } else { bogus_param = TRUE; } break; case('g'): case('G'): tmp_ptr = STalloc(argv[i]); CVlower((tmp_ptr + 1)); if (STcompare((tmp_ptr + 1),DO_GRAF_FLAG) == 0) { del_obj_type = OC_GRAPH; Dobj_pr_str = ERget(F_DE0005_Graph); obj_params++; } else if (*(argv[i] + 1) == 'G') { Dobj_gidflag = argv[i]; } else { bogus_param = TRUE; } MEfree((PTR)tmp_ptr); break; case('a'): case('A'): CVlower((argv[i] + 1)); if (STcompare((argv[i] + 1),DO_APPL_FLAG) == 0) { del_obj_type = OC_APPL; Dobj_pr_str = ERget(F_DE0003_App); obj_params++; } else if (STcompare((argv[i] + 1), DO_ALL_FLAG) == 0) { del_obj_type = OC_OBJECT; /* ** No prompt string for -all */ Dobj_pr_str = ERget(F_DE0009_Dobj_O); all_param = TRUE; } else { bogus_param = TRUE; } break; case('q'): case('Q'): CVlower((argv[i] + 1)); if (STcompare((argv[i] + 1),DO_QBF_FLAG) == 0) { del_obj_type = OC_QBFNAME; Dobj_pr_str = ERget(F_DE0007_Qbfnm); obj_params++; } else { bogus_param = TRUE; } break; case('i'): case('I'): CVlower((argv[i] + 1)); if (STcompare((argv[i] + 1),DO_INCL_FLAG) == 0) { /* ** Clear out the flag so we don't see ** it when we look for DB and FE object ** names. */ argv[i] = NULL; i++; if (i >= argc) { IIUGerr(E_DE000B_Dobj_no_file, UG_ERR_ERROR,0); FEexits(ERx("")); PCexit(FAIL); break; } Dobj_dfile = argv[i]; } else { bogus_param = TRUE; } break; case('s'): case('S'): CVlower((argv[i] + 1)); if (STcompare((argv[i] + 1),DO_QT_FLAG) == 0) { Dobj_silent = TRUE; } else { bogus_param = TRUE; } break; case('u'): case('U'): Dobj_uflag = argv[i]; break; case('w'): case('W'): CVlower((argv[i] + 1)); if (STcompare((argv[i] + 1),DO_WILD_FLAG) == 0) { Dobj_wildcard = TRUE; } else { bogus_param = TRUE; } break; case('P'): /* -P (password) flag set */ Dobj_passflag = argv[i]; break; default: bogus_param = TRUE; break; } if (bogus_param) { IIUGerr(E_DE000A_Dobj_bad_flag, UG_ERR_ERROR,2,argv[i], ERget(E_DE0014_Dobj_syntax)); FEexits(ERx("")); PCexit(FAIL); } /* ** Clear out the flag so we don't see it when ** we look for DB and FE object names. */ argv[i] = NULL; argc_remain--; } i++; } # ifdef DGC_AOS with_ptr = STalloc(ERx("dgc_mode='reading'"); IIUIswc_SetWithClause(with_ptr); # else with_ptr = ERx(""); # endif /* ** If -all was specified, then we can't have -wildcard, -include, ** object type specifications, or objects names as well. argc_remain ** should at most reflect a database name. */ if ((all_param) && ((Dobj_wildcard) || (Dobj_dfile != NULL) || (obj_params > 0) || (argc_remain > 1))) { IIUGerr(E_DE0012_Dobj_badall,UG_ERR_ERROR,1, ERget(E_DE0014_Dobj_syntax)); FEexits(ERx("")); PCexit(FAIL); } /* ** If multiple object types were specified, then abort! */ if (obj_params > 1) { IIUGerr(E_DE0015_Dobj_multype,UG_ERR_ERROR,1, ERget(E_DE0014_Dobj_syntax)); FEexits(ERx("")); PCexit(FAIL); } /* ** If no object type was specified, then abort! */ if (del_obj_type == OC_UNDEFINED) { IIUGerr(E_DE0013_Dobj_notype,UG_ERR_ERROR,1, ERget(E_DE0014_Dobj_syntax)); FEexits(ERx("")); PCexit(FAIL); } /* ** Check to see that the database name was specified. ** If so, it will be the first non-flag parameter. ** If not, ask for one: */ i = 1; while (i < argc) { if (argv[i] == NULL) { /* ** If we reached a used option, ** then the database name is missing. b66456 */ break; /* i++; */ /* continue; */ } /* ** If we reached an option then, no dbname b66456 */ if (*argv[i] == '-') break; Dobj_database = argv[i++]; break; } if (Dobj_database == NULL) { c = FEprompt(ERget(FE_Database),TRUE,(sizeof(pr_buf) - 1), &pr_buf[0]); Dobj_database = STalloc(&pr_buf[0]); } /* ** If the '-P' flag has been set, prompt for the password */ if (Dobj_passflag != NULL) { /* ** If there is something wrong with the '-P' flag, such as the ** user has specified the password on the command line, ** IIUIpassword() will return NULL. In such cases bail out. */ if ((Dobj_passflag = IIUIpassword(Dobj_passflag)) == NULL) { IIUGerr(E_DE000A_Dobj_bad_flag,UG_ERR_ERROR,2, ERx("-P"),ERget(E_DE0014_Dobj_syntax)); FEexits(ERx("")); PCexit(FAIL); } } /* ** Open the database, will abort on FAIL. We do it here because we ** need to establish the invoking user name before we process the FE ** object names. We use "user" since owners of FE objects are always ** stored in the FE catalogs as lower case. This will have to change ** to suser when we fully support authorization identifiers as ** delimited identifiers, which can be other than lower case ** (specifically FIPS which is UI_MIXED_CASE). */ user_flag = ERx(""); group_flag = ERx(""); pwd_flag = ERx(""); if (Dobj_uflag != NULL) { user_flag = Dobj_uflag; } if (Dobj_gidflag != NULL) { group_flag = Dobj_gidflag; } if (Dobj_passflag != NULL) { pwd_flag = Dobj_passflag; } if (FEingres(Dobj_database,user_flag,group_flag,pwd_flag,NULL) != OK) { IIUGerr(E_DE0004_NoOpen,UG_ERR_ERROR,0); FEexits(ERx("")); PCexit(FAIL); } /* ** If -all was specified, force a wildcard expansion of "%". ** do_expand_name() will recognize del_obj_type == OC_OBJECT ** as being special. */ if (del_obj_type == OC_OBJECT) { Dobj_wildcard = TRUE; fd = (FE_DEL *)MEreqmem(0,sizeof(FE_DEL),TRUE,NULL); Ptr_fd_top = fd; prev_fd = (FE_DEL *)NULL; Cact_fd = fd; Cact_fd->fd_name_info = (FE_RSLV_NAME *)MEreqmem(0, sizeof(FE_RSLV_NAME),TRUE,NULL); Cact_fd->fd_name_info->name = STalloc(ERx("%")); Cact_fd->fd_below = (FE_DEL *)NULL; Cact_fd = do_expand_name(Cact_fd,&prev_fd,del_obj_type); return; } /* ** The rest of the parameters will be FE object names. */ while (i < argc) { if (argv[i] == NULL) { i++; continue; } rn_params = TRUE; fd = (FE_DEL *)MEreqmem(0,sizeof(FE_DEL),TRUE,NULL); if (Ptr_fd_top == (FE_DEL *)NULL) { Ptr_fd_top = fd; prev_fd = (FE_DEL *)NULL; } else { Cact_fd->fd_below = fd; prev_fd = Cact_fd; } Cact_fd = fd; Cact_fd->fd_name_info = (FE_RSLV_NAME *)MEreqmem(0, sizeof(FE_RSLV_NAME),TRUE,NULL); Cact_fd->fd_name_info->name = STalloc(argv[i]); Cact_fd->fd_below = (FE_DEL *)NULL; Cact_fd = do_expand_name(Cact_fd,&prev_fd,del_obj_type); /* ** Returns ptr to current end of FE_DEL chain, which may be ** NULL if (still) 1st and no match. If no match, the FE_DEL ** and its name will have been de-allocated, and prev_fd and ** Ptr_fd_top will have been be altered as required. */ i++; } if (Dobj_dfile != NULL) { do_ifile_parse(Dobj_dfile,del_obj_type); } /* ** If we found anything, then we're all done */ if (Ptr_fd_top != (FE_DEL *)NULL) { return; } /* ** If we had FE object names either on the command line or in a ** file but they all failed expansion/resolution, then don't prompt ** for any names! */ if ((rn_params) || (Dobj_dfile != NULL)) { IIUGerr(E_DE000C_Dobj_no_input,UG_ERR_ERROR,1, Dobj_pr_str); FEexits(ERx("")); PCexit(FAIL); } /* ** Prompt for no FE object name - either on ** the command line or in a -list file. Note that ** we ignore any Dobj_silent in this instance. */ while (TRUE) { c = FEprompt(Dobj_pr_str,FALSE,(sizeof(pr_buf) - 1),&pr_buf[0]); if ((c != OK) || (STtrmwhite(&pr_buf[0]) == 0)) { /* ** When NULL string entered (or error), all done */ break; } fd = (FE_DEL *)MEreqmem(0,sizeof(FE_DEL),TRUE,NULL); if (Ptr_fd_top == (FE_DEL *)NULL) { Ptr_fd_top = fd; prev_fd = (FE_DEL *)NULL; } else { Cact_fd->fd_below = fd; prev_fd = Cact_fd; } Cact_fd = fd; Cact_fd->fd_name_info = (FE_RSLV_NAME *)MEreqmem(0, sizeof(FE_RSLV_NAME),TRUE,NULL); Cact_fd->fd_name_info->name = STalloc(&pr_buf[0]); Cact_fd->fd_below = (FE_DEL *)NULL; Cact_fd = do_expand_name(Cact_fd,&prev_fd,del_obj_type); } if (Ptr_fd_top == (FE_DEL *)NULL) { IIUGerr(E_DE000C_Dobj_no_input,UG_ERR_ERROR,1,Dobj_pr_str); FEexits(ERx("")); PCexit(FAIL); } return; }