diff pr_util_log/pr_load.c pr_util_nolog/pr_load.c|wc 1117 5467 45735 mercury.cs.uml.edu(9)> diff pr_util_log/pr_load.c pr_util_nolog/pr_load.c >pr_load.log.vs.nolog.dif ------------------------- 22,32c22,23 < 0---startlog--->1 ---hcg_log ---> < / \ <-stoplog<- / \ | < V ^ V ^ | < SR| |SP SR| |SP |hcg_replay < V ^ V ^ | < \ / \ / | < 2---startlog--->3 V < <-stoplog<- < < *This is equivalent to having two independent 2-state models: state's MSbit < *hcg_replay toggled by "SR"/"SP", LSbit hcg_log toggled by pr_startlog/pr_stoplog. --- > *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. 34c25 < *(TBD) Tests to be defined as isLogging() and isReplay() --- > * Tests are defined as isLogging() and isReplay() 69c60 < extern void strncpy_null (char * , char * , int); //Beware of overflow --- > extern void strncpy_null (char * , char * , int); 134,136d124 < /** Pre-condition not checked: - RJL060227 **/ < /** strlen(a) must be long enough to void overflow **/ < /** Side effect: assert fails if a is not long enough **/ 141,142d128 < //dprintdd("strlen(a)=%d >=? n=%d \n", strlen(a), n); < 151d136 < 173,176c158 < /* ALWAYS check return value - < * hcg_tbl_idx = 0 is real and mis-leads on fail. RJL040611 */ < /* Bug fix TBD: ?? - assumed 0 was invalid return value */ < /* BUG?:strncpy appends '\0' terminator at a[n] regardless of strlen(a);*/ --- > /* ALWAYS check return value - altered global hcg_tbl_idx = 0 is valid. RJL040611 */ 179,181c161,166 < 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 */ --- > EP;strncpy(tmpabb, hcg_table_seq_list[hcg_tbl_idx].ttabbrev, HCG_ABBR_SIZE); > if (strncmp(pkey,tmpabb,HCG_ABBR_SIZE) == 0) /*strcmp-->strncmp-RJL040522 */ > { > dprintds("old hcg_tbl_idx %d matches pkey %s \n", hcg_tbl_idx, pkey); > return(1); /* current hcg_tbl_idx is valid - skip search */ > } 186,187c171,174 < if (strncmp(pkey, tmpabb, HCG_ABBR_SIZE) == 0) { < return(1); --- > if (strncmp(pkey, tmpabb, HCG_ABBR_SIZE) == 0) > { dprintsd("new hcg_tbl_idx matching pkey %s is %d\n", pkey, hcg_tbl_idx); > LP;return(1); > } 189d175 < }/* not found */ 191c177,178 < return(0); --- > dprint("find_tbl_idx fails;\n"); > LP;return(0); 200c187 < /* Note: clients are pr_init(loads views),load_data(search views),pr_replay? */ --- > /* Note: clients are pr_init(loads views), load_data (seaqrch views) and pr_replay? */ 203c190 < { char tmpname[MAXVIEWNAMELEN]; --- > { char tmpname[MAXVIEWNAMELEN+1];/* '+1' added - RJL060208 */ 215,217d201 < //DP; dprintsd( < // "viewname %s matched w/o search at hcg_view_idx= %d\n", < // viewname, hcg_view_idx); 224,225d207 < //dprintdd("for_loop iter: hcg_view_idx = %d, hcg_view_list.num_views = %d\n", < // hcg_view_idx, hcg_view_list.num_views); 229,231d210 < //DP; dprintsd( < // "Found match to viewname %s at hcg_view_idx = %d\n", < // viewname, hcg_view_idx); 235,241d213 < //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); 290c262 < /* read buffer, reads the next line at hcg_ascii_fp, and then converts any */ --- > /* read buffer, reads the next line of the file, and then converts any */ 333a306 > 336d308 < 361a334 > /* Changed to HCG_KEY_SIZE and HCG_ABBR_SIZE - RJL060218 */ 362a336 > 378c352 < static int key_len = HCG_KEY_SIZE; /* == OLD_KEY_LEN or NEW_KEY_LEN */ --- > static int key_len = HCG_KEY_SIZE; 394c368 < set_external_key_length( int klen ) /* has no client users? -RJL060228 */ --- > set_external_key_length( int klen ) 430c404 < * If fails, sets ver = empty string and returns -1 --- > * If fails, sets ver = empty string and returns -1. 436c410 < if( key_len == OLD_KEY_LEN ) --- > if( key_len == OLD_KEY_LEN ) /* 2+2+4 bytes */ 441c415 < else if( key_len == NEW_KEY_LEN ) --- > else if( key_len == NEW_KEY_LEN ) /* 4+3+5 bytes */ 460c434 < if( key_len == OLD_KEY_LEN ) --- > if( key_len == OLD_KEY_LEN ) /* 2+2+4 bytes */ 464c438 < else if( key_len == NEW_KEY_LEN ) --- > else if( key_len == NEW_KEY_LEN ) /* 4+3+5 bytes */ 477a452 > * - RJL 040521 571c546 < if( klen == OLD_KEY_LEN ) /* if ncp==2 */ --- > if( klen == OLD_KEY_LEN ) 578c553 < else /* if ncp==4 */ --- > else 602,603c577,578 < * Returns NULL ptr if failure. WARNING: Not re-entrant: extrnal_key is corrupted. < * Calls decode() to set external_key and return 1, else return -1. --- > * Returns NULL ptr if failure. > * Calls decode() to set external_key and return +/-1 609c584 < EP;LP;return (( (status = decode(external_key,k)) == 1 ) ? external_key : NULL); --- > return ( (status = decode(external_key,k)) == 1 ) ? external_key : NULL; 613,615c588,589 < * Decode the encoded key k, put key_string or '\0' into *external_key array < * Calls abb_decode, ver_decode, row_decode; expects external_key[KEY_SIZE+1]; < * Clients: decode_retstr + others. --- > * Decode the encoded key k, return key_string or empty *external_key > * Calls abb_decode, ver_decode, row_decode 619a594 > char t[HCG_KEY_SIZE+1] = ""; 621,628c596,597 < char t[HCG_KEY_SIZE+1] = ""; /* empty string */ < assert(t[0] == '\0'); < strncpy_null(external_key, t, HCG_KEY_SIZE+1); /* append each key part from t */ < /* external_key is static in client decode_rtnstr(); */ < if (k == 0) < { < LP;return -1; < } --- > external_key[0] = '\0'; > if (k == 0) {LP;return -1;}; /* assert !=0 failed 0512, 0601 -RJL */ 636,637c605 < /*if( ((klen = strlen(t)) != OLD_ABB_LEN) && (klen != NEW_ABB_LEN) )*/ < if (klen != HCG_ABBR_SIZE) /* RJL060218 */ --- > if ( klen != HCG_ABBR_SIZE) /* RJL060219 */ 644c612 < strcat( external_key, t ); --- > strcat( external_key, t ); /*tttype*/ 651c619 < strcat( external_key, t ); --- > strcat( external_key, t ); /* ttyp+ver*/ 657c625 < { --- > { /*ttyp+ver+row*/ 658a627 > assert(strlen(external_key)==HCG_KEY_SIZE); 664c633 < } /* end decode */ --- > } // end decode 671,673c640,642 < if( *(unsigned long*)k1 < *(unsigned long*)k2 ) {return -1;}; < if( *(unsigned long*)k1 == *(unsigned long*)k2 ){return 0;} < else { return 1;} --- > if( *(unsigned long*)k1 < *(unsigned long*)k2 ) return -1; > if( *(unsigned long*)k1 == *(unsigned long*)k2 ) return 0; > else return 1; 770,785d738 < /***********************************************************************/ < /* 772-784: new function to reject comment prefix '/_/' or '/_*' in first token */ < /* of record - moved up out of pr_init and load_data - RJL060307 */ < /* WARNING: comment terminator not checked; Multi-line comment will not */ < /* be recognized; extra comment lines will be ignored. */ < /* No side effects; Pre-cond: *tokptr is a string of length >= 1. */ < /************************************************************************/ < int notacomment(const char* tokptr) { < int result = 1; < char char1 = (char)(*tokptr); < char char2 = (char)(*(tokptr+1)); < if ((char1 == '/') && ((char2 == '/')||(char2 =='*'))) < result = 0; // FALSE ==> commentLines++; < return result; < }/* end notacomment:pr_load.c:784 */ < 786a740 > 799c753 < void pr_init ( char *viewdef_filename, char *filelist) /* (786-1181)*/ --- > void pr_init ( char *viewdef_filename, char *filelist) /* 766-1079 */ 813d766 < /* Next two HCG_ABBR_SIZE sizes changed from ABBREV_NAME_LENGTH - RJL060204 */ 815,818c768 < char temp_verstring[HCG_KEY_SIZE], badttabbrv[HCG_ABBR_SIZE+1]; /* was ^^^ -RJL0600204*/ < /* Genlog - 5/7/96: log call to pr_init */ < char log_text[BUFSIZE]; < FILE *logdata_fp; --- > char temp_verstring[10], badttabbrv[HCG_ABBR_SIZE+1]; 820,830d769 < if (hcg_log) < { < printf("Warning: pr_init() called during log session"); < printf("may cause unexpected results.\n"); < } < logwait(); < sprintf(log_text, "IN %s %s\n", viewdef_filename, filelist); < logstr(log_text); < < /* End Genlog addition */ < 836c775 < /*in lut.c, abbr_lut_create calls lut_init(p_lut, ABBR_TBL_TYPE); -RJL051127 */ --- > /*in lut.c, bbr_lut_create calls lut_init(p_lut, ABBR_TBL_TYPE); -RJL051127 */ 848,863d786 < /* Added by Genlog 5/7/96 */ < /* 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) */ < /* (independent of hcg_replay?)*/ < < if (hcg_log == 1) { /*try to open file for LATER replay - RJL 040425 */ < if ((logdata_fp = fopen("logdata.txt", "w")) == NULL) { < 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? */ < < } < } < /* End Genlog Addition*/ < 922,928d844 < /* Added by Genlog 5/7/96 to log pr_init */ < /* 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 */ < /* End Genlog Addition */ < 931,932c847 < while ( !feof(hcg_ascii_fp) ) < /* if hcg_log == 1, append infile data rows to logdata.txt */ --- > while ( !feof(hcg_ascii_fp) )/* if hcg_log == 1, append infile data rows to logdata.txt */ 935,939c850 < /* Genlog 5/7/96: log table rows [to be] copied to logdata_fp file */ < if (hcg_log == 1) /* was != 2 (not in replay) - RJL 040622 */ < fprintf(logdata_fp, "%s\n",hcg_buffer); < /* End Genlog Addition */ < --- > //DP;dprints("hcg_buffer: %s\n", hcg_buffer); 942,943c853 < < if(strlen(hcg_t) != HCG_KEY_SIZE) /*moved above find_tbl_idx-RJL060228*/ --- > if (!find_tbl_idx(hcg_t)) /* caches and may alter hcg_tbl_idx - RJL 040622 */ 945,949c855,857 < DP;if (notacomment(hcg_t)==1) { < fprintf(stderr, < "pr_init Warning: invalid keysize %d for key %s, must be %d, ignored.\n" < ,(int)strlen(hcg_t), hcg_t, HCG_KEY_SIZE); < } /* else just skip the comment: -RJL060308*/ --- > strncpy_null(badttabbrv, hcg_t, HCG_ABBR_SIZE); > printf("pr_init Warning: unknown table %s found in scanned datafile %s, ignored.\n", > badttabbrv,scan_filename); 953,955c861 < < if (!find_tbl_idx(hcg_t)) < /* caches and may alter hcg_tbl_idx - RJL 040622 */ --- > if(strlen(hcg_t) != HCG_KEY_SIZE) 957,963c863,864 < strncpy_null(badttabbrv, hcg_t, HCG_ABBR_SIZE); < //ABBREV_NAME_LENGTH ---> HCG_ABBR_SIZE - RJL060204 < DP;if (notacomment(hcg_t)==1) { < fprintf(stderr, < "pr_init Warning: unknown tbltype %s found in scanned datafile %s, ignored.\n", < badttabbrv, scan_filename); < } /* else just skip the comment -RJL060308 */ --- > printf("pr_init Warning: invalid keysize %d for key %s, must be %d, ignored.\n", > (int)strlen(hcg_t), hcg_t, HCG_KEY_SIZE); 967,970c868,871 < // tbl_idx is valid for pkey hcg_t now: < ver_chars = (HCG_KEY_SIZE == 8)? 2 :3; < /*size of version number subfield of pkey */ < /* copy version digits from pkey offset: */ --- > > ver_chars = (HCG_KEY_SIZE == 8)? 2 :3; /*size of version number subfield of pkey */ > > /* copy version digits from pkey at version# offset: */ 977c878 < LP;exit(0); /* exit closes (hcg_ascii_fp)? */ --- > exit(0); /* exit closes (hcg_ascii_fp)? */ 987,988c888,890 < /* dprintdd("hcg_row = %d, hcg_version = %d in ", < hcg_row, hcg_version);DP; newline in DP */ --- > /*dprintdd("hcg_row = %d, hcg_version = %d ", > hcg_row, hcg_version);DP; > */ 991c893 < /* This reported 1-char pkeys only during load of table FO - RJL 040616 */ --- > /* This reported 1-char pkeys during load of table FO - RJL 040616 */ 998c900 < dprintdd("New maxver = %d from key %x\n", hcg_version, hcg_k); --- > //dprintdd("New maxver = %d from key %x\n", hcg_version, hcg_k); 1001c903 < } /* while (!feof(hcg_ascii_fp))*/ --- > } /* end while (!feof(hcg_ascii_fp))*/ 1009,1036d910 < if (hcg_log == 1) /* added 040622 - RJL */ < fclose(logdata_fp); /* done copying infiles */ < < /* Added by Genlog 5/7/96 to log pr_init */ < /* if (hcg_log != 2) why? = RK: 04042only 5 - crashed bde below - RJL 040530 */ < /* if (hcg_log == 1) */ < /* This crashed bde 040530:1150 - RJL: */ < /* End Genlog Addition */ < /* filelist is effectively consumed by now. */ < < /*===================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 < */ 1058c932 < --- > /*DP;*/ 1066c940 < if (hcg_view_list.num_views >= MAXVIEWS) /* = 10 */ --- > if (hcg_view_list.num_views >= MAXVIEWS) 1068,1069c942 < printf( < "Error: Too many views defined (max=%d), next view would have been %s.\n", --- > printf("Error: Too many views defined (max=%d), next view would have been %s.\n", 1091c964 < DP;dprints("pr_init:1076: added viewname '%s' to viewdefs file.\n", viewname); --- > printf("pr_init:1878: added viewname '%s' to viewdefs file.\n", viewname); 1103c976 < --- > /*DP;*/ 1118c991 < hcg_read_next(); --- > hcg_read_next(); /* skip this table type */ 1121c994 < /* Now can assume valid hcg_table_idx - RJL 040616 */ --- > /* Now can assume valid hcg_tbl_idx - RJL 040616 */ 1126c999 < { /* MAXVERSIONS = 0 now - RJL060308 */ --- > { 1129c1002 < hcg_read_next(); --- > hcg_read_next(); /* skip this table type */ 1136c1009 < printf("Error: view = %s invoked on table %s as write, MAXVERSION = %d is already used\n", --- > printf("Error: view %s invoked on table %s as write, MAXVERSION of %d is used\n", 1168c1041 < } /* end if icmd = define_view or view_element */ --- > } /* end if view_element */ 1183c1056 < else { /* empty temp_command ==> empty line */ --- > else /* empty temp_command ==> empty line */ 1186d1058 < } 1193,1194c1065,1066 < < LP;}/* end pr_init (786-1181)*/ --- > /*DP;*/ > LP;}/* end pr_init (log:1592:1922)(nolog:766-1079) */ 1237c1109 < /* linked into the tables row chain at the alphabetically correct location, */ --- > /* linked int//o the tables row chain at the alphabetically correct location, */ 1241d1112 < /* RJL060309: even if tbl==NULL, tbl##curr=tbl_elt at exit (valid post-cond) */ 1315c1186 < /* children. Pre-condition: pa##elt is a valid (pa*) ptr. */ --- > /* children. */ 1325c1196 < ca##curr2->p##_fpp = (struct dummy_type*) pa##curr; \ --- > (struct pa *) ca##curr2->p##_fpp = pa##curr; \ 1332,1336c1203,1205 < for ( ca##temp2 = pa##curr->c##_fcp; \ < ca##temp2->p##_fpp != (struct dummy_type*)pa##curr; \ < ca##temp2 = (struct ca *)(ca##temp2->p##_fpp) ) /*no-op*/; \ < ca##temp2->p##_fpp = (struct dummy_type*)ca##curr2; \ < }; \ --- > for (ca##temp2 = pa##curr->c##_fcp; (struct pa *) ca##temp2->p##_fpp != pa##curr; ca##temp2 = (struct ca *)ca##temp2->p##_fpp); \ > (struct ca *) ca##temp2->p##_fpp = ca##curr2; \ > } \ 1348,1351c1217 < for (pa##curr2 = pa; \ < (pa##curr2 != NULL) && (key_compare(&pa##curr2->pk,&ca##curr->cf) < 0); \ < pa##curr2 = pa##curr2->next_ptr;\ < ) /*no-op*/; \ --- > for (pa##curr2 = pa; (pa##curr2 != NULL) && (key_compare(&pa##curr2->pk,&ca##curr->cf) < 0); pa##curr2 = pa##curr2->next_ptr); \ 1358c1224 < /*****************************************************************************/ --- > /******************************************************************************/ 1368c1234 < /* calls to link_child_[no}bp are included in the caller (pr_add). */ --- > /* calls to link_child_{no}bp are included in the caller (pr_add). */ 1370a1237 > /* */ 1372a1240,1241 > for (pa##curr2 = pa; (pa##curr2 != NULL) && (key_compare(&pa##curr2->pk,&ca##curr->cf) < 0); pa##curr2 = pa##curr2->next_ptr); \ > if ((pa##curr2 != NULL) && (key_compare(&ca##curr->cf,&pa##curr2->pk) == 0)) \ 1374,1380c1243,1244 < for( pa##curr2 = pa; \ < pa##curr2 != NULL && key_compare(&pa##curr2->pk, &ca##curr->cf) < 0; \ < pa##curr2 = pa##curr2->next_ptr \ < ) /* no-op */ ; \ < if (pa##curr2 != NULL && key_compare(&ca##curr->cf,&pa##curr2->pk) == 0 ) \ < { \ < ca##curr->p##_pp = pa##curr2; /* ADDED 060310 */ \ --- > ca##curr->p##_pp = pa##curr2; \ > /*(struct pa *) ca##curr->p##_fpp = pa##curr2;*/ \ 1387,1391c1251,1253 < ca##temp2->p##_fpp != (struct dummy_type*)pa##curr2; \ < ca##temp2 = (struct ca*)(ca##temp2->p##_fpp) \ < ) /*no-op*/ ; \ < ca##temp2->p##_fpp = (struct dummy_type*)ca##curr;/*RJL060310*/ \ < } \ --- > (struct pa*) ca##temp2->p##_fpp != pa##curr2; \ > ca##temp2 = (struct ca *)ca##temp2->p##_fpp); \ > /*(struct ca *)*/ ca##temp2->p##_fpp = (struct dummy_type*) ca##curr; \ 1394d1255 < /* end macro link_parent_nobp_m */ 1396c1257 < /*********************** (1350-1418) *********************************/ --- > /******************************************************************************/ 1399c1260 < /* expanded first call to link_parent_nobp_m(HN, HG,...) line 1379 to 17 lines */ --- > 1402,1403c1263,1264 < { < --- > {EP; > dprintd("tbl_encoding = %d\n", tbl_encoding);//RJL060204 1420c1281 < case 3 : /* encoding of HN (1374:1380) */ --- > case 3 : /* encoding of HN */ 1433c1294 < case 5 :/* encoding of HL *//*Pre-cond: valid HNcurr*/ --- > case 5 : /* encoding of HL */ 1437,1463c1298 < /*link_parent_nobp_m(HL,HN,HNid1,HNid,HNid1,HLid1);*/ < //expansion (g++ -E) of link parent HNid1:pr_load:1437-1455 -RJL060309 < assert(HLcurr!= NULL); < { for( HNcurr2 = HN; < HNcurr2!=((void*)0)&&key_compare(&HNcurr2->HNid,&HLcurr->HNid1)<0; < HNcurr2 = HNcurr2->next_ptr ) ; // empty body < if (HNcurr2 != ((void *)0)&&key_compare(&HLcurr->HNid1,&HNcurr2->HNid)==0) < { < HLcurr->HNid1_pp = HNcurr2; /* ADDED 060310 */ \ < HLcurr->HNid1_fpp = (struct dummy_type*)HNcurr2; < DP;fprintf(stderr,"HLcurr = %px, HLcurr->HNid1_fpp = %px\n", < HLcurr,HLcurr->HNid1_fpp); < if (HNcurr2->HLid1_fcp == ((void *)0)) /* no HL-children yet */ < HNcurr2->HLid1_fcp = HLcurr; /* first HL-child */ < else { < for ( HLtemp2 = HNcurr2->HLid1_fcp; < HLtemp2->HNid1_fpp != (struct dummy_type*)HNcurr2; < HLtemp2 = (struct HL*)(HLtemp2->HNid1_fpp));//emptybody < HLtemp2->HNid1_fpp = (struct dummy_type*)HLcurr;/*RJL060310*/ < } < } < else { < DP; fprintf(stderr, "HLtemp2 = %px, HLemp2->HNid1_fpp = %px\n", < HLtemp2,HLtemp2->HNid1_fpp); < } < }; // end link_parent HNid1 < --- > link_parent_nobp_m(HL,HN,HNid1,HNid,HNid1,HLid1); 1490c1325 < } /* end pr_link ( :1418)(1480 wih expansion)*/ --- > LP;} /* end pr_link */ 1495c1330 < /* pre-cond: size is not largr than int */ --- > 1500c1335 < /* This should also set all keys to null_key() but doesn't right now -- MM */ --- > /* This should also set all the keys to null_key() but doesn't right now -- MM */ 1503,1506d1337 < /******************************************************************************/ < /* This macro is used to generate the next available primary key value for the*/ < /* specified table, using the specified view. */ < /******************************************************************************/ 1507a1339,1344 > /************************************************************************/ > /* Macro pr_gen_key composes the next available primary key value */ > /* for the specified table, from its last 3 params. */ > /* When pr_gen_pkey calls pr_gen_key, it insures tbl_abbrv is in viewname.*/ > /* When pr_check_fkey calls pr_gen_key, fkeys default to version = row = 0.*/ > /************************************************************************/ 1514a1352 > 1517c1355 < /* gets args from hcg_* structs and calls pr_gen_key to update pkey; */ --- > /* gets args from hcg_* structs and calls pr_gen_key to concat pkey parts; */ 1519a1358 > /* E.g. pr_gen_pkey( */ 1520a1360 > /* hcg_tbl_idx is set by find_tbl_idx -RJL060208 */ 1526c1366 < tt##idx = (int) hcg_tbl_idx;\ --- > DP;tt##idx = (int) hcg_tbl_idx;\ 1532c1372 < } \ --- > } /* end if */\ 1537c1377 < /* pr_check_fkey modified: print 32bit unsigned fkey as hex */ --- > /* pr_check_fkey modified: compose and print 32bit unsigned fkey as hex */ 1557c1397 < /**************************************************************************/ --- > /************************************************************************/ 1561c1401 < /**************************************************************************/ --- > /************************************************************************/ 1568c1408 < " Warning: null %s.%s : expanded to at most ??? for pkey %ux\n", \ --- > " Warning: null %s.%s : expanded to at most '?^ for pkey %ux\n", \ 1577,1725d1416 < < /*************************************************************************/ < /* Function : log_pr_add */ < /* */ < /* Abstract : This function is used to log a pr_add transaction */ < /* The tbl indicates which table is having a row added. */ < /* tbl_ptr points to the record to be added. */ < /**************************************************************************/ < /* 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 */ < /* Why can't dump_row be used to log the row exactly? -RJL060310 */ < //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) < < void log_pr_add (char *tbl, char *viewname, hcg_ptr tbl_ptr) < { < FILE* hcg_logfileptr; // pre-cond: already open (by startllog?)- RJL 040708 < char outkey[3][HCG_KEY_SIZE+1]; // updated by decode(outkey[j], anykeyfield) < int idx; < 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"); < return; < } < < assert(find_tbl_idx(tbl)); /* alters tbl##curr; exit if NULL */ < if (hcg_log){ < < idx = hcg_tbl_idx; < < /* Write to hcg_logfile based on idx */ < /* TBD: make this a switch on idx = enumerated ttabbrev symbols */ < if (idx==0) < { < FOcurr=(struct FO *) tbl_ptr; < hcg_update_version(&FOcurr->FOid,FO_idx,0); < decode(outkey[0], &FOcurr->FOid); < PrintCheck(fprintf(hcg_logfileptr, < " %-8s %-50s %-50s %-2s %-15s\n", < outkey[0], FOcurr->xfont, FOcurr->psfontname, < FOcurr->psfontsize, FOcurr->bdefont)); < } < if (idx==1) < { < GDcurr=(struct GD *) tbl_ptr; < hcg_update_version(&GDcurr->GDid,GD_idx,0); < decode(outkey[0], &GDcurr->GDid); < 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)); < } < if (idx==2) < { < HGcurr=(struct HG *) tbl_ptr; < hcg_update_version(&HGcurr->HGid,HG_idx,0); < decode(outkey[0], &HGcurr->HGid); < PrintCheck(fprintf(hcg_logfileptr, " %-8s %-8s %-8s %-12s %-12s %-12s %-60s\n" < , outkey[0], HGcurr->FSid, HGcurr->HNid, HGcurr->HGauthor, HGcurr->HGcreated, HGcurr->HGlastmod < , HGcurr->HGtitle)); < } < if (idx==3) < { < HNcurr=(struct HN *) tbl_ptr; < hcg_update_version(&HNcurr->HNid,HN_idx,0); < decode(outkey[0], &HNcurr->HNid); < hcg_update_version(&HNcurr->HGid,HG_idx,0); < decode(outkey[1], &HNcurr->HGid); < PrintCheck(fprintf(hcg_logfileptr, " %-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)); < } < if (idx==4) < { < HAcurr=(struct HA *) tbl_ptr; < hcg_update_version(&HAcurr->HAid,HA_idx,0); < decode(outkey[0], &HAcurr->HAid); < hcg_update_version(&HAcurr->HNid,HN_idx,0); < decode(outkey[1], &HAcurr->HNid); < PrintCheck(fprintf(hcg_logfileptr, " %-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)); < } < if (idx==5) < { < HLcurr=(struct HL *) tbl_ptr; < hcg_update_version(&HLcurr->HLid,HL_idx,0); < decode(outkey[0], &HLcurr->HLid); < hcg_update_version(&HLcurr->HNid1,HN_idx,0); < decode(outkey[1], &HLcurr->HNid1); < hcg_update_version(&HLcurr->HNid2,HN_idx,0); < decode(outkey[2], &HLcurr->HNid2); < PrintCheck(fprintf(hcg_logfileptr, " %-8s %-8s %-8s %8d %8d\n" < , outkey[0], outkey[1], outkey[2], HLcurr->HPcount, HLcurr->allvisible)); < } < if (idx==6) < { < HPcurr=(struct HP *) tbl_ptr; < hcg_update_version(&HPcurr->HPid,HP_idx,0); < decode(outkey[0], &HPcurr->HPid); < hcg_update_version(&HPcurr->HLid,HL_idx,0); < decode(outkey[1], &HPcurr->HLid); < PrintCheck(fprintf(hcg_logfileptr, " %-8s %-8s %8.4f %8.4f %8d %-4s\n" < , outkey[0], outkey[1], HPcurr->HPx, HPcurr->HPy, HPcurr->is_visible, HPcurr->hsegpattern)); < } < if (idx==7) < { < HIcurr=(struct HI *) tbl_ptr; < hcg_update_version(&HIcurr->HIid,HI_idx,0); < decode(outkey[0], &HIcurr->HIid); < hcg_update_version(&HIcurr->HLid,HL_idx,0); < decode(outkey[1], &HIcurr->HLid); < PrintCheck(fprintf(hcg_logfileptr, " %-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)); < } < if (idx==8) < { < CGcurr=(struct CG *) tbl_ptr; < hcg_update_version(&CGcurr->CGid,CG_idx,0); < decode(outkey[0], &CGcurr->CGid); < hcg_update_version(&CGcurr->HGid,HG_idx,0); < decode(outkey[1], &CGcurr->HGid); < PrintCheck(fprintf(hcg_logfileptr, " %-8s %-8s %8.4f %8.4f %8.4f %8.4f\n" < , outkey[0], outkey[1], CGcurr->CGcenterx, CGcurr->CGcentery, CGcurr->CGwidth, CGcurr->CGheight)); < } < if (idx==9) < { < GXcurr=(struct GX *) tbl_ptr; < hcg_update_version(&GXcurr->GXid,GX_idx,0); < decode(outkey[0], &GXcurr->GXid); < hcg_update_version(&GXcurr->CGid,CG_idx,0); < decode(outkey[1], &GXcurr->CGid); < PrintCheck(fprintf(hcg_logfileptr, " %-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)); < } < } /* end if hcg_log */ < /* RJL040712: log_pr_add is a no-op unless hcg_log==1 */ < } /* end log_pr_add */ < /* end of gen_pr_add output to pr_load.c */ < < 1727c1418 < /******************* (1729-1912)*********************************************/ --- > /******************************************************************************/ 1732,1734d1422 < /* else [a no-op???]. If load_data or replay_log was the client, */ < /* pr_parse already did XXelt = pr_create(XX) and pr_set_ ... field values. */ < /* log_do_pr_add calls fprintf(hcg_logfileptr,"...") iff hcg_log==1-RJL)60217 */ 1736,1737c1424 < /* #define pr_add(a,b,c) do_pr_add(a,#b,c)? */ < #define TTPRNT dprint("tbl_encoding [0..9] = FO,GD,HG,HN,HA,HL,HP,HI,CG,GX\n") --- > /* RJL040712: log_pr_add is a no-op unless hcg_log==1 */ 1741c1428,1430 < char badttabbrv[HCG_ABBR_SIZE+1]; --- > #define TTPRNT dprint("tbl_encoding [0..9] = FO,GD,HG,HN,HA,HL,HP,HI,CG,GX\n") > char error_table[HCG_ABBR_SIZE+1]; > /*char tempkey[HCG_KEY_SIZE+1];*/ 1743c1432 < char* ttabbrev; /* added 051127 - wouldn't permit decl in asgnmt. */ --- > char* ttabbrev; /* local var added 051127 - wouldn't permit decl in asgnmt. */ 1745,1749c1434,1437 < < /* skip leading spaces (if any) from tbl_abbrv */ < < while( *tbl_abbrv == ' ') ++tbl_abbrv; < --- > /* skip leading whitespace (if any) from tbl_abbrv */ > /* (\t added 060126; was ++tbl_abbrv until 060126 - RJL*/ > while( *tbl_abbrv == ' '||*tbl_abbrv== '\t') tbl_abbrv++; > DP;assert(strlen(tbl_abbrv) == HCG_ABBR_SIZE); //2 or 4 - RJL060126 1754,1755c1442 < /*log_pr_add(tbl_abbrv, viewname, tbl_ptr); */ < return; --- > LP;return; 1757c1444 < if (!find_view_idx(viewname)) --- > DP; if (!find_view_idx(viewname)) 1760,1761c1447 < /*log_pr_add (tbl_abbrv, viewname, tbl_ptr); */ < return; --- > LP;return; 1763c1449 < if (!find_tbl_idx(tbl_abbrv)) --- > if (!find_tbl_idx(tbl_abbrv)) /* updates hcg_tbl_idx */ 1765,1769c1451,1454 < strncpy_null(badttabbrv, tbl_abbrv, HCG_ABBR_SIZE+1); < // '+1' added 060204-RJL < printf("Warning: unknown table (%s) passed to pr_add, ignored.\n",badttabbrv); < /*log_pr_add (tbl_abbrv, viewname, tbl_ptr); */ < return; --- > strncpy_null(error_table, tbl_abbrv, HCG_ABBR_SIZE); > printf("Warning: unknown table (%s) passed to [do_]pr_add, ignored.\n", > error_table); > LP;return; 1770a1456,1457 > DP;dprintd("hcg_tbl_idx = %d\n", hcg_tbl_idx); /* in do_pr_add -RJL060208 */ > 1777c1464 < //bde/pr_util_nolog crashed because following updates were skipped when --- > //bde crashed because following updates were skipped when 1784,1785c1471 < < /*tbl_encoding=encoding( hcg_table_seq_list[hcg_tbl_idx].ttabbrev);*/ --- > /*Expanded: tbl_encoding=encoding( hcg_table_seq_list[hcg_tbl_idx].ttabbrev);*/ 1787,1789c1473,1475 < tbl_encoding = encoding(ttabbrev); < dprintsd("tbl_encoding(%s) = %d ",ttabbrev,tbl_encoding); < DP; --- > DP; tbl_encoding = encoding(ttabbrev); > dprintds("tbl_encoding=%d,ttabbrev=\n", tbl_encoding, ttabbrev); > TTPRNT; 1791,1793c1477,1480 < assert(strlen(viewname)>0); < switch( tbl_encoding ) < { --- > DP;switch( tbl_encoding ) > {/* TBD: make these class methods when gencpp makes XX a class:*/ > /* E.g.: call class method FO::do_add(fld_val_lIst) for case#0.*/ > /* Pre-cond: pr_create did tbl_ptr = malloc(sizeof()) */ 1805,1806d1491 < assert(strlen(viewname)>0); < log_pr_add ("FO", viewname, FOelt); /* iff hcg_log */ 1818d1502 < log_pr_add ("GD", viewname, GDelt); 1823,1824c1507,1509 < HGelt = (struct HG *) tbl_ptr; < pr_gen_pkey(viewname,HG,HGelt->HGid); --- > DP;HGelt = (struct HG *) tbl_ptr; > DP;pr_gen_pkey(viewname,HG,HGelt->HGid); > printf("pr_gen_pkey returns %ux\n", (unsigned)HGelt->HGid); 1831d1515 < log_pr_add ("HG", viewname, HGelt); 1836c1520 < HNelt = (struct HN *) tbl_ptr; --- > DP;HNelt = (struct HN *) tbl_ptr; 1843d1526 < log_pr_add ("HN", viewname, HNelt); 1854d1536 < log_pr_add ("HA", viewname, HAelt); 1863d1544 < log_pr_add ("HL", viewname, HLelt); 1872d1552 < log_pr_add ("HP", viewname, HPelt); 1883d1562 < log_pr_add ("HI", viewname, HIelt); 1891d1569 < log_pr_add ("CG", viewname, CGelt); 1902d1579 < log_pr_add ("GX", viewname, GXelt); 1910,1911c1587 < } /* end do_pr_add (1729-1912) */ < /* end of gen_pr_add output to pr_load.c */ --- > } /* end do_pr_add */ 1926c1602 < /* */ --- > /* WARNING: make sure clients call hcg_read_next to prime hcg_buffer - RJL 040616 */ 1930,1931c1606 < < int load_data(char *viewname) /*(1895-2040)*/ --- > int load_data(char *viewname) 1934c1609 < /* extern char *logfile; */ --- > //extern char *logfile; 1945c1620,1621 < char temp_verstring[ABBREV_NAME_LENGTH]; /* abbrev, not version? */ --- > char temp_verstring[ABBREV_NAME_LENGTH]; /* = 5 in schema.h */ > char char1, char2; 1952c1628 < hcg_read_next(); /* read FIRST line - added 040616 - RJL */ --- > hcg_read_next(); /* added 040616 - RJL */ 1955,1956c1631,1632 < < DP;dprints("hcg_parse-ing this hcg_buffer:\n\t'%s'\n", hcg_buffer); --- > //DP; > dprints("load_data at pr_load.c:2664: parsing this hcg_buffer:\n\t'%s'\n", hcg_buffer); 1961c1637 < { /*dprint("Empty line found in file %s\n");*/ --- > { dprint("Empty line found in file %s\n"); 1969c1645 < dprint("TBD: Load checkpoint *DB1 then replay logfile.\n"); --- > dprint("TBD: Load checkpoint *DB1 then replay logfile.\n");//was bug - RA051126 1971,1977c1647 < DP;return 1; // TBD: close file, start replay - RJL 040522 < } < else if (notacomment(hcg_t) == FALSE) { < commentLines++; < // dprint("skipped a comment introducer line \n"); < hcg_read_next(); < continue; --- > return 1; // TBD: close file, start replay - RJL 040522 1987,1990c1657 < < // non-empty line begins with a non-comment token of length HCG_KEY_SIZE: < < else if (!find_tbl_idx(hcg_t)) /* if table type not found in view */ --- > else if (!find_tbl_idx(hcg_t)) /* table type not found for field 1 */ 1992,1994c1659,1660 < /* find_tbl_idx sets tmpabb to hcg_table_seq_list[hcg_tbl_idx].ttabbrev,HCG_ABBR_SIZE) < * and returns (strncmp(pkey,tmpabb,HCG_ABBR_SIZE) == 0) and updates hcg_tbl-idx. */ < strncpy_null(temp_verstring, hcg_t, HCG_ABBR_SIZE); --- > strncpy_null(temp_verstring, hcg_t, HCG_ABBR_SIZE);/* why ABBR? */ > /* TBD: call function here to check for comments */ 1995a1662,1667 > char1 = (char)(*hcg_t); > char2 = (char)(*(hcg_t+1)); > if ((char1 == '/') && ((char2 == '/')||(char2 =='*'))) > commentLines++; > else > { 1999a1672 > } 2003,2015d1675 < // tbl_idx found in view: check version now: (assume we don't care): < // New 060307: ignore version#; assume all version# chars are either < // '\0' (not in view) or '0' (don't care == latest version). < // else if (hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] == '\0') < // { /* does zero byte mean no version allowed? */ < // hcg_read_next(); < // continue; < // } < // RJL060307: maybe ver_chars (length) could be 0 since don't want to use it any more; < // Later, (TBD) we need namespace scope instead (priority maybe > tbl_idx ?) < // Namespace AND View are now just a list of tabletypes (version_list value ignored) < // tabletypes can overlap across views and across namespaces. < // tabletypes must be unique inside a view and also inside a namespace. 2017c1677,1685 < ver_chars = ( (HCG_KEY_SIZE==8)? 2:((HCG_KEY_SIZE==12)?3:0) ); //-RJL060307 --- > if (hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] == '\0') > { > hcg_read_next(); > continue; > } > > if (HCG_KEY_SIZE == 8) ver_chars = 2; > else ver_chars = 3; > 2019d1686 < assert (ver_chars == 2 || ver_chars == 3); 2021c1688 < //detect comments indep of token length first: --- > 2033,2035c1700,1702 < /* (:1975-1987:) The next block skips unwanted table versions < * (meets_view depends on pkey as well as new_version = TRUE||FALSE) < * Added NEW_VERSION brackets - RJL 031023; removed this code 060307 --- > /* The next block skips unwanted table versions > * Alt: why not use meets_view() here? - RJL: 031012 > * Added NEW_VERSION brackets - RJL 031023 2037,2039c1704,1707 < //Replaced NEW_VERSION dependence by ttabbr_in_view test only -RJL060307 < if (hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] == -1) < {// table is not in this view --- > #ifndef NEW_VERSION > if (((char) hcg_version) != > hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx]) > { 2044c1712 < //Now have a valid pkey in view at hcg_view_idx. --- > #endif 2046,2048c1714,1715 < hcg_ts_list[hcg_tbl_idx].ts_list[hcg_version].rcount++;//maybe superfluous < //Before removing the above line, we could assert both rcounts match above. < // Update maxrow to prevent pkey re-use: --- > hcg_ts_list[hcg_tbl_idx].ts_list[hcg_version].rcount++; > 2054,2055d1720 < //assert (tbl_encoding == hcg_tbl_idx)????????????? < //now get field tokens and build struct XX values: 2074,2077c1739,1740 < LP;return 0; // TBD: Client must close file < } /* end load_data (:1895-2040) */ < /* end of gen_load_data output */ < --- > return 0; // TBD: Client must close file > } /* end load_data (2599-2720) */ 2088c1751 < /***********************************************************************/ --- > /*****************************************************************************/ 2091c1754 < {EP; --- > { 2297a1961 > 2300d1963 < 2302c1965 < /*********************** (2222-2304) ******************************************/ --- > /******************************************************************************/ 2318,2328d1980 < /* Added by Genlog 5/8/96 to log pr_load */ < /* extern char *logfile; */ < char log_text[BUFSIZE]; < EP; < if ( hcg_log == 1 ) { < logwait(); < sprintf(log_text,"LD %s %s\n", viewname, file_name); < logstr(log_text); < } < /* End Genlog Addition */ < 2345c1997 < LP;exit(2); --- > exit(2); 2357c2009 < dprints("\nFinished load; fclose %s\n TBD in load_data; ", file_name); --- > dprints("\nFinished load; fclose %s\n TBD in load_data", file_name); 2363,2367c2015,2017 < 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); < replayStatus = pr_replay(viewname, file_name, 1, 1); < --- > dprints("data file %s contains StartReplay = 'SR' cmd:\n", file_name); > dprint("Rebuild bde with chgen -log option to replay.\n"); > exit(3); /* TBD: Pick error # */ 2369c2019 < /* (This should? work because pr_replay is tail-recursive) */ --- > /* (This should work because pr_replay is tail-recursive) */ 2375,2377c2025,2027 < LP;exit(3); < }/*if replayStatus!=0*/ < }/* is logfile */ --- > exit(3); > } > } 2382,2384c2032,2034 < LP;return; < /* see $CASE/03f522/bdeReplayUserGuideR1.031027 for TBD? comments-RJL060227 */ < } /* end (void) pr_load (2942-3017)- RJL 040616 [---> (2222-2304), 060227] */ --- > > return; > } /* end (void) pr_load (2942-3017 - RJL 040616 */ 2390c2040 < /* Output: none ( it will move table position to the specific row. */ --- > /* Output: none.( it will move table position to the specific row. */ 2428,2429c2078,2081 < if (tempptr1 == NULL) tempptr1 = tempptr0-1; /* add 1 later */ < else printf("chars skipped = %d\n", (int)(tempptr1-tempptr0)); --- > if (tempptr1 == NULL) > tempptr1 = tempptr0-1; /* add 1 later */ > DP;printf("%d chars in filename %s\n", > (int)(tempptr1-tempptr0), (char*) tempptr1+1); 2437a2090 >