changeset 258:8ad8fd1c5451

check return codes from forked processes
author Carl Byington <carl@five-ten-sg.com>
date Sat, 16 Apr 2011 10:09:28 -0700
parents c947b8812120
children 78e95fab9a8b
files regression/regression-tests.bash src/Makefile.am src/nick2ldif.cpp src/readpst.c
diffstat 4 files changed, 39 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/regression/regression-tests.bash	Fri Dec 24 19:26:05 2010 -0800
+++ b/regression/regression-tests.bash	Sat Apr 16 10:09:28 2011 -0700
@@ -55,17 +55,17 @@
     jobs=""
     [ -n "$val" ] && jobs="-j 0"
     rm -rf output$n
-    if [ -z "$val" ] || [ $size -lt 10000000 ]; then
+    if [ -z "$val" ] || [ $size -lt 100000000 ]; then
         echo $fn
         mkdir output$n
         if [ "$regression" == "yes" ]; then
             $val ../src/readpst $jobs -te -r -cv -o output$n $fn >$ba.err 2>&1
         else
             ## only email and include deleted items, have a deleted items folder with multiple item types
-            $val ../src/readpst $jobs -te -r -D -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
+            #$val ../src/readpst $jobs -te -r -D -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
 
             ## normal recursive dump
-            #$val ../src/readpst $jobs     -r    -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
+            $val ../src/readpst $jobs     -r    -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
 
             ## separate mode with filename extensions
             #$val ../src/readpst $jobs     -r -e -D -cv -o output$n -d $ba.log $fn >$ba.err 2>&1
@@ -119,13 +119,14 @@
 #$func  16 test-mac.pst
 ##$func  17 harris.pst
 ##$func  18 spam.pst
-#$func  19 rendgen.pst       # single email appointment
-#$func  20 rendgen2.pst      # email appointment with no termination date
-#$func  21 rendgen3.pst      # mime signed email
-#$func  22 rendgen4.pst      # appointment test cases
-#$func  23 rendgen5.pst      # appointment test cases
-#$func  24 paul.sheer.pst    # embedded rfc822 attachment
-$func  25 jerry.pst         # non ascii subject lines
+#$func  19 rendgen.pst           # single email appointment
+#$func  20 rendgen2.pst          # email appointment with no termination date
+#$func  21 rendgen3.pst          # mime signed email
+#$func  22 rendgen4.pst          # appointment test cases
+#$func  23 rendgen5.pst          # appointment test cases
+#$func  24 paul.sheer.pst        # embedded rfc822 attachment
+#$func  25 jerry.pst             # non ascii subject lines
+$func  26 phill.bertolus.pst    #
 
 [ -n "$val" ] && grep 'lost:' *err | grep -v 'lost: 0 '
 
--- a/src/Makefile.am	Fri Dec 24 19:26:05 2010 -0800
+++ b/src/Makefile.am	Sat Apr 16 10:09:28 2011 -0700
@@ -40,7 +40,7 @@
 endif
 
 noinst_PROGRAMS     = deltasearch dumpblocks getidblock
-bin_PROGRAMS        = lspst readpst pst2ldif
+bin_PROGRAMS        = lspst readpst pst2ldif nick2ldif
 if BUILD_DII
     bin_PROGRAMS   += pst2dii
 endif
@@ -51,6 +51,7 @@
 deltasearch_SOURCES = deltasearch.cpp  $(common_header)
 dumpblocks_SOURCES  = dumpblocks.c     $(common_header)
 getidblock_SOURCES  = getidblock.c     $(common_header)
+nick2ldif_SOURCES   = nick2ldif.cpp    $(common_header)
 
 
 lspst_DEPENDENCIES        = libpst.la
@@ -60,6 +61,7 @@
 deltasearch_DEPENDENCIES  = libpst.la
 dumpblocks_DEPENDENCIES   = libpst.la
 getidblock_DEPENDENCIES   = libpst.la
+nick2ldif_DEPENDENCIES    = libpst.la
 
 if STATIC_TOOLS
     noinst_LTLIBRARIES    = libpst.la
@@ -92,8 +94,9 @@
 readpst_LDADD     = $(all_libraries) $(PSTLIB) $(LTLIBICONV) $(REGEXLIB)
 pst2ldif_LDADD    = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
 pst2dii_LDADD     = $(all_libraries) $(PSTLIB) $(LTLIBICONV) -lgd
+deltasearch_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
 dumpblocks_LDADD  = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
 getidblock_LDADD  = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
-deltasearch_LDADD = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
+nick2ldif_LDADD   = $(all_libraries) $(PSTLIB) $(LTLIBICONV)
 
 
--- a/src/nick2ldif.cpp	Fri Dec 24 19:26:05 2010 -0800
+++ b/src/nick2ldif.cpp	Sat Apr 16 10:09:28 2011 -0700
@@ -18,7 +18,7 @@
 
 using namespace std;
 
-int main(int argc, const char** argv) {
+int main(int argc, char* const* argv) {
 	char c;
 	char *temp;
 	while ((c = getopt(argc, argv, "b:c:"))!= -1) {
@@ -46,6 +46,7 @@
 		cin.getline(line, LINE_SIZE);
 		int n = strlen(line);
 		if (!n) continue;
+        if (strncmp(line, "alias", 5) != 0) continue;   // not alias
 		char *f = line + 6; 	// skip alias keyword
 		char *e;
 		if (*f == '"') {
@@ -60,11 +61,22 @@
 		char *m = e+1;
 		while (*m == ' ') m++;
 		if (*m != '\0') {
-			char cn[1000];
-			snprintf(cn, sizeof(cn), "email %s", f);
+			char cn[1000], givenName[1000], sn[1000];
+			snprintf(cn, sizeof(cn), "%s", f);
+            char *ff = strchr(f, ' ');
+            if (ff) {
+                strncpy(givenName, ff+1, sizeof(givenName)-1);
+                *ff = '\0';
+                strncpy(sn, f, sizeof(sn)-1);
+            }
+            else {
+                strcpy(givenName, cn);
+                strcpy(sn, cn);
+            }
 			printf("dn: cn=%s, %s\n", cn, ldap_base);
 			printf("cn: %s\n", cn);
-			printf("sn: %s\n", f);
+            printf("givenName: %s\n", givenName);
+			printf("sn: %s\n", sn);
 			printf("mail: %s\n", m);
 			printf("objectClass: %s\n\n", ldap_class);
 		}
--- a/src/readpst.c	Fri Dec 24 19:26:05 2010 -0800
+++ b/src/readpst.c	Sat Apr 16 10:09:28 2011 -0700
@@ -156,9 +156,15 @@
         //fflush(stdout);
         int i,j;
         for (i=0; i<active_children; i++) {
+            int status;
             pid_t child = child_processes[i];
-            pid_t ch = waitpid(child, NULL, ((waitall) ? 0 : WNOHANG));
+            pid_t ch = waitpid(child, &status, ((waitall) ? 0 : WNOHANG));
             if (ch == child) {
+                // check termination status
+                if (WIFSIGNALED(status)) {
+                    int sig = WTERMSIG(status);
+                    DEBUG_INFO(("Process %d terminated with signal %d\n", child, sig));
+                }
                 // this has terminated, remove it from the list
                 for (j=i; j<active_children-1; j++) {
                     child_processes[j] = child_processes[j+1];