bool r_rep_do() { char *_Retrieving = ERget(F_RW0003_Retrieving_data); LOCATION loc; /* file where the report will be written */ char title[80+1]; /* the help title buffer */ char help_scr[80+1]; /* the help screen buffer */ char pr_title[80+1]; /* print report title */ char file_title[80+1]; /* file report title */ /* ** The following is for scrollable output. */ FUNC_EXTERN BCB *IIUFint_Init(); FUNC_EXTERN bool IIUFmro_MoreOutput(); bool scrl_fl; r_rep_set(&loc); if (St_ing_error != 0) return FALSE; if (!St_silent) { /* give message while waiting for retrieve */ SIprintf(_Retrieving); SIflush(stdout); } if (St_to_term) { if( Warning_count != 0 ) { r_prompt(ERget(S_RW0025_Hit_RETURN_when_done), FALSE); } /* ** If output is the terminal, then initialize forms to do ** scrollable output. */ if (r_init_frms() != OK) { return FALSE; } /* set up the bcb (buffer control block) */ STprintf (title, ERget(S_RW1400_report_title), En_report); En_bcb = IIUFint_Init((char *)NULL, title); if (En_bcb == NULL) /* IIUFint_Init failed */ { return FALSE; } /* initialize bcb */ En_bcb->nxrec = r_scroll; /* routine to handle scrolling */ En_bcb->req_begin = TRUE; En_bcb->req_complete = FALSE; En_bcb->eor_warning = FALSE; LOdelete(&En_bcb->bfloc); /* check directory is writable */ En_bcb->nrecs = 0; En_bcb->mxcol = 0; En_bcb->print_time = FALSE; if (En_bcb->rd_ahead) { MEfree(En_bcb->rd_ahead); En_bcb->rd_ahead = NULL; } /* get first screen to display */ if (!IIUFmro_MoreOutput(En_bcb, En_bcb->mx_rows-2, NULL)) { r_end_frms(); /* suppress message if undocumented flag is used */ if (!St_copyright) { SIprintf(ERget(S_RW0045_No_data_in_table)); } SIflush(stdout); return FALSE; } STcopy (ERx("rwoutput.hlp"), help_scr); STcopy (ERget(S_RW13F1_RW_output_helpfile), title); STcopy (ERget(S_RW1408_print_report_title), pr_title); STcopy (ERget(S_RW1409_file_report_title), file_title); /* If there is nothing to display, then just exit */ if (En_bcb->rows_added != 0) { /* ** If the pagelength is equal to screen display size ** (4 less lines for the report title, status line, ** solid line and menu line in the scrollable output) ** then do NOT scroll keeping the current line visible. ** This is the default behavior. Want to scroll a ** full page at a time. */ if (St_p_length == (En_lines-4)) /* ** page length is the same as window size, so ** want page scrolling */ scrl_fl = FALSE; else /* ** different page size so want to scroll, ** leaving the one line for context. */ scrl_fl = TRUE; if (!IIUFdsp_Display(En_bcb, NULL, help_scr, title, scrl_fl, pr_title, file_title, FALSE)) { return FALSE; } } IIUFdone (En_bcb); } else { while (r_getrow() == OK) { r_nxt_row(); /* process next row */ } return (r_do_end(&loc)); } return TRUE; }
i4 IIgetfldio(i2 *ind, i4 variable, i4 type, i4 len, PTR data, char *name) { char *namestr; char fbuf[MAXFRSNAME+1]; DB_EMBEDDED_DATA edv; DB_DATA_VALUE *dbvptr; DB_DATA_VALUE oper_dbv; DB_DATA_VALUE dbvcop; i4 oper; ADF_CB *cb; bool errflag = FALSE; i4 getop = 0; i4 (*oldproc)(); bool disp_msgs = TRUE; /* Check field name for validity */ namestr = IIstrconv(II_CONV, name, fbuf, (i4)MAXFRSNAME); if (namestr == NULL) { IIFDerror(RTRFFL, 2, IIfrmio->fdfrmnm, ERx("")); return(FALSE); } /* Set up an EDV to describe the caller's parameters. */ edv.ed_type = type; edv.ed_length = len; edv.ed_data = (PTR) data; edv.ed_null = ind; cb = FEadfcb(); if (IIfrscb->frs_globs->enabled & GETMSGS_OFF) { disp_msgs = FALSE; oldproc = IIseterr(IIFRgmoGetmsgsOff); } /* ** If getting an 'oper', not a value, special processing required. ** Operators are not returned from FRAME as DBV's, so we must build ** one so we can follow the normal path and convert to the final EDV. */ getop = IIgetoper( (i4) 0 ); if ( getop ) { oper_dbv.db_datatype = DB_INT_TYPE; oper_dbv.db_length = sizeof(i4); oper_dbv.db_prec = 0; oper_dbv.db_data = (PTR) &oper; /* ** Make sure the frame is in Query mode, else return NOOP. */ if (IIfrmio->fdrunmd != fdrtQRY) oper = fdNOP; else FDqryop( IIfrmio->fdrunfrm, namestr, (i4 *) oper_dbv.db_data ); dbvptr = &oper_dbv; } else if (IIfrmio->fdrunmd == fdrtQRY) { /* ** If in query mode, we must use a different routine ** to retrieve the data portion of the field. This ** routine also strips off the operator. */ if (!FDqryfld(IIfrmio->fdrunfrm, namestr, &dbvptr)) errflag = TRUE; } else { IIfrscb->frs_event->eval_aggs = TRUE; /* ** Get data portion of the field */ if (!FDgetfld(IIfrmio->fdrunfrm, namestr, &dbvptr)) errflag = TRUE; IIfrscb->frs_event->eval_aggs = FALSE; } /* ** If "errflag" is set at this point, then it was not ** possible to get the DB_DATA_VALUE pointer for a field. ** ** Trim trailing blanks on character-type fields */ if ( errflag == FALSE && ( IIftrim( dbvptr, &dbvcop ) != OK ) ) errflag = TRUE; /* ** Convert the DBV containing the field's value to an EDV */ if ( errflag == FALSE && ( adh_dbcvtev( cb, &dbvcop, &edv ) != OK ) ) { if (cb->adf_errcb.ad_errcode == E_AD1012_NULL_TO_NONNULL) { IIFDerror(RTRNLNNL, 2, IIfrmio->fdfrmnm, namestr); } else { IIFDerror(RTGFERR, 2, IIfrmio->fdfrmnm, namestr); } errflag = TRUE; } if (!disp_msgs) _VOID_ IIseterr(oldproc); if ( errflag == TRUE ) return (FALSE); else return (TRUE); }
/* ** Writes or erases a transaction log and displays a completion thermometer. ** ** 'context' must not be NULL, and defaults for element 0 & 1 of context ** must have been set. */ i4 write_transaction_log(bool create, PM_CONTEXT *context, char *log_dir[], char *log_file[], void (*message)(char *), void (*init_graph)(bool, i4), i4 graph_size, void (*update_graph)()) { # define LG_PAGE_SIZE 2048L # define LG_NUMBER_OF_PAGES 32L /* Number of pages to write at a time */ DI_IO dio[LG_MAX_FILE]; char buf[LG_PAGE_SIZE * LG_NUMBER_OF_PAGES]; char nodename[GL_MAXNAME]; i4 i, j, marker, count, num_logs; i4 num_pages, page, part_size, remainder, loop; CL_ERR_DESC err; char *string; LOCATION loc[LG_MAX_FILE]; char locbuf[MAX_LOC + 1]; char *path[LG_MAX_FILE]; i4 LOinfo_flag; LOINFORMATION loc_info; i8 size; CS_SCB scb; bool size_in_kbytes = FALSE; MEfill( sizeof( scb ), 0, ( PTR ) &scb ); ++graph_size; /* Prepare transaction for log LOCATION(s) */ for (num_logs = 0; num_logs < LG_MAX_FILE; num_logs++) { if (log_dir[num_logs] == 0) break; STcopy( log_dir[num_logs], locbuf ); LOfroms( PATH, locbuf, &loc[num_logs] ); LOfstfile( log_file[num_logs], &loc[num_logs] ); LOtos( &loc[num_logs], &path[num_logs] ); } /* get size (in bytes) of log file to be created or erased */ if( create ) { STATUS status; char *value; bool havevalue = FALSE; status = PMmGet( context, ERx( "$.$.rcp.file.kbytes" ), &value ); if ( status == OK ) { havevalue = TRUE; size_in_kbytes = TRUE; } if ( havevalue == FALSE ) { status = PMmGet( context, ERx( "$.$.rcp.file.size" ), &value ); if ( status == OK ) havevalue = TRUE; } if ( havevalue == FALSE ) { if ( message != NULL ) { char msg[ BIG_ENOUGH ]; STprintf( msg, ERx( "%s %s" ), PMmExpandRequest( context, ERx( "$.$.rcp.file.kbytes" ) ), "not found." ); message( msg ); } return( 0 ); } CVal8( value, &size ); } else { LOinfo_flag = LO_I_SIZE; size = 0; for (i = 0; i < num_logs; i++) { if ( LOinfo( &loc[i], &LOinfo_flag, &loc_info ) != OK ) { if ( message != NULL ) { char msg[ BIG_ENOUGH ]; STprintf( msg, "Unable to get size of transaction log:\n\n\t%s", path[i] ); (*message)( msg ); } return( 0 ); } else size += loc_info.li_size; if ((LOinfo_flag & LO_I_SIZE) == 0) break; } if ( (LOinfo_flag & LO_I_SIZE) == 0 || size == 0L) { STATUS status; char *value; bool havevalue = FALSE; status = PMmGet( context, ERx( "$.$.rcp.file.kbytes" ), &value ); if ( status == OK ) { havevalue = TRUE; size_in_kbytes = TRUE; } if ( havevalue == FALSE ) { status = PMmGet( context, ERx( "$.$.rcp.file.size" ), &value ); if ( status == OK ) havevalue = TRUE; } if ( havevalue == FALSE ) { if ( message != NULL ) { char msg[ BIG_ENOUGH ]; STprintf( msg, ERx( "%s %s." ), PMmExpandRequest( context, ERx( "$.$.rcp.file.kbytes" ) ), "not found." ); message( msg ); } return( 0 ); } CVal8( value, &size ); } } for (i = 0; i < num_logs; i++) { if ( create && LOexist( &loc[i] ) == OK ) { char msg[ BIG_ENOUGH ]; if ( message != NULL ) { STprintf( msg, "%s already exists.", path[i] ); (*message)( msg ); STprintf( msg, "To create a new transaction log, you must first delete all partitions of the old one." ); (*message)( msg ); } return( 0 ); } } if ( CSinitiate( (i4 *) NULL, (char ***) NULL, (CS_CB *) NULL ) != OK ) { if ( message != NULL ) message( "Unable to connect to shared memory" ); return( 0 ); } CSset_sid( &scb ); /* create DI file */ for (i = 0; i < num_logs; i++) { if ( create && DIcreate( &dio[i], log_dir[i], (u_i4)STlength(log_dir[i]), log_file[i], (u_i4)STlength(log_file[i]), (i4)LG_PAGE_SIZE, &err) != OK ) { char msg[ BIG_ENOUGH ]; if ( message != NULL ) { STprintf( msg, "Unable to create transaction log:\n\n\t%s", path[i] ); (*message)( msg ); } return( 0 ); } /* open DI file */ if ( DIopen( &dio[i], log_dir[i], (u_i4)STlength(log_dir[i]), log_file[i], (u_i4)STlength(log_file[i]), (i4)LG_PAGE_SIZE, DI_IO_WRITE, 0, &err) != OK ) { if ( message != NULL ) { char msg[ BIG_ENOUGH ]; STprintf( msg, "Unable to open transaction log:\n\n\t%s", path[i] ); (*message)( msg ); } return( 0 ); } } if ( size_in_kbytes == FALSE ) size = (size + 1023) / 1024; (*init_graph)( create, (i4) size ); num_pages = size / (LG_PAGE_SIZE/1024); part_size = num_pages / num_logs; /* Readjust num_pages to be a multiple of num_logs */ num_pages = part_size * num_logs; loop = part_size / LG_NUMBER_OF_PAGES; remainder = part_size % LG_NUMBER_OF_PAGES; marker = loop / graph_size; /* Fill buffer with zeroes */ MEfill( sizeof( buf ), 0 , buf); for (i = 0; i < num_logs; i++) { if ( create && DIalloc( &dio[i], part_size, &page, &err ) != OK ) { DIdelete( &dio[i], log_dir[i], (u_i4)STlength( log_dir[i] ), log_file[i], (u_i4)STlength( log_file[i] ), &err ); if ( message != NULL ) (*message)( "Unable to allocate space in transaction log file." ); return( 0 ); } } count = 0; for( j = 0; j < loop; j++ ) { i4 n = LG_NUMBER_OF_PAGES; i4 page_no = j * n; for (i = 0; i < num_logs; i++) { if ( DIwrite( &dio[i], &n, page_no, buf, &err ) != OK ) { DIdelete( &dio[i], log_dir[i], (u_i4)STlength(log_dir[i]), log_file[i], (u_i4)STlength(log_file[i]), &err ); if ( message != NULL ) (*message)( "Unable to continue writing transaction log." ); return( 0 ); } } if ( j >= marker && j % marker == 0 && (f4) ((f4) j / (f4) loop) >= ((f4) count + 1) / graph_size ) { ++count; (*update_graph)(); SIflush( stdout ); } } if (remainder) { i4 page_no = loop * LG_NUMBER_OF_PAGES; for (i = 0; i < num_logs; i++) { if ( DIwrite( &dio[i], &remainder, page_no, buf, &err ) != OK ) { DIdelete( &dio[i], log_dir[i], (u_i4)STlength(log_dir[i]), log_file[i], (u_i4)STlength(log_file[i]), &err ); if ( message != NULL ) (*message)( "Unable to continue writing transaction log." ); return( 0 ); } } } for (i = 0; i < num_logs; i++) { if ( DIforce( &dio[i], &err ) != OK ) { DIdelete( &dio[i], log_dir[i], (u_i4)STlength(log_dir[i]), log_file[i], (u_i4)STlength(log_file[i]), &err ); if ( message != NULL ) (*message)( "Unable to force changes to transaction log." ); return( 0 ); } if ( create && DIflush( &dio[i], &err ) != OK ) { DIdelete( &dio[i], log_dir[i], (u_i4)STlength(log_dir[i]), log_file[i], (u_i4)STlength(log_file[i]), &err ); if ( message != NULL ) (*message)( "Unable to flush transaction log to disk." ); return( 0 ); } if( DIclose( &dio[i], &err ) != OK) { DIdelete( &dio[i], log_dir[i], (u_i4)STlength(log_dir[i]), log_file[i], (u_i4)STlength(log_file[i]), &err ); if ( message != NULL ) (*message)( "Unable to finish writing transaction log." ); return( 0 ); } } return( (i4) size ); }
static STATUS mmsModifyModuleStar(); static VOID pmsPrintModuleStatus(); GLOBALREF bool IIDDsilent; GLOBALREF i4 IIDDpagesize; static VOID DDexit(); static char *dbname; static char *uname; static char *xflag; static bool Wait = FALSE; static bool nowait = FALSE; static char *Wait_final; static i4 page_size = 0; #ifdef NT_GENERIC static char *connect_w = ERx(""); #else static char *connect = ERx(""); #endif static const char _Pgm[] = ERx("modifyfe"); static const char _Empty[] = ERx(""); static const char _Wait[] = ERx("+w"); static const char _Nowait[] = ERx("-w"); static ARG_DESC args[] = { /* Required arguments */ {ERx("database"), DB_CHR_TYPE, FARG_PROMPT, (PTR) &dbname}, /* Optional arguments */
i4 Is_it_If_statement(FILE *testFile,i4 *counter,bool Ignore_it) { char *cp1 = NULL ; char *cp2 = NULL ; i4 cmd ; bool yes_its_if = FALSE ; bool yes_its_tc = FALSE ; cmd = 0; if ((!shellMode)&&(SEP_CMstlen(lineTokens[0],0) > 1)&& (CMcmpcase(lineTokens[0],ERx(".")) == 0)) { cp1 = buffer_1 ; /* Fix the ".if" statement. */ cp2 = buffer_2 ; STcopy(buffer_1, holdBuf); CMcpyinc(cp1,cp2); CMcpychar(ERx(" "),cp2); CMnext(cp2); STcopy(cp1, cp2); STcopy(buffer_2, buffer_1); break_line(buffer_2, counter, lineTokens); } cmd = classify_cmmd(sepcmmds, lineTokens[1]); if (cmd == IF_CMMD || cmd == ELSE_CMMD || cmd == ENDIF_CMMD) { yes_its_if = TRUE; } else if (cmd == TEST_CASE_CMMD || cmd == TEST_CASE_END_CMMD) { yes_its_tc = TRUE; } if (yes_its_if || yes_its_tc) { append_line(holdBuf, 0); if (Ignore_it) ignore_silent == TRUE; if (yes_its_if) { process_if(testFile, lineTokens, cmd); } else if (yes_its_tc) { if (cmd == TEST_CASE_CMMD) { testcase_start(&lineTokens[1]); } else if (cmd == TEST_CASE_END_CMMD) { testcase_end(FALSE); } } if (Ignore_it) ignore_silent == FALSE; } else { cmd = 0; } return (cmd); }
static DB_DATA_VALUE Op_dpart = AFE_DCMP_INIT_MACRO(DB_CHA_TYPE,5,NULL); static DB_DATA_VALUE *Op_db[2] = { &Op_dpart, NULL }; static AFE_OPERS Ops = { 2, Op_db }; /* ** set up a "convert to string" DB_DATA_VALUE to use */ static GRC_STORE Dsa; static DB_DATA_VALUE Dstr = AFE_DCMP_INIT_MACRO(DB_LTXT_TYPE,GRC_SLEN-1,(PTR) &Dsa); /* ** format for date string conversion for fields / legends. Df_str is ** set to NULL after Dfmt has been built. */ static FMT *Dfmt; static char *Df_str = ERx("d\"3-feb-1901\""); /** ** Name: grcoerce.c - graf library type coercion routine. ** ** Description: ** This are the routines used to coerce types when mapping a ** query to a graph: ** ** GRcoerce_type: coerce a database type into internal types ** used to produce graphics data, and optionally, into ** a string. ** ** GRzero_pt: produce a data value for use in filling in "empty" ** spots when dense data must be constructed. **
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; }
STATUS open_log(char *testPrefix,char *testSufix,char *username,char *errbuff) { SYSTIME atime ; char uname [20] ; char logFileName [MAX_LOC+1] ; char timestr [TEST_LINE] ; char buffer [MAX_LOC+1] ; char *dot = NULL ; char *cptr = NULL ; char year[5]; if (shellMode) STpolycat(3, testPrefix, ERx("."), testSufix, logFileName); else if (updateMode) STpolycat(2, testPrefix, ERx(".upd"), logFileName); else STpolycat(2, testPrefix, ERx(".log"), logFileName); if (outputDir) { if (outputDir_type == PATH) { STcopy(outputDir, buffer); LOfroms(PATH, buffer, &logloc); LOfstfile(logFileName, &logloc); LOtos(&logloc, &cptr); } else { LOtos(&outLoc,&cptr); } STcopy(cptr, logname); } else STcopy(logFileName, logname); if (LOfroms(FILENAME & PATH, logname, &logloc) != OK) { STprintf(errbuff,ERx("ERROR: could not get location for log file")); return(FAIL); } if (SIopen(&logloc,ERx("w"),&logptr) != OK) { STprintf(errbuff,ERx("ERROR: could not open log file")); return(FAIL); } if (!updateMode) { append_line(ERx("/*"),1); copyright_year(&year[0]); STprintf(buffer, ERx("Copyright (c) %s Ingres Corporation"), &year); append_line(buffer, 1); append_line(ERx(" "), 1); STprintf(buffer,ERx("\tTest Name: %s.%s"), testPrefix, testSufix); append_line(buffer,1); TMnow(&atime); TMstr(&atime,timestr); STprintf(buffer,ERx("\tTime: %s"),timestr); append_line(buffer,1); dot = uname; if (username == NULL || *username == '\0') IDname(&dot); else STcopy(username,uname); STprintf(buffer,ERx("\tUser Name: %s"),uname); append_line(buffer,1); STprintf(buffer, ERx("\tTerminal type: %s"), terminalType); append_line(buffer,1); append_line(ERx(" "),1); } return(OK); }
/* ** The table which converts from a suffix of a file to the ** Right equel language constants for IIlang. */ typedef struct { char *acsuffix; i4 aclang; i4 acci; i4 acdml; } UT_SUFFIX; # define UTSUFSIZ (sizeof(utsuffix)/sizeof(utsuffix[0])) /* GLOBALDEF's */ GLOBALDEF char *IIutExtensions[_OLMAX+1][3] = { {ERx("c"), ERx("qc"), ERx("sc")}, {FORTRAN, ERx("qf"), ERx("sf")}, {PASCAL, ERx("qp"), ERx("sp")}, {BASIC, ERx("qb"), ERx("sb")}, {COBOL, ERx("qcb"), ERx("scb")}, {ERx(""), ERx(""), ERx("")}, {ADA, ERx("qa"), ERx("sa")}, {ERx(""), ERx("osl"), ERx("osq")}, {ERx(""), ERx("quel"), ERx("sql")} }; /* extern's */ /* static's */ static STATUS getLanguage(); static UT_SUFFIX * _utSuffix ();
STATUS disp_diff(STATUS acmmt,i4 canons) { STATUS ioerr ; STATUS up_canon = FAIL ; char cmmtfile [50] ; char canon_upd = '\0' ; char junk ; char menu_ans ; bool conditional_exp ; /* initialize diff window */ conditional_exp = FALSE; #ifndef NT_GENERIC TEwrite(CL,STlength(CL)); TEflush(); #endif diffW = TDnewwin(MAIN_ROWS,MAIN_COLS,FIRST_MAIN_ROW,FIRST_MAIN_COL); diffstW = TDnewwin(STATUS_ROWS,STATUS_COLS,FIRST_STAT_ROW,FIRST_MAIN_COL); TDrefresh(diffstW); TDrefresh(diffW); screenLine = 0; old_page = 0; bottom_page = 0; myPages = NULL; ioerr = OK; STprintf(cmmtfile,ERx("ct%s.stf"),SEPpidstr); diffPtr = sepDiffer->_fptr; /* ** display diff */ page_down(0); if (updateMode) up_canon = OK; for (;;) { if (updateMode) { if (editCAns == '\0') disp_prompt(DIFF_MENU_M,&menu_ans,DIFF_MENU_AM); else menu_ans = 'e'; } else disp_prompt(DIFF_MENU,&menu_ans,DIFF_MENU_A); switch (menu_ans) { case 'A': case 'a': ioerr = FAIL; break; case 'P': case 'p': page_up(); break; case 'N': case 'n': page_down(0); break; case 'C': case 'c': if (acmmt == FAIL && !updateMode) disp_prompt(ERx("no comments attached to this command"), &junk,NULL); else { edit_file(cmmtfile); TDtouchwin(diffW); TDrefresh(diffW); } break; case 'E': case 'e': if (up_canon == OK) { if (editCAns == '\0') { disp_prompt(UPD_CANON,&canon_upd,UPD_CANON_A); } else { canon_upd = editCAns; menu_ans = 'q'; } if (canon_upd == 'M' || canon_upd == 'A' || canon_upd == 'm' || canon_upd == 'a' ) conditional_exp = ask_for_conditional(diffstW, editCAns); up_canon = FAIL; } break; } if (menu_ans == 'Q' || menu_ans == 'q' || menu_ans == 'A' || menu_ans == 'a' || menu_ans == 'D' || menu_ans == 'd') { disp_prompt(NULLSTR,NULL,NULL); SEPdisconnect = (menu_ans == 'A' || menu_ans == 'a' || menu_ans == 'D' || menu_ans == 'd'); break; } } /* ** update test */ if (updateMode) { LOCATION cmmtloc; short count; /* add comments */ LOfroms(FILENAME & PATH,cmmtfile,&cmmtloc); if (SEP_LOexists(&cmmtloc)) { append_line(OPEN_COMMENT,1); append_file(cmmtfile); append_line(CLOSE_COMMENT,1); LOdelete(&cmmtloc); } /* add canons */ switch (canon_upd) { case 'I': case 'i': append_line(OPEN_CANON,1); append_line(SKIP_SYMBOL,1); append_line(CLOSE_CANON,1); break; case 'M': case 'm': SEPrewind(sepResults, FALSE); if (conditional_exp == TRUE) { append_line(OPEN_CANON,0); append_line(conditional_prompt,1); } else append_line(OPEN_CANON,1); append_sepfile(sepResults); append_line(CLOSE_CANON,1); append_sepfile(sepGCanons); break; case 'O': case 'o': SEPrewind(sepResults, FALSE); append_line(OPEN_CANON,1); append_sepfile(sepResults); append_line(CLOSE_CANON,1); break; case '\0': case 'E': case 'e': append_sepfile(sepGCanons); break; case 'A': case 'a': append_sepfile(sepGCanons); SEPrewind(sepResults, FALSE); if (conditional_exp == TRUE) { append_line(OPEN_CANON,0); append_line(conditional_prompt,1); } else append_line(OPEN_CANON,1); append_sepfile(sepResults); append_line(CLOSE_CANON,1); break; } } MEtfree(SEP_ME_TAG_PAGES); TDdelwin(diffW); TDdelwin(diffstW); return(ioerr); }
STATUS display_lines() { STATUS ret_val ; i4 count ; char dispBuff [TERM_LINE+1] ; #ifdef NT_GENERIC char *ptr = NULL; i4 buffCount, i, count2; bool more_found; #endif for (screenLine = 0;;) { if ((ret_val = SIread(diffPtr, TEST_LINE, &count, dispBuff)) == FAIL) { get_d_answer(ERx("ERROR: read failed on diff file."), dispBuff); return(FAIL); } #ifdef NT_GENERIC ptr = dispBuff; i = count = 0; count2 = TEST_LINE; more_found = TRUE; while (more_found == TRUE) { count2 = count2 + count; buffCount = 0; while (i != count2) { if (dispBuff[i] == SEP_ESCAPE) { CMnext(ptr); i++; if (i == count2) { if (diffPtr->_ptr[0] == SEP_ESCAPE) buffCount++; } else if (dispBuff[i] == SEP_ESCAPE) buffCount++; } if (i != count2) { i++; CMnext(ptr); } } if (buffCount > 0) { if ((ret_val = SIread(diffPtr, buffCount, &count, ptr)) == FAIL) { get_d_answer(ERx("ERROR: read failed on diff file."), dispBuff); return(FAIL); } } else more_found = FALSE; } #endif if (ret_val == ENDFILE || SEPcheckEnd(dispBuff)) { STprintf(dispBuff, ERx("--- EOF RETURNED ---")); myPages->final_page = TRUE; disp_d_line(dispBuff, 0, 0); break; } dispBuff[TEST_LINE + 1] = '\0'; #ifdef NT_GENERIC if (dispBuff[TEST_LINE] == -3) dispBuff[TEST_LINE] = '\0'; #endif SEPtranslate(dispBuff, TERM_LINE); disp_d_line(dispBuff, 0, 0); if (screenLine > LAST_MAIN_ROW) break; } return(OK); } /* display_lines */
VOID get_string(WINDOW *wndow,char *question,char *ansbuff) { char *prompt = NULL ; char tempBuffer [TERM_LINE] ; char *cp = ansbuff ; char *cptr = NULL ; i4 clen ; register i4 i ; prompt = SEP_MEalloc(SEP_ME_TAG_NODEL, STlength(question)+5, TRUE, (STATUS *) NULL); STprintf(prompt, ERx("%s "), question); put_message(wndow, prompt); getstr(wndow, tempBuffer, FALSE); /* check if continuation character was entered */ cptr = SEP_CMlastchar(tempBuffer,0); if (CMcmpcase(cptr,cont_char) == 0) { *cptr = EOS; STcopy(tempBuffer,cp); clen = SEP_CMstlen(tempBuffer,0); for (i=0; i<clen; i++) CMnext(cp); TDerase(wndow); STprintf(tempBuffer, ERx("%s%s"), prompt, ansbuff); SEPprintw(wndow, PROMPT_ROW - 1, PROMPT_COL, tempBuffer); STprintf(prompt, ERx("%s%s"), question, cont_char); SEPprintw(wndow, PROMPT_ROW, PROMPT_COL, prompt); TDrefresh(wndow); getstr(wndow,tempBuffer,FALSE); /* check if continuation character was entered */ cptr = SEP_CMlastchar(tempBuffer,0); if (CMcmpcase(cptr,cont_char) == 0) { i4 temp; *cptr = EOS; STprintf(prompt, ERx("%s %s"), question, tempBuffer); SEPprintw(wndow, PROMPT_ROW, PROMPT_COL, prompt); STcopy(tempBuffer, cp); STprintf(prompt, ERx("%s%s"), question, cont_char); SEPprintw(wndow, PROMPT_ROW + 1, PROMPT_COL, prompt); /* ** ugly fix to prevent the screen from scrolling when ** typing to the last line of the screen. It will hopefully ** be changed in the future for a more elegant solution */ temp = LINES; LINES++; TDrefresh(wndow); getstr(wndow, tempBuffer, FALSE); disp_prompt((char *)NULLSTR, (char *)NULL, (char *)NULL); LINES = temp; } } MEfree(prompt); STcopy(tempBuffer, cp); TDerase(wndow); TDrefresh(wndow); }
STATUS disp_prompt(char *buffer,char *achar,char *range) { STATUS ret_val = OK ; char caracter ; char *legal = NULL ; char termBuffer [255] ; #ifdef NT_GENERIC COORD coordinate; int numchars, i; char tempchar [80]; #endif if (achar == NULL) { #ifndef NT_GENERIC STprintf(termBuffer,ERx("%s%s%s%s%s"),REG_CHAR,ATTR_OFF, PROMPT_POS,DEL_EOL,buffer); TEwrite(termBuffer,STlength(termBuffer)); TEflush(); #else SetConsoleActiveScreenBuffer(hTEconsole); coordinate.X=0; coordinate.Y=22; SetConsoleCursorPosition(hTEconsole, coordinate); WriteConsole(hTEconsole, buffer, strlen(buffer), &numchars, NULL); coordinate.X=strlen(buffer); coordinate.Y=22; SetConsoleCursorPosition(hTEconsole, coordinate); strcpy (tempchar, " "); for (i=2; i<=(80-strlen(buffer)); i++) strcat (tempchar, " "); WriteConsole(hTEconsole, tempchar, strlen(tempchar), &numchars, NULL); #endif } else { #ifndef NT_GENERIC STprintf(termBuffer,ERx("%s%s%s%s%s[ %s ]%s "),REG_CHAR,ATTR_OFF, PROMPT_POS,DEL_EOL,REV_VIDEO,buffer,ATTR_OFF); TEwrite(termBuffer,STlength(termBuffer)); TEflush(); #else SetConsoleActiveScreenBuffer(hTEconsole); coordinate.X=0; coordinate.Y=22; SetConsoleCursorPosition(hTEconsole, coordinate); SetConsoleTextAttribute(hTEconsole, FOREGROUND_BLUE|BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE|BACKGROUND_INTENSITY); STpolycat(3, ERx("[ "), buffer, ERx(" ]"), &termBuffer); WriteConsole(hTEconsole, termBuffer, strlen(termBuffer), &numchars, NULL); coordinate.X=strlen(termBuffer); coordinate.Y=22; SetConsoleCursorPosition(hTEconsole, coordinate); strcpy (tempchar, " "); for (i=2; i<=(80-strlen(termBuffer)); i++) strcat (tempchar, " "); SetConsoleTextAttribute(hTEconsole, FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY|BACKGROUND_BLUE); WriteConsole(hTEconsole, tempchar, strlen(tempchar), &numchars, NULL); #endif TEinflush(); for (;;) { EXinterrupt(EX_OFF); #ifdef VMS sys$setast(0); #endif caracter = TEget(0); EXinterrupt(EX_ON); #ifdef VMS sys$setast(1); #endif if (range == NULL || (legal = STindex(range,&caracter,0)) != NULL) break; else { TEput(BELL); TEflush(); } } *achar = caracter; } return (ret_val); }
FUNC_EXTERN GR_DVEC *GTdvcreate(); FUNC_EXTERN char *GRtxtstore(); static i4 deftag = 0; static i4 npoints = 6; static char xname[FE_MAXNAME+1]; static char yname[FE_MAXNAME+1]; static char zname[FE_MAXNAME+1]; static struct txtmap { char *str; i4 val; } labels[] = { {ERx("Athens"),1}, {ERx("London"),2}, {ERx("New York"),3}, {ERx("Paris"),4}, {ERx("Rome"),5}, {ERx("Tokyo"),6} }; static float pieval[] = { 40, 25, 10, 5, 15, 5 }; static float bary1[] = { 5, 8, 9.8, 3, 3, 2 }; static float bary2[] = { 14.8, 10, 7, 2, 10, 12 }; static float *liney1 = bary1; static float *liney2 = bary2; /*{ ** Name: map_def - get 'default' data for a chart
main(int argc, char **argv) { char *value = NULL; char *host, *server_type, *command_line; char *server_location, *env, *arguments; u_i4 command_line_length; char config_string[256]; char iidbms[256]; STARTUPINFO si; PROCESS_INFORMATION ProcessInfo; BOOL Status; SECURITY_ATTRIBUTES sa; HANDLE hRead, hWrite; HANDLE hStdout; char buffer[512]; DWORD bufferl = sizeof(buffer); DWORD pipe_size = 0; /* Use default buffer size */ DWORD datal = 0; bool havequote, failed = FALSE; MEadvise( ME_INGRES_ALLOC ); switch (argc) { case 1: server_type = ERx("dbms"); server_location = ERx("*"); break; case 2: server_type = argv[1]; server_location = ERx("*"); break; default: server_type = argv[1]; if (STcompare(server_type, "recovery") == 0) server_location = ERx("*"); else server_location = argv[2]; break; } get_sys_dependencies(); /* ** Get the host name, formally used iipmhost. */ host = PMhost(); /* ** Build the string we will search for in the config.dat file. */ STprintf( config_string, ERx("%s.%s.%s.%s.image_name"), SystemCfgPrefix, host, server_type, server_location ); /* ** Get set up for the PMget call. */ PMinit(); if( PMload( NULL, (PM_ERR_FUNC *)NULL ) != OK ) PCexit( FAIL ); /* ** Go search config.dat for a match on the string we just built. */ PMget( config_string, &value ); if ( value == NULL ) { NMgtAt( SystemLocationVariable, &env ); if (STcompare(server_type, "recovery") == 0) { STprintf(iidbms, ERx("%s\\%s\\bin\\%sdbms"), env, SystemLocationSubdirectory, SystemCfgPrefix); } else { STprintf(iidbms, ERx("%s\\%s\\bin\\%s%s"), env, SystemLocationSubdirectory, SystemCfgPrefix, server_type); } } else if ( *value == '/' || *value == '\\' || (*(value+1) == ':' && *(value+2) == '\\') ) { /* Must be a qualified path name */ STcopy( value, iidbms ); } else { NMgtAt( SystemLocationVariable, &env ); STprintf( iidbms, ERx("%s\\%s\\bin\\%s"), env, SystemLocationSubdirectory, value ); } /* ** Initialize the startinfo structure. */ ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); /* ** Get the original command line. */ arguments = GetCommandLine(); havequote = FALSE; while (*arguments != '\0' && *arguments != '\n') { if ( *arguments == '"' ) havequote = (havequote) ? FALSE : TRUE; if ( CMwhite(arguments) && havequote == FALSE ) break; arguments++; } /* ** Put together a command line to create a process with. ** - 4 blank separators, quotes, null termination */ command_line_length = STlength(arguments) + STlength(iidbms) + STlength(iirun) + 6 + 1; if((command_line = (char *) MEreqmem(0, command_line_length, TRUE, NULL)) == NULL) { error(ERx("Request for memory failed"),NULL); } STprintf( command_line, "%s \"%s\" %s", iirun, iidbms, arguments ); /* ** Save standard out's handle, to be restored later. */ hStdout = GetStdHandle(STD_OUTPUT_HANDLE); /* ** Initialize the security attributes structure that will ** be used to make the pipe handles inheritable. */ sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; /* Make object inheritable */ /* ** Define a anonymous pipe to catch the server's startup message. */ if((Status = CreatePipe(&hRead,&hWrite,&sa,pipe_size)) != TRUE) { error(ERx("CreatePipe failed"),ERx("error code = ")); } SetStdHandle(STD_OUTPUT_HANDLE,hWrite); /* ** Initialize the security attributes structure that will ** be used to make the pipe handles inheritable. */ sa.nLength = sizeof(sa); sa.lpSecurityDescriptor = NULL; sa.bInheritHandle = TRUE; /* Make object inheritable */ /* ** Initialize the startup information structure. */ ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); /* ** Start it up. */ /* ** Start iirun which will start the server. */ if ((Status = CreateProcess(NULL,command_line,&sa,NULL,TRUE, HIGH_PRIORITY_CLASS, NULL, NULL,&si,&ProcessInfo)) != TRUE) { DWORD dwError = GetLastError(); switch(dwError) { case ERROR_ACCESS_DENIED: error(ERROR_REQ_PRIVILEGE, ERx("")); break; case ERROR_ELEVATION_REQUIRED: error(ERROR_DENIED_PRIVILEGE, ERROR_REQ_ELEVATION); break; default: error(ERx("CreateProcess failed"),ERx("error code = ")); break; } } SetStdHandle(STD_OUTPUT_HANDLE,hStdout); for (;;) { char *tmpptr; if((Status = ReadFile(hRead,&buffer,bufferl,&datal,NULL)) != TRUE) { error(ERx("ReadFile failed"),ERx("error code = ")); } buffer[datal] = '\0'; if ((tmpptr = STstrindex(buffer, "PASS\n", 0, FALSE))) { *tmpptr = '\0'; if (STlength(buffer)) SIfprintf(stdout, "%s", buffer); break; } SIfprintf(stdout, "%s", buffer); if ((tmpptr = STstrindex(buffer, bad_msg, 0, FALSE))) { *tmpptr = '\0'; if (STlength(buffer)) SIfprintf(stdout, "%s", buffer); failed = TRUE; break; } } /* ** Close handles since we don't need them anymore. */ CloseHandle(ProcessInfo.hThread); CloseHandle(ProcessInfo.hProcess); CloseHandle(hRead); CloseHandle(hWrite); if (failed && STscompare(server_type, STlength(server_type), "gcb", 3) != 0 && STscompare(server_type, STlength(server_type), "gcc", 3) != 0 && STscompare(server_type, STlength(server_type), "jdbc", 4) != 0) { SIfprintf( stderr,"\n%s: server would not start.\n", iirundbms ); SIfprintf(stderr, " %s must be set in your environment.\n", SystemLocationVariable ); SIfprintf(stderr, " Has the csinstall program been run?\n"); SIfprintf(stderr, " %s_DATABASE, %s_CHECKPOINT, %s_JOURNAL and %s_DUMP\n", SystemVarPrefix, SystemVarPrefix, SystemVarPrefix, SystemVarPrefix ); SIfprintf(stderr, " must also be set. See %s_CONFIG\\symbol.tbl.\n", SystemVarPrefix ); SIfprintf(stderr, " Check the file '%%%s%%\\%s\\files\\errlog.log'\n", SystemLocationVariable, SystemLocationSubdirectory ); SIfprintf(stderr, " for more details concerning internal errors.\n"); SIfprintf(stderr, " See your Installation and Operation Guide for more\n"); SIfprintf(stderr, " information concerning server startup.\n"); PCexit(FAIL); } else { PCexit(OK); } }
/* ** Name: GCwintcp_init ** Description: ** WINTCP inititialization function. This routine is called from ** GCwinsock_init() -- the routine GCC calls to initialize protocol ** drivers. ** ** This function does initialization specific to the protocol: ** Reads any protocol-specific env vars. ** Sets up the winsock protocol-specific control info. ** History: ** 05-Nov-93 (edg) ** created. ** 23-Feb-1998 (thaal01) ** Allow space for port_id, stops GCC crashing on startup sometimes. ** 07-Jul-1998 (macbr01) ** Bug 91972 - jasgcc not receiving incoming communications. This is ** due to incorrect usage of PMget() in function GCwintcp_init(). ** Changed to test return code of PMget() instead of testing passed ** in parameter for not equal to NULL. ** 15-jul-1998 (canor01) ** Move assignment of port_id to port_id_buf to prevent possible ** access violation. Clean up comments. ** 09-feb-2004 (somsa01) ** When working with instance identifiers as port IDs, make sure ** we initialize sbprt with the trailing number, if set. ** 13-may-2004 (somsa01) ** Updated config.dat string used to retrieve port information such ** that we do not rely specifically on the GCC port. Also, corrected ** function used to convert subport into a number. ** 26-Jan-2006 (loera01) Bug 115671 ** Added GCWINTCP_log_rem_host to allow of gethostbyaddr() to be ** disabled. ** 06-Feb-2007 (Ralph Loen) SIR 117590 ** Removed GCWINTCP_log_rem_host, since gethostbyaddr() is no ** longer invoked for network listens. ** 22-Feb-2008 (rajus01) Bug 119987, SD issue 125582 ** Bridge server configuration requires listening on a specified ** three character listen address. During protocol initialization ** the bridge server fails to start when three character listen ** address is specified. For example, ** the following configuration entries in config.dat ** ii.<host>.gcb.*.wintcp.port: <xxn>, ** ii.<host>.gcb.*.wintcp.status:<prot_stat> ** are for command line configuration. When these entries are ** present in addition to the CBF VNODE configuration (shown below ) ** ii.rajus01.gcb.*.wintcp.port.v1:<xxn> ** ii.rajus01.gcb.*.wintcp.status.v1:<prot_stat> ** the bridge server fails even though the port is available for use. ** It has been found that the global 'sbprt' variable gets set ** by the bridge server during protocol initialization to 'n' in the ** three charater listen address 'xxn'. Later, while resolving the ** three character portname into port number by GCwintcp_port routine ** it assumes that this port is already in use even though it is not ** the case. ** Added server_type to determine the GCF server type. ** The error messages from errlog.log are the following: ** rajus01 ::[R3\BRIDGE\12c4 , 4804 , ffffffff]: Tue Feb 19 ** 19:49:27 2008 E_GC2808_NTWK_OPEN_FAIL Network open failed for ** protocol TCP_IP, port R3; status follows. ** rajus01 ::[R3\BRIDGE\12c4 , 4804 , ffffffff]: Tue Feb 19 ** 19:49:27 2008 E_CL2787_GC_OPEN_FAIL An attempted network open ** failed. ** Change description: ** The code that clears the third character in the listen address ** specified in the config.dat has been removed. This ** appears to be a wrong assumption in the protocol driver based ** on the documentation in "Appendix A:TCP/IP protocol, Listen ** Address Format seciton of Connectivity Guide". With these ** changes the protocol driver will behave the way UNIX does. ** ** WARNING: This DOES introduce the behavioural changes in the ** following cases when starting one or more servers by increa- ** sing the startup count in config.dat. ** ** Case 1: ** Both tcp_ip and win_tcp status are set to ON with Listen ** Addresses II5 and II5 for example. ** New behaviour: The GCF server will come up and listen on ** one protocol using port II5, but will fail on the other ** protocol. ** Original behaviour: ** The GCF server will listen on port II5 on the first ** protocol and the second one will listen on II6. ** This seems to be a bug in the driver as this is not the ** behaviour documented in the connectivity guide. ** Case 2: ** Both tcp_ip and win_tcp status are set to ON with Listen ** Addresses (win_tcp=II, tcp_ip = II1). ** Original behaviour: ** First GCF server will come up OK (II0, II1). The second ** GCF server will come up fine too ( II2, II3 ). ** New Behaviour: ** First GCF server will come up fine. The second GCF server ** will fail for tcp_ip protocol, but will come up on win_tcp ** protocol. This doesn't seem to be much of an issue because ** the second GCF server will still come up using win_tcp. ** 13-Apr-2010 (Bruce Lunsford) SIR 122679 ** Set wsd->pce_driver from GCC PCT rather than from ex-global ** WS_wintcp. */ STATUS GCwintcp_init(GCC_PCE * pptr, GCC_WINSOCK_DRIVER *wsd) { char *ptr = NULL; char real_name_size[] = "100"; char *host, *server_id, *port_id; char config_string[256]; char install[32]; //II_INSTALLATION code /* ** Get set up for the PMget call. */ PMinit(); if( PMload( NULL, (PM_ERR_FUNC *)NULL ) != OK ) PCexit( FAIL ); /* ** Construct the network port identifier. */ host = PMhost(); server_id = PMgetDefault(3); if (!server_id) server_id = "*" ; STprintf( config_string, ERx("!.wintcp.port"), SystemCfgPrefix, host, server_id); /* ** Search config.dat for a match on the string we just built. ** If we don't find it, then use the value for II_INSTALLATION ** failing that, default to II. */ if ((PMget( config_string, &port_id ) != OK) || (port_id == NULL )) { NMgtAt("II_INSTALLATION", &ptr); port_id = install; if (ptr != NULL && *ptr != '\0') { STcopy(ptr, port_id); } else { STcopy(SystemVarPrefix, port_id); } } STcopy(port_id, pptr->pce_port); GCTRACE(1)("GCwintcp_init: port = %s\n", pptr->pce_port ); /* ** Fill in protocol-specific info */ wsd->addr_len = sizeof( struct sockaddr_in ); wsd->sock_fam = AF_INET; wsd->sock_type = SOCK_STREAM; wsd->sock_proto = 0; wsd->block_mode = FALSE; wsd->pce_driver = pptr->pce_driver; /* ** Get trace variable */ ptr = NULL; NMgtAt( "II_WINTCP_TRACE", &ptr ); if ( !(ptr && *ptr) && PMget("!.wintcp_trace_level", &ptr) != OK ) { GCWINTCP_trace = 0; } else { GCWINTCP_trace = atoi( ptr ); } return OK; }
FUNC_EXTERN VOID IIFGti_tblindx(); extern FILE *outfp; extern METAFRAME *G_metaframe; /* static's */ static VOID fgqdelete(); static VOID fgqinsert(); static VOID fgqselect(); static VOID fgqmselect(); static VOID fgqdselect(); static VOID fgqupdate(); static VOID check_options(); static i4 check_section(); static const char _and[] = ERx("AND"); static const char _delete[] = ERx("delete"); static const char _detail[] = ERx("detail"); static const char _insert[] = ERx("insert"); static const char _select[] = ERx("select"); static const char _master[] = ERx("master"); static const char _master_detail[] = ERx("master_detail"); static const char _null[] = ERx(""); static const char _repeat[] = ERx("repeated"); static const char _noterm[] = ERx("noterm"); static const char _repeated[] = ERx("REPEATED "); static const char _update[] = ERx("update"); static char *fgpad; static i4 sectdx[TAB_DETAIL+1][2];
/* GLOBALDEF's */ /* extern's */ GLOBALREF FILE *outfp; GLOBALREF METAFRAME *G_metaframe; FUNC_EXTERN bool IIFGnkf_nullKeyFlags(); FUNC_EXTERN MFTAB *IIFGpt_pritbl(); FUNC_EXTERN i4 IIFGnkc_nullKeyCols(); FUNC_EXTERN MFCOL *IIFGmj_MasterJoinCol(); FUNC_EXTERN char *IIFGbuf_pad(); /* static's */ static VOID genSetNulKeys(); static const char _null[] = ERx(""); static const char _dot[] = ERx("."); /*{ ** Name: IIFGsf_SetNullKeyFlags - Gen 4gl to set Nullable key Flag fields. ** ** Description: ** Process ##GENERATE SET_NULL_KEY_FLAGS [ MASTER | DETAIL ] statement. ** ** Create 4gl statements to set the values of the Flag fields that we ** need to use when a table has NULLable keys and/or NULLable optimistic ** locking columns. ** Generated statements look like: ** ** IF (<name of NULLable hidden key field or column> IS NULL) THEN ** iiNullKeyFlag1 = 1;
** Unicode data that gets through to the tm and provide a means of ** altering the default with II_UNICODE_SUBS environment varaiable. ** 15-Sep-2008 (jonj) ** SIR 120874: Add ad_dberror inside adf_errcb in ADF_CB static. ** 05-Feb-2009 (wanfr01) ** Bug 121617 ** Do not blindly copy 4 bytes in IIUGnfNowFunc because you might ** be copying the value into a long rather than an i4. */ static bool done = FALSE; static ADF_CB cb = { NULL, /* adf_srv_cb */ DB_US_DFMT, /* adf_dfmt */ {ERx("$"),ERx(""),DB_LEAD_MONY,2}, /* adf_mfmt */ { TRUE, '.' }, /* adf_decimal */ { /* adf_outarg */ -1, /* .ad_c0width */ -1, /* .ad_t0width */ -1, /* .ad_i1width */ -1, /* .ad_i2width */ -1, /* .ad_i4width */ -1, /* .ad_f4width */ -1, /* .ad_f8width */ -1, /* .ad_f4prec */ -1, /* .ad_f8prec */ -1, /* .ad_i8width */ -1, /* .ad_2_rsvd */ NULLCHAR, /* .ad_f4style */ NULLCHAR, /* .ad_f8style */
** OK if everything ok. ** status, usually FAIL, if anything goes wrong. ** ** History: ** 9-jun-1987 (Joe) ** Initial Version ** 22-mar-94 (donc) Bug 59981 ** Replace CI_PART_RUNTIME in preference for CI_ABF_IMAGE */ /* Parameter Description */ static ARG_DESC args[] = { /* Required */ {ERx("database"), DB_CHR_TYPE, FARG_PROMPT, NULL}, {ERx("application"), DB_CHR_TYPE, FARG_PROMPT, NULL}, /* Internal optional */ {ERx("equel"), DB_CHR_TYPE, FARG_FAIL, NULL}, /* Optional */ {ERx("user"), DB_CHR_TYPE, FARG_FAIL, NULL}, {ERx("open"), DB_BOO_TYPE, FARG_FAIL, NULL}, {ERx("warning"), DB_BOO_TYPE, FARG_FAIL, NULL}, {ERx("5.0"), DB_BOO_TYPE, FARG_FAIL, NULL}, {ERx("groupid"), DB_CHR_TYPE, FARG_FAIL, NULL}, {ERx("roleid"), DB_CHR_TYPE, FARG_FAIL, NULL}, {ERx("password"), DB_BOO_TYPE, FARG_FAIL, NULL}, {ERx("force"), DB_BOO_TYPE, FARG_FAIL, NULL}, {ERx("executable"), DB_CHR_TYPE, FARG_FAIL, NULL}, {ERx("connect"), DB_CHR_TYPE, FARG_FAIL, NULL}, {ERx("constants_file"), DB_CHR_TYPE, FARG_FAIL, NULL},
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); }
** The number of longnat indices that can fit on each page following ** the leading index page. */ #define PERBLOCK (sizeof(INDEX_PAGE)/sizeof(i4)) #define SRECFACTOR (sizeof(INDEX_PAGE)/512) /* ** Language table ** ** This table is used to get directory name and internal code. ** (in ERlangcode and ERlangstr) */ GLOBALDEF ER_LANGT_DEF ER_langt[] = { ERx("english"), 1 , ERx("japanese"), 2 , ERx("french"), 3 , ERx("flemish"), 4 , ERx("german"), 5 , ERx("italian"), 6 , ERx("dutch"), 7 , ERx("finnish"), 8 , ERx("danish"), 9 , ERx("spanish"), 10 , ERx("swedish"), 11 , ERx("norwegian"), 12 , ERx("hebrew"), 13 , ERx("korean"), 14 , ERx("chinese"), 15 , ERx("thai"), 16 ,
STATUS gca_ns_init( VOID ) { #ifdef GCF_EMBEDDED_GCN char *ptr, host[ 50 ]; char *pm_default[ PM_MAX_ELEM ]; i4 count; STATUS status = OK; /* ** We do not want to initialize the embedded Name Server ** interface if this is the actual Name Server. The Name ** Server initializes the interface before initializing ** GCA, so check to see if IIGCn_static is initialized, ** indicating that gcn_init() has already been called. */ if ( IIGCn_static.maxsessions ) return( OK ); /* ** Check to see if tracing of Name Server code ** is enabled (for whoever we are) before resetting ** PM for the Name Server. */ gcu_get_tracesym( "II_GCN_TRACE", "!.gcn_trace_level", &ptr ); if ( ptr && *ptr ) CVal( ptr, &IIGCn_static.trace ); /* ** Save current PM defaults and set up for Name Server. */ for( count = 0; count < PM_MAX_ELEM; count++ ) pm_default[ count ] = PMgetDefault( count ); PMsetDefault( 0, SystemCfgPrefix ); /* Name Server defaults */ PMsetDefault( 1, PMhost() ); PMsetDefault( 2, ERx( "gcn" ) ); for( count = 3; count < PM_MAX_ELEM; count++ ) PMsetDefault( count, NULL ); /* ** Initialize embedded Name Server. */ GChostname( host, sizeof( host ) ); if ( gcn_srv_init() != OK || gcn_srv_load( host, NULL ) != OK ) status = E_GC0013_ASSFL_MEM; /* ** Reset PM defaults. */ for( count = 0; count < PM_MAX_ELEM; count++ ) PMsetDefault( count, pm_default[ count ] ); return( status ); #else /* GCA_EMBEDDED_GCN */ return( OK ); #endif /* GCA_EMBEDDED_GCN */ }
/* ** Name: GClanman_init ** Description: ** LANMAN inititialization function. This routine is called from ** GCpinit() -- the routine GCC calls to initialize protocol drivers. ** ** This function does initialization specific to the protocol: ** Creates Events and Mutex's for the protocol ** Finds and saves a pointer to it's input event Q. ** Fires up the thread which will do asynch I/O ** History: ** 11-Nov-93 (edg) ** created. ** 15-jul-95 (emmag) ** Use a NULL Discretionary Access Control List (DACL) for ** security, to give implicit access to everyone. ** 23-Feb-1998 (thaal01) ** Make space for port_id, stops gcc crashing on startup, sometimes. ** 13-may-2004 (somsa01) ** Updated config.dat string used to retrieve port information such ** that we do not rely specifically on the GCC port. ** 06-Aug-2009 (Bruce Lunsford) Sir 122426 ** Change arglist pointer in _beginthreadex for async_thread from ** uninitialized "dummy" to NULL to eliminate compiler warning ** and possible startup problem. */ STATUS GClanman_init(GCC_PCE * pptr) { char *ptr, *host, *server_id, *port_id; char config_string[256]; char buffer[MAX_COMPUTERNAME_LENGTH + 1]; int real_name_size = MAX_COMPUTERNAME_LENGTH + 1; i4 i; int tid; HANDLE hThread; int status; SECURITY_ATTRIBUTES sa; char port_id_buf[8]; port_id = port_id_buf; iimksec (&sa); /* ** Look for trace variable. */ NMgtAt( "II_LANMAN_TRACE", &ptr ); if ( !(ptr && *ptr) && PMget("!.lanman_trace_level", &ptr) != OK ) { GCLANMAN_trace = 0; } else { GCLANMAN_trace = atoi( ptr ); } /* ** Create MUTEX and EVENT for the input queue of this protocol ** driver. */ if ( ( hMutexThreadInQ = CreateMutex(&sa, FALSE, NULL) ) == NULL ) { return FAIL; } GCTRACE(3)( "GClanman_init: MutexInQ Handle = %d\n", hMutexThreadInQ ); if ( ( hEventThreadInQ = CreateEvent(&sa, FALSE, FALSE, NULL)) == NULL ) { CloseHandle( hMutexThreadInQ ); return FAIL; } GCTRACE(3)( "GClanman_init: EventInQ Handle = %d\n", hEventThreadInQ ); GCTRACE(4)( "Start GClanman_init\n" ); /* ** Get set up for the PMget call. */ PMinit(); if( PMload( NULL, (PM_ERR_FUNC *)NULL ) != OK ) PCexit( FAIL ); /* ** Construct the network port identifier. */ host = PMhost(); server_id = PMgetDefault(3); if (!server_id) server_id = "*" ; STprintf( config_string, ERx("!.lanman.port"), SystemCfgPrefix, host, server_id); /* ** Search config.dat for a match on the string we just built. ** If we don't find it, then use the value for II_INSTALLATION ** failing that, default to II. */ PMget( config_string, &port_id ); if (port_id == NULL ) { NMgtAt("II_INSTALLATION", &ptr); if (ptr != NULL && *ptr != '\0') { STcopy(ptr, port_id); } else { STcopy(SystemVarPrefix, port_id); } } NMgtAt( "II_NETBIOS_NODE", &ptr ); if ( !ptr || !*ptr ) { /* ** Get Computer Name into buffer. */ *buffer = (char)NULL; GetComputerName( buffer, &real_name_size ); if ( !*buffer ) STcopy( "NONAME", buffer ); ptr = buffer; } /* ** MyName holds ID for outgoing connections. */ STpolycat( 2, ptr, "_", MyName ); /* ** Create listen port ID. */ STpolycat( 3, ptr, "_", port_id, GCc_listen_port ); CVupper( MyName ); CVupper( GCc_listen_port ); STcopy( GCc_listen_port, pptr->pce_port ); GCTRACE(2)("GClanman_init: port = %s\n", pptr->pce_port ); /* ** Go thru the the protocol threads event list and find the index ** of the lanman thread. Set the Global Tptr for easy reference ** to the event q's for this protocols thread. */ for ( i = 0; i < IIGCc_proto_threads.no_threads; i++ ) { THREAD_EVENTS *p = &IIGCc_proto_threads.thread[i]; if ( !STcompare( LANMAN_ID, p->thread_name ) ) { Tptr = p; break; } } if ( Tptr == NULL ) { CloseHandle( hEventThreadInQ ); CloseHandle( hMutexThreadInQ ); return FAIL; } /* ** Finally we start the asynchronous I/O thread */ hThread = (HANDLE)_beginthreadex(&sa, GC_STACK_SIZE, (LPTHREAD_START_ROUTINE) GClanman_async_thread, NULL, (unsigned long)NULL, &tid); if (hThread) { CloseHandle(hThread); } else { status = errno; GCTRACE(1)("GClanman_init: Couldn't create thread errno = %d '%s'\n", status, strerror(status) ); return FAIL; } return OK; }
VOID s_break() { /* internal declarations */ i4 tok_type; /* next token type */ i4 rtn_char; /* ** dummy variable for s_g_skip() ** and real variable for ** s_g_ident(). */ char *name; /* break name */ bool err; char nrml_buf[(FE_MAXNAME + 1)]; /* start of routine */ if (St_b_given) { s_error(0x3A6, NONFATAL, NULL); s_cmd_skip(); return; } St_b_given = TRUE; save_em(); /* store aside the values of Command fields */ /* Initialize the fields in Command */ STcopy(NAM_BREAK, Ctype); STcopy(ERx(" "), Csection); STcopy(ERx(" "), Ccommand); if (Cact_ren == NULL) { s_error(0x38A, FATAL, NULL); } Csequence = Cact_ren->ren_bcount; err = FALSE; while (!err) { tok_type = s_g_skip(TRUE, &rtn_char); switch (tok_type) { case TK_ENDFILE: case TK_PERIOD: goto allexit; case TK_COMMA: break; case TK_ALPHA: case TK_QUOTE: case TK_DOLLAR: if (tok_type == TK_ALPHA) { name = s_g_ident(FALSE,&rtn_char, FALSE); if (rtn_char != UI_REG_ID) { s_error(0x39D,NONFATAL, name,NULL); s_cmd_skip(); err = TRUE; break; } IIUGdbo_dlmBEobject(name,FALSE); } else if (tok_type == TK_QUOTE) /* Delim ID */ { if (!St_xns_given) { s_error(0x39D,NONFATAL, name,NULL); s_cmd_skip(); err = TRUE; break; } name = s_g_ident(FALSE,&rtn_char, FALSE); if (rtn_char != UI_DELIM_ID) { s_error(0x39D,NONFATAL, name,NULL); s_cmd_skip(); err = TRUE; break; } _VOID_ IIUGdlm_ChkdlmBEobject(name, &nrml_buf[0], FALSE); name = &nrml_buf[0]; } else { name = s_g_name(FALSE); IIUGdbo_dlmBEobject(name,FALSE); } if (s_sbr_find(name) != NULL) { /* already specified */ s_error(0x39E, NONFATAL, name, NULL); s_cmd_skip(); err = TRUE; break; } /* name not specified. Add it */ s_sbr_add(name); STcopy(name,Cattid); _VOID_ s_w_row(); break; default: s_error(0x39D, NONFATAL, NULL); s_cmd_skip(); err = TRUE; break; } } allexit: get_em(); }
** 30-mar-2004 (gupsh01) ** Added getQinfoParm as input parameter to II_sw... functions. **/ # define MAX_TMWORDS 6 GLOBALDEF bool RStwo_phase = TRUE; static i4 high_limit = 0; static i4 low = 0; static II_PTR dtrans_id_handle = NULL; static bool first = TRUE; static char *log_format = ERx("%d!%d!%d!%d!%s!%s!%d!%d!%d!%s!%s\n"); static void mktimestamp(char *timestr, char *timestamp); /*{ ** Name: RScommit - two-phase commit processing ** ** Description: ** Prepares to commit locally, commits remotely, commits locally. ** Logs each step of the commit so that a reasonable attempt can ** be made to recover if it does not complete. ** ** Inputs: ** target - target database, CDDS and connection number
** 31-aug-2000 (hanch04) ** cross change to main ** replace nat and longnat with i4 ** 01-aug-2003 (somsa01) ** Added NO_OPTIM for i64_win to prevent oslsql.exe from SEGVing ** during the run of 4GL SEP test fgl10.sep . ** 17-dec-2008 (joea) ** Replace READONLY/WSCREADONLY by const. ** 26-Aug-2009 (kschendel) b121804 ** Void prototypes to keep gcc 4.3 happy. */ GLOBALREF char osDecimal; /* referenced in osmkconst() */ bool osckadfproc(); /* _Is_ prefix for postfix RELOP operators */ static const char _Is_[] = ERx("is "); /*{ ** Name: osmknode() - Make a Node. ** ** History: ** 01/90 (jhw) ** Modify procedure check so all UNDEF procedures ** are also not ADF functions. ** 04/07/91 (emerson) ** Modifications for local procedures: ** Doctor VALUE node if symbol is a local procedure. ** 09/20/92 (emerson) ** Use N_ROW bit of n_flags instead of n_sub. Added logic to set ** new N_COMPLEXOBJ, N_TABLEFLD, and N_ROW bits in n_flags. ** Added logic to place "value" into the new n_targlfrag member
** Added additional error handling for Vista OS. ** This program will recognize ERROR_ELEVATION_REQUIRED ** and ERROR_ACCESS_DENIED errors as Vista's lack ** of privileges. */ /* ** mkming hints NEEDLIBS = COMPATLIB PROGRAM = iirundbms */ char bad_msg[GL_MAXNAME] = ERx("\nFAIL\n"); char iirun[GL_MAXNAME] = ERx("iirun.exe"); char iirundbms[GL_MAXNAME] = ERx("iirundbms"); main(int argc, char **argv) { char *value = NULL; char *host, *server_type, *command_line; char *server_location, *env, *arguments; u_i4 command_line_length; char config_string[256]; char iidbms[256]; STARTUPINFO si; PROCESS_INFORMATION ProcessInfo; BOOL Status;
void main(int argc, char *argv[]) { #define MAXBUF 4095 #define MAX_NAME 32 char buf[ MAXBUF+1 ]; char repbuf[ MAXBUF+1 ]; int iarg, ibuf, ichr; char *database = NULL; char username[MAX_NAME] = {""}; LOCATION tloc; LOCATION loc_out; LOCATION loc_in; char loc_buf[MAX_LOC + 1]; char tmp_buf[MAX_LOC + 1]; char otmp_buf[MAX_LOC + 1]; char dev[MAX_LOC + 1]; char path[MAX_LOC + 1]; char fprefix[MAX_LOC + 1]; char fsuffix[MAX_LOC + 1]; char version[MAX_LOC + 1]; char odev[MAX_LOC + 1]; char opath[MAX_LOC + 1]; char ofprefix[MAX_LOC + 1]; char ofsuffix[MAX_LOC + 1]; char oversion[MAX_LOC + 1]; char *new_filename; char *temploc; CL_ERR_DESC err_code; char *p1 = NULL; bool usergiven = FALSE; bool Repmod = FALSE; bool nowait = TRUE; char waitflag[3]; if (argc < 2) { usage(); PCexit(FAIL); } /* Get the temporary path location */ NMloc(TEMP, PATH, NULL, &tloc); LOcopy(&tloc, tmp_buf, &loc_in); LOtos(&tloc, &temploc); LOcopy(&tloc, otmp_buf, &loc_out); /* Get the new filename for path location */ LOuniq(ERx("usrmod"), ERx("sql"), &loc_in); LOtos(&loc_in, &new_filename); LOuniq(ERx("usrmod"), ERx("out"), &loc_out); /* Get just the filename for copydb code */ LOdetail(&loc_in, dev, path, fprefix, fsuffix, version); if ( *fsuffix != '\0' ) { STcat(fprefix, "."); STcat(fprefix, fsuffix); } /* Get just the filename for copydb code */ LOdetail(&loc_out, odev, opath, ofprefix, ofsuffix,oversion); STcat(ofprefix, "."); STcat(ofprefix, ofsuffix); STprintf(buf, ERx("copydb -with_modify -nodependency_check -with_index -with_comments -no_persist -parallel -no_repmod -group_tab_idx -no_warn -d\"%s\" -infile=\"%s\" -outfile=\"%s\"" ), temploc, fprefix,ofprefix); ibuf = STlength(buf); for (iarg = 1; (iarg < argc) && (ibuf < MAXBUF); iarg++) { if( STscompare( argv[ iarg ], 1, ERx( "-" ), 1 ) == 0 ) { p1 = argv[ iarg ]; (void) CMnext( p1 ); if ( (STlength(p1) == 0) || !(((STscompare( p1, 1, ERx( "u" ), 1 ) == 0 ) || (STscompare( p1, 5, ERx( "noint" ), 5 ) == 0 ) || (STscompare( p1, 6, ERx( "repmod" ), 6 ) == 0 ) || (STscompare( p1, 1, ERx( "w" ), 6 ) == 0 ) || (STscompare( p1, 6, ERx( "online"), 6 ) == 0 )) && ( argc > 2 ) )) { usage(); PCexit(FAIL); } /* ** Get the username if the -u flag is passed in ** with the input */ if (STscompare( p1, 1, ERx( "u" ), 1 ) == 0 ) { STcopy(&argv[iarg][2] , (char *)&username); usergiven = TRUE; } else if (STscompare( p1, 1, ERx( "r" ), 1 ) == 0 ) { Repmod = TRUE; continue; } else if (STscompare( p1, 1, ERx( "w"), 1 ) == 0) { nowait = TRUE; continue; } } if( STscompare( argv[ iarg ], 1, ERx( "+" ), 1 ) == 0 ) { p1 = argv[ iarg ]; (void) CMnext( p1 ); if (STscompare( p1, 1, ERx( "w" ), 1 ) == 0 ) { nowait = FALSE; continue; } else { usage(); PCexit(FAIL); } } if((database == NULL) && (STscompare( argv[ iarg ], 1, ERx( "+" ), 1 ) != 0) && (STscompare( argv[ iarg ], 1, ERx( "-" ), 1 ) != 0)) { database = argv[ iarg ]; } buf[ibuf++] = ' '; for (ichr = 0; (argv[iarg][ichr] != '\0') && (ibuf < MAXBUF); ichr++, ibuf++) { buf[ibuf] = argv[iarg][ichr]; } buf[ibuf] = '\0'; } /* ** Execute the command. */ if( PCcmdline((LOCATION *) NULL, buf, PC_WAIT, (LOCATION *) NULL, &err_code) != OK ) PCexit(FAIL); /* ** we should run the sql script ** sql dbname < new_filename ** if -u flag given then run: ** sql -uusername dbname < new_filename */ if (usergiven) STprintf(buf, ERx( "sql -u%s -s %s <%s" ), username, database, new_filename ); else STprintf(buf, ERx( "sql -s %s <%s" ), database, new_filename ); /* ** Execute the command. */ if( PCcmdline((LOCATION *) NULL, buf, PC_WAIT, (LOCATION *) NULL, &err_code) != OK ) { STprintf(buf, ERx(" Warning: Non-persistent objects associated with the base table\n in the failed query may have been lost. Please refer to\n %s\n to determine whether any corrective action is required.\n"), new_filename); SIfprintf(stdout, buf); PCexit(FAIL); } /* Now execute the repmod command if the replicator ** modify is also required by the user (-repmod) */ if (Repmod) { if (nowait) STcopy("-w", waitflag) ; else STcopy("+w", waitflag) ; if (usergiven) STprintf(repbuf, ERx( "repmod -u%s %s %s" ), username, database, waitflag ); else STprintf(repbuf, ERx( "repmod %s %s" ), database, waitflag ); if( PCcmdline((LOCATION *) NULL, repbuf, PC_WAIT, (LOCATION *) NULL, &err_code) != OK ) PCexit(FAIL); } /* ** Delete the location */ LOdelete(&loc_in); LOdelete(&loc_out); PCexit(OK); }
/*{ ** Name: RSstats_init - initialize monitor statistics ** ** Description: ** Initializes the Replicator Server statistics memory segment. ** ** Inputs: ** none ** ** Outputs: ** none ** ** Returns: ** OK Function completed normally. */ STATUS RSstats_init() { STATUS status; char *val; i4 num_targs; SIZE_TYPE pages_alloc; u_i4 stats_size; RS_TARGET_STATS *targ; RS_TARGET_STATS *targ_end; RS_TABLE_STATS *tbl; RS_CONN *conn; RS_TBLDESC *tbl_info; CL_SYS_ERR sys_err; char server_num[4]; PMsetDefault(1, PMhost()); STprintf(server_num, ERx("%d"), (i4)RSserver_no); PMsetDefault(3, server_num); status = PMget(ERx("II.$.REPSERV.$.SHARED_STATISTICS"), &val); if (status == OK && STbcompare(val, 0, ERx("ON"), 0, TRUE) == 0) shared_stats = TRUE; num_targs = RSnum_conns - TARG_BASE; stats_size = sizeof(RS_MONITOR) + sizeof(RS_MONITOR) % sizeof(ALIGN_RESTRICT); targ_size = sizeof(RS_TARGET_STATS) + sizeof(RS_TARGET_STATS) % sizeof(ALIGN_RESTRICT); if (shared_stats) tbl_size = sizeof(RS_TABLE_STATS) + sizeof(RS_TABLE_STATS) % sizeof(ALIGN_RESTRICT); else tbl_size = 0; num_pages = (stats_size + num_targs * (targ_size + RSrdf_svcb.num_tbls * tbl_size)) / ME_MPAGESIZE + 1; if (shared_stats) { STprintf(sm_key, ERx("%s.%03d"), RS_STATS_FILE, RSserver_no); status = MEget_pages(ME_SSHARED_MASK | ME_CREATE_MASK | ME_MZERO_MASK | ME_NOTPERM_MASK, num_pages, sm_key, (PTR *)&mon_stats, &pages_alloc, &sys_err); if (status == ME_ALREADY_EXISTS) { status = MEsmdestroy(sm_key, &sys_err); if (status == OK) status = MEget_pages(ME_SSHARED_MASK | ME_CREATE_MASK | ME_MZERO_MASK | ME_NOTPERM_MASK, num_pages, sm_key, (PTR *)&mon_stats, &pages_alloc, &sys_err); } } else { mon_stats = (RS_MONITOR *)MEreqmem(0, num_pages * ME_MPAGESIZE, TRUE, &status); } if (status != OK) return (status); mon_stats->server_no = RSserver_no; mon_stats->local_db_no = RSlocal_conn.db_no; PCpid(&mon_stats->pid); mon_stats->startup_time = TMsecs(); mon_stats->num_targets = num_targs; mon_stats->num_tables = RSrdf_svcb.num_tbls; STcopy(RSlocal_conn.vnode_name, mon_stats->vnode_name); STcopy(RSlocal_conn.db_name, mon_stats->db_name); mon_stats->target_stats = (RS_TARGET_STATS *)((PTR)mon_stats + stats_size); targ_end = (RS_TARGET_STATS *)((PTR)mon_stats->target_stats + mon_stats->num_targets * (targ_size + tbl_size * mon_stats->num_tables)); for (conn = &RSconns[TARG_BASE], targ = mon_stats->target_stats; targ < targ_end; ++conn, targ = (RS_TARGET_STATS *)((PTR)targ + targ_size + tbl_size * mon_stats->num_tables)) { targ->db_no = conn->db_no; STcopy(conn->vnode_name, targ->vnode_name); STcopy(conn->db_name, targ->db_name); if (shared_stats) { targ->table_stats = (RS_TABLE_STATS *)((PTR)targ + targ_size); for (tbl_info = RSrdf_svcb.tbl_info, tbl = targ->table_stats; tbl < targ->table_stats + mon_stats->num_tables; ++tbl, ++tbl_info) { tbl->table_no = tbl_info->table_no; STcopy(tbl_info->table_owner, tbl->table_owner); STcopy(tbl_info->table_name, tbl->table_name); } } } return (OK); }