summaryrefslogtreecommitdiff
path: root/src/makecolumns.sh
blob: cd260913fa2fb187cc6f53e2b2950df67e58ba4d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh

export LANG=C
export LC_CTYPE=C
export LC_ALL=C

[ -f /usr/local/bin/el ] && EL=/usr/local/bin/el
[ -f `dirname $0`/../bin/el ] && EL=`dirname $0`/../bin/el

if [ -z "${EL}" ]; then
  echo "el not found. Get it at 'cvs -d :pserver:anoncvs@cvs.erdgeist.org:/home/cvsroot co el'"
  exit 1
fi

HO=`dirname $0`/../bin/hexout

if [ $# -ne 1 ]; then
  echo "Syntax: $0 [phonebookdirectory]"
  exit 1
fi

make -f Makefile all

mkdir ../work
cd ../work

../bin/decompress $1/streets.tl

cat file_* > streets
rm file_*

../bin/decompress $1/phonebook.db

numfiles=`find . -name file_\* | wc -l`

for column in `jot - 0 10 1`; do
  for file in `jot - ${column} ${numfiles} 11`; do
    acton=`printf file_%05X ${file}`
    if [ ${column} = 0 ]; then
      ${HO} < ${acton} >> column_0;
    else
      tr '\0' '\n' < ${acton} >> column_${column};
    fi
 done;
done

mv column_0 01_Flags
mv column_1 02_Nachname
mv column_2 03_Vorname
mv column_3 04_05_Namenszusatz_Addresszusatz
mv column_4 09_Detail
mv column_5 07_08_Strassenindex_Hausnummer
mv column_6 12_Vorwahl
mv column_7 10_Postleitzahl
mv column_8 11_Ort
mv column_9 13_Rufnummer
mv column_10 14_15_Email_Webadresse

[ -e streets ] && tr '\0' '\n' < streets > 99_Strassenname && rm streets

if [ -e 99_Strassenname ]; then
  cut -f 1 07_08_Strassenindex_Hausnummer | ${EL} -0 99_Strassenname > 07_Strasse
else
  echo Could not convert streetindexes
fi

find . -name file_\* -delete