# HG changeset patch # User Carl Byington # Date 1441991883 25200 # Node ID 7a91e30826d81f735b25e4f0559caf0061e5f021 # Parent a57c15b3108ab381f4d3c150f3d4780d6d602c93 Hans Liss - debug level output diff -r a57c15b3108a -r 7a91e30826d8 AUTHORS --- a/AUTHORS Fri Sep 11 09:46:12 2015 -0700 +++ b/AUTHORS Fri Sep 11 10:18:03 2015 -0700 @@ -38,6 +38,8 @@ Dominique Leuenberger a.k.a. Dimstar Daniel Gryniewicz AJ Shankar + Jeffrey Morlan + Hans Liss Testing team: Mac OSX - Michael Watson diff -r a57c15b3108a -r 7a91e30826d8 ChangeLog --- a/ChangeLog Fri Sep 11 09:46:12 2015 -0700 +++ b/ChangeLog Fri Sep 11 10:18:03 2015 -0700 @@ -1,3 +1,8 @@ +LibPST 0.6.65 (2015-09-11) +=============================== + * Jeffrey Morlan - fix multiple Content-Type headers + * Hans Liss - debug level output + LibPST 0.6.64 (2015-03-09) =============================== * AJ Shankar fixes for attachment processing and body diff -r a57c15b3108a -r 7a91e30826d8 NEWS --- a/NEWS Fri Sep 11 09:46:12 2015 -0700 +++ b/NEWS Fri Sep 11 10:18:03 2015 -0700 @@ -1,3 +1,4 @@ +0.6.65 2015-09-11 Jeffrey Morlan - fix multiple Content-Type headers; Hans Liss - debug level output 0.6.64 2015-03-09 AJ Shankar fixes for attachment processing and body encodings that contain embedded null chars 0.6.63 2013-12-27 Daniel Gryniewicz found buffer overrun in LIST_COPY_TIME 0.6.62 2013-09-22 983596 - Old dependency filter breaks file coloring diff -r a57c15b3108a -r 7a91e30826d8 configure.in --- a/configure.in Fri Sep 11 09:46:12 2015 -0700 +++ b/configure.in Fri Sep 11 10:18:03 2015 -0700 @@ -1,5 +1,5 @@ AC_PREREQ(2.60) -AC_INIT(libpst,0.6.64,carl@five-ten-sg.com) +AC_INIT(libpst,0.6.65,carl@five-ten-sg.com) AC_CONFIG_SRCDIR([src/libpst.c]) AC_CONFIG_HEADER([config.h]) AC_CONFIG_MACRO_DIR([m4]) diff -r a57c15b3108a -r 7a91e30826d8 libpst.spec.in --- a/libpst.spec.in Fri Sep 11 09:46:12 2015 -0700 +++ b/libpst.spec.in Fri Sep 11 10:18:03 2015 -0700 @@ -162,6 +162,7 @@ %changelog * Fri Sep 11 2015 Carl Byington 0.6.65-1 - Jeffrey Morlan - fix multiple Content-Type headers +- Hans Liss - debug level output * Thu Aug 27 2015 Jonathan Wakely - 0.6.64-6 - Rebuilt for Boost 1.59 diff -r a57c15b3108a -r 7a91e30826d8 src/debug.c --- a/src/debug.c Fri Sep 11 09:46:12 2015 -0700 +++ b/src/debug.c Fri Sep 11 10:18:03 2015 -0700 @@ -12,6 +12,7 @@ static struct pst_debug_func *func_head = NULL; static int func_depth = 0; +static int pst_debuglevel = 0; static char indent[MAX_DEPTH*4+1]; static FILE *debug_fp = NULL; #ifdef HAVE_SEMAPHORE_H @@ -19,6 +20,11 @@ #endif +void pst_debug_setlevel(int level) +{ + pst_debuglevel = level; +} + void pst_debug_lock() { #ifdef HAVE_SEMAPHORE_H @@ -50,7 +56,8 @@ } -void pst_debug_func(const char* function) { +void pst_debug_func(int level, const char* function) { + if (pst_debuglevel > level) return; struct pst_debug_func *func_ptr = pst_malloc (sizeof(struct pst_debug_func)); func_ptr->name = strdup(function); func_ptr->next = func_head; @@ -59,7 +66,8 @@ } -void pst_debug_func_ret() { +void pst_debug_func_ret(int level) { + if (pst_debuglevel > level) return; //remove the head item struct pst_debug_func *func_ptr = func_head; if (func_head) { @@ -73,8 +81,9 @@ } -static void pst_debug_info(int line, const char* file); -static void pst_debug_info(int line, const char* file) { +static void pst_debug_info(int level, int line, const char* file); +static void pst_debug_info(int level, int line, const char* file) { + if (pst_debuglevel > level) return; int le = (func_depth > MAX_DEPTH) ? MAX_DEPTH : func_depth; if (le > 0) le--; char *func = (func_head ? func_head->name : "No Function"); @@ -83,23 +92,25 @@ } -void pst_debug(int line, const char* file, const char *fmt, ...) { +void pst_debug(int level, int line, const char* file, const char *fmt, ...) { + if (pst_debuglevel > level) return; if (debug_fp) { - pst_debug_info(line, file); - va_list ap; - va_start(ap,fmt); - vfprintf(debug_fp, fmt, ap); - va_end(ap); - fflush(debug_fp); + pst_debug_info(level, line, file); + va_list ap; + va_start(ap,fmt); + vfprintf(debug_fp, fmt, ap); + va_end(ap); + fflush(debug_fp); pst_debug_unlock(); } } -void pst_debug_hexdump(int line, const char *file, const char *buf, size_t size, int cols, int delta) { +void pst_debug_hexdump(int level, int line, const char *file, const char *buf, size_t size, int cols, int delta) { + if (pst_debuglevel > level) return; if (debug_fp) { - pst_debug_info(line, file); - pst_debug_hexdumper(debug_fp, buf, size, cols, delta); + pst_debug_info(level, line, file); + pst_debug_hexdumper(debug_fp, buf, size, cols, delta); pst_debug_unlock(); } } diff -r a57c15b3108a -r 7a91e30826d8 src/define.h --- a/src/define.h Fri Sep 11 09:46:12 2015 -0700 +++ b/src/define.h Fri Sep 11 10:18:03 2015 -0700 @@ -135,20 +135,23 @@ void pst_debug_lock(); void pst_debug_unlock(); +void pst_debug_setlevel(int level); void pst_debug_init(const char* fname, void* output_mutex); -void pst_debug_func(const char* function); -void pst_debug_func_ret(); -void pst_debug(int line, const char *file, const char *fmt, ...); -void pst_debug_hexdump(int line, const char *file, const char* buf, size_t size, int cols, int delta); +void pst_debug_func(int level, const char* function); +void pst_debug_func_ret(int level); +void pst_debug(int level, int line, const char *file, const char *fmt, ...); +void pst_debug_hexdump(int level, int line, const char *file, const char* buf, size_t size, int cols, int delta); void pst_debug_hexdumper(FILE* out, const char* buf, size_t size, int cols, int delta); -void pst_debug_close(void); +void pst_debug_close(); void* pst_malloc(size_t size); void *pst_realloc(void *ptr, size_t size); -#define MESSAGEPRINT(...) pst_debug(__LINE__, __FILE__, __VA_ARGS__) +#define MESSAGEPRINT1(...) pst_debug(1, __LINE__, __FILE__, __VA_ARGS__) +#define MESSAGEPRINT2(...) pst_debug(2, __LINE__, __FILE__, __VA_ARGS__) +#define MESSAGEPRINT3(...) pst_debug(3, __LINE__, __FILE__, __VA_ARGS__) #define WARN(x) { \ - MESSAGEPRINT x; \ + MESSAGEPRINT3 x; \ pst_debug_lock(); \ printf x; \ fflush(stdout); \ @@ -160,21 +163,21 @@ exit(EXIT_FAILURE); \ } -#define DEBUG_WARN(x) MESSAGEPRINT x -#define DEBUG_INFO(x) MESSAGEPRINT x -#define DEBUG_HEXDUMP(x, s) pst_debug_hexdump(__LINE__, __FILE__, (char*)x, s, 0x10, 0) -#define DEBUG_HEXDUMPC(x, s, c) pst_debug_hexdump(__LINE__, __FILE__, (char*)x, s, c, 0) +#define DEBUG_WARN(x) MESSAGEPRINT3 x +#define DEBUG_INFO(x) MESSAGEPRINT2 x +#define DEBUG_HEXDUMP(x, s) pst_debug_hexdump(1, __LINE__, __FILE__, (char*)x, s, 0x10, 0) +#define DEBUG_HEXDUMPC(x, s, c) pst_debug_hexdump(1, __LINE__, __FILE__, (char*)x, s, c, 0) #define DEBUG_ENT(x) \ { \ - pst_debug_func(x); \ - pst_debug(__LINE__, __FILE__, "Entering function\n"); \ + pst_debug_func(1, x); \ + pst_debug(1, __LINE__, __FILE__, "Entering function\n"); \ } #define DEBUG_RET() \ { \ - pst_debug(__LINE__, __FILE__, "Leaving function\n"); \ - pst_debug_func_ret(); \ + pst_debug(1, __LINE__, __FILE__, "Leaving function\n"); \ + pst_debug_func_ret(1); \ } #define DEBUG_INIT(fname,mutex) {pst_debug_init(fname,mutex);} diff -r a57c15b3108a -r 7a91e30826d8 src/readpst.c --- a/src/readpst.c Fri Sep 11 09:46:12 2015 -0700 +++ b/src/readpst.c Fri Sep 11 10:18:03 2015 -0700 @@ -420,11 +420,11 @@ } else if (item->message_store) { // there should only be one message_store, and we have already done it ff.skip_count++; - DEBUG_INFO(("item with message store content, type %i %s folder type %i, skipping it\n", item->type, item->ascii_type, ff.type)); + DEBUG_WARN(("item with message store content, type %i %s folder type %i, skipping it\n", item->type, item->ascii_type, ff.type)); } else { ff.skip_count++; - DEBUG_INFO(("Unknown item type %i (%s) name (%s)\n", + DEBUG_WARN(("Unknown item type %i (%s) name (%s)\n", item->type, item->ascii_type, item->file_as.str)); } pst_freeItem(item); @@ -453,7 +453,7 @@ } // command-line option handling - while ((c = getopt(argc, argv, "a:bC:c:Dd:emhj:kMo:qrSt:uVw8"))!= -1) { + while ((c = getopt(argc, argv, "a:bC:c:Dd:emhj:kMo:qrSt:uVwL:8"))!= -1) { switch (c) { case 'a': if (optarg) { @@ -524,6 +524,9 @@ mode_MSG = 0; file_name_len = 14; break; + case 'L': + pst_debug_setlevel(atoi(optarg)); + break; case 'm': mode = MODE_SEPARATE; mode_MH = 1; @@ -745,6 +748,7 @@ printf("\t-V\t- Version. Display program version\n"); printf("\t-C charset\t- character set for items with an unspecified character set\n"); printf("\t-D\t- Include deleted items in output\n"); + printf("\t-L \t- Set debug level; 1=debug,2=info,3=warn.\n"); printf("\t-M\t- Write emails in the MH (rfc822) format\n"); printf("\t-S\t- Separate. Write emails in the separate format\n"); printf("\t-a \t- Discard any attachment without an extension on the list\n");