0a1 > 6c7,17 < --- > /* > * $Log: pr_dump.c,v $ > * Revision 1.1.2.7 2005/02/25 00:34:12 lechner > * > * cvs diff pr_util 050223: No changes except hasType macro in 94sbde_schema.h > * > * Revision 1.1.2.6 2004/11/29 20:10:19 lechner > * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. > * > ******************************************************************************/ > #include /* for exit() */ 15a27,30 > /* outkey changed to dumpkey here; - RJL)40711 */ > /* outkey was local to pr_dump.c; it is distinct from outkey[] in pr_load.c: */ > /* decode maps hcg_key pfkeys into 1 to 3 ASCII string ptrs in outkey[0-2.*/ > char dumpkey[3][HCG_KEY_SIZE+1]; /* used in pr_dump_row */ 17,20c32 < /* This outkey is local to pr_dump; it has a distinct scope in pr_load.c: */ < char outkey[3][HCG_KEY_SIZE+1]; /* used in dump_row */ < < /* encoding expands to (in pr_util/94sbde_*schema.h line 469): */ --- > /* encoding declared in pr_util/94sbde_*schema.h line 469: */ 22,23c34,42 < int fstatus; < void dump_row( char*, char*, char*, int, char* );/*fwd ref*/ --- > int fstatus; /* from fclose(hcg_dump_fp) */ > int fpfstatus; /* from fprintf in PrintCheck macro */ > void dump_row( char*, char*, FILE*, char*, int, char* ); /*fwd ref*/ > > /* dump_row is called indirectly - see 94sbde_schema.h:562: > * #define pr_dump_row(tbl,viewname,file_ptr,file_name,new_version,modestr) \ > * dump_row(#tbl,viewname,file_fp,file_name,new_version,modestr) > * (dump_row actually uses global var hcg_dump_fp; file_name is for printing) > */ 31a51,57 > /* Client must pass new arg3 = dump_fp via macro pr_dump_row.-RJL 040615 */ > /* modestr arg no longer needed - open_file status variable removed - RJL 040615*/ > /* Q1 040625: does mode "w" imply over-writing a new file? */ > /* Q2 040625: PrintCheck aborts with errno 9 = EBADF (can't write to file). Why?*/ > /* dump_row now gets new arg3 = FILE* for flexibility (e.g. graphDump client) */ > /* Global hcg_dump_fp replaced by local dump_fp - RJL 040629 */ > 33,36d58 < /*char viewname[]; < char file_name[]; < int new_version; < char modestr[];*/ 39c61,62 < open_file=0; --- > FILE* dump_fp; /* was global hcg_dump_fp - RJL 040629 */ > EP; 50c73 < if ((hcg_dump_fp=fopen(file_name,modestr)) == NULL) --- > if ((dump_fp = fopen(file_name,modestr)) == NULL) 68c91,94 < pr_dump_row(FO,viewname,file_name,new_version,modestr); --- > /* TBD: No need to pass file_name to pr_dump_row now .-RJL 040629 */ > /* Here, actual arg3 passes the global variable hcg_dump_fp - RJL 040629 */ > > pr_dump_row(FO,viewname,dump_fp,file_name,new_version,modestr); 76c102 < pr_dump_row(GD,viewname,file_name,new_version,modestr); --- > pr_dump_row(GD,viewname,dump_fp,file_name,new_version,modestr); 83,84c109 < < pr_dump_row(HG,viewname,file_name,new_version,modestr); --- > pr_dump_row(HG,viewname,dump_fp,file_name,new_version,modestr); 91,92c116 < < pr_dump_row(HN,viewname,file_name,new_version,modestr); --- > pr_dump_row(HN,viewname,dump_fp,file_name,new_version,modestr); 100c124 < pr_dump_row(HA,viewname,file_name,new_version,modestr); --- > pr_dump_row(HA,viewname,dump_fp,file_name,new_version,modestr); 107,108c131 < < pr_dump_row(HL,viewname,file_name,new_version,modestr); --- > pr_dump_row(HL,viewname,dump_fp,file_name,new_version,modestr); 116c139 < pr_dump_row(HP,viewname,file_name,new_version,modestr); --- > pr_dump_row(HP,viewname,dump_fp,file_name,new_version,modestr); 124c147 < pr_dump_row(HI,viewname,file_name,new_version,modestr); --- > pr_dump_row(HI,viewname,dump_fp,file_name,new_version,modestr); 132c155 < pr_dump_row(CG,viewname,file_name,new_version,modestr); --- > pr_dump_row(CG,viewname,dump_fp,file_name,new_version,modestr); 140c163 < pr_dump_row(GX,viewname,file_name,new_version,modestr); --- > pr_dump_row(GX,viewname,dump_fp,file_name,new_version,modestr); 145,150c168,181 < } /* end if */ < } /* end for */ < fstatus = fclose(hcg_dump_fp); < if (fstatus != 0) < printf("\n\nERROR: pr_dump File failed to close!\n\n"); < open_file=1; --- > } /* end if rcount > 0 */ > } /* end for each table (hcg_tbl_idx++) */ > fstatus = fclose(dump_fp); // AFTER all tables are dumped! - RJL 040625 > // man fclose: Upon successful completion, fclose() etc. > // return a value of 0 (zero). > // Otherwise, EOF is returned, and errno is set to indicate the error. > if (fstatus!= 0) { > printf( > "\n\nERROR %d: pr_dump failed to close filename %s: abort!\n\n", > errno, file_name); > exit(0); > } > /* Next dump_row client must re-do hcg_dump_fp = fopen(file_name,modestr) */ > return; 151a183 > 152a185 > /* dump_row is called from macro pr_dump_row which 'stringizes' arg1=ttabbr */ 154,157c187,190 < /* view to the specified file_name. The tbl indicates which table's row */ < /* will be dumped. The open_file flag of 1 indicates open a file for dumping */ < /* a single row. Otherwise doesn't open file because pr_dump had opened a */ < /* file. If the mode of the view is rite, the caller is allowed to specify a */ --- > /* view to the specified file_name. Arg't tbl indicates which table's row */ > /* will be dumped. The dumpfile_is_open flag of 1 indicates open a file for */ > /* dumping a single row. Else, do not open because pr_dump opened hcg_dump_fp.*/ > /* If the mode of the view is right, the caller is allowed to specify a */ 160c193,194 < /* or append to an existing file ('a'). */ --- > /* or append to an existing file ('a'). (arg3=file_ptr added - RJL 040629 */ > /* I added arg3=FILE* dump_fp and removed arg6=char* modestr - RJL 040629 */ 162c196,203 < void dump_row ( char* tbl, char* viewname, char* file_name, int new_version, char* modestr ) --- > /* RJL: 040615: Since scatter-writing one row at a time doesn't make sense, > * dump_row gets an explicit file_ptr for filename opened by the caller, > * and just write out the appropriate table-row. > * pr_dump's table_loop is bypassed so an optional depth-first > * spanning-tree-walk thru descendant table rows can sequence the output. > */ > > void dump_row ( char* tbl, char* viewname, FILE* dump_fp, char* file_name, int new_version, char* modestr ) 165,173c206,213 < if (open_file==1) < { < if ((hcg_dump_fp=fopen(file_name,modestr)) == NULL) < { < printf("Error: pr_dump_row() cannot open %s using file mode %s\n", file_name,modestr); < exit(1); < } < } < if (idx==0) --- > //EP; > > /* removed fopen action - Pre-condition: > dump_fp open for write or append - RJL 040615 */ > /* changed if conditions to switch cases with breaks - RJL040630 */ > assert (dump_fp != NULL); > switch(idx) { > case 0: 176,178c216,218 < decode((char*)outkey[0], &FOcurr->FOid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-50s %-50s %-2s %-15s\n" < , outkey[0], FOcurr->xfont, FOcurr->psfontname, FOcurr->psfontsize, FOcurr->bdefont)); --- > decode((char*)dumpkey[0], &FOcurr->FOid); > PrintCheck(fprintf(dump_fp, " %-8s %-50s %-50s %-2s %-15s\n" , dumpkey[0], FOcurr->xfont, FOcurr->psfontname, FOcurr->psfontsize, FOcurr->bdefont)); > break; 180c220 < if (idx==1) --- > case 1: 183,186c223,225 < decode((char*)outkey[0], &GDcurr->GDid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-10s %8.4f %8.4f %-4s %-25s %-10s %-10s %8.4f %8.4f\n" < , outkey[0], GDcurr->shape, GDcurr->width, GDcurr->height, GDcurr->hsegpattern, GDcurr->txtfont, GDcurr->location, GDcurr->justify < , GDcurr->gcwidth, GDcurr->gcheight)); --- > decode((char*)dumpkey[0], &GDcurr->GDid); > PrintCheck(fprintf(dump_fp, " %-8s %-10s %8.4f %8.4f %-4s %-25s %-10s %-10s %8.4f %8.4f\n" , dumpkey[0], GDcurr->shape, GDcurr->width, GDcurr->height, GDcurr->hsegpattern, GDcurr->txtfont, GDcurr->location, GDcurr->justify , GDcurr->gcwidth, GDcurr->gcheight)); > break; 188c227 < if (idx==2) --- > case 2: 191,193c230,232 < decode((char*)outkey[0], &HGcurr->HGid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %-12s %-12s %-12s %-60s\n" < , outkey[0], HGcurr->FSid, HGcurr->HNid, HGcurr->HGauthor, HGcurr->HGcreated, HGcurr->HGlastmod, HGcurr->HGtitle)); --- > decode((char*)dumpkey[0], &HGcurr->HGid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %-12s %-12s %-12s %-60s\n" , dumpkey[0], HGcurr->FSid, HGcurr->HNid, HGcurr->HGauthor, HGcurr->HGcreated, HGcurr->HGlastmod, HGcurr->HGtitle)); > break; 195c234 < if (idx==3) --- > case 3: 198c237 < decode((char*)outkey[0], &HNcurr->HNid); --- > decode((char*)dumpkey[0], &HNcurr->HNid); 200,203c239,241 < decode((char*)outkey[1], &HNcurr->HGid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %-1s %8.4f %8.4f %8.4f %8.4f %-25s %8.4f %8.4f %8d %8d %-20s\n" < , outkey[0], outkey[1], HNcurr->FSid, HNcurr->shape, HNcurr->centerx, HNcurr->centery, HNcurr->width, HNcurr->height, HNcurr->txtfont < , HNcurr->txtoffsetx, HNcurr->txtoffsety, HNcurr->txtwidth, HNcurr->txtheight, HNcurr->nodename)); --- > decode((char*)dumpkey[1], &HNcurr->HGid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %-1s %8.4f %8.4f %8.4f %8.4f %-25s %8.4f %8.4f %8d %8d %-20s\n" , dumpkey[0], dumpkey[1], HNcurr->FSid, HNcurr->shape, HNcurr->centerx, HNcurr->centery, HNcurr->width, HNcurr->height, HNcurr->txtfont , HNcurr->txtoffsetx, HNcurr->txtoffsety, HNcurr->txtwidth, HNcurr->txtheight, HNcurr->nodename)); > break; 205c243 < if (idx==4) --- > case 4: 208c246 < decode((char*)outkey[0], &HAcurr->HAid); --- > decode((char*)dumpkey[0], &HAcurr->HAid); 210,213c248,250 < decode((char*)outkey[1], &HAcurr->HNid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %8.4f %8.4f %8.4f %8d %8d %-25s %-60s\n" < , outkey[0], outkey[1], HAcurr->DAid, HAcurr->txtoffsetx, HAcurr->txtoffsety, HAcurr->HAorigin, HAcurr->txtwidth, HAcurr->txtheight < , HAcurr->txtfont, HAcurr->hlabel)); --- > decode((char*)dumpkey[1], &HAcurr->HNid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %8.4f %8.4f %8.4f %8d %8d %-25s %-60s\n" , dumpkey[0], dumpkey[1], HAcurr->DAid, HAcurr->txtoffsetx, HAcurr->txtoffsety, HAcurr->HAorigin, HAcurr->txtwidth, HAcurr->txtheight , HAcurr->txtfont, HAcurr->hlabel)); > break; 215,216c252,253 < if (idx==5) < { --- > case 5: > { /* decode gives SIGSEGV from dumpkey = 0x0 - RJL 040630 */ 218c255,257 < decode((char*)outkey[0], &HLcurr->HLid); --- > assert(HLcurr!=NULL); > dprintd("doDump case 5 (HL): pkey HLid = %lx\n", (int)HLcurr->HLid); > decode((char*)dumpkey[0], &HLcurr->HLid); 220c259 < decode((char*)outkey[1], &HLcurr->HNid1); --- > decode((char*)dumpkey[1], &HLcurr->HNid1); 222,224c261,263 < decode((char*)outkey[2], &HLcurr->HNid2); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %8d %8d\n" < , outkey[0], outkey[1], outkey[2], HLcurr->HPcount, HLcurr->allvisible)); --- > decode((char*)dumpkey[2], &HLcurr->HNid2); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %8d %8d\n" , dumpkey[0], dumpkey[1], dumpkey[2], HLcurr->HPcount, HLcurr->allvisible)); > break; 226c265 < if (idx==6) --- > case 6: 229c268 < decode((char*)outkey[0], &HPcurr->HPid); --- > decode((char*)dumpkey[0], &HPcurr->HPid); 231,233c270,272 < decode((char*)outkey[1], &HPcurr->HLid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %8.4f %8.4f %8d %-4s\n" < , outkey[0], outkey[1], HPcurr->HPx, HPcurr->HPy, HPcurr->is_visible, HPcurr->hsegpattern)); --- > decode((char*)dumpkey[1], &HPcurr->HLid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %8.4f %8.4f %8d %-4s\n" , dumpkey[0], dumpkey[1], HPcurr->HPx, HPcurr->HPy, HPcurr->is_visible, HPcurr->hsegpattern)); > break; 235c274 < if (idx==7) --- > case 7: 238c277 < decode((char*)outkey[0], &HIcurr->HIid); --- > decode((char*)dumpkey[0], &HIcurr->HIid); 240,243c279,281 < decode((char*)outkey[1], &HIcurr->HLid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %8.4f %8.4f %8.4f %8d %8d %-25s %-40s\n" < , outkey[0], outkey[1], HIcurr->DIid, HIcurr->HIorigin, HIcurr->tbeginx, HIcurr->tbeginy, HIcurr->txtwidth, HIcurr->txtheight < , HIcurr->txtfont, HIcurr->hlabel)); --- > decode((char*)dumpkey[1], &HIcurr->HLid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %8.4f %8.4f %8.4f %8d %8d %-25s %-40s\n" , dumpkey[0], dumpkey[1], HIcurr->DIid, HIcurr->HIorigin, HIcurr->tbeginx, HIcurr->tbeginy, HIcurr->txtwidth, HIcurr->txtheight , HIcurr->txtfont, HIcurr->hlabel)); > break; 245c283 < if (idx==8) --- > case 8: 248c286 < decode((char*)outkey[0], &CGcurr->CGid); --- > decode((char*)dumpkey[0], &CGcurr->CGid); 250,252c288,290 < decode((char*)outkey[1], &CGcurr->HGid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %8.4f %8.4f %8.4f %8.4f\n" < , outkey[0], outkey[1], CGcurr->CGcenterx, CGcurr->CGcentery, CGcurr->CGwidth, CGcurr->CGheight)); --- > decode((char*)dumpkey[1], &CGcurr->HGid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %8.4f %8.4f %8.4f %8.4f\n" , dumpkey[0], dumpkey[1], CGcurr->CGcenterx, CGcurr->CGcentery, CGcurr->CGwidth, CGcurr->CGheight)); > break; 254c292 < if (idx==9) --- > case 9: 257c295 < decode((char*)outkey[0], &GXcurr->GXid); --- > decode((char*)dumpkey[0], &GXcurr->GXid); 259,262c297,299 < decode((char*)outkey[1], &GXcurr->CGid); < PrintCheck(fprintf(hcg_dump_fp, " %-8s %-8s %-8s %8.4f %-25s %8.4f %8.4f %8d %8d %-128s\n" < , outkey[0], outkey[1], GXcurr->DAid, GXcurr->GXorigin, GXcurr->txtfont, GXcurr->txtoffsetx, GXcurr->txtoffsety, GXcurr->txtwidth < , GXcurr->txtheight, GXcurr->grphcaption)); --- > decode((char*)dumpkey[1], &GXcurr->CGid); > PrintCheck(fprintf(dump_fp, " %-8s %-8s %-8s %8.4f %-25s %8.4f %8.4f %8d %8d %-128s\n" , dumpkey[0], dumpkey[1], GXcurr->DAid, GXcurr->GXorigin, GXcurr->txtfont, GXcurr->txtoffsetx, GXcurr->txtoffsety, GXcurr->txtwidth , GXcurr->txtheight, GXcurr->grphcaption)); > break; 264,265c301 < if (open_file==1) < fclose(hcg_dump_fp); --- > default: assert(0); 266a303,305 > //Do NOT close this file! > return; > } /* end pr_dump_row */ 1:0a1 3:6c7,17 17:15a27,30 22:17,20c32 29:22,23c34,42 42:31a51,57 50:33,36d58 55:39c61,62 60:50c73 64:68c91,94 71:76c102 75:83,84c109 80:91,92c116 85:100c124 89:107,108c131 94:116c139 98:124c147 102:132c155 106:140c163 110:145,150c168,181 132:151a183 134:152a185 136:154,157c187,190 146:160c193,194 151:162c196,203 162:165,173c206,213 181:176,178c216,218 189:180c220 193:183,186c223,225 202:188c227 206:191,193c230,232 214:195c234 218:198c237 222:200,203c239,241 231:205c243 235:208c246 239:210,213c248,250 248:215,216c252,253 254:218c255,257 260:220c259 264:222,224c261,263 272:226c265 276:229c268 280:231,233c270,272 288:235c274 292:238c277 296:240,243c279,281 305:245c283 309:248c286 313:250,252c288,290 321:254c292 325:257c295 329:259,262c297,299 338:264,265c301 343:266a303,305