comparison libfdproto/dictionary_functions.c @ 1093:44f3e48dfe27

Align the behavior of all fd_*dump functions wrt final \n
author Sebastien Decugis <sdecugis@freediameter.net>
date Mon, 06 May 2013 16:33:22 +0800
parents 7d7266115a34
children d4371b7aa0ff
comparison
equal deleted inserted replaced
1092:e40374ddfeef 1093:44f3e48dfe27
159 sSS ss; 159 sSS ss;
160 sSA4 sin; 160 sSA4 sin;
161 sSA6 sin6; 161 sSA6 sin6;
162 } s; 162 } s;
163 uint16_t fam; 163 uint16_t fam;
164 size_t o = 0; 164
165 165 FD_DUMP_HANDLE_OFFSET();
166 if (!offset)
167 offset = &o;
168 166
169 memset(&s, 0, sizeof(s)); 167 memset(&s, 0, sizeof(s));
170 168
171 /* The first two octets represent the address family, http://www.iana.org/assignments/address-family-numbers/ */ 169 /* The first two octets represent the address family, http://www.iana.org/assignments/address-family-numbers/ */
172 if (avp_value->os.len < 2) { 170 if (avp_value->os.len < 2) {
210 /*******************************/ 208 /*******************************/
211 209
212 /* Dump the AVP in a natural human-readable format. This dumps the complete length of the AVP, it is up to the caller to truncate if needed */ 210 /* Dump the AVP in a natural human-readable format. This dumps the complete length of the AVP, it is up to the caller to truncate if needed */
213 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_UTF8String_dump, union avp_value * avp_value) 211 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_UTF8String_dump, union avp_value * avp_value)
214 { 212 {
215 size_t o = 0, l; 213 size_t l;
216 if (!offset) 214 FD_DUMP_HANDLE_OFFSET();
217 offset = &o;
218 215
219 l = avp_value->os.len; 216 l = avp_value->os.len;
220 /* Just in case the string ends in invalid UTF-8 chars, we shorten it */ 217 /* Just in case the string ends in invalid UTF-8 chars, we shorten it */
221 while ((l > 0) && (avp_value->os.data[l - 1] & 0x80)) { 218 while ((l > 0) && (avp_value->os.data[l - 1] & 0x80)) {
222 /* this byte is start or cont. of multibyte sequence, as we do not know the next byte we need to delete it. */ 219 /* this byte is start or cont. of multibyte sequence, as we do not know the next byte we need to delete it. */
302 return diameter_string_to_time_t((const char *)avp_value->os.data, avp_value->os.len, interpreted); 299 return diameter_string_to_time_t((const char *)avp_value->os.data, avp_value->os.len, interpreted);
303 } 300 }
304 301
305 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_Time_dump, union avp_value * avp_value) 302 DECLARE_FD_DUMP_PROTOTYPE(fd_dictfct_Time_dump, union avp_value * avp_value)
306 { 303 {
307 size_t o = 0;
308 time_t val; 304 time_t val;
309 struct tm conv; 305 struct tm conv;
310 306
311 if (!offset) 307 FD_DUMP_HANDLE_OFFSET();
312 offset = &o;
313 308
314 if (avp_value->os.len != 4) { 309 if (avp_value->os.len != 4) {
315 CHECK_MALLOC_DO( fd_dump_extend(FD_DUMP_STD_PARAMS, "[invalid length: %zd]", avp_value->os.len), return NULL); 310 CHECK_MALLOC_DO( fd_dump_extend(FD_DUMP_STD_PARAMS, "[invalid length: %zd]", avp_value->os.len), return NULL);
316 return *buf; 311 return *buf;
317 } 312 }
"Welcome to our mercurial repository"