$RL/pr_utilSinceGenv12.diffs050316 --------------------------- Backing up current edited pr_util before re-generating it by genv12: ------------- saturn.cs.uml.edu(35)> cd ..; mv pr_util pr_util050316 saturn.cs.uml.edu(36)> cp -r pr_util050316 pr_util pwd saturn.cs.uml.edu(37)> pwd /nfs/earth/faculty/fac1/lechner/bde2alpha_rl/sandbox/bdecheckout/bde saturn.cs.uml.edu(39)> cvs diff pr_util cvs diff: Diffing pr_util saturn.cs.uml.edu(40)> ------------- saturn.cs.uml.edu(45)> cd pr_util; rm pr*.o pr*.c 94*.ha; lg; cd .. total 692 drwx--x--x 10 lechner 04f522 4096 Mar 16 23:18 . -rwx--x--x 1 lechner 04f522 55745 Mar 16 23:14 .#94sbde_schema.h.1.1.2.22 drwxr-xr-x 24 lechner 04f522 4096 Mar 16 23:17 .. -rwx--x--x 1 lechner 04f522 56018 Mar 16 23:14 94sbde_schema.h drwx--x--- 2 lechner 04f522 4096 Mar 16 23:14 CVS -rwx--x--x 1 lechner 04f522 7553 Mar 16 23:14 Imakefile -rw------- 1 lechner 04f522 39867 Mar 16 23:14 Makefile -rw------- 1 lechner 04f522 39851 Mar 16 23:14 Makefile.bak -rw------- 1 lechner 04f522 808 Mar 16 23:14 Makegenlog -rw------- 1 lechner 04f522 2364 Mar 16 23:14 aareadme -rw------- 1 lechner 04f522 582 Mar 16 23:14 aareadme_pr_util drwx--x--x 2 lechner 04f522 4096 Mar 16 23:14 cvsdiffs drwx--x--x 2 lechner 04f522 4096 Mar 16 23:14 datedVersions -rw------- 1 lechner 04f522 1517 Mar 16 23:14 dprint.c -rw------- 1 lechner 04f522 11888 Mar 16 23:14 dprint.o drwx--x--x 2 lechner 04f522 4096 Mar 16 23:14 genv12_pr_util040829 drwx--x--x 3 lechner 04f522 4096 Mar 16 23:14 genv12_pr_util041114 drwx--x--x 2 lechner 04f522 4096 Mar 16 23:14 misc_pr_util_files041114 -rw------- 1 lechner 04f522 12425 Mar 16 23:14 pr_set_fkeyHelp050315.txt -rw------- 1 lechner 04f522 401998 Mar 16 23:14 pr_util.a drwx--x--x 2 lechner 04f522 4096 Mar 16 23:14 pr_util040829 drwx--x--x 5 lechner 04f522 4096 Mar 16 23:14 restored040730 saturn.cs.uml.edu(46)> pwd /nfs/earth/faculty/fac1/lechner/bde2alpha_rl/sandbox/bdecheckout/bde ------------------ Demo that xmkmf -a reruns genv12 and regenerates pr_util/pr*.c and *schema.h --------------- saturn.cs.uml.edu(51)> touch 94sbde_schema.sch saturn.cs.uml.edu(52)> xmkmf -a mv -f Makefile Makefile.bak imake -DUseInstalled -I/usr/lib/X11/config make Makefiles making Makefiles in pr_util... mv -f Makefile Makefile.bak making Makefiles in src... mv -f Makefile Makefile.bak make includes including in ./pr_util... including in ./src... make depend depending in ./pr_util... makedepend -- -I/usr/include -I../include -I../pr_util -I/usr/include -I../include -DLONG_BIT=64 -- /usr/proj3/case/gen/ver_12/sjaganat/executables/alpha/chgen12 -ansi -metafile -log -nobp ../schema/94sbde_schema.sch Chgen V 12 by Sathya, report errors to Dr. Lechner: CHGEN Chgen V 12 - Sathya, released Tue Mar 05 23:00:00 GMT 2002, Copyright 2002, University of Mass - Lowell CHGEN-I-DEFAULTQUAL, Using default key size of 8 characters CHGEN-I-NONDEFAULTQUAL, Using non-default command-line qualifier -ansi CHGEN-I-NONDEFAULTQUAL, Using non-default command-line qualifier -nobp CHGEN-I-NONDEFAULTQUAL, Using non-default command-line qualifier -metafile CHGEN-I-NONDEFAULTQUAL, Using non-default command-line qualifier -log temp = ../schema/94sbde_schema.msdat Processing Complete depending in ./src... makedepend -- -I/usr/include -I../include -I../pr_util -I/usr/local/lib/g++-include -I/usr/include -I../include -DLONG_BIT=64 -- bde.cc bendpt.cc bendptops.cc buttonevent.cc captionops.cc cursor.cc dialog.cc display.cc draw.cc edit.cc fileio.cc font.cc fprint.cc graphobject.cc graphops.cc handler.cc help.cc hlink.cc infodialog.cc infomessage.cc init.cc initClasses.cc leftmenu.cc leftmenu_cb.cc linkops.cc menubar.cc menubar_cb.cc msgBox.cc nodeops.cc select.cc smselect.cc strdup.cc text.cc bdeReplay.cc textops.cc "dialog.cc":7: 0 // Let's not bother with this just yet. ^--- expecting variable or number "dialog.cc":20: 0 // Let's not bother with this just yet. ^--- expecting variable or number "fileio.cc":2236: 0 // 99s523 rgantyal, vdhamoda ^--- expecting variable or number "textops.cc":786: 0 //:817 ^--- expecting variable or number saturn.cs.uml.edu(53)> pwd /nfs/earth/faculty/fac1/lechner/bde2alpha_rl/sandbox/bdecheckout/bde saturn.cs.uml.edu(54)> lg pr_util total 484 drwx--x--x 10 lechner 04f522 4096 Mar 16 23:20 . -rwx--x--x 1 lechner 04f522 55745 Mar 16 23:14 .#94sbde_schema.h.1.1.2.22 drwxr-xr-x 24 lechner 04f522 4096 Mar 16 23:20 .. -rwx--x--x 1 lechner 04f522 50395 Mar 16 23:20 94sbde_schema.h drwx--x--- 2 lechner 04f522 4096 Mar 16 23:14 CVS -rwx--x--x 1 lechner 04f522 7553 Mar 16 23:14 Imakefile -rw------- 1 lechner 04f522 39867 Mar 16 23:20 Makefile -rw------- 1 lechner 04f522 39851 Mar 16 23:20 Makefile.bak -rw------- 1 lechner 04f522 808 Mar 16 23:14 Makegenlog -rw------- 1 lechner 04f522 2364 Mar 16 23:14 aareadme -rw------- 1 lechner 04f522 582 Mar 16 23:14 aareadme_pr_util drwx--x--x 2 lechner 04f522 4096 Mar 16 23:14 cvsdiffs drwx--x--x 2 lechner 04f522 4096 Mar 16 23:14 datedVersions -rw------- 1 lechner 04f522 1517 Mar 16 23:14 dprint.c -rw------- 1 lechner 04f522 11888 Mar 16 23:14 dprint.o drwx--x--x 2 lechner 04f522 4096 Mar 16 23:14 genv12_pr_util040829 drwx--x--x 3 lechner 04f522 4096 Mar 16 23:14 genv12_pr_util041114 drwx--x--x 2 lechner 04f522 4096 Mar 16 23:14 misc_pr_util_files041114 -rw------- 1 lechner 04f522 10318 Mar 16 23:20 pr_delete.c -rw------- 1 lechner 04f522 9842 Mar 16 23:20 pr_dump.c -rw------- 1 lechner 04f522 1756 Mar 16 23:20 pr_free.c -rw------- 1 lechner 04f522 88200 Mar 16 23:20 pr_load.c -rw------- 1 lechner 04f522 63217 Mar 16 23:20 pr_log.c -rw------- 1 lechner 04f522 12425 Mar 16 23:14 pr_set_fkeyHelp050315.txt -rw------- 1 lechner 04f522 4316 Mar 16 23:20 pr_stats.c drwx--x--x 2 lechner 04f522 4096 Mar 16 23:14 pr_util040829 drwx--x--x 5 lechner 04f522 4096 Mar 16 23:14 restored040730 saturn.cs.uml.edu(55)> date 050316:2321 saturn.cs.uml.edu(56)> ----------------------------- saturn.cs.uml.edu(81)> pwd /nfs/earth/faculty/fac1/lechner/bde2alpha_rl/sandbox/bdecheckout/bde saturn.cs.uml.edu(82)> mv pr_util genpr_util.050316 saturn.cs.uml.edu(83)> diff genpr_util.050316 newpr_util050316 | wc 2721 13541 111682 =============================================================== Refactoring Plan 050320: (genv12 --> genv13) ----- (Make separate diff file for each output of genv12.) (Remove non-essential comment diffs to reduce refactoring labor. (Move large design notes to separate files.) (Identify new replay code blocks that are not ttabbr-sensitive.) ----- This list shows how many diff lines exist for each pr_util file: saturn.cs.uml.edu(84)> diff genpr_util.050316 newpr_util050316 >> \ pr_utilSinceGenv12.diffs050316 --------------------- saturn.cs.uml.edu(88)> diff genpr_util.050316 newpr_util050316 |grep '(^diff|^Only)' 1:diff -bitw genpr_util.050316/94sbde_schema.h newpr_util050316/94sbde_schema.h ( 367) 368:diff -bitw genpr_util.050316/pr_delete.c newpr_util050316/pr_delete.ca ( 107) 475:diff -bitw genpr_util.050316/pr_dump.c newpr_util050316/pr_dump.c ( 348) 823:diff -bitw genpr_util.050316/pr_free.c newpr_util050316/pr_free.c ( 20) 843:diff -bitw genpr_util.050316/pr_load.c newpr_util050316/pr_load.c (1050) 1893:diff -bitw genpr_util.050316/pr_log.c newpr_util050316/pr_log.c ( 812) 2705:diff -bitw genpr_util.050316/pr_stats.c newpr_util050316/pr_stats.c ( 16) saturn.cs.uml.edu(89)> alias grep egrep -n saturn.cs.uml.edu(90)> ---------------------- =============================================================== saturn.cs.uml.edu(84)> diff genpr_util.050316 newpr_util050316 >> \ pr_utilSinceGenv12.diffs050316 ----------------------- Here is full diff output: (first line below is line 1 in diff | grep above): (Add 160 to above line#s) Total: 2720 diff -bitw genpr_util.050316/94sbde_schema.h newpr_util050316/94sbde_schema.h 6a7,26 > /* > * $Log: 94sbde_schema.h,v $ > * Revision 1.1.2.25 2005/03/11 04:21:39 lechner > * Removed merge conflict by removng & from key? in hasType defin. > * > * Revision 1.1.2.24 2005/03/10 06:02:37 lechner > * Added '&' to 'key?' in #define hasType(key, ttabbr) (&key?((... > * > * Revision 1.1.2.23 2005/02/26 04:25:35 lechner > * Update defin of select_CG - test &key not key, for 0 value. > * > * Revision 1.1.2.22 2005/02/25 00:30:00 lechner > * Modified hastType macro - added key!=0 condition. > * > * Revision 1.1.2.21 2004/11/29 20:10:18 lechner > * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. > * > ************************************************************************/ > /* Log aded 041129 - RJL */ > 17a38,42 > #include "../dprint.h" > /* #defines macros DP and EP to trace fcn calls - RJL 040601 */ > /* Func. #defs are conditional on __cplusplus__ */ > /* in bde, for g++ in src and gcc in pr_util - RJL 031024 */ > /* ??? EP macro ==> parse error in pr_*.c but not in src/_*.cc ??? - RJL 040621 */ 19a45 > 116a143 > extern int fpfstatus; /* for PrintCheck macro in schema.h */ 168d194 < 171c197,198 < char* get_abbr(); --- > char* get_abbr(hcg_key *k, char *ret ); > /* char* get_abbr(); - RJL 040517 */ 180c207 < #endif /*__cplusplus*/ --- > #endif /* not __cplusplus*/ 190c217 < --- > /* Why BTREESEARCH== TRUE? see pr_find_bt in pr_load.c - RJL 030808 */ 263,264c290 < /* This structure is used to simplify type casting pointers within table */ < /* rows. */ --- > /*This structure is used to simplify type casting _fpp pointers in table rows.*/ 273c299 < /* This following is a type definition for generic porinters */ --- > /* This following is a type definition for generic pointers */ 281c307,311 < extern hcg_ptr pr_gen_create(); --- > #ifdef __cplusplus > extern "C" hcg_ptr pr_gen_create(unsigned long); > #else > extern hcg_ptr pr_gen_create(unsigned long); > #endif 294,295d323 < /*hcg_key key_value; -- for pr_set_key() */ < /*int PARSE;*/ 297c325,328 < #define pr_set_int(tbl,fld,value) \ --- > > > /* replaced tbl by tbptr in pr_set_int macro only, TBtested - RJL 030814 */ > #define pr_set_int(tblptr,fld,value) \ 299c330 < if((tbl)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ --- > if((tblptr)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ 302c333 < decode_retstr( (hcg_key*)(tbl) ),"fld", (value) );\ --- > decode_retstr( (hcg_key*)(tblptr) ),"fld", (value) );\ 304c335 < (tbl)->fld = (value); \ --- > (tblptr)->fld = (value); \ 307c338,339 < #define pr_set_flt(tbl,fld,value) \ --- > /* replaced tbl in pr_set_flt macro by tblptr - RJL */ > #define pr_set_flt(tblptr,fld,value) \ 309c341 < if((tbl)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ --- > if((tblptr)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ 312c344 < decode_retstr( (hcg_key*)(tbl) ),"fld", (value) );\ --- > decode_retstr( (hcg_key*)(tblptr) ),"fld", (value) );\ 314c346 < (tbl)->fld = (value); \ --- > (tblptr)->fld = (value); \ 317c349,350 < #define pr_set_key(tbl,fld,value) \ --- > /* replaced tbl in pr_set_key macro by tblptr - RJL 040402 */ > #define pr_set_key(tblptr,fld,value) \ 319c352 < if((tbl)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ --- > if((tblptr)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ 323c356 < decode_retstr( (hcg_key*)(tbl) ),"fld", decode_retstr(&key_value) );\ --- > decode_retstr( (hcg_key*)(tblptr) ),"fld", decode_retstr(&key_value) );\ 325c358 < (tbl)->fld = (value); \ --- > (tblptr)->fld = (value); \ 327a361,365 > /* replaced tbl in pr_set_str macro by tblptr - RJL 040402 */ > /* this led to errors - no hsegpattern field in struct at tblptr! */ > /* restored tbl again - suppresed the fprinf below RJL 040404 */ > /* fprintf restored after replacing fld with #fld to quote it. */ > 332c370,371 < "Warning: field %s in table at %s is too long- truncated\n", "fld", "decode_retstr( (hcg_key*)(tbl)");\ --- > "Warning: field %s in table %s of length %d - truncated\n", \ > #fld, decode_retstr( (hcg_key*)(tbl)), (int) strlen(value) );\ 336c375 < decode_retstr( (hcg_key*)(tbl) ),"fld", (value) );\ --- > decode_retstr( (hcg_key*)(tbl) ), #fld, (value) );\ 343,347c382,386 < < #define pr_get_int(tbl,fld) (tbl)->fld < #define pr_get_flt(tbl,fld) (tbl)->fld < #define pr_get_str(tbl,fld) (tbl)->fld < #define pr_get_key(tbl,fld) (tbl)->fld --- > /* WARNING: these are ptr-baed and not safe - want read-only access.*/ > #define pr_get_int(tblptr,fld) (tblptr)->fld > #define pr_get_flt(tblptr,fld) (tblptr)->fld > #define pr_get_str(tblptr,fld) (tblptr)->fld > #define pr_get_key(tblptr,fld) (tblptr)->fld 370c409,410 < int hcg_log; /* Integer indicating log on (1) off (0) replay (2) */ --- > int hcg_log; /* Integer indicating log on (1) or off (0) */ > int hcg_replay; /* Integer indicating replay on (1) or off (0) */ 384c424,425 < extern int hcg_default_fkey; --- > extern int hcg_default_fkey; /* a flag, above - NOT an hcg_key (unsigned int)???-RJL 040517*/ > // extern hcg_key hcg_default_fkey; 386c427,428 < extern int hcg_row; --- > extern int hcg_row; /* An int above, not an hcg_key? (unsigned int)???-RJL 040517*/ > // extern hcg_key hcg_row; /* Inconsistent with MAIN block ==>? Unaligned Access loading tables.*/ 389c431 < extern int hcg_log; --- > extern int hcg_log, hcg_replay; 453a496,498 > /* actual arg tbl is unquoted ttabbr */ > /* PRECONDITION: tbl##curr is a valid ptr; e.g. via find_tbl_idx(). */ > 462c507,508 < #define encoding(s) (lut_insert_element(&hcg_table_abbrev_lut, s)) --- > #define encoding(ttabbr) (lut_insert_element(&hcg_table_abbrev_lut, ttabbr)) > /* SIDE EFFECTS? - RJL 030814 */ 485,486c531 < hcg_ts_list[tbl##_idx].ts_list[hcg_view_list.view_list[hcg_view_idx].version_list[tbl##_idx]].rcount : \ < 0) --- > hcg_ts_list[tbl##_idx].ts_list[hcg_view_list.view_list[hcg_view_idx].version_list[tbl##_idx]].rcount:0) 488,492c533,546 < /******************************************************************************/ < /* This macro is used to determine if the specified child exists under the */ < /* specified parent. */ < /******************************************************************************/ < #define child_exists(parent,child) ((child##curr != NULL) && ((struct parent *) child##curr) != (parent##curr)) --- > /*****************************************************************************/ > /* This macro verifies that the CURRENT parent's child_list is non-empty - RJL 040821*/ > /* This depends on the child type and the fkey name (there may be more than one)*/ > /* which implies the inverse (virtual) pfkey2c##_fcp = parent's first-child ptr*/ > /* Pre-condition: p2c relation exists in schema && parent##curr is not NULL- RJL 040821*/ > /*****************************************************************************/ > /***************************************************************/ > /* An alternate way to determine if any children exist under the */ > /* specified parent : (Revised to avoid child##curr dependence - RJL 040821 */ > /* It depends on the last child having the parent address (not NULL) in its _fcp field.*/ > /****************************************************************************/ > #define child_exists(ptype,ctype,pfkey2c) \ > ((ptype##curr->pfkey2c##_fcp != NULL) && \ > ((struct ptype *) ptype##curr->pfkey2c##_fcp != (ptype##curr))) 529c583,584 < #define first_child(parent,child,pkey) (parent##curr->pkey##_fcp == child##curr) --- > #define first_child(ptype,ctype,cfkey2p) \ > (ptype##curr->cfkey2p##_fcp == ctype##curr) 535c590,591 < #define last_child(parent,child,ckey) ((struct parent *) child##curr->ckey##_fpp == parent##curr) --- > #define last_child(ptype,ctype,cfkey2p) (\ > (struct ptype*) ctype##curr->cfkey2p##_fpp == ptype##curr) 538c594,595 < /* The macro defines pr_dump_row() as dump_row(). */ --- > /* The macro pr_dump_row() calls dump_row() and converts arguments */ > /* (Added arg3 - RJL 040629) */ 540,541c597,599 < #define pr_dump_row(tbl,viewname,file_name,new_version,modestr) dump_row(#tbl,viewname,file_name,new_version,modestr) < extern int open_file; --- > #define pr_dump_row(tbl,viewname,file_fp,file_name,new_version,modestr)\ > dump_row(#tbl,viewname,file_fp,file_name,new_version,modestr) > 543,544c601,602 < /* This macro is used to add the row into a binary tree. It is for internal */ < /* use to build a binary tree. */ --- > /* This macro btree_add_row adds the row into a binary tree. */ > /* It is for internal use to build a binary tree. */ 591c649,650 < } /******************************************************************************/ --- > } > /*****************************************************************************/ 593,594c652,669 < /* key is the one specified. */ < /******************************************************************************/ --- > /* key matches vslue. [Added 030807: If value is not at tbl##curr, */ > /* loop to search for the pkey value, if tbl##btidx==1 call pr_find_bt. */ > /* Optimization: skip search if tbl##curr->tbl##id is correct.-RJL 030807 */ > /* WARNING: pr_find sets tbl##curr == NULL if value is not found - RJL 030807]*/ > /* pr_find_bt is a no-op in pr_load.c, not implemented - RJL 030708. */ > /* No longer depends on pkey order - searches entire table - rev. RJL 040701 */ > /*****************************************************************************/ > /* WARNING: this is a MACRO, expands to a { statement } - it alters tbl##curr;*/ > /* TBD: Make this a function returning [a ptr or Pass/Fail?] - RJL 040701 */ > /* I altered a significant typo: from != to == below - RJL040708 */ > /* I removed this if-block below since pr_find_bt was a no-op - RJL 040724 */ > /* if( tbl##btidx == BTREESEARCH ) \ > * { \ > * pr_find_bt(#tbl,&value);\ > * } \ > * else\ > */ > 596c671,676 < if( tbl##btidx == BTREESEARCH ) \ --- > if ((tbl##curr!=NULL) && (key_compare(&tbl##curr->pkey,&value)==0))\ > ; /* a no-op if cached */ \ > else {\ > for (tbl##curr = tbl; tbl##curr != NULL;\ > tbl##curr = tbl##curr->next_ptr ) \ > if (key_compare(&tbl##curr->pkey,&value)==0) \ 598,600c678,679 < sprintf(tempbtree,"tbl"); \ < tempbtree[HCG_ABBR_SIZE]='\0'; \ < pr_find_bt(tempbtree,&value); \ --- > /*DP; dprintd("Found pkey = %lx\n", (hcg_key)value); */\ > break;\ 602,605c681 < else \ < for (tbl##curr = tbl; (tbl##curr != NULL) && (key_compare(&tbl##curr->pkey,&value) < 0); tbl##curr = tbl##curr->next_ptr); \ < if ((tbl##curr != NULL) && (key_compare(&tbl##curr->pkey,&value) != 0)) \ < tbl##curr = NULL --- > } /* end else */ 682c758 < /* his/her own looping variable. */ --- > /* his/her own looping variable. [WARNING: NO btree case here - RJL 030807] */ 762,765c838,850 < /******************************************************************************/ < /* Macro for checking error in file writes */ < /******************************************************************************/ < #define PrintCheck(x) if((x) == -1) { printf("Error in outputing file. Exiting\n"); exit(1);} --- > /***************************************************************************/ > /* Macro for checking errors in fprintf -(added pfstatus - RJL 040623) */ > /***************************************************************************/ > // PrintCheck's arg (x) is any [f]printf command, > // (man [f]printf ==> it returns either bytecount written, or a negative int.) > // (errno becomes one of 8 enum'td symbols. > // bdetest yield errno=9: EBADF (file not open for write). > // extern int pfstatus; (x below is a printf func call) > > #define PrintCheck(x) do {int pfstatus; pfstatus = (x);\ > if (pfstatus<0) {\ > dprintd("Errno %d in PrintCheck()\n",errno);\ > exit(1);} }while(0) 767d851 < /* C function prototypes for the C++ compiler */ 768a853,854 > > /* C function prototypes for the C++ compiler */ 787c873 < extern hcg_ptr pr_gen_create(int); --- > extern hcg_ptr pr_gen_create(unsigned long); 793a880,881 > extern int replay_log(void); /* added 031018 - RJL */ > 796a885,906 > /* wrapper macros to report calls to pr* fcns - RJL 030812 */ > > #define dpr_load printf\("%s:%i:pr_load\n",__FILE__, __LINE__\);pr_load > > #define dpr_init printf\("%s:%i:pr_init\n",__FILE__, __LINE__\);pr_init > > #define dpr_delete printf("%s:%i:pr_delete\n",__FILE__, __LINE__);pr_delete > > #define dpr_log printf\("%s:%i:pr_log\n",__FILE__, __LINE__\);pr_log > > #define dpr_dump printf\("%s:%i:pr_dump\n",__FILE__, __LINE__\);pr_dump > > #define dpr_replay printf\("%s:%i:pr_replay\n",__FILE__, __LINE__\);pr_replay > > #define dpr_add printf\("%s:%i:pr_add\n",__FILE__, __LINE__\);pr_add > > #define dpr_find printf("%s:%i:pr_find\n",__FILE__, __LINE__);pr_find > > /* this wrapper avoids unneeded call if result already true: RJL 030812 */ > #define opr_find(a,b,c) if (a##curr->b!=c) pr_find(a,b,c) > > 1025c1135 < char hsegpattern[5]; /* optional drawing patern for this segment*/ --- > char hsegpattern[5]; /* optional drawing pattern for segment*/ 1106,1107c1216 < < --- > /* Client: pr_util/pr_load.c:1669: abbr_lut_create(...) */ 1119a1229,1241 > /*#define hasType(key, ttabbr) strstr(decode_retstr(&key), #ttabbr) */ > /* moved from text.h - TBD: auto-generate - RJL 040629; changed RJL040925 */ > /* failed - when id = 0 is passed to key expecting a string ttabbr.... */ > /* changed 050211: check key? first: and 050225: test key address> 0 ? */ > > #define hasType(key,ttabbr) (key?((strstr(decode_retstr(&key),#ttabbr)?1:0)):0) > //#define hasType(key, ttabbr) (&key?((strstr(decode_retstr(&key), #ttabbr)?1:0)):0) > > /* where decode_retstr(&key) returns (PASS? => char*, FAIL? => NULL) */ > /* ( (status = decode(external_key,k)) == 1 ) ? external_key : NULL; */ > /* try : extern char *lut_get_name(lut_st* p_lut, int index) */ > > /* end ifndef __SCHEMA_LOADED */ Common subdirectories: genpr_util.050316/CVS and newpr_util050316/CVS Common subdirectories: genpr_util.050316/cvsdiffs and newpr_util050316/cvsdiffs Common subdirectories: genpr_util.050316/datedVersions and newpr_util050316/datedVersions Binary files genpr_util.050316/dprint.o and newpr_util050316/dprint.o differ Common subdirectories: genpr_util.050316/genv12_pr_util040829 and newpr_util050316/genv12_pr_util040829 Common subdirectories: genpr_util.050316/genv12_pr_util041114 and newpr_util050316/genv12_pr_util041114 Common subdirectories: genpr_util.050316/misc_pr_util_files041114 and newpr_util050316/misc_pr_util_files041114 diff -bitw genpr_util.050316/pr_delete.c newpr_util050316/pr_delete.c 5a6,17 > /* > * $Log: pr_delete.c,v $ > * Revision 1.1.2.15 2004/12/17 06:33:46 lechner > * I removed LHS cast and added (struct dummy_type*) on RHS, line 85. > * This removed warnings frm a newer Linux verskon of gcc than Mercury has. > * > * Revision 1.1.2.14 2004/11/29 20:10:19 lechner > * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. > * > ************************************************************************/ > /* Log aded 041129 - RJL */ > 12c24 < extern void pr_find_bt(char*, hcg_key*); --- > /*extern void pr_find_bt(char*, hcg_key*); */ 15a28 > /* In *schema.h:454:#define pr_delete(tbl) pr_del(tbl##_idx) - RJL 030807 */ 18c31 < /* also unlinks the row from its table's row chain. */ --- > /* also unlinks the row from its table's row chain and invalidates tbl#curr. */ 67a81 > /* I moved LHS cast to (dummy_type)on RHS (PC/Linux gcc warning)-RJL041216 */ 75c89 < ( (struct pa *) ca##curr->p##_fpp == pa##temp)) /* only child case */ \ --- > ( ca##curr->p##_fpp == (struct dummy_type*)pa##temp)) /* only child case */ \ 126c140 < int tbl_idx; --- > int tbl_idx; /* index of table type in hcg_table_seq_list[] */ 127a142,144 > int tmpidx; /* encoding of ttabbrev - RJL 030807 */ > /* used to get ttabbrev for encoding */ > /* Why doesn't tbl_idx match encoding of ttabbrev? */ 133,134c150,151 < < switch( encoding(hcg_table_seq_list[tbl_idx].ttabbrev) ) --- > tmpidx = encoding(hcg_table_seq_list[tbl_idx].ttabbrev); > switch(tmpidx) 139a157 > printf("\t tbl_idx = %i, encoding(tabbrev) = %i\n",tbl_idx,tmpidx); 141,142c159,160 < del_row(FO); < --- > /* del_row(FO); moved below the logstr - RJL 031021*/ > /* and similarly for each case below - RJL 031021 */ 147c165 < --- > del_row(FO); 155d172 < del_row(GD); 161a179 > del_row(GD); 171d188 < del_row(HG); 177a195 > del_row(HG); 189d206 < del_row(HN); 195a213 > del_row(HN); 204d221 < del_row(HA); 210a228 > del_row(HA); 222d239 < del_row(HL); 228a246 > del_row(HL); 237d254 < del_row(HP); 243a261 > del_row(HP); 252d269 < del_row(HI); 258a276 > del_row(HI); 268d285 < del_row(CG); 274a292 > del_row(CG); 283d300 < del_row(GX); 289a307 > del_row(GX); 292c310,311 < } --- > /* TBD: add a default case with error/abort - RJL 031021 */ > } /* end switch */ 308c327,328 < default: printf("\n\tWARNING: pr_del_bt(%s, %x) called: not implemented \n\n", --- > default: > printf("\n\tWARNING: pr_del_bt(%s, %x) called: not implemented \n\n", 310c330 < } --- > }; Binary files genpr_util.050316/pr_delete.o and newpr_util050316/pr_delete.o differ diff -bitw genpr_util.050316/pr_dump.c newpr_util050316/pr_dump.c 0a1 > 6c7,17 < --- > /* > * $Log: pr_dump.c,v $ > * Revision 1.1.2.7 2005/02/25 00:34:12 lechner > * > * cvs diff pr_util 050223: No changes except hasType macro in 94sbde_schema.h > * > * Revision 1.1.2.6 2004/11/29 20:10:19 lechner > * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. > * > ******************************************************************************/ > #include /* for exit() */ 15a27,30 > /* outkey changed to dumpkey here; - RJL)40711 */ > /* outkey was local to pr_dump.c; it is distinct from outkey[] in pr_load.c: */ > /* decode maps hcg_key pfkeys into 1 to 3 ASCII string ptrs in outkey[0-2.*/ > char dumpkey[3][HCG_KEY_SIZE+1]; /* used in pr_dump_row */ 17,20c32 < /* This outkey is local to pr_dump; it has a distinct scope in pr_load.c: */ < char outkey[3][HCG_KEY_SIZE+1]; /* used in dump_row */ < < /* encoding expands to (in pr_util/94sbde_*schema.h line 469): */ --- > /* encoding declared in pr_util/94sbde_*schema.h line 469: */ 22,23c34,42 < int fstatus; < void dump_row( char*, char*, char*, int, char* );/*fwd ref*/ --- > int fstatus; /* from fclose(hcg_dump_fp) */ > int fpfstatus; /* from fprintf in PrintCheck macro */ > void dump_row( char*, char*, FILE*, char*, int, char* ); /*fwd ref*/ > > /* dump_row is called indirectly - see 94sbde_schema.h:562: > * #define pr_dump_row(tbl,viewname,file_ptr,file_name,new_version,modestr) \ > * dump_row(#tbl,viewname,file_fp,file_name,new_version,modestr) > * (dump_row actually uses global var hcg_dump_fp; file_name is for printing) > */ 31a51,57 > /* Client must pass new arg3 = dump_fp via macro pr_dump_row.-RJL 040615 */ > /* modestr arg no longer needed - open_file status variable removed - RJL 040615*/ > /* Q1 040625: does mode "w" imply over-writing a new file? */ > /* Q2 040625: PrintCheck aborts with errno 9 = EBADF (can't write to file). Why?*/ > /* dump_row now gets new arg3 = FILE* for flexibility (e.g. graphDump client) */ > /* Global hcg_dump_fp replaced by local dump_fp - RJL 040629 */ > 33,36d58 < /*char viewname[]; < char file_name[]; < int new_version; < char modestr[];*/ 39c61,62 < open_file=0; --- > FILE* dump_fp; /* was global hcg_dump_fp - RJL 040629 */ > EP; 50c73 < if ((hcg_dump_fp=fopen(file_name,modestr)) == NULL) --- > if ((dump_fp = fopen(file_name,modestr)) == NULL) 68c91,94 < pr_dump_row(FO,viewname,file_name,new_version,modestr); --- > /* TBD: No need to pass file_name to pr_dump_row now .-RJL 040629 */ > /* Here, actual arg3 passes the global variable hcg_dump_fp - RJL 040629 */ > > pr_dump_row(FO,viewname,dump_fp,file_name,new_version,modestr); 76c102 < pr_dump_row(GD,viewname,file_name,new_version,modestr); --- > pr_dump_row(GD,viewname,dump_fp,file_name,new_version,modestr); 83,84c109 < < pr_dump_row(HG,viewname,file_name,new_version,modestr); --- > pr_dump_row(HG,viewname,dump_fp,file_name,new_version,modestr); 91,92c116 < < pr_dump_row(HN,viewname,file_name,new_version,modestr); --- > pr_dump_row(HN,viewname,dump_fp,file_name,new_version,modestr); 100c124 < pr_dump_row(HA,viewname,file_name,new_version,modestr); --- > pr_dump_row(HA,viewname,dump_fp,file_name,new_version,modestr); 107,108c131 < < pr_dump_row(HL,viewname,file_name,new_version,modestr); --- > pr_dump_row(HL,viewname,dump_fp,file_name,new_version,modestr); 116c139 < pr_dump_row(HP,viewname,file_name,new_version,modestr); --- > pr_dump_row(HP,viewname,dump_fp,file_name,new_version,modestr); 124c147 < pr_dump_row(HI,viewname,file_name,new_version,modestr); --- > pr_dump_row(HI,viewname,dump_fp,file_name,new_version,modestr); 132c155 < pr_dump_row(CG,viewname,file_name,new_version,modestr); --- > pr_dump_row(CG,viewname,dump_fp,file_name,new_version,modestr); 140c163 < pr_dump_row(GX,viewname,file_name,new_version,modestr); --- > pr_dump_row(GX,viewname,dump_fp,file_name,new_version,modestr); 145,150c168,181 < } /* end if */ < } /* end for */ < fstatus = fclose(hcg_dump_fp); < if (fstatus != 0) < printf("\n\nERROR: pr_dump File failed to close!\n\n"); < open_file=1; --- > } /* end if rcount > 0 */ > } /* end for each table (hcg_tbl_idx++) */ > fstatus = fclose(dump_fp); // AFTER all tables are dumped! - RJL 040625 > // man fclose: Upon successful completion, fclose() etc. > // return a value of 0 (zero). > // Otherwise, EOF is returned, and errno is set to indicate the error. > if (fstatus!= 0) { > printf( > "\n\nERROR %d: pr_dump failed to close filename %s: abort!\n\n", > errno, file_name); > exit(0); > } > /* Next dump_row client must re-do hcg_dump_fp = fopen(file_name,modestr) */ > return; 151a183 > 152a185 > /* dump_row is called from macro pr_dump_row which 'stringizes' arg1=ttabbr */ 154,157c187,190 < /* view to the specified file_name. The tbl indicates which table's row */ < /* will be dumped. The open_file flag of 1 indicates open a file for dumping */ < /* a single row. Otherwise doesn't open file because pr_dump had opened a */ < /* file. If the mode of the view is rite, the caller is allowed to specify a */ --- > /* view to the specified file_name. Arg't tbl indicates which table's row */ > /* will be dumped. The dumpfile_is_open flag of 1 indicates open a file for */ > /* dumping a single row. Else, do not open because pr_dump opened hcg_dump_fp.*/ > /* If the mode of the view is right, the caller is allowed to specify a */ 160c193,194 < /* or append to an existing file ('a'). */ --- > /* or append to an existing file ('a'). (arg3=file_ptr added - RJL 040629 */ > /* I added arg3=FILE* dump_fp and removed arg6=char* modestr - RJL 040629 */ 162c196,203 < void dump_row ( char* tbl, char* viewname, char* file_name, int new_version, char* modestr ) --- > /* RJL: 040615: Since scatter-writing one row at a time doesn't make sense, > * dump_row gets an explicit file_ptr for filename opened by the caller, > * and just write out the appropriate table-row. > * pr_dump's table_loop is bypassed so an optional depth-first > * spanning-tree-walk thru descendant table rows can sequence the output. > */ > > void dump_row ( char* tbl, char* viewname, FILE* dump_fp, char* file_name, int new_version, char* modestr ) 165,173c206,213 < if (open_file==1) < { < if ((hcg_dump_fp=fopen(file_name,modestr)) == NULL) < { < printf("Error: pr_dump_row() cannot open %s using file mode %s\n", file_name,modestr); < exit(1); < } < } < if (idx==0) --- > //EP; > > /* removed fopen action - Pre-condition: > dump_fp open for write or append - RJL 040615 */ > /* changed if conditions to switch cases with breaks - RJL040630 */ > assert (dump_fp != NULL); > switch(idx) { > case 0: 176,178c216,218 < decode((char*)outkey[0], &FOcurr->FOid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-50s %-50s %-2s %-15s\n" < , outkey[0], FOcurr->xfont, FOcurr->psfontname, FOcurr->psfontsize, FOcurr->bdefont)); --- > decode((char*)dumpkey[0], &FOcurr->FOid); > PrintCheck(fprintf(dump_fp, " %-8s %-50s %-50s %-2s %-15s\n" , dumpkey[0], FOcurr->xfont, FOcurr->psfontname, FOcurr->psfontsize, FOcurr->bdefont)); > break; 180c220 < if (idx==1) --- > case 1: 183,186c223,225 < decode((char*)outkey[0], &GDcurr->GDid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-10s %8.4f %8.4f %-4s %-25s %-10s %-10s %8.4f %8.4f\n" < , outkey[0], GDcurr->shape, GDcurr->width, GDcurr->height, GDcurr->hsegpattern, GDcurr->txtfont, GDcurr->location, GDcurr->justify < , GDcurr->gcwidth, GDcurr->gcheight)); --- > decode((char*)dumpkey[0], &GDcurr->GDid); > PrintCheck(fprintf(dump_fp, " %-8s %-10s %8.4f %8.4f %-4s %-25s %-10s %-10s %8.4f %8.4f\n" , dumpkey[0], GDcurr->shape, GDcurr->width, GDcurr->height, GDcurr->hsegpattern, GDcurr->txtfont, GDcurr->location, GDcurr->justify , GDcurr->gcwidth, GDcurr->gcheight)); > break; 188c227 < if (idx==2) --- > case 2: 191,193c230,232 < decode((char*)outkey[0], &HGcurr->HGid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %-12s %-12s %-12s %-60s\n" < , outkey[0], HGcurr->FSid, HGcurr->HNid, HGcurr->HGauthor, HGcurr->HGcreated, HGcurr->HGlastmod, HGcurr->HGtitle)); --- > decode((char*)dumpkey[0], &HGcurr->HGid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %-12s %-12s %-12s %-60s\n" , dumpkey[0], HGcurr->FSid, HGcurr->HNid, HGcurr->HGauthor, HGcurr->HGcreated, HGcurr->HGlastmod, HGcurr->HGtitle)); > break; 195c234 < if (idx==3) --- > case 3: 198c237 < decode((char*)outkey[0], &HNcurr->HNid); --- > decode((char*)dumpkey[0], &HNcurr->HNid); 200,203c239,241 < decode((char*)outkey[1], &HNcurr->HGid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %-1s %8.4f %8.4f %8.4f %8.4f %-25s %8.4f %8.4f %8d %8d %-20s\n" < , outkey[0], outkey[1], HNcurr->FSid, HNcurr->shape, HNcurr->centerx, HNcurr->centery, HNcurr->width, HNcurr->height, HNcurr->txtfont < , HNcurr->txtoffsetx, HNcurr->txtoffsety, HNcurr->txtwidth, HNcurr->txtheight, HNcurr->nodename)); --- > decode((char*)dumpkey[1], &HNcurr->HGid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %-1s %8.4f %8.4f %8.4f %8.4f %-25s %8.4f %8.4f %8d %8d %-20s\n" , dumpkey[0], dumpkey[1], HNcurr->FSid, HNcurr->shape, HNcurr->centerx, HNcurr->centery, HNcurr->width, HNcurr->height, HNcurr->txtfont , HNcurr->txtoffsetx, HNcurr->txtoffsety, HNcurr->txtwidth, HNcurr->txtheight, HNcurr->nodename)); > break; 205c243 < if (idx==4) --- > case 4: 208c246 < decode((char*)outkey[0], &HAcurr->HAid); --- > decode((char*)dumpkey[0], &HAcurr->HAid); 210,213c248,250 < decode((char*)outkey[1], &HAcurr->HNid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %8.4f %8.4f %8.4f %8d %8d %-25s %-60s\n" < , outkey[0], outkey[1], HAcurr->DAid, HAcurr->txtoffsetx, HAcurr->txtoffsety, HAcurr->HAorigin, HAcurr->txtwidth, HAcurr->txtheight < , HAcurr->txtfont, HAcurr->hlabel)); --- > decode((char*)dumpkey[1], &HAcurr->HNid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %8.4f %8.4f %8.4f %8d %8d %-25s %-60s\n" , dumpkey[0], dumpkey[1], HAcurr->DAid, HAcurr->txtoffsetx, HAcurr->txtoffsety, HAcurr->HAorigin, HAcurr->txtwidth, HAcurr->txtheight , HAcurr->txtfont, HAcurr->hlabel)); > break; 215,216c252,253 < if (idx==5) < { --- > case 5: > { /* decode gives SIGSEGV from dumpkey = 0x0 - RJL 040630 */ 218c255,257 < decode((char*)outkey[0], &HLcurr->HLid); --- > assert(HLcurr!=NULL); > dprintd("doDump case 5 (HL): pkey HLid = %lx\n", (int)HLcurr->HLid); > decode((char*)dumpkey[0], &HLcurr->HLid); 220c259 < decode((char*)outkey[1], &HLcurr->HNid1); --- > decode((char*)dumpkey[1], &HLcurr->HNid1); 222,224c261,263 < decode((char*)outkey[2], &HLcurr->HNid2); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %8d %8d\n" < , outkey[0], outkey[1], outkey[2], HLcurr->HPcount, HLcurr->allvisible)); --- > decode((char*)dumpkey[2], &HLcurr->HNid2); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %8d %8d\n" , dumpkey[0], dumpkey[1], dumpkey[2], HLcurr->HPcount, HLcurr->allvisible)); > break; 226c265 < if (idx==6) --- > case 6: 229c268 < decode((char*)outkey[0], &HPcurr->HPid); --- > decode((char*)dumpkey[0], &HPcurr->HPid); 231,233c270,272 < decode((char*)outkey[1], &HPcurr->HLid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %8.4f %8.4f %8d %-4s\n" < , outkey[0], outkey[1], HPcurr->HPx, HPcurr->HPy, HPcurr->is_visible, HPcurr->hsegpattern)); --- > decode((char*)dumpkey[1], &HPcurr->HLid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %8.4f %8.4f %8d %-4s\n" , dumpkey[0], dumpkey[1], HPcurr->HPx, HPcurr->HPy, HPcurr->is_visible, HPcurr->hsegpattern)); > break; 235c274 < if (idx==7) --- > case 7: 238c277 < decode((char*)outkey[0], &HIcurr->HIid); --- > decode((char*)dumpkey[0], &HIcurr->HIid); 240,243c279,281 < decode((char*)outkey[1], &HIcurr->HLid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %8.4f %8.4f %8.4f %8d %8d %-25s %-40s\n" < , outkey[0], outkey[1], HIcurr->DIid, HIcurr->HIorigin, HIcurr->tbeginx, HIcurr->tbeginy, HIcurr->txtwidth, HIcurr->txtheight < , HIcurr->txtfont, HIcurr->hlabel)); --- > decode((char*)dumpkey[1], &HIcurr->HLid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %8.4f %8.4f %8.4f %8d %8d %-25s %-40s\n" , dumpkey[0], dumpkey[1], HIcurr->DIid, HIcurr->HIorigin, HIcurr->tbeginx, HIcurr->tbeginy, HIcurr->txtwidth, HIcurr->txtheight , HIcurr->txtfont, HIcurr->hlabel)); > break; 245c283 < if (idx==8) --- > case 8: 248c286 < decode((char*)outkey[0], &CGcurr->CGid); --- > decode((char*)dumpkey[0], &CGcurr->CGid); 250,252c288,290 < decode((char*)outkey[1], &CGcurr->HGid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %8.4f %8.4f %8.4f %8.4f\n" < , outkey[0], outkey[1], CGcurr->CGcenterx, CGcurr->CGcentery, CGcurr->CGwidth, CGcurr->CGheight)); --- > decode((char*)dumpkey[1], &CGcurr->HGid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %8.4f %8.4f %8.4f %8.4f\n" , dumpkey[0], dumpkey[1], CGcurr->CGcenterx, CGcurr->CGcentery, CGcurr->CGwidth, CGcurr->CGheight)); > break; 254c292 < if (idx==9) --- > case 9: 257c295 < decode((char*)outkey[0], &GXcurr->GXid); --- > decode((char*)dumpkey[0], &GXcurr->GXid); 259,262c297,299 < decode((char*)outkey[1], &GXcurr->CGid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %8.4f %-25s %8.4f %8.4f %8d %8d %-128s\n" < , outkey[0], outkey[1], GXcurr->DAid, GXcurr->GXorigin, GXcurr->txtfont, GXcurr->txtoffsetx, GXcurr->txtoffsety, GXcurr->txtwidth < , GXcurr->txtheight, GXcurr->grphcaption)); --- > decode((char*)dumpkey[1], &GXcurr->CGid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %8.4f %-25s %8.4f %8.4f %8d %8d %-128s\n" , dumpkey[0], dumpkey[1], GXcurr->DAid, GXcurr->GXorigin, GXcurr->txtfont, GXcurr->txtoffsetx, GXcurr->txtoffsety, GXcurr->txtwidth , GXcurr->txtheight, GXcurr->grphcaption)); > break; 264,265c301 < if (open_file==1) < fclose(hcg_dump_fp); --- > default: assert(0); 266a303,305 > //Do NOT close this file! > return; > } /* end pr_dump_row */ Binary files genpr_util.050316/pr_dump.o and newpr_util050316/pr_dump.o differ diff -bitw genpr_util.050316/pr_free.c newpr_util050316/pr_free.c 5a6,16 > /* > * $Log: pr_free.c,v $ > * Revision 1.1.2.11 2005/02/25 00:34:12 lechner > * > * cvs diff pr_util 050223: No changes except hasType macro in 94sbde_schema.h > * > * Revision 1.1.2.10 2004/11/29 20:10:19 lechner > * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. > * > ************************************************************************/ > /* Log aded 041129 - RJL */ 26a38 > tbl##end = NULL; /* see hcg_declare - RJL 040412 */\ 32a45 > /* TBD: Move log* calls to client (do_cmmand in pr_load) - RJL 020429 */ 35a49 > EP; Binary files genpr_util.050316/pr_free.o and newpr_util050316/pr_free.o differ diff -bitw genpr_util.050316/pr_load.c newpr_util050316/pr_load.c 6c6,23 < --- > /* > * $Log: pr_load.c,v $ > * Revision 1.1.2.27 2005/02/25 00:34:12 lechner > * > * cvs diff pr_util 050223: No changes except hasType macro in 94sbde_schema.h > * > * Revision 1.1.2.26 2004/11/29 20:10:19 lechner > * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. > * > ******************************************************************************/ > /*New state model for logging/replay - RJL 040712; (not tested for state 3 yet) > * pr_startlog: 0-->1, 2-->3; "SR" input: 1-->3, 0-->2 turns logging on/off. > * "SP" input: 3-->1, 2-->0; pr_stoplog: 1-->0; 3-->2 turns replay on/off. > *This is equivalent to having two independent 2-state models and states > *hcg_replay toggled by "SR"/"SP", hcg_log toggled by pr_startlog/pr_stoplog. > *This reverts to the old model by prohibiting state 3 ==> logging AND replay. > * Tests are defined as isLogging() and isReplay() > */ 8a26 > 12a31 > 13a33,35 > /* includes dprint.h */ > int stripDPath(char*, char* ); > /* strip directory segments from arg2 and return as fname in arg1 */ 24a47 > 29c52 < int replayStatus; --- > int replayStatus = 0; /* = 0 by RJL 031018 */ 30a54,55 > extern char* logfile; /* in pr_log.c */ > 32,33c57 < void logwait(void){}; < void logstr(char* dummy_strptr){}; --- > void logwait(void){/* a no-op */}; 48c72,74 < int open_file; --- > > extern FILE* hcg_logfileptr; /* for log_pr_add - TBD: pass as arglast */ > 106a133,134 > /* Not-found case set hcg_tbl_idx to 0 (changed to -1 - RJL 040521) */ > /* -1 caused '!find_tbl_idx(table_abbrev)' errors at pr_load:1910-RJL040522 */ 107a136 > /* ALWAYS check return value - hcg_tbl_idx=0 is real and mis-leads on fail. RJL040611 */ 109,111c138,142 < { < if (strncmp(pkey,hcg_table_seq_list[hcg_tbl_idx].ttabbrev,HCG_ABBR_SIZE) == 0) < return(1); --- > { char tmpabb[HCG_ABBR_SIZE+1]; > strncpy(tmpabb, hcg_table_seq_list[hcg_tbl_idx].ttabbrev, HCG_ABBR_SIZE); > if (strncmp(pkey,tmpabb,HCG_ABBR_SIZE)== 0) > return(1); /* strcmp --> strncmp - RJL 040522 */ > /* else search: */ 113c144,146 < if (strncmp(pkey,hcg_table_seq_list[hcg_tbl_idx].ttabbrev,HCG_ABBR_SIZE) == 0) --- > { /* strncpy restored inside loop - RJL 040522 */ > strncpy(tmpabb, hcg_table_seq_list[hcg_tbl_idx].ttabbrev,HCG_ABBR_SIZE); > if (strncmp(pkey, tmpabb, HCG_ABBR_SIZE) == 0) 115,116d147 < hcg_tbl_idx = 0; < return(0); 117a149,151 > hcg_tbl_idx = -1; /* was HCG_NUM_TABLES on loop exit - RJL 040614 */ > return(0); > } /* end find_tbl_idx */ 122,123c156,159 < /* used. In this case, viewnames are not restricted to any fixed length, */ < /* so a regular strcmp() is used. */ --- > /* updated. In this case, viewnames are not restricted to any fixed length, */ > /* so a regular strcmp() is used. Returns: 1 on PASS, */ > /* 0 on FAIL (with hcg_view_idx = -1); */ > /* Note: clients are pr_init(loads views), load_data (seaqrch views) and pr_replay? */ 126,130c162,176 < { < if (strcmp(viewname,hcg_view_list.view_list[hcg_view_idx].view_name) == 0) < return(1); < for (hcg_view_idx=0; hcg_view_idx < hcg_view_list.num_views; hcg_view_idx++) < { if (strcmp(viewname,hcg_view_list.view_list[hcg_view_idx].view_name) == 0) --- > { char tmpname[MAXVIEWNAMELEN]; > //EP; > //dprintsd("Entered find_view_idx(view=%s, hcg_view_idx = %d)\n", > // viewname, hcg_view_idx); > /* this logic was rewritten - RJL 040616 */ > /* check for a match at cached hcg_view_idx if in-range - RJL 040616 */ > /* prior failure may set hcg_view_idx to -1??? - RJL 040622 */ > if (hcg_view_idx >= 0 && hcg_view_idx < hcg_view_list.num_views) > { > strcpy(tmpname, hcg_view_list.view_list[hcg_view_idx].view_name ); > if (strcmp(viewname,tmpname) == 0) > { > //DP; dprintsd( > // "viewname %s matched w/o search at hcg_view_idx= %d\n", > // viewname, hcg_view_idx); 133,134d178 < hcg_view_idx = 0; < return(0); 135a180,202 > /* else search: (hcg_view_idx out of range, or in-range but no match): */ > for (hcg_view_idx = 0; hcg_view_idx < hcg_view_list.num_views; hcg_view_idx++) > { > //dprintdd("for_loop iter: hcg_view_idx = %d, hcg_view_list.num_views = %d\n", > // hcg_view_idx, hcg_view_list.num_views); > strcpy(tmpname, hcg_view_list.view_list[hcg_view_idx].view_name ); > if (strcmp(viewname,tmpname) == 0) > { > //DP; dprintsd( > // "Found match to viewname %s at hcg_view_idx = %d\n", > // viewname, hcg_view_idx); > return(1); /* new matching hcg_view_idx 'cached' */ > } > } > //dprintdd( > // "After for_loop: hcg_view_idx = %d, hcg_view_list.num_views = %d\n", > // hcg_view_idx, hcg_view_list.num_views); /* RJL 040622 */ > //DP; > //dprints("for_loop exit: failed to find viewname = %s\n", (char*)tmpname); > //dprintdd("\t hcg_view_idx = %d, hcg_view_list.num_views = %d\n", > // hcg_view_idx, hcg_view_list.num_views); > return(0); > } /* end find_view_idx */ 149c216 < --- > /* 040429: */ 239c306 < printf("Error: Can not set version# at p_key %lu to %d\n", (unsigned long) p_key, hcg_table_seq_list[tbl_idx].maxver + 1); --- > printf("Error: Can not set version# at p_key %lx to %d\n", (unsigned long) p_key, hcg_table_seq_list[tbl_idx].maxver + 1); 788d854 < 1157a1224 > /* NEW_KEY_LEN is used in decode and decode_retstr - RJL040723 */ 1178c1245 < static int abshift = 24; /* these are the amounts to shift the 32 bit key to use the above masks */ --- > static int abshift = 24; /* the amounts to shift the 32 bit key to use the above masks */ 1271a1339 > * WARNING: Client pr_gen_pkey does not check for failure to update k! - RJL 040521 1339c1407,1408 < if( (lut_st*) &hcg_table_abbrev_lut == (lut_st*)NULL ) /* ensure necessary tables have been initialized */ --- > if( (lut_st*) &hcg_table_abbrev_lut == (lut_st*)NULL ) > /* ensure necessary tables have been initialized */ 1345c1414,1415 < printf("Key encode: invalid character key length: %d; key: %s\n",klen,external_key); --- > printf("Key encode: invalid character key length: %d; key: %s\n", > klen,external_key); 1390c1460 < } --- > } // end encode (1336-1397) 1397c1467 < static char external_key[NEW_KEY_LEN + 1]; --- > static char external_key[HCG_KEY_SIZE + 1]; /* was NEW_KEY_LEN (private)*/ 1406a1477 > //EP; 1410c1481,1482 < if( abb_decode(k,t) < 0 ) --- > assert (k != 0); > if( abb_decode(k,t) < 0 ) /* SIGSEGV if k = 0x0 - RJL 040630 */ 1460a1533 > assert(k!= NULL); /* RJL 040713 */ 1481c1554 < * Set the abbr field of an encoded key to a desired value --- > * Set the (int) abbr field of an encoded key to a desired value 1541a1615 > * (it does not test for zero row and version only) 1558c1632,1634 < void pr_init ( char *viewdef_filename, char *filelist) --- > /* Requires pre-cond: hcg_initialized == 0 by pr_free */ > /* Ensures post-cond: hcg_initialized == 1, file_is_open = 1 */ > void pr_init ( char *viewdef_filename, char *filelist) /* l592-1922 */ 1561,1562c1637,1646 < int i,idx, ver_chars; < char scan_filename[SCHEMA_HEADER_FILE_NAME_LENGTH]; --- > int j,k,fnidx,idx,vernbr,ver_chars; > int isLocal; /* for stripDPath at end */ > int infile_is_open = 0; > int isDefineViewCmd; /* 0 if view_element, 1 if define_view */ > /* open_file was set but not used; replaced by infile_is_open - RJL 040601 */ > > /*char scan_filename[SCHEMA_HEADER_FILE_NAME_LENGTH], localname[NAMELENGTH];*/ > > char scan_filename[BUFSIZE]; /* full path name? */ > char localname[NAMELENGTH]; /* after path prefix removed */ 1564c1648,1651 < char temp_mode[8],temp_command[100],table_abbrev[ABBREV_NAME_LENGTH],temp_verstring[10], error_table[ABBREV_NAME_LENGTH]; --- > char* localptr = &localname[0]; > > char temp_mode[8],temp_command[100],table_abbrev[ABBREV_NAME_LENGTH]; > char temp_verstring[10], error_table[ABBREV_NAME_LENGTH]; 1568,1569c1655,1656 < < if (hcg_log == 1) --- > EP; > if (hcg_log) 1580d1666 < open_file=1; 1583c1669 < printf("Error: pr_init() called when database is already initialized.\n"); --- > printf("Error: pr_init() called but database is already initialized.\n"); 1594,1595c1680,1681 < for(i=0; i < MAXVIEWS; i++) < hcg_view_list.view_list[i].view_name[0]='\0'; --- > for(k=0; k < MAXVIEWS; k++) > hcg_view_list.view_list[k].view_name[0]='\0'; 1598,1599c1684,1687 < /* For the capture of datafile if not in replay session */ < if (hcg_log != 2) { --- > /* For the capture of datafile [logging info?] if NOT in replay session */ > /* THE INTENT OF THIS IS UNCLEAR TO ME - RJL 031019 */ > /* if (hcg_log != 2) { */ /* why not if(hcg_log == 1) (logging has been activated)?*/ > if (hcg_log == 1) { /* try to open a file for LATER replay - RJL 040425 */ 1601,1602c1689,1691 < printf("can not open logdata.txt to capture log data\n"); < exit(2); --- > printf("pr_init(): can not open logdata.txt to WRITE the log data\n"); > exit(2); /* is it safe for pr_init to preserve hcg_log = 1? */ > 1607,1608c1696,1736 < i = 0; < hcg_parse(filelist,scan_filename,&i); --- > /* RJL 040425: Notes on concurrent log and replay for DBDE: > * For concurrent log and replay, do we need hcg_log? > * Pre-condition: > * pr_load must do pr_init's pkey-range-updates while replaying a file > * with "SR" + checkpoint file table rows or equivalent "LD" command; > * replay is complicated because discovering "SR" in infile.dat implies > * pr_init and pr_load of infileDB1.dat, then replaying log_data.txt. > > * Replay is simplified if infile.dat replaces log_data.txt > * and pr_loading infileDB1.dat is replaced by inline checkpoint tables > * or an equivalent "LD" replay command. > * Replay then means load checkpoint table rows followed by changelog commands > * without handling multiple files (unless the "LD" command refers to a file). > * The initial "SR" command is superfluous but can be retained for now. > > * Bde will redraw the canvas whenever updates to the memory-resident > * tables affect the selected and displayed HG. It does this now by calling > * clear/updatedisplaylist/ReDraw (but not pr_free). > * The bde clients also log updates (but ONLY locally originated ones - > * NOT those from remote client updates in the file or stream being replayed). > > * Bde local editing must be interrupted by X11 to sample the replay file or stream. > * X11 supports user-defined callbacks XtAppAddInput and XtAppAddWorkProc for this. > * X11 calls these only when the local Xevent buffer is empty. > * DBDE clients may need to slow down so narrow-band links can keep up with > * the server-merged broadcast stream of remotely-originated changes. > > * For the 02f522 Hominid replay project, the 's' Keypress callback was used. > * But in 02s > * http://www.cs.uml.edu/~lechner/02s592/pkingsto > * Paul Kingston wrote and tested XtAppAddInput and XtAppAddWorkProc (without linking > * them into bde). His work should be re-used in 04s522/dbde. > * RJL 040425 > */ > > /* ======= copy each infile to local tempinfile.txt ========================= */ > fnidx = 0; /* hcg_parse index of filename into filelist */ > hcg_parse(filelist,scan_filename,&fnidx); > > dprints("pr_init: scan_filename is %s\n", scan_filename); > 1610a1739 > /* OPEN INFILE */ 1613c1742 < printf("can not open %s to find TS data\n", scan_filename); --- > printf("pr_init cannot open %s to get table stats.\n", scan_filename); 1615a1745,1753 > infile_is_open = 1; > /* TBD: RJL 030810: Convert ../lib/fonts.dat to fonts.dat */ > /* before prefixing temp: want tempfonts.dat as local copy */ > > /* Strip all directory segments from name: */ > isLocal = stripDPath(localname, scan_filename); > dprints("infile localname is %s\n", localname); > > assert(strlen(localname) >0); 1617,1618c1755,1758 < if (hcg_log != 2) < fprintf(logdata_fp, "LogDataFile %s\n",scan_filename); --- > /* if (hcg_log != 2) */ > > if (hcg_log == 1) /*logging is on: add Keyword+filename to logdata_fp*/ > fprintf(logdata_fp, "LogDataFile %s\n", localptr);/* localptr added 040602 -RJL */ 1621,1623c1761,1764 < hcg_tbl_idx = 0; < hcg_read_next(); < while ( !feof(hcg_ascii_fp) ) --- > /* READ ALL LINES FROM EACH FILE: copy to local filename */ > hcg_read_next(); /* fills hcg_buffer */ > while ( !feof(hcg_ascii_fp)) /* if hcg_log == 1, append infile data rows to logdata.txt */ > /* and check pkey validity and range */ 1625,1626c1766,1767 < /* Added by Genlog 5/7/96 to log pr_init */ < if (hcg_log != 2) --- > /* Added by Genlog 5/7/96 to log table rows [to be] copied to logdata_fp file */ > if (hcg_log == 1) /* was != 2 (not in replay) - RJL 040622 */ 1629c1770 < --- > //DP;dprints("hcg_buffer: %s\n", hcg_buffer); 1632c1773 < if (!find_tbl_idx(hcg_t)) --- > if (!find_tbl_idx(hcg_t)) /* caches and may alter hcg_tbl_idx - RJL 040622 */ 1635c1776,1777 < printf("Warning: unknown table %s found in scanned datafile %s, ignored.\n",error_table,scan_filename); --- > printf("pr_init Warning: unknown table %s found in scanned datafile %s, ignored.\n", > error_table,scan_filename); 1641c1783,1784 < printf("Warning: invalid keysize %d for key %s, must be %d, ignored.\n", (int)strlen(hcg_t), hcg_t, HCG_KEY_SIZE); --- > printf("pr_init Warning: invalid keysize %d for key %s, must be %d, ignored.\n", > (int)strlen(hcg_t), hcg_t, HCG_KEY_SIZE); 1646,1648c1789 < if(HCG_KEY_SIZE == 8) < ver_chars = 2; < else ver_chars = 3; --- > ver_chars = (HCG_KEY_SIZE == 8)? 2 :3; /*size of version number subfield of pkey */ 1649a1791 > /* copy version digits from pkey offset: */ 1651,1652c1793,1794 < < if(atoi(temp_verstring) > MAXVERSIONS || atoi(temp_verstring) < 0) --- > vernbr = atoi(temp_verstring); > if (vernbr > MAXVERSIONS || vernbr < 0) 1654,1655c1796,1798 < printf("Warning: invalid version %d for key %s, exiting.\n", atoi(temp_verstring), hcg_t); < exit(0); --- > printf("Warning: invalid version %d for key %s, exiting.\n", > vernbr, hcg_t); > exit(0); /* exit closes (hcg_ascii_fp)? */ 1657c1800 < if(encode(hcg_t, &hcg_k) != 1) --- > if(encode(hcg_t, &hcg_k) != 1) /* alters hcg_key hcg_k */ 1662d1804 < 1665a1808,1810 > dprintdd("hcg_row = %d, hcg_version = %d in ", > hcg_row, hcg_version);DP; /* newline in DP */ > /* check new row, update maxrow, maxver - RJL 040425 */ 1667c1812,1813 < if (hcg_row > hcg_ts_list[hcg_tbl_idx].ts_list[hcg_version].maxrow) --- > /* This reported 1-char pkeys only during load of table FO - RJL 040616 */ > if (hcg_row > hcg_ts_list[hcg_tbl_idx].ts_list[hcg_version].maxrow){ 1669c1815,1817 < if (hcg_version > hcg_table_seq_list[hcg_tbl_idx].maxver) --- > //dprintdd("New maxrow = %d from key %x\n", hcg_row, hcg_k); > } > if (hcg_version > hcg_table_seq_list[hcg_tbl_idx].maxver){ 1670a1819,1820 > dprintdd("New maxver = %d from key %x\n", hcg_version, hcg_k); > } 1672,1675c1822 < } /* while !feof */ < fclose(hcg_ascii_fp); < hcg_parse(filelist,scan_filename,&i); < } /* while scan_filename */ --- > } /* while(!feof(hcg_ascii_fp))*/ 1676a1824,1831 > if (infile_is_open){ > fclose(hcg_ascii_fp); /* finished this infile */ > infile_is_open = 0; > } > hcg_parse(filelist,scan_filename,&fnidx);/* get next infile name */ > } /* while scan_filename */ > if (hcg_log == 1) /* added 040622 - RJL */ > fclose(logdata_fp); /* done copying infiles */ 1679,1680c1834,1836 < if (hcg_log != 2) < fclose(logdata_fp); --- > /* if (hcg_log != 2) why? = RK: 04042only 5 - crashed bde below - RJL 040530 */ > /* if (hcg_log == 1) */ > /* This crashed bde 040530:1150 - RJL: */ 1681a1838 > /* filelist is effectively consumed by now. */ 1682a1840,1857 > /*===================read viewdefs===============================*/ > /* shouldn't this have been done earlier ? - RJL 040622 */ > /* (maybe not if scan filelist gets pkey ranges BEFORE pr_load is called?) */ > /* Open viewdef_filename to load view defs : > * filename = *.viewdefs; > * file format: > * These should be 2 meta-schema table types ([DV]---<[VE]) - RJL 040615 > * define_view 94sbdedefaultsView read > * view_element 94sbdedefaultsView GD 0 > * ... > * define_view 94sbdeview update (All highest versions for update) > * view_element 94sbdeview HG 0 > * ... > * NOTE: viewnames MUST be declared before their resp[ective view_elements. > * BUT: view_elements need NOT be placed directly under their define_View parent. > * E.g., ALL viewnames may be declared before ANY view elements > * (due to the redundant viewname prefix to each view_elelement line).- RJL 040622 > */ 1684c1859,1860 < if ((hcg_ascii_fp=fopen(viewdef_filename,"r")) == NULL) --- > hcg_ascii_fp = fopen(viewdef_filename,"r"); /* split out - RJL 040531 */ > if (hcg_ascii_fp == NULL) 1689c1865,1868 < hcg_tbl_idx = hcg_view_idx = 0; --- > > dprints("Viewdef file %s opened \n", viewdef_filename); > hcg_tbl_idx = 0; > //hcg_view_idx = 0; 1693c1872,1873 < idx = 0; --- > idx = 0; /* reset pointer for hcg_parse - RJL 040601 */ > dprints("next viewdef line: %s\n", hcg_buffer); 1696c1876,1877 < { --- > { /* fields: viewname, mode */ > isDefineViewCmd = 1; /* last cmd is define_view - RJL040622 */ 1698c1879,1880 < if (find_view_idx(viewname)) --- > /*DP;*/ > if (find_view_idx(viewname)) /* alters hcg_view_idx - RJL 040622 */ 1700c1882 < printf("Warning: view %s defined twice, ignored.\n",viewname); --- > printf("Found duplicate definition of view %s: ignored.\n",viewname); 1704,1707c1886,1887 < hcg_parse(hcg_buffer,temp_mode,&idx); < if ((strcmp(temp_mode,"read") != 0) && < (strcmp(temp_mode,"write") != 0) && < (strcmp(temp_mode,"update") != 0)) --- > > if (hcg_view_list.num_views >= MAXVIEWS) 1709c1889,1890 < printf("Error: mode %s specified for view %s is invalid.\n",temp_mode,viewname); --- > printf("Error: Too many views defined (max=%d), next view would have been %s.\n", > MAXVIEWS, viewname); 1712c1893,1900 < if (hcg_view_list.num_views >= MAXVIEWS) --- > /* NEW viewname found and space available - proceed */ > > strcpy(hcg_view_list.view_list[hcg_view_list.num_views].view_name, > viewname); > hcg_parse(hcg_buffer,temp_mode,&idx); /* get mode r/w/u */ > if ((strcmp(temp_mode,"read") != 0) && > (strcmp(temp_mode,"write") != 0) && > (strcmp(temp_mode,"update") != 0)) 1714c1902,1903 < printf("Error: Too many views defined (max=%d), next view would have been %s.\n",MAXVIEWS,viewname); --- > printf("Error: Invalid mode %s specified for view %s.\n", > temp_mode,viewname); 1717c1906 < strcpy(hcg_view_list.view_list[hcg_view_list.num_views].view_name,viewname); --- > 1719,1720c1908,1911 < for (i=0; i<100; i++) < hcg_view_list.view_list[hcg_view_list.num_views].version_list[i] = '\0'; --- > > for (j=0; j hcg_view_list.view_list[hcg_view_list.num_views].version_list[j] = '\0'; > printf("pr_init:1878: added viewname '%s' to viewdefs file.\n", viewname); 1722c1913,1915 < } /* if define_view */ --- > > } /* end if cmd = define_view */ > 1725c1918,1920 < { --- > { /* fields: viewname ==> fkey2parent, table_type, version_tag */ > isDefineViewCmd = 0; /* last cmd is define_view - RJL040622 */ > 1726a1922,1923 > dprints("view_element viewname = %s\n", viewname); > /*DP;*/ 1729c1926,1928 < printf("Warning: view %s specified in view_element statement is not defined, ignored.\n",viewname); --- > printf( > "Warning: view_element's fwd-ref to new viewname %s is not allowed: view_element is ignored.\n", > viewname); 1736c1935,1937 < printf("Warning: unknown table (%s) specified for view %s in view_element statement, ignored.\n",table_abbrev,viewname); --- > printf( > "Warning: unknown table (%s) specified - view_element is ignored.\n", > table_abbrev); 1739a1941 > /* Now can assume valid hcg_table_idx - RJL 040616 */ 1741a1944 > /* TBD: put all this version-checking into a subroutine - RJL 040622 */ 1744c1947,1948 < printf("Warning: version-offset %d specified for view %s in view_element statement is out of range, ignored.\n",hcg_version,viewname); --- > printf("Warning: version-offset %d for view %s in view_element statement is out of range, ignored.\n", > hcg_version,viewname); 1752c1956,1957 < printf("Error: view %s invoked on table %s as write, MAXVERSION of %d is used\n",viewname, table_abbrev, MAXVERSIONS); --- > printf("Error: view %s invoked on table %s as write, MAXVERSION of %d is used\n", > viewname, table_abbrev, MAXVERSIONS); 1758c1963,1967 < printf("Warning: absolute version-number %d specified for view %s in view_element statement is higher than current max-version (%d), ignored.\n",hcg_version,viewname,hcg_table_seq_list[hcg_tbl_idx].maxver); --- > printf("Warning: absolute version-number %d specified for view %s \n", > hcg_version, viewname); > printf( > "\tin view_element stmt exceeds current max-version(%d),ignored.\n", > hcg_table_seq_list[hcg_tbl_idx].maxver); 1765,1778c1974,1975 < printf("Warning: version-offset %d specified for view %s in view_element statement would lead ",hcg_version,viewname); < printf("to an invalid version number (<1), current max-version (%d), ignored.\n",hcg_table_seq_list[hcg_tbl_idx].maxver); < hcg_read_next(); < continue; < } < if (hcg_version > 0) < hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] = (char) hcg_version; < else < hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] = (char) hcg_table_seq_list[hcg_tbl_idx].maxver+hcg_version; < } /* if view_element */ < else < if ((temp_command[0] != '\0') && (strncmp(temp_command,"/*",2) != 0)) < { < printf("Warning: unknown command (%s) found in view-definition file (%s), ignored.\n",temp_command,viewdef_filename); --- > printf("Warning: version-offset %d specified for view %s in view_element statement ",hcg_version,viewname); > printf(" would lead to an invalid version number (<1), current max-version (%d), ignored.\n",hcg_table_seq_list[hcg_tbl_idx].maxver); 1781a1979,2005 > /* update hcg_view+_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx]: */ > if (hcg_version > 0) /* absolute version no. */ > hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] = > (char) hcg_version; > else /* maxver + negative version offset */ > hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] = > (char) hcg_table_seq_list[hcg_tbl_idx].maxver+hcg_version; > hcg_read_next(); /* added 040622 - RJL */ > continue; /* added 040622 - RJL */ > } /* end if view_element */ > > /* TBChecked: How is view-element added to viewname's child-list?-RJL 040616 */ > > else { > if (temp_command[0] != '\0') > { > if ( temp_command[0] != '/' || > (temp_command[1] != '*' && temp_command[1] != '/') ) > { /* not null and not a comment */ > dprintss( > "Warning: unknown command (%s) found in view-definition file (%s), ignored.\n", > temp_command,viewdef_filename); > } > } > else /* empty temp_command ==> empty line */ > dprint("Empty line found in viewdefs file - igored \n"); > } /* not view_element or define_view */ 1785,1787d2008 < btree_initialized(); < < hcg_initialized = 1; 1789c2010,2013 < } --- > btree_initialized(); /* prevent btree use: tbl##btidx=SEQUENCESEARCH */ > hcg_initialized = 1; /* prevent redo of pr_init; enable dump to bde_abort.dat */ > /*DP;*/ > } /* end pr_init (1592:1922)*/ 1812a2037 > 1831a2057,2058 > /* Calls dup_row_warning if elt is already in table. */ > /* Assumes and maintains tbl rows in ascending pkey order */ 1882c2109 < /* The assert macro aborts if more than one child is linked in - RJL 94/12/6 */ --- > /* The macro aborts if more than one child is linked in - RJL 94/12/6 */ 2041c2268 < } --- > } /* end pr_link */ 2074c2301 < if (find_view_idx(viewname)){\ --- > DP; if (find_view_idx(viewname)){\ 2086a2314,2316 > /******************************************************************/ > /* pr_check_fkey modified: print 32bit unsigned fkey as hex */ > /******************************************************************/ 2088d2317 < /* pr_check_fkey modified: print 32bit unsigned fkey as hex */ \ 2107c2336,2338 < /* This macro is used set the default value of non-key fields of type cX or tX*/ --- > /* This macro sets the default value of non-key fields of type cX or tX */ > /* its only client is do_pr_add(). */ > /* error at pr_load.c:2283: unterminated character constant - RJL 040616 */ 2120c2351 < (tbl_ptr)->fldname[i--] = (char)'?';\ --- > (tbl_ptr)->fldname[i--] = (char) '\?';\ 2125c2356 < /********************************************************************************/ --- > /*************************************************************************/ 2128c2359 < /* Abstract : This function is used to log a call to pr_add to hcg_logfile */ --- > /* Abstract : This function is used to log a pr_add transaction */ 2131,2132c2362,2369 < /* */ < /********************************************************************************/ --- > /**************************************************************************/ > /* TBD: Define a macro for all these cases. No need for repetitious code */ > /* Pre-condition: hcg_log == 1 */ > /* Pre-condition: exists FILE* hcg_logfileptr open for output */ > /* Pre-cond failed 040712: pr_startlog was not called to open it */ > > //New state model for logging/replay - RJL 040712; (not tested for state 3 yet) > // See preamble to pr_load.c; do log_pr_add iff (hcg_log) 2136c2373,2374 < char outkey[3][HCG_KEY_SIZE+1]; --- > FILE* hcg_logfileptr; // pre-cond: already open (by startllog?)- RJL 040708 > char outkey[3][HCG_KEY_SIZE+1]; // updated by decode(outkey[j], anykeyfield) 2138,2140c2376,2380 < < /* Return if logging not on */ < if (hcg_log != 1) --- > EP; > /* pre-condition: logging is turned on by startlog(); */ > //assert(hcg_log); /* failed 040713.0130 - RJL 040713 */ > if (!hcg_log) { > dprint("WARNING: log_pr_add call with hcg_log = 0, ignored.\n"); 2141a2382,2385 > } > > assert(find_tbl_idx(tbl)); /* alters tbl##curr; exit if NULL */ > if (hcg_log){ 2143d2386 < find_tbl_idx(tbl); 2147c2390 < --- > /* TBD: make this a switch on idx = enumerated ttabbrev symbols */ 2153,2154c2396,2399 < PrintCheck(fprintf(hcg_logfileptr, " %-8s %-50s %-50s %-2s %-15s\n" < , outkey[0], FOcurr->xfont, FOcurr->psfontname, FOcurr->psfontsize, FOcurr->bdefont)); --- > PrintCheck(fprintf(hcg_logfileptr, > " %-8s %-50s %-50s %-2s %-15s\n", > outkey[0], FOcurr->xfont, FOcurr->psfontname, > FOcurr->psfontsize, FOcurr->bdefont)); 2161,2163c2406,2410 < PrintCheck(fprintf(hcg_logfileptr, " %-8s %-10s %8.4f %8.4f %-4s %-25s %-10s %-10s %8.4f %8.4f\n" < , outkey[0], GDcurr->shape, GDcurr->width, GDcurr->height, GDcurr->hsegpattern, GDcurr->txtfont < , GDcurr->location, GDcurr->justify, GDcurr->gcwidth, GDcurr->gcheight)); --- > PrintCheck(fprintf(hcg_logfileptr, > " %-8s %-10s %8.4f %8.4f %-4s %-25s %-10s %-10s %8.4f %8.4f\n", > outkey[0], GDcurr->shape, GDcurr->width, GDcurr->height, > GDcurr->hsegpattern, GDcurr->txtfont, GDcurr->location, > GDcurr->justify, GDcurr->gcwidth, GDcurr->gcheight)); 2251c2498,2499 < } --- > } /* end if hcg_log */ > } /* end log_pr_add */ 2259a2508,2509 > /* RJL040712: log_pr_add is a no-op unless hcg_log==1 */ > 2271c2521 < if (hcg_log == 1) --- > if (hcg_log) 2291,2292c2541 < < if (!find_view_idx(viewname)) --- > DP; if (!find_view_idx(viewname)) 2294c2543 < printf("[do_]pr_add ignored; view %s not found.\n",viewname); --- > printf("do_pr_add ignored; view %s not found.\n",viewname); 2316,2319c2565,2572 < assert(strlen( FOelt->xfont)>0); pr_check_str (FO,FOelt,xfont,50); < assert(strlen( FOelt->psfontname)>0); pr_check_str (FO,FOelt,psfontname,50); < assert(strlen( FOelt->psfontsize)>0); pr_check_str (FO,FOelt,psfontsize,2); < assert(strlen( FOelt->bdefont)>0); pr_check_str (FO,FOelt,bdefont,15); --- > assert(strlen( FOelt->xfont)>0); > pr_check_str (FO,FOelt,xfont,50); > assert(strlen( FOelt->psfontname)>0); > pr_check_str (FO,FOelt,psfontname,50); > assert(strlen( FOelt->psfontsize)>0); > pr_check_str (FO,FOelt,psfontsize,2); > assert(strlen( FOelt->bdefont)>0); > pr_check_str (FO,FOelt,bdefont,15); 2321c2574 < log_pr_add ("FO", viewname, FOelt); --- > log_pr_add ("FO", viewname, FOelt); /* iff hcg_log */ 2424c2677,2678 < } --- > return; /* RJL 030811 */ > } /* end do_pr_add */ 2427,2428c2681,2682 < /* This routine is used to read the (already open datafile) and call pr_add */ < /* with each row, to add it to the database. Validations for valid table-id, */ --- > /* This routine is used to read the (already open) datafile and call pr_add */ > /* for each row, to add it to the database. Validations for valid table-id, */ 2432c2686,2695 < /******************************************************************************/ --- > /*****************************************************************************/ > /* If "SR"("SP") is read (first/last command currently), set hcg_replay to 1 (0); */ > /* Client calls to pr_startlog (pr_stoplog) set hcg_log to 1 (0); */ > /* (see preamble to pr_load.c ). (hcg_log=1 ==>log the pr_load call not each row.)*/ > /* hcg_replay ==> load checkpoint *DB1.dat then read the logfile until "SP" or EOF.*/ > /* pre-condition: file at hcg_ascii_fp already opened */ > /* WARNING: make sure clients call hcg_read_next to prime hcg_buffer - RJL 040616 */ > /* Pre-condition: (hcg_ascii_fp = fopen(file_name,"r") != NULL) - from pr_load */ > /* Counts: emptyLines,commentLines,badKeySizes,unEncodableKeys,tblTypesNotFound,rowsNotInView */ > 2437c2700,2708 < char temp_verstring[ABBREV_NAME_LENGTH]; --- > int emptyLines = 0; /* counts empty lines skipped (firsttokenlength == 0)-RJL040621 */ > int commentLines = 0; /* counts comment lines skipped */ > int badKeySizes = 0; /* counts invalid non-zero pkey lengths */ > int unEncodableKeys = 0; /* counts pkeys not encodable */ > int rowTypesNotFound= 0; /* counts table types not in view */ > int rowsNotInView = 0; /* counts rows rejected #ifndef NEW_VERSION*/ > > char temp_verstring[ABBREV_NAME_LENGTH]; /* abbrev, not version? */ > char char1, char2; 2441,2443d2711 < /*hcg_read_next();*/ < while ( !feof(hcg_ascii_fp) ) < { 2444a2713,2719 > EP; > assert(hcg_ascii_fp != NULL); /* pre-condition */ > hcg_read_next(); /* added 040616 - RJL */ > while ( !feof(hcg_ascii_fp) ) /* assume hcg_ascii_fp = fopen(file_name,"r") */ > { > //DP; > dprints("load_data at pr_load.c:2664: parsing this hcg_buffer:\n\t'%s'\n", hcg_buffer); 2447,2455c2722,2727 < < if ( strlen(hcg_t) == 2 ) { < if( strcmp( hcg_t, "SR") == 0 ) { < #ifdef DEBUG < printf("StartLog command found: \n"); < printf("Replay logfile is %s \n", logfile); < #endif < return 1; < } --- > /* Expecting pkey or "SR" or comment prefix */ > if (strlen(hcg_t) == 0) /* block added 040621 - RJL */ > { dprint("Empty line found in file %s\n"); > emptyLines ++; > hcg_read_next(); > continue; 2457,2458c2729 < else < if (!find_tbl_idx(hcg_t)) --- > else if (strcmp( hcg_t, "SR") == 0 ) // and hcg_log == 0 ?? - RJL040712 2460,2461c2731,2741 < strncpy_null(temp_verstring, hcg_t, HCG_ABBR_SIZE); < printf("Warning: unknown table (%s) found in datafile, ignored.\n",temp_verstring); --- > dprint("StartLog command found: \n"); > dprints("Replay logfile is %s \n", logfile); > /* is logfile known ? */ > hcg_replay = 1; > return 1; // TBD: close file, start replay - RJL 040522 > } > else if(strlen(hcg_t) != HCG_KEY_SIZE) > { > dprintds("Warning:load_data:invalid keysize %d for key %s, line ignored.\n", > (int)strlen(hcg_t), hcg_t); > badKeySizes++; 2465,2466c2745 < < if(strlen(hcg_t) != HCG_KEY_SIZE) --- > else if (!find_tbl_idx(hcg_t)) /* table type not found for field 1 */ 2468c2747,2760 < printf("Warning: invalid keysize %d for key %s, must be %d, ignored.\n", (int)strlen(hcg_t), hcg_t, HCG_KEY_SIZE); --- > strncpy_null(temp_verstring, hcg_t, HCG_ABBR_SIZE); > /* TBD: call function here to check for comments */ > /* init():546-550 skips logfile's leading comments - RJL 040429 */ > char1 = (char)(*hcg_t); //comment prefix ? > char2 = (char)(*(hcg_t+1)); //comment prefix ? > if ((char1 == '/') && ((char2 == '/')||(char2 =='*'))) > commentLines++; > else > { > dprints( > "Warning: unknown table type:'%s' found in datafile, ignored.\n", > temp_verstring); > rowTypesNotFound++; > } 2473,2474c2765 < if(HCG_KEY_SIZE == 8) < ver_chars = 2; --- > if (HCG_KEY_SIZE == 8) ver_chars = 2; 2475a2767,2768 > > /* strcpy version field from hcg_t[offset:ttabbr] and append '\0' */ 2480c2773,2774 < printf("Warning: invalid key %s, ignored.\n", hcg_t); --- > dprints("Warning: invalid key %s, ignored.\n", hcg_t); > unEncodableKeys++; 2483c2777 < } --- > }; 2488,2489c2782,2788 < < if (((char) hcg_version) != hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx]) --- > /* The next block skips unwanted table versions > * Alt: why not use meets_view() here? - RJL: 031012 > * Added NEW_VERSION brackets - RJL 031023 > */ > #ifndef NEW_VERSION > if (((char) hcg_version) != > hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx]) 2490a2790 > rowsNotInView++; 2494c2794 < --- > #endif 2496a2797 > 2500d2800 < /* 93su523 PGEN merge (BEGIN) */ 2501a2802 > /* idx is cursor for during pr_parse below, in while looop */ 2504,2505c2805 < /* 93su523 PGEN merge (END) */ < --- > /* Not logged: pr_load logs an "LD" command with this filename - RJL 0040712 */ 2507,2508c2807,2820 < } < } --- > } /* end while */ > > /* print statistics: */ > printf("EOF: Ignored the following lines:\n"); > if (commentLines >0) > printf("\tComment lines:\t%i\n", commentLines); > if (badKeySizes > 0) > printf("\tLines with wrong Key Sizes:\t%i\n", badKeySizes); > if (rowTypesNotFound > 0) > printf("\tLines with wrong table type:\t%i\n", rowTypesNotFound); > if (rowsNotInView > 0) > printf("\tLines not in the View: \t%i\n\n", rowsNotInView); > if (unEncodableKeys > 0) > printf("\t unEncodableKeys: \t%i\n\n", unEncodableKeys); 2509a2822 > return 0; // TBD: Client must close file 2510a2824 > } /* end load_data (2599-2720) */ 2517,2518c2831,2837 < /******************************************************************************/ < void pr_parse (char viewname[], char buffer[], int tbl_encoding, int idx, hcg_key hcg_k) --- > /*****************************************************************************/ > /* macros useless - each table has distinct sequence of field names - RJL */ > /* actual arg is &idx in client load_data */ > /* Case blocks can become method over-rides in table_row_classes from gencpp */ > /*****************************************************************************/ > void pr_parse (char viewname[], char buffer[], > int tbl_encoding, int idx, hcg_key hcg_k) 2521,2523c2840 < #ifdef DEBUG < printf("Row to be added = %s\n", buffer); < #endif --- > dprints("Row to be added = %s\n", buffer); 2726c3043 < } --- > } /* end pr_parse */ 2729c3046 < /* This routine is used to load the contents of the virtual database from the */ --- > /* pr_load is used to load the contents of the virtual database from the */ 2732c3049 < /* just verifys the view name, opens the file, and then calls load_data. */ --- > /* just verifies the view name, opens the file, and then calls load_data. */ 2734a3052,3055 > /* RJL 040520: exit(1|2|3) if !hcg_initialized */ > /* |can't find viewname or open file_name */ > /* |replayStatus != 0 (pr_replay failure) */ > 2740c3061,3062 < int doReplay; --- > int isLogFile; /* was doReplay*/ > EP; 2745d3066 < /* End Genlog Addition */ 2746a3068,3069 > /* End Genlog Addition */ > 2752a3076 > dprints("In pr_load: viewname is %s\n", viewname); 2757a3082 > 2763,2765c3088,3106 < doReplay = load_data (viewname); < fclose(hcg_ascii_fp); < if( doReplay ) { --- > /* Pre-cond for load_data: hcg_ascii_fp is valid: */ > /* If load_data sees no "SR" command it loads database; */ > /* else it closes logfile, pr_replay loads checkpoint fileDB1.dat */ > /* then repays logfile - RJL 040616 */ > /* check for global args to load_data below: =- RJL 040622 */ > isLogFile = > load_data(viewname); /* isLogFile=1 iff "SR" command on line 1 */ > /* and sets hcg_replay state flag */ > fclose(hcg_ascii_fp); // restored - RJL 040522 > > dprints("\nFinished load; fclose %s\n TBD in load_data", file_name); > dprintd("pr_load: isLogFile = %d : == 1 iff 'SR' at BOF\n", isLogFile); > dprintd("load_data returns isLogFile = %d\n", isLogFile); > > if( isLogFile ) { > DP; dprints( "load_data found SR cmd - calling pr_replay on file %s\n", > file_name); > dprintdd("hcg_log = %d, hcg_replay = %d\n", hcg_log, hcg_replay); > 2766a3108,3117 > > > /* WARNING: If pr_replay sees a LD command it re-calls load_data */ > /* (This should work because pr_replay is tail-recursive) */ > /* Replay updates can be done by 's' Keypress callback - one transaction at a time */ > > if (replayStatus != 0) { > printf("Error: pr_replay returned replayStatus %d = FAIL: aborting bde\n\n", > replayStatus); > exit(3); 2768a3120,3126 > else { > DP; dprintd("isLogFile = %d; data is loaded \n", isLogFile); > dprintdd("hcg_log = %d, hcg_replay = %d\n", hcg_log, hcg_replay); > } > > return; > } /* end (void) pr_load (2942-3017 - RJL 040616 */ 2790d3147 < 2792a3150,3179 > > /******************************************************************** > * Function stripDPath scans arg2, and copies only the filename > * without directory path segments (if any) to arg1. It returns isLocal = 0 or 1. > * Tested as stripDPath.c #included in ../test/stripDiryPath.c - RJL 030810 > * Clients: pr_init //TBD: pr_log.c:2177 pr_replay()? > ****************************************************************** > */ > int stripDPath(char* localname, char* scan_fname) > /* strip directory segments from copy of scan_fname into localname */ > /* Client: pr_init above */ > { > #define BUFFERSIZE 256 > int isLocal = 0; > char tempfname[BUFFERSIZE]; > char* tempptr, * tempptr0, * tempptr1; > tempptr0 = tempptr = &tempfname[0]; > assert (strlen(scan_fname) < BUFFERSIZE); > strcpy(tempfname, scan_fname); /* update tempfname */ > tempptr1 = strrchr(tempptr0, '/'); /* reverse scan; NOT FOR MSWindows */ > if (tempptr1 == NULL) tempptr1 = tempptr0-1; /* add 1 later */ > else printf("chars skipped = %d\n", (int)(tempptr1-tempptr0)); > assert ((char) *tempfname=='/' || \ > strlen(tempfname)==strlen(scan_fname)); > printf("char at tempfname = %c\n", (char)tempfname[0]); > strcpy(localname, (char*)(tempptr1+1)); > printf("localname=%s\n", localname); > return (isLocal = (tempptr } /* end stripDPath */ > /*****************************************************************/ Binary files genpr_util.050316/pr_load.o and newpr_util050316/pr_load.o differ diff -bitw genpr_util.050316/pr_log.c newpr_util050316/pr_log.c 1c1 < /******************************************************************************/ --- > /************************************************************************/ 5c5,16 < /******************************************************************************/ --- > /************************************************************************/ > /* > * $Log: pr_log.c,v $ > * Revision 1.1.2.26 2005/02/25 00:34:13 lechner > * > * cvs diff pr_util 050223: No changes except hasType macro in 94sbde_schema.h > * > * Revision 1.1.2.25 2004/11/29 20:10:20 lechner > * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. > * > ************************************************************************/ > /* Log aded 041129 - RJL */ 14a26 > /* hcg_logfile[NAMELENGTH] defined where #ifdef MAIN (in bde/src/fileio.cc)*/ 16,17c28 < < /******************************************************************************/ --- > /**********************************************************************/ 19c30 < /******************************************************************************/ --- > /**********************************************************************/ 24c35,38 < strcpy(); --- > char *strcpy( > char *s1, > const char *s2); > /* strcpy();*/ 41c55 < extern void pr_del(int); /* REQUIRES XXcurr ptr */ --- > extern void pr_del(int); /* arg1=XX.idx; REQUIRES valid XXcurr ptr */ 44,45c58,60 < #ifdef BDELOG < extern "C" int replay_log(void); --- > /* #ifdef BDELOG */ > #ifdef GENLOG > extern /*"C"*/ int replay_log(void); 64c79 < char viewname[NAMELENGTH]; --- > char viewname[NAMELENGTH]; // in limits.h? -see pr_load.c 86,89d100 < int dbg = 1; < #define dprintf(string) if (dbg) printf(string); < #define dprintf1arg(string, arg1) if (dbg) printf(string, arg1); < #define dprintf2args(string, arg1, arg2) if (dbg) printf(string, arg1, arg2); 91c102 < /******************************************************************************/ --- > /************************************************************************/ 93c104 < /******************************************************************************/ --- > /************************************************************************/ 185c196 < --- > EP; 277c288 < } --- > } /* end mysleep */ 353c364 < } --- > } /* end get_delta_tee */ 398c409 < if (hcg_log == 1) --- > if (hcg_log) 456c467 < --- > EP; 458d468 < 467c477 < if (!find_view_idx(viewname)) --- > DP; if (!find_view_idx(viewname)) 473c483,484 < /* check that logging is off - if not, return without starting log*/ --- > /* pre-condition: logging is off - recursion not allowed */ > assert(!hcg_log); 475c486 < if (hcg_log != 0 ) --- > if (hcg_replay) 477,483c488 < if (hcg_log == 1 ) < { < printf("Error: pr_startlog called when logging was not off.\n"); < return (-3); < } < else if ( hcg_log == 2) < printf("Error: pr_startlog called when logging was not off.\n"); --- > printf("WARNING:: pr_startlog called during replay .\n"); 484a490 > 492c498 < /* set global hcg_logfile to file name of log file (w/out extention) */ --- > /* set global hcg_logfile to file name of log file (w/out extension) */ 494,497c500,503 < (i>=0) && (file_name[i]!= '.'); < i--); < < if (i<0) /* no extention */ --- > ((i>=0) && (file_name[i]!= '.')); /* no period found yet */ > (i--)); > /* (i = namelength before type extension, i == -1 if no type ext.) */ > if (i<0) /* no extension */ 499,500c505 < < else /* remove extention */ --- > else /* remove extension */ 516c521 < --- > /* This will be a checkpoint for initialization during replay. */ 518c523 < pr_dump (viewname, logfileDB1_name, FALSE, "w" ); --- > DP; pr_dump (viewname, logfileDB1_name, FALSE, "w" ); 521c526 < --- > /* hcg_replay is either on or off. - RJL 040712 */ 526c531 < logstr("SR\n"); --- > logstr("SR\n"); // logstr is conditional on hcg_replay */ 540,541c545,549 < /* It optionally dumps a current copy of the database and closes */ < /* the logfile */ --- > /* If (dump_flag), dumps a copy of the database */ > /* to logfileDB2_name and closes the logfile */ > /* [RJL 040615] If (hcg_log==1) and viewname is valid, */ > /* sets hcg_log = 0, closes hcg_logfileptr and returns 0; */ > /* else is a no-op (returning -1 if (!hcg_log), -2 if viewname invalid) */ 555c563 < --- > EP; 564c572 < /* check that viewname is valid - if not, return without starting log*/ --- > /* check that viewname is valid - if not, return without stopping log*/ 566c574 < if (!find_view_idx(viewname)) --- > DP; if (!find_view_idx(viewname)) 568c576 < printf("Error: view %s passed to pr_startlog is not defined.\n",viewname); --- > printf("Error: view %s passed to pr_stopog is not defined.\n",viewname); 576c584 < logwait(); --- > logwait(); /* conditional on hcg_replay */ 580,584c588,589 < logstr("SP\n"); < < /* Terminate logging by setting global hcg_log = 0 */ < < hcg_log =0; --- > logstr("SP\n"); /* conditional on hcg_replay */ > hcg_log = 0; /* Terminate logging */ 591c596 < pr_dump (viewname, logfileDB2_name, FALSE, "w" ); --- > DP; pr_dump (viewname, logfileDB2_name, FALSE, "w" ); 600c605,606 < /* This function is used to parse the data file(logdata.txt)*/ --- > /* This function is used to parse the data in logdata.txt */ > /* (to which pr_log appended all files in pr_init's arg2) */ 602,610c608,623 < /* original data files. It returns a string list with */ < /* the names of the new files. The new file names are */ < /* separated by spaces. It returns a value to indicate */ < /* success or failure. */ < /* */ < /* Arguments: newlist - a list of files separated by commas */ < /* */ < /* Preconditions: */ < /* newlist must be a character string of size BUFSIZE */ --- > /* original data files. It initializes char* newlist with */ > /* new temp* filenames separated by spaces. These files */ > /* will be read and deleted before replaying the logfile. */ > /* The return value indicates success=0, or failure <0. */ > /* */ > /* Arguments: newlist - updated list of temp* filenames. */ > /* */ > /* Preconditions: Added by RJL 030809: */ > /* File logdata.txt must exist with data TBscanned */ > /* Datafile lines: field 1 cannot be "LogDataFile " */ > /* newlist must not exceed BUFSIZE bytes in length */ > /* filenames must not exceed NAMELENGTH bytes */ > /* (BUFSIZE=256, NAMELENGTH=30 in bde's schema.h) */ > /* (FILENAME_MAX and PATH_MAX=255 in limits.h) */ > /* (Non-local file names cannot be prefixed by 'temp' */ > /* until path prefixes are deleted - RJL 030810.) */ 612,613c625,626 < /* returns: 0 - success */ < /* <0 - failure */ --- > /* returns: 0 - success (newlist has tempfnames) */ > /* <0 - failure (newlist is null) */ 619c632,633 < char datafile[NAMELENGTH],token[BUFSIZE],tempfname[NAMELENGTH],tempnewlist[BUFSIZE]; --- > char datafile[NAMELENGTH],token[BUFSIZE]; > char tempfname[NAMELENGTH],tempnewlist[BUFSIZE]; 622c636,637 < --- > EP; > newlist[0] = '\0'; 625,627c640,643 < if ((data_fp = fopen(datafile, "r")) ==NULL) < return(-3); < --- > if ((data_fp = fopen(datafile, "r")) ==NULL) { > printf("Failed to open file logdata.txt\n"); > return(-3); //newlist[0] = '\0'; > } 629,630c645,647 < hcg_read_next(); /* read first line of data file */ < idx = 0; --- > hcg_read_next(); /* read first line to hcg_buffer[BUFSIZE] */ > assert(strlen(hcg_buffer) <= BUFSIZE); /* else buffer overflow */ > idx = 0; /* running index in line buffer */ 633,634c650,651 < /* invalid file format */ < return(-5); --- > printf("File logdata.txt: Invalid format \n"); > return(-5); //newlist[0] = '\0'; 635a653 > 641,642c659,662 < if ((temp_fp = fopen(tempfname, "w")) ==NULL) < return(-3); --- > if ((temp_fp = fopen(tempfname, "w")) == NULL) { > printf("fopen(%s, \"w\" failed \n", tempfname); > return(-3); /* fail to open file */ > } 648a669 > 652a674 > assert(strlen(hcg_buffer) <= BUFSIZE); /* else buffer overflow */ 655c677 < } /* end while !feof loop */ --- > } /* end loop to copy lines until next "LogDataFile" token */ 660c682,683 < strcpy(newlist,tempnewlist); --- > assert(strlen(tempnewlist) <= BUFSIZE); > strcpy(newlist,tempnewlist); // non-empty list of fnames 662c685 < } --- > } /* end log_parselogdata */ 670,671c693 < /* Arguments: filelist - a list of files separated by */ < /* commas. */ --- > /* Arguments: filelist - list of files separated by commas */ 680c702 < dprintf1arg("Unlinked %s.\n",token); --- > dprints("Unlinked %s.\n",token); 687a710 > /* log_do_ SHOULD be renamed log_replay_ etc.-RJL 031019 */ 719c742 < if (!find_tbl_idx(tablename)) --- > if (!find_tbl_idx(tablename)) /* updates hcg_tbl_idx */ 727c750,751 < tbl_encoding = encoding(hcg_table_seq_list[hcg_tbl_idx].ttabbrev); /* global hcg_tbl_idx is set by find_tbl_idx */ --- > tbl_encoding = encoding(hcg_table_seq_list[hcg_tbl_idx].ttabbrev); > /* global hcg_tbl_idx is set by find_tbl_idx */ 783c807,808 < fprintf(stderr,"%s: %d: log_do_add: pr_create failed\n", __FILE__, __LINE__); --- > fprintf(stderr, "%s: %d: log_do_add: pr_create failed\n", > __FILE__, __LINE__); 1025c1050 < } --- > } /* end convert2temp */ 1028c1053 < /* Function: log_do_delete */ --- > /* Function: log_do_delete (log_replay_delete - RJL) */ 1033a1059,1063 > /* RJL note 031021: int find_tbl_idx puts a table type code in tbl_idx. > * and returns 0 or 1; pr_delete(XX) really deletes a row of the table 'type' > * with integer code XX##_idx. > * It works via this macro call: #define pr_delete(tbl) pr_del(tbl##_idx) > */ 1036c1066 < long unsigned temp_id; --- > 1037a1068 > int isValidTbl; 1039c1070,1075 < find_tbl_idx(pkeychar); --- > isValidTbl = find_tbl_idx(pkeychar); > if (!isValidTbl) { > fprintf(stdout, "find_tbl_idx fails to find pkey %s: DL cmd ignored.\n", pkeychar); > return; > } > /* else (find_tbl_idx() correctly updated hcg_tbl_idx) */ 1042c1078 < dprintf1arg("Found DL with pkey %s.\n",pkeychar); --- > dprints("Found DL (delete-row) cmd. with pkey %s.\n", pkeychar); 1044,1045c1080,1081 < switch(tbl_encoding) { < --- > switch(tbl_encoding) > { 1127,1128c1163,1164 < } /* end if decode */ < } --- > } /* end if encode */ > } /* end log_do_delete */ 1146a1183 > int isValidTbl; 1149,1152c1186,1197 < find_tbl_idx(pkeychar); < if(encode(pkey,&hcg_k) ==1) < { < dprintf1arg("Found DL with pkey %s.\n",pkeychar); --- > isValidTbl = find_tbl_idx(pkey); > if (!isValidTbl) { > fprintf(stdout, "Illegal pkey %s ; SET_INT cmd. ignored during replay \n", pkey); > return; > } > if (!encode(pkey,&hcg_k)) { /* updates hcg_k to unsigned long[?-RJL040614] */ > dprints("log_do_set_int ignored: : failed to encode pkey %s\n", pkey); > return; > } > /* else pkey and hcg_tbl_idx are valid and encoding to hcg_k succeeds */ > > dprints("Found DL with pkey %s.\n", pkeychar); 1159,1160c1204,1205 < printf("log_do_set_int %s not found.\n", pkeychar); < else{ --- > printf("log_do_set_int pkey %s not found.\n", pkeychar); > else{ /* no int fields */ 1168c1213 < else{ --- > else{ /* no int fields */ 1189a1235 > /* POSITION and SHAPE are floats */ 1263,1265c1309,1315 < } /* end switch */ < } /* end if decode */ < } --- > default: > assert(hcg_k = NULL); /* print error and exit */ > break; > > }; /* end switch */ > return; > } /* end log_do_set_int */ 1280c1330,1332 < void log_do_set_flt(const char pkeychar[HCG_KEY_SIZE+1],const char fieldname[NAMELENGTH+1],const float newval) --- > > void log_do_set_flt(const char pkeychar[HCG_KEY_SIZE+1], > const char fieldname[NAMELENGTH+1],const float newval) 1283a1336 > int isValidTbl; 1286,1289c1339,1350 < find_tbl_idx(pkeychar); < if(encode(pkey,&hcg_k) ==1) < { < dprintf1arg("Found DL with pkey %s.\n",pkeychar); --- > isValidTbl = find_tbl_idx(pkey); > if (!isValidTbl) { > fprintf(stdout, "Illegal pkey %s arg. of SET_FLT cmd. during replay \n", pkey); > return; > } > if (!encode(pkey,&hcg_k)) { /* updates hcg_k to unsigned long[?-RJL040614] */ > dprints("log_do_set_int: failed to encode pkey %s\n", pkey); > return; > } > /* else pkey and hcg_tbl_idx are valid and encoding to hcg_k succeeds */ > > dprints("Found DL with pkey %s.\n",pkeychar); 1442,1443c1503 < } /* end if decode */ < } --- > } /* end log_do_set_flt */ 1458c1518,1528 < void log_do_set_key(const char pkeychar[HCG_KEY_SIZE+1],const char fieldname[NAMELENGTH+1],const char newval[HCG_KEY_SIZE+1]) --- > /* THIS DOESN'T MAKE SENSE: 'encode(fieldname,&new_key)'; - RJL 040614 */ > /* fieldname matches a pfkey fieldname in a TA-child-row of a TT-row for hcg_tbl_idx.*/ > /* it is not a pkey itself and cannot be encoded. */ > /* Updating a pkey is a no-no: pkey is a unique immutable identifier. */ > /* Updating an fkey is possible but problematic - chain pointers must track the fkey. */ > /* Such tracking is only possible by unlink and relink macro calls (missing below) */ > /* *************************************************************/ > /* TBD: reject action for pkeys (fieldname[0-1] == pkeychar[0-1]) - RJL 040621 */ > /* #if 0 at line 1559 to EOF */ > void log_do_set_key(const char pkeychar[HCG_KEY_SIZE+1], > const char fieldname[NAMELENGTH+1],const char newval[HCG_KEY_SIZE+1]) 1462,1463c1532,1534 < hcg_key new_key; < --- > int isValidTbl; > char ttabrv[HCG_ABBR_SIZE+1]; > // hcg_key new_key; 1465,1469c1536,1562 < find_tbl_idx(pkeychar); < if(encode(pkey,&hcg_k) ==1) < { < dprintf1arg("Found DL with pkey %s.\n",pkeychar); < if(encode(fieldname,&new_key) ==1) --- > isValidTbl = find_tbl_idx(pkey); > > if (!isValidTbl) { > fprintf(stdout, "Illegal pkey %s: SET_KEY cmd. ignored during replay \n", pkey); > return; > } > if (!encode(pkey,&hcg_k)) { /* updates hcg_k to unsigned long[?-RJL040614] */ > dprints("log_do_set_key: failed to encode pkey %s\n", pkey); > return; > } > /* TBD: prevent pkey pdate; allow fkey update only after adding unlink and relink calls */ > /* else pkey and hcg_tbl_idx are valid and encoding to hcg_k succeeds */ > > dprintss("Found SET_KEY for row pkey %s, pfkeyname %s.\n", pkeychar, fieldname); > /* if(encode(fieldname,&new_key) ==1) */ > /* ERROR ABOVE: newval is the new encoded value for some XXid tbl-row; */ > /* so (if legal), could pr_find XXcurr and update the pkey there. */ > /* newval is an ASCI pfkey; fieldname is its name XXid; */ > > strncpy(ttabrv, fieldname, HCG_ABBR_SIZE); /* ttabrv is problematic as pr_find arg1? */ > ttabrv[HCG_ABBR_SIZE] = '\0'; > /* use var_find_tbl_idx ? - RJL 040614 */ > /* requires further discrimination: (switch(ttyp or tbl_idx?) */ > /* if (pr_find( ttabrv, fieldname, newval)) */ > /* disallow pkey changes; */ > /* fkey changes OK iff unlink/link for referential integrity */ > /* and unlink and relink chain pointers as well - RJL 040614 */ 1471c1564 < dprintf1arg("Found DL with key %s.\n",fieldname); --- > dprints(" SET_KEY with pfkey %s ignored.\n",fieldname); 1472a1566,1571 > fprintf(stdout, "pkey update is illegal; fkey update is not supported - SET_KEY ignored\n"); > } > return; > /* returns above bypass following code for now - RJL 040814 */ > /* per-case, could reject action if tabletype = first 2 bytes of pfkeyname? */ > #if 0 1475c1574,1575 < case 0: /* FO table */ --- > case 0: /* FO table - no fkeys */ > /* e.g.: if strcmp(substr(fieldname,0,2), ttabrv) ==0){ */ 1482a1583 > /* } //end if strcmp */ 1505c1606 < case 3: /* HN table */ --- > case 3: /* HN table - one HGid fkey */ 1514a1616 > 1600,1602c1702,1703 < } /* end if decode of fieldname */ < } /* end if decode of pkey */ < } --- > #endif > } /* end log_do_set_key */ 1617c1718,1719 < void log_do_set_str(const char pkeychar[HCG_KEY_SIZE+1],const char fieldname[NAMELENGTH+1],const char newval[BUFSIZE+1]) --- > void log_do_set_str(const char pkeychar[HCG_KEY_SIZE+1], > const char fieldname[NAMELENGTH+1],const char newval[BUFSIZE+1]) 1620a1723 > int isValidTbl; 1623,1626c1726,1737 < find_tbl_idx(pkeychar); < if(encode(pkey,&hcg_k) ==1) < { < dprintf1arg("Found DL with pkey %s.\n",pkeychar); --- > isValidTbl = find_tbl_idx(pkey); > if (!isValidTbl) { > fprintf(stdout, "Illegal pkey %s arg. of SET_STR cmd. during replay \n", pkey); > return; > } > if (!encode(pkey,&hcg_k)) { /* updates hcg_k to unsigned long[?-RJL040614] */ > dprints("log_do_set_str: failed to encode pkey %s\n", pkey); > return; > } > /* else pkey and hcg_tbl_idx are valid and encoding to hcg_k succeeds */ > > dprints("Found DL with pkey %s.\n",pkeychar); 1775,1776c1886 < } /* end if decode */ < } --- > } /* end log_do_set_str */ 1784a1895 > /* This could be an STL map function if available in 'C". */ 1786c1897 < replayCode encode_token( char *token ) --- > replayCode encode_token( char *token ) /* convert token to command */ 1788a1900,1901 > EP; //assert(tokenlength == 2 || tokenlength == 10);//FAILED 040722.1630 > // failed 040903: called with legal pkey as token and DBrow content 1793a1907,1910 > else { > fprintf(stderr, "Illegal 10-byte commanda\"%s\", ignored\n", token); > return -1; > } 1803a1921,1923 > else { > fprintf(stderr, "Illegal 2-byte commanda\"%s\", ignored\n", token); > return -1; 1805c1925,1926 < else --- > } > else if (tokenlength == HCG_KEY_SIZE) 1806a1928,1931 > else { > dprintsd("Illegal token %s length=%d\n", token, tokenlength); > return -1; /* can't reach here - else 'reach end of non-void fcn' */ > } 1815a1941,1944 > /* It is application-independent and completely chgen-produced. */ > /* TBD? Update MVstate/RFLAG+ to trigger updatedisplaylist and ReDraw? */ > /* RJL 040904: this fails on a pkey token1 in legal DB record */ > /* WARNING: viewfile and viewname may depend on external replay sources? */ 1827a1957 > char viewfile[FILENAME_MAX]; 1836c1966 < dprintf2args("Token =%s, Command = %d\n", token, command); --- > DP;dprintsd("Token =%s, Command = %d\n", token, command); 1844c1974 < dprintf1arg("Found WA with total milliseconds %d.\n",totMsec); --- > dprintd("Found WA with total milliseconds %d.\n", totMsec); 1850a1981 > if (strlen(temp_newkey) == 0) break; // Null pkey -ignore 1888c2019 < hcg_parse(hcg_buffer,viewname,&idx); --- > hcg_parse(hcg_buffer,viewfile,&idx); 1892,1893c2023,2024 < dprintf2args("Found IN with viewname %s, datalist=%s.\n",viewname,temp); < pr_init(viewname,tempdatalist); --- > dprintss("Found IN with viewfile %s, datalist=%s.\n",viewfile,temp); > DP; pr_init(viewfile,tempdatalist); 1901,1902c2032,2033 < dprintf2args("Found LD: viewname:%s,datafile:%s.\n",logviewname, newdatafile); < pr_load(logviewname,newdatafile); --- > dprintss("Found LD: viewname:%s,datafile:%s.\n",logviewname, newdatafile); > DP;pr_load(logviewname,newdatafile); 1907,1908c2038,2039 < dprintf("Found FR.\n"); < pr_free(); --- > dprint("Found FR.\n"); > DP; pr_free(); 1913c2044 < dprintf1arg("Found VN with viewname %s.\n",viewname); --- > dprints("Found VN with viewname %s.\n",viewname); 1918c2049 < dprintf("Found SP\n"); --- > dprint("Found SP\n"); 1931c2062 < dprintf1arg("Unknown pkey %s: skipping \n", token); --- > dprints("Unknown pkey %s: skipping \n", token); 1934c2065 < dprintf2args("Found Add with pkey %s, rest %s.\n",temppkey,addlist); --- > dprintss("Found Add with pkey %s, rest %s.\n",temppkey,addlist); 1937a2069 > hcg_parse(hcg_buffer,datafile,&idx); /*a garble may be a bug here - RJL 031022*/ 1941c2073,2075 < return (command); /* needed for second switch(command) which */ --- > return (command); /* needed for second switch(command) which is in */ > /* bdeReplay's replay_log byt may not be needed. */ > 1949c2083 < /* This function is used to replay a logsession based on */ --- > /* This function is used to replay a logged session based on*/ 1951,1952c2085,2087 < /* replace the DB from the start of the log session, */ < /* reproduce the DB modifications based on the logfile. */ --- > /* restore the DB from the checkpoint *DB1.dat file, */ > /* and reproduce the DB modifications from the change-log. */ > /* Note: startlog during replay is untested and may fail */ 1964a2100,2109 > /* */ > /* Pre-conditions (added by RJL 030809) */ > /* (name without extension) cannot include "." */ > /* DB1.dat exists to initialize database */ > /* logdata.txt must contain "LogDataFile\n" plus data */ > /* for each file copy that pr_init will scan. */ > /* (hcg_replay == 1) (from "SR" command; reset here) */ > /* pr_load sets hcg_log = 0 and returns retval. */ > /* Is this BAD if retval = -4? */ > /* */ 1966c2111 < /* 0 - success */ --- > /* 0 - success [or no-op? - RJL 040520] */ 1969c2114 < /* -3 - Replay error - unable to open file */ --- > /* -3 - Replay error - unable to open some tempfile */ 1971c2116,2117 < /* -5 - Replay error - incorrect log file format */ --- > /* -5 - Replay error - Missing "LogFileData" header */ > /* -6 - Replay error - already doing replay - RJL 040520 */ 1974c2120,2126 < int pr_replay(char *view,char logfile[NAMELENGTH],int near_realtime,int take_endsnapshot) --- > /* Note added by RJL - 040520: */ > /* replay occurs only #ifdef GENLOG - if assume pr_log.c*/ > /* doesn't even exist unless #ifdef GENLOG - RJL 040520?*/ > /********************************************************/ > > int pr_replay(char *view, char logfile[NAMELENGTH], > int near_realtime, int take_endsnapshot) 1977,1979c2129,2137 < char filelist[BUFSIZE], tempfilelist[BUFSIZE],tempvar[BUFSIZE], logfiledb[NAMELENGTH]; < int retval; < --- > char filelist[BUFSIZE], tempfilelist[BUFSIZE], > tempvar[BUFSIZE], logfiledb[NAMELENGTH]; > int retval = 0; > filelist[0] = '\0'; > EP; > #ifdef DEBUG > printf("pr_replay:BUFSIZE=%i, NAMELENGTH=%i, filelist=\n\t%s\n", > BUFSIZE, NAMELENGTH, filelist); > #endif 1980a2139 > /* range constraint pre-condition - should be an enumeration */ 1983,1984c2142,2143 < printf("pr_replay error: logging in progress\n"); < return(-4); --- > printf("Error: pr_replay invalid - logging in progress\n"); > return -4; // hcg_log = 1 1985a2145,2146 > /* TBD: Allow "SR" command AFTER loading valid data? */ > /* Why? - replay already permits pr_adding rows after "SR". */ 1987,1990c2148,2152 < /* set replay to be on & save logfilename*/ < hcg_log = 2; < strcpy(hcg_logfile,logfile); < --- > if (hcg_log == 2) { > printf("Error: recursive pr_replay invalid - already doing replay\n"); > return -6; // hcg_log = 2 > } > assert(hcg_replay); // was assert(hcg_log==0); - RJL 040712 1994,1995c2156 < hcg_log = 0; < return(-1); --- > return(-1); // hcg_log = 0 1999,2000c2160 < hcg_log = 0; < return(-2); --- > return(-2); // hcg_log = 0 2003,2005c2163,2167 < /* free the existing database */ < if (hcg_initialized) { < pr_free(); --- > /* set replay to be on & save logfilename*/ > hcg_replay = 1; // was hcg_log = 2 - RJL 040712 > strcpy(hcg_logfile, logfile); //hcg_logfile scope is? > if (hcg_initialized) { /* free the existing database */ > DP; pr_free(); // clears hcg_initialized = 0; 2008,2009c2170,2173 < /* generate the data files */ < strtok(logfile,"."); --- > strtok(logfile,"."); /* assumes exactly one period */ > // TBD: see pr_load.c:2967:int stripDPath > > /* generate checkpoint file name by appending "DB1" */ 2011,2012c2175 < log_parselogdata(tempfilelist); < sprintf(filelist,"%s %s",tempfilelist, logfiledb); --- > /*Pre-condition: infile logdata.txt MUST exist here - RJL 030809 */ 2014c2177 < dprintf1arg("filelist: %s \n\n", filelist); --- > retval = log_parselogdata(tempfilelist); 2015a2179,2185 > if (retval != 0) > return(retval); /* Why quit now? - RJL 040404 */ > > sprintf(filelist, "%s %s", > tempfilelist, logfiledb); > > dprints("pr_replay: filelist to pr_init: \n\t%s\n\n", filelist); 2017,2018c2187,2199 < pr_init("../lib/bdetest.viewdefs",filelist); < pr_load(view,logfiledb); --- > /* GENLOG is a link-time pre-condition for generating pr_log.c */ > DP; pr_init("../lib/bdetest.viewdefs", tempfilelist); //hcg_initialized = 1; > /* get stats from tempfilelist and logfiledb: RJL 030809*/ > DP; pr_load(view, logfiledb); /* checkpoint initializes VMNetDB */ > > /* DO THE REPLAY HERE: */ > retval = 0; /* unless replay_log returns another value */ > retval = replay_log(); /* compiled only #ifdef GENLOG */ > > /* HGcurr != NULL fails in replay_log at bdeReplay.cc, line 403-RJL040904i */ > /* NB: CLIENT must have a stub for this, which is an */ > /* application-specific part of replaying the logfile */ > /* e.g., bdeReplay.cc contains a work-completion function after replay_log. */ 2020,2026c2201 < /* replay the log */ < #ifndef BDELOG < retval = replay_log(); < if ( retval != 0 ) { < hcg_log = 0; < return(retval); < } --- > hcg_replay = 0; /* this replay interval is ended */ 2031c2206,2207 < pr_dump(view, tempvar,0,"w"); --- > DP; pr_dump(view, tempvar,0,"w"); > dprints("endSnapshot is in file %sDB3.dat\n", logfile); 2033c2209 < #endif --- > // #endif 2035,2037c2211,2215 < hcg_log = 0; < return (0); < } --- > assert (hcg_log == 2); // RJL 040520 > hcg_log = 0; /* replay finished; resume normal editing */ > /* TBD: allow logging during replay and both afterward - RJL 030807 */ > return (retval); > } // end pr_replay Binary files genpr_util.050316/pr_log.o and newpr_util050316/pr_log.o differ diff -bitw genpr_util.050316/pr_stats.c newpr_util050316/pr_stats.c 5a6,16 > /* > * $Log: pr_stats.c,v $ > * Revision 1.1.2.7 2005/02/25 00:34:13 lechner > * > * cvs diff pr_util 050223: No changes except hasType macro in 94sbde_schema.h > * > * Revision 1.1.2.6 2004/11/29 20:10:21 lechner > * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. > * > ******************************************************************************/ > /* Log aded 041129 - RJL */ Binary files genpr_util.050316/pr_stats.o and newpr_util050316/pr_stats.o differ Binary files genpr_util.050316/pr_util.a and newpr_util050316/pr_util.a differ Common subdirectories: genpr_util.050316/pr_util040829 and newpr_util050316/pr_util040829 Common subdirectories: genpr_util.050316/restored040730 and newpr_util050316/restored040730