apps/dtnrespond/dtnrespond.c
changeset 70 51693ac735a5
parent 67 cfe2328ba1c6
child 71 fdb6e00dacc9
equal deleted inserted replaced
69:cfd4a4e36ea2 70:51693ac735a5
   475     const char * matching_filename,
   475     const char * matching_filename,
   476     u_int * response_kind,
   476     u_int * response_kind,
   477     char  * response_path,
   477     char  * response_path,
   478     int     response_path_len,
   478     int     response_path_len,
   479     dtn_timeval_t * response_expiry,
   479     dtn_timeval_t * response_expiry,
   480     int   * found)
   480     int   * found,
       
   481     int     verbose)
   481 {
   482 {
   482     char line[PATH_MAX];
   483     char line[PATH_MAX];
   483     char trim_path[PATH_MAX];
   484     char trim_path[PATH_MAX];
   484     char * matching_rule;
   485     char * matching_rule;
   485     char * query;
   486     char * query;
   486     char * path;
   487     char * path;
   487     char * kind;
   488     char * kind;
   488     char * expiry;
   489     char * expiry;
   489     FILE * file;
   490     FILE * file;
   490 
   491 
   491     if ((file = fopen(matching_filename, "r")) == 0)
   492     if ((file = fopen(matching_filename, "r")) == 0) {
       
   493     	fprintf(stderr, "Error opening matching file: %s\n",
       
   494     			matching_filename);
   492         return -1;
   495         return -1;
       
   496     }
   493     
   497     
       
   498     if (verbose) fprintf(stdout, "Matching query: %s\n",
       
   499                                  bpq->query.query_val);
       
   500 
   494     while (1) {
   501     while (1) {
   495     	memset(line, 0 , PATH_MAX);
   502     	memset(line, 0 , PATH_MAX);
   496     	*found = 0;
   503     	*found = 0;
   497 
   504 
   498     	// read line from matching file
   505     	// read line from matching file
   515     	// match query
   522     	// match query
   516         if (atoi(matching_rule) != (int)bpq->matching_rule		||
   523         if (atoi(matching_rule) != (int)bpq->matching_rule		||
   517 			BPQ_MATCHING_RULE_EXACT != bpq->matching_rule		||
   524 			BPQ_MATCHING_RULE_EXACT != bpq->matching_rule		||
   518 			strlen(query) != bpq->query.query_len 				||
   525 			strlen(query) != bpq->query.query_len 				||
   519         	strncmp(query, bpq->query.query_val, bpq->query.query_len) != 0) {
   526         	strncmp(query, bpq->query.query_val, bpq->query.query_len) != 0) {
       
   527 
       
   528             if (verbose) fprintf(stdout, "Line [%s] does not match\n",line);
   520 
   529 
   521         	continue;
   530         	continue;
   522         }
   531         }
   523 
   532 
   524 
   533 
  1001                 			matching_filename,
  1010                 			matching_filename,
  1002                 			&response_kind,
  1011                 			&response_kind,
  1003                 			pathname,
  1012                 			pathname,
  1004                 			PATH_MAX,
  1013                 			PATH_MAX,
  1005                 			&bundle_expiry,
  1014                 			&bundle_expiry,
  1006                 			&found);
  1015                 			&found,
       
  1016                 			verbose);
  1007 
  1017 
  1008                 break;
  1018                 break;
  1009             }                
  1019             }                
  1010         }
  1020         }
  1011 
  1021