From 10d7fe4252cf795c72e0d718db3f0836afa4888f Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sun, 23 Feb 2014 20:39:54 +0100 Subject: Add handling Telefonbuch version 1 in main script --- src/makecolumns.sh | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/makecolumns.sh b/src/makecolumns.sh index 28dd0a8..0f9c5ba 100755 --- a/src/makecolumns.sh +++ b/src/makecolumns.sh @@ -23,15 +23,17 @@ main() { make binaries printf "Cleaning up old working directory ... " - rm -rf ../work_`basename ${1#white_}` + rm -rf ../work_`basename "${1#white_}"` printf "done.\n" - mkdir -p ../work_`basename ${1#white_}` - cd ../work_`basename ${1#white_}` || exit 1 + mkdir -p ../work_`basename "${1#white_}"` + cd ../work_`basename "${1#white_}"` || exit 1 if [ -f "$1/phonebook.db" ]; then - handle_format_version_3 $1 - elif [ -f $1/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt] ]; then - handle_format_version_2 $1 + handle_format_version_3 "${1}" + elif [ -f "${1}/[Dd][Aa][Tt]/[Tt][Ee][Ii][Ll][Nn].[Dd][Aa][Tt]" ]; then + handle_format_version_2 "${1}" + elif [ -n "`find "${1}" -name dpr00000.005 -ls -quit`" ]; then + handle_format_version_1 "${1}" else echo "Not a recognized Telefonbuch folder" fi @@ -81,6 +83,31 @@ get_dword() { hexdump -n 4 -v -e '" " 1/4 "%u"' `printf %0${filename_len}d ${1}` } +handle_format_version_1() { + echo "Working on $1. Detected pre-02/1996 Telefonbuch version." + # Extract all dpr database files + printf "Extracting dpr databases ... " + find "$1" -name dpr\*.001 | extract_version_1 + printf "done.\n" + + # rename our extracted columns + mv 01_unknown 01_Flags + mv 02_unknown 02_Nachname + mv 03_unknown 03_Vorname + mv 04_unknown 05_Adresszusatz + mv 05_unknown 06_Ortszusatz + mv 06_unknown 10_Zustellamt_PLZOst + mv 07_unknown 07_Strasse + mv 08_unknown 08_Hausnummer + mv 09_unknown 04_Namenszusatz + mv 10_unknown 09_Fax_Verweise + mv 11_unknown 12_Vorwahl + mv 12_unknown 13_Rufnummer + mv 13_unknown 11_Ort + mv 14_unknown 10_Postleitzahl +} + + handle_format_version_2() { echo "Working on $1. Detected pre-2004 Telefonbuch version." # Extract teiln.dat -- cgit v1.2.3