Changeset df2dff9 for lib/trace.c
- Timestamp:
- 08/05/05 11:11:38 (17 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:
- f99a183
- Parents:
- da8b03e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/trace.c
r77bd94f rdf2dff9 361 361 struct libtrace_out_t *libtrace = malloc(sizeof(struct libtrace_out_t)); 362 362 363 if (init_output(&libtrace, uri) == 0) 364 return 0; 363 char *scan = calloc(sizeof(char),URI_PROTO_LINE); 364 char *uridata = 0; 365 int i; 366 367 // parse the URI to determine what sort of event we are dealing with 368 369 // want snippet before the : to get the uri base type. 370 371 if((uridata = strchr(uri,':')) == NULL) { 372 // badly formed URI - needs a : 373 return 0; 374 } 375 376 if ((*uridata - *uri) > URI_PROTO_LINE) { 377 // badly formed URI - uri type is too long 378 return 0; 379 } 380 381 strncpy(scan,uri, (uridata - uri)); 382 383 libtrace->format = 0; 384 for (i = 0; i < nformats; i++) { 385 if (strlen(scan) == strlen(format_list[i]->name) && 386 !strncasecmp(scan, 387 format_list[i]->name, 388 strlen(scan))) { 389 libtrace->format=format_list[i]; 390 break; 391 } 392 } 393 if (libtrace->format == 0) { 394 fprintf(stderr, 395 "libtrace has no support for this format (%s)\n",scan); 396 return 0; 397 } 398 399 // push uridata past the delimiter 400 uridata++; 401 libtrace->uridata = strdup(uridata); 402 403 404 // libtrace->format now contains the type of uri 405 // libtrace->uridata contains the appropriate data for this 406 407 if (libtrace->format->init_output) { 408 libtrace->format->init_output( libtrace); 409 } else { 410 fprintf(stderr, 411 "No init_output function for format %s\n",scan); 412 return 0; 413 } 414 415 416 libtrace->fifo = create_fifo(1048576); 417 assert( libtrace->fifo); 365 418 366 419 return libtrace;
Note: See TracChangeset
for help on using the changeset viewer.