~pi-rho/netre-tools/trunk

« back to all changes in this revision

Viewing changes to src/puniq.c

  • Committer: pi-rho
  • Date: 2014-02-25 01:44:02 UTC
  • Revision ID: ubuntu@tyr.cx-20140225014402-zad7qq87fzukkhdp
do a bit better for error control
use err.h's warnx for a consistent feedback
puniq: move the start of the output pcap to inside the big loop to prevent
       writing the pcap file header when there is no input

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    struct pcap_file   out;
44
44
    int                cur;
45
45
 
46
 
    if (pcap_open_out(&out, output) == -1) {
47
 
        perror("writing header");
48
 
        return EX_IOERR;
49
 
    }
50
 
 
51
46
    do {
52
47
        struct pcap_file p;
53
48
 
62
57
            inf = *inputs++;
63
58
        }
64
59
 
65
 
        if (pcap_open_in(&p, inp) == -1) {
66
 
            fprintf(stderr, "unable to process: %s\n", inf);
67
 
            return EX_IOERR;
 
60
        if (pcap_open_in(&p, inp) == -1) return EX_IOERR;
 
61
 
 
62
        if (!out.f) {
 
63
            if (pcap_open_out(&out, output) == -1) {
 
64
                perror("writing header");
 
65
                return EX_IOERR;
 
66
            }
68
67
        }
69
68
 
70
69
        cur = 0;