# Zoneutils

- redzone - Reduce a zonefile
- compzone - Compare/Verify zonefiles
- mkzonedb - Make a gdbm file from a reduced zonefile
- zone.c, zone - i4l-zonefuncs / Standalone zonefile verify

## redzone

redzone reduces a Zonefile by inserting wildcards. The reduction for AT is 99,5%, for DE 99,3%.

### Synopsis

    redzone -zZonefile -rReducedfile [ -vverboselevel ] [ -n ] [ -llen ] [ -k ] [ -o ]

### Options

    -zZonefile
    -rReducedfile
    -vverboselevel ... default=1
    -n ... Normalize input (i.e. sort ascending)
    -llen ... a number is maximal len long, default=4
    -k ... keep intermediate files
    -o ... optimize only (this is the last pass)

## compzone

Verifys a Reducedfile against a Zonefile or a Zonefile against a Codefile or querys the zone of two numbers.

### Synopsis

    compzone -zZonefile -rReducedfile[-vVerboselevel ] [ -m[2] ] [-h ] -a [ -d ]
    compzone -zZonefile -rReducedfile[-vVerboselevel ] [ -m[2] ] from to [ -d ]
    compzone { -zZonefile | -rReducedfile } -cCodefile [-vVerboselevel ] [ -h ] [ -m[2] ]\

### Options

    -zZonefile
    -rReducedfile
    -vVerboselevel default=1, 2 prints also the steps for searching the Reducedfile
    -m ... Read reduced file into memory
    -m2 ... Also read zonefile (!!) into memory
    -h ... halt on errors
    -a ... auto, test all
    -d ... the reduced file is a GDBM-file
    -cCodefile

### Examples

    ./compzone -zzoneall -ccode -a -h0 -m2 | tee loecher

Verifys that all combinations of number are in the zonefile zoneall and write the result also to loecher.

    ./compzone -zzoneall -rzoneall.red -a -m

Verifys the reduced zonefile against the full file and stops on first error.

## mkzonedb

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 [-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
    -a CC .. Countrycode (only 1 File per country should have this)

For examples look at the `Makefile` in target `zonefiles`.

## zone

### Standalone-Synopsis

    zone -d Datafile [ -v ] [ -V ] { -z zonefile | num1 num2 }

or

    zone -d Datafile [ -v ] [ -V ] -a CC num1

or

    zone -d Datafile [ -v ] [ -V ] -a CC -c codefile

### Options

    -v ... verbose
    -V ... print version and exit

For standalone compile with:

    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 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 if returnvalue != UNKNOWN.

## Glossary

#### Zonefile

A sorted whitespace separated list of entries `from` `to` `zone`, where `to` is greater then `from`.

    1 2142 0
    1 2143 0
    ...
    1 2252 1
    1 2253 1
    ...

It has N*(N-1)/2 entries.

#### Reducedfile

A Zonefile with wildcards. It must be read top down to get correct rsults. The first matching entry is the right one.

    1 252 1
    ...
    2252 228 1
    2252 22 0
    ...
    2252 2 1
    ...
    2252 7 1
    2253 2252 127
    ...
    1 2 0
    ...

The line with zone 127 is a link to the zone-info 2252, so there are theoretical maximum of 126 zones.

#### Codefile

File of lines of all tel numbers and cits, separated by <tab>s

    1	Wien
    2142	Gattendorf
    2143	Berg
    ...
    2252	Baden b Wien
    ...

## Author

## Copyright

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.