6a7,26 > /* > * $Log: 94sbde_schema.h,v $ > * Revision 1.1.2.25 2005/03/11 04:21:39 lechner > * Removed merge conflict by removng & from key? in hasType defin. > * > * Revision 1.1.2.24 2005/03/10 06:02:37 lechner > * Added '&' to 'key?' in #define hasType(key, ttabbr) (&key?((... > * > * Revision 1.1.2.23 2005/02/26 04:25:35 lechner > * Update defin of select_CG - test &key not key, for 0 value. > * > * Revision 1.1.2.22 2005/02/25 00:30:00 lechner > * Modified hastType macro - added key!=0 condition. > * > * Revision 1.1.2.21 2004/11/29 20:10:18 lechner > * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. > * > ************************************************************************/ > /* Log aded 041129 - RJL */ > 17a38,42 > #include "../dprint.h" > /* #defines macros DP and EP to trace fcn calls - RJL 040601 */ > /* Func. #defs are conditional on __cplusplus__ */ > /* in bde, for g++ in src and gcc in pr_util - RJL 031024 */ > /* ??? EP macro ==> parse error in pr_*.c but not in src/_*.cc ??? - RJL 040621 */ 19a45 > 116a143 > extern int fpfstatus; /* for PrintCheck macro in schema.h */ 168d194 < 171c197,198 < char* get_abbr(); --- > char* get_abbr(hcg_key *k, char *ret ); > /* char* get_abbr(); - RJL 040517 */ 180c207 < #endif /*__cplusplus*/ --- > #endif /* not __cplusplus*/ 190c217 < --- > /* Why BTREESEARCH== TRUE? see pr_find_bt in pr_load.c - RJL 030808 */ 263,264c290 < /* This structure is used to simplify type casting pointers within table */ < /* rows. */ --- > /*This structure is used to simplify type casting _fpp pointers in table rows.*/ 273c299 < /* This following is a type definition for generic porinters */ --- > /* This following is a type definition for generic pointers */ 281c307,311 < extern hcg_ptr pr_gen_create(); --- > #ifdef __cplusplus > extern "C" hcg_ptr pr_gen_create(unsigned long); > #else > extern hcg_ptr pr_gen_create(unsigned long); > #endif 294,295d323 < /*hcg_key key_value; -- for pr_set_key() */ < /*int PARSE;*/ 297c325,328 < #define pr_set_int(tbl,fld,value) \ --- > > > /* replaced tbl by tbptr in pr_set_int macro only, TBtested - RJL 030814 */ > #define pr_set_int(tblptr,fld,value) \ 299c330 < if((tbl)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ --- > if((tblptr)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ 302c333 < decode_retstr( (hcg_key*)(tbl) ),"fld", (value) );\ --- > decode_retstr( (hcg_key*)(tblptr) ),"fld", (value) );\ 304c335 < (tbl)->fld = (value); \ --- > (tblptr)->fld = (value); \ 307c338,339 < #define pr_set_flt(tbl,fld,value) \ --- > /* replaced tbl in pr_set_flt macro by tblptr - RJL */ > #define pr_set_flt(tblptr,fld,value) \ 309c341 < if((tbl)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ --- > if((tblptr)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ 312c344 < decode_retstr( (hcg_key*)(tbl) ),"fld", (value) );\ --- > decode_retstr( (hcg_key*)(tblptr) ),"fld", (value) );\ 314c346 < (tbl)->fld = (value); \ --- > (tblptr)->fld = (value); \ 317c349,350 < #define pr_set_key(tbl,fld,value) \ --- > /* replaced tbl in pr_set_key macro by tblptr - RJL 040402 */ > #define pr_set_key(tblptr,fld,value) \ 319c352 < if((tbl)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ --- > if((tblptr)->RFLAG==1 && /*!PARSE && */ hcg_log ==1 )\ 323c356 < decode_retstr( (hcg_key*)(tbl) ),"fld", decode_retstr(&key_value) );\ --- > decode_retstr( (hcg_key*)(tblptr) ),"fld", decode_retstr(&key_value) );\ 325c358 < (tbl)->fld = (value); \ --- > (tblptr)->fld = (value); \ 327a361,365 > /* replaced tbl in pr_set_str macro by tblptr - RJL 040402 */ > /* this led to errors - no hsegpattern field in struct at tblptr! */ > /* restored tbl again - suppresed the fprinf below RJL 040404 */ > /* fprintf restored after replacing fld with #fld to quote it. */ > 332c370,371 < "Warning: field %s in table at %s is too long- truncated\n", "fld", "decode_retstr( (hcg_key*)(tbl)");\ --- > "Warning: field %s in table %s of length %d - truncated\n", \ > #fld, decode_retstr( (hcg_key*)(tbl)), (int) strlen(value) );\ 336c375 < decode_retstr( (hcg_key*)(tbl) ),"fld", (value) );\ --- > decode_retstr( (hcg_key*)(tbl) ), #fld, (value) );\ 343,347c382,386 < < #define pr_get_int(tbl,fld) (tbl)->fld < #define pr_get_flt(tbl,fld) (tbl)->fld < #define pr_get_str(tbl,fld) (tbl)->fld < #define pr_get_key(tbl,fld) (tbl)->fld --- > /* WARNING: these are ptr-baed and not safe - want read-only access.*/ > #define pr_get_int(tblptr,fld) (tblptr)->fld > #define pr_get_flt(tblptr,fld) (tblptr)->fld > #define pr_get_str(tblptr,fld) (tblptr)->fld > #define pr_get_key(tblptr,fld) (tblptr)->fld 370c409,410 < int hcg_log; /* Integer indicating log on (1) off (0) replay (2) */ --- > int hcg_log; /* Integer indicating log on (1) or off (0) */ > int hcg_replay; /* Integer indicating replay on (1) or off (0) */ 384c424,425 < extern int hcg_default_fkey; --- > extern int hcg_default_fkey; /* a flag, above - NOT an hcg_key (unsigned int)???-RJL 040517*/ > // extern hcg_key hcg_default_fkey; 386c427,428 < extern int hcg_row; --- > extern int hcg_row; /* An int above, not an hcg_key? (unsigned int)???-RJL 040517*/ > // extern hcg_key hcg_row; /* Inconsistent with MAIN block ==>? Unaligned Access loading tables.*/ 389c431 < extern int hcg_log; --- > extern int hcg_log, hcg_replay; 453a496,498 > /* actual arg tbl is unquoted ttabbr */ > /* PRECONDITION: tbl##curr is a valid ptr; e.g. via find_tbl_idx(). */ > 462c507,508 < #define encoding(s) (lut_insert_element(&hcg_table_abbrev_lut, s)) --- > #define encoding(ttabbr) (lut_insert_element(&hcg_table_abbrev_lut, ttabbr)) > /* SIDE EFFECTS? - RJL 030814 */ 485,486c531 < hcg_ts_list[tbl##_idx].ts_list[hcg_view_list.view_list[hcg_view_idx].version_list[tbl##_idx]].rcount : \ < 0) --- > hcg_ts_list[tbl##_idx].ts_list[hcg_view_list.view_list[hcg_view_idx].version_list[tbl##_idx]].rcount:0) 488,492c533,546 < /******************************************************************************/ < /* This macro is used to determine if the specified child exists under the */ < /* specified parent. */ < /******************************************************************************/ < #define child_exists(parent,child) ((child##curr != NULL) && ((struct parent *) child##curr) != (parent##curr)) --- > /*****************************************************************************/ > /* This macro verifies that the CURRENT parent's child_list is non-empty - RJL 040821*/ > /* This depends on the child type and the fkey name (there may be more than one)*/ > /* which implies the inverse (virtual) pfkey2c##_fcp = parent's first-child ptr*/ > /* Pre-condition: p2c relation exists in schema && parent##curr is not NULL- RJL 040821*/ > /*****************************************************************************/ > /***************************************************************/ > /* An alternate way to determine if any children exist under the */ > /* specified parent : (Revised to avoid child##curr dependence - RJL 040821 */ > /* It depends on the last child having the parent address (not NULL) in its _fcp field.*/ > /****************************************************************************/ > #define child_exists(ptype,ctype,pfkey2c) \ > ((ptype##curr->pfkey2c##_fcp != NULL) && \ > ((struct ptype *) ptype##curr->pfkey2c##_fcp != (ptype##curr))) 529c583,584 < #define first_child(parent,child,pkey) (parent##curr->pkey##_fcp == child##curr) --- > #define first_child(ptype,ctype,cfkey2p) \ > (ptype##curr->cfkey2p##_fcp == ctype##curr) 535c590,591 < #define last_child(parent,child,ckey) ((struct parent *) child##curr->ckey##_fpp == parent##curr) --- > #define last_child(ptype,ctype,cfkey2p) (\ > (struct ptype*) ctype##curr->cfkey2p##_fpp == ptype##curr) 538c594,595 < /* The macro defines pr_dump_row() as dump_row(). */ --- > /* The macro pr_dump_row() calls dump_row() and converts arguments */ > /* (Added arg3 - RJL 040629) */ 540,541c597,599 < #define pr_dump_row(tbl,viewname,file_name,new_version,modestr) dump_row(#tbl,viewname,file_name,new_version,modestr) < extern int open_file; --- > #define pr_dump_row(tbl,viewname,file_fp,file_name,new_version,modestr)\ > dump_row(#tbl,viewname,file_fp,file_name,new_version,modestr) > 543,544c601,602 < /* This macro is used to add the row into a binary tree. It is for internal */ < /* use to build a binary tree. */ --- > /* This macro btree_add_row adds the row into a binary tree. */ > /* It is for internal use to build a binary tree. */ 591c649,650 < } /******************************************************************************/ --- > } > /*****************************************************************************/ 593,594c652,669 < /* key is the one specified. */ < /******************************************************************************/ --- > /* key matches vslue. [Added 030807: If value is not at tbl##curr, */ > /* loop to search for the pkey value, if tbl##btidx==1 call pr_find_bt. */ > /* Optimization: skip search if tbl##curr->tbl##id is correct.-RJL 030807 */ > /* WARNING: pr_find sets tbl##curr == NULL if value is not found - RJL 030807]*/ > /* pr_find_bt is a no-op in pr_load.c, not implemented - RJL 030708. */ > /* No longer depends on pkey order - searches entire table - rev. RJL 040701 */ > /*****************************************************************************/ > /* WARNING: this is a MACRO, expands to a { statement } - it alters tbl##curr;*/ > /* TBD: Make this a function returning [a ptr or Pass/Fail?] - RJL 040701 */ > /* I altered a significant typo: from != to == below - RJL040708 */ > /* I removed this if-block below since pr_find_bt was a no-op - RJL 040724 */ > /* if( tbl##btidx == BTREESEARCH ) \ > * { \ > * pr_find_bt(#tbl,&value);\ > * } \ > * else\ > */ > 596c671,676 < if( tbl##btidx == BTREESEARCH ) \ --- > if ((tbl##curr!=NULL) && (key_compare(&tbl##curr->pkey,&value)==0))\ > ; /* a no-op if cached */ \ > else {\ > for (tbl##curr = tbl; tbl##curr != NULL;\ > tbl##curr = tbl##curr->next_ptr ) \ > if (key_compare(&tbl##curr->pkey,&value)==0) \ 598,600c678,679 < sprintf(tempbtree,"tbl"); \ < tempbtree[HCG_ABBR_SIZE]='\0'; \ < pr_find_bt(tempbtree,&value); \ --- > /*DP; dprintd("Found pkey = %lx\n", (hcg_key)value); */\ > break;\ 602,605c681 < else \ < for (tbl##curr = tbl; (tbl##curr != NULL) && (key_compare(&tbl##curr->pkey,&value) < 0); tbl##curr = tbl##curr->next_ptr); \ < if ((tbl##curr != NULL) && (key_compare(&tbl##curr->pkey,&value) != 0)) \ < tbl##curr = NULL --- > } /* end else */ 682c758 < /* his/her own looping variable. */ --- > /* his/her own looping variable. [WARNING: NO btree case here - RJL 030807] */ 762,765c838,850 < /******************************************************************************/ < /* Macro for checking error in file writes */ < /******************************************************************************/ < #define PrintCheck(x) if((x) == -1) { printf("Error in outputing file. Exiting\n"); exit(1);} --- > /***************************************************************************/ > /* Macro for checking errors in fprintf -(added pfstatus - RJL 040623) */ > /***************************************************************************/ > // PrintCheck's arg (x) is any [f]printf command, > // (man [f]printf ==> it returns either bytecount written, or a negative int.) > // (errno becomes one of 8 enum'td symbols. > // bdetest yield errno=9: EBADF (file not open for write). > // extern int pfstatus; (x below is a printf func call) > > #define PrintCheck(x) do {int pfstatus; pfstatus = (x);\ > if (pfstatus<0) {\ > dprintd("Errno %d in PrintCheck()\n",errno);\ > exit(1);} }while(0) 767d851 < /* C function prototypes for the C++ compiler */ 768a853,854 > > /* C function prototypes for the C++ compiler */ 787c873 < extern hcg_ptr pr_gen_create(int); --- > extern hcg_ptr pr_gen_create(unsigned long); 793a880,881 > extern int replay_log(void); /* added 031018 - RJL */ > 796a885,906 > /* wrapper macros to report calls to pr* fcns - RJL 030812 */ > > #define dpr_load printf\("%s:%i:pr_load\n",__FILE__, __LINE__\);pr_load > > #define dpr_init printf\("%s:%i:pr_init\n",__FILE__, __LINE__\);pr_init > > #define dpr_delete printf("%s:%i:pr_delete\n",__FILE__, __LINE__);pr_delete > > #define dpr_log printf\("%s:%i:pr_log\n",__FILE__, __LINE__\);pr_log > > #define dpr_dump printf\("%s:%i:pr_dump\n",__FILE__, __LINE__\);pr_dump > > #define dpr_replay printf\("%s:%i:pr_replay\n",__FILE__, __LINE__\);pr_replay > > #define dpr_add printf\("%s:%i:pr_add\n",__FILE__, __LINE__\);pr_add > > #define dpr_find printf("%s:%i:pr_find\n",__FILE__, __LINE__);pr_find > > /* this wrapper avoids unneeded call if result already true: RJL 030812 */ > #define opr_find(a,b,c) if (a##curr->b!=c) pr_find(a,b,c) > > 1025c1135 < char hsegpattern[5]; /* optional drawing patern for this segment*/ --- > char hsegpattern[5]; /* optional drawing pattern for segment*/ 1106,1107c1216 < < --- > /* Client: pr_util/pr_load.c:1669: abbr_lut_create(...) */ 1119a1229,1241 > /*#define hasType(key, ttabbr) strstr(decode_retstr(&key), #ttabbr) */ > /* moved from text.h - TBD: auto-generate - RJL 040629; changed RJL040925 */ > /* failed - when id = 0 is passed to key expecting a string ttabbr.... */ > /* changed 050211: check key? first: and 050225: test key address> 0 ? */ > > #define hasType(key,ttabbr) (key?((strstr(decode_retstr(&key),#ttabbr)?1:0)):0) > //#define hasType(key, ttabbr) (&key?((strstr(decode_retstr(&key), #ttabbr)?1:0)):0) > > /* where decode_retstr(&key) returns (PASS? => char*, FAIL? => NULL) */ > /* ( (status = decode(external_key,k)) == 1 ) ? external_key : NULL; */ > /* try : extern char *lut_get_name(lut_st* p_lut, int index) */ > > /* end ifndef __SCHEMA_LOADED */ 1:6a7,26 22:17a38,42 28:19a45 30:116a143 32:168d194 34:171c197,198 39:180c207 43:190c217 47:263,264c290 52:273c299 56:281c307,311 64:294,295d323 67:297c325,328 74:299c330 78:302c333 82:304c335 86:307c338,339 91:309c341 95:312c344 99:314c346 103:317c349,350 108:319c352 112:323c356 116:325c358 120:327a361,365 126:332c370,371 131:336c375 135:343,347c382,386 147:370c409,410 152:384c424,425 157:386c427,428 162:389c431 166:453a496,498 170:462c507,508 175:485,486c531 180:488,492c533,546 201:529c583,584 206:535c590,591 211:538c594,595 216:540,541c597,599 223:543,544c601,602 229:591c649,650 234:593,594c652,669 256:596c671,676 265:598,600c678,679 272:602,605c681 279:682c758 283:762,765c838,850 302:767d851 304:768a853,854 307:787c873 311:793a880,881 314:796a885,906 337:1025c1135 341:1106,1107c1216 346:1119a1229,1241