diff --git a/isdnlog/.country-alias b/isdnlog/.country-alias index 69b16508..623e5e80 100644 --- a/isdnlog/.country-alias +++ b/isdnlog/.country-alias @@ -95,6 +95,7 @@ libyien libyen liechtensctein liechtenstein madaira madeira maderia madeira +malayisa malaysia marianen (nördliche) marianen (saipannord-) marokka marokko marshall inseln marshallinseln diff --git a/isdnlog/Makefile.in b/isdnlog/Makefile.in index e03a1007..6b6d55d0 100644 --- a/isdnlog/Makefile.in +++ b/isdnlog/Makefile.in @@ -1,4 +1,4 @@ -## $Id: Makefile.in,v 1.126 1999/11/28 19:32:41 akool Exp $ +## $Id: Makefile.in,v 1.127 1999/12/01 21:47:23 akool Exp $ ## ## ISDN accounting for isdn4linux. ## @@ -19,6 +19,31 @@ ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## ## $Log: Makefile.in,v $ +## Revision 1.127 1999/12/01 21:47:23 akool +## isdnlog-3.72 +## - new rates for 01051 +## - next version of isdnbill +## +## - isdnlog/tools/telnum.c ... cleanup +## - isdnlog/tools/isdnrate.c ... -s Service +## - isdnlog/tools/rate.{c,h} ... -s +## - isdnlog/tools/NEWS ... -s +## - doc/isdnrate.man .. updated -o, -s +## - doc/rate-files.man ... updated +## - isdnlog/tools/dest/README.makedest ... updt. +## - isdnlog/isdnlog/isdnlog.8.in .. updt. +## +## Telrate +## - isdnlog/tools/telrate/README-telrate +## - isdnlog/tools/telrate/config.in NEW +## - isdnlog/tools/telrate/configure NEW +## - isdnlog/tools/telrate/Makefile.in NEW +## - isdnlog/tools/telrate/index.html.in was index.html +## - isdnlog/tools/telrate/info.html.in was info.html +## - isdnlog/tools/telrate/telrate.cgi.in was telrate.cgi +## - isdnlog/tools/telrate/leo.sample NEW sample config +## - isdnlog/tools/telrate/alex.sample NEW sample config +## ## Revision 1.126 1999/11/28 19:32:41 akool ## isdnlog-3.71 ## @@ -867,7 +892,7 @@ SERVICEFILE = /etc/services # DON'T EDIT BELOW THIS LINE ###################################################################### -VERSION = 3.71 +VERSION = 3.72 MANPAGES = isdnlog/callerid.conf.5 isdnlog/isdn.conf.5 \ isdnlog/isdnformat.5 isdnlog/isdnlog.5 isdnlog/isdnlog.8 \ diff --git a/isdnlog/country-de.dat b/isdnlog/country-de.dat index 16afcae4..c7d5f94e 100644 --- a/isdnlog/country-de.dat +++ b/isdnlog/country-de.dat @@ -368,7 +368,7 @@ T:_RUMF N:Russische Föderat. (westl.) A:Russische Foderat. (westl.) -A:Rußland (westl.), GUS (Russische Föderation), GUS +A:Rußland (westl.), GUS (Russische Föderation), GUS, Russische Förderation West C:+7863, +7862, +7861, +7820, +7817, +7816, +7815, +7814 C:+7811, +7543, +7517, +75112, +75110, +7510, +7505, +7503, +7501, +709246 C:+709245, +709244, +709243, +709237, +7091, +7087, +7086, +7085, +7084 @@ -396,7 +396,7 @@ R:RU T:MOW N:Russische Forderation (ostl.) -A:Rußland, Rußland (östl.), Russische Föderation, Russian Federation +A:Rußland, Rußland (östl.), Russische Föderation, Russian Federation, Russische Förderation Ost C:+7 T:SU @@ -835,15 +835,15 @@ E:Germany C:+49 T:DE -N:Deutschland Mobilfunk -C:+491610,+491611,+491612,+491613,+491614,+491615,+491616,+491617,+491619 # C -C:+491618 # T-C-Tel Voice Mail -C:+49170,+49171,+49175 # D1 -C:+49172,+49173,+49174 # D2 -C:+49177,+49178 # Eplus -C:+49176,+49179 # E2 -R:DE -T:_DEMF +# N:Deutschland Mobilfunk +# C:+491610,+491611,+491612,+491613,+491614,+491615,+491616,+491617,+491619 # C +# C:+491618 # T-C-Tel Voice Mail +# C:+49170,+49171,+49175 # D1 +# C:+49172,+49173,+49174 # D2 +# C:+49177,+49178 # Eplus +# C:+49176,+49179 # E2 +# R:DE +# T:_DEMF N:Deutschland Mobilfunk C-Tel Voice Mail A:C-Tel Voice Mail @@ -854,7 +854,7 @@ T:_DEMCM N:Deutschland Mobilfunk C-Netz A:C-Netz C:+491610,+491611,+491612,+491613,+491614,+491615,+491616,+491617,+491619 -R:_DEMF +R:DE T:_DEMC N:Deutschland Mobilfunk D1 diff --git a/isdnlog/isdnlog/isdnlog.8.in b/isdnlog/isdnlog/isdnlog.8.in index 7d845999..5b62caae 100644 --- a/isdnlog/isdnlog/isdnlog.8.in +++ b/isdnlog/isdnlog/isdnlog.8.in @@ -1,13 +1,19 @@ -.\" $Id: isdnlog.8.in,v 1.2 1998/12/29 15:53:50 paul Exp $ -.\" CHECKIN $Date: 1998/12/29 15:53:50 $ +.\" $Id: isdnlog.8.in,v 1.3 1999/12/01 21:47:24 akool Exp $ +.\" CHECKIN $Date: 1999/12/01 21:47:24 $ .TH isdnlog 8 "@MANDATE_ISDNLOG8@" "ISDN 4 Linux @I4LVERSION@" "Linux System Administration" .PD 0 .SH NAME isdnlog \- isdn log system (and more) +.SH "DESCRIPTION" +Isdnlog gets information from your isdn card, decodes this +information, and can do anything with it, such as logging, starting +programs, and more. All options to isdnlog can be given as command line +flags, or you can specify a file with options (recommended). + .SH "RESTRICTION" Isdnlog only works with the HiSax isdn driver. Other cards with their -own driver are not supported. Additionally you need to enable d-channel logging +own driver are not supported. Additionally you need to enable d-channel logging (you can use "hisaxctrl 1 4" to do that, e.g. "hisaxctrl line0 1 4"). Isdnlog can only log outgoing calls that originate from @@ -17,12 +23,6 @@ isdn card, with crossed lines. Such a card is not usable for communicating, but can log outgoing calls from any device (see dual option below). -.SH "DESCRIPTION" -Isdnlog gets information from your isdn card, decodes this -information, and can do anything with it, such as logging, starting -programs, and more. All options to isdnlog can be given as command line -flags, or you can specify a file with options (recommended). - .SH "GENERAL OPTIONS" .TP @@ -30,8 +30,10 @@ flags, or you can specify a file with options (recommended). show version information and exit. .TP -.B \-fFILE -read options from the config file FILE. The first line should be +.BI \-f FILE +read options from the config file +.IR FILE . +The first line should be "[options]". You may use blank lines and comments (starting with a #). All config files for isdnlog have the format described in isdn.conf(5). Debug options must be given on the command line, they cannot be stored in a @@ -47,38 +49,34 @@ Isdnlog has a replay mode for debugging, where you can simulate previous recorded events. In that case use "-" instead of a device. .TP -.B \-r -Replay a debug file (e.g. /tmp/isdnctrl0) to find bugs. With this flag -you should give a filename with the debug information instead of a device. -It will also work with files not created by isdnlog (e.g. -"cat /dev/isdnctrl0"). - -.TP -.B \-n newline={yes|no} -Display throughput messages on the same line (only useful with logging to -stderr or a console device). - -.TP -.B \-Wx width="value" -Limit all messages to X characters per line. - -.TP -.B \-Ax amt="value" +.B \-A\fIx\fB amt="value" Set digits necessary to get an outside line, when connected through a PABX. You can give several codes padded with a ":" (e.g. -A0:80:81:82). .TP -.B \-0x:y trim="value:value" -Suppress leading zeroes. If isdnlog is connected through a PABX, it is +.B \-B\fIvbn\fB vbn="value" +Set the provider preselectio to the given value. More prefixes may be separated +by a ":". +.br +Values are e.g. "010" for DE, "10" for AT, "16:17" for NL, "9" for FR. + +.TP +.B \-R\fIprefix\fB preselected="value" +Set the preselected (i.e the provider choosen, if no prefix is dialed) +provider to value. Value should be without \fIvbn\fR. + +.TP +.B \-0\fIx:y\fB trim="value:value" +Suppress leading digits. If isdnlog is connected through a PABX, it is sometimes not possible to let isdnlog distinguish between a national and an international call, even with help of the .B \-A option. .br -This option requires two digits separated with ":" as an argument. These digits -tell isdnlog how many leading zeroes to remove from incoming and outgoing calls -respectively. If only one digit is given, it is used for both values. +This option requires two values separated with ":" as an argument. These values +tell isdnlog how many leading digits to remove from incoming and outgoing calls +respectively. If only one value is given, it is used for both incoming and outgoing calls. .br Don't use this in combination with the .B \-A @@ -93,23 +91,57 @@ numbers must have one leading zero). So, in this case, the option \fB-03:2\fR would be correct. .TP -.B \-o other={yes|no} +.B \-o other={yes|no} Normally "causes" (e.g. "non-selected user clearing") for other connected ISDN devices are not displayed, only those which are related to the connection will be shown. With this option the causes for the other devices are also displayed. .TP -.B \-2x dual="value" +.B \-u\fIx\fB ignoreRR="value" +Ignore "housekeeping" frames. +.I x +may be 1 (ignore RR=Receiver ready) or 2 (ignore EMP=Euracom Management Protokoll) frames. + +.TP +.B \-U\fIx\fB ignoreCOLP="value" +Ignore COLP/CLIP frames. + +.TP +.B \-2\fIx\fB dual="value" Enable dual mode. You need this if you have a second isdn card attached with crossed lines so it can listen to what other isdn devices like telephones -are doing. With x=2 you can increase the debug output - every single +are doing. With \fIx\fR=2 you can increase the debug output - every single digit will be displayed. +.TP +.B \-1 +A HFC-based card is used for echo mode. Enable echo mode for the HFC card with +.br +.I hisaxctrl id 10 1 +.br +.I hisaxctrl id 12 1 + .SH "DEBUG MODULE" .TP -.B \-vX log=X +.B \-r +Replay a debug file (e.g. /tmp/isdnctrl0) to find bugs. With this flag +you should give a filename with the debug information instead of a device. +It will also work with files not created by isdnlog (e.g. +"cat /dev/isdnctrl0"). + +.TP +.B \-n newline={yes|no} +Display throughput messages on the same line (only useful with logging to +stderr or a console device). + +.TP +.B \-W\fIX\fR width="value" +Limit all messages to X characters per line. + +.TP +.B \-v\fIX\fR log=X Isdnlog can copy all information to /tmp/DEVICE (e.g. /tmp/isdnctrl0 if you started isdnlog with /dev/isdnctrl0). Choose what debugging you want from the following list, add the corresponding numbers together and use @@ -124,7 +156,7 @@ copy all "HEX:" lines from the hisax isdn device driver. copy /dev/isdnctrl output (or whatever device you specified). .TP 4 -copy /dev/isdninfo output +copy /dev/isdninfo output .TP 8 copy transfer values ("ibyte","obyte"). @@ -237,20 +269,20 @@ You should log at least 0x7 (errors, warnings, notice) messages. Log estimated time till next charge signal. .TP -.B \-mX stdout="value" +.B \-m\fIX\fB stdout="value" Log to stderr. .TP -.B \-OX outfile="path" -Log to file X instead of stderr. Isdnlog will close this device when it +.B \-O\fIX\fB outfile="path" +Log to file \fIX\fR instead of stderr. Isdnlog will close this device when it gets a signal -SIGHUP (-1). Only valid with -m option. .br If the name starts with a "+", new data will be appended to the existing file. Default behaviour is to truncate the file when isdnlog opens it. .TP -.B \-C X console="path" -Log to console X instead of stderr. You can use -O and -C together, +.B \-C \fIX\fB console="path" +Log to console \fIX\fR instead of stderr. You can use -O and -C together, so that isdnlog copies output to both. Specify a full pathname. Beware: you .ul @@ -263,50 +295,53 @@ With this flag, isdnlog will generate output for monitor programs like imon, imontty or isdnmon. You must also give -m with 0x800 enabled. .TP -.B \-lX syslog="value" -Log to syslog. X is the log code. You can log to syslog and to stdout at +.B \-l\fIX\fB syslog="value" +Log to syslog. \fIX\fR is the log code. You can log to syslog and to stdout at the same time. .TP -.B \-xX xisdn="value" +.B \-x\fIX\fB xisdn="value" Pass information to x11 client. X is the log code. You can pass information to x11 clients and log to syslog and/or stdout at the same time. .TP -.B \-cX calls="value" -Only with -xX : save the last X calls and pass this information to an +.B \-p\fIPORT\fB port="value" +Pass information to x11 client on this \fIPORT\fR. + +.TP +.B \-c\fIX\fB calls="value" +Only with -x\fIX\fR : save the last \fIX\fR calls and pass this information to an x11 client. Default value is 100. .TP -.B \-LX xlog="value" -Only with -xX : save the last X messages and pass this information to an +.B \-L\fIX\fB xlog="value" +Only with -x\fIX\fR : save the last \fIX\fR messages and pass this information to an x11 client. Default value is 500. .TP -.B \-wX thruput="value" +.B \-w\fIX\fB thruput="value" If you enabled throughput logging (0x400), isdnlog will log the throughput -every X seconds. +every \fIX\fR seconds. .SH "TIME MODULE" .TP -.B \-tX time={0|1|2} +.B \-t\fIX\fB time={0|1|2} Isdnlog will set your local system time to the time transmitted by your -isdn service provider: -t1 = once, -t2 = every time. +isdn service provider: -t1 = once, -t2 = every time. .SH "CHARGEHUP MODULE" .TP -.B \-hX hangup="value" +.B \-h\fIX\fB hangup="value" The isdn kernel system has a chargehup system, so it will hang up a few seconds before the next charge signal. If you don't get a charge -signal from your phone company, isdnlog can emulate it. +signal from your phone company, isdnlog can emulate it. On every outgoing connection, isdnlog will calculate the charge time from day of week, time of day and the distance zone of the -connection. So you need to list the system in isdn.conf with a ZONE= -line. +connection. The kernel needs to know how long the charge time is, and how many seconds before the next charge signal it should hang up. You have to set @@ -322,18 +357,6 @@ isdnctrl, but this would have the same effect). You should run isdnlog with -t1 or better with -t2, so isdnlog sets the local time in sync with telephone switching office. -.TP -.B \-F cityweekend=y -Deutsche Telekom offer an option where on weekends and national holidays, -you are charged one unit every four minutes, instead of the normal rate -of one unit every 2.5 minutes from 5:00 - 21:00. Isdnlog must be informed -of this option when the chargehup option is used, or it will hangup at -completely the wrong time. As the charge info delivered is -.B not -modified, only the final bill you get is lower, isdnlog also needs to -override the charge info if it is delivered. - - .SH "START MODULE" isdnlog can react on any event and start programs. This feature is @@ -385,7 +408,7 @@ access that device. .TP .B @I4LCONFDIR@/@CONFFILE@ isdnlog config file. Options to isdnlog can be given on the command line, can -be stored in this file in [options] (with command line option +be stored in this file in [options] (with command line option -f@I4LCONFDIR@/@CONFFILE@), or in a different config file, but isdnlog will look at this file for sections [global] [variables] [isdnlog]. @@ -414,7 +437,7 @@ syslog=0x1ff7 # syslog logging level thruput=60 # if throughput logging is enabled: log every X seconds time=2 # set time: 0 = never; 1 = once; 2 = every time #hangup= # simulate charge signals -start=yes # enable starting programs +start=yes # enable starting programs .SH SEE ALSO .B isdnconf(8) isdn.conf(5) callerid.conf(5) diff --git a/isdnlog/isdnrep/isdnbill.c b/isdnlog/isdnrep/isdnbill.c index a2dc065b..5df5b7c4 100644 --- a/isdnlog/isdnrep/isdnbill.c +++ b/isdnlog/isdnrep/isdnbill.c @@ -1,4 +1,4 @@ -/* $Id: isdnbill.c,v 1.4 1999/11/28 19:32:41 akool Exp $ +/* $Id: isdnbill.c,v 1.5 1999/12/01 21:47:25 akool Exp $ * * ISDN accounting for isdn4linux. (Billing-module) * @@ -40,6 +40,7 @@ #define CALLED 1 #define MAXMYMSN 20 +#define MAXSI 10 #define FREECALL 0 #define ORTSZONE 1 @@ -54,11 +55,18 @@ #define SUBTOTAL 0 #define TOTAL 1 -#define COUNTRYLEN 30 +#define COUNTRYLEN 32 #define PROVLEN 20 +#define MSNLEN 6 + +#undef ME +#undef OTHER + +#define ME (c.dialout ? CALLING : CALLED) +#define OTHER (c.dialout ? CALLED : CALLING) typedef struct { - char num[2][64]; + char num[2][64]; double duration; time_t connect; int units; @@ -73,7 +81,6 @@ typedef struct { char currency[64]; double pay; int provider; - int zone; double compute; int computed; @@ -81,6 +88,9 @@ typedef struct { char country[BUFSIZ]; char sprovider[BUFSIZ]; char error[BUFSIZ]; + int zone; + int ihome; + int known[2]; } CALLER; typedef struct { @@ -90,7 +100,7 @@ typedef struct { double duration; double compute; double aktiv; - char *alias[8]; + char *alias; } MSNSUM; typedef struct { @@ -110,17 +120,32 @@ typedef struct { double aktiv; } ZONESUM; -static CALLER curcall; -static MSNSUM msnsum[2][MAXMYMSN]; -static PROVSUM provsum[2][MAXPROVIDER]; -static ZONESUM zonesum[2][MAXZONE]; -static char rstr[BUFSIZ]; +typedef struct { + char msn[32]; + int ncalls; + double pay; + double duration; + double compute; +} PARTNER; -static int nhome = 0; -static int homei = 0; +static char options[] = "nv:V"; +static char usage[] = "%s: usage: %s [ -%s ]\n"; + + +static CALLER c; +static MSNSUM msnsum[2][MAXSI][MAXMYMSN]; +static PROVSUM provsum[2][MAXPROVIDER]; +static ZONESUM zonesum[2][MAXZONE]; +static PARTNER *partner[2]; +static TELNUM number[2]; +static char rstr[BUFSIZ]; +static char home[BUFSIZ]; +static int nhome = 0; int verbose = 0; +static int onlynumbers = 0; + int print_msg(int Level, const char *fmt, ...) { @@ -155,16 +180,16 @@ int print_in_modules(const char *fmt, ...) } /* print_in_modules */ -static int when(time_t connect, char *s) +static void when(char *s, int *day, int *month) { - auto struct tm *tm = localtime(&connect); + auto struct tm *tm = localtime(&c.connect); + *day = tm->tm_mday; + *month = tm->tm_mon + 1; + sprintf(s, "%02d.%02d.%04d %02d:%02d:%02d", - tm->tm_mday, tm->tm_mon + 1, tm->tm_year + 1900, - tm->tm_hour, tm->tm_min, tm->tm_sec); - - return(tm->tm_mon + 1); + *day, *month, tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec); } /* when */ @@ -216,37 +241,57 @@ char *timestr(double n) static void total(int w) { - register int i; + register int i, j; + auto int ncalls = 0; + auto double duration = 0.0, pay = 0.0, compute = 0.0; printf("------------------------------------------------------------------------------\n"); - printf("\nMSN calls Duration Charge Computed\n"); - printf("------------------------------------------------\n"); + printf("\nMSN calls Duration Charge Computed\n"); + printf("---------------------------------------------------------------\n"); for (i = 0; i < nhome; i++) { - if (msnsum[w][i].ncalls) - printf("%6s %5d %s DM %8.3f DM %8.3f\n", - msnsum[w][i].msn, - msnsum[w][i].ncalls, - timestr(msnsum[w][i].duration), - msnsum[w][i].pay, - msnsum[w][i].compute); + for (j = 0; j < MAXSI; j++) { + if (msnsum[w][j][i].ncalls) { + printf("%6s,%d %-12s %5d %s DM %8.3f DM %8.3f\n", + msnsum[w][j][i].msn, + j, + msnsum[w][j][i].alias, + msnsum[w][j][i].ncalls, + timestr(msnsum[w][j][i].duration), + msnsum[w][j][i].pay, + msnsum[w][j][i].compute); - if (w == SUBTOTAL) { - strcpy(msnsum[TOTAL][i].msn, msnsum[SUBTOTAL][i].msn); - msnsum[TOTAL][i].ncalls += msnsum[SUBTOTAL][i].ncalls; - msnsum[TOTAL][i].duration += msnsum[SUBTOTAL][i].duration; - msnsum[TOTAL][i].pay += msnsum[SUBTOTAL][i].pay; - msnsum[TOTAL][i].compute += msnsum[SUBTOTAL][i].compute; + ncalls += msnsum[w][j][i].ncalls; + duration += msnsum[w][j][i].duration; + pay += msnsum[w][j][i].pay; + compute += msnsum[w][j][i].compute; + } /* if */ - msnsum[SUBTOTAL][i].ncalls = 0; - msnsum[SUBTOTAL][i].duration = 0; - msnsum[SUBTOTAL][i].pay = 0; - msnsum[SUBTOTAL][i].compute = 0; - } /* if */ + if (w == SUBTOTAL) { + strcpy(msnsum[TOTAL][j][i].msn, msnsum[SUBTOTAL][j][i].msn); + msnsum[TOTAL][j][i].alias = msnsum[SUBTOTAL][j][i].alias; + msnsum[TOTAL][j][i].ncalls += msnsum[SUBTOTAL][j][i].ncalls; + msnsum[TOTAL][j][i].duration += msnsum[SUBTOTAL][j][i].duration; + msnsum[TOTAL][j][i].pay += msnsum[SUBTOTAL][j][i].pay; + msnsum[TOTAL][j][i].compute += msnsum[SUBTOTAL][j][i].compute; + + msnsum[SUBTOTAL][j][i].ncalls = 0; + msnsum[SUBTOTAL][j][i].duration = 0; + msnsum[SUBTOTAL][j][i].pay = 0; + msnsum[SUBTOTAL][j][i].compute = 0; + } /* if */ + } /* for */ } /* for */ + printf("---------------------------------------------------------------\n"); + printf(" %5d %s DM %8.3f DM %8.3f\n", + ncalls, + timestr(duration), + pay, + compute); + printf("\nProvider calls Duration Charge Computed failures avail\n"); printf("---------------------------------------------------------------------------------------\n"); @@ -258,7 +303,7 @@ static void total(int w) else printf("%s%03d", vbn, i - 100); - printf(":%-24s", getProvider(pnum2prefix(i, 0))); + printf(":%-24s", getProvider(pnum2prefix(i, c.connect))); printf("%5d %s DM %8.3f DM %8.3f %8d %5.1f%%\n", provsum[w][i].ncalls, @@ -307,7 +352,7 @@ static void total(int w) timestr(zonesum[w][i].duration), zonesum[w][i].pay, zonesum[w][i].compute, - zonesum[w][i].pay - zonesum[w][i].aktiv); + zonesum[w][i].aktiv); } /* if */ if (w == SUBTOTAL) { @@ -329,31 +374,62 @@ static void total(int w) } /* total */ +static void showpartner() +{ + register int i, k; + + + for (k = 0; k < 2; k++) { + switch (k) { + case 0 : printf("Angerufene Partner:\n"); break; + case 1 : printf("Anrufer:\n"); break; + } /* switch */ + + for (i = 0; i < knowns; i++) + if (partner[k][i].ncalls) + printf("%-32s %-32s %5d %10.3f %s %10.3f\n", + partner[k][i].msn, + known[i]->who, + partner[k][i].ncalls, + partner[k][i].pay, + timestr(partner[k][i].duration), + partner[k][i].compute); + } /* for */ +} /* showpartner */ + + static char *numtonam(int n) { register int i, j = -1; + if (onlynumbers) + return(NULL); + for (i = 0; i < knowns; i++) { - if (!num_match(known[i]->num, curcall.num[n])) { + if (!num_match(known[i]->num, c.num[n])) { j = i; - if (known[i]->si == curcall.si1) + if (known[i]->si == c.si1) { + c.known[n] = i; return(known[i]->who); + } /* if */ } /* if */ } /* for */ + c.known[n] = j; + return((j == -1) ? NULL : known[j]->who); } /* numtonam */ -static void justify(char *fromnum, char *tonum, int dialout, TELNUM number) +static void justify(char *fromnum, char *tonum, TELNUM number) { register char *p1, *p2; - auto char s[BUFSIZ], sx[BUFSIZ]; + auto char s[BUFSIZ], sx[BUFSIZ], sy[BUFSIZ]; - p1 = numtonam(dialout ? CALLED : CALLING); + p1 = numtonam(c.dialout ? CALLED : CALLING); if (*number.msn) sprintf(sx, "%s%s%s", number.area, (*number.area ? "/" : ""), number.msn); @@ -365,11 +441,11 @@ static void justify(char *fromnum, char *tonum, int dialout, TELNUM number) else sprintf(s, "%s%s", (*number.country ? "0" : ""), sx); - p2 = msnsum[SUBTOTAL][homei].alias[curcall.si1]; + p2 = msnsum[SUBTOTAL][c.si1][c.ihome].alias; - printf("%12s %s %-17s", + printf("%12s %s %-21s", p2 ? p2 : fromnum, - (dialout ? "->" : "<-"), + (c.dialout ? "->" : "<-"), p1 ? p1 : s); *s = 0; @@ -387,6 +463,11 @@ static void justify(char *fromnum, char *tonum, int dialout, TELNUM number) strcat(s, ", "); strcat(s, number.sarea); + + if (c.dialout) { + sprintf(sy, ",%d", c.zone); + strcat(s, sy); + } /* if */ } /* if */ if (!*s) @@ -395,297 +476,403 @@ static void justify(char *fromnum, char *tonum, int dialout, TELNUM number) s[COUNTRYLEN] = 0; /* clipping */ - sprintf(curcall.country, "%-*s", COUNTRYLEN, s); + sprintf(c.country, "%-*s", COUNTRYLEN, s); } /* justify */ +static void findme() +{ + register int i; + register char *p; + auto char s[BUFSIZ]; + + + sprintf(s, "%*s", -MSNLEN, number[ME].msn); + s[MSNLEN] = 0; + + p = strstr(home, s); + + if (p == NULL) { + strcat(home, s); + strcat(home, "|"); + + p = strstr(home, s); + c.ihome = (int)(p - home) / 7; + + i = c.si1; + + for (c.si1 = 0; c.si1 < MAXSI; c.si1++) { + strcpy(msnsum[SUBTOTAL][c.si1][c.ihome].msn, number[ME].msn); + msnsum[SUBTOTAL][c.si1][c.ihome].alias = numtonam(ME); + } /* for */ + + c.si1 = i; + + nhome++; + } /* if */ + + c.ihome = (int)(p - home) / 7; +} /* findme */ + + +static void findrate() +{ + auto RATE Rate; + auto char *version; + + + clearRate(&Rate); + Rate.start = c.connect; + Rate.now = c.connect + c.duration; + Rate.prefix = pnum2prefix(c.provider, c.connect); + + Rate.src[0] = number[CALLING].country; + Rate.src[1] = number[CALLING].area; + Rate.src[2] = number[CALLING].msn; + + Rate.dst[0] = number[CALLED].country; + Rate.dst[1] = number[CALLED].area; + Rate.dst[2] = number[CALLED].msn; + + if (getRate(&Rate, &version) != UNKNOWN) { + c.zone = Rate.z; + + if (!c.zone && (*number[CALLED].country && strcmp(number[CALLED].country, mycountry))) + c.zone = AUSLAND; + else if (getSpecial(c.num[CALLED])) + c.zone = SONDERRUFNUMMERN; + else if (c.zone == UNKNOWN) + c.zone = ELSEWHERE; + + zonesum[SUBTOTAL][c.zone].ncalls++; + + c.compute = Rate.Charge; + } + else { + c.zone = ELSEWHERE; + c.compute = c.pay; + sprintf(c.error, " ??? %s", version); + } /* else */ +} /* findrate */ + + int main(int argc, char *argv[], char *envp[]) { - register char *pl, *pr, *p; + register char *pl, *pr, *p, x; #ifdef DEBUG auto FILE *f = fopen("/www/log/isdn.log", "r"); #else auto FILE *f = fopen("/var/log/isdn.log", "r"); #endif - auto char s[BUFSIZ], sx[BUFSIZ], home[BUFSIZ]; - auto int z, i, l, col, month = -1; - auto TELNUM number[2]; + auto char s[BUFSIZ], sx[BUFSIZ]; + auto int l, col, day, lday = -1, month, lmonth = -1; auto double dur; - auto RATE Rate; auto char *version; - auto char *myname = basename(argv[0]); + auto char *myname = basename(argv[0]); + auto int opt; if (f != (FILE *)NULL) { + while ((opt = getopt(argc, argv, options)) != EOF) + switch (opt) { + case 'n' : onlynumbers++; + break; + + case 'v' : verbose = atoi(optarg); + break; + + case 'V' : print_version(myname); + exit(0); + + case '?' : printf(usage, argv[0], argv[0], options); + return(1); + } /* switch */ + + *home = 0; set_print_fct_for_tools(print_in_modules); - if (readconfig(myname) != 0) - return(1); + if (!readconfig(myname)) { - initHoliday("/usr/lib/isdn/holiday-de.dat", &version); + initHoliday(holifile, &version); - initDest("/usr/lib/isdn/dest.gdbm", &version); + if (verbose) + fprintf(stderr, "%s\n", version); - initRate("/etc/isdn/rate.conf", "/usr/lib/isdn/rate-de.dat", "/usr/lib/isdn/zone-de-%s.gdbm", &version); + initDest(destfile, &version); - memset(&msnsum, 0, sizeof(msnsum)); - memset(&provsum, 0, sizeof(provsum)); - memset(&zonesum, 0, sizeof(zonesum)); + if (verbose) + fprintf(stderr, "%s\n", version); - while (fgets(s, BUFSIZ, f)) { - pl = s; - col = 0; + initRate(rateconf, ratefile, zonefile, &version); - memset(&curcall, 0, sizeof(curcall)); + if (verbose) + fprintf(stderr, "%s\n", version); - while ((pr = strchr(pl, '|'))) { - memcpy(sx, pl, (l = (pr - pl))); - sx[l] = 0; - pl = pr + 1; - switch (col++) { - case 0 : break; + memset(&msnsum, 0, sizeof(msnsum)); + memset(&provsum, 0, sizeof(provsum)); + memset(&zonesum, 0, sizeof(zonesum)); - case 1 : deb(sx); - strcpy(curcall.num[CALLING], sx); - break; + partner[0] = (PARTNER *)calloc(knowns, sizeof(PARTNER)); + partner[1] = (PARTNER *)calloc(knowns, sizeof(PARTNER)); - case 2 : deb(sx); - strcpy(curcall.num[CALLED], sx); - break; + while (fgets(s, BUFSIZ, f)) { + pl = s; + col = 0; - case 3 : dur = atoi(sx); break; + memset(&c, 0, sizeof(c)); - case 4 : curcall.duration = atol(sx) / HZ; + while ((pr = strchr(pl, '|'))) { + memcpy(sx, pl, (l = (pr - pl))); + sx[l] = 0; + pl = pr + 1; - if (abs((int)dur - (int)curcall.duration) > 1) - curcall.duration = dur; - break; + switch (col++) { + case 0 : break; - case 5 : curcall.connect = atol(sx); break; - case 6 : curcall.units = atoi(sx); break; - case 7 : curcall.dialout = *sx == 'O'; break; - case 8 : curcall.cause = atoi(sx); break; - case 9 : curcall.ibytes = atoi(sx); break; - case 10 : curcall.obytes = atoi(sx); break; - case 11 : strcpy(curcall.version, sx); break; - case 12 : curcall.si1 = atoi(sx); break; - case 13 : curcall.si2 = atoi(sx); break; - case 14 : curcall.currency_factor = atof(sx); break; - case 15 : strcpy(curcall.currency, sx); break; - case 16 : curcall.pay = atof(sx); break; - case 17 : curcall.provider = atoi(sx); break; - case 18 : break; - } /* switch */ + case 1 : deb(sx); + strcpy(c.num[CALLING], sx); + break; - } /* while */ + case 2 : deb(sx); + strcpy(c.num[CALLED], sx); + break; - /* Repair wrong entries from older isdnlog-versions ... */ + case 3 : dur = atoi(sx); break; - if (!curcall.provider || (curcall.provider == UNKNOWN)) - curcall.provider = preselect; + case 4 : c.duration = atol(sx) / HZ; + break; - if (curcall.dialout && (strlen(curcall.num[CALLED]) > 3) && !getSpecial(curcall.num[CALLED])) { - sprintf(s, "0%s", curcall.num[CALLED] + 3); + case 5 : c.connect = atol(sx); break; + case 6 : c.units = atoi(sx); break; + case 7 : c.dialout = *sx == 'O'; break; + case 8 : c.cause = atoi(sx); break; + case 9 : c.ibytes = atoi(sx); break; + case 10 : c.obytes = atoi(sx); break; + case 11 : strcpy(c.version, sx); break; + case 12 : c.si1 = atoi(sx); break; + case 13 : c.si2 = atoi(sx); break; + case 14 : c.currency_factor = atof(sx); break; + case 15 : strcpy(c.currency, sx); break; + case 16 : c.pay = atof(sx); break; + case 17 : c.provider = atoi(sx); break; + case 18 : break; + } /* switch */ - if (getSpecial(s)) - strcpy(curcall.num[CALLED], s); - } /* if */ + } /* while */ - if (!curcall.dialout && (strlen(curcall.num[CALLING]) > 3) && !getSpecial(curcall.num[CALLING])) { - sprintf(s, "0%s", curcall.num[CALLING] + 3); - if (getSpecial(s)) - strcpy(curcall.num[CALLING], s); - } /* if */ + /* Repair wrong entries from older (or current?) isdnlog-versions ... */ - /* if (curcall.dialout) */ - /* if (curcall.duration) */ - /* if (curcall.provider != UNKNOWN) */ + if (abs((int)dur - (int)c.duration) > 1) { + if (verbose) + fprintf(stderr, "REPAIR: Duration %f -> %f\n", c.duration, dur); - if (*curcall.num[CALLING] && *curcall.num[CALLED]) { - - i = when(curcall.connect, s); - - if (month == -1) - month = i; - else if (i != month) { - total(SUBTOTAL); - month = i; + c.duration = dur; } /* if */ - printf("%s%s ", s, timestr(curcall.duration)); + if (!memcmp(c.num[CALLED], "+4910", 5)) { + p = c.num[CALLED] + 7; + x = *p; + *p = 0; - normalizeNumber(curcall.num[CALLING], &number[CALLING], TN_ALL); - normalizeNumber(curcall.num[CALLED], &number[CALLED], TN_ALL); + c.provider = atoi(c.num[CALLED] + 5); - if (curcall.dialout) { + *p = x; - p = strstr(home, number[CALLING].msn); + memmove(c.num[CALLED] + 3, c.num[CALLED] + 8, strlen(c.num[CALLED]) - 7); - if (p == NULL) { - strcat(home, number[CALLING].msn); - strcat(home, "|"); + if (verbose) + fprintf(stderr, "REPAIR: Provider=%d\n", c.provider); + } /* if */ - p = strstr(home, number[CALLING].msn); - homei = (int)(p - home) / 7; + if (!c.provider || (c.provider == UNKNOWN)) { + if (verbose) + fprintf(stderr, "REPAIR: Provider %d -> %d\n", c.provider, preselect); - strcpy(msnsum[SUBTOTAL][homei].msn, number[CALLING].msn); + c.provider = preselect; + } /* if */ - i = curcall.si1; + if (c.dialout && (strlen(c.num[CALLED]) > 3) && !getSpecial(c.num[CALLED])) { + sprintf(s, "0%s", c.num[CALLED] + 3); - for (curcall.si1 = 1; curcall.si1 < 8; curcall.si1++) - msnsum[SUBTOTAL][homei].alias[curcall.si1] = numtonam(CALLING); + if (getSpecial(s)) { + if (verbose) + fprintf(stderr, "REPAIR: Callee %s -> %s\n", c.num[CALLED], s); - curcall.si1 = i; + strcpy(c.num[CALLED], s); + } /* if */ + } /* if */ - nhome++; + if (!c.dialout && (strlen(c.num[CALLING]) > 3) && !getSpecial(c.num[CALLING])) { + sprintf(s, "0%s", c.num[CALLING] + 3); + + if (getSpecial(s)) { + if (verbose) + fprintf(stderr, "REPAIR: Caller %s -> %s\n", c.num[CALLING], s); + + strcpy(c.num[CALLING], s); + } /* if */ + } /* if */ + + /* if (c.dialout) */ + /* if (c.duration) */ + /* if (c.provider != UNKNOWN) */ + + if (*c.num[CALLING] && *c.num[CALLED]) { + + when(s, &day, &month); + + if (lmonth == -1) + lmonth = month; + else if (month != lmonth) { + total(SUBTOTAL); + lmonth = month; } /* if */ - homei = (int)(p - home) / 7; - msnsum[SUBTOTAL][homei].ncalls++; - - justify(number[CALLING].msn, curcall.num[CALLED], curcall.dialout, number[CALLED]); - - provsum[SUBTOTAL][curcall.provider].ncalls++; - - strcpy(s, getProvider(pnum2prefix(curcall.provider, 0))); - s[PROVLEN] = 0; - - if (curcall.provider < 100) - sprintf(curcall.sprovider, " %s%02d:%-*s", vbn, curcall.provider, PROVLEN, s); - else - sprintf(curcall.sprovider, "%s%03d:%-*s", vbn, curcall.provider - 100, PROVLEN, s); - - - if (!curcall.duration) { - printf(" %s%s", curcall.country, curcall.sprovider); - - if ((curcall.cause != 0x1f) && /* Normal, unspecified */ - (curcall.cause != 0x10)) /* Normal call clearing */ - printf(" %s", qmsg(TYPE_CAUSE, VERSION_EDSS1, curcall.cause)); - - if ((curcall.cause == 0x22) || /* No circuit/channel available */ - (curcall.cause == 0x2a) || /* Switching equipment congestion */ - (curcall.cause == 0x2f)) /* Resource unavailable, unspecified */ - provsum[SUBTOTAL][curcall.provider].failed++; - - printf("\n"); - continue; - } /* if */ - - - clearRate(&Rate); - Rate.start = curcall.connect; - Rate.now = curcall.connect + curcall.duration; - Rate.prefix = pnum2prefix(curcall.provider, 0); - - Rate.src[0] = number[CALLING].country; - Rate.src[1] = number[CALLING].area; - Rate.src[2] = number[CALLING].msn; - - Rate.dst[0] = number[CALLED].country; - Rate.dst[1] = number[CALLED].area; - Rate.dst[2] = number[CALLED].msn; - - if (getRate(&Rate, &version) != UNKNOWN) { - z = Rate.z; - - if (!z && (*number[CALLED].country && strcmp(number[CALLED].country, mycountry))) - z = AUSLAND; - else if (getSpecial(curcall.num[CALLED])) - z = SONDERRUFNUMMERN; - else if (z == UNKNOWN) - z = ELSEWHERE; - - zonesum[SUBTOTAL][z].ncalls++; - - curcall.compute = Rate.Charge; - } - else { - z = ELSEWHERE; - curcall.compute = curcall.pay; - sprintf(curcall.error, " ??? %s", version); + if (lday == -1) + lday = day; + else if (day != lday) { + printf("\n"); + lday = day; } /* else */ - if ((z == 1) || (z == 2)) { - auto struct tm *tm = localtime(&curcall.connect); - auto int takte; - auto double price; + printf("%s%s ", s, timestr(c.duration)); + + normalizeNumber(c.num[CALLING], &number[CALLING], TN_ALL); + normalizeNumber(c.num[CALLED], &number[CALLED], TN_ALL); + + findme(); + + if (c.dialout) { + + findrate(); + + msnsum[SUBTOTAL][c.si1][c.ihome].ncalls++; + + justify(number[CALLING].msn, c.num[CALLED], number[CALLED]); + + provsum[SUBTOTAL][c.provider].ncalls++; + + strcpy(s, getProvider(pnum2prefix(c.provider, c.connect))); + s[PROVLEN] = 0; + + if (c.provider < 100) + sprintf(c.sprovider, " %s%02d:%-*s", vbn, c.provider, PROVLEN, s); + else + sprintf(c.sprovider, "%s%03d:%-*s", vbn, c.provider - 100, PROVLEN, s); - takte = (curcall.duration + 59) / 60; + if (!c.duration) { + printf(" %s%s", c.country, c.sprovider); - if ((tm->tm_wday > 0) && (tm->tm_wday < 5)) { /* Wochentag */ - if ((tm->tm_hour > 8) && (tm->tm_hour < 18)) /* Hauptzeit */ - price = 0.06; - else + if ((c.cause != 0x1f) && /* Normal, unspecified */ + (c.cause != 0x10)) /* Normal call clearing */ + printf(" %s", qmsg(TYPE_CAUSE, VERSION_EDSS1, c.cause)); + + if ((c.cause == 0x22) || /* No circuit/channel available */ + (c.cause == 0x2a) || /* Switching equipment congestion */ + (c.cause == 0x2f)) /* Resource unavailable, unspecified */ + provsum[SUBTOTAL][c.provider].failed++; + + printf("\n"); + continue; + } /* if */ + + if ((c.zone == 1) || (c.zone == 2)) { + auto struct tm *tm = localtime(&c.connect); + auto int takte; + auto double price; + + + takte = (c.duration + 59) / 60; + + if ((tm->tm_wday > 0) && (tm->tm_wday < 5)) { /* Wochentag */ + if ((tm->tm_hour > 8) && (tm->tm_hour < 18)) /* Hauptzeit */ + price = 0.06; + else + price = 0.03; + } + else /* Wochenende */ price = 0.03; - } - else /* Wochenende */ - price = 0.03; - curcall.aktiv = takte * price; + c.aktiv = takte * price; -// printf("AKTIVPLUS:%8.3f, gespart: %8.3f", curcall.aktiv, curcall.pay - curcall.aktiv); + msnsum[SUBTOTAL][c.si1][c.ihome].aktiv += c.aktiv; + provsum[SUBTOTAL][c.provider].aktiv += c.aktiv; + zonesum[SUBTOTAL][c.zone].aktiv += c.aktiv; + } /* if */ - msnsum[SUBTOTAL][homei].aktiv += curcall.aktiv; - provsum[SUBTOTAL][curcall.provider].aktiv += curcall.aktiv; - zonesum[SUBTOTAL][z].aktiv += curcall.aktiv; - } /* if */ + if (c.pay < 0.0) { /* impossible! */ + c.pay = c.compute; + c.computed++; + } /* if */ - if (curcall.pay < 0.0) { /* impossible! */ - curcall.pay = curcall.compute; - curcall.computed++; - } /* if */ - - if (curcall.compute && fabs(curcall.pay - Rate.Charge) > 1.00) { - curcall.pay = curcall.compute; - curcall.computed++; - } /* if */ + if (c.compute && fabs(c.pay - c.compute) > 1.00) { + c.pay = c.compute; + c.computed++; + } /* if */ - if (curcall.pay) - printf("%s%7.3f%s ", curcall.currency, curcall.pay, curcall.computed ? "*" : " "); - else - printf(" ", curcall.currency, curcall.pay, curcall.computed ? "*" : " "); + if (c.pay) + printf("%s%7.3f%s ", c.currency, c.pay, c.computed ? "*" : " "); + else + printf(" "); - printf("%s%s%s", curcall.country, curcall.sprovider, curcall.error); + printf("%s%s%s", c.country, c.sprovider, c.error); + + if (c.aktiv) + printf(" AktivPlus - %s%6.3f", c.currency, c.pay - c.aktiv); + + msnsum[SUBTOTAL][c.si1][c.ihome].pay += c.pay; + msnsum[SUBTOTAL][c.si1][c.ihome].duration += c.duration; + msnsum[SUBTOTAL][c.si1][c.ihome].compute += c.compute; + + provsum[SUBTOTAL][c.provider].pay += c.pay; + provsum[SUBTOTAL][c.provider].duration += c.duration; + provsum[SUBTOTAL][c.provider].compute += c.compute; + + zonesum[SUBTOTAL][c.zone].pay += c.pay; + zonesum[SUBTOTAL][c.zone].duration += c.duration; + zonesum[SUBTOTAL][c.zone].compute += c.compute; + + strcpy(partner[0][c.known[CALLING]].msn, c.num[OTHER]); + partner[0][c.known[CALLING]].ncalls++; + partner[0][c.known[CALLING]].pay += c.pay; + partner[0][c.known[CALLING]].duration += c.duration; + partner[0][c.known[CALLING]].compute += c.compute; - if (curcall.aktiv) { - printf(" AktivPlus - %s%6.3f", curcall.currency, curcall.pay - curcall.aktiv); } + else { /* Dialin: */ + justify(number[CALLED].msn, c.num[CALLING], number[CALLING]); + printf(" %s%s", c.country, c.sprovider); - msnsum[SUBTOTAL][homei].pay += curcall.pay; - msnsum[SUBTOTAL][homei].duration += curcall.duration; - msnsum[SUBTOTAL][homei].compute += curcall.compute; + strcpy(partner[1][c.known[CALLING]].msn, c.num[OTHER]); + partner[1][c.known[CALLING]].ncalls++; + partner[1][c.known[CALLING]].duration += c.duration; + } /* else */ - provsum[SUBTOTAL][curcall.provider].pay += curcall.pay; - provsum[SUBTOTAL][curcall.provider].duration += curcall.duration; - provsum[SUBTOTAL][curcall.provider].compute += curcall.compute; - zonesum[SUBTOTAL][z].pay += curcall.pay; - zonesum[SUBTOTAL][z].duration += curcall.duration; - zonesum[SUBTOTAL][z].compute += curcall.compute; - } - else { /* Dialin: */ - justify(number[CALLED].msn, curcall.num[CALLING], curcall.dialout, number[CALLING]); - printf(" %s%s", curcall.country, curcall.sprovider); - } /* else */ + printf("\n"); - printf("\n"); + } /* if */ + } /* while */ - } /* if */ - } /* while */ + fclose(f); + total(SUBTOTAL); + total(TOTAL); - fclose(f); - total(SUBTOTAL); - total(TOTAL); + showpartner(); - } /* if */ + } + else + fprintf(stderr, "%s: Can't read configuration file(s)\n", myname); + } + else + fprintf(stderr, "%s: Can't open \"isdn.log\" file\n", myname); return(0); } /* isdnbill */ diff --git a/isdnlog/rate-de.dat b/isdnlog/rate-de.dat index e81f3594..7fa83f4f 100644 --- a/isdnlog/rate-de.dat +++ b/isdnlog/rate-de.dat @@ -1,4 +1,4 @@ -V:1.10-Germany [27-Nov-1999 13:09:30] +V:1.10-Germany [01-Dec-1999 18:41:57] # Währungsformat U:%.3f DM @@ -8,7 +8,7 @@ U:%.3f DM # # (C) Copyright 1999 by Andreas Kool (akool@isdn4linux.de) # -# $Id: rate-de.dat,v 1.64 1999/11/27 19:24:17 akool Exp $ +# $Id: rate-de.dat,v 1.65 1999/12/01 21:47:23 akool Exp $ # # # Das "A:" Tag muß folgendermaßen gefüllt werden: @@ -12472,7 +12472,7 @@ T:*/*=2.3084(60)/1 P:51 01051 B:01051 C:ID-Switch GmbH, Graf-Adolf-Straße, 40210 Düsseldorf 01051 -# G:18-Nov-1999 +# G:01-Dec-1999 C:Homepage: http://www.01051.com C:Adresse: Koenigsallee 60f C: 40210 Duesseldorf @@ -12633,7 +12633,40 @@ T:*/*=0.35/60 Z:246 Polen A:PL T:*/*=0.38/60 -Z:247 impossible +Z:247 Russische Förderation +A:RU,SU +T:*/*=0.55/60 +Z:248 Bahamas +A:BS +T:*/*=0.37/60 +Z:249 Bulgarien +A:BG +T:*/*=0.62/60 +Z:250 Lettland +A:LV +T:*/*=0.64/60 +Z:251 Litauen +A:LT +T:*/*=0.57/60 +Z:252 Malaysia +A:MY +T:*/*=0.42/60 +Z:253 Malta +A:MT +T:*/*=0.44/60 +Z:254 Moldawien +A:MD +T:*/*=0.79/60 +Z:255 Philippinen +A:PH +T:*/*=0.61/60 +Z:256 Thailand +A:TH +T:*/*=0.75/60 +Z:257 Ukraine +A:UA +T:*/*=0.75/60 +Z:258 impossible A:_ARMF A:_AUMF A:_BEMF @@ -12660,6 +12693,17 @@ A:_CHMF A:_ESMF A:_TWMF A:_VEMF +# A:Russische F”rderation West Mobilfunk, Russische F”rderation Ost Mobilfunk +# A:Bahamas Mobilfunk +# A:Bulgarien Mobilfunk +# A:Lettland Mobilfunk +# A:Litauen Mobilfunk +# A:Malayisa Mobilfunk +# A:Malta Mobilfunk +# A:Moldawien Mobilfunk +A:_PHMF +# A:Thailand Mobilfunk +# A:Ukraine Mobilfunk T:*/*=99.99/60 ##################################################################### # diff --git a/isdnlog/rate-de.dat.src b/isdnlog/rate-de.dat.src index 5ce5c780..05fe7329 100644 --- a/isdnlog/rate-de.dat.src +++ b/isdnlog/rate-de.dat.src @@ -1,4 +1,4 @@ -V:1.10-Germany [27-Nov-1999 13:09:30] +V:1.10-Germany [01-Dec-1999 18:41:57] # Währungsformat U:%.3f DM @@ -8,7 +8,7 @@ U:%.3f DM # # (C) Copyright 1999 by Andreas Kool (akool@isdn4linux.de) # -# $Id: rate-de.dat.src,v 1.14 1999/11/27 19:24:18 akool Exp $ +# $Id: rate-de.dat.src,v 1.15 1999/12/01 21:47:23 akool Exp $ # # # Das "A:" Tag muß folgendermaßen gefüllt werden: @@ -12472,7 +12472,7 @@ T:*/*=2.3084(60)/1 P:51 01051 B:01051 C:ID-Switch GmbH, Graf-Adolf-Straße, 40210 Düsseldorf 01051 -# G:18-Nov-1999 +# G:01-Dec-1999 C:Homepage: http://www.01051.com C:Adresse: Koenigsallee 60f C: 40210 Duesseldorf @@ -12633,7 +12633,40 @@ T:*/*=0.35/60 Z:246 Polen A:Polen T:*/*=0.38/60 -Z:247 impossible +Z:247 Russische Förderation +A:Russische Förderation West, Russische Förderation Ost +T:*/*=0.55/60 +Z:248 Bahamas +A:Bahamas +T:*/*=0.37/60 +Z:249 Bulgarien +A:Bulgarien +T:*/*=0.62/60 +Z:250 Lettland +A:Lettland +T:*/*=0.64/60 +Z:251 Litauen +A:Litauen +T:*/*=0.57/60 +Z:252 Malaysia +A:Malayisa +T:*/*=0.42/60 +Z:253 Malta +A:Malta +T:*/*=0.44/60 +Z:254 Moldawien +A:Moldawien +T:*/*=0.79/60 +Z:255 Philippinen +A:Philippinen +T:*/*=0.61/60 +Z:256 Thailand +A:Thailand +T:*/*=0.75/60 +Z:257 Ukraine +A:Ukraine +T:*/*=0.75/60 +Z:258 impossible A:Argentinien Mobilfunk A:Australien Mobilfunk A:Belgien Mobilfunk @@ -12660,6 +12693,17 @@ A:Schweiz Mobilfunk A:Spanien Mobilfunk A:Taiwan Mobilfunk A:Venezuela Mobilfunk +# A:Russische F”rderation West Mobilfunk, Russische F”rderation Ost Mobilfunk +# A:Bahamas Mobilfunk +# A:Bulgarien Mobilfunk +# A:Lettland Mobilfunk +# A:Litauen Mobilfunk +# A:Malayisa Mobilfunk +# A:Malta Mobilfunk +# A:Moldawien Mobilfunk +A:Philippinen Mobilfunk +# A:Thailand Mobilfunk +# A:Ukraine Mobilfunk T:*/*=99.99/60 ##################################################################### # diff --git a/isdnlog/tools/NEWS b/isdnlog/tools/NEWS index 789661c6..4491cbaa 100644 --- a/isdnlog/tools/NEWS +++ b/isdnlog/tools/NEWS @@ -1,5 +1,16 @@ NEWS for tools: (rate, isdnrate, isdnrep) + +1999.11.30 + isdnrate: + new option -s shows services + e.g. + isdnrate -s Internet + +1999.11.28 + isdnrate: + new option -o shows only booked providers + 1999.11.08 all utils: initRate reads now all provider-variants. @@ -14,28 +25,28 @@ NEWS for tools: (rate, isdnrate, isdnrep) e.g. isdnrate -ZX 19430 - + rate.c / getLeastCost if number is a special number, this function looks at the service and performs LCR for all numbers listet in this service. - So its possible now to find the cheapest online number / provider. + So its possible now to find the cheapest online number / provider. 1999.10.21 Destination DB runs with isdnrate / isdnlog Removed a lot of country-specific stuff in various files - + all - new entries in isdn.conf section + new entries in isdn.conf section [ISDNLOG] DESTFILE=/usr/lib/isdn/dest.gdbm VBN=Providerselection-Prefix (DE 010, AT 10, NL 16:17) VBNLEN=Number of digits following VBN (DE 2:3, AT 2, NL 1 ??, FR 1) PRESELECTED=provider# (DE 33, AT 1, NL 999) s. isdnlog/samples or isdnlog/README - - isdnrep.c + + isdnrep.c shows now zone names from rate-CC.dat - + isdnrate.c new option -N show info about number parsing @@ -52,7 +63,7 @@ NEWS for tools: (rate, isdnrate, isdnrep) 1999.09.07 rate-CC.dat: Syntaxerweiterung im C:Tag - + C:TarifChanged:dd.mm.yyyy (Datum der letzten Tarifwartung) @@ -61,16 +72,16 @@ NEWS for tools: (rate, isdnrate, isdnrep) telrate.cgi: uses now gd 1.6.3, GD 1.21 with PNG instead of GIF (smaller, no licence troubles) - + requires gd 1.6.3 which requires libz, libpng - (e.g. ln -s /usr/X11R6/lib/libz.so /usr/lib/libz.so + (e.g. ln -s /usr/X11R6/lib/libz.so /usr/lib/libz.so ln -s /usr/X11R6/lib/libpng.so /usr/lib/libpng.so ln -s /usr/X11R6/include/png.h /usr/local/include/png.h ln -s /usr/X11R6/include/pngconf.h /usr/local/include/pngconf.h - ) + ) or from GD README Make sure you have downloaded and installed the following packages: @@ -82,7 +93,7 @@ NEWS for tools: (rate, isdnrate, isdnrep) http://www.cdrom.com/pub/png/ d. The zlib compression library: http://www.cdrom.com/pub/infozip/zlib/ - + dann noch ein kleiner Patch in GD.c, weiss der Geier warum --- GD.c Sat Sep 4 19:06:37 1999 @@ -100,18 +111,18 @@ NEWS for tools: (rate, isdnrate, isdnrep) @@ -2039,7 +2040,7 @@ XSRETURN_YES; } - + - +#if 0 #define XSCAPI(name) void name(CV* cv, void* pPerl) - + #ifdef __cplusplus @@ -2051,3 +2052,4 @@ boot__CAPI_entry(cv); } - + +#endif - + 1999.09.04 @@ -119,10 +130,10 @@ NEWS for tools: (rate, isdnrate, isdnrep) -p, -x take now an additional argument 'B' -pB ... show only business providers -xB ... don't show - + The provider is considered as a business-provider if the C:GT:-Tag contains the string "Business" (uppercase) - + 1999.09.03 @@ -130,49 +141,49 @@ NEWS for tools: (rate, isdnrate, isdnrep) ... W:H Feiertag W:* Immer # APPEND THIS - + Hat ein Provider jeden Tag den gleichen Tarif (T:*/...) wird nun statt dem Wochentag 'Immer' ausgegeben. Damit ist eine klarere Unterscheidung - zu Providern mit tagesabhaengigen Tarifen gegeben. - + zu Providern mit tagesabhaengigen Tarifen gegeben. -1999.09.01 + +1999.09.01 Neues Feld in struct RATE double Sales; (Mindestgesprächsgebühr) - + rate-CC.dat: Syntaxerweiterung im T:Tag - + T:*.*=0.30|2.20(60)/1 - Mindestens 0.30, sonst 2.20 per Minute - + Mindestens 0.30, sonst 2.20 per Minute + aber: - + T:*.*=0.30/0,2.20(60/1 0.30 + 2.20/Min (0.30 = Herstellungsgebühr) - + rate-CC.dat: Syntaxerweiterung im C:Tag - + gleichlautende C:Tags werden per '\n' appended - + telnum.c: - Dirty hack fuer +1, +7 (s. _getCountry...) - + Dirty hack fuer +1, +7 (s. _getCountry...) + isdnrate.c: Neue Option -S[v|n] (sort VBN oder Name statt Preis) - + z.B. - isdnrate -C -Sv -XHomepage + isdnrate -C -Sv -XHomepage (sortierte Proiderliste mit Homepage) - - + + 1999.08.24 rate-CC.dat: Syntaxerweiterung im C:Tag - + folgende C:-Tags sind dzt. in Verwendung: - + C:Name:Provider-Firmenbezeichnung C:Address:Provider-Adresse C:Homepage:http://www.provider.CC @@ -190,37 +201,37 @@ NEWS for tools: (rate, isdnrate, isdnrep) z.B. C:GT:99 Mindestumsatz (per Monat) C:GF:Cost = Ch > 99 ? 0 : 99 - + C:GT:Businesskunden ab 5000 Umsatz C:GF:Ch >= 5000 ? 1 : -1 - + C:GT:Freischaltgebühr einmalig 480 C:GF:Cost = 480/12 - - Vom telrate.cgi sind dzt. die Variablen + + Vom telrate.cgi sind dzt. die Variablen 'Ch' ... Kosten pro Mix 'MaxCh' ... Teuerste Spalte im Mix 'Cost' ... Angefallenen Kosten definiert. - - Ist der Rückgabewert (i.e. die letzte Expression) -1, wird der - Provider verworfen (z.B. Mindestumsatz nicht erreicht). - - - isdnrate: - isdnrate -D2 + Ist der Rückgabewert (i.e. die letzte Expression) -1, wird der + Provider verworfen (z.B. Mindestumsatz nicht erreicht). + + + isdnrate: + + isdnrate -D2 begibt sich nach dem Starten in den Hintergund - isdnrate -CX9 Argentinien + isdnrate -CX9 Argentinien verbindet ich mit dem oben gestarteten Daemon und wirft die Tarifliste aus. isdnrate -CD3 - killed den Daemon wieder + killed den Daemon wieder 1999.08.24 Neues Feld in struct RATE double Rhythm[2]; (Takt z.B. 60,1) - + -lt- diff --git a/isdnlog/tools/dest/README.makedest b/isdnlog/tools/dest/README.makedest index f29eab89..1204b22a 100644 --- a/isdnlog/tools/dest/README.makedest +++ b/isdnlog/tools/dest/README.makedest @@ -1,3 +1,39 @@ +makedest makes a destination database + + usage: + makedest [-en] [-a] [-v[2]] [cc ...] [ -cCC file|-] + eg. + $ makedest at de nl + which is the same as + $ makedest + $ makedest -a at de nl + or + $ makedest -a -c43 somecodes + + -a ... append country cc to database + -en .. write english names for countries + -v ... verbose, -v2 warns also for duplicate city names, which can be many + -c ... appends file or stdin to country CC (CC may be number or isocode) + + input files: + global (de/en) /usr/lib/isdn/country-de.dat + + code-files /usr/lib/isdn/code-CC.dat or ../zone/CC/code + where CC is the given countrycode + code-files (and input for stdin) consists of lines + number\tcity[\tlen of prefix] + + outputfile dest.gdbm is written to current directory and shoud be + installed to desired destination. + +Troubleshooting: + + Jochen Erwied reported that he had troubles building the destination database + (a empty dest.gdbm was built). + After updateing from perl 5.004_04 to 5.005_02 everything worked fine. + +Author: Leopold Toetsch +Licence: GPL makedest makes a destination database usage: diff --git a/isdnlog/tools/isdnrate.c b/isdnlog/tools/isdnrate.c index 020e14e3..33bc4685 100644 --- a/isdnlog/tools/isdnrate.c +++ b/isdnlog/tools/isdnrate.c @@ -1,4 +1,4 @@ -/* $Id: isdnrate.c,v 1.25 1999/11/08 21:09:41 akool Exp $ +/* $Id: isdnrate.c,v 1.26 1999/12/01 21:47:25 akool Exp $ * ISDN accounting for isdn4linux. (rate evaluation) * @@ -19,6 +19,31 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: isdnrate.c,v $ + * Revision 1.26 1999/12/01 21:47:25 akool + * isdnlog-3.72 + * - new rates for 01051 + * - next version of isdnbill + * + * - isdnlog/tools/telnum.c ... cleanup + * - isdnlog/tools/isdnrate.c ... -s Service + * - isdnlog/tools/rate.{c,h} ... -s + * - isdnlog/tools/NEWS ... -s + * - doc/isdnrate.man .. updated -o, -s + * - doc/rate-files.man ... updated + * - isdnlog/tools/dest/README.makedest ... updt. + * - isdnlog/isdnlog/isdnlog.8.in .. updt. + * + * Telrate + * - isdnlog/tools/telrate/README-telrate + * - isdnlog/tools/telrate/config.in NEW + * - isdnlog/tools/telrate/configure NEW + * - isdnlog/tools/telrate/Makefile.in NEW + * - isdnlog/tools/telrate/index.html.in was index.html + * - isdnlog/tools/telrate/info.html.in was info.html + * - isdnlog/tools/telrate/telrate.cgi.in was telrate.cgi + * - isdnlog/tools/telrate/leo.sample NEW sample config + * - isdnlog/tools/telrate/alex.sample NEW sample config + * * Revision 1.25 1999/11/08 21:09:41 akool * isdnlog-3.65 * - added "B:" Tag to "rate-xx.dat" @@ -40,7 +65,7 @@ * Revision 1.21 1999/10/25 18:30:03 akool * isdnlog-3.57 * WARNING: Experimental version! - * Please use isdnlog-3.56 for production systems! + * Please use isdnlog-3.56 for production systems! * * Revision 1.20 1999/09/19 14:16:27 akool * isdnlog-3.53 @@ -128,12 +153,11 @@ static void print_header(void); static char *myname, *myshortname; -static char options[] = "ab:d:f:h:l:p:t:v::x:CD::G:HLNS:TUVX::Z"; +static char options[] = "ab:d:f:h:l:op:st:v::x:CD::G:HLNS:TUVX::Z"; static char usage[] = "%s: usage: %s [ -%s ] Destination ...\n"; -static int header = 0, best = MAXPROVIDER, table = 0, - explain = 0; -int verbose = 0; +static int header = 0, best = MAXPROVIDER, table = 0, explain = 0; +int verbose = 0; static int usestat = 0; static int duration = LCR_DURATION; static time_t start; @@ -145,11 +169,13 @@ static int list = 0; static char *comment; static char **providers = 0; /* incl these */ static int n_providers = 0; -static int business=0; +static int business = 0; static char **xproviders = 0; /* excl these */ static int nx_providers = 0; -static int xbusiness=0; -static int all=0; +static int xbusiness = 0; +static int all = 0; +static int booked = 0; +static int service = 0; #define SOCKNAME "/tmp/isdnrate" static int is_daemon = 0; @@ -158,9 +184,8 @@ static int we_are_daemon = 0; static int takt = 99999; static char sortby; static int need_dest; -static int h_param=0; -static int lcr=0; - +static int h_param = 0; +static int lcr = 0; static TELNUM srcnum, destnum; typedef struct { @@ -188,8 +213,8 @@ int print_msg(int Level, const char *fmt,...) auto va_list ap; auto char String[BUFSIZ * 3]; - if ((Level > 1 && !verbose) || (Level>2&&verbose<2)) - return (1); + if ((Level > 1 && !verbose) || (Level > 2 && verbose < 2)) + return (1); va_start(ap, fmt); (void) vsnprintf(String, BUFSIZ * 3, fmt, ap); @@ -234,6 +259,7 @@ static void deinit(void) exitDest(); exitHoliday(); } + /* calc a day/time W | E | H */ static void get_day(char d) { @@ -243,22 +269,21 @@ static void get_day(char d) tm = localtime(&start); /* now */ switch (d) { - case 'W': /* we need a normal weekday, so we take - + case 'W': /* we need a normal weekday, so we take today and inc. day if today is holiday */ what = WORKDAY; - if(!h_param) + if (!h_param) hour = 10; break; case 'N': what = WORKDAY; - if(!h_param) + if (!h_param) hour = 23; break; case 'E': what = SUNDAY; - if(!h_param) + if (!h_param) hour = 10; break; } @@ -292,20 +317,21 @@ static int opts(int argc, char *argv[]) register int c; register char *p; int x; - h_param=0; + + h_param = 0; optind = 0; /* make it repeatable */ - need_dest=1; + need_dest = 1; while ((c = getopt(argc, argv, options)) != EOF) { switch (c) { - case 'a': /* all rates old/newer */ + case 'a': /* all rates old/newer */ all++; break; case 'b': best = strtol(optarg, NIL, 0); break; -/* case 'c': country */ +/* case 'c': country */ break; case 'd': @@ -346,57 +372,69 @@ static int opts(int argc, char *argv[]) sec = atoi(p + 1); } else - min=0; + min = 0; break; case 'l': duration = strtol(optarg, NIL, 0); /* l wie lt */ break; + case 'o': /* booked only */ + booked++; + break; + + case 's': /* service */ + service++; + break; + case 't': x = strtol(optarg, NIL, 0); if (x > 0) - takt = x; + takt = x; break; case 'x': /* eXclude Poviders */ { - char *arg = strdup(optarg); - p = strtok(arg, ","); - while (p) { + char *arg = strdup(optarg); + + p = strtok(arg, ","); + while (p) { if (*p == 'B') { /* Business Provider */ - xbusiness=1; + xbusiness = 1; p = strtok(0, ","); continue; - } - xproviders = realloc(xproviders, (nx_providers + 1) * sizeof(char*)); + } + xproviders = realloc(xproviders, (nx_providers + 1) * sizeof(char *)); + xproviders[nx_providers] = strdup(p); p = strtok(0, ","); nx_providers++; - } + } free(arg); } break; - + case 'p': /* Providers ... */ { - char *arg = strdup(optarg); - p = strtok(arg, ","); - while (p) { + char *arg = strdup(optarg); + + p = strtok(arg, ","); + while (p) { if (*p == 'B') { /* Business Provider */ - business=1; + business = 1; p = strtok(0, ","); continue; - } - providers = realloc(providers, (n_providers + 1) * sizeof(char*)); + } + providers = realloc(providers, (n_providers + 1) * sizeof(char *)); + providers[n_providers] = strdup(p); p = strtok(0, ","); n_providers++; - } + } free(arg); } break; - + case 'v': verbose++; if (optarg && (x = atoi(optarg))) @@ -436,7 +474,7 @@ static int opts(int argc, char *argv[]) break; case 'S': sortby = *optarg; - break; + break; case 'T': table++; break; @@ -454,13 +492,13 @@ static int opts(int argc, char *argv[]) explain++; if (optarg && isdigit(*optarg) && (x = atoi(optarg))) { explain = x; - if (x==50||x==51) - need_dest=0; - } - else if(optarg) { + if (x == 50 || x == 51) + need_dest = 0; + } + else if (optarg) { comment = strdup(optarg); - explain = 8; - need_dest=0; + explain = 8; + need_dest = 0; } break; } @@ -492,9 +530,13 @@ static int opts(int argc, char *argv[]) best = MAXPROVIDER; print_msg(PRT_V, "Illegal options, -b ignored\n"); } - if ((explain==50||explain==51) && header) { + if ((explain == 50 || explain == 51) && header) { print_msg(PRT_V, "Conflicting options, -H ignored\n"); - } + } + if (explain >= 10 && service) { + print_msg(PRT_V, "Conflicting options, -s ignored\n"); + service=0; + } if (argc > optind) return (optind); else @@ -502,7 +544,7 @@ static int opts(int argc, char *argv[]) } /* opts */ -static int (*compare_func)(const void *s1, const void *s2); +static int (*compare_func) (const void *s1, const void *s2); static int compare(const void *s1, const void *s2) { return (((SORT *) s1)->rate > ((SORT *) s2)->rate); @@ -516,8 +558,6 @@ static int compare_name(const void *s1, const void *s2) return strcasecmp(((SORT *) s1)->name, ((SORT *) s2)->name); } - - static int compare2(const void *s1, const void *s2) { return (((SORT2 *) s1)->weight < ((SORT2 *) s2)->weight); @@ -529,6 +569,9 @@ char *short_explainRate(RATE * Rate) static char buffer[BUFSIZ]; char *p = buffer; + if (service && Rate->dst[1] && *Rate->dst[1]) + p += sprintf(p, "%s, ", Rate->dst[1]); + if (Rate->Zone && *Rate->Zone) p += sprintf(p, "%s", Rate->Zone); else @@ -550,7 +593,6 @@ static char *printrate(RATE * Rate) { static char message[BUFSIZ]; - if (Rate->Basic > 0) sprintf(message, "%s + %s/%.4fs = %s + %s/Min (%s)", printRate(Rate->Basic), @@ -637,10 +679,11 @@ static char *takt_str(RATE * Rate) return s; } -static inline char * P_EMPTY(char *s) +static inline char *P_EMPTY(char *s) { - char *p = s; - return p ? p : ""; + char *p = s; + + return p ? p : ""; } #define DEL ';' @@ -653,15 +696,19 @@ static int compute(char *num) struct tm *tm; char prov[TN_MAX_PROVIDER_LEN]; int first = 1; - static char BUSINESS[] = "Business"; /* in C:GT:Tag */ + static char BUSINESS[] = "Business"; /* in C:GT:Tag */ if (destnum.nprovider != UNKNOWN) { low = high = destnum.nprovider; } /* if */ compare_func = compare; switch (sortby) { - case 'v' : compare_func = compare_vbn; break; - case 'n' : compare_func = compare_name; break; + case 'v': + compare_func = compare_vbn; + break; + case 'n': + compare_func = compare_name; + break; } buildtime(); @@ -682,26 +729,29 @@ static int compute(char *num) } for (i = low; i <= high; i++) { int found, p; - char *t; - if (ignore[i]) /* Fixme: */ + char *t; + + if (ignore[i]) /* Fixme: */ continue; - if(!all && !isProviderValid(i,start)) + if (booked && !isProviderBooked(i)) + continue; + if (!all && !isProviderValid(i, start)) continue; t = getProvider(i); - if (!t || t[strlen(t) - 1] == '?') /* UNKNOWN Provider */ + if (!t || t[strlen(t) - 1] == '?') /* UNKNOWN Provider */ continue; - - t = getComment(i, "GT"); /* get Geb. Text comment */ - if (business) { /* only business wanted */ + + t = getComment(i, "GT"); /* get Geb. Text comment */ + if (business) { /* only business wanted */ if (t == 0) continue; - else if(strstr(t, BUSINESS) == 0) + else if (strstr(t, BUSINESS) == 0) continue; - } - if (xbusiness) { /* no business wanted */ - if(t && strstr(t, BUSINESS) > 0) - continue; - } + } + if (xbusiness) { /* no business wanted */ + if (t && strstr(t, BUSINESS) > 0) + continue; + } found = 0; if (n_providers) { for (p = 0; p < n_providers; p++) @@ -727,7 +777,7 @@ static int compute(char *num) Rate.src[2] = ""; destnum.nprovider = i; - Strncpy(destnum.provider,getProvider(i),TN_MAX_PROVIDER_LEN); + Strncpy(destnum.provider, getProvider(i), TN_MAX_PROVIDER_LEN); if (normalizeNumber(num, &destnum, TN_NO_PROVIDER) == UNKNOWN) { continue; } @@ -785,17 +835,19 @@ static int compute(char *num) if (Rate.Duration <= takt) printf("@----- %s %s\n", currency, Rate.Provider); } - else if (explain==50||explain==51) { - int fi=1; - while(getZoneRate(&Rate, explain-50,fi) == 0) { + else if (explain == 50 || explain == 51) { + int fi = 1; + + while (getZoneRate(&Rate, explain - 50, fi) == 0) { double cpm = Rate.Duration > 0 ? 60 * Rate.Price / Rate.Duration : 99.99; - fi=0; + + fi = 0; if (Rate.Price != 99.99) printf("%s%c%s%c%s%c%.2f%c%.2f%c%s\n", prefix2provider(Rate.prefix, prov), DEL, - Rate.Provider,DEL,currency,DEL,Rate.Charge,DEL,cpm,DEL, - P_EMPTY(Rate.Country)); + Rate.Provider, DEL, currency, DEL, Rate.Charge, DEL, cpm, DEL, + P_EMPTY(Rate.Country)); free(Rate.Country); - } + } } else { /* kludge to suppress "impossible" Rates */ @@ -807,7 +859,10 @@ static int compute(char *num) sort[n].name = Rate.Provider; switch (explain) { case 1: - sprintf(s, " (%s)", Rate.Zone); + if (service) + sprintf(s, " (%s, %s)", P_EMPTY(Rate.dst[1]), Rate.Zone); + else + sprintf(s, " (%s)", Rate.Zone); sort[n].explain = strdup(s); break; case 2: @@ -846,19 +901,20 @@ static int compute(char *num) } /* for i */ if (explain < 10) { qsort((void *) sort, n, sizeof(SORT), compare_func); - if(lcr) { - RATE Cheap; - int res=getLeastCost(&Rate, &Cheap, 0, -1); - if(res!= UNKNOWN) { + if (lcr) { + RATE Cheap; + int res = getLeastCost(&Rate, &Cheap, 0, -1); + + if (res != UNKNOWN) { sort[n].prefix = Cheap.prefix; sort[n].rate = Cheap.Charge; sort[n].name = Cheap.Provider; - sprintf(s,"(Cheapest: %s)", Cheap.dst[1]); + sprintf(s, "(Cheapest: %s)", Cheap.dst[1]); sort[n].explain = strdup(s); - n++; - } /* res*/ - } /* lcr */ - } /* explain */ + n++; + } /* res */ + } /* lcr */ + } /* explain */ return (n); } /* compute */ @@ -866,7 +922,7 @@ static void print_header(void) { printf("Eine %d Sekunden lange Verbindung von %s nach %s kostet am %s\n", duration, formatNumber("%F", &srcnum), formatNumber("%F", &destnum), - ctime(&start)); + ctime(&start)); } static void printList(int n) @@ -902,13 +958,11 @@ static void purge(int n) { register int i; - for (i = 0; i < n; i++) if (sort[i].explain) free(sort[i].explain); } /* purge */ - /* Werktag Wochenende @@ -932,13 +986,12 @@ static void printTable(char *num) auto SORT2 wsort[MAXPROVIDER]; static int firsttime = 1; int first; - int prefix; + int prefix; memset(used, 0, sizeof(used)); memset(hours, 0, sizeof(hours)); memset(weight, 0, sizeof(weight)); - for (d = 0; d < 2; d++) { last[0].prefix = UNKNOWN; lasthour = UNKNOWN; @@ -964,8 +1017,9 @@ static void printTable(char *num) first = 1; while (1) { destnum.nprovider = UNKNOWN; - if(provider2prefix(num, &prefix)) /* set provider if it is in number */ - normalizeNumber(num, &destnum, TN_PROVIDER); + if (provider2prefix(num, &prefix)) /* set provider if it + is in number */ + normalizeNumber(num, &destnum, TN_PROVIDER); n = compute(num); if (header && first && d == 0 && firsttime) @@ -992,16 +1046,16 @@ static void printTable(char *num) if (!i) printf(" %02d:00 .. %02d:59 %s = %s %s%s\n", - lasthour, hour - 1, Provider(last[i].prefix), - currency, - double2str(last[i].rate, 5, 3, DEB), - last[i].explain); + lasthour, hour - 1, Provider(last[i].prefix), + currency, + double2str(last[i].rate, 5, 3, DEB), + last[i].explain); else printf(" %s = %s %s%s\n", - Provider(last[i].prefix), - currency, - double2str(last[i].rate, 5, 3, DEB), - last[i].explain); + Provider(last[i].prefix), + currency, + double2str(last[i].rate, 5, 3, DEB), + last[i].explain); } /* for */ used[last[0].prefix]++; @@ -1042,23 +1096,23 @@ static void printTable(char *num) if (!i) { if ((lasthour == 7) && (hour == 7)) printf(" immer %s = %s %s%s\n", - Provider(last[i].prefix), - currency, - double2str(last[i].rate, 5, 3, DEB), - last[i].explain); + Provider(last[i].prefix), + currency, + double2str(last[i].rate, 5, 3, DEB), + last[i].explain); else printf(" %02d:00 .. %02d:59 %s = %s %s%s\n", - lasthour, hour - 1, Provider(last[i].prefix), - currency, - double2str(last[i].rate, 5, 3, DEB), - last[i].explain); + lasthour, hour - 1, Provider(last[i].prefix), + currency, + double2str(last[i].rate, 5, 3, DEB), + last[i].explain); } else - printf( " %s = %s %s%s\n", - Provider(last[i].prefix), - currency, - double2str(last[i].rate, 5, 3, DEB), - last[i].explain); + printf(" %s = %s %s%s\n", + Provider(last[i].prefix), + currency, + double2str(last[i].rate, 5, 3, DEB), + last[i].explain); } /* for */ used[last[0].prefix]++; @@ -1086,7 +1140,7 @@ static void printTable(char *num) for (i = 0; i < MAXPROVIDER; i++) if (used[i]) { printf("%s %d times, %d hours, weight = %d\n", - Provider(i), used[i], hours[i], weight[i]); + Provider(i), used[i], hours[i], weight[i]); wsort[useds].weight = weight[i]; wsort[useds].index = i; @@ -1104,7 +1158,7 @@ static void printTable(char *num) for (i = 0; i < useds; i++) { printf("%s %d times, %d hours, weight = %d\n", - Provider(wsort[i].index), used[wsort[i].index], hours[wsort[i].index], weight[wsort[i].index]); + Provider(wsort[i].index), used[wsort[i].index], hours[wsort[i].index], weight[wsort[i].index]); if (i == best - 1) printf("\n"); @@ -1137,90 +1191,63 @@ static void clean_up() free(comment); comment = 0; sortby = 0; - need_dest=1; + need_dest = 1; } - -#if 0 -static void viacode(char *target, TELNUM *destnum) -{ - register char *p, *p1; - auto FILE *fi = fopen("/usr/lib/isdn/code-de.dat", "r"); - auto char s[BUFSIZ]; - - - if (fi != (FILE *)NULL) { - while (fgets(s, BUFSIZ, fi)) { - if ((p = strchr(s, '\n'))) { - - *p-- = 0; - - while ((p > s) && !isblank(*p)) - p--; - - if (p > s) { - if (!strcasecmp(p + 1, target)) { - p1 = s; - - while (!isblank(*p1)) - p1++; - - *p1 = 0; - - sprintf(destnum->msn, "0%s", s); - break; - } - } /* if */ - } /* if */ - } /* while */ - - fclose(fi); - } /* if */ -} /* viacode */ -#endif - - static void doit(int i, int argc, char *argv[]) { int n; - int prefix; - + int prefix; + char *num; + post_init(); memset(ignore, 0, sizeof(ignore)); - if (!need_dest && i==0) { - i=0; argc=1; - argv[0]="2345"; - } + if (!need_dest && i == 0) { + i = 0; + argc = 1; + argv[0] = "2345"; + } while (i < argc) { + num = argv[i]; if (explain == 55) { - if(n_providers) { - destnum.nprovider=pnum2prefix_variant(providers[0], 0); - Strncpy(destnum.provider,getProvider(destnum.nprovider),TN_MAX_PROVIDER_LEN); - normalizeNumber(argv[i], &destnum, TN_NO_PROVIDER); + if (n_providers) { + destnum.nprovider = pnum2prefix_variant(providers[0], 0); + Strncpy(destnum.provider, getProvider(destnum.nprovider), TN_MAX_PROVIDER_LEN); + normalizeNumber(num, &destnum, TN_NO_PROVIDER); } - else - normalizeNumber(argv[i], &destnum, TN_ALL); - printf("%s => %s \n",argv[i],formatNumber("%l - %p",&destnum)); + else + normalizeNumber(num, &destnum, TN_ALL); + printf("%s => %s \n", num, formatNumber("%l - %p", &destnum)); i++; continue; - } - destnum.nprovider = UNKNOWN; - if(provider2prefix(argv[i], &prefix)) /* set provider if it is in number */ - normalizeNumber(argv[i], &destnum, TN_PROVIDER); -#if 0 - if (isalpha(*destnum.msn)) - viacode(argv[i], &destnum); -#endif - if (table) - printTable(argv[i]); - else { - n = compute(argv[i]); - if (list) - printList(n); - else if (explain < 10) - result(n); - purge(n); } + if (service) { + num = getServiceNum(num); + if (!num || !*num) { + i++; + continue; + } + } + do { + destnum.nprovider = UNKNOWN; + if (provider2prefix(num, &prefix)) /* set provider if it + is in number */ + normalizeNumber(num, &destnum, TN_PROVIDER); + if (table) + printTable(num); + else { + n = compute(num); + if (list) + printList(n); + else if (explain < 10) + result(n); + purge(n); + } + if (service) + num = getServiceNum(0); + else + num = 0; + } while (num && *num); i++; } /* while */ clean_up(); @@ -1261,7 +1288,7 @@ static int handle_client(int fd) time(&start); /* set time of call */ splittime(); /* date time my be overridden by opts */ we_are_daemon = 1; - if ((i = opts(argc, argv))||need_dest==0) { + if ((i = opts(argc, argv)) || need_dest == 0) { if (shutdown(fd, 0) < 0) /* no read any more */ err("shutdown"); if (dup2(fd, STDOUT_FILENO) < 0) /* stdout to sock */ @@ -1284,19 +1311,19 @@ void catch_sig(int sig) err("Sig"); } -static void del_sock(void) +static void del_sock(void) { if (getppid() > 0) unlink(SOCKNAME); } static volatile sig_atomic_t stopped = 0, reinit = 0; -static void catch_term(int sig) +static void catch_term(int sig) { stopped = 1; } -static void catch_hup(int sig) +static void catch_hup(int sig) { reinit = 1; } @@ -1305,12 +1332,12 @@ static void do_reinit(void) { deinit(); init(); - reinit=0; + reinit = 0; } - + /* thank's to Jochen Erwied for this: */ #ifndef TEMP_FAILURE_RETRY -# define TEMP_FAILURE_RETRY(expression) \ +#define TEMP_FAILURE_RETRY(expression) \ (__extension__ \ ({ long int __result; \ do __result = (long int) (expression); \ @@ -1347,7 +1374,7 @@ static void setup_daemon() else if (pid > 0) exit(EXIT_SUCCESS); } - if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) + if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) err("Can't open socket"); sa.sun_family = AF_UNIX; strcpy(sa.sun_path, sock_name); @@ -1435,8 +1462,7 @@ static int connect_2_daemon(int argc, char *argv[]) case 'C': break; case 'D': - if (optarg && atoi(optarg) == 3) ; /* goon, kill a running - + if (optarg && atoi(optarg) == 3) ; /* goon, kill a running daemon */ else break; @@ -1478,7 +1504,7 @@ int main(int argc, char *argv[], char *envp[]) time(&start); splittime(); - if ((i = opts(argc, argv)) || need_dest==0) { + if ((i = opts(argc, argv)) || need_dest == 0) { if (is_client) exit(connect_2_daemon(argc, argv)); else @@ -1499,7 +1525,9 @@ int main(int argc, char *argv[], char *envp[]) print_msg(PRT_A, "\t-f areacode\tyou are calling from \n"); print_msg(PRT_A, "\t-h h[:m[:s]]\tstart time of call (default now)\n"); print_msg(PRT_A, "\t-l duration\tduration of call in seconds (default %d seconds)\n", LCR_DURATION); + print_msg(PRT_A, "\t-o \t show only booked providers\n"); print_msg(PRT_A, "\t-p prov|B[,prov...]\t show only these providers\n"); + print_msg(PRT_A, "\t-s \t consider 'Destination' as a service name\n"); print_msg(PRT_A, "\t-t takt\t\tshow providers if chargeduration<=takt\n"); print_msg(PRT_A, "\t-v [level]\tverbose\n"); print_msg(PRT_A, "\t-x prov|B[,prov...]\t exclude these providers\n"); diff --git a/isdnlog/tools/rate.c b/isdnlog/tools/rate.c index 9a9f6e8f..dc15b550 100644 --- a/isdnlog/tools/rate.c +++ b/isdnlog/tools/rate.c @@ -1,4 +1,4 @@ -/* $Id: rate.c,v 1.64 1999/11/28 19:32:42 akool Exp $ +/* $Id: rate.c,v 1.65 1999/12/01 21:47:25 akool Exp $ * * Tarifdatenbank * @@ -19,6 +19,31 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * * $Log: rate.c,v $ + * Revision 1.65 1999/12/01 21:47:25 akool + * isdnlog-3.72 + * - new rates for 01051 + * - next version of isdnbill + * + * - isdnlog/tools/telnum.c ... cleanup + * - isdnlog/tools/isdnrate.c ... -s Service + * - isdnlog/tools/rate.{c,h} ... -s + * - isdnlog/tools/NEWS ... -s + * - doc/isdnrate.man .. updated -o, -s + * - doc/rate-files.man ... updated + * - isdnlog/tools/dest/README.makedest ... updt. + * - isdnlog/isdnlog/isdnlog.8.in .. updt. + * + * Telrate + * - isdnlog/tools/telrate/README-telrate + * - isdnlog/tools/telrate/config.in NEW + * - isdnlog/tools/telrate/configure NEW + * - isdnlog/tools/telrate/Makefile.in NEW + * - isdnlog/tools/telrate/index.html.in was index.html + * - isdnlog/tools/telrate/info.html.in was info.html + * - isdnlog/tools/telrate/telrate.cgi.in was telrate.cgi + * - isdnlog/tools/telrate/leo.sample NEW sample config + * - isdnlog/tools/telrate/alex.sample NEW sample config + * * Revision 1.64 1999/11/28 19:32:42 akool * isdnlog-3.71 * @@ -398,6 +423,11 @@ * char *getSpecialName(char *number) * get the Service Name of a special number * + * char *getServiceNum(char *name) + * returns the first Tel-Number for Service 'name', + * call it with name=NULL to get the next number + * returns NULL if no mor numbers + * * void clearRate (RATE *Rate) * setzt alle Felder von *Rate zurück * @@ -440,6 +470,9 @@ * int isProviderValid(int prefix, time_t when) * returns true, if the G:tag entries match when * + * inline int isProviderBooked( int prefix) + * returns true if Provider is booked (i.e. listed int rate.conf) + * */ #define _RATE_C_ @@ -788,6 +821,10 @@ inline int getNProvider( void ) { return nProvider; } +inline int isProviderBooked( int i) { + return Provider[i].booked; +} + int isProviderValid(int i, time_t when) { return @@ -1592,6 +1629,24 @@ char *getSpecialName(char *number) { return 0; } +char *getServiceNum(char *name) { + static int serv, cod; + int i; + + if(name && *name) { + for (i=0; inprovider = preselect; - Strncpy(num->provider, getProvider(preselect), TN_MAX_PROVIDER_LEN); + num->nprovider = pnum2prefix(preselect,0); + Strncpy(num->provider, getProvider(num->nprovider), TN_MAX_PROVIDER_LEN); } if (flag & TN_COUNTRY) { /* subst '00' => '+' */ @@ -288,23 +281,20 @@ static void _init(void) { char *s; - clearNum(&defnum); + //clearNum(&defnum); Strncpy(defnum.area, myarea, TN_MAX_AREA_LEN); s = malloc(strlen(mycountry) + strlen(myarea) + 1); strcpy(s, mycountry); strcat(s, myarea); getDest(s, &defnum); Strncpy(defnum.vbn, vbn, TN_MAX_VBN_LEN); + defnum.nprovider=pnum2prefix(preselect,0); + Strncpy(defnum.provider, getProvider(defnum.nprovider), TN_MAX_PROVIDER_LEN); } void clearNum(TELNUM * num) { -/* num->nprovider=UNKNOWN; - strcpy(num->provider,""); */ - strcpy(num->area, ""); - initNum(num); - strcpy(num->msn, ""); - Strncpy(num->vbn, vbn, TN_MAX_VBN_LEN); + memcpy(num, &defnum, sizeof(TELNUM)); } /* %Np .. Provider diff --git a/isdnlog/tools/telrate/README-telrate b/isdnlog/tools/telrate/README-telrate index fc112000..8b38a9ae 100644 --- a/isdnlog/tools/telrate/README-telrate +++ b/isdnlog/tools/telrate/README-telrate @@ -1,4 +1,4 @@ -Telrate CGI +Telrate CGI ------------ Telrate.cgi is a web interface to isdnrate for displaying tables & graphics of @@ -11,8 +11,11 @@ Installation $ ./configure # make install -(Sorry n/y) - + + run ./configure to get a list of default options, you may override them, as + ./configure --cc ch --gifpng png ... + or look at the sample config's alex & leo. + - Manually @@ -23,7 +26,7 @@ extract index.html,info.html,pics to /usr/local/httpd/htdocs/somedir # tar -xzf telrate.tgz make it readable for your webserver - + edit telrate.cgi: -------------- @@ -32,12 +35,12 @@ edit telrate.cgi: ( this file is actually ./tools/zone/CC/code ) location of isdnrate (only if pipe's are used not sockets) location of mktemp (should be ok) - + location of index.html, info.html, pic, (default /telrate/ under htdocs) - - if your /tmp ist not writable by all users, turn of $use_sockets + + if your /tmp ist not writable by all users, turn off $use_sockets or change the location of the unix socket in both isdnrate.c and telrate.cgi. - + make a tmp dir below htdocs # mkdir /usr/local/httpd/htdocs/tmp # chmod 700 /usr/local/httpd/htdocs/tmp @@ -76,24 +79,24 @@ Options +ExecCGI ----------------- End Apache config - + # cp telrate.cgi /usr/local/httpd/cgi-bin # chmod 755 /usr/local/httpd/cgi-bin/telrate.cgi - # chmod 644 /etc/isdn/isdn.conf - + # chmod 644 /etc/isdn/isdn.conf + NB: telrate.cgi uses the following perl modules: CGI, GD, IO::Handle und Socket - if you don't have these, point your browser to www.perl.com, + if you don't have these, point your browser to www.perl.com, and look for CPAN mirrors near your location. - - + + index.html, info.html --------------------- - + If your script-url ist not /perl/ change it to /cgi-bin in both files or configure apache to use /perl for your /cgi-bin. -If you expanded to a different dir then /telrate/ you have to adjust +If you expanded to a different dir then /telrate/ you have to adjust IMG tags too. @@ -102,9 +105,9 @@ Running the Program if $use_sockets is on, start the server instance of isdnlog/bin/isdnrate with options -D2 [-v] -as soon as you see "Setup sockets" and "Going background" you can point -your browser to +as soon as you see "Setup sockets" and "Going background" you can point +your browser to /telrate/index.html -Enjoy \ No newline at end of file +Enjoy diff --git a/isdnlog/tools/telrate/index.html b/isdnlog/tools/telrate/index.html.in similarity index 81% rename from isdnlog/tools/telrate/index.html rename to isdnlog/tools/telrate/index.html.in index acee586d..5e044f07 100644 --- a/isdnlog/tools/telrate/index.html +++ b/isdnlog/tools/telrate/index.html.in @@ -1,9 +1,9 @@ - + - + -Tel-R.at - Telefonkosten +@TITLE@ - Telefonkosten