From ae31e19f92e717919ac8e3db9039eb38d2b89aae Mon Sep 17 00:00:00 2001 From: in2 Date: Thu, 7 Mar 2002 15:13:44 +0000 Subject: Initial revision git-svn-id: http://opensvn.csie.org/pttbbs/pttbbs/trunk/pttbbs@1 63ad8ddf-47c3-0310-b6dd-a9e9d9715204 --- util/webgrep.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 util/webgrep.c (limited to 'util/webgrep.c') diff --git a/util/webgrep.c b/util/webgrep.c new file mode 100644 index 00000000..07089bb6 --- /dev/null +++ b/util/webgrep.c @@ -0,0 +1,46 @@ +/* $Id: webgrep.c,v 1.1 2002/03/07 15:13:46 in2 Exp $ */ +#include +#include +#include + +int main() +{ + char genbuf[256], *str, *buf; + while (fgets(genbuf, 255, stdin)) + { + register int ansi; + if (!strncmp(genbuf, "References", 10)) + break; + str = genbuf; + buf = genbuf; + if (!strncmp(genbuf, "lynx: Can't access", 18)) + { + printf("氣象報導小姐休假中,請到Record版翻過去資料."); + break; + } + for (ansi = 0; *str; str++) + { + if (*str == '[' && strchr("0123456789", *(str + 1))) + { + ansi = 1; + } + else if (ansi) + { + if (!strchr("0123456789]", *str)) + { + ansi = 0; + if (str) + *buf++ = *str; + } + } + else + { + if (str) + *buf++ = *str; + } + } + *buf = 0; + printf(genbuf); + } + return 0; +} -- cgit v1.2.3