Selaa lähdekoodia

Parser updated, expires_body structure has a new field which indicates if
the HF contains a valid value, if not, this field will be set to 0 and module
that called the parser can use some default value.

Jan Janak 23 vuotta sitten
vanhempi
commit
c9cb6cfeff
2 muutettua tiedostoa jossa 13 lisäystä ja 2 poistoa
  1. 10 0
      parser/parse_expires.c
  2. 3 2
      parser/parse_expires.h

+ 10 - 0
parser/parse_expires.c

@@ -48,6 +48,7 @@ static inline int expires_parser(char* _s, int _l, exp_body_t* _e)
 
 
 	if (tmp.len == 0) {
 	if (tmp.len == 0) {
 		LOG(L_ERR, "expires_parser(): Empty body\n");
 		LOG(L_ERR, "expires_parser(): Empty body\n");
+		_e->valid = 0;
 		return -1;
 		return -1;
 	}
 	}
 
 
@@ -64,16 +65,25 @@ static inline int expires_parser(char* _s, int _l, exp_body_t* _e)
 			case '\r':
 			case '\r':
 			case '\n':
 			case '\n':
 				_e->text.len = i;
 				_e->text.len = i;
+				_e->valid = 1;
 				return 0;
 				return 0;
 
 
 			default:
 			default:
+				     /* Exit normally here, we want to be backwards compatible with
+				      * RFC2543 entities that can put absolute time here
+				      */
+				     /*
 				LOG(L_ERR, "expires_parser(): Invalid character\n");
 				LOG(L_ERR, "expires_parser(): Invalid character\n");
 				return -2;
 				return -2;
+				     */
+				_e->valid = 0;
+				return 0;
 			}
 			}
 		}
 		}
 	}
 	}
 
 
 	_e->text.len = _l;
 	_e->text.len = _l;
+	_e->valid = 1;
 	return 0;
 	return 0;
 }
 }
 
 

+ 3 - 2
parser/parse_expires.h

@@ -36,8 +36,9 @@
 
 
 
 
 typedef struct exp_body {
 typedef struct exp_body {
-	str text;          /* Original text representation */
-	int val;           /* Parsed value */
+	str text;            /* Original text representation */
+	unsigned char valid; /* Was parsing successfull ? */
+	int val;             /* Parsed value */
 } exp_body_t;
 } exp_body_t;