STATUS SIeqinit() { # if defined (UNIX) || defined (NT_GENERIC) /* Just verify the environment is normal */ if (!SIisopen(stdin)) return(INCHAN_ERR); if (!SIisopen(stdout)) return(OUTCHAN_ERR); if (!SIisopen(stderr)) return(ERRCHAN_ERR); return(OK); # endif # ifdef VMS LOCATION loc; FILE *fp; char buf[MAX_LOC +1]; /* ** If stdin cannot be opened, attempt to open stdout, stderr for ** possible error messages. */ STATUS in_status, out_status, err_status; if (SIisopen(stdin)) return (OK); STcopy("SYS$INPUT", buf); LOfroms(PATH & FILENAME, buf, &loc); in_status = SIopen(&loc, "r", &fp); STcopy("SYS$OUTPUT", buf); LOfroms(PATH & FILENAME, buf, &loc); out_status = SIopen(&loc, "w", &fp); STcopy("SYS$ERROR", buf); LOfroms(PATH & FILENAME, buf, &loc); err_status = SIopen(&loc, "w", &fp); if (in_status != OK){ if (in_status == iicl__siopen) return(INCHAN_ERR); else return (in_status); } if (out_status != OK){ if (out_status == iicl__siopen) return(OUTCHAN_ERR); else return (out_status); } if (err_status == iicl__siopen) return(ERRCHAN_ERR); else return (err_status); /* OK or a real status */ # endif }
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); }
STATUS append_file(char *filename) { LOCATION fileloc ; FILE *fileptr = NULL ; char buffer [SCR_LINE] ; if (LOfroms(FILENAME & PATH,filename,&fileloc) == OK && SEP_LOexists(&fileloc) && SIopen(&fileloc,ERx("r"),&fileptr) == OK) { while (SIgetrec(buffer,SCR_LINE,fileptr) == OK) append_line(buffer,0); return(SIclose(fileptr)); } else return(FAIL); }
/*{ ** 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: NMwritesyms - write the symbol table list to file. ** ** Description: ** Write the symbol table list back out to the file. ** ** This duplicates the function in ingunset.c, but shouldn't be in ** compatlib because no one else has any business writing the file. ** ** Inputs: ** none. ** ** Output: ** none. ** ** Returns: ** OK Function completed normally. ** FAIL Function completed abnormally. ** ** History: ** 20-jul-87 (mmm) ** Updated to meet jupiter standards. ** 14-apr-89 (arana) ** When LOlast was added to update symbol table mod time, ** return value was saved off but not returned. ** 15-jul-93 (ed) ** adding <gl.h> after <compat.h> ** 29-sep-94 (cwaldman) ** Changed check of NMopensyms return value to compare against ** (FILE *)NULL (was NULL). ** Changed write routine to write into a temporary file first, ** check whether this file has been written OK, and rename ** temporary file to symbol.tbl if it is alright. This is part ** of the fix for bug 44445 (symbol.tbl disappears). There is ** still a slight chance of something going wrong during the ** rename, but in that case variables are at least preserved ** in symbol.tmp. ** 19-oct-94 (abowler) ** Minor correction to change above. Cal to SIopen should be ** passed address of location structure. (Didn't show up as ** a bug on su4_u42 !) ** 28-feb-95 (cwaldman) ** Amendment to change on 29 Sep. Part of the check whether ** the temporary symbol table had been written OK was to check ** the file size. The check would return the file size if ** check was OK and 0 otherwise. If a 0 was returned, the old ** symbol.tbl would not be replaced. This made it impossible ** to 'ingunset' the last variable in a symbol.tbl. Changed ** 'OK-check' to use -1 as error indicator. ** 02-jul-1996 (sweeney) ** Apply umask fix (bug #71890) from ingres63p ** 07-apr-2004 (somsa01) ** Added backup of symbol.tbl logic. */ STATUS NMwritesyms() { register SYM *sp; FILE *fp, *tfp = NULL; register i4 status = OK; register i4 closestat; char buf[ MAXLINE + NULL_NL_NULL ]; char tbuf[ MAXLINE + NULL_NL_NULL ]; i4 flagword, size, symcount = 0, bksymcount; STATUS retval; LOCATION t_loc; LOINFORMATION loinfo; bool perform_backup = TRUE; OFFSET_TYPE bk_size; /* ** ensure sensible umask for symbol.tmp, as it will become symbol.tbl */ PEsave(); PEumask("rw-r--"); if ((FILE *)NULL == (fp = NMopensyms( "r" ))) { PEreset(); return (NM_STOPN); } SIclose(fp); LOcopy(&NMSymloc, tbuf, &t_loc); if ( OK != LOfstfile("symbol.tmp", &t_loc) || OK != SIopen(&t_loc, "w", &tfp)) { return (NM_STOPN); } for ( sp = s_list; sp != NULL; sp = sp->s_next ) { (VOID) STpolycat( 3, sp->s_sym, "\t", sp->s_val, buf ); STmove( buf, ' ', MAXLINE, buf ); buf[ MAXLINE - 1 ] = '\n'; buf[ MAXLINE ] = '\0'; if ( OK != (status = SIputrec(buf, tfp))) break; symcount++; } /* Very interested in close status of file being written */ closestat = SIclose( tfp ); flagword = (LO_I_SIZE); size = (OK == LOinfo(&t_loc,&flagword,&loinfo) ? loinfo.li_size : -1); retval=(status != OK || closestat != OK || size == -1 ? NM_STAPP : OK); /* if file written ok update modification time */ if(retval == OK) { LOrename(&t_loc, &NMSymloc); LOlast(&NMSymloc, &NMtime); #if defined(su4_cmw) /* Now reset the old MAC label if any */ if (NM_got_label) { (void)setcmwlabel(NM_path, &NM_saved_label, SETCL_ALL); NM_got_label=0; } #endif /* ** If we have no backup to check against, just do it. Otherwise, ** make sure our new symbol table differs from the backup by at most ** one symbol before performing a backup. */ if (LOexist(&NMBakSymloc) == OK) { LOsize(&NMBakSymloc, &bk_size); bksymcount = (i4)(bk_size / (MAXLINE + 1)); if (bksymcount != symcount && bksymcount != symcount - 1 && bksymcount != symcount + 1) { perform_backup = FALSE; } } if (perform_backup) { if (SIopen(&NMBakSymloc, "w", &tfp) == OK) { for (sp = s_list; sp != NULL; sp = sp->s_next) { STpolycat(3, sp->s_sym, "\t", sp->s_val, buf); STmove(buf, ' ', MAXLINE, buf); buf[MAXLINE - 1] = '\n'; buf[MAXLINE] = '\0'; if ((status = SIputrec(buf, tfp)) != OK) break; } SIclose(tfp); } } } PEreset(); return (retval); }
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); }
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); }
void main(int argc, char **argv) { int i; char buf[MAX_LOC]; FILE *fp; STATUS status; char *callstmt; i4 casef; char timestr[512]; SYSTIME timeval; char path[512]; char drive[2]; char current_path[512]; if (argc < 3) { SIfprintf(stdout,"Not enough parameters\n"); PCexit(FAIL); } /* ** */ if (!STbcompare(*++argv, STlength("Net"), "Net", STlength("Net"), casef )) callstmt = "@call %II_SYSTEM%\\ingres\\utility\\iisunet"; else if (!STbcompare(*argv, STlength("Dbms"), "Dbms", STlength("Dbms"), casef )) callstmt = "@call %II_SYSTEM%\\ingres\\utility\\iisudbms"; else if (!STbcompare(*argv, STlength("Star"), "Star", STlength("Star"), casef )) callstmt = "@call %II_SYSTEM%\\ingres\\utility\\iisustar"; else if (!STbcompare(*argv, STlength("Vision"), "Vision", STlength("Vision"), casef )) callstmt = "@call %II_SYSTEM%\\ingres\\utility\\iisuabf"; else if (!STbcompare(*argv, STlength("ESQL"), "ESQL", STlength("ESQL"), casef )) callstmt = "@call %II_SYSTEM%\\ingres\\utility\\iisutm"; else PCexit(FAIL); /* ** Set location and file name for the subsequent open. */ strcpy(path,*++argv); strcpy(current_path,*argv+2); strcat(path,"\\ingres\\bin\\ipsetup.bat"); LOfroms(PATH & FILENAME, path, &location); /* ** Open ipsetup.bat so we can append another line. */ if ((status = SIopen(&location, "a", &fp)) != OK) { printf("error opening file\n"); } /* ** Append another line that will call the setup bat files. */ TMnow(&timeval); TMstr(&timeval,×tr); drive[0] = path[0]; drive[1] = '\0'; /* ** Write a statement in the batch file that will set ** the current drive to the drive passed to us. */ SIfprintf(fp,"@%s:\n",drive); /* ** Write a statement in the batch file that will set ** the current path to the path passed to us. */ SIfprintf(fp,"@cd %s\n",current_path); /* ** Write a Remark as a primitive log. */ SIfprintf(fp,"@REM %s installed at %s\n",*argv,timestr); /* ** Now write the call statement that will call the appropiate ** iisu batch file. */ SIfprintf(fp,"%s\n",callstmt); }
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 */
/*{ ** Name: CK_subst - build a CK command from template and requirements ** ** Description: ** This function will search a CK command template file for ** a line meeting the requirements of the inputs and will substitute ** various esacpe sequences with other strings such as file names. ** ** Based on a II_subst of the 5.0 UNIX CL. ** ** Inputs: ** comlen length of cline space ** oper operation - one of 'B'egin, 'E'nd, 'W'ork ** dev device type - one of 'T'ape, 'D'isk ** dir direction - one of 'S'ave, 'R'estore ** type type (device type) 0 for disk, 1 for tape ** locnum location number (sequence or quantity) ** di_l_path length of di path string ** di_path di path string ** ckp_l_path length of checkpoint path string ** ckp_path checkpoint path string ** ckp_l_file length of checkpoint file string ** ckp_file checkpoint file string ** ** Outputs: ** cline space for generated command ** ** Returns: ** CK_FILENOTFOUND template file can't be found ** E_DB_OK ** ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 27-oct-88 (anton) ** Created. ** 16-may-90 (walt) ** Return CK_FILENOTFOUND if the template file (cktmpl.def) can't ** be opened. ** 23-may-1994 (bryanp) ** Modified Walt's 16-may-90 fix to use CK_TEMPLATE_MISSING, rather ** than CK_FILENOTFOUND, since CK_TEMPLATE_MISSING is a more ** specific, and therefore hopefully more useful, error message. ** 03-jan-1995 (dougb) ** Cross-integrate Unix change 415365: ** 02-dec-1994 (andyw) ** Check on granularity for partial backup */ STATUS CK_subst( char *cline, i4 comlen, char oper, char dev, char dir, u_i4 type, u_i4 locnum, u_i4 di_l_path, char *di_path, u_i4 ckp_l_path, char *ckp_path, u_i4 ckp_l_file, char *ckp_file) { STATUS ret_val = OK; auto LOCATION loc; auto char *s; auto FILE *fp; auto char *cp; char *command; command = MEreqmem(0, comlen, TRUE, &ret_val); if (!ret_val) { NMgtAt("II_CKTMPL_FILE", &s); if (s == NULL || *s == EOS) { ret_val = NMf_open("r", "cktmpl.def", &fp); } else { LOfroms( PATH & FILENAME, s, &loc ); ret_val = SIopen( &loc, "r", &fp); } if (ret_val) { ret_val = CK_TEMPLATE_MISSING; } } /* find command line - skip comments and blank lines */ if (!ret_val) { while ((ret_val = SIgetrec(command, comlen, fp)) == OK) { if (*command == '\n') { continue; } if (command[0] == oper && (command[1] == dir || command[1] == 'E') && (command[2] == dev || command[2] == 'E') && (command[3] == 'D' || command[3] == 'E') && command[4] == ':') { break; } } } _VOID_ SIclose(fp); if (!ret_val) { /* found the line - do the substitution */ s = command + 5; cp = cline; while (*s != '\n') { if (*s == '%') { switch (*++s) { case '%': *cp++ = '%'; break; case 'D': CK_lfill(&cp, di_l_path, di_path); break; case 'C': CK_lfill(&cp, ckp_l_path, ckp_path); break; case 'F': CK_lfill(&cp, ckp_l_file, ckp_file); break; case 'A': CK_lfill(&cp, ckp_l_path, ckp_path); # ifdef UNIX *cp++ = '/'; # endif CK_lfill(&cp, ckp_l_file, ckp_file); break; case 'T': *cp++ = type ? '1' : '0'; break; case 'N': CVna(locnum, cp); while (*cp) cp++; break; default: *cp++ = '%'; *cp++ = *s; } ++s; } else { *cp++ = *s++; } } *cp = EOS; } # ifdef xDEBUG TRdisplay("CK_subst %c %c %c: %s\n", oper, dir, dev, cline); # endif return(ret_val); }
/* ** Name: makeutable - make unicode collation element table ** ** Descrription: ** Reads input collation element text file and compiles a table. ** also reads the Unicode character database and adds attributes for ** each character found. Currently we only take note of canonical ** decomposition for normalization. ** ** Inputs: ** desfile - collation element description file ** ** Outputs: ** None ** ** Returns: ** utbl - collation element table ** ** History: ** 14-mar-2001 (stephenb) ** Created ** 5-apr-2001 (stephenb) ** Add code to read unciode character database. ** 17-may-2001 (stephenb) ** Read in combining class from character database. ** 24-dec-2001 (somsa01) ** Modified such that the varsize which is placed in the Unicode ** table is now a SIZE_TYPE rather than an i4. ** 12-dec-2001 (devjo01) ** Make sure 1st overflow entry is properly aligned. ** Add messages to report if files cannot be opened. ** 17-jul-2001 (gupsh01) ** Modified the placing of the decomposition enty to ** decomp structure in the file, to be the first entry. ** 04-Mar-2005 (hanje04) ** Add support for reverse hybrid builds, i.e. 64bit exe needs to ** call 32bit version. ** 17-May-2007 (gupsh01) ** Added support for reverse sorting of the accented characters. ** This is done to support @backwards tag in custom collation file. ** 08-Aug-2007 (kiria01) b118917 ** Detect lines relating to conditional special caseing and ignore them. ** 08-Aug-2007 (gupsh01) ** Fixed the typo for CASE_IGNORABLE setting. Also fixed the ** handling of Final_Sigma in the special_casing.txt. ** 08-Aug-2007 (gupsh01) ** Fixed the decomposition mapping which were not being set for ** composite characters. ** 24-Nov-2008 (gupsh01) ** When alloating the memory for recombination table make sure ** we initialize the buffer. */ static ADUUCETAB * makeutable( char *desfile) { char buf[MAX_UCOL_REC]; FILE *fp; FILE *dfp; LOCATION loc; char table_vers[MAX_UVERS] = ""; i4 lno = 0; char *recptr; char *separator; ADUUCETAB *tab = &w.utab; i4 num_rvals = 0; ADUUCETAB *epointer = (ADUUCETAB *)w.buff; /* entries first */ /* then instructions */ char *ipointer; SIZE_TYPE *varsize; char *tptr; ADU_UCEFILE *rrec = NULL; ADU_UCEFILE *cerec = NULL; char csval[7]; char svalue[21]; char *ceptr; char *comment; u_i4 cval; i4 numce; bool combent; i4 i; /* Stuff to track the size of the recomb_tbl entries */ u_i2 **recomb_def2d; u_i2 *recomb_def1d; char *recombtbl; char *tracker; SIZE_TYPE *recomb_tbl_size; i4 tr = 0; i4 j = 0; STATUS stat; i4 rcbufsz; char *tempbuf; i4 current_bytes; char *upperval; char *lowerval; char *titleval; char *endval; i4 bts = 0; i4 lcnt = 0; i4 tcnt = 0; i4 ucnt = 0; i4 row = 0; i4 col = 0; bool backward_set = FALSE; /* open file */ STcopy(desfile, buf); LOfroms(FILENAME, buf, &loc); if (SIopen(&loc, "r", &fp) != OK) { SIprintf("aducompile: Unable to open input file \"%s\".\n", loc.string ); return NULL; } varsize = (SIZE_TYPE *)(w.buff + ENTRY_SIZE); recomb_tbl_size = (SIZE_TYPE *)(varsize + 1); ipointer = (char*)(recomb_tbl_size + 1); ipointer = ME_ALIGN_MACRO(ipointer, sizeof(PTR)); /* this is a sparse table, make sure we initialize it */ MEfill(INSTRUCTION_SIZE + ENTRY_SIZE, 0, w.buff); *varsize = 0; /* read data */ while (SIgetrec(buf, sizeof(buf), fp) != ENDFILE) { lno++; if (buf[0] == '#') /* comment line */ continue; (VOID)STtrmwhite(buf); if (STcompare(buf, "") == 0) /* blank line */ continue; /* should first find version */ if (table_vers[0] == EOS) { if (STbcompare(buf, 8, "@version", 8, TRUE) == 0) { /* we don't parse the version string, maybe we should */ STlcopy(buf+9, table_vers, MAX_UVERS); continue; } else { SIprintf("Syntax error on line %d, version line must be first \ non-comment line in the file, ignored\n", lno); continue; } } /* then alternate weights (optional), currently un-supported */ if (STbcompare(buf, 10, "@alternate", 10, TRUE) == 0) { SIprintf("Syntax error on line %d, alternate weights are not \ currently supported, ignored\n", lno); continue; } /* now backwards lines (also not currently supported) */ if (STbcompare(buf, 10, "@backwards", 10, TRUE) == 0) { backward_set = TRUE; continue; } /* and rearrange lines */ if (STbcompare(buf, 10, "@rearrange", 10, TRUE) == 0) { bool strend = FALSE; u_i4 rval; for (recptr = buf + 10;;) { /* skip blanks */ if ((recptr = STskipblank(recptr, STlength(recptr))) == NULL) { /* blank string, ignore */ SIprintf("Syntax error on line %d, no characters in \ rearrange list, ignoring\n", lno); strend = TRUE; break; } /* find next comma separator */ if ((separator = STindex(recptr, ",", 0)) == NULL) { strend = TRUE; separator = recptr + 4; } if (separator - recptr != 4) { SIprintf("Syntax error on line %d, characters in a rearrange\ line must be a comma separated list of 4 digit hex values, ABORTING\n", lno); tab = NULL; break; }
/*{ ** Name: maketable - compile a collation description ** ** Description: ** Read a collation description file and create a collation table. ** The table is a modified TRIE structure with a complete map ** at the top level and sparse maps below. ** ** Inputs: ** desfile collation description filename ** ** Outputs: ** none ** ** Returns: ** pointer to collation table on success ** NULL on failure ** ** Exceptions: ** none ** ** Side Effects: ** none ** ** History: ** 03-may-89 (anton) ** Created. ** 17-Jun-89 (anton) ** Moved to ADU from CL ** 17-Jul-89 (anton) ** replace 16 with COL_MULTI and use adulstrinit not aducolinit ** 21-jun-93 (geri) ** Added 2 bugfixes which were in the the 6.4 version: ** 31892: better syntax checking and sane delimiter ** handling; 31993: multiple character pattern match ** rules were not handled correctly. ** 1-oct-04 (toumi01) ** On file-not-found error, make that clear rather than just issuing ** a bogus and misleading syntax error message. ** 1-May-2008 (kibro01) b120307 ** When we find a "+", just check the next character isn't also a "+", ** since it ought to be possible to set the collation relative to "+" ** by having a line "++1:<". */ static ADULTABLE * maketable( char *desfile) { FILE *fp; i4 n; char buf[MAX_LOC]; u_char *s; register i4 lno = 0; register i4 errcnt = 0; i2 *sp, v, t, tt; struct ADUL_tstate *ts; LOCATION loc; ADULcstate cs; STcopy(desfile, buf); LOfroms(FILENAME, buf, &loc); if (SIopen(&loc, "r", &fp) != OK) { SIprintf("aducompile: Unable to open input file \"%s\".\n", loc.string ); return NULL; } w.tab.magic = ADUL_MAGIC; w.tab.nstate = 0; for (n = 0; n < 256; n++) w.tab.firstchar[n] = n * COL_MULTI; while (SIgetrec(buf, sizeof buf, fp) != ENDFILE) { lno++; if (*buf == ':') { /* line is a comment */ continue; } adulstrinit(&w.tab, (u_char*)buf, &cs); v = 0; sp = NULL; while ((t = *(s = adulptr(&cs))) != ':') { /* If this is '+', just confirm that the next character isn't, ** since the construction "++1:<" would be fine, setting < as the ** character 1 place beyond + (kibro01) b120307 */ if (t == '+' && (*(s+1) != '+')) { if (*++s == '*') { v = ADUL_SKVAL; while (*++s != ':' && *s != '\n') continue; if (*s == '\n') { /* syntax error: report line and line number */ SIprintf("Syntax error on line %d: %s", lno, buf); errcnt++; s = NULL; } break; } tt = 0; while ((t = *s - '0') <= 9 && t >= 0) { tt = tt * 10 + t; s++; } adulstrinit(&w.tab, s, &cs); if (sp == NULL) sp = &v; *sp += tt; continue; } if (t == '\n') { /* syntax error - line has no ':' */ SIprintf("Syntax error on line %d: %s", lno, buf); errcnt++; s = NULL; break; } t = adultrans(&cs); adulnext(&cs); if (sp == NULL) { v = t; sp = &v; } else { ts = &w.tab.statetab[w.tab.nstate]; ts->match = *sp; ts->flags = ADUL_LMULT; *sp = w.tab.nstate++ | ADUL_TMULT; ts->nomatch = t; sp = &ts->nomatch; } } if (s == NULL) { /* syntax error occurred */ continue; /* to the next line */ } sp = &w.tab.firstchar[255 & *++s]; ts = NULL; if (*s == '\n') { SIprintf("Syntax error on line %d (no substitution string): %s", lno, buf); continue; } while (*++s != '\n') { while (*sp & ADUL_TMULT) { ts = &w.tab.statetab[*sp & ADUL_TDATA]; if (ts->testchr == *s) { sp = &ts->match; if (*++s == '\n') { goto done; } } else { sp = &ts->nomatch; } } ts = &w.tab.statetab[w.tab.nstate]; ts->match = ts->nomatch = *sp; *sp = ADUL_TMULT | w.tab.nstate++; sp = &ts->match; ts->testchr = *s; ts->flags = ADUL_FINAL; } done: if (ts) ts->flags ^= ADUL_FINAL; *sp = v; } if (errcnt == 0) return &w.tab; return NULL; }
/* ** 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); }