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 */ > /*****************************************************************/ 1:6c6,23 22:8a26 24:12a31 26:13a33,35 30:24a47 32:29c52 36:30a54,55 39:32,33c57 44:48c72,74 50:106a133,134 53:107a136 55:109,111c138,142 65:113c144,146 71:115,116d147 74:117a149,151 78:122,123c156,159 86:126,130c162,176 108:133,134d178 111:135a180,202 135:149c216 139:239c306 143:788d854 145:1157a1224 147:1178c1245 151:1271a1339 153:1339c1407,1408 158:1345c1414,1415 163:1390c1460 167:1397c1467 171:1406a1477 173:1410c1481,1482 178:1460a1533 180:1481c1554 184:1541a1615 186:1558c1632,1634 192:1561,1562c1637,1646 206:1564c1648,1651 213:1568,1569c1655,1656 219:1580d1666 221:1583c1669 225:1594,1595c1680,1681 231:1598,1599c1684,1687 239:1601,1602c1689,1691 246:1607,1608c1696,1736 291:1610a1739 293:1613c1742 297:1615a1745,1753 307:1617,1618c1755,1758 315:1621,1623c1761,1764 324:1625,1626c1766,1767 330:1629c1770 334:1632c1773 338:1635c1776,1777 343:1641c1783,1784 348:1646,1648c1789 354:1649a1791 356:1651,1652c1793,1794 362:1654,1655c1796,1798 369:1657c1800 373:1662d1804 375:1665a1808,1810 379:1667c1812,1813 384:1669c1815,1817 390:1670a1819,1820 393:1672,1675c1822 400:1676a1824,1831 409:1679,1680c1834,1836 416:1681a1838 418:1682a1840,1857 437:1684c1859,1860 442:1689c1865,1868 449:1693c1872,1873 454:1696c1876,1877 459:1698c1879,1880 464:1700c1882 468:1704,1707c1886,1887 476:1709c1889,1890 481:1712c1893,1900 492:1714c1902,1903 497:1717c1906 501:1719,1720c1908,1911 509:1722c1913,1915 515:1725c1918,1920 521:1726a1922,1923 524:1729c1926,1928 530:1736c1935,1937 536:1739a1941 538:1741a1944 540:1744c1947,1948 545:1752c1956,1957 550:1758c1963,1967 558:1765,1778c1974,1975 576:1781a1979,2005 604:1785,1787d2008 608:1789c2010,2013 615:1812a2037 617:1831a2057,2058 620:1882c2109 624:2041c2268 628:2074c2301 632:2086a2314,2316 636:2088d2317 638:2107c2336,2338 644:2120c2351 648:2125c2356 652:2128c2359 656:2131,2132c2362,2369 668:2136c2373,2374 673:2138,2140c2376,2380 683:2141a2382,2385 688:2143d2386 690:2147c2390 694:2153,2154c2396,2399 702:2161,2163c2406,2410 712:2251c2498,2499 717:2259a2508,2509 720:2271c2521 724:2291,2292c2541 729:2294c2543 733:2316,2319c2565,2572 747:2321c2574 751:2424c2677,2678 756:2427,2428c2681,2682 762:2432c2686,2695 775:2437c2700,2708 787:2441,2443d2711 791:2444a2713,2719 799:2447,2455c2722,2727 816:2457,2458c2729 821:2460,2461c2731,2741 836:2465,2466c2745 841:2468c2747,2760 858:2473,2474c2765 863:2475a2767,2768 866:2480c2773,2774 871:2483c2777 875:2488,2489c2782,2788 886:2490a2790 888:2494c2794 892:2496a2797 894:2500d2800 896:2501a2802 898:2504,2505c2805 903:2507,2508c2807,2820 921:2509a2822 923:2510a2824 925:2517,2518c2831,2837 936:2521,2523c2840 942:2726c3043 946:2729c3046 950:2732c3049 954:2734a3052,3055 959:2740c3061,3062 964:2745d3066 966:2746a3068,3069 969:2752a3076 971:2757a3082 973:2763,2765c3088,3106 997:2766a3108,3117 1008:2768a3120,3126 1016:2790d3147 1018:2792a3150,3179