From 8dcd2b4cab6d481b0875c702176505b6ef6b6d5d Mon Sep 17 00:00:00 2001 From: xchaos Date: Wed, 11 Jun 2014 23:00:11 +0000 Subject: [PATCH] some bugfixes git-svn-id: https://dev.arachne.cz/repos/prometheus/trunk@243 251d49ef-1d17-4917-a970-b30cf55b089b --- parsehosts.c | 17 ++++++++++++----- prometheus.c | 36 +++++++++++++++++------------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/parsehosts.c b/parsehosts.c index 18418ed..ecb956a 100644 --- a/parsehosts.c +++ b/parsehosts.c @@ -1,4 +1,4 @@ -/* Modified by: xChaos, 20131029 */ +/* Modified by: xChaos, 20131220 */ #include "cll1-0.6.2.h" #include "ipstruct.h" @@ -163,23 +163,30 @@ void parse_hosts(char *hosts) /* any line starting with non-number is comment ...*/ continue; } - + + ptr = strchr(str,'\r'); /* fore unix-style end of line */ + if(ptr) + { + *ptr = 0; + } + /* first, expand (rewrite) any predefined macros, if found*/ for_each(macro, macros) { substring = strstr(str, macro->rewrite_from); - if(substring); + if(substring) { int l1, l3; *substring = 0; substring += strlen(macro->rewrite_from); l1 = strlen(str); l3 = strlen(substring); - string(ptr, l1 + strlen(macro->rewrite_to) + l3); + string(ptr, l1 + strlen(macro->rewrite_to) + l3 + 1); strcpy(ptr, str); strcat(ptr, macro->rewrite_to); strcat(ptr, substring); str = ptr; + /* printf("REWRITE: %s -> %s\n",_,str); */ } } @@ -329,4 +336,4 @@ void parse_hosts(char *hosts) // TheIP("0.0.0.0", TRUE); // ip->name = "TOTAL"; // ip->mask = 0; -} \ No newline at end of file +} diff --git a/prometheus.c b/prometheus.c index e091d6e..43238b3 100644 --- a/prometheus.c +++ b/prometheus.c @@ -581,6 +581,23 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); string(str, STRLEN); string(limit_pkts, STRLEN); + /*-----------------------------------------------------------------*/ + printf("Parsing macro definition file %s ...\n", macrosfile); + /*-----------------------------------------------------------------*/ + parse(macrosfile) + { + ptr = parse_datafile_line(_); + if(ptr) + { + create(macro, Macro); + macro->rewrite_from = _; + macro->rewrite_to = ptr; + push(macro, macros); + printf("%s -> %s\n", macro->rewrite_from, macro->rewrite_to); + } + } + done; /* ugly macro end */ + /*-----------------------------------------------------------------*/ printf("Parsing class defintion file %s ...\n", hosts); /*-----------------------------------------------------------------*/ @@ -631,25 +648,6 @@ Credit: CZFree.Net, Martin Devera, Netdave, Aquarius, Gandalf\n\n",version); done; /* ugly macro end */ } - if(enable_credit && just_flush<9) - { - /*-----------------------------------------------------------------*/ - printf("Parsing macro definition file %s ...\n", macrosfile); - /*-----------------------------------------------------------------*/ - parse(macrosfile) - { - ptr = parse_datafile_line(_); - if(ptr) - { - create(macro, Macro); - macro->rewrite_from = _; - macro->rewrite_to = ptr; - push(macro, macros); - printf("%s -> %s\n", macro->rewrite_from, macro->rewrite_to); - } - } - done; /* ugly macro end */ - } if(!just_preview) { -- 2.30.2