| 36 | bool pdc_trace_on = FALSE; |
| 37 | |
| 38 | void PDC_debug(const char *fmt, ...) |
| 39 | { |
| 40 | va_list args; |
| 41 | FILE *dbfp; |
| 42 | char hms[9]; |
| 43 | time_t now; |
| 44 | |
| 45 | if (!pdc_trace_on) |
| 46 | return; |
| 47 | |
| 48 | /* open debug log file append */ |
| 49 | |
| 50 | dbfp = fopen("trace", "a"); |
| 51 | if (!dbfp) |
| 52 | { |
| 53 | fprintf(stderr, |
| 54 | "PDC_debug(): Unable to open debug log file\n"); |
| 55 | return; |
| 56 | } |
| 57 | |
| 58 | time(&now); |
| 59 | strftime(hms, 9, "%H:%M:%S", localtime(&now)); |
| 60 | fprintf(dbfp, "At: %8.8ld - %s ", (long) clock(), hms); |
| 61 | |
| 62 | va_start(args, fmt); |
| 63 | vfprintf(dbfp, fmt, args); |
| 64 | va_end(args); |
| 65 | |
| 66 | fclose(dbfp); |
| 67 | } |
| 68 | |
| 69 | void traceon(void) |
| 70 | { |