libpst

changeset 350:7a91e30826d8 stable-0-6-65

Hans Liss - debug level output
author Carl Byington <carl@five-ten-sg.com>
date Fri, 11 Sep 2015 10:18:03 -0700
parents a57c15b3108a
children 602869b958a3
files AUTHORS ChangeLog NEWS configure.in libpst.spec.in src/debug.c src/define.h src/readpst.c
diffstat 8 files changed, 60 insertions(+), 33 deletions(-) [+]
line diff
     1.1 --- a/AUTHORS	Fri Sep 11 09:46:12 2015 -0700
     1.2 +++ b/AUTHORS	Fri Sep 11 10:18:03 2015 -0700
     1.3 @@ -38,6 +38,8 @@
     1.4      Dominique Leuenberger a.k.a. Dimstar <dimstar@opensuse.org>
     1.5      Daniel Gryniewicz <dang@linuxbox.com>
     1.6      AJ Shankar <aj@everlaw.com>
     1.7 +    Jeffrey Morlan <jeffrey@everlaw.com>
     1.8 +    Hans Liss <Hans@Liss.pp.se>
     1.9  
    1.10  Testing team:
    1.11      Mac OSX - Michael Watson <mike@mikeandgayle.com>
     2.1 --- a/ChangeLog	Fri Sep 11 09:46:12 2015 -0700
     2.2 +++ b/ChangeLog	Fri Sep 11 10:18:03 2015 -0700
     2.3 @@ -1,3 +1,8 @@
     2.4 +LibPST 0.6.65 (2015-09-11)
     2.5 +===============================
     2.6 +    * Jeffrey Morlan - fix multiple Content-Type headers
     2.7 +    * Hans Liss - debug level output
     2.8 +
     2.9  LibPST 0.6.64 (2015-03-09)
    2.10  ===============================
    2.11      * AJ Shankar fixes for attachment processing and body
     3.1 --- a/NEWS	Fri Sep 11 09:46:12 2015 -0700
     3.2 +++ b/NEWS	Fri Sep 11 10:18:03 2015 -0700
     3.3 @@ -1,3 +1,4 @@
     3.4 +0.6.65  2015-09-11 Jeffrey Morlan - fix multiple Content-Type headers; Hans Liss - debug level output
     3.5  0.6.64  2015-03-09 AJ Shankar fixes for attachment processing and body encodings that contain embedded null chars
     3.6  0.6.63  2013-12-27 Daniel Gryniewicz found buffer overrun in LIST_COPY_TIME
     3.7  0.6.62  2013-09-22 983596 - Old dependency filter breaks file coloring
     4.1 --- a/configure.in	Fri Sep 11 09:46:12 2015 -0700
     4.2 +++ b/configure.in	Fri Sep 11 10:18:03 2015 -0700
     4.3 @@ -1,5 +1,5 @@
     4.4  AC_PREREQ(2.60)
     4.5 -AC_INIT(libpst,0.6.64,carl@five-ten-sg.com)
     4.6 +AC_INIT(libpst,0.6.65,carl@five-ten-sg.com)
     4.7  AC_CONFIG_SRCDIR([src/libpst.c])
     4.8  AC_CONFIG_HEADER([config.h])
     4.9  AC_CONFIG_MACRO_DIR([m4])
     5.1 --- a/libpst.spec.in	Fri Sep 11 09:46:12 2015 -0700
     5.2 +++ b/libpst.spec.in	Fri Sep 11 10:18:03 2015 -0700
     5.3 @@ -162,6 +162,7 @@
     5.4  %changelog
     5.5  * Fri Sep 11 2015 Carl Byington <carl@five-ten-sg.com> 0.6.65-1
     5.6  - Jeffrey Morlan - fix multiple Content-Type headers
     5.7 +- Hans Liss - debug level output
     5.8  
     5.9  * Thu Aug 27 2015 Jonathan Wakely <jwakely@redhat.com> - 0.6.64-6
    5.10  - Rebuilt for Boost 1.59
     6.1 --- a/src/debug.c	Fri Sep 11 09:46:12 2015 -0700
     6.2 +++ b/src/debug.c	Fri Sep 11 10:18:03 2015 -0700
     6.3 @@ -12,6 +12,7 @@
     6.4  
     6.5  static struct pst_debug_func *func_head = NULL;
     6.6  static int func_depth = 0;
     6.7 +static int pst_debuglevel = 0;
     6.8  static char indent[MAX_DEPTH*4+1];
     6.9  static FILE *debug_fp = NULL;
    6.10  #ifdef HAVE_SEMAPHORE_H
    6.11 @@ -19,6 +20,11 @@
    6.12  #endif
    6.13  
    6.14  
    6.15 +void pst_debug_setlevel(int level)
    6.16 +{
    6.17 +  pst_debuglevel = level;
    6.18 +}
    6.19 +
    6.20  void pst_debug_lock()
    6.21  {
    6.22      #ifdef HAVE_SEMAPHORE_H
    6.23 @@ -50,7 +56,8 @@
    6.24  }
    6.25  
    6.26  
    6.27 -void pst_debug_func(const char* function) {
    6.28 +void pst_debug_func(int level, const char* function) {
    6.29 +    if (pst_debuglevel > level) return;
    6.30      struct pst_debug_func *func_ptr = pst_malloc (sizeof(struct pst_debug_func));
    6.31      func_ptr->name = strdup(function);
    6.32      func_ptr->next = func_head;
    6.33 @@ -59,7 +66,8 @@
    6.34  }
    6.35  
    6.36  
    6.37 -void pst_debug_func_ret() {
    6.38 +void pst_debug_func_ret(int level) {
    6.39 +    if (pst_debuglevel > level) return;
    6.40      //remove the head item
    6.41      struct pst_debug_func *func_ptr = func_head;
    6.42      if (func_head) {
    6.43 @@ -73,8 +81,9 @@
    6.44  }
    6.45  
    6.46  
    6.47 -static void pst_debug_info(int line, const char* file);
    6.48 -static void pst_debug_info(int line, const char* file) {
    6.49 +static void pst_debug_info(int level, int line, const char* file);
    6.50 +static void pst_debug_info(int level, int line, const char* file) {
    6.51 +    if (pst_debuglevel > level) return;
    6.52      int le = (func_depth > MAX_DEPTH) ? MAX_DEPTH : func_depth;
    6.53      if (le > 0) le--;
    6.54      char *func = (func_head ? func_head->name : "No Function");
    6.55 @@ -83,23 +92,25 @@
    6.56  }
    6.57  
    6.58  
    6.59 -void pst_debug(int line, const char* file, const char *fmt, ...) {
    6.60 +void pst_debug(int level, int line, const char* file, const char *fmt, ...) {
    6.61 +    if (pst_debuglevel > level) return;
    6.62      if (debug_fp) {
    6.63 -        pst_debug_info(line, file);
    6.64 -            va_list ap;
    6.65 -            va_start(ap,fmt);
    6.66 -            vfprintf(debug_fp, fmt, ap);
    6.67 -            va_end(ap);
    6.68 -            fflush(debug_fp);
    6.69 +        pst_debug_info(level, line, file);
    6.70 +        va_list ap;
    6.71 +        va_start(ap,fmt);
    6.72 +        vfprintf(debug_fp, fmt, ap);
    6.73 +        va_end(ap);
    6.74 +        fflush(debug_fp);
    6.75          pst_debug_unlock();
    6.76      }
    6.77  }
    6.78  
    6.79  
    6.80 -void pst_debug_hexdump(int line, const char *file, const char *buf, size_t size, int cols, int delta) {
    6.81 +void pst_debug_hexdump(int level, int line, const char *file, const char *buf, size_t size, int cols, int delta) {
    6.82 +    if (pst_debuglevel > level) return;
    6.83      if (debug_fp) {
    6.84 -        pst_debug_info(line, file);
    6.85 -           pst_debug_hexdumper(debug_fp, buf, size, cols, delta);
    6.86 +        pst_debug_info(level, line, file);
    6.87 +        pst_debug_hexdumper(debug_fp, buf, size, cols, delta);
    6.88          pst_debug_unlock();
    6.89      }
    6.90  }
     7.1 --- a/src/define.h	Fri Sep 11 09:46:12 2015 -0700
     7.2 +++ b/src/define.h	Fri Sep 11 10:18:03 2015 -0700
     7.3 @@ -135,20 +135,23 @@
     7.4  
     7.5  void  pst_debug_lock();
     7.6  void  pst_debug_unlock();
     7.7 +void  pst_debug_setlevel(int level);
     7.8  void  pst_debug_init(const char* fname, void* output_mutex);
     7.9 -void  pst_debug_func(const char* function);
    7.10 -void  pst_debug_func_ret();
    7.11 -void  pst_debug(int line, const char *file, const char *fmt, ...);
    7.12 -void  pst_debug_hexdump(int line, const char *file, const char* buf, size_t size, int cols, int delta);
    7.13 +void  pst_debug_func(int level, const char* function);
    7.14 +void  pst_debug_func_ret(int level);
    7.15 +void  pst_debug(int level, int line, const char *file, const char *fmt, ...);
    7.16 +void  pst_debug_hexdump(int level, int line, const char *file, const char* buf, size_t size, int cols, int delta);
    7.17  void  pst_debug_hexdumper(FILE* out, const char* buf, size_t size, int cols, int delta);
    7.18 -void  pst_debug_close(void);
    7.19 +void  pst_debug_close();
    7.20  void* pst_malloc(size_t size);
    7.21  void *pst_realloc(void *ptr, size_t size);
    7.22  
    7.23 -#define MESSAGEPRINT(...) pst_debug(__LINE__, __FILE__,  __VA_ARGS__)
    7.24 +#define MESSAGEPRINT1(...) pst_debug(1, __LINE__, __FILE__,  __VA_ARGS__)
    7.25 +#define MESSAGEPRINT2(...) pst_debug(2, __LINE__, __FILE__,  __VA_ARGS__)
    7.26 +#define MESSAGEPRINT3(...) pst_debug(3, __LINE__, __FILE__,  __VA_ARGS__)
    7.27  
    7.28  #define WARN(x) {           \
    7.29 -    MESSAGEPRINT x;         \
    7.30 +    MESSAGEPRINT3 x;	    \
    7.31      pst_debug_lock();       \
    7.32          printf x;           \
    7.33          fflush(stdout);     \
    7.34 @@ -160,21 +163,21 @@
    7.35      exit(EXIT_FAILURE);     \
    7.36  }
    7.37  
    7.38 -#define DEBUG_WARN(x)           MESSAGEPRINT x
    7.39 -#define DEBUG_INFO(x)           MESSAGEPRINT x
    7.40 -#define DEBUG_HEXDUMP(x, s)     pst_debug_hexdump(__LINE__, __FILE__, (char*)x, s, 0x10, 0)
    7.41 -#define DEBUG_HEXDUMPC(x, s, c) pst_debug_hexdump(__LINE__, __FILE__, (char*)x, s, c, 0)
    7.42 +#define DEBUG_WARN(x)           MESSAGEPRINT3 x
    7.43 +#define DEBUG_INFO(x)           MESSAGEPRINT2 x
    7.44 +#define DEBUG_HEXDUMP(x, s)     pst_debug_hexdump(1, __LINE__, __FILE__, (char*)x, s, 0x10, 0)
    7.45 +#define DEBUG_HEXDUMPC(x, s, c) pst_debug_hexdump(1, __LINE__, __FILE__, (char*)x, s, c, 0)
    7.46  
    7.47  
    7.48  #define DEBUG_ENT(x)                                            \
    7.49      {                                                           \
    7.50 -        pst_debug_func(x);                                      \
    7.51 -        pst_debug(__LINE__, __FILE__, "Entering function\n");   \
    7.52 +      pst_debug_func(1, x);                                      \
    7.53 +      pst_debug(1, __LINE__, __FILE__, "Entering function\n");	 \
    7.54      }
    7.55  #define DEBUG_RET()                                             \
    7.56      {                                                           \
    7.57 -        pst_debug(__LINE__, __FILE__, "Leaving function\n");    \
    7.58 -        pst_debug_func_ret();                                   \
    7.59 +      pst_debug(1, __LINE__, __FILE__, "Leaving function\n");    \
    7.60 +      pst_debug_func_ret(1);					 \
    7.61      }
    7.62  
    7.63  #define DEBUG_INIT(fname,mutex) {pst_debug_init(fname,mutex);}
     8.1 --- a/src/readpst.c	Fri Sep 11 09:46:12 2015 -0700
     8.2 +++ b/src/readpst.c	Fri Sep 11 10:18:03 2015 -0700
     8.3 @@ -420,11 +420,11 @@
     8.4          } else if (item->message_store) {
     8.5              // there should only be one message_store, and we have already done it
     8.6              ff.skip_count++;
     8.7 -            DEBUG_INFO(("item with message store content, type %i %s folder type %i, skipping it\n", item->type, item->ascii_type, ff.type));
     8.8 +            DEBUG_WARN(("item with message store content, type %i %s folder type %i, skipping it\n", item->type, item->ascii_type, ff.type));
     8.9  
    8.10          } else {
    8.11              ff.skip_count++;
    8.12 -            DEBUG_INFO(("Unknown item type %i (%s) name (%s)\n",
    8.13 +            DEBUG_WARN(("Unknown item type %i (%s) name (%s)\n",
    8.14                          item->type, item->ascii_type, item->file_as.str));
    8.15          }
    8.16          pst_freeItem(item);
    8.17 @@ -453,7 +453,7 @@
    8.18      }
    8.19  
    8.20      // command-line option handling
    8.21 -    while ((c = getopt(argc, argv, "a:bC:c:Dd:emhj:kMo:qrSt:uVw8"))!= -1) {
    8.22 +    while ((c = getopt(argc, argv, "a:bC:c:Dd:emhj:kMo:qrSt:uVwL:8"))!= -1) {
    8.23          switch (c) {
    8.24          case 'a':
    8.25              if (optarg) {
    8.26 @@ -524,6 +524,9 @@
    8.27              mode_MSG = 0;
    8.28              file_name_len = 14;
    8.29              break;
    8.30 +        case 'L':
    8.31 +            pst_debug_setlevel(atoi(optarg));
    8.32 +            break;
    8.33          case 'm':
    8.34              mode = MODE_SEPARATE;
    8.35              mode_MH  = 1;
    8.36 @@ -745,6 +748,7 @@
    8.37      printf("\t-V\t- Version. Display program version\n");
    8.38      printf("\t-C charset\t- character set for items with an unspecified character set\n");
    8.39      printf("\t-D\t- Include deleted items in output\n");
    8.40 +    printf("\t-L <level> \t- Set debug level; 1=debug,2=info,3=warn.\n");
    8.41      printf("\t-M\t- Write emails in the MH (rfc822) format\n");
    8.42      printf("\t-S\t- Separate. Write emails in the separate format\n");
    8.43      printf("\t-a <attachment-extension-list>\t- Discard any attachment without an extension on the list\n");