commit b839df64d84b2ae4eb1ec07f129313d69b808773
parent 880cfbe870d0439eafa9ad3d02f03a18ddfc8c60
Author: Jordan Ritter <jpr5@darkridge.com>
Date: Fri, 1 Dec 2006 10:16:51 +0000
more work around the hiliting stuff. wtf is the format for the
GREP_COLOR envariable? lame manpages.
Diffstat:
2 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/ngrep.c b/ngrep.c
@@ -986,7 +986,7 @@ void dump_byline(unsigned char *data, uint32_t len, uint16_t mindex, uint16_t ms
while (s < data + len) {
if (enable_hilite && !hiliting && (s == data + mindex)) {
hiliting = 1;
- printf("\33[01;31m");
+ printf(ANSI_bold);
}
printf("%c", (*s == '\n' || isprint(*s)) ? *s : nonprint_char);
@@ -994,7 +994,7 @@ void dump_byline(unsigned char *data, uint32_t len, uint16_t mindex, uint16_t ms
if (enable_hilite && hiliting && (s == data + mindex + msize)) {
hiliting = 0;
- printf("\33[00m");
+ printf(ANSI_off);
}
}
@@ -1010,7 +1010,7 @@ void dump_unwrapped(unsigned char *data, uint32_t len, uint16_t mindex, uint16_t
while (s < data + len) {
if (enable_hilite && !hiliting && (s == data + mindex)) {
hiliting = 1;
- printf("\33[01;31m");
+ printf(ANSI_bold);
}
printf("%c", isprint(*s) ? *s : nonprint_char);
@@ -1018,7 +1018,7 @@ void dump_unwrapped(unsigned char *data, uint32_t len, uint16_t mindex, uint16_t
if (enable_hilite && hiliting && (s == data + mindex + msize)) {
hiliting = 0;
- printf("\33[00m");
+ printf(ANSI_off);
}
}
@@ -1041,7 +1041,7 @@ void dump_formatted(unsigned char *data, uint32_t len, uint16_t mindex, uint16_t
for (j = 0; j < width; j++) {
if (enable_hilite && (mindex <= (i+j) && (i+j) < mindex + msize)) {
hiliting = 1;
- printf("\33[01;31m");
+ printf(ANSI_bold);
}
if (i + j < len)
@@ -1053,7 +1053,7 @@ void dump_formatted(unsigned char *data, uint32_t len, uint16_t mindex, uint16_t
if (hiliting) {
hiliting = 0;
- printf("\33[00m");
+ printf(ANSI_off);
}
}
}
@@ -1061,7 +1061,7 @@ void dump_formatted(unsigned char *data, uint32_t len, uint16_t mindex, uint16_t
for (j = 0; j < width; j++) {
if (enable_hilite && mindex <= (i+j) && (i+j) < mindex + msize) {
hiliting = 1;
- printf("\33[01;31m");
+ printf(ANSI_bold);
}
if (i + j < len)
@@ -1070,7 +1070,7 @@ void dump_formatted(unsigned char *data, uint32_t len, uint16_t mindex, uint16_t
if (hiliting) {
hiliting = 0;
- printf("\33[00m");
+ printf(ANSI_off);
}
}
diff --git a/ngrep.h b/ngrep.h
@@ -122,3 +122,12 @@ struct NGREP_rtaphdr_t {
uint32_t it_present;
};
+
+/*
+ * ANSI color/hilite stuff.
+ */
+
+const char ANSI_red[] = "\33[01;31m";
+const char ANSI_bold[] = "\33[01m";
+const char ANSI_off[] = "\33[00m";
+