debug logging
authoraidan
Tue, 10 Jan 2012 15:21:56 +0000
changeset 70 51693ac735a5
parent 69 cfd4a4e36ea2
child 71 fdb6e00dacc9
debug logging
apps/dtnrespond/dtnrespond.c
--- a/apps/dtnrespond/dtnrespond.c	Tue Jan 10 14:50:22 2012 +0000
+++ b/apps/dtnrespond/dtnrespond.c	Tue Jan 10 15:21:56 2012 +0000
@@ -477,7 +477,8 @@
     char  * response_path,
     int     response_path_len,
     dtn_timeval_t * response_expiry,
-    int   * found)
+    int   * found,
+    int     verbose)
 {
     char line[PATH_MAX];
     char trim_path[PATH_MAX];
@@ -488,9 +489,15 @@
     char * expiry;
     FILE * file;
 
-    if ((file = fopen(matching_filename, "r")) == 0)
+    if ((file = fopen(matching_filename, "r")) == 0) {
+    	fprintf(stderr, "Error opening matching file: %s\n",
+    			matching_filename);
         return -1;
+    }
     
+    if (verbose) fprintf(stdout, "Matching query: %s\n",
+                                 bpq->query.query_val);
+
     while (1) {
     	memset(line, 0 , PATH_MAX);
     	*found = 0;
@@ -518,6 +525,8 @@
 			strlen(query) != bpq->query.query_len 				||
         	strncmp(query, bpq->query.query_val, bpq->query.query_len) != 0) {
 
+            if (verbose) fprintf(stdout, "Line [%s] does not match\n",line);
+
         	continue;
         }
 
@@ -1003,7 +1012,8 @@
                 			pathname,
                 			PATH_MAX,
                 			&bundle_expiry,
-                			&found);
+                			&found,
+                			verbose);
 
                 break;
             }