utils/ngrep/show_eol.patch
be0b8a5e
 diff -Naur ngrep.old/ngrep.8 ngrep.patched/ngrep.8
 --- ngrep.old/ngrep.8	Mon Dec 31 23:07:02 2001
 +++ ngrep.patched/ngrep.8	Fri Aug 30 17:33:28 2002
 @@ -48,6 +48,10 @@
  .IP -h
  Display help/usage information.
  
 +.IP -L
 +Display captured packets in line-by-line manner. Good for post-processing
 +of textual protocols.
 +
  .IP -X
  Treat the match expression as a hexadecimal string.  See the
  explanation of \fImatch expression\fP below.
 diff -Naur ngrep.old/ngrep.c ngrep.patched/ngrep.c
 --- ngrep.old/ngrep.c	Mon Dec 31 23:11:00 2001
 +++ ngrep.patched/ngrep.c	Fri Aug 30 17:33:28 2002
 @@ -54,6 +54,8 @@
  #include <signal.h>
  #include <sys/ioctl.h>
  
 +#include <locale.h>
 +
  #ifdef USE_PCRE
  #include "pcre-3.4/pcre.h"
  #else
 @@ -62,6 +64,9 @@
  
  #include "ngrep.h"
  
 +#define dump(_a,_b) ( show_eol ? \
 +	dump_line_by_line((_a),(_b)) : _dump((_a),(_b)) )
 +
  
  static char rcsver[] = "$Revision$";
  
 @@ -72,6 +77,8 @@
  int matches = 0, max_matches = 0;
  int live_read = 1, want_delay = 0;
  
 +int show_eol=0;
 +
  char pc_err[PCAP_ERRBUF_SIZE];
  #ifdef USE_PCRE
  int err_offset;
 @@ -117,8 +124,13 @@
    signal(SIGPIPE, clean_exit);
    signal(SIGWINCH, update_windowsize);
  
 -  while ((c = getopt(argc, argv, "hXViwqpevxlDtTs:n:d:A:I:O:")) != EOF) {
 +  setlocale(LC_ALL, "");
 +
 +  while ((c = getopt(argc, argv, "LhXViwqpevxlDtTs:n:d:A:I:O:")) != EOF) {
      switch (c) {
 +	case 'L':
 +		show_eol=1;
 +		break;
      case 'I':  
        read_file = optarg;
        break;
 @@ -649,8 +661,28 @@
    return 1;
  }
  
 +void dump_line_by_line( char *data, int len )
 +{
 +	unsigned width;
 +	char *c;
 +	
 +	c=data;
 +
 +	while( c< data + len) {
 +		if (*c=='\n') {
 +			puts("");
 +		} else {
 +	  		putchar(isprint(*c)?*c:'.');
 +		}
 +		c++;
 +
 +	}
 +	puts("");
 +
 +}
 +
  
 -void dump(char *data, int len) {  
 +void _dump(char *data, int len) {  
    if (len > 0) {
      unsigned width = show_hex?16:(ws_col-5);
      char *str = data;
 @@ -811,7 +843,7 @@
  
  
  void usage(int e) {
 -  printf("usage: ngrep <-hXViwqpevxlDtT> <-IO pcap_dump> <-n num> <-d dev> <-A num>\n"
 +  printf("usage: ngrep <-hLXViwqpevxlDtT> <-IO pcap_dump> <-n num> <-d dev> <-A num>\n"
  	 "                               <-s snaplen> <match expression> <bpf filter>\n");
    exit(e);
  }
 diff -Naur ngrep.old/ngrep.h ngrep.patched/ngrep.h
 --- ngrep.old/ngrep.h	Mon Dec 31 23:02:00 2001
 +++ ngrep.patched/ngrep.h	Fri Aug 30 17:33:29 2002
 @@ -29,7 +29,8 @@
  
  char *get_filter(char **);
  void process(u_char *, struct pcap_pkthdr*, u_char *);
 -void dump(char *, int); 
 +void _dump(char *, int); 
 +void dump_line_by_line(char *, int); 
  void clean_exit(int);
  void usage(int);
  void version(void);