Changeset 1373

Show
Ignore:
Timestamp:
28/10/08 12:51:53 (2 months ago)
Author:
perry
Message:

Add the ability to specify compression levels

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tools/tracemerge/tracemerge.c

    r1260 r1373  
    1212        "%s flags outputuri traceuri [traceuri...]\n" 
    1313        "-i [interfaces_per_input] --set-interface [interfaces_per_input]\n" 
    14         "                       Each trace is allocated an interface. Default leaves this flag as read from the original traces, if appropriate\n" 
     14        "                       Each trace is allocated an interface. Default leaves this flag as\n" 
     15        "                       read from the original traces, if appropriate\n" 
    1516        "-u --unique-packets    Discard duplicate packets\n" 
     17        "-z [level] --compression [level]\n" 
     18        "                       Compression level\n" 
    1619        "-H --libtrace-help     Print libtrace runtime documentation\n" 
    1720        ,argv0); 
     
    3841        uint64_t last_ts=0; 
    3942        struct sigaction sigact; 
     43        int compression=6; 
    4044 
    4145        while (1) { 
     
    4549                        { "unique-packets",     0, 0, 'u' }, 
    4650                        { "libtrace-help",      0, 0, 'H' }, 
     51                        { "compression",        2, 0, 'z' }, 
    4752                        { NULL,                 0, 0, 0   }, 
    4853                }; 
    4954 
    50                 int c=getopt_long(argc, argv, "i::uH", 
     55                int c=getopt_long(argc, argv, "i::uHz::", 
    5156                                long_options, &option_index); 
    5257 
     
    6671                                  exit(1); 
    6772                                  break; 
     73                        case 'z': 
     74                                if (optarg) 
     75                                        compression = atoi(optarg); 
     76                                else 
     77                                        compression = 6; 
     78                                if (compression<0 || compression>9) { 
     79                                        fprintf(stderr,"Compression level must be between 0 and 9\n"); 
     80                                        usage(argv[0]); 
     81                                } 
     82                                break; 
    6883                        default: 
    6984                                fprintf(stderr,"unknown option: %c\n",c); 
     
    8297                return 1; 
    8398        } 
     99 
     100        if (trace_config_output(output, TRACE_OPTION_OUTPUT_COMPRESS, &compression) == -1) { 
     101                trace_perror_output(output,"Unable to set compression level"); 
     102        } 
     103 
    84104        if (trace_start_output(output)==-1) { 
    85105                trace_perror_output(output,"trace_start_output");