diff --git a/isdnlog/Makefile.in b/isdnlog/Makefile.in
index d2c9efd1..b7406350 100644
--- a/isdnlog/Makefile.in
+++ b/isdnlog/Makefile.in
@@ -1,4 +1,4 @@
-## $Id: Makefile.in,v 1.87 1999/06/16 19:11:54 akool Exp $
+## $Id: Makefile.in,v 1.88 1999/06/21 19:32:08 akool Exp $
##
## ISDN accounting for isdn4linux.
##
@@ -19,6 +19,12 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## $Log: Makefile.in,v $
+## Revision 1.88 1999/06/21 19:32:08 akool
+## isdnlog Version 3.35
+## zone data for .nl (many thanks to Paul!)
+##
+## WARNING: This version of isdnlog dont even compile! *EXPERIMENTAL*!!
+##
## Revision 1.87 1999/06/16 19:11:54 akool
## isdnlog Version 3.34
## fixed some memory faults
@@ -686,7 +692,7 @@ SERVICEFILE = /etc/services
# DON'T EDIT BELOW THIS LINE
######################################################################
-VERSION = 3.34
+VERSION = 3.35
MANPAGES = isdnlog/callerid.conf.5 isdnlog/isdn.conf.5 \
isdnlog/isdnformat.5 isdnlog/isdnlog.5 isdnlog/isdnlog.8 \
diff --git a/isdnlog/isdnlog/processor.c b/isdnlog/isdnlog/processor.c
index eeabca88..e1a0b1cd 100644
--- a/isdnlog/isdnlog/processor.c
+++ b/isdnlog/isdnlog/processor.c
@@ -1,4 +1,4 @@
-/* $Id: processor.c,v 1.68 1999/06/16 23:37:35 akool Exp $
+/* $Id: processor.c,v 1.69 1999/06/21 19:33:53 akool Exp $
*
* ISDN accounting for isdn4linux. (log-module)
*
@@ -19,6 +19,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: processor.c,v $
+ * Revision 1.69 1999/06/21 19:33:53 akool
+ * isdnlog Version 3.35
+ * zone data for .nl (many thanks to Paul!)
+ *
+ * WARNING: This version of isdnlog dont even compile! *EXPERIMENTAL*!!
+ *
* Revision 1.68 1999/06/16 23:37:35 akool
* fixed zone-processing
*
@@ -3573,10 +3579,13 @@ static void prepareRate(int chan, char **msg, char **tip, int viarep)
if (call[chan].intern[CALLING])
call[chan].Rate.src = mynum;
else {
- static char src[BUFSIZ];
+ static char src[BUFSIZ], *text;
auto int l;
+ l = getAreacode(DTAG, call[chan].num[CALLING] + 3, &text);
+ print_msg(PRT_NORMAL, "getAreacode(49,%s,\"%s\")=%d\n", call[chan].num[CALLING] + 3, text, l);
+
if ((get_areacode(call[chan].num[CALLING], &l, C_NO_WARN | C_NO_EXPAND | C_NO_ERROR)))
Strncpy(src, call[chan].num[CALLING], l + 1);
else
@@ -3586,9 +3595,11 @@ static void prepareRate(int chan, char **msg, char **tip, int viarep)
}
{
- static char dst[BUFSIZ];
+ static char dst[BUFSIZ], *text;
auto int l;
+ l = getAreacode(DTAG, call[chan].num[CALLED] + 3, &text);
+ print_msg(PRT_NORMAL, "getAreacode(49,%s,\"%s\")=%d\n", call[chan].num[CALLED] + 3, text, l);
if ((get_areacode(call[chan].num[CALLED], &l, C_NO_WARN | C_NO_EXPAND | C_NO_ERROR)))
Strncpy(dst, call[chan].num[CALLED], l + 1);
else
diff --git a/isdnlog/rate-de.dat b/isdnlog/rate-de.dat
index bcf837ca..9b245581 100644
--- a/isdnlog/rate-de.dat
+++ b/isdnlog/rate-de.dat
@@ -1,4 +1,4 @@
-V:1.02-Germany [16-Jun-1999 21:08:01]
+V:1.02-Germany [20-Jun-1999 22:27:34]
# 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.22 1999/06/16 19:12:01 akool Exp $
+# $Id: rate-de.dat,v 1.23 1999/06/21 19:32:14 akool Exp $
#
# Zonenzuordnung für Deutschland
#
@@ -11295,7 +11295,9 @@ T:*/8-18=0.07(60)/90
T:*/18-8=0.035(60)/90
Z:3,4
T:*/8-18=0.12(60)/1
-T:*/18-8=0.09(60)/1
+T:*/18-2,6-8=0.09(60)/1
+T:*/2-6=0.065(60)/1 Data
+A:+49
Z:10-15
T:*/8-18=0.59(60)/1
T:*/18-8=0.49(60)/1
@@ -13268,7 +13270,7 @@ Z:457
A:Ägypten # +20
T:*/08-20=1.199(60)/1
T:*/20-08=1.179(60)/1
-Z:358 Alaska
+Z:458 Alaska
A:Alaska # +1907
T:*/08-20=0.319(60)/1
T:*/20-08=0.299(60)/1
@@ -13375,7 +13377,7 @@ P:79 Viatel
##
## macht *keinen* Tarifwechsel in laufender Verbindung!
##
-G:01.05.1999
+G:15.06.1999
C:VIAPHONE GmbH, Hanauer Landstraße 187, 60314 Frankfurt 01079
C:Homepage: http://www.viatel.de
C:Hotline: 0800/79-01079
@@ -13384,20 +13386,188 @@ C:Telefax: 069/94 994-100
C:Adresse: Hanauer Landstrasse 187-189
C: 60314 Frankfurt am Main
D:dtag
-Z:2-4 Fern
-T:W/09-18=0.08/30,0.16(60)/1 Standard
-T:W/18-09=0.045/30,0.09(60)/1 Spar
-T:E/*=0.045/30,0.09(60)/1 Nacht
+Z:2-4 National
+T:W/09-18=0.064/30,0.128(60)/1 Hauptzeit
+T:W/18-21=0.085(60)/60 Nebenzeit
+T:W/21-9=0.055(60)/60 Nacht
+T:E/9-21=0.085(60)/60 Hauptzeit
+T:E/21-9=0.055(60)/60 Nacht
A:+49
-Z:5-10 Deutschland GSM
-A:01610,01617,01619,01618 # C
-A:0170,0171 # D1
-A:0172,0173 # D2
-A:0177,0178 # Eplus
-A:0176,0179 # E2
-T:W/09-18=0.365/30,0.73(60)/1 Standard
-T:W/18-09=0.18/30,0.36(60)/1 Spar
-T:E/*=0.18/30,0.36(60)/1 Spar
+Z:10-15 Mobilfunk
+T:W/09-18=0.365/30,0.730(60)/1 Hauptzeit
+T:W/18-09=0.01825/30,0.365(60)/1 Nebenzeit
+T:E/*=0.365(60)/60
+# Auslandstarife
+Z:200
+A:Afganistan,Amerikanisch Samoa,Angola,Antigua,Aquatorial Guinea,Anguilla
+A:Armenien,Aruba,Ascension,Aserbaidschan,Athiopien,Bahamas,Bahrain
+A:Bangladesch,Barbados,Belize,Benin,Bermuda,Bhutan,Botswana
+A:Britisch Jungferninseln,Brunei,Burkina Faso,Burma,Burundi,Cap Verde
+A:Cayman Inseln,Christmas & Cocos Inseln,Cook Inseln,Diego Garcia
+A:Dominica,Dschibuti,Elfenbeinküste,Eritrea,Falkland Inseln,Fidschi Inseln
+A:Franz. Antillen,Guadeloup,Franz. Guinea,Franz. Polynesion,Gabun
+A:Gambia,Ghana,Grenada,Carriacou,Grönland,Guam,Guantanamo Bay,Guinea
+A:Guinea Bissau,Guayana,Haiti,Indien,Irak,Iran,Jamaika,Jemen,Kambodscha
+A:Kamerun,Kasachstan,Katar,Kenia,Kirgisien,Kiribati,Kommoren,Kongo
+A:Korea Nord,Kuba,Kuwait,Laos,Lesotho,Liberia,Macao,Madagaskar
+A:Madeira,Malawi,Malediven,Mali,Marshall Inseln,Mauretanien,Mauritius
+A:Mayotte Inseln,Mikronesien,Mongolei,Montserrat,Mozambik,Namibia
+A:Nauru,Nepal,Neu Kaledonien,Nevis,Niederl. Antillen,Niger,Nigeria
+A:Niue,Norfolk Inseln,Oman,Pakistan,Palau,Papua Neu Guinea,Puerto Rico
+A:Reunion,Ruanda,Salomon Inseln,Sambia,Sao Tome,Saudi-Arabien,Senegal
+A:Seychellen,Somalia,Sri Lanka,St. Helena,St. Lucia,St. Kitts
+A:St. Pierre & Miquelon,St. Vincent & Greens.,Sudan,Surinam,Swaziland
+A:Tadschikistan,Tansania,Togo,Tonga,Trinidad & Tobago,Tschad,Turkmenistan
+A:Turks and Caicos Inseln,Tuvalu,US Jungferninseln,Uganda,Usbekistan
+A:Vanuatu,Vereinte Arabische Emirate,Vienam,Wallis & Futuna, Westl. Marianen
+A:Westl. Samoa,Zaire,Zentral. Afrika. Rep.,Zimbabwe
+T:W/9-18=1.065/30,2.13(60)/1
+T:W/18-9=0.937/30,1.874(60)/1
+T:E/*=0.937/30,1.874(60)/1
+Z:201
+A:Agypten,Jordanien,Syrien,Libanon
+T:*/*=0.5475/30,1.095(60)/1
+Z:202
+A:Albanien,Litauen,Mazedonien,Moldavien,Bosnien-Herzegovina,Bulgarien
+A:Estland,Rumänien,Rußland,Slowenien,Jugoslawien,Ukraine,Lettland
+T:W/9-18=0.5125/30,1.025(60)/1
+T:W/18-9=0.451/30,0.902(60)/1
+T:E/*=0.451/30,0.902(60)/1
+Z:203
+A:Algerien,Marokko,Gibraltar,Israel,Tunesien,Weißrußland,Libyen
+T:W/9-18=0.483/30,0.966(60)/1
+T:W/18-9=0.425/30,0.850(60)/1
+T:E/*=0.425/30,0.850(60)/1
+Z:204
+A:Andorra,Belgien Mobilfunk,Liechtenstein,Luxemburg,Monaco,Dänemark
+A:Niederlande Mobilfunk,San Marino,Irland,Spanien
+T:W/9-18=0.480/30,0.960(60)/1
+T:W/18-9=0.297/30,0.594(60)/1
+T:E/*=0.297/30,0.594(60)/1
+Z:205
+A:Argentinien,Mexiko,Dominikanische Republik,Brasilien,Kolumbien,Südafrika
+T:W/9-18=1.065/30,2.13(60)/1
+T:W/18-9=0.6605/30,1.321(60)/1
+T:E/*=0.6605/30,1.321(60)/1
+Z:206
+A:Australien,Japan
+T:W/9-18=0.631/30,1.262(60)/1
+T:W/18-9=0.4355/30,0.871(60)/1
+T:E/*=0.4355/30,0.871(60)/1
+Z:207
+A:Malaysia,Bolivien,China,Ecuador,El Salvador,Panama,Paraguay,Peru
+A:Guatemala,Honduras,Indonesien,Kosta Rica,Thailand,Uruguay,Venezuela
+A:Nicaragua
+T:W/9-18=1.065/30,2.13(60)/1
+T:W/18-9=0.788/30,1.576(60)/1
+T:E/*=0.788/30,1.576(60)/1
+Z:208
+A:Malta
+T:W/9-18=0.498/30,0.996(60)/1
+T:W/18-9=0.438/30,0.876(60)/1
+T:E/*=0.438/30,0.876(60)/1
+Z:209
+A:Belgien,Frankreich,Niederlande,Schweiz,Großbritannien,Schweiz Mobilfunk
+T:1-5/9-18=0.185/30,0.37(60)/1
+T:2-5/18-9=0.165/30,0.33(60)/1
+T:1/18-0=0.165/30,0.33(60)/1
+T:6/0-9=0.165/30,0.33(60)/1
+T:6/9-0=0.241/60 Weekend Special
+T:7/*=0.241/60 Weekend Special
+T:1/0-9=0.241/60 Weekend Special
+Z:210
+A:Osterreich
+T:W/9-18=0.185/30,0.37(60)/1
+T:W/18-9=0.165/30,0.33(60)/1
+T:E/*=0.165/30,0.33(60)/1
+Z:211
+A:Chile
+T:W/9-18=0.9665/30,1.933(60)/1
+T:W/18-9=0.483/30,0.966(60)/1
+T:E/*=0.483/30,0.966(60)/1
+Z:212
+A:Faroer Inseln
+T:W/9-18=0.338/30,0.676(60)/1
+T:W/18-9=0.3045/30,0.609(60)/1
+T:E/*=0.3045/30,0.609(60)/1
+Z:213
+A:Finnland,Norwegen,Portugal,Schweden,Island
+T:W/9-18=0.3985/30,0.797(60)/1
+T:W/18-9=0.299/30,0.598(60)/1
+T:E/*=0.299/30,0.598(60)/1
+Z:214
+A:Frankreich Mobilfunk
+T:*/*=0.2635/30,0.527(60)/1
+Z:215
+A:Georgien
+T:W/9-18=1.331/30,2.662(60)/1
+T:W/18-9=1.025/30,2.05(60)/1
+T:E/*=1.025/30,2.05(60)/1
+Z:216
+A:Griechenland
+T:W/9-18=0.345/30,0.690(60)/1
+T:W/18-9=0.328/30,0.656(60)/1
+T:E/*=0.328/30,0.656(60)/1
+Z:217
+A:Neuseeland,Singapur,Hongkong
+T:W/9-18=0.8185/30,1.637(60)/1
+T:W/18-9=0.434/30,0.868(60)/1
+T:E/*=0.434/30,0.868(60)/1
+Z:218
+A:Philippinen
+T:W/9-18=1.045/30,2.09(60)/1
+T:W/18-9=0.690/30,1.38(60)/1
+T:E/*=0.690/30,1.38(60)/1
+Z:219
+A:Polen
+T:W/9-18=0.337/30,0.674(60)/1
+T:W/18-9=0.3035/30,0.607(60)/1
+T:E/*=0.3035/30,0.607(60)/1
+Z:220
+A:Slowakei,Tschechien
+T:W/9-18=0.409/30,0.818(60)/1
+T:W/18-9=0.307/30,0.614(60)/1
+T:E/*=0.307/30,0.614(60)/1
+Z:221
+A:Großbritannien Mobilfunk
+T:*/*=0.2365/30,0.473(60)/1
+Z:222
+A:Italien,Italien POPs
+T:W/9-18=0.3215/30,0.643(60)/1
+T:W/18-9=0.2895/30,0.579(60)/1
+T:E/*=0.2895/30,0.579(60)/1
+Z:223
+A:Italien - Mailand,Italien - Rom
+T:*/*=0.273/30,0.546(60)/1
+Z:224
+A:Korea Süd
+T:W/9-18=0.8185/30,1.637(60)/1
+T:W/18-9=0.54/30,1.08(60)/1
+T:E/*=0.54/30,1.08(60)/1
+Z:225
+A:Kroatien,Ungarn.Zypern
+T:W/9-18=0.4635/30,0.927(60)/1
+T:W/18-9=0.4125/30,0.825(60)/1
+T:E/*=0.4125/30,0.825(60)/1
+Z:226
+A:Spanien - Barcelona,Spanien - Bilbao,Spanien - Gerona,Spanien - Madrid
+A:Spanien - Mallorca,Spanien - Tarragona,Spanien - Valencia
+T:W/9-18=0.3155/30,0.631(60)/1
+T:W/18-9=0.284/30,0.568(60)/1
+T:E/*=0.284/30,0.568(60)/1
+Z:227
+A:Taiwan
+T:W/9-18=0.789/30,1.578(60)/1
+T:W/18-9=0.5445/30,1.089(60)/1
+T:E/*=0.5445/30,1.089(60)/1
+Z:228
+A:Türkei
+T:W/9-18=0.3995/30,0.799(60)/1
+T:W/18-9=0.3795/30,0.759(60)/1
+T:E/*=0.3795/30,0.759(60)/1
+Z:229
+A:USA
+T:*/*=0.12/30,0.24(60)/1
#####################################################################
#
#
@@ -14142,7 +14312,7 @@ T:*/*=0.847/0,0.121/6.7
# 51:01051 Telecom 04.06.1999 je
# 70:Arcor 01.05.1999 ak
# 78:3U 01.05.1999 ak
-# 79:Viatel 01.05.1999 ak
+# 79:Viatel 20.06.1999 je
# 85:GTS-WESTCom 01.05.1999 ak
# 90:Viag Interkom 29.05.1999 je
#
diff --git a/isdnlog/tools/rate.c b/isdnlog/tools/rate.c
index d0faec75..6ec91815 100644
--- a/isdnlog/tools/rate.c
+++ b/isdnlog/tools/rate.c
@@ -1,4 +1,4 @@
-/* $Id: rate.c,v 1.23 1999/06/16 23:37:50 akool Exp $
+/* $Id: rate.c,v 1.24 1999/06/21 19:34:28 akool Exp $
*
* Tarifdatenbank
*
@@ -19,6 +19,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: rate.c,v $
+ * Revision 1.24 1999/06/21 19:34:28 akool
+ * isdnlog Version 3.35
+ * zone data for .nl (many thanks to Paul!)
+ *
+ * WARNING: This version of isdnlog dont even compile! *EXPERIMENTAL*!!
+ *
* Revision 1.23 1999/06/16 23:37:50 akool
* fixed zone-processing
*
@@ -1149,7 +1155,6 @@ int getRate(RATE *Rate, char **msg)
if (Rate->domestic && *(Rate->dst)=='+') {
int l=strlen(mycountry);
int z=getZone(prefix, Rate->src+l, Rate->dst+l);
- print_msg(PRT_NORMAL, "@@@ getZone(%d,%s,%s)=%d\n", prefix, Rate->src + l, Rate->dst + l, z);
if (z!=UNKNOWN) {
for (i=0; i
struct sth {
_DB fh;
@@ -88,15 +95,18 @@ struct sth {
int table_size;
int oz;
int numlen;
+ int cc;
} ;
#define min(a,b) (a) < (b) ? (a) : (b)
static struct sth *sthp;
static int count;
-static char version[] = "1.00";
+static char version[] = "1.10";
+static bool area_read = false;
+
#define LINK 127
#define INFO_LEN 80
-#define LENGTH 120
+#define LENGTH 160
#define BUFSIZE 200
#ifdef STANDALONE
@@ -118,7 +128,17 @@ static void warning (char *file, char *fmt, ...)
#endif
}
-void exitZone(int provider)
+static void _exitZone(int provider);
+
+void exitZone(int provider) {
+ int i;
+ _exitZone(provider);
+ for (i=0; i=10000)
+ _exitZone(sthp[i].provider);
+}
+
+static void _exitZone(int provider)
{
int i;
bool any = false;
@@ -154,20 +174,85 @@ void exitZone(int provider)
sthp = 0;
}
}
+#define ZONES 0
+#define AREACODES 1
+static int _initZone(int provider, char *path, char **msg, bool area_only);
int initZone(int provider, char *path, char **msg)
{
- int i;
static char message[LENGTH];
+ int res;
+ char * dir;
+ char * file;
+ char *p;
+ DIR *dp;
+ struct dirent *ep;
+ int len, i;
+
+ if (msg)
+ *(*msg=message)='\0';
+ res = _initZone(provider, path, msg, ZONES);
+ if (area_read)
+ return res;
+
+ area_read = true;
+ if ((dir = strdup(path)) == 0) {
+ if (msg)
+ snprintf (message, LENGTH,
+ "Zone V%s: Error: Out of mem 10", version);
+ return res;
+ }
+ p = strrchr(dir, '/');
+ if ((file = strdup(p+1)) == 0) {
+ if (msg)
+ snprintf (message, LENGTH,
+ "Zone V%s: Error: Out of mem 11", version);
+ return res;
+ }
+ p[1] = '\0';
+ if ((dp = opendir(dir)) == 0) {
+ if (msg)
+ snprintf (message, LENGTH,
+ "Zone V%s: Error: Out of mem 11", version);
+ return res;
+ }
+ len = strchr(file,'-')-file;
+ i = 0;
+ while ((ep = readdir(dp))) { /* zone-cc-xx */
+ if (memcmp(ep->d_name, file, len) == 0 && memcmp(ep->d_name, file, len+3) != 0) {
+ int l=strlen(dir)+strlen(ep->d_name)+1;
+ char *npath=malloc(l);
+ strcpy(npath, dir);
+ strcat(npath, ep->d_name);
+ _initZone(10000+i, npath, 0, AREACODES);
+ i++;
+ free(npath);
+ }
+ }
+ closedir(dp);
+ free(dir);
+ free(file);
+ if (msg && strlen(message) < LENGTH-5) {
+ strcat(message, " - ");
+ for (i=0; i=10000 && sthp[i].cc && strlen(message) < LENGTH-5)
+ sprintf(message+strlen(message),"%d ",sthp[i].cc);
+ }
+ return res;
+}
+
+static int _initZone(int provider, char *path, char **msg, bool area_only)
+{
+ int i;
struct sth *newsthp;
bool found;
int ocount;
int csize=0, tsize=0, n;
datum key, value;
+ char *message;
if (msg)
- *(*msg=message)='\0';
-
+ message = *msg;
if (!path || !*path) {
if (msg)
snprintf (message, LENGTH,
@@ -209,6 +294,7 @@ int initZone(int provider, char *path, char **msg)
sthp[ocount].real = -1;
sthp[ocount].oz=1;
sthp[ocount].numlen=0;
+ sthp[ocount].cc=0;
/* now search for same path */
found = false;
for (i=0; i 256 ? 256 : csize,
sizeof(int)) ) == 0) {
if (msg)
@@ -346,10 +442,10 @@ int initZone(int provider, char *path, char **msg)
if (msg) {
snprintf (message, LENGTH,
"Zone V%s: Provider %d File '%s' opened fine - "
- "V%s K%d C%d N%d T%d O%d L%d",
+ "V%s K%d C%d N%d T%d O%d L%d A%d",
version, provider, path,
dversion, sthp[ocount].pack_key, sthp[ocount].pack_table,
- csize, tsize, sthp[ocount].oz, sthp[ocount].numlen);
+ csize, tsize, sthp[ocount].oz, sthp[ocount].numlen, sthp[ocount].cc);
}
}
else {
@@ -369,7 +465,7 @@ static int _getZ(struct sth *sthp, char *from, char *sto) {
char *temp;
int res;
- if ((res=strcmp(from, sto)) == 0)
+ if ((res=strcmp(from, sto)) == 0)
return sthp->oz;
else if (res > 0) {
temp=from;
@@ -379,7 +475,7 @@ static int _getZ(struct sth *sthp, char *from, char *sto) {
strncpy(newfrom, from, LENGTH-1);
while (strlen(newfrom)) {
UL lifrom = (UL) atol(newfrom); /* keys could be long */
- US ifrom = (US) lifrom;
+ US ifrom = (US) lifrom;
if (sthp->pack_key == 2) {
key.dptr = (char *) &ifrom;
key.dsize = sizeof(US);
@@ -395,9 +491,9 @@ static int _getZ(struct sth *sthp, char *from, char *sto) {
US count;
int ito;
unsigned char z=0;
+ if (sthp->cc) /* if areacodes */
/* here is since 1.00 a zero-terminated strring */
while (*p++);
- /* skipped */
count = *((US*)p)++;
while (count--) {
bool ind = true;
@@ -437,10 +533,8 @@ static int _getZ(struct sth *sthp, char *from, char *sto) {
int getZone(int provider, char *from, char *to)
{
int i;
- char *path=NULL;
for (i=0; inumlen] = '\0';
while ((len=strlen(newfrom))) {
UL lifrom = (UL) atol(newfrom); /* keys could be long */
- US ifrom = (US) lifrom;
+ US ifrom = (US) lifrom;
if (sthp->pack_key == 2) {
+ if (lifrom >= 0x10000) { /* can't be, so cut a digit */
+ newfrom[strlen(newfrom) - 1] = '\0';
+ continue;
+ } /* if */
key.dptr = (char *) &ifrom;
key.dsize = sizeof(US);
}
@@ -473,17 +571,17 @@ static int _getAreacode(struct sth *sthp, char *from, char **text) {
if (*dbv == 'G') /* GDBM has a malloced string in dptr */
free(value.dptr);
return UNKNOWN;
- }
+ }
if (*dbv == 'G') /* GDBM has a malloced string in dptr */
*text = value.dptr;
- else
+ else
*text = strdup(value.dptr);
return len;
} /* if dptr */
newfrom[strlen(newfrom)-1] = '\0';
}
return UNKNOWN;
-}
+}
int getAreacode(int provider, char *from, char **text)
{
@@ -494,8 +592,8 @@ int getAreacode(int provider, char *from, char **text)
path = sthp[i].path ? sthp[i].path : sthp[sthp[i].real].path;
if (sthp[i].fh == 0)
return UNKNOWN;
- return _getAreacode(&sthp[i], from, text);
- }
+ return _getAreacode(&sthp[i], from, text);
+ }
}
#ifdef STANDALONE
@@ -568,7 +666,7 @@ static int checkZone(char *zf, char* df,int num1,int num2, bool verbose)
return ret;
}
-static int checkArea(char *df, char *from, int verbose) {
+static int checkArea(char *df, int cc, char *from, int verbose) {
char *msg, *text;
int ret=0;
@@ -578,13 +676,13 @@ static int checkArea(char *df, char *from, int verbose) {
}
if(verbose)
printf("%s\n", msg);
- ret = getAreacode(1, from, &text);
+ ret = getAreacode(cc, from, &text);
if(ret != UNKNOWN) {
- printf("%s:%d '%s'\n", from, ret, text);
+ printf("%s:%d '%s'\n", from, ret, text);
free(text);
}
else
- printf("%s - UNKNOWN\n", from);
+ printf("%s - UNKNOWN\n", from);
exitZone(1);
return ret;
}
@@ -596,13 +694,15 @@ int main (int argc, char *argv[])
char *zf=0;
int c;
int num1=0, num2=0;
+ int cc=0;
char snum1[LENGTH];
- while ( (c=getopt(argc, argv, "vVd:z:")) != EOF) {
+ while ( (c=getopt(argc, argv, "vVd:z:a:")) != EOF) {
switch (c) {
case 'v' : verbose = true; break;
case 'V' : printf("%s: V%s\n", basename(argv[0]), version); exit(1);
case 'd' : df = strdup(optarg); break;
case 'z' : zf = strdup(optarg); break;
+ case 'a' : cc = atoi(optarg); break;
}
}
while (optind < argc) {
@@ -622,7 +722,7 @@ int main (int argc, char *argv[])
if (df && (zf || (num1 && num2)))
return checkZone(zf, df, num1, num2, verbose);
if (df && num1)
- return checkArea(df, snum1, verbose);
+ return checkArea(df, snum1, verbose);
fprintf(stderr, "Usage:\n%s -d DBfile -v -V { -z Zonefile | num1 num2 }\n", basename(argv[0]));
fprintf(stderr, "\t-d DBfile -v -V num1\n");
return 0;
diff --git a/isdnlog/tools/zone/Makefile.in b/isdnlog/tools/zone/Makefile.in
index 644a1eee..59615420 100644
--- a/isdnlog/tools/zone/Makefile.in
+++ b/isdnlog/tools/zone/Makefile.in
@@ -3,8 +3,10 @@
#
# (C) 1999 l.toetsch
#
+BZIP2 = @BZIP2@
+BZIP2 = @BZIP2@
SHELL = /bin/sh
-CFLAGS = -Wall -g
+CFLAGS = -Wall -O2
INCLUDES =
LDFLAGS = @DBMLIB@
DBEXT = @DBEXT@
@@ -71,17 +73,21 @@ distclean: clean
rm -f config.h config.status config.cache config.log *.man Makefile
test:
- ./$(PROGRAM) -d uta$(DBEXT) -r at/uta/zred.uta -c at/code -v
- ./zone -d uta$(RDBEXT) -z at/uta/zoneall.uta -v
+ ./$(PROGRAM) -d zone-at-pta$(DBEXT) -r at/pta/zred.pta -c at/code -v
+ $(BZIP2) -d at/pta/zred.pta.bz2
+ $(BZIP2) -d at/pta/zoneall.pta.bz2
+ ./zone -d zone-at-pta$(RDBEXT) -z at/pta/zoneall.pta -v
+ $(BZIP2) -9 at/pta/zred.pta
+ $(BZIP2) -9 at/pta/zoneall.pta
zonefiles:
./$(PROGRAM) -d ../../zone-at-1012$(DBEXT) -r at/1012/zred-at-1012 -c at/code -v -l4
- bzip2 -d at/uta/zred.uta.bz2
+ $(BZIP2) -d at/uta/zred.uta.bz2
./$(PROGRAM) -d ../../zone-at-uta$(DBEXT) -r at/uta/zred.uta -c at/code -v
- bzip2 -9 at/uta/zred.uta
- bzip2 -d at/pta/zred.pta.bz2
+ $(BZIP2) -9 at/uta/zred.uta
+ $(BZIP2) -d at/pta/zred.pta.bz2
./$(PROGRAM) -d ../../zone-at-pta$(DBEXT) -r at/pta/zred.pta -c at/code -v
- bzip2 -9 at/pta/zred.pta
- bzip2 -d de/01033/zred.dtag.bz2
+ $(BZIP2) -9 at/pta/zred.pta
+ $(BZIP2) -d de/01033/zred.dtag.bz2
./$(PROGRAM) -d ../../zone-de-dtag$(DBEXT) -r de/01033/zred.dtag -c de/code -v
- bzip2 -9 de/01033/zred.dtag
+ $(BZIP2) -9 de/01033/zred.dtag
diff --git a/isdnlog/tools/zone/compzone b/isdnlog/tools/zone/compzone
index 51264a09..d63dac0c 100755
--- a/isdnlog/tools/zone/compzone
+++ b/isdnlog/tools/zone/compzone
@@ -86,7 +86,7 @@ sub min {
return $_[0] < $_[1] ? $_[0] : $_[1];
}
sub read_compact {
- my ($from,$to,$z,$n);
+ my ($from,$to,$z,$n, $cc);
print "Reading $reducedf...\n" if($verbose);
if (!$dbm) {
open(IN, $reducedf) || die("Can't read $reducedf");
@@ -112,6 +112,7 @@ sub read_compact {
$pack_table = $1 if(/C(\w)/);
$n = $1 if(/N(\d+)/);
$t = $1 if(/T(\d+)/);
+ $cc = $1 if(/A(\d+)/);
}
my($bnum) = $db{"_tAbLe\x0"};
my %len = ('C' => 1, 'S' => 2, 'L' => 4);
@@ -124,9 +125,11 @@ sub read_compact {
next if ($key eq "_tAbLe\x0" || $key eq "vErSiO\x0");
my($temp) = unpack($pack_key, $key);
next if( $temp !~ /\d/);
+ if ($cc) {
my($ind);
my($ort) = substr($value,0, $ind=index($value, "\x0"));
$value = substr($value, $ind+1);
+ }
my($count) = unpack('S', $value);
$value=substr($value, 2); # past count
while ($count--) {
diff --git a/isdnlog/tools/zone/configure b/isdnlog/tools/zone/configure
index a6d35126..1dff15b2 100755
--- a/isdnlog/tools/zone/configure
+++ b/isdnlog/tools/zone/configure
@@ -774,9 +774,42 @@ test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+for ac_prog in bzip2
+do
+# Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
+echo "configure:783: checking for $ac_word" >&5
+if eval "test \"`echo '$''{'ac_cv_prog_BZIP2'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ if test -n "$BZIP2"; then
+ ac_cv_prog_BZIP2="$BZIP2" # Let the user override the test.
+else
+ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
+ for ac_dir in $PATH; do
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$ac_word; then
+ ac_cv_prog_BZIP2="$ac_prog"
+ break
+ fi
+ done
+ IFS="$ac_save_ifs"
+fi
+fi
+BZIP2="$ac_cv_prog_BZIP2"
+if test -n "$BZIP2"; then
+ echo "$ac_t""$BZIP2" 1>&6
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+test -n "$BZIP2" && break
+done
+
echo $ac_n "checking for gdbm_open in -lgdbm""... $ac_c" 1>&6
-echo "configure:780: checking for gdbm_open in -lgdbm" >&5
+echo "configure:813: checking for gdbm_open in -lgdbm" >&5
ac_lib_var=`echo gdbm'_'gdbm_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -784,7 +817,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-lgdbm $LIBS"
cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:832: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -817,7 +850,7 @@ EOF
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 1>&6
-echo "configure:821: checking for dbm_open in -ldbm" >&5
+echo "configure:854: checking for dbm_open in -ldbm" >&5
ac_lib_var=`echo dbm'_'dbm_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -825,7 +858,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldbm $LIBS"
cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:873: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -858,7 +891,7 @@ EOF
else
echo "$ac_t""no" 1>&6
echo $ac_n "checking for dbm_open in -ldb""... $ac_c" 1>&6
-echo "configure:862: checking for dbm_open in -ldb" >&5
+echo "configure:895: checking for dbm_open in -ldb" >&5
ac_lib_var=`echo db'_'dbm_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
@@ -866,7 +899,7 @@ else
ac_save_LIBS="$LIBS"
LIBS="-ldb $LIBS"
cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:914: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes"
else
@@ -907,7 +940,7 @@ fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
-echo "configure:911: checking how to run the C preprocessor" >&5
+echo "configure:944: checking how to run the C preprocessor" >&5
# On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then
CPP=
@@ -922,13 +955,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp.
cat > conftest.$ac_ext <
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:932: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:965: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@@ -939,13 +972,13 @@ else
rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <
Syntax Error
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:949: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:982: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
:
@@ -968,12 +1001,12 @@ fi
echo "$ac_t""$CPP" 1>&6
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
-echo "configure:972: checking for ANSI C header files" >&5
+echo "configure:1005: checking for ANSI C header files" >&5
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
#include
@@ -981,7 +1014,7 @@ else
#include
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:985: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1018: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -998,7 +1031,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <
EOF
@@ -1016,7 +1049,7 @@ fi
if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <
EOF
@@ -1037,7 +1070,7 @@ if test "$cross_compiling" = yes; then
:
else
cat > conftest.$ac_ext <
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
@@ -1048,7 +1081,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }
EOF
-if { (eval echo configure:1052: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1085: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
:
else
@@ -1075,17 +1108,17 @@ for ac_hdr in unistd.h
do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
-echo "configure:1079: checking for $ac_hdr" >&5
+echo "configure:1112: checking for $ac_hdr" >&5
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
-{ (eval echo configure:1089: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+{ (eval echo configure:1122: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then
rm -rf conftest*
@@ -1113,12 +1146,12 @@ done
echo $ac_n "checking for size_t""... $ac_c" 1>&6
-echo "configure:1117: checking for size_t" >&5
+echo "configure:1150: checking for size_t" >&5
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <
#if STDC_HEADERS
@@ -1147,7 +1180,7 @@ fi
echo $ac_n "checking size of char""... $ac_c" 1>&6
-echo "configure:1151: checking size of char" >&5
+echo "configure:1184: checking size of char" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1155,7 +1188,7 @@ else
ac_cv_sizeof_char=1
else
cat > conftest.$ac_ext <
main()
@@ -1166,7 +1199,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1170: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1203: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_char=`cat conftestval`
else
@@ -1186,7 +1219,7 @@ EOF
echo $ac_n "checking size of short""... $ac_c" 1>&6
-echo "configure:1190: checking size of short" >&5
+echo "configure:1223: checking size of short" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1194,7 +1227,7 @@ else
ac_cv_sizeof_short=2
else
cat > conftest.$ac_ext <
main()
@@ -1205,7 +1238,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1209: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1242: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_short=`cat conftestval`
else
@@ -1225,7 +1258,7 @@ EOF
echo $ac_n "checking size of long""... $ac_c" 1>&6
-echo "configure:1229: checking size of long" >&5
+echo "configure:1262: checking size of long" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1233,7 +1266,7 @@ else
ac_cv_sizeof_long=4
else
cat > conftest.$ac_ext <
main()
@@ -1244,7 +1277,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1248: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1281: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_long=`cat conftestval`
else
@@ -1264,7 +1297,7 @@ EOF
echo $ac_n "checking size of int""... $ac_c" 1>&6
-echo "configure:1268: checking size of int" >&5
+echo "configure:1301: checking size of int" >&5
if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@@ -1272,7 +1305,7 @@ else
ac_cv_sizeof_int=4
else
cat > conftest.$ac_ext <
main()
@@ -1283,7 +1316,7 @@ main()
exit(0);
}
EOF
-if { (eval echo configure:1287: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
+if { (eval echo configure:1320: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
ac_cv_sizeof_int=`cat conftestval`
else
@@ -1306,12 +1339,12 @@ EOF
for ac_func in strdup strtoul
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
-echo "configure:1310: checking for $ac_func" >&5
+echo "configure:1343: checking for $ac_func" >&5
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
cat > conftest.$ac_ext <&5; (eval $ac_link) 2>&5; } && test -s conftest; then
+if { (eval echo configure:1371: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest; then
rm -rf conftest*
eval "ac_cv_func_$ac_func=yes"
else
@@ -1501,6 +1534,7 @@ s%@mandir@%$mandir%g
s%@CC@%$CC%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
s%@INSTALL_DATA@%$INSTALL_DATA%g
+s%@BZIP2@%$BZIP2%g
s%@CPP@%$CPP%g
s%@DBMLIB@%$DBMLIB%g
s%@DBEXT@%$DBEXT%g
diff --git a/isdnlog/tools/zone/configure.in b/isdnlog/tools/zone/configure.in
index 610b1066..2bf2c202 100644
--- a/isdnlog/tools/zone/configure.in
+++ b/isdnlog/tools/zone/configure.in
@@ -9,6 +9,7 @@ CONFIG_SBINDIR=`eval echo ${CONFIG_SBINDIR:-"/sbin"}`
dnl Checks for programs.
AC_PROG_CC
AC_PROG_INSTALL
+AC_CHECK_PROGS(BZIP2, bzip2)
dnl Checks for libraries.
dnl Berkeley DB appends RDBEXT
diff --git a/isdnlog/tools/zone/ddb b/isdnlog/tools/zone/ddb
index a95cfb8b..a2497b9f 100755
--- a/isdnlog/tools/zone/ddb
+++ b/isdnlog/tools/zone/ddb
@@ -33,7 +33,7 @@ sub min {
return $_[0] < $_[1] ? $_[0] : $_[1];
}
sub read_compact {
- my ($from,$to,$z,$n);
+ my ($from,$to,$z,$n, $cc);
$verbose=3;
print "Reading $reducedf...\n" if($verbose);
@@ -49,6 +49,7 @@ sub read_compact {
$pack_table = $1 if(/C(\w)/);
$n = $1 if(/N(\d+)/);
$t = $1 if(/T(\d+)/);
+ $cc = $1 if(/A(\d+)/);
}
my($bnum) = $db{"_tAbLe\x0"};
my %len = ('C' => 1, 'S' => 2, 'L' => 4);
@@ -62,10 +63,12 @@ sub read_compact {
next if ($key eq "_tAbLe\x0" || $key eq "vErSiO\x0");
my($temp) = unpack($pack_key, $key);
next if( $temp !~ /\d/);
+ if ($cc) {
my($ind);
my($ort) = substr($value,0, $ind=index($value, "\x0"));
print "$temp $ort\n";
$value = substr($value, $ind+1);
+ }
my($count) = unpack('S', $value);
$value=substr($value, 2); # past count
while ($count--) {
diff --git a/isdnlog/tools/zone/mkzonedb.c b/isdnlog/tools/zone/mkzonedb.c
index 022d55a8..b4fd08ea 100644
--- a/isdnlog/tools/zone/mkzonedb.c
+++ b/isdnlog/tools/zone/mkzonedb.c
@@ -4,7 +4,7 @@
* Copyright 1999 by Leopold Toetsch
*
* SYNOPSIS
- * mkzonedb -r Zonefile -d database [ -f ] [ -v ] [ - V ]
+ * mkzonedb -r Zonefile -d database -c Codef [-f] [-v] [-V] [-o Oz] [-l L]
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -22,7 +22,7 @@
*
*/
-static char progversion[] = "1.00";
+static char progversion[] = "1.01";
/* first char must match dataversion */
@@ -75,7 +75,6 @@ static int numlen;
static void read_codefile(char *cf) {
FILE *fp;
- int l, llen = 0;
char *p;
auto char line[BUFSIZ];
@@ -87,14 +86,13 @@ static void read_codefile(char *cf) {
exit(EXIT_FAILURE);
}
maxnum = 0;
- while (!feof(fp)) {
+ while (fgets(line, BUFSIZ, fp)) {
if (verbose && (nc % 1000) == 0) {
printf("%d\r", nc);
fflush(stdout);
}
- fgets(line, BUFSIZ, fp);
if (!isdigit(*line))
- continue;
+ break;
line[strlen(line)-1] = '\0';
if ((codes=realloc(codes, (nc+1)*sizeof(code_t))) == 0) {
fprintf(stderr, "Out of mem\n");
@@ -118,7 +116,7 @@ static void read_codefile(char *cf) {
fflush(stdout);
}
fclose(fp);
- /* we append a dumm for not defined nums */
+ /* we append a dummy for not defined nums */
if ((codes=realloc(codes, (nc+1)*sizeof(code_t))) == 0) {
fprintf(stderr, "Out of mem\n");
exit(EXIT_FAILURE);
@@ -131,8 +129,6 @@ static void read_codefile(char *cf) {
static void read_rzfile(char *rf) {
int i;
char line[BUFSIZ], *p, *op;
-
- size_t llen, l;
FILE *fp;
int from,to,z;
@@ -140,30 +136,24 @@ static void read_rzfile(char *rf) {
fprintf(stderr, "Coudn't read '%s'\n", rf);
exit(EXIT_FAILURE);
}
- llen=40;
- n=0;
- zones = 0;
if ((numbers = calloc(maxnum+1, sizeof(int))) == 0) {
fprintf(stderr, "Out of mem\n");
exit(EXIT_FAILURE);
}
- i=keylen=keydigs=0;
+ n=i=keylen=keydigs=0;
if (verbose)
printf("Reading %s\n", rf);
- while (!feof(fp)) {
+ while (fgets(line, BUFSIZ, fp)) {
if (verbose && (n % 1000) == 0) {
printf("%d\r", n);
fflush(stdout);
}
- fgets(line, BUFSIZ, fp);
- l = strlen(line);
- if (!l || l == -1 || !*line)
+ if (!*line)
break;
- if (l>40)
+ if (strlen(line)>40)
fprintf(stderr, "Possible junk in line %d", n);
- p = line;
- from = strtoul(p, &p, 10);
+ from = strtoul(line, &p, 10);
if (p-line > keydigs)
keydigs=p-line;
p++;
@@ -194,6 +184,7 @@ static void read_rzfile(char *rf) {
free(rf);
}
+/* get the 256 top used nums in table */
static void make_table() {
int i, j, k;
tablelen = 0;
@@ -253,8 +244,16 @@ static void write_remaining_codes(_DB db) {
US kus;
datum key, value;
char *val;
+ if (verbose)
+ printf("Writing remaining\n");
+
for (i=0 ; i< nc; i++)
if (codes[i].num > 0 && *codes[i].code) {
+ if (verbose && (i % 1000) == 0) {
+ printf("%d\r", i);
+ fflush(stdout);
+ }
+
if (keylen == 4) {
kul = (UL)codes[i].num;
key.dptr = (char*)&kul;
@@ -271,7 +270,7 @@ static void write_remaining_codes(_DB db) {
value.dsize = l;
if(STORE(db, key, value)) {
fprintf(stderr, "Error storing key '%d' - %s\n",codes[i].num,GET_ERR);
-/* exit(EXIT_FAILURE); */
+ exit(EXIT_FAILURE);
}
free(val);
}
@@ -309,7 +308,10 @@ static void write_db(char * df) {
nn,n, ortszone, numlen?numlen:keydigs);
value.dptr = version;
value.dsize = strlen(version)+1;
- STORE(db, key, value);
+ if(STORE(db, key, value)) {
+ fprintf(stderr, "Error storing version key - %s\n", GET_ERR);
+ exit(EXIT_FAILURE);
+ }
if ((p = val = calloc(nn, tablelen)) == 0) {
fprintf(stderr, "Out of mem\n");
@@ -326,11 +328,14 @@ static void write_db(char * df) {
*((UL*)p)++ = (UL)table[i];
value.dptr = val;
value.dsize = nn*tablelen;
- STORE(db, key, value);
+ if(STORE(db, key, value)) {
+ fprintf(stderr, "Error storing table key - %s\n", GET_ERR);
+ exit(EXIT_FAILURE);
+ }
free(val);
/* and write data */
- val = malloc(2); /* size */
+ val = malloc(2); /* size of count */
vlen = 2;
ofrom = -1;
count = 0;
@@ -351,7 +356,7 @@ static void write_db(char * df) {
fprintf(stderr, "Error storing key '%d' - %s\n",ofrom,GET_ERR);
exit(EXIT_FAILURE);
}
- free(val);
+ free(value.dptr); /* the realloced val */
}
if (ofrom != zones[i][0]) {
count = 0;
@@ -404,7 +409,7 @@ static void write_db(char * df) {
value.dsize = vlen;
insert_code(&value, ofrom);
STORE(db, key, value);
- free(val);
+ free(value.dptr);
write_remaining_codes(db);
CLOSE(db);
free(zones);
@@ -437,12 +442,9 @@ int main (int argc, char *argv[])
}
read_codefile(cf);
read_rzfile(rf);
- /* make table of 256 maxused to's */
make_table();
-
write_db(df);
-
/* Uff this got longer as I thought,
C is a real low level language -
now it's clear, why I prefer Perl
diff --git a/isdnlog/tools/zone/zoneutils.html b/isdnlog/tools/zone/zoneutils.html
index 2f70e312..ea22d07c 100644
--- a/isdnlog/tools/zone/zoneutils.html
+++ b/isdnlog/tools/zone/zoneutils.html
@@ -59,11 +59,16 @@ compzone { -zZonefile | -rReducedfile } -cCodefi
Makes a zonedatabase (gdbm - GNU Database or db - Berkeley DB) from a reduced file.
Synopsis
-./mkzonedb -d zone-CC-PP.gdbm -r ReducedFile -c Codefile [ -vVerboselevel ] [ -o Localzone ] [ -l Len ]
+./mkzonedb -d zone-CC-PP.gdbm -r ReducedFile -c Codefile [-a CC ] [ -vVerboselevel ] [ -o Localzone ] [ -l Len ]
Options
-r ReducedFile ... reduced zone file from redzone
--d zone-CC-PP.gdbm ...CC = Iso-Countrycode, PP = Providername/number
-c Codefile
-v Verboselevel ... default = 1
-o Localzone ... default = 1
-l Len ... default = maxlen of data
+-d zone-CC-PP.gdbm ...CC = Iso-Countrycode, PP = Providername/number
+-c Codefile
+-v Verboselevel ... default = 1
+-o Localzone ... default = 1
+-l Len ... default = maxlen of data
+-a CC .. Countrycode (only 1 File per country should have this)
For examples look at the Makefile in target zonefiles.
@@ -71,7 +76,7 @@ compzone { -zZonefile | -rReducedfile } -cCodefi
zone -d Datafile [ -v ] [ -V ] { -z zonefile | num1 num2 }
or
-zone -d Datafile [ -v ] [ -V ] num1
+zone -d Datafile [ -v ] [ -V ] -a CC num1
Options
-v ... verbose
@@ -81,7 +86,7 @@ compzone { -zZonefile | -rReducedfile } -cCodefi
cc -DSTANDALONE -o zone zone.c -lgdbm
I4L-Interface:
-int initZone(int provider, char *datapath, char **msg)
returns -1 on error, 0 if ok
void exitZone(int provider)
int getZone(int provider, char *from, char *to)
returns -2 on error, UNKNOWN on not found, zone if ok
int getAreacode(int provider, char *num, char **text)
returns UNKNOWN if not found, or len of areacode
text is a malloced string containing the name of the area
+int initZone(int provider, char *datapath, char **msg)
returns -1 on error, 0 if ok
void exitZone(int provider)
int getZone(int provider, char *from, char *to)
returns -2 on error, UNKNOWN on not found, zone if ok
int getAreacode(int country, char *num, char **text)
returns UNKNOWN if not found, or len of areacode
text is a malloced string containing the name of the area
the caller should free this text.
Glossary
@@ -95,12 +100,12 @@ then from.
1 2253 1
...
-It has (N*N-1)/2 entries.
+It has N*(N-1)/2 entries.
A Zonefile with wildcards. It must be read top down to get correct rsults. The first matching entry is the right
one.
-1 0252 1
+1 252 1
...
2252 228 1
2252 22 0
@@ -116,12 +121,12 @@ one.
The line with zone 127 is a link to the zone-info 2252, so there are theoretical maximum of 126 zones.
-File of lines of all tel numbers.
-1
-2142
-2143
+File of lines of all tel numbers and cits, separated by <tab>s
+1 Wien
+2142 Gattendorf
+2143 Berg
...
-2252
+2252 Baden b Wien
...
Author
diff --git a/isdnlog/zone-at-1012.gdbm b/isdnlog/zone-at-1012.gdbm
index 39a4bbec..41ce7603 100644
Binary files a/isdnlog/zone-at-1012.gdbm and b/isdnlog/zone-at-1012.gdbm differ
diff --git a/isdnlog/zone-at-pta.gdbm b/isdnlog/zone-at-pta.gdbm
index 583a0b61..ed04720c 100644
Binary files a/isdnlog/zone-at-pta.gdbm and b/isdnlog/zone-at-pta.gdbm differ
diff --git a/isdnlog/zone-at-uta.gdbm b/isdnlog/zone-at-uta.gdbm
index 23999b77..8d1f4553 100644
Binary files a/isdnlog/zone-at-uta.gdbm and b/isdnlog/zone-at-uta.gdbm differ
diff --git a/isdnlog/zone-de-dtag.gdbm b/isdnlog/zone-de-dtag.gdbm
index 2a14047f..c58619e8 100644
Binary files a/isdnlog/zone-de-dtag.gdbm and b/isdnlog/zone-de-dtag.gdbm differ