You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(19) |
Nov
(34) |
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(3) |
Feb
(1) |
Mar
(4) |
Apr
(31) |
May
(15) |
Jun
(33) |
Jul
(3) |
Aug
(7) |
Sep
(2) |
Oct
(7) |
Nov
(2) |
Dec
|
2005 |
Jan
|
Feb
(7) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
(3) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(13) |
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(2) |
Oct
|
Nov
(3) |
Dec
|
2015 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <kai...@us...> - 2003-11-17 06:56:33
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv31268 Modified Files: fetchipac.c Removed Files: README-NG Log Message: still removing classic mode Index: fetchipac.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/fetchipac.c,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- fetchipac.c 14 Nov 2003 19:51:29 -0000 1.11 +++ fetchipac.c 17 Nov 2003 06:55:49 -0000 1.12 @@ -325,127 +325,6 @@ strftime(s, 29, "%c", tmp); } -/* - * Some work to make sure that all rules are switched on and we can bill - * for traffic on them.. then decrement limits at database and cut off user in - * case there are no more bucks - */ -/* -int -check_cash(const data_record_type *data) -{ - rule_type *d; - double old_cash, new_cash, price; - int pay_type; - int was_locked=0; - char *last_paid; - - was_locked = lock(LOCKFILE); - if (was_locked) - unlock(LOCKFILE); - - d = data->firstrule; - - while(d) { - if (fnmatch("admin *", d->name, 0)) { - pay_type = access_agent->get_pay_type(d->name); - if (pay_type != 0) { - old_cash = access_agent->get_cash(d->name); - new_cash = old_cash; - price = access_agent->get_price(d->name); - switch (pay_type) - { - case 1: // price for a byte - new_cash = old_cash - - (d->bytes*price); - break; - case 15: - last_paid = access_agent-> - get_last_paid(d->name); - if (!fnmatch("*mon*", last_paid, 0)|| - !fnmatch("*year*", last_paid, 0)) { - new_cash = old_cash - - price; - access_agent->set_last_paid( - d->name, "1 mons"); - } - break; - } - if (old_cash!=new_cash) - access_agent->set_cash(d->name, new_cash); - // drop connections to that user - if (new_cash<=0) { - access_agent->logout(d->name, new_cash); - } - } - } - d=d->next; - } - if (was_locked) - lock(LOCKFILE); - return 0; -} -*/ - -int list_timestamps(timestamp_t tstart, timestamp_t tend, char *ahost) -{ - timestamp_t *tlist, *t, before, after; - int n, i; - char s[30]; - - if (!storage_opened) { - storage_method->open(SM_OPEN_READONLY); - n = storage_method->list_timestamps(tstart, tend, &tlist, - &before, &after, ahost); - storage_method->close(); - } else - n = storage_method->list_timestamps(tstart, tend, &tlist, - &before, &after, ahost); - - if (n > 0) { - printf(machine_output_format ? "%d\n" - : "number of timestamps found: %d\n", n); - if (before != (timestamp_t)-1) { - if (machine_output_format) - printf("- %lu\n", before); - else { - nice_time(before, s); - printf("%12lu (%s) (final timestamp before " - "start time)\n", before, s); - } - } - for (i=0, t=tlist; i<n; i++, t++) { - if (machine_output_format) - printf("* %lu\n", *t); - else - { - nice_time(*t, s); - printf("%12lu (%s) ", *t, s); - if (i%2 == 1) - printf("\n"); - } - } - if (machine_output_format == 0) - printf("\n"); - if (after != (timestamp_t)-1) - { - if (machine_output_format) - printf("+ %lu\n", after); - else - { - nice_time(after, s); - printf("%12lu (%s) (first timestamp after " - "end time)\n", after, s); - } - } - } else - printf(machine_output_format ? "0\n" - : "number of timestamps found: 0\n"); - if (n > 0) - free(tlist); - return n>-1 ? 0 : 1; -} - /* signal handler for SIGALRM: close the database backend to avoid * locking it too long. * commented out, because it introduces more problems that it solves (Manfred Weihs) --- README-NG DELETED --- |
From: <fr...@us...> - 2003-11-14 19:51:33
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv31360 Modified Files: conffile.l conffile.y config.h.in fetchipac.c ipac.h Log Message: remove some more remains of the non-classic mode... Index: conffile.l =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/conffile.l,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- conffile.l 6 Jul 2003 11:34:51 -0000 1.2 +++ conffile.l 14 Nov 2003 19:51:29 -0000 1.3 @@ -22,7 +22,6 @@ <par>yes|true BEGIN(0); conflval.n = 1; return BOOL; <par>no|false BEGIN(0); conflval.n = 0; return BOOL; <par>[[:alnum:]\/\-\.]+|[ \t]*\n BEGIN(0); conflval.s = (char *) strdup(conftext); confline++; return PARAMETER; -"classic"[ \t]+"mode" return CLASSIC; "access"[ \t]+"agent" return ACCESS; "account"[ \t]+"agent" return ACCOUNT; "hostname" return HOSTNAME; Index: conffile.y =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/conffile.y,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- conffile.y 6 Jul 2003 11:34:51 -0000 1.2 +++ conffile.y 14 Nov 2003 19:51:29 -0000 1.3 @@ -38,11 +38,11 @@ %token <n> BOOL %token EQUAL -%token CLASSIC ACCESS ACCOUNT STORAGE RULES SLOGIN AUTHHOST DROPZERO ERROR +%token ACCESS ACCOUNT STORAGE RULES SLOGIN AUTHHOST DROPZERO ERROR %token DBHOST DBPORT DBNAME DBUSER DBPASS %token HOSTNAME -%type <s> commands dbhost_opt command dbport_opt classic_opt access_opt +%type <s> commands dbhost_opt command dbport_opt access_opt %type <s> account_opt storage_opt rules_opt slogin_opt authhost_opt dropzero_opt %type <s> dbname_opt dbuser_opt dbpass_opt hostname_opt @@ -61,8 +61,7 @@ ; command: - classic_opt - |hostname_opt + hostname_opt |access_opt |account_opt |storage_opt @@ -139,17 +138,6 @@ dbpass = xstrdup(conflval.s); } | DBPASS error - { - fprintf(stderr, "error while parsing config file\n"); - $$ = NULL; - }; - -classic_opt: - CLASSIC EQUAL BOOL - { - is_classic = conflval.n; - } - | CLASSIC error { fprintf(stderr, "error while parsing config file\n"); $$ = NULL; Index: config.h.in =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/config.h.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- config.h.in 6 Jul 2003 11:34:51 -0000 1.2 +++ config.h.in 14 Nov 2003 19:51:29 -0000 1.3 @@ -20,9 +20,6 @@ /* define default access agent */ #define DEFAULT_ACCESS xxx -/* should we emulate classic ipac by default? */ -#define EMULATE_CLASSIC xxx - /* define conf file for plain-file storage method */ #define CONFFILE xxx Index: fetchipac.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/fetchipac.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- fetchipac.c 13 Nov 2003 22:38:23 -0000 1.10 +++ fetchipac.c 14 Nov 2003 19:51:29 -0000 1.11 @@ -92,8 +92,6 @@ int storage_opened = 0; -int is_classic = 1; - int access_opened = 1; char *storage_method_name = NULL; @@ -767,8 +765,6 @@ me = argv[0]; mode = 0; /* fetch data */ strncpy(conffile, CONFFILE, sizeof(conffile)-1); // default config - - is_classic = 1; /* create array storage_methods */ create_storage_methods(); Index: ipac.h =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/ipac.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ipac.h 31 Oct 2003 07:29:06 -0000 1.4 +++ ipac.h 14 Nov 2003 19:51:29 -0000 1.5 @@ -75,9 +75,7 @@ extern int access_opened; -/* flag to indicate work method */ -extern int is_classic; - +/* the database configuration extern char *dbname; extern char *dbport; extern char *dbhost; |
From: <fr...@us...> - 2003-11-14 19:51:33
|
Update of /cvsroot/ipac-ng/ipac-ng/agents/iptables In directory sc8-pr-cvs1:/tmp/cvs-serv31360/agents/iptables Modified Files: iptables.c Log Message: remove some more remains of the non-classic mode... Index: iptables.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/agents/iptables/iptables.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- iptables.c 31 Oct 2003 07:29:06 -0000 1.4 +++ iptables.c 14 Nov 2003 19:51:29 -0000 1.5 @@ -1532,35 +1532,6 @@ fprintf(stderr, "iptables: %s\n", iptc_strerror(errno)); return (1); } - -/* - if ((!is_classic)) { - if (!iptc_is_chain("ipac~c_fi", handle)) - if (!iptc_create_chain("ipac~c_fi", &handle)) { - fprintf(stderr, "iptables: %s\n", - iptc_strerror(errno)); - return (1); - } - if (!iptc_is_chain("ipac~c_fo", handle)) - if (!iptc_create_chain("ipac~c_fo", &handle)) { - fprintf(stderr, "iptables: %s\n", - iptc_strerror(errno)); - return (1); - } - if (!iptc_is_chain("ipac~c_i", handle)) - if (!iptc_create_chain("ipac~c_i", &handle)) { - fprintf(stderr, "iptables: %s\n", - iptc_strerror(errno)); - return (1); - } - if (!iptc_is_chain("ipac~c_o", handle)) - if (!iptc_create_chain("ipac~c_o", &handle)) { - fprintf(stderr, "iptables: %s\n", - iptc_strerror(errno)); - return (1); - } - } -*/ return 0; }; @@ -1589,34 +1560,6 @@ fprintf(stderr, "iptables: %s\n", iptc_strerror(errno)); return (1); } -/* - if (!is_classic) { - if (iptc_is_chain("ipac~c_fi", handle)) - if (!iptc_flush_entries("ipac~c_fi", &handle)) { - fprintf(stderr, "iptables: %s\n", - iptc_strerror(errno)); - return (1); - } - if (iptc_is_chain("ipac~c_fo", handle)) - if (!iptc_flush_entries("ipac~c_fo", &handle)) { - fprintf(stderr, "iptables: %s\n", - iptc_strerror(errno)); - return (1); - } - if (iptc_is_chain("ipac~c_i", handle)) - if (!iptc_flush_entries("ipac~c_i", &handle)) { - fprintf(stderr, "iptables: %s\n", - iptc_strerror(errno)); - return (1); - } - if (iptc_is_chain("ipac~c_o", handle)) - if (!iptc_flush_entries("ipac~c_o", &handle)) { - fprintf(stderr, "iptables: %s\n", - iptc_strerror(errno)); - return (1); - } - } -*/ // Try to flush our old chains if (access_agent->get_raw_list("iptables", "", &d)) { fprintf(stderr, "access error\n"); @@ -1702,8 +1645,7 @@ } strcpy(targ, d->name+8); iptc_create_chain(targ, &handle); - if (is_classic) - fprintf(frunfile, "%s|%%\n", chain); + fprintf(frunfile, "%s|%%\n", chain); } else { fprintf(stderr, "error: incorrect symbol %% " "in rule name\n"); @@ -1714,21 +1656,10 @@ (!memcmp(chain+strlen(chain)-4, "~c", 2))) || ((strlen(chain)>5) && (!memcmp(chain+strlen(chain)-5, "~c", 2))))) - if (is_classic || - !strncmp(chain, "ipac", 4) || - !strncmp(chain, "admin", 5) || - ((strlen(d->name)>3) && - !memcmp(d->name+strlen(d->name)-3, - "~st", 3))) - fprintf(frunfile,"%s|%s\n", chain, d->name); + fprintf(frunfile,"%s|%s\n", chain, d->name); - if (is_classic || - !strncmp(chain, "ipac", 4) || - !strncmp(chain, "admin", 5) || - ((strlen(d->name)>3) && - !memcmp(d->name+strlen(d->name)-3, "~st", 3))) - strcpy(d->dest, chain); - append_rule(d); + strcpy(d->dest, chain); + append_rule(d); d=d->next; } fclose(frunfile); |
From: <fr...@us...> - 2003-11-14 19:51:33
|
Update of /cvsroot/ipac-ng/ipac-ng/agents/ipchains In directory sc8-pr-cvs1:/tmp/cvs-serv31360/agents/ipchains Modified Files: ipchains.c Log Message: remove some more remains of the non-classic mode... Index: ipchains.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/agents/ipchains/ipchains.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ipchains.c 31 Oct 2003 07:29:06 -0000 1.3 +++ ipchains.c 14 Nov 2003 19:51:29 -0000 1.4 @@ -432,16 +432,6 @@ parse_ports(NULL, fw.ipfw.fw_dpts, fw.ipfw.fw_proto); ipfwc_create_chain(CH_INNAME); ipfwc_create_chain(CH_OUTNAME); - if (!is_classic) { - ipfwc_create_chain(CH_CTRL_IN); - ipfwc_create_chain(CH_CTRL_OUT); - strcpy(fw.label, CH_CTRL_IN); - ipfwc_delete_entry("input", &fw); - ipfwc_append_entry("input", &fw); - strcpy(fw.label, CH_CTRL_OUT); - ipfwc_delete_entry("output", &fw); - ipfwc_append_entry("output", &fw); - } strcpy(fw.label, CH_INNAME); ipfwc_delete_entry("input", &fw); ipfwc_append_entry("input", &fw); @@ -476,11 +466,6 @@ int ipchains_ipac_init(int flag) { - if (!is_classic) { - fprintf(stderr, "Neoclassic mode does not supported with " - "ipchains, aborting\n"); - exit(1); - } return 0; }; |
From: <fr...@us...> - 2003-11-13 22:42:11
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv5220 Modified Files: CHANGELOG Log Message: document changes about memory usage characteristics Index: CHANGELOG =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/CHANGELOG,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- CHANGELOG 30 Oct 2003 11:45:17 -0000 1.14 +++ CHANGELOG 13 Nov 2003 22:42:08 -0000 1.15 @@ -18,6 +18,7 @@ # 1.28 +- reduce worst case memory usage with huge database of >= 4GB to about 1.2GB (friedl) - start to remove classic mode - logging of database debug messages improved (friedl) - add option '--enable-debug-database' to configure (friedl) |
From: <fr...@us...> - 2003-11-13 22:38:32
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv4388 Modified Files: fetchipac.c Log Message: remove the leftovers of the classic mode Index: fetchipac.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/fetchipac.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- fetchipac.c 9 Nov 2003 16:38:55 -0000 1.9 +++ fetchipac.c 13 Nov 2003 22:38:23 -0000 1.10 @@ -152,130 +152,6 @@ return acc_agent->check(); } -/* -int -try_to_login(char *login_name) -{ - int tmp = 1; - user_list *ul=NULL, *ul1=NULL, *ulist=NULL; - FILE *sf; - char *tmp1; - char line[MAX_RULE_NAME_LENGTH]; - - tmp = access_agent->login(login_name); - - if (tmp) - return 1; - - while(lock(LOCKFILE)); - - if (!(sf = fopen(STATUSFILE, "r"))) { - printf("Can't open status file %s\n", STATUSFILE); - return 1; - } - while(fgets(line, MAX_RULE_NAME_LENGTH, sf)) { - ul = new_user(); - if (ul1 == NULL) - ulist = ul; - else - ul1->next = ul; - ul1=ul; - strcpy(ul->login, line); - } - fclose(sf); - ul=ulist; - if (!(sf = fopen(STATUSFILE, "w"))) { - printf("Can't open status file %s\n", STATUSFILE); - return 1; - } - while(ul) { - tmp1=strchr(ul->login, '|'); - tmp1[0]='\0'; - if (!strcmp(ul->login, login_name)) { - strcpy(ul->login, login_name); - strcpy(ul->login+strlen(ul->login), "|accept\n"); - } - tmp1[0]='|'; - fprintf(sf, "%s", ul->login); - ul=ul->next; - } - fclose(sf); - unlock(LOCKFILE); - return tmp; -} -*/ - -/* -int -try_to_logoff(char *login_name) -{ - int tmp; - user_list *ul=NULL, *ul1=NULL, *ulist=NULL; - FILE *sf; - char *tmp1; - char line[MAX_RULE_NAME_LENGTH]; - - tmp = access_agent->logout(login_name, -1); - if (tmp) - return 1; - - while(lock(LOCKFILE)); - - if (!(sf = fopen(STATUSFILE, "r"))) { - printf("Can't open status file %s\n", STATUSFILE); - return 1; - } - while(fgets(line, MAX_RULE_NAME_LENGTH, sf)) { - ul = new_user(); - if (ul1 == NULL) - ulist = ul; - else - ul1->next = ul; - ul1=ul; - strcpy(ul->login, line); - } - fclose(sf); - ul=ulist; - if (!(sf = fopen(STATUSFILE, "w"))) { - printf("Can't open status file %s\n", STATUSFILE); - return 1; - } - while(ul) { - tmp1=strchr(ul->login, '|'); - tmp1[0]='\0'; - if (!strcmp(ul->login, login_name)) { - strcpy(ul->login, login_name); - strcpy(ul->login+strlen(ul->login), "|deny\n"); - } - tmp1[0]='|'; - fprintf(sf, "%s", ul->login); - ul=ul->next; - } - fclose(sf); - unlock(LOCKFILE); - return tmp; -} -*/ - -/* -int -get_user_list(void) -{ - user_list *u; - - if(access_agent->get_user_list(&u)) { - fprintf(stderr, "access error\n"); - access_agent->close(); - return 1; - } - while (u) { - printf("'%s'\t\t'%s'\n", u->login, u->ip); - u=u->next; - } - return 0; -} -*/ - int list_raw(void) { @@ -345,21 +221,6 @@ int setup_agents(void) { -/* - setup_access(1); - if (!is_classic) { - setup_status(); - if (slogin) { - user_list *ul; - if (access_agent->get_user_list(&ul)) return 1; - while(ul) { - if (strcmp(ul->login, "admin")) - try_to_login(ul->login); - ul=ul->next; - } - } - } -*/ return setup_access(1); } |
From: <fr...@us...> - 2003-11-09 17:17:43
|
Update of /cvsroot/ipac-ng/ipac-ng/storage/postgre In directory sc8-pr-cvs1:/tmp/cvs-serv20879/storage/postgre Modified Files: postgre.c Log Message: do correct memory margin rounding Index: postgre.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/storage/postgre/postgre.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- postgre.c 9 Nov 2003 16:51:32 -0000 1.26 +++ postgre.c 9 Nov 2003 17:17:39 -0000 1.27 @@ -64,7 +64,7 @@ static int _rules_max = 0; /* a safety margin of 0.5 percent for memory allocations */ -#define MEMORY_SAFETY_MARGIN(x) (int)(x * 0.005) +#define MEMORY_SAFETY_MARGIN(x) (int)(x * 0.005 + 0.5) /* plain file ipac interface entries */ int postgre_stor_open (int flag); |
From: <fr...@us...> - 2003-11-09 16:51:35
|
Update of /cvsroot/ipac-ng/ipac-ng/storage/postgre In directory sc8-pr-cvs1:/tmp/cvs-serv14476/storage/postgre Modified Files: postgre.c Log Message: correct a comment Index: postgre.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/storage/postgre/postgre.c,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- postgre.c 9 Nov 2003 16:43:51 -0000 1.25 +++ postgre.c 9 Nov 2003 16:51:32 -0000 1.26 @@ -62,7 +62,8 @@ static int _timestamp_max = 0; static rule_type *_rules_lst = NULL; static int _rules_max = 0; -/* a safety margin for allocation memory of 0.5 percent */ + +/* a safety margin of 0.5 percent for memory allocations */ #define MEMORY_SAFETY_MARGIN(x) (int)(x * 0.005) /* plain file ipac interface entries */ |
From: <fr...@us...> - 2003-11-09 16:44:02
|
Update of /cvsroot/ipac-ng/ipac-ng/storage/postgre In directory sc8-pr-cvs1:/tmp/cvs-serv11942/storage/postgre Modified Files: postgre.c Log Message: - minimize the use of calloc calls by reusing already allocated memory - added postgre_stor_clear() which is currently used by postgre_stor_close() to clean up data held in memory, might be good to added to the general storage interface Index: postgre.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/storage/postgre/postgre.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- postgre.c 8 Nov 2003 02:43:44 -0000 1.24 +++ postgre.c 9 Nov 2003 16:43:51 -0000 1.25 @@ -57,6 +57,14 @@ static PGconn *conn; static PGresult *res; +/* the statical variables used for returning results */ +static data_record_type *_timestamp_lst = NULL; +static int _timestamp_max = 0; +static rule_type *_rules_lst = NULL; +static int _rules_max = 0; +/* a safety margin for allocation memory of 0.5 percent */ +#define MEMORY_SAFETY_MARGIN(x) (int)(x * 0.005) + /* plain file ipac interface entries */ int postgre_stor_open (int flag); int postgre_stor_store_record (const data_record_type *data); @@ -69,6 +77,7 @@ data_record_type **data, char *filter); int postgre_stor_delete_record (timestamp_t timestamp); void postgre_stor_close (); +void postgre_stor_clear (); static const storage_method_t interface_entry = { "postgre", @@ -234,9 +243,8 @@ int postgre_stor_get_records (timestamp_t timestamp_b, timestamp_t timestamp_e, data_record_type **data, char *filter) { - static rule_type *rules = NULL; - rule_type *r, *r1 = NULL; - int i, nr_timestamps, index, count; + rule_type *r, *r1 = NULL, *rules; + int i, nr_timestamps, index, nr_rules; timestamp_t timestamp_akt; char wh_exec[320]; /* char *tmp; */ @@ -304,50 +312,74 @@ PQfinish(conn); exit (-1); } - count = PQntuples (res); - DPRINTF ("result: %u data records\n", count); + nr_rules = PQntuples (res); + DPRINTF ("result: %u data records\n", nr_rules); DPRINTF ("starting to convert data into our format\n"); /* create record_data_type. */ - DPRINTF ("trying to allocate memory for timestamp list:\n"); - DPRINTF (" calloc (cnt %u, size %u) = %lu bytes\n", nr_timestamps, sizeof (data_record_type), (long)((long)nr_timestamps * (long)sizeof (data_record_type))); - *data = (data_record_type *)calloc (nr_timestamps, sizeof (data_record_type)); + if (nr_timestamps > _timestamp_max) { + /* need to increase size of data_record_type array */ + + if (_timestamp_lst != NULL) { + /* as realloc does not support a count parameter we free the old list first + and then call calloc again */ + DPRINTF ("freeing memory of old timestamp list of size %i\n", _timestamp_max); + free (_timestamp_lst); + } + + /* always add a safety margin */ + _timestamp_max = nr_timestamps + MEMORY_SAFETY_MARGIN(nr_timestamps); + + DPRINTF ("allocating memory for timestamp list with %i elements\n", _timestamp_max); + DPRINTF (" calloc (cnt %i, size %u) = %lu bytes\n", _timestamp_max, sizeof (data_record_type), (long)((long)_timestamp_max * (long)sizeof (data_record_type))); + _timestamp_lst = (data_record_type *)calloc (_timestamp_max, sizeof (data_record_type)); - if (*data == NULL) { - fprintf (stderr,"%s: data_record_type calloc(cnt %u, size %u) failed: %s\n", me, nr_timestamps, sizeof (data_record_type), strerror(errno)); + if (_timestamp_lst == NULL) { + fprintf (stderr,"%s: data_record_type calloc(cnt %i, size %u) failed: %s\n", me, _timestamp_max, sizeof (data_record_type), strerror(errno)); - DPRINTF ("failed: %s\n", strerror(errno)); + DPRINTF ("failed: %s\n", strerror(errno)); - PQclear (res); - PQfinish(conn); - exit (-1); + PQclear (res); + PQfinish(conn); + exit (-1); + } } - DPRINTF ("succeeded\n"); + *data = _timestamp_lst; /* create rule_type. */ - if (rules != NULL) { - DPRINTF ("freeing memory of old rule list\n"); - free (rules); - } - DPRINTF ("trying to allocate memory for rule list:\n"); - DPRINTF (" calloc (cnt %u, size %u) = %lu bytes\n", count, sizeof (rule_type), (long)((long)count * (long)sizeof (rule_type))); - rules = (rule_type *)calloc (count, sizeof (rule_type)); + if (nr_rules > _rules_max) { + /* need to increase size of rule_type array */ + + if (_rules_lst != NULL) { + /* as realloc does not support a count parameter we free the old list first + and then call calloc again */ + DPRINTF ("freeing memory of old timestamp list of size %i\n", _rules_max); + free (_rules_lst); + } + + /* always add a safety margin */ + _rules_max = nr_rules + MEMORY_SAFETY_MARGIN(nr_rules); + + DPRINTF ("allocating memory for rule list with %i elements\n", _rules_max); + DPRINTF (" calloc (cnt %i, size %u) = %lu bytes\n", _rules_max, sizeof (rule_type), (long)((long)_rules_max * (long)sizeof (rule_type))); + _rules_lst = (rule_type *)calloc (_rules_max, sizeof (rule_type)); - if (rules == NULL) { - fprintf (stderr,"%s: rule_type calloc(cnt %u, size %u) failed: %s\n", me, count, sizeof (rule_type), strerror(errno)); + if (_rules_lst == NULL) { + fprintf (stderr,"%s: rule_type calloc(cnt %i, size %u) failed: %s\n", me, _rules_max, sizeof (rule_type), strerror(errno)); - DPRINTF ("failed: %s\n", strerror(errno)); + DPRINTF ("failed: %s\n", strerror(errno)); - PQclear (res); - PQfinish(conn); - exit (-1); + PQclear (res); + PQfinish(conn); + exit (-1); + } } - DPRINTF ("succeeded\n"); + rules = _rules_lst; index = -1; timestamp_akt = 0; - for (i = 0; i < count; i++) { + for (i = 0; i < nr_rules; i++) { // currently timestamp_t is of type time_t which is essentially long timestamp_t tstamp_new = strtol ((char *) PQgetvalue (res,i,3), NULL, 10); if (tstamp_new != timestamp_akt) { // do we have a new timestamp? @@ -551,16 +583,43 @@ void postgre_stor_close () { - DPRINTF ("postgre_stor_close\n"); + DPRINTF ("postgre_stor_close()\n"); + + /* clean up first */ + postgre_stor_clear (); + + PQfinish (conn); + storage_opened = 0; + DPRINTF ("postgre_stor_close finished\n"); #ifdef DEBUG_DB + /* close logfile */ if (fd != -1) { close (fd); } #endif - PQfinish (conn); - storage_opened = 0; +} + +/* free data we kept in memory */ +void postgre_stor_clear () +{ + DPRINTF ("postgre_stor_clear() \n"); + + if (_timestamp_lst != NULL) { + DPRINTF ("freeing data_record_type array with %i elements\n", _timestamp_max); + free_data_record_type_array (_timestamp_lst, _timestamp_max); + _timestamp_lst = NULL; + _timestamp_max = 0; + } + + if (_rules_lst != NULL) { + DPRINTF ("freeing rule_type array with %i elements\n", _rules_max); + free (_rules_lst); + _rules_lst = NULL; + _rules_max = 0; + } + DPRINTF ("postgre_stor_clear finished\n"); } #ifdef DEBUG_DB |
From: <fr...@us...> - 2003-11-09 16:38:59
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv10091 Modified Files: fetchipac.c Log Message: - print the hostname in the output if the user used the -H/--hostname option - let the postgres storage free its data itself Index: fetchipac.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/fetchipac.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- fetchipac.c 8 Nov 2003 15:12:08 -0000 1.8 +++ fetchipac.c 9 Nov 2003 16:38:55 -0000 1.9 @@ -626,10 +626,10 @@ fprintf(f, machine_output_format ? "( %s\n" : " machine name: %s\n", /* FIXME: at the moment it's useless to - print the machine name + print the machine name returned dr->machine_name */ - ""); + (ahost != NULL) ? ahost : ""); for (r = dr->firstrule; r != NULL; r=r->next) fprintf(f, machine_output_format ? "%llu %llu |%s|\n" @@ -676,8 +676,6 @@ n = storage_method->get_records(*t, 0, &dr, filter); print_records(stdout, n, dr); - if (n>0) - free_data_record_type_array(dr, n); } if (tlist) { free (tlist); @@ -687,10 +685,11 @@ /* all other storage methodes do it the default way */ n = storage_method->get_records(timestamp_b, timestamp_e, &dr, filter); print_records(stdout, n, dr); - - if (n>0) - free_data_record_type_array(dr, n); } + + /* free memory */ + if (strcmp(storage_method->name, "postgre") && (n>0)) + free_data_record_type_array(dr, n); } storage_method->close(); |
From: <fr...@us...> - 2003-11-08 15:12:12
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv17733 Modified Files: fetchipac.c Log Message: optimize list_records(filter) for stoarage postgres so in the worst case we don't take up to or more than 4GB of RAM the downside might be that it can take longer for short-range queries but at least for now we don't run out of RAM anymore Index: fetchipac.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/fetchipac.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- fetchipac.c 8 Nov 2003 02:58:45 -0000 1.7 +++ fetchipac.c 8 Nov 2003 15:12:08 -0000 1.8 @@ -644,10 +644,10 @@ /* list record data of timestamps on standard input */ int list_records(char *filter) { - timestamp_t timestamp_b,timestamp_e; - data_record_type *dr; + timestamp_t timestamp_b, timestamp_e, *t, *tlist = NULL; + data_record_type *dr = NULL; char buf[256], *cp; - int n; + int n, i, cnt; if (!storage_opened) storage_method->open(SM_OPEN_READONLY); @@ -665,11 +665,32 @@ } else timestamp_e = 0; - n = storage_method->get_records(timestamp_b, timestamp_e, &dr, filter); - print_records(stdout, n, dr); - if (n>0) - free_data_record_type_array(dr, n); + if (timestamp_e && !strcmp(storage_method->name, "postgre")) { + /* for postgres storage and query for a timestamp range + do some memory optimizations */ + cnt = storage_method->list_timestamps(timestamp_b, timestamp_e, &tlist, + NULL, NULL, NULL); + + for (i=0, t=tlist; i<cnt; i++, t++) { + n = storage_method->get_records(*t, 0, &dr, filter); + print_records(stdout, n, dr); + + if (n>0) + free_data_record_type_array(dr, n); + } + if (tlist) { + free (tlist); + tlist = NULL; + } + } else { + /* all other storage methodes do it the default way */ + n = storage_method->get_records(timestamp_b, timestamp_e, &dr, filter); + print_records(stdout, n, dr); + + if (n>0) + free_data_record_type_array(dr, n); + } } storage_method->close(); |
From: <fr...@us...> - 2003-11-08 03:36:23
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv17444 Modified Files: subst.c Log Message: remove some extern's Index: subst.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/subst.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- subst.c 31 Oct 2003 15:53:25 -0000 1.4 +++ subst.c 8 Nov 2003 03:36:20 -0000 1.5 @@ -38,10 +38,6 @@ extern char *optarg; extern int optind; -extern void exit(); -extern char *malloc(); -extern char *strcpy(); - /* |
From: <fr...@us...> - 2003-11-08 03:22:36
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv15793 Modified Files: rule.c Log Message: we currently do not store the machine name so we do not need to free it Index: rule.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/rule.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- rule.c 8 Nov 2003 03:20:55 -0000 1.4 +++ rule.c 8 Nov 2003 03:22:33 -0000 1.5 @@ -62,9 +62,11 @@ */ void free_data_record_type_array(data_record_type *data, int n) { + /* FIXME: the following variables are only needed in the loop int i; data_record_type *dr; rule_type *r; + */ /* FIXME: there's no usefull code here so don't do the loop for (i=0, dr=data; i<n; i++, dr++) |
From: <fr...@us...> - 2003-11-08 03:20:58
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv15595 Modified Files: rule.c Log Message: we currently do not store the machine name so we do not need to free it Index: rule.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/rule.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- rule.c 8 Nov 2003 02:02:41 -0000 1.3 +++ rule.c 8 Nov 2003 03:20:55 -0000 1.4 @@ -66,10 +66,14 @@ data_record_type *dr; rule_type *r; + /* FIXME: there's no usefull code here so don't do the loop for (i=0, dr=data; i<n; i++, dr++) { + */ + /* FIXME: we currently don't store the machine name if (dr->machine_name != NULL) free(dr->machine_name); + */ /* FIXME: should delegate this to the storage module as it knows better how to free this @@ -80,7 +84,9 @@ dr->firstrule = r; } */ + /* } + */ free(data); } |
From: <fr...@us...> - 2003-11-08 02:58:48
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv12594 Modified Files: fetchipac.c Log Message: little space-tabs reformating Index: fetchipac.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/fetchipac.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- fetchipac.c 8 Nov 2003 02:02:41 -0000 1.6 +++ fetchipac.c 8 Nov 2003 02:58:45 -0000 1.7 @@ -4,7 +4,7 @@ * * Fetch IP accounting stats * Copyright (C) 1997 - 2000 Moritz Both - * (C) 2001 - 2003 Al Zakharov + * (C) 2001 - 2003 Al Zakharov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -52,7 +52,7 @@ /** name of the program */ const char *me; -/** the directory with the database. +/** the directory with the database. * At least for plain-file and gdbm storage backend - and in any case for * the spool file. */ @@ -77,11 +77,11 @@ /** the current accounting agent */ const acc_agent_t *acc_agent; - + const access_agent_t **access_agents; const access_agent_t *access_agent; - + /** flag for output format. 0=user readable, * 1=for machine (ipacsum) */ int machine_output_format = 0; @@ -175,10 +175,10 @@ } while(fgets(line, MAX_RULE_NAME_LENGTH, sf)) { ul = new_user(); - if (ul1 == NULL) - ulist = ul; - else - ul1->next = ul; + if (ul1 == NULL) + ulist = ul; + else + ul1->next = ul; ul1=ul; strcpy(ul->login, line); } @@ -227,10 +227,10 @@ } while(fgets(line, MAX_RULE_NAME_LENGTH, sf)) { ul = new_user(); - if (ul1 == NULL) - ulist = ul; - else - ul1->next = ul; + if (ul1 == NULL) + ulist = ul; + else + ul1->next = ul; ul1=ul; strcpy(ul->login, line); } @@ -276,7 +276,7 @@ } */ -int +int list_raw(void) { raw_rule_type *r; @@ -293,15 +293,15 @@ "------------------------------------------------------\n"); while(r) { printf("%-20s | %-13s | %-5s | %-5s | %-18s %s | %-18s %s | %-9s | %-8s",r->name, - r->dest,r->iface,r->protocol,r->snet,r->sport,r->dnet, - r->dport,r->direction,r->policy); + r->dest,r->iface,r->protocol,r->snet,r->sport,r->dnet, + r->dport,r->direction,r->policy); for (i=0;i<8;i++) { if (r->extension[i]) printf(" %-8s ", r->extension[i]); } printf("\n"); r = r->next; - } + } return 0; } @@ -312,12 +312,12 @@ if(acc_agent->init(0)) { perror("Failed to initialize accounting agent, " - "aborting operations\n"); + "aborting operations\n"); return 1; } if(acc_agent->set(&tmp, first)) { perror("Failed to setup accounting agent, " - "aborting operations\n"); + "aborting operations\n"); return 1; } return 0; @@ -341,7 +341,7 @@ fclose(sf); return 0; } - + int setup_agents(void) { @@ -383,9 +383,9 @@ if (!hostname) { if (gethostname(hname, 256) != 0) { - strcpy(hname, "(unknown host)"); + strcpy(hname, "(unknown host)"); fprintf(stderr, "%s warning: cant get hostname, " - "using '%s': %s\n", + "using '%s': %s\n", me, hname, strerror(errno)); } else hostname = xstrdup(hname); @@ -396,7 +396,7 @@ * @see storage_methods */ void -create_storage_methods() +create_storage_methods() { int i; const storage_method_t **p; @@ -414,7 +414,7 @@ /** create array acc_agents * @see acc_agents */ -void create_acc_agents() +void create_acc_agents() { int i; const acc_agent_t **p; @@ -432,7 +432,7 @@ /** create array acc_agents * @see access_agents */ -void create_access_agents() +void create_access_agents() { int i; const access_agent_t **p; @@ -466,13 +466,13 @@ strftime(s, 29, "%c", tmp); } -/* +/* * Some work to make sure that all rules are switched on and we can bill * for traffic on them.. then decrement limits at database and cut off user in * case there are no more bucks */ /* -int +int check_cash(const data_record_type *data) { rule_type *d; @@ -482,7 +482,7 @@ char *last_paid; was_locked = lock(LOCKFILE); - if (was_locked) + if (was_locked) unlock(LOCKFILE); d = data->firstrule; @@ -498,22 +498,22 @@ { case 1: // price for a byte new_cash = old_cash - - (d->bytes*price); + (d->bytes*price); break; case 15: last_paid = access_agent-> get_last_paid(d->name); if (!fnmatch("*mon*", last_paid, 0)|| !fnmatch("*year*", last_paid, 0)) { - new_cash = old_cash - + new_cash = old_cash - price; access_agent->set_last_paid( - d->name, "1 mons"); + d->name, "1 mons"); } break; } if (old_cash!=new_cash) - access_agent->set_cash(d->name, new_cash); + access_agent->set_cash(d->name, new_cash); // drop connections to that user if (new_cash<=0) { access_agent->logout(d->name, new_cash); @@ -544,7 +544,7 @@ &before, &after, ahost); if (n > 0) { - printf(machine_output_format ? "%d\n" + printf(machine_output_format ? "%d\n" : "number of timestamps found: %d\n", n); if (before != (timestamp_t)-1) { if (machine_output_format) @@ -580,7 +580,7 @@ } } } else - printf(machine_output_format ? "0\n" + printf(machine_output_format ? "0\n" : "number of timestamps found: 0\n"); if (n > 0) free(tlist); @@ -600,7 +600,7 @@ */ /* print a record on file descriptor f */ -int +int print_records(FILE *f, int n, const data_record_type *dr) { char buf[256]; @@ -614,18 +614,18 @@ for (i=0; i<n; i++, dr++) { fprintf(f, "%s%lu ", machine_output_format ? "ADD\n":"timstamp: ", - dr->timestamp); - if (machine_output_format == 0) { - nice_time(dr->timestamp, buf); - fprintf(f, "(%s) ", buf); - } - fprintf(f, "%s1\n", machine_output_format ? "": + dr->timestamp); + if (machine_output_format == 0) { + nice_time(dr->timestamp, buf); + fprintf(f, "(%s) ", buf); + } + fprintf(f, "%s1\n", machine_output_format ? "": "number of records: "); if (machine_output_format == 0 && n>1) fprintf(f, " record number: 1\n"); fprintf(f, machine_output_format ? "( %s\n" : " machine name: %s\n", - /* FIXME: at the moment it's useless to + /* FIXME: at the moment it's useless to print the machine name dr->machine_name */ @@ -649,7 +649,7 @@ char buf[256], *cp; int n; - if (!storage_opened) + if (!storage_opened) storage_method->open(SM_OPEN_READONLY); while(fgets(buf, 256, stdin) != NULL) { @@ -659,12 +659,12 @@ while (*cp!=0 && *cp==' ') cp++; timestamp_b = strtoul(cp, &cp, 0); - if (*cp == '-') { //we also have an end timestamp - cp++; - timestamp_e = strtoul(cp, NULL, 0); + if (*cp == '-') { //we also have an end timestamp + cp++; + timestamp_e = strtoul(cp, NULL, 10); } - else - timestamp_e = 0; + else + timestamp_e = 0; n = storage_method->get_records(timestamp_b, timestamp_e, &dr, filter); print_records(stdout, n, dr); @@ -677,10 +677,10 @@ return 0; } -int print_summary(timestamp_t tstart, timestamp_t tend, +int print_summary(timestamp_t tstart, timestamp_t tend, char *ahost, char *filter) { - data_record_type *dr; + data_record_type *dr; int n; storage_method->open(SM_OPEN_READONLY); @@ -780,7 +780,7 @@ newf = fopen(spoolfile_new, "w"); if (newf == NULL) { fprintf(stderr, "%s: cant open new spool file " - "\"%s\": %s\n", me, + "\"%s\": %s\n", me, spoolfile_new, strerror(errno)); fclose(f); @@ -789,7 +789,7 @@ do { if (fputs(line, newf) == EOF) { fprintf(stderr, "%s: cant write to file" - "\"%s\": %s\n", me, + "\"%s\": %s\n", me, spoolfile_new, strerror(errno)); fclose(newf); @@ -799,7 +799,7 @@ } while(fgets(line, 256, f) != NULL); if (ferror(f)) { fprintf(stderr, "%s: error reading from spool " - "file: %s", me, + "file: %s", me, strerror(errno)); fclose(f); fclose(newf); @@ -809,7 +809,7 @@ fflush(newf); if (ferror(newf)) { fprintf(stderr, "%s: error writing to new spool" - " file: %s", me, + " file: %s", me, strerror(errno)); fclose(newf); return; @@ -817,7 +817,7 @@ fclose(newf); if (rename(spoolfile_new, spoolfile) != 0) { fprintf(stderr, "%s: error renaming \"%s\" to " - "\"%s\": %s\n", me, + "\"%s\": %s\n", me, spoolfile_new, spoolfile, strerror(errno)); } @@ -866,8 +866,8 @@ static struct option long_options[] = { { "agent", required_argument, NULL, 'a' }, { "config", required_argument, NULL, 'C' }, - { "filter", required_argument, NULL, 'f' }, - { "start", no_argument, NULL, 'S' }, + { "filter", required_argument, NULL, 'f' }, + { "start", no_argument, NULL, 'S' }, { "list-raw", no_argument, NULL, 'R' }, { "ahost", required_argument, NULL, 'H' }, { "batch", no_argument, NULL, 'b' }, @@ -897,7 +897,7 @@ /* parse command line */ while(1) { - c = getopt_long(argc, argv, "a:L:O:C:f:SRUH:bd:vhmu::r::c:s:t::e", + c = getopt_long(argc, argv, "a:L:O:C:f:SRUH:bd:vhmu::r::c:s:t::e", long_options, NULL); if (c==EOF) break; @@ -1047,7 +1047,7 @@ return list_records(filter); case 3: return batchmode(); - case 4: + case 4: return list_raw(); case 5: return setup_agents(); @@ -1098,7 +1098,7 @@ &before, &after); if (tmp>0) t++; } -*/ +*/ if (acc_agent->read(&firstrule) == 0) { data_record.timestamp = t; data_record.firstrule = firstrule; @@ -1112,8 +1112,8 @@ while (rule1) { if (rule1->pkts==0) rule2->next=rule1->next; - else - rule2=rule1; + else + rule2=rule1; rule1=rule1->next; } } |
From: <fr...@us...> - 2003-11-08 02:43:47
|
Update of /cvsroot/ipac-ng/ipac-ng/storage/postgre In directory sc8-pr-cvs1:/tmp/cvs-serv10813 Modified Files: postgre.c Log Message: optimize postgre_stor_get_records() for queries about just one timestamp Index: postgre.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/storage/postgre/postgre.c,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- postgre.c 8 Nov 2003 02:02:41 -0000 1.23 +++ postgre.c 8 Nov 2003 02:43:44 -0000 1.24 @@ -157,7 +157,7 @@ sprintf (wh_exec, "SELECT distinct that_time FROM logs WHERE "); if (ahost) - sprintf (wh_exec+strlen (wh_exec), "hostname = '%s' ", ahost); + sprintf (wh_exec+strlen (wh_exec), "hostname = '%s' AND ", ahost); sprintf (wh_exec+strlen (wh_exec), "that_time between %lu and %lu " "ORDER BY that_time ASC", start, end); @@ -234,7 +234,8 @@ int postgre_stor_get_records (timestamp_t timestamp_b, timestamp_t timestamp_e, data_record_type **data, char *filter) { - rule_type *r, *r1 = NULL, *rules; + static rule_type *rules = NULL; + rule_type *r, *r1 = NULL; int i, nr_timestamps, index, count; timestamp_t timestamp_akt; char wh_exec[320]; @@ -243,54 +244,51 @@ DPRINTF ("postgre_stor_get_records (%lu, %lu, **data, %s)\n", timestamp_b, timestamp_e, (filter!=NULL) ? filter : "NULL"); - if (!timestamp_e) - timestamp_e = timestamp_b; - - if (ahost) - sprintf (wh_exec, "SELECT count (distinct that_time) FROM logs " - "WHERE hostname = '%s' and " - "that_time between '%lu' and '%lu'", - ahost, timestamp_b, timestamp_e); - else - sprintf (wh_exec, "SELECT count (distinct that_time) FROM logs " - "WHERE " - "that_time between '%lu' and '%lu'", - timestamp_b, timestamp_e); - if (filter) - sprintf (wh_exec+strlen (wh_exec), " and rule_name like '%%%s%%'", filter); + if (timestamp_e) { + sprintf (wh_exec, "SELECT count (distinct that_time) FROM logs WHERE "); + if (ahost) + sprintf (wh_exec+strlen (wh_exec), "hostname = '%s' AND ", ahost); + sprintf (wh_exec+strlen (wh_exec), "that_time between '%lu' and '%lu'", + timestamp_b, timestamp_e); + if (filter) + sprintf (wh_exec+strlen (wh_exec), " AND rule_name like '%%%s%%'", + filter); - DPRINTF ("%s\n", wh_exec); + DPRINTF ("%s\n", wh_exec); - res = PQexec (conn, wh_exec); - if (!res || PQresultStatus (res) != PGRES_TUPLES_OK) { - fprintf (stderr, "%s: PQexec of (%s) command didn't return tuples" - " properly\nlibpq says: %s", me, wh_exec, - PQresultErrorMessage (res)); + res = PQexec (conn, wh_exec); + if (!res || PQresultStatus (res) != PGRES_TUPLES_OK) { + fprintf (stderr, "%s: PQexec of (%s) command didn't return tuples" + " properly\nlibpq says: %s", me, wh_exec, + PQresultErrorMessage (res)); - DPRINTF ("%s\n", PQresultErrorMessage (res)); + DPRINTF ("%s\n", PQresultErrorMessage (res)); + PQclear (res); + PQfinish(conn); + exit (-1); + } + nr_timestamps = strtol (PQgetvalue (res,0,0),0,0); + DPRINTF ("result: %u timestamps\n", nr_timestamps); PQclear (res); - PQfinish(conn); - exit (-1); + } else { + nr_timestamps = 1; + DPRINTF ("searching for exactly one timestamp: %u\n", timestamp_b); } - nr_timestamps = strtol (PQgetvalue (res,0,0),0,0); - DPRINTF ("result: %u timestamps\n", nr_timestamps); - PQclear (res); + sprintf (wh_exec, "SELECT rule_name, bytes, pkts, that_time, hostname FROM logs WHERE "); if (ahost) - sprintf (wh_exec, "SELECT rule_name, bytes, pkts, that_time, hostname FROM logs " - "WHERE " - "hostname = '%s' and that_time between '%lu' and '%lu' ", - ahost, timestamp_b, timestamp_e); - else - sprintf (wh_exec, "SELECT rule_name, bytes, pkts, that_time, hostname FROM logs " - "WHERE " - "that_time between '%lu' and '%lu' ", - timestamp_b, timestamp_e); + sprintf (wh_exec+strlen (wh_exec), "hostname = '%s' AND ", ahost); + if (timestamp_e) { + sprintf (wh_exec+strlen (wh_exec), "that_time between '%lu' and '%lu'", + timestamp_b, timestamp_e); + } else { + sprintf (wh_exec+strlen (wh_exec), "that_time = '%lu'", timestamp_b); + } if (filter) - sprintf (wh_exec+strlen (wh_exec), " and rule_name like '%%%s%%'", filter); - - sprintf (wh_exec+strlen (wh_exec), " ORDER BY that_time"); + sprintf (wh_exec+strlen (wh_exec), " AND rule_name like '%%%s%%'", filter); + if (timestamp_e) + sprintf (wh_exec+strlen (wh_exec), " ORDER BY that_time"); DPRINTF ("%s\n", wh_exec); @@ -328,6 +326,10 @@ DPRINTF ("succeeded\n"); /* create rule_type. */ + if (rules != NULL) { + DPRINTF ("freeing memory of old rule list\n"); + free (rules); + } DPRINTF ("trying to allocate memory for rule list:\n"); DPRINTF (" calloc (cnt %u, size %u) = %lu bytes\n", count, sizeof (rule_type), (long)((long)count * (long)sizeof (rule_type))); rules = (rule_type *)calloc (count, sizeof (rule_type)); |
From: <fr...@us...> - 2003-11-08 02:02:48
|
Update of /cvsroot/ipac-ng/ipac-ng/storage/postgre In directory sc8-pr-cvs1:/tmp/cvs-serv5399/storage/postgre Modified Files: postgre.c Log Message: - improve memory handling in storage/postgre - add more debugging there too - machine name is not handled correctly at the moment so comment it out where needed and print an empty one Index: postgre.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/storage/postgre/postgre.c,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- postgre.c 5 Oct 2003 00:02:50 -0000 1.22 +++ postgre.c 8 Nov 2003 02:02:41 -0000 1.23 @@ -234,10 +234,11 @@ int postgre_stor_get_records (timestamp_t timestamp_b, timestamp_t timestamp_e, data_record_type **data, char *filter) { - rule_type *r, *r1 = NULL; - int i, nr_timestamps, index; + rule_type *r, *r1 = NULL, *rules; + int i, nr_timestamps, index, count; timestamp_t timestamp_akt; char wh_exec[320]; + /* char *tmp; */ DPRINTF ("postgre_stor_get_records (%lu, %lu, **data, %s)\n", timestamp_b, timestamp_e, (filter!=NULL) ? filter : "NULL"); @@ -262,17 +263,18 @@ res = PQexec (conn, wh_exec); if (!res || PQresultStatus (res) != PGRES_TUPLES_OK) { - fprintf (stderr, "PQexec of (%s) command didn't return tuples" - " properly\nlibpq says: %s", wh_exec, + fprintf (stderr, "%s: PQexec of (%s) command didn't return tuples" + " properly\nlibpq says: %s", me, wh_exec, PQresultErrorMessage (res)); - DPRINTF ("%s: %s\n", me, PQresultErrorMessage (res)); + DPRINTF ("%s\n", PQresultErrorMessage (res)); PQclear (res); PQfinish(conn); exit (-1); } nr_timestamps = strtol (PQgetvalue (res,0,0),0,0); + DPRINTF ("result: %u timestamps\n", nr_timestamps); PQclear (res); if (ahost) @@ -294,47 +296,98 @@ res = PQexec (conn, wh_exec); if (!res || PQresultStatus (res) != PGRES_TUPLES_OK) { - fprintf (stderr, "PQexec of (%s) command didn't return tuples" - " properly\nlibpq says: %s", wh_exec, + fprintf (stderr, "%s: PQexec of (%s) command didn't return tuples" + " properly\nlibpq says: %s", me, wh_exec, PQresultErrorMessage (res)); - DPRINTF ("%s: %s\n", me, PQresultErrorMessage (res)); + DPRINTF ("%s\n", PQresultErrorMessage (res)); PQclear (res); PQfinish(conn); exit (-1); } + count = PQntuples (res); + DPRINTF ("result: %u data records\n", count); DPRINTF ("starting to convert data into our format\n"); /* create record_data_type. */ - *data = (data_record_type *)xmalloc (sizeof (data_record_type) * nr_timestamps); + DPRINTF ("trying to allocate memory for timestamp list:\n"); + DPRINTF (" calloc (cnt %u, size %u) = %lu bytes\n", nr_timestamps, sizeof (data_record_type), (long)((long)nr_timestamps * (long)sizeof (data_record_type))); + *data = (data_record_type *)calloc (nr_timestamps, sizeof (data_record_type)); + + if (*data == NULL) { + fprintf (stderr,"%s: data_record_type calloc(cnt %u, size %u) failed: %s\n", me, nr_timestamps, sizeof (data_record_type), strerror(errno)); + + DPRINTF ("failed: %s\n", strerror(errno)); + + PQclear (res); + PQfinish(conn); + exit (-1); + } + DPRINTF ("succeeded\n"); + + /* create rule_type. */ + DPRINTF ("trying to allocate memory for rule list:\n"); + DPRINTF (" calloc (cnt %u, size %u) = %lu bytes\n", count, sizeof (rule_type), (long)((long)count * (long)sizeof (rule_type))); + rules = (rule_type *)calloc (count, sizeof (rule_type)); + + if (rules == NULL) { + fprintf (stderr,"%s: rule_type calloc(cnt %u, size %u) failed: %s\n", me, count, sizeof (rule_type), strerror(errno)); + + DPRINTF ("failed: %s\n", strerror(errno)); + + PQclear (res); + PQfinish(conn); + exit (-1); + } + DPRINTF ("succeeded\n"); index = -1; timestamp_akt = 0; - for (i = 0; i < PQntuples (res); i++) { + for (i = 0; i < count; i++) { // currently timestamp_t is of type time_t which is essentially long timestamp_t tstamp_new = strtol ((char *) PQgetvalue (res,i,3), NULL, 10); if (tstamp_new != timestamp_akt) { // do we have a new timestamp? timestamp_akt = tstamp_new; index++; if (index > nr_timestamps) { - fprintf (stderr,"We got more records then timestamps " - "were reported before. This should not happen\n"); + fprintf (stderr,"%s: We got more records than timestamps " + "were reported before. This should not happen!\n", me); - DPRINTF ("%s: %s\n", me, PQresultErrorMessage (res)); + DPRINTF ("We got more records than timestamps " + "were reported before. This should not happen!\n"); PQclear (res); PQfinish(conn); exit (-1); } (*data)[index].timestamp = timestamp_akt; - (*data)[index].machine_name = xstrdup ((char *) PQgetvalue (res, i, 4)); + /* FIXME: storing only the first machine name found is crap + so there's no need to store the machine name anyway + + tmp = (char *)PQgetvalue (res, i, 4); + (*data)[index].machine_name = calloc(1, strlen(tmp)+1); + + if ((*data)[index].machine_name == NULL) { + fprintf (stderr,"%s: calloc(1, size %u) for string \"%s\" failed: %s\n", me, strlen(tmp)+1, tmp, strerror(errno)); + + DPRINTF ("calloc(1, size %u) for string \"%s\" failed: %s\n", strlen(tmp)+1, tmp, strerror(errno)); + + PQclear (res); + PQfinish(conn); + exit (-1); + } + memcpy((*data)[index].machine_name, tmp, strlen(tmp)+1); */ + (*data)[index].machine_name = NULL; + (*data)[index].firstrule = NULL; r1 = NULL; } - r = new_rule (); + r = &rules[i]; + r->next = NULL; + if (r1 == NULL) (*data)[index].firstrule = r; else |
From: <fr...@us...> - 2003-11-08 02:02:45
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv5399 Modified Files: fetchipac.c rule.c Log Message: - improve memory handling in storage/postgre - add more debugging there too - machine name is not handled correctly at the moment so comment it out where needed and print an empty one Index: fetchipac.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/fetchipac.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- fetchipac.c 3 Nov 2003 15:13:13 -0000 1.5 +++ fetchipac.c 8 Nov 2003 02:02:41 -0000 1.6 @@ -625,7 +625,11 @@ fprintf(f, " record number: 1\n"); fprintf(f, machine_output_format ? "( %s\n" : " machine name: %s\n", - dr->machine_name); + /* FIXME: at the moment it's useless to + print the machine name + dr->machine_name + */ + ""); for (r = dr->firstrule; r != NULL; r=r->next) fprintf(f, machine_output_format ? "%llu %llu |%s|\n" Index: rule.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/rule.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- rule.c 6 Jul 2003 11:34:51 -0000 1.2 +++ rule.c 8 Nov 2003 02:02:41 -0000 1.3 @@ -70,12 +70,16 @@ { if (dr->machine_name != NULL) free(dr->machine_name); + /* FIXME: should delegate this to the storage module + as it knows better how to free this + while(dr->firstrule != NULL) { r = dr->firstrule->next; free(dr->firstrule); dr->firstrule = r; } + */ } free(data); } |
From: <fr...@us...> - 2003-11-08 01:23:42
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv32406 Modified Files: configure configure.in Makefile.in Log Message: add --enable-debug-ipacsum=yes|no to configure Index: configure =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/configure,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- configure 31 Oct 2003 15:20:53 -0000 1.6 +++ configure 8 Nov 2003 01:23:37 -0000 1.7 @@ -309,7 +309,7 @@ #endif" ac_subdirs_all="$ac_subdirs_all $configure_dirs" -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS VERSION MANTIME CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT AWK YACC LEX LEXLIB LEX_OUTPUT_ROOT IPCHAINS IPTABLES MKTEMP PERL CPP EGREP TMP DATDELIM STORAGEMETHODS STORAGEMETHODLIBRARYS DEFAULT_STORAGE BILLAGENTS BILLAGENTSLIBRARYS DEFAULT_ACCESS CONFDIR CONFFILE ACCAGENTS ACCAGENTSLIBRARYS DEFAULT_AGENT IPT_LIB_DIR IPFWADM_PROC IPCHAINS_PROC_C IPCHAINS_PROC_N CH_CTRL_IN CH_CTRL_OUT CH_INNAME CH_OUTNAME ipac_datadir RUNFILE PIDFILE RECONFLAG STATUSFILE LOCKFILE DBASE DBASE_PORT WEB_HOST WEB_LOGIN WEB_PASS subdirs LIBOBJS LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS VERSION MANTIME CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT AWK YACC LEX LEXLIB LEX_OUTPUT_ROOT IPCHAINS IPTABLES MKTEMP PERL CPP EGREP TMP DATDELIM STORAGEMETHODS STORAGEMETHODLIBRARYS DEFAULT_STORAGE BILLAGENTS BILLAGENTSLIBRARYS DEFAULT_ACCESS CONFDIR CONFFILE ACCAGENTS ACCAGENTSLIBRARYS DEFAULT_AGENT DBSTRIP IPT_LIB_DIR IPFWADM_PROC IPCHAINS_PROC_C IPCHAINS_PROC_N CH_CTRL_IN CH_CTRL_OUT CH_INNAME CH_OUTNAME ipac_datadir RUNFILE PIDFILE RECONFLAG STATUSFILE LOCKFILE DBASE DBASE_PORT WEB_HOST WEB_LOGIN WEB_PASS subdirs LIBOBJS LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -854,6 +854,7 @@ possible accounting agents is ipchains and any additional ones which are stored under agents/. The default is iptables. +--enable-debug-ipacsum=yes|no enable debugging in ipacsum. --enable-debug-database=yes|no switch on debugging of all accesses to the backend database. @@ -3983,6 +3984,31 @@ +echo "$as_me:$LINENO: checking if ipacsum debugging is desired" >&5 +echo $ECHO_N "checking if ipacsum debugging is desired... $ECHO_C" >&6 +IP_COMMENT="" +# Check whether --enable-debug-ipacsum or --disable-debug-ipacsum was given. +if test "${enable_debug_ipacsum+set}" = set; then + enableval="$enable_debug_ipacsum" + DEBUG_IPACSUM=$enableval +else + DEBUG_IPACSUM="" +fi; +if test x$DEBUG_IPACSUM = x; then + DEBUG_IPACSUM="no" + IP_COMMENT=" (default)" +else + IP_COMMENT=" (set by user)" +fi +if test x$DEBUG_IPACSUM = xyes; then + DBSTRIP="" +else + DBSTRIP="dbstrip" +fi +echo "$as_me:$LINENO: result: $DEBUG_IPACSUM$IP_COMMENT" >&5 +echo "${ECHO_T}$DEBUG_IPACSUM$IP_COMMENT" >&6 + + echo "$as_me:$LINENO: checking if database debugging is desired" >&5 echo $ECHO_N "checking if database debugging is desired... $ECHO_C" >&6 IP_COMMENT="" @@ -4934,6 +4960,7 @@ s,@ACCAGENTS@,$ACCAGENTS,;t t s,@ACCAGENTSLIBRARYS@,$ACCAGENTSLIBRARYS,;t t s,@DEFAULT_AGENT@,$DEFAULT_AGENT,;t t +s,@DBSTRIP@,$DBSTRIP,;t t s,@IPT_LIB_DIR@,$IPT_LIB_DIR,;t t s,@IPFWADM_PROC@,$IPFWADM_PROC,;t t s,@IPCHAINS_PROC_C@,$IPCHAINS_PROC_C,;t t Index: configure.in =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/configure.in,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- configure.in 31 Oct 2003 15:20:53 -0000 1.6 +++ configure.in 8 Nov 2003 01:23:37 -0000 1.7 @@ -359,6 +359,26 @@ AC_DEFINE_UNQUOTED(DEFAULT_AGENT,"$DEFAULT_AGENT") AC_SUBST(DEFAULT_AGENT) +dnl Check if ipacsum debugging is on +AC_MSG_CHECKING([if ipacsum debugging is desired]) +IP_COMMENT="" +AC_ARG_ENABLE(debug-ipacsum, +[--enable-debug-ipacsum=yes|no enable debugging in ipacsum.], + DEBUG_IPACSUM=$enableval,DEBUG_IPACSUM="") +if test x$DEBUG_IPACSUM = x; then + DEBUG_IPACSUM="no" + IP_COMMENT=" (default)" +else + IP_COMMENT=" (set by user)" +fi +if test x$DEBUG_IPACSUM = xyes; then + DBSTRIP="" +else + DBSTRIP="dbstrip" +fi +AC_MSG_RESULT([$DEBUG_IPACSUM$IP_COMMENT]) +AC_SUBST(DBSTRIP) + dnl Check if database debugging is on AC_MSG_CHECKING([if database debugging is desired]) IP_COMMENT="" Index: Makefile.in =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/Makefile.in,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Makefile.in 31 Oct 2003 15:53:25 -0000 1.3 +++ Makefile.in 8 Nov 2003 01:23:37 -0000 1.4 @@ -69,7 +69,7 @@ # subst may have changed Makefile! -install: all dbstrip +install: all @DBSTRIP@ make doinstall doinstall: install-bin install-man |
From: <fr...@us...> - 2003-11-08 00:10:33
|
Update of /cvsroot/ipac-ng/ipac-ng/doc In directory sc8-pr-cvs1:/tmp/cvs-serv20905/doc Added Files: tips-and-tricks Log Message: starting a list of tips-and-tricks --- NEW FILE: tips-and-tricks --- Q: How can I test ipacsum by running if from the source directory without installing it in the system? A: Run the following configure command (add other options if needed): ./configure --prefix=${PWD%/*} --sbindir='${exec_prefix}'/${PWD##*/} |
From: <fr...@us...> - 2003-11-08 00:08:57
|
Update of /cvsroot/ipac-ng/ipac-ng/doc In directory sc8-pr-cvs1:/tmp/cvs-serv20599/doc Log Message: Directory /cvsroot/ipac-ng/ipac-ng/doc added to the repository |
From: <fr...@us...> - 2003-11-06 19:49:20
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv23149 Modified Files: ipacsum Log Message: fix for perl 5.8.0 Index: ipacsum =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/ipacsum,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- ipacsum 30 Oct 2003 11:45:17 -0000 1.9 +++ ipacsum 6 Nov 2003 19:49:15 -0000 1.10 @@ -323,7 +323,7 @@ } if ($opt_human_kilo) { - C_QU = C_QU_H; + @C_QU = @C_QU_H; } |
From: <kai...@us...> - 2003-11-03 15:13:16
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv21739 Modified Files: fetchipac.c Log Message: non classic mode removal part 3 (we can compile it now) Index: fetchipac.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/fetchipac.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- fetchipac.c 30 Oct 2003 11:45:17 -0000 1.4 +++ fetchipac.c 3 Nov 2003 15:13:13 -0000 1.5 @@ -1025,7 +1025,6 @@ fprintf(stderr, "%s: error while opening access database\n", me); access_opened = 0; fprintf(stderr, "cant operate while database access is absent\n"); - acc_agent->alarm(); return 1; } spoolfile = xmalloc(strlen(datadir) + sizeof(SPOOLFILE) + 10); |
From: <fr...@us...> - 2003-10-31 15:53:28
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv6954 Modified Files: Makefile.in subst.c Log Message: add CFLAGS to compile of subst and remove some warnings there Index: Makefile.in =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/Makefile.in,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Makefile.in 6 Jul 2003 11:34:51 -0000 1.2 +++ Makefile.in 31 Oct 2003 15:53:25 -0000 1.3 @@ -93,7 +93,7 @@ subst: subst.c - $(CC) -o subst subst.c + $(CC) $(CFLAGS) -o subst subst.c fetchipac: fetchipac.o storagetable.o billtable.o agenttable.o batch.tab.o libipac.a batch.yy.o\ conffile.tab.o conffile.yy.o\ Index: subst.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/subst.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- subst.c 31 Oct 2003 15:39:28 -0000 1.3 +++ subst.c 31 Oct 2003 15:53:25 -0000 1.4 @@ -6,6 +6,8 @@ #include <string.h> #include <signal.h> #include <errno.h> +#include <unistd.h> +#include <stdlib.h> #include <sys/stat.h> #define LINESIZE 1024 |
From: <fr...@us...> - 2003-10-31 15:39:32
|
Update of /cvsroot/ipac-ng/ipac-ng In directory sc8-pr-cvs1:/tmp/cvs-serv4295 Modified Files: subst.c Log Message: remove compiler warning by using strerror instead of sys_errlist[] Index: subst.c =================================================================== RCS file: /cvsroot/ipac-ng/ipac-ng/subst.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- subst.c 6 Jul 2003 11:34:51 -0000 1.2 +++ subst.c 31 Oct 2003 15:39:28 -0000 1.3 @@ -3,6 +3,7 @@ ** A C version of Henry Spencer's "subst" script. */ #include <stdio.h> +#include <string.h> #include <signal.h> #include <errno.h> #include <sys/stat.h> @@ -23,11 +24,6 @@ #define NEED_GETOPT */ -/* Linux and FreeBSD have sys_errlist defined in their stdio.h files. */ -#if !defined(__FreeBSD__) && !defined(__linux__) -extern char *sys_errlist[]; -#endif - typedef struct _PAIR { @@ -53,17 +49,13 @@ /* ** Return string represtation of errno. */ -static char * +static inline char * xstrerror() { extern int sys_nerr; extern int errno; - static char buff[30]; - if (errno >= 0 && errno < sys_nerr) - return (char *) (sys_errlist[errno]); - (void)sprintf(buff, "Error code %d\n", errno); - return buff; + return strerror(errno); } |