getRate() speedup

This commit is contained in:
akool 1999-07-31 09:25:03 +00:00
parent a7fbecb8de
commit c841376b7d
8 changed files with 1050 additions and 353 deletions

View File

@ -359,7 +359,7 @@ C:+673
N:Weihnachtsinseln
A:Weihnachtsinsel (Australien), Christmas Island, Christmas Island (Antarctica)
A:Christmas Islands, Christmas Inseln,Weihnachtsinsel
A:Christmas Inseln,Weihnachtsinsel
C:+6724
N:Norfolkinseln
@ -368,7 +368,7 @@ C:+6723
N:Kokosinseln
A:Kokosinseln (Australien), Cocos Island, Cocos Island (Antarctica)
A:Cocos Islands, Cocos Inseln
A:Cocos Inseln
C:+6722, +6189162
N:Antarktis
@ -412,7 +412,6 @@ A:Australia
C:+61
N:Malaysia
A:Malaysien
C:+60
N:Niederl. Antillen
@ -1176,7 +1175,7 @@ C:+1809946, +1809941, +1649
N:Amerikanische Jungferninseln
A:Jungferninseln (USA), Amerikan. Jungferninseln, American Virgin Isles
A:US Jungferninseln, Virgin Islands (US)
A:US Jungferninseln
C:+180977, +1809719, +1809715, +1809714, +1809713, +1809712, +1809693, +1809692, +1809690, +1809611, +1809513, +1340
N:Britische Jungferninseln

View File

@ -1,4 +1,4 @@
V:1.02-Germany [23-Jul-1999 22:39:23]
V:1.02-Germany [31-Jul-1999 11:30:28]
# 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.33 1999/07/24 08:43:54 akool Exp $
# $Id: rate-de.dat,v 1.34 1999/07/31 09:25:08 akool Exp $
#
# Zonenzuordnung für Deutschland
#
@ -167,7 +167,7 @@ C:GmbH, Gutleutstra
#
P:11 o.tel.o CbC
G:15-Jul-1999
C:o.tel.o communications GmbH, Am Bonneshof 35, 40474 Düsseldorf 01011
C:Mannesmann Zwölfte Verwaltungsgesellschaft mbH, Mannesmannufer 2, 40213 Düsseldorf
C:Homepage: http://www.o-tel-o.de
C:Hotline: 01803/1998 oder 0800/7370 (Geschaeftskunden)
C:Adresse: 96038 Bamberg
@ -405,7 +405,7 @@ A:+ # Alle anderen Auslandsverbindungen
T:*/*=2.790032/60
#####################################################################
P:11,1 o.tel.o direct Preselection
C:o.tel.o communications GmbH, Am Bonneshof 35, 40474 Düsseldorf 01011
C:Mannesmann Zwölfte Verwaltungsgesellschaft mbH, Mannesmannufer 2, 40213 Düsseldorf
C:Homepage: http://www.o-tel-o.de
C:Hotline: 01803/1998 oder 0800/7370 (Geschaeftskunden)
C:Adresse: 96038 Bamberg
@ -658,7 +658,7 @@ C:Internetz GmbH, S
#
#
P:13 Tele 2
C:Tele 2 Kinnevik Telecommunciations International S.A., 75, route de Longwy, L-8080 Bertrange, Luxembourg 01013
C:Telecommunications Services GmbH, Düsseldorf
C:Homepage: http://www.tele2.de
C:Hotline: 0800/24-01013
C:Adresse: Postfach 130840, 40558
@ -733,8 +733,8 @@ T:*/*=2.44/60
#####################################################################
#
#
P:14 EWE TEL Call By Call national
C:GmbH, Donnerschweer Straße 22-26, 26123 Oldenburg 01014
P:14 EWE TEL CbC national
C:Cloppenburger Str. 300, 26133 Oldenburg
C:Homepage: http://www.ewetel.de
C:Hotline: (07-22h) 01803/25 24 23
C:Regionaltarif gilt nur in bestimmten Orten in der Nähe von Oldenburg
@ -802,8 +802,8 @@ Z:206 Welt 4
A:+
T:*/*=2.99(60)/1
#####################################################################
P:14,1 EWE TEL Call By Call/pre-select regional
C:GmbH, Donnerschweer Straße 22-26, 26123 Oldenburg 01014
P:14,1 EWE TEL CbC/pre-select regional
C:Cloppenburger Str. 300, 26133 Oldenburg
C:Homepage: http://www.ewetel.de
C:Hotline: (07-22h) 01803/25 24 23
C:Regionaltarif gilt nur in bestimmten Orten in der Nähe von Oldenburg
@ -976,7 +976,7 @@ C:81 - 85 Service 0180-x
C:91 - 94 Service 0190-x
C:100 T-Online
C:160, 164 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:200 - Ausland
G:01.04.1999
@ -1836,7 +1836,7 @@ C:81 - 85 Service 0180-x
C:91 - 94 Service 0190-x
C:100 T-Online
C:160, 164 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:200 - Ausland
G:01.04.1999
@ -2702,7 +2702,7 @@ C:81 - 85 Service 0180-x
C:91 - 94 Service 0190-x
C:100 T-Online
C:160, 164 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:200 - Ausland
G:01.04.1999
@ -3805,7 +3805,7 @@ T:*/*=0.05/0,2.49/30
#
#
P:19 Mobilcom CbC
C:CityLine Telefondienste GmbH, Schwarzer Weg 13, 24837 Schleswig 01019
C:City LINE GmbH, Holler Str. 126, 24782 Büdelsdorf
C:MobilCom AG
C:Homepage: http://www.mobilcom.de
C:Hotline: 01805/191919
@ -3845,7 +3845,7 @@ A:D
T:*/*=0.49/60
#####################################################################
P:19,1 Mobilcom Preselection/Business
C:CityLine Telefondienste GmbH, Schwarzer Weg 13, 24837 Schleswig 01019
C:City LINE GmbH, Holler Str. 126, 24782 Büdelsdorf
C:Erfasste Zonen:
C:2 - 4 Deutschland
C:10 Mobilfunk
@ -3899,7 +3899,7 @@ A:China (Volksrepublik), Australien
T:*/*=1.49(60)/1
#####################################################################
P:19,2 Mobilcom Preselection/Privat
C:CityLine Telefondienste GmbH, Schwarzer Weg 13, 24837 Schleswig 01019
C:City LINE GmbH, Holler Str. 126, 24782 Büdelsdorf
C:MobilCom AG
C:Homepage: http://www.mobilcom.de
C:Hotline: 01805/191919
@ -8334,7 +8334,7 @@ C:Carrier Services, Industriestra
#
#
P:30 TelDaFax
G:19-Apr-1999
G:01-Aug-1999
D:dtag
C:Telefon-, Daten- und Fax-Transfer GmbH & Co. KG, Schuppertsgasse 30, 35083 Wetter (Hessen) 01030
C:Name: TeDaFax Telefon-, Daten- und Faxtransfer AG
@ -8355,7 +8355,11 @@ C:81 - 85 Service 0180-x
C:91 - 94 Service 0190-x
C:102 TelDa.net
C:200 - Ausland
Z:2-4 Deutschland
Z:2 Regio 20
T:W/07-21=0.07(60)/1
T:W/21-07=0.04(60)/1
T:E/*=0.04(60)/1
Z:3-4 Deutschland
A:+49
T:W/07-09=0.09(60)/1
T:W/09-18=0.12(60)/1
@ -8449,7 +8453,7 @@ C:81 - 85 Service 0180-x
C:91 - 94 Service 0190-x
C:100 T-Online
C:162 - 166 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:172 Sonderrufnummern zum Citytarif
C:200 - Ausland
@ -8689,7 +8693,7 @@ C:81 - 85 Service 0180-x
C:91 - 94 Service 0190-x
C:100 T-Online
C:162 - 166 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:172 Sonderrufnummern zum Citytarif
C:200 - Ausland
@ -8915,7 +8919,7 @@ C:81 - 85 Service 0180-x
C:91 - 94 Service 0190-x
C:100 T-Online
C:162 - 166 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:172 Sonderrufnummern zum Citytarif
C:200 - Ausland
@ -9150,7 +9154,7 @@ C:81 - 85 Service 0180-x
C:91 - 94 Service 0190-x
C:100 T-Online
C:162 - 166 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:172 Sonderrufnummern zum Citytarif
C:200 - Ausland
@ -9380,7 +9384,7 @@ C:81 - 85 Service 0180-x
C:91 - 94 Service 0190-x
C:100 T-Online
C:162 - 166 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:172 Sonderrufnummern zum Citytarif
C:200 - Ausland
@ -9915,7 +9919,7 @@ C:10 Mobilfunk
C:102 net@home
C:103 Call POP
C:161 - 166 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:172 IVBB
C:200 - Ausland
@ -10270,7 +10274,7 @@ C:91 - 94 Service 0190-x
C:100 T-Online
C:101 AOL
C:160 - 163 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:172 IVBB
C:200 - Ausland
@ -10465,7 +10469,7 @@ C:91 - 94 Service 0190-x
C:100 T-Online
C:101 AOL
C:161 - 166 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:172 IVBB
C:200 - Ausland
@ -10628,7 +10632,7 @@ A:+491191
T:W/08-20=0.10(60)/1 Tag
T:W/20-08=0.06(60)/1 Nacht
T:E,H/*=0.06(60)/1 Wochenende
Z:170 Persöhnliche Rufnummer 0700
Z:170 Persönliche Rufnummer 0700
A:+49700
T:W/08-20=0.48(60)/1 Tag
T:W/20-08=0.24(60)/1 Nacht
@ -10770,7 +10774,7 @@ C:91 - 94 Service 0190-x
C:100 T-Online
C:101 AOL
C:161 - 166 DTAG Service Nummern
C:170 Persöhnliche Rufnummer
C:170 Persönliche Rufnummer
C:171 Info Expo 2000
C:172 IVBB
C:200 - Ausland
@ -10944,7 +10948,7 @@ A:+491191
T:W/08-20=0.10(60)/1 Tag
T:W/20-08=0.06(60)/1 Nacht
T:E,H/*=0.06(60)/1 Wochenende
Z:170 Persöhnliche Rufnummer 0700
Z:170 Persönliche Rufnummer 0700
A:+49700
T:W/08-20=0.48(60)/1 Tag
T:W/20-08=0.24(60)/1 Nacht
@ -11523,7 +11527,7 @@ T:*/*=2.35(60)/1
#
#
P:50 Talkline
G:11-May-1999
G:19-Jul-1999
C:PS PhoneServices GmbH, Adenauer Damm 1, 25337 Elmshorn 01050
C:Homepage: http://www.null1050.de
C:Hotline: 01802/2002
@ -13685,7 +13689,7 @@ P:79 Viatel
##
## macht *keinen* Tarifwechsel in laufender Verbindung!
##
G:15-Jun-1999
G:01-Aug-1999
C:VIAPHONE GmbH, Hanauer Landstraße 187, 60314 Frankfurt 01079
C:Homepage: http://www.viatel.de
C:Hotline: 0800/79-01079
@ -13695,11 +13699,11 @@ C:Adresse: Hanauer Landstrasse 187-189
C: 60314 Frankfurt am Main
D:dtag
Z:2-4 National
T:W/09-18=0.064/30,0.128(60)/1 Hauptzeit
T:W/09-18=0.102/60 Hauptzeit
T:W/18-21=0.085(60)/60 Nebenzeit
T:W/21-9=0.055(60)/60 Nacht
T:W/21-9=0.05(60)/60 Nacht
T:E/9-21=0.085(60)/60 Hauptzeit
T:E/21-9=0.055(60)/60 Nacht
T:E/21-9=0.05(60)/60 Nacht
A:+49
Z:10-15 Mobilfunk
A:+491618 # T-C-Tel Voice Mail
@ -14484,6 +14488,11 @@ C:Telecom BV, Prinses Beatrixlaan 23, 2595 AK's Gravenhage, Niederlande 010007
P:108 USA Global Link
C:Deutschland GmbH, Theaterstraße 90, 52062 Aachen 010008
#####################################################################
P:109 ChemTel
C:Telekommunikations GmbH Chemnitz, Postfach 510, 09031 Chemnitz
#####################################################################
#
#
#
#
P:110 Bertelsmann mediaSystems
@ -14494,16 +14503,21 @@ C:GmbH, An der Autobahn, 33311 G
P:111 RED LINE
C:Telekommunikationsgesellschaft mbH, Brückenstraße 17, 63897 Miltenberg 010011
#####################################################################
#
#
P:114 NordKom
C:Weser-Elbe Telekommunikation GmbH, Stresemannstraße 48, 28207 Bremen 010014
P:112 MEGASAT
C:Friedrich-Krupp-Str. 16-18, 45164 Kaarst
#####################################################################
#
#
#
#
P:115 Delta Three
C:Inc., 430 Park Ave, New York 010015
#####################################################################
P:118 MFS
C:MFS Communications GmbH, Postfach 190409, 60091 Frankfurt am Main
#####################################################################
#
#
#
#
P:119 E.T.H.
@ -14519,6 +14533,11 @@ C:Oberweg 15, 82024 Taufkirchen bei M
P:122 Motorola
C:Electronic GmbH, Hagenauer Straße 47, 65203 Wiesbaden 010022
#####################################################################
+P:125 Mediascape
+C:Mediascape Communications GmbH, Usedomstraße 19, 22047 Hamburg
+#####################################################################
+#
+#
#
#
P:130 tnp telenet
@ -14529,11 +14548,21 @@ C:potsdam, kommunikationsgesellschaft mbH, Erich-Weinert-Stra
P:131 accom
C:Gesellschaft für Telekommunikationsnetze und -dienstleistungen GmbH & Co.KG, Borngasse 34, 52064 Aachen 010031
#####################################################################
P:132 SD
C:SD Telecom Telekommunikations GmbH, Heinersdorfer Damm 55-57, 16303 Schwedt
#####################################################################
#
#
#
#
P:133 Level 3
C:Communications GmbH, Oberlindau 54 - 56, 60323 Frankfurt/Main 010033
#####################################################################
P:140 VossNet
C:VossNet Communications GmbH, 28199 Bremen
#####################################################################
#
#
#
#
P:142 connection 42
@ -14565,6 +14594,11 @@ A:+49176,+49179 # E2
T:W/08-21=0.69/60,0.69(60)/15
T:W/21-08=0.59/60,0.59(60)/15
#####################################################################
P:154 Osnatel
C:Osnatel GmbH, Luisenstraße 16, 49074 Osnabrück
#####################################################################
#
#
#
#
P:155 Telia
@ -14580,13 +14614,13 @@ C:Kassel GmbH, K
P:160 JelloCom
C:GmbH & Co.KG, Prüssingstraße 41, 07745 Jena 010060
#####################################################################
#
#
P:166 InterCard
C:GmbH, POS-Service, Mehlbeerenstraße 4, 82024 Taufkirchen bei München 010066
P:168 VSE
C:VSE Net GmbH, Postfach, 103232, 66032 Saarbrücken
#####################################################################
#
#
#
#
P:170 Deutsche Telefon- und Marketing Services
C:GmbH, Isaac-Fulda-Allee 16, 55124 Mainz 010070
#####################################################################
@ -14595,21 +14629,41 @@ C:GmbH, Isaac-Fulda-Allee 16, 55124 Mainz 010070
P:173 TFN COM SA
C:World Of Communication, Via Greina 2 CP 2950, CH-6901 Lugano 010073
#####################################################################
P:175 Gigabell
C:Gigabell AG, 60325 Frankfurt am Main
#####################################################################
#
#
#
#
P:177 WorldxChange
C:Communications GmbH, Am Seedamm 44, 60489 Frankfurt 010077
#####################################################################
P:178 Cybernet
C:Cybernet Internet-Dienstleistungen AG, Stefan-George-Ring 19-23, 81929 München
#####################################################################
#
#
#
#
P:180 FaciliCom
C:Telekommunikation GmbH; Windmühlstraße 1, 60329 Frankfurt/Main 010080
#####################################################################
P:181 Daten- und Telekommunikations-GmbH Dessau
C:Daten- und Telekommunikations-GmbH Dessau, Willy-Lohmann-Straße 6a, 06844 Dessau
#####################################################################
#
#
#
#
P:184 Startec
C:Global Communications (Germany) GmbH, Broßstraße 6, 60487 Frankfurt 010084
#####################################################################
P:185 FirstMark
C:Communications Deutschland GmbH, Am Opernplatz 2, 60313 Frankfurt am Main
#####################################################################
#
#
#
#
P:188 jk-tel

View File

@ -1,9 +1,9 @@
CC=gcc -m486 -O0 -g -pg -Wall -DSTANDALONE -I. -I.. -I../isdnlog
CC=gcc -m486 -O0 -g -Wall -DSTANDALONE -I. -I.. -I../isdnlog
all: rate zone.exe country holiday rate-at
rate: rate.u zone.u country.u holiday.u
${CC} -lgdbm -o rate rate.u zone.u country.u holiday.u
${CC} -lgdbm -lm -o rate rate.u zone.u country.u holiday.u
zone.exe: zone.c zone.h
${CC} -DZONETEST -lgdbm -o zone.exe zone.c

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
/* $Id: isdnrate.c,v 1.14 1999/07/26 16:28:41 akool Exp $
/* $Id: isdnrate.c,v 1.15 1999/07/31 09:25:36 akool Exp $
*
* ISDN accounting for isdn4linux. (rate evaluation)
*
@ -19,6 +19,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: isdnrate.c,v $
* Revision 1.15 1999/07/31 09:25:36 akool
* getRate() speedup
*
* Revision 1.14 1999/07/26 16:28:41 akool
* getRate() speedup from Leo
*
@ -102,7 +105,7 @@ static int exclude=0;
static int is_daemon=0;
static TELNUM srcnum, destnum;
typedef struct {
int prefix;
double rate;
@ -125,7 +128,7 @@ int print_msg(int Level, const char *fmt, ...)
auto char String[BUFSIZ * 3];
if (Level == PRT_ERR || (Level == PRT_V && !verbose))
return(1);
return(1);
va_start(ap, fmt);
(void)vsnprintf(String, BUFSIZ * 3, fmt, ap);
@ -163,8 +166,8 @@ static void init()
if (verbose && *version)
print_msg(PRT_V, "%s\n", version);
initTelNum();
initTelNum();
} /* init */
/* calc a day/time W | E | H */
@ -205,10 +208,10 @@ static void post_init()
if (fromarea) {
Strncpy(srcnum.area, fromarea, TN_MAX_AREA_LEN);
free(fromarea);
fromarea=0;
fromarea=0;
}
initNum(&srcnum);
if (wanted_day)
get_day(wanted_day);
} /* post_init */
@ -238,7 +241,7 @@ static int opts(int argc, char *argv[])
year = atoi(p + 1);
if (year < 50)
year += 2000;
else if (year < 100)
else if (year < 100)
year += 1900;
}
}
@ -255,7 +258,7 @@ static int opts(int argc, char *argv[])
}
break;
case 'h': hour = atoi(optarg);
case 'h': hour = atoi(optarg);
if ((p = strchr(optarg + 1, ':'))) {
min = atoi(p + 1);
if ((p = strchr(p + 1, ':')))
@ -270,13 +273,13 @@ static int opts(int argc, char *argv[])
exclude = 1;
/* goon */
case 'p': /* Providers ... */
p = strtok(optarg, ",");
p = strsep(&optarg, ",");
while (p) {
providers = realloc(providers, n_providers+1);
providers = realloc(providers, (n_providers+1)*sizeof(int));
providers[n_providers] = atoi(p);
p = strtok(0, ",");
p = strsep(&optarg, ",");
n_providers++;
}
}
break;
case 'v' : verbose++;
break;
@ -480,12 +483,12 @@ static int compute(char *num)
Rate.src[2] = "";
oldprov = destnum.nprovider;
if (destnum.nprovider == UNKNOWN)
if (destnum.nprovider == UNKNOWN)
destnum.nprovider=i;
if (normalizeNumber(num, &destnum, TN_ALL) == UNKNOWN) {
destnum.nprovider=oldprov;
continue;
}
}
destnum.nprovider=oldprov;
Rate.dst[0] = destnum.country?destnum.country->Code[0] : "";
@ -556,7 +559,7 @@ static int compute(char *num)
else if (explain == 1) {
sprintf(s, " (%s)", Rate.Zone);
sort[n].explain = strdup(s);
}
}
else
sort[n].explain = strdup("");
@ -572,7 +575,7 @@ static int compute(char *num)
static void print_header(void) {
print_msg(PRT_NORMAL, "Eine %d Sekunden lange Verbindung von %s nach %s kostet am %s\n",
duration, formatNumber("%f",&srcnum), formatNumber("%f",&destnum),
duration, formatNumber("%f",&srcnum), formatNumber("%f",&destnum),
ctime(&start));
}
static void printList(char *target, int n) {
@ -602,7 +605,7 @@ static void result(char *target, int n)
n = best;
if (explain < 10)
for (i = 0; i < n; i++)
print_msg(PRT_NORMAL, "%s %s %8.4f%s\n",
print_msg(PRT_NORMAL, "%s %s %8.3f%s\n",
Provider(sort[i].prefix), currency, sort[i].rate, sort[i].explain);
} /* result */
@ -856,14 +859,14 @@ static void doit(int i, int argc, char *argv[]) {
else
result(argv[i], n);
purge(n);
}
}
i++;
} /* while */
clean_up();
}
static void err(char *s) {
fprintf(stderr, "%s - %s\n", s, strerror (errno));
print_msg(PRT_A, "%s - '%s'\n", s, strerror (errno));
exit(2);
}
@ -878,7 +881,7 @@ static int handle_client(int fd) {
if (n) {
argv = calloc(sizeof(char*),20);
buffer[n] = '\0';
if(verbose==2)
if(verbose==1)
fprintf(stderr, "got '%s' (bs=%d)\n", buffer, BUFSIZ);
argc = 0;
argv[argc++] = strdup(myname);
@ -907,6 +910,11 @@ static int handle_client(int fd) {
return n == 0 ? -1 : 0;
}
void catch_sig(int sig) {
print_msg(PRT_A, "Signal %d\n",sig);
err("Sig");
}
static void setup_daemon() {
int sock;
struct sockaddr_un sa;
@ -919,9 +927,10 @@ static void setup_daemon() {
if(verbose)
fprintf(stderr,"Setup sockets\n");
if ((sock=socket(PF_FILE, SOCK_STREAM, 0)) < 0)
signal(SIGSEGV, catch_sig);
if ((sock=socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
err("Can't open socket");
sa.sun_family = AF_FILE;
sa.sun_family = AF_UNIX;
unlink(sock_name);
strcpy(sa.sun_path, sock_name);
size = offsetof(struct sockaddr_un, sun_path) + strlen(sa.sun_path)+1;

View File

@ -1,4 +1,4 @@
/* $Id: rate.c,v 1.37 1999/07/26 16:28:49 akool Exp $
/* $Id: rate.c,v 1.38 1999/07/31 09:25:45 akool Exp $
*
* Tarifdatenbank
*
@ -19,6 +19,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: rate.c,v $
* Revision 1.38 1999/07/31 09:25:45 akool
* getRate() speedup
*
* Revision 1.37 1999/07/26 16:28:49 akool
* getRate() speedup from Leo
*
@ -303,6 +306,7 @@
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <time.h>
#include <unistd.h>
#include <errno.h>
@ -1167,6 +1171,18 @@ void clearRate (RATE *Rate)
Rate->_zone=UNKNOWN;
}
static int leo (int a, int b, double c, double d)
{
int x;
if (a < b)
b = a;
if (b < c || c < 0)
c = b;
x = ceil(c/d);
return x < 1 ? 1 : x;
}
int getRate(RATE *Rate, char **msg)
{
static char message[LENGTH];
@ -1174,7 +1190,7 @@ int getRate(RATE *Rate, char **msg)
ZONE *Zone;
HOUR *Hour;
UNIT *Unit;
int prefix, freeze, cur, max, i, j;
int prefix, freeze, cur, max, i, j, n;
double now, end, jmp, leap;
char *day;
time_t time;
@ -1260,7 +1276,7 @@ int getRate(RATE *Rate, char **msg)
Rate->Time=end;
leap=UNKNOWN; /* Stundenwechsel erzwingen */
while (now<end) {
while (1) {
if (!freeze && now>=leap) { /* Neuberechnung bei Stundenwechsel */
time=Rate->start+now;
leap=3600*(int)(time/3600+1)-Rate->start;
@ -1284,35 +1300,37 @@ int getRate(RATE *Rate, char **msg)
freeze=Hour->Freeze;
Rate->Hour=Hour->Name;
Unit=Hour->Unit;
if (now==0.0 && Unit->Duration==0.0)
Rate->Basic=Unit->Price;
jmp=now;
while (Unit->Delay!=UNKNOWN && Unit->Delay<=jmp) {
while (Unit->Delay!=UNKNOWN && Unit->Delay<=jmp && jmp>0) {
jmp-=Unit->Delay;
Unit++;
}
if (now==0.0 && Unit->Duration==0.0)
Rate->Basic=Unit->Price;
else
Rate->Price=Unit->Price;
Rate->Price=Unit->Price;
Rate->Duration=Unit->Duration;
}
now+=Unit->Duration;
Rate->Charge+=Unit->Price;
if (Unit->Duration>0.0)
Rate->Units++;
if (Unit->Duration==0.0) {
Rate->Charge+=Unit->Price;
} else {
n=leo(end-now, leap-now, Unit->Delay, Unit->Duration);
Rate->Units+=n;
Rate->Charge+=n*Unit->Price;
now+=n*Unit->Duration;
if (now>end)
break;
}
if (Unit->Delay!=UNKNOWN && Unit->Delay<=now) {
Unit++;
Rate->Price=Unit->Price;
Rate->Duration=Unit->Duration;
} else if (Unit->Duration==0.0)
break;
}
}
if (now>0.0)
Rate->Rest=now-Rate->Time;
return 0;
}
@ -1432,7 +1450,7 @@ void main (int argc, char *argv[])
printf ("%s\n", msg);
clearRate(&Rate);
Rate.prefix = 2;
Rate.prefix = 1;
if (argc==3) {
getNumber (argv[1], Rate.src);
@ -1446,15 +1464,18 @@ void main (int argc, char *argv[])
}
time(&Rate.start);
Rate.now=Rate.start;
Rate.now=Rate.start+153;
for (i=0; i<5000; i++) {
#if 1
Rate.prefix = 2;
for (i=0; i<10000; i++) {
if (getRate(&Rate, &msg)==UNKNOWN) {
printf ("Ooops: %s\n", msg);
exit (1);
}
Rate.now++;
}
printf ("domestic=%d _area=%d _zone=%d zone=%d Country=%s Zone=%s Service=%s Flags=%s\n"
"current=%s\n\n",
Rate.domestic, Rate._area, Rate._zone, Rate.zone, Rate.Country, Rate.Zone,
@ -1469,9 +1490,10 @@ void main (int argc, char *argv[])
explainRate(&Rate));
exit (0);
#endif
#if 1
#if 0
time(&Rate.start);
Rate.now=Rate.start+153;
@ -1519,9 +1541,20 @@ void main (int argc, char *argv[])
printf ("---Date--- --Time-- --Charge-- ( Basic Price) Unit Dur Time Rest\n");
time(&Rate.start)
time(&Rate.start);
time(&Rate.now);
if (getRate(&Rate, &msg)==UNKNOWN) {
printf ("Ooops: %s\n", msg);
exit (1);
}
printf ("domestic=%d _area=%d _zone=%d zone=%d Country=%s Zone=%s Service=%s Flags=%s\n"
"current=%s\n\n",
Rate.domestic, Rate._area, Rate._zone, Rate.zone, Rate.Country, Rate.Zone,
Rate.Service, Rate.Flags, explainRate(&Rate));
while (1) {
time(&Rate.now)
time(&Rate.now);
if (getRate(&Rate, &msg)==UNKNOWN) {
printf ("Ooops: %s\n", msg);
exit (1);

View File

@ -97,6 +97,10 @@ static void _init(void);
#undef ISDN_AT
#define ISDN_DE
#endif
#ifdef TESTnl
#undef ISDN_AT
#define ISDN_NL
#endif
/* --------------------- ADJUST here ----------------*/
#ifdef ISDN_AT
@ -122,7 +126,7 @@ void initTelNum(void)
#endif
#ifdef ISDN_NL
static void initTelNum()
void initTelNum()
{
vbn = strdup("16:17"); /* Fixme: VBN is defined in isdn.conf but not read yet */
preselect=999;
@ -296,7 +300,7 @@ int normalizeNumber(char *target, TELNUM *num, int flag) {
split_vbn(&p, num);
if (flag & TN_COUNTRY) {
res = split_country(&p, num);
if (res<0)
if (res<0)
return UNKNOWN;
else if(res==0)
first=1;
@ -353,6 +357,8 @@ void initNum(TELNUM *num) {
Strncpy(num->sarea, s, TN_MAX_SAREA_LEN);
free(s);
}
else
clearArea(num, UNKNOWN);
strcpy(num->vbn, defnum.vbn);
}

View File

@ -1,4 +1,4 @@
/* $Id: zone.c,v 1.15 1999/07/26 16:28:51 akool Exp $
/* $Id: zone.c,v 1.16 1999/07/31 09:25:49 akool Exp $
*
* Zonenberechnung
*
@ -19,6 +19,9 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: zone.c,v $
* Revision 1.16 1999/07/31 09:25:49 akool
* getRate() speedup
*
* Revision 1.15 1999/07/26 16:28:51 akool
* getRate() speedup from Leo
*
@ -647,14 +650,18 @@ static int _getAreacode(struct sth *sthp, char *from, char **text) {
if ((p = strchr(value.dptr, '\t')) != 0) { /* NL */
*p = '\0';
len = p[1] - '0'; /* gcc2.7.2.3 segfaults here if strtoul ?? */
*text = strdup(value.dptr);
if (text)
*text = strdup(value.dptr);
if (*dbv == 'G')
free(value.dptr);
}
else {
if (*dbv == 'G')
*text = value.dptr;
else
if(text)
*text = value.dptr;
else
free(value.dptr);
else if(text)
*text = strdup(value.dptr);
}
return len;