Changeset 91ebc50 for lib/format_erf.c
- Timestamp:
- 08/03/05 14:24:59 (16 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:
- 283acce
- Parents:
- 1f2220f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/format_erf.c
r9a36e6d r91ebc50 32 32 #include "format.h" 33 33 #include "rtserver.h" 34 #include "parse_cmd.h" 34 35 35 36 #ifdef HAVE_INTTYPES_H … … 54 55 #include <netdb.h> 55 56 #include <fcntl.h> 57 #include <getopt.h> 56 58 57 59 /* Catch undefined O_LARGEFILE on *BSD etc */ … … 199 201 200 202 static int erf_init_output(struct libtrace_out_t *libtrace) { 201 struct stat buf; 202 203 if (!strncmp(libtrace->conn_info.path,"-",1)) { 203 char *filemode = 0; 204 205 libtrace->options.erf.level = 1; 206 asprintf(&filemode,"wb%d",libtrace->options.erf.level); 207 208 if (!strncmp(libtrace->uridata,"-",1)) { 204 209 // STDOUT 205 210 #if HAVE_ZLIB 206 libtrace->output.file = gzdopen(dup(1), "w");211 libtrace->output.file = gzdopen(dup(1), filemode); 207 212 #else 208 213 libtrace->output.file = stdout; … … 216 221 // we lose any error checking on "open" 217 222 libtrace->output.file = gzdopen(open( 218 libtrace->conn_info.path, 223 libtrace->uridata, 224 O_CREAT | O_LARGEFILE | O_WRONLY, 225 S_IRUSR | S_IWUSR), filemode); 226 #else 227 libtrace->output.file = fdopen(open( 228 libtrace->uridata, 219 229 O_CREAT | O_LARGEFILE | O_WRONLY, 220 230 S_IRUSR | S_IWUSR), "w"); 221 #else 222 libtrace->output.file = fdopen(open( 223 libtrace->conn_info.path, 224 O_CREAT | O_LARGEFILE | O_WRONLY, 225 S_IRUSR | S_IWUSR), "w"); 226 #endif 227 } 231 #endif 232 } 233 228 234 229 235 } 230 236 231 237 static int rtclient_init_output(struct libtrace_out_t *libtrace) { 232 char * uridata = libtrace-> conn_info.path;238 char * uridata = libtrace->uridata; 233 239 char * scan; 234 240 // extract conn_info from uridata … … 258 264 return 0; 259 265 266 } 267 268 static int erf_config_output(struct libtrace_out_t *libtrace, int argc, char *argv[]) { 269 int opt; 270 int level = libtrace->options.erf.level; 271 optind = 1; 272 273 while ((opt = getopt(argc, argv, "z:")) != EOF) { 274 switch (opt) { 275 case 'z': 276 level = atoi(optarg); 277 break; 278 default: 279 printf("Bad argument to erf: %s\n", opt); 280 // maybe spit out some help here 281 return -1; 282 } 283 } 284 if (level != libtrace->options.erf.level) { 285 if (level > 9 || level < 0) { 286 // retarded level choice 287 printf("Compression level must be between 0 and 9 inclusive - you selected %i \n", level); 288 289 } else { 290 libtrace->options.erf.level = level; 291 return gzsetparams(libtrace->output.file, level, Z_DEFAULT_STRATEGY); 292 } 293 } 294 return 0; 295 296 } 297 298 static int rtclient_config_output(struct libtrace_out_t *libtrace, int argc, char *argv[]) { 299 return 0; 260 300 } 261 301 … … 534 574 535 575 fifo_out_update(libtrace->fifo, size); 536 // Need an ack to come back 537 // TODO: Obviously this is a little unfinished 538 if ("ACK_ARRIVES") { 539 fifo_ack_update(libtrace->fifo, size); 540 return numbytes; 541 } else { 542 fifo_out_reset(libtrace->fifo); 543 } 576 fifo_ack_update(libtrace->fifo, size); 544 577 } while(1); 545 578 } … … 618 651 erf_init_input, /* init_input */ 619 652 erf_init_output, /* init_output */ 653 erf_config_output, /* config_output */ 620 654 erf_fin_input, /* fin_input */ 621 655 erf_fin_output, /* fin_output */ … … 640 674 dag_init_input, /* init_input */ 641 675 NULL, /* init_output */ 676 NULL, /* config_output */ 642 677 dag_fin_input, /* fin_input */ 643 678 NULL, /* fin_output */ … … 662 697 rtclient_init_input, /* init_input */ 663 698 rtclient_init_output, /* init_output */ 699 rtclient_config_output, /* config_output */ 664 700 rtclient_fin_input, /* fin_input */ 665 701 rtclient_fin_output, /* fin_output */
Note: See TracChangeset
for help on using the changeset viewer.