isdnlog Version 3.31

- Release 0.91 of zone-Database (aka "Verzonungstabelle")
 - "rate-de.dat" V:1.02-Germany [09-Jun-1999 21:45:26]
This commit is contained in:
akool 1999-06-09 19:57:22 +00:00
parent cca6d0fdea
commit fd500ff8b0
14 changed files with 2110 additions and 688 deletions

View File

@ -1,4 +1,4 @@
## $Id: Makefile.in,v 1.83 1999/06/03 18:49:36 akool Exp $
## $Id: Makefile.in,v 1.84 1999/06/09 19:57:22 akool Exp $
##
## ISDN accounting for isdn4linux.
##
@ -19,6 +19,11 @@
## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
##
## $Log: Makefile.in,v $
## Revision 1.84 1999/06/09 19:57:22 akool
## isdnlog Version 3.31
## - Release 0.91 of zone-Database (aka "Verzonungstabelle")
## - "rate-de.dat" V:1.02-Germany [09-Jun-1999 21:45:26]
##
## Revision 1.83 1999/06/03 18:49:36 akool
## isdnlog Version 3.30
## - rate-de.dat V:1.02-Germany [03-Jun-1999 19:49:22]
@ -665,7 +670,7 @@ SERVICEFILE = /etc/services
# DON'T EDIT BELOW THIS LINE
######################################################################
VERSION = 3.30
VERSION = 3.31
MANPAGES = isdnlog/callerid.conf.5 isdnlog/isdn.conf.5 \
isdnlog/isdnformat.5 isdnlog/isdnlog.5 isdnlog/isdnlog.8 \

View File

@ -1,6 +1,6 @@
V:1.02-Germany [01-Jun-1999 20:52:35]
# $Id: countries-de.dat,v 1.7 1999/06/03 18:49:39 akool Exp $
# $Id: countries-de.dat,v 1.8 1999/06/09 19:57:25 akool Exp $
#
+999:DUMMY
+998:Usbekistan:Uzbekistan

View File

@ -1,4 +1,4 @@
/* $Id: isdnconf.c,v 1.29 1999/06/03 18:50:10 akool Exp $
/* $Id: isdnconf.c,v 1.30 1999/06/09 19:58:12 akool Exp $
*
* ISDN accounting for isdn4linux. (Report-module)
*
@ -20,6 +20,11 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: isdnconf.c,v $
* Revision 1.30 1999/06/09 19:58:12 akool
* isdnlog Version 3.31
* - Release 0.91 of zone-Database (aka "Verzonungstabelle")
* - "rate-de.dat" V:1.02-Germany [09-Jun-1999 21:45:26]
*
* Revision 1.29 1999/06/03 18:50:10 akool
* isdnlog Version 3.30
* - rate-de.dat V:1.02-Germany [03-Jun-1999 19:49:22]
@ -978,6 +983,76 @@ retry:
} /* showLCR */
static void showWorld(int duration)
{
auto FILE *f = fopen("/usr/lib/isdn/countries.dat", "r");
auto char s[BUFSIZ], areacode[BUFSIZ];
auto int provider;
register int n;
register char *p;
auto RATE Rate;
auto char *msg;
if (f != (FILE *)NULL) {
while (fgets(s, BUFSIZ, f)) {
if (p = strchr(s, '\n'))
*p = 0;
if (abroad(s, areacode)) {
memset(&Rate, 0, sizeof(Rate));
time(&Rate.start);
Rate.now = Rate.start + duration - ZAUNPFAHL;
n = 0;
for (Rate.prefix = 0; Rate.prefix < MAXPROVIDER; Rate.prefix++) {
Rate.zone = getZone(Rate.prefix, areacode);
if (Rate.zone != UNKNOWN) {
time(&Rate.start);
Rate.now = Rate.start + duration - ZAUNPFAHL;
if (getRate(&Rate, &msg) != UNKNOWN) {
sort[n].prefix = Rate.prefix;
sort[n].rate = Rate.Charge;
sort[n].msg = strdup(msg);
sort[n].explain = strdup(printrate(Rate));
n++;
} /* if */
#if 0
if (provider = getLeastCost(&Rate, UNKNOWN)) {
print_msg(PRT_NORMAL, "%-50s %s %s%d:%s (%s)\n",
s, areacode, vbn, provider, getProvidername(provider), explainRate(&Rate));
break;
} /* if */
#endif
} /* if */
} /* for */
if (n > 0) {
qsort((void *)sort, n, sizeof(SORT), compare);
print_msg(PRT_NORMAL, "%-46s %-9s %s%d:%s (%s)\n",
s, areacode, vbn, sort[0].prefix,
getProvidername(sort[0].prefix), sort[0].explain);
} /* if */
}
else
print_msg(PRT_NORMAL, "%-50s UNKNOWN\n", s);
} /* while */
fclose(f);
} /* if */
} /* showWorld */
int main(int argc, char *argv[], char *envp[])
{
int c, n = 0;
@ -1174,6 +1249,10 @@ int main(int argc, char *argv[], char *envp[])
exit(0);
} /* else */
}
else if (*areacode == '*') {
showWorld(duration);
exit(0);
}
else {
if (isalpha(*areacode)) {
if (abroad(areacode, country))

View File

@ -1,4 +1,4 @@
/* $Id: processor.c,v 1.64 1999/06/03 18:50:33 akool Exp $
/* $Id: processor.c,v 1.65 1999/06/09 19:58:26 akool Exp $
*
* ISDN accounting for isdn4linux. (log-module)
*
@ -19,6 +19,11 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: processor.c,v $
* Revision 1.65 1999/06/09 19:58:26 akool
* isdnlog Version 3.31
* - Release 0.91 of zone-Database (aka "Verzonungstabelle")
* - "rate-de.dat" V:1.02-Germany [09-Jun-1999 21:45:26]
*
* Revision 1.64 1999/06/03 18:50:33 akool
* isdnlog Version 3.30
* - rate-de.dat V:1.02-Germany [03-Jun-1999 19:49:22]
@ -697,6 +702,7 @@
#define _PROCESSOR_C_
#include "isdnlog.h"
#include "sys/times.h"
#include "asn1.h"
static int HiSax = 0, hexSeen = 0, uid = UNKNOWN, lfd = 0;
@ -2797,7 +2803,7 @@ static void huptime(int chan, int setup)
auto int oldchargeint = 0, newchargeint = 0;
auto int oldhuptimeout, newhuptimeout;
auto char sx[BUFSIZ], why[BUFSIZ];
#if LCR
#if LCRtest
auto char n[1024], n1[1024];
auto union p {
isdn_net_ioctl_phone phone;
@ -2821,7 +2827,7 @@ static void huptime(int chan, int setup)
#endif
call[chan].huptimeout = oldhuptimeout = cfg.onhtime;
#if LCR
#if LCRtest
if (setup) {
strcpy(ph.phone.name, known[c]->interface);
ph.phone.outgoing = 1;
@ -3636,6 +3642,50 @@ static void prepareRate(int chan, char **msg, char **tip, int viarep)
} /* prepareRate */
static void LCR(int chan, char *s)
{
auto char *why, *hint;
auto struct tms t1, t2;
auto long int tr1, tr2;
tr1 = times(&t1);
print_msg(PRT_NORMAL, ">> LCR: OUTGOING SETUP(%s)\n", s + 5);
print_msg(PRT_NORMAL, ">> LCR: from TEI %d, to number \"%s\", Provider=%s%d:%s, Sonderrufnummer=%d, InternalCall=%d, LocalCall=%d\n",
call[chan].tei, call[chan].num[CALLED], vbn, call[chan].provider, getProvidername(call[chan].provider),
call[chan].sondernummer[CALLED], call[chan].intern[CALLED], call[chan].local[CALLED]);
if (!call[chan].intern[CALLED]) { /* keine Hausinternen Gespr„che */
if (!call[chan].local[CALLED]) { /* keine Ortsgespr„che */
if (call[chan].sondernummer[CALLED] == UNKNOWN) { /* keine Sonderrufnummern */
call[chan].disconnect = call[chan].connect = cur_time;
prepareRate(chan, &why, &hint, 0);
if (call[chan].hint == UNKNOWN)
print_msg(PRT_NORMAL, ">> LCR: NO ACTION: Better provider unknown :-(\n", why);
else if (call[chan].hint == call[chan].provider)
print_msg(PRT_NORMAL, ">> LCR: Best provider already used!", why);
else {
print_msg(PRT_NORMAL, ">> LCR: %s\n", why);
print_msg(PRT_NORMAL, ">> LCR: %s\n", hint);
tr2 = times(&t2);
print_msg(PRT_NORMAL, ">> LCR: FAKE! TRYING(%s%d0%s) - Time required: %8.6g s\n", vbn, call[chan].hint, call[chan].num[CALLED] + 3, (double)(tr2 - tr1) / (double)CLK_TCK);
} /* else */
}
else
print_msg(PRT_NORMAL, ">> LCR: NO ACTION: Sonderrufnummer\n");
}
else
print_msg(PRT_NORMAL, ">> LCR: NO ACTION: Local call\n");
}
else
print_msg(PRT_NORMAL, ">> LCR: NO ACTION: Internal call\n");
} /* LCR */
static void processctrl(int card, char *s)
{
register char *ps = s, *p;
@ -3957,6 +4007,11 @@ static void processctrl(int card, char *s)
call[chan].uid = ++uid;
decode(chan, ps, type, version, tei);
#if 0
if (OUTGOING && *call[chan].num[CALLED])
LCR(chan, s);
#endif
if (call[chan].channel) { /* Aha, Kanal war dabei, dann nehmen wir den gleich */
chan = call[chan].channel - 1;

View File

@ -1,4 +1,4 @@
/* $Id: isdnrep.c,v 1.66 1999/06/03 18:50:46 akool Exp $
/* $Id: isdnrep.c,v 1.67 1999/06/09 19:58:44 akool Exp $
*
* ISDN accounting for isdn4linux. (Report-module)
*
@ -24,6 +24,11 @@
*
*
* $Log: isdnrep.c,v $
* Revision 1.67 1999/06/09 19:58:44 akool
* isdnlog Version 3.31
* - Release 0.91 of zone-Database (aka "Verzonungstabelle")
* - "rate-de.dat" V:1.02-Germany [09-Jun-1999 21:45:26]
*
* Revision 1.66 1999/06/03 18:50:46 akool
* isdnlog Version 3.30
* - rate-de.dat V:1.02-Germany [03-Jun-1999 19:49:22]
@ -531,9 +536,6 @@
#include "../../vbox/src/libvbox.h"
#include "libisdn.h"
/*****************************************************************************/
#define getProvidername(x) "" /* FIXME */
/*****************************************************************************/
#define END_TIME 1
@ -906,10 +908,12 @@ int read_logfile(char *myname)
one_call cur_call;
/* initHoliday(holifile, NULL); FIXME */
/* initRate(rateconf, ratefile, NULL); FIXME */
interns0 = 3; /* FIXME */
/* FIXME: */
initHoliday(holifile, NULL);
initRate("/etc/isdn/rate.conf", "/usr/lib/isdn/rate-de.dat", "/usr/lib/isdn/countries-de.dat", NULL, NULL);
currency = strdup("DM");
vbn = strdup("010");
interns0 = 3;
msn_sum = calloc(mymsns + 1, sizeof(double));
usage_sum = calloc(mymsns + 1, sizeof(int));

File diff suppressed because it is too large Load Diff

View File

@ -7,15 +7,30 @@ P:20=99
# Dont use NetCologne
P:22=99
# Dont use tesion))
P:23=99
# Dont use CityKom
P:25=99
# Dont use Nordcom Butensurf
P:27=99
# Dont use Telebridge
P:28=99
# Dont use HanseNet
P:41=99
# Dont use TeleBeL
P:42=99
# Dont use VEW TELNET
P:44=99
# Dont use DOKOM
P:48=99
# Dont use ACC
P:49=99
@ -37,14 +52,17 @@ P:70=1
# 4=Nikocity Minutentakt
# 5=Nikocity Sekundentakt
# 6=C@llas Clever Communications
# dont use 98
P:98=99
# dont use Star
P:98=5
# Dont use Drillisch
P:150=99
# my LCR
P:11=99
P:13=99
P:40=99
#P:11=99
#P:13=99
#P:18=99
#P:19=99
#P:24=99
#P:40=99
#P:70=99

33
isdnlog/tools/Makefile Normal file
View File

@ -0,0 +1,33 @@
CC=gcc -m486 -O2 -pg -Wall -DSTANDALONE -I. -I.. -I../isdnlog
all: rate zone country holiday rate-at
rate: rate.u zone.u country.u holiday.u
${CC} -o rate rate.u country.u holiday.u
zone: zone.c zone.h
${CC} -DZONETEST -lgdbm -o zone zone.c
country: country.c country.h
${CC} -DCOUNTRYTEST -o country country.c
holiday: holiday.c holiday.h
${CC} -DHOLITEST -lm -o holiday holiday.c
rate-at: rate-at.c
${CC} -o rate-at rate-at.c
rate.u: rate.c rate.h holiday.h
${CC} -c -o rate.u rate.c
zone.u: zone.c zone.h
${CC} -c -o zone.u zone.c
country.u: country.c country.h
${CC} -c -o country.u country.c
holiday.u: holiday.c holiday.h
${CC} -c -o holiday.u holiday.c
clean:
rm -f rate holiday *.u *~

View File

@ -1,4 +1,4 @@
/* $Id: rate.c,v 1.19 1999/06/01 19:33:43 akool Exp $
/* $Id: rate.c,v 1.20 1999/06/09 19:59:20 akool Exp $
*
* Tarifdatenbank
*
@ -19,6 +19,11 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: rate.c,v $
* Revision 1.20 1999/06/09 19:59:20 akool
* isdnlog Version 3.31
* - Release 0.91 of zone-Database (aka "Verzonungstabelle")
* - "rate-de.dat" V:1.02-Germany [09-Jun-1999 21:45:26]
*
* Revision 1.19 1999/06/01 19:33:43 akool
* rate-de.dat V:1.02-Germany [01-Jun-1999 20:52:32]
*
@ -947,7 +952,7 @@ int initRate(char *conf, char *dat, char *countries, char **msg, char **cmsg)
if (isalpha(*c) && !countrymatch(c, NULL))
warning(dat, "Unknown country \"%s\"", c);
else if ((*c != '+') &&
(!zones->data ||
(!zones->data ||
((zones->data > 39) && (zones->data < 200)))) {
/* ^MICHI:
Anstelle dieser wuesten Abfrage auf die Zonen [0,5..10,20..99]

499
isdnlog/tools/zone.c Normal file
View File

@ -0,0 +1,499 @@
/*
* Zonenberechnung
*
* Copyright 1999 by Leopold Toetsch <lt@toetsch.at>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* Interface:
*
* int initZone(int provider, char *path, char **msg)
* initialize returns -1 on error, 0 if ok
*
* void exitZone(int provider)
* deinitialize
*
* int getZone(int provider, char *from, char *to)
* returns zone for provider, -1 on not found, -2 on error
*
*/
#define _ZONE_C_
#ifdef STANDALONE
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdarg.h>
#include <time.h>
#include <unistd.h>
#include <errno.h>
/* Fixme: basename() ist bei libc5 anscheinend nicht definiert
* könnte da mal jemand ein passende #ifdef herumstricken?
*/
extern const char *basename (const char *name);
#else
#include "isdnlog.h"
#include "tools.h"
#endif
#include <gdbm.h>
#include "zone.h"
struct sth {
GDBM_FILE fh;
char *path;
int provider;
int used;
int real;
int *table;
char pack_key, pack_table;
int table_size;
} ;
typedef unsigned char UC; /* len 1 */
typedef unsigned short US; /* len 2 */
typedef unsigned long UL; /* len 4 */
typedef enum {false,true} bool;
#define min(a,b) (a) < (b) ? (a) : (b)
static struct sth *sthp;
static int count;
static char version[] = "0.91";
#define LINK 127
#define INFO_LEN 80
#define LENGTH 120
#define BUFSIZE 200
#ifdef STANDALONE
#define UNKNOWN -1
#endif
static void warning (char *file, char *fmt, ...)
{
va_list ap;
char msg[BUFSIZ];
va_start (ap, fmt);
vsnprintf (msg, BUFSIZ, fmt, ap);
va_end (ap);
#ifdef STANDALONE
fprintf(stderr, "WARNING: %s %s\n", basename(file), msg);
#else
print_msg(PRT_NORMAL, "WARNING: %s %s\n", basename(file), msg);
#endif
}
void exitZone(int provider)
{
int i;
bool any = false;
bool found = false;
for (i=0; i<count; i++)
if (sthp[i].provider == provider) {
found = true;
if (sthp[i].real >= 0)
sthp[sthp[i].real].used--;
else if (sthp[i].path && sthp[i].used == 0) {
free(sthp[i].path);
sthp[i].path = 0;
free(sthp[i].table);
sthp[i].table = 0;
gdbm_close(sthp[i].fh);
sthp[i].fh = 0;
if (i == count-1) /* last released ? */
count--;
}
break;
}
if (!found) {
warning(sthp[i].path ? sthp[i].path : sthp[sthp[i].real].path,
"ExitZone for unknown provider %d", provider);
}
for (i=0; i<count; i++)
if (sthp[i].used || sthp[i].path) {
any=true;
break;
}
if (!any) {
free(sthp);
sthp = 0;
}
}
int initZone(int provider, char *path, char **msg)
{
int i;
static char message[LENGTH];
struct sth *newsthp;
bool found;
int ocount;
int csize=0, tsize=0, n;
datum key, value;
if (msg)
*(*msg=message)='\0';
if (!path || !*path) {
if (msg)
snprintf (message, LENGTH,
"Zone V%s: Error: no zone database specified!", version);
return -1;
}
ocount = count;
if (sthp == 0) {
if ((sthp = calloc(++count, sizeof(struct sth))) == 0) {
if (msg)
snprintf (message, LENGTH,
"Zone V%s: Error: Out of mem 0", version);
return -1;
}
}
else {
/* look if we can reuse some space */
found = false;
for (i=0; i<ocount; i++)
if (sthp[i].fh == 0) {
ocount = i;
found = true;
break;
}
if (!found) {
if ((newsthp = realloc(sthp, sizeof(struct sth) * ++count)) == 0) {
if (msg)
snprintf (message, LENGTH,
"Zone V%s: Error: Out of mem 1", version);
return -1;
}
sthp = newsthp;
}
}
sthp[ocount].path=0;
sthp[ocount].table=0;
sthp[ocount].used=0;
sthp[ocount].fh=0;
sthp[ocount].real = -1;
/* now search for same path */
found = false;
for (i=0; i<count-1; i++) {
if (sthp[i].path && strcmp(sthp[i].path, path) == 0) {
sthp[ocount].fh = sthp[i].fh;
sthp[ocount].pack_key = sthp[i].pack_key;
sthp[ocount].pack_table = sthp[i].pack_table;
sthp[ocount].table = sthp[i].table;
sthp[i].used++;
sthp[ocount].real = i;
found = true;
break;
}
}
sthp[ocount].provider = provider;
if (!found) {
char vinfo[] = "vErSiO";
char table[] = "_tAbLe";
char dversion[6];
char *p, *q;
*dversion = '\0';
if((sthp[ocount].path = strdup(path)) == 0) {
if (msg)
snprintf (message, LENGTH,
"Zone V%s: Error: Out of mem 2", version);
return -1;
}
if((sthp[ocount].fh = gdbm_open(path, 0, GDBM_READER, 0, 0)) == 0) {
if (msg)
snprintf (message, LENGTH,
"Zone V%s: Error: gdbm_open '%s': '%s'",
version, path, gdbm_strerror(gdbm_errno));
return -1;
}
/* read info */
key.dptr = vinfo;
key.dsize = 7;
value = gdbm_fetch(sthp[ocount].fh, key);
if (value.dptr == 0) {
if (msg)
snprintf (message, LENGTH,
"Zone V%s: Error: Provider %d File '%s': no Vinfo",
version, provider, path);
exitZone(provider);
return -1;
}
for (p=value.dptr; *p; p++) {
switch (*p) {
case 'V' :
for (p++,n=0,q=dversion; n<6 && *p != ' '; n++)
*q++ = *p++;
*q = '\0';
break;
case 'K' :
sthp[ocount].pack_key = *(++p);
break;
case 'C' :
sthp[ocount].pack_table = *(++p);
break;
case 'N' :
p++;
csize = strtol(p, &p, 10);
break;
case 'T' :
p++;
tsize = strtol(p, &p, 10);
break;
}
} /* for */
free (value.dptr);
/* check it */
if (strlen(dversion) == 0 ||
sthp[ocount].pack_key == '\x0' ||
strchr("SL", sthp[ocount].pack_key) == 0 ||
sthp[ocount].pack_table == '\x0' ||
strchr("CSL", sthp[ocount].pack_table) == 0 ||
csize == 0 ||
tsize == 0) {
if (msg)
snprintf (message, LENGTH,
"Zone V%s: Error: Provider %d File '%s' seems to be corrupted",
version, provider, path);
exitZone(provider);
return -1;
}
/* alloc & read table */
sthp[ocount].pack_table = sthp[ocount].pack_table == 'C' ? sizeof(char) :
sthp[ocount].pack_table == 'S' ? sizeof(short) : sizeof(long);
sthp[ocount].pack_key = sthp[ocount].pack_key == 'S' ? sizeof(short) : sizeof(long);
if ( (sthp[ocount].table = calloc(csize > 256 ? 256 : csize,
sizeof(int)) ) == 0) {
if (msg)
snprintf (message, LENGTH,
"Zone V%s: Error: Out of mem 3", version);
exitZone(provider);
return -1;
}
key.dptr = table;
key.dsize = 7;
value = gdbm_fetch(sthp[ocount].fh, key);
if (value.dptr == 0) {
if (msg)
snprintf (message, LENGTH,
"Zone V%s: Error: Provider %d File '%s': no NTable",
version, provider, path);
exitZone(provider);
return -1;
}
for (p = value.dptr, i=0; i< (csize > 256 ? 256 : csize); i++)
sthp[ocount].table[i] =
sthp[ocount].pack_table == 1 ? (int)(UC)*((UC*)p)++ :
sthp[ocount].pack_table == 2 ? (int)(US)*((US*)p)++ :
(int)(UL)*((UL*)p)++;
free(value.dptr);
if (msg) {
snprintf (message, LENGTH,
"Zone V%s: Provider %d File '%s' opened fine - "
"V%s K%d C%d N%d T%d",
version, provider, path,
dversion, sthp[ocount].pack_key, sthp[ocount].pack_table,
csize, tsize);
}
}
else {
if (msg)
snprintf (message, LENGTH,
"Zone V%s: Provider %d is open as '%s' for provider %d",
version, provider, path, sthp[sthp[ocount].real].provider);
}
return 0;
}
static int _getZ(struct sth *sthp, char *from, char *sto) {
GDBM_FILE fh = sthp->fh;
datum key, value;
static char newfrom[LENGTH];
bool found = false;
char *temp;
if (strcmp(from, sto) > 0) {
temp=from;
from=sto;
sto=temp;
}
strncpy(newfrom, from, LENGTH-1);
while (strlen(newfrom)) {
US ifrom = (US) atol(newfrom);
key.dptr = (char *) &ifrom;
key.dsize = sizeof(US);
value = gdbm_fetch(fh, key);
if (value.dptr) {
char *p = value.dptr;
char to[10];
US count;
int ito;
unsigned char z=0;
count = *((US*)p)++;
while (count--) {
bool ind = true;
int len=1;
z = *p++;
if (z >= 128) {
z -= 128;
ind = false;
len = sthp->pack_key;
}
ito = len==1 ? (int)*((UC*)p)++ :
len==2 ? (int)*((US*)p)++ : (int)*((UL*)p)++;
if (ind)
ito = sthp->table[ito];
if (z == LINK) {
sprintf(newfrom, "%d", ito);
free(value.dptr);
return _getZ(sthp, newfrom, sto);
}
else {
sprintf(to, "%d", ito);
if (memcmp(to, sto, strlen(to))==0) {
found = true;
break;
}
}
}
free(value.dptr);
if (found)
return z;
} /* if dptr */
newfrom[strlen(newfrom)-1] = '\0';
}
return -1;
}
int getZone(int provider, char *from, char *to)
{
int i;
char *path=NULL;
for (i=0; i<count; i++)
if (sthp[i].provider == provider) {
path = sthp[i].path ? sthp[i].path : sthp[sthp[i].real].path;
if (sthp[i].fh == 0)
return UNKNOWN;
return _getZ(&sthp[i], from, to);
}
return UNKNOWN;
}
#ifdef STANDALONE
static int checkZone(char *zf, char* df,int num1,int num2, bool verbose)
{
char *msg;
int z, ret=0;
char from[10];
char to[10];
if (initZone(1, df, &msg)) {
fprintf(stderr,"%s\n", msg);
exit(1);
}
if (num1 && num2) {
snprintf(from, 9, "%d",num1);
snprintf(to, 9, "%d",num2);
ret = getZone(1, from, to);
if (verbose)
printf("%s %s = %d\n", from, to, ret);
}
else {
FILE *fp;
char line[40];
char *p, *q;
int rz, i, n;
if ((fp = fopen(zf, "r")) == 0) {
fprintf(stderr, "Can't read %s\n", zf);
exitZone(1);
exit(1);
}
n=0;
while (!feof(fp)) {
if((++n % 1000) == 0 && verbose) {
fprintf(stderr,"%d\r",n);
fflush(stderr);
}
fgets(line, 39, fp);
p=line;
q=from;
if (!isdigit(*p))
continue;
i=0;
while (isdigit(*p) && ++i<9) {
*q++ = *p++;
}
*q = '\0';
p++;
q=to;
i=0;
while (isdigit(*p) && ++i<9) {
*q++ = *p++;
}
*q = '\0';
p++;
rz = atoi(p);
if ((z=getZone(1, from, to)) != rz) {
if(verbose)
printf("Err: %s %s = %d not %d\n", from, to, rz, z);
ret = -1;
break;
}
}
fclose(fp);
if (verbose)
printf("'%s' verified ok.\n", df);
}
exitZone(1);
return ret;
}
int main (int argc, char *argv[])
{
int verbose=false;
char *df=0;
char *zf=0;
int c;
int num1=0, num2=0;
while ( (c=getopt(argc, argv, "vVd:z:")) != 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;
}
}
while (optind < argc) {
if (!num1 && isdigit(*argv[optind])) {
num1 = atoi(argv[optind]);
optind++;
continue;
}
else if (!num2 && isdigit(*argv[optind])) {
num2 = atoi(argv[optind]);
optind++;
continue;
}
optind++;
}
if (df && (zf || (num1 && num2)))
return checkZone(zf, df, num1, num2, verbose);
fprintf(stderr, "Usage:\n%s -d DBfile -v -V { -z Zonefile | num1 num2 }\n", basename(argv[0]));
return 0;
}
#endif

37
isdnlog/tools/zone.h Normal file
View File

@ -0,0 +1,37 @@
/* $Id: zone.h,v 1.1 1999/06/09 19:59:23 akool Exp $
*
* Verzonungsberechnung
*
* Copyright 1999 by Leo Tötsch <lt@toetsch.at>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
* $Log: zone.h,v $
* Revision 1.1 1999/06/09 19:59:23 akool
* isdnlog Version 3.31
* - Release 0.91 of zone-Database (aka "Verzonungstabelle")
* - "rate-de.dat" V:1.02-Germany [09-Jun-1999 21:45:26]
*
*
*/
#ifndef _ZONE_H_
#define _ZONE_H_
int initZone (int provider, char *path, char **msg);
void exitZone (int provider);
int getZone (int provider, char *from, char *to);
#endif

BIN
isdnlog/zone-at-pta.gdbm Normal file

Binary file not shown.

BIN
isdnlog/zone-at-uta.gdbm Normal file

Binary file not shown.

BIN
isdnlog/zone-de-dtag.gdbm Normal file

Binary file not shown.