isdnlog Version 3.35

zone data for .nl (many thanks to Paul!)

  WARNING: This version of isdnlog dont even compile! *EXPERIMENTAL*!!
This commit is contained in:
akool 1999-06-21 19:32:08 +00:00
parent 06b8787949
commit f6fe20a597
16 changed files with 495 additions and 149 deletions

View File

@ -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. ## ISDN accounting for isdn4linux.
## ##
@ -19,6 +19,12 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
## ##
## $Log: Makefile.in,v $ ## $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 ## Revision 1.87 1999/06/16 19:11:54 akool
## isdnlog Version 3.34 ## isdnlog Version 3.34
## fixed some memory faults ## fixed some memory faults
@ -686,7 +692,7 @@ SERVICEFILE = /etc/services
# DON'T EDIT BELOW THIS LINE # DON'T EDIT BELOW THIS LINE
###################################################################### ######################################################################
VERSION = 3.34 VERSION = 3.35
MANPAGES = isdnlog/callerid.conf.5 isdnlog/isdn.conf.5 \ MANPAGES = isdnlog/callerid.conf.5 isdnlog/isdn.conf.5 \
isdnlog/isdnformat.5 isdnlog/isdnlog.5 isdnlog/isdnlog.8 \ isdnlog/isdnformat.5 isdnlog/isdnlog.5 isdnlog/isdnlog.8 \

View File

@ -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) * ISDN accounting for isdn4linux. (log-module)
* *
@ -19,6 +19,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *
* $Log: processor.c,v $ * $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 * Revision 1.68 1999/06/16 23:37:35 akool
* fixed zone-processing * fixed zone-processing
* *
@ -3573,10 +3579,13 @@ static void prepareRate(int chan, char **msg, char **tip, int viarep)
if (call[chan].intern[CALLING]) if (call[chan].intern[CALLING])
call[chan].Rate.src = mynum; call[chan].Rate.src = mynum;
else { else {
static char src[BUFSIZ]; static char src[BUFSIZ], *text;
auto int l; 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))) 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); Strncpy(src, call[chan].num[CALLING], l + 1);
else 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; 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))) 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); Strncpy(dst, call[chan].num[CALLED], l + 1);
else else

View File

@ -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 # Währungsformat
U:%.3f DM U:%.3f DM
@ -8,7 +8,7 @@ U:%.3f DM
# #
# (C) Copyright 1999 by Andreas Kool (akool@isdn4linux.de) # (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 # Zonenzuordnung für Deutschland
# #
@ -11295,7 +11295,9 @@ T:*/8-18=0.07(60)/90
T:*/18-8=0.035(60)/90 T:*/18-8=0.035(60)/90
Z:3,4 Z:3,4
T:*/8-18=0.12(60)/1 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 Z:10-15
T:*/8-18=0.59(60)/1 T:*/8-18=0.59(60)/1
T:*/18-8=0.49(60)/1 T:*/18-8=0.49(60)/1
@ -13268,7 +13270,7 @@ Z:457
A:Ägypten # +20 A:Ägypten # +20
T:*/08-20=1.199(60)/1 T:*/08-20=1.199(60)/1
T:*/20-08=1.179(60)/1 T:*/20-08=1.179(60)/1
Z:358 Alaska Z:458 Alaska
A:Alaska # +1907 A:Alaska # +1907
T:*/08-20=0.319(60)/1 T:*/08-20=0.319(60)/1
T:*/20-08=0.299(60)/1 T:*/20-08=0.299(60)/1
@ -13375,7 +13377,7 @@ P:79 Viatel
## ##
## macht *keinen* Tarifwechsel in laufender Verbindung! ## 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:VIAPHONE GmbH, Hanauer Landstraße 187, 60314 Frankfurt 01079
C:Homepage: http://www.viatel.de C:Homepage: http://www.viatel.de
C:Hotline: 0800/79-01079 C:Hotline: 0800/79-01079
@ -13384,20 +13386,188 @@ C:Telefax: 069/94 994-100
C:Adresse: Hanauer Landstrasse 187-189 C:Adresse: Hanauer Landstrasse 187-189
C: 60314 Frankfurt am Main C: 60314 Frankfurt am Main
D:dtag D:dtag
Z:2-4 Fern Z:2-4 National
T:W/09-18=0.08/30,0.16(60)/1 Standard T:W/09-18=0.064/30,0.128(60)/1 Hauptzeit
T:W/18-09=0.045/30,0.09(60)/1 Spar T:W/18-21=0.085(60)/60 Nebenzeit
T:E/*=0.045/30,0.09(60)/1 Nacht 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 A:+49
Z:5-10 Deutschland GSM Z:10-15 Mobilfunk
A:01610,01617,01619,01618 # C T:W/09-18=0.365/30,0.730(60)/1 Hauptzeit
A:0170,0171 # D1 T:W/18-09=0.01825/30,0.365(60)/1 Nebenzeit
A:0172,0173 # D2 T:E/*=0.365(60)/60
A:0177,0178 # Eplus # Auslandstarife
A:0176,0179 # E2 Z:200
T:W/09-18=0.365/30,0.73(60)/1 Standard A:Afganistan,Amerikanisch Samoa,Angola,Antigua,Aquatorial Guinea,Anguilla
T:W/18-09=0.18/30,0.36(60)/1 Spar A:Armenien,Aruba,Ascension,Aserbaidschan,Athiopien,Bahamas,Bahrain
T:E/*=0.18/30,0.36(60)/1 Spar 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 # 51:01051 Telecom 04.06.1999 je
# 70:Arcor 01.05.1999 ak # 70:Arcor 01.05.1999 ak
# 78:3U 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 # 85:GTS-WESTCom 01.05.1999 ak
# 90:Viag Interkom 29.05.1999 je # 90:Viag Interkom 29.05.1999 je
# #

View File

@ -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 * Tarifdatenbank
* *
@ -19,6 +19,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *
* $Log: rate.c,v $ * $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 * Revision 1.23 1999/06/16 23:37:50 akool
* fixed zone-processing * fixed zone-processing
* *
@ -1149,7 +1155,6 @@ int getRate(RATE *Rate, char **msg)
if (Rate->domestic && *(Rate->dst)=='+') { if (Rate->domestic && *(Rate->dst)=='+') {
int l=strlen(mycountry); int l=strlen(mycountry);
int z=getZone(prefix, Rate->src+l, Rate->dst+l); 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) { if (z!=UNKNOWN) {
for (i=0; i<Provider[prefix].nZone; i++) { for (i=0; i<Provider[prefix].nZone; i++) {
for (j=0; j<Provider[prefix].Zone[i].nNumber; j++) { for (j=0; j<Provider[prefix].Zone[i].nNumber; j++) {

View File

@ -1,4 +1,4 @@
/* $Id: zone.c,v 1.4 1999/06/18 12:41:57 akool Exp $ /* $Id: zone.c,v 1.5 1999/06/21 19:35:04 akool Exp $
* *
* Zonenberechnung * Zonenberechnung
* *
@ -19,6 +19,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
* *
* $Log: zone.c,v $ * $Log: zone.c,v $
* Revision 1.5 1999/06/21 19:35:04 akool
* isdnlog Version 3.35
* zone data for .nl (many thanks to Paul!)
*
* WARNING: This version of isdnlog dont even compile! *EXPERIMENTAL*!!
*
* Revision 1.4 1999/06/18 12:41:57 akool * Revision 1.4 1999/06/18 12:41:57 akool
* zone V1.0 * zone V1.0
* *
@ -43,7 +49,7 @@
* int getZone(int provider, char *from, char *to) * int getZone(int provider, char *from, char *to)
* returns zone for provider, UNKNOWN on not found, -2 on error * returns zone for provider, UNKNOWN on not found, -2 on error
* *
* int getAreacode(int provider, char *num, char **text) * int getAreacode(int countrycode, char *num, char **text)
* returns len of areacode in num and in text a malloced string * returns len of areacode in num and in text a malloced string
* UNKNOWN on not found * UNKNOWN on not found
* *
@ -76,6 +82,7 @@ extern const char *basename (const char *name);
/* this config (from config.in) could go in global policy */ /* this config (from config.in) could go in global policy */
#include "zone/config.h" #include "zone/config.h"
#include "zone/common.h" #include "zone/common.h"
#include <dirent.h>
struct sth { struct sth {
_DB fh; _DB fh;
@ -88,15 +95,18 @@ struct sth {
int table_size; int table_size;
int oz; int oz;
int numlen; int numlen;
int cc;
} ; } ;
#define min(a,b) (a) < (b) ? (a) : (b) #define min(a,b) (a) < (b) ? (a) : (b)
static struct sth *sthp; static struct sth *sthp;
static int count; static int count;
static char version[] = "1.00"; static char version[] = "1.10";
static bool area_read = false;
#define LINK 127 #define LINK 127
#define INFO_LEN 80 #define INFO_LEN 80
#define LENGTH 120 #define LENGTH 160
#define BUFSIZE 200 #define BUFSIZE 200
#ifdef STANDALONE #ifdef STANDALONE
@ -118,7 +128,17 @@ static void warning (char *file, char *fmt, ...)
#endif #endif
} }
void exitZone(int provider) static void _exitZone(int provider);
void exitZone(int provider) {
int i;
_exitZone(provider);
for (i=0; i<count; i++)
if(sthp[i].provider>=10000)
_exitZone(sthp[i].provider);
}
static void _exitZone(int provider)
{ {
int i; int i;
bool any = false; bool any = false;
@ -154,20 +174,85 @@ void exitZone(int provider)
sthp = 0; 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 initZone(int provider, char *path, char **msg)
{ {
int i;
static char message[LENGTH]; 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<count; i++)
if(sthp[i].provider>=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; struct sth *newsthp;
bool found; bool found;
int ocount; int ocount;
int csize=0, tsize=0, n; int csize=0, tsize=0, n;
datum key, value; datum key, value;
char *message;
if (msg) if (msg)
*(*msg=message)='\0'; message = *msg;
if (!path || !*path) { if (!path || !*path) {
if (msg) if (msg)
snprintf (message, LENGTH, snprintf (message, LENGTH,
@ -209,6 +294,7 @@ int initZone(int provider, char *path, char **msg)
sthp[ocount].real = -1; sthp[ocount].real = -1;
sthp[ocount].oz=1; sthp[ocount].oz=1;
sthp[ocount].numlen=0; sthp[ocount].numlen=0;
sthp[ocount].cc=0;
/* now search for same path */ /* now search for same path */
found = false; found = false;
for (i=0; i<count-1; i++) { for (i=0; i<count-1; i++) {
@ -265,7 +351,7 @@ int initZone(int provider, char *path, char **msg)
*q++ = *p++; *q++ = *p++;
*q = '\0'; *q = '\0';
if (*dversion != *version) { if (*dversion != *version) {
if (msg) if (msg)
snprintf (message, LENGTH, snprintf (message, LENGTH,
"Zone V%s: Error: Provider %d File '%s': incompatible Dataversion %s", "Zone V%s: Error: Provider %d File '%s': incompatible Dataversion %s",
version, provider, path, dversion); version, provider, path, dversion);
@ -287,14 +373,18 @@ int initZone(int provider, char *path, char **msg)
p++; p++;
tsize = strtol(p, &p, 10); tsize = strtol(p, &p, 10);
break; break;
case 'O' : case 'O' :
p++; p++;
sthp[ocount].oz = strtol(p, &p, 10); sthp[ocount].oz = strtol(p, &p, 10);
break; break;
case 'L' : case 'L' :
p++; p++;
sthp[ocount].numlen = strtol(p, &p, 10); sthp[ocount].numlen = strtol(p, &p, 10);
break; break;
case 'A' : /* this provider has the areacodes for county A */
p++;
sthp[ocount].cc = strtol(p, &p, 10);
break;
} }
} /* for */ } /* for */
free (value.dptr); free (value.dptr);
@ -314,10 +404,16 @@ int initZone(int provider, char *path, char **msg)
exitZone(provider); exitZone(provider);
return -1; return -1;
} }
/* alloc & read table */
sthp[ocount].pack_table = sthp[ocount].pack_table == 'C' ? sizeof(char) : sthp[ocount].pack_table = sthp[ocount].pack_table == 'C' ? sizeof(char) :
sthp[ocount].pack_table == 'S' ? sizeof(short) : sizeof(long); sthp[ocount].pack_table == 'S' ? sizeof(short) : sizeof(long);
sthp[ocount].pack_key = sthp[ocount].pack_key == 'S' ? sizeof(short) : sizeof(long); sthp[ocount].pack_key = sthp[ocount].pack_key == 'S' ? sizeof(short) : sizeof(long);
if (area_only) {
if (sthp[ocount].cc == 0)
_exitZone(provider); /* discard this one */
return;
}
/* alloc & read table */
if ( (sthp[ocount].table = calloc(csize > 256 ? 256 : csize, if ( (sthp[ocount].table = calloc(csize > 256 ? 256 : csize,
sizeof(int)) ) == 0) { sizeof(int)) ) == 0) {
if (msg) if (msg)
@ -346,10 +442,10 @@ int initZone(int provider, char *path, char **msg)
if (msg) { if (msg) {
snprintf (message, LENGTH, snprintf (message, LENGTH,
"Zone V%s: Provider %d File '%s' opened fine - " "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, version, provider, path,
dversion, sthp[ocount].pack_key, sthp[ocount].pack_table, 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 { else {
@ -369,7 +465,7 @@ static int _getZ(struct sth *sthp, char *from, char *sto) {
char *temp; char *temp;
int res; int res;
if ((res=strcmp(from, sto)) == 0) if ((res=strcmp(from, sto)) == 0)
return sthp->oz; return sthp->oz;
else if (res > 0) { else if (res > 0) {
temp=from; temp=from;
@ -379,7 +475,7 @@ static int _getZ(struct sth *sthp, char *from, char *sto) {
strncpy(newfrom, from, LENGTH-1); strncpy(newfrom, from, LENGTH-1);
while (strlen(newfrom)) { while (strlen(newfrom)) {
UL lifrom = (UL) atol(newfrom); /* keys could be long */ UL lifrom = (UL) atol(newfrom); /* keys could be long */
US ifrom = (US) lifrom; US ifrom = (US) lifrom;
if (sthp->pack_key == 2) { if (sthp->pack_key == 2) {
key.dptr = (char *) &ifrom; key.dptr = (char *) &ifrom;
key.dsize = sizeof(US); key.dsize = sizeof(US);
@ -395,9 +491,9 @@ static int _getZ(struct sth *sthp, char *from, char *sto) {
US count; US count;
int ito; int ito;
unsigned char z=0; unsigned char z=0;
if (sthp->cc) /* if areacodes */
/* here is since 1.00 a zero-terminated strring */ /* here is since 1.00 a zero-terminated strring */
while (*p++); while (*p++);
/* skipped */
count = *((US*)p)++; count = *((US*)p)++;
while (count--) { while (count--) {
bool ind = true; 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 getZone(int provider, char *from, char *to)
{ {
int i; int i;
char *path=NULL;
for (i=0; i<count; i++) for (i=0; i<count; i++)
if (sthp[i].provider == provider) { if (sthp[i].provider == provider) {
path = sthp[i].path ? sthp[i].path : sthp[sthp[i].real].path;
if (sthp[i].fh == 0) if (sthp[i].fh == 0)
return UNKNOWN; return UNKNOWN;
return _getZ(&sthp[i], from, to); return _getZ(&sthp[i], from, to);
@ -458,8 +552,12 @@ static int _getAreacode(struct sth *sthp, char *from, char **text) {
newfrom[sthp->numlen] = '\0'; newfrom[sthp->numlen] = '\0';
while ((len=strlen(newfrom))) { while ((len=strlen(newfrom))) {
UL lifrom = (UL) atol(newfrom); /* keys could be long */ UL lifrom = (UL) atol(newfrom); /* keys could be long */
US ifrom = (US) lifrom; US ifrom = (US) lifrom;
if (sthp->pack_key == 2) { 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.dptr = (char *) &ifrom;
key.dsize = sizeof(US); 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 */ if (*dbv == 'G') /* GDBM has a malloced string in dptr */
free(value.dptr); free(value.dptr);
return UNKNOWN; return UNKNOWN;
} }
if (*dbv == 'G') /* GDBM has a malloced string in dptr */ if (*dbv == 'G') /* GDBM has a malloced string in dptr */
*text = value.dptr; *text = value.dptr;
else else
*text = strdup(value.dptr); *text = strdup(value.dptr);
return len; return len;
} /* if dptr */ } /* if dptr */
newfrom[strlen(newfrom)-1] = '\0'; newfrom[strlen(newfrom)-1] = '\0';
} }
return UNKNOWN; return UNKNOWN;
} }
int getAreacode(int provider, char *from, char **text) 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; path = sthp[i].path ? sthp[i].path : sthp[sthp[i].real].path;
if (sthp[i].fh == 0) if (sthp[i].fh == 0)
return UNKNOWN; return UNKNOWN;
return _getAreacode(&sthp[i], from, text); return _getAreacode(&sthp[i], from, text);
} }
} }
#ifdef STANDALONE #ifdef STANDALONE
@ -568,7 +666,7 @@ static int checkZone(char *zf, char* df,int num1,int num2, bool verbose)
return ret; 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; char *msg, *text;
int ret=0; int ret=0;
@ -578,13 +676,13 @@ static int checkArea(char *df, char *from, int verbose) {
} }
if(verbose) if(verbose)
printf("%s\n", msg); printf("%s\n", msg);
ret = getAreacode(1, from, &text); ret = getAreacode(cc, from, &text);
if(ret != UNKNOWN) { if(ret != UNKNOWN) {
printf("%s:%d '%s'\n", from, ret, text); printf("%s:%d '%s'\n", from, ret, text);
free(text); free(text);
} }
else else
printf("%s - UNKNOWN\n", from); printf("%s - UNKNOWN\n", from);
exitZone(1); exitZone(1);
return ret; return ret;
} }
@ -596,13 +694,15 @@ int main (int argc, char *argv[])
char *zf=0; char *zf=0;
int c; int c;
int num1=0, num2=0; int num1=0, num2=0;
int cc=0;
char snum1[LENGTH]; char snum1[LENGTH];
while ( (c=getopt(argc, argv, "vVd:z:")) != EOF) { while ( (c=getopt(argc, argv, "vVd:z:a:")) != EOF) {
switch (c) { switch (c) {
case 'v' : verbose = true; break; case 'v' : verbose = true; break;
case 'V' : printf("%s: V%s\n", basename(argv[0]), version); exit(1); case 'V' : printf("%s: V%s\n", basename(argv[0]), version); exit(1);
case 'd' : df = strdup(optarg); break; case 'd' : df = strdup(optarg); break;
case 'z' : zf = strdup(optarg); break; case 'z' : zf = strdup(optarg); break;
case 'a' : cc = atoi(optarg); break;
} }
} }
while (optind < argc) { while (optind < argc) {
@ -622,7 +722,7 @@ int main (int argc, char *argv[])
if (df && (zf || (num1 && num2))) if (df && (zf || (num1 && num2)))
return checkZone(zf, df, num1, num2, verbose); return checkZone(zf, df, num1, num2, verbose);
if (df && num1) 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, "Usage:\n%s -d DBfile -v -V { -z Zonefile | num1 num2 }\n", basename(argv[0]));
fprintf(stderr, "\t-d DBfile -v -V num1\n"); fprintf(stderr, "\t-d DBfile -v -V num1\n");
return 0; return 0;

View File

@ -3,8 +3,10 @@
# #
# (C) 1999 l.toetsch <lt@toetsch.at> # (C) 1999 l.toetsch <lt@toetsch.at>
# #
BZIP2 = @BZIP2@
BZIP2 = @BZIP2@
SHELL = /bin/sh SHELL = /bin/sh
CFLAGS = -Wall -g CFLAGS = -Wall -O2
INCLUDES = INCLUDES =
LDFLAGS = @DBMLIB@ LDFLAGS = @DBMLIB@
DBEXT = @DBEXT@ DBEXT = @DBEXT@
@ -71,17 +73,21 @@ distclean: clean
rm -f config.h config.status config.cache config.log *.man Makefile rm -f config.h config.status config.cache config.log *.man Makefile
test: test:
./$(PROGRAM) -d uta$(DBEXT) -r at/uta/zred.uta -c at/code -v ./$(PROGRAM) -d zone-at-pta$(DBEXT) -r at/pta/zred.pta -c at/code -v
./zone -d uta$(RDBEXT) -z at/uta/zoneall.uta -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: zonefiles:
./$(PROGRAM) -d ../../zone-at-1012$(DBEXT) -r at/1012/zred-at-1012 -c at/code -v -l4 ./$(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 ./$(PROGRAM) -d ../../zone-at-uta$(DBEXT) -r at/uta/zred.uta -c at/code -v
bzip2 -9 at/uta/zred.uta $(BZIP2) -9 at/uta/zred.uta
bzip2 -d at/pta/zred.pta.bz2 $(BZIP2) -d at/pta/zred.pta.bz2
./$(PROGRAM) -d ../../zone-at-pta$(DBEXT) -r at/pta/zred.pta -c at/code -v ./$(PROGRAM) -d ../../zone-at-pta$(DBEXT) -r at/pta/zred.pta -c at/code -v
bzip2 -9 at/pta/zred.pta $(BZIP2) -9 at/pta/zred.pta
bzip2 -d de/01033/zred.dtag.bz2 $(BZIP2) -d de/01033/zred.dtag.bz2
./$(PROGRAM) -d ../../zone-de-dtag$(DBEXT) -r de/01033/zred.dtag -c de/code -v ./$(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

View File

@ -86,7 +86,7 @@ sub min {
return $_[0] < $_[1] ? $_[0] : $_[1]; return $_[0] < $_[1] ? $_[0] : $_[1];
} }
sub read_compact { sub read_compact {
my ($from,$to,$z,$n); my ($from,$to,$z,$n, $cc);
print "Reading $reducedf...\n" if($verbose); print "Reading $reducedf...\n" if($verbose);
if (!$dbm) { if (!$dbm) {
open(IN, $reducedf) || die("Can't read $reducedf"); open(IN, $reducedf) || die("Can't read $reducedf");
@ -112,6 +112,7 @@ sub read_compact {
$pack_table = $1 if(/C(\w)/); $pack_table = $1 if(/C(\w)/);
$n = $1 if(/N(\d+)/); $n = $1 if(/N(\d+)/);
$t = $1 if(/T(\d+)/); $t = $1 if(/T(\d+)/);
$cc = $1 if(/A(\d+)/);
} }
my($bnum) = $db{"_tAbLe\x0"}; my($bnum) = $db{"_tAbLe\x0"};
my %len = ('C' => 1, 'S' => 2, 'L' => 4); 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"); next if ($key eq "_tAbLe\x0" || $key eq "vErSiO\x0");
my($temp) = unpack($pack_key, $key); my($temp) = unpack($pack_key, $key);
next if( $temp !~ /\d/); next if( $temp !~ /\d/);
if ($cc) {
my($ind); my($ind);
my($ort) = substr($value,0, $ind=index($value, "\x0")); my($ort) = substr($value,0, $ind=index($value, "\x0"));
$value = substr($value, $ind+1); $value = substr($value, $ind+1);
}
my($count) = unpack('S', $value); my($count) = unpack('S', $value);
$value=substr($value, 2); # past count $value=substr($value, 2); # past count
while ($count--) { while ($count--) {

View File

@ -774,9 +774,42 @@ test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' 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 $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_%'` ac_lib_var=`echo gdbm'_'gdbm_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -784,7 +817,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-lgdbm $LIBS" LIBS="-lgdbm $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 788 "configure" #line 821 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -795,7 +828,7 @@ int main() {
gdbm_open() gdbm_open()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:799: \"$ac_link\") 1>&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* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -817,7 +850,7 @@ EOF
else else
echo "$ac_t""no" 1>&6 echo "$ac_t""no" 1>&6
echo $ac_n "checking for dbm_open in -ldbm""... $ac_c" 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_%'` ac_lib_var=`echo dbm'_'dbm_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -825,7 +858,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-ldbm $LIBS" LIBS="-ldbm $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 829 "configure" #line 862 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -836,7 +869,7 @@ int main() {
dbm_open() dbm_open()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:840: \"$ac_link\") 1>&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* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -858,7 +891,7 @@ EOF
else else
echo "$ac_t""no" 1>&6 echo "$ac_t""no" 1>&6
echo $ac_n "checking for dbm_open in -ldb""... $ac_c" 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_%'` ac_lib_var=`echo db'_'dbm_open | sed 'y%./+-%__p_%'`
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
@ -866,7 +899,7 @@ else
ac_save_LIBS="$LIBS" ac_save_LIBS="$LIBS"
LIBS="-ldb $LIBS" LIBS="-ldb $LIBS"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 870 "configure" #line 903 "configure"
#include "confdefs.h" #include "confdefs.h"
/* Override any gcc2 internal prototype to avoid an error. */ /* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2 /* We use char because int might match the return type of a gcc2
@ -877,7 +910,7 @@ int main() {
dbm_open() dbm_open()
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:881: \"$ac_link\") 1>&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* rm -rf conftest*
eval "ac_cv_lib_$ac_lib_var=yes" eval "ac_cv_lib_$ac_lib_var=yes"
else else
@ -907,7 +940,7 @@ fi
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 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. # On Suns, sometimes $CPP names a directory.
if test -n "$CPP" && test -d "$CPP"; then if test -n "$CPP" && test -d "$CPP"; then
CPP= CPP=
@ -922,13 +955,13 @@ else
# On the NeXT, cc -E runs the code through the compiler's parser, # On the NeXT, cc -E runs the code through the compiler's parser,
# not just through cpp. # not just through cpp.
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 926 "configure" #line 959 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <assert.h> #include <assert.h>
Syntax Error Syntax Error
EOF EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 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` ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then if test -z "$ac_err"; then
: :
@ -939,13 +972,13 @@ else
rm -rf conftest* rm -rf conftest*
CPP="${CC-cc} -E -traditional-cpp" CPP="${CC-cc} -E -traditional-cpp"
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 943 "configure" #line 976 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <assert.h> #include <assert.h>
Syntax Error Syntax Error
EOF EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 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` ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then if test -z "$ac_err"; then
: :
@ -968,12 +1001,12 @@ fi
echo "$ac_t""$CPP" 1>&6 echo "$ac_t""$CPP" 1>&6
echo $ac_n "checking for ANSI C header files""... $ac_c" 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 if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 977 "configure" #line 1010 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <stdlib.h> #include <stdlib.h>
#include <stdarg.h> #include <stdarg.h>
@ -981,7 +1014,7 @@ else
#include <float.h> #include <float.h>
EOF EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 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` ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then if test -z "$ac_err"; then
rm -rf conftest* rm -rf conftest*
@ -998,7 +1031,7 @@ rm -f conftest*
if test $ac_cv_header_stdc = yes; then if test $ac_cv_header_stdc = yes; then
# SunOS 4.x string.h does not declare mem*, contrary to ANSI. # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1002 "configure" #line 1035 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <string.h> #include <string.h>
EOF EOF
@ -1016,7 +1049,7 @@ fi
if test $ac_cv_header_stdc = yes; then if test $ac_cv_header_stdc = yes; then
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1020 "configure" #line 1053 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <stdlib.h> #include <stdlib.h>
EOF EOF
@ -1037,7 +1070,7 @@ if test "$cross_compiling" = yes; then
: :
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1041 "configure" #line 1074 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <ctype.h> #include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') #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); } exit (0); }
EOF 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 then
: :
else else
@ -1075,17 +1108,17 @@ for ac_hdr in unistd.h
do do
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'` ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1084 "configure" #line 1117 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <$ac_hdr> #include <$ac_hdr>
EOF EOF
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" 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` ac_err=`grep -v '^ *+' conftest.out`
if test -z "$ac_err"; then if test -z "$ac_err"; then
rm -rf conftest* rm -rf conftest*
@ -1113,12 +1146,12 @@ done
echo $ac_n "checking for size_t""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1122 "configure" #line 1155 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <sys/types.h> #include <sys/types.h>
#if STDC_HEADERS #if STDC_HEADERS
@ -1147,7 +1180,7 @@ fi
echo $ac_n "checking size of char""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_sizeof_char'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1155,7 +1188,7 @@ else
ac_cv_sizeof_char=1 ac_cv_sizeof_char=1
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1159 "configure" #line 1192 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <stdio.h> #include <stdio.h>
main() main()
@ -1166,7 +1199,7 @@ main()
exit(0); exit(0);
} }
EOF 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 then
ac_cv_sizeof_char=`cat conftestval` ac_cv_sizeof_char=`cat conftestval`
else else
@ -1186,7 +1219,7 @@ EOF
echo $ac_n "checking size of short""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_sizeof_short'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1194,7 +1227,7 @@ else
ac_cv_sizeof_short=2 ac_cv_sizeof_short=2
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1198 "configure" #line 1231 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <stdio.h> #include <stdio.h>
main() main()
@ -1205,7 +1238,7 @@ main()
exit(0); exit(0);
} }
EOF 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 then
ac_cv_sizeof_short=`cat conftestval` ac_cv_sizeof_short=`cat conftestval`
else else
@ -1225,7 +1258,7 @@ EOF
echo $ac_n "checking size of long""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_sizeof_long'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1233,7 +1266,7 @@ else
ac_cv_sizeof_long=4 ac_cv_sizeof_long=4
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1237 "configure" #line 1270 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <stdio.h> #include <stdio.h>
main() main()
@ -1244,7 +1277,7 @@ main()
exit(0); exit(0);
} }
EOF 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 then
ac_cv_sizeof_long=`cat conftestval` ac_cv_sizeof_long=`cat conftestval`
else else
@ -1264,7 +1297,7 @@ EOF
echo $ac_n "checking size of int""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_sizeof_int'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
@ -1272,7 +1305,7 @@ else
ac_cv_sizeof_int=4 ac_cv_sizeof_int=4
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1276 "configure" #line 1309 "configure"
#include "confdefs.h" #include "confdefs.h"
#include <stdio.h> #include <stdio.h>
main() main()
@ -1283,7 +1316,7 @@ main()
exit(0); exit(0);
} }
EOF 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 then
ac_cv_sizeof_int=`cat conftestval` ac_cv_sizeof_int=`cat conftestval`
else else
@ -1306,12 +1339,12 @@ EOF
for ac_func in strdup strtoul for ac_func in strdup strtoul
do do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 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 if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6 echo $ac_n "(cached) $ac_c" 1>&6
else else
cat > conftest.$ac_ext <<EOF cat > conftest.$ac_ext <<EOF
#line 1315 "configure" #line 1348 "configure"
#include "confdefs.h" #include "confdefs.h"
/* System header to define __stub macros and hopefully few prototypes, /* System header to define __stub macros and hopefully few prototypes,
which can conflict with char $ac_func(); below. */ which can conflict with char $ac_func(); below. */
@ -1334,7 +1367,7 @@ $ac_func();
; return 0; } ; return 0; }
EOF EOF
if { (eval echo configure:1338: \"$ac_link\") 1>&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* rm -rf conftest*
eval "ac_cv_func_$ac_func=yes" eval "ac_cv_func_$ac_func=yes"
else else
@ -1501,6 +1534,7 @@ s%@mandir@%$mandir%g
s%@CC@%$CC%g s%@CC@%$CC%g
s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g
s%@INSTALL_DATA@%$INSTALL_DATA%g s%@INSTALL_DATA@%$INSTALL_DATA%g
s%@BZIP2@%$BZIP2%g
s%@CPP@%$CPP%g s%@CPP@%$CPP%g
s%@DBMLIB@%$DBMLIB%g s%@DBMLIB@%$DBMLIB%g
s%@DBEXT@%$DBEXT%g s%@DBEXT@%$DBEXT%g

View File

@ -9,6 +9,7 @@ CONFIG_SBINDIR=`eval echo ${CONFIG_SBINDIR:-"/sbin"}`
dnl Checks for programs. dnl Checks for programs.
AC_PROG_CC AC_PROG_CC
AC_PROG_INSTALL AC_PROG_INSTALL
AC_CHECK_PROGS(BZIP2, bzip2)
dnl Checks for libraries. dnl Checks for libraries.
dnl Berkeley DB appends RDBEXT dnl Berkeley DB appends RDBEXT

View File

@ -33,7 +33,7 @@ sub min {
return $_[0] < $_[1] ? $_[0] : $_[1]; return $_[0] < $_[1] ? $_[0] : $_[1];
} }
sub read_compact { sub read_compact {
my ($from,$to,$z,$n); my ($from,$to,$z,$n, $cc);
$verbose=3; $verbose=3;
print "Reading $reducedf...\n" if($verbose); print "Reading $reducedf...\n" if($verbose);
@ -49,6 +49,7 @@ sub read_compact {
$pack_table = $1 if(/C(\w)/); $pack_table = $1 if(/C(\w)/);
$n = $1 if(/N(\d+)/); $n = $1 if(/N(\d+)/);
$t = $1 if(/T(\d+)/); $t = $1 if(/T(\d+)/);
$cc = $1 if(/A(\d+)/);
} }
my($bnum) = $db{"_tAbLe\x0"}; my($bnum) = $db{"_tAbLe\x0"};
my %len = ('C' => 1, 'S' => 2, 'L' => 4); 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"); next if ($key eq "_tAbLe\x0" || $key eq "vErSiO\x0");
my($temp) = unpack($pack_key, $key); my($temp) = unpack($pack_key, $key);
next if( $temp !~ /\d/); next if( $temp !~ /\d/);
if ($cc) {
my($ind); my($ind);
my($ort) = substr($value,0, $ind=index($value, "\x0")); my($ort) = substr($value,0, $ind=index($value, "\x0"));
print "$temp $ort\n"; print "$temp $ort\n";
$value = substr($value, $ind+1); $value = substr($value, $ind+1);
}
my($count) = unpack('S', $value); my($count) = unpack('S', $value);
$value=substr($value, 2); # past count $value=substr($value, 2); # past count
while ($count--) { while ($count--) {

View File

@ -4,7 +4,7 @@
* Copyright 1999 by Leopold Toetsch <lt@toetsch.at> * Copyright 1999 by Leopold Toetsch <lt@toetsch.at>
* *
* SYNOPSIS * 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 * 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 * 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 */ /* first char must match dataversion */
@ -75,7 +75,6 @@ static int numlen;
static void read_codefile(char *cf) { static void read_codefile(char *cf) {
FILE *fp; FILE *fp;
int l, llen = 0;
char *p; char *p;
auto char line[BUFSIZ]; auto char line[BUFSIZ];
@ -87,14 +86,13 @@ static void read_codefile(char *cf) {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
maxnum = 0; maxnum = 0;
while (!feof(fp)) { while (fgets(line, BUFSIZ, fp)) {
if (verbose && (nc % 1000) == 0) { if (verbose && (nc % 1000) == 0) {
printf("%d\r", nc); printf("%d\r", nc);
fflush(stdout); fflush(stdout);
} }
fgets(line, BUFSIZ, fp);
if (!isdigit(*line)) if (!isdigit(*line))
continue; break;
line[strlen(line)-1] = '\0'; line[strlen(line)-1] = '\0';
if ((codes=realloc(codes, (nc+1)*sizeof(code_t))) == 0) { if ((codes=realloc(codes, (nc+1)*sizeof(code_t))) == 0) {
fprintf(stderr, "Out of mem\n"); fprintf(stderr, "Out of mem\n");
@ -118,7 +116,7 @@ static void read_codefile(char *cf) {
fflush(stdout); fflush(stdout);
} }
fclose(fp); 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) { if ((codes=realloc(codes, (nc+1)*sizeof(code_t))) == 0) {
fprintf(stderr, "Out of mem\n"); fprintf(stderr, "Out of mem\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@ -131,8 +129,6 @@ static void read_codefile(char *cf) {
static void read_rzfile(char *rf) { static void read_rzfile(char *rf) {
int i; int i;
char line[BUFSIZ], *p, *op; char line[BUFSIZ], *p, *op;
size_t llen, l;
FILE *fp; FILE *fp;
int from,to,z; int from,to,z;
@ -140,30 +136,24 @@ static void read_rzfile(char *rf) {
fprintf(stderr, "Coudn't read '%s'\n", rf); fprintf(stderr, "Coudn't read '%s'\n", rf);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
llen=40;
n=0;
zones = 0;
if ((numbers = calloc(maxnum+1, sizeof(int))) == 0) { if ((numbers = calloc(maxnum+1, sizeof(int))) == 0) {
fprintf(stderr, "Out of mem\n"); fprintf(stderr, "Out of mem\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
i=keylen=keydigs=0; n=i=keylen=keydigs=0;
if (verbose) if (verbose)
printf("Reading %s\n", rf); printf("Reading %s\n", rf);
while (!feof(fp)) { while (fgets(line, BUFSIZ, fp)) {
if (verbose && (n % 1000) == 0) { if (verbose && (n % 1000) == 0) {
printf("%d\r", n); printf("%d\r", n);
fflush(stdout); fflush(stdout);
} }
fgets(line, BUFSIZ, fp); if (!*line)
l = strlen(line);
if (!l || l == -1 || !*line)
break; break;
if (l>40) if (strlen(line)>40)
fprintf(stderr, "Possible junk in line %d", n); fprintf(stderr, "Possible junk in line %d", n);
p = line; from = strtoul(line, &p, 10);
from = strtoul(p, &p, 10);
if (p-line > keydigs) if (p-line > keydigs)
keydigs=p-line; keydigs=p-line;
p++; p++;
@ -194,6 +184,7 @@ static void read_rzfile(char *rf) {
free(rf); free(rf);
} }
/* get the 256 top used nums in table */
static void make_table() { static void make_table() {
int i, j, k; int i, j, k;
tablelen = 0; tablelen = 0;
@ -253,8 +244,16 @@ static void write_remaining_codes(_DB db) {
US kus; US kus;
datum key, value; datum key, value;
char *val; char *val;
if (verbose)
printf("Writing remaining\n");
for (i=0 ; i< nc; i++) for (i=0 ; i< nc; i++)
if (codes[i].num > 0 && *codes[i].code) { if (codes[i].num > 0 && *codes[i].code) {
if (verbose && (i % 1000) == 0) {
printf("%d\r", i);
fflush(stdout);
}
if (keylen == 4) { if (keylen == 4) {
kul = (UL)codes[i].num; kul = (UL)codes[i].num;
key.dptr = (char*)&kul; key.dptr = (char*)&kul;
@ -271,7 +270,7 @@ static void write_remaining_codes(_DB db) {
value.dsize = l; value.dsize = l;
if(STORE(db, key, value)) { if(STORE(db, key, value)) {
fprintf(stderr, "Error storing key '%d' - %s\n",codes[i].num,GET_ERR); fprintf(stderr, "Error storing key '%d' - %s\n",codes[i].num,GET_ERR);
/* exit(EXIT_FAILURE); */ exit(EXIT_FAILURE);
} }
free(val); free(val);
} }
@ -309,7 +308,10 @@ static void write_db(char * df) {
nn,n, ortszone, numlen?numlen:keydigs); nn,n, ortszone, numlen?numlen:keydigs);
value.dptr = version; value.dptr = version;
value.dsize = strlen(version)+1; 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) { if ((p = val = calloc(nn, tablelen)) == 0) {
fprintf(stderr, "Out of mem\n"); fprintf(stderr, "Out of mem\n");
@ -326,11 +328,14 @@ static void write_db(char * df) {
*((UL*)p)++ = (UL)table[i]; *((UL*)p)++ = (UL)table[i];
value.dptr = val; value.dptr = val;
value.dsize = nn*tablelen; 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); free(val);
/* and write data */ /* and write data */
val = malloc(2); /* size */ val = malloc(2); /* size of count */
vlen = 2; vlen = 2;
ofrom = -1; ofrom = -1;
count = 0; count = 0;
@ -351,7 +356,7 @@ static void write_db(char * df) {
fprintf(stderr, "Error storing key '%d' - %s\n",ofrom,GET_ERR); fprintf(stderr, "Error storing key '%d' - %s\n",ofrom,GET_ERR);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
free(val); free(value.dptr); /* the realloced val */
} }
if (ofrom != zones[i][0]) { if (ofrom != zones[i][0]) {
count = 0; count = 0;
@ -404,7 +409,7 @@ static void write_db(char * df) {
value.dsize = vlen; value.dsize = vlen;
insert_code(&value, ofrom); insert_code(&value, ofrom);
STORE(db, key, value); STORE(db, key, value);
free(val); free(value.dptr);
write_remaining_codes(db); write_remaining_codes(db);
CLOSE(db); CLOSE(db);
free(zones); free(zones);
@ -437,12 +442,9 @@ int main (int argc, char *argv[])
} }
read_codefile(cf); read_codefile(cf);
read_rzfile(rf); read_rzfile(rf);
/* make table of 256 maxused to's */
make_table(); make_table();
write_db(df); write_db(df);
/* Uff this got longer as I thought, /* Uff this got longer as I thought,
C is a real low level language - C is a real low level language -
now it's clear, why I prefer Perl now it's clear, why I prefer Perl

View File

@ -59,11 +59,16 @@ compzone { -z<CITE>Zonefile</CITE> | -r<CITE>Reducedfile</CITE> } -c<CITE>Codefi
<H2><A NAME="mkzonedb">mkzonedb</A></H2> <H2><A NAME="mkzonedb">mkzonedb</A></H2>
<P>Makes a zonedatabase (gdbm - GNU Database or db - Berkeley DB) from a reduced file.</P> <P>Makes a zonedatabase (gdbm - GNU Database or db - Berkeley DB) from a reduced file.</P>
<H3>Synopsis</H3> <H3>Synopsis</H3>
<PRE>./mkzonedb -d <CITE>zone-CC-PP.gdbm</CITE> -r <CITE>ReducedFile</CITE> -c Codefile [ -v<CITE>Verboselevel</CITE> ] [ -o Localzone ] [ -l Len ]</PRE> <PRE>./mkzonedb -d <CITE>zone-CC-PP.gdbm</CITE> -r <CITE>ReducedFile</CITE> -c Codefile [-a CC ] [ -v<CITE>Verboselevel</CITE> ] [ -o Localzone ] [ -l Len ]</PRE>
<H3>Options</H3> <H3>Options</H3>
<PRE>-r <CITE>ReducedFile</CITE> ... reduced zone file from <STRONG>redzone</STRONG> <PRE>-r <CITE>ReducedFile</CITE> ... reduced zone file from <STRONG>redzone</STRONG>
-d <CITE>zone-CC-PP.gdbm</CITE> ...CC = Iso-Countrycode, PP = Providername/number<BR>-c <CITE>Codefile</CITE><BR>-v Verboselevel ... default = 1<BR>-o Localzone ... default = 1<BR>-l Len ... default = maxlen of data</PRE> -d <CITE>zone-CC-PP.gdbm</CITE> ...CC = Iso-Countrycode, PP = Providername/number
-c <CITE>Codefile</CITE>
-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)</PRE>
<P>For examples look at the <TT>Makefile</TT> in target <TT>zonefiles</TT>.</P> <P>For examples look at the <TT>Makefile</TT> in target <TT>zonefiles</TT>.</P>
<H2><A NAME="zone">zone</A></H2> <H2><A NAME="zone">zone</A></H2>
@ -71,7 +76,7 @@ compzone { -z<CITE>Zonefile</CITE> | -r<CITE>Reducedfile</CITE> } -c<CITE>Codefi
<PRE>zone -d <CITE>Datafile</CITE> [ -v ] [ -V ] { -z <CITE>zonefile</CITE> | num1 num2 }</PRE> <PRE>zone -d <CITE>Datafile</CITE> [ -v ] [ -V ] { -z <CITE>zonefile</CITE> | num1 num2 }</PRE>
<P>or</P> <P>or</P>
<PRE>zone -d <CITE>Datafile</CITE> [ -v ] [ -V ] num1 </PRE> <PRE>zone -d <CITE>Datafile</CITE> [ -v ] [ -V ] -a CC num1 </PRE>
<H3>Options</H3> <H3>Options</H3>
<PRE>-v ... verbose <PRE>-v ... verbose
@ -81,7 +86,7 @@ compzone { -z<CITE>Zonefile</CITE> | -r<CITE>Reducedfile</CITE> } -c<CITE>Codefi
<PRE>cc -DSTANDALONE -o zone zone.c -lgdbm</PRE> <PRE>cc -DSTANDALONE -o zone zone.c -lgdbm</PRE>
<H3>I4L-Interface:</H3> <H3>I4L-Interface:</H3>
<PRE>int initZone(int provider, char *datapath, char **msg)<BR> returns -1 on error, 0 if ok<BR>void exitZone(int provider)<BR>int getZone(int provider, char *from, char *to)<BR> returns -2 on error, UNKNOWN on not found, zone if ok<BR>int getAreacode(int provider, char *num, char **text)<BR> returns UNKNOWN if not found, or len of areacode<BR> text is a malloced string containing the name of the area <PRE>int initZone(int provider, char *datapath, char **msg)<BR> returns -1 on error, 0 if ok<BR>void exitZone(int provider)<BR>int getZone(int provider, char *from, char *to)<BR> returns -2 on error, UNKNOWN on not found, zone if ok<BR>int getAreacode(int country, char *num, char **text)<BR> returns UNKNOWN if not found, or len of areacode<BR> text is a malloced string containing the name of the area
the caller should free this text.</PRE> the caller should free this text.</PRE>
<H2>Glossary</H2> <H2>Glossary</H2>
@ -95,12 +100,12 @@ then <TT>from</TT>.</P>
1 2253 1 1 2253 1
...</PRE> ...</PRE>
<P>It has (N*N-1)/2 entries.</P> <P>It has N*(N-1)/2 entries.</P>
<H4><A NAME="redf">Reducedfile</A></H4> <H4><A NAME="redf">Reducedfile</A></H4>
<P>A Zonefile with wildcards. It must be read top down to get correct rsults. The first matching entry is the right <P>A Zonefile with wildcards. It must be read top down to get correct rsults. The first matching entry is the right
one.</P> one.</P>
<PRE> <PRE>
1 0252 1 1 252 1
... ...
2252 228 1 2252 228 1
2252 22 0 2252 22 0
@ -116,12 +121,12 @@ one.</P>
<P>The line with zone 127 is a link to the zone-info 2252, so there are theoretical maximum of 126 zones.</P> <P>The line with zone 127 is a link to the zone-info 2252, so there are theoretical maximum of 126 zones.</P>
<H4><A NAME="codef">Codefile</A></H4> <H4><A NAME="codef">Codefile</A></H4>
<P>File of lines of all tel numbers.</P> <P>File of lines of all tel numbers and cits, separated by &lt;tab&gt;s</P>
<PRE>1 <PRE>1 Wien
2142 2142 Gattendorf
2143 2143 Berg
... ...
2252 2252 Baden b Wien
...</PRE> ...</PRE>
<H2>Author</H2> <H2>Author</H2>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.