7b4bb371da6813455b4b5a53906d5cd59457240b tdreszer Fri Aug 3 16:40:44 2012 -0700 By redefining printf, puts and putc in the header file and including that header in select c files, hgTrackUi can decide to add a box around the cfg dialog after it is written. This is useful since it is not clear whether a cfg will be written until it is tried. Openning the box beforehand can leave an empty box. This minor check-in does not include changes to any cgis, only the ability to do so. diff --git src/inc/dsPrint.h src/inc/dsPrint.h index 90e6ce3..08f458d 100644 --- src/inc/dsPrint.h +++ src/inc/dsPrint.h @@ -9,32 +9,39 @@ // Output goes to STDOUT unless a single alternative out file is registered. #ifndef DSPRINT_H /* Wrapper to avoid including this twice. */ #define DSPRINT_H #include "common.h" #include "dystring.h" int dsPrintOpen(int initialBufSize); // Allocate dynamic string and puts at top of stack // returns token to be used for later stack accounting asserts int dsPrintf(char *format, ...); // Prints into end of the top ds buffer, and return resulting string length // If there is no current buffer, this acts like a simple printf and returns -1 -#define dsPrintPuts(str) dsPrintf("%s\n",str) -#define dsPrintPutc(chr) dsPrintf("%c",chr) +#define dsPuts(str) dsPrintf("%s\n",str) +#define dsPutc(chr) dsPrintf("%c",chr) +#define SWAP_PRINTF +#ifdef SWAP_PRINTF +#define printf dsPrintf +#define puts dsPuts +#undef putc +#define putc dsPutc +#endif//def SWAP_PRINTF int dsPrintDirectly(int token,FILE *file); // Prints the contents of the top buffer directly to a file. // Will leave the filled buffer at top of stack // Returns the length printed. int dsPrintFlush(int token); // Flushes the top buffer to the next lower one and empties top buffer. // If there is no lower buffer then the content is printed to STDOUT (or registered out). // Returns the length flushed. int dsPrintClose(int token); // Abandons the top buffer and its content, freeing memory. // Returns the length abandoned. #define dsPrintAbandon(token) dsPrintClose(token) @@ -77,24 +84,25 @@ int dsPrintFlushAndCloseAll(); // flushes, frees and closes all stacked buffers // returns length flushed char *dsPrintCannibalizeAndClose(int token); // Closes the top stack buffer returning content. Returned string should be freed. char *dsPrintCannibalizeAndCloseAll(); // Closes all stack buffers and returns a single string that is the full content. // Returned string should be freed. //void dsPrintTest(); // Tests of dsPrint functions /* Next steps: - * 1) in cheapCgi.c replace all printfs with dsPrintf - * 2) in hui.c replace all printfs with dsPrintf - * 3) in hgTrackUi replace all printfs with dsPrintf - * 4) After 1-3, add opens and closes to hgTrackUi - * 5) Handle isConfigurable tests with dsPrintf and throw away results - * 5) Handle boxing cfg with dsPrintf + * 1) DONE WITH MACROS: in cheapCgi.c replace all printfs with dsPrintf + * 2) DONE WITH MACROS: in hui.c replace all printfs with dsPrintf + * 3) DONE WITH MACROS: in hgTrackUi replace all printfs with dsPrintf + * 4) DONE: After 1-3, add opens and closes to hgTrackUi + * 5) DONE: Handle boxing cfg with dsPrintf (note existing cfgs that support boxing still do it) + * 6) Handle isConfigurable tests with dsPrintf and throw away results + * This one will require making hgTrackUi Cfgs all lib code. */ #endif /* DSPRINT_H */