/*{ ** Name: open_infile - open a template file ** ** Description: ** Opens a template file from a directory. ** ** Inputs: ** directory - template directory ** template_filename - input template file name ** ** Outputs: ** none ** ** Returns: ** NULL - open failed ** FILE * - file pointer */ FILE * open_infile( char *directory, char *template_filename) { FILE *in_file; char *p; char filename[MAX_LOC+1]; LOCATION loc; if (template_filename == NULL || *template_filename == EOS) { IIUGerr(E_RM00EE_Null_empty_arg, UG_ERR_ERROR, 1, ERx("open_infile")); return (NULL); } STcopy(directory, filename); LOfroms(PATH, filename, &loc); LOfstfile(template_filename, &loc); if (SIfopen(&loc, ERx("r"), SI_TXT, SI_MAX_TXT_REC, &in_file) != OK) { LOtos(&loc, &p); IIUGerr(E_RM00F1_Err_open_template, UG_ERR_ERROR, 1, p); return (NULL); } return (in_file); }
/*{ ** Name: open_outfile - creates or appends to an output file ** ** Description: ** Creates or opens (for append) a file in a directory and sets a ** LOCATION structure. ** ** Inputs: ** out_filename - output file name ** out_dir - output directory ** create_or_append - create a new file or append to existing file ** uniq - make a unique filename ** ** Outputs: ** loc_name - output file path ** ** Returns: ** NULL - open failed ** FILE * - file pointer */ FILE * open_outfile( char *out_filename, char *out_dir, char *create_or_append, char *loc_name, bool uniq) { FILE *out_file; char *p; char filename[MAX_LOC+1]; LOCATION loc; if (loc_name == NULL) return (NULL); if (CMcmpcase(create_or_append, ERx("c")) == 0) { STcopy(out_dir, filename); LOfroms(PATH, filename, &loc); /* if uniq is 1, create a unique filename */ if (uniq == 1) LOuniq(out_filename, ERx(""), &loc); else LOfstfile(out_filename, &loc); if (SIfopen(&loc, ERx("w"), SI_TXT, SI_MAX_TXT_REC, &out_file) != OK) { IIUGerr(E_RM00F2_Err_open_outfile, UG_ERR_ERROR, 1, out_filename); return (NULL); } LOtos(&loc, &p); STcopy(p, loc_name); } else { LOfroms(PATH & FILENAME, loc_name, &loc); if (SIfopen(&loc, ERx("a"), SI_TXT, SI_MAX_TXT_REC, &out_file) != OK) { IIUGerr(E_RM00F2_Err_open_outfile, UG_ERR_ERROR, 1, out_filename); return (NULL); } } return (out_file); }
i4 do_ifile_parse(char *filename,OOID del_obj_type) { i4 i; FILE *fp; STATUS status; LOCATION loc; char buf[(DO_MAXLINE + 1)]; LOfroms((PATH & FILENAME),filename,&loc); status = SIopen(&loc,ERx("r"),&fp); if (status != OK) { IIUGerr(E_DE000D_Dobj_open_fail,UG_ERR_ERROR,1,filename); return(FAIL); } while ((i = do_readln(fp,&buf[0],sizeof(buf))) >= 0) { if (i == 0) { /* ** Ignore empty lines */ continue; } do_getwords(&buf[0],del_obj_type); } SIclose(fp); return(OK); }
TAGID FEgettag(void) { u_i2 tag; tag = MEgettag(); if (tag == 0) IIUGerr(E_UG002F_BadMemoryTag, 0, 0); return tag; }
/* ** Name: main ** ** Description: ** Program entry point handles processing of command line arguments. ** ** Inputs: ** argc Count of number of parameters ** argv List of parameters. ** ** Outputs: ** None. ** ** Returns: ** OK Completed successfully ** !OK Failed. ** ** History: ** 23-May-2001 (fanra01) ** Created. */ ICE_STATUS main(int argc, II_CHAR** argv) { ICE_STATUS status = OK; II_INT4 opt = 1; if (argc == 1) { IIUGerr( E_WU0024_ICEVAR_USAGE, UG_ERR_ERROR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); return(FAIL); } switch(argc) { case 6: progparms.value = argv[5]; case 5: progparms.variable = argv[4]; progparms.scope = argv[3]; if (STcompare(argv[2], IC_STR_RET) == 0) { progparms.action = IC_VAR_RET; } else if (STcompare(argv[2], IC_STR_SET) == 0) { progparms.action = IC_VAR_SET; } progparms.cookie = argv[1]; progparms.name = argv[0]; /* setup for use in messages */ status = icevar( &progparms ); break; default: IIUGerr( E_WU0024_ICEVAR_USAGE, UG_ERR_ERROR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); status = FAIL; break; } return(status); }
i4 delCom() { register POS *ps; if (vfrealx == endxFrm + 1 + IIVFsfaSpaceForAttr) { IIUGerr(E_VF0035_Can_not_delete_right, UG_ERR_ERROR, 0); return; } if (globy == endFrame) { IIUGerr(E_VF0036_Cant_delete_the_last, UG_ERR_ERROR, 0); return; } ps = onPos(globy, globx); if (ps != NULL) delFeat(ps, TRUE, FALSE); else delLine(globy); }
void FEapply_decimal(ADF_CB *cb, char *decimal) { if (*(decimal+1) != EOS || (*decimal != '.' && *decimal != ',')) { IIUGerr(E_UG0023_BadDecimal, 0, 1, (PTR)decimal); /* default is `.' */ } else { cb->adf_decimal.db_decimal = decimal[0]; } }
void FEapply_money_format(ADF_CB *cb, char *money_format) { CMtolower(money_format, money_format); if ((*money_format == 'n') && STlength(money_format) == 4) { if ( ((*(money_format+1) == 'o') || (*(money_format+1) == 'O')) && ((*(money_format+2) == 'n') || (*(money_format+2) == 'N')) && ((*(money_format+3) == 'e') || (*(money_format+3) == 'E')) ) { cb->adf_mfmt.db_mny_lort = DB_NONE_MONY; } else { IIUGerr(E_UG0021_BadMnyFormat, 0, 1, (PTR)money_format); } } else if ((*money_format != 'l' && *money_format != 't' && *money_format != 'n') || *(money_format+1) != ':' /* {l|t}:$$$ */ || STlength(money_format) > DB_MAXMONY + 2 || STlength(money_format) < 3) { IIUGerr(E_UG0021_BadMnyFormat, 0, 1, (PTR)money_format); /* default is "l:$"; leading currency symbol of "$" */ } else { if ( *money_format == 'l') { cb->adf_mfmt.db_mny_lort = DB_LEAD_MONY; } else if ( *money_format == 't' ) { cb->adf_mfmt.db_mny_lort = DB_TRAIL_MONY; } STcopy( money_format + 2, cb->adf_mfmt.db_mny_sym ); } }
static bool proc_install(char *featname, bool only) { PKGBLK *pkg; SCAN_LIST(distPkgList,pkg) { if (!STbcompare(featname, 0, pkg->feature, 0, TRUE)) { pkg->selected = SELECTED; return TRUE; } } IIUGerr(E_ST017A_bad_featname, 0, 1, featname); return FALSE; }
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; } }
void FEapply_money_prec(ADF_CB *cb, char *money_prec) { if (*money_prec == '0') { cb->adf_mfmt.db_mny_prec = 0; } else if (*money_prec == '1') { cb->adf_mfmt.db_mny_prec = 1; } else if (*money_prec != '2') { IIUGerr(E_UG0022_BadMnyPrec, 0, 1, (PTR)money_prec); /* default is 2 */ } }
static bool proc_version(char *featname, bool only) { PKGBLK *pkg; SCAN_LIST(instPkgList,pkg) { if (!STbcompare(featname, 0, pkg->feature, 0, TRUE)) { if (!only) /* Don't identify the package if there's only one. */ SIfprintf(batchOutf, ERx("%s "), pkg->feature); SIfprintf(batchOutf, ERx("%s\n"), pkg->version); return TRUE; } } IIUGerr(E_ST017B_not_present, 0, 1, featname); return FALSE; }
/* ** Name: icevar ** ** Description: ** ** ** Inputs: ** parms command line parameters. ** ** Outputs: ** None. ** ** Returns: ** OK Completed successfully ** !OK Failed. ** ** History: ** 23-May-2001 (fanra01) ** Created. */ ICE_STATUS icevar( PARAMS* parms ) { ICE_STATUS status = OK; II_CHAR cookie[80]; HICECTX hicectx; STprintf( cookie, "ii_cookie=%s", progparms.cookie ); if ((status = ic_initialize( NULL, NULL, NULL, cookie, &hicectx )) == OK) { switch(parms->action) { case IC_VAR_SET: status = ic_setvariable( hicectx, parms->scope, parms->variable, parms->value ); break; case IC_VAR_RET: status = ic_retvariable( hicectx, parms->scope, parms->variable, &parms->value ); break; } ic_close( hicectx ); } if (status != OK) { IIUGerr( status, UG_ERR_ERROR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); } else { SIprintf("%s: %s=%s\n", parms->name, parms->variable, ((parms->value != NULL) ? parms->value : "\0") ); } return(status); }
ADF_CB * FEadfcb () { if (!done) { char *cp; DB_STATUS rval; PTR srv_cb_ptr; SIZE_TYPE srv_size; SIZE_TYPE dbinfo_size; PTR dbinfoptr; STATUS tmtz_status; STATUS date_status; char date_type_alias[100]; char col[] = "udefault"; STATUS status = OK; CL_ERR_DESC sys_err; ADUUCETAB *ucode_ctbl; /* unicode collation information */ PTR ucode_cvtbl; done = TRUE; /* first, get the size of the ADF's server control block */ srv_size = adg_srv_size(); /* allocate enough memory for it */ if ((srv_cb_ptr = MEreqmem(0, srv_size, FALSE, (STATUS *)NULL)) == NULL) { EXsignal(EXFEBUG, 1, ERx("FEadfcb(alloc)")); } /* ** Fix up code so that "now" works properly for frontends. ** Only allocating enough for one (1) dbmsinfo() request. */ dbinfo_size = sizeof(ADF_TAB_DBMSINFO); if ((dbinfoptr = MEreqmem(0, dbinfo_size, TRUE, (STATUS*)NULL)) == NULL) { IIUGbmaBadMemoryAllocation(ERx("FEadfcb")); } dbinfo = (ADF_TAB_DBMSINFO *) dbinfoptr; dbinfo->tdbi_next = NULL; dbinfo->tdbi_prev = NULL; dbinfo->tdbi_length = dbinfo_size; dbinfo->tdbi_type = ADTDBI_TYPE; dbinfo->tdbi_s_reserved = -1; dbinfo->tdbi_l_reserved = (PTR)-1; dbinfo->tdbi_owner = (PTR)-1; dbinfo->tdbi_ascii_id = ADTDBI_ASCII_ID; dbinfo->tdbi_numreqs = 1; /* ** Now define request. */ dbinfo->tdbi_reqs[0].dbi_func = IIUGnfNowFunc; dbinfo->tdbi_reqs[0].dbi_num_inputs = 0; dbinfo->tdbi_reqs[0].dbi_lenspec.adi_lncompute = ADI_FIXED; STcopy("_BINTIM", dbinfo->tdbi_reqs[0].dbi_reqname); dbinfo->tdbi_reqs[0].dbi_reqcode = 1; dbinfo->tdbi_reqs[0].dbi_lenspec.adi_fixedsize = 4; dbinfo->tdbi_reqs[0].dbi_dtr = DB_INT_TYPE; /* ** set timezone in ADF cb - Any errors must be reported ** after adg_init() called. */ if ( (tmtz_status = TMtz_init(&cb.adf_tzcb)) == OK) { tmtz_status = TMtz_year_cutoff(&cb.adf_year_cutoff); } /* Always use INGRESDATE by default, and check ** 'ii.<node>.config.date_alias' (kibro01) b118702 */ cb.adf_date_type_alias = AD_DATE_TYPE_ALIAS_INGRES; STprintf(date_type_alias,ERx("ii.%s.config.date_alias"),PMhost()); date_status = PMget(date_type_alias, &cp); if (date_status == OK && cp != NULL && STlength(cp)) { if (STbcompare(cp, 0, ERx("ansidate"), 0, 1) == 0) cb.adf_date_type_alias = AD_DATE_TYPE_ALIAS_ANSI; else if (STbcompare(cp, 0, ERx("ingresdate"), 0, 1) == 0) cb.adf_date_type_alias = AD_DATE_TYPE_ALIAS_INGRES; else cb.adf_date_type_alias = AD_DATE_TYPE_ALIAS_NONE; } /* set timezone table to NULL in ADF cb, adg_init() will fill it */ /* cb.adf_tz_table = NULL; - not needed, done in declaration above */ /* Start up ADF */ rval = adg_startup(srv_cb_ptr, srv_size, dbinfo, 0); if (DB_FAILURE_MACRO(rval)) { /* ** Before bailing out, try to be helpful. Since the environment ** is likely not set up correctly, write hard coded messages ** since error message fetch will likely fail in this situation. */ char *tempchar; i4 dummy; LOCATION temploc; NMgtAt("II_SYSTEM", &tempchar); if (tempchar && *tempchar) { LOfroms(PATH, tempchar, &temploc); if (LOexist(&temploc)) { tempchar = ERx("FEadfcb: II_SYSTEM DOES NOT EXIST\n"); SIwrite(STlength(tempchar), tempchar, &dummy, stderr); } else { NMloc(ADMIN, FILENAME, ERx("config.dat"), &temploc); if (LOexist(&temploc)) { tempchar = ERx("FEadfcb: II_SYSTEM IS NOT SET CORRECTLY\n"); SIwrite(STlength(tempchar), tempchar, &dummy, stderr); } } } else { tempchar = ERx("FEadfcb: II_SYSTEM IS NOT SET\n"); SIwrite(STlength(tempchar), tempchar, &dummy, stderr); } EXsignal(EXFEBUG, 1, ERx("FEadfcb(start)")); } /* put the pointer to ADF's server control block in the ADF_CB */ cb.adf_srv_cb = srv_cb_ptr; /* set up the error message buffer */ cb.adf_errcb.ad_ebuflen = DB_ERR_SIZE; cb.adf_errcb.ad_errmsgp = ebuffer; /* initialize the ADF_CB */ rval = adg_init(&cb); if (DB_FAILURE_MACRO(rval)) { EXsignal(EXFEBUG, 1, ERx("FEadfcb(init)")); } /* find out which natural language we should speak */ cb.adf_slang = iiuglcd_langcode(); /* Always QUEL; for SQL explictly change this with 'IIAFdsDmlSet()'. */ cb.adf_qlang = DB_QUEL; /* lets get the multinational info */ /* ** Defaults for all of these are initially set statically, above. */ NMgtAt(ERx("II_DATE_FORMAT"), &cp); if ( cp != NULL && *cp != EOS ) { FEapply_date_format(&cb,cp); } NMgtAt(ERx("II_MONEY_FORMAT"), &cp); if ( cp != NULL && *cp != EOS ) { FEapply_money_format(&cb,cp); } NMgtAt(ERx("II_MONEY_PREC"), &cp); if ( cp != NULL && *cp != EOS ) { FEapply_money_prec(&cb,cp); } NMgtAt(ERx("II_DECIMAL"), &cp); if ( cp != NULL && *cp != EOS ) { FEapply_decimal(&cb,cp); } NMgtAt(ERx("II_UNICODE_SUBS"), &cp); if ( !cp ) { cb.adf_unisub_status = AD_UNISUB_OFF; } else { /* As with SET unicode_substitution take the first char */ cb.adf_unisub_status = AD_UNISUB_ON; *cb.adf_unisub_char = cp[0]; } NMgtAt(ERx("II_NULL_STRING"), &cp); if ( cp != NULL && *cp != EOS ) { FEapply_null(&cb,cp); } /* If there was a Timezone error other than the expected ingbuild ** error TM_PMFILE_OPNERR, then lets report it now. */ if (tmtz_status && (tmtz_status != TM_PMFILE_OPNERR)) { LOCATION loc_root; STATUS status = OK; status = NMloc(FILES, PATH, ERx("zoneinfo"), &loc_root); #if defined(conf_BUILD_ARCH_32_64) && defined(BUILD_ARCH64) status = LOfaddpath(&loc_root, ERx("lp64"), &loc_root); #endif #if defined(conf_BUILD_ARCH_64_32) && defined(BUILD_ARCH32) { /* ** Reverse hybrid support must be available in ALL ** 32bit binaries */ char *rhbsup; NMgtAt("II_LP32_ENABLED", &rhbsup); if ( (rhbsup && *rhbsup) && ( !(STbcompare(rhbsup, 0, "ON", 0, TRUE)) || !(STbcompare(rhbsup, 0, "TRUE", 0, TRUE)))) status = LOfaddpath(&loc_root, "lp32", &loc_root); } #endif /* ! LP64 */ if ( status == OK ) { status = LOexist(&loc_root); } if ( status == OK ) { IIUGerr(tmtz_status, 0, 0); /* As this may disappear from the screen quickly, ** let's pause to allow the users to reflect on the ** fact that the timezone info is (probably) wrong. */ if (!IIugefa_err_function) PCsleep(5000); } } /* Initialize unicode collation for UTF8 installations */ if (CMischarset_utf8()) { if (status = aduucolinit(col, MEreqmem, &ucode_ctbl, &ucode_cvtbl, &sys_err)) { EXsignal(EXFEBUG, 1, ERx("FEadfcb(alloc)")); } cb.adf_ucollation = (PTR) ucode_ctbl; /* Set unicode normalization to NFC just in case ** Front end will need it. */ if ((status = adg_setnfc(&cb)) != E_DB_OK) EXsignal(EXFEBUG, 1, ERx("FEadfcb(alloc)")); } /* lets not do this again! */ } return &cb; }
/* ** Name: main ** ** Description: ** Program entry point handles processing of command line arguments. ** ** Inputs: ** argc Count of number of parameters ** argv List of parameters. ** ** Outputs: ** None. ** ** Returns: ** OK Completed successfully ** !OK Failed. ** ** History: ** 21-Feb-2001 (fanra01) ** Created. */ int main(int argc, II_CHAR** argv) { ICE_STATUS status = OK; II_INT4 i; II_INT4 opt = 1; II_CHAR* option; II_CHAR* value; if (argc == 1) { IIUGerr( E_WU001A_REGDOCS_USAGE, UG_ERR_ERROR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); return(1); } progparms.name = argv[0]; /* setup for use in messages */ for(i=1; (status == OK) && (i < argc); i+=1) { if (opt) { if (*argv[i] == '-') { option = argv[i]; option += 1; value = option; value += 1; if (*value == 0) { i+=1; if (i < argc) { value = argv[i]; } } else { while((*value==' ') || (*value=='\t')) { value += 1; } } switch(*option) { case 'n': progparms.node = value; break; case 'o': progparms.owner = value; break; case 'u': progparms.unit = value; break; case 'l': progparms.loc = value; break; case 'i': progparms.inpfile = value; break; case 'x': progparms.xmlfile = value; break; case 't': for( ;*value; value+=1) { switch(*value) { case 'p': progparms.type = IA_PAGE; break; case 'f': progparms.type = IA_FACET; break; default: SIprintf("Ignored: Unknown type %c\n", *value); break; } } break; case 'f': for( ;*value; value+=1) { switch(*value) { case 'e': progparms.flags |= IA_EXTERNAL; progparms.flags &= ~(IA_PRE_CACHE | IA_FIX_CACHE | IA_SESS_CACHE); break; case 'r': progparms.flags &= ~IA_EXTERNAL; break; case 'g': progparms.flags |= IA_PUBLIC; break; case 'p': if ((progparms.flags & IA_EXTERNAL) == 0) { progparms.flags |= IA_PRE_CACHE; } break; case 'f': if ((progparms.flags & IA_EXTERNAL) == 0) { progparms.flags |= IA_FIX_CACHE; } break; case 's': if ((progparms.flags & IA_EXTERNAL) == 0) { progparms.flags |= IA_SESS_CACHE; } break; default: SIprintf("Ignored: Unknown flags %c\n", *value); break; } } break; default: SIprintf("Ignored unknown option -%c\n", *option); break; } } else { opt = 0; break; } } } /* ** if there is a difference between the counter and the end there must ** be a list of filenames. */ if (i < argc) { /* ** Setup a pointer to the list starting with the first filename. ** Save the number of filenames in the list. */ progparms.args = &argv[i]; progparms.nargs = argc - i; } dumpparms( &progparms ); status = regdocs( &progparms ); return(status); }
static i4 do_readln(FILE *fp,char *buf_ptr,i2 maxchar) { char *ptr; /* Working pointer into line buffer */ i4 count; /* Number of chars read */ STATUS status; ptr = buf_ptr; while (maxchar > 0) { status = SIread(fp,sizeof(char),&count,ptr); CMbytedec(maxchar,ptr); if ((CMdbl1st(ptr)) && (maxchar > 0)) { status = SIread(fp,sizeof(char),&count,(ptr + 1)); CMbytedec(maxchar,ptr); } switch(status) { case(ENDFILE): *ptr = EOS; count = STlength(buf_ptr); if (count > 0) { /* ** We hit EOF on a file that ended abruptly ** without a final end-of-line character. ** Return the final line's count this time - ** we'll return EOF on the next call. */ return(count); } return(-1); break; case(OK): if ((*ptr == CR) || (*ptr == LF) || (*ptr == FF)) { /* ** Do NOT include the end-of-line character! */ *ptr = EOS; return(STlength(buf_ptr)); } CMnext(ptr); break; default: /* ** According to the documentation, we shouldn't ** be able to get here. */ IIUGerr(E_DE000E_Dobj_read_fail,UG_ERR_ERROR,0); return(-1); } } /* ** If we wind up here, then ** we've exceeded maxchars! */ *ptr = EOS; return(STlength(buf_ptr)); }
VOID r_p_let() { i4 tok_type; DB_DATA_VALUE exp_type; i4 state = WANT_VAR; char *name; ITEM item; DB_DATA_VALUE *dbdv; LET *let; i4 status; DB_DATA_VALUE *con; while ((tok_type = r_g_eskip()) != TK_ENDSTRING) { switch(state) { case WANT_VAR: if ((tok_type == TK_ALPHA) || ((tok_type == TK_QUOTE) && (St_xns_given))) { name = r_g_ident(FALSE); _VOID_ IIUGdlm_ChkdlmBEobject(name,name,FALSE); status = r_p_tparam(name, FALSE, &item, &exp_type); } if (((tok_type != TK_ALPHA) && (tok_type != TK_QUOTE)) || ((tok_type == TK_QUOTE) && (!St_xns_given)) || (status == NO_EXP)) { r_error(0x3C, NONFATAL, Cact_tname, Cact_attribute, Cact_command, Cact_rtext, NULL); return; } dbdv = &(item.item_val.i_v_par->par_value); state = WANT_COLON; break; case WANT_COLON: if (tok_type == TK_COLON) { Tokchar++; state = WANT_EQUAL; break; } /* fall through */ case WANT_EQUAL: if (tok_type != TK_EQUALS) { r_error(0x3C, NONFATAL, Cact_tname, Cact_attribute, Cact_command, Cact_rtext, NULL); return; } Tokchar++; state = WANT_EXPR; break; case WANT_EXPR: status = r_g_expr(&item, &exp_type); switch (status) { case NO_EXP: r_error(0x3E, NONFATAL, Cact_tname, Cact_attribute, Tokchar, Cact_command, Cact_rtext, NULL); return; case BAD_EXP: return; case GOOD_EXP: if (exp_type.db_datatype == DB_BOO_TYPE) { IIUGerr(E_RW003D_r_p_let_No_boolean,UG_ERR_FATAL,0); } break; case NULL_EXP: if (!AFE_NULLABLE_MACRO(dbdv->db_datatype)) { r_error(0x41, NONFATAL, Cact_tname, Cact_attribute, Cact_command, Cact_rtext, NULL); return; } item.item_type = I_CON; con = (DB_DATA_VALUE *) MEreqmem(0,sizeof(DB_DATA_VALUE),TRUE, (STATUS *) NULL); item.item_val.i_v_con = con; con->db_datatype = dbdv->db_datatype; con->db_length = dbdv->db_length; con->db_prec = dbdv->db_prec; con->db_data = (PTR) MEreqmem(0,con->db_length,TRUE, (STATUS *) NULL); adc_getempty(Adf_scb, con); break; } Cact_tcmd->tcmd_code = P_LET; let = (LET *) MEreqmem(0,sizeof(LET),TRUE,(STATUS *) NULL); Cact_tcmd->tcmd_val.t_v_let = let; let->let_left = dbdv; MEcopy((PTR)&item, (u_i2)sizeof(ITEM), (PTR)&(let->let_right)); return; } } }
void rf_att_dflt(i4 NumRels, char *RelList[]) { FE_ATT_QBLK qblk; FE_ATT_INFO attinfo; FE_REL_INFO relinfo; register ATTRIB id; i4 i = 0; bool RepeatedField; char ColName [FE_MAXNAME + 1]; i4 ins = 0; FE_RSLV_NAME *rfa_ferslv[MQ_MAXRELS]; RFCOLDESC *coldesc; ATT *attptr; char *cname; ATTRIB did; i4 real_cols; char dsply_name[(FE_UNRML_MAXNAME + 1)]; /* ** If the user went through the choose columns path, we will ** use that information to create the structures since we ** alredy have all the needed information. */ if (IIRFcccount != 0) { En_n_attribs = IIRFcccount; real_cols = IIRFcccount - IIRFcdcount; /* Allocate memory for the ATT array. */ if ((Ptr_att_top = (ATT *)FEreqmem((u_i4)Rst4_tag, (u_i4)(IIRFcccount*(sizeof(ATT))), TRUE, (STATUS *)NULL)) == NULL) { IIUGbmaBadMemoryAllocation(ERx("rf_att_dflt - Ptr_att_top")); } /* ** Step through the set of column names. Deleted ones are ** placed at the end of the array. We need to keep them ** around so that the user can add them back in the layout ** frame. */ for (i = 0, id = 0, did = real_cols, coldesc = IIRFcollist; i < IIRFcccount; i++, coldesc++) { if (coldesc->deleted) { attptr = &(Ptr_att_top[did++]); attptr->pre_deleted = TRUE; } else { attptr = &(Ptr_att_top[id++]); } cname = coldesc->name; attptr->att_name = FEtsalloc(Rst4_tag, cname); /* check if attribute name is a keyword */ if (!St_silent && (r_gt_pcode(cname) != PC_ERROR || r_gt_wcode(cname) != A_ERROR || r_gt_vcode(cname) != VC_NONE || r_gt_cagg(cname) || STcompare(cname, NAM_REPORT) == 0 || STcompare(cname, NAM_PAGE) == 0 || STcompare(cname, NAM_DETAIL) == 0)) { IIUGmsg(ERget(S_RF0047_Column_name_keyword), (bool) FALSE, 1, cname); } /* set up the data type field */ attptr->att_value.db_datatype = coldesc->datatype; attptr->att_prev_val.db_datatype = coldesc->datatype; attptr->att_value.db_length = coldesc->length; attptr->att_prev_val.db_length = coldesc->length; attptr->att_value.db_prec = coldesc->prec; attptr->att_prev_val.db_prec = coldesc->prec; /* ** Do not allocate value buffers for un-supported datatypes. ** We already let the user know that they're being ignored ** when we passed through ChooseColumns, so don't do it again! */ if (!IIAFfedatatype(&attptr->att_value)) { attptr->att_value.db_data = (PTR)NULL; attptr->att_prev_val.db_data = (PTR)NULL; } else { if ((attptr->att_value.db_data = (PTR)FEreqmem((u_i4)Rst4_tag, (u_i4)(attptr->att_value.db_length), TRUE, (STATUS *)NULL)) == NULL) { IIUGbmaBadMemoryAllocation(ERx("rf_att_dflt - db_data")); } if ((attptr->att_prev_val.db_data = (PTR)FEreqmem((u_i4)Rst4_tag, (u_i4)(attptr->att_prev_val.db_length), TRUE, (STATUS *)NULL)) == NULL) { IIUGbmaBadMemoryAllocation(ERx("rf_att_dflt - prev db_data")); } } /* flag to indicate when done */ attptr->att_position = 0; attptr->att_lac = NULL; } return; } /* ** determine number of attributes in base table: */ for (i = 0; i < NumRels; i ++) { /* ** Decompose any owner.tablename, validate the components, ** and normalize them for later use. */ if ((rfa_ferslv[i] = (FE_RSLV_NAME *)MEreqmem((u_i4)0, (u_i4)sizeof(FE_RSLV_NAME),TRUE, (STATUS *)NULL)) == (FE_RSLV_NAME *)NULL) { IIUGbmaBadMemoryAllocation(ERx("rf_att_dflt - rfa_ferslv")); } if ((rfa_ferslv[i]->name_dest = (char *)MEreqmem((u_i4)0, (u_i4)(FE_UNRML_MAXNAME+1),TRUE,(STATUS *)NULL)) == NULL) { IIUGbmaBadMemoryAllocation(ERx("rf_att_dflt - name_dest")); } if ((rfa_ferslv[i]->owner_dest = (char *)MEreqmem((u_i4)0, (u_i4)(FE_UNRML_MAXNAME+1),TRUE,(STATUS *)NULL)) == NULL) { IIUGbmaBadMemoryAllocation(ERx("rf_att_dflt - owner_dest")); } rfa_ferslv[i]->name = RelList[i]; rfa_ferslv[i]->is_nrml = FALSE; FE_decompose(rfa_ferslv[i]); if ((rfa_ferslv[i]->owner_spec) && (((STcompare(IIUIcsl_CommonSQLLevel(),UI_LEVEL_65) < 0) && (IIUIdcd_dist() == FALSE) || IIUIdcd_dist() == TRUE && (STcompare(IIUIcsl_CommonSQLLevel(), UI_LEVEL_61) < 0)))) { continue; } if ((IIUGdlm_ChkdlmBEobject(rfa_ferslv[i]->name_dest, rfa_ferslv[i]->name_dest, rfa_ferslv[i]->is_nrml) == UI_BOGUS_ID) || ((rfa_ferslv[i]->owner_spec) && ((IIUGdlm_ChkdlmBEobject(rfa_ferslv[i]->owner_dest, rfa_ferslv[i]->owner_dest, rfa_ferslv[i]->is_nrml) == UI_BOGUS_ID) && STcompare(rfa_ferslv[i]->owner_dest, UI_FE_CAT_ID_65)))) { continue; } if (FE_resolve(rfa_ferslv[i],rfa_ferslv[i]->name_dest, rfa_ferslv[i]->owner_dest)) { En_n_attribs += FEnumatts(rfa_ferslv[i]->name_dest, rfa_ferslv[i]->owner_dest); } } /* ** Allocate array of ATT structures: */ if ((Ptr_att_top = (ATT *)FEreqmem((u_i4)Rst4_tag, (u_i4)(En_n_attribs*(sizeof(ATT))), TRUE, (STATUS *)NULL)) == NULL) { IIUGbmaBadMemoryAllocation(ERx("rf_att_dflt - Ptr_att_top")); } /* ** For each relation fill out the ATT structures: */ id = 0; if (En_SrcTyp == JDRepSrc) _VOID_ r_JDMaintTabList(JD_TAB_INIT_INS_CNT, NULL, NULL, NULL, NULL); for (i = 0; i < NumRels; i ++) { /* ** open access to base table */ /* ** Fill out relinfo with table information, including table owner. */ FErel_ffetch(rfa_ferslv[i]->name_dest,rfa_ferslv[i]->owner_dest, &relinfo); MEfree((PTR)rfa_ferslv[i]->name_dest); MEfree((PTR)rfa_ferslv[i]->owner_dest); MEfree((PTR)rfa_ferslv[i]); FEatt_fopen(&qblk, &relinfo); if (En_SrcTyp == JDRepSrc) _VOID_ r_JDMaintTabList(JD_TAB_TAB_ADV_INS_CNT, NULL, relinfo.name, relinfo.owner, &ins); /* ** For each attribute in table, fill ATT structure ** (make sure no DB access will take place in this loop!) */ while (FEatt_fetch(&qblk, &attinfo) == OK) { register ATT *r_att; register ATTRIB chk_id; register char *attname; attname = attinfo.column_name; /* ** Check for duplicate column names. If found one, and ** the source of data is not a JoinDef we have a problem, ** Bug #5952: */ RepeatedField = FALSE; chk_id = id - 1; while ((--chk_id >= 0) && (!RepeatedField)) { register ATT *chk_p = &(Ptr_att_top[chk_id]); if (STcompare(chk_p->att_name, attname) == 0) RepeatedField = TRUE; } if ((RepeatedField) && (En_SrcTyp == TabRepSrc)) { r_error(0x2C8, FATAL, attname, NULL); } /* ** Make sure that if the source of data is a JoinDef ** the attribute is being used, and if it's being used ** in more than one table get the constructed name for ** it. Be sure and include the owner in the table look-up! */ if (En_SrcTyp == JDRepSrc) { i4 cnt = 0; /* ** If we can't find the field then it's not being used so ** skip it: */ if (!r_JDMaintAttrList(JD_ATT_GET_FIELD_CNT, r_JDTabNameToRv(relinfo.name, relinfo.owner, ins), attname, &cnt)) continue; if (cnt > 1) { _VOID_ r_JDMaintAttrList(JD_ATT_GET_ATTR_NAME, r_JDTabNameToRv(relinfo.name, relinfo.owner, ins), attname, &ColName [0]); attname = ColName; } } r_att = &(Ptr_att_top[id++]); r_att->att_name = FEtsalloc(Rst4_tag, attname); /* check if attribute name is a keyword */ if (!St_silent && (r_gt_pcode(attname) != PC_ERROR || r_gt_wcode(attname) != A_ERROR || r_gt_vcode(attname) != VC_NONE || r_gt_cagg(attname) || STcompare(attname, NAM_REPORT) == 0 || STcompare(attname, NAM_PAGE) == 0 || STcompare(attname, NAM_DETAIL) == 0)) { IIUGmsg(ERget(S_RF0047_Column_name_keyword), (bool) FALSE, 1, attname); } /* set up the data type field */ r_att->att_value.db_datatype = attinfo.adf_type; r_att->att_prev_val.db_datatype = attinfo.adf_type; r_att->att_value.db_length = attinfo.intern_length; r_att->att_prev_val.db_length = attinfo.intern_length; r_att->att_value.db_prec = attinfo.intern_prec; r_att->att_prev_val.db_prec = attinfo.intern_prec; /* ** Do not allocate value buffers for un-supported datatypes. ** Let the user know that they're being ignored. */ if (!IIAFfedatatype(&r_att->att_value)) { _VOID_ IIUGxri_id(&attinfo.column_name[0], &dsply_name[0]); IIUGerr(E_RW1414_ignored_attrib, UG_ERR_ERROR,1,&dsply_name[0]); r_att->att_value.db_data = (PTR)NULL; r_att->att_prev_val.db_data = (PTR)NULL; } else { if ((r_att->att_value.db_data = (PTR)FEreqmem((u_i4)Rst4_tag, (u_i4)(r_att->att_value.db_length), TRUE, (STATUS *)NULL)) == NULL) { IIUGbmaBadMemoryAllocation(ERx("rf_att_dflt - db_data")); } if ((r_att->att_prev_val.db_data = (PTR)FEreqmem((u_i4)Rst4_tag, (u_i4)(r_att->att_prev_val.db_length), TRUE, (STATUS *)NULL)) == NULL) { IIUGbmaBadMemoryAllocation(ERx("rf_att_dflt - prev db_data")); } } r_att->att_position = 0; /* flag to indicate when done */ r_att->att_lac = NULL; } FEatt_close(&qblk); } /* for */ /* ** Just in case if we have skipped any attributes, ** we're leaking memory though: Note that unsupported ** datatypes will not be reflected as skipped as far as the ** id count is concerned! */ En_n_attribs = id; return; }
/* ** Name: regdocs ** ** Description: ** Function drives the registration loop according to whether the ** parameters are from an input file or the command line. ** ** Inputs: ** prog Program level global parameters. ** ** Outputs: ** None. ** ** Returns: ** OK Completed successfully ** E_IC_INVALID_UNIT_NAME Specified unit does not exist. ** E_IC_INVALID_LOC_NAME Specified location does not exist. ** ** History: ** 21-Feb-2001 (fanra01) ** Created. ** 04-May-2001 (fanra01) ** Add NULL cookie session parameter to function call. NULL denotes ** exclusive session. */ ICE_STATUS regdocs( PARAMS* prog ) { ICE_STATUS status = OK; LOCATION inloc; II_CHAR pathstr[MAX_LOC + 1]; REGPARAMS regparams; II_CHAR user[80] = ""; II_CHAR passwd[80]= ""; HICECTX icectx = NULL; II_CHAR* bu; II_CHAR* loc; /* ** Get user an password information in preparation to connect to the ** ice server */ IIUGprompt("ICE Admin User?", 1, 0, user, sizeof(user), 0); IIUGprompt("Password?", 1, 1, passwd, sizeof(passwd), 0); /* ** if the connection to ice server is successful get business unit id ** and location id from their names. */ if ((status = ic_initialize( prog->node, user, passwd, NULL, &icectx )) == OK) { if ((prog->unit != NULL) && ((status = ic_getitem( icectx, ICE_UNIT, "unit_name", prog->unit, "unit_id", &bu )) == OK)) { if (bu != NULL) { ASCTOI( bu, &prog->buid ); } } else { if (status == E_IC_OUT_OF_DATA) { status = E_IC_INVALID_UNIT_NAME; } } if ((status == OK) && (prog->loc != NULL)) { status = ic_getitem( icectx, ICE_LOCATION, "loc_name", prog->loc, "loc_id", &loc ); if((status == OK) && (loc != NULL)) { ASCTOI( loc, &prog->locid ); } else { if (status == E_IC_OUT_OF_DATA) { status = E_IC_INVALID_LOC_NAME; } } } if (prog->inpfile) { /* ** Options contain an input file. Open file and scan. ** ** -o owner -u unit -l location -t doctype -f flags filename.ext */ FILE* inpfile = NULL; if (*prog->inpfile == '-') { inpfile = stdin; } else { STcopy( prog->inpfile, pathstr ); if ((status = LOfroms( (PATH&FILENAME), pathstr, &inloc )) == OK) { status = SIopen( &inloc, "r", &inpfile ); } } if (inpfile != NULL) { while ((status == OK) && (readinpfile( inpfile, ®params ) == OK)) { status = registerdoc( icectx, prog, ®params ); if(regparams.owner) { MEMFREE( regparams.owner ); } if(regparams.unit) { MEMFREE( regparams.unit ); } if(regparams.location) { MEMFREE( regparams.location ); } if(regparams.filename) { MEMFREE( regparams.filename ); } } if (inpfile != stdin) { SIclose( inpfile ); } } } if (prog->xmlfile) { /* ** Options contain an XML input file. Open and scan. ** ** <unit name="unit_name" owner="owner_name"> ** <location name="location_name"> ** <page name="filename" ext="ext" type="external|global|repository"/> ** <facet name="filename" ext="ext" type="external|global|repository"/> ** </location> ** </unit> */ FILE* xmlfile; STcopy( prog->xmlfile, pathstr ); if ((status = LOfroms( (PATH&FILENAME), pathstr, &inloc )) == OK) { if ((status = SIopen( &inloc, "r", &xmlfile )) == OK) { /* ** No action until XML parser included. ** Just close the file for now. */ SIclose( xmlfile ); } } } if(prog->args != NULL) { /* ** Command line arguments contains a list of filenames. */ II_INT4 i; MEMFILL( sizeof(REGPARAMS), 0, ®params ); for (i=0; (status == OK) && (i < prog->nargs); i+=1) { regparams.filename = prog->args[i]; status = registerdoc( icectx, prog, ®params ); } } /* ** Disconnect from ice server. */ status = ic_close( icectx ); icectx = NULL; ic_terminate(); } else { IIUGerr( status, UG_ERR_ERROR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); } return(status); }
STATUS xfsetdirs(char *dir, char *frompath, char *intopath) { auto i2 dirflag; auto char *s; char *locbuf; STATUS status; locbuf = XF_REQMEM(MAX_LOC + 1, FALSE); if (dir == NULL || *dir == EOS) { /* Default to current directory. */ status = LOgt(locbuf, &Xf_dir); if(status != OK) { #ifdef UNIX status = LOfakepwd(locbuf, &Xf_dir); #endif if(status != OK) { IIUGerr(E_XF0061_Can_Not_Determine_Dir, UG_ERR_ERROR, 0); return(FAIL); } } dir = NULL; } else { STlcopy(dir, locbuf, MAX_LOC); if (LOfroms(PATH, locbuf, &Xf_dir) != OK) { IIUGerr(E_XF0006_Invalid_directory_pat, UG_ERR_ERROR, 1, dir); return (FAIL); } if (!LOisfull(&Xf_dir)) { auto LOCATION xloc; char xbuf[MAX_LOC + 1]; /* ** path spec. is a relative specification -- we must expand it ** to a full pathname. */ LOcopy(&Xf_dir, xbuf, &xloc); status = LOgt(locbuf, &Xf_dir); if(status != OK) { IIUGerr(E_XF0061_Can_Not_Determine_Dir, UG_ERR_ERROR, 0); return(FAIL); } LOaddpath(&Xf_dir, &xloc, &Xf_dir); } /* LOisdir and LOexist are archaic and should be replaced by LOinfo. */ LOisdir(&Xf_dir, &dirflag); if (dirflag != ISDIR || LOexist(&Xf_dir) != OK) { IIUGerr(E_XF0006_Invalid_directory_pat, UG_ERR_ERROR, 1, dir); return (FAIL); } } LOtos(&Xf_dir, &s); /* the COPY FROM path doesn't have to exist. */ if (frompath != NULL && *frompath != EOS) Xf_from_path = saveloc(frompath); /* the COPY INTO path doesn't have to exist. */ if (intopath != NULL && *intopath != EOS) Xf_into_path = saveloc(intopath); IIUGmsg(ERget(S_XF0064_Unload_Directory_is), FALSE, 1, (PTR)(Xf_into_path == NULL ? s : Xf_into_path)); IIUGmsg(ERget(S_XF0065_Reload_Directory_is), FALSE, 1, (PTR)(Xf_from_path == NULL ? s : Xf_from_path)); return (OK); }
static VOID IILQgtfGcaTraceFile( II_LBQ_CB *IIlbqcb, i4 action ) { IILQ_TRACE *msgtrc = &IIglbcb->iigl_msgtrc; FILE *trace_file = (FILE *)msgtrc->ii_tr_file; char *title = ERx("off"); SYSTIME now; char nowbuf[100]; i4 nowend; /* ** Check to see that we actually need to open ** or close the trace file. */ if ( (action == IITRC_ON && trace_file) || (action == IITRC_OFF && ! trace_file) || (action == IITRC_SWITCH && ! trace_file) ) return; if ( action == IITRC_SWITCH ) title = ERx("switched"); if ( action == IITRC_ON ) { LOCATION trace_loc; STATUS stat; /* ** If trace file name not provided, use default. */ if ( ! msgtrc->ii_tr_fname ) msgtrc->ii_tr_fname = STalloc( GCTRACEFILE ); LOfroms(FILENAME, msgtrc->ii_tr_fname, &trace_loc ); # ifdef hp9_mpe if ( msgtrc->ii_tr_flags & II_TR_APPEND ) stat = SIfopen(&trace_loc, ERx("a"), SI_TXT, 252, &trace_file); else stat = SIfopen(&trace_loc, ERx("w"), SI_TXT, 252, &trace_file); # else if ( msgtrc->ii_tr_flags & II_TR_APPEND ) stat = SIopen(&trace_loc, ERx("a"), &trace_file); else stat = SIopen(&trace_loc, ERx("w"), &trace_file); # endif if (stat != OK) { /* Simplest error path; don't want IIlocerr functionality */ IIUGerr(E_LQ0007_PRINTQRY, 0, 1, msgtrc->ii_tr_fname); /* ** We can't call IILQgstGcaSetTrace() because ** of possible conflicts with the tracing ** semaphore, so just turn off tracing here. */ msgtrc->ii_tr_flags &= ~II_TR_FILE; if ( ! (msgtrc->ii_tr_flags & II_TR_HDLR) ) IIcgct1_set_trace( IIlbqcb->ii_lq_gca, 0, NULL, NULL ); return; } msgtrc->ii_tr_file = (PTR)trace_file; title = ERx("on "); } /* Get time stamp */ TMnow(&now); TMstr(&now, nowbuf); nowend = STlength( nowbuf ); if ( nowbuf[ nowend - 1 ] == '\n' ) nowbuf[ nowend - 1 ] = EOS; SIfprintf( trace_file, ERx("---- printgca = %s session %d (%s) ---\n\n"), title, IIlbqcb->ii_lq_sid, nowbuf ); SIflush( trace_file ); if ( action != IITRC_OFF ) msgtrc->ii_tr_sid = IIlbqcb->ii_lq_sid; else { SIclose( trace_file ); msgtrc->ii_tr_file = NULL; msgtrc->ii_tr_sid = 0; msgtrc->ii_tr_flags |= II_TR_APPEND; /* Don't overwrite if reopened */ } return; } /* IILQgtfGcaTraceFile */
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); }
int main(int argc, char *argv[]) { #define MAXBUF 4095 char buf[ MAXBUF+1 ]; int iarg, ibuf, ichr; bool debug = FALSE; CL_ERR_DESC err_code; char *p1 = NULL; char pid[MAXBUF]; char *database = ERx(""); char *user = ERx(""); char *xmlfile = ERx(""); char sql_fname[LO_NM_LEN + 1]; char *work_dir = NULL; char directory[MAX_LOC + 1]; char *tmp_dir = NULL; char tmp_buf[MAX_LOC + 1]; char subdir_buf[MAX_LOC + 1]; char sql_loc_buf[MAX_LOC + 1]; char *progname; LOCATION tmp_dir_loc; LOCATION tmp_subdir_loc; LOCATION tmp_buff_loc; LOCATION curr_loc; LOCATION sql_file_loc; char *password = ERx(""); char *groupid = ERx(""); ARGRET rarg; i4 pos; LOCATION xmlfile_loc; FILE *xmlfile_read; STATUS stat = FAIL; char dbuf[256]; char encode[32]; u_i4 tmppid; TM_STAMP tm_stamp; /* Tell EX this is an ingres tool. */ (void) EXsetclient(EX_INGRES_TOOL); /* Call IIUGinit to initialize character set attribute table */ if ( IIUGinit() != OK) PCexit(FAIL); progname = ERget(F_XM0006_IMPXML); FEcopyright(progname, ERx("2001")); /* ** Get arguments from command line */ /* required parameters */ if (FEutaopen(argc, argv, ERx("xmlimport")) != OK) PCexit(FAIL); /* database name is required */ if (FEutaget(ERx("database"), 0, FARG_PROMPT, &rarg, &pos) != OK) PCexit(FAIL); database = rarg.dat.name; if (FEutaget(ERx("xmlfile"), 0, FARG_PROMPT, &rarg, &pos) != OK) PCexit(FAIL); xmlfile = rarg.dat.name; if (FEutaget(ERx("user"), 0, FARG_FAIL, &rarg, &pos) == OK) user = rarg.dat.name; if (FEutaget(ERx("password"), 0, FARG_FAIL, &rarg, &pos) == OK) { char *IIUIpassword(); if ((password = IIUIpassword(ERx("-P"))) == NULL) { FEutaerr(BADARG, 1, ERx("")); PCexit(FAIL); } } if (FEutaget(ERx("groupid"), 0, FARG_FAIL, &rarg, &pos) == OK) groupid = rarg.dat.name; if (FEutaget(ERx("debug"), 0, FARG_FAIL, &rarg, &pos) == OK) debug = TRUE; ibuf = STlength(buf); /* b121678: pid is no longer based on process id, but it's ** a random number instead. */ PCpid(&tmppid); TMget_stamp(&tm_stamp); MHsrand2(tmppid * tm_stamp.tms_usec); STprintf(pid, "%x", MHrand2()); #ifdef xDEBUG SIprintf(" the pid is: %s \n", pid); #endif /* create the sql file */ /* Avoid a name like "foo.xml.sql" on VMS, use pid.sql instead */ STcopy(pid, sql_fname); STcat(sql_fname, ".sql"); /* ** create in the temp location a directory ** with the name pid. set this directory ** as the working directory for impxml */ NMloc (TEMP, PATH, NULL, &tmp_dir_loc); /* make a location for TMP loc */ /* print location name */ LOcopy (&tmp_dir_loc, tmp_buf, &tmp_buff_loc); LOtos (&tmp_buff_loc, &tmp_dir); #ifdef xDEBUG SIprintf ("temploc: %s \n", tmp_dir); #endif /* make a subdir location with filename, pid */ STcopy (pid, subdir_buf); /* Initialize result loc so that everyone is happy */ LOcopy (&tmp_dir_loc, sql_loc_buf, &sql_file_loc); /* Generate location for temp subdirectory */ if (LOfaddpath (&tmp_dir_loc, subdir_buf, &sql_file_loc) != OK) { IIUGerr(E_XM0007_Locname_Failed, UG_ERR_FATAL, 2, tmp_dir, subdir_buf); /* NOTREACHED */ } /* print the location name */ LOcopy (&sql_file_loc, tmp_buf, &tmp_buff_loc); LOtos (&tmp_buff_loc, &work_dir); #ifdef xDEBUG SIprintf ("work dir loc: %s \n", work_dir); #endif /* create the subdir */ if (LOcreate (&sql_file_loc) != OK) { IIUGerr(E_XM0008_Create_Temp_Dir, UG_ERR_ERROR, 1, work_dir); PCexit(FAIL); } STcopy(work_dir, directory); #ifdef xDEBUG SIprintf ("sql file name: %s \n", sql_fname); SIprintf ("xml file name: %s \n", xmlfile); #endif /* Execute the command impxml */ STprintf (buf, ERx( "impxml -d=\"%s\" -o=\"%s\" " ), directory, sql_fname); /* encoding? */ if ( (LOfroms(PATH & FILENAME, xmlfile, &xmlfile_loc) != OK) || (SIopen(&xmlfile_loc, "r", &xmlfile_read) != OK) || (xmlfile_read == NULL) ) { IIUGerr(E_XM0009_Cannot_Open_File, UG_ERR_ERROR, 1, xmlfile); PCexit(FAIL); } /* scan XML declaration for encoding, if any */ if (stat = SIgetrec(dbuf, sizeof(dbuf) - 1, xmlfile_read) == OK) { char *d = dbuf; i4 i = 0; for (d = dbuf; d != (dbuf + sizeof(dbuf)); d++) { if (MEcmp(d, ERx("encoding="), sizeof(ERx("encoding=")) - 1) == 0) { d += sizeof(ERx("encoding=")); while (MEcmp (d, "\'", sizeof(char)) && MEcmp(d, "\"", sizeof(char))) MEcopy(d++, sizeof(char), &encode[i++]); encode[i++] = MIN_CHAR; encode[i] = EOS; STcat(buf, ERx("-x=")); STcat(buf, encode); break; } } } else if (stat != ENDFILE) { /* unable to read file, report error */ IIUGerr(E_XM000A_Cannot_Read_File, UG_ERR_ERROR, 1, xmlfile); PCexit(FAIL); } stat = SIclose(xmlfile_read); STcat(buf, xmlfile); #ifdef xDEBUG SIprintf ( " query send: %s \n", buf); #endif /* Execute the command. */ if( PCcmdline((LOCATION *) NULL, buf, PC_WAIT, (LOCATION *)NULL, &err_code) != OK ) { if (!debug) LOdelete(&sql_file_loc); PCexit(FAIL); } /* ** we should run the sql script ** sql dbname < new_filename */ /* save the current location */ LOcopy(&sql_file_loc, tmp_buf, &curr_loc); /* make a full location path to the location first */ LOfroms(FILENAME, sql_fname, &tmp_buff_loc); LOstfile(&tmp_buff_loc, &curr_loc); LOcopy (&curr_loc, tmp_buf, &tmp_buff_loc); LOtos (&tmp_buff_loc, &tmp_dir); #ifdef xDEBUG SIprintf ("sql file is: %s \n", tmp_dir); #endif /* No space between < and input file for VMS */ STprintf(buf, ERx( "sql -s %s %s %s %s <%s" ), database, user, password, groupid, tmp_dir); #ifdef xDEBUG SIprintf (" query send: %s \n", buf); #endif /* ** Execute the command. */ if( PCcmdline((LOCATION *) NULL, buf, PC_WAIT, (LOCATION *)NULL, &err_code) != OK ) { if (!debug) LOdelete(&sql_file_loc); PCexit(FAIL); } /* ** Delete the location */ if (!debug) LOdelete(&sql_file_loc); PCexit(OK); }
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; }
STATUS ip_batch(i4 argc, char *argv[]) { i4 argvx; PKGBLK *pkg; uchar opid; uchar option = opNONE; LOCATION outloc; char line[ MAX_MANIFEST_LINE + 1 ]; LISTELE *lp; /* no command line arguments except mkresponse ** or exresponse allowed for ingbuild in form mode */ if ((argc < 2) || ((argc ==2) && ((pmode == TRUE) || (mkresponse == TRUE) || (exresponse == TRUE))) || ((argc ==3) && (((mkresponse == TRUE) || (exresponse == TRUE)) && (respfilename != NULL)))) /* No command-line args? */ return OK; /* Fine, must be forms mode; return without setting flag. */ batchMode = TRUE; /* We're in command-line mode. */ batchOutf = stdout; /* For now, we'll direct output to the terminal. */ /* Top of loop through the non-positional arguments on the command line. */ for (argvx = 1; argvx < argc; argvx++) { if (argv[argvx][0] != '-') /* Not a switch? Time for positional arg. */ break; /* Get the option code for the current flag and deal with it... */ switch (opid = lookup(&argv[argvx][1])) { /* instruct ingbuild to skip set up */ case opNOSETUP: noSetup = TRUE; break; case opEXPRESS: eXpress = TRUE; break; case opPATCH: continue; /* -install=<list of features> */ case opINSTALL: if (option != opNONE || argval == NULL) USAGE; option = opid; featlist = argval; if( !STbcompare("ice", 3, featlist, STlength(featlist), TRUE) || !STbcompare("ice64", 5, featlist, STlength(featlist), TRUE) ) Install_Ice = TRUE; break; /* ** -version, -products, -all, -describe ** (All the options that don't require values.) */ case opVERSION: case opPACKAGES: case opDESCRIBE: case opALL: if (option == opNONE) { featlist = argval; option = opid; break; } case opIGNORE: ignoreChecksum = TRUE; break; case opEXRESPONSE: exresponse = TRUE; break; case opRESPFILE: break; /* -acceptlicense is still accepted for forward compatibility */ case opACCEPTLIC: #if LICENSE_PROMPT acceptLicense = TRUE; #endif break; /* Fall through */ default: USAGE; } } /* ** When we break from the flags loop, we must have a maximum of one ** remaining argument... */ if (argvx < (argc - 1)) /* Too many non-flags at the end of the line. */ USAGE; if (exresponse && (option == opNONE)) { char *def_file="ingrsp.rsp"; char *filename; FILE *respfile; if (respfilename != NULL) filename = respfilename; else filename = def_file; if (OK == ip_open_response (ERx(""), filename, &respfile, ERx( "r" )) ) { bool found = FALSE; char line[MAX_MANIFEST_LINE + 1]; char *pkg_set = ERx("_set=YES"); char *setp, *realloc; i4 pkglen; i4 buflen = MAX_MANIFEST_LINE + 1; i4 space = buflen; while (SIgetrec((char *)&line, MAX_MANIFEST_LINE, respfile) == OK ) { /* Check for _set=YES */ setp = STstrindex(line, pkg_set, 0, 1); if(setp != NULL) { if(found == FALSE) { featlist = ip_alloc_blk( buflen ); } *setp = NULLCHAR; pkglen = STlength(line); if(found == TRUE) { if(space < (pkglen + 1)) { buflen += MAX_MANIFEST_LINE; realloc = ip_alloc_blk( buflen ); STcopy(featlist, realloc); MEfree(featlist); featlist = realloc; } STcat(featlist, ","); space--; } else { found = TRUE; } STcat(featlist, line); space = space - pkglen; } } /* end read loop */ ip_close_response(respfile); if( found == TRUE) { /* Need to test this does not override any other options that ** may be valid */ option = opINSTALL; } } else { PCexit ( FAIL ); } } /* ** If we have no positionals, no distribution device was provided on ** the command line. That might or might not be ok... */ if (argvx == argc) { switch (option) { case opPATCH: case opVERSION: case opPACKAGES: case opDESCRIBE: break; /* ...yes. */ default: USAGE; /* ...no. */ } } else /* We got a positional, so copy it into the global field. */ { STcopy(argv[argvx], distribDev); if( !IPCLsetDevice( distribDev ) ) USAGE; } if (option == opNONE) /* No option? Default to "all". */ option = opALL; if ( option == opALL ); batch_opALL = TRUE; /* ** First processing pass. If the option doesn't involve doing actual ** installation, just do whatever needs to be done, and return. ** If it's an installation option, mark all requested packages ** as selected, and continue. */ switch (option) { case opPACKAGES: SIfprintf(batchOutf,ERget(S_ST0179_pkg_list_header)); for( lp = distPkgList.head; lp != NULL; lp = lp->cdr ) { pkg = (PKGBLK *) lp->car; if( ip_is_visible( pkg ) || ip_is_visiblepkg( pkg ) ) { SIfprintf( batchOutf, ERx("\t%-16s %-30s\n"), pkg->feature,pkg->name ); } } return OK; case opVERSION: if (instRelID == NULL) { IIUGerr(E_ST017B_not_present,0,1,SystemProductName); return FAIL; } if (featlist == NULL) { SIfprintf(batchOutf, ERx("%s\n"), instRelID); return OK; } if (!apply_list(proc_version)) return FAIL; return OK; case opINSTALL: SCAN_LIST(distPkgList, pkg) { pkg->selected = NOT_SELECTED; } if (!apply_list(proc_install)) return FAIL; break; case opDESCRIBE: _VOID_ apply_list(proc_describe); return OK; default: for( lp = distPkgList.head; lp != NULL; lp = lp->cdr ) { pkg = (PKGBLK *) lp->car; switch (option) { case opALL: if ( ip_is_visible(pkg) || ip_is_visiblepkg( pkg ) ) pkg->selected = SELECTED; break; } } } /* ** If we haven't left yet, that must mean we have an install-class ** option, i.e. one that's going to cause us to actually install ** something. First of all, let's make sure that the user has ** defined II_AUTH_STRING and has selected something to install... */ #ifndef INGRESII if( !authStringEnv ) { IIUGerr( E_ST0117_license_required, 0, 0 ); return( FAIL ); } #endif /* INGRESII */ SCAN_LIST(distPkgList, pkg) { if (pkg->selected == SELECTED) break; } if (pkg == NULL) /* Got all the way through the list? Nothing selected! */ USAGE; /* If Ingres is up, no go; otherwise, do the installation... */ switch (option) { case opALL: case opINSTALL: if (ip_sysstat() == IP_SYSUP) { IIUGerr(E_ST0178_installation_is_up, 0, 2, SystemProductName, installDir); return FAIL; } #if LICENSE_PROMPT if( !acceptLicense ) license_prompt(); #endif ip_install(NULL); break; } return OK; }
rFcsreset() { /* internal declarations */ CS *cs; /* ptr to CS for att */ register LIST *list; /* fast ptr to list element */ register i4 i; /* counter */ FIELD *f; /* pointer to field */ CS *ntop; /* new Cs_top value */ CS *ncs; /* new CS ptr */ ATTRIB ordinal; /* ordinal of this attribute */ bool associated; /* associated to column */ /* start of routine */ # ifdef xRTR1 if (TRgettrace(180,0) || TRgettrace(181,0)) { SIprintf(ERx("rFcsreset: entry.\r\n")); } # endif ntop = (CS *) MEreqmem(0,(u_i4) En_n_attribs*sizeof(CS), TRUE,(STATUS *) NULL); /* first reorder the attributes into the ntop arrary */ for (i=1; i<=Cs_length; i++) { cs = rFgt_cs(i); # ifdef xRTR1 if (TRgettrace(181,0)) { SIprintf(ERx(" Next CS ord from VIFRED: %d\r\n"),i); rFpr_cs(cs); } # endif associated = FALSE; for (list=cs->cs_flist; list!=NULL; list=list->lt_next) { /* identify the attribute */ if ((f=list->lt_field) == NULL) { continue; } ordinal = r_mtch_att(f->fldname); if ((ordinal>0) && (ordinal<=En_n_attribs)) { /* found the attribute. Store list in ntop */ # ifdef xRTR3 if (TRgettrace(181,0)) { SIprintf(ERx(" Match on ordinal:%d: %s\r\n"), ordinal, f->fldname); } # endif ncs = &(ntop[ordinal-1]); ncs->cs_flist = cs->cs_flist; ncs->cs_tlist = cs->cs_tlist; associated = TRUE; break; } } if (!associated) /* not associated. ERROR */ IIUGerr(E_RF0025_rFcsreset___CS_struct, UG_ERR_FATAL, 0); } Cs_top = ntop; # ifdef xRTR3 if (TRgettrace(181,0)) { SIprintf(ERx(" At end of rFcsreset. CS_TOP:%p.\r\n"),Cs_top); } # endif return; }
/*{ ** Name: xffileinput - get input files ** ** Description: ** This routine will make input from the command line, transparent ** from input from a file name. This will be done by reading ** the input file and building an argv,argc parameter from the ** file specification. ** ** ** Inputs: ** paramfile Name of the parameter file ** which is passed in ** to this routine. ** argv ptr to command line parameters ** which may point to a file name ** containing input specifications ** argc ptr to number of command line parameters ** ** Outputs: ** argv ptr to command line parameters ** which may have been created from ** an input file specification ** argc ptr to number of command line parameters ** ** Returns: ** OK : if successful. ** FAIL: if failed ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 31-oct-01 (gupsh01) ** Created.(Based on fileinput:opqutils.sc.) ** */ STATUS xffileinput( char *paramfile, char ***argv, i4 *argc) { FILE *inf; STATUS stat = FAIL; LOCATION inf_loc; /* create argv and argc to simulate a "long" command input line */ /* open the file containing the specifications */ inf = NULL; if ( ((stat =LOfroms(PATH & FILENAME, paramfile, &inf_loc)) != OK) || ((stat = SIopen(&inf_loc, "r", &inf)) != OK) || (inf == NULL) ) { /* report error dereferencing or opening file */ char buf[ER_MAX_LEN]; if ((ERreport(stat, buf)) != OK) buf[0] = '\0'; IIUGerr(E_XF0007_Cannot_open_param, UG_ERR_ERROR, 1, paramfile); return (FAIL); } { char buf[XF_MAXBUFLEN]; /* buffer used to read lines ** from the command file */ /* ptr to current parameter to be copied from temp buffer */ char **targv=(char **)NULL; i4 targc ;/* number of parameters ** which have been copied */ SIZE_TYPE len; /* size of dyn.mem. to be allocated. */ i4 argcount = XF_MAXARGLEN; /* get room for maxarglen args */ len = XF_MAXARGLEN * sizeof(char *); targv = (char **)NULL; targv = (char **)XF_REQMEM(len, FALSE); targc = 1; buf[XF_MAXBUFLEN-1]= 0; while ((stat = SIgetrec((PTR)&buf[0], (i4)(XF_MAXBUFLEN-1), inf)) == OK) { char *cp = &buf[0]; do { if (targc >= argcount) { i4 i; char **targv1 = NULL; /* Allocate another vector, ** twice the size of the prev. */ targv = (char **)XF_REQMEM((i4) (argcount * 2 * sizeof(char *)), FALSE); /* Copy previous into current. */ for (i = 0; i < argcount; i++) targv1[i] = targv[i]; targv = targv1; argcount += argcount; } { char *tp = (char *) NULL; i4 arglen = STlength(cp); tp = (char *)XF_REQMEM (arglen, FALSE); targv[targc++] = tp; { i4 len = STlength(cp); cp[len - 1] = EOS; STskipblank(cp,(len -1)); STtrmwhite(cp); STcopy(cp, tp); cp = &cp[len - 1]; } } } while (*cp); } if (stat != ENDFILE) { /* report error unable to read line from the file */ char buf[ER_MAX_LEN]; if ((ERreport(stat, buf)) != OK) buf[0] = '\0'; IIUGerr(E_XF0008_Cannot_read_param, UG_ERR_ERROR, 1, paramfile); return (FAIL); } *argv = targv; *argc = targc; } /* Close input file */ stat = SIclose(inf); if (stat != OK) { /* report error closing file */ char buf[ER_MAX_LEN]; if ((ERreport(stat, buf)) != OK) buf[0] = '\0'; IIUGerr(E_XF0025_Cannot_close_param, UG_ERR_ERROR, 1, paramfile); return (FAIL); } return OK; }
/* ** Name: registerdoc ** ** Description: ** Function sets up the parameters required to complete the command. ** Parameters are either global as set on the command line or overriden ** from the input file. ** ** Inputs: ** hicectx Handle to the connection context returned from a ** a call to ic_initialize. ** ** Outputs: ** None. ** ** Returns: ** OK Completed successfully ** E_IC_INVALID_UNIT_NAME Specified unit does not exist. ** E_IC_INVALID_LOC_NAME Specified location does not exist. ** ** History: ** 21-Feb-2001 (fanra01) ** Created. */ ICE_STATUS registerdoc( HICECTX icectx, PARAMS* prog, PREGPARAMS rp ) { ICE_STATUS status = OK; II_CHAR* owner; II_CHAR* unitname; II_CHAR* location; II_CHAR* filename; II_CHAR* bu; II_CHAR* loc; II_CHAR* file; II_CHAR* ext; II_INT4 buid; II_INT4 locid; II_INT4 docid; II_INT4 type; II_INT4 flags; /* ** if the input file didn't explicitly define an option use the ** one from the command line. */ owner = (rp->owner != NULL) ? rp->owner : prog->owner; unitname = (rp->unit != NULL) ? rp->unit : prog->unit; location = (rp->location != NULL) ? rp->location : prog->loc; filename = rp->filename; type = (rp->type != 0) ? rp->type : prog->type; flags = (rp->flags != 0) ? rp->flags : prog->flags; /* ** Setup the business unit and location id. */ buid = prog->buid; locid = prog->locid; /* ** if the unit id has not previously been set or the unit name is ** specified in the file get the id of the specified unit. */ if ((buid == 0) || (rp->unit != NULL)) { if ((status = ic_getitem( icectx, ICE_UNIT, "unit_name", unitname, "unit_id", &bu )) == OK) if (bu != NULL) { ASCTOI( bu, &buid ); } else { if (status == E_IC_OUT_OF_DATA) { status = E_IC_INVALID_UNIT_NAME; } } } /* ** if the location id has not previously ben set or the location name is ** specified in the get the id of the specified location. */ if ((status == OK) && ((locid == 0) || (rp->location != NULL))) { status = ic_getitem( icectx, ICE_LOCATION, "loc_name", location, "loc_id", &loc ); if((status == OK) && (loc != NULL)) { ASCTOI( loc, &locid ); } else { if (status == E_IC_OUT_OF_DATA) { status = E_IC_INVALID_LOC_NAME; } } } if ((status = ic_getfileparts( filename, &file, &ext )) == OK) { if ((status = ic_createdoc( icectx, buid, file, (ext) ? ext : "", type, locid, flags, filename, owner, &docid )) == OK) { SIprintf("%s: Unit:%s Location:%s %03d %s.%s registered\n", prog->name, unitname, location, docid, file, ext); } else { II_CHAR* errmsg; ic_errormsg( icectx, status, &errmsg ); SIprintf( "%s: Error 0x%08x - %s.%s %s\n", prog->name, status, file, ext, (errmsg != NULL) ? errmsg : "\0"); } } if (status != OK) { IIUGerr( status, UG_ERR_ERROR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); } return(status); }