Changeset df2dff9
- Timestamp:
- 08/05/05 11:11:38 (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:
- f99a183
- Parents:
- da8b03e
- Location:
- lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_erf.c
rda8b03e rdf2dff9 478 478 void *buffer2 = buffer; 479 479 int rlen; 480 480 #if HAVE_ZLIB 481 481 if ((numbytes=gzread(INPUT.file, 482 482 buffer, … … 485 485 return -1; 486 486 } 487 #else 488 if ((numbytes = read(INPUT.file, buffer, dag_record_size)) == -1) { 489 perror("read"); 490 return -1; 491 } 492 #endif 487 493 if (numbytes == 0) { 488 494 return 0; … … 592 598 static int erf_write_packet(struct libtrace_out_t *libtrace, struct libtrace_packet_t *packet) { 593 599 int numbytes = 0; 594 595 if ((numbytes = gzwrite( libtrace->format_data->output.file, packet->buffer, packet->size)) == 0) {600 #if HAVE_ZLIB 601 if ((numbytes = gzwrite(OUTPUT.file, packet->buffer, packet->size)) == 0) { 596 602 perror("gzwrite"); 597 603 return -1; 598 604 } 605 #else 606 if ((numbytes = write(OUTPUT.file, packet->buffer, packet->size)) == 0) { 607 perror("write"); 608 return -1; 609 } 610 #endif 599 611 return numbytes; 600 612 } -
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.