%% options copyright owner = Dirk Krause copyright year = 2011-2014 license = bsd %% header #include "dk3all.h" /* ifndef DK_INC */ #include #if defined(__cplusplus) extern "C" { #endif /** Close trace output file. */ void dktrace_end(void); /** Start tracing. @param filename File name to write trace output or NULL to use standard output. */ void dktrace_init(char const *filename); /** Get trace file. @return Pointer to open file used for tracing. */ FILE * dktrace_file(void); /** Close trace output file. */ void dk_trace_end(void); /** Start tracing. @param filename File name to write trace output or NULL to use standard output. */ void dk_trace_init(char const *filename); /** Get trace file. @return Pointer to open file used for tracing. */ FILE * dk_trace_file(void); /** Write time to trace output. */ void dktrace_time(void); /** Write time to trace output. */ void dk_trace_time(void); /** Write time to standard output. */ void dktrace_stdout_time(void); #if defined(__cplusplus) } #endif /* ifdef __cplusplus */ /** Show string. */ #define TR_STR(x) ((x) ? (x) : "(NULL)") /** Show pointer. */ #define TR_PTR(x) ((x) ? "PTR" : "(NULL)") %% module #include "dk3all.h" #include "dktr.h" #include "dkt-version.h" $(trace-include) /** Application group name. */ static dkChar const dktrace_group_name[] = { dkT("dkt-3") }; /** String table file name. */ static dkChar const dktrace_stfn[] = { dkT("dk3trace.str") }; /** Localized messages used by the program. */ static dkChar const * const dktrace_msgs[] = { /* 0 */ dkT("ERROR: Not enough memory!\n"), NULL }; /** The main function. @param argc Number of command line arguments. @param argv Command line arguments array. @return 0 on success, positive values on error. */ DK3_MAIN { dk3_app_t *app = NULL; /* Application. */ dkChar const * const *msg = NULL; /* Localized messages. */ $(trace-init dktrace.deb) app = dk3app_open_command( argc, (dkChar const * const *)argv, dktrace_group_name ); if(app) { msg = dk3app_messages(app, dktrace_stfn, (dkChar const **)dktrace_msgs); dk3app_close(app); app = NULL; } else { if(!dk3app_first_silence_check(NULL, argc, argv)) { dk3sf_initialize_stderr(); dk3sf_fputs(dktrace_msgs[0], stderr); fflush(stderr); } } $(trace-end) fflush(stdout); exit(exval); return exval; } /* vim: set ai sw=2 : */