Skip to content

Commit

Permalink
Merge pull request #96 from luv/master
Browse files Browse the repository at this point in the history
new option -0 to omit extra new lines
  • Loading branch information
simsong committed Mar 7, 2015
2 parents 683fc4e + 9f661dc commit 5eb5bd1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/tcpdemux.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,16 @@ class tcpdemux {
class options {
public:;
enum { MAX_SEEK=1024*1024*16 };
options():console_output(false),store_output(true),opt_md5(false),
options():console_output(false),console_output_nonewline(false),
store_output(true),opt_md5(false),
post_processing(false),gzip_decompress(true),
max_bytes_per_flow(),
max_flows(0),suppress_header(0),
output_strip_nonprint(true),output_hex(false),use_color(0),
output_packet_index(false),max_seek(MAX_SEEK) {
}
bool console_output;
bool console_output_nonewline;
bool store_output; // do we output?
bool opt_md5; // do we calculate MD5 on DFXML output?
bool post_processing; // decode headers after tcp connection closes
Expand Down
6 changes: 5 additions & 1 deletion src/tcpflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ static void usage(int level)
std::cout << " -B: binary output, even with -c or -C (normally -c or -C turn it off)\n";
std::cout << " -c: console print only (don't create files)\n";
std::cout << " -C: console print only, but without the display of source/dest header\n";
std::cout << " -0: don't print newlines after packets when printing to console";
std::cout << " -s: strip non-printable characters (change to '.')\n";
std::cout << " -D: output in hex (useful to combine with -c or -C)\n";
std::cout << "\n";
Expand Down Expand Up @@ -434,7 +435,7 @@ int main(int argc, char *argv[])

bool trailing_input_list = false;
int arg;
while ((arg = getopt(argc, argv, "aA:Bb:cCd:DE:e:E:F:f:gHhIi:lL:m:o:pqR:r:S:sT:Vvw:x:X:Z")) != EOF) {
while ((arg = getopt(argc, argv, "aA:Bb:cCd:DE:e:E:F:f:gHhIi:lL:m:o:pqR:r:S:sT:Vvw:x:X:Z:0")) != EOF) {
switch (arg) {
case 'a':
demux.opt.post_processing = true;
Expand Down Expand Up @@ -464,6 +465,9 @@ int main(int argc, char *argv[])
case 'c':
demux.opt.console_output = true; DEBUG(10) ("printing packets to console only");
break;
case '0':
demux.opt.console_output_nonewline = true;
break;
case 'd':
if ((debug = atoi(optarg)) < 0) {
debug = DEFAULT_DEBUG_LEVEL;
Expand Down
2 changes: 1 addition & 1 deletion src/tcpip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ void tcpip::print_packet(const u_char *data, uint32_t length)

if (demux.opt.use_color) printf("\033[0m");

putchar('\n');
if (! demux.opt.console_output_nonewline) putchar('\n');
fflush(stdout);

#ifdef HAVE_PTHREAD
Expand Down

0 comments on commit 5eb5bd1

Please sign in to comment.