comparison libfdproto/dictionary_functions.c @ 1300:3f1e79e1273e

Added new callbacks in the derived types definitions to improve value checks during message parsing. Thanks Ranjith for the suggestion.
author Sebastien Decugis <sdecugis@freediameter.net>
date Sun, 30 Aug 2015 01:11:55 +0800
parents 38e4a7c318ac
children 3cbe458fbfa9
comparison
equal deleted inserted replaced
1299:035f489b845b 1300:3f1e79e1273e
356 _format_offs(conv.tm_gmtoff, tz_buf); 356 _format_offs(conv.tm_gmtoff, tz_buf);
357 CHECK_MALLOC_DO( fd_dump_extend(FD_DUMP_STD_PARAMS, "%d%02d%02dT%02d%02d%02d%s", conv.tm_year+1900, conv.tm_mon+1, conv.tm_mday, conv.tm_hour, conv.tm_min, conv.tm_sec, tz_buf), return NULL); 357 CHECK_MALLOC_DO( fd_dump_extend(FD_DUMP_STD_PARAMS, "%d%02d%02dT%02d%02d%02d%s", conv.tm_year+1900, conv.tm_mon+1, conv.tm_mday, conv.tm_hour, conv.tm_min, conv.tm_sec, tz_buf), return NULL);
358 return *buf; 358 return *buf;
359 } 359 }
360 360
361 /* Check that a given AVP value contains all the characters from data in the same order */
362 static char error_message[80];
363 int fd_dictfct_CharInOS_check(void * data, union avp_value * val, char ** error_msg)
364 {
365 char * inChar = data;
366 char * inData = (char *)val->os.data;
367 int i = 0;
368 CHECK_PARAMS(data);
369 while (*inChar != '\0') {
370 while (i < val->os.len) {
371 if (*inChar == inData[i++]) {
372 inChar++;
373 break;
374 }
375 }
376 if (i >= val->os.len)
377 break;
378 }
379 if (*inChar == '\0')
380 return 0;
381
382 if (error_msg) {
383 snprintf(error_message, sizeof(error_message), "Could not find '%c' in AVP", *inChar);
384 *error_msg = error_message;
385 }
386 return EBADMSG;
387 }
"Welcome to our mercurial repository"