$RBGB/pr_load.r1.3.vs.r1.4.cvsdiff: [This was done in the older directory ~/bde2alpha_rl/bde/pr_util, before the bde/pr_util repository node was split into pr_util_[no]log:] cvs log reported all prior revs despite this migration. rcslint was ableo to reveal the one-line diff; see the extract and comments in $RBGB/do_pr_add.r1.3.vs.r1.4.cvsdiff. --------------------------------------------- saturn.cs.uml.edu1](7)> pwd /tmp_mnt/nfs/galaxy/faculty/fac1/lechner/bde2alpha_rl/bde/pr_util [saturn.cs.uml.edu1](9)> cvs diff -r1.3 -r1.4 pr_load.c | wc 1183 4035 34339 [saturn.cs.uml.edu1](8)> cvs diff -r1.3 -r1.4 pr_load.c >pr_load.r1.3.vs.r1.4.cvsdiff ===================================== Index: pr_load.c =================================================================== RCS file: /usr/proj3/case/95s523/95sbde/base/Master/bde/pr_util/pr_load.c,v retrieving revision 1.3 retrieving revision 1.4 diff -r1.3 -r1.4 0a1 > /* Start of gen_pr_utils output to pr_load.c */ 5a7,8 > /* pr_load.c sources (sequential): */ > /* gen_pr_utils gen_pr_init gen_pr_add gen_load_data gen_pr_load*/ 38,47c41,54 < char outkey[3][HCG_KEY_SIZE+1]; /* used in log_pr_add() */ < /* A distinct outkey is local to pr_dump.c; */ < /* forward declaration */ < int btree_insert_node(btree_node_st**, char*, int); < int lut_does_node_exist(lut_st*, char*); < int btree_does_node_exist(btree_node_st*, char*); < int btree_destroy(btree_node_st*, btree_node_st*); < int btree_create(lut_st*); < int btree_wt(btree_node_st*); < void btree_initialized(void); --- > char outkey[3][HCG_KEY_SIZE+1]; /* for log_pr_add() */ > /* A distinct outkey is local to pr_dump.c; */ > /* forward declaration of prototypes */ > extern int lut_insert_element (lut_st *, char *); > extern char * lut_get_name (lut_st *, int); > extern int abbr_lut_create (lut_st *, char **, int); > extern int btree_insert_node(btree_node_st**, char*, int); > extern int lut_does_node_exist(lut_st*, char*); > extern int btree_does_node_exist(btree_node_st*, char*); > extern int btree_destroy(btree_node_st*, btree_node_st*); > extern int btree_create(lut_st*); > extern int btree_wt(btree_node_st*); > extern void btree_initialized(void); > 50,51c57,60 < < #ifdef GENLOG --- > extern void hcg_parse (char * , char * , int *); > extern void mystrcpy (char * , char * , int, int); > extern void strncpy_null (char * , char * , int); > extern void logstr(char*); 53c62,64 < extern void logstr(char*); --- > extern int pr_replay(char *, char *, int, int); > extern char* logfile; > 55c66,67 < extern int pr_replay(char *, char *, int, int);/* #ifdef GENLOG */ --- > #ifndef GENLOG > void logstr(char* s) {/*no-op*/}; 59,63d70 < #else < < void logwait(void){/* a no-op */} < < extern void logstr(char*); 65c72,73 < int pr_replay(char*s1,char*s2, int x1, int x2){ return 0;}/*#ifndef GENLOG*/ --- > void logwait(void){/* a no-op */}; > int pr_replay(char * u, char *v , int w, int x) {return 0;}; 69a78 > char* logfile = "dummylogfilename"; 83c92,93 < /******************************************************************************/ --- > #ifndef GENPR > /****************************************************************/ 88c98 < /******************************************************************************/ --- > /****************************************************************/ 123c133,136 < /******************************************************************************/ --- > /* end GENPR_dependent compilation */ > /* to avoid duplicate defs in chgen/src/lut.c - RJL050710 */ > #endif > /*********************************************************/ 127c140 < /******************************************************************************/ --- > /*********************************************************/ 134c147 < /******************************************************************************/ --- > /*********************************************************/ 143c156 < /******************************************************************************/ --- > /*********************************************************/ 161c174 < /******************************************************************************/ --- > /*********************************************************/ 168c181 < /******************************************************************************/ --- > /*********************************************************/ 212c225 < /******************************************************************************/ --- > /*********************************************************/ 216c229 < /******************************************************************************/ --- > /*********************************************************/ 219c232 < /******************************************************************************/ --- > /*********************************************************/ 222c235 < return(1); --- > return(hcg_view_list.view_list[view_idx].version_list[tbl_idx] == (get_version(&pkey))); 225c238 < /******************************************************************************/ --- > /*********************************************************/ 229c242 < /******************************************************************************/ --- > /*********************************************************/ 269c282,283 < /******************************************************************************/ --- > #ifndef GENPR > /*********************************************************/ 277c291 < /******************************************************************************/ --- > /*********************************************************/ 298a313,314 > /* end GENPR_dependent compilation to avoid duplicate defs in lut.c */ > #endif 311c327,328 < (hcg_view_list.view_list[hcg_view_idx].mode == 'w') ) --- > (hcg_view_list.view_list[hcg_view_idx].mode == 'w') && > (hcg_view_list.view_list[hcg_view_idx].version_list[tbl_idx] != '\0')) 318,1228d334 < < < /*----------------------------------------------------------- < * < * Source File : lut.c < * < * This file contains code for look up table < * and binary tree mainipulations used by chgen and gen < * developed for spring 1993 project... < *----------------------------------------------------------- < */ < < #ifndef HCG_KEY_SIZE /* used to determine context of lut */ < /* code use so that includes are not*/ < /* multiply defined */ < < #include < #include < #include < #include "lut.h" < < #endif < < char *lut_get_name(); < < /* < ************************************************************ < * Function : is_string_null < * < * Abstract : function to determine if string is NULL... < * < * Created by : T. Cunningham < * < * Creation Date : 4/14/93 < * < * Modified : < * < ************************************************************ < */ < bool < is_string_null(p_string) < char *p_string; < { < /* local variables */ < < < /**************************************/ < < if(*p_string == '\0') < { < return(TRUE); < } < < return(FALSE); < < } /* end is_string_null */ < < /* < ************************************************************ < * Function : lut_display < * < * Abstract : Function to display look up table... < * < * Created by : T. Cunningham < * < * Creation Date : 4/14/93 < * < * Modified : < * < ************************************************************ < */ < int < lut_display(p_lut, max_num) < lut_st *p_lut; < int max_num; < { < /* local variables */ < < int idx; < < char *p_str; < /**************************************/ < < printf("\nLook Up Table Output \n"); < printf( "---- -- ----- ------\n\n"); < for(idx=0; idxtype = type; < p_lut->p_btree_root = NULL; < p_lut->num_elements = 0; < < for(idx=0; idxnames[idx]; < *p_ch = '\0'; < } < < return(0); < < } /* end lut_init */ < < < < < /* < ************************************************************ < * Function : lut_insert_element < * < * Abstract : Function to insert an element into a look up table. < * < * Created by : T. Cunnigham < * < * Creation Date : 4/13/92 < * < * Modified : < * < ************************************************************ < */ < int < lut_insert_element(lut_st *p_lut, char *name) < { < /* local variables */ < < int test, < idx, < loop, < len; < < /**************************************/ < < len = strlen(name); < < switch(p_lut->type) < { < case ABBR_TBL_TYPE : < if( (len != ABBR_SIZE_BIG) && (len != ABBR_SIZE_SMALL)) < { < printf("%s : Input character string != required abbreviation size...\n", name); < return(ERROR); < } < else < { < /*************************************/ < /* check if abbrv is AAA thru ZZZ */ < /*************************************/ < for(idx=0; idx < len; idx++) < { < if((name[idx] > 'Z') || (name[idx] < 'A') ) < { < printf("%s : Invalid abbreviation passed to insert funct...\n", name); < return(ERROR); < } < } < } < break; < < case VER_TBL_TYPE : < if(len != VER_SIZE) < { < printf("Input character string != required version size...\n"); < return(ERROR); < } < else < { < /****************************************************/ < /* check if version is between 0 and MAX_VER_NUMBER */ < /****************************************************/ < test = atoi(name); < if((test < 0) || (test > MAX_VER_NUMBER)) < { < printf("%s : Invalid version number passed to insert funct. \n", name); < return(ERROR); < } < < < /*************************************/ < /* check to see if there are already */ < /* MAX_VER_ELEMENTS in the table... */ < /*************************************/ < if(p_lut->num_elements >= MAX_VER_ELEMENTS) < { < printf("Version look up table already full...\n"); < printf("Only allowed to have %d indexes...\n", < MAX_VER_ELEMENTS); < return(ERROR); < } < } < break; < default : < printf("%s : Unknown table type input to lut_insert_element routine...\n",name); < return(ERROR); < break; < } < < < < < /**************************************/ < /* check btree to see if abbrv exists */ < /* if exists do not add to table */ < /**************************************/ < < if((test = btree_does_node_exist(p_lut->p_btree_root, name)) != ERROR) < { < return(test); < } < < < /*************************************/ < /* find next available slot in table */ < /*************************************/ < < idx = 0; < loop = TRUE; < < while(idx < LUT_NUM_ELEMENTS) < { < if(is_string_null(p_lut->names[idx])) < { < strcpy((char *) p_lut->names[idx], name); < < p_lut->num_elements++; < < btree_insert_node(&p_lut->p_btree_root, name, idx); < < return(idx); < } < < idx++; < < } /* end while */ < < printf("No slots available for element insertion...\n"); < return(ERROR); < < } /* end lut_insert_element */ < < < /* < ************************************************************ < * Function : lut_delete_element < * < * Abstract : Function to delete an entry in the look up table. < * < * Created by : T. Cunningham < * < * Creation Date : 4/13/93 < * < * Modified : < * < ************************************************************ < */ < int < lut_delete_element(p_lut, index) < lut_st *p_lut; < int index; < { < /* local variables */ < < char *p_ch; < /**************************************/ < < if(index > LUT_NUM_ELEMENTS) < { < printf("ERROR - Requested index > look up table size...\n"); < return(ERROR); < } < < if(is_string_null(p_lut->names[index])) < { < printf("ERROR - Requested index to delete does not exist...\n"); < return(ERROR); < } < < printf("Deleting lut element # %d\n", index); < < p_ch = (char *) p_lut->names[index]; < *p_ch = '\0'; < p_lut->num_elements--; /* decrement number of elements in lut */ < < printf("Destroying binary tree\n"); < btree_destroy(p_lut->p_btree_root, (btree_node_st *)NULL); < < printf("Recreating binary tree\n"); < p_lut->p_btree_root = NULL; < btree_create(p_lut); < < return(0); < < } /* end lut_delete_element */ < < < /* < ************************************************************ < * Function : lut_does_node_exist < * < * Abstract : Function to accept a character string < * and return the index of that array in the < * look up table. < * Return a ERROR if the string does not exist < * in the table... < * < * Created by : T. Cunningham < * < * Creation Date : 5/6/93 < * < * Modified : < * < ********************************************************** < */ < < int < lut_does_node_exist(p_lut, name) < lut_st *p_lut; < char name[]; < { < < int ret_stat; < < < if(p_lut == NULL) < { < printf("Null ptr passed as lut address...\n"); < return(ERROR); < } < < ret_stat = btree_does_node_exist(p_lut->p_btree_root, name); < < return(ret_stat); < < } /* end lut_does_node_exist */ < < < < /* < ************************************************************ < * Function : lut_get_name < * < * Abstract : Function to accept an index number and return < * the abbreviation name corresponding to the < * index number... < * < * returns a character pointer. < * < * Created by : T. Cunningham < * < * Creation Date : 4/13/92 < * < * Modified : < * < ************************************************************ < */ < char < *lut_get_name(p_lut, index) < lut_st *p_lut; < int index; < { < /* local variables */ < < < /**************************************/ < < if(index <= LUT_NUM_ELEMENTS) < { < if(is_string_null(p_lut->names[index])) < { < return(NULL); < } < else < { < return((char *)p_lut->names[index]); < } < } < else < { < printf("Invalid index input to lut_get_name...\n"); < return(NULL); < } < < } /* end lut_get_name */ < < < /* < ************************************************************ < * Function : abbr_lut_create < * < * Abstract : Function to create a lut from an array of < * strings... < * Returns ERROR if failure occurred or < * returns (0) if successful.... < * < * Created by : T. Cunningham < * < * Creation Date : 5/2/93 < * < * Modified : < * < ************************************************************ < */ < int < abbr_lut_create(p_lut, p_abbr, num_strings) < lut_st *p_lut; < char *p_abbr[]; < int num_strings; < { < int ret_stat, < idx; < < < lut_init(p_lut, ABBR_TBL_TYPE); < < /* build the lut table and btree */ < for(idx=0; idxname, p_node->num, p_node->weight); < < btree_print_node(p_node->p_left); < btree_print_node(p_node->p_right); < < return(0); < < } /* end btree_print_node */ < < < < < /* < *********************************************************** < * Function : btree_display_nodes < * < * Abstract : Function to traverse the btree and print out < * each node in a depth first fashion. < * < * Created by : T. Cunningham < * < * Creation Date : 4/14/93 < * < * Modified : < * < ************************************************************ < */ < int < btree_display_nodes(p_root) < btree_node_st *p_root; < { < /* local variables */ < < < /**************************************/ < printf("\n\nAbbreviation Index Weight - Binary Tree Output\n"); < printf( "------------ ----- ------\n\n"); < < btree_print_node(p_root); < < return(0); < < } /* end btree_display_nodes */ < < < < < /* < *********************************************************** < * Function : btree_does_node_exist < * < * Abstract : Function to determine if abbreviation exists < * in the lut binary tree. < * < * returns : index number of abbreviation < * or ERROR if it does not exist. < * < * Created by : T. Cunningham < * < * Creation Date : 4/14/93 < * < * Modified : < * < ************************************************************ < */ < int < btree_does_node_exist(p_node, name) < btree_node_st *p_node; < char name[]; < { < /* local variables */ < < int test, < ret_stat; < < /**************************************/ < < if(p_node == NULL) < { < return(ERROR); < } < < if( (test = strcmp(p_node->name, name)) == 0) < { < return(p_node->num); < } < < ret_stat = btree_does_node_exist(p_node->p_left, name); < if(ret_stat >= 0) < { < return(ret_stat); < } < < < ret_stat = btree_does_node_exist(p_node->p_right, name); < if(ret_stat >= 0) < { < return(ret_stat); < } < else < { < return(ERROR); < } < < } /* end btree_does_node_exist */ < < < /* < ************************************************************ < * Function : btree_insert_node < * < * Abstract : Function to insert a node into an existing btree, < * or if btree does not exist create a new one and < * insert the node as the root. < * < * Created by : T. Cunningham < * < * Creation Date : 4/14/93 < * < * Modified : < * < ************************************************************ < */ < int < btree_insert_node(p_new, abbr, index) < btree_node_st **p_new; < char abbr[]; < int index; < { < /* local variables */ < < int test; < < /**************************************/ < < btree_node_st *p_temp, < *p_node; < < /**************************************************/ < /* first check if btree exists - if not create it */ < /**************************************************/ < if(*p_new == NULL) < { < p_node = (btree_node_st *) calloc(sizeof(btree_node_st), 1); < < strcpy(p_node->name, abbr); < < p_node->num = index; < p_node->weight = 2; < p_node->p_right = NULL; < p_node->p_left = NULL; < < < *p_new = p_node; < return(0); < } < < < /* insert into existing binary tree */ < < p_temp = *p_new; < < /*******************************************/ < /* check out if abbreviation already exists */ < /* if so return the index of the abbrev */ < /********************************************/ < test = strcmp(p_temp->name, abbr); < < if(test == 0) < { < /* node exists */ < printf("Node : %s Already exists...\n", p_temp->name); < return(0); < } < else if (test < 0) /* insert into right child */ < { < btree_insert_node(&p_temp->p_right, abbr, index); < } < else if (test > 0) /* insert into left child */ < { < btree_insert_node(&p_temp->p_left, abbr, index); < } < < < p_temp->weight = btree_wt(p_temp->p_left) + btree_wt(p_temp->p_right); < < return(0); < < } /* end btree_insert_node */ < < < < /* < ************************************************************ < * Function : btree_create < * < * Abstract : Function to create the btree from the look up table. < * < * Created by : T. Cunningham < * < * Creation Date : 4/14/93 < * < * Modified : < * < ************************************************************ < */ < int < btree_create(p_lut) < lut_st *p_lut; < { < /* local variables */ < < int idx; < < char *p_abbr; /* ptr to abbreviation */ < < /**************************************/ < < /* traverse the lut */ < < for(idx=0; idx < LUT_NUM_ELEMENTS; idx++) < { < /* get next element in the lut */ < < p_abbr = lut_get_name(p_lut, idx); < if(p_abbr != NULL) < { < /* add to btree */ < < btree_insert_node(&p_lut->p_btree_root, p_abbr, idx); < } < < } /* end for */ < < < return(0); < < } /* end btree_create */ < < < /* < ************************************************************ < * Function : btree_destroy < * < * Abstract : Function to delete the binary tree and < * free up the memory allocated to the tree. < * < * Created by : T. Cunningham < * < * Creation Date : 4/15/93 < * < * Modified : < * < *********************************************************** < */ < int < btree_destroy(p_node, p_back) < btree_node_st *p_node; < btree_node_st *p_back; < { < /* local variables */ < < char child_dir; < /**************************************/ < < if(p_back == NULL) < { < /* this is a root node */ < child_dir = 'N'; < } < else if(p_back->p_right == p_node) < { < /* this is a right child of the parent */ < < child_dir = 'R'; < } < else if(p_back->p_left == p_node) < { < /* this is a left child of the parent */ < < child_dir = 'L'; < } < < < < /* if leaf node */ < if( (p_node->p_left == NULL) && (p_node->p_right == NULL)) < { < /***********************/ < /* this is a leaf node */ < /***********************/ < < /* set parent ptr to this node to NULL */ < < if(child_dir == 'R') < { < p_back->p_right = NULL; < } < else if(child_dir == 'L') < { < p_back->p_left = NULL; < } < else < { < /* node is root */ < } < < free(p_node); < < return(0); < } < < < /* not a leaf node */ < < if(p_node->p_left == NULL) < { < /*****************************/ < /* node has right child only */ < /*****************************/ < < btree_destroy(p_node->p_right, p_node); < } < else /* left node exists */ < { < if(p_node->p_right == NULL) < { < /****************************/ < /* node has left child only */ < /****************************/ < btree_destroy(p_node->p_left, p_node); < } < else < { < /***********************************/ < /* node has two children */ < /***********************************/ < < btree_destroy(p_node->p_left, p_node); < btree_destroy(p_node->p_right, p_node); < } < } < < < < < /*******************************************/ < /* If you get here you are now a leaf node */ < /* All of your subtrees have been deleted */ < /*******************************************/ < < /* set parent ptr to this node to NULL */ < < if(child_dir == 'R') < { < p_back->p_right = NULL; < } < else if(child_dir == 'L') < { < p_back->p_left = NULL; < } < else < { < /* node is root */ < } < < free(p_node); < < return(0); < < } /* end btree_destroy */ < < < < < < < < /* < **************************************************************** < * Function : btree_wt < * < * Abstract : Function to give a weight to each node in the tree < * The weight is based on number of nodes below it. < * This is used for balencing btrees - however the < * the balence code was not included in this gen < * version due to a lack of time to debug it... < * < * Created by : D. Pinkney < * < * Creation Date :?????? < * < * Modified : < * < ********************************************************** < */ < int < btree_wt(t) /* returns weight of tree or 1 otherwise */ < btree_node_st *t; < { < if (t == (btree_node_st *) NULL) < { < return(1); < } < else < { < return(t->weight); < } < < } /* end btree_wt */ < < 1288c394 < if( (tmp = (char *)lut_get_name(&hcg_table_abbrev_lut, abi)) != NULL ) --- > if( (tmp = (char *)lut_get_name(&hcg_table_abbrev_lut, (int)abi)) != NULL ) 1631a738,739 > /* end of gen_pr_utils output to pr_load.c */ > /* start of gen_pr_init output to pr_load.c */ 1657,1658d764 < char* localptr = &localname[0]; < 1984c1090,1091 < /******************************************************************************/ --- > /* end of gen_pr_init output to pr_load.c */ > /******************************************************************************/ 2216c1323 < hcg_ptr pr_gen_create ( unsigned long size ) --- > hcg_ptr pr_gen_create ( size_t size ) 2222c1329 < } --- > } /* end pr_gen_create */ 2296a1404 > /* start of gen_pr_add output to pr_load.c */ 2331a1440,1441 > if (hcg_view_list.view_list[hcg_view_idx].version_list[hcg_tbl_idx] == '\0') > return; 2447c1557,1559 < /******************************************************************************//* This routine is used to read the (already open) datafile and call pr_add */ --- > /* start of gen_load_data output to pr_load.c */ > /******************************************************************************/ > /* This routine is used to read the (already open) datafile and call pr_add */ 2465,2466c1577,1578 < extern char *logfile; < /* int hcg_replay; - Quandary: bootstrap m*.h may not have this declaration?~RJL050526 */ --- > //extern char *logfile; > /* int hcg_replay; - Quandary: bootstrap m*.h may not have this declaration?-RJL050526 */ 2498c1610 < else if (strcmp( hcg_t, "SR") == 0 ) // and hcg_log == 0 ?? - RJL040712 --- > else if (strcmp( hcg_t, "SR") == 0 ) // and hcg_log == 0 ? - RJL040712 2501,2502c1613,1614 < dprints("Replay logfile is %s \n", logfile); < /* is logfile known ? */ --- > dprint("TBD: Load checkpoint *DB1 then replay logfile. > "); 2534c1646,1652 < if (HCG_KEY_SIZE == 8) ver_chars = 2; --- > 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; 2591a1710 > /* start of gen_pr_parse output to pr_load.c */ 2810a1930,1932 > /* end of gen_pr_parse output to pr_load.c */ > /* end of gen_load_data output to pr_load.c */ > /* start of gen_pr_load output to pr_load.c */ 2825,2827d1946 < /* extern char *logfile; */ < /* Added by Genlog 5/8/96 to log pr_load */ < char log_text[BUFSIZE]; 2829,2839c1948 < if ( hcg_log == 1 ) { < #ifdef GENLOG < logwait(); < sprintf(log_text,"LD %s %s\n", viewname, file_name); < logstr(log_text); < #else < printf("hcg_log==1 is illegal (#ifndef GENLOG)\n");/*RJL050606*/ < #endif < } < /* End Genlog Addition */ < --- > /* Removed logfile decl'n - RJL050719 */ 2862c1971 < /* check for global args to load_data below: =- RJL 040622 */ --- > /* check for global args to load_data below: - RJL 040622 */ 2864c1973 < load_data(viewname); /* isLogFile=1 iff "SR" command on line 1 */ --- > load_data(viewname); /* isLogFile=1 iff "SR" command on line 1 */ 2866,2867c1975,1976 < fclose(hcg_ascii_fp); // restored - RJL 040522 < --- > fclose(hcg_ascii_fp); // restored - RJL 040522 > 2873,2879c1982,1985 < 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); < < replayStatus = pr_replay(viewname, file_name, 1, 1); < < --- > DP; > 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 # */ 2882c1988 < /* Replay updates can be done by 's' Keypress callback - one transaction at a time */ --- > /* Replay updates can be done by 's' Keypress callback - one at a time */ 2919c2025 < } --- > }/*end pr_find_bt()*/ 2948c2054 < } /* end stripDPath */ --- > } /* end stripDPath() */ 2950a2057 > /* end of gen_pr_load.c output to pr_load.c */