improved performance

This commit is contained in:
luethje 1997-03-23 23:11:48 +00:00
parent 14c6bb242c
commit 3b5555f28f
6 changed files with 92 additions and 63 deletions

View File

@ -1,4 +1,4 @@
## $Id: Makefile.in,v 1.1 1997/03/23 19:22:33 fritz Exp $
## $Id: Makefile.in,v 1.2 1997/03/23 23:11:48 luethje Exp $
##
## ISDN accounting for isdn4linux.
##
@ -19,6 +19,9 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## $Log: Makefile.in,v $
## Revision 1.2 1997/03/23 23:11:48 luethje
## improved performance
##
## Revision 1.1 1997/03/23 19:22:33 fritz
## Make isdnlog configurable.
##
@ -108,7 +111,7 @@ SERVICEFILE = /etc/services
# DON'T EDIT BELOW THIS LINE
######################################################################
VERSION = 2.99.1
VERSION = 2.99.2
ifeq ($(POSTGRES),1)
CFLAGS += -DPOSTGRES

View File

@ -1,4 +1,4 @@
/* $Id: functions.c,v 1.1 1997/03/16 20:58:39 luethje Exp $
/* $Id: functions.c,v 1.2 1997/03/23 23:11:53 luethje Exp $
*
* ISDN accounting for isdn4linux. (log-module)
*
@ -169,13 +169,13 @@ void logger(int chan)
if ((tries < 1000) && ((flog = fdopen(fd, "a")) == (FILE *)NULL))
print_msg(PRT_ERR, "Can not open file `%s': %s!\n", logname, strerror(errno));
else {
fprintf(flog, "%s|%-16s|%-16s|%5d|%10d|%10d|%5d|%c|%3d|%10ld|%10ld|%d.%d|%d|%d|%g|%s|%8.2f|\n",
fprintf(flog, "%s|%-16s|%-16s|%5d|%10d|%10d|%5d|%c|%3d|%10ld|%10ld|%s|%d|%d|%g|%s|%8.2f|\n",
s + 4, call[chan].num[CALLING], call[chan].num[CALLED],
(int)(call[chan].disconnect - call[chan].connect),
(int)call[chan].duration, (int)call[chan].connect,
call[chan].aoce, call[chan].dialin ? 'I' : 'O',
call[chan].cause, call[chan].ibytes, call[chan].obytes,
LOG_MAJOR_VERSION, LOG_MINOR_VERSION, call[chan].si1, call[chan].si11,
LOG_VERSION, call[chan].si1, call[chan].si11,
currency_factor, currency, call[chan].pay);
fclose(flog);

View File

@ -1,4 +1,4 @@
/* $Id: isdnlog.h,v 1.2 1997/03/23 20:55:41 luethje Exp $
/* $Id: isdnlog.h,v 1.3 1997/03/23 23:11:54 luethje Exp $
*
* ISDN accounting for isdn4linux.
*
@ -19,6 +19,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: isdnlog.h,v $
* Revision 1.3 1997/03/23 23:11:54 luethje
* improved performance
*
* Revision 1.2 1997/03/23 20:55:41 luethje
* some bugfixes
*
@ -76,11 +79,6 @@
/****************************************************************************/
#define LOG_MAJOR_VERSION 3
#define LOG_MINOR_VERSION 0
/****************************************************************************/
#define MAX_CALLS_IN_QUEUE 100
#define MAX_PRINTS_IN_QUEUE 500

View File

@ -1,4 +1,4 @@
/* $Id: isdnrep.c,v 1.3 1997/03/23 20:25:23 luethje Exp $
/* $Id: isdnrep.c,v 1.4 1997/03/23 23:11:59 luethje Exp $
*
* ISDN accounting for isdn4linux. (Report-module)
*
@ -19,6 +19,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: isdnrep.c,v $
* Revision 1.4 1997/03/23 23:11:59 luethje
* improved performance
*
* Revision 1.3 1997/03/23 20:25:23 luethje
* tmporary (running) result of the new structure of isdnrep
*
@ -115,9 +118,9 @@
/*****************************************************************************/
#define LOG_VERSION_1 0
#define LOG_VERSION_2 1
#define LOG_VERSION_3 2
#define LOG_VERSION_1 "1.0"
#define LOG_VERSION_2 "2.0"
#define LOG_VERSION_3 LOG_VERSION
/*****************************************************************************/
@ -142,7 +145,7 @@ static int add_one_call(sum_calls *s1, one_call *s2, double units);
static int clear_sum(sum_calls *s1);
static char *print_currency(int units, double money, int Format);
static void strich(int type);
static int n_match(char *Pattern, char* Number, int version);
static int n_match(char *Pattern, char* Number, char* version);
static int set_caller_infos(one_call *cur_call, char *string);
static int set_alias(one_call *cur_call, int *nx, char *myname);
static int print_header(int lday, char *time_string, sum_calls *day_sum, sum_calls *day_com_sum, sum_calls *all_sum, sum_calls *all_com_sum);
@ -863,25 +866,28 @@ static int set_alias(one_call *cur_call, int *nx, char *myname)
for (j = 0; ((j < 2) && !cc); j++) {
for (i = 0; i < knowns; i++) {
if (*cur_call->num[n] != '0') {
/* Alte Syntax der "isdn.log" : Ohne vorlaufene "0" */
cc = ((known[i]->si == cur_call->si) || j) &&
!match(known[i]->num+1, cur_call->num[n], LOG_VERSION_1);
if (!cc) {
/* Ganz alte Syntax der "isdn.log" : Ohne Vorwahl */
if (cur_call->version[0] != '\0')
{
if (!strcmp(cur_call->version,LOG_VERSION_2) ||
!strcmp(cur_call->version,LOG_VERSION_3) )
cc = ((known[i]->si == cur_call->si) || j) &&
!n_match(known[i]->num, cur_call->num[n], LOG_VERSION_1);
} /* if */
}
else if (*(cur_call->num[n] + 1) != '0') { /* pre 2.6 Syntax : ohne int. Vorwahl */
cc = ((known[i]->si == cur_call->si) || j) &&
!n_match(known[i]->num, cur_call->num[n], LOG_VERSION_2);
!n_match(known[i]->num, cur_call->num[n], cur_call->version);
}
else
cc = ((known[i]->si == cur_call->si) || j) &&
!n_match(known[i]->num, cur_call->num[n], LOG_VERSION_3);
{
if (*cur_call->num[n] != '0') {
/* Alte Syntax der "isdn.log" : Ohne vorlaufene "0" */
cc = ((known[i]->si == cur_call->si) || j) &&
!match(known[i]->num+1, cur_call->num[n], 0);
if (!cc) {
/* Ganz alte Syntax der "isdn.log" : Ohne Vorwahl */
cc = ((known[i]->si == cur_call->si) || j) &&
!n_match(known[i]->num, cur_call->num[n], LOG_VERSION_1);
} /* if */
}
}
if (cc) {
@ -937,13 +943,13 @@ static int set_alias(one_call *cur_call, int *nx, char *myname)
static int set_caller_infos(one_call *cur_call, char *string)
{
register int i;
register int i = 0;
auto char **array;
auto char *Ptr;
auto char *ptr;
if ((Ptr = strrchr(string,C_DELIM)) != NULL)
*Ptr = '\0';
if ((ptr = strrchr(string,C_DELIM)) != NULL)
*ptr = '\0';
if ((array = String_to_Array(string,C_DELIM)) == NULL)
{
@ -961,7 +967,8 @@ static int set_caller_infos(one_call *cur_call, char *string)
cur_call->dir = -1;
cur_call->cause = -1;
cur_call->ibytes = cur_call->obytes = 0L;
cur_call->version = cur_call->dm = 0.0;
cur_call->dm = 0.0;
cur_call->version[0] = '\0';
cur_call->pay = 0.0;
cur_call->si = cur_call->si1 = 0;
cur_call->dir = DIALOUT;
@ -992,7 +999,7 @@ static int set_caller_infos(one_call *cur_call, char *string)
break;
case 10: cur_call->obytes = atol(array[i]);
break;
case 11: cur_call->version = atof(array[i]);
case 11: strcpy(cur_call->version,array[i]);
break;
case 12: cur_call->si = atoi(array[i]);
break;
@ -1009,8 +1016,6 @@ static int set_caller_infos(one_call *cur_call, char *string)
}
}
del_Array(array);
if (i < 3)
return -1;
@ -1386,28 +1391,33 @@ static void strich(int type)
/*****************************************************************************/
static int n_match(char *Pattern, char* Number, int version)
static int n_match(char *Pattern, char* Number, char* version)
{
int RetCode = -1;
char s[SHORT_STRING_SIZE];
switch(version)
if (!strcmp(version,LOG_VERSION_3))
{
case LOG_VERSION_1: if ((RetCode = match(Pattern, Number,0)) != 0 &&
!strncmp(Pattern,S_AREA_PREFIX,strlen(S_AREA_PREFIX)))
{
sprintf(s,"*%s%s",myarea/*+strlen(S_AREA_PREFIX)*/,Pattern);
RetCode = match(s,Number,0);
}
break;
case LOG_VERSION_2: strcpy(s,expand_number(Number));
RetCode = num_match(Pattern,s);
break;
case LOG_VERSION_3: RetCode = num_match(Pattern,Number);
break;
default : print_msg(PRT_ERR,"Unknown Version of logfile entries!\n");
break;
RetCode = num_match(Pattern,Number);
}
else
if (!strcmp(version,LOG_VERSION_2))
{
strcpy(s,expand_number(Number));
RetCode = num_match(Pattern,s);
}
else
if (!strcmp(version,LOG_VERSION_1))
{
if ((RetCode = match(Pattern, Number,0)) != 0 &&
!strncmp(Pattern,S_AREA_PREFIX,strlen(S_AREA_PREFIX)) )
{
sprintf(s,"*%s%s",myarea/*+strlen(S_AREA_PREFIX)*/,Pattern);
RetCode = match(s,Number,0);
}
}
else
print_msg(PRT_ERR,"Unknown Version of logfile entries!\n");
return RetCode;
}

View File

@ -1,4 +1,4 @@
/* $Id: tools.h,v 1.5 1997/03/23 21:04:10 luethje Exp $
/* $Id: tools.h,v 1.6 1997/03/23 23:12:05 luethje Exp $
*
* ISDN accounting for isdn4linux.
*
@ -19,6 +19,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: tools.h,v $
* Revision 1.6 1997/03/23 23:12:05 luethje
* improved performance
*
* Revision 1.5 1997/03/23 21:04:10 luethje
* some bugfixes
*
@ -153,6 +156,10 @@
/****************************************************************************/
#define LOG_VERSION "3.0"
/****************************************************************************/
#undef min
#undef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
@ -510,7 +517,7 @@ typedef struct {
char num[2][NUMSIZE];
long ibytes;
long obytes;
double version;
char version[10];
int si;
int si1;
double currency_factor;

View File

@ -1,4 +1,4 @@
/* $Id: conffile.c,v 1.8 1997/03/20 00:22:51 luethje Exp $
/* $Id: conffile.c,v 1.9 1997/03/23 23:12:10 luethje Exp $
* ISDN accounting for isdn4linux.
*
* Copyright 1996 by Stefan Luethje (luethje@sl-gw.lake.de)
@ -18,6 +18,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: conffile.c,v $
* Revision 1.9 1997/03/23 23:12:10 luethje
* improved performance
*
* Revision 1.8 1997/03/20 00:22:51 luethje
* Only a test
*
@ -682,7 +685,7 @@ static section *Insert_Section(section **main_sec, section **ins_sec, char **var
static int Compare_Sections(section* sec1, section *sec2, char **variables)
{
int i;
int i Cnt1, Cnt2;
int found1, found2, Cnt, depth, width, exist = 1;
char **array;
char **array2;
@ -721,17 +724,25 @@ static int Compare_Sections(section* sec1, section *sec2, char **variables)
while ((array2 = Compare_Section_Get_Path(array,&width,&depth)) != NULL)
{
Cnt1 = Cnt2 = 0;
while (_Get_Section_From_Path(array2,sec1,&RetSection,&RetEntry1,0) == sec1)
{
Cnt1++;
while (_Get_Section_From_Path(array2,sec2,&RetSection,&RetEntry2,0) == sec2)
{
Cnt2++;
if (RetEntry1 != NULL && RetEntry2 != NULL &&
!strcmp(RetEntry1->name, RetEntry2->name) &&
((RetEntry1->value == NULL && RetEntry2->value == NULL) ||
!strcmp(RetEntry1->value,RetEntry2->value) ) )
found1++;
}
}
if (exist && array2[depth-1][0] == C_EXIST &&
_Get_Section_From_Path(array2,sec1,&RetSection,&RetEntry1,0) == NULL &&
_Get_Section_From_Path(array2,sec2,&RetSection,&RetEntry2,0) == NULL )
if (exist && array2[depth-1][0] == C_EXIST && Cnt1 == 0 && Cnt2 == 0) &&
found2++;
if ((++Cnt)%width == 0)