Changeset de8c420b for lib/trace.c
- Timestamp:
- 09/07/05 16:13:48 (15 years ago)
- Branches:
- 4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
- Children:
- 5bbe424
- Parents:
- 084d95a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/trace.c
r084d95a rde8c420b 237 237 struct libtrace_t *trace_create(char *uri) { 238 238 struct libtrace_t *libtrace = malloc(sizeof(struct libtrace_t)); 239 char *scan = calloc(sizeof(char),URI_PROTO_LINE);239 char *scan = 0; 240 240 char *uridata = 0; 241 241 int i = 0; … … 244 244 trace_err.err_num = E_NOERROR; 245 245 246 246 //scan = calloc(sizeof(char),URI_PROTO_LINE); 247 247 // parse the URI to determine what sort of event we are dealing with 248 248 249 // want snippet before the : to get the uri base type. 250 251 if((uridata = strchr(uri,':')) == NULL) { 252 // badly formed URI - needs a : 253 trace_err.err_num = E_URI_NOCOLON; 254 return 0; 255 } 256 257 258 if ((uridata - uri) > URI_PROTO_LINE) { 259 // badly formed URI - uri type is too long 260 trace_err.err_num = E_URI_LONG; 261 return 0; 262 } 263 strncpy(scan,uri, (uridata - uri)); 264 249 if ((uridata = trace_parse_uri(uri, &scan)) == 0) { 250 return 0; 251 } 252 265 253 libtrace->event.tdelta = 0.0; 266 267 254 268 255 libtrace->format = 0; … … 282 269 } 283 270 284 // push uridata past the delimiter285 uridata++;286 271 libtrace->uridata = strdup(uridata); 287 272 … … 353 338 struct libtrace_out_t *libtrace = malloc(sizeof(struct libtrace_out_t)); 354 339 355 char *scan = calloc(sizeof(char),URI_PROTO_LINE);340 char *scan = 0; 356 341 char *uridata = 0; 357 342 int i; … … 360 345 // parse the URI to determine what sort of event we are dealing with 361 346 362 // want snippet before the : to get the uri base type. 363 364 if((uridata = strchr(uri,':')) == NULL) { 365 // badly formed URI - needs a : 366 trace_err.err_num = E_URI_NOCOLON; 367 return 0; 368 } 369 370 if ((uridata - uri) > URI_PROTO_LINE) { 371 // badly formed URI - uri type is too long 372 trace_err.err_num = E_URI_LONG; 373 return 0; 374 } 375 376 strncpy(scan,uri, (uridata - uri)); 377 347 if ((uridata = trace_parse_uri(uri, &scan)) == 0) { 348 return 0; 349 } 350 351 378 352 libtrace->format = 0; 379 353 for (i = 0; i < nformats; i++) { … … 391 365 return 0; 392 366 } 393 394 // push uridata past the delimiter395 uridata++;396 367 libtrace->uridata = strdup(uridata); 397 368 … … 1324 1295 } 1325 1296 1297 char * trace_parse_uri(char *uri, char **format) { 1298 char *uridata = 0; 1299 1300 *format = calloc(sizeof(char), URI_PROTO_LINE); 1301 1302 if((uridata = strchr(uri,':')) == NULL) { 1303 // badly formed URI - needs a : 1304 trace_err.err_num = E_URI_NOCOLON; 1305 return 0; 1306 } 1307 1308 if ((uridata - uri) > URI_PROTO_LINE) { 1309 // badly formed URI - uri type is too long 1310 trace_err.err_num = E_URI_LONG; 1311 return 0; 1312 } 1313 1314 strncpy(*format ,uri, (uridata - uri)); 1315 // push uridata past the delimiter 1316 uridata++; 1317 return uridata; 1318 } 1319
Note: See TracChangeset
for help on using the changeset viewer.