isdnlog-4.67:
- Enhancements for isdnrep: - New option -r for recomputing the connection fees with the rates from the current (and for a different or the cheapest provider). - Revised output format of summaries at end of report. - New format parameters %j, %v, and %V. - 2 new input formats for -t option. - Fix for dualmode workaround 0x100 to ensure that incoming calls will not become outgoing calls if a CALL_PROCEEDING message with an B channel confirmation is sent by a terminal prior to CONNECT. - Fixed and enhanced t: Tag handling in pp_rate. - Fixed typo in interface description of tools/rate.c - Fixed typo in tools/isdnrate.man, found by Paul Slootman. - Minor update to sample isdn.conf files: - Default isdnrep format shows numbers with 16 chars (+ & 15 digits). - New isdnrep format (-FNIO) without display of transfered bytes. - EUR as currency in Austria, may clash with outdated rate-at.dat. The number left of the currency symbol is nowadays insignificant. - Changes checked in earlier but after step to isdnlog-4.66: - New option for isdnrate: `-rvNN' requires a vbn starting with NN. - Do not compute the zone with empty strings (areacodes) as input. - New ratefile tags r: und t: which need an enhanced pp_rate. For a tag description see rate-files(5). - Some new and a few updated international cellphone destinations. NOTE: If there any questions, problems, or problems regarding isdnlog, feel free to join the isdn4linux mailinglist, see https://www.isdn4linux.de/mailman/listinfo/isdn4linux for details, or send a mail in English or German to <tobiasb@isdn4linux.de>.
This commit is contained in:
parent
dfa2f9cbf2
commit
0680582c2b
|
@ -1,4 +1,4 @@
|
|||
## $Id: Makefile.in,v 1.210 2003/08/26 19:46:11 tobiasb Exp $
|
||||
## $Id: Makefile.in,v 1.211 2003/10/29 17:41:33 tobiasb Exp $
|
||||
##
|
||||
## ISDN accounting for isdn4linux.
|
||||
##
|
||||
|
@ -19,6 +19,37 @@
|
|||
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
##
|
||||
## $Log: Makefile.in,v $
|
||||
## Revision 1.211 2003/10/29 17:41:33 tobiasb
|
||||
## isdnlog-4.67:
|
||||
## - Enhancements for isdnrep:
|
||||
## - New option -r for recomputing the connection fees with the rates
|
||||
## from the current (and for a different or the cheapest provider).
|
||||
## - Revised output format of summaries at end of report.
|
||||
## - New format parameters %j, %v, and %V.
|
||||
## - 2 new input formats for -t option.
|
||||
## - Fix for dualmode workaround 0x100 to ensure that incoming calls
|
||||
## will not become outgoing calls if a CALL_PROCEEDING message with
|
||||
## an B channel confirmation is sent by a terminal prior to CONNECT.
|
||||
## - Fixed and enhanced t: Tag handling in pp_rate.
|
||||
## - Fixed typo in interface description of tools/rate.c
|
||||
## - Fixed typo in tools/isdnrate.man, found by Paul Slootman.
|
||||
## - Minor update to sample isdn.conf files:
|
||||
## - Default isdnrep format shows numbers with 16 chars (+ & 15 digits).
|
||||
## - New isdnrep format (-FNIO) without display of transfered bytes.
|
||||
## - EUR as currency in Austria, may clash with outdated rate-at.dat.
|
||||
## The number left of the currency symbol is nowadays insignificant.
|
||||
## - Changes checked in earlier but after step to isdnlog-4.66:
|
||||
## - New option for isdnrate: `-rvNN' requires a vbn starting with NN.
|
||||
## - Do not compute the zone with empty strings (areacodes) as input.
|
||||
## - New ratefile tags r: und t: which need an enhanced pp_rate.
|
||||
## For a tag description see rate-files(5).
|
||||
## - Some new and a few updated international cellphone destinations.
|
||||
##
|
||||
## NOTE: If there any questions, problems, or problems regarding isdnlog,
|
||||
## feel free to join the isdn4linux mailinglist, see
|
||||
## https://www.isdn4linux.de/mailman/listinfo/isdn4linux for details,
|
||||
## or send a mail in English or German to <tobiasb@isdn4linux.de>.
|
||||
##
|
||||
## Revision 1.210 2003/08/26 19:46:11 tobiasb
|
||||
## isdnlog-4.66:
|
||||
## - Added support for AVM B1 (with layer 2 d-channel trace) in point-to-
|
||||
|
@ -1620,7 +1651,7 @@ SERVICEFILE = /etc/services
|
|||
# DON'T EDIT BELOW THIS LINE
|
||||
######################################################################
|
||||
|
||||
VERSION = 4.66
|
||||
VERSION = 4.67
|
||||
|
||||
# fallback to I4L-Version as set at configure time
|
||||
ifndef (I4LVERSION)
|
||||
|
@ -1741,7 +1772,7 @@ endif
|
|||
|
||||
|
||||
ISDNREP_OBJS = isdnrep/rep_main.o tools/tools.o tools/isdnconf.o \
|
||||
isdnlog/messages.o isdnrep/isdnrep.o \
|
||||
isdnlog/messages.o isdnrep/isdnrep.o isdnrep/opt_time.o \
|
||||
tools/rate.o tools/zone.o tools/holiday.o tools/dest.o \
|
||||
tools/telnum.o tools/zone/upack.o \
|
||||
$(LIBISDNDIR)/libisdn.a $(CDBEXTRALIBS)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
V:1.55 Int [21-Sep-2003 01:00:00]
|
||||
V:1.56 Int [20-Oct-2003 01:00:00]
|
||||
#
|
||||
# This version of country.dat originates from rates4linux:
|
||||
# $Id: country-de.dat,v 1.44 2003/09/22 19:46:01 tobiasb Exp $
|
||||
# $Id: country-de.dat,v 1.45 2003/10/29 17:41:34 tobiasb Exp $
|
||||
# The rates4linux homepage: http://www.sourceforge.net/projects/rates4linux/
|
||||
# It bases on Rev. 1.39 of isdn4k-utils/isdnlog/country-de.dat
|
||||
# in the CVS at http://www.isdn4linux.de.
|
||||
|
@ -1275,10 +1275,20 @@ N:Nicaragua
|
|||
C:+505
|
||||
T:NI
|
||||
|
||||
# Source (2003-07-19):
|
||||
# http://www.itu.int/itudoc/itu-t/number/h/hnd/82323_ww2.doc
|
||||
N:Honduras
|
||||
C:+504
|
||||
T:HN
|
||||
|
||||
N:Honduras Mobilfunk
|
||||
E:Honduras cellphone
|
||||
C:+5049575, +5049576, +5049577, +5049578, 5049579
|
||||
C:+504958, +504959
|
||||
C:+50496, +50497, +50498, +50499
|
||||
R:HN
|
||||
T:_HNMF
|
||||
|
||||
N:El Salvador Mobilfunk
|
||||
E:El Salvador cellphone
|
||||
C:+5038
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: processor.c,v 1.126 2003/08/26 19:46:12 tobiasb Exp $
|
||||
/* $Id: processor.c,v 1.127 2003/10/29 17:41:34 tobiasb Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (log-module)
|
||||
*
|
||||
|
@ -19,6 +19,37 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: processor.c,v $
|
||||
* Revision 1.127 2003/10/29 17:41:34 tobiasb
|
||||
* isdnlog-4.67:
|
||||
* - Enhancements for isdnrep:
|
||||
* - New option -r for recomputing the connection fees with the rates
|
||||
* from the current (and for a different or the cheapest provider).
|
||||
* - Revised output format of summaries at end of report.
|
||||
* - New format parameters %j, %v, and %V.
|
||||
* - 2 new input formats for -t option.
|
||||
* - Fix for dualmode workaround 0x100 to ensure that incoming calls
|
||||
* will not become outgoing calls if a CALL_PROCEEDING message with
|
||||
* an B channel confirmation is sent by a terminal prior to CONNECT.
|
||||
* - Fixed and enhanced t: Tag handling in pp_rate.
|
||||
* - Fixed typo in interface description of tools/rate.c
|
||||
* - Fixed typo in tools/isdnrate.man, found by Paul Slootman.
|
||||
* - Minor update to sample isdn.conf files:
|
||||
* - Default isdnrep format shows numbers with 16 chars (+ & 15 digits).
|
||||
* - New isdnrep format (-FNIO) without display of transfered bytes.
|
||||
* - EUR as currency in Austria, may clash with outdated rate-at.dat.
|
||||
* The number left of the currency symbol is nowadays insignificant.
|
||||
* - Changes checked in earlier but after step to isdnlog-4.66:
|
||||
* - New option for isdnrate: `-rvNN' requires a vbn starting with NN.
|
||||
* - Do not compute the zone with empty strings (areacodes) as input.
|
||||
* - New ratefile tags r: und t: which need an enhanced pp_rate.
|
||||
* For a tag description see rate-files(5).
|
||||
* - Some new and a few updated international cellphone destinations.
|
||||
*
|
||||
* NOTE: If there any questions, problems, or problems regarding isdnlog,
|
||||
* feel free to join the isdn4linux mailinglist, see
|
||||
* https://www.isdn4linux.de/mailman/listinfo/isdn4linux for details,
|
||||
* or send a mail in English or German to <tobiasb@isdn4linux.de>.
|
||||
*
|
||||
* Revision 1.126 2003/08/26 19:46:12 tobiasb
|
||||
* isdnlog-4.66:
|
||||
* - Added support for AVM B1 (with layer 2 d-channel trace) in point-to-
|
||||
|
@ -4492,6 +4523,7 @@ static void processctrl(int card, char *s)
|
|||
register int i, c;
|
||||
register int wegchan; /* fuer gemakelte */
|
||||
auto int dialin, type = 0, cref = -1, creflen, version;
|
||||
auto int dialin_cref;
|
||||
static int tei = BROADCAST, sapi = 0, net = 1, firsttime = 1;
|
||||
auto char sx[BUFSIZ], s1[BUFSIZ], s2[BUFSIZ];
|
||||
auto char *why, *hint;
|
||||
|
@ -4813,10 +4845,12 @@ static void processctrl(int card, char *s)
|
|||
|
||||
type = strtol(ps += 3, NIL, 16);
|
||||
|
||||
dialin_cref = (cref>>7)!=net;
|
||||
|
||||
if (isAVMB1)
|
||||
dialin = (cref & 0x80); /* first (SETUP) tells us who initiates the connection */
|
||||
else if (isAVMB1_D2 && tei==0) /* AVMB1 with D2 D-channel trace connected */
|
||||
dialin = (cref>>7)!=net; /* point to point (PtP) to NT or PABX */
|
||||
dialin = dialin_cref; /* point to point (PtP) to NT or PABX */
|
||||
else
|
||||
dialin = (tei == BROADCAST); /* dialin (Broadcast), alle anderen haben schon eine Tei! */
|
||||
|
||||
|
@ -4973,12 +5007,15 @@ static void processctrl(int card, char *s)
|
|||
* - ... && type=SETUP_ACKNOWLEDGE is to restrictrive. In case of
|
||||
* SETUP with complete called party number, the exchange responds
|
||||
* with C_PROC instead of S_ACK and C_PROC contains the B-channel.
|
||||
* - ... && !dialin_cref is necessary, because C_PROC may be send
|
||||
* by local terminal on incoming call and dialin is 0 instead of
|
||||
* 1 in this case. (Wrong call direction due to depency on tei 127.)
|
||||
* This workaround requires the value of DUALFIX_DESTNUM in dualfix,
|
||||
* which is set with -2.. or dual=.. at command line or parameter file.
|
||||
* |TB| 2003-08-14
|
||||
* |TB| 2003-09-16
|
||||
*/
|
||||
if (!chanused[chan] || (dualfix & DUALFIX_DESTNUM &&
|
||||
!call[chan].dialog && !call[5].dialin)) {
|
||||
!call[chan].dialog && !call[5].dialin && !dialin_cref)) {
|
||||
/* nicht --channel, channel muss unveraendert bleiben! */
|
||||
if (chanused[chan]) { /* catch second line condition */
|
||||
print_msg(PRT_DEBUG_BUGS, " DEBUG> %s: %s contained channel B%d which is marked as in use -- overwriting anyway.\n", st+4, (type==SETUP_ACKNOWLEDGE)?"S_ACK":"C_PROC", call[5].channel);
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
isdnrep.1
|
||||
opt_time
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" $Id: isdnrep.1.in,v 1.5 2000/11/06 15:02:17 paul Exp $
|
||||
.\" CHECKIN $Date: 2000/11/06 15:02:17 $
|
||||
.\" $Id: isdnrep.1.in,v 1.6 2003/10/29 17:41:35 tobiasb Exp $
|
||||
.\" CHECKIN $Date: 2003/10/29 17:41:35 $
|
||||
.TH isdnrep 1 "@MANDATE_ISDNREP@" "ISDN 4 Linux @I4LVERSION@" "Linux System Commands"
|
||||
|
||||
.PD 0
|
||||
|
@ -125,6 +125,42 @@ At the end of the report, all numbers not aliased in callerid.conf or
|
|||
~/.isdn are displayed. This option is not available when HTML output
|
||||
is requested.
|
||||
|
||||
.TP
|
||||
.B \-rPROV recompute
|
||||
Recompute the connection fees with the current ratefile instead of
|
||||
showing the amounts stored in the logfile as usual. The provider
|
||||
.B PROV
|
||||
for recomputation is selected in one of the following ways:
|
||||
|
||||
.RS
|
||||
.TP 10
|
||||
\-
|
||||
Use the logged provider.
|
||||
.TP
|
||||
pNUM
|
||||
Use provider with Pnum NUM (according to P: tag in ratefile).
|
||||
The provider variant is taken from rate.conf where the provider
|
||||
must be enabled.
|
||||
.TP
|
||||
pNUM_VAR
|
||||
Use provider with Pnum NUM and variant VAR
|
||||
(according to P:NUM,VAR in ratefile). No requirements for rate.conf.
|
||||
.TP
|
||||
vVBN
|
||||
.TP
|
||||
vVBN_VAR
|
||||
Similar to pNUM[_VAR] but the provider is selected via VBN
|
||||
(B: tag in ratefile) instead of Pnum.
|
||||
.TP
|
||||
b
|
||||
Use the cheapest of all booked providers. The provider selection
|
||||
is done per call. Booked providers are those, which are enabled
|
||||
in rate.conf
|
||||
.TP
|
||||
B
|
||||
Like b but allow all providers, not only the booked.
|
||||
.RE
|
||||
|
||||
.TP
|
||||
.B \-wX WWW
|
||||
isdnrep can give its output in HTML format; this is switched on with
|
||||
|
@ -213,6 +249,19 @@ the cost, if known
|
|||
.br
|
||||
e.g. 2,28 DM
|
||||
.TP
|
||||
%\fBx\fRj
|
||||
the name of the used provider
|
||||
.TP
|
||||
%v
|
||||
the VBN (carrier selection prefix) of the provider
|
||||
.br
|
||||
e.g. 01012
|
||||
.TP
|
||||
%V
|
||||
the VBN and variant of the provider
|
||||
.br
|
||||
e.g. 01012_3
|
||||
.TP
|
||||
%I
|
||||
amount of INPUT data
|
||||
.TP
|
||||
|
@ -259,6 +308,15 @@ The above string is put into @CONFFILE@ at installation as
|
|||
and can be used with
|
||||
.B -Fshort.
|
||||
|
||||
Without showing the transfered bytes, this string also fits into 80 chars:
|
||||
|
||||
.in +4
|
||||
" %X %D %16.16H %T %-25.25F %U"
|
||||
.in -4
|
||||
|
||||
It is included as
|
||||
.B REPFMTNIO.
|
||||
|
||||
.in -7
|
||||
.TP
|
||||
.B \-FX format
|
||||
|
@ -573,7 +631,7 @@ For the -d and -t options, the time is specified in the following formats:
|
|||
|
||||
.TP
|
||||
[DD/][M]M/[[YY]YY]
|
||||
specifes the month or day.
|
||||
specifies the month or day.
|
||||
|
||||
Examples:
|
||||
|
||||
|
@ -585,8 +643,8 @@ July of the current year
|
|||
8/1996
|
||||
August 1996
|
||||
.TP
|
||||
29/6/95
|
||||
June 29th 1995
|
||||
29/6/05
|
||||
June 29th 2005
|
||||
.TP
|
||||
6/6/
|
||||
error, is not June 6th of the current year; it's June 1906
|
||||
|
@ -596,6 +654,25 @@ error, is not June 6th of the current year; it's June 1906
|
|||
[D]D
|
||||
day of current month
|
||||
|
||||
.TP
|
||||
[D]D.[M]M.[[[CC]Y]Y]
|
||||
specifies a day. If century or year and century are missing, they will
|
||||
be taken from the current date.
|
||||
|
||||
Examples:
|
||||
|
||||
.RS
|
||||
.TP 10
|
||||
23.5.
|
||||
May 23rd in the current year
|
||||
.TP
|
||||
19.01.38
|
||||
January 19th 2038
|
||||
.TP
|
||||
16.10.1998
|
||||
October 16th 1998
|
||||
.RE
|
||||
|
||||
.TP
|
||||
[MM]DD[hhmm[[CC]YY][.ss]]
|
||||
specifies an exact time. Unspecified parts are defined as 0 when
|
||||
|
@ -638,6 +715,9 @@ all entries between June 1st 1995 00:00:00 and August 12th 14:38:25
|
|||
all entries between September 12th 1995 03:04:20 and December 31st
|
||||
1995 23:59:59
|
||||
.TP
|
||||
09.06.2006-9/7/6
|
||||
all entries between June 6th 2006 00:00:00 and July 7th 2006 00:00:00
|
||||
.TP
|
||||
7/95
|
||||
all entries between July 1st 1995 00:00:00 and July 31st 1995 23:59:59
|
||||
.TP
|
||||
|
@ -649,6 +729,43 @@ September 8th in the current year 23:59:59
|
|||
third day of the current month
|
||||
.RE
|
||||
|
||||
.TP
|
||||
[CC]YY\-MM\-DDThh:mm:ss
|
||||
specifies a year, a moment, or something between. Each seperator
|
||||
\'-', 'T', and ':' can be omitted or not. If the first '-' is
|
||||
missing, the century must be given.
|
||||
|
||||
This notation cannot be combined with the above notations.
|
||||
Time spans are noted with '--' instead of '-'. If no '--' is given,
|
||||
\'i' must be noted after the \-t option.
|
||||
|
||||
Examples:
|
||||
|
||||
.RS
|
||||
.TP
|
||||
i2002
|
||||
the entire year 2002 from January 1st 00:00:00 to December 31st 23:59:59
|
||||
.TP
|
||||
i200306
|
||||
the entire month June 2003
|
||||
.TP
|
||||
200308--200309
|
||||
August and September 2003
|
||||
.TP
|
||||
2003-10-03T17--
|
||||
all entries after October 3rd 2003 16:59:59
|
||||
.TP
|
||||
2003-08-27T11:51:25--20030827115128
|
||||
4 seconds at August 27th 2003
|
||||
.TP
|
||||
200306
|
||||
error: neither 'i' nor '--' given
|
||||
.TP
|
||||
2003-1-4
|
||||
error: leading zeros (at month and day) must not omitted
|
||||
.RE
|
||||
.in -7
|
||||
|
||||
.SH "FILES"
|
||||
.TP
|
||||
\fB@LOGFILE@\fR or \fB/var/lib/isdn/calls\fR
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdnrep.c,v 1.96 2003/07/25 22:18:03 tobiasb Exp $
|
||||
/* $Id: isdnrep.c,v 1.97 2003/10/29 17:41:35 tobiasb Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (Report-module)
|
||||
*
|
||||
|
@ -24,6 +24,37 @@
|
|||
*
|
||||
*
|
||||
* $Log: isdnrep.c,v $
|
||||
* Revision 1.97 2003/10/29 17:41:35 tobiasb
|
||||
* isdnlog-4.67:
|
||||
* - Enhancements for isdnrep:
|
||||
* - New option -r for recomputing the connection fees with the rates
|
||||
* from the current (and for a different or the cheapest provider).
|
||||
* - Revised output format of summaries at end of report.
|
||||
* - New format parameters %j, %v, and %V.
|
||||
* - 2 new input formats for -t option.
|
||||
* - Fix for dualmode workaround 0x100 to ensure that incoming calls
|
||||
* will not become outgoing calls if a CALL_PROCEEDING message with
|
||||
* an B channel confirmation is sent by a terminal prior to CONNECT.
|
||||
* - Fixed and enhanced t: Tag handling in pp_rate.
|
||||
* - Fixed typo in interface description of tools/rate.c
|
||||
* - Fixed typo in tools/isdnrate.man, found by Paul Slootman.
|
||||
* - Minor update to sample isdn.conf files:
|
||||
* - Default isdnrep format shows numbers with 16 chars (+ & 15 digits).
|
||||
* - New isdnrep format (-FNIO) without display of transfered bytes.
|
||||
* - EUR as currency in Austria, may clash with outdated rate-at.dat.
|
||||
* The number left of the currency symbol is nowadays insignificant.
|
||||
* - Changes checked in earlier but after step to isdnlog-4.66:
|
||||
* - New option for isdnrate: `-rvNN' requires a vbn starting with NN.
|
||||
* - Do not compute the zone with empty strings (areacodes) as input.
|
||||
* - New ratefile tags r: und t: which need an enhanced pp_rate.
|
||||
* For a tag description see rate-files(5).
|
||||
* - Some new and a few updated international cellphone destinations.
|
||||
*
|
||||
* NOTE: If there any questions, problems, or problems regarding isdnlog,
|
||||
* feel free to join the isdn4linux mailinglist, see
|
||||
* https://www.isdn4linux.de/mailman/listinfo/isdn4linux for details,
|
||||
* or send a mail in English or German to <tobiasb@isdn4linux.de>.
|
||||
*
|
||||
* Revision 1.96 2003/07/25 22:18:03 tobiasb
|
||||
* isdnlog-4.65:
|
||||
* - New values for isdnlog option -2x / dual=x with enable certain
|
||||
|
@ -160,8 +191,6 @@
|
|||
#include "../../vbox/src/libvbox.h"
|
||||
#include "libisdn.h"
|
||||
|
||||
#define END_TIME 1
|
||||
|
||||
#define SET_TIME 1
|
||||
#define GET_TIME 2
|
||||
#define GET_DATE 4
|
||||
|
@ -298,8 +327,6 @@ typedef struct {
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static time_t get_month(char *String, int TimeStatus);
|
||||
static time_t get_time(char *String, int TimeStatus);
|
||||
static int show_msn(one_call *cur_call);
|
||||
static int add_sum_calls(sum_calls *s1, sum_calls *s2);
|
||||
static int print_sum_calls(sum_calls *s, int computed);
|
||||
|
@ -598,6 +625,9 @@ int read_logfile(char *myname)
|
|||
known[knowns++]->num = "0000";
|
||||
}
|
||||
|
||||
if (recalc.mode && !prep_recalc())
|
||||
return UNKNOWN; /* error in -r Option, msg by prep_recalc to stdout */
|
||||
|
||||
if (delentries)
|
||||
{
|
||||
if(begintime)
|
||||
|
@ -774,7 +804,7 @@ static int print_bottom(double unit, char *start, char *stop)
|
|||
sum_calls tmp_sum;
|
||||
auto double s = 0.0, s2 = 0.0;
|
||||
auto int s1 = 0;
|
||||
|
||||
auto int showIO = 1; /* display inbyte and outbyte */
|
||||
|
||||
if (timearea && summary < 2) {
|
||||
strich(1);
|
||||
|
@ -818,8 +848,46 @@ static int print_bottom(double unit, char *start, char *stop)
|
|||
|
||||
print_line2(F_BODY_BOTTOM2,"");
|
||||
|
||||
get_format("%-14.14s %4d call(s) %10.10s %12s %-12s %-12s");
|
||||
i = 0;
|
||||
if (recalc.mode && recalc.unknown)
|
||||
{
|
||||
print_line2(F_TEXT_LINE, "Recomputed %d of %d qualified call(s)",
|
||||
(recalc.count-recalc.unknown), recalc.count);
|
||||
i++;
|
||||
}
|
||||
if (tolower(recalc.mode)=='b' &&
|
||||
recalc.cheaper != recalc.count- recalc.unknown)
|
||||
{
|
||||
print_line2(F_TEXT_LINE, "Found cheaper provider for %d of %d call(s)",
|
||||
recalc.cheaper, (recalc.count-recalc.unknown));
|
||||
i++;
|
||||
}
|
||||
if (i)
|
||||
print_line2(F_TEXT_LINE, "");
|
||||
|
||||
/* foreign caller summary (out and in) ------------------------------- */
|
||||
/* strategy for width of summary lines:
|
||||
* call entry format (-F, -s) with %I or %O ==> summary also
|
||||
* call entry format longer than 80 chars ==> summary also
|
||||
* summary header out is 72 chars log, header in 74 chars */
|
||||
|
||||
if ( !(strstr(lineformat, "%I") || strstr(lineformat, "%O")) )
|
||||
showIO = 0;
|
||||
if ( set_col_size() > 80 )
|
||||
{
|
||||
if (showIO)
|
||||
get_format("%-25.25s %4d call(s) %10.10s %12s %-12s %-12s");
|
||||
else
|
||||
get_format("%-36.36s %4d call(s) %10.10s %12s");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (showIO)
|
||||
get_format("%-14.14s %4d call(s) %10.10s %12s %-12s %-12s");
|
||||
else
|
||||
get_format("%-36.36s %4d call(s) %10.10s %12s");
|
||||
}
|
||||
|
||||
for (j = 0; summary < 2 && j < 2; j++)
|
||||
{
|
||||
if ((j == DIALOUT && !incomingonly) || (!outgoingonly && j == DIALIN))
|
||||
|
@ -839,10 +907,11 @@ static int print_bottom(double unit, char *start, char *stop)
|
|||
/*!numbers?*/known[i]->who/*:known[i]->num*/,
|
||||
known[i]->usage[j],
|
||||
double2clock(known[i]->dur[j]),
|
||||
j==DIALOUT?print_currency(known[i]->pay,0):
|
||||
fill_spaces(print_currency(known[i]->pay,0)),
|
||||
j==DIALOUT?print_currency(known[i]->pay,0):
|
||||
fill_spaces(print_currency(known[i]->pay,0)),
|
||||
set_byte_string(GET_IN|GET_BYTES,known[i]->ibytes[j]),
|
||||
set_byte_string(GET_OUT|GET_BYTES,known[i]->obytes[j]));
|
||||
/* the last two arguments may be excessive */
|
||||
} /* if */
|
||||
} /* for */
|
||||
|
||||
|
@ -852,10 +921,13 @@ static int print_bottom(double unit, char *start, char *stop)
|
|||
|
||||
if (!incomingonly)
|
||||
{
|
||||
/* zone summary (outgoing) ----------------------------------------- */
|
||||
int ztypes = 0;
|
||||
h_percent = 60.0;
|
||||
/* prev.: 60.0 */
|
||||
h_percent = 70.0;
|
||||
h_table_color = H_TABLE_COLOR3;
|
||||
get_format("%-21.21s %4d call(s) %10.10s %12s");
|
||||
/* prev.: "%-21.21s %4d call(s) %10.10s %12s" */
|
||||
get_format("%-34.34s %4d call(s) %10.10s %12s");
|
||||
print_line2(F_BODY_HEADER,"");
|
||||
/* Fixme: zones are provider-specific
|
||||
we are summing up zones for all provides here */
|
||||
|
@ -904,35 +976,41 @@ static int print_bottom(double unit, char *start, char *stop)
|
|||
|
||||
print_line2(F_BODY_BOTTOM2,"");
|
||||
|
||||
h_percent = 60.0;
|
||||
/* provider summary (outgoing) ------------------------------------- */
|
||||
/* prev.: 60.0 */
|
||||
h_percent = 80.0;
|
||||
h_table_color = H_TABLE_COLOR4;
|
||||
get_format("%-8.8s %05s %-25.25s %4d call(s) %10.10s %12s %s");
|
||||
/* prev.: "%-8.8s %05s %-25.25s %4d call(s) %10.10s %12s %s" */
|
||||
get_format("%-8.8s %8.8s %-24.24s %4d call(s) %10.10s %13.13s %-13s");
|
||||
/* "Prov" vbn provstr no durat. cost ..avail */
|
||||
/* 80 chars >| */
|
||||
print_line2(F_BODY_HEADER,"");
|
||||
print_line2(F_BODY_HEADERL,"Outgoing calls ordered by Provider");
|
||||
strich(1);
|
||||
|
||||
for (i = 0; i < MAXPROVIDER; i++) {
|
||||
prefix2provider(i, string);
|
||||
prefix2provider(i, string);
|
||||
if (usage_provider[i]) {
|
||||
if (duration_provider[i])
|
||||
sprintf(sx, "%5.1f%% avail.",
|
||||
100.0 * (usage_provider[i] - provider_failed[i]) / usage_provider[i]);
|
||||
else
|
||||
*sx = 0;
|
||||
p = getProvider(i);
|
||||
if (!p || p[strlen(p) - 1] == '?') /* UNKNOWN Provider */
|
||||
p = "UNKNOWN";
|
||||
if (duration_provider[i])
|
||||
sprintf(sx, "%5.1f%% avail.",
|
||||
100.0 * (usage_provider[i] - provider_failed[i]) / usage_provider[i]);
|
||||
else
|
||||
*sx = 0;
|
||||
p = getProvider(i);
|
||||
if (!p || p[strlen(p) - 1] == '?') /* UNKNOWN Provider */
|
||||
p = "UNKNOWN";
|
||||
|
||||
print_line3(NULL, "Provider", string, p,
|
||||
usage_provider[i],
|
||||
double2clock(duration_provider[i]),
|
||||
print_currency(pay_provider[i], 0), sx);
|
||||
} /* if */
|
||||
print_line3(NULL, "Provider", string, p,
|
||||
usage_provider[i],
|
||||
double2clock(duration_provider[i]),
|
||||
print_currency(pay_provider[i], 0), sx);
|
||||
} /* if */
|
||||
|
||||
} /* for */
|
||||
} /* for */
|
||||
|
||||
print_line2(F_BODY_BOTTOM2,"");
|
||||
|
||||
/* MSN summary (outgoing) ------------------------------------------ */
|
||||
h_percent = 60.0;
|
||||
h_table_color = H_TABLE_COLOR5;
|
||||
get_format("%-30.30s %4d call(s) %10.10s %12s");
|
||||
|
@ -1040,7 +1118,7 @@ static int print_line3(const char *fmt, ...)
|
|||
case 'f' : sprintf(tmpstr,"%f",va_arg(ap,double));
|
||||
append_string(&string,*fmtstring,tmpstr);
|
||||
break;
|
||||
default : print_msg(PRT_ERR, "isdnrep: internal Error: unknown format `%c'!\n",(*fmtstring)->s_type);
|
||||
default : print_msg(PRT_ERR, "isdnrep: internal Error: unknown format `%c'!\n",(*fmtstring)->s_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1114,7 +1192,7 @@ static int print_line(int status, one_call *cur_call, int computed, char *overla
|
|||
int dir;
|
||||
int i = 0;
|
||||
int free_col;
|
||||
int last_free_col = UNKNOWN;
|
||||
int last_free_col = UNKNOWN;
|
||||
|
||||
|
||||
if (colsize == NULL || status == F_COUNT_ONLY)
|
||||
|
@ -1298,13 +1376,13 @@ static int print_line(int status, one_call *cur_call, int computed, char *overla
|
|||
if (cur_call->dir)
|
||||
colsize[i] = append_string(&string,NULL," ");
|
||||
else
|
||||
colsize[i] = append_string(&string,*fmtstring,print_currency(cur_call->pay,computed));
|
||||
colsize[i] = append_string(&string,*fmtstring,print_currency(cur_call->pay,computed));
|
||||
}
|
||||
else
|
||||
if ((status == F_BODY_LINE) &&
|
||||
(cur_call->cause != UNKNOWN) &&
|
||||
(cur_call->cause != UNKNOWN) &&
|
||||
(cur_call->cause != 0x10) && /* Normal call clearing */
|
||||
(cur_call->cause != 0x1f)) /* Normal, unspecified */
|
||||
(cur_call->cause != 0x1f)) /* Normal, unspecified */
|
||||
colsize[i] = append_string(&string,*fmtstring,qmsg(TYPE_CAUSE, VERSION_EDSS1, cur_call->cause));
|
||||
else
|
||||
colsize[i] = append_string(&string,NULL," ");
|
||||
|
@ -1332,22 +1410,67 @@ static int print_line(int status, one_call *cur_call, int computed, char *overla
|
|||
colsize[i] = append_string(&string,*fmtstring," ");
|
||||
break;
|
||||
|
||||
/* provider name (from ratefile): */
|
||||
/* should have range */
|
||||
case 'j': if (status == F_BODY_LINE)
|
||||
{
|
||||
if (!numbers)
|
||||
/* if (!numbers) */ /* there is no numeric alternative */
|
||||
{
|
||||
register char *p;
|
||||
|
||||
p = (cur_call->provider >= 0) ? getProvider(cur_call->provider) : "";
|
||||
|
||||
if (cur_call->dir == DIALIN)
|
||||
p = "";
|
||||
|
||||
colsize[i] = append_string(&string,*fmtstring, p);
|
||||
register char *p;
|
||||
p = (cur_call->provider >= 0) ? getProvider(cur_call->provider) : "";
|
||||
if (cur_call->dir == DIALIN)
|
||||
p = "";
|
||||
colsize[i] = append_string(&string,*fmtstring, p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
else
|
||||
{
|
||||
free_col = 1;
|
||||
if (!html || status == F_COUNT_ONLY)
|
||||
colsize[i] = append_string(&string,*fmtstring, "");
|
||||
}
|
||||
break;
|
||||
|
||||
/* v: vbn aka carrier selection prefix (B: tag in ratefile) */
|
||||
case 'v': if (status == F_BODY_LINE)
|
||||
{
|
||||
char help2[16];
|
||||
if (cur_call->dir == DIALIN)
|
||||
help[0] = '\0';
|
||||
else
|
||||
prefix2provider(cur_call->provider, help);
|
||||
snprintf(help2, 16, "%-8s", help);
|
||||
colsize[i] = append_string(&string,*fmtstring, help2);
|
||||
}
|
||||
else
|
||||
{
|
||||
free_col = 1;
|
||||
if (!html || status == F_COUNT_ONLY)
|
||||
colsize[i] = append_string(&string,*fmtstring,
|
||||
" ");
|
||||
}
|
||||
break;
|
||||
|
||||
/* V: vbn and provider variant, e. g. "01012_3" */
|
||||
case 'V': if (status == F_BODY_LINE)
|
||||
{
|
||||
char help2[16];
|
||||
if (cur_call->dir == DIALIN)
|
||||
help[0] = '\0';
|
||||
else
|
||||
prefix2provider_variant(cur_call->provider, help);
|
||||
snprintf(help2, 16, "%-10s", help);
|
||||
colsize[i] = append_string(&string,*fmtstring, help2);
|
||||
}
|
||||
else
|
||||
{
|
||||
free_col = 1;
|
||||
if (!html || status == F_COUNT_ONLY)
|
||||
colsize[i] = append_string(&string,*fmtstring,
|
||||
" ");
|
||||
}
|
||||
break;
|
||||
|
||||
/* Link for answering machine! */
|
||||
case 'C': if (html)
|
||||
|
@ -1379,7 +1502,7 @@ static int print_line(int status, one_call *cur_call, int computed, char *overla
|
|||
|
||||
colsize[i] = append_string(&string,*fmtstring, " ");
|
||||
break;
|
||||
default : print_msg(PRT_ERR, "isdnrep: internal Error: unknown format `%c'!\n",(*fmtstring)->s_type);
|
||||
default : print_msg(PRT_ERR, "isdnrep: internal Error: unknown format `%c'!\n",(*fmtstring)->s_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1401,7 +1524,7 @@ static int print_line(int status, one_call *cur_call, int computed, char *overla
|
|||
i++;
|
||||
}
|
||||
|
||||
if (last_free_col != UNKNOWN)
|
||||
if (last_free_col != UNKNOWN)
|
||||
{
|
||||
char *help2 = NULL;
|
||||
|
||||
|
@ -1409,7 +1532,7 @@ static int print_line(int status, one_call *cur_call, int computed, char *overla
|
|||
if ((help2 = (char*) calloc(strlen(H_BODY_BOTTOM1)+(string?strlen(string):0)+strlen(overlap)+1,sizeof(char))) == NULL)
|
||||
{
|
||||
print_msg(PRT_ERR, nomemory);
|
||||
return(UNKNOWN);
|
||||
return(UNKNOWN);
|
||||
}
|
||||
|
||||
sprintf(help2,H_BODY_BOTTOM1,last_free_col+1,overlap,string?string:"");
|
||||
|
@ -1419,10 +1542,10 @@ static int print_line(int status, one_call *cur_call, int computed, char *overla
|
|||
overlap = NULL;
|
||||
}
|
||||
|
||||
colsize[i] = UNKNOWN;
|
||||
colsize[i] = UNKNOWN;
|
||||
|
||||
if (status == F_COUNT_ONLY)
|
||||
return strlen(string);
|
||||
return (string) ? strlen(string) : 0; /* do not call strlen(0) */
|
||||
else
|
||||
print_line2(status,"%s",overlap_string(string,overlap));
|
||||
|
||||
|
@ -1501,7 +1624,7 @@ static int append_string(char **string, prt_fmt *fmt_ptr, char* value)
|
|||
if ((tmpfmt = (char*) alloca(sizeof(char)*(strlen(htmlfmt)+strlen(tmpfmt2)+1))) == NULL)
|
||||
{
|
||||
print_msg(PRT_ERR, nomemory);
|
||||
return(UNKNOWN);
|
||||
return(UNKNOWN);
|
||||
}
|
||||
|
||||
sprintf(tmpfmt,htmlfmt,tmpfmt2);
|
||||
|
@ -1519,7 +1642,7 @@ static int append_string(char **string, prt_fmt *fmt_ptr, char* value)
|
|||
if (*string == NULL)
|
||||
{
|
||||
print_msg(PRT_ERR, nomemory);
|
||||
return(UNKNOWN);
|
||||
return(UNKNOWN);
|
||||
}
|
||||
|
||||
strcat(*string,tmpstr);
|
||||
|
@ -1955,18 +2078,42 @@ static int print_header(int lday)
|
|||
time_t now;
|
||||
|
||||
|
||||
if (lday == UNKNOWN) {
|
||||
if (lday == UNKNOWN) { /* first day, print overall header, no day sum */
|
||||
time(&now);
|
||||
|
||||
if (bill)
|
||||
print_line2(F_1ST_LINE, "Ihre Verbindungen im einzelnen - %s", ctime(&now));
|
||||
else
|
||||
print_line2(F_1ST_LINE,"I S D N Connection Report - %s", ctime(&now));
|
||||
if (bill)
|
||||
print_line2(F_1ST_LINE, "Ihre Verbindungen im einzelnen - %s", ctime(&now));
|
||||
else
|
||||
print_line2(F_1ST_LINE,"I S D N Connection Report - %s", ctime(&now));
|
||||
|
||||
if (recalc.mode)
|
||||
{
|
||||
char s[80];
|
||||
char *prov, *vbn;
|
||||
if (recalc.mode == '-')
|
||||
snprintf(s, 80, "Connection fees recomputed");
|
||||
else if (tolower(recalc.mode) == 'b')
|
||||
snprintf(s, 80, "Connection fees recomputed using the cheapest "
|
||||
"of all %sproviders", (recalc.mode=='b')?"booked ":"");
|
||||
else
|
||||
{
|
||||
prov = getProvider(recalc.prefix);
|
||||
vbn = getProviderVBN(recalc.prefix);
|
||||
if (strstr(prov, vbn)) /* don't show vbn twice */
|
||||
snprintf(s, 80, "Connection fees recomputed for provider %s",
|
||||
prov);
|
||||
else
|
||||
snprintf(s, 80, "Connection fees recomputed for provider %s %s",
|
||||
vbn, prov);
|
||||
}
|
||||
print_line2(F_TEXT_LINE, "%s", s);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (summary >= 2)
|
||||
return 0;
|
||||
if (summary >= 2)
|
||||
return 0;
|
||||
strich(1);
|
||||
print_sum_calls(&day_sum,0);
|
||||
|
||||
|
@ -1995,9 +2142,24 @@ static int print_header(int lday)
|
|||
h_percent = 100.0;
|
||||
h_table_color = H_TABLE_COLOR1;
|
||||
print_line2(F_BODY_HEADER,"");
|
||||
print_line2(F_BODY_HEADERL,"%s %s", get_time_value(0,NULL,GET_DATE),
|
||||
get_time_value(0,NULL,GET_YEAR));
|
||||
|
||||
if (summary < 2)
|
||||
print_line2(F_BODY_HEADERL,"%s %s", get_time_value(0,NULL,GET_DATE),
|
||||
get_time_value(0,NULL,GET_YEAR));
|
||||
else /* show timespam "from .. to" for options -SS */
|
||||
{
|
||||
char s[80];
|
||||
s[0]=0;
|
||||
strcat(s, get_time_value(0, NULL, GET_DATE));
|
||||
strcat(s, " ");
|
||||
strcat(s, get_time_value(0, NULL, GET_YEAR));
|
||||
strcat(s, " .. ");
|
||||
get_time_value(endtime, &lday, SET_TIME);
|
||||
strcat(s, get_time_value(0, NULL, GET_DATE));
|
||||
strcat(s, " ");
|
||||
strcat(s, get_time_value(0, NULL, GET_YEAR));
|
||||
print_line2(F_BODY_HEADERL, "%s", s);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -2066,7 +2228,7 @@ static int set_alias(one_call *cur_call, int *nx, char *myname)
|
|||
|
||||
|
||||
for (n = CALLING; n <= CALLED; n++) {
|
||||
nx[n] = UNKNOWN;
|
||||
nx[n] = UNKNOWN;
|
||||
hit = 0;
|
||||
|
||||
if (!*(cur_call->num[n])) {
|
||||
|
@ -2089,7 +2251,7 @@ static int set_alias(one_call *cur_call, int *nx, char *myname)
|
|||
{
|
||||
if (!strcmp(cur_call->version,LOG_VERSION_2) ||
|
||||
!strcmp(cur_call->version,LOG_VERSION_3) ||
|
||||
!strcmp(cur_call->version,LOG_VERSION_4) ||
|
||||
!strcmp(cur_call->version,LOG_VERSION_4) ||
|
||||
!strcmp(cur_call->version,LOG_VERSION) )
|
||||
cc = ((known[i]->si == cur_call->si) || j) &&
|
||||
!n_match(known[i]->num, cur_call->num[n], cur_call->version);
|
||||
|
@ -2112,7 +2274,7 @@ static int set_alias(one_call *cur_call, int *nx, char *myname)
|
|||
|
||||
if (cc) {
|
||||
|
||||
strncpy(cur_call->who[n], known[i]->who,NUMSIZE);
|
||||
Strncpy(cur_call->who[n], known[i]->who,RETSIZE);
|
||||
|
||||
nx[n] = i;
|
||||
hit++;
|
||||
|
@ -2126,16 +2288,16 @@ static int set_alias(one_call *cur_call, int *nx, char *myname)
|
|||
if (!hit && seeunknowns) {
|
||||
for (i = 0; i < unknowns; i++)
|
||||
if (!strcmp(unknown[i].num, cur_call->num[n])) {
|
||||
hit++;
|
||||
break;
|
||||
} /* if */
|
||||
hit++;
|
||||
break;
|
||||
} /* if */
|
||||
|
||||
strcpy(unknown[i].num, cur_call->num[n]);
|
||||
strcpy(unknown[i].mynum, cur_call->num[1 - n]);
|
||||
unknown[i].si1 = cur_call->si1;
|
||||
strcpy(unknown[i].mynum, cur_call->num[1 - n]);
|
||||
unknown[i].si1 = cur_call->si1;
|
||||
unknown[i].called = !n;
|
||||
unknown[i].connect[unknown[i].connects] = cur_call->t;
|
||||
unknown[i].cause = cur_call->cause;
|
||||
unknown[i].cause = cur_call->cause;
|
||||
|
||||
/* ACHTUNG: MAXCONNECTS und MAXUNKNOWN sollten unbedingt groesser sein ! */
|
||||
if (unknown[i].connects + 1 < MAXCONNECTS)
|
||||
|
@ -2158,7 +2320,7 @@ static int set_alias(one_call *cur_call, int *nx, char *myname)
|
|||
|
||||
static void repair(one_call *cur_call)
|
||||
{
|
||||
RATE Rate;
|
||||
RATE Rate, lcrRate;
|
||||
TELNUM srcnum, destnum;
|
||||
int have_z; /* Zone Rate.z from getZone valid or not */
|
||||
int best_zone; /* =Rate.z if valid or =Rate.zone if Rate.z invalid */
|
||||
|
@ -2205,6 +2367,35 @@ static void repair(one_call *cur_call)
|
|||
Rate.start = cur_call->t;
|
||||
Rate.now = call[0].disconnect;
|
||||
Rate.prefix = cur_call->provider;
|
||||
|
||||
if (recalc.mode) {
|
||||
recalc.count++;
|
||||
if (recalc.mode == 'p' || recalc.mode == 'v')
|
||||
Rate.prefix = recalc.prefix;
|
||||
if (!getRate(&Rate,0)) {
|
||||
if ( (tolower(recalc.mode) == 'b') && /* find new provider with lcr */
|
||||
!getPrsel(cur_call->num[CALLED], &Rate.prefix, NULL, NULL) &&
|
||||
getLeastCost (&Rate, &lcrRate, recalc.mode=='b', Rate.prefix)
|
||||
!= UNKNOWN &&
|
||||
lcrRate.Charge < Rate.Charge &&
|
||||
!strcmp(lcrRate.dst[1], Rate.dst[1]) /* no new special number */
|
||||
) {
|
||||
recalc.cheaper++;
|
||||
cur_call->pay = lcrRate.Charge;
|
||||
cur_call->provider = lcrRate.prefix;
|
||||
}
|
||||
else { /* lcr failed (error or no cheaper provider) or not requested */
|
||||
cur_call->pay = Rate.Charge;
|
||||
cur_call->provider = Rate.prefix;
|
||||
}
|
||||
}
|
||||
else { /* fall back to logged provider for zone name etc */
|
||||
recalc.unknown++;
|
||||
Rate.prefix = cur_call->provider;
|
||||
Rate._zone = Rate._area = Rate.zone = UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
if (!getRate(&Rate,0)) {
|
||||
#if DEBUG
|
||||
fprintf(stderr,"Rate.zone=%i Rate.z=%i Rate.domestic=%i call.[0]so..r[CALLED]=%i\n", Rate.zone, Rate.z, Rate.domestic, call[0].sondernummer[CALLED]);
|
||||
|
@ -2437,7 +2628,7 @@ static int set_caller_infos(one_call *cur_call, char *string, time_t from)
|
|||
/* repair() recalculates the connection cost for entries with LOG_VERSION
|
||||
* older than the current and sets cur_call->zone for outgoing calls with
|
||||
* recorded one of -1 (=UNKNWON). The necessary information is taken from
|
||||
* the current rate-file.
|
||||
* the current rate-file. The -r option is also handled there.
|
||||
*/
|
||||
repair(cur_call);
|
||||
|
||||
|
@ -2469,186 +2660,6 @@ static char **string_to_array(char *string)
|
|||
return array;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
int get_term (char *String, time_t *Begin, time_t *End,int delentries)
|
||||
{
|
||||
time_t now;
|
||||
time_t Date[2];
|
||||
int Cnt;
|
||||
char DateStr[2][256] = {"",""};
|
||||
|
||||
|
||||
time(&now);
|
||||
|
||||
if (String[0] == '-')
|
||||
strcpy(DateStr[1],String+1);
|
||||
else
|
||||
if (String[strlen(String)-1] == '-')
|
||||
{
|
||||
strcpy(DateStr[0],String);
|
||||
DateStr[0][strlen(String)-1] ='\0';
|
||||
}
|
||||
else
|
||||
if (strchr(String,'-'))
|
||||
{
|
||||
if (sscanf(String,"%[/.0-9]-%[/.0-9]",DateStr[0],DateStr[1]) != 2)
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(DateStr[0],String);
|
||||
strcpy(DateStr[1],String);
|
||||
}
|
||||
|
||||
for (Cnt = 0; Cnt < 2; Cnt++)
|
||||
{
|
||||
if (strchr(DateStr[Cnt],'/'))
|
||||
Date[Cnt] = get_month(DateStr[Cnt],delentries?0:Cnt);
|
||||
else
|
||||
Date[Cnt] = get_time(DateStr[Cnt],delentries?0:Cnt);
|
||||
}
|
||||
|
||||
*Begin = DateStr[0][0] == '\0' ? 0 : Date[0];
|
||||
*End = DateStr[1][0] == '\0' ? now : Date[1];
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static time_t get_month(char *String, int TimeStatus)
|
||||
{
|
||||
time_t now;
|
||||
int Cnt = 0;
|
||||
struct tm *TimeStruct;
|
||||
int Args[3];
|
||||
int ArgCnt;
|
||||
|
||||
|
||||
time(&now);
|
||||
TimeStruct = localtime(&now);
|
||||
TimeStruct->tm_sec = 0;
|
||||
TimeStruct->tm_min = 0;
|
||||
TimeStruct->tm_hour= 0;
|
||||
TimeStruct->tm_mday= 1;
|
||||
TimeStruct->tm_isdst= UNKNOWN;
|
||||
|
||||
ArgCnt = sscanf(String,"%d/%d/%d",&(Args[0]),&(Args[1]),&(Args[2]));
|
||||
|
||||
switch (ArgCnt)
|
||||
{
|
||||
case 3:
|
||||
TimeStruct->tm_mday = Args[0];
|
||||
Cnt++;
|
||||
case 2:
|
||||
/* if (Args[Cnt+1] > 99) */
|
||||
if (Args[Cnt+1] >= 1900)
|
||||
TimeStruct->tm_year = ((Args[Cnt+1] / 100) - 19) * 100 + (Args[Cnt+1]%100);
|
||||
else
|
||||
if (Args[Cnt+1] < 70)
|
||||
TimeStruct->tm_year = Args[Cnt+1] + 100;
|
||||
else
|
||||
TimeStruct->tm_year = Args[Cnt+1];
|
||||
case 1:
|
||||
TimeStruct->tm_mon = Args[Cnt];
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (TimeStatus == END_TIME)
|
||||
{
|
||||
if (ArgCnt == 3) /* Wenn Tag angegeben ist */
|
||||
{
|
||||
TimeStruct->tm_mday++;
|
||||
TimeStruct->tm_mon--;
|
||||
}
|
||||
}
|
||||
else
|
||||
TimeStruct->tm_mon--;
|
||||
|
||||
return mktime(TimeStruct);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static time_t get_time(char *String, int TimeStatus)
|
||||
{
|
||||
time_t now;
|
||||
int Len = 0;
|
||||
int Year;
|
||||
char *Ptr;
|
||||
struct tm *TimeStruct;
|
||||
|
||||
|
||||
time(&now);
|
||||
TimeStruct = localtime(&now);
|
||||
TimeStruct->tm_sec = 0;
|
||||
TimeStruct->tm_min = 0;
|
||||
TimeStruct->tm_hour= 0;
|
||||
TimeStruct->tm_isdst= UNKNOWN;
|
||||
|
||||
switch (strlen(String))
|
||||
{
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
case 2:
|
||||
TimeStruct->tm_mday = atoi(String);
|
||||
break;
|
||||
default:
|
||||
Len = strlen(String);
|
||||
|
||||
if ((Ptr = strchr(String,'.')) != NULL)
|
||||
{
|
||||
TimeStruct->tm_sec = atoi(Ptr+1);
|
||||
Len -= strlen(Ptr);
|
||||
}
|
||||
|
||||
if (Len % 2)
|
||||
return 0;
|
||||
|
||||
if (sscanf(String,"%2d%2d%2d%2d%d",
|
||||
&(TimeStruct->tm_mon),
|
||||
&(TimeStruct->tm_mday),
|
||||
&(TimeStruct->tm_hour),
|
||||
&(TimeStruct->tm_min),
|
||||
&Year ) > 4) {
|
||||
/* if (Year > 99) */
|
||||
if (Year >= 1900)
|
||||
TimeStruct->tm_year = ((Year / 100) - 19) * 100 + (Year%100);
|
||||
else {
|
||||
if (Year < 70)
|
||||
TimeStruct->tm_year = Year + 100;
|
||||
else
|
||||
TimeStruct->tm_year = Year;
|
||||
}
|
||||
}
|
||||
TimeStruct->tm_mon--;
|
||||
break;
|
||||
}
|
||||
|
||||
if (TimeStatus == END_TIME) {
|
||||
if (TimeStruct->tm_sec == 0 &&
|
||||
TimeStruct->tm_min == 0 &&
|
||||
TimeStruct->tm_hour== 0 )
|
||||
TimeStruct->tm_mday++;
|
||||
else {
|
||||
if (TimeStruct->tm_sec == 0 &&
|
||||
TimeStruct->tm_min == 0 )
|
||||
TimeStruct->tm_hour++;
|
||||
else {
|
||||
if (TimeStruct->tm_sec == 0 )
|
||||
TimeStruct->tm_min++;
|
||||
else
|
||||
TimeStruct->tm_sec++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mktime(TimeStruct);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* called for -p ... command line options */
|
||||
int set_msnlist(char *String)
|
||||
|
@ -3751,5 +3762,68 @@ static int app_fmt_string(char *target, int targetlen, char *fmt, int condition,
|
|||
return snprintf(target,targetlen,tmpfmt,value);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* find provider for recalculation of connection fees (-r Option) */
|
||||
int prep_recalc (void)
|
||||
{
|
||||
int pnum;
|
||||
char *variant;
|
||||
/* eror messages should work in HTML mode (text/html) too */
|
||||
if (recalc.mode == '-' || /* just recalc, no different provider */
|
||||
recalc.mode == 'b' || /* do lcr with booked providers */
|
||||
recalc.mode == 'B' ) /* do lcr with all providers */
|
||||
return 1;
|
||||
|
||||
if (recalc.mode == 'p')
|
||||
{
|
||||
if (strchr(recalc.input, '_')) /* -rp21_0 */
|
||||
{
|
||||
recalc.prefix = pnum2prefix_variant(recalc.input, 0);
|
||||
}
|
||||
else /* -rp21 */
|
||||
{
|
||||
pnum = atoi(recalc.input);
|
||||
recalc.prefix = pnum2prefix(pnum, 0);
|
||||
}
|
||||
}
|
||||
else if (recalc.mode == 'v')
|
||||
{
|
||||
if ( (variant = strchr(recalc.input, '_')) )
|
||||
{ /* -rv01021_0 */
|
||||
int p;
|
||||
char *vbn;
|
||||
char s[16];
|
||||
variant++;
|
||||
for (p=0; p<getNProvider(); p++)
|
||||
{ /* something like vbn2prefix_variant */
|
||||
vbn = getProviderVBN(p);
|
||||
if (strncmp(vbn, recalc.input, strlen(vbn)))
|
||||
continue;
|
||||
pnum = prefix2pnum(p);
|
||||
snprintf(s, 12, "%d_%s", pnum, variant );
|
||||
if ( (recalc.prefix = pnum2prefix_variant(s, 0)) != UNKNOWN )
|
||||
break;
|
||||
}
|
||||
}
|
||||
else /* -rv01021 */
|
||||
{
|
||||
int l;
|
||||
recalc.prefix = vbn2prefix(recalc.input, &l);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Unknown provider selection mode in option -r: %c.\n", recalc.mode);
|
||||
return 0;
|
||||
}
|
||||
if (recalc.prefix == UNKNOWN)
|
||||
{
|
||||
printf("No provider found in ratefile for %s %s.\n",
|
||||
(recalc.mode=='p') ? "Pnum" : "VBN", recalc.input);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* vim:set ts=2: */
|
||||
/*****************************************************************************/
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: isdnrep.h,v 1.21 2000/10/15 12:53:04 leo Exp $
|
||||
/* $Id: isdnrep.h,v 1.22 2003/10/29 17:41:35 tobiasb Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux.
|
||||
*
|
||||
|
@ -20,6 +20,37 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: isdnrep.h,v $
|
||||
* Revision 1.22 2003/10/29 17:41:35 tobiasb
|
||||
* isdnlog-4.67:
|
||||
* - Enhancements for isdnrep:
|
||||
* - New option -r for recomputing the connection fees with the rates
|
||||
* from the current (and for a different or the cheapest provider).
|
||||
* - Revised output format of summaries at end of report.
|
||||
* - New format parameters %j, %v, and %V.
|
||||
* - 2 new input formats for -t option.
|
||||
* - Fix for dualmode workaround 0x100 to ensure that incoming calls
|
||||
* will not become outgoing calls if a CALL_PROCEEDING message with
|
||||
* an B channel confirmation is sent by a terminal prior to CONNECT.
|
||||
* - Fixed and enhanced t: Tag handling in pp_rate.
|
||||
* - Fixed typo in interface description of tools/rate.c
|
||||
* - Fixed typo in tools/isdnrate.man, found by Paul Slootman.
|
||||
* - Minor update to sample isdn.conf files:
|
||||
* - Default isdnrep format shows numbers with 16 chars (+ & 15 digits).
|
||||
* - New isdnrep format (-FNIO) without display of transfered bytes.
|
||||
* - EUR as currency in Austria, may clash with outdated rate-at.dat.
|
||||
* The number left of the currency symbol is nowadays insignificant.
|
||||
* - Changes checked in earlier but after step to isdnlog-4.66:
|
||||
* - New option for isdnrate: `-rvNN' requires a vbn starting with NN.
|
||||
* - Do not compute the zone with empty strings (areacodes) as input.
|
||||
* - New ratefile tags r: und t: which need an enhanced pp_rate.
|
||||
* For a tag description see rate-files(5).
|
||||
* - Some new and a few updated international cellphone destinations.
|
||||
*
|
||||
* NOTE: If there any questions, problems, or problems regarding isdnlog,
|
||||
* feel free to join the isdn4linux mailinglist, see
|
||||
* https://www.isdn4linux.de/mailman/listinfo/isdn4linux for details,
|
||||
* or send a mail in English or German to <tobiasb@isdn4linux.de>.
|
||||
*
|
||||
* Revision 1.21 2000/10/15 12:53:04 leo
|
||||
* Changed iobytes to double
|
||||
*
|
||||
|
@ -149,6 +180,7 @@
|
|||
#include <tools.h>
|
||||
#include <holiday.h>
|
||||
#include <rate.h>
|
||||
#include <telnum.h>
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
@ -169,6 +201,19 @@
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
char mode; /* \0 (none), - (logged provider), p (provider), v (vbn) */
|
||||
int prefix; /* internal provider number */
|
||||
int count; /* number of calls suitable for recomputing */
|
||||
int unknown; /* thereof the calls which have not been recomputed */
|
||||
int cheaper; /* number of calls where a cheaper provider was found */
|
||||
char *input; /* input from command line after -r[vp] */
|
||||
} RECALC;
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* isdnrep.c defines _REP_FUNC_C_, rep_main.c definies _ISDNREP_C_, ... */
|
||||
|
||||
#ifdef _REP_FUNC_C_
|
||||
#define _EXTERN
|
||||
#define _SET_NULL = NULL
|
||||
|
@ -191,6 +236,7 @@ _EXTERN int get_term (char *String, time_t *Begin, time_t *End,int delentries);
|
|||
_EXTERN int set_msnlist(char *String);
|
||||
_EXTERN int send_html_request(char *myname, char *option);
|
||||
_EXTERN int new_args(int *nargc, char ***nargv);
|
||||
_EXTERN int prep_recalc(void);
|
||||
|
||||
_EXTERN int print_msg(int Level, const char *, ...);
|
||||
_EXTERN int incomingonly _SET_0;
|
||||
|
@ -213,7 +259,7 @@ _EXTERN time_t endtime _SET_0;
|
|||
_EXTERN int preselect _SET_33;
|
||||
#endif
|
||||
_EXTERN int summary _SET_0;
|
||||
|
||||
_EXTERN RECALC recalc; /* initialiation done in main */
|
||||
|
||||
#undef _SET_NULL
|
||||
#undef _SET_0
|
||||
|
@ -223,6 +269,18 @@ _EXTERN int summary _SET_0;
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifdef _OPT_TIME_C_
|
||||
#define _EXTERN
|
||||
#else
|
||||
#define _EXTERN extern
|
||||
#endif
|
||||
|
||||
_EXTERN int get_term (char *String, time_t *Begin, time_t *End,int delentries);
|
||||
|
||||
#undef _EXTERN
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#define LOG_VERSION_1 "1.0"
|
||||
#define LOG_VERSION_2 "2.0"
|
||||
#define LOG_VERSION_3 "3.0"
|
||||
|
@ -232,9 +290,6 @@ _EXTERN int summary _SET_0;
|
|||
|
||||
#define C_DELIM '|'
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
typedef struct {
|
||||
|
@ -270,7 +325,7 @@ typedef struct {
|
|||
int dir;
|
||||
double duration;
|
||||
char num[2][NUMSIZE];
|
||||
char who[2][NUMSIZE];
|
||||
char who[2][RETSIZE];
|
||||
char sarea[2][TN_MAX_SAREA_LEN]; /* lt */
|
||||
double ibytes;
|
||||
double obytes;
|
||||
|
@ -283,7 +338,7 @@ typedef struct {
|
|||
int provider;
|
||||
int zone; /* fixme: zones may vary over time */
|
||||
} one_call;
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#endif /* _ISDNREP_H_ */
|
||||
|
|
|
@ -0,0 +1,453 @@
|
|||
/* $Id: opt_time.c,v 1.1 2003/10/29 17:41:35 tobiasb Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (Report-module)
|
||||
* Time options parsing. (Seperated from isdnrep.c 1.96)
|
||||
*
|
||||
* Copyright 1995 .. 2000 by Andreas Kool (akool@isdn4linux.de)
|
||||
* and Stefan Luethje (luethje@sl-gw.lake.de)
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* Copyright 1994, Steven Grimm <koreth@hyperion.com>.
|
||||
*
|
||||
*
|
||||
* $Log: opt_time.c,v $
|
||||
* Revision 1.1 2003/10/29 17:41:35 tobiasb
|
||||
* isdnlog-4.67:
|
||||
* - Enhancements for isdnrep:
|
||||
* - New option -r for recomputing the connection fees with the rates
|
||||
* from the current (and for a different or the cheapest provider).
|
||||
* - Revised output format of summaries at end of report.
|
||||
* - New format parameters %j, %v, and %V.
|
||||
* - 2 new input formats for -t option.
|
||||
* - Fix for dualmode workaround 0x100 to ensure that incoming calls
|
||||
* will not become outgoing calls if a CALL_PROCEEDING message with
|
||||
* an B channel confirmation is sent by a terminal prior to CONNECT.
|
||||
* - Fixed and enhanced t: Tag handling in pp_rate.
|
||||
* - Fixed typo in interface description of tools/rate.c
|
||||
* - Fixed typo in tools/isdnrate.man, found by Paul Slootman.
|
||||
* - Minor update to sample isdn.conf files:
|
||||
* - Default isdnrep format shows numbers with 16 chars (+ & 15 digits).
|
||||
* - New isdnrep format (-FNIO) without display of transfered bytes.
|
||||
* - EUR as currency in Austria, may clash with outdated rate-at.dat.
|
||||
* The number left of the currency symbol is nowadays insignificant.
|
||||
* - Changes checked in earlier but after step to isdnlog-4.66:
|
||||
* - New option for isdnrate: `-rvNN' requires a vbn starting with NN.
|
||||
* - Do not compute the zone with empty strings (areacodes) as input.
|
||||
* - New ratefile tags r: und t: which need an enhanced pp_rate.
|
||||
* For a tag description see rate-files(5).
|
||||
* - Some new and a few updated international cellphone destinations.
|
||||
*
|
||||
* NOTE: If there any questions, problems, or problems regarding isdnlog,
|
||||
* feel free to join the isdn4linux mailinglist, see
|
||||
* https://www.isdn4linux.de/mailman/listinfo/isdn4linux for details,
|
||||
* or send a mail in English or German to <tobiasb@isdn4linux.de>.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#define _OPT_TIME_C_
|
||||
|
||||
/* allow standalone binary for testing */
|
||||
/* build with
|
||||
gcc -g -DTEST_OPT_TIME -o opt_time opt_time.c
|
||||
*/
|
||||
#ifdef TEST_OPT_TIME
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#define UNKNOWN (-1)
|
||||
#define min(x,y) ((x) < (y) ? (x) : (y))
|
||||
char *Strncpy(char *dest, const char *src, int len);
|
||||
#else
|
||||
|
||||
#include "isdnrep.h"
|
||||
|
||||
#endif
|
||||
|
||||
#define END_TIME 1
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static time_t get_month(char *String, int TimeStatus);
|
||||
static time_t get_time(char *String, int TimeStatus);
|
||||
static time_t get_gertime(char *s, int TimeStatus);
|
||||
static time_t get_itime(char *s, int TimeStatus);
|
||||
|
||||
/*****************************************************************************/
|
||||
/* parse time option, a return value of 0 means failure. */
|
||||
int get_term (char *String, time_t *Begin, time_t *End,int delentries)
|
||||
{
|
||||
time_t now;
|
||||
time_t Date[2];
|
||||
int Cnt;
|
||||
char DateStr[2][256] = {"",""};
|
||||
int idate = 0;
|
||||
char sep[3] = { '-', 0, 0 };
|
||||
int sep_l = 1;
|
||||
char *p;
|
||||
|
||||
time(&now);
|
||||
|
||||
if (tolower(String[0])=='i' || strstr(String,"--")) {
|
||||
String += tolower(String[0])=='i';
|
||||
sep[1] = sep[0];
|
||||
sep_l++;
|
||||
idate++;
|
||||
}
|
||||
|
||||
if ( (p=strstr(String, sep)) )
|
||||
{
|
||||
if (String != p) /* ...<sep> */
|
||||
Strncpy(DateStr[0], String, min(p-String+1,256));
|
||||
if (*(p+sep_l)) /* <sep>... */
|
||||
Strncpy(DateStr[1], p+sep_l, 256);
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(DateStr[0],String);
|
||||
strcpy(DateStr[1],String);
|
||||
}
|
||||
|
||||
for (Cnt = 0; Cnt < 2; Cnt++)
|
||||
{
|
||||
if ( strspn(DateStr[Cnt], idate ? "01234567890T:-" : "01234567890/.")
|
||||
!= strlen(DateStr[Cnt]) )
|
||||
return 0;
|
||||
if (idate)
|
||||
Date[Cnt] = get_itime(DateStr[Cnt],delentries?0:Cnt);
|
||||
else if ( (p=strchr(DateStr[Cnt],'.')) && strchr(p+1,'.') )
|
||||
Date[Cnt] = get_gertime(DateStr[Cnt],delentries?0:Cnt);
|
||||
else if (strchr(DateStr[Cnt],'/'))
|
||||
Date[Cnt] = get_month(DateStr[Cnt],delentries?0:Cnt);
|
||||
else
|
||||
Date[Cnt] = get_time(DateStr[Cnt],delentries?0:Cnt);
|
||||
}
|
||||
|
||||
*Begin = DateStr[0][0] == '\0' ? 0 : Date[0];
|
||||
*End = DateStr[1][0] == '\0' || !Date[1] ? now : Date[1];
|
||||
|
||||
if (*Begin > *End)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* parse a date like [DD/][M]M/[[YY]YY] */
|
||||
static time_t get_month(char *String, int TimeStatus)
|
||||
{
|
||||
time_t now;
|
||||
int Cnt = 0;
|
||||
struct tm *TimeStruct;
|
||||
int Args[3];
|
||||
int ArgCnt;
|
||||
|
||||
|
||||
time(&now);
|
||||
TimeStruct = localtime(&now);
|
||||
TimeStruct->tm_sec = 0;
|
||||
TimeStruct->tm_min = 0;
|
||||
TimeStruct->tm_hour= 0;
|
||||
TimeStruct->tm_mday= 1;
|
||||
TimeStruct->tm_isdst= UNKNOWN;
|
||||
|
||||
ArgCnt = sscanf(String,"%d/%d/%d",&(Args[0]),&(Args[1]),&(Args[2]));
|
||||
|
||||
switch (ArgCnt)
|
||||
{
|
||||
case 3:
|
||||
TimeStruct->tm_mday = Args[0];
|
||||
Cnt++;
|
||||
case 2:
|
||||
/* if (Args[Cnt+1] > 99) */
|
||||
if (Args[Cnt+1] >= 1900)
|
||||
TimeStruct->tm_year = ((Args[Cnt+1] / 100) - 19) * 100 + (Args[Cnt+1]%100);
|
||||
else
|
||||
if (Args[Cnt+1] < 70)
|
||||
TimeStruct->tm_year = Args[Cnt+1] + 100;
|
||||
else
|
||||
TimeStruct->tm_year = Args[Cnt+1];
|
||||
case 1:
|
||||
TimeStruct->tm_mon = Args[Cnt];
|
||||
break;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (TimeStatus == END_TIME)
|
||||
{
|
||||
if (ArgCnt == 3) /* Wenn Tag angegeben ist */
|
||||
{
|
||||
TimeStruct->tm_mday++;
|
||||
TimeStruct->tm_mon--;
|
||||
}
|
||||
}
|
||||
else
|
||||
TimeStruct->tm_mon--;
|
||||
|
||||
return mktime(TimeStruct);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* parse a date like [MM]DD[hhmm[[CC]YY][.ss]] */
|
||||
static time_t get_time(char *String, int TimeStatus)
|
||||
{
|
||||
time_t now;
|
||||
int Len = 0;
|
||||
int Year;
|
||||
char *Ptr;
|
||||
struct tm *TimeStruct;
|
||||
|
||||
|
||||
time(&now);
|
||||
TimeStruct = localtime(&now);
|
||||
TimeStruct->tm_sec = 0;
|
||||
TimeStruct->tm_min = 0;
|
||||
TimeStruct->tm_hour= 0;
|
||||
TimeStruct->tm_isdst= UNKNOWN;
|
||||
|
||||
switch (strlen(String))
|
||||
{
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
case 2:
|
||||
TimeStruct->tm_mday = atoi(String);
|
||||
break;
|
||||
default:
|
||||
Len = strlen(String);
|
||||
|
||||
if ((Ptr = strchr(String,'.')) != NULL)
|
||||
{
|
||||
TimeStruct->tm_sec = atoi(Ptr+1);
|
||||
Len -= strlen(Ptr);
|
||||
}
|
||||
|
||||
if (Len % 2)
|
||||
return 0;
|
||||
|
||||
if (sscanf(String,"%2d%2d%2d%2d%d",
|
||||
&(TimeStruct->tm_mon),
|
||||
&(TimeStruct->tm_mday),
|
||||
&(TimeStruct->tm_hour),
|
||||
&(TimeStruct->tm_min),
|
||||
&Year ) > 4) {
|
||||
/* if (Year > 99) */
|
||||
if (Year >= 1900)
|
||||
TimeStruct->tm_year = ((Year / 100) - 19) * 100 + (Year%100);
|
||||
else {
|
||||
if (Year < 70)
|
||||
TimeStruct->tm_year = Year + 100;
|
||||
else
|
||||
TimeStruct->tm_year = Year;
|
||||
}
|
||||
}
|
||||
TimeStruct->tm_mon--;
|
||||
break;
|
||||
}
|
||||
|
||||
if (TimeStatus == END_TIME) {
|
||||
if (TimeStruct->tm_sec == 0 &&
|
||||
TimeStruct->tm_min == 0 &&
|
||||
TimeStruct->tm_hour== 0 )
|
||||
TimeStruct->tm_mday++;
|
||||
else {
|
||||
if (TimeStruct->tm_sec == 0 &&
|
||||
TimeStruct->tm_min == 0 )
|
||||
TimeStruct->tm_hour++;
|
||||
else {
|
||||
if (TimeStruct->tm_sec == 0 )
|
||||
TimeStruct->tm_min++;
|
||||
else
|
||||
TimeStruct->tm_sec++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return mktime(TimeStruct);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* parse a date like [D]D.[M]M.[[CC][Y]Y] */
|
||||
static time_t get_gertime(char *s, int TimeStatus)
|
||||
{
|
||||
/* convert to CCYY-MM-DD and give it to get_itime */
|
||||
char t[10+1], *sm, *sy;
|
||||
int day, month, year;
|
||||
if (strlen(s)>10 || strlen(s)<4)
|
||||
return 0;
|
||||
sm = strchr(s,'.') + 1;
|
||||
sy = strchr(sm,'.') + 1;
|
||||
|
||||
if ( *sy )
|
||||
year = atoi(sy); /* (century and) year from input */
|
||||
else { /* get current year */
|
||||
time_t now;
|
||||
struct tm *tm;
|
||||
time(&now);
|
||||
tm = localtime(&now);
|
||||
year = tm->tm_year+1900;
|
||||
}
|
||||
|
||||
month = atoi(sm);
|
||||
day = atoi(s);
|
||||
if (year>9999 || month>12 || day>31)
|
||||
return 0;
|
||||
|
||||
sprintf(t, "%02d-%02d-%02d", year, month, day);
|
||||
|
||||
return get_itime(t, TimeStatus);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* parse a date like CCYY[-]MM[-]DD["T"]hh[:]mm[:]ss */
|
||||
static time_t get_itime(char *s, int TimeStatus)
|
||||
{
|
||||
time_t now, offset=0;
|
||||
struct tm *t;
|
||||
char *p;
|
||||
char a[5];
|
||||
int i[6];
|
||||
int n;
|
||||
|
||||
time(&now);
|
||||
t = localtime(&now);
|
||||
t->tm_isdst = UNKNOWN;
|
||||
|
||||
p = s;
|
||||
if (strlen(s)<4) /* at least CCYY or YY-MM */
|
||||
return 0;
|
||||
|
||||
p = s;
|
||||
if ( !( isdigit(p[0]) && isdigit(p[1]) ) )
|
||||
return 0;
|
||||
if (p[2] == '-') { /* YY- */
|
||||
Strncpy(a, p, 2+1);
|
||||
i[0] = atoi(a);
|
||||
i[0] += ((t->tm_year+1900)/100)*100; /* add current century */
|
||||
p += 2;
|
||||
}
|
||||
else { /* CCYY */
|
||||
if ( !( isdigit(p[2]) && isdigit(p[3]) ) )
|
||||
return 0;
|
||||
Strncpy(a, p, 4+1);
|
||||
i[0] = atoi(a);
|
||||
p += 4;
|
||||
}
|
||||
|
||||
for (n=1; n<6; n++) /* MM DD hh mm ss */
|
||||
{ /* 1 2 3 4 5 */
|
||||
if (*p == ( n<3 ? '-' : (n<4 ? 'T' : ':') ) )
|
||||
p++;
|
||||
if (! *p)
|
||||
break;
|
||||
if ( !( isdigit(p[0]) && isdigit(p[1]) ) )
|
||||
return 0;
|
||||
Strncpy(a, p, 2+1);
|
||||
i[n] = atoi(a);
|
||||
p += 2;
|
||||
}
|
||||
|
||||
t->tm_year = i[0] - 1900;
|
||||
|
||||
if (n==2 && TimeStatus==END_TIME && i[1] == 12)
|
||||
n = 1; /* --2003-12 => --2003 */
|
||||
|
||||
if (n==1 && TimeStatus==END_TIME) /* --2003 => --2003-12-31T23:59:59 */
|
||||
{
|
||||
TimeStatus = 0; /* 1) => --2003-01-01T00:00:00 */
|
||||
t->tm_year++; /* 2) => --2004-01-01T00:00:00 */
|
||||
offset = -1; /* 3) => --2003-12-31T23:59:59 */
|
||||
}
|
||||
|
||||
t->tm_mon = (n>1) ? i[1]-1 : 0;
|
||||
|
||||
if (n==2 && TimeStatus==END_TIME) /* --2000-02 => --2000-02-29T23:59:59 */
|
||||
{
|
||||
TimeStatus = 0; /* 1) => --2000-02-01T00:00:00 */
|
||||
t->tm_mon++; /* 2) => --2000-03-01T00:00:00 */
|
||||
offset = -1; /* 3) => --2000-02-29T23:59:59 */
|
||||
}
|
||||
|
||||
t->tm_mday = (n>2) ? i[2] : 1;
|
||||
|
||||
t->tm_hour = (n>3) ? i[3] : ( (TimeStatus==END_TIME) ? 23 : 0);
|
||||
t->tm_min = (n>4) ? i[4] : ( (TimeStatus==END_TIME) ? 59 : 0);
|
||||
t->tm_sec = (n>5) ? i[5] : ( (TimeStatus==END_TIME) ? 59 : 0);
|
||||
|
||||
return mktime(t)+offset;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
#ifdef TEST_OPT_TIME
|
||||
|
||||
/* taken from ../../lib/libtools.c */
|
||||
char *Strncpy(char *dest, const char *src, int len)
|
||||
{
|
||||
int l = strlen(src);
|
||||
if (l > len - 1)
|
||||
l = len - 1;
|
||||
strncpy(dest,src,l);
|
||||
dest[l] = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
#define STIME(z) a=localtime(&z); strftime(s, BUFSIZ, "%Y-%m-%d %H:%M:%S", a);
|
||||
|
||||
int main(int argc, char *argv[], char *envp[])
|
||||
{
|
||||
int delentries = 0, res;
|
||||
time_t begintime, endtime, now;
|
||||
struct tm *a;
|
||||
char s[BUFSIZ];
|
||||
|
||||
time(&now);
|
||||
STIME(now)
|
||||
printf("Testing get_term (parses isdnrep's -t option)\n"
|
||||
"Enter . to quit, d to switch delentries.\n"
|
||||
"Any other input will be parsed as option value\n"
|
||||
"Current time: %s\n", s);
|
||||
while(1)
|
||||
{
|
||||
fgets(s, BUFSIZ, stdin);
|
||||
s[strlen(s)-1]=0;
|
||||
|
||||
if (s[0] == '.' && s[1] == 0)
|
||||
break;
|
||||
else if (s[0] == 'd' && s[1] == 0) {
|
||||
delentries = !delentries;
|
||||
continue;
|
||||
}
|
||||
res = get_term (s, &begintime, &endtime, delentries);
|
||||
if (res) {
|
||||
STIME(begintime)
|
||||
printf("OK: %s -- ", s);
|
||||
STIME(endtime)
|
||||
printf("%s (delentries=%d)\n", s, delentries);
|
||||
}
|
||||
else
|
||||
printf("ERR\n");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#undef STIME
|
||||
#endif
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* vim:set ts=2: */
|
||||
|
||||
/*****************************************************************************/
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: rep_main.c,v 1.16 2003/07/25 22:18:03 tobiasb Exp $
|
||||
/* $Id: rep_main.c,v 1.17 2003/10/29 17:41:35 tobiasb Exp $
|
||||
*
|
||||
* ISDN accounting for isdn4linux. (Report-module)
|
||||
*
|
||||
|
@ -20,6 +20,37 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: rep_main.c,v $
|
||||
* Revision 1.17 2003/10/29 17:41:35 tobiasb
|
||||
* isdnlog-4.67:
|
||||
* - Enhancements for isdnrep:
|
||||
* - New option -r for recomputing the connection fees with the rates
|
||||
* from the current (and for a different or the cheapest provider).
|
||||
* - Revised output format of summaries at end of report.
|
||||
* - New format parameters %j, %v, and %V.
|
||||
* - 2 new input formats for -t option.
|
||||
* - Fix for dualmode workaround 0x100 to ensure that incoming calls
|
||||
* will not become outgoing calls if a CALL_PROCEEDING message with
|
||||
* an B channel confirmation is sent by a terminal prior to CONNECT.
|
||||
* - Fixed and enhanced t: Tag handling in pp_rate.
|
||||
* - Fixed typo in interface description of tools/rate.c
|
||||
* - Fixed typo in tools/isdnrate.man, found by Paul Slootman.
|
||||
* - Minor update to sample isdn.conf files:
|
||||
* - Default isdnrep format shows numbers with 16 chars (+ & 15 digits).
|
||||
* - New isdnrep format (-FNIO) without display of transfered bytes.
|
||||
* - EUR as currency in Austria, may clash with outdated rate-at.dat.
|
||||
* The number left of the currency symbol is nowadays insignificant.
|
||||
* - Changes checked in earlier but after step to isdnlog-4.66:
|
||||
* - New option for isdnrate: `-rvNN' requires a vbn starting with NN.
|
||||
* - Do not compute the zone with empty strings (areacodes) as input.
|
||||
* - New ratefile tags r: und t: which need an enhanced pp_rate.
|
||||
* For a tag description see rate-files(5).
|
||||
* - Some new and a few updated international cellphone destinations.
|
||||
*
|
||||
* NOTE: If there any questions, problems, or problems regarding isdnlog,
|
||||
* feel free to join the isdn4linux mailinglist, see
|
||||
* https://www.isdn4linux.de/mailman/listinfo/isdn4linux for details,
|
||||
* or send a mail in English or German to <tobiasb@isdn4linux.de>.
|
||||
*
|
||||
* Revision 1.16 2003/07/25 22:18:03 tobiasb
|
||||
* isdnlog-4.65:
|
||||
* - New values for isdnlog option -2x / dual=x with enable certain
|
||||
|
@ -268,7 +299,7 @@ int main(int argc, char *argv[], char *envp[])
|
|||
auto char fnbuff[512] = "";
|
||||
auto char usage[] = "%s: usage: %s [ -%s ]\n";
|
||||
auto char wrongdate[] = "unknown date: %s\n";
|
||||
auto char options[] = "ad:f:hinop:s:t:uvw:NVF:M:R:bES";
|
||||
auto char options[] = "ad:f:hinop:r:s:t:uvw:NVF:M:R:bES";
|
||||
auto char *myname = basename(argv[0]);
|
||||
auto char *ptr = NULL;
|
||||
auto char *linefmt = "";
|
||||
|
@ -278,6 +309,9 @@ int main(int argc, char *argv[], char *envp[])
|
|||
|
||||
set_print_fct_for_tools(print_in_modules);
|
||||
|
||||
recalc.mode = '\0'; recalc.prefix = UNKNOWN; recalc.input = NULL;
|
||||
recalc.count = recalc.unknown = recalc.cheaper = 0;
|
||||
|
||||
/* we don't need this at the moment:
|
||||
new_args(&argc,&argv);
|
||||
*/
|
||||
|
@ -364,6 +398,10 @@ int main(int argc, char *argv[], char *envp[])
|
|||
case 'S' : summary++;
|
||||
break;
|
||||
|
||||
case 'r' : recalc.mode = *optarg;
|
||||
recalc.input = strdup(optarg+1);
|
||||
break;
|
||||
|
||||
case '?' : printf(usage, argv[0], argv[0], options);
|
||||
return(1);
|
||||
} /* switch */
|
||||
|
@ -478,4 +516,4 @@ int set_linefmt(char *linefmt)
|
|||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* vim:set ts=2: */
|
||||
|
|
|
@ -16,7 +16,8 @@ ILABEL = %b %e %T %ICall to tei %t from %N2 on %n2
|
|||
OLABEL = %b %e %T %Itei %t calling %N2 with '%n0'
|
||||
REPFMTWWW = "%X %D %17.17H %T %-17.17F %-20.20l SI: %S %9u %U %I %O"
|
||||
REPFMTSHORT = "%X%D %8.8H %T %-14.14F%U%I %O"
|
||||
REPFMT = " %X %D %15.15H %T %-15.15F %7u %U %I %O"
|
||||
REPFMTNIO = " %X %D %16.16H %T %-25.25F %U"
|
||||
REPFMT = " %X %D %16.16H %T %-16.16F %7u %U %I %O"
|
||||
CHARGEMAX = 50.00
|
||||
CURRENCY = 0.062,EUR
|
||||
|
||||
|
|
|
@ -20,9 +20,10 @@ ILABEL = %b %e %T %ICall to tei %t from %N2 on %n2
|
|||
OLABEL = %b %e %T %Itei %t calling %N2 with '%n0'
|
||||
REPFMTWWW = "%X %D %17.17H %T %-17.17F %-20.20l SI: %S %9u %U %I %O"
|
||||
REPFMTSHORT = "%X%D %8.8H %T %-14.14F%U%I %O"
|
||||
REPFMT = " %X %D %15.15H %T %-15.15F %7u %U %I %O"
|
||||
REPFMTNIO = " %X %D %16.16H %T %-25.25F %U"
|
||||
REPFMT = " %X %D %16.16H %T %-16.16F %7u %U %I %O"
|
||||
CHARGEMAX = 50.00
|
||||
CURRENCY = 1.056,ATS
|
||||
CURRENCY = 1.056,EUR
|
||||
|
||||
COUNTRYFILE = /usr/lib/isdn/country.dat
|
||||
RATECONF= /etc/isdn/rate.conf
|
||||
|
|
|
@ -20,7 +20,8 @@ ILABEL = %b %e %T %ICall to tei %t from %N2 on %n2
|
|||
OLABEL = %b %e %T %Itei %t calling %N2 with %n2
|
||||
REPFMTWWW = "%X %D %17.17H %T %-17.17F %-20.20l SI: %S %9u %U %I %O"
|
||||
REPFMTSHORT = "%X%D %8.8H %T %-14.14F%U%I %O"
|
||||
REPFMT = " %X %D %15.15H %T %-15.15F %7u %U %I %O"
|
||||
REPFMTNIO = " %X %D %16.16H %T %-25.25F %U"
|
||||
REPFMT = " %X %D %16.16H %T %-16.16F %7u %U %I %O"
|
||||
CHARGEMAX = 50.00
|
||||
CURRENCY = 0.062,EUR
|
||||
|
||||
|
@ -38,6 +39,7 @@ PRESELECTED=33
|
|||
|
||||
|
||||
# allgemein verfügbare Internet-Zugänge (mit sowie ohne Anmeldung):
|
||||
# Stand 2000-09-15
|
||||
|
||||
[NUMBER]
|
||||
NUMBER = +49 4105/599777, +49 4133/469777, +49 4142/889777 # , +49 4146/959777, +49 4164/879777, +49 4172/979777, +49 4173/599777, +49 4182/809777, +49 421/2210010, +49 4221/685685, +49 4231/909777, +49 4252/909800, +49 4254/819777, +49 4262/919777, +49 4264/399777, +49 4274/809777, +49 4281/999777, +49 4283/609777, +49 4401/859859, +49 441/3508877, +49 4431/709100, +49 4451/809809, +49 4462/209209, +49 4471/709709, +49 4488/529529, +49 4491/789789, +49 4721/599777, +49 4731/209898, +49 4761/809777, +49 4771/689777, +49 4779/899777, +49 491/9999111, +49 4921/369850, +49 4941/699077, +49 4961/839839, +49 5022/809777, +49 5191/929777, +49 5192/899777, +49 5431/969777, +49 5441/509777, +49 5494/979777, +49 5495/989800, +49 5902/999777, +49 5936/919777, +49 5952/969969, +49 5961/919777, +49 5976/789777
|
||||
|
|
|
@ -21,7 +21,8 @@ ILABEL = %b %e %T %ICall to tei %t from %N2 on %n2
|
|||
OLABEL = %b %e %T %Itei %t calling %N2 with '%n0'
|
||||
REPFMTWWW = "%X %D %17.17H %T %-17.17F %-20.20l SI: %S %9u %U %I %O"
|
||||
REPFMTSHORT = "%X%D %8.8H %T %-14.14F%U%I %O"
|
||||
REPFMT = " %X %D %15.15H %T %-15.15F %7u %U %I %O"
|
||||
REPFMTNIO = " %X %D %16.16H %T %-25.25F %U"
|
||||
REPFMT = " %X %D %16.16H %T %-16.16F %7u %U %I %O"
|
||||
CHARGEMAX = 50.00
|
||||
|
||||
CURRENCY = 1,EUR
|
||||
|
|
|
@ -23,7 +23,8 @@ OLABEL = %b %e %T %Itei %t calling %N2 with %n2
|
|||
# OLABEL = %a %b %e %T uitgaand %I%n2 -> %N2
|
||||
REPFMTWWW = "%X %D %17.17H %T %-17.17F %-20.20l SI: %S %9u %U %I %O"
|
||||
REPFMTSHORT = "%X%D %8.8H %T %-14.14F%U%I %O"
|
||||
REPFMT = " %X %D %15.15H %T %-15.15F %7u %U %I %O"
|
||||
REPFMTNIO = " %X %D %16.16H %T %-25.25F %U"
|
||||
REPFMT = " %X %D %16.16H %T %-15.15F %7u %U %I %O"
|
||||
CHARGEMAX = 50.00
|
||||
CURRENCY = 0.01,EUR
|
||||
|
||||
|
|
|
@ -13,7 +13,8 @@ ILABEL = %b %e %T %ICall to tei %t from %N2 on %n2 on B%B
|
|||
OLABEL = %b %e %T %Itei %t calling %N2 with %n2 from B%B
|
||||
REPFMTWWW = "%X %D %17.17H %T %-17.17F %-20.20l SI: %S %9u %U %I %O"
|
||||
REPFMTSHORT = "%X%D %8.8H %T %-14.14F%U%I %O"
|
||||
REPFMT = " %X %D %15.15H %T %-15.15F %7u %U %I %O"
|
||||
REPFMTNIO = " %X %D %16.16H %T %-25.25F %U"
|
||||
REPFMT = " %X %D %16.16H %T %-16.16F %7u %U %I %O"
|
||||
CHARGEMAX = 200.00
|
||||
CALLFMT = %b %e %T %N7 %N3 %N4 %N5 %N6
|
||||
|
||||
|
|
|
@ -20,7 +20,8 @@ ILABEL = %b %e %T %ICall to tei %t from %N2 on %n2
|
|||
OLABEL = %b %e %T %Itei %t calling %N2 with %n2
|
||||
REPFMTWWW = "%X %D %17.17H %T %-17.17F %-20.20l SI: %S %9u %U %I %O"
|
||||
REPFMTSHORT = "%X%D %8.8H %T %-14.14F%U%I %O"
|
||||
REPFMT = " %X %D %15.15H %T %-15.15F %7u %U %I %O"
|
||||
REPFMTNIO = " %X %D %16.16H %T %-25.25F %U"
|
||||
REPFMT = " %X %D %16.16H %T %-16.16F %7u %U %I %O"
|
||||
CHARGEMAX = 10.00
|
||||
CURRENCY = 0.3538,PLN
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#! /usr/bin/perl
|
||||
|
||||
# This version of pp_rate originates from rates4linux:
|
||||
# $Id: pp_rate,v 1.7 2003/09/22 19:46:00 tobiasb Exp $
|
||||
# $Id: pp_rate,v 1.8 2003/10/29 17:41:36 tobiasb Exp $
|
||||
# The rates4linux homepage: http://www.sourceforge.net/projects/rates4linux/
|
||||
# It bases on Rev. 1.5 of isdn4k-utils/isdnlog/tools/dest/pp_rate
|
||||
# in the CVS at http://www.isdn4linux.de.
|
||||
|
@ -77,6 +77,8 @@ sub get_alias {
|
|||
# prototypes for lower case tag processing
|
||||
sub complete_T ($\@);
|
||||
sub fill_T (\@$$$$);
|
||||
sub same_hours (@);
|
||||
sub find_ranges (@);
|
||||
|
||||
sub prep_rate {
|
||||
my ($l, $infile, $outfile);
|
||||
|
@ -502,8 +504,9 @@ sub fill_T (\@$$$$) {
|
|||
$holiday = 1 if ($modus =~ /H/);
|
||||
|
||||
# step 1 - get already definied day/hour sets.
|
||||
my ($dh, $Tline, $numday);
|
||||
my ($dh, $Tline, $numday, $only_anyday);
|
||||
$numday = 0;
|
||||
$only_anyday = 1; # only T: for day "*" present
|
||||
foreach $Tline (@$Ttags) {
|
||||
my ($day, $aday, @days, $hour, $ahour, @hours);
|
||||
if ($Tline =~ /^T:\s*(\[[^\]]+\])\s*([1-7WEH,*-]+)\s*\/\s*([0-9,*-]+)\s*=/ ) {
|
||||
|
@ -520,6 +523,7 @@ sub fill_T (\@$$$$) {
|
|||
next;
|
||||
}
|
||||
$numday = 1 if ($day =~ /\d/); # use numbers (1-7) instead of W|E|H
|
||||
$only_anyday = 0 if ($day ne "*");
|
||||
foreach $aday (split(/,/, $day)) {
|
||||
if ($aday =~ /^(\d)-(\d)$/) {
|
||||
push @days, ($1 .. $2);
|
||||
|
@ -542,7 +546,9 @@ sub fill_T (\@$$$$) {
|
|||
next;
|
||||
}
|
||||
}
|
||||
@days = ("*") if ($only_anyday); # day "*" matches all other days
|
||||
foreach $ahour (split(/,/, $hour)) {
|
||||
$ahour =~ s/(^|-)0?(\d)/$1$2/g; # remove leading zeros, 00 -> 0
|
||||
if ($ahour eq "*") {
|
||||
push @hours, (0 .. 23, "*");
|
||||
}
|
||||
|
@ -576,26 +582,43 @@ sub fill_T (\@$$$$) {
|
|||
my ($d, $h, $x, $y, @adays, @bdays, @hours, %hd);
|
||||
# step 2.1 - find days with complete hours
|
||||
foreach $d (keys %$dh) {
|
||||
next if (defined $dh->{$d}->{"*"});
|
||||
if (defined $dh->{$d}->{"*"}) {
|
||||
$dh->{$d}->{"_bits"} = 0xFFFFFF;
|
||||
next;
|
||||
}
|
||||
my $bits=0;
|
||||
$x=1;
|
||||
for $h (0..23) {
|
||||
$x = 0 unless (defined $dh->{$d}->{$h});
|
||||
if (defined $dh->{$d}->{$h}) {
|
||||
$bits |= 1<<$h;
|
||||
}
|
||||
else {
|
||||
$x = 0;
|
||||
}
|
||||
}
|
||||
$dh->{$d}->{"*"}++ if ($x);
|
||||
$dh->{$d}->{"_bits"} = $bits;
|
||||
}
|
||||
# step 2.2 - find days with hour gaps
|
||||
# priority for _partial_ W or E entries
|
||||
# as long as the days 1..5 / 6..7 have identical hours
|
||||
# a better approach separate between common and different hours
|
||||
if ( defined($dh->{W}) and scalar(%{$dh->{W}})
|
||||
and not defined $dh->{W}-{"*"} ) {
|
||||
and not defined $dh->{W}->{"*"}
|
||||
and same_hours($dh->{1},$dh->{2},$dh->{3},$dh->{4},$dh->{5}) ) {
|
||||
push @adays, ("W");
|
||||
map { $dh->{$_}->{"*"}++} (1..5, "W");
|
||||
}
|
||||
if ( defined($dh->{E}) and scalar(%{$dh->{E}})
|
||||
and not defined $dh->{E}-{"*"} ) {
|
||||
and not defined $dh->{E}->{"*"}
|
||||
and same_hours($dh->{6},$dh->{7}) ) {
|
||||
push @adays, ("E");
|
||||
map { $dh->{$_}->{"*"}++} (6, 7, "E");
|
||||
}
|
||||
if ($numday) {
|
||||
if ($only_anyday) {
|
||||
push @adays, ("*");
|
||||
}
|
||||
elsif ($numday) {
|
||||
for $d (1..7) {
|
||||
push @adays, ($d) unless (defined $dh->{$d}->{"*"});
|
||||
}
|
||||
|
@ -629,8 +652,8 @@ sub fill_T (\@$$$$) {
|
|||
$x = $y;
|
||||
}
|
||||
}
|
||||
push @hours, ("23") if ($x); # terminate last hour range
|
||||
if ($hours[0] == 0 and $hours[-1] == 23) {
|
||||
push @hours, ("0") if ($x); # terminate last hour range
|
||||
if ($hours[0] == 0 and $hours[-1] == 0 ) {
|
||||
$hours[0] = $hours[-2];
|
||||
$#hours -= 2;
|
||||
}
|
||||
|
@ -650,21 +673,51 @@ sub fill_T (\@$$$$) {
|
|||
} # /foreach $d (@adays)
|
||||
# step 2.4 generate T:-lines
|
||||
foreach $h (sort keys %hd) {
|
||||
next if $h =~ /^$/; # hourlist must not be empty
|
||||
$hd{$h} =~ s/^,//;
|
||||
$hd{$h} = find_ranges(split(/,/, $hd{$h}));
|
||||
push @$addT, "T:$range$hd{$h}/$h=$content\n";
|
||||
}
|
||||
@bdays = sort @bdays; # generate dayranges (1-5) if possible
|
||||
$d = find_ranges(@bdays); # generate dayranges (1-5) if possible
|
||||
push @$addT, "T:$range$d/*=$content\n" if ($d);
|
||||
} # /sub fill_T
|
||||
|
||||
# compare hours of given days (given as $dh->{day})
|
||||
sub same_hours (@) {
|
||||
my ($d, @days);
|
||||
# use only days with hour definitions
|
||||
foreach $d (@_) {
|
||||
push @days, $d if (defined($d) and scalar(%$d));
|
||||
}
|
||||
return 1 unless (scalar(@days)); # no days, no differences
|
||||
my ($and, $or);
|
||||
$d = shift @days;
|
||||
$and = $or = $d->{"_bits"};
|
||||
foreach $d (@days) {
|
||||
$or |= $d->{"_bits"};
|
||||
$and &= $d->{"_bits"};
|
||||
}
|
||||
return ($and == $or);
|
||||
} # /sub same_hours
|
||||
|
||||
# convert list of numbers to ranges, e.g. 1,2,3,W -> 1-3,W
|
||||
sub find_ranges (@) {
|
||||
my @days = sort @_;
|
||||
my ($d, $x);
|
||||
$x = -1; # previous day
|
||||
foreach $d (@bdays) {
|
||||
foreach $d (@days) {
|
||||
next if ($d !~ /^\d$/);
|
||||
if ($x+1 == $d) {
|
||||
$x = $d;
|
||||
$d = "-$d";
|
||||
}
|
||||
$x = $d;
|
||||
else {
|
||||
$x = $d;
|
||||
}
|
||||
}
|
||||
$d = "," . join(",", @bdays);
|
||||
$d = "," . join(",", @days);
|
||||
while ($d =~ s/,-\d(,-\d)/$1/g) {};
|
||||
$d =~ s/(,\d),(-\d)/$1$2/g;
|
||||
$d =~ s/^,//;
|
||||
push @$addT, "T:$range$d/*=$content\n" if ($d);
|
||||
} # /sub fill_T
|
||||
return $d;
|
||||
} # /sub find_ranges
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
.\" CHECKIN $Date: 2003/09/04 19:45:07 $
|
||||
.\" CHECKIN $Date: 2003/10/29 17:41:35 $
|
||||
.TH ISDNRATE 1 "@MANDATE@" -lt-
|
||||
.SH NAME
|
||||
isdnrate \- Print telefon rates and various info from rate\-files(5).
|
||||
|
@ -307,7 +307,7 @@ getting a SIGHUP signal.
|
|||
.SH "SEE ALSO"
|
||||
.BR rate-files(5) ", " isdnlog(8) ", " isdn.conf(5)
|
||||
.SH BUGS
|
||||
Definitly yes. Sometimes more then one daemon can be started, sometimes the
|
||||
Definitely yes. Sometimes more then one daemon can be started, sometimes the
|
||||
socket is not removed, when the daemon terminates. if this happens
|
||||
('socket in use'), do a
|
||||
.I rm /tmp/isdnrate
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* #define DEBUG_REDIRZ */
|
||||
|
||||
/* $Id: rate.c,v 1.85 2002/07/25 18:16:06 akool Exp $
|
||||
/* $Id: rate.c,v 1.86 2003/10/29 17:41:35 tobiasb Exp $
|
||||
*
|
||||
* Tarifdatenbank
|
||||
*
|
||||
|
@ -21,6 +21,37 @@
|
|||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* $Log: rate.c,v $
|
||||
* Revision 1.86 2003/10/29 17:41:35 tobiasb
|
||||
* isdnlog-4.67:
|
||||
* - Enhancements for isdnrep:
|
||||
* - New option -r for recomputing the connection fees with the rates
|
||||
* from the current (and for a different or the cheapest provider).
|
||||
* - Revised output format of summaries at end of report.
|
||||
* - New format parameters %j, %v, and %V.
|
||||
* - 2 new input formats for -t option.
|
||||
* - Fix for dualmode workaround 0x100 to ensure that incoming calls
|
||||
* will not become outgoing calls if a CALL_PROCEEDING message with
|
||||
* an B channel confirmation is sent by a terminal prior to CONNECT.
|
||||
* - Fixed and enhanced t: Tag handling in pp_rate.
|
||||
* - Fixed typo in interface description of tools/rate.c
|
||||
* - Fixed typo in tools/isdnrate.man, found by Paul Slootman.
|
||||
* - Minor update to sample isdn.conf files:
|
||||
* - Default isdnrep format shows numbers with 16 chars (+ & 15 digits).
|
||||
* - New isdnrep format (-FNIO) without display of transfered bytes.
|
||||
* - EUR as currency in Austria, may clash with outdated rate-at.dat.
|
||||
* The number left of the currency symbol is nowadays insignificant.
|
||||
* - Changes checked in earlier but after step to isdnlog-4.66:
|
||||
* - New option for isdnrate: `-rvNN' requires a vbn starting with NN.
|
||||
* - Do not compute the zone with empty strings (areacodes) as input.
|
||||
* - New ratefile tags r: und t: which need an enhanced pp_rate.
|
||||
* For a tag description see rate-files(5).
|
||||
* - Some new and a few updated international cellphone destinations.
|
||||
*
|
||||
* NOTE: If there any questions, problems, or problems regarding isdnlog,
|
||||
* feel free to join the isdn4linux mailinglist, see
|
||||
* https://www.isdn4linux.de/mailman/listinfo/isdn4linux for details,
|
||||
* or send a mail in English or German to <tobiasb@isdn4linux.de>.
|
||||
*
|
||||
* Revision 1.85 2002/07/25 18:16:06 akool
|
||||
* isdnlog-2.60:
|
||||
* - new provider "01081" (1,5 EuroCent/minute)
|
||||
|
@ -670,7 +701,7 @@
|
|||
*
|
||||
* int pnum2prefix(int pnum, time_t when)
|
||||
* converts the external provider number to the internal prefix at
|
||||
* the given date/time when, or know if when is 0
|
||||
* the given date/time when, or now if when is 0
|
||||
*
|
||||
* inline int prefix2pnum(int prefix)
|
||||
* returns the external provider number
|
||||
|
|
Loading…
Reference in New Issue