Changeset db9fa93 for tools/tracemerge
- Timestamp:
- 04/23/10 11:18:11 (12 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:
- ba91618
- Parents:
- 97b5bf4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracemerge/tracemerge.c
rec0f8f1 rdb9fa93 6 6 #include <getopt.h> 7 7 #include <signal.h> 8 #include <string.h> 8 9 9 10 static void usage(char *argv0) … … 15 16 " read from the original traces, if appropriate\n" 16 17 "-u --unique-packets Discard duplicate packets\n" 17 "-z [level] --compression [level]\n"18 "-z level --compression level\n" 18 19 " Compression level\n" 20 "-Z method --compression-type method\n" 21 " Compression method\n" 19 22 "-H --libtrace-help Print libtrace runtime documentation\n" 20 23 ,argv0); … … 41 44 uint64_t last_ts=0; 42 45 struct sigaction sigact; 43 int compression=6; 46 int compression=-1; 47 char *compress_type_str = NULL; 48 trace_option_compresstype_t compress_type = TRACE_OPTION_COMPRESSTYPE_NONE; 44 49 45 50 while (1) { … … 49 54 { "unique-packets", 0, 0, 'u' }, 50 55 { "libtrace-help", 0, 0, 'H' }, 51 { "compression", 2, 0, 'z' }, 56 { "compression", 1, 0, 'z' }, 57 { "compression-type", 1, 0, 'Z' }, 52 58 { NULL, 0, 0, 0 }, 53 59 }; 54 60 55 int c=getopt_long(argc, argv, "i::uHz: :",61 int c=getopt_long(argc, argv, "i::uHz:Z:", 56 62 long_options, &option_index); 57 63 … … 72 78 break; 73 79 case 'z': 74 if (optarg) 75 compression = atoi(optarg); 76 else 77 compression = 6; 80 compression = atoi(optarg); 78 81 if (compression<0 || compression>9) { 79 82 fprintf(stderr,"Compression level must be between 0 and 9\n"); … … 81 84 } 82 85 break; 86 87 case 'Z': 88 compress_type_str = optarg; 89 break; 83 90 default: 84 91 fprintf(stderr,"unknown option: %c\n",c); … … 92 99 usage(argv[0]); 93 100 101 if (compress_type_str == NULL && compression >= 0) { 102 fprintf(stderr, "Compression level set, but no compression type was defined, setting to gzip\n"); 103 compress_type = TRACE_OPTION_COMPRESSTYPE_ZLIB; 104 } 105 106 else if (compress_type_str == NULL) { 107 /* If a level or type is not specified, use the "none" 108 * compression module */ 109 compress_type = TRACE_OPTION_COMPRESSTYPE_NONE; 110 } 111 112 /* I decided to be fairly generous in what I accept for the 113 * compression type string */ 114 else if (strncmp(compress_type_str, "gz", 2) == 0 || 115 strncmp(compress_type_str, "zlib", 4) == 0) { 116 compress_type = TRACE_OPTION_COMPRESSTYPE_ZLIB; 117 } else if (strncmp(compress_type_str, "bz", 2) == 0) { 118 compress_type = TRACE_OPTION_COMPRESSTYPE_BZ2; 119 } else if (strncmp(compress_type_str, "lzo", 3) == 0) { 120 compress_type = TRACE_OPTION_COMPRESSTYPE_LZO; 121 } else if (strncmp(compress_type_str, "no", 2) == 0) { 122 compress_type = TRACE_OPTION_COMPRESSTYPE_NONE; 123 } else { 124 fprintf(stderr, "Unknown compression type: %s\n", 125 compress_type_str); 126 return 1; 127 } 128 129 94 130 output=trace_create_output(argv[optind++]); 95 131 if (trace_is_err_output(output)) { … … 98 134 } 99 135 100 if (trace_config_output(output, TRACE_OPTION_OUTPUT_COMPRESS, &compression) == -1) { 136 if (compression >= 0 && 137 trace_config_output(output, 138 TRACE_OPTION_OUTPUT_COMPRESS, &compression) == -1) { 101 139 trace_perror_output(output,"Unable to set compression level"); 140 return 1; 141 } 142 143 if (trace_config_output(output, TRACE_OPTION_OUTPUT_COMPRESSTYPE, 144 &compress_type) == -1) { 145 trace_perror_output(output, "Unable to set compression method"); 146 return 1; 102 147 } 103 148
Note: See TracChangeset
for help on using the changeset viewer.