/* dprintf.c - functions to provide printf under DEBUG control. */ /* using zero, one or two int or char* args */ /****************************************************************/ /* * $Log: dprint.c,v $ * Revision 1.5 2006/09/09 01:46:39 lechner * Replaced #ifdef DEBUG with #if DPRNT. * Added conditions in print_rcounts() to detect the two bde viewnames * "94sbdedefaultsView" and " 94sbdeview", print their respective tables, * and ignore others. [So far, dprint.c is identical as checked in * under pr_util_log and pr_util_nolog/.] * * Revision 1.4 2006/08/08 03:35:23 lechner * Func printrowcounts() moved here from src/fileio,.cc - RJL060807 * * Revision 1.3 2006/02/05 03:40:46 lechner * Corrected one return expression. * * Revision 1.2 2005/12/10 03:53:09 lechner * #included "dprint.h, and * and a new test function ' int isComment(char* tmpstr)' * (used in pr_load to ignore a line beginning with '/' followed by '/' or '*') * * Revision 1.1 2005/10/27 03:28:08 lechner * Added dprint.c to provide #ifdef DEBUG control over printouts. * Now in both bde/pr_util_[no]log directories. TBD: Move them to bde. * * Revision 1.2 2005/05/03 06:49:19 lechner * Added printf functions dprint*() with #ifdef DPRNT conditioni bracketss. * bde/pr_util/dprint.c requires bde/dprint.h; both are constant, not from chgen. * * Revision 1.1.2.5 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.4 2004/11/29 20:10:19 lechner * Added $Log line to insert cvs rev comments in pr_*.c and *schema.h. * ****************************************************************/ /* Log aded 041129 - RJL */ /* RJL 040602: these don't seem to get executed with -DDEBUG??? */ /* RJL 040602: all could be subcases of a polymorphic method */ #define DPRNT 1 #include "94sbde_schema.h" // #includes "dprint.h" #include #include int isComment(char* tmpstr) /* in bde, used for gcc in pr_util and g++ in src */ {/* returns 0 unless first two chars of tmpstr are "/_/" or "/_*" * Used in pr_load and apps to ignore a line beginning with either one. */ return((strncmp(tmpstr, "/*", 2) !=0 && strncmp(tmpstr, "//", 2)!= 0)?0:1); } void dprint(const char* fmt) { #if DPRNT printf(fmt); #endif } void dprintd(const char* fmt, const int i) { #if DPRNT printf(fmt, i); #endif } void dprints(const char* fmt, const char* s) { #if DPRNT printf(fmt, s); #endif } void dprintdd(const char* fmt, const int i, const int j) { #if DPRNT printf(fmt, i, j); #endif } void dprintds(const char* fmt, const int i, const char* s) { #if DPRNT printf(fmt, i, s); #endif } void dprintsd(const char* fmt, const char* s, const int j) { #if DPRNT printf(fmt, s, j); #endif } void dprintss(const char* fmt, const char* s, const char* t) { #if DPRNT printf(fmt, s, t); #endif } /* printrowcounts() - moved from src/fileio,.cc to dprint.c- RJL060807 */ /**********************************************************t* * #if DPRNT, prints row-counts for each table in bde's view: - RJL06016 * For eempty tables or tables not in the view, prints 0. * Client: real_load, line 1838 below, and pr_init() in pr_load.c. * Pre-cond: view contains at least these 10 tables. * (A loop would require laborious conversion of case# to tblabbr ) ********************************************************** */ /* Clients (060805): CreateHGDialogBox and real_load, in fileio.cc. * and pr_init() in pr_load.c * CLient of: find_view_idx(viewname) (via get_rcount macro) * Uses hcg_view_idx from find_view_idx, hcg_table_idx from find_tbl_idx; * get_rcount calls find_tbl_idx to update hcg_tbl_idx.(On FAIL, it returns 0) * E.g.: in get_rcount: ((find_view_idx(viewname)&&find_tbl_idx(#tbl)) ? *******************************************************************/ /* Pre-cond'ns: */ void printrowcounts(const char* viewname) /*:831-855:)*/ {EP; /* depends on hcg_structs, not on non-empty table lists at XX* XX)*/ #if DPRNT /* get_rcount calls find_tbl_idx to update hcg_tbl_idx - RJL060808 */ if (strcmp(viewname, "94sbdeview")== 0) { dprint("\tTable:\tRows: in view 94sbdeview\n"); dprintsd("\t%s:\t%d\n", "HG", get_rcount("94sbdeview", HG)); dprintsd("\t%s:\t%d\n", "HN", get_rcount("94sbdeview", HN)); dprintsd("\t%s:\t%d\n", "HA", get_rcount("94sbdeview", HA)); dprintsd("\t%s:\t%d\n", "HL", get_rcount("94sbdeview", HL)); dprintsd("\t%s:\t%d\n", "HP", get_rcount("94sbdeview", HP)); dprintsd("\t%s:\t%d\n", "HI", get_rcount("94sbdeview", HI)); dprintsd("\t%s:\t%d\n", "CG", get_rcount("94sbdeview", CG)); dprintsd("\t%s:\t%d\n", "GX", get_rcount("94sbdeview", GX)); } else if (strcmp(viewname, "94sbdedefaultsView")== 0) { dprint("\tTable:\tRows: in view 94sbdedefaultsView\n"); dprintsd("\t%s:\t%d\n", "FO", get_rcount("94sbdedefaultsView", FO)); dprintsd("\t%s:\t%d\n", "GD", get_rcount("94sbdedefaultsView", GD)); } else { DP; dprints("viewname %s is not 94sbde{v,defaultsV}iew; ignored.\n", viewname); } #endif LP;} // end printrowcounts (:831-855:)