summaryrefslogtreecommitdiff
path: root/navit/support
diff options
context:
space:
mode:
authorCircle CI <circleci@navit-project.org>2017-10-30 00:23:00 +0000
committerCircle CI <circleci@navit-project.org>2017-10-30 00:23:00 +0000
commit82b0529430d6bbfa9d1ebe3c8706c2a37a033b12 (patch)
treea7d8c6e13a25a4add493f7ab74bbd45530d5bfb5 /navit/support
parent3d234b7049c094314ae60de2779cd6672a04d90c (diff)
downloadnavit-82b0529430d6bbfa9d1ebe3c8706c2a37a033b12.tar.gz
Update doc for commit c4e55b27cca91d761c9f4385cddb65b2eb5f8e3c
Diffstat (limited to 'navit/support')
-rw-r--r--navit/support/espeak/CMakeLists.txt9
-rw-r--r--navit/support/espeak/StdAfx.h3
-rwxr-xr-xnavit/support/espeak/compiledict.c1671
-rw-r--r--navit/support/espeak/debug.c74
-rw-r--r--navit/support/espeak/debug.h26
-rwxr-xr-xnavit/support/espeak/dictionary.c3490
-rw-r--r--navit/support/espeak/espeak-data/af_dictbin74925 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/ca_dictbin4212 -> 0 bytes
-rwxr-xr-xnavit/support/espeak/espeak-data/config9
-rw-r--r--navit/support/espeak/espeak-data/cs_dictbin7798 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/cy_dictbin3541 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/da_dictbin5327 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/de_dictbin19322 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/el_dictbin4585 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/en_dictbin87069 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/eo_dictbin4746 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/es_dictbin5309 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/fi_dictbin4567 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/fr_dictbin19363 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/grc_dictbin3390 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/hbs_dictbin7404 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/hi_dictbin5696 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/hu_dictbin5916 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/hy_dictbin2469 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/id_dictbin3083 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/is_dictbin5566 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/it_dictbin48870 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/jbo_dictbin2051 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/ku_dictbin2277 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/la_dictbin3911 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/lv_dictbin12558 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/af1_phtransbin1636 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/ca1_phtransbin1372 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/cr1_phtransbin2164 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/cs_phtransbin580 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/de2_phtransbin1444 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/de4_phtransbin1588 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/de6_phtransbin1204 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/en1_phtransbin796 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/es_phtransbin1708 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/fr1_phtransbin1852 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/gr2_phtransbin2212 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/grc-de6_phtransbin484 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/hu1_phtransbin1420 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/id1_phtransbin868 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/in1_phtransbin1252 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/it3_phtransbin892 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/la1_phtransbin748 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/nl_phtransbin1612 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/pl1_phtransbin1540 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/pt1_phtransbin2092 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/pt_phtransbin2092 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/ptbr4_phtransbin2356 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/ptbr_phtransbin2500 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/ro1_phtransbin2116 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/sv2_phtransbin1564 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/sv_phtransbin1564 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/us3_phtransbin1012 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mbrola_ph/us_phtransbin1084 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/mk_dictbin4948 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/nl_dictbin4124 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/no_dictbin3735 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/pap_dictbin2148 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/phondatabin355256 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/phondata-manifest729
-rw-r--r--navit/support/espeak/espeak-data/phonindexbin30256 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/phontabbin36460 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/pl_dictbin40458 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/pt_dictbin14970 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/ro_dictbin24961 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/ru_dictbin5519 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/sk_dictbin8898 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/sq_dictbin3222 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/sv_dictbin9508 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/sw_dictbin3072 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/ta_dictbin2527 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/tr_dictbin4783 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/vi_dictbin4855 -> 0 bytes
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/croak11
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/f118
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/f220
-rw-r--r--navit/support/espeak/espeak-data/voices/!v/f322
-rw-r--r--navit/support/espeak/espeak-data/voices/!v/f418
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/fast11
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/m119
-rw-r--r--navit/support/espeak/espeak-data/voices/!v/m215
-rw-r--r--navit/support/espeak/espeak-data/voices/!v/m316
-rw-r--r--navit/support/espeak/espeak-data/voices/!v/m417
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/m515
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/m613
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/m718
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/!v/whisper13
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/af8
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/bs16
-rw-r--r--navit/support/espeak/espeak-data/voices/ca4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/cs4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/cy5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/da3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/de5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/default4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/el5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/en/en9
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/en/en-n14
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/en/en-rp12
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/en/en-sc16
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/en/en-us17
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/en/en-wi19
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/en/en-wm12
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/eo3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/es7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/es-la11
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/fi4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/fr7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/fr-be7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/hi9
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/hr18
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/hu3
-rw-r--r--navit/support/espeak/espeak-data/voices/hy3
-rw-r--r--navit/support/espeak/espeak-data/voices/hy-west19
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/id8
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/is4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/it6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/ku6
-rw-r--r--navit/support/espeak/espeak-data/voices/la13
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/lv6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-af17
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-af1-en7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-br19
-rw-r--r--navit/support/espeak/espeak-data/voices/mb/mb-br39
-rw-r--r--navit/support/espeak/espeak-data/voices/mb/mb-br49
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-cr19
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-cz26
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de26
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de46
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de4-en6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de510
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de5-en7
-rw-r--r--navit/support/espeak/espeak-data/voices/mb/mb-de66
-rw-r--r--navit/support/espeak/espeak-data/voices/mb/mb-de6-grc6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-de77
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-en17
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-es17
-rw-r--r--navit/support/espeak/espeak-data/voices/mb/mb-es27
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-fr19
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-fr1-en8
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-fr48
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-fr4-en8
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-gr26
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-gr2-en6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-hu16
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-hu1-en6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-id17
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-it38
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-it48
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-la16
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-nl27
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-nl2-en7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-pl16
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-pl1-en6
-rw-r--r--navit/support/espeak/espeak-data/voices/mb/mb-pt19
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-ro17
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-ro1-en7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-sw17
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-sw1-en7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-sw27
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-sw2-en7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-us112
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-us212
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mb/mb-us312
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/mk4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/nl3
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/no6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/pl5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/pt7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/pt-pt7
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/ro5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/ru6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/sk4
-rw-r--r--navit/support/espeak/espeak-data/voices/sq6
-rw-r--r--navit/support/espeak/espeak-data/voices/sr15
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/sv4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/sw4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/ta6
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/test/grc8
-rw-r--r--navit/support/espeak/espeak-data/voices/test/jbo3
-rw-r--r--navit/support/espeak/espeak-data/voices/test/pap5
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/tr4
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/vi6
-rw-r--r--navit/support/espeak/espeak-data/voices/zh30
-rwxr-xr-xnavit/support/espeak/espeak-data/voices/zh-yue14
-rw-r--r--navit/support/espeak/espeak-data/zh_dictbin41834 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak-data/zhy_dictbin1556 -> 0 bytes
-rw-r--r--navit/support/espeak/espeak.c665
-rw-r--r--navit/support/espeak/espeak_command.c707
-rw-r--r--navit/support/espeak/espeak_command.h145
-rw-r--r--navit/support/espeak/event.c725
-rw-r--r--navit/support/espeak/event.h51
-rw-r--r--navit/support/espeak/fifo.c593
-rw-r--r--navit/support/espeak/fifo.h58
-rwxr-xr-xnavit/support/espeak/intonation.c1104
-rw-r--r--navit/support/espeak/klatt.c1303
-rw-r--r--navit/support/espeak/klatt.h153
-rw-r--r--navit/support/espeak/mbrolib.h205
-rw-r--r--navit/support/espeak/numbers.c1507
-rwxr-xr-xnavit/support/espeak/phoneme.h168
-rwxr-xr-xnavit/support/espeak/phonemelist.c686
-rwxr-xr-xnavit/support/espeak/portaudio.h466
-rwxr-xr-xnavit/support/espeak/portaudio18.h466
-rw-r--r--navit/support/espeak/portaudio19.h1127
-rw-r--r--navit/support/espeak/readclause.c2440
-rwxr-xr-xnavit/support/espeak/setlengths.c673
-rwxr-xr-xnavit/support/espeak/sintab.h258
-rwxr-xr-xnavit/support/espeak/speak.c898
-rw-r--r--navit/support/espeak/speak_init.c6
-rw-r--r--navit/support/espeak/speak_lib.c1156
-rw-r--r--navit/support/espeak/speak_lib.h601
-rwxr-xr-xnavit/support/espeak/speech.h86
-rwxr-xr-xnavit/support/espeak/synth_mbrola.c760
-rwxr-xr-xnavit/support/espeak/synthdata.c682
-rwxr-xr-xnavit/support/espeak/synthesize.c1658
-rwxr-xr-xnavit/support/espeak/synthesize.h377
-rw-r--r--navit/support/espeak/tr_languages.c1335
-rwxr-xr-xnavit/support/espeak/translate.c2800
-rwxr-xr-xnavit/support/espeak/translate.h584
-rw-r--r--navit/support/espeak/voice.h81
-rwxr-xr-xnavit/support/espeak/voices.c1746
-rwxr-xr-xnavit/support/espeak/wave.c1112
-rw-r--r--navit/support/espeak/wave.h52
-rwxr-xr-xnavit/support/espeak/wave_pulse.c935
-rwxr-xr-xnavit/support/espeak/wave_sada.c588
-rwxr-xr-xnavit/support/espeak/wavegen.c1941
-rw-r--r--navit/support/ezxml/CMakeLists.txt1
-rw-r--r--navit/support/ezxml/ezxml.c1022
-rw-r--r--navit/support/ezxml/ezxml.h167
-rw-r--r--navit/support/ezxml/ezxml_init.c6
-rw-r--r--navit/support/gettext_intl/CMakeLists.txt4
-rw-r--r--navit/support/gettext_intl/ChangeLog4
-rw-r--r--navit/support/gettext_intl/VERSION1
-rw-r--r--navit/support/gettext_intl/bindtextdom.c363
-rwxr-xr-xnavit/support/gettext_intl/config.charset608
-rw-r--r--navit/support/gettext_intl/dcgettext.c56
-rw-r--r--navit/support/gettext_intl/dcigettext.c1220
-rw-r--r--navit/support/gettext_intl/dcngettext.c57
-rw-r--r--navit/support/gettext_intl/dgettext.c58
-rw-r--r--navit/support/gettext_intl/dngettext.c59
-rw-r--r--navit/support/gettext_intl/eval-plural.h108
-rw-r--r--navit/support/gettext_intl/explodename.c185
-rw-r--r--navit/support/gettext_intl/finddomain.c192
-rw-r--r--navit/support/gettext_intl/gettext.c63
-rw-r--r--navit/support/gettext_intl/gettextP.h215
-rw-r--r--navit/support/gettext_intl/gmo.h149
-rw-r--r--navit/support/gettext_intl/hash-string.h48
-rw-r--r--navit/support/gettext_intl/intl-compat.c131
-rw-r--r--navit/support/gettext_intl/l10nflist.c421
-rw-r--r--navit/support/gettext_intl/libgnuintl.h384
-rw-r--r--navit/support/gettext_intl/libgnuintl.h.in383
-rw-r--r--navit/support/gettext_intl/loadinfo.h145
-rw-r--r--navit/support/gettext_intl/loadmsgcat.c1423
-rw-r--r--navit/support/gettext_intl/localcharset.c398
-rw-r--r--navit/support/gettext_intl/localcharset.h42
-rw-r--r--navit/support/gettext_intl/locale.alias78
-rw-r--r--navit/support/gettext_intl/localealias.c414
-rw-r--r--navit/support/gettext_intl/localename.c1148
-rw-r--r--navit/support/gettext_intl/log.c98
-rw-r--r--navit/support/gettext_intl/ngettext.c65
-rw-r--r--navit/support/gettext_intl/os2compat.c98
-rw-r--r--navit/support/gettext_intl/os2compat.h46
-rw-r--r--navit/support/gettext_intl/osdep.c24
-rw-r--r--navit/support/gettext_intl/plural-exp.c154
-rw-r--r--navit/support/gettext_intl/plural-exp.h118
-rw-r--r--navit/support/gettext_intl/plural.c1490
-rw-r--r--navit/support/gettext_intl/plural.y381
-rw-r--r--navit/support/gettext_intl/printf-args.c119
-rw-r--r--navit/support/gettext_intl/printf-args.h137
-rw-r--r--navit/support/gettext_intl/printf-parse.c537
-rw-r--r--navit/support/gettext_intl/printf-parse.h75
-rw-r--r--navit/support/gettext_intl/printf.c373
-rw-r--r--navit/support/gettext_intl/ref-add.sin31
-rw-r--r--navit/support/gettext_intl/ref-del.sin26
-rw-r--r--navit/support/gettext_intl/relocatable.c449
-rw-r--r--navit/support/gettext_intl/relocatable.h77
-rw-r--r--navit/support/gettext_intl/textdomain.c141
-rw-r--r--navit/support/gettext_intl/vasnprintf.c897
-rw-r--r--navit/support/gettext_intl/vasnprintf.h61
-rw-r--r--navit/support/gettext_intl/vasnwprintf.h46
-rw-r--r--navit/support/gettext_intl/wprintf-parse.h75
-rw-r--r--navit/support/gettext_intl/xsize.h109
-rw-r--r--navit/support/glib/CMakeLists.txt3
-rw-r--r--navit/support/glib/fake.c119
-rw-r--r--navit/support/glib/fake.h50
-rw-r--r--navit/support/glib/galias.h0
-rw-r--r--navit/support/glib/galiasdef.c0
-rw-r--r--navit/support/glib/galloca.h63
-rw-r--r--navit/support/glib/gatomic.c946
-rw-r--r--navit/support/glib/gerror.c381
-rw-r--r--navit/support/glib/gerror.h92
-rw-r--r--navit/support/glib/ghash.c1202
-rw-r--r--navit/support/glib/ghash.h145
-rw-r--r--navit/support/glib/glib.h42
-rw-r--r--navit/support/glib/glib_init.c6
-rw-r--r--navit/support/glib/glibconfig.h266
-rw-r--r--navit/support/glib/glibintl.h43
-rw-r--r--navit/support/glib/glist.c999
-rw-r--r--navit/support/glib/glist.h120
-rw-r--r--navit/support/glib/gmacros.h273
-rw-r--r--navit/support/glib/gmem.c742
-rw-r--r--navit/support/glib/gmem.h152
-rw-r--r--navit/support/glib/gmessages.c1126
-rw-r--r--navit/support/glib/gmessages.h341
-rw-r--r--navit/support/glib/gprimes.c90
-rw-r--r--navit/support/glib/gprintf.c342
-rw-r--r--navit/support/glib/gprintf.h52
-rw-r--r--navit/support/glib/gprintfint.h69
-rw-r--r--navit/support/glib/gquark.h52
-rw-r--r--navit/support/glib/gslice.c1496
-rw-r--r--navit/support/glib/gslice.h90
-rw-r--r--navit/support/glib/gslist.c1088
-rw-r--r--navit/support/glib/gslist.h116
-rw-r--r--navit/support/glib/gstrfuncs.c3133
-rw-r--r--navit/support/glib/gstrfuncs.h266
-rw-r--r--navit/support/glib/gstring.c1488
-rw-r--r--navit/support/glib/gthreadprivate.h68
-rw-r--r--navit/support/glib/gtypes.h432
-rw-r--r--navit/support/glib/gunicode.h404
-rw-r--r--navit/support/glib/gutf8.c1891
-rw-r--r--navit/support/glib/gutils.c3420
-rwxr-xr-xnavit/support/glib/gutils.h490
-rw-r--r--navit/support/libc/CMakeLists.txt1
-rw-r--r--navit/support/libc/_mingw.h304
-rw-r--r--navit/support/libc/abort.c9
-rw-r--r--navit/support/libc/bsearch.c81
-rw-r--r--navit/support/libc/calloc.c8
-rw-r--r--navit/support/libc/chsize.c51
-rw-r--r--navit/support/libc/close.c27
-rw-r--r--navit/support/libc/errno.h72
-rw-r--r--navit/support/libc/fcntl.h75
-rw-r--r--navit/support/libc/getopt.h111
-rw-r--r--navit/support/libc/gmtime.c25
-rw-r--r--navit/support/libc/io.h372
-rw-r--r--navit/support/libc/libc.c254
-rw-r--r--navit/support/libc/libc.h51
-rw-r--r--navit/support/libc/libc_init.c6
-rw-r--r--navit/support/libc/locale.h22
-rw-r--r--navit/support/libc/localtime.c38
-rw-r--r--navit/support/libc/lseek.c41
-rw-r--r--navit/support/libc/math.h13
-rw-r--r--navit/support/libc/mkdir.c29
-rw-r--r--navit/support/libc/mktime.c32
-rw-r--r--navit/support/libc/open.c135
-rw-r--r--navit/support/libc/process.h147
-rw-r--r--navit/support/libc/read.c30
-rw-r--r--navit/support/libc/rename.c27
-rw-r--r--navit/support/libc/signal.h2
-rw-r--r--navit/support/libc/stat.c151
-rw-r--r--navit/support/libc/strcasecmp.c21
-rw-r--r--navit/support/libc/sys/stat.h196
-rw-r--r--navit/support/libc/sys/time.h56
-rw-r--r--navit/support/libc/sys/types.h124
-rw-r--r--navit/support/libc/time.c28
-rw-r--r--navit/support/libc/timeutil.c126
-rw-r--r--navit/support/libc/timeutil.h17
-rw-r--r--navit/support/libc/unistd.h48
-rw-r--r--navit/support/libc/unlink.c29
-rw-r--r--navit/support/libc/write.c29
-rw-r--r--navit/support/libpng/CMakeLists.txt2
-rw-r--r--navit/support/libpng/libpng_init.c6
-rw-r--r--navit/support/libpng/png.c912
-rw-r--r--navit/support/libpng/png.h3682
-rw-r--r--navit/support/libpng/pngconf.h1496
-rw-r--r--navit/support/libpng/pngerror.c359
-rw-r--r--navit/support/libpng/pngget.c900
-rw-r--r--navit/support/libpng/pngm2pnm.c430
-rw-r--r--navit/support/libpng/pngmem.c610
-rw-r--r--navit/support/libpng/pngread.c1459
-rw-r--r--navit/support/libpng/pngrio.c168
-rw-r--r--navit/support/libpng/pngrtran.c4296
-rw-r--r--navit/support/libpng/pngrutil.c3223
-rw-r--r--navit/support/libpng/pngset.c1253
-rw-r--r--navit/support/libpng/pngtrans.c662
-rw-r--r--navit/support/shapefile/CMakeLists.txt1
-rw-r--r--navit/support/shapefile/dbfopen.c2405
-rw-r--r--navit/support/shapefile/shapefil.h747
-rw-r--r--navit/support/shapefile/shpopen.c3030
-rw-r--r--navit/support/shapefile/shptree.c1266
-rw-r--r--navit/support/win32/CMakeLists.txt2
-rw-r--r--navit/support/win32/ConvertUTF.c539
-rw-r--r--navit/support/win32/ConvertUTF.h149
-rw-r--r--navit/support/win32/X11/XF86keysym.h189
-rw-r--r--navit/support/win32/addwinsock.c8
-rw-r--r--navit/support/win32/addwinsock.h8
-rw-r--r--navit/support/win32/mmap.c43
-rw-r--r--navit/support/win32/serial_io.c166
-rw-r--r--navit/support/win32/serial_io.h42
-rw-r--r--navit/support/win32/stdint.h13
-rw-r--r--navit/support/win32/sys/mman.h8
-rw-r--r--navit/support/win32/win32_init.c6
-rw-r--r--navit/support/wordexp/CMakeLists.txt1
-rw-r--r--navit/support/wordexp/glob.c196
-rw-r--r--navit/support/wordexp/glob.h19
-rw-r--r--navit/support/wordexp/wordexp.c136
-rw-r--r--navit/support/wordexp/wordexp.h42
-rw-r--r--navit/support/wordexp/wordexp_init.c6
-rw-r--r--navit/support/xgetopt/CMakeLists.txt2
-rw-r--r--navit/support/xgetopt/XGetopt.c216
-rw-r--r--navit/support/xgetopt/XGetopt.h29
-rw-r--r--navit/support/xgetopt/getopt_long.c210
-rw-r--r--navit/support/xgetopt/getopt_long.h43
-rw-r--r--navit/support/zlib/CMakeLists.txt1
-rw-r--r--navit/support/zlib/adler32.c149
-rw-r--r--navit/support/zlib/crc32.c423
-rw-r--r--navit/support/zlib/crc32.h441
-rw-r--r--navit/support/zlib/infback.c623
-rw-r--r--navit/support/zlib/inffast.c318
-rw-r--r--navit/support/zlib/inffast.h11
-rw-r--r--navit/support/zlib/inffixed.h94
-rw-r--r--navit/support/zlib/inflate.c1368
-rw-r--r--navit/support/zlib/inflate.h115
-rw-r--r--navit/support/zlib/inftrees.c329
-rw-r--r--navit/support/zlib/inftrees.h55
-rw-r--r--navit/support/zlib/zconf.h332
-rw-r--r--navit/support/zlib/zlib.h1357
-rw-r--r--navit/support/zlib/zlib_init.c6
-rw-r--r--navit/support/zlib/zutil.c318
-rw-r--r--navit/support/zlib/zutil.h269
424 files changed, 0 insertions, 113159 deletions
diff --git a/navit/support/espeak/CMakeLists.txt b/navit/support/espeak/CMakeLists.txt
deleted file mode 100644
index 6a20511e7..000000000
--- a/navit/support/espeak/CMakeLists.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-
-if(INTERNAL_ESPEAK_COMPLETE)
- set(ESPEAK_LIBRARY_ADDITIONAL speak_lib.c)
-endif()
-supportlib_add_library(support_espeak compiledict.c dictionary.c intonation.c readclause.c setlengths.c
- numbers.c synth_mbrola.c synthdata.c synthesize.c translate.c tr_languages.c voices.c wavegen.c
- phonemelist.c klatt.c speak_init.c ${ESPEAK_LIBRARY_ADDITIONAL})
-
-install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/espeak-data DESTINATION ${SHARE_DIR} PATTERN ".svn" EXCLUDE)
diff --git a/navit/support/espeak/StdAfx.h b/navit/support/espeak/StdAfx.h
deleted file mode 100644
index c9a526fdf..000000000
--- a/navit/support/espeak/StdAfx.h
+++ /dev/null
@@ -1,3 +0,0 @@
-// This is a dummy file.
-// A file of this name is needed on Windows
-
diff --git a/navit/support/espeak/compiledict.c b/navit/support/espeak/compiledict.c
deleted file mode 100755
index a2b7865f9..000000000
--- a/navit/support/espeak/compiledict.c
+++ /dev/null
@@ -1,1671 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <wctype.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "translate.h"
-
-//#define OPT_FORMAT // format the text and write formatted copy to Log file
-//#define OUTPUT_FORMAT
-
-extern void Write4Bytes(FILE *f, int value);
-int HashDictionary(const char *string);
-
-static FILE *f_log = NULL;
-extern char *dir_dictionary;
-
-static int linenum;
-static int error_count;
-static int transpose_offset; // transpose character range for LookupDictList()
-static int transpose_min;
-static int transpose_max;
-static int text_mode = 0;
-static int debug_flag = 0;
-
-static int hash_counts[N_HASH_DICT];
-static char *hash_chains[N_HASH_DICT];
-static char letterGroupsDefined[N_LETTER_GROUPS];
-
-#define __cdecl
-
-MNEM_TAB mnem_flags[] = {
- // these in the first group put a value in bits0-3 of dictionary_flags
- {"$1", 0x41}, // stress on 1st syllable
- {"$2", 0x42}, // stress on 2nd syllable
- {"$3", 0x43},
- {"$4", 0x44},
- {"$5", 0x45},
- {"$6", 0x46},
- {"$7", 0x47},
- {"$u", 0x48}, // reduce to unstressed
- {"$u1", 0x49},
- {"$u2", 0x4a},
- {"$u3", 0x4b},
- {"$u+", 0x4c}, // reduce to unstressed, but stress at end of clause
- {"$u1+", 0x4d},
- {"$u2+", 0x4e},
- {"$u3+", 0x4f},
-
-
- // these set the corresponding numbered bit if dictionary_flags
- {"$pause", 8}, /* ensure pause before this word */
- {"$only", 9}, /* only match on this word without suffix */
- {"$onlys", 10}, /* only match with none, or with 's' suffix */
- {"$strend", 11}, /* full stress if at end of clause */
- {"$strend2", 12}, /* full stress if at end of clause, or only followed by unstressed */
- {"$unstressend",13}, /* reduce stress at end of clause */
- {"$atend", 14}, /* use this pronunciation if at end of clause */
-
- {"$dot", 16}, /* ignore '.' after this word (abbreviation) */
- {"$abbrev", 17}, /* use this pronuciation rather than split into letters */
- {"$stem", 18}, // must have a suffix
-
-// language specific
- {"$double", 19}, // IT double the initial consonant of next word
- {"$alt", 20}, // use alternative pronunciation
- {"$alt2", 21},
-
-
- {"$max3", 27}, // limit to 3 repetitions
- {"$brk", 28}, // a shorter $pause
- {"$text", 29}, // word translates to replcement text, not phonemes
-
-// flags in dictionary word 2
- {"$verbf", 0x20}, /* verb follows */
- {"$verbsf", 0x21}, /* verb follows, allow -s suffix */
- {"$nounf", 0x22}, /* noun follows */
- {"$pastf", 0x23}, /* past tense follows */
- {"$verb", 0x24}, /* use this pronunciation when its a verb */
- {"$noun", 0x25}, /* use this pronunciation when its a noun */
- {"$past", 0x26}, /* use this pronunciation when its past tense */
- {"$verbextend",0x28}, /* extend influence of 'verb follows' */
- {"$capital", 0x29}, /* use this pronunciation if initial letter is upper case */
- {"$allcaps", 0x2a}, /* use this pronunciation if initial letter is upper case */
- {"$accent", 0x2b}, // character name is base-character name + accent name
-
- // doesn't set dictionary_flags
- {"$?", 100}, // conditional rule, followed by byte giving the condition number
-
- {"$textmode", 200},
- {"$phonememode", 201},
- {NULL, -1}
-};
-
-
-#define LEN_GROUP_NAME 12
-
-typedef struct {
- char name[LEN_GROUP_NAME+1];
- unsigned int start;
- unsigned int length;
-} RGROUP;
-
-
-int isspace2(unsigned int c)
-{//=========================
-// can't use isspace() because on Windows, isspace(0xe1) gives TRUE !
- int c2;
-
- if(((c2 = (c & 0xff)) == 0) || (c > ' '))
- return(0);
- return(1);
-}
-
-
-static const char *LookupMnem2(MNEM_TAB *table, int value)
-{//=======================================================
- while(table->mnem != NULL)
- {
- if(table->value == value)
- return(table->mnem);
- table++;
- }
- return("");
-}
-
-
-char *print_dictionary_flags(unsigned int *flags)
-{//==============================================
- static char buf[20];
-
- sprintf(buf,"%s 0x%x/%x",LookupMnem2(mnem_flags,(flags[0] & 0xf)+0x40), flags[0], flags[1]);
- return(buf);
-}
-
-
-
-static FILE *fopen_log(const char *fname,const char *access)
-{//==================================================
-// performs fopen, but produces error message to f_log if it fails
- FILE *f;
-
- if((f = fopen(fname,access)) == NULL)
- {
- if(f_log != NULL)
- fprintf(f_log,"Can't access (%s) file '%s'\n",access,fname);
- }
- return(f);
-}
-
-
-#ifdef OPT_FORMAT
-static const char *lookup_mnem(MNEM_TAB *table, int value)
-//========================================================
-/* Lookup a mnemonic string in a table, return its name */
-{
- while(table->mnem != NULL)
- {
- if(table->value==value)
- return(table->mnem);
- table++;
- }
- return("??"); /* not found */
-} /* end of mnem */
-#endif
-
-
-
-
-static int compile_line(char *linebuf, char *dict_line, int *hash)
-{//===============================================================
-// Compile a line in the language_list file
- unsigned char c;
- char *p;
- char *word;
- char *phonetic;
- unsigned int ix;
- int step;
- unsigned int n_flag_codes = 0;
- int flag_offset;
- int length;
- int multiple_words = 0;
- int multiple_numeric_hyphen = 0;
- char *multiple_string = NULL;
- char *multiple_string_end = NULL;
-
- int len_word;
- int len_phonetic;
- int text_not_phonemes; // this word specifies replacement text, not phonemes
- unsigned int wc;
- int all_upper_case;
-
- char *mnemptr;
- char *comment;
- unsigned char flag_codes[100];
- char encoded_ph[200];
- unsigned char bad_phoneme[4];
-static char nullstring[] = {0};
-
- comment = NULL;
- text_not_phonemes = 0;
- phonetic = word = nullstring;
-
-if(memcmp(linebuf,"_-",2)==0)
-{
-step=1; // TEST
-}
- p = linebuf;
-// while(isspace2(*p)) p++;
-
-#ifdef deleted
- if(*p == '$')
- {
- if(memcmp(p,"$textmode",9) == 0)
- {
- text_mode = 1;
- return(0);
- }
- if(memcmp(p,"$phonememode",12) == 0)
- {
- text_mode = 0;
- return(0);
- }
- }
-#endif
-
- step = 0;
-
- c = 0;
- while(c != '\n')
- {
- c = *p;
-
- if((c == '?') && (step==0))
- {
- // conditional rule, allow only if the numbered condition is set for the voice
- flag_offset = 100;
-
- p++;
- if(*p == '!')
- {
- // allow only if the numbered condition is NOT set
- flag_offset = 132;
- p++;
- }
-
- ix = 0;
- if(isdigit(*p))
- {
- ix += (*p-'0');
- p++;
- }
- if(isdigit(*p))
- {
- ix = ix*10 + (*p-'0');
- p++;
- }
- flag_codes[n_flag_codes++] = ix + flag_offset;
- c = *p;
- }
-
- if((c == '$') && isalnum(p[1]))
- {
- /* read keyword parameter */
- mnemptr = p;
- while(!isspace2(c = *p)) p++;
- *p = 0;
-
- ix = LookupMnem(mnem_flags,mnemptr);
- if(ix > 0)
- {
- if(ix == 200)
- {
- text_mode = 1;
- }
- else
- if(ix == 201)
- {
- text_mode = 0;
- }
- else
- if(ix == BITNUM_FLAG_TEXTMODE)
- {
- text_not_phonemes = 1;
- }
- else
- {
- flag_codes[n_flag_codes++] = ix;
- }
- }
- else
- {
- fprintf(f_log,"%5d: Unknown keyword: %s\n",linenum,mnemptr);
- error_count++;
- }
- }
-
- if((c == '/') && (p[1] == '/') && (multiple_words==0))
- {
- c = '\n'; /* "//" treat comment as end of line */
- comment = p;
- }
-
- switch(step)
- {
- case 0:
- if(c == '(')
- {
- multiple_words = 1;
- word = p+1;
- step = 1;
- }
- else
- if(!isspace2(c))
- {
- word = p;
- step = 1;
- }
- break;
-
- case 1:
- if((c == '-') && (word[0] != '_'))
- {
- if(isdigit(word[0]))
- {
- multiple_numeric_hyphen = 1;
- }
- else
- {
- flag_codes[n_flag_codes++] = BITNUM_FLAG_HYPHENATED;
- }
- c = ' ';
- }
- if(isspace2(c))
- {
- p[0] = 0; /* terminate english word */
-
- if(multiple_words)
- {
- multiple_string = multiple_string_end = p+1;
- step = 2;
- }
- else
- {
- step = 3;
- }
- }
- else
- if((c == ')') && multiple_words)
- {
- p[0] = 0;
- step = 3;
- multiple_words = 0;
- }
- break;
-
- case 2:
- if(isspace2(c))
- {
- multiple_words++;
- }
- else
- if(c == ')')
- {
- p[0] = ' '; // terminate extra string
- multiple_string_end = p+1;
- step = 3;
- }
- break;
-
- case 3:
- if(!isspace2(c))
- {
- phonetic = p;
- step = 4;
- }
- break;
-
- case 4:
- if(isspace2(c))
- {
- p[0] = 0; /* terminate phonetic */
- step = 5;
- }
- break;
-
- case 5:
- break;
- }
- p++;
- }
-
- if(word[0] == 0)
- {
-#ifdef OPT_FORMAT
- if(comment != NULL)
- fprintf(f_log,"%s",comment);
- else
- fputc('\n',f_log);
-#endif
- return(0); /* blank line */
- }
-
- if(text_mode)
- text_not_phonemes = 1;
-
- if(text_not_phonemes != translator->langopts.textmode)
- {
- flag_codes[n_flag_codes++] = BITNUM_FLAG_TEXTMODE;
- }
-
- if(text_not_phonemes)
- {
- // this is replacement text, so don't encode as phonemes. Restrict the length of the replacement word
- strncpy0(encoded_ph,phonetic,N_WORD_BYTES-4);
- }
- else
- {
- EncodePhonemes(phonetic,encoded_ph,bad_phoneme);
- if(strchr(encoded_ph,phonSWITCH) != 0)
- {
- flag_codes[n_flag_codes++] = BITNUM_FLAG_ONLY_S; // don't match on suffixes (except 's') when switching languages
- }
-
- // check for errors in the phonemes codes
- for(ix=0; ix<sizeof(encoded_ph); ix++)
- {
- c = encoded_ph[ix];
- if(c == 0) break;
-
- if(c == 255)
- {
- /* unrecognised phoneme, report error */
- fprintf(f_log,"%5d: Bad phoneme [%c] (0x%x) in: %s %s\n",linenum,bad_phoneme[0],bad_phoneme[0],word,phonetic);
- error_count++;
- }
- }
- }
-
- if(sscanf(word,"U+%x",&wc) == 1)
- {
- // Character code
- ix = utf8_out(wc, word);
- word[ix] = 0;
- }
- else
- if(word[0] != '_')
- {
- // convert to lower case, and note if the word is all-capitals
- int c2;
-
- all_upper_case = 1;
- p = word;
- for(p=word;;)
- {
- // this assumes that the lower case char is the same length as the upper case char
- // OK, except for Turkish "I", but use towlower() rather than towlower2()
- ix = utf8_in(&c2,p);
- if(c2 == 0)
- break;
- if(iswupper(c2))
- {
- utf8_out(towlower(c2),p);
- }
- else
- {
- all_upper_case = 0;
- }
- p += ix;
- }
- if(all_upper_case)
- {
- flag_codes[n_flag_codes++] = BITNUM_FLAG_ALLCAPS;
- }
- }
-
- len_word = strlen(word);
-
- if(transpose_offset > 0)
- {
- len_word = TransposeAlphabet(word, transpose_offset, transpose_min, transpose_max);
- }
-
- *hash = HashDictionary(word);
- len_phonetic = strlen(encoded_ph);
-
- dict_line[1] = len_word; // bit 6 indicates whether the word has been compressed
- len_word &= 0x3f;
-
- memcpy(&dict_line[2],word,len_word);
-
- if(len_phonetic == 0)
- {
- // no phonemes specified. set bit 7
- dict_line[1] |= 0x80;
- length = len_word + 2;
- }
- else
- {
- length = len_word + len_phonetic + 3;
- strcpy(&dict_line[(len_word)+2],encoded_ph);
- }
-
- for(ix=0; ix<n_flag_codes; ix++)
- {
- dict_line[ix+length] = flag_codes[ix];
- }
- length += n_flag_codes;
-
- if((multiple_string != NULL) && (multiple_words > 0))
- {
- if(multiple_words > 10)
- {
- fprintf(f_log,"%5d: Two many parts in a multi-word entry: %d\n",linenum,multiple_words);
- }
- else
- {
- dict_line[length++] = 80 + multiple_words + multiple_numeric_hyphen; // if numeric, count a hyphen as an extra word
- ix = multiple_string_end - multiple_string;
- if(multiple_numeric_hyphen)
- {
- // the first part is numeric, so keep the hyphen to match on
- dict_line[length++] = '-';
- dict_line[length++] = ' ';
- }
- memcpy(&dict_line[length],multiple_string,ix);
- length += ix;
- }
- }
- dict_line[0] = length;
-
-#ifdef OPT_FORMAT
- spaces = 16;
- for(ix=0; ix<n_flag_codes; ix++)
- {
- if(flag_codes[ix] >= 100)
- {
- fprintf(f_log,"?%d ",flag_codes[ix]-100);
- spaces -= 3;
- }
- }
-
- fprintf(f_log,"%s",word);
- spaces -= strlen(word);
- DecodePhonemes(encoded_ph,decoded_ph);
- while(spaces-- > 0) fputc(' ',f_log);
- spaces += (14 - strlen(decoded_ph));
-
- fprintf(f_log," %s",decoded_ph);
- while(spaces-- > 0) fputc(' ',f_log);
- for(ix=0; ix<n_flag_codes; ix++)
- {
- if(flag_codes[ix] < 100)
- fprintf(f_log," %s",lookup_mnem(mnem_flags,flag_codes[ix]));
- }
- if(comment != NULL)
- fprintf(f_log," %s",comment);
- else
- fputc('\n',f_log);
-#endif
-
- return(length);
-} /* end of compile_line */
-
-
-
-static void compile_dictlist_start(void)
-{//=====================================
-// initialise dictionary list
- int ix;
- char *p;
- char *p2;
-
- for(ix=0; ix<N_HASH_DICT; ix++)
- {
- p = hash_chains[ix];
- while(p != NULL)
- {
- memcpy(&p2,p,sizeof(char *));
- free(p);
- p = p2;
- }
- hash_chains[ix] = NULL;
- hash_counts[ix]=0;
- }
-}
-
-
-static void compile_dictlist_end(FILE *f_out)
-{//==========================================
-// Write out the compiled dictionary list
- int hash;
- int length;
- char *p;
-
- if(f_log != NULL)
- {
-#ifdef OUTPUT_FORMAT
- for(hash=0; hash<N_HASH_DICT; hash++)
- {
- fprintf(f_log,"%8d",hash_counts[hash]);
- if((hash & 7) == 7)
- fputc('\n',f_log);
- }
- fflush(f_log);
-#endif
- }
-
- for(hash=0; hash<N_HASH_DICT; hash++)
- {
- p = hash_chains[hash];
- hash_counts[hash] = (int)ftell(f_out);
-
- while(p != NULL)
- {
- length = *(p+sizeof(char *));
- fwrite(p+sizeof(char *),length,1,f_out);
- memcpy(&p,p,sizeof(char *));
- }
- fputc(0,f_out);
- }
-}
-
-
-
-static int compile_dictlist_file(const char *path, const char* filename)
-{//=====================================================================
- int length;
- int hash;
- char *p;
- int count=0;
- FILE *f_in;
- char buf[200];
- char fname[sizeof(path_home)+45];
- char dict_line[128];
-
- text_mode = 0;
-
- sprintf(fname,"%s%s",path,filename);
- if((f_in = fopen(fname,"r")) == NULL)
- return(-1);
-
- fprintf(f_log,"Compiling: '%s'\n",fname);
-
- linenum=0;
-
- while(fgets(buf,sizeof(buf),f_in) != NULL)
- {
- linenum++;
-
- length = compile_line(buf,dict_line,&hash);
- if(length == 0) continue; /* blank line */
-
- hash_counts[hash]++;
-
- p = (char *)malloc(length+sizeof(char *));
- if(p == NULL)
- {
- if(f_log != NULL)
- {
- fprintf(f_log,"Can't allocate memory\n");
- error_count++;
- }
- break;
- }
-
- memcpy(p,&hash_chains[hash],sizeof(char *));
- hash_chains[hash] = p;
- memcpy(p+sizeof(char *),dict_line,length);
- count++;
- }
-
- fprintf(f_log,"\t%d entries\n",count);
- fclose(f_in);
- return(0);
-} /* end of compile_dictlist_file */
-
-
-
-static char rule_cond[80];
-static char rule_pre[80];
-static char rule_post[80];
-static char rule_match[80];
-static char rule_phonemes[80];
-static char group_name[LEN_GROUP_NAME+1];
-
-#define N_RULES 2000 // max rules for each group
-
-
-
-static void copy_rule_string(char *string, int *state)
-{//===================================================
-// state 0: conditional, 1=pre, 2=match, 3=post, 4=phonemes
- static char *outbuf[5] = {rule_cond, rule_pre, rule_match, rule_post, rule_phonemes};
- static int next_state[5] = {2,2,4,4,4};
- char *output;
- char *p;
- int ix;
- int len;
- char c;
- int sxflags;
- int value;
- int literal;
-
- if(string[0] == 0) return;
-
- output = outbuf[*state];
- if(*state==4)
- {
- // append to any previous phoneme string, i.e. allow spaces in the phoneme string
- len = strlen(rule_phonemes);
- if(len > 0)
- rule_phonemes[len++] = ' ';
- output = &rule_phonemes[len];
- }
- sxflags = 0x808000; // to ensure non-zero bytes
-
- for(p=string,ix=0;;)
- {
- literal = 0;
- c = *p++;
- if(c == '\\')
- {
- c = *p++; // treat next character literally
- if((c >= '0') && (c <= '3') && (p[0] >= '0') && (p[0] <= '7') && (p[1] >= '0') && (p[1] <= '7'))
- {
- // character code given by 3 digit octal value;
- c = (c-'0')*64 + (p[0]-'0')*8 + (p[1]-'0');
- p += 2;
- }
- literal = 1;
- }
-
- if(((*state)==1) || ((*state)==3))
- {
- // replace special characters (note: 'E' is reserved for a replaced silent 'e')
- if(literal == 0)
- {
- static const char lettergp_letters[9] = {LETTERGP_A,LETTERGP_B,LETTERGP_C,0,0,LETTERGP_F,LETTERGP_G,LETTERGP_H,LETTERGP_Y};
- switch(c)
- {
- case '_':
- c = RULE_SPACE;
- break;
-
- case 'Y':
- c = 'I'; // drop through to next case
- case 'A': // vowel
- case 'B':
- case 'C':
- case 'H':
- case 'F':
- case 'G':
- if((*state) == 1)
- {
- // pre-rule, put the number before the RULE_LETTERGP;
- output[ix++] = lettergp_letters[c-'A'] + 'A';
- c = RULE_LETTERGP;
- }
- else
- {
- output[ix++] = RULE_LETTERGP;
- c = lettergp_letters[c-'A'] + 'A';
- }
- break;
- case 'D':
- c = RULE_DIGIT;
- break;
- case 'K':
- c = RULE_NOTVOWEL;
- break;
- case 'N':
- c = RULE_NO_SUFFIX;
- break;
- case 'V':
- c = RULE_IFVERB;
- break;
- case 'Z':
- c = RULE_NONALPHA;
- break;
- case '+':
- c = RULE_INC_SCORE;
- break;
- case '@':
- c = RULE_SYLLABLE;
- break;
- case '&':
- c = RULE_STRESSED;
- break;
- case '%':
- c = RULE_DOUBLE;
- break;
- case '#':
- c = RULE_DEL_FWD;
- break;
- case '!':
- c = RULE_CAPITAL;
- break;
- case 'T':
- c = RULE_ALT1;
- break;
- case 'W':
- c = RULE_SPELLING;
- break;
- case 'X':
- c = RULE_NOVOWELS;
- break;
- case 'L':
- // expect two digits
- c = *p++ - '0';
- value = *p++ - '0';
- c = c * 10 + value;
- if((value < 0) || (value > 9))
- {
- c = 0;
- fprintf(f_log,"%5d: Expected 2 digits after 'L'\n",linenum);
- error_count++;
- }
- else
- if((c <= 0) || (c >= N_LETTER_GROUPS) || (letterGroupsDefined[(int)c] == 0))
- {
- fprintf(f_log,"%5d: Letter group L%.2d not defined\n",linenum,c);
- error_count++;
- }
- c += 'A';
- if((*state) == 1)
- {
- // pre-rule, put the group number before the RULE_LETTERGP command
- output[ix++] = c;
- c = RULE_LETTERGP2;
- }
- else
- {
- output[ix++] = RULE_LETTERGP2;
- }
- break;
-
- case '$': // obsolete, replaced by S
- fprintf(f_log,"%5d: $ now not allowed, use S for suffix",linenum);
- error_count++;
- break;
- case 'P':
- sxflags |= SUFX_P; // Prefix, now drop through to Suffix
- case 'S':
- output[ix++] = RULE_ENDING;
- value = 0;
- while(!isspace2(c = *p++) && (c != 0))
- {
- switch(c)
- {
- case 'e':
- sxflags |= SUFX_E;
- break;
- case 'i':
- sxflags |= SUFX_I;
- break;
- case 'p': // obsolete, replaced by 'P' above
- sxflags |= SUFX_P;
- break;
- case 'v':
- sxflags |= SUFX_V;
- break;
- case 'd':
- sxflags |= SUFX_D;
- break;
- case 'f':
- sxflags |= SUFX_F;
- break;
- case 'q':
- sxflags |= SUFX_Q;
- break;
- case 't':
- sxflags |= SUFX_T;
- break;
- case 'b':
- sxflags |= SUFX_B;
- break;
- default:
- if(isdigit(c))
- value = (value*10) + (c - '0');
- break;
- }
- }
- p--;
- output[ix++] = sxflags >> 16;
- output[ix++] = sxflags >> 8;
- c = value | 0x80;
- break;
- }
- }
- }
- output[ix++] = c;
- if(c == 0) break;
- }
-
- *state = next_state[*state];
-} // end of copy_rule_string
-
-
-
-static char *compile_rule(char *input)
-{//===================================
- int ix;
- unsigned char c;
- int wc;
- char *p;
- char *prule;
- int len;
- int len_name;
- int state=2;
- int finish=0;
- int pre_bracket=0;
- char buf[80];
- char output[150];
- unsigned char bad_phoneme[4];
-
- buf[0]=0;
- rule_cond[0]=0;
- rule_pre[0]=0;
- rule_post[0]=0;
- rule_match[0]=0;
- rule_phonemes[0]=0;
-
- p = buf;
-
- for(ix=0; finish==0; ix++)
- {
- c = input[ix];
-
- switch(c = input[ix])
- {
- case ')': // end of prefix section
- *p = 0;
- state = 1;
- pre_bracket = 1;
- copy_rule_string(buf,&state);
- p = buf;
- break;
-
- case '(': // start of suffix section
- *p = 0;
- state = 2;
- copy_rule_string(buf,&state);
- state = 3;
- p = buf;
- break;
-
- case '\n': // end of line
- case '\r':
- case 0: // end of line
- *p = 0;
- copy_rule_string(buf,&state);
- finish=1;
- break;
-
- case '\t': // end of section section
- case ' ':
- *p = 0;
- copy_rule_string(buf,&state);
- p = buf;
- break;
-
- case '?':
- if(state==2)
- state=0;
- else
- *p++ = c;
- break;
-
- default:
- *p++ = c;
- break;
- }
- }
-
- if(strcmp(rule_match,"$group")==0)
- strcpy(rule_match,group_name);
-
- if(rule_match[0]==0)
- return(NULL);
-
- EncodePhonemes(rule_phonemes,buf,bad_phoneme);
- for(ix=0;; ix++)
- {
- if((c = buf[ix])==0) break;
- if(c==255)
- {
- fprintf(f_log,"%5d: Bad phoneme [%c] in %s",linenum,bad_phoneme[0],input);
- error_count++;
- break;
- }
- }
- strcpy(output,buf);
- len = strlen(buf)+1;
-
- len_name = strlen(group_name);
- if((len_name > 0) && (memcmp(rule_match,group_name,len_name) != 0))
- {
- utf8_in(&wc,rule_match);
- if((group_name[0] == '9') && IsDigit(wc))
- {
- // numeric group, rule_match starts with a digit, so OK
- }
- else
- {
- fprintf(f_log,"%5d: Wrong initial letters '%s' for group '%s'\n",linenum,rule_match,group_name);
- error_count++;
- }
- }
- strcpy(&output[len],rule_match);
- len += strlen(rule_match);
-
- if(debug_flag)
- {
- output[len] = RULE_LINENUM;
- output[len+1] = (linenum % 255) + 1;
- output[len+2] = (linenum / 255) + 1;
- len+=3;
- }
-
- if(rule_cond[0] != 0)
- {
- ix = -1;
- if(rule_cond[0] == '!')
- {
- // allow the rule only if the condition number is NOT set for the voice
- ix = atoi(&rule_cond[1]) + 32;
- }
- else
- {
- // allow the rule only if the condition number is set for the voice
- ix = atoi(rule_cond);
- }
-
- if((ix > 0) && (ix < 255))
- {
- output[len++] = RULE_CONDITION;
- output[len++] = ix;
- }
- else
- {
- fprintf(f_log,"%5d: bad condition number ?%d\n",linenum,ix);
- error_count++;
- }
- }
- if(rule_pre[0] != 0)
- {
- output[len++] = RULE_PRE;
- // output PRE string in reverse order
- for(ix = strlen(rule_pre)-1; ix>=0; ix--)
- output[len++] = rule_pre[ix];
- }
-
- if(rule_post[0] != 0)
- {
- sprintf(&output[len],"%c%s",RULE_POST,rule_post);
- len += (strlen(rule_post)+1);
- }
- output[len++]=0;
- prule = (char *)malloc(len);
- memcpy(prule,output,len);
- return(prule);
-} // end of compile_rule
-
-
-static int __cdecl string_sorter(char **a, char **b)
-{//=================================================
- char *pa, *pb;
- int ix;
-
- if((ix = strcmp(pa = *a,pb = *b)) != 0)
- return(ix);
- pa += (strlen(pa)+1);
- pb += (strlen(pb)+1);
- return(strcmp(pa,pb));
-} /* end of string_sorter */
-
-
-static int __cdecl rgroup_sorter(RGROUP *a, RGROUP *b)
-{//===================================================
- int ix;
- ix = strcmp(a->name,b->name);
- if(ix != 0) return(ix);
- return(a->start-b->start);
-}
-
-
-#ifdef OUTPUT_FORMAT
-static void print_rule_group(FILE *f_out, int n_rules, char **rules, char *name)
-{//=============================================================================
- int rule;
- int ix;
- unsigned char c;
- int len1;
- int len2;
- int spaces;
- char *p;
- char *pout;
- int condition;
- char buf[80];
- char suffix[12];
-
- static unsigned char symbols[] = {'@','&','%','+','#','$','D','Z','A','B','C','F'};
-
- fprintf(f_out,"\n$group %s\n",name);
-
- for(rule=0; rule<n_rules; rule++)
- {
- p = rules[rule];
- len1 = strlen(p) + 1;
- p = &p[len1];
- len2 = strlen(p);
-
- rule_match[0]=0;
- rule_pre[0]=0;
- rule_post[0]=0;
- condition = 0;
-
- pout = rule_match;
- for(ix=0; ix<len2; ix++)
- {
- switch(c = p[ix])
- {
- case RULE_PRE:
- *pout = 0;
- pout = rule_pre;
- break;
- case RULE_POST:
- *pout = 0;
- pout = rule_post;
- break;
- case RULE_CONDITION:
- condition = p[++ix];
- break;
- case RULE_ENDING:
- sprintf(suffix,"$%d[%x]",(p[ix+2]),p[ix+1] & 0x7f);
- ix += 2;
- strcpy(pout,suffix);
- pout += strlen(suffix);
- break;
- default:
- if(c <= RULE_LETTER7)
- c = symbols[c-RULE_SYLLABLE];
- if(c == ' ')
- c = '_';
- *pout++ = c;
- break;
- }
- }
- *pout = 0;
-
- spaces = 12;
- if(condition > 0)
- {
- sprintf(buf,"?%d ",condition);
- spaces -= strlen(buf);
- fprintf(f_out,"%s",buf);
- }
-
- if(rule_pre[0] != 0)
- {
- p = buf;
- for(ix=strlen(rule_pre)-1;ix>=0;ix--)
- *p++ = rule_pre[ix];
- sprintf(p,") ");
- spaces -= strlen(buf);
- for(ix=0; ix<spaces; ix++)
- fputc(' ',f_out);
- fprintf(f_out,"%s",buf);
- spaces = 0;
- }
-
- for(ix=0; ix<spaces; ix++)
- fputc(' ',f_out);
-
- spaces = 14;
- sprintf(buf," %s ",rule_match);
- if(rule_post[0] != 0)
- {
- p = &buf[strlen(buf)];
- sprintf(p,"(%s ",rule_post);
- }
- fprintf(f_out,"%s",buf);
- spaces -= strlen(buf);
-
- for(ix=0; ix<spaces; ix++)
- fputc(' ',f_out);
- DecodePhonemes(rules[rule],buf);
- fprintf(f_out,"%s\n",buf); // phonemes
- }
-}
-#endif
-
-
-//#define LIST_GROUP_INFO
-static void output_rule_group(FILE *f_out, int n_rules, char **rules, char *name)
-{//==============================================================================
- int ix;
- int len1;
- int len2;
- int len_name;
- char *p;
- char *p2, *p3;
- const char *common;
-
- short nextchar_count[256];
- memset(nextchar_count,0,sizeof(nextchar_count));
-
- len_name = strlen(name);
-
-#ifdef OUTPUT_FORMAT
- print_rule_group(f_log,n_rules,rules,name);
-#endif
-
- // sort the rules in this group by their phoneme string
- common = "";
- qsort((void *)rules,n_rules,sizeof(char *),(int (__cdecl *)(const void *,const void *))string_sorter);
-
- if(strcmp(name,"9")==0)
- len_name = 0; // don't remove characters from numeric match strings
-
- for(ix=0; ix<n_rules; ix++)
- {
- p = rules[ix];
- len1 = strlen(p) + 1; // phoneme string
- p3 = &p[len1];
- p2 = p3 + len_name; // remove group name from start of match string
- len2 = strlen(p2);
-
- nextchar_count[(unsigned char)(p2[0])]++; // the next byte after the group name
-
- if((common[0] != 0) && (strcmp(p,common)==0))
- {
- fwrite(p2,len2,1,f_out);
- fputc(0,f_out); // no phoneme string, it's the same as previous rule
- }
- else
- {
- if((ix < n_rules-1) && (strcmp(p,rules[ix+1])==0))
- {
- common = rules[ix]; // phoneme string is same as next, set as common
- fputc(RULE_PH_COMMON,f_out);
- }
-
- fwrite(p2,len2,1,f_out);
- fputc(RULE_PHONEMES,f_out);
- fwrite(p,len1,1,f_out);
- }
- }
-
-#ifdef LIST_GROUP_INFO
- for(ix=32; ix<256; ix++)
- {
- if(nextchar_count[ix] > 30)
- printf("Group %s %c %d\n",name,ix,nextchar_count[ix]);
- }
-#endif
-} // end of output_rule_group
-
-
-
-static int compile_lettergroup(char *input, FILE *f_out)
-{//=====================================================
- char *p;
- char *p_start;
- int group;
- int ix;
- int n_items;
- int length;
- int max_length = 0;
-
- #define N_LETTERGP_ITEMS 200
- char *items[N_LETTERGP_ITEMS];
- char item_length[N_LETTERGP_ITEMS];
-
- p = input;
- if(!isdigit(p[0]) || !isdigit(p[1]))
- {
- fprintf(f_log,"%5d: Expected 2 digits after '.L'\n",linenum);
- error_count++;
- return(1);
- }
-
- group = atoi(&p[0]);
- if(group >= N_LETTER_GROUPS)
- {
- fprintf(f_log,"%5d: lettergroup out of range (01-%.2d)\n",linenum,N_LETTER_GROUPS-1);
- error_count++;
- return(1);
- }
-
- while(!isspace2(*p)) p++;
-
- fputc(RULE_GROUP_START,f_out);
- fputc(RULE_LETTERGP2,f_out);
- fputc(group + 'A', f_out);
- if(letterGroupsDefined[group] != 0)
- {
- fprintf(f_log,"%5d: lettergroup L%.2d is already defined\n",linenum,group);
- error_count++;
- }
- letterGroupsDefined[group] = 1;
-
- n_items = 0;
- while(n_items < N_LETTERGP_ITEMS)
- {
- while(isspace2(*p)) p++;
- if(*p == 0)
- break;
-
- items[n_items] = p_start = p;
- while((*p & 0xff) > ' ')
- {
- p++;
- }
- *p++ = 0;
- length = p - p_start;
- if(length > max_length)
- max_length = length;
- item_length[n_items++] = length;
- }
-
- // write out the items, longest first
- while(max_length > 1)
- {
- for(ix=0; ix < n_items; ix++)
- {
- if(item_length[ix] == max_length)
- {
- fwrite(items[ix],1,max_length,f_out);
- }
- }
- max_length--;
- }
-
- fputc(RULE_GROUP_END,f_out);
-
- return(0);
-}
-
-
-static int compile_dictrules(FILE *f_in, FILE *f_out, char *fname_temp)
-{//====================================================================
- char *prule;
- unsigned char *p;
- int ix;
- int c;
- int gp;
- FILE *f_temp;
- int n_rules=0;
- int count=0;
- int different;
- const char *prev_rgroup_name;
- unsigned int char_code;
- int compile_mode=0;
- char *buf;
- char buf1[200];
- char *rules[N_RULES];
-
- int n_rgroups = 0;
- RGROUP rgroup[N_RULE_GROUP2];
-
- linenum = 0;
- group_name[0] = 0;
-
- if((f_temp = fopen_log(fname_temp,"wb")) == NULL)
- return(1);
-
- for(;;)
- {
- linenum++;
- buf = fgets(buf1,sizeof(buf1),f_in);
- if(buf != NULL)
- {
- if((p = (unsigned char *)strstr(buf,"//")) != NULL)
- *p = 0;
-
- if(buf[0] == '\r') buf++; // ignore extra \r in \r\n
- }
-
- if((buf == NULL) || (buf[0] == '.'))
- {
- // next .group or end of file, write out the previous group
-
- if(n_rules > 0)
- {
- strcpy(rgroup[n_rgroups].name,group_name);
- rgroup[n_rgroups].start = ftell(f_temp);
- output_rule_group(f_temp,n_rules,rules,group_name);
- rgroup[n_rgroups].length = ftell(f_temp) - rgroup[n_rgroups].start;
- n_rgroups++;
-
- count += n_rules;
- }
- n_rules = 0;
-
- if(compile_mode == 2)
- {
- // end of the character replacements section
- fwrite(&n_rules,1,4,f_out); // write a zero word to terminate the replacemenmt list
- compile_mode = 0;
- }
-
- if(buf == NULL) break; // end of file
-
- if(memcmp(buf,".L",2)==0)
- {
- compile_lettergroup(&buf[2], f_out);
- continue;
- }
-
- if(memcmp(buf,".replace",8)==0)
- {
- compile_mode = 2;
- fputc(RULE_GROUP_START,f_out);
- fputc(RULE_REPLACEMENTS,f_out);
-
- // advance to next word boundary
- while((ftell(f_out) & 3) != 0)
- fputc(0,f_out);
- }
-
- if(memcmp(buf,".group",6)==0)
- {
- compile_mode = 1;
-
- p = (unsigned char *)&buf[6];
- while((p[0]==' ') || (p[0]=='\t')) p++; // Note: Windows isspace(0xe1) gives TRUE !
- ix = 0;
- while((*p > ' ') && (ix < LEN_GROUP_NAME))
- group_name[ix++] = *p++;
- group_name[ix]=0;
-
- if(sscanf(group_name,"0x%x",&char_code)==1)
- {
- // group character is given as a character code (max 16 bits)
- p = (unsigned char *)group_name;
-
- if(char_code > 0x100)
- {
- *p++ = (char_code >> 8);
- }
- *p++ = char_code;
- *p = 0;
- }
-
- if(strlen(group_name) > 2)
- {
- if(utf8_in(&c,group_name) < 2)
- {
- fprintf(f_log,"%5d: Group name longer than 2 bytes (UTF8)",linenum);
- error_count++;
- }
-
- group_name[2] = 0;
- }
- }
-
- continue;
- }
-
- switch(compile_mode)
- {
- case 1: // .group
- prule = compile_rule(buf);
- if((prule != NULL) && (n_rules < N_RULES))
- {
- rules[n_rules++] = prule;
- }
- break;
-
- case 2: // .replace
- {
- int replace1;
- int replace2;
- char *p;
-
- p = buf;
- replace1 = 0;
- replace2 = 0;
- while(isspace2(*p)) p++;
- ix = 0;
- while((unsigned char)(*p) > 0x20) // not space or zero-byte
- {
- p += utf8_in(&c,p);
- replace1 += (c << ix);
- ix += 16;
- }
- while(isspace2(*p)) p++;
- ix = 0;
- while((unsigned char)(*p) > 0x20)
- {
- p += utf8_in(&c,p);
- replace2 += (c << ix);
- ix += 16;
- }
- if(replace1 != 0)
- {
- Write4Bytes(f_out,replace1); // write as little-endian
- Write4Bytes(f_out,replace2); // if big-endian, reverse the bytes in LoadDictionary()
- }
- }
- break;
- }
- }
- fclose(f_temp);
-
- qsort((void *)rgroup,n_rgroups,sizeof(rgroup[0]),(int (__cdecl *)(const void *,const void *))rgroup_sorter);
-
- if((f_temp = fopen(fname_temp,"rb"))==NULL)
- return(2);
-
- prev_rgroup_name = "\n";
-
- for(gp = 0; gp < n_rgroups; gp++)
- {
- fseek(f_temp,rgroup[gp].start,SEEK_SET);
-
- if((different = strcmp(rgroup[gp].name, prev_rgroup_name)) != 0)
- {
- // not the same as the previous group
- if(gp > 0)
- fputc(RULE_GROUP_END,f_out);
- fputc(RULE_GROUP_START,f_out);
- fprintf(f_out, prev_rgroup_name = rgroup[gp].name);
- fputc(0,f_out);
- }
-
- for(ix=rgroup[gp].length; ix>0; ix--)
- {
- c = fgetc(f_temp);
- fputc(c,f_out);
- }
-
- if(different)
- {
- }
- }
- fputc(RULE_GROUP_END,f_out);
- fputc(0,f_out);
-
- fclose(f_temp);
-#if 0
- remove(fname_temp);
-#endif
-
- fprintf(f_log,"\t%d rules, %d groups\n\n",count,n_rgroups);
- return(0);
-} // end of compile_dictrules
-
-
-
-int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, char *fname_err, int flags)
-{//=====================================================================================================
-// fname: space to write the filename in case of error
-// flags: bit 0: include source line number information, for debug purposes.
-
- FILE *f_in;
- FILE *f_out;
- int offset_rules=0;
- int value;
- char fname_in[sizeof(path_home)+45];
- char fname_out[sizeof(path_home)+15];
- char fname_temp[sizeof(path_home)+15];
- char path[sizeof(path_home)+40]; // path_dsource+20
-
- error_count = 0;
- memset(letterGroupsDefined,0,sizeof(letterGroupsDefined));
-
- debug_flag = flags & 1;
-
- if(dsource == NULL)
- dsource = "";
-
- f_log = log;
-//f_log = fopen("log2.txt","w");
- if(f_log == NULL)
- f_log = stderr;
-
- sprintf(path,"%s%s_",dsource,dict_name);
- sprintf(fname_in,"%srules",path);
- f_in = fopen_log(fname_in,"r");
- if(f_in == NULL)
- {
- if(fname_err)
- strcpy(fname_err,fname_in);
- return(-1);
- }
-
- sprintf(fname_out,"%s%c%s_dict",path_home,PATHSEP,dict_name);
- if((f_out = fopen_log(fname_out,"wb+")) == NULL)
- {
- if(fname_err)
- strcpy(fname_err,fname_in);
- return(-1);
- }
- sprintf(fname_temp,"%s%ctemp",path_home,PATHSEP);
-
- transpose_offset = 0;
-
- if(strcmp(dict_name,"ru") == 0)
- {
- // transpose cyrillic alphabet from unicode to iso8859-5
-// transpose_offset = 0x430-0xd0;
- transpose_offset = 0x42f; // range 0x01 to 0x22
- transpose_min = 0x430;
- transpose_max = 0x451;
- }
-
- value = N_HASH_DICT;
- Write4Bytes(f_out,value);
- Write4Bytes(f_out,offset_rules);
-
- compile_dictlist_start();
-
- fprintf(f_log,"Using phonemetable: '%s'\n",phoneme_tab_list[phoneme_tab_number].name);
- compile_dictlist_file(path,"roots");
- if(translator->langopts.listx)
- {
- compile_dictlist_file(path,"list");
- compile_dictlist_file(path,"listx");
- }
- else
- {
- compile_dictlist_file(path,"listx");
- compile_dictlist_file(path,"list");
- }
- compile_dictlist_file(path,"extra");
-
- compile_dictlist_end(f_out);
- offset_rules = ftell(f_out);
-
- fprintf(f_log,"Compiling: '%s'\n",fname_in);
-
- compile_dictrules(f_in,f_out,fname_temp);
- fclose(f_in);
-
- fseek(f_out,4,SEEK_SET);
- Write4Bytes(f_out,offset_rules);
- fclose(f_out);
-
- LoadDictionary(translator, dict_name, 0);
-
- return(error_count);
-} // end of compile_dictionary
-
diff --git a/navit/support/espeak/debug.c b/navit/support/espeak/debug.c
deleted file mode 100644
index 38ea57c99..000000000
--- a/navit/support/espeak/debug.c
+++ /dev/null
@@ -1,74 +0,0 @@
-#include <stdio.h>
-#include <stdarg.h>
-#include "speech.h"
-#include "debug.h"
-
-#ifdef DEBUG_ENABLED
-#include <sys/time.h>
-#include <unistd.h>
-
-static FILE* fd_log=NULL;
-static const char* FILENAME="/tmp/espeak.log";
-
-void debug_init()
-{
- if((fd_log = fopen(FILENAME,"a")) != NULL)
- setvbuf(fd_log, NULL, _IONBF, 0);
-}
-
-void debug_enter(const char* text)
-{
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
-
- // fd_log = fopen(FILENAME,"a");
- if (!fd_log)
- {
- debug_init();
- }
-
- if (fd_log)
- {
- fprintf(fd_log, "%03d.%03dms > ENTER %s\n",(int)(tv.tv_sec%1000), (int)(tv.tv_usec/1000), text);
- // fclose(fd_log);
- }
-}
-
-
-void debug_show(const char *format, ...)
-{
- va_list args;
- va_start(args, format);
- // fd_log = fopen(FILENAME,"a");
- if (!fd_log)
- {
- debug_init();
- }
- if (fd_log)
- {
- vfprintf(fd_log, format, args);
- // fclose(fd_log);
- }
- va_end(args);
-}
-
-void debug_time(const char* text)
-{
- struct timeval tv;
-
- gettimeofday(&tv, NULL);
-
- // fd_log = fopen(FILENAME,"a");
- if (!fd_log)
- {
- debug_init();
- }
- if (fd_log)
- {
- fprintf(fd_log, "%03d.%03dms > %s\n",(int)(tv.tv_sec%1000), (int)(tv.tv_usec/1000), text);
- // fclose(fd_log);
- }
-}
-
-#endif
diff --git a/navit/support/espeak/debug.h b/navit/support/espeak/debug.h
deleted file mode 100644
index c3fb9c920..000000000
--- a/navit/support/espeak/debug.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef DEBUG_H
-#define DEBUG_H
-
-//#define DEBUG_ENABLED
-
-#ifdef DEBUG_ENABLED
-#define ENTER(text) debug_enter(text)
-#define SHOW(format,...) debug_show(format,__VA_ARGS__);
-#define SHOW_TIME(text) debug_time(text);
-extern void debug_enter(const char* text);
-extern void debug_show(const char* format,...);
-extern void debug_time(const char* text);
-
-#else
-
-#ifdef PLATFORM_WINDOWS
-#define SHOW(format) // VC6 doesn't allow "..."
-#else
-#define SHOW(format,...)
-#endif
-#define SHOW_TIME(text)
-#define ENTER(text)
-#endif
-
-
-#endif
diff --git a/navit/support/espeak/dictionary.c b/navit/support/espeak/dictionary.c
deleted file mode 100755
index d7dd3dc65..000000000
--- a/navit/support/espeak/dictionary.c
+++ /dev/null
@@ -1,3490 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#define LOG_TRANSLATE
-
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <wctype.h>
-#include <wchar.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "translate.h"
-
-
-int dictionary_skipwords;
-char dictionary_name[40];
-
-extern char *print_dictionary_flags(unsigned int *flags);
-
-// accented characters which indicate (in some languages) the start of a separate syllable
-//static const unsigned short diereses_list[7] = {L'ä',L'ë',L'ï',L'ö',L'ü',L'ÿ',0};
-static const unsigned short diereses_list[7] = {0xe4,0xeb,0xef,0xf6,0xfc,0xff,0};
-
-// convert characters to an approximate 7 bit ascii equivalent
-// used for checking for vowels
-static unsigned char remove_accent[] = {
-'a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i', // 0c0
-'d','n','o','o','o','o','o', 0, 'o','u','u','u','u','y','t','s', // 0d0
-'a','a','a','a','a','a','a','c','e','e','e','e','i','i','i','i', // 0e0
-'d','n','o','o','o','o','o', 0 ,'o','u','u','u','u','y','t','y', // 0f0
-
-'a','a','a','a','a','a','c','c','c','c','c','c','c','c','d','d', // 100
-'d','d','e','e','e','e','e','e','e','e','e','e','g','g','g','g', // 110
-'g','g','g','g','h','h','h','h','i','i','i','i','i','i','i','i', // 120
-'i','i','i','i','j','j','k','k','k','l','l','l','l','l','l','l', // 130
-'l','l','l','n','n','n','n','n','n','n','n','n','o','o','o','o', // 140
-'o','o','o','o','r','r','r','r','r','r','s','s','s','s','s','s', // 150
-'s','s','t','t','t','t','t','t','u','u','u','u','u','u','u','u', // 160
-'u','u','u','u','w','w','y','y','y','z','z','z','z','z','z','s', // 170
-'b','b','b','b', 0, 0, 'o','c','c','d','d','d','d','d','e','e', // 180
-'e','f','f','g','g','h','i','i','k','k','l','l','m','n','n','o', // 190
-'o','o','o','o','p','p','y', 0, 0, 's','s','t','t','t','t','u', // 1a0
-'u','u','v','y','y','z','z','z','z','z','z','z', 0, 0, 0, 'w', // 1b0
-'t','t','t','k','d','d','d','l','l','l','n','n','n','a','a','i', // 1c0
-'i','o','o','u','u','u','u','u','u','u','u','u','u','e','a','a', // 1d0
-'a','a','a','a','g','g','g','g','k','k','o','o','o','o','z','z', // 1e0
-'j','d','d','d','g','g','w','w','n','n','a','a','a','a','o','o', // 1f0
-
-'a','a','a','a','e','e','e','e','i','i','i','i','o','o','o','o', // 200
-'r','r','r','r','u','u','u','u','s','s','t','t','y','y','h','h', // 210
-'n','d','o','o','z','z','a','a','e','e','o','o','o','o','o','o', // 220
-'o','o','y','y','l','n','t','j','d','q','a','c','c','l','t','s', // 230
-'z', 0 };
-
-
-
-
-void strncpy0(char *to,const char *from, int size)
-{//===============================================
- // strcpy with limit, ensures a zero terminator
- strncpy(to,from,size);
- to[size-1] = 0;
-}
-
-
-static int reverse_word_bytes(int word)
-{//=============================
- // reverse the order of bytes from little-endian to big-endian
-#ifdef ARCH_BIG
- int ix;
- int word2 = 0;
-
- for(ix=0; ix<=24; ix+=8)
- {
- word2 = word2 << 8;
- word2 |= (word >> ix) & 0xff;
- }
- return(word2);
-#else
- return(word);
-#endif
-}
-
-
-int LookupMnem(MNEM_TAB *table, char *string)
-{//==========================================
- while(table->mnem != NULL)
- {
- if(strcmp(string,table->mnem)==0)
- return(table->value);
- table++;
- }
- return(table->value);
-}
-
-
-
-//=============================================================================================
-// Read pronunciation rules and pronunciation lookup dictionary
-//
-//=============================================================================================
-
-
-static void InitGroups(Translator *tr)
-{//===================================
-/* Called after dictionary 1 is loaded, to set up table of entry points for translation rule chains
- for single-letters and two-letter combinations
-*/
-
- int ix;
- char *p;
- char *p_name;
- unsigned int *pw;
- unsigned char c, c2;
- int len;
-
- tr->n_groups2 = 0;
- for(ix=0; ix<256; ix++)
- {
- tr->groups1[ix]=NULL;
- tr->groups2_count[ix]=0;
- tr->groups2_start[ix]=255; // indicates "not set"
- }
- memset(tr->letterGroups,0,sizeof(tr->letterGroups));
-
- p = tr->data_dictrules;
- while(*p != 0)
- {
- if(*p != RULE_GROUP_START)
- {
- fprintf(stderr,"Bad rules data in '%s_dict' at 0x%x\n",dictionary_name,(unsigned int)(p - tr->data_dictrules));
- break;
- }
- p++;
-
- if(p[0] == RULE_REPLACEMENTS)
- {
- pw = (unsigned int *)(((long)p+4) & ~3); // advance to next word boundary
- tr->langopts.replace_chars = pw;
- while(pw[0] != 0)
- {
- pw += 2; // find the end of the replacement list, each entry is 2 words.
- }
- p = (char *)(pw+1);
-
-#ifdef ARCH_BIG
- pw = (unsigned int *)(tr->langopts.replace_chars);
- while(*pw != 0)
- {
- *pw = reverse_word_bytes(*pw);
- pw++;
- *pw = reverse_word_bytes(*pw);
- pw++;
- }
-#endif
- continue;
- }
-
- if(p[0] == RULE_LETTERGP2)
- {
- ix = p[1] - 'A';
- p += 2;
- if((ix >= 0) && (ix < N_LETTER_GROUPS))
- {
- tr->letterGroups[ix] = p;
- }
- }
- else
- {
- len = strlen(p);
- p_name = p;
- c = p_name[0];
-
- p += (len+1);
- if(len == 1)
- {
- tr->groups1[c] = p;
- }
- else
- if(len == 0)
- {
- tr->groups1[0] = p;
- }
- else
- {
- if(tr->groups2_start[c] == 255)
- tr->groups2_start[c] = tr->n_groups2;
-
- tr->groups2_count[c]++;
- tr->groups2[tr->n_groups2] = p;
- c2 = p_name[1];
- tr->groups2_name[tr->n_groups2++] = (c + (c2 << 8));
- }
- }
-
- // skip over all the rules in this group
- while(*p != RULE_GROUP_END)
- {
- p += (strlen(p) + 1);
- }
- p++;
- }
-
-} // end of InitGroups
-
-
-
-int LoadDictionary(Translator *tr, const char *name, int no_error)
-{//===============================================================
- int hash;
- char *p;
- int *pw;
- int length;
- FILE *f;
- unsigned int size;
- char fname[sizeof(path_home)+20];
-
- strcpy(dictionary_name,name); // currently loaded dictionary name
-
- if(no_error) // don't load dictionary, just set the dictionary_name
- return(1);
-
- // Load a pronunciation data file into memory
- // bytes 0-3: offset to rules data
- // bytes 4-7: number of hash table entries
- sprintf(fname,"%s%c%s_dict",path_home,PATHSEP,name);
- size = GetFileLength(fname);
-
- f = fopen(fname,"rb");
- if((f == NULL) || (size <= 0))
- {
- if(no_error == 0)
- {
- fprintf(stderr,"Can't read dictionary file: '%s'\n",fname);
- }
- return(1);
- }
-
- if(tr->data_dictlist != NULL)
- Free(tr->data_dictlist);
-
- tr->data_dictlist = Alloc(size);
- fread(tr->data_dictlist,size,1,f);
- fclose(f);
-
-
- pw = (int *)(tr->data_dictlist);
- length = reverse_word_bytes(pw[1]);
-
- if(size <= (N_HASH_DICT + sizeof(int)*2))
- {
- fprintf(stderr,"Empty _dict file: '%s\n",fname);
- return(2);
- }
-
- if((reverse_word_bytes(pw[0]) != N_HASH_DICT) ||
- (length <= 0) || (length > 0x8000000))
- {
- fprintf(stderr,"Bad data: '%s' (%x length=%x)\n",fname,reverse_word_bytes(pw[0]),length);
- return(2);
- }
- tr->data_dictrules = &(tr->data_dictlist[length]);
-
- // set up indices into data_dictrules
- InitGroups(tr);
- if(tr->groups1[0] == NULL)
- {
- fprintf(stderr,"Error in %s_rules, no default rule group\n",name);
- }
-
- // set up hash table for data_dictlist
- p = &(tr->data_dictlist[8]);
-
- for(hash=0; hash<N_HASH_DICT; hash++)
- {
- tr->dict_hashtab[hash] = p;
- while((length = *p) != 0)
- {
- p += length;
- }
- p++; // skip over the zero which terminates the list for this hash value
- }
-
- return(0);
-} // end of LoadDictionary
-
-
-int HashDictionary(const char *string)
-//====================================
-/* Generate a hash code from the specified string
- This is used to access the dictionary_2 word-lookup dictionary
-*/
-{
- int c;
- int chars=0;
- int hash=0;
-
- while((c = (*string++ & 0xff)) != 0)
- {
- hash = hash * 8 + c;
- hash = (hash & 0x3ff) ^ (hash >> 8); /* exclusive or */
- chars++;
- }
-
- return((hash+chars) & 0x3ff); // a 10 bit hash code
-} // end of HashDictionary
-
-
-
-//=============================================================================================
-// Translate between internal representation of phonemes and a mnemonic form for display
-//
-//=============================================================================================
-
-
-
-char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme)
-/*********************************************************************/
-/* Translate a phoneme string from ascii mnemonics to internal phoneme numbers,
- from 'p' up to next blank .
- Returns advanced 'p'
- outptr contains encoded phonemes, unrecognised phonemes are encoded as 255
- bad_phoneme must point to char array of length 2 of more
-*/
-{
- int ix;
- unsigned char c;
- int count; /* num. of matching characters */
- int max; /* highest num. of matching found so far */
- int max_ph; /* corresponding phoneme with highest matching */
- int consumed;
- unsigned int mnemonic_word;
-
- bad_phoneme[0] = 0;
-
- // skip initial blanks
- while(isspace(*p))
- {
- p++;
- }
-
- while(((c = *p) != 0) && !isspace(c))
- {
- consumed = 0;
-
- switch(c)
- {
- case '|':
- // used to separate phoneme mnemonics if needed, to prevent characters being treated
- // as a multi-letter mnemonic
-
- if((c = p[1]) == '|')
- {
- // treat double || as a word-break symbol, drop through
- // to the default case with c = '|'
- }
- else
- {
- p++;
- break;
- }
-
- default:
- // lookup the phoneme mnemonic, find the phoneme with the highest number of
- // matching characters
- max= -1;
- max_ph= 0;
-
- for(ix=1; ix<n_phoneme_tab; ix++)
- {
- if(phoneme_tab[ix] == NULL)
- continue;
- if(phoneme_tab[ix]->type == phINVALID)
- continue; // this phoneme is not defined for this language
-
- count = 0;
- mnemonic_word = phoneme_tab[ix]->mnemonic;
-
- while(((c = p[count]) > ' ') && (count < 4) &&
- (c == ((mnemonic_word >> (count*8)) & 0xff)))
- count++;
-
- if((count > max) &&
- ((count == 4) || (((mnemonic_word >> (count*8)) & 0xff)==0)))
- {
- max = count;
- max_ph = phoneme_tab[ix]->code;
- }
- }
-
- if(max_ph == 0)
- {
- max_ph = 255; /* not recognised */
- bad_phoneme[0] = *p;
- bad_phoneme[1] = 0;
- }
-
- if(max <= 0)
- max = 1;
- p += (consumed + max);
- *outptr++ = (char)(max_ph);
-
- if(max_ph == phonSWITCH)
- {
- // Switch Language: this phoneme is followed by a text string
- char *p_lang = outptr;
- while(!isspace(c = *p) && (c != 0))
- {
- p++;
- *outptr++ = tolower(c);
- }
- *outptr = 0;
- if(c == 0)
- {
- if(strcmp(p_lang,"en")==0)
- {
- *p_lang = 0; // don't need "en", it's assumed by default
- return(p);
- }
- }
- else
- {
- *outptr++ = '|'; // more phonemes follow, terminate language string with separator
- }
- }
- break;
- }
- }
- /* terminate the encoded string */
- *outptr = 0;
- return(p);
-} // end of EncodePhonemes
-
-
-
-void DecodePhonemes(const char *inptr, char *outptr)
-//==================================================
-// Translate from internal phoneme codes into phoneme mnemonics
-{
- unsigned char phcode;
- unsigned char c;
- unsigned int mnem;
- PHONEME_TAB *ph;
- static const char *stress_chars = "==,,'* ";
-
- while((phcode = *inptr++) > 0)
- {
- if(phcode == 255)
- continue; /* indicates unrecognised phoneme */
- if((ph = phoneme_tab[phcode]) == NULL)
- continue;
-
- if((ph->type == phSTRESS) && (ph->std_length <= 4) && (ph->spect == 0))
- {
- if(ph->std_length > 1)
- *outptr++ = stress_chars[ph->std_length];
- }
- else
- {
- mnem = ph->mnemonic;
-
- while((c = (mnem & 0xff)) != 0)
- {
- *outptr++ = c;
- mnem = mnem >> 8;
- }
- if(phcode == phonSWITCH)
- {
- while(isalpha(*inptr))
- {
- *outptr++ = *inptr++;
- }
- }
- }
- }
- *outptr = 0; /* string terminator */
-} // end of DecodePhonemes
-
-
-
-static void WriteMnemonic(char *phon_out, int *ix, int mnem)
-{//=========================================================
- unsigned char c;
-
- while((c = mnem & 0xff) != 0)
- {
- if((c == '/') && (option_phoneme_variants==0))
- break; // discard phoneme variant indicator
- phon_out[(*ix)++]= c;
- // phon_out[phon_out_ix++]= ipa1[c];
- mnem = mnem >> 8;
- }
-}
-
-
-
-void GetTranslatedPhonemeString(char *phon_out, int n_phon_out)
-{//============================================================
-/* Can be called after a clause has been translated into phonemes, in order
- to display the clause in phoneme mnemonic form.
-*/
-
- int ix;
- int phon_out_ix=0;
- int stress;
- char *p;
- PHONEME_LIST *plist;
-
- static const char *stress_chars = "==,,''";
-
- if(phon_out != NULL)
- {
- for(ix=1; ix<(n_phoneme_list-2) && (phon_out_ix < (n_phon_out - 6)); ix++)
- {
- plist = &phoneme_list[ix];
- if(plist->newword)
- phon_out[phon_out_ix++] = ' ';
-
- if(plist->synthflags & SFLAG_SYLLABLE)
- {
- if((stress = plist->stresslevel) > 1)
- {
- if(stress > 5) stress = 5;
- phon_out[phon_out_ix++] = stress_chars[stress];
- }
- }
- WriteMnemonic(phon_out, &phon_out_ix, plist->ph->mnemonic);
-
- if(plist->synthflags & SFLAG_LENGTHEN)
- {
- WriteMnemonic(phon_out, &phon_out_ix, phoneme_tab[phonLENGTHEN]->mnemonic);
- }
- if((plist->synthflags & SFLAG_SYLLABLE) && (plist->type != phVOWEL))
- {
- // syllablic consonant
- WriteMnemonic(phon_out, &phon_out_ix, phoneme_tab[phonSYLLABIC]->mnemonic);
- }
- if(plist->ph->code == phonSWITCH)
- {
- // the tone_ph field contains a phoneme table number
- p = phoneme_tab_list[plist->tone_ph].name;
- while(*p != 0)
- {
- phon_out[phon_out_ix++] = *p++;
- }
- phon_out[phon_out_ix++] = ' ';
- }
- else
- if(plist->tone_ph > 0)
- {
- WriteMnemonic(phon_out, &phon_out_ix, phoneme_tab[plist->tone_ph]->mnemonic);
- }
- }
-
- if(phon_out_ix >= n_phon_out)
- phon_out_ix = n_phon_out - 1;
- phon_out[phon_out_ix] = 0;
- }
-} // end of GetTranslatedPhonemeString
-
-
-
-//=============================================================================================
-// Is a word Unpronouncable - and so should be spoken as individual letters
-//
-//=============================================================================================
-
-
-
-static int IsLetterGroup(Translator *tr, char *word, int group, int pre)
-{//=====================================================================
- // match the word against a list of utf-8 strings
- char *p;
- char *w;
- int len=0;
-
- p = tr->letterGroups[group];
- if(p == NULL)
- return(0);
-
- while(*p != RULE_GROUP_END)
- {
- if(pre)
- {
- len = strlen(p);
- w = word - len + 1;
- }
- else
- {
- w = word;
- }
- while(*p == *w)
- {
- w++;
- p++;
- }
- if(*p == 0)
- {
- if(pre)
- return(len);
- return(w-word); // matched a complete string
- }
-
- while(*p++ != 0); // skip to end of string
- }
- return(0);
-}
-
-
-static int IsLetter(Translator *tr, int letter, int group)
-{//=======================================================
- int letter2;
-
- if(tr->letter_groups[group] != NULL)
- {
- if(wcschr(tr->letter_groups[group],letter))
- return(1);
- return(0);
- }
-
- if(group > 7)
- return(0);
-
- if(tr->letter_bits_offset > 0)
- {
- if(((letter2 = (letter - tr->letter_bits_offset)) > 0) && (letter2 < 0x80))
- letter = letter2;
- else
- return(0);
- }
- else
- {
- if((letter >= 0xc0) && (letter <= 0x241))
- return(tr->letter_bits[remove_accent[letter-0xc0]] & (1L << group));
- }
-
- if((letter >= 0) && (letter < 0x80))
- return(tr->letter_bits[letter] & (1L << group));
-
- return(0);
-}
-
-
-static int IsVowel(Translator *tr, int letter)
-{//===========================================
- return(IsLetter(tr, letter, 0));
-}
-
-
-
-
-static int Unpronouncable_en(Translator *tr, char *word)
-{//=====================================================
-/* Determines whether a word in 'unpronouncable', i.e. whether it should
- be spoken as individual letters.
-
- This function is language specific.
-*/
-
- int c;
- int vowel_posn=9;
- int index;
- int count;
- int ix;
- int apostrophe=0;
-
- static unsigned char initials_bitmap[86] = {
- 0x00, 0x00, 0x00, 0x00, 0x22, 0x08, 0x00, 0x88, // 0
- 0x20, 0x24, 0x20, 0x80, 0x10, 0x00, 0x00, 0x00,
- 0x00, 0x28, 0x08, 0x00, 0x88, 0x22, 0x04, 0x00, // 16
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x88, 0x22, 0x04, 0x00, 0x02, 0x00, 0x04, // 32
- 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x28, 0x8a, 0x03, 0x00, 0x00, 0x40, 0x00, // 48
- 0x02, 0x00, 0x41, 0xca, 0xbb, 0x06, 0x20, 0x80,
- 0x91, 0x00, 0x00, 0x00, 0x00, 0x20, 0x08, 0x00, // 64
- 0x08, 0x20, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x22, 0x00, 0x01, 0x00, };
-
-
- // words which we pass through to the dictionary, even though they look unpronouncable
- static const char *exceptions[] = {
- "'s ", "st ","nd ","rd ","th ",NULL };
-
- if((*word == ' ') || (*word == 0))
- return(0);
-
- for(ix=0; exceptions[ix] != NULL; ix++)
- {
- // Seemingly uncpronouncable words, but to be looked in the dictionary rules instead
- if(memcmp(word,exceptions[ix],3)==0)
- return(0);
- }
-
- index=0;
- count=0;
- for(;;)
- {
- index += utf8_in(&c,&word[index]);
- count++;
-
- if((c==0) || (c==' '))
- break;
-
- if(IsVowel(tr, c) || (c == 'y'))
- {
- vowel_posn = count;
- break;
- }
-
- if(c == '\'')
- apostrophe = 1;
- else
- if(!IsAlpha(c))
- return(0); // letter (not vowel) outside Latin character range or apostrophe, abort test
- }
- if((vowel_posn > 5) || ((word[0]!='s') && (vowel_posn > 4)))
- return(1); // no vowel, or no vowel in first four letters
-
- /* there is at least one vowel, is the initial letter combination valid ? */
-
- if(vowel_posn < 3)
- return(0); /* vowel in first two letters, OK */
-
- if(apostrophe)
- return(0); // first two letters not a-z, abort test
-
- index = (word[0]-'a') * 26 + (word[1]-'a');
- if(initials_bitmap[index >> 3] & (1L << (index & 7)))
- return(0);
- else
- return(1); /****/
-} /* end of Unpronounceable */
-
-
-
-
-int Unpronouncable(Translator *tr, char *word)
-{//===========================================
-/* Determines whether a word in 'unpronouncable', i.e. whether it should
- be spoken as individual letters.
-
- This function may be language specific. This is a generic version.
-*/
-
- int c;
- int c1=0;
- int vowel_posn=9;
- int index;
- int count;
- int apostrophe=0;
-
- if(tr->translator_name == L('e','n'))
- {
- return(Unpronouncable_en(tr,word));
- }
-
- utf8_in(&c,word);
- if((tr->letter_bits_offset > 0) && (c < 0x241))
- {
- // Latin characters for a language with a non-latin alphabet
- return(0); // so we can re-translate the word as English
- }
-
- if(tr->langopts.param[LOPT_UNPRONOUNCABLE] == 1)
- return(0);
-
- if((*word == ' ') || (*word == 0))
- return(0);
-
- index = 0;
- count = 0;
- for(;;)
- {
- index += utf8_in(&c,&word[index]);
- if((c==0) || (c==' '))
- break;
-
- if(count==0)
- c1 = c;
- count++;
-
- if(IsVowel(tr, c))
- {
- vowel_posn = count; // position of the first vowel
- break;
- }
-
- if(c == '\'')
- apostrophe = 1;
- else
- if(!iswalpha(c))
- return(0); // letter (not vowel) outside a-z range or apostrophe, abort test
- }
-
- if((vowel_posn < 9) && (tr->langopts.param[LOPT_UNPRONOUNCABLE] == 2))
- return(0); // option means allow any word with a vowel
-
- if(c1 == tr->langopts.param[LOPT_UNPRONOUNCABLE])
- vowel_posn--; // disregard this as the initial letter when counting
-
- if(vowel_posn > (tr->langopts.max_initial_consonants+1))
- return(1); // no vowel, or no vowel in first four letters
-
-return(0);
-
-} /* end of Unpronounceable */
-
-
-
-//=============================================================================================
-// Determine the stress pattern of a word
-//
-//=============================================================================================
-
-
-
-static int GetVowelStress(Translator *tr, unsigned char *phonemes, unsigned char *vowel_stress, int *vowel_count, int *stressed_syllable, int control)
-{//====================================================================================================================================================
-// control = 1, set stress to 1 for forced unstressed vowels
- unsigned char phcode;
- PHONEME_TAB *ph;
- unsigned char *ph_out = phonemes;
- int count = 1;
- int max_stress = 0;
- int ix;
- int j;
- int stress = 0;
- int primary_posn = 0;
-
- vowel_stress[0] = 0;
- while(((phcode = *phonemes++) != 0) && (count < (N_WORD_PHONEMES/2)-1))
- {
- if((ph = phoneme_tab[phcode]) == NULL)
- continue;
-
- if((ph->type == phSTRESS) && (ph->spect == 0))
- {
- /* stress marker, use this for the following vowel */
-
- if(phcode == phonSTRESS_PREV)
- {
- /* primary stress on preceeding vowel */
- j = count - 1;
- while((j > 0) && (*stressed_syllable == 0) && (vowel_stress[j] < 4))
- {
- if(vowel_stress[j] != 1)
- {
- // don't promote a phoneme which must be unstressed
- vowel_stress[j] = 4;
-
- if(max_stress < 4)
- {
- max_stress = 4;
- primary_posn = j;
- }
-
- /* reduce any preceding primary stress markers */
- for(ix=1; ix<j; ix++)
- {
- if(vowel_stress[ix] == 4)
- vowel_stress[ix] = 3;
- }
- break;
- }
- j--;
- }
- }
- else
- {
- if((ph->std_length < 4) || (*stressed_syllable == 0))
- {
- stress = ph->std_length;
-
- if(stress > max_stress)
- max_stress = stress;
- }
- }
- continue;
- }
-
- if((ph->type == phVOWEL) && !(ph->phflags & phNONSYLLABIC))
- {
- vowel_stress[count] = (char)stress;
- if((stress >= 4) && (stress >= max_stress))
- {
- primary_posn = count;
- max_stress = stress;
- }
-
- if((stress == 0) && (control & 1) && (ph->phflags & phUNSTRESSED))
- vowel_stress[count] = 1; /* weak vowel, must be unstressed */
-
- count++;
- stress = 0;
- }
- else
- if(phcode == phonSYLLABIC)
- {
- // previous consonant phoneme is syllablic
- vowel_stress[count] = (char)stress;
- if((stress == 0) && (control & 1))
- vowel_stress[count++] = 1; // syllabic consonant, usually unstressed
- }
-
- *ph_out++ = phcode;
- }
- vowel_stress[count] = 0;
- *ph_out = 0;
-
- /* has the position of the primary stress been specified by $1, $2, etc? */
- if(*stressed_syllable > 0)
- {
- if(*stressed_syllable >= count)
- *stressed_syllable = count-1; // the final syllable
-
- vowel_stress[*stressed_syllable] = 4;
- max_stress = 4;
- primary_posn = *stressed_syllable;
- }
-
- if(max_stress == 5)
- {
- // priority stress, replaces any other primary stress marker
- for(ix=1; ix<count; ix++)
- {
- if(vowel_stress[ix] == 4)
- {
- if(tr->langopts.stress_flags & 0x20000)
- vowel_stress[ix] = 0;
- else
- vowel_stress[ix] = 3;
- }
-
- if(vowel_stress[ix] == 5)
- {
- vowel_stress[ix] = 4;
- primary_posn = ix;
- }
- }
- max_stress = 4;
- }
-
- *stressed_syllable = primary_posn;
- *vowel_count = count;
- return(max_stress);
-} // end of GetVowelStress
-
-
-
-static char stress_phonemes[] = {phonSTRESS_U, phonSTRESS_D, phonSTRESS_2, phonSTRESS_3,
- phonSTRESS_P, phonSTRESS_P2, phonSTRESS_TONIC};
-
-
-void ChangeWordStress(Translator *tr, char *word, int new_stress)
-{//==============================================================
- int ix;
- unsigned char *p;
- int max_stress;
- int vowel_count; // num of vowels + 1
- int stressed_syllable=0; // position of stressed syllable
- unsigned char phonetic[N_WORD_PHONEMES];
- unsigned char vowel_stress[N_WORD_PHONEMES/2];
-
- strcpy((char *)phonetic,word);
- max_stress = GetVowelStress(tr, phonetic, vowel_stress, &vowel_count, &stressed_syllable, 0);
-
- if(new_stress >= 4)
- {
- // promote to primary stress
- for(ix=1; ix<vowel_count; ix++)
- {
- if(vowel_stress[ix] >= max_stress)
- {
- vowel_stress[ix] = new_stress;
- break;
- }
- }
- }
- else
- {
- // remove primary stress
- for(ix=1; ix<vowel_count; ix++)
- {
- if(vowel_stress[ix] > new_stress) // >= allows for diminished stress (=1)
- vowel_stress[ix] = new_stress;
- }
- }
-
- // write out phonemes
- ix = 1;
- p = phonetic;
- while(*p != 0)
- {
- if((phoneme_tab[*p]->type == phVOWEL) && !(phoneme_tab[*p]->phflags & phNONSYLLABIC))
- {
- if(vowel_stress[ix] != 0)
- *word++ = stress_phonemes[vowel_stress[ix]];
-
- ix++;
- }
- *word++ = *p++;
- }
- *word = 0;
-} // end of ChangeWordStress
-
-
-
-void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int prev_stress)
-{//=========================================================================================================
-/* Guess stress pattern of word. This is language specific
-
- 'dictionary_flags' has bits 0-3 position of stressed vowel (if > 0)
- or unstressed (if == 7) or syllables 1 and 2 (if == 6)
- bits 8... dictionary flags
-
- If 'tonic' is set (>= 0), replace highest stress by this value.
-
- Parameter used for input and output
-*/
-
- unsigned char phcode;
- unsigned char *p;
- PHONEME_TAB *ph;
- int stress;
- int max_stress;
- int vowel_count; // num of vowels + 1
- int ix;
- int v;
- int v_stress;
- int stressed_syllable; // position of stressed syllable
- int max_stress_posn;
- int unstressed_word = 0;
- char *max_output;
- int final_ph;
- int final_ph2;
- int mnem;
- int mnem2;
- int post_tonic;
- int opt_length;
- int done;
- int stressflags;
-
- unsigned char vowel_stress[N_WORD_PHONEMES/2];
- char syllable_weight[N_WORD_PHONEMES/2];
- char vowel_length[N_WORD_PHONEMES/2];
- unsigned char phonetic[N_WORD_PHONEMES];
-
- static char consonant_types[16] = {0,0,0,1,1,1,1,1,1,1,0,0,0,0,0,0};
-
-
- /* stress numbers STRESS_BASE +
- 0 diminished, unstressed within a word
- 1 unstressed, weak
- 2
- 3 secondary stress
- 4 main stress */
-
- stressflags = tr->langopts.stress_flags;
-
- /* copy input string into internal buffer */
- for(ix=0; ix<N_WORD_PHONEMES; ix++)
- {
- phonetic[ix] = output[ix];
- // check for unknown phoneme codes
- if(phonetic[ix] >= n_phoneme_tab)
- phonetic[ix] = phonSCHWA;
- if(phonetic[ix] == 0)
- break;
- }
- if(ix == 0) return;
- final_ph = phonetic[ix-1];
- final_ph2 = phonetic[ix-2];
-
- max_output = output + (N_WORD_PHONEMES-3); /* check for overrun */
-
- // any stress position marked in the xx_list dictionary ?
- stressed_syllable = (*dictionary_flags) & 0x7;
- if((*dictionary_flags) & 0x8)
- {
- // this indicates a word without a primary stress
- stressed_syllable = (*dictionary_flags) & 0x3;
- unstressed_word = 1;
- }
-
- max_stress = GetVowelStress(tr, phonetic, vowel_stress, &vowel_count, &stressed_syllable, 1);
-
- if((max_stress == 0) && (tr->langopts.stress_flags & 1) && (vowel_count == 2))
- {
- // option: don't stress monosyllables except at end-of-clause
- vowel_stress[1] = 1;
- (*dictionary_flags) |= FLAG_STRESS_END2;
- }
-
- // heavy or light syllables
- ix = 1;
- for(p = phonetic; *p != 0; p++)
- {
- if((phoneme_tab[p[0]]->type == phVOWEL) && !(phoneme_tab[p[0]]->phflags & phNONSYLLABIC))
- {
- int weight = 0;
- int lengthened = 0;
-
- if(phoneme_tab[p[1]]->code == phonLENGTHEN)
- lengthened = 1;
-
- if(lengthened || (phoneme_tab[p[0]]->phflags & phLONG))
- {
- // long vowel, increase syllable weight
- weight++;
- }
- vowel_length[ix] = weight;
-
- if(lengthened) p++; // advance over phonLENGTHEN
-
- if(consonant_types[phoneme_tab[p[1]]->type] && ((phoneme_tab[p[2]]->type != phVOWEL) || (phoneme_tab[p[1]]->phflags & phLONG)))
- {
- // followed by two consonants, a long consonant, or consonant and end-of-word
- weight++;
- }
- syllable_weight[ix] = weight;
- ix++;
- }
- }
-
- switch(tr->langopts.stress_rule)
- {
- case 8:
- // stress on first syllable, unless it is a light syllable
- if(syllable_weight[1] > 0)
- break;
- // else drop through to case 1
- case 1:
- // stress on second syllable
- if((stressed_syllable == 0) && (vowel_count > 2))
- {
- stressed_syllable = 2;
- if(max_stress == 0)
- {
- vowel_stress[stressed_syllable] = 4;
- }
- max_stress = 4;
- }
- break;
-
- case 2:
- // a language with stress on penultimate vowel
-
- if(stressed_syllable == 0)
- {
- /* no explicit stress - stress the penultimate vowel */
- max_stress = 4;
-
- if(vowel_count > 2)
- {
- stressed_syllable = vowel_count - 2;
-
- if(stressflags & 0x300)
- {
- // LANG=Spanish, stress on last vowel if the word ends in a consonant other than 'n' or 's'
- if(phoneme_tab[final_ph]->type != phVOWEL)
- {
- if(stressflags & 0x100)
- {
- stressed_syllable = vowel_count - 1;
- }
- else
- {
- mnem = phoneme_tab[final_ph]->mnemonic;
- mnem2 = phoneme_tab[final_ph2]->mnemonic;
-
- if((mnem == 's') && (mnem2 == 'n'))
- {
- // -ns stress remains on penultimate syllable
- }
- else
- if(((mnem != 'n') && (mnem != 's')) || (phoneme_tab[final_ph2]->type != phVOWEL))
- {
- stressed_syllable = vowel_count - 1;
- }
- }
- }
- }
- if(stressflags & 0x80000)
- {
- // stress on last syllable if it has a long vowel, but previous syllable has a short vowel
- if(vowel_length[vowel_count - 1] > vowel_length[vowel_count - 2])
- {
- stressed_syllable = vowel_count - 1;
- }
- }
-
- if(vowel_stress[stressed_syllable] == 1)
- {
- // but this vowel is explicitly marked as unstressed
- if(stressed_syllable > 1)
- stressed_syllable--;
- else
- stressed_syllable++;
- }
- }
- else
- {
- stressed_syllable = 1;
- }
-
- // only set the stress if it's not already marked explicitly
- if(vowel_stress[stressed_syllable] == 0)
- {
- // don't stress if next and prev syllables are stressed
- if((vowel_stress[stressed_syllable-1] < 4) || (vowel_stress[stressed_syllable+1] < 4))
- vowel_stress[stressed_syllable] = max_stress;
- }
- }
- break;
-
- case 3:
- // stress on last vowel
- if(stressed_syllable == 0)
- {
- /* no explicit stress - stress the final vowel */
- stressed_syllable = vowel_count - 1;
- if(max_stress == 0)
- {
- while(stressed_syllable > 0)
- {
- if(vowel_stress[stressed_syllable] == 0)
- {
- vowel_stress[stressed_syllable] = 4;
- break;
- }
- else
- stressed_syllable--;
- }
- }
- max_stress = 4;
- }
- break;
-
- case 4: // stress on antipenultimate vowel
- if(stressed_syllable == 0)
- {
- stressed_syllable = vowel_count - 3;
- if(stressed_syllable < 1)
- stressed_syllable = 1;
-
- if(max_stress == 0)
- {
- vowel_stress[stressed_syllable] = 4;
- }
- max_stress = 4;
- }
- break;
-
- case 5:
- // LANG=Russian
- if(stressed_syllable == 0)
- {
- /* no explicit stress - guess the stress from the number of syllables */
- static char guess_ru[16] = {0,0,1,1,2,3,3,4,5,6,7,7,8,9,10,11};
- static char guess_ru_v[16] = {0,0,1,1,2,2,3,3,4,5,6,7,7,8,9,10}; // for final phoneme is a vowel
- static char guess_ru_t[16] = {0,0,1,2,3,3,3,4,5,6,7,7,7,8,9,10}; // for final phoneme is an unvoiced stop
-
- stressed_syllable = vowel_count - 3;
- if(vowel_count < 16)
- {
- if(phoneme_tab[final_ph]->type == phVOWEL)
- stressed_syllable = guess_ru_v[vowel_count];
- else
- if(phoneme_tab[final_ph]->type == phSTOP)
- stressed_syllable = guess_ru_t[vowel_count];
- else
- stressed_syllable = guess_ru[vowel_count];
- }
- vowel_stress[stressed_syllable] = 4;
- max_stress = 4;
- }
- break;
-
- case 6: // LANG=hi stress on the last heaviest syllable
- if(stressed_syllable == 0)
- {
- int wt;
- int max_weight = -1;
- int prev_stressed;
-
- // find the heaviest syllable, excluding the final syllable
- for(ix = 1; ix < (vowel_count-1); ix++)
- {
- if(vowel_stress[ix] == 0)
- {
- if((wt = syllable_weight[ix]) >= max_weight)
- {
- max_weight = wt;
- prev_stressed = stressed_syllable;
- stressed_syllable = ix;
- }
- }
- }
-
- if((syllable_weight[vowel_count-1] == 2) && (max_weight< 2))
- {
- // the only double=heavy syllable is the final syllable, so stress this
- stressed_syllable = vowel_count-1;
- }
- else
- if(max_weight <= 0)
- {
- // all syllables, exclusing the last, are light. Stress the first syllable
- stressed_syllable = 1;
- }
-
- vowel_stress[stressed_syllable] = 4;
- max_stress = 4;
- }
- break;
-
- case 7: // LANG=tr, the last syllable for any vowel markes explicitly as unstressed
- if(stressed_syllable == 0)
- {
- stressed_syllable = vowel_count - 1;
- for(ix=1; ix < vowel_count; ix++)
- {
- if(vowel_stress[ix] == 1)
- {
- stressed_syllable = ix-1;
- break;
- }
- }
- vowel_stress[stressed_syllable] = 4;
- max_stress = 4;
- }
- break;
-
- case 9: // mark all as stressed
- for(ix=1; ix<vowel_count; ix++)
- {
- if(vowel_stress[ix] == 0)
- vowel_stress[ix] = 4;
- }
- break;
- }
-
- /* now guess the complete stress pattern */
- if(max_stress < 4)
- stress = 4; /* no primary stress marked, use for 1st syllable */
- else
- stress = 3;
-
-
- if((stressflags & 0x1000) && (vowel_count == 2))
- {
- // Two syllable word, if one syllable has primary stress, then give the other secondary stress
- if(vowel_stress[1] == 4)
- vowel_stress[2] = 3;
- if(vowel_stress[2] == 4)
- vowel_stress[1] = 3;
- }
-#if deleted
- if((stressflags & 0x2000) && (vowel_stress[1] == 0))
- {
- // If there is only one syllable before the primary stress, give it a secondary stress
- if((vowel_count > 2) && (vowel_stress[2] >= 4))
- {
- vowel_stress[1] = 3;
- }
- }
-#endif
-
- done = 0;
- for(v=1; v<vowel_count; v++)
- {
- if(vowel_stress[v] == 0)
- {
- if((stressflags & 0x10) && (stress < 4) && (v == vowel_count-1))
- {
- // flag: don't give secondary stress to final vowel
- }
- else
- if((stressflags & 0x8000) && (done == 0))
- {
- vowel_stress[v] = (char)stress;
- done =1;
- stress = 3; /* use secondary stress for remaining syllables */
- }
- else
- if((vowel_stress[v-1] <= 1) && ((vowel_stress[v+1] <= 1) || ((stress == 4) && (vowel_stress[v+1] <= 2))))
- {
- /* trochaic: give stress to vowel surrounded by unstressed vowels */
-
- if((stress == 3) && (stressflags & 0x20))
- continue; // don't use secondary stress
-
- if((v > 1) && (stressflags & 0x40) && (syllable_weight[v]==0) && (syllable_weight[v+1]>0))
- {
- // don't put secondary stress on a light syllable which is followed by a heavy syllable
- continue;
- }
-
-// should start with secondary stress on the first syllable, or should it count back from
-// the primary stress and put secondary stress on alternate syllables?
- vowel_stress[v] = (char)stress;
- done =1;
- stress = 3; /* use secondary stress for remaining syllables */
- }
- }
- }
-
- if((unstressed_word) && (tonic < 0))
- {
- if(vowel_count <= 2)
- tonic = tr->langopts.unstressed_wd1; /* monosyllable - unstressed */
- else
- tonic = tr->langopts.unstressed_wd2; /* more than one syllable, used secondary stress as the main stress */
- }
-
- max_stress = 0;
- max_stress_posn = 0;
- for(v=1; v<vowel_count; v++)
- {
- if(vowel_stress[v] >= max_stress)
- {
- max_stress = vowel_stress[v];
- max_stress_posn = v;
- }
- }
-
- if(tonic >= 0)
- {
- /* find position of highest stress, and replace it by 'tonic' */
-
- /* don't disturb an explicitly set stress by 'unstress-at-end' flag */
- if((tonic > max_stress) || (max_stress <= 4))
- vowel_stress[max_stress_posn] = (char)tonic;
- max_stress = tonic;
- }
-
-
- /* produce output phoneme string */
- p = phonetic;
- v = 1;
-
- if((ph = phoneme_tab[*p]) != NULL)
- {
-
- if(ph->type == phSTRESS)
- ph = phoneme_tab[p[1]];
-
-#ifdef deleted
- int gap = tr->langopts.word_gap & 0x700;
- if((gap) && (vowel_stress[1] >= 4) && (prev_stress >= 4))
- {
- /* two primary stresses together, insert a short pause */
- *output++ = pause_phonemes[gap >> 8];
- }
- else
-#endif
- if((tr->langopts.vowel_pause & 0x30) && (ph->type == phVOWEL))
- {
- // word starts with a vowel
-
- if((tr->langopts.vowel_pause & 0x20) && (vowel_stress[1] >= 4))
- {
- *output++ = phonPAUSE_NOLINK; // not to be replaced by link
- }
- else
- {
- *output++ = phonPAUSE_VSHORT; // break, but no pause
- }
- }
- }
-
- p = phonetic;
- post_tonic = 0;
- while(((phcode = *p++) != 0) && (output < max_output))
- {
- if((ph = phoneme_tab[phcode]) == NULL)
- continue;
-
-// if(ph->type == phSTRESS)
-// continue;
-
- if(ph->type == phPAUSE)
- {
- tr->prev_last_stress = 0;
- }
- else
- if(((ph->type == phVOWEL) && !(ph->phflags & phNONSYLLABIC)) || (*p == phonSYLLABIC))
- {
- // a vowel, or a consonant followed by a syllabic consonant marker
-
- v_stress = vowel_stress[v];
- tr->prev_last_stress = v_stress;
-
- if(vowel_stress[v-1] >= max_stress)
- post_tonic = 1;
-
- if(v_stress <= 1)
- {
- if((v > 1) && (max_stress >= 4) && (stressflags & 4) && (v == (vowel_count-1)))
- {
- // option: mark unstressed final syllable as diminished
- v_stress = 1;
- }
- else
- if((stressflags & 2) || (v == 1) || (v == (vowel_count-1)))
- {
- // first or last syllable, or option 'don't set diminished stress'
- v_stress = 0;
- }
- else
- if((v == (vowel_count-2)) && (vowel_stress[vowel_count-1] <= 1))
- {
- // penultimate syllable, followed by an unstressed final syllable
- v_stress = 0;
- }
- else
- {
- // unstressed syllable within a word
- if((vowel_stress[v-1] != 1) || ((stressflags & 0x10000) == 0))
- {
- v_stress = 1; /* change from 0 (unstressed) to 1 (diminished stress) */
- vowel_stress[v] = v_stress;
- }
- }
- }
-
- if(v_stress > 0)
- *output++ = stress_phonemes[v_stress]; // mark stress of all vowels except 0 (unstressed)
-
-
- if(vowel_stress[v] > max_stress)
- {
- max_stress = vowel_stress[v];
- }
-
- if((*p == phonLENGTHEN) && ((opt_length = tr->langopts.param[LOPT_IT_LENGTHEN]) & 1))
- {
- // remove lengthen indicator from non-stressed syllables
- int shorten=0;
-
- if(opt_length & 0x10)
- {
- // only allow lengthen indicator on the highest stress syllable in the word
- if(v != max_stress_posn)
- shorten = 1;
- }
- else
- if(v_stress < 4)
- {
- // only allow lengthen indicator if stress >= 4.
- shorten = 1;
- }
-
- if(shorten)
- p++;
- }
-
- if((v_stress >= 4) && (tr->langopts.param[LOPT_IT_LENGTHEN] == 2))
- {
- // LANG=Italian, lengthen penultimate stressed vowels, unless followed by 2 consonants
- if((v == (vowel_count - 2)) && (syllable_weight[v] == 0))
- {
- *output++ = phcode;
- phcode = phonLENGTHEN;
- }
- }
-
- v++;
- }
-
- if(phcode != 1)
- *output++ = phcode;
- }
- *output++ = 0;
-
-} /* end of SetWordStress */
-
-
-
-
-//=============================================================================================
-// Look up a word in the pronunciation rules
-//
-//=============================================================================================
-
-
-#ifdef LOG_TRANSLATE
-static char *DecodeRule(const char *group, char *rule)
-{//==================================================
-/* Convert compiled match template to ascii */
-
- unsigned char rb;
- unsigned char c;
- char *p;
- int ix;
- int match_type;
- int finished=0;
- int value;
- int linenum=0;
- int flags;
- int suffix_char;
- int condition_num=0;
- char buf[60];
- char buf_pre[60];
- char suffix[20];
- static char output[60];
-
- static char symbols[] = {' ',' ',' ',' ',' ',' ',' ',' ',' ',
- '@','&','%','+','#','S','D','Z','A','L',' ',' ',' ',' ',' ','N','K','V',' ','T','X','?','W'};
-
- static char symbols_lg[] = {'A','B','C','H','F','G','Y'};
-
- match_type = 0;
- buf_pre[0] = 0;
- strcpy(buf,group);
- p = &buf[strlen(buf)];
- while(!finished)
- {
- rb = *rule++;
-
- if(rb <= RULE_LINENUM)
- {
- switch(rb)
- {
- case 0:
- case RULE_PHONEMES:
- finished=1;
- break;
- case RULE_PRE:
- match_type = RULE_PRE;
- *p = 0;
- p = buf_pre;
- break;
- case RULE_POST:
- match_type = RULE_POST;
- *p = 0;
- strcat(buf," (");
- p = &buf[strlen(buf)];
- break;
- case RULE_PH_COMMON:
- break;
- case RULE_CONDITION:
- /* conditional rule, next byte gives condition number */
- condition_num = *rule++;
- break;
- case RULE_LINENUM:
- value = (rule[1] & 0xff) - 1;
- linenum = (rule[0] & 0xff) - 1 + (value * 255);
- rule+=2;
- break;
- }
- continue;
- }
-
- if(rb == RULE_ENDING)
- {
- static const char *flag_chars = "ei vtfq t";
- flags = ((rule[0] & 0x7f)<< 8) + (rule[1] & 0x7f);
- suffix_char = 'S';
- if(flags & (SUFX_P >> 8))
- suffix_char = 'P';
- sprintf(suffix,"%c%d",suffix_char,rule[2] & 0x7f);
- rule += 3;
- for(ix=0;ix<9;ix++)
- {
- if(flags & 1)
- sprintf(&suffix[strlen(suffix)],"%c",flag_chars[ix]);
- flags = (flags >> 1);
- }
- strcpy(p,suffix);
- p += strlen(suffix);
- c = ' ';
- }
- else
- if(rb == RULE_LETTERGP)
- {
- c = symbols_lg[*rule++ - 'A'];
- }
- else
- if(rb == RULE_LETTERGP2)
- {
- value = *rule++ - 'A';
- p[0] = 'L';
- p[1] = (value / 10) + '0';
- c = (value % 10) + '0';
-
- if(match_type == RULE_PRE)
- {
- p[0] = c;
- c = 'L';
- }
- p+=2;
- }
- else
- if(rb <= RULE_LAST_RULE)
- c = symbols[rb];
- else
- if(rb == RULE_SPACE)
- c = '_';
- else
- c = rb;
- *p++ = c;
- }
- *p = 0;
-
- p = output;
- if(linenum > 0)
- {
- sprintf(p,"%5d:\t",linenum);
- p += 7;
- }
- if(condition_num > 0)
- {
- sprintf(p,"?%d ",condition_num);
- p = &p[strlen(p)];
- }
- if((ix = strlen(buf_pre)) > 0)
- {
- while(--ix >= 0)
- *p++ = buf_pre[ix];
- *p++ = ')';
- *p++ = ' ';
- }
- *p = 0;
- strcat(p,buf);
- ix = strlen(output);
- while(ix < 8)
- output[ix++]=' ';
- output[ix]=0;
- return(output);
-} /* end of decode_match */
-#endif
-
-
-
-void AppendPhonemes(Translator *tr, char *string, int size, const char *ph)
-{//========================================================================
-/* Add new phoneme string "ph" to "string"
- Keeps count of the number of vowel phonemes in the word, and whether these
- can be stressed syllables. These values can be used in translation rules
-*/
- const char *p;
- unsigned char c;
- int unstress_mark;
- int length;
-
- length = strlen(ph) + strlen(string);
- if(length >= size)
- {
- return;
- }
-
- /* any stressable vowel ? */
- unstress_mark = 0;
- p = ph;
- while((c = *p++) != 0)
- {
- if(c >= n_phoneme_tab) continue;
-
- if(phoneme_tab[c]->type == phSTRESS)
- {
- if(phoneme_tab[c]->std_length < 4)
- unstress_mark = 1;
- }
- else
- {
- if(phoneme_tab[c]->type == phVOWEL)
- {
- if(((phoneme_tab[c]->phflags & phUNSTRESSED) == 0) &&
- (unstress_mark == 0))
- {
- tr->word_stressed_count++;
- }
- unstress_mark = 0;
- tr->word_vowel_count++;
- }
- }
- }
-
- if(string != NULL)
- strcat(string,ph);
-} /* end of AppendPhonemes */
-
-
-
-static void MatchRule(Translator *tr, char *word[], const char *group, char *rule, MatchRecord *match_out, int word_flags, int dict_flags)
-{//=======================================================================================================================================
-/* Checks a specified word against dictionary rules.
- Returns with phoneme code string, or NULL if no match found.
-
- word (indirect) points to current character group within the input word
- This is advanced by this procedure as characters are consumed
-
- group: the initial characters used to choose the rules group
-
- rule: address of dictionary rule data for this character group
-
- match_out: returns best points score
-
- word_flags: indicates whether this is a retranslation after a suffix has been removed
-*/
-
- unsigned char rb; // current instuction from rule
- unsigned char letter; // current letter from input word, single byte
- int letter_w; // current letter, wide character
- int letter_xbytes; // number of extra bytes of multibyte character (num bytes - 1)
- unsigned char last_letter;
-
- char *pre_ptr;
- char *post_ptr; /* pointer to first character after group */
-
- char *rule_start; /* start of current match template */
- char *p;
-
- int match_type; /* left, right, or consume */
- int failed;
- int consumed; /* number of letters consumed from input */
- int count; /* count through rules in the group */
- int syllable_count;
- int vowel;
- int letter_group;
- int distance_right;
- int distance_left;
- int lg_pts;
- int n_bytes;
- int add_points;
-
- MatchRecord match;
- static MatchRecord best;
-
- int total_consumed; /* letters consumed for best match */
- int group_length;
-
- unsigned char condition_num;
- char *common_phonemes; /* common to a group of entries */
-
-
-
- if(rule == NULL)
- {
- match_out->points = 0;
- (*word)++;
- return;
- }
-
-
- total_consumed = 0;
- count = 0;
- common_phonemes = NULL;
- match_type = 0;
-
- best.points = 0;
- best.phonemes = "";
- best.end_type = 0;
- best.del_fwd = NULL;
-
- group_length = strlen(group);
-
- /* search through dictionary rules */
- while(rule[0] != RULE_GROUP_END)
- {
- match_type=0;
- consumed = 0;
- letter = 0;
- distance_right= -6; /* used to reduce points for matches further away the current letter */
- distance_left= -2;
- count++;
-
- match.points = 1;
- match.end_type = 0;
- match.del_fwd = NULL;
-
- pre_ptr = *word;
- post_ptr = *word + group_length;
-
- /* work through next rule until end, or until no-match proved */
- rule_start = rule;
- failed = 0;
- while(!failed)
- {
- rb = *rule++;
-
- if(rb <= RULE_LINENUM)
- {
- switch(rb)
- {
- case 0: // no phoneme string for this rule, use previous common rule
- if(common_phonemes != NULL)
- {
- match.phonemes = common_phonemes;
- while(((rb = *match.phonemes++) != 0) && (rb != RULE_PHONEMES))
- {
- if(rb == RULE_CONDITION)
- match.phonemes++; // skip over condition number
- }
- }
- else
- {
- match.phonemes = "";
- }
- rule--; // so we are still pointing at the 0
- failed=2; // matched OK
- break;
- case RULE_PRE:
- match_type = RULE_PRE;
- break;
- case RULE_POST:
- match_type = RULE_POST;
- break;
- case RULE_PHONEMES:
- match.phonemes = rule;
- failed=2; // matched OK
- break;
- case RULE_PH_COMMON:
- common_phonemes = rule;
- break;
- case RULE_CONDITION:
- /* conditional rule, next byte gives condition number */
- condition_num = *rule++;
-
- if(condition_num >= 32)
- {
- // allow the rule only if the condition number is NOT set
- if((tr->dict_condition & (1L << (condition_num-32))) != 0)
- failed = 1;
- }
- else
- {
- // allow the rule only if the condition number is set
- if((tr->dict_condition & (1L << condition_num)) == 0)
- failed = 1;
- }
-
- if(!failed)
- match.points++; // add one point for a matched conditional rule
- break;
- case RULE_LINENUM:
- rule+=2;
- break;
- }
- continue;
- }
-
- add_points = 0;
-
- switch(match_type)
- {
- case 0:
- /* match and consume this letter */
- last_letter = letter;
- letter = *post_ptr++;
-
- if((letter == rb) || ((letter==(unsigned char)REPLACED_E) && (rb=='e')))
- {
- add_points = 21;
- consumed++;
- }
- else
- failed = 1;
- break;
-
-
- case RULE_POST:
- /* continue moving fowards */
- distance_right += 6;
- if(distance_right > 18)
- distance_right = 19;
- last_letter = letter;
- letter_xbytes = utf8_in(&letter_w,post_ptr)-1;
- letter = *post_ptr++;
-
- switch(rb)
- {
- case RULE_LETTERGP:
- letter_group = *rule++ - 'A';
- if(IsLetter(tr, letter_w, letter_group))
- {
- lg_pts = 20;
- if(letter_group==2)
- lg_pts = 19; // fewer points for C, general consonant
- add_points = (lg_pts-distance_right);
- post_ptr += letter_xbytes;
- }
- else
- failed = 1;
- break;
-
- case RULE_LETTERGP2: // match against a list of utf-8 strings
- letter_group = *rule++ - 'A';
- if((n_bytes = IsLetterGroup(tr, post_ptr-1,letter_group,0)) >0)
- {
- add_points = (20-distance_right);
- post_ptr += (n_bytes-1);
- }
- else
- failed =1;
- break;
-
- case RULE_NOTVOWEL:
- if(!IsLetter(tr, letter_w,0))
- {
- add_points = (20-distance_right);
- post_ptr += letter_xbytes;
- }
- else
- failed = 1;
- break;
-
- case RULE_DIGIT:
- if(IsDigit(letter_w))
- {
- add_points = (20-distance_right);
- post_ptr += letter_xbytes;
- }
- else
- if(tr->langopts.tone_numbers)
- {
- // also match if there is no digit
- add_points = (20-distance_right);
- post_ptr--;
- }
- else
- failed = 1;
- break;
-
- case RULE_NONALPHA:
- if(!iswalpha(letter_w))
- {
- add_points = (21-distance_right);
- post_ptr += letter_xbytes;
- }
- else
- failed = 1;
- break;
-
- case RULE_DOUBLE:
- if(letter == last_letter)
- add_points = (21-distance_right);
- else
- failed = 1;
- break;
-
- case RULE_ALT1:
- if(dict_flags & FLAG_ALT_TRANS)
- add_points = 1;
- else
- failed = 1;
- break;
-
- case '-':
- if((letter == '-') || ((letter == ' ') && (word_flags & FLAG_HYPHEN_AFTER)))
- {
- add_points = (22-distance_right); // one point more than match against space
- }
- else
- failed = 1;
- break;
-
- case RULE_SYLLABLE:
- {
- /* more than specified number of vowel letters to the right */
- char *p = post_ptr + letter_xbytes;
-
- syllable_count = 1;
- while(*rule == RULE_SYLLABLE)
- {
- rule++;
- syllable_count+=1; /* number of syllables to match */
- }
- vowel = 0;
- while(letter_w != RULE_SPACE)
- {
- if((vowel==0) && IsLetter(tr, letter_w,LETTERGP_VOWEL2))
- {
- // this is counting vowels which are separated by non-vowels
- syllable_count--;
- }
- vowel = IsLetter(tr, letter_w,LETTERGP_VOWEL2);
- p += utf8_in(&letter_w,p);
- }
- if(syllable_count <= 0)
- add_points = (19-distance_right);
- else
- failed = 1;
- }
- break;
-
- case RULE_NOVOWELS:
- {
- char *p = post_ptr + letter_xbytes;
- while(letter_w != RULE_SPACE)
- {
- if(IsLetter(tr, letter_w,LETTERGP_VOWEL2))
- {
- failed = 1;
- break;
- }
- p += utf8_in(&letter_w,p);
- }
- if(!failed)
- add_points = (19-distance_right);
- }
- break;
-
- case RULE_INC_SCORE:
- add_points = 20; // force an increase in points
- break;
-
- case RULE_DEL_FWD:
- // find the next 'e' in the word and replace by ''
- for(p = *word + group_length; *p != ' '; p++)
- {
- if(*p == 'e')
- {
- match.del_fwd = p;
- break;
- }
- }
- break;
-
- case RULE_ENDING:
- // next 3 bytes are a (non-zero) ending type. 2 bytes of flags + suffix length
- match.end_type = (rule[0] << 16) + ((rule[1] & 0x7f) << 8) + (rule[2] & 0x7f);
- rule += 3;
- break;
-
- case RULE_NO_SUFFIX:
- if(word_flags & FLAG_SUFFIX_REMOVED)
- failed = 1; // a suffix has been removed
- else
- add_points = 1;
- break;
-
- default:
- if(letter == rb)
- {
- if(letter == RULE_SPACE)
- add_points = (21-distance_right);
- else
- add_points = (21-distance_right);
- }
- else
- failed = 1;
- break;
- }
- break;
-
-
- case RULE_PRE:
- /* match backwards from start of current group */
- distance_left += 2;
- if(distance_left > 18)
- distance_left = 19;
-
- last_letter = *pre_ptr;
- pre_ptr--;
- letter_xbytes = utf8_in2(&letter_w,pre_ptr,1)-1;
- letter = *pre_ptr;
-
- switch(rb)
- {
- case RULE_LETTERGP:
- letter_group = *rule++ - 'A';
- if(IsLetter(tr, letter_w,letter_group))
- {
- lg_pts = 20;
- if(letter_group==2)
- lg_pts = 19; // fewer points for C, general consonant
- add_points = (lg_pts-distance_left);
- pre_ptr -= letter_xbytes;
- }
- else
- failed = 1;
- break;
-
- case RULE_LETTERGP2: // match against a list of utf-8 strings
- letter_group = *rule++ - 'A';
- if((n_bytes = IsLetterGroup(tr, pre_ptr,letter_group,1)) >0)
- {
- add_points = (20-distance_right);
- pre_ptr -= (n_bytes-1);
- }
- else
- failed =1;
- break;
-
- case RULE_NOTVOWEL:
- if(!IsLetter(tr, letter_w,0))
- {
- add_points = (20-distance_left);
- pre_ptr -= letter_xbytes;
- }
- else
- failed = 1;
- break;
-
- case RULE_DOUBLE:
- if(letter == last_letter)
- add_points = (21-distance_left);
- else
- failed = 1;
- break;
-
- case RULE_DIGIT:
- if(IsDigit(letter_w))
- {
- add_points = (21-distance_left);
- pre_ptr -= letter_xbytes;
- }
- else
- failed = 1;
- break;
-
- case RULE_NONALPHA:
- if(!iswalpha(letter_w))
- {
- add_points = (21-distance_right);
- pre_ptr -= letter_xbytes;
- }
- else
- failed = 1;
- break;
-
- case RULE_SYLLABLE:
- /* more than specified number of vowels to the left */
- syllable_count = 1;
- while(*rule == RULE_SYLLABLE)
- {
- rule++;
- syllable_count++; /* number of syllables to match */
- }
- if(syllable_count <= tr->word_vowel_count)
- add_points = (19-distance_left);
- else
- failed = 1;
- break;
-
- case RULE_STRESSED:
- if(tr->word_stressed_count > 0)
- add_points = 19;
- else
- failed = 1;
- break;
-
- case RULE_NOVOWELS:
- {
- char *p = pre_ptr - letter_xbytes - 1;
- while(letter_w != RULE_SPACE)
- {
- if(IsLetter(tr, letter_w,LETTERGP_VOWEL2))
- {
- failed = 1;
- break;
- }
- p -= utf8_in2(&letter_w,p,1);
- }
- if(!failed)
- add_points = 3;
- }
- break;
-
- case RULE_IFVERB:
- if(tr->expect_verb)
- add_points = 1;
- else
- failed = 1;
- break;
-
- case RULE_CAPITAL:
- if(word_flags & FLAG_FIRST_UPPER)
- add_points = 1;
- else
- failed = 1;
- break;
-
- case '.':
- // dot in pre- section, match on any dot before this point in the word
- for(p=pre_ptr; *p != ' '; p--)
- {
- if(*p == '.')
- {
- add_points = 50;
- break;
- }
- }
- if(*p == ' ')
- failed = 1;
- break;
-
- case '-':
- if((letter == '-') || ((letter == ' ') && (word_flags & FLAG_HYPHEN)))
- {
- add_points = (22-distance_right); // one point more than match against space
- }
- else
- failed = 1;
- break;
-
- default:
- if(letter == rb)
- {
- if(letter == RULE_SPACE)
- add_points = 4;
- else
- add_points = (21-distance_left);
- }
- else
- failed = 1;
- break;
- }
- break;
- }
-
- if(failed == 0)
- match.points += add_points;
- }
-
- if(failed == 2)
- {
- /* matched OK, is this better than the last best match ? */
- if(match.points >= best.points)
- {
- memcpy(&best,&match,sizeof(match));
- total_consumed = consumed;
- }
-
-#ifdef LOG_TRANSLATE
- if((option_phonemes == 2) && (match.points > 0) && ((word_flags & FLAG_NO_TRACE) == 0))
- {
- // show each rule that matches, and it's points score
- int pts;
- char decoded_phonemes[80];
-
- // note: 'count' contains the rule number, if we want to include it
- pts = match.points;
- if(group_length > 1)
- pts += 35; // to account for an extra letter matching
- DecodePhonemes(match.phonemes,decoded_phonemes);
- fprintf(f_trans,"%3d\t%s [%s]\n",pts,DecodeRule(group,rule_start),decoded_phonemes);
- }
-#endif
-
- }
-
- /* skip phoneme string to reach start of next template */
- while(*rule++ != 0);
- }
-
-#ifdef LOG_TRANSLATE
- if((option_phonemes == 2) && ((word_flags & FLAG_NO_TRACE)==0))
- {
- if(group_length <= 1)
- fprintf(f_trans,"\n");
- }
-#endif
-
- /* advance input data pointer */
- total_consumed += group_length;
- if(total_consumed == 0)
- total_consumed = 1; /* always advance over 1st letter */
-
- *word += total_consumed;
-
- if(best.points == 0)
- best.phonemes = "";
- memcpy(match_out,&best,sizeof(MatchRecord));
-} /* end of MatchRule */
-
-
-
-
-int TranslateRules(Translator *tr, char *p_start, char *phonemes, int ph_size, char *end_phonemes, int word_flags, unsigned int *dict_flags)
-{//=====================================================================================================================================
-/* Translate a word bounded by space characters
- Append the result to 'phonemes' and any standard prefix/suffix in 'end_phonemes' */
-
- unsigned char c, c2;
- unsigned int c12;
- int wc=0;
- int wc_prev;
- int wc_bytes;
- char *p2; /* copy of p for use in double letter chain match */
- int found;
- int g; /* group chain number */
- int g1; /* first group for this letter */
- int n;
- int letter;
- int any_alpha=0;
- int ix;
- unsigned int digit_count=0;
- char *p;
- int dict_flags0=0;
- MatchRecord match1;
- MatchRecord match2;
- char ph_buf[40];
- char word_copy[N_WORD_BYTES];
- static const char str_pause[2] = {phonPAUSE_NOLINK,0};
-
- char group_name[4];
-
- if(tr->data_dictrules == NULL)
- return(0);
-
- if(dict_flags != NULL)
- dict_flags0 = dict_flags[0];
-
- for(ix=0; ix<(N_WORD_BYTES-1);)
- {
- c = p_start[ix];
- word_copy[ix++] = c;
- if(c == 0)
- break;
- }
- word_copy[ix] = 0;
-
-
-#ifdef LOG_TRANSLATE
- if((option_phonemes == 2) && ((word_flags & FLAG_NO_TRACE)==0))
- {
- char wordbuf[120];
- int ix;
-
- for(ix=0; ((c = p_start[ix]) != ' ') && (c != 0); ix++)
- {
- wordbuf[ix] = c;
- }
- wordbuf[ix] = 0;
- fprintf(f_trans,"Translate '%s'\n",wordbuf);
- }
-#endif
-
- p = p_start;
- tr->word_vowel_count = 0;
- tr->word_stressed_count = 0;
-
- if(end_phonemes != NULL)
- end_phonemes[0] = 0;
-
- while(((c = *p) != ' ') && (c != 0))
- {
- wc_prev = wc;
- wc_bytes = utf8_in(&wc,p);
- if(IsAlpha(wc))
- any_alpha++;
-
- n = tr->groups2_count[c];
- if(IsDigit(wc) && ((tr->langopts.tone_numbers == 0) || !any_alpha))
- {
- // lookup the number in *_list not *_rules
- char string[8];
- char buf[40];
- string[0] = '_';
- memcpy(&string[1],p,wc_bytes);
- string[1+wc_bytes] = 0;
- Lookup(tr, string,buf);
- if(++digit_count >= 2)
- {
- strcat(buf,str_pause);
- digit_count=0;
- }
- AppendPhonemes(tr,phonemes,ph_size,buf);
- p += wc_bytes;
- continue;
- }
- else
- {
- digit_count = 0;
- found = 0;
-
- if(n > 0)
- {
- /* there are some 2 byte chains for this initial letter */
- c2 = p[1];
- c12 = c + (c2 << 8); /* 2 characters */
-
- g1 = tr->groups2_start[c];
- for(g=g1; g < (g1+n); g++)
- {
- if(tr->groups2_name[g] == c12)
- {
- found = 1;
-
- group_name[0] = c;
- group_name[1] = c2;
- group_name[2] = 0;
- p2 = p;
- MatchRule(tr, &p2, group_name, tr->groups2[g], &match2, word_flags, dict_flags0);
- if(match2.points > 0)
- match2.points += 35; /* to acount for 2 letters matching */
-
- /* now see whether single letter chain gives a better match ? */
- group_name[1] = 0;
- MatchRule(tr, &p, group_name, tr->groups1[c], &match1, word_flags, dict_flags0);
-
- if(match2.points >= match1.points)
- {
- // use match from the 2-letter group
- memcpy(&match1,&match2,sizeof(MatchRecord));
- p = p2;
- }
- }
- }
- }
-
- if(!found)
- {
- /* alphabetic, single letter chain */
- group_name[0] = c;
- group_name[1] = 0;
-
- if(tr->groups1[c] != NULL)
- MatchRule(tr, &p, group_name, tr->groups1[c], &match1, word_flags, dict_flags0);
- else
- {
- // no group for this letter, use default group
- MatchRule(tr, &p, "", tr->groups1[0], &match1, word_flags, dict_flags0);
-
- if((match1.points == 0) && ((option_sayas & 0x10) == 0))
- {
- n = utf8_in(&letter,p-1)-1;
-
- if(tr->letter_bits_offset > 0)
- {
- // not a Latin alphabet, switch to the default Latin alphabet language
- if((letter <= 0x241) && iswalpha(letter))
- {
- sprintf(phonemes,"%c%s",phonSWITCH,tr->langopts.ascii_language);
- return(0);
- }
- }
-#ifdef deleted
-// can't switch to a tone language, because the tone-phoneme numbers are not valid for the original language
- if((letter >= 0x4e00) && (letter < 0xa000) && (tr->langopts.ideographs != 1))
- {
- // Chinese ideogram
- sprintf(phonemes,"%czh",phonSWITCH);
- return(0);
- }
-#endif
-
- // is it a bracket ?
- if(IsBracket(letter))
- {
- if(pre_pause < 4)
- pre_pause = 4;
- }
-
- // no match, try removing the accent and re-translating the word
- if((letter >= 0xc0) && (letter <= 0x241) && ((ix = remove_accent[letter-0xc0]) != 0))
- {
- // within range of the remove_accent table
- if((p[-2] != ' ') || (p[n] != ' '))
- {
- // not the only letter in the word
- p2 = p-1;
- p[-1] = ix;
- while((p[0] = p[n]) != ' ') p++;
- while(n-- > 0) *p++ = ' '; // replacement character must be no longer than original
-
- if(tr->langopts.param[LOPT_DIERESES] && (lookupwchar(diereses_list,letter) > 0))
- {
- // vowel with dieresis, replace and continue from this point
- p = p2;
- continue;
- }
-
- phonemes[0] = 0; // delete any phonemes which have been produced so far
- p = p_start;
- tr->word_vowel_count = 0;
- tr->word_stressed_count = 0;
- continue; // start again at the beginning of the word
- }
- }
- else
- if((letter >= 0x3200) && (letter < 0xa700) && (end_phonemes != NULL))
- {
- // ideograms
- // outside the range of the accent table, speak the unknown symbol sound
- Lookup(tr, "_??", ph_buf);
- match1.phonemes = ph_buf;
- match1.points = 1;
- p += (wc_bytes-1);
- }
- }
- }
-
- if(match1.points == 0)
- {
- if((wc >= 0x300) && (wc <= 0x36f))
- {
- // combining accent inside a word, ignore
- }
- else
- if(IsAlpha(wc))
- {
- if((any_alpha > 1) || (p[wc_bytes-1] > ' '))
- {
- // an unrecognised character in a word, abort and then spell the word
- phonemes[0] = 0;
- if(dict_flags != NULL)
- dict_flags[0] |= FLAG_SPELLWORD;
- break;
- }
- }
- else
- {
- LookupLetter(tr, wc, -1, ph_buf);
- if(ph_buf[0])
- {
- match1.phonemes = ph_buf;
- match1.points = 1;
- }
- }
- p += (wc_bytes-1);
- }
- else
- {
- tr->phonemes_repeat_count = 0;
- }
- }
- }
-
- if(match1.phonemes == NULL)
- match1.phonemes = "";
-
- if(match1.points > 0)
- {
- if((match1.phonemes[0] == phonSWITCH) && ((word_flags & FLAG_DONT_SWITCH_TRANSLATOR)==0))
- {
- // an instruction to switch language, return immediately so we can re-translate
- strcpy(phonemes,match1.phonemes);
- return(0);
- }
-
- if((match1.end_type != 0) && (end_phonemes != NULL))
- {
- /* a standard ending has been found, re-translate the word without it */
- if((match1.end_type & SUFX_P) && (word_flags & FLAG_NO_PREFIX))
- {
- // ignore the match on a prefix
- }
- else
- {
- if((match1.end_type & SUFX_P) && ((match1.end_type & 0x7f) == 0))
- {
- // no prefix length specified
- match1.end_type |= p - p_start;
- }
- strcpy(end_phonemes,match1.phonemes);
- memcpy(p_start,word_copy,strlen(word_copy));
- return(match1.end_type);
- }
- }
- if(match1.del_fwd != NULL)
- *match1.del_fwd = REPLACED_E;
- AppendPhonemes(tr,phonemes,ph_size,match1.phonemes);
- }
- }
-
- // any language specific changes ?
- ApplySpecialAttribute(tr,phonemes,dict_flags0);
- memcpy(p_start,word_copy,strlen(word_copy));
-
- return(0);
-} /* end of TranslateRules */
-
-
-void ApplySpecialAttribute2(Translator *tr, char *phonemes, int dict_flags)
-{//========================================================================
- // apply after the translation is complete
- int ix;
- int len;
- char *p;
-
- len = strlen(phonemes);
-
- switch(tr->translator_name)
- {
- case L('i','t'):
- for(ix=0; ix<(len-1); ix++)
- {
- if(phonemes[ix] == phonSTRESS_P)
- {
- p = &phonemes[ix+1];
- if((dict_flags & FLAG_ALT2_TRANS) != 0)
- {
- if(*p == PhonemeCode('E'))
- *p = PhonemeCode('e');
- if(*p == PhonemeCode('O'))
- *p = PhonemeCode('o');
- }
- else
- {
- if(*p == PhonemeCode('e'))
- *p = PhonemeCode('E');
- if(*p == PhonemeCode('o'))
- *p = PhonemeCode('O');
- }
- break;
- }
- }
- break;
- }
-} // end of ApplySpecialAttribute2
-
-
-void ApplySpecialAttribute(Translator *tr, char *phonemes, int dict_flags)
-{//=======================================================================
-// Amend the translated phonemes according to an attribute which is specific for the language.
- int len;
- int ix;
- char *p_end;
- int phoneme_1;
-
- if((dict_flags & (FLAG_ALT_TRANS | FLAG_ALT2_TRANS)) == 0)
- return;
-
- len = strlen(phonemes);
- p_end = &phonemes[len-1];
-
- switch(tr->translator_name)
- {
- case L('d','e'):
- if(p_end[0] == PhonemeCode2('i',':'))
- {
- // words ends in ['i:], change to [=I@]
- p_end[-1] = phonSTRESS_PREV;
- p_end[0] = PhonemeCode('I');
- p_end[1] = phonSCHWA;
- p_end[2] = 0;
- }
- break;
-
- case L('p','t'):
- phoneme_1 = PhonemeCode('o');
- for(ix=0; ix<(len-1); ix++)
- {
- if(phonemes[ix] == phoneme_1)
- {
- phonemes[ix] = PhonemeCode('O');
- break;
- }
- }
- break;
-
- case L('r','o'):
- if(p_end[0] == PhonemeCode('j'))
- {
- // word end in [j], change to ['i]
- p_end[0] = phonSTRESS_P;
- p_end[1] = PhonemeCode('i');
- p_end[2] = 0;
- }
- break;
- }
-} // end of ApplySpecialAttribute
-
-
-
-//=============================================================================================
-// Look up a word in the pronunciation dictionary list
-// - exceptions which override the usual pronunciation rules, or which give a word
-// special properties, such as pronounce as unstressed
-//=============================================================================================
-
-// common letter pairs, encode these as a single byte
-static const short pairs_ru[] = {
-0x010c, // ла 21052 0x23
-0x010e, // на 18400
-0x0113, // та 14254
-0x0301, // ав 31083
-0x030f, // ов 13420
-0x060e, // не 21798
-0x0611, // ре 19458
-0x0903, // ви 16226
-0x0b01, // ак 14456
-0x0b0f, // ок 17836
-0x0c01, // ал 13324
-0x0c09, // ил 16877
-0x0e01, // ан 15359
-0x0e06, // ен 13543 0x30
-0x0e09, // ин 17168
-0x0e0e, // нн 15973
-0x0e0f, // он 22373
-0x0e1c, // ын 15052
-0x0f03, // во 24947
-0x0f11, // ро 13552
-0x0f12, // Ñо 16368
-0x100f, // оп 19054
-0x1011, // рп 17067
-0x1101, // ар 23967
-0x1106, // ер 18795
-0x1109, // ир 13797
-0x110f, // ор 21737
-0x1213, // Ñ‚Ñ 25076
-0x1220, // ÑÑ 14310
-0x7fff};
-//0x040f ог 12976
-//0x1306 ет 12826
-//0x0f0d мо 12688
-
-
-int TransposeAlphabet(char *text, int offset, int min, int max)
-{//============================================================
-// transpose cyrillic alphabet (for example) into ascii (single byte) character codes
-// return: number of bytes, bit 6: 1=used compression
- int c;
- int c2;
- int ix;
- char *p = text;
- char *p2 = text;
- int all_alpha=1;
- int bits;
- int acc;
-
- do {
- p += utf8_in(&c,p);
- if((c >= min) && (c <= max))
- {
- *p2++ = c - offset;
- }
- else
- if(c != 0)
- {
- p2 += utf8_out(c,p2);
- all_alpha=0;
- }
- } while (c != 0);
- *p2 = 0;
-
- if(all_alpha)
- {
- // compress to 6 bits per character
- acc=0;
- bits=0;
-
- p = text;
- p2 = text;
- while((c = *p++) != 0)
- {
- c2 = c + (*p << 8);
- for(ix=0; c2 >= pairs_ru[ix]; ix++)
- {
- if(c2 == pairs_ru[ix])
- {
- // found an encoding for a 2-character pair
- c = ix + 0x23; // 2-character codes start at 0x23
- p++;
- break;
- }
- }
- acc = (acc << 6) + (c & 0x3f);
- bits += 6;
-
- if(bits >= 8)
- {
- bits -= 8;
- *p2++ = (acc >> bits);
- }
- }
- if(bits > 0)
- {
- *p2++ = (acc << (8-bits));
- }
- *p2 = 0;
- return((p2 - text) | 0x40); // bit 6 indicates compressed characters
- }
- return(p2 - text);
-} // end of TransposeAlphabet
-
-
-
-
-static const char *LookupDict2(Translator *tr, const char *word, const char *word2,
- char *phonetic, unsigned int *flags, int end_flags, WORD_TAB *wtab)
-//=====================================================================================
-/* Find an entry in the word_dict file for a specified word.
- Returns NULL if no match, else returns 'word_end'
-
- word zero terminated word to match
- word2 pointer to next word(s) in the input text (terminated by space)
-
- flags: returns dictionary flags which are associated with a matched word
-
- end_flags: indicates whether this is a retranslation after removing a suffix
-*/
-{
- char *p;
- char *next;
- int hash;
- int phoneme_len;
- int wlen;
- unsigned char flag;
- unsigned int dictionary_flags;
- unsigned int dictionary_flags2;
- int condition_failed=0;
- int n_chars;
- int no_phonemes;
- int skipwords;
- int ix;
- const char *word_end;
- const char *word1;
- int wflags = 0;
- char word_buf[N_WORD_BYTES];
-
- if(wtab != NULL)
- {
- wflags = wtab->flags;
- }
-
- word1 = word;
- if(tr->transpose_offset > 0)
- {
- strcpy(word_buf,word);
- wlen = TransposeAlphabet(word_buf, tr->transpose_offset, tr->transpose_min, tr->transpose_max);
- word = word_buf;
- }
- else
- {
- wlen = strlen(word);
- }
-
- hash = HashDictionary(word);
- p = tr->dict_hashtab[hash];
-
- if(p == NULL)
- {
- if(flags != NULL)
- *flags = 0;
- return(0);
- }
-
- // Find the first entry in the list for this hash value which matches.
- // This corresponds to the last matching entry in the *_list file.
-
- while(*p != 0)
- {
- next = p + p[0];
-
- if(((p[1] & 0x7f) != wlen) || (memcmp(word,&p[2],wlen & 0x3f) != 0))
- {
- // bit 6 of wlen indicates whether the word has been compressed; so we need to match on this also.
- p = next;
- continue;
- }
-
- /* found matching entry. Decode the phonetic string */
- word_end = word2;
-
- dictionary_flags = 0;
- dictionary_flags2 = 0;
- no_phonemes = p[1] & 0x80;
-
- p += ((p[1] & 0x3f) + 2);
-
- if(no_phonemes)
- {
- phonetic[0] = 0;
- phoneme_len = 0;
- }
- else
- {
- strcpy(phonetic,p);
- phoneme_len = strlen(p);
- p += (phoneme_len + 1);
- }
-
- while(p < next)
- {
- // examine the flags which follow the phoneme string
-
- flag = *p++;
- if(flag >= 100)
- {
- // conditional rule
- if(flag >= 132)
- {
- // fail if this condition is set
- if((tr->dict_condition & (1 << (flag-132))) != 0)
- condition_failed = 1;
- }
- else
- {
- // allow only if this condition is set
- if((tr->dict_condition & (1 << (flag-100))) == 0)
- condition_failed = 1;
- }
- }
- else
- if(flag > 80)
- {
- // flags 81 to 90 match more than one word
- // This comes after the other flags
- n_chars = next - p;
- skipwords = flag - 80;
-
- // don't use the contraction if any of the words are emphasized
- for(ix=0; ix <= skipwords; ix++)
- {
- if(wflags & FLAG_EMPHASIZED2)
- {
- condition_failed = 1;
- }
- }
-
- if(memcmp(word2,p,n_chars) != 0)
- condition_failed = 1;
-
- if(condition_failed)
- {
- p = next;
- break;
- }
-
- dictionary_flags |= FLAG_SKIPWORDS;
- dictionary_skipwords = skipwords;
- p = next;
- word_end = word2 + n_chars;
- }
- else
- if(flag > 64)
- {
- // stressed syllable information, put in bits 0-3
- dictionary_flags = (dictionary_flags & ~0xf) | (flag & 0xf);
- if((flag & 0xc) == 0xc)
- dictionary_flags |= FLAG_STRESS_END;
- }
- else
- if(flag >= 32)
- {
- dictionary_flags2 |= (1L << (flag-32));
- }
- else
- {
- dictionary_flags |= (1L << flag);
- }
- }
-
- if(condition_failed)
- {
- condition_failed=0;
- continue;
- }
-
- if((end_flags & FLAG_SUFX)==0)
- {
- // no suffix has been removed
- if(dictionary_flags & FLAG_STEM)
- continue; // this word must have a suffix
- }
-
- if((end_flags & SUFX_P) && (dictionary_flags & (FLAG_ONLY | FLAG_ONLY_S)))
- continue; // $only or $onlys, don't match if a prefix has been removed
-
- if(end_flags & FLAG_SUFX)
- {
- // a suffix was removed from the word
- if(dictionary_flags & FLAG_ONLY)
- continue; // no match if any suffix
-
- if((dictionary_flags & FLAG_ONLY_S) && ((end_flags & FLAG_SUFX_S)==0))
- {
- // only a 's' suffix allowed, but the suffix wasn't 's'
- continue;
- }
- }
-
- if(dictionary_flags2 & FLAG_HYPHENATED)
- {
- if(!(wflags & FLAG_HYPHEN_AFTER))
- {
- continue;
- }
- }
- if(dictionary_flags2 & FLAG_CAPITAL)
- {
- if(!(wflags & FLAG_FIRST_UPPER))
- {
- continue;
- }
- }
- if(dictionary_flags2 & FLAG_ALLCAPS)
- {
- if(!(wflags & FLAG_ALL_UPPER))
- {
- continue;
- }
- }
-
- if((dictionary_flags & FLAG_ATEND) && (word_end < tr->clause_end))
- {
- // only use this pronunciation if it's the last word of the clause
- continue;
- }
-
- if(dictionary_flags2 & FLAG_VERB)
- {
- // this is a verb-form pronunciation
-
- if(tr->expect_verb || (tr->expect_verb_s && (end_flags & FLAG_SUFX_S)))
- {
- // OK, we are expecting a verb
- }
- else
- {
- /* don't use the 'verb' pronunciation unless we are
- expecting a verb */
- continue;
- }
- }
- if(dictionary_flags2 & FLAG_PAST)
- {
- if(!tr->expect_past)
- {
- /* don't use the 'past' pronunciation unless we are
- expecting past tense */
- continue;
- }
- }
- if(dictionary_flags2 & FLAG_NOUN)
- {
- if(!tr->expect_noun)
- {
- /* don't use the 'noun' pronunciation unless we are
- expecting a noun */
- continue;
- }
- }
-
- if(flags != NULL)
- {
- flags[0] = dictionary_flags | FLAG_FOUND_ATTRIBUTES;
- flags[1] = dictionary_flags2;
- }
-
- if(phoneme_len == 0)
- {
- if(option_phonemes == 2)
- {
- fprintf(f_trans,"Flags: %s %s\n",word1,print_dictionary_flags(flags));
- }
- return(0); // no phoneme translation found here, only flags. So use rules
- }
-
- if(flags != NULL)
- flags[0] |= FLAG_FOUND; // this flag indicates word was found in dictionary
-
- if(option_phonemes == 2)
- {
- unsigned int flags1 = 0;
- char ph_decoded[N_WORD_PHONEMES];
- int textmode;
-
- DecodePhonemes(phonetic,ph_decoded);
- if(flags != NULL)
- flags1 = flags[0];
-
- if((dictionary_flags & FLAG_TEXTMODE) == 0)
- textmode = 0;
- else
- textmode = 1;
-
- if(textmode == translator->langopts.textmode)
- {
- // only show this line if the word translates to phonemes, not replacement text
- fprintf(f_trans,"Found: %s [%s] %s\n",word1,ph_decoded,print_dictionary_flags(flags));
- }
- }
- return(word_end);
-
- }
- return(0);
-} // end of LookupDict2
-
-
-
-int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *flags, int end_flags, WORD_TAB *wtab)
-//==================================================================================================================
-/* Lookup a specified word in the word dictionary.
- Returns phonetic data in 'phonetic' and bits in 'flags'
-
- end_flags: indicates if a suffix has been removed
-*/
-{
- int length;
- const char *found;
- const char *word1;
- const char *word2;
- unsigned char c;
- int nbytes;
- int len;
- char word[N_WORD_BYTES];
- static char word_replacement[N_WORD_BYTES];
-
- length = 0;
- word2 = word1 = *wordptr;
-
- while((word2[nbytes = utf8_nbytes(word2)]==' ') && (word2[nbytes+1]=='.'))
- {
- // look for an abbreviation of the form a.b.c
- // try removing the spaces between the dots and looking for a match
- memcpy(&word[length],word2,nbytes);
- length += nbytes;
- word[length++] = '.';
- word2 += nbytes+3;
- }
- if(length > 0)
- {
- // found an abbreviation containing dots
- nbytes = 0;
- while(((c = word2[nbytes]) != 0) && (c != ' '))
- {
- nbytes++;
- }
- memcpy(&word[length],word2,nbytes);
- word[length+nbytes] = 0;
- found = LookupDict2(tr, word, word2, ph_out, flags, end_flags, wtab);
- if(found)
- {
- // set the skip words flag
- flags[0] |= FLAG_SKIPWORDS;
- dictionary_skipwords = length;
- return(1);
- }
- }
-
- for(length=0; length<N_WORD_BYTES; length++)
- {
- if(((c = *word1++)==0) || (c == ' '))
- break;
- word[length] = c;
- }
- word[length] = 0;
-
- found = LookupDict2(tr, word, word1, ph_out, flags, end_flags, wtab);
-
- if(flags[0] & FLAG_MAX3)
- {
- if(strcmp(ph_out, tr->phonemes_repeat) == 0)
- {
- tr->phonemes_repeat_count++;
- if(tr->phonemes_repeat_count > 3)
- {
- ph_out[0] = 0;
- }
- }
- else
- {
- strncpy0(tr->phonemes_repeat, ph_out, sizeof(tr->phonemes_repeat));
- tr->phonemes_repeat_count = 1;
- }
- }
- else
- {
- tr->phonemes_repeat_count = 0;
- }
-
-
- if((found == 0) && (flags[1] & FLAG_ACCENT))
- {
- int letter;
- word2 = word;
- if(*word2 == '_') word2++;
- len = utf8_in(&letter, word2);
- LookupAccentedLetter(tr,letter, ph_out);
- found = word2 + len;
- }
-
- if(found == 0)
- {
- ph_out[0] = 0;
-
- // try modifications to find a recognised word
-
- if((end_flags & FLAG_SUFX_E_ADDED) && (word[length-1] == 'e'))
- {
- // try removing an 'e' which has been added by RemoveEnding
- word[length-1] = 0;
- found = LookupDict2(tr, word, word1, ph_out, flags, end_flags, wtab);
- }
- else
- if((end_flags & SUFX_D) && (word[length-1] == word[length-2]))
- {
- // try removing a double letter
- word[length-1] = 0;
- found = LookupDict2(tr, word, word1, ph_out, flags, end_flags, wtab);
- }
- }
-
- if(found)
- {
- // if textmode is the default, then words which have phonemes are marked.
- if(tr->langopts.textmode)
- *flags ^= FLAG_TEXTMODE;
-
- if(*flags & FLAG_TEXTMODE)
- {
- // the word translates to replacement text, not to phonemes
-
- if(end_flags & FLAG_ALLOW_TEXTMODE)
- {
- // only use replacement text if this is the original word, not if a prefix or suffix has been removed
- word_replacement[0] = 0;
- word_replacement[1] = ' ';
- sprintf(&word_replacement[2],"%s ",ph_out); // replacement word, preceded by zerochar and space
-
- word1 = *wordptr;
- *wordptr = &word_replacement[2];
-
- if(option_phonemes == 2)
- {
- len = found - word1;
- memcpy(word,word1,len); // include multiple matching words
- word[len] = 0;
- fprintf(f_trans,"Replace: %s %s\n",word,*wordptr);
- }
- }
-
- ph_out[0] = 0;
- return(0);
- }
-
- return(1);
- }
-
- ph_out[0] = 0;
- return(0);
-} // end of LookupDictList
-
-
-
-int Lookup(Translator *tr, const char *word, char *ph_out)
-{//===================================================
- unsigned int flags[2]={0,0};
- char* word1 = (char *)word;
- return(LookupDictList(tr, &word1, ph_out, flags, 0, NULL));
-}
-
-
-
-int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy)
-{//========================================================================
-/* Removes a standard suffix from a word, once it has been indicated by the dictionary rules.
- end_type: bits 0-6 number of letters
- bits 8-14 suffix flags
-
- word_copy: make a copy of the original word
- This routine is language specific. In English it deals with reversing y->i and e-dropping
- that were done when the suffix was added to the original word.
-*/
-
- int i;
- char *word_end;
- int len_ending;
- int end_flags;
- const char *p;
- int len;
- static char ending[12];
-
- // these lists are language specific, but are only relevent if the 'e' suffix flag is used
- static const char *add_e_exceptions[] = {
- "ion", NULL };
-
- static const char *add_e_additions[] = {
- "c", "rs", "ir", "ur", "ath", "ns", "lu", NULL };
-
- for(word_end = word; *word_end != ' '; word_end++)
- {
- /* replace discarded 'e's */
- if(*word_end == REPLACED_E)
- *word_end = 'e';
- }
- i = word_end - word;
- memcpy(word_copy,word,i);
- word_copy[i] = 0;
-
- // look for multibyte characters to increase the number of bytes to remove
- for(len_ending = i = (end_type & 0x3f); i>0 ;i--) // num.of characters of the suffix
- {
- word_end--;
- while((*word_end & 0xc0) == 0x80)
- {
- word_end--; // for multibyte characters
- len_ending++;
- }
- }
-
- // remove bytes from the end of the word and replace them by spaces
- for(i=0; i<len_ending; i++)
- {
- ending[i] = word_end[i];
- word_end[i] = ' ';
- }
- ending[i] = 0;
- word_end--; /* now pointing at last character of stem */
-
- end_flags = (end_type & 0xfff0) | FLAG_SUFX;
-
- /* add an 'e' to the stem if appropriate,
- if stem ends in vowel+consonant
- or stem ends in 'c' (add 'e' to soften it) */
-
- if(end_type & SUFX_I)
- {
- if(word_end[0] == 'i')
- word_end[0] = 'y';
- }
-
- if(end_type & SUFX_E)
- {
- // add 'e' to end of stem
- if(IsLetter(tr, word_end[-1],LETTERGP_VOWEL2) && IsLetter(tr, word_end[0],1))
- {
- // vowel(incl.'y') + hard.consonant
-
- for(i=0; (p = add_e_exceptions[i]) != NULL; i++)
- {
- len = strlen(p);
- if(memcmp(p,&word_end[1-len],len)==0)
- {
- break;
- }
- }
- if(p == NULL)
- end_flags |= FLAG_SUFX_E_ADDED; // no exception found
- }
- else
- {
- for(i=0; (p = add_e_additions[i]) != NULL; i++)
- {
- len = strlen(p);
- if(memcmp(p,&word_end[1-len],len)==0)
- {
- end_flags |= FLAG_SUFX_E_ADDED;
- break;
- }
- }
- }
-
- if(end_flags & FLAG_SUFX_E_ADDED)
- {
- word_end[1] = 'e';
-#ifdef LOG_TRANSLATE
-if(option_phonemes == 2)
-{
- fprintf(f_trans,"add e\n");
-}
-#endif
- }
- }
-
- if((end_type & SUFX_V) && (tr->expect_verb==0))
- tr->expect_verb = 1; // this suffix indicates the verb pronunciation
-
-
- if((strcmp(ending,"s")==0) || (strcmp(ending,"es")==0))
- end_flags |= FLAG_SUFX_S;
-
- if(strcmp(ending,"'s")==0)
- end_flags &= ~FLAG_SUFX; // don't consider 's as an added suffix
-
- return(end_flags);
-} /* end of RemoveEnding */
-
-
diff --git a/navit/support/espeak/espeak-data/af_dict b/navit/support/espeak/espeak-data/af_dict
deleted file mode 100644
index 7819c9fe0..000000000
--- a/navit/support/espeak/espeak-data/af_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ca_dict b/navit/support/espeak/espeak-data/ca_dict
deleted file mode 100644
index b9a4ea43a..000000000
--- a/navit/support/espeak/espeak-data/ca_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/config b/navit/support/espeak/espeak-data/config
deleted file mode 100755
index be1b6246a..000000000
--- a/navit/support/espeak/espeak-data/config
+++ /dev/null
@@ -1,9 +0,0 @@
-//pa_device 7
-
-// play a sound for punctuation, rather than speak its name
-//soundicon _( /usr/share/sounds/sound-icons/left-round-bracket
-//soundicon _) /usr/share/sounds/sound-icons/right-round-bracket
-//soundicon _[ /usr/share/sounds/sound-icons/left-square-bracket
-//soundicon _] /usr/share/sounds/sound-icons/right-square-bracket
-//soundicon _{ /usr/share/sounds/sound-icons/left-brace
-//soundicon _} /usr/share/sounds/sound-icons/right-brace
diff --git a/navit/support/espeak/espeak-data/cs_dict b/navit/support/espeak/espeak-data/cs_dict
deleted file mode 100644
index 3391b98b2..000000000
--- a/navit/support/espeak/espeak-data/cs_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/cy_dict b/navit/support/espeak/espeak-data/cy_dict
deleted file mode 100644
index 13a768030..000000000
--- a/navit/support/espeak/espeak-data/cy_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/da_dict b/navit/support/espeak/espeak-data/da_dict
deleted file mode 100644
index 75ccbd670..000000000
--- a/navit/support/espeak/espeak-data/da_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/de_dict b/navit/support/espeak/espeak-data/de_dict
deleted file mode 100644
index 988f4c31b..000000000
--- a/navit/support/espeak/espeak-data/de_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/el_dict b/navit/support/espeak/espeak-data/el_dict
deleted file mode 100644
index a6ab63dee..000000000
--- a/navit/support/espeak/espeak-data/el_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/en_dict b/navit/support/espeak/espeak-data/en_dict
deleted file mode 100644
index d15b0e9ab..000000000
--- a/navit/support/espeak/espeak-data/en_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/eo_dict b/navit/support/espeak/espeak-data/eo_dict
deleted file mode 100644
index 155523963..000000000
--- a/navit/support/espeak/espeak-data/eo_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/es_dict b/navit/support/espeak/espeak-data/es_dict
deleted file mode 100644
index 203da2639..000000000
--- a/navit/support/espeak/espeak-data/es_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/fi_dict b/navit/support/espeak/espeak-data/fi_dict
deleted file mode 100644
index a08d45a6f..000000000
--- a/navit/support/espeak/espeak-data/fi_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/fr_dict b/navit/support/espeak/espeak-data/fr_dict
deleted file mode 100644
index e66708e04..000000000
--- a/navit/support/espeak/espeak-data/fr_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/grc_dict b/navit/support/espeak/espeak-data/grc_dict
deleted file mode 100644
index 0aeab45e0..000000000
--- a/navit/support/espeak/espeak-data/grc_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/hbs_dict b/navit/support/espeak/espeak-data/hbs_dict
deleted file mode 100644
index 91ee7ba4b..000000000
--- a/navit/support/espeak/espeak-data/hbs_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/hi_dict b/navit/support/espeak/espeak-data/hi_dict
deleted file mode 100644
index 388d3f246..000000000
--- a/navit/support/espeak/espeak-data/hi_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/hu_dict b/navit/support/espeak/espeak-data/hu_dict
deleted file mode 100644
index 5a1f21165..000000000
--- a/navit/support/espeak/espeak-data/hu_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/hy_dict b/navit/support/espeak/espeak-data/hy_dict
deleted file mode 100644
index 18c3e2027..000000000
--- a/navit/support/espeak/espeak-data/hy_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/id_dict b/navit/support/espeak/espeak-data/id_dict
deleted file mode 100644
index 3c9967ce8..000000000
--- a/navit/support/espeak/espeak-data/id_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/is_dict b/navit/support/espeak/espeak-data/is_dict
deleted file mode 100644
index 10cf846f8..000000000
--- a/navit/support/espeak/espeak-data/is_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/it_dict b/navit/support/espeak/espeak-data/it_dict
deleted file mode 100644
index 40cf952a2..000000000
--- a/navit/support/espeak/espeak-data/it_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/jbo_dict b/navit/support/espeak/espeak-data/jbo_dict
deleted file mode 100644
index f7ebcf454..000000000
--- a/navit/support/espeak/espeak-data/jbo_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ku_dict b/navit/support/espeak/espeak-data/ku_dict
deleted file mode 100644
index 18d285845..000000000
--- a/navit/support/espeak/espeak-data/ku_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/la_dict b/navit/support/espeak/espeak-data/la_dict
deleted file mode 100644
index 3ef82f832..000000000
--- a/navit/support/espeak/espeak-data/la_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/lv_dict b/navit/support/espeak/espeak-data/lv_dict
deleted file mode 100644
index 3ecb61b51..000000000
--- a/navit/support/espeak/espeak-data/lv_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/af1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/af1_phtrans
deleted file mode 100644
index fc9ad0179..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/af1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/ca1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/ca1_phtrans
deleted file mode 100644
index 4fe4188e5..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/ca1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/cr1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/cr1_phtrans
deleted file mode 100644
index 15e2c4988..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/cr1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/cs_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/cs_phtrans
deleted file mode 100644
index 85ebb03e3..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/cs_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/de2_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/de2_phtrans
deleted file mode 100644
index c5af1a7c4..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/de2_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/de4_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/de4_phtrans
deleted file mode 100644
index b10fc8441..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/de4_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/de6_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/de6_phtrans
deleted file mode 100644
index 4cb62d9c2..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/de6_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/en1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/en1_phtrans
deleted file mode 100644
index c847d1703..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/en1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/es_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/es_phtrans
deleted file mode 100644
index b959f92c1..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/es_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/fr1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/fr1_phtrans
deleted file mode 100644
index 1a242b36f..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/fr1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/gr2_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/gr2_phtrans
deleted file mode 100644
index b3775abbd..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/gr2_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/grc-de6_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/grc-de6_phtrans
deleted file mode 100644
index e41d3105c..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/grc-de6_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/hu1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/hu1_phtrans
deleted file mode 100644
index 26dad49a0..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/hu1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/id1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/id1_phtrans
deleted file mode 100644
index 452de8c8a..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/id1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/in1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/in1_phtrans
deleted file mode 100644
index 7f4631899..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/in1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/it3_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/it3_phtrans
deleted file mode 100644
index 6d826477b..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/it3_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/la1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/la1_phtrans
deleted file mode 100644
index 1f2eb9290..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/la1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/nl_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/nl_phtrans
deleted file mode 100644
index d982c1845..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/nl_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/pl1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/pl1_phtrans
deleted file mode 100644
index 9d4e50fd7..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/pl1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/pt1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/pt1_phtrans
deleted file mode 100644
index c5172f7b3..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/pt1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/pt_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/pt_phtrans
deleted file mode 100644
index 9de1630d9..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/pt_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/ptbr4_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/ptbr4_phtrans
deleted file mode 100644
index 0b94de719..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/ptbr4_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/ptbr_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/ptbr_phtrans
deleted file mode 100644
index a1dbba000..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/ptbr_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/ro1_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/ro1_phtrans
deleted file mode 100644
index 4aeaf54ec..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/ro1_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/sv2_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/sv2_phtrans
deleted file mode 100644
index ae119d86e..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/sv2_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/sv_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/sv_phtrans
deleted file mode 100644
index bb556eb28..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/sv_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/us3_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/us3_phtrans
deleted file mode 100644
index 449b419ac..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/us3_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mbrola_ph/us_phtrans b/navit/support/espeak/espeak-data/mbrola_ph/us_phtrans
deleted file mode 100644
index bdeef5d1a..000000000
--- a/navit/support/espeak/espeak-data/mbrola_ph/us_phtrans
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/mk_dict b/navit/support/espeak/espeak-data/mk_dict
deleted file mode 100644
index a6cf3dc53..000000000
--- a/navit/support/espeak/espeak-data/mk_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/nl_dict b/navit/support/espeak/espeak-data/nl_dict
deleted file mode 100644
index f286bee90..000000000
--- a/navit/support/espeak/espeak-data/nl_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/no_dict b/navit/support/espeak/espeak-data/no_dict
deleted file mode 100644
index 4f8f84f0d..000000000
--- a/navit/support/espeak/espeak-data/no_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/pap_dict b/navit/support/espeak/espeak-data/pap_dict
deleted file mode 100644
index 11eb4b515..000000000
--- a/navit/support/espeak/espeak-data/pap_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/phondata b/navit/support/espeak/espeak-data/phondata
deleted file mode 100644
index d46417ed0..000000000
--- a/navit/support/espeak/espeak-data/phondata
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/phondata-manifest b/navit/support/espeak/espeak-data/phondata-manifest
deleted file mode 100644
index 4197d142d..000000000
--- a/navit/support/espeak/espeak-data/phondata-manifest
+++ /dev/null
@@ -1,729 +0,0 @@
-# This file lists the type of data that has been compiled into the
-# phondata file
-#
-# The first character of a line indicates the type of data:
-# S - A SPECT_SEQ structure
-# W - A wavefile segment
-# E - An envelope
-#
-# Address is the displacement within phondata of this item
-#
-# Address Data file
-# ------- ---------
-W 0x00004 ustop/null
-S 0x00154 vowel/@
-S 0x00218 vowel/@-
-W 0x002dc ustop/percus10
-S 0x004e8 j/j@
-S 0x005ec j2/j2@
-S 0x006b0 w/w@
-S 0x00774 l/l@
-S 0x00838 l^/j2@
-S 0x008fc r/r@
-S 0x009c0 r2/r2@
-S 0x00a84 m/m@
-S 0x00b88 n/n@
-S 0x00c8c nn/nn@
-S 0x00d50 n^/n^@
-S 0x00ed4 l/L1_@L
-S 0x00fd8 l/L2_@L
-S 0x010dc l/l_@
-S 0x011a0 l/xl
-S 0x01224 w/xw
-S 0x012a8 j/xj
-S 0x0132c r/xr
-S 0x013b0 r3/r_@
-S 0x01474 j/ja
-S 0x01578 j2/j2a
-S 0x0163c w/wa
-S 0x01700 l/la
-S 0x01784 l^/j2a
-S 0x01848 r/ra
-S 0x0190c r2/r2a
-S 0x019d0 m/ma
-S 0x01ad4 n/na
-S 0x01bd8 nn/nna
-S 0x01c9c n^/n^a
-S 0x01de0 l/L1_aL
-S 0x01ee4 l/L2_aL
-S 0x01fe8 l/l_a
-S 0x020ac r3/r_a
-S 0x02170 j/je
-S 0x02274 j2/j2e
-S 0x02338 w/we
-S 0x023fc l/le
-S 0x02480 l^/j2e
-S 0x02544 r/re
-S 0x02608 r2/r2e
-S 0x0270c m/me
-S 0x02810 n/ne
-S 0x02914 nn/nne
-S 0x029d8 n^/n^e
-S 0x02b5c l/L1_eL
-S 0x02c20 l/L2_eL
-S 0x02ce4 l/l_e
-S 0x02d68 r3/r_e
-S 0x02e2c j/ji
-S 0x02ef0 j2/j2i
-S 0x02fb4 w/wi
-S 0x03078 l/li
-S 0x0313c l^/j2i
-S 0x03200 r/ri
-S 0x032c4 r2/r2i
-S 0x03388 m/mi
-S 0x034cc n/ni
-S 0x035d0 nn/nni
-S 0x03694 n^/n^i
-S 0x03818 l/L1_iL
-S 0x0391c l/L2_iL
-S 0x03a20 l/l_i
-S 0x03ae4 nn/inn
-S 0x03ba8 j2/xj2
-S 0x03c2c r3/r_i
-S 0x03cf0 j/jo
-S 0x03e34 j2/j2o
-S 0x03f38 w/wo
-S 0x03ffc l/lo
-S 0x04100 l^/j2o
-S 0x04204 r/ro
-S 0x042c8 r2/r2o
-S 0x0438c m/mo
-S 0x04490 n/no
-S 0x04594 nn/nno
-S 0x04658 n^/n^o
-S 0x0481c l/L1_oL
-S 0x04960 l/L2_oL
-S 0x04aa4 l/l_o
-S 0x04ba8 r3/r_o
-S 0x04c6c j/ju
-S 0x04d30 j2/j2u
-S 0x04df4 w/wu
-S 0x04eb8 l/lu
-S 0x04f7c l^/j2u
-S 0x05080 r/ru
-S 0x05144 r2/r2u
-S 0x05208 m/mu
-S 0x0530c n/nu
-S 0x05410 nn/nnu
-S 0x054d4 n^/n^u
-S 0x05658 l/L1_uL
-S 0x0575c l/L2_uL
-S 0x05860 l/l_u
-S 0x05924 r3/r_u
-S 0x059e8 r/r
-S 0x05aac r/_r
-S 0x05b70 r/tr
-S 0x05bf4 r/r_
-S 0x05d38 r3/r_
-W 0x05dbc r3/rx
-S 0x07114 r3/r_n
-S 0x07198 r/rr
-S 0x0725c r/trr
-S 0x07320 r2/_r2
-S 0x073e4 r3/r_trill2
-W 0x074a8 r3/r_trill2.wav
-S 0x07bb4 r3/r_trill
-W 0x07cb8 r3/r_trill.wav
-W 0x08724 r3/r_trill3.wav
-S 0x08b68 r3/r_uvl
-W 0x08c6c r3/r_uvl.wav
-S 0x09b74 l/l
-S 0x09bf8 l/_l
-S 0x09cbc l/tl
-S 0x09d40 l/l_long
-S 0x09dc4 l/l_
-S 0x09e48 l^/l^
-S 0x09f4c l^/_l^
-S 0x0a050 w/w
-S 0x0a0d4 w/_w
-S 0x0a198 w/w_
-S 0x0a25c w/iw_
-S 0x0a320 j/_j
-S 0x0a3a4 j/j_
-S 0x0a468 j2/_j2
-S 0x0a4ec m/_m
-S 0x0a570 m/m_
-S 0x0a634 m/mj
-S 0x0a6f8 n/_n
-S 0x0a77c n/n_
-S 0x0a840 n/nj
-S 0x0a904 n/_nr
-S 0x0a988 n/nr_
-S 0x0aa4c n^/_n^
-S 0x0aad0 n^/n^_
-S 0x0ac14 nn/_nn
-S 0x0ac98 nn/nn_
-S 0x0ad5c nn/nnj
-S 0x0ade0 r3/@tap
-S 0x0af24 r3/@tap2
-S 0x0b068 r3/@tap_rfx
-S 0x0b1ac b/b
-W 0x0b2b0 x/b
-S 0x0b414 b/b_
-W 0x0b4d8 x/b_
-S 0x0b8f0 b/ba
-S 0x0b9f4 b/b@
-S 0x0baf8 b/be
-S 0x0bbfc b/bi
-S 0x0bd00 b/bo
-S 0x0be04 b/bu
-S 0x0bf08 b/b@2
-S 0x0c00c b/xb
-S 0x0c0d0 d/d
-W 0x0c194 x/d
-S 0x0c3b0 d/d_
-W 0x0c474 x/d_
-S 0x0c89c d/dr
-S 0x0c920 d/xd
-W 0x0c9e4 x/d_dnt
-S 0x0ccc8 d/tap3
-S 0x0cdcc d/tap1
-S 0x0ce90 dzh/dzh
-W 0x0cf54 x/dzh
-S 0x0d360 dzh/dzh_
-W 0x0d424 x/dzh_
-S 0x0de5c dzh/xdzh
-W 0x0df20 x/dz_pzd
-S 0x0e380 dzh/dz_pzd
-S 0x0e444 dzh/dz_pzd_
-S 0x0e508 dzh/xdz_pzd
-S 0x0e5cc g/g
-W 0x0e690 x/g2
-S 0x0e918 g/g_
-W 0x0e9dc x/g_
-S 0x0ed9c g/xg
-S 0x0ee60 g2/g
-W 0x0ef24 x/g2_
-S 0x0f2e4 g2/g_
-S 0x0f3a8 g2/xg
-S 0x0f46c voc/bh
-W 0x0f530 vocw/v
-S 0x0fe30 voc/v_
-S 0x0fef4 voc/v
-S 0x0fff8 voc/vj
-S 0x100fc voc/dh
-W 0x101c0 vocw/dh
-S 0x10ac8 voc/dh_
-S 0x10b8c voc/z
-W 0x10c50 ufric/s_
-S 0x11704 voc/z_
-S 0x117c8 voc/zh
-W 0x1188c vocw/zh
-S 0x121f4 voc/zh_
-W 0x122b8 vocw/zh_rfx
-S 0x12b48 voc/z_pzd
-W 0x12c0c ufric/s_pzd
-S 0x13544 voc/z_pzd_
-W 0x13608 ufric/s_pzd_
-W 0x1410c ufric/sh_pzd
-W 0x14a40 ufric/sh_pzd_
-S 0x15508 voc/j
-W 0x1560c ufric/ch
-S 0x15d24 voc/Q
-W 0x15de8 vocw/Q
-S 0x165f4 voc/Q_
-W 0x166b8 vocw/Q_
-S 0x16ec4 voc/Q_ulv
-W 0x16fc8 ufric/xx
-W 0x17ac4 ustop/p
-W 0x17e34 ustop/p_
-W 0x18644 ustop/pr
-W 0x18a8c ustop/p_unasp
-W 0x18db8 ustop/pl
-W 0x191b0 ustop/t
-W 0x195e4 ustop/t_
-W 0x19aa4 ustop/t_dnt
-W 0x19eb4 ustop/tr
-W 0x1a614 ustop/t_hi
-W 0x1a9b0 ustop/tsh
-W 0x1aff0 ustop/tsh_
-W 0x1b930 ustop/ts_pzd
-W 0x1c034 ustop/c
-W 0x1c2e4 ustop/t_pzd
-W 0x1c730 ustop/k
-W 0x1cc04 ustop/k_
-W 0x1d0c0 ustop/kr
-W 0x1d700 ustop/k_unasp
-W 0x1dbd4 ustop/kl
-W 0x1e204 ustop/ki
-W 0x1e7cc ustop/q
-W 0x1e938 ustop/q_u
-W 0x1ea58 ufric/f
-W 0x1f248 ufric/f_
-W 0x1fd18 ufric/th
-W 0x205b0 ufric/th_
-W 0x20e30 ufric/s
-W 0x215d0 ufric/s!
-W 0x21e80 ufric/sh
-W 0x22830 ufric/sh_
-W 0x232e0 ufric/sh_rfx
-W 0x23c7c ufric/ll
-W 0x246c0 ufric/ch_
-W 0x24fe8 ufric/x_hr
-W 0x258fc ufric/x
-W 0x26260 h/h_
-W 0x2690c h/h@
-W 0x26e60 h/ha
-W 0x274dc h/he
-W 0x27b70 h/hi
-W 0x28108 h/ho
-W 0x287c4 h/hu
-S 0x28ee8 vowel/a_2
-S 0x28fec vowel/a#
-S 0x290f0 vowel/e
-S 0x291f4 vowel/ee_1
-S 0x29338 vowel/i
-S 0x2943c vowel/o
-S 0x29580 vowel/oo_4
-S 0x29684 vowel/u_bck
-S 0x29788 vowel/uu_2
-S 0x2988c vowel/y
-S 0x299d0 vowel/y#
-S 0x29ad4 vdiph/au_4
-S 0x29c58 vdiph/eu
-S 0x29d9c vdiph2/iu
-S 0x29f20 vdiph/ai
-S 0x2a064 vdiph/ei
-S 0x2a1a8 vdiph/eei
-S 0x2a32c vdiph/oi
-S 0x2a4f0 vdiph/ui
-S 0x2a634 w/w2
-W 0x2a6f8 ustop/p_unasp_
-W 0x2a834 ustop/ts
-W 0x2b290 ustop/ts_
-W 0x2bbf0 ustop/t_dnt2
-S 0x2be48 vwl_en/@L
-S 0x2bf0c vowel/a
-S 0x2c010 vowel/a#_3
-S 0x2c0d4 vowel/ee_2
-S 0x2c1d8 vowel/ii_4
-S 0x2c2dc vowel/ii_en
-S 0x2c3a0 vowel/0
-S 0x2c4a4 vowel/V_2
-S 0x2c5a8 vowel/uu
-S 0x2c6ac vowel/aa_2
-S 0x2c830 vowel/3_en
-S 0x2c974 vowel/i_en
-S 0x2cab8 w/wi2
-S 0x2cbbc vowel/oo_en
-S 0x2cd00 vdiph2/uw_2
-S 0x2ce44 vwl_en/u_L
-S 0x2cf88 vdiph/au
-S 0x2d10c vdiph/@u_en
-S 0x2d290 vdiph/ai_2
-S 0x2d454 vdiph/ooi
-S 0x2d618 vdiph2/ii@
-S 0x2d79c vdiph2/uu@
-S 0x2d8e0 vwl_en/aI@
-S 0x2daa4 vwl_en/aU@
-S 0x2dc28 vowelr/V_r
-S 0x2dd6c vowelr/V3_r
-S 0x2deb0 vnasal/aa_n2
-S 0x2dff4 vnasal/ee_n
-S 0x2e138 vnasal/oo_n
-S 0x2e23c vowel/oe
-S 0x2e300 vowel/@_fr
-S 0x2e3c4 vowel/ee
-S 0x2e4c8 vowel/ii
-S 0x2e5cc vowel/e_3
-S 0x2e6d0 vowel/0_2
-S 0x2e7d4 vowel/o-_2
-S 0x2e8d8 vowel/aa_5
-S 0x2ea1c vwl_en_n/aa_5
-S 0x2eb60 vowel/3_2
-S 0x2eca4 vowel/oo_1
-S 0x2ede8 vwl_en_n/O@
-S 0x2eeec vdiph2/uw_4
-S 0x2f030 vdiph/eeu_3
-S 0x2f174 vdiph/ae_2
-S 0x2f2f8 vdiph2/ee@
-S 0x2f43c vdiph2/i@
-S 0x2f600 vwl_en_us/3_us
-S 0x2f704 vowel/@_4
-S 0x2f7c8 vowel/@_low2
-S 0x2f88c vwl_en_us/a
-S 0x2f990 vnasal/ee_n2
-S 0x2fad4 vwl_en_us/ee
-S 0x2fbd8 vowel/ii#_3
-S 0x2fcdc vowel/ii_final
-S 0x2fde0 vowel/aa_8
-S 0x2fee4 vwl_en_us/oor
-S 0x30028 vowel/V_6
-S 0x3012c vowel/8_2
-S 0x30230 vwl_en_us/ar
-S 0x30374 vwl_en_us/3_us2
-S 0x304b8 vowel/0_3
-S 0x305bc vwl_en_us/or
-S 0x30700 vowel/aa#
-S 0x30804 vdiph2/uw
-S 0x30948 vdiph/aoo
-S 0x30a8c vdiph/8u
-S 0x30bd0 vdiph/aae
-S 0x30d54 vdiph2/ei_4
-S 0x30e98 vdiph/ooi_4
-S 0x30fdc vwl_en_us/er
-S 0x31120 vwl_en_us/ir
-S 0x31264 vwl_en_us/ur
-S 0x313a8 vwl_en_us/ai@
-S 0x3152c d/tap2
-S 0x315f0 d/x_tap
-S 0x316b4 vowel/@_3
-S 0x31778 vowel/V
-S 0x3187c vowel/a_3
-S 0x31980 vowel/e_e
-S 0x31a84 vowel/e#
-S 0x31b88 vowel/e_5
-S 0x31c8c vowel/oo_2
-S 0x31d90 vowel/V_4
-S 0x31e94 vowel/u#_4
-S 0x31f98 vowelr/aa_r
-S 0x3215c vdiph2/e@
-S 0x322a0 vowel/i_5
-S 0x323a4 vowel/oo
-S 0x324a8 vowelr/oo_r
-S 0x325ac vowelr/o_r
-S 0x32730 vowel/u#
-S 0x32834 vdiph/au#
-S 0x32978 vowel/o_3
-S 0x32a7c vdiph/ai_7
-S 0x32c00 vwl_en/aI@_2
-S 0x32d84 vwl_en/@L_2
-S 0x32e88 vowel/e_2
-S 0x32f8c vdiph/0i_2
-S 0x33110 vowelr/i_r
-S 0x33254 vdiph2/u#@
-S 0x33398 vowel/@_low
-S 0x3345c vowel/&
-S 0x33560 vowel/e_mid
-S 0x33664 vowel/V_3
-S 0x33728 vowel/o-_3
-S 0x3382c vwl_en_rp/aa
-S 0x33970 vowel/3_3
-S 0x33ab4 vowel/u_fnt
-S 0x33bb8 vdiph/au_3
-S 0x33d3c vdiph/@u_2
-S 0x33e80 vdiph/ai_6
-S 0x34044 vdiph2/ei_2
-S 0x34188 vdiph/ooi_3
-S 0x3430c vdiph2/ee@_2
-S 0x34450 vwl_en_rp/i@
-S 0x345d4 vowel/o_mid
-S 0x346d8 vwl_en_rp/aU@
-S 0x3485c vowel/ii_6
-S 0x34920 vdiph2/ei_3
-S 0x34a64 vdiph/@u
-S 0x34ba8 vdiph/Vu_2
-S 0x34d2c vdiph/@i_3
-S 0x34e70 vdiph2/i@_2
-S 0x34ff4 vwl_en/ooi@
-S 0x351b8 vowel/@_fnt
-S 0x352bc vowel/uu_bck
-S 0x353c0 vowel/i_fnt
-S 0x354c4 vdiph2/o_oo
-S 0x35608 vowel/u
-S 0x3570c vdiph/aau_2
-S 0x35850 vdiph2/ie
-S 0x35994 vwl_af/@
-S 0x35a58 vwl_af/r@
-S 0x35b1c vowel/e_mid2
-S 0x35c20 vwl_af/I
-S 0x35ce4 vowel/oo_3
-S 0x35da8 vowel/uu_3
-S 0x35e6c vowel/ee_3
-S 0x35f30 l/L_eL_af
-S 0x35ff4 vowel/aa_3
-S 0x360f8 vdiph/i@_2
-S 0x3627c vowel/i_3
-S 0x36380 vdiph2/o@
-S 0x36504 vowel/y_3
-S 0x36608 vdiph2/iu_3
-S 0x367cc vdiph/Vu
-S 0x36950 vdiph/ai_4
-S 0x36ad4 vdiph/aai_2
-S 0x36c98 vdiph/@i_2
-S 0x36ddc vdiph/ooi_2
-S 0x36f60 vdiph/oi_2
-S 0x37124 vdiph/ui_2
-S 0x372a8 vdiph/y#y_2
-S 0x3742c vdiph2/y#@
-S 0x37570 vnasal/aa_n3
-S 0x376b4 vnasal/e_n
-S 0x377b8 vnasal/o_n2
-W 0x378fc ufric/x2
-S 0x38254 vowel/ii_3
-S 0x38358 vowel/ii#
-S 0x3845c vowel/i#
-S 0x38560 vowel/o_2
-S 0x386a4 vdiph2/iu_4
-S 0x387e8 vdiph/ui_3
-S 0x3896c vowel/aa_6
-S 0x38ab0 vowel/i_2
-S 0x38bb4 vdiph/ai_5
-S 0x38cf8 vowel/yy_4
-S 0x38dfc l/l_3
-S 0x38e80 j/_j_short
-S 0x38f04 vdiph/eei_2
-S 0x39048 vowelr/r-voc
-S 0x3918c vwl_hi/l-voc
-S 0x39290 vowel/i_4
-S 0x39394 vowel/aa_9
-S 0x39498 vowel/u_2
-S 0x3959c vowel/uu_4
-S 0x396a0 vdiph/aai_3
-S 0x39824 vdiph/&i
-S 0x39968 vdiph/y#i
-S 0x39aac vdiph/ui_4
-S 0x39bf0 vdiph/yi
-S 0x39d34 vdiph/aau
-S 0x39eb8 vdiph/ou
-S 0x39ffc vdiph/eu_2
-S 0x3a140 vdiph2/iu_2
-S 0x3a2c4 vdiph/&y
-S 0x3a408 vdiph/eey
-S 0x3a54c vdiph/y#y
-S 0x3a690 vdiph2/iy
-S 0x3a7d4 vdiph2/uo
-S 0x3a918 vdiph2/y-y#
-S 0x3aa5c r3/r_trill_short
-W 0x3ab60 ufric/s_continue
-W 0x3b310 h/hu_fi
-S 0x3bc00 vwl_fr/tr
-S 0x3bc84 vwl_fr/@R5
-S 0x3bd48 vowel/@_hgh
-S 0x3be0c vwl_fr/r_@
-S 0x3bed0 vowel/a_6
-S 0x3bfd4 vwl_fr/r_a
-S 0x3c058 vowel/e_8
-S 0x3c15c vwl_fr/r_e
-S 0x3c220 vwl_fr/r_i
-S 0x3c2e4 vwl_fr/r_o
-S 0x3c3a8 vowel/u_bck2
-S 0x3c4ac vwl_fr/r_u
-S 0x3c570 vowel/y_2
-S 0x3c6b4 l/l_y
-S 0x3c778 vwl_fr/r_y
-S 0x3c83c vowel/@_5
-S 0x3c900 vwl_fr/r_@2
-S 0x3c984 vwl_fr/w_a
-S 0x3cac8 vdiph/yi_fr
-S 0x3cc4c vnasal/aa_n4
-S 0x3cd90 vwl_fr/r_a~
-S 0x3ce14 vnasal/W_n
-S 0x3cf58 vowel/a_en
-S 0x3d05c vwl_fr/r
-S 0x3d0e0 r3/r_2
-W 0x3d164 ustop/t_short
-S 0x3d3a8 vowel/yy
-S 0x3d4ac vdiph/ae
-S 0x3d5f0 vowel/aa
-S 0x3d6f4 vwl_fr/@R2
-S 0x3d7f8 vowel/@_bck
-S 0x3d8fc vowel/i_6
-S 0x3da00 vdiph/ee-e
-S 0x3db44 vnasal/i_n2
-S 0x3dc48 vnasal/aa_n
-S 0x3dd8c vnasal/V_n
-S 0x3de90 vnasal/oo_n2
-S 0x3dfd4 vnasal/o_n
-S 0x3e118 vnasal/u_n
-S 0x3e21c vdiph/aau_3
-S 0x3e3a0 l^/l_rfx
-S 0x3e464 voc/v#
-S 0x3e568 voc/v#_
-W 0x3e62c ustop/p_asp
-S 0x3eb30 d/xd3
-W 0x3ebf4 ustop/ts_pzd2
-W 0x3ef28 ustop/ts_pzd_
-W 0x3f3ec ustop/k_asp
-S 0x3faf0 vowel/a_5
-S 0x3fbf4 vowel/u#_3
-S 0x3fcf8 vowel/u#_2
-S 0x3fdfc vowel/y#_2
-S 0x3ff00 vowel/8_7
-S 0x40004 vdiph/aai
-S 0x40188 vdiph2/uaa
-S 0x4030c vdiph2/ie_2
-W 0x40450 ustop/ts2
-S 0x40920 vowel/o_5
-S 0x40a24 vowel/o_6
-S 0x40ae8 vowel/aa_7
-S 0x40bec vdiph/y#y_3
-S 0x40cf0 vdiph/Vu_3
-S 0x40e74 vdiph2/yu
-S 0x40ff8 voc/Q_less
-W 0x410bc vocw/Q2
-W 0x41988 ufric/sx_sv
-S 0x421d0 vowel/a#_2
-S 0x422d4 vowel/ee#
-S 0x423d8 vowel/i_7
-S 0x424dc vowel/oo_5
-S 0x425e0 vowel/ii#_2
-S 0x426e4 vnasal/ee_u_n
-S 0x42868 vnasal/oo_n3
-W 0x429ec x/d_pzd
-S 0x42e00 d/xd_pzd
-S 0x42ec4 d/xdz
-S 0x42f88 vowel/ee_6
-S 0x4304c vdiph/ou_2
-S 0x43190 vdiph/eei_3
-W 0x432d4 r3/rz_cs
-S 0x43d80 voc/zh_2
-S 0x43e44 vdiph/oou
-W 0x43f88 ufric/sh3
-W 0x4491c ustop/tsh2
-W 0x45028 ustop/ts_pzd3
-S 0x456a8 dzh/dzh2
-W 0x4576c ustop/t_sr
-S 0x45aa4 d/d_dnt
-W 0x45b68 ufric/x_sr
-W 0x463e8 ufric/ch_sr
-W 0x46fc8 ufric/sh_pzd2
-W 0x47b18 ustop/ts_sr
-W 0x482d4 ustop/tsh_sr
-S 0x48bec vwl_ru/ii-
-S 0x48cb0 vwl_ro/mi
-S 0x48df4 vwl_ru/i
-S 0x48ef8 vwl_ru/ii#
-S 0x48fbc vwl_ru/i#
-S 0x490c0 vwl_ru/ii
-S 0x491c4 vwl_ru/e
-S 0x492c8 vwl_ru/E#
-S 0x493cc vwl_ru/E@
-S 0x494d0 vwl_ru/a
-S 0x495d4 vwl_ru/o
-S 0x496d8 vwl_ru/oo
-S 0x4979c vwl_ru/u
-S 0x498a0 vwl_ru/u#
-S 0x499e4 vwl_ru/u#u
-S 0x49b28 vwl_ru/8
-S 0x49bec vwl_ru/ee
-S 0x49d30 vwl_ru/ju
-S 0x49e34 vwl_ru/ja
-S 0x49fb8 vwl_ru/aa
-S 0x4a0bc r3/r_ru2
-W 0x4a1c0 r3/r_ru
-S 0x4a4c4 vowel/ii_5
-S 0x4a5c8 vdiph/eeu_2
-S 0x4a70c d/tap4
-S 0x4a810 voc/v2
-S 0x4a8d4 vnasal/i_n
-S 0x4a9d8 vnasal/a#_n
-S 0x4aadc vnasal/a#u_n
-S 0x4ac20 vnasal/oi_n
-S 0x4ade4 vdiph/0i
-S 0x4afa8 vdiph/eeu
-S 0x4b0ec vowel/i#_5
-S 0x4b1f0 vowel/u_6
-S 0x4b2f4 vwl_fr/@R
-S 0x4b3f8 vwl_ro/ii-
-S 0x4b4bc vwl_ro/li
-S 0x4b5c0 vwl_ro/ni
-S 0x4b6c4 vowel/o-_4
-S 0x4b7c8 vdiph/@u_3
-S 0x4b94c vdiph/ii
-S 0x4bb10 vdiph/i#i
-S 0x4bc54 vdiph2/uw_3
-S 0x4bd98 vdiph2/ea
-S 0x4bedc vdiph2/eo
-S 0x4c060 vdiph2/e[u
-S 0x4c1a4 vdiph2/oa
-S 0x4c2e8 d/tap
-S 0x4c3ac d/tap_i
-S 0x4c470 vowel/a_4
-S 0x4c574 vowel/ee#_2
-S 0x4c678 vowel/y_5
-S 0x4c7bc vowel/yy_3
-S 0x4c8c0 vowel/oe_4
-S 0x4c984 vowel/aa_4
-S 0x4ca88 vwl_sv/r_sv3
-S 0x4cc8c vowel/y_4
-S 0x4cd90 vowel/oe_2
-S 0x4ce94 vwl_no/y#
-S 0x4cf98 vwl_no/&
-S 0x4d09c vwl_no/u#
-S 0x4d1a0 vwl_no/u#2
-S 0x4d2e4 vdiph/ai_3
-S 0x4d428 vwl_no/y#y
-S 0x4d56c vwl_no/au-
-S 0x4d730 vowel/y##
-S 0x4d834 vowel/y#_3
-S 0x4d938 vdiph/ou_3
-S 0x4da3c vdiph/y#i_2
-S 0x4db80 m/m#_
-S 0x4dc84 n/n#_
-S 0x4dd88 n^/n^#_
-S 0x4de8c nn/nn#_
-W 0x4df90 ufric/tl#
-S 0x4e8f8 r3/r#_
-E 0x4e97c envelope/p_level
-E 0x4e9fc envelope/p_fall
-E 0x4ea7c envelope/p_rise
-E 0x4eafc envelope/p_fallrise
-E 0x4eb7c envelope/p_214
-E 0x4ebfc envelope/vi_5amp
-E 0x4ec7c envelope/p_512
-E 0x4ecfc envelope/vi_6amp
-S 0x4ed7c vowel/u_7
-S 0x4ee80 vowel/u#_5
-S 0x4ef84 vowel/@_2
-S 0x4f088 vdiph/&i_3
-S 0x4f20c vdiph/@i
-S 0x4f350 vdiph/u-i
-S 0x4f494 vdiph/aau_4
-S 0x4f618 vdiph2/ii@_3
-S 0x4f79c l/l_vi
-S 0x4f8a0 vwl_zh/ang
-S 0x4faa4 vwl_zh/aang
-S 0x4fce8 vdiph/au_2
-S 0x4fe6c vwl_zh/eng
-S 0x50070 vwl_zh/ing
-S 0x502b4 vwl_zh/ng
-S 0x503f8 vwl_zh/oeng
-S 0x505bc vwl_zh/ong
-S 0x50740 vwl_zh/ung
-S 0x508c4 vowel/8_3
-E 0x509c8 envelope/i_risefall
-W 0x50a48 ustop/t_unasp2
-S 0x50b54 n/n_long_
-W 0x50c18 ustop/k_unasp_
-W 0x50ed4 ustop/tsh_pzd_unasp
-W 0x51724 ustop/tsh_pzd
-W 0x52264 ustop/ts_unasp
-W 0x52adc ustop/ts_rfx_unasp
-W 0x536c8 ustop/ts_rfx
-S 0x543a8 nn/nn2_
-S 0x5446c vwl_zh/a_n
-S 0x54570 vwl_zh/aau
-S 0x546b4 vowel/ii_2
-S 0x54778 vowel/i#_7
-S 0x5487c vowel/i#_6
-S 0x54980 vwl_zh/iaa
-S 0x54ac4 vwl_zh/iaau
-S 0x54c48 vwl_zh/ie
-S 0x54d8c vdiph2/iioo
-S 0x54ed0 vwl_zh/iou
-S 0x55054 vowel/8
-S 0x55158 vwl_zh/uaa
-S 0x5529c vwl_zh/uai
-S 0x55420 vwl_zh/uei
-S 0x555a4 vwl_zh/uo
-S 0x55728 vwl_zh/y&
-S 0x5586c vwl_zh/yee
-S 0x559b0 vdiph2/y@
-S 0x55af4 vowel/u_5
-S 0x55bf8 vnasal/m-
-S 0x55cfc vnasal/n-
-S 0x55e00 vnasal/nn-
-S 0x55f04 vowel/u#_7
-S 0x56008 vowel/8_5
-S 0x5610c vowel/o_7
-S 0x56210 vowel/uu#
-S 0x56314 vowel/8_6
-S 0x56418 vowel/ee_4
-S 0x5651c vdiph2/ye
-S 0x56660 l/l_front_
-S 0x567a4 l/l_front
-S 0x568a8 l/l_4
-S 0x5696c vwl_fr/@R3
-S 0x56a30 vwl_fr/@R4
-S 0x56af4 r/a_
diff --git a/navit/support/espeak/espeak-data/phonindex b/navit/support/espeak/espeak-data/phonindex
deleted file mode 100644
index 8bed38930..000000000
--- a/navit/support/espeak/espeak-data/phonindex
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/phontab b/navit/support/espeak/espeak-data/phontab
deleted file mode 100644
index c0d3a751d..000000000
--- a/navit/support/espeak/espeak-data/phontab
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/pl_dict b/navit/support/espeak/espeak-data/pl_dict
deleted file mode 100644
index e46b00b04..000000000
--- a/navit/support/espeak/espeak-data/pl_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/pt_dict b/navit/support/espeak/espeak-data/pt_dict
deleted file mode 100644
index 9ba2a7a78..000000000
--- a/navit/support/espeak/espeak-data/pt_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ro_dict b/navit/support/espeak/espeak-data/ro_dict
deleted file mode 100644
index b0a72f406..000000000
--- a/navit/support/espeak/espeak-data/ro_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ru_dict b/navit/support/espeak/espeak-data/ru_dict
deleted file mode 100644
index 52d652ccd..000000000
--- a/navit/support/espeak/espeak-data/ru_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/sk_dict b/navit/support/espeak/espeak-data/sk_dict
deleted file mode 100644
index a5d7e7c75..000000000
--- a/navit/support/espeak/espeak-data/sk_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/sq_dict b/navit/support/espeak/espeak-data/sq_dict
deleted file mode 100644
index aea3d0625..000000000
--- a/navit/support/espeak/espeak-data/sq_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/sv_dict b/navit/support/espeak/espeak-data/sv_dict
deleted file mode 100644
index 1327d8d0c..000000000
--- a/navit/support/espeak/espeak-data/sv_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/sw_dict b/navit/support/espeak/espeak-data/sw_dict
deleted file mode 100644
index 77e2fd233..000000000
--- a/navit/support/espeak/espeak-data/sw_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/ta_dict b/navit/support/espeak/espeak-data/ta_dict
deleted file mode 100644
index 214e2f4da..000000000
--- a/navit/support/espeak/espeak-data/ta_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/tr_dict b/navit/support/espeak/espeak-data/tr_dict
deleted file mode 100644
index a3f685047..000000000
--- a/navit/support/espeak/espeak-data/tr_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/vi_dict b/navit/support/espeak/espeak-data/vi_dict
deleted file mode 100644
index 24a645a03..000000000
--- a/navit/support/espeak/espeak-data/vi_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/voices/!v/croak b/navit/support/espeak/espeak-data/voices/!v/croak
deleted file mode 100755
index ae76a4c4d..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/croak
+++ /dev/null
@@ -1,11 +0,0 @@
-language variant
-name croak
-gender male 70
-
-pitch 85 117
-flutter 20
-
-formant 0 100 80 110
-
-
-
diff --git a/navit/support/espeak/espeak-data/voices/!v/f1 b/navit/support/espeak/espeak-data/voices/!v/f1
deleted file mode 100755
index 13664a34f..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/f1
+++ /dev/null
@@ -1,18 +0,0 @@
-language variant
-name female1
-gender female
-
-pitch 145 200
-flutter 7
-roughness 4
-formant 0 115 80 150
-formant 1 120 80 180
-formant 2 100 70 150 150
-formant 3 115 70 150
-formant 4 110 80 150
-formant 5 110 90 150
-formant 6 105 80 150
-formant 7 110 70 150
-formant 8 110 70 150
-
-stressAdd -10 -10 -20 -20 0 0 40 70
diff --git a/navit/support/espeak/espeak-data/voices/!v/f2 b/navit/support/espeak/espeak-data/voices/!v/f2
deleted file mode 100755
index e92946707..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/f2
+++ /dev/null
@@ -1,20 +0,0 @@
-language variant
-name female2
-gender female
-
-pitch 142 220
-roughness 3
-
-formant 0 105 80 150
-formant 1 110 80 160
-formant 2 110 70 150
-formant 3 110 70 150
-formant 4 115 80 150
-formant 5 115 80 150
-formant 6 110 70 150
-formant 7 110 70 150
-formant 8 110 70 150
-
-stressAdd 0 0 -10 -10 0 0 10 40
-breath 0 2 3 3 3 3 3 2
-echo 140 10
diff --git a/navit/support/espeak/espeak-data/voices/!v/f3 b/navit/support/espeak/espeak-data/voices/!v/f3
deleted file mode 100644
index 92a158281..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/f3
+++ /dev/null
@@ -1,22 +0,0 @@
-language variant
-name female3
-gender female
-
-pitch 140 240
-formant 0 105 80 150
-formant 1 120 75 150 -50
-formant 2 135 70 150 -250
-formant 3 125 80 150
-formant 4 125 80 150
-formant 5 125 80 150
-formant 6 120 70 150
-formant 7 110 70 150
-formant 8 110 70 150
-
-stressAmp 18 18 20 20 20 20 20 20
-//breath 0 2 4 4 4 4 4 4
-breath 0 2 3 3 3 3 3 2
-echo 120 10
-roughness 4
-
-
diff --git a/navit/support/espeak/espeak-data/voices/!v/f4 b/navit/support/espeak/espeak-data/voices/!v/f4
deleted file mode 100644
index 52c5ac935..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/f4
+++ /dev/null
@@ -1,18 +0,0 @@
-language variant
-name female4
-gender female
-
-echo 130 15
-pitch 142 200
-formant 0 120 80 150
-formant 1 115 80 160 -20
-formant 2 130 75 150 -200
-formant 3 123 75 150
-formant 4 125 80 150
-formant 5 125 80 150
-formant 6 110 80 150
-formant 7 110 75 150
-formant 8 110 75 150
-
-stressAdd -20 -20 -20 -20 0 0 20 120
-stressAmp 18 16 20 20 20 20 20 20
diff --git a/navit/support/espeak/espeak-data/voices/!v/fast b/navit/support/espeak/espeak-data/voices/!v/fast
deleted file mode 100755
index 30441d7e2..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/fast
+++ /dev/null
@@ -1,11 +0,0 @@
-language variant
-name fast_test
-
-// Try decreasing these values to make eSpeak's fastest speed faster.
-// The 3 parameters affect:
-// pauses,
-// unvoiced consonants,
-// vowels and voiced consonants
-// The default values are: fast 15 72 110
-
-fast_test 15 72 110
diff --git a/navit/support/espeak/espeak-data/voices/!v/m1 b/navit/support/espeak/espeak-data/voices/!v/m1
deleted file mode 100755
index 57603a885..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/m1
+++ /dev/null
@@ -1,19 +0,0 @@
-language variant
-name male1
-gender male 70
-
-pitch 74 109
-flutter 4
-roughness 4
-
-formant 0 98 95 100
-formant 1 97 95 100
-formant 2 97 95 100
-formant 3 97 100 100
-formant 4 97 100 100
-formant 5 105 100 100
-formant 6 95 100 100
-formant 7 100 100 100
-formant 8 100 100 100
-
-stressAdd -10 -10 -20 -20 0 0 40 70
diff --git a/navit/support/espeak/espeak-data/voices/!v/m2 b/navit/support/espeak/espeak-data/voices/!v/m2
deleted file mode 100644
index c234f4687..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/m2
+++ /dev/null
@@ -1,15 +0,0 @@
-language variant
-name male2
-gender male
-
-pitch 88 115
-echo 130 15
-formant 0 100 80 120
-formant 1 90 85 120
-formant 2 110 85 120
-formant 3 105 90 120
-formant 4 100 90 120
-formant 5 100 90 120
-formant 6 100 90 120
-formant 7 100 90 120
-formant 8 100 90 120
diff --git a/navit/support/espeak/espeak-data/voices/!v/m3 b/navit/support/espeak/espeak-data/voices/!v/m3
deleted file mode 100644
index 581cd883f..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/m3
+++ /dev/null
@@ -1,16 +0,0 @@
-language variant
-name male3
-gender male
-
-pitch 80 122
-formant 0 100 100 100
-formant 1 96 97 100
-formant 2 96 97 100
-formant 3 96 103 100
-formant 4 95 103 100
-formant 5 95 103 100
-formant 6 100 100 100
-formant 7 100 100 100
-formant 8 100 100 100
-
-stressAdd 10 10 0 0 0 0 -30 -30
diff --git a/navit/support/espeak/espeak-data/voices/!v/m4 b/navit/support/espeak/espeak-data/voices/!v/m4
deleted file mode 100644
index 7199341c3..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/m4
+++ /dev/null
@@ -1,17 +0,0 @@
-language variant
-name male4
-gender male
-
-pitch 70 110
-
-formant 0 103 100 100
-formant 1 103 100 100
-formant 2 103 100 100
-formant 3 103 100 100
-formant 4 106 100 100
-formant 5 106 100 100
-formant 6 106 100 100
-formant 7 103 100 100
-formant 8 103 100 100
-
-stressAdd -10 -10 -30 -30 0 0 60 90
diff --git a/navit/support/espeak/espeak-data/voices/!v/m5 b/navit/support/espeak/espeak-data/voices/!v/m5
deleted file mode 100755
index d25865608..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/m5
+++ /dev/null
@@ -1,15 +0,0 @@
-language variant
-name male5
-gender male
-
-formant 0 100 85 130
-formant 1 90 85 130 40
-formant 2 80 85 130 310
-formant 3 105 85 130
-formant 4 105 85 130
-formant 5 105 85 130
-formant 6 105 85 150
-formant 7 105 85 150
-formant 8 105 85 150
-
-intonation 2
diff --git a/navit/support/espeak/espeak-data/voices/!v/m6 b/navit/support/espeak/espeak-data/voices/!v/m6
deleted file mode 100755
index bd336a988..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/m6
+++ /dev/null
@@ -1,13 +0,0 @@
-language variant
-name male6
-gender male
-
-pitch 82 117
-
-formant 0 100 90 120
-formant 1 100 90 140
-formant 2 100 70 140
-formant 3 100 75 140
-formant 4 100 80 140
-formant 5 100 80 140
-
diff --git a/navit/support/espeak/espeak-data/voices/!v/m7 b/navit/support/espeak/espeak-data/voices/!v/m7
deleted file mode 100755
index 9a8370622..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/m7
+++ /dev/null
@@ -1,18 +0,0 @@
-language variant
-gender male 35
-name male5
-
-formant 0 120 150 220
-
-formant 1 100 100 100
-formant 2 100 100 100
-formant 3 100 100 100
-
-formant 4 100 80 100
-formant 5 100 100 100
-
-formant 6 80 200 80
-formant 7 80 200 100
-
-pitch 80 118
-tone 600 150 255 50 100 100
diff --git a/navit/support/espeak/espeak-data/voices/!v/whisper b/navit/support/espeak/espeak-data/voices/!v/whisper
deleted file mode 100755
index 4f8f5e88f..000000000
--- a/navit/support/espeak/espeak-data/voices/!v/whisper
+++ /dev/null
@@ -1,13 +0,0 @@
-language variant
-name whisper
-gender male
-
-pitch 82 117
-flutter 20
-
-formant 0 100 0 100
-formant 1 100 80 100
-
-voicing 17
-breath 75 75 50 40 15 10
-breathw 150 150 200 200 400 400
diff --git a/navit/support/espeak/espeak-data/voices/af b/navit/support/espeak/espeak-data/voices/af
deleted file mode 100755
index bcbb2a005..000000000
--- a/navit/support/espeak/espeak-data/voices/af
+++ /dev/null
@@ -1,8 +0,0 @@
-name afrikaans
-language af
-gender male
-roughness 0
-pitch 63 120
-
-
-
diff --git a/navit/support/espeak/espeak-data/voices/bs b/navit/support/espeak/espeak-data/voices/bs
deleted file mode 100755
index eadd70732..000000000
--- a/navit/support/espeak/espeak-data/voices/bs
+++ /dev/null
@@ -1,16 +0,0 @@
-name bosnian
-language bs
-phonemes hr
-dictionary hbs
-gender male
-
-pitch 81 120
-formant 0 100 100 100
-formant 1 97 97 100
-formant 2 97 97 100
-formant 3 97 102 100
-formant 4 97 102 100
-formant 5 97 102 100
-
-stressAdd 10 10 0 0 0 0 -30 -30
-dictrules 3 4
diff --git a/navit/support/espeak/espeak-data/voices/ca b/navit/support/espeak/espeak-data/voices/ca
deleted file mode 100644
index dc51396ce..000000000
--- a/navit/support/espeak/espeak-data/voices/ca
+++ /dev/null
@@ -1,4 +0,0 @@
-name catalan
-language ca
-gender male
-
diff --git a/navit/support/espeak/espeak-data/voices/cs b/navit/support/espeak/espeak-data/voices/cs
deleted file mode 100755
index 1c2992dd5..000000000
--- a/navit/support/espeak/espeak-data/voices/cs
+++ /dev/null
@@ -1,4 +0,0 @@
-name czech
-language cs
-gender male
-
diff --git a/navit/support/espeak/espeak-data/voices/cy b/navit/support/espeak/espeak-data/voices/cy
deleted file mode 100755
index 2991e99d1..000000000
--- a/navit/support/espeak/espeak-data/voices/cy
+++ /dev/null
@@ -1,5 +0,0 @@
-language cy
-name welsh-test
-gender male
-
-intonation 4
diff --git a/navit/support/espeak/espeak-data/voices/da b/navit/support/espeak/espeak-data/voices/da
deleted file mode 100755
index ec9936cc2..000000000
--- a/navit/support/espeak/espeak-data/voices/da
+++ /dev/null
@@ -1,3 +0,0 @@
-name danish-test
-language da
-gender male
diff --git a/navit/support/espeak/espeak-data/voices/de b/navit/support/espeak/espeak-data/voices/de
deleted file mode 100755
index 653c3f5c4..000000000
--- a/navit/support/espeak/espeak-data/voices/de
+++ /dev/null
@@ -1,5 +0,0 @@
-name german
-language de
-gender male
-
-
diff --git a/navit/support/espeak/espeak-data/voices/default b/navit/support/espeak/espeak-data/voices/default
deleted file mode 100755
index b2fd9d084..000000000
--- a/navit/support/espeak/espeak-data/voices/default
+++ /dev/null
@@ -1,4 +0,0 @@
-name default
-language en
-gender male
-
diff --git a/navit/support/espeak/espeak-data/voices/el b/navit/support/espeak/espeak-data/voices/el
deleted file mode 100755
index 1e9a757f8..000000000
--- a/navit/support/espeak/espeak-data/voices/el
+++ /dev/null
@@ -1,5 +0,0 @@
-name greek
-language el
-gender male
-
-
diff --git a/navit/support/espeak/espeak-data/voices/en/en b/navit/support/espeak/espeak-data/voices/en/en
deleted file mode 100755
index 43e2ca1fc..000000000
--- a/navit/support/espeak/espeak-data/voices/en/en
+++ /dev/null
@@ -1,9 +0,0 @@
-name english
-language en-uk 2
-language en 2
-gender male
-
-//pitch 80 117
-
-replace 03 I i
-replace 03 I2 i
diff --git a/navit/support/espeak/espeak-data/voices/en/en-n b/navit/support/espeak/espeak-data/voices/en/en-n
deleted file mode 100755
index 933311dad..000000000
--- a/navit/support/espeak/espeak-data/voices/en/en-n
+++ /dev/null
@@ -1,14 +0,0 @@
-name lancashire
-language en-uk-north
-language en-uk 3
-gender male
-
-phonemes en_n
-
-stressLength 160 150 180 180 220 220 290 290
-
-replace 00 i@3 i@
-replace 03 N n
-//replace 03 I i
-//replace 03 I2 i
-
diff --git a/navit/support/espeak/espeak-data/voices/en/en-rp b/navit/support/espeak/espeak-data/voices/en/en-rp
deleted file mode 100755
index 3489f28ad..000000000
--- a/navit/support/espeak/espeak-data/voices/en/en-rp
+++ /dev/null
@@ -1,12 +0,0 @@
-name english_rp
-language en-uk-rp
-language en-uk 4
-gender male
-
-phonemes en_rp
-replace 00 o@ O@
-replace 00 i@3 i@
-replace 03 I i
-replace 03 I2 i
-replace 03 @ a2
-replace 03 3 a2
diff --git a/navit/support/espeak/espeak-data/voices/en/en-sc b/navit/support/espeak/espeak-data/voices/en/en-sc
deleted file mode 100755
index e16ae25a8..000000000
--- a/navit/support/espeak/espeak-data/voices/en/en-sc
+++ /dev/null
@@ -1,16 +0,0 @@
-name en-scottish
-language en-sc
-language en 4
-gender male
-
-phonemes en_sc
-dictrules 5 6 7
-stressLength 180 130 200 200 0 0 250 270
-
-replace 03 @ V
-replace 03 I i
-replace 03 I2 i
-replace 01 aI aI2
-replace 02 a a/
-replace 02 u: U
-replace 02 3: VR
diff --git a/navit/support/espeak/espeak-data/voices/en/en-us b/navit/support/espeak/espeak-data/voices/en/en-us
deleted file mode 100755
index c2656b28c..000000000
--- a/navit/support/espeak/espeak-data/voices/en/en-us
+++ /dev/null
@@ -1,17 +0,0 @@
-// moving towards US English
-name english-us
-language en-us 2
-language en-r
-language en 3
-gender male
-
-phonemes en_us
-dictrules 3 6
-option 12 1 // reduce [t]
-
-stressLength 145 125 170 170 0 0 265 290
-stressAmp 17 16 20 20 20 22 22 20
-
-replace 03 I i
-replace 03 I2 i
-replace 03 @ @/
diff --git a/navit/support/espeak/espeak-data/voices/en/en-wi b/navit/support/espeak/espeak-data/voices/en/en-wi
deleted file mode 100755
index 28a42a563..000000000
--- a/navit/support/espeak/espeak-data/voices/en/en-wi
+++ /dev/null
@@ -1,19 +0,0 @@
-name en-westindies
-language en-wi
-language en-uk 4
-gender male
-
-phonemes en_wi
-dictrules 8
-stressLength 175 175 175 175 220 220 250 290
-
-replace 00 D d
-replace 00 T t[
-replace 00 U@ o@
-replace 00 i@3 i@
-replace 03 @ a2
-replace 03 3 a2
-replace 03 N n
-
-formant 1 98 100 100
-formant 2 98 100 100
diff --git a/navit/support/espeak/espeak-data/voices/en/en-wm b/navit/support/espeak/espeak-data/voices/en/en-wm
deleted file mode 100755
index aa82f88fb..000000000
--- a/navit/support/espeak/espeak-data/voices/en/en-wm
+++ /dev/null
@@ -1,12 +0,0 @@
-name english_wmids
-language en-uk-wmids
-gender male
-
-phonemes en_wm
-
-replace 00 h NULL
-replace 00 o@ O@
-replace 00 i@3 i@
-dictrules 6
-intonation 4
-stressAdd 0 0 0 0 0 0 0 20
diff --git a/navit/support/espeak/espeak-data/voices/eo b/navit/support/espeak/espeak-data/voices/eo
deleted file mode 100755
index 36a4bff65..000000000
--- a/navit/support/espeak/espeak-data/voices/eo
+++ /dev/null
@@ -1,3 +0,0 @@
-name esperanto
-language eo
-gender male
diff --git a/navit/support/espeak/espeak-data/voices/es b/navit/support/espeak/espeak-data/voices/es
deleted file mode 100755
index 1a9e53b6e..000000000
--- a/navit/support/espeak/espeak-data/voices/es
+++ /dev/null
@@ -1,7 +0,0 @@
-name spanish
-language es
-gender male
-
-dictrules 1
-intonation 3
-
diff --git a/navit/support/espeak/espeak-data/voices/es-la b/navit/support/espeak/espeak-data/voices/es-la
deleted file mode 100755
index c326c46f5..000000000
--- a/navit/support/espeak/espeak-data/voices/es-la
+++ /dev/null
@@ -1,11 +0,0 @@
-name spanish-latin-american
-language es-la
-language es-mx 6
-gender male
-
-phonemes es_la
-dictrules 2
-intonation 2
-stressLength 170 200 180 180 0 0 250 280
-
-replace 00 T s
diff --git a/navit/support/espeak/espeak-data/voices/fi b/navit/support/espeak/espeak-data/voices/fi
deleted file mode 100755
index 6e11c9312..000000000
--- a/navit/support/espeak/espeak-data/voices/fi
+++ /dev/null
@@ -1,4 +0,0 @@
-name finnish
-language fi
-gender male
-
diff --git a/navit/support/espeak/espeak-data/voices/fr b/navit/support/espeak/espeak-data/voices/fr
deleted file mode 100755
index 973073161..000000000
--- a/navit/support/espeak/espeak-data/voices/fr
+++ /dev/null
@@ -1,7 +0,0 @@
-language fr
-name french
-gender male
-
-dictrules 1
-intonation 3
-
diff --git a/navit/support/espeak/espeak-data/voices/fr-be b/navit/support/espeak/espeak-data/voices/fr-be
deleted file mode 100755
index cba9b2757..000000000
--- a/navit/support/espeak/espeak-data/voices/fr-be
+++ /dev/null
@@ -1,7 +0,0 @@
-language fr-be
-name french (Belgium)
-gender male
-
-dictrules 2
-intonation 3
-
diff --git a/navit/support/espeak/espeak-data/voices/hi b/navit/support/espeak/espeak-data/voices/hi
deleted file mode 100755
index de4786c94..000000000
--- a/navit/support/espeak/espeak-data/voices/hi
+++ /dev/null
@@ -1,9 +0,0 @@
-name hindi-test
-language hi
-gender male
-
-translator hi
-phonemes hi
-dictionary hi
-
-dictrules 1
diff --git a/navit/support/espeak/espeak-data/voices/hr b/navit/support/espeak/espeak-data/voices/hr
deleted file mode 100755
index d6811d3ae..000000000
--- a/navit/support/espeak/espeak-data/voices/hr
+++ /dev/null
@@ -1,18 +0,0 @@
-name croatian
-language hr
-language hbs
-gender male
-
-dictionary hbs
-
-// attributes towards !variant3
-pitch 81 120
-formant 0 100 100 100
-formant 1 97 97 100
-formant 2 97 97 100
-formant 3 97 102 100
-formant 4 97 102 100
-formant 5 97 102 100
-
-stressAdd 10 10 0 0 0 0 -30 -30
-dictrules 1
diff --git a/navit/support/espeak/espeak-data/voices/hu b/navit/support/espeak/espeak-data/voices/hu
deleted file mode 100755
index ba2bdde41..000000000
--- a/navit/support/espeak/espeak-data/voices/hu
+++ /dev/null
@@ -1,3 +0,0 @@
-name hungarian
-language hu
-gender male
diff --git a/navit/support/espeak/espeak-data/voices/hy b/navit/support/espeak/espeak-data/voices/hy
deleted file mode 100644
index 6c65e3c68..000000000
--- a/navit/support/espeak/espeak-data/voices/hy
+++ /dev/null
@@ -1,3 +0,0 @@
-name armenian
-language hy
-gender male
diff --git a/navit/support/espeak/espeak-data/voices/hy-west b/navit/support/espeak/espeak-data/voices/hy-west
deleted file mode 100644
index 46317618d..000000000
--- a/navit/support/espeak/espeak-data/voices/hy-west
+++ /dev/null
@@ -1,19 +0,0 @@
-name armenian-west
-language hy
-gender male
-
-// change consonants for West Armenian pronunciation
-replace 00 b p#
-replace 00 d t#
-replace 00 dz ts#
-replace 00 dZ tS
-replace 00 g k#
-
-replace 00 p b
-replace 00 t d
-replace 00 ts dz
-replace 00 c dZ
-replace 00 k g
-
-replace 00 ** R // ??
-replace 00 r R
diff --git a/navit/support/espeak/espeak-data/voices/id b/navit/support/espeak/espeak-data/voices/id
deleted file mode 100755
index ce800f70b..000000000
--- a/navit/support/espeak/espeak-data/voices/id
+++ /dev/null
@@ -1,8 +0,0 @@
-name indonesian-test
-language id
-gender male
-
-stressLength 160 200 180 180 0 0 220 240
-stressAmp 16 18 18 18 0 0 22 21
-
-consonants 80 80
diff --git a/navit/support/espeak/espeak-data/voices/is b/navit/support/espeak/espeak-data/voices/is
deleted file mode 100755
index 9e9c4e747..000000000
--- a/navit/support/espeak/espeak-data/voices/is
+++ /dev/null
@@ -1,4 +0,0 @@
-name icelandic-test
-language is
-gender male
-
diff --git a/navit/support/espeak/espeak-data/voices/it b/navit/support/espeak/espeak-data/voices/it
deleted file mode 100755
index 53c2a7048..000000000
--- a/navit/support/espeak/espeak-data/voices/it
+++ /dev/null
@@ -1,6 +0,0 @@
-name italian
-language it
-gender male
-
-replace 03 i I
-
diff --git a/navit/support/espeak/espeak-data/voices/ku b/navit/support/espeak/espeak-data/voices/ku
deleted file mode 100755
index 536957cb8..000000000
--- a/navit/support/espeak/espeak-data/voices/ku
+++ /dev/null
@@ -1,6 +0,0 @@
-name kurdish
-language ku
-gender male
-
-//words 1 48
-
diff --git a/navit/support/espeak/espeak-data/voices/la b/navit/support/espeak/espeak-data/voices/la
deleted file mode 100644
index f3e97b523..000000000
--- a/navit/support/espeak/espeak-data/voices/la
+++ /dev/null
@@ -1,13 +0,0 @@
-name latin
-language la
-gender male
-stressrule 2 33 0 2
-// rule=penultimate
-// flags=0100001 (no automatic secondary stress + don't stres monosyllables)
-// unstressed_wd1=0
-// unstressed_wd2=2
-
-// short gap between words
-words 2
-
-// Note: The Latin voice needs long vowels to be marked with macrons
diff --git a/navit/support/espeak/espeak-data/voices/lv b/navit/support/espeak/espeak-data/voices/lv
deleted file mode 100755
index 0278ea213..000000000
--- a/navit/support/espeak/espeak-data/voices/lv
+++ /dev/null
@@ -1,6 +0,0 @@
-name latvian
-language lv
-gender male
-
-replace 03 o o:
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-af1 b/navit/support/espeak/espeak-data/voices/mb/mb-af1
deleted file mode 100755
index 03dac4f6b..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-af1
+++ /dev/null
@@ -1,7 +0,0 @@
-name afrikaans-mbrola-1
-language af 7
-gender male
-
-pitch 82 117
-mbrola af1 af1_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-af1-en b/navit/support/espeak/espeak-data/voices/mb/mb-af1-en
deleted file mode 100755
index 71ecab719..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-af1-en
+++ /dev/null
@@ -1,7 +0,0 @@
-name en-afrikaans
-language en 11
-gender male
-
-pitch 82 117
-mbrola af1 af1_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-br1 b/navit/support/espeak/espeak-data/voices/mb/mb-br1
deleted file mode 100755
index ba7c42cc4..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-br1
+++ /dev/null
@@ -1,9 +0,0 @@
-language pt 7
-name brazil-mbrola-1
-gender male
-pitch 82 117
-
-dictrules 2 3 4
-
-mbrola br1 ptbr_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-br3 b/navit/support/espeak/espeak-data/voices/mb/mb-br3
deleted file mode 100644
index 8479e658e..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-br3
+++ /dev/null
@@ -1,9 +0,0 @@
-language pt 7
-name brazil-mbrola-3
-gender male
-pitch 82 117
-
-dictrules 2 3 4
-
-mbrola br3 ptbr_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-br4 b/navit/support/espeak/espeak-data/voices/mb/mb-br4
deleted file mode 100644
index d3d772007..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-br4
+++ /dev/null
@@ -1,9 +0,0 @@
-language pt 7
-name brazil-mbrola-4
-gender female
-pitch 140 220
-
-dictrules 2 3 4
-
-mbrola br4 ptbr4_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-cr1 b/navit/support/espeak/espeak-data/voices/mb/mb-cr1
deleted file mode 100755
index 9b280bf8b..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-cr1
+++ /dev/null
@@ -1,9 +0,0 @@
-name croatian-mbrola-1
-language hr 7
-gender male
-
-dictionary hbs
-dictrules 1
-
-pitch 82 117
-mbrola cr1 cr1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-cz2 b/navit/support/espeak/espeak-data/voices/mb/mb-cz2
deleted file mode 100755
index dbde21234..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-cz2
+++ /dev/null
@@ -1,6 +0,0 @@
-name czech-mbrola-2
-language cs 7
-gender male
-
-pitch 82 117
-mbrola cz2 cs_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de2 b/navit/support/espeak/espeak-data/voices/mb/mb-de2
deleted file mode 100755
index c0a5475ec..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de2
+++ /dev/null
@@ -1,6 +0,0 @@
-name german-mbrola-2
-language de 6
-gender male
-
-mbrola de2 de2_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de4 b/navit/support/espeak/espeak-data/voices/mb/mb-de4
deleted file mode 100755
index 31bd479a3..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de4
+++ /dev/null
@@ -1,6 +0,0 @@
-name german-mbrola-4
-language de 6
-gender male
-
-mbrola de4 de4_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de4-en b/navit/support/espeak/espeak-data/voices/mb/mb-de4-en
deleted file mode 100755
index 8fd4a63a1..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de4-en
+++ /dev/null
@@ -1,6 +0,0 @@
-name en-german
-language en 9
-gender male
-
-mbrola de4 de4_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de5 b/navit/support/espeak/espeak-data/voices/mb/mb-de5
deleted file mode 100755
index 569f9d054..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de5
+++ /dev/null
@@ -1,10 +0,0 @@
-name german-mbrola-5
-language de 7
-gender female
-
-pitch 140 220
-mbrola de5 de6_phtrans 22050
-
-// avoid glottal stops. de5 assumes [?] between pause and vowel
-replace 00 _! _
-replace 00 _| _
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de5-en b/navit/support/espeak/espeak-data/voices/mb/mb-de5-en
deleted file mode 100755
index e416c6dc5..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de5-en
+++ /dev/null
@@ -1,7 +0,0 @@
-name en-german-5
-language en
-gender female
-
-pitch 140 220
-mbrola de5 de6_phtrans 22050
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de6 b/navit/support/espeak/espeak-data/voices/mb/mb-de6
deleted file mode 100644
index 35a4a3fc5..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de6
+++ /dev/null
@@ -1,6 +0,0 @@
-name german-mbrola-6
-language de 6
-gender male
-
-mbrola de6 de6_phtrans 22050
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de6-grc b/navit/support/espeak/espeak-data/voices/mb/mb-de6-grc
deleted file mode 100644
index a6e0f46bb..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de6-grc
+++ /dev/null
@@ -1,6 +0,0 @@
-name german-mbrola-6
-language grc 6
-gender male
-
-mbrola de6 grc-de6_phtrans 22050
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-de7 b/navit/support/espeak/espeak-data/voices/mb/mb-de7
deleted file mode 100755
index aa80edaad..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-de7
+++ /dev/null
@@ -1,7 +0,0 @@
-name german-mbrola-7
-language de 7
-gender female
-
-pitch 140 220
-mbrola de7 de6_phtrans 22050
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-en1 b/navit/support/espeak/espeak-data/voices/mb/mb-en1
deleted file mode 100755
index fc60f4167..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-en1
+++ /dev/null
@@ -1,7 +0,0 @@
-name english-mb-en1
-language en-uk 3
-language en 2
-gender male
-
-pitch 82 117
-mbrola en1 en1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-es1 b/navit/support/espeak/espeak-data/voices/mb/mb-es1
deleted file mode 100755
index d59fe7952..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-es1
+++ /dev/null
@@ -1,7 +0,0 @@
-language es 7
-name spanish-mbrola-1
-gender male
-pitch 82 117
-
-mbrola es1 es_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-es2 b/navit/support/espeak/espeak-data/voices/mb/mb-es2
deleted file mode 100644
index 42de58882..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-es2
+++ /dev/null
@@ -1,7 +0,0 @@
-language es 7
-name spanish-mbrola-2
-gender male
-pitch 82 117
-
-mbrola es2 es_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-fr1 b/navit/support/espeak/espeak-data/voices/mb/mb-fr1
deleted file mode 100755
index 7cbdab338..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-fr1
+++ /dev/null
@@ -1,9 +0,0 @@
-language fr 7
-name french-mbrola-1
-gender male
-
-dictrules 1
-stressLength 180 180 180 180 0 0 220 220
-pitch 82 117
-mbrola fr1 fr1_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-fr1-en b/navit/support/espeak/espeak-data/voices/mb/mb-fr1-en
deleted file mode 100755
index 366653147..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-fr1-en
+++ /dev/null
@@ -1,8 +0,0 @@
-name en-french
-language en 10
-gender male
-
-dictrules 1
-pitch 82 117
-mbrola fr1 fr1_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-fr4 b/navit/support/espeak/espeak-data/voices/mb/mb-fr4
deleted file mode 100755
index c276bec0d..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-fr4
+++ /dev/null
@@ -1,8 +0,0 @@
-language fr 7
-name french-mbrola-4
-gender female
-
-dictrules 1
-pitch 140 220
-mbrola fr1 fr1_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-fr4-en b/navit/support/espeak/espeak-data/voices/mb/mb-fr4-en
deleted file mode 100755
index b8f782946..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-fr4-en
+++ /dev/null
@@ -1,8 +0,0 @@
-language en 10
-name en-french
-gender female
-
-dictrules 1
-pitch 140 220
-mbrola fr1 fr1_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-gr2 b/navit/support/espeak/espeak-data/voices/mb/mb-gr2
deleted file mode 100755
index 30dea8920..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-gr2
+++ /dev/null
@@ -1,6 +0,0 @@
-name greek-mbrola-1
-language el 7
-gender male
-
-pitch 82 117
-mbrola gr2 gr2_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-gr2-en b/navit/support/espeak/espeak-data/voices/mb/mb-gr2-en
deleted file mode 100755
index b48b1788b..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-gr2-en
+++ /dev/null
@@ -1,6 +0,0 @@
-name en-greek
-language en 7
-gender male
-
-pitch 82 117
-mbrola gr2 gr2_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-hu1 b/navit/support/espeak/espeak-data/voices/mb/mb-hu1
deleted file mode 100755
index b8519559d..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-hu1
+++ /dev/null
@@ -1,6 +0,0 @@
-name hungarian-mbrola-1
-language hu 7
-gender female
-
-pitch 140 220
-mbrola hu1 hu1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-hu1-en b/navit/support/espeak/espeak-data/voices/mb/mb-hu1-en
deleted file mode 100755
index 73ac62a4a..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-hu1-en
+++ /dev/null
@@ -1,6 +0,0 @@
-name en-hungarian
-language en 10
-gender female
-
-pitch 140 220
-mbrola hu1 hu1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-id1 b/navit/support/espeak/espeak-data/voices/mb/mb-id1
deleted file mode 100755
index b86f59306..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-id1
+++ /dev/null
@@ -1,7 +0,0 @@
-name indonesian-mbrola-1
-language id 7
-gender male
-
-pitch 82 117
-mbrola id1 id1_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-it3 b/navit/support/espeak/espeak-data/voices/mb/mb-it3
deleted file mode 100755
index 00e88867c..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-it3
+++ /dev/null
@@ -1,8 +0,0 @@
-name italian-mbrola-3
-language it 7
-gender male
-
-pitch 82 117
-mbrola it3 it3_phtrans
-
-replace 03 i I // final unstressed "i"
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-it4 b/navit/support/espeak/espeak-data/voices/mb/mb-it4
deleted file mode 100755
index f2130ba4f..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-it4
+++ /dev/null
@@ -1,8 +0,0 @@
-name italian-mbrola-4
-language it 7
-gender female
-
-pitch 140 220
-mbrola it4 it3_phtrans
-
-replace 03 i I // final unstressed "i"
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-la1 b/navit/support/espeak/espeak-data/voices/mb/mb-la1
deleted file mode 100755
index 7ef93a5ed..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-la1
+++ /dev/null
@@ -1,6 +0,0 @@
-name latin-mbrola-1
-language la 7
-gender male
-
-pitch 82 117
-mbrola la1 la1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-nl2 b/navit/support/espeak/espeak-data/voices/mb/mb-nl2
deleted file mode 100755
index fc377156b..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-nl2
+++ /dev/null
@@ -1,7 +0,0 @@
-language nl 7
-name dutch-mbrola-2
-gender male
-
-pitch 82 117
-mbrola nl2 nl_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-nl2-en b/navit/support/espeak/espeak-data/voices/mb/mb-nl2-en
deleted file mode 100755
index 0c2d13a65..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-nl2-en
+++ /dev/null
@@ -1,7 +0,0 @@
-language en 10
-name en-dutch
-gender male
-
-pitch 82 117
-mbrola nl2 nl_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-pl1 b/navit/support/espeak/espeak-data/voices/mb/mb-pl1
deleted file mode 100755
index 4e2b9d23e..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-pl1
+++ /dev/null
@@ -1,6 +0,0 @@
-name polish-mbrola-1
-language pl 7
-gender female
-
-pitch 140 220
-mbrola pl1 pl1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-pl1-en b/navit/support/espeak/espeak-data/voices/mb/mb-pl1-en
deleted file mode 100755
index 9ba872a49..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-pl1-en
+++ /dev/null
@@ -1,6 +0,0 @@
-name en-polish
-language en 11
-gender female
-
-pitch 140 220
-mbrola pl1 pl1_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-pt1 b/navit/support/espeak/espeak-data/voices/mb/mb-pt1
deleted file mode 100644
index ebd92ffb3..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-pt1
+++ /dev/null
@@ -1,9 +0,0 @@
-language pt 7
-name portugal-mbrola-1
-gender female
-pitch 140 220
-
-dictrules 1
-
-mbrola pt1 pt1_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-ro1 b/navit/support/espeak/espeak-data/voices/mb/mb-ro1
deleted file mode 100755
index 14417c1fd..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-ro1
+++ /dev/null
@@ -1,7 +0,0 @@
-name romanian-mbrola-1
-language ro 7
-gender male
-
-pitch 82 117
-mbrola ro1 ro1_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-ro1-en b/navit/support/espeak/espeak-data/voices/mb/mb-ro1-en
deleted file mode 100755
index f310f868e..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-ro1-en
+++ /dev/null
@@ -1,7 +0,0 @@
-name en-romanian
-language en 9
-gender male
-
-pitch 82 117
-mbrola ro1 ro1_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-sw1 b/navit/support/espeak/espeak-data/voices/mb/mb-sw1
deleted file mode 100755
index 4c6239268..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-sw1
+++ /dev/null
@@ -1,7 +0,0 @@
-name swedish-mbrola-1
-language sv 7
-gender male
-
-pitch 82 117
-mbrola sw1 sv_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-sw1-en b/navit/support/espeak/espeak-data/voices/mb/mb-sw1-en
deleted file mode 100755
index 52692c385..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-sw1-en
+++ /dev/null
@@ -1,7 +0,0 @@
-name en-swedish
-language en 11
-gender male
-
-pitch 82 117
-mbrola sw1 sv_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-sw2 b/navit/support/espeak/espeak-data/voices/mb/mb-sw2
deleted file mode 100755
index c632e263c..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-sw2
+++ /dev/null
@@ -1,7 +0,0 @@
-name swedish-mbrola-2
-language sv 8
-gender female
-
-pitch 140 220
-mbrola sw2 sv2_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-sw2-en b/navit/support/espeak/espeak-data/voices/mb/mb-sw2-en
deleted file mode 100755
index f2033dc11..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-sw2-en
+++ /dev/null
@@ -1,7 +0,0 @@
-name en-swedish-f
-language en
-gender female
-
-pitch 140 220
-mbrola sw2 sv2_phtrans
-
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-us1 b/navit/support/espeak/espeak-data/voices/mb/mb-us1
deleted file mode 100755
index c62589be7..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-us1
+++ /dev/null
@@ -1,12 +0,0 @@
-name us-mbrola-1
-language en-us
-language en 8
-gender female
-
-phonemes en_us
-dictrules 3 6
-
-stressLength 170 135 205 205 0 0 245 275
-
-pitch 140 220
-mbrola us1 us_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-us2 b/navit/support/espeak/espeak-data/voices/mb/mb-us2
deleted file mode 100755
index d94fce5a4..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-us2
+++ /dev/null
@@ -1,12 +0,0 @@
-name us-mbrola-2
-language en-us
-language en 7
-gender male
-
-phonemes en_us
-dictrules 3 6
-
-stressLength 170 135 205 205 0 0 245 275
-
-pitch 82 117
-mbrola us2 us_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mb/mb-us3 b/navit/support/espeak/espeak-data/voices/mb/mb-us3
deleted file mode 100755
index 645e1b7d0..000000000
--- a/navit/support/espeak/espeak-data/voices/mb/mb-us3
+++ /dev/null
@@ -1,12 +0,0 @@
-name us-mbrola-3
-language en-us
-language en 8
-gender male
-
-phonemes en_us
-dictrules 3 6
-
-stressLength 170 135 205 205 0 0 245 275
-
-pitch 82 117
-mbrola us3 us3_phtrans
diff --git a/navit/support/espeak/espeak-data/voices/mk b/navit/support/espeak/espeak-data/voices/mk
deleted file mode 100755
index 4607dd079..000000000
--- a/navit/support/espeak/espeak-data/voices/mk
+++ /dev/null
@@ -1,4 +0,0 @@
-name macedonian-test
-language mk
-gender male
-
diff --git a/navit/support/espeak/espeak-data/voices/nl b/navit/support/espeak/espeak-data/voices/nl
deleted file mode 100755
index 6a8d5efd8..000000000
--- a/navit/support/espeak/espeak-data/voices/nl
+++ /dev/null
@@ -1,3 +0,0 @@
-language nl
-name dutch-test
-gender male
diff --git a/navit/support/espeak/espeak-data/voices/no b/navit/support/espeak/espeak-data/voices/no
deleted file mode 100755
index 77b60b963..000000000
--- a/navit/support/espeak/espeak-data/voices/no
+++ /dev/null
@@ -1,6 +0,0 @@
-name norwegian-test
-language no
-language nb
-gender male
-
-intonation 4
diff --git a/navit/support/espeak/espeak-data/voices/pl b/navit/support/espeak/espeak-data/voices/pl
deleted file mode 100755
index 8fc65d4ba..000000000
--- a/navit/support/espeak/espeak-data/voices/pl
+++ /dev/null
@@ -1,5 +0,0 @@
-name polish
-language pl
-gender male
-
-intonation 2
diff --git a/navit/support/espeak/espeak-data/voices/pt b/navit/support/espeak/espeak-data/voices/pt
deleted file mode 100755
index 53cb31446..000000000
--- a/navit/support/espeak/espeak-data/voices/pt
+++ /dev/null
@@ -1,7 +0,0 @@
-name brazil
-language pt
-language pt-br
-gender male
-
-dictrules 2
-
diff --git a/navit/support/espeak/espeak-data/voices/pt-pt b/navit/support/espeak/espeak-data/voices/pt-pt
deleted file mode 100755
index e23915f39..000000000
--- a/navit/support/espeak/espeak-data/voices/pt-pt
+++ /dev/null
@@ -1,7 +0,0 @@
-name portugal
-language pt-pt
-gender male
-phonemes pt_pt
-
-dictrules 1
-intonation 2
diff --git a/navit/support/espeak/espeak-data/voices/ro b/navit/support/espeak/espeak-data/voices/ro
deleted file mode 100755
index d8ecd252c..000000000
--- a/navit/support/espeak/espeak-data/voices/ro
+++ /dev/null
@@ -1,5 +0,0 @@
-name romanian
-language ro
-gender male
-
-
diff --git a/navit/support/espeak/espeak-data/voices/ru b/navit/support/espeak/espeak-data/voices/ru
deleted file mode 100755
index 238c69126..000000000
--- a/navit/support/espeak/espeak-data/voices/ru
+++ /dev/null
@@ -1,6 +0,0 @@
-name russian_test
-language ru
-gender male
-
-replace 03 a a#
-
diff --git a/navit/support/espeak/espeak-data/voices/sk b/navit/support/espeak/espeak-data/voices/sk
deleted file mode 100755
index 026363f6a..000000000
--- a/navit/support/espeak/espeak-data/voices/sk
+++ /dev/null
@@ -1,4 +0,0 @@
-name slovak
-language sk
-gender male
-
diff --git a/navit/support/espeak/espeak-data/voices/sq b/navit/support/espeak/espeak-data/voices/sq
deleted file mode 100644
index d0b729579..000000000
--- a/navit/support/espeak/espeak-data/voices/sq
+++ /dev/null
@@ -1,6 +0,0 @@
-name albanian
-language sq
-gender male
-
-// add this line to remove 'ë' at the end of words
-// replace 00 @/ NULL
diff --git a/navit/support/espeak/espeak-data/voices/sr b/navit/support/espeak/espeak-data/voices/sr
deleted file mode 100644
index a7a8223db..000000000
--- a/navit/support/espeak/espeak-data/voices/sr
+++ /dev/null
@@ -1,15 +0,0 @@
-name serbian
-language sr
-gender male
-dictionary hbs
-
-// attributes towards !variant3 pitch 80 120
-formant 0 100 100 100
-formant 1 97 97 100
-formant 2 97 97 100
-formant 3 97 102 100
-formant 4 97 102 100
-formant 5 97 102 100
-
-stressAdd 10 10 0 0 0 0 -30 -30
-dictrules 2 4
diff --git a/navit/support/espeak/espeak-data/voices/sv b/navit/support/espeak/espeak-data/voices/sv
deleted file mode 100755
index df70f4387..000000000
--- a/navit/support/espeak/espeak-data/voices/sv
+++ /dev/null
@@ -1,4 +0,0 @@
-name swedish
-language sv
-gender male
-
diff --git a/navit/support/espeak/espeak-data/voices/sw b/navit/support/espeak/espeak-data/voices/sw
deleted file mode 100755
index cf584b7dd..000000000
--- a/navit/support/espeak/espeak-data/voices/sw
+++ /dev/null
@@ -1,4 +0,0 @@
-name swahihi-test
-language sw
-gender male
-
diff --git a/navit/support/espeak/espeak-data/voices/ta b/navit/support/espeak/espeak-data/voices/ta
deleted file mode 100755
index 8848d6820..000000000
--- a/navit/support/espeak/espeak-data/voices/ta
+++ /dev/null
@@ -1,6 +0,0 @@
-name tamil
-language ta
-gender male
-
-intonation 2
-consonants 80
diff --git a/navit/support/espeak/espeak-data/voices/test/grc b/navit/support/espeak/espeak-data/voices/test/grc
deleted file mode 100755
index ffa942063..000000000
--- a/navit/support/espeak/espeak-data/voices/test/grc
+++ /dev/null
@@ -1,8 +0,0 @@
-name greek-ancient
-language grc
-gender male
-
-stressLength 170 170 190 190 0 0 230 240
-dictrules 1
-words 3
-
diff --git a/navit/support/espeak/espeak-data/voices/test/jbo b/navit/support/espeak/espeak-data/voices/test/jbo
deleted file mode 100644
index ebab1a875..000000000
--- a/navit/support/espeak/espeak-data/voices/test/jbo
+++ /dev/null
@@ -1,3 +0,0 @@
-name lojban
-language jbo
-
diff --git a/navit/support/espeak/espeak-data/voices/test/pap b/navit/support/espeak/espeak-data/voices/test/pap
deleted file mode 100644
index 3b105a7fb..000000000
--- a/navit/support/espeak/espeak-data/voices/test/pap
+++ /dev/null
@@ -1,5 +0,0 @@
-name papiamento-test
-language pap
-
-phonemes base2
-
diff --git a/navit/support/espeak/espeak-data/voices/tr b/navit/support/espeak/espeak-data/voices/tr
deleted file mode 100755
index 4f1904e51..000000000
--- a/navit/support/espeak/espeak-data/voices/tr
+++ /dev/null
@@ -1,4 +0,0 @@
-name turkish
-language tr
-gender male
-
diff --git a/navit/support/espeak/espeak-data/voices/vi b/navit/support/espeak/espeak-data/voices/vi
deleted file mode 100755
index 1596e3c77..000000000
--- a/navit/support/espeak/espeak-data/voices/vi
+++ /dev/null
@@ -1,6 +0,0 @@
-name vietnam-test
-language vi
-gender male
-
-words 1
-pitch 80 118
diff --git a/navit/support/espeak/espeak-data/voices/zh b/navit/support/espeak/espeak-data/voices/zh
deleted file mode 100644
index 03edde41d..000000000
--- a/navit/support/espeak/espeak-data/voices/zh
+++ /dev/null
@@ -1,30 +0,0 @@
-name Mandarin
-language zh
-gender male
-words 1
-pitch 80 118
-
-//for some dialects
-
-//[en]: replace ng with n
-//[zh]: �޺�������ng���n
-//replace 0 N n
-
-//[en]: replace rfx consonants
-//[zh]: �޾�������r���l��z��er���e
-//replace 0 ts.h tsh
-//replace 0 ts. ts
-//replace 0 s. s
-//replace 0 i. i[
-//replace 0 z. l
-//replace 0 z. z
-//replace 0 @r @
-
-//[en]: replace beginning n or l
-//[zh]: ����nl��n���l��l���n
-//replace 2 n l
-//replace 2 l n
-
-//[en]: replace beginning w with v
-//[zh]: w���v
-//replace 0 w v \ No newline at end of file
diff --git a/navit/support/espeak/espeak-data/voices/zh-yue b/navit/support/espeak/espeak-data/voices/zh-yue
deleted file mode 100755
index ba8723264..000000000
--- a/navit/support/espeak/espeak-data/voices/zh-yue
+++ /dev/null
@@ -1,14 +0,0 @@
-name cantonese-test
-language zh-yue
-language yue
-language zhy
-
-translator zhy
-phonemes zhy
-dictionary zhy
-gender male
-
-// interpret English letters as 1=English words, 2=jyutping
-dictrules 1
-
-words 1
diff --git a/navit/support/espeak/espeak-data/zh_dict b/navit/support/espeak/espeak-data/zh_dict
deleted file mode 100644
index 0b611f845..000000000
--- a/navit/support/espeak/espeak-data/zh_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak-data/zhy_dict b/navit/support/espeak/espeak-data/zhy_dict
deleted file mode 100644
index 4ad9e7c21..000000000
--- a/navit/support/espeak/espeak-data/zhy_dict
+++ /dev/null
Binary files differ
diff --git a/navit/support/espeak/espeak.c b/navit/support/espeak/espeak.c
deleted file mode 100644
index 7997d0673..000000000
--- a/navit/support/espeak/espeak.c
+++ /dev/null
@@ -1,665 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2006 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <getopt.h>
-#include <time.h>
-#include <sys/stat.h>
-
-#include "speak_lib.h"
-
-// This version of the command-line speak program uses the
-// libespeak.so.1 library
-
-
-
-static const char *help_text =
-"\nspeak [options] [\"<words>\"]\n\n"
-"-f <text file> Text file to speak\n"
-"--stdin Read text input from stdin instead of a file\n\n"
-"If neither -f nor --stdin, <words> are spoken, or if none then text is\n"
-"spoken from stdin, each line separately.\n\n"
-"-a <integer>\n"
-"\t Amplitude, 0 to 200, default is 100\n"
-"-g <integer>\n"
-"\t Word gap. Pause between words, units of 10mS at the default speed\n"
-"-l <integer>\n"
-"\t Line length. If not zero (which is the default), consider\n"
-"\t lines less than this length as end-of-clause\n"
-"-p <integer>\n"
-"\t Pitch adjustment, 0 to 99, default is 50\n"
-"-s <integer>\n"
-"\t Speed in words per minute, 80 to 390, default is 170\n"
-"-v <voice name>\n"
-"\t Use voice file of this name from espeak-data/voices\n"
-"-w <wave file name>\n"
-"\t Write output to this WAV file, rather than speaking it directly\n"
-"-b\t Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit \n"
-"-m\t Interpret SSML markup, and ignore other < > tags\n"
-"-q\t Quiet, don't produce any speech (may be useful with -x)\n"
-"-x\t Write phoneme mnemonics to stdout\n"
-"-X\t Write phonemes mnemonics and translation trace to stdout\n"
-"-z\t No final sentence pause at the end of the text\n"
-"--stdout Write speech output to stdout\n"
-"--compile=<voice name>\n"
-"\t Compile the pronunciation rules and dictionary in the current\n"
-"\t directory. =<voice name> is optional and specifies which language\n"
-"--path=\"<path>\"\n"
-"\t Specifies the directory containing the espeak-data directory\n"
-"--phonout=\"<filename>\"\n"
-"\t Write output from -x -X commands and mbrola phoneme data to this file\n"
-"--punct=\"<characters>\"\n"
-"\t Speak the names of punctuation characters during speaking. If\n"
-"\t =<characters> is omitted, all punctuation is spoken.\n"
-"--split=\"<minutes>\"\n"
-"\t Starts a new WAV file every <minutes>. Used with -w\n"
-"--voices=<language>\n"
-"\t List the available voices for the specified language.\n"
-"\t If <language> is omitted, then list all voices.\n"
-"-k <integer>\n"
-"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
-"\t higher values = a pitch increase (try -k20).\n";
-
-
-
-
-int samplerate;
-int quiet = 0;
-unsigned int samples_total = 0;
-unsigned int samples_split = 0;
-unsigned int wavefile_count = 0;
-
-FILE *f_wavfile = NULL;
-char filetype[5];
-char wavefile[200];
-
-
-int GetFileLength(const char *filename)
-{//====================================
- struct stat statbuf;
-
- if(stat(filename,&statbuf) != 0)
- return(0);
-
- if((statbuf.st_mode & S_IFMT) == S_IFDIR)
- return(-2); // a directory
-
- return(statbuf.st_size);
-} // end of GetFileLength
-
-
-void strncpy0(char *dest, const char *source, int size)
-{//====================================================
- if(source!=NULL)
- {
- strncpy(dest,source,size);
- dest[size-1] = 0;
- }
-}
-
-
-void DisplayVoices(FILE *f_out, char *language)
-{//============================================
- int ix;
- const char *p;
- int len;
- int count;
- int scores = 0;
- const espeak_VOICE *v;
- const char *lang_name;
- char age_buf[12];
- const espeak_VOICE **voices;
- espeak_VOICE voice_select;
-
- static char genders[4] = {' ','M','F',' '};
-
- if((language != NULL) && (language[0] != 0))
- {
- // display only voices for the specified language, in order of priority
- voice_select.languages = language;
- voice_select.age = 0;
- voice_select.gender = 0;
- voice_select.name = NULL;
- voices = espeak_ListVoices(&voice_select);
- scores = 1;
- }
- else
- {
- voices = espeak_ListVoices(NULL);
- }
-
- fprintf(f_out,"Pty Language Age/Gender VoiceName File Other Langs\n");
-
- for(ix=0; (v = voices[ix]) != NULL; ix++)
- {
- count = 0;
- p = v->languages;
- while(*p != 0)
- {
- len = strlen(p+1);
- lang_name = p+1;
-
- if(v->age == 0)
- strcpy(age_buf," ");
- else
- sprintf(age_buf,"%3d",v->age);
-
- if(count==0)
- {
- fprintf(f_out,"%2d %-12s%s%c %-17s %-11s ",
- p[0],lang_name,age_buf,genders[v->gender],v->name,v->identifier);
- }
- else
- {
- fprintf(f_out,"(%s %d)",lang_name,p[0]);
- }
- count++;
- p += len+2;
- }
-// if(scores)
-// fprintf(f_out,"%3d ",v->score);
- fputc('\n',f_out);
- }
-} // end of DisplayVoices
-
-
-
-
-static void Write4Bytes(FILE *f, int value)
-{//=================================
-// Write 4 bytes to a file, least significant first
- int ix;
-
- for(ix=0; ix<4; ix++)
- {
- fputc(value & 0xff,f);
- value = value >> 8;
- }
-}
-
-
-
-int OpenWavFile(char *path, int rate)
-//===================================
-{
- static unsigned char wave_hdr[44] = {
- 'R','I','F','F',0x24,0xf0,0xff,0x7f,'W','A','V','E','f','m','t',' ',
- 0x10,0,0,0,1,0,1,0, 9,0x3d,0,0,0x12,0x7a,0,0,
- 2,0,0x10,0,'d','a','t','a', 0x00,0xf0,0xff,0x7f};
-
- if(path == NULL)
- return(2);
-
- if(path[0] == 0)
- return(0);
-
- if(strcmp(path,"stdout")==0)
- f_wavfile = stdout;
- else
- f_wavfile = fopen(path,"wb");
-
- if(f_wavfile != NULL)
- {
- fwrite(wave_hdr,1,24,f_wavfile);
- Write4Bytes(f_wavfile,rate);
- Write4Bytes(f_wavfile,rate * 2);
- fwrite(&wave_hdr[32],1,12,f_wavfile);
- return(0);
- }
- return(1);
-} // end of OpenWavFile
-
-
-
-static void CloseWavFile()
-//========================
-{
- unsigned int pos;
-
- if((f_wavfile==NULL) || (f_wavfile == stdout))
- return;
-
- fflush(f_wavfile);
- pos = ftell(f_wavfile);
-
- fseek(f_wavfile,4,SEEK_SET);
- Write4Bytes(f_wavfile,pos - 8);
-
- fseek(f_wavfile,40,SEEK_SET);
- Write4Bytes(f_wavfile,pos - 44);
-
- fclose(f_wavfile);
- f_wavfile = NULL;
-
-} // end of CloseWavFile
-
-
-static int SynthCallback(short *wav, int numsamples, espeak_EVENT *events)
-{//========================================================================
- char fname[210];
-
- if(quiet) return(0); // -q quiet mode
-
- if(wav == NULL)
- {
- CloseWavFile();
- return(0);
- }
-
- if(samples_split > 0)
- {
- // start a new WAV file when this limit is reached, at the next sentence boundary
- while(events->type != 0)
- {
- if((events->type == espeakEVENT_SENTENCE) && (samples_total > samples_split))
- {
- CloseWavFile();
- samples_total = 0;
- }
- events++;
- }
- }
-
- if(f_wavfile == NULL)
- {
- sprintf(fname,"%s_%.2d%s",wavefile,++wavefile_count,filetype);
- if(OpenWavFile(fname, samplerate) != 0)
- return(1);
- }
-
- if(numsamples > 0)
- {
- samples_total += numsamples;
- fwrite(wav,numsamples*2,1,f_wavfile);
- }
- return(0);
-}
-
-
-
-int main (int argc, char **argv)
-//==============================
-{
- static struct option long_options[] =
- {
- /* These options set a flag. */
-// {"verbose", no_argument, &verbose_flag, 1},
-// {"brief", no_argument, &verbose_flag, 0},
-
- /* These options don't set a flag.
- We distinguish them by their indices. */
- {"help", no_argument, 0, 'h'},
- {"stdin", no_argument, 0, 0x100},
- {"compile-debug", optional_argument, 0, 0x101},
- {"compile", optional_argument, 0, 0x102},
- {"punct", optional_argument, 0, 0x103},
- {"voices", optional_argument, 0, 0x104},
- {"stdout", no_argument, 0, 0x105},
- {"split", optional_argument, 0, 0x106},
- {"path", required_argument, 0, 0x107},
- {"phonout", required_argument, 0, 0x108},
- {0, 0, 0, 0}
- };
-
- static const char* err_load = "Failed to read ";
-
-
- FILE *f_text=NULL;
- char *p_text=NULL;
- FILE *f_phonemes_out = stdout;
- char *data_path = NULL; // use default path for espeak-data
-
- int option_index = 0;
- int c;
- int ix;
- int value;
- int flag_stdin = 0;
- int flag_compile = 0;
- int filesize = 0;
- int synth_flags = espeakCHARS_AUTO | espeakPHONEMES | espeakENDPAUSE;
-
- int volume = -1;
- int speed = -1;
- int pitch = -1;
- int wordgap = -1;
- int option_capitals = -1;
- int option_punctuation = -1;
- int option_phonemes = -1;
- int option_linelength = 0;
- int option_waveout = 0;
-
- espeak_VOICE voice_select;
- char filename[200];
- char voicename[40];
- char voice_mbrola[20];
- char dictname[40];
-#define N_PUNCTLIST 100
- wchar_t option_punctlist[N_PUNCTLIST];
-
- voicename[0] = 0;
- voice_mbrola[0] = 0;
- dictname[0] = 0;
- wavefile[0] = 0;
- filename[0] = 0;
- option_punctlist[0] = 0;
-
- while(true)
- {
- c = getopt_long (argc, argv, "a:b:f:g:hk:l:mp:qs:v:w:xXz",
- long_options, &option_index);
-
- /* Detect the end of the options. */
- if (c == -1)
- break;
-
- switch (c)
- {
- case 'b':
- // input character encoding, 8bit, 16bit, UTF8
- if((sscanf(optarg,"%d",&value) == 1) && (value <= 4))
- synth_flags |= value;
- else
- synth_flags |= espeakCHARS_8BIT;
- break;
-
- case 'h':
- printf("\n");
- printf("eSpeak text-to-speech: %s\n%s",espeak_Info(),help_text);
- exit(0);
- break;
-
- case 'k':
- option_capitals = atoi(optarg);
- break;
-
- case 'x':
- option_phonemes = 1;
- break;
-
- case 'X':
- option_phonemes = 2;
- break;
-
- case 'm':
- synth_flags |= espeakSSML;
- break;
-
- case 'p':
- pitch = atoi(optarg);
- break;
-
- case 'q':
- quiet = 1;
- break;
-
- case 'f':
- strncpy0(filename,optarg,sizeof(filename));
- break;
-
- case 'l':
- option_linelength = atoi(optarg);
- break;
-
- case 'a':
- volume = atoi(optarg);
- break;
-
- case 's':
- speed = atoi(optarg);
- break;
-
- case 'g':
- wordgap = atoi(optarg);
- break;
-
- case 'v':
- strncpy0(voicename,optarg,sizeof(voicename));
- break;
-
- case 'w':
- option_waveout = 1;
- strncpy0(wavefile,optarg,sizeof(filename));
- break;
-
- case 'z': // remove pause from the end of a sentence
- synth_flags &= ~espeakENDPAUSE;
- break;
-
- case 0x100: // --stdin
- flag_stdin = 1;
- break;
-
- case 0x105: // --stdout
- option_waveout = 1;
- strcpy(wavefile,"stdout");
- break;
-
- case 0x101: // --compile-debug
- case 0x102: // --compile
- strncpy0(voicename,optarg,sizeof(voicename));
- flag_compile = c;
- quiet = 1;
- break;
-
- case 0x103: // --punct
- option_punctuation = 1;
- if(optarg != NULL)
- {
- ix = 0;
- while((ix < N_PUNCTLIST) && ((option_punctlist[ix] = optarg[ix]) != 0)) ix++;
- option_punctlist[N_PUNCTLIST-1] = 0;
- option_punctuation = 2;
- }
- break;
-
- case 0x104: // --voices
- espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,data_path,0);
- DisplayVoices(stdout,optarg);
- exit(0);
-
- case 0x106: // -- split
- if(optarg == NULL)
- samples_split = 30; // default 30 minutes
- else
- samples_split = atoi(optarg);
- break;
-
- case 0x107: // --path
- data_path = optarg;
- break;
-
- case 0x108: // --phonout
- if((f_phonemes_out = fopen(optarg,"w")) == NULL)
- {
- fprintf(stderr,"Can't write to: %s\n",optarg);
- }
- break;
-
- default:
- exit(0);
- }
- }
-
-
- if(option_waveout || quiet)
- {
- // writing to a file (or no output), we can use synchronous mode
- samplerate = espeak_Initialize(AUDIO_OUTPUT_SYNCHRONOUS,0,data_path,0);
- samples_split = (samplerate * samples_split) * 60;
-
- espeak_SetSynthCallback(SynthCallback);
- if(samples_split)
- {
- char *extn;
- extn = strrchr(wavefile,'.');
- if((extn != NULL) && ((wavefile + strlen(wavefile) - extn) <= 4))
- {
- strcpy(filetype,extn);
- *extn = 0;
- }
- }
- else
- if(option_waveout)
- {
- if(OpenWavFile(wavefile,samplerate) != 0)
- exit(4);
- }
- }
- else
- {
- // play the sound output
- samplerate = espeak_Initialize(AUDIO_OUTPUT_PLAYBACK,0,data_path,0);
- }
-
-
- if(voicename[0] == 0)
- strcpy(voicename,"default");
-
- if(espeak_SetVoiceByName(voicename) != EE_OK)
- {
- memset(&voice_select,0,sizeof(voice_select));
- voice_select.languages = voicename;
- if(espeak_SetVoiceByProperties(&voice_select) != EE_OK)
- {
- fprintf(stderr,"%svoice '%s'\n",err_load,voicename);
- exit(2);
- }
- }
-
- if(flag_compile)
- {
- // This must be done after the voice is set
- espeak_CompileDictionary("", stderr, flag_compile & 0x1);
- exit(0);
- }
-
- // set any non-default values of parameters. This must be done after espeak_Initialize()
- if(speed > 0)
- espeak_SetParameter(espeakRATE,speed,0);
- if(volume >= 0)
- espeak_SetParameter(espeakVOLUME,volume,0);
- if(pitch >= 0)
- espeak_SetParameter(espeakPITCH,pitch,0);
- if(option_capitals >= 0)
- espeak_SetParameter(espeakCAPITALS,option_capitals,0);
- if(option_punctuation >= 0)
- espeak_SetParameter(espeakPUNCTUATION,option_punctuation,0);
- if(wordgap >= 0)
- espeak_SetParameter(espeakWORDGAP,wordgap,0);
- if(option_linelength > 0)
- espeak_SetParameter(espeakLINELENGTH,option_linelength,0);
- if(option_punctuation == 2)
- espeak_SetPunctuationList(option_punctlist);
- espeak_SetPhonemeTrace(option_phonemes,f_phonemes_out);
-
- if(filename[0]==0)
- {
- if((optind < argc) && (flag_stdin == 0))
- {
- // there's a non-option parameter, and no -f or --stdin
- // use it as text
- p_text = argv[optind];
- }
- else
- {
- f_text = stdin;
- if(flag_stdin == 0)
- {
- flag_stdin = 2;
- }
- }
- }
- else
- {
- filesize = GetFileLength(filename);
- f_text = fopen(filename,"r");
- }
-
- if((f_text == NULL) && (p_text == NULL))
- {
- fprintf(stderr,"%sfile '%s'\n",err_load,filename);
- exit(1);
- }
-
-
- if(p_text != NULL)
- {
- int size;
- size = strlen(p_text);
- espeak_Synth(p_text,size+1,0,POS_CHARACTER,0,synth_flags,NULL,NULL);
- }
- else
- if(flag_stdin)
- {
- int max = 1000;
- p_text = (char *)malloc(max);
-
- if(flag_stdin == 2)
- {
- // line by line input on stdin
- while(fgets(p_text,max,stdin) != NULL)
- {
- p_text[max-1] = 0;
- espeak_Synth(p_text,max,0,POS_CHARACTER,0,synth_flags,NULL,NULL);
-
- }
- }
- else
- {
- // bulk input on stdin
- ix = 0;
- while(!feof(stdin))
- {
- p_text[ix++] = fgetc(stdin);
- if(ix >= (max-1))
- {
- max += 1000;
- p_text = (char *)realloc(p_text,max);
- }
- }
- if(ix > 0)
- {
- p_text[ix-1] = 0;
- espeak_Synth(p_text,ix+1,0,POS_CHARACTER,0,synth_flags,NULL,NULL);
- }
- }
- }
- else
- if(f_text != NULL)
- {
- if((p_text = (char *)malloc(filesize+1)) == NULL)
- {
- fprintf(stderr,"Failed to allocate memory %d bytes",filesize);
- exit(3);
- }
-
- fread(p_text,1,filesize,f_text);
- p_text[filesize]=0;
- espeak_Synth(p_text,filesize+1,0,POS_CHARACTER,0,synth_flags,NULL,NULL);
- fclose(f_text);
- }
-
- espeak_Synchronize();
-
- if(f_phonemes_out != stdout)
- fclose(f_phonemes_out); // needed for WinCE
- return(0);
-}
diff --git a/navit/support/espeak/espeak_command.c b/navit/support/espeak/espeak_command.c
deleted file mode 100644
index 1b59333c1..000000000
--- a/navit/support/espeak/espeak_command.c
+++ /dev/null
@@ -1,707 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2007, Gilles Casse <gcasse@oralux.org> *
- * *
- * 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 3 of the License, 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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#include "speech.h"
-
-#ifdef USE_ASYNC
-// This source file is only used for asynchronious modes
-
-#include "espeak_command.h"
-#include <stdlib.h>
-#include <string.h>
-#include <assert.h>
-#include <wchar.h>
-
-#include "debug.h"
-
-
-static unsigned int my_current_text_id=0;
-
-
-//<create_espeak_text
-t_espeak_command* create_espeak_text(const void *text, size_t size, unsigned int position, espeak_POSITION_TYPE position_type, unsigned int end_position, unsigned int flags, void* user_data)
-{
- ENTER("create_espeak_text");
- int a_error=1;
- void* a_text = NULL;
- t_espeak_text* data = NULL;
- t_espeak_command* a_command = (t_espeak_command*)malloc(sizeof(t_espeak_command));
-
- if (!text || !size || !a_command)
- {
- goto text_error;
- }
-
- a_text = malloc( size );
- if (!a_text)
- {
- goto text_error;
- }
- memcpy(a_text, text, size);
-
- a_command->type = ET_TEXT;
- a_command->state = CS_UNDEFINED;
- data = &(a_command->u.my_text);
- data->unique_identifier = ++my_current_text_id;
- data->text = a_text;
- data->size = size;
- data->position = position;
- data->position_type = position_type;
- data->end_position = end_position;
- data->flags = flags;
- data->user_data = user_data;
- a_error=0;
-
- SHOW("ET_TEXT malloc text=%x, command=%x (uid=%d)\n", a_text, a_command, data->unique_identifier);
-
- text_error:
- if (a_error)
- {
- if (a_text)
- {
- free (a_text);
- }
- if (a_command)
- {
- free (a_command);
- }
- a_command = NULL;
- }
-
- SHOW("command=0x%x\n", a_command);
-
- return a_command;
-}
-
-//>
-
-
-t_espeak_command* create_espeak_terminated_msg(unsigned int unique_identifier, void* user_data)
-{
- ENTER("create_espeak_terminated_msg");
- int a_error=1;
- t_espeak_terminated_msg* data = NULL;
- t_espeak_command* a_command = (t_espeak_command*)malloc(sizeof(t_espeak_command));
-
- if (!a_command)
- {
- goto msg_error;
- }
-
- a_command->type = ET_TERMINATED_MSG;
- a_command->state = CS_UNDEFINED;
- data = &(a_command->u.my_terminated_msg);
- data->unique_identifier = unique_identifier;
- data->user_data = user_data;
- a_error=0;
-
- SHOW("ET_TERMINATED_MSG command=%x (uid=%d, user_data=0x%x)\n", a_command, unique_identifier, (int)user_data);
-
- msg_error:
- if (a_error)
- {
- if (a_command)
- {
- free (a_command);
- }
- a_command = NULL;
- }
-
- SHOW("command=0x%x\n", a_command);
-
- return a_command;
-
-}
-
-
-
-
-//<create_espeak_mark
-t_espeak_command* create_espeak_mark(const void *text, size_t size, const char *index_mark, unsigned int end_position, unsigned int flags, void* user_data)
-{
- ENTER("create_espeak_mark");
- int a_error=1;
- void* a_text = NULL;
- char *a_index_mark = NULL;
- t_espeak_mark* data = NULL;
- t_espeak_command* a_command = (t_espeak_command*)malloc(sizeof(t_espeak_command));
-
- if (!text || !size || !index_mark || !a_command)
- {
- goto mark_error;
- }
-
- a_text = malloc( size );
- if (!a_text)
- {
- goto mark_error;
- }
- memcpy(a_text, text, size);
-
- a_index_mark = strdup( index_mark);
-
- a_command->type = ET_MARK;
- a_command->state = CS_UNDEFINED;
- data = &(a_command->u.my_mark);
- data->unique_identifier = ++my_current_text_id;
- data->text = a_text;
- data->size = size;
- data->index_mark = a_index_mark;
- data->end_position = end_position;
- data->flags = flags;
- data->user_data = user_data;
- a_error=0;
-
- mark_error:
- if (a_error)
- {
- if (a_text)
- {
- free (a_text);
- }
- if (a_command)
- {
- free (a_command);
- }
- a_command = NULL;
- if (a_index_mark)
- {
- free (a_index_mark);
- }
- }
-
- SHOW("ET_MARK malloc text=%x, command=%x (uid=%d)\n", a_text, a_command, data->unique_identifier);
-
- return a_command;
-}
-//>
-//< create_espeak_key, create_espeak_char
-
-t_espeak_command* create_espeak_key(const char *key_name, void *user_data)
-{
- ENTER("create_espeak_key");
- int a_error=1;
- t_espeak_command* a_command = (t_espeak_command*)malloc(sizeof(t_espeak_command));
-
- if (!key_name || !a_command)
- {
- goto key_error;
- }
-
- a_command->type = ET_KEY;
- a_command->state = CS_UNDEFINED;
- a_command->u.my_key.user_data = user_data;
- a_command->u.my_key.unique_identifier = ++my_current_text_id;
- a_command->u.my_key.key_name = strdup( key_name);
- a_error=0;
-
- key_error:
- if (a_error)
- {
- if (a_command)
- {
- free (a_command);
- }
- a_command = NULL;
- }
-
- SHOW("command=0x%x\n", a_command);
-
- return a_command;
-}
-
-t_espeak_command* create_espeak_char(wchar_t character, void* user_data)
-{
- ENTER("create_espeak_char");
- int a_error=1;
- t_espeak_command* a_command = (t_espeak_command*)malloc(sizeof(t_espeak_command));
- if (!a_command)
- {
- goto char_error;
- }
-
- a_command->type = ET_CHAR;
- a_command->state = CS_UNDEFINED;
- a_command->u.my_char.user_data = user_data;
- a_command->u.my_char.unique_identifier = ++my_current_text_id;
- a_command->u.my_char.character = character;
- a_error=0;
-
- char_error:
- if (a_error)
- {
- if (a_command)
- {
- free (a_command);
- }
- a_command = NULL;
- }
-
- SHOW("command=0x%x\n", a_command);
-
- return a_command;
-}
-
-//>
-//< create_espeak_parameter
-
-t_espeak_command* create_espeak_parameter(espeak_PARAMETER parameter, int value, int relative)
-{
- ENTER("create_espeak_parameter");
- int a_error=1;
- t_espeak_parameter* data = NULL;
- t_espeak_command* a_command = (t_espeak_command*)malloc(sizeof(t_espeak_command));
- if (!a_command)
- {
- goto param_error;
- }
-
- a_command->type = ET_PARAMETER;
- a_command->state = CS_UNDEFINED;
- data = &(a_command->u.my_param);
- data->parameter = parameter;
- data->value = value;
- data->relative = relative;
- a_error=0;
-
- param_error:
- if (a_error)
- {
- if (a_command)
- {
- free (a_command);
- }
- a_command = NULL;
- }
-
- SHOW("command=0x%x\n", a_command);
-
- return a_command;
-}
-
-//>
-//< create_espeak_punctuation_list
-
-t_espeak_command* create_espeak_punctuation_list(const wchar_t *punctlist)
-{
- ENTER("create_espeak_punctuation_list");
- int a_error=1;
- // wchar_t *a_list = NULL;
- t_espeak_command* a_command = (t_espeak_command*)malloc(sizeof(t_espeak_command));
-
- if (!punctlist || !a_command)
- {
- goto list_error;
- }
-
- a_command->type = ET_PUNCTUATION_LIST;
- a_command->state = CS_UNDEFINED;
-
- {
- size_t len = (wcslen(punctlist) + 1)*sizeof(wchar_t);
- wchar_t* a_list = (wchar_t*)malloc(len);
- memcpy(a_list, punctlist, len);
- a_command->u.my_punctuation_list = a_list;
- }
-
- a_error=0;
-
- list_error:
- if (a_error)
- {
- if (a_command)
- {
- free (a_command);
- }
- a_command = NULL;
- }
-
- SHOW("command=0x%x\n", a_command);
-
- return a_command;
-}
-
-//>
-//< create_espeak_voice_name, create_espeak_voice_spec
-
-t_espeak_command* create_espeak_voice_name(const char *name)
-{
- ENTER("create_espeak_voice_name");
-
- int a_error=1;
- t_espeak_command* a_command = (t_espeak_command*)malloc(sizeof(t_espeak_command));
-
- if (!name || !a_command)
- {
- goto name_error;
- }
-
- a_command->type = ET_VOICE_NAME;
- a_command->state = CS_UNDEFINED;
- a_command->u.my_voice_name = strdup( name);
- a_error=0;
-
- name_error:
- if (a_error)
- {
- if (a_command)
- {
- free (a_command);
- }
- a_command = NULL;
- }
-
- SHOW("command=0x%x\n", a_command);
-
- return a_command;
-}
-
-t_espeak_command* create_espeak_voice_spec(espeak_VOICE *voice)
-{
- ENTER("create_espeak_voice_spec");
- int a_error=1;
- t_espeak_command* a_command = (t_espeak_command*)malloc(sizeof(t_espeak_command));
-
- if (!voice || !a_command)
- {
- goto spec_error;
- }
-
- a_command->type = ET_VOICE_SPEC;
- a_command->state = CS_UNDEFINED;
- {
- espeak_VOICE* data = &(a_command->u.my_voice_spec);
- memcpy(data, voice, sizeof(espeak_VOICE));
-
- if (voice->name)
- {
- data->name = strdup(voice->name);
- }
-
- if (voice->languages)
- {
- data->languages = strdup(voice->languages);
- }
-
- if (voice->identifier)
- {
- data->identifier = strdup(voice->identifier);
- }
-
- a_error=0;
- }
-
- spec_error:
- if (a_error)
- {
- if (a_command)
- {
- free (a_command);
- }
- a_command = NULL;
- }
-
- SHOW("command=0x%x\n", a_command);
-
- return a_command;
-}
-
-//>
-//< delete_espeak_command
-int delete_espeak_command( t_espeak_command* the_command)
-{
- ENTER("delete_espeak_command");
- int a_status = 0;
- if (the_command)
- {
- switch(the_command->type)
- {
- case ET_TEXT:
- if (the_command->u.my_text.text)
- {
- SHOW("delete_espeak_command > ET_TEXT free text=%x, command=%x, uid=%d\n", the_command->u.my_text.text, the_command, the_command->u.my_text.unique_identifier);
- free(the_command->u.my_text.text);
- }
- break;
-
- case ET_MARK:
- if (the_command->u.my_mark.text)
- {
- free(the_command->u.my_mark.text);
- }
- if (the_command->u.my_mark.index_mark)
- {
- free((void*)(the_command->u.my_mark.index_mark));
- }
- break;
-
- case ET_TERMINATED_MSG:
- {
- // if the terminated msg is pending,
- // it must be processed here for informing the calling program
- // that its message is finished.
- // This can be important for cleaning the related user data.
- t_espeak_terminated_msg* data = &(the_command->u.my_terminated_msg);
- if (the_command->state == CS_PENDING)
- {
- the_command->state = CS_PROCESSED;
- SHOW("delete_espeak_command > ET_TERMINATED_MSG callback (command=0x%x, uid=%d) \n", the_command, data->unique_identifier);
- sync_espeak_terminated_msg( data->unique_identifier, data->user_data);
- }
- }
- break;
-
- case ET_KEY:
- if (the_command->u.my_key.key_name)
- {
- free((void*)(the_command->u.my_key.key_name));
- }
- break;
-
- case ET_CHAR:
- case ET_PARAMETER:
- // No allocation
- break;
-
- case ET_PUNCTUATION_LIST:
- if (the_command->u.my_punctuation_list)
- {
- free((void*)(the_command->u.my_punctuation_list));
- }
- break;
-
- case ET_VOICE_NAME:
- if (the_command->u.my_voice_name)
- {
- free((void*)(the_command->u.my_voice_name));
- }
- break;
-
- case ET_VOICE_SPEC:
- {
- espeak_VOICE* data = &(the_command->u.my_voice_spec);
-
- if (data->name)
- {
- free((void *)data->name);
- }
-
- if (data->languages)
- {
- free((void *)data->languages);
- }
-
- if (data->identifier)
- {
- free((void *)data->identifier);
- }
- }
- break;
-
- default:
- assert(0);
- }
- SHOW("delete_espeak_command > free command=0x%x\n", the_command);
- free(the_command);
- a_status = 1;
- }
- return a_status;
-}
-//>
-//< process_espeak_command
-void process_espeak_command( t_espeak_command* the_command)
-{
- ENTER("process_espeak_command");
-
- SHOW("command=0x%x\n", the_command);
-
- if (the_command == NULL)
- {
- return;
- }
-
- the_command->state = CS_PROCESSED;
-
- switch(the_command->type)
- {
- case ET_TEXT:
- {
- t_espeak_text* data = &(the_command->u.my_text);
- sync_espeak_Synth( data->unique_identifier, data->text, data->size,
- data->position, data->position_type,
- data->end_position, data->flags, data->user_data);
- }
- break;
-
- case ET_MARK:
- {
- t_espeak_mark* data = &(the_command->u.my_mark);
- sync_espeak_Synth_Mark( data->unique_identifier, data->text, data->size,
- data->index_mark, data->end_position, data->flags,
- data->user_data);
- }
- break;
-
- case ET_TERMINATED_MSG:
- {
- t_espeak_terminated_msg* data = &(the_command->u.my_terminated_msg);
- sync_espeak_terminated_msg( data->unique_identifier, data->user_data);
- }
- break;
-
- case ET_KEY:
- {
- const char* data = the_command->u.my_key.key_name;
- sync_espeak_Key(data);
- }
- break;
-
- case ET_CHAR:
- {
- const wchar_t data = the_command->u.my_char.character;
- sync_espeak_Char( data);
- }
- break;
-
- case ET_PARAMETER:
- {
- t_espeak_parameter* data = &(the_command->u.my_param);
- SetParameter( data->parameter, data->value, data->relative);
- }
- break;
-
- case ET_PUNCTUATION_LIST:
- {
- const wchar_t* data = the_command->u.my_punctuation_list;
- sync_espeak_SetPunctuationList( data);
- }
- break;
-
- case ET_VOICE_NAME:
- {
- const char* data = the_command->u.my_voice_name;
- SetVoiceByName( data);
- }
- break;
-
- case ET_VOICE_SPEC:
- {
- espeak_VOICE* data = &(the_command->u.my_voice_spec);
- SetVoiceByProperties(data);
- }
- break;
-
- default:
- assert(0);
- break;
- }
-}
-
-//>
-
-//< process_espeak_command
-void display_espeak_command( t_espeak_command* the_command)
-{
- ENTER("display_espeak_command");
-#ifdef DEBUG_ENABLED
- if (the_command == NULL)
- {
- SHOW("display_espeak_command > command=%s\n","NULL");
- return;
- }
-
- SHOW("display_espeak_command > state=%d\n",the_command->state);
-
- switch(the_command->type)
- {
- case ET_TEXT:
- {
- t_espeak_text* data = &(the_command->u.my_text);
- SHOW("display_espeak_command > (0x%x) uid=%d, TEXT=%s, user_data=0x%x\n", the_command, data->unique_identifier, (char*)data->text, (int)(data->user_data));
- }
- break;
-
- case ET_MARK:
- {
- t_espeak_mark* data = &(the_command->u.my_mark);
- SHOW("display_espeak_command > (0x%x) uid=%d, MARK=%s, user_data=0x%x\n", the_command, data->unique_identifier, (char*)data->text, (int)(data->user_data));
- }
- break;
-
- case ET_KEY:
- {
- const char* data = the_command->u.my_key;
- SHOW("display_espeak_command > (0x%x) KEY=%c\n", the_command, data);
- }
- break;
-
- case ET_TERMINATED_MSG:
- {
- t_espeak_terminated_msg* data = &(the_command->u.my_terminated_msg);
-
- SHOW("display_espeak_command > (0x%x) TERMINATED_MSG uid=%d, user_data=0x%x, state=%d\n",
- the_command, data->unique_identifier, data->user_data,
- the_command->state);
- }
- break;
-
- case ET_CHAR:
- {
- const wchar_t data = the_command->u.my_char;
- SHOW("display_espeak_command > (0x%x) CHAR=%c\n", the_command, (char)data);
- }
- break;
-
- case ET_PARAMETER:
- {
- t_espeak_parameter* data = &(the_command->u.my_param);
- SHOW("display_espeak_command > (0x%x) PARAMETER=%d, value=%d, relative=%d\n",
- the_command, data->parameter, data->value, data->relative);
- }
- break;
-
- case ET_PUNCTUATION_LIST:
- {
- const wchar_t* data = the_command->u.my_punctuation_list;
- sync_espeak_SetPunctuationList( data);
- SHOW("display_espeak_command > (0x%x) PUNCTLIST=%s\n", the_command, (char*)data);
- }
- break;
-
- case ET_VOICE_NAME:
- {
- const char* data = the_command->u.my_voice_name;
- SHOW("display_espeak_command > (0x%x) VOICE_NAME=%s\n", the_command, data);
- }
- break;
-
- case ET_VOICE_SPEC:
- {
- SHOW("display_espeak_command > (0x%x) VOICE_SPEC", the_command);
- }
- break;
-
- default:
- assert(0);
- break;
- }
-#endif
-}
-
-#endif
-//>
diff --git a/navit/support/espeak/espeak_command.h b/navit/support/espeak/espeak_command.h
deleted file mode 100644
index b2664be6a..000000000
--- a/navit/support/espeak/espeak_command.h
+++ /dev/null
@@ -1,145 +0,0 @@
-#ifndef ESPEAK_COMMAND_H
-#define ESPEAK_COMMAND_H
-
-#ifndef PLATFORM_WINDOWS
-#include <unistd.h>
-#endif
-#include "speak_lib.h"
-
-enum t_espeak_type
- {
- ET_TEXT,
- ET_MARK,
- ET_KEY,
- ET_CHAR,
- ET_PARAMETER,
- ET_PUNCTUATION_LIST,
- ET_VOICE_NAME,
- ET_VOICE_SPEC,
- ET_TERMINATED_MSG
- };
-
-typedef struct
-{
- unsigned int unique_identifier;
- void* text;
- size_t size;
- unsigned int position;
- espeak_POSITION_TYPE position_type;
- unsigned int end_position;
- unsigned int flags;
- void* user_data;
-} t_espeak_text;
-
-typedef struct
-{
- unsigned int unique_identifier;
- void* text;
- size_t size;
- const char* index_mark;
- unsigned int end_position;
- unsigned int flags;
- void* user_data;
-} t_espeak_mark;
-
-typedef struct
-{
- unsigned int unique_identifier;
- void* user_data;
- wchar_t character;
-} t_espeak_character;
-
-typedef struct
-{
- unsigned int unique_identifier;
- void* user_data;
- const char* key_name;
-} t_espeak_key;
-
-
-typedef struct
-{
- unsigned int unique_identifier;
- void* user_data;
-} t_espeak_terminated_msg;
-
-
-typedef struct
-{
- espeak_PARAMETER parameter;
- int value;
- int relative;
-} t_espeak_parameter;
-
-enum t_command_state
-{
- CS_UNDEFINED, // The command has just been created
- CS_PENDING, // stored in the fifo
- CS_PROCESSED // processed
-};
-
-typedef struct
-{
- enum t_espeak_type type;
- enum t_command_state state;
-
- union command
- {
- t_espeak_text my_text;
- t_espeak_mark my_mark;
- t_espeak_key my_key;
- t_espeak_character my_char;
- t_espeak_parameter my_param;
- const wchar_t* my_punctuation_list;
- const char *my_voice_name;
- espeak_VOICE my_voice_spec;
- t_espeak_terminated_msg my_terminated_msg;
- } u;
-} t_espeak_command;
-
-
-t_espeak_command* create_espeak_text(const void *text, size_t size, unsigned int position, espeak_POSITION_TYPE position_type, unsigned int end_position, unsigned int flags, void* user_data);
-
-t_espeak_command* create_espeak_mark(const void *text, size_t size, const char *index_mark, unsigned int end_position, unsigned int flags, void* user_data);
-
-t_espeak_command* create_espeak_terminated_msg(unsigned int unique_identifier, void* user_data);
-
-t_espeak_command* create_espeak_key(const char *key_name, void *user_data);
-
-t_espeak_command* create_espeak_char(wchar_t character, void *user_data);
-
-t_espeak_command* create_espeak_parameter(espeak_PARAMETER parameter, int value, int relative);
-
-t_espeak_command* create_espeak_punctuation_list(const wchar_t *punctlist);
-
-t_espeak_command* create_espeak_voice_name(const char *name);
-
-t_espeak_command* create_espeak_voice_spec(espeak_VOICE *voice_spec);
-
-void process_espeak_command( t_espeak_command* the_command);
-
-int delete_espeak_command( t_espeak_command* the_command);
-
-void display_espeak_command(t_espeak_command* the_command);
-
-
-espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, size_t size,
- unsigned int position, espeak_POSITION_TYPE position_type,
- unsigned int end_position, unsigned int flags, void* user_data);
-espeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, size_t size,
- const char *index_mark, unsigned int end_position,
- unsigned int flags, void* user_data);
-void sync_espeak_Key(const char *key);
-void sync_espeak_Char(wchar_t character);
-void sync_espeak_SetPunctuationList(const wchar_t *punctlist);
-void sync_espeak_SetParameter(espeak_PARAMETER parameter, int value, int relative);
-int sync_espeak_SetVoiceByName(const char *name);
-int sync_espeak_SetVoiceByProperties(espeak_VOICE *voice_selector);
-espeak_ERROR SetVoiceByName(const char *name);
-espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector);
-void SetParameter(int parameter, int value, int relative);
-
-int sync_espeak_terminated_msg(unsigned int unique_identifier, void* user_data);
-
-//>
-#endif
diff --git a/navit/support/espeak/event.c b/navit/support/espeak/event.c
deleted file mode 100644
index cc696272d..000000000
--- a/navit/support/espeak/event.c
+++ /dev/null
@@ -1,725 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2007, Gilles Casse <gcasse@oralux.org> *
- * *
- * 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 3 of the License, 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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-#include "speech.h"
-
-#ifdef USE_ASYNC
-// This source file is only used for asynchronious modes
-
-
-//<includes
-#include <unistd.h>
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <sys/time.h>
-#include <errno.h>
-
-#include "speak_lib.h"
-#include "event.h"
-#include "wave.h"
-#include "debug.h"
-//>
-//<decls and function prototypes
-
-
-// my_mutex: protects my_thread_is_talking,
-static pthread_mutex_t my_mutex;
-static sem_t my_sem_start_is_required;
-static sem_t my_sem_stop_is_required;
-static sem_t my_sem_stop_is_acknowledged;
-// my_thread: polls the audio duration and compares it to the duration of the first event.
-static pthread_t my_thread;
-
-static t_espeak_callback* my_callback = NULL;
-static int my_event_is_running=0;
-
-enum {MIN_TIMEOUT_IN_MS=10,
- ACTIVITY_TIMEOUT=50, // in ms, check that the stream is active
- MAX_ACTIVITY_CHECK=6
-};
-
-
-typedef struct t_node
-{
- void* data;
- t_node *next;
-} node;
-
-static node* head=NULL;
-static node* tail=NULL;
-static int node_counter=0;
-static espeak_ERROR push(void* data);
-static void* pop();
-static void init();
-static void* polling_thread(void*);
-
-//>
-//<event_init
-
-void event_set_callback(t_espeak_callback* SynthCallback)
-{
- my_callback = SynthCallback;
-}
-
-void event_init(void)
-{
- ENTER("event_init");
-
- my_event_is_running=0;
-
- // security
- pthread_mutex_init( &my_mutex, (const pthread_mutexattr_t *)NULL);
- init();
-
- assert(-1 != sem_init(&my_sem_start_is_required, 0, 0));
- assert(-1 != sem_init(&my_sem_stop_is_required, 0, 0));
- assert(-1 != sem_init(&my_sem_stop_is_acknowledged, 0, 0));
-
- pthread_attr_t a_attrib;
- if (pthread_attr_init (& a_attrib)
- || pthread_attr_setdetachstate(&a_attrib, PTHREAD_CREATE_JOINABLE)
- || pthread_create( &my_thread,
- & a_attrib,
- polling_thread,
- (void*)NULL))
- {
- assert(0);
- }
-
- pthread_attr_destroy(&a_attrib);
-}
-//>
-//<event_display
-static void event_display(espeak_EVENT* event)
-{
-ENTER("event_display");
-
-#ifdef DEBUG_ENABLED
- if (event==NULL)
- {
- SHOW("event_display > event=%s\n","NULL");
- }
- else
- {
- static const char* label[] = {
- "LIST_TERMINATED",
- "WORD",
- "SENTENCE",
- "MARK",
- "PLAY",
- "END",
- "MSG_TERMINATED"
- };
-
- SHOW("event_display > event=0x%x\n",event);
- SHOW("event_display > type=%s\n",label[event->type]);
- SHOW("event_display > uid=%d\n",event->unique_identifier);
- SHOW("event_display > text_position=%d\n",event->text_position);
- SHOW("event_display > length=%d\n",event->length);
- SHOW("event_display > audio_position=%d\n",event->audio_position);
- SHOW("event_display > sample=%d\n",event->sample);
- SHOW("event_display > user_data=0x%x\n",event->user_data);
- }
-#endif
-}
-//>
-//<event_copy
-
-static espeak_EVENT* event_copy (espeak_EVENT* event)
-{
- ENTER("event_copy");
-
- if (event==NULL)
- {
- return NULL;
- }
-
- espeak_EVENT* a_event=(espeak_EVENT*)malloc(sizeof(espeak_EVENT));
- if (a_event)
- {
- memcpy(a_event, event, sizeof(espeak_EVENT));
-
- switch(event->type)
- {
- case espeakEVENT_MARK:
- case espeakEVENT_PLAY:
- if (event->id.name)
- {
- a_event->id.name = strdup(event->id.name);
- }
- break;
-
- default:
- break;
- }
- }
-
- event_display(a_event);
-
- return a_event;
-}
-
-//>
-//<event_notify
-
-// Call the user supplied callback
-//
-// Note: the current sequence is:
-//
-// * First call with: event->type = espeakEVENT_SENTENCE
-// * 0, 1 or several calls: event->type = espeakEVENT_WORD
-// * Last call: event->type = espeakEVENT_MSG_TERMINATED
-//
-
-static void event_notify(espeak_EVENT* event)
-{
-ENTER("event_notify");
- static unsigned int a_old_uid = 0;
-
- espeak_EVENT events[2];
- memcpy(&events[0],event,sizeof(espeak_EVENT)); // the event parameter in the callback function should be an array of eventd
- memcpy(&events[1],event,sizeof(espeak_EVENT));
- events[1].type = espeakEVENT_LIST_TERMINATED; // ... terminated by an event type=0
-
- if (event && my_callback)
- {
- event_display(event);
-
- switch(event->type)
- {
- case espeakEVENT_SENTENCE:
- my_callback(NULL, 0, events);
- a_old_uid = event->unique_identifier;
- break;
-
- case espeakEVENT_MSG_TERMINATED:
- case espeakEVENT_MARK:
- case espeakEVENT_WORD:
- case espeakEVENT_END:
- case espeakEVENT_PHONEME:
- {
-// jonsd - I'm not sure what this is for. gilles says it's for when Gnome Speech reads a file of blank lines
- if (a_old_uid != event->unique_identifier)
- {
- espeak_EVENT_TYPE a_new_type = events[0].type;
- events[0].type = espeakEVENT_SENTENCE;
- my_callback(NULL, 0, events);
- events[0].type = a_new_type;
- usleep(50000);
- }
- my_callback(NULL, 0, events);
- a_old_uid = event->unique_identifier;
- }
- break;
-
- default:
- case espeakEVENT_LIST_TERMINATED:
- case espeakEVENT_PLAY:
- break;
- }
- }
-}
-//>
-//<event_delete
-
-static int event_delete(espeak_EVENT* event)
-{
-ENTER("event_delete");
-
- event_display(event);
-
- if(event==NULL)
- {
- return 0;
- }
-
- switch(event->type)
- {
- case espeakEVENT_MSG_TERMINATED:
- event_notify(event);
- break;
-
- case espeakEVENT_MARK:
- case espeakEVENT_PLAY:
- if(event->id.name)
- {
- free((void*)(event->id.name));
- }
- break;
-
- default:
- break;
- }
-
- free(event);
- return 1;
-}
-
-//>
-//<event_declare
-
-espeak_ERROR event_declare (espeak_EVENT* event)
-{
-ENTER("event_declare");
-
- event_display(event);
-
- if (!event)
- {
- return EE_INTERNAL_ERROR;
- }
-
- int a_status = pthread_mutex_lock(&my_mutex);
- espeak_ERROR a_error = EE_OK;
-
- if (!a_status)
- {
- SHOW_TIME("event_declare > locked\n");
- espeak_EVENT* a_event = event_copy(event);
- a_error = push(a_event);
- if (a_error != EE_OK)
- {
- event_delete(a_event);
- }
- SHOW_TIME("event_declare > unlocking\n");
- a_status = pthread_mutex_unlock(&my_mutex);
- }
-
- // TBD: remove the comment
- // reminder: code in comment.
- // This wait can lead to an underrun
- //
-// if (!a_status && !my_event_is_running && (a_error == EE_OK))
-// {
-// // quit when command is actually started
-// // (for possible forthcoming 'end of command' checks)
- SHOW_TIME("event_declare > post my_sem_start_is_required\n");
- sem_post(&my_sem_start_is_required);
-// int val=1;
-// while (val)
-// {
-// usleep(50000); // TBD: event?
-// sem_getvalue(&my_sem_start_is_required, &val);
-// }
-// }
-
- if (a_status != 0)
- {
- a_error = EE_INTERNAL_ERROR;
- }
-
- return a_error;
-}
-
-//>
-//<event_clear_all
-
-espeak_ERROR event_clear_all ()
-{
- ENTER("event_clear_all");
-
- int a_status = pthread_mutex_lock(&my_mutex);
- int a_event_is_running = 0;
-
- SHOW_TIME("event_stop > locked\n");
- if (a_status != 0)
- {
- return EE_INTERNAL_ERROR;
- }
-
- if (my_event_is_running)
- {
- SHOW_TIME("event_stop > post my_sem_stop_is_required\n");
- sem_post(&my_sem_stop_is_required);
- a_event_is_running = 1;
- }
- else
- {
- init(); // clear pending events
- }
- SHOW_TIME("event_stop > unlocking\n");
- a_status = pthread_mutex_unlock(&my_mutex);
- if (a_status != 0)
- {
- return EE_INTERNAL_ERROR;
- }
-
- if (a_event_is_running)
- {
- SHOW_TIME("event_stop > wait for my_sem_stop_is_acknowledged\n");
- while ((sem_wait(&my_sem_stop_is_acknowledged) == -1) && errno == EINTR)
- {
- continue; // Restart when interrupted by handler
- }
- SHOW_TIME("event_stop > get my_sem_stop_is_acknowledged\n");
- }
-
- SHOW_TIME("LEAVE event_stop\n");
-
- return EE_OK;
-}
-
-//>
-//<sleep_until_timeout_or_stop_request
-
-static int sleep_until_timeout_or_stop_request(uint32_t time_in_ms)
-{
-ENTER("sleep_until_timeout_or_stop_request");
-
- int a_stop_is_required=0;
- struct timespec ts, to;
- struct timeval tv;
- int err=0;
-
- clock_gettime2( &ts);
- to.tv_sec = ts.tv_sec;
- to.tv_nsec = ts.tv_nsec;
-
- add_time_in_ms( &ts, time_in_ms);
-
- SHOW("polling_thread > sleep_until_timeout_or_stop_request > start sem_timedwait from %d.%09lu to %d.%09lu \n",
- to.tv_sec, to.tv_nsec,
- ts.tv_sec, ts.tv_nsec);
-
- while ((err = sem_timedwait(&my_sem_stop_is_required, &ts)) == -1
- && errno == EINTR)
- {
- continue; // Restart when interrupted by handler
- }
-
- assert (gettimeofday(&tv, NULL) != -1);
- SHOW("polling_thread > sleep_until_timeout_or_stop_request > stop sem_timedwait %d.%09lu \n",
- tv.tv_sec, tv.tv_usec*1000);
-
- if (err == 0)
- {
- SHOW("polling_thread > sleep_until_timeout_or_stop_request > %s\n","stop required!");
- a_stop_is_required=1; // stop required
- }
- return a_stop_is_required;
-}
-
-//>
-//<get_remaining_time
-// Asked for the time interval required for reaching the sample.
-// If the stream is opened but the audio samples are not played,
-// a timeout is started.
-
-static int get_remaining_time(uint32_t sample, uint32_t* time_in_ms, int* stop_is_required)
-{
-ENTER("get_remaining_time");
-
- int err = 0;
- *stop_is_required = 0;
- int i=0;
-
- for (i=0; i < MAX_ACTIVITY_CHECK && (*stop_is_required == 0); i++)
- {
- err = wave_get_remaining_time( sample, time_in_ms);
-
- if (err || wave_is_busy(NULL) || (*time_in_ms == 0))
- { // if err, stream not available: quit
- // if wave is busy, time_in_ms is known: quit
- // if wave is not busy but remaining time == 0, event is reached: quit
- break;
- }
-
- // stream opened but not active
- //
- // Several possible states:
- // * the stream is opened but not yet started:
- //
- // wait for the start of stream
- //
- // * some samples have already been played,
- // ** the end of stream is reached
- // ** or there is an underrun
- //
- // wait for the close of stream
-
- *stop_is_required = sleep_until_timeout_or_stop_request( ACTIVITY_TIMEOUT);
- }
-
- return err;
-}
-
-//>
-//<polling_thread
-
-static void* polling_thread(void*)
-{
-ENTER("polling_thread");
-
- while(1)
- {
- int a_stop_is_required=0;
-
- SHOW_TIME("polling_thread > locking\n");
- int a_status = pthread_mutex_lock(&my_mutex);
- SHOW_TIME("polling_thread > locked (my_event_is_running = 0)\n");
- my_event_is_running = 0;
- pthread_mutex_unlock(&my_mutex);
- SHOW_TIME("polling_thread > unlocked\n");
-
- SHOW_TIME("polling_thread > wait for my_sem_start_is_required\n");
-
- while ((sem_wait(&my_sem_start_is_required) == -1) && errno == EINTR)
- {
- continue; // Restart when interrupted by handler
- }
-
- SHOW_TIME("polling_thread > get my_sem_start_is_required\n");
-
- a_status = pthread_mutex_lock(&my_mutex);
- SHOW_TIME("polling_thread > locked (my_event_is_running = 1)\n");
- my_event_is_running = 1;
- pthread_mutex_unlock(&my_mutex);
- SHOW_TIME("polling_thread > unlocked\n");
-
- a_stop_is_required=0;
- a_status = sem_getvalue(&my_sem_stop_is_required, &a_stop_is_required);
- if ((a_status==0) && a_stop_is_required)
- {
- SHOW("polling_thread > stop required (%d)\n", __LINE__);
- while(0 == sem_trywait(&my_sem_stop_is_required))
- {
- };
- }
- else
- {
- a_stop_is_required=0;
- }
-
- // In this loop, my_event_is_running = 1
- while (head && !a_stop_is_required)
- {
- SHOW_TIME("polling_thread > check head\n");
- while(0 == sem_trywait(&my_sem_start_is_required))
- {
- };
-
- espeak_EVENT* event = (espeak_EVENT*)(head->data);
- assert(event);
-
- uint32_t time_in_ms = 0;
-
- int err = get_remaining_time((uint32_t)event->sample,
- &time_in_ms,
- &a_stop_is_required);
- if (a_stop_is_required)
- {
- break;
- }
- else if (err != 0)
- {
- // No available time: the event is deleted.
- SHOW("polling_thread > %s\n","audio device down");
- a_status = pthread_mutex_lock(&my_mutex);
- SHOW_TIME("polling_thread > locked\n");
- event_delete( (espeak_EVENT*)pop());
- a_status = pthread_mutex_unlock(&my_mutex);
- SHOW_TIME("polling_thread > unlocked\n");
- }
- else if (time_in_ms==0)
- { // the event is already reached.
- if (my_callback)
- {
- event_notify(event);
- // the user_data (and the type) are cleaned to be sure
- // that MSG_TERMINATED is called twice (at delete time too).
- event->type=espeakEVENT_LIST_TERMINATED;
- event->user_data=NULL;
- }
-
- a_status = pthread_mutex_lock(&my_mutex);
- SHOW_TIME("polling_thread > locked\n");
- event_delete( (espeak_EVENT*)pop());
- a_status = pthread_mutex_unlock(&my_mutex);
- SHOW_TIME("polling_thread > unlocked\n");
-
- a_stop_is_required=0;
- a_status = sem_getvalue(&my_sem_stop_is_required, &a_stop_is_required);
-
- if ((a_status==0) && a_stop_is_required)
- {
- SHOW("polling_thread > stop required (%d)\n", __LINE__);
- while(0 == sem_trywait(&my_sem_stop_is_required))
- {
- };
- }
- else
- {
- a_stop_is_required=0;
- }
- }
- else
- { // The event will be notified soon: sleep until timeout or stop request
- a_stop_is_required = sleep_until_timeout_or_stop_request(time_in_ms);
- }
- }
-
- a_status = pthread_mutex_lock(&my_mutex);
- SHOW_TIME("polling_thread > locked\n");
-
- SHOW_TIME("polling_thread > my_event_is_running = 0\n");
- my_event_is_running = 0;
-
- if(!a_stop_is_required)
- {
- a_status = sem_getvalue(&my_sem_stop_is_required, &a_stop_is_required);
- if ((a_status==0) && a_stop_is_required)
- {
- SHOW("polling_thread > stop required (%d)\n", __LINE__);
- while(0 == sem_trywait(&my_sem_stop_is_required))
- {
- };
- }
- else
- {
- a_stop_is_required=0;
- }
- }
-
- a_status = pthread_mutex_unlock(&my_mutex);
- SHOW_TIME("polling_thread > unlocked\n");
-
- if (a_stop_is_required)
- {
- SHOW("polling_thread > %s\n","stop required!");
- // no mutex required since the stop command is synchronous
- // and waiting for my_sem_stop_is_acknowledged
- init();
-
- // acknowledge the stop request
- SHOW_TIME("polling_thread > post my_sem_stop_is_acknowledged\n");
- a_status = sem_post(&my_sem_stop_is_acknowledged);
- }
- }
-
- return NULL;
-}
-
-//>
-//<push, pop, init
-enum {MAX_NODE_COUNTER=1000};
-// return 1 if ok, 0 otherwise
-static espeak_ERROR push(void* the_data)
-{
- ENTER("event > push");
-
- assert((!head && !tail) || (head && tail));
-
- if (the_data == NULL)
- {
- SHOW("event > push > event=0x%x\n", NULL);
- return EE_INTERNAL_ERROR;
- }
-
- if (node_counter >= MAX_NODE_COUNTER)
- {
- SHOW("event > push > %s\n", "EE_BUFFER_FULL");
- return EE_BUFFER_FULL;
- }
-
- node *n = (node *)malloc(sizeof(node));
- if (n == NULL)
- {
- return EE_INTERNAL_ERROR;
- }
-
- if (head == NULL)
- {
- head = n;
- tail = n;
- }
- else
- {
- tail->next = n;
- tail = n;
- }
-
- tail->next = NULL;
- tail->data = the_data;
-
- node_counter++;
- SHOW("event > push > counter=%d (uid=%d)\n",node_counter,((espeak_EVENT*)the_data)->unique_identifier);
-
- return EE_OK;
-}
-
-static void* pop()
-{
- ENTER("event > pop");
- void* the_data = NULL;
-
- assert((!head && !tail) || (head && tail));
-
- if (head != NULL)
- {
- node* n = head;
- the_data = n->data;
- head = n->next;
- free(n);
- node_counter--;
- SHOW("event > pop > event=0x%x (counter=%d, uid=%d)\n",the_data, node_counter,((espeak_EVENT*)the_data)->unique_identifier);
- }
-
- if(head == NULL)
- {
- tail = NULL;
- }
-
- return the_data;
-}
-
-
-static void init()
-{
- ENTER("event > init");
-
- while (event_delete( (espeak_EVENT*)pop() ))
- {}
-
- node_counter = 0;
-}
-
-//>
-//<event_terminate
-void event_terminate()
-{
-ENTER("event_terminate");
-
- if (my_thread)
- {
- pthread_cancel(my_thread);
- pthread_join(my_thread,NULL);
- pthread_mutex_destroy(&my_mutex);
- sem_destroy(&my_sem_start_is_required);
- sem_destroy(&my_sem_stop_is_required);
- sem_destroy(&my_sem_stop_is_acknowledged);
- init(); // purge event
- }
-}
-
-#endif
-//>
-
diff --git a/navit/support/espeak/event.h b/navit/support/espeak/event.h
deleted file mode 100644
index c9ee482b0..000000000
--- a/navit/support/espeak/event.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef EVENT_H
-#define EVENT_H
-
-/*
-Manage events (sentence, word, mark, end,...), is responsible of calling the external
-callback as soon as the relevant audio sample is played.
-
-
-The audio stream is composed of samples from synthetised messages or audio icons.
-Each event is associated to a sample.
-
-Scenario:
-
-- event_declare is called for each expected event.
-
-- A timeout is started for the first pending event.
-
-- When the timeout happens, the synth_callback is called.
-
-Note: the timeout is checked against the real progress of the audio stream, which depends on pauses or underruns. If the real progress is lower than the expected one, a new timeout starts.
-
-*/
-
-#include "speak_lib.h"
-
-// Initialize the event component.
-// First function to be called.
-// the callback will be called when the event actually occurs.
-// The callback is detailled in speak_lib.h .
-void event_init(void);
-void event_set_callback(t_espeak_callback* cb);
-
-// Clear any pending event.
-//
-// Return: EE_OK: operation achieved
-// EE_INTERNAL_ERROR.
-espeak_ERROR event_clear_all ();
-
-// Declare a future event
-//
-// Return: EE_OK: operation achieved
-// EE_BUFFER_FULL: the event can not be buffered;
-// you may try after a while to call the function again.
-// EE_INTERNAL_ERROR.
-espeak_ERROR event_declare (espeak_EVENT* event);
-
-// Terminate the event component.
-// Last function to be called.
-void event_terminate();
-
-#endif
diff --git a/navit/support/espeak/fifo.c b/navit/support/espeak/fifo.c
deleted file mode 100644
index 95d5ab1ed..000000000
--- a/navit/support/espeak/fifo.c
+++ /dev/null
@@ -1,593 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2007, Gilles Casse <gcasse@oralux.org> *
- * *
- * 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 3 of the License, 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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-#include "speech.h"
-
-#ifdef USE_ASYNC
-// This source file is only used for asynchronious modes
-
-
-//<includes
-
-#include <unistd.h>
-#include <assert.h>
-#include <string.h>
-#include <stdlib.h>
-#include <pthread.h>
-#include <semaphore.h>
-#include <wchar.h>
-#include <errno.h>
-#include <sys/time.h>
-#include <time.h>
-
-#include "fifo.h"
-#include "wave.h"
-#include "debug.h"
-
-
-//>
-//<decls and function prototypes
-
-// my_mutex: protects my_thread_is_talking,
-// my_stop_is_required, and the command fifo
-static pthread_mutex_t my_mutex;
-static int my_command_is_running = 0;
-static int my_stop_is_required = 0;
-// + fifo
-//
-
-// my_thread: reads commands from the fifo, and runs them.
-static pthread_t my_thread;
-static sem_t my_sem_start_is_required;
-static sem_t my_sem_stop_is_acknowledged;
-
-static void* say_thread(void*);
-
-static espeak_ERROR push(t_espeak_command* the_command);
-static t_espeak_command* pop();
-static void init();
-static int node_counter=0;
-enum {MAX_NODE_COUNTER=400,
- INACTIVITY_TIMEOUT=50, // in ms, check that the stream is inactive
- MAX_INACTIVITY_CHECK=2
-};
-
-//>
-//<fifo_init
-void fifo_init()
-{
- ENTER("fifo_init");
-
- // security
- pthread_mutex_init( &my_mutex, (const pthread_mutexattr_t *)NULL);
- init();
-
- assert(-1 != sem_init(&my_sem_start_is_required, 0, 0));
- assert(-1 != sem_init(&my_sem_stop_is_acknowledged, 0, 0));
-
- pthread_attr_t a_attrib;
- if (pthread_attr_init (& a_attrib)
- || pthread_attr_setdetachstate(&a_attrib, PTHREAD_CREATE_JOINABLE)
- || pthread_create( &my_thread,
- & a_attrib,
- say_thread,
- (void*)NULL))
- {
- assert(0);
- }
-
- pthread_attr_destroy(&a_attrib);
-
- // leave once the thread is actually started
- SHOW_TIME("fifo > wait for my_sem_stop_is_acknowledged\n");
- while ((sem_wait(&my_sem_stop_is_acknowledged) == -1) && errno == EINTR)
- {
- continue; // Restart when interrupted by handler
- }
- SHOW_TIME("fifo > get my_sem_stop_is_acknowledged\n");
-}
-//>
-//<fifo_add_command
-
-espeak_ERROR fifo_add_command (t_espeak_command* the_command)
-{
- ENTER("fifo_add_command");
-
- int a_status = pthread_mutex_lock(&my_mutex);
- espeak_ERROR a_error = EE_OK;
-
- if (!a_status)
- {
- SHOW_TIME("fifo_add_command > locked\n");
- a_error = push(the_command);
- SHOW_TIME("fifo_add_command > unlocking\n");
- a_status = pthread_mutex_unlock(&my_mutex);
- }
-
- if (!a_status && !my_command_is_running && (a_error == EE_OK))
- {
- // quit when command is actually started
- // (for possible forthcoming 'end of command' checks)
- SHOW_TIME("fifo_add_command > post my_sem_start_is_required\n");
- sem_post(&my_sem_start_is_required);
- int val=1;
- while (val)
- {
- usleep(50000); // TBD: event?
- sem_getvalue(&my_sem_start_is_required, &val);
- }
- }
-
- if (a_status != 0)
- {
- a_error = EE_INTERNAL_ERROR;
- }
-
- SHOW_TIME("LEAVE fifo_add_command");
- return a_error;
-}
-
-//>
-//<fifo_add_commands
-
-espeak_ERROR fifo_add_commands (t_espeak_command* command1, t_espeak_command* command2)
-{
- ENTER("fifo_add_command");
-
- int a_status = pthread_mutex_lock(&my_mutex);
- espeak_ERROR a_error = EE_OK;
-
- if (!a_status)
- {
- SHOW_TIME("fifo_add_commands > locked\n");
-
- if (node_counter+1 >= MAX_NODE_COUNTER)
- {
- SHOW("push > %s\n", "EE_BUFFER_FULL");
- a_error = EE_BUFFER_FULL;
- }
- else
- {
- push(command1);
- push(command2);
- }
- SHOW_TIME("fifo_add_command > unlocking\n");
- a_status = pthread_mutex_unlock(&my_mutex);
- }
-
- if (!a_status && !my_command_is_running && (a_error == EE_OK))
- {
- // quit when one command is actually started
- // (for possible forthcoming 'end of command' checks)
- SHOW_TIME("fifo_add_command > post my_sem_start_is_required\n");
- sem_post(&my_sem_start_is_required);
- int val=1;
- while (val)
- {
- usleep(50000); // TBD: event?
- sem_getvalue(&my_sem_start_is_required, &val);
- }
- }
-
- if (a_status != 0)
- {
- a_error = EE_INTERNAL_ERROR;
- }
-
- SHOW_TIME("LEAVE fifo_add_commands");
- return a_error;
-}
-
-//>
-//<fifo_stop
-
-espeak_ERROR fifo_stop ()
-{
- ENTER("fifo_stop");
-
- int a_command_is_running = 0;
- int a_status = pthread_mutex_lock(&my_mutex);
- SHOW_TIME("fifo_stop > locked\n");
- if (a_status != 0)
- {
- return EE_INTERNAL_ERROR;
- }
-
- if (my_command_is_running)
- {
- a_command_is_running = 1;
- my_stop_is_required = 1;
- SHOW_TIME("fifo_stop > my_stop_is_required = 1\n");
- }
- SHOW_TIME("fifo_stop > unlocking\n");
- a_status = pthread_mutex_unlock(&my_mutex);
- if (a_status != 0)
- {
- return EE_INTERNAL_ERROR;
- }
-
- if (a_command_is_running)
- {
- SHOW_TIME("fifo_stop > wait for my_sem_stop_is_acknowledged\n");
- while ((sem_wait(&my_sem_stop_is_acknowledged) == -1) && errno == EINTR)
- {
- continue; // Restart when interrupted by handler
- }
- SHOW_TIME("fifo_stop > get my_sem_stop_is_acknowledged\n");
- }
-
- SHOW_TIME("fifo_stop > my_stop_is_required = 0\n");
- my_stop_is_required = 0;
- SHOW_TIME("LEAVE fifo_stop\n");
-
- return EE_OK;
-}
-
-//>
-
-//<fifo_is_speaking
-int fifo_is_busy ()
-{
- // ENTER("isSpeaking");
- // int aResult = (int) (my_command_is_running || WaveIsPlaying());
- SHOW("fifo_is_busy > aResult = %d\n",my_command_is_running);
- return my_command_is_running;
-}
-
-// int pause ()
-// {
-// ENTER("pause");
-// // TBD
-// // if (espeakPause (espeakHandle, 1))
-// return true;
-// }
-
-// int resume ()
-// {
-// ENTER("resume");
-// // TBD
-// // if (espeakPause (espeakHandle, 0))
-// return true;
-// }
-//>
-
-
-//<sleep_until_start_request_or_inactivity
-
-static int sleep_until_start_request_or_inactivity()
-{
- SHOW_TIME("fifo > sleep_until_start_request_or_inactivity > ENTER");
- int a_start_is_required=0;
-
- // Wait for the start request (my_sem_start_is_required).
- // Besides this, if the audio stream is still busy,
- // check from time to time its end.
- // The end of the stream is confirmed by several checks
- // for filtering underflow.
- //
- int i=0;
- while((i<= MAX_INACTIVITY_CHECK) && !a_start_is_required)
- {
- if (wave_is_busy( NULL) )
- {
- i = 0;
- }
- else
- {
- i++;
- }
-
- int err=0;
- struct timespec ts, to;
- struct timeval tv;
-
- clock_gettime2( &ts);
- to.tv_sec = ts.tv_sec;
- to.tv_nsec = ts.tv_nsec;
-
- add_time_in_ms( &ts, INACTIVITY_TIMEOUT);
-
- SHOW("fifo > sleep_until_start_request_or_inactivity > start sem_timedwait (start_is_required) from %d.%09lu to %d.%09lu \n",
- to.tv_sec, to.tv_nsec,
- ts.tv_sec, ts.tv_nsec);
-
- while ((err = sem_timedwait(&my_sem_start_is_required, &ts)) == -1
- && errno == EINTR)
- {
- continue;
- }
-
- assert (gettimeofday(&tv, NULL) != -1);
- SHOW("fifo > sleep_until_start_request_or_inactivity > stop sem_timedwait (start_is_required, err=%d) %d.%09lu \n", err,
- tv.tv_sec, tv.tv_usec*1000);
-
- if (err==0)
- {
- a_start_is_required = 1;
- }
- }
- SHOW_TIME("fifo > sleep_until_start_request_or_inactivity > LEAVE");
- return a_start_is_required;
-}
-
-//>
-//<close_stream
-
-static void close_stream()
-{
- SHOW_TIME("fifo > close_stream > ENTER\n");
-
- // Warning: a wave_close can be already required by
- // an external command (espeak_Cancel + fifo_stop), if so:
- // my_stop_is_required = 1;
-
- int a_status = pthread_mutex_lock(&my_mutex);
- assert (!a_status);
- int a_stop_is_required = my_stop_is_required;
- if (!a_stop_is_required)
- {
- my_command_is_running = 1;
- }
- a_status = pthread_mutex_unlock(&my_mutex);
-
- if (!a_stop_is_required)
- {
- wave_close(NULL);
-
- int a_status = pthread_mutex_lock(&my_mutex);
- assert (!a_status);
- my_command_is_running = 0;
-
- a_stop_is_required = my_stop_is_required;
- a_status = pthread_mutex_unlock(&my_mutex);
-
- if (a_stop_is_required)
- {
- // acknowledge the stop request
- SHOW_TIME("fifo > close_stream > post my_sem_stop_is_acknowledged\n");
- int a_status = sem_post(&my_sem_stop_is_acknowledged);
- assert( a_status != -1);
- }
- }
-
- SHOW_TIME("fifo > close_stream > LEAVE\n");
-}
-
-//>
-//<say_thread
-
-static void* say_thread(void*)
-{
- ENTER("say_thread");
-
- SHOW_TIME("say_thread > post my_sem_stop_is_acknowledged\n");
-
- // announce that thread is started
- sem_post(&my_sem_stop_is_acknowledged);
-
- int look_for_inactivity=0;
-
- while(1)
- {
- SHOW_TIME("say_thread > wait for my_sem_start_is_required\n");
-
- int a_start_is_required = 0;
- if (look_for_inactivity)
- {
- a_start_is_required = sleep_until_start_request_or_inactivity();
- if (!a_start_is_required)
- {
- close_stream();
- }
- }
- look_for_inactivity = 1;
-
- if (!a_start_is_required)
- {
- while ((sem_wait(&my_sem_start_is_required) == -1) && errno == EINTR)
- {
- continue; // Restart when interrupted by handler
- }
- }
- SHOW_TIME("say_thread > get my_sem_start_is_required\n");
-
- SHOW_TIME("say_thread > my_command_is_running = 1\n");
- my_command_is_running = 1;
-
- while( my_command_is_running)
- {
- SHOW_TIME("say_thread > locking\n");
- int a_status = pthread_mutex_lock(&my_mutex);
- assert (!a_status);
- t_espeak_command* a_command = (t_espeak_command*)pop();
-
- if (a_command == NULL)
- {
- SHOW_TIME("say_thread > text empty (talking=0) \n");
- a_status = pthread_mutex_unlock(&my_mutex);
- SHOW_TIME("say_thread > unlocked\n");
- SHOW_TIME("say_thread > my_command_is_running = 0\n");
- my_command_is_running = 0;
- }
- else
- {
- display_espeak_command(a_command);
- // purge start semaphore
- SHOW_TIME("say_thread > purge my_sem_start_is_required\n");
- while(0 == sem_trywait(&my_sem_start_is_required))
- {
- };
-
- if (my_stop_is_required)
- {
- SHOW_TIME("say_thread > my_command_is_running = 0\n");
- my_command_is_running = 0;
- }
- SHOW_TIME("say_thread > unlocking\n");
- a_status = pthread_mutex_unlock(&my_mutex);
-
- if (my_command_is_running)
- {
- process_espeak_command(a_command);
- }
- delete_espeak_command(a_command);
- }
- }
-
- if (my_stop_is_required)
- {
- // no mutex required since the stop command is synchronous
- // and waiting for my_sem_stop_is_acknowledged
- init();
-
- // purge start semaphore
- SHOW_TIME("say_thread > purge my_sem_start_is_required\n");
- while(0==sem_trywait(&my_sem_start_is_required))
- {
- };
-
- // acknowledge the stop request
- SHOW_TIME("say_thread > post my_sem_stop_is_acknowledged\n");
- int a_status = sem_post(&my_sem_stop_is_acknowledged);
- assert( a_status != -1);
- }
- // and wait for the next start
- SHOW_TIME("say_thread > wait for my_sem_start_is_required\n");
- }
-
- return NULL;
-}
-
-int fifo_is_command_enabled()
-{
- SHOW("ENTER fifo_is_command_enabled=%d\n",(int)(0 == my_stop_is_required));
- return (0 == my_stop_is_required);
-}
-
-//>
-//<fifo
-typedef struct t_node
-{
- t_espeak_command* data;
- t_node *next;
-} node;
-
-static node* head=NULL;
-static node* tail=NULL;
-// return 1 if ok, 0 otherwise
-static espeak_ERROR push(t_espeak_command* the_command)
-{
- ENTER("fifo > push");
-
- assert((!head && !tail) || (head && tail));
-
- if (the_command == NULL)
- {
- SHOW("push > command=0x%x\n", NULL);
- return EE_INTERNAL_ERROR;
- }
-
- if (node_counter >= MAX_NODE_COUNTER)
- {
- SHOW("push > %s\n", "EE_BUFFER_FULL");
- return EE_BUFFER_FULL;
- }
-
- node *n = (node *)malloc(sizeof(node));
- if (n == NULL)
- {
- return EE_INTERNAL_ERROR;
- }
-
- if (head == NULL)
- {
- head = n;
- tail = n;
- }
- else
- {
- tail->next = n;
- tail = n;
- }
-
- tail->next = NULL;
- tail->data = the_command;
-
- node_counter++;
- SHOW("push > counter=%d\n",node_counter);
-
- the_command->state = CS_PENDING;
- display_espeak_command(the_command);
-
- return EE_OK;
-}
-
-static t_espeak_command* pop()
-{
- ENTER("fifo > pop");
- t_espeak_command* the_command = NULL;
-
- assert((!head && !tail) || (head && tail));
-
- if (head != NULL)
- {
- node* n = head;
- the_command = n->data;
- head = n->next;
- free(n);
- node_counter--;
- SHOW("pop > command=0x%x (counter=%d)\n",the_command, node_counter);
- }
-
- if(head == NULL)
- {
- tail = NULL;
- }
-
- display_espeak_command(the_command);
-
- return the_command;
-}
-
-
-static void init()
-{
- ENTER("fifo > init");
- while (delete_espeak_command( pop() ))
- {}
- node_counter = 0;
-}
-
-//>
-//<fifo_init
-void fifo_terminate()
-{
- ENTER("fifo_terminate");
-
- pthread_cancel(my_thread);
- pthread_join(my_thread,NULL);
- pthread_mutex_destroy(&my_mutex);
- sem_destroy(&my_sem_start_is_required);
- sem_destroy(&my_sem_stop_is_acknowledged);
-
- init(); // purge fifo
-}
-
-#endif
-//>
-
diff --git a/navit/support/espeak/fifo.h b/navit/support/espeak/fifo.h
deleted file mode 100644
index b3699ff9b..000000000
--- a/navit/support/espeak/fifo.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef FIFO_H
-#define FIFO_H
-
-// Helps to add espeak commands in a first-in first-out queue
-// and run them asynchronously.
-
-#include "espeak_command.h"
-#include "speak_lib.h"
-
-// Initialize the fifo component.
-// First function to be called.
-void fifo_init();
-
-// Add an espeak command.
-//
-// Note: this function fails if too many commands are already buffered.
-// In such a case, the calling function could wait and then add again its command.
-//
-// Return: EE_OK: operation achieved
-// EE_BUFFER_FULL: the command can not be buffered;
-// you may try after a while to call the function again.
-// EE_INTERNAL_ERROR.
-espeak_ERROR fifo_add_command (t_espeak_command* c);
-
-// Add two espeak commands in a single transaction.
-//
-// Note: this function fails if too many commands are already buffered.
-// In such a case, the calling function could wait and then add again these commands.
-//
-// Return: EE_OK: operation achieved
-// EE_BUFFER_FULL: at least one command can not be buffered;
-// you may try after a while to call the function again.
-// EE_INTERNAL_ERROR.
-espeak_ERROR fifo_add_commands (t_espeak_command* c1, t_espeak_command* c2);
-
-// The current running command must be stopped and the awaiting commands are cleared.
-// Return: EE_OK: operation achieved
-// EE_INTERNAL_ERROR.
-espeak_ERROR fifo_stop ();
-
-// Is there a running command?
-// Returns 1 if yes; 0 otherwise.
-int fifo_is_busy ();
-
-// Terminate the fifo component.
-// Last function to be called.
-void fifo_terminate();
-
-// Indicates if the running command is still enabled.
-//
-// Note: this function is mainly called by the SynthCallback (speak_lib.cpp)
-// It indicates if the actual wave sample can still be played. It is helpful for
-// stopping speech as soon as a cancel command is applied.
-//
-// Returns 1 if yes, or 0 otherwise.
-int fifo_is_command_enabled();
-
-#endif
diff --git a/navit/support/espeak/intonation.c b/navit/support/espeak/intonation.c
deleted file mode 100755
index 61b2ff282..000000000
--- a/navit/support/espeak/intonation.c
+++ /dev/null
@@ -1,1104 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <string.h>
-#include <wctype.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-#include "translate.h"
-
-
-/* Note this module is mostly old code that needs to be rewritten to
- provide a more flexible intonation system.
-*/
-
-// bits in SYLLABLE.flags
-#define SYL_RISE 1
-#define SYL_EMPHASIS 2
-#define SYL_END_CLAUSE 4
-
-typedef struct {
- char stress;
- char env;
- char flags; //bit 0=pitch rising, bit1=emnphasized, bit2=end of clause
- char nextph_type;
- short pitch1;
- short pitch2;
-} SYLLABLE;
-
-static SYLLABLE *syllable_tab;
-
-
-static int tone_pitch_env; /* used to return pitch envelope */
-
-
-
-/* Pitch data for tone types */
-/*****************************/
-
-
-#define PITCHfall 0
-#define PITCHrise 1
-#define PITCHfrise 2 // and 3 must be for the varient preceded by 'r'
-#define PITCHfrise2 4 // and 5 must be the 'r' variant
-#define PITCHrisefall 6
-
-/* 0 fall */
-unsigned char env_fall[128] = {
- 0xff, 0xfd, 0xfa, 0xf8, 0xf6, 0xf4, 0xf2, 0xf0, 0xee, 0xec, 0xea, 0xe8, 0xe6, 0xe4, 0xe2, 0xe0,
- 0xde, 0xdc, 0xda, 0xd8, 0xd6, 0xd4, 0xd2, 0xd0, 0xce, 0xcc, 0xca, 0xc8, 0xc6, 0xc4, 0xc2, 0xc0,
- 0xbe, 0xbc, 0xba, 0xb8, 0xb6, 0xb4, 0xb2, 0xb0, 0xae, 0xac, 0xaa, 0xa8, 0xa6, 0xa4, 0xa2, 0xa0,
- 0x9e, 0x9c, 0x9a, 0x98, 0x96, 0x94, 0x92, 0x90, 0x8e, 0x8c, 0x8a, 0x88, 0x86, 0x84, 0x82, 0x80,
- 0x7e, 0x7c, 0x7a, 0x78, 0x76, 0x74, 0x72, 0x70, 0x6e, 0x6c, 0x6a, 0x68, 0x66, 0x64, 0x62, 0x60,
- 0x5e, 0x5c, 0x5a, 0x58, 0x56, 0x54, 0x52, 0x50, 0x4e, 0x4c, 0x4a, 0x48, 0x46, 0x44, 0x42, 0x40,
- 0x3e, 0x3c, 0x3a, 0x38, 0x36, 0x34, 0x32, 0x30, 0x2e, 0x2c, 0x2a, 0x28, 0x26, 0x24, 0x22, 0x20,
- 0x1e, 0x1c, 0x1a, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0e, 0x0c, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x00 };
-
-/* 1 rise */
-unsigned char env_rise[128] = {
- 0x00, 0x02, 0x04, 0x06, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1a, 0x1c, 0x1e,
- 0x20, 0x22, 0x24, 0x26, 0x28, 0x2a, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e,
- 0x40, 0x42, 0x44, 0x46, 0x48, 0x4a, 0x4c, 0x4e, 0x50, 0x52, 0x54, 0x56, 0x58, 0x5a, 0x5c, 0x5e,
- 0x60, 0x62, 0x64, 0x66, 0x68, 0x6a, 0x6c, 0x6e, 0x70, 0x72, 0x74, 0x76, 0x78, 0x7a, 0x7c, 0x7e,
- 0x80, 0x82, 0x84, 0x86, 0x88, 0x8a, 0x8c, 0x8e, 0x90, 0x92, 0x94, 0x96, 0x98, 0x9a, 0x9c, 0x9e,
- 0xa0, 0xa2, 0xa4, 0xa6, 0xa8, 0xaa, 0xac, 0xae, 0xb0, 0xb2, 0xb4, 0xb6, 0xb8, 0xba, 0xbc, 0xbe,
- 0xc0, 0xc2, 0xc4, 0xc6, 0xc8, 0xca, 0xcc, 0xce, 0xd0, 0xd2, 0xd4, 0xd6, 0xd8, 0xda, 0xdc, 0xde,
- 0xe0, 0xe2, 0xe4, 0xe6, 0xe8, 0xea, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfd, 0xff };
-
-unsigned char env_frise[128] = {
- 0xff, 0xf4, 0xea, 0xe0, 0xd6, 0xcc, 0xc3, 0xba, 0xb1, 0xa8, 0x9f, 0x97, 0x8f, 0x87, 0x7f, 0x78,
- 0x71, 0x6a, 0x63, 0x5c, 0x56, 0x50, 0x4a, 0x44, 0x3f, 0x39, 0x34, 0x2f, 0x2b, 0x26, 0x22, 0x1e,
- 0x1a, 0x17, 0x13, 0x10, 0x0d, 0x0b, 0x08, 0x06, 0x04, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x0a, 0x0c, 0x0e, 0x10, 0x13, 0x15, 0x17,
- 0x1a, 0x1d, 0x1f, 0x22, 0x25, 0x28, 0x2c, 0x2e, 0x30, 0x32, 0x34, 0x36, 0x39, 0x3b, 0x3d, 0x40,
- 0x42, 0x45, 0x47, 0x4a, 0x4c, 0x4f, 0x51, 0x54, 0x57, 0x5a, 0x5d, 0x5f, 0x62, 0x65, 0x68, 0x6b,
- 0x6e, 0x71, 0x74, 0x78, 0x7b, 0x7e, 0x81, 0x85, 0x88, 0x8b, 0x8f, 0x92, 0x96, 0x99, 0x9d, 0xa0,
- 0xa4, 0xa8, 0xac, 0xaf, 0xb3, 0xb7, 0xbb, 0xbf, 0xc3, 0xc7, 0xcb, 0xcf, 0xd3, 0xd7, 0xdb, 0xe0 };
-
-static unsigned char env_r_frise[128] = {
- 0xcf, 0xcc, 0xc9, 0xc6, 0xc3, 0xc0, 0xbd, 0xb9, 0xb4, 0xb0, 0xab, 0xa7, 0xa2, 0x9c, 0x97, 0x92,
- 0x8c, 0x86, 0x81, 0x7b, 0x75, 0x6f, 0x69, 0x63, 0x5d, 0x57, 0x50, 0x4a, 0x44, 0x3e, 0x38, 0x33,
- 0x2d, 0x27, 0x22, 0x1c, 0x17, 0x12, 0x0d, 0x08, 0x04, 0x02, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x01, 0x01, 0x02, 0x03, 0x04, 0x05, 0x07, 0x08, 0x0a, 0x0c, 0x0d, 0x0f, 0x12, 0x14, 0x16,
- 0x19, 0x1b, 0x1e, 0x21, 0x24, 0x27, 0x2a, 0x2d, 0x30, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3f, 0x41,
- 0x43, 0x46, 0x48, 0x4b, 0x4d, 0x50, 0x52, 0x55, 0x58, 0x5a, 0x5d, 0x60, 0x63, 0x66, 0x69, 0x6c,
- 0x6f, 0x72, 0x75, 0x78, 0x7b, 0x7e, 0x81, 0x85, 0x88, 0x8b, 0x8f, 0x92, 0x96, 0x99, 0x9d, 0xa0,
- 0xa4, 0xa8, 0xac, 0xaf, 0xb3, 0xb7, 0xbb, 0xbf, 0xc3, 0xc7, 0xcb, 0xcf, 0xd3, 0xd7, 0xdb, 0xe0 };
-
-static unsigned char env_frise2[128] = {
- 0xff, 0xf9, 0xf4, 0xee, 0xe9, 0xe4, 0xdf, 0xda, 0xd5, 0xd0, 0xcb, 0xc6, 0xc1, 0xbd, 0xb8, 0xb3,
- 0xaf, 0xaa, 0xa6, 0xa1, 0x9d, 0x99, 0x95, 0x90, 0x8c, 0x88, 0x84, 0x80, 0x7d, 0x79, 0x75, 0x71,
- 0x6e, 0x6a, 0x67, 0x63, 0x60, 0x5d, 0x59, 0x56, 0x53, 0x50, 0x4d, 0x4a, 0x47, 0x44, 0x41, 0x3e,
- 0x3c, 0x39, 0x37, 0x34, 0x32, 0x2f, 0x2d, 0x2b, 0x28, 0x26, 0x24, 0x22, 0x20, 0x1e, 0x1c, 0x1a,
- 0x19, 0x17, 0x15, 0x14, 0x12, 0x11, 0x0f, 0x0e, 0x0d, 0x0c, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05,
- 0x05, 0x04, 0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x0f, 0x10, 0x12, 0x13, 0x15, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20 };
-
-static unsigned char env_r_frise2[128] = {
- 0xd0, 0xce, 0xcd, 0xcc, 0xca, 0xc8, 0xc7, 0xc5, 0xc3, 0xc1, 0xc0, 0xbd, 0xbb, 0xb8, 0xb5, 0xb3,
- 0xb0, 0xad, 0xaa, 0xa7, 0xa3, 0xa0, 0x9d, 0x99, 0x96, 0x92, 0x8f, 0x8b, 0x87, 0x84, 0x80, 0x7c,
- 0x78, 0x74, 0x70, 0x6d, 0x69, 0x65, 0x61, 0x5d, 0x59, 0x55, 0x51, 0x4d, 0x4a, 0x46, 0x42, 0x3e,
- 0x3b, 0x37, 0x34, 0x31, 0x2f, 0x2d, 0x2a, 0x28, 0x26, 0x24, 0x22, 0x20, 0x1e, 0x1c, 0x1a, 0x19,
- 0x17, 0x15, 0x14, 0x12, 0x11, 0x0f, 0x0e, 0x0d, 0x0c, 0x0a, 0x09, 0x08, 0x07, 0x06, 0x05, 0x05,
- 0x04, 0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x02, 0x03, 0x04, 0x04, 0x05, 0x06, 0x07, 0x08,
- 0x09, 0x0a, 0x0b, 0x0c, 0x0e, 0x0f, 0x10, 0x12, 0x13, 0x15, 0x17, 0x18, 0x1a, 0x1c, 0x1e, 0x20 };
-
-static unsigned char env_risefall[128] = {
- 0x98, 0x99, 0x99, 0x9a, 0x9c, 0x9d, 0x9f, 0xa1, 0xa4, 0xa7, 0xa9, 0xac, 0xb0, 0xb3, 0xb6, 0xba,
- 0xbe, 0xc1, 0xc5, 0xc9, 0xcd, 0xd1, 0xd4, 0xd8, 0xdc, 0xdf, 0xe3, 0xe6, 0xea, 0xed, 0xf0, 0xf2,
- 0xf5, 0xf7, 0xf9, 0xfb, 0xfc, 0xfd, 0xfe, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfd,
- 0xfb, 0xfa, 0xf8, 0xf6, 0xf3, 0xf1, 0xee, 0xec, 0xe9, 0xe6, 0xe4, 0xe0, 0xdd, 0xda, 0xd7, 0xd3,
- 0xd0, 0xcc, 0xc8, 0xc4, 0xc0, 0xbc, 0xb8, 0xb4, 0xb0, 0xac, 0xa7, 0xa3, 0x9f, 0x9a, 0x96, 0x91,
- 0x8d, 0x88, 0x84, 0x7f, 0x7b, 0x76, 0x72, 0x6d, 0x69, 0x65, 0x60, 0x5c, 0x58, 0x54, 0x50, 0x4c,
- 0x48, 0x44, 0x40, 0x3c, 0x39, 0x35, 0x32, 0x2f, 0x2b, 0x28, 0x26, 0x23, 0x20, 0x1d, 0x1a, 0x17,
- 0x15, 0x12, 0x0f, 0x0d, 0x0a, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00 };
-
-static unsigned char env_rise2[128] = {
- 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x02, 0x02, 0x03, 0x03, 0x04, 0x04, 0x05, 0x06, 0x06,
- 0x07, 0x08, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14,
- 0x16, 0x17, 0x18, 0x19, 0x1b, 0x1c, 0x1d, 0x1f, 0x20, 0x22, 0x23, 0x25, 0x26, 0x28, 0x29, 0x2b,
- 0x2d, 0x2f, 0x30, 0x32, 0x34, 0x36, 0x38, 0x3a, 0x3c, 0x3e, 0x40, 0x42, 0x44, 0x47, 0x49, 0x4b,
- 0x4e, 0x50, 0x52, 0x55, 0x57, 0x5a, 0x5d, 0x5f, 0x62, 0x65, 0x67, 0x6a, 0x6d, 0x70, 0x73, 0x76,
- 0x79, 0x7c, 0x7f, 0x82, 0x86, 0x89, 0x8c, 0x90, 0x93, 0x96, 0x9a, 0x9d, 0xa0, 0xa3, 0xa6, 0xa9,
- 0xac, 0xaf, 0xb2, 0xb5, 0xb8, 0xbb, 0xbe, 0xc1, 0xc4, 0xc7, 0xca, 0xcd, 0xd0, 0xd3, 0xd6, 0xd9,
- 0xdc, 0xdf, 0xe2, 0xe4, 0xe7, 0xe9, 0xec, 0xee, 0xf0, 0xf2, 0xf4, 0xf6, 0xf8, 0xfa, 0xfb, 0xfd };
-
-static unsigned char env_fall2[128] = {
- 0xfe, 0xfe, 0xfd, 0xfd, 0xfc, 0xfb, 0xfb, 0xfa, 0xfa, 0xf9, 0xf8, 0xf8, 0xf7, 0xf7, 0xf6, 0xf6,
- 0xf5, 0xf4, 0xf4, 0xf3, 0xf3, 0xf2, 0xf2, 0xf1, 0xf0, 0xf0, 0xef, 0xee, 0xee, 0xed, 0xec, 0xeb,
- 0xea, 0xea, 0xe9, 0xe8, 0xe7, 0xe6, 0xe5, 0xe4, 0xe3, 0xe2, 0xe1, 0xe0, 0xde, 0xdd, 0xdc, 0xdb,
- 0xd9, 0xd8, 0xd6, 0xd5, 0xd3, 0xd2, 0xd0, 0xce, 0xcc, 0xcb, 0xc9, 0xc7, 0xc5, 0xc3, 0xc0, 0xbe,
- 0xbc, 0xb9, 0xb7, 0xb5, 0xb2, 0xaf, 0xad, 0xaa, 0xa7, 0xa4, 0xa1, 0x9e, 0x9a, 0x97, 0x94, 0x90,
- 0x8d, 0x89, 0x85, 0x81, 0x7d, 0x79, 0x75, 0x71, 0x6d, 0x68, 0x64, 0x61, 0x5e, 0x5b, 0x57, 0x54,
- 0x51, 0x4d, 0x4a, 0x46, 0x43, 0x40, 0x3c, 0x39, 0x35, 0x32, 0x2e, 0x2a, 0x27, 0x23, 0x1f, 0x1c,
- 0x18, 0x14, 0x11, 0x0d, 0x0b, 0x09, 0x07, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x00, 0x00, 0x00 };
-
-static unsigned char env_fallrise3[128] = {
- 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xfd, 0xfc, 0xfa, 0xf8, 0xf6, 0xf4, 0xf1, 0xee, 0xeb,
- 0xe8, 0xe5, 0xe1, 0xde, 0xda, 0xd6, 0xd2, 0xcd, 0xc9, 0xc4, 0xbf, 0xba, 0xb6, 0xb0, 0xab, 0xa6,
- 0xa1, 0x9c, 0x96, 0x91, 0x8b, 0x86, 0x80, 0x7b, 0x75, 0x6f, 0x6a, 0x64, 0x5f, 0x59, 0x54, 0x4f,
- 0x49, 0x44, 0x3f, 0x3a, 0x35, 0x30, 0x2b, 0x26, 0x22, 0x1d, 0x19, 0x15, 0x11, 0x0d, 0x0a, 0x07,
- 0x04, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x04, 0x05,
- 0x07, 0x09, 0x0b, 0x0d, 0x10, 0x12, 0x15, 0x18, 0x1b, 0x1e, 0x22, 0x25, 0x29, 0x2d, 0x31, 0x35,
- 0x3a, 0x3e, 0x43, 0x48, 0x4c, 0x51, 0x57, 0x5b, 0x5e, 0x62, 0x65, 0x68, 0x6b, 0x6e, 0x71, 0x74,
- 0x76, 0x78, 0x7b, 0x7c, 0x7e, 0x80, 0x81, 0x82, 0x83, 0x83, 0x84, 0x84, 0x83, 0x83, 0x82, 0x81 };
-
-static unsigned char env_fallrise4[128] = {
- 0x72, 0x72, 0x71, 0x71, 0x70, 0x6f, 0x6d, 0x6c, 0x6a, 0x68, 0x66, 0x64, 0x61, 0x5f, 0x5c, 0x5a,
- 0x57, 0x54, 0x51, 0x4e, 0x4b, 0x48, 0x45, 0x42, 0x3f, 0x3b, 0x38, 0x35, 0x32, 0x2f, 0x2c, 0x29,
- 0x26, 0x23, 0x20, 0x1d, 0x1b, 0x18, 0x16, 0x14, 0x12, 0x10, 0x0e, 0x0c, 0x0b, 0x0a, 0x09, 0x08,
- 0x07, 0x07, 0x07, 0x07, 0x07, 0x06, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x06,
- 0x07, 0x07, 0x08, 0x09, 0x0a, 0x0c, 0x0d, 0x0f, 0x10, 0x12, 0x14, 0x16, 0x18, 0x1b, 0x1d, 0x20,
- 0x23, 0x26, 0x29, 0x2c, 0x2f, 0x33, 0x37, 0x3b, 0x3f, 0x43, 0x47, 0x4c, 0x51, 0x56, 0x5b, 0x60,
- 0x65, 0x6a, 0x6f, 0x74, 0x79, 0x7f, 0x84, 0x89, 0x8f, 0x95, 0x9b, 0xa1, 0xa7, 0xad, 0xb3, 0xba,
- 0xc0, 0xc7, 0xce, 0xd5, 0xdc, 0xe3, 0xea, 0xf1, 0xf5, 0xf7, 0xfa, 0xfc, 0xfd, 0xfe, 0xff, 0xff };
-
-static unsigned char env_risefallrise[128] = {
- 0x7f, 0x7f, 0x7f, 0x80, 0x81, 0x83, 0x84, 0x87, 0x89, 0x8c, 0x8f, 0x92, 0x96, 0x99, 0x9d, 0xa1,
- 0xa5, 0xaa, 0xae, 0xb2, 0xb7, 0xbb, 0xc0, 0xc5, 0xc9, 0xcd, 0xd2, 0xd6, 0xda, 0xde, 0xe2, 0xe6,
- 0xea, 0xed, 0xf0, 0xf3, 0xf5, 0xf8, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xfe, 0xfd, 0xfc, 0xfb, 0xf9,
- 0xf7, 0xf4, 0xf0, 0xec, 0xe7, 0xe2, 0xdc, 0xd5, 0xce, 0xc6, 0xbd, 0xb4, 0xa9, 0x9e, 0x92, 0x88,
- 0x82, 0x7d, 0x77, 0x72, 0x6c, 0x66, 0x60, 0x5a, 0x54, 0x4e, 0x49, 0x42, 0x3c, 0x37, 0x32, 0x2d,
- 0x28, 0x24, 0x1f, 0x1b, 0x18, 0x14, 0x11, 0x0e, 0x0c, 0x09, 0x07, 0x06, 0x05, 0x04, 0x04, 0x04,
- 0x04, 0x05, 0x06, 0x08, 0x0a, 0x0d, 0x10, 0x14, 0x18, 0x1d, 0x23, 0x29, 0x2f, 0x37, 0x3e, 0x47,
- 0x50, 0x5a, 0x64, 0x70, 0x7c, 0x83, 0x85, 0x88, 0x8a, 0x8c, 0x8e, 0x8f, 0x91, 0x92, 0x93, 0x93 };
-
-
-
-
-unsigned char *envelope_data[18] = {
- env_fall,
- env_rise,
- env_frise, env_r_frise,
- env_frise2, env_r_frise2,
- env_risefall, env_risefall,
-
- env_fallrise3, env_fallrise3,
- env_fallrise4, env_fallrise4,
- env_fall2, env_fall2,
- env_rise2, env_rise2,
- env_risefallrise, env_risefallrise
- };
-
-
-/* all pitches given in Hz above pitch_base */
-
-// pitch change during the main part of the clause
-static int drops_0[8] = {0x400,0x400,0x700,0x700,0x700,0xa00,0x1800,0x0e00};
-//static int drops_1[8] = {0x400,0x400,0x600,0x600,0xc00,0xc00,0x0e00,0x0e00};
-//static int drops_2[8] = {0x400,0x400,0x600,0x600,-0x800,0xc00,0x0e00,0x0e00};
-
-static short oflow[] = {0, 20, 12, 4, 0};
-static short oflow_emf[] = {5, 24, 15, 10, 5};
-static short oflow_less[] = {3, 19, 12, 7, 2};
-// static short oflow_test2[] = {20, 0, 20, 0, 20};
-// static short back_emf[] = {35, 32, 0};
-
-
-#define N_TONE_HEAD_TABLE 13
-#define N_TONE_NUCLEUS_TABLE 13
-
-
-typedef struct {
- unsigned char pre_start;
- unsigned char pre_end;
-
- unsigned char body_start;
- unsigned char body_end;
-
- int *body_drops;
- unsigned char body_max_steps;
- char body_lower_u;
-
- char n_overflow;
- short *overflow;
-} TONE_HEAD;
-
-
-typedef struct {
- unsigned char pitch_env0; /* pitch envelope, tonic syllable at end */
- unsigned char tonic_max0;
- unsigned char tonic_min0;
-
- unsigned char pitch_env1; /* followed by unstressed */
- unsigned char tonic_max1;
- unsigned char tonic_min1;
-
- short *backwards;
-
- unsigned char tail_start;
- unsigned char tail_end;
- unsigned char flags;
-} TONE_NUCLEUS;
-
-#define T_EMPH 1
-
-static TONE_HEAD tone_head_table[N_TONE_HEAD_TABLE] = {
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 0 statement
- {20, 25, 34, 20, drops_0, 3, 3, 5, oflow}, // 1 comma
- {20, 25, 34, 20, drops_0, 3, 3, 5, oflow}, // 2 question
- {20, 25, 36, 22, drops_0, 3, 4, 5, oflow_emf}, // 3 exclamation
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 4 statement, emphatic
- {20, 25, 32, 24, drops_0, 4, 3, 5, oflow_less}, // 5 statement, less intonation
- {20, 25, 32, 24, drops_0, 4, 3, 5, oflow_less}, // 6 comma, less intonation
- {20, 25, 32, 24, drops_0, 4, 3, 5, oflow_less}, // 7 comma, less intonation, less rise
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 8 pitch raises at end of sentence
- {20, 25, 34, 20, drops_0, 3, 3, 5, oflow}, // 9 comma
- {20, 25, 34, 22, drops_0, 3, 3, 5, oflow}, // 10 question
- {15, 18, 18, 14, drops_0, 3, 3, 5, oflow_less}, // 11 test
- {20, 25, 24, 22, drops_0, 3, 3, 5, oflow_less}, // 12 test
-};
-
-static TONE_NUCLEUS tone_nucleus_table[N_TONE_NUCLEUS_TABLE] = {
- {PITCHfall, 30, 5, PITCHfall, 32, 9, NULL, 12, 7, 0}, // 0 statement
- {PITCHfrise, 35, 8, PITCHfrise2, 35,10, NULL, 15, 23, 0}, // 1 comma
- {PITCHfrise, 39,10, PITCHfrise2, 36,10, NULL, 15, 28, 0}, // 2 question
-// {PITCHfall, 41, 4, PITCHfall, 41,27, NULL, 16, 4, T_EMPH}, // 3 exclamation
- {PITCHfall, 41, 4, PITCHfall, 41,35, NULL, 35, 4, T_EMPH}, // 3 exclamation
- {PITCHfall, 38, 2, PITCHfall, 42,30, NULL, 15, 5, 0}, // 4 statement, emphatic
- {PITCHfall, 28, 5, PITCHfall, 28, 9, NULL, 12, 7, 0}, // 5 statement, less intonation
- {PITCHfrise, 30, 8, PITCHfrise2, 30,10, NULL, 13, 20, 0}, // 6 comma, less intonation
- {PITCHfrise2, 28, 7, PITCHfall, 29,14, NULL, 14, 8, 0}, // 7 comma, less intonation, less rise
- {PITCHrise, 30,20, PITCHfall, 19,14, NULL, 20, 26, 0}, // 8 pitch raises at end of sentence
- {PITCHfrise, 35,11, PITCHfrise2, 32,10, NULL, 19, 24, 0}, // 9 comma
- {PITCHfrise, 39,15, PITCHfall, 28,14, NULL, 20, 36, 0}, // 10 question
- {PITCHfall, 28, 6, PITCHfall, 28,10, NULL, 12, 6, 0}, // 11 test
- {PITCHfall, 35, 9, PITCHfall, 35,12, NULL, 16, 10, 0}, // 12 test
-};
-
-
-
-/* index by 0=. 1=, 2=?, 3=! 4=none, 5=emphasized */
-unsigned char punctuation_to_tone[INTONATION_TYPES][PUNCT_INTONATIONS] = {
- {0,1,2,3,0,4},
- {0,1,2,3,0,4},
- {5,6,2,3,0,4},
- {5,7,1,3,0,4},
- {8,9,10,3,0,0},
- {8,8,10,3,0,0},
- {11,11,11,11,0,0}, // 6 test
- {12,12,12,12,0,0}
-};
-
-
-
-/* indexed by stress */
-static int min_drop[] = {0x300,0x300,0x400,0x400,0x900,0x900,0x900,0xb00};
-
-
-
-
-#define SECONDARY 3
-#define PRIMARY 4
-#define PRIMARY_STRESSED 6
-#define PRIMARY_LAST 7
-
-
-static int number_pre;
-static int number_body;
-static int number_tail;
-static int last_primary;
-static int tone_posn;
-static int tone_posn2;
-static int no_tonic;
-
-
-static void count_pitch_vowels(int start, int end, int clause_end)
-/****************************************************************/
-{
- int ix;
- int stress;
- int max_stress = 0;
- int max_stress_posn = 0; // last syllable ot the highest stress
- int max_stress_posn2 = 0; // penuntimate syllable of the highest stress
-
- number_pre = -1; /* number of vowels before 1st primary stress */
- number_body = 0;
- number_tail = 0; /* number between tonic syllable and next primary */
- last_primary = -1;
-
- for(ix=start; ix<end; ix++)
- {
- stress = syllable_tab[ix].stress; /* marked stress level */
-
- if(stress >= max_stress)
- {
- if(stress > max_stress)
- {
- max_stress_posn2 = ix;
- }
- else
- {
- max_stress_posn2 = max_stress_posn;
- }
- max_stress_posn = ix;
- max_stress = stress;
- }
- if(stress >= PRIMARY)
- {
- if(number_pre < 0)
- number_pre = ix - start;
-
- last_primary = ix;
- }
-
- }
-
- if(number_pre < 0)
- number_pre = end;
-
- number_tail = end - max_stress_posn - 1;
- tone_posn = max_stress_posn;
- tone_posn2 = max_stress_posn2;
-
- if(no_tonic)
- {
- tone_posn = tone_posn2 = end; // next position after the end of the truncated clause
- }
- else
- if(last_primary >= 0)
- {
- if(end == clause_end)
- {
- syllable_tab[last_primary].stress = PRIMARY_LAST;
- }
- }
- else
- {
- // no primary stress. Use the highest stress
- syllable_tab[tone_posn].stress = PRIMARY_LAST;
- }
-} /* end of count_pitch_vowels */
-
-
-
-
-static int count_increments(int ix, int end_ix, int min_stress)
-/*************************************************************/
-/* Count number of primary stresses up to tonic syllable or body_reset */
-{
- int count = 0;
- int stress;
-
- while(ix < end_ix)
- {
- stress = syllable_tab[ix++].stress;
- if(stress >= PRIMARY_LAST)
- break;
-
- if(stress >= min_stress)
- count++;
- }
- return(count);
-} /* end of count_increments */
-
-
-
-static void set_pitch(SYLLABLE *syl, int base, int drop)
-/******************************************************/
-// Set the pitch of a vowel in syllable_tab. Base & drop are Hz * 256
-{
- int pitch1, pitch2;
- int flags = 0;
-
- /* adjust experimentally */
- int pitch_range2 = 148;
- int pitch_base2 = 72;
-
- if(base < 0) base = 0;
-
- pitch2 = ((base * pitch_range2 ) >> 15) + pitch_base2;
-
- if(drop < 0)
- {
- flags = SYL_RISE;
- drop = -drop;
- }
-
- pitch1 = pitch2 + ((drop * pitch_range2) >> 15);
-
- if(pitch1 > 511) pitch1 = 511;
- if(pitch2 > 511) pitch2 = 511;
-
- syl->pitch1 = pitch1;
- syl->pitch2 = pitch2;
- syl->flags |= flags;
-} /* end of set_pitch */
-
-
-
-static int calc_pitch_segment(int ix, int end_ix, TONE_HEAD *th, TONE_NUCLEUS *tn, int min_stress, int continuing)
-/**********************************************************************************************/
-/* Calculate pitches until next RESET or tonic syllable, or end.
- Increment pitch if stress is >= min_stress.
- Used for tonic segment */
-{
- int stress;
- int pitch=0;
- int increment=0;
- int n_primary=0;
- int n_steps=0;
- int initial;
- int overflow=0;
- int n_overflow;
- int *drops;
- short *overflow_tab;
- SYLLABLE *syl;
-
- static short continue_tab[5] = {-13, 16, 10, 4, 0};
-
- drops = th->body_drops;
-
- if(continuing)
- {
- initial =0;
- overflow = 0;
- n_overflow = 5;
- overflow_tab = continue_tab;
- increment = (th->body_end - th->body_start) << 8;
- increment = increment / (th->body_max_steps -1);
- }
- else
- {
- n_overflow = th->n_overflow;
- overflow_tab = th->overflow;
- initial = 1;
- }
-
- while(ix < end_ix)
- {
- syl = &syllable_tab[ix];
- stress = syl->stress;
-
-// if(stress == PRIMARY_MARKED)
-// initial = 1; // reset the intonation pattern
-
- if(initial || (stress >= min_stress))
- {
- // a primary stress
-
- if((initial) || (stress == 5))
- {
- initial = 0;
- overflow = 0;
- n_steps = n_primary = count_increments(ix,end_ix,min_stress);
-
- if(n_steps > th->body_max_steps)
- n_steps = th->body_max_steps;
-
- if(n_steps > 1)
- {
- increment = (th->body_end - th->body_start) << 8;
- increment = increment / (n_steps -1);
- }
- else
- increment = 0;
-
- pitch = th->body_start << 8;
- }
- else
- {
- if(n_steps > 0)
- pitch += increment;
- else
- {
- pitch = (th->body_end << 8) - (increment * overflow_tab[overflow++])/16;
- if(overflow >= n_overflow)
- {
- overflow = 0;
- overflow_tab = th->overflow;
- }
- }
- }
-
- n_steps--;
-
- n_primary--;
- if((tn->backwards) && (n_primary < 2))
- {
- pitch = tn->backwards[n_primary] << 8;
- }
- }
-
- if(stress >= PRIMARY)
- {
- syl->stress = PRIMARY_STRESSED;
- set_pitch(syl,pitch,drops[stress]);
- }
- else
- if(stress >= SECONDARY)
- {
- set_pitch(syl,pitch,drops[stress]);
- }
- else
- {
- /* unstressed, drop pitch if preceded by PRIMARY */
- if((syllable_tab[ix-1].stress & 0x3f) >= SECONDARY)
- set_pitch(syl,pitch - (th->body_lower_u << 8), drops[stress]);
- else
- set_pitch(syl,pitch,drops[stress]);
- }
-
- ix++;
- }
- return(ix);
-} /* end of calc_pitch_segment */
-
-
-
-
-
-static int calc_pitch_segment2(int ix, int end_ix, int start_p, int end_p, int min_stress)
-/****************************************************************************************/
-/* Linear pitch rise/fall, change pitch at min_stress or stronger
- Used for pre-head and tail */
-{
- int stress;
- int pitch;
- int increment;
- int n_increments;
- int drop;
- SYLLABLE *syl;
-
- if(ix >= end_ix)
- return(ix);
-
- n_increments = count_increments(ix,end_ix,min_stress);
- increment = (end_p - start_p) << 8;
-
- if(n_increments > 1)
- {
- increment = increment / n_increments;
- }
-
-
- pitch = start_p << 8;
- while(ix < end_ix)
- {
- syl = &syllable_tab[ix];
- stress = syl->stress;
-
- if(increment > 0)
- {
- set_pitch(syl,pitch,-increment);
- pitch += increment;
- }
- else
- {
- drop = -increment;
- if(drop < min_drop[stress])
- drop = min_drop[stress];
-
- pitch += increment;
-
- if(drop > 0x900)
- drop = 0x900;
- set_pitch(syl, pitch, drop);
- }
-
- ix++;
- }
- return(ix);
-} /* end of calc_pitch_segment2 */
-
-
-
-
-
-
-static int calc_pitches(int start, int end, int head_tone, int nucleus_tone)
-//===========================================================================
-// Calculate pitch values for the vowels in this tone group
-{
- int ix;
- TONE_HEAD *th;
- TONE_NUCLEUS *tn;
- int drop;
- int continuing = 0;
-
- if(start > 0)
- continuing = 1;
-
- th = &tone_head_table[head_tone];
- tn = &tone_nucleus_table[nucleus_tone];
- ix = start;
-
- /* vowels before the first primary stress */
- /******************************************/
-
- if(number_pre > 0)
- {
- ix = calc_pitch_segment2(ix, ix+number_pre, th->pre_start, th->pre_end, 0);
- }
-
- /* body of tonic segment */
- /*************************/
-
- if(option_tone_flags & OPTION_EMPHASIZE_PENULTIMATE)
- {
- tone_posn = tone_posn2; // put tone on the penultimate stressed word
- }
- ix = calc_pitch_segment(ix,tone_posn, th, tn, PRIMARY, continuing);
-
- if(no_tonic)
- return(0);
-
- /* tonic syllable */
- /******************/
-
- if(tn->flags & T_EMPH)
- {
- syllable_tab[ix].flags |= SYL_EMPHASIS;
- }
-
- if(number_tail == 0)
- {
- tone_pitch_env = tn->pitch_env0;
- drop = tn->tonic_max0 - tn->tonic_min0;
- set_pitch(&syllable_tab[ix++],tn->tonic_min0 << 8,drop << 8);
- }
- else
- {
- tone_pitch_env = tn->pitch_env1;
- drop = tn->tonic_max1 - tn->tonic_min1;
- set_pitch(&syllable_tab[ix++],tn->tonic_min1 << 8,drop << 8);
- }
-
- syllable_tab[tone_posn].env = tone_pitch_env;
- if(syllable_tab[tone_posn].stress == PRIMARY)
- syllable_tab[tone_posn].stress = PRIMARY_STRESSED;
-
- /* tail, after the tonic syllable */
- /**********************************/
-
- calc_pitch_segment2(ix, end, tn->tail_start, tn->tail_end, 0);
-
- return(tone_pitch_env);
-} /* end of calc_pitches */
-
-
-
-
-
-
-static void CalcPitches_Tone(Translator *tr, int clause_tone)
-{//==========================================================
-// clause_tone: 0=. 1=, 2=?, 3=! 4=none
- PHONEME_LIST *p;
- int ix;
- int count_stressed=0;
- int final_stressed=0;
-
- int tone_ph;
- int pause;
- int tone_promoted;
- PHONEME_TAB *tph;
- PHONEME_TAB *prev_tph; // forget across word boundary
- PHONEME_TAB *prevw_tph; // remember across word boundary
- PHONEME_TAB *prev2_tph; // 2 tones previous
- PHONEME_LIST *prev_p;
-
- int pitch_adjust = 0; // pitch gradient through the clause - inital value
- int pitch_decrement = 0; // decrease by this for each stressed syllable
- int pitch_low = 0; // until it drops to this
- int pitch_high = 0; // then reset to this
-
- p = &phoneme_list[0];
-
- // count number of stressed syllables
- p = &phoneme_list[0];
- for(ix=0; ix<n_phoneme_list; ix++, p++)
- {
- if((p->type == phVOWEL) && (p->stresslevel >= 4))
- {
- if(count_stressed == 0)
- final_stressed = ix;
-
- if(p->stresslevel >= 4)
- {
- final_stressed = ix;
- count_stressed++;
- }
- }
- }
-
- phoneme_list[final_stressed].stresslevel = 7;
-
- // language specific, changes to tones
- if(tr->translator_name == L('v','i'))
- {
- // LANG=vi
- p = &phoneme_list[final_stressed];
- if(p->tone_ph == 0)
- p->tone_ph = PhonemeCode('7'); // change default tone (tone 1) to falling tone at end of clause
- }
-
-
- pause = 1;
- tone_promoted = 0;
-
- prev_p = p = &phoneme_list[0];
- prev_tph = prevw_tph = phoneme_tab[phonPAUSE];
-
- // perform tone sandhi
- for(ix=0; ix<n_phoneme_list; ix++, p++)
- {
- if((p->type == phPAUSE) && (p->ph->std_length > 50))
- {
- pause = 1; // there is a pause since the previous vowel
- prevw_tph = phoneme_tab[phonPAUSE]; // forget previous tone
- }
-
- if(p->newword)
- {
- prev_tph = phoneme_tab[phonPAUSE]; // forget across word boundaries
- }
-
- if(p->synthflags & SFLAG_SYLLABLE)
- {
- tone_ph = p->tone_ph;
- tph = phoneme_tab[tone_ph];
-
- // Mandarin
- if(tr->translator_name == L('z','h'))
- {
- if(tone_ph == 0)
- {
- if(pause || tone_promoted)
- {
- tone_ph = PhonemeCode2('5','5'); // no previous vowel, use tone 1
- tone_promoted = 1;
- }
- else
- {
- tone_ph = PhonemeCode2('1','1'); // default tone 5
- }
-
- p->tone_ph = tone_ph;
- tph = phoneme_tab[tone_ph];
-
- }
- else
- {
- tone_promoted = 0;
- }
-
- if(ix == final_stressed)
- {
- if((tph->mnemonic == 0x3535 ) || (tph->mnemonic == 0x3135))
- {
- // change sentence final tone 1 or 4 to stress 6, not 7
- phoneme_list[final_stressed].stresslevel = 6;
- }
- }
-
- if(prevw_tph->mnemonic == 0x343132) // [214]
- {
- if(tph->mnemonic == 0x343132) // [214]
- prev_p->tone_ph = PhonemeCode2('3','5');
- else
- prev_p->tone_ph = PhonemeCode2('2','1');
- }
- if((prev_tph->mnemonic == 0x3135) && (tph->mnemonic == 0x3135)) // [51] + [51]
- {
- prev_p->tone_ph = PhonemeCode2('5','3');
- }
-
- if(tph->mnemonic == 0x3131) // [11] Tone 5
- {
- // tone 5, change its level depending on the previous tone (across word boundaries)
- if(prevw_tph->mnemonic == 0x3535)
- p->tone_ph = PhonemeCode2('2','2');
- if(prevw_tph->mnemonic == 0x3533)
- p->tone_ph = PhonemeCode2('3','3');
- if(prevw_tph->mnemonic == 0x343132)
- p->tone_ph = PhonemeCode2('4','4');
-
- // tone 5 is unstressed (shorter)
- p->stresslevel = 1; // diminished stress
- }
- }
-
- prev_p = p;
- prev2_tph = prevw_tph;
- prevw_tph = prev_tph = tph;
- pause = 0;
- }
- }
-
- // convert tone numbers to pitch
- p = &phoneme_list[0];
- for(ix=0; ix<n_phoneme_list; ix++, p++)
- {
- if(p->synthflags & SFLAG_SYLLABLE)
- {
- tone_ph = p->tone_ph;
-
- if(p->stresslevel != 1) // TEST, consider all syllables as stressed
- {
- if(ix == final_stressed)
- {
- // the last stressed syllable
- pitch_adjust = pitch_low;
- }
- else
- {
- pitch_adjust -= pitch_decrement;
- if(pitch_adjust <= pitch_low)
- pitch_adjust = pitch_high;
- }
- }
-
- if(tone_ph ==0)
- {
- tone_ph = phonDEFAULTTONE; // no tone specified, use default tone 1
- p->tone_ph = tone_ph;
- }
- p->pitch1 = pitch_adjust + phoneme_tab[tone_ph]->start_type;
- p->pitch2 = pitch_adjust + phoneme_tab[tone_ph]->end_type;
- }
- }
-
-
-} // end of Translator::CalcPitches_Tone
-
-
-
-void CalcPitches(Translator *tr, int clause_type)
-{//==============================================
-// clause_type: 0=. 1=, 2=?, 3=! 4=none
- PHONEME_LIST *p;
- SYLLABLE *syl;
- int ix;
- int x;
- int st_ix;
- int n_st;
- int option;
- int group_tone;
- int group_tone_emph;
- int group_tone_comma;
- int ph_start=0;
- int st_start;
- int st_clause_end;
- int count;
- int n_primary;
- int count_primary;
- PHONEME_TAB *ph;
- int ph_end=n_phoneme_list;
-
- SYLLABLE syllable_tab2[N_PHONEME_LIST];
-
- syllable_tab = syllable_tab2; // don't use permanent storage. it's only needed during the call of CalcPitches()
- n_st = 0;
- n_primary = 0;
- for(ix=0; ix<(n_phoneme_list-1); ix++)
- {
- p = &phoneme_list[ix];
- if(p->synthflags & SFLAG_SYLLABLE)
- {
- syllable_tab[n_st].flags = 0;
- syllable_tab[n_st].env = PITCHfall;
- syllable_tab[n_st].nextph_type = phoneme_list[ix+1].type;
- syllable_tab[n_st++].stress = p->stresslevel;
-
- if(p->stresslevel >= 4)
- n_primary++;
- }
- else
- if((p->ph->code == phonPAUSE_CLAUSE) && (n_st > 0))
- {
- syllable_tab[n_st-1].flags |= SYL_END_CLAUSE;
- }
- }
- syllable_tab[n_st].stress = 0; // extra 0 entry at the end
-
- if(n_st == 0)
- return; // nothing to do
-
-
-
- if(tr->langopts.tone_language == 1)
- {
- CalcPitches_Tone(tr,clause_type);
- return;
- }
-
-
- option = tr->langopts.intonation_group;
- if(option >= INTONATION_TYPES)
- option = 0;
-
- group_tone = tr->punct_to_tone[option][clause_type];
- group_tone_emph = tr->punct_to_tone[option][5]; // emphatic form of statement
- group_tone_comma = tr->punct_to_tone[option][1]; // emphatic form of statement
-
- if(clause_type == 4)
- no_tonic = 1; /* incomplete clause, used for abbreviations such as Mr. Dr. Mrs. */
- else
- no_tonic = 0;
-
- st_start = 0;
- count_primary=0;
- for(st_ix=0; st_ix<n_st; st_ix++)
- {
- syl = &syllable_tab[st_ix];
-
- if(syl->stress >= 4)
- count_primary++;
-
- if(syl->stress == 6)
- {
- // reduce the stress of the previous stressed syllable (review only the previous few syllables)
- for(ix=st_ix-1; ix>=st_start && ix>=(st_ix-3); ix--)
- {
- if(syllable_tab[ix].stress == 6)
- break;
- if(syllable_tab[ix].stress == 4)
- {
- syllable_tab[ix].stress = 3;
- break;
- }
- }
-
- // are the next primary syllables also emphasized ?
- for(ix=st_ix+1; ix<n_st; ix++)
- {
- if(syllable_tab[ix].stress == 4)
- break;
- if(syllable_tab[ix].stress == 6)
- {
- // emphasize this syllable, but don't end the current tone group
- syllable_tab[st_ix].flags = SYL_EMPHASIS;
- syl->stress = 5;
- break;
- }
- }
- }
-
- if(syl->stress == 6)
- {
- // an emphasized syllable, end the tone group after the next primary stress
- syllable_tab[st_ix].flags = SYL_EMPHASIS;
-
- count = 0;
- if((n_primary - count_primary) > 1)
- count =1;
-
- for(ix=st_ix+1; ix<n_st; ix++)
- {
- if(syllable_tab[ix].stress > 4)
- break;
- if(syllable_tab[ix].stress == 4)
- {
- count++;
- if(count > 1)
- break;
- }
- }
-
- count_pitch_vowels(st_start, ix, n_st);
- if((ix < n_st) || (clause_type == 0))
- calc_pitches(st_start, ix, group_tone_emph, group_tone_emph); // split into > 1 tone groups, use emphatic tone
- else
- calc_pitches(st_start, ix, group_tone, group_tone);
-
- st_start = ix;
- }
- if((st_start < st_ix) && (syl->flags & SYL_END_CLAUSE))
- {
- // end of clause after this syllable, indicated by a phonPAUSE_CLAUSE phoneme
- st_clause_end = st_ix+1;
- count_pitch_vowels(st_start, st_clause_end, st_clause_end);
- calc_pitches(st_start, st_clause_end, group_tone_comma, group_tone_comma);
- st_start = st_clause_end;
- }
- }
-
- if(st_start < st_ix)
- {
- count_pitch_vowels(st_start, st_ix, n_st);
- calc_pitches(st_start, st_ix, group_tone, group_tone);
- }
-
-
- // unpack pitch data
- st_ix=0;
- for(ix=ph_start; ix < ph_end; ix++)
- {
- p = &phoneme_list[ix];
- p->stresslevel = syllable_tab[st_ix].stress;
-
- if(p->synthflags & SFLAG_SYLLABLE)
- {
- syl = &syllable_tab[st_ix];
-
- x = syl->pitch1 - 72;
- if(x < 0) x = 0;
- p->pitch1 = x;
-
- x = syl->pitch2 - 72;
- if(x < 0) x = 0;
- p->pitch2 = x;
-
- p->env = PITCHfall;
- if(syl->flags & SYL_RISE)
- {
- p->env = PITCHrise;
- }
- else
- if(p->stresslevel > 5)
- p->env = syl->env;
-
- if(p->pitch1 > p->pitch2)
- {
- // swap so that pitch2 is the higher
- x = p->pitch1;
- p->pitch1 = p->pitch2;
- p->pitch2 = x;
- }
-
-if(p->tone_ph)
-{
- ph = phoneme_tab[p->tone_ph];
- x = (p->pitch1 + p->pitch2)/2;
- p->pitch2 = x + ph->end_type;
- p->pitch1 = x + ph->start_type;
-}
-
- if(syl->flags & SYL_EMPHASIS)
- {
- p->stresslevel |= 8; // emphasized
- }
-
- st_ix++;
- }
- }
-
-} // end of Translator::CalcPitches
-
-
diff --git a/navit/support/espeak/klatt.c b/navit/support/espeak/klatt.c
deleted file mode 100644
index 8cdbf782b..000000000
--- a/navit/support/espeak/klatt.c
+++ /dev/null
@@ -1,1303 +0,0 @@
-
-/***************************************************************************
- * Copyright (C) 2008 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * Based on a re-implementation by: *
- * (c) 1993,94 Jon Iles and Nick Ing-Simmons *
- * of the Klatt cascade-parallel formant synthesizer *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-// See URL: ftp://svr-ftp.eng.cam.ac.uk/pub/comp.speech/synthesis/klatt.3.04.tar.gz
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "klatt.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-
-#ifdef INCLUDE_KLATT // conditional compilation for the whole file
-
-extern unsigned char *out_ptr; // **JSD
-extern unsigned char *out_start;
-extern unsigned char *out_end;
-extern WGEN_DATA wdata;
-static int nsamples;
-static int sample_count;
-
-
-#ifdef _MSC_VER
-#define getrandom(min,max) ((rand()%(int)(((max)+1)-(min)))+(min))
-#else
-#define getrandom(min,max) ((rand()%(long)(((max)+1)-(min)))+(min))
-#endif
-
-
-/* function prototypes for functions private to this file */
-
-static void flutter(klatt_frame_ptr);
-static double sampled_source (void);
-static double impulsive_source (void);
-static double natural_source (void);
-static void pitch_synch_par_reset (klatt_frame_ptr);
-static double gen_noise (double);
-static double DBtoLIN (long);
-static void frame_init (klatt_frame_ptr);
-static void setabc (long,long,resonator_ptr);
-static void setzeroabc (long,long,resonator_ptr);
-
-static klatt_frame_t kt_frame;
-static klatt_global_t kt_globals;
-
-/*
-function RESONATOR
-
-This is a generic resonator function. Internal memory for the resonator
-is stored in the globals structure.
-*/
-
-static double resonator(resonator_ptr r, double input)
-{
- double x;
-
- x = (double) ((double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2);
- r->p2 = (double)r->p1;
- r->p1 = (double)x;
-
- return (double)x;
-}
-
-static double resonator2(resonator_ptr r, double input)
-{
- double x;
-
- x = (double) ((double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2);
- r->p2 = (double)r->p1;
- r->p1 = (double)x;
-
- r->a += r->a_inc;
- r->b += r->b_inc;
- r->c += r->c_inc;
- return (double)x;
-}
-
-
-
-/*
-function ANTIRESONATOR
-
-This is a generic anti-resonator function. The code is the same as resonator
-except that a,b,c need to be set with setzeroabc() and we save inputs in
-p1/p2 rather than outputs. There is currently only one of these - "rnz"
-Output = (rnz.a * input) + (rnz.b * oldin1) + (rnz.c * oldin2)
-*/
-
-#ifdef deleted
-static double antiresonator(resonator_ptr r, double input)
-{
- register double x = (double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2;
- r->p2 = (double)r->p1;
- r->p1 = (double)input;
- return (double)x;
-}
-#endif
-
-static double antiresonator2(resonator_ptr r, double input)
-{
- register double x = (double)r->a * (double)input + (double)r->b * (double)r->p1 + (double)r->c * (double)r->p2;
- r->p2 = (double)r->p1;
- r->p1 = (double)input;
-
- r->a += r->a_inc;
- r->b += r->b_inc;
- r->c += r->c_inc;
- return (double)x;
-}
-
-
-
-/*
-function FLUTTER
-
-This function adds F0 flutter, as specified in:
-
-"Analysis, synthesis and perception of voice quality variations among
-female and male talkers" D.H. Klatt and L.C. Klatt JASA 87(2) February 1990.
-
-Flutter is added by applying a quasi-random element constructed from three
-slowly varying sine waves.
-*/
-
-static void flutter(klatt_frame_ptr frame)
-{
- static int time_count;
- double delta_f0;
- double fla,flb,flc,fld,fle;
-
- fla = (double) kt_globals.f0_flutter / 50;
- flb = (double) kt_globals.original_f0 / 100;
-// flc = sin(2*PI*12.7*time_count);
-// fld = sin(2*PI*7.1*time_count);
-// fle = sin(2*PI*4.7*time_count);
- flc = sin(PI*12.7*time_count); // because we are calling flutter() more frequently, every 2.9mS
- fld = sin(PI*7.1*time_count);
- fle = sin(PI*4.7*time_count);
- delta_f0 = fla * flb * (flc + fld + fle) * 10;
- frame->F0hz10 = frame->F0hz10 + (long) delta_f0;
- time_count++;
-}
-
-
-
-/*
-function SAMPLED_SOURCE
-
-Allows the use of a glottal excitation waveform sampled from a real
-voice.
-*/
-
-static double sampled_source()
-{
- int itemp;
- double ftemp;
- double result;
- double diff_value;
- int current_value;
- int next_value;
- double temp_diff;
-
- if(kt_globals.T0!=0)
- {
- ftemp = (double) kt_globals.nper;
- ftemp = ftemp / kt_globals.T0;
- ftemp = ftemp * kt_globals.num_samples;
- itemp = (int) ftemp;
-
- temp_diff = ftemp - (double) itemp;
-
- current_value = kt_globals.natural_samples[itemp];
- next_value = kt_globals.natural_samples[itemp+1];
-
- diff_value = (double) next_value - (double) current_value;
- diff_value = diff_value * temp_diff;
-
- result = kt_globals.natural_samples[itemp] + diff_value;
- result = result * kt_globals.sample_factor;
- }
- else
- {
- result = 0;
- }
- return(result);
-}
-
-
-
-
-/*
-function PARWAVE
-
-Converts synthesis parameters to a waveform.
-*/
-
-
-static int parwave(klatt_frame_ptr frame)
-{
- double temp;
- double outbypas;
- double out;
- long n4;
- double frics;
- double glotout;
- double aspiration;
- double casc_next_in;
- double par_glotout;
- static double noise;
- static double voice;
- static double vlast;
- static double glotlast;
- static double sourc;
- int ix;
-
- frame_init(frame); /* get parameters for next frame of speech */
-
- flutter(frame); /* add f0 flutter */
-
-#ifdef deleted
-{
- FILE *f;
- f=fopen("klatt_log","a");
- fprintf(f,"%4dhz %2dAV %4d %3d, %4d %3d, %4d %3d, %4d %3d, %4d, %3d, %4d %3d TLT=%2d\n",frame->F0hz10,frame->AVdb,
- frame->F1hz,frame->B1hz,frame->F2hz,frame->B2hz,frame->F3hz,frame->B3hz,frame->F4hz,frame->B4hz,frame->F5hz,frame->B5hz,frame->F6hz,frame->B6hz,frame->TLTdb);
- fclose(f);
-}
-#endif
-
- /* MAIN LOOP, for each output sample of current frame: */
-
- for (kt_globals.ns=0; kt_globals.ns<kt_globals.nspfr; kt_globals.ns++)
- {
- /* Get low-passed random number for aspiration and frication noise */
- noise = gen_noise(noise);
-
- /*
- Amplitude modulate noise (reduce noise amplitude during
- second half of glottal period) if voicing simultaneously present.
- */
-
- if (kt_globals.nper > kt_globals.nmod)
- {
- noise *= (double) 0.5;
- }
-
- /* Compute frication noise */
- frics = kt_globals.amp_frica * noise;
-
- /*
- Compute voicing waveform. Run glottal source simulation at 4
- times normal sample rate to minimize quantization noise in
- period of female voice.
- */
-
- for (n4=0; n4<4; n4++)
- {
- switch(kt_globals.glsource)
- {
- case IMPULSIVE:
- voice = impulsive_source();
- break;
- case NATURAL:
- voice = natural_source();
- break;
- case SAMPLED:
- voice = sampled_source();
- break;
- }
-
- /* Reset period when counter 'nper' reaches T0 */
- if (kt_globals.nper >= kt_globals.T0)
- {
- kt_globals.nper = 0;
- pitch_synch_par_reset(frame);
- }
-
- /*
- Low-pass filter voicing waveform before downsampling from 4*samrate
- to samrate samples/sec. Resonator f=.09*samrate, bw=.06*samrate
- */
-
- voice = resonator(&(kt_globals.rsn[RLP]),voice);
-
- /* Increment counter that keeps track of 4*samrate samples per sec */
- kt_globals.nper++;
- }
-
- /*
- Tilt spectrum of voicing source down by soft low-pass filtering, amount
- of tilt determined by TLTdb
- */
-
- voice = (voice * kt_globals.onemd) + (vlast * kt_globals.decay);
- vlast = voice;
-
- /*
- Add breathiness during glottal open phase. Amount of breathiness
- determined by parameter Aturb Use nrand rather than noise because
- noise is low-passed.
- */
-
-
- if (kt_globals.nper < kt_globals.nopen)
- {
- voice += kt_globals.amp_breth * kt_globals.nrand;
- }
-
- /* Set amplitude of voicing */
- glotout = kt_globals.amp_voice * voice;
- par_glotout = kt_globals.par_amp_voice * voice;
-
- /* Compute aspiration amplitude and add to voicing source */
- aspiration = kt_globals.amp_aspir * noise;
- glotout += aspiration;
-
- par_glotout += aspiration;
-
- /*
- Cascade vocal tract, excited by laryngeal sources.
- Nasal antiresonator, then formants FNP, F5, F4, F3, F2, F1
- */
-
- out=0;
- if(kt_globals.synthesis_model != ALL_PARALLEL)
- {
- casc_next_in = antiresonator2(&(kt_globals.rsn[Rnz]),glotout);
- casc_next_in = resonator(&(kt_globals.rsn[Rnpc]),casc_next_in);
- casc_next_in = resonator(&(kt_globals.rsn[R8c]),casc_next_in);
- casc_next_in = resonator(&(kt_globals.rsn[R7c]),casc_next_in);
- casc_next_in = resonator(&(kt_globals.rsn[R6c]),casc_next_in);
- casc_next_in = resonator2(&(kt_globals.rsn[R5c]),casc_next_in);
- casc_next_in = resonator2(&(kt_globals.rsn[R4c]),casc_next_in);
- casc_next_in = resonator2(&(kt_globals.rsn[R3c]),casc_next_in);
- casc_next_in = resonator2(&(kt_globals.rsn[R2c]),casc_next_in);
- out = resonator2(&(kt_globals.rsn[R1c]),casc_next_in);
- }
-
- /* Excite parallel F1 and FNP by voicing waveform */
- sourc = par_glotout; /* Source is voicing plus aspiration */
-
- /*
- Standard parallel vocal tract Formants F6,F5,F4,F3,F2,
- outputs added with alternating sign. Sound source for other
- parallel resonators is frication plus first difference of
- voicing waveform.
- */
-
- out += resonator(&(kt_globals.rsn[R1p]),sourc);
- out += resonator(&(kt_globals.rsn[Rnpp]),sourc);
-
- sourc = frics + par_glotout - glotlast;
- glotlast = par_glotout;
-
- for(ix=R2p; ix<=R6p; ix++)
- {
- out = resonator(&(kt_globals.rsn[ix]),sourc) - out;
- }
-
- outbypas = kt_globals.amp_bypas * sourc;
-
- out = outbypas - out;
-
-#ifdef deleted
-// for testing
- if (kt_globals.outsl != 0)
- {
- switch(kt_globals.outsl)
- {
- case 1:
- out = voice;
- break;
- case 2:
- out = aspiration;
- break;
- case 3:
- out = frics;
- break;
- case 4:
- out = glotout;
- break;
- case 5:
- out = par_glotout;
- break;
- case 6:
- out = outbypas;
- break;
- case 7:
- out = sourc;
- break;
- }
- }
-#endif
-
- out = resonator(&(kt_globals.rsn[Rout]),out);
- temp = (out * wdata.amplitude * kt_globals.amp_gain0) ; /* Convert back to integer */
-
-
- // mix with a recorded WAV if required for this phoneme
- {
- int z2;
- signed char c;
- int sample;
-
- z2 = 0;
- if(wdata.mix_wavefile_ix < wdata.n_mix_wavefile)
- {
- if(wdata.mix_wave_scale == 0)
- {
- // a 16 bit sample
- c = wdata.mix_wavefile[wdata.mix_wavefile_ix+1];
- sample = wdata.mix_wavefile[wdata.mix_wavefile_ix] + (c * 256);
- wdata.mix_wavefile_ix += 2;
- }
- else
- {
- // a 8 bit sample, scaled
- sample = (signed char)wdata.mix_wavefile[wdata.mix_wavefile_ix++] * wdata.mix_wave_scale;
- }
- z2 = sample * wdata.amplitude_v / 1024;
- z2 = (z2 * wdata.mix_wave_amp)/40;
- temp += z2;
- }
- }
-
- // if fadeout is set, fade to zero over 64 samples, to avoid clicks at end of synthesis
- if(kt_globals.fadeout > 0)
- {
- kt_globals.fadeout--;
- temp = (temp * kt_globals.fadeout) / 64;
- }
-
- if (temp < -32768.0)
- {
- temp = -32768.0;
- }
-
- if (temp > 32767.0)
- {
- temp = 32767.0;
- }
-
- *out_ptr++ = (int)(temp); // **JSD
- *out_ptr++ = (int)(temp) >> 8;
- sample_count++;
- if(out_ptr >= out_end)
- {
- return(1);
- }
- }
- return(0);
-} // end of parwave
-
-
-
-
-/*
-function PARWAVE_INIT
-
-Initialises all parameters used in parwave, sets resonator internal memory
-to zero.
-*/
-
-static void reset_resonators()
-{
- int r_ix;
-
- for(r_ix=0; r_ix < N_RSN; r_ix++)
- {
- kt_globals.rsn[r_ix].p1 = 0;
- kt_globals.rsn[r_ix].p2 = 0;
- }
-}
-
-static void parwave_init()
-{
- kt_globals.FLPhz = (950 * kt_globals.samrate) / 10000;
- kt_globals.BLPhz = (630 * kt_globals.samrate) / 10000;
- kt_globals.minus_pi_t = -PI / kt_globals.samrate;
- kt_globals.two_pi_t = -2.0 * kt_globals.minus_pi_t;
- setabc(kt_globals.FLPhz,kt_globals.BLPhz,&(kt_globals.rsn[RLP]));
- kt_globals.nper = 0;
- kt_globals.T0 = 0;
- kt_globals.nopen = 0;
- kt_globals.nmod = 0;
-
- reset_resonators();
-}
-
-
-/*
-function FRAME_INIT
-
-Use parameters from the input frame to set up resonator coefficients.
-*/
-
-static void frame_init(klatt_frame_ptr frame)
-{
- double amp_par[7];
- static double amp_par_factor[7] = {0.6, 0.4, 0.15, 0.06, 0.04, 0.022, 0.03};
- long Gain0_tmp;
- int ix;
-
- kt_globals.original_f0 = frame->F0hz10 / 10;
-
- frame->AVdb_tmp = frame->AVdb - 7;
- if (frame->AVdb_tmp < 0)
- {
- frame->AVdb_tmp = 0;
- }
-
- kt_globals.amp_aspir = DBtoLIN(frame->ASP) * 0.05;
- kt_globals.amp_frica = DBtoLIN(frame->AF) * 0.25;
- kt_globals.par_amp_voice = DBtoLIN(frame->AVpdb);
- kt_globals.amp_bypas = DBtoLIN(frame->AB) * 0.05;
-
- for(ix=0; ix <= 6; ix++)
- {
- // parallel amplitudes F1 to F6, and parallel nasal pole
- amp_par[ix] = DBtoLIN(frame->Ap[ix]) * amp_par_factor[ix];
- }
-
- Gain0_tmp = frame->Gain0 - 3;
- if (Gain0_tmp <= 0)
- {
- Gain0_tmp = 57;
- }
- kt_globals.amp_gain0 = DBtoLIN(Gain0_tmp) / kt_globals.scale_wav;
-
- /* Set coefficients of variable cascade resonators */
- for(ix=0; ix<=8; ix++)
- {
- // formants 1 to 8, plus nasal pole
- setabc(frame->Fhz[ix],frame->Bhz[ix],&(kt_globals.rsn[ix]));
-
- if(ix <= 5)
- {
- setabc(frame->Fhz_next[ix],frame->Bhz_next[ix],&(kt_globals.rsn_next[ix]));
-
- kt_globals.rsn[ix].a_inc = (kt_globals.rsn_next[ix].a - kt_globals.rsn[ix].a) / 64.0;
- kt_globals.rsn[ix].b_inc = (kt_globals.rsn_next[ix].b - kt_globals.rsn[ix].b) / 64.0;
- kt_globals.rsn[ix].c_inc = (kt_globals.rsn_next[ix].c - kt_globals.rsn[ix].c) / 64.0;
- }
- }
-
- // nasal zero anti-resonator
- setzeroabc(frame->Fhz[F_NZ],frame->Bhz[F_NZ],&(kt_globals.rsn[Rnz]));
- setzeroabc(frame->Fhz_next[F_NZ],frame->Bhz_next[F_NZ],&(kt_globals.rsn_next[Rnz]));
- kt_globals.rsn[F_NZ].a_inc = (kt_globals.rsn_next[F_NZ].a - kt_globals.rsn[F_NZ].a) / 64.0;
- kt_globals.rsn[F_NZ].b_inc = (kt_globals.rsn_next[F_NZ].b - kt_globals.rsn[F_NZ].b) / 64.0;
- kt_globals.rsn[F_NZ].c_inc = (kt_globals.rsn_next[F_NZ].c - kt_globals.rsn[F_NZ].c) / 64.0;
-
-
- /* Set coefficients of parallel resonators, and amplitude of outputs */
-
- for(ix=0; ix<=6; ix++)
- {
- setabc(frame->Fhz[ix],frame->Bphz[ix],&(kt_globals.rsn[Rparallel+ix]));
- kt_globals.rsn[Rparallel+ix].a *= amp_par[ix];
- }
-
- /* output low-pass filter */
-
- setabc((long)0.0,(long)(kt_globals.samrate/2),&(kt_globals.rsn[Rout]));
-
-}
-
-
-
-/*
-function IMPULSIVE_SOURCE
-
-Generate a low pass filtered train of impulses as an approximation of
-a natural excitation waveform. Low-pass filter the differentiated impulse
-with a critically-damped second-order filter, time constant proportional
-to Kopen.
-*/
-
-
-static double impulsive_source()
-{
- static double doublet[] = {0.0,13000000.0,-13000000.0};
- static double vwave;
-
- if (kt_globals.nper < 3)
- {
- vwave = doublet[kt_globals.nper];
- }
- else
- {
- vwave = 0.0;
- }
-
- return(resonator(&(kt_globals.rsn[RGL]),vwave));
-}
-
-
-
-/*
-function NATURAL_SOURCE
-
-Vwave is the differentiated glottal flow waveform, there is a weak
-spectral zero around 800 Hz, magic constants a,b reset pitch synchronously.
-*/
-
-static double natural_source()
-{
- double lgtemp;
- static double vwave;
-
- if (kt_globals.nper < kt_globals.nopen)
- {
- kt_globals.pulse_shape_a -= kt_globals.pulse_shape_b;
- vwave += kt_globals.pulse_shape_a;
- lgtemp=vwave * 0.028;
-
- return(lgtemp);
- }
- else
- {
- vwave = 0.0;
- return(0.0);
- }
-}
-
-
-
-
-
-/*
-function PITCH_SYNC_PAR_RESET
-
-Reset selected parameters pitch-synchronously.
-
-
-Constant B0 controls shape of glottal pulse as a function
-of desired duration of open phase N0
-(Note that N0 is specified in terms of 40,000 samples/sec of speech)
-
-Assume voicing waveform V(t) has form: k1 t**2 - k2 t**3
-
- If the radiation characterivative, a temporal derivative
- is folded in, and we go from continuous time to discrete
- integers n: dV/dt = vwave[n]
- = sum over i=1,2,...,n of { a - (i * b) }
- = a n - b/2 n**2
-
- where the constants a and b control the detailed shape
- and amplitude of the voicing waveform over the open
- potion of the voicing cycle "nopen".
-
- Let integral of dV/dt have no net dc flow --> a = (b * nopen) / 3
-
- Let maximum of dUg(n)/dn be constant --> b = gain / (nopen * nopen)
- meaning as nopen gets bigger, V has bigger peak proportional to n
-
- Thus, to generate the table below for 40 <= nopen <= 263:
-
- B0[nopen - 40] = 1920000 / (nopen * nopen)
-*/
-
-static void pitch_synch_par_reset(klatt_frame_ptr frame)
-{
- long temp;
- double temp1;
- static long skew;
- static short B0[224] =
- {
- 1200,1142,1088,1038, 991, 948, 907, 869, 833, 799, 768, 738, 710, 683, 658,
- 634, 612, 590, 570, 551, 533, 515, 499, 483, 468, 454, 440, 427, 415, 403,
- 391, 380, 370, 360, 350, 341, 332, 323, 315, 307, 300, 292, 285, 278, 272,
- 265, 259, 253, 247, 242, 237, 231, 226, 221, 217, 212, 208, 204, 199, 195,
- 192, 188, 184, 180, 177, 174, 170, 167, 164, 161, 158, 155, 153, 150, 147,
- 145, 142, 140, 137, 135, 133, 131, 128, 126, 124, 122, 120, 119, 117, 115,
- 113,111, 110, 108, 106, 105, 103, 102, 100, 99, 97, 96, 95, 93, 92, 91, 90,
- 88, 87, 86, 85, 84, 83, 82, 80, 79, 78, 77, 76, 75, 75, 74, 73, 72, 71,
- 70, 69, 68, 68, 67, 66, 65, 64, 64, 63, 62, 61, 61, 60, 59, 59, 58, 57,
- 57, 56, 56, 55, 55, 54, 54, 53, 53, 52, 52, 51, 51, 50, 50, 49, 49, 48, 48,
- 47, 47, 46, 46, 45, 45, 44, 44, 43, 43, 42, 42, 41, 41, 41, 41, 40, 40,
- 39, 39, 38, 38, 38, 38, 37, 37, 36, 36, 36, 36, 35, 35, 35, 35, 34, 34,33,
- 33, 33, 33, 32, 32, 32, 32, 31, 31, 31, 31, 30, 30, 30, 30, 29, 29, 29, 29,
- 28, 28, 28, 28, 27, 27
- };
-
- if (frame->F0hz10 > 0)
- {
- /* T0 is 4* the number of samples in one pitch period */
-
- kt_globals.T0 = (40 * kt_globals.samrate) / frame->F0hz10;
-
-
- kt_globals.amp_voice = DBtoLIN(frame->AVdb_tmp);
-
- /* Duration of period before amplitude modulation */
-
- kt_globals.nmod = kt_globals.T0;
- if (frame->AVdb_tmp > 0)
- {
- kt_globals.nmod >>= 1;
- }
-
- /* Breathiness of voicing waveform */
-
- kt_globals.amp_breth = DBtoLIN(frame->Aturb) * 0.1;
-
- /* Set open phase of glottal period where 40 <= open phase <= 263 */
-
- kt_globals.nopen = 4 * frame->Kopen;
-
- if ((kt_globals.glsource == IMPULSIVE) && (kt_globals.nopen > 263))
- {
- kt_globals.nopen = 263;
- }
-
- if (kt_globals.nopen >= (kt_globals.T0-1))
- {
-// printf("Warning: glottal open period cannot exceed T0, truncated\n");
- kt_globals.nopen = kt_globals.T0 - 2;
- }
-
- if (kt_globals.nopen < 40)
- {
- /* F0 max = 1000 Hz */
-// printf("Warning: minimum glottal open period is 10 samples.\n");
-// printf("truncated, nopen = %d\n",kt_globals.nopen);
- kt_globals.nopen = 40;
- }
-
-
- /* Reset a & b, which determine shape of "natural" glottal waveform */
-
- kt_globals.pulse_shape_b = B0[kt_globals.nopen-40];
- kt_globals.pulse_shape_a = (kt_globals.pulse_shape_b * kt_globals.nopen) * 0.333;
-
- /* Reset width of "impulsive" glottal pulse */
-
- temp = kt_globals.samrate / kt_globals.nopen;
-
- setabc((long)0,temp,&(kt_globals.rsn[RGL]));
-
- /* Make gain at F1 about constant */
-
- temp1 = kt_globals.nopen *.00833;
- kt_globals.rsn[RGL].a *= temp1 * temp1;
-
- /*
- Truncate skewness so as not to exceed duration of closed phase
- of glottal period.
- */
-
-
- temp = kt_globals.T0 - kt_globals.nopen;
- if (frame->Kskew > temp)
- {
-// printf("Kskew duration=%d > glottal closed period=%d, truncate\n", frame->Kskew, kt_globals.T0 - kt_globals.nopen);
- frame->Kskew = temp;
- }
- if (skew >= 0)
- {
- skew = frame->Kskew;
- }
- else
- {
- skew = - frame->Kskew;
- }
-
- /* Add skewness to closed portion of voicing period */
- kt_globals.T0 = kt_globals.T0 + skew;
- skew = - skew;
- }
- else
- {
- kt_globals.T0 = 4; /* Default for f0 undefined */
- kt_globals.amp_voice = 0.0;
- kt_globals.nmod = kt_globals.T0;
- kt_globals.amp_breth = 0.0;
- kt_globals.pulse_shape_a = 0.0;
- kt_globals.pulse_shape_b = 0.0;
- }
-
- /* Reset these pars pitch synchronously or at update rate if f0=0 */
-
- if ((kt_globals.T0 != 4) || (kt_globals.ns == 0))
- {
- /* Set one-pole low-pass filter that tilts glottal source */
-
- kt_globals.decay = (0.033 * frame->TLTdb);
-
- if (kt_globals.decay > 0.0)
- {
- kt_globals.onemd = 1.0 - kt_globals.decay;
- }
- else
- {
- kt_globals.onemd = 1.0;
- }
- }
-}
-
-
-
-/*
-function SETABC
-
-Convert formant freqencies and bandwidth into resonator difference
-equation constants.
-*/
-
-
-static void setabc(long int f, long int bw, resonator_ptr rp)
-{
- double r;
- double arg;
-
- /* Let r = exp(-pi bw t) */
- arg = kt_globals.minus_pi_t * bw;
- r = exp(arg);
-
- /* Let c = -r**2 */
- rp->c = -(r * r);
-
- /* Let b = r * 2*cos(2 pi f t) */
- arg = kt_globals.two_pi_t * f;
- rp->b = r * cos(arg) * 2.0;
-
- /* Let a = 1.0 - b - c */
- rp->a = 1.0 - rp->b - rp->c;
-}
-
-
-/*
-function SETZEROABC
-
-Convert formant freqencies and bandwidth into anti-resonator difference
-equation constants.
-*/
-
-static void setzeroabc(long int f, long int bw, resonator_ptr rp)
-{
- double r;
- double arg;
-
- f = -f;
-
- if(f>=0)
- {
- f = -1;
- }
-
- /* First compute ordinary resonator coefficients */
- /* Let r = exp(-pi bw t) */
- arg = kt_globals.minus_pi_t * bw;
- r = exp(arg);
-
- /* Let c = -r**2 */
- rp->c = -(r * r);
-
- /* Let b = r * 2*cos(2 pi f t) */
- arg = kt_globals.two_pi_t * f;
- rp->b = r * cos(arg) * 2.;
-
- /* Let a = 1.0 - b - c */
- rp->a = 1.0 - rp->b - rp->c;
-
- /* Now convert to antiresonator coefficients (a'=1/a, b'=b/a, c'=c/a) */
- rp->a = 1.0 / rp->a;
- rp->c *= -rp->a;
- rp->b *= -rp->a;
-}
-
-
-/*
-function GEN_NOISE
-
-Random number generator (return a number between -8191 and +8191)
-Noise spectrum is tilted down by soft low-pass filter having a pole near
-the origin in the z-plane, i.e. output = input + (0.75 * lastoutput)
-*/
-
-
-static double gen_noise(double noise)
-{
- long temp;
- static double nlast;
-
- temp = (long) getrandom(-8191,8191);
- kt_globals.nrand = (long) temp;
-
- noise = kt_globals.nrand + (0.75 * nlast);
- nlast = noise;
-
- return(noise);
-}
-
-
-/*
-function DBTOLIN
-
-Convert from decibels to a linear scale factor
-
-
-Conversion table, db to linear, 87 dB --> 32767
- 86 dB --> 29491 (1 dB down = 0.5**1/6)
- ...
- 81 dB --> 16384 (6 dB down = 0.5)
- ...
- 0 dB --> 0
-
-The just noticeable difference for a change in intensity of a vowel
-is approximately 1 dB. Thus all amplitudes are quantized to 1 dB
-steps.
-*/
-
-
-static double DBtoLIN(long dB)
-{
- static short amptable[88] =
- {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 7,
- 8, 9, 10, 11, 13, 14, 16, 18, 20, 22, 25, 28, 32,
- 35, 40, 45, 51, 57, 64, 71, 80, 90, 101, 114, 128,
- 142, 159, 179, 202, 227, 256, 284, 318, 359, 405,
- 455, 512, 568, 638, 719, 881, 911, 1024, 1137, 1276,
- 1438, 1622, 1823, 2048, 2273, 2552, 2875, 3244, 3645,
- 4096, 4547, 5104, 5751, 6488, 7291, 8192, 9093, 10207,
- 11502, 12976, 14582, 16384, 18350, 20644, 23429,
- 26214, 29491, 32767 };
-
- if ((dB < 0) || (dB > 87))
- {
- return(0);
- }
-
- return((double)(amptable[dB]) * 0.001);
-}
-
-
-
-
-
-extern voice_t *wvoice;
-static klatt_peaks_t peaks[N_PEAKS];
-static int end_wave;
-static int klattp[N_KLATTP];
-static double klattp1[N_KLATTP];
-static double klattp_inc[N_KLATTP];
-
-static int scale_wav_tab[] = {45,38,45,45}; // scale output from different voicing sources
-
-
-
-int Wavegen_Klatt(int resume)
-{//==========================
- int pk;
- int x;
- int ix;
-
- if(resume==0)
- {
- sample_count = 0;
- }
-
- while(sample_count < nsamples)
- {
- kt_frame.F0hz10 = (wdata.pitch * 10) / 4096;
-
- // formants F6,F7,F8 are fixed values for cascade resonators, set in KlattInit()
- // but F6 is used for parallel resonator
- // F0 is used for the nasal zero
- for(ix=0; ix < 6; ix++)
- {
- kt_frame.Fhz[ix] = peaks[ix].freq;
- if(ix < 4)
- {
- kt_frame.Bhz[ix] = peaks[ix].bw;
- }
- }
- for(ix=1; ix < 7; ix++)
- {
- kt_frame.Ap[ix] = 0;
- }
-
- kt_frame.AVdb = klattp[KLATT_AV];
- kt_frame.AVpdb = klattp[KLATT_AVp];
- kt_frame.AF = klattp[KLATT_Fric];
- kt_frame.AB = klattp[KLATT_FricBP];
- kt_frame.ASP = klattp[KLATT_Aspr];
- kt_frame.Aturb = klattp[KLATT_Turb];
- kt_frame.Kskew = klattp[KLATT_Skew];
- kt_frame.TLTdb = klattp[KLATT_Tilt];
- kt_frame.Kopen = klattp[KLATT_Kopen];
-
- // advance formants
- for(pk=0; pk<N_PEAKS; pk++)
- {
- peaks[pk].freq1 += peaks[pk].freq_inc;
- peaks[pk].freq = (int)peaks[pk].freq1;
- peaks[pk].bw1 += peaks[pk].bw_inc;
- peaks[pk].bw = (int)peaks[pk].bw1;
- peaks[pk].bp1 += peaks[pk].bp_inc;
- peaks[pk].bp = (int)peaks[pk].bp1;
- peaks[pk].ap1 += peaks[pk].ap_inc;
- peaks[pk].ap = (int)peaks[pk].ap1;
- }
-
- // advance other parameters
- for(ix=0; ix < N_KLATTP; ix++)
- {
- klattp1[ix] += klattp_inc[ix];
- klattp[ix] = (int)(klattp1[ix]);
- }
-
- for(ix=0; ix<=6; ix++)
- {
- kt_frame.Fhz_next[ix] = peaks[ix].freq;
- if(ix < 4)
- {
- kt_frame.Bhz_next[ix] = peaks[ix].bw;
- }
- }
-
- // advance the pitch
- wdata.pitch_ix += wdata.pitch_inc;
- if((ix = wdata.pitch_ix>>8) > 127) ix = 127;
- x = wdata.pitch_env[ix] * wdata.pitch_range;
- wdata.pitch = (x>>8) + wdata.pitch_base;
-
- kt_globals.nspfr = (nsamples - sample_count);
- if(kt_globals.nspfr > STEPSIZE)
- kt_globals.nspfr = STEPSIZE;
-
- if(parwave(&kt_frame) == 1)
- {
- return(1);
- }
- }
-
- if(end_wave == 1)
- {
- // fade out to avoid a click
- kt_globals.fadeout = 64;
- end_wave = 0;
- sample_count -= 64;
- kt_globals.nspfr = 64;
- if(parwave(&kt_frame) == 1)
- {
- return(1);
- }
- }
-
- return(0);
-}
-
-
-void SetSynth_Klatt(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v, int control)
-{//===========================================================================================
- int ix;
- DOUBLEX next;
- int qix;
- int cmd;
- static frame_t prev_fr;
-
- if(wvoice != NULL)
- {
- if((wvoice->klattv[0] > 0) && (wvoice->klattv[0] <=3 ))
- {
- kt_globals.glsource = wvoice->klattv[0];
- kt_globals.scale_wav = scale_wav_tab[kt_globals.glsource];
- }
- kt_globals.f0_flutter = wvoice->flutter/32;
- }
-
- end_wave = 0;
- if(control & 2)
- {
- end_wave = 1; // fadeout at the end
- }
- if(control & 1)
- {
- end_wave = 1;
- for(qix=wcmdq_head+1;;qix++)
- {
- if(qix >= N_WCMDQ) qix = 0;
- if(qix == wcmdq_tail) break;
-
- cmd = wcmdq[qix][0];
- if(cmd==WCMD_KLATT)
- {
- end_wave = 0; // next wave generation is from another spectrum
- break;
- }
- if((cmd==WCMD_WAVE) || (cmd==WCMD_PAUSE))
- break; // next is not from spectrum, so continue until end of wave cycle
- }
- }
-
-{
-//FILE *f;
-//f=fopen("klatt_log","a");
-//fprintf(f,"len %4d (%3d %4d %4d) (%3d %4d %4d)\n",length,fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3],fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3]);
-//fclose(f);
-}
-
- if(control & 1)
- {
- if(wdata.prev_was_synth == 0)
- {
- // A break, not following on from another synthesized sound.
- // Reset the synthesizer
- //reset_resonators(&kt_globals);
- parwave_init();
- }
- else
- {
- if((prev_fr.ffreq[1] != fr1->ffreq[1]) || (prev_fr.ffreq[2] != fr1->ffreq[2]))
- {
-
- // fade out to avoid a click, but only up to the end of output buffer
- ix = (out_end - out_ptr)/2;
- if(ix > 64)
- ix = 64;
- kt_globals.fadeout = ix;
- kt_globals.nspfr = ix;
- parwave(&kt_frame);
-
- //reset_resonators(&kt_globals);
- parwave_init();
- }
- }
- wdata.prev_was_synth = 1;
- memcpy(&prev_fr,fr2,sizeof(prev_fr));
- }
- if(fr2->frflags & FRFLAG_BREAK)
- {
-// fr2 = fr1;
-// reset_resonators(&kt_globals);
- }
-
- for(ix=0; ix<N_KLATTP; ix++)
- {
- if((ix >= 5) && ((fr1->frflags & FRFLAG_KLATT) == 0))
- {
- klattp1[ix] = klattp[ix] = 0;
- klattp_inc[ix] = 0;
- }
- else
- {
- klattp1[ix] = klattp[ix] = fr1->klattp[ix];
- klattp_inc[ix] = (double)((fr2->klattp[ix] - klattp[ix]) * STEPSIZE)/length;
- }
-
- // get klatt parameter adjustments for the voice
-// if((ix>0) && (ix < KLATT_AVp))
-// klattp1[ix] = klattp[ix] = (klattp[ix] + wvoice->klattv[ix]);
- }
-
- nsamples = length;
-
- for(ix=1; ix < 6; ix++)
- {
- peaks[ix].freq1 = (fr1->ffreq[ix] * v->freq[ix] / 256.0) + v->freqadd[ix];
- peaks[ix].freq = (int)(peaks[ix].freq1);
- next = (fr2->ffreq[ix] * v->freq[ix] / 256.0) + v->freqadd[ix];
- peaks[ix].freq_inc = ((next - peaks[ix].freq1) * STEPSIZE) / length;
-
- if(ix < 4)
- {
- // klatt bandwidth for f1, f2, f3 (others are fixed)
- peaks[ix].bw1 = fr1->bw[ix] * 2;
- peaks[ix].bw = (int)(peaks[ix].bw1);
- next = fr2->bw[ix] * 2;
- peaks[ix].bw_inc = ((next - peaks[ix].bw1) * STEPSIZE) / length;
- }
- }
-
- // nasal zero frequency
- peaks[0].freq1 = fr1->klattp[KLATT_FNZ] * 2;
- peaks[0].freq = (int)(peaks[0].freq1);
- next = fr2->klattp[KLATT_FNZ] * 2;
- peaks[0].freq_inc = ((next - peaks[0].freq1) * STEPSIZE) / length;
-
- peaks[0].bw1 = 89;
- peaks[0].bw = 89;
- peaks[0].bw_inc = 0;
-
- if(fr1->frflags & FRFLAG_KLATT)
- {
- // the frame contains additional parameters for parallel resonators
- for(ix=1; ix < 7; ix++)
- {
- peaks[ix].bp1 = fr1->klatt_bp[ix] * 4; // parallel bandwidth
- peaks[ix].bp = (int)(peaks[ix].bp1);
- next = fr2->klatt_bp[ix] * 2;
- peaks[ix].bp_inc = ((next - peaks[ix].bp1) * STEPSIZE) / length;
-
- peaks[ix].ap1 = fr1->klatt_ap[ix]; // parallal amplitude
- peaks[ix].ap = (int)(peaks[ix].ap1);
- next = fr2->klatt_ap[ix] * 2;
- peaks[ix].ap_inc = ((next - peaks[ix].ap1) * STEPSIZE) / length;
- }
- }
-} // end of SetSynth_Klatt
-
-
-int Wavegen_Klatt2(int length, int modulation, int resume, frame_t *fr1, frame_t *fr2)
-{//===================================================================================
- if(resume==0)
- SetSynth_Klatt(length, modulation, fr1, fr2, wvoice, 1);
-
- return(Wavegen_Klatt(resume));
-}
-
-
-
-void KlattInit()
-{
-#define NUMBER_OF_SAMPLES 100
-
- static short natural_samples[NUMBER_OF_SAMPLES]=
- {
- -310,-400,530,356,224,89,23,-10,-58,-16,461,599,536,701,770,
- 605,497,461,560,404,110,224,131,104,-97,155,278,-154,-1165,
- -598,737,125,-592,41,11,-247,-10,65,92,80,-304,71,167,-1,122,
- 233,161,-43,278,479,485,407,266,650,134,80,236,68,260,269,179,
- 53,140,275,293,296,104,257,152,311,182,263,245,125,314,140,44,
- 203,230,-235,-286,23,107,92,-91,38,464,443,176,98,-784,-2449,
- -1891,-1045,-1600,-1462,-1384,-1261,-949,-730
- };
- static short formant_hz[10] = {280,688,1064,2806,3260,3700,6500,7000,8000,280};
- static short bandwidth[10] = {89,160,70,160,200,200,500,500,500,89};
- static short parallel_amp[10] = { 0,59,59,59,59,59,59,0,0,0};
- static short parallel_bw[10] = {59,59,89,149,200,200,500,0,0,0};
-
- int ix;
-
- sample_count=0;
-
- kt_globals.synthesis_model = CASCADE_PARALLEL;
- kt_globals.samrate = 22050;
-
- kt_globals.glsource = IMPULSIVE; // IMPULSIVE, NATURAL, SAMPLED
- kt_globals.scale_wav = scale_wav_tab[kt_globals.glsource];
- kt_globals.natural_samples = natural_samples;
- kt_globals.num_samples = NUMBER_OF_SAMPLES;
- kt_globals.sample_factor = 3.0;
- kt_globals.nspfr = (kt_globals.samrate * 10) / 1000;
- kt_globals.outsl = 0;
- kt_globals.f0_flutter = 20;
-
- parwave_init();
-
- // set default values for frame parameters
- for(ix=0; ix<=9; ix++)
- {
- kt_frame.Fhz[ix] = formant_hz[ix];
- kt_frame.Bhz[ix] = bandwidth[ix];
- kt_frame.Ap[ix] = parallel_amp[ix];
- kt_frame.Bphz[ix] = parallel_bw[ix];
- }
- kt_frame.Bhz_next[F_NZ] = bandwidth[F_NZ];
-
- kt_frame.F0hz10 = 1000;
- kt_frame.AVdb = 59; // 59
- kt_frame.ASP = 0;
- kt_frame.Kopen = 40; // 40
- kt_frame.Aturb = 0;
- kt_frame.TLTdb = 0;
- kt_frame.AF =50;
- kt_frame.Kskew = 0;
- kt_frame.AB = 0;
- kt_frame.AVpdb = 0;
- kt_frame.Gain0 = 60; // 62
-} // end of KlattInit
-
-#endif // INCLUDE_KLATT
diff --git a/navit/support/espeak/klatt.h b/navit/support/espeak/klatt.h
deleted file mode 100644
index 5583b178a..000000000
--- a/navit/support/espeak/klatt.h
+++ /dev/null
@@ -1,153 +0,0 @@
-
-
-#define CASCADE_PARALLEL 1 /* Type of synthesis model */
-#define ALL_PARALLEL 2
-
-#define IMPULSIVE 1 /* Type of voicing source */
-#define NATURAL 2
-#define SAMPLED 3
-
-#define PI 3.1415927
-
-
-/* typedef's that need to be exported */
-
-typedef long flag;
-
-/* Resonator Structure */
-
-typedef struct
-{
- double a;
- double b;
- double c;
- double p1;
- double p2;
- double a_inc;
- double b_inc;
- double c_inc;
-} resonator_t, *resonator_ptr;
-
-/* Structure for Klatt Globals */
-
-typedef struct
-{
- flag synthesis_model; /* cascade-parallel or all-parallel */
- flag outsl; /* Output waveform selector */
- long samrate; /* Number of output samples per second */
- long FLPhz ; /* Frequeny of glottal downsample low-pass filter */
- long BLPhz ; /* Bandwidth of glottal downsample low-pass filter */
- flag glsource; /* Type of glottal source */
- int f0_flutter; /* Percentage of f0 flutter 0-100 */
- long nspfr; /* number of samples per frame */
- long nper; /* Counter for number of samples in a pitch period */
- long ns;
- long T0; /* Fundamental period in output samples times 4 */
- long nopen; /* Number of samples in open phase of period */
- long nmod; /* Position in period to begin noise amp. modul */
- long nrand; /* Varible used by random number generator */
- double pulse_shape_a; /* Makes waveshape of glottal pulse when open */
- double pulse_shape_b; /* Makes waveshape of glottal pulse when open */
- double minus_pi_t;
- double two_pi_t;
- double onemd;
- double decay;
- double amp_bypas; /* AB converted to linear gain */
- double amp_voice; /* AVdb converted to linear gain */
- double par_amp_voice; /* AVpdb converted to linear gain */
- double amp_aspir; /* AP converted to linear gain */
- double amp_frica; /* AF converted to linear gain */
- double amp_breth; /* ATURB converted to linear gain */
- double amp_gain0; /* G0 converted to linear gain */
- int num_samples; /* number of glottal samples */
- double sample_factor; /* multiplication factor for glottal samples */
- short *natural_samples; /* pointer to an array of glottal samples */
- long original_f0; /* original value of f0 not modified by flutter */
-
- int fadeout; // set to 64 to cause fadeout over 64 samples
- int scale_wav; // depends on the voicing source
-
-#define N_RSN 20
-#define Rnpc 0
-#define R1c 1
-#define R2c 2
-#define R3c 3
-#define R4c 4
-#define R5c 5
-#define R6c 6
-#define R7c 7
-#define R8c 8
-#define Rnz 9
-
-#define Rparallel 10
-#define Rnpp 10
-#define R1p 11
-#define R2p 12
-#define R3p 13
-#define R4p 14
-#define R5p 15
-#define R6p 16
-
-#define RGL 17
-#define RLP 18
-#define Rout 19
-
- resonator_t rsn[N_RSN]; // internal storage for resonators
- resonator_t rsn_next[N_RSN];
-
-} klatt_global_t, *klatt_global_ptr;
-
-/* Structure for Klatt Parameters */
-
-#define F_NZ 0 // nasal zero formant
-#define F1 1
-#define F2 2
-#define F3 3
-#define F4 4
-#define F5 5
-#define F6 6
-#define F_NP 9 // nasal pole formant
-
-
-typedef struct
-{
- long F0hz10; /* Voicing fund freq in Hz */
- long AVdb; /* Amp of voicing in dB, 0 to 70 */
- int Fhz[10]; // formant Hz, F_NZ to F6 to F_NP
- int Bhz[10];
- int Ap[10]; /* Amp of parallel formants in dB, 0 to 80 */
- int Bphz[10]; /* Parallel formants bw in Hz, 40 to 1000 */
-
- long ASP; /* Amp of aspiration in dB, 0 to 70 */
- long Kopen; /* # of samples in open period, 10 to 65 */
- long Aturb; /* Breathiness in voicing, 0 to 80 */
- long TLTdb; /* Voicing spectral tilt in dB, 0 to 24 */
- long AF; /* Amp of frication in dB, 0 to 80 */
- long Kskew; /* Skewness of alternate periods, 0 to 40 in sample#/2 */
-
- long AB; /* Amp of bypass fric. in dB, 0 to 80 */
- long AVpdb; /* Amp of voicing, par in dB, 0 to 70 */
- long Gain0; /* Overall gain, 60 dB is unity, 0 to 60 */
-
- long AVdb_tmp; //copy of AVdb, which is changed within parwave()
- int Fhz_next[10]; // Fhz for the next chunk, so we can do interpolation of resonator (a,b,c) parameters
- int Bhz_next[10];
- } klatt_frame_t, *klatt_frame_ptr;
-
-
-typedef struct {
- int freq; // Hz
- int bw; // klatt bandwidth
- int ap; // parallel amplitude
- int bp; // parallel bandwidth
- DOUBLEX freq1; // floating point versions of the above
- DOUBLEX bw1;
- DOUBLEX ap1;
- DOUBLEX bp1;
- DOUBLEX freq_inc; // increment by this every 64 samples
- DOUBLEX bw_inc;
- DOUBLEX ap_inc;
- DOUBLEX bp_inc;
-} klatt_peaks_t;
-
-
diff --git a/navit/support/espeak/mbrolib.h b/navit/support/espeak/mbrolib.h
deleted file mode 100644
index 0616b464b..000000000
--- a/navit/support/espeak/mbrolib.h
+++ /dev/null
@@ -1,205 +0,0 @@
-#ifndef MBROLIB_H
-#define MBROLIB_H
-
-/*
- * mbrolib: mbrola wrapper.
- *
- * Copyright (C) 2007 Gilles Casse <gcasse@oralux.org>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
-*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* < types */
-
-/** Parameters */
-
-typedef struct {
- int ignore_error; /* 1=Ignore any fatal error or unknown diphone */
- char comment_char; /* Comment character */
- float volume_ratio; /* Volume ratio */
- float frequency_ratio; /* Applied to pitch points */
- float time_ratio; /* Applied to phone durations */
-} mbrolib_parameter;
-
-
-/** Returned errors */
-
-typedef enum {
- MBROLIB_OK=0,
- MBROLIB_DATABASE_NOT_INSTALLED,
- MBROLIB_INVAL,
- MBROLIB_OUT_OF_MEMORY,
- MBROLIB_OUT_OF_RANGE,
- MBROLIB_READ_ERROR,
- MBROLIB_WRITE_ERROR
-} MBROLIB_ERROR;
-
-
-
-/** Gender */
-
-typedef enum {
- MBROLIB_FEMALE,
- MBROLIB_MALE
-} MBROLIB_GENDER;
-
-
-
-/** Voice descriptor */
-
-typedef struct {
- char *name; /* name (for example: "en1") */
- char *filename; /* database pathname (for example: "/usr/share/mbrola/voices/en1) */
- int rate; /* database sample rate */
- MBROLIB_GENDER gender;
- const char *language; /* Language and optional dialect qualifier in ascii (e.g. en, fr_ca). */
-} mbrolib_voice;
-
-/* > */
-
-
-/** Initialization, returns a new handle.
- First function.
-
- @param the_sample_rate: output rate in Hz (for example 22050). If 0, keep the original database rate.
-
- @return handle (or NULL if error).
-*/
-void* mbrolib_init( int sample_rate);
-typedef void* (t_mbrolib_init)(int);
-
-
-/** Returns the list of the installed mbrola databases.
- The databases are searched according to the MBROLA_PATH environment variable if set,
- or under a default path otherwise (see MBROLA_PATH in mbrolib.c).
-
- An array of voices is returned. The last item is set to NULL.
- The caller must not free the returned items or the array.
-
- @param the_handle previously given by mbrolib_init.
-
- @return An array of voices.
-*/
-const mbrolib_voice ** mbrolib_list_voices( void* the_handle);
-typedef const mbrolib_voice ** (t_mbrolib_list_voices)(void*);
-
-
-
-/** Set voice
-
- @param the_handle.
-
- @param the_database (for example, "en1").
-
- @return error code (MBROLIB_OK, MBROLIB_DATABASE_NOT_INSTALLED, MBROLIB_INVAL).
-
-*/
-MBROLIB_ERROR mbrolib_set_voice( void* the_handle, const char* the_name);
-typedef MBROLIB_ERROR (t_mbrolib_set_voice)( void*, const char*);
-
-
-
-/** Get the current database parameters.
- The caller supplies a pointer to an already allocated structure.
-
- @param the_handle previously given by mbrolib_init.
-
- @param the_parameters: pointer to the structure.
-
- @return error code (MBROLIB_OK, MBROLIB_INVAL).
-*/
-MBROLIB_ERROR mbrolib_get_parameter(void* the_handle, mbrolib_parameter* the_parameter);
-typedef MBROLIB_ERROR (t_mbrolib_get_parameter)(void*, mbrolib_parameter*);
-
-
-
-/** Set the database parameters using the supplied data.
-
- @param the_handle previously given by mbrolib_init.
-
- @param the_parameters: pointer to the wished parameters.
-
- @return error code (MBROLIB_OK, MBROLIB_INVAL).
-*/
-MBROLIB_ERROR mbrolib_set_parameter(void* the_handle, const mbrolib_parameter* the_parameter);
-typedef MBROLIB_ERROR (t_mbrolib_set_parameter)(void*, const mbrolib_parameter*);
-
-
-
-/** Write the mbrola phonemes in the internal buffer.
-
- @param the_handle.
-
- @param the_mbrola_phonemes.
-
- @param the_size in bytes.
-
- @return error code (MBROLIB_OK, MBROLIB_INVAL, MBROLIB_WRITE_ERROR, MBROLIB_READ_ERROR).
-*/
-MBROLIB_ERROR mbrolib_write(void* the_handle, const char* the_mbrola_phonemes, size_t the_size);
-typedef MBROLIB_ERROR (t_mbrolib_write)(void*, const char*, size_t);
-
-
-
-/** Read n bytes of the output samples.
-
- @param the_handle.
-
- @param the_samples (raw audio data, 16bits, mono).
-
- @param the_size max number of int16 to read.
-
- @param the_size number of int16 read.
-
- @return error code (MBROLIB_OK, MBROLIB_INVAL, MBROLIB_READ_ERROR).
-
-*/
-MBROLIB_ERROR mbrolib_read(void* the_handle, short* the_samples, int the_max_size, int* the_read_size);
-typedef MBROLIB_ERROR (t_mbrolib_read)(void*, short*, int, int*);
-
-
-
-/** Flush
-
- @param the_handle.
-
-*/
-void mbrolib_flush(void* the_handle);
-typedef void (t_mbrolib_flush)(void*);
-
-
-
-/** Release the handle
-
- @param the_handle.
-
- @return error code (MBROLIB_OK, MBROLIB_INVAL).
-
-*/
-MBROLIB_ERROR mbrolib_terminate(void* the_handle);
-typedef MBROLIB_ERROR (t_mbrolib_terminate)(void*);
-
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/navit/support/espeak/numbers.c b/navit/support/espeak/numbers.c
deleted file mode 100644
index 9c74eaca3..000000000
--- a/navit/support/espeak/numbers.c
+++ /dev/null
@@ -1,1507 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <wctype.h>
-#include <wchar.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-#include "translate.h"
-
-
-
-#define M_NAME 0
-#define M_SMALLCAP 1
-#define M_TURNED 2
-#define M_REVERSED 3
-#define M_CURL 4
-
-#define M_ACUTE 5
-#define M_BREVE 6
-#define M_CARON 7
-#define M_CEDILLA 8
-#define M_CIRCUMFLEX 9
-#define M_DIAERESIS 10
-#define M_DOUBLE_ACUTE 11
-#define M_DOT_ABOVE 12
-#define M_GRAVE 13
-#define M_MACRON 14
-#define M_OGONEK 15
-#define M_RING 16
-#define M_STROKE 17
-#define M_TILDE 18
-
-#define M_BAR 19
-#define M_RETROFLEX 20
-#define M_HOOK 21
-
-
-#define M_MIDDLE_DOT M_DOT_ABOVE // duplicate of M_DOT_ABOVE
-#define M_IMPLOSIVE M_HOOK
-
-typedef struct {
-const char *name;
-int flags;
-} ACCENTS;
-
-// these are tokens to look up in the *_list file.
-static ACCENTS accents_tab[] = {
-{"_lig", 1},
-{"_smc", 1}, // smallcap
-{"_tur", 1}, // turned
-{"_rev", 1}, // reversed
-{"_crl", 0}, // curl
-
-{"_acu", 0}, // acute
-{"_brv", 0}, // breve
-{"_hac", 0}, // caron/hacek
-{"_ced", 0}, // cedilla
-{"_cir", 0}, // circumflex
-{"_dia", 0}, // diaeresis
-{"_ac2", 0}, // double acute
-{"_dot", 0}, // dot
-{"_grv", 0}, // grave
-{"_mcn", 0}, // macron
-{"_ogo", 0}, // ogonek
-{"_rng", 0}, // ring
-{"_stk", 0}, // stroke
-{"_tld", 0}, // tilde
-
-{"_bar", 0}, // bar
-{"_rfx", 0}, // retroflex
-{"_hok", 0}, // hook
-};
-
-
-#define CAPITAL 0
-#define LETTER(ch,mod1,mod2) (ch-59)+(mod1 << 6)+(mod2 << 11)
-#define LIGATURE(ch1,ch2,mod1) (ch1-59)+((ch2-59) << 6)+(mod1 << 12)+0x8000
-
-
-#define L_ALPHA 60 // U+3B1
-#define L_SCHWA 61 // U+259
-#define L_OPEN_E 62 // U+25B
-#define L_GAMMA 63 // U+3B3
-#define L_IOTA 64 // U+3B9
-#define L_OE 65 // U+153
-#define L_OMEGA 66 // U+3C9
-
-#define L_PHI 67 // U+3C6
-#define L_ESH 68 // U+283
-#define L_UPSILON 69 // U+3C5
-#define L_EZH 70 // U+292
-#define L_GLOTTAL 71 // U+294
-#define L_RTAP 72 // U+27E
-
-
-static const short non_ascii_tab[] = {
- 0, 0x3b1, 0x259, 0x25b, 0x3b3, 0x3b9, 0x153, 0x3c9,
-0x3c6, 0x283, 0x3c5, 0x292, 0x294, 0x27e };
-
-
-// characters U+00e0 to U+017f
-static const unsigned short letter_accents_0e0[] = {
-LETTER('a',M_GRAVE,0), // U+00e0
-LETTER('a',M_ACUTE,0),
-LETTER('a',M_CIRCUMFLEX,0),
-LETTER('a',M_TILDE,0),
-LETTER('a',M_DIAERESIS,0),
-LETTER('a',M_RING,0),
-LIGATURE('a','e',0),
-LETTER('c',M_CEDILLA,0),
-LETTER('e',M_GRAVE,0),
-LETTER('e',M_ACUTE,0),
-LETTER('e',M_CIRCUMFLEX,0),
-LETTER('e',M_DIAERESIS,0),
-LETTER('i',M_GRAVE,0),
-LETTER('i',M_ACUTE,0),
-LETTER('i',M_CIRCUMFLEX,0),
-LETTER('i',M_DIAERESIS,0),
-LETTER('d',M_NAME,0), // eth // U+00f0
-LETTER('n',M_TILDE,0),
-LETTER('o',M_GRAVE,0),
-LETTER('o',M_ACUTE,0),
-LETTER('o',M_CIRCUMFLEX,0),
-LETTER('o',M_TILDE,0),
-LETTER('o',M_DIAERESIS,0),
-0, // division sign
-LETTER('o',M_STROKE,0),
-LETTER('u',M_GRAVE,0),
-LETTER('u',M_ACUTE,0),
-LETTER('u',M_CIRCUMFLEX,0),
-LETTER('u',M_DIAERESIS,0),
-LETTER('y',M_ACUTE,0),
-LETTER('t',M_NAME,0), // thorn
-LETTER('y',M_DIAERESIS,0),
-CAPITAL, // U+0100
-LETTER('a',M_MACRON,0),
-CAPITAL,
-LETTER('a',M_BREVE,0),
-CAPITAL,
-LETTER('a',M_OGONEK,0),
-CAPITAL,
-LETTER('c',M_ACUTE,0),
-CAPITAL,
-LETTER('c',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('c',M_DOT_ABOVE,0),
-CAPITAL,
-LETTER('c',M_CARON,0),
-CAPITAL,
-LETTER('d',M_CARON,0),
-CAPITAL, // U+0110
-LETTER('d',M_STROKE,0),
-CAPITAL,
-LETTER('e',M_MACRON,0),
-CAPITAL,
-LETTER('e',M_BREVE,0),
-CAPITAL,
-LETTER('e',M_DOT_ABOVE,0),
-CAPITAL,
-LETTER('e',M_OGONEK,0),
-CAPITAL,
-LETTER('e',M_CARON,0),
-CAPITAL,
-LETTER('g',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('g',M_BREVE,0),
-CAPITAL, // U+0120
-LETTER('g',M_DOT_ABOVE,0),
-CAPITAL,
-LETTER('g',M_CEDILLA,0),
-CAPITAL,
-LETTER('h',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('h',M_STROKE,0),
-CAPITAL,
-LETTER('i',M_TILDE,0),
-CAPITAL,
-LETTER('i',M_MACRON,0),
-CAPITAL,
-LETTER('i',M_BREVE,0),
-CAPITAL,
-LETTER('i',M_OGONEK,0),
-CAPITAL, // U+0130
-LETTER('i',M_NAME,0), // dotless i
-CAPITAL,
-LIGATURE('i','j',0),
-CAPITAL,
-LETTER('j',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('k',M_CEDILLA,0),
-LETTER('k',M_NAME,0), // kra
-CAPITAL,
-LETTER('l',M_ACUTE,0),
-CAPITAL,
-LETTER('l',M_CEDILLA,0),
-CAPITAL,
-LETTER('l',M_CARON,0),
-CAPITAL,
-LETTER('l',M_MIDDLE_DOT,0), // U+0140
-CAPITAL,
-LETTER('l',M_STROKE,0),
-CAPITAL,
-LETTER('n',M_ACUTE,0),
-CAPITAL,
-LETTER('n',M_CEDILLA,0),
-CAPITAL,
-LETTER('n',M_CARON,0),
-LETTER('n',M_NAME,0), // apostrophe n
-CAPITAL,
-LETTER('n',M_NAME,0), // eng
-CAPITAL,
-LETTER('o',M_MACRON,0),
-CAPITAL,
-LETTER('o',M_BREVE,0),
-CAPITAL, // U+0150
-LETTER('o',M_DOUBLE_ACUTE,0),
-CAPITAL,
-LIGATURE('o','e',0),
-CAPITAL,
-LETTER('r',M_ACUTE,0),
-CAPITAL,
-LETTER('r',M_CEDILLA,0),
-CAPITAL,
-LETTER('r',M_CARON,0),
-CAPITAL,
-LETTER('s',M_ACUTE,0),
-CAPITAL,
-LETTER('s',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('s',M_CEDILLA,0),
-CAPITAL, // U+0160
-LETTER('s',M_CARON,0),
-CAPITAL,
-LETTER('t',M_CEDILLA,0),
-CAPITAL,
-LETTER('t',M_CARON,0),
-CAPITAL,
-LETTER('t',M_STROKE,0),
-CAPITAL,
-LETTER('u',M_TILDE,0),
-CAPITAL,
-LETTER('u',M_MACRON,0),
-CAPITAL,
-LETTER('u',M_BREVE,0),
-CAPITAL,
-LETTER('u',M_RING,0),
-CAPITAL, // U+0170
-LETTER('u',M_DOUBLE_ACUTE,0),
-CAPITAL,
-LETTER('u',M_OGONEK,0),
-CAPITAL,
-LETTER('w',M_CIRCUMFLEX,0),
-CAPITAL,
-LETTER('y',M_CIRCUMFLEX,0),
-CAPITAL, // Y-DIAERESIS
-CAPITAL,
-LETTER('z',M_ACUTE,0),
-CAPITAL,
-LETTER('z',M_DOT_ABOVE,0),
-CAPITAL,
-LETTER('z',M_CARON,0),
-LETTER('s',M_NAME,0), // long-s // U+17f
-};
-
-
-// characters U+0250 to U+029F
-static const unsigned short letter_accents_250[] = {
-LETTER('a',M_TURNED,0), // U+250
-LETTER(L_ALPHA,0,0),
-LETTER(L_ALPHA,M_TURNED,0),
-LETTER('b',M_IMPLOSIVE,0),
-0, // open-o
-LETTER('c',M_CURL,0),
-LETTER('d',M_RETROFLEX,0),
-LETTER('d',M_IMPLOSIVE,0),
-LETTER('e',M_REVERSED,0), // U+258
-0, // schwa
-LETTER(L_SCHWA,M_HOOK,0),
-0, // open-e
-LETTER(L_OPEN_E,M_REVERSED,0),
-LETTER(L_OPEN_E,M_HOOK,M_REVERSED),
-0,//LETTER(L_OPEN_E,M_CLOSED,M_REVERSED),
-LETTER('j',M_BAR,0),
-LETTER('g',M_IMPLOSIVE,0), // U+260
-LETTER('g',0,0),
-LETTER('g',M_SMALLCAP,0),
-LETTER(L_GAMMA,0,0),
-0, // ramshorn
-LETTER('h',M_TURNED,0),
-LETTER('h',M_HOOK,0),
-0,//LETTER(L_HENG,M_HOOK,0),
-LETTER('i',M_BAR,0), // U+268
-LETTER(L_IOTA,0,0),
-LETTER('i',M_SMALLCAP,0),
-LETTER('l',M_TILDE,0),
-LETTER('l',M_BAR,0),
-LETTER('l',M_RETROFLEX,0),
-LIGATURE('l','z',0),
-LETTER('m',M_TURNED,0),
-0,//LETTER('m',M_TURNED,M_LEG), // U+270
-LETTER('m',M_HOOK,0),
-0,//LETTER('n',M_LEFTHOOK,0),
-LETTER('n',M_RETROFLEX,0),
-LETTER('n',M_SMALLCAP,0),
-LETTER('o',M_BAR,0),
-LIGATURE('o','e',M_SMALLCAP),
-0,//LETTER(L_OMEGA,M_CLOSED,0),
-LETTER(L_PHI,0,0), // U+278
-LETTER('r',M_TURNED,0),
-0,//LETTER('r',M_TURNED,M_LEG),
-LETTER('r',M_RETROFLEX,M_TURNED),
-0,//LETTER('r',M_LEG,0),
-LETTER('r',M_RETROFLEX,0),
-0, // r-tap
-LETTER(L_RTAP,M_REVERSED,0),
-LETTER('r',M_SMALLCAP,0), // U+280
-LETTER('r',M_TURNED,M_SMALLCAP),
-LETTER('s',M_RETROFLEX,0),
-0, // esh
-0,//LETTER('j',M_BAR,L_IMPLOSIVE),
-LETTER(L_ESH,M_REVERSED,0),
-LETTER(L_ESH,M_CURL,0),
-LETTER('t',M_TURNED,0),
-LETTER('t',M_RETROFLEX,0), // U+288
-LETTER('u',M_BAR,0),
-LETTER(L_UPSILON,0,0),
-LETTER('v',M_HOOK,0),
-LETTER('v',M_TURNED,0),
-LETTER('w',M_TURNED,0),
-LETTER('y',M_TURNED,0),
-LETTER('y',M_SMALLCAP,0),
-LETTER('z',M_RETROFLEX,0), // U+290
-LETTER('z',M_CURL,0),
-0, // ezh
-LETTER(L_EZH,M_CURL,0),
-0, // glottal stop
-LETTER(L_GLOTTAL,M_REVERSED,0),
-LETTER(L_GLOTTAL,M_TURNED,0),
-0,//LETTER('c',M_LONG,0),
-0, // bilabial click // U+298
-LETTER('b',M_SMALLCAP,0),
-0,//LETTER(L_OPEN_E,M_CLOSED,0),
-LETTER('g',M_IMPLOSIVE,M_SMALLCAP),
-LETTER('h',M_SMALLCAP,0),
-LETTER('j',M_CURL,0),
-LETTER('k',M_TURNED,0),
-LETTER('l',M_SMALLCAP,0),
-LETTER('q',M_HOOK,0), // U+2a0
-LETTER(L_GLOTTAL,M_STROKE,0),
-LETTER(L_GLOTTAL,M_STROKE,M_REVERSED),
-LIGATURE('d','z',0),
-0, // dezh
-LIGATURE('d','z',M_CURL),
-LIGATURE('t','s',0),
-0, // tesh
-LIGATURE('t','s',M_CURL),
-};
-
-static int LookupLetter2(Translator *tr, unsigned int letter, char *ph_buf)
-{//========================================================================
- int len;
- char single_letter[10];
-
- single_letter[0] = 0;
- single_letter[1] = '_';
- len = utf8_out(letter, &single_letter[2]);
- single_letter[len+2] = ' ';
- single_letter[len+3] = 0;
-
- if(Lookup(tr, &single_letter[1], ph_buf) == 0)
- {
- single_letter[1] = ' ';
- if(Lookup(tr, &single_letter[2], ph_buf) == 0)
- {
- TranslateRules(tr, &single_letter[2], ph_buf, 20, NULL,0,NULL);
- }
- }
- return(ph_buf[0]);
-}
-
-
-void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf)
-{//=========================================================================
- // lookup the character in the accents table
- int accent_data = 0;
- int accent1 = 0;
- int accent2 = 0;
- int basic_letter;
- int letter2=0;
- char ph_letter1[30];
- char ph_letter2[30];
- char ph_accent1[30];
- char ph_accent2[30];
-
- ph_accent2[0] = 0;
-
- if((letter >= 0xe0) && (letter < 0x17f))
- {
- accent_data = letter_accents_0e0[letter - 0xe0];
- }
- else
- if((letter >= 0x250) && (letter <= 0x2a8))
- {
- accent_data = letter_accents_250[letter - 0x250];
- }
-
- if(accent_data != 0)
- {
- basic_letter = (accent_data & 0x3f) + 59;
- if(basic_letter < 'a')
- basic_letter = non_ascii_tab[basic_letter-59];
-
- if(accent_data & 0x8000)
- {
- letter2 = (accent_data >> 6) & 0x3f;
- letter2 += 59;
- accent2 = (accent_data >> 12) & 0x7;
- }
- else
- {
- accent1 = (accent_data >> 6) & 0x1f;
- accent2 = (accent_data >> 11) & 0xf;
- }
-
-
- if(Lookup(tr, accents_tab[accent1].name, ph_accent1) != 0)
- {
-
- if(LookupLetter2(tr, basic_letter, ph_letter1) != 0)
- {
- if(accent2 != 0)
- {
- if(Lookup(tr, accents_tab[accent2].name, ph_accent2) == 0)
- {
-// break;
- }
-
- if(accents_tab[accent2].flags & 1)
- {
- strcpy(ph_buf,ph_accent2);
- ph_buf += strlen(ph_buf);
- ph_accent2[0] = 0;
- }
- }
- if(letter2 != 0)
- {
- //ligature
- LookupLetter2(tr, letter2, ph_letter2);
- sprintf(ph_buf,"%s%c%s%c%s%s",ph_accent1, phonPAUSE_VSHORT, ph_letter1, phonSTRESS_P, ph_letter2, ph_accent2);
- }
- else
- {
- if(accent1 == 0)
- strcpy(ph_buf, ph_letter1);
- else
- if((tr->langopts.accents & 1) || (accents_tab[accent1].flags & 1))
- sprintf(ph_buf,"%s%c%c%s", ph_accent1, phonPAUSE_VSHORT, phonSTRESS_P, ph_letter1);
- else
- sprintf(ph_buf,"%c%s%c%s%c", phonSTRESS_2, ph_letter1, phonPAUSE_VSHORT, ph_accent1, phonPAUSE_VSHORT);
- }
- }
- }
- }
-} // end of LookupAccentedLetter
-
-
-
-void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf1)
-{//=================================================================================
- int len;
- unsigned char *p;
- static char single_letter[10] = {0,0};
- char ph_stress[2];
- unsigned int dict_flags[2];
- char ph_buf3[40];
- char *ptr;
-
- ph_buf1[0] = 0;
- len = utf8_out(letter,&single_letter[2]);
- single_letter[len+2] = ' ';
-
- if(next_byte == -1)
- {
- // speaking normal text, not individual characters
- if(Lookup(tr, &single_letter[2], ph_buf1) != 0)
- return;
-
- single_letter[1] = '_';
- if(Lookup(tr, &single_letter[1], ph_buf3) != 0)
- return; // the character is specified as _* so ignore it when speaking normal text
-
- // check whether this character is specified for English
- if(tr->translator_name == L('e','n'))
- return; // we are already using English
-
- SetTranslator2("en");
- if(Lookup(translator2, &single_letter[2], ph_buf3) != 0)
- {
- // yes, switch to English and re-translate the word
- sprintf(ph_buf1,"%c",phonSWITCH);
- }
- SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
- return;
- }
-
- if((letter <= 32) || iswspace(letter))
- {
- // lookup space as _&32 etc.
- sprintf(&single_letter[1],"_#%d ",letter);
- Lookup(tr, &single_letter[1], ph_buf1);
- return;
- }
-
- if(next_byte != ' ')
- next_byte = RULE_SPELLING;
- single_letter[3+len] = next_byte; // follow by space-space if the end of the word, or space-0x31
-
- single_letter[1] = '_';
-
- // if the $accent flag is set for this letter, use the accents table (below)
- dict_flags[1] = 0;
- ptr = &single_letter[1];
-
- if(Lookup(tr, &single_letter[1], ph_buf3) == 0)
- {
- single_letter[1] = ' ';
- if(Lookup(tr, &single_letter[2], ph_buf3) == 0)
- {
- TranslateRules(tr, &single_letter[2], ph_buf3, sizeof(ph_buf3), NULL,FLAG_NO_TRACE,NULL);
- }
- }
-
- if(ph_buf3[0] == 0)
- {
- LookupAccentedLetter(tr, letter, ph_buf3);
- }
-
- if(ph_buf3[0] == 0)
- {
- ph_buf1[0] = 0;
- return;
- }
- if(ph_buf3[0] == phonSWITCH)
- {
- strcpy(ph_buf1,ph_buf3);
- return;
- }
- // at a stress marker at the start of the letter name, unless one is already marked
- ph_stress[0] = phonSTRESS_P;
- ph_stress[1] = 0;
-
- for(p=(unsigned char *)ph_buf3; *p != 0; p++)
- {
- if(phoneme_tab[*p]->type == phSTRESS)
- ph_stress[0] = 0; // stress is already marked
- }
- sprintf(ph_buf1,"%s%s",ph_stress,ph_buf3);
-}
-
-
-
-int TranslateLetter(Translator *tr, char *word, char *phonemes, int control, int word_length)
-{//======================================================================================
-// get pronunciation for an isolated letter
-// return number of bytes used by the letter
-// control 2=say-as glyphs, 3-say-as chars
- int n_bytes;
- int letter;
- int len;
- int save_option_phonemes;
- char *p2;
- char *pbuf;
- char capital[20];
- char ph_buf[60];
- char ph_buf2[60];
- char hexbuf[6];
-
- ph_buf[0] = 0;
- capital[0] = 0;
-
- n_bytes = utf8_in(&letter,word);
-
- if((letter & 0xfff00) == 0x0e000)
- {
- letter &= 0xff; // uncode private usage area
- }
-
- if(control > 2)
- {
- // include CAPITAL information
- if(iswupper(letter))
- {
- Lookup(tr, "_cap", capital);
- }
- }
- letter = towlower2(letter);
-
- LookupLetter(tr, letter, word[n_bytes], ph_buf);
-
- if(ph_buf[0] == phonSWITCH)
- {
- strcpy(phonemes,ph_buf);
- return(0);
- }
-
- if((ph_buf[0] == 0) && (tr->translator_name != L('e','n')))
- {
- // speak as English, check whether there is a translation for this character
- SetTranslator2("en");
- save_option_phonemes = option_phonemes;
- option_phonemes = 0;
- LookupLetter(translator2, letter, word[n_bytes], ph_buf);
- SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
- option_phonemes = save_option_phonemes;
-
- if(ph_buf[0] != 0)
- {
- sprintf(phonemes,"%cen",phonSWITCH);
- return(0);
- }
- }
-
- if(ph_buf[0] == 0)
- {
- // character name not found
- if(iswalpha(letter))
- Lookup(tr, "_?A", ph_buf);
-
- if((ph_buf[0]==0) && !iswspace(letter))
- Lookup(tr, "_??", ph_buf);
-
- if(ph_buf[0] != 0)
- {
- // speak the hexadecimal number of the character code
- sprintf(hexbuf,"%x",letter);
- pbuf = ph_buf;
- for(p2 = hexbuf; *p2 != 0; p2++)
- {
- pbuf += strlen(pbuf);
- *pbuf++ = phonPAUSE_VSHORT;
- LookupLetter(tr, *p2, 0, pbuf);
- }
- }
- }
-
- len = strlen(phonemes);
- if(tr->langopts.accents & 2)
- sprintf(ph_buf2,"%c%s%s",0xff,ph_buf,capital);
- else
- sprintf(ph_buf2,"%c%s%s",0xff,capital,ph_buf); // the 0xff marker will be removed or replaced in SetSpellingStress()
- if((len + strlen(ph_buf2)) < N_WORD_PHONEMES)
- {
- strcpy(&phonemes[len],ph_buf2);
- }
- return(n_bytes);
-} // end of TranslateLetter
-
-
-
-void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars)
-{//=============================================================================
-// Individual letter names, reduce the stress of some.
- int ix;
- unsigned int c;
- int n_stress=0;
- int count;
- unsigned char buf[N_WORD_PHONEMES];
-
- for(ix=0; (c = phonemes[ix]) != 0; ix++)
- {
- if(c == phonSTRESS_P)
- {
- n_stress++;
- }
- buf[ix] = c;
- }
- buf[ix] = 0;
-
- count = 0;
- for(ix=0; (c = buf[ix]) != 0; ix++)
- {
- if((c == phonSTRESS_P) && (n_chars > 1))
- {
- count++;
-
- if(tr->langopts.spelling_stress == 1)
- {
- // stress on initial letter when spelling
- if(count > 1)
- c = phonSTRESS_3;
- }
- else
- {
- if(count != n_stress)
- {
- if(((count % 3) != 0) || (count == n_stress-1))
- c = phonSTRESS_3; // reduce to secondary stress
- }
- }
- }
- else
- if(c == 0xff)
- {
- if((control < 2) || (ix==0))
- continue; // don't insert pauses
-
- if(control == 4)
- c = phonPAUSE; // pause after each character
- if(((count % 3) == 0) || (control > 2))
- c = phonPAUSE_SHORT; // pause following a primary stress
- else
- continue; // remove marker
- }
- *phonemes++ = c;
- }
- if(control >= 2)
- *phonemes++ = phonPAUSE_NOLINK;
- *phonemes = 0;
-} // end of SetSpellingStress
-
-
-
-// Numbers
-
-static char ph_ordinal2[12];
-
-int TranslateRoman(Translator *tr, char *word, char *ph_out)
-{//=====================================================
- int c;
- char *p;
- const char *p2;
- int acc;
- int prev;
- int value;
- int subtract;
- int repeat = 0;
- unsigned int flags;
- char ph_roman[30];
- char number_chars[N_WORD_BYTES];
-
- static const char *roman_numbers = "ixcmvld";
- static int roman_values[] = {1,10,100,1000,5,50,500};
-
- acc = 0;
- prev = 0;
- subtract = 0x7fff;
-
- while((c = *word++) != ' ')
- {
- if((p2 = strchr(roman_numbers,c)) == NULL)
- return(0);
-
- value = roman_values[p2 - roman_numbers];
- if(value == prev)
- {
- repeat++;
- if(repeat >= 3)
- return(0);
- }
- else
- repeat = 0;
-
- if((prev > 1) && (prev != 10) && (prev != 100))
- {
- if(value >= prev)
- return(0);
- }
- if((prev != 0) && (prev < value))
- {
- if(((acc % 10) != 0) || ((prev*10) < value))
- return(0);
- subtract = prev;
- value -= subtract;
- }
- else
- if(value >= subtract)
- return(0);
- else
- acc += prev;
- prev = value;
- }
- acc += prev;
- if(acc < 2)
- return(0);
-
- if(acc > tr->langopts.max_roman)
- return(0);
-
- Lookup(tr, "_roman",ph_roman); // precede by "roman" if _rom is defined in *_list
- p = &ph_out[0];
-
- if((tr->langopts.numbers & NUM_ROMAN_AFTER) == 0)
- {
- strcpy(ph_out,ph_roman);
- p = &ph_out[strlen(ph_out)];
- }
-
- sprintf(number_chars," %d ",acc);
- TranslateNumber(tr, &number_chars[1], p, &flags, 0);
-
- if(tr->langopts.numbers & NUM_ROMAN_AFTER)
- strcat(ph_out,ph_roman);
- return(1);
-} // end of TranslateRoman
-
-
-static const char *M_Variant(int value)
-{//====================================
- // returns M, or perhaps MA for some cases
-
- if((translator->langopts.numbers2 & 0x100) && (value >= 2) && (value <= 4))
- return("0MA"); // Czech, Slovak
- else
- if(((value % 100) < 10) || ((value % 100) > 20)) // but not teens, 10 to 19
- {
- if ((translator->langopts.numbers2 & 0x40) &&
- ((value % 10)>=2) &&
- ((value % 10)<=4))
- {
- // for Polish language - two forms of plural!
- return("0MA");
- }
-
- if((translator->langopts.numbers2 & 0x80) &&
- ((value % 10)==1))
- {
- return("1MA");
- }
-
- }
- return("0M");
-}
-
-
-static int LookupThousands(Translator *tr, int value, int thousandplex, char *ph_out)
-{//==================================================================================
- int found;
- char string[12];
- char ph_of[12];
- char ph_thousands[40];
-
- ph_of[0] = 0;
-
- // first look fora match with the exact value of thousands
- sprintf(string,"_%dM%d",value,thousandplex);
-
- if((found = Lookup(tr, string, ph_thousands)) == 0)
- {
- if((value % 100) >= 20)
- {
- Lookup(tr, "_0of", ph_of);
- }
-
- sprintf(string,"_%s%d",M_Variant(value),thousandplex);
-
- if(Lookup(tr, string, ph_thousands) == 0)
- {
- // repeat "thousand" if higher order names are not available
- sprintf(string,"_%dM1",value);
- if((found = Lookup(tr, string, ph_thousands)) == 0)
- Lookup(tr, "_0M1", ph_thousands);
- }
- }
- sprintf(ph_out,"%s%s",ph_of,ph_thousands);
- return(found);
-}
-
-
-static int LookupNum2(Translator *tr, int value, int control, char *ph_out)
-{//========================================================================
-// Lookup a 2 digit number
-// control bit 0: tens and units (use special form of '1')
-// control bit 1: ordinal number
-// control bit 2: use feminine form of '2'
-// control bit 3: speak zero tens
-
- int found;
- int ix;
- int units;
- int used_and=0;
- int found_ordinal = 0;
- int next_phtype;
- char string[12]; // for looking up entries in *_list
- char ph_ordinal[20];
- char ph_tens[50];
- char ph_digits[50];
- char ph_and[12];
-
- // is there a special pronunciation for this 2-digit number
- found = 0;
- ph_ordinal[0] = 0;
-
- if(control & 4)
- {
- sprintf(string,"_%df",value);
- found = Lookup(tr, string, ph_digits);
- }
- if(control & 2)
- {
- strcpy(ph_ordinal, ph_ordinal2);
-
- sprintf(string,"_%do",value);
- if((found = Lookup(tr, string, ph_digits)) != 0)
- {
- found_ordinal = 1;
- }
- }
-
- if(found == 0)
- {
- if((value == 1) && (control & 1))
- {
- if(Lookup(tr, "_1a", ph_out) != 0)
- return(0);
- }
- sprintf(string,"_%d",value);
- found = Lookup(tr, string, ph_digits);
- }
-
- // no, speak as tens+units
-
- if((control & 8) && (value < 10))
- {
- // speak leading zero
- Lookup(tr, "_0", ph_tens);
- }
- else
- {
- if(found)
- {
- ph_tens[0] = 0;
- }
- else
- {
- units = (value % 10);
-
- if((control & 2) && ((units == 0) || (tr->langopts.numbers & 0x10)))
- {
- sprintf(string,"_%dXo",value / 10);
- if(Lookup(tr, string, ph_tens) != 0)
- {
- found_ordinal = 1;
- }
- }
- if(found_ordinal == 0)
- {
- sprintf(string,"_%dX",value / 10);
- Lookup(tr, string, ph_tens);
- }
-
- if((ph_tens[0] == 0) && (tr->langopts.numbers & NUM_VIGESIMAL))
- {
- // tens not found, (for example) 73 is 60+13
- units = (value % 20);
- sprintf(string,"_%dX",(value / 10) & 0xfe);
- Lookup(tr, string, ph_tens);
- }
-
- ph_digits[0] = 0;
- if(units > 0)
- {
- found = 0;
- if(control & 4)
- {
- // is there a variant form of this number?
- sprintf(string,"_%df",units);
- found = Lookup(tr, string, ph_digits);
- }
- if((control & 2) && ((tr->langopts.numbers & 0x10) == 0))
- {
- // ordinal
- sprintf(string,"_%do",units);
- if((found = Lookup(tr, string, ph_digits)) != 0)
- {
- found_ordinal = 1;
- }
- }
- if(found == 0)
- {
- sprintf(string,"_%d",units);
- Lookup(tr, string, ph_digits);
- }
- }
- }
- }
-
- if((control & 2) && (found_ordinal == 0) && (ph_ordinal[0] == 0))
- {
- if((value >= 20) && (((value % 10) == 0) || (tr->langopts.numbers & 0x10)))
- Lookup(tr, "_ord20", ph_ordinal);
- if(ph_ordinal[0] == 0)
- Lookup(tr, "_ord", ph_ordinal);
- }
-
- if((tr->langopts.numbers & 0x30) && (ph_tens[0] != 0) && (ph_digits[0] != 0))
- {
- Lookup(tr, "_0and", ph_and);
- if(tr->langopts.numbers & 0x10)
- sprintf(ph_out,"%s%s%s%s",ph_digits, ph_and, ph_tens, ph_ordinal);
- else
- sprintf(ph_out,"%s%s%s%s",ph_tens, ph_and, ph_digits, ph_ordinal);
- used_and = 1;
- }
- else
- {
- if(tr->langopts.numbers & 0x200)
- {
- // remove vowel from the end of tens if units starts with a vowel (LANG=Italian)
- if(((ix = strlen(ph_tens)-1) >= 0) && (ph_digits[0] != 0))
- {
- if((next_phtype = phoneme_tab[(unsigned int)(ph_digits[0])]->type) == phSTRESS)
- next_phtype = phoneme_tab[(unsigned int)(ph_digits[1])]->type;
-
- if((phoneme_tab[(unsigned int)(ph_tens[ix])]->type == phVOWEL) && (next_phtype == phVOWEL))
- ph_tens[ix] = 0;
- }
- }
- sprintf(ph_out,"%s%s%s",ph_tens, ph_digits, ph_ordinal);
- }
-
- if(tr->langopts.numbers & 0x100)
- {
- // only one primary stress
- found = 0;
- for(ix=strlen(ph_out)-1; ix>=0; ix--)
- {
- if(ph_out[ix] == phonSTRESS_P)
- {
- if(found)
- ph_out[ix] = phonSTRESS_3;
- else
- found = 1;
- }
- }
- }
- return(used_and);
-} // end of LookupNum2
-
-
-static int LookupNum3(Translator *tr, int value, char *ph_out, int suppress_null, int thousandplex, int control)
-{//=============================================================================================================
-// Translate a 3 digit number
-// control bit 0, previous thousands
-// bit 1, ordinal number
- int found;
- int hundreds;
- int x;
- char string[12]; // for looking up entries in **_list
- char buf1[100];
- char buf2[100];
- char ph_100[20];
- char ph_10T[20];
- char ph_digits[50];
- char ph_thousands[50];
- char ph_hundred_and[12];
- char ph_thousand_and[12];
-
- hundreds = value / 100;
- buf1[0] = 0;
-
- if(hundreds > 0)
- {
- ph_thousands[0] = 0;
- ph_thousand_and[0] = 0;
-
- found = 0;
- if((control & 2) && ((value % 100) == 0))
- {
- // ordinal number, with no tens or units
- found = Lookup(tr, "_0Co", ph_100);
- }
- if(found == 0)
- {
- Lookup(tr, "_0C", ph_100);
- }
-
- if(((tr->langopts.numbers & 0x0800) != 0) && (hundreds == 19))
- {
- // speak numbers such as 1984 as years: nineteen-eighty-four
-// ph_100[0] = 0; // don't say "hundred", we also need to surpess "and"
- }
- else
- if(hundreds >= 10)
- {
- ph_digits[0] = 0;
-
- if(LookupThousands(tr, hundreds / 10, thousandplex+1, ph_10T) == 0)
- {
- x = 0;
- if(tr->langopts.numbers2 & (1 << (thousandplex+1)))
- x = 4;
- LookupNum2(tr, hundreds/10, x, ph_digits);
- }
-
- if(tr->langopts.numbers2 & 0x200)
- sprintf(ph_thousands,"%s%s%c",ph_10T,ph_digits,phonPAUSE_NOLINK); // say "thousands" before its number, not after
- else
- sprintf(ph_thousands,"%s%s%c",ph_digits,ph_10T,phonPAUSE_NOLINK);
-
- hundreds %= 10;
- if(hundreds == 0)
- ph_100[0] = 0;
- suppress_null = 1;
- }
-
- ph_digits[0] = 0;
- if(hundreds > 0)
- {
- if((tr->langopts.numbers & 0x100000) && ((control & 1) || (ph_thousands[0] != 0)))
- {
- Lookup(tr, "_0and", ph_thousand_and);
- }
-
- suppress_null = 1;
-
- found = 0;
- if((value % 1000) == 100)
- {
- // is there a special pronunciation for exactly 100 ?
- found = Lookup(tr, "_1C0", ph_digits);
- }
- if(!found)
- {
- sprintf(string,"_%dC",hundreds);
- found = Lookup(tr, string, ph_digits); // is there a specific pronunciation for n-hundred ?
- }
-
- if(found)
- {
- ph_100[0] = 0;
- }
- else
- {
- if((hundreds > 1) || ((tr->langopts.numbers & 0x400) == 0))
- {
- LookupNum2(tr, hundreds, 0, ph_digits);
- }
- }
- }
-
- sprintf(buf1,"%s%s%s%s",ph_thousands,ph_thousand_and,ph_digits,ph_100);
- }
-
- ph_hundred_and[0] = 0;
- if((tr->langopts.numbers & 0x40) && ((value % 100) != 0))
- {
- if((value > 100) || ((control & 1) && (thousandplex==0)))
- {
- Lookup(tr, "_0and", ph_hundred_and);
- }
- }
-
-
- buf2[0] = 0;
- value = value % 100;
-
- if((value != 0) || (suppress_null == 0))
- {
- x = 0;
- if(thousandplex==0)
- {
- x = 1; // allow "eins" for 1 rather than "ein"
- if(control & 2)
- x = 3; // ordinal number
- }
- else
- {
- if(tr->langopts.numbers2 & (1 << thousandplex))
- x = 4; // use variant (feminine) for before thousands and millions
- }
-
- if(LookupNum2(tr, value, x, buf2) != 0)
- {
- if(tr->langopts.numbers & 0x80)
- ph_hundred_and[0] = 0; // don't put 'and' after 'hundred' if there's 'and' between tens and units
- }
- }
-
- sprintf(ph_out,"%s%s%s",buf1,ph_hundred_and,buf2);
-
- return(0);
-} // end of LookupNum3
-
-
-static int TranslateNumber_1(Translator *tr, char *word, char *ph_out, unsigned int *flags, int wflags)
-{//====================================================================================================
-// Number translation with various options
-// the "word" may be up to 4 digits
-// "words" of 3 digits may be preceded by another number "word" for thousands or millions
-
- int n_digits;
- int value;
- unsigned int ix;
- unsigned char c;
- int suppress_null = 0;
- int decimal_point = 0;
- int thousandplex = 0;
- int thousands_inc = 0;
- int prev_thousands = 0;
- int ordinal = 0;
- int this_value;
- static int prev_value;
- int decimal_count;
- int max_decimal_count;
- int decimal_mode;
- int hyphen;
- char *p;
- char string[20]; // for looking up entries in **_list
- char buf1[100];
- char ph_append[50];
- char ph_buf[200];
- char ph_buf2[50];
- char suffix[20];
-
- static const char str_pause[2] = {phonPAUSE_NOLINK,0};
-
- *flags = 0;
-
- for(ix=0; isdigit(word[ix]); ix++) ;
- n_digits = ix;
- value = this_value = atoi(word);
-
- ph_ordinal2[0] = 0;
- if((tr->langopts.numbers & 0x10000) && (word[ix] == '.') && !isdigit(word[ix+2]))
- {
- // ordinal number is indicated by dot after the number
- ordinal = 2;
- word[ix] = ' ';
- }
- else
- {
- // look for an ordinal number suffix after the number
- ix++;
- hyphen = 0;
- p = suffix;
- if(word[ix] == '-')
- {
- *p++ = '-';
- hyphen = 1;
- ix += 2;
- }
- while((word[ix] != 0) && (word[ix] != ' ') && (ix < (sizeof(suffix)-1)))
- {
- *p++ = word[ix++];
- }
- *p = 0;
-
- if(suffix[0] != 0)
- {
- sprintf(string,"_0%s",suffix);
- if(Lookup(tr, string, ph_ordinal2))
- {
- // this is an ordinal suffix
- ordinal = 2;
- flags[0] |= FLAG_SKIPWORDS;
- dictionary_skipwords = 1 + hyphen;
- }
- }
- }
-
- ph_append[0] = 0;
- ph_buf2[0] = 0;
-
- // is there a previous thousands part (as a previous "word") ?
- if((n_digits == 3) && (word[-2] == tr->langopts.thousands_sep) && isdigit(word[-3]))
- {
- prev_thousands = 1;
- }
- else
- if((tr->langopts.thousands_sep == ' ') || (tr->langopts.numbers & 0x1000))
- {
- // thousands groups can be separated by spaces
- if((n_digits == 3) && isdigit(word[-2]))
- {
- prev_thousands = 1;
- }
- }
-
- if((word[0] == '0') && (prev_thousands == 0) && (word[1] != ' ') && (word[1] != tr->langopts.decimal_sep))
- {
- if((n_digits == 2) && (word[3] == ':') && isdigit(word[5]) && isspace(word[7]))
- {
- // looks like a time 02:30, omit the leading zero
- }
- else
- {
- return(0); // number string with leading zero, speak as individual digits
- }
- }
-
- if((tr->langopts.numbers & 0x1000) && (word[n_digits] == ' '))
- thousands_inc = 1;
- else
- if(word[n_digits] == tr->langopts.thousands_sep)
- thousands_inc = 2;
-
- if(thousands_inc > 0)
- {
- // if the following "words" are three-digit groups, count them and add
- // a "thousand"/"million" suffix to this one
-
- ix = n_digits + thousands_inc;
- while(isdigit(word[ix]) && isdigit(word[ix+1]) && isdigit(word[ix+2]))
- {
- thousandplex++;
- if(word[ix+3] == tr->langopts.thousands_sep)
- ix += (3 + thousands_inc);
- else
- break;
- }
- }
-
- if((value == 0) && prev_thousands)
- {
- suppress_null = 1;
- }
-
- if((word[n_digits] == tr->langopts.decimal_sep) && isdigit(word[n_digits+1]))
- {
- // this "word" ends with a decimal point
- Lookup(tr, "_dpt", ph_append);
- decimal_point = 1;
- }
- else
- if(suppress_null == 0)
- {
- if(thousands_inc > 0)
- {
- if((thousandplex > 0) && (value < 1000))
- {
- if((suppress_null == 0) && (LookupThousands(tr,value,thousandplex,ph_append)))
- {
- // found an exact match for N thousand
- value = 0;
- suppress_null = 1;
- }
- }
- }
- }
- else
- if((thousandplex > 1) && prev_thousands && (prev_value > 0))
- {
- sprintf(string,"_%s%d",M_Variant(value),thousandplex+1);
- if(Lookup(tr, string, buf1)==0)
- {
- // speak this thousandplex if there was no word for the previous thousandplex
- sprintf(string,"_0M%d",thousandplex);
- Lookup(tr, string, ph_append);
- }
- }
-
- if((ph_append[0] == 0) && (word[n_digits] == '.') && (thousandplex == 0))
- {
- Lookup(tr, "_.", ph_append);
- }
-
- LookupNum3(tr, value, ph_buf, suppress_null, thousandplex, prev_thousands | ordinal);
- if((thousandplex > 0) && (tr->langopts.numbers2 & 0x200))
- sprintf(ph_out,"%s%s%s",ph_append,ph_buf2,ph_buf); // say "thousands" before its number
- else
- sprintf(ph_out,"%s%s%s",ph_buf2,ph_buf,ph_append);
-
-
- while(decimal_point)
- {
- n_digits++;
-
- decimal_count = 0;
- while(isdigit(word[n_digits+decimal_count]))
- decimal_count++;
-
- if(decimal_count > 1)
- {
- max_decimal_count = 2;
- switch(decimal_mode = (tr->langopts.numbers & 0xe000))
- {
- case 0x8000:
- max_decimal_count = 5;
- case 0x4000:
- // French/Polish decimal fraction
- while(word[n_digits] == '0')
- {
- Lookup(tr, "_0", buf1);
- strcat(ph_out,buf1);
- decimal_count--;
- n_digits++;
- }
- if((decimal_count <= max_decimal_count) && isdigit(word[n_digits]))
- {
- LookupNum3(tr, atoi(&word[n_digits]), buf1, 0,0,0);
- strcat(ph_out,buf1);
- n_digits += decimal_count;
- }
- break;
-
- case 0x2000:
- case 0xa000:
- // Italian decimal fractions
- if(decimal_count <= 4)
- {
- LookupNum3(tr, atoi(&word[n_digits]), ph_buf, 0,0,0);
- if((word[n_digits]=='0') || (decimal_mode == 0xa000))
- {
- // decimal part has leading zeros, so add a "hundredths" or "thousandths" suffix
- sprintf(string,"_0Z%d",decimal_count);
- if(Lookup(tr, string, buf1) == 0)
- break; // revert to speaking single digits
-
- strcat(ph_buf,buf1);
- }
- strcat(ph_out,ph_buf);
- n_digits += decimal_count;
- }
- break;
-
- case 0x6000:
- // Romanian decimal fractions
- if((decimal_count <= 4) && (word[n_digits] != '0'))
- {
- LookupNum3(tr, atoi(&word[n_digits]), buf1, 0,0,0);
- strcat(ph_out,buf1);
- n_digits += decimal_count;
- }
- break;
- }
- }
-
- while(isdigit(c = word[n_digits]) && (strlen(ph_out) < (N_WORD_PHONEMES - 10)))
- {
- value = word[n_digits++] - '0';
- LookupNum2(tr, value, 1, buf1);
- strcat(ph_out,buf1);
- }
-
- // something after the decimal part ?
- if(Lookup(tr, "_dpt2", buf1))
- strcat(ph_out,buf1);
-
- if((c == tr->langopts.decimal_sep) && isdigit(word[n_digits+1]))
- {
- Lookup(tr, "_dpt", buf1);
- strcat(ph_out,buf1);
- }
- else
- {
- decimal_point = 0;
- }
- }
- if((ph_out[0] != 0) && (ph_out[0] != phonSWITCH))
- {
- int next_char;
- char *p;
- p = &word[n_digits+1];
-
- p += utf8_in(&next_char,p);
- if((tr->langopts.numbers & NUM_NOPAUSE) && (next_char == ' '))
- utf8_in(&next_char,p);
-
- if(!iswalpha(next_char))
- strcat(ph_out,str_pause); // don't add pause for 100s, 6th, etc.
- }
-
- *flags |= FLAG_FOUND;
- prev_value = this_value;
- return(1);
-} // end of TranslateNumber_1
-
-
-
-int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, int wflags)
-{//============================================================================================
- if(option_sayas == SAYAS_DIGITS1)
- return(0); // speak digits individually
-
- if((tr->langopts.numbers & 0x3) == 1)
- return(TranslateNumber_1(tr, word1, ph_out, flags, wflags));
-
- return(0);
-} // end of TranslateNumber
-
diff --git a/navit/support/espeak/phoneme.h b/navit/support/espeak/phoneme.h
deleted file mode 100755
index 596f457ef..000000000
--- a/navit/support/espeak/phoneme.h
+++ /dev/null
@@ -1,168 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-
-
-// phoneme types
-#define phPAUSE 0
-#define phSTRESS 1
-#define phVOWEL 2
-#define phLIQUID 3
-#define phSTOP 4
-#define phVSTOP 5
-#define phFRICATIVE 6
-#define phVFRICATIVE 7
-#define phNASAL 8
-#define phVIRTUAL 9
-#define phDELETED 14
-#define phINVALID 15
-
-
-// phoneme properties
-// bits 16-19 give place of articulation (not currently used)
-#define phWAVE 0x01
-#define phUNSTRESSED 0x02
-#define phFORTIS 0x08
-#define phVOICED 0x10
-#define phSIBILANT 0x20
-#define phNOLINK 0x40
-#define phTRILL 0x80
-#define phVOWEL2 0x100 // liquid that is considered a vowel
-#define phPALATAL 0x200
-#define phAPPENDPH 0x2000 // always insert another phoneme (link_out) after this one
-#define phBRKAFTER 0x4000 // [*] add a post-pause
-#define phBEFOREPAUSE 0x8000 // replace with the link_out phoneme if the next phoneme is a pause
-
-#define phALTERNATIVE 0x1c00 // bits 10,11,12 specifying use of alternative_ph
-#define phBEFOREVOWEL 0x0000
-#define phBEFOREVOWELPAUSE 0x0400
-#define phBEFORENOTVOWEL 0x0c00
-#define phBEFORENOTVOWEL2 0x1000
-#define phSWITCHVOICING 0x0800
-#define phBEFORE_R 0x1400
-
-#define phNONSYLLABIC 0x100000 // don't count this vowel as a syllable when finding the stress position
-#define phLONG 0x200000
-#define phLENGTHENSTOP 0x400000 // make the pre-pause slightly longer
-#define phRHOTIC 0x800000
-
-// fixed phoneme code numbers, these can be used from the program code
-#define phonCONTROL 1
-#define phonSTRESS_U 2
-#define phonSTRESS_D 3
-#define phonSTRESS_2 4
-#define phonSTRESS_3 5
-#define phonSTRESS_P 6
-#define phonSTRESS_P2 7 // priority stress within a word
-#define phonSTRESS_PREV 8
-#define phonPAUSE 9
-#define phonPAUSE_SHORT 10
-#define phonPAUSE_NOLINK 11
-#define phonLENGTHEN 12
-#define phonSCHWA 13
-#define phonSCHWA_SHORT 14
-#define phonEND_WORD 15
-#define phonSONORANT 16
-#define phonDEFAULTTONE 17
-#define phonCAPITAL 18
-#define phonGLOTTALSTOP 19
-#define phonSYLLABIC 20
-#define phonSWITCH 21
-#define phonX1 22 // a language specific action
-#define phonPAUSE_VSHORT 23
-#define phonPAUSE_LONG 24
-#define phonT_REDUCED 25
-#define phonSTRESS_TONIC 26
-#define phonPAUSE_CLAUSE 27
-
-extern const unsigned char pause_phonemes[8]; // 0, vshort, short, pause, long, glottalstop
-
-// place of articulation
-#define phPLACE 0xf0000
-#define phPLACE_pla 0x60000
-
-#define N_PHONEME_TABS 100 // number of phoneme tables
-#define N_PHONEME_TAB 256 // max phonemes in a phoneme table
-#define N_PHONEME_TAB_NAME 32 // must be multiple of 4
-
-// main table of phonemes, index by phoneme number (1-254)
-typedef struct {
- unsigned int mnemonic; // 1st char is in the l.s.byte
- unsigned int phflags; // bits 28-30 reduce_to level, bits 16-19 place of articulation
- // bits 10-11 alternative ph control
-
- unsigned short std_length; // for vowels, in mS; for phSTRESS, the stress/tone type
- unsigned short spect;
- unsigned short before;
- unsigned short after;
-
- unsigned char code; // the phoneme number
- unsigned char type; // phVOWEL, phPAUSE, phSTOP etc
- unsigned char start_type;
- unsigned char end_type;
-
- unsigned char length_mod; // a length_mod group number, used to access length_mod_tab
- unsigned char reduce_to; // change to this phoneme if unstressed
- unsigned char alternative_ph; // change to this phoneme if a vowel follows/doesn't follow
- unsigned char link_out; // insert linking phoneme if a vowel follows
-
-} PHONEME_TAB;
-
-
-// Several phoneme tables may be loaded into memory. phoneme_tab points to
-// one for the current voice
-extern int n_phoneme_tab;
-extern int current_phoneme_table;
-extern PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];
-extern unsigned char phoneme_tab_flags[N_PHONEME_TAB]; // bit 0: not inherited
-
-typedef struct {
- char name[N_PHONEME_TAB_NAME];
- PHONEME_TAB *phoneme_tab_ptr;
- int n_phonemes;
- int includes; // also include the phonemes from this other phoneme table
-} PHONEME_TAB_LIST;
-
-
-
-// table of phonemes to be replaced with different phonemes, for the current voice
-#define N_REPLACE_PHONEMES 60
-typedef struct {
- unsigned char old_ph;
- unsigned char new_ph;
- char type; // 0=always replace, 1=only at end of word
-} REPLACE_PHONEMES;
-
-extern int n_replace_phonemes;
-extern REPLACE_PHONEMES replace_phonemes[N_REPLACE_PHONEMES];
-
-
-#define PH(c1,c2) (c2<<8)+c1 // combine two characters into an integer for phoneme name
-#define PH3(c1,c2,c3) (c3<<16)+(c2<<8)+c1
-#define PhonemeCode2(c1,c2) PhonemeCode((c2<<8)+c1)
-int LookupPhonemeString(const char *string);
-int PhonemeCode(unsigned int mnem);
-
-char *EncodePhonemes(char *p, char *outptr, unsigned char *bad_phoneme);
-void DecodePhonemes(const char *inptr, char *outptr);
-
-extern const char *WordToString(unsigned int word);
-
-extern PHONEME_TAB_LIST phoneme_tab_list[N_PHONEME_TABS];
-extern int phoneme_tab_number;
diff --git a/navit/support/espeak/phonemelist.c b/navit/support/espeak/phonemelist.c
deleted file mode 100755
index d663e2e94..000000000
--- a/navit/support/espeak/phonemelist.c
+++ /dev/null
@@ -1,686 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "translate.h"
-
-
-const unsigned char pause_phonemes[8] = {0, phonPAUSE_VSHORT, phonPAUSE_SHORT, phonPAUSE, phonPAUSE_LONG, phonGLOTTALSTOP, phonPAUSE_LONG, phonPAUSE_LONG};
-
-
-extern int n_ph_list2;
-extern PHONEME_LIST2 ph_list2[N_PHONEME_LIST]; // first stage of text->phonemes
-
-
-
-static int ChangePhonemes(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
-{//=================================================================================================================
-// Called for each phoneme in the phoneme list, to allow a language to make changes
-// ph The current phoneme
-
- if(tr->translator_name == L('r','u'))
- return(ChangePhonemes_ru(tr, phlist, n_ph, index, ph, ch));
-
- return(0);
-}
-
-
-static int SubstitutePhonemes(Translator *tr, PHONEME_LIST2 *plist_out)
-{//====================================================================
-// Copy the phonemes list and perform any substitutions that are required for the
-// current voice
- int ix;
- int k;
- int replace_flags;
- int n_plist_out = 0;
- int word_end;
- int max_stress = -1;
- int switched_language = 0;
- int max_stress_posn=0;
- int n_syllables = 0;
- int syllable = 0;
- int syllable_stressed = 0;
- PHONEME_LIST2 *plist2;
- PHONEME_LIST2 *pl;
- PHONEME_TAB *next=NULL;
-
- for(ix=0; (ix < n_ph_list2) && (n_plist_out < N_PHONEME_LIST); ix++)
- {
- plist2 = &ph_list2[ix];
-
- if(plist2->phcode == phonSWITCH)
- switched_language ^= 1;
-
- // don't do any substitution if the language has been temporarily changed
- if(switched_language == 0)
- {
- if(ix < (n_ph_list2 -1))
- next = phoneme_tab[ph_list2[ix+1].phcode];
-
- word_end = 0;
- if((plist2+1)->sourceix || ((next != 0) && (next->type == phPAUSE)))
- word_end = 1; // this phoneme is the end of a word
-
- if(tr->langopts.phoneme_change != 0)
- {
- // this language does changes to phonemes after translation
- int flags;
- CHANGEPH ch;
- if(plist2->sourceix)
- {
- // start of a word, find the stressed vowel
- syllable = 0;
- syllable_stressed = 0;
- n_syllables = 0;
-
- max_stress = -1;
- max_stress_posn = ix;
- for(k=ix; k < n_ph_list2; k++)
- {
- if(((pl = &ph_list2[k])->sourceix != 0) && (k > ix))
- break;
-
- pl->stress &= 0xf;
-
- if(phoneme_tab[pl->phcode]->type == phVOWEL)
- {
- n_syllables++;
-
- if(pl->stress > max_stress)
- {
- syllable_stressed = n_syllables;
- max_stress = pl->stress;
- max_stress_posn = k;
- }
- }
- }
- }
-
- if(phoneme_tab[plist2->phcode]->type == phVOWEL)
- {
- syllable++;
- }
-
- // make any language specific changes
- flags = 0;
- if(ix == max_stress_posn)
- flags |= 2;
- if(ix > max_stress_posn)
- flags |= 4;
- if(ph_list2[ix].synthflags & SFLAG_DICTIONARY)
- flags |= 8;
- ch.flags = flags | word_end;
-
- ch.stress = plist2->stress;
- ch.stress_highest = max_stress;
- ch.n_vowels = n_syllables;
- ch.vowel_this = syllable;
- ch.vowel_stressed = syllable_stressed;
-
- ChangePhonemes(tr, ph_list2, n_ph_list2, ix, phoneme_tab[ph_list2[ix].phcode], &ch);
- }
-
- // check whether a Voice has specified that we should replace this phoneme
- for(k=0; k<n_replace_phonemes; k++)
- {
- if(plist2->phcode == replace_phonemes[k].old_ph)
- {
- replace_flags = replace_phonemes[k].type;
-
- if((replace_flags & 1) && (word_end == 0))
- continue; // this replacement only occurs at the end of a word
-
- if((replace_flags & 2) && ((plist2->stress & 0x7) > 3))
- continue; // this replacement doesn't occur in stressed syllables
-
- // substitute the replacement phoneme
- plist2->phcode = replace_phonemes[k].new_ph;
- if((plist2->stress > 1) && (phoneme_tab[plist2->phcode]->phflags & phUNSTRESSED))
- plist2->stress = 0; // the replacement must be unstressed
- break;
- }
- }
-
- if(plist2->phcode == 0)
- {
- continue; // phoneme has been replaced by NULL, so don't copy it
- }
- }
-
- // copy phoneme into the output list
- memcpy(&plist_out[n_plist_out++],plist2,sizeof(PHONEME_LIST2));
- }
- return(n_plist_out);
-} // end of SubstitutePhonemes
-
-
-
-void MakePhonemeList(Translator *tr, int post_pause, int start_sentence)
-{//=====================================================================
-
- int ix=0;
- int j;
- int insert_ph = 0;
- PHONEME_LIST *phlist;
- PHONEME_TAB *ph;
- PHONEME_TAB *prev, *next, *next2;
- int unstress_count = 0;
- int word_stress = 0;
- int switched_language = 0;
- int max_stress;
- int voicing;
- int regression;
- int end_sourceix;
- int alternative;
- int first_vowel=0; // first vowel in a word
- PHONEME_LIST2 ph_list3[N_PHONEME_LIST];
-
- static PHONEME_LIST2 ph_list2_null = {0,0,0,0,0};
- PHONEME_LIST2 *plist2 = &ph_list2_null;
- PHONEME_LIST2 *plist2_inserted = NULL;
-
- plist2 = ph_list2;
- phlist = phoneme_list;
- end_sourceix = plist2[n_ph_list2-1].sourceix;
-
- // is the last word of the clause unstressed ?
- max_stress = 0;
- for(j = n_ph_list2-3; j>=0; j--)
- {
- // start with the last phoneme (before the terminating pauses) and move forwards
- if((plist2[j].stress & 0x7f) > max_stress)
- max_stress = plist2[j].stress & 0x7f;
- if(plist2[j].sourceix != 0)
- break;
- }
- if(max_stress < 4)
- {
- // the last word is unstressed, look for a previous word that can be stressed
- while(--j >= 0)
- {
- if(plist2[j].synthflags & SFLAG_PROMOTE_STRESS) // dictionary flags indicated that this stress can be promoted
- {
- plist2[j].stress = 4; // promote to stressed
- break;
- }
- if(plist2[j].stress >= 4)
- {
- // found a stressed syllable, so stop looking
- break;
- }
- }
- }
-
- if((regression = tr->langopts.param[LOPT_REGRESSIVE_VOICING]) != 0)
- {
- // set consonant clusters to all voiced or all unvoiced
- // Regressive
- int type;
- voicing = 0;
-
- for(j=n_ph_list2-1; j>=0; j--)
- {
- ph = phoneme_tab[plist2[j].phcode];
- if(ph == NULL)
- continue;
-
- if(ph->code == phonSWITCH)
- switched_language ^= 1;
- if(switched_language)
- continue;
-
- type = ph->type;
-
- if(regression & 0x2)
- {
- // LANG=Russian, [v] amd [v;] don't cause regression, or [R^]
- if((ph->mnemonic == 'v') || (ph->mnemonic == ((';'<<8)+'v')) || ((ph->mnemonic & 0xff)== 'R'))
- type = phLIQUID;
- }
-
- if((type==phSTOP) || type==(phFRICATIVE))
- {
- if(voicing==0)
- {
- voicing = 1;
- }
- else
- if((voicing==2) && ((ph->phflags & phALTERNATIVE)==phSWITCHVOICING))
- {
- plist2[j].phcode = ph->alternative_ph; // change to voiced equivalent
- }
- }
- else
- if((type==phVSTOP) || type==(phVFRICATIVE))
- {
- if(voicing==0)
- {
- voicing = 2;
- }
- else
- if((voicing==1) && ((ph->phflags & phALTERNATIVE)==phSWITCHVOICING))
- {
- plist2[j].phcode = ph->alternative_ph; // change to unvoiced equivalent
- }
- }
- else
- {
- if(regression & 0x8)
- {
- // LANG=Polish, propagate through liquids and nasals
- if((type == phPAUSE) || (type == phVOWEL))
- voicing = 0;
- }
- else
- {
- voicing = 0;
- }
- }
- if((regression & 0x4) && (plist2[j].sourceix))
- {
- // stop propagation at a word boundary
- voicing = 0;
- }
- }
- }
-
- n_ph_list2 = SubstitutePhonemes(tr,ph_list3) - 2;
-
- // transfer all the phonemes of the clause into phoneme_list
- ph = phoneme_tab[phonPAUSE];
- switched_language = 0;
-
- for(j=0; insert_ph || ((j < n_ph_list2) && (ix < N_PHONEME_LIST-3)); j++)
- {
- prev = ph;
-
- plist2 = &ph_list3[j];
-
- if(insert_ph != 0)
- {
- // we have a (linking) phoneme which we need to insert here
- next = phoneme_tab[plist2->phcode]; // this phoneme, i.e. after the insert
-
- // re-use the previous entry for the inserted phoneme.
- // That's OK because we don't look backwards from plist2
- j--;
- plist2 = plist2_inserted = &ph_list3[j];
- memset(plist2, 0, sizeof(*plist2));
- plist2->phcode = insert_ph;
- ph = phoneme_tab[insert_ph];
- insert_ph = 0;
- }
- else
- {
- // otherwise get the next phoneme from the list
- ph = phoneme_tab[plist2->phcode];
-
- if(plist2->phcode == phonSWITCH)
- {
- // change phoneme table
- SelectPhonemeTable(plist2->tone_number);
- switched_language ^= SFLAG_SWITCHED_LANG;
- }
- next = phoneme_tab[(plist2+1)->phcode]; // the phoneme after this one
- }
-
- if(plist2->sourceix)
- {
- // start of a word
- int k;
- word_stress = 0;
- first_vowel = 1;
-
- // find the highest stress level in this word
- for(k=j+1; k < n_ph_list2; k++)
- {
- if(ph_list3[k].sourceix)
- break; // start of the next word
-
- if(ph_list3[k].stress > word_stress)
- word_stress = ph_list3[k].stress;
- }
- }
-
- if(ph == NULL) continue;
-
- if(ph->type == phVOWEL)
- {
- // check for consecutive unstressed syllables
- if(plist2->stress == 0)
- {
- // an unstressed vowel
- unstress_count++;
- if((unstress_count > 1) && ((unstress_count & 1)==0))
- {
- // in a sequence of unstressed syllables, reduce alternate syllables to 'diminished'
- // stress. But not for the last phoneme of a stressed word
- if((tr->langopts.stress_flags & 0x2) || ((word_stress > 3) && ((plist2+1)->sourceix!=0)))
- {
- // An unstressed final vowel of a stressed word
- unstress_count=1; // try again for next syllable
- }
- else
- {
- plist2->stress = 1; // change stress to 'diminished'
- }
- }
- }
- else
- {
- unstress_count = 0;
- }
- }
-
- alternative = 0;
-
- if(ph->alternative_ph > 0)
- {
- switch(ph->phflags & phALTERNATIVE)
- {
- // This phoneme changes if vowel follows, or doesn't follow, depending on its phNOTFOLLOWS flag
- case phBEFORENOTVOWEL:
- if(next->type != phVOWEL)
- alternative = ph->alternative_ph;
- break;
-
- case phBEFORENOTVOWEL2: // LANG=tr
- if(((plist2+1)->sourceix != 0) ||
- ((next->type != phVOWEL) && ((phoneme_tab[(plist2+2)->phcode]->type != phVOWEL) || ((plist2+2)->sourceix != 0))))
- {
- alternative = ph->alternative_ph;
- }
- break;
-
- case phBEFOREVOWELPAUSE:
- if((next->type == phVOWEL) || (next->type == phPAUSE))
- alternative = ph->alternative_ph;
- break;
-
- case phBEFOREVOWEL:
- if(next->type == phVOWEL)
- alternative = ph->alternative_ph;
- break;
-
- case phBEFORE_R:
- if(next->phflags & phRHOTIC)
- {
- alternative = ph->alternative_ph;
- }
- break;
- }
- }
- if(ph->phflags & phBEFOREPAUSE)
- {
- if(next->type == phPAUSE)
- alternative = ph->link_out; // replace with the link_out phoneme
- }
-
- if(alternative == 1)
- continue; // NULL phoneme, discard
-
- if(alternative > 1)
- {
- PHONEME_TAB *ph2;
- ph2 = ph;
- ph = phoneme_tab[alternative];
-
- if(ph->type == phVOWEL)
- {
- plist2->synthflags |= SFLAG_SYLLABLE;
- if(ph2->type != phVOWEL)
- plist2->stress = 0; // change from non-vowel to vowel, make sure it's unstressed
- }
- else
- plist2->synthflags &= ~SFLAG_SYLLABLE;
- }
-
- if(tr->langopts.param[LOPT_REDUCE_T])
- {
- if((ph->mnemonic == 't') && (plist2->sourceix == 0) && ((prev->type == phVOWEL) || (prev->mnemonic == 'n')))
- {
- if(((plist2+1)->sourceix == 0) && ((plist2+1)->stress < 3) && (next->type == phVOWEL))
- {
- ph = phoneme_tab[phonT_REDUCED];
- }
- }
- }
-
-
- while((ph->reduce_to != 0) && (!(plist2->synthflags & SFLAG_DICTIONARY) || (tr->langopts.param[LOPT_REDUCE] & 1)))
- {
- int reduce_level;
- int stress_level;
- int reduce = 0;
-
- reduce_level = (ph->phflags >> 28) & 7;
-
- if(ph->type == phVOWEL)
- {
- stress_level = plist2->stress;
- }
- else
- {
- // consonant, get stress from the following vowel
- if(next->type == phVOWEL)
- stress_level = (plist2+1)->stress;
- else
- break;
- }
-
- if((stress_level == 1) && (first_vowel))
- stress_level = 0; // ignore 'dimished' stress on first syllable
-
- if(stress_level == 1)
- reduce = 1; // stress = 'reduced'
-
- if(stress_level < reduce_level)
- reduce =1;
-
- if((word_stress < 4) && (tr->langopts.param[LOPT_REDUCE] & 0x2) && (stress_level >= word_stress))
- {
- // don't reduce the most stressed syllable in an unstressed word
- reduce = 0;
- }
-
- if(reduce)
- ph = phoneme_tab[ph->reduce_to];
- else
- break;
- }
-
- if(ph->type == phVOWEL)
- first_vowel = 0;
-
- if((plist2+1)->synthflags & SFLAG_LENGTHEN)
- {
- static char types_double[] = {phFRICATIVE,phVFRICATIVE,phNASAL,phLIQUID,0};
- if(strchr(types_double,next->type))
- {
- // lengthen this consonant by doubling it
- insert_ph = next->code;
- (plist2+1)->synthflags ^= SFLAG_LENGTHEN;
- }
- }
-
- if((plist2+1)->sourceix != 0)
- {
- int x;
-
- if(tr->langopts.vowel_pause && (ph->type != phPAUSE))
- {
-
- if((ph->type != phVOWEL) && (tr->langopts.vowel_pause & 0x200))
- {
- // add a pause after a word which ends in a consonant
- insert_ph = phonPAUSE_NOLINK;
- }
-
- if(next->type == phVOWEL)
- {
- if((x = tr->langopts.vowel_pause & 0x0c) != 0)
- {
- // break before a word which starts with a vowel
- if(x == 0xc)
- insert_ph = phonPAUSE_NOLINK;
- else
- insert_ph = phonPAUSE_VSHORT;
- }
-
- if((ph->type == phVOWEL) && ((x = tr->langopts.vowel_pause & 0x03) != 0))
- {
- // adjacent vowels over a word boundary
- if(x == 2)
- insert_ph = phonPAUSE_SHORT;
- else
- insert_ph = phonPAUSE_VSHORT;
- }
-
- if(((plist2+1)->stress >= 4) && (tr->langopts.vowel_pause & 0x100))
- {
- // pause before a words which starts with a stressed vowel
- insert_ph = phonPAUSE_SHORT;
- }
- }
- }
-
- if(plist2 != plist2_inserted)
- {
- if((x = (tr->langopts.word_gap & 0x7)) != 0)
- {
- if((x > 1) || ((insert_ph != phonPAUSE_SHORT) && (insert_ph != phonPAUSE_NOLINK)))
- {
- // don't reduce the pause
- insert_ph = pause_phonemes[x];
- }
- }
- if(option_wordgap > 0)
- {
- insert_ph = phonPAUSE_LONG;
- }
- }
- }
-
- next2 = phoneme_tab[(plist2+2)->phcode];
-
- if((insert_ph == 0) && (ph->link_out != 0) && !(ph->phflags & phBEFOREPAUSE) && (((plist2+1)->synthflags & SFLAG_EMBEDDED)==0))
- {
- if(ph->phflags & phAPPENDPH)
- {
- // always append the specified phoneme, unless it already is the next phoneme
- if((ph->link_out != (plist2+1)->phcode) && (next->type == phVOWEL))
-// if(ph->link_out != (plist2+1)->phcode)
- {
- insert_ph = ph->link_out;
- }
- }
- else
- if(((tr->langopts.word_gap & 8)==0) || ((plist2+1)->sourceix == 0))
- {
- // This phoneme can be linked to a following vowel by inserting a linking phoneme
- if(next->type == phVOWEL)
- insert_ph = ph->link_out;
- else
- if(next->code == phonPAUSE_SHORT)
- {
- // Pause followed by Vowel, replace the Short Pause with the linking phoneme,
- if(next2->type == phVOWEL)
- (plist2+1)->phcode = ph->link_out; // replace pause by linking phoneme
- }
- }
- }
-
- if(ph->phflags & phVOICED)
- {
- // check that a voiced consonant is preceded or followed by a vowel or liquid
- // and if not, add a short schwa
-
- // not yet implemented
- }
-
- phlist[ix].ph = ph;
- phlist[ix].type = ph->type;
- phlist[ix].env = PITCHfall; // default, can be changed in the "intonation" module
- phlist[ix].synthflags = plist2->synthflags | switched_language;
- phlist[ix].stresslevel = plist2->stress & 0xf;
- phlist[ix].tone_ph = plist2->tone_number;
- phlist[ix].sourceix = 0;
-
- if(plist2->sourceix != 0)
- {
- phlist[ix].sourceix = plist2->sourceix;
- phlist[ix].newword = 1; // this phoneme is the start of a word
-
- if(start_sentence)
- {
- phlist[ix].newword = 5; // start of sentence + start of word
- start_sentence = 0;
- }
- }
- else
- {
- phlist[ix].newword = 0;
- }
-
- phlist[ix].length = ph->std_length;
- if((ph->code == phonPAUSE_LONG) && (option_wordgap > 0))
- {
- phlist[ix].ph = phoneme_tab[phonPAUSE_SHORT];
- phlist[ix].length = option_wordgap*14; // 10mS per unit at the default speed
- }
-
- if(ph->type==phVOWEL || ph->type==phLIQUID || ph->type==phNASAL || ph->type==phVSTOP || ph->type==phVFRICATIVE)
- {
- phlist[ix].length = 128; // length_mod
- phlist[ix].env = PITCHfall;
- }
-
- phlist[ix].prepause = 0;
- phlist[ix].amp = 20; // default, will be changed later
- phlist[ix].pitch1 = 0x400;
- phlist[ix].pitch2 = 0x400;
- ix++;
- }
- phlist[ix].newword = 2; // end of clause
-
- phlist[ix].type = phPAUSE; // terminate with 2 Pause phonemes
- phlist[ix].length = post_pause; // length of the pause, depends on the punctuation
- phlist[ix].sourceix = end_sourceix;
- phlist[ix].synthflags = 0;
-
- phlist[ix++].ph = phoneme_tab[phonPAUSE];
- phlist[ix].type = phPAUSE;
- phlist[ix].length = 0;
- phlist[ix].sourceix=0;
- phlist[ix].synthflags = 0;
- phlist[ix++].ph = phoneme_tab[phonPAUSE_SHORT];
-
- n_phoneme_list = ix;
-} // end of MakePhonemeList
-
-
diff --git a/navit/support/espeak/portaudio.h b/navit/support/espeak/portaudio.h
deleted file mode 100755
index 2ab8e02a4..000000000
--- a/navit/support/espeak/portaudio.h
+++ /dev/null
@@ -1,466 +0,0 @@
-// NOTE: Copy this file to portaudio.h in order to compile with V18 portaudio
-
-
-#ifndef PORT_AUDIO_H
-#define PORT_AUDIO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-/*
- * $Id: portaudio.h,v 1.5 2002/03/26 18:04:22 philburk Exp $
- * PortAudio Portable Real-Time Audio Library
- * PortAudio API Header File
- * Latest version available at: http://www.audiomulch.com/portaudio/
- *
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * Any person wishing to distribute modifications to the Software is
- * requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-typedef int PaError;
-typedef enum {
- paNoError = 0,
-
- paHostError = -10000,
- paInvalidChannelCount,
- paInvalidSampleRate,
- paInvalidDeviceId,
- paInvalidFlag,
- paSampleFormatNotSupported,
- paBadIODeviceCombination,
- paInsufficientMemory,
- paBufferTooBig,
- paBufferTooSmall,
- paNullCallback,
- paBadStreamPtr,
- paTimedOut,
- paInternalError,
- paDeviceUnavailable
-} PaErrorNum;
-
-/*
- Pa_Initialize() is the library initialisation function - call this before
- using the library.
-
-*/
-
-PaError Pa_Initialize( void );
-
-/*
- Pa_Terminate() is the library termination function - call this after
- using the library.
-
-*/
-
-PaError Pa_Terminate( void );
-
-/*
- Pa_GetHostError() returns a host specific error code.
- This can be called after receiving a PortAudio error code of paHostError.
-
-*/
-
-long Pa_GetHostError( void );
-
-/*
- Pa_GetErrorText() translates the supplied PortAudio error number
- into a human readable message.
-
-*/
-
-const char *Pa_GetErrorText( PaError errnum );
-
-/*
- Sample formats
-
- These are formats used to pass sound data between the callback and the
- stream. Each device has a "native" format which may be used when optimum
- efficiency or control over conversion is required.
-
- Formats marked "always available" are supported (emulated) by all
- PortAudio implementations.
-
- The floating point representation (paFloat32) uses +1.0 and -1.0 as the
- maximum and minimum respectively.
-
- paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
-
-*/
-
-typedef unsigned long PaSampleFormat;
-#define paFloat32 ((PaSampleFormat) (1<<0)) /*always available*/
-#define paInt16 ((PaSampleFormat) (1<<1)) /*always available*/
-#define paInt32 ((PaSampleFormat) (1<<2)) /*always available*/
-#define paInt24 ((PaSampleFormat) (1<<3))
-#define paPackedInt24 ((PaSampleFormat) (1<<4))
-#define paInt8 ((PaSampleFormat) (1<<5))
-#define paUInt8 ((PaSampleFormat) (1<<6))
-#define paCustomFormat ((PaSampleFormat) (1<<16))
-
-/*
- Device enumeration mechanism.
-
- Device ids range from 0 to Pa_CountDevices()-1.
-
- Devices may support input, output or both.
-
-*/
-
-typedef int PaDeviceID;
-#define paNoDevice -1
-
-int Pa_CountDevices( void );
-
-typedef struct
-{
- int structVersion;
- const char *name;
- int maxInputChannels;
- int maxOutputChannels;
- /* Number of discrete rates, or -1 if range supported. */
- int numSampleRates;
- /* Array of supported sample rates, or {min,max} if range supported. */
- const double *sampleRates;
- PaSampleFormat nativeSampleFormats;
-}
-PaDeviceInfo;
-
-/*
- Pa_GetDefaultInputDeviceID(), Pa_GetDefaultOutputDeviceID() return the
- default device ids for input and output respectively, or paNoDevice if
- no device is available.
- The result can be passed to Pa_OpenStream().
-
- On the PC, the user can specify a default device by
- setting an environment variable. For example, to use device #1.
-
- set PA_RECOMMENDED_OUTPUT_DEVICE=1
-
- The user should first determine the available device ids by using
- the supplied application "pa_devs".
-
-*/
-
-PaDeviceID Pa_GetDefaultInputDeviceID( void );
-PaDeviceID Pa_GetDefaultOutputDeviceID( void );
-
-
-
-/*
- Pa_GetDeviceInfo() returns a pointer to an immutable PaDeviceInfo structure
- for the device specified.
- If the device parameter is out of range the function returns NULL.
-
- PortAudio manages the memory referenced by the returned pointer, the client
- must not manipulate or free the memory. The pointer is only guaranteed to be
- valid between calls to Pa_Initialize() and Pa_Terminate().
-
-*/
-
-const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceID device );
-
-/*
- PaTimestamp is used to represent a continuous sample clock with arbitrary
- start time that can be used for syncronization. The type is used for the
- outTime argument to the PortAudioCallback and as the result of Pa_StreamTime()
-
-*/
-
-typedef double PaTimestamp;
-
-/*
- PortAudioCallback is implemented by PortAudio clients.
-
- inputBuffer and outputBuffer are arrays of interleaved samples,
- the format, packing and number of channels used by the buffers are
- determined by parameters to Pa_OpenStream() (see below).
-
- framesPerBuffer is the number of sample frames to be processed by the callback.
-
- outTime is the time in samples when the buffer(s) processed by
- this callback will begin being played at the audio output.
- See also Pa_StreamTime()
-
- userData is the value of a user supplied pointer passed to Pa_OpenStream()
- intended for storing synthesis data etc.
-
- return value:
- The callback can return a non-zero value to stop the stream. This may be
- useful in applications such as soundfile players where a specific duration
- of output is required. However, it is not necessary to utilise this mechanism
- as StopStream() will also terminate the stream. A callback returning a
- non-zero value must fill the entire outputBuffer.
-
- NOTE: None of the other stream functions may be called from within the
- callback function except for Pa_GetCPULoad().
-
-*/
-
-typedef int (PortAudioCallback)(
- void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData );
-
-
-/*
- Stream flags
-
- These flags may be supplied (ored together) in the streamFlags argument to
- the Pa_OpenStream() function.
-
-*/
-
-#define paNoFlag (0)
-#define paClipOff (1<<0) /* disable default clipping of out of range samples */
-#define paDitherOff (1<<1) /* disable default dithering */
-#define paPlatformSpecificFlags (0x00010000)
-typedef unsigned long PaStreamFlags;
-
-/*
- A single PortAudioStream provides multiple channels of real-time
- input and output audio streaming to a client application.
- Pointers to PortAudioStream objects are passed between PortAudio functions.
-*/
-
-typedef void PortAudioStream;
-#define PaStream PortAudioStream
-
-/*
- Pa_OpenStream() opens a stream for either input, output or both.
-
- stream is the address of a PortAudioStream pointer which will receive
- a pointer to the newly opened stream.
-
- inputDevice is the id of the device used for input (see PaDeviceID above.)
- inputDevice may be paNoDevice to indicate that an input device is not required.
-
- numInputChannels is the number of channels of sound to be delivered to the
- callback. It can range from 1 to the value of maxInputChannels in the
- PaDeviceInfo record for the device specified by the inputDevice parameter.
- If inputDevice is paNoDevice numInputChannels is ignored.
-
- inputSampleFormat is the sample format of inputBuffer provided to the callback
- function. inputSampleFormat may be any of the formats described by the
- PaSampleFormat enumeration (see above). PortAudio guarantees support for
- the device's native formats (nativeSampleFormats in the device info record)
- and additionally 16 and 32 bit integer and 32 bit floating point formats.
- Support for other formats is implementation defined.
-
- inputDriverInfo is a pointer to an optional driver specific data structure
- containing additional information for device setup or stream processing.
- inputDriverInfo is never required for correct operation. If not used
- inputDriverInfo should be NULL.
-
- outputDevice is the id of the device used for output (see PaDeviceID above.)
- outputDevice may be paNoDevice to indicate that an output device is not required.
-
- numOutputChannels is the number of channels of sound to be supplied by the
- callback. See the definition of numInputChannels above for more details.
-
- outputSampleFormat is the sample format of the outputBuffer filled by the
- callback function. See the definition of inputSampleFormat above for more
- details.
-
- outputDriverInfo is a pointer to an optional driver specific data structure
- containing additional information for device setup or stream processing.
- outputDriverInfo is never required for correct operation. If not used
- outputDriverInfo should be NULL.
-
- sampleRate is the desired sampleRate. For full-duplex streams it is the
- sample rate for both input and output
-
- framesPerBuffer is the length in sample frames of all internal sample buffers
- used for communication with platform specific audio routines. Wherever
- possible this corresponds to the framesPerBuffer parameter passed to the
- callback function.
-
- numberOfBuffers is the number of buffers used for multibuffered communication
- with the platform specific audio routines. If you pass zero, then an optimum
- value will be chosen for you internally. This parameter is provided only
- as a guide - and does not imply that an implementation must use multibuffered
- i/o when reliable double buffering is available (such as SndPlayDoubleBuffer()
- on the Macintosh.)
-
- streamFlags may contain a combination of flags ORed together.
- These flags modify the behaviour of the streaming process. Some flags may only
- be relevant to certain buffer formats.
-
- callback is a pointer to a client supplied function that is responsible
- for processing and filling input and output buffers (see above for details.)
-
- userData is a client supplied pointer which is passed to the callback
- function. It could for example, contain a pointer to instance data necessary
- for processing the audio buffers.
-
- return value:
- Upon success Pa_OpenStream() returns PaNoError and places a pointer to a
- valid PortAudioStream in the stream argument. The stream is inactive (stopped).
- If a call to Pa_OpenStream() fails a non-zero error code is returned (see
- PaError above) and the value of stream is invalid.
-
-*/
-
-PaError Pa_OpenStream( PortAudioStream** stream,
- PaDeviceID inputDevice,
- int numInputChannels,
- PaSampleFormat inputSampleFormat,
- void *inputDriverInfo,
- PaDeviceID outputDevice,
- int numOutputChannels,
- PaSampleFormat outputSampleFormat,
- void *outputDriverInfo,
- double sampleRate,
- unsigned long framesPerBuffer,
- unsigned long numberOfBuffers,
- PaStreamFlags streamFlags,
- PortAudioCallback *callback,
- void *userData );
-
-
-/*
- Pa_OpenDefaultStream() is a simplified version of Pa_OpenStream() that opens
- the default input and/or output devices. Most parameters have identical meaning
- to their Pa_OpenStream() counterparts, with the following exceptions:
-
- If either numInputChannels or numOutputChannels is 0 the respective device
- is not opened. This has the same effect as passing paNoDevice in the device
- arguments to Pa_OpenStream().
-
- sampleFormat applies to both the input and output buffers.
-
-*/
-
-PaError Pa_OpenDefaultStream( PortAudioStream** stream,
- int numInputChannels,
- int numOutputChannels,
- PaSampleFormat sampleFormat,
- double sampleRate,
- unsigned long framesPerBuffer,
- unsigned long numberOfBuffers,
- PortAudioCallback *callback,
- void *userData );
-
-/*
- Pa_CloseStream() closes an audio stream, flushing any pending buffers.
-
-*/
-
-PaError Pa_CloseStream( PortAudioStream* );
-
-/*
- Pa_StartStream() and Pa_StopStream() begin and terminate audio processing.
- Pa_StopStream() waits until all pending audio buffers have been played.
- Pa_AbortStream() stops playing immediately without waiting for pending
- buffers to complete.
-
-*/
-
-PaError Pa_StartStream( PortAudioStream *stream );
-
-PaError Pa_StopStream( PortAudioStream *stream );
-
-PaError Pa_AbortStream( PortAudioStream *stream );
-
-/*
- Pa_StreamActive() returns one (1) when the stream is active (ie playing
- or recording audio), zero (0) when not playing, or a negative error number
- if the stream is invalid.
- The stream is active between calls to Pa_StartStream() and Pa_StopStream(),
- but may also become inactive if the callback returns a non-zero value.
- In the latter case, the stream is considered inactive after the last
- buffer has finished playing.
-
-*/
-
-PaError Pa_StreamActive( PortAudioStream *stream );
-
-/*
- Pa_StreamTime() returns the current output time in samples for the stream.
- This time may be used as a time reference (for example synchronizing audio to
- MIDI).
-
-*/
-
-PaTimestamp Pa_StreamTime( PortAudioStream *stream );
-
-/*
- Pa_GetCPULoad() returns the CPU Load for the stream.
- The "CPU Load" is a fraction of total CPU time consumed by the stream's
- audio processing routines including, but not limited to the client supplied
- callback.
- A value of 0.5 would imply that PortAudio and the sound generating
- callback was consuming roughly 50% of the available CPU time.
- This function may be called from the callback function or the application.
-
-*/
-
-double Pa_GetCPULoad( PortAudioStream* stream );
-
-/*
- Pa_GetMinNumBuffers() returns the minimum number of buffers required by
- the current host based on minimum latency.
- On the PC, for the DirectSound implementation, latency can be optionally set
- by user by setting an environment variable.
- For example, to set latency to 200 msec, put:
-
- set PA_MIN_LATENCY_MSEC=200
-
- in the AUTOEXEC.BAT file and reboot.
- If the environment variable is not set, then the latency will be determined
- based on the OS. Windows NT has higher latency than Win95.
-
-*/
-
-int Pa_GetMinNumBuffers( int framesPerBuffer, double sampleRate );
-
-/*
- Pa_Sleep() puts the caller to sleep for at least 'msec' milliseconds.
- You may sleep longer than the requested time so don't rely on this for
- accurate musical timing.
-
- Pa_Sleep() is provided as a convenience for authors of portable code (such as
- the tests and examples in the PortAudio distribution.)
-
-*/
-
-void Pa_Sleep( long msec );
-
-/*
- Pa_GetSampleSize() returns the size in bytes of a single sample in the
- supplied PaSampleFormat, or paSampleFormatNotSupported if the format is
- no supported.
-
-*/
-
-PaError Pa_GetSampleSize( PaSampleFormat format );
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* PORT_AUDIO_H */
diff --git a/navit/support/espeak/portaudio18.h b/navit/support/espeak/portaudio18.h
deleted file mode 100755
index 2ab8e02a4..000000000
--- a/navit/support/espeak/portaudio18.h
+++ /dev/null
@@ -1,466 +0,0 @@
-// NOTE: Copy this file to portaudio.h in order to compile with V18 portaudio
-
-
-#ifndef PORT_AUDIO_H
-#define PORT_AUDIO_H
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-/*
- * $Id: portaudio.h,v 1.5 2002/03/26 18:04:22 philburk Exp $
- * PortAudio Portable Real-Time Audio Library
- * PortAudio API Header File
- * Latest version available at: http://www.audiomulch.com/portaudio/
- *
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * Any person wishing to distribute modifications to the Software is
- * requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-typedef int PaError;
-typedef enum {
- paNoError = 0,
-
- paHostError = -10000,
- paInvalidChannelCount,
- paInvalidSampleRate,
- paInvalidDeviceId,
- paInvalidFlag,
- paSampleFormatNotSupported,
- paBadIODeviceCombination,
- paInsufficientMemory,
- paBufferTooBig,
- paBufferTooSmall,
- paNullCallback,
- paBadStreamPtr,
- paTimedOut,
- paInternalError,
- paDeviceUnavailable
-} PaErrorNum;
-
-/*
- Pa_Initialize() is the library initialisation function - call this before
- using the library.
-
-*/
-
-PaError Pa_Initialize( void );
-
-/*
- Pa_Terminate() is the library termination function - call this after
- using the library.
-
-*/
-
-PaError Pa_Terminate( void );
-
-/*
- Pa_GetHostError() returns a host specific error code.
- This can be called after receiving a PortAudio error code of paHostError.
-
-*/
-
-long Pa_GetHostError( void );
-
-/*
- Pa_GetErrorText() translates the supplied PortAudio error number
- into a human readable message.
-
-*/
-
-const char *Pa_GetErrorText( PaError errnum );
-
-/*
- Sample formats
-
- These are formats used to pass sound data between the callback and the
- stream. Each device has a "native" format which may be used when optimum
- efficiency or control over conversion is required.
-
- Formats marked "always available" are supported (emulated) by all
- PortAudio implementations.
-
- The floating point representation (paFloat32) uses +1.0 and -1.0 as the
- maximum and minimum respectively.
-
- paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
-
-*/
-
-typedef unsigned long PaSampleFormat;
-#define paFloat32 ((PaSampleFormat) (1<<0)) /*always available*/
-#define paInt16 ((PaSampleFormat) (1<<1)) /*always available*/
-#define paInt32 ((PaSampleFormat) (1<<2)) /*always available*/
-#define paInt24 ((PaSampleFormat) (1<<3))
-#define paPackedInt24 ((PaSampleFormat) (1<<4))
-#define paInt8 ((PaSampleFormat) (1<<5))
-#define paUInt8 ((PaSampleFormat) (1<<6))
-#define paCustomFormat ((PaSampleFormat) (1<<16))
-
-/*
- Device enumeration mechanism.
-
- Device ids range from 0 to Pa_CountDevices()-1.
-
- Devices may support input, output or both.
-
-*/
-
-typedef int PaDeviceID;
-#define paNoDevice -1
-
-int Pa_CountDevices( void );
-
-typedef struct
-{
- int structVersion;
- const char *name;
- int maxInputChannels;
- int maxOutputChannels;
- /* Number of discrete rates, or -1 if range supported. */
- int numSampleRates;
- /* Array of supported sample rates, or {min,max} if range supported. */
- const double *sampleRates;
- PaSampleFormat nativeSampleFormats;
-}
-PaDeviceInfo;
-
-/*
- Pa_GetDefaultInputDeviceID(), Pa_GetDefaultOutputDeviceID() return the
- default device ids for input and output respectively, or paNoDevice if
- no device is available.
- The result can be passed to Pa_OpenStream().
-
- On the PC, the user can specify a default device by
- setting an environment variable. For example, to use device #1.
-
- set PA_RECOMMENDED_OUTPUT_DEVICE=1
-
- The user should first determine the available device ids by using
- the supplied application "pa_devs".
-
-*/
-
-PaDeviceID Pa_GetDefaultInputDeviceID( void );
-PaDeviceID Pa_GetDefaultOutputDeviceID( void );
-
-
-
-/*
- Pa_GetDeviceInfo() returns a pointer to an immutable PaDeviceInfo structure
- for the device specified.
- If the device parameter is out of range the function returns NULL.
-
- PortAudio manages the memory referenced by the returned pointer, the client
- must not manipulate or free the memory. The pointer is only guaranteed to be
- valid between calls to Pa_Initialize() and Pa_Terminate().
-
-*/
-
-const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceID device );
-
-/*
- PaTimestamp is used to represent a continuous sample clock with arbitrary
- start time that can be used for syncronization. The type is used for the
- outTime argument to the PortAudioCallback and as the result of Pa_StreamTime()
-
-*/
-
-typedef double PaTimestamp;
-
-/*
- PortAudioCallback is implemented by PortAudio clients.
-
- inputBuffer and outputBuffer are arrays of interleaved samples,
- the format, packing and number of channels used by the buffers are
- determined by parameters to Pa_OpenStream() (see below).
-
- framesPerBuffer is the number of sample frames to be processed by the callback.
-
- outTime is the time in samples when the buffer(s) processed by
- this callback will begin being played at the audio output.
- See also Pa_StreamTime()
-
- userData is the value of a user supplied pointer passed to Pa_OpenStream()
- intended for storing synthesis data etc.
-
- return value:
- The callback can return a non-zero value to stop the stream. This may be
- useful in applications such as soundfile players where a specific duration
- of output is required. However, it is not necessary to utilise this mechanism
- as StopStream() will also terminate the stream. A callback returning a
- non-zero value must fill the entire outputBuffer.
-
- NOTE: None of the other stream functions may be called from within the
- callback function except for Pa_GetCPULoad().
-
-*/
-
-typedef int (PortAudioCallback)(
- void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData );
-
-
-/*
- Stream flags
-
- These flags may be supplied (ored together) in the streamFlags argument to
- the Pa_OpenStream() function.
-
-*/
-
-#define paNoFlag (0)
-#define paClipOff (1<<0) /* disable default clipping of out of range samples */
-#define paDitherOff (1<<1) /* disable default dithering */
-#define paPlatformSpecificFlags (0x00010000)
-typedef unsigned long PaStreamFlags;
-
-/*
- A single PortAudioStream provides multiple channels of real-time
- input and output audio streaming to a client application.
- Pointers to PortAudioStream objects are passed between PortAudio functions.
-*/
-
-typedef void PortAudioStream;
-#define PaStream PortAudioStream
-
-/*
- Pa_OpenStream() opens a stream for either input, output or both.
-
- stream is the address of a PortAudioStream pointer which will receive
- a pointer to the newly opened stream.
-
- inputDevice is the id of the device used for input (see PaDeviceID above.)
- inputDevice may be paNoDevice to indicate that an input device is not required.
-
- numInputChannels is the number of channels of sound to be delivered to the
- callback. It can range from 1 to the value of maxInputChannels in the
- PaDeviceInfo record for the device specified by the inputDevice parameter.
- If inputDevice is paNoDevice numInputChannels is ignored.
-
- inputSampleFormat is the sample format of inputBuffer provided to the callback
- function. inputSampleFormat may be any of the formats described by the
- PaSampleFormat enumeration (see above). PortAudio guarantees support for
- the device's native formats (nativeSampleFormats in the device info record)
- and additionally 16 and 32 bit integer and 32 bit floating point formats.
- Support for other formats is implementation defined.
-
- inputDriverInfo is a pointer to an optional driver specific data structure
- containing additional information for device setup or stream processing.
- inputDriverInfo is never required for correct operation. If not used
- inputDriverInfo should be NULL.
-
- outputDevice is the id of the device used for output (see PaDeviceID above.)
- outputDevice may be paNoDevice to indicate that an output device is not required.
-
- numOutputChannels is the number of channels of sound to be supplied by the
- callback. See the definition of numInputChannels above for more details.
-
- outputSampleFormat is the sample format of the outputBuffer filled by the
- callback function. See the definition of inputSampleFormat above for more
- details.
-
- outputDriverInfo is a pointer to an optional driver specific data structure
- containing additional information for device setup or stream processing.
- outputDriverInfo is never required for correct operation. If not used
- outputDriverInfo should be NULL.
-
- sampleRate is the desired sampleRate. For full-duplex streams it is the
- sample rate for both input and output
-
- framesPerBuffer is the length in sample frames of all internal sample buffers
- used for communication with platform specific audio routines. Wherever
- possible this corresponds to the framesPerBuffer parameter passed to the
- callback function.
-
- numberOfBuffers is the number of buffers used for multibuffered communication
- with the platform specific audio routines. If you pass zero, then an optimum
- value will be chosen for you internally. This parameter is provided only
- as a guide - and does not imply that an implementation must use multibuffered
- i/o when reliable double buffering is available (such as SndPlayDoubleBuffer()
- on the Macintosh.)
-
- streamFlags may contain a combination of flags ORed together.
- These flags modify the behaviour of the streaming process. Some flags may only
- be relevant to certain buffer formats.
-
- callback is a pointer to a client supplied function that is responsible
- for processing and filling input and output buffers (see above for details.)
-
- userData is a client supplied pointer which is passed to the callback
- function. It could for example, contain a pointer to instance data necessary
- for processing the audio buffers.
-
- return value:
- Upon success Pa_OpenStream() returns PaNoError and places a pointer to a
- valid PortAudioStream in the stream argument. The stream is inactive (stopped).
- If a call to Pa_OpenStream() fails a non-zero error code is returned (see
- PaError above) and the value of stream is invalid.
-
-*/
-
-PaError Pa_OpenStream( PortAudioStream** stream,
- PaDeviceID inputDevice,
- int numInputChannels,
- PaSampleFormat inputSampleFormat,
- void *inputDriverInfo,
- PaDeviceID outputDevice,
- int numOutputChannels,
- PaSampleFormat outputSampleFormat,
- void *outputDriverInfo,
- double sampleRate,
- unsigned long framesPerBuffer,
- unsigned long numberOfBuffers,
- PaStreamFlags streamFlags,
- PortAudioCallback *callback,
- void *userData );
-
-
-/*
- Pa_OpenDefaultStream() is a simplified version of Pa_OpenStream() that opens
- the default input and/or output devices. Most parameters have identical meaning
- to their Pa_OpenStream() counterparts, with the following exceptions:
-
- If either numInputChannels or numOutputChannels is 0 the respective device
- is not opened. This has the same effect as passing paNoDevice in the device
- arguments to Pa_OpenStream().
-
- sampleFormat applies to both the input and output buffers.
-
-*/
-
-PaError Pa_OpenDefaultStream( PortAudioStream** stream,
- int numInputChannels,
- int numOutputChannels,
- PaSampleFormat sampleFormat,
- double sampleRate,
- unsigned long framesPerBuffer,
- unsigned long numberOfBuffers,
- PortAudioCallback *callback,
- void *userData );
-
-/*
- Pa_CloseStream() closes an audio stream, flushing any pending buffers.
-
-*/
-
-PaError Pa_CloseStream( PortAudioStream* );
-
-/*
- Pa_StartStream() and Pa_StopStream() begin and terminate audio processing.
- Pa_StopStream() waits until all pending audio buffers have been played.
- Pa_AbortStream() stops playing immediately without waiting for pending
- buffers to complete.
-
-*/
-
-PaError Pa_StartStream( PortAudioStream *stream );
-
-PaError Pa_StopStream( PortAudioStream *stream );
-
-PaError Pa_AbortStream( PortAudioStream *stream );
-
-/*
- Pa_StreamActive() returns one (1) when the stream is active (ie playing
- or recording audio), zero (0) when not playing, or a negative error number
- if the stream is invalid.
- The stream is active between calls to Pa_StartStream() and Pa_StopStream(),
- but may also become inactive if the callback returns a non-zero value.
- In the latter case, the stream is considered inactive after the last
- buffer has finished playing.
-
-*/
-
-PaError Pa_StreamActive( PortAudioStream *stream );
-
-/*
- Pa_StreamTime() returns the current output time in samples for the stream.
- This time may be used as a time reference (for example synchronizing audio to
- MIDI).
-
-*/
-
-PaTimestamp Pa_StreamTime( PortAudioStream *stream );
-
-/*
- Pa_GetCPULoad() returns the CPU Load for the stream.
- The "CPU Load" is a fraction of total CPU time consumed by the stream's
- audio processing routines including, but not limited to the client supplied
- callback.
- A value of 0.5 would imply that PortAudio and the sound generating
- callback was consuming roughly 50% of the available CPU time.
- This function may be called from the callback function or the application.
-
-*/
-
-double Pa_GetCPULoad( PortAudioStream* stream );
-
-/*
- Pa_GetMinNumBuffers() returns the minimum number of buffers required by
- the current host based on minimum latency.
- On the PC, for the DirectSound implementation, latency can be optionally set
- by user by setting an environment variable.
- For example, to set latency to 200 msec, put:
-
- set PA_MIN_LATENCY_MSEC=200
-
- in the AUTOEXEC.BAT file and reboot.
- If the environment variable is not set, then the latency will be determined
- based on the OS. Windows NT has higher latency than Win95.
-
-*/
-
-int Pa_GetMinNumBuffers( int framesPerBuffer, double sampleRate );
-
-/*
- Pa_Sleep() puts the caller to sleep for at least 'msec' milliseconds.
- You may sleep longer than the requested time so don't rely on this for
- accurate musical timing.
-
- Pa_Sleep() is provided as a convenience for authors of portable code (such as
- the tests and examples in the PortAudio distribution.)
-
-*/
-
-void Pa_Sleep( long msec );
-
-/*
- Pa_GetSampleSize() returns the size in bytes of a single sample in the
- supplied PaSampleFormat, or paSampleFormatNotSupported if the format is
- no supported.
-
-*/
-
-PaError Pa_GetSampleSize( PaSampleFormat format );
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* PORT_AUDIO_H */
diff --git a/navit/support/espeak/portaudio19.h b/navit/support/espeak/portaudio19.h
deleted file mode 100644
index 5c060b711..000000000
--- a/navit/support/espeak/portaudio19.h
+++ /dev/null
@@ -1,1127 +0,0 @@
-// NOTE: Copy this file to portaudio.h in order to compile with V19 portaudio
-
-#ifndef PORTAUDIO_H
-#define PORTAUDIO_H
-/*
- * $Id: portaudio.h 1061 2006-06-19 22:46:41Z lschwardt $
- * PortAudio Portable Real-Time Audio Library
- * PortAudio API Header File
- * Latest version available at: http://www.portaudio.com/
- *
- * Copyright (c) 1999-2002 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * Any person wishing to distribute modifications to the Software is
- * requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-/** @file
- @brief The PortAudio API.
-*/
-
-
-#ifdef __cplusplus
-extern "C"
-{
-#endif /* __cplusplus */
-
-
-/** Retrieve the release number of the currently running PortAudio build,
- eg 1900.
-*/
-int Pa_GetVersion( void );
-
-
-/** Retrieve a textual description of the current PortAudio build,
- eg "PortAudio V19-devel 13 October 2002".
-*/
-const char* Pa_GetVersionText( void );
-
-
-/** Error codes returned by PortAudio functions.
- Note that with the exception of paNoError, all PaErrorCodes are negative.
-*/
-
-typedef int PaError;
-typedef enum PaErrorCode
-{
- paNoError = 0,
-
- paNotInitialized = -10000,
- paUnanticipatedHostError,
- paInvalidChannelCount,
- paInvalidSampleRate,
- paInvalidDevice,
- paInvalidFlag,
- paSampleFormatNotSupported,
- paBadIODeviceCombination,
- paInsufficientMemory,
- paBufferTooBig,
- paBufferTooSmall,
- paNullCallback,
- paBadStreamPtr,
- paTimedOut,
- paInternalError,
- paDeviceUnavailable,
- paIncompatibleHostApiSpecificStreamInfo,
- paStreamIsStopped,
- paStreamIsNotStopped,
- paInputOverflowed,
- paOutputUnderflowed,
- paHostApiNotFound,
- paInvalidHostApi,
- paCanNotReadFromACallbackStream, /**< @todo review error code name */
- paCanNotWriteToACallbackStream, /**< @todo review error code name */
- paCanNotReadFromAnOutputOnlyStream, /**< @todo review error code name */
- paCanNotWriteToAnInputOnlyStream, /**< @todo review error code name */
- paIncompatibleStreamHostApi,
- paBadBufferPtr
-} PaErrorCode;
-
-
-/** Translate the supplied PortAudio error code into a human readable
- message.
-*/
-const char *Pa_GetErrorText( PaError errorCode );
-
-
-/** Library initialization function - call this before using PortAudio.
- This function initialises internal data structures and prepares underlying
- host APIs for use. This function MUST be called before using any other
- PortAudio API functions.
-
- If Pa_Initialize() is called multiple times, each successful
- call must be matched with a corresponding call to Pa_Terminate().
- Pairs of calls to Pa_Initialize()/Pa_Terminate() may overlap, and are not
- required to be fully nested.
-
- Note that if Pa_Initialize() returns an error code, Pa_Terminate() should
- NOT be called.
-
- @return paNoError if successful, otherwise an error code indicating the cause
- of failure.
-
- @see Pa_Terminate
-*/
-PaError Pa_Initialize( void );
-
-
-/** Library termination function - call this when finished using PortAudio.
- This function deallocates all resources allocated by PortAudio since it was
- initializied by a call to Pa_Initialize(). In cases where Pa_Initialise() has
- been called multiple times, each call must be matched with a corresponding call
- to Pa_Terminate(). The final matching call to Pa_Terminate() will automatically
- close any PortAudio streams that are still open.
-
- Pa_Terminate() MUST be called before exiting a program which uses PortAudio.
- Failure to do so may result in serious resource leaks, such as audio devices
- not being available until the next reboot.
-
- @return paNoError if successful, otherwise an error code indicating the cause
- of failure.
-
- @see Pa_Initialize
-*/
-PaError Pa_Terminate( void );
-
-
-
-/** The type used to refer to audio devices. Values of this type usually
- range from 0 to (Pa_DeviceCount-1), and may also take on the PaNoDevice
- and paUseHostApiSpecificDeviceSpecification values.
-
- @see Pa_DeviceCount, paNoDevice, paUseHostApiSpecificDeviceSpecification
-*/
-typedef int PaDeviceIndex;
-
-
-/** A special PaDeviceIndex value indicating that no device is available,
- or should be used.
-
- @see PaDeviceIndex
-*/
-#define paNoDevice ((PaDeviceIndex)-1)
-
-
-/** A special PaDeviceIndex value indicating that the device(s) to be used
- are specified in the host api specific stream info structure.
-
- @see PaDeviceIndex
-*/
-#define paUseHostApiSpecificDeviceSpecification ((PaDeviceIndex)-2)
-
-
-/* Host API enumeration mechanism */
-
-/** The type used to enumerate to host APIs at runtime. Values of this type
- range from 0 to (Pa_GetHostApiCount()-1).
-
- @see Pa_GetHostApiCount
-*/
-typedef int PaHostApiIndex;
-
-
-/** Retrieve the number of available host APIs. Even if a host API is
- available it may have no devices available.
-
- @return A non-negative value indicating the number of available host APIs
- or, a PaErrorCode (which are always negative) if PortAudio is not initialized
- or an error is encountered.
-
- @see PaHostApiIndex
-*/
-PaHostApiIndex Pa_GetHostApiCount( void );
-
-
-/** Retrieve the index of the default host API. The default host API will be
- the lowest common denominator host API on the current platform and is
- unlikely to provide the best performance.
-
- @return A non-negative value ranging from 0 to (Pa_GetHostApiCount()-1)
- indicating the default host API index or, a PaErrorCode (which are always
- negative) if PortAudio is not initialized or an error is encountered.
-*/
-PaHostApiIndex Pa_GetDefaultHostApi( void );
-
-
-/** Unchanging unique identifiers for each supported host API. This type
- is used in the PaHostApiInfo structure. The values are guaranteed to be
- unique and to never change, thus allowing code to be written that
- conditionally uses host API specific extensions.
-
- New type ids will be allocated when support for a host API reaches
- "public alpha" status, prior to that developers should use the
- paInDevelopment type id.
-
- @see PaHostApiInfo
-*/
-typedef enum PaHostApiTypeId
-{
- paInDevelopment=0, /* use while developing support for a new host API */
- paDirectSound=1,
- paMME=2,
- paASIO=3,
- paSoundManager=4,
- paCoreAudio=5,
- paOSS=7,
- paALSA=8,
- paAL=9,
- paBeOS=10,
- paWDMKS=11,
- paJACK=12,
- paWASAPI=13,
- paAudioScienceHPI=14
-} PaHostApiTypeId;
-
-
-/** A structure containing information about a particular host API. */
-
-typedef struct PaHostApiInfo
-{
- /** this is struct version 1 */
- int structVersion;
- /** The well known unique identifier of this host API @see PaHostApiTypeId */
- PaHostApiTypeId type;
- /** A textual description of the host API for display on user interfaces. */
- const char *name;
-
- /** The number of devices belonging to this host API. This field may be
- used in conjunction with Pa_HostApiDeviceIndexToDeviceIndex() to enumerate
- all devices for this host API.
- @see Pa_HostApiDeviceIndexToDeviceIndex
- */
- int deviceCount;
-
- /** The default input device for this host API. The value will be a
- device index ranging from 0 to (Pa_GetDeviceCount()-1), or paNoDevice
- if no default input device is available.
- */
- PaDeviceIndex defaultInputDevice;
-
- /** The default output device for this host API. The value will be a
- device index ranging from 0 to (Pa_GetDeviceCount()-1), or paNoDevice
- if no default output device is available.
- */
- PaDeviceIndex defaultOutputDevice;
-
-} PaHostApiInfo;
-
-
-/** Retrieve a pointer to a structure containing information about a specific
- host Api.
-
- @param hostApi A valid host API index ranging from 0 to (Pa_GetHostApiCount()-1)
-
- @return A pointer to an immutable PaHostApiInfo structure describing
- a specific host API. If the hostApi parameter is out of range or an error
- is encountered, the function returns NULL.
-
- The returned structure is owned by the PortAudio implementation and must not
- be manipulated or freed. The pointer is only guaranteed to be valid between
- calls to Pa_Initialize() and Pa_Terminate().
-*/
-const PaHostApiInfo * Pa_GetHostApiInfo( PaHostApiIndex hostApi );
-
-
-/** Convert a static host API unique identifier, into a runtime
- host API index.
-
- @param type A unique host API identifier belonging to the PaHostApiTypeId
- enumeration.
-
- @return A valid PaHostApiIndex ranging from 0 to (Pa_GetHostApiCount()-1) or,
- a PaErrorCode (which are always negative) if PortAudio is not initialized
- or an error is encountered.
-
- The paHostApiNotFound error code indicates that the host API specified by the
- type parameter is not available.
-
- @see PaHostApiTypeId
-*/
-PaHostApiIndex Pa_HostApiTypeIdToHostApiIndex( PaHostApiTypeId type );
-
-
-/** Convert a host-API-specific device index to standard PortAudio device index.
- This function may be used in conjunction with the deviceCount field of
- PaHostApiInfo to enumerate all devices for the specified host API.
-
- @param hostApi A valid host API index ranging from 0 to (Pa_GetHostApiCount()-1)
-
- @param hostApiDeviceIndex A valid per-host device index in the range
- 0 to (Pa_GetHostApiInfo(hostApi)->deviceCount-1)
-
- @return A non-negative PaDeviceIndex ranging from 0 to (Pa_GetDeviceCount()-1)
- or, a PaErrorCode (which are always negative) if PortAudio is not initialized
- or an error is encountered.
-
- A paInvalidHostApi error code indicates that the host API index specified by
- the hostApi parameter is out of range.
-
- A paInvalidDevice error code indicates that the hostApiDeviceIndex parameter
- is out of range.
-
- @see PaHostApiInfo
-*/
-PaDeviceIndex Pa_HostApiDeviceIndexToDeviceIndex( PaHostApiIndex hostApi,
- int hostApiDeviceIndex );
-
-
-
-/** Structure used to return information about a host error condition.
-*/
-typedef struct PaHostErrorInfo{
- PaHostApiTypeId hostApiType; /**< the host API which returned the error code */
- long errorCode; /**< the error code returned */
- const char *errorText; /**< a textual description of the error if available, otherwise a zero-length string */
-}PaHostErrorInfo;
-
-
-/** Return information about the last host error encountered. The error
- information returned by Pa_GetLastHostErrorInfo() will never be modified
- asyncronously by errors occurring in other PortAudio owned threads
- (such as the thread that manages the stream callback.)
-
- This function is provided as a last resort, primarily to enhance debugging
- by providing clients with access to all available error information.
-
- @return A pointer to an immutable structure constaining information about
- the host error. The values in this structure will only be valid if a
- PortAudio function has previously returned the paUnanticipatedHostError
- error code.
-*/
-const PaHostErrorInfo* Pa_GetLastHostErrorInfo( void );
-
-
-
-/* Device enumeration and capabilities */
-
-/** Retrieve the number of available devices. The number of available devices
- may be zero.
-
- @return A non-negative value indicating the number of available devices or,
- a PaErrorCode (which are always negative) if PortAudio is not initialized
- or an error is encountered.
-*/
-PaDeviceIndex Pa_GetDeviceCount( void );
-
-
-/** Retrieve the index of the default input device. The result can be
- used in the inputDevice parameter to Pa_OpenStream().
-
- @return The default input device index for the default host API, or paNoDevice
- if no default input device is available or an error was encountered.
-*/
-PaDeviceIndex Pa_GetDefaultInputDevice( void );
-
-
-/** Retrieve the index of the default output device. The result can be
- used in the outputDevice parameter to Pa_OpenStream().
-
- @return The default output device index for the defualt host API, or paNoDevice
- if no default output device is available or an error was encountered.
-
- @note
- On the PC, the user can specify a default device by
- setting an environment variable. For example, to use device #1.
-<pre>
- set PA_RECOMMENDED_OUTPUT_DEVICE=1
-</pre>
- The user should first determine the available device ids by using
- the supplied application "pa_devs".
-*/
-PaDeviceIndex Pa_GetDefaultOutputDevice( void );
-
-
-/** The type used to represent monotonic time in seconds that can be used
- for syncronisation. The type is used for the outTime argument to the
- PaStreamCallback and as the result of Pa_GetStreamTime().
-
- @see PaStreamCallback, Pa_GetStreamTime
-*/
-typedef double PaTime;
-
-
-/** A type used to specify one or more sample formats. Each value indicates
- a possible format for sound data passed to and from the stream callback,
- Pa_ReadStream and Pa_WriteStream.
-
- The standard formats paFloat32, paInt16, paInt32, paInt24, paInt8
- and aUInt8 are usually implemented by all implementations.
-
- The floating point representation (paFloat32) uses +1.0 and -1.0 as the
- maximum and minimum respectively.
-
- paUInt8 is an unsigned 8 bit format where 128 is considered "ground"
-
- The paNonInterleaved flag indicates that a multichannel buffer is passed
- as a set of non-interleaved pointers.
-
- @see Pa_OpenStream, Pa_OpenDefaultStream, PaDeviceInfo
- @see paFloat32, paInt16, paInt32, paInt24, paInt8
- @see paUInt8, paCustomFormat, paNonInterleaved
-*/
-typedef unsigned long PaSampleFormat;
-
-
-#define paFloat32 ((PaSampleFormat) 0x00000001) /**< @see PaSampleFormat */
-#define paInt32 ((PaSampleFormat) 0x00000002) /**< @see PaSampleFormat */
-#define paInt24 ((PaSampleFormat) 0x00000004) /**< Packed 24 bit format. @see PaSampleFormat */
-#define paInt16 ((PaSampleFormat) 0x00000008) /**< @see PaSampleFormat */
-#define paInt8 ((PaSampleFormat) 0x00000010) /**< @see PaSampleFormat */
-#define paUInt8 ((PaSampleFormat) 0x00000020) /**< @see PaSampleFormat */
-#define paCustomFormat ((PaSampleFormat) 0x00010000)/**< @see PaSampleFormat */
-
-#define paNonInterleaved ((PaSampleFormat) 0x80000000)
-
-/** A structure providing information and capabilities of PortAudio devices.
- Devices may support input, output or both input and output.
-*/
-typedef struct PaDeviceInfo
-{
- int structVersion; /* this is struct version 2 */
- const char *name;
- PaHostApiIndex hostApi; /* note this is a host API index, not a type id*/
-
- int maxInputChannels;
- int maxOutputChannels;
-
- /* Default latency values for interactive performance. */
- PaTime defaultLowInputLatency;
- PaTime defaultLowOutputLatency;
- /* Default latency values for robust non-interactive applications (eg. playing sound files). */
- PaTime defaultHighInputLatency;
- PaTime defaultHighOutputLatency;
-
- double defaultSampleRate;
-} PaDeviceInfo;
-
-
-/** Retrieve a pointer to a PaDeviceInfo structure containing information
- about the specified device.
- @return A pointer to an immutable PaDeviceInfo structure. If the device
- parameter is out of range the function returns NULL.
-
- @param device A valid device index in the range 0 to (Pa_GetDeviceCount()-1)
-
- @note PortAudio manages the memory referenced by the returned pointer,
- the client must not manipulate or free the memory. The pointer is only
- guaranteed to be valid between calls to Pa_Initialize() and Pa_Terminate().
-
- @see PaDeviceInfo, PaDeviceIndex
-*/
-const PaDeviceInfo* Pa_GetDeviceInfo( PaDeviceIndex device );
-
-
-/** Parameters for one direction (input or output) of a stream.
-*/
-typedef struct PaStreamParameters
-{
- /** A valid device index in the range 0 to (Pa_GetDeviceCount()-1)
- specifying the device to be used or the special constant
- paUseHostApiSpecificDeviceSpecification which indicates that the actual
- device(s) to use are specified in hostApiSpecificStreamInfo.
- This field must not be set to paNoDevice.
- */
- PaDeviceIndex device;
-
- /** The number of channels of sound to be delivered to the
- stream callback or accessed by Pa_ReadStream() or Pa_WriteStream().
- It can range from 1 to the value of maxInputChannels in the
- PaDeviceInfo record for the device specified by the device parameter.
- */
- int channelCount;
-
- /** The sample format of the buffer provided to the stream callback,
- a_ReadStream() or Pa_WriteStream(). It may be any of the formats described
- by the PaSampleFormat enumeration.
- */
- PaSampleFormat sampleFormat;
-
- /** The desired latency in seconds. Where practical, implementations should
- configure their latency based on these parameters, otherwise they may
- choose the closest viable latency instead. Unless the suggested latency
- is greater than the absolute upper limit for the device implementations
- should round the suggestedLatency up to the next practial value - ie to
- provide an equal or higher latency than suggestedLatency wherever possibe.
- Actual latency values for an open stream may be retrieved using the
- inputLatency and outputLatency fields of the PaStreamInfo structure
- returned by Pa_GetStreamInfo().
- @see default*Latency in PaDeviceInfo, *Latency in PaStreamInfo
- */
- PaTime suggestedLatency;
-
- /** An optional pointer to a host api specific data structure
- containing additional information for device setup and/or stream processing.
- hostApiSpecificStreamInfo is never required for correct operation,
- if not used it should be set to NULL.
- */
- void *hostApiSpecificStreamInfo;
-
-} PaStreamParameters;
-
-
-/** Return code for Pa_IsFormatSupported indicating success. */
-#define paFormatIsSupported (0)
-
-/** Determine whether it would be possible to open a stream with the specified
- parameters.
-
- @param inputParameters A structure that describes the input parameters used to
- open a stream. The suggestedLatency field is ignored. See PaStreamParameters
- for a description of these parameters. inputParameters must be NULL for
- output-only streams.
-
- @param outputParameters A structure that describes the output parameters used
- to open a stream. The suggestedLatency field is ignored. See PaStreamParameters
- for a description of these parameters. outputParameters must be NULL for
- input-only streams.
-
- @param sampleRate The required sampleRate. For full-duplex streams it is the
- sample rate for both input and output
-
- @return Returns 0 if the format is supported, and an error code indicating why
- the format is not supported otherwise. The constant paFormatIsSupported is
- provided to compare with the return value for success.
-
- @see paFormatIsSupported, PaStreamParameters
-*/
-PaError Pa_IsFormatSupported( const PaStreamParameters *inputParameters,
- const PaStreamParameters *outputParameters,
- double sampleRate );
-
-
-
-/* Streaming types and functions */
-
-
-/**
- A single PaStream can provide multiple channels of real-time
- streaming audio input and output to a client application. A stream
- provides access to audio hardware represented by one or more
- PaDevices. Depending on the underlying Host API, it may be possible
- to open multiple streams using the same device, however this behavior
- is implementation defined. Portable applications should assume that
- a PaDevice may be simultaneously used by at most one PaStream.
-
- Pointers to PaStream objects are passed between PortAudio functions that
- operate on streams.
-
- @see Pa_OpenStream, Pa_OpenDefaultStream, Pa_OpenDefaultStream, Pa_CloseStream,
- Pa_StartStream, Pa_StopStream, Pa_AbortStream, Pa_IsStreamActive,
- Pa_GetStreamTime, Pa_GetStreamCpuLoad
-
-*/
-typedef void PaStream;
-
-
-/** Can be passed as the framesPerBuffer parameter to Pa_OpenStream()
- or Pa_OpenDefaultStream() to indicate that the stream callback will
- accept buffers of any size.
-*/
-#define paFramesPerBufferUnspecified (0)
-
-
-/** Flags used to control the behavior of a stream. They are passed as
- parameters to Pa_OpenStream or Pa_OpenDefaultStream. Multiple flags may be
- ORed together.
-
- @see Pa_OpenStream, Pa_OpenDefaultStream
- @see paNoFlag, paClipOff, paDitherOff, paNeverDropInput,
- paPrimeOutputBuffersUsingStreamCallback, paPlatformSpecificFlags
-*/
-typedef unsigned long PaStreamFlags;
-
-/** @see PaStreamFlags */
-#define paNoFlag ((PaStreamFlags) 0)
-
-/** Disable default clipping of out of range samples.
- @see PaStreamFlags
-*/
-#define paClipOff ((PaStreamFlags) 0x00000001)
-
-/** Disable default dithering.
- @see PaStreamFlags
-*/
-#define paDitherOff ((PaStreamFlags) 0x00000002)
-
-/** Flag requests that where possible a full duplex stream will not discard
- overflowed input samples without calling the stream callback. This flag is
- only valid for full duplex callback streams and only when used in combination
- with the paFramesPerBufferUnspecified (0) framesPerBuffer parameter. Using
- this flag incorrectly results in a paInvalidFlag error being returned from
- Pa_OpenStream and Pa_OpenDefaultStream.
-
- @see PaStreamFlags, paFramesPerBufferUnspecified
-*/
-#define paNeverDropInput ((PaStreamFlags) 0x00000004)
-
-/** Call the stream callback to fill initial output buffers, rather than the
- default behavior of priming the buffers with zeros (silence). This flag has
- no effect for input-only and blocking read/write streams.
-
- @see PaStreamFlags
-*/
-#define paPrimeOutputBuffersUsingStreamCallback ((PaStreamFlags) 0x00000008)
-
-/** A mask specifying the platform specific bits.
- @see PaStreamFlags
-*/
-#define paPlatformSpecificFlags ((PaStreamFlags)0xFFFF0000)
-
-/**
- Timing information for the buffers passed to the stream callback.
-*/
-typedef struct PaStreamCallbackTimeInfo{
- PaTime inputBufferAdcTime;
- PaTime currentTime;
- PaTime outputBufferDacTime;
-} PaStreamCallbackTimeInfo;
-
-
-/**
- Flag bit constants for the statusFlags to PaStreamCallback.
-
- @see paInputUnderflow, paInputOverflow, paOutputUnderflow, paOutputOverflow,
- paPrimingOutput
-*/
-typedef unsigned long PaStreamCallbackFlags;
-
-/** In a stream opened with paFramesPerBufferUnspecified, indicates that
- input data is all silence (zeros) because no real data is available. In a
- stream opened without paFramesPerBufferUnspecified, it indicates that one or
- more zero samples have been inserted into the input buffer to compensate
- for an input underflow.
- @see PaStreamCallbackFlags
-*/
-#define paInputUnderflow ((PaStreamCallbackFlags) 0x00000001)
-
-/** In a stream opened with paFramesPerBufferUnspecified, indicates that data
- prior to the first sample of the input buffer was discarded due to an
- overflow, possibly because the stream callback is using too much CPU time.
- Otherwise indicates that data prior to one or more samples in the
- input buffer was discarded.
- @see PaStreamCallbackFlags
-*/
-#define paInputOverflow ((PaStreamCallbackFlags) 0x00000002)
-
-/** Indicates that output data (or a gap) was inserted, possibly because the
- stream callback is using too much CPU time.
- @see PaStreamCallbackFlags
-*/
-#define paOutputUnderflow ((PaStreamCallbackFlags) 0x00000004)
-
-/** Indicates that output data will be discarded because no room is available.
- @see PaStreamCallbackFlags
-*/
-#define paOutputOverflow ((PaStreamCallbackFlags) 0x00000008)
-
-/** Some of all of the output data will be used to prime the stream, input
- data may be zero.
- @see PaStreamCallbackFlags
-*/
-#define paPrimingOutput ((PaStreamCallbackFlags) 0x00000010)
-
-/**
- Allowable return values for the PaStreamCallback.
- @see PaStreamCallback
-*/
-typedef enum PaStreamCallbackResult
-{
- paContinue=0,
- paComplete=1,
- paAbort=2
-} PaStreamCallbackResult;
-
-
-/**
- Functions of type PaStreamCallback are implemented by PortAudio clients.
- They consume, process or generate audio in response to requests from an
- active PortAudio stream.
-
- @param input and @param output are arrays of interleaved samples,
- the format, packing and number of channels used by the buffers are
- determined by parameters to Pa_OpenStream().
-
- @param frameCount The number of sample frames to be processed by
- the stream callback.
-
- @param timeInfo The time in seconds when the first sample of the input
- buffer was received at the audio input, the time in seconds when the first
- sample of the output buffer will begin being played at the audio output, and
- the time in seconds when the stream callback was called.
- See also Pa_GetStreamTime()
-
- @param statusFlags Flags indicating whether input and/or output buffers
- have been inserted or will be dropped to overcome underflow or overflow
- conditions.
-
- @param userData The value of a user supplied pointer passed to
- Pa_OpenStream() intended for storing synthesis data etc.
-
- @return
- The stream callback should return one of the values in the
- PaStreamCallbackResult enumeration. To ensure that the callback continues
- to be called, it should return paContinue (0). Either paComplete or paAbort
- can be returned to finish stream processing, after either of these values is
- returned the callback will not be called again. If paAbort is returned the
- stream will finish as soon as possible. If paComplete is returned, the stream
- will continue until all buffers generated by the callback have been played.
- This may be useful in applications such as soundfile players where a specific
- duration of output is required. However, it is not necessary to utilise this
- mechanism as Pa_StopStream(), Pa_AbortStream() or Pa_CloseStream() can also
- be used to stop the stream. The callback must always fill the entire output
- buffer irrespective of its return value.
-
- @see Pa_OpenStream, Pa_OpenDefaultStream
-
- @note With the exception of Pa_GetStreamCpuLoad() it is not permissable to call
- PortAudio API functions from within the stream callback.
-*/
-typedef int PaStreamCallback(
- const void *input, void *output,
- unsigned long frameCount,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *userData );
-
-
-/** Opens a stream for either input, output or both.
-
- @param stream The address of a PaStream pointer which will receive
- a pointer to the newly opened stream.
-
- @param inputParameters A structure that describes the input parameters used by
- the opened stream. See PaStreamParameters for a description of these parameters.
- inputParameters must be NULL for output-only streams.
-
- @param outputParameters A structure that describes the output parameters used by
- the opened stream. See PaStreamParameters for a description of these parameters.
- outputParameters must be NULL for input-only streams.
-
- @param sampleRate The desired sampleRate. For full-duplex streams it is the
- sample rate for both input and output
-
- @param framesPerBuffer The number of frames passed to the stream callback
- function, or the preferred block granularity for a blocking read/write stream.
- The special value paFramesPerBufferUnspecified (0) may be used to request that
- the stream callback will recieve an optimal (and possibly varying) number of
- frames based on host requirements and the requested latency settings.
- Note: With some host APIs, the use of non-zero framesPerBuffer for a callback
- stream may introduce an additional layer of buffering which could introduce
- additional latency. PortAudio guarantees that the additional latency
- will be kept to the theoretical minimum however, it is strongly recommended
- that a non-zero framesPerBuffer value only be used when your algorithm
- requires a fixed number of frames per stream callback.
-
- @param streamFlags Flags which modify the behaviour of the streaming process.
- This parameter may contain a combination of flags ORed together. Some flags may
- only be relevant to certain buffer formats.
-
- @param streamCallback A pointer to a client supplied function that is responsible
- for processing and filling input and output buffers. If this parameter is NULL
- the stream will be opened in 'blocking read/write' mode. In blocking mode,
- the client can receive sample data using Pa_ReadStream and write sample data
- using Pa_WriteStream, the number of samples that may be read or written
- without blocking is returned by Pa_GetStreamReadAvailable and
- Pa_GetStreamWriteAvailable respectively.
-
- @param userData A client supplied pointer which is passed to the stream callback
- function. It could for example, contain a pointer to instance data necessary
- for processing the audio buffers. This parameter is ignored if streamCallback
- is NULL.
-
- @return
- Upon success Pa_OpenStream() returns paNoError and places a pointer to a
- valid PaStream in the stream argument. The stream is inactive (stopped).
- If a call to Pa_OpenStream() fails, a non-zero error code is returned (see
- PaError for possible error codes) and the value of stream is invalid.
-
- @see PaStreamParameters, PaStreamCallback, Pa_ReadStream, Pa_WriteStream,
- Pa_GetStreamReadAvailable, Pa_GetStreamWriteAvailable
-*/
-PaError Pa_OpenStream( PaStream** stream,
- const PaStreamParameters *inputParameters,
- const PaStreamParameters *outputParameters,
- double sampleRate,
- unsigned long framesPerBuffer,
- PaStreamFlags streamFlags,
- PaStreamCallback *streamCallback,
- void *userData );
-
-
-/** A simplified version of Pa_OpenStream() that opens the default input
- and/or output devices.
-
- @param stream The address of a PaStream pointer which will receive
- a pointer to the newly opened stream.
-
- @param numInputChannels The number of channels of sound that will be supplied
- to the stream callback or returned by Pa_ReadStream. It can range from 1 to
- the value of maxInputChannels in the PaDeviceInfo record for the default input
- device. If 0 the stream is opened as an output-only stream.
-
- @param numOutputChannels The number of channels of sound to be delivered to the
- stream callback or passed to Pa_WriteStream. It can range from 1 to the value
- of maxOutputChannels in the PaDeviceInfo record for the default output dvice.
- If 0 the stream is opened as an output-only stream.
-
- @param sampleFormat The sample format of both the input and output buffers
- provided to the callback or passed to and from Pa_ReadStream and Pa_WriteStream.
- sampleFormat may be any of the formats described by the PaSampleFormat
- enumeration.
-
- @param sampleRate Same as Pa_OpenStream parameter of the same name.
- @param framesPerBuffer Same as Pa_OpenStream parameter of the same name.
- @param streamCallback Same as Pa_OpenStream parameter of the same name.
- @param userData Same as Pa_OpenStream parameter of the same name.
-
- @return As for Pa_OpenStream
-
- @see Pa_OpenStream, PaStreamCallback
-*/
-PaError Pa_OpenDefaultStream( PaStream** stream,
- int numInputChannels,
- int numOutputChannels,
- PaSampleFormat sampleFormat,
- double sampleRate,
- unsigned long framesPerBuffer,
- PaStreamCallback *streamCallback,
- void *userData );
-
-
-/** Closes an audio stream. If the audio stream is active it
- discards any pending buffers as if Pa_AbortStream() had been called.
-*/
-PaError Pa_CloseStream( PaStream *stream );
-
-
-/** Functions of type PaStreamFinishedCallback are implemented by PortAudio
- clients. They can be registered with a stream using the Pa_SetStreamFinishedCallback
- function. Once registered they are called when the stream becomes inactive
- (ie once a call to Pa_StopStream() will not block).
- A stream will become inactive after the stream callback returns non-zero,
- or when Pa_StopStream or Pa_AbortStream is called. For a stream providing audio
- output, if the stream callback returns paComplete, or Pa_StopStream is called,
- the stream finished callback will not be called until all generated sample data
- has been played.
-
- @param userData The userData parameter supplied to Pa_OpenStream()
-
- @see Pa_SetStreamFinishedCallback
-*/
-typedef void PaStreamFinishedCallback( void *userData );
-
-
-/** Register a stream finished callback function which will be called when the
- stream becomes inactive. See the description of PaStreamFinishedCallback for
- further details about when the callback will be called.
-
- @param stream a pointer to a PaStream that is in the stopped state - if the
- stream is not stopped, the stream's finished callback will remain unchanged
- and an error code will be returned.
-
- @param streamFinishedCallback a pointer to a function with the same signature
- as PaStreamFinishedCallback, that will be called when the stream becomes
- inactive. Passing NULL for this parameter will un-register a previously
- registered stream finished callback function.
-
- @return on success returns paNoError, otherwise an error code indicating the cause
- of the error.
-
- @see PaStreamFinishedCallback
-*/
-PaError Pa_SetStreamFinishedCallback( PaStream *stream, PaStreamFinishedCallback* streamFinishedCallback );
-
-
-/** Commences audio processing.
-*/
-PaError Pa_StartStream( PaStream *stream );
-
-
-/** Terminates audio processing. It waits until all pending
- audio buffers have been played before it returns.
-*/
-PaError Pa_StopStream( PaStream *stream );
-
-
-/** Terminates audio processing immediately without waiting for pending
- buffers to complete.
-*/
-PaError Pa_AbortStream( PaStream *stream );
-
-
-/** Determine whether the stream is stopped.
- A stream is considered to be stopped prior to a successful call to
- Pa_StartStream and after a successful call to Pa_StopStream or Pa_AbortStream.
- If a stream callback returns a value other than paContinue the stream is NOT
- considered to be stopped.
-
- @return Returns one (1) when the stream is stopped, zero (0) when
- the stream is running or, a PaErrorCode (which are always negative) if
- PortAudio is not initialized or an error is encountered.
-
- @see Pa_StopStream, Pa_AbortStream, Pa_IsStreamActive
-*/
-PaError Pa_IsStreamStopped( PaStream *stream );
-
-
-/** Determine whether the stream is active.
- A stream is active after a successful call to Pa_StartStream(), until it
- becomes inactive either as a result of a call to Pa_StopStream() or
- Pa_AbortStream(), or as a result of a return value other than paContinue from
- the stream callback. In the latter case, the stream is considered inactive
- after the last buffer has finished playing.
-
- @return Returns one (1) when the stream is active (ie playing or recording
- audio), zero (0) when not playing or, a PaErrorCode (which are always negative)
- if PortAudio is not initialized or an error is encountered.
-
- @see Pa_StopStream, Pa_AbortStream, Pa_IsStreamStopped
-*/
-PaError Pa_IsStreamActive( PaStream *stream );
-
-
-
-/** A structure containing unchanging information about an open stream.
- @see Pa_GetStreamInfo
-*/
-
-typedef struct PaStreamInfo
-{
- /** this is struct version 1 */
- int structVersion;
-
- /** The input latency of the stream in seconds. This value provides the most
- accurate estimate of input latency available to the implementation. It may
- differ significantly from the suggestedLatency value passed to Pa_OpenStream().
- The value of this field will be zero (0.) for output-only streams.
- @see PaTime
- */
- PaTime inputLatency;
-
- /** The output latency of the stream in seconds. This value provides the most
- accurate estimate of output latency available to the implementation. It may
- differ significantly from the suggestedLatency value passed to Pa_OpenStream().
- The value of this field will be zero (0.) for input-only streams.
- @see PaTime
- */
- PaTime outputLatency;
-
- /** The sample rate of the stream in Hertz (samples per second). In cases
- where the hardware sample rate is inaccurate and PortAudio is aware of it,
- the value of this field may be different from the sampleRate parameter
- passed to Pa_OpenStream(). If information about the actual hardware sample
- rate is not available, this field will have the same value as the sampleRate
- parameter passed to Pa_OpenStream().
- */
- double sampleRate;
-
-} PaStreamInfo;
-
-
-/** Retrieve a pointer to a PaStreamInfo structure containing information
- about the specified stream.
- @return A pointer to an immutable PaStreamInfo structure. If the stream
- parameter invalid, or an error is encountered, the function returns NULL.
-
- @param stream A pointer to an open stream previously created with Pa_OpenStream.
-
- @note PortAudio manages the memory referenced by the returned pointer,
- the client must not manipulate or free the memory. The pointer is only
- guaranteed to be valid until the specified stream is closed.
-
- @see PaStreamInfo
-*/
-const PaStreamInfo* Pa_GetStreamInfo( PaStream *stream );
-
-
-/** Determine the current time for the stream according to the same clock used
- to generate buffer timestamps. This time may be used for syncronising other
- events to the audio stream, for example synchronizing audio to MIDI.
-
- @return The stream's current time in seconds, or 0 if an error occurred.
-
- @see PaTime, PaStreamCallback
-*/
-PaTime Pa_GetStreamTime( PaStream *stream );
-
-
-/** Retrieve CPU usage information for the specified stream.
- The "CPU Load" is a fraction of total CPU time consumed by a callback stream's
- audio processing routines including, but not limited to the client supplied
- stream callback. This function does not work with blocking read/write streams.
-
- This function may be called from the stream callback function or the
- application.
-
- @return
- A floating point value, typically between 0.0 and 1.0, where 1.0 indicates
- that the stream callback is consuming the maximum number of CPU cycles possible
- to maintain real-time operation. A value of 0.5 would imply that PortAudio and
- the stream callback was consuming roughly 50% of the available CPU time. The
- return value may exceed 1.0. A value of 0.0 will always be returned for a
- blocking read/write stream, or if an error occurrs.
-*/
-double Pa_GetStreamCpuLoad( PaStream* stream );
-
-
-/** Read samples from an input stream. The function doesn't return until
- the entire buffer has been filled - this may involve waiting for the operating
- system to supply the data.
-
- @param stream A pointer to an open stream previously created with Pa_OpenStream.
-
- @param buffer A pointer to a buffer of sample frames. The buffer contains
- samples in the format specified by the inputParameters->sampleFormat field
- used to open the stream, and the number of channels specified by
- inputParameters->numChannels. If non-interleaved samples were requested,
- buffer is a pointer to the first element of an array of non-interleaved
- buffer pointers, one for each channel.
-
- @param frames The number of frames to be read into buffer. This parameter
- is not constrained to a specific range, however high performance applications
- will want to match this parameter to the framesPerBuffer parameter used
- when opening the stream.
-
- @return On success PaNoError will be returned, or PaInputOverflowed if input
- data was discarded by PortAudio after the previous call and before this call.
-*/
-PaError Pa_ReadStream( PaStream* stream,
- void *buffer,
- unsigned long frames );
-
-
-/** Write samples to an output stream. This function doesn't return until the
- entire buffer has been consumed - this may involve waiting for the operating
- system to consume the data.
-
- @param stream A pointer to an open stream previously created with Pa_OpenStream.
-
- @param buffer A pointer to a buffer of sample frames. The buffer contains
- samples in the format specified by the outputParameters->sampleFormat field
- used to open the stream, and the number of channels specified by
- outputParameters->numChannels. If non-interleaved samples were requested,
- buffer is a pointer to the first element of an array of non-interleaved
- buffer pointers, one for each channel.
-
- @param frames The number of frames to be written from buffer. This parameter
- is not constrained to a specific range, however high performance applications
- will want to match this parameter to the framesPerBuffer parameter used
- when opening the stream.
-
- @return On success PaNoError will be returned, or paOutputUnderflowed if
- additional output data was inserted after the previous call and before this
- call.
-*/
-PaError Pa_WriteStream( PaStream* stream,
- const void *buffer,
- unsigned long frames );
-
-
-/** Retrieve the number of frames that can be read from the stream without
- waiting.
-
- @return Returns a non-negative value representing the maximum number of frames
- that can be read from the stream without blocking or busy waiting or, a
- PaErrorCode (which are always negative) if PortAudio is not initialized or an
- error is encountered.
-*/
-signed long Pa_GetStreamReadAvailable( PaStream* stream );
-
-
-/** Retrieve the number of frames that can be written to the stream without
- waiting.
-
- @return Returns a non-negative value representing the maximum number of frames
- that can be written to the stream without blocking or busy waiting or, a
- PaErrorCode (which are always negative) if PortAudio is not initialized or an
- error is encountered.
-*/
-signed long Pa_GetStreamWriteAvailable( PaStream* stream );
-
-
-/* Miscellaneous utilities */
-
-
-/** Retrieve the size of a given sample format in bytes.
-
- @return The size in bytes of a single sample in the specified format,
- or paSampleFormatNotSupported if the format is not supported.
-*/
-PaError Pa_GetSampleSize( PaSampleFormat format );
-
-
-/** Put the caller to sleep for at least 'msec' milliseconds. This function is
- provided only as a convenience for authors of portable code (such as the tests
- and examples in the PortAudio distribution.)
-
- The function may sleep longer than requested so don't rely on this for accurate
- musical timing.
-*/
-void Pa_Sleep( long msec );
-
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-#endif /* PORTAUDIO_H */
diff --git a/navit/support/espeak/readclause.c b/navit/support/espeak/readclause.c
deleted file mode 100644
index b8d302a27..000000000
--- a/navit/support/espeak/readclause.c
+++ /dev/null
@@ -1,2440 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <wctype.h>
-#include <wchar.h>
-#include <math.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-#include "translate.h"
-
-#ifdef PLATFORM_POSIX
-#include <unistd.h>
-#endif
-
-#include <locale.h>
-#define N_XML_BUF 256
-
-#define double(x) ((double)(x))
-static const char *xmlbase = ""; // base URL from <speak>
-
-static int namedata_ix=0;
-static int n_namedata = 0;
-char *namedata = NULL;
-
-
-static FILE *f_input = NULL;
-static int ungot_char2 = 0;
-unsigned char *p_textinput;
-wchar_t *p_wchar_input;
-static int ungot_char;
-static const char *ungot_word = NULL;
-static int end_of_input;
-
-static int ignore_text=0; // set during <sub> ... </sub> to ignore text which has been replaced by an alias
-static int clear_skipping_text = 0; // next clause should clear the skipping_text flag
-int count_characters = 0;
-static int sayas_mode;
-static int ssml_ignore_l_angle = 0;
-
-static const char *punct_stop = ".:!?"; // pitch fall if followed by space
-static const char *punct_close = ")]}>;'\""; // always pitch fall unless followed by alnum
-
-// alter tone for announce punctuation or capitals
-static const char *tone_punct_on = "\0016T"; // add reverberation, lower pitch
-static const char *tone_punct_off = "\001T";
-
-// punctuations symbols that can end a clause
-static const unsigned short punct_chars[] = {',','.','?','!',':',';',
- 0x2013, // en-dash
- 0x2014, // em-dash
- 0x2026, // elipsis
-
- 0x037e, // Greek question mark (looks like semicolon)
- 0x0387, // Greek semicolon, ano teleia
- 0x0964, // Devanagari Danda (fullstop)
-
- 0x0589, // Armenian period
- 0x055d, // Armenian comma
- 0x055c, // Armenian exclamation
- 0x055e, // Armenian question
- 0x055b, // Armenian emphasis mark
-
- 0x1362, // Ethiopic period
- 0x1363,
- 0x1364,
- 0x1365,
- 0x1366,
- 0x1367,
- 0x1368,
-
- 0x3001, // ideograph comma
- 0x3002, // ideograph period
-
- 0xff01, // fullwidth exclamation
- 0xff0c, // fullwidth comma
- 0xff0e, // fullwidth period
- 0xff1a, // fullwidth colon
- 0xff1b, // fullwidth semicolon
- 0xff1f, // fullwidth question mark
-
- 0};
-
-
-// indexed by (entry num. in punct_chars) + 1
-// bits 0-7 pause x 10mS, bits 12-14 intonation type, bit 15 don't need following space or bracket
-static const unsigned int punct_attributes [] = { 0,
- CLAUSE_COMMA, CLAUSE_PERIOD, CLAUSE_QUESTION, CLAUSE_EXCLAMATION, CLAUSE_COLON, CLAUSE_SEMICOLON,
- CLAUSE_SEMICOLON, // en-dash
- CLAUSE_SEMICOLON, // em-dash
- CLAUSE_SEMICOLON, // elipsis
-
- CLAUSE_QUESTION, // Greek question mark
- CLAUSE_SEMICOLON, // Greek semicolon
- CLAUSE_PERIOD+0x8000, // Devanagari Danda (fullstop)
-
- CLAUSE_PERIOD+0x8000, // Armenian period
- CLAUSE_COMMA, // Armenian comma
- CLAUSE_EXCLAMATION + PUNCT_IN_WORD, // Armenian exclamation
- CLAUSE_QUESTION + PUNCT_IN_WORD, // Armenian question
- CLAUSE_PERIOD + PUNCT_IN_WORD, // Armenian emphasis mark
-
- CLAUSE_PERIOD, // Ethiopic period
- CLAUSE_COMMA, // Ethiopic comma
- CLAUSE_SEMICOLON, // Ethiopic semicolon
- CLAUSE_COLON, // Ethiopic colon
- CLAUSE_COLON, // Ethiopic preface colon
- CLAUSE_QUESTION, // Ethiopic question mark
- CLAUSE_PERIOD, // Ethiopic paragraph
-
- CLAUSE_COMMA+0x8000, // ideograph comma
- CLAUSE_PERIOD+0x8000, // ideograph period
-
- CLAUSE_EXCLAMATION+0x8000, // fullwidth
- CLAUSE_COMMA+0x8000,
- CLAUSE_PERIOD+0x8000,
- CLAUSE_COLON+0x8000,
- CLAUSE_SEMICOLON+0x8000,
- CLAUSE_QUESTION+0x8000,
-
- CLAUSE_SEMICOLON, // spare
- 0 };
-
-
-// stack for language and voice properties
-// frame 0 is for the defaults, before any ssml tags.
-typedef struct {
- int tag_type;
- int voice_variant;
- int voice_gender;
- int voice_age;
- char voice_name[40];
- char language[20];
-} SSML_STACK;
-
-#define N_SSML_STACK 20
-static int n_ssml_stack;
-static SSML_STACK ssml_stack[N_SSML_STACK];
-
-static char current_voice_id[40] = {0};
-
-
-#define N_PARAM_STACK 20
-static int n_param_stack;
-PARAM_STACK param_stack[N_PARAM_STACK];
-
-static int speech_parameters[N_SPEECH_PARAM]; // current values, from param_stack
-
-const int param_defaults[N_SPEECH_PARAM] = {
- 0, // silence (internal use)
- 170, // rate wpm
- 100, // volume
- 50, // pitch
- 50, // range
- 0, // punctuation
- 0, // capital letters
- 0, // wordgap
- 0, // options
- 0, // intonation
- 0,
- 0,
- 0, // emphasis
- 0, // line length
- 0, // voice type
-};
-
-
-#ifdef NEED_WCHAR_FUNCTIONS
-
-// additional Latin characters beyond the Latin1 character set
-#define MAX_WALPHA 0x233
-// indexed by character - 0x100
-// 0=not alphabetic, 0xff=lower case, other=value to add to upper case to convert to lower case
-static unsigned char walpha_tab[MAX_WALPHA-0xff] = {
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 100
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 110
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 120
- 0xff,0xff, 1,0xff, 1,0xff, 1,0xff,0xff, 1,0xff, 1,0xff, 1,0xff, 1, // 130
- 0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff,0xff, 1,0xff, 1,0xff, 1,0xff, // 140
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 150
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 160
- 1,0xff, 1,0xff, 1,0xff, 1,0xff,0xff, 1,0xff, 1,0xff, 1,0xff,0xff, // 170
- 0xff, 210, 1,0xff, 1,0xff, 206, 1,0xff, 205, 205, 1,0xff,0xff, 79, 202, // 180
- 203, 1,0xff, 205, 207,0xff, 211, 209, 1,0xff,0xff,0xff, 211, 213,0xff, 214, // 190
- 1,0xff, 1,0xff, 1,0xff, 218, 1,0xff, 218,0xff,0xff, 1,0xff, 218, 1, // 1a0
- 0xff, 217, 217, 1,0xff, 1,0xff, 219, 1,0xff,0xff,0xff, 1,0xff,0xff,0xff, // 1b0
- 0xff,0xff,0xff,0xff, 2, 1,0xff, 2, 1,0xff, 2, 1,0xff, 1,0xff, 1, // 1c0
- 0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff,0xff, 1,0xff, // 1d0
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 1e0
- 0xff, 2, 1,0xff, 1,0xff,0xff,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 1f0
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 200
- 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 210
- 0xff, 0, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, 1,0xff, // 220
- 1,0xff, 1,0xff }; // 230
-
-// use ctype.h functions for Latin1 (character < 0x100)
-int iswalpha(int c)
-{
- if(c < 0x100)
- return(isalpha(c));
- if((c > 0x3040) && (c <= 0xa700))
- return(1); // japanese, chinese characters
- if(c > MAX_WALPHA)
- return(0);
- return(walpha_tab[c-0x100]);
-}
-
-int iswdigit(int c)
-{
- if(c < 0x100)
- return(isdigit(c));
- return(0);
-}
-
-int iswalnum(int c)
-{
- if(iswdigit(c))
- return(1);
- return(iswalpha(c));
-}
-
-int towlower(int c)
-{
- int x;
- if(c < 0x100)
- return(tolower(c));
- if((c > MAX_WALPHA) || ((x = walpha_tab[c-0x100])==0xff))
- return(c); // already lower case
- return(c + x); // convert to lower case
-}
-
-int towupper(int c)
-{
- // check whether the previous character code is the upper-case equivalent of this character
- if(tolower(c-1) == c)
- return(c-1); // yes, use it
- return(c); // no
-}
-
-int iswupper(int c)
-{
- int x;
- if(c < 0x100)
- return(isupper(c));
- if(((c > MAX_WALPHA) || (x = walpha_tab[c-0x100])==0) || (x == 0xff))
- return(0);
- return(1);
-}
-
-int iswlower(int c)
-{
- if(c < 0x100)
- return(islower(c));
- if((c > MAX_WALPHA) || (walpha_tab[c-0x100] != 0xff))
- return(0);
- return(1);
-}
-
-int iswspace(int c)
-{
- if(c < 0x100)
- return(isspace(c));
- return(0);
-}
-
-int iswpunct(int c)
-{
- if(c < 0x100)
- return(ispunct(c));
- return(0);
-}
-
-const wchar_t *wcschr(const wchar_t *str, int c)
-{
- while(*str != 0)
- {
- if(*str == c)
- return(str);
- str++;
- }
- return(NULL);
-}
-
-#ifndef WINCE
-// wcslen() is provided by WINCE, but not the other wchar functions
-const int wcslen(const wchar_t *str)
-{
- int ix=0;
-
- while(*str != 0)
- {
- ix++;
- }
- return(ix);
-}
-#endif
-
-float wcstod(const wchar_t *str, wchar_t **tailptr)
-{
- int ix;
- char buf[80];
- while(isspace(*str)) str++;
- for(ix=0; ix<80; ix++)
- {
- buf[ix] = str[ix];
- if(isspace(buf[ix]))
- break;
- }
- *tailptr = (wchar_t *)&str[ix];
- return(atof(buf));
-}
-#endif
-
-int towlower2(unsigned int c)
-{
- // check for non-standard upper to lower case conversions
- if(c == 'I')
- {
- if(translator->translator_name == L('t','r'))
- {
- c = 0x131; // I -> ı
- }
- }
- return(towlower(c));
-}
-
-static void GetC_unget(int c)
-{//==========================
-// This is only called with UTF8 input, not wchar input
- if(f_input != NULL)
- ungetc(c,f_input);
- else
- {
- p_textinput--;
- *p_textinput = c;
- end_of_input = 0;
- }
-}
-
-int Eof(void)
-{//==========
- if(ungot_char != 0)
- return(0);
-
- if(f_input != 0)
- return(feof(f_input));
-
- return(end_of_input);
-}
-
-
-static int GetC_get(void)
-{//======================
- unsigned int c;
- unsigned int c2;
-
- if(f_input != NULL)
- {
- c = fgetc(f_input);
- if(feof(f_input)) c = ' ';
-
- if(option_multibyte == espeakCHARS_16BIT)
- {
- c2 = fgetc(f_input);
- if(feof(f_input)) c2 = 0;
- c = c + (c2 << 8);
- }
- return(c);
- }
-
- if(option_multibyte == espeakCHARS_WCHAR)
- {
- if(*p_wchar_input == 0)
- {
- end_of_input = 1;
- return(0);
- }
-
- if(!end_of_input)
- return(*p_wchar_input++);
- }
- else
- {
- if(*p_textinput == 0)
- {
- end_of_input = 1;
- return(0);
- }
-
- if(!end_of_input)
- {
- if(option_multibyte == espeakCHARS_16BIT)
- {
- c = p_textinput[0] + (p_textinput[1] << 8);
- p_textinput += 2;
- return(c);
- }
- return(*p_textinput++ & 0xff);
- }
- }
- return(0);
-}
-
-
-static int GetC(void)
-{//==================
-// Returns a unicode wide character
-// Performs UTF8 checking and conversion
-
- int c;
- int c1;
- int c2;
- int cbuf[4];
- int ix;
- int n_bytes;
- unsigned char m;
- static int ungot2 = 0;
- static const unsigned char mask[4] = {0xff,0x1f,0x0f,0x07};
- static const unsigned char mask2[4] = {0,0x80,0x20,0x30};
-
- if((c1 = ungot_char) != 0)
- {
- ungot_char = 0;
- return(c1);
- }
-
- if(ungot2 != 0)
- {
- c1 = ungot2;
- ungot2 = 0;
- }
- else
- {
- c1 = GetC_get();
- }
-
- if((option_multibyte == espeakCHARS_WCHAR) || (option_multibyte == espeakCHARS_16BIT))
- {
- count_characters++;
- return(c1); // wchar_t text
- }
-
- if((option_multibyte < 2) && (c1 & 0x80))
- {
- // multi-byte utf8 encoding, convert to unicode
- n_bytes = 0;
-
- if(((c1 & 0xe0) == 0xc0) && ((c1 & 0x1e) != 0))
- n_bytes = 1;
- else
- if((c1 & 0xf0) == 0xe0)
- n_bytes = 2;
- else
- if(((c1 & 0xf8) == 0xf0) && ((c1 & 0x0f) <= 4))
- n_bytes = 3;
-
- if((ix = n_bytes) > 0)
- {
- c = c1 & mask[ix];
- m = mask2[ix];
- while(ix > 0)
- {
- if((c2 = cbuf[ix] = GetC_get()) == 0)
- {
- if(option_multibyte==espeakCHARS_AUTO)
- option_multibyte=espeakCHARS_8BIT; // change "auto" option to "no"
- GetC_unget(' ');
- break;
- }
-
- if((c2 & 0xc0) != 0x80)
- {
- // This is not UTF8. Change to 8-bit characterset.
- if((n_bytes == 2) && (ix == 1))
- ungot2 = cbuf[2];
- GetC_unget(c2);
- break;
- }
- m = 0x80;
- c = (c << 6) + (c2 & 0x3f);
- ix--;
- }
- if(ix == 0)
- {
- count_characters++;
- return(c);
- }
- }
- // top-bit-set character is not utf8, drop through to 8bit charset case
- if((option_multibyte==espeakCHARS_AUTO) && !Eof())
- option_multibyte=espeakCHARS_8BIT; // change "auto" option to "no"
- }
-
- // 8 bit character set, convert to unicode if
- count_characters++;
- if(c1 >= 0xa0)
- return(translator->charset_a0[c1-0xa0]);
- return(c1);
-} // end of GetC
-
-
-static void UngetC(int c)
-{//======================
- ungot_char = c;
-}
-
-
-static const char *WordToString2(unsigned int word)
-{//================================================
-// Convert a language mnemonic word into a string
- int ix;
- static char buf[5];
- char *p;
-
- p = buf;
- for(ix=3; ix>=0; ix--)
- {
- if((*p = word >> (ix*8)) != 0)
- p++;
- }
- *p = 0;
- return(buf);
-}
-
-
-static const char *LookupSpecial(Translator *tr, const char *string, char* text_out)
-{//=================================================================================
- unsigned int flags[2];
- char phonemes[55];
- char phonemes2[55];
- char *string1 = (char *)string;
-
- if(LookupDictList(tr,&string1,phonemes,flags,0,NULL))
- {
- SetWordStress(tr, phonemes, &flags[0], -1, 0);
- DecodePhonemes(phonemes,phonemes2);
- sprintf(text_out,"[[%s]]",phonemes2);
- option_phoneme_input |= 2;
- return(text_out);
- }
- return(NULL);
-}
-
-
-static const char *LookupCharName(Translator *tr, int c)
-{//=====================================================
-// Find the phoneme string (in ascii) to speak the name of character c
-// Used for punctuation characters and symbols
-
- int ix;
- unsigned int flags[2];
- char single_letter[24];
- char phonemes[60];
- char phonemes2[60];
- const char *lang_name = NULL;
- char *string;
- static char buf[60];
-
- buf[0] = 0;
- flags[0] = 0;
- flags[1] = 0;
- single_letter[0] = 0;
- single_letter[1] = '_';
- ix = utf8_out(c,&single_letter[2]);
- single_letter[2+ix]=0;
-
- string = &single_letter[1];
- if(LookupDictList(tr, &string, phonemes, flags, 0, NULL) == 0)
- {
- // try _* then *
- string = &single_letter[2];
- if(LookupDictList(tr, &string, phonemes, flags, 0, NULL) == 0)
- {
- // now try the rules
- single_letter[1] = ' ';
- TranslateRules(tr, &single_letter[2], phonemes, sizeof(phonemes), NULL,0,NULL);
- }
- }
-
- if((phonemes[0] == 0) && (tr->translator_name != L('e','n')))
- {
- // not found, try English
- SetTranslator2("en");
- string = &single_letter[1];
- single_letter[1] = '_';
- if(LookupDictList(translator2, &string, phonemes, flags, 0, NULL) == 0)
- {
- string = &single_letter[2];
- LookupDictList(translator2, &string, phonemes, flags, 0, NULL);
- }
- if(phonemes[0])
- {
- lang_name = "en";
- }
- else
- {
- SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
- }
- }
-
- if(phonemes[0])
- {
- if(lang_name)
- {
- SetWordStress(translator2, phonemes, &flags[0], -1, 0);
- DecodePhonemes(phonemes,phonemes2);
- sprintf(buf,"[[_^_%s %s _^_%s]]","en",phonemes2,WordToString2(tr->translator_name));
- SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
- }
- else
- {
- SetWordStress(tr, phonemes, &flags[0], -1, 0);
- DecodePhonemes(phonemes,phonemes2);
- sprintf(buf,"[[%s]] ",phonemes2);
- }
- option_phoneme_input |= 2;
- }
- else
- {
- strcpy(buf,"[[(X1)(X1)(X1)]]");
- option_phoneme_input |= 2;
- }
-
- return(buf);
-}
-
-int Read4Bytes(FILE *f)
-{//====================
-// Read 4 bytes (least significant first) into a word
- int ix;
- unsigned char c;
- int acc=0;
-
- for(ix=0; ix<4; ix++)
- {
- c = fgetc(f) & 0xff;
- acc += (c << (ix*8));
- }
- return(acc);
-}
-
-
-static int LoadSoundFile(const char *fname, int index)
-{//===================================================
- FILE *f;
- char *p;
- int *ip;
- int length;
- char fname_temp[100];
- char fname2[sizeof(path_home)+13+40];
-
- if(fname == NULL)
- {
- // filename is already in the table
- fname = soundicon_tab[index].filename;
- }
-
- if(fname==NULL)
- return(1);
-
- if(fname[0] != '/')
- {
- // a relative path, look in espeak-data/soundicons
- sprintf(fname2,"%s%csoundicons%c%s",path_home,PATHSEP,PATHSEP,fname);
- fname = fname2;
- }
-
- f = NULL;
-#ifdef PLATFORM_POSIX
- if((f = fopen(fname,"rb")) != NULL)
- {
- int ix;
- int fd_temp;
- const char *resample;
- int header[3];
- char command[sizeof(fname2)+sizeof(fname2)+40];
-
- fseek(f,20,SEEK_SET);
- for(ix=0; ix<3; ix++)
- header[ix] = Read4Bytes(f);
-
- // if the sound file is not mono, 16 bit signed, at the correct sample rate, then convert it
- if((header[0] != 0x10001) || (header[1] != samplerate) || (header[2] != samplerate*2))
- {
- fclose(f);
- f = NULL;
-
- if(header[2] == samplerate)
- resample = "";
- else
- resample = "polyphase";
-
- strcpy(fname_temp,"/tmp/espeakXXXXXX");
- if((fd_temp = mkstemp(fname_temp)) >= 0)
- {
- close(fd_temp);
-// sprintf(fname_temp,"%s.wav",tmpnam(NULL));
- sprintf(command,"sox \"%s\" -r %d -w -s -c1 %s %s\n", fname, samplerate, fname_temp, resample);
- if(system(command) == 0)
- {
- fname = fname_temp;
- }
- }
- }
- }
-#endif
-
- if(f == NULL)
- {
- f = fopen(fname,"rb");
- if(f == NULL)
- {
- fprintf(stderr,"Can't read temp file: %s\n",fname);
- return(3);
- }
- }
-
- length = GetFileLength(fname);
- fseek(f,0,SEEK_SET);
- if((p = (char *)realloc(soundicon_tab[index].data, length)) == NULL)
- {
- fclose(f);
- return(4);
- }
- fread(p,length,1,f);
- fclose(f);
-#if 0
- remove(fname_temp);
-#endif
-
- ip = (int *)(&p[40]);
- soundicon_tab[index].length = (*ip) / 2; // length in samples
- soundicon_tab[index].data = p;
- return(0);
-} // end of LoadSoundFile
-
-
-static int LookupSoundicon(int c)
-{//==============================
-// Find the sound icon number for a punctuation chatacter
- int ix;
-
- for(ix=N_SOUNDICON_SLOTS; ix<n_soundicon_tab; ix++)
- {
- if(soundicon_tab[ix].name == c)
- {
- if(soundicon_tab[ix].length == 0)
- {
- if(LoadSoundFile(NULL,ix)!=0)
- return(-1); // sound file is not available
- }
- return(ix);
- }
- }
- return(-1);
-}
-
-
-static int LoadSoundFile2(const char *fname)
-{//=========================================
-// Load a sound file into one of the reserved slots in the sound icon table
-// (if it'snot already loaded)
-
- int ix;
- static int slot = -1;
-
- for(ix=0; ix<n_soundicon_tab; ix++)
- {
- if(((soundicon_tab[ix].filename != NULL) && strcmp(fname, soundicon_tab[ix].filename) == 0))
- return(ix); // already loaded
- }
-
- // load the file into the next slot
- slot++;
- if(slot >= N_SOUNDICON_SLOTS)
- slot = 0;
-
- if(LoadSoundFile(fname, slot) != 0)
- return(-1);
-
- soundicon_tab[slot].filename = (char *)realloc(soundicon_tab[ix].filename, strlen(fname)+1);
- strcpy(soundicon_tab[slot].filename, fname);
- return(slot);
-}
-
-
-
-static int AnnouncePunctuation(Translator *tr, int c1, int c2, char *buf, int bufix)
-{//=================================================================================
- // announce punctuation names
- // c1: the punctuation character
- // c2: the following character
-
- int punct_count;
- const char *punctname;
- int found = 0;
- int soundicon;
- char *p;
-
- if((soundicon = LookupSoundicon(c1)) >= 0)
- {
- // add an embedded command to play the soundicon
- sprintf(&buf[bufix],"\001%dI ",soundicon);
- UngetC(c2);
- found = 1;
- }
- else
- if((punctname = LookupCharName(tr, c1)) != NULL)
- {
- found = 1;
- if(bufix==0)
- {
- punct_count=1;
- while(c2 == c1)
- {
- punct_count++;
- c2 = GetC();
- }
- UngetC(c2);
-
- p = &buf[bufix];
- if(punct_count==1)
- {
- sprintf(p,"%s %s %s",tone_punct_on,punctname,tone_punct_off);
- }
- else
- if(punct_count < 4)
- {
- sprintf(p,"\001+10S%s",tone_punct_on);
- while(punct_count-- > 0)
- sprintf(buf,"%s %s",buf,punctname);
- sprintf(p,"%s %s\001-10S",buf,tone_punct_off);
- }
- else
- {
- sprintf(p,"%s %s %d %s %s",
- tone_punct_on,punctname,punct_count,punctname,tone_punct_off);
- return(CLAUSE_COMMA);
- }
- }
- else
- {
- // end the clause now and pick up the punctuation next time
- UngetC(c2);
- if(option_ssml)
- {
- if((c1 == '<') || (c1 == '&'))
- ssml_ignore_l_angle = c1; // this was &lt; which was converted to <, don't pick it up again as <
- }
- ungot_char2 = c1;
- buf[bufix] = ' ';
- buf[bufix+1] = 0;
- }
- }
-
- if(found == 0)
- return(-1);
-
- if(c1 == '-')
- return(CLAUSE_NONE); // no pause
- if(bufix > 0)
- return(CLAUSE_SHORTCOMMA);
- if((strchr_w(punct_close,c1) != NULL) && !iswalnum(c2))
- return(CLAUSE_SHORTFALL+4);
- if(iswspace(c2) && strchr_w(punct_stop,c1)!=NULL)
- return(punct_attributes[lookupwchar(punct_chars,c1)]);
-
- return(CLAUSE_SHORTCOMMA);
-} // end of AnnouncePunctuation
-
-#define SSML_SPEAK 1
-#define SSML_VOICE 2
-#define SSML_PROSODY 3
-#define SSML_SAYAS 4
-#define SSML_MARK 5
-#define SSML_SENTENCE 6
-#define SSML_PARAGRAPH 7
-#define SSML_PHONEME 8
-#define SSML_SUB 9
-#define SSML_STYLE 10
-#define SSML_AUDIO 11
-#define SSML_EMPHASIS 12
-#define SSML_BREAK 13
-#define SSML_IGNORE_TEXT 14
-#define HTML_BREAK 15
-#define SSML_CLOSE 0x10 // for a closing tag, OR this with the tag type
-
-// these tags have no effect if they are self-closing, eg. <voice />
-static char ignore_if_self_closing[] = {0,1,1,1,1,0,0,0,0,1,1,0,1,0,1,0,0};
-
-
-static MNEM_TAB ssmltags[] = {
- {"speak", SSML_SPEAK},
- {"voice", SSML_VOICE},
- {"prosody", SSML_PROSODY},
- {"say-as", SSML_SAYAS},
- {"mark", SSML_MARK},
- {"s", SSML_SENTENCE},
- {"p", SSML_PARAGRAPH},
- {"phoneme", SSML_PHONEME},
- {"sub", SSML_SUB},
- {"tts:style", SSML_STYLE},
- {"audio", SSML_AUDIO},
- {"emphasis", SSML_EMPHASIS},
- {"break", SSML_BREAK},
- {"metadata", SSML_IGNORE_TEXT},
-
- {"br", HTML_BREAK},
- {"li", HTML_BREAK},
- {"img", HTML_BREAK},
- {"td", HTML_BREAK},
- {"h1", SSML_PARAGRAPH},
- {"h2", SSML_PARAGRAPH},
- {"h3", SSML_PARAGRAPH},
- {"h4", SSML_PARAGRAPH},
- {"hr", SSML_PARAGRAPH},
- {"script", SSML_IGNORE_TEXT},
- {"style", SSML_IGNORE_TEXT},
- {NULL,0}};
-
-
-
-
-static const char *VoiceFromStack()
-{//================================
-// Use the voice properties from the SSML stack to choose a voice, and switch
-// to that voice if it's not the current voice
- int ix;
- SSML_STACK *sp;
- const char *v_id;
- int voice_name_specified;
- int voice_found;
- espeak_VOICE voice_select;
- char voice_name[40];
- char language[40];
-
- strcpy(voice_name,ssml_stack[0].voice_name);
- strcpy(language,ssml_stack[0].language);
- voice_select.age = ssml_stack[0].voice_age;
- voice_select.gender = ssml_stack[0].voice_gender;
- voice_select.variant = ssml_stack[0].voice_variant;
- voice_select.identifier = NULL;
-
- for(ix=0; ix<n_ssml_stack; ix++)
- {
- sp = &ssml_stack[ix];
- voice_name_specified = 0;
-
- if((sp->voice_name[0] != 0) && (SelectVoiceByName(NULL,sp->voice_name) != NULL))
- {
- voice_name_specified = 1;
- strcpy(voice_name, sp->voice_name);
- language[0] = 0;
- voice_select.gender = 0;
- voice_select.age = 0;
- voice_select.variant = 0;
- }
- if(sp->language[0] != 0)
- {
- strcpy(language, sp->language);
- if(voice_name_specified == 0)
- voice_name[0] = 0; // forget a previous voice name if a language is specified
- }
- if(sp->voice_gender != 0)
- voice_select.gender = sp->voice_gender;
- if(sp->voice_age != 0)
- voice_select.age = sp->voice_age;
- if(sp->voice_variant != 0)
- voice_select.variant = sp->voice_variant;
- }
-
- voice_select.name = voice_name;
- voice_select.languages = language;
- v_id = SelectVoice(&voice_select, &voice_found);
- if(v_id == NULL)
- return("default");
- return(v_id);
-} // end of VoiceFromStack
-
-
-
-static void ProcessParamStack(char *outbuf, int *outix)
-{//====================================================
-// Set the speech parameters from the parameter stack
- int param;
- int ix;
- int value;
- char buf[20];
- int new_parameters[N_SPEECH_PARAM];
- static char cmd_letter[N_SPEECH_PARAM] = {0, 'S','A','P','R', 0, 0, 0, 0, 0, 0, 0, 'F'}; // embedded command letters
-
-
- for(param=0; param<N_SPEECH_PARAM; param++)
- new_parameters[param] = -1;
-
- for(ix=0; ix<n_param_stack; ix++)
- {
- for(param=0; param<N_SPEECH_PARAM; param++)
- {
- if(param_stack[ix].parameter[param] >= 0)
- new_parameters[param] = param_stack[ix].parameter[param];
- }
- }
-
- for(param=0; param<N_SPEECH_PARAM; param++)
- {
- if((value = new_parameters[param]) != speech_parameters[param])
- {
- buf[0] = 0;
-
- switch(param)
- {
- case espeakPUNCTUATION:
- option_punctuation = value-1;
- break;
-
- case espeakCAPITALS:
- option_capitals = value;
- break;
-
- case espeakRATE:
- case espeakVOLUME:
- case espeakPITCH:
- case espeakRANGE:
- case espeakEMPHASIS:
- sprintf(buf,"%c%d%c",CTRL_EMBEDDED,value,cmd_letter[param]);
- break;
- }
-
- speech_parameters[param] = new_parameters[param];
- strcpy(&outbuf[*outix],buf);
- (*outix) += strlen(buf);
- }
- }
-} // end of ProcessParamStack
-
-
-static PARAM_STACK *PushParamStack(int tag_type)
-{//=============================================
- int ix;
- PARAM_STACK *sp;
-
- sp = &param_stack[n_param_stack];
- if(n_param_stack < (N_PARAM_STACK-1))
- n_param_stack++;
-
- sp->type = tag_type;
- for(ix=0; ix<N_SPEECH_PARAM; ix++)
- {
- sp->parameter[ix] = -1;
- }
- return(sp);
-} // end of PushParamStack
-
-
-static void PopParamStack(int tag_type, char *outbuf, int *outix)
-{//==============================================================
- // unwind the stack up to and including the previous tag of this type
- int ix;
- int top = 0;
-
- if(tag_type >= SSML_CLOSE)
- tag_type -= SSML_CLOSE;
-
- for(ix=0; ix<n_param_stack; ix++)
- {
- if(param_stack[ix].type == tag_type)
- {
- top = ix;
- }
- }
- if(top > 0)
- {
- n_param_stack = top;
- }
- ProcessParamStack(outbuf, outix);
-} // end of PopParamStack
-
-
-
-static wchar_t *GetSsmlAttribute(wchar_t *pw, const char *name)
-{//============================================================
-// Gets the value string for an attribute.
-// Returns NULL if the attribute is not present
- int ix;
- static wchar_t empty[1] = {0};
-
- while(*pw != 0)
- {
- if(iswspace(pw[-1]))
- {
- ix = 0;
- while(*pw == name[ix])
- {
- pw++;
- ix++;
- }
- if(name[ix]==0)
- {
- // found the attribute, now get the value
- while(iswspace(*pw)) pw++;
- if(*pw == '=') pw++;
- while(iswspace(*pw)) pw++;
- if(*pw == '"')
- return(pw+1);
- else
- return(empty);
- }
- }
- pw++;
- }
- return(NULL);
-} // end of GetSsmlAttribute
-
-
-static int attrcmp(const wchar_t *string1, const char *string2)
-{//============================================================
- int ix;
-
- if(string1 == NULL)
- return(1);
-
- for(ix=0; (string1[ix] == string2[ix]) && (string1[ix] != 0); ix++)
- {
- }
- if((string1[ix]=='"') && (string2[ix]==0))
- return(0);
- return(1);
-}
-
-
-static int attrlookup(const wchar_t *string1, const MNEM_TAB *mtab)
-{//================================================================
- int ix;
-
- for(ix=0; mtab[ix].mnem != NULL; ix++)
- {
- if(attrcmp(string1,mtab[ix].mnem) == 0)
- return(mtab[ix].value);
- }
- return(mtab[ix].value);
-}
-
-
-static int attrnumber(const wchar_t *pw, int default_value, int type)
-{//==================================================================
- int value = 0;
-
- if((pw == NULL) || !isdigit(*pw))
- return(default_value);
-
- while(isdigit(*pw))
- {
- value = value*10 + *pw++ - '0';
- }
- if((type==1) && (towlower(*pw)=='s'))
- {
- // time: seconds rather than ms
- value *= 1000;
- }
- return(value);
-} // end of attrnumber
-
-
-
-static int attrcopy_utf8(char *buf, const wchar_t *pw, int len)
-{//============================================================
-// Convert attribute string into utf8, write to buf, and return its utf8 length
- unsigned int c;
- int ix = 0;
- int n;
- int prev_c = 0;
-
- if(pw != NULL)
- {
- while((ix < (len-4)) && ((c = *pw++) != 0))
- {
- if((c=='"') && (prev_c != '\\'))
- break; // " indicates end of attribute, unless preceded by backstroke
- n = utf8_out(c,&buf[ix]);
- ix += n;
- prev_c = c;
- }
- }
- buf[ix] = 0;
- return(ix);
-} // end of attrcopy_utf8
-
-
-
-static int attr_prosody_value(int param_type, const wchar_t *pw, int *value_out)
-{//=============================================================================
- int sign = 0;
- wchar_t *tail;
- float value;
-
- while(iswspace(*pw)) pw++;
- if(*pw == '+')
- {
- pw++;
- sign = 1;
- }
- if(*pw == '-')
- {
- pw++;
- sign = -1;
- }
- value = (float)wcstod(pw,&tail);
- if(tail == pw)
- {
- // failed to find a number, return 100%
- *value_out = 100;
- return(2);
- }
-
- if(*tail == '%')
- {
- if(sign != 0)
- value = 100 + (sign * value);
- *value_out = (int)value;
- return(2); // percentage
- }
-
- if((tail[0]=='s') && (tail[1]=='t'))
- {
- double x;
- // convert from semitones to a frequency percentage
- x = pow(double(2.0),double((value*sign)/12)) * 100;
- *value_out = (int)x;
- return(2); // percentage
- }
-
- if(param_type == espeakRATE)
- {
- *value_out = (int)(value * 100);
- return(2); // percentage
- }
-
- *value_out = (int)value;
- return(sign); // -1, 0, or 1
-} // end of attr_prosody_value
-
-
-int AddNameData(const char *name, int wide)
-{//========================================
-// Add the name to the namedata and return its position
-// (Used by the Windows SAPI wrapper)
- int ix;
- int len;
- void *vp;
-
- if(wide)
- {
- len = (wcslen((const wchar_t *)name)+1)*sizeof(wchar_t);
- n_namedata = (n_namedata + sizeof(wchar_t) - 1) % sizeof(wchar_t); // round to wchar_t boundary
- }
- else
- {
- len = strlen(name)+1;
- }
-
- if(namedata_ix+len >= n_namedata)
- {
- // allocate more space for marker names
- if((vp = realloc(namedata, namedata_ix+len + 300)) == NULL)
- return(-1); // failed to allocate, original data is unchanged but ignore this new name
-
- namedata = (char *)vp;
- n_namedata = namedata_ix+len + 300;
- }
- memcpy(&namedata[ix = namedata_ix],name,len);
- namedata_ix += len;
- return(ix);
-} // end of AddNameData
-
-
-void SetVoiceStack(espeak_VOICE *v)
-{//================================
- SSML_STACK *sp;
- sp = &ssml_stack[0];
-
- if(v == NULL)
- {
- memset(sp,0,sizeof(ssml_stack[0]));
- return;
- }
- if(v->languages != NULL)
- strcpy(sp->language,v->languages);
- if(v->name != NULL)
- strcpy(sp->voice_name,v->name);
- sp->voice_variant = v->variant;
- sp->voice_age = v->age;
- sp->voice_gender = v->gender;
-}
-
-
-static int GetVoiceAttributes(wchar_t *pw, int tag_type)
-{//=====================================================
-// Determines whether voice attribute are specified in this tag, and if so, whether this means
-// a voice change.
-// If it's a closing tag, delete the top frame of the stack and determine whether this implies
-// a voice change.
-// Returns CLAUSE_BIT_VOICE if there is a voice change
-
- wchar_t *lang;
- wchar_t *gender;
- wchar_t *name;
- wchar_t *age;
- wchar_t *variant;
- const char *new_voice_id;
- SSML_STACK *ssml_sp;
-
- static const MNEM_TAB mnem_gender[] = {
- {"male", 1},
- {"female", 2},
- {"neutral", 3},
- {NULL, 0}};
-
- if(tag_type & SSML_CLOSE)
- {
- // delete a stack frame
- if(n_ssml_stack > 1)
- {
- n_ssml_stack--;
- }
- }
- else
- {
- // add a stack frame if any voice details are specified
- lang = GetSsmlAttribute(pw,"xml:lang");
-
- if(tag_type != SSML_VOICE)
- {
- // only expect an xml:lang attribute
- name = NULL;
- variant = NULL;
- age = NULL;
- gender = NULL;
- }
- else
- {
- name = GetSsmlAttribute(pw,"name");
- variant = GetSsmlAttribute(pw,"variant");
- age = GetSsmlAttribute(pw,"age");
- gender = GetSsmlAttribute(pw,"gender");
- }
-
- if((tag_type != SSML_VOICE) && (lang==NULL))
- return(0); // <s> or <p> without language spec, nothing to do
-
- ssml_sp = &ssml_stack[n_ssml_stack++];
-
- attrcopy_utf8(ssml_sp->language,lang,sizeof(ssml_sp->language));
- attrcopy_utf8(ssml_sp->voice_name,name,sizeof(ssml_sp->voice_name));
- ssml_sp->voice_variant = attrnumber(variant,1,0)-1;
- ssml_sp->voice_age = attrnumber(age,0,0);
- ssml_sp->voice_gender = attrlookup(gender,mnem_gender);
- ssml_sp->tag_type = tag_type;
- }
-
- new_voice_id = VoiceFromStack();
- if(strcmp(new_voice_id,current_voice_id) != 0)
- {
- // add an embedded command to change the voice
- strcpy(current_voice_id,new_voice_id);
- return(CLAUSE_BIT_VOICE); // change of voice
- }
-
- return(0);
-} // end of GetVoiceAttributes
-
-
-static void SetProsodyParameter(int param_type, wchar_t *attr1, PARAM_STACK *sp)
-{//=============================================================================
- int value;
- int sign;
-
- static const MNEM_TAB mnem_volume[] = {
- {"default",100},
- {"silent",0},
- {"x-soft",30},
- {"soft",65},
- {"medium",100},
- {"loud",150},
- {"x-loud",230},
- {NULL, -1}};
-
- static const MNEM_TAB mnem_rate[] = {
- {"default",100},
- {"x-slow",60},
- {"slow",80},
- {"medium",100},
- {"fast",120},
- {"x-fast",150},
- {NULL, -1}};
-
- static const MNEM_TAB mnem_pitch[] = {
- {"default",100},
- {"x-low",70},
- {"low",85},
- {"medium",100},
- {"high",110},
- {"x-high",120},
- {NULL, -1}};
-
- static const MNEM_TAB mnem_range[] = {
- {"default",100},
- {"x-low",20},
- {"low",50},
- {"medium",100},
- {"high",140},
- {"x-high",180},
- {NULL, -1}};
-
- static const MNEM_TAB *mnem_tabs[5] = {
- NULL, mnem_rate, mnem_volume, mnem_pitch, mnem_range };
-
-
- if((value = attrlookup(attr1,mnem_tabs[param_type])) >= 0)
- {
- // mnemonic specifies a value as a percentage of the base pitch/range/rate/volume
- sp->parameter[param_type] = (param_stack[0].parameter[param_type] * value)/100;
- }
- else
- {
- sign = attr_prosody_value(param_type,attr1,&value);
-
- if(sign == 0)
- sp->parameter[param_type] = value; // absolute value in Hz
- else
- if(sign == 2)
- {
- // change specified as percentage or in semitones
- sp->parameter[param_type] = (speech_parameters[param_type] * value)/100;
- }
- else
- {
- // change specified as plus or minus Hz
- sp->parameter[param_type] = speech_parameters[param_type] + (value*sign);
- }
- }
-} // end of SetProsodyParemeter
-
-
-
-static int ProcessSsmlTag(wchar_t *xml_buf, char *outbuf, int *outix, int n_outbuf, int self_closing)
-{//==================================================================================================
-// xml_buf is the tag and attributes with a zero terminator in place of the original '>'
-// returns a clause terminator value.
-
- unsigned int ix;
- int index;
- int c;
- int tag_type;
- int value;
- int value2;
- int value3;
- int voice_change_flag;
- wchar_t *px;
- wchar_t *attr1;
- wchar_t *attr2;
- wchar_t *attr3;
- int terminator;
- char *uri;
- int param_type;
- char tag_name[40];
- char buf[80];
- PARAM_STACK *sp;
- SSML_STACK *ssml_sp;
-
- static const MNEM_TAB mnem_punct[] = {
- {"none", 1},
- {"all", 2},
- {"some", 3},
- {NULL, -1}};
-
- static const MNEM_TAB mnem_capitals[] = {
- {"no", 0},
- {"spelling", 2},
- {"icon", 1},
- {"pitch", 20}, // this is the amount by which to raise the pitch
- {NULL, -1}};
-
- static const MNEM_TAB mnem_interpret_as[] = {
- {"characters",SAYAS_CHARS},
- {"tts:char",SAYAS_SINGLE_CHARS},
- {"tts:key",SAYAS_KEY},
- {"tts:digits",SAYAS_DIGITS},
- {"telephone",SAYAS_DIGITS1},
- {NULL, -1}};
-
- static const MNEM_TAB mnem_sayas_format[] = {
- {"glyphs",1},
- {NULL, -1}};
-
- static const MNEM_TAB mnem_break[] = {
- {"none",0},
- {"x-weak",1},
- {"weak",2},
- {"medium",3},
- {"strong",4},
- {"x-strong",5},
- {NULL,-1}};
-
- static const MNEM_TAB mnem_emphasis[] = {
- {"none",1},
- {"reduced",2},
- {"moderate",3},
- {"strong",4},
- {NULL,-1}};
-
- static const char *prosody_attr[5] = {
- NULL, "rate", "volume", "pitch", "range" };
-
- for(ix=0; ix<(sizeof(tag_name)-1); ix++)
- {
- if(((c = xml_buf[ix]) == 0) || iswspace(c))
- break;
- tag_name[ix] = tolower((char)c);
- }
- tag_name[ix] = 0;
-
- px = &xml_buf[ix]; // the tag's attributes
-
- if(tag_name[0] == '/')
- {
- tag_type = LookupMnem(ssmltags,&tag_name[1]) + SSML_CLOSE; // closing tag
- }
- else
- {
- tag_type = LookupMnem(ssmltags,tag_name);
-
- if(self_closing && ignore_if_self_closing[tag_type])
- return(0);
- }
-
- voice_change_flag = 0;
- terminator = CLAUSE_NONE;
- ssml_sp = &ssml_stack[n_ssml_stack-1];
-
- switch(tag_type)
- {
- case SSML_STYLE:
- sp = PushParamStack(tag_type);
- attr1 = GetSsmlAttribute(px,"field");
- attr2 = GetSsmlAttribute(px,"mode");
-
-
- if(attrcmp(attr1,"punctuation")==0)
- {
- value = attrlookup(attr2,mnem_punct);
- sp->parameter[espeakPUNCTUATION] = value;
- }
- else
- if(attrcmp(attr1,"capital_letters")==0)
- {
- value = attrlookup(attr2,mnem_capitals);
- sp->parameter[espeakCAPITALS] = value;
- }
- ProcessParamStack(outbuf, outix);
- break;
-
- case SSML_PROSODY:
- sp = PushParamStack(tag_type);
-
- // look for attributes: rate, volume, pitch, range
- for(param_type=espeakRATE; param_type <= espeakRANGE; param_type++)
- {
- if((attr1 = GetSsmlAttribute(px,prosody_attr[param_type])) != NULL)
- {
- SetProsodyParameter(param_type, attr1, sp);
- }
- }
-
- ProcessParamStack(outbuf, outix);
- break;
-
- case SSML_EMPHASIS:
- sp = PushParamStack(tag_type);
- value = 3; // default is "moderate"
- if((attr1 = GetSsmlAttribute(px,"level")) != NULL)
- {
- value = attrlookup(attr1,mnem_emphasis);
- }
-
- if(translator->langopts.tone_language == 1)
- {
- static unsigned char emphasis_to_pitch_range[] = {50,50,40,70,90,90};
- static unsigned char emphasis_to_volume[] = {100,100,70,110,140,140};
- // tone language (eg.Chinese) do emphasis by increasing the pitch range.
- sp->parameter[espeakRANGE] = emphasis_to_pitch_range[value];
- sp->parameter[espeakVOLUME] = emphasis_to_volume[value];
- }
- else
- {
- sp->parameter[espeakEMPHASIS] = value;
- }
- ProcessParamStack(outbuf, outix);
- break;
-
- case SSML_STYLE + SSML_CLOSE:
- case SSML_PROSODY + SSML_CLOSE:
- case SSML_EMPHASIS + SSML_CLOSE:
- PopParamStack(tag_type, outbuf, outix);
- break;
-
- case SSML_SAYAS:
- attr1 = GetSsmlAttribute(px,"interpret-as");
- attr2 = GetSsmlAttribute(px,"format");
- attr3 = GetSsmlAttribute(px,"detail");
- value = attrlookup(attr1,mnem_interpret_as);
- value2 = attrlookup(attr2,mnem_sayas_format);
- if(value2 == 1)
- value = SAYAS_GLYPHS;
-
- value3 = attrnumber(attr3,0,0);
-
- if(value == SAYAS_DIGITS)
- {
- if(value3 <= 1)
- value = SAYAS_DIGITS1;
- else
- value = SAYAS_DIGITS + value3;
- }
-
- sprintf(buf,"%c%dY",CTRL_EMBEDDED,value);
- strcpy(&outbuf[*outix],buf);
- (*outix) += strlen(buf);
-
- sayas_mode = value; // punctuation doesn't end clause during SAY-AS
- break;
-
- case SSML_SAYAS + SSML_CLOSE:
- outbuf[(*outix)++] = CTRL_EMBEDDED;
- outbuf[(*outix)++] = 'Y';
- sayas_mode = 0;
- break;
-
- case SSML_SUB:
- if((attr1 = GetSsmlAttribute(px,"alias")) != NULL)
- {
- // use the alias rather than the text
- ignore_text = 1;
- (*outix) += attrcopy_utf8(&outbuf[*outix],attr1,n_outbuf-*outix);
- }
- break;
-
- case SSML_IGNORE_TEXT:
- ignore_text = 1;
- break;
-
- case SSML_SUB + SSML_CLOSE:
- case SSML_IGNORE_TEXT + SSML_CLOSE:
- ignore_text = 0;
- break;
-
- case SSML_MARK:
- if((attr1 = GetSsmlAttribute(px,"name")) != NULL)
- {
- // add name to circular buffer of marker names
- attrcopy_utf8(buf,attr1,sizeof(buf));
-
- if(strcmp(skip_marker,buf)==0)
- {
- // This is the marker we are waiting for before starting to speak
- clear_skipping_text = 1;
- skip_marker[0] = 0;
- return(CLAUSE_NONE);
- }
-
- if((index = AddNameData(buf,0)) >= 0)
- {
- sprintf(buf,"%c%dM",CTRL_EMBEDDED,index);
- strcpy(&outbuf[*outix],buf);
- (*outix) += strlen(buf);
- }
- }
- break;
-
- case SSML_AUDIO:
- sp = PushParamStack(tag_type);
-
- if((attr1 = GetSsmlAttribute(px,"src")) != NULL)
- {
- char fname[256];
- attrcopy_utf8(buf,attr1,sizeof(buf));
-
- if(uri_callback == NULL)
- {
- if((xmlbase != NULL) && (buf[0] != '/'))
- {
- sprintf(fname,"%s/%s",xmlbase,buf);
- index = LoadSoundFile2(fname);
- }
- else
- {
- index = LoadSoundFile2(buf);
- }
- if(index >= 0)
- {
- sprintf(buf,"%c%dI",CTRL_EMBEDDED,index);
- strcpy(&outbuf[*outix],buf);
- (*outix) += strlen(buf);
- sp->parameter[espeakSILENCE] = 1;
- }
- }
- else
- {
- if((index = AddNameData(buf,0)) >= 0)
- {
- uri = &namedata[index];
- if(uri_callback(1,uri,xmlbase) == 0)
- {
- sprintf(buf,"%c%dU",CTRL_EMBEDDED,index);
- strcpy(&outbuf[*outix],buf);
- (*outix) += strlen(buf);
- sp->parameter[espeakSILENCE] = 1;
- }
- }
- }
- }
- ProcessParamStack(outbuf, outix);
-
- if(self_closing)
- PopParamStack(tag_type, outbuf, outix);
- return(CLAUSE_NONE);
-
- case SSML_AUDIO + SSML_CLOSE:
- PopParamStack(tag_type, outbuf, outix);
- return(CLAUSE_NONE);
-
- case SSML_BREAK:
- value = 21;
- terminator = CLAUSE_NONE;
-
- if((attr1 = GetSsmlAttribute(px,"strength")) != NULL)
- {
- static int break_value[6] = {0,7,14,21,40,80}; // *10mS
- value = attrlookup(attr1,mnem_break);
- if(value < 3)
- {
- // adjust prepause on the following word
- sprintf(&outbuf[*outix],"%c%dB",CTRL_EMBEDDED,value);
- (*outix) += 3;
- terminator = 0;
- }
- value = break_value[value];
- }
- if((attr2 = GetSsmlAttribute(px,"time")) != NULL)
- {
- value = (attrnumber(attr2,0,1) * 25) / speed.speed_factor1; // compensate for speaking speed to keep constant pause length
-
- if(terminator == 0)
- terminator = CLAUSE_NONE;
- }
- if(terminator)
- {
- if(value > 0xfff)
- value = 0xfff;
- return(terminator + value);
- }
- break;
-
- case SSML_SPEAK:
- if((attr1 = GetSsmlAttribute(px,"xml:base")) != NULL)
- {
- attrcopy_utf8(buf,attr1,sizeof(buf));
- if((index = AddNameData(buf,0)) >= 0)
- {
- xmlbase = &namedata[index];
- }
- }
- if(GetVoiceAttributes(px, tag_type) == 0)
- return(0); // no voice change
- return(CLAUSE_VOICE);
-
- case SSML_VOICE:
- if(GetVoiceAttributes(px, tag_type) == 0)
- return(0); // no voice change
- return(CLAUSE_VOICE);
-
- case SSML_SPEAK + SSML_CLOSE:
- // unwind stack until the previous <voice> or <speak> tag
- while((n_ssml_stack > 1) && (ssml_stack[n_ssml_stack-1].tag_type != SSML_SPEAK))
- {
- n_ssml_stack--;
- }
- return(CLAUSE_PERIOD + GetVoiceAttributes(px, tag_type));
-
- case SSML_VOICE + SSML_CLOSE:
- // unwind stack until the previous <voice> or <speak> tag
- while((n_ssml_stack > 1) && (ssml_stack[n_ssml_stack-1].tag_type != SSML_VOICE))
- {
- n_ssml_stack--;
- }
-
-terminator=0; // ?? Sentence intonation, but no pause ??
- return(terminator + GetVoiceAttributes(px, tag_type));
-
- case HTML_BREAK:
- case HTML_BREAK + SSML_CLOSE:
- return(CLAUSE_COLON);
-
- case SSML_SENTENCE:
- if(ssml_sp->tag_type == SSML_SENTENCE)
- {
- // new sentence implies end-of-sentence
- voice_change_flag = GetVoiceAttributes(px, SSML_SENTENCE+SSML_CLOSE);
- }
- voice_change_flag |= GetVoiceAttributes(px, tag_type);
- return(CLAUSE_PARAGRAPH + voice_change_flag);
-
-
- case SSML_PARAGRAPH:
- if(ssml_sp->tag_type == SSML_SENTENCE)
- {
- // new paragraph implies end-of-sentence or end-of-paragraph
- voice_change_flag = GetVoiceAttributes(px, SSML_SENTENCE+SSML_CLOSE);
- }
- if(ssml_sp->tag_type == SSML_PARAGRAPH)
- {
- // new paragraph implies end-of-sentence or end-of-paragraph
- voice_change_flag |= GetVoiceAttributes(px, SSML_PARAGRAPH+SSML_CLOSE);
- }
- voice_change_flag |= GetVoiceAttributes(px, tag_type);
- return(CLAUSE_PARAGRAPH + voice_change_flag);
-
-
- case SSML_SENTENCE + SSML_CLOSE:
- if(ssml_sp->tag_type == SSML_SENTENCE)
- {
- // end of a sentence which specified a language
- voice_change_flag = GetVoiceAttributes(px, tag_type);
- }
- return(CLAUSE_PERIOD + voice_change_flag);
-
-
- case SSML_PARAGRAPH + SSML_CLOSE:
- if((ssml_sp->tag_type == SSML_SENTENCE) || (ssml_sp->tag_type == SSML_PARAGRAPH))
- {
- // End of a paragraph which specified a language.
- // (End-of-paragraph also implies end-of-sentence)
- return(GetVoiceAttributes(px, tag_type) + CLAUSE_PARAGRAPH);
- }
- return(CLAUSE_PARAGRAPH);
- }
- return(0);
-} // end of ProcessSsmlTag
-
-
-static MNEM_TAB xml_char_mnemonics[] = {
- {"gt",'>'},
- {"lt",'<'},
- {"amp", '&'},
- {"quot", '"'},
- {"nbsp", ' '},
- {"apos", '\''},
- {NULL,-1}};
-
-
-int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type)
-{//=============================================================================================================
-/* Find the end of the current clause.
- Write the clause into buf
-
- returns: clause type (bits 0-7: pause x10mS, bits 8-11 intonation type)
-
- Also checks for blank line (paragraph) as end-of-clause indicator.
-
- Does not end clause for:
- punctuation immediately followed by alphanumeric eg. 1.23 !Speak :path
- repeated punctuation, eg. ... !!!
-*/
- int c1=' '; // current character
- int c2; // next character
- int cprev=' '; // previous character
- int parag;
- int ix = 0;
- int j;
- int nl_count;
- int linelength = 0;
- int phoneme_mode = 0;
- int n_xml_buf;
- int terminator;
- int punct;
- int found;
- int any_alnum = 0;
- int self_closing;
- int punct_data;
- int stressed_word = 0;
- const char *p;
- wchar_t xml_buf[N_XML_BUF+1];
-
-#define N_XML_BUF2 20
- char xml_buf2[N_XML_BUF2+2]; // for &<name> and &<number> sequences
- static char ungot_string[N_XML_BUF2+4];
- static int ungot_string_ix = -1;
-
- if(clear_skipping_text)
- {
- skipping_text = 0;
- clear_skipping_text = 0;
- }
-
- tr->clause_upper_count = 0;
- tr->clause_lower_count = 0;
- end_of_input = 0;
- *tone_type = 0;
-
-f_input = f_in; // for GetC etc
-
- if(ungot_word != NULL)
- {
- strcpy(buf,ungot_word);
- ix += strlen(ungot_word);
- ungot_word = NULL;
- }
-
- if(ungot_char2 != 0)
- {
- c2 = ungot_char2;
- }
- else
- {
- c2 = GetC();
- }
-
- while(!Eof() || (ungot_char != 0) || (ungot_char2 != 0) || (ungot_string_ix >= 0))
- {
- if(!iswalnum(c1))
- {
- if((end_character_position > 0) && (count_characters > end_character_position))
- {
- end_of_input = 1;
- return(CLAUSE_EOF);
- }
-
- if((skip_characters > 0) && (count_characters > skip_characters))
- {
- // reached the specified start position
- // don't break a word
- clear_skipping_text = 1;
- skip_characters = 0;
- UngetC(c2);
- return(CLAUSE_NONE);
- }
- }
-
- cprev = c1;
- c1 = c2;
-
- if(ungot_string_ix >= 0)
- {
- if(ungot_string[ungot_string_ix] == 0)
- ungot_string_ix = -1;
- }
-
- if((ungot_string_ix == 0) && (ungot_char2 == 0))
- {
- c1 = ungot_string[ungot_string_ix++];
- }
- if(ungot_string_ix >= 0)
- {
- c2 = ungot_string[ungot_string_ix++];
- }
- else
- {
- c2 = GetC();
-
- if(Eof())
- {
- c2 = ' ';
- }
- }
- ungot_char2 = 0;
-
- if((option_ssml) && (phoneme_mode==0))
- {
- if((ssml_ignore_l_angle != '&') && (c1 == '&') && ((c2=='#') || ((c2 >= 'a') && (c2 <= 'z'))))
- {
- n_xml_buf = 0;
- c1 = c2;
- while(!Eof() && (iswalnum(c1) || (c1=='#')) && (n_xml_buf < N_XML_BUF2))
- {
- xml_buf2[n_xml_buf++] = c1;
- c1 = GetC();
- }
- xml_buf2[n_xml_buf] = 0;
- c2 = GetC();
- sprintf(ungot_string,"%s%c%c",&xml_buf2[0],c1,c2);
-
- if(c1 == ';')
- {
- if(xml_buf2[0] == '#')
- {
- // character code number
- if(xml_buf2[1] == 'x')
- found = sscanf(&xml_buf2[2],"%x",(unsigned int *)(&c1));
- else
- found = sscanf(&xml_buf2[1],"%d",&c1);
- }
- else
- {
- if((found = LookupMnem(xml_char_mnemonics,xml_buf2)) != -1)
- {
- c1 = found;
- if(c2 == 0)
- c2 = ' ';
- }
- }
- }
- else
- {
- found = -1;
- }
-
- if(found <= 0)
- {
- ungot_string_ix = 0;
- c1 = '&';
- c2 = ' ';
- }
-
- if((c1 <= 0x20) && ((sayas_mode == SAYAS_SINGLE_CHARS) || (sayas_mode == SAYAS_KEY)))
- {
- c1 += 0xe000; // move into unicode private usage area
- }
- }
- else
- if((c1 == '<') && (ssml_ignore_l_angle != '<'))
- {
- if(c2 == '!')
- {
- // a comment, ignore until closing '<'
- while(!Eof() && (c1 != '>'))
- {
- c1 = GetC();
- }
- c2 = ' ';
- }
- else
- if((c2 == '/') || iswalpha(c2))
- {
- // SSML Tag
- n_xml_buf = 0;
- c1 = c2;
- while(!Eof() && (c1 != '>') && (n_xml_buf < N_XML_BUF))
- {
- xml_buf[n_xml_buf++] = c1;
- c1 = GetC();
- }
- xml_buf[n_xml_buf] = 0;
- c2 = ' ';
-
- buf[ix++] = ' ';
-
- self_closing = 0;
- if(xml_buf[n_xml_buf-1] == '/')
- {
- // a self-closing tag
- xml_buf[n_xml_buf-1] = ' ';
- self_closing = 1;
- }
-
- terminator = ProcessSsmlTag(xml_buf,buf,ix,n_buf,self_closing);
-
- if(terminator != 0)
- {
- buf[ix] = ' ';
- buf[ix++] = 0;
-
- if(terminator & CLAUSE_BIT_VOICE)
- {
- // a change in voice, write the new voice name to the end of the buf
- p = current_voice_id;
- while((*p != 0) && (ix < (n_buf-1)))
- {
- buf[ix++] = *p++;
- }
- buf[ix++] = 0;
- }
- return(terminator);
- }
- continue;
- }
- }
- }
- ssml_ignore_l_angle=0;
-
- if(ignore_text)
- continue;
-
- if((c2=='\n') && (option_linelength == -1))
- {
- // single-line mode, return immediately on NL
- if((punct = lookupwchar(punct_chars,c1)) == 0)
- {
- charix[ix] = count_characters - clause_start_char;
- *charix_top = ix;
- ix += utf8_out(c1,&buf[ix]);
- terminator = CLAUSE_PERIOD; // line doesn't end in punctuation, assume period
- }
- else
- {
- terminator = punct_attributes[punct];
- }
- buf[ix] = ' ';
- buf[ix+1] = 0;
- return(terminator);
- }
-
- if((c1 == CTRL_EMBEDDED) || (c1 == ctrl_embedded))
- {
- // an embedded command. If it's a voice change, end the clause
- if(c2 == 'V')
- {
- buf[ix++] = 0; // end the clause at this point
- while(!iswspace(c1 = GetC()) && !Eof() && (ix < (n_buf-1)))
- buf[ix++] = c1; // add voice name to end of buffer, after the text
- buf[ix++] = 0;
- return(CLAUSE_VOICE);
- }
- else
- if(c2 == 'B')
- {
- // set the punctuation option from an embedded command
- // B0 B1 B<punct list><space>
- strcpy(&buf[ix]," ");
- ix += 3;
-
- if((c2 = GetC()) == '0')
- option_punctuation = 0;
- else
- {
- option_punctuation = 1;
- option_punctlist[0] = 0;
- if(c2 != '1')
- {
- // a list of punctuation characters to be spoken, terminated by space
- j = 0;
- while(!iswspace(c2) && !Eof())
- {
- option_punctlist[j++] = c2;
- c2 = GetC();
- buf[ix++] = ' ';
- }
- option_punctlist[j] = 0; // terminate punctuation list
- option_punctuation = 2;
- }
- }
- c2 = GetC();
- continue;
- }
- }
-
- linelength++;
-
- if(iswalnum(c1))
- any_alnum = 1;
- else
- {
- if(stressed_word)
- {
- stressed_word = 0;
- c1 = CHAR_EMPHASIS; // indicate this word is stressed
- UngetC(c2);
- c2 = ' ';
- }
-
- if(iswspace(c1))
- {
- char *p_word;
-
- if(tr->translator_name == 0x6a626f)
- {
- // language jbo : lojban
- // treat "i" or ".i" as end-of-sentence
- p_word = &buf[ix-1];
- if(p_word[0] == 'i')
- {
- if(p_word[-1] == '.')
- p_word--;
- if(p_word[-1] == ' ')
- {
- ungot_word = "i ";
- UngetC(c2);
- p_word[0] = 0;
- return(CLAUSE_PERIOD);
- }
- }
- }
- }
- }
-
- if(iswupper(c1))
- {
- tr->clause_upper_count++;
- if((option_capitals == 2) && (sayas_mode == 0) && !iswupper(cprev))
- {
- char text_buf[40];
- char text_buf2[30];
- if(LookupSpecial(tr, "_cap", text_buf2) != NULL)
- {
- sprintf(text_buf,"%s%s%s",tone_punct_on,text_buf2,tone_punct_off);
- j = strlen(text_buf);
- if((ix + j) < n_buf)
- {
- strcpy(&buf[ix],text_buf);
- ix += j;
- }
- }
- }
- }
- else
- if(iswalpha(c1))
- tr->clause_lower_count++;
-
- if(option_phoneme_input)
- {
- if(phoneme_mode > 0)
- phoneme_mode--;
- else
- if((c1 == '[') && (c2 == '['))
- phoneme_mode = -1; // input is phoneme mnemonics, so don't look for punctuation
- else
- if((c1 == ']') && (c2 == ']'))
- phoneme_mode = 2; // set phoneme_mode to zero after the next two characters
- }
-
- if(c1 == '\n')
- {
- parag = 0;
-
- // count consecutive newlines, ignoring other spaces
- while(!Eof() && iswspace(c2))
- {
- if(c2 == '\n')
- parag++;
- c2 = GetC();
- }
- if(parag > 0)
- {
- // 2nd newline, assume paragraph
- UngetC(c2);
-
- buf[ix] = ' ';
- buf[ix+1] = 0;
- if(parag > 3)
- parag = 3;
-if(option_ssml) parag=1;
- return((CLAUSE_PARAGRAPH-30) + 30*parag); // several blank lines, longer pause
- }
-
- if(linelength <= option_linelength)
- {
- // treat lines shorter than a specified length as end-of-clause
- UngetC(c2);
- buf[ix] = ' ';
- buf[ix+1] = 0;
- return(CLAUSE_COLON);
- }
-
- linelength = 0;
- }
-
- if(option_punctuation && (phoneme_mode==0) && (sayas_mode==0) && iswpunct(c1))
- {
- // option is set to explicitly speak punctuation characters
- // if a list of allowed punctuation has been set up, check whether the character is in it
- if((option_punctuation == 1) || (wcschr(option_punctlist,c1) != NULL))
- {
- if((terminator = AnnouncePunctuation(tr, c1, c2, buf, ix)) >= 0)
- return(terminator);
- }
- }
-
- if((phoneme_mode==0) && (sayas_mode==0) && ((punct = lookupwchar(punct_chars,c1)) != 0))
- {
- punct_data = punct_attributes[punct];
-
- if(punct_data & PUNCT_IN_WORD)
- {
- // Armenian punctuation inside a word
- stressed_word = 1;
- *tone_type = punct_data >> 12 & 0xf; // override the end-of-sentence type
- continue;
- }
-
- if((iswspace(c2) || (punct_data & 0x8000) || IsBracket(c2) || (c2=='?') || (c2=='-') || Eof()))
- {
- // note: (c2='?') is for when a smart-quote has been replaced by '?'
- buf[ix] = ' ';
- buf[ix+1] = 0;
-
- if((c1 == '.') && (cprev == '.'))
- {
- c1 = 0x2026;
- punct = 9; // elipsis
- }
-
- nl_count = 0;
- while(!Eof() && iswspace(c2))
- {
- if(c2 == '\n')
- nl_count++;
- c2 = GetC(); // skip past space(s)
- }
- if(!Eof())
- {
- UngetC(c2);
- }
-
- if((nl_count==0) && (c1 == '.'))
- {
- if(iswdigit(cprev) && (tr->langopts.numbers & 0x10000) && islower(c2))
- {
- // dot after a number indicates an ordinal number
- c2 = '.';
- continue;
- }
- if(iswlower(c2))
- {
- c2 = ' ';
- continue; // next word has no capital letter, this dot is probably from an abbreviation
- }
- if(any_alnum==0)
- {
- c2 = ' '; // no letters or digits yet, so probably not a sentence terminator
- continue;
- }
- }
-
- punct_data = punct_attributes[punct];
- if(nl_count > 1)
- {
- if((punct_data == CLAUSE_QUESTION) || (punct_data == CLAUSE_EXCLAMATION))
- return(punct_data + 35); // with a longer pause
- return(CLAUSE_PARAGRAPH);
- }
- return(punct_data); // only recognise punctuation if followed by a blank or bracket/quote
- }
- }
-
- if(speech_parameters[espeakSILENCE]==1)
- continue;
-
- j = ix+1;
- ix += utf8_out(c1,&buf[ix]); // buf[ix++] = c1;
- if(!iswspace(c1) && !IsBracket(c1))
- {
- charix[ix] = count_characters - clause_start_char;
- while(j < ix)
- charix[j++] = -1; // subsequent bytes of a multibyte character
- }
- *charix_top = ix;
-
- if(((ix > (n_buf-20)) && !IsAlpha(c1) && !iswdigit(c1)) || (ix >= (n_buf-2)))
- {
- // clause too long, getting near end of buffer, so break here
- // try to break at a word boundary (unless we actually reach the end of buffer).
- buf[ix] = ' ';
- buf[ix+1] = 0;
- UngetC(c2);
- return(CLAUSE_NONE);
- }
- }
-
- if(stressed_word)
- {
- ix += utf8_out(CHAR_EMPHASIS, &buf[ix]);
- }
- buf[ix] = ' ';
- buf[ix+1] = 0;
- return(CLAUSE_EOF); // end of file
-} // end of ReadClause
-
-
-void InitNamedata(void)
-{//====================
- namedata_ix = 0;
- if(namedata != NULL)
- {
- free(namedata);
- namedata = NULL;
- n_namedata = 0;
- }
-}
-
-
-void InitText2(void)
-{//=================
- int param;
-
- ungot_char = 0;
-
- n_ssml_stack =1;
- n_param_stack = 1;
- ssml_stack[0].tag_type = 0;
-
- for(param=0; param<N_SPEECH_PARAM; param++)
- speech_parameters[param] = param_stack[0].parameter[param]; // set all speech parameters to defaults
-
- option_punctuation = speech_parameters[espeakPUNCTUATION];
- option_capitals = speech_parameters[espeakCAPITALS];
-
- current_voice_id[0] = 0;
-
- ignore_text = 0;
- clear_skipping_text = 0;
- count_characters = -1;
- sayas_mode = 0;
-
- xmlbase = NULL;
-}
-
diff --git a/navit/support/espeak/setlengths.c b/navit/support/espeak/setlengths.c
deleted file mode 100755
index ed4421bf9..000000000
--- a/navit/support/espeak/setlengths.c
+++ /dev/null
@@ -1,673 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <wctype.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-#include "translate.h"
-
-extern int GetAmplitude(void);
-
-
-// convert from words-per-minute to internal speed factor
-static unsigned char speed_lookup[290] = {
- 250, 246, 243, 239, 236, // 80
- 233, 229, 226, 223, 220, // 85
- 217, 214, 211, 208, 205, // 90
- 202, 197, 194, 192, 190, // 95
- 187, 185, 183, 180, 178, // 100
- 176, 174, 172, 170, 168, // 105
- 166, 164, 161, 159, 158, // 110
- 156, 154, 152, 150, 148, // 115
- 146, 145, 143, 141, 137, // 120
- 136, 135, 133, 132, 131, // 125
- 129, 128, 127, 126, 125, // 130
- 124, 122, 121, 120, 119, // 135
- 117, 116, 115, 114, 113, // 140
- 112, 111, 110, 108, 107, // 145
- 106, 105, 104, 103, 102, // 150
- 101, 100, 99, 98, 97, // 155
- 96, 95, 93, 92, 92, // 160
- 91, 90, 89, 89, 88, // 165
- 87, 87, 86, 85, 85, // 170
- 84, 83, 83, 82, 81, // 175
- 80, 80, 79, 78, 78, // 180
- 77, 76, 76, 75, 73, // 185
- 72, 72, 71, 71, 70, // 190
- 70, 69, 69, 68, 67, // 195
- 67, 66, 66, 65, 65, // 200
- 64, 64, 63, 63, 62, // 205
- 62, 61, 60, 60, 59, // 210
- 59, 58, 58, 57, 57, // 215
- 56, 56, 55, 55, 55, // 220
- 54, 54, 53, 53, 52, // 225
- 52, 51, 51, 50, 50, // 230
- 49, 49, 49, 48, 48, // 235
- 47, 47, 46, 46, 46, // 240
- 45, 45, 44, 44, 43, // 245
- 43, 43, 42, 42, 41, // 250
- 41, 41, 40, 40, 39, // 255
- 39, 39, 38, 38, 38, // 260
- 37, 37, 37, 36, 36, // 265
- 35, 35, 35, 34, 34, // 270
- 34, 33, 33, 33, 32, // 275
- 32, 32, 32, 31, 31, // 280
- 31, 30, 30, 30, 29, // 285
- 29, 29, 29, 28, 28, // 290
- 28, 28, 27, 27, 27, // 295
- 26, 26, 26, 26, 25, // 300
- 25, 25, 22, 22, 22, // 305
- 22, 22, 22, 22, 22, // 310
- 21, 21, 21, 21, 21, // 315
- 21, 20, 20, 20, 20, // 320
- 20, 15, 15, 15, 15, // 325
- 15, 15, 15, 15, 16, // 330
- 16, 16, 16, 15, 15, // 335
- 15, 15, 15, 15, 15, // 340
- 15, 17, 17, 16, 16, // 345
- 15, 15, 14, 14, 13, // 350
- 13, 12, 12, 11, 11, // 355
- 10, 10, 9, 8, 8, // 360
- 7, 6, 5, 5, 4, // 365
-};
-
-// speed_factor2 adjustments for speeds 370 to 390
-static unsigned char faster[] = {
-114,112,110,109,107,105,104,102,100,98, // 370-379
-96,94,92,90,88,85,83,80,78,75,72 }; //380-390
-
-static int speed1 = 130;
-static int speed2 = 121;
-static int speed3 = 118;
-
-
-
-void SetSpeed(int control)
-{//=======================
- int x;
- int s1;
- int wpm;
- int wpm2;
-
- wpm = embedded_value[EMBED_S];
- if(control == 2)
- wpm = embedded_value[EMBED_S2];
- wpm2 = wpm;
-
- if(wpm > 369) wpm = 369;
- if(wpm < 80) wpm = 80;
-
- x = speed_lookup[wpm-80];
-
- if(control & 1)
- {
- // set speed factors for different syllable positions within a word
- // these are used in CalcLengths()
- speed1 = (x * voice->speedf1)/256;
- speed2 = (x * voice->speedf2)/256;
- speed3 = (x * voice->speedf3)/256;
- }
-
- if(control & 2)
- {
- // these are used in synthesis file
- s1 = (x * voice->speedf1)/256;
- speed.speed_factor1 = (256 * s1)/115; // full speed adjustment, used for pause length
-if(speed.speed_factor1 < 15)
- speed.speed_factor1 = 15;
- if(wpm >= 170)
-// speed_factor2 = 100 + (166*s1)/128; // reduced speed adjustment, used for playing recorded sounds
- speed.speed_factor2 = 110 + (150*s1)/128; // reduced speed adjustment, used for playing recorded sounds
- else
- speed.speed_factor2 = 128 + (128*s1)/130; // = 215 at 170 wpm
-
- if(wpm2 > 369)
- {
- if(wpm2 > 390)
- wpm2 = 390;
- speed.speed_factor2 = faster[wpm2 - 370];
- }
- }
-
- speed.min_sample_len = 450;
- speed.speed_factor3 = 110; // controls the effect of FRFLAG_LEN_MOD reduce length change
-
- if(wpm2 >= 370)
- {
- // TESTING
- // use experimental fast settings if they have been specified in the Voice
- if(speed.fast_settings[0] > 0)
- speed.speed_factor1 = speed.fast_settings[0];
- if(speed.fast_settings[1] > 0)
- speed.speed_factor2 = speed.fast_settings[1];
- if(speed.fast_settings[2] > 0)
- speed.speed_factor3 = speed.fast_settings[2];
- }
-} // end of SetSpeed
-
-
-#ifdef deleted
-void SetAmplitude(int amp)
-{//=======================
- static unsigned char amplitude_factor[] = {0,5,6,7,9,11,14,17,21,26, 32, 38,44,50,56,63,70,77,84,91,100 };
-
- if((amp >= 0) && (amp <= 20))
- {
- option_amplitude = (amplitude_factor[amp] * 480)/256;
- }
-}
-#endif
-
-
-
-void SetParameter(int parameter, int value, int relative)
-{//======================================================
-// parameter: reset-all, amp, pitch, speed, linelength, expression, capitals, number grouping
-// relative 0=absolute 1=relative
-
- int new_value = value;
- int default_value;
-
- if(relative)
- {
- if(parameter < 5)
- {
- default_value = param_defaults[parameter];
- new_value = default_value + (default_value * value)/100;
- }
- }
- param_stack[0].parameter[parameter] = new_value;
-
- switch(parameter)
- {
- case espeakRATE:
- embedded_value[EMBED_S] = new_value;
- embedded_value[EMBED_S2] = new_value;
- SetSpeed(3);
- break;
-
- case espeakVOLUME:
- embedded_value[EMBED_A] = new_value;
- GetAmplitude();
- break;
-
- case espeakPITCH:
- if(new_value > 99) new_value = 99;
- if(new_value < 0) new_value = 0;
- embedded_value[EMBED_P] = new_value;
- break;
-
- case espeakRANGE:
- if(new_value > 99) new_value = 99;
- embedded_value[EMBED_R] = new_value;
- break;
-
- case espeakLINELENGTH:
- option_linelength = new_value;
- break;
-
- case espeakWORDGAP:
- option_wordgap = new_value;
- break;
-
- case espeakINTONATION:
- if((new_value & 0xff) != 0)
- translator->langopts.intonation_group = new_value & 0xff;
- option_tone_flags = new_value;
- break;
-
- default:
- break;
- }
-} // end of SetParameter
-
-
-
-static void DoEmbedded2(int *embix)
-{//================================
- // There were embedded commands in the text at this point
-
- unsigned int word;
-
- do {
- word = embedded_list[(*embix)++];
-
- if((word & 0x1f) == EMBED_S)
- {
- // speed
- SetEmbedded(word & 0x7f, word >> 8); // adjusts embedded_value[EMBED_S]
- SetSpeed(1);
- }
- } while((word & 0x80) == 0);
-}
-
-
-void CalcLengths(Translator *tr)
-{//==============================
- int ix;
- int ix2;
- PHONEME_LIST *prev;
- PHONEME_LIST *next;
- PHONEME_LIST *next2;
- PHONEME_LIST *next3;
- PHONEME_LIST *p;
- PHONEME_LIST *p2;
-
- int stress;
- int type;
- static int more_syllables=0;
- int pre_sonorant=0;
- int pre_voiced=0;
- int last_pitch = 0;
- int pitch_start;
- int length_mod;
- int len;
- int env2;
- int end_of_clause;
- int embedded_ix = 0;
- int min_drop;
- int emphasized;
- int tone_mod;
- unsigned char *pitch_env=NULL;
-
- for(ix=1; ix<n_phoneme_list; ix++)
- {
- prev = &phoneme_list[ix-1];
- p = &phoneme_list[ix];
- stress = p->stresslevel & 0x7;
- emphasized = p->stresslevel & 0x8;
-
- next = &phoneme_list[ix+1];
-
- if(p->synthflags & SFLAG_EMBEDDED)
- {
- DoEmbedded2(&embedded_ix);
- }
-
- type = p->type;
- if(p->synthflags & SFLAG_SYLLABLE)
- type = phVOWEL;
-
- switch(type)
- {
- case phPAUSE:
- last_pitch = 0;
- break;
-
- case phSTOP:
- last_pitch = 0;
- if(prev->type == phFRICATIVE)
- p->prepause = 20;
- else
- if((more_syllables > 0) || (stress < 4))
- p->prepause = 40;
- else
- p->prepause = 60;
-
- if(prev->type == phSTOP)
- p->prepause = 60;
-
- if((tr->langopts.word_gap & 0x10) && (p->newword))
- p->prepause = 60;
-
- if(p->ph->phflags & phLENGTHENSTOP)
- p->prepause += 30;
-
- if(p->synthflags & SFLAG_LENGTHEN)
- p->prepause += tr->langopts.long_stop;
- break;
-
- case phVFRICATIVE:
- if(next->type==phVOWEL)
- {
- pre_voiced = 1;
- } // drop through
- case phFRICATIVE:
- if(p->newword)
- p->prepause = 15;
-
- if(next->type==phPAUSE && prev->type==phNASAL && !(p->ph->phflags&phFORTIS))
- p->prepause = 25;
-
- if(prev->ph->phflags & phBRKAFTER)
- p->prepause = 30;
-
- if((p->ph->phflags & phSIBILANT) && next->type==phSTOP && !next->newword)
- {
- if(prev->type == phVOWEL)
- p->length = 200; // ?? should do this if it's from a prefix
- else
- p->length = 150;
- }
- else
- p->length = 256;
-
- if((tr->langopts.word_gap & 0x10) && (p->newword))
- p->prepause = 30;
-
- break;
-
- case phVSTOP:
- if(prev->type==phVFRICATIVE || prev->type==phFRICATIVE || (prev->ph->phflags & phSIBILANT) || (prev->type == phLIQUID))
- p->prepause = 30;
-
- if(next->type==phVOWEL || next->type==phLIQUID)
- {
- if((next->type==phVOWEL) || !next->newword)
- pre_voiced = 1;
-
- p->prepause = 40;
-
- if((prev->type == phPAUSE) || (prev->type == phVOWEL)) // || (prev->ph->mnemonic == ('/'*256+'r')))
- p->prepause = 0;
- else
- if(p->newword==0)
- {
- if(prev->type==phLIQUID)
- p->prepause = 20;
- if(prev->type==phNASAL)
- p->prepause = 12;
-
- if(prev->type==phSTOP && !(prev->ph->phflags & phFORTIS))
- p->prepause = 0;
- }
- }
- if((tr->langopts.word_gap & 0x10) && (p->newword) && (p->prepause < 20))
- p->prepause = 20;
-
- break;
-
- case phLIQUID:
- case phNASAL:
- p->amp = tr->stress_amps[1]; // unless changed later
- p->length = 256; // TEMPORARY
- min_drop = 0;
-
- if(p->newword)
- {
- if(prev->type==phLIQUID)
- p->prepause = 25;
- if(prev->type==phVOWEL)
- p->prepause = 12;
- }
-
- if(next->type==phVOWEL)
- {
- pre_sonorant = 1;
- }
- else
- if((prev->type==phVOWEL) || (prev->type == phLIQUID))
- {
- p->length = prev->length;
- p->pitch2 = last_pitch;
- if(p->pitch2 < 7)
- p->pitch2 = 7;
- p->pitch1 = p->pitch2 - 8;
- p->env = PITCHfall;
- pre_voiced = 0;
-
- if(p->type == phLIQUID)
- {
- p->length = speed1;
-//p->pitch1 = p->pitch2 - 20; // post vocalic [r/]
- }
-
- if(next->type == phVSTOP)
- {
- p->length = (p->length * 160)/100;
- }
- if(next->type == phVFRICATIVE)
- {
- p->length = (p->length * 120)/100;
- }
- }
- else
- {
- p->pitch2 = last_pitch;
- for(ix2=ix; ix2<n_phoneme_list; ix2++)
- {
- if(phoneme_list[ix2].type == phVOWEL)
- {
- p->pitch2 = phoneme_list[ix2].pitch2;
- break;
- }
- }
- p->pitch1 = p->pitch2-8;
- p->env = PITCHfall;
- pre_voiced = 0;
- }
- break;
-
- case phVOWEL:
- min_drop = 0;
- next2 = &phoneme_list[ix+2];
- next3 = &phoneme_list[ix+3];
-
- if(stress > 7) stress = 7;
-
- if(pre_sonorant)
- p->amp = tr->stress_amps[stress]-1;
- else
- p->amp = tr->stress_amps[stress];
-
- if(emphasized)
- p->amp = 25;
-
- if(ix >= (n_phoneme_list-3))
- {
- // last phoneme of a clause, limit its amplitude
- if(p->amp > tr->langopts.param[LOPT_MAXAMP_EOC])
- p->amp = tr->langopts.param[LOPT_MAXAMP_EOC];
- }
-
- // is the last syllable of a word ?
- more_syllables=0;
- end_of_clause = 0;
- for(p2 = p+1; p2->newword== 0; p2++)
- {
- if((p2->type == phVOWEL) && !(p2->ph->phflags & phNONSYLLABIC))
- more_syllables++;
-
- if(p2->ph->code == phonPAUSE_CLAUSE)
- end_of_clause = 2;
- }
- if(p2->ph->code == phonPAUSE_CLAUSE)
- end_of_clause = 2;
-
- if((p2->newword & 2) && (more_syllables==0))
- {
- end_of_clause = 2;
- }
-
- // calc length modifier
- if((next->ph->code == phonPAUSE_VSHORT) && (next2->type == phPAUSE))
- {
- // if PAUSE_VSHORT is followed by a pause, then use that
- next = next2;
- next2 = next3;
- next3 = &phoneme_list[ix+4];
- }
-
- if(more_syllables==0)
- {
- len = tr->langopts.length_mods0[next2->ph->length_mod *10+ next->ph->length_mod];
-
- if((next->newword) && (tr->langopts.word_gap & 0x20))
- {
- // consider as a pause + first phoneme of the next word
- length_mod = (len + tr->langopts.length_mods0[next->ph->length_mod *10+ 1])/2;
- }
- else
- length_mod = len;
- }
- else
- {
- length_mod = tr->langopts.length_mods[next2->ph->length_mod *10+ next->ph->length_mod];
-
- if((next->type == phNASAL) && (next2->type == phSTOP || next2->type == phVSTOP) && (next3->ph->phflags & phFORTIS))
- length_mod -= 15;
- }
-
- if(more_syllables==0)
- length_mod *= speed1;
- else
- if(more_syllables==1)
- length_mod *= speed2;
- else
- length_mod *= speed3;
-
- length_mod = length_mod / 128;
-
- if(length_mod < 8)
- length_mod = 8; // restrict how much lengths can be reduced
-
- if(stress >= 7)
- {
- // tonic syllable, include a constant component so it doesn't decrease directly with speed
- length_mod += 20;
- if(emphasized)
- length_mod += 10;
- }
- else
- if(emphasized)
- {
- length_mod += 20;
- }
-
- if((len = tr->stress_lengths[stress]) == 0)
- len = tr->stress_lengths[6];
-
- length_mod = (length_mod * len)/128;
-
- if(p->tone_ph != 0)
- {
- if((tone_mod = phoneme_tab[p->tone_ph]->std_length) > 0)
- {
- // a tone phoneme specifies a percentage change to the length
- length_mod = (length_mod * tone_mod) / 100;
- }
- }
-
- if(end_of_clause == 2)
- {
- // this is the last syllable in the clause, lengthen it - more for short vowels
- len = p->ph->std_length;
- if(tr->langopts.stress_flags & 0x40000)
- len=200; // don't lengthen short vowels more than long vowels at end-of-clause
- length_mod = length_mod * (256 + (280 - len)/3)/256;
- }
-
-if(p->type != phVOWEL)
-{
- length_mod = 256; // syllabic consonant
- min_drop = 8;
-}
- p->length = length_mod;
-
- // pre-vocalic part
- // set last-pitch
- env2 = p->env;
- if(env2 > 1) env2++; // version for use with preceding semi-vowel
-
- if(p->tone_ph != 0)
- {
- pitch_env = LookupEnvelope(phoneme_tab[p->tone_ph]->spect);
- }
- else
- {
- pitch_env = envelope_data[env2];
- }
-
- pitch_start = p->pitch1 + ((p->pitch2-p->pitch1)*pitch_env[0])/256;
-
- if(pre_sonorant || pre_voiced)
- {
- // set pitch for pre-vocalic part
- if(pitch_start == 1024)
- last_pitch = pitch_start; // pitch is not set
-
- if(pitch_start - last_pitch > 8) // was 9
- last_pitch = pitch_start - 8;
-
- prev->pitch1 = last_pitch;
- prev->pitch2 = pitch_start;
- if(last_pitch < pitch_start)
- {
- prev->env = PITCHrise;
- p->env = env2;
- }
- else
- {
- prev->env = PITCHfall;
- }
-
- prev->length = length_mod;
-
- prev->amp = p->amp;
- if((prev->type != phLIQUID) && (prev->amp > 18))
- prev->amp = 18;
- }
-
- // vowel & post-vocalic part
- next->synthflags &= ~SFLAG_SEQCONTINUE;
- if(next->type == phNASAL && next2->type != phVOWEL)
- next->synthflags |= SFLAG_SEQCONTINUE;
-
- if(next->type == phLIQUID)
- {
- next->synthflags |= SFLAG_SEQCONTINUE;
-
- if(next2->type == phVOWEL)
- {
- next->synthflags &= ~SFLAG_SEQCONTINUE;
- }
-
- if(next2->type != phVOWEL)
- {
- if(next->ph->mnemonic == ('/'*256+'r'))
- {
- next->synthflags &= ~SFLAG_SEQCONTINUE;
-// min_drop = 15;
- }
- }
- }
-
- if((min_drop > 0) && ((p->pitch2 - p->pitch1) < min_drop))
- {
- p->pitch1 = p->pitch2 - min_drop;
- if(p->pitch1 < 0)
- p->pitch1 = 0;
- }
-
- last_pitch = p->pitch1 + ((p->pitch2-p->pitch1)*envelope_data[p->env][127])/256;
- pre_sonorant = 0;
- pre_voiced = 0;
- break;
- }
- }
-} // end of CalcLengths
-
diff --git a/navit/support/espeak/sintab.h b/navit/support/espeak/sintab.h
deleted file mode 100755
index 08fc18f31..000000000
--- a/navit/support/espeak/sintab.h
+++ /dev/null
@@ -1,258 +0,0 @@
-short int sin_tab[2048] = {
- 0, -25, -50, -75, -100, -125, -150, -175,
- -201, -226, -251, -276, -301, -326, -351, -376,
- -401, -427, -452, -477, -502, -527, -552, -577,
- -602, -627, -652, -677, -702, -727, -752, -777,
- -802, -827, -852, -877, -902, -927, -952, -977,
- -1002, -1027, -1052, -1077, -1102, -1127, -1152, -1177,
- -1201, -1226, -1251, -1276, -1301, -1326, -1350, -1375,
- -1400, -1425, -1449, -1474, -1499, -1523, -1548, -1573,
- -1597, -1622, -1647, -1671, -1696, -1721, -1745, -1770,
- -1794, -1819, -1843, -1868, -1892, -1917, -1941, -1965,
- -1990, -2014, -2038, -2063, -2087, -2111, -2136, -2160,
- -2184, -2208, -2233, -2257, -2281, -2305, -2329, -2353,
- -2377, -2401, -2425, -2449, -2473, -2497, -2521, -2545,
- -2569, -2593, -2617, -2640, -2664, -2688, -2712, -2735,
- -2759, -2783, -2806, -2830, -2853, -2877, -2900, -2924,
- -2947, -2971, -2994, -3018, -3041, -3064, -3088, -3111,
- -3134, -3157, -3180, -3204, -3227, -3250, -3273, -3296,
- -3319, -3342, -3365, -3388, -3410, -3433, -3456, -3479,
- -3502, -3524, -3547, -3570, -3592, -3615, -3637, -3660,
- -3682, -3705, -3727, -3749, -3772, -3794, -3816, -3839,
- -3861, -3883, -3905, -3927, -3949, -3971, -3993, -4015,
- -4037, -4059, -4080, -4102, -4124, -4146, -4167, -4189,
- -4211, -4232, -4254, -4275, -4296, -4318, -4339, -4360,
- -4382, -4403, -4424, -4445, -4466, -4487, -4508, -4529,
- -4550, -4571, -4592, -4613, -4633, -4654, -4675, -4695,
- -4716, -4736, -4757, -4777, -4798, -4818, -4838, -4859,
- -4879, -4899, -4919, -4939, -4959, -4979, -4999, -5019,
- -5039, -5059, -5078, -5098, -5118, -5137, -5157, -5176,
- -5196, -5215, -5235, -5254, -5273, -5292, -5311, -5331,
- -5350, -5369, -5388, -5406, -5425, -5444, -5463, -5482,
- -5500, -5519, -5537, -5556, -5574, -5593, -5611, -5629,
- -5648, -5666, -5684, -5702, -5720, -5738, -5756, -5774,
- -5791, -5809, -5827, -5844, -5862, -5880, -5897, -5914,
- -5932, -5949, -5966, -5984, -6001, -6018, -6035, -6052,
- -6069, -6085, -6102, -6119, -6136, -6152, -6169, -6185,
- -6202, -6218, -6235, -6251, -6267, -6283, -6299, -6315,
- -6331, -6347, -6363, -6379, -6395, -6410, -6426, -6441,
- -6457, -6472, -6488, -6503, -6518, -6533, -6549, -6564,
- -6579, -6594, -6608, -6623, -6638, -6653, -6667, -6682,
- -6696, -6711, -6725, -6739, -6754, -6768, -6782, -6796,
- -6810, -6824, -6838, -6852, -6865, -6879, -6893, -6906,
- -6920, -6933, -6946, -6960, -6973, -6986, -6999, -7012,
- -7025, -7038, -7051, -7064, -7076, -7089, -7101, -7114,
- -7126, -7139, -7151, -7163, -7175, -7187, -7199, -7211,
- -7223, -7235, -7247, -7259, -7270, -7282, -7293, -7305,
- -7316, -7327, -7338, -7349, -7361, -7372, -7382, -7393,
- -7404, -7415, -7425, -7436, -7446, -7457, -7467, -7478,
- -7488, -7498, -7508, -7518, -7528, -7538, -7548, -7557,
- -7567, -7577, -7586, -7596, -7605, -7614, -7623, -7633,
- -7642, -7651, -7660, -7668, -7677, -7686, -7695, -7703,
- -7712, -7720, -7728, -7737, -7745, -7753, -7761, -7769,
- -7777, -7785, -7793, -7800, -7808, -7816, -7823, -7830,
- -7838, -7845, -7852, -7859, -7866, -7873, -7880, -7887,
- -7894, -7900, -7907, -7914, -7920, -7926, -7933, -7939,
- -7945, -7951, -7957, -7963, -7969, -7975, -7980, -7986,
- -7991, -7997, -8002, -8008, -8013, -8018, -8023, -8028,
- -8033, -8038, -8043, -8047, -8052, -8057, -8061, -8066,
- -8070, -8074, -8078, -8082, -8086, -8090, -8094, -8098,
- -8102, -8105, -8109, -8113, -8116, -8119, -8123, -8126,
- -8129, -8132, -8135, -8138, -8141, -8143, -8146, -8149,
- -8151, -8153, -8156, -8158, -8160, -8162, -8164, -8166,
- -8168, -8170, -8172, -8174, -8175, -8177, -8178, -8179,
- -8181, -8182, -8183, -8184, -8185, -8186, -8187, -8187,
- -8188, -8189, -8189, -8190, -8190, -8190, -8190, -8190,
- -8191, -8190, -8190, -8190, -8190, -8190, -8189, -8189,
- -8188, -8187, -8187, -8186, -8185, -8184, -8183, -8182,
- -8181, -8179, -8178, -8177, -8175, -8174, -8172, -8170,
- -8168, -8166, -8164, -8162, -8160, -8158, -8156, -8153,
- -8151, -8149, -8146, -8143, -8141, -8138, -8135, -8132,
- -8129, -8126, -8123, -8119, -8116, -8113, -8109, -8105,
- -8102, -8098, -8094, -8090, -8086, -8082, -8078, -8074,
- -8070, -8066, -8061, -8057, -8052, -8047, -8043, -8038,
- -8033, -8028, -8023, -8018, -8013, -8008, -8002, -7997,
- -7991, -7986, -7980, -7975, -7969, -7963, -7957, -7951,
- -7945, -7939, -7933, -7926, -7920, -7914, -7907, -7900,
- -7894, -7887, -7880, -7873, -7866, -7859, -7852, -7845,
- -7838, -7830, -7823, -7816, -7808, -7800, -7793, -7785,
- -7777, -7769, -7761, -7753, -7745, -7737, -7728, -7720,
- -7712, -7703, -7695, -7686, -7677, -7668, -7660, -7651,
- -7642, -7633, -7623, -7614, -7605, -7596, -7586, -7577,
- -7567, -7557, -7548, -7538, -7528, -7518, -7508, -7498,
- -7488, -7478, -7467, -7457, -7446, -7436, -7425, -7415,
- -7404, -7393, -7382, -7372, -7361, -7349, -7338, -7327,
- -7316, -7305, -7293, -7282, -7270, -7259, -7247, -7235,
- -7223, -7211, -7199, -7187, -7175, -7163, -7151, -7139,
- -7126, -7114, -7101, -7089, -7076, -7064, -7051, -7038,
- -7025, -7012, -6999, -6986, -6973, -6960, -6946, -6933,
- -6920, -6906, -6893, -6879, -6865, -6852, -6838, -6824,
- -6810, -6796, -6782, -6768, -6754, -6739, -6725, -6711,
- -6696, -6682, -6667, -6653, -6638, -6623, -6608, -6594,
- -6579, -6564, -6549, -6533, -6518, -6503, -6488, -6472,
- -6457, -6441, -6426, -6410, -6395, -6379, -6363, -6347,
- -6331, -6315, -6299, -6283, -6267, -6251, -6235, -6218,
- -6202, -6185, -6169, -6152, -6136, -6119, -6102, -6085,
- -6069, -6052, -6035, -6018, -6001, -5984, -5966, -5949,
- -5932, -5914, -5897, -5880, -5862, -5844, -5827, -5809,
- -5791, -5774, -5756, -5738, -5720, -5702, -5684, -5666,
- -5648, -5629, -5611, -5593, -5574, -5556, -5537, -5519,
- -5500, -5482, -5463, -5444, -5425, -5406, -5388, -5369,
- -5350, -5331, -5311, -5292, -5273, -5254, -5235, -5215,
- -5196, -5176, -5157, -5137, -5118, -5098, -5078, -5059,
- -5039, -5019, -4999, -4979, -4959, -4939, -4919, -4899,
- -4879, -4859, -4838, -4818, -4798, -4777, -4757, -4736,
- -4716, -4695, -4675, -4654, -4633, -4613, -4592, -4571,
- -4550, -4529, -4508, -4487, -4466, -4445, -4424, -4403,
- -4382, -4360, -4339, -4318, -4296, -4275, -4254, -4232,
- -4211, -4189, -4167, -4146, -4124, -4102, -4080, -4059,
- -4037, -4015, -3993, -3971, -3949, -3927, -3905, -3883,
- -3861, -3839, -3816, -3794, -3772, -3749, -3727, -3705,
- -3682, -3660, -3637, -3615, -3592, -3570, -3547, -3524,
- -3502, -3479, -3456, -3433, -3410, -3388, -3365, -3342,
- -3319, -3296, -3273, -3250, -3227, -3204, -3180, -3157,
- -3134, -3111, -3088, -3064, -3041, -3018, -2994, -2971,
- -2947, -2924, -2900, -2877, -2853, -2830, -2806, -2783,
- -2759, -2735, -2712, -2688, -2664, -2640, -2617, -2593,
- -2569, -2545, -2521, -2497, -2473, -2449, -2425, -2401,
- -2377, -2353, -2329, -2305, -2281, -2257, -2233, -2208,
- -2184, -2160, -2136, -2111, -2087, -2063, -2038, -2014,
- -1990, -1965, -1941, -1917, -1892, -1868, -1843, -1819,
- -1794, -1770, -1745, -1721, -1696, -1671, -1647, -1622,
- -1597, -1573, -1548, -1523, -1499, -1474, -1449, -1425,
- -1400, -1375, -1350, -1326, -1301, -1276, -1251, -1226,
- -1201, -1177, -1152, -1127, -1102, -1077, -1052, -1027,
- -1002, -977, -952, -927, -902, -877, -852, -827,
- -802, -777, -752, -727, -702, -677, -652, -627,
- -602, -577, -552, -527, -502, -477, -452, -427,
- -401, -376, -351, -326, -301, -276, -251, -226,
- -201, -175, -150, -125, -100, -75, -50, -25,
- 0, 25, 50, 75, 100, 125, 150, 175,
- 201, 226, 251, 276, 301, 326, 351, 376,
- 401, 427, 452, 477, 502, 527, 552, 577,
- 602, 627, 652, 677, 702, 727, 752, 777,
- 802, 827, 852, 877, 902, 927, 952, 977,
- 1002, 1027, 1052, 1077, 1102, 1127, 1152, 1177,
- 1201, 1226, 1251, 1276, 1301, 1326, 1350, 1375,
- 1400, 1425, 1449, 1474, 1499, 1523, 1548, 1573,
- 1597, 1622, 1647, 1671, 1696, 1721, 1745, 1770,
- 1794, 1819, 1843, 1868, 1892, 1917, 1941, 1965,
- 1990, 2014, 2038, 2063, 2087, 2111, 2136, 2160,
- 2184, 2208, 2233, 2257, 2281, 2305, 2329, 2353,
- 2377, 2401, 2425, 2449, 2473, 2497, 2521, 2545,
- 2569, 2593, 2617, 2640, 2664, 2688, 2712, 2735,
- 2759, 2783, 2806, 2830, 2853, 2877, 2900, 2924,
- 2947, 2971, 2994, 3018, 3041, 3064, 3088, 3111,
- 3134, 3157, 3180, 3204, 3227, 3250, 3273, 3296,
- 3319, 3342, 3365, 3388, 3410, 3433, 3456, 3479,
- 3502, 3524, 3547, 3570, 3592, 3615, 3637, 3660,
- 3682, 3705, 3727, 3749, 3772, 3794, 3816, 3839,
- 3861, 3883, 3905, 3927, 3949, 3971, 3993, 4015,
- 4037, 4059, 4080, 4102, 4124, 4146, 4167, 4189,
- 4211, 4232, 4254, 4275, 4296, 4318, 4339, 4360,
- 4382, 4403, 4424, 4445, 4466, 4487, 4508, 4529,
- 4550, 4571, 4592, 4613, 4633, 4654, 4675, 4695,
- 4716, 4736, 4757, 4777, 4798, 4818, 4838, 4859,
- 4879, 4899, 4919, 4939, 4959, 4979, 4999, 5019,
- 5039, 5059, 5078, 5098, 5118, 5137, 5157, 5176,
- 5196, 5215, 5235, 5254, 5273, 5292, 5311, 5331,
- 5350, 5369, 5388, 5406, 5425, 5444, 5463, 5482,
- 5500, 5519, 5537, 5556, 5574, 5593, 5611, 5629,
- 5648, 5666, 5684, 5702, 5720, 5738, 5756, 5774,
- 5791, 5809, 5827, 5844, 5862, 5880, 5897, 5914,
- 5932, 5949, 5966, 5984, 6001, 6018, 6035, 6052,
- 6069, 6085, 6102, 6119, 6136, 6152, 6169, 6185,
- 6202, 6218, 6235, 6251, 6267, 6283, 6299, 6315,
- 6331, 6347, 6363, 6379, 6395, 6410, 6426, 6441,
- 6457, 6472, 6488, 6503, 6518, 6533, 6549, 6564,
- 6579, 6594, 6608, 6623, 6638, 6653, 6667, 6682,
- 6696, 6711, 6725, 6739, 6754, 6768, 6782, 6796,
- 6810, 6824, 6838, 6852, 6865, 6879, 6893, 6906,
- 6920, 6933, 6946, 6960, 6973, 6986, 6999, 7012,
- 7025, 7038, 7051, 7064, 7076, 7089, 7101, 7114,
- 7126, 7139, 7151, 7163, 7175, 7187, 7199, 7211,
- 7223, 7235, 7247, 7259, 7270, 7282, 7293, 7305,
- 7316, 7327, 7338, 7349, 7361, 7372, 7382, 7393,
- 7404, 7415, 7425, 7436, 7446, 7457, 7467, 7478,
- 7488, 7498, 7508, 7518, 7528, 7538, 7548, 7557,
- 7567, 7577, 7586, 7596, 7605, 7614, 7623, 7633,
- 7642, 7651, 7660, 7668, 7677, 7686, 7695, 7703,
- 7712, 7720, 7728, 7737, 7745, 7753, 7761, 7769,
- 7777, 7785, 7793, 7800, 7808, 7816, 7823, 7830,
- 7838, 7845, 7852, 7859, 7866, 7873, 7880, 7887,
- 7894, 7900, 7907, 7914, 7920, 7926, 7933, 7939,
- 7945, 7951, 7957, 7963, 7969, 7975, 7980, 7986,
- 7991, 7997, 8002, 8008, 8013, 8018, 8023, 8028,
- 8033, 8038, 8043, 8047, 8052, 8057, 8061, 8066,
- 8070, 8074, 8078, 8082, 8086, 8090, 8094, 8098,
- 8102, 8105, 8109, 8113, 8116, 8119, 8123, 8126,
- 8129, 8132, 8135, 8138, 8141, 8143, 8146, 8149,
- 8151, 8153, 8156, 8158, 8160, 8162, 8164, 8166,
- 8168, 8170, 8172, 8174, 8175, 8177, 8178, 8179,
- 8181, 8182, 8183, 8184, 8185, 8186, 8187, 8187,
- 8188, 8189, 8189, 8190, 8190, 8190, 8190, 8190,
- 8191, 8190, 8190, 8190, 8190, 8190, 8189, 8189,
- 8188, 8187, 8187, 8186, 8185, 8184, 8183, 8182,
- 8181, 8179, 8178, 8177, 8175, 8174, 8172, 8170,
- 8168, 8166, 8164, 8162, 8160, 8158, 8156, 8153,
- 8151, 8149, 8146, 8143, 8141, 8138, 8135, 8132,
- 8129, 8126, 8123, 8119, 8116, 8113, 8109, 8105,
- 8102, 8098, 8094, 8090, 8086, 8082, 8078, 8074,
- 8070, 8066, 8061, 8057, 8052, 8047, 8043, 8038,
- 8033, 8028, 8023, 8018, 8013, 8008, 8002, 7997,
- 7991, 7986, 7980, 7975, 7969, 7963, 7957, 7951,
- 7945, 7939, 7933, 7926, 7920, 7914, 7907, 7900,
- 7894, 7887, 7880, 7873, 7866, 7859, 7852, 7845,
- 7838, 7830, 7823, 7816, 7808, 7800, 7793, 7785,
- 7777, 7769, 7761, 7753, 7745, 7737, 7728, 7720,
- 7712, 7703, 7695, 7686, 7677, 7668, 7660, 7651,
- 7642, 7633, 7623, 7614, 7605, 7596, 7586, 7577,
- 7567, 7557, 7548, 7538, 7528, 7518, 7508, 7498,
- 7488, 7478, 7467, 7457, 7446, 7436, 7425, 7415,
- 7404, 7393, 7382, 7372, 7361, 7349, 7338, 7327,
- 7316, 7305, 7293, 7282, 7270, 7259, 7247, 7235,
- 7223, 7211, 7199, 7187, 7175, 7163, 7151, 7139,
- 7126, 7114, 7101, 7089, 7076, 7064, 7051, 7038,
- 7025, 7012, 6999, 6986, 6973, 6960, 6946, 6933,
- 6920, 6906, 6893, 6879, 6865, 6852, 6838, 6824,
- 6810, 6796, 6782, 6768, 6754, 6739, 6725, 6711,
- 6696, 6682, 6667, 6653, 6638, 6623, 6608, 6594,
- 6579, 6564, 6549, 6533, 6518, 6503, 6488, 6472,
- 6457, 6441, 6426, 6410, 6395, 6379, 6363, 6347,
- 6331, 6315, 6299, 6283, 6267, 6251, 6235, 6218,
- 6202, 6185, 6169, 6152, 6136, 6119, 6102, 6085,
- 6069, 6052, 6035, 6018, 6001, 5984, 5966, 5949,
- 5932, 5914, 5897, 5880, 5862, 5844, 5827, 5809,
- 5791, 5774, 5756, 5738, 5720, 5702, 5684, 5666,
- 5648, 5629, 5611, 5593, 5574, 5556, 5537, 5519,
- 5500, 5482, 5463, 5444, 5425, 5406, 5388, 5369,
- 5350, 5331, 5311, 5292, 5273, 5254, 5235, 5215,
- 5196, 5176, 5157, 5137, 5118, 5098, 5078, 5059,
- 5039, 5019, 4999, 4979, 4959, 4939, 4919, 4899,
- 4879, 4859, 4838, 4818, 4798, 4777, 4757, 4736,
- 4716, 4695, 4675, 4654, 4633, 4613, 4592, 4571,
- 4550, 4529, 4508, 4487, 4466, 4445, 4424, 4403,
- 4382, 4360, 4339, 4318, 4296, 4275, 4254, 4232,
- 4211, 4189, 4167, 4146, 4124, 4102, 4080, 4059,
- 4037, 4015, 3993, 3971, 3949, 3927, 3905, 3883,
- 3861, 3839, 3816, 3794, 3772, 3749, 3727, 3705,
- 3682, 3660, 3637, 3615, 3592, 3570, 3547, 3524,
- 3502, 3479, 3456, 3433, 3410, 3388, 3365, 3342,
- 3319, 3296, 3273, 3250, 3227, 3204, 3180, 3157,
- 3134, 3111, 3088, 3064, 3041, 3018, 2994, 2971,
- 2947, 2924, 2900, 2877, 2853, 2830, 2806, 2783,
- 2759, 2735, 2712, 2688, 2664, 2640, 2617, 2593,
- 2569, 2545, 2521, 2497, 2473, 2449, 2425, 2401,
- 2377, 2353, 2329, 2305, 2281, 2257, 2233, 2208,
- 2184, 2160, 2136, 2111, 2087, 2063, 2038, 2014,
- 1990, 1965, 1941, 1917, 1892, 1868, 1843, 1819,
- 1794, 1770, 1745, 1721, 1696, 1671, 1647, 1622,
- 1597, 1573, 1548, 1523, 1499, 1474, 1449, 1425,
- 1400, 1375, 1350, 1326, 1301, 1276, 1251, 1226,
- 1201, 1177, 1152, 1127, 1102, 1077, 1052, 1027,
- 1002, 977, 952, 927, 902, 877, 852, 827,
- 802, 777, 752, 727, 702, 677, 652, 627,
- 602, 577, 552, 527, 502, 477, 452, 427,
- 401, 376, 351, 326, 301, 276, 251, 226,
- 201, 175, 150, 125, 100, 75, 50, 25,
- };
diff --git a/navit/support/espeak/speak.c b/navit/support/espeak/speak.c
deleted file mode 100755
index ab33a867b..000000000
--- a/navit/support/espeak/speak.c
+++ /dev/null
@@ -1,898 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include "speech.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifndef PLATFORM_DOS
-#ifdef PLATFORM_WINDOWS
-#include <windows.h>
-#include <winreg.h>
-#else
-#include <unistd.h>
-#endif
-#endif
-
-#ifndef NEED_GETOPT
-#include <getopt.h>
-#endif
-#include <time.h>
-#include <signal.h>
-#include <locale.h>
-#include <sys/stat.h>
-
-#include "speak_lib.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-#include "translate.h"
-
-
-
-extern void Write4Bytes(FILE *f, int value);
-char path_home[N_PATH_HOME]; // this is the espeak-data directory
-
-char filetype[5];
-char wavefile[200];
-int (* uri_callback)(int, const char *, const char *) = NULL;
-int (* phoneme_callback)(const char *) = NULL;
-
-FILE *f_wave = NULL;
-int quiet = 0;
-unsigned int samples_total = 0;
-unsigned int samples_split = 0;
-unsigned int wavefile_count = 0;
-int end_of_sentence = 0;
-
-static const char *help_text =
-"\nspeak [options] [\"<words>\"]\n\n"
-"-f <text file> Text file to speak\n"
-"--stdin Read text input from stdin instead of a file\n\n"
-"If neither -f nor --stdin, <words> are spoken, or if none then text is\n"
-"spoken from stdin, each line separately.\n\n"
-"-a <integer>\n"
-"\t Amplitude, 0 to 200, default is 100\n"
-"-g <integer>\n"
-"\t Word gap. Pause between words, units of 10mS at the default speed\n"
-"-l <integer>\n"
-"\t Line length. If not zero (which is the default), consider\n"
-"\t lines less than this length as end-of-clause\n"
-"-p <integer>\n"
-"\t Pitch adjustment, 0 to 99, default is 50\n"
-"-s <integer>\n"
-"\t Speed in words per minute 80 to 390, default is 170\n"
-"-v <voice name>\n"
-"\t Use voice file of this name from espeak-data/voices\n"
-"-w <wave file name>\n"
-"\t Write output to this WAV file, rather than speaking it directly\n"
-"-b\t Input text encoding, 1=UTF8, 2=8 bit, 4=16 bit \n"
-"-m\t Interpret SSML markup, and ignore other < > tags\n"
-"-q\t Quiet, don't produce any speech (may be useful with -x)\n"
-"-x\t Write phoneme mnemonics to stdout\n"
-"-X\t Write phonemes mnemonics and translation trace to stdout\n"
-"-z\t No final sentence pause at the end of the text\n"
-"--stdout Write speech output to stdout\n"
-"--compile=<voice name>\n"
-"\t Compile the pronunciation rules and dictionary in the current\n"
-"\t directory. =<voice name> is optional and specifies which language\n"
-"--path=\"<path>\"\n"
-"\t Specifies the directory containing the espeak-data directory\n"
-"--phonout=\"<filename>\"\n"
-"\t Write output from -x -X commands and mbrola phoneme data to this file\n"
-"--punct=\"<characters>\"\n"
-"\t Speak the names of punctuation characters during speaking. If\n"
-"\t =<characters> is omitted, all punctuation is spoken.\n"
-"--split=\"<minutes>\"\n"
-"\t Starts a new WAV file every <minutes>. Used with -w\n"
-"--voices=<language>\n"
-"\t List the available voices for the specified language.\n"
-"\t If <language> is omitted, then list all voices.\n"
-"-k <integer>\n"
-"\t Indicate capital letters with: 1=sound, 2=the word \"capitals\",\n"
-"\t higher values = a pitch increase (try -k20).\n";
-
-
-void DisplayVoices(FILE *f_out, char *language);
-
-USHORT voice_pcnt[N_PEAKS+1][3];
-
-
-
-int GetFileLength(const char *filename)
-{//====================================
- struct stat statbuf;
-
- if(stat(filename,&statbuf) != 0)
- return(0);
-
- if((statbuf.st_mode & S_IFMT) == S_IFDIR)
-// if(S_ISDIR(statbuf.st_mode))
- return(-2); // a directory
-
- return(statbuf.st_size);
-} // end of GetFileLength
-
-
-char *Alloc(int size)
-{//==================
- char *p;
- if((p = (char *)malloc(size)) == NULL)
- fprintf(stderr,"Can't allocate memory\n");
- return(p);
-}
-
-void Free(void *ptr)
-{//=================
- if(ptr != NULL)
- free(ptr);
-}
-
-
-void DisplayVoices(FILE *f_out, char *language)
-{//============================================
- int ix;
- const char *p;
- int len;
- int count;
- int scores = 0;
- const espeak_VOICE *v;
- const char *lang_name;
- char age_buf[12];
- const espeak_VOICE **voices;
- espeak_VOICE voice_select;
-
- static char genders[4] = {' ','M','F',' '};
-
- if((language != NULL) && (language[0] != 0))
- {
- // display only voices for the specified language, in order of priority
- voice_select.languages = language;
- voice_select.age = 0;
- voice_select.gender = 0;
- voice_select.name = NULL;
- voices = espeak_ListVoices(&voice_select);
- scores = 1;
- }
- else
- {
- voices = espeak_ListVoices(NULL);
- }
-
- fprintf(f_out,"Pty Language Age/Gender VoiceName File Other Langs\n");
-
- for(ix=0; (v = voices[ix]) != NULL; ix++)
- {
- count = 0;
- p = v->languages;
- while(*p != 0)
- {
- len = strlen(p+1);
- lang_name = p+1;
-
- if(v->age == 0)
- strcpy(age_buf," ");
- else
- sprintf(age_buf,"%3d",v->age);
-
- if(count==0)
- {
- fprintf(f_out,"%2d %-12s%s%c %-17s %-11s ",
- p[0],lang_name,age_buf,genders[v->gender],v->name,v->identifier);
- }
- else
- {
- fprintf(f_out,"(%s %d)",lang_name,p[0]);
- }
- count++;
- p += len+2;
- }
-// if(scores)
-// fprintf(f_out,"%3d ",v->score);
- fputc('\n',f_out);
- }
-} // end of DisplayVoices
-
-
-
-
-static int OpenWaveFile(const char *path, int rate)
-//=================================================
-{
- // Set the length of 0x7ffff000 for --stdout
- // This will be changed to the correct length for -w (write to file)
- static unsigned char wave_hdr[44] = {
- 'R','I','F','F',0x24,0xf0,0xff,0x7f,'W','A','V','E','f','m','t',' ',
- 0x10,0,0,0,1,0,1,0, 9,0x3d,0,0,0x12,0x7a,0,0,
- 2,0,0x10,0,'d','a','t','a', 0x00,0xf0,0xff,0x7f};
-
- if(path == NULL)
- return(2);
-
- if(strcmp(path,"stdout")==0)
- f_wave = stdout;
- else
- f_wave = fopen(path,"wb");
-
- if(f_wave != NULL)
- {
- fwrite(wave_hdr,1,24,f_wave);
- Write4Bytes(f_wave,rate);
- Write4Bytes(f_wave,rate * 2);
- fwrite(&wave_hdr[32],1,12,f_wave);
- return(0);
- }
- return(1);
-} // end of OpenWaveFile
-
-
-
-
-static void CloseWaveFile()
-//=========================
-{
- unsigned int pos;
-
- if((f_wave == NULL) || (f_wave == stdout))
- return;
-
- fflush(f_wave);
- pos = ftell(f_wave);
-
- fseek(f_wave,4,SEEK_SET);
- Write4Bytes(f_wave,pos - 8);
-
- fseek(f_wave,40,SEEK_SET);
- Write4Bytes(f_wave,pos - 44);
-
-
- fclose(f_wave);
- f_wave = NULL;
-
-} // end of CloseWaveFile
-
-
-
-
-void MarkerEvent(int type, unsigned int char_position, int value, unsigned char *out_ptr)
-{//======================================================================================
-// Do nothing in the command-line version.
- if(type == 2)
- end_of_sentence = 1;
-} // end of MarkerEvent
-
-
-static int WavegenFile(void)
-{//=========================
- int finished;
- unsigned char wav_outbuf[512];
- char fname[210];
-
- out_ptr = out_start = wav_outbuf;
- out_end = wav_outbuf + sizeof(wav_outbuf);
-
- finished = WavegenFill(0);
-
- if(quiet)
- return(finished);
-
- if(f_wave == NULL)
- {
- sprintf(fname,"%s_%.2d%s",wavefile,++wavefile_count,filetype);
- if(OpenWaveFile(fname, samplerate) != 0)
- return(1);
- }
-
- if(end_of_sentence)
- {
- end_of_sentence = 0;
- if((samples_split > 0 ) && (samples_total > samples_split))
- {
- CloseWaveFile();
- samples_total = 0;
- }
- }
-
- if(f_wave != NULL)
- {
- samples_total += (out_ptr - wav_outbuf)/2;
- fwrite(wav_outbuf, 1, out_ptr - wav_outbuf, f_wave);
- }
- return(finished);
-} // end of WavegenFile
-
-
-
-static void init_path(char *argv0, char *path_specified)
-{//=====================================================
-
- if(path_specified)
- {
- sprintf(path_home,"%s/espeak-data",path_specified);
- return;
- }
-
-#ifdef PLATFORM_WINDOWS
- HKEY RegKey;
- unsigned long size;
- unsigned long var_type;
- char *p;
- char *env;
- unsigned char buf[sizeof(path_home)-12];
-
-#if 0
- if(((env = getenv("ESPEAK_DATA_PATH")) != NULL) && ((strlen(env)+12) < sizeof(path_home)))
- {
- sprintf(path_home,"%s\\espeak-data",env);
- if(GetFileLength(path_home) == -2)
- return; // an espeak-data directory exists in the directory specified by environment variable
- }
-#endif
-
- strcpy(path_home,argv0);
- if((p = strrchr(path_home,'\\')) != NULL)
- {
- strcpy(&p[1],"espeak-data");
- if(GetFileLength(path_home) == -2)
- return; // an espeak-data directory exists in the same directory as the espeak program
- }
-
- // otherwise, look in the Windows Registry
- buf[0] = 0;
- RegOpenKeyEx(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Speech\\Voices\\Tokens\\eSpeak", 0, KEY_READ, &RegKey);
- size = sizeof(buf);
- var_type = REG_SZ;
- RegQueryValueEx(RegKey, "path", 0, &var_type, buf, &size);
-
- sprintf(path_home,"%s\\espeak-data",buf);
-#else
-#ifdef PLATFORM_DOS
- strcpy(path_home,PATH_ESPEAK_DATA);
-#else
- char *env;
-#if 0
- if((env = getenv("ESPEAK_DATA_PATH")) != NULL)
- {
- snprintf(path_home,sizeof(path_home),"%s/espeak-data",env);
- if(GetFileLength(path_home) == -2)
- return; // an espeak-data directory exists
- }
-#endif
-
-#if 0
- snprintf(path_home,sizeof(path_home),"%s/espeak-data",getenv("HOME"));
- if(access(path_home,R_OK) != 0)
- {
- strcpy(path_home,PATH_ESPEAK_DATA);
- }
-#endif
-#endif
-#endif
-}
-
-
-static int initialise(void)
-{//========================
- int param;
- int result;
-
- // It seems that the wctype functions don't work until the locale has been set
- // to something other than the default "C". Then, not only Latin1 but also the
- // other characters give the correct results with iswalpha() etc.
-#ifdef PLATFORM_RISCOS
- setlocale(LC_CTYPE,"ISO8859-1");
-#else
-#if 0
- if(setlocale(LC_CTYPE,"en_US.UTF-8") == NULL)
- {
- if(setlocale(LC_CTYPE,"UTF-8") == NULL)
- setlocale(LC_CTYPE,"");
- }
-#endif
-#endif
-
-
- WavegenInit(22050,0); // 22050
- if((result = LoadPhData()) != 1)
- {
- if(result == -1)
- {
- fprintf(stderr,"Failed to load espeak-data\n");
- exit(1);
- }
- else
- fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home);
- }
- LoadConfig();
- SetVoiceStack(NULL);
- SynthesizeInit();
-
- for(param=0; param<N_SPEECH_PARAM; param++)
- param_stack[0].parameter[param] = param_defaults[param];
-
- return(0);
-}
-
-
-static void StopSpeak(int unused)
-{//==============================
-// signal(SIGINT,SIG_IGN);
- // DEBUG
-// printf("\n*** Interrupting speech output (use Ctrl-D to actually quit).\n");
- fflush(stdout);
- SpeakNextClause(NULL,NULL,5);
-// signal(SIGINT,StopSpeak);
-} // end of StopSpeak()
-
-#ifdef NEED_GETOPT
- struct option {
- char *name;
- int has_arg;
- int *flag;
- int val;
- };
- int optind;
- static int optional_argument;
- static const char *arg_opts = "abfgklpsvw"; // which options have arguments
- static char *opt_string="";
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
-#endif
-
-int main (int argc, char **argv)
-//==============================
-{
- static struct option long_options[] =
- {
- /* These options set a flag. */
-// {"verbose", no_argument, &verbose_flag, 1},
-// {"brief", no_argument, &verbose_flag, 0},
-
- /* These options don't set a flag.
- We distinguish them by their indices. */
- {"help", no_argument, 0, 'h'},
- {"stdin", no_argument, 0, 0x100},
- {"compile-debug", optional_argument, 0, 0x101},
- {"compile", optional_argument, 0, 0x102},
- {"punct", optional_argument, 0, 0x103},
- {"voices", optional_argument, 0, 0x104},
- {"stdout", no_argument, 0, 0x105},
- {"split", optional_argument, 0, 0x106},
- {"path", required_argument, 0, 0x107},
- {"phonout", required_argument, 0, 0x108},
- {0, 0, 0, 0}
- };
-
- static const char *err_load = "Failed to read ";
-
- FILE *f_text=NULL;
- const char *p_text=NULL;
- char *data_path = NULL; // use default path for espeak-data
-
- int option_index = 0;
- int c;
- int value;
- int speed=170;
- int ix;
- char *optarg2;
- int amp = 100; // default
- int wordgap = 0;
- int speaking = 0;
- int flag_stdin = 0;
- int flag_compile = 0;
- int pitch_adjustment = 50;
- espeak_VOICE voice_select;
- char filename[200];
- char voicename[40];
- char dictname[40];
-
- voicename[0] = 0;
- mbrola_name[0] = 0;
- dictname[0] = 0;
- wavefile[0] = 0;
- filename[0] = 0;
- option_linelength = 0;
- option_phonemes = 0;
- option_waveout = 0;
- option_wordgap = 0;
- option_endpause = 1;
- option_phoneme_input = 1;
- option_multibyte = espeakCHARS_AUTO; // auto
- f_trans = stdout;
-
-#ifdef NEED_GETOPT
- optind = 1;
- opt_string = "";
- while(optind < argc)
- {
- int len;
- char *p;
-
- if((c = *opt_string) == 0)
- {
- opt_string = argv[optind];
- if(opt_string[0] != '-')
- break;
-
- optind++;
- opt_string++;
- c = *opt_string;
- }
- opt_string++;
- p = optarg2 = opt_string;
-
- if(c == '-')
- {
- opt_string="";
- for(ix=0; ;ix++)
- {
- if(long_options[ix].name == 0)
- break;
- len = strlen(long_options[ix].name);
- if(memcmp(long_options[ix].name,p,len)==0)
- {
- c = long_options[ix].val;
- optarg2 = NULL;
-
- if((long_options[ix].has_arg != 0) && (p[len]=='='))
- {
- optarg2 = &p[len+1];
- }
- break;
- }
- }
- }
- else
- if(strchr(arg_opts,c) != NULL)
- {
- opt_string="";
- if(optarg2[0]==0)
- {
- // the option's value is in the next argument
- optarg2 = argv[optind++];
- }
- }
-#else
- while(1)
- {
- c = getopt_long (argc, argv, "a:b:f:g:hk:l:p:qs:v:w:xXmz", // NOTE: also change arg_opts to indicate which commands have a numeric value
- long_options, &option_index);
-
- /* Detect the end of the options. */
- if (c == -1)
- break;
- optarg2 = optarg;
-#endif
-
- switch (c)
- {
- case 'b':
- // input character encoding, 8bit, 16bit, UTF8
- option_multibyte = espeakCHARS_8BIT;
- if((sscanf(optarg2,"%d",&value) == 1) && (value <= 4))
- option_multibyte= value;
- break;
-
- case 'h':
- printf("\nspeak text-to-speech: %s\n%s",version_string,help_text);
- exit(0);
- break;
-
- case 'k':
- option_capitals = atoi(optarg2);
- break;
-
- case 'x':
- option_phonemes = 1;
- break;
-
- case 'X':
- option_phonemes = 2;
- break;
-
- case 'm':
- option_ssml = 1;
- break;
-
- case 'p':
- pitch_adjustment = atoi(optarg2);
- if(pitch_adjustment > 99) pitch_adjustment = 99;
- break;
-
- case 'q':
- quiet = 1;
- break;
-
- case 'f':
- strncpy0(filename,optarg2,sizeof(filename));
- break;
-
- case 'l':
- value = 0;
- value = atoi(optarg2);
- option_linelength = value;
- break;
-
- case 'a':
- amp = atoi(optarg2);
- break;
-
- case 's':
- speed = atoi(optarg2);
- break;
-
- case 'g':
- wordgap = atoi(optarg2);
- break;
-
- case 'v':
- strncpy0(voicename,optarg2,sizeof(voicename));
- break;
-
- case 'w':
- option_waveout = 1;
- strncpy0(wavefile,optarg2,sizeof(wavefile));
- break;
-
- case 'z':
- option_endpause = 0;
- break;
-
- case 0x100: // --stdin
- flag_stdin = 1;
- break;
-
- case 0x105: // --stdout
- option_waveout = 1;
- strcpy(wavefile,"stdout");
- break;
-
- case 0x101: // --compile-debug
- case 0x102: // --compile
- if(optarg2 != NULL)
- strncpy0(voicename,optarg2,sizeof(voicename));
- flag_compile = c;
- break;
-
- case 0x103: // --punct
- option_punctuation = 1;
- if(optarg2 != NULL)
- {
- ix = 0;
- while((ix < N_PUNCTLIST) && ((option_punctlist[ix] = optarg2[ix]) != 0)) ix++;
- option_punctlist[N_PUNCTLIST-1] = 0;
- option_punctuation = 2;
- }
- break;
-
- case 0x104: // --voices
- init_path(argv[0],data_path);
- DisplayVoices(stdout,optarg2);
- exit(0);
-
- case 0x106: // -- split
- if(optarg2 == NULL)
- samples_split = 30; // default 30 minutes
- else
- samples_split = atoi(optarg2);
- break;
-
- case 0x107: // --path
- data_path = optarg2;
- break;
-
- case 0x108: // --phonout
- if((f_trans = fopen(optarg2,"w")) == NULL)
- {
- fprintf(stderr,"Can't write to: %s\n",optarg2);
- f_trans = stderr;
- }
- break;
-
- default:
- exit(0);
- }
- }
-
- init_path(argv[0],data_path);
- initialise();
-
-
- if(flag_compile)
- {
- LoadVoice(voicename,5);
-
-#ifdef PLATFORM_DOS
- char path_dsource[sizeof(path_home)+20];
- strcpy(path_dsource,path_home);
- path_dsource[strlen(path_home)-11] = 0; // remove "espeak-data" from the end
- strcat(path_dsource,"dictsource\\");
- CompileDictionary(path_dsource,dictionary_name,NULL,NULL, flag_compile & 0x1);
-#else
-#ifdef PLATFORM_WINDOWS
- char path_dsource[sizeof(path_home)+20];
- strcpy(path_dsource,path_home);
- path_dsource[strlen(path_home)-11] = 0; // remove "espeak-data" from the end
- strcat(path_dsource,"dictsource\\");
- CompileDictionary(path_dsource,dictionary_name,NULL,NULL, flag_compile & 0x1);
-#else
- CompileDictionary(NULL,dictionary_name,NULL,NULL, flag_compile & 0x1);
-#endif
-#endif
- exit(0);
- }
-
-
- if(voicename[0] == 0)
- strcpy(voicename,"default");
-
- if(SetVoiceByName(voicename) != EE_OK)
- {
- memset(&voice_select,0,sizeof(voice_select));
- voice_select.languages = voicename;
- if(SetVoiceByProperties(&voice_select) != EE_OK)
- {
- fprintf(stderr,"%svoice '%s'\n",err_load,voicename);
- exit(2);
- }
- }
-
- SetParameter(espeakRATE,speed,0);
- SetParameter(espeakVOLUME,amp,0);
- SetParameter(espeakCAPITALS,option_capitals,0);
- SetParameter(espeakPUNCTUATION,option_punctuation,0);
- SetParameter(espeakWORDGAP,wordgap,0);
-
- if(pitch_adjustment != 50)
- {
- SetParameter(espeakPITCH,pitch_adjustment,0);
- }
- DoVoiceChange(voice);
-
- if(filename[0]==0)
- {
- if((optind < argc) && (flag_stdin == 0))
- {
- // there's a non-option parameter, and no -f or --stdin
- // use it as text
- p_text = argv[optind];
- }
- else
- {
- f_text = stdin;
- if(flag_stdin == 0)
- option_linelength = -1; // single input lines on stdin
- }
- }
- else
- {
- f_text = fopen(filename,"r");
- }
-
- if((f_text == NULL) && (p_text == NULL))
- {
- fprintf(stderr,"%sfile '%s'\n",err_load,filename);
- exit(1);
- }
-
- if(option_waveout || quiet)
- {
- if(quiet)
- {
- // no sound output
- OpenWaveFile(NULL,samplerate);
- option_waveout = 1;
- }
- else
- {
- // write sound output to a WAV file
- samples_split = (samplerate * samples_split) * 60;
-
- if(samples_split)
- {
- // don't open the wav file until we start generating speech
- char *extn;
- extn = strrchr(wavefile,'.');
- if((extn != NULL) && ((wavefile + strlen(wavefile) - extn) <= 4))
- {
- strcpy(filetype,extn);
- *extn = 0;
- }
- }
- else
- if(OpenWaveFile(wavefile,samplerate) != 0)
- {
- fprintf(stderr,"Can't write to output file '%s'\n'",wavefile);
- exit(3);
- }
- }
-
- InitText(0);
- SpeakNextClause(f_text,p_text,0);
-
- ix = 1;
- for(;;)
- {
- if(WavegenFile() != 0)
- {
- if(ix == 0)
- break; // finished, wavegen command queue is empty
- }
-
- if(Generate(phoneme_list,&n_phoneme_list,1)==0)
- {
- ix = SpeakNextClause(NULL,NULL,1);
- }
- }
-
- CloseWaveFile();
- }
- else
- {
- // Silence on ^C or SIGINT
-// signal(SIGINT,StopSpeak);
-
- // output sound using portaudio
- WavegenInitSound();
-
- InitText(0);
- SpeakNextClause(f_text,p_text,0);
-
- if(option_quiet)
- {
- while(SpeakNextClause(NULL,NULL,1) != 0);
- return(0);
- }
-
-#ifdef USE_PORTAUDIO
- speaking = 1;
- while(speaking)
- {
- // NOTE: if nanosleep() isn't recognised on your system, try replacing
- // this by sleep(1);
-#ifdef PLATFORM_WINDOWS
- Sleep(300); // 0.3s
-#else
-#ifdef USE_NANOSLEEP
- struct timespec period;
- struct timespec remaining;
- period.tv_sec = 0;
- period.tv_nsec = 300000000; // 0.3 sec
- nanosleep(&period,&remaining);
-#else
- sleep(1);
-#endif
-#endif
- if(SynthOnTimer() != 0)
- speaking = 0;
- }
-#else
- fprintf(stderr,"-w option must be used because the program was built without a sound interface\n");
-#endif // USE_PORTAUDIO
- }
-
- if((f_trans != stdout) && (f_trans != stderr))
- fclose(f_trans); // needed for WinCe
- return(0);
-}
diff --git a/navit/support/espeak/speak_init.c b/navit/support/espeak/speak_init.c
deleted file mode 100644
index 06a34235f..000000000
--- a/navit/support/espeak/speak_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "../../plugin.h"
-
-void
-plugin_init(void)
-{
-}
diff --git a/navit/support/espeak/speak_lib.c b/navit/support/espeak/speak_lib.c
deleted file mode 100644
index 85c1b39a3..000000000
--- a/navit/support/espeak/speak_lib.c
+++ /dev/null
@@ -1,1156 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include "stdio.h"
-#include "ctype.h"
-#include "string.h"
-#include "stdlib.h"
-#include "wchar.h"
-#include "locale.h"
-#include <assert.h>
-#include <time.h>
-
-#include "speech.h"
-
-#include <sys/stat.h>
-#ifdef PLATFORM_WINDOWS
-#include <windows.h>
-#else
-#include <unistd.h>
-#endif
-
-#include "speak_lib.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-#include "translate.h"
-#include "debug.h"
-
-#include "fifo.h"
-#include "event.h"
-#include "wave.h"
-
-unsigned char *outbuf=NULL;
-extern espeak_VOICE voice_selected;
-
-espeak_EVENT *event_list=NULL;
-int event_list_ix=0;
-int n_event_list;
-long count_samples;
-void* my_audio=NULL;
-
-static unsigned int my_unique_identifier=0;
-static void* my_user_data=NULL;
-static espeak_AUDIO_OUTPUT my_mode=AUDIO_OUTPUT_SYNCHRONOUS;
-static int synchronous_mode = 1;
-t_espeak_callback* synth_callback = NULL;
-int (* uri_callback)(int, const char *, const char *) = NULL;
-int (* phoneme_callback)(const char *) = NULL;
-
-char path_home[N_PATH_HOME]; // this is the espeak-data directory
-
-
-#ifdef USE_ASYNC
-
-static int dispatch_audio(short* outbuf, int length, espeak_EVENT* event)
-{//======================================================================
- ENTER("dispatch_audio");
-
- int a_wave_can_be_played = fifo_is_command_enabled();
-
-#ifdef DEBUG_ENABLED
- SHOW("*** dispatch_audio > uid=%d, [write=%p (%d bytes)], sample=%d, a_wave_can_be_played = %d\n",
- (event) ? event->unique_identifier : 0, wave_test_get_write_buffer(), 2*length,
- (event) ? event->sample : 0,
- a_wave_can_be_played);
-#endif
-
- switch(my_mode)
- {
- case AUDIO_OUTPUT_PLAYBACK:
- {
- if (outbuf && length && a_wave_can_be_played)
- {
- wave_write (my_audio, (char*)outbuf, 2*length);
- }
-
- while(a_wave_can_be_played) {
- // TBD: some event are filtered here but some insight might be given
- // TBD: in synthesise.cpp for avoiding to create WORDs with size=0.
- // TBD: For example sentence "or ALT)." returns three words
- // "or", "ALT" and "".
- // TBD: the last one has its size=0.
- if (event && (event->type == espeakEVENT_WORD) && (event->length==0))
- {
- break;
- }
- espeak_ERROR a_error = event_declare(event);
- if (a_error != EE_BUFFER_FULL)
- {
- break;
- }
- SHOW_TIME("dispatch_audio > EE_BUFFER_FULL\n");
- usleep(10000);
- a_wave_can_be_played = fifo_is_command_enabled();
- }
- }
- break;
-
- case AUDIO_OUTPUT_RETRIEVAL:
- if (synth_callback)
- {
- synth_callback(outbuf, length, event);
- }
- break;
-
- case AUDIO_OUTPUT_SYNCHRONOUS:
- case AUDIO_OUTPUT_SYNCH_PLAYBACK:
- break;
- }
-
- if (!a_wave_can_be_played)
- {
- SHOW_TIME("dispatch_audio > synth must be stopped!\n");
- }
-
- SHOW_TIME("LEAVE dispatch_audio\n");
-
- return (a_wave_can_be_played==0); // 1 = stop synthesis
-}
-
-
-
-static int create_events(short* outbuf, int length, espeak_EVENT* event, uint32_t the_write_pos)
-{//=====================================================================
- int finished;
- int i=0;
-
- // The audio data are written to the output device.
- // The list of events in event_list (index: event_list_ix) is read:
- // Each event is declared to the "event" object which stores them internally.
- // The event object is responsible of calling the external callback
- // as soon as the relevant audio sample is played.
-
- do
- { // for each event
- espeak_EVENT* event;
- if (event_list_ix == 0)
- {
- event = NULL;
- }
- else
- {
- event = event_list + i;
-#ifdef DEBUG_ENABLED
- SHOW("Synthesize: event->sample(%d) + %d = %d\n", event->sample, the_write_pos, event->sample + the_write_pos);
-#endif
- event->sample += the_write_pos;
- }
-#ifdef DEBUG_ENABLED
- SHOW("*** Synthesize: i=%d (event_list_ix=%d), length=%d\n",i,event_list_ix,length);
-#endif
- finished = dispatch_audio((short *)outbuf, length, event);
- length = 0; // the wave data are played once.
- i++;
- } while((i < event_list_ix) && !finished);
- return finished;
-}
-
-
-int sync_espeak_terminated_msg( uint unique_identifier, void* user_data)
-{//=====================================================================
- ENTER("sync_espeak_terminated_msg");
-
- int finished=0;
-
- memset(event_list, 0, 2*sizeof(espeak_EVENT));
-
- event_list[0].type = espeakEVENT_MSG_TERMINATED;
- event_list[0].unique_identifier = unique_identifier;
- event_list[0].user_data = user_data;
- event_list[1].type = espeakEVENT_LIST_TERMINATED;
- event_list[1].unique_identifier = unique_identifier;
- event_list[1].user_data = user_data;
-
- if (my_mode==AUDIO_OUTPUT_PLAYBACK)
- {
- while(1)
- {
- espeak_ERROR a_error = event_declare(event_list);
- if (a_error != EE_BUFFER_FULL)
- {
- break;
- }
- SHOW_TIME("sync_espeak_terminated_msg > EE_BUFFER_FULL\n");
- usleep(10000);
- }
- }
- else
- {
- if (synth_callback)
- {
- finished=synth_callback(NULL,0,event_list);
- }
- }
- return finished;
-}
-
-#endif
-
-
-static void select_output(espeak_AUDIO_OUTPUT output_type)
-{//=======================================================
- my_mode = output_type;
- my_audio = NULL;
- synchronous_mode = 1;
- option_waveout = 1; // inhibit portaudio callback from wavegen.cpp
-
- switch(my_mode)
- {
- case AUDIO_OUTPUT_PLAYBACK:
- synchronous_mode = 0;
-#ifdef USE_ASYNC
- wave_init();
- wave_set_callback_is_output_enabled( fifo_is_command_enabled);
- my_audio = wave_open("alsa");
- event_init();
-#endif
- break;
-
- case AUDIO_OUTPUT_RETRIEVAL:
- synchronous_mode = 0;
- break;
-
- case AUDIO_OUTPUT_SYNCHRONOUS:
- break;
-
- case AUDIO_OUTPUT_SYNCH_PLAYBACK:
- option_waveout = 0;
- WavegenInitSound();
- break;
- }
-} // end of select_output
-
-
-
-
-int GetFileLength(const char *filename)
-{//====================================
- struct stat statbuf;
-
- if(stat(filename,&statbuf) != 0)
- return(0);
-
- if((statbuf.st_mode & S_IFMT) == S_IFDIR)
- // if(S_ISDIR(statbuf.st_mode))
- return(-2); // a directory
-
- return(statbuf.st_size);
-} // end of GetFileLength
-
-
-char *Alloc(int size)
-{//==================
- char *p;
- if((p = (char *)malloc(size)) == NULL)
- fprintf(stderr,"Can't allocate memory\n"); // I was told that size+1 fixes a crash on 64-bit systems
- return(p);
-}
-
-void Free(void *ptr)
-{//=================
- if(ptr != NULL)
- free(ptr);
-}
-
-
-
-static void init_path(const char *path)
-{//====================================
-#ifdef PLATFORM_WINDOWS
- HKEY RegKey;
- unsigned long size;
- unsigned long var_type;
- char *env;
- unsigned char buf[sizeof(path_home)-13];
-
- if(path != NULL)
- {
- sprintf(path_home,"%s/espeak-data",path);
- return;
- }
-
- if((env = getenv("ESPEAK_DATA_PATH")) != NULL)
- {
- sprintf(path_home,"%s/espeak-data",env);
- if(GetFileLength(path_home) == -2)
- return; // an espeak-data directory exists
- }
-
- buf[0] = 0;
- RegOpenKeyExA(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Speech\\Voices\\Tokens\\eSpeak", 0, KEY_READ, &RegKey);
- size = sizeof(buf);
- var_type = REG_SZ;
- RegQueryValueExA(RegKey, "path", 0, &var_type, buf, &size);
-
- sprintf(path_home,"%s\\espeak-data",buf);
-
-#else
- char *env;
-
- if(path != NULL)
- {
- snprintf(path_home,sizeof(path_home),"%s/espeak-data",path);
- return;
- }
-
- // check for environment variable
- if((env = getenv("ESPEAK_DATA_PATH")) != NULL)
- {
- snprintf(path_home,sizeof(path_home),"%s/espeak-data",env);
- if(GetFileLength(path_home) == -2)
- return; // an espeak-data directory exists
- }
-
- snprintf(path_home,sizeof(path_home),"%s/espeak-data",getenv("HOME"));
- if(access(path_home,R_OK) != 0)
- {
- strcpy(path_home,PATH_ESPEAK_DATA);
- }
-#endif
-}
-
-static int initialise(void)
-{//========================
- int param;
- int result;
-
- LoadConfig();
- WavegenInit(22050,0); // 22050
- if((result = LoadPhData()) != 1)
- {
- if(result == -1)
- {
- fprintf(stderr,"Failed to load espeak-data\n");
- exit(1);
- }
- else
- fprintf(stderr,"Wrong version of espeak-data 0x%x (expects 0x%x) at %s\n",result,version_phdata,path_home);
- }
-
- memset(&voice_selected,0,sizeof(voice_selected));
- SetVoiceStack(NULL);
- SynthesizeInit();
- InitNamedata();
-
- for(param=0; param<N_SPEECH_PARAM; param++)
- param_stack[0].parameter[param] = param_defaults[param];
-
- return(0);
-}
-
-
-static espeak_ERROR Synthesize(unsigned int unique_identifier, const void *text, int flags)
-{//========================================================================================
- // Fill the buffer with output sound
- int length;
- int finished = 0;
- int count_buffers = 0;
-#ifdef USE_ASYNC
- uint32_t a_write_pos=0;
-#endif
-
-#ifdef DEBUG_ENABLED
- ENTER("Synthesize");
- if (text)
- {
- SHOW("Synthesize > uid=%d, flags=%d, >>>text=%s<<<\n", unique_identifier, flags, text);
- }
-#endif
-
- if((outbuf==NULL) || (event_list==NULL))
- return(EE_INTERNAL_ERROR); // espeak_Initialize() has not been called
-
- option_multibyte = flags & 7;
- option_ssml = flags & espeakSSML;
- option_phoneme_input = flags & espeakPHONEMES;
- option_endpause = flags & espeakENDPAUSE;
-
- count_samples = 0;
-
-#ifdef USE_ASYNC
- if(my_mode == AUDIO_OUTPUT_PLAYBACK)
- {
- a_write_pos = wave_get_write_position(my_audio);
- }
-#endif
-
- if(translator == NULL)
- {
- SetVoiceByName("default");
- }
-
- SpeakNextClause(NULL,text,0);
-
- if(my_mode == AUDIO_OUTPUT_SYNCH_PLAYBACK)
- {
- for(;;)
- {
-#ifdef PLATFORM_WINDOWS
- Sleep(300); // 0.3s
-#else
-#ifdef USE_NANOSLEEP
- struct timespec period;
- struct timespec remaining;
- period.tv_sec = 0;
- period.tv_nsec = 300000000; // 0.3 sec
- nanosleep(&period,&remaining);
-#else
- sleep(1);
-#endif
-#endif
- if(SynthOnTimer() != 0)
- break;
- }
- return(EE_OK);
- }
-
- for(;;)
- {
-#ifdef DEBUG_ENABLED
- SHOW("Synthesize > %s\n","for (next)");
-#endif
- out_ptr = outbuf;
- out_end = &outbuf[outbuf_size];
- event_list_ix = 0;
- WavegenFill(0);
-
- length = (out_ptr - outbuf)/2;
- count_samples += length;
- event_list[event_list_ix].type = espeakEVENT_LIST_TERMINATED; // indicates end of event list
- event_list[event_list_ix].unique_identifier = my_unique_identifier;
- event_list[event_list_ix].user_data = my_user_data;
-
- count_buffers++;
- if (my_mode==AUDIO_OUTPUT_PLAYBACK)
- {
-#ifdef USE_ASYNC
- finished = create_events((short *)outbuf, length, event_list, a_write_pos);
- length = 0; // the wave data are played once.
-#endif
- }
- else
- {
- finished = synth_callback((short *)outbuf, length, event_list);
- }
- if(finished)
- {
- SpeakNextClause(NULL,0,2); // stop
- break;
- }
-
- if(Generate(phoneme_list,&n_phoneme_list,1)==0)
- {
- if(WcmdqUsed() == 0)
- {
- // don't process the next clause until the previous clause has finished generating speech.
- // This ensures that <audio> tag (which causes end-of-clause) is at a sound buffer boundary
-
- event_list[0].type = espeakEVENT_LIST_TERMINATED;
- event_list[0].unique_identifier = my_unique_identifier;
- event_list[0].user_data = my_user_data;
-
- if(SpeakNextClause(NULL,NULL,1)==0)
- {
-#ifdef USE_ASYNC
- if (my_mode==AUDIO_OUTPUT_PLAYBACK)
- {
- dispatch_audio(NULL, 0, NULL); // TBD: test case
- }
- else
- {
- synth_callback(NULL, 0, event_list); // NULL buffer ptr indicates end of data
- }
-#else
- synth_callback(NULL, 0, event_list); // NULL buffer ptr indicates end of data
-#endif
- break;
- }
- }
- }
- }
- return(EE_OK);
-} // end of Synthesize
-
-#ifdef DEBUG_ENABLED
-static const char* label[] = {
- "END_OF_EVENT_LIST",
- "WORD",
- "SENTENCE",
- "MARK",
- "PLAY",
- "END"};
-#endif
-
-
-void MarkerEvent(int type, unsigned int char_position, int value, unsigned char *out_ptr)
-{//======================================================================================
- // type: 1=word, 2=sentence, 3=named mark, 4=play audio, 5=end
- ENTER("MarkerEvent");
- espeak_EVENT *ep;
- double time;
-
- if((event_list == NULL) || (event_list_ix >= (n_event_list-2)))
- return;
-
- ep = &event_list[event_list_ix++];
- ep->type = (espeak_EVENT_TYPE)type;
- ep->unique_identifier = my_unique_identifier;
- ep->user_data = my_user_data;
- ep->text_position = char_position & 0xffffff;
- ep->length = char_position >> 24;
-
- time = ((double)(count_samples + mbrola_delay + (out_ptr - out_start)/2)*1000.0)/samplerate;
- ep->audio_position = (int)(time);
- ep->sample = (count_samples + mbrola_delay + (out_ptr - out_start)/2);
-
-#ifdef DEBUG_ENABLED
- SHOW("MarkerEvent > count_samples=%d, out_ptr=%x, out_start=0x%x\n",count_samples, out_ptr, out_start);
- SHOW("*** MarkerEvent > type=%s, uid=%d, text_pos=%d, length=%d, audio_position=%d, sample=%d\n",
- label[ep->type], ep->unique_identifier, ep->text_position, ep->length,
- ep->audio_position, ep->sample);
-#endif
-
- if((type == espeakEVENT_MARK) || (type == espeakEVENT_PLAY))
- ep->id.name = &namedata[value];
- else
- ep->id.number = value;
-} // end of MarkerEvent
-
-
-
-
-espeak_ERROR sync_espeak_Synth(unsigned int unique_identifier, const void *text, size_t size,
- unsigned int position, espeak_POSITION_TYPE position_type,
- unsigned int end_position, unsigned int flags, void* user_data)
-{//===========================================================================
-
-#ifdef DEBUG_ENABLED
- ENTER("sync_espeak_Synth");
- SHOW("sync_espeak_Synth > position=%d, position_type=%d, end_position=%d, flags=%d, user_data=0x%x, text=%s\n", position, position_type, end_position, flags, user_data, text);
-#endif
-
- espeak_ERROR aStatus;
-
- InitText(flags);
- my_unique_identifier = unique_identifier;
- my_user_data = user_data;
-
- switch(position_type)
- {
- case POS_CHARACTER:
- skip_characters = position;
- break;
-
- case POS_WORD:
- skip_words = position;
- break;
-
- case POS_SENTENCE:
- skip_sentences = position;
- break;
-
- }
- if(skip_characters || skip_words || skip_sentences)
- skipping_text = 1;
-
- end_character_position = end_position;
-
- aStatus = Synthesize(unique_identifier, text, flags);
- #ifdef USE_ASYNC
- wave_flush(my_audio);
- #endif
-
- SHOW_TIME("LEAVE sync_espeak_Synth");
- return aStatus;
-} // end of sync_espeak_Synth
-
-
-
-
-espeak_ERROR sync_espeak_Synth_Mark(unsigned int unique_identifier, const void *text, size_t size,
- const char *index_mark, unsigned int end_position,
- unsigned int flags, void* user_data)
-{//=========================================================================
- espeak_ERROR aStatus;
-
- InitText(flags);
-
- my_unique_identifier = unique_identifier;
- my_user_data = user_data;
-
- if(index_mark != NULL)
- {
- strncpy0(skip_marker, index_mark, sizeof(skip_marker));
- skipping_text = 1;
- }
-
- end_character_position = end_position;
-
-
- aStatus = Synthesize(unique_identifier, text, flags | espeakSSML);
- SHOW_TIME("LEAVE sync_espeak_Synth_Mark");
-
- return (aStatus);
-} // end of sync_espeak_Synth_Mark
-
-
-
-void sync_espeak_Key(const char *key)
-{//==================================
- // symbolic name, symbolicname_character - is there a system resource of symbolic names per language?
- int letter;
- int ix;
-
- ix = utf8_in(&letter,key);
- if(key[ix] == 0)
- {
- // a single character
- sync_espeak_Char(letter);
- return;
- }
-
- my_unique_identifier = 0;
- my_user_data = NULL;
- Synthesize(0, key,0); // speak key as a text string
-}
-
-
-void sync_espeak_Char(wchar_t character)
-{//=====================================
- // is there a system resource of character names per language?
- char buf[80];
- my_unique_identifier = 0;
- my_user_data = NULL;
-
- sprintf(buf,"<say-as interpret-as=\"tts:char\">&#%d;</say-as>",character);
- Synthesize(0, buf,espeakSSML);
-}
-
-
-
-void sync_espeak_SetPunctuationList(const wchar_t *punctlist)
-{//==========================================================
- // Set the list of punctuation which are spoken for "some".
- my_unique_identifier = 0;
- my_user_data = NULL;
-
- wcsncpy(option_punctlist, punctlist, N_PUNCTLIST);
- option_punctlist[N_PUNCTLIST-1] = 0;
-} // end of sync_espeak_SetPunctuationList
-
-
-
-
-#pragma GCC visibility push(default)
-
-
-ESPEAK_API void espeak_SetSynthCallback(t_espeak_callback* SynthCallback)
-{//======================================================================
- ENTER("espeak_SetSynthCallback");
- synth_callback = SynthCallback;
-#ifdef USE_ASYNC
- event_set_callback(synth_callback);
-#endif
-}
-
-ESPEAK_API void espeak_SetUriCallback(int (* UriCallback)(int, const char*, const char *))
-{//=======================================================================================
- ENTER("espeak_SetUriCallback");
- uri_callback = UriCallback;
-}
-
-
-ESPEAK_API void espeak_SetPhonemeCallback(int (* PhonemeCallback)(const char*))
-{//===========================================================================
- phoneme_callback = PhonemeCallback;
-}
-
-ESPEAK_API int espeak_Initialize(espeak_AUDIO_OUTPUT output_type, int buf_length, const char *path, int options)
-{//=============================================================================================================
-ENTER("espeak_Initialize");
- int param;
-
- // It seems that the wctype functions don't work until the locale has been set
- // to something other than the default "C". Then, not only Latin1 but also the
- // other characters give the correct results with iswalpha() etc.
-#ifdef PLATFORM_RISCOS
- setlocale(LC_CTYPE,"ISO8859-1");
-#else
- if(setlocale(LC_CTYPE,"en_US.UTF-8") == NULL)
- {
- if(setlocale(LC_CTYPE,"UTF-8") == NULL)
- setlocale(LC_CTYPE,"");
- }
-#endif
-
- init_path(path);
- initialise();
- select_output(output_type);
-
- // buflength is in mS, allocate 2 bytes per sample
- if(buf_length == 0)
- buf_length = 200;
- outbuf_size = (buf_length * samplerate)/500;
- outbuf = (unsigned char*)realloc(outbuf,outbuf_size);
- if((out_start = outbuf) == NULL)
- return(EE_INTERNAL_ERROR);
-
- // allocate space for event list. Allow 200 events per second.
- // Add a constant to allow for very small buf_length
- n_event_list = (buf_length*200)/1000 + 20;
- if((event_list = (espeak_EVENT *)realloc(event_list,sizeof(espeak_EVENT) * n_event_list)) == NULL)
- return(EE_INTERNAL_ERROR);
-
- option_phonemes = 0;
- option_phoneme_events = (options & 1);
-
- SetVoiceByName("default");
-
- for(param=0; param<N_SPEECH_PARAM; param++)
- param_stack[0].parameter[param] = param_defaults[param];
-
- SetParameter(espeakRATE,170,0);
- SetParameter(espeakVOLUME,100,0);
- SetParameter(espeakCAPITALS,option_capitals,0);
- SetParameter(espeakPUNCTUATION,option_punctuation,0);
- SetParameter(espeakWORDGAP,0,0);
- DoVoiceChange(voice);
-
-#ifdef USE_ASYNC
- fifo_init();
-#endif
-
- return(samplerate);
-}
-
-
-
-ESPEAK_API espeak_ERROR espeak_Synth(const void *text, size_t size,
- unsigned int position,
- espeak_POSITION_TYPE position_type,
- unsigned int end_position, unsigned int flags,
- unsigned int* unique_identifier, void* user_data)
-{//=====================================================================================
-#ifdef DEBUG_ENABLED
- ENTER("espeak_Synth");
- SHOW("espeak_Synth > position=%d, position_type=%d, end_position=%d, flags=%d, user_data=0x%x, text=%s\n", position, position_type, end_position, flags, user_data, text);
-#endif
-
- espeak_ERROR a_error=EE_INTERNAL_ERROR;
- static unsigned int temp_identifier;
-
- if (unique_identifier == NULL)
- {
- unique_identifier = &temp_identifier;
- }
- *unique_identifier = 0;
-
- if(synchronous_mode)
- {
- return(sync_espeak_Synth(0,text,size,position,position_type,end_position,flags,user_data));
- }
-
-#ifdef USE_ASYNC
- // Create the text command
- t_espeak_command* c1 = create_espeak_text(text, size, position, position_type, end_position, flags, user_data);
-
- // Retrieve the unique identifier
- *unique_identifier = c1->u.my_text.unique_identifier;
-
- // Create the "terminated msg" command (same uid)
- t_espeak_command* c2 = create_espeak_terminated_msg(*unique_identifier, user_data);
-
- // Try to add these 2 commands (single transaction)
- if (c1 && c2)
- {
- a_error = fifo_add_commands(c1, c2);
- if (a_error != EE_OK)
- {
- delete_espeak_command(c1);
- delete_espeak_command(c2);
- c1=c2=NULL;
- }
- }
- else
- {
- delete_espeak_command(c1);
- delete_espeak_command(c2);
- }
-
-#endif
- return a_error;
-} // end of espeak_Synth
-
-
-
-ESPEAK_API espeak_ERROR espeak_Synth_Mark(const void *text, size_t size,
- const char *index_mark,
- unsigned int end_position,
- unsigned int flags,
- unsigned int* unique_identifier,
- void* user_data)
-{//=========================================================================
-#ifdef DEBUG_ENABLED
- ENTER("espeak_Synth_Mark");
- SHOW("espeak_Synth_Mark > index_mark=%s, end_position=%d, flags=%d, text=%s\n", index_mark, end_position, flags, text);
-#endif
-
- espeak_ERROR a_error=EE_OK;
- static unsigned int temp_identifier;
-
- if (unique_identifier == NULL)
- {
- unique_identifier = &temp_identifier;
- }
- *unique_identifier = 0;
-
- if(synchronous_mode)
- {
- return(sync_espeak_Synth_Mark(0,text,size,index_mark,end_position,flags,user_data));
- }
-
-#ifdef USE_ASYNC
- // Create the mark command
- t_espeak_command* c1 = create_espeak_mark(text, size, index_mark, end_position,
- flags, user_data);
-
- // Retrieve the unique identifier
- *unique_identifier = c1->u.my_mark.unique_identifier;
-
- // Create the "terminated msg" command (same uid)
- t_espeak_command* c2 = create_espeak_terminated_msg(*unique_identifier, user_data);
-
- // Try to add these 2 commands (single transaction)
- if (c1 && c2)
- {
- a_error = fifo_add_commands(c1, c2);
- if (a_error != EE_OK)
- {
- delete_espeak_command(c1);
- delete_espeak_command(c2);
- c1=c2=NULL;
- }
- }
- else
- {
- delete_espeak_command(c1);
- delete_espeak_command(c2);
- }
-
-#endif
- return a_error;
-} // end of espeak_Synth_Mark
-
-
-
-ESPEAK_API espeak_ERROR espeak_Key(const char *key)
-{//================================================
- ENTER("espeak_Key");
- // symbolic name, symbolicname_character - is there a system resource of symbolicnames per language
-
- espeak_ERROR a_error = EE_OK;
-
- if(synchronous_mode)
- {
- sync_espeak_Key(key);
- return(EE_OK);
- }
-
-#ifdef USE_ASYNC
- t_espeak_command* c = create_espeak_key( key, NULL);
- a_error = fifo_add_command(c);
- if (a_error != EE_OK)
- {
- delete_espeak_command(c);
- }
-
-#endif
- return a_error;
-}
-
-
-ESPEAK_API espeak_ERROR espeak_Char(wchar_t character)
-{//===========================================
- ENTER("espeak_Char");
- // is there a system resource of character names per language?
-
-#ifdef USE_ASYNC
- espeak_ERROR a_error;
-
- if(synchronous_mode)
- {
- sync_espeak_Char(character);
- return(EE_OK);
- }
-
- t_espeak_command* c = create_espeak_char( character, NULL);
- a_error = fifo_add_command(c);
- if (a_error != EE_OK)
- {
- delete_espeak_command(c);
- }
- return a_error;
-#else
- sync_espeak_Char(character);
- return(EE_OK);
-#endif
-}
-
-
-ESPEAK_API espeak_ERROR espeak_SetVoiceByName(const char *name)
-{//============================================================
- ENTER("espeak_SetVoiceByName");
-
-//#ifdef USE_ASYNC
-// I don't think there's a need to queue change voice requests
-#ifdef deleted
- espeak_ERROR a_error;
-
- if(synchronous_mode)
- {
- return(SetVoiceByName(name));
- }
-
- t_espeak_command* c = create_espeak_voice_name(name);
- a_error = fifo_add_command(c);
- if (a_error != EE_OK)
- {
- delete_espeak_command(c);
- }
- return a_error;
-#else
- return(SetVoiceByName(name));
-#endif
-} // end of espeak_SetVoiceByName
-
-
-
-ESPEAK_API espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_selector)
-{//==============================================================================
- ENTER("espeak_SetVoiceByProperties");
-
-//#ifdef USE_ASYNC
-#ifdef deleted
- espeak_ERROR a_error;
-
- if(synchronous_mode)
- {
- return(SetVoiceByProperties(voice_selector));
- }
-
- t_espeak_command* c = create_espeak_voice_spec( voice_selector);
- a_error = fifo_add_command(c);
- if (a_error != EE_OK)
- {
- delete_espeak_command(c);
- }
- return a_error;
-#else
- return(SetVoiceByProperties(voice_selector));
-#endif
-} // end of espeak_SetVoiceByProperties
-
-
-ESPEAK_API int espeak_GetParameter(espeak_PARAMETER parameter, int current)
-{//========================================================================
- ENTER("espeak_GetParameter");
- // current: 0=default value, 1=current value
- if(current)
- {
- return(param_stack[0].parameter[parameter]);
- }
- else
- {
- return(param_defaults[parameter]);
- }
-} // end of espeak_GetParameter
-
-
-ESPEAK_API espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int relative)
-{//=============================================================================================
- ENTER("espeak_SetParameter");
-
-#ifdef USE_ASYNC
- espeak_ERROR a_error;
-
- if(synchronous_mode)
- {
- SetParameter(parameter,value,relative);
- return(EE_OK);
- }
-
- t_espeak_command* c = create_espeak_parameter(parameter, value, relative);
-
- a_error = fifo_add_command(c);
- if (a_error != EE_OK)
- {
- delete_espeak_command(c);
- }
- return a_error;
-#else
- SetParameter(parameter,value,relative);
- return(EE_OK);
-#endif
-}
-
-
-ESPEAK_API espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist)
-{//================================================================
- ENTER("espeak_SetPunctuationList");
- // Set the list of punctuation which are spoken for "some".
-
-#ifdef USE_ASYNC
- espeak_ERROR a_error;
-
- if(synchronous_mode)
- {
- sync_espeak_SetPunctuationList(punctlist);
- return(EE_OK);
- }
-
- t_espeak_command* c = create_espeak_punctuation_list( punctlist);
- a_error = fifo_add_command(c);
- if (a_error != EE_OK)
- {
- delete_espeak_command(c);
- }
- return a_error;
-#else
- sync_espeak_SetPunctuationList(punctlist);
- return(EE_OK);
-#endif
-} // end of espeak_SetPunctuationList
-
-
-ESPEAK_API void espeak_SetPhonemeTrace(int value, FILE *stream)
-{//============================================================
- ENTER("espeak_SetPhonemes");
- /* Controls the output of phoneme symbols for the text
- value=0 No phoneme output (default)
- value=1 Output the translated phoneme symbols for the text
- value=2 as (1), but also output a trace of how the translation was done (matching rules and list entries)
- */
- option_phonemes = value;
- f_trans = stream;
- if(stream == NULL)
- f_trans = stderr;
-
-} // end of espeak_SetPhonemes
-
-
-ESPEAK_API void espeak_CompileDictionary(const char *path, FILE *log, int flags)
-{//=============================================================================
- ENTER("espeak_CompileDictionary");
- CompileDictionary(path, dictionary_name, log, NULL, flags);
-} // end of espeak_CompileDirectory
-
-
-ESPEAK_API espeak_ERROR espeak_Cancel(void)
-{//===============================
-#ifdef USE_ASYNC
- ENTER("espeak_Cancel");
- fifo_stop();
- event_clear_all();
-
- if(my_mode == AUDIO_OUTPUT_PLAYBACK)
- {
- wave_close(my_audio);
- }
- SHOW_TIME("espeak_Cancel > LEAVE");
-#endif
- embedded_value[EMBED_T] = 0; // reset echo for pronunciation announcements
- return EE_OK;
-} // end of espeak_Cancel
-
-
-ESPEAK_API int espeak_IsPlaying(void)
-{//==================================
-// ENTER("espeak_IsPlaying");
-#ifdef USE_ASYNC
- if((my_mode == AUDIO_OUTPUT_PLAYBACK) && wave_is_busy(my_audio))
- return(1);
-
- return(fifo_is_busy());
-#else
- return(0);
-#endif
-} // end of espeak_IsPlaying
-
-
-ESPEAK_API espeak_ERROR espeak_Synchronize(void)
-{//=============================================
-#ifdef USE_ASYNC
- SHOW_TIME("espeak_Synchronize > ENTER");
- while (espeak_IsPlaying())
- {
- usleep(20000);
- }
-#endif
- SHOW_TIME("espeak_Synchronize > LEAVE");
- return EE_OK;
-} // end of espeak_Synchronize
-
-
-extern void FreePhData(void);
-
-ESPEAK_API espeak_ERROR espeak_Terminate(void)
-{//===========================================
- ENTER("espeak_Terminate");
-#ifdef USE_ASYNC
- fifo_stop();
- fifo_terminate();
- event_terminate();
-
- if(my_mode == AUDIO_OUTPUT_PLAYBACK)
- {
- wave_close(my_audio);
- wave_terminate();
- }
-
-#endif
- Free(event_list);
- event_list = NULL;
- Free(outbuf);
- outbuf = NULL;
- FreePhData();
-
- return EE_OK;
-} // end of espeak_Terminate
-
-ESPEAK_API const char *espeak_Info(void)
-{//=======================================
- return(version_string);
-}
-
-#pragma GCC visibility pop
-
-
diff --git a/navit/support/espeak/speak_lib.h b/navit/support/espeak/speak_lib.h
deleted file mode 100644
index 25c24c173..000000000
--- a/navit/support/espeak/speak_lib.h
+++ /dev/null
@@ -1,601 +0,0 @@
-#ifndef SPEAK_LIB_H
-#define SPEAK_LIB_H
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-
-/*************************************************************/
-/* This is the header file for the library version of espeak */
-/* */
-/*************************************************************/
-
-#include <stdio.h>
-#include <wchar.h>
-#define ESPEAK_API_REVISION 5
-/*
-Revision 2
- Added parameter "options" to eSpeakInitialize()
-
-Revision 3
- Added espeakWORDGAP to espeak_PARAMETER
-
-Revision 4
- Added flags parameter to espeak_CompileDictionary()
-
-Revision 5
- Added espeakCHARS_16BIT
-*/
- /********************/
- /* Initialization */
- /********************/
-
-
-typedef enum {
- espeakEVENT_LIST_TERMINATED = 0, // Retrieval mode: terminates the event list.
- espeakEVENT_WORD = 1, // Start of word
- espeakEVENT_SENTENCE, // Start of sentence
- espeakEVENT_MARK, // Mark
- espeakEVENT_PLAY, // Audio element
- espeakEVENT_END, // End of sentence or clause
- espeakEVENT_MSG_TERMINATED, // End of message
- espeakEVENT_PHONEME // Phoneme, if enabled in espeak_Initialize()
-} espeak_EVENT_TYPE;
-
-
-
-typedef struct {
- espeak_EVENT_TYPE type;
- unsigned int unique_identifier; // message identifier (or 0 for key or character)
- int text_position; // the number of characters from the start of the text
- int length; // word length, in characters (for espeakEVENT_WORD)
- int audio_position; // the time in mS within the generated speech output data
- int sample; // sample id (internal use)
- void* user_data; // pointer supplied by the calling program
- union {
- int number; // used for WORD and SENTENCE events. For PHONEME events this is the phoneme mnemonic.
- const char *name; // used for MARK and PLAY events. UTF8 string
- } id;
-} espeak_EVENT;
-/*
- When a message is supplied to espeak_synth, the request is buffered and espeak_synth returns. When the message is really processed, the callback function will be repetedly called.
-
-
- In RETRIEVAL mode, the callback function supplies to the calling program the audio data and an event list terminated by 0 (LIST_TERMINATED).
-
- In PLAYBACK mode, the callback function is called as soon as an event happens.
-
- For example suppose that the following message is supplied to espeak_Synth:
- "hello, hello."
-
-
- * Once processed in RETRIEVAL mode, it could lead to 3 calls of the callback function :
-
- ** Block 1:
- <audio data> +
- List of events: SENTENCE + WORD + LIST_TERMINATED
-
- ** Block 2:
- <audio data> +
- List of events: WORD + END + LIST_TERMINATED
-
- ** Block 3:
- no audio data
- List of events: MSG_TERMINATED + LIST_TERMINATED
-
-
- * Once processed in PLAYBACK mode, it could lead to 5 calls of the callback function:
-
- ** SENTENCE
- ** WORD (call when the sounds are actually played)
- ** WORD
- ** END (call when the end of sentence is actually played.)
- ** MSG_TERMINATED
-
-
- The MSG_TERMINATED event is the last event. It can inform the calling program to clear the user data related to the message.
- So if the synthesis must be stopped, the callback function is called for each pending message with the MSG_TERMINATED event.
-
- A MARK event indicates a <mark> element in the text.
- A PLAY event indicates an <audio> element in the text, for which the calling program should play the named sound file.
-*/
-
-
-
-typedef enum {
- POS_CHARACTER = 1,
- POS_WORD,
- POS_SENTENCE
-} espeak_POSITION_TYPE;
-
-
-typedef enum {
- /* PLAYBACK mode: plays the audio data, supplies events to the calling program*/
- AUDIO_OUTPUT_PLAYBACK,
-
- /* RETRIEVAL mode: supplies audio data and events to the calling program */
- AUDIO_OUTPUT_RETRIEVAL,
-
- /* SYNCHRONOUS mode: as RETRIEVAL but doesn't return until synthesis is completed */
- AUDIO_OUTPUT_SYNCHRONOUS,
-
- /* Synchronous playback */
- AUDIO_OUTPUT_SYNCH_PLAYBACK
-
-} espeak_AUDIO_OUTPUT;
-
-
-typedef enum {
- EE_OK=0,
- EE_INTERNAL_ERROR=-1,
- EE_BUFFER_FULL=1,
- EE_NOT_FOUND=2
-} espeak_ERROR;
-
-
-#ifdef __cplusplus
-extern "C"
-#endif
-int espeak_Initialize(espeak_AUDIO_OUTPUT output, int buflength, const char *path, int options);
-/* Must be called before any synthesis functions are called.
- output: the audio data can either be played by eSpeak or passed back by the SynthCallback function.
-
- buflength: The length in mS of sound buffers passed to the SynthCallback function.
-
- path: The directory which contains the espeak-data directory, or NULL for the default location.
-
- options: bit 0: 1=allow espeakEVENT_PHONEME events.
-
-
- Returns: sample rate in Hz, or -1 (EE_INTERNAL_ERROR).
-*/
-
-typedef int (t_espeak_callback)(short*, int, espeak_EVENT*);
-
-#ifdef __cplusplus
-extern "C"
-#endif
-void espeak_SetSynthCallback(t_espeak_callback* SynthCallback);
-/* Must be called before any synthesis functions are called.
- This specifies a function in the calling program which is called when a buffer of
- speech sound data has been produced.
-
-
- The callback function is of the form:
-
-int SynthCallback(short *wav, int numsamples, espeak_EVENT *events);
-
- wav: is the speech sound data which has been produced.
- NULL indicates that the synthesis has been completed.
-
- numsamples: is the number of entries in wav. This number may vary, may be less than
- the value implied by the buflength parameter given in espeak_Initialize, and may
- sometimes be zero (which does NOT indicate end of synthesis).
-
- events: an array of espeak_EVENT items which indicate word and sentence events, and
- also the occurance if <mark> and <audio> elements within the text. The list of
- events is terminated by an event of type = 0.
-
-
- Callback returns: 0=continue synthesis, 1=abort synthesis.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-void espeak_SetUriCallback(int (*UriCallback)(int, const char*, const char*));
-/* This function may be called before synthesis functions are used, in order to deal with
- <audio> tags. It specifies a callback function which is called when an <audio> element is
- encountered and allows the calling program to indicate whether the sound file which
- is specified in the <audio> element is available and is to be played.
-
- The callback function is of the form:
-
-int UriCallback(int type, const char *uri, const char *base);
-
- type: type of callback event. Currently only 1= <audio> element
-
- uri: the "src" attribute from the <audio> element
-
- base: the "xml:base" attribute (if any) from the <speak> element
-
- Return: 1=don't play the sound, but speak the text alternative.
- 0=place a PLAY event in the event list at the point where the <audio> element
- occurs. The calling program can then play the sound at that point.
-*/
-
-
- /********************/
- /* Synthesis */
- /********************/
-
-
-#define espeakCHARS_AUTO 0
-#define espeakCHARS_UTF8 1
-#define espeakCHARS_8BIT 2
-#define espeakCHARS_WCHAR 3
-#define espeakCHARS_16BIT 4
-
-#define espeakSSML 0x10
-#define espeakPHONEMES 0x100
-#define espeakENDPAUSE 0x1000
-#define espeakKEEP_NAMEDATA 0x2000
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_Synth(const void *text,
- size_t size,
- unsigned int position,
- espeak_POSITION_TYPE position_type,
- unsigned int end_position,
- unsigned int flags,
- unsigned int* unique_identifier,
- void* user_data);
-/* Synthesize speech for the specified text. The speech sound data is passed to the calling
- program in buffers by means of the callback function specified by espeak_SetSynthCallback(). The command is asynchronous: it is internally buffered and returns as soon as possible. If espeak_Initialize was previously called with AUDIO_OUTPUT_PLAYBACK as argument, the sound data are played by eSpeak.
-
- text: The text to be spoken, terminated by a zero character. It may be either 8-bit characters,
- wide characters (wchar_t), or UTF8 encoding. Which of these is determined by the "flags"
- parameter.
-
- size: Equal to (or greatrer than) the size of the text data, in bytes. This is used in order
- to allocate internal storage space for the text. This value is not used for
- AUDIO_OUTPUT_SYNCHRONOUS mode.
-
- position: The position in the text where speaking starts. Zero indicates speak from the
- start of the text.
-
- position_type: Determines whether "position" is a number of characters, words, or sentences.
- Values:
-
- end_position: If set, this gives a character position at which speaking will stop. A value
- of zero indicates no end position.
-
- flags: These may be OR'd together:
- Type of character codes, one of:
- espeakCHARS_UTF8 UTF8 encoding
- espeakCHARS_8BIT The 8 bit ISO-8859 character set for the particular language.
- espeakCHARS_AUTO 8 bit or UTF8 (this is the default)
- espeakCHARS_WCHAR Wide characters (wchar_t)
-
- espeakSSML Elements within < > are treated as SSML elements, or if not recognised are ignored.
-
- espeakPHONEMES Text within [[ ]] is treated as phonemes codes (in espeak's Hirshenbaum encoding).
-
- espeakENDPAUSE If set then a sentence pause is added at the end of the text. If not set then
- this pause is suppressed.
-
- unique_identifier: message identifier; helpful for identifying later
- data supplied to the callback.
-
- user_data: pointer which will be passed to the callback function.
-
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
- you may try after a while to call the function again.
- EE_INTERNAL_ERROR.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_Synth_Mark(const void *text,
- size_t size,
- const char *index_mark,
- unsigned int end_position,
- unsigned int flags,
- unsigned int* unique_identifier,
- void* user_data);
-/* Synthesize speech for the specified text. Similar to espeak_Synth() but the start position is
- specified by the name of a <mark> element in the text.
-
- index_mark: The "name" attribute of a <mark> element within the text which specified the
- point at which synthesis starts. UTF8 string.
-
- For the other parameters, see espeak_Synth()
-
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
- you may try after a while to call the function again.
- EE_INTERNAL_ERROR.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_Key(const char *key_name);
-/* Speak the name of a keyboard key.
- If key_name is a single character, it speaks the name of the character.
- Otherwise, it speaks key_name as a text string.
-
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
- you may try after a while to call the function again.
- EE_INTERNAL_ERROR.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_Char(wchar_t character);
-/* Speak the name of the given character
-
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
- you may try after a while to call the function again.
- EE_INTERNAL_ERROR.
-*/
-
-
-
-
- /***********************/
- /* Speech Parameters */
- /***********************/
-
-typedef enum {
- espeakSILENCE=0, /* internal use */
- espeakRATE=1,
- espeakVOLUME=2,
- espeakPITCH=3,
- espeakRANGE=4,
- espeakPUNCTUATION=5,
- espeakCAPITALS=6,
- espeakWORDGAP=7,
- espeakOPTIONS=8, // reserved for misc. options. not yet used
- espeakINTONATION=9,
-
- espeakRESERVED1=10,
- espeakRESERVED2=11,
- espeakEMPHASIS, /* internal use */
- espeakLINELENGTH, /* internal use */
- espeakVOICETYPE, // internal, 1=mbrola
- N_SPEECH_PARAM /* last enum */
-} espeak_PARAMETER;
-
-typedef enum {
- espeakPUNCT_NONE=0,
- espeakPUNCT_ALL=1,
- espeakPUNCT_SOME=2
-} espeak_PUNCT_TYPE;
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_SetParameter(espeak_PARAMETER parameter, int value, int relative);
-/* Sets the value of the specified parameter.
- relative=0 Sets the absolute value of the parameter.
- relative=1 Sets a relative value of the parameter.
-
- parameter:
- espeakRATE: speaking speed in word per minute.
-
- espeakVOLUME: volume in range 0-100 0=silence
-
- espeakPITCH: base pitch, range 0-100. 50=normal
-
- espeakRANGE: pitch range, range 0-100. 0-monotone, 50=normal
-
- espeakPUNCTUATION: which punctuation characters to announce:
- value in espeak_PUNCT_TYPE (none, all, some),
- see espeak_GetParameter() to specify which characters are announced.
-
- espeakCAPITALS: announce capital letters by:
- 0=none,
- 1=sound icon,
- 2=spelling,
- 3 or higher, by raising pitch. This values gives the amount in Hz by which the pitch
- of a word raised to indicate it has a capital letter.
-
- espeakWORDGAP: pause between words, units of 10mS (at the default speed)
-
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
- you may try after a while to call the function again.
- EE_INTERNAL_ERROR.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-int espeak_GetParameter(espeak_PARAMETER parameter, int current);
-/* current=0 Returns the default value of the specified parameter.
- current=1 Returns the current value of the specified parameter, as set by SetParameter()
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_SetPunctuationList(const wchar_t *punctlist);
-/* Specified a list of punctuation characters whose names are to be spoken when the
- value of the Punctuation parameter is set to "some".
-
- punctlist: A list of character codes, terminated by a zero character.
-
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
- you may try after a while to call the function again.
- EE_INTERNAL_ERROR.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-void espeak_SetPhonemeTrace(int value, FILE *stream);
-/* Controls the output of phoneme symbols for the text
- value=0 No phoneme output (default)
- value=1 Output the translated phoneme symbols for the text
- value=2 as (1), but also output a trace of how the translation was done (matching rules and list entries)
-
- stream output stream for the phoneme symbols (and trace). If stream=NULL then it uses stdout.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-void espeak_CompileDictionary(const char *path, FILE *log, int flags);
-/* Compile pronunciation dictionary for a language which corresponds to the currently
- selected voice. The required voice should be selected before calling this function.
-
- path: The directory which contains the language's '_rules' and '_list' files.
- 'path' should end with a path separator character ('/').
- log: Stream for error reports and statistics information. If log=NULL then stderr will be used.
-
- flags: Bit 0: include source line information for debug purposes (This is displayed with the
- -X command line option).
-*/
- /***********************/
- /* Voice Selection */
- /***********************/
-
-
-// voice table
-typedef struct {
- const char *name; // a given name for this voice. UTF8 string.
- const char *languages; // list of pairs of (byte) priority + (string) language (and dialect qualifier)
- const char *identifier; // the filename for this voice within espeak-data/voices
- unsigned char gender; // 0=none 1=male, 2=female,
- unsigned char age; // 0=not specified, or age in years
- unsigned char variant; // only used when passed as a parameter to espeak_SetVoiceByProperties
- unsigned char xx1; // for internal use
- int score; // for internal use
- void *spare; // for internal use
-} espeak_VOICE;
-
-/* Note: The espeak_VOICE structure is used for two purposes:
- 1. To return the details of the available voices.
- 2. As a parameter to espeak_SetVoiceByProperties() in order to specify selection criteria.
-
- In (1), the "languages" field consists of a list of (UTF8) language names for which this voice
- may be used, each language name in the list is terminated by a zero byte and is also preceded by
- a single byte which gives a "priority" number. The list of languages is terminated by an
- additional zero byte.
-
- A language name consists of a language code, optionally followed by one or more qualifier (dialect)
- names separated by hyphens (eg. "en-uk"). A voice might, for example, have languages "en-uk" and
- "en". Even without "en" listed, voice would still be selected for the "en" language (because
- "en-uk" is related) but at a lower priority.
-
- The priority byte indicates how the voice is preferred for the language. A low number indicates a
- more preferred voice, a higher number indicates a less preferred voice.
-
- In (2), the "languages" field consists simply of a single (UTF8) language name, with no preceding
- priority byte.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec);
-/* Reads the voice files from espeak-data/voices and creates an array of espeak_VOICE pointers.
- The list is terminated by a NULL pointer
-
- If voice_spec is NULL then all voices are listed.
- If voice spec is give, then only the voices which are compatible with the voice_spec
- are listed, and they are listed in preference order.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_SetVoiceByName(const char *name);
-/* Searches for a voice with a matching "name" field. Language is not considered.
- "name" is a UTF8 string.
-
- Return: EE_OK: operation achieved
- EE_BUFFER_FULL: the command can not be buffered;
- you may try after a while to call the function again.
- EE_INTERNAL_ERROR.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_SetVoiceByProperties(espeak_VOICE *voice_spec);
-/* An espeak_VOICE structure is used to pass criteria to select a voice. Any of the following
- fields may be set:
-
- name NULL, or a voice name
-
- languages NULL, or a single language string (with optional dialect), eg. "en-uk", or "en"
-
- gender 0=not specified, 1=male, 2=female
-
- age 0=not specified, or an age in years
-
- variant After a list of candidates is produced, scored and sorted, "variant" is used to index
- that list and choose a voice.
- variant=0 takes the top voice (i.e. best match). variant=1 takes the next voice, etc
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_VOICE *espeak_GetCurrentVoice(void);
-/* Returns the espeak_VOICE data for the currently selected voice.
- This is not affected by temporary voice changes caused by SSML elements such as <voice> and <s>
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_Cancel(void);
-/* Stop immediately synthesis and audio output of the current text. When this
- function returns, the audio output is fully stopped and the synthesizer is ready to
- synthesize a new message.
-
- Return: EE_OK: operation achieved
- EE_INTERNAL_ERROR.
-*/
-
-
-#ifdef __cplusplus
-extern "C"
-#endif
-int espeak_IsPlaying(void);
-/* Returns 1 if audio is played, 0 otherwise.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_Synchronize(void);
-/* This function returns when all data have been spoken.
- Return: EE_OK: operation achieved
- EE_INTERNAL_ERROR.
-*/
-
-#ifdef __cplusplus
-extern "C"
-#endif
-espeak_ERROR espeak_Terminate(void);
-/* last function to be called.
- Return: EE_OK: operation achieved
- EE_INTERNAL_ERROR.
-*/
-
-
-#ifdef __cplusplus
-extern "C"
-#endif
-const char *espeak_Info(void);
-/* Returns the version number string.
- The parameter is for future use, and should be set to NULL
-*/
-#endif
diff --git a/navit/support/espeak/speech.h b/navit/support/espeak/speech.h
deleted file mode 100755
index 9673b0c8b..000000000
--- a/navit/support/espeak/speech.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-
-#include <sys/types.h>
-
-// conditional compilation options
-#define INCLUDE_KLATT
-
-#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
-#define ARCH_BIG
-#endif
-
-/* #define PLATFORM_POSIX */
-#define PATHSEP '/'
-// USE_PORTAUDIO or USE_PULSEAUDIO are now defined in the makefile
-//#define USE_PORTAUDIO
-//#define USE_PULSEAUDIO
-#define USE_NANOSLEEP
-//#define ESPEAK_API extern "C"
-
-#ifdef LIBRARY
-#define USE_ASYNC
-//#define USE_MBROLA_LIB
-#endif
-
-#ifdef _ESPEAKEDIT
-#define USE_PORTAUDIO
-#define USE_ASYNC
-#define LOG_FRAMES // write keyframe info to log-espeakedit
-#endif
-
-// will look for espeak_data directory here, and also in user's home directory
-#ifndef PATH_ESPEAK_DATA
- #define PATH_ESPEAK_DATA "/usr/share/espeak-data"
-#endif
-
-typedef unsigned short USHORT;
-typedef unsigned char UCHAR;
-typedef double DOUBLEX;
-
-
-
-
-typedef struct {
- const char *mnem;
- int value;
-} MNEM_TAB;
-int LookupMnem(MNEM_TAB *table, char *string);
-
-
-#ifdef PLATFORM_WINDOWS
-#define N_PATH_HOME 220
-#define ESPEAK_API
-#else
-#define N_PATH_HOME 150
-#ifdef __cplusplus
-#define ESPEAK_API extern "C"
-#else
-#define ESPEAK_API
-#endif
-#endif
-
-extern char path_home[N_PATH_HOME]; // this is the espeak-data directory
-
-extern void strncpy0(char *to,const char *from, int size);
-int GetFileLength(const char *filename);
-char *Alloc(int size);
-void Free(void *ptr);
-
diff --git a/navit/support/espeak/synth_mbrola.c b/navit/support/espeak/synth_mbrola.c
deleted file mode 100755
index 1055f549f..000000000
--- a/navit/support/espeak/synth_mbrola.c
+++ /dev/null
@@ -1,760 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <wctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "translate.h"
-#include "voice.h"
-
-extern int Read4Bytes(FILE *f);
-extern void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pitch_range);
-
-#ifdef USE_MBROLA_LIB
-
-extern unsigned char *outbuf;
-
-#ifndef PLATFORM_WINDOWS
-
-#include "mbrolib.h"
-void * mb_handle;
-
-#else
-#include <windows.h>
-typedef void (WINAPI *PROCVV)(void);
-typedef void (WINAPI *PROCVI)(int);
-typedef void (WINAPI *PROCVF)(float);
-typedef int (WINAPI *PROCIV)();
-typedef int (WINAPI *PROCIC) (char *);
-typedef int (WINAPI *PROCISI)(short *,int);
-typedef char* (WINAPI *PROCVCI)(char *,int);
-
-PROCIC init_MBR;
-PROCIC write_MBR;
-PROCIV flush_MBR;
-PROCISI read_MBR;
-PROCVV close_MBR;
-PROCVV reset_MBR;
-PROCIV lastError_MBR;
-PROCVCI lastErrorStr_MBR;
-PROCVI setNoError_MBR;
-PROCVI setFreq_MBR;
-PROCVF setVolumeRatio_MBR;
-
-
-
-HINSTANCE hinstDllMBR = NULL;
-
-
-BOOL load_MBR()
-{
- if(hinstDllMBR != NULL)
- return TRUE; // already loaded
-
- if (!(hinstDllMBR=LoadLibraryA("mbrola.dll")))
- return FALSE;
- init_MBR =(PROCIC) GetProcAddress(hinstDllMBR,"init_MBR");
- write_MBR =(PROCIC) GetProcAddress(hinstDllMBR,"write_MBR");
- flush_MBR =(PROCIV) GetProcAddress(hinstDllMBR,"flush_MBR");
- read_MBR =(PROCISI) GetProcAddress(hinstDllMBR,"read_MBR");
- close_MBR =(PROCVV) GetProcAddress(hinstDllMBR,"close_MBR");
- reset_MBR =(PROCVV) GetProcAddress(hinstDllMBR,"reset_MBR");
- lastError_MBR =(PROCIV) GetProcAddress(hinstDllMBR,"lastError_MBR");
- lastErrorStr_MBR =(PROCVCI) GetProcAddress(hinstDllMBR,"lastErrorStr_MBR");
- setNoError_MBR =(PROCVI) GetProcAddress(hinstDllMBR,"setNoError_MBR");
- setVolumeRatio_MBR =(PROCVF) GetProcAddress(hinstDllMBR,"setVolumeRatio_MBR");
- return TRUE;
-}
-
-
-void unload_MBR()
-{
- if (hinstDllMBR)
- {
- FreeLibrary (hinstDllMBR);
- hinstDllMBR=NULL;
- }
-}
-
-#endif // windows
-#endif // USE_MBROLA_LIB
-
-
-static MBROLA_TAB *mbrola_tab = NULL;
-static int mbrola_control = 0;
-
-
-
-
-espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int srate)
-{//===================================================================================
-// Load a phoneme name translation table from espeak-data/mbrola
-
- int size;
- int ix;
- int *pw;
- FILE *f_in;
- char path[sizeof(path_home)+15];
-
- mbrola_name[0] = 0;
- mbrola_delay = 0;
-
- if(mbrola_voice == NULL)
- {
- samplerate = samplerate_native;
- SetParameter(espeakVOICETYPE,0,0);
- return(EE_OK);
- }
-
- sprintf(path,"%s/mbrola/%s",path_home,mbrola_voice);
-#ifdef USE_MBROLA_LIB
-#ifdef PLATFORM_WINDOWS
- if(load_MBR() == FALSE) // load mbrola.dll
- return(EE_INTERNAL_ERROR);
-
- if(init_MBR(path) != 0) // initialise the required mbrola voice
- return(EE_NOT_FOUND);
-
- setNoError_MBR(1); // don't stop on phoneme errors
-#else
- mb_handle = mbrolib_init(srate);
- mbrolib_parameter m_parameters;
-
- if(mb_handle == NULL)
- return(EE_INTERNAL_ERROR);
-
- MBROLIB_ERROR a_status = mbrolib_set_voice(mb_handle, mbrola_voice);
- if(a_status != MBROLIB_OK)
- return(EE_NOT_FOUND);
-#endif // not windows
-#endif // USE_MBROLA_LIB
-
- // read eSpeak's mbrola phoneme translation data, eg. en1_phtrans
- sprintf(path,"%s/mbrola_ph/%s",path_home,phtrans);
- size = GetFileLength(path);
- if((f_in = fopen(path,"r")) == NULL)
- return(EE_NOT_FOUND);
-
- if((mbrola_tab = (MBROLA_TAB *)realloc(mbrola_tab,size)) == NULL)
- {
- fclose(f_in);
- return(EE_INTERNAL_ERROR);
- }
-
- mbrola_control = Read4Bytes(f_in);
- pw = (int *)mbrola_tab;
- for(ix=4; ix<size; ix+=4)
- {
- *pw++ = Read4Bytes(f_in);
- }
- fread(mbrola_tab,size,1,f_in);
- fclose(f_in);
-
-
-#ifdef USE_MBROLA_LIB
-#ifdef PLATFORM_WINDOWS
- setVolumeRatio_MBR((float)(mbrola_control & 0xff) /16.0f);
-#else
- mbrolib_get_parameter(mb_handle,&m_parameters);
- m_parameters.ignore_error = 1;
- m_parameters.volume_ratio = (float)(mbrola_control & 0xff) /16.0;
- mbrolib_set_parameter(mb_handle,&m_parameters);
-#endif // not windows
-#endif // USE_MBROLA_LIB
-
- option_quiet = 1;
- samplerate = srate;
- if(srate == 22050)
- SetParameter(espeakVOICETYPE,0,0);
- else
- SetParameter(espeakVOICETYPE,1,0);
- strcpy(mbrola_name,mbrola_voice);
- mbrola_delay = 3800; // improve synchronization of events
- return(EE_OK);
-} // end of LoadMbrolaTable
-
-
-static int GetMbrName(PHONEME_LIST *plist, PHONEME_TAB *ph, PHONEME_TAB *ph_prev, PHONEME_TAB *ph_next, int *name2, int *split, int *control)
-{//==========================================================================================================================================
-// Look up a phoneme in the mbrola phoneme name translation table
-// It may give none, 1, or 2 mbrola phonemes
- int mnem = ph->mnemonic;
- MBROLA_TAB *pr;
- PHONEME_TAB *other_ph;
- int found = 0;
-
- // control
- // bit 0 skip the next phoneme
- // bit 1 match this and Previous phoneme
- // bit 2 only at the start of a word
- // bit 3 don't match two phonemes across a word boundary
-
- pr = mbrola_tab;
- while(pr->name != 0)
- {
- if(mnem == pr->name)
- {
- if(pr->next_phoneme == 0)
- found = 1;
- else
- if((pr->next_phoneme == ':') && (plist->synthflags & SFLAG_LENGTHEN))
- {
- found = 1;
- }
- else
- {
- if(pr->control & 2)
- other_ph = ph_prev;
- else
- if((pr->control & 8) && ((plist+1)->newword))
- other_ph = phoneme_tab[phPAUSE]; // don't match the next phoneme over a word boundary
- else
- other_ph = ph_next;
-
- if((pr->next_phoneme == other_ph->mnemonic) ||
- ((pr->next_phoneme == 2) && (other_ph->type == phVOWEL)) ||
- ((pr->next_phoneme == '_') && (other_ph->type == phPAUSE)))
- {
- found = 1;
- }
- }
-
- if((pr->control & 4) && (plist->newword == 0)) // only at start of word
- found = 0;
-
- if(found)
- {
- *name2 = pr->mbr_name2;
- *split = pr->percent;
- *control = pr->control;
- return(pr->mbr_name);
- }
- }
-
- pr++;
- }
- *name2=0;
- *split=0;
- *control=0;
- return(mnem);
-}
-
-
-static char *WritePitch(int env, int pitch1, int pitch2, int split, int final)
-{//===========================================================================
-// final=1: only give the final pitch value.
- int x;
- int ix;
- int pitch_base;
- int pitch_range;
- int p1,p2,p_end;
- unsigned char *pitch_env;
- int max = -1;
- int min = 999;
- int y_max=0;
- int y_min=0;
- int env100 = 80; // apply the pitch change only over this proportion of the mbrola phoneme(s)
- int y2;
- int y[4];
- int env_split;
- char buf[50];
- static char output[50];
-
- output[0] = 0;
- pitch_env = envelope_data[env];
-
-
- SetPitch2(voice, pitch1, pitch2, &pitch_base, &pitch_range);
-
-
- env_split = (split * 128)/100;
- if(env_split < 0)
- env_split = 0-env_split;
-
- // find max and min in the pitch envelope
- for(x=0; x<128; x++)
- {
- if(pitch_env[x] > max)
- {
- max = pitch_env[x];
- y_max = x;
- }
- if(pitch_env[x] < min)
- {
- min = pitch_env[x];
- y_min = x;
- }
- }
- // set an additional pitch point half way through the phoneme.
- // but look for a maximum or a minimum and use that instead
- y[2] = 64;
- if((y_max > 0) && (y_max < 127))
- {
- y[2] = y_max;
- }
- if((y_min > 0) && (y_min < 127))
- {
- y[2] = y_min;
- }
- y[1] = y[2] / 2;
- y[3] = y[2] + (127 - y[2])/2;
-
- // set initial pitch
- p1 = ((pitch_env[0]*pitch_range)>>8) + pitch_base; // Hz << 12
- p_end = ((pitch_env[127]*pitch_range)>>8) + pitch_base;
-
-
- if(split >= 0)
- {
- sprintf(buf," 0 %d",p1/4096);
- strcat(output,buf);
- }
-
- // don't use intermediate pitch points for linear rise and fall
- if(env > 1)
- {
- for(ix=1; ix<4; ix++)
- {
- p2 = ((pitch_env[y[ix]]*pitch_range)>>8) + pitch_base;
-
- if(split > 0)
- {
- y2 = (y[ix] * env100)/env_split;
- }
- else
- if(split < 0)
- {
- y2 = ((y[ix]-env_split) * env100)/env_split;
- }
- else
- {
- y2 = (y[ix] * env100)/128;
- }
- if((y2 > 0) && (y2 <= env100))
- {
- sprintf(buf," %d %d",y2,p2/4096);
- strcat(output,buf);
- }
- }
- }
-
- p_end = p_end/4096;
- if(split <= 0)
- {
- sprintf(buf," %d %d",env100,p_end);
- strcat(output,buf);
- }
- if(env100 < 100)
- {
- sprintf(buf," %d %d",100,p_end);
- strcat(output,buf);
- }
- strcat(output,"\n");
-
- if(final)
- sprintf(output,"\t100 %d\n",p_end);
- return(output);
-} // end of WritePitch
-
-
-#ifdef USE_MBROLA_LIB
-
-static void MbrolaMarker(int type, int char_posn, int length, int value)
-{//=====================================================================
-
- MarkerEvent(type,(char_posn & 0xffffff) | (length << 24),value,outbuf);
-
-}
-
-
-static void MbrolaEmbedded(int &embix, int sourceix)
-{//=================================================
- // There were embedded commands in the text at this point
- unsigned int word; // bit 7=last command for this word, bits 5,6 sign, bits 0-4 command
- unsigned int value;
- int command;
- int sign=0;
-
- do {
- word = embedded_list[embix++];
- value = word >> 8;
- command = word & 0x1f;
-
- if((word & 0x60) == 0x60)
- sign = -1;
- else
- if((word & 0x60) == 0x40)
- sign = 1;
-
- if(command < N_EMBEDDED_VALUES)
- {
- if(sign == 0)
- embedded_value[command] = value;
- else
- embedded_value[command] += (value * sign);
- }
-
- switch(command & 0x1f)
- {
- case EMBED_M: // named marker
- MbrolaMarker(espeakEVENT_MARK, (sourceix & 0x7ff) + clause_start_char, 0, value);
- break;
- }
- } while ((word & 0x80) == 0);
-}
-
-
-#ifdef PLATFORM_WINDOWS
-static int MbrolaSynth(char *p_mbrola)
-{//===================================
-// p_mbrola is a string of mbrola pho lines - Windows
- int len;
- int finished;
- int result=0;
-
- if(synth_callback == NULL)
- return(1);
-
- if(p_mbrola == NULL)
- flush_MBR();
- else
- result = write_MBR(p_mbrola);
-
-
- finished = 0;
- while(!finished && ((len = read_MBR((short *)outbuf, outbuf_size/2)) > 0))
- {
- out_ptr = outbuf + len*2;
-
- if(event_list)
- {
- event_list[event_list_ix].type = espeakEVENT_LIST_TERMINATED; // indicates end of event list
- event_list[event_list_ix].user_data = 0;
- }
- count_samples += len;
- finished = synth_callback((short *)outbuf, len, event_list);
- event_list_ix=0;
- }
-
- if(finished)
- {
- // cancelled by user, discard any unused mbrola speech
- flush_MBR();
- while((len = read_MBR((short *)outbuf, outbuf_size/2)) > 0);
- }
- return(finished);
-} // end of SynthMbrola
-#else
-
-static int MbrolaSynth(char *p_mbrola)
-{//===================================
-// p_mbrola is a string of mbrola pho lines - Linux
-
-// This is wrong
-// It must be called from WavegenFill()
-
- int len;
- int finished;
- int result=0;
-
- if(synth_callback == NULL)
- return(1);
-
- if(p_mbrola == NULL)
- mbrolib_flush(mb_handle);
- else
- result = mbrolib_write(mb_handle,p_mbrola,strlen(p_mbrola));
-
-
- finished = 0;
- while(!finished && (mbrolib_read(mb_handle, (short *)out_ptr, (out_end - out_ptr)/2, &len) == MBROLIB_OK))
- {
- if(len == 0)
- break;
-
- out_ptr += (len*2);
-
- if(event_list)
- {
- event_list[event_list_ix].type = espeakEVENT_LIST_TERMINATED; // indicates end of event list
- event_list[event_list_ix].user_data = 0;
- }
- count_samples += len;
- finished = synth_callback((short *)outbuf, len, event_list);
- event_list_ix=0;
- }
-
- if(finished)
- {
- // cancelled by user, discard any unused mbrola speech
- mbrolib_flush(mb_handle);
- while(mbrolib_read(mb_handle, (short *)outbuf, outbuf_size/2, &len) == MBROLIB_OK)
- {
- if(len == 0)
- break;
- }
- }
- return(finished);
-} // end of SynthMbrola
-#endif // not windows
-#endif // USE_MBROLA_LIB
-
-
-
-void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola)
-{//======================================================================
-// Generate a mbrola pho file
- unsigned int name;
- int phix;
- int len;
- int len1;
- PHONEME_TAB *ph;
- PHONEME_TAB *ph_next;
- PHONEME_TAB *ph_prev;
- PHONEME_LIST *p;
- PHONEME_LIST *next;
- PHONEME_LIST *prev;
- int pause = 0;
- int released;
- int name2;
- int control;
- int done;
- int len_percent;
- const char *final_pitch;
- char buf[80];
- char mbr_buf[120];
-
-#ifdef USE_MBROLA_LIB
- int embedded_ix=0;
- int word_count=0;
-
- event_list_ix = 0;
- out_ptr = outbuf;
-#ifdef PLATFORM_WINDOWS
- setNoError_MBR(1); // don't stop on phoneme errors
-#endif
-#else
-// fprintf(f_mbrola,";; v=%.2f\n",(float)(mbrola_control & 0xff)/16.0); // ;; v= has no effect on mbrola
-#endif
-
- for(phix=1; phix < n_phonemes; phix++)
- {
- mbr_buf[0] = 0;
-
- p = &plist[phix];
- next = &plist[phix+1];
- prev = &plist[phix-1];
- ph = p->ph;
- ph_prev = plist[phix-1].ph;
- ph_next = plist[phix+1].ph;
-
-#ifdef USE_MBROLA_LIB
- if(p->synthflags & SFLAG_EMBEDDED)
- {
- MbrolaEmbedded(embedded_ix, p->sourceix);
- }
- if(p->newword & 4)
- MbrolaMarker(espeakEVENT_SENTENCE, (p->sourceix & 0x7ff) + clause_start_char, 0, count_sentences);
-
- if(p->newword & 1)
- MbrolaMarker(espeakEVENT_WORD, (p->sourceix & 0x7ff) + clause_start_char, p->sourceix >> 11, clause_start_word + word_count++);
-#endif
-
- name = GetMbrName(p,ph,ph_prev,ph_next,&name2,&len_percent,&control);
- if(control & 1)
- phix++;
-
- if(name == 0)
- continue; // ignore this phoneme
-
- if((ph->type == phPAUSE) && (name == ph->mnemonic))
- {
- // a pause phoneme, which has not been changed by the translation
- name = '_';
- len = (p->length * speed.speed_factor1)/256;
-// if(len == 0) continue;
- if(len == 0)
- len = 1;
- }
- else
- len = (80 * speed.speed_factor2)/256;
-
-#ifdef USE_MBROLA_LIB
- MbrolaMarker(espeakEVENT_PHONEME, (p->sourceix & 0x7ff) + clause_start_char, 0, ph->mnemonic);
-#endif
-
- sprintf(buf,"%s\t",WordToString(name));
- strcat(mbr_buf,buf);
-
- if(name2 == '_')
- {
- // add a pause after this phoneme
- pause = PauseLength(len_percent,0);
- name2 = 0;
- }
-
- done = 0;
- final_pitch = "";
-
- switch(ph->type)
- {
- case phVOWEL:
- len = ph->std_length;
- if(p->synthflags & SFLAG_LENGTHEN)
- len += phoneme_tab[phonLENGTHEN]->std_length; // phoneme was followed by an extra : symbol
-
- if(ph_next->type == phPAUSE)
- len += 50; // lengthen vowels before a pause
- len = (len * p->length)/256;
-
- if(name2 == 0)
- {
- sprintf(buf,"%d\t%s", len, WritePitch(p->env,p->pitch1,p->pitch2,0,0));
- strcat(mbr_buf,buf);
- }
- else
- {
- len1 = (len * len_percent)/100;
- sprintf(buf,"%d\t%s", len1, WritePitch(p->env,p->pitch1,p->pitch2,len_percent,0));
- strcat(mbr_buf,buf);
-
- sprintf(buf,"%s\t%d\t%s", WordToString(name2), len-len1, WritePitch(p->env,p->pitch1,p->pitch2,-len_percent,0));
- strcat(mbr_buf,buf);
- }
- done = 1;
- break;
-
- case phSTOP:
- released = 0;
- if(next->type==phVOWEL) released = 1;
- if(next->type==phLIQUID && !next->newword) released = 1;
-
- if(released)
- len = DoSample(p->ph,next->ph,2,0,-1);
- else
- len = DoSample(p->ph,phoneme_tab[phonPAUSE],2,0,-1);
- len = (len * 1000)/samplerate; // convert to mS
- len += PauseLength(p->prepause,1);
- break;
-
- case phVSTOP:
- len = (80 * speed.speed_factor2)/256;
- break;
-
- case phFRICATIVE:
- len = 0;
- if(p->synthflags & SFLAG_LENGTHEN)
- len = DoSample(ph,ph_next,2,p->length,-1); // play it twice for [s:] etc.
- len += DoSample(ph,ph_next,2,p->length,-1);
-
- len = (len * 1000)/samplerate; // convert to mS
- break;
-
- case phNASAL:
- if(next->type != phVOWEL)
- {
- len = DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,-1);
- len = (len * 1000)/samplerate;
- if(next->type == phPAUSE)
- len += 50;
- final_pitch = WritePitch(p->env,p->pitch1,p->pitch2,0,1);
- }
- break;
-
- case phLIQUID:
- if(next->type == phPAUSE)
- {
- len += 50;
- final_pitch = WritePitch(p->env,p->pitch1,p->pitch2,0,1);
- }
- break;
- }
-
- if(!done)
- {
- if(name2 != 0)
- {
- len1 = (len * len_percent)/100;
- sprintf(buf,"%d\n%s\t",len1,WordToString(name2));
- strcat(mbr_buf,buf);
- len -= len1;
- }
- sprintf(buf,"%d%s\n",len,final_pitch);
- strcat(mbr_buf,buf);
- }
-
- if(pause)
- {
- sprintf(buf,"_ \t%d\n",PauseLength(pause,0));
- strcat(mbr_buf,buf);
- pause = 0;
- }
-
- if(f_mbrola)
- {
- fwrite(mbr_buf,1,strlen(mbr_buf),f_mbrola); // write .pho to a file
- }
- else
- {
-#ifdef USE_MBROLA_LIB
- if(MbrolaSynth(mbr_buf) != 0)
- return;
-#endif
- }
- }
-
-#ifdef USE_MBROLA_LIB
- MbrolaSynth(NULL);
-#endif
-} // end of MbrolaTranslate
-
-
-#ifdef TEST_MBROLA
-
-static PHONEME_LIST mbrola_phlist;
-static int mbrola_n_ph;
-static int mbrola_phix;
-
-
-int MbrolaFill(int fill_zeros)
-{//===========================
-}
-
-int MbrolaGenerate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
-{//==================================================================
- if(resume == 0)
- {
- mbrola_phlist = phoneme_list;
- mbrola_n_ph = n_ph;
- mbrola_phix = 0;
- }
-
- resume(0); // finished phoneme list
-}
-#endif
diff --git a/navit/support/espeak/synthdata.c b/navit/support/espeak/synthdata.c
deleted file mode 100755
index 4f8234beb..000000000
--- a/navit/support/espeak/synthdata.c
+++ /dev/null
@@ -1,682 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <wctype.h>
-#include <string.h>
-
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-#include "translate.h"
-#include "wave.h"
-
-const char *version_string = "1.41.01 25.Aug.09";
-const int version_phdata = 0x014100;
-
-int option_device_number = -1;
-
-// copy the current phoneme table into here
-int n_phoneme_tab;
-int current_phoneme_table;
-PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];
-unsigned char phoneme_tab_flags[N_PHONEME_TAB]; // bit 0: not inherited
-
-static unsigned int *phoneme_index=NULL;
-char *spects_data=NULL;
-unsigned char *wavefile_data=NULL;
-static unsigned char *phoneme_tab_data = NULL;
-
-int n_phoneme_tables;
-PHONEME_TAB_LIST phoneme_tab_list[N_PHONEME_TABS];
-int phoneme_tab_number = 0;
-
-int wavefile_ix; // a wavefile to play along with the synthesis
-int wavefile_amp;
-int wavefile_ix2;
-int wavefile_amp2;
-
-int seq_len_adjust;
-int vowel_transition[4];
-int vowel_transition0;
-int vowel_transition1;
-
-int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsigned int data2, PHONEME_TAB *other_ph, int which);
-
-
-
-static char *ReadPhFile(void *ptr, const char *fname)
-{//==================================================
- FILE *f_in;
- char *p;
- unsigned int length;
- char buf[sizeof(path_home)+40];
-
- sprintf(buf,"%s%c%s",path_home,PATHSEP,fname);
- length = GetFileLength(buf);
-
- if((f_in = fopen(buf,"rb")) == NULL)
- {
- fprintf(stderr,"Can't read data file: '%s'\n",buf);
- return(NULL);
- }
-
- if(ptr != NULL)
- Free(ptr);
-
- if((p = Alloc(length)) == NULL)
- {
- fclose(f_in);
- return(NULL);
- }
- if(fread(p,1,length,f_in) != length)
- {
- fclose(f_in);
- return(NULL);
- }
-
- fclose(f_in);
- return(p);
-} // end of ReadPhFile
-
-
-int LoadPhData()
-{//=============
- int ix;
- int n_phonemes;
- int version;
- int result = 1;
- unsigned char *p;
-
- if((phoneme_tab_data = (unsigned char *)ReadPhFile((void *)(phoneme_tab_data),"phontab")) == NULL)
- return(-1);
- if((phoneme_index = (unsigned int *)ReadPhFile((void *)(phoneme_index),"phonindex")) == NULL)
- return(-1);
- if((spects_data = ReadPhFile((void *)(spects_data),"phondata")) == NULL)
- return(-1);
- wavefile_data = (unsigned char *)spects_data;
-
- // read the version number from the first 4 bytes of phondata
- version = 0;
- for(ix=0; ix<4; ix++)
- {
- version += (wavefile_data[ix] << (ix*8));
- }
-
- if(version != version_phdata)
- {
- result = version;
- }
-
- // set up phoneme tables
- p = phoneme_tab_data;
- n_phoneme_tables = p[0];
- p+=4;
-
- for(ix=0; ix<n_phoneme_tables; ix++)
- {
- n_phonemes = p[0];
- phoneme_tab_list[ix].n_phonemes = p[0];
- phoneme_tab_list[ix].includes = p[1];
- p += 4;
- memcpy(phoneme_tab_list[ix].name,p,N_PHONEME_TAB_NAME);
- p += N_PHONEME_TAB_NAME;
- phoneme_tab_list[ix].phoneme_tab_ptr = (PHONEME_TAB *)p;
- p += (n_phonemes * sizeof(PHONEME_TAB));
- }
-
- if(phoneme_tab_number >= n_phoneme_tables)
- phoneme_tab_number = 0;
-
- return(result);
-} // end of LoadPhData
-
-
-void FreePhData(void)
-{//==================
- Free(phoneme_tab_data);
- Free(phoneme_index);
- Free(spects_data);
- phoneme_tab_data=NULL;
- phoneme_index=NULL;
- spects_data=NULL;
-}
-
-
-int PhonemeCode(unsigned int mnem)
-{//===============================
- int ix;
-
- for(ix=0; ix<n_phoneme_tab; ix++)
- {
- if(phoneme_tab[ix] == NULL)
- continue;
- if(phoneme_tab[ix]->mnemonic == mnem)
- return(phoneme_tab[ix]->code);
- }
- return(0);
-}
-
-
-int LookupPhonemeString(const char *string)
-{//========================================
- int ix;
- unsigned char c;
- unsigned int mnem;
-
- // Pack up to 4 characters into a word
- mnem = 0;
- for(ix=0; ix<4; ix++)
- {
- if(string[ix]==0) break;
- c = string[ix];
- mnem |= (c << (ix*8));
- }
-
- return(PhonemeCode(mnem));
-}
-
-
-
-static unsigned int LookupSound2(int index, unsigned int other_phcode, int control)
-{//================================================================================
-// control=1 get formant transition data only
-
- unsigned int code;
- unsigned int value, value2;
-
- while((value = phoneme_index[index++]) != 0)
- {
- if((code = (value & 0xff)) == other_phcode)
- {
- while(((value2 = phoneme_index[index]) != 0) && ((value2 & 0xff) < 8))
- {
- switch(value2 & 0xff)
- {
- case 0:
- // next entry is a wavefile to be played along with the synthesis
- if(control==0)
- {
- wavefile_ix = value2 >> 8;
- }
- break;
- case 1:
- if(control==0)
- {
- seq_len_adjust = value2 >> 8;
- }
- break;
- case 2:
- if(control==0)
- {
- seq_len_adjust = value2 >> 8;
- seq_len_adjust = -seq_len_adjust;
- }
- break;
- case 3:
- if(control==0)
- {
- wavefile_amp = value2 >> 8;
- }
- break;
- case 4:
- // formant transition data, 2 words
- vowel_transition[0] = value2 >> 8;
- vowel_transition[1] = phoneme_index[index++ + 1];
- break;
- case 5:
- // formant transition data, 2 words
- vowel_transition[2] = value2 >> 8;
- vowel_transition[3] = phoneme_index[index++ + 1];
- break;
- }
- index++;
- }
- return(value >> 8);
- }
- else
- if((code == 4) || (code == 5))
- {
- // formant transition data, ignore next word of data
- index++;
- }
- }
- return(3); // not found
-} // end of LookupSound2
-
-
-unsigned int LookupSound(PHONEME_TAB *this_ph, PHONEME_TAB *other_ph, int which, int *match_level, int control)
-{//============================================================================================================
- // follows, 1 other_ph preceeds this_ph, 2 other_ph follows this_ph
- // control: 1= get formant transition data only
- int spect_list;
- int spect_list2;
- int s_list;
- unsigned char virtual_ph;
- int result;
- int level=0;
- unsigned int other_code;
- unsigned int other_virtual;
-
- if(control==0)
- {
- wavefile_ix = 0;
- wavefile_amp = 32;
- seq_len_adjust = 0;
- }
- memset(vowel_transition,0,sizeof(vowel_transition));
-
- other_code = other_ph->code;
- if(phoneme_tab[other_code]->type == phPAUSE)
- other_code = phonPAUSE_SHORT; // use this version of Pause for matching
-
- if(which==1)
- {
- spect_list = this_ph->after;
- virtual_ph = this_ph->start_type;
- spect_list2 = phoneme_tab[virtual_ph]->after;
- other_virtual = other_ph->end_type;
- }
- else
- {
- spect_list = this_ph->before;
- virtual_ph = this_ph->end_type;
- spect_list2 = phoneme_tab[virtual_ph]->before;
- other_virtual = other_ph->start_type;
- }
-
- result = 3;
- // look for ph1-ph2 combination
- if((s_list = spect_list) != 0)
- {
- if((result = LookupSound2(s_list,other_code,control)) != 3)
- {
- level = 2;
- }
- else
- if(other_virtual != 0)
- {
- if((result = LookupSound2(spect_list,other_virtual,control)) != 3)
- {
- level = 1;
- }
- }
- }
- // not found, look in a virtual phoneme if one is given for this phoneme
- if((result==3) && (virtual_ph != 0) && ((s_list = spect_list2) != 0))
- {
- if((result = LookupSound2(s_list,other_code,control)) != 3)
- {
- level = 1;
- }
- else
- if(other_virtual != 0)
- {
- if((result = LookupSound2(spect_list2,other_virtual,control)) != 3)
- {
- level = 1;
- }
- }
- }
-
- if(match_level != NULL)
- *match_level = level;
-
- if(result==0)
- return(0); // NULL was given in the phoneme source
-
- // note: values = 1 indicates use the default for this phoneme, even though we found a match
- // which set a secondary reference
- if(result >= 4)
- {
- // values 1-3 can be used for special codes
- // 1 = DFT from the phoneme source file
- return(result);
- }
-
- // no match found for other_ph, return the default
- return(LookupSound2(this_ph->spect,phonPAUSE,control));
-
-} // end of LookupSound
-
-
-
-frameref_t *LookupSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB *next_ph,
- int which, int *match_level, int *n_frames, PHONEME_LIST *plist)
-{//=========================================================================================================
- int ix;
- int nf;
- int nf1;
- int seq_break;
- frameref_t *frames;
- int length1;
- int length_std;
- int length_factor;
- SPECT_SEQ *seq, *seq2;
- SPECT_SEQK *seqk, *seqk2;
- PHONEME_TAB *next2_ph;
- frame_t *frame;
- static frameref_t frames_buf[N_SEQ_FRAMES];
-
- PHONEME_TAB *other_ph;
- if(which == 1)
- other_ph = prev_ph;
- else
- other_ph = next_ph;
-
- if((ix = LookupSound(this_ph,other_ph,which,match_level,0)) < 4)
- return(NULL);
- seq = (SPECT_SEQ *)(&spects_data[ix]);
- seqk = (SPECT_SEQK *)seq;
- nf = seq->n_frames;
-
-
- if(nf >= N_SEQ_FRAMES)
- nf = N_SEQ_FRAMES - 1;
-
- seq_break = 0;
- length1 = 0;
-
- for(ix=0; ix<nf; ix++)
- {
- if(seq->frame[0].frflags & FRFLAG_KLATT)
- frame = &seqk->frame[ix];
- else
- frame = (frame_t *)&seq->frame[ix];
- frames_buf[ix].frame = frame;
- frames_buf[ix].frflags = frame->frflags;
- frames_buf[ix].length = frame->length;
- if(frame->frflags & FRFLAG_VOWEL_CENTRE)
- seq_break = ix;
- }
-
- frames = &frames_buf[0];
- if(seq_break > 0)
- {
- if(which==1)
- {
- nf = seq_break + 1;
- }
- else
- {
- frames = &frames_buf[seq_break]; // body of vowel, skip past initial frames
- nf -= seq_break;
- }
- }
-
- // do we need to modify a frame for blending with a consonant?
- if(this_ph->type == phVOWEL)
- {
- if((which==2) && ((frames[nf-1].frflags & FRFLAG_BREAK) == 0))
- {
- // lookup formant transition for the following phoneme
-
- if((*match_level == 0) || (next_ph->type == phNASAL))
- {
- LookupSound(next_ph,this_ph,1,NULL,1);
- seq_len_adjust += FormantTransition2(frames,&nf,vowel_transition[2],vowel_transition[3],next_ph,which);
- }
- else
- if(next_ph->phflags == phVOWEL2)
- {
- // not really a consonant, rather a coloured vowel
- if(LookupSound(next_ph,this_ph,1,NULL,1) == 0)
- {
- next2_ph = plist[2].ph;
- LookupSound(next2_ph,next_ph,1,NULL,1);
- seq_len_adjust += FormantTransition2(frames,&nf,vowel_transition[2],vowel_transition[3],next2_ph,which);
- }
- }
- }
- else
- {
- if(*match_level == 0)
- seq_len_adjust = FormantTransition2(frames,&nf,vowel_transition0,vowel_transition1,prev_ph,which);
- }
- }
-
- nf1 = nf - 1;
- for(ix=0; ix<nf1; ix++)
- length1 += frames[ix].length;
-
-
- if((wavefile_ix != 0) && ((wavefile_ix & 0x800000)==0))
- {
- // a secondary reference has been returned, which is not a wavefile
- // add these spectra to the main sequence
- seq2 = (SPECT_SEQ *)(&spects_data[wavefile_ix]);
- seqk2 = (SPECT_SEQK *)seq2;
-
- // first frame of the addition just sets the length of the last frame of the main seq
- nf--;
- for(ix=0; ix<seq2->n_frames; ix++)
- {
- if(seq2->frame[0].frflags & FRFLAG_KLATT)
- frame = &seqk2->frame[ix];
- else
- frame = (frame_t *)&seq2->frame[ix];
-
- frames[nf].length = frame->length;
- if(ix > 0)
- {
- frames[nf].frame = frame;
- frames[nf].frflags = frame->frflags;
- }
- nf++;
- }
- wavefile_ix = 0;
- }
-
- if((this_ph->type == phVOWEL) && (length1 > 0))
- {
- if(which==2)
- {
- // adjust the length of the main part to match the standard length specified for the vowel
- // less the front part of the vowel and any added suffix
-
- length_std = this_ph->std_length + seq_len_adjust - 45;
- if(length_std < 10)
- length_std = 10;
- if(plist->synthflags & SFLAG_LENGTHEN)
- length_std += phoneme_tab[phonLENGTHEN]->std_length; // phoneme was followed by an extra : symbol
-
-// can adjust vowel length for stressed syllables here
-
-
- length_factor = (length_std * 256)/ length1;
-
- for(ix=0; ix<nf1; ix++)
- {
- frames[ix].length = (frames[ix].length * length_factor)/256;
- }
- }
- else
- {
- // front of a vowel
- if(*match_level == 0)
- {
- // allow very short vowels to have shorter front parts
- if(this_ph->std_length < 130)
- frames[0].length = (frames[0].length * this_ph->std_length)/130;
- }
-
- if(seq_len_adjust != 0)
- {
- length_std = 0;
- for(ix=0; ix<nf1; ix++)
- {
- length_std += frames[ix].length;
- }
- length_factor = ((length_std + seq_len_adjust) * 256)/length_std;
- for(ix=0; ix<nf1; ix++)
- {
- frames[ix].length = (frames[ix].length * length_factor)/256;
- }
- }
- }
- }
-
- *n_frames = nf;
- return(frames);
-} // end of LookupSpect
-
-
-unsigned char *LookupEnvelope(int ix)
-{//================================
- if(ix==0)
- return(NULL);
- return((unsigned char *)&spects_data[phoneme_index[ix]]);
-}
-
-
-static void SetUpPhonemeTable(int number, int recursing)
-{//=====================================================
- int ix;
- int includes;
- int ph_code;
- PHONEME_TAB *phtab;
-
- if(recursing==0)
- {
- memset(phoneme_tab_flags,0,sizeof(phoneme_tab_flags));
- }
-
- if((includes = phoneme_tab_list[number].includes) > 0)
- {
- // recursively include base phoneme tables
- SetUpPhonemeTable(includes-1,1);
- }
-
- // now add the phonemes from this table
- phtab = phoneme_tab_list[number].phoneme_tab_ptr;
- for(ix=0; ix<phoneme_tab_list[number].n_phonemes; ix++)
- {
- ph_code = phtab[ix].code;
- phoneme_tab[ph_code] = &phtab[ix];
- if(ph_code > n_phoneme_tab)
- n_phoneme_tab = ph_code;
-
- if(recursing == 0)
- phoneme_tab_flags[ph_code] |= 1; // not inherited
- }
-} // end of SetUpPhonemeTable
-
-
-void SelectPhonemeTable(int number)
-{//================================
- n_phoneme_tab = 0;
- SetUpPhonemeTable(number,0); // recursively for included phoneme tables
- n_phoneme_tab++;
- current_phoneme_table = number;
-} // end of SelectPhonemeTable
-
-
-int LookupPhonemeTable(const char *name)
-{//=====================================
- int ix;
-
- for(ix=0; ix<n_phoneme_tables; ix++)
- {
- if(strcmp(name,phoneme_tab_list[ix].name)==0)
- {
- phoneme_tab_number = ix;
- break;
- }
- }
- if(ix == n_phoneme_tables)
- return(-1);
-
- return(ix);
-}
-
-
-int SelectPhonemeTableName(const char *name)
-{//=========================================
-// Look up a phoneme set by name, and select it if it exists
-// Returns the phoneme table number
- int ix;
-
- if((ix = LookupPhonemeTable(name)) == -1)
- return(-1);
-
- SelectPhonemeTable(ix);
- return(ix);
-} // end of DelectPhonemeTableName
-
-
-
-
-void LoadConfig(void)
-{//==================
-// Load configuration file, if one exists
- char buf[sizeof(path_home)+10];
- FILE *f;
- int ix;
- char c1;
- char *p;
- char string[200];
-
- for(ix=0; ix<N_SOUNDICON_SLOTS; ix++)
- {
- soundicon_tab[ix].filename = NULL;
- soundicon_tab[ix].data = NULL;
- }
-
- sprintf(buf,"%s%c%s",path_home,PATHSEP,"config");
- if((f = fopen(buf,"r"))==NULL)
- {
- return;
- }
-
- while(fgets(buf,sizeof(buf),f)!=NULL)
- {
- if(memcmp(buf,"tone",4)==0)
- {
- ReadTonePoints(&buf[5],tone_points);
- }
- else
- if(memcmp(buf,"pa_device",9)==0)
- {
- sscanf(&buf[7],"%d",&option_device_number);
- }
- else
- if(memcmp(buf,"soundicon",9)==0)
- {
- ix = sscanf(&buf[10],"_%c %s",&c1,string);
- if(ix==2)
- {
- soundicon_tab[n_soundicon_tab].name = c1;
- p = Alloc(strlen(string)+1);
- strcpy(p,string);
- soundicon_tab[n_soundicon_tab].filename = p;
- soundicon_tab[n_soundicon_tab++].length = 0;
- }
- }
- }
- fclose(f);
-} // end of LoadConfig
-
diff --git a/navit/support/espeak/synthesize.c b/navit/support/espeak/synthesize.c
deleted file mode 100755
index 3a48b1d72..000000000
--- a/navit/support/espeak/synthesize.c
+++ /dev/null
@@ -1,1658 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <wctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-#include "translate.h"
-
-
-extern FILE *f_log;
-static void SmoothSpect(void);
-
-
-// list of phonemes in a clause
-int n_phoneme_list=0;
-PHONEME_LIST phoneme_list[N_PHONEME_LIST];
-
-int mbrola_delay;
-char mbrola_name[20];
-
-SPEED_FACTORS speed;
-
-static int last_pitch_cmd;
-static int last_amp_cmd;
-static frame_t *last_frame;
-static int last_wcmdq;
-static int pitch_length;
-static int amp_length;
-static int modn_flags;
-
-static int syllable_start;
-static int syllable_end;
-static int syllable_centre;
-
-static voice_t *new_voice=NULL;
-
-int n_soundicon_tab=N_SOUNDICON_SLOTS;
-SOUND_ICON soundicon_tab[N_SOUNDICON_TAB];
-
-#define RMS_GLOTTAL1 35 // vowel before glottal stop
-#define RMS_START 28 // 28
-
-#define VOWEL_FRONT_LENGTH 50
-
-#define long(x) ((long)(x))
-
-// a dummy phoneme_list entry which looks like a pause
-static PHONEME_LIST next_pause;
-
-
-const char *WordToString(unsigned int word)
-{//========================================
-// Convert a phoneme mnemonic word into a string
- int ix;
- static char buf[5];
-
- for(ix=0; ix<3; ix++)
- buf[ix] = word >> (ix*8);
- buf[4] = 0;
- return(buf);
-}
-
-
-
-void SynthesizeInit()
-{//==================
- last_pitch_cmd = 0;
- last_amp_cmd = 0;
- last_frame = NULL;
- syllable_centre = -1;
-
- // initialise next_pause, a dummy phoneme_list entry
-// next_pause.ph = phoneme_tab[phonPAUSE]; // this must be done after voice selection
- next_pause.type = phPAUSE;
- next_pause.newword = 0;
-}
-
-
-
-static void EndAmplitude(void)
-{//===========================
- if(amp_length > 0)
- {
- if(wcmdq[last_amp_cmd][1] == 0)
- wcmdq[last_amp_cmd][1] = amp_length;
- amp_length = 0;
- }
-}
-
-
-
-static void EndPitch(int voice_break)
-{//==================================
- // posssible end of pitch envelope, fill in the length
- if((pitch_length > 0) && (last_pitch_cmd >= 0))
- {
- if(wcmdq[last_pitch_cmd][1] == 0)
- wcmdq[last_pitch_cmd][1] = pitch_length;
- pitch_length = 0;
- }
-
- if(voice_break)
- {
- last_wcmdq = -1;
- last_frame = NULL;
- syllable_end = wcmdq_tail;
- SmoothSpect();
- syllable_centre = -1;
- memset(vowel_transition,0,sizeof(vowel_transition));
- }
-} // end of Synthesize::EndPitch
-
-
-
-static void DoAmplitude(int amp, unsigned char *amp_env)
-{//=====================================================
- long *q;
-
- last_amp_cmd = wcmdq_tail;
- amp_length = 0; // total length of vowel with this amplitude envelope
-
- q = wcmdq[wcmdq_tail];
- q[0] = WCMD_AMPLITUDE;
- q[1] = 0; // fill in later from amp_length
- q[2] = (long)amp_env;
- q[3] = amp;
- WcmdqInc();
-} // end of Synthesize::DoAmplitude
-
-
-
-static void DoPitch(unsigned char *env, int pitch1, int pitch2)
-{//============================================================
- long *q;
-
- EndPitch(0);
-
- if(pitch1 == 1024)
- {
- // pitch was not set
- pitch1 = 24;
- pitch2 = 33;
- env = envelope_data[PITCHfall];
- }
- last_pitch_cmd = wcmdq_tail;
- pitch_length = 0; // total length of spect with this pitch envelope
-
- if(pitch2 < 0)
- pitch2 = 0;
-
- q = wcmdq[wcmdq_tail];
- q[0] = WCMD_PITCH;
- q[1] = 0; // length, fill in later from pitch_length
- q[2] = (long)env;
- q[3] = (pitch1 << 16) + pitch2;
- WcmdqInc();
-} // end of Synthesize::DoPitch
-
-
-
-int PauseLength(int pause, int control)
-{//====================================
- int len;
-
- if(control == 0)
- len = (pause * speed.speed_factor1)/256;
- else
- len = (pause * speed.speed_factor2)/256;
-
- if(len < 5) len = 5; // mS, limit the amount to which pauses can be shortened
- return(len);
-}
-
-
-static void DoPause(int length, int control)
-{//=========================================
-// control = 1, less shortening at fast speeds
- int len;
-
- len = PauseLength(length, control);
-
- len = (len * samplerate) / 1000; // convert from mS to number of samples
-
- EndPitch(1);
- wcmdq[wcmdq_tail][0] = WCMD_PAUSE;
- wcmdq[wcmdq_tail][1] = len;
- WcmdqInc();
- last_frame = NULL;
-} // end of Synthesize::DoPause
-
-
-extern int seq_len_adjust; // temporary fix to advance the start point for playing the wav sample
-
-
-static int DoSample2(int index, int which, int length_mod, int amp)
-{//================================================================
- int length;
- int length1;
- int format;
- int min_length;
- int start=0;
- long *q;
- unsigned char *p;
-
- index = index & 0x7fffff;
- p = &wavefile_data[index];
- format = p[2];
- length1 = (p[1] * 256);
- length1 += p[0]; // length in bytes
-
- if(seq_len_adjust > 0)
- {
- start = (seq_len_adjust * samplerate)/1000;
- if(format == 0)
- start *= 2;
- length1 -= start;
- index += start;
- }
-
-
- if(length_mod > 0)
- length = (length1 * length_mod) / 256;
- else
- length = length1;
-
-
- length = (length * speed.speed_factor2)/256;
- min_length = speed.min_sample_len;
- if(format==0)
- min_length *= 2;
-
- if(length < min_length)
- length = min_length;
-
- if(length > length1)
- length = length1; // don't exceed wavefile length
-
- if(format==0)
- length /= 2; // 2 byte samples
-
-
- index += 4;
-
- if(amp >= 0)
- {
- last_wcmdq = wcmdq_tail;
- q = wcmdq[wcmdq_tail];
- if(which & 0x100)
- q[0] = WCMD_WAVE2; // mix this with synthesised wave
- else
- q[0] = WCMD_WAVE;
- q[1] = length; // length in samples
- q[2] = long(&wavefile_data[index]);
- q[3] = format + (amp << 8);
- WcmdqInc();
- }
- return(length);
-} // end of Synthesize::DoSample2
-
-
-int DoSample(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int length_mod, int amp)
-{//====================== ==========================================================
- int index;
- int match_level;
- int amp2;
- int result;
-
- EndPitch(1);
- index = LookupSound(ph1,ph2,which & 0xff,&match_level,0);
- if((index & 0x800000) == 0)
- return(0); // not wavefile data
-
- amp2 = wavefile_amp;
- if(amp != 0)
- amp2 = (amp * wavefile_amp)/20;
-
- if(amp == -1)
- amp2 = amp;
-
- result = DoSample2(index,which,length_mod,amp2);
- last_frame = NULL;
- return(result);
-} // end of Synthesize::DoSample
-
-
-
-
-static frame_t *AllocFrame()
-{//=========================
- // Allocate a temporary spectrum frame for the wavegen queue. Use a pool which is big
- // enough to use a round-robin without checks.
- // Only needed for modifying spectra for blending to consonants
-
-#define N_FRAME_POOL N_WCMDQ
- static int ix=0;
- static frame_t frame_pool[N_FRAME_POOL];
-
- ix++;
- if(ix >= N_FRAME_POOL)
- ix = 0;
- return(&frame_pool[ix]);
-}
-
-
-static void set_frame_rms(frame_t *fr, int new_rms)
-{//=================================================
-// Each frame includes its RMS amplitude value, so to set a new
-// RMS just adjust the formant amplitudes by the appropriate ratio
-
- int x;
- int h;
- int ix;
-
- static const short sqrt_tab[200] = {
- 0, 64, 90,110,128,143,156,169,181,192,202,212,221,230,239,247,
- 256,263,271,278,286,293,300,306,313,320,326,332,338,344,350,356,
- 362,367,373,378,384,389,394,399,404,409,414,419,424,429,434,438,
- 443,448,452,457,461,465,470,474,478,483,487,491,495,499,503,507,
- 512,515,519,523,527,531,535,539,543,546,550,554,557,561,565,568,
- 572,576,579,583,586,590,593,596,600,603,607,610,613,617,620,623,
- 627,630,633,636,640,643,646,649,652,655,658,662,665,668,671,674,
- 677,680,683,686,689,692,695,698,701,704,706,709,712,715,718,721,
- 724,726,729,732,735,738,740,743,746,749,751,754,757,759,762,765,
- 768,770,773,775,778,781,783,786,789,791,794,796,799,801,804,807,
- 809,812,814,817,819,822,824,827,829,832,834,836,839,841,844,846,
- 849,851,853,856,858,861,863,865,868,870,872,875,877,879,882,884,
- 886,889,891,893,896,898,900,902};
-
- if(voice->klattv[0])
- {
- if(new_rms == -1)
- {
- fr->klattp[KLATT_AV] = 50;
- }
- return;
- }
-
- if(fr->rms == 0) return; // check for divide by zero
- x = (new_rms * 64)/fr->rms;
- if(x >= 200) x = 199;
-
- x = sqrt_tab[x]; // sqrt(new_rms/fr->rms)*0x200;
-
- for(ix=0; ix < 8; ix++)
- {
- h = fr->fheight[ix] * x;
- fr->fheight[ix] = h/0x200;
- }
-} /* end of set_frame_rms */
-
-
-
-static void formants_reduce_hf(frame_t *fr, int level)
-{//====================================================
-// change height of peaks 2 to 8, percentage
- int ix;
- int x;
-
- if(voice->klattv[0])
- return;
-
- for(ix=2; ix < 8; ix++)
- {
- x = fr->fheight[ix] * level;
- fr->fheight[ix] = x/100;
- }
-}
-
-
-static frame_t *CopyFrame(frame_t *frame1, int copy)
-{//=================================================
-// create a copy of the specified frame in temporary buffer
- frame_t *frame2;
-
- if((copy==0) && (frame1->frflags & FRFLAG_COPIED))
- {
- // this frame has already been copied in temporary rw memory
- return(frame1);
- }
-
- frame2 = AllocFrame();
- if(frame2 != NULL)
- {
- memcpy(frame2,frame1,sizeof(frame_t));
- frame2->length = 0;
- frame2->frflags |= FRFLAG_COPIED;
- }
- return(frame2);
-}
-
-
-static frame_t *DuplicateLastFrame(frameref_t *seq, int n_frames, int length)
-{//==========================================================================
- frame_t *fr;
-
- seq[n_frames-1].length = length;
- fr = CopyFrame(seq[n_frames-1].frame,1);
- seq[n_frames].frame = fr;
- seq[n_frames].length = 0;
- return fr;
-}
-
-
-static void AdjustFormants(frame_t *fr, int target, int min, int max, int f1_adj, int f3_adj, int hf_reduce, int flags)
-{//====================================================================================================================
- int x;
-
-//hf_reduce = 70; // ?? using fixed amount rather than the parameter??
-
- target = (target * voice->formant_factor)/256;
-
- x = (target - fr->ffreq[2]) / 2;
- if(x > max) x = max;
- if(x < min) x = min;
- fr->ffreq[2] += x;
- fr->ffreq[3] += f3_adj;
-
- if(flags & 0x20)
- {
- f3_adj = -f3_adj; //. reverse direction for f4,f5 change
- }
- fr->ffreq[4] += f3_adj;
- fr->ffreq[5] += f3_adj;
-
- if(f1_adj==1)
- {
- x = (235 - fr->ffreq[1]);
- if(x < -100) x = -100;
- if(x > -60) x = -60;
- fr->ffreq[1] += x;
- }
- if(f1_adj==2)
- {
- x = (235 - fr->ffreq[1]);
- if(x < -300) x = -300;
- if(x > -150) x = -150;
- fr->ffreq[1] += x;
- fr->ffreq[0] += x;
- }
- if(f1_adj==3)
- {
- x = (100 - fr->ffreq[1]);
- if(x < -400) x = -400;
- if(x > -300) x = -400;
- fr->ffreq[1] += x;
- fr->ffreq[0] += x;
- }
- formants_reduce_hf(fr,hf_reduce);
-}
-
-
-static int VowelCloseness(frame_t *fr)
-{//===================================
-// return a value 0-3 depending on the vowel's f1
- int f1;
-
- if((f1 = fr->ffreq[1]) < 300)
- return(3);
- if(f1 < 400)
- return(2);
- if(f1 < 500)
- return(1);
- return(0);
-}
-
-
-int FormantTransition2(frameref_t *seq, int *n_frames, unsigned int data1, unsigned int data2, PHONEME_TAB *other_ph, int which)
-{//==============================================================================================================================
- int ix;
- int formant;
- int next_rms;
-
- int len;
- int rms;
- int f1;
- int f2;
- int f2_min;
- int f2_max;
- int f3_adj;
- int f3_amp;
- int flags;
- int vcolour;
-
-#define N_VCOLOUR 2
-// percentage change for each formant in 256ths
-static short vcolouring[N_VCOLOUR][5] = {
- {243,272,256,256,256}, // palatal consonant follows
- {256,256,240,240,240}, // retroflex
-};
-
- frame_t *fr = NULL;
-
- if(*n_frames < 2)
- return(0);
-
- len = (data1 & 0x3f) * 2;
- rms = (data1 >> 6) & 0x3f;
- flags = (data1 >> 12);
-
- f2 = (data2 & 0x3f) * 50;
- f2_min = (((data2 >> 6) & 0x1f) - 15) * 50;
- f2_max = (((data2 >> 11) & 0x1f) - 15) * 50;
- f3_adj = (((data2 >> 16) & 0x1f) - 15) * 50;
- f3_amp = ((data2 >> 21) & 0x1f) * 8;
- f1 = ((data2 >> 26) & 0x7);
- vcolour = (data2 >> 29);
-
-// fprintf(stderr,"FMT%d %3s %3d-%3d f1=%d f2=%4d %4d %4d f3=%4d %3d\n",
-// which,WordToString(other_ph->mnemonic),len,rms,f1,f2,f2_min,f2_max,f3_adj,f3_amp);
-
- if(other_ph->mnemonic == '?')
- flags |= 8;
-
- if(which == 1)
- {
- /* entry to vowel */
- fr = CopyFrame(seq[0].frame,0);
- seq[0].frame = fr;
- seq[0].length = VOWEL_FRONT_LENGTH;
- if(len > 0)
- seq[0].length = len;
- seq[0].frflags |= FRFLAG_LEN_MOD; // reduce length modification
- fr->frflags |= FRFLAG_LEN_MOD;
-
- next_rms = seq[1].frame->rms;
-
-if(voice->klattv[0])
-{
- fr->klattp[KLATT_AV] = 53; // reduce the amplituide of the start of a vowel
-}
- if(f2 != 0)
- {
- if(rms & 0x20)
- {
- set_frame_rms(fr,(next_rms * (rms & 0x1f))/30);
- }
- AdjustFormants(fr, f2, f2_min, f2_max, f1, f3_adj, f3_amp, flags);
-
- if((rms & 0x20) == 0)
- {
- set_frame_rms(fr,rms*2);
- }
- }
- else
- {
- if(flags & 8)
- set_frame_rms(fr,(next_rms*24)/32);
- else
- set_frame_rms(fr,RMS_START);
- }
-
- if(flags & 8)
- {
-// set_frame_rms(fr,next_rms - 5);
- modn_flags = 0x800 + (VowelCloseness(fr) << 8);
- }
- }
- else
- {
- // exit from vowel
- rms = rms*2;
- if((f2 != 0) || (flags != 0))
- {
-
- if(flags & 8)
- {
- fr = CopyFrame(seq[*n_frames-1].frame,0);
- seq[*n_frames-1].frame = fr;
- rms = RMS_GLOTTAL1;
-
- // degree of glottal-stop effect depends on closeness of vowel (indicated by f1 freq)
- modn_flags = 0x400 + (VowelCloseness(fr) << 8);
- }
- else
- {
- fr = DuplicateLastFrame(seq,(*n_frames)++,len);
- if(len > 36)
- seq_len_adjust += (len - 36);
-
- if(f2 != 0)
- {
- AdjustFormants(fr, f2, f2_min, f2_max, f1, f3_adj, f3_amp, flags);
- }
- }
-
- set_frame_rms(fr,rms);
-
- if((vcolour > 0) && (vcolour <= N_VCOLOUR))
- {
- for(ix=0; ix<*n_frames; ix++)
- {
- fr = CopyFrame(seq[ix].frame,0);
- seq[ix].frame = fr;
-
- for(formant=1; formant<=5; formant++)
- {
- int x;
- x = fr->ffreq[formant] * vcolouring[vcolour-1][formant-1];
- fr->ffreq[formant] = x / 256;
- }
- }
- }
- }
- }
-
- if(fr != NULL)
- {
- if(flags & 4)
- fr->frflags |= FRFLAG_FORMANT_RATE;
- if(flags & 2)
- fr->frflags |= FRFLAG_BREAK; // don't merge with next frame
- }
-
- if(flags & 0x40)
- DoPause(12,0); // add a short pause after the consonant
-
- if(flags & 16)
- return(len);
- return(0);
-} // end of FormantTransition2
-
-
-
-static void SmoothSpect(void)
-{//==========================
- // Limit the rate of frequence change of formants, to reduce chirping
-
- long *q;
- frame_t *frame;
- frame_t *frame2;
- frame_t *frame1;
- frame_t *frame_centre;
- int ix;
- int len;
- int pk;
- int modified;
- int allowed;
- int diff;
-
- if(syllable_start == syllable_end)
- return;
-
- if((syllable_centre < 0) || (syllable_centre == syllable_start))
- {
- syllable_start = syllable_end;
- return;
- }
-
- q = wcmdq[syllable_centre];
- frame_centre = (frame_t *)q[2];
-
- // backwards
- ix = syllable_centre -1;
- frame = frame2 = frame_centre;
- for(;;)
- {
- if(ix < 0) ix = N_WCMDQ-1;
- q = wcmdq[ix];
-
- if(q[0] == WCMD_PAUSE || q[0] == WCMD_WAVE)
- break;
-
- if(q[0] <= WCMD_SPECT2)
- {
- len = q[1] & 0xffff;
-
- frame1 = (frame_t *)q[3];
- if(frame1 == frame)
- {
- q[3] = (long)frame2;
- frame1 = frame2;
- }
- else
- break; // doesn't follow on from previous frame
-
- frame = frame2 = (frame_t *)q[2];
- modified = 0;
-
- if(frame->frflags & FRFLAG_BREAK)
- break;
-
- if(frame->frflags & FRFLAG_FORMANT_RATE)
- len = (len * 12)/10; // allow slightly greater rate of change for this frame (was 12/10)
-
- for(pk=0; pk<6; pk++)
- {
- int f1, f2;
-
- if((frame->frflags & FRFLAG_BREAK_LF) && (pk < 3))
- continue;
-
- f1 = frame1->ffreq[pk];
- f2 = frame->ffreq[pk];
-
- // backwards
- if((diff = f2 - f1) > 0)
- {
- allowed = f1*2 + f2;
- }
- else
- {
- allowed = f1 + f2*2;
- }
-
- // the allowed change is specified as percentage (%*10) of the frequency
- // take "frequency" as 1/3 from the lower freq
- allowed = (allowed * formant_rate[pk])/3000;
- allowed = (allowed * len)/256;
-
- if(diff > allowed)
- {
- if(modified == 0)
- {
- frame2 = CopyFrame(frame,0);
- modified = 1;
- }
- frame2->ffreq[pk] = frame1->ffreq[pk] + allowed;
- q[2] = (long)frame2;
- }
- else
- if(diff < -allowed)
- {
- if(modified == 0)
- {
- frame2 = CopyFrame(frame,0);
- modified = 1;
- }
- frame2->ffreq[pk] = frame1->ffreq[pk] - allowed;
- q[2] = (long)frame2;
- }
- }
- }
-
- if(ix == syllable_start)
- break;
- ix--;
- }
-
- // forwards
- ix = syllable_centre;
-
- frame = NULL;
- for(;;)
- {
- q = wcmdq[ix];
-
- if(q[0] == WCMD_PAUSE || q[0] == WCMD_WAVE)
- break;
-
- if(q[0] <= WCMD_SPECT2)
- {
-
- len = q[1] & 0xffff;
-
- frame1 = (frame_t *)q[2];
- if(frame != NULL)
- {
- if(frame1 == frame)
- {
- q[2] = (long)frame2;
- frame1 = frame2;
- }
- else
- break; // doesn't follow on from previous frame
- }
-
- frame = frame2 = (frame_t *)q[3];
- modified = 0;
-
- if(frame1->frflags & FRFLAG_BREAK)
- break;
-
- if(frame1->frflags & FRFLAG_FORMANT_RATE)
- len = (len *6)/5; // allow slightly greater rate of change for this frame
-
- for(pk=0; pk<6; pk++)
- {
- int f1, f2;
- f1 = frame1->ffreq[pk];
- f2 = frame->ffreq[pk];
-
- // forwards
- if((diff = f2 - f1) > 0)
- {
- allowed = f1*2 + f2;
- }
- else
- {
- allowed = f1 + f2*2;
- }
- allowed = (allowed * formant_rate[pk])/3000;
- allowed = (allowed * len)/256;
-
- if(diff > allowed)
- {
- if(modified == 0)
- {
- frame2 = CopyFrame(frame,0);
- modified = 1;
- }
- frame2->ffreq[pk] = frame1->ffreq[pk] + allowed;
- q[3] = (long)frame2;
- }
- else
- if(diff < -allowed)
- {
- if(modified == 0)
- {
- frame2 = CopyFrame(frame,0);
- modified = 1;
- }
- frame2->ffreq[pk] = frame1->ffreq[pk] - allowed;
- q[3] = (long)frame2;
- }
- }
- }
-
- ix++;
- if(ix >= N_WCMDQ) ix = 0;
- if(ix == syllable_end)
- break;
- }
-
- syllable_start = syllable_end;
-} // end of SmoothSpect
-
-
-static void StartSyllable(void)
-{//============================
- // start of syllable, if not already started
- if(syllable_end == syllable_start)
- syllable_end = wcmdq_tail;
-}
-
-
-int DoSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB *next_ph,
- int which, PHONEME_LIST *plist, int modulation)
-{//===================================================================================
- // which 1 start of phoneme, 2 body and end
- // length_mod: 256 = 100%
- // modulation: -1 = don't write to wcmdq
-
- int n_frames;
- frameref_t *frames;
- int frameix;
- frame_t *frame1;
- frame_t *frame2;
- frame_t *fr;
- int ix;
- long *q;
- int len;
- int match_level;
- int frame_length;
- int frame1_length;
- int frame2_length;
- int length_factor;
- int length_mod;
- int total_len = 0;
- static int wave_flag = 0;
- int wcmd_spect = WCMD_SPECT;
-
- length_mod = plist->length;
- if(length_mod==0) length_mod=256;
-
-if(which==1)
-{
- // limit the shortening of sonorants before shortened (eg. unstressed vowels)
- if((this_ph->type==phLIQUID) || (prev_ph->type==phLIQUID) || (prev_ph->type==phNASAL))
- {
- if(length_mod < (len = translator->langopts.param[LOPT_SONORANT_MIN]))
- {
- length_mod = len;
- }
- }
-}
-
- modn_flags = 0;
- frames = LookupSpect(this_ph,prev_ph,next_ph,which,&match_level,&n_frames, plist);
- if(frames == NULL)
- return(0); // not found
-
- frame1 = frames[0].frame;
- frame1_length = frames[0].length;
- if(voice->klattv[0])
- wcmd_spect = WCMD_KLATT;
-
- if(wavefile_ix == 0)
- {
- if(wave_flag)
- {
- // cancel any wavefile that was playing previously
- wcmd_spect = WCMD_SPECT2;
- if(voice->klattv[0])
- wcmd_spect = WCMD_KLATT2;
- wave_flag = 0;
- }
- else
- {
- wcmd_spect = WCMD_SPECT;
- if(voice->klattv[0])
- wcmd_spect = WCMD_KLATT;
- }
- }
-
- if(last_frame != NULL)
- {
- if(((last_frame->length < 2) || (last_frame->frflags & FRFLAG_VOWEL_CENTRE))
- && !(last_frame->frflags & FRFLAG_BREAK))
- {
- // last frame of previous sequence was zero-length, replace with first of this sequence
- wcmdq[last_wcmdq][3] = (long)frame1;
-
- if(last_frame->frflags & FRFLAG_BREAK_LF)
- {
- // but flag indicates keep HF peaks in last segment
- fr = CopyFrame(frame1,1);
- for(ix=3; ix < 8; ix++)
- {
- if(ix < 7)
- fr->ffreq[ix] = last_frame->ffreq[ix];
- fr->fheight[ix] = last_frame->fheight[ix];
- }
- wcmdq[last_wcmdq][3] = (long)fr;
- }
- }
- }
-
- if((this_ph->type == phVOWEL) && (which == 2))
- {
- SmoothSpect(); // process previous syllable
-
- // remember the point in the output queue of the centre of the vowel
- syllable_centre = wcmdq_tail;
- }
-
- frame_length = frame1_length;
- for(frameix=1; frameix<n_frames; frameix++)
- {
- frame2 = frames[frameix].frame;
- frame2_length = frames[frameix].length;
-
- if((wavefile_ix != 0) && ((frame1->frflags & FRFLAG_DEFER_WAV)==0))
- {
- // there is a wave file to play along with this synthesis
- seq_len_adjust = 0;
- DoSample2(wavefile_ix,which+0x100,0,wavefile_amp);
- wave_flag = 1;
- wavefile_ix = 0;
- }
-
- length_factor = length_mod;
- if(frame1->frflags & FRFLAG_LEN_MOD) // reduce effect of length mod
- {
- length_factor = (length_mod*(256-speed.speed_factor3) + 256*speed.speed_factor3)/256;
- }
- len = (frame_length * samplerate)/1000;
- len = (len * length_factor)/256;
-
- if(modulation >= 0)
- {
- if(frame1->frflags & FRFLAG_MODULATE)
- {
- modulation = 6;
- }
- if((frameix == n_frames-1) && (modn_flags & 0xf00))
- modulation |= modn_flags; // before or after a glottal stop
- }
-
- pitch_length += len;
- amp_length += len;
-
- if(frame_length < 2)
- {
- last_frame = NULL;
- frame_length = frame2_length;
- frame1 = frame2;
- }
- else
- {
- last_wcmdq = wcmdq_tail;
-
- if(modulation >= 0)
- {
- q = wcmdq[wcmdq_tail];
- q[0] = wcmd_spect;
- q[1] = len + (modulation << 16);
- q[2] = long(frame1);
- q[3] = long(frame2);
-
- WcmdqInc();
- }
- last_frame = frame1 = frame2;
- frame_length = frame2_length;
- total_len += len;
- }
- }
- return(total_len);
-} // end of Synthesize::DoSpect
-
-
-static void DoMarker(int type, int char_posn, int length, int value)
-{//=================================================================
-// This could be used to return an index to the word currently being spoken
-// Type 1=word, 2=sentence, 3=named marker, 4=play audio, 5=end
- wcmdq[wcmdq_tail][0] = WCMD_MARKER;
- wcmdq[wcmdq_tail][1] = type;
- wcmdq[wcmdq_tail][2] = (char_posn & 0xffffff) | (length << 24);
- wcmdq[wcmdq_tail][3] = value;
- WcmdqInc();
-
-} // end of Synthesize::DoMarker
-
-
-void DoVoiceChange(voice_t *v)
-{//===========================
-// allocate memory for a copy of the voice data, and free it in wavegenfill()
- voice_t *v2;
-
- v2 = (voice_t *)malloc(sizeof(voice_t));
- memcpy(v2,v,sizeof(voice_t));
- wcmdq[wcmdq_tail][0] = WCMD_VOICE;
- wcmdq[wcmdq_tail][1] = (long)(v2);
- WcmdqInc();
-}
-
-
-static void DoEmbedded(int *embix, int sourceix)
-{//=============================================
- // There were embedded commands in the text at this point
- unsigned int word; // bit 7=last command for this word, bits 5,6 sign, bits 0-4 command
- unsigned int value;
- int command;
-
- do {
- word = embedded_list[(*embix)++];
- value = word >> 8;
- command = word & 0x7f;
-
- switch(command & 0x1f)
- {
- case EMBED_S: // speed
- SetEmbedded((command & 0x60) + EMBED_S2,value); // adjusts embedded_value[EMBED_S2]
- SetSpeed(2);
- break;
-
- case EMBED_I: // play dynamically loaded wav data (sound icon)
- if((int)value < n_soundicon_tab)
- {
- if(soundicon_tab[value].length != 0)
- {
- DoPause(10,0); // ensure a break in the speech
- wcmdq[wcmdq_tail][0] = WCMD_WAVE;
- wcmdq[wcmdq_tail][1] = soundicon_tab[value].length;
- wcmdq[wcmdq_tail][2] = (long)soundicon_tab[value].data + 44; // skip WAV header
- wcmdq[wcmdq_tail][3] = 0x1500; // 16 bit data, amp=21
- WcmdqInc();
- }
- }
- break;
-
- case EMBED_M: // named marker
- DoMarker(espeakEVENT_MARK, (sourceix & 0x7ff) + clause_start_char, 0, value);
- break;
-
- case EMBED_U: // play sound
- DoMarker(espeakEVENT_PLAY, count_characters+1, 0, value); // always occurs at end of clause
- break;
-
- default:
- DoPause(10,0); // ensure a break in the speech
- wcmdq[wcmdq_tail][0] = WCMD_EMBEDDED;
- wcmdq[wcmdq_tail][1] = command;
- wcmdq[wcmdq_tail][2] = value;
- WcmdqInc();
- break;
- }
- } while ((word & 0x80) == 0);
-}
-
-
-
-int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume)
-{//============================================================
- static int ix;
- static int embedded_ix;
- static int word_count;
- PHONEME_LIST *prev;
- PHONEME_LIST *next;
- PHONEME_LIST *next2;
- PHONEME_LIST *p;
- int released;
- int stress;
- int modulation;
- int pre_voiced;
- int free_min;
- unsigned char *pitch_env=NULL;
- unsigned char *amp_env;
- PHONEME_TAB *ph;
- PHONEME_TAB *prev_ph;
- static int sourceix=0;
-
-#ifdef TEST_MBROLA
- if(mbrola_name[0] != 0)
- return(MbrolaGenerate(phoneme_list,n_ph,resume));
-#endif
-
- if(option_quiet)
- return(0);
-
- if(resume == 0)
- {
- ix = 1;
- embedded_ix=0;
- word_count = 0;
- pitch_length = 0;
- amp_length = 0;
- last_frame = NULL;
- last_wcmdq = -1;
- syllable_start = wcmdq_tail;
- syllable_end = wcmdq_tail;
- syllable_centre = -1;
- last_pitch_cmd = -1;
- memset(vowel_transition,0,sizeof(vowel_transition));
- }
-
- while(ix < (*n_ph))
- {
- p = &phoneme_list[ix];
-
- if(p->type == phPAUSE)
- free_min = 5;
- else
- if(p->type != phVOWEL)
- free_min = 10; // we need less Q space for non-vowels, and we need to generate phonemes after a vowel so that the pitch_length is filled in
- else
- free_min = MIN_WCMDQ; // 22
-
- if(WcmdqFree() <= free_min)
- return(1); // wait
-
- prev = &phoneme_list[ix-1];
- next = &phoneme_list[ix+1];
- next2 = &phoneme_list[ix+2];
-
- if(p->synthflags & SFLAG_EMBEDDED)
- {
- DoEmbedded(&embedded_ix, p->sourceix);
- }
-
- if(p->newword)
- {
- if(translator->langopts.param[LOPT_WORD_MERGE] == 0)
- last_frame = NULL;
-
- sourceix = (p->sourceix & 0x7ff) + clause_start_char;
-
- if(p->newword & 4)
- DoMarker(espeakEVENT_SENTENCE, sourceix, 0, count_sentences); // start of sentence
-
-// if(p->newword & 2)
-// DoMarker(espeakEVENT_END, count_characters, 0, count_sentences); // end of clause
-
- if(p->newword & 1)
- DoMarker(espeakEVENT_WORD, sourceix, p->sourceix >> 11, clause_start_word + word_count++);
- }
-
- EndAmplitude();
-
- if(p->prepause > 0)
- DoPause(p->prepause,1);
-
- if(option_phoneme_events && (p->type != phVOWEL))
- {
- // Note, for vowels, do the phoneme event after the vowel-start
- DoMarker(espeakEVENT_PHONEME, sourceix, 0, p->ph->mnemonic);
- }
-
- switch(p->type)
- {
- case phPAUSE:
- DoPause(p->length,0);
- break;
-
- case phSTOP:
- released = 0;
- if(next->type==phVOWEL) released = 1;
- if(next->type==phLIQUID && !next->newword) released = 1;
-
- if(released)
- DoSample(p->ph,next->ph,2,0,0);
- else
- DoSample(p->ph,phoneme_tab[phonPAUSE],2,0,0);
- break;
-
- case phFRICATIVE:
- if(p->synthflags & SFLAG_LENGTHEN)
- DoSample(p->ph,next->ph,2,p->length,0); // play it twice for [s:] etc.
- DoSample(p->ph,next->ph,2,p->length,0);
- break;
-
- case phVSTOP:
- pre_voiced = 0;
- if(next->type==phVOWEL)
- {
- DoAmplitude(p->amp,NULL);
- DoPitch(envelope_data[p->env],p->pitch1,p->pitch2);
- pre_voiced = 1;
- }
- else
- if((next->type==phLIQUID) && !next->newword)
- {
- DoAmplitude(next->amp,NULL);
- DoPitch(envelope_data[next->env],next->pitch1,next->pitch2);
- pre_voiced = 1;
- }
- else
- {
- if(last_pitch_cmd < 0)
- {
- DoAmplitude(next->amp,NULL);
- DoPitch(envelope_data[p->env],p->pitch1,p->pitch2);
- }
- }
-
- if((prev->type==phVOWEL) || (prev->ph->phflags & phVOWEL2))
- {
- // a period of voicing before the release
- DoSpect(p->ph,phoneme_tab[phonSCHWA],next->ph,1,p,0);
- if(p->synthflags & SFLAG_LENGTHEN)
- {
- DoPause(20,0);
- DoSpect(p->ph,phoneme_tab[phonSCHWA],next->ph,1,p,0);
- }
- }
- else
- {
- if(p->synthflags & SFLAG_LENGTHEN)
- {
- DoPause(50,0);
- }
- }
-
- if(pre_voiced)
- {
- // followed by a vowel, or liquid + vowel
- StartSyllable();
- DoSpect(p->ph,prev->ph,next->ph,2,p,0);
- }
- else
- {
-// if((prev->type != phVOWEL) && ((prev->ph->phflags & phVOICED)==0) && ((next->ph->phflags & phVOICED)==0))
-// DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE_SHORT],2,p,0);
-// else
- DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
-// DoSpect(p->ph,prev->ph,next->ph,2,p,0);
- }
- break;
-
- case phVFRICATIVE:
- if(next->type==phVOWEL)
- {
- DoAmplitude(p->amp,NULL);
- DoPitch(envelope_data[p->env],p->pitch1,p->pitch2);
- }
- else
- if(next->type==phLIQUID)
- {
- DoAmplitude(next->amp,NULL);
- DoPitch(envelope_data[next->env],next->pitch1,next->pitch2);
- }
- else
- {
- if(last_pitch_cmd < 0)
- {
- DoAmplitude(p->amp,NULL);
- DoPitch(envelope_data[p->env],p->pitch1,p->pitch2);
- }
- }
-
- if((next->type==phVOWEL) || ((next->type==phLIQUID)) && (next->newword==0)) // ?? test 14.Aug.2007
- {
- StartSyllable();
- if(p->synthflags & SFLAG_LENGTHEN)
- DoSpect(p->ph,prev->ph,next->ph,2,p,0);
- DoSpect(p->ph,prev->ph,next->ph,2,p,0);
- }
- else
- {
- if(p->synthflags & SFLAG_LENGTHEN)
- DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
- DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
- }
- break;
-
- case phNASAL:
- if(!(p->synthflags & SFLAG_SEQCONTINUE))
- {
- DoAmplitude(p->amp,NULL);
- DoPitch(envelope_data[p->env],p->pitch1,p->pitch2);
- }
-
- if(prev->type==phNASAL)
- {
- last_frame = NULL;
- }
-
- if(next->type==phVOWEL)
- {
- StartSyllable();
- DoSpect(p->ph,prev->ph,next->ph,1,p,0);
- }
- else
- if(prev->type==phVOWEL && (p->synthflags & SFLAG_SEQCONTINUE))
- {
- DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
- }
- else
- {
- last_frame = NULL; // only for nasal ?
- if(next->type == phLIQUID)
- DoSpect(p->ph,prev->ph,phoneme_tab[phonSONORANT],2,p,0);
- else
- DoSpect(p->ph,prev->ph,phoneme_tab[phonPAUSE],2,p,0);
- last_frame = NULL;
- }
-
- break;
-
- case phLIQUID:
- modulation = 0;
- if(p->ph->phflags & phTRILL)
- modulation = 5;
-
- prev_ph = prev->ph;
-// if(p->newword)
-// prev_ph = phoneme_tab[phonPAUSE]; // pronounce fully at the start of a word
-
- if(!(p->synthflags & SFLAG_SEQCONTINUE))
- {
- DoAmplitude(p->amp,NULL);
- DoPitch(envelope_data[p->env],p->pitch1,p->pitch2);
- }
-
- if(prev->type==phNASAL)
- {
- last_frame = NULL;
- }
-
- if(next->type==phVOWEL)
- {
- StartSyllable();
- DoSpect(p->ph,prev_ph,next->ph,1,p,modulation); // (,)r
- }
- else
- if(prev->type==phVOWEL && (p->synthflags & SFLAG_SEQCONTINUE))
- {
- DoSpect(p->ph,prev_ph,next->ph,1,p,modulation);
- }
- else
- {
- DoSpect(p->ph,prev_ph,next->ph,1,p,modulation);
- }
-
- break;
-
- case phVOWEL:
- ph = p->ph;
- stress = p->stresslevel & 0xf;
-
- // vowel transition from the preceding phoneme
- vowel_transition0 = vowel_transition[0];
- vowel_transition1 = vowel_transition[1];
-
- pitch_env = envelope_data[p->env];
- amp_env = NULL;
- if(p->tone_ph != 0)
- {
- pitch_env = LookupEnvelope(phoneme_tab[p->tone_ph]->spect);
- amp_env = LookupEnvelope(phoneme_tab[p->tone_ph]->after);
- }
-
- StartSyllable();
-
- modulation = 2;
- if(stress <= 1)
- modulation = 1; // 16ths
- else
- if(stress >= 7)
- modulation = 3;
-
- if(prev->type == phVSTOP || prev->type == phVFRICATIVE)
- {
- DoAmplitude(p->amp,amp_env);
- DoPitch(pitch_env,p->pitch1,p->pitch2); // don't use prevocalic rising tone
- DoSpect(ph,prev->ph,next->ph,1,p,modulation);
- }
- else
- if(prev->type==phLIQUID || prev->type==phNASAL)
- {
- DoAmplitude(p->amp,amp_env);
- DoSpect(ph,prev->ph,next->ph,1,p,modulation); // continue with pre-vocalic rising tone
- DoPitch(pitch_env,p->pitch1,p->pitch2);
- }
- else
- {
- if(!(p->synthflags & SFLAG_SEQCONTINUE))
- {
- DoAmplitude(p->amp,amp_env);
- DoPitch(pitch_env,p->pitch1,p->pitch2);
- }
-
- DoSpect(ph,prev->ph,next->ph,1,p,modulation);
- }
-
- if(option_phoneme_events)
- {
- DoMarker(espeakEVENT_PHONEME, sourceix, 0, p->ph->mnemonic);
- }
-
- DoSpect(p->ph,prev->ph,next->ph,2,p,modulation);
-
- memset(vowel_transition,0,sizeof(vowel_transition));
- break;
- }
- ix++;
- }
- EndPitch(1);
- if(*n_ph > 0)
- {
- DoMarker(espeakEVENT_END, count_characters, 0, count_sentences); // end of clause
- *n_ph = 0;
- }
-
- return(0); // finished the phoneme list
-} // end of Generate
-
-
-
-
-static int timer_on = 0;
-static int paused = 0;
-
-int SynthOnTimer()
-{//===============
- if(!timer_on)
- {
- return(WavegenCloseSound());
- }
-
- do {
- if(WcmdqUsed() > 0)
- WavegenOpenSound();
-
- if(Generate(phoneme_list,&n_phoneme_list,1)==0)
- {
- SpeakNextClause(NULL,NULL,1);
- }
- } while(skipping_text);
-
- return(0);
-}
-
-
-int SynthStatus()
-{//==============
- return(timer_on | paused);
-}
-
-
-
-int SpeakNextClause(FILE *f_in, const void *text_in, int control)
-{//==============================================================
-// Speak text from file (f_in) or memory (text_in)
-// control 0: start
-// either f_in or text_in is set, the other must be NULL
-
-// The other calls have f_in and text_in = NULL
-// control 1: speak next text
-// 2: stop
-// 3: pause (toggle)
-// 4: is file being read (0=no, 1=yes)
-// 5: interrupt and flush current text.
-
- int clause_tone;
- char *voice_change;
- static FILE *f_text=NULL;
- static const void *p_text=NULL;
-
- if(control == 4)
- {
- if((f_text == NULL) && (p_text == NULL))
- return(0);
- else
- return(1);
- }
-
- if(control == 2)
- {
- // stop speaking
- timer_on = 0;
- p_text = NULL;
- if(f_text != NULL)
- {
- fclose(f_text);
- f_text=NULL;
- }
- n_phoneme_list = 0;
- WcmdqStop();
-
- embedded_value[EMBED_T] = 0;
- return(0);
- }
-
- if(control == 3)
- {
- // toggle pause
- if(paused == 0)
- {
- timer_on = 0;
- paused = 2;
- }
- else
- {
- WavegenOpenSound();
- timer_on = 1;
- paused = 0;
- Generate(phoneme_list,&n_phoneme_list,0); // re-start from beginning of clause
- }
- return(0);
- }
-
- if(control == 5)
- {
- // stop speaking, but continue looking for text
- n_phoneme_list = 0;
- WcmdqStop();
- return(0);
- }
-
- if((f_in != NULL) || (text_in != NULL))
- {
- f_text = f_in;
- p_text = text_in;
- timer_on = 1;
- paused = 0;
- }
-
- if((f_text==NULL) && (p_text==NULL))
- {
- skipping_text = 0;
- timer_on = 0;
- return(0);
- }
-
- if((f_text != NULL) && feof(f_text))
- {
- timer_on = 0;
- fclose(f_text);
- f_text=NULL;
- return(0);
- }
-
- if(current_phoneme_table != voice->phoneme_tab_ix)
- {
- SelectPhonemeTable(voice->phoneme_tab_ix);
- }
-
- // read the next clause from the input text file, translate it, and generate
- // entries in the wavegen command queue
- p_text = TranslateClause(translator, f_text, p_text, &clause_tone, &voice_change);
-
- CalcPitches(translator, clause_tone);
- CalcLengths(translator);
-
- GetTranslatedPhonemeString(translator->phon_out,sizeof(translator->phon_out));
- if(option_phonemes > 0)
- {
- fprintf(f_trans,"%s\n",translator->phon_out);
-
- if(!iswalpha(0x010d))
- {
- // check that c-caron is recognized as an alphabetic character
- fprintf(stderr,"Warning: Accented letters are not recognized, eg: U+010D\nSet LC_CTYPE to a UTF-8 locale\n");
- }
- }
- if(phoneme_callback != NULL)
- {
- phoneme_callback(translator->phon_out);
- }
-
-
- if(skipping_text)
- {
- n_phoneme_list = 0;
- return(1);
- }
-
- if(mbrola_name[0] != 0)
- {
-#ifdef USE_MBROLA_LIB
- MbrolaTranslate(phoneme_list,n_phoneme_list,NULL);
-#else
- {
- FILE *f_mbrola;
- if((f_mbrola = f_trans) == stderr)
- f_mbrola = stdout;
- MbrolaTranslate(phoneme_list,n_phoneme_list,f_mbrola);
- }
-#endif
- }
-
- Generate(phoneme_list,&n_phoneme_list,0);
- WavegenOpenSound();
-
- if(voice_change != NULL)
- {
- // voice change at the end of the clause (i.e. clause was terminated by a voice change)
- new_voice = LoadVoiceVariant(voice_change,0); // add a Voice instruction to wavegen at the end of the clause
- }
-
- if(new_voice)
- {
- // finished the current clause, now change the voice if there was an embedded
- // change voice command at the end of it (i.e. clause was broken at the change voice command)
- DoVoiceChange(voice);
- new_voice = NULL;
- }
-
- return(1);
-} // end of SpeakNextClause
-
diff --git a/navit/support/espeak/synthesize.h b/navit/support/espeak/synthesize.h
deleted file mode 100755
index 193b93297..000000000
--- a/navit/support/espeak/synthesize.h
+++ /dev/null
@@ -1,377 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-
-#define N_PHONEME_LIST 1000 // enough for source[N_TR_SOURCE] full of text, else it will truncate
-
-#define MAX_HARMONIC 400 // 400 * 50Hz = 20 kHz, more than enough
-#define N_SEQ_FRAMES 25 // max frames in a spectrum sequence (real max is ablut 8)
-#define STEPSIZE 64 // 2.9mS at 22 kHz sample rate
-
-#define PITCHfall 0
-#define PITCHrise 1
-
-// flags set for frames within a spectrum sequence
-#define FRFLAG_KLATT 0x01 // this frame includes extra data for Klatt synthesizer
-#define FRFLAG_VOWEL_CENTRE 0x02 // centre point of vowel
-#define FRFLAG_LEN_MOD 0x04 // reduce effect of length adjustment
-#define FRFLAG_BREAK_LF 0x08 // but keep f3 upwards
-#define FRFLAG_BREAK 0x10 // don't merge with next frame
-#define FRFLAG_BREAK_2 0x18 // FRFLAG_BREAK_LF or FRFLAG_BREAK
-#define FRFLAG_FORMANT_RATE 0x20 // Flag5 allow increased rate of change of formant freq
-#define FRFLAG_MODULATE 0x40 // Flag6 modulate amplitude of some cycles to give trill
-#define FRFLAG_DEFER_WAV 0x80 // Flag7 defer mixing WAV until the next frame
-#define FRFLAG_COPIED 0x8000 // This frame has been copied into temporary rw memory
-
-#define SFLAG_SEQCONTINUE 0x01 // a liquid or nasal after a vowel, but not followed by a vowel
-#define SFLAG_EMBEDDED 0x02 // there are embedded commands before this phoneme
-#define SFLAG_SYLLABLE 0x04 // vowel or syllabic consonant
-#define SFLAG_LENGTHEN 0x08 // lengthen symbol : included after this phoneme
-#define SFLAG_DICTIONARY 0x10 // the pronunciation of this word was listed in the xx_list dictionary
-#define SFLAG_SWITCHED_LANG 0x20 // this word uses phonemes from a different language
-#define SFLAG_PROMOTE_STRESS 0x40 // this unstressed word can be promoted to stressed
-
-// embedded command numbers
-#define EMBED_P 1 // pitch
-#define EMBED_S 2 // speed (used in setlengths)
-#define EMBED_A 3 // amplitude/volume
-#define EMBED_R 4 // pitch range/expression
-#define EMBED_H 5 // echo/reverberation
-#define EMBED_T 6 // different tone for announcing punctuation
-#define EMBED_I 7 // sound icon
-#define EMBED_S2 8 // speed (used in synthesize)
-#define EMBED_Y 9 // say-as commands
-#define EMBED_M 10 // mark name
-#define EMBED_U 11 // audio uri
-#define EMBED_B 12 // break
-#define EMBED_F 13 // emphasis
-
-#define N_EMBEDDED_VALUES 14
-extern int embedded_value[N_EMBEDDED_VALUES];
-extern int embedded_default[N_EMBEDDED_VALUES];
-
-
-#define N_PEAKS 9
-#define N_MARKERS 8
-
-#define N_KLATTP 10 // this affects the phoneme data file format
-#define N_KLATTP2 14 // used in vowel files, with extra parameters for future extensions
-
-#define KLATT_AV 0
-#define KLATT_FNZ 1 // nasal zero freq
-#define KLATT_Tilt 2
-#define KLATT_Aspr 3
-#define KLATT_Skew 4
-
-#define KLATT_Kopen 5
-#define KLATT_AVp 6
-#define KLATT_Fric 7
-#define KLATT_FricBP 8
-#define KLATT_Turb 9
-
-
-
-typedef struct { // 44 bytes
- short frflags;
- short ffreq[7];
- unsigned char length;
- unsigned char rms;
- unsigned char fheight[8];
- unsigned char fwidth[6]; // width/4 f0-5
- unsigned char fright[3]; // width/4 f0-2
- unsigned char bw[4]; // Klatt bandwidth BNZ /2, f1,f2,f3
- unsigned char klattp[5]; // AV, FNZ, Tilt, Aspr, Skew
- unsigned char klattp2[5]; // continuation of klattp[], Avp, Fric, FricBP, Turb
- unsigned char klatt_ap[7]; // Klatt parallel amplitude
- unsigned char klatt_bp[7]; // Klatt parallel bandwidth /2
-} frame_t; // with extra Klatt parameters for parallel resonators
-
-typedef struct { // 44 bytes
- short frflags;
- short ffreq[7];
- unsigned char length;
- unsigned char rms;
- unsigned char fheight[8];
- unsigned char fwidth[6]; // width/4 f0-5
- unsigned char fright[3]; // width/4 f0-2
- unsigned char bw[4]; // Klatt bandwidth BNZ /2, f1,f2,f3
- unsigned char klattp[5]; // AV, FNZ, Tilt, Aspr, Skew
-} frame_t2; // TESTING
-
-
-#ifdef deleted
-typedef struct {
- short frflags;
- unsigned char length;
- unsigned char rms;
- short ffreq[9];
- unsigned char fheight[9];
- unsigned char fwidth[6]; // width/4
- unsigned char fright[6]; // width/4
- unsigned char fwidth6, fright6;
- unsigned char klattp[N_KLATTP];
-} frame_t;
-
-typedef struct { // 43 bytes
- short frflags;
- unsigned char length;
- unsigned char rms;
- short ffreq[9];
- unsigned char fheight[9];
- unsigned char fwidth[6]; // width/4
- unsigned char fright[6]; // width/4
-} frame_t2; // the original, without Klatt additions, used for file "phondata"
-#endif
-
-
-
-// formant data used by wavegen
-typedef struct {
- int freq; // Hz<<16
- int height; // height<<15
- int left; // Hz<<16
- int right; // Hz<<16
- DOUBLEX freq1; // floating point versions of the above
- DOUBLEX height1;
- DOUBLEX left1;
- DOUBLEX right1;
- DOUBLEX freq_inc; // increment by this every 64 samples
- DOUBLEX height_inc;
- DOUBLEX left_inc;
- DOUBLEX right_inc;
-} wavegen_peaks_t;
-
-typedef struct {
-unsigned char *pitch_env;
-int pitch; // pitch Hz*256
-int pitch_ix; // index into pitch envelope (*256)
-int pitch_inc; // increment to pitch_ix
-int pitch_base; // Hz*256 low, before modified by envelope
-int pitch_range; // Hz*256 range of envelope
-
-unsigned char *mix_wavefile; // wave file to be added to synthesis
-int n_mix_wavefile; // length in bytes
-int mix_wave_scale; // 0=2 byte samples
-int mix_wave_amp;
-int mix_wavefile_ix;
-
-int amplitude;
-int amplitude_v;
-int prev_was_synth; // previous sound was synthesized (not a played wave or pause)
-} WGEN_DATA;
-
-
-typedef struct {
- double a;
- double b;
- double c;
- double x1;
- double x2;
-} RESONATOR;
-
-
-typedef struct {
- short length_total; // not used
- unsigned char n_frames;
- unsigned char flags;
- frame_t2 frame[N_SEQ_FRAMES]; // max. frames in a spectrum sequence
-} SPECT_SEQ; // sequence of espeak formant frames
-
-typedef struct {
- short length_total; // not used
- unsigned char n_frames;
- unsigned char flags;
- frame_t frame[N_SEQ_FRAMES]; // max. frames in a spectrum sequence
-} SPECT_SEQK; // sequence of klatt formants frames
-
-
-typedef struct {
- short length;
- short frflags;
- frame_t *frame;
-} frameref_t;
-
-
-typedef struct {
- PHONEME_TAB *ph;
- unsigned char env; // pitch envelope number
- unsigned char stresslevel;
- unsigned char type;
- unsigned char prepause;
- unsigned char amp;
- unsigned char tone_ph; // tone phoneme to use with this vowel
- unsigned char newword; // bit 0=start of word, bit 1=end of clause, bit 2=start of sentence
- unsigned char synthflags;
- short length; // length_mod
- short pitch1; // pitch, 0-4095 within the Voice's pitch range
- short pitch2;
- unsigned short sourceix; // ix into the original source text string, only set at the start of a word
-} PHONEME_LIST;
-
-
-typedef struct {
- int name;
- int length;
- char *data;
- char *filename;
-} SOUND_ICON;
-
-typedef struct {
- int name;
- unsigned int next_phoneme;
- int mbr_name;
- int mbr_name2;
- int percent; // percentage length of first component
- int control;
-} MBROLA_TAB;
-
-typedef struct {
- int speed_factor1;
- int speed_factor2;
- int speed_factor3;
- int min_sample_len;
- int fast_settings[8];
-} SPEED_FACTORS;
-
-
-// phoneme table
-extern PHONEME_TAB *phoneme_tab[N_PHONEME_TAB];
-
-// list of phonemes in a clause
-extern int n_phoneme_list;
-extern PHONEME_LIST phoneme_list[N_PHONEME_LIST];
-extern unsigned int embedded_list[];
-
-extern unsigned char env_fall[128];
-extern unsigned char env_rise[128];
-extern unsigned char env_frise[128];
-
-#define MAX_PITCH_VALUE 101
-extern unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1];
-
-// queue of commands for wavegen
-#define WCMD_KLATT 1
-#define WCMD_KLATT2 2
-#define WCMD_SPECT 3
-#define WCMD_SPECT2 4
-#define WCMD_PAUSE 5
-#define WCMD_WAVE 6
-#define WCMD_WAVE2 7
-#define WCMD_AMPLITUDE 8
-#define WCMD_PITCH 9
-#define WCMD_MARKER 10
-#define WCMD_VOICE 11
-#define WCMD_EMBEDDED 12
-
-
-#define N_WCMDQ 160
-#define MIN_WCMDQ 22 // need this many free entries before adding new phoneme
-
-extern long wcmdq[N_WCMDQ][4];
-extern int wcmdq_head;
-extern int wcmdq_tail;
-
-// from Wavegen file
-int WcmdqFree();
-void WcmdqStop();
-int WcmdqUsed();
-void WcmdqInc();
-int WavegenOpenSound();
-int WavegenCloseSound();
-int WavegenInitSound();
-void WavegenInit(int rate, int wavemult_fact);
-float polint(float xa[],float ya[],int n,float x);
-int WavegenFill(int fill_zeros);
-void MarkerEvent(int type, unsigned int char_position, int value, unsigned char *out_ptr);
-
-
-extern unsigned char *wavefile_data;
-extern int samplerate;
-extern int samplerate_native;
-
-extern int wavefile_ix;
-extern int wavefile_amp;
-extern int wavefile_ix2;
-extern int wavefile_amp2;
-extern int vowel_transition[4];
-extern int vowel_transition0, vowel_transition1;
-
-extern int mbrola_delay;
-extern char mbrola_name[20];
-
-// from synthdata file
-unsigned int LookupSound(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int *match_level, int control);
-frameref_t *LookupSpect(PHONEME_TAB *ph1, PHONEME_TAB *prev_ph, PHONEME_TAB *next_ph, int which, int *match_level, int *n_frames, PHONEME_LIST *plist);
-
-unsigned char *LookupEnvelope(int ix);
-int LoadPhData();
-
-void SynthesizeInit(void);
-int Generate(PHONEME_LIST *phoneme_list, int *n_ph, int resume);
-void MakeWave2(PHONEME_LIST *p, int n_ph);
-int SynthOnTimer(void);
-int SpeakNextClause(FILE *f_text, const void *text_in, int control);
-int SynthStatus(void);
-void SetSpeed(int control);
-void SetEmbedded(int control, int value);
-void SelectPhonemeTable(int number);
-int SelectPhonemeTableName(const char *name);
-
-void Write4Bytes(FILE *f, int value);
-int Read4Bytes(FILE *f);
-int CompileDictionary(const char *dsource, const char *dict_name, FILE *log, char *err_name,int flags);
-
-
-extern unsigned char *envelope_data[18];
-extern int formant_rate[]; // max rate of change of each formant
-extern SPEED_FACTORS speed;
-
-extern long count_samples;
-extern int outbuf_size;
-extern unsigned char *out_ptr;
-extern unsigned char *out_start;
-extern unsigned char *out_end;
-extern int event_list_ix;
-extern espeak_EVENT *event_list;
-extern t_espeak_callback* synth_callback;
-extern int option_log_frames;
-extern const char *version_string;
-extern const int version_phdata;
-
-#define N_SOUNDICON_TAB 80 // total entries in soundicon_tab
-#define N_SOUNDICON_SLOTS 4 // number of slots reserved for dynamic loading of audio files
-extern int n_soundicon_tab;
-extern SOUND_ICON soundicon_tab[N_SOUNDICON_TAB];
-
-espeak_ERROR SetVoiceByName(const char *name);
-espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector);
-espeak_ERROR LoadMbrolaTable(const char *mbrola_voice, const char *phtrans, int srate);
-void SetParameter(int parameter, int value, int relative);
-void MbrolaTranslate(PHONEME_LIST *plist, int n_phonemes, FILE *f_mbrola);
-//int MbrolaSynth(char *p_mbrola);
-int DoSample(PHONEME_TAB *ph1, PHONEME_TAB *ph2, int which, int length_mod, int amp);
-int DoSpect(PHONEME_TAB *this_ph, PHONEME_TAB *prev_ph, PHONEME_TAB *next_ph,
- int which, PHONEME_LIST *plist, int modulation);
-int PauseLength(int pause, int control);
-int LookupPhonemeTable(const char *name);
-
-void InitBreath(void);
-
-void KlattInit();
-int Wavegen_Klatt2(int length, int modulation, int resume, frame_t *fr1, frame_t *fr2);
diff --git a/navit/support/espeak/tr_languages.c b/navit/support/espeak/tr_languages.c
deleted file mode 100644
index 83d1c8041..000000000
--- a/navit/support/espeak/tr_languages.c
+++ /dev/null
@@ -1,1335 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <wctype.h>
-#include <stdlib.h>
-#include <string.h>
-#include <locale.h>
-
-#include <wctype.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "translate.h"
-
-
-
-#define L_qa 0x716100
-#define L_grc 0x677263 // grc Ancient Greek
-#define L_jbo 0x6a626f // jbo Lojban
-#define L_pap 0x706170 // pap Papiamento
-#define L_zhy 0x7a6879 // zhy
-
-// start of unicode pages for character sets
-#define OFFSET_GREEK 0x380
-#define OFFSET_CYRILLIC 0x420
-#define OFFSET_ARMENIAN 0x530
-#define OFFSET_DEVANAGARI 0x900
-#define OFFSET_BENGALI 0x980
-#define OFFSET_TAMIL 0xb80
-#define OFFSET_KANNADA 0xc80
-#define OFFSET_MALAYALAM 0xd00
-#define OFFSET_KOREAN 0x1100
-
-static void Translator_Russian(Translator *tr);
-
-static void SetLetterVowel(Translator *tr, int c)
-{//==============================================
- tr->letter_bits[c] = (tr->letter_bits[c] & 0x40) | 0x81; // keep value for group 6 (front vowels e,i,y)
-}
-
-static void ResetLetterBits(Translator *tr, int groups)
-{//====================================================
-// Clear all the specified groups
- unsigned int ix;
- unsigned int mask;
-
- mask = ~groups;
-
- for(ix=0; ix<sizeof(tr->letter_bits); ix++)
- {
- tr->letter_bits[ix] &= mask;
- }
-}
-
-static void SetLetterBits(Translator *tr, int group, const char *string)
-{//=====================================================================
- int bits;
- unsigned char c;
-
- bits = (1L << group);
- while((c = *string++) != 0)
- tr->letter_bits[c] |= bits;
-}
-
-static void SetLetterBitsRange(Translator *tr, int group, int first, int last)
-{//===========================================================================
- int bits;
- int ix;
-
- bits = (1L << group);
- for(ix=first; ix<=last; ix++)
- {
- tr->letter_bits[ix] |= bits;
- }
-}
-
-
-static Translator* NewTranslator(void)
-{//===================================
- Translator *tr;
- int ix;
- static const unsigned char stress_amps2[] = {17,17, 20,20, 20,22, 22,20 };
- static const short stress_lengths2[8] = {182,140, 220,220, 220,240, 260,280};
- static const wchar_t empty_wstring[1] = {0};
- static const wchar_t punct_in_word[2] = {'\'', 0}; // allow hyphen within words
-
- tr = (Translator *)Alloc(sizeof(Translator));
- if(tr == NULL)
- return(NULL);
-
- tr->charset_a0 = charsets[1]; // ISO-8859-1, this is for when the input is not utf8
- dictionary_name[0] = 0;
- tr->dict_condition=0;
- tr->data_dictrules = NULL; // language_1 translation rules file
- tr->data_dictlist = NULL; // language_2 dictionary lookup file
-
- tr->transpose_offset = 0;
-
- // only need lower case
- tr->letter_bits_offset = 0;
- memset(tr->letter_bits,0,sizeof(tr->letter_bits));
- memset(tr->letter_groups,0,sizeof(tr->letter_groups));
-
- // 0-5 sets of characters matched by A B C E F G in pronunciation rules
- // these may be set differently for different languages
- SetLetterBits(tr,0,"aeiou"); // A vowels, except y
- SetLetterBits(tr,1,"bcdfgjklmnpqstvxz"); // B hard consonants, excluding h,r,w
- SetLetterBits(tr,2,"bcdfghjklmnpqrstvwxz"); // C all consonants
- SetLetterBits(tr,3,"hlmnr"); // H 'soft' consonants
- SetLetterBits(tr,4,"cfhkpqstx"); // F voiceless consonants
- SetLetterBits(tr,5,"bdgjlmnrvwyz"); // G voiced
- SetLetterBits(tr,6,"eiy"); // Letter group Y, front vowels
- SetLetterBits(tr,7,"aeiouy"); // vowels, including y
-
-
- tr->char_plus_apostrophe = empty_wstring;
- tr->punct_within_word = punct_in_word;
-
- for(ix=0; ix<8; ix++)
- {
- tr->stress_amps[ix] = stress_amps2[ix];
- tr->stress_amps_r[ix] = stress_amps2[ix] - 1;
- tr->stress_lengths[ix] = stress_lengths2[ix];
- }
- memset(&(tr->langopts),0,sizeof(tr->langopts));
-
- tr->langopts.stress_rule = 2;
- tr->langopts.unstressed_wd1 = 1;
- tr->langopts.unstressed_wd2 = 3;
- tr->langopts.param[LOPT_SONORANT_MIN] = 95;
- tr->langopts.param[LOPT_MAXAMP_EOC] = 19;
- tr->langopts.param[LOPT_UNPRONOUNCABLE] = 's'; // don't count this character at start of word
- tr->langopts.max_initial_consonants = 3;
- tr->langopts.replace_chars = NULL;
- tr->langopts.ascii_language = ""; // Non-Latin alphabet languages, use this language to speak Latin words, default is English
-
- SetLengthMods(tr,201);
-// tr->langopts.length_mods = length_mods_en;
-// tr->langopts.length_mods0 = length_mods_en0;
-
- tr->langopts.long_stop = 100;
-
- tr->langopts.max_roman = 49;
- tr->langopts.thousands_sep = ',';
- tr->langopts.decimal_sep = '.';
-
- memcpy(tr->punct_to_tone, punctuation_to_tone, sizeof(tr->punct_to_tone));
-
- return(tr);
-}
-
-
-static const unsigned int replace_cyrillic_latin[] =
- {0x430,'a',
- 0x431,'b',
- 0x446,'c',
- 0x45b,0x107,
- 0x447,0x10d,
- 0x45f,'d'+(0x17e<<16),
- 0x455,'d'+('z'<<16),
- 0x434,'d',
- 0x452,0x111,
- 0x435,'e',
- 0x444,'f',
- 0x433,'g',
- 0x445,'h',
- 0x438,'i',
- 0x458,'j',
- 0x43a,'k',
- 0x459,'l'+('j'<<16),
- 0x43b,'l',
- 0x43c,'m',
- 0x45a,'n'+('j'<<16),
- 0x43d,'n',
- 0x43e,'o',
- 0x43f,'p',
- 0x440,'r',
- 0x441,'s',
- 0x448,0x161,
- 0x442,'t',
- 0x443,'u',
- 0x432,'v',
- 0x437,'z',
- 0x436,0x17e,
- 0x453,0x111,
- 0x45c,0x107,
-0}; // ѓ ѕ ќ
-
-
-void SetIndicLetters(Translator *tr)
-{//=================================
- // Set letter types for Indic scripts, Devanagari, Tamill, etc
- static const char dev_consonants2[] = {0x02,0x03,0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f};
-
- memset(tr->letter_bits,0,sizeof(tr->letter_bits));
- SetLetterBitsRange(tr,LETTERGP_A,0x04,0x14); // vowel letters only
- SetLetterBitsRange(tr,LETTERGP_B,0x3e,0x4d); // vowel signs, and virama
-
- SetLetterBitsRange(tr,LETTERGP_C,0x15,0x39); // the main consonant range
- SetLetterBits(tr,LETTERGP_C,dev_consonants2); // + additional consonants
-
- SetLetterBitsRange(tr,LETTERGP_Y,0x04,0x14); // vowel letters
- SetLetterBitsRange(tr,LETTERGP_Y,0x3e,0x4c); // + vowel signs
-
- tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
-}
-
-void SetupTranslator(Translator *tr, const short *lengths, const unsigned char *amps)
-{//==================================================================================
- if(lengths != NULL)
- memcpy(tr->stress_lengths,lengths,sizeof(tr->stress_lengths));
- if(amps != NULL)
- memcpy(tr->stress_amps,amps,sizeof(tr->stress_amps));
-}
-
-
-Translator *SelectTranslator(const char *name)
-{//===========================================
- int name2 = 0;
- Translator *tr;
-
- static const unsigned char stress_amps_sk[8] = {17,17, 20,20, 20,22, 22,21 };
- static const short stress_lengths_sk[8] = {190,190, 210,210, 0,0, 210,210};
-
- // convert name string into a word of up to 4 characters, for the switch()
- while(*name != 0)
- name2 = (name2 << 8) + *name++;
-
- tr = NewTranslator();
-
- switch(name2)
- {
- case L('a','f'):
- {
- static const short stress_lengths_af[8] = {170,140, 220,220, 0, 0, 250,270};
- SetupTranslator(tr,stress_lengths_af,NULL);
-
- tr->langopts.stress_rule = 0;
- tr->langopts.vowel_pause = 0x30;
- tr->langopts.param[LOPT_DIERESES] = 1;
- tr->langopts.param[LOPT_PREFIXES] = 1;
- SetLetterVowel(tr,'y'); // add 'y' to vowels
-
- tr->langopts.numbers = 0x8d1 + NUM_ROMAN;
- tr->langopts.accents = 1;
- }
- break;
-
- case L('b','n'): // Bengali
- {
- static const short stress_lengths_bn[8] = {180, 180, 210, 210, 0, 0, 230, 240};
- static const unsigned char stress_amps_bn[8] = {18,18, 18,18, 20,20, 22,22 };
-
- SetupTranslator(tr,stress_lengths_bn,stress_amps_bn);
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
-
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
- tr->letter_bits_offset = OFFSET_BENGALI;
- SetIndicLetters(tr); // call this after setting OFFSET_BENGALI
- SetLetterBitsRange(tr,LETTERGP_F,0x3e,0x4c); // vowel signs, but not virama
-
- tr->langopts.numbers = 0x1;
- tr->langopts.numbers2 = NUM2_100000;
- }
- break;
-
- case L('c','y'): // Welsh
- {
- static const short stress_lengths_cy[8] = {170,220, 180,180, 0, 0, 250,270};
- static const unsigned char stress_amps_cy[8] = {17,15, 18,18, 0,0, 22,20 }; // 'diminished' is used to mark a quieter, final unstressed syllable
-
- SetupTranslator(tr,stress_lengths_cy,stress_amps_cy);
-
- tr->charset_a0 = charsets[14]; // ISO-8859-14
-// tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 2;
-// tr->langopts.intonation_group = 4;
-
- // 'diminished' is an unstressed final syllable
- tr->langopts.stress_flags = 0x6 | 0x10;
- tr->langopts.unstressed_wd1 = 0;
- tr->langopts.unstressed_wd2 = 2;
- tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
-
- tr->langopts.numbers = 0x401;
-
- SetLetterVowel(tr,'w'); // add letter to vowels and remove from consonants
- SetLetterVowel(tr,'y');
- }
- break;
-
- case L('d','a'): // Danish
- {
- static const short stress_lengths_da[8] = {160,140, 200,200, 0,0, 220,210};
- SetupTranslator(tr,stress_lengths_da,NULL);
-
- tr->langopts.stress_rule = 0;
- SetLetterVowel(tr,'y');
- tr->langopts.numbers = 0x10c59;
- }
- break;
-
-
- case L('d','e'):
- {
- static const short stress_lengths_de[8] = {150,130, 200,200, 0, 0, 260,275};
- tr->langopts.stress_rule = 0;
- tr->langopts.word_gap = 0x8; // don't use linking phonemes
- tr->langopts.vowel_pause = 0x30;
- tr->langopts.param[LOPT_PREFIXES] = 1;
- memcpy(tr->stress_lengths,stress_lengths_de,sizeof(tr->stress_lengths));
-
- tr->langopts.numbers = 0x11419 + NUM_ROMAN;
- SetLetterVowel(tr,'y');
- }
- break;
-
- case L('e','n'):
- {
- static const short stress_lengths_en[8] = {182,140, 220,220, 0,0, 248,275};
- SetupTranslator(tr,stress_lengths_en,NULL);
-
- tr->langopts.stress_rule = 0;
- tr->langopts.numbers = 0x841 + NUM_ROMAN;
- tr->langopts.param[LOPT_COMBINE_WORDS] = 2; // allow "mc" to cmbine with the following word
- }
- break;
-
- case L('e','l'): // Greek
- case L_grc: // Ancient Greek
- {
- static const short stress_lengths_el[8] = {155, 180, 210, 210, 0, 0, 270, 300};
- static const unsigned char stress_amps_el[8] = {15,12, 20,20, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
-
- // character codes offset by 0x380
- static const char el_vowels[] = {0x10,0x2c,0x2d,0x2e,0x2f,0x30,0x31,0x35,0x37,0x39,0x3f,0x45,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0};
- static const char el_fvowels[] = {0x2d,0x2e,0x2f,0x35,0x37,0x39,0x45,0x4d,0}; // ε η ι Ï… έ ή ί Ï
- static const char el_voiceless[]= {0x38,0x3a,0x3e,0x40,0x42,0x43,0x44,0x46,0x47,0}; // θ κ ξ π ς σ τ φ χ
- static const char el_consonants[]={0x32,0x33,0x34,0x36,0x38,0x3a,0x3b,0x3c,0x3d,0x3e,0x40,0x41,0x42,0x43,0x44,0x46,0x47,0x48,0};
- static const wchar_t el_char_apostrophe[] = {0x3c3,0}; // σ
-
- SetupTranslator(tr,stress_lengths_el,stress_amps_el);
-
- tr->charset_a0 = charsets[7]; // ISO-8859-7
- tr->char_plus_apostrophe = el_char_apostrophe;
-
- tr->letter_bits_offset = OFFSET_GREEK;
- memset(tr->letter_bits,0,sizeof(tr->letter_bits));
- SetLetterBits(tr,LETTERGP_A,el_vowels);
- SetLetterBits(tr,LETTERGP_B,el_voiceless);
- SetLetterBits(tr,LETTERGP_C,el_consonants);
- SetLetterBits(tr,LETTERGP_Y,el_fvowels); // front vowels: ε η ι υ
-
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
- tr->langopts.unstressed_wd1 = 0;
- tr->langopts.unstressed_wd2 = 2;
- tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
-
- tr->langopts.numbers = 0x109;
- tr->langopts.numbers2 = 0x2; // variant form of numbers before thousands
-
- if(name2 == L_grc)
- {
- // ancient greek
- tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1;
- }
- }
- break;
-
- case L('e','o'):
- {
- static const short stress_lengths_eo[8] = {145, 145, 230, 170, 0, 0, 360, 370};
- static const unsigned char stress_amps_eo[] = {16,14, 20,20, 20,22, 22,21 };
- static const wchar_t eo_char_apostrophe[2] = {'l',0};
-
- SetupTranslator(tr,stress_lengths_eo,stress_amps_eo);
-
- tr->charset_a0 = charsets[3]; // ISO-8859-3
- tr->char_plus_apostrophe = eo_char_apostrophe;
-
- tr->langopts.word_gap = 1;
- tr->langopts.vowel_pause = 2;
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x6 | 0x10;
- tr->langopts.unstressed_wd1 = 3;
- tr->langopts.unstressed_wd2 = 2;
-
- tr->langopts.numbers = 0x1409 + NUM_ROMAN;
- }
- break;
-
- case L('e','s'): // Spanish
- case L('c','a'): // Catalan
- case L_pap: // Papiamento
- {
- static const short stress_lengths_es[8] = {180, 210, 190, 190, 0, 0, 230, 260};
-// static const short stress_lengths_es[8] = {170, 200, 180, 180, 0, 0, 220, 250};
- static const unsigned char stress_amps_es[8] = {16,12, 18,18, 20,20, 20,20 }; // 'diminished' is used to mark a quieter, final unstressed syllable
- static const wchar_t ca_punct_within_word[] = {'\'',0xb7,0}; // ca: allow middle-dot within word
-
- SetupTranslator(tr,stress_lengths_es,stress_amps_es);
-
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 2;
-
- // stress last syllable if it doesn't end in vowel or "s" or "n"
- // 'diminished' is an unstressed final syllable
- tr->langopts.stress_flags = 0x200 | 0x6 | 0x10;
- tr->langopts.unstressed_wd1 = 0;
- tr->langopts.unstressed_wd2 = 2;
- tr->langopts.param[LOPT_SONORANT_MIN] = 120; // limit the shortening of sonorants before short vowels
-
- tr->langopts.numbers = 0x529 + NUM_ROMAN + NUM_ROMAN_AFTER;
-
- if(name2 == L('c','a'))
- {
- tr->punct_within_word = ca_punct_within_word;
- tr->langopts.stress_flags = 0x200 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
- }
- else
- if(name2 == L_pap)
- {
- tr->langopts.stress_flags = 0x100 | 0x6 | 0x30; // stress last syllable unless word ends with a vowel
- }
- }
- break;
-
-
- case L('e','u'): // basque
- {
- static const short stress_lengths_eu[8] = {200, 200, 200, 200, 0, 0, 210, 230}; // very weak stress
- static const unsigned char stress_amps_eu[8] = {16,16, 18,18, 18,18, 18,18 };
- SetupTranslator(tr,stress_lengths_eu,stress_amps_eu);
- tr->langopts.stress_rule = 1; // ?? second syllable ??
- tr->langopts.numbers = 0x569 + NUM_VIGESIMAL;
- }
- break;
-
-
- case L('f','i'): // Finnish
- {
- static const unsigned char stress_amps_fi[8] = {18,16, 22,22, 20,22, 22,22 };
- static const short stress_lengths_fi[8] = {150,180, 200,200, 0,0, 210,250};
-
- SetupTranslator(tr,stress_lengths_fi,stress_amps_fi);
-
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x56; // move secondary stress from light to a following heavy syllable
- tr->langopts.param[LOPT_IT_DOUBLING] = 1;
- tr->langopts.long_stop = 130;
-
- tr->langopts.numbers = 0x1009;
- SetLetterVowel(tr,'y');
-// tr->langopts.max_initial_consonants = 2; // BUT foreign words may have 3
- tr->langopts.spelling_stress = 1;
- tr->langopts.intonation_group = 3; // less intonation, don't raise pitch at comma
- }
- break;
-
-
- case L('f','r'): // french
- {
- static const short stress_lengths_fr[8] = {190, 170, 190, 200, 0, 0, 235, 240};
- static const unsigned char stress_amps_fr[8] = {18,16, 20,20, 20,22, 22,21 };
-
- SetupTranslator(tr,stress_lengths_fr,stress_amps_fr);
- tr->langopts.stress_rule = 3; // stress on final syllable
- tr->langopts.stress_flags = 0x0024; // don't use secondary stress
- tr->langopts.param[LOPT_IT_LENGTHEN] = 1; // remove lengthen indicator from unstressed syllables
-
- tr->langopts.numbers = 0x1509 + 0x8000 + (NUM_NOPAUSE | NUM_ROMAN | NUM_VIGESIMAL);
- SetLetterVowel(tr,'y');
- }
- break;
-
-#ifdef deleted
- case L('g','a'): // Irish Gaelic
- {
- tr->langopts.stress_rule = 1;
- }
- break;
-#endif
-
- case L('h','i'): // Hindi
- case L('n','e'): // Nepali
- {
- static const short stress_lengths_hi[8] = {190, 190, 210, 210, 0, 0, 230, 250};
- static const unsigned char stress_amps_hi[8] = {17,14, 20,19, 20,22, 22,21 };
-
- SetupTranslator(tr,stress_lengths_hi,stress_amps_hi);
- tr->charset_a0 = charsets[19]; // ISCII
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
-
- tr->langopts.stress_rule = 6; // stress on last heaviest syllable, excluding final syllable
- tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
- tr->langopts.numbers = 0x011;
- tr->langopts.numbers2 = NUM2_100000;
- tr->letter_bits_offset = OFFSET_DEVANAGARI;
- SetIndicLetters(tr);
- }
- break;
-
-
- case L('h','r'): // Croatian
- case L('b','s'): // Bosnian
- case L('s','r'): // Serbian
- {
- static const unsigned char stress_amps_hr[8] = {17,17, 20,20, 20,22, 22,21 };
- static const short stress_lengths_hr[8] = {180,160, 200,200, 0,0, 220,230};
- static const short stress_lengths_sr[8] = {160,150, 200,200, 0,0, 250,260};
-
- if(name2 == L('s','r'))
- SetupTranslator(tr,stress_lengths_sr,stress_amps_hr);
- else
- SetupTranslator(tr,stress_lengths_hr,stress_amps_hr);
- tr->charset_a0 = charsets[2]; // ISO-8859-2
-
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x10;
- tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
- tr->langopts.max_initial_consonants = 5;
- tr->langopts.spelling_stress = 1;
- tr->langopts.accents = 1;
-
- tr->langopts.numbers = 0x140d + 0x4000 + NUM_ROMAN_UC;
- tr->langopts.numbers2 = 0x4a; // variant numbers before thousands,milliards
- tr->langopts.replace_chars = replace_cyrillic_latin;
-
- SetLetterVowel(tr,'y');
- SetLetterVowel(tr,'r');
- }
- break;
-
-
- case L('h','u'): // Hungarian
- {
- static const unsigned char stress_amps_hu[8] = {17,17, 19,19, 20,22, 22,21 };
- static const short stress_lengths_hu[8] = {185,195, 195,190, 0,0, 210,220};
-
- SetupTranslator(tr,stress_lengths_hu,stress_amps_hu);
- tr->charset_a0 = charsets[2]; // ISO-8859-2
-
- tr->langopts.vowel_pause = 0x20;
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x8036;
- tr->langopts.unstressed_wd1 = 2;
-// tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x4; // don't propagate over word boundaries
- tr->langopts.param[LOPT_IT_DOUBLING] = 1;
- tr->langopts.param[LOPT_COMBINE_WORDS] = 99; // combine some prepositions with the following word
-
- tr->langopts.numbers = 0x1009 + 0xa000 + NUM_ROMAN + 0x10000;
- SetLetterVowel(tr,'y');
- tr->langopts.spelling_stress = 1;
-SetLengthMods(tr,3); // all equal
- }
- break;
-
- case L('h','y'): // Armenian
- {
- static const short stress_lengths_hy[8] = {250, 200, 250, 250, 0, 0, 250, 250};
- static const char hy_vowels[] = {0x31, 0x35, 0x37, 0x38, 0x3b, 0x48, 0x55, 0};
- static const char hy_consonants[] = {0x32,0x33,0x34,0x36,0x39,0x3a,0x3c,0x3d,0x3e,0x3f,
- 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x56,0};
-
- SetupTranslator(tr,stress_lengths_hy,NULL);
- tr->langopts.stress_rule = 3; // default stress on final syllable
-
- tr->letter_bits_offset = OFFSET_ARMENIAN;
- memset(tr->letter_bits,0,sizeof(tr->letter_bits));
- SetLetterBits(tr,LETTERGP_A,hy_vowels);
- SetLetterBits(tr,LETTERGP_C,hy_consonants);
- tr->langopts.max_initial_consonants = 6;
- tr->langopts.numbers = 0x409;
-// tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
- }
- break;
-
- case L('i','d'): // Indonesian
- {
- static const short stress_lengths_id[8] = {160, 200, 180, 180, 0, 0, 220, 240};
- static const unsigned char stress_amps_id[8] = {16,18, 18,18, 20,22, 22,21 };
-
- SetupTranslator(tr,stress_lengths_id,stress_amps_id);
- tr->langopts.stress_rule = 2;
- tr->langopts.numbers = 0x1009 + NUM_ROMAN;
- tr->langopts.stress_flags = 0x6 | 0x10;
- tr->langopts.accents = 2; // "capital" after letter name
- }
- break;
-
- case L('i','s'): // Icelandic
- {
- static const short stress_lengths_is[8] = {180,160, 200,200, 0,0, 240,250};
- static const wchar_t is_lettergroup_B[] = {'c','f','h','k','p','t','x',0xfe,0}; // voiceless conants, including 'þ' ?? 's'
-
- SetupTranslator(tr,stress_lengths_is,NULL);
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x10;
- tr->langopts.param[LOPT_IT_LENGTHEN] = 0x11; // remove lengthen indicator from unstressed vowels
- tr->langopts.param[LOPT_REDUCE] = 2;
-
- ResetLetterBits(tr,0x18);
- SetLetterBits(tr,4,"kpst"); // Letter group F
- SetLetterBits(tr,3,"jvr"); // Letter group H
- tr->letter_groups[1] = is_lettergroup_B;
- SetLetterVowel(tr,'y');
- tr->langopts.numbers = 0x8e9;
- tr->langopts.numbers2 = 0x2;
- }
- break;
-
- case L('i','t'): // Italian
- {
- static const short stress_lengths_it[8] = {150, 140, 170, 170, 0, 0, 300, 330};
- static const unsigned char stress_amps_it[8] = {15,14, 19,19, 20,22, 22,20 };
-
- SetupTranslator(tr,stress_lengths_it,stress_amps_it);
-
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x10 | 0x20000;
- tr->langopts.vowel_pause = 1;
- tr->langopts.unstressed_wd1 = 2;
- tr->langopts.unstressed_wd2 = 2;
- tr->langopts.param[LOPT_IT_LENGTHEN] = 2; // remove lengthen indicator from unstressed or non-penultimate syllables
- tr->langopts.param[LOPT_IT_DOUBLING] = 2; // double the first consonant if the previous word ends in a stressed vowel
- tr->langopts.param[LOPT_SONORANT_MIN] = 130; // limit the shortening of sonorants before short vowels
- tr->langopts.param[LOPT_REDUCE] = 1; // reduce vowels even if phonemes are specified in it_list
- tr->langopts.param[LOPT_ALT] = 2; // call ApplySpecialAttributes2() if a word has $alt or $alt2
- tr->langopts.numbers = 0x2709 + NUM_ROMAN;
- tr->langopts.accents = 2; // Say "Capital" after the letter.
- SetLetterVowel(tr,'y');
- }
- break;
-
- case L_jbo: // Lojban
- {
- static const short stress_lengths_jbo[8] = {145,145, 170,160, 0,0, 330,350};
- static const wchar_t jbo_punct_within_word[] = {'.',',','\'',0x2c8,0}; // allow period and comma within a word, also stress marker (from LOPT_CAPS_IN_WORD)
-
- SetupTranslator(tr,stress_lengths_jbo,NULL);
- tr->langopts.stress_rule = 2;
- tr->langopts.vowel_pause = 0x20c; // pause before a word which starts with a vowel, or after a word which ends in a consonant
-// tr->langopts.word_gap = 1;
- tr->punct_within_word = jbo_punct_within_word;
- tr->langopts.param[LOPT_CAPS_IN_WORD] = 2; // capitals indicate stressed syllables
- SetLetterVowel(tr,'y');
- }
- break;
-
- case L('k','o'): // Korean, TEST
- {
- static const char ko_ivowels[] = {0x63,0x64,0x67,0x68,0x6d,0x72,0x74,0x75,0}; // y and i vowels
- static const unsigned char ko_voiced[] = {0x02,0x05,0x06,0xab,0xaf,0xb7,0xbc,0}; // voiced consonants, l,m,n,N
-
- tr->letter_bits_offset = OFFSET_KOREAN;
- memset(tr->letter_bits,0,sizeof(tr->letter_bits));
- SetLetterBitsRange(tr,LETTERGP_A,0x61,0x75);
- SetLetterBits(tr,LETTERGP_Y,ko_ivowels);
- SetLetterBits(tr,LETTERGP_G,(const char *)ko_voiced);
-
- tr->langopts.stress_rule = 8; // ?? 1st syllable if it is heavy, else 2nd syllable
- tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
- tr->langopts.numbers = 0x0401;
- }
- break;
-
- case L('k','u'): // Kurdish
- {
- static const unsigned char stress_amps_ku[8] = {18,18, 20,20, 20,22, 22,21 };
- static const short stress_lengths_ku[8] = {180,180, 190,180, 0,0, 230,240};
-
- SetupTranslator(tr,stress_lengths_ku,stress_amps_ku);
- tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
-
- tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
-
- tr->langopts.numbers = 0x100461;
- tr->langopts.max_initial_consonants = 2;
- }
- break;
-
- case L('l','a'): //Latin
- {
- tr->charset_a0 = charsets[4]; // ISO-8859-4, includes a,e,i,o,u-macron
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x20;
- tr->langopts.unstressed_wd1 = 0;
- tr->langopts.unstressed_wd2 = 2;
- tr->langopts.param[LOPT_DIERESES] = 1;
- tr->langopts.numbers = 0x1 + NUM_ROMAN;
- tr->langopts.max_roman = 5000;
- }
- break;
-
- case L('l','v'): // latvian
- {
- static const unsigned char stress_amps_lv[8] = {17,13, 20,20, 20,22, 22,21 };
- static const short stress_lengths_lv[8] = {180,130, 210,210, 0,0, 210,210};
-
- SetupTranslator(tr,stress_lengths_lv,stress_amps_lv);
-
- tr->langopts.stress_rule = 0;
- tr->langopts.spelling_stress = 1;
- tr->charset_a0 = charsets[4]; // ISO-8859-4
- tr->langopts.numbers = 0x409 + 0x8000 + 0x10000;
- tr->langopts.stress_flags = 0x16 + 0x40000;
- }
- break;
-
- case L('m','k'): // Macedonian
- {
- static wchar_t vowels_cyrillic[] = {0x440, // also include 'Ñ€' [R]
- 0x430,0x435,0x438,0x439,0x43e,0x443,0x44b,0x44d,0x44e,0x44f,0x450,0x451,0x456,0x457,0x45d,0x45e,0};
- static const unsigned char stress_amps_mk[8] = {17,17, 20,20, 20,22, 22,21 };
- static const short stress_lengths_mk[8] = {180,160, 200,200, 0,0, 220,230};
-
- SetupTranslator(tr,stress_lengths_mk,stress_amps_mk);
- tr->charset_a0 = charsets[5]; // ISO-8859-5
- tr->letter_groups[0] = vowels_cyrillic;
-
- tr->langopts.stress_rule = 4; // antipenultimate
- tr->langopts.numbers = 0x0429 + 0x4000;
- tr->langopts.numbers2 = 0x8a; // variant numbers before thousands,milliards
- }
- break;
-
-
- case L('n','l'): // Dutch
- {
- static const short stress_lengths_nl[8] = {160,135, 210,210, 0, 0, 260,280};
-
- tr->langopts.stress_rule = 0;
- tr->langopts.vowel_pause = 1;
- tr->langopts.param[LOPT_DIERESES] = 1;
- tr->langopts.param[LOPT_PREFIXES] = 1;
- SetLetterVowel(tr,'y');
-
- tr->langopts.numbers = 0x11c19;
- memcpy(tr->stress_lengths,stress_lengths_nl,sizeof(tr->stress_lengths));
- }
- break;
-
- case L('n','o'): // Norwegian
- {
- static const short stress_lengths_no[8] = {160,140, 200,200, 0,0, 220,210};
-
- SetupTranslator(tr,stress_lengths_no,NULL);
- tr->langopts.stress_rule = 0;
- SetLetterVowel(tr,'y');
- tr->langopts.numbers = 0x11849;
- }
- break;
-
- case L('o','m'):
- {
- static const unsigned char stress_amps_om[] = {18,15, 20,20, 20,22, 22,22 };
- static const short stress_lengths_om[8] = {200,200, 200,200, 0,0, 200,200};
-
- SetupTranslator(tr,stress_lengths_om,stress_amps_om);
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x16 + 0x80000;
- }
- break;
-
- case L('p','l'): // Polish
- {
- static const short stress_lengths_pl[8] = {160, 190, 175, 175, 0, 0, 200, 210};
- static const unsigned char stress_amps_pl[8] = {17,13, 19,19, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
-
- SetupTranslator(tr,stress_lengths_pl,stress_amps_pl);
-
- tr->charset_a0 = charsets[2]; // ISO-8859-2
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x6; // mark unstressed final syllables as diminished
- tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x8;
- tr->langopts.max_initial_consonants = 7; // for example: wchrzczony :)
- tr->langopts.numbers=0x1009 + 0x4000;
- tr->langopts.numbers2=0x40;
- tr->langopts.param[LOPT_COMBINE_WORDS] = 4 + 0x100; // combine 'nie' (marked with $alt2) with some 1-syllable (and 2-syllable) words (marked with $alt)
- SetLetterVowel(tr,'y');
- }
- break;
-
- case L('p','t'): // Portuguese
- {
- static const short stress_lengths_pt[8] = {180, 125, 210, 210, 0, 0, 270, 295};
- static const unsigned char stress_amps_pt[8] = {16,13, 19,19, 20,22, 22,21 }; // 'diminished' is used to mark a quieter, final unstressed syllable
-
- SetupTranslator(tr,stress_lengths_pt,stress_amps_pt);
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
-
- tr->langopts.stress_rule = 3; // stress on final syllable
- tr->langopts.stress_flags = 0x6 | 0x10 | 0x20000;
- tr->langopts.numbers = 0x069 + 0x4000 + NUM_ROMAN;
- SetLetterVowel(tr,'y');
- ResetLetterBits(tr,0x2);
- SetLetterBits(tr,1,"bcdfgjkmnpqstvxz"); // B hard consonants, excluding h,l,r,w,y
- }
- break;
-
- case L('r','o'): // Romanian
- {
- static const short stress_lengths_ro[8] = {170, 170, 180, 180, 0, 0, 240, 260};
- static const unsigned char stress_amps_ro[8] = {15,13, 18,18, 20,22, 22,21 };
-
- SetupTranslator(tr,stress_lengths_ro,stress_amps_ro);
-
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x100 + 0x6;
-
- tr->charset_a0 = charsets[2]; // ISO-8859-2
- tr->langopts.numbers = 0x1029+0x6000 + NUM_ROMAN;
- tr->langopts.numbers2 = 0x1e; // variant numbers before all thousandplex
- }
- break;
-
- case L('r','u'): // Russian
- Translator_Russian(tr);
- break;
-
- case L('r','w'): // Kiryarwanda
- {
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x16;
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
-
- tr->langopts.numbers = 0x61 + 0x100000 + 0x4000;
- tr->langopts.numbers2 = 0x200; // say "thousands" before its number
- }
- break;
-
- case L('s','k'): // Slovak
- case L('c','s'): // Czech
- {
- static const char *sk_voiced = "bdgjlmnrvwzaeiouy";
-
- SetupTranslator(tr,stress_lengths_sk,stress_amps_sk);
- tr->charset_a0 = charsets[2]; // ISO-8859-2
-
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x16;
- tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 0x3;
- tr->langopts.max_initial_consonants = 5;
- tr->langopts.spelling_stress = 1;
- tr->langopts.param[LOPT_COMBINE_WORDS] = 4; // combine some prepositions with the following word
-
- tr->langopts.numbers = 0x0401 + 0x4000 + NUM_ROMAN;
- tr->langopts.numbers2 = 0x100;
- tr->langopts.thousands_sep = 0; //no thousands separator
- tr->langopts.decimal_sep = ',';
-
- if(name2 == L('c','s'))
- {
- tr->langopts.numbers2 = 0x108; // variant numbers before milliards
- }
-
- SetLetterVowel(tr,'y');
- SetLetterVowel(tr,'r');
- ResetLetterBits(tr,0x20);
- SetLetterBits(tr,5,sk_voiced);
- }
- break;
-
- case L('s','q'): // Albanian
- {
- static const short stress_lengths_sq[8] = {150, 150, 180, 180, 0, 0, 300, 300};
- static const unsigned char stress_amps_sq[8] = {16,12, 16,16, 20,20, 21,19 };
-
- SetupTranslator(tr,stress_lengths_sq,stress_amps_sq);
-
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x16 + 0x100;
- SetLetterVowel(tr,'y');
- tr->langopts.numbers = 0x69 + 0x8000;
- tr->langopts.accents = 2; // "capital" after letter name
- }
- break;
-
-
- case L('s','v'): // Swedish
- {
- static const unsigned char stress_amps_sv[] = {16,16, 20,20, 20,22, 22,21 };
- static const short stress_lengths_sv[8] = {160,135, 220,220, 0,0, 250,280};
- SetupTranslator(tr,stress_lengths_sv,stress_amps_sv);
-
- tr->langopts.stress_rule = 0;
- SetLetterVowel(tr,'y');
- tr->langopts.numbers = 0x1909;
- tr->langopts.accents = 1;
- }
- break;
-
- case L('s','w'): // Swahili
- {
- static const short stress_lengths_sw[8] = {160, 170, 200, 200, 0, 0, 320, 340};
- static const unsigned char stress_amps_sw[] = {16,12, 19,19, 20,22, 22,21 };
-
- SetupTranslator(tr,stress_lengths_sw,stress_amps_sw);
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
-
- tr->langopts.vowel_pause = 1;
- tr->langopts.stress_rule = 2;
- tr->langopts.stress_flags = 0x6 | 0x10;
-
- tr->langopts.numbers = 0x4e1;
- tr->langopts.numbers2 = NUM2_100000a;
- }
- break;
-
- case L('t','a'): // Tamil
- case L('m','l'): // Malayalam
- case L('k','n'): // Kannada
- case L('m','r'): // Marathi
- {
- static const short stress_lengths_ta[8] = {200, 200, 210, 210, 0, 0, 230, 230};
- static const unsigned char stress_amps_ta[8] = {18,18, 18,18, 20,20, 22,22 };
-
- SetupTranslator(tr,stress_lengths_ta,stress_amps_ta);
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
-
- tr->langopts.stress_rule = 0;
- tr->langopts.stress_flags = 0x10004; // use 'diminished' for unstressed final syllable
- tr->letter_bits_offset = OFFSET_TAMIL;
-
- if(name2 == L('m','r'))
- {
- tr->letter_bits_offset = OFFSET_DEVANAGARI;
- }
- else
- if(name2 == L('m','l'))
- {
- tr->letter_bits_offset = OFFSET_MALAYALAM;
- }
- else
- if(name2 == L('k','n'))
- {
- tr->letter_bits_offset = OFFSET_KANNADA;
- tr->langopts.numbers = 0x1;
- tr->langopts.numbers2 = NUM2_100000;
- }
- tr->langopts.param[LOPT_WORD_MERGE] = 1; // don't break vowels betwen words
- SetIndicLetters(tr); // call this after setting OFFSET_
- }
- break;
-
-#ifdef deleted
- case L('t','h'): // Thai
- {
- static const short stress_lengths_th[8] = {230,150, 230,230, 230,0, 230,250};
- static const unsigned char stress_amps_th[] = {22,16, 22,22, 22,22, 22,22 };
-
- SetupTranslator(tr,stress_lengths_th,stress_amps_th);
-
- tr->langopts.stress_rule = 0; // stress on final syllable of a "word"
- tr->langopts.stress_flags = 2; // don't automatically set diminished stress (may be set in the intonation module)
- tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
-// tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
- tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
- }
- break;
-#endif
-
- case L('t','r'): // Turkish
- {
- static const unsigned char stress_amps_tr[8] = {18,18, 20,20, 20,22, 22,21 };
- static const short stress_lengths_tr[8] = {190,190, 190,190, 0,0, 250,270};
-
- SetupTranslator(tr,stress_lengths_tr,stress_amps_tr);
- tr->charset_a0 = charsets[9]; // ISO-8859-9 - Latin5
-
- tr->langopts.stress_rule = 7; // stress on the last syllable, before any explicitly unstressed syllable
- tr->langopts.stress_flags = 0x20; //no automatic secondary stress
-
- tr->langopts.numbers = 0x1509 + 0x4000;
- tr->langopts.max_initial_consonants = 2;
- }
- break;
-
- case L('v','i'): // Vietnamese
- {
- static const short stress_lengths_vi[8] = {150, 150, 180, 180, 210, 230, 230, 240};
- static const unsigned char stress_amps_vi[] = {16,16, 16,16, 22,22, 22,22 };
- static wchar_t vowels_vi[] = {
- 0x61, 0xe0, 0xe1, 0x1ea3, 0xe3, 0x1ea1, // a
- 0x103, 0x1eb1, 0x1eaf, 0x1eb3, 0x1eb5, 0x1eb7, // ă
- 0xe2, 0x1ea7, 0x1ea5, 0x1ea9, 0x1eab, 0x1ead, // â
- 0x65, 0xe8, 0xe9, 0x1ebb, 0x1ebd, 0x1eb9, // e
- 0xea, 0x1ec1, 0x1ebf, 0x1ec3, 0x1ec5, 0x1ec7, // i
- 0x69, 0xec, 0xed, 0x1ec9, 0x129, 0x1ecb, // i
- 0x6f, 0xf2, 0xf3, 0x1ecf, 0xf5, 0x1ecd, // o
- 0xf4, 0x1ed3, 0x1ed1, 0x1ed5, 0x1ed7, 0x1ed9, // ô
- 0x1a1, 0x1edd, 0x1edb, 0x1edf, 0x1ee1, 0x1ee3, // Æ¡
- 0x75, 0xf9, 0xfa, 0x1ee7, 0x169, 0x1ee5, // u
- 0x1b0, 0x1eeb, 0x1ee9, 0x1eed, 0x1eef, 0x1ef1, // Æ°
- 0x79, 0x1ef3, 0xfd, 0x1ef7, 0x1ef9, 0x1e, 0 }; // y
-
- SetupTranslator(tr,stress_lengths_vi,stress_amps_vi);
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
-
- tr->langopts.stress_rule = 0;
- tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
-// tr->langopts.vowel_pause = 4;
- tr->letter_groups[0] = vowels_vi;
- tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
- tr->langopts.unstressed_wd1 = 2;
- tr->langopts.numbers = 0x0049 + 0x8000;
-
- }
- break;
-
- case L('z','h'):
- case L_zhy:
- {
- static const short stress_lengths_zh[8] = {230,150, 230,230, 230,0, 240,250}; // 1=tone5. end-of-sentence, 6=tone 1&4, 7=tone 2&3
- static const unsigned char stress_amps_zh[] = {22,16, 22,22, 22,22, 22,22 };
-
- SetupTranslator(tr,stress_lengths_zh,stress_amps_zh);
-
- tr->langopts.stress_rule = 3; // stress on final syllable of a "word"
- tr->langopts.stress_flags = 2; // don't automatically set diminished stress (may be set in the intonation module)
- tr->langopts.vowel_pause = 0;
- tr->langopts.tone_language = 1; // Tone language, use CalcPitches_Tone() rather than CalcPitches()
- tr->langopts.length_mods0 = tr->langopts.length_mods; // don't lengthen vowels in the last syllable
- tr->langopts.tone_numbers = 1; // a number after letters indicates a tone number (eg. pinyin or jyutping)
- tr->langopts.ideographs = 1;
- tr->langopts.word_gap = 0x21; // length of a final vowel is less dependent on the next consonant, don't merge consonant with next word
- if(name2 == L('z','h'))
- {
- tr->langopts.textmode = 1;
- tr->langopts.listx = 1; // compile zh_listx after zh_list
- }
- }
- break;
-
- default:
- tr->langopts.param[LOPT_UNPRONOUNCABLE] = 1; // disable check for unpronouncable words
- break;
- }
-
- tr->translator_name = name2;
-
- if(tr->langopts.numbers & 0x8)
- {
- // use . and ; for thousands and decimal separators
- tr->langopts.thousands_sep = '.';
- tr->langopts.decimal_sep = ',';
- }
- if(tr->langopts.numbers & 0x4)
- {
- tr->langopts.thousands_sep = 0; // don't allow thousands separator, except space
- }
- return(tr);
-} // end of SelectTranslator
-
-
-
-//**********************************************************************************************************
-
-
-
-static void Translator_Russian(Translator *tr)
-{//===========================================
- static const unsigned char stress_amps_ru[] = {16,16, 18,18, 20,24, 24,22 };
- static const short stress_lengths_ru[8] = {150,140, 220,220, 0,0, 260,280};
-
-
- // character codes offset by 0x420
- static const char ru_vowels[] = {0x10,0x15,0x31,0x18,0x1e,0x23,0x2b,0x2d,0x2e,0x2f,0};
- static const char ru_consonants[] = {0x11,0x12,0x13,0x14,0x16,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x26,0x27,0x28,0x29,0x2a,0x2c,0};
- static const char ru_soft[] = {0x2c,0x19,0x27,0x29,0}; // letter group B [k ts; s;]
- static const char ru_hard[] = {0x2a,0x16,0x26,0x28,0}; // letter group H [S Z ts]
- static const char ru_nothard[] = {0x11,0x12,0x13,0x14,0x17,0x19,0x1a,0x1b,0x1c,0x1d,0x1f,0x20,0x21,0x22,0x24,0x25,0x27,0x29,0x2c,0};
- static const char ru_voiced[] = {0x11,0x12,0x13,0x14,0x16,0x17,0}; // letter group G (voiced obstruents)
- static const char ru_ivowels[] = {0x2c,0x15,0x31,0x18,0x2e,0x2f,0}; // letter group Y (iotated vowels & soft-sign)
-
- SetupTranslator(tr,stress_lengths_ru,stress_amps_ru);
-
- tr->charset_a0 = charsets[18]; // KOI8-R
- tr->transpose_offset = 0x42f; // convert cyrillic from unicode into range 0x01 to 0x22
- tr->transpose_min = 0x430;
- tr->transpose_max = 0x451;
-
- tr->letter_bits_offset = OFFSET_CYRILLIC;
- memset(tr->letter_bits,0,sizeof(tr->letter_bits));
- SetLetterBits(tr,0,ru_vowels);
- SetLetterBits(tr,1,ru_soft);
- SetLetterBits(tr,2,ru_consonants);
- SetLetterBits(tr,3,ru_hard);
- SetLetterBits(tr,4,ru_nothard);
- SetLetterBits(tr,5,ru_voiced);
- SetLetterBits(tr,6,ru_ivowels);
- SetLetterBits(tr,7,ru_vowels);
-
- tr->langopts.param[LOPT_UNPRONOUNCABLE] = 0x432; // [v] don't count this character at start of word
- tr->langopts.param[LOPT_REGRESSIVE_VOICING] = 1;
- tr->langopts.param[LOPT_REDUCE] = 2;
- tr->langopts.stress_rule = 5;
- tr->langopts.stress_flags = 0x0020; // waas 0x1010
-
- tr->langopts.numbers = 0x0409;
- tr->langopts.numbers2 = 0xc2; // variant numbers before thousands
- tr->langopts.phoneme_change = 1;
- tr->langopts.testing = 2;
-
-} // end of Translator_Russian
-
-
-
-/*
-typedef struct {
- int flags;
- unsigned char stress; // stress level of this vowel
- unsigned char stress_highest; // the highest stress level of a vowel in this word
- unsigned char n_vowels; // number of vowels in the word
- unsigned char vowel_this; // syllable number of this vowel (counting from 1)
- unsigned char vowel_stressed; // syllable number of the highest stressed vowel
-} CHANGEPH;
-*/
-
-
-#define RUSSIAN2
-#ifdef RUSSIAN2
-
-int ChangePhonemes_ru(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
-{//=============================================================================================================
-// Called for each phoneme in the phoneme list, to allow a language to make changes
-// ph The current phoneme
-
- int variant;
- int vowelix;
- int stressed;
- int soft;
- PHONEME_TAB *prev, *next;
-
- if(ch->flags & 8)
- return(0); // full phoneme translation has already been given
- // Russian vowel softening and reduction rules
-
- if(ph->type == phVOWEL)
- {
- int prestressed = ch->vowel_stressed==ch->vowel_this+1; // the next vowel after this has the main stress
-
- #define N_VOWELS_RU 11
- static unsigned int vowels_ru[N_VOWELS_RU] = {'a','V','O','I',PH('I','#'),PH('E','#'),PH('E','2'),
-PH('V','#'),PH('I','3'),PH('I','2'),PH('E','3')};
-
-
- static unsigned int vowel_replace[N_VOWELS_RU][6] = {
- // stressed, soft, soft-stressed, j+stressed, j+soft, j+soft-stressed
- /*0*/ {'A', 'I', PH('j','a'), 'a', 'a', 'a'}, // a Uses 3,4,5 columns.
- /*1*/ {'A', 'V', PH('j','a'), 'a', 'V', 'a'}, // V Uses 3,4,5 columns.
- /*2*/ {'o', '8', '8', 'o', '8', '8'}, // O
- /*3*/ {'i', 'I', 'i', 'a', 'I', 'a'}, // I Uses 3,4,5 columns.
- /*4*/ {'i', PH('I','#'), 'i', 'i', PH('I','#'), 'i'}, // I#
- /*5*/ {'E', PH('E','#'), 'E', 'e', PH('E','#'), 'e'}, // E#
- /*6*/ {'E', PH('E','2'), 'E', 'e', PH('E','2'), 'e'}, // E2 Uses 3,4,5 columns.
- /*7*/ {PH('j','a'), 'V', PH('j','a'), 'A', 'V', 'A'}, // V#
- /*8*/ {PH('j','a'), 'I', PH('j','a'), 'e', 'I', 'e'}, // I3 Uses 3,4,5 columns.
- /*9*/ {'e', 'I', 'e', 'e', 'I', 'e'}, // I2
- /*10*/ {'e', PH('E', '2'), 'e', 'e', PH('E','2'), 'e'} // E3
- };
-
- prev = phoneme_tab[phlist[index-1].phcode];
- next = phoneme_tab[phlist[index+1].phcode];
-
- // lookup the vowel name to get an index into the vowel_replace[] table
- for(vowelix=0; vowelix<N_VOWELS_RU; vowelix++)
- {
- if(vowels_ru[vowelix] == ph->mnemonic)
- break;
- }
- if(vowelix == N_VOWELS_RU)
- return(0);
-
- if(prestressed)
- {
- if((vowelix==6)&&(prev->mnemonic=='j'))
- vowelix=8;
- if(vowelix==1)
- vowelix=0;
- if(vowelix==4)
- vowelix=3;
- if(vowelix==6)
- vowelix=5;
- if(vowelix==7)
- vowelix=8;
- if(vowelix==10)
- vowelix=9;
- }
- // do we need a variant of this vowel, depending on the stress and adjacent phonemes ?
- variant = -1;
- stressed = ch->flags & 2;
- soft=prev->phflags & phPALATAL;
-
- if (soft && stressed)
- variant = 2; else
- if (stressed)
- variant = 0; else
- if (soft)
- variant = 1;
- if(variant >= 0)
- {
- if(prev->mnemonic == 'j')
- variant += 3;
-
- phlist[index].phcode = PhonemeCode(vowel_replace[vowelix][variant]);
- }
- else
- {
- phlist[index].phcode = PhonemeCode(vowels_ru[vowelix]);
- }
- }
-
- return(0);
-}
-#else
-
-
-int ChangePhonemes_ru(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch)
-{//=============================================================================================================
-// Called for each phoneme in the phoneme list, to allow a language to make changes
-// flags: bit 0=1 last phoneme in a word
-// bit 1=1 this is the highest stressed vowel in the current word
-// bit 2=1 after the highest stressed vowel in the current word
-// bit 3=1 the phonemes were specified explicitly, or found from an entry in the xx_list dictionary
-// ph The current phoneme
-
- int variant;
- int vowelix;
- PHONEME_TAB *prev, *next;
-
- if(ch->flags & 8)
- return(0); // full phoneme translation has already been given
-
- // Russian vowel softening and reduction rules
- if(ph->type == phVOWEL)
- {
- #define N_VOWELS_RU 7
- static unsigned char vowels_ru[N_VOWELS_RU] = {'a','A','o','E','i','u','y'};
-
- // each line gives: soft, reduced, soft-reduced, post-tonic
- static unsigned short vowel_replace[N_VOWELS_RU][4] = {
- {'&', 'V', 'I', 'V'}, // a
- {'&', 'V', 'I', 'V'}, // A
- {'8', 'V', 'I', 'V'}, // o
- {'e', 'I', 'I', 'I'}, // E
- {'i', 'I', 'I', 'I'}, // i
- {'u'+('"'<<8), 'U', 'U', 'U'}, // u
- {'y', 'Y', 'Y', 'Y'}}; // y
-
- prev = phoneme_tab[phlist[index-1].phcode];
- next = phoneme_tab[phlist[index+1].phcode];
-
-if(prev->mnemonic == 'j')
- return(0);
-
- // lookup the vowel name to get an index into the vowel_replace[] table
- for(vowelix=0; vowelix<N_VOWELS_RU; vowelix++)
- {
- if(vowels_ru[vowelix] == ph->mnemonic)
- break;
- }
- if(vowelix == N_VOWELS_RU)
- return(0);
-
- // do we need a variant of this vowel, depending on the stress and adjacent phonemes ?
- variant = -1;
- if(ch->flags & 2)
- {
- // a stressed vowel
- if((prev->phflags & phPALATAL) && ((next->phflags & phPALATAL) || phoneme_tab[phlist[index+2].phcode]->mnemonic == ';'))
- {
- // between two palatal consonants, use the soft variant
- variant = 0;
- }
- }
- else
- {
- // an unstressed vowel
- if(prev->phflags & phPALATAL)
- {
- variant = 2; // unstressed soft
- }
- else
- if((ph->mnemonic == 'o') && ((prev->phflags & phPLACE) == phPLACE_pla))
- {
- variant = 2; // unstressed soft ([o] vowel following: ш ж
- }
- else
- if(ch->flags & 4)
- {
- variant = 3; // post tonic
- }
- else
- {
- variant = 1; // unstressed
- }
- }
- if(variant >= 0)
- {
- phlist[index].phcode = PhonemeCode(vowel_replace[vowelix][variant]);
- }
- }
-
- return(0);
-}
-#endif
-
diff --git a/navit/support/espeak/translate.c b/navit/support/espeak/translate.c
deleted file mode 100755
index 4891644cd..000000000
--- a/navit/support/espeak/translate.c
+++ /dev/null
@@ -1,2800 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <wctype.h>
-#include <wchar.h>
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-#include "translate.h"
-
-#define WORD_STRESS_CHAR '*'
-
-
-Translator *translator = NULL; // the main translator
-Translator *translator2 = NULL; // secondary translator for certain words
-static char translator2_language[20] = {0};
-
-FILE *f_trans = NULL; // phoneme output text
-int option_tone2 = 0;
-int option_tone_flags = 0; // bit 8=emphasize allcaps, bit 9=emphasize penultimate stress
-int option_phonemes = 0;
-int option_phoneme_events = 0;
-int option_quiet = 0;
-int option_endpause = 0; // suppress pause after end of text
-int option_capitals = 0;
-int option_punctuation = 0;
-int option_sayas = 0;
-static int option_sayas2 = 0; // used in translate_clause()
-static int option_emphasis = 0; // 0=normal, 1=normal, 2=weak, 3=moderate, 4=strong
-int option_ssml = 0;
-int option_phoneme_input = 0; // allow [[phonemes]] in input
-int option_phoneme_variants = 0; // 0= don't display phoneme variant mnemonics
-int option_wordgap = 0;
-
-static int count_sayas_digits;
-int skip_sentences;
-int skip_words;
-int skip_characters;
-char skip_marker[N_MARKER_LENGTH];
-int skipping_text; // waiting until word count, sentence count, or named marker is reached
-int end_character_position;
-int count_sentences;
-int count_words;
-int clause_start_char;
-int clause_start_word;
-int new_sentence;
-static int word_emphasis = 0; // set if emphasis level 3 or 4
-static int embedded_flag = 0; // there are embedded commands to be applied to the next phoneme, used in TranslateWord2()
-
-static int prev_clause_pause=0;
-static int max_clause_pause = 0;
-int pre_pause;
-
-
-// these were previously in translator class
-char word_phonemes[N_WORD_PHONEMES]; // a word translated into phoneme codes
-int n_ph_list2;
-PHONEME_LIST2 ph_list2[N_PHONEME_LIST]; // first stage of text->phonemes
-
-
-
-wchar_t option_punctlist[N_PUNCTLIST]={0};
-char ctrl_embedded = '\001'; // to allow an alternative CTRL for embedded commands
-int option_multibyte=espeakCHARS_AUTO; // 0=auto, 1=utf8, 2=8bit, 3=wchar, 4=16bit
-
-// these are overridden by defaults set in the "speak" file
-int option_linelength = 0;
-
-#define N_EMBEDDED_LIST 250
-static int embedded_ix;
-static int embedded_read;
-unsigned int embedded_list[N_EMBEDDED_LIST];
-
-// the source text of a single clause (UTF8 bytes)
-#define N_TR_SOURCE 700
-static char source[N_TR_SOURCE+40]; // extra space for embedded command & voice change info at end
-
-int n_replace_phonemes;
-REPLACE_PHONEMES replace_phonemes[N_REPLACE_PHONEMES];
-
-
-// brackets, also 0x2014 to 0x021f which don't need to be in this list
-static const unsigned short brackets[] = {
-'(',')','[',']','{','}','<','>','"','\'','`',
-0xab,0xbb, // double angle brackets
-0x300a,0x300b, // double angle brackets (ideograph)
-0};
-
-// other characters which break a word, but don't produce a pause
-static const unsigned short breaks[] = {'_', 0};
-
-// treat these characters as spaces, in addition to iswspace()
-static const wchar_t chars_space[] = {0x2500,0}; // box drawing horiz
-
-
-// Translate character codes 0xA0 to 0xFF into their unicode values
-// ISO_8859_1 is set as default
-static const unsigned short ISO_8859_1[0x60] = {
- 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, // a0
- 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, // a8
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, // b0
- 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, // b8
- 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, // c0
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
- 0x00d0, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, // d0
- 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x00de, 0x00df, // d8
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, // e0
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
- 0x00f0, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, // f0
- 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff, // f8
-};
-
-static const unsigned short ISO_8859_2[0x60] = {
- 0x00a0, 0x0104, 0x02d8, 0x0141, 0x00a4, 0x013d, 0x015a, 0x00a7, // a0
- 0x00a8, 0x0160, 0x015e, 0x0164, 0x0179, 0x00ad, 0x017d, 0x017b, // a8
- 0x00b0, 0x0105, 0x02db, 0x0142, 0x00b4, 0x013e, 0x015b, 0x02c7, // b0
- 0x00b8, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c, // b8
- 0x0154, 0x00c1, 0x00c2, 0x0102, 0x00c4, 0x0139, 0x0106, 0x00c7, // c0
- 0x010c, 0x00c9, 0x0118, 0x00cb, 0x011a, 0x00cd, 0x00ce, 0x010e, // c8
- 0x0110, 0x0143, 0x0147, 0x00d3, 0x00d4, 0x0150, 0x00d6, 0x00d7, // d0
- 0x0158, 0x016e, 0x00da, 0x0170, 0x00dc, 0x00dd, 0x0162, 0x00df, // d8
- 0x0155, 0x00e1, 0x00e2, 0x0103, 0x00e4, 0x013a, 0x0107, 0x00e7, // e0
- 0x010d, 0x00e9, 0x0119, 0x00eb, 0x011b, 0x00ed, 0x00ee, 0x010f, // e8
- 0x0111, 0x0144, 0x0148, 0x00f3, 0x00f4, 0x0151, 0x00f6, 0x00f7, // f0
- 0x0159, 0x016f, 0x00fa, 0x0171, 0x00fc, 0x00fd, 0x0163, 0x02d9, // f8
-};
-
-static const unsigned short ISO_8859_3[0x60] = {
- 0x00a0, 0x0126, 0x02d8, 0x00a3, 0x00a4, 0x0000, 0x0124, 0x00a7, // a0
- 0x00a8, 0x0130, 0x015e, 0x011e, 0x0134, 0x00ad, 0x0000, 0x017b, // a8
- 0x00b0, 0x0127, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x0125, 0x00b7, // b0
- 0x00b8, 0x0131, 0x015f, 0x011f, 0x0135, 0x00bd, 0x0000, 0x017c, // b8
- 0x00c0, 0x00c1, 0x00c2, 0x0000, 0x00c4, 0x010a, 0x0108, 0x00c7, // c0
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
- 0x0000, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x0120, 0x00d6, 0x00d7, // d0
- 0x011c, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x016c, 0x015c, 0x00df, // d8
- 0x00e0, 0x00e1, 0x00e2, 0x0000, 0x00e4, 0x010b, 0x0109, 0x00e7, // e0
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
- 0x0000, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x0121, 0x00f6, 0x00f7, // f0
- 0x011d, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x016d, 0x015d, 0x02d9, // f8
-};
-
-static const unsigned short ISO_8859_4[0x60] = {
- 0x00a0, 0x0104, 0x0138, 0x0156, 0x00a4, 0x0128, 0x013b, 0x00a7, // a0
- 0x00a8, 0x0160, 0x0112, 0x0122, 0x0166, 0x00ad, 0x017d, 0x00af, // a8
- 0x00b0, 0x0105, 0x02db, 0x0157, 0x00b4, 0x0129, 0x013c, 0x02c7, // b0
- 0x00b8, 0x0161, 0x0113, 0x0123, 0x0167, 0x014a, 0x017e, 0x014b, // b8
- 0x0100, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x012e, // c0
- 0x010c, 0x00c9, 0x0118, 0x00cb, 0x0116, 0x00cd, 0x00ce, 0x012a, // c8
- 0x0110, 0x0145, 0x014c, 0x0136, 0x00d4, 0x00d5, 0x00d6, 0x00d7, // d0
- 0x00d8, 0x0172, 0x00da, 0x00db, 0x00dc, 0x0168, 0x016a, 0x00df, // d8
- 0x0101, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x012f, // e0
- 0x010d, 0x00e9, 0x0119, 0x00eb, 0x0117, 0x00ed, 0x00ee, 0x012b, // e8
- 0x0111, 0x0146, 0x014d, 0x0137, 0x00f4, 0x00f5, 0x00f6, 0x00f7, // f0
- 0x00f8, 0x0173, 0x00fa, 0x00fb, 0x00fc, 0x0169, 0x016b, 0x02d9, // f8
-};
-
-static const unsigned short ISO_8859_5[0x60] = {
- 0x00a0, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0406, 0x0407, // a0 Cyrillic
- 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x00ad, 0x040e, 0x040f, // a8
- 0x0410, 0x0411, 0x0412, 0x0413, 0x0414, 0x0415, 0x0416, 0x0417, // b0
- 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, 0x041f, // b8
- 0x0420, 0x0421, 0x0422, 0x0423, 0x0424, 0x0425, 0x0426, 0x0427, // c0
- 0x0428, 0x0429, 0x042a, 0x042b, 0x042c, 0x042d, 0x042e, 0x042f, // c8
- 0x0430, 0x0431, 0x0432, 0x0433, 0x0434, 0x0435, 0x0436, 0x0437, // d0
- 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, 0x043f, // d8
- 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445, 0x0446, 0x0447, // e0
- 0x0448, 0x0449, 0x044a, 0x044b, 0x044c, 0x044d, 0x044e, 0x044f, // e8
- 0x2116, 0x0451, 0x0452, 0x0453, 0x0454, 0x0455, 0x0456, 0x0457, // f0
- 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x00a7, 0x045e, 0x045f, // f8
-};
-
-static const unsigned short ISO_8859_7[0x60] = {
- 0x00a0, 0x2018, 0x2019, 0x00a3, 0x20ac, 0x20af, 0x00a6, 0x00a7, // a0 Greek
- 0x00a8, 0x00a9, 0x037a, 0x00ab, 0x00ac, 0x00ad, 0x0000, 0x2015, // a8
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x0384, 0x0385, 0x0386, 0x00b7, // b0
- 0x0388, 0x0389, 0x038a, 0x00bb, 0x038c, 0x00bd, 0x038e, 0x038f, // b8
- 0x0390, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, // c0
- 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, // c8
- 0x03a0, 0x03a1, 0x0000, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, // d0
- 0x03a8, 0x03a9, 0x03aa, 0x03ab, 0x03ac, 0x03ad, 0x03ae, 0x03af, // d8
- 0x03b0, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, // e0
- 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, // e8
- 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, // f0
- 0x03c8, 0x03c9, 0x03ca, 0x03cb, 0x03cc, 0x03cd, 0x03ce, 0x0000, // f8
-};
-
-static const unsigned short ISO_8859_9[0x60] = {
- 0x00a0, 0x00a1, 0x00a2, 0x00a3, 0x00a4, 0x00a5, 0x00a6, 0x00a7, // a0
- 0x00a8, 0x00a9, 0x00aa, 0x00ab, 0x00ac, 0x00ad, 0x00ae, 0x00af, // a8
- 0x00b0, 0x00b1, 0x00b2, 0x00b3, 0x00b4, 0x00b5, 0x00b6, 0x00b7, // b0
- 0x00b8, 0x00b9, 0x00ba, 0x00bb, 0x00bc, 0x00bd, 0x00be, 0x00bf, // b8
- 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, // c0
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
- 0x011e, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x00d7, // d0
- 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x0130, 0x015e, 0x00df, // d8
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, // e0
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
- 0x011f, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x00f7, // f0
- 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x0131, 0x015f, 0x00ff, // f8
-};
-
-static const unsigned short ISO_8859_14[0x60] = {
- 0x00a0, 0x1e02, 0x1e03, 0x00a3, 0x010a, 0x010b, 0x1e0a, 0x00a7, // a0 Welsh
- 0x1e80, 0x00a9, 0x1e82, 0x1e0b, 0x1ef2, 0x00ad, 0x00ae, 0x0178, // a8
- 0x1e1e, 0x1e1f, 0x0120, 0x0121, 0x1e40, 0x1e41, 0x00b6, 0x1e56, // b0
- 0x1e81, 0x1e57, 0x1e83, 0x1e60, 0x1ef3, 0x1e84, 0x1e85, 0x1e61, // b8
- 0x00c0, 0x00c1, 0x00c2, 0x00c3, 0x00c4, 0x00c5, 0x00c6, 0x00c7, // c0
- 0x00c8, 0x00c9, 0x00ca, 0x00cb, 0x00cc, 0x00cd, 0x00ce, 0x00cf, // c8
- 0x0174, 0x00d1, 0x00d2, 0x00d3, 0x00d4, 0x00d5, 0x00d6, 0x1e6a, // d0
- 0x00d8, 0x00d9, 0x00da, 0x00db, 0x00dc, 0x00dd, 0x0176, 0x00df, // d8
- 0x00e0, 0x00e1, 0x00e2, 0x00e3, 0x00e4, 0x00e5, 0x00e6, 0x00e7, // e0
- 0x00e8, 0x00e9, 0x00ea, 0x00eb, 0x00ec, 0x00ed, 0x00ee, 0x00ef, // e8
- 0x0175, 0x00f1, 0x00f2, 0x00f3, 0x00f4, 0x00f5, 0x00f6, 0x1e6b, // f0
- 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x0177, 0x00ff, // f8
-};
-
-static const unsigned short KOI8_R[0x60] = {
- 0x2550, 0x2551, 0x2552, 0x0451, 0x2553, 0x2554, 0x2555, 0x2556, // a0 Russian
- 0x2557, 0x2558, 0x2559, 0x255a, 0x255b, 0x255c, 0x255d, 0x255e, // a8
- 0x255f, 0x2560, 0x2561, 0x0401, 0x2562, 0x2563, 0x2564, 0x2565, // b0
- 0x2566, 0x2567, 0x2568, 0x2569, 0x256a, 0x256b, 0x256c, 0x00a9, // b8
- 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, // c0
- 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, // c8
- 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, // d0
- 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a, // d8
- 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, // e0
- 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, // e8
- 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, // f0
- 0x042c, 0x042b, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a, // f8
-};
-
-static const unsigned short ISCII[0x60] = {
- 0x0020, 0x0901, 0x0902, 0x0903, 0x0905, 0x0906, 0x0907, 0x0908, // a0
- 0x0909, 0x090a, 0x090b, 0x090e, 0x090f, 0x0910, 0x090d, 0x0912, // a8
- 0x0913, 0x0914, 0x0911, 0x0915, 0x0916, 0x0917, 0x0918, 0x0919, // b0
- 0x091a, 0x091b, 0x091c, 0x091d, 0x091e, 0x091f, 0x0920, 0x0921, // b8
- 0x0922, 0x0923, 0x0924, 0x0925, 0x0926, 0x0927, 0x0928, 0x0929, // c0
- 0x092a, 0x092b, 0x092c, 0x092d, 0x092e, 0x092f, 0x095f, 0x0930, // c8
- 0x0931, 0x0932, 0x0933, 0x0934, 0x0935, 0x0936, 0x0937, 0x0938, // d0
- 0x0939, 0x0020, 0x093e, 0x093f, 0x0940, 0x0941, 0x0942, 0x0943, // d8
- 0x0946, 0x0947, 0x0948, 0x0945, 0x094a, 0x094b, 0x094c, 0x0949, // e0
- 0x094d, 0x093c, 0x0964, 0x0020, 0x0020, 0x0020, 0x0020, 0x0020, // e8
- 0x0020, 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, // f0
- 0x0037, 0x0038, 0x0039, 0x20, 0x20, 0x20, 0x20, 0x20, // f8
-};
-
-const unsigned short *charsets[N_CHARSETS] = {
- ISO_8859_1,
- ISO_8859_1,
- ISO_8859_2,
- ISO_8859_3,
- ISO_8859_4,
- ISO_8859_5,
- ISO_8859_1,
- ISO_8859_7,
- ISO_8859_1,
- ISO_8859_9,
- ISO_8859_1,
- ISO_8859_1,
- ISO_8859_1,
- ISO_8859_1,
- ISO_8859_14,
- ISO_8859_1,
- ISO_8859_1,
- ISO_8859_1,
- KOI8_R, // 18
- ISCII };
-
-// Tables of the relative lengths of vowels, depending on the
-// type of the two phonemes that follow
-// indexes are the "length_mod" value for the following phonemes
-
-// use this table if vowel is not the last in the word
-static unsigned char length_mods_en[100] = {
-/* a , t s n d z r N <- next */
- 100,120,100,105,100,110,110,100, 95, 100, /* a <- next2 */
- 105,120,105,110,125,130,135,115,125, 100, /* , */
- 105,120, 75,100, 75,105,120, 85, 75, 100, /* t */
- 105,120, 85,105, 95,115,120,100, 95, 100, /* s */
- 110,120, 95,105,100,115,120,100,100, 100, /* n */
- 105,120,100,105, 95,115,120,110, 95, 100, /* d */
- 105,120,100,105,105,122,125,110,105, 100, /* z */
- 105,120,100,105,105,122,125,110,105, 100, /* r */
- 105,120, 95,105,100,115,120,110,100, 100, /* N */
- 100,120,100,100,100,100,100,100,100, 100 }; // SPARE
-
-// as above, but for the last syllable in a word
-static unsigned char length_mods_en0[100] = {
-/* a , t s n d z r N <- next */
- 100,150,100,105,110,115,110,110,110, 100, /* a <- next2 */
- 105,150,105,110,125,135,140,115,135, 100, /* , */
- 105,150, 90,105, 90,122,135,100, 90, 100, /* t */
- 105,150,100,105,100,122,135,100,100, 100, /* s */
- 105,150,100,105,105,115,135,110,105, 100, /* n */
- 105,150,100,105,105,122,130,120,125, 100, /* d */
- 105,150,100,105,110,122,125,115,110, 100, /* z */
- 105,150,100,105,105,122,135,120,105, 100, /* r */
- 105,150,100,105,105,115,135,110,105, 100, /* N */
- 100,100,100,100,100,100,100,100,100, 100 }; // SPARE
-
-
-static unsigned char length_mods_equal[100] = {
-/* a , t s n d z r N <- next */
- 110,110,110,110,110,110,110,110,110, 110, /* a <- next2 */
- 110,110,110,110,110,110,110,110,110, 110, /* , */
- 110,110,110,110,110,110,110,110,110, 110, /* t */
- 110,110,110,110,110,110,110,110,110, 110, /* s */
- 110,110,110,110,110,110,110,110,110, 110, /* n */
- 110,110,110,110,110,110,110,110,110, 110, /* d */
- 110,110,110,110,110,110,110,110,110, 110, /* z */
- 110,110,110,110,110,110,110,110,110, 110, /* r */
- 110,110,110,110,110,110,110,110,110, 110, /* N */
- 110,110,110,110,110,110,110,110,110, 110 }; // SPARE
-
-
-static unsigned char *length_mod_tabs[6] = {
- length_mods_en,
- length_mods_en, // 1
- length_mods_en0, // 2
- length_mods_equal, // 3
- length_mods_equal, // 4
- length_mods_equal // 5
- };
-
-
-void SetLengthMods(Translator *tr, int value)
-{//==========================================
- int value2;
-
- tr->langopts.length_mods0 = tr->langopts.length_mods = length_mod_tabs[value % 100];
- if((value2 = value / 100) != 0)
- {
- tr->langopts.length_mods0 = length_mod_tabs[value2];
- }
-}
-
-
-int IsAlpha(unsigned int c)
-{//========================
-// Replacement for iswalph() which also checks for some in-word symbols
-
- if(iswalpha(c))
- return(1);
-
- if((c >= 0x901) && (c <= 0xdf7))
- {
- // Indic scripts: Devanagari, Tamil, etc
- if((c & 0x7f) < 0x64)
- return(1);
- return(0);
- }
-
- if((c >= 0x300) && (c <= 0x36f))
- return(1); // combining accents
-
- if((c >= 0x1100) && (c <= 0x11ff))
- return(1); //Korean jamo
-
- if((c > 0x3040) && (c <= 0xa700))
- return(1); // Chinese/Japanese. Should never get here, but Mac OS 10.4's iswalpha seems to be broken, so just make sure
-
- return(0);
-}
-
-static int IsDigit09(unsigned int c)
-{//=========================
- if((c >= '0') && (c <= '9'))
- return(1);
- return(0);
-}
-
-int IsDigit(unsigned int c)
-{//========================
- if(iswdigit(c))
- return(1);
-
- if((c >= 0x966) && (c <= 0x96f))
- return(1);
-
- return(0);
-}
-
-int IsSpace(unsigned int c)
-{//========================
- if(c == 0)
- return(0);
- if(wcschr(chars_space,c))
- return(1);
- return(iswspace(c));
-}
-
-
-void DeleteTranslator(Translator *tr)
-{//==================================
- if(tr->data_dictlist != NULL)
- Free(tr->data_dictlist);
- Free(tr);
-}
-
-
-int lookupwchar(const unsigned short *list,int c)
-{//==============================================
-// Is the character c in the list ?
- int ix;
-
- for(ix=0; list[ix] != 0; ix++)
- {
- if(list[ix] == c)
- return(ix+1);
- }
- return(0);
-}
-
-int IsBracket(int c)
-{//=================
- if((c >= 0x2014) && (c <= 0x201f))
- return(1);
- return(lookupwchar(brackets,c));
-}
-
-
-int utf8_out(unsigned int c, char *buf)
-{//====================================
-// write a unicode character into a buffer as utf8
-// returns the number of bytes written
- int n_bytes;
- int j;
- int shift;
- static char unsigned code[4] = {0,0xc0,0xe0,0xf0};
-
- if(c < 0x80)
- {
- buf[0] = c;
- return(1);
- }
- if(c >= 0x110000)
- {
- buf[0] = ' '; // out of range character code
- return(1);
- }
- if(c < 0x0800)
- n_bytes = 1;
- else
- if(c < 0x10000)
- n_bytes = 2;
- else
- n_bytes = 3;
-
- shift = 6*n_bytes;
- buf[0] = code[n_bytes] | (c >> shift);
- for(j=0; j<n_bytes; j++)
- {
- shift -= 6;
- buf[j+1] = 0x80 + ((c >> shift) & 0x3f);
- }
- return(n_bytes+1);
-} // end of utf8_out
-
-
-int utf8_nbytes(const char *buf)
-{//=============================
-// Returns the number of bytes for the first UTF-8 character in buf
- unsigned char c = (unsigned char)buf[0];
- if(c < 0x80)
- return(1);
- if(c < 0xe0)
- return(2);
- if(c < 0xf0)
- return(3);
- return(4);
-}
-
-
-int utf8_in2(int *c, const char *buf, int backwards)
-{//=================================================
-// Read a unicode characater from a UTF8 string
-// Returns the number of UTF8 bytes used.
-// backwards: set if we are moving backwards through the UTF8 string
- int c1;
- int n_bytes;
- int ix;
- static const unsigned char mask[4] = {0xff,0x1f,0x0f,0x07};
-
- // find the start of the next/previous character
- while((*buf & 0xc0) == 0x80)
- {
- // skip over non-initial bytes of a multi-byte utf8 character
- if(backwards)
- buf--;
- else
- buf++;
- }
-
- n_bytes = 0;
-
- if((c1 = *buf++) & 0x80)
- {
- if((c1 & 0xe0) == 0xc0)
- n_bytes = 1;
- else
- if((c1 & 0xf0) == 0xe0)
- n_bytes = 2;
- else
- if((c1 & 0xf8) == 0xf0)
- n_bytes = 3;
-
- c1 &= mask[n_bytes];
- for(ix=0; ix<n_bytes; ix++)
- {
- c1 = (c1 << 6) + (*buf++ & 0x3f);
- }
- }
- *c = c1;
- return(n_bytes+1);
-}
-
-
-int utf8_in(int *c, const char *buf)
-{//=================================
-// Read a unicode characater from a UTF8 string
-// Returns the number of UTF8 bytes used.
- return(utf8_in2(c,buf,0));
-}
-
-
-char *strchr_w(const char *s, int c)
-{//=================================
-// return NULL for any non-ascii character
- if(c >= 0x80)
- return(NULL);
- return(strchr((char *)s,c)); // (char *) is needed for Borland compiler
-}
-
-
-
-
-int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab)
-{//===========================================================================
-// word1 is terminated by space (0x20) character
-
- int length;
- int word_length;
- int ix;
- int posn;
- int pfix;
- int n_chars;
- unsigned int dictionary_flags[2];
- unsigned int dictionary_flags2[2];
- int end_type=0;
- int prefix_type=0;
- char *wordx;
- char phonemes[N_WORD_PHONEMES];
- char *ph_limit;
- char *phonemes_ptr;
- char prefix_phonemes[N_WORD_PHONEMES];
- char end_phonemes[N_WORD_PHONEMES];
- char word_copy[N_WORD_BYTES];
- char prefix_chars[N_WORD_BYTES];
- int found=0;
- int end_flags;
- char c_temp; // save a character byte while we temporarily replace it with space
- int first_char;
- int last_char = 0;
- int unpron_length;
- int add_plural_suffix = 0;
- int prefix_flags = 0;
- int confirm_prefix;
- int spell_word;
- int stress_bits;
- int emphasize_allcaps = 0;
- int wflags = wtab->flags;
- int wmark = wtab->wmark;
-
- // translate these to get pronunciations of plural 's' suffix (different forms depending on
- // the preceding letter
- static char word_zz[4] = {0,'z','z',0};
- static char word_iz[4] = {0,'i','z',0};
- static char word_ss[4] = {0,'s','s',0};
-
- dictionary_flags[0] = 0;
- dictionary_flags[1] = 0;
- dictionary_flags2[0] = 0;
- dictionary_flags2[1] = 0;
- dictionary_skipwords = 0;
-
- prefix_phonemes[0] = 0;
- end_phonemes[0] = 0;
- ph_limit = &phonemes[N_WORD_PHONEMES];
-
- // count the length of the word
- wordx = word1;
- utf8_in(&first_char,wordx);
- word_length = 0;
- while((*wordx != 0) && (*wordx != ' '))
- {
- wordx += utf8_in(&last_char,wordx);
- word_length++;
- }
-
- // try an initial lookup in the dictionary list, we may find a pronunciation specified, or
- // we may just find some flags
- spell_word = 0;
- if(option_sayas == SAYAS_KEY)
- {
- if(word_length == 1)
- spell_word = 4;
- }
-
- if(option_sayas & 0x10)
- {
- // SAYAS_CHAR, SAYAS_GYLPH, or SAYAS_SINGLE_CHAR
- spell_word = option_sayas & 0xf; // 2,3,4
- }
- else
- {
- found = LookupDictList(tr, &word1, phonemes, dictionary_flags, FLAG_ALLOW_TEXTMODE, wtab); // the original word
- if(dictionary_flags[0] & FLAG_TEXTMODE)
- {
- first_char = word1[0];
- stress_bits = dictionary_flags[0] & 0x7f;
- found = LookupDictList(tr, &word1, phonemes, dictionary_flags2, 0, wtab); // the text replacement
- if(dictionary_flags2[0]!=0)
- {
- dictionary_flags[0] = dictionary_flags2[0];
- dictionary_flags[1] = dictionary_flags2[1];
- if(stress_bits != 0)
- {
- // keep any stress information from the original word
- dictionary_flags[0] = (dictionary_flags[0] & ~0x7f) | stress_bits;
- }
- }
- }
- else
- if((found==0) && (dictionary_flags[0] & FLAG_SKIPWORDS))
- {
- // grouped words, but no translation. Join the words with hyphens.
- wordx = word1;
- ix = 0;
- while(ix < dictionary_skipwords)
- {
- if(*wordx == ' ')
- {
- *wordx = '-';
- ix++;
- }
- wordx++;
- }
- }
-
- // if textmode, LookupDictList() replaces word1 by the new text and returns found=0
-
- if(phonemes[0] == phonSWITCH)
- {
- // change to another language in order to translate this word
- strcpy(word_phonemes,phonemes);
- return(0);
- }
-
-if((wmark > 0) && (wmark < 8))
-{
- // the stressed syllable has been specified in the text (TESTING)
- dictionary_flags[0] = (dictionary_flags[0] & ~0xf) | wmark;
-}
-
- if(!found && (dictionary_flags[0] & FLAG_ABBREV))
- {
- // the word has $abbrev flag, but no pronunciation specified. Speak as individual letters
- spell_word = 1;
- }
-
- if(!found && iswdigit(first_char))
- {
- Lookup(tr,"_0lang",word_phonemes);
- if(word_phonemes[0] == phonSWITCH)
- return(0);
-
- found = TranslateNumber(tr,word1,phonemes,dictionary_flags,wflags);
- }
-
- if(!found & ((wflags & FLAG_UPPERS) != FLAG_FIRST_UPPER))
- {
- // either all upper or all lower case
-
- if((tr->langopts.numbers & NUM_ROMAN) || ((tr->langopts.numbers & NUM_ROMAN_UC) && (wflags & FLAG_ALL_UPPER)))
- {
- if((found = TranslateRoman(tr, word1, phonemes)) != 0)
- dictionary_flags[0] |= FLAG_ABBREV; // prevent emphasis if capitals
- }
- }
-
- if((wflags & FLAG_ALL_UPPER) && (word_length > 1)&& iswalpha(first_char))
- {
- if((option_tone_flags & OPTION_EMPHASIZE_ALLCAPS) && !(dictionary_flags[0] & FLAG_ABBREV))
- {
- // emphasize words which are in capitals
- emphasize_allcaps = FLAG_EMPHASIZED;
- }
- else
- if(!found && !(dictionary_flags[0] & FLAG_SKIPWORDS) && (word_length<4) && (tr->clause_lower_count > 3)
- && (tr->clause_upper_count <= tr->clause_lower_count))
- {
- // An upper case word in a lower case clause. This could be an abbreviation.
- spell_word = 1;
- }
- }
- }
-
- if(spell_word > 0)
- {
- // Speak as individual letters
- wordx = word1;
- posn = 0;
- phonemes[0] = 0;
- end_type = 0;
-
- while(*wordx != ' ')
- {
- wordx += TranslateLetter(tr,wordx, phonemes,spell_word, word_length);
- posn++;
- if(phonemes[0] == phonSWITCH)
- {
- // change to another language in order to translate this word
- strcpy(word_phonemes,phonemes);
- if(word_length > 1)
- return(FLAG_SPELLWORD); // a mixture of languages, retranslate as individual letters, separated by spaces
- return(0);
- }
- }
- SetSpellingStress(tr,phonemes,spell_word,posn);
- }
- else
- if(found == 0)
- {
- // word's pronunciation is not given in the dictionary list, although
- // dictionary_flags may have ben set there
-
- posn = 0;
- length = 999;
- wordx = word1;
-
- while(((length < 3) && (length > 0))|| (word_length > 1 && Unpronouncable(tr,wordx)))
- {
- char *p;
- // This word looks "unpronouncable", so speak letters individually until we
- // find a remainder that we can pronounce.
- emphasize_allcaps = 0;
- wordx += TranslateLetter(tr,wordx,phonemes,0, word_length);
- posn++;
- if(phonemes[0] == phonSWITCH)
- {
- // change to another language in order to translate this word
- strcpy(word_phonemes,phonemes);
- if(strcmp(&phonemes[1],"en")==0)
- return(FLAG_SPELLWORD); // _^_en must have been set in TranslateLetter(), not *_rules
- return(0);
- }
-
- p = &wordx[word_length-3]; // this looks wrong. Doesn't consider multi-byte chars.
- if(memcmp(p,"'s ",3) == 0)
- {
- // remove a 's suffix and pronounce this separately (not as an individual letter)
- add_plural_suffix = 1;
- p[0] = ' ';
- p[1] = ' ';
- last_char = p[-1];
- }
-
- length=0;
- while(wordx[length] != ' ') length++;
- if(length > 0)
- wordx[-1] = ' '; // prevent this affecting the pronunciation of the pronuncable part
- }
- SetSpellingStress(tr,phonemes,0,posn);
-
- // anything left ?
- if(*wordx != ' ')
- {
- // Translate the stem
- unpron_length = strlen(phonemes);
- end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, wflags, dictionary_flags);
-
- if(phonemes[0] == phonSWITCH)
- {
- // change to another language in order to translate this word
- strcpy(word_phonemes,phonemes);
- return(0);
- }
-
- if((phonemes[0] == 0) && (end_phonemes[0] == 0))
- {
- int wc;
- // characters not recognised, speak them individually
-
- utf8_in(&wc, wordx);
- if((word_length == 1) && IsAlpha(wc))
- {
- posn = 0;
- while((*wordx != ' ') && (*wordx != 0))
- {
- wordx += TranslateLetter(tr,wordx, phonemes, 4, word_length);
- posn++;
- if(phonemes[0] == phonSWITCH)
- {
- // change to another language in order to translate this word
- strcpy(word_phonemes,phonemes);
- return(0);
- }
- }
- SetSpellingStress(tr,phonemes,spell_word,posn);
- }
- }
-
- c_temp = wordx[-1];
-
- found = 0;
- confirm_prefix = 1;
- while(end_type & SUFX_P)
- {
- // Found a standard prefix, remove it and retranslate
-
- if(confirm_prefix && !(end_type & SUFX_B))
- {
- int end2;
- char phonemes2[N_WORD_PHONEMES];
- char end_phonemes2[N_WORD_PHONEMES];
-
- // remove any standard suffix and confirm that the prefix is still recognised
- phonemes2[0] = 0;
- end2 = TranslateRules(tr, wordx, phonemes2, N_WORD_PHONEMES, end_phonemes2, wflags|FLAG_NO_PREFIX|FLAG_NO_TRACE, dictionary_flags);
- if(end2)
- {
- RemoveEnding(tr, wordx, end2, word_copy);
- end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, wflags|FLAG_NO_TRACE, dictionary_flags);
- memcpy(wordx,word_copy,strlen(word_copy));
- if((end_type & SUFX_P) == 0)
- {
- // after removing the suffix, the prefix is no longer recognised.
- // Keep the suffix, but don't use the prefix
- end_type = end2;
- strcpy(phonemes,phonemes2);
- strcpy(end_phonemes,end_phonemes2);
- if(option_phonemes == 2)
- {
- DecodePhonemes(end_phonemes,end_phonemes2);
- fprintf(f_trans," suffix [%s]\n\n",end_phonemes2);
- }
- }
- confirm_prefix = 0;
- continue;
- }
- }
-
- prefix_type = end_type;
-
- if(prefix_type & SUFX_V)
- {
- tr->expect_verb = 1; // use the verb form of the word
- }
-
- wordx[-1] = c_temp;
-
- if((prefix_type & SUFX_B) == 0)
- {
- for(ix=(prefix_type & 0xf); ix>0; ix--) // num. of characters to remove
- {
- wordx++;
- while((*wordx & 0xc0) == 0x80) wordx++; // for multibyte characters
- }
- }
- else
- {
- pfix = 1;
- prefix_chars[0] = 0;
- n_chars = prefix_type & 0x3f;
-
- for(ix=0; ix < n_chars; ix++) // num. of bytes to remove
- {
- prefix_chars[pfix++] = *wordx++;
-
- if((prefix_type & SUFX_B) && (ix == (n_chars-1)))
- {
- prefix_chars[pfix-1] = 0; // discard the last character of the prefix, this is the separator character
- }
- }
- prefix_chars[pfix] = 0;
- }
- c_temp = wordx[-1];
- wordx[-1] = ' ';
- confirm_prefix = 1;
-
- if(prefix_type & SUFX_B)
- {
-// SUFX_B is used for Turkish, tr_rules contains "(Pb£
- // retranslate the prefix part
- char *wordpf;
- char prefix_phonemes2[12];
-
- strncpy0(prefix_phonemes2,end_phonemes,sizeof(prefix_phonemes2));
- wordpf = &prefix_chars[1];
- found = LookupDictList(tr, &wordpf, phonemes, dictionary_flags, SUFX_P, wtab); // without prefix
- if(found == 0)
- {
- end_type = TranslateRules(tr, wordpf, phonemes, N_WORD_PHONEMES, end_phonemes, 0, dictionary_flags);
- sprintf(prefix_phonemes,"%s%s%s",phonemes,end_phonemes,prefix_phonemes2);
- }
- prefix_flags = 1;
- }
- else
- {
- strcat(prefix_phonemes,end_phonemes);
- }
- end_phonemes[0] = 0;
-
- end_type = 0;
- found = LookupDictList(tr, &wordx, phonemes, dictionary_flags2, SUFX_P, wtab); // without prefix
- if(dictionary_flags[0]==0)
- {
- dictionary_flags[0] = dictionary_flags2[0];
- dictionary_flags[1] = dictionary_flags2[1];
- }
- else
- prefix_flags = 1;
- if(found == 0)
- {
- end_type = TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, end_phonemes, 0, dictionary_flags);
-
- if(phonemes[0] == phonSWITCH)
- {
- // change to another language in order to translate this word
- wordx[-1] = c_temp;
- strcpy(word_phonemes,phonemes);
- return(0);
- }
- }
- }
-
- if((end_type != 0) && !(end_type & SUFX_P))
- {
-char phonemes2[N_WORD_PHONEMES];
-strcpy(phonemes2,phonemes);
-
- // The word has a standard ending, re-translate without this ending
- end_flags = RemoveEnding(tr, wordx, end_type, word_copy);
-
- phonemes_ptr = &phonemes[unpron_length];
- phonemes_ptr[0] = 0;
-
- if(prefix_phonemes[0] != 0)
- {
- // lookup the stem without the prefix removed
- wordx[-1] = c_temp;
- found = LookupDictList(tr, &word1, phonemes_ptr, dictionary_flags2, end_flags, wtab); // include prefix, but not suffix
- wordx[-1] = ' ';
- if(dictionary_flags[0]==0)
- {
- dictionary_flags[0] = dictionary_flags2[0];
- dictionary_flags[1] = dictionary_flags2[1];
- }
- if(found)
- prefix_phonemes[0] = 0; // matched whole word, don't need prefix now
-
- if((found==0) && (dictionary_flags2[0] != 0))
- prefix_flags = 1;
- }
- if(found == 0)
- {
- found = LookupDictList(tr, &wordx, phonemes_ptr, dictionary_flags2, end_flags, wtab); // without prefix and suffix
- if(phonemes_ptr[0] == phonSWITCH)
- {
- // change to another language in order to translate this word
- memcpy(wordx,word_copy,strlen(word_copy));
- strcpy(word_phonemes,phonemes_ptr);
- return(0);
- }
- if(dictionary_flags[0]==0)
- {
- dictionary_flags[0] = dictionary_flags2[0];
- dictionary_flags[1] = dictionary_flags2[1];
- }
- }
- if(found == 0)
- {
- if(end_type & SUFX_Q)
- {
- // don't retranslate, use the original lookup result
- strcpy(phonemes,phonemes2);
-
- // language specific changes
- ApplySpecialAttribute(tr,phonemes,dictionary_flags[0]);
- }
- else
- {
- if(end_flags & FLAG_SUFX)
- TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, NULL,wflags | FLAG_SUFFIX_REMOVED, dictionary_flags);
- else
- TranslateRules(tr, wordx, phonemes, N_WORD_PHONEMES, NULL,wflags,dictionary_flags);
-
- if(phonemes[0] == phonSWITCH)
- {
- // change to another language in order to translate this word
- strcpy(word_phonemes,phonemes);
- memcpy(wordx,word_copy,strlen(word_copy));
- wordx[-1] = c_temp;
- return(0);
- }
- }
- }
-
- if((end_type & SUFX_T) == 0)
- {
- // the default is to add the suffix and then determine the word's stress pattern
- AppendPhonemes(tr,phonemes, N_WORD_PHONEMES, end_phonemes);
- end_phonemes[0] = 0;
- }
- }
- wordx[-1] = c_temp;
- }
- }
-
- if((add_plural_suffix) || (wflags & FLAG_HAS_PLURAL))
- {
- // s or 's suffix, append [s], [z] or [Iz] depending on previous letter
- if(last_char == 'f')
- TranslateRules(tr, &word_ss[1], phonemes, N_WORD_PHONEMES, NULL, 0, NULL);
- else
- if((last_char==0) || (strchr_w("hsx",last_char)==NULL))
- TranslateRules(tr, &word_zz[1], phonemes, N_WORD_PHONEMES, NULL, 0, NULL);
- else
- TranslateRules(tr, &word_iz[1], phonemes, N_WORD_PHONEMES, NULL, 0, NULL);
- }
-
- wflags |= emphasize_allcaps;
-
-
- /* determine stress pattern for this word */
- /******************************************/
- /* NOTE: this also adds a single PAUSE if the previous word ended
- in a primary stress, and this one starts with one */
- if(prefix_flags || (strchr(prefix_phonemes,phonSTRESS_P)!=NULL))
- {
- if((tr->langopts.param[LOPT_PREFIXES]) || (prefix_type & SUFX_T))
- {
- char *p;
- // German, keep a secondary stress on the stem
- SetWordStress(tr, phonemes, &dictionary_flags[0], 3, 0);
-
- // reduce all but the first primary stress
- ix=0;
- for(p=prefix_phonemes; *p != 0; p++)
- {
- if(*p == phonSTRESS_P)
- {
- if(ix==0)
- ix=1;
- else
- *p = phonSTRESS_3;
- }
- }
- strcpy(word_phonemes,prefix_phonemes);
- strcat(word_phonemes,phonemes);
- SetWordStress(tr, word_phonemes, &dictionary_flags[0], -1, 0);
- }
- else
- {
- // stress position affects the whole word, including prefix
- strcpy(word_phonemes,prefix_phonemes);
- strcat(word_phonemes,phonemes);
- SetWordStress(tr, word_phonemes, &dictionary_flags[0], -1, tr->prev_last_stress);
- }
- }
- else
- {
- if(prefix_phonemes[0] == 0)
- SetWordStress(tr, phonemes, &dictionary_flags[0], -1, tr->prev_last_stress);
- else
- SetWordStress(tr, phonemes, &dictionary_flags[0], -1, 0);
- strcpy(word_phonemes,prefix_phonemes);
- strcat(word_phonemes,phonemes);
- }
-
- if(end_phonemes[0] != 0)
- {
- // a suffix had the SUFX_T option set, add the suffix after the stress pattern has been determined
- strcat(word_phonemes,end_phonemes);
- }
-
- if(wflags & FLAG_LAST_WORD)
- {
- // don't use $brk pause before the last word of a sentence
- // (but allow it for emphasis, see below
- dictionary_flags[0] &= ~FLAG_PAUSE1;
- }
-
- if(wflags & FLAG_EMPHASIZED2)
- {
- // A word is indicated in the source text as stressed
- // Give it stress level 6 (for the intonation module)
- ChangeWordStress(tr,word_phonemes,6);
-
- if(wflags & FLAG_EMPHASIZED)
- dictionary_flags[0] |= FLAG_PAUSE1; // precede by short pause
- }
- else
- if(wtab[dictionary_skipwords].flags & FLAG_LAST_WORD)
- {
- // the word has attribute to stress or unstress when at end of clause
- if(dictionary_flags[0] & (FLAG_STRESS_END | FLAG_STRESS_END2))
- ChangeWordStress(tr,word_phonemes,4);
- else
- if(dictionary_flags[0] & FLAG_UNSTRESS_END)
- ChangeWordStress(tr,word_phonemes,3);
- }
-
- // dictionary flags for this word give a clue about which alternative pronunciations of
- // following words to use.
- if(end_type & SUFX_F)
- {
- // expect a verb form, with or without -s suffix
- tr->expect_verb = 2;
- tr->expect_verb_s = 2;
- }
-
- if(dictionary_flags[1] & FLAG_PASTF)
- {
- /* expect perfect tense in next two words */
- tr->expect_past = 3;
- tr->expect_verb = 0;
- tr->expect_noun = 0;
- }
- else
- if(dictionary_flags[1] & FLAG_VERBF)
- {
- /* expect a verb in the next word */
- tr->expect_verb = 2;
- tr->expect_verb_s = 0; /* verb won't have -s suffix */
- tr->expect_noun = 0;
- }
- else
- if(dictionary_flags[1] & FLAG_VERBSF)
- {
- // expect a verb, must have a -s suffix
- tr->expect_verb = 0;
- tr->expect_verb_s = 2;
- tr->expect_past = 0;
- tr->expect_noun = 0;
- }
- else
- if(dictionary_flags[1] & FLAG_NOUNF)
- {
- /* not expecting a verb next */
- tr->expect_noun = 2;
- tr->expect_verb = 0;
- tr->expect_verb_s = 0;
- tr->expect_past = 0;
- }
-
- if((wordx[0] != 0) && (!(dictionary_flags[1] & FLAG_VERB_EXT)))
- {
- if(tr->expect_verb > 0)
- tr->expect_verb--;
-
- if(tr->expect_verb_s > 0)
- tr->expect_verb_s--;
-
- if(tr->expect_noun >0)
- tr->expect_noun--;
-
- if(tr->expect_past > 0)
- tr->expect_past--;
- }
-
- if((word_length == 1) && iswalpha(first_char) && (first_char != 'i'))
- {
-// English Specific !!!!
- // any single letter before a dot is an abbreviation, except 'I'
- dictionary_flags[0] |= FLAG_DOT;
- }
-
- if((tr->langopts.param[LOPT_ALT] & 2) && ((dictionary_flags[0] & (FLAG_ALT_TRANS | FLAG_ALT2_TRANS)) != 0))
- {
- ApplySpecialAttribute2(tr,word_phonemes,dictionary_flags[0]);
- }
-
- return(dictionary_flags[0]);
-} // end of TranslateWord
-
-
-
-static void SetPlist2(PHONEME_LIST2 *p, unsigned char phcode)
-{//==========================================================
- p->phcode = phcode;
- p->stress = 0;
- p->tone_number = 0;
- p->synthflags = embedded_flag;
- p->sourceix = 0;
- embedded_flag = 0;
-}
-
-static int CountSyllables(unsigned char *phonemes)
-{//===============================================
- int count = 0;
- int phon;
- while((phon = *phonemes++) != 0)
- {
- if(phoneme_tab[phon]->type == phVOWEL)
- count++;
- }
- return(count);
-}
-
-
-int SetTranslator2(const char *new_language)
-{//=========================================
-// Set translator2 to a second language
- int new_phoneme_tab;
-
- if((new_phoneme_tab = SelectPhonemeTableName(new_language)) >= 0)
- {
- if((translator2 != NULL) && (strcmp(new_language,translator2_language) != 0))
- {
- // we already have an alternative translator, but not for the required language, delete it
- DeleteTranslator(translator2);
- translator2 = NULL;
- }
-
- if(translator2 == NULL)
- {
- translator2 = SelectTranslator(new_language);
- strcpy(translator2_language,new_language);
-
- if(LoadDictionary(translator2, new_language, 0) != 0)
- {
- SelectPhonemeTable(voice->phoneme_tab_ix); // revert to original phoneme table
- new_phoneme_tab = -1;
- translator2_language[0] = 0;
- }
- }
- }
- return(new_phoneme_tab);
-} // end of SetTranslator2
-
-
-
-static int TranslateWord2(Translator *tr, char *word, WORD_TAB *wtab, int pre_pause, int next_pause)
-{//=================================================================================================
- int flags=0;
- int stress;
- int next_stress;
- int next_tone=0;
- unsigned char *p;
- int srcix;
- int embedded_cmd;
- int value;
- int found_dict_flag;
- unsigned char ph_code;
- PHONEME_LIST2 *plist2;
- PHONEME_TAB *ph;
- int max_stress;
- int max_stress_ix=0;
- int prev_vowel = -1;
- int pitch_raised = 0;
- int switch_phonemes = -1;
- int first_phoneme = 1;
- int source_ix;
- int len;
- int ix;
- int sylimit; // max. number of syllables in a word to be combined with a preceding preposition
- const char *new_language;
- unsigned char bad_phoneme[4];
- int word_flags;
- int word_copy_len;
- char word_copy[N_WORD_BYTES+1];
-
- len = wtab->length;
- if(len > 31) len = 31;
- source_ix = (wtab->sourceix & 0x7ff) | (len << 11); // bits 0-10 sourceix, bits 11-15 word length
-
- word_flags = wtab[0].flags;
- if(word_flags & FLAG_EMBEDDED)
- {
- embedded_flag = SFLAG_EMBEDDED;
-
- do
- {
- embedded_cmd = embedded_list[embedded_read++];
- value = embedded_cmd >> 8;
-
- switch(embedded_cmd & 0x1f)
- {
- case EMBED_Y:
- option_sayas = value;
- break;
-
- case EMBED_F:
- option_emphasis = value;
- break;
-
- case EMBED_B:
- // break command
- if(value == 0)
- pre_pause = 0; // break=none
- else
- pre_pause += value;
- break;
- }
- } while((embedded_cmd & 0x80) == 0);
- }
-
- if(word[0] == 0)
- {
- // nothing to translate
- word_phonemes[0] = 0;
- return(0);
- }
-
- // after a $pause word attribute, ignore a $pause attribute on the next two words
- if(tr->prepause_timeout > 0)
- tr->prepause_timeout--;
-
- if((option_sayas & 0xf0) == 0x10)
- {
- if(!(word_flags & FLAG_FIRST_WORD))
- {
- // SAYAS_CHARS, SAYAS_GLYPHS, or SAYAS_SINGLECHARS. Pause between each word.
- pre_pause += 4;
- }
- }
-
- if(word_flags & FLAG_FIRST_UPPER)
- {
- if((option_capitals > 2) && (embedded_ix < N_EMBEDDED_LIST-6))
- {
- // indicate capital letter by raising pitch
- if(embedded_flag)
- embedded_list[embedded_ix-1] &= ~0x80; // already embedded command before this word, remove terminator
- if((pitch_raised = option_capitals) == 3)
- pitch_raised = 20; // default pitch raise for capitals
- embedded_list[embedded_ix++] = EMBED_P+0x40+0x80 + (pitch_raised << 8); // raise pitch
- embedded_flag = SFLAG_EMBEDDED;
- }
- }
-
- p = (unsigned char *)word_phonemes;
- if(word_flags & FLAG_PHONEMES)
- {
- // The input is in phoneme mnemonics, not language text
- int c1;
- char lang_name[12];
-
- if(memcmp(word,"_^_",3)==0)
- {
- // switch languages
- word+=3;
- for(ix=0;;)
- {
- c1 = *word++;
- if((c1==' ') || (c1==0))
- break;
- lang_name[ix++] = tolower(c1);
- }
- lang_name[ix] = 0;
-
- if((ix = LookupPhonemeTable(lang_name)) > 0)
- {
- SelectPhonemeTable(ix);
- word_phonemes[0] = phonSWITCH;
- word_phonemes[1] = ix;
- word_phonemes[2] = 0;
- }
- }
- else
- {
- EncodePhonemes(word,word_phonemes,bad_phoneme);
- }
- flags = FLAG_FOUND;
- }
- else
- {
- int c2;
- ix = 0;
- while(((c2 = word_copy[ix] = word[ix]) != ' ') && (c2 != 0) && (ix < N_WORD_BYTES)) ix++;
- word_copy_len = ix;
-
- flags = TranslateWord(translator, word, next_pause, wtab);
-
- if(flags & FLAG_SPELLWORD)
- {
- // re-translate the word as individual letters, separated by spaces
- memcpy(word, word_copy, word_copy_len);
- return(flags);
- }
-
- if((flags & FLAG_ALT2_TRANS) && ((sylimit = tr->langopts.param[LOPT_COMBINE_WORDS]) > 0))
- {
- char *p2;
- int ok = 1;
- int flags2;
- int c_word2;
- char ph_buf[N_WORD_PHONEMES];
-
- // LANG=cs,sk
- // combine a preposition with the following word
- p2 = word;
- while(*p2 != ' ') p2++;
-
- utf8_in(&c_word2, p2+1); // first character of the next word;
- if(!iswalpha(c_word2))
- {
- ok =0;
- }
-
- if(ok != 0)
- {
- if(sylimit & 0x100)
- {
- // only if the second word has $alt attribute
- strcpy(ph_buf,word_phonemes);
- flags2 = TranslateWord(translator, p2+1, 0, wtab+1);
- if((flags2 & FLAG_ALT_TRANS) == 0)
- {
- ok = 0;
- strcpy(word_phonemes,ph_buf);
- }
- }
-
- if((sylimit & 0x200) && ((wtab+1)->flags & FLAG_LAST_WORD))
- {
- // not if the next word is end-of-sentence
- ok = 0;
- }
- }
-
- if(ok)
- {
- *p2 = '-'; // replace next space by hyphen
- flags = TranslateWord(translator, word, next_pause, wtab); // translate the combined word
- if(CountSyllables(p) > (sylimit & 0xf))
- {
- // revert to separate words
- *p2 = ' ';
- flags = TranslateWord(translator, word, next_pause, wtab);
- }
- else
- {
- flags |= FLAG_SKIPWORDS;
- dictionary_skipwords = 1;
- }
- }
- }
-
- if(p[0] == phonSWITCH)
- {
- // this word uses a different language
- memcpy(word, word_copy, word_copy_len);
-
- new_language = (char *)(&p[1]);
- if(new_language[0]==0)
- new_language = "en";
-
- switch_phonemes = SetTranslator2(new_language);
-
- if(switch_phonemes >= 0)
- {
- // re-translate the word using the new translator
- flags = TranslateWord(translator2, word, next_pause, wtab);
-// strcpy((char *)p,translator2->word_phonemes);
- if(p[0] == phonSWITCH)
- {
- // the second translator doesn't want to process this word
- switch_phonemes = -1;
- }
- }
- if(switch_phonemes < 0)
- {
- // language code is not recognised or 2nd translator won't translate it
- p[0] = phonSCHWA; // just say something
- p[1] = phonSCHWA;
- p[2] = 0;
- }
- }
-
- if(!(word_flags & FLAG_HYPHEN))
- {
- if(flags & FLAG_PAUSE1)
- {
- if(pre_pause < 1)
- pre_pause = 1;
- }
- if((flags & FLAG_PREPAUSE) && ((word_flags && FLAG_LAST_WORD) == 0) && (tr->prepause_timeout == 0))
- {
- // the word is marked in the dictionary list with $pause
- if(pre_pause < 4) pre_pause = 4;
- tr->prepause_timeout = 3;
- }
- }
-
- if((option_emphasis >= 3) && (pre_pause < 1))
- pre_pause = 1;
- }
-
- plist2 = &ph_list2[n_ph_list2];
- stress = 0;
- next_stress = 0;
- srcix = 0;
- max_stress = -1;
-
- found_dict_flag = 0;
- if(flags & FLAG_FOUND)
- found_dict_flag = SFLAG_DICTIONARY;
-
- while((pre_pause > 0) && (n_ph_list2 < N_PHONEME_LIST-4))
- {
- // add pause phonemes here. Either because of punctuation (brackets or quotes) in the
- // text, or because the word is marked in the dictionary lookup as a conjunction
- if(pre_pause > 1)
- {
- SetPlist2(&ph_list2[n_ph_list2++],phonPAUSE);
- pre_pause -= 2;
- }
- else
- {
- SetPlist2(&ph_list2[n_ph_list2++],phonPAUSE_NOLINK);
- pre_pause--;
- }
- tr->end_stressed_vowel = 0; // forget about the previous word
- tr->prev_dict_flags = 0;
- }
-
- if((option_capitals==1) && (word_flags & FLAG_FIRST_UPPER))
- {
- SetPlist2(&ph_list2[n_ph_list2++],phonPAUSE_SHORT);
- SetPlist2(&ph_list2[n_ph_list2++],phonCAPITAL);
- if((word_flags & FLAG_ALL_UPPER) && IsAlpha(word[1]))
- {
- // word > 1 letter and all capitals
- SetPlist2(&ph_list2[n_ph_list2++],phonPAUSE_SHORT);
- SetPlist2(&ph_list2[n_ph_list2++],phonCAPITAL);
- }
- }
-
- if(switch_phonemes >= 0)
- {
- // this word uses a different phoneme table
- SetPlist2(&ph_list2[n_ph_list2],phonSWITCH);
- ph_list2[n_ph_list2++].tone_number = switch_phonemes; // temporary phoneme table number
- }
-
- // remove initial pause from a word if it follows a hyphen
- if((word_flags & FLAG_HYPHEN) && (phoneme_tab[*p]->type == phPAUSE))
- p++;
-
- while(((ph_code = *p++) != 0) && (n_ph_list2 < N_PHONEME_LIST-4))
- {
- if(ph_code == 255)
- continue; // unknown phoneme
-
- // Add the phonemes to the first stage phoneme list (ph_list2)
- ph = phoneme_tab[ph_code];
-
- if(ph_code == phonSWITCH)
- {
- ph_list2[n_ph_list2].phcode = ph_code;
- ph_list2[n_ph_list2].sourceix = 0;
- ph_list2[n_ph_list2].synthflags = embedded_flag;
- ph_list2[n_ph_list2++].tone_number = *p++;
- }
- else
- if(ph->type == phSTRESS)
- {
- // don't add stress phonemes codes to the list, but give their stress
- // value to the next vowel phoneme
- // std_length is used to hold stress number or (if >10) a tone number for a tone language
- if(ph->spect == 0)
- next_stress = ph->std_length;
- else
- {
- // for tone languages, the tone number for a syllable follows the vowel
- if(prev_vowel >= 0)
- {
- ph_list2[prev_vowel].tone_number = ph_code;
- }
- else
- {
- next_tone = ph_code; // no previous vowel, apply to the next vowel
- }
- }
- }
- else
- if(ph_code == phonSYLLABIC)
- {
- // mark the previous phoneme as a syllabic consonant
- prev_vowel = n_ph_list2-1;
- ph_list2[prev_vowel].synthflags |= SFLAG_SYLLABLE;
- ph_list2[prev_vowel].stress = next_stress;
- }
- else
- if(ph_code == phonLENGTHEN)
- {
- ph_list2[n_ph_list2-1].synthflags |= SFLAG_LENGTHEN;
- }
- else
- if(ph_code == phonEND_WORD)
- {
- // a || symbol in a phoneme string was used to indicate a word boundary
- // Don't add this phoneme to the list, but make sure the next phoneme has
- // a newword indication
- srcix = source_ix+1;
- }
- else
- if(ph_code == phonX1)
- {
- // a language specific action
- if(tr->langopts.param[LOPT_IT_DOUBLING])
- {
- flags |= FLAG_DOUBLING;
- }
- }
- else
- {
- ph_list2[n_ph_list2].phcode = ph_code;
- ph_list2[n_ph_list2].tone_number = 0;
- ph_list2[n_ph_list2].synthflags = embedded_flag | found_dict_flag;
- embedded_flag = 0;
- ph_list2[n_ph_list2].sourceix = srcix;
- srcix = 0;
-
- if(ph->type == phVOWEL)
- {
- stress = next_stress;
- next_stress = 0;
-
- if((prev_vowel >= 0) && (n_ph_list2-1) != prev_vowel)
- ph_list2[n_ph_list2-1].stress = stress; // set stress for previous consonant
-
- ph_list2[n_ph_list2].synthflags |= SFLAG_SYLLABLE;
- prev_vowel = n_ph_list2;
-
- if(stress > max_stress)
- {
- max_stress = stress;
- max_stress_ix = n_ph_list2;
- }
- if(next_tone != 0)
- {
- ph_list2[n_ph_list2].tone_number = next_tone;
- next_tone=0;
- }
- }
- else
- {
- if(first_phoneme && tr->langopts.param[LOPT_IT_DOUBLING])
- {
- if(((tr->prev_dict_flags & FLAG_DOUBLING) && (tr->langopts.param[LOPT_IT_DOUBLING] & 1)) ||
- (tr->end_stressed_vowel && (tr->langopts.param[LOPT_IT_DOUBLING] & 2)))
- {
- // italian, double the initial consonant if the previous word ends with a
- // stressed vowel, or is marked with a flag
- ph_list2[n_ph_list2].synthflags |= SFLAG_LENGTHEN;
- }
- }
- }
-
- ph_list2[n_ph_list2].stress = stress;
- n_ph_list2++;
- first_phoneme = 0;
- }
- }
- // don't set new-word if there is a hyphen before it
- if((word_flags & FLAG_HYPHEN) == 0)
- {
- plist2->sourceix = source_ix;
- }
-
- tr->end_stressed_vowel = 0;
- if((stress >= 4) && (phoneme_tab[ph_list2[n_ph_list2-1].phcode]->type == phVOWEL))
- {
- tr->end_stressed_vowel = 1; // word ends with a stressed vowel
- }
-
- if(switch_phonemes >= 0)
- {
- // this word uses a different phoneme table, now switch back
- SelectPhonemeTable(voice->phoneme_tab_ix);
- SetPlist2(&ph_list2[n_ph_list2],phonSWITCH);
- ph_list2[n_ph_list2++].tone_number = voice->phoneme_tab_ix; // original phoneme table number
- }
-
-
- if(pitch_raised > 0)
- {
- embedded_list[embedded_ix++] = EMBED_P+0x60+0x80 + (pitch_raised << 8); // lower pitch
- SetPlist2(&ph_list2[n_ph_list2],phonPAUSE_SHORT);
- ph_list2[n_ph_list2++].synthflags = SFLAG_EMBEDDED;
- }
-
- if(flags & FLAG_STRESS_END2)
- {
- // this's word's stress could be increased later
- ph_list2[max_stress_ix].synthflags |= SFLAG_PROMOTE_STRESS;
- }
-
- tr->prev_dict_flags = flags;
- return(flags);
-} // end of TranslateWord2
-
-
-
-static int EmbeddedCommand(unsigned int *source_index)
-{//===================================================
- // An embedded command to change the pitch, volume, etc.
- // returns number of commands added to embedded_list
-
- // pitch,speed,amplitude,expression,reverb,tone,voice,sayas
- const char *commands = "PSARHTIVYMUBF";
- int value = -1;
- int sign = 0;
- unsigned char c;
- char *p;
- int cmd;
-
- c = source[*source_index];
- if(c == '+')
- {
- sign = 0x40;
- (*source_index)++;
- }
- else
- if(c == '-')
- {
- sign = 0x60;
- (*source_index)++;
- }
-
- if(isdigit(source[*source_index]))
- {
- value = atoi(&source[*source_index]);
- while(isdigit(source[*source_index]))
- source_index++;
- }
-
- c = source[(*source_index)++];
- if(embedded_ix >= (N_EMBEDDED_LIST - 2))
- return(0); // list is full
-
- if((p = strchr_w(commands,c)) == NULL)
- return(0);
- cmd = (p - commands)+1;
- if(value == -1)
- {
- value = embedded_default[cmd];
- sign = 0;
- }
-
- if(cmd == EMBED_Y)
- {
- option_sayas2 = value;
- count_sayas_digits = 0;
- }
- if(cmd == EMBED_F)
- {
- if(value >= 3)
- word_emphasis = FLAG_EMPHASIZED;
- else
- word_emphasis = 0;
- }
-
- embedded_list[embedded_ix++] = cmd + sign + (value << 8);
- return(1);
-} // end of EmbeddedCommand
-
-
-
-static int SubstituteChar(Translator *tr, unsigned int c, unsigned int next_in, int *insert)
-{//=========================================================================================
- int ix;
- unsigned int word;
- unsigned int new_c, c2, c_lower;
- int upper_case = 0;
- static int ignore_next = 0;
- const unsigned int *replace_chars;
-
- if(ignore_next)
- {
- ignore_next = 0;
- return(8);
- }
- if(c == 0) return(0);
-
- if((replace_chars = tr->langopts.replace_chars) == NULL)
- return(c);
-
- // there is a list of character codes to be substituted with alternative codes
-
- if(iswupper(c_lower = c))
- {
- c_lower = towlower(c);
- upper_case = 1;
- }
-
- new_c = 0;
- for(ix=0; (word = replace_chars[ix]) != 0; ix+=2)
- {
- if(c_lower == (word & 0xffff))
- {
- if((word >> 16) == 0)
- {
- new_c = replace_chars[ix+1];
- break;
- }
- if((word >> 16) == (unsigned int)towlower(next_in))
- {
- new_c = replace_chars[ix+1];
- ignore_next = 1;
- break;
- }
- }
- }
-
- if(new_c == 0)
- return(c); // no substitution
-
- if(new_c & 0xffe00000)
- {
- // there is a second character to be inserted
- // don't convert the case of the second character unless the next letter is also upper case
- c2 = new_c >> 16;
- if(upper_case && iswupper(next_in))
- c2 = towupper(c2);
- *insert = c2;
- new_c &= 0xffff;
- }
-
- if(upper_case)
- new_c = towupper(new_c);
- return(new_c);
-
-}
-
-
-static int TranslateChar(Translator *tr, char *ptr, int prev_in, unsigned int c, unsigned int next_in, int *insert)
-{//================================================================================================================
- // To allow language specific examination and replacement of characters
-
- int code;
- int initial;
- int medial;
- int final;
- int next2;
-
- static const unsigned char hangul_compatibility[0x34] = {
- 0, 0x00,0x01,0xaa,0x02,0xac,0xad,0x03,
- 0x04,0x05,0xb0,0xb1,0xb2,0xb3,0xb4,0xb4,
- 0xb6,0x06,0x07,0x08,0xb9,0x09,0x0a,0xbc,
- 0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,0x61,
- 0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,
- 0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,
- 0x72,0x73,0x74,0x75 };
-
- switch(tr->translator_name)
- {
- case L('a','f'):
- // look for 'n and replace by a special character (unicode: schwa)
-
- utf8_in(&next2, &ptr[1]);
-
- if(!iswalpha(prev_in))
- {
- if((c == '\'') && (next_in == 'n') && IsSpace(next2))
- {
- // n preceded by either apostrophe or U2019 "right single quotation mark"
- ptr[0] = ' '; // delete the n
- return(0x0259); // replace ' by unicode schwa character
- }
- }
- break;
-
- case L('k','o'):
- if(((code = c - 0xac00) >= 0) && (c <= 0xd7af))
- {
- // break a syllable hangul into 2 or 3 individual jamo
- initial = (code/28)/21;
- medial = (code/28) % 21;
- final = code % 28;
-
- if(initial == 11)
- {
- // null initial
- c = medial + 0x1161;
- if(final > 0)
- *insert = final + 0x11a7;
- }
- else
- {
- // extact the initial and insert the remainder with a null initial
- c = initial + 0x1100;
- *insert = (11*28*21) + (medial*28) + final + 0xac00;
- }
- return(c);
- }
- else
- if(((code = c - 0x3130) >= 0) && (code < 0x34))
- {
- // Hangul compatibility jamo
- return(hangul_compatibility[code] + 0x1100);
- }
- break;
- }
- return(SubstituteChar(tr,c,next_in,insert));
-}
-
-
-void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *tone_out, char **voice_change)
-{//==========================================================================================================
- int ix;
- int c;
- int cc;
- unsigned int source_index=0;
- unsigned int prev_source_index=0;
- int prev_in;
- int prev_out=' ';
- int prev_out2;
- int prev_in2=0;
- int next_in;
- int char_inserted=0;
- int clause_pause;
- int pre_pause_add=0;
- int word_mark = 0;
- int all_upper_case=FLAG_ALL_UPPER;
- int finished;
- int single_quoted;
- int phoneme_mode = 0;
- int dict_flags = 0; // returned from dictionary lookup
- int word_flags; // set here
- int next_word_flags;
- int embedded_count = 0;
- int letter_count = 0;
- int space_inserted = 0;
- int syllable_marked = 0;
- int decimal_sep_count = 0;
- char *word;
- char *p;
- int j, k;
- int n_digits;
- int charix_top=0;
-
- short charix[N_TR_SOURCE+4];
- WORD_TAB words[N_CLAUSE_WORDS];
- int word_count=0; // index into words
-
- char sbuf[N_TR_SOURCE];
-
- int terminator;
- int tone;
- int tone2;
-
- p_textinput = (unsigned char *)vp_input;
- p_wchar_input = (wchar_t *)vp_input;
-
- embedded_ix = 0;
- embedded_read = 0;
- option_phoneme_input &= ~2; // clear bit 1 (temporary indication)
- pre_pause = 0;
-
- if((clause_start_char = count_characters) < 0)
- clause_start_char = 0;
- clause_start_word = count_words + 1;
-
- for(ix=0; ix<N_TR_SOURCE; ix++)
- charix[ix] = 0;
- terminator = ReadClause(tr, f_text, source, charix, &charix_top, N_TR_SOURCE, &tone2);
-
- charix[charix_top+1] = 0;
- charix[charix_top+2] = 0x7fff;
- charix[charix_top+3] = 0;
-
- clause_pause = (terminator & 0xfff) * 10; // mS
- tone = (terminator >> 12) & 0xf;
- if(tone2 != 0)
- {
- // override the tone type
- tone = tone2;
- }
-
- for(p=source; *p != 0; p++)
- {
- if(!isspace2(*p))
- {
- break;
- }
- }
- if(*p == 0)
- {
- // No characters except spaces. This is not a sentence.
- // Don't add this pause, just make up the previous pause to this value;
- clause_pause -= max_clause_pause;
- if(clause_pause < 0)
- clause_pause = 0;
-
- terminator &= ~CLAUSE_BIT_SENTENCE; // clear sentence bit
- max_clause_pause += clause_pause;
- }
- else
- {
- max_clause_pause = clause_pause;
- }
-
- if(new_sentence)
- {
- count_sentences++;
- if(skip_sentences > 0)
- {
- skip_sentences--;
- if(skip_sentences == 0)
- skipping_text = 0;
- }
- }
-
- memset(&ph_list2[0],0,sizeof(ph_list2[0]));
- ph_list2[0].phcode = phonPAUSE_SHORT;
-
- n_ph_list2 = 1;
- tr->prev_last_stress = 0;
- tr->prepause_timeout = 0;
- tr->expect_verb=0;
- tr->expect_noun=0;
- tr->expect_past=0;
- tr->expect_verb_s=0;
- tr->phonemes_repeat_count = 0;
- tr->end_stressed_vowel=0;
- tr->prev_dict_flags = 0;
-
- word_count = 0;
- single_quoted = 0;
- word_flags = 0;
- next_word_flags = 0;
-
- sbuf[0] = 0;
- sbuf[1] = ' ';
- sbuf[2] = ' ';
- ix = 3;
- prev_in = ' ';
-
- words[0].start = ix;
- words[0].flags = 0;
- finished = 0;
-
- for(j=0; charix[j]==0; j++);
- words[0].sourceix = charix[j];
- k = 0;
- while(charix[j] != 0)
- {
- // count the number of characters (excluding multibyte continuation bytes)
- if(charix[j++] != -1)
- k++;
- }
- words[0].length = k;
-
- while(!finished && (ix < (int)sizeof(sbuf))&& (n_ph_list2 < N_PHONEME_LIST-4))
- {
- prev_out2 = prev_out;
- utf8_in2(&prev_out,&sbuf[ix-1],1); // prev_out = sbuf[ix-1];
-
- if(tr->langopts.tone_numbers && IsDigit09(prev_out) && IsAlpha(prev_out2))
- {
- // tone numbers can be part of a word, consider them as alphabetic
- prev_out = 'a';
- }
-
- if(prev_in2 != 0)
- {
- prev_in = prev_in2;
- prev_in2 = 0;
- }
- else
- if(source_index > 0)
- {
- utf8_in2(&prev_in,&source[source_index-1],1); // prev_in = source[source_index-1];
- }
-
- prev_source_index = source_index;
-
- if(char_inserted)
- {
- c = char_inserted;
- char_inserted = 0;
- }
- else
- {
- source_index += utf8_in(&cc,&source[source_index]); // cc = source[source_index++];
- c = cc;
- }
- utf8_in(&next_in,&source[source_index]);
-
- if((c == CTRL_EMBEDDED) || (c == ctrl_embedded))
- {
- // start of embedded command in the text
- int srcix = source_index-1;
-
- if(prev_in != ' ')
- {
- c = ' ';
- prev_in2 = c;
- source_index--;
- }
- else
- {
- embedded_count += EmbeddedCommand(&source_index);
- prev_in2 = prev_in;
- // replace the embedded command by spaces
- memset(&source[srcix],' ',source_index-srcix);
- source_index = srcix;
- continue;
- }
- }
-
- if(option_sayas2 == SAYAS_KEY)
- {
- if(((c == '_') || (c == '-')) && IsAlpha(prev_in))
- {
- c = ' ';
- }
- c = towlower2(c);
- }
-
- if(phoneme_mode)
- {
- all_upper_case = FLAG_PHONEMES;
-
- if((c == ']') && (next_in == ']'))
- {
- phoneme_mode = 0;
- source_index++;
- c = ' ';
- }
- }
- else
- if((option_sayas2 & 0xf0) == SAYAS_DIGITS)
- {
- if(iswdigit(c))
- {
- count_sayas_digits++;
- if(count_sayas_digits > (option_sayas2 & 0xf))
- {
- // break after the specified number of digits
- c = ' ';
- space_inserted = 1;
- count_sayas_digits = 0;
- }
- }
- else
- {
- count_sayas_digits = 0;
- if(iswdigit(prev_out))
- {
- c = ' ';
- space_inserted = 1;
- }
- }
- }
- else
- if((option_sayas2 & 0x30) == 0)
- {
- // speak as words
-
-#ifdef deleted
-if((c == '/') && (tr->langopts.testing & 2) && IsDigit09(next_in) && IsAlpha(prev_out))
-{
- // TESTING, explicit indication of stressed syllable by /2 after the word
- word_mark = next_in-'0';
- source_index++;
- c = ' ';
-}
-#endif
- if((c == 0x92) || (c == 0xb4) || (c == 0x2019) || (c == 0x2032))
- c = '\''; // 'microsoft' quote or sexed closing single quote, or prime - possibly used as apostrophe
-
- if((c == '?') && IsAlpha(prev_out) && IsAlpha(next_in))
- {
- // ? between two letters may be a smart-quote replaced by ?
- c = '\'';
- }
-
- if(c == CHAR_EMPHASIS)
- {
- // this character is a marker that the previous word is the focus of the clause
- c = ' ';
- word_flags |= FLAG_FOCUS;
- }
-
- c = TranslateChar(tr, &source[source_index], prev_in,c, next_in, &char_inserted); // optional language specific function
- if(c == 8)
- continue; // ignore this character
-
- if(char_inserted)
- next_in = char_inserted;
-
- // allow certain punctuation within a word (usually only apostrophe)
- if(!IsAlpha(c) && !IsSpace(c) && (wcschr(tr->punct_within_word,c) == 0))
- {
- if(IsAlpha(prev_out))
- {
- if(tr->langopts.tone_numbers && IsDigit09(c) && !IsDigit09(next_in))
- {
- // allow a tone number as part of the word
- }
- else
- {
- c = ' '; // ensure we have an end-of-word terminator
- space_inserted = 1;
- }
- }
- }
-
- if(iswdigit(prev_out))
- {
- if(!iswdigit(c) && (c != '.') && (c != ','))
- {
- c = ' '; // terminate digit string with a space
- space_inserted = 1;
- }
- }
- else
- {
- if(prev_in != ',')
- {
- decimal_sep_count = 0;
- }
- }
-
- if((c == '[') && (next_in == '[') && option_phoneme_input)
- {
- phoneme_mode = FLAG_PHONEMES;
- source_index++;
- continue;
- }
-
- if(c == 0)
- {
- finished = 1;
- c = ' ';
- }
- else
- if(IsAlpha(c))
- {
- if(!IsAlpha(prev_out) || (tr->langopts.ideographs && ((c > 0x3040) || (prev_out > 0x3040))))
- {
- if(wcschr(tr->punct_within_word,prev_out) == 0)
- letter_count = 0; // don't reset count for an apostrophy within a word
-
- if((prev_out != ' ') && (wcschr(tr->punct_within_word,prev_out) == 0))
- {
- // start of word, insert space if not one there already
- c = ' ';
- space_inserted = 1;
- }
- else
- {
- if(iswupper(c))
- word_flags |= FLAG_FIRST_UPPER;
-
- if((prev_out == ' ') && iswdigit(sbuf[ix-2]) && !iswdigit(prev_in))
- {
- // word, following a number, but with a space between
- // Add an extra space, to distinguish "2 a" from "2a"
- sbuf[ix++] = ' ';
- words[word_count].start++;
- }
- }
- }
-
- letter_count++;
-
- if(iswupper(c))
- {
- c = towlower2(c);
-
- if((j = tr->langopts.param[LOPT_CAPS_IN_WORD]) > 0)
- {
- if((j == 2) && (syllable_marked == 0))
- {
- char_inserted = c;
- c = 0x2c8; // stress marker
- syllable_marked = 1;
- }
- }
- else
- {
- if(iswlower(prev_in))
- {
- c = ' '; // lower case followed by upper case, treat as new word
- space_inserted = 1;
- prev_in2 = c;
- }
- else
- if((c != ' ') && iswupper(prev_in) && iswlower(next_in) &&
- (memcmp(&source[source_index],"s ",2) != 0)) // ENGLISH specific plural
- {
- c = ' '; // change from upper to lower case, start new word at the last uppercase
- space_inserted = 1;
- prev_in2 = c;
- next_word_flags |= FLAG_NOSPACE;
- }
- }
- }
- else
- {
- if((all_upper_case) && (letter_count > 2))
- {
- if((c == 's') && (next_in==' '))
- {
- c = ' ';
- all_upper_case |= FLAG_HAS_PLURAL;
-
- if(sbuf[ix-1] == '\'')
- sbuf[ix-1] = ' ';
- }
- else
- all_upper_case = 0; // current word contains lower case letters, not "'s"
- }
- else
- all_upper_case = 0;
- }
- }
- else
- if(c=='-')
- {
- if(IsAlpha(prev_in) && IsAlpha(next_in))
- {
- // '-' between two letters is a hyphen, treat as a space
- word_flags |= FLAG_HYPHEN;
- words[word_count-1].flags |= FLAG_HYPHEN_AFTER;
- c = ' ';
- }
- else
- if((prev_in==' ') && (next_in==' '))
- {
- // ' - ' dash between two spaces, treat as pause
- c = ' ';
- pre_pause_add = 4;
- }
- else
- if(next_in=='-')
- {
- // double hyphen, treat as pause
- source_index++;
- c = ' ';
- pre_pause_add = 4;
- }
- else
- if((prev_out == ' ') && IsAlpha(sbuf[ix-2]) && !IsAlpha(prev_in))
- {
- // insert extra space between a word + space + hyphen, to distinguish 'a -2' from 'a-2'
- sbuf[ix++] = ' ';
- words[word_count].start++;
- }
- }
- else
- if(c == '\'')
- {
- if(iswalnum(prev_in) && IsAlpha(next_in))
- {
- // between two letters, consider apostrophe as part of the word
- single_quoted = 0;
- }
- else
- if((wcschr(tr->char_plus_apostrophe,prev_in) != 0) && (prev_out2 == ' '))
- {
- // consider single character plus apostrophe as a word
- single_quoted = 0;
- if(next_in == ' ')
- {
- source_index++; // skip following space
- }
- }
- else
- {
- if((prev_out == 's') && (single_quoted==0))
- {
- // looks like apostrophe after an 's'
- c = ' ';
- }
- else
- {
- if(IsSpace(prev_out))
- single_quoted = 1;
- else
- single_quoted = 0;
-
- pre_pause_add = 4; // single quote
- c = ' ';
- }
- }
- }
- else
-#ifdef deleted
-// Brackets are now recognised in TranslateRules()
- if(IsBracket(c))
- {
- pre_pause_add = 4;
- c = ' ';
- }
- else
-#endif
- if(lookupwchar(breaks,c) != 0)
- {
- c = ' '; // various characters to treat as space
- }
- else
- if(iswdigit(c))
- {
- if(tr->langopts.tone_numbers && IsAlpha(prev_out) && !IsDigit(next_in))
- {
- }
- else
- if((prev_out != ' ') && !iswdigit(prev_out))
- {
- if((prev_out != tr->langopts.decimal_sep) || ((decimal_sep_count > 0) && (tr->langopts.decimal_sep == ',')))
- {
- c = ' ';
- space_inserted = 1;
- }
- else
- {
- decimal_sep_count = 1;
- }
- }
- else
- if((prev_out == ' ') && IsAlpha(sbuf[ix-2]) && !IsAlpha(prev_in))
- {
- // insert extra space between a word and a number, to distinguish 'a 2' from 'a2'
- sbuf[ix++] = ' ';
- words[word_count].start++;
- }
- }
- }
-
- if(IsSpace(c))
- {
- if(prev_out == ' ')
- {
- continue; // multiple spaces
- }
-
- if(space_inserted)
- {
- words[word_count].length = source_index - words[word_count].sourceix;
- }
-
- // end of 'word'
- sbuf[ix++] = ' ';
-
- if((ix > words[word_count].start) && (word_count < N_CLAUSE_WORDS-1))
- {
- if(embedded_count > 0)
- {
- // there are embedded commands before this word
- embedded_list[embedded_ix-1] |= 0x80; // terminate list of commands for this word
- words[word_count].flags |= FLAG_EMBEDDED;
- embedded_count = 0;
- }
- words[word_count].pre_pause = pre_pause;
- words[word_count].flags |= (all_upper_case | word_flags | word_emphasis);
- words[word_count].wmark = word_mark;
-
- if(pre_pause > 0)
- {
- // insert an extra space before the word, to prevent influence from previous word across the pause
- for(j=ix; j>words[word_count].start; j--)
- {
- sbuf[j] = sbuf[j-1];
- }
- sbuf[j] = ' ';
- words[word_count].start++;
- ix++;
- }
-
- word_count++;
- words[word_count].start = ix;
- words[word_count].flags = 0;
-
- for(j=source_index; charix[j] <= 0; j++); // skip blanks
- words[word_count].sourceix = charix[j];
- k = 0;
- while(charix[j] != 0)
- {
- // count the number of characters (excluding multibyte continuation bytes)
- if(charix[j++] != -1)
- k++;
- }
- words[word_count].length = k;
-
- word_flags = next_word_flags;
- next_word_flags = 0;
- pre_pause = 0;
- word_mark = 0;
- all_upper_case = FLAG_ALL_UPPER;
- syllable_marked = 0;
- }
-
- if(space_inserted)
- {
- source_index = prev_source_index; // rewind to the previous character
- char_inserted = 0;
- space_inserted = 0;
- }
- }
- else
- {
- ix += utf8_out(c,&sbuf[ix]); // sbuf[ix++] = c;
- }
- if(pre_pause_add > pre_pause)
- pre_pause = pre_pause_add;
- pre_pause_add = 0;
- }
-
- if((word_count==0) && (embedded_count > 0))
- {
- // add a null 'word' to carry the embedded command flag
- embedded_list[embedded_ix-1] |= 0x80;
- words[word_count].flags |= FLAG_EMBEDDED;
- word_count = 1;
- }
-
- tr->clause_end = &sbuf[ix-1];
- sbuf[ix] = 0;
- words[0].pre_pause = 0; // don't add extra pause at beginning of clause
- words[word_count].pre_pause = 8;
- if(word_count > 0)
- words[word_count-1].flags |= FLAG_LAST_WORD;
- words[0].flags |= FLAG_FIRST_WORD;
-
- for(ix=0; ix<word_count; ix++)
- {
- int nx;
- int c_temp;
- char *pn;
- char *pw;
- static unsigned int break_numbers1 = 0x49249248;
- static unsigned int break_numbers2 = 0x24924aa8; // for languages which have numbers for 100,000 and 100,00,000, eg Hindi
- static unsigned int break_numbers3 = 0x49249268; // for languages which have numbers for 100,000 and 1,000,000
- unsigned int break_numbers;
- char number_buf[80];
-
- // start speaking at a specified word position in the text?
- count_words++;
- if(skip_words > 0)
- {
- skip_words--;
- if(skip_words == 0)
- skipping_text = 0;
- }
- if(skipping_text)
- continue;
-
-
- // digits should have been converted to Latin alphabet ('0' to '9')
- word = pw = &sbuf[words[ix].start];
-
- if(iswdigit(word[0]) && (tr->langopts.numbers2 & NUM2_100000))
- {
- // Languages with 100000 numbers. Remove thousands separators so that we can insert them again later
- pn = number_buf;
- while(pn < &number_buf[sizeof(number_buf)-3])
- {
- if(iswdigit(*pw))
- {
- *pn++ = *pw++;
- }
- else
- if((*pw == tr->langopts.thousands_sep) && (pw[1] == ' ') && iswdigit(pw[2]))
- {
- pw += 2;
- ix++; // skip "word"
- }
- else
- {
- nx = pw - word;
- memset(word,' ',nx);
- nx = pn - number_buf;
- memcpy(word,number_buf,nx);
- break;
- }
- }
- pw = word;
- }
-
- for(n_digits=0; iswdigit(word[n_digits]); n_digits++); // count consecutive digits
-
- if((n_digits > 4) && (word[0] != '0'))
- {
- // word is entirely digits, insert commas and break into 3 digit "words"
- number_buf[0] = ' ';
- pn = &number_buf[1];
- nx = n_digits;
-
- if((tr->langopts.numbers2 & NUM2_100000a) == NUM2_100000a)
- break_numbers = break_numbers3;
- else
- if(tr->langopts.numbers2 & NUM2_100000)
- break_numbers = break_numbers2;
- else
- break_numbers = break_numbers1;
-
- while(pn < &number_buf[sizeof(number_buf)-3])
- {
- if(!isdigit(c = *pw++) && (c != tr->langopts.decimal_sep))
- break;
-
- *pn++ = c;
- if((--nx > 0) && (break_numbers & (1 << nx)))
- {
- if(tr->langopts.thousands_sep != ' ')
- {
- *pn++ = tr->langopts.thousands_sep;
- }
- *pn++ = ' ';
- if(break_numbers & (1 << (nx-1)))
- {
- // the next group only has 1 digits (i.e. NUM2_10000), make it three
- *pn++ = '0';
- *pn++ = '0';
- }
- if(break_numbers & (1 << (nx-2)))
- {
- // the next group only has 2 digits (i.e. NUM2_10000), make it three
- *pn++ = '0';
- }
- }
- }
- word = pw;
-
- // include the next few characters, in case there are an ordinal indicator
- pn[0] = ' ';
- memcpy(pn+1, pw, 8);
- pn[8] = 0;
-
- for(pw = &number_buf[1]; pw < pn;)
- {
- dict_flags = TranslateWord2(tr, pw, &words[ix], words[ix].pre_pause,0 );
- while(*pw++ != ' ');
- words[ix].pre_pause = 0;
- words[ix].flags = 0;
- }
- }
- else
- {
- pre_pause = 0;
- dict_flags = TranslateWord2(tr, word, &words[ix], words[ix].pre_pause, words[ix+1].pre_pause);
-
- if(pre_pause > words[ix+1].pre_pause)
- {
- words[ix+1].pre_pause = pre_pause;
- pre_pause = 0;
- }
-
- if(dict_flags & FLAG_SPELLWORD)
- {
- // redo the word, speaking single letters
- for(pw = word; *pw != ' ';)
- {
- memset(number_buf,' ',9);
- nx = utf8_in(&c_temp, pw);
- memcpy(&number_buf[2],pw,nx);
- TranslateWord2(tr, &number_buf[2], &words[ix], 0, 0 );
- pw += nx;
- }
- }
-
- if((dict_flags & FLAG_DOT) && (ix == word_count-1) && (terminator == CLAUSE_PERIOD))
- {
- // probably an abbreviation such as Mr. or B. rather than end of sentence
- clause_pause = 10;
- tone = 4;
- }
- }
-
- if(dict_flags & FLAG_SKIPWORDS)
- {
- ix += dictionary_skipwords; // dictionary indicates skip next word(s)
- }
- }
-
- for(ix=0; ix<2; ix++)
- {
- // terminate the clause with 2 PAUSE phonemes
- PHONEME_LIST2 *p2;
- p2 = &ph_list2[n_ph_list2 + ix];
- p2->phcode = phonPAUSE;
- p2->stress = 0;
- p2->sourceix = source_index;
- p2->synthflags = 0;
- }
- n_ph_list2 += 2;
-
- if(count_words == 0)
- {
- clause_pause = 0;
- }
- if(Eof() && ((word_count == 0) || (option_endpause==0)))
- {
- clause_pause = 10;
- }
-
- MakePhonemeList(tr, clause_pause, new_sentence);
-
- if(embedded_count) // ???? is this needed
- {
- phoneme_list[n_phoneme_list-2].synthflags = SFLAG_EMBEDDED;
- embedded_list[embedded_ix-1] |= 0x80;
- }
-
-
- prev_clause_pause = clause_pause;
-
- *tone_out = tone;
-
- new_sentence = 0;
- if(terminator & CLAUSE_BIT_SENTENCE)
- {
- new_sentence = 1; // next clause is a new sentence
- }
-
-
- if(voice_change != NULL)
- {
- // return new voice name if an embedded voice change command terminated the clause
- if(terminator & CLAUSE_BIT_VOICE)
- *voice_change = &source[source_index];
- else
- *voice_change = NULL;
- }
-
- if(Eof() || (vp_input==NULL))
- return(NULL);
-
- if(option_multibyte == espeakCHARS_WCHAR)
- return((void *)p_wchar_input);
- else
- return((void *)p_textinput);
-} // end of TranslateClause
-
-
-
-
-
-void InitText(int control)
-{//=======================
- count_sentences = 0;
- count_words = 0;
- end_character_position = 0;
- skip_sentences = 0;
- skip_marker[0] = 0;
- skip_words = 0;
- skip_characters = 0;
- skipping_text = 0;
- new_sentence = 1;
-
- prev_clause_pause = 0;
-
- option_sayas = 0;
- option_sayas2 = 0;
- option_emphasis = 0;
- word_emphasis = 0;
- embedded_flag = 0;
-
- InitText2();
-
- if((control & espeakKEEP_NAMEDATA) == 0)
- {
- InitNamedata();
- }
-}
-
diff --git a/navit/support/espeak/translate.h b/navit/support/espeak/translate.h
deleted file mode 100755
index 0556bf280..000000000
--- a/navit/support/espeak/translate.h
+++ /dev/null
@@ -1,584 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-
-#define L(c1,c2) (c1<<8)+c2 // combine two characters into an integer for translator name
-
-#define CTRL_EMBEDDED 0x01 // control character at the start of an embedded command
-#define REPLACED_E 'E' // 'e' replaced by silent e
-
-#define N_WORD_PHONEMES 160 // max phonemes in a word
-#define N_WORD_BYTES 160 // max bytes for the UTF8 characters in a word
-#define N_CLAUSE_WORDS 300 // max words in a clause
-#define N_RULE_GROUP2 120 // max num of two-letter rule chains
-#define N_HASH_DICT 1024
-#define N_CHARSETS 20
-#define N_LETTER_GROUPS 26
-
-
-/* dictionary flags, word 1 */
-// bits 0-3 stressed syllable, bit 6=unstressed
-#define FLAG_SKIPWORDS 0x80
-#define FLAG_PREPAUSE 0x100
-
-#define FLAG_ONLY 0x200
-#define FLAG_ONLY_S 0x400
-#define BITNUM_FLAG_ONLY 9 // bit 9 is set
-#define BITNUM_FLAG_ONLY_S 10 // bit 10 is set
-
-#define FLAG_STRESS_END 0x800 /* full stress if at end of clause */
-#define FLAG_STRESS_END2 0x1000 /* full stress if at end of clause, or only followed by unstressed */
-#define FLAG_UNSTRESS_END 0x2000 /* reduce stress at end of clause */
-#define FLAG_ATEND 0x4000 /* use this pronunciation if at end of clause */
-#define FLAG_SPELLWORD 0x8000 // re-translate the word as individual letters, separated by spaces
-
-#define FLAG_DOT 0x10000 /* ignore '.' after word (abbreviation) */
-#define FLAG_ABBREV 0x20000 // spell as letters, even with a vowel, OR use specified pronunciation rather than split into letters
-#define FLAG_STEM 0x40000 // must have a suffix
-
-#define FLAG_DOUBLING 0x80000 // doubles the following consonant
-#define FLAG_ALT_TRANS 0x100000 // language specific
-#define FLAG_ALT2_TRANS 0x200000 // language specific
-
-#define FLAG_MAX3 0x08000000 // limit to 3 repeats
-#define FLAG_PAUSE1 0x10000000 // shorter prepause
-#define FLAG_TEXTMODE 0x20000000 // word translates to replacement text, not phonemes
-#define BITNUM_FLAG_TEXTMODE 29
-
-#define FLAG_FOUND_ATTRIBUTES 0x40000000 // word was found in the dictionary list (has attributes)
-#define FLAG_FOUND 0x80000000 // pronunciation was found in the dictionary list
-
-// dictionary flags, word 2
-#define FLAG_VERBF 0x1 /* verb follows */
-#define FLAG_VERBSF 0x2 /* verb follows, may have -s suffix */
-#define FLAG_NOUNF 0x4 /* noun follows */
-#define FLAG_PASTF 0x8 /* past tense follows */
-#define FLAG_VERB 0x10 /* pronunciation for verb */
-#define FLAG_NOUN 0x20 /* pronunciation for noun */
-#define FLAG_PAST 0x40 /* pronunciation for past tense */
-#define FLAG_VERB_EXT 0x100 /* extend the 'verb follows' */
-#define FLAG_CAPITAL 0x200 /* pronunciation if initial letter is upper case */
-#define FLAG_ALLCAPS 0x400 // only if the word is all capitals
-#define BITNUM_FLAG_ALLCAPS 0x2a
-#define FLAG_ACCENT 0x800 // character name is base-character name + accent name
-#define FLAG_HYPHENATED 0x1000 // multiple-words, but needs hyphen between parts 1 and 2
-#define BITNUM_FLAG_HYPHENATED 0x2c
-
-
-// wordflags, flags in source word
-#define FLAG_ALL_UPPER 0x1 /* no lower case letters in the word */
-#define FLAG_FIRST_UPPER 0x2 /* first letter is upper case */
-#define FLAG_UPPERS 0x3 // FLAG_ALL_UPPER | FLAG_FIRST_UPPER
-#define FLAG_HAS_PLURAL 0x4 /* upper-case word with s or 's lower-case ending */
-#define FLAG_PHONEMES 0x8 /* word is phonemes */
-#define FLAG_LAST_WORD 0x10 /* last word in clause */
-#define FLAG_EMBEDDED 0x40 /* word is preceded by embedded commands */
-#define FLAG_HYPHEN 0x80
-#define FLAG_NOSPACE 0x100 // word is not seperated from previous word by a space
-#define FLAG_FIRST_WORD 0x200 // first word in clause
-#define FLAG_FOCUS 0x400 // the focus word of a clause
-#define FLAG_EMPHASIZED 0x800
-#define FLAG_EMPHASIZED2 0xc00 // FLAG_FOCUS | FLAG_EMPHASIZED
-#define FLAG_DONT_SWITCH_TRANSLATOR 0x1000
-#define FLAG_SUFFIX_REMOVED 0x2000
-#define FLAG_HYPHEN_AFTER 0x4000
-
-#define FLAG_NO_TRACE 0x10000 // passed to TranslateRules() to suppress dictionary lookup printout
-#define FLAG_NO_PREFIX 0x20000
-
-// prefix/suffix flags (bits 8 to 14, bits 16 to 22) don't use 0x8000, 0x800000
-#define SUFX_E 0x0100 // e may have been added
-#define SUFX_I 0x0200 // y may have been changed to i
-#define SUFX_P 0x0400 // prefix
-#define SUFX_V 0x0800 // suffix means use the verb form pronunciation
-#define SUFX_D 0x1000 // previous letter may have been doubles
-#define SUFX_F 0x2000 // verb follows
-#define SUFX_Q 0x4000 // don't retranslate
-#define SUFX_T 0x10000 // don't affect the stress position in the stem
-#define SUFX_B 0x20000 // break, this character breaks the word into stem and suffix (used with SUFX_P)
-
-#define FLAG_ALLOW_TEXTMODE 0x02 // allow dictionary to translate to text rather than phonemes
-#define FLAG_SUFX 0x04
-#define FLAG_SUFX_S 0x08
-#define FLAG_SUFX_E_ADDED 0x10
-
-
-// codes in dictionary rules
-#define RULE_PRE 1
-#define RULE_POST 2
-#define RULE_PHONEMES 3
-#define RULE_PH_COMMON 4 // At start of rule. Its phoneme string is used by subsequent rules
-#define RULE_CONDITION 5 // followed by condition number (byte)
-#define RULE_GROUP_START 6
-#define RULE_GROUP_END 7
-#define RULE_LINENUM 8 // next 2 bytes give a line number, for debugging purposes
-
-#define RULE_SPACE 32 // ascii space
-#define RULE_SYLLABLE 9
-#define RULE_STRESSED 10
-#define RULE_DOUBLE 11
-#define RULE_INC_SCORE 12
-#define RULE_DEL_FWD 13
-#define RULE_ENDING 14
-#define RULE_DIGIT 15 // D digit
-#define RULE_NONALPHA 16 // Z non-alpha
-#define RULE_LETTERGP 17 // A B C H F G Y letter group number
-#define RULE_LETTERGP2 18 // L + letter group number
-#define RULE_CAPITAL 19 // word starts with a capital letter
-#define RULE_REPLACEMENTS 20 // section for character replacements
-#define RULE_NO_SUFFIX 24 // N
-#define RULE_NOTVOWEL 25 // K
-#define RULE_IFVERB 26 // V
-#define RULE_ALT1 28 // T word has $alt attribute
-#define RULE_NOVOWELS 29 // X no vowels up to word boundary
-#define RULE_SPELLING 31 // W while spelling letter-by-letter
-#define RULE_LAST_RULE 31
-
-#define LETTERGP_A 0
-#define LETTERGP_B 1
-#define LETTERGP_C 2
-#define LETTERGP_H 3
-#define LETTERGP_F 4
-#define LETTERGP_G 5
-#define LETTERGP_Y 6
-#define LETTERGP_VOWEL2 7
-
-
-// Punctuation types returned by ReadClause()
-// bits 0-7 pause x 10mS, bits 12-14 intonation type,
-// bit 19=sentence, bit 18=clause, bits 17=voice change
-// bit 16 used to distinguish otherwise identical types
-// bit 20= punctuation character can be inside a word (Armenian)
-#define CLAUSE_BIT_SENTENCE 0x80000
-#define CLAUSE_BIT_VOICE 0x20000
-#define PUNCT_IN_WORD 0x100000
-
-#define CLAUSE_NONE 0 + 0x04000
-#define CLAUSE_PARAGRAPH 70 + 0x80000
-#define CLAUSE_EOF 35 + 0x90000
-#define CLAUSE_VOICE 0 + 0x24000
-#define CLAUSE_PERIOD 35 + 0x80000
-#define CLAUSE_COMMA 20 + 0x41000
-#define CLAUSE_SHORTCOMMA 4 + 0x41000
-#define CLAUSE_SHORTFALL 4 + 0x40000
-#define CLAUSE_QUESTION 35 + 0x82000
-#define CLAUSE_EXCLAMATION 40 + 0x83000
-#define CLAUSE_COLON 30 + 0x40000
-#ifdef PLATFORM_RISCOS
-#define CLAUSE_SEMICOLON 30 + 0x40000
-#else
-#define CLAUSE_SEMICOLON 30 + 0x41000
-#endif
-
-#define SAYAS_CHARS 0x12
-#define SAYAS_GLYPHS 0x13
-#define SAYAS_SINGLE_CHARS 0x14
-#define SAYAS_KEY 0x24
-#define SAYAS_DIGITS 0x40 // + number of digits
-#define SAYAS_DIGITS1 0xc1
-
-#define CHAR_EMPHASIS 0x0530 // this is an unused character code
-
-// Rule:
-// [4] [match] [1 pre] [2 post] [3 phonemes] 0
-// match 1 pre 2 post 0 - use common phoneme string
-// match 1 pre 2 post 3 0 - empty phoneme string
-
-typedef const char * constcharptr;
-
-typedef struct {
- int points;
- const char *phonemes;
- int end_type;
- char *del_fwd;
-} MatchRecord;
-
-
-// used to mark words with the source[] buffer
-typedef struct{
- unsigned short start;
- unsigned short sourceix;
- unsigned short flags;
- unsigned char pre_pause;
- unsigned char wmark;
- unsigned char length;
-} WORD_TAB;
-
-// a clause translated into phoneme codes (first stage)
-typedef struct {
- unsigned char phcode;
- unsigned char stress;
- unsigned char tone_number;
- unsigned char synthflags;
- unsigned short sourceix;
-} PHONEME_LIST2;
-
-
-typedef struct {
- int type;
- int parameter[N_SPEECH_PARAM];
-} PARAM_STACK;
-
-extern PARAM_STACK param_stack[];
-extern const int param_defaults[N_SPEECH_PARAM];
-
-
-
-#define N_LOPTS 16
-#define LOPT_DIERESES 1
- // 1=remove [:] from unstressed syllables, 2= remove from unstressed or non-penultimate syllables
- // bit 4=0, if stress < 4, bit 4=1, if not the highest stress in the word
-#define LOPT_IT_LENGTHEN 2
-
- // 1=german
-#define LOPT_PREFIXES 3
-
- // non-zero, change voiced/unoiced to match last consonant in a cluster
- // bit 1=LANG=ru, don't propagate over [v]
- // bit 2=don't propagate acress word boundaries
- // bit 3=LANG=pl, propagate over liquids and nasals
-#define LOPT_REGRESSIVE_VOICING 4
-
- // 0=default, 1=no check, other allow this character as an extra initial letter (default is 's')
-#define LOPT_UNPRONOUNCABLE 5
-
- // select length_mods tables, (length_mod_tab) + (length_mod_tab0 * 100)
-#define LOPT_LENGTH_MODS 6
-
- // increase this to prevent sonorants being shortened before shortened (eg. unstressed) vowels
-#define LOPT_SONORANT_MIN 7
-
- // don't break vowels at word boundary
-#define LOPT_WORD_MERGE 8
-
- // max. amplitude for vowel at the end of a clause
-#define LOPT_MAXAMP_EOC 9
-
- // bit 0=reduce even if phonemes are specified in the **_list file
- // bit 1=don't reduce the strongest vowel in a word which is marked 'unstressed'
-#define LOPT_REDUCE 10
-
- // LANG=cs,sk combine some prepositions with the following word, if the combination has N or fewer syllables
- // bits 0-3 N syllables
- // bit 4=only if the second word has $alt attribute
- // bit 5=not if the second word is end-of-sentence
-#define LOPT_COMBINE_WORDS 11
-
- // change [t] when followed by unstressed vowel
-#define LOPT_REDUCE_T 12
-
- // 1 = allow capitals inside a word
- // 2 = stressed syllable is indicated by capitals
-#define LOPT_CAPS_IN_WORD 13
-
- // bit 0=Italian "syntactic doubling" of consoants in the word after a word marked with $double attribute
- // bit 1=also after a word which ends with a stressed vowel
-#define LOPT_IT_DOUBLING 14
-
- // Call ApplySpecialAttributes() if $alt or $alt2 is set for a word
-#define LOPT_ALT 15
-
-
-typedef struct {
-// bits0-2 separate words with (1=pause_vshort, 2=pause_short, 3=pause, 4=pause_long 5=[?] phonemme)
-// bit 3=don't use linking phoneme
-// bit4=longer pause before STOP, VSTOP,FRIC
-// bit5=length of a final vowel doesn't depend on the next phoneme
- int word_gap;
- int vowel_pause;
- int stress_rule; // 1=first syllable, 2=penultimate, 3=last
-
-// bit0=don't stress monosyllables, except at end of clause
-// bit1=don't set diminished stress,
-// bit2=mark unstressed final syllables as diminished
-// bit4=don't allow secondary stress on last syllable
-// bit5-don't use automatic secondary stress
-// bit6=light syllable followed by heavy, move secondary stress to the heavy syllable. LANG=Finnish
-// bit8=stress last syllable if it doesn't end in a vowel
-// bit9=stress last syllable if it doesn't end in vowel or "s" or "n" LANG=Spanish
-// bit12= In a 2-syllable word, if one has primary stress then give the other secondary stress
-// bit13= If there is only one syllable before the primary stress, give it a secondary stress
-// bit15= Give stress to the first unstressed syllable
-// bit16= Don't diminish consecutive syllables within a word.
-// bit17= "priority" stress reduces other primary stress to "unstressed" not "secondary"
-// bit18= don't lengthen short vowels more than long vowels at end-of-clause
-// bit19=stress on final syllable if it has a long vowel, but previous syllable has a short vowel
-
- int stress_flags;
- int unstressed_wd1; // stress for $u word of 1 syllable
- int unstressed_wd2; // stress for $u word of >1 syllable
- int param[N_LOPTS];
- unsigned char *length_mods;
- unsigned char *length_mods0;
-
-#define NUM_ROMAN 0x20000
-#define NUM_ROMAN_UC 0x40000
-#define NUM_NOPAUSE 0x80000
-#define NUM_ROMAN_AFTER 0x200000
-#define NUM_VIGESIMAL 0x400000
-
- // bits0-1=which numbers routine to use.
- // bit2= thousands separator must be space
- // bit3= , decimal separator, not .
- // bit4=use three-and-twenty rather than twenty-three
- // bit5='and' between tens and units
- // bit6=add "and" after hundred or thousand
- // bit7=don't have "and" both after hundreds and also between tens and units
- // bit8=only one primary stress in tens+units
- // bit9=only one vowel betwen tens and units
- // bit10=omit "one" before "hundred"
- // bit11=say 19** as nineteen hundred
- // bit12=allow space as thousands separator (in addition to langopts.thousands_sep)
- // bits13-15 post-decimal-digits 0=single digits, 1=(LANG=it) 2=(LANG=pl) 3=(LANG=ro)
- // bit16=dot after number indicates ordinal
- // bit17=recognize roman numbers
- // bit18=Roman numbers only if upper case
- // bit19=don't add pause after a number
- // bit20='and' before hundreds
- // bit21= say "roman" after the number, not before
- // bit22= vigesimal number, if tens are not found
- int numbers;
-
-#define NUM2_100000 0x800 // numbers for 100,000 and 10,000,000
-#define NUM2_100000a 0xc00 // numbers for 100,000 and 1,000,000
- // bits 1-4 use variant form of numbers before thousands,millions,etc.
- // bit6=(LANG=pl) two forms of plural, M or MA
- // bit7=(LANG-ru) use MB for 1 thousand, million, etc
- // bit8=(LANG=cs,sk) two forms of plural, M or MA
- // bit9=(LANG=rw) say "thousand" and "million" before its number, not after
- // bit10=(LANG=sw) special word for 100,000 and 1,000,000
- // bit11=(LANG=hi) special word for 100,000 and 10,000,000
- int numbers2;
-
- int max_roman;
- int thousands_sep;
- int decimal_sep;
-
- // bit 0, accent name before the letter name, bit 1 "capital" after letter name
- int accents;
-
- int tone_language; // 1=tone language
- int intonation_group;
- int long_stop; // extra mS pause for a lengthened stop
- int phoneme_change; // TEST, change phonemes, after translation
- char max_initial_consonants;
- char spelling_stress; // 0=default, 1=stress first letter
- char tone_numbers;
- char ideographs; // treat as separate words
- char textmode; // the meaning of FLAG_TEXTMODE is reversed (to save data when *_list file is compiled)
- int testing; // testing options: bit 1= specify stressed syllable in the form: "outdoor/2"
- int listx; // compile *_listx after *list
- const unsigned int *replace_chars; // characters to be substitutes
- const char *ascii_language; // switch to this language for Latin characters
-} LANGUAGE_OPTIONS;
-
-
-// a parameter of ChangePhonemes()
-typedef struct {
- int flags;
- unsigned char stress; // stress level of this vowel
- unsigned char stress_highest; // the highest stress level of a vowel in this word
- unsigned char n_vowels; // number of vowels in the word
- unsigned char vowel_this; // syllable number of this vowel (counting from 1)
- unsigned char vowel_stressed; // syllable number of the highest stressed vowel
-} CHANGEPH;
-
-
-
-#define NUM_SEP_DOT 0x0008 // . , for thousands and decimal separator
-#define NUM_SEP_SPACE 0x1000 // allow space as thousands separator (in addition to langopts.thousands_sep)
-#define NUM_DEC_IT 0x2000 // (LANG=it) speak post-decimal-point digits as a combined number not as single digits
-
-typedef struct Translator
-{//=============
-
- LANGUAGE_OPTIONS langopts;
- int translator_name;
- int transpose_offset;
- int transpose_max;
- int transpose_min;
-
- char phon_out[300];
- char phonemes_repeat[20];
- int phonemes_repeat_count;
-
- unsigned char stress_amps[8];
- unsigned char stress_amps_r[8];
- short stress_lengths[8];
- int dict_condition; // conditional apply some pronunciation rules and dict.lookups
- const unsigned short *charset_a0; // unicodes for characters 0xa0 to oxff
- const wchar_t *char_plus_apostrophe; // single chars + apostrophe treated as words
- const wchar_t *punct_within_word; // allow these punctuation characters within words
-
-// holds properties of characters: vowel, consonant, etc for pronunciation rules
- unsigned char letter_bits[256];
- int letter_bits_offset;
- const wchar_t *letter_groups[8];
-
- /* index1=option, index2 by 0=. 1=, 2=?, 3=! 4=none */
-#define INTONATION_TYPES 8
-#define PUNCT_INTONATIONS 6
- unsigned char punct_to_tone[INTONATION_TYPES][PUNCT_INTONATIONS];
-
- char *data_dictrules; // language_1 translation rules file
- char *data_dictlist; // language_2 dictionary lookup file
- char *dict_hashtab[N_HASH_DICT]; // hash table to index dictionary lookup file
- char *letterGroups[N_LETTER_GROUPS];
-
- // groups1 and groups2 are indexes into data_dictrules, set up by InitGroups()
- // the two-letter rules for each letter must be consecutive in the language_rules source
-
- char *groups1[256]; // translation rule lists, index by single letter
- char *groups2[N_RULE_GROUP2]; // translation rule lists, indexed by two-letter pairs
- unsigned int groups2_name[N_RULE_GROUP2]; // the two letter pairs for groups2[]
- int n_groups2; // number of groups2[] entries used
-
- unsigned char groups2_count[256]; // number of 2 letter groups for this initial letter
- unsigned char groups2_start[256]; // index into groups2
-
-
- int expect_verb;
- int expect_past; // expect past tense
- int expect_verb_s;
- int expect_noun;
- int prev_last_stress;
- char *clause_end;
-
- int word_vowel_count; // number of vowels so far
- int word_stressed_count; // number of vowels so far which could be stressed
-
- int clause_upper_count; // number of upper case letters in the clause
- int clause_lower_count; // number of lower case letters in the clause
-
- int prepause_timeout;
- int end_stressed_vowel; // word ends with stressed vowel
- int prev_dict_flags; // dictionary flags from previous word
-} Translator; // end of class Translator
-
-
-extern int option_tone2;
-#define OPTION_EMPHASIZE_ALLCAPS 0x100
-#define OPTION_EMPHASIZE_PENULTIMATE 0x200
-extern int option_tone_flags;
-extern int option_waveout;
-extern int option_quiet;
-extern int option_phonemes;
-extern int option_phoneme_events;
-extern int option_linelength; // treat lines shorter than this as end-of-clause
-extern int option_multibyte;
-extern int option_capitals;
-extern int option_punctuation;
-extern int option_endpause;
-extern int option_ssml;
-extern int option_phoneme_input; // allow [[phonemes]] in input text
-extern int option_phoneme_variants;
-extern int option_sayas;
-extern int option_wordgap;
-
-extern int count_characters;
-extern int count_words;
-extern int count_sentences;
-extern int skip_characters;
-extern int skip_words;
-extern int skip_sentences;
-extern int skipping_text;
-extern int end_character_position;
-extern int clause_start_char;
-extern int clause_start_word;
-extern char *namedata;
-extern int pre_pause;
-
-
-
-#define N_MARKER_LENGTH 50 // max.length of a mark name
-extern char skip_marker[N_MARKER_LENGTH];
-
-#define N_PUNCTLIST 60
-extern wchar_t option_punctlist[N_PUNCTLIST]; // which punctuation characters to announce
-extern unsigned char punctuation_to_tone[INTONATION_TYPES][PUNCT_INTONATIONS];
-
-extern struct Translator *translator;
-extern struct Translator *translator2;
-extern const unsigned short *charsets[N_CHARSETS];
-extern char dictionary_name[40];
-extern char ctrl_embedded; // to allow an alternative CTRL for embedded commands
-extern unsigned char *p_textinput;
-extern wchar_t *p_wchar_input;
-extern int dictionary_skipwords;
-
-extern int (* uri_callback)(int, const char *, const char *);
-extern int (* phoneme_callback)(const char *);
-extern void SetLengthMods(struct Translator *tr, int value);
-
-void LoadConfig(void);
-int TransposeAlphabet(char *text, int offset, int min, int max);
-int utf8_in(int *c, const char *buf);
-int utf8_in2(int *c, const char *buf, int backwards);
-int utf8_out(unsigned int c, char *buf);
-int utf8_nbytes(const char *buf);
-int lookupwchar(const unsigned short *list,int c);
-int Eof(void);
-char *strchr_w(const char *s, int c);
-int IsBracket(int c);
-void InitNamedata(void);
-void InitText(int flags);
-void InitText2(void);
-int IsDigit(unsigned int c);
-int IsAlpha(unsigned int c);
-int isspace2(unsigned int c);
-int towlower2(unsigned int c);
-void GetTranslatedPhonemeString(char *phon_out, int n_phon_out);
-
-struct Translator *SelectTranslator(const char *name);
-int SetTranslator2(const char *name);
-void DeleteTranslator(struct Translator *tr);
-int Lookup(struct Translator *tr, const char *word, char *ph_out);
-
-int TranslateNumber(Translator *tr, char *word1, char *ph_out, unsigned int *flags, int wflags);
-int TranslateRoman(Translator *tr, char *word, char *ph_out);
-
-void ChangeWordStress(Translator *tr, char *word, int new_stress);
-void SetSpellingStress(Translator *tr, char *phonemes, int control, int n_chars);
-int TranslateLetter(Translator *tr, char *letter, char *phonemes, int control, int word_length);
-void LookupLetter(Translator *tr, unsigned int letter, int next_byte, char *ph_buf);
-void LookupAccentedLetter(Translator *tr, unsigned int letter, char *ph_buf);
-
-int LoadDictionary(Translator *tr, const char *name, int no_error);
-int LookupDictList(Translator *tr, char **wordptr, char *ph_out, unsigned int *flags, int end_flags, WORD_TAB *wtab);
-
-void MakePhonemeList(Translator *tr, int post_pause, int new_sentence);
-int ChangePhonemes_ru(Translator *tr, PHONEME_LIST2 *phlist, int n_ph, int index, PHONEME_TAB *ph, CHANGEPH *ch);
-void ApplySpecialAttribute(Translator *tr, char *phonemes, int dict_flags);
-void ApplySpecialAttribute2(Translator *tr, char *phonemes, int dict_flags);
-void AppendPhonemes(Translator *tr, char *string, int size, const char *ph);
-
-void CalcLengths(Translator *tr);
-void CalcPitches(Translator *tr, int clause_tone);
-
-int RemoveEnding(Translator *tr, char *word, int end_type, char *word_copy);
-int Unpronouncable(Translator *tr, char *word);
-void SetWordStress(Translator *tr, char *output, unsigned int *dictionary_flags, int tonic, int prev_stress);
-int TranslateRules(Translator *tr, char *p, char *phonemes, int size, char *end_phonemes, int end_flags, unsigned int *dict_flags);
-int TranslateWord(Translator *tr, char *word1, int next_pause, WORD_TAB *wtab);
-void *TranslateClause(Translator *tr, FILE *f_text, const void *vp_input, int *tone, char **voice_change);
-int ReadClause(Translator *tr, FILE *f_in, char *buf, short *charix, int *charix_top, int n_buf, int *tone_type);
-
-void SetVoiceStack(espeak_VOICE *v);
-
-extern FILE *f_trans; // for logging
diff --git a/navit/support/espeak/voice.h b/navit/support/espeak/voice.h
deleted file mode 100644
index ab69fa128..000000000
--- a/navit/support/espeak/voice.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-
-
-typedef struct {
- char v_name[40];
-
- int phoneme_tab_ix; // phoneme table number
- int pitch_base; // Hz<<12
- int pitch_range; // standard = 0x1000
-
- int speedf1;
- int speedf2;
- int speedf3;
-
- int flutter;
- int roughness;
- int echo_delay;
- int echo_amp;
- int n_harmonic_peaks; // highest formant which is formed from adding harmonics
- int peak_shape; // alternative shape for formant peaks (0=standard 1=squarer)
- int voicing; // 100% = 64, level of formant-synthesized sound
- int formant_factor; // adjust nominal formant frequencies by this because of the voice's pitch (256ths)
- int consonant_amp; // amplitude of unvoiced consonants
- int consonant_ampv; // amplitude of the noise component of voiced consonants
- int klattv[8];
-
- // parameters used by Wavegen
- short freq[N_PEAKS]; // 100% = 256
- short height[N_PEAKS]; // 100% = 256
- short width[N_PEAKS]; // 100% = 256
- short freqadd[N_PEAKS]; // Hz
-
- // copies without temporary adjustments from embedded commands
- short freq2[N_PEAKS]; // 100% = 256
- short height2[N_PEAKS]; // 100% = 256
- short width2[N_PEAKS]; // 100% = 256
-
- int breath[N_PEAKS]; // amount of breath for each formant. breath[0] indicates whether any are set.
- int breathw[N_PEAKS]; // width of each breath formant
-
- // This table provides the opportunity for tone control.
- // Adjustment of harmonic amplitudes, steps of 8Hz
- // value of 128 means no change
- #define N_TONE_ADJUST 1000
- unsigned char tone_adjust[N_TONE_ADJUST]; // 8Hz steps * 1000 = 8kHz
-
-} voice_t;
-
-// percentages shown to user, ix=N_PEAKS means ALL peaks
-extern USHORT voice_pcnt[N_PEAKS+1][3];
-
-
-extern voice_t *voice;
-extern int tone_points[12];
-
-const char *SelectVoice(espeak_VOICE *voice_select, int *found);
-espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name);
-voice_t *LoadVoice(const char *voice_name, int control);
-voice_t *LoadVoiceVariant(const char *voice_name, int variant);
-void DoVoiceChange(voice_t *v);
-void WavegenSetVoice(voice_t *v);
-void ReadTonePoints(char *string, int *tone_pts);
-
diff --git a/navit/support/espeak/voices.c b/navit/support/espeak/voices.c
deleted file mode 100755
index a7bd3f5a0..000000000
--- a/navit/support/espeak/voices.c
+++ /dev/null
@@ -1,1746 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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 see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-#include "stdio.h"
-#include "ctype.h"
-#include "wctype.h"
-#include "string.h"
-#include "stdlib.h"
-#include "speech.h"
-
-#ifdef PLATFORM_WINDOWS
-#include "windows.h"
-#else
-#ifdef PLATFORM_RISCOS
-#include "kernel.h"
-#else
-#include "dirent.h"
-#endif
-#endif
-
-#include "speak_lib.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-#include "translate.h"
-
-#define int(x) ((int)(x))
-#define double(x) ((double)(x))
-#define __cdecl
-
-MNEM_TAB genders [] = {
- {"unknown", 0},
- {"male", 1},
- {"female", 2},
- {NULL, 0 }};
-
-int tone_points[12] = {600,170, 1200,135, 2000,110, 3000,110, -1,0};
-//int tone_points[12] = {250,200, 400,170, 600,170, 1200,135, 2000,110, -1,0};
-
-// limit the rate of change for each formant number
-//static int formant_rate_22050[9] = {50, 104, 165, 230, 220, 220, 220, 220, 220}; // values for 22kHz sample rate
-//static int formant_rate_22050[9] = {240, 180, 180, 180, 180, 180, 180, 180, 180}; // values for 22kHz sample rate
-static int formant_rate_22050[9] = {240, 170, 170, 170, 170, 170, 170, 170, 170}; // values for 22kHz sample rate
-int formant_rate[9]; // values adjusted for actual sample rate
-
-
-
-#define DEFAULT_LANGUAGE_PRIORITY 5
-#define N_VOICES_LIST 150
-static int n_voices_list = 0;
-static espeak_VOICE *voices_list[N_VOICES_LIST];
-static int len_path_voices;
-
-espeak_VOICE voice_selected;
-
-
-enum {
- V_NAME = 1,
- V_LANGUAGE,
- V_GENDER,
- V_TRANSLATOR,
- V_PHONEMES,
- V_DICTIONARY,
-
-// these affect voice quality, are independent of language
- V_FORMANT,
- V_PITCH,
- V_ECHO,
- V_FLUTTER,
- V_ROUGHNESS,
- V_CLARITY,
- V_TONE,
- V_VOICING,
- V_BREATH,
- V_BREATHW,
-
-// these override defaults set by the translator
- V_WORDGAP,
- V_INTONATION,
- V_STRESSLENGTH,
- V_STRESSAMP,
- V_STRESSADD,
- V_DICTRULES,
- V_STRESSRULE,
- V_CHARSET,
- V_NUMBERS,
- V_OPTION,
-
- V_MBROLA,
- V_KLATT,
- V_FAST,
-
-// these need a phoneme table to have been specified
- V_REPLACE,
- V_CONSONANTS
-};
-
-
-
-typedef struct {
- const char *mnem;
- int data;
-} keywtab_t;
-
-static keywtab_t keyword_tab[] = {
- {"name", V_NAME},
- {"language", V_LANGUAGE},
- {"gender", V_GENDER},
-
- {"formant", V_FORMANT},
- {"pitch", V_PITCH},
- {"phonemes", V_PHONEMES},
- {"translator", V_TRANSLATOR},
- {"dictionary", V_DICTIONARY},
- {"stressLength", V_STRESSLENGTH},
- {"stressAmp", V_STRESSAMP},
- {"stressAdd", V_STRESSADD},
- {"intonation", V_INTONATION},
- {"dictrules", V_DICTRULES},
- {"stressrule", V_STRESSRULE},
- {"charset", V_CHARSET},
- {"replace", V_REPLACE},
- {"words", V_WORDGAP},
- {"echo", V_ECHO},
- {"flutter", V_FLUTTER},
- {"roughness", V_ROUGHNESS},
- {"clarity", V_CLARITY},
- {"tone", V_TONE},
- {"voicing", V_VOICING},
- {"breath", V_BREATH},
- {"breathw", V_BREATHW},
- {"numbers", V_NUMBERS},
- {"option", V_OPTION},
- {"mbrola", V_MBROLA},
- {"consonants", V_CONSONANTS},
- {"klatt", V_KLATT},
- {"fast_test", V_FAST},
-
- // these just set a value in langopts.param[]
- {"l_dieresis", 0x100+LOPT_DIERESES},
-// {"l_lengthen", 0x100+LOPT_IT_LENGTHEN},
- {"l_prefix", 0x100+LOPT_PREFIXES},
- {"l_regressive_v", 0x100+LOPT_REGRESSIVE_VOICING},
- {"l_unpronouncable", 0x100+LOPT_UNPRONOUNCABLE},
- {"l_sonorant_min", 0x100+LOPT_SONORANT_MIN},
- {"l_length_mods", 0x100+LOPT_LENGTH_MODS},
- {NULL, 0} };
-
-#define N_VOICE_VARIANTS 12
-const char variants_either[N_VOICE_VARIANTS] = {1,2,12,3,13,4,14,5,11,0};
-const char variants_male[N_VOICE_VARIANTS] = {1,2,3,4,5,0};
-const char variants_female[N_VOICE_VARIANTS] = {11,12,13,14,0};
-const char *variant_lists[3] = {variants_either, variants_male, variants_female};
-
-static voice_t voicedata;
-voice_t *voice = &voicedata;
-
-
-static char *fgets_strip(char *buf, int size, FILE *f_in)
-{//======================================================
-// strip trailing spaces, and truncate lines at // comment
- int len;
- char *p;
-
- if(fgets(buf,size,f_in) == NULL)
- return(NULL);
-
- len = strlen(buf);
- while((--len > 0) && isspace(buf[len]))
- buf[len] = 0;
-
- if((p = strstr(buf,"//")) != NULL)
- *p = 0;
-
- return(buf);
-}
-
-
-static void SetToneAdjust(voice_t *voice, int *tone_pts)
-{//=====================================================
- int ix;
- int pt;
- int y;
- int freq1=0;
- int freq2;
- int height1 = tone_pts[1];
- int height2;
- double rate;
-
- for(pt=0; pt<12; pt+=2)
- {
- if(tone_pts[pt] == -1)
- {
- tone_pts[pt] = N_TONE_ADJUST*8;
- if(pt > 0)
- tone_pts[pt+1] = tone_pts[pt-1];
- }
- freq2 = tone_pts[pt] / 8; // 8Hz steps
- height2 = tone_pts[pt+1];
- if((freq2 - freq1) > 0)
- {
- rate = double(height2-height1)/(freq2-freq1);
-
- for(ix=freq1; ix<freq2; ix++)
- {
- y = height1 + int(rate * (ix-freq1));
- if(y > 255)
- y = 255;
- voice->tone_adjust[ix] = y;
- }
- }
- freq1 = freq2;
- height1 = height2;
- }
-}
-
-
-void ReadTonePoints(char *string, int *tone_pts)
-{//=============================================
-// tone_pts[] is int[12]
- int ix;
-
- for(ix=0; ix<12; ix++)
- tone_pts[ix] = -1;
-
- sscanf(string,"%d %d %d %d %d %d %d %d %d %d",
- &tone_pts[0],&tone_pts[1],&tone_pts[2],&tone_pts[3],
- &tone_pts[4],&tone_pts[5],&tone_pts[6],&tone_pts[7],
- &tone_pts[8],&tone_pts[9]);
-}
-
-
-
-
-static espeak_VOICE *ReadVoiceFile(FILE *f_in, const char *fname, const char*leafname)
-{//===================================================================================
-// Read a Voice file, allocate a VOICE_DATA and set data from the
-// file's language, gender, name lines
-
- char linebuf[120];
- char vname[80];
- char vgender[80];
- char vlanguage[80];
- char languages[300]; // allow space for several alternate language names and priorities
-
-
- unsigned int len;
- int langix = 0;
- int n_languages = 0;
- char *p;
- espeak_VOICE *voice_data;
- int priority;
- int age;
- int n_variants = 3; // default, number of variants of this voice before using another voice
- int gender;
-
-#ifdef PLATFORM_WINDOWS
- char fname_buf[sizeof(path_home)+15];
- if(memcmp(leafname,"mb-",3) == 0)
- {
- // check whether the mbrola speech data is present for this voice
- memcpy(vname,&leafname[3],3);
- vname[3] = 0;
- sprintf(fname_buf,"%s/mbrola/%s",path_home,vname);
-
- if(GetFileLength(fname_buf) <= 0)
- return(0);
- }
-#endif
-
- vname[0] = 0;
- vgender[0] = 0;
- age = 0;
-
- while(fgets_strip(linebuf,sizeof(linebuf),f_in) != NULL)
- {
- if(memcmp(linebuf,"name",4)==0)
- {
- p = &linebuf[4];
- while(isspace(*p)) p++;
- strncpy0(vname,p,sizeof(vname));
- }
- else
- if(memcmp(linebuf,"language",8)==0)
- {
- priority = DEFAULT_LANGUAGE_PRIORITY;
- vlanguage[0] = 0;
-
- sscanf(&linebuf[8],"%s %d",vlanguage,&priority);
- len = strlen(vlanguage) + 2;
- // check for space in languages[]
- if(len < (sizeof(languages)-langix-1))
- {
- languages[langix] = priority;
-
- strcpy(&languages[langix+1],vlanguage);
- langix += len;
- n_languages++;
- }
- }
- else
- if(memcmp(linebuf,"gender",6)==0)
- {
- sscanf(&linebuf[6],"%s %d",vgender,&age);
- }
- else
- if(memcmp(linebuf,"variants",8)==0)
- {
- sscanf(&linebuf[8],"%d",&n_variants);
- }
- }
- languages[langix++] = 0;
-
- gender = LookupMnem(genders,vgender);
-
- if(n_languages == 0)
- {
- return(NULL); // no language lines in the voice file
- }
-
- p = (char *)calloc(sizeof(espeak_VOICE) + langix + strlen(fname) + strlen(vname) + 3, 1);
- voice_data = (espeak_VOICE *)p;
- p = &p[sizeof(espeak_VOICE)];
-
- memcpy(p,languages,langix);
- voice_data->languages = p;
-
- strcpy(&p[langix],fname);
- voice_data->identifier = &p[langix];
- voice_data->name = &p[langix];
-
- if(vname[0] != 0)
- {
- langix += strlen(fname)+1;
- strcpy(&p[langix],vname);
- voice_data->name = &p[langix];
- }
-
- voice_data->age = age;
- voice_data->gender = gender;
- voice_data->variant = 0;
- voice_data->xx1 = n_variants;
- return(voice_data);
-} // end of ReadVoiceFile
-
-
-
-
-void VoiceReset(int tone_only)
-{//===========================
-// Set voice to the default values
-
- int pk;
- static unsigned char default_heights[N_PEAKS] = {128,128,120,120,110,110,128,128,128};
- static unsigned char default_widths[N_PEAKS] = {128,128,128,160,171,171,128,128,128};
-
- static int breath_widths[N_PEAKS] = {0,200,200,400,400,400,600,600,600};
-
- // default is: pitch 82,118
-// voice->pitch_base = 0x49000; // default, 73 << 12;
-// voice->pitch_range = 0x0f30; // default = 0x1000
- voice->pitch_base = 0x47000;
- voice->pitch_range = 3996;
-
- voice->formant_factor = 256;
-
- voice->echo_delay = 0;
- voice->echo_amp = 0;
- voice->flutter = 64;
- voice->n_harmonic_peaks = 5;
- voice->peak_shape = 0;
- voice->voicing = 64;
- voice->consonant_amp = 100;
- voice->consonant_ampv = 100;
- memset(voice->klattv,0,sizeof(voice->klattv));
- memset(speed.fast_settings,0,sizeof(speed.fast_settings));
-
-#ifdef PLATFORM_RISCOS
- voice->roughness = 1;
-#else
- voice->roughness = 2;
-#endif
-
- InitBreath();
- for(pk=0; pk<N_PEAKS; pk++)
- {
- voice->freq[pk] = 256;
- voice->height[pk] = default_heights[pk]*2;
- voice->width[pk] = default_widths[pk]*2;
- voice->breath[pk] = 0;
- voice->breathw[pk] = breath_widths[pk]; // default breath formant woidths
- voice->freqadd[pk] = 0;
-
- // adjust formant smoothing depending on sample rate
- formant_rate[pk] = (formant_rate_22050[pk] * 22050)/samplerate;
- }
- voice->height[2] = 240; // reduce F2 slightly
-
- // This table provides the opportunity for tone control.
- // Adjustment of harmonic amplitudes, steps of 8Hz
- // value of 128 means no change
-// memset(voice->tone_adjust,128,sizeof(voice->tone_adjust));
-SetToneAdjust(voice,tone_points);
-
- // default values of speed factors
- voice->speedf1 = 256;
- voice->speedf2 = 238;
- voice->speedf3 = 232;
-
- if(tone_only == 0)
- {
- n_replace_phonemes = 0;
- option_quiet = 0;
- LoadMbrolaTable(NULL,NULL,0);
- }
-} // end of VoiceReset
-
-
-static void VoiceFormant(char *p)
-{//==============================
- // Set parameters for a formant
- int ix;
- int formant;
- int freq = 100;
- int height = 100;
- int width = 100;
- int freqadd = 0;
-
- ix = sscanf(p,"%d %d %d %d %d",&formant,&freq,&height,&width,&freqadd);
- if(ix < 2)
- return;
-
- if((formant < 0) || (formant > 8))
- return;
-
- if(freq >= 0)
- voice->freq[formant] = int(freq * 2.56001);
- if(height >= 0)
- voice->height[formant] = int(height * 2.56001);
- if(width >= 0)
- voice->width[formant] = int(width * 2.56001);
- voice->freqadd[formant] = freqadd;
-}
-
-
-
-
-
-static void PhonemeReplacement(int type, char *p)
-{//==============================================
- int n;
- int phon;
- int flags = 0;
- char phon_string1[12];
- char phon_string2[12];
-
- strcpy(phon_string2,"NULL");
- n = sscanf(p,"%d %s %s",&flags,phon_string1,phon_string2);
- if((n < 2) || (n_replace_phonemes >= N_REPLACE_PHONEMES))
- return;
-
- if((phon = LookupPhonemeString(phon_string1)) == 0)
- return; // not recognised
-
- replace_phonemes[n_replace_phonemes].old_ph = phon;
- replace_phonemes[n_replace_phonemes].new_ph = LookupPhonemeString(phon_string2);
- replace_phonemes[n_replace_phonemes++].type = flags;
-} // end of PhonemeReplacement
-
-
-
-static int Read8Numbers(char *data_in,int *data)
-{//=============================================
-// Read 8 integer numbers
- return(sscanf(data_in,"%d %d %d %d %d %d %d %d",
- &data[0],&data[1],&data[2],&data[3],&data[4],&data[5],&data[6],&data[7]));
-}
-
-
-voice_t *LoadVoice(const char *vname, int control)
-{//===============================================
-// control, bit 0 1= no_default
-// bit 1 1 = change tone only, not language
-// bit 2 1 = don't report error on LoadDictionary
-// bit 4 1 = vname = full path
-
- FILE *f_voice = NULL;
- keywtab_t *k;
- char *p;
- int key;
- int ix;
- int n;
- int value;
- int error = 0;
- int langix = 0;
- int tone_only = control & 2;
- int language_set = 0;
- int phonemes_set = 0;
- int stress_amps_set = 0;
- int stress_lengths_set = 0;
- int stress_add_set = 0;
- int conditional_rules = 0;
- LANGUAGE_OPTIONS *langopts = NULL;
-
- Translator *new_translator = NULL;
-
- char voicename[40];
- char language_name[40];
- char translator_name[40];
- char new_dictionary[40];
- char phonemes_name[40];
- const char *language_type;
- char buf[200];
- char path_voices[sizeof(path_home)+12];
- char langname[4];
-
- int stress_amps[8];
- int stress_lengths[8];
- int stress_add[8];
-
- int pitch1;
- int pitch2;
-
- static char voice_identifier[40]; // file name for voice_selected
- static char voice_name[40]; // voice name for voice_selected
- static char voice_languages[100]; // list of languages and priorities for voice_selected
-
- strcpy(voicename,vname);
- if(voicename[0]==0)
- strcpy(voicename,"default");
-
- if(control & 0x10)
- {
- strcpy(buf,vname);
- if(GetFileLength(buf) <= 0)
- return(NULL);
- }
- else
- {
- sprintf(path_voices,"%s%cvoices%c",path_home,PATHSEP,PATHSEP);
- sprintf(buf,"%s%s",path_voices,voicename);
-
- if(GetFileLength(buf) <= 0)
- {
- // look for the voice in a sub-directory of the language name
- langname[0] = voicename[0];
- langname[1] = voicename[1];
- langname[2] = 0;
- sprintf(buf,"%s%s%c%s",path_voices,langname,PATHSEP,voicename);
-
- if(GetFileLength(buf) <= 0)
- {
- // look in "test" sub-directory
- sprintf(buf,"%stest%c%s",path_voices,PATHSEP,voicename);
- }
- }
- }
-
- f_voice = fopen(buf,"r");
-
- language_type = "en"; // default
- if(f_voice == NULL)
- {
- if(control & 3)
- return(NULL); // can't open file
-
- if(SelectPhonemeTableName(voicename) >= 0)
- language_type = voicename;
- }
-
- if(!tone_only && (translator != NULL))
- {
- DeleteTranslator(translator);
- translator = NULL;
- }
-
- strcpy(translator_name,language_type);
- strcpy(new_dictionary,language_type);
- strcpy(phonemes_name,language_type);
-
-
- if(!tone_only)
- {
- voice = &voicedata;
- strncpy0(voice_identifier,vname,sizeof(voice_identifier));
- voice_name[0] = 0;
- voice_languages[0] = 0;
-
- voice_selected.identifier = voice_identifier;
- voice_selected.name = voice_name;
- voice_selected.languages = voice_languages;
- }
- else
- {
- // append the variant file name to the voice identifier
- if((p = strchr(voice_identifier,'+')) != NULL)
- *p = 0; // remove previous variant name
- sprintf(buf,"+%s",&vname[3]); // omit !v/ from the variant filename
- strcat(voice_identifier,buf);
- langopts = &translator->langopts;
- }
- VoiceReset(tone_only);
-
- if(!tone_only)
- SelectPhonemeTableName(phonemes_name); // set up phoneme_tab
-
-
- while((f_voice != NULL) && (fgets_strip(buf,sizeof(buf),f_voice) != NULL))
- {
- // isolate the attribute name
- for(p=buf; (*p != 0) && !isspace(*p); p++);
- *p++ = 0;
-
- if(buf[0] == 0) continue;
-
- key = 0;
- for(k=keyword_tab; k->mnem != NULL; k++)
- {
- if(strcmp(buf,k->mnem)==0)
- {
- key = k->data;
- break;
- }
- }
-
- switch(key)
- {
- case V_LANGUAGE:
- {
- unsigned int len;
- int priority;
-
- if(tone_only)
- break;
-
- priority = DEFAULT_LANGUAGE_PRIORITY;
- language_name[0] = 0;
-
- sscanf(p,"%s %d",language_name,&priority);
- if(strcmp(language_name,"variant") == 0)
- break;
-
- len = strlen(language_name) + 2;
- // check for space in languages[]
- if(len < (sizeof(voice_languages)-langix-1))
- {
- voice_languages[langix] = priority;
-
- strcpy(&voice_languages[langix+1],language_name);
- langix += len;
- }
-
- // only act on the first language line
- if(language_set == 0)
- {
- language_type = strtok(language_name,"-");
- language_set = 1;
- strcpy(translator_name,language_type);
- strcpy(new_dictionary,language_type);
- strcpy(phonemes_name,language_type);
- SelectPhonemeTableName(phonemes_name);
-
- if(new_translator != NULL)
- DeleteTranslator(new_translator);
-
- new_translator = SelectTranslator(translator_name);
- langopts = &new_translator->langopts;
- }
- }
- break;
-
- case V_NAME:
- if(tone_only == 0)
- {
- while(isspace(*p)) p++;
- strncpy0(voice_name,p,sizeof(voice_name));
- }
- break;
-
- case V_GENDER:
- {
- int age;
- char vgender[80];
- sscanf(p,"%s %d",vgender,&age);
- voice_selected.gender = LookupMnem(genders,vgender);
- voice_selected.age = age;
- }
- break;
-
- case V_TRANSLATOR:
- if(tone_only) break;
-
- sscanf(p,"%s",translator_name);
-
- if(new_translator != NULL)
- DeleteTranslator(new_translator);
-
- new_translator = SelectTranslator(translator_name);
- langopts = &new_translator->langopts;
- break;
-
- case V_DICTIONARY: // dictionary
- sscanf(p,"%s",new_dictionary);
- break;
-
- case V_PHONEMES: // phoneme table
- sscanf(p,"%s",phonemes_name);
- break;
-
- case V_FORMANT:
- VoiceFormant(p);
- break;
-
- case V_PITCH:
- {
- double factor;
- // default is pitch 82 118
- n = sscanf(p,"%d %d",&pitch1,&pitch2);
- voice->pitch_base = (pitch1 - 9) << 12;
- voice->pitch_range = (pitch2 - pitch1) * 108;
- factor = double(pitch1 - 82)/82;
- voice->formant_factor = (int)((1+factor/4) * 256); // nominal formant shift for a different voice pitch
- }
- break;
-
- case V_STRESSLENGTH: // stressLength
- stress_lengths_set = Read8Numbers(p,stress_lengths);
- break;
-
- case V_STRESSAMP: // stressAmp
- stress_amps_set = Read8Numbers(p,stress_amps);
- break;
-
- case V_STRESSADD: // stressAdd
- stress_add_set = Read8Numbers(p,stress_add);
- break;
-
- case V_INTONATION: // intonation
- sscanf(p,"%d %d",&option_tone_flags,&option_tone2);
- if((option_tone_flags & 0xff) != 0)
- langopts->intonation_group = option_tone_flags & 0xff;
- break;
-
- case V_DICTRULES: // conditional dictionary rules and list entries
- while(*p != 0)
- {
- while(isspace(*p)) p++;
- n = -1;
- if(((n = atoi(p)) > 0) && (n < 32))
- {
- p++;
- conditional_rules |= (1 << n);
- }
- while(isalnum(*p)) p++;
- }
- break;
-
- case V_REPLACE:
- if(phonemes_set == 0)
- {
- // must set up a phoneme table before we can lookup phoneme mnemonics
- SelectPhonemeTableName(phonemes_name);
- phonemes_set = 1;
- }
- PhonemeReplacement(key,p);
- break;
-
- case V_WORDGAP: // words
- sscanf(p,"%d %d",&langopts->word_gap, &langopts->vowel_pause);
- break;
-
- case V_STRESSRULE:
- sscanf(p,"%d %d %d %d",&langopts->stress_rule,
- &langopts->stress_flags,
- &langopts->unstressed_wd1,
- &langopts->unstressed_wd2);
- break;
-
- case V_CHARSET:
- if((sscanf(p,"%d",&value)==1) && (value < N_CHARSETS))
- new_translator->charset_a0 = charsets[value];
- break;
-
- case V_NUMBERS:
- sscanf(p,"%d %d",&langopts->numbers,&langopts->numbers2);
- break;
-
- case V_OPTION:
- if(sscanf(p,"%d %d",&ix,&value) == 2)
- {
- if((ix >= 0) && (ix < N_LOPTS))
- langopts->param[ix] = value;
- }
- break;
-
- case V_ECHO:
- // echo. suggest: 135mS 11%
- value = 0;
- voice->echo_amp = 0;
- sscanf(p,"%d %d",&voice->echo_delay,&voice->echo_amp);
- break;
-
- case V_FLUTTER: // flutter
- if(sscanf(p,"%d",&value)==1)
- voice->flutter = value * 32;
- break;
-
- case V_ROUGHNESS: // roughness
- if(sscanf(p,"%d",&value)==1)
- voice->roughness = value;
- break;
-
- case V_CLARITY: // formantshape
- if(sscanf(p,"%d",&value)==1)
- {
- if(value > 4)
- {
- voice->peak_shape = 1; // squarer formant peaks
- value = 4;
- }
- voice->n_harmonic_peaks = 1+value;
- }
- break;
-
- case V_TONE:
- {
- int tone_data[12];
- ReadTonePoints(p,tone_data);
- SetToneAdjust(voice,tone_data);
- }
- break;
-
- case V_VOICING:
- if(sscanf(p,"%d",&value)==1)
- voice->voicing = (value * 64)/100;
- break;
-
- case V_BREATH:
- voice->breath[0] = Read8Numbers(p,&voice->breath[1]);
- for(ix=1; ix<8; ix++)
- {
- if(ix % 2)
- voice->breath[ix] = -voice->breath[ix];
- }
- break;
-
- case V_BREATHW:
- voice->breathw[0] = Read8Numbers(p,&voice->breathw[1]);
- break;
-
- case V_CONSONANTS:
- value = sscanf(p,"%d %d",&voice->consonant_amp, &voice->consonant_ampv);
- break;
-
- case V_MBROLA:
- {
- int srate = 16000;
- char name[40];
- char phtrans[40];
-
- phtrans[0] = 0;
- sscanf(p,"%s %s %d",name,phtrans,&srate);
- LoadMbrolaTable(name,phtrans,srate);
- }
- break;
-
- case V_KLATT:
- voice->klattv[0] = 1; // default source: IMPULSIVE
- Read8Numbers(p,voice->klattv);
- voice->klattv[KLATT_Kopen] -= 40;
- break;
-
- case V_FAST:
- Read8Numbers(p,speed.fast_settings);
- SetSpeed(2);
- break;
-
- default:
- if((key & 0xff00) == 0x100)
- {
- sscanf(p,"%d",&langopts->param[key &0xff]);
- }
- else
- {
- fprintf(stderr,"Bad voice attribute: %s\n",buf);
- }
- break;
- }
- }
- if(f_voice != NULL)
- fclose(f_voice);
-
- if((new_translator == NULL) && (!tone_only))
- {
- // not set by language attribute
- new_translator = SelectTranslator(translator_name);
- }
-
- for(ix=0; ix<N_PEAKS; ix++)
- {
- voice->freq2[ix] = voice->freq[ix];
- voice->height2[ix] = voice->height[ix];
- voice->width2[ix] = voice->width[ix];
- }
-
- if(tone_only)
- {
- new_translator = translator;
- }
- else
- {
- if((ix = SelectPhonemeTableName(phonemes_name)) < 0)
- {
- fprintf(stderr,"Unknown phoneme table: '%s'\n",phonemes_name);
- }
- voice->phoneme_tab_ix = ix;
- error = LoadDictionary(new_translator, new_dictionary, control & 4);
- if(dictionary_name[0]==0)
- return(NULL); // no dictionary loaded
-
- new_translator->dict_condition = conditional_rules;
-
- voice_languages[langix] = 0;
- }
-
- langopts = &new_translator->langopts;
-
-
- if((value = langopts->param[LOPT_LENGTH_MODS]) != 0)
- {
- SetLengthMods(new_translator,value);
- }
-
- voice->width[0] = (voice->width[0] * 105)/100;
-
- if(!tone_only)
- {
- translator = new_translator;
- }
-
- // relative lengths of different stress syllables
- for(ix=0; ix<stress_lengths_set; ix++)
- {
- translator->stress_lengths[ix] = stress_lengths[ix];
- }
- for(ix=0; ix<stress_add_set; ix++)
- {
- translator->stress_lengths[ix] += stress_add[ix];
- }
- for(ix=0; ix<stress_amps_set; ix++)
- {
- translator->stress_amps[ix] = stress_amps[ix];
- translator->stress_amps_r[ix] = stress_amps[ix] -1;
- }
-
- return(voice);
-} // end of LoadVoice
-
-
-static char *ExtractVoiceVariantName(char *vname, int variant_num)
-{//===============================================================
-// Remove any voice variant suffix (name or number) from a voice name
-// Returns the voice variant name
-
- char *p;
- static char variant_name[20];
- char variant_prefix[5];
-
- variant_name[0] = 0;
- sprintf(variant_prefix,"!v%c",PATHSEP);
-
- if(vname != NULL)
- {
- if((p = strchr(vname,'+')) != NULL)
- {
- // The voice name has a +variant suffix
- *p++ = 0; // delete the suffix from the voice name
- if(isdigit(*p))
- {
- variant_num = atoi(p); // variant number
- }
- else
- {
- // voice variant name, not number
- strcpy(variant_name,variant_prefix);
- strncpy0(&variant_name[3],p,sizeof(variant_name)-3);
- }
- }
- }
-
- if(variant_num > 0)
- {
- if(variant_num < 10)
- sprintf(variant_name,"%sm%d",variant_prefix, variant_num); // male
- else
- sprintf(variant_name,"%sf%d",variant_prefix, variant_num-10); // female
- }
-
- return(variant_name);
-} // end of ExtractVoiceVariantName
-
-
-
-voice_t *LoadVoiceVariant(const char *vname, int variant_num)
-{//==========================================================
-// Load a voice file.
-// Also apply a voice variant if specified by "variant", or by "+number" or "+name" in the "vname"
-
- voice_t *v;
- char *variant_name;
- char buf[60];
-
- strncpy0(buf,vname,sizeof(buf));
- variant_name = ExtractVoiceVariantName(buf,variant_num);
-
- if((v = LoadVoice(buf,0)) == NULL)
- return(NULL);
-
- if(variant_name[0] != 0)
- {
- v = LoadVoice(variant_name,2);
- }
- return(v);
-}
-
-
-
-static int __cdecl VoiceNameSorter(const void *p1, const void *p2)
-{//=======================================================
- int ix;
- espeak_VOICE *v1 = *(espeak_VOICE **)p1;
- espeak_VOICE *v2 = *(espeak_VOICE **)p2;
-
-
- if((ix = strcmp(&v1->languages[1],&v2->languages[1])) != 0) // primary language name
- return(ix);
- if((ix = v1->languages[0] - v2->languages[0]) != 0) // priority number
- return(ix);
- return(strcmp(v1->name,v2->name));
-}
-
-
-static int __cdecl VoiceScoreSorter(const void *p1, const void *p2)
-{//========================================================
- int ix;
- espeak_VOICE *v1 = *(espeak_VOICE **)p1;
- espeak_VOICE *v2 = *(espeak_VOICE **)p2;
-
- if((ix = v2->score - v1->score) != 0)
- return(ix);
- return(strcmp(v1->name,v2->name));
-}
-
-
-static int ScoreVoice(espeak_VOICE *voice_spec, const char *spec_language, int spec_n_parts, int spec_lang_len, espeak_VOICE *voice)
-{//=========================================================================================================================
- int ix;
- const char *p;
- int c1, c2;
- int language_priority;
- int n_parts;
- int matching;
- int matching_parts;
- int score = 0;
- int x;
- int ratio;
- int required_age;
- int diff;
-
- p = voice->languages; // list of languages+dialects for which this voice is suitable
-
- if(strcmp(spec_language,"mbrola")==0)
- {
- // only list mbrola voices
- if(memcmp(voice->identifier,"mb/",3) == 0)
- return(100);
- return(0);
- }
-
- if(spec_n_parts == 0)
- {
- score = 100;
- }
- else
- {
- if((*p == 0) && (strcmp(spec_language,"variants")==0))
- {
- // match on a voice with no languages if the required language is "variants"
- score = 100;
- }
-
- // compare the required language with each of the languages of this voice
- while(*p != 0)
- {
- language_priority = *p++;
-
- matching = 1;
- matching_parts = 0;
- n_parts = 1;
-
- for(ix=0; ; ix++)
- {
- if((ix >= spec_lang_len) || ((c1 = spec_language[ix]) == '-'))
- c1 = 0;
- if((c2 = p[ix]) == '-')
- c2 = 0;
-
- if(c1 != c2)
- {
- matching = 0;
- }
-
- if(p[ix] == '-')
- {
- n_parts++;
- if(matching)
- matching_parts++;
- }
- if(p[ix] == 0)
- break;
- }
- p += (ix+1);
- matching_parts += matching; // number of parts which match
-
- if(matching_parts == 0)
- continue; // no matching parts for this language
-
- x = 5;
- // reduce the score if not all parts of the required language match
- if((diff = (spec_n_parts - matching_parts)) > 0)
- x -= diff;
-
- // reduce score if the language is more specific than required
- if((diff = (n_parts - matching_parts)) > 0)
- x -= diff;
-
- x = x*100 - (language_priority * 2);
-
- if(x > score)
- score = x;
- }
- }
- if(score == 0)
- return(0);
-
- if(voice_spec->name != NULL)
- {
- if(strcmp(voice_spec->name,voice->name)==0)
- {
- // match on voice name
- score += 500;
- }
- else
- if(strcmp(voice_spec->name,voice->identifier)==0)
- {
- score += 400;
- }
- }
-
- if(((voice_spec->gender == 1) || (voice_spec->gender == 2)) &&
- ((voice->gender == 1) || (voice->gender == 2)))
- {
- if(voice_spec->gender == voice->gender)
- score += 50;
- else
- score -= 50;
- }
-
- if((voice_spec->age <= 12) && (voice->gender == 2) && (voice->age > 12))
- {
- score += 5; // give some preference for non-child female voice if a child is requested
- }
-
- if(voice->age != 0)
- {
- if(voice_spec->age == 0)
- required_age = 30;
- else
- required_age = voice_spec->age;
-
- ratio = (required_age*100)/voice->age;
- if(ratio < 100)
- ratio = 10000/ratio;
- ratio = (ratio - 100)/10; // 0=exact match, 10=out by factor of 2
- x = 5 - ratio;
- if(x > 0) x = 0;
-
- score = score + x;
-
- if(voice_spec->age > 0)
- score += 10; // required age specified, favour voices with a specified age (near it)
- }
- if(score < 1)
- score = 1;
- return(score);
-} // end of ScoreVoice
-
-
-static int SetVoiceScores(espeak_VOICE *voice_select, espeak_VOICE **voices, int control)
-{//======================================================================================
-// control: bit0=1 include mbrola voices
- int ix;
- int score;
- int nv; // number of candidates
- int n_parts=0;
- int lang_len=0;
- espeak_VOICE *vp;
- char language[80];
-
- // count number of parts in the specified language
- if((voice_select->languages != NULL) && (voice_select->languages[0] != 0))
- {
- n_parts = 1;
- lang_len = strlen(voice_select->languages);
- for(ix=0; (ix<=lang_len) && ((unsigned)ix < sizeof(language)); ix++)
- {
- if((language[ix] = tolower(voice_select->languages[ix])) == '-')
- n_parts++;
- }
- }
- // select those voices which match the specified language
- nv = 0;
- for(ix=0; ix<n_voices_list; ix++)
- {
- vp = voices_list[ix];
-
- if(((control & 1) == 0) && (memcmp(vp->identifier,"mb/",3) == 0))
- continue;
-
- if((score = ScoreVoice(voice_select, language, n_parts, lang_len, voices_list[ix])) > 0)
- {
- voices[nv++] = vp;
- vp->score = score;
- }
- }
- voices[nv] = NULL; // list terminator
-
- if(nv==0)
- return(0);
-
- // sort the selected voices by their score
- qsort(voices,nv,sizeof(espeak_VOICE *),VoiceScoreSorter);
-
- return(nv);
-} // end of SetVoiceScores
-
-
-
-
-espeak_VOICE *SelectVoiceByName(espeak_VOICE **voices, const char *name)
-{//=====================================================================
- int ix;
- int match_fname = -1;
- int match_fname2 = -1;
- int match_name = -1;
- const char *id;
- int last_part_len;
- char last_part[41];
-
- if(voices == NULL)
- {
- if(n_voices_list == 0)
- espeak_ListVoices(NULL); // create the voices list
- voices = voices_list;
- }
-
- sprintf(last_part,"%c%s",PATHSEP,name);
- last_part_len = strlen(last_part);
-
- for(ix=0; voices[ix] != NULL; ix++)
- {
- if(strcmp(name,voices[ix]->name)==0)
- {
- match_name = ix; // found matching voice name
- break;
- }
- else
- if(strcmp(name,id = voices[ix]->identifier)==0)
- {
- match_fname = ix; // matching identifier, use this if no matching name
- }
- else
- if(strcmp(last_part,&id[strlen(id)-last_part_len])==0)
- {
- match_fname2 = ix;
- }
- }
-
- if(match_name < 0)
- {
- match_name = match_fname; // no matching name, try matching filename
- if(match_name < 0)
- match_name = match_fname2; // try matching just the last part of the filename
- }
-
- if(match_name < 0)
- return(NULL);
-
- return(voices[match_name]);
-} // end of SelectVoiceByName
-
-
-
-
-char const *SelectVoice(espeak_VOICE *voice_select, int *found)
-{//============================================================
-// Returns a path within espeak-voices, with a possible +variant suffix
-// variant is an output-only parameter
- int nv; // number of candidates
- int ix, ix2;
- int j;
- int n_variants;
- int variant_number;
- int gender;
- int skip;
- int aged=1;
- char *variant_name;
- const char *p, *p_start;
- espeak_VOICE *vp = NULL;
- espeak_VOICE *vp2;
- espeak_VOICE voice_select2;
- espeak_VOICE *voices[N_VOICES_LIST]; // list of candidates
- espeak_VOICE *voices2[N_VOICES_LIST+N_VOICE_VARIANTS];
- static espeak_VOICE voice_variants[N_VOICE_VARIANTS];
- static char voice_id[50];
-
- *found = 1;
- memcpy(&voice_select2,voice_select,sizeof(voice_select2));
-
- if(n_voices_list == 0)
- espeak_ListVoices(NULL); // create the voices list
-
- if((voice_select2.languages == NULL) || (voice_select2.languages[0] == 0))
- {
- // no language is specified. Get language from the named voice
- static char buf[60];
-
- if(voice_select2.name == NULL)
- {
- if((voice_select2.name = voice_select2.identifier) == NULL)
- voice_select2.name = "default";
- }
-
- strncpy0(buf,voice_select2.name,sizeof(buf));
- variant_name = ExtractVoiceVariantName(buf,0);
-
- vp = SelectVoiceByName(voices_list,buf);
- if(vp != NULL)
- {
- voice_select2.languages = &(vp->languages[1]);
-
- if((voice_select2.gender==0) && (voice_select2.age==0) && (voice_select2.variant==0))
- {
- if(variant_name[0] != 0)
- {
- sprintf(voice_id,"%s+%s",vp->identifier,&variant_name[3]); // omit the !v/ from variant_name
- return(voice_id);
- }
-
- return(vp->identifier);
- }
- }
- }
-
- // select and sort voices for the required language
- nv = SetVoiceScores(&voice_select2,voices,0);
-
- if(nv == 0)
- {
- // no matching voice, choose the default
- *found = 0;
- if((voices[0] = SelectVoiceByName(voices_list,"default")) != NULL)
- nv = 1;
- }
-
- gender = 0;
- if((voice_select2.gender == 2) || ((voice_select2.age > 0) && (voice_select2.age < 13)))
- gender = 2;
- else
- if(voice_select2.gender == 1)
- gender = 1;
-
-#define AGE_OLD 60
- if(voice_select2.age < AGE_OLD)
- aged = 0;
-
- p = p_start = variant_lists[gender];
- if(aged == 0)
- p++; // the first voice in the variants list is older
-
- // add variants for the top voices
- n_variants = 0;
- for(ix=0, ix2=0; ix<nv; ix++)
- {
- vp = voices[ix];
- // is the main voice the required gender?
- skip=0;
- if((gender != 0) && (vp->gender != gender))
- {
- skip=1;
- }
- if((ix2==0) && aged && (vp->age < AGE_OLD))
- {
- skip=1;
- }
- if(skip==0)
- {
- voices2[ix2++] = vp;
- }
-
- for(j=0; (j < vp->xx1) && (n_variants < N_VOICE_VARIANTS);)
- {
- if((variant_number = *p) == 0)
- {
- p = p_start;
- continue;
- }
-
- vp2 = &voice_variants[n_variants++]; // allocate space for voice variant
- memcpy(vp2,vp,sizeof(espeak_VOICE)); // copy from the original voice
- vp2->variant = variant_number;
- voices2[ix2++] = vp2;
- p++;
- j++;
- }
- }
- // add any more variants to the end of the list
- while((vp != NULL) && ((variant_number = *p++) != 0) && (n_variants < N_VOICE_VARIANTS))
- {
- vp2 = &voice_variants[n_variants++]; // allocate space for voice variant
- memcpy(vp2,vp,sizeof(espeak_VOICE)); // copy from the original voice
- vp2->variant = variant_number;
- voices2[ix2++] = vp2;
- }
-
- // index the sorted list by the required variant number
- vp = voices2[voice_select2.variant % ix2];
-
- if(vp->variant != 0)
- {
- variant_name = ExtractVoiceVariantName(NULL,vp->variant);
- sprintf(voice_id,"%s+%s",vp->identifier,&variant_name[3]);
- return(voice_id);
- }
-
- return(vp->identifier);
-} // end of SelectVoice
-
-
-
-static void GetVoices(const char *path)
-{//====================================
- FILE *f_voice;
- espeak_VOICE *voice_data;
- int ftype;
- char fname[sizeof(path_home)+100];
-
-#ifdef PLATFORM_RISCOS
- int len;
- int *type;
- char *p;
- _kernel_swi_regs regs;
- _kernel_oserror *error;
- char buf[80];
- char directory2[sizeof(path_home)+100];
-
- regs.r[0] = 10;
- regs.r[1] = (int)path;
- regs.r[2] = (int)buf;
- regs.r[3] = 1;
- regs.r[4] = 0;
- regs.r[5] = sizeof(buf);
- regs.r[6] = 0;
-
- while(regs.r[3] > 0)
- {
- error = _kernel_swi(0x0c+0x20000,&regs,&regs); /* OS_GBPB 10, read directory entries */
- if((error != NULL) || (regs.r[3] == 0))
- {
- break;
- }
- type = (int *)(&buf[16]);
- len = strlen(&buf[20]);
- sprintf(fname,"%s.%s",path,&buf[20]);
-
- if(*type == 2)
- {
- // a sub-directory
- GetVoices(fname);
- }
- else
- {
- // a regular line, add it to the voices list
- if((f_voice = fopen(fname,"r")) == NULL)
- continue;
-
- // pass voice file name within the voices directory
- voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, &buf[20]);
- fclose(f_voice);
-
- if(voice_data != NULL)
- {
- voices_list[n_voices_list++] = voice_data;
- }
- }
- }
-#else
-#ifdef PLATFORM_WINDOWS
- WIN32_FIND_DATAA FindFileData;
- HANDLE hFind = INVALID_HANDLE_VALUE;
-
-#undef UNICODE // we need FindFirstFileA() which takes an 8-bit c-string
- sprintf(fname,"%s\\*",path);
- hFind = FindFirstFileA(fname, &FindFileData);
- if(hFind == INVALID_HANDLE_VALUE)
- return;
-
- do {
- sprintf(fname,"%s%c%s",path,PATHSEP,FindFileData.cFileName);
-
- ftype = GetFileLength(fname);
-
- if((ftype == -2) && (FindFileData.cFileName[0] != '.'))
- {
- // a sub-sirectory
- GetVoices(fname);
- }
- else
- if(ftype > 0)
- {
- // a regular line, add it to the voices list
- if((f_voice = fopen(fname,"r")) == NULL)
- continue;
-
- // pass voice file name within the voices directory
- voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, FindFileData.cFileName);
- fclose(f_voice);
-
- if(voice_data != NULL)
- {
- voices_list[n_voices_list++] = voice_data;
- }
- }
- } while(FindNextFileA(hFind, &FindFileData) != 0);
- FindClose(hFind);
-
-#else
- DIR *dir;
- struct dirent *ent;
-
- if((dir = opendir((char *)path)) == NULL) // note: (char *) is needed for WINCE
- return;
-
- while((ent = readdir(dir)) != NULL)
- {
- if(n_voices_list >= (N_VOICES_LIST-2))
- break; // voices list is full
-
- sprintf(fname,"%s%c%s",path,PATHSEP,ent->d_name);
-
- ftype = GetFileLength(fname);
-
- if((ftype == -2) && (ent->d_name[0] != '.'))
- {
- // a sub-sirectory
- GetVoices(fname);
- }
- else
- if(ftype > 0)
- {
- // a regular line, add it to the voices list
- if((f_voice = fopen(fname,"r")) == NULL)
- continue;
-
- // pass voice file name within the voices directory
- voice_data = ReadVoiceFile(f_voice, fname+len_path_voices, ent->d_name);
- fclose(f_voice);
-
- if(voice_data != NULL)
- {
- voices_list[n_voices_list++] = voice_data;
- }
- }
- }
- closedir(dir);
-#endif
-#endif
-} // end of GetVoices
-
-
-
-espeak_ERROR SetVoiceByName(const char *name)
-{//=========================================
- espeak_VOICE *v;
- espeak_VOICE voice_selector;
- char *variant_name;
- static char buf[60];
-
- strncpy0(buf,name,sizeof(buf));
- variant_name = ExtractVoiceVariantName(buf,0);
-
- memset(&voice_selector,0,sizeof(voice_selector));
-// voice_selector.name = buf;
- voice_selector.name = (char *)name; // include variant name in voice stack ??
-
- // first check for a voice with this filename
- // This may avoid the need to call espeak_ListVoices().
-
- if(LoadVoice(buf,1) != NULL)
- {
- if(variant_name[0] != 0)
- {
- LoadVoice(variant_name,2);
- }
-
- DoVoiceChange(voice);
- SetVoiceStack(&voice_selector);
- return(EE_OK);
- }
-
- if(n_voices_list == 0)
- espeak_ListVoices(NULL); // create the voices list
-
- if((v = SelectVoiceByName(voices_list,buf)) != NULL)
- {
- if(LoadVoice(v->identifier,0) != NULL)
- {
- if(variant_name[0] != 0)
- {
- LoadVoice(variant_name,2);
- }
- DoVoiceChange(voice);
- SetVoiceStack(&voice_selector);
- return(EE_OK);
- }
- }
- return(EE_INTERNAL_ERROR); // voice name not found
-} // end of SetVoiceByName
-
-
-
-espeak_ERROR SetVoiceByProperties(espeak_VOICE *voice_selector)
-{//============================================================
- const char *voice_id;
- int voice_found;
-
- voice_id = SelectVoice(voice_selector, &voice_found);
-
- if(voice_found == 0)
- return(EE_NOT_FOUND);
-
- LoadVoiceVariant(voice_id,0);
- DoVoiceChange(voice);
- SetVoiceStack(voice_selector);
-
- return(EE_OK);
-} // end of SetVoiceByProperties
-
-
-
-
-//=======================================================================
-// Library Interface Functions
-//=======================================================================
-#pragma GCC visibility push(default)
-
-
-const espeak_VOICE **espeak_ListVoices(espeak_VOICE *voice_spec)
-{//========================================================================
-#ifndef PLATFORM_RISCOS
- int ix;
- int j;
- espeak_VOICE *v;
- static espeak_VOICE *voices[N_VOICES_LIST];
- char path_voices[sizeof(path_home)+12];
-
- // free previous voice list data
-
- for(ix=0; ix<n_voices_list; ix++)
- {
- if(voices_list[ix] != NULL)
- free(voices_list[ix]);
- }
- n_voices_list = 0;
-
- sprintf(path_voices,"%s%cvoices",path_home,PATHSEP);
- len_path_voices = strlen(path_voices)+1;
-
- GetVoices(path_voices);
- voices_list[n_voices_list] = NULL; // voices list terminator
-
- // sort the voices list
- qsort(voices_list,n_voices_list,sizeof(espeak_VOICE *),VoiceNameSorter);
-
-
- if(voice_spec)
- {
- // select the voices which match the voice_spec, and sort them by preference
- SetVoiceScores(voice_spec,voices,1);
- }
- else
- {
- // list all: omit variant voices and mbrola voices
- j = 0;
- for(ix=0; (v = voices_list[ix]) != NULL; ix++)
- {
- if((v->languages[0] != 0) && (strcmp(&v->languages[1],"variant") != 0) && (memcmp(v->identifier,"mb/",3) != 0))
- {
- voices[j++] = v;
- }
- }
- voices[j] = NULL;
- }
- return((const espeak_VOICE **)voices);
-#endif
- return((const espeak_VOICE **)voices_list);
-} // end of espeak_ListVoices
-
-
-
-espeak_VOICE *espeak_GetCurrentVoice(void)
-{//==================================================
- return(&voice_selected);
-}
-
-#pragma GCC visibility pop
-
-
diff --git a/navit/support/espeak/wave.c b/navit/support/espeak/wave.c
deleted file mode 100755
index 364dcf577..000000000
--- a/navit/support/espeak/wave.c
+++ /dev/null
@@ -1,1112 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2007, Gilles Casse <gcasse@oralux.org> *
- * based on AudioIO.cc (Audacity-1.2.4b) and wavegen.cpp *
- * *
- * 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 3 of the License, 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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-#include "speech.h"
-
-#ifdef USE_ASYNC
-// This source file is only used for asynchronious modes
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-#include <assert.h>
-#include <sys/time.h>
-#include <time.h>
-
-#include "portaudio.h"
-#ifndef PLATFORM_WINDOWS
-#include <unistd.h>
-#endif
-#include "wave.h"
-#include "debug.h"
-
-//<Definitions
-
-enum {ONE_BILLION=1000000000};
-
-#ifdef USE_PORTAUDIO
-
-#undef USE_PORTAUDIO
-// determine portaudio version by looking for a #define which is not in V18
-#ifdef paNeverDropInput
-#define USE_PORTAUDIO 19
-#else
-#define USE_PORTAUDIO 18
-#endif
-
-
-static t_wave_callback* my_callback_is_output_enabled=NULL;
-
-#define N_WAV_BUF 10
-#define SAMPLE_RATE 22050
-#define FRAMES_PER_BUFFER 512
-#define BUFFER_LENGTH (SAMPLE_RATE*2*sizeof(uint16_t))
-#define THRESHOLD (BUFFER_LENGTH/5)
-static char myBuffer[BUFFER_LENGTH];
-static char* myRead=NULL;
-static char* myWrite=NULL;
-static int out_channels=1;
-static int my_stream_could_start=0;
-
-static int mInCallbackFinishedState = false;
-#if (USE_PORTAUDIO == 18)
-static PortAudioStream *pa_stream=NULL;
-#endif
-#if (USE_PORTAUDIO == 19)
-static struct PaStreamParameters myOutputParameters;
-static PaStream *pa_stream=NULL;
-#endif
-
-static int userdata[4];
-static PaError pa_init_err=0;
-
-// time measurement
-// The read and write position audio stream in the audio stream are measured in ms.
-//
-// * When the stream is opened, myReadPosition and myWritePosition are cleared.
-// * myWritePosition is updated in wave_write.
-// * myReadPosition is updated in pa_callback (+ sample delay).
-
-static uint32_t myReadPosition = 0; // in ms
-static uint32_t myWritePosition = 0;
-
-//>
-//<init_buffer, get_used_mem
-
-static void init_buffer()
-{
- myWrite = myBuffer;
- myRead = myBuffer;
- memset(myBuffer,0,BUFFER_LENGTH);
- myReadPosition = myWritePosition = 0;
- SHOW("init_buffer > myRead=0x%x, myWrite=0x%x, BUFFER_LENGTH=0x%x, myReadPosition = myWritePosition = 0\n", (int)myRead, (int)myWrite, BUFFER_LENGTH);
-}
-
-static unsigned int get_used_mem()
-{
- char* aRead = myRead;
- char* aWrite = myWrite;
- unsigned int used = 0;
-
- assert ((aRead >= myBuffer)
- && (aRead <= myBuffer + BUFFER_LENGTH)
- && (aWrite >= myBuffer)
- && (aWrite <= myBuffer + BUFFER_LENGTH));
-
- if (aRead < aWrite)
- {
- used = aWrite - aRead;
- }
- else
- {
- used = aWrite + BUFFER_LENGTH - aRead;
- }
- SHOW("get_used_mem > %d\n", used);
-
- return used;
-}
-
-//>
-//<start stream
-
-static void start_stream()
-{
- PaError err;
- SHOW_TIME("start_stream");
-
- my_stream_could_start=0;
- mInCallbackFinishedState = false;
-
- err = Pa_StartStream(pa_stream);
- SHOW("start_stream > Pa_StartStream=%d (%s)\n", err, Pa_GetErrorText(err));
-
-#if USE_PORTAUDIO == 19
- if(err == paStreamIsNotStopped)
- {
- SHOW_TIME("start_stream > restart stream (begin)");
- // not sure why we need this, but PA v19 seems to need it
- err = Pa_StopStream(pa_stream);
- SHOW("start_stream > Pa_StopStream=%d (%s)\n", err, Pa_GetErrorText(err));
- err = Pa_StartStream(pa_stream);
- SHOW("start_stream > Pa_StartStream=%d (%s)\n", err, Pa_GetErrorText(err));
- SHOW_TIME("start_stream > restart stream (end)");
- }
-#endif
-}
-
-//>
-//<pa_callback
-
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may called at interrupt level on some machines so don't do anything
-** that could mess up the system like calling malloc() or free().
-*/
-#if USE_PORTAUDIO == 18
-static int pa_callback(void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer, PaTimestamp outTime, void *userData )
-#else
- static int pa_callback(const void *inputBuffer, void *outputBuffer,
- long unsigned int framesPerBuffer, const PaStreamCallbackTimeInfo *outTime,
- PaStreamCallbackFlags flags, void *userData )
-#endif
-{
- int aResult=0; // paContinue
- char* aWrite = myWrite;
- size_t n = out_channels*sizeof(uint16_t)*framesPerBuffer;
-
- myReadPosition += framesPerBuffer;
- SHOW("pa_callback > myReadPosition=%u, framesPerBuffer=%lu (n=0x%x) \n",(int)myReadPosition, framesPerBuffer, n);
-
- if (aWrite >= myRead)
- {
- if((size_t)(aWrite - myRead) >= n)
- {
- memcpy(outputBuffer, myRead, n);
- myRead += n;
- }
- else
- {
- SHOW_TIME("pa_callback > underflow");
- aResult=1; // paComplete;
- mInCallbackFinishedState = true;
- size_t aUsedMem=0;
- aUsedMem = (size_t)(aWrite - myRead);
- if (aUsedMem)
- {
- memcpy(outputBuffer, myRead, aUsedMem);
- }
- char* p = (char*)outputBuffer + aUsedMem;
- memset(p, 0, n - aUsedMem);
- // myReadPosition += aUsedMem/(out_channels*sizeof(uint16_t));
- myRead = aWrite;
- }
- }
- else // myRead > aWrite
- {
- if ((size_t)(myBuffer + BUFFER_LENGTH - myRead) >= n)
- {
- memcpy(outputBuffer, myRead, n);
- myRead += n;
- }
- else if ((size_t)(aWrite + BUFFER_LENGTH - myRead) >= n)
- {
- int aTopMem = myBuffer + BUFFER_LENGTH - myRead;
- if (aTopMem)
- {
- SHOW("pa_callback > myRead=0x%x, aTopMem=0x%x\n",(int)myRead, (int)aTopMem);
- memcpy(outputBuffer, myRead, aTopMem);
- }
- int aRest = n - aTopMem;
- if (aRest)
- {
- SHOW("pa_callback > myRead=0x%x, aRest=0x%x\n",(int)myRead, (int)aRest);
- char* p = (char*)outputBuffer + aTopMem;
- memcpy(p, myBuffer, aRest);
- }
- myRead = myBuffer + aRest;
- }
- else
- {
- SHOW_TIME("pa_callback > underflow");
- aResult=1; // paComplete;
-
- int aTopMem = myBuffer + BUFFER_LENGTH - myRead;
- if (aTopMem)
- {
- SHOW("pa_callback > myRead=0x%x, aTopMem=0x%x\n",(int)myRead, (int)aTopMem);
- memcpy(outputBuffer, myRead, aTopMem);
- }
- int aRest = aWrite - myBuffer;
- if (aRest)
- {
- SHOW("pa_callback > myRead=0x%x, aRest=0x%x\n",(int)myRead, (int)aRest);
- char* p = (char*)outputBuffer + aTopMem;
- memcpy(p, myBuffer, aRest);
- }
-
- size_t aUsedMem = aTopMem + aRest;
- char* p = (char*)outputBuffer + aUsedMem;
- memset(p, 0, n - aUsedMem);
- // myReadPosition += aUsedMem/(out_channels*sizeof(uint16_t));
- myRead = aWrite;
- }
- }
-
- SHOW("pa_callback > myRead=%x\n",(int)myRead);
-
-
- // #if USE_PORTAUDIO == 18
- // if(aBufferEmpty)
- // {
- // static int end_timer = 0;
- // if(end_timer == 0)
- // end_timer = 4;
- // if(end_timer > 0)
- // {
- // end_timer--;
- // if(end_timer == 0)
- // return(1);
- // }
- // }
- // return(0);
- // #else
-
-#ifdef ARCH_BIG
- {
- // BIG-ENDIAN, swap the order of bytes in each sound sample in the portaudio buffer
- int c;
- unsigned char *out_ptr;
- unsigned char *out_end;
- out_ptr = (unsigned char *)outputBuffer;
- out_end = out_ptr + framesPerBuffer*2 * out_channels;
- while(out_ptr < out_end)
- {
- c = out_ptr[0];
- out_ptr[0] = out_ptr[1];
- out_ptr[1] = c;
- out_ptr += 2;
- }
- }
-#endif
-
-
- return(aResult);
- //#endif
-
-} // end of WaveCallBack
-
-//>
-
-
-void wave_flush(void* theHandler)
-{
- ENTER("wave_flush");
-
- if (my_stream_could_start)
- {
-// #define buf 1024
-// static char a_buffer[buf*2];
-// memset(a_buffer,0,buf*2);
-// wave_write(theHandler, a_buffer, buf*2);
- start_stream();
- }
-}
-
-//<wave_open_sound
-
-static int wave_open_sound()
-{
- ENTER("wave_open_sound");
-
- PaError err=paNoError;
- PaError active;
-
-#if USE_PORTAUDIO == 18
- active = Pa_StreamActive(pa_stream);
-#else
- active = Pa_IsStreamActive(pa_stream);
-#endif
-
- if(active == 1)
- {
- SHOW_TIME("wave_open_sound > already active");
- return(0);
- }
- if(active < 0)
- {
- out_channels = 1;
-
-#if USE_PORTAUDIO == 18
- // err = Pa_OpenDefaultStream(&pa_stream,0,1,paInt16,SAMPLE_RATE,FRAMES_PER_BUFFER,N_WAV_BUF,pa_callback,(void *)userdata);
-
- PaDeviceID playbackDevice = Pa_GetDefaultOutputDeviceID();
-
- PaError err = Pa_OpenStream( &pa_stream,
- /* capture parameters */
- paNoDevice,
- 0,
- paInt16,
- NULL,
- /* playback parameters */
- playbackDevice,
- out_channels,
- paInt16,
- NULL,
- /* general parameters */
- SAMPLE_RATE, FRAMES_PER_BUFFER, 0,
- //paClipOff | paDitherOff,
- paNoFlag,
- pa_callback, (void *)userdata);
-
- SHOW("wave_open_sound > Pa_OpenDefaultStream(1): err=%d (%s)\n",err, Pa_GetErrorText(err));
-
- if(err == paInvalidChannelCount)
- {
- SHOW_TIME("wave_open_sound > try stereo");
- // failed to open with mono, try stereo
- out_channels = 2;
- // myOutputParameters.channelCount = out_channels;
- PaError err = Pa_OpenStream( &pa_stream,
- /* capture parameters */
- paNoDevice,
- 0,
- paInt16,
- NULL,
- /* playback parameters */
- playbackDevice,
- out_channels,
- paInt16,
- NULL,
- /* general parameters */
- SAMPLE_RATE, FRAMES_PER_BUFFER, 0,
- //paClipOff | paDitherOff,
- paNoFlag,
- pa_callback, (void *)userdata);
-// err = Pa_OpenDefaultStream(&pa_stream,0,2,paInt16,
-// SAMPLE_RATE,
-// FRAMES_PER_BUFFER,
-// N_WAV_BUF,pa_callback,(void *)userdata);
- SHOW("wave_open_sound > Pa_OpenDefaultStream(2): err=%d (%s)\n",err, Pa_GetErrorText(err));
- err=0; // avoid warning
- }
- mInCallbackFinishedState = false; // v18 only
-#else
- myOutputParameters.channelCount = out_channels;
- unsigned long framesPerBuffer = paFramesPerBufferUnspecified;
- err = Pa_OpenStream(
- &pa_stream,
- NULL, /* no input */
- &myOutputParameters,
- SAMPLE_RATE,
- framesPerBuffer,
- paNoFlag,
- // paClipOff | paDitherOff,
- pa_callback,
- (void *)userdata);
- if ((err!=paNoError)
- && (err!=paInvalidChannelCount)) //err==paUnanticipatedHostError
- {
- fprintf(stderr, "wave_open_sound > Pa_OpenStream : err=%d (%s)\n",err,Pa_GetErrorText(err));
- framesPerBuffer = FRAMES_PER_BUFFER;
- err = Pa_OpenStream(
- &pa_stream,
- NULL, /* no input */
- &myOutputParameters,
- SAMPLE_RATE,
- framesPerBuffer,
- paNoFlag,
- // paClipOff | paDitherOff,
- pa_callback,
- (void *)userdata);
- }
- if(err == paInvalidChannelCount)
- {
- SHOW_TIME("wave_open_sound > try stereo");
- // failed to open with mono, try stereo
- out_channels = 2;
- myOutputParameters.channelCount = out_channels;
- err = Pa_OpenStream(
- &pa_stream,
- NULL, /* no input */
- &myOutputParameters,
- SAMPLE_RATE,
- framesPerBuffer,
- paNoFlag,
- // paClipOff | paDitherOff,
- pa_callback,
- (void *)userdata);
-
- // err = Pa_OpenDefaultStream(&pa_stream,0,2,paInt16,(double)SAMPLE_RATE,FRAMES_PER_BUFFER,pa_callback,(void *)userdata);
- }
- mInCallbackFinishedState = false;
-#endif
- }
-
- SHOW("wave_open_sound > %s\n","LEAVE");
-
- return (err != paNoError);
-}
-
-//>
-//<select_device
-
-#if (USE_PORTAUDIO == 19)
-static void update_output_parameters(int selectedDevice, const PaDeviceInfo *deviceInfo)
-{
- // const PaDeviceInfo *pdi = Pa_GetDeviceInfo(i);
- myOutputParameters.device = selectedDevice;
- // myOutputParameters.channelCount = pdi->maxOutputChannels;
- myOutputParameters.channelCount = 1;
- myOutputParameters.sampleFormat = paInt16;
-
- // Latency greater than 100ms for avoiding glitches
- // (e.g. when moving a window in a graphical desktop)
- // deviceInfo = Pa_GetDeviceInfo(selectedDevice);
- if (deviceInfo)
- {
- double aLatency = deviceInfo->defaultLowOutputLatency;
- double aCoeff = round(0.100 / aLatency);
-// myOutputParameters.suggestedLatency = aCoeff * aLatency; // to avoid glitches ?
- myOutputParameters.suggestedLatency = aLatency; // for faster response ?
- SHOW("Device=%d, myOutputParameters.suggestedLatency=%f, aCoeff=%f\n",
- selectedDevice,
- myOutputParameters.suggestedLatency,
- aCoeff);
- }
- else
- {
- myOutputParameters.suggestedLatency = (double)0.1; // 100ms
- SHOW("Device=%d, myOutputParameters.suggestedLatency=%f (default)\n",
- selectedDevice,
- myOutputParameters.suggestedLatency);
- }
- //pdi->defaultLowOutputLatency;
-
- myOutputParameters.hostApiSpecificStreamInfo = NULL;
-}
-#endif
-
-static void select_device(const char* the_api)
-{
- ENTER("select_device");
-
-#if (USE_PORTAUDIO == 19)
- int numDevices = Pa_GetDeviceCount();
- if( numDevices < 0 )
- {
- SHOW( "ERROR: Pa_CountDevices returned 0x%x\n", numDevices );
- assert(0);
- }
-
- PaDeviceIndex i=0, selectedIndex=0, defaultAlsaIndex=numDevices;
- const PaDeviceInfo *deviceInfo=NULL;
- const PaDeviceInfo *selectedDeviceInfo=NULL;
-
- if(option_device_number >= 0)
- {
- selectedIndex = option_device_number;
- selectedDeviceInfo = Pa_GetDeviceInfo(selectedIndex);
- }
-
- if(selectedDeviceInfo == NULL)
- {
- for( i=0; i<numDevices; i++ )
- {
- deviceInfo = Pa_GetDeviceInfo( i );
-
- if (deviceInfo == NULL)
- {
- break;
- }
- const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi );
-
- if (hostInfo && hostInfo->type == paALSA)
- {
- // Check (once) the default output device
- if (defaultAlsaIndex == numDevices)
- {
- defaultAlsaIndex = hostInfo->defaultOutputDevice;
- const PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo( defaultAlsaIndex );
- update_output_parameters(defaultAlsaIndex, deviceInfo);
- if (Pa_IsFormatSupported(NULL, &myOutputParameters, SAMPLE_RATE) == 0)
- {
- SHOW( "select_device > ALSA (default), name=%s (#%d)\n", deviceInfo->name, defaultAlsaIndex);
- selectedIndex = defaultAlsaIndex;
- selectedDeviceInfo = deviceInfo;
- break;
- }
- }
-
- // if the default output device does not match,
- // look for the device with the highest number of output channels
- SHOW( "select_device > ALSA, i=%d (numDevices=%d)\n", i, numDevices);
-
- update_output_parameters(i, deviceInfo);
-
- if (Pa_IsFormatSupported(NULL, &myOutputParameters, SAMPLE_RATE) == 0)
- {
- SHOW( "select_device > ALSA, name=%s (#%d)\n", deviceInfo->name, i);
-
- if (!selectedDeviceInfo
- || (selectedDeviceInfo->maxOutputChannels < deviceInfo->maxOutputChannels))
- {
- selectedIndex = i;
- selectedDeviceInfo = deviceInfo;
- }
- }
- }
- }
- }
-
- if (selectedDeviceInfo)
- {
- update_output_parameters(selectedIndex, selectedDeviceInfo);
- }
- else
- {
- i = Pa_GetDefaultOutputDevice();
- deviceInfo = Pa_GetDeviceInfo( i );
- update_output_parameters(i, deviceInfo);
- }
-
-#endif
-}
-
-//>
-
-
-// int wave_Close(void* theHandler)
-// {
-// SHOW_TIME("WaveCloseSound");
-
-// // PaError active;
-
-// // check whether speaking has finished, and close the stream
-// if(pa_stream != NULL)
-// {
-// Pa_CloseStream(pa_stream);
-// pa_stream = NULL;
-// init_buffer();
-
-// // #if USE_PORTAUDIO == 18
-// // active = Pa_StreamActive(pa_stream);
-// // #else
-// // active = Pa_IsStreamActive(pa_stream);
-// // #endif
-// // if(active == 0)
-// // {
-// // SHOW_TIME("WaveCloseSound > ok, not active");
-// // Pa_CloseStream(pa_stream);
-// // pa_stream = NULL;
-// // return(1);
-// // }
-// }
-// return(0);
-// }
-
-//<wave_set_callback_is_output_enabled
-
-void wave_set_callback_is_output_enabled(t_wave_callback* cb)
-{
- my_callback_is_output_enabled = cb;
-}
-
-//>
-//<wave_init
-
-// TBD: the arg could be "alsa", "oss",...
-void wave_init()
-{
- ENTER("wave_init");
- PaError err;
-
- pa_stream = NULL;
- mInCallbackFinishedState = false;
- init_buffer();
-
- // PortAudio sound output library
- err = Pa_Initialize();
- pa_init_err = err;
- if(err != paNoError)
- {
- SHOW_TIME("wave_init > Failed to initialise the PortAudio sound");
- }
-}
-
-//>
-//<wave_open
-
-void* wave_open(const char* the_api)
-{
- ENTER("wave_open");
- static int once=0;
-
- // TBD: the_api (e.g. "alsa") is not used at the moment
- // select_device is called once
- if (!once)
- {
- select_device("alsa");
- once=1;
- }
- return((void*)1);
-}
-
-//>
-//<copyBuffer
-
-
-static size_t copyBuffer(char* dest, char* src, const size_t theSizeInBytes)
-{
- size_t bytes_written = 0;
- unsigned int i = 0;
- uint16_t* a_dest = NULL;
- uint16_t* a_src = NULL;
-
- if ((src != NULL) && dest != NULL)
- {
- // copy for one channel (mono)?
- if(out_channels==1)
- {
- SHOW("copyBuffer > 1 channel > memcpy %x (%d bytes)\n", (int)myWrite, theSizeInBytes);
- memcpy(dest, src, theSizeInBytes);
- bytes_written = theSizeInBytes;
- }
- else // copy for 2 channels (stereo)
- {
- SHOW("copyBuffer > 2 channels > memcpy %x (%d bytes)\n", (int)myWrite, theSizeInBytes);
- i = 0;
- a_dest = (uint16_t* )dest;
- a_src = (uint16_t* )src;
-
- for(i=0; i<theSizeInBytes/2; i++)
- {
- a_dest[2*i] = a_src[i];
- a_dest[2*i+1] = a_src[i];
- }
- bytes_written = 2*theSizeInBytes;
- } // end if(out_channels==1)
- } // end if ((src != NULL) && dest != NULL)
-
- return bytes_written;
-}
-
-//>
-//<wave_write
-
-size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize)
-{
- ENTER("wave_write");
- size_t bytes_written = 0;
- // space in ringbuffer for the sample needed: 1x mono channel but 2x for 1 stereo channel
- size_t bytes_to_write = (out_channels==1) ? theSize : theSize*2;
- my_stream_could_start = 0;
-
- if(pa_stream == NULL)
- {
- SHOW_TIME("wave_write > wave_open_sound\n");
- if (0 != wave_open_sound())
- {
- SHOW_TIME("wave_write > wave_open_sound fails!");
- return 0;
- }
- my_stream_could_start=1;
- }
- else if (!wave_is_busy(NULL))
- {
- my_stream_could_start = 1;
- }
- assert(BUFFER_LENGTH >= bytes_to_write);
-
- if (myWrite >= myBuffer + BUFFER_LENGTH)
- {
- myWrite = myBuffer;
- } // end if (myWrite >= myBuffer + BUFFER_LENGTH)
-
- size_t aTotalFreeMem=0;
- char* aRead = myRead;
- SHOW("wave_write > aRead=%x, myWrite=%x\n", (int)aRead, (int)myWrite);
-
- while (1)
- {
- if (my_callback_is_output_enabled && (0==my_callback_is_output_enabled()))
- {
- SHOW_TIME("wave_write > my_callback_is_output_enabled: no!");
- return 0;
- }
-
- aRead = myRead;
-
- // write pointer is before read pointer?
- if (myWrite >= aRead)
- {
- aTotalFreeMem = aRead + BUFFER_LENGTH - myWrite;
- }
- else // read pointer is before write pointer!
- {
- aTotalFreeMem = aRead - myWrite;
- } // end if (myWrite >= aRead)
-
- if (aTotalFreeMem>1)
- {
- // -1 because myWrite must be different of aRead
- // otherwise buffer would be considered as empty
- aTotalFreeMem -= 1;
- } // end if (aTotalFreeMem>1)
-
- if (aTotalFreeMem >= bytes_to_write)
- {
- break;
- } // end if (aTotalFreeMem >= bytes_to_write)
-
- //SHOW_TIME("wave_write > wait");
- SHOW("wave_write > wait: aTotalFreeMem=%d\n", aTotalFreeMem);
- SHOW("wave_write > aRead=%x, myWrite=%x\n", (int)aRead, (int)myWrite);
- usleep(10000);
- } // end while (1)
-
- aRead = myRead;
-
- // write pointer is ahead the read pointer?
- if (myWrite >= aRead)
- {
- SHOW_TIME("wave_write > myWrite >= aRead");
- // determine remaining free memory to the end of the ringbuffer
- size_t aFreeMem = myBuffer + BUFFER_LENGTH - myWrite;
- // is enough linear space available (regardless 1 or 2 channels)?
- if (aFreeMem >= bytes_to_write)
- {
- // copy direct - no wrap around at end of ringbuffer needed
- myWrite += copyBuffer(myWrite, theMono16BitsWaveBuffer, theSize);
- }
- else // not enough linear space available
- {
- // 2 channels (stereo)?
- if (out_channels == 2)
- {
- // copy with wrap around at the end of ringbuffer
- copyBuffer(myWrite, theMono16BitsWaveBuffer, aFreeMem/2);
- myWrite = myBuffer;
- myWrite += copyBuffer(myWrite, theMono16BitsWaveBuffer+aFreeMem/2, theSize - aFreeMem/2);
- }
- else // 1 channel (mono)
- {
- // copy with wrap around at the end of ringbuffer
- copyBuffer(myWrite, theMono16BitsWaveBuffer, aFreeMem);
- myWrite = myBuffer;
- myWrite += copyBuffer(myWrite, theMono16BitsWaveBuffer+aFreeMem, theSize - aFreeMem);
- } // end if (out_channels == 2)
- } // end if (aFreeMem >= bytes_to_write)
- } // if (myWrite >= aRead)
- else // read pointer is ahead the write pointer
- {
- SHOW_TIME("wave_write > myWrite <= aRead");
- myWrite += copyBuffer(myWrite, theMono16BitsWaveBuffer, theSize);
- } // end if (myWrite >= aRead)
-
- bytes_written = bytes_to_write;
- myWritePosition += theSize/sizeof(uint16_t); // add number of samples
-
- if (my_stream_could_start && (get_used_mem() >= out_channels * sizeof(uint16_t) * FRAMES_PER_BUFFER))
- {
- start_stream();
- } // end if (my_stream_could_start && (get_used_mem() >= out_channels * sizeof(uint16_t) * FRAMES_PER_BUFFER))
-
- SHOW_TIME("wave_write > LEAVE");
-
- return bytes_written;
-}
-
-//>
-//<wave_close
-
-int wave_close(void* theHandler)
-{
- SHOW_TIME("wave_close > ENTER");
-
- static int aStopStreamCount = 0;
-
-#if (USE_PORTAUDIO == 19)
- if( pa_stream == NULL )
- {
- SHOW_TIME("wave_close > LEAVE (NULL stream)");
- return 0;
- }
-
- if( Pa_IsStreamStopped( pa_stream ) )
- {
- SHOW_TIME("wave_close > LEAVE (stopped)");
- return 0;
- }
-#else
- if( pa_stream == NULL )
- {
- SHOW_TIME("wave_close > LEAVE (NULL stream)");
- return 0;
- }
-
- if( Pa_StreamActive( pa_stream ) == false && mInCallbackFinishedState == false )
- {
- SHOW_TIME("wave_close > LEAVE (not active)");
- return 0;
- }
-#endif
-
- // Avoid race condition by making sure this function only
- // gets called once at a time
- aStopStreamCount++;
- if (aStopStreamCount != 1)
- {
- SHOW_TIME("wave_close > LEAVE (stopStreamCount)");
- return 0;
- }
-
- // Comment from Audacity-1.2.4b adapted to the eSpeak context.
- //
- // We got here in one of two ways:
- //
- // 1. The calling program calls the espeak_Cancel function and we
- // therefore want to stop as quickly as possible.
- // So we use AbortStream(). If this is
- // the case the portaudio stream is still in the Running state
- // (see PortAudio state machine docs).
- //
- // 2. The callback told PortAudio to stop the stream since it had
- // reached the end of the selection.
- // The event polling thread discovered this by noticing that
- // wave_is_busy() returned false.
- // wave_is_busy() (which calls Pa_GetStreamActive()) will not return
- // false until all buffers have finished playing, so we can call
- // AbortStream without losing any samples. If this is the case
- // we are in the "callback finished state" (see PortAudio state
- // machine docs).
- //
- // The moral of the story: We can call AbortStream safely, without
- // losing samples.
- //
- // DMM: This doesn't seem to be true; it seems to be necessary to
- // call StopStream if the callback brought us here, and AbortStream
- // if the user brought us here.
- //
-
-#if (USE_PORTAUDIO == 19)
- if (pa_stream)
- {
- Pa_AbortStream( pa_stream );
- SHOW_TIME("wave_close > Pa_AbortStream (end)");
-
- Pa_CloseStream( pa_stream );
- SHOW_TIME("wave_close > Pa_CloseStream (end)");
- pa_stream = NULL;
- mInCallbackFinishedState = false;
- }
-#else
- if (pa_stream)
- {
- if (mInCallbackFinishedState)
- {
- Pa_StopStream( pa_stream );
- SHOW_TIME("wave_close > Pa_StopStream (end)");
- }
- else
- {
- Pa_AbortStream( pa_stream );
- SHOW_TIME("wave_close > Pa_AbortStream (end)");
- }
- Pa_CloseStream( pa_stream );
- SHOW_TIME("wave_close > Pa_CloseStream (end)");
-
- pa_stream = NULL;
- mInCallbackFinishedState = false;
- }
-#endif
- init_buffer();
-
- aStopStreamCount = 0; // last action
- SHOW_TIME("wave_close > LEAVE");
- return 0;
-}
-
-// int wave_close(void* theHandler)
-// {
-// ENTER("wave_close");
-
-// if(pa_stream != NULL)
-// {
-// PaError err = Pa_AbortStream(pa_stream);
-// SHOW_TIME("wave_close > Pa_AbortStream (end)");
-// SHOW("wave_close Pa_AbortStream > err=%d\n",err);
-// while(1)
-// {
-// PaError active;
-// #if USE_PORTAUDIO == 18
-// active = Pa_StreamActive(pa_stream);
-// #else
-// active = Pa_IsStreamActive(pa_stream);
-// #endif
-// if (active != 1)
-// {
-// break;
-// }
-// SHOW("wave_close > active=%d\n",err);
-// usleep(10000); /* sleep until playback has finished */
-// }
-// err = Pa_CloseStream( pa_stream );
-// SHOW_TIME("wave_close > Pa_CloseStream (end)");
-// SHOW("wave_close Pa_CloseStream > err=%d\n",err);
-// pa_stream = NULL;
-// init_buffer();
-// }
-// return 0;
-// }
-
-//>
-//<wave_is_busy
-
-int wave_is_busy(void* theHandler)
-{
- PaError active=0;
-
- SHOW_TIME("wave_is_busy");
-
- if (pa_stream)
- {
-#if USE_PORTAUDIO == 18
- active = Pa_StreamActive(pa_stream)
- && (mInCallbackFinishedState == false);
-#else
- active = Pa_IsStreamActive(pa_stream)
- && (mInCallbackFinishedState == false);
-#endif
- }
-
- SHOW("wave_is_busy: %d\n",active);
-
-
- return (active==1);
-}
-
-//>
-//<wave_terminate
-
-void wave_terminate()
-{
- ENTER("wave_terminate");
-
- Pa_Terminate();
-
-}
-
-//>
-//<wave_get_read_position, wave_get_write_position, wave_get_remaining_time
-
-uint32_t wave_get_read_position(void* theHandler)
-{
- SHOW("wave_get_read_position > myReadPosition=%u\n", myReadPosition);
- return myReadPosition;
-}
-
-uint32_t wave_get_write_position(void* theHandler)
-{
- SHOW("wave_get_write_position > myWritePosition=%u\n", myWritePosition);
- return myWritePosition;
-}
-
-int wave_get_remaining_time(uint32_t sample, uint32_t* time)
-{
- double a_time=0;
-
- if (!time || !pa_stream)
- {
- SHOW("event get_remaining_time> %s\n","audio device not available");
- return -1;
- }
-
- if (sample > myReadPosition)
- {
- // TBD: take in account time suplied by portaudio V18 API
- a_time = sample - myReadPosition;
- a_time = 0.5 + (a_time * 1000.0) / SAMPLE_RATE;
- }
- else
- {
- a_time = 0;
- }
-
- SHOW("wave_get_remaining_time > sample=%d, time=%d\n", sample, (uint32_t)a_time);
-
- *time = (uint32_t)a_time;
-
- return 0;
-}
-
-//>
-//<wave_test_get_write_buffer
-
-void *wave_test_get_write_buffer()
-{
- return myWrite;
-}
-
-
-#else
-// notdef USE_PORTAUDIO
-
-
-void wave_init() {}
-void* wave_open(const char* the_api) {return (void *)1;}
-size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
-int wave_close(void* theHandler) {return 0;}
-int wave_is_busy(void* theHandler) {return 0;}
-void wave_terminate() {}
-uint32_t wave_get_read_position(void* theHandler) {return 0;}
-uint32_t wave_get_write_position(void* theHandler) {return 0;}
-void wave_flush(void* theHandler) {}
-typedef int (t_wave_callback)(void);
-void wave_set_callback_is_output_enabled(t_wave_callback* cb) {}
-extern void* wave_test_get_write_buffer() {return NULL;}
-
-int wave_get_remaining_time(uint32_t sample, uint32_t* time)
-{
- if (!time) return(-1);
- *time = (uint32_t)0;
- return 0;
-}
-
-#endif // of USE_PORTAUDIO
-
-//>
-//<clock_gettime2, add_time_in_ms
-
-void clock_gettime2(struct timespec *ts)
-{
- struct timeval tv;
-
- if (!ts)
- {
- return;
- }
-
- assert (gettimeofday(&tv, NULL) != -1);
- ts->tv_sec = tv.tv_sec;
- ts->tv_nsec = tv.tv_usec*1000;
-}
-
-void add_time_in_ms(struct timespec *ts, int time_in_ms)
-{
- if (!ts)
- {
- return;
- }
-
- uint64_t t_ns = (uint64_t)ts->tv_nsec + 1000000 * (uint64_t)time_in_ms;
- while(t_ns >= ONE_BILLION)
- {
- SHOW("event > add_time_in_ms ns: %d sec %Lu nsec \n", ts->tv_sec, t_ns);
- ts->tv_sec += 1;
- t_ns -= ONE_BILLION;
- }
- ts->tv_nsec = (long int)t_ns;
-}
-
-
-#endif // USE_ASYNC
-
-//>
diff --git a/navit/support/espeak/wave.h b/navit/support/espeak/wave.h
deleted file mode 100644
index de8bf1ef8..000000000
--- a/navit/support/espeak/wave.h
+++ /dev/null
@@ -1,52 +0,0 @@
-#ifndef WAVE_H
-#define WAVE_H
-
-#ifdef _MSC_VER
-
-typedef __int32 int32_t;
-typedef unsigned __int32 uint32_t;
-typedef __int64 int64_t;
-typedef unsigned __int32 uint64_t;
-
-#else
-#ifndef PLATFORM_DOS
-#include "stdint.h"
-#endif
-#endif
-
-extern int option_device_number;
-
-extern void wave_init();
-// TBD: the arg could be "alsa", "oss",...
-extern void* wave_open(const char* the_api);
-
-extern size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize);
-extern int wave_close(void* theHandler);
-extern void wave_flush(void* theHandler);
-extern int wave_is_busy(void* theHandler);
-extern void wave_terminate();
-extern uint32_t wave_get_read_position(void* theHandler);
-extern uint32_t wave_get_write_position(void* theHandler);
-
-// Supply the remaining time in ms before the sample is played
-// (or 0 if the event has been already played).
-// sample: sample identifier
-// time: supplied value in ms
-//
-// return 0 if ok or -1 otherwise (stream not opened).
-extern int wave_get_remaining_time(uint32_t sample, uint32_t* time);
-
-// set the callback which informs if the output is still enabled.
-// Helpful if a new sample is waiting for free space whereas sound must be stopped.
-typedef int (t_wave_callback)(void);
-extern void wave_set_callback_is_output_enabled(t_wave_callback* cb);
-
-
-// general functions
-extern void clock_gettime2(struct timespec *ts);
-extern void add_time_in_ms(struct timespec *ts, int time_in_ms);
-
-// for tests
-extern void *wave_test_get_write_buffer();
-
-#endif
diff --git a/navit/support/espeak/wave_pulse.c b/navit/support/espeak/wave_pulse.c
deleted file mode 100755
index d5fbc8c1e..000000000
--- a/navit/support/espeak/wave_pulse.c
+++ /dev/null
@@ -1,935 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2007, Gilles Casse <gcasse@oralux.org> *
- * eSpeak driver for PulseAudio *
- * based on the XMMS PulseAudio Plugin *
- * *
- * 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 3 of the License, 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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-// TBD:
-// * ARCH_BIG
-// * uint64? a_timing_info.read_index
-// * prebuf,... size?
-// * 0.9.6: pb pulse_free using tlength=8820 (max size never returned -> tlength=10000 ok, but higher drain).
-//
-#include "speech.h"
-
-#ifdef USE_ASYNC
-// This source file is only used for asynchronious modes
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-#include <assert.h>
-#include <sys/time.h>
-#include <time.h>
-#include <pulse/pulseaudio.h>
-#include <pthread.h>
-
-#ifndef PLATFORM_WINDOWS
-#include <unistd.h>
-#endif
-#include "wave.h"
-#include "debug.h"
-
-//<Definitions
-
-enum {ONE_BILLION=1000000000};
-
-enum {
-// /* 100ms.
-// If a greater value is set (several seconds),
-// please update _pulse_timeout_start accordingly */
-// PULSE_TIMEOUT_IN_USEC = 100000,
-
- /* return value */
- PULSE_OK = 0,
- PULSE_ERROR = -1,
- PULSE_NO_CONNECTION = -2
-};
-
-#ifdef USE_PULSEAUDIO
-
-static t_wave_callback* my_callback_is_output_enabled=NULL;
-
-#define SAMPLE_RATE 22050
-#define ESPEAK_FORMAT PA_SAMPLE_S16LE
-#define ESPEAK_CHANNEL 1
-
-#define MAXLENGTH 132300
-#define TLENGTH 4410
-#define PREBUF 2200
-#define MINREQ 880
-#define FRAGSIZE 0
-
-static pthread_mutex_t pulse_mutex;
-
-static pa_context *context = NULL;
-static pa_stream *stream = NULL;
-static pa_threaded_mainloop *mainloop = NULL;
-
-static pa_cvolume volume;
-static int volume_valid = 0;
-
-static int do_trigger = 0;
-static uint64_t written = 0;
-static int time_offset_msec = 0;
-static int just_flushed = 0;
-
-static int connected = 0;
-
-#define CHECK_DEAD_GOTO(label, warn) do { \
-if (!mainloop || \
- !context || pa_context_get_state(context) != PA_CONTEXT_READY || \
- !stream || pa_stream_get_state(stream) != PA_STREAM_READY) { \
- if (warn) \
- SHOW("Connection died: %s\n", context ? pa_strerror(pa_context_errno(context)) : "NULL"); \
- goto label; \
- } \
-} while(0);
-
-#define CHECK_CONNECTED(retval) \
-do { \
- if (!connected) return retval; \
-} while (0);
-
-#define CHECK_CONNECTED_NO_RETVAL(id) \
- do { \
- if (!connected){ SHOW("CHECK_CONNECTED_NO_RETVAL: !pulse_connected\n", ""); return; } \
- } while (0);
-
-//>
-
-
-// static void display_timing_info(const pa_timing_info* the_time)
-// {
-// const struct timeval *tv=&(the_time->timestamp);
-
-// SHOW_TIME("ti>");
-// SHOW("ti> timestamp=%03d.%03dms\n",(int)(tv->tv_sec%1000), (int)(tv->tv_usec/1000));
-// SHOW("ti> synchronized_clocks=%d\n",the_time->synchronized_clocks);
-// SHOW("ti> sink_usec=%ld\n",the_time->sink_usec);
-// SHOW("ti> source_usec=%ld\n",the_time->source_usec);
-// SHOW("ti> transport=%ld\n",the_time->transport_usec);
-// SHOW("ti> playing=%d\n",the_time->playing);
-// SHOW("ti> write_index_corrupt=%d\n",the_time->write_index_corrupt);
-// SHOW("ti> write_index=0x%lx\n",the_time->write_index);
-// SHOW("ti> read_index_corrupt=%d\n",the_time->read_index_corrupt);
-// SHOW("ti> read_index=0x%lx\n",the_time->read_index);
-// }
-
-
-static void info_cb(struct pa_context *c, const struct pa_sink_input_info *i, int is_last, void *userdata) {
- ENTER(__FUNCTION__);
- assert(c);
-
- if (!i)
- return;
-
- volume = i->volume;
- volume_valid = 1;
-}
-
-static void subscribe_cb(struct pa_context *c, enum pa_subscription_event_type t, uint32_t index, void *userdata) {
- pa_operation *o;
- ENTER(__FUNCTION__);
-
- assert(c);
-
- if (!stream ||
- index != pa_stream_get_index(stream) ||
- (t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_CHANGE) &&
- t != (PA_SUBSCRIPTION_EVENT_SINK_INPUT|PA_SUBSCRIPTION_EVENT_NEW)))
- return;
-
- if (!(o = pa_context_get_sink_input_info(c, index, info_cb, NULL))) {
- SHOW("pa_context_get_sink_input_info() failed: %s\n", pa_strerror(pa_context_errno(c)));
- return;
- }
-
- pa_operation_unref(o);
-}
-
-static void context_state_cb(pa_context *c, void *userdata) {
- ENTER(__FUNCTION__);
- assert(c);
-
- switch (pa_context_get_state(c)) {
- case PA_CONTEXT_READY:
- case PA_CONTEXT_TERMINATED:
- case PA_CONTEXT_FAILED:
- pa_threaded_mainloop_signal(mainloop, 0);
- break;
-
- case PA_CONTEXT_UNCONNECTED:
- case PA_CONTEXT_CONNECTING:
- case PA_CONTEXT_AUTHORIZING:
- case PA_CONTEXT_SETTING_NAME:
- break;
- }
-}
-
-static void stream_state_cb(pa_stream *s, void * userdata) {
- ENTER(__FUNCTION__);
- assert(s);
-
- switch (pa_stream_get_state(s)) {
-
- case PA_STREAM_READY:
- case PA_STREAM_FAILED:
- case PA_STREAM_TERMINATED:
- pa_threaded_mainloop_signal(mainloop, 0);
- break;
-
- case PA_STREAM_UNCONNECTED:
- case PA_STREAM_CREATING:
- break;
- }
-}
-
-static void stream_success_cb(pa_stream *s, int success, void *userdata) {
- ENTER(__FUNCTION__);
- assert(s);
-
- if (userdata)
- *(int*) userdata = success;
-
- pa_threaded_mainloop_signal(mainloop, 0);
-}
-
-static void context_success_cb(pa_context *c, int success, void *userdata) {
- ENTER(__FUNCTION__);
- assert(c);
-
- if (userdata)
- *(int*) userdata = success;
-
- pa_threaded_mainloop_signal(mainloop, 0);
-}
-
-static void stream_request_cb(pa_stream *s, size_t length, void *userdata) {
- ENTER(__FUNCTION__);
- assert(s);
-
- pa_threaded_mainloop_signal(mainloop, 0);
-}
-
-static void stream_latency_update_cb(pa_stream *s, void *userdata) {
- // ENTER(__FUNCTION__);
- assert(s);
-
- pa_threaded_mainloop_signal(mainloop, 0);
-}
-
-static int pulse_free(void) {
- ENTER(__FUNCTION__);
- size_t l = 0;
- pa_operation *o = NULL;
-
- CHECK_CONNECTED(0);
-
- SHOW("pulse_free: %s (call)\n", "pa_threaded_main_loop_lock");
- pa_threaded_mainloop_lock(mainloop);
- CHECK_DEAD_GOTO(fail, 1);
-
- if ((l = pa_stream_writable_size(stream)) == (size_t) -1) {
- SHOW("pa_stream_writable_size() failed: %s", pa_strerror(pa_context_errno(context)));
- l = 0;
- goto fail;
- }
-
- SHOW("pulse_free: %s (ret=%d)\n", "pa_stream_writable_size", l);
-
- /* If this function is called twice with no pulse_write() call in
- * between this means we should trigger the playback */
- if (do_trigger) {
- int success = 0;
-
- SHOW("pulse_free: %s (call)\n", "pa_stream_trigger");
- if (!(o = pa_stream_trigger(stream, stream_success_cb, &success))) {
- SHOW("pa_stream_trigger() failed: %s", pa_strerror(pa_context_errno(context)));
- goto fail;
- }
-
- SHOW("pulse_free: %s (call)\n", "pa_threaded_main_loop");
- while (pa_operation_get_state(o) != PA_OPERATION_DONE) {
- CHECK_DEAD_GOTO(fail, 1);
- pa_threaded_mainloop_wait(mainloop);
- }
- SHOW("pulse_free: %s (ret)\n", "pa_threaded_main_loop");
-
- if (!success)
- SHOW("pa_stream_trigger() failed: %s", pa_strerror(pa_context_errno(context)));
- }
-
-fail:
- SHOW("pulse_free: %s (call)\n", "pa_operation_unref");
- if (o)
- pa_operation_unref(o);
-
- SHOW("pulse_free: %s (call)\n", "pa_threaded_main_loop_unlock");
- pa_threaded_mainloop_unlock(mainloop);
-
- do_trigger = !!l;
- SHOW("pulse_free: %d (ret)\n", (int)l);
- return (int) l;
-}
-
-static int pulse_playing(const pa_timing_info *the_timing_info) {
- ENTER(__FUNCTION__);
- int r = 0;
- const pa_timing_info *i;
-
- assert(the_timing_info);
-
- CHECK_CONNECTED(0);
-
- pa_threaded_mainloop_lock(mainloop);
-
- for (;;) {
- CHECK_DEAD_GOTO(fail, 1);
-
- if ((i = pa_stream_get_timing_info(stream)))
- {
- break;
- }
- if (pa_context_errno(context) != PA_ERR_NODATA) {
- SHOW("pa_stream_get_timing_info() failed: %s", pa_strerror(pa_context_errno(context)));
- goto fail;
- }
-
- pa_threaded_mainloop_wait(mainloop);
- }
-
- r = i->playing;
- memcpy((void*)the_timing_info, (void*)i, sizeof(pa_timing_info));
-
- // display_timing_info(i);
-
-fail:
- pa_threaded_mainloop_unlock(mainloop);
-
- return r;
-}
-
-
-// static void pulse_flush(int time) {
-// ENTER(__FUNCTION__);
-// pa_operation *o = NULL;
-// int success = 0;
-
-// CHECK_CONNECTED();
-
-// pa_threaded_mainloop_lock(mainloop);
-// CHECK_DEAD_GOTO(fail, 1);
-
-// if (!(o = pa_stream_flush(stream, stream_success_cb, &success))) {
-// SHOW("pa_stream_flush() failed: %s", pa_strerror(pa_context_errno(context)));
-// goto fail;
-// }
-
-// while (pa_operation_get_state(o) != PA_OPERATION_DONE) {
-// CHECK_DEAD_GOTO(fail, 1);
-// pa_threaded_mainloop_wait(mainloop);
-// }
-
-// if (!success)
-// SHOW("pa_stream_flush() failed: %s", pa_strerror(pa_context_errno(context)));
-
-// written = (uint64_t) (((double) time * pa_bytes_per_second(pa_stream_get_sample_spec(stream))) / 1000);
-// just_flushed = 1;
-// time_offset_msec = time;
-
-// fail:
-// if (o)
-// pa_operation_unref(o);
-
-// pa_threaded_mainloop_unlock(mainloop);
-// }
-
-
-static void pulse_write(void* ptr, int length) {
- ENTER(__FUNCTION__);
-
-
- SHOW("pulse_write > length=%d\n", length);
-
- CHECK_CONNECTED();
-
- pa_threaded_mainloop_lock(mainloop);
- CHECK_DEAD_GOTO(fail, 1);
-
- if (pa_stream_write(stream, ptr, length, NULL, PA_SEEK_RELATIVE, (pa_seek_mode_t)0) < 0) {
- SHOW("pa_stream_write() failed: %s", pa_strerror(pa_context_errno(context)));
- goto fail;
- }
-
- do_trigger = 0;
- written += length;
-
-fail:
-
- pa_threaded_mainloop_unlock(mainloop);
-}
-
-static int drain(void) {
- pa_operation *o = NULL;
- int success = 0;
- int ret = PULSE_ERROR;
-
- ENTER(__FUNCTION__);
-
- CHECK_CONNECTED(ret);
-
- pa_threaded_mainloop_lock(mainloop);
- CHECK_DEAD_GOTO(fail, 0);
-
- SHOW_TIME("pa_stream_drain (call)");
- if (!(o = pa_stream_drain(stream, stream_success_cb, &success))) {
- SHOW("pa_stream_drain() failed: %s\n", pa_strerror(pa_context_errno(context)));
- goto fail;
- }
-
- SHOW_TIME("pa_threaded_mainloop_wait (call)");
- while (pa_operation_get_state(o) != PA_OPERATION_DONE) {
- CHECK_DEAD_GOTO(fail, 1);
- pa_threaded_mainloop_wait(mainloop);
- }
- SHOW_TIME("pa_threaded_mainloop_wait (ret)");
-
- if (!success) {
- SHOW("pa_stream_drain() failed: %s\n", pa_strerror(pa_context_errno(context)));
- }
- else {
- ret = PULSE_OK;
- }
-
-fail:
- SHOW_TIME("pa_operation_unref (call)");
- if (o)
- pa_operation_unref(o);
-
- pa_threaded_mainloop_unlock(mainloop);
- SHOW_TIME("drain (ret)");
-
- return ret;
-}
-
-
-static void pulse_close(void) {
-
- ENTER(__FUNCTION__);
-
- drain();
-
- connected = 0;
-
- if (mainloop)
- pa_threaded_mainloop_stop(mainloop);
-
- connected = 0;
-
- if (context) {
- SHOW_TIME("pa_context_disconnect (call)");
- pa_context_disconnect(context);
- pa_context_unref(context);
- context = NULL;
- }
-
- if (mainloop) {
- SHOW_TIME("pa_threaded_mainloop_free (call)");
- pa_threaded_mainloop_free(mainloop);
- mainloop = NULL;
- }
- SHOW_TIME("pulse_close (ret)");
-
-}
-
-
-static int pulse_open()
-{
- ENTER(__FUNCTION__);
- pa_sample_spec ss;
- pa_operation *o = NULL;
- int success;
- int ret = PULSE_ERROR;
-
- assert(!mainloop);
- assert(!context);
- assert(!stream);
- assert(!connected);
-
- pthread_mutex_init( &pulse_mutex, (const pthread_mutexattr_t *)NULL);
-
- ss.format = ESPEAK_FORMAT;
- ss.rate = SAMPLE_RATE;
- ss.channels = ESPEAK_CHANNEL;
-
- if (!pa_sample_spec_valid(&ss))
- return false;
-
-/* if (!volume_valid) { */
- pa_cvolume_reset(&volume, ss.channels);
- volume_valid = 1;
-/* } else if (volume.channels != ss.channels) */
-/* pa_cvolume_set(&volume, ss.channels, pa_cvolume_avg(&volume)); */
-
- SHOW_TIME("pa_threaded_mainloop_new (call)");
- if (!(mainloop = pa_threaded_mainloop_new())) {
- SHOW("Failed to allocate main loop\n","");
- goto fail;
- }
-
- pa_threaded_mainloop_lock(mainloop);
-
- SHOW_TIME("pa_context_new (call)");
- if (!(context = pa_context_new(pa_threaded_mainloop_get_api(mainloop), "eSpeak"))) {
- SHOW("Failed to allocate context\n","");
- goto unlock_and_fail;
- }
-
- pa_context_set_state_callback(context, context_state_cb, NULL);
- pa_context_set_subscribe_callback(context, subscribe_cb, NULL);
-
- SHOW_TIME("pa_context_connect (call)");
- if (pa_context_connect(context, NULL, (pa_context_flags_t)0, NULL) < 0) {
- SHOW("Failed to connect to server: %s", pa_strerror(pa_context_errno(context)));
- ret = PULSE_NO_CONNECTION;
- goto unlock_and_fail;
- }
-
- SHOW_TIME("pa_threaded_mainloop_start (call)");
- if (pa_threaded_mainloop_start(mainloop) < 0) {
- SHOW("Failed to start main loop","");
- goto unlock_and_fail;
- }
-
- /* Wait until the context is ready */
- SHOW_TIME("pa_threaded_mainloop_wait");
- pa_threaded_mainloop_wait(mainloop);
-
- if (pa_context_get_state(context) != PA_CONTEXT_READY) {
- SHOW("Failed to connect to server: %s", pa_strerror(pa_context_errno(context)));
- ret = PULSE_NO_CONNECTION;
- if (mainloop)
- pa_threaded_mainloop_stop(mainloop);
- goto unlock_and_fail;
- }
-
- SHOW_TIME("pa_stream_new");
- if (!(stream = pa_stream_new(context, "unknown", &ss, NULL))) {
- SHOW("Failed to create stream: %s", pa_strerror(pa_context_errno(context)));
- goto unlock_and_fail;
- }
-
- pa_stream_set_state_callback(stream, stream_state_cb, NULL);
- pa_stream_set_write_callback(stream, stream_request_cb, NULL);
- pa_stream_set_latency_update_callback(stream, stream_latency_update_cb, NULL);
-
-
-
- pa_buffer_attr a_attr;
-
- a_attr.maxlength = MAXLENGTH;
- a_attr.tlength = TLENGTH;
- a_attr.prebuf = PREBUF;
- a_attr.minreq = MINREQ;
- a_attr.fragsize = 0;
-
- SHOW_TIME("pa_connect_playback");
- if (pa_stream_connect_playback(stream, NULL, &a_attr, (pa_stream_flags_t)(PA_STREAM_INTERPOLATE_TIMING|PA_STREAM_AUTO_TIMING_UPDATE), &volume, NULL) < 0) {
- SHOW("Failed to connect stream: %s", pa_strerror(pa_context_errno(context)));
- goto unlock_and_fail;
- }
-
- /* Wait until the stream is ready */
- SHOW_TIME("pa_threaded_mainloop_wait");
- pa_threaded_mainloop_wait(mainloop);
-
- if (pa_stream_get_state(stream) != PA_STREAM_READY) {
- SHOW("Failed to connect stream: %s", pa_strerror(pa_context_errno(context)));
- goto unlock_and_fail;
- }
-
- /* Now subscribe to events */
- SHOW_TIME("pa_context_subscribe");
- if (!(o = pa_context_subscribe(context, PA_SUBSCRIPTION_MASK_SINK_INPUT, context_success_cb, &success))) {
- SHOW("pa_context_subscribe() failed: %s", pa_strerror(pa_context_errno(context)));
- goto unlock_and_fail;
- }
-
- success = 0;
- SHOW_TIME("pa_threaded_mainloop_wait");
- while (pa_operation_get_state(o) != PA_OPERATION_DONE) {
- CHECK_DEAD_GOTO(fail, 1);
- pa_threaded_mainloop_wait(mainloop);
- }
-
- if (!success) {
- SHOW("pa_context_subscribe() failed: %s", pa_strerror(pa_context_errno(context)));
- goto unlock_and_fail;
- }
-
- pa_operation_unref(o);
-
- /* Now request the initial stream info */
- if (!(o = pa_context_get_sink_input_info(context, pa_stream_get_index(stream), info_cb, NULL))) {
- SHOW("pa_context_get_sink_input_info() failed: %s", pa_strerror(pa_context_errno(context)));
- goto unlock_and_fail;
- }
-
- SHOW_TIME("pa_threaded_mainloop_wait 2");
- while (pa_operation_get_state(o) != PA_OPERATION_DONE) {
- CHECK_DEAD_GOTO(fail, 1);
- pa_threaded_mainloop_wait(mainloop);
- }
-
-/* if (!volume_valid) { */
-/* SHOW("pa_context_get_sink_input_info() failed: %s", pa_strerror(pa_context_errno(context))); */
-/* goto unlock_and_fail; */
-/* } */
-
- do_trigger = 0;
- written = 0;
- time_offset_msec = 0;
- just_flushed = 0;
- connected = 1;
- // volume_time_event = NULL;
-
- pa_threaded_mainloop_unlock(mainloop);
- SHOW_TIME("pulse_open (ret true)");
-
- // return true;
- return PULSE_OK;
-
-
-unlock_and_fail:
-
- if (o)
- pa_operation_unref(o);
-
- pa_threaded_mainloop_unlock(mainloop);
-
-fail:
-
- // pulse_close();
-
- if (ret == PULSE_NO_CONNECTION) {
- if (context) {
- SHOW_TIME("pa_context_disconnect (call)");
- pa_context_disconnect(context);
- pa_context_unref(context);
- context = NULL;
- }
-
- if (mainloop) {
- SHOW_TIME("pa_threaded_mainloop_free (call)");
- pa_threaded_mainloop_free(mainloop);
- mainloop = NULL;
- }
- }
- else {
- pulse_close();
- }
-
- SHOW_TIME("pulse_open (ret false)");
-
- return ret;
-
-}
-
-void wave_flush(void* theHandler)
-{
- ENTER("wave_flush");
-
-// if (my_stream_could_start)
-// {
-// // #define buf 1024
-// // static char a_buffer[buf*2];
-// // memset(a_buffer,0,buf*2);
-// // wave_write(theHandler, a_buffer, buf*2);
-// start_stream();
-// }
-}
-
-
-
-//<wave_set_callback_is_output_enabled
-
-void wave_set_callback_is_output_enabled(t_wave_callback* cb)
-{
- my_callback_is_output_enabled = cb;
-}
-
-//>
-//<wave_init
-
-void wave_init()
-{
- ENTER("wave_init");
-
- stream = NULL;
-
- pulse_open();
-}
-
-//>
-//<wave_open
-
-void* wave_open(const char* the_api)
-{
- ENTER("wave_open");
- return((void*)1);
-}
-
-//>
-//<wave_write
-
-size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize)
-{
- ENTER("wave_write");
- size_t bytes_to_write = theSize;
- char* aBuffer=theMono16BitsWaveBuffer;
-
- assert(stream);
-
- size_t aTotalFreeMem=0;
-
- pthread_mutex_lock(&pulse_mutex);
-
- while (1)
- {
- if (my_callback_is_output_enabled
- && (0==my_callback_is_output_enabled()))
- {
- SHOW_TIME("wave_write > my_callback_is_output_enabled: no!");
- theSize=0;
- goto terminate;
- }
-
- aTotalFreeMem = pulse_free();
- if (aTotalFreeMem >= bytes_to_write)
- {
- SHOW("wave_write > aTotalFreeMem(%d) >= bytes_to_write(%d)\n", aTotalFreeMem, bytes_to_write);
- break;
- }
-
- // TBD: check if really helpful
- if (aTotalFreeMem >= MAXLENGTH*2)
- {
- aTotalFreeMem = MAXLENGTH*2;
- }
-
- SHOW("wave_write > wait: aTotalFreeMem(%d) < bytes_to_write(%d)\n", aTotalFreeMem, bytes_to_write);
-
- // 500: threshold for avoiding too many calls to pulse_write
- if (aTotalFreeMem>500)
- {
- pulse_write(aBuffer, aTotalFreeMem);
- bytes_to_write -= aTotalFreeMem;
- aBuffer += aTotalFreeMem;
- }
-
- usleep(10000);
- }
-
- pulse_write(aBuffer, bytes_to_write);
-
- terminate:
- pthread_mutex_unlock(&pulse_mutex);
- SHOW("wave_write: theSize=%d", theSize);
- SHOW_TIME("wave_write > LEAVE");
- return theSize;
-}
-
-//>
-//<wave_close
-
-int wave_close(void* theHandler)
-{
- SHOW_TIME("wave_close > ENTER");
-
- int a_status = pthread_mutex_lock(&pulse_mutex);
- if (a_status) {
- SHOW("Error: pulse_mutex lock=%d (%s)\n", a_status, __FUNCTION__);
- return PULSE_ERROR;
- }
-
- drain();
-
- pthread_mutex_unlock(&pulse_mutex);
- SHOW_TIME("wave_close (ret)");
-
- return PULSE_OK;
-}
-
-//>
-//<wave_is_busy
-
-int wave_is_busy(void* theHandler)
-{
- SHOW_TIME("wave_is_busy");
-
- pa_timing_info a_timing_info;
- int active = pulse_playing(&a_timing_info);
- SHOW("wave_is_busy: %d\n",active);
- return active;
-}
-
-//>
-//<wave_terminate
-
-void wave_terminate()
-{
- ENTER("wave_terminate");
-
-// Pa_Terminate();
-
- int a_status;
- pthread_mutex_t* a_mutex = NULL;
- a_mutex = &pulse_mutex;
- a_status = pthread_mutex_lock(a_mutex);
-
- pulse_close();
-
- SHOW_TIME("unlock mutex");
- a_status = pthread_mutex_unlock(a_mutex);
- pthread_mutex_destroy(a_mutex);
-}
-
-//>
-//<wave_get_read_position, wave_get_write_position, wave_get_remaining_time
-
-uint32_t wave_get_read_position(void* theHandler)
-{
- pa_timing_info a_timing_info;
- pulse_playing(&a_timing_info);
- SHOW("wave_get_read_position > %lx\n", a_timing_info.read_index);
- return a_timing_info.read_index;
-}
-
-uint32_t wave_get_write_position(void* theHandler)
-{
- pa_timing_info a_timing_info;
- pulse_playing(&a_timing_info);
- SHOW("wave_get_read_position > %lx\n", a_timing_info.write_index);
- return a_timing_info.write_index;
-}
-
-int wave_get_remaining_time(uint32_t sample, uint32_t* time)
-{
- double a_time=0;
-
- if (!time || !stream)
- {
- SHOW("event get_remaining_time> %s\n","audio device not available");
- return -1;
- }
-
- pa_timing_info a_timing_info;
- pulse_playing(&a_timing_info);
-
- if (sample > a_timing_info.read_index)
- {
- // TBD: take in account time suplied by portaudio V18 API
- a_time = sample - a_timing_info.read_index;
- a_time = 0.5 + (a_time * 1000.0) / SAMPLE_RATE;
- }
- else
- {
- a_time = 0;
- }
-
- SHOW("wave_get_remaining_time > sample=%d, time=%d\n", sample, (uint32_t)a_time);
-
- *time = (uint32_t)a_time;
-
- return 0;
-}
-
-//>
-//<wave_test_get_write_buffer
-
-void *wave_test_get_write_buffer()
-{
- return NULL;
-}
-
-
-#else
-// notdef USE_PULSEAUDIO
-
-
-void wave_init() {}
-void* wave_open(const char* the_api) {return (void *)1;}
-size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
-int wave_close(void* theHandler) {return 0;}
-int wave_is_busy(void* theHandler) {return 0;}
-void wave_terminate() {}
-uint32_t wave_get_read_position(void* theHandler) {return 0;}
-uint32_t wave_get_write_position(void* theHandler) {return 0;}
-void wave_flush(void* theHandler) {}
-typedef int (t_wave_callback)(void);
-void wave_set_callback_is_output_enabled(t_wave_callback* cb) {}
-extern void* wave_test_get_write_buffer() {return NULL;}
-
-int wave_get_remaining_time(uint32_t sample, uint32_t* time)
-{
- if (!time) return(-1);
- *time = (uint32_t)0;
- return 0;
-}
-
-#endif // of USE_PORTAUDIO
-
-//>
-//<clock_gettime2, add_time_in_ms
-
-void clock_gettime2(struct timespec *ts)
-{
- struct timeval tv;
-
- if (!ts)
- {
- return;
- }
-
- assert (gettimeofday(&tv, NULL) != -1);
- ts->tv_sec = tv.tv_sec;
- ts->tv_nsec = tv.tv_usec*1000;
-}
-
-void add_time_in_ms(struct timespec *ts, int time_in_ms)
-{
- if (!ts)
- {
- return;
- }
-
- uint64_t t_ns = (uint64_t)ts->tv_nsec + 1000000 * (uint64_t)time_in_ms;
- while(t_ns >= ONE_BILLION)
- {
- SHOW("event > add_time_in_ms ns: %d sec %Lu nsec \n", ts->tv_sec, t_ns);
- ts->tv_sec += 1;
- t_ns -= ONE_BILLION;
- }
- ts->tv_nsec = (long int)t_ns;
-}
-
-
-#endif // USE_ASYNC
-
-//>
diff --git a/navit/support/espeak/wave_sada.c b/navit/support/espeak/wave_sada.c
deleted file mode 100755
index c69a4dc99..000000000
--- a/navit/support/espeak/wave_sada.c
+++ /dev/null
@@ -1,588 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2008, Sun Microsystems, Inc. *
- * eSpeak driver for Solaris Audio Device Architecture (SADA) *
- * Written by Willie Walker, based on the eSpeak PulseAudio driver *
- * from Gilles Casse *
- * *
- * 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 3 of the License, 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., *
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
- ***************************************************************************/
-
-#include "speech.h"
-
-#ifdef USE_ASYNC
-// This source file is only used for asynchronious modes
-
-#include <errno.h>
-#include <string.h>
-#include <stropts.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/audioio.h>
-
-#include "wave.h"
-#include "debug.h"
-
-enum {ONE_BILLION=1000000000};
-#define SAMPLE_RATE 22050
-#define SAMPLE_SIZE 16
-
-#ifdef USE_SADA
-
-static t_wave_callback* my_callback_is_output_enabled=NULL;
-
-static const char *sun_audio_device = "/dev/audio";
-static int sun_audio_fd = -1;
-
-// The total number of 16-bit samples sent to be played via the
-// wave_write method.
-//
-static uint32_t total_samples_sent;
-
-// The total number of samples sent to be played via the wave_write
-// method, but which were never played because of a call to
-// wave_close.
-//
-static uint32_t total_samples_skipped;
-
-// The last known playing index after a call to wave_close.
-//
-static uint32_t last_play_position=0;
-
-//>
-// wave_init
-//
-// DESCRIPTION:
-//
-// initializes the audio subsytem.
-//
-// GLOBALS USED/MODIFIED:
-//
-// sun_audio_fd: modified to hold the file descriptor of the opened
-// audio device.
-//
-//<wave_init
-
-void wave_init() {
- ENTER("wave_init");
-
- audio_info_t ainfo;
- char *audio_device = NULL;
-
- audio_device = getenv("AUDIODEV");
- if (audio_device != NULL) {
- if ((sun_audio_fd = open(audio_device, O_WRONLY)) < 0) {
- SHOW("wave_init() could not open: %s (%d)\n",
- audio_device, sun_audio_fd);
- }
- }
-
- if (sun_audio_fd < 0) {
- if ((sun_audio_fd = open(sun_audio_device, O_WRONLY)) < 0) {
- SHOW("wave_init() could not open: %s (%d)\n",
- sun_audio_device, sun_audio_fd);
- }
- }
-
- SHOW("wave_init() sun_audio_fd: %d\n", sun_audio_fd);
-
- if (sun_audio_fd < 0) {
- return;
- }
-
- ioctl(sun_audio_fd, AUDIO_GETINFO, &ainfo);
- SHOW("wave_init() play buffer size: %d\n", ainfo.play.buffer_size);
- ainfo.play.encoding = AUDIO_ENCODING_LINEAR;
- ainfo.play.channels = 1;
- ainfo.play.sample_rate = SAMPLE_RATE;
- ainfo.play.precision = SAMPLE_SIZE;
-
- if (ioctl(sun_audio_fd, AUDIO_SETINFO, &ainfo) == -1) {
- SHOW("wave_init() failed to set audio params: %s\n", strerror(errno));
- close(sun_audio_fd);
- return;
- }
-}
-
-//>
-// wave_open
-//
-// DESCRIPTION:
-//
-// opens the audio subsystem given a specific API (e.g., "alsa",
-// "oss", ...). We ignore the_api and just return the sun_audio_fd we
-// opened in wave_init. This return value will be passed in as the
-// theHandler parameter in all other methods.
-//
-// PARAMETERS:
-//
-// the_api: "alsa", "oss" (ignored)
-//
-// GLOBALS USED/MODIFIED:
-//
-// sun_audio_fd: used as return value
-//
-// RETURNS:
-//
-// sun_audio_fd opened in wave_init, which is passed in as theHandler
-// parameter in all other methods
-//
-//<wave_open
-
-void* wave_open(const char* the_api)
-{
- ENTER("wave_open");
- return((void*) sun_audio_fd);
-}
-
-//>
-// wave_write
-//
-// DESCRIPTION:
-//
-// Meant to be asynchronous, it supplies the wave sample to the lower
-// audio layer and returns. The sample is played later on. [[[WDW -
-// we purposely do not open the audio device as non-blocking because
-// managing that would be a pain. So, we rely a lot upon fifo.cpp and
-// event.cpp to not overload us, allowing us to get away with a
-// blocking write. event.cpp:polling_thread in particular appears to
-// use get_remaining_time to prevent flooding.]]]
-//
-// PARAMETERS:
-//
-// theHandler: the audio device file descriptor
-// theMono16BitsWaveBuffer: the audio data
-// theSize: the number of bytes (not 16-bit samples)
-//
-// GLOBALS USED/MODIFIED:
-//
-// total_samples_sent: modified based upon 16-bit samples sent
-//
-// RETURNS:
-//
-// the number of bytes (not 16-bit samples) sent
-//
-//<wave_write
-
-size_t wave_write(void* theHandler,
- char* theMono16BitsWaveBuffer,
- size_t theSize)
-{
- size_t num;
- ENTER("wave_write");
- if (my_callback_is_output_enabled && (0==my_callback_is_output_enabled())) {
- SHOW_TIME("wave_write > my_callback_is_output_enabled: no!");
- return 0;
- }
-
-#if defined(BYTE_ORDER) && BYTE_ORDER == BIG_ENDIAN
- {
- // BIG-ENDIAN, swap the order of bytes in each sound sample
- int c;
- char *out_ptr;
- char *out_end;
- out_ptr = (char *)theMono16BitsWaveBuffer;
- out_end = out_ptr + theSize;
- while(out_ptr < out_end)
- {
- c = out_ptr[0];
- out_ptr[0] = out_ptr[1];
- out_ptr[1] = c;
- out_ptr += 2;
- }
- }
-#endif
-
- num = write((int) theHandler, theMono16BitsWaveBuffer, theSize);
-
- // Keep track of the total number of samples sent -- we use this in
- // wave_get_read_position and also use it to help calculate the
- // total_samples_skipped in wave_close.
- //
- total_samples_sent += num / 2;
-
- if (num < theSize) {
- SHOW("ERROR: wave_write only wrote %d of %d bytes\n", num, theSize);
- } else {
- SHOW("wave_write wrote %d bytes\n", theSize);
- }
-
- SHOW_TIME("wave_write > LEAVE");
- return num;
-}
-
-//>
-// wave_close
-//
-// DESCRIPTION:
-//
-// Does what SADA normally would call a flush, which means to cease
-// all audio production in progress and throw any remaining audio
-// away. [[[WDW - see comment in wave_flush.]]]
-//
-// PARAMETERS:
-//
-// theHandler: the audio device file descriptor
-//
-// GLOBALS USED/MODIFIED:
-//
-// last_play_position: modified to reflect play position the last time
-// this method was called
-// total_samples_sent: used to help calculate total_samples_skipped
-// total_samples_skipped: modified to hold the total number of 16-bit
-// samples sent to wave_write, but which were
-// never played
-// sun_audio_fd: used because some calls to wave_close seem to
-// pass a NULL for theHandler for some odd reason
-//
-// RETURNS:
-//
-// The result of the ioctl call (non-0 means failure)
-//
-//<wave_close
-
-int wave_close(void* theHandler)
-{
- int ret;
- audio_info_t ainfo;
- int audio_fd = (int) theHandler;
- if (!audio_fd) {
- audio_fd = sun_audio_fd;
- }
- ENTER("wave_close");
- // [[[WDW: maybe do a pause/resume ioctl???]]]
- ret = ioctl(audio_fd, I_FLUSH, FLUSHRW);
- ioctl(audio_fd, AUDIO_GETINFO, &ainfo);
-
- // Calculate the number of samples that won't get
- // played. We also keep track of the last_play_position
- // because wave_close can be called multiple times
- // before another call to wave_write.
- //
- if (last_play_position != ainfo.play.samples) {
- last_play_position = ainfo.play.samples;
- total_samples_skipped = total_samples_sent - last_play_position;
- }
- SHOW_TIME("wave_close > LEAVE");
- return ret;
-}
-
-//>
-// wave_is_busy
-//
-// DESCRIPTION:
-//
-// Returns a non-0 value if audio is being played.
-//
-// PARAMETERS:
-//
-// theHandler: the audio device file descriptor
-//
-// GLOBALS USED/MODIFIED:
-//
-// sun_audio_fd: used because some calls to wave_is_busy seem to
-// pass a NULL for theHandler for some odd reason
-//
-// RETURNS:
-//
-// A non-0 value if audio is being played
-//
-//<wave_is_busy
-
-int wave_is_busy(void* theHandler)
-{
- uint32_t time;
- wave_get_remaining_time(total_samples_sent - 1, &time);
- return time != 0;
-}
-
-//>
-// wave_terminate
-//
-// DESCRIPTION:
-//
-// Used to end our session with eSpeak.
-//
-// GLOBALS USED/MODIFIED:
-//
-// sun_audio_fd: modified - closed and set to -1
-//
-//<wave_terminate
-
-void wave_terminate()
-{
- ENTER("wave_terminate");
- close(sun_audio_fd);
- sun_audio_fd = -1;
- SHOW_TIME("wave_terminate > LEAVE");
-}
-
-//>
-// wave_flush
-//
-// DESCRIPTION:
-//
-// Appears to want to tell the audio subsystem to make sure it plays
-// the audio. In our case, the system is already doing this, so this
-// is basically a no-op. [[[WDW - if you do a drain, you block, so
-// don't do that. In addition the typical SADA notion of flush is
-// currently handled by wave_close. I think this is most likely just
-// terminology conflict between eSpeak and SADA.]]]
-//
-// PARAMETERS:
-//
-// theHandler: the audio device file descriptor
-//
-//<wave_flush
-
-void wave_flush(void* theHandler)
-{
- ENTER("wave_flush");
- //ioctl((int) theHandler, AUDIO_DRAIN, 0);
- SHOW_TIME("wave_flush > LEAVE");
-}
-
-//>
-// wave_set_callback_is_output_enabled
-//
-// DESCRIPTION:
-//
-// Sets the callback to call from wave_write before it sends data to
-// be played. It helps wave_write determine if the data should be
-// thrown away or not.
-//
-// PARAMETERS:
-//
-// cb: the callback to call from wave_write
-//
-//<wave_set_callback_is_output_enabled
-
-void wave_set_callback_is_output_enabled(t_wave_callback* cb)
-{
- my_callback_is_output_enabled = cb;
-}
-
-//>
-// wave_test_get_write_buffer
-//
-// DESCRIPTION:
-//
-// Unnecessary and is used for debug output from
-// speak_lib.cpp:dispatch_audio.
-//
-// RETURNS:
-//
-// NULL
-//
-//<wave_test_get_write_buffer
-
-void *wave_test_get_write_buffer()
-{
- return NULL;
-}
-
-//>
-// wave_get_read_position
-//
-// DESCRIPTION:
-//
-// Concerns the sample which is currently played by the audio layer,
-// where 'sample' is a small buffer of synthesized wave data,
-// identified so that the user callback could be called when the
-// 'sample' is really played. The identifier is returned by
-// wave_get_write_position. This method is unused.
-//
-// PARAMETERS:
-//
-// theHandler: the audio device file descriptor
-//
-// RETURNS:
-//
-// The total number of 16-bit samples played by the audio system
-// so far.
-//
-//<wave_get_read_position
-
-uint32_t wave_get_read_position(void* theHandler)
-{
- audio_info_t ainfo;
- ENTER("wave_get_read_position");
- ioctl((int) theHandler, AUDIO_GETINFO, &ainfo);
- SHOW("wave_get_read_position: %d\n", ainfo.play.samples);
- SHOW_TIME("wave_get_read_position > LEAVE");
- return ainfo.play.samples;
-}
-
-//>
-// wave_get_write_position
-//
-// DESCRIPTION:
-//
-// Returns an identifier for a new sample, where 'sample' is a small
-// buffer of synthesized wave data, identified so that the user
-// callback could be called when the 'sample' is really played. This
-// implementation views the audio as one long continuous stream of
-// 16-bit samples.
-//
-// PARAMETERS:
-//
-// theHandler: the audio device file descriptor
-//
-// GLOBALS USED/MODIFIED:
-//
-// total_samples_sent: used as the return value
-//
-// RETURNS:
-//
-// total_samples_sent, which is the index for the end of this long
-// continuous stream. [[[WDW: with a unit32_t managing 16-bit
-// samples at 22050Hz, we have about 54 hours of play time before
-// the index wraps back to 0. We don't handle that wrapping, so
-// the behavior after 54 hours of play time is undefined.]]]
-//
-//<wave_get_write_position
-
-uint32_t wave_get_write_position(void* theHandler)
-{
- ENTER("wave_get_write_position");
- SHOW("wave_get_write_position: %d\n", total_samples_sent);
- SHOW_TIME("wave_get_write_position > LEAVE");
- return total_samples_sent;
-}
-
-//>
-// wave_get_remaining_time
-//
-// DESCRIPTION:
-//
-// Returns the remaining time (in ms) before the sample is played.
-// The sample in this case is a return value from a previous call to
-// wave_get_write_position.
-//
-// PARAMETERS:
-//
-// sample: an index returned from wave_get_write_position representing
-// an index into the long continuous stream of 16-bit samples
-// time: a return value representing the delay in milliseconds until
-// sample is played. A value of 0 means the sample is either
-// currently being played or it has already been played.
-//
-// GLOBALS USED/MODIFIED:
-//
-// sun_audio_fd: used to determine total number of samples played by
-// the audio system
-// total_samples_skipped: used in remaining time calculation
-//
-// RETURNS:
-//
-// Time in milliseconds before the sample is played or 0 if the sample
-// is currently playing or has already been played.
-//
-//<wave_get_remaining_time
-
-int wave_get_remaining_time(uint32_t sample, uint32_t* time)
-{
- uint32_t a_time=0;
- uint32_t actual_index;
-
- audio_info_t ainfo;
- ENTER("wave_get_remaining_time");
- if (!time) {
- return(-1);
- SHOW_TIME("wave_get_remaining_time > LEAVE");
- }
-
- ioctl(sun_audio_fd, AUDIO_GETINFO, &ainfo);
-
- // See if this sample has already been played or is currently
- // playing.
- //
- actual_index = sample - total_samples_skipped;
- if ((sample < total_samples_skipped) ||
- (actual_index <= ainfo.play.samples)) {
- *time = 0;
- } else {
- a_time = ((actual_index - ainfo.play.samples) * 1000) / SAMPLE_RATE;
- *time = (uint32_t) a_time;
- }
- SHOW("wave_get_remaining_time for %d: %d\n", sample, *time);
- SHOW_TIME("wave_get_remaining_time > LEAVE");
- return 0;
-}
-
-#else
-// notdef USE_SADA
-
-void wave_init() {}
-void* wave_open(const char* the_api) {return (void *)1;}
-size_t wave_write(void* theHandler, char* theMono16BitsWaveBuffer, size_t theSize) {return theSize;}
-int wave_close(void* theHandler) {return 0;}
-int wave_is_busy(void* theHandler) {return 0;}
-void wave_terminate() {}
-uint32_t wave_get_read_position(void* theHandler) {return 0;}
-uint32_t wave_get_write_position(void* theHandler) {return 0;}
-void wave_flush(void* theHandler) {}
-typedef int (t_wave_callback)(void);
-void wave_set_callback_is_output_enabled(t_wave_callback* cb) {}
-extern void* wave_test_get_write_buffer() {return NULL;}
-
-int wave_get_remaining_time(uint32_t sample, uint32_t* time)
-{
- if (!time) return(-1);
- *time = (uint32_t)0;
- return 0;
-}
-
-#endif // of USE_PORTAUDIO
-
-//>
-//<clock_gettime2, add_time_in_ms
-
-void clock_gettime2(struct timespec *ts)
-{
- struct timeval tv;
-
- if (!ts)
- {
- return;
- }
-
- assert (gettimeofday(&tv, NULL) != -1);
- ts->tv_sec = tv.tv_sec;
- ts->tv_nsec = tv.tv_usec*1000;
-}
-
-void add_time_in_ms(struct timespec *ts, int time_in_ms)
-{
- if (!ts)
- {
- return;
- }
-
- uint64_t t_ns = (uint64_t)ts->tv_nsec + 1000000 * (uint64_t)time_in_ms;
- while(t_ns >= ONE_BILLION)
- {
- SHOW("event > add_time_in_ms ns: %d sec %Lu nsec \n", ts->tv_sec, t_ns);
- ts->tv_sec += 1;
- t_ns -= ONE_BILLION;
- }
- ts->tv_nsec = (long int)t_ns;
-}
-
-#endif // USE_ASYNC
-
-//>
diff --git a/navit/support/espeak/wavegen.c b/navit/support/espeak/wavegen.c
deleted file mode 100755
index a5467ca1e..000000000
--- a/navit/support/espeak/wavegen.c
+++ /dev/null
@@ -1,1941 +0,0 @@
-/***************************************************************************
- * Copyright (C) 2005 to 2007 by Jonathan Duddington *
- * email: jonsd@users.sourceforge.net *
- * *
- * 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 3 of the License, 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, see: *
- * <http://www.gnu.org/licenses/>. *
- ***************************************************************************/
-
-#include "StdAfx.h"
-
-// this version keeps wavemult window as a constant fraction
-// of the cycle length - but that spreads out the HF peaks too much
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <math.h>
-
-
-#include "speak_lib.h"
-#include "speech.h"
-#include "phoneme.h"
-#include "synthesize.h"
-#include "voice.h"
-
-//#undef INCLUDE_KLATT
-
-#ifdef USE_PORTAUDIO
-#include "portaudio.h"
-#undef USE_PORTAUDIO
-// determine portaudio version by looking for a #define which is not in V18
-#ifdef paNeverDropInput
-#define USE_PORTAUDIO 19
-#else
-#define USE_PORTAUDIO 18
-#endif
-#endif
-
-#define N_SINTAB 2048
-#include "sintab.h"
-
-
-#define PI 3.1415927
-#define PI2 6.283185307
-#define N_WAV_BUF 10
-
-voice_t *wvoice;
-
-FILE *f_log = NULL;
-int option_waveout = 0;
-static int option_harmonic1 = 10; // 10
-int option_log_frames = 0;
-static int flutter_amp = 64;
-
-static int general_amplitude = 60;
-static int consonant_amp = 26; // 24
-
-int embedded_value[N_EMBEDDED_VALUES];
-
-static int PHASE_INC_FACTOR;
-int samplerate = 0; // this is set by Wavegeninit()
-int samplerate_native=0;
-extern int option_device_number;
-extern int option_quiet;
-
-static wavegen_peaks_t peaks[N_PEAKS];
-static int peak_harmonic[N_PEAKS];
-static int peak_height[N_PEAKS];
-
-#define N_ECHO_BUF 5500 // max of 250mS at 22050 Hz
-static int echo_head;
-static int echo_tail;
-static int echo_length = 0; // period (in sample\) to ensure completion of echo at the end of speech, set in WavegenSetEcho()
-static int echo_amp = 0;
-static short echo_buf[N_ECHO_BUF];
-
-static int voicing;
-static RESONATOR rbreath[N_PEAKS];
-
-static int harm_sqrt_n = 0;
-
-
-#define N_LOWHARM 30
-static int harm_inc[N_LOWHARM]; // only for these harmonics do we interpolate amplitude between steps
-static int *harmspect;
-static int hswitch=0;
-static int hspect[2][MAX_HARMONIC]; // 2 copies, we interpolate between then
-static int max_hval=0;
-
-static int nsamples=0; // number to do
-static int modulation_type = 0;
-static int glottal_flag = 0;
-static int glottal_reduce = 0;
-
-
-WGEN_DATA wdata;
-
-static int amp_ix;
-static int amp_inc;
-static unsigned char *amplitude_env = NULL;
-
-static int samplecount=0; // number done
-static int samplecount_start=0; // count at start of this segment
-static int end_wave=0; // continue to end of wave cycle
-static int wavephase;
-static int phaseinc;
-static int cycle_samples; // number of samples in a cycle at current pitch
-static int cbytes;
-static int hf_factor;
-
-static double minus_pi_t;
-static double two_pi_t;
-
-
-unsigned char *out_ptr;
-unsigned char *out_start;
-unsigned char *out_end;
-int outbuf_size = 0;
-
-// the queue of operations passed to wavegen from sythesize
-long wcmdq[N_WCMDQ][4];
-int wcmdq_head=0;
-int wcmdq_tail=0;
-
-// pitch,speed,
-int embedded_default[N_EMBEDDED_VALUES] = {0,50,170,100,50, 0,0, 0,170,0,0,0,0,0};
-static int embedded_max[N_EMBEDDED_VALUES] = {0,0x7fff,600,300,99,99,99, 0,600,0,0,0,0,4};
-
-#define N_CALLBACK_IX N_WAV_BUF-2 // adjust this delay to match display with the currently spoken word
-int current_source_index=0;
-
-extern FILE *f_wave;
-
-#if (USE_PORTAUDIO == 18)
-static PortAudioStream *pa_stream=NULL;
-#endif
-#if (USE_PORTAUDIO == 19)
-static PaStream *pa_stream=NULL;
-#endif
-
-/* default pitch envelope, a steady fall */
-#define ENV_LEN 128
-
-#define int(x) (int)(x)
-/*
-unsigned char Pitch_env0[ENV_LEN] = {
- 255,253,251,249,247,245,243,241,239,237,235,233,231,229,227,225,
- 223,221,219,217,215,213,211,209,207,205,203,201,199,197,195,193,
- 191,189,187,185,183,181,179,177,175,173,171,169,167,165,163,161,
- 159,157,155,153,151,149,147,145,143,141,139,137,135,133,131,129,
- 127,125,123,121,119,117,115,113,111,109,107,105,103,101, 99, 97,
- 95, 93, 91, 89, 87, 85, 83, 81, 79, 77, 75, 73, 71, 69, 67, 65,
- 63, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 35, 33,
- 31, 29, 27, 25, 23, 21, 19, 17, 15, 13, 11, 9, 7, 5, 3, 1
-};
-*/
-
-/*
-unsigned char Pitch_long[ENV_LEN] = {
- 254,249,250,251,252,253,254,254, 255,255,255,255,254,254,253,252,
- 251,250,249,247,244,242,238,234, 230,225,221,217,213,209,206,203,
- 199,195,191,187,183,179,175,172, 168,165,162,159,156,153,150,148,
- 145,143,140,138,136,134,132,130, 128,126,123,120,117,114,111,107,
- 104,100,96,91, 86,82,77,73, 70,66,63,60, 58,55,53,51,
- 49,47,46,45, 43,42,40,38, 36,34,31,28, 26,24,22,20,
- 18,16,14,12, 11,10,9,8, 8,8,8,8, 9,8,8,8,
- 8,8,7,7, 6,6,6,5, 4,4,3,3, 2,1,1,0
-};
-*/
-
-// 1st index=roughness
-// 2nd index=modulation_type
-// value: bits 0-3 amplitude (16ths), bits 4-7 every n cycles
-#define N_ROUGHNESS 8
-static unsigned char modulation_tab[N_ROUGHNESS][8] = {
- {0, 0x00, 0x00, 0x00, 0, 0x46, 0xf2, 0x29},
- {0, 0x2f, 0x00, 0x2f, 0, 0x45, 0xf2, 0x29},
- {0, 0x2f, 0x00, 0x2e, 0, 0x45, 0xf2, 0x28},
- {0, 0x2e, 0x00, 0x2d, 0, 0x34, 0xf2, 0x28},
- {0, 0x2d, 0x2d, 0x2c, 0, 0x34, 0xf2, 0x28},
- {0, 0x2b, 0x2b, 0x2b, 0, 0x34, 0xf2, 0x28},
- {0, 0x2a, 0x2a, 0x2a, 0, 0x34, 0xf2, 0x28},
- {0, 0x29, 0x29, 0x29, 0, 0x34, 0xf2, 0x28},
-};
-
-// Flutter table, to add natural variations to the pitch
-#define N_FLUTTER 0x170
-static int Flutter_inc;
-static const unsigned char Flutter_tab[N_FLUTTER] = {
- 0x80, 0x9b, 0xb5, 0xcb, 0xdc, 0xe8, 0xed, 0xec,
- 0xe6, 0xdc, 0xce, 0xbf, 0xb0, 0xa3, 0x98, 0x90,
- 0x8c, 0x8b, 0x8c, 0x8f, 0x92, 0x94, 0x95, 0x92,
- 0x8c, 0x83, 0x78, 0x69, 0x59, 0x49, 0x3c, 0x31,
- 0x2a, 0x29, 0x2d, 0x36, 0x44, 0x56, 0x69, 0x7d,
- 0x8f, 0x9f, 0xaa, 0xb1, 0xb2, 0xad, 0xa4, 0x96,
- 0x87, 0x78, 0x69, 0x5c, 0x53, 0x4f, 0x4f, 0x55,
- 0x5e, 0x6b, 0x7a, 0x88, 0x96, 0xa2, 0xab, 0xb0,
-
- 0xb1, 0xae, 0xa8, 0xa0, 0x98, 0x91, 0x8b, 0x88,
- 0x89, 0x8d, 0x94, 0x9d, 0xa8, 0xb2, 0xbb, 0xc0,
- 0xc1, 0xbd, 0xb4, 0xa5, 0x92, 0x7c, 0x63, 0x4a,
- 0x32, 0x1e, 0x0e, 0x05, 0x02, 0x05, 0x0f, 0x1e,
- 0x30, 0x44, 0x59, 0x6d, 0x7f, 0x8c, 0x96, 0x9c,
- 0x9f, 0x9f, 0x9d, 0x9b, 0x99, 0x99, 0x9c, 0xa1,
- 0xa9, 0xb3, 0xbf, 0xca, 0xd5, 0xdc, 0xe0, 0xde,
- 0xd8, 0xcc, 0xbb, 0xa6, 0x8f, 0x77, 0x60, 0x4b,
-
- 0x3a, 0x2e, 0x28, 0x29, 0x2f, 0x3a, 0x48, 0x59,
- 0x6a, 0x7a, 0x86, 0x90, 0x94, 0x95, 0x91, 0x89,
- 0x80, 0x75, 0x6b, 0x62, 0x5c, 0x5a, 0x5c, 0x61,
- 0x69, 0x74, 0x80, 0x8a, 0x94, 0x9a, 0x9e, 0x9d,
- 0x98, 0x90, 0x86, 0x7c, 0x71, 0x68, 0x62, 0x60,
- 0x63, 0x6b, 0x78, 0x88, 0x9b, 0xaf, 0xc2, 0xd2,
- 0xdf, 0xe6, 0xe7, 0xe2, 0xd7, 0xc6, 0xb2, 0x9c,
- 0x84, 0x6f, 0x5b, 0x4b, 0x40, 0x39, 0x37, 0x38,
-
- 0x3d, 0x43, 0x4a, 0x50, 0x54, 0x56, 0x55, 0x52,
- 0x4d, 0x48, 0x42, 0x3f, 0x3e, 0x41, 0x49, 0x56,
- 0x67, 0x7c, 0x93, 0xab, 0xc3, 0xd9, 0xea, 0xf6,
- 0xfc, 0xfb, 0xf4, 0xe7, 0xd5, 0xc0, 0xaa, 0x94,
- 0x80, 0x71, 0x64, 0x5d, 0x5a, 0x5c, 0x61, 0x68,
- 0x70, 0x77, 0x7d, 0x7f, 0x7f, 0x7b, 0x74, 0x6b,
- 0x61, 0x57, 0x4e, 0x48, 0x46, 0x48, 0x4e, 0x59,
- 0x66, 0x75, 0x84, 0x93, 0x9f, 0xa7, 0xab, 0xaa,
-
- 0xa4, 0x99, 0x8b, 0x7b, 0x6a, 0x5b, 0x4e, 0x46,
- 0x43, 0x45, 0x4d, 0x5a, 0x6b, 0x7f, 0x92, 0xa6,
- 0xb8, 0xc5, 0xcf, 0xd3, 0xd2, 0xcd, 0xc4, 0xb9,
- 0xad, 0xa1, 0x96, 0x8e, 0x89, 0x87, 0x87, 0x8a,
- 0x8d, 0x91, 0x92, 0x91, 0x8c, 0x84, 0x78, 0x68,
- 0x55, 0x41, 0x2e, 0x1c, 0x0e, 0x05, 0x01, 0x05,
- 0x0f, 0x1f, 0x34, 0x4d, 0x68, 0x81, 0x9a, 0xb0,
- 0xc1, 0xcd, 0xd3, 0xd3, 0xd0, 0xc8, 0xbf, 0xb5,
-
- 0xab, 0xa4, 0x9f, 0x9c, 0x9d, 0xa0, 0xa5, 0xaa,
- 0xae, 0xb1, 0xb0, 0xab, 0xa3, 0x96, 0x87, 0x76,
- 0x63, 0x51, 0x42, 0x36, 0x2f, 0x2d, 0x31, 0x3a,
- 0x48, 0x59, 0x6b, 0x7e, 0x8e, 0x9c, 0xa6, 0xaa,
- 0xa9, 0xa3, 0x98, 0x8a, 0x7b, 0x6c, 0x5d, 0x52,
- 0x4a, 0x48, 0x4a, 0x50, 0x5a, 0x67, 0x75, 0x82
-};
-
-// waveform shape table for HF peaks, formants 6,7,8
-#define N_WAVEMULT 128
-static int wavemult_offset=0;
-static int wavemult_max=0;
-
-// the presets are for 22050 Hz sample rate.
-// A different rate will need to recalculate the presets in WavegenInit()
-static unsigned char wavemult[N_WAVEMULT] = {
- 0, 0, 0, 2, 3, 5, 8, 11, 14, 18, 22, 27, 32, 37, 43, 49,
- 55, 62, 69, 76, 83, 90, 98,105,113,121,128,136,144,152,159,166,
- 174,181,188,194,201,207,213,218,224,228,233,237,240,244,246,249,
- 251,252,253,253,253,253,252,251,249,246,244,240,237,233,228,224,
- 218,213,207,201,194,188,181,174,166,159,152,144,136,128,121,113,
- 105, 98, 90, 83, 76, 69, 62, 55, 49, 43, 37, 32, 27, 22, 18, 14,
- 11, 8, 5, 3, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
-
-
-// set from y = pow(2,x) * 128, x=-1 to 1
-unsigned char pitch_adjust_tab[MAX_PITCH_VALUE+1] = {
- 64, 65, 66, 67, 68, 69, 70, 71,
- 72, 73, 74, 75, 76, 77, 78, 79,
- 80, 81, 82, 83, 84, 86, 87, 88,
- 89, 91, 92, 93, 94, 96, 97, 98,
- 100,101,103,104,105,107,108,110,
- 111,113,115,116,118,119,121,123,
- 124,126,128,130,132,133,135,137,
- 139,141,143,145,147,149,151,153,
- 155,158,160,162,164,167,169,171,
- 174,176,179,181,184,186,189,191,
- 194,197,199,202,205,208,211,214,
- 217,220,223,226,229,232,236,239,
- 242,246,249,252, 254,255 };
-
-int WavegenFill(int fill_zeros);
-
-
-#ifdef LOG_FRAMES
-static void LogMarker(int type, int value)
-{//=======================================
- if(option_log_frames == 0)
- return;
-
- if((type == espeakEVENT_PHONEME) || (type == espeakEVENT_SENTENCE))
- {
- f_log=fopen("log-espeakedit","a");
- if(f_log)
- {
- if(type == espeakEVENT_PHONEME)
- fprintf(f_log,"Phoneme [%s]\n",WordToString(value));
- else
- fprintf(f_log,"\n");
- fclose(f_log);
- f_log = NULL;
- }
- }
-}
-#endif
-
-void WcmdqStop()
-{//=============
- wcmdq_head = 0;
- wcmdq_tail = 0;
-#ifdef USE_PORTAUDIO
- Pa_AbortStream(pa_stream);
-#endif
-}
-
-
-int WcmdqFree()
-{//============
- int i;
- i = wcmdq_head - wcmdq_tail;
- if(i <= 0) i += N_WCMDQ;
- return(i);
-}
-
-int WcmdqUsed()
-{//============
- return(N_WCMDQ - WcmdqFree());
-}
-
-
-void WcmdqInc()
-{//============
- wcmdq_tail++;
- if(wcmdq_tail >= N_WCMDQ) wcmdq_tail=0;
-}
-
-static void WcmdqIncHead()
-{//=======================
- wcmdq_head++;
- if(wcmdq_head >= N_WCMDQ) wcmdq_head=0;
-}
-
-
-
-// data points from which to make the presets for pk_shape1 and pk_shape2
-#define PEAKSHAPEW 256
-static const float pk_shape_x[2][8] = {
- {0,-0.6f, 0.0f, 0.6f, 1.4f, 2.5f, 4.5f, 5.5f},
- {0,-0.6f, 0.0f, 0.6f, 1.4f, 2.0f, 4.5f, 5.5f }};
-static const float pk_shape_y[2][8] = {
- {0, 67, 81, 67, 31, 14, 0, -6} ,
- {0, 77, 81, 77, 31, 7, 0, -6 }};
-
-unsigned char pk_shape1[PEAKSHAPEW+1] = {
- 255,254,254,254,254,254,253,253,252,251,251,250,249,248,247,246,
- 245,244,242,241,239,238,236,234,233,231,229,227,225,223,220,218,
- 216,213,211,209,207,205,203,201,199,197,195,193,191,189,187,185,
- 183,180,178,176,173,171,169,166,164,161,159,156,154,151,148,146,
- 143,140,138,135,132,129,126,123,120,118,115,112,108,105,102, 99,
- 96, 95, 93, 91, 90, 88, 86, 85, 83, 82, 80, 79, 77, 76, 74, 73,
- 72, 70, 69, 68, 67, 66, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55,
- 55, 54, 53, 52, 52, 51, 50, 50, 49, 48, 48, 47, 47, 46, 46, 46,
- 45, 45, 45, 44, 44, 44, 44, 44, 44, 44, 43, 43, 43, 43, 44, 43,
- 42, 42, 41, 40, 40, 39, 38, 38, 37, 36, 36, 35, 35, 34, 33, 33,
- 32, 32, 31, 30, 30, 29, 29, 28, 28, 27, 26, 26, 25, 25, 24, 24,
- 23, 23, 22, 22, 21, 21, 20, 20, 19, 19, 18, 18, 18, 17, 17, 16,
- 16, 15, 15, 15, 14, 14, 13, 13, 13, 12, 12, 11, 11, 11, 10, 10,
- 10, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 5, 5,
- 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 2, 2, 2, 2, 2,
- 2, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 };
-
-static unsigned char pk_shape2[PEAKSHAPEW+1] = {
- 255,254,254,254,254,254,254,254,254,254,253,253,253,253,252,252,
- 252,251,251,251,250,250,249,249,248,248,247,247,246,245,245,244,
- 243,243,242,241,239,237,235,233,231,229,227,225,223,221,218,216,
- 213,211,208,205,203,200,197,194,191,187,184,181,178,174,171,167,
- 163,160,156,152,148,144,140,136,132,127,123,119,114,110,105,100,
- 96, 94, 91, 88, 86, 83, 81, 78, 76, 74, 71, 69, 66, 64, 62, 60,
- 57, 55, 53, 51, 49, 47, 44, 42, 40, 38, 36, 34, 32, 30, 29, 27,
- 25, 23, 21, 19, 18, 16, 14, 12, 11, 9, 7, 6, 4, 3, 1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0 };
-
-static unsigned char *pk_shape;
-
-
-static void WavegenInitPkData(int which)
-{//=====================================
-// this is only needed to set up the presets for pk_shape1 and pk_shape2
-// These have already been pre-calculated and preset
-#ifdef deleted
- int ix;
- int p;
- float x;
- float y[PEAKSHAPEW];
- float maxy=0;
-
- if(which==0)
- pk_shape = pk_shape1;
- else
- pk_shape = pk_shape2;
-
- p = 0;
- for(ix=0;ix<PEAKSHAPEW;ix++)
- {
- x = (4.5*ix)/PEAKSHAPEW;
- if(x >= pk_shape_x[which][p+3]) p++;
- y[ix] = polint(&pk_shape_x[which][p],&pk_shape_y[which][p],3,x);
- if(y[ix] > maxy) maxy = y[ix];
- }
- for(ix=0;ix<PEAKSHAPEW;ix++)
- {
- p = (int)(y[ix]*255/maxy);
- pk_shape[ix] = (p >= 0) ? p : 0;
- }
- pk_shape[PEAKSHAPEW]=0;
-#endif
-} // end of WavegenInitPkData
-
-
-
-#ifdef USE_PORTAUDIO
-// PortAudio interface
-
-static int userdata[4];
-static PaError pa_init_err=0;
-static int out_channels=1;
-
-#if USE_PORTAUDIO == 18
-static int WaveCallback(void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer, PaTimestamp outTime, void *userData )
-#else
-static int WaveCallback(const void *inputBuffer, void *outputBuffer,
- long unsigned int framesPerBuffer, const PaStreamCallbackTimeInfo *outTime,
- PaStreamCallbackFlags flags, void *userData )
-#endif
-{
- int ix;
- int result;
- unsigned char *p;
-
- out_ptr = out_start = (unsigned char *)outputBuffer;
- out_end = out_ptr + framesPerBuffer*2;
-
-#ifdef LIBRARY
- event_list_ix = 0;
-#endif
-
- result = WavegenFill(1);
-
-#ifdef LIBRARY
- count_samples += framesPerBuffer;
- if(synth_callback)
- {
- // synchronous-playback mode, allow the calling process to abort the speech
- event_list[event_list_ix].type = espeakEVENT_LIST_TERMINATED; // indicates end of event list
- event_list[event_list_ix].user_data = 0;
-
- if(synth_callback(NULL,0,event_list) == 1)
- {
- SpeakNextClause(NULL,NULL,2); // stop speaking
- result = 1;
- }
- }
-#endif
-
-#ifdef ARCH_BIG
- {
- // swap the order of bytes in each sound sample in the portaudio buffer
- int c;
- out_ptr = (unsigned char *)outputBuffer;
- out_end = out_ptr + framesPerBuffer*2;
- while(out_ptr < out_end)
- {
- c = out_ptr[0];
- out_ptr[0] = out_ptr[1];
- out_ptr[1] = c;
- out_ptr += 2;
- }
- }
-#endif
-
- if(out_channels == 2)
- {
- // sound output can only do stereo, not mono. Duplicate each sound sample to
- // produce 2 channels.
- out_ptr = (unsigned char *)outputBuffer;
- for(ix=framesPerBuffer-1; ix>=0; ix--)
- {
- p = &out_ptr[ix*4];
- p[3] = p[1] = out_ptr[ix*2 + 1];
- p[2] = p[0] = out_ptr[ix*2];
- }
- }
-
-#if USE_PORTAUDIO == 18
-#ifdef PLATFORM_WINDOWS
- return(result);
-#endif
- if(result != 0)
- {
- static int end_timer = 0;
- if(end_timer == 0)
- end_timer = 4;
- if(end_timer > 0)
- {
- end_timer--;
- if(end_timer == 0)
- return(1);
- }
- }
- return(0);
-#else
- return(result);
-#endif
-
-} // end of WaveCallBack
-
-
-#if USE_PORTAUDIO == 19
-/* This is a fixed version of Pa_OpenDefaultStream() for use if the version in portaudio V19
- is broken */
-
-static PaError Pa_OpenDefaultStream2( PaStream** stream,
- int inputChannelCount,
- int outputChannelCount,
- PaSampleFormat sampleFormat,
- double sampleRate,
- unsigned long framesPerBuffer,
- PaStreamCallback *streamCallback,
- void *userData )
-{
- PaError result;
- PaStreamParameters hostApiOutputParameters;
-
- if(option_device_number >= 0)
- hostApiOutputParameters.device = option_device_number;
- else
- hostApiOutputParameters.device = Pa_GetDefaultOutputDevice();
-
- if( hostApiOutputParameters.device == paNoDevice )
- return paDeviceUnavailable;
-
- hostApiOutputParameters.channelCount = outputChannelCount;
- hostApiOutputParameters.sampleFormat = sampleFormat;
- /* defaultHighOutputLatency is used below instead of
- defaultLowOutputLatency because it is more important for the default
- stream to work reliably than it is for it to work with the lowest
- latency.
- */
- hostApiOutputParameters.suggestedLatency =
- Pa_GetDeviceInfo( hostApiOutputParameters.device )->defaultHighOutputLatency;
- hostApiOutputParameters.hostApiSpecificStreamInfo = NULL;
-
- result = Pa_OpenStream(
- stream, NULL, &hostApiOutputParameters, sampleRate, framesPerBuffer, paNoFlag, streamCallback, userData );
-
- return(result);
-}
-#endif
-
-
-int WavegenOpenSound()
-{//===================
- PaError err, err2;
- PaError active;
-
- if(option_waveout || option_quiet)
- {
- // writing to WAV file, not to portaudio
- return(0);
- }
-
-#if USE_PORTAUDIO == 18
- active = Pa_StreamActive(pa_stream);
-#else
- active = Pa_IsStreamActive(pa_stream);
-#endif
-
- if(active == 1)
- return(0);
- if(active < 0)
- {
- out_channels = 1;
-
-#if USE_PORTAUDIO == 18
- err2 = Pa_OpenDefaultStream(&pa_stream,0,1,paInt16,samplerate,512,N_WAV_BUF,WaveCallback,(void *)userdata);
-
- if(err2 == paInvalidChannelCount)
- {
- // failed to open with mono, try stereo
- out_channels=2;
- err2 = Pa_OpenDefaultStream(&pa_stream,0,2,paInt16,samplerate,512,N_WAV_BUF,WaveCallback,(void *)userdata);
- }
-#else
- err2 = Pa_OpenDefaultStream2(&pa_stream,0,1,paInt16,(double)samplerate,512,WaveCallback,(void *)userdata);
-
- if(err2 == paInvalidChannelCount)
- {
- // failed to open with mono, try stereo
- out_channels=2;
- err2 = Pa_OpenDefaultStream(&pa_stream,0,2,paInt16,(double)samplerate,512,WaveCallback,(void *)userdata);
- }
-#endif
- }
- err = Pa_StartStream(pa_stream);
-
-#if USE_PORTAUDIO == 19
- if(err == paStreamIsNotStopped)
- {
- // not sure why we need this, but PA v19 seems to need it
- err = Pa_StopStream(pa_stream);
- err = Pa_StartStream(pa_stream);
- }
-#endif
-
- if(err != paNoError)
- {
- // exit speak if we can't open the sound device - this is OK if speak is being run for each utterance
- exit(2);
- }
-
- return(0);
-}
-
-
-
-int WavegenCloseSound()
-{//====================
- PaError active;
-
- // check whether speaking has finished, and close the stream
- if(pa_stream != NULL)
- {
-#if USE_PORTAUDIO == 18
- active = Pa_StreamActive(pa_stream);
-#else
- active = Pa_IsStreamActive(pa_stream);
-#endif
- if(WcmdqUsed() == 0) // also check that the queue is empty
- {
- if(active == 0)
- {
- Pa_CloseStream(pa_stream);
- pa_stream = NULL;
- return(1);
- }
- }
- else
- {
- WavegenOpenSound(); // still items in the queue, shouldn't be closed
- }
- }
- return(0);
-}
-
-
-int WavegenInitSound()
-{//===================
- PaError err;
-
- if(option_quiet)
- return(0);
-
- // PortAudio sound output library
- err = Pa_Initialize();
- pa_init_err = err;
- if(err != paNoError)
- {
- fprintf(stderr,"Failed to initialise the PortAudio sound\n");
- return(1);
- }
- return(0);
-}
-#else
-int WavegenOpenSound()
-{//===================
- return(0);
-}
-int WavegenCloseSound()
-{//====================
- return(0);
-}
-int WavegenInitSound()
-{//===================
- return(0);
-}
-#endif
-
-
-void WavegenInit(int rate, int wavemult_fact)
-{//==========================================
- int ix;
- double x;
-
- if(wavemult_fact == 0)
- wavemult_fact=60; // default
-
- wvoice = NULL;
- samplerate = samplerate_native = rate;
- PHASE_INC_FACTOR = 0x8000000 / samplerate; // assumes pitch is Hz*32
- Flutter_inc = (64 * samplerate)/rate;
- samplecount = 0;
- nsamples = 0;
- wavephase = 0x7fffffff;
- max_hval = 0;
-
- wdata.amplitude = 32;
- wdata.prev_was_synth = 0;
-
- for(ix=0; ix<N_EMBEDDED_VALUES; ix++)
- embedded_value[ix] = embedded_default[ix];
-
-
- // set up window to generate a spread of harmonics from a
- // single peak for HF peaks
- wavemult_max = (samplerate * wavemult_fact)/(256 * 50);
- if(wavemult_max > N_WAVEMULT) wavemult_max = N_WAVEMULT;
-
- wavemult_offset = wavemult_max/2;
-
- if(samplerate != 22050)
- {
- // wavemult table has preset values for 22050 Hz, we only need to
- // recalculate them if we have a different sample rate
- for(ix=0; ix<wavemult_max; ix++)
- {
- x = 127*(1.0 - cos(PI2*ix/wavemult_max));
- wavemult[ix] = (int)x;
- }
- }
-
- WavegenInitPkData(1);
- WavegenInitPkData(0);
- pk_shape = pk_shape2; // pk_shape2
-
-#ifdef INCLUDE_KLATT
- KlattInit();
-#endif
-
-#ifdef LOG_FRAMES
-remove("log-espeakedit");
-#endif
-} // end of WavegenInit
-
-
-int GetAmplitude(void)
-{//===================
- int amp;
-
- // normal, none, reduced, moderate, strong
- static const unsigned char amp_emphasis[5] = {16, 16, 10, 16, 22};
-
- amp = (embedded_value[EMBED_A])*55/100;
- general_amplitude = amp * amp_emphasis[embedded_value[EMBED_F]] / 16;
- return(general_amplitude);
-}
-
-
-static void WavegenSetEcho(void)
-{//=============================
- int delay;
- int amp;
-
- voicing = wvoice->voicing;
- delay = wvoice->echo_delay;
- amp = wvoice->echo_amp;
-
- if(delay >= N_ECHO_BUF)
- delay = N_ECHO_BUF-1;
- if(amp > 100)
- amp = 100;
-
- memset(echo_buf,0,sizeof(echo_buf));
- echo_tail = 0;
-
- if(embedded_value[EMBED_H] > 0)
- {
- // set echo from an embedded command in the text
- amp = embedded_value[EMBED_H];
- delay = 130;
- }
- if(embedded_value[EMBED_T] > 0)
- {
- // announcing punctuation
- amp = embedded_value[EMBED_T] * 8;
- delay = 60;
- }
-
- if(delay == 0)
- amp = 0;
-
- echo_head = (delay * samplerate)/1000;
- echo_length = echo_head; // ensure completion of echo at the end of speech. Use 1 delay period?
- if(amp == 0)
- echo_length = 0;
- if(amp > 20)
- echo_length = echo_head * 2; // perhaps allow 2 echo periods if the echo is loud.
-
- // echo_amp units are 1/256ths of the amplitude of the original sound.
- echo_amp = amp;
- // compensate (partially) for increase in amplitude due to echo
- general_amplitude = GetAmplitude();
- general_amplitude = ((general_amplitude * (500-amp))/500);
-} // end of WavegenSetEcho
-
-
-
-int PeaksToHarmspect(wavegen_peaks_t *peaks, int pitch, int *htab, int control)
-{//============================================================================
-// Calculate the amplitude of each harmonics from the formants
-// Only for formants 0 to 5
-
-// control 0=initial call, 1=every 64 cycles
-
- // pitch and freqs are Hz<<16
-
- int f;
- wavegen_peaks_t *p;
- int fp; // centre freq of peak
- int fhi; // high freq of peak
- int h; // harmonic number
- int pk;
- int hmax;
- int hmax_samplerate; // highest harmonic allowed for the samplerate
- int x;
- int ix;
- int h1;
-
-#ifdef SPECT_EDITOR
- if(harm_sqrt_n > 0)
- return(HarmToHarmspect(pitch,htab));
-#endif
-
- // initialise as much of *out as we will need
- if(wvoice == NULL)
- return(1);
- hmax = (peaks[wvoice->n_harmonic_peaks].freq + peaks[wvoice->n_harmonic_peaks].right)/pitch;
- if(hmax >= MAX_HARMONIC)
- hmax = MAX_HARMONIC-1;
-
- // restrict highest harmonic to half the samplerate
- hmax_samplerate = (((samplerate * 19)/40) << 16)/pitch; // only 95% of Nyquist freq
-// hmax_samplerate = (samplerate << 16)/(pitch*2);
-
- if(hmax > hmax_samplerate)
- hmax = hmax_samplerate;
-
- for(h=0;h<=hmax;h++)
- htab[h]=0;
-
- h=0;
- for(pk=0; pk<=wvoice->n_harmonic_peaks; pk++)
- {
- p = &peaks[pk];
- if((p->height == 0) || (fp = p->freq)==0)
- continue;
-
- fhi = p->freq + p->right;
- h = ((p->freq - p->left) / pitch) + 1;
- if(h <= 0) h = 1;
-
- for(f=pitch*h; f < fp; f+=pitch)
- {
- htab[h++] += pk_shape[(fp-f)/(p->left>>8)] * p->height;
- }
- for(; f < fhi; f+=pitch)
- {
- htab[h++] += pk_shape[(f-fp)/(p->right>>8)] * p->height;
- }
- }
-
-{
-int y;
-int h2;
- // increase bass
- y = peaks[1].height * 10; // addition as a multiple of 1/256s
- h2 = (1000<<16)/pitch; // decrease until 1000Hz
- if(h2 > 0)
- {
- x = y/h2;
- h = 1;
- while(y > 0)
- {
- htab[h++] += y;
- y -= x;
- }
- }
-}
-
- // find the nearest harmonic for HF peaks where we don't use shape
- for(; pk<N_PEAKS; pk++)
- {
- x = peaks[pk].height >> 14;
- peak_height[pk] = (x * x * 5)/2;
-
- // find the nearest harmonic for HF peaks where we don't use shape
- if(control == 0)
- {
- // set this initially, but make changes only at the quiet point
- peak_harmonic[pk] = peaks[pk].freq / pitch;
- }
- // only use harmonics up to half the samplerate
- if(peak_harmonic[pk] >= hmax_samplerate)
- peak_height[pk] = 0;
- }
-
- // convert from the square-rooted values
- f = 0;
- for(h=0; h<=hmax; h++, f+=pitch)
- {
- x = htab[h] >> 15;
- htab[h] = (x * x) >> 8;
-
- if((ix = (f >> 19)) < N_TONE_ADJUST)
- {
- htab[h] = (htab[h] * wvoice->tone_adjust[ix]) >> 13; // index tone_adjust with Hz/8
- }
- }
-
- // adjust the amplitude of the first harmonic, affects tonal quality
- h1 = htab[1] * option_harmonic1;
- htab[1] = h1/8;
-
-
- // calc intermediate increments of LF harmonics
- if(control & 1)
- {
- for(h=1; h<N_LOWHARM; h++)
- {
- harm_inc[h] = (htab[h] - harmspect[h]) >> 3;
- }
- }
-
- return(hmax); // highest harmonic number
-} // end of PeaksToHarmspect
-
-
-
-static void AdvanceParameters()
-{//============================
-// Called every 64 samples to increment the formant freq, height, and widths
-
- int x;
- int ix;
- static int Flutter_ix = 0;
-
- // advance the pitch
- wdata.pitch_ix += wdata.pitch_inc;
- if((ix = wdata.pitch_ix>>8) > 127) ix = 127;
- x = wdata.pitch_env[ix] * wdata.pitch_range;
- wdata.pitch = (x>>8) + wdata.pitch_base;
-
- amp_ix += amp_inc;
-
- /* add pitch flutter */
- if(Flutter_ix >= (N_FLUTTER*64))
- Flutter_ix = 0;
- x = ((int)(Flutter_tab[Flutter_ix >> 6])-0x80) * flutter_amp;
- Flutter_ix += Flutter_inc;
- wdata.pitch += x;
- if(wdata.pitch < 102400)
- wdata.pitch = 102400; // min pitch, 25 Hz (25 << 12)
-
- if(samplecount == samplecount_start)
- return;
-
- for(ix=0; ix <= wvoice->n_harmonic_peaks; ix++)
- {
- peaks[ix].freq1 += peaks[ix].freq_inc;
- peaks[ix].freq = (int)(peaks[ix].freq1);
- peaks[ix].height1 += peaks[ix].height_inc;
- if((peaks[ix].height = (int)(peaks[ix].height1)) < 0)
- peaks[ix].height = 0;
- peaks[ix].left1 += peaks[ix].left_inc;
- peaks[ix].left = (int)(peaks[ix].left1);
- if(ix < 3)
- {
- peaks[ix].right1 += peaks[ix].right_inc;
- peaks[ix].right = (int)(peaks[ix].right1);
- }
- else
- {
- peaks[ix].right = peaks[ix].left;
- }
- }
- for(;ix < 8; ix++)
- {
- // formants 6,7,8 don't have a width parameter
- if(ix < 7)
- {
- peaks[ix].freq1 += peaks[ix].freq_inc;
- peaks[ix].freq = (int)(peaks[ix].freq1);
- }
- peaks[ix].height1 += peaks[ix].height_inc;
- if((peaks[ix].height = (int)(peaks[ix].height1)) < 0)
- peaks[ix].height = 0;
- }
-
-#ifdef SPECT_EDITOR
- if(harm_sqrt_n != 0)
- {
- // We are generating from a harmonic spectrum at a given pitch, not from formant peaks
- for(ix=0; ix<harm_sqrt_n; ix++)
- harm_sqrt[ix] += harm_sqrt_inc[ix];
- }
-#endif
-} // end of AdvanceParameters
-
-
-#ifndef PLATFORM_RISCOS
-static double resonator(RESONATOR *r, double input)
-{//================================================
- double x;
-
- x = r->a * input + r->b * r->x1 + r->c * r->x2;
- r->x2 = r->x1;
- r->x1 = x;
-
- return x;
-}
-
-
-
-static void setresonator(RESONATOR *rp, int freq, int bwidth, int init)
-{//====================================================================
-// freq Frequency of resonator in Hz
-// bwidth Bandwidth of resonator in Hz
-// init Initialize internal data
-
- double x;
- double arg;
-
- if(init)
- {
- rp->x1 = 0;
- rp->x2 = 0;
- }
-
- // x = exp(-pi * bwidth * t)
- arg = minus_pi_t * bwidth;
- x = exp(arg);
-
- // c = -(x*x)
- rp->c = -(x * x);
-
- // b = x * 2*cos(2 pi * freq * t)
-
- arg = two_pi_t * freq;
- rp->b = x * cos(arg) * 2.0;
-
- // a = 1.0 - b - c
- rp->a = 1.0 - rp->b - rp->c;
-} // end if setresonator
-#endif
-
-
-void InitBreath(void)
-{//==================
-#ifndef PLATFORM_RISCOS
- int ix;
-
- minus_pi_t = -PI / samplerate;
- two_pi_t = -2.0 * minus_pi_t;
-
- for(ix=0; ix<N_PEAKS; ix++)
- {
- setresonator(&rbreath[ix],2000,200,1);
- }
-#endif
-} // end of InitBreath
-
-
-
-static void SetBreath()
-{//====================
-#ifndef PLATFORM_RISCOS
- int pk;
-
- if(wvoice->breath[0] == 0)
- return;
-
- for(pk=1; pk<N_PEAKS; pk++)
- {
- if(wvoice->breath[pk] != 0)
- {
- // breath[0] indicates that some breath formants are needed
- // set the freq from the current ynthesis formant and the width from the voice data
- setresonator(&rbreath[pk], peaks[pk].freq >> 16, wvoice->breathw[pk],0);
- }
- }
-#endif
-} // end of SetBreath
-
-
-static int ApplyBreath(void)
-{//=========================
- int value = 0;
-#ifndef PLATFORM_RISCOS
- int noise;
- int ix;
- int amp;
-
- // use two random numbers, for alternate formants
- noise = (rand() & 0x3fff) - 0x2000;
-
- for(ix=1; ix < N_PEAKS; ix++)
- {
- if((amp = wvoice->breath[ix]) != 0)
- {
- amp *= (peaks[ix].height >> 14);
- value += (int)(resonator(&rbreath[ix],noise) * amp);
- }
- }
-#endif
- return (value);
-}
-
-
-
-int Wavegen()
-{//==========
- unsigned short waveph;
- unsigned short theta;
- int total;
- int h;
- int ix;
- int z, z1, z2;
- int echo;
- int ov;
- static int maxh, maxh2;
- int pk;
- signed char c;
- int sample;
- int amp;
- int modn_amp, modn_period;
- static int agc = 256;
- static int h_switch_sign = 0;
- static int cycle_count = 0;
- static int amplitude2 = 0; // adjusted for pitch
-
- // continue until the output buffer is full, or
- // the required number of samples have been produced
-
- for(;;)
- {
- if((end_wave==0) && (samplecount==nsamples))
- return(0);
-
- if((samplecount & 0x3f) == 0)
- {
- // every 64 samples, adjust the parameters
- if(samplecount == 0)
- {
- hswitch = 0;
- harmspect = hspect[0];
- maxh2 = PeaksToHarmspect(peaks, wdata.pitch<<4, hspect[0], 0);
-
- // adjust amplitude to compensate for fewer harmonics at higher pitch
- amplitude2 = (wdata.amplitude * wdata.pitch)/(100 << 11);
-
- // switch sign of harmonics above about 900Hz, to reduce max peak amplitude
- h_switch_sign = 890 / (wdata.pitch >> 12);
- }
- else
- AdvanceParameters();
-
- // pitch is Hz<<12
- phaseinc = (wdata.pitch>>7) * PHASE_INC_FACTOR;
- cycle_samples = samplerate/(wdata.pitch >> 12); // sr/(pitch*2)
- hf_factor = wdata.pitch >> 11;
-
- maxh = maxh2;
- harmspect = hspect[hswitch];
- hswitch ^= 1;
- maxh2 = PeaksToHarmspect(peaks, wdata.pitch<<4, hspect[hswitch], 1);
-
- SetBreath();
- }
- else
- if((samplecount & 0x07) == 0)
- {
- for(h=1; h<N_LOWHARM && h<=maxh2 && h<=maxh; h++)
- {
- harmspect[h] += harm_inc[h];
- }
-
- // bring automctic gain control back towards unity
- if(agc < 256) agc++;
- }
-
- samplecount++;
-
- if(wavephase > 0)
- {
- wavephase += phaseinc;
- if(wavephase < 0)
- {
- // sign has changed, reached a quiet point in the waveform
- cbytes = wavemult_offset - (cycle_samples)/2;
- if(samplecount > nsamples)
- return(0);
-
- cycle_count++;
-
- for(pk=wvoice->n_harmonic_peaks+1; pk<N_PEAKS; pk++)
- {
- // find the nearest harmonic for HF peaks where we don't use shape
- peak_harmonic[pk] = peaks[pk].freq / (wdata.pitch*16);
- }
-
- // adjust amplitude to compensate for fewer harmonics at higher pitch
- amplitude2 = (wdata.amplitude * wdata.pitch)/(100 << 11);
-
- if(glottal_flag > 0)
- {
- if(glottal_flag == 3)
- {
- if((nsamples-samplecount) < (cycle_samples*2))
- {
- // Vowel before glottal-stop.
- // This is the start of the penultimate cycle, reduce its amplitude
- glottal_flag = 2;
- amplitude2 = (amplitude2 * glottal_reduce)/256;
- }
- }
- else
- if(glottal_flag == 4)
- {
- // Vowel following a glottal-stop.
- // This is the start of the second cycle, reduce its amplitude
- glottal_flag = 2;
- amplitude2 = (amplitude2 * glottal_reduce)/256;
- }
- else
- {
- glottal_flag--;
- }
- }
-
- if(amplitude_env != NULL)
- {
- // amplitude envelope is only used for creaky voice effect on certain vowels/tones
- if((ix = amp_ix>>8) > 127) ix = 127;
- amp = amplitude_env[ix];
- amplitude2 = (amplitude2 * amp)/128;
-// if(amp < 255)
-// modulation_type = 7;
- }
-
- // introduce roughness into the sound by reducing the amplitude of
- modn_period = 0;
- if(voice->roughness < N_ROUGHNESS)
- {
- modn_period = modulation_tab[voice->roughness][modulation_type];
- modn_amp = modn_period & 0xf;
- modn_period = modn_period >> 4;
- }
-
- if(modn_period != 0)
- {
- if(modn_period==0xf)
- {
- // just once */
- amplitude2 = (amplitude2 * modn_amp)/16;
- modulation_type = 0;
- }
- else
- {
- // reduce amplitude every [modn_period} cycles
- if((cycle_count % modn_period)==0)
- amplitude2 = (amplitude2 * modn_amp)/16;
- }
- }
- }
- }
- else
- {
- wavephase += phaseinc;
- }
- waveph = (unsigned short)(wavephase >> 16);
- total = 0;
-
- // apply HF peaks, formants 6,7,8
- // add a single harmonic and then spread this my multiplying by a
- // window. This is to reduce the processing power needed to add the
- // higher frequence harmonics.
- cbytes++;
- if(cbytes >=0 && cbytes<wavemult_max)
- {
- for(pk=wvoice->n_harmonic_peaks+1; pk<N_PEAKS; pk++)
- {
- theta = peak_harmonic[pk] * waveph;
- total += (long)sin_tab[theta >> 5] * peak_height[pk];
- }
-
- // spread the peaks by multiplying by a window
- total = (long)(total / hf_factor) * wavemult[cbytes];
- }
-
- // apply main peaks, formants 0 to 5
-#ifdef USE_ASSEMBLER_1
- // use an optimised routine for this loop, if available
- total += AddSineWaves(waveph, h_switch_sign, maxh, harmspect); // call an assembler code routine
-#else
- theta = waveph;
-
- for(h=1; h<=h_switch_sign; h++)
- {
- total += ((int)(sin_tab[theta >> 5]) * harmspect[h]);
- theta += waveph;
- }
- while(h<=maxh)
- {
- total -= ((int)(sin_tab[theta >> 5]) * harmspect[h]);
- theta += waveph;
- h++;
- }
-#endif
-
- if(voicing != 64)
- {
- total = (total >> 6) * voicing;
- }
-
-#ifndef PLATFORM_RISCOS
- if(wvoice->breath[0])
- {
- total += ApplyBreath();
- }
-#endif
-
- // mix with sampled wave if required
- z2 = 0;
- if(wdata.mix_wavefile_ix < wdata.n_mix_wavefile)
- {
- if(wdata.mix_wave_scale == 0)
- {
- // a 16 bit sample
- c = wdata.mix_wavefile[wdata.mix_wavefile_ix+1];
- sample = wdata.mix_wavefile[wdata.mix_wavefile_ix] + (c * 256);
- wdata.mix_wavefile_ix += 2;
- }
- else
- {
- // a 8 bit sample, scaled
- sample = (signed char)wdata.mix_wavefile[wdata.mix_wavefile_ix++] * wdata.mix_wave_scale;
- }
- z2 = (sample * wdata.amplitude_v) >> 10;
- z2 = (z2 * wdata.mix_wave_amp)/32;
- }
-
- z1 = z2 + (((total>>8) * amplitude2) >> 13);
-
- echo = (echo_buf[echo_tail++] * echo_amp);
- z1 += echo >> 8;
- if(echo_tail >= N_ECHO_BUF)
- echo_tail=0;
-
- z = (z1 * agc) >> 8;
-
- // check for overflow, 16bit signed samples
- if(z >= 32768)
- {
- ov = 8388608/z1 - 1; // 8388608 is 2^23, i.e. max value * 256
- if(ov < agc) agc = ov; // set agc to number of 1/256ths to multiply the sample by
- z = (z1 * agc) >> 8; // reduce sample by agc value to prevent overflow
- }
- else
- if(z <= -32768)
- {
- ov = -8388608/z1 - 1;
- if(ov < agc) agc = ov;
- z = (z1 * agc) >> 8;
- }
- *out_ptr++ = z;
- *out_ptr++ = z >> 8;
-
- echo_buf[echo_head++] = z;
- if(echo_head >= N_ECHO_BUF)
- echo_head = 0;
-
- if(out_ptr >= out_end)
- return(1);
- }
- return(0);
-} // end of Wavegen
-
-
-static int PlaySilence(int length, int resume)
-{//===========================================
- static int n_samples;
- int value=0;
-
- if(length == 0)
- return(0);
-
- nsamples = 0;
- samplecount = 0;
-
- if(resume==0)
- n_samples = length;
-
- while(n_samples-- > 0)
- {
- value = (echo_buf[echo_tail++] * echo_amp) >> 8;
-
- if(echo_tail >= N_ECHO_BUF)
- echo_tail = 0;
-
- *out_ptr++ = value;
- *out_ptr++ = value >> 8;
-
- echo_buf[echo_head++] = value;
- if(echo_head >= N_ECHO_BUF)
- echo_head = 0;
-
- if(out_ptr >= out_end)
- return(1);
- }
- return(0);
-} // end of PlaySilence
-
-
-
-static int PlayWave(int length, int resume, unsigned char *data, int scale, int amp)
-{//=================================================================================
- static int n_samples;
- static int ix=0;
- int value;
- signed char c;
-
- if(resume==0)
- {
- n_samples = length;
- ix = 0;
- }
-
- nsamples = 0;
- samplecount = 0;
-
- while(n_samples-- > 0)
- {
- if(scale == 0)
- {
- // 16 bits data
- c = data[ix+1];
- value = data[ix] + (c * 256);
- ix+=2;
- }
- else
- {
- // 8 bit data, shift by the specified scale factor
- value = (signed char)data[ix++] * scale;
- }
- value *= (consonant_amp * general_amplitude); // reduce strength of consonant
- value = value >> 10;
- value = (value * amp)/32;
-
- value += ((echo_buf[echo_tail++] * echo_amp) >> 8);
-
- if(value > 32767)
- value = 32768;
- else
- if(value < -32768)
- value = -32768;
-
- if(echo_tail >= N_ECHO_BUF)
- echo_tail = 0;
-
- out_ptr[0] = value;
- out_ptr[1] = value >> 8;
- out_ptr+=2;
-
- echo_buf[echo_head++] = (value*3)/4;
- if(echo_head >= N_ECHO_BUF)
- echo_head = 0;
-
- if(out_ptr >= out_end)
- return(1);
- }
- return(0);
-}
-
-
-static int SetWithRange0(int value, int max)
-{//=========================================
- if(value < 0)
- return(0);
- if(value > max)
- return(max);
- return(value);
-}
-
-
-void SetEmbedded(int control, int value)
-{//=====================================
- // there was an embedded command in the text at this point
- int sign=0;
- int command;
- int ix;
- int factor;
- int pitch_value;
-
- command = control & 0x1f;
- if((control & 0x60) == 0x60)
- sign = -1;
- else
- if((control & 0x60) == 0x40)
- sign = 1;
-
- if(command < N_EMBEDDED_VALUES)
- {
- if(sign == 0)
- embedded_value[command] = value;
- else
- embedded_value[command] += (value * sign);
- embedded_value[command] = SetWithRange0(embedded_value[command],embedded_max[command]);
- }
-
- switch(command)
- {
- case EMBED_T:
- WavegenSetEcho(); // and drop through to case P
- case EMBED_P:
- // adjust formants to give better results for a different voice pitch
- if((pitch_value = embedded_value[EMBED_P]) > MAX_PITCH_VALUE)
- pitch_value = MAX_PITCH_VALUE;
-
- factor = 256 + (25 * (pitch_value - 50))/50;
- for(ix=0; ix<=5; ix++)
- {
- wvoice->freq[ix] = (wvoice->freq2[ix] * factor)/256;
- }
- factor = embedded_value[EMBED_T]*3;
- wvoice->height[0] = (wvoice->height2[0] * (256 - factor*2))/256;
- wvoice->height[1] = (wvoice->height2[1] * (256 - factor))/256;
- break;
-
- case EMBED_A: // amplitude
- general_amplitude = GetAmplitude();
- break;
-
- case EMBED_F: // emphasiis
- general_amplitude = GetAmplitude();
- break;
-
- case EMBED_H:
- WavegenSetEcho();
- break;
- }
-}
-
-
-void WavegenSetVoice(voice_t *v)
-{//=============================
- static voice_t v2;
-
- memcpy(&v2,v,sizeof(v2));
- wvoice = &v2;
-
- if(v->peak_shape==0)
- pk_shape = pk_shape1;
- else
- pk_shape = pk_shape2;
-
- consonant_amp = (v->consonant_amp * 26) /100;
- if(samplerate <= 11000)
- {
- consonant_amp = consonant_amp*2; // emphasize consonants at low sample rates
- option_harmonic1 = 6;
- }
- WavegenSetEcho();
-}
-
-
-static void SetAmplitude(int length, unsigned char *amp_env, int value)
-{//====================================================================
- amp_ix = 0;
- if(length==0)
- amp_inc = 0;
- else
- amp_inc = (256 * ENV_LEN * STEPSIZE)/length;
-
- wdata.amplitude = (value * general_amplitude)/16;
- wdata.amplitude_v = (wdata.amplitude * wvoice->consonant_ampv * 15)/100; // for wave mixed with voiced sounds
-
- amplitude_env = amp_env;
-}
-
-
-void SetPitch2(voice_t *voice, int pitch1, int pitch2, int *pitch_base, int *pitch_range)
-{//======================================================================================
- int x;
- int base;
- int range;
- int pitch_value;
-
- if(pitch1 > pitch2)
- {
- x = pitch1; // swap values
- pitch1 = pitch2;
- pitch2 = x;
- }
-
- if((pitch_value = embedded_value[EMBED_P]) > MAX_PITCH_VALUE)
- pitch_value = MAX_PITCH_VALUE;
- pitch_value -= embedded_value[EMBED_T]; // adjust tone for announcing punctuation
- if(pitch_value < 0)
- pitch_value = 0;
-
- base = (voice->pitch_base * pitch_adjust_tab[pitch_value])/128;
- range = (voice->pitch_range * embedded_value[EMBED_R])/50;
-
- // compensate for change in pitch when the range is narrowed or widened
- base -= (range - voice->pitch_range)*18;
-
- *pitch_base = base + (pitch1 * range);
- *pitch_range = base + (pitch2 * range) - *pitch_base;
-}
-
-
-void SetPitch(int length, unsigned char *env, int pitch1, int pitch2)
-{//==================================================================
-// length in samples
-
-#ifdef LOG_FRAMES
-if(option_log_frames)
-{
- f_log=fopen("log-espeakedit","a");
- if(f_log != NULL)
- {
- fprintf(f_log," pitch %3d %3d %3dmS\n",pitch1,pitch2,(length*1000)/samplerate);
- fclose(f_log);
- f_log=NULL;
- }
-}
-#endif
- if((wdata.pitch_env = env)==NULL)
- wdata.pitch_env = env_fall; // default
-
- wdata.pitch_ix = 0;
- if(length==0)
- wdata.pitch_inc = 0;
- else
- wdata.pitch_inc = (256 * ENV_LEN * STEPSIZE)/length;
-
- SetPitch2(wvoice, pitch1, pitch2, &wdata.pitch_base, &wdata.pitch_range);
- // set initial pitch
- wdata.pitch = ((wdata.pitch_env[0] * wdata.pitch_range) >>8) + wdata.pitch_base; // Hz << 12
-
- flutter_amp = wvoice->flutter;
-
-} // end of SetPitch
-
-
-
-
-
-void SetSynth(int length, int modn, frame_t *fr1, frame_t *fr2, voice_t *v)
-{//========================================================================
- int ix;
- DOUBLEX next;
- int length2;
- int length4;
- int qix;
- int cmd;
- static int glottal_reduce_tab1[4] = {0x30, 0x30, 0x40, 0x50}; // vowel before [?], amp * 1/256
-// static int glottal_reduce_tab1[4] = {0x30, 0x40, 0x50, 0x60}; // vowel before [?], amp * 1/256
- static int glottal_reduce_tab2[4] = {0x90, 0xa0, 0xb0, 0xc0}; // vowel after [?], amp * 1/256
-
-#ifdef LOG_FRAMES
-if(option_log_frames)
-{
- f_log=fopen("log-espeakedit","a");
- if(f_log != NULL)
- {
- fprintf(f_log,"%3dmS %3d %3d %4d %4d (%3d %3d %3d %3d) to %3d %3d %4d %4d (%3d %3d %3d %3d)\n",length*1000/samplerate,
- fr1->ffreq[0],fr1->ffreq[1],fr1->ffreq[2],fr1->ffreq[3], fr1->fheight[0],fr1->fheight[1],fr1->fheight[2],fr1->fheight[3],
- fr2->ffreq[0],fr2->ffreq[1],fr2->ffreq[2],fr2->ffreq[3], fr2->fheight[0],fr2->fheight[1],fr2->fheight[2],fr2->fheight[3] );
-
- fclose(f_log);
- f_log=NULL;
- }
-}
-#endif
-
- harm_sqrt_n = 0;
- end_wave = 1;
-
- // any additional information in the param1 ?
- modulation_type = modn & 0xff;
-
- glottal_flag = 0;
- if(modn & 0x400)
- {
- glottal_flag = 3; // before a glottal stop
- glottal_reduce = glottal_reduce_tab1[(modn >> 8) & 3];
- }
- if(modn & 0x800)
- {
- glottal_flag = 4; // after a glottal stop
- glottal_reduce = glottal_reduce_tab2[(modn >> 8) & 3];
- }
-
- for(qix=wcmdq_head+1;;qix++)
- {
- if(qix >= N_WCMDQ) qix = 0;
- if(qix == wcmdq_tail) break;
-
- cmd = wcmdq[qix][0];
- if(cmd==WCMD_SPECT)
- {
- end_wave = 0; // next wave generation is from another spectrum
- break;
- }
- if((cmd==WCMD_WAVE) || (cmd==WCMD_PAUSE))
- break; // next is not from spectrum, so continue until end of wave cycle
- }
-
- // round the length to a multiple of the stepsize
- length2 = (length + STEPSIZE/2) & ~0x3f;
- if(length2 == 0)
- length2 = STEPSIZE;
-
- // add this length to any left over from the previous synth
- samplecount_start = samplecount;
- nsamples += length2;
-
- length4 = length2/4;
-
- peaks[7].freq = (7800 * v->freq[7] + v->freqadd[7]*256) << 8;
- peaks[8].freq = (9000 * v->freq[8] + v->freqadd[8]*256) << 8;
-
- for(ix=0; ix < 8; ix++)
- {
- if(ix < 7)
- {
- peaks[ix].freq1 = (fr1->ffreq[ix] * v->freq[ix] + v->freqadd[ix]*256) << 8;
- peaks[ix].freq = (int)(peaks[ix].freq1);
- next = (fr2->ffreq[ix] * v->freq[ix] + v->freqadd[ix]*256) << 8;
- peaks[ix].freq_inc = ((next - peaks[ix].freq1) * (STEPSIZE/4)) / length4; // lower headroom for fixed point math
- }
-
- peaks[ix].height1 = (fr1->fheight[ix] * v->height[ix]) << 6;
- peaks[ix].height = (int)(peaks[ix].height1);
- next = (fr2->fheight[ix] * v->height[ix]) << 6;
- peaks[ix].height_inc = ((next - peaks[ix].height1) * STEPSIZE) / length2;
-
- if(ix <= wvoice->n_harmonic_peaks)
- {
- peaks[ix].left1 = (fr1->fwidth[ix] * v->width[ix]) << 10;
- peaks[ix].left = int(peaks[ix].left1);
- next = (fr2->fwidth[ix] * v->width[ix]) << 10;
- peaks[ix].left_inc = ((next - peaks[ix].left1) * STEPSIZE) / length2;
-
- if(ix < 3)
- {
- peaks[ix].right1 = (fr1->fright[ix] * v->width[ix]) << 10;
- peaks[ix].right = int(peaks[ix].right1);
- next = (fr2->fright[ix] * v->width[ix]) << 10;
- peaks[ix].right_inc = ((next - peaks[ix].right1) * STEPSIZE) / length2;
- }
- else
- {
- peaks[ix].right = peaks[ix].left;
- }
- }
- }
-} // end of SetSynth
-
-
-static int Wavegen2(int length, int modulation, int resume, frame_t *fr1, frame_t *fr2)
-{//====================================================================================
- if(resume==0)
- SetSynth(length, modulation, fr1, fr2, wvoice);
-
- return(Wavegen());
-}
-
-void Write4Bytes(FILE *f, int value)
-{//=================================
-// Write 4 bytes to a file, least significant first
- int ix;
-
- for(ix=0; ix<4; ix++)
- {
- fputc(value & 0xff,f);
- value = value >> 8;
- }
-}
-
-
-
-
-int WavegenFill(int fill_zeros)
-{//============================
-// Pick up next wavegen commands from the queue
-// return: 0 output buffer has been filled
-// return: 1 input command queue is now empty
-
- long *q;
- int length;
- int result;
- static int resume=0;
- static int echo_complete=0;
-
-#ifdef TEST_MBROLA
- if(mbrola_name[0] != 0)
- return(MbrolaFill(fill_zeros));
-#endif
-
- while(out_ptr < out_end)
- {
- if(WcmdqUsed() <= 0)
- {
- if(echo_complete > 0)
- {
- // continue to play silence until echo is completed
- resume = PlaySilence(echo_complete,resume);
- if(resume == 1)
- return(0); // not yet finished
- }
-
- if(fill_zeros)
- {
- while(out_ptr < out_end)
- *out_ptr++ = 0;
- }
- return(1); // queue empty, close sound channel
- }
-
- result = 0;
- q = wcmdq[wcmdq_head];
- length = q[1];
-
- switch(q[0])
- {
- case WCMD_PITCH:
- SetPitch(length,(unsigned char *)q[2],q[3] >> 16,q[3] & 0xffff);
- break;
-
- case WCMD_PAUSE:
- if(resume==0)
- {
- echo_complete -= length;
- }
- wdata.n_mix_wavefile = 0;
- wdata.prev_was_synth = 0;
- result = PlaySilence(length,resume);
- break;
-
- case WCMD_WAVE:
- echo_complete = echo_length;
- wdata.n_mix_wavefile = 0;
- wdata.prev_was_synth = 0;
- result = PlayWave(length,resume,(unsigned char*)q[2], q[3] & 0xff, q[3] >> 8);
- break;
-
- case WCMD_WAVE2:
- // wave file to be played at the same time as synthesis
- wdata.mix_wave_amp = q[3] >> 8;
- wdata.mix_wave_scale = q[3] & 0xff;
- if(wdata.mix_wave_scale == 0)
- wdata.n_mix_wavefile = length*2;
- else
- wdata.n_mix_wavefile = length;
- wdata.mix_wavefile_ix = 0;
- wdata.mix_wavefile = (unsigned char *)q[2];
- break;
-
- case WCMD_SPECT2: // as WCMD_SPECT but stop any concurrent wave file
- wdata.n_mix_wavefile = 0; // ... and drop through to WCMD_SPECT case
- case WCMD_SPECT:
- echo_complete = echo_length;
- result = Wavegen2(length & 0xffff,q[1] >> 16,resume,(frame_t *)q[2],(frame_t *)q[3]);
- break;
-
-#ifdef INCLUDE_KLATT
- case WCMD_KLATT2: // as WCMD_SPECT but stop any concurrent wave file
- wdata.n_mix_wavefile = 0; // ... and drop through to WCMD_SPECT case
- case WCMD_KLATT:
- echo_complete = echo_length;
- result = Wavegen_Klatt2(length & 0xffff,q[1] >> 16,resume,(frame_t *)q[2],(frame_t *)q[3]);
- break;
-#endif
-
- case WCMD_MARKER:
- MarkerEvent(q[1],q[2],q[3],out_ptr);
-#ifdef LOG_FRAMES
- LogMarker(q[1],q[3]);
-#endif
- if(q[1] == 1)
- {
- current_source_index = q[2] & 0xffffff;
- }
- break;
-
- case WCMD_AMPLITUDE:
- SetAmplitude(length,(unsigned char *)q[2],q[3]);
- break;
-
- case WCMD_VOICE:
- WavegenSetVoice((voice_t *)q[1]);
- free((voice_t *)q[1]);
- break;
-
- case WCMD_EMBEDDED:
- SetEmbedded(q[1],q[2]);
- break;
- }
-
- if(result==0)
- {
- WcmdqIncHead();
- resume=0;
- }
- else
- {
- resume=1;
- }
- }
-
- return(0);
-} // end of WavegenFill
-
-
diff --git a/navit/support/ezxml/CMakeLists.txt b/navit/support/ezxml/CMakeLists.txt
deleted file mode 100644
index d93ad0686..000000000
--- a/navit/support/ezxml/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-supportlib_add_library(support_ezxml ezxml.c ezxml_init.c )
diff --git a/navit/support/ezxml/ezxml.c b/navit/support/ezxml/ezxml.c
deleted file mode 100644
index 991268fd6..000000000
--- a/navit/support/ezxml/ezxml.c
+++ /dev/null
@@ -1,1022 +0,0 @@
-/* ezxml.c
- *
- * Copyright 2004-2006 Aaron Voisine <aaron@voisine.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <string.h>
-#include <ctype.h>
-#include <glib.h>
-#include "config.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-#ifndef EZXML_NOMMAP
-#include <sys/mman.h>
-#endif // EZXML_NOMMAP
-#include <sys/stat.h>
-#include "ezxml.h"
-#ifdef HAVE_API_WIN32_CE
-#include "libc.h"
-#endif
-
-#define EZXML_WS "\t\r\n " // whitespace
-#define EZXML_ERRL 128 // maximum error string length
-
-typedef struct ezxml_root *ezxml_root_t;
-struct ezxml_root { // additional data for the root tag
- struct ezxml xml; // is a super-struct built on top of ezxml struct
- ezxml_t cur; // current xml tree insertion point
- char *m; // original xml string
- size_t len; // length of allocated memory for mmap, -1 for malloc
- char *u; // UTF-8 conversion of string if original was UTF-16
- char *s; // start of work area
- char *e; // end of work area
- char **ent; // general entities (ampersand sequences)
- char ***attr; // default attributes
- char ***pi; // processing instructions
- short standalone; // non-zero if <?xml standalone="yes"?>
- char err[EZXML_ERRL]; // error string
-};
-
-char *EZXML_NIL[] = { NULL }; // empty, null terminated array of strings
-
-// returns the first child tag with the given name or NULL if not found
-ezxml_t ezxml_child(ezxml_t xml, const char *name)
-{
- xml = (xml) ? xml->child : NULL;
- while (xml && strcmp(name, xml->name)) xml = xml->sibling;
- return xml;
-}
-
-// returns the Nth tag with the same name in the same subsection or NULL if not
-// found
-ezxml_t ezxml_idx(ezxml_t xml, int idx)
-{
- for (; xml && idx; idx--) xml = xml->next;
- return xml;
-}
-
-// returns the value of the requested tag attribute or NULL if not found
-const char *ezxml_attr(ezxml_t xml, const char *attr)
-{
- int i = 0, j = 1;
- ezxml_root_t root = (ezxml_root_t)xml;
-
- if (! xml || ! xml->attr) return NULL;
- while (xml->attr[i] && strcmp(attr, xml->attr[i])) i += 2;
- if (xml->attr[i]) return xml->attr[i + 1]; // found attribute
-
- while (root->xml.parent) root = (ezxml_root_t)root->xml.parent; // root tag
- for (i = 0; root->attr[i] && strcmp(xml->name, root->attr[i][0]); i++);
- if (! root->attr[i]) return NULL; // no matching default attributes
- while (root->attr[i][j] && strcmp(attr, root->attr[i][j])) j += 3;
- return (root->attr[i][j]) ? root->attr[i][j + 1] : NULL; // found default
-}
-
-// same as ezxml_get but takes an already initialized va_list
-ezxml_t ezxml_vget(ezxml_t xml, va_list ap)
-{
- char *name = va_arg(ap, char *);
- int idx = -1;
-
- if (name && *name) {
- idx = va_arg(ap, int);
- xml = ezxml_child(xml, name);
- }
- return (idx < 0) ? xml : ezxml_vget(ezxml_idx(xml, idx), ap);
-}
-
-// Traverses the xml tree to retrieve a specific subtag. Takes a variable
-// length list of tag names and indexes. The argument list must be terminated
-// by either an index of -1 or an empty string tag name. Example:
-// title = ezxml_get(library, "shelf", 0, "book", 2, "title", -1);
-// This retrieves the title of the 3rd book on the 1st shelf of library.
-// Returns NULL if not found.
-ezxml_t ezxml_get(ezxml_t xml, ...)
-{
- va_list ap;
- ezxml_t r;
-
- va_start(ap, xml);
- r = ezxml_vget(xml, ap);
- va_end(ap);
- return r;
-}
-
-// returns a null terminated array of processing instructions for the given
-// target
-const char **ezxml_pi(ezxml_t xml, const char *target)
-{
- ezxml_root_t root = (ezxml_root_t)xml;
- int i = 0;
-
- if (! root) return (const char **)EZXML_NIL;
- while (root->xml.parent) root = (ezxml_root_t)root->xml.parent; // root tag
- while (root->pi[i] && strcmp(target, root->pi[i][0])) i++; // find target
- return (const char **)((root->pi[i]) ? root->pi[i] + 1 : EZXML_NIL);
-}
-
-// set an error string and return root
-ezxml_t ezxml_err(ezxml_root_t root, char *s, const char *err, ...)
-{
- va_list ap;
- int line = 1;
- char *t, fmt[EZXML_ERRL];
-
- for (t = root->s; t < s; t++) if (*t == '\n') line++;
- g_snprintf(fmt, EZXML_ERRL, "[error near line %d]: %s", line, err);
-
- va_start(ap, err);
- g_vsnprintf(root->err, EZXML_ERRL, fmt, ap);
- va_end(ap);
-
- return &root->xml;
-}
-
-// Recursively decodes entity and character references and normalizes new lines
-// ent is a null terminated array of alternating entity names and values. set t
-// to '&' for general entity decoding, '%' for parameter entity decoding, 'c'
-// for cdata sections, ' ' for attribute normalization, or '*' for non-cdata
-// attribute normalization. Returns s, or if the decoded string is longer than
-// s, returns a malloced string that must be freed.
-char *ezxml_decode(char *s, char **ent, char t)
-{
- char *e, *r = s, *m = s;
- long b, c, d, l;
-
- for (; *s; s++) { // normalize line endings
- while (*s == '\r') {
- *(s++) = '\n';
- if (*s == '\n') memmove(s, (s + 1), strlen(s));
- }
- }
-
- for (s = r; ; ) {
- while (*s && *s != '&' && (*s != '%' || t != '%') && !isspace((unsigned char)(*s))) s++;
-
- if (! *s) break;
- else if (t != 'c' && ! strncmp(s, "&#", 2)) { // character reference
- if (s[2] == 'x') c = strtol(s + 3, &e, 16); // base 16
- else c = strtol(s + 2, &e, 10); // base 10
- if (! c || *e != ';') { s++; continue; } // not a character ref
-
- if (c < 0x80) *(s++) = c; // US-ASCII subset
- else { // multi-byte UTF-8 sequence
- for (b = 0, d = c; d; d /= 2) b++; // number of bits in c
- b = (b - 2) / 5; // number of bytes in payload
- *(s++) = (0xFF << (7 - b)) | (c >> (6 * b)); // head
- while (b) *(s++) = 0x80 | ((c >> (6 * --b)) & 0x3F); // payload
- }
-
- memmove(s, strchr(s, ';') + 1, strlen(strchr(s, ';')));
- }
- else if ((*s == '&' && (t == '&' || t == ' ' || t == '*')) ||
- (*s == '%' && t == '%')) { // entity reference
- for (b = 0; ent[b] && strncmp(s + 1, ent[b], strlen(ent[b]));
- b += 2); // find entity in entity list
-
- if (ent[b++]) { // found a match
- if ((c = strlen(ent[b])) - 1 > (e = strchr(s, ';')) - s) {
- l = (d = (s - r)) + c + strlen(e); // new length
- r = (r == m) ? strcpy(malloc(l), r) : realloc(r, l);
- e = strchr((s = r + d), ';'); // fix up pointers
- }
-
- memmove(s + c, e + 1, strlen(e)); // shift rest of string
- strncpy(s, ent[b], c); // copy in replacement text
- }
- else s++; // not a known entity
- }
- else if ((t == ' ' || t == '*') && isspace(*s)) *(s++) = ' ';
- else s++; // no decoding needed
- }
-
- if (t == '*') { // normalize spaces for non-cdata attributes
- for (s = r; *s; s++) {
- if ((l = strspn(s, " "))) memmove(s, s + l, strlen(s + l) + 1);
- while (*s && *s != ' ') s++;
- }
- if (--s >= r && *s == ' ') *s = '\0'; // trim any trailing space
- }
- return r;
-}
-
-// called when parser finds start of new tag
-void ezxml_open_tag(ezxml_root_t root, char *name, char **attr)
-{
- ezxml_t xml = root->cur;
-
- if (xml->name) xml = ezxml_add_child(xml, name, strlen(xml->txt));
- else xml->name = name; // first open tag
-
- xml->attr = attr;
- root->cur = xml; // update tag insertion point
-}
-
-// called when parser finds character content between open and closing tag
-void ezxml_char_content(ezxml_root_t root, char *s, size_t len, char t)
-{
- ezxml_t xml = root->cur;
- char *m = s;
- size_t l;
-
- if (! xml || ! xml->name || ! len) return; // sanity check
-
- s[len] = '\0'; // null terminate text (calling functions anticipate this)
- len = strlen(s = ezxml_decode(s, root->ent, t)) + 1;
-
- if (! *(xml->txt)) xml->txt = s; // initial character content
- else { // allocate our own memory and make a copy
- xml->txt = (xml->flags & EZXML_TXTM) // allocate some space
- ? realloc(xml->txt, (l = strlen(xml->txt)) + len)
- : strcpy(malloc((l = strlen(xml->txt)) + len), xml->txt);
- strcpy(xml->txt + l, s); // add new char content
- if (s != m) free(s); // free s if it was malloced by ezxml_decode()
- }
-
- if (xml->txt != m) ezxml_set_flag(xml, EZXML_TXTM);
-}
-
-// called when parser finds closing tag
-ezxml_t ezxml_close_tag(ezxml_root_t root, char *name, char *s)
-{
- if (! root->cur || ! root->cur->name || strcmp(name, root->cur->name))
- return ezxml_err(root, s, "unexpected closing tag </%s>", name);
-
- root->cur = root->cur->parent;
- return NULL;
-}
-
-// checks for circular entity references, returns non-zero if no circular
-// references are found, zero otherwise
-int ezxml_ent_ok(char *name, char *s, char **ent)
-{
- int i;
-
- for (; ; s++) {
- while (*s && *s != '&') s++; // find next entity reference
- if (! *s) return 1;
- if (! strncmp(s + 1, name, strlen(name))) return 0; // circular ref.
- for (i = 0; ent[i] && strncmp(ent[i], s + 1, strlen(ent[i])); i += 2);
- if (ent[i] && ! ezxml_ent_ok(name, ent[i + 1], ent)) return 0;
- }
-}
-
-// called when the parser finds a processing instruction
-void ezxml_proc_inst(ezxml_root_t root, char *s, size_t len)
-{
- int i = 0, j = 1;
- char *target = s;
-
- s[len] = '\0'; // null terminate instruction
- if (*(s += strcspn(s, EZXML_WS))) {
- *s = '\0'; // null terminate target
- s += strspn(s + 1, EZXML_WS) + 1; // skip whitespace after target
- }
-
- if (! strcmp(target, "xml")) { // <?xml ... ?>
- if ((s = strstr(s, "standalone")) && ! strncmp(s + strspn(s + 10,
- EZXML_WS "='\"") + 10, "yes", 3)) root->standalone = 1;
- return;
- }
-
- if (! root->pi[0]) *(root->pi = malloc(sizeof(char **))) = NULL; //first pi
-
- while (root->pi[i] && strcmp(target, root->pi[i][0])) i++; // find target
- if (! root->pi[i]) { // new target
- root->pi = realloc(root->pi, sizeof(char **) * (i + 2));
- root->pi[i] = malloc(sizeof(char *) * 3);
- root->pi[i][0] = target;
- root->pi[i][1] = (char *)(root->pi[i + 1] = NULL); // terminate pi list
- root->pi[i][2] = g_strdup(""); // empty document position list
- }
-
- while (root->pi[i][j]) j++; // find end of instruction list for this target
- root->pi[i] = realloc(root->pi[i], sizeof(char *) * (j + 3));
- root->pi[i][j + 2] = realloc(root->pi[i][j + 1], j + 1);
- strcpy(root->pi[i][j + 2] + j - 1, (root->xml.name) ? ">" : "<");
- root->pi[i][j + 1] = NULL; // null terminate pi list for this target
- root->pi[i][j] = s; // set instruction
-}
-
-// called when the parser finds an internal doctype subset
-short ezxml_internal_dtd(ezxml_root_t root, char *s, size_t len)
-{
- char q, *c, *t, *n = NULL, *v, **ent, **pe;
- int i, j;
-
- pe = memcpy(malloc(sizeof(EZXML_NIL)), EZXML_NIL, sizeof(EZXML_NIL));
-
- for (s[len] = '\0'; s; ) {
- while (*s && *s != '<' && *s != '%') s++; // find next declaration
-
- if (! *s) break;
- else if (! strncmp(s, "<!ENTITY", 8)) { // parse entity definitions
- c = s += strspn(s + 8, EZXML_WS) + 8; // skip white space separator
- n = s + strspn(s, EZXML_WS "%"); // find name
- *(s = n + strcspn(n, EZXML_WS)) = ';'; // append ; to name
-
- v = s + strspn(s + 1, EZXML_WS) + 1; // find value
- if ((q = *(v++)) != '"' && q != '\'') { // skip externals
- s = strchr(s, '>');
- continue;
- }
-
- for (i = 0, ent = (*c == '%') ? pe : root->ent; ent[i]; i++);
- ent = realloc(ent, (i + 3) * sizeof(char *)); // space for next ent
- if (*c == '%') pe = ent;
- else root->ent = ent;
-
- *(++s) = '\0'; // null terminate name
- if ((s = strchr(v, q))) *(s++) = '\0'; // null terminate value
- ent[i + 1] = ezxml_decode(v, pe, '%'); // set value
- ent[i + 2] = NULL; // null terminate entity list
- if (! ezxml_ent_ok(n, ent[i + 1], ent)) { // circular reference
- if (ent[i + 1] != v) free(ent[i + 1]);
- ezxml_err(root, v, "circular entity declaration &%s", n);
- break;
- }
- else ent[i] = n; // set entity name
- }
- else if (! strncmp(s, "<!ATTLIST", 9)) { // parse default attributes
- t = s + strspn(s + 9, EZXML_WS) + 9; // skip whitespace separator
- if (! *t) { ezxml_err(root, t, "unclosed <!ATTLIST"); break; }
- if (*(s = t + strcspn(t, EZXML_WS ">")) == '>') continue;
- else *s = '\0'; // null terminate tag name
- for (i = 0; root->attr[i] && strcmp(n, root->attr[i][0]); i++);
-
- while (*(n = ++s + strspn(s, EZXML_WS)) && *n != '>') {
- if (*(s = n + strcspn(n, EZXML_WS))) *s = '\0'; // attr name
- else { ezxml_err(root, t, "malformed <!ATTLIST"); break; }
-
- s += strspn(s + 1, EZXML_WS) + 1; // find next token
- c = (strncmp(s, "CDATA", 5)) ? "*" : " "; // is it cdata?
- if (! strncmp(s, "NOTATION", 8))
- s += strspn(s + 8, EZXML_WS) + 8;
- s = (*s == '(') ? strchr(s, ')') : s + strcspn(s, EZXML_WS);
- if (! s) { ezxml_err(root, t, "malformed <!ATTLIST"); break; }
-
- s += strspn(s, EZXML_WS ")"); // skip white space separator
- if (! strncmp(s, "#FIXED", 6))
- s += strspn(s + 6, EZXML_WS) + 6;
- if (*s == '#') { // no default value
- s += strcspn(s, EZXML_WS ">") - 1;
- if (*c == ' ') continue; // cdata is default, nothing to do
- v = NULL;
- }
- else if ((*s == '"' || *s == '\'') && // default value
- (s = strchr(v = s + 1, *s))) *s = '\0';
- else { ezxml_err(root, t, "malformed <!ATTLIST"); break; }
-
- if (! root->attr[i]) { // new tag name
- root->attr = (! i) ? malloc(2 * sizeof(char **))
- : realloc(root->attr,
- (i + 2) * sizeof(char **));
- root->attr[i] = malloc(2 * sizeof(char *));
- root->attr[i][0] = t; // set tag name
- root->attr[i][1] = (char *)(root->attr[i + 1] = NULL);
- }
-
- for (j = 1; root->attr[i][j]; j += 3); // find end of list
- root->attr[i] = realloc(root->attr[i],
- (j + 4) * sizeof(char *));
-
- root->attr[i][j + 3] = NULL; // null terminate list
- root->attr[i][j + 2] = c; // is it cdata?
- root->attr[i][j + 1] = (v) ? ezxml_decode(v, root->ent, *c)
- : NULL;
- root->attr[i][j] = n; // attribute name
- }
- }
- else if (! strncmp(s, "<!--", 4)) s = strstr(s + 4, "-->"); // comments
- else if (! strncmp(s, "<?", 2)) { // processing instructions
- if ((s = strstr(c = s + 2, "?>")))
- ezxml_proc_inst(root, c, s++ - c);
- }
- else if (*s == '<') s = strchr(s, '>'); // skip other declarations
- else if (*(s++) == '%' && ! root->standalone) break;
- }
-
- free(pe);
- return ! *root->err;
-}
-
-// Converts a UTF-16 string to UTF-8. Returns a new string that must be freed
-// or NULL if no conversion was needed.
-char *ezxml_str2utf8(char **s, size_t *len)
-{
- char *u;
- size_t l = 0, sl, max = *len;
- long c, d;
- int b, be = (**s == '\xFE') ? 1 : (**s == '\xFF') ? 0 : -1;
-
- if (be == -1) return NULL; // not UTF-16
-
- u = malloc(max);
- for (sl = 2; sl < *len - 1; sl += 2) {
- c = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF) //UTF-16BE
- : (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF); //UTF-16LE
- if (c >= 0xD800 && c <= 0xDFFF && (sl += 2) < *len - 1) { // high-half
- d = (be) ? (((*s)[sl] & 0xFF) << 8) | ((*s)[sl + 1] & 0xFF)
- : (((*s)[sl + 1] & 0xFF) << 8) | ((*s)[sl] & 0xFF);
- c = (((c & 0x3FF) << 10) | (d & 0x3FF)) + 0x10000;
- }
-
- while (l + 6 > max) u = realloc(u, max += EZXML_BUFSIZE);
- if (c < 0x80) u[l++] = c; // US-ASCII subset
- else { // multi-byte UTF-8 sequence
- for (b = 0, d = c; d; d /= 2) b++; // bits in c
- b = (b - 2) / 5; // bytes in payload
- u[l++] = (0xFF << (7 - b)) | (c >> (6 * b)); // head
- while (b) u[l++] = 0x80 | ((c >> (6 * --b)) & 0x3F); // payload
- }
- }
- return *s = realloc(u, *len = l);
-}
-
-// frees a tag attribute list
-void ezxml_free_attr(char **attr) {
- int i = 0;
- char *m;
-
- if (! attr || attr == EZXML_NIL) return; // nothing to free
- while (attr[i]) i += 2; // find end of attribute list
- m = attr[i + 1]; // list of which names and values are malloced
- for (i = 0; m[i]; i++) {
- if (m[i] & EZXML_NAMEM) free(attr[i * 2]);
- if (m[i] & EZXML_TXTM) free(attr[(i * 2) + 1]);
- }
- free(m);
- free(attr);
-}
-
-// parse the given xml string and return an ezxml structure
-ezxml_t ezxml_parse_str(char *s, size_t len)
-{
- ezxml_root_t root = (ezxml_root_t)ezxml_new(NULL);
- char q, e, *d, **attr, **a = NULL; // initialize a to avoid compile warning
- int l, i, j;
-
- root->m = s;
- if (! len) return ezxml_err(root, NULL, "root tag missing");
- root->u = ezxml_str2utf8(&s, &len); // convert utf-16 to utf-8
- root->e = (root->s = s) + len; // record start and end of work area
-
- e = s[len - 1]; // save end char
- s[len - 1] = '\0'; // turn end char into null terminator
-
- while (*s && *s != '<') s++; // find first tag
- if (! *s) return ezxml_err(root, s, "root tag missing");
-
- for (; ; ) {
- attr = (char **)EZXML_NIL;
- d = ++s;
-
- if (isalpha(*s) || *s == '_' || *s == ':' || *s < '\0') { // new tag
- if (! root->cur)
- return ezxml_err(root, d, "markup outside of root element");
-
- s += strcspn(s, EZXML_WS "/>");
- while (isspace(*s)) *(s++) = '\0'; // null terminate tag name
-
- if (*s && *s != '/' && *s != '>') // find tag in default attr list
- for (i = 0; (a = root->attr[i]) && strcmp(a[0], d); i++);
-
- for (l = 0; *s && *s != '/' && *s != '>'; l += 2) { // new attrib
- attr = (l) ? realloc(attr, (l + 4) * sizeof(char *))
- : malloc(4 * sizeof(char *)); // allocate space
- attr[l + 3] = (l) ? realloc(attr[l + 1], (l / 2) + 2)
- : malloc(2); // mem for list of maloced vals
- strcpy(attr[l + 3] + (l / 2), " "); // value is not malloced
- attr[l + 2] = NULL; // null terminate list
- attr[l + 1] = ""; // temporary attribute value
- attr[l] = s; // set attribute name
-
- s += strcspn(s, EZXML_WS "=/>");
- if (*s == '=' || isspace(*s)) {
- *(s++) = '\0'; // null terminate tag attribute name
- q = *(s += strspn(s, EZXML_WS "="));
- if (q == '"' || q == '\'') { // attribute value
- attr[l + 1] = ++s;
- while (*s && *s != q) s++;
- if (*s) *(s++) = '\0'; // null terminate attribute val
- else {
- ezxml_free_attr(attr);
- return ezxml_err(root, d, "missing %c", q);
- }
-
- for (j = 1; a && a[j] && strcmp(a[j], attr[l]); j +=3);
- attr[l + 1] = ezxml_decode(attr[l + 1], root->ent, (a
- && a[j]) ? *a[j + 2] : ' ');
- if (attr[l + 1] < d || attr[l + 1] > s)
- attr[l + 3][l / 2] = EZXML_TXTM; // value malloced
- }
- }
- while (isspace(*s)) s++;
- }
-
- if (*s == '/') { // self closing tag
- *(s++) = '\0';
- if ((*s && *s != '>') || (! *s && e != '>')) {
- if (l) ezxml_free_attr(attr);
- return ezxml_err(root, d, "missing >");
- }
- ezxml_open_tag(root, d, attr);
- ezxml_close_tag(root, d, s);
- }
- else if ((q = *s) == '>' || (! *s && e == '>')) { // open tag
- *s = '\0'; // temporarily null terminate tag name
- ezxml_open_tag(root, d, attr);
- *s = q;
- }
- else {
- if (l) ezxml_free_attr(attr);
- return ezxml_err(root, d, "missing >");
- }
- }
- else if (*s == '/') { // close tag
- s += strcspn(d = s + 1, EZXML_WS ">") + 1;
- if (! (q = *s) && e != '>') return ezxml_err(root, d, "missing >");
- *s = '\0'; // temporarily null terminate tag name
- if (ezxml_close_tag(root, d, s)) return &root->xml;
- if (isspace(*s = q)) s += strspn(s, EZXML_WS);
- }
- else if (! strncmp(s, "!--", 3)) { // xml comment
- if (! (s = strstr(s + 3, "--")) || (*(s += 2) != '>' && *s) ||
- (! *s && e != '>')) return ezxml_err(root, d, "unclosed <!--");
- }
- else if (! strncmp(s, "![CDATA[", 8)) { // cdata
- if ((s = strstr(s, "]]>")))
- ezxml_char_content(root, d + 8, (s += 2) - d - 10, 'c');
- else return ezxml_err(root, d, "unclosed <![CDATA[");
- }
- else if (! strncmp(s, "!DOCTYPE", 8)) { // dtd
- for (l = 0; *s && ((! l && *s != '>') || (l && (*s != ']' ||
- *(s + strspn(s + 1, EZXML_WS) + 1) != '>')));
- l = (*s == '[') ? 1 : l) s += strcspn(s + 1, "[]>") + 1;
- if (! *s && e != '>')
- return ezxml_err(root, d, "unclosed <!DOCTYPE");
- d = (l) ? strchr(d, '[') + 1 : d;
- if (l && ! ezxml_internal_dtd(root, d, s++ - d)) return &root->xml;
- }
- else if (*s == '?') { // <?...?> processing instructions
- do { s = strchr(s, '?'); } while (s && *(++s) && *s != '>');
- if (! s || (! *s && e != '>'))
- return ezxml_err(root, d, "unclosed <?");
- else ezxml_proc_inst(root, d + 1, s - d - 2);
- }
- else return ezxml_err(root, d, "unexpected <");
-
- if (! s || ! *s) break;
- *s = '\0';
- d = ++s;
- if (*s && *s != '<') { // tag character content
- while (*s && *s != '<') s++;
- if (*s) ezxml_char_content(root, d, s - d, '&');
- else break;
- }
- else if (! *s) break;
- }
-
- if (! root->cur) return &root->xml;
- else if (! root->cur->name) return ezxml_err(root, d, "root tag missing");
- else return ezxml_err(root, d, "unclosed tag <%s>", root->cur->name);
-}
-
-// Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire
-// stream into memory and then parses it. For xml files, use ezxml_parse_file()
-// or ezxml_parse_fd()
-ezxml_t ezxml_parse_fp(FILE *fp)
-{
- ezxml_root_t root;
- size_t l, len = 0;
- char *s;
-
- if (! (s = malloc(EZXML_BUFSIZE))) return NULL;
- do {
- len += (l = fread((s + len), 1, EZXML_BUFSIZE, fp));
- if (l == EZXML_BUFSIZE) s = realloc(s, len + EZXML_BUFSIZE);
- } while (s && l == EZXML_BUFSIZE);
-
- if (! s) return NULL;
- root = (ezxml_root_t)ezxml_parse_str(s, len);
- root->len = -1; // so we know to free s in ezxml_free()
- return &root->xml;
-}
-
-// A wrapper for ezxml_parse_str() that accepts a file descriptor. First
-// attempts to mem map the file. Failing that, reads the file into memory.
-// Returns NULL on failure.
-ezxml_t ezxml_parse_fd(int fd)
-{
- ezxml_root_t root;
- struct stat st;
- size_t l;
- void *m;
-
- if (fd == -1) return NULL;
- fstat(fd, &st);
-
-#ifndef EZXML_NOMMAP
- l = (st.st_size + sysconf(_SC_PAGESIZE) - 1) & ~(sysconf(_SC_PAGESIZE) -1);
- if ((m = mmap(NULL, l, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0)) !=
- MAP_FAILED) {
- madvise(m, l, MADV_SEQUENTIAL); // optimize for sequential access
- root = (ezxml_root_t)ezxml_parse_str(m, st.st_size);
- madvise(m, root->len = l, MADV_NORMAL); // put it back to normal
- }
- else { // mmap failed, read file into memory
-#endif // EZXML_NOMMAP
- l = read(fd, m = malloc(st.st_size), st.st_size);
- root = (ezxml_root_t)ezxml_parse_str(m, l);
- root->len = -1; // so we know to free s in ezxml_free()
-#ifndef EZXML_NOMMAP
- }
-#endif // EZXML_NOMMAP
- return &root->xml;
-}
-
-// a wrapper for ezxml_parse_fd that accepts a file name
-ezxml_t ezxml_parse_file(const char *file)
-{
- int fd = open(file, O_RDONLY, 0);
- ezxml_t xml = ezxml_parse_fd(fd);
-
- if (fd >= 0) close(fd);
- return xml;
-}
-
-// Encodes ampersand sequences appending the results to *dst, reallocating *dst
-// if length excedes max. a is non-zero for attribute encoding. Returns *dst
-char *ezxml_ampencode(const char *s, size_t len, char **dst, size_t *dlen,
- size_t *max, short a)
-{
- const char *e;
-
- for (e = s + len; s != e; s++) {
- while (*dlen + 10 > *max) *dst = realloc(*dst, *max += EZXML_BUFSIZE);
-
- switch (*s) {
- case '\0': return *dst;
- case '&': *dlen += sprintf(*dst + *dlen, "&amp;"); break;
- case '<': *dlen += sprintf(*dst + *dlen, "&lt;"); break;
- case '>': *dlen += sprintf(*dst + *dlen, "&gt;"); break;
- case '"': *dlen += sprintf(*dst + *dlen, (a) ? "&quot;" : "\""); break;
- case '\n': *dlen += sprintf(*dst + *dlen, (a) ? "&#xA;" : "\n"); break;
- case '\t': *dlen += sprintf(*dst + *dlen, (a) ? "&#x9;" : "\t"); break;
- case '\r': *dlen += sprintf(*dst + *dlen, "&#xD;"); break;
- default: (*dst)[(*dlen)++] = *s;
- }
- }
- return *dst;
-}
-
-// Recursively converts each tag to xml appending it to *s. Reallocates *s if
-// its length excedes max. start is the location of the previous tag in the
-// parent tag's character content. Returns *s.
-char *ezxml_toxml_r(ezxml_t xml, char **s, size_t *len, size_t *max,
- size_t start, char ***attr)
-{
- int i, j;
- char *txt = (xml->parent) ? xml->parent->txt : "";
- size_t off = 0;
-
- // parent character content up to this tag
- *s = ezxml_ampencode(txt + start, xml->off - start, s, len, max, 0);
-
- while (*len + strlen(xml->name) + 4 > *max) // reallocate s
- *s = realloc(*s, *max += EZXML_BUFSIZE);
-
- *len += sprintf(*s + *len, "<%s", xml->name); // open tag
- for (i = 0; xml->attr[i]; i += 2) { // tag attributes
- if (ezxml_attr(xml, xml->attr[i]) != xml->attr[i + 1]) continue;
- while (*len + strlen(xml->attr[i]) + 7 > *max) // reallocate s
- *s = realloc(*s, *max += EZXML_BUFSIZE);
-
- *len += sprintf(*s + *len, " %s=\"", xml->attr[i]);
- ezxml_ampencode(xml->attr[i + 1], -1, s, len, max, 1);
- *len += sprintf(*s + *len, "\"");
- }
-
- for (i = 0; attr[i] && strcmp(attr[i][0], xml->name); i++);
- for (j = 1; attr[i] && attr[i][j]; j += 3) { // default attributes
- if (! attr[i][j + 1] || ezxml_attr(xml, attr[i][j]) != attr[i][j + 1])
- continue; // skip duplicates and non-values
- while (*len + strlen(attr[i][j]) + 7 > *max) // reallocate s
- *s = realloc(*s, *max += EZXML_BUFSIZE);
-
- *len += sprintf(*s + *len, " %s=\"", attr[i][j]);
- ezxml_ampencode(attr[i][j + 1], -1, s, len, max, 1);
- *len += sprintf(*s + *len, "\"");
- }
- *len += sprintf(*s + *len, ">");
-
- *s = (xml->child) ? ezxml_toxml_r(xml->child, s, len, max, 0, attr) //child
- : ezxml_ampencode(xml->txt, -1, s, len, max, 0); //data
-
- while (*len + strlen(xml->name) + 4 > *max) // reallocate s
- *s = realloc(*s, *max += EZXML_BUFSIZE);
-
- *len += sprintf(*s + *len, "</%s>", xml->name); // close tag
-
- while (txt[off] && off < xml->off) off++; // make sure off is within bounds
- return (xml->ordered) ? ezxml_toxml_r(xml->ordered, s, len, max, off, attr)
- : ezxml_ampencode(txt + off, -1, s, len, max, 0);
-}
-
-// Converts an ezxml structure back to xml. Returns a string of xml data that
-// must be freed.
-char *ezxml_toxml(ezxml_t xml)
-{
- ezxml_t p = (xml) ? xml->parent : NULL, o = (xml) ? xml->ordered : NULL;
- ezxml_root_t root = (ezxml_root_t)xml;
- size_t len = 0, max = EZXML_BUFSIZE;
- char *s = strcpy(malloc(max), ""), *t, *n;
- int i, j, k;
-
- if (! xml || ! xml->name) return realloc(s, len + 1);
- while (root->xml.parent) root = (ezxml_root_t)root->xml.parent; // root tag
-
- for (i = 0; ! p && root->pi[i]; i++) { // pre-root processing instructions
- for (k = 2; root->pi[i][k - 1]; k++);
- for (j = 1; (n = root->pi[i][j]); j++) {
- if (root->pi[i][k][j - 1] == '>') continue; // not pre-root
- while (len + strlen(t = root->pi[i][0]) + strlen(n) + 7 > max)
- s = realloc(s, max += EZXML_BUFSIZE);
- len += sprintf(s + len, "<?%s%s%s?>\n", t, *n ? " " : "", n);
- }
- }
-
- xml->parent = xml->ordered = NULL;
- s = ezxml_toxml_r(xml, &s, &len, &max, 0, root->attr);
- xml->parent = p;
- xml->ordered = o;
-
- for (i = 0; ! p && root->pi[i]; i++) { // post-root processing instructions
- for (k = 2; root->pi[i][k - 1]; k++);
- for (j = 1; (n = root->pi[i][j]); j++) {
- if (root->pi[i][k][j - 1] == '<') continue; // not post-root
- while (len + strlen(t = root->pi[i][0]) + strlen(n) + 7 > max)
- s = realloc(s, max += EZXML_BUFSIZE);
- len += sprintf(s + len, "\n<?%s%s%s?>", t, *n ? " " : "", n);
- }
- }
- return realloc(s, len + 1);
-}
-
-// free the memory allocated for the ezxml structure
-void ezxml_free(ezxml_t xml)
-{
- ezxml_root_t root = (ezxml_root_t)xml;
- int i, j;
- char **a, *s;
-
- if (! xml) return;
- ezxml_free(xml->child);
- ezxml_free(xml->ordered);
-
- if (! xml->parent) { // free root tag allocations
- for (i = 10; root->ent[i]; i += 2) // 0 - 9 are default entites (<>&"')
- if ((s = root->ent[i + 1]) < root->s || s > root->e) free(s);
- free(root->ent); // free list of general entities
-
- for (i = 0; (a = root->attr[i]); i++) {
- for (j = 1; a[j++]; j += 2) // free malloced attribute values
- if (a[j] && (a[j] < root->s || a[j] > root->e)) free(a[j]);
- free(a);
- }
- if (root->attr[0]) free(root->attr); // free default attribute list
-
- for (i = 0; root->pi[i]; i++) {
- for (j = 1; root->pi[i][j]; j++);
- free(root->pi[i][j + 1]);
- free(root->pi[i]);
- }
- if (root->pi[0]) free(root->pi); // free processing instructions
-
- if (root->len == -1) free(root->m); // malloced xml data
-#ifndef EZXML_NOMMAP
- else if (root->len) munmap(root->m, root->len); // mem mapped xml data
-#endif // EZXML_NOMMAP
- if (root->u) free(root->u); // utf8 conversion
- }
-
- ezxml_free_attr(xml->attr); // tag attributes
- if ((xml->flags & EZXML_TXTM)) free(xml->txt); // character content
- if ((xml->flags & EZXML_NAMEM)) free(xml->name); // tag name
- free(xml);
-}
-
-// return parser error message or empty string if none
-const char *ezxml_error(ezxml_t xml)
-{
- while (xml && xml->parent) xml = xml->parent; // find root tag
- return (xml) ? ((ezxml_root_t)xml)->err : "";
-}
-
-// returns a new empty ezxml structure with the given root tag name
-ezxml_t ezxml_new(const char *name)
-{
- static char *ent[] = { "lt;", "&#60;", "gt;", "&#62;", "quot;", "&#34;",
- "apos;", "&#39;", "amp;", "&#38;", NULL };
- ezxml_root_t root = (ezxml_root_t)memset(malloc(sizeof(struct ezxml_root)),
- '\0', sizeof(struct ezxml_root));
- root->xml.name = (char *)name;
- root->cur = &root->xml;
- strcpy(root->err, root->xml.txt = "");
- root->ent = memcpy(malloc(sizeof(ent)), ent, sizeof(ent));
- root->attr = root->pi = (char ***)(root->xml.attr = EZXML_NIL);
- return &root->xml;
-}
-
-// inserts an existing tag into an ezxml structure
-ezxml_t ezxml_insert(ezxml_t xml, ezxml_t dest, size_t off)
-{
- ezxml_t cur, prev, head;
-
- xml->next = xml->sibling = xml->ordered = NULL;
- xml->off = off;
- xml->parent = dest;
-
- if ((head = dest->child)) { // already have sub tags
- if (head->off <= off) { // not first subtag
- for (cur = head; cur->ordered && cur->ordered->off <= off;
- cur = cur->ordered);
- xml->ordered = cur->ordered;
- cur->ordered = xml;
- }
- else { // first subtag
- xml->ordered = head;
- dest->child = xml;
- }
-
- for (cur = head, prev = NULL; cur && strcmp(cur->name, xml->name);
- prev = cur, cur = cur->sibling); // find tag type
- if (cur && cur->off <= off) { // not first of type
- while (cur->next && cur->next->off <= off) cur = cur->next;
- xml->next = cur->next;
- cur->next = xml;
- }
- else { // first tag of this type
- if (prev && cur) prev->sibling = cur->sibling; // remove old first
- xml->next = cur; // old first tag is now next
- for (cur = head, prev = NULL; cur && cur->off <= off;
- prev = cur, cur = cur->sibling); // new sibling insert point
- xml->sibling = cur;
- if (prev) prev->sibling = xml;
- }
- }
- else dest->child = xml; // only sub tag
-
- return xml;
-}
-
-// Adds a child tag. off is the offset of the child tag relative to the start
-// of the parent tag's character content. Returns the child tag.
-ezxml_t ezxml_add_child(ezxml_t xml, const char *name, size_t off)
-{
- ezxml_t child;
-
- if (! xml) return NULL;
- child = (ezxml_t)memset(malloc(sizeof(struct ezxml)), '\0',
- sizeof(struct ezxml));
- child->name = (char *)name;
- child->attr = EZXML_NIL;
- child->txt = "";
-
- return ezxml_insert(child, xml, off);
-}
-
-// sets the character content for the given tag and returns the tag
-ezxml_t ezxml_set_txt(ezxml_t xml, const char *txt)
-{
- if (! xml) return NULL;
- if (xml->flags & EZXML_TXTM) free(xml->txt); // existing txt was malloced
- xml->flags &= ~EZXML_TXTM;
- xml->txt = (char *)txt;
- return xml;
-}
-
-// Sets the given tag attribute or adds a new attribute if not found. A value
-// of NULL will remove the specified attribute. Returns the tag given.
-ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value)
-{
- int l = 0, c;
-
- if (! xml) return NULL;
- while (xml->attr[l] && strcmp(xml->attr[l], name)) l += 2;
- if (! xml->attr[l]) { // not found, add as new attribute
- if (! value) return xml; // nothing to do
- if (xml->attr == EZXML_NIL) { // first attribute
- xml->attr = malloc(4 * sizeof(char *));
- xml->attr[1] = g_strdup(""); // empty list of malloced names/vals
- }
- else xml->attr = realloc(xml->attr, (l + 4) * sizeof(char *));
-
- xml->attr[l] = (char *)name; // set attribute name
- xml->attr[l + 2] = NULL; // null terminate attribute list
- xml->attr[l + 3] = realloc(xml->attr[l + 1],
- (c = strlen(xml->attr[l + 1])) + 2);
- strcpy(xml->attr[l + 3] + c, " "); // set name/value as not malloced
- if (xml->flags & EZXML_DUP) xml->attr[l + 3][c] = EZXML_NAMEM;
- }
- else if (xml->flags & EZXML_DUP) free((char *)name); // name was strduped
-
- for (c = l; xml->attr[c]; c += 2); // find end of attribute list
- if (xml->attr[c + 1][l / 2] & EZXML_TXTM) free(xml->attr[l + 1]); //old val
- if (xml->flags & EZXML_DUP) xml->attr[c + 1][l / 2] |= EZXML_TXTM;
- else xml->attr[c + 1][l / 2] &= ~EZXML_TXTM;
-
- if (value) xml->attr[l + 1] = (char *)value; // set attribute value
- else { // remove attribute
- if (xml->attr[c + 1][l / 2] & EZXML_NAMEM) free(xml->attr[l]);
- memmove(xml->attr + l, xml->attr + l + 2, (c - l + 2) * sizeof(char*));
- xml->attr = realloc(xml->attr, (c + 2) * sizeof(char *));
- memmove(xml->attr[c + 1] + (l / 2), xml->attr[c + 1] + (l / 2) + 1,
- (c / 2) - (l / 2)); // fix list of which name/vals are malloced
- }
- xml->flags &= ~EZXML_DUP; // clear strdup() flag
- return xml;
-}
-
-// sets a flag for the given tag and returns the tag
-ezxml_t ezxml_set_flag(ezxml_t xml, short flag)
-{
- if (xml) xml->flags |= flag;
- return xml;
-}
-
-// removes a tag along with its subtags without freeing its memory
-ezxml_t ezxml_cut(ezxml_t xml)
-{
- ezxml_t cur;
-
- if (! xml) return NULL; // nothing to do
- if (xml->next) xml->next->sibling = xml->sibling; // patch sibling list
-
- if (xml->parent) { // not root tag
- cur = xml->parent->child; // find head of subtag list
- if (cur == xml) xml->parent->child = xml->ordered; // first subtag
- else { // not first subtag
- while (cur->ordered != xml) cur = cur->ordered;
- cur->ordered = cur->ordered->ordered; // patch ordered list
-
- cur = xml->parent->child; // go back to head of subtag list
- if (strcmp(cur->name, xml->name)) { // not in first sibling list
- while (strcmp(cur->sibling->name, xml->name))
- cur = cur->sibling;
- if (cur->sibling == xml) { // first of a sibling list
- cur->sibling = (xml->next) ? xml->next
- : cur->sibling->sibling;
- }
- else cur = cur->sibling; // not first of a sibling list
- }
-
- while (cur->next && cur->next != xml) cur = cur->next;
- if (cur->next) cur->next = cur->next->next; // patch next list
- }
- }
- xml->ordered = xml->sibling = xml->next = NULL;
- return xml;
-}
-
-#ifdef EZXML_TEST // test harness
-int main(int argc, char **argv)
-{
- ezxml_t xml;
- char *s;
- int i;
-
- if (argc != 2) return fprintf(stderr, "usage: %s xmlfile\n", argv[0]);
-
- xml = ezxml_parse_file(argv[1]);
- printf("%s\n", (s = ezxml_toxml(xml)));
- free(s);
- i = fprintf(stderr, "%s", ezxml_error(xml));
- ezxml_free(xml);
- return (i) ? 1 : 0;
-}
-#endif // EZXML_TEST
diff --git a/navit/support/ezxml/ezxml.h b/navit/support/ezxml/ezxml.h
deleted file mode 100644
index a0cb92ee5..000000000
--- a/navit/support/ezxml/ezxml.h
+++ /dev/null
@@ -1,167 +0,0 @@
-/* ezxml.h
- *
- * Copyright 2004-2006 Aaron Voisine <aaron@voisine.org>
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sublicense, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
- * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _EZXML_H
-#define _EZXML_H
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <stdarg.h>
-#include <fcntl.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define EZXML_BUFSIZE 1024 // size of internal memory buffers
-#define EZXML_NAMEM 0x80 // name is malloced
-#define EZXML_TXTM 0x40 // txt is malloced
-#define EZXML_DUP 0x20 // attribute name and value are strduped
-
-typedef struct ezxml *ezxml_t;
-struct ezxml {
- char *name; // tag name
- char **attr; // tag attributes { name, value, name, value, ... NULL }
- char *txt; // tag character content, empty string if none
- size_t off; // tag offset from start of parent tag character content
- ezxml_t next; // next tag with same name in this section at this depth
- ezxml_t sibling; // next tag with different name in same section and depth
- ezxml_t ordered; // next tag, same section and depth, in original order
- ezxml_t child; // head of sub tag list, NULL if none
- ezxml_t parent; // parent tag, NULL if current tag is root tag
- short flags; // additional information
-};
-
-// Given a string of xml data and its length, parses it and creates an ezxml
-// structure. For efficiency, modifies the data by adding null terminators
-// and decoding ampersand sequences. If you don't want this, copy the data and
-// pass in the copy. Returns NULL on failure.
-ezxml_t ezxml_parse_str(char *s, size_t len);
-
-// A wrapper for ezxml_parse_str() that accepts a file descriptor. First
-// attempts to mem map the file. Failing that, reads the file into memory.
-// Returns NULL on failure.
-ezxml_t ezxml_parse_fd(int fd);
-
-// a wrapper for ezxml_parse_fd() that accepts a file name
-ezxml_t ezxml_parse_file(const char *file);
-
-// Wrapper for ezxml_parse_str() that accepts a file stream. Reads the entire
-// stream into memory and then parses it. For xml files, use ezxml_parse_file()
-// or ezxml_parse_fd()
-ezxml_t ezxml_parse_fp(FILE *fp);
-
-// returns the first child tag (one level deeper) with the given name or NULL
-// if not found
-ezxml_t ezxml_child(ezxml_t xml, const char *name);
-
-// returns the next tag of the same name in the same section and depth or NULL
-// if not found
-#define ezxml_next(xml) ((xml) ? xml->next : NULL)
-
-// Returns the Nth tag with the same name in the same section at the same depth
-// or NULL if not found. An index of 0 returns the tag given.
-ezxml_t ezxml_idx(ezxml_t xml, int idx);
-
-// returns the name of the given tag
-#define ezxml_name(xml) ((xml) ? xml->name : NULL)
-
-// returns the given tag's character content or empty string if none
-#define ezxml_txt(xml) ((xml) ? xml->txt : "")
-
-// returns the value of the requested tag attribute, or NULL if not found
-const char *ezxml_attr(ezxml_t xml, const char *attr);
-
-// Traverses the ezxml sturcture to retrieve a specific subtag. Takes a
-// variable length list of tag names and indexes. The argument list must be
-// terminated by either an index of -1 or an empty string tag name. Example:
-// title = ezxml_get(library, "shelf", 0, "book", 2, "title", -1);
-// This retrieves the title of the 3rd book on the 1st shelf of library.
-// Returns NULL if not found.
-ezxml_t ezxml_get(ezxml_t xml, ...);
-
-// Converts an ezxml structure back to xml. Returns a string of xml data that
-// must be freed.
-char *ezxml_toxml(ezxml_t xml);
-
-// returns a NULL terminated array of processing instructions for the given
-// target
-const char **ezxml_pi(ezxml_t xml, const char *target);
-
-// frees the memory allocated for an ezxml structure
-void ezxml_free(ezxml_t xml);
-
-// returns parser error message or empty string if none
-const char *ezxml_error(ezxml_t xml);
-
-// returns a new empty ezxml structure with the given root tag name
-ezxml_t ezxml_new(const char *name);
-
-// wrapper for ezxml_new() that strdup()s name
-#define ezxml_new_d(name) ezxml_set_flag(ezxml_new(strdup(name)), EZXML_NAMEM)
-
-// Adds a child tag. off is the offset of the child tag relative to the start
-// of the parent tag's character content. Returns the child tag.
-ezxml_t ezxml_add_child(ezxml_t xml, const char *name, size_t off);
-
-// wrapper for ezxml_add_child() that strdup()s name
-#define ezxml_add_child_d(xml, name, off) \
- ezxml_set_flag(ezxml_add_child(xml, strdup(name), off), EZXML_NAMEM)
-
-// sets the character content for the given tag and returns the tag
-ezxml_t ezxml_set_txt(ezxml_t xml, const char *txt);
-
-// wrapper for ezxml_set_txt() that strdup()s txt
-#define ezxml_set_txt_d(xml, txt) \
- ezxml_set_flag(ezxml_set_txt(xml, strdup(txt)), EZXML_TXTM)
-
-// Sets the given tag attribute or adds a new attribute if not found. A value
-// of NULL will remove the specified attribute. Returns the tag given.
-ezxml_t ezxml_set_attr(ezxml_t xml, const char *name, const char *value);
-
-// Wrapper for ezxml_set_attr() that strdup()s name/value. Value cannot be NULL
-#define ezxml_set_attr_d(xml, name, value) \
- ezxml_set_attr(ezxml_set_flag(xml, EZXML_DUP), g_strdup(name), strdup(value))
-
-// sets a flag for the given tag and returns the tag
-ezxml_t ezxml_set_flag(ezxml_t xml, short flag);
-
-// removes a tag along with its subtags without freeing its memory
-ezxml_t ezxml_cut(ezxml_t xml);
-
-// inserts an existing tag into an ezxml structure
-ezxml_t ezxml_insert(ezxml_t xml, ezxml_t dest, size_t off);
-
-// Moves an existing tag to become a subtag of dest at the given offset from
-// the start of dest's character content. Returns the moved tag.
-#define ezxml_move(xml, dest, off) ezxml_insert(ezxml_cut(xml), dest, off)
-
-// removes a tag along with all its subtags
-#define ezxml_remove(xml) ezxml_free(ezxml_cut(xml))
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif // _EZXML_H
diff --git a/navit/support/ezxml/ezxml_init.c b/navit/support/ezxml/ezxml_init.c
deleted file mode 100644
index 32be387da..000000000
--- a/navit/support/ezxml/ezxml_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "plugin.h"
-
-void
-plugin_init(void)
-{
-}
diff --git a/navit/support/gettext_intl/CMakeLists.txt b/navit/support/gettext_intl/CMakeLists.txt
deleted file mode 100644
index ab74f3f1c..000000000
--- a/navit/support/gettext_intl/CMakeLists.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-add_definitions(-DLOCALE_ALIAS_PATH=LOCALEDIR -DIN_LIBINTL=1 -DHAVE_CONFIG_H=1 -DENABLE_RELOCATABLE=1 -DIN_LIBRARY -DNO_XMALLOC -Dset_relocation_prefix=libintl_set_relocation_prefix -Drelocate=libintl_relocate -DDEPENDS_ON_LIBICONV=1 -DLIBDIR=\"${CMAKE_INSTALL_PREFIX}/${LIB_DIR}\")
-supportlib_add_library(support_gettext_intl bindtextdom.c dcgettext.c dcigettext.c dcngettext.c dgettext.c dngettext.c explodename.c finddomain.c gettext.c intl-compat.c l10nflist.c loadmsgcat.c localcharset.c localealias.c localename.c log.c ngettext.c osdep.c plural-exp.c plural.c printf-args.c printf.c relocatable.c textdomain.c vasnprintf.c)
-ADD_CUSTOM_TARGET(libintl.h DEPENDS libgnuintl.h COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/libgnuintl.h ${CMAKE_CURRENT_BINARY_DIR}/libintl.h)
-ADD_DEPENDENCIES(support_gettext_intl libintl.h)
diff --git a/navit/support/gettext_intl/ChangeLog b/navit/support/gettext_intl/ChangeLog
deleted file mode 100644
index 751291929..000000000
--- a/navit/support/gettext_intl/ChangeLog
+++ /dev/null
@@ -1,4 +0,0 @@
-2004-01-29 GNU <bug-gnu-gettext@gnu.org>
-
- * Version 0.14.1 released.
-
diff --git a/navit/support/gettext_intl/VERSION b/navit/support/gettext_intl/VERSION
deleted file mode 100644
index b4b846ca7..000000000
--- a/navit/support/gettext_intl/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-GNU gettext library from gettext-0.14.1
diff --git a/navit/support/gettext_intl/bindtextdom.c b/navit/support/gettext_intl/bindtextdom.c
deleted file mode 100644
index dcdc40085..000000000
--- a/navit/support/gettext_intl/bindtextdom.c
+++ /dev/null
@@ -1,363 +0,0 @@
-/* Implementation of the bindtextdomain(3) function
- Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef _LIBC
-# include <libintl.h>
-#else
-# include "libgnuintl.h"
-#endif
-#include "gettextP.h"
-
-#ifdef _LIBC
-/* We have to handle multi-threaded applications. */
-# include <bits/libc-lock.h>
-#else
-/* Provide dummy implementation if this is outside glibc. */
-# define __libc_rwlock_define(CLASS, NAME)
-# define __libc_rwlock_wrlock(NAME)
-# define __libc_rwlock_unlock(NAME)
-#endif
-
-/* The internal variables in the standalone libintl.a must have different
- names than the internal variables in GNU libc, otherwise programs
- using libintl.a cannot be linked statically. */
-#if !defined _LIBC
-# define _nl_default_dirname libintl_nl_default_dirname
-# define _nl_domain_bindings libintl_nl_domain_bindings
-#endif
-
-/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>. */
-#ifndef offsetof
-# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
-#endif
-
-/* @@ end of prolog @@ */
-
-/* Contains the default location of the message catalogs. */
-extern const char _nl_default_dirname[];
-#ifdef _LIBC
-extern const char _nl_default_dirname_internal[] attribute_hidden;
-#else
-# define INTUSE(name) name
-#endif
-
-/* List with bindings of specific domains. */
-extern struct binding *_nl_domain_bindings;
-
-/* Lock variable to protect the global data in the gettext implementation. */
-__libc_rwlock_define (extern, _nl_state_lock attribute_hidden)
-
-
-/* Names for the libintl functions are a problem. They must not clash
- with existing names and they should follow ANSI C. But this source
- code is also used in GNU C Library where the names have a __
- prefix. So we have to make a difference here. */
-#ifdef _LIBC
-# define BINDTEXTDOMAIN __bindtextdomain
-# define BIND_TEXTDOMAIN_CODESET __bind_textdomain_codeset
-# ifndef strdup
-# define strdup(str) __strdup (str)
-# endif
-#else
-# define BINDTEXTDOMAIN libintl_bindtextdomain
-# define BIND_TEXTDOMAIN_CODESET libintl_bind_textdomain_codeset
-#endif
-
-/* Specifies the directory name *DIRNAMEP and the output codeset *CODESETP
- to be used for the DOMAINNAME message catalog.
- If *DIRNAMEP or *CODESETP is NULL, the corresponding attribute is not
- modified, only the current value is returned.
- If DIRNAMEP or CODESETP is NULL, the corresponding attribute is neither
- modified nor returned. */
-static void
-set_binding_values (const char *domainname,
- const char **dirnamep, const char **codesetp)
-{
- struct binding *binding;
- int modified;
-
- /* Some sanity checks. */
- if (domainname == NULL || domainname[0] == '\0')
- {
- if (dirnamep)
- *dirnamep = NULL;
- if (codesetp)
- *codesetp = NULL;
- return;
- }
-
- __libc_rwlock_wrlock (_nl_state_lock);
-
- modified = 0;
-
- for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
- {
- int compare = strcmp (domainname, binding->domainname);
- if (compare == 0)
- /* We found it! */
- break;
- if (compare < 0)
- {
- /* It is not in the list. */
- binding = NULL;
- break;
- }
- }
-
- if (binding != NULL)
- {
- if (dirnamep)
- {
- const char *dirname = *dirnamep;
-
- if (dirname == NULL)
- /* The current binding has be to returned. */
- *dirnamep = binding->dirname;
- else
- {
- /* The domain is already bound. If the new value and the old
- one are equal we simply do nothing. Otherwise replace the
- old binding. */
- char *result = binding->dirname;
- if (strcmp (dirname, result) != 0)
- {
- if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0)
- result = (char *) INTUSE(_nl_default_dirname);
- else
- {
-#if defined _LIBC || defined HAVE_STRDUP
- result = strdup (dirname);
-#else
- size_t len = strlen (dirname) + 1;
- result = (char *) malloc (len);
- if (__builtin_expect (result != NULL, 1))
- memcpy (result, dirname, len);
-#endif
- }
-
- if (__builtin_expect (result != NULL, 1))
- {
- if (binding->dirname != INTUSE(_nl_default_dirname))
- free (binding->dirname);
-
- binding->dirname = result;
- modified = 1;
- }
- }
- *dirnamep = result;
- }
- }
-
- if (codesetp)
- {
- const char *codeset = *codesetp;
-
- if (codeset == NULL)
- /* The current binding has be to returned. */
- *codesetp = binding->codeset;
- else
- {
- /* The domain is already bound. If the new value and the old
- one are equal we simply do nothing. Otherwise replace the
- old binding. */
- char *result = binding->codeset;
- if (result == NULL || strcmp (codeset, result) != 0)
- {
-#if defined _LIBC || defined HAVE_STRDUP
- result = strdup (codeset);
-#else
- size_t len = strlen (codeset) + 1;
- result = (char *) malloc (len);
- if (__builtin_expect (result != NULL, 1))
- memcpy (result, codeset, len);
-#endif
-
- if (__builtin_expect (result != NULL, 1))
- {
- if (binding->codeset != NULL)
- free (binding->codeset);
-
- binding->codeset = result;
- binding->codeset_cntr++;
- modified = 1;
- }
- }
- *codesetp = result;
- }
- }
- }
- else if ((dirnamep == NULL || *dirnamep == NULL)
- && (codesetp == NULL || *codesetp == NULL))
- {
- /* Simply return the default values. */
- if (dirnamep)
- *dirnamep = INTUSE(_nl_default_dirname);
- if (codesetp)
- *codesetp = NULL;
- }
- else
- {
- /* We have to create a new binding. */
- size_t len = strlen (domainname) + 1;
- struct binding *new_binding =
- (struct binding *) malloc (offsetof (struct binding, domainname) + len);
-
- if (__builtin_expect (new_binding == NULL, 0))
- goto failed;
-
- memcpy (new_binding->domainname, domainname, len);
-
- if (dirnamep)
- {
- const char *dirname = *dirnamep;
-
- if (dirname == NULL)
- /* The default value. */
- dirname = INTUSE(_nl_default_dirname);
- else
- {
- if (strcmp (dirname, INTUSE(_nl_default_dirname)) == 0)
- dirname = INTUSE(_nl_default_dirname);
- else
- {
- char *result;
-#if defined _LIBC || defined HAVE_STRDUP
- result = strdup (dirname);
- if (__builtin_expect (result == NULL, 0))
- goto failed_dirname;
-#else
- size_t len = strlen (dirname) + 1;
- result = (char *) malloc (len);
- if (__builtin_expect (result == NULL, 0))
- goto failed_dirname;
- memcpy (result, dirname, len);
-#endif
- dirname = result;
- }
- }
- *dirnamep = dirname;
- new_binding->dirname = (char *) dirname;
- }
- else
- /* The default value. */
- new_binding->dirname = (char *) INTUSE(_nl_default_dirname);
-
- new_binding->codeset_cntr = 0;
-
- if (codesetp)
- {
- const char *codeset = *codesetp;
-
- if (codeset != NULL)
- {
- char *result;
-
-#if defined _LIBC || defined HAVE_STRDUP
- result = strdup (codeset);
- if (__builtin_expect (result == NULL, 0))
- goto failed_codeset;
-#else
- size_t len = strlen (codeset) + 1;
- result = (char *) malloc (len);
- if (__builtin_expect (result == NULL, 0))
- goto failed_codeset;
- memcpy (result, codeset, len);
-#endif
- codeset = result;
- new_binding->codeset_cntr++;
- }
- *codesetp = codeset;
- new_binding->codeset = (char *) codeset;
- }
- else
- new_binding->codeset = NULL;
-
- /* Now enqueue it. */
- if (_nl_domain_bindings == NULL
- || strcmp (domainname, _nl_domain_bindings->domainname) < 0)
- {
- new_binding->next = _nl_domain_bindings;
- _nl_domain_bindings = new_binding;
- }
- else
- {
- binding = _nl_domain_bindings;
- while (binding->next != NULL
- && strcmp (domainname, binding->next->domainname) > 0)
- binding = binding->next;
-
- new_binding->next = binding->next;
- binding->next = new_binding;
- }
-
- modified = 1;
-
- /* Here we deal with memory allocation failures. */
- if (0)
- {
- failed_codeset:
- if (new_binding->dirname != INTUSE(_nl_default_dirname))
- free (new_binding->dirname);
- failed_dirname:
- free (new_binding);
- failed:
- if (dirnamep)
- *dirnamep = NULL;
- if (codesetp)
- *codesetp = NULL;
- }
- }
-
- /* If we modified any binding, we flush the caches. */
- if (modified)
- ++_nl_msg_cat_cntr;
-
- __libc_rwlock_unlock (_nl_state_lock);
-}
-
-/* Specify that the DOMAINNAME message catalog will be found
- in DIRNAME rather than in the system locale data base. */
-char *
-BINDTEXTDOMAIN (const char *domainname, const char *dirname)
-{
- set_binding_values (domainname, &dirname, NULL);
- return (char *) dirname;
-}
-
-/* Specify the character encoding in which the messages from the
- DOMAINNAME message catalog will be returned. */
-char *
-BIND_TEXTDOMAIN_CODESET (const char *domainname, const char *codeset)
-{
- set_binding_values (domainname, NULL, &codeset);
- return (char *) codeset;
-}
-
-#ifdef _LIBC
-/* Aliases for function names in GNU C Library. */
-weak_alias (__bindtextdomain, bindtextdomain);
-weak_alias (__bind_textdomain_codeset, bind_textdomain_codeset);
-#endif
diff --git a/navit/support/gettext_intl/config.charset b/navit/support/gettext_intl/config.charset
deleted file mode 100755
index 43d45fb75..000000000
--- a/navit/support/gettext_intl/config.charset
+++ /dev/null
@@ -1,608 +0,0 @@
-#! /bin/sh
-# Output a system dependent table of character encoding aliases.
-#
-# Copyright (C) 2000-2004 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Library 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
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-# USA.
-#
-# The table consists of lines of the form
-# ALIAS CANONICAL
-#
-# ALIAS is the (system dependent) result of "nl_langinfo (CODESET)".
-# ALIAS is compared in a case sensitive way.
-#
-# CANONICAL is the GNU canonical name for this character encoding.
-# It must be an encoding supported by libiconv. Support by GNU libc is
-# also desirable. CANONICAL is case insensitive. Usually an upper case
-# MIME charset name is preferred.
-# The current list of GNU canonical charset names is as follows.
-#
-# name MIME? used by which systems
-# ASCII, ANSI_X3.4-1968 glibc solaris freebsd darwin
-# ISO-8859-1 Y glibc aix hpux irix osf solaris freebsd darwin
-# ISO-8859-2 Y glibc aix hpux irix osf solaris freebsd darwin
-# ISO-8859-3 Y glibc solaris
-# ISO-8859-4 Y osf solaris freebsd darwin
-# ISO-8859-5 Y glibc aix hpux irix osf solaris freebsd darwin
-# ISO-8859-6 Y glibc aix hpux solaris
-# ISO-8859-7 Y glibc aix hpux irix osf solaris
-# ISO-8859-8 Y glibc aix hpux osf solaris
-# ISO-8859-9 Y glibc aix hpux irix osf solaris
-# ISO-8859-13 glibc
-# ISO-8859-14 glibc
-# ISO-8859-15 glibc aix osf solaris freebsd
-# KOI8-R Y glibc solaris freebsd darwin
-# KOI8-U Y glibc freebsd darwin
-# KOI8-T glibc
-# CP437 dos
-# CP775 dos
-# CP850 aix osf dos
-# CP852 dos
-# CP855 dos
-# CP856 aix
-# CP857 dos
-# CP861 dos
-# CP862 dos
-# CP864 dos
-# CP865 dos
-# CP866 freebsd darwin dos
-# CP869 dos
-# CP874 woe32 dos
-# CP922 aix
-# CP932 aix woe32 dos
-# CP943 aix
-# CP949 osf woe32 dos
-# CP950 woe32 dos
-# CP1046 aix
-# CP1124 aix
-# CP1125 dos
-# CP1129 aix
-# CP1250 woe32
-# CP1251 glibc solaris darwin woe32
-# CP1252 aix woe32
-# CP1253 woe32
-# CP1254 woe32
-# CP1255 glibc woe32
-# CP1256 woe32
-# CP1257 woe32
-# GB2312 Y glibc aix hpux irix solaris freebsd darwin
-# EUC-JP Y glibc aix hpux irix osf solaris freebsd darwin
-# EUC-KR Y glibc aix hpux irix osf solaris freebsd darwin
-# EUC-TW glibc aix hpux irix osf solaris
-# BIG5 Y glibc aix hpux osf solaris freebsd darwin
-# BIG5-HKSCS glibc solaris
-# GBK glibc aix osf solaris woe32 dos
-# GB18030 glibc solaris
-# SHIFT_JIS Y hpux osf solaris freebsd darwin
-# JOHAB glibc solaris woe32
-# TIS-620 glibc aix hpux osf solaris
-# VISCII Y glibc
-# TCVN5712-1 glibc
-# GEORGIAN-PS glibc
-# HP-ROMAN8 hpux
-# HP-ARABIC8 hpux
-# HP-GREEK8 hpux
-# HP-HEBREW8 hpux
-# HP-TURKISH8 hpux
-# HP-KANA8 hpux
-# DEC-KANJI osf
-# DEC-HANYU osf
-# UTF-8 Y glibc aix hpux osf solaris
-#
-# Note: Names which are not marked as being a MIME name should not be used in
-# Internet protocols for information interchange (mail, news, etc.).
-#
-# Note: ASCII and ANSI_X3.4-1968 are synonymous canonical names. Applications
-# must understand both names and treat them as equivalent.
-#
-# The first argument passed to this file is the canonical host specification,
-# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
-# or
-# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
-
-host="$1"
-os=`echo "$host" | sed -e 's/^[^-]*-[^-]*-\(.*\)$/\1/'`
-echo "# This file contains a table of character encoding aliases,"
-echo "# suitable for operating system '${os}'."
-echo "# It was automatically generated from config.charset."
-# List of references, updated during installation:
-echo "# Packages using this file: "
-case "$os" in
- linux-gnulibc1*)
- # Linux libc5 doesn't have nl_langinfo(CODESET); therefore
- # localcharset.c falls back to using the full locale name
- # from the environment variables.
- echo "C ASCII"
- echo "POSIX ASCII"
- for l in af af_ZA ca ca_ES da da_DK de de_AT de_BE de_CH de_DE de_LU \
- en en_AU en_BW en_CA en_DK en_GB en_IE en_NZ en_US en_ZA \
- en_ZW es es_AR es_BO es_CL es_CO es_DO es_EC es_ES es_GT \
- es_HN es_MX es_PA es_PE es_PY es_SV es_US es_UY es_VE et \
- et_EE eu eu_ES fi fi_FI fo fo_FO fr fr_BE fr_CA fr_CH fr_FR \
- fr_LU ga ga_IE gl gl_ES id id_ID in in_ID is is_IS it it_CH \
- it_IT kl kl_GL nl nl_BE nl_NL no no_NO pt pt_BR pt_PT sv \
- sv_FI sv_SE; do
- echo "$l ISO-8859-1"
- echo "$l.iso-8859-1 ISO-8859-1"
- echo "$l.iso-8859-15 ISO-8859-15"
- echo "$l.iso-8859-15@euro ISO-8859-15"
- echo "$l@euro ISO-8859-15"
- echo "$l.cp-437 CP437"
- echo "$l.cp-850 CP850"
- echo "$l.cp-1252 CP1252"
- echo "$l.cp-1252@euro CP1252"
- #echo "$l.atari-st ATARI-ST" # not a commonly used encoding
- echo "$l.utf-8 UTF-8"
- echo "$l.utf-8@euro UTF-8"
- done
- for l in cs cs_CZ hr hr_HR hu hu_HU pl pl_PL ro ro_RO sk sk_SK sl \
- sl_SI sr sr_CS sr_YU; do
- echo "$l ISO-8859-2"
- echo "$l.iso-8859-2 ISO-8859-2"
- echo "$l.cp-852 CP852"
- echo "$l.cp-1250 CP1250"
- echo "$l.utf-8 UTF-8"
- done
- for l in mk mk_MK ru ru_RU; do
- echo "$l ISO-8859-5"
- echo "$l.iso-8859-5 ISO-8859-5"
- echo "$l.koi8-r KOI8-R"
- echo "$l.cp-866 CP866"
- echo "$l.cp-1251 CP1251"
- echo "$l.utf-8 UTF-8"
- done
- for l in ar ar_SA; do
- echo "$l ISO-8859-6"
- echo "$l.iso-8859-6 ISO-8859-6"
- echo "$l.cp-864 CP864"
- #echo "$l.cp-868 CP868" # not a commonly used encoding
- echo "$l.cp-1256 CP1256"
- echo "$l.utf-8 UTF-8"
- done
- for l in el el_GR gr gr_GR; do
- echo "$l ISO-8859-7"
- echo "$l.iso-8859-7 ISO-8859-7"
- echo "$l.cp-869 CP869"
- echo "$l.cp-1253 CP1253"
- echo "$l.cp-1253@euro CP1253"
- echo "$l.utf-8 UTF-8"
- echo "$l.utf-8@euro UTF-8"
- done
- for l in he he_IL iw iw_IL; do
- echo "$l ISO-8859-8"
- echo "$l.iso-8859-8 ISO-8859-8"
- echo "$l.cp-862 CP862"
- echo "$l.cp-1255 CP1255"
- echo "$l.utf-8 UTF-8"
- done
- for l in tr tr_TR; do
- echo "$l ISO-8859-9"
- echo "$l.iso-8859-9 ISO-8859-9"
- echo "$l.cp-857 CP857"
- echo "$l.cp-1254 CP1254"
- echo "$l.utf-8 UTF-8"
- done
- for l in lt lt_LT lv lv_LV; do
- #echo "$l BALTIC" # not a commonly used encoding, wrong encoding name
- echo "$l ISO-8859-13"
- done
- for l in ru_UA uk uk_UA; do
- echo "$l KOI8-U"
- done
- for l in zh zh_CN; do
- #echo "$l GB_2312-80" # not a commonly used encoding, wrong encoding name
- echo "$l GB2312"
- done
- for l in ja ja_JP ja_JP.EUC; do
- echo "$l EUC-JP"
- done
- for l in ko ko_KR; do
- echo "$l EUC-KR"
- done
- for l in th th_TH; do
- echo "$l TIS-620"
- done
- for l in fa fa_IR; do
- #echo "$l ISIRI-3342" # a broken encoding
- echo "$l.utf-8 UTF-8"
- done
- ;;
- linux* | *-gnu*)
- # With glibc-2.1 or newer, we don't need any canonicalization,
- # because glibc has iconv and both glibc and libiconv support all
- # GNU canonical names directly. Therefore, the Makefile does not
- # need to install the alias file at all.
- # The following applies only to glibc-2.0.x and older libcs.
- echo "ISO_646.IRV:1983 ASCII"
- ;;
- aix*)
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-6 ISO-8859-6"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-8 ISO-8859-8"
- echo "ISO8859-9 ISO-8859-9"
- echo "ISO8859-15 ISO-8859-15"
- echo "IBM-850 CP850"
- echo "IBM-856 CP856"
- echo "IBM-921 ISO-8859-13"
- echo "IBM-922 CP922"
- echo "IBM-932 CP932"
- echo "IBM-943 CP943"
- echo "IBM-1046 CP1046"
- echo "IBM-1124 CP1124"
- echo "IBM-1129 CP1129"
- echo "IBM-1252 CP1252"
- echo "IBM-eucCN GB2312"
- echo "IBM-eucJP EUC-JP"
- echo "IBM-eucKR EUC-KR"
- echo "IBM-eucTW EUC-TW"
- echo "big5 BIG5"
- echo "GBK GBK"
- echo "TIS-620 TIS-620"
- echo "UTF-8 UTF-8"
- ;;
- hpux*)
- echo "iso88591 ISO-8859-1"
- echo "iso88592 ISO-8859-2"
- echo "iso88595 ISO-8859-5"
- echo "iso88596 ISO-8859-6"
- echo "iso88597 ISO-8859-7"
- echo "iso88598 ISO-8859-8"
- echo "iso88599 ISO-8859-9"
- echo "iso885915 ISO-8859-15"
- echo "roman8 HP-ROMAN8"
- echo "arabic8 HP-ARABIC8"
- echo "greek8 HP-GREEK8"
- echo "hebrew8 HP-HEBREW8"
- echo "turkish8 HP-TURKISH8"
- echo "kana8 HP-KANA8"
- echo "tis620 TIS-620"
- echo "big5 BIG5"
- echo "eucJP EUC-JP"
- echo "eucKR EUC-KR"
- echo "eucTW EUC-TW"
- echo "hp15CN GB2312"
- #echo "ccdc ?" # what is this?
- echo "SJIS SHIFT_JIS"
- echo "utf8 UTF-8"
- ;;
- irix*)
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-9 ISO-8859-9"
- echo "eucCN GB2312"
- echo "eucJP EUC-JP"
- echo "eucKR EUC-KR"
- echo "eucTW EUC-TW"
- ;;
- osf*)
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-4 ISO-8859-4"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-8 ISO-8859-8"
- echo "ISO8859-9 ISO-8859-9"
- echo "ISO8859-15 ISO-8859-15"
- echo "cp850 CP850"
- echo "big5 BIG5"
- echo "dechanyu DEC-HANYU"
- echo "dechanzi GB2312"
- echo "deckanji DEC-KANJI"
- echo "deckorean EUC-KR"
- echo "eucJP EUC-JP"
- echo "eucKR EUC-KR"
- echo "eucTW EUC-TW"
- echo "GBK GBK"
- echo "KSC5601 CP949"
- echo "sdeckanji EUC-JP"
- echo "SJIS SHIFT_JIS"
- echo "TACTIS TIS-620"
- echo "UTF-8 UTF-8"
- ;;
- solaris*)
- echo "646 ASCII"
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-3 ISO-8859-3"
- echo "ISO8859-4 ISO-8859-4"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-6 ISO-8859-6"
- echo "ISO8859-7 ISO-8859-7"
- echo "ISO8859-8 ISO-8859-8"
- echo "ISO8859-9 ISO-8859-9"
- echo "ISO8859-15 ISO-8859-15"
- echo "koi8-r KOI8-R"
- echo "ansi-1251 CP1251"
- echo "BIG5 BIG5"
- echo "Big5-HKSCS BIG5-HKSCS"
- echo "gb2312 GB2312"
- echo "GBK GBK"
- echo "GB18030 GB18030"
- echo "cns11643 EUC-TW"
- echo "5601 EUC-KR"
- echo "ko_KR.johap92 JOHAB"
- echo "eucJP EUC-JP"
- echo "PCK SHIFT_JIS"
- echo "TIS620.2533 TIS-620"
- #echo "sun_eu_greek ?" # what is this?
- echo "UTF-8 UTF-8"
- ;;
- freebsd* | os2*)
- # FreeBSD 4.2 doesn't have nl_langinfo(CODESET); therefore
- # localcharset.c falls back to using the full locale name
- # from the environment variables.
- # Likewise for OS/2. OS/2 has XFree86 just like FreeBSD. Just
- # reuse FreeBSD's locale data for OS/2.
- echo "C ASCII"
- echo "US-ASCII ASCII"
- for l in la_LN lt_LN; do
- echo "$l.ASCII ASCII"
- done
- for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
- fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT la_LN \
- lt_LN nl_BE nl_NL no_NO pt_PT sv_SE; do
- echo "$l.ISO_8859-1 ISO-8859-1"
- echo "$l.DIS_8859-15 ISO-8859-15"
- done
- for l in cs_CZ hr_HR hu_HU la_LN lt_LN pl_PL sl_SI; do
- echo "$l.ISO_8859-2 ISO-8859-2"
- done
- for l in la_LN lt_LT; do
- echo "$l.ISO_8859-4 ISO-8859-4"
- done
- for l in ru_RU ru_SU; do
- echo "$l.KOI8-R KOI8-R"
- echo "$l.ISO_8859-5 ISO-8859-5"
- echo "$l.CP866 CP866"
- done
- echo "uk_UA.KOI8-U KOI8-U"
- echo "zh_TW.BIG5 BIG5"
- echo "zh_TW.Big5 BIG5"
- echo "zh_CN.EUC GB2312"
- echo "ja_JP.EUC EUC-JP"
- echo "ja_JP.SJIS SHIFT_JIS"
- echo "ja_JP.Shift_JIS SHIFT_JIS"
- echo "ko_KR.EUC EUC-KR"
- ;;
- netbsd*)
- echo "646 ASCII"
- echo "ISO8859-1 ISO-8859-1"
- echo "ISO8859-2 ISO-8859-2"
- echo "ISO8859-4 ISO-8859-4"
- echo "ISO8859-5 ISO-8859-5"
- echo "ISO8859-15 ISO-8859-15"
- echo "eucCN GB2312"
- echo "eucJP EUC-JP"
- echo "eucKR EUC-KR"
- echo "eucTW EUC-TW"
- echo "BIG5 BIG5"
- echo "SJIS SHIFT_JIS"
- ;;
- darwin*)
- # Darwin 6.8 doesn't have nl_langinfo(CODESET); therefore
- # localcharset.c falls back to using the full locale name
- # from the environment variables.
- echo "C ASCII"
- for l in en_AU en_CA en_GB en_US la_LN; do
- echo "$l.US-ASCII ASCII"
- done
- for l in da_DK de_AT de_CH de_DE en_AU en_CA en_GB en_US es_ES \
- fi_FI fr_BE fr_CA fr_CH fr_FR is_IS it_CH it_IT nl_BE \
- nl_NL no_NO pt_PT sv_SE; do
- echo "$l ISO-8859-1"
- echo "$l.ISO8859-1 ISO-8859-1"
- echo "$l.ISO8859-15 ISO-8859-15"
- done
- for l in la_LN; do
- echo "$l.ISO8859-1 ISO-8859-1"
- echo "$l.ISO8859-15 ISO-8859-15"
- done
- for l in cs_CZ hr_HR hu_HU la_LN pl_PL sl_SI; do
- echo "$l.ISO8859-2 ISO-8859-2"
- done
- for l in la_LN lt_LT; do
- echo "$l.ISO8859-4 ISO-8859-4"
- done
- for l in ru_RU; do
- echo "$l.KOI8-R KOI8-R"
- echo "$l.ISO8859-5 ISO-8859-5"
- echo "$l.CP866 CP866"
- done
- for l in bg_BG; do
- echo "$l.CP1251 CP1251"
- done
- echo "uk_UA.KOI8-U KOI8-U"
- echo "zh_TW.BIG5 BIG5"
- echo "zh_TW.Big5 BIG5"
- echo "zh_CN.EUC GB2312"
- echo "ja_JP.EUC EUC-JP"
- echo "ja_JP.SJIS SHIFT_JIS"
- echo "ko_KR.EUC EUC-KR"
- ;;
- beos*)
- # BeOS has a single locale, and it has UTF-8 encoding.
- echo "* UTF-8"
- ;;
- msdosdjgpp*)
- # DJGPP 2.03 doesn't have nl_langinfo(CODESET); therefore
- # localcharset.c falls back to using the full locale name
- # from the environment variables.
- echo "#"
- echo "# The encodings given here may not all be correct."
- echo "# If you find that the encoding given for your language and"
- echo "# country is not the one your DOS machine actually uses, just"
- echo "# correct it in this file, and send a mail to"
- echo "# Juan Manuel Guerrero <st001906@hrz1.hrz.tu-darmstadt.de>"
- echo "# and Bruno Haible <bruno@clisp.org>."
- echo "#"
- echo "C ASCII"
- # ISO-8859-1 languages
- echo "ca CP850"
- echo "ca_ES CP850"
- echo "da CP865" # not CP850 ??
- echo "da_DK CP865" # not CP850 ??
- echo "de CP850"
- echo "de_AT CP850"
- echo "de_CH CP850"
- echo "de_DE CP850"
- echo "en CP850"
- echo "en_AU CP850" # not CP437 ??
- echo "en_CA CP850"
- echo "en_GB CP850"
- echo "en_NZ CP437"
- echo "en_US CP437"
- echo "en_ZA CP850" # not CP437 ??
- echo "es CP850"
- echo "es_AR CP850"
- echo "es_BO CP850"
- echo "es_CL CP850"
- echo "es_CO CP850"
- echo "es_CR CP850"
- echo "es_CU CP850"
- echo "es_DO CP850"
- echo "es_EC CP850"
- echo "es_ES CP850"
- echo "es_GT CP850"
- echo "es_HN CP850"
- echo "es_MX CP850"
- echo "es_NI CP850"
- echo "es_PA CP850"
- echo "es_PY CP850"
- echo "es_PE CP850"
- echo "es_SV CP850"
- echo "es_UY CP850"
- echo "es_VE CP850"
- echo "et CP850"
- echo "et_EE CP850"
- echo "eu CP850"
- echo "eu_ES CP850"
- echo "fi CP850"
- echo "fi_FI CP850"
- echo "fr CP850"
- echo "fr_BE CP850"
- echo "fr_CA CP850"
- echo "fr_CH CP850"
- echo "fr_FR CP850"
- echo "ga CP850"
- echo "ga_IE CP850"
- echo "gd CP850"
- echo "gd_GB CP850"
- echo "gl CP850"
- echo "gl_ES CP850"
- echo "id CP850" # not CP437 ??
- echo "id_ID CP850" # not CP437 ??
- echo "is CP861" # not CP850 ??
- echo "is_IS CP861" # not CP850 ??
- echo "it CP850"
- echo "it_CH CP850"
- echo "it_IT CP850"
- echo "lt CP775"
- echo "lt_LT CP775"
- echo "lv CP775"
- echo "lv_LV CP775"
- echo "nb CP865" # not CP850 ??
- echo "nb_NO CP865" # not CP850 ??
- echo "nl CP850"
- echo "nl_BE CP850"
- echo "nl_NL CP850"
- echo "nn CP865" # not CP850 ??
- echo "nn_NO CP865" # not CP850 ??
- echo "no CP865" # not CP850 ??
- echo "no_NO CP865" # not CP850 ??
- echo "pt CP850"
- echo "pt_BR CP850"
- echo "pt_PT CP850"
- echo "sv CP850"
- echo "sv_SE CP850"
- # ISO-8859-2 languages
- echo "cs CP852"
- echo "cs_CZ CP852"
- echo "hr CP852"
- echo "hr_HR CP852"
- echo "hu CP852"
- echo "hu_HU CP852"
- echo "pl CP852"
- echo "pl_PL CP852"
- echo "ro CP852"
- echo "ro_RO CP852"
- echo "sk CP852"
- echo "sk_SK CP852"
- echo "sl CP852"
- echo "sl_SI CP852"
- echo "sq CP852"
- echo "sq_AL CP852"
- echo "sr CP852" # CP852 or CP866 or CP855 ??
- echo "sr_CS CP852" # CP852 or CP866 or CP855 ??
- echo "sr_YU CP852" # CP852 or CP866 or CP855 ??
- # ISO-8859-3 languages
- echo "mt CP850"
- echo "mt_MT CP850"
- # ISO-8859-5 languages
- echo "be CP866"
- echo "be_BE CP866"
- echo "bg CP866" # not CP855 ??
- echo "bg_BG CP866" # not CP855 ??
- echo "mk CP866" # not CP855 ??
- echo "mk_MK CP866" # not CP855 ??
- echo "ru CP866"
- echo "ru_RU CP866"
- echo "uk CP1125"
- echo "uk_UA CP1125"
- # ISO-8859-6 languages
- echo "ar CP864"
- echo "ar_AE CP864"
- echo "ar_DZ CP864"
- echo "ar_EG CP864"
- echo "ar_IQ CP864"
- echo "ar_IR CP864"
- echo "ar_JO CP864"
- echo "ar_KW CP864"
- echo "ar_MA CP864"
- echo "ar_OM CP864"
- echo "ar_QA CP864"
- echo "ar_SA CP864"
- echo "ar_SY CP864"
- # ISO-8859-7 languages
- echo "el CP869"
- echo "el_GR CP869"
- # ISO-8859-8 languages
- echo "he CP862"
- echo "he_IL CP862"
- # ISO-8859-9 languages
- echo "tr CP857"
- echo "tr_TR CP857"
- # Japanese
- echo "ja CP932"
- echo "ja_JP CP932"
- # Chinese
- echo "zh_CN GBK"
- echo "zh_TW CP950" # not CP938 ??
- # Korean
- echo "kr CP949" # not CP934 ??
- echo "kr_KR CP949" # not CP934 ??
- # Thai
- echo "th CP874"
- echo "th_TH CP874"
- # Other
- echo "eo CP850"
- echo "eo_EO CP850"
- ;;
-esac
diff --git a/navit/support/gettext_intl/dcgettext.c b/navit/support/gettext_intl/dcgettext.c
deleted file mode 100644
index 850acdee9..000000000
--- a/navit/support/gettext_intl/dcgettext.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* Implementation of the dcgettext(3) function.
- Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "gettextP.h"
-#ifdef _LIBC
-# include <libintl.h>
-#else
-# include "libgnuintl.h"
-#endif
-
-/* @@ end of prolog @@ */
-
-/* Names for the libintl functions are a problem. They must not clash
- with existing names and they should follow ANSI C. But this source
- code is also used in GNU C Library where the names have a __
- prefix. So we have to make a difference here. */
-#ifdef _LIBC
-# define DCGETTEXT __dcgettext
-# define DCIGETTEXT __dcigettext
-#else
-# define DCGETTEXT libintl_dcgettext
-# define DCIGETTEXT libintl_dcigettext
-#endif
-
-/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
- locale. */
-char *
-DCGETTEXT (const char *domainname, const char *msgid, int category)
-{
- return DCIGETTEXT (domainname, msgid, NULL, 0, 0, category);
-}
-
-#ifdef _LIBC
-/* Alias for function name in GNU C Library. */
-INTDEF(__dcgettext)
-weak_alias (__dcgettext, dcgettext);
-#endif
diff --git a/navit/support/gettext_intl/dcigettext.c b/navit/support/gettext_intl/dcigettext.c
deleted file mode 100644
index 9d4e3542e..000000000
--- a/navit/support/gettext_intl/dcigettext.c
+++ /dev/null
@@ -1,1220 +0,0 @@
-/* Implementation of the internal dcigettext function.
- Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* Tell glibc's <string.h> to provide a prototype for mempcpy().
- This must come before <config.h> because <config.h> may include
- <features.h>, and once <features.h> has been included, it's too late. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <sys/types.h>
-
-#ifdef __GNUC__
-# undef alloca
-# define alloca __builtin_alloca
-# define HAVE_ALLOCA 1
-#else
-# ifdef _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
-# else
-# if defined HAVE_ALLOCA_H || defined _LIBC
-# include <alloca.h>
-# else
-# ifdef _AIX
- #pragma alloca
-# else
-# ifndef alloca
-char *alloca ();
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-#ifndef __set_errno
-# define __set_errno(val) errno = (val)
-#endif
-
-#include <stddef.h>
-#include <string.h>
-
-#if defined HAVE_UNISTD_H || defined _LIBC
-# include <unistd.h>
-#endif
-
-#include <locale.h>
-
-#ifdef _LIBC
- /* Guess whether integer division by zero raises signal SIGFPE.
- Set to 1 only if you know for sure. In case of doubt, set to 0. */
-# if defined __alpha__ || defined __arm__ || defined __i386__ \
- || defined __m68k__ || defined __s390__
-# define INTDIV0_RAISES_SIGFPE 1
-# else
-# define INTDIV0_RAISES_SIGFPE 0
-# endif
-#endif
-#if !INTDIV0_RAISES_SIGFPE
-# include <signal.h>
-#endif
-
-#if defined HAVE_SYS_PARAM_H || defined _LIBC
-# include <sys/param.h>
-#endif
-
-#include "gettextP.h"
-#include "plural-exp.h"
-#ifdef _LIBC
-# include <libintl.h>
-#else
-# include "libgnuintl.h"
-#endif
-#include "hash-string.h"
-
-/* Thread safetyness. */
-#ifdef _LIBC
-# include <bits/libc-lock.h>
-#else
-/* Provide dummy implementation if this is outside glibc. */
-# define __libc_lock_define_initialized(CLASS, NAME)
-# define __libc_lock_lock(NAME)
-# define __libc_lock_unlock(NAME)
-# define __libc_rwlock_define_initialized(CLASS, NAME)
-# define __libc_rwlock_rdlock(NAME)
-# define __libc_rwlock_unlock(NAME)
-#endif
-
-/* Alignment of types. */
-#if defined __GNUC__ && __GNUC__ >= 2
-# define alignof(TYPE) __alignof__ (TYPE)
-#else
-# define alignof(TYPE) \
- ((int) &((struct { char dummy1; TYPE dummy2; } *) 0)->dummy2)
-#endif
-
-/* The internal variables in the standalone libintl.a must have different
- names than the internal variables in GNU libc, otherwise programs
- using libintl.a cannot be linked statically. */
-#if !defined _LIBC
-# define _nl_default_default_domain libintl_nl_default_default_domain
-# define _nl_current_default_domain libintl_nl_current_default_domain
-# define _nl_default_dirname libintl_nl_default_dirname
-# define _nl_domain_bindings libintl_nl_domain_bindings
-#endif
-
-/* Some compilers, like SunOS4 cc, don't have offsetof in <stddef.h>. */
-#ifndef offsetof
-# define offsetof(type,ident) ((size_t)&(((type*)0)->ident))
-#endif
-
-/* @@ end of prolog @@ */
-
-#ifdef _LIBC
-/* Rename the non ANSI C functions. This is required by the standard
- because some ANSI C functions will require linking with this object
- file and the name space must not be polluted. */
-# define getcwd __getcwd
-# ifndef stpcpy
-# define stpcpy __stpcpy
-# endif
-# define tfind __tfind
-#else
-# if !defined HAVE_GETCWD
-char *getwd ();
-# define getcwd(buf, max) getwd (buf)
-# else
-# if VMS
-# define getcwd(buf, max) (getcwd) (buf, max, 0)
-# else
-char *getcwd ();
-# endif
-# endif
-# ifndef HAVE_STPCPY
-static char *stpcpy (char *dest, const char *src);
-# endif
-# ifndef HAVE_MEMPCPY
-static void *mempcpy (void *dest, const void *src, size_t n);
-# endif
-#endif
-
-/* Amount to increase buffer size by in each try. */
-#define PATH_INCR 32
-
-/* The following is from pathmax.h. */
-/* Non-POSIX BSD systems might have gcc's limits.h, which doesn't define
- PATH_MAX but might cause redefinition warnings when sys/param.h is
- later included (as on MORE/BSD 4.3). */
-#if defined _POSIX_VERSION || (defined HAVE_LIMITS_H && !defined __GNUC__)
-# include <limits.h>
-#endif
-
-#ifndef _POSIX_PATH_MAX
-# define _POSIX_PATH_MAX 255
-#endif
-
-#if !defined PATH_MAX && defined _PC_PATH_MAX
-# define PATH_MAX (pathconf ("/", _PC_PATH_MAX) < 1 ? 1024 : pathconf ("/", _PC_PATH_MAX))
-#endif
-
-/* Don't include sys/param.h if it already has been. */
-#if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN
-# include <sys/param.h>
-#endif
-
-#if !defined PATH_MAX && defined MAXPATHLEN
-# define PATH_MAX MAXPATHLEN
-#endif
-
-#ifndef PATH_MAX
-# define PATH_MAX _POSIX_PATH_MAX
-#endif
-
-/* Pathname support.
- ISSLASH(C) tests whether C is a directory separator character.
- IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not,
- it may be concatenated to a directory pathname.
- IS_PATH_WITH_DIR(P) tests whether P contains a directory specification.
- */
-#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
- /* Win32, OS/2, DOS */
-# define ISSLASH(C) ((C) == '/' || (C) == '\\')
-# define HAS_DEVICE(P) \
- ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
- && (P)[1] == ':')
-# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
-# define IS_PATH_WITH_DIR(P) \
- (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
-#else
- /* Unix */
-# define ISSLASH(C) ((C) == '/')
-# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
-# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
-#endif
-
-/* This is the type used for the search tree where known translations
- are stored. */
-struct known_translation_t
-{
- /* Domain in which to search. */
- char *domainname;
-
- /* The category. */
- int category;
-
- /* State of the catalog counter at the point the string was found. */
- int counter;
-
- /* Catalog where the string was found. */
- struct loaded_l10nfile *domain;
-
- /* And finally the translation. */
- const char *translation;
- size_t translation_length;
-
- /* Pointer to the string in question. */
- char msgid[ZERO];
-};
-
-/* Root of the search tree with known translations. We can use this
- only if the system provides the `tsearch' function family. */
-#if defined HAVE_TSEARCH || defined _LIBC
-# include <search.h>
-
-static void *root;
-
-# ifdef _LIBC
-# define tsearch __tsearch
-# endif
-
-/* Function to compare two entries in the table of known translations. */
-static int
-transcmp (const void *p1, const void *p2)
-{
- const struct known_translation_t *s1;
- const struct known_translation_t *s2;
- int result;
-
- s1 = (const struct known_translation_t *) p1;
- s2 = (const struct known_translation_t *) p2;
-
- result = strcmp (s1->msgid, s2->msgid);
- if (result == 0)
- {
- result = strcmp (s1->domainname, s2->domainname);
- if (result == 0)
- /* We compare the category last (though this is the cheapest
- operation) since it is hopefully always the same (namely
- LC_MESSAGES). */
- result = s1->category - s2->category;
- }
-
- return result;
-}
-#endif
-
-#ifndef INTVARDEF
-# define INTVARDEF(name)
-#endif
-#ifndef INTUSE
-# define INTUSE(name) name
-#endif
-
-/* Name of the default domain used for gettext(3) prior any call to
- textdomain(3). The default value for this is "messages". */
-const char _nl_default_default_domain[] attribute_hidden = "messages";
-
-/* Value used as the default domain for gettext(3). */
-const char *_nl_current_default_domain attribute_hidden
- = _nl_default_default_domain;
-
-/* Contains the default location of the message catalogs. */
-#if defined __EMX__
-extern const char _nl_default_dirname[];
-#else
-const char _nl_default_dirname[] = LOCALEDIR;
-INTVARDEF (_nl_default_dirname)
-#endif
-
-/* List with bindings of specific domains created by bindtextdomain()
- calls. */
-struct binding *_nl_domain_bindings;
-
-/* Prototypes for local functions. */
-static char *plural_lookup (struct loaded_l10nfile *domain,
- unsigned long int n,
- const char *translation, size_t translation_len)
- internal_function;
-static const char *guess_category_value (int category,
- const char *categoryname)
- internal_function;
-#ifdef _LIBC
-# include "../locale/localeinfo.h"
-# define category_to_name(category) _nl_category_names[category]
-#else
-static const char *category_to_name (int category) internal_function;
-#endif
-
-
-/* For those loosing systems which don't have `alloca' we have to add
- some additional code emulating it. */
-#ifdef HAVE_ALLOCA
-/* Nothing has to be done. */
-# define freea(p) /* nothing */
-# define ADD_BLOCK(list, address) /* nothing */
-# define FREE_BLOCKS(list) /* nothing */
-#else
-struct block_list
-{
- void *address;
- struct block_list *next;
-};
-# define ADD_BLOCK(list, addr) \
- do { \
- struct block_list *newp = (struct block_list *) malloc (sizeof (*newp)); \
- /* If we cannot get a free block we cannot add the new element to \
- the list. */ \
- if (newp != NULL) { \
- newp->address = (addr); \
- newp->next = (list); \
- (list) = newp; \
- } \
- } while (0)
-# define FREE_BLOCKS(list) \
- do { \
- while (list != NULL) { \
- struct block_list *old = list; \
- list = list->next; \
- free (old->address); \
- free (old); \
- } \
- } while (0)
-# undef alloca
-# define alloca(size) (malloc (size))
-# define freea(p) free (p)
-#endif /* have alloca */
-
-
-#ifdef _LIBC
-/* List of blocks allocated for translations. */
-typedef struct transmem_list
-{
- struct transmem_list *next;
- char data[ZERO];
-} transmem_block_t;
-static struct transmem_list *transmem_list;
-#else
-typedef unsigned char transmem_block_t;
-#endif
-
-
-/* Names for the libintl functions are a problem. They must not clash
- with existing names and they should follow ANSI C. But this source
- code is also used in GNU C Library where the names have a __
- prefix. So we have to make a difference here. */
-#ifdef _LIBC
-# define DCIGETTEXT __dcigettext
-#else
-# define DCIGETTEXT libintl_dcigettext
-#endif
-
-/* Lock variable to protect the global data in the gettext implementation. */
-#ifdef _LIBC
-__libc_rwlock_define_initialized (, _nl_state_lock attribute_hidden)
-#endif
-
-/* Checking whether the binaries runs SUID must be done and glibc provides
- easier methods therefore we make a difference here. */
-#ifdef _LIBC
-# define ENABLE_SECURE __libc_enable_secure
-# define DETERMINE_SECURE
-#else
-# ifndef HAVE_GETUID
-# define getuid() 0
-# endif
-# ifndef HAVE_GETGID
-# define getgid() 0
-# endif
-# ifndef HAVE_GETEUID
-# define geteuid() getuid()
-# endif
-# ifndef HAVE_GETEGID
-# define getegid() getgid()
-# endif
-static int enable_secure;
-# define ENABLE_SECURE (enable_secure == 1)
-# define DETERMINE_SECURE \
- if (enable_secure == 0) \
- { \
- if (getuid () != geteuid () || getgid () != getegid ()) \
- enable_secure = 1; \
- else \
- enable_secure = -1; \
- }
-#endif
-
-/* Get the function to evaluate the plural expression. */
-#include "eval-plural.h"
-
-/* Look up MSGID in the DOMAINNAME message catalog for the current
- CATEGORY locale and, if PLURAL is nonzero, search over string
- depending on the plural form determined by N. */
-char *
-DCIGETTEXT (const char *domainname, const char *msgid1, const char *msgid2,
- int plural, unsigned long int n, int category)
-{
-#ifndef HAVE_ALLOCA
- struct block_list *block_list = NULL;
-#endif
- struct loaded_l10nfile *domain;
- struct binding *binding;
- const char *categoryname;
- const char *categoryvalue;
- char *dirname, *xdomainname;
- char *single_locale;
- char *retval;
- size_t retlen;
- int saved_errno;
-#if defined HAVE_TSEARCH || defined _LIBC
- struct known_translation_t *search;
- struct known_translation_t **foundp = NULL;
- size_t msgid_len;
-#endif
- size_t domainname_len;
-
- /* If no real MSGID is given return NULL. */
- if (msgid1 == NULL)
- return NULL;
-
-#ifdef _LIBC
- if (category < 0 || category >= __LC_LAST || category == LC_ALL)
- /* Bogus. */
- return (plural == 0
- ? (char *) msgid1
- /* Use the Germanic plural rule. */
- : n == 1 ? (char *) msgid1 : (char *) msgid2);
-#endif
-
- __libc_rwlock_rdlock (_nl_state_lock);
-
- /* If DOMAINNAME is NULL, we are interested in the default domain. If
- CATEGORY is not LC_MESSAGES this might not make much sense but the
- definition left this undefined. */
- if (domainname == NULL)
- domainname = _nl_current_default_domain;
-
- /* OS/2 specific: backward compatibility with older libintl versions */
-#ifdef LC_MESSAGES_COMPAT
- if (category == LC_MESSAGES_COMPAT)
- category = LC_MESSAGES;
-#endif
-
-#if defined HAVE_TSEARCH || defined _LIBC
- msgid_len = strlen (msgid1) + 1;
-
- /* Try to find the translation among those which we found at
- some time. */
- search = (struct known_translation_t *)
- alloca (offsetof (struct known_translation_t, msgid) + msgid_len);
- memcpy (search->msgid, msgid1, msgid_len);
- search->domainname = (char *) domainname;
- search->category = category;
-
- foundp = (struct known_translation_t **) tfind (search, &root, transcmp);
- freea (search);
- if (foundp != NULL && (*foundp)->counter == _nl_msg_cat_cntr)
- {
- /* Now deal with plural. */
- if (plural)
- retval = plural_lookup ((*foundp)->domain, n, (*foundp)->translation,
- (*foundp)->translation_length);
- else
- retval = (char *) (*foundp)->translation;
-
- __libc_rwlock_unlock (_nl_state_lock);
- return retval;
- }
-#endif
-
- /* Preserve the `errno' value. */
- saved_errno = errno;
-
- /* See whether this is a SUID binary or not. */
- DETERMINE_SECURE;
-
- /* First find matching binding. */
- for (binding = _nl_domain_bindings; binding != NULL; binding = binding->next)
- {
- int compare = strcmp (domainname, binding->domainname);
- if (compare == 0)
- /* We found it! */
- break;
- if (compare < 0)
- {
- /* It is not in the list. */
- binding = NULL;
- break;
- }
- }
-
- if (binding == NULL)
- dirname = (char *) INTUSE(_nl_default_dirname);
- else if (IS_ABSOLUTE_PATH (binding->dirname))
- dirname = binding->dirname;
- else
- {
- /* We have a relative path. Make it absolute now. */
- size_t dirname_len = strlen (binding->dirname) + 1;
- size_t path_max;
- char *ret;
-
- path_max = (unsigned int) PATH_MAX;
- path_max += 2; /* The getcwd docs say to do this. */
-
- for (;;)
- {
- dirname = (char *) alloca (path_max + dirname_len);
- ADD_BLOCK (block_list, dirname);
-
- __set_errno (0);
- ret = getcwd (dirname, path_max);
- if (ret != NULL || errno != ERANGE)
- break;
-
- path_max += path_max / 2;
- path_max += PATH_INCR;
- }
-
- if (ret == NULL)
- /* We cannot get the current working directory. Don't signal an
- error but simply return the default string. */
- goto return_untranslated;
-
- stpcpy (stpcpy (strchr (dirname, '\0'), "/"), binding->dirname);
- }
-
- /* Now determine the symbolic name of CATEGORY and its value. */
- categoryname = category_to_name (category);
- categoryvalue = guess_category_value (category, categoryname);
-
- domainname_len = strlen (domainname);
- xdomainname = (char *) alloca (strlen (categoryname)
- + domainname_len + 5);
- ADD_BLOCK (block_list, xdomainname);
-
- stpcpy (mempcpy (stpcpy (stpcpy (xdomainname, categoryname), "/"),
- domainname, domainname_len),
- ".mo");
-
- /* Creating working area. */
- single_locale = (char *) alloca (strlen (categoryvalue) + 1);
- ADD_BLOCK (block_list, single_locale);
-
-
- /* Search for the given string. This is a loop because we perhaps
- got an ordered list of languages to consider for the translation. */
- while (1)
- {
- /* Make CATEGORYVALUE point to the next element of the list. */
- while (categoryvalue[0] != '\0' && categoryvalue[0] == ':')
- ++categoryvalue;
- if (categoryvalue[0] == '\0')
- {
- /* The whole contents of CATEGORYVALUE has been searched but
- no valid entry has been found. We solve this situation
- by implicitly appending a "C" entry, i.e. no translation
- will take place. */
- single_locale[0] = 'C';
- single_locale[1] = '\0';
- }
- else
- {
- char *cp = single_locale;
- while (categoryvalue[0] != '\0' && categoryvalue[0] != ':')
- *cp++ = *categoryvalue++;
- *cp = '\0';
-
- /* When this is a SUID binary we must not allow accessing files
- outside the dedicated directories. */
- if (ENABLE_SECURE && IS_PATH_WITH_DIR (single_locale))
- /* Ingore this entry. */
- continue;
- }
-
- /* If the current locale value is C (or POSIX) we don't load a
- domain. Return the MSGID. */
- if (strcmp (single_locale, "C") == 0
- || strcmp (single_locale, "POSIX") == 0)
- break;
-
- /* Find structure describing the message catalog matching the
- DOMAINNAME and CATEGORY. */
- domain = _nl_find_domain (dirname, single_locale, xdomainname, binding);
-
- if (domain != NULL)
- {
- retval = _nl_find_msg (domain, binding, msgid1, &retlen);
-
- if (retval == NULL)
- {
- int cnt;
-
- for (cnt = 0; domain->successor[cnt] != NULL; ++cnt)
- {
- retval = _nl_find_msg (domain->successor[cnt], binding,
- msgid1, &retlen);
-
- if (retval != NULL)
- {
- domain = domain->successor[cnt];
- break;
- }
- }
- }
-
- if (retval != NULL)
- {
- /* Found the translation of MSGID1 in domain DOMAIN:
- starting at RETVAL, RETLEN bytes. */
- FREE_BLOCKS (block_list);
-#if defined HAVE_TSEARCH || defined _LIBC
- if (foundp == NULL)
- {
- /* Create a new entry and add it to the search tree. */
- struct known_translation_t *newp;
-
- newp = (struct known_translation_t *)
- malloc (offsetof (struct known_translation_t, msgid)
- + msgid_len + domainname_len + 1);
- if (newp != NULL)
- {
- newp->domainname =
- mempcpy (newp->msgid, msgid1, msgid_len);
- memcpy (newp->domainname, domainname, domainname_len + 1);
- newp->category = category;
- newp->counter = _nl_msg_cat_cntr;
- newp->domain = domain;
- newp->translation = retval;
- newp->translation_length = retlen;
-
- /* Insert the entry in the search tree. */
- foundp = (struct known_translation_t **)
- tsearch (newp, &root, transcmp);
- if (foundp == NULL
- || __builtin_expect (*foundp != newp, 0))
- /* The insert failed. */
- free (newp);
- }
- }
- else
- {
- /* We can update the existing entry. */
- (*foundp)->counter = _nl_msg_cat_cntr;
- (*foundp)->domain = domain;
- (*foundp)->translation = retval;
- (*foundp)->translation_length = retlen;
- }
-#endif
- __set_errno (saved_errno);
-
- /* Now deal with plural. */
- if (plural)
- retval = plural_lookup (domain, n, retval, retlen);
-
- __libc_rwlock_unlock (_nl_state_lock);
- return retval;
- }
- }
- }
-
- return_untranslated:
- /* Return the untranslated MSGID. */
- FREE_BLOCKS (block_list);
- __libc_rwlock_unlock (_nl_state_lock);
-#ifndef _LIBC
- if (!ENABLE_SECURE)
- {
- extern void _nl_log_untranslated (const char *logfilename,
- const char *domainname,
- const char *msgid1, const char *msgid2,
- int plural);
- const char *logfilename = getenv ("GETTEXT_LOG_UNTRANSLATED");
-
- if (logfilename != NULL && logfilename[0] != '\0')
- _nl_log_untranslated (logfilename, domainname, msgid1, msgid2, plural);
- }
-#endif
- __set_errno (saved_errno);
- return (plural == 0
- ? (char *) msgid1
- /* Use the Germanic plural rule. */
- : n == 1 ? (char *) msgid1 : (char *) msgid2);
-}
-
-
-char *
-internal_function
-_nl_find_msg (struct loaded_l10nfile *domain_file,
- struct binding *domainbinding, const char *msgid,
- size_t *lengthp)
-{
- struct loaded_domain *domain;
- nls_uint32 nstrings;
- size_t act;
- char *result;
- size_t resultlen;
-
- if (domain_file->decided == 0)
- _nl_load_domain (domain_file, domainbinding);
-
- if (domain_file->data == NULL)
- return NULL;
-
- domain = (struct loaded_domain *) domain_file->data;
-
- nstrings = domain->nstrings;
-
- /* Locate the MSGID and its translation. */
- if (domain->hash_tab != NULL)
- {
- /* Use the hashing table. */
- nls_uint32 len = strlen (msgid);
- nls_uint32 hash_val = hash_string (msgid);
- nls_uint32 idx = hash_val % domain->hash_size;
- nls_uint32 incr = 1 + (hash_val % (domain->hash_size - 2));
-
- while (1)
- {
- nls_uint32 nstr =
- W (domain->must_swap_hash_tab, domain->hash_tab[idx]);
-
- if (nstr == 0)
- /* Hash table entry is empty. */
- return NULL;
-
- nstr--;
-
- /* Compare msgid with the original string at index nstr.
- We compare the lengths with >=, not ==, because plural entries
- are represented by strings with an embedded NUL. */
- if (nstr < nstrings
- ? W (domain->must_swap, domain->orig_tab[nstr].length) >= len
- && (strcmp (msgid,
- domain->data + W (domain->must_swap,
- domain->orig_tab[nstr].offset))
- == 0)
- : domain->orig_sysdep_tab[nstr - nstrings].length > len
- && (strcmp (msgid,
- domain->orig_sysdep_tab[nstr - nstrings].pointer)
- == 0))
- {
- act = nstr;
- goto found;
- }
-
- if (idx >= domain->hash_size - incr)
- idx -= domain->hash_size - incr;
- else
- idx += incr;
- }
- /* NOTREACHED */
- }
- else
- {
- /* Try the default method: binary search in the sorted array of
- messages. */
- size_t top, bottom;
-
- bottom = 0;
- top = nstrings;
- while (bottom < top)
- {
- int cmp_val;
-
- act = (bottom + top) / 2;
- cmp_val = strcmp (msgid, (domain->data
- + W (domain->must_swap,
- domain->orig_tab[act].offset)));
- if (cmp_val < 0)
- top = act;
- else if (cmp_val > 0)
- bottom = act + 1;
- else
- goto found;
- }
- /* No translation was found. */
- return NULL;
- }
-
- found:
- /* The translation was found at index ACT. If we have to convert the
- string to use a different character set, this is the time. */
- if (act < nstrings)
- {
- result = (char *)
- (domain->data + W (domain->must_swap, domain->trans_tab[act].offset));
- resultlen = W (domain->must_swap, domain->trans_tab[act].length) + 1;
- }
- else
- {
- result = (char *) domain->trans_sysdep_tab[act - nstrings].pointer;
- resultlen = domain->trans_sysdep_tab[act - nstrings].length;
- }
-
-#if defined _LIBC || HAVE_ICONV
- if (domain->codeset_cntr
- != (domainbinding != NULL ? domainbinding->codeset_cntr : 0))
- {
- /* The domain's codeset has changed through bind_textdomain_codeset()
- since the message catalog was initialized or last accessed. We
- have to reinitialize the converter. */
- _nl_free_domain_conv (domain);
- _nl_init_domain_conv (domain_file, domain, domainbinding);
- }
-
- if (
-# ifdef _LIBC
- domain->conv != (__gconv_t) -1
-# else
-# if HAVE_ICONV
- domain->conv != (iconv_t) -1
-# endif
-# endif
- )
- {
- /* We are supposed to do a conversion. First allocate an
- appropriate table with the same structure as the table
- of translations in the file, where we can put the pointers
- to the converted strings in.
- There is a slight complication with plural entries. They
- are represented by consecutive NUL terminated strings. We
- handle this case by converting RESULTLEN bytes, including
- NULs. */
-
- if (domain->conv_tab == NULL
- && ((domain->conv_tab =
- (char **) calloc (nstrings + domain->n_sysdep_strings,
- sizeof (char *)))
- == NULL))
- /* Mark that we didn't succeed allocating a table. */
- domain->conv_tab = (char **) -1;
-
- if (__builtin_expect (domain->conv_tab == (char **) -1, 0))
- /* Nothing we can do, no more memory. */
- goto converted;
-
- if (domain->conv_tab[act] == NULL)
- {
- /* We haven't used this string so far, so it is not
- translated yet. Do this now. */
- /* We use a bit more efficient memory handling.
- We allocate always larger blocks which get used over
- time. This is faster than many small allocations. */
- __libc_lock_define_initialized (static, lock)
-# define INITIAL_BLOCK_SIZE 4080
- static unsigned char *freemem;
- static size_t freemem_size;
-
- const unsigned char *inbuf;
- unsigned char *outbuf;
- int malloc_count;
-# ifndef _LIBC
- transmem_block_t *transmem_list = NULL;
-# endif
-
- __libc_lock_lock (lock);
-
- inbuf = (const unsigned char *) result;
- outbuf = freemem + sizeof (size_t);
-
- malloc_count = 0;
- while (1)
- {
- transmem_block_t *newmem;
-# ifdef _LIBC
- size_t non_reversible;
- int res;
-
- if (freemem_size < sizeof (size_t))
- goto resize_freemem;
-
- res = __gconv (domain->conv,
- &inbuf, inbuf + resultlen,
- &outbuf,
- outbuf + freemem_size - sizeof (size_t),
- &non_reversible);
-
- if (res == __GCONV_OK || res == __GCONV_EMPTY_INPUT)
- break;
-
- if (res != __GCONV_FULL_OUTPUT)
- {
- __libc_lock_unlock (lock);
- goto converted;
- }
-
- inbuf = result;
-# else
-# if HAVE_ICONV
- const char *inptr = (const char *) inbuf;
- size_t inleft = resultlen;
- char *outptr = (char *) outbuf;
- size_t outleft;
-
- if (freemem_size < sizeof (size_t))
- goto resize_freemem;
-
- outleft = freemem_size - sizeof (size_t);
- if (iconv (domain->conv,
- (ICONV_CONST char **) &inptr, &inleft,
- &outptr, &outleft)
- != (size_t) (-1))
- {
- outbuf = (unsigned char *) outptr;
- break;
- }
- if (errno != E2BIG)
- {
- __libc_lock_unlock (lock);
- goto converted;
- }
-# endif
-# endif
-
- resize_freemem:
- /* We must allocate a new buffer or resize the old one. */
- if (malloc_count > 0)
- {
- ++malloc_count;
- freemem_size = malloc_count * INITIAL_BLOCK_SIZE;
- newmem = (transmem_block_t *) realloc (transmem_list,
- freemem_size);
-# ifdef _LIBC
- if (newmem != NULL)
- transmem_list = transmem_list->next;
- else
- {
- struct transmem_list *old = transmem_list;
-
- transmem_list = transmem_list->next;
- free (old);
- }
-# endif
- }
- else
- {
- malloc_count = 1;
- freemem_size = INITIAL_BLOCK_SIZE;
- newmem = (transmem_block_t *) malloc (freemem_size);
- }
- if (__builtin_expect (newmem == NULL, 0))
- {
- freemem = NULL;
- freemem_size = 0;
- __libc_lock_unlock (lock);
- goto converted;
- }
-
-# ifdef _LIBC
- /* Add the block to the list of blocks we have to free
- at some point. */
- newmem->next = transmem_list;
- transmem_list = newmem;
-
- freemem = newmem->data;
- freemem_size -= offsetof (struct transmem_list, data);
-# else
- transmem_list = newmem;
- freemem = newmem;
-# endif
-
- outbuf = freemem + sizeof (size_t);
- }
-
- /* We have now in our buffer a converted string. Put this
- into the table of conversions. */
- *(size_t *) freemem = outbuf - freemem - sizeof (size_t);
- domain->conv_tab[act] = (char *) freemem;
- /* Shrink freemem, but keep it aligned. */
- freemem_size -= outbuf - freemem;
- freemem = outbuf;
- freemem += freemem_size & (alignof (size_t) - 1);
- freemem_size = freemem_size & ~ (alignof (size_t) - 1);
-
- __libc_lock_unlock (lock);
- }
-
- /* Now domain->conv_tab[act] contains the translation of all
- the plural variants. */
- result = domain->conv_tab[act] + sizeof (size_t);
- resultlen = *(size_t *) domain->conv_tab[act];
- }
-
- converted:
- /* The result string is converted. */
-
-#endif /* _LIBC || HAVE_ICONV */
-
- *lengthp = resultlen;
- return result;
-}
-
-
-/* Look up a plural variant. */
-static char *
-internal_function
-plural_lookup (struct loaded_l10nfile *domain, unsigned long int n,
- const char *translation, size_t translation_len)
-{
- struct loaded_domain *domaindata = (struct loaded_domain *) domain->data;
- unsigned long int index;
- const char *p;
-
- index = plural_eval (domaindata->plural, n);
- if (index >= domaindata->nplurals)
- /* This should never happen. It means the plural expression and the
- given maximum value do not match. */
- index = 0;
-
- /* Skip INDEX strings at TRANSLATION. */
- p = translation;
- while (index-- > 0)
- {
-#ifdef _LIBC
- p = __rawmemchr (p, '\0');
-#else
- p = strchr (p, '\0');
-#endif
- /* And skip over the NUL byte. */
- p++;
-
- if (p >= translation + translation_len)
- /* This should never happen. It means the plural expression
- evaluated to a value larger than the number of variants
- available for MSGID1. */
- return (char *) translation;
- }
- return (char *) p;
-}
-
-#ifndef _LIBC
-/* Return string representation of locale CATEGORY. */
-static const char *
-internal_function
-category_to_name (int category)
-{
- const char *retval;
-
- switch (category)
- {
-#ifdef LC_COLLATE
- case LC_COLLATE:
- retval = "LC_COLLATE";
- break;
-#endif
-#ifdef LC_CTYPE
- case LC_CTYPE:
- retval = "LC_CTYPE";
- break;
-#endif
-#ifdef LC_MONETARY
- case LC_MONETARY:
- retval = "LC_MONETARY";
- break;
-#endif
-#ifdef LC_NUMERIC
- case LC_NUMERIC:
- retval = "LC_NUMERIC";
- break;
-#endif
-#ifdef LC_TIME
- case LC_TIME:
- retval = "LC_TIME";
- break;
-#endif
-#ifdef LC_MESSAGES
- case LC_MESSAGES:
- retval = "LC_MESSAGES";
- break;
-#endif
-#ifdef LC_RESPONSE
- case LC_RESPONSE:
- retval = "LC_RESPONSE";
- break;
-#endif
-#ifdef LC_ALL
- case LC_ALL:
- /* This might not make sense but is perhaps better than any other
- value. */
- retval = "LC_ALL";
- break;
-#endif
- default:
- /* If you have a better idea for a default value let me know. */
- retval = "LC_XXX";
- }
-
- return retval;
-}
-#endif
-
-/* Guess value of current locale from value of the environment variables. */
-static const char *
-internal_function
-guess_category_value (int category, const char *categoryname)
-{
- const char *language;
- const char *retval;
-
- /* The highest priority value is the `LANGUAGE' environment
- variable. But we don't use the value if the currently selected
- locale is the C locale. This is a GNU extension. */
- language = getenv ("LANGUAGE");
- if (language != NULL && language[0] == '\0')
- language = NULL;
-
- /* We have to proceed with the POSIX methods of looking to `LC_ALL',
- `LC_xxx', and `LANG'. On some systems this can be done by the
- `setlocale' function itself. */
-#ifdef _LIBC
- retval = __current_locale_name (category);
-#else
- retval = _nl_locale_name (category, categoryname);
-#endif
-
- /* Ignore LANGUAGE if the locale is set to "C" because
- 1. "C" locale usually uses the ASCII encoding, and most international
- messages use non-ASCII characters. These characters get displayed
- as question marks (if using glibc's iconv()) or as invalid 8-bit
- characters (because other iconv()s refuse to convert most non-ASCII
- characters to ASCII). In any case, the output is ugly.
- 2. The precise output of some programs in the "C" locale is specified
- by POSIX and should not depend on environment variables like
- "LANGUAGE". We allow such programs to use gettext(). */
- return language != NULL && strcmp (retval, "C") != 0 ? language : retval;
-}
-
-/* @@ begin of epilog @@ */
-
-/* We don't want libintl.a to depend on any other library. So we
- avoid the non-standard function stpcpy. In GNU C Library this
- function is available, though. Also allow the symbol HAVE_STPCPY
- to be defined. */
-#if !_LIBC && !HAVE_STPCPY
-static char *
-stpcpy (char *dest, const char *src)
-{
- while ((*dest++ = *src++) != '\0')
- /* Do nothing. */ ;
- return dest - 1;
-}
-#endif
-
-#if !_LIBC && !HAVE_MEMPCPY
-static void *
-mempcpy (void *dest, const void *src, size_t n)
-{
- return (void *) ((char *) memcpy (dest, src, n) + n);
-}
-#endif
-
-
-#ifdef _LIBC
-/* If we want to free all resources we have to do some work at
- program's end. */
-libc_freeres_fn (free_mem)
-{
- void *old;
-
- while (_nl_domain_bindings != NULL)
- {
- struct binding *oldp = _nl_domain_bindings;
- _nl_domain_bindings = _nl_domain_bindings->next;
- if (oldp->dirname != INTUSE(_nl_default_dirname))
- /* Yes, this is a pointer comparison. */
- free (oldp->dirname);
- free (oldp->codeset);
- free (oldp);
- }
-
- if (_nl_current_default_domain != _nl_default_default_domain)
- /* Yes, again a pointer comparison. */
- free ((char *) _nl_current_default_domain);
-
- /* Remove the search tree with the known translations. */
- __tdestroy (root, free);
- root = NULL;
-
- while (transmem_list != NULL)
- {
- old = transmem_list;
- transmem_list = transmem_list->next;
- free (old);
- }
-}
-#endif
diff --git a/navit/support/gettext_intl/dcngettext.c b/navit/support/gettext_intl/dcngettext.c
deleted file mode 100644
index 48a3e09e0..000000000
--- a/navit/support/gettext_intl/dcngettext.c
+++ /dev/null
@@ -1,57 +0,0 @@
-/* Implementation of the dcngettext(3) function.
- Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "gettextP.h"
-#ifdef _LIBC
-# include <libintl.h>
-#else
-# include "libgnuintl.h"
-#endif
-
-/* @@ end of prolog @@ */
-
-/* Names for the libintl functions are a problem. They must not clash
- with existing names and they should follow ANSI C. But this source
- code is also used in GNU C Library where the names have a __
- prefix. So we have to make a difference here. */
-#ifdef _LIBC
-# define DCNGETTEXT __dcngettext
-# define DCIGETTEXT __dcigettext
-#else
-# define DCNGETTEXT libintl_dcngettext
-# define DCIGETTEXT libintl_dcigettext
-#endif
-
-/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
- locale. */
-char *
-DCNGETTEXT (const char *domainname,
- const char *msgid1, const char *msgid2, unsigned long int n,
- int category)
-{
- return DCIGETTEXT (domainname, msgid1, msgid2, 1, n, category);
-}
-
-#ifdef _LIBC
-/* Alias for function name in GNU C Library. */
-weak_alias (__dcngettext, dcngettext);
-#endif
diff --git a/navit/support/gettext_intl/dgettext.c b/navit/support/gettext_intl/dgettext.c
deleted file mode 100644
index b64b0f5d3..000000000
--- a/navit/support/gettext_intl/dgettext.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* Implementation of the dgettext(3) function.
- Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "gettextP.h"
-
-#include <locale.h>
-
-#ifdef _LIBC
-# include <libintl.h>
-#else
-# include "libgnuintl.h"
-#endif
-
-/* @@ end of prolog @@ */
-
-/* Names for the libintl functions are a problem. They must not clash
- with existing names and they should follow ANSI C. But this source
- code is also used in GNU C Library where the names have a __
- prefix. So we have to make a difference here. */
-#ifdef _LIBC
-# define DGETTEXT __dgettext
-# define DCGETTEXT INTUSE(__dcgettext)
-#else
-# define DGETTEXT libintl_dgettext
-# define DCGETTEXT libintl_dcgettext
-#endif
-
-/* Look up MSGID in the DOMAINNAME message catalog of the current
- LC_MESSAGES locale. */
-char *
-DGETTEXT (const char *domainname, const char *msgid)
-{
- return DCGETTEXT (domainname, msgid, LC_MESSAGES);
-}
-
-#ifdef _LIBC
-/* Alias for function name in GNU C Library. */
-weak_alias (__dgettext, dgettext);
-#endif
diff --git a/navit/support/gettext_intl/dngettext.c b/navit/support/gettext_intl/dngettext.c
deleted file mode 100644
index 7815637f0..000000000
--- a/navit/support/gettext_intl/dngettext.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Implementation of the dngettext(3) function.
- Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "gettextP.h"
-
-#include <locale.h>
-
-#ifdef _LIBC
-# include <libintl.h>
-#else
-# include "libgnuintl.h"
-#endif
-
-/* @@ end of prolog @@ */
-
-/* Names for the libintl functions are a problem. They must not clash
- with existing names and they should follow ANSI C. But this source
- code is also used in GNU C Library where the names have a __
- prefix. So we have to make a difference here. */
-#ifdef _LIBC
-# define DNGETTEXT __dngettext
-# define DCNGETTEXT __dcngettext
-#else
-# define DNGETTEXT libintl_dngettext
-# define DCNGETTEXT libintl_dcngettext
-#endif
-
-/* Look up MSGID in the DOMAINNAME message catalog of the current
- LC_MESSAGES locale and skip message according to the plural form. */
-char *
-DNGETTEXT (const char *domainname,
- const char *msgid1, const char *msgid2, unsigned long int n)
-{
- return DCNGETTEXT (domainname, msgid1, msgid2, n, LC_MESSAGES);
-}
-
-#ifdef _LIBC
-/* Alias for function name in GNU C Library. */
-weak_alias (__dngettext, dngettext);
-#endif
diff --git a/navit/support/gettext_intl/eval-plural.h b/navit/support/gettext_intl/eval-plural.h
deleted file mode 100644
index 01bd5af5f..000000000
--- a/navit/support/gettext_intl/eval-plural.h
+++ /dev/null
@@ -1,108 +0,0 @@
-/* Plural expression evaluation.
- Copyright (C) 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef STATIC
-#define STATIC static
-#endif
-
-/* Evaluate the plural expression and return an index value. */
-STATIC
-unsigned long int
-internal_function
-plural_eval (struct expression *pexp, unsigned long int n)
-{
- switch (pexp->nargs)
- {
- case 0:
- switch (pexp->operation)
- {
- case var:
- return n;
- case num:
- return pexp->val.num;
- default:
- break;
- }
- /* NOTREACHED */
- break;
- case 1:
- {
- /* pexp->operation must be lnot. */
- unsigned long int arg = plural_eval (pexp->val.args[0], n);
- return ! arg;
- }
- case 2:
- {
- unsigned long int leftarg = plural_eval (pexp->val.args[0], n);
- if (pexp->operation == lor)
- return leftarg || plural_eval (pexp->val.args[1], n);
- else if (pexp->operation == land)
- return leftarg && plural_eval (pexp->val.args[1], n);
- else
- {
- unsigned long int rightarg = plural_eval (pexp->val.args[1], n);
-
- switch (pexp->operation)
- {
- case mult:
- return leftarg * rightarg;
- case divide:
-#if !INTDIV0_RAISES_SIGFPE
- if (rightarg == 0)
- raise (SIGFPE);
-#endif
- return leftarg / rightarg;
- case module:
-#if !INTDIV0_RAISES_SIGFPE
- if (rightarg == 0)
- raise (SIGFPE);
-#endif
- return leftarg % rightarg;
- case plus:
- return leftarg + rightarg;
- case minus:
- return leftarg - rightarg;
- case less_than:
- return leftarg < rightarg;
- case greater_than:
- return leftarg > rightarg;
- case less_or_equal:
- return leftarg <= rightarg;
- case greater_or_equal:
- return leftarg >= rightarg;
- case equal:
- return leftarg == rightarg;
- case not_equal:
- return leftarg != rightarg;
- default:
- break;
- }
- }
- /* NOTREACHED */
- break;
- }
- case 3:
- {
- /* pexp->operation must be qmop. */
- unsigned long int boolarg = plural_eval (pexp->val.args[0], n);
- return plural_eval (pexp->val.args[boolarg ? 1 : 2], n);
- }
- }
- /* NOTREACHED */
- return 0;
-}
diff --git a/navit/support/gettext_intl/explodename.c b/navit/support/gettext_intl/explodename.c
deleted file mode 100644
index 52c25e727..000000000
--- a/navit/support/gettext_intl/explodename.c
+++ /dev/null
@@ -1,185 +0,0 @@
-/* Copyright (C) 1995-1998, 2000-2001, 2003 Free Software Foundation, Inc.
- Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-
-#include "loadinfo.h"
-
-/* On some strange systems still no definition of NULL is found. Sigh! */
-#ifndef NULL
-# if defined __STDC__ && __STDC__
-# define NULL ((void *) 0)
-# else
-# define NULL 0
-# endif
-#endif
-
-/* @@ end of prolog @@ */
-
-char *
-_nl_find_language (const char *name)
-{
- while (name[0] != '\0' && name[0] != '_' && name[0] != '@'
- && name[0] != '+' && name[0] != ',')
- ++name;
-
- return (char *) name;
-}
-
-
-int
-_nl_explode_name (char *name,
- const char **language, const char **modifier,
- const char **territory, const char **codeset,
- const char **normalized_codeset, const char **special,
- const char **sponsor, const char **revision)
-{
- enum { undecided, xpg, cen } syntax;
- char *cp;
- int mask;
-
- *modifier = NULL;
- *territory = NULL;
- *codeset = NULL;
- *normalized_codeset = NULL;
- *special = NULL;
- *sponsor = NULL;
- *revision = NULL;
-
- /* Now we determine the single parts of the locale name. First
- look for the language. Termination symbols are `_' and `@' if
- we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
- mask = 0;
- syntax = undecided;
- *language = cp = name;
- cp = _nl_find_language (*language);
-
- if (*language == cp)
- /* This does not make sense: language has to be specified. Use
- this entry as it is without exploding. Perhaps it is an alias. */
- cp = strchr (*language, '\0');
- else if (cp[0] == '_')
- {
- /* Next is the territory. */
- cp[0] = '\0';
- *territory = ++cp;
-
- while (cp[0] != '\0' && cp[0] != '.' && cp[0] != '@'
- && cp[0] != '+' && cp[0] != ',' && cp[0] != '_')
- ++cp;
-
- mask |= TERRITORY;
-
- if (cp[0] == '.')
- {
- /* Next is the codeset. */
- syntax = xpg;
- cp[0] = '\0';
- *codeset = ++cp;
-
- while (cp[0] != '\0' && cp[0] != '@')
- ++cp;
-
- mask |= XPG_CODESET;
-
- if (*codeset != cp && (*codeset)[0] != '\0')
- {
- *normalized_codeset = _nl_normalize_codeset (*codeset,
- cp - *codeset);
- if (strcmp (*codeset, *normalized_codeset) == 0)
- free ((char *) *normalized_codeset);
- else
- mask |= XPG_NORM_CODESET;
- }
- }
- }
-
- if (cp[0] == '@' || (syntax != xpg && cp[0] == '+'))
- {
- /* Next is the modifier. */
- syntax = cp[0] == '@' ? xpg : cen;
- cp[0] = '\0';
- *modifier = ++cp;
-
- while (syntax == cen && cp[0] != '\0' && cp[0] != '+'
- && cp[0] != ',' && cp[0] != '_')
- ++cp;
-
- mask |= XPG_MODIFIER | CEN_AUDIENCE;
- }
-
- if (syntax != xpg && (cp[0] == '+' || cp[0] == ',' || cp[0] == '_'))
- {
- syntax = cen;
-
- if (cp[0] == '+')
- {
- /* Next is special application (CEN syntax). */
- cp[0] = '\0';
- *special = ++cp;
-
- while (cp[0] != '\0' && cp[0] != ',' && cp[0] != '_')
- ++cp;
-
- mask |= CEN_SPECIAL;
- }
-
- if (cp[0] == ',')
- {
- /* Next is sponsor (CEN syntax). */
- cp[0] = '\0';
- *sponsor = ++cp;
-
- while (cp[0] != '\0' && cp[0] != '_')
- ++cp;
-
- mask |= CEN_SPONSOR;
- }
-
- if (cp[0] == '_')
- {
- /* Next is revision (CEN syntax). */
- cp[0] = '\0';
- *revision = ++cp;
-
- mask |= CEN_REVISION;
- }
- }
-
- /* For CEN syntax values it might be important to have the
- separator character in the file name, not for XPG syntax. */
- if (syntax == xpg)
- {
- if (*territory != NULL && (*territory)[0] == '\0')
- mask &= ~TERRITORY;
-
- if (*codeset != NULL && (*codeset)[0] == '\0')
- mask &= ~XPG_CODESET;
-
- if (*modifier != NULL && (*modifier)[0] == '\0')
- mask &= ~XPG_MODIFIER;
- }
-
- return mask;
-}
diff --git a/navit/support/gettext_intl/finddomain.c b/navit/support/gettext_intl/finddomain.c
deleted file mode 100644
index 4992a8c9e..000000000
--- a/navit/support/gettext_intl/finddomain.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/* Handle list of needed message catalogs
- Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc.
- Written by Ulrich Drepper <drepper@gnu.org>, 1995.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <stdlib.h>
-#include <string.h>
-
-#if defined HAVE_UNISTD_H || defined _LIBC
-# include <unistd.h>
-#endif
-
-#include "gettextP.h"
-#ifdef _LIBC
-# include <libintl.h>
-#else
-# include "libgnuintl.h"
-#endif
-
-/* @@ end of prolog @@ */
-/* List of already loaded domains. */
-static struct loaded_l10nfile *_nl_loaded_domains;
-
-
-/* Return a data structure describing the message catalog described by
- the DOMAINNAME and CATEGORY parameters with respect to the currently
- established bindings. */
-struct loaded_l10nfile *
-internal_function
-_nl_find_domain (const char *dirname, char *locale,
- const char *domainname, struct binding *domainbinding)
-{
- struct loaded_l10nfile *retval;
- const char *language;
- const char *modifier;
- const char *territory;
- const char *codeset;
- const char *normalized_codeset;
- const char *special;
- const char *sponsor;
- const char *revision;
- const char *alias_value;
- int mask;
-
- /* LOCALE can consist of up to four recognized parts for the XPG syntax:
-
- language[_territory[.codeset]][@modifier]
-
- and six parts for the CEN syntax:
-
- language[_territory][+audience][+special][,[sponsor][_revision]]
-
- Beside the first part all of them are allowed to be missing. If
- the full specified locale is not found, the less specific one are
- looked for. The various parts will be stripped off according to
- the following order:
- (1) revision
- (2) sponsor
- (3) special
- (4) codeset
- (5) normalized codeset
- (6) territory
- (7) audience/modifier
- */
-
- /* If we have already tested for this locale entry there has to
- be one data set in the list of loaded domains. */
- retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
- strlen (dirname) + 1, 0, locale, NULL, NULL,
- NULL, NULL, NULL, NULL, NULL, domainname, 0);
- if (retval != NULL)
- {
- /* We know something about this locale. */
- int cnt;
-
- if (retval->decided == 0)
- _nl_load_domain (retval, domainbinding);
-
- if (retval->data != NULL)
- return retval;
-
- for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
- {
- if (retval->successor[cnt]->decided == 0)
- _nl_load_domain (retval->successor[cnt], domainbinding);
-
- if (retval->successor[cnt]->data != NULL)
- break;
- }
- return cnt >= 0 ? retval : NULL;
- /* NOTREACHED */
- }
-
- /* See whether the locale value is an alias. If yes its value
- *overwrites* the alias name. No test for the original value is
- done. */
- alias_value = _nl_expand_alias (locale);
- if (alias_value != NULL)
- {
-#if defined _LIBC || defined HAVE_STRDUP
- locale = strdup (alias_value);
- if (locale == NULL)
- return NULL;
-#else
- size_t len = strlen (alias_value) + 1;
- locale = (char *) malloc (len);
- if (locale == NULL)
- return NULL;
-
- memcpy (locale, alias_value, len);
-#endif
- }
-
- /* Now we determine the single parts of the locale name. First
- look for the language. Termination symbols are `_' and `@' if
- we use XPG4 style, and `_', `+', and `,' if we use CEN syntax. */
- mask = _nl_explode_name (locale, &language, &modifier, &territory,
- &codeset, &normalized_codeset, &special,
- &sponsor, &revision);
-
- /* Create all possible locale entries which might be interested in
- generalization. */
- retval = _nl_make_l10nflist (&_nl_loaded_domains, dirname,
- strlen (dirname) + 1, mask, language, territory,
- codeset, normalized_codeset, modifier, special,
- sponsor, revision, domainname, 1);
- if (retval == NULL)
- /* This means we are out of core. */
- return NULL;
-
- if (retval->decided == 0)
- _nl_load_domain (retval, domainbinding);
- if (retval->data == NULL)
- {
- int cnt;
- for (cnt = 0; retval->successor[cnt] != NULL; ++cnt)
- {
- if (retval->successor[cnt]->decided == 0)
- _nl_load_domain (retval->successor[cnt], domainbinding);
- if (retval->successor[cnt]->data != NULL)
- break;
- }
- }
-
- /* The room for an alias was dynamically allocated. Free it now. */
- if (alias_value != NULL)
- free (locale);
-
- /* The space for normalized_codeset is dynamically allocated. Free it. */
- if (mask & XPG_NORM_CODESET)
- free ((void *) normalized_codeset);
-
- return retval;
-}
-
-
-#ifdef _LIBC
-libc_freeres_fn (free_mem)
-{
- struct loaded_l10nfile *runp = _nl_loaded_domains;
-
- while (runp != NULL)
- {
- struct loaded_l10nfile *here = runp;
- if (runp->data != NULL)
- _nl_unload_domain ((struct loaded_domain *) runp->data);
- runp = runp->next;
- free ((char *) here->filename);
- free (here);
- }
-}
-#endif
diff --git a/navit/support/gettext_intl/gettext.c b/navit/support/gettext_intl/gettext.c
deleted file mode 100644
index 92c42faa7..000000000
--- a/navit/support/gettext_intl/gettext.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/* Implementation of gettext(3) function.
- Copyright (C) 1995, 1997, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef _LIBC
-# define __need_NULL
-# include <stddef.h>
-#else
-# include <stdlib.h> /* Just for NULL. */
-#endif
-
-#include "gettextP.h"
-#ifdef _LIBC
-# include <libintl.h>
-#else
-# include "libgnuintl.h"
-#endif
-
-/* @@ end of prolog @@ */
-
-/* Names for the libintl functions are a problem. They must not clash
- with existing names and they should follow ANSI C. But this source
- code is also used in GNU C Library where the names have a __
- prefix. So we have to make a difference here. */
-#ifdef _LIBC
-# define GETTEXT __gettext
-# define DCGETTEXT INTUSE(__dcgettext)
-#else
-# define GETTEXT libintl_gettext
-# define DCGETTEXT libintl_dcgettext
-#endif
-
-/* Look up MSGID in the current default message catalog for the current
- LC_MESSAGES locale. If not found, returns MSGID itself (the default
- text). */
-char *
-GETTEXT (const char *msgid)
-{
- return DCGETTEXT (NULL, msgid, LC_MESSAGES);
-}
-
-#ifdef _LIBC
-/* Alias for function name in GNU C Library. */
-weak_alias (__gettext, gettext);
-#endif
diff --git a/navit/support/gettext_intl/gettextP.h b/navit/support/gettext_intl/gettextP.h
deleted file mode 100644
index ab9cc8c64..000000000
--- a/navit/support/gettext_intl/gettextP.h
+++ /dev/null
@@ -1,215 +0,0 @@
-/* Header describing internals of libintl library.
- Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
- Written by Ulrich Drepper <drepper@cygnus.com>, 1995.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _GETTEXTP_H
-#define _GETTEXTP_H
-
-#include <stddef.h> /* Get size_t. */
-
-#ifdef _LIBC
-# include "../iconv/gconv_int.h"
-#else
-# if HAVE_ICONV
-# include <iconv.h>
-# endif
-#endif
-
-#include "loadinfo.h"
-
-#include "gmo.h" /* Get nls_uint32. */
-
-/* @@ end of prolog @@ */
-
-#ifndef internal_function
-# define internal_function
-#endif
-
-#ifndef attribute_hidden
-# define attribute_hidden
-#endif
-
-/* Tell the compiler when a conditional or integer expression is
- almost always true or almost always false. */
-#ifndef HAVE_BUILTIN_EXPECT
-# define __builtin_expect(expr, val) (expr)
-#endif
-
-#ifndef W
-# define W(flag, data) ((flag) ? SWAP (data) : (data))
-#endif
-
-
-#ifdef _LIBC
-# include <byteswap.h>
-# define SWAP(i) bswap_32 (i)
-#else
-static nls_uint32
-SWAP (i)
- nls_uint32 i;
-{
- return (i << 24) | ((i & 0xff00) << 8) | ((i >> 8) & 0xff00) | (i >> 24);
-}
-#endif
-
-
-/* In-memory representation of system dependent string. */
-struct sysdep_string_desc
-{
- /* Length of addressed string, including the trailing NUL. */
- size_t length;
- /* Pointer to addressed string. */
- const char *pointer;
-};
-
-/* The representation of an opened message catalog. */
-struct loaded_domain
-{
- /* Pointer to memory containing the .mo file. */
- const char *data;
- /* 1 if the memory is mmap()ed, 0 if the memory is malloc()ed. */
- int use_mmap;
- /* Size of mmap()ed memory. */
- size_t mmap_size;
- /* 1 if the .mo file uses a different endianness than this machine. */
- int must_swap;
- /* Pointer to additional malloc()ed memory. */
- void *malloced;
-
- /* Number of static strings pairs. */
- nls_uint32 nstrings;
- /* Pointer to descriptors of original strings in the file. */
- const struct string_desc *orig_tab;
- /* Pointer to descriptors of translated strings in the file. */
- const struct string_desc *trans_tab;
-
- /* Number of system dependent strings pairs. */
- nls_uint32 n_sysdep_strings;
- /* Pointer to descriptors of original sysdep strings. */
- const struct sysdep_string_desc *orig_sysdep_tab;
- /* Pointer to descriptors of translated sysdep strings. */
- const struct sysdep_string_desc *trans_sysdep_tab;
-
- /* Size of hash table. */
- nls_uint32 hash_size;
- /* Pointer to hash table. */
- const nls_uint32 *hash_tab;
- /* 1 if the hash table uses a different endianness than this machine. */
- int must_swap_hash_tab;
-
- int codeset_cntr;
-#ifdef _LIBC
- __gconv_t conv;
-#else
-# if HAVE_ICONV
- iconv_t conv;
-# endif
-#endif
- char **conv_tab;
-
- struct expression *plural;
- unsigned long int nplurals;
-};
-
-/* We want to allocate a string at the end of the struct. But ISO C
- doesn't allow zero sized arrays. */
-#ifdef __GNUC__
-# define ZERO 0
-#else
-# define ZERO 1
-#endif
-
-/* A set of settings bound to a message domain. Used to store settings
- from bindtextdomain() and bind_textdomain_codeset(). */
-struct binding
-{
- struct binding *next;
- char *dirname;
- int codeset_cntr; /* Incremented each time codeset changes. */
- char *codeset;
- char domainname[ZERO];
-};
-
-/* A counter which is incremented each time some previous translations
- become invalid.
- This variable is part of the external ABI of the GNU libintl. */
-extern int _nl_msg_cat_cntr;
-
-#ifndef _LIBC
-const char *_nl_locale_name (int category, const char *categoryname);
-#endif
-
-struct loaded_l10nfile *_nl_find_domain (const char *__dirname, char *__locale,
- const char *__domainname,
- struct binding *__domainbinding)
- internal_function;
-void _nl_load_domain (struct loaded_l10nfile *__domain,
- struct binding *__domainbinding)
- internal_function;
-void _nl_unload_domain (struct loaded_domain *__domain)
- internal_function;
-const char *_nl_init_domain_conv (struct loaded_l10nfile *__domain_file,
- struct loaded_domain *__domain,
- struct binding *__domainbinding)
- internal_function;
-void _nl_free_domain_conv (struct loaded_domain *__domain)
- internal_function;
-
-char *_nl_find_msg (struct loaded_l10nfile *domain_file,
- struct binding *domainbinding, const char *msgid,
- size_t *lengthp)
- internal_function;
-
-#ifdef _LIBC
-extern char *__gettext (const char *__msgid);
-extern char *__dgettext (const char *__domainname, const char *__msgid);
-extern char *__dcgettext (const char *__domainname, const char *__msgid,
- int __category);
-extern char *__ngettext (const char *__msgid1, const char *__msgid2,
- unsigned long int __n);
-extern char *__dngettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- unsigned long int n);
-extern char *__dcngettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- unsigned long int __n, int __category);
-extern char *__dcigettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- int __plural, unsigned long int __n,
- int __category);
-extern char *__textdomain (const char *__domainname);
-extern char *__bindtextdomain (const char *__domainname,
- const char *__dirname);
-extern char *__bind_textdomain_codeset (const char *__domainname,
- const char *__codeset);
-#else
-/* Declare the exported libintl_* functions, in a way that allows us to
- call them under their real name. */
-# undef _INTL_REDIRECT_INLINE
-# undef _INTL_REDIRECT_MACROS
-# define _INTL_REDIRECT_MACROS
-# include "libgnuintl.h"
-extern char *libintl_dcigettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- int __plural, unsigned long int __n,
- int __category);
-#endif
-
-/* @@ begin of epilog @@ */
-
-#endif /* gettextP.h */
diff --git a/navit/support/gettext_intl/gmo.h b/navit/support/gettext_intl/gmo.h
deleted file mode 100644
index e7c9cc14b..000000000
--- a/navit/support/gettext_intl/gmo.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/* Description of GNU message catalog format: general file layout.
- Copyright (C) 1995, 1997, 2000-2002, 2004 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _GETTEXT_H
-#define _GETTEXT_H 1
-
-#include <limits.h>
-
-/* @@ end of prolog @@ */
-
-/* The magic number of the GNU message catalog format. */
-#define _MAGIC 0x950412de
-#define _MAGIC_SWAPPED 0xde120495
-
-/* Revision number of the currently used .mo (binary) file format. */
-#define MO_REVISION_NUMBER 0
-#define MO_REVISION_NUMBER_WITH_SYSDEP_I 1
-
-/* The following contortions are an attempt to use the C preprocessor
- to determine an unsigned integral type that is 32 bits wide. An
- alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
- as of version autoconf-2.13, the AC_CHECK_SIZEOF macro doesn't work
- when cross-compiling. */
-
-#if __STDC__
-# define UINT_MAX_32_BITS 4294967295U
-#else
-# define UINT_MAX_32_BITS 0xFFFFFFFF
-#endif
-
-/* If UINT_MAX isn't defined, assume it's a 32-bit type.
- This should be valid for all systems GNU cares about because
- that doesn't include 16-bit systems, and only modern systems
- (that certainly have <limits.h>) have 64+-bit integral types. */
-
-#ifndef UINT_MAX
-# define UINT_MAX UINT_MAX_32_BITS
-#endif
-
-#if UINT_MAX == UINT_MAX_32_BITS
-typedef unsigned nls_uint32;
-#else
-# if USHRT_MAX == UINT_MAX_32_BITS
-typedef unsigned short nls_uint32;
-# else
-# if ULONG_MAX == UINT_MAX_32_BITS
-typedef unsigned long nls_uint32;
-# else
- /* The following line is intended to throw an error. Using #error is
- not portable enough. */
- "Cannot determine unsigned 32-bit data type."
-# endif
-# endif
-#endif
-
-
-/* Header for binary .mo file format. */
-struct mo_file_header
-{
- /* The magic number. */
- nls_uint32 magic;
- /* The revision number of the file format. */
- nls_uint32 revision;
-
- /* The following are only used in .mo files with major revision 0 or 1. */
-
- /* The number of strings pairs. */
- nls_uint32 nstrings;
- /* Offset of table with start offsets of original strings. */
- nls_uint32 orig_tab_offset;
- /* Offset of table with start offsets of translated strings. */
- nls_uint32 trans_tab_offset;
- /* Size of hash table. */
- nls_uint32 hash_tab_size;
- /* Offset of first hash table entry. */
- nls_uint32 hash_tab_offset;
-
- /* The following are only used in .mo files with minor revision >= 1. */
-
- /* The number of system dependent segments. */
- nls_uint32 n_sysdep_segments;
- /* Offset of table describing system dependent segments. */
- nls_uint32 sysdep_segments_offset;
- /* The number of system dependent strings pairs. */
- nls_uint32 n_sysdep_strings;
- /* Offset of table with start offsets of original sysdep strings. */
- nls_uint32 orig_sysdep_tab_offset;
- /* Offset of table with start offsets of translated sysdep strings. */
- nls_uint32 trans_sysdep_tab_offset;
-};
-
-/* Descriptor for static string contained in the binary .mo file. */
-struct string_desc
-{
- /* Length of addressed string, not including the trailing NUL. */
- nls_uint32 length;
- /* Offset of string in file. */
- nls_uint32 offset;
-};
-
-/* The following are only used in .mo files with minor revision >= 1. */
-
-/* Descriptor for system dependent string segment. */
-struct sysdep_segment
-{
- /* Length of addressed string, including the trailing NUL. */
- nls_uint32 length;
- /* Offset of string in file. */
- nls_uint32 offset;
-};
-
-/* Descriptor for system dependent string. */
-struct sysdep_string
-{
- /* Offset of static string segments in file. */
- nls_uint32 offset;
- /* Alternating sequence of static and system dependent segments.
- The last segment is a static segment, including the trailing NUL. */
- struct segment_pair
- {
- /* Size of static segment. */
- nls_uint32 segsize;
- /* Reference to system dependent string segment, or ~0 at the end. */
- nls_uint32 sysdepref;
- } segments[1];
-};
-
-/* Marker for the end of the segments[] array. This has the value 0xFFFFFFFF,
- regardless whether 'int' is 16 bit, 32 bit, or 64 bit. */
-#define SEGMENTS_END ((nls_uint32) ~0)
-
-/* @@ begin of epilog @@ */
-
-#endif /* gettext.h */
diff --git a/navit/support/gettext_intl/hash-string.h b/navit/support/gettext_intl/hash-string.h
deleted file mode 100644
index eb3a6ae76..000000000
--- a/navit/support/gettext_intl/hash-string.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/* Description of GNU message catalog format: string hashing function.
- Copyright (C) 1995, 1997-1998, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* @@ end of prolog @@ */
-
-/* We assume to have `unsigned long int' value with at least 32 bits. */
-#define HASHWORDBITS 32
-
-
-/* Defines the so called `hashpjw' function by P.J. Weinberger
- [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
- 1986, 1987 Bell Telephone Laboratories, Inc.] */
-static unsigned long int
-hash_string (const char *str_param)
-{
- unsigned long int hval, g;
- const char *str = str_param;
-
- /* Compute the hash value for the given string. */
- hval = 0;
- while (*str != '\0')
- {
- hval <<= 4;
- hval += (unsigned char) *str++;
- g = hval & ((unsigned long int) 0xf << (HASHWORDBITS - 4));
- if (g != 0)
- {
- hval ^= g >> (HASHWORDBITS - 8);
- hval ^= g;
- }
- }
- return hval;
-}
diff --git a/navit/support/gettext_intl/intl-compat.c b/navit/support/gettext_intl/intl-compat.c
deleted file mode 100644
index 96f9d955d..000000000
--- a/navit/support/gettext_intl/intl-compat.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/* intl-compat.c - Stub functions to call gettext functions from GNU gettext
- Library.
- Copyright (C) 1995, 2000-2003 Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include "gettextP.h"
-
-/* @@ end of prolog @@ */
-
-/* This file redirects the gettext functions (without prefix) to those
- defined in the included GNU libintl library (with "libintl_" prefix).
- It is compiled into libintl in order to make the AM_GNU_GETTEXT test
- of gettext <= 0.11.2 work with the libintl library >= 0.11.3 which
- has the redirections primarily in the <libintl.h> include file.
- It is also compiled into libgnuintl so that libgnuintl.so can be used
- as LD_PRELOADable library on glibc systems, to provide the extra
- features that the functions in the libc don't have (namely, logging). */
-
-
-#undef gettext
-#undef dgettext
-#undef dcgettext
-#undef ngettext
-#undef dngettext
-#undef dcngettext
-#undef textdomain
-#undef bindtextdomain
-#undef bind_textdomain_codeset
-
-
-/* When building a DLL, we must export some functions. Note that because
- the functions are only defined for binary backward compatibility, we
- don't need to use __declspec(dllimport) in any case. */
-#if defined _MSC_VER && BUILDING_DLL
-# define DLL_EXPORTED __declspec(dllexport)
-#else
-# define DLL_EXPORTED
-#endif
-
-
-DLL_EXPORTED
-char *
-gettext (const char *msgid)
-{
- return libintl_gettext (msgid);
-}
-
-
-DLL_EXPORTED
-char *
-dgettext (const char *domainname, const char *msgid)
-{
- return libintl_dgettext (domainname, msgid);
-}
-
-
-DLL_EXPORTED
-char *
-dcgettext (const char *domainname, const char *msgid, int category)
-{
- return libintl_dcgettext (domainname, msgid, category);
-}
-
-
-DLL_EXPORTED
-char *
-ngettext (const char *msgid1, const char *msgid2, unsigned long int n)
-{
- return libintl_ngettext (msgid1, msgid2, n);
-}
-
-
-DLL_EXPORTED
-char *
-dngettext (const char *domainname,
- const char *msgid1, const char *msgid2, unsigned long int n)
-{
- return libintl_dngettext (domainname, msgid1, msgid2, n);
-}
-
-
-DLL_EXPORTED
-char *
-dcngettext (const char *domainname,
- const char *msgid1, const char *msgid2, unsigned long int n,
- int category)
-{
- return libintl_dcngettext (domainname, msgid1, msgid2, n, category);
-}
-
-
-DLL_EXPORTED
-char *
-textdomain (const char *domainname)
-{
- return libintl_textdomain (domainname);
-}
-
-
-DLL_EXPORTED
-char *
-bindtextdomain (const char *domainname, const char *dirname)
-{
- return libintl_bindtextdomain (domainname, dirname);
-}
-
-
-DLL_EXPORTED
-char *
-bind_textdomain_codeset (const char *domainname, const char *codeset)
-{
- return libintl_bind_textdomain_codeset (domainname, codeset);
-}
diff --git a/navit/support/gettext_intl/l10nflist.c b/navit/support/gettext_intl/l10nflist.c
deleted file mode 100644
index 7d4182ada..000000000
--- a/navit/support/gettext_intl/l10nflist.c
+++ /dev/null
@@ -1,421 +0,0 @@
-/* Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc.
- Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* Tell glibc's <string.h> to provide a prototype for stpcpy().
- This must come before <config.h> because <config.h> may include
- <features.h>, and once <features.h> has been included, it's too late. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <string.h>
-
-#if defined _LIBC || defined HAVE_ARGZ_H
-# include <argz.h>
-#endif
-#include <ctype.h>
-#include <sys/types.h>
-#include <stdlib.h>
-
-#include "loadinfo.h"
-
-/* On some strange systems still no definition of NULL is found. Sigh! */
-#ifndef NULL
-# if defined __STDC__ && __STDC__
-# define NULL ((void *) 0)
-# else
-# define NULL 0
-# endif
-#endif
-
-/* @@ end of prolog @@ */
-
-#ifdef _LIBC
-/* Rename the non ANSI C functions. This is required by the standard
- because some ANSI C functions will require linking with this object
- file and the name space must not be polluted. */
-# ifndef stpcpy
-# define stpcpy(dest, src) __stpcpy(dest, src)
-# endif
-#else
-# ifndef HAVE_STPCPY
-static char *stpcpy (char *dest, const char *src);
-# endif
-#endif
-
-/* Pathname support.
- ISSLASH(C) tests whether C is a directory separator character.
- IS_ABSOLUTE_PATH(P) tests whether P is an absolute path. If it is not,
- it may be concatenated to a directory pathname.
- */
-#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
- /* Win32, OS/2, DOS */
-# define ISSLASH(C) ((C) == '/' || (C) == '\\')
-# define HAS_DEVICE(P) \
- ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
- && (P)[1] == ':')
-# define IS_ABSOLUTE_PATH(P) (ISSLASH ((P)[0]) || HAS_DEVICE (P))
-#else
- /* Unix */
-# define ISSLASH(C) ((C) == '/')
-# define IS_ABSOLUTE_PATH(P) ISSLASH ((P)[0])
-#endif
-
-/* Define function which are usually not available. */
-
-#if !defined _LIBC && !defined HAVE___ARGZ_COUNT
-/* Returns the number of strings in ARGZ. */
-static size_t
-argz_count__ (const char *argz, size_t len)
-{
- size_t count = 0;
- while (len > 0)
- {
- size_t part_len = strlen (argz);
- argz += part_len + 1;
- len -= part_len + 1;
- count++;
- }
- return count;
-}
-# undef __argz_count
-# define __argz_count(argz, len) argz_count__ (argz, len)
-#else
-# ifdef _LIBC
-# define __argz_count(argz, len) INTUSE(__argz_count) (argz, len)
-# endif
-#endif /* !_LIBC && !HAVE___ARGZ_COUNT */
-
-#if !defined _LIBC && !defined HAVE___ARGZ_STRINGIFY
-/* Make '\0' separated arg vector ARGZ printable by converting all the '\0's
- except the last into the character SEP. */
-static void
-argz_stringify__ (char *argz, size_t len, int sep)
-{
- while (len > 0)
- {
- size_t part_len = strlen (argz);
- argz += part_len;
- len -= part_len + 1;
- if (len > 0)
- *argz++ = sep;
- }
-}
-# undef __argz_stringify
-# define __argz_stringify(argz, len, sep) argz_stringify__ (argz, len, sep)
-#else
-# ifdef _LIBC
-# define __argz_stringify(argz, len, sep) \
- INTUSE(__argz_stringify) (argz, len, sep)
-# endif
-#endif /* !_LIBC && !HAVE___ARGZ_STRINGIFY */
-
-#if !defined _LIBC && !defined HAVE___ARGZ_NEXT
-static char *
-argz_next__ (char *argz, size_t argz_len, const char *entry)
-{
- if (entry)
- {
- if (entry < argz + argz_len)
- entry = strchr (entry, '\0') + 1;
-
- return entry >= argz + argz_len ? NULL : (char *) entry;
- }
- else
- if (argz_len > 0)
- return argz;
- else
- return 0;
-}
-# undef __argz_next
-# define __argz_next(argz, len, entry) argz_next__ (argz, len, entry)
-#endif /* !_LIBC && !HAVE___ARGZ_NEXT */
-
-
-/* Return number of bits set in X. */
-static int
-pop (int x)
-{
- /* We assume that no more than 16 bits are used. */
- x = ((x & ~0x5555) >> 1) + (x & 0x5555);
- x = ((x & ~0x3333) >> 2) + (x & 0x3333);
- x = ((x >> 4) + x) & 0x0f0f;
- x = ((x >> 8) + x) & 0xff;
-
- return x;
-}
-
-
-struct loaded_l10nfile *
-_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
- const char *dirlist, size_t dirlist_len,
- int mask, const char *language, const char *territory,
- const char *codeset, const char *normalized_codeset,
- const char *modifier, const char *special,
- const char *sponsor, const char *revision,
- const char *filename, int do_allocate)
-{
- char *abs_filename;
- struct loaded_l10nfile **lastp;
- struct loaded_l10nfile *retval;
- char *cp;
- size_t dirlist_count;
- size_t entries;
- int cnt;
-
- /* If LANGUAGE contains an absolute directory specification, we ignore
- DIRLIST. */
- if (IS_ABSOLUTE_PATH (language))
- dirlist_len = 0;
-
- /* Allocate room for the full file name. */
- abs_filename = (char *) malloc (dirlist_len
- + strlen (language)
- + ((mask & TERRITORY) != 0
- ? strlen (territory) + 1 : 0)
- + ((mask & XPG_CODESET) != 0
- ? strlen (codeset) + 1 : 0)
- + ((mask & XPG_NORM_CODESET) != 0
- ? strlen (normalized_codeset) + 1 : 0)
- + (((mask & XPG_MODIFIER) != 0
- || (mask & CEN_AUDIENCE) != 0)
- ? strlen (modifier) + 1 : 0)
- + ((mask & CEN_SPECIAL) != 0
- ? strlen (special) + 1 : 0)
- + (((mask & CEN_SPONSOR) != 0
- || (mask & CEN_REVISION) != 0)
- ? (1 + ((mask & CEN_SPONSOR) != 0
- ? strlen (sponsor) : 0)
- + ((mask & CEN_REVISION) != 0
- ? strlen (revision) + 1 : 0)) : 0)
- + 1 + strlen (filename) + 1);
-
- if (abs_filename == NULL)
- return NULL;
-
- /* Construct file name. */
- cp = abs_filename;
- if (dirlist_len > 0)
- {
- memcpy (cp, dirlist, dirlist_len);
- __argz_stringify (cp, dirlist_len, PATH_SEPARATOR);
- cp += dirlist_len;
- cp[-1] = '/';
- }
-
- cp = stpcpy (cp, language);
-
- if ((mask & TERRITORY) != 0)
- {
- *cp++ = '_';
- cp = stpcpy (cp, territory);
- }
- if ((mask & XPG_CODESET) != 0)
- {
- *cp++ = '.';
- cp = stpcpy (cp, codeset);
- }
- if ((mask & XPG_NORM_CODESET) != 0)
- {
- *cp++ = '.';
- cp = stpcpy (cp, normalized_codeset);
- }
- if ((mask & (XPG_MODIFIER | CEN_AUDIENCE)) != 0)
- {
- /* This component can be part of both syntaces but has different
- leading characters. For CEN we use `+', else `@'. */
- *cp++ = (mask & CEN_AUDIENCE) != 0 ? '+' : '@';
- cp = stpcpy (cp, modifier);
- }
- if ((mask & CEN_SPECIAL) != 0)
- {
- *cp++ = '+';
- cp = stpcpy (cp, special);
- }
- if ((mask & (CEN_SPONSOR | CEN_REVISION)) != 0)
- {
- *cp++ = ',';
- if ((mask & CEN_SPONSOR) != 0)
- cp = stpcpy (cp, sponsor);
- if ((mask & CEN_REVISION) != 0)
- {
- *cp++ = '_';
- cp = stpcpy (cp, revision);
- }
- }
-
- *cp++ = '/';
- stpcpy (cp, filename);
-
- /* Look in list of already loaded domains whether it is already
- available. */
- lastp = l10nfile_list;
- for (retval = *l10nfile_list; retval != NULL; retval = retval->next)
- if (retval->filename != NULL)
- {
- int compare = strcmp (retval->filename, abs_filename);
- if (compare == 0)
- /* We found it! */
- break;
- if (compare < 0)
- {
- /* It's not in the list. */
- retval = NULL;
- break;
- }
-
- lastp = &retval->next;
- }
-
- if (retval != NULL || do_allocate == 0)
- {
- free (abs_filename);
- return retval;
- }
-
- dirlist_count = (dirlist_len > 0 ? __argz_count (dirlist, dirlist_len) : 1);
-
- /* Allocate a new loaded_l10nfile. */
- retval =
- (struct loaded_l10nfile *)
- malloc (sizeof (*retval)
- + (((dirlist_count << pop (mask)) + (dirlist_count > 1 ? 1 : 0))
- * sizeof (struct loaded_l10nfile *)));
- if (retval == NULL)
- return NULL;
-
- retval->filename = abs_filename;
-
- /* We set retval->data to NULL here; it is filled in later.
- Setting retval->decided to 1 here means that retval does not
- correspond to a real file (dirlist_count > 1) or is not worth
- looking up (if an unnormalized codeset was specified). */
- retval->decided = (dirlist_count > 1
- || ((mask & XPG_CODESET) != 0
- && (mask & XPG_NORM_CODESET) != 0));
- retval->data = NULL;
-
- retval->next = *lastp;
- *lastp = retval;
-
- entries = 0;
- /* Recurse to fill the inheritance list of RETVAL.
- If the DIRLIST is a real list (i.e. DIRLIST_COUNT > 1), the RETVAL
- entry does not correspond to a real file; retval->filename contains
- colons. In this case we loop across all elements of DIRLIST and
- across all bit patterns dominated by MASK.
- If the DIRLIST is a single directory or entirely redundant (i.e.
- DIRLIST_COUNT == 1), we loop across all bit patterns dominated by
- MASK, excluding MASK itself.
- In either case, we loop down from MASK to 0. This has the effect
- that the extra bits in the locale name are dropped in this order:
- first the modifier, then the territory, then the codeset, then the
- normalized_codeset. */
- for (cnt = dirlist_count > 1 ? mask : mask - 1; cnt >= 0; --cnt)
- if ((cnt & ~mask) == 0
- && ((cnt & CEN_SPECIFIC) == 0 || (cnt & XPG_SPECIFIC) == 0)
- && ((cnt & XPG_CODESET) == 0 || (cnt & XPG_NORM_CODESET) == 0))
- {
- if (dirlist_count > 1)
- {
- /* Iterate over all elements of the DIRLIST. */
- char *dir = NULL;
-
- while ((dir = __argz_next ((char *) dirlist, dirlist_len, dir))
- != NULL)
- retval->successor[entries++]
- = _nl_make_l10nflist (l10nfile_list, dir, strlen (dir) + 1,
- cnt, language, territory, codeset,
- normalized_codeset, modifier, special,
- sponsor, revision, filename, 1);
- }
- else
- retval->successor[entries++]
- = _nl_make_l10nflist (l10nfile_list, dirlist, dirlist_len,
- cnt, language, territory, codeset,
- normalized_codeset, modifier, special,
- sponsor, revision, filename, 1);
- }
- retval->successor[entries] = NULL;
-
- return retval;
-}
-
-/* Normalize codeset name. There is no standard for the codeset
- names. Normalization allows the user to use any of the common
- names. The return value is dynamically allocated and has to be
- freed by the caller. */
-const char *
-_nl_normalize_codeset (const char *codeset, size_t name_len)
-{
- int len = 0;
- int only_digit = 1;
- char *retval;
- char *wp;
- size_t cnt;
-
- for (cnt = 0; cnt < name_len; ++cnt)
- if (isalnum ((unsigned char) codeset[cnt]))
- {
- ++len;
-
- if (isalpha ((unsigned char) codeset[cnt]))
- only_digit = 0;
- }
-
- retval = (char *) malloc ((only_digit ? 3 : 0) + len + 1);
-
- if (retval != NULL)
- {
- if (only_digit)
- wp = stpcpy (retval, "iso");
- else
- wp = retval;
-
- for (cnt = 0; cnt < name_len; ++cnt)
- if (isalpha ((unsigned char) codeset[cnt]))
- *wp++ = tolower ((unsigned char) codeset[cnt]);
- else if (isdigit ((unsigned char) codeset[cnt]))
- *wp++ = codeset[cnt];
-
- *wp = '\0';
- }
-
- return (const char *) retval;
-}
-
-
-/* @@ begin of epilog @@ */
-
-/* We don't want libintl.a to depend on any other library. So we
- avoid the non-standard function stpcpy. In GNU C Library this
- function is available, though. Also allow the symbol HAVE_STPCPY
- to be defined. */
-#if !_LIBC && !HAVE_STPCPY
-static char *
-stpcpy (char *dest, const char *src)
-{
- while ((*dest++ = *src++) != '\0')
- /* Do nothing. */ ;
- return dest - 1;
-}
-#endif
diff --git a/navit/support/gettext_intl/libgnuintl.h b/navit/support/gettext_intl/libgnuintl.h
deleted file mode 100644
index 87d234511..000000000
--- a/navit/support/gettext_intl/libgnuintl.h
+++ /dev/null
@@ -1,384 +0,0 @@
-/* Message catalogs for internationalization.
- Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _LIBINTL_H
-#define _LIBINTL_H 1
-#include "config.h"
-
-#include <locale.h>
-
-/* The LC_MESSAGES locale category is the category used by the functions
- gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
- On systems that don't define it, use an arbitrary value instead.
- On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
- then includes <libintl.h> (i.e. this file!) and then only defines
- LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
- in this case. */
-#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
-# define LC_MESSAGES 1729
-#endif
-
-/* We define an additional symbol to signal that we use the GNU
- implementation of gettext. */
-#define __USE_GNU_GETTEXT 1
-
-/* Provide information about the supported file formats. Returns the
- maximum minor revision number supported for a given major revision. */
-#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
- ((major) == 0 ? 1 : -1)
-
-/* Resolve a platform specific conflict on DJGPP. GNU gettext takes
- precedence over _conio_gettext. */
-#ifdef __DJGPP__
-# undef gettext
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* We redirect the functions to those prefixed with "libintl_". This is
- necessary, because some systems define gettext/textdomain/... in the C
- library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
- If we used the unprefixed names, there would be cases where the
- definition in the C library would override the one in the libintl.so
- shared library. Recall that on ELF systems, the symbols are looked
- up in the following order:
- 1. in the executable,
- 2. in the shared libraries specified on the link command line, in order,
- 3. in the dependencies of the shared libraries specified on the link
- command line,
- 4. in the dlopen()ed shared libraries, in the order in which they were
- dlopen()ed.
- The definition in the C library would override the one in libintl.so if
- either
- * -lc is given on the link command line and -lintl isn't, or
- * -lc is given on the link command line before -lintl, or
- * libintl.so is a dependency of a dlopen()ed shared library but not
- linked to the executable at link time.
- Since Solaris gettext() behaves differently than GNU gettext(), this
- would be unacceptable.
-
- The redirection happens by default through macros in C, so that &gettext
- is independent of the compilation unit, but through inline functions in
- C++, in order not to interfere with the name mangling of class fields or
- class methods called 'gettext'. */
-
-/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
- If he doesn't, we choose the method. A third possible method is
- _INTL_REDIRECT_ASM, supported only by GCC. */
-#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
-# if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
-# define _INTL_REDIRECT_ASM
-# else
-# ifdef __cplusplus
-# define _INTL_REDIRECT_INLINE
-# else
-# define _INTL_REDIRECT_MACROS
-# endif
-# endif
-#endif
-/* Auxiliary macros. */
-#ifdef _INTL_REDIRECT_ASM
-# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
-# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
-# define _INTL_STRINGIFY(prefix) #prefix
-#else
-# define _INTL_ASM(cname)
-#endif
-
-/* Look up MSGID in the current default message catalog for the current
- LC_MESSAGES locale. If not found, returns MSGID itself (the default
- text). */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_gettext (const char *__msgid);
-static inline char *gettext (const char *__msgid)
-{
- return libintl_gettext (__msgid);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define gettext libintl_gettext
-#endif
-extern char *gettext (const char *__msgid)
- _INTL_ASM (libintl_gettext);
-#endif
-
-/* Look up MSGID in the DOMAINNAME message catalog for the current
- LC_MESSAGES locale. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
-static inline char *dgettext (const char *__domainname, const char *__msgid)
-{
- return libintl_dgettext (__domainname, __msgid);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define dgettext libintl_dgettext
-#endif
-extern char *dgettext (const char *__domainname, const char *__msgid)
- _INTL_ASM (libintl_dgettext);
-#endif
-
-/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
- locale. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
- int __category);
-static inline char *dcgettext (const char *__domainname, const char *__msgid,
- int __category)
-{
- return libintl_dcgettext (__domainname, __msgid, __category);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define dcgettext libintl_dcgettext
-#endif
-extern char *dcgettext (const char *__domainname, const char *__msgid,
- int __category)
- _INTL_ASM (libintl_dcgettext);
-#endif
-
-
-/* Similar to `gettext' but select the plural form corresponding to the
- number N. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
- unsigned long int __n);
-static inline char *ngettext (const char *__msgid1, const char *__msgid2,
- unsigned long int __n)
-{
- return libintl_ngettext (__msgid1, __msgid2, __n);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define ngettext libintl_ngettext
-#endif
-extern char *ngettext (const char *__msgid1, const char *__msgid2,
- unsigned long int __n)
- _INTL_ASM (libintl_ngettext);
-#endif
-
-/* Similar to `dgettext' but select the plural form corresponding to the
- number N. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
- const char *__msgid2, unsigned long int __n);
-static inline char *dngettext (const char *__domainname, const char *__msgid1,
- const char *__msgid2, unsigned long int __n)
-{
- return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define dngettext libintl_dngettext
-#endif
-extern char *dngettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- unsigned long int __n)
- _INTL_ASM (libintl_dngettext);
-#endif
-
-/* Similar to `dcgettext' but select the plural form corresponding to the
- number N. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_dcngettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- unsigned long int __n, int __category);
-static inline char *dcngettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- unsigned long int __n, int __category)
-{
- return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define dcngettext libintl_dcngettext
-#endif
-extern char *dcngettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- unsigned long int __n, int __category)
- _INTL_ASM (libintl_dcngettext);
-#endif
-
-
-/* Set the current default message catalog to DOMAINNAME.
- If DOMAINNAME is null, return the current default.
- If DOMAINNAME is "", reset to the default of "messages". */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_textdomain (const char *__domainname);
-static inline char *textdomain (const char *__domainname)
-{
- return libintl_textdomain (__domainname);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define textdomain libintl_textdomain
-#endif
-extern char *textdomain (const char *__domainname)
- _INTL_ASM (libintl_textdomain);
-#endif
-
-/* Specify that the DOMAINNAME message catalog will be found
- in DIRNAME rather than in the system locale data base. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_bindtextdomain (const char *__domainname,
- const char *__dirname);
-static inline char *bindtextdomain (const char *__domainname,
- const char *__dirname)
-{
- return libintl_bindtextdomain (__domainname, __dirname);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define bindtextdomain libintl_bindtextdomain
-#endif
-extern char *bindtextdomain (const char *__domainname, const char *__dirname)
- _INTL_ASM (libintl_bindtextdomain);
-#endif
-
-/* Specify the character encoding in which the messages from the
- DOMAINNAME message catalog will be returned. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_bind_textdomain_codeset (const char *__domainname,
- const char *__codeset);
-static inline char *bind_textdomain_codeset (const char *__domainname,
- const char *__codeset)
-{
- return libintl_bind_textdomain_codeset (__domainname, __codeset);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define bind_textdomain_codeset libintl_bind_textdomain_codeset
-#endif
-extern char *bind_textdomain_codeset (const char *__domainname,
- const char *__codeset)
- _INTL_ASM (libintl_bind_textdomain_codeset);
-#endif
-
-
-/* Support for format strings with positions in *printf(), following the
- POSIX/XSI specification.
- Note: These replacements for the *printf() functions are visible only
- in source files that #include <libintl.h> or #include "gettext.h".
- Packages that use *printf() in source files that don't refer to _()
- or gettext() but for which the format string could be the return value
- of _() or gettext() need to add this #include. Oh well. */
-
-#if 1
-
-#include <stdio.h>
-#include <stddef.h>
-
-/* Get va_list. */
-#if __STDC__ || defined __cplusplus || defined _MSC_VER
-# include <stdarg.h>
-#else
-# include <varargs.h>
-#endif
-
-#undef fprintf
-#define fprintf libintl_fprintf
-extern int fprintf (FILE *, const char *, ...);
-#undef vfprintf
-#define vfprintf libintl_vfprintf
-extern int vfprintf (FILE *, const char *, va_list);
-
-#undef printf
-#define printf libintl_printf
-extern int printf (const char *, ...);
-#undef vprintf
-#define vprintf libintl_vprintf
-extern int vprintf (const char *, va_list);
-
-#undef sprintf
-#define sprintf libintl_sprintf
-extern int sprintf (char *, const char *, ...);
-#undef vsprintf
-#define vsprintf libintl_vsprintf
-extern int vsprintf (char *, const char *, va_list);
-
-#if HAVE_SNPRINTF
-
-#undef snprintf
-#define snprintf libintl_snprintf
-extern int snprintf (char *, size_t, const char *, ...);
-#undef vsnprintf
-#define vsnprintf libintl_vsnprintf
-extern int vsnprintf (char *, size_t, const char *, va_list);
-
-#endif
-
-#if HAVE_ASPRINTF
-
-#undef asprintf
-#define asprintf libintl_asprintf
-extern int asprintf (char **, const char *, ...);
-#undef vasprintf
-#define vasprintf libintl_vasprintf
-extern int vasprintf (char **, const char *, va_list);
-
-#endif
-
-#if HAVE_WPRINTF
-
-#undef fwprintf
-#define fwprintf libintl_fwprintf
-extern int fwprintf (FILE *, const wchar_t *, ...);
-#undef vfwprintf
-#define vfwprintf libintl_vfwprintf
-extern int vfwprintf (FILE *, const wchar_t *, va_list);
-
-#undef wprintf
-#define wprintf libintl_wprintf
-extern int wprintf (const wchar_t *, ...);
-#undef vwprintf
-#define vwprintf libintl_vwprintf
-extern int vwprintf (const wchar_t *, va_list);
-
-#undef swprintf
-#define swprintf libintl_swprintf
-extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
-#undef vswprintf
-#define vswprintf libintl_vswprintf
-extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
-
-#endif
-
-#endif
-
-
-/* Support for relocatable packages. */
-
-/* Sets the original and the current installation prefix of the package.
- Relocation simply replaces a pathname starting with the original prefix
- by the corresponding pathname with the current prefix instead. Both
- prefixes should be directory names without trailing slash (i.e. use ""
- instead of "/"). */
-#define libintl_set_relocation_prefix libintl_set_relocation_prefix
-extern void
- libintl_set_relocation_prefix (const char *orig_prefix,
- const char *curr_prefix);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* libintl.h */
diff --git a/navit/support/gettext_intl/libgnuintl.h.in b/navit/support/gettext_intl/libgnuintl.h.in
deleted file mode 100644
index 3be7eb990..000000000
--- a/navit/support/gettext_intl/libgnuintl.h.in
+++ /dev/null
@@ -1,383 +0,0 @@
-/* Message catalogs for internationalization.
- Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _LIBINTL_H
-#define _LIBINTL_H 1
-
-#include <locale.h>
-
-/* The LC_MESSAGES locale category is the category used by the functions
- gettext() and dgettext(). It is specified in POSIX, but not in ANSI C.
- On systems that don't define it, use an arbitrary value instead.
- On Solaris, <locale.h> defines __LOCALE_H (or _LOCALE_H in Solaris 2.5)
- then includes <libintl.h> (i.e. this file!) and then only defines
- LC_MESSAGES. To avoid a redefinition warning, don't define LC_MESSAGES
- in this case. */
-#if !defined LC_MESSAGES && !(defined __LOCALE_H || (defined _LOCALE_H && defined __sun))
-# define LC_MESSAGES 1729
-#endif
-
-/* We define an additional symbol to signal that we use the GNU
- implementation of gettext. */
-#define __USE_GNU_GETTEXT 1
-
-/* Provide information about the supported file formats. Returns the
- maximum minor revision number supported for a given major revision. */
-#define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
- ((major) == 0 ? 1 : -1)
-
-/* Resolve a platform specific conflict on DJGPP. GNU gettext takes
- precedence over _conio_gettext. */
-#ifdef __DJGPP__
-# undef gettext
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* We redirect the functions to those prefixed with "libintl_". This is
- necessary, because some systems define gettext/textdomain/... in the C
- library (namely, Solaris 2.4 and newer, and GNU libc 2.0 and newer).
- If we used the unprefixed names, there would be cases where the
- definition in the C library would override the one in the libintl.so
- shared library. Recall that on ELF systems, the symbols are looked
- up in the following order:
- 1. in the executable,
- 2. in the shared libraries specified on the link command line, in order,
- 3. in the dependencies of the shared libraries specified on the link
- command line,
- 4. in the dlopen()ed shared libraries, in the order in which they were
- dlopen()ed.
- The definition in the C library would override the one in libintl.so if
- either
- * -lc is given on the link command line and -lintl isn't, or
- * -lc is given on the link command line before -lintl, or
- * libintl.so is a dependency of a dlopen()ed shared library but not
- linked to the executable at link time.
- Since Solaris gettext() behaves differently than GNU gettext(), this
- would be unacceptable.
-
- The redirection happens by default through macros in C, so that &gettext
- is independent of the compilation unit, but through inline functions in
- C++, in order not to interfere with the name mangling of class fields or
- class methods called 'gettext'. */
-
-/* The user can define _INTL_REDIRECT_INLINE or _INTL_REDIRECT_MACROS.
- If he doesn't, we choose the method. A third possible method is
- _INTL_REDIRECT_ASM, supported only by GCC. */
-#if !(defined _INTL_REDIRECT_INLINE || defined _INTL_REDIRECT_MACROS)
-# if __GNUC__ >= 2 && !defined __APPLE_CC__ && !defined __MINGW32__ && !(__GNUC__ == 2 && defined _AIX) && (defined __STDC__ || defined __cplusplus)
-# define _INTL_REDIRECT_ASM
-# else
-# ifdef __cplusplus
-# define _INTL_REDIRECT_INLINE
-# else
-# define _INTL_REDIRECT_MACROS
-# endif
-# endif
-#endif
-/* Auxiliary macros. */
-#ifdef _INTL_REDIRECT_ASM
-# define _INTL_ASM(cname) __asm__ (_INTL_ASMNAME (__USER_LABEL_PREFIX__, #cname))
-# define _INTL_ASMNAME(prefix,cnamestring) _INTL_STRINGIFY (prefix) cnamestring
-# define _INTL_STRINGIFY(prefix) #prefix
-#else
-# define _INTL_ASM(cname)
-#endif
-
-/* Look up MSGID in the current default message catalog for the current
- LC_MESSAGES locale. If not found, returns MSGID itself (the default
- text). */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_gettext (const char *__msgid);
-static inline char *gettext (const char *__msgid)
-{
- return libintl_gettext (__msgid);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define gettext libintl_gettext
-#endif
-extern char *gettext (const char *__msgid)
- _INTL_ASM (libintl_gettext);
-#endif
-
-/* Look up MSGID in the DOMAINNAME message catalog for the current
- LC_MESSAGES locale. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_dgettext (const char *__domainname, const char *__msgid);
-static inline char *dgettext (const char *__domainname, const char *__msgid)
-{
- return libintl_dgettext (__domainname, __msgid);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define dgettext libintl_dgettext
-#endif
-extern char *dgettext (const char *__domainname, const char *__msgid)
- _INTL_ASM (libintl_dgettext);
-#endif
-
-/* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
- locale. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_dcgettext (const char *__domainname, const char *__msgid,
- int __category);
-static inline char *dcgettext (const char *__domainname, const char *__msgid,
- int __category)
-{
- return libintl_dcgettext (__domainname, __msgid, __category);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define dcgettext libintl_dcgettext
-#endif
-extern char *dcgettext (const char *__domainname, const char *__msgid,
- int __category)
- _INTL_ASM (libintl_dcgettext);
-#endif
-
-
-/* Similar to `gettext' but select the plural form corresponding to the
- number N. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_ngettext (const char *__msgid1, const char *__msgid2,
- unsigned long int __n);
-static inline char *ngettext (const char *__msgid1, const char *__msgid2,
- unsigned long int __n)
-{
- return libintl_ngettext (__msgid1, __msgid2, __n);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define ngettext libintl_ngettext
-#endif
-extern char *ngettext (const char *__msgid1, const char *__msgid2,
- unsigned long int __n)
- _INTL_ASM (libintl_ngettext);
-#endif
-
-/* Similar to `dgettext' but select the plural form corresponding to the
- number N. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_dngettext (const char *__domainname, const char *__msgid1,
- const char *__msgid2, unsigned long int __n);
-static inline char *dngettext (const char *__domainname, const char *__msgid1,
- const char *__msgid2, unsigned long int __n)
-{
- return libintl_dngettext (__domainname, __msgid1, __msgid2, __n);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define dngettext libintl_dngettext
-#endif
-extern char *dngettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- unsigned long int __n)
- _INTL_ASM (libintl_dngettext);
-#endif
-
-/* Similar to `dcgettext' but select the plural form corresponding to the
- number N. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_dcngettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- unsigned long int __n, int __category);
-static inline char *dcngettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- unsigned long int __n, int __category)
-{
- return libintl_dcngettext (__domainname, __msgid1, __msgid2, __n, __category);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define dcngettext libintl_dcngettext
-#endif
-extern char *dcngettext (const char *__domainname,
- const char *__msgid1, const char *__msgid2,
- unsigned long int __n, int __category)
- _INTL_ASM (libintl_dcngettext);
-#endif
-
-
-/* Set the current default message catalog to DOMAINNAME.
- If DOMAINNAME is null, return the current default.
- If DOMAINNAME is "", reset to the default of "messages". */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_textdomain (const char *__domainname);
-static inline char *textdomain (const char *__domainname)
-{
- return libintl_textdomain (__domainname);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define textdomain libintl_textdomain
-#endif
-extern char *textdomain (const char *__domainname)
- _INTL_ASM (libintl_textdomain);
-#endif
-
-/* Specify that the DOMAINNAME message catalog will be found
- in DIRNAME rather than in the system locale data base. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_bindtextdomain (const char *__domainname,
- const char *__dirname);
-static inline char *bindtextdomain (const char *__domainname,
- const char *__dirname)
-{
- return libintl_bindtextdomain (__domainname, __dirname);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define bindtextdomain libintl_bindtextdomain
-#endif
-extern char *bindtextdomain (const char *__domainname, const char *__dirname)
- _INTL_ASM (libintl_bindtextdomain);
-#endif
-
-/* Specify the character encoding in which the messages from the
- DOMAINNAME message catalog will be returned. */
-#ifdef _INTL_REDIRECT_INLINE
-extern char *libintl_bind_textdomain_codeset (const char *__domainname,
- const char *__codeset);
-static inline char *bind_textdomain_codeset (const char *__domainname,
- const char *__codeset)
-{
- return libintl_bind_textdomain_codeset (__domainname, __codeset);
-}
-#else
-#ifdef _INTL_REDIRECT_MACROS
-# define bind_textdomain_codeset libintl_bind_textdomain_codeset
-#endif
-extern char *bind_textdomain_codeset (const char *__domainname,
- const char *__codeset)
- _INTL_ASM (libintl_bind_textdomain_codeset);
-#endif
-
-
-/* Support for format strings with positions in *printf(), following the
- POSIX/XSI specification.
- Note: These replacements for the *printf() functions are visible only
- in source files that #include <libintl.h> or #include "gettext.h".
- Packages that use *printf() in source files that don't refer to _()
- or gettext() but for which the format string could be the return value
- of _() or gettext() need to add this #include. Oh well. */
-
-#if !@HAVE_POSIX_PRINTF@
-
-#include <stdio.h>
-#include <stddef.h>
-
-/* Get va_list. */
-#if __STDC__ || defined __cplusplus || defined _MSC_VER
-# include <stdarg.h>
-#else
-# include <varargs.h>
-#endif
-
-#undef fprintf
-#define fprintf libintl_fprintf
-extern int fprintf (FILE *, const char *, ...);
-#undef vfprintf
-#define vfprintf libintl_vfprintf
-extern int vfprintf (FILE *, const char *, va_list);
-
-#undef printf
-#define printf libintl_printf
-extern int printf (const char *, ...);
-#undef vprintf
-#define vprintf libintl_vprintf
-extern int vprintf (const char *, va_list);
-
-#undef sprintf
-#define sprintf libintl_sprintf
-extern int sprintf (char *, const char *, ...);
-#undef vsprintf
-#define vsprintf libintl_vsprintf
-extern int vsprintf (char *, const char *, va_list);
-
-#if @HAVE_SNPRINTF@
-
-#undef snprintf
-#define snprintf libintl_snprintf
-extern int snprintf (char *, size_t, const char *, ...);
-#undef vsnprintf
-#define vsnprintf libintl_vsnprintf
-extern int vsnprintf (char *, size_t, const char *, va_list);
-
-#endif
-
-#if @HAVE_ASPRINTF@
-
-#undef asprintf
-#define asprintf libintl_asprintf
-extern int asprintf (char **, const char *, ...);
-#undef vasprintf
-#define vasprintf libintl_vasprintf
-extern int vasprintf (char **, const char *, va_list);
-
-#endif
-
-#if @HAVE_WPRINTF@
-
-#undef fwprintf
-#define fwprintf libintl_fwprintf
-extern int fwprintf (FILE *, const wchar_t *, ...);
-#undef vfwprintf
-#define vfwprintf libintl_vfwprintf
-extern int vfwprintf (FILE *, const wchar_t *, va_list);
-
-#undef wprintf
-#define wprintf libintl_wprintf
-extern int wprintf (const wchar_t *, ...);
-#undef vwprintf
-#define vwprintf libintl_vwprintf
-extern int vwprintf (const wchar_t *, va_list);
-
-#undef swprintf
-#define swprintf libintl_swprintf
-extern int swprintf (wchar_t *, size_t, const wchar_t *, ...);
-#undef vswprintf
-#define vswprintf libintl_vswprintf
-extern int vswprintf (wchar_t *, size_t, const wchar_t *, va_list);
-
-#endif
-
-#endif
-
-
-/* Support for relocatable packages. */
-
-/* Sets the original and the current installation prefix of the package.
- Relocation simply replaces a pathname starting with the original prefix
- by the corresponding pathname with the current prefix instead. Both
- prefixes should be directory names without trailing slash (i.e. use ""
- instead of "/"). */
-#define libintl_set_relocation_prefix libintl_set_relocation_prefix
-extern void
- libintl_set_relocation_prefix (const char *orig_prefix,
- const char *curr_prefix);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* libintl.h */
diff --git a/navit/support/gettext_intl/loadinfo.h b/navit/support/gettext_intl/loadinfo.h
deleted file mode 100644
index 65e5ebd1f..000000000
--- a/navit/support/gettext_intl/loadinfo.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* Copyright (C) 1996-1999, 2000-2003 Free Software Foundation, Inc.
- This file is part of the GNU C Library.
- Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _LOADINFO_H
-#define _LOADINFO_H 1
-
-/* Declarations of locale dependent catalog lookup functions.
- Implemented in
-
- localealias.c Possibly replace a locale name by another.
- explodename.c Split a locale name into its various fields.
- l10nflist.c Generate a list of filenames of possible message catalogs.
- finddomain.c Find and open the relevant message catalogs.
-
- The main function _nl_find_domain() in finddomain.c is declared
- in gettextP.h.
- */
-
-#ifndef internal_function
-# define internal_function
-#endif
-
-/* Tell the compiler when a conditional or integer expression is
- almost always true or almost always false. */
-#ifndef HAVE_BUILTIN_EXPECT
-# define __builtin_expect(expr, val) (expr)
-#endif
-
-/* Separator in PATH like lists of pathnames. */
-#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
- /* Win32, OS/2, DOS */
-# define PATH_SEPARATOR ';'
-#else
- /* Unix */
-# define PATH_SEPARATOR ':'
-#endif
-
-/* Encoding of locale name parts. */
-#define CEN_REVISION 1
-#define CEN_SPONSOR 2
-#define CEN_SPECIAL 4
-#define XPG_NORM_CODESET 8
-#define XPG_CODESET 16
-#define TERRITORY 32
-#define CEN_AUDIENCE 64
-#define XPG_MODIFIER 128
-
-#define CEN_SPECIFIC (CEN_REVISION|CEN_SPONSOR|CEN_SPECIAL|CEN_AUDIENCE)
-#define XPG_SPECIFIC (XPG_CODESET|XPG_NORM_CODESET|XPG_MODIFIER)
-
-
-struct loaded_l10nfile
-{
- const char *filename;
- int decided;
-
- const void *data;
-
- struct loaded_l10nfile *next;
- struct loaded_l10nfile *successor[1];
-};
-
-
-/* Normalize codeset name. There is no standard for the codeset
- names. Normalization allows the user to use any of the common
- names. The return value is dynamically allocated and has to be
- freed by the caller. */
-extern const char *_nl_normalize_codeset (const char *codeset,
- size_t name_len);
-
-/* Lookup a locale dependent file.
- *L10NFILE_LIST denotes a pool of lookup results of locale dependent
- files of the same kind, sorted in decreasing order of ->filename.
- DIRLIST and DIRLIST_LEN are an argz list of directories in which to
- look, containing at least one directory (i.e. DIRLIST_LEN > 0).
- MASK, LANGUAGE, TERRITORY, CODESET, NORMALIZED_CODESET, MODIFIER,
- SPECIAL, SPONSOR, REVISION are the pieces of the locale name, as
- produced by _nl_explode_name(). FILENAME is the filename suffix.
- The return value is the lookup result, either found in *L10NFILE_LIST,
- or - if DO_ALLOCATE is nonzero - freshly allocated, or possibly NULL.
- If the return value is non-NULL, it is added to *L10NFILE_LIST, and
- its ->next field denotes the chaining inside *L10NFILE_LIST, and
- furthermore its ->successor[] field contains a list of other lookup
- results from which this lookup result inherits. */
-extern struct loaded_l10nfile *
-_nl_make_l10nflist (struct loaded_l10nfile **l10nfile_list,
- const char *dirlist, size_t dirlist_len, int mask,
- const char *language, const char *territory,
- const char *codeset, const char *normalized_codeset,
- const char *modifier, const char *special,
- const char *sponsor, const char *revision,
- const char *filename, int do_allocate);
-
-/* Lookup the real locale name for a locale alias NAME, or NULL if
- NAME is not a locale alias (but possibly a real locale name).
- The return value is statically allocated and must not be freed. */
-extern const char *_nl_expand_alias (const char *name);
-
-/* Split a locale name NAME into its pieces: language, modifier,
- territory, codeset, special, sponsor, revision.
- NAME gets destructively modified: NUL bytes are inserted here and
- there. *LANGUAGE gets assigned NAME. Each of *MODIFIER, *TERRITORY,
- *CODESET, *SPECIAL, *SPONSOR, *REVISION gets assigned either a
- pointer into the old NAME string, or NULL. *NORMALIZED_CODESET
- gets assigned the expanded *CODESET, if it is different from *CODESET;
- this one is dynamically allocated and has to be freed by the caller.
- The return value is a bitmask, where each bit corresponds to one
- filled-in value:
- XPG_MODIFIER, CEN_AUDIENCE for *MODIFIER,
- TERRITORY for *TERRITORY,
- XPG_CODESET for *CODESET,
- XPG_NORM_CODESET for *NORMALIZED_CODESET,
- CEN_SPECIAL for *SPECIAL,
- CEN_SPONSOR for *SPONSOR,
- CEN_REVISION for *REVISION.
- */
-extern int _nl_explode_name (char *name, const char **language,
- const char **modifier, const char **territory,
- const char **codeset,
- const char **normalized_codeset,
- const char **special, const char **sponsor,
- const char **revision);
-
-/* Split a locale name NAME into a leading language part and all the
- rest. Return a pointer to the first character after the language,
- i.e. to the first byte of the rest. */
-extern char *_nl_find_language (const char *name);
-
-#endif /* loadinfo.h */
diff --git a/navit/support/gettext_intl/loadmsgcat.c b/navit/support/gettext_intl/loadmsgcat.c
deleted file mode 100644
index 55208667f..000000000
--- a/navit/support/gettext_intl/loadmsgcat.c
+++ /dev/null
@@ -1,1423 +0,0 @@
-/* Load needed message catalogs.
- Copyright (C) 1995-1999, 2000-2004 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* Tell glibc's <string.h> to provide a prototype for mempcpy().
- This must come before <config.h> because <config.h> may include
- <features.h>, and once <features.h> has been included, it's too late. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <ctype.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#ifdef __GNUC__
-# undef alloca
-# define alloca __builtin_alloca
-# define HAVE_ALLOCA 1
-#else
-# ifdef _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
-# else
-# if defined HAVE_ALLOCA_H || defined _LIBC
-# include <alloca.h>
-# else
-# ifdef _AIX
- #pragma alloca
-# else
-# ifndef alloca
-char *alloca ();
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#include <string.h>
-
-#if defined HAVE_UNISTD_H || defined _LIBC
-# include <unistd.h>
-#endif
-
-#ifdef _LIBC
-# include <langinfo.h>
-# include <locale.h>
-#endif
-
-#if (defined HAVE_MMAP && defined HAVE_MUNMAP && !defined DISALLOW_MMAP) \
- || (defined _LIBC && defined _POSIX_MAPPED_FILES)
-# include <sys/mman.h>
-# undef HAVE_MMAP
-# define HAVE_MMAP 1
-#else
-# undef HAVE_MMAP
-#endif
-
-#if defined HAVE_STDINT_H_WITH_UINTMAX || defined _LIBC
-# include <stdint.h>
-#endif
-#if defined HAVE_INTTYPES_H || defined _LIBC
-# include <inttypes.h>
-#endif
-
-#include "gmo.h"
-#include "gettextP.h"
-#include "hash-string.h"
-#include "plural-exp.h"
-
-#ifdef _LIBC
-# include "../locale/localeinfo.h"
-#endif
-
-/* Provide fallback values for macros that ought to be defined in <inttypes.h>.
- Note that our fallback values need not be literal strings, because we don't
- use them with preprocessor string concatenation. */
-#if !defined PRId8 || PRI_MACROS_BROKEN
-# undef PRId8
-# define PRId8 "d"
-#endif
-#if !defined PRIi8 || PRI_MACROS_BROKEN
-# undef PRIi8
-# define PRIi8 "i"
-#endif
-#if !defined PRIo8 || PRI_MACROS_BROKEN
-# undef PRIo8
-# define PRIo8 "o"
-#endif
-#if !defined PRIu8 || PRI_MACROS_BROKEN
-# undef PRIu8
-# define PRIu8 "u"
-#endif
-#if !defined PRIx8 || PRI_MACROS_BROKEN
-# undef PRIx8
-# define PRIx8 "x"
-#endif
-#if !defined PRIX8 || PRI_MACROS_BROKEN
-# undef PRIX8
-# define PRIX8 "X"
-#endif
-#if !defined PRId16 || PRI_MACROS_BROKEN
-# undef PRId16
-# define PRId16 "d"
-#endif
-#if !defined PRIi16 || PRI_MACROS_BROKEN
-# undef PRIi16
-# define PRIi16 "i"
-#endif
-#if !defined PRIo16 || PRI_MACROS_BROKEN
-# undef PRIo16
-# define PRIo16 "o"
-#endif
-#if !defined PRIu16 || PRI_MACROS_BROKEN
-# undef PRIu16
-# define PRIu16 "u"
-#endif
-#if !defined PRIx16 || PRI_MACROS_BROKEN
-# undef PRIx16
-# define PRIx16 "x"
-#endif
-#if !defined PRIX16 || PRI_MACROS_BROKEN
-# undef PRIX16
-# define PRIX16 "X"
-#endif
-#if !defined PRId32 || PRI_MACROS_BROKEN
-# undef PRId32
-# define PRId32 "d"
-#endif
-#if !defined PRIi32 || PRI_MACROS_BROKEN
-# undef PRIi32
-# define PRIi32 "i"
-#endif
-#if !defined PRIo32 || PRI_MACROS_BROKEN
-# undef PRIo32
-# define PRIo32 "o"
-#endif
-#if !defined PRIu32 || PRI_MACROS_BROKEN
-# undef PRIu32
-# define PRIu32 "u"
-#endif
-#if !defined PRIx32 || PRI_MACROS_BROKEN
-# undef PRIx32
-# define PRIx32 "x"
-#endif
-#if !defined PRIX32 || PRI_MACROS_BROKEN
-# undef PRIX32
-# define PRIX32 "X"
-#endif
-#if !defined PRId64 || PRI_MACROS_BROKEN
-# undef PRId64
-# define PRId64 (sizeof (long) == 8 ? "ld" : "lld")
-#endif
-#if !defined PRIi64 || PRI_MACROS_BROKEN
-# undef PRIi64
-# define PRIi64 (sizeof (long) == 8 ? "li" : "lli")
-#endif
-#if !defined PRIo64 || PRI_MACROS_BROKEN
-# undef PRIo64
-# define PRIo64 (sizeof (long) == 8 ? "lo" : "llo")
-#endif
-#if !defined PRIu64 || PRI_MACROS_BROKEN
-# undef PRIu64
-# define PRIu64 (sizeof (long) == 8 ? "lu" : "llu")
-#endif
-#if !defined PRIx64 || PRI_MACROS_BROKEN
-# undef PRIx64
-# define PRIx64 (sizeof (long) == 8 ? "lx" : "llx")
-#endif
-#if !defined PRIX64 || PRI_MACROS_BROKEN
-# undef PRIX64
-# define PRIX64 (sizeof (long) == 8 ? "lX" : "llX")
-#endif
-#if !defined PRIdLEAST8 || PRI_MACROS_BROKEN
-# undef PRIdLEAST8
-# define PRIdLEAST8 "d"
-#endif
-#if !defined PRIiLEAST8 || PRI_MACROS_BROKEN
-# undef PRIiLEAST8
-# define PRIiLEAST8 "i"
-#endif
-#if !defined PRIoLEAST8 || PRI_MACROS_BROKEN
-# undef PRIoLEAST8
-# define PRIoLEAST8 "o"
-#endif
-#if !defined PRIuLEAST8 || PRI_MACROS_BROKEN
-# undef PRIuLEAST8
-# define PRIuLEAST8 "u"
-#endif
-#if !defined PRIxLEAST8 || PRI_MACROS_BROKEN
-# undef PRIxLEAST8
-# define PRIxLEAST8 "x"
-#endif
-#if !defined PRIXLEAST8 || PRI_MACROS_BROKEN
-# undef PRIXLEAST8
-# define PRIXLEAST8 "X"
-#endif
-#if !defined PRIdLEAST16 || PRI_MACROS_BROKEN
-# undef PRIdLEAST16
-# define PRIdLEAST16 "d"
-#endif
-#if !defined PRIiLEAST16 || PRI_MACROS_BROKEN
-# undef PRIiLEAST16
-# define PRIiLEAST16 "i"
-#endif
-#if !defined PRIoLEAST16 || PRI_MACROS_BROKEN
-# undef PRIoLEAST16
-# define PRIoLEAST16 "o"
-#endif
-#if !defined PRIuLEAST16 || PRI_MACROS_BROKEN
-# undef PRIuLEAST16
-# define PRIuLEAST16 "u"
-#endif
-#if !defined PRIxLEAST16 || PRI_MACROS_BROKEN
-# undef PRIxLEAST16
-# define PRIxLEAST16 "x"
-#endif
-#if !defined PRIXLEAST16 || PRI_MACROS_BROKEN
-# undef PRIXLEAST16
-# define PRIXLEAST16 "X"
-#endif
-#if !defined PRIdLEAST32 || PRI_MACROS_BROKEN
-# undef PRIdLEAST32
-# define PRIdLEAST32 "d"
-#endif
-#if !defined PRIiLEAST32 || PRI_MACROS_BROKEN
-# undef PRIiLEAST32
-# define PRIiLEAST32 "i"
-#endif
-#if !defined PRIoLEAST32 || PRI_MACROS_BROKEN
-# undef PRIoLEAST32
-# define PRIoLEAST32 "o"
-#endif
-#if !defined PRIuLEAST32 || PRI_MACROS_BROKEN
-# undef PRIuLEAST32
-# define PRIuLEAST32 "u"
-#endif
-#if !defined PRIxLEAST32 || PRI_MACROS_BROKEN
-# undef PRIxLEAST32
-# define PRIxLEAST32 "x"
-#endif
-#if !defined PRIXLEAST32 || PRI_MACROS_BROKEN
-# undef PRIXLEAST32
-# define PRIXLEAST32 "X"
-#endif
-#if !defined PRIdLEAST64 || PRI_MACROS_BROKEN
-# undef PRIdLEAST64
-# define PRIdLEAST64 PRId64
-#endif
-#if !defined PRIiLEAST64 || PRI_MACROS_BROKEN
-# undef PRIiLEAST64
-# define PRIiLEAST64 PRIi64
-#endif
-#if !defined PRIoLEAST64 || PRI_MACROS_BROKEN
-# undef PRIoLEAST64
-# define PRIoLEAST64 PRIo64
-#endif
-#if !defined PRIuLEAST64 || PRI_MACROS_BROKEN
-# undef PRIuLEAST64
-# define PRIuLEAST64 PRIu64
-#endif
-#if !defined PRIxLEAST64 || PRI_MACROS_BROKEN
-# undef PRIxLEAST64
-# define PRIxLEAST64 PRIx64
-#endif
-#if !defined PRIXLEAST64 || PRI_MACROS_BROKEN
-# undef PRIXLEAST64
-# define PRIXLEAST64 PRIX64
-#endif
-#if !defined PRIdFAST8 || PRI_MACROS_BROKEN
-# undef PRIdFAST8
-# define PRIdFAST8 "d"
-#endif
-#if !defined PRIiFAST8 || PRI_MACROS_BROKEN
-# undef PRIiFAST8
-# define PRIiFAST8 "i"
-#endif
-#if !defined PRIoFAST8 || PRI_MACROS_BROKEN
-# undef PRIoFAST8
-# define PRIoFAST8 "o"
-#endif
-#if !defined PRIuFAST8 || PRI_MACROS_BROKEN
-# undef PRIuFAST8
-# define PRIuFAST8 "u"
-#endif
-#if !defined PRIxFAST8 || PRI_MACROS_BROKEN
-# undef PRIxFAST8
-# define PRIxFAST8 "x"
-#endif
-#if !defined PRIXFAST8 || PRI_MACROS_BROKEN
-# undef PRIXFAST8
-# define PRIXFAST8 "X"
-#endif
-#if !defined PRIdFAST16 || PRI_MACROS_BROKEN
-# undef PRIdFAST16
-# define PRIdFAST16 "d"
-#endif
-#if !defined PRIiFAST16 || PRI_MACROS_BROKEN
-# undef PRIiFAST16
-# define PRIiFAST16 "i"
-#endif
-#if !defined PRIoFAST16 || PRI_MACROS_BROKEN
-# undef PRIoFAST16
-# define PRIoFAST16 "o"
-#endif
-#if !defined PRIuFAST16 || PRI_MACROS_BROKEN
-# undef PRIuFAST16
-# define PRIuFAST16 "u"
-#endif
-#if !defined PRIxFAST16 || PRI_MACROS_BROKEN
-# undef PRIxFAST16
-# define PRIxFAST16 "x"
-#endif
-#if !defined PRIXFAST16 || PRI_MACROS_BROKEN
-# undef PRIXFAST16
-# define PRIXFAST16 "X"
-#endif
-#if !defined PRIdFAST32 || PRI_MACROS_BROKEN
-# undef PRIdFAST32
-# define PRIdFAST32 "d"
-#endif
-#if !defined PRIiFAST32 || PRI_MACROS_BROKEN
-# undef PRIiFAST32
-# define PRIiFAST32 "i"
-#endif
-#if !defined PRIoFAST32 || PRI_MACROS_BROKEN
-# undef PRIoFAST32
-# define PRIoFAST32 "o"
-#endif
-#if !defined PRIuFAST32 || PRI_MACROS_BROKEN
-# undef PRIuFAST32
-# define PRIuFAST32 "u"
-#endif
-#if !defined PRIxFAST32 || PRI_MACROS_BROKEN
-# undef PRIxFAST32
-# define PRIxFAST32 "x"
-#endif
-#if !defined PRIXFAST32 || PRI_MACROS_BROKEN
-# undef PRIXFAST32
-# define PRIXFAST32 "X"
-#endif
-#if !defined PRIdFAST64 || PRI_MACROS_BROKEN
-# undef PRIdFAST64
-# define PRIdFAST64 PRId64
-#endif
-#if !defined PRIiFAST64 || PRI_MACROS_BROKEN
-# undef PRIiFAST64
-# define PRIiFAST64 PRIi64
-#endif
-#if !defined PRIoFAST64 || PRI_MACROS_BROKEN
-# undef PRIoFAST64
-# define PRIoFAST64 PRIo64
-#endif
-#if !defined PRIuFAST64 || PRI_MACROS_BROKEN
-# undef PRIuFAST64
-# define PRIuFAST64 PRIu64
-#endif
-#if !defined PRIxFAST64 || PRI_MACROS_BROKEN
-# undef PRIxFAST64
-# define PRIxFAST64 PRIx64
-#endif
-#if !defined PRIXFAST64 || PRI_MACROS_BROKEN
-# undef PRIXFAST64
-# define PRIXFAST64 PRIX64
-#endif
-#if !defined PRIdMAX || PRI_MACROS_BROKEN
-# undef PRIdMAX
-# define PRIdMAX (sizeof (uintmax_t) == sizeof (long) ? "ld" : "lld")
-#endif
-#if !defined PRIiMAX || PRI_MACROS_BROKEN
-# undef PRIiMAX
-# define PRIiMAX (sizeof (uintmax_t) == sizeof (long) ? "li" : "lli")
-#endif
-#if !defined PRIoMAX || PRI_MACROS_BROKEN
-# undef PRIoMAX
-# define PRIoMAX (sizeof (uintmax_t) == sizeof (long) ? "lo" : "llo")
-#endif
-#if !defined PRIuMAX || PRI_MACROS_BROKEN
-# undef PRIuMAX
-# define PRIuMAX (sizeof (uintmax_t) == sizeof (long) ? "lu" : "llu")
-#endif
-#if !defined PRIxMAX || PRI_MACROS_BROKEN
-# undef PRIxMAX
-# define PRIxMAX (sizeof (uintmax_t) == sizeof (long) ? "lx" : "llx")
-#endif
-#if !defined PRIXMAX || PRI_MACROS_BROKEN
-# undef PRIXMAX
-# define PRIXMAX (sizeof (uintmax_t) == sizeof (long) ? "lX" : "llX")
-#endif
-#if !defined PRIdPTR || PRI_MACROS_BROKEN
-# undef PRIdPTR
-# define PRIdPTR \
- (sizeof (void *) == sizeof (long) ? "ld" : \
- sizeof (void *) == sizeof (int) ? "d" : \
- "lld")
-#endif
-#if !defined PRIiPTR || PRI_MACROS_BROKEN
-# undef PRIiPTR
-# define PRIiPTR \
- (sizeof (void *) == sizeof (long) ? "li" : \
- sizeof (void *) == sizeof (int) ? "i" : \
- "lli")
-#endif
-#if !defined PRIoPTR || PRI_MACROS_BROKEN
-# undef PRIoPTR
-# define PRIoPTR \
- (sizeof (void *) == sizeof (long) ? "lo" : \
- sizeof (void *) == sizeof (int) ? "o" : \
- "llo")
-#endif
-#if !defined PRIuPTR || PRI_MACROS_BROKEN
-# undef PRIuPTR
-# define PRIuPTR \
- (sizeof (void *) == sizeof (long) ? "lu" : \
- sizeof (void *) == sizeof (int) ? "u" : \
- "llu")
-#endif
-#if !defined PRIxPTR || PRI_MACROS_BROKEN
-# undef PRIxPTR
-# define PRIxPTR \
- (sizeof (void *) == sizeof (long) ? "lx" : \
- sizeof (void *) == sizeof (int) ? "x" : \
- "llx")
-#endif
-#if !defined PRIXPTR || PRI_MACROS_BROKEN
-# undef PRIXPTR
-# define PRIXPTR \
- (sizeof (void *) == sizeof (long) ? "lX" : \
- sizeof (void *) == sizeof (int) ? "X" : \
- "llX")
-#endif
-
-/* @@ end of prolog @@ */
-
-#ifdef _LIBC
-/* Rename the non ISO C functions. This is required by the standard
- because some ISO C functions will require linking with this object
- file and the name space must not be polluted. */
-# define open __open
-# define close __close
-# define read __read
-# define mmap __mmap
-# define munmap __munmap
-#endif
-
-/* For those losing systems which don't have `alloca' we have to add
- some additional code emulating it. */
-#ifdef HAVE_ALLOCA
-# define freea(p) /* nothing */
-#else
-# define alloca(n) malloc (n)
-# define freea(p) free (p)
-#endif
-
-/* For systems that distinguish between text and binary I/O.
- O_BINARY is usually declared in <fcntl.h>. */
-#if !defined O_BINARY && defined _O_BINARY
- /* For MSC-compatible compilers. */
-# define O_BINARY _O_BINARY
-# define O_TEXT _O_TEXT
-#endif
-#ifdef __BEOS__
- /* BeOS 5 has O_BINARY and O_TEXT, but they have no effect. */
-# undef O_BINARY
-# undef O_TEXT
-#endif
-/* On reasonable systems, binary I/O is the default. */
-#ifndef O_BINARY
-# define O_BINARY 0
-#endif
-
-
-/* We need a sign, whether a new catalog was loaded, which can be associated
- with all translations. This is important if the translations are
- cached by one of GCC's features. */
-int _nl_msg_cat_cntr;
-
-
-/* Expand a system dependent string segment. Return NULL if unsupported. */
-static const char *
-get_sysdep_segment_value (const char *name)
-{
- /* Test for an ISO C 99 section 7.8.1 format string directive.
- Syntax:
- P R I { d | i | o | u | x | X }
- { { | LEAST | FAST } { 8 | 16 | 32 | 64 } | MAX | PTR } */
- /* We don't use a table of 14 times 6 'const char *' strings here, because
- data relocations cost startup time. */
- if (name[0] == 'P' && name[1] == 'R' && name[2] == 'I')
- {
- if (name[3] == 'd' || name[3] == 'i' || name[3] == 'o' || name[3] == 'u'
- || name[3] == 'x' || name[3] == 'X')
- {
- if (name[4] == '8' && name[5] == '\0')
- {
- if (name[3] == 'd')
- return PRId8;
- if (name[3] == 'i')
- return PRIi8;
- if (name[3] == 'o')
- return PRIo8;
- if (name[3] == 'u')
- return PRIu8;
- if (name[3] == 'x')
- return PRIx8;
- if (name[3] == 'X')
- return PRIX8;
- abort ();
- }
- if (name[4] == '1' && name[5] == '6' && name[6] == '\0')
- {
- if (name[3] == 'd')
- return PRId16;
- if (name[3] == 'i')
- return PRIi16;
- if (name[3] == 'o')
- return PRIo16;
- if (name[3] == 'u')
- return PRIu16;
- if (name[3] == 'x')
- return PRIx16;
- if (name[3] == 'X')
- return PRIX16;
- abort ();
- }
- if (name[4] == '3' && name[5] == '2' && name[6] == '\0')
- {
- if (name[3] == 'd')
- return PRId32;
- if (name[3] == 'i')
- return PRIi32;
- if (name[3] == 'o')
- return PRIo32;
- if (name[3] == 'u')
- return PRIu32;
- if (name[3] == 'x')
- return PRIx32;
- if (name[3] == 'X')
- return PRIX32;
- abort ();
- }
- if (name[4] == '6' && name[5] == '4' && name[6] == '\0')
- {
- if (name[3] == 'd')
- return PRId64;
- if (name[3] == 'i')
- return PRIi64;
- if (name[3] == 'o')
- return PRIo64;
- if (name[3] == 'u')
- return PRIu64;
- if (name[3] == 'x')
- return PRIx64;
- if (name[3] == 'X')
- return PRIX64;
- abort ();
- }
- if (name[4] == 'L' && name[5] == 'E' && name[6] == 'A'
- && name[7] == 'S' && name[8] == 'T')
- {
- if (name[9] == '8' && name[10] == '\0')
- {
- if (name[3] == 'd')
- return PRIdLEAST8;
- if (name[3] == 'i')
- return PRIiLEAST8;
- if (name[3] == 'o')
- return PRIoLEAST8;
- if (name[3] == 'u')
- return PRIuLEAST8;
- if (name[3] == 'x')
- return PRIxLEAST8;
- if (name[3] == 'X')
- return PRIXLEAST8;
- abort ();
- }
- if (name[9] == '1' && name[10] == '6' && name[11] == '\0')
- {
- if (name[3] == 'd')
- return PRIdLEAST16;
- if (name[3] == 'i')
- return PRIiLEAST16;
- if (name[3] == 'o')
- return PRIoLEAST16;
- if (name[3] == 'u')
- return PRIuLEAST16;
- if (name[3] == 'x')
- return PRIxLEAST16;
- if (name[3] == 'X')
- return PRIXLEAST16;
- abort ();
- }
- if (name[9] == '3' && name[10] == '2' && name[11] == '\0')
- {
- if (name[3] == 'd')
- return PRIdLEAST32;
- if (name[3] == 'i')
- return PRIiLEAST32;
- if (name[3] == 'o')
- return PRIoLEAST32;
- if (name[3] == 'u')
- return PRIuLEAST32;
- if (name[3] == 'x')
- return PRIxLEAST32;
- if (name[3] == 'X')
- return PRIXLEAST32;
- abort ();
- }
- if (name[9] == '6' && name[10] == '4' && name[11] == '\0')
- {
- if (name[3] == 'd')
- return PRIdLEAST64;
- if (name[3] == 'i')
- return PRIiLEAST64;
- if (name[3] == 'o')
- return PRIoLEAST64;
- if (name[3] == 'u')
- return PRIuLEAST64;
- if (name[3] == 'x')
- return PRIxLEAST64;
- if (name[3] == 'X')
- return PRIXLEAST64;
- abort ();
- }
- }
- if (name[4] == 'F' && name[5] == 'A' && name[6] == 'S'
- && name[7] == 'T')
- {
- if (name[8] == '8' && name[9] == '\0')
- {
- if (name[3] == 'd')
- return PRIdFAST8;
- if (name[3] == 'i')
- return PRIiFAST8;
- if (name[3] == 'o')
- return PRIoFAST8;
- if (name[3] == 'u')
- return PRIuFAST8;
- if (name[3] == 'x')
- return PRIxFAST8;
- if (name[3] == 'X')
- return PRIXFAST8;
- abort ();
- }
- if (name[8] == '1' && name[9] == '6' && name[10] == '\0')
- {
- if (name[3] == 'd')
- return PRIdFAST16;
- if (name[3] == 'i')
- return PRIiFAST16;
- if (name[3] == 'o')
- return PRIoFAST16;
- if (name[3] == 'u')
- return PRIuFAST16;
- if (name[3] == 'x')
- return PRIxFAST16;
- if (name[3] == 'X')
- return PRIXFAST16;
- abort ();
- }
- if (name[8] == '3' && name[9] == '2' && name[10] == '\0')
- {
- if (name[3] == 'd')
- return PRIdFAST32;
- if (name[3] == 'i')
- return PRIiFAST32;
- if (name[3] == 'o')
- return PRIoFAST32;
- if (name[3] == 'u')
- return PRIuFAST32;
- if (name[3] == 'x')
- return PRIxFAST32;
- if (name[3] == 'X')
- return PRIXFAST32;
- abort ();
- }
- if (name[8] == '6' && name[9] == '4' && name[10] == '\0')
- {
- if (name[3] == 'd')
- return PRIdFAST64;
- if (name[3] == 'i')
- return PRIiFAST64;
- if (name[3] == 'o')
- return PRIoFAST64;
- if (name[3] == 'u')
- return PRIuFAST64;
- if (name[3] == 'x')
- return PRIxFAST64;
- if (name[3] == 'X')
- return PRIXFAST64;
- abort ();
- }
- }
- if (name[4] == 'M' && name[5] == 'A' && name[6] == 'X'
- && name[7] == '\0')
- {
- if (name[3] == 'd')
- return PRIdMAX;
- if (name[3] == 'i')
- return PRIiMAX;
- if (name[3] == 'o')
- return PRIoMAX;
- if (name[3] == 'u')
- return PRIuMAX;
- if (name[3] == 'x')
- return PRIxMAX;
- if (name[3] == 'X')
- return PRIXMAX;
- abort ();
- }
- if (name[4] == 'P' && name[5] == 'T' && name[6] == 'R'
- && name[7] == '\0')
- {
- if (name[3] == 'd')
- return PRIdPTR;
- if (name[3] == 'i')
- return PRIiPTR;
- if (name[3] == 'o')
- return PRIoPTR;
- if (name[3] == 'u')
- return PRIuPTR;
- if (name[3] == 'x')
- return PRIxPTR;
- if (name[3] == 'X')
- return PRIXPTR;
- abort ();
- }
- }
- }
- /* Test for a glibc specific printf() format directive flag. */
- if (name[0] == 'I' && name[1] == '\0')
- {
-#if defined _LIBC || __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)
- /* The 'I' flag, in numeric format directives, replaces ASCII digits
- with the 'outdigits' defined in the LC_CTYPE locale facet. This is
- used for Farsi (Persian) and maybe Arabic. */
- return "I";
-#else
- return "";
-#endif
- }
- /* Other system dependent strings are not valid. */
- return NULL;
-}
-
-/* Initialize the codeset dependent parts of an opened message catalog.
- Return the header entry. */
-const char *
-internal_function
-_nl_init_domain_conv (struct loaded_l10nfile *domain_file,
- struct loaded_domain *domain,
- struct binding *domainbinding)
-{
- /* Find out about the character set the file is encoded with.
- This can be found (in textual form) in the entry "". If this
- entry does not exist or if this does not contain the `charset='
- information, we will assume the charset matches the one the
- current locale and we don't have to perform any conversion. */
- char *nullentry;
- size_t nullentrylen;
-
- /* Preinitialize fields, to avoid recursion during _nl_find_msg. */
- domain->codeset_cntr =
- (domainbinding != NULL ? domainbinding->codeset_cntr : 0);
-#ifdef _LIBC
- domain->conv = (__gconv_t) -1;
-#else
-# if HAVE_ICONV
- domain->conv = (iconv_t) -1;
-# endif
-#endif
- domain->conv_tab = NULL;
-
- /* Get the header entry. */
- nullentry = _nl_find_msg (domain_file, domainbinding, "", &nullentrylen);
-
- if (nullentry != NULL)
- {
-#if defined _LIBC || HAVE_ICONV
- const char *charsetstr;
-
- charsetstr = strstr (nullentry, "charset=");
- if (charsetstr != NULL)
- {
- size_t len;
- char *charset;
- const char *outcharset;
-
- charsetstr += strlen ("charset=");
- len = strcspn (charsetstr, " \t\n");
-
- charset = (char *) alloca (len + 1);
-# if defined _LIBC || HAVE_MEMPCPY
- *((char *) mempcpy (charset, charsetstr, len)) = '\0';
-# else
- memcpy (charset, charsetstr, len);
- charset[len] = '\0';
-# endif
-
- /* The output charset should normally be determined by the
- locale. But sometimes the locale is not used or not correctly
- set up, so we provide a possibility for the user to override
- this. Moreover, the value specified through
- bind_textdomain_codeset overrides both. */
- if (domainbinding != NULL && domainbinding->codeset != NULL)
- outcharset = domainbinding->codeset;
- else
- {
- outcharset = getenv ("OUTPUT_CHARSET");
- if (outcharset == NULL || outcharset[0] == '\0')
- {
-# ifdef _LIBC
- outcharset = _NL_CURRENT (LC_CTYPE, CODESET);
-# else
-# if HAVE_ICONV
- extern const char *locale_charset (void);
- outcharset = locale_charset ();
-# endif
-# endif
- }
- }
-
-# ifdef _LIBC
- /* We always want to use transliteration. */
- outcharset = norm_add_slashes (outcharset, "TRANSLIT");
- charset = norm_add_slashes (charset, NULL);
- if (__gconv_open (outcharset, charset, &domain->conv,
- GCONV_AVOID_NOCONV)
- != __GCONV_OK)
- domain->conv = (__gconv_t) -1;
-# else
-# if HAVE_ICONV
- /* When using GNU libc >= 2.2 or GNU libiconv >= 1.5,
- we want to use transliteration. */
-# if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2) || __GLIBC__ > 2 \
- || _LIBICONV_VERSION >= 0x0105
- if (strchr (outcharset, '/') == NULL)
- {
- char *tmp;
-
- len = strlen (outcharset);
- tmp = (char *) alloca (len + 10 + 1);
- memcpy (tmp, outcharset, len);
- memcpy (tmp + len, "//TRANSLIT", 10 + 1);
- outcharset = tmp;
-
- domain->conv = iconv_open (outcharset, charset);
-
- freea (outcharset);
- }
- else
-# endif
- domain->conv = iconv_open (outcharset, charset);
-# endif
-# endif
-
- freea (charset);
- }
-#endif /* _LIBC || HAVE_ICONV */
- }
-
- return nullentry;
-}
-
-/* Frees the codeset dependent parts of an opened message catalog. */
-void
-internal_function
-_nl_free_domain_conv (struct loaded_domain *domain)
-{
- if (domain->conv_tab != NULL && domain->conv_tab != (char **) -1)
- free (domain->conv_tab);
-
-#ifdef _LIBC
- if (domain->conv != (__gconv_t) -1)
- __gconv_close (domain->conv);
-#else
-# if HAVE_ICONV
- if (domain->conv != (iconv_t) -1)
- iconv_close (domain->conv);
-# endif
-#endif
-}
-
-/* Load the message catalogs specified by FILENAME. If it is no valid
- message catalog do nothing. */
-void
-internal_function
-_nl_load_domain (struct loaded_l10nfile *domain_file,
- struct binding *domainbinding)
-{
- int fd;
- size_t size;
-#ifdef _LIBC
- struct stat64 st;
-#else
- struct stat st;
-#endif
- struct mo_file_header *data = (struct mo_file_header *) -1;
- int use_mmap = 0;
- struct loaded_domain *domain;
- int revision;
- const char *nullentry;
-
- domain_file->decided = 1;
- domain_file->data = NULL;
-
- /* Note that it would be useless to store domainbinding in domain_file
- because domainbinding might be == NULL now but != NULL later (after
- a call to bind_textdomain_codeset). */
-
- /* If the record does not represent a valid locale the FILENAME
- might be NULL. This can happen when according to the given
- specification the locale file name is different for XPG and CEN
- syntax. */
- if (domain_file->filename == NULL)
- return;
-
- /* Try to open the addressed file. */
- fd = open (domain_file->filename, O_RDONLY | O_BINARY);
- if (fd == -1)
- return;
-
- /* We must know about the size of the file. */
- if (
-#ifdef _LIBC
- __builtin_expect (fstat64 (fd, &st) != 0, 0)
-#else
- __builtin_expect (fstat (fd, &st) != 0, 0)
-#endif
- || __builtin_expect ((size = (size_t) st.st_size) != st.st_size, 0)
- || __builtin_expect (size < sizeof (struct mo_file_header), 0))
- {
- /* Something went wrong. */
- close (fd);
- return;
- }
-
-#ifdef HAVE_MMAP
- /* Now we are ready to load the file. If mmap() is available we try
- this first. If not available or it failed we try to load it. */
- data = (struct mo_file_header *) mmap (NULL, size, PROT_READ,
- MAP_PRIVATE, fd, 0);
-
- if (__builtin_expect (data != (struct mo_file_header *) -1, 1))
- {
- /* mmap() call was successful. */
- close (fd);
- use_mmap = 1;
- }
-#endif
-
- /* If the data is not yet available (i.e. mmap'ed) we try to load
- it manually. */
- if (data == (struct mo_file_header *) -1)
- {
- size_t to_read;
- char *read_ptr;
-
- data = (struct mo_file_header *) malloc (size);
- if (data == NULL)
- return;
-
- to_read = size;
- read_ptr = (char *) data;
- do
- {
- long int nb = (long int) read (fd, read_ptr, to_read);
- if (nb <= 0)
- {
-#ifdef EINTR
- if (nb == -1 && errno == EINTR)
- continue;
-#endif
- close (fd);
- return;
- }
- read_ptr += nb;
- to_read -= nb;
- }
- while (to_read > 0);
-
- close (fd);
- }
-
- /* Using the magic number we can test whether it really is a message
- catalog file. */
- if (__builtin_expect (data->magic != _MAGIC && data->magic != _MAGIC_SWAPPED,
- 0))
- {
- /* The magic number is wrong: not a message catalog file. */
-#ifdef HAVE_MMAP
- if (use_mmap)
- munmap ((caddr_t) data, size);
- else
-#endif
- free (data);
- return;
- }
-
- domain = (struct loaded_domain *) malloc (sizeof (struct loaded_domain));
- if (domain == NULL)
- return;
- domain_file->data = domain;
-
- domain->data = (char *) data;
- domain->use_mmap = use_mmap;
- domain->mmap_size = size;
- domain->must_swap = data->magic != _MAGIC;
- domain->malloced = NULL;
-
- /* Fill in the information about the available tables. */
- revision = W (domain->must_swap, data->revision);
- /* We support only the major revisions 0 and 1. */
- switch (revision >> 16)
- {
- case 0:
- case 1:
- domain->nstrings = W (domain->must_swap, data->nstrings);
- domain->orig_tab = (const struct string_desc *)
- ((char *) data + W (domain->must_swap, data->orig_tab_offset));
- domain->trans_tab = (const struct string_desc *)
- ((char *) data + W (domain->must_swap, data->trans_tab_offset));
- domain->hash_size = W (domain->must_swap, data->hash_tab_size);
- domain->hash_tab =
- (domain->hash_size > 2
- ? (const nls_uint32 *)
- ((char *) data + W (domain->must_swap, data->hash_tab_offset))
- : NULL);
- domain->must_swap_hash_tab = domain->must_swap;
-
- /* Now dispatch on the minor revision. */
- switch (revision & 0xffff)
- {
- case 0:
- domain->n_sysdep_strings = 0;
- domain->orig_sysdep_tab = NULL;
- domain->trans_sysdep_tab = NULL;
- break;
- case 1:
- default:
- {
- nls_uint32 n_sysdep_strings;
-
- if (domain->hash_tab == NULL)
- /* This is invalid. These minor revisions need a hash table. */
- goto invalid;
-
- n_sysdep_strings =
- W (domain->must_swap, data->n_sysdep_strings);
- if (n_sysdep_strings > 0)
- {
- nls_uint32 n_sysdep_segments;
- const struct sysdep_segment *sysdep_segments;
- const char **sysdep_segment_values;
- const nls_uint32 *orig_sysdep_tab;
- const nls_uint32 *trans_sysdep_tab;
- nls_uint32 n_inmem_sysdep_strings;
- size_t memneed;
- char *mem;
- struct sysdep_string_desc *inmem_orig_sysdep_tab;
- struct sysdep_string_desc *inmem_trans_sysdep_tab;
- nls_uint32 *inmem_hash_tab;
- unsigned int i, j;
-
- /* Get the values of the system dependent segments. */
- n_sysdep_segments =
- W (domain->must_swap, data->n_sysdep_segments);
- sysdep_segments = (const struct sysdep_segment *)
- ((char *) data
- + W (domain->must_swap, data->sysdep_segments_offset));
- sysdep_segment_values =
- alloca (n_sysdep_segments * sizeof (const char *));
- for (i = 0; i < n_sysdep_segments; i++)
- {
- const char *name =
- (char *) data
- + W (domain->must_swap, sysdep_segments[i].offset);
- nls_uint32 namelen =
- W (domain->must_swap, sysdep_segments[i].length);
-
- if (!(namelen > 0 && name[namelen - 1] == '\0'))
- {
- freea (sysdep_segment_values);
- goto invalid;
- }
-
- sysdep_segment_values[i] = get_sysdep_segment_value (name);
- }
-
- orig_sysdep_tab = (const nls_uint32 *)
- ((char *) data
- + W (domain->must_swap, data->orig_sysdep_tab_offset));
- trans_sysdep_tab = (const nls_uint32 *)
- ((char *) data
- + W (domain->must_swap, data->trans_sysdep_tab_offset));
-
- /* Compute the amount of additional memory needed for the
- system dependent strings and the augmented hash table.
- At the same time, also drop string pairs which refer to
- an undefined system dependent segment. */
- n_inmem_sysdep_strings = 0;
- memneed = domain->hash_size * sizeof (nls_uint32);
- for (i = 0; i < n_sysdep_strings; i++)
- {
- int valid = 1;
- size_t needs[2];
-
- for (j = 0; j < 2; j++)
- {
- const struct sysdep_string *sysdep_string =
- (const struct sysdep_string *)
- ((char *) data
- + W (domain->must_swap,
- j == 0
- ? orig_sysdep_tab[i]
- : trans_sysdep_tab[i]));
- size_t need = 0;
- const struct segment_pair *p = sysdep_string->segments;
-
- if (W (domain->must_swap, p->sysdepref) != SEGMENTS_END)
- for (p = sysdep_string->segments;; p++)
- {
- nls_uint32 sysdepref;
-
- need += W (domain->must_swap, p->segsize);
-
- sysdepref = W (domain->must_swap, p->sysdepref);
- if (sysdepref == SEGMENTS_END)
- break;
-
- if (sysdepref >= n_sysdep_segments)
- {
- /* Invalid. */
- freea (sysdep_segment_values);
- goto invalid;
- }
-
- if (sysdep_segment_values[sysdepref] == NULL)
- {
- /* This particular string pair is invalid. */
- valid = 0;
- break;
- }
-
- need += strlen (sysdep_segment_values[sysdepref]);
- }
-
- needs[j] = need;
- if (!valid)
- break;
- }
-
- if (valid)
- {
- n_inmem_sysdep_strings++;
- memneed += needs[0] + needs[1];
- }
- }
- memneed += 2 * n_inmem_sysdep_strings
- * sizeof (struct sysdep_string_desc);
-
- if (n_inmem_sysdep_strings > 0)
- {
- unsigned int k;
-
- /* Allocate additional memory. */
- mem = (char *) malloc (memneed);
- if (mem == NULL)
- goto invalid;
-
- domain->malloced = mem;
- inmem_orig_sysdep_tab = (struct sysdep_string_desc *) mem;
- mem += n_inmem_sysdep_strings
- * sizeof (struct sysdep_string_desc);
- inmem_trans_sysdep_tab = (struct sysdep_string_desc *) mem;
- mem += n_inmem_sysdep_strings
- * sizeof (struct sysdep_string_desc);
- inmem_hash_tab = (nls_uint32 *) mem;
- mem += domain->hash_size * sizeof (nls_uint32);
-
- /* Compute the system dependent strings. */
- k = 0;
- for (i = 0; i < n_sysdep_strings; i++)
- {
- int valid = 1;
-
- for (j = 0; j < 2; j++)
- {
- const struct sysdep_string *sysdep_string =
- (const struct sysdep_string *)
- ((char *) data
- + W (domain->must_swap,
- j == 0
- ? orig_sysdep_tab[i]
- : trans_sysdep_tab[i]));
- const struct segment_pair *p =
- sysdep_string->segments;
-
- if (W (domain->must_swap, p->sysdepref)
- != SEGMENTS_END)
- for (p = sysdep_string->segments;; p++)
- {
- nls_uint32 sysdepref;
-
- sysdepref =
- W (domain->must_swap, p->sysdepref);
- if (sysdepref == SEGMENTS_END)
- break;
-
- if (sysdep_segment_values[sysdepref] == NULL)
- {
- /* This particular string pair is
- invalid. */
- valid = 0;
- break;
- }
- }
-
- if (!valid)
- break;
- }
-
- if (valid)
- {
- for (j = 0; j < 2; j++)
- {
- const struct sysdep_string *sysdep_string =
- (const struct sysdep_string *)
- ((char *) data
- + W (domain->must_swap,
- j == 0
- ? orig_sysdep_tab[i]
- : trans_sysdep_tab[i]));
- const char *static_segments =
- (char *) data
- + W (domain->must_swap, sysdep_string->offset);
- const struct segment_pair *p =
- sysdep_string->segments;
-
- /* Concatenate the segments, and fill
- inmem_orig_sysdep_tab[k] (for j == 0) and
- inmem_trans_sysdep_tab[k] (for j == 1). */
-
- struct sysdep_string_desc *inmem_tab_entry =
- (j == 0
- ? inmem_orig_sysdep_tab
- : inmem_trans_sysdep_tab)
- + k;
-
- if (W (domain->must_swap, p->sysdepref)
- == SEGMENTS_END)
- {
- /* Only one static segment. */
- inmem_tab_entry->length =
- W (domain->must_swap, p->segsize);
- inmem_tab_entry->pointer = static_segments;
- }
- else
- {
- inmem_tab_entry->pointer = mem;
-
- for (p = sysdep_string->segments;; p++)
- {
- nls_uint32 segsize =
- W (domain->must_swap, p->segsize);
- nls_uint32 sysdepref =
- W (domain->must_swap, p->sysdepref);
- size_t n;
-
- if (segsize > 0)
- {
- memcpy (mem, static_segments, segsize);
- mem += segsize;
- static_segments += segsize;
- }
-
- if (sysdepref == SEGMENTS_END)
- break;
-
- n = strlen (sysdep_segment_values[sysdepref]);
- memcpy (mem, sysdep_segment_values[sysdepref], n);
- mem += n;
- }
-
- inmem_tab_entry->length =
- mem - inmem_tab_entry->pointer;
- }
- }
-
- k++;
- }
- }
- if (k != n_inmem_sysdep_strings)
- abort ();
-
- /* Compute the augmented hash table. */
- for (i = 0; i < domain->hash_size; i++)
- inmem_hash_tab[i] =
- W (domain->must_swap_hash_tab, domain->hash_tab[i]);
- for (i = 0; i < n_inmem_sysdep_strings; i++)
- {
- const char *msgid = inmem_orig_sysdep_tab[i].pointer;
- nls_uint32 hash_val = hash_string (msgid);
- nls_uint32 idx = hash_val % domain->hash_size;
- nls_uint32 incr =
- 1 + (hash_val % (domain->hash_size - 2));
-
- for (;;)
- {
- if (inmem_hash_tab[idx] == 0)
- {
- /* Hash table entry is empty. Use it. */
- inmem_hash_tab[idx] = 1 + domain->nstrings + i;
- break;
- }
-
- if (idx >= domain->hash_size - incr)
- idx -= domain->hash_size - incr;
- else
- idx += incr;
- }
- }
-
- domain->n_sysdep_strings = n_inmem_sysdep_strings;
- domain->orig_sysdep_tab = inmem_orig_sysdep_tab;
- domain->trans_sysdep_tab = inmem_trans_sysdep_tab;
-
- domain->hash_tab = inmem_hash_tab;
- domain->must_swap_hash_tab = 0;
- }
- else
- {
- domain->n_sysdep_strings = 0;
- domain->orig_sysdep_tab = NULL;
- domain->trans_sysdep_tab = NULL;
- }
-
- freea (sysdep_segment_values);
- }
- else
- {
- domain->n_sysdep_strings = 0;
- domain->orig_sysdep_tab = NULL;
- domain->trans_sysdep_tab = NULL;
- }
- }
- break;
- }
- break;
- default:
- /* This is an invalid revision. */
- invalid:
- /* This is an invalid .mo file. */
- if (domain->malloced)
- free (domain->malloced);
-#ifdef HAVE_MMAP
- if (use_mmap)
- munmap ((caddr_t) data, size);
- else
-#endif
- free (data);
- free (domain);
- domain_file->data = NULL;
- return;
- }
-
- /* Now initialize the character set converter from the character set
- the file is encoded with (found in the header entry) to the domain's
- specified character set or the locale's character set. */
- nullentry = _nl_init_domain_conv (domain_file, domain, domainbinding);
-
- /* Also look for a plural specification. */
- EXTRACT_PLURAL_EXPRESSION (nullentry, &domain->plural, &domain->nplurals);
-}
-
-
-#ifdef _LIBC
-void
-internal_function
-_nl_unload_domain (struct loaded_domain *domain)
-{
- if (domain->plural != &__gettext_germanic_plural)
- __gettext_free_exp (domain->plural);
-
- _nl_free_domain_conv (domain);
-
- if (domain->malloced)
- free (domain->malloced);
-
-# ifdef _POSIX_MAPPED_FILES
- if (domain->use_mmap)
- munmap ((caddr_t) domain->data, domain->mmap_size);
- else
-# endif /* _POSIX_MAPPED_FILES */
- free ((void *) domain->data);
-
- free (domain);
-}
-#endif
diff --git a/navit/support/gettext_intl/localcharset.c b/navit/support/gettext_intl/localcharset.c
deleted file mode 100644
index 4865f1037..000000000
--- a/navit/support/gettext_intl/localcharset.c
+++ /dev/null
@@ -1,398 +0,0 @@
-/* Determine a canonical name for the current locale's character encoding.
-
- Copyright (C) 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* Written by Bruno Haible <bruno@clisp.org>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* Specification. */
-#include "localcharset.h"
-
-#if HAVE_STDDEF_H
-# include <stddef.h>
-#endif
-
-#include <stdio.h>
-#if HAVE_STRING_H
-# include <string.h>
-#else
-# include <strings.h>
-#endif
-#if HAVE_STDLIB_H
-# include <stdlib.h>
-#endif
-
-#if defined _WIN32 || defined __WIN32__
-# undef WIN32 /* avoid warning on mingw32 */
-# define WIN32
-#endif
-
-#if defined __EMX__
-/* Assume EMX program runs on OS/2, even if compiled under DOS. */
-# define OS2
-#endif
-
-#if !defined WIN32
-# if HAVE_LANGINFO_CODESET
-# include <langinfo.h>
-# else
-# if HAVE_SETLOCALE
-# include <locale.h>
-# endif
-# endif
-#elif defined WIN32
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-#endif
-#if defined OS2
-# define INCL_DOS
-# include <os2.h>
-#endif
-
-#if ENABLE_RELOCATABLE
-# include "relocatable.h"
-#else
-# define relocate(pathname) (pathname)
-#endif
-
-#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
- /* Win32, OS/2, DOS */
-# define ISSLASH(C) ((C) == '/' || (C) == '\\')
-#endif
-
-#ifndef DIRECTORY_SEPARATOR
-# define DIRECTORY_SEPARATOR '/'
-#endif
-
-#ifndef ISSLASH
-# define ISSLASH(C) ((C) == DIRECTORY_SEPARATOR)
-#endif
-
-#if HAVE_DECL_GETC_UNLOCKED
-# undef getc
-# define getc getc_unlocked
-#endif
-
-/* The following static variable is declared 'volatile' to avoid a
- possible multithread problem in the function get_charset_aliases. If we
- are running in a threaded environment, and if two threads initialize
- 'charset_aliases' simultaneously, both will produce the same value,
- and everything will be ok if the two assignments to 'charset_aliases'
- are atomic. But I don't know what will happen if the two assignments mix. */
-#if __STDC__ != 1
-# define volatile /* empty */
-#endif
-/* Pointer to the contents of the charset.alias file, if it has already been
- read, else NULL. Its format is:
- ALIAS_1 '\0' CANONICAL_1 '\0' ... ALIAS_n '\0' CANONICAL_n '\0' '\0' */
-static const char * volatile charset_aliases;
-
-/* Return a pointer to the contents of the charset.alias file. */
-static const char *
-get_charset_aliases ()
-{
- const char *cp;
-
- cp = charset_aliases;
- if (cp == NULL)
- {
-#if !(defined VMS || defined WIN32)
- FILE *fp;
- const char *dir = relocate (LIBDIR);
- const char *base = "charset.alias";
- char *file_name;
-
- /* Concatenate dir and base into freshly allocated file_name. */
- {
- size_t dir_len = strlen (dir);
- size_t base_len = strlen (base);
- int add_slash = (dir_len > 0 && !ISSLASH (dir[dir_len - 1]));
- file_name = (char *) malloc (dir_len + add_slash + base_len + 1);
- if (file_name != NULL)
- {
- memcpy (file_name, dir, dir_len);
- if (add_slash)
- file_name[dir_len] = DIRECTORY_SEPARATOR;
- memcpy (file_name + dir_len + add_slash, base, base_len + 1);
- }
- }
-
- if (file_name == NULL || (fp = fopen (file_name, "r")) == NULL)
- /* Out of memory or file not found, treat it as empty. */
- cp = "";
- else
- {
- /* Parse the file's contents. */
- int c;
- char buf1[50+1];
- char buf2[50+1];
- char *res_ptr = NULL;
- size_t res_size = 0;
- size_t l1, l2;
-
- for (;;)
- {
- c = getc (fp);
- if (c == EOF)
- break;
- if (c == '\n' || c == ' ' || c == '\t')
- continue;
- if (c == '#')
- {
- /* Skip comment, to end of line. */
- do
- c = getc (fp);
- while (!(c == EOF || c == '\n'));
- if (c == EOF)
- break;
- continue;
- }
- ungetc (c, fp);
- if (fscanf (fp, "%50s %50s", buf1, buf2) < 2)
- break;
- l1 = strlen (buf1);
- l2 = strlen (buf2);
- if (res_size == 0)
- {
- res_size = l1 + 1 + l2 + 1;
- res_ptr = (char *) malloc (res_size + 1);
- }
- else
- {
- res_size += l1 + 1 + l2 + 1;
- res_ptr = (char *) realloc (res_ptr, res_size + 1);
- }
- if (res_ptr == NULL)
- {
- /* Out of memory. */
- res_size = 0;
- break;
- }
- strcpy (res_ptr + res_size - (l2 + 1) - (l1 + 1), buf1);
- strcpy (res_ptr + res_size - (l2 + 1), buf2);
- }
- fclose (fp);
- if (res_size == 0)
- cp = "";
- else
- {
- *(res_ptr + res_size) = '\0';
- cp = res_ptr;
- }
- }
-
- if (file_name != NULL)
- free (file_name);
-
-#else
-
-# if defined VMS
- /* To avoid the troubles of an extra file charset.alias_vms in the
- sources of many GNU packages, simply inline the aliases here. */
- /* The list of encodings is taken from the OpenVMS 7.3-1 documentation
- "Compaq C Run-Time Library Reference Manual for OpenVMS systems"
- section 10.7 "Handling Different Character Sets". */
- cp = "ISO8859-1" "\0" "ISO-8859-1" "\0"
- "ISO8859-2" "\0" "ISO-8859-2" "\0"
- "ISO8859-5" "\0" "ISO-8859-5" "\0"
- "ISO8859-7" "\0" "ISO-8859-7" "\0"
- "ISO8859-8" "\0" "ISO-8859-8" "\0"
- "ISO8859-9" "\0" "ISO-8859-9" "\0"
- /* Japanese */
- "eucJP" "\0" "EUC-JP" "\0"
- "SJIS" "\0" "SHIFT_JIS" "\0"
- "DECKANJI" "\0" "DEC-KANJI" "\0"
- "SDECKANJI" "\0" "EUC-JP" "\0"
- /* Chinese */
- "eucTW" "\0" "EUC-TW" "\0"
- "DECHANYU" "\0" "DEC-HANYU" "\0"
- "DECHANZI" "\0" "GB2312" "\0"
- /* Korean */
- "DECKOREAN" "\0" "EUC-KR" "\0";
-# endif
-
-# if defined WIN32
- /* To avoid the troubles of installing a separate file in the same
- directory as the DLL and of retrieving the DLL's directory at
- runtime, simply inline the aliases here. */
-
- cp = "CP936" "\0" "GBK" "\0"
- "CP1361" "\0" "JOHAB" "\0"
- "CP20127" "\0" "ASCII" "\0"
- "CP20866" "\0" "KOI8-R" "\0"
- "CP21866" "\0" "KOI8-RU" "\0"
- "CP28591" "\0" "ISO-8859-1" "\0"
- "CP28592" "\0" "ISO-8859-2" "\0"
- "CP28593" "\0" "ISO-8859-3" "\0"
- "CP28594" "\0" "ISO-8859-4" "\0"
- "CP28595" "\0" "ISO-8859-5" "\0"
- "CP28596" "\0" "ISO-8859-6" "\0"
- "CP28597" "\0" "ISO-8859-7" "\0"
- "CP28598" "\0" "ISO-8859-8" "\0"
- "CP28599" "\0" "ISO-8859-9" "\0"
- "CP28605" "\0" "ISO-8859-15" "\0";
-# endif
-#endif
-
- charset_aliases = cp;
- }
-
- return cp;
-}
-
-/* Determine the current locale's character encoding, and canonicalize it
- into one of the canonical names listed in config.charset.
- The result must not be freed; it is statically allocated.
- If the canonical name cannot be determined, the result is a non-canonical
- name. */
-
-#ifdef STATIC
-STATIC
-#endif
-const char *
-locale_charset ()
-{
- const char *codeset;
- const char *aliases;
-
-#if !(defined WIN32 || defined OS2)
-
-# if HAVE_LANGINFO_CODESET
-
- /* Most systems support nl_langinfo (CODESET) nowadays. */
- codeset = nl_langinfo (CODESET);
-
-# else
-
- /* On old systems which lack it, use setlocale or getenv. */
- const char *locale = NULL;
-
- /* But most old systems don't have a complete set of locales. Some
- (like SunOS 4 or DJGPP) have only the C locale. Therefore we don't
- use setlocale here; it would return "C" when it doesn't support the
- locale name the user has set. */
-# if HAVE_SETLOCALE && 0
- locale = setlocale (LC_CTYPE, NULL);
-# endif
- if (locale == NULL || locale[0] == '\0')
- {
- locale = getenv ("LC_ALL");
- if (locale == NULL || locale[0] == '\0')
- {
- locale = getenv ("LC_CTYPE");
- if (locale == NULL || locale[0] == '\0')
- locale = getenv ("LANG");
- }
- }
-
- /* On some old systems, one used to set locale = "iso8859_1". On others,
- you set it to "language_COUNTRY.charset". In any case, we resolve it
- through the charset.alias file. */
- codeset = locale;
-
-# endif
-
-#elif defined WIN32
-
- static char buf[2 + 10 + 1];
-
- /* Woe32 has a function returning the locale's codepage as a number. */
- sprintf (buf, "CP%u", GetACP ());
- codeset = buf;
-
-#elif defined OS2
-
- const char *locale;
- static char buf[2 + 10 + 1];
- ULONG cp[3];
- ULONG cplen;
-
- /* Allow user to override the codeset, as set in the operating system,
- with standard language environment variables. */
- locale = getenv ("LC_ALL");
- if (locale == NULL || locale[0] == '\0')
- {
- locale = getenv ("LC_CTYPE");
- if (locale == NULL || locale[0] == '\0')
- locale = getenv ("LANG");
- }
- if (locale != NULL && locale[0] != '\0')
- {
- /* If the locale name contains an encoding after the dot, return it. */
- const char *dot = strchr (locale, '.');
-
- if (dot != NULL)
- {
- const char *modifier;
-
- dot++;
- /* Look for the possible @... trailer and remove it, if any. */
- modifier = strchr (dot, '@');
- if (modifier == NULL)
- return dot;
- if (modifier - dot < sizeof (buf))
- {
- memcpy (buf, dot, modifier - dot);
- buf [modifier - dot] = '\0';
- return buf;
- }
- }
-
- /* Resolve through the charset.alias file. */
- codeset = locale;
- }
- else
- {
- /* OS/2 has a function returning the locale's codepage as a number. */
- if (DosQueryCp (sizeof (cp), cp, &cplen))
- codeset = "";
- else
- {
- sprintf (buf, "CP%u", cp[0]);
- codeset = buf;
- }
- }
-
-#endif
-
- if (codeset == NULL)
- /* The canonical name cannot be determined. */
- codeset = "";
-
- /* Resolve alias. */
- for (aliases = get_charset_aliases ();
- *aliases != '\0';
- aliases += strlen (aliases) + 1, aliases += strlen (aliases) + 1)
- if (strcmp (codeset, aliases) == 0
- || (aliases[0] == '*' && aliases[1] == '\0'))
- {
- codeset = aliases + strlen (aliases) + 1;
- break;
- }
-
- /* Don't return an empty string. GNU libc and GNU libiconv interpret
- the empty string as denoting "the locale's character encoding",
- thus GNU libiconv would call this function a second time. */
- if (codeset[0] == '\0')
- codeset = "ASCII";
-
- return codeset;
-}
diff --git a/navit/support/gettext_intl/localcharset.h b/navit/support/gettext_intl/localcharset.h
deleted file mode 100644
index 3b137e73c..000000000
--- a/navit/support/gettext_intl/localcharset.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* Determine a canonical name for the current locale's character encoding.
- Copyright (C) 2000-2003 Free Software Foundation, Inc.
- This file is part of the GNU CHARSET Library.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _LOCALCHARSET_H
-#define _LOCALCHARSET_H
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Determine the current locale's character encoding, and canonicalize it
- into one of the canonical names listed in config.charset.
- The result must not be freed; it is statically allocated.
- If the canonical name cannot be determined, the result is a non-canonical
- name. */
-extern const char * locale_charset (void);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _LOCALCHARSET_H */
diff --git a/navit/support/gettext_intl/locale.alias b/navit/support/gettext_intl/locale.alias
deleted file mode 100644
index bd6bb2562..000000000
--- a/navit/support/gettext_intl/locale.alias
+++ /dev/null
@@ -1,78 +0,0 @@
-# Locale name alias data base.
-# Copyright (C) 1996-2001,2003 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Library 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
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-# USA.
-
-# The format of this file is the same as for the corresponding file of
-# the X Window System, which normally can be found in
-# /usr/lib/X11/locale/locale.alias
-# A single line contains two fields: an alias and a substitution value.
-# All entries are case independent.
-
-# Note: This file is far from being complete. If you have a value for
-# your own site which you think might be useful for others too, share
-# it with the rest of us. Send it using the `glibcbug' script to
-# bugs@gnu.org.
-
-# Packages using this file:
-
-bokmal nb_NO.ISO-8859-1
-bokmål nb_NO.ISO-8859-1
-catalan ca_ES.ISO-8859-1
-croatian hr_HR.ISO-8859-2
-czech cs_CZ.ISO-8859-2
-danish da_DK.ISO-8859-1
-dansk da_DK.ISO-8859-1
-deutsch de_DE.ISO-8859-1
-dutch nl_NL.ISO-8859-1
-eesti et_EE.ISO-8859-1
-estonian et_EE.ISO-8859-1
-finnish fi_FI.ISO-8859-1
-français fr_FR.ISO-8859-1
-french fr_FR.ISO-8859-1
-galego gl_ES.ISO-8859-1
-galician gl_ES.ISO-8859-1
-german de_DE.ISO-8859-1
-greek el_GR.ISO-8859-7
-hebrew he_IL.ISO-8859-8
-hrvatski hr_HR.ISO-8859-2
-hungarian hu_HU.ISO-8859-2
-icelandic is_IS.ISO-8859-1
-italian it_IT.ISO-8859-1
-japanese ja_JP.eucJP
-japanese.euc ja_JP.eucJP
-ja_JP ja_JP.eucJP
-ja_JP.ujis ja_JP.eucJP
-japanese.sjis ja_JP.SJIS
-korean ko_KR.eucKR
-korean.euc ko_KR.eucKR
-ko_KR ko_KR.eucKR
-lithuanian lt_LT.ISO-8859-13
-no_NO nb_NO.ISO-8859-1
-no_NO.ISO-8859-1 nb_NO.ISO-8859-1
-norwegian nb_NO.ISO-8859-1
-nynorsk nn_NO.ISO-8859-1
-polish pl_PL.ISO-8859-2
-portuguese pt_PT.ISO-8859-1
-romanian ro_RO.ISO-8859-2
-russian ru_RU.ISO-8859-5
-slovak sk_SK.ISO-8859-2
-slovene sl_SI.ISO-8859-2
-slovenian sl_SI.ISO-8859-2
-spanish es_ES.ISO-8859-1
-swedish sv_SE.ISO-8859-1
-thai th_TH.TIS-620
-turkish tr_TR.ISO-8859-9
diff --git a/navit/support/gettext_intl/localealias.c b/navit/support/gettext_intl/localealias.c
deleted file mode 100644
index ee27649af..000000000
--- a/navit/support/gettext_intl/localealias.c
+++ /dev/null
@@ -1,414 +0,0 @@
-/* Handle aliases for locale names.
- Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* Tell glibc's <string.h> to provide a prototype for mempcpy().
- This must come before <config.h> because <config.h> may include
- <features.h>, and once <features.h> has been included, it's too late. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#include <stdlib.h>
-
-#include <ctype.h>
-#include <stdio.h>
-#if defined _LIBC || defined HAVE___FSETLOCKING
-# include <stdio_ext.h>
-#endif
-#include <sys/types.h>
-
-#ifdef __GNUC__
-# undef alloca
-# define alloca __builtin_alloca
-# define HAVE_ALLOCA 1
-#else
-# ifdef _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
-# else
-# if defined HAVE_ALLOCA_H || defined _LIBC
-# include <alloca.h>
-# else
-# ifdef _AIX
- #pragma alloca
-# else
-# ifndef alloca
-char *alloca ();
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#include <string.h>
-
-#include "gettextP.h"
-
-#if ENABLE_RELOCATABLE
-# include "relocatable.h"
-#else
-# define relocate(pathname) (pathname)
-#endif
-
-/* @@ end of prolog @@ */
-
-#ifdef _LIBC
-/* Rename the non ANSI C functions. This is required by the standard
- because some ANSI C functions will require linking with this object
- file and the name space must not be polluted. */
-# define strcasecmp __strcasecmp
-
-# ifndef mempcpy
-# define mempcpy __mempcpy
-# endif
-# define HAVE_MEMPCPY 1
-# define HAVE___FSETLOCKING 1
-
-/* We need locking here since we can be called from different places. */
-# include <bits/libc-lock.h>
-
-__libc_lock_define_initialized (static, lock);
-#endif
-
-#ifndef internal_function
-# define internal_function
-#endif
-
-/* Some optimizations for glibc. */
-#ifdef _LIBC
-# define FEOF(fp) feof_unlocked (fp)
-# define FGETS(buf, n, fp) fgets_unlocked (buf, n, fp)
-#else
-# define FEOF(fp) feof (fp)
-# define FGETS(buf, n, fp) fgets (buf, n, fp)
-#endif
-
-/* For those losing systems which don't have `alloca' we have to add
- some additional code emulating it. */
-#ifdef HAVE_ALLOCA
-# define freea(p) /* nothing */
-#else
-# define alloca(n) malloc (n)
-# define freea(p) free (p)
-#endif
-
-#if defined _LIBC_REENTRANT || HAVE_DECL_FGETS_UNLOCKED
-# undef fgets
-# define fgets(buf, len, s) fgets_unlocked (buf, len, s)
-#endif
-#if defined _LIBC_REENTRANT || HAVE_DECL_FEOF_UNLOCKED
-# undef feof
-# define feof(s) feof_unlocked (s)
-#endif
-
-
-struct alias_map
-{
- const char *alias;
- const char *value;
-};
-
-
-#ifndef _LIBC
-# define libc_freeres_ptr(decl) decl
-#endif
-
-libc_freeres_ptr (static char *string_space);
-static size_t string_space_act;
-static size_t string_space_max;
-libc_freeres_ptr (static struct alias_map *map);
-static size_t nmap;
-static size_t maxmap;
-
-
-/* Prototypes for local functions. */
-static size_t read_alias_file (const char *fname, int fname_len)
- internal_function;
-static int extend_alias_table (void);
-static int alias_compare (const struct alias_map *map1,
- const struct alias_map *map2);
-
-
-const char *
-_nl_expand_alias (const char *name)
-{
- static const char *locale_alias_path;
- struct alias_map *retval;
- const char *result = NULL;
- size_t added;
-
-#ifdef _LIBC
- __libc_lock_lock (lock);
-#endif
-
- if (locale_alias_path == NULL)
- locale_alias_path = LOCALE_ALIAS_PATH;
-
- do
- {
- struct alias_map item;
-
- item.alias = name;
-
- if (nmap > 0)
- retval = (struct alias_map *) bsearch (&item, map, nmap,
- sizeof (struct alias_map),
- (int (*) (const void *,
- const void *)
- ) alias_compare);
- else
- retval = NULL;
-
- /* We really found an alias. Return the value. */
- if (retval != NULL)
- {
- result = retval->value;
- break;
- }
-
- /* Perhaps we can find another alias file. */
- added = 0;
- while (added == 0 && locale_alias_path[0] != '\0')
- {
- const char *start;
-
- while (locale_alias_path[0] == PATH_SEPARATOR)
- ++locale_alias_path;
- start = locale_alias_path;
-
- while (locale_alias_path[0] != '\0'
- && locale_alias_path[0] != PATH_SEPARATOR)
- ++locale_alias_path;
-
- if (start < locale_alias_path)
- added = read_alias_file (start, locale_alias_path - start);
- }
- }
- while (added != 0);
-
-#ifdef _LIBC
- __libc_lock_unlock (lock);
-#endif
-
- return result;
-}
-
-
-static size_t
-internal_function
-read_alias_file (const char *fname, int fname_len)
-{
- FILE *fp;
- char *full_fname;
- size_t added;
- static const char aliasfile[] = "/locale.alias";
-
- full_fname = (char *) alloca (fname_len + sizeof aliasfile);
-#ifdef HAVE_MEMPCPY
- mempcpy (mempcpy (full_fname, fname, fname_len),
- aliasfile, sizeof aliasfile);
-#else
- memcpy (full_fname, fname, fname_len);
- memcpy (&full_fname[fname_len], aliasfile, sizeof aliasfile);
-#endif
-
- fp = fopen (relocate (full_fname), "r");
- freea (full_fname);
- if (fp == NULL)
- return 0;
-
-#ifdef HAVE___FSETLOCKING
- /* No threads present. */
- __fsetlocking (fp, FSETLOCKING_BYCALLER);
-#endif
-
- added = 0;
- while (!FEOF (fp))
- {
- /* It is a reasonable approach to use a fix buffer here because
- a) we are only interested in the first two fields
- b) these fields must be usable as file names and so must not
- be that long
- We avoid a multi-kilobyte buffer here since this would use up
- stack space which we might not have if the program ran out of
- memory. */
- char buf[400];
- char *alias;
- char *value;
- char *cp;
-
- if (FGETS (buf, sizeof buf, fp) == NULL)
- /* EOF reached. */
- break;
-
- cp = buf;
- /* Ignore leading white space. */
- while (isspace ((unsigned char) cp[0]))
- ++cp;
-
- /* A leading '#' signals a comment line. */
- if (cp[0] != '\0' && cp[0] != '#')
- {
- alias = cp++;
- while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
- ++cp;
- /* Terminate alias name. */
- if (cp[0] != '\0')
- *cp++ = '\0';
-
- /* Now look for the beginning of the value. */
- while (isspace ((unsigned char) cp[0]))
- ++cp;
-
- if (cp[0] != '\0')
- {
- size_t alias_len;
- size_t value_len;
-
- value = cp++;
- while (cp[0] != '\0' && !isspace ((unsigned char) cp[0]))
- ++cp;
- /* Terminate value. */
- if (cp[0] == '\n')
- {
- /* This has to be done to make the following test
- for the end of line possible. We are looking for
- the terminating '\n' which do not overwrite here. */
- *cp++ = '\0';
- *cp = '\n';
- }
- else if (cp[0] != '\0')
- *cp++ = '\0';
-
- if (nmap >= maxmap)
- if (__builtin_expect (extend_alias_table (), 0))
- return added;
-
- alias_len = strlen (alias) + 1;
- value_len = strlen (value) + 1;
-
- if (string_space_act + alias_len + value_len > string_space_max)
- {
- /* Increase size of memory pool. */
- size_t new_size = (string_space_max
- + (alias_len + value_len > 1024
- ? alias_len + value_len : 1024));
- char *new_pool = (char *) realloc (string_space, new_size);
- if (new_pool == NULL)
- return added;
-
- if (__builtin_expect (string_space != new_pool, 0))
- {
- size_t i;
-
- for (i = 0; i < nmap; i++)
- {
- map[i].alias += new_pool - string_space;
- map[i].value += new_pool - string_space;
- }
- }
-
- string_space = new_pool;
- string_space_max = new_size;
- }
-
- map[nmap].alias = memcpy (&string_space[string_space_act],
- alias, alias_len);
- string_space_act += alias_len;
-
- map[nmap].value = memcpy (&string_space[string_space_act],
- value, value_len);
- string_space_act += value_len;
-
- ++nmap;
- ++added;
- }
- }
-
- /* Possibly not the whole line fits into the buffer. Ignore
- the rest of the line. */
- while (strchr (buf, '\n') == NULL)
- if (FGETS (buf, sizeof buf, fp) == NULL)
- /* Make sure the inner loop will be left. The outer loop
- will exit at the `feof' test. */
- break;
- }
-
- /* Should we test for ferror()? I think we have to silently ignore
- errors. --drepper */
- fclose (fp);
-
- if (added > 0)
- qsort (map, nmap, sizeof (struct alias_map),
- (int (*) (const void *, const void *)) alias_compare);
-
- return added;
-}
-
-
-static int
-extend_alias_table ()
-{
- size_t new_size;
- struct alias_map *new_map;
-
- new_size = maxmap == 0 ? 100 : 2 * maxmap;
- new_map = (struct alias_map *) realloc (map, (new_size
- * sizeof (struct alias_map)));
- if (new_map == NULL)
- /* Simply don't extend: we don't have any more core. */
- return -1;
-
- map = new_map;
- maxmap = new_size;
- return 0;
-}
-
-
-static int
-alias_compare (const struct alias_map *map1, const struct alias_map *map2)
-{
-#if defined _LIBC || defined HAVE_STRCASECMP
- return strcasecmp (map1->alias, map2->alias);
-#else
- const unsigned char *p1 = (const unsigned char *) map1->alias;
- const unsigned char *p2 = (const unsigned char *) map2->alias;
- unsigned char c1, c2;
-
- if (p1 == p2)
- return 0;
-
- do
- {
- /* I know this seems to be odd but the tolower() function in
- some systems libc cannot handle nonalpha characters. */
- c1 = isupper (*p1) ? tolower (*p1) : *p1;
- c2 = isupper (*p2) ? tolower (*p2) : *p2;
- if (c1 == '\0')
- break;
- ++p1;
- ++p2;
- }
- while (c1 == c2);
-
- return c1 - c2;
-#endif
-}
diff --git a/navit/support/gettext_intl/localename.c b/navit/support/gettext_intl/localename.c
deleted file mode 100644
index 2706b0e46..000000000
--- a/navit/support/gettext_intl/localename.c
+++ /dev/null
@@ -1,1148 +0,0 @@
-/* Determine the current selected locale.
- Copyright (C) 1995-1999, 2000-2004 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* Written by Ulrich Drepper <drepper@gnu.org>, 1995. */
-/* Win32 code written by Tor Lillqvist <tml@iki.fi>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <locale.h>
-
-#if defined _WIN32 || defined __WIN32__
-# undef WIN32 /* avoid warning on mingw32 */
-# define WIN32
-#endif
-
-#ifdef WIN32
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-/* List of language codes, sorted by value:
- 0x01 LANG_ARABIC
- 0x02 LANG_BULGARIAN
- 0x03 LANG_CATALAN
- 0x04 LANG_CHINESE
- 0x05 LANG_CZECH
- 0x06 LANG_DANISH
- 0x07 LANG_GERMAN
- 0x08 LANG_GREEK
- 0x09 LANG_ENGLISH
- 0x0a LANG_SPANISH
- 0x0b LANG_FINNISH
- 0x0c LANG_FRENCH
- 0x0d LANG_HEBREW
- 0x0e LANG_HUNGARIAN
- 0x0f LANG_ICELANDIC
- 0x10 LANG_ITALIAN
- 0x11 LANG_JAPANESE
- 0x12 LANG_KOREAN
- 0x13 LANG_DUTCH
- 0x14 LANG_NORWEGIAN
- 0x15 LANG_POLISH
- 0x16 LANG_PORTUGUESE
- 0x17 LANG_RHAETO_ROMANCE
- 0x18 LANG_ROMANIAN
- 0x19 LANG_RUSSIAN
- 0x1a LANG_CROATIAN == LANG_SERBIAN
- 0x1b LANG_SLOVAK
- 0x1c LANG_ALBANIAN
- 0x1d LANG_SWEDISH
- 0x1e LANG_THAI
- 0x1f LANG_TURKISH
- 0x20 LANG_URDU
- 0x21 LANG_INDONESIAN
- 0x22 LANG_UKRAINIAN
- 0x23 LANG_BELARUSIAN
- 0x24 LANG_SLOVENIAN
- 0x25 LANG_ESTONIAN
- 0x26 LANG_LATVIAN
- 0x27 LANG_LITHUANIAN
- 0x28 LANG_TAJIK
- 0x29 LANG_FARSI
- 0x2a LANG_VIETNAMESE
- 0x2b LANG_ARMENIAN
- 0x2c LANG_AZERI
- 0x2d LANG_BASQUE
- 0x2e LANG_SORBIAN
- 0x2f LANG_MACEDONIAN
- 0x30 LANG_SUTU
- 0x31 LANG_TSONGA
- 0x32 LANG_TSWANA
- 0x33 LANG_VENDA
- 0x34 LANG_XHOSA
- 0x35 LANG_ZULU
- 0x36 LANG_AFRIKAANS
- 0x37 LANG_GEORGIAN
- 0x38 LANG_FAEROESE
- 0x39 LANG_HINDI
- 0x3a LANG_MALTESE
- 0x3b LANG_SAAMI
- 0x3c LANG_GAELIC
- 0x3d LANG_YIDDISH
- 0x3e LANG_MALAY
- 0x3f LANG_KAZAK
- 0x40 LANG_KYRGYZ
- 0x41 LANG_SWAHILI
- 0x42 LANG_TURKMEN
- 0x43 LANG_UZBEK
- 0x44 LANG_TATAR
- 0x45 LANG_BENGALI
- 0x46 LANG_PUNJABI
- 0x47 LANG_GUJARATI
- 0x48 LANG_ORIYA
- 0x49 LANG_TAMIL
- 0x4a LANG_TELUGU
- 0x4b LANG_KANNADA
- 0x4c LANG_MALAYALAM
- 0x4d LANG_ASSAMESE
- 0x4e LANG_MARATHI
- 0x4f LANG_SANSKRIT
- 0x50 LANG_MONGOLIAN
- 0x51 LANG_TIBETAN
- 0x52 LANG_WELSH
- 0x53 LANG_CAMBODIAN
- 0x54 LANG_LAO
- 0x55 LANG_BURMESE
- 0x56 LANG_GALICIAN
- 0x57 LANG_KONKANI
- 0x58 LANG_MANIPURI
- 0x59 LANG_SINDHI
- 0x5a LANG_SYRIAC
- 0x5b LANG_SINHALESE
- 0x5c LANG_CHEROKEE
- 0x5d LANG_INUKTITUT
- 0x5e LANG_AMHARIC
- 0x5f LANG_TAMAZIGHT
- 0x60 LANG_KASHMIRI
- 0x61 LANG_NEPALI
- 0x62 LANG_FRISIAN
- 0x63 LANG_PASHTO
- 0x64 LANG_TAGALOG
- 0x65 LANG_DIVEHI
- 0x66 LANG_EDO
- 0x67 LANG_FULFULDE
- 0x68 LANG_HAUSA
- 0x69 LANG_IBIBIO
- 0x6a LANG_YORUBA
- 0x70 LANG_IGBO
- 0x71 LANG_KANURI
- 0x72 LANG_OROMO
- 0x73 LANG_TIGRINYA
- 0x74 LANG_GUARANI
- 0x75 LANG_HAWAIIAN
- 0x76 LANG_LATIN
- 0x77 LANG_SOMALI
- 0x78 LANG_YI
- 0x79 LANG_PAPIAMENTU
-*/
-/* Mingw headers don't have latest language and sublanguage codes. */
-# ifndef LANG_AFRIKAANS
-# define LANG_AFRIKAANS 0x36
-# endif
-# ifndef LANG_ALBANIAN
-# define LANG_ALBANIAN 0x1c
-# endif
-# ifndef LANG_AMHARIC
-# define LANG_AMHARIC 0x5e
-# endif
-# ifndef LANG_ARABIC
-# define LANG_ARABIC 0x01
-# endif
-# ifndef LANG_ARMENIAN
-# define LANG_ARMENIAN 0x2b
-# endif
-# ifndef LANG_ASSAMESE
-# define LANG_ASSAMESE 0x4d
-# endif
-# ifndef LANG_AZERI
-# define LANG_AZERI 0x2c
-# endif
-# ifndef LANG_BASQUE
-# define LANG_BASQUE 0x2d
-# endif
-# ifndef LANG_BELARUSIAN
-# define LANG_BELARUSIAN 0x23
-# endif
-# ifndef LANG_BENGALI
-# define LANG_BENGALI 0x45
-# endif
-# ifndef LANG_BURMESE
-# define LANG_BURMESE 0x55
-# endif
-# ifndef LANG_CAMBODIAN
-# define LANG_CAMBODIAN 0x53
-# endif
-# ifndef LANG_CATALAN
-# define LANG_CATALAN 0x03
-# endif
-# ifndef LANG_CHEROKEE
-# define LANG_CHEROKEE 0x5c
-# endif
-# ifndef LANG_DIVEHI
-# define LANG_DIVEHI 0x65
-# endif
-# ifndef LANG_EDO
-# define LANG_EDO 0x66
-# endif
-# ifndef LANG_ESTONIAN
-# define LANG_ESTONIAN 0x25
-# endif
-# ifndef LANG_FAEROESE
-# define LANG_FAEROESE 0x38
-# endif
-# ifndef LANG_FARSI
-# define LANG_FARSI 0x29
-# endif
-# ifndef LANG_FRISIAN
-# define LANG_FRISIAN 0x62
-# endif
-# ifndef LANG_FULFULDE
-# define LANG_FULFULDE 0x67
-# endif
-# ifndef LANG_GAELIC
-# define LANG_GAELIC 0x3c
-# endif
-# ifndef LANG_GALICIAN
-# define LANG_GALICIAN 0x56
-# endif
-# ifndef LANG_GEORGIAN
-# define LANG_GEORGIAN 0x37
-# endif
-# ifndef LANG_GUARANI
-# define LANG_GUARANI 0x74
-# endif
-# ifndef LANG_GUJARATI
-# define LANG_GUJARATI 0x47
-# endif
-# ifndef LANG_HAUSA
-# define LANG_HAUSA 0x68
-# endif
-# ifndef LANG_HAWAIIAN
-# define LANG_HAWAIIAN 0x75
-# endif
-# ifndef LANG_HEBREW
-# define LANG_HEBREW 0x0d
-# endif
-# ifndef LANG_HINDI
-# define LANG_HINDI 0x39
-# endif
-# ifndef LANG_IBIBIO
-# define LANG_IBIBIO 0x69
-# endif
-# ifndef LANG_IGBO
-# define LANG_IGBO 0x70
-# endif
-# ifndef LANG_INDONESIAN
-# define LANG_INDONESIAN 0x21
-# endif
-# ifndef LANG_INUKTITUT
-# define LANG_INUKTITUT 0x5d
-# endif
-# ifndef LANG_KANNADA
-# define LANG_KANNADA 0x4b
-# endif
-# ifndef LANG_KANURI
-# define LANG_KANURI 0x71
-# endif
-# ifndef LANG_KASHMIRI
-# define LANG_KASHMIRI 0x60
-# endif
-# ifndef LANG_KAZAK
-# define LANG_KAZAK 0x3f
-# endif
-# ifndef LANG_KONKANI
-# define LANG_KONKANI 0x57
-# endif
-# ifndef LANG_KYRGYZ
-# define LANG_KYRGYZ 0x40
-# endif
-# ifndef LANG_LAO
-# define LANG_LAO 0x54
-# endif
-# ifndef LANG_LATIN
-# define LANG_LATIN 0x76
-# endif
-# ifndef LANG_LATVIAN
-# define LANG_LATVIAN 0x26
-# endif
-# ifndef LANG_LITHUANIAN
-# define LANG_LITHUANIAN 0x27
-# endif
-# ifndef LANG_MACEDONIAN
-# define LANG_MACEDONIAN 0x2f
-# endif
-# ifndef LANG_MALAY
-# define LANG_MALAY 0x3e
-# endif
-# ifndef LANG_MALAYALAM
-# define LANG_MALAYALAM 0x4c
-# endif
-# ifndef LANG_MALTESE
-# define LANG_MALTESE 0x3a
-# endif
-# ifndef LANG_MANIPURI
-# define LANG_MANIPURI 0x58
-# endif
-# ifndef LANG_MARATHI
-# define LANG_MARATHI 0x4e
-# endif
-# ifndef LANG_MONGOLIAN
-# define LANG_MONGOLIAN 0x50
-# endif
-# ifndef LANG_NEPALI
-# define LANG_NEPALI 0x61
-# endif
-# ifndef LANG_ORIYA
-# define LANG_ORIYA 0x48
-# endif
-# ifndef LANG_OROMO
-# define LANG_OROMO 0x72
-# endif
-# ifndef LANG_PAPIAMENTU
-# define LANG_PAPIAMENTU 0x79
-# endif
-# ifndef LANG_PASHTO
-# define LANG_PASHTO 0x63
-# endif
-# ifndef LANG_PUNJABI
-# define LANG_PUNJABI 0x46
-# endif
-# ifndef LANG_RHAETO_ROMANCE
-# define LANG_RHAETO_ROMANCE 0x17
-# endif
-# ifndef LANG_SAAMI
-# define LANG_SAAMI 0x3b
-# endif
-# ifndef LANG_SANSKRIT
-# define LANG_SANSKRIT 0x4f
-# endif
-# ifndef LANG_SERBIAN
-# define LANG_SERBIAN 0x1a
-# endif
-# ifndef LANG_SINDHI
-# define LANG_SINDHI 0x59
-# endif
-# ifndef LANG_SINHALESE
-# define LANG_SINHALESE 0x5b
-# endif
-# ifndef LANG_SLOVAK
-# define LANG_SLOVAK 0x1b
-# endif
-# ifndef LANG_SOMALI
-# define LANG_SOMALI 0x77
-# endif
-# ifndef LANG_SORBIAN
-# define LANG_SORBIAN 0x2e
-# endif
-# ifndef LANG_SUTU
-# define LANG_SUTU 0x30
-# endif
-# ifndef LANG_SWAHILI
-# define LANG_SWAHILI 0x41
-# endif
-# ifndef LANG_SYRIAC
-# define LANG_SYRIAC 0x5a
-# endif
-# ifndef LANG_TAGALOG
-# define LANG_TAGALOG 0x64
-# endif
-# ifndef LANG_TAJIK
-# define LANG_TAJIK 0x28
-# endif
-# ifndef LANG_TAMAZIGHT
-# define LANG_TAMAZIGHT 0x5f
-# endif
-# ifndef LANG_TAMIL
-# define LANG_TAMIL 0x49
-# endif
-# ifndef LANG_TATAR
-# define LANG_TATAR 0x44
-# endif
-# ifndef LANG_TELUGU
-# define LANG_TELUGU 0x4a
-# endif
-# ifndef LANG_THAI
-# define LANG_THAI 0x1e
-# endif
-# ifndef LANG_TIBETAN
-# define LANG_TIBETAN 0x51
-# endif
-# ifndef LANG_TIGRINYA
-# define LANG_TIGRINYA 0x73
-# endif
-# ifndef LANG_TSONGA
-# define LANG_TSONGA 0x31
-# endif
-# ifndef LANG_TSWANA
-# define LANG_TSWANA 0x32
-# endif
-# ifndef LANG_TURKMEN
-# define LANG_TURKMEN 0x42
-# endif
-# ifndef LANG_UKRAINIAN
-# define LANG_UKRAINIAN 0x22
-# endif
-# ifndef LANG_URDU
-# define LANG_URDU 0x20
-# endif
-# ifndef LANG_UZBEK
-# define LANG_UZBEK 0x43
-# endif
-# ifndef LANG_VENDA
-# define LANG_VENDA 0x33
-# endif
-# ifndef LANG_VIETNAMESE
-# define LANG_VIETNAMESE 0x2a
-# endif
-# ifndef LANG_WELSH
-# define LANG_WELSH 0x52
-# endif
-# ifndef LANG_XHOSA
-# define LANG_XHOSA 0x34
-# endif
-# ifndef LANG_YI
-# define LANG_YI 0x78
-# endif
-# ifndef LANG_YIDDISH
-# define LANG_YIDDISH 0x3d
-# endif
-# ifndef LANG_YORUBA
-# define LANG_YORUBA 0x6a
-# endif
-# ifndef LANG_ZULU
-# define LANG_ZULU 0x35
-# endif
-# ifndef SUBLANG_ARABIC_SAUDI_ARABIA
-# define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
-# endif
-# ifndef SUBLANG_ARABIC_IRAQ
-# define SUBLANG_ARABIC_IRAQ 0x02
-# endif
-# ifndef SUBLANG_ARABIC_EGYPT
-# define SUBLANG_ARABIC_EGYPT 0x03
-# endif
-# ifndef SUBLANG_ARABIC_LIBYA
-# define SUBLANG_ARABIC_LIBYA 0x04
-# endif
-# ifndef SUBLANG_ARABIC_ALGERIA
-# define SUBLANG_ARABIC_ALGERIA 0x05
-# endif
-# ifndef SUBLANG_ARABIC_MOROCCO
-# define SUBLANG_ARABIC_MOROCCO 0x06
-# endif
-# ifndef SUBLANG_ARABIC_TUNISIA
-# define SUBLANG_ARABIC_TUNISIA 0x07
-# endif
-# ifndef SUBLANG_ARABIC_OMAN
-# define SUBLANG_ARABIC_OMAN 0x08
-# endif
-# ifndef SUBLANG_ARABIC_YEMEN
-# define SUBLANG_ARABIC_YEMEN 0x09
-# endif
-# ifndef SUBLANG_ARABIC_SYRIA
-# define SUBLANG_ARABIC_SYRIA 0x0a
-# endif
-# ifndef SUBLANG_ARABIC_JORDAN
-# define SUBLANG_ARABIC_JORDAN 0x0b
-# endif
-# ifndef SUBLANG_ARABIC_LEBANON
-# define SUBLANG_ARABIC_LEBANON 0x0c
-# endif
-# ifndef SUBLANG_ARABIC_KUWAIT
-# define SUBLANG_ARABIC_KUWAIT 0x0d
-# endif
-# ifndef SUBLANG_ARABIC_UAE
-# define SUBLANG_ARABIC_UAE 0x0e
-# endif
-# ifndef SUBLANG_ARABIC_BAHRAIN
-# define SUBLANG_ARABIC_BAHRAIN 0x0f
-# endif
-# ifndef SUBLANG_ARABIC_QATAR
-# define SUBLANG_ARABIC_QATAR 0x10
-# endif
-# ifndef SUBLANG_AZERI_LATIN
-# define SUBLANG_AZERI_LATIN 0x01
-# endif
-# ifndef SUBLANG_AZERI_CYRILLIC
-# define SUBLANG_AZERI_CYRILLIC 0x02
-# endif
-# ifndef SUBLANG_BENGALI_INDIA
-# define SUBLANG_BENGALI_INDIA 0x00
-# endif
-# ifndef SUBLANG_BENGALI_BANGLADESH
-# define SUBLANG_BENGALI_BANGLADESH 0x01
-# endif
-# ifndef SUBLANG_CHINESE_MACAU
-# define SUBLANG_CHINESE_MACAU 0x05
-# endif
-# ifndef SUBLANG_ENGLISH_SOUTH_AFRICA
-# define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
-# endif
-# ifndef SUBLANG_ENGLISH_JAMAICA
-# define SUBLANG_ENGLISH_JAMAICA 0x08
-# endif
-# ifndef SUBLANG_ENGLISH_CARIBBEAN
-# define SUBLANG_ENGLISH_CARIBBEAN 0x09
-# endif
-# ifndef SUBLANG_ENGLISH_BELIZE
-# define SUBLANG_ENGLISH_BELIZE 0x0a
-# endif
-# ifndef SUBLANG_ENGLISH_TRINIDAD
-# define SUBLANG_ENGLISH_TRINIDAD 0x0b
-# endif
-# ifndef SUBLANG_ENGLISH_ZIMBABWE
-# define SUBLANG_ENGLISH_ZIMBABWE 0x0c
-# endif
-# ifndef SUBLANG_ENGLISH_PHILIPPINES
-# define SUBLANG_ENGLISH_PHILIPPINES 0x0d
-# endif
-# ifndef SUBLANG_ENGLISH_INDONESIA
-# define SUBLANG_ENGLISH_INDONESIA 0x0e
-# endif
-# ifndef SUBLANG_ENGLISH_HONGKONG
-# define SUBLANG_ENGLISH_HONGKONG 0x0f
-# endif
-# ifndef SUBLANG_ENGLISH_INDIA
-# define SUBLANG_ENGLISH_INDIA 0x10
-# endif
-# ifndef SUBLANG_ENGLISH_MALAYSIA
-# define SUBLANG_ENGLISH_MALAYSIA 0x11
-# endif
-# ifndef SUBLANG_ENGLISH_SINGAPORE
-# define SUBLANG_ENGLISH_SINGAPORE 0x12
-# endif
-# ifndef SUBLANG_FRENCH_LUXEMBOURG
-# define SUBLANG_FRENCH_LUXEMBOURG 0x05
-# endif
-# ifndef SUBLANG_FRENCH_MONACO
-# define SUBLANG_FRENCH_MONACO 0x06
-# endif
-# ifndef SUBLANG_FRENCH_WESTINDIES
-# define SUBLANG_FRENCH_WESTINDIES 0x07
-# endif
-# ifndef SUBLANG_FRENCH_REUNION
-# define SUBLANG_FRENCH_REUNION 0x08
-# endif
-# ifndef SUBLANG_FRENCH_CONGO
-# define SUBLANG_FRENCH_CONGO 0x09
-# endif
-# ifndef SUBLANG_FRENCH_SENEGAL
-# define SUBLANG_FRENCH_SENEGAL 0x0a
-# endif
-# ifndef SUBLANG_FRENCH_CAMEROON
-# define SUBLANG_FRENCH_CAMEROON 0x0b
-# endif
-# ifndef SUBLANG_FRENCH_COTEDIVOIRE
-# define SUBLANG_FRENCH_COTEDIVOIRE 0x0c
-# endif
-# ifndef SUBLANG_FRENCH_MALI
-# define SUBLANG_FRENCH_MALI 0x0d
-# endif
-# ifndef SUBLANG_FRENCH_MOROCCO
-# define SUBLANG_FRENCH_MOROCCO 0x0e
-# endif
-# ifndef SUBLANG_FRENCH_HAITI
-# define SUBLANG_FRENCH_HAITI 0x0f
-# endif
-# ifndef SUBLANG_GERMAN_LUXEMBOURG
-# define SUBLANG_GERMAN_LUXEMBOURG 0x04
-# endif
-# ifndef SUBLANG_GERMAN_LIECHTENSTEIN
-# define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
-# endif
-# ifndef SUBLANG_KASHMIRI_INDIA
-# define SUBLANG_KASHMIRI_INDIA 0x02
-# endif
-# ifndef SUBLANG_MALAY_MALAYSIA
-# define SUBLANG_MALAY_MALAYSIA 0x01
-# endif
-# ifndef SUBLANG_MALAY_BRUNEI_DARUSSALAM
-# define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
-# endif
-# ifndef SUBLANG_NEPALI_INDIA
-# define SUBLANG_NEPALI_INDIA 0x02
-# endif
-# ifndef SUBLANG_PUNJABI_INDIA
-# define SUBLANG_PUNJABI_INDIA 0x00
-# endif
-# ifndef SUBLANG_PUNJABI_PAKISTAN
-# define SUBLANG_PUNJABI_PAKISTAN 0x01
-# endif
-# ifndef SUBLANG_ROMANIAN_ROMANIA
-# define SUBLANG_ROMANIAN_ROMANIA 0x00
-# endif
-# ifndef SUBLANG_ROMANIAN_MOLDOVA
-# define SUBLANG_ROMANIAN_MOLDOVA 0x01
-# endif
-# ifndef SUBLANG_SERBIAN_LATIN
-# define SUBLANG_SERBIAN_LATIN 0x02
-# endif
-# ifndef SUBLANG_SERBIAN_CYRILLIC
-# define SUBLANG_SERBIAN_CYRILLIC 0x03
-# endif
-# ifndef SUBLANG_SINDHI_INDIA
-# define SUBLANG_SINDHI_INDIA 0x00
-# endif
-# ifndef SUBLANG_SINDHI_PAKISTAN
-# define SUBLANG_SINDHI_PAKISTAN 0x01
-# endif
-# ifndef SUBLANG_SPANISH_GUATEMALA
-# define SUBLANG_SPANISH_GUATEMALA 0x04
-# endif
-# ifndef SUBLANG_SPANISH_COSTA_RICA
-# define SUBLANG_SPANISH_COSTA_RICA 0x05
-# endif
-# ifndef SUBLANG_SPANISH_PANAMA
-# define SUBLANG_SPANISH_PANAMA 0x06
-# endif
-# ifndef SUBLANG_SPANISH_DOMINICAN_REPUBLIC
-# define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
-# endif
-# ifndef SUBLANG_SPANISH_VENEZUELA
-# define SUBLANG_SPANISH_VENEZUELA 0x08
-# endif
-# ifndef SUBLANG_SPANISH_COLOMBIA
-# define SUBLANG_SPANISH_COLOMBIA 0x09
-# endif
-# ifndef SUBLANG_SPANISH_PERU
-# define SUBLANG_SPANISH_PERU 0x0a
-# endif
-# ifndef SUBLANG_SPANISH_ARGENTINA
-# define SUBLANG_SPANISH_ARGENTINA 0x0b
-# endif
-# ifndef SUBLANG_SPANISH_ECUADOR
-# define SUBLANG_SPANISH_ECUADOR 0x0c
-# endif
-# ifndef SUBLANG_SPANISH_CHILE
-# define SUBLANG_SPANISH_CHILE 0x0d
-# endif
-# ifndef SUBLANG_SPANISH_URUGUAY
-# define SUBLANG_SPANISH_URUGUAY 0x0e
-# endif
-# ifndef SUBLANG_SPANISH_PARAGUAY
-# define SUBLANG_SPANISH_PARAGUAY 0x0f
-# endif
-# ifndef SUBLANG_SPANISH_BOLIVIA
-# define SUBLANG_SPANISH_BOLIVIA 0x10
-# endif
-# ifndef SUBLANG_SPANISH_EL_SALVADOR
-# define SUBLANG_SPANISH_EL_SALVADOR 0x11
-# endif
-# ifndef SUBLANG_SPANISH_HONDURAS
-# define SUBLANG_SPANISH_HONDURAS 0x12
-# endif
-# ifndef SUBLANG_SPANISH_NICARAGUA
-# define SUBLANG_SPANISH_NICARAGUA 0x13
-# endif
-# ifndef SUBLANG_SPANISH_PUERTO_RICO
-# define SUBLANG_SPANISH_PUERTO_RICO 0x14
-# endif
-# ifndef SUBLANG_SWEDISH_FINLAND
-# define SUBLANG_SWEDISH_FINLAND 0x02
-# endif
-# ifndef SUBLANG_TAMAZIGHT_ARABIC
-# define SUBLANG_TAMAZIGHT_ARABIC 0x01
-# endif
-# ifndef SUBLANG_TAMAZIGHT_LATIN
-# define SUBLANG_TAMAZIGHT_LATIN 0x02
-# endif
-# ifndef SUBLANG_TIGRINYA_ETHIOPIA
-# define SUBLANG_TIGRINYA_ETHIOPIA 0x00
-# endif
-# ifndef SUBLANG_TIGRINYA_ERITREA
-# define SUBLANG_TIGRINYA_ERITREA 0x01
-# endif
-# ifndef SUBLANG_URDU_PAKISTAN
-# define SUBLANG_URDU_PAKISTAN 0x01
-# endif
-# ifndef SUBLANG_URDU_INDIA
-# define SUBLANG_URDU_INDIA 0x02
-# endif
-# ifndef SUBLANG_UZBEK_LATIN
-# define SUBLANG_UZBEK_LATIN 0x01
-# endif
-# ifndef SUBLANG_UZBEK_CYRILLIC
-# define SUBLANG_UZBEK_CYRILLIC 0x02
-# endif
-#endif
-
-/* XPG3 defines the result of 'setlocale (category, NULL)' as:
- "Directs 'setlocale()' to query 'category' and return the current
- setting of 'local'."
- However it does not specify the exact format. Neither do SUSV2 and
- ISO C 99. So we can use this feature only on selected systems (e.g.
- those using GNU C Library). */
-#if defined _LIBC || (defined __GNU_LIBRARY__ && __GNU_LIBRARY__ >= 2)
-# define HAVE_LOCALE_NULL
-#endif
-
-/* Determine the current locale's name, and canonicalize it into XPG syntax
- language[_territory[.codeset]][@modifier]
- The codeset part in the result is not reliable; the locale_charset()
- should be used for codeset information instead.
- The result must not be freed; it is statically allocated. */
-
-const char *
-_nl_locale_name (int category, const char *categoryname)
-{
- const char *retval;
-
-#ifndef WIN32
-
- /* Use the POSIX methods of looking to 'LC_ALL', 'LC_xxx', and 'LANG'.
- On some systems this can be done by the 'setlocale' function itself. */
-# if defined HAVE_SETLOCALE && defined HAVE_LC_MESSAGES && defined HAVE_LOCALE_NULL
- retval = setlocale (category, NULL);
-# else
- /* Setting of LC_ALL overwrites all other. */
- retval = getenv ("LC_ALL");
- if (retval == NULL || retval[0] == '\0')
- {
- /* Next comes the name of the desired category. */
- retval = getenv (categoryname);
- if (retval == NULL || retval[0] == '\0')
- {
- /* Last possibility is the LANG environment variable. */
- retval = getenv ("LANG");
- if (retval == NULL || retval[0] == '\0')
- /* We use C as the default domain. POSIX says this is
- implementation defined. */
- retval = "C";
- }
- }
-# endif
-
- return retval;
-
-#else /* WIN32 */
-
- /* Return an XPG style locale name language[_territory][@modifier].
- Don't even bother determining the codeset; it's not useful in this
- context, because message catalogs are not specific to a single
- codeset. */
-
- LCID lcid;
- LANGID langid;
- int primary, sub;
-
- /* Let the user override the system settings through environment
- variables, as on POSIX systems. */
- retval = getenv ("LC_ALL");
- if (retval != NULL && retval[0] != '\0')
- return retval;
- retval = getenv (categoryname);
- if (retval != NULL && retval[0] != '\0')
- return retval;
- retval = getenv ("LANG");
- if (retval != NULL && retval[0] != '\0')
- return retval;
-
- /* Use native Win32 API locale ID. */
- lcid = GetThreadLocale ();
-
- /* Strip off the sorting rules, keep only the language part. */
- langid = LANGIDFROMLCID (lcid);
-
- /* Split into language and territory part. */
- primary = PRIMARYLANGID (langid);
- sub = SUBLANGID (langid);
-
- /* Dispatch on language.
- See also http://www.unicode.org/unicode/onlinedat/languages.html .
- For details about languages, see http://www.ethnologue.com/ . */
- switch (primary)
- {
- case LANG_AFRIKAANS: return "af_ZA";
- case LANG_ALBANIAN: return "sq_AL";
- case LANG_AMHARIC: return "am_ET";
- case LANG_ARABIC:
- switch (sub)
- {
- case SUBLANG_ARABIC_SAUDI_ARABIA: return "ar_SA";
- case SUBLANG_ARABIC_IRAQ: return "ar_IQ";
- case SUBLANG_ARABIC_EGYPT: return "ar_EG";
- case SUBLANG_ARABIC_LIBYA: return "ar_LY";
- case SUBLANG_ARABIC_ALGERIA: return "ar_DZ";
- case SUBLANG_ARABIC_MOROCCO: return "ar_MA";
- case SUBLANG_ARABIC_TUNISIA: return "ar_TN";
- case SUBLANG_ARABIC_OMAN: return "ar_OM";
- case SUBLANG_ARABIC_YEMEN: return "ar_YE";
- case SUBLANG_ARABIC_SYRIA: return "ar_SY";
- case SUBLANG_ARABIC_JORDAN: return "ar_JO";
- case SUBLANG_ARABIC_LEBANON: return "ar_LB";
- case SUBLANG_ARABIC_KUWAIT: return "ar_KW";
- case SUBLANG_ARABIC_UAE: return "ar_AE";
- case SUBLANG_ARABIC_BAHRAIN: return "ar_BH";
- case SUBLANG_ARABIC_QATAR: return "ar_QA";
- }
- return "ar";
- case LANG_ARMENIAN: return "hy_AM";
- case LANG_ASSAMESE: return "as_IN";
- case LANG_AZERI:
- switch (sub)
- {
- /* FIXME: Adjust this when Azerbaijani locales appear on Unix. */
- case SUBLANG_AZERI_LATIN: return "az_AZ@latin";
- case SUBLANG_AZERI_CYRILLIC: return "az_AZ@cyrillic";
- }
- return "az";
- case LANG_BASQUE:
- return "eu"; /* Ambiguous: could be "eu_ES" or "eu_FR". */
- case LANG_BELARUSIAN: return "be_BY";
- case LANG_BENGALI:
- switch (sub)
- {
- case SUBLANG_BENGALI_INDIA: return "bn_IN";
-#if 0 /* FIXME */
- case SUBLANG_BENGALI_BANGLADESH: return "bn_BD";
-#endif
- }
- return "bn";
- case LANG_BULGARIAN: return "bg_BG";
- case LANG_BURMESE: return "my_MM";
- case LANG_CAMBODIAN: return "km_KH";
- case LANG_CATALAN: return "ca_ES";
- case LANG_CHEROKEE: return "chr_US";
- case LANG_CHINESE:
- switch (sub)
- {
- case SUBLANG_CHINESE_TRADITIONAL: return "zh_TW";
- case SUBLANG_CHINESE_SIMPLIFIED: return "zh_CN";
- case SUBLANG_CHINESE_HONGKONG: return "zh_HK";
- case SUBLANG_CHINESE_SINGAPORE: return "zh_SG";
- case SUBLANG_CHINESE_MACAU: return "zh_MO";
- }
- return "zh";
- case LANG_CROATIAN: /* LANG_CROATIAN == LANG_SERBIAN
- * What used to be called Serbo-Croatian
- * should really now be two separate
- * languages because of political reasons.
- * (Says tml, who knows nothing about Serbian
- * or Croatian.)
- * (I can feel those flames coming already.)
- */
- switch (sub)
- {
- case SUBLANG_DEFAULT: return "hr_HR";
- case SUBLANG_SERBIAN_LATIN: return "sr_CS";
- case SUBLANG_SERBIAN_CYRILLIC: return "sr_CS@cyrillic";
- }
- return "hr";
- case LANG_CZECH: return "cs_CZ";
- case LANG_DANISH: return "da_DK";
- case LANG_DIVEHI: return "dv_MV";
- case LANG_DUTCH:
- switch (sub)
- {
- case SUBLANG_DUTCH: return "nl_NL";
- case SUBLANG_DUTCH_BELGIAN: /* FLEMISH, VLAAMS */ return "nl_BE";
- }
- return "nl";
- case LANG_EDO: return "bin_NG";
- case LANG_ENGLISH:
- switch (sub)
- {
- /* SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. Heh. I thought
- * English was the language spoken in England.
- * Oh well.
- */
- case SUBLANG_ENGLISH_US: return "en_US";
- case SUBLANG_ENGLISH_UK: return "en_GB";
- case SUBLANG_ENGLISH_AUS: return "en_AU";
- case SUBLANG_ENGLISH_CAN: return "en_CA";
- case SUBLANG_ENGLISH_NZ: return "en_NZ";
- case SUBLANG_ENGLISH_EIRE: return "en_IE";
- case SUBLANG_ENGLISH_SOUTH_AFRICA: return "en_ZA";
- case SUBLANG_ENGLISH_JAMAICA: return "en_JM";
- case SUBLANG_ENGLISH_CARIBBEAN: return "en_GD"; /* Grenada? */
- case SUBLANG_ENGLISH_BELIZE: return "en_BZ";
- case SUBLANG_ENGLISH_TRINIDAD: return "en_TT";
- case SUBLANG_ENGLISH_ZIMBABWE: return "en_ZW";
- case SUBLANG_ENGLISH_PHILIPPINES: return "en_PH";
- case SUBLANG_ENGLISH_INDONESIA: return "en_ID";
- case SUBLANG_ENGLISH_HONGKONG: return "en_HK";
- case SUBLANG_ENGLISH_INDIA: return "en_IN";
- case SUBLANG_ENGLISH_MALAYSIA: return "en_MY";
- case SUBLANG_ENGLISH_SINGAPORE: return "en_SG";
- }
- return "en";
- case LANG_ESTONIAN: return "et_EE";
- case LANG_FAEROESE: return "fo_FO";
- case LANG_FARSI: return "fa_IR";
- case LANG_FINNISH: return "fi_FI";
- case LANG_FRENCH:
- switch (sub)
- {
- case SUBLANG_FRENCH: return "fr_FR";
- case SUBLANG_FRENCH_BELGIAN: /* WALLOON */ return "fr_BE";
- case SUBLANG_FRENCH_CANADIAN: return "fr_CA";
- case SUBLANG_FRENCH_SWISS: return "fr_CH";
- case SUBLANG_FRENCH_LUXEMBOURG: return "fr_LU";
- case SUBLANG_FRENCH_MONACO: return "fr_MC";
- case SUBLANG_FRENCH_WESTINDIES: return "fr"; /* Caribbean? */
- case SUBLANG_FRENCH_REUNION: return "fr_RE";
- case SUBLANG_FRENCH_CONGO: return "fr_CG";
- case SUBLANG_FRENCH_SENEGAL: return "fr_SN";
- case SUBLANG_FRENCH_CAMEROON: return "fr_CM";
- case SUBLANG_FRENCH_COTEDIVOIRE: return "fr_CI";
- case SUBLANG_FRENCH_MALI: return "fr_ML";
- case SUBLANG_FRENCH_MOROCCO: return "fr_MA";
- case SUBLANG_FRENCH_HAITI: return "fr_HT";
- }
- return "fr";
- case LANG_FRISIAN: return "fy_NL";
- case LANG_FULFULDE:
- /* Spoken in Nigeria, Guinea, Senegal, Mali, Niger, Cameroon, Benin. */
- return "ff_NG";
- case LANG_GAELIC:
- switch (sub)
- {
- case 0x01: /* SCOTTISH */ return "gd_GB";
- case 0x02: /* IRISH */ return "ga_IE";
- }
- return "C";
- case LANG_GALICIAN: return "gl_ES";
- case LANG_GEORGIAN: return "ka_GE";
- case LANG_GERMAN:
- switch (sub)
- {
- case SUBLANG_GERMAN: return "de_DE";
- case SUBLANG_GERMAN_SWISS: return "de_CH";
- case SUBLANG_GERMAN_AUSTRIAN: return "de_AT";
- case SUBLANG_GERMAN_LUXEMBOURG: return "de_LU";
- case SUBLANG_GERMAN_LIECHTENSTEIN: return "de_LI";
- }
- return "de";
- case LANG_GREEK: return "el_GR";
- case LANG_GUARANI: return "gn_PY";
- case LANG_GUJARATI: return "gu_IN";
- case LANG_HAUSA: return "ha_NG";
- case LANG_HAWAIIAN:
- /* FIXME: Do they mean Hawaiian ("haw_US", 1000 speakers)
- or Hawaii Creole English ("cpe_US", 600000 speakers)? */
- return "cpe_US";
- case LANG_HEBREW: return "he_IL";
- case LANG_HINDI: return "hi_IN";
- case LANG_HUNGARIAN: return "hu_HU";
- case LANG_IBIBIO: return "nic_NG";
- case LANG_ICELANDIC: return "is_IS";
- case LANG_IGBO: return "ig_NG";
- case LANG_INDONESIAN: return "id_ID";
- case LANG_INUKTITUT: return "iu_CA";
- case LANG_ITALIAN:
- switch (sub)
- {
- case SUBLANG_ITALIAN: return "it_IT";
- case SUBLANG_ITALIAN_SWISS: return "it_CH";
- }
- return "it";
- case LANG_JAPANESE: return "ja_JP";
- case LANG_KANNADA: return "kn_IN";
- case LANG_KANURI: return "kr_NG";
- case LANG_KASHMIRI:
- switch (sub)
- {
- case SUBLANG_DEFAULT: return "ks_PK";
- case SUBLANG_KASHMIRI_INDIA: return "ks_IN";
- }
- return "ks";
- case LANG_KAZAK: return "kk_KZ";
- case LANG_KONKANI:
- /* FIXME: Adjust this when such locales appear on Unix. */
- return "kok_IN";
- case LANG_KOREAN: return "ko_KR";
- case LANG_KYRGYZ: return "ky_KG";
- case LANG_LAO: return "lo_LA";
- case LANG_LATIN: return "la_VA";
- case LANG_LATVIAN: return "lv_LV";
- case LANG_LITHUANIAN: return "lt_LT";
- case LANG_MACEDONIAN: return "mk_MK";
- case LANG_MALAY:
- switch (sub)
- {
- case SUBLANG_MALAY_MALAYSIA: return "ms_MY";
- case SUBLANG_MALAY_BRUNEI_DARUSSALAM: return "ms_BN";
- }
- return "ms";
- case LANG_MALAYALAM: return "ml_IN";
- case LANG_MALTESE: return "mt_MT";
- case LANG_MANIPURI:
- /* FIXME: Adjust this when such locales appear on Unix. */
- return "mni_IN";
- case LANG_MARATHI: return "mr_IN";
- case LANG_MONGOLIAN:
- return "mn"; /* Ambiguous: could be "mn_CN" or "mn_MN". */
- case LANG_NEPALI:
- switch (sub)
- {
- case SUBLANG_DEFAULT: return "ne_NP";
- case SUBLANG_NEPALI_INDIA: return "ne_IN";
- }
- return "ne";
- case LANG_NORWEGIAN:
- switch (sub)
- {
- case SUBLANG_NORWEGIAN_BOKMAL: return "no_NO";
- case SUBLANG_NORWEGIAN_NYNORSK: return "nn_NO";
- }
- return "no";
- case LANG_ORIYA: return "or_IN";
- case LANG_OROMO: return "om_ET";
- case LANG_PAPIAMENTU: return "pap_AN";
- case LANG_PASHTO:
- return "ps"; /* Ambiguous: could be "ps_PK" or "ps_AF". */
- case LANG_POLISH: return "pl_PL";
- case LANG_PORTUGUESE:
- switch (sub)
- {
- case SUBLANG_PORTUGUESE: return "pt_PT";
- /* Hmm. SUBLANG_PORTUGUESE_BRAZILIAN == SUBLANG_DEFAULT.
- Same phenomenon as SUBLANG_ENGLISH_US == SUBLANG_DEFAULT. */
- case SUBLANG_PORTUGUESE_BRAZILIAN: return "pt_BR";
- }
- return "pt";
- case LANG_PUNJABI:
- switch (sub)
- {
- case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */
-#if 0 /* FIXME */
- case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */
-#endif
- }
- return "pa";
- case LANG_RHAETO_ROMANCE: return "rm_CH";
- case LANG_ROMANIAN:
- switch (sub)
- {
- case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO";
-#if 0 /* FIXME */
- case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD";
-#endif
- }
- return "ro";
- case LANG_RUSSIAN:
- return "ru"; /* Ambiguous: could be "ru_RU" or "ru_UA" or "ru_MD". */
- case LANG_SAAMI: /* actually Northern Sami */ return "se_NO";
- case LANG_SANSKRIT: return "sa_IN";
- case LANG_SINDHI:
- switch (sub)
- {
- case SUBLANG_SINDHI_INDIA: return "sd_IN";
- case SUBLANG_SINDHI_PAKISTAN: return "sd_PK";
- }
- return "sd";
- case LANG_SINHALESE: return "si_LK";
- case LANG_SLOVAK: return "sk_SK";
- case LANG_SLOVENIAN: return "sl_SI";
- case LANG_SOMALI: return "so_SO";
- case LANG_SORBIAN:
- /* FIXME: Adjust this when such locales appear on Unix. */
- return "wen_DE";
- case LANG_SPANISH:
- switch (sub)
- {
- case SUBLANG_SPANISH: return "es_ES";
- case SUBLANG_SPANISH_MEXICAN: return "es_MX";
- case SUBLANG_SPANISH_MODERN:
- return "es_ES@modern"; /* not seen on Unix */
- case SUBLANG_SPANISH_GUATEMALA: return "es_GT";
- case SUBLANG_SPANISH_COSTA_RICA: return "es_CR";
- case SUBLANG_SPANISH_PANAMA: return "es_PA";
- case SUBLANG_SPANISH_DOMINICAN_REPUBLIC: return "es_DO";
- case SUBLANG_SPANISH_VENEZUELA: return "es_VE";
- case SUBLANG_SPANISH_COLOMBIA: return "es_CO";
- case SUBLANG_SPANISH_PERU: return "es_PE";
- case SUBLANG_SPANISH_ARGENTINA: return "es_AR";
- case SUBLANG_SPANISH_ECUADOR: return "es_EC";
- case SUBLANG_SPANISH_CHILE: return "es_CL";
- case SUBLANG_SPANISH_URUGUAY: return "es_UY";
- case SUBLANG_SPANISH_PARAGUAY: return "es_PY";
- case SUBLANG_SPANISH_BOLIVIA: return "es_BO";
- case SUBLANG_SPANISH_EL_SALVADOR: return "es_SV";
- case SUBLANG_SPANISH_HONDURAS: return "es_HN";
- case SUBLANG_SPANISH_NICARAGUA: return "es_NI";
- case SUBLANG_SPANISH_PUERTO_RICO: return "es_PR";
- }
- return "es";
- case LANG_SUTU: return "bnt_TZ"; /* or "st_LS" or "nso_ZA"? */
- case LANG_SWAHILI: return "sw_KE";
- case LANG_SWEDISH:
- switch (sub)
- {
- case SUBLANG_DEFAULT: return "sv_SE";
- case SUBLANG_SWEDISH_FINLAND: return "sv_FI";
- }
- return "sv";
- case LANG_SYRIAC: return "syr_TR"; /* An extinct language. */
- case LANG_TAGALOG: return "tl_PH";
- case LANG_TAJIK: return "tg_TJ";
- case LANG_TAMAZIGHT:
- switch (sub)
- {
- /* FIXME: Adjust this when Tamazight locales appear on Unix. */
- case SUBLANG_TAMAZIGHT_ARABIC: return "ber_MA@arabic";
- case SUBLANG_TAMAZIGHT_LATIN: return "ber_MA@latin";
- }
- return "ber_MA";
- case LANG_TAMIL:
- return "ta"; /* Ambiguous: could be "ta_IN" or "ta_LK" or "ta_SG". */
- case LANG_TATAR: return "tt_RU";
- case LANG_TELUGU: return "te_IN";
- case LANG_THAI: return "th_TH";
- case LANG_TIBETAN: return "bo_CN";
- case LANG_TIGRINYA:
- switch (sub)
- {
- case SUBLANG_TIGRINYA_ETHIOPIA: return "ti_ET";
- case SUBLANG_TIGRINYA_ERITREA: return "ti_ER";
- }
- return "ti";
- case LANG_TSONGA: return "ts_ZA";
- case LANG_TSWANA: return "tn_BW";
- case LANG_TURKISH: return "tr_TR";
- case LANG_TURKMEN: return "tk_TM";
- case LANG_UKRAINIAN: return "uk_UA";
- case LANG_URDU:
- switch (sub)
- {
- case SUBLANG_URDU_PAKISTAN: return "ur_PK";
- case SUBLANG_URDU_INDIA: return "ur_IN";
- }
- return "ur";
- case LANG_UZBEK:
- switch (sub)
- {
- case SUBLANG_UZBEK_LATIN: return "uz_UZ";
- case SUBLANG_UZBEK_CYRILLIC: return "uz_UZ@cyrillic";
- }
- return "uz";
- case LANG_VENDA: return "ve_ZA";
- case LANG_VIETNAMESE: return "vi_VN";
- case LANG_WELSH: return "cy_GB";
- case LANG_XHOSA: return "xh_ZA";
- case LANG_YI: return "sit_CN";
- case LANG_YIDDISH: return "yi_IL";
- case LANG_YORUBA: return "yo_NG";
- case LANG_ZULU: return "zu_ZA";
- default: return "C";
- }
-
-#endif
-}
diff --git a/navit/support/gettext_intl/log.c b/navit/support/gettext_intl/log.c
deleted file mode 100644
index cb6076e80..000000000
--- a/navit/support/gettext_intl/log.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Log file output.
- Copyright (C) 2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* Written by Bruno Haible <bruno@clisp.org>. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* Print an ASCII string with quotes and escape sequences where needed. */
-static void
-print_escaped (FILE *stream, const char *str)
-{
- putc ('"', stream);
- for (; *str != '\0'; str++)
- if (*str == '\n')
- {
- fputs ("\\n\"", stream);
- if (str[1] == '\0')
- return;
- fputs ("\n\"", stream);
- }
- else
- {
- if (*str == '"' || *str == '\\')
- putc ('\\', stream);
- putc (*str, stream);
- }
- putc ('"', stream);
-}
-
-/* Add to the log file an entry denoting a failed translation. */
-void
-_nl_log_untranslated (const char *logfilename, const char *domainname,
- const char *msgid1, const char *msgid2, int plural)
-{
- static char *last_logfilename = NULL;
- static FILE *last_logfile = NULL;
- FILE *logfile;
-
- /* Can we reuse the last opened logfile? */
- if (last_logfilename == NULL || strcmp (logfilename, last_logfilename) != 0)
- {
- /* Close the last used logfile. */
- if (last_logfilename != NULL)
- {
- if (last_logfile != NULL)
- {
- fclose (last_logfile);
- last_logfile = NULL;
- }
- free (last_logfilename);
- last_logfilename = NULL;
- }
- /* Open the logfile. */
- last_logfilename = (char *) malloc (strlen (logfilename) + 1);
- if (last_logfilename == NULL)
- return;
- strcpy (last_logfilename, logfilename);
- last_logfile = fopen (logfilename, "a");
- if (last_logfile == NULL)
- return;
- }
- logfile = last_logfile;
-
- fprintf (logfile, "domain ");
- print_escaped (logfile, domainname);
- fprintf (logfile, "\nmsgid ");
- print_escaped (logfile, msgid1);
- if (plural)
- {
- fprintf (logfile, "\nmsgid_plural ");
- print_escaped (logfile, msgid2);
- fprintf (logfile, "\nmsgstr[0] \"\"\n");
- }
- else
- fprintf (logfile, "\nmsgstr \"\"\n");
- putc ('\n', logfile);
-}
diff --git a/navit/support/gettext_intl/ngettext.c b/navit/support/gettext_intl/ngettext.c
deleted file mode 100644
index e73e00c48..000000000
--- a/navit/support/gettext_intl/ngettext.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/* Implementation of ngettext(3) function.
- Copyright (C) 1995, 1997, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#ifdef _LIBC
-# define __need_NULL
-# include <stddef.h>
-#else
-# include <stdlib.h> /* Just for NULL. */
-#endif
-
-#include "gettextP.h"
-#ifdef _LIBC
-# include <libintl.h>
-#else
-# include "libgnuintl.h"
-#endif
-
-#include <locale.h>
-
-/* @@ end of prolog @@ */
-
-/* Names for the libintl functions are a problem. They must not clash
- with existing names and they should follow ANSI C. But this source
- code is also used in GNU C Library where the names have a __
- prefix. So we have to make a difference here. */
-#ifdef _LIBC
-# define NGETTEXT __ngettext
-# define DCNGETTEXT __dcngettext
-#else
-# define NGETTEXT libintl_ngettext
-# define DCNGETTEXT libintl_dcngettext
-#endif
-
-/* Look up MSGID in the current default message catalog for the current
- LC_MESSAGES locale. If not found, returns MSGID itself (the default
- text). */
-char *
-NGETTEXT (const char *msgid1, const char *msgid2, unsigned long int n)
-{
- return DCNGETTEXT (NULL, msgid1, msgid2, n, LC_MESSAGES);
-}
-
-#ifdef _LIBC
-/* Alias for function name in GNU C Library. */
-weak_alias (__ngettext, ngettext);
-#endif
diff --git a/navit/support/gettext_intl/os2compat.c b/navit/support/gettext_intl/os2compat.c
deleted file mode 100644
index c8dc33e7c..000000000
--- a/navit/support/gettext_intl/os2compat.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* OS/2 compatibility functions.
- Copyright (C) 2001-2002 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#define OS2_AWARE
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-#include <sys/param.h>
-
-/* A version of getenv() that works from DLLs */
-extern unsigned long DosScanEnv (const unsigned char *pszName, unsigned char **ppszValue);
-
-char *
-_nl_getenv (const char *name)
-{
- unsigned char *value;
- if (DosScanEnv (name, &value))
- return NULL;
- else
- return value;
-}
-
-/* A fixed size buffer. */
-char libintl_nl_default_dirname[MAXPATHLEN+1];
-
-char *_nlos2_libdir = NULL;
-char *_nlos2_localealiaspath = NULL;
-char *_nlos2_localedir = NULL;
-
-static __attribute__((constructor)) void
-nlos2_initialize ()
-{
- char *root = getenv ("UNIXROOT");
- char *gnulocaledir = getenv ("GNULOCALEDIR");
-
- _nlos2_libdir = gnulocaledir;
- if (!_nlos2_libdir)
- {
- if (root)
- {
- size_t sl = strlen (root);
- _nlos2_libdir = (char *) malloc (sl + strlen (LIBDIR) + 1);
- memcpy (_nlos2_libdir, root, sl);
- memcpy (_nlos2_libdir + sl, LIBDIR, strlen (LIBDIR) + 1);
- }
- else
- _nlos2_libdir = LIBDIR;
- }
-
- _nlos2_localealiaspath = gnulocaledir;
- if (!_nlos2_localealiaspath)
- {
- if (root)
- {
- size_t sl = strlen (root);
- _nlos2_localealiaspath = (char *) malloc (sl + strlen (LOCALE_ALIAS_PATH) + 1);
- memcpy (_nlos2_localealiaspath, root, sl);
- memcpy (_nlos2_localealiaspath + sl, LOCALE_ALIAS_PATH, strlen (LOCALE_ALIAS_PATH) + 1);
- }
- else
- _nlos2_localealiaspath = LOCALE_ALIAS_PATH;
- }
-
- _nlos2_localedir = gnulocaledir;
- if (!_nlos2_localedir)
- {
- if (root)
- {
- size_t sl = strlen (root);
- _nlos2_localedir = (char *) malloc (sl + strlen (LOCALEDIR) + 1);
- memcpy (_nlos2_localedir, root, sl);
- memcpy (_nlos2_localedir + sl, LOCALEDIR, strlen (LOCALEDIR) + 1);
- }
- else
- _nlos2_localedir = LOCALEDIR;
- }
-
- if (strlen (_nlos2_localedir) <= MAXPATHLEN)
- strcpy (libintl_nl_default_dirname, _nlos2_localedir);
-}
diff --git a/navit/support/gettext_intl/os2compat.h b/navit/support/gettext_intl/os2compat.h
deleted file mode 100644
index 4f74e8c03..000000000
--- a/navit/support/gettext_intl/os2compat.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* OS/2 compatibility defines.
- This file is intended to be included from config.h
- Copyright (C) 2001-2002 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* When included from os2compat.h we need all the original definitions */
-#ifndef OS2_AWARE
-
-#undef LIBDIR
-#define LIBDIR _nlos2_libdir
-extern char *_nlos2_libdir;
-
-#undef LOCALEDIR
-#define LOCALEDIR _nlos2_localedir
-extern char *_nlos2_localedir;
-
-#undef LOCALE_ALIAS_PATH
-#define LOCALE_ALIAS_PATH _nlos2_localealiaspath
-extern char *_nlos2_localealiaspath;
-
-#endif
-
-#undef HAVE_STRCASECMP
-#define HAVE_STRCASECMP 1
-#define strcasecmp stricmp
-#define strncasecmp strnicmp
-
-/* We have our own getenv() which works even if library is compiled as DLL */
-#define getenv _nl_getenv
-
-/* Older versions of gettext used -1 as the value of LC_MESSAGES */
-#define LC_MESSAGES_COMPAT (-1)
diff --git a/navit/support/gettext_intl/osdep.c b/navit/support/gettext_intl/osdep.c
deleted file mode 100644
index b37259838..000000000
--- a/navit/support/gettext_intl/osdep.c
+++ /dev/null
@@ -1,24 +0,0 @@
-/* OS dependent parts of libintl.
- Copyright (C) 2001-2002 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#if defined __EMX__
-# include "os2compat.c"
-#else
-/* Avoid AIX compiler warning. */
-typedef int dummy;
-#endif
diff --git a/navit/support/gettext_intl/plural-exp.c b/navit/support/gettext_intl/plural-exp.c
deleted file mode 100644
index 8c04e6426..000000000
--- a/navit/support/gettext_intl/plural-exp.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/* Expression parsing for plural form selection.
- Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc.
- Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "plural-exp.h"
-
-#if (defined __GNUC__ && !defined __APPLE_CC__) \
- || (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
-
-/* These structs are the constant expression for the germanic plural
- form determination. It represents the expression "n != 1". */
-static const struct expression plvar =
-{
- .nargs = 0,
- .operation = var,
-};
-static const struct expression plone =
-{
- .nargs = 0,
- .operation = num,
- .val =
- {
- .num = 1
- }
-};
-struct expression GERMANIC_PLURAL =
-{
- .nargs = 2,
- .operation = not_equal,
- .val =
- {
- .args =
- {
- [0] = (struct expression *) &plvar,
- [1] = (struct expression *) &plone
- }
- }
-};
-
-# define INIT_GERMANIC_PLURAL()
-
-#else
-
-/* For compilers without support for ISO C 99 struct/union initializers:
- Initialization at run-time. */
-
-static struct expression plvar;
-static struct expression plone;
-struct expression GERMANIC_PLURAL;
-
-static void
-init_germanic_plural ()
-{
- if (plone.val.num == 0)
- {
- plvar.nargs = 0;
- plvar.operation = var;
-
- plone.nargs = 0;
- plone.operation = num;
- plone.val.num = 1;
-
- GERMANIC_PLURAL.nargs = 2;
- GERMANIC_PLURAL.operation = not_equal;
- GERMANIC_PLURAL.val.args[0] = &plvar;
- GERMANIC_PLURAL.val.args[1] = &plone;
- }
-}
-
-# define INIT_GERMANIC_PLURAL() init_germanic_plural ()
-
-#endif
-
-void
-internal_function
-EXTRACT_PLURAL_EXPRESSION (const char *nullentry, struct expression **pluralp,
- unsigned long int *npluralsp)
-{
- if (nullentry != NULL)
- {
- const char *plural;
- const char *nplurals;
-
- plural = strstr (nullentry, "plural=");
- nplurals = strstr (nullentry, "nplurals=");
- if (plural == NULL || nplurals == NULL)
- goto no_plural;
- else
- {
- char *endp;
- unsigned long int n;
- struct parse_args args;
-
- /* First get the number. */
- nplurals += 9;
- while (*nplurals != '\0' && isspace ((unsigned char) *nplurals))
- ++nplurals;
- if (!(*nplurals >= '0' && *nplurals <= '9'))
- goto no_plural;
-#if defined HAVE_STRTOUL || defined _LIBC
- n = strtoul (nplurals, &endp, 10);
-#else
- for (endp = nplurals, n = 0; *endp >= '0' && *endp <= '9'; endp++)
- n = n * 10 + (*endp - '0');
-#endif
- if (nplurals == endp)
- goto no_plural;
- *npluralsp = n;
-
- /* Due to the restrictions bison imposes onto the interface of the
- scanner function we have to put the input string and the result
- passed up from the parser into the same structure which address
- is passed down to the parser. */
- plural += 7;
- args.cp = plural;
- if (PLURAL_PARSE (&args) != 0)
- goto no_plural;
- *pluralp = args.res;
- }
- }
- else
- {
- /* By default we are using the Germanic form: singular form only
- for `one', the plural form otherwise. Yes, this is also what
- English is using since English is a Germanic language. */
- no_plural:
- INIT_GERMANIC_PLURAL ();
- *pluralp = &GERMANIC_PLURAL;
- *npluralsp = 2;
- }
-}
diff --git a/navit/support/gettext_intl/plural-exp.h b/navit/support/gettext_intl/plural-exp.h
deleted file mode 100644
index 49e2c5bfc..000000000
--- a/navit/support/gettext_intl/plural-exp.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/* Expression parsing and evaluation for plural form selection.
- Copyright (C) 2000-2003 Free Software Foundation, Inc.
- Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _PLURAL_EXP_H
-#define _PLURAL_EXP_H
-
-#ifndef internal_function
-# define internal_function
-#endif
-
-#ifndef attribute_hidden
-# define attribute_hidden
-#endif
-
-
-/* This is the representation of the expressions to determine the
- plural form. */
-struct expression
-{
- int nargs; /* Number of arguments. */
- enum operator
- {
- /* Without arguments: */
- var, /* The variable "n". */
- num, /* Decimal number. */
- /* Unary operators: */
- lnot, /* Logical NOT. */
- /* Binary operators: */
- mult, /* Multiplication. */
- divide, /* Division. */
- module, /* Modulo operation. */
- plus, /* Addition. */
- minus, /* Subtraction. */
- less_than, /* Comparison. */
- greater_than, /* Comparison. */
- less_or_equal, /* Comparison. */
- greater_or_equal, /* Comparison. */
- equal, /* Comparison for equality. */
- not_equal, /* Comparison for inequality. */
- land, /* Logical AND. */
- lor, /* Logical OR. */
- /* Ternary operators: */
- qmop /* Question mark operator. */
- } operation;
- union
- {
- unsigned long int num; /* Number value for `num'. */
- struct expression *args[3]; /* Up to three arguments. */
- } val;
-};
-
-/* This is the data structure to pass information to the parser and get
- the result in a thread-safe way. */
-struct parse_args
-{
- const char *cp;
- struct expression *res;
-};
-
-
-/* Names for the libintl functions are a problem. This source code is used
- 1. in the GNU C Library library,
- 2. in the GNU libintl library,
- 3. in the GNU gettext tools.
- The function names in each situation must be different, to allow for
- binary incompatible changes in 'struct expression'. Furthermore,
- 1. in the GNU C Library library, the names have a __ prefix,
- 2.+3. in the GNU libintl library and in the GNU gettext tools, the names
- must follow ANSI C and not start with __.
- So we have to distinguish the three cases. */
-#ifdef _LIBC
-# define FREE_EXPRESSION __gettext_free_exp
-# define PLURAL_PARSE __gettextparse
-# define GERMANIC_PLURAL __gettext_germanic_plural
-# define EXTRACT_PLURAL_EXPRESSION __gettext_extract_plural
-#elif defined (IN_LIBINTL)
-# define FREE_EXPRESSION libintl_gettext_free_exp
-# define PLURAL_PARSE libintl_gettextparse
-# define GERMANIC_PLURAL libintl_gettext_germanic_plural
-# define EXTRACT_PLURAL_EXPRESSION libintl_gettext_extract_plural
-#else
-# define FREE_EXPRESSION free_plural_expression
-# define PLURAL_PARSE parse_plural_expression
-# define GERMANIC_PLURAL germanic_plural
-# define EXTRACT_PLURAL_EXPRESSION extract_plural_expression
-#endif
-
-extern void FREE_EXPRESSION (struct expression *exp)
- internal_function;
-extern int PLURAL_PARSE (void *arg);
-extern struct expression GERMANIC_PLURAL attribute_hidden;
-extern void EXTRACT_PLURAL_EXPRESSION (const char *nullentry,
- struct expression **pluralp,
- unsigned long int *npluralsp)
- internal_function;
-
-#if !defined (_LIBC) && !defined (IN_LIBINTL)
-extern unsigned long int plural_eval (struct expression *pexp,
- unsigned long int n);
-#endif
-
-#endif /* _PLURAL_EXP_H */
diff --git a/navit/support/gettext_intl/plural.c b/navit/support/gettext_intl/plural.c
deleted file mode 100644
index 89f4b45ed..000000000
--- a/navit/support/gettext_intl/plural.c
+++ /dev/null
@@ -1,1490 +0,0 @@
-/* A Bison parser, made from plural.y
- by GNU bison 1.35. */
-
-#define YYBISON 1 /* Identify Bison output. */
-
-#define yyparse __gettextparse
-#define yylex __gettextlex
-#define yyerror __gettexterror
-#define yylval __gettextlval
-#define yychar __gettextchar
-#define yydebug __gettextdebug
-#define yynerrs __gettextnerrs
-# define EQUOP2 257
-# define CMPOP2 258
-# define ADDOP2 259
-# define MULOP2 260
-# define NUMBER 261
-
-#line 1 "plural.y"
-
-/* Expression parsing for plural form selection.
- Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc.
- Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* The bison generated parser uses alloca. AIX 3 forces us to put this
- declaration at the beginning of the file. The declaration in bison's
- skeleton file comes too late. This must come before <config.h>
- because <config.h> may include arbitrary system headers. */
-#if defined _AIX && !defined __GNUC__
- #pragma alloca
-#endif
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stddef.h>
-#include <stdlib.h>
-#include "plural-exp.h"
-
-/* The main function generated by the parser is called __gettextparse,
- but we want it to be called PLURAL_PARSE. */
-#ifndef _LIBC
-# define __gettextparse PLURAL_PARSE
-#endif
-
-#define YYLEX_PARAM &((struct parse_args *) arg)->cp
-#define YYPARSE_PARAM arg
-
-#line 49 "plural.y"
-#ifndef YYSTYPE
-typedef union {
- unsigned long int num;
- enum operator op;
- struct expression *exp;
-} yystype;
-# define YYSTYPE yystype
-# define YYSTYPE_IS_TRIVIAL 1
-#endif
-#line 55 "plural.y"
-
-/* Prototypes for local functions. */
-static int yylex (YYSTYPE *lval, const char **pexp);
-static void yyerror (const char *str);
-
-/* Allocation of expressions. */
-
-static struct expression *
-new_exp (int nargs, enum operator op, struct expression * const *args)
-{
- int i;
- struct expression *newp;
-
- /* If any of the argument could not be malloc'ed, just return NULL. */
- for (i = nargs - 1; i >= 0; i--)
- if (args[i] == NULL)
- goto fail;
-
- /* Allocate a new expression. */
- newp = (struct expression *) malloc (sizeof (*newp));
- if (newp != NULL)
- {
- newp->nargs = nargs;
- newp->operation = op;
- for (i = nargs - 1; i >= 0; i--)
- newp->val.args[i] = args[i];
- return newp;
- }
-
- fail:
- for (i = nargs - 1; i >= 0; i--)
- FREE_EXPRESSION (args[i]);
-
- return NULL;
-}
-
-static struct expression *
-new_exp_0 (enum operator op)
-{
- return new_exp (0, op, NULL);
-}
-
-static struct expression *
-new_exp_1 (enum operator op, struct expression *right)
-{
- struct expression *args[1];
-
- args[0] = right;
- return new_exp (1, op, args);
-}
-
-static struct expression *
-new_exp_2 (enum operator op, struct expression *left, struct expression *right)
-{
- struct expression *args[2];
-
- args[0] = left;
- args[1] = right;
- return new_exp (2, op, args);
-}
-
-static struct expression *
-new_exp_3 (enum operator op, struct expression *bexp,
- struct expression *tbranch, struct expression *fbranch)
-{
- struct expression *args[3];
-
- args[0] = bexp;
- args[1] = tbranch;
- args[2] = fbranch;
- return new_exp (3, op, args);
-}
-
-#ifndef YYDEBUG
-# define YYDEBUG 0
-#endif
-
-
-
-#define YYFINAL 27
-#define YYFLAG -32768
-#define YYNTBASE 16
-
-/* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
-#define YYTRANSLATE(x) ((unsigned)(x) <= 261 ? yytranslate[x] : 18)
-
-/* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
-static const char yytranslate[] =
-{
- 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 10, 2, 2, 2, 2, 5, 2,
- 14, 15, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 12, 2,
- 2, 2, 2, 3, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 13, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 4, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- 2, 2, 2, 2, 2, 2, 1, 6, 7, 8,
- 9, 11
-};
-
-#if YYDEBUG
-static const short yyprhs[] =
-{
- 0, 0, 2, 8, 12, 16, 20, 24, 28, 32,
- 35, 37, 39
-};
-static const short yyrhs[] =
-{
- 17, 0, 17, 3, 17, 12, 17, 0, 17, 4,
- 17, 0, 17, 5, 17, 0, 17, 6, 17, 0,
- 17, 7, 17, 0, 17, 8, 17, 0, 17, 9,
- 17, 0, 10, 17, 0, 13, 0, 11, 0, 14,
- 17, 15, 0
-};
-
-#endif
-
-#if YYDEBUG
-/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
-static const short yyrline[] =
-{
- 0, 150, 158, 162, 166, 170, 174, 178, 182, 186,
- 190, 194, 199
-};
-#endif
-
-
-#if (YYDEBUG) || defined YYERROR_VERBOSE
-
-/* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
-static const char *const yytname[] =
-{
- "$", "error", "$undefined.", "'?'", "'|'", "'&'", "EQUOP2", "CMPOP2",
- "ADDOP2", "MULOP2", "'!'", "NUMBER", "':'", "'n'", "'('", "')'",
- "start", "exp", 0
-};
-#endif
-
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
-static const short yyr1[] =
-{
- 0, 16, 17, 17, 17, 17, 17, 17, 17, 17,
- 17, 17, 17
-};
-
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
-static const short yyr2[] =
-{
- 0, 1, 5, 3, 3, 3, 3, 3, 3, 2,
- 1, 1, 3
-};
-
-/* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
- doesn't specify something else to do. Zero means the default is an
- error. */
-static const short yydefact[] =
-{
- 0, 0, 11, 10, 0, 1, 9, 0, 0, 0,
- 0, 0, 0, 0, 0, 12, 0, 3, 4, 5,
- 6, 7, 8, 0, 2, 0, 0, 0
-};
-
-static const short yydefgoto[] =
-{
- 25, 5
-};
-
-static const short yypact[] =
-{
- -9, -9,-32768,-32768, -9, 34,-32768, 11, -9, -9,
- -9, -9, -9, -9, -9,-32768, 24, 39, 43, 16,
- 26, -3,-32768, -9, 34, 21, 53,-32768
-};
-
-static const short yypgoto[] =
-{
- -32768, -1
-};
-
-
-#define YYLAST 53
-
-
-static const short yytable[] =
-{
- 6, 1, 2, 7, 3, 4, 14, 16, 17, 18,
- 19, 20, 21, 22, 8, 9, 10, 11, 12, 13,
- 14, 26, 24, 12, 13, 14, 15, 8, 9, 10,
- 11, 12, 13, 14, 13, 14, 23, 8, 9, 10,
- 11, 12, 13, 14, 10, 11, 12, 13, 14, 11,
- 12, 13, 14, 27
-};
-
-static const short yycheck[] =
-{
- 1, 10, 11, 4, 13, 14, 9, 8, 9, 10,
- 11, 12, 13, 14, 3, 4, 5, 6, 7, 8,
- 9, 0, 23, 7, 8, 9, 15, 3, 4, 5,
- 6, 7, 8, 9, 8, 9, 12, 3, 4, 5,
- 6, 7, 8, 9, 5, 6, 7, 8, 9, 6,
- 7, 8, 9, 0
-};
-#define YYPURE 1
-
-/* -*-C-*- Note some compilers choke on comments on `#line' lines. */
-#line 3 "/usr/local/share/bison/bison.simple"
-
-/* Skeleton output parser for bison,
-
- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
- Foundation, Inc.
-
- 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., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA. */
-
-/* As a special exception, when this file is copied by Bison into a
- Bison output file, you may use that output file without restriction.
- This special exception was added by the Free Software Foundation
- in version 1.24 of Bison. */
-
-/* This is the parser code that is written into each bison parser when
- the %semantic_parser declaration is not specified in the grammar.
- It was written by Richard Stallman by simplifying the hairy parser
- used when %semantic_parser is specified. */
-
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
-
-/* The parser invokes alloca or malloc; define the necessary symbols. */
-
-# if YYSTACK_USE_ALLOCA
-# define YYSTACK_ALLOC alloca
-# else
-# ifndef YYSTACK_USE_ALLOCA
-# if defined (alloca) || defined (_ALLOCA_H)
-# define YYSTACK_ALLOC alloca
-# else
-# ifdef __GNUC__
-# define YYSTACK_ALLOC __builtin_alloca
-# endif
-# endif
-# endif
-# endif
-
-# ifdef YYSTACK_ALLOC
- /* Pacify GCC's `empty if-body' warning. */
-# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
-# else
-# if defined (__STDC__) || defined (__cplusplus)
-# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# endif
-# define YYSTACK_ALLOC malloc
-# define YYSTACK_FREE free
-# endif
-#endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
-
-
-#if (! defined (yyoverflow) \
- && (! defined (__cplusplus) \
- || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
-
-/* A type that is properly aligned for any stack member. */
-union yyalloc
-{
- short yyss;
- YYSTYPE yyvs;
-# if YYLSP_NEEDED
- YYLTYPE yyls;
-# endif
-};
-
-/* The size of the maximum gap between one aligned stack and the next. */
-# define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
-
-/* The size of an array large to enough to hold all stacks, each with
- N elements. */
-# if YYLSP_NEEDED
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
- + 2 * YYSTACK_GAP_MAX)
-# else
-# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAX)
-# endif
-
-/* Copy COUNT objects from FROM to TO. The source and destination do
- not overlap. */
-# ifndef YYCOPY
-# if 1 < __GNUC__
-# define YYCOPY(To, From, Count) \
- __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
-# else
-# define YYCOPY(To, From, Count) \
- do \
- { \
- register YYSIZE_T yyi; \
- for (yyi = 0; yyi < (Count); yyi++) \
- (To)[yyi] = (From)[yyi]; \
- } \
- while (0)
-# endif
-# endif
-
-/* Relocate STACK from its old location to the new one. The
- local variables YYSIZE and YYSTACKSIZE give the old and new number of
- elements in the stack, and YYPTR gives the new location of the
- stack. Advance YYPTR to a properly aligned location for the next
- stack. */
-# define YYSTACK_RELOCATE(Stack) \
- do \
- { \
- YYSIZE_T yynewbytes; \
- YYCOPY (&yyptr->Stack, Stack, yysize); \
- Stack = &yyptr->Stack; \
- yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
- yyptr += yynewbytes / sizeof (*yyptr); \
- } \
- while (0)
-
-#endif
-
-
-#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
-# define YYSIZE_T __SIZE_TYPE__
-#endif
-#if ! defined (YYSIZE_T) && defined (size_t)
-# define YYSIZE_T size_t
-#endif
-#if ! defined (YYSIZE_T)
-# if defined (__STDC__) || defined (__cplusplus)
-# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
-# define YYSIZE_T size_t
-# endif
-#endif
-#if ! defined (YYSIZE_T)
-# define YYSIZE_T unsigned int
-#endif
-
-#define yyerrok (yyerrstatus = 0)
-#define yyclearin (yychar = YYEMPTY)
-#define YYEMPTY -2
-#define YYEOF 0
-#define YYACCEPT goto yyacceptlab
-#define YYABORT goto yyabortlab
-#define YYERROR goto yyerrlab1
-/* Like YYERROR except do call yyerror. This remains here temporarily
- to ease the transition to the new meaning of YYERROR, for GCC.
- Once GCC version 2 has supplanted version 1, this can go. */
-#define YYFAIL goto yyerrlab
-#define YYRECOVERING() (!!yyerrstatus)
-#define YYBACKUP(Token, Value) \
-do \
- if (yychar == YYEMPTY && yylen == 1) \
- { \
- yychar = (Token); \
- yylval = (Value); \
- yychar1 = YYTRANSLATE (yychar); \
- YYPOPSTACK; \
- goto yybackup; \
- } \
- else \
- { \
- yyerror ("syntax error: cannot back up"); \
- YYERROR; \
- } \
-while (0)
-
-#define YYTERROR 1
-#define YYERRCODE 256
-
-
-/* YYLLOC_DEFAULT -- Compute the default location (before the actions
- are run).
-
- When YYLLOC_DEFAULT is run, CURRENT is set the location of the
- first token. By default, to implement support for ranges, extend
- its range to the last symbol. */
-
-#ifndef YYLLOC_DEFAULT
-# define YYLLOC_DEFAULT(Current, Rhs, N) \
- Current.last_line = Rhs[N].last_line; \
- Current.last_column = Rhs[N].last_column;
-#endif
-
-
-/* YYLEX -- calling `yylex' with the right arguments. */
-
-#if YYPURE
-# if YYLSP_NEEDED
-# ifdef YYLEX_PARAM
-# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
-# else
-# define YYLEX yylex (&yylval, &yylloc)
-# endif
-# else /* !YYLSP_NEEDED */
-# ifdef YYLEX_PARAM
-# define YYLEX yylex (&yylval, YYLEX_PARAM)
-# else
-# define YYLEX yylex (&yylval)
-# endif
-# endif /* !YYLSP_NEEDED */
-#else /* !YYPURE */
-# define YYLEX yylex ()
-#endif /* !YYPURE */
-
-
-/* Enable debugging if requested. */
-#if YYDEBUG
-
-# ifndef YYFPRINTF
-# include <stdio.h> /* INFRINGES ON USER NAME SPACE */
-# define YYFPRINTF fprintf
-# endif
-
-# define YYDPRINTF(Args) \
-do { \
- if (yydebug) \
- YYFPRINTF Args; \
-} while (0)
-/* Nonzero means print parse trace. It is left uninitialized so that
- multiple parsers can coexist. */
-int yydebug;
-#else /* !YYDEBUG */
-# define YYDPRINTF(Args)
-#endif /* !YYDEBUG */
-
-/* YYINITDEPTH -- initial size of the parser's stacks. */
-#ifndef YYINITDEPTH
-# define YYINITDEPTH 200
-#endif
-
-/* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
- if the built-in stack extension method is used).
-
- Do not make this value too large; the results are undefined if
- SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
- evaluated with infinite-precision integer arithmetic. */
-
-#if YYMAXDEPTH == 0
-# undef YYMAXDEPTH
-#endif
-
-#ifndef YYMAXDEPTH
-# define YYMAXDEPTH 10000
-#endif
-
-#ifdef YYERROR_VERBOSE
-
-# ifndef yystrlen
-# if defined (__GLIBC__) && defined (_STRING_H)
-# define yystrlen strlen
-# else
-/* Return the length of YYSTR. */
-static YYSIZE_T
-# if defined (__STDC__) || defined (__cplusplus)
-yystrlen (const char *yystr)
-# else
-yystrlen (yystr)
- const char *yystr;
-# endif
-{
- register const char *yys = yystr;
-
- while (*yys++ != '\0')
- continue;
-
- return yys - yystr - 1;
-}
-# endif
-# endif
-
-# ifndef yystpcpy
-# if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
-# define yystpcpy stpcpy
-# else
-/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
- YYDEST. */
-static char *
-# if defined (__STDC__) || defined (__cplusplus)
-yystpcpy (char *yydest, const char *yysrc)
-# else
-yystpcpy (yydest, yysrc)
- char *yydest;
- const char *yysrc;
-# endif
-{
- register char *yyd = yydest;
- register const char *yys = yysrc;
-
- while ((*yyd++ = *yys++) != '\0')
- continue;
-
- return yyd - 1;
-}
-# endif
-# endif
-#endif
-
-#line 315 "/usr/local/share/bison/bison.simple"
-
-
-/* The user can define YYPARSE_PARAM as the name of an argument to be passed
- into yyparse. The argument should have type void *.
- It should actually point to an object.
- Grammar actions can access the variable by casting it
- to the proper pointer type. */
-
-#ifdef YYPARSE_PARAM
-# if defined (__STDC__) || defined (__cplusplus)
-# define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
-# define YYPARSE_PARAM_DECL
-# else
-# define YYPARSE_PARAM_ARG YYPARSE_PARAM
-# define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
-# endif
-#else /* !YYPARSE_PARAM */
-# define YYPARSE_PARAM_ARG
-# define YYPARSE_PARAM_DECL
-#endif /* !YYPARSE_PARAM */
-
-/* Prevent warning if -Wstrict-prototypes. */
-#ifdef __GNUC__
-# ifdef YYPARSE_PARAM
-int yyparse (void *);
-# else
-int yyparse (void);
-# endif
-#endif
-
-/* YY_DECL_VARIABLES -- depending whether we use a pure parser,
- variables are global, or local to YYPARSE. */
-
-#define YY_DECL_NON_LSP_VARIABLES \
-/* The lookahead symbol. */ \
-int yychar; \
- \
-/* The semantic value of the lookahead symbol. */ \
-YYSTYPE yylval; \
- \
-/* Number of parse errors so far. */ \
-int yynerrs;
-
-#if YYLSP_NEEDED
-# define YY_DECL_VARIABLES \
-YY_DECL_NON_LSP_VARIABLES \
- \
-/* Location data for the lookahead symbol. */ \
-YYLTYPE yylloc;
-#else
-# define YY_DECL_VARIABLES \
-YY_DECL_NON_LSP_VARIABLES
-#endif
-
-
-/* If nonreentrant, generate the variables here. */
-
-#if !YYPURE
-YY_DECL_VARIABLES
-#endif /* !YYPURE */
-
-int
-yyparse (YYPARSE_PARAM_ARG)
- YYPARSE_PARAM_DECL
-{
- /* If reentrant, generate the variables here. */
-#if YYPURE
- YY_DECL_VARIABLES
-#endif /* !YYPURE */
-
- register int yystate;
- register int yyn;
- int yyresult;
- /* Number of tokens to shift before error messages enabled. */
- int yyerrstatus;
- /* Lookahead token as an internal (translated) token number. */
- int yychar1 = 0;
-
- /* Three stacks and their tools:
- `yyss': related to states,
- `yyvs': related to semantic values,
- `yyls': related to locations.
-
- Refer to the stacks thru separate pointers, to allow yyoverflow
- to reallocate them elsewhere. */
-
- /* The state stack. */
- short yyssa[YYINITDEPTH];
- short *yyss = yyssa;
- register short *yyssp;
-
- /* The semantic value stack. */
- YYSTYPE yyvsa[YYINITDEPTH];
- YYSTYPE *yyvs = yyvsa;
- register YYSTYPE *yyvsp;
-
-#if YYLSP_NEEDED
- /* The location stack. */
- YYLTYPE yylsa[YYINITDEPTH];
- YYLTYPE *yyls = yylsa;
- YYLTYPE *yylsp;
-#endif
-
-#if YYLSP_NEEDED
-# define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
-#else
-# define YYPOPSTACK (yyvsp--, yyssp--)
-#endif
-
- YYSIZE_T yystacksize = YYINITDEPTH;
-
-
- /* The variables used to return semantic value and location from the
- action routines. */
- YYSTYPE yyval;
-#if YYLSP_NEEDED
- YYLTYPE yyloc;
-#endif
-
- /* When reducing, the number of symbols on the RHS of the reduced
- rule. */
- int yylen;
-
- YYDPRINTF ((stderr, "Starting parse\n"));
-
- yystate = 0;
- yyerrstatus = 0;
- yynerrs = 0;
- yychar = YYEMPTY; /* Cause a token to be read. */
-
- /* Initialize stack pointers.
- Waste one element of value and location stack
- so that they stay on the same level as the state stack.
- The wasted elements are never initialized. */
-
- yyssp = yyss;
- yyvsp = yyvs;
-#if YYLSP_NEEDED
- yylsp = yyls;
-#endif
- goto yysetstate;
-
-/*------------------------------------------------------------.
-| yynewstate -- Push a new state, which is found in yystate. |
-`------------------------------------------------------------*/
- yynewstate:
- /* In all cases, when you get here, the value and location stacks
- have just been pushed. so pushing a state here evens the stacks.
- */
- yyssp++;
-
- yysetstate:
- *yyssp = yystate;
-
- if (yyssp >= yyss + yystacksize - 1)
- {
- /* Get the current used size of the three stacks, in elements. */
- YYSIZE_T yysize = yyssp - yyss + 1;
-
-#ifdef yyoverflow
- {
- /* Give user a chance to reallocate the stack. Use copies of
- these so that the &'s don't force the real ones into
- memory. */
- YYSTYPE *yyvs1 = yyvs;
- short *yyss1 = yyss;
-
- /* Each stack pointer address is followed by the size of the
- data in use in that stack, in bytes. */
-# if YYLSP_NEEDED
- YYLTYPE *yyls1 = yyls;
- /* This used to be a conditional around just the two extra args,
- but that might be undefined if yyoverflow is a macro. */
- yyoverflow ("parser stack overflow",
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
- &yyls1, yysize * sizeof (*yylsp),
- &yystacksize);
- yyls = yyls1;
-# else
- yyoverflow ("parser stack overflow",
- &yyss1, yysize * sizeof (*yyssp),
- &yyvs1, yysize * sizeof (*yyvsp),
- &yystacksize);
-# endif
- yyss = yyss1;
- yyvs = yyvs1;
- }
-#else /* no yyoverflow */
-# ifndef YYSTACK_RELOCATE
- goto yyoverflowlab;
-# else
- /* Extend the stack our own way. */
- if (yystacksize >= YYMAXDEPTH)
- goto yyoverflowlab;
- yystacksize *= 2;
- if (yystacksize > YYMAXDEPTH)
- yystacksize = YYMAXDEPTH;
-
- {
- short *yyss1 = yyss;
- union yyalloc *yyptr =
- (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
- if (! yyptr)
- goto yyoverflowlab;
- YYSTACK_RELOCATE (yyss);
- YYSTACK_RELOCATE (yyvs);
-# if YYLSP_NEEDED
- YYSTACK_RELOCATE (yyls);
-# endif
-# undef YYSTACK_RELOCATE
- if (yyss1 != yyssa)
- YYSTACK_FREE (yyss1);
- }
-# endif
-#endif /* no yyoverflow */
-
- yyssp = yyss + yysize - 1;
- yyvsp = yyvs + yysize - 1;
-#if YYLSP_NEEDED
- yylsp = yyls + yysize - 1;
-#endif
-
- YYDPRINTF ((stderr, "Stack size increased to %lu\n",
- (unsigned long int) yystacksize));
-
- if (yyssp >= yyss + yystacksize - 1)
- YYABORT;
- }
-
- YYDPRINTF ((stderr, "Entering state %d\n", yystate));
-
- goto yybackup;
-
-
-/*-----------.
-| yybackup. |
-`-----------*/
-yybackup:
-
-/* Do appropriate processing given the current state. */
-/* Read a lookahead token if we need one and don't already have one. */
-/* yyresume: */
-
- /* First try to decide what to do without reference to lookahead token. */
-
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yydefault;
-
- /* Not known => get a lookahead token if don't already have one. */
-
- /* yychar is either YYEMPTY or YYEOF
- or a valid token in external form. */
-
- if (yychar == YYEMPTY)
- {
- YYDPRINTF ((stderr, "Reading a token: "));
- yychar = YYLEX;
- }
-
- /* Convert token to internal form (in yychar1) for indexing tables with */
-
- if (yychar <= 0) /* This means end of input. */
- {
- yychar1 = 0;
- yychar = YYEOF; /* Don't call YYLEX any more */
-
- YYDPRINTF ((stderr, "Now at end of input.\n"));
- }
- else
- {
- yychar1 = YYTRANSLATE (yychar);
-
-#if YYDEBUG
- /* We have to keep this `#if YYDEBUG', since we use variables
- which are defined only if `YYDEBUG' is set. */
- if (yydebug)
- {
- YYFPRINTF (stderr, "Next token is %d (%s",
- yychar, yytname[yychar1]);
- /* Give the individual parser a way to print the precise
- meaning of a token, for further debugging info. */
-# ifdef YYPRINT
- YYPRINT (stderr, yychar, yylval);
-# endif
- YYFPRINTF (stderr, ")\n");
- }
-#endif
- }
-
- yyn += yychar1;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
- goto yydefault;
-
- yyn = yytable[yyn];
-
- /* yyn is what to do for this token type in this state.
- Negative => reduce, -yyn is rule number.
- Positive => shift, yyn is new state.
- New state is final state => don't bother to shift,
- just return success.
- 0, or most negative number => error. */
-
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrlab;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrlab;
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- /* Shift the lookahead token. */
- YYDPRINTF ((stderr, "Shifting token %d (%s), ",
- yychar, yytname[yychar1]));
-
- /* Discard the token being shifted unless it is eof. */
- if (yychar != YYEOF)
- yychar = YYEMPTY;
-
- *++yyvsp = yylval;
-#if YYLSP_NEEDED
- *++yylsp = yylloc;
-#endif
-
- /* Count tokens shifted since error; after three, turn off error
- status. */
- if (yyerrstatus)
- yyerrstatus--;
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-----------------------------------------------------------.
-| yydefault -- do the default action for the current state. |
-`-----------------------------------------------------------*/
-yydefault:
- yyn = yydefact[yystate];
- if (yyn == 0)
- goto yyerrlab;
- goto yyreduce;
-
-
-/*-----------------------------.
-| yyreduce -- Do a reduction. |
-`-----------------------------*/
-yyreduce:
- /* yyn is the number of a rule to reduce with. */
- yylen = yyr2[yyn];
-
- /* If YYLEN is nonzero, implement the default value of the action:
- `$$ = $1'.
-
- Otherwise, the following line sets YYVAL to the semantic value of
- the lookahead token. This behavior is undocumented and Bison
- users should not rely upon it. Assigning to YYVAL
- unconditionally makes the parser a bit smaller, and it avoids a
- GCC warning that YYVAL may be used uninitialized. */
- yyval = yyvsp[1-yylen];
-
-#if YYLSP_NEEDED
- /* Similarly for the default location. Let the user run additional
- commands if for instance locations are ranges. */
- yyloc = yylsp[1-yylen];
- YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
-#endif
-
-#if YYDEBUG
- /* We have to keep this `#if YYDEBUG', since we use variables which
- are defined only if `YYDEBUG' is set. */
- if (yydebug)
- {
- int yyi;
-
- YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
- yyn, yyrline[yyn]);
-
- /* Print the symbols being reduced, and their result. */
- for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
- YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
- YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
- }
-#endif
-
- switch (yyn) {
-
-case 1:
-#line 151 "plural.y"
-{
- if (yyvsp[0].exp == NULL)
- YYABORT;
- ((struct parse_args *) arg)->res = yyvsp[0].exp;
- }
- break;
-case 2:
-#line 159 "plural.y"
-{
- yyval.exp = new_exp_3 (qmop, yyvsp[-4].exp, yyvsp[-2].exp, yyvsp[0].exp);
- }
- break;
-case 3:
-#line 163 "plural.y"
-{
- yyval.exp = new_exp_2 (lor, yyvsp[-2].exp, yyvsp[0].exp);
- }
- break;
-case 4:
-#line 167 "plural.y"
-{
- yyval.exp = new_exp_2 (land, yyvsp[-2].exp, yyvsp[0].exp);
- }
- break;
-case 5:
-#line 171 "plural.y"
-{
- yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
- }
- break;
-case 6:
-#line 175 "plural.y"
-{
- yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
- }
- break;
-case 7:
-#line 179 "plural.y"
-{
- yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
- }
- break;
-case 8:
-#line 183 "plural.y"
-{
- yyval.exp = new_exp_2 (yyvsp[-1].op, yyvsp[-2].exp, yyvsp[0].exp);
- }
- break;
-case 9:
-#line 187 "plural.y"
-{
- yyval.exp = new_exp_1 (lnot, yyvsp[0].exp);
- }
- break;
-case 10:
-#line 191 "plural.y"
-{
- yyval.exp = new_exp_0 (var);
- }
- break;
-case 11:
-#line 195 "plural.y"
-{
- if ((yyval.exp = new_exp_0 (num)) != NULL)
- yyval.exp->val.num = yyvsp[0].num;
- }
- break;
-case 12:
-#line 200 "plural.y"
-{
- yyval.exp = yyvsp[-1].exp;
- }
- break;
-}
-
-#line 705 "/usr/local/share/bison/bison.simple"
-
-
- yyvsp -= yylen;
- yyssp -= yylen;
-#if YYLSP_NEEDED
- yylsp -= yylen;
-#endif
-
-#if YYDEBUG
- if (yydebug)
- {
- short *yyssp1 = yyss - 1;
- YYFPRINTF (stderr, "state stack now");
- while (yyssp1 != yyssp)
- YYFPRINTF (stderr, " %d", *++yyssp1);
- YYFPRINTF (stderr, "\n");
- }
-#endif
-
- *++yyvsp = yyval;
-#if YYLSP_NEEDED
- *++yylsp = yyloc;
-#endif
-
- /* Now `shift' the result of the reduction. Determine what state
- that goes to, based on the state we popped back to and the rule
- number reduced by. */
-
- yyn = yyr1[yyn];
-
- yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
- if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
- yystate = yytable[yystate];
- else
- yystate = yydefgoto[yyn - YYNTBASE];
-
- goto yynewstate;
-
-
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
-yyerrlab:
- /* If not already recovering from an error, report this error. */
- if (!yyerrstatus)
- {
- ++yynerrs;
-
-#ifdef YYERROR_VERBOSE
- yyn = yypact[yystate];
-
- if (yyn > YYFLAG && yyn < YYLAST)
- {
- YYSIZE_T yysize = 0;
- char *yymsg;
- int yyx, yycount;
-
- yycount = 0;
- /* Start YYX at -YYN if negative to avoid negative indexes in
- YYCHECK. */
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
- if (yycheck[yyx + yyn] == yyx)
- yysize += yystrlen (yytname[yyx]) + 15, yycount++;
- yysize += yystrlen ("parse error, unexpected ") + 1;
- yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
- yymsg = (char *) YYSTACK_ALLOC (yysize);
- if (yymsg != 0)
- {
- char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
- yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
-
- if (yycount < 5)
- {
- yycount = 0;
- for (yyx = yyn < 0 ? -yyn : 0;
- yyx < (int) (sizeof (yytname) / sizeof (char *));
- yyx++)
- if (yycheck[yyx + yyn] == yyx)
- {
- const char *yyq = ! yycount ? ", expecting " : " or ";
- yyp = yystpcpy (yyp, yyq);
- yyp = yystpcpy (yyp, yytname[yyx]);
- yycount++;
- }
- }
- yyerror (yymsg);
- YYSTACK_FREE (yymsg);
- }
- else
- yyerror ("parse error; also virtual memory exhausted");
- }
- else
-#endif /* defined (YYERROR_VERBOSE) */
- yyerror ("parse error");
- }
- goto yyerrlab1;
-
-
-/*--------------------------------------------------.
-| yyerrlab1 -- error raised explicitly by an action |
-`--------------------------------------------------*/
-yyerrlab1:
- if (yyerrstatus == 3)
- {
- /* If just tried and failed to reuse lookahead token after an
- error, discard it. */
-
- /* return failure if at end of input */
- if (yychar == YYEOF)
- YYABORT;
- YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
- yychar, yytname[yychar1]));
- yychar = YYEMPTY;
- }
-
- /* Else will try to reuse lookahead token after shifting the error
- token. */
-
- yyerrstatus = 3; /* Each real token shifted decrements this */
-
- goto yyerrhandle;
-
-
-/*-------------------------------------------------------------------.
-| yyerrdefault -- current state does not do anything special for the |
-| error token. |
-`-------------------------------------------------------------------*/
-yyerrdefault:
-#if 0
- /* This is wrong; only states that explicitly want error tokens
- should shift them. */
-
- /* If its default is to accept any token, ok. Otherwise pop it. */
- yyn = yydefact[yystate];
- if (yyn)
- goto yydefault;
-#endif
-
-
-/*---------------------------------------------------------------.
-| yyerrpop -- pop the current state because it cannot handle the |
-| error token |
-`---------------------------------------------------------------*/
-yyerrpop:
- if (yyssp == yyss)
- YYABORT;
- yyvsp--;
- yystate = *--yyssp;
-#if YYLSP_NEEDED
- yylsp--;
-#endif
-
-#if YYDEBUG
- if (yydebug)
- {
- short *yyssp1 = yyss - 1;
- YYFPRINTF (stderr, "Error: state stack now");
- while (yyssp1 != yyssp)
- YYFPRINTF (stderr, " %d", *++yyssp1);
- YYFPRINTF (stderr, "\n");
- }
-#endif
-
-/*--------------.
-| yyerrhandle. |
-`--------------*/
-yyerrhandle:
- yyn = yypact[yystate];
- if (yyn == YYFLAG)
- goto yyerrdefault;
-
- yyn += YYTERROR;
- if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
- goto yyerrdefault;
-
- yyn = yytable[yyn];
- if (yyn < 0)
- {
- if (yyn == YYFLAG)
- goto yyerrpop;
- yyn = -yyn;
- goto yyreduce;
- }
- else if (yyn == 0)
- goto yyerrpop;
-
- if (yyn == YYFINAL)
- YYACCEPT;
-
- YYDPRINTF ((stderr, "Shifting error token, "));
-
- *++yyvsp = yylval;
-#if YYLSP_NEEDED
- *++yylsp = yylloc;
-#endif
-
- yystate = yyn;
- goto yynewstate;
-
-
-/*-------------------------------------.
-| yyacceptlab -- YYACCEPT comes here. |
-`-------------------------------------*/
-yyacceptlab:
- yyresult = 0;
- goto yyreturn;
-
-/*-----------------------------------.
-| yyabortlab -- YYABORT comes here. |
-`-----------------------------------*/
-yyabortlab:
- yyresult = 1;
- goto yyreturn;
-
-/*---------------------------------------------.
-| yyoverflowab -- parser overflow comes here. |
-`---------------------------------------------*/
-yyoverflowlab:
- yyerror ("parser stack overflow");
- yyresult = 2;
- /* Fall through. */
-
-yyreturn:
-#ifndef yyoverflow
- if (yyss != yyssa)
- YYSTACK_FREE (yyss);
-#endif
- return yyresult;
-}
-#line 205 "plural.y"
-
-
-void
-internal_function
-FREE_EXPRESSION (struct expression *exp)
-{
- if (exp == NULL)
- return;
-
- /* Handle the recursive case. */
- switch (exp->nargs)
- {
- case 3:
- FREE_EXPRESSION (exp->val.args[2]);
- /* FALLTHROUGH */
- case 2:
- FREE_EXPRESSION (exp->val.args[1]);
- /* FALLTHROUGH */
- case 1:
- FREE_EXPRESSION (exp->val.args[0]);
- /* FALLTHROUGH */
- default:
- break;
- }
-
- free (exp);
-}
-
-
-static int
-yylex (YYSTYPE *lval, const char **pexp)
-{
- const char *exp = *pexp;
- int result;
-
- while (1)
- {
- if (exp[0] == '\0')
- {
- *pexp = exp;
- return YYEOF;
- }
-
- if (exp[0] != ' ' && exp[0] != '\t')
- break;
-
- ++exp;
- }
-
- result = *exp++;
- switch (result)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- {
- unsigned long int n = result - '0';
- while (exp[0] >= '0' && exp[0] <= '9')
- {
- n *= 10;
- n += exp[0] - '0';
- ++exp;
- }
- lval->num = n;
- result = NUMBER;
- }
- break;
-
- case '=':
- if (exp[0] == '=')
- {
- ++exp;
- lval->op = equal;
- result = EQUOP2;
- }
- else
- result = YYERRCODE;
- break;
-
- case '!':
- if (exp[0] == '=')
- {
- ++exp;
- lval->op = not_equal;
- result = EQUOP2;
- }
- break;
-
- case '&':
- case '|':
- if (exp[0] == result)
- ++exp;
- else
- result = YYERRCODE;
- break;
-
- case '<':
- if (exp[0] == '=')
- {
- ++exp;
- lval->op = less_or_equal;
- }
- else
- lval->op = less_than;
- result = CMPOP2;
- break;
-
- case '>':
- if (exp[0] == '=')
- {
- ++exp;
- lval->op = greater_or_equal;
- }
- else
- lval->op = greater_than;
- result = CMPOP2;
- break;
-
- case '*':
- lval->op = mult;
- result = MULOP2;
- break;
-
- case '/':
- lval->op = divide;
- result = MULOP2;
- break;
-
- case '%':
- lval->op = module;
- result = MULOP2;
- break;
-
- case '+':
- lval->op = plus;
- result = ADDOP2;
- break;
-
- case '-':
- lval->op = minus;
- result = ADDOP2;
- break;
-
- case 'n':
- case '?':
- case ':':
- case '(':
- case ')':
- /* Nothing, just return the character. */
- break;
-
- case ';':
- case '\n':
- case '\0':
- /* Be safe and let the user call this function again. */
- --exp;
- result = YYEOF;
- break;
-
- default:
- result = YYERRCODE;
-#if YYDEBUG != 0
- --exp;
-#endif
- break;
- }
-
- *pexp = exp;
-
- return result;
-}
-
-
-static void
-yyerror (const char *str)
-{
- /* Do nothing. We don't print error messages here. */
-}
diff --git a/navit/support/gettext_intl/plural.y b/navit/support/gettext_intl/plural.y
deleted file mode 100644
index 4d33bd7c7..000000000
--- a/navit/support/gettext_intl/plural.y
+++ /dev/null
@@ -1,381 +0,0 @@
-%{
-/* Expression parsing for plural form selection.
- Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc.
- Written by Ulrich Drepper <drepper@cygnus.com>, 2000.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* The bison generated parser uses alloca. AIX 3 forces us to put this
- declaration at the beginning of the file. The declaration in bison's
- skeleton file comes too late. This must come before <config.h>
- because <config.h> may include arbitrary system headers. */
-#if defined _AIX && !defined __GNUC__
- #pragma alloca
-#endif
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stddef.h>
-#include <stdlib.h>
-#include "plural-exp.h"
-
-/* The main function generated by the parser is called __gettextparse,
- but we want it to be called PLURAL_PARSE. */
-#ifndef _LIBC
-# define __gettextparse PLURAL_PARSE
-#endif
-
-#define YYLEX_PARAM &((struct parse_args *) arg)->cp
-#define YYPARSE_PARAM arg
-%}
-%pure_parser
-%expect 7
-
-%union {
- unsigned long int num;
- enum operator op;
- struct expression *exp;
-}
-
-%{
-/* Prototypes for local functions. */
-static int yylex (YYSTYPE *lval, const char **pexp);
-static void yyerror (const char *str);
-
-/* Allocation of expressions. */
-
-static struct expression *
-new_exp (int nargs, enum operator op, struct expression * const *args)
-{
- int i;
- struct expression *newp;
-
- /* If any of the argument could not be malloc'ed, just return NULL. */
- for (i = nargs - 1; i >= 0; i--)
- if (args[i] == NULL)
- goto fail;
-
- /* Allocate a new expression. */
- newp = (struct expression *) malloc (sizeof (*newp));
- if (newp != NULL)
- {
- newp->nargs = nargs;
- newp->operation = op;
- for (i = nargs - 1; i >= 0; i--)
- newp->val.args[i] = args[i];
- return newp;
- }
-
- fail:
- for (i = nargs - 1; i >= 0; i--)
- FREE_EXPRESSION (args[i]);
-
- return NULL;
-}
-
-static inline struct expression *
-new_exp_0 (enum operator op)
-{
- return new_exp (0, op, NULL);
-}
-
-static inline struct expression *
-new_exp_1 (enum operator op, struct expression *right)
-{
- struct expression *args[1];
-
- args[0] = right;
- return new_exp (1, op, args);
-}
-
-static struct expression *
-new_exp_2 (enum operator op, struct expression *left, struct expression *right)
-{
- struct expression *args[2];
-
- args[0] = left;
- args[1] = right;
- return new_exp (2, op, args);
-}
-
-static inline struct expression *
-new_exp_3 (enum operator op, struct expression *bexp,
- struct expression *tbranch, struct expression *fbranch)
-{
- struct expression *args[3];
-
- args[0] = bexp;
- args[1] = tbranch;
- args[2] = fbranch;
- return new_exp (3, op, args);
-}
-
-%}
-
-/* This declares that all operators have the same associativity and the
- precedence order as in C. See [Harbison, Steele: C, A Reference Manual].
- There is no unary minus and no bitwise operators.
- Operators with the same syntactic behaviour have been merged into a single
- token, to save space in the array generated by bison. */
-%right '?' /* ? */
-%left '|' /* || */
-%left '&' /* && */
-%left EQUOP2 /* == != */
-%left CMPOP2 /* < > <= >= */
-%left ADDOP2 /* + - */
-%left MULOP2 /* * / % */
-%right '!' /* ! */
-
-%token <op> EQUOP2 CMPOP2 ADDOP2 MULOP2
-%token <num> NUMBER
-%type <exp> exp
-
-%%
-
-start: exp
- {
- if ($1 == NULL)
- YYABORT;
- ((struct parse_args *) arg)->res = $1;
- }
- ;
-
-exp: exp '?' exp ':' exp
- {
- $$ = new_exp_3 (qmop, $1, $3, $5);
- }
- | exp '|' exp
- {
- $$ = new_exp_2 (lor, $1, $3);
- }
- | exp '&' exp
- {
- $$ = new_exp_2 (land, $1, $3);
- }
- | exp EQUOP2 exp
- {
- $$ = new_exp_2 ($2, $1, $3);
- }
- | exp CMPOP2 exp
- {
- $$ = new_exp_2 ($2, $1, $3);
- }
- | exp ADDOP2 exp
- {
- $$ = new_exp_2 ($2, $1, $3);
- }
- | exp MULOP2 exp
- {
- $$ = new_exp_2 ($2, $1, $3);
- }
- | '!' exp
- {
- $$ = new_exp_1 (lnot, $2);
- }
- | 'n'
- {
- $$ = new_exp_0 (var);
- }
- | NUMBER
- {
- if (($$ = new_exp_0 (num)) != NULL)
- $$->val.num = $1;
- }
- | '(' exp ')'
- {
- $$ = $2;
- }
- ;
-
-%%
-
-void
-internal_function
-FREE_EXPRESSION (struct expression *exp)
-{
- if (exp == NULL)
- return;
-
- /* Handle the recursive case. */
- switch (exp->nargs)
- {
- case 3:
- FREE_EXPRESSION (exp->val.args[2]);
- /* FALLTHROUGH */
- case 2:
- FREE_EXPRESSION (exp->val.args[1]);
- /* FALLTHROUGH */
- case 1:
- FREE_EXPRESSION (exp->val.args[0]);
- /* FALLTHROUGH */
- default:
- break;
- }
-
- free (exp);
-}
-
-
-static int
-yylex (YYSTYPE *lval, const char **pexp)
-{
- const char *exp = *pexp;
- int result;
-
- while (1)
- {
- if (exp[0] == '\0')
- {
- *pexp = exp;
- return YYEOF;
- }
-
- if (exp[0] != ' ' && exp[0] != '\t')
- break;
-
- ++exp;
- }
-
- result = *exp++;
- switch (result)
- {
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7': case '8': case '9':
- {
- unsigned long int n = result - '0';
- while (exp[0] >= '0' && exp[0] <= '9')
- {
- n *= 10;
- n += exp[0] - '0';
- ++exp;
- }
- lval->num = n;
- result = NUMBER;
- }
- break;
-
- case '=':
- if (exp[0] == '=')
- {
- ++exp;
- lval->op = equal;
- result = EQUOP2;
- }
- else
- result = YYERRCODE;
- break;
-
- case '!':
- if (exp[0] == '=')
- {
- ++exp;
- lval->op = not_equal;
- result = EQUOP2;
- }
- break;
-
- case '&':
- case '|':
- if (exp[0] == result)
- ++exp;
- else
- result = YYERRCODE;
- break;
-
- case '<':
- if (exp[0] == '=')
- {
- ++exp;
- lval->op = less_or_equal;
- }
- else
- lval->op = less_than;
- result = CMPOP2;
- break;
-
- case '>':
- if (exp[0] == '=')
- {
- ++exp;
- lval->op = greater_or_equal;
- }
- else
- lval->op = greater_than;
- result = CMPOP2;
- break;
-
- case '*':
- lval->op = mult;
- result = MULOP2;
- break;
-
- case '/':
- lval->op = divide;
- result = MULOP2;
- break;
-
- case '%':
- lval->op = module;
- result = MULOP2;
- break;
-
- case '+':
- lval->op = plus;
- result = ADDOP2;
- break;
-
- case '-':
- lval->op = minus;
- result = ADDOP2;
- break;
-
- case 'n':
- case '?':
- case ':':
- case '(':
- case ')':
- /* Nothing, just return the character. */
- break;
-
- case ';':
- case '\n':
- case '\0':
- /* Be safe and let the user call this function again. */
- --exp;
- result = YYEOF;
- break;
-
- default:
- result = YYERRCODE;
-#if YYDEBUG != 0
- --exp;
-#endif
- break;
- }
-
- *pexp = exp;
-
- return result;
-}
-
-
-static void
-yyerror (const char *str)
-{
- /* Do nothing. We don't print error messages here. */
-}
diff --git a/navit/support/gettext_intl/printf-args.c b/navit/support/gettext_intl/printf-args.c
deleted file mode 100644
index f6f3219e7..000000000
--- a/navit/support/gettext_intl/printf-args.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* Specification. */
-#include "printf-args.h"
-
-#ifdef STATIC
-STATIC
-#endif
-int
-printf_fetchargs (va_list args, arguments *a)
-{
- size_t i;
- argument *ap;
-
- for (i = 0, ap = &a->arg[0]; i < a->count; i++, ap++)
- switch (ap->type)
- {
- case TYPE_SCHAR:
- ap->a.a_schar = va_arg (args, /*signed char*/ int);
- break;
- case TYPE_UCHAR:
- ap->a.a_uchar = va_arg (args, /*unsigned char*/ int);
- break;
- case TYPE_SHORT:
- ap->a.a_short = va_arg (args, /*short*/ int);
- break;
- case TYPE_USHORT:
- ap->a.a_ushort = va_arg (args, /*unsigned short*/ int);
- break;
- case TYPE_INT:
- ap->a.a_int = va_arg (args, int);
- break;
- case TYPE_UINT:
- ap->a.a_uint = va_arg (args, unsigned int);
- break;
- case TYPE_LONGINT:
- ap->a.a_longint = va_arg (args, long int);
- break;
- case TYPE_ULONGINT:
- ap->a.a_ulongint = va_arg (args, unsigned long int);
- break;
-#ifdef HAVE_LONG_LONG
- case TYPE_LONGLONGINT:
- ap->a.a_longlongint = va_arg (args, long long int);
- break;
- case TYPE_ULONGLONGINT:
- ap->a.a_ulonglongint = va_arg (args, unsigned long long int);
- break;
-#endif
- case TYPE_DOUBLE:
- ap->a.a_double = va_arg (args, double);
- break;
-#ifdef HAVE_LONG_DOUBLE
- case TYPE_LONGDOUBLE:
- ap->a.a_longdouble = va_arg (args, long double);
- break;
-#endif
- case TYPE_CHAR:
- ap->a.a_char = va_arg (args, int);
- break;
-#ifdef HAVE_WINT_T
- case TYPE_WIDE_CHAR:
- ap->a.a_wide_char = va_arg (args, wint_t);
- break;
-#endif
- case TYPE_STRING:
- ap->a.a_string = va_arg (args, const char *);
- break;
-#ifdef HAVE_WCHAR_T
- case TYPE_WIDE_STRING:
- ap->a.a_wide_string = va_arg (args, const wchar_t *);
- break;
-#endif
- case TYPE_POINTER:
- ap->a.a_pointer = va_arg (args, void *);
- break;
- case TYPE_COUNT_SCHAR_POINTER:
- ap->a.a_count_schar_pointer = va_arg (args, signed char *);
- break;
- case TYPE_COUNT_SHORT_POINTER:
- ap->a.a_count_short_pointer = va_arg (args, short *);
- break;
- case TYPE_COUNT_INT_POINTER:
- ap->a.a_count_int_pointer = va_arg (args, int *);
- break;
- case TYPE_COUNT_LONGINT_POINTER:
- ap->a.a_count_longint_pointer = va_arg (args, long int *);
- break;
-#ifdef HAVE_LONG_LONG
- case TYPE_COUNT_LONGLONGINT_POINTER:
- ap->a.a_count_longlongint_pointer = va_arg (args, long long int *);
- break;
-#endif
- default:
- /* Unknown type. */
- return -1;
- }
- return 0;
-}
diff --git a/navit/support/gettext_intl/printf-args.h b/navit/support/gettext_intl/printf-args.h
deleted file mode 100644
index f11e64c04..000000000
--- a/navit/support/gettext_intl/printf-args.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/* Decomposed printf argument list.
- Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _PRINTF_ARGS_H
-#define _PRINTF_ARGS_H
-
-/* Get size_t. */
-#include <stddef.h>
-
-/* Get wchar_t. */
-#ifdef HAVE_WCHAR_T
-# include <stddef.h>
-#endif
-
-/* Get wint_t. */
-#ifdef HAVE_WINT_T
-# include <wchar.h>
-#endif
-
-/* Get va_list. */
-#include <stdarg.h>
-
-
-/* Argument types */
-typedef enum
-{
- TYPE_NONE,
- TYPE_SCHAR,
- TYPE_UCHAR,
- TYPE_SHORT,
- TYPE_USHORT,
- TYPE_INT,
- TYPE_UINT,
- TYPE_LONGINT,
- TYPE_ULONGINT,
-#ifdef HAVE_LONG_LONG
- TYPE_LONGLONGINT,
- TYPE_ULONGLONGINT,
-#endif
- TYPE_DOUBLE,
-#ifdef HAVE_LONG_DOUBLE
- TYPE_LONGDOUBLE,
-#endif
- TYPE_CHAR,
-#ifdef HAVE_WINT_T
- TYPE_WIDE_CHAR,
-#endif
- TYPE_STRING,
-#ifdef HAVE_WCHAR_T
- TYPE_WIDE_STRING,
-#endif
- TYPE_POINTER,
- TYPE_COUNT_SCHAR_POINTER,
- TYPE_COUNT_SHORT_POINTER,
- TYPE_COUNT_INT_POINTER,
- TYPE_COUNT_LONGINT_POINTER
-#ifdef HAVE_LONG_LONG
-, TYPE_COUNT_LONGLONGINT_POINTER
-#endif
-} arg_type;
-
-/* Polymorphic argument */
-typedef struct
-{
- arg_type type;
- union
- {
- signed char a_schar;
- unsigned char a_uchar;
- short a_short;
- unsigned short a_ushort;
- int a_int;
- unsigned int a_uint;
- long int a_longint;
- unsigned long int a_ulongint;
-#ifdef HAVE_LONG_LONG
- long long int a_longlongint;
- unsigned long long int a_ulonglongint;
-#endif
- float a_float;
- double a_double;
-#ifdef HAVE_LONG_DOUBLE
- long double a_longdouble;
-#endif
- int a_char;
-#ifdef HAVE_WINT_T
- wint_t a_wide_char;
-#endif
- const char* a_string;
-#ifdef HAVE_WCHAR_T
- const wchar_t* a_wide_string;
-#endif
- void* a_pointer;
- signed char * a_count_schar_pointer;
- short * a_count_short_pointer;
- int * a_count_int_pointer;
- long int * a_count_longint_pointer;
-#ifdef HAVE_LONG_LONG
- long long int * a_count_longlongint_pointer;
-#endif
- }
- a;
-}
-argument;
-
-typedef struct
-{
- size_t count;
- argument *arg;
-}
-arguments;
-
-
-/* Fetch the arguments, putting them into a. */
-#ifdef STATIC
-STATIC
-#else
-extern
-#endif
-int printf_fetchargs (va_list args, arguments *a);
-
-#endif /* _PRINTF_ARGS_H */
diff --git a/navit/support/gettext_intl/printf-parse.c b/navit/support/gettext_intl/printf-parse.c
deleted file mode 100644
index d19f903d7..000000000
--- a/navit/support/gettext_intl/printf-parse.c
+++ /dev/null
@@ -1,537 +0,0 @@
-/* Formatted output to strings.
- Copyright (C) 1999-2000, 2002-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* Specification. */
-#if WIDE_CHAR_VERSION
-# include "wprintf-parse.h"
-#else
-# include "printf-parse.h"
-#endif
-
-/* Get size_t, NULL. */
-#include <stddef.h>
-
-/* Get intmax_t. */
-#if HAVE_STDINT_H_WITH_UINTMAX
-# include <stdint.h>
-#endif
-#if HAVE_INTTYPES_H_WITH_UINTMAX
-# include <inttypes.h>
-#endif
-
-/* malloc(), realloc(), free(). */
-#include <stdlib.h>
-
-/* Checked size_t computations. */
-#include "xsize.h"
-
-#if WIDE_CHAR_VERSION
-# define PRINTF_PARSE wprintf_parse
-# define CHAR_T wchar_t
-# define DIRECTIVE wchar_t_directive
-# define DIRECTIVES wchar_t_directives
-#else
-# define PRINTF_PARSE printf_parse
-# define CHAR_T char
-# define DIRECTIVE char_directive
-# define DIRECTIVES char_directives
-#endif
-
-#ifdef STATIC
-STATIC
-#endif
-int
-PRINTF_PARSE (const CHAR_T *format, DIRECTIVES *d, arguments *a)
-{
- const CHAR_T *cp = format; /* pointer into format */
- size_t arg_posn = 0; /* number of regular arguments consumed */
- size_t d_allocated; /* allocated elements of d->dir */
- size_t a_allocated; /* allocated elements of a->arg */
- size_t max_width_length = 0;
- size_t max_precision_length = 0;
-
- d->count = 0;
- d_allocated = 1;
- d->dir = malloc (d_allocated * sizeof (DIRECTIVE));
- if (d->dir == NULL)
- /* Out of memory. */
- return -1;
-
- a->count = 0;
- a_allocated = 0;
- a->arg = NULL;
-
-#define REGISTER_ARG(_index_,_type_) \
- { \
- size_t n = (_index_); \
- if (n >= a_allocated) \
- { \
- size_t memory_size; \
- argument *memory; \
- \
- a_allocated = xtimes (a_allocated, 2); \
- if (a_allocated <= n) \
- a_allocated = xsum (n, 1); \
- memory_size = xtimes (a_allocated, sizeof (argument)); \
- if (size_overflow_p (memory_size)) \
- /* Overflow, would lead to out of memory. */ \
- goto error; \
- memory = (a->arg \
- ? realloc (a->arg, memory_size) \
- : malloc (memory_size)); \
- if (memory == NULL) \
- /* Out of memory. */ \
- goto error; \
- a->arg = memory; \
- } \
- while (a->count <= n) \
- a->arg[a->count++].type = TYPE_NONE; \
- if (a->arg[n].type == TYPE_NONE) \
- a->arg[n].type = (_type_); \
- else if (a->arg[n].type != (_type_)) \
- /* Ambiguous type for positional argument. */ \
- goto error; \
- }
-
- while (*cp != '\0')
- {
- CHAR_T c = *cp++;
- if (c == '%')
- {
- size_t arg_index = ARG_NONE;
- DIRECTIVE *dp = &d->dir[d->count];/* pointer to next directive */
-
- /* Initialize the next directive. */
- dp->dir_start = cp - 1;
- dp->flags = 0;
- dp->width_start = NULL;
- dp->width_end = NULL;
- dp->width_arg_index = ARG_NONE;
- dp->precision_start = NULL;
- dp->precision_end = NULL;
- dp->precision_arg_index = ARG_NONE;
- dp->arg_index = ARG_NONE;
-
- /* Test for positional argument. */
- if (*cp >= '0' && *cp <= '9')
- {
- const CHAR_T *np;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- ;
- if (*np == '$')
- {
- size_t n = 0;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- n = xsum (xtimes (n, 10), *np - '0');
- if (n == 0)
- /* Positional argument 0. */
- goto error;
- if (size_overflow_p (n))
- /* n too large, would lead to out of memory later. */
- goto error;
- arg_index = n - 1;
- cp = np + 1;
- }
- }
-
- /* Read the flags. */
- for (;;)
- {
- if (*cp == '\'')
- {
- dp->flags |= FLAG_GROUP;
- cp++;
- }
- else if (*cp == '-')
- {
- dp->flags |= FLAG_LEFT;
- cp++;
- }
- else if (*cp == '+')
- {
- dp->flags |= FLAG_SHOWSIGN;
- cp++;
- }
- else if (*cp == ' ')
- {
- dp->flags |= FLAG_SPACE;
- cp++;
- }
- else if (*cp == '#')
- {
- dp->flags |= FLAG_ALT;
- cp++;
- }
- else if (*cp == '0')
- {
- dp->flags |= FLAG_ZERO;
- cp++;
- }
- else
- break;
- }
-
- /* Parse the field width. */
- if (*cp == '*')
- {
- dp->width_start = cp;
- cp++;
- dp->width_end = cp;
- if (max_width_length < 1)
- max_width_length = 1;
-
- /* Test for positional argument. */
- if (*cp >= '0' && *cp <= '9')
- {
- const CHAR_T *np;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- ;
- if (*np == '$')
- {
- size_t n = 0;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- n = xsum (xtimes (n, 10), *np - '0');
- if (n == 0)
- /* Positional argument 0. */
- goto error;
- if (size_overflow_p (n))
- /* n too large, would lead to out of memory later. */
- goto error;
- dp->width_arg_index = n - 1;
- cp = np + 1;
- }
- }
- if (dp->width_arg_index == ARG_NONE)
- {
- dp->width_arg_index = arg_posn++;
- if (dp->width_arg_index == ARG_NONE)
- /* arg_posn wrapped around. */
- goto error;
- }
- REGISTER_ARG (dp->width_arg_index, TYPE_INT);
- }
- else if (*cp >= '0' && *cp <= '9')
- {
- size_t width_length;
-
- dp->width_start = cp;
- for (; *cp >= '0' && *cp <= '9'; cp++)
- ;
- dp->width_end = cp;
- width_length = dp->width_end - dp->width_start;
- if (max_width_length < width_length)
- max_width_length = width_length;
- }
-
- /* Parse the precision. */
- if (*cp == '.')
- {
- cp++;
- if (*cp == '*')
- {
- dp->precision_start = cp - 1;
- cp++;
- dp->precision_end = cp;
- if (max_precision_length < 2)
- max_precision_length = 2;
-
- /* Test for positional argument. */
- if (*cp >= '0' && *cp <= '9')
- {
- const CHAR_T *np;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- ;
- if (*np == '$')
- {
- size_t n = 0;
-
- for (np = cp; *np >= '0' && *np <= '9'; np++)
- n = xsum (xtimes (n, 10), *np - '0');
- if (n == 0)
- /* Positional argument 0. */
- goto error;
- if (size_overflow_p (n))
- /* n too large, would lead to out of memory
- later. */
- goto error;
- dp->precision_arg_index = n - 1;
- cp = np + 1;
- }
- }
- if (dp->precision_arg_index == ARG_NONE)
- {
- dp->precision_arg_index = arg_posn++;
- if (dp->precision_arg_index == ARG_NONE)
- /* arg_posn wrapped around. */
- goto error;
- }
- REGISTER_ARG (dp->precision_arg_index, TYPE_INT);
- }
- else
- {
- size_t precision_length;
-
- dp->precision_start = cp - 1;
- for (; *cp >= '0' && *cp <= '9'; cp++)
- ;
- dp->precision_end = cp;
- precision_length = dp->precision_end - dp->precision_start;
- if (max_precision_length < precision_length)
- max_precision_length = precision_length;
- }
- }
-
- {
- arg_type type;
-
- /* Parse argument type/size specifiers. */
- {
- int flags = 0;
-
- for (;;)
- {
- if (*cp == 'h')
- {
- flags |= (1 << (flags & 1));
- cp++;
- }
- else if (*cp == 'L')
- {
- flags |= 4;
- cp++;
- }
- else if (*cp == 'l')
- {
- flags += 8;
- cp++;
- }
-#ifdef HAVE_INTMAX_T
- else if (*cp == 'j')
- {
- if (sizeof (intmax_t) > sizeof (long))
- {
- /* intmax_t = long long */
- flags += 16;
- }
- else if (sizeof (intmax_t) > sizeof (int))
- {
- /* intmax_t = long */
- flags += 8;
- }
- cp++;
- }
-#endif
- else if (*cp == 'z' || *cp == 'Z')
- {
- /* 'z' is standardized in ISO C 99, but glibc uses 'Z'
- because the warning facility in gcc-2.95.2 understands
- only 'Z' (see gcc-2.95.2/gcc/c-common.c:1784). */
- if (sizeof (size_t) > sizeof (long))
- {
- /* size_t = long long */
- flags += 16;
- }
- else if (sizeof (size_t) > sizeof (int))
- {
- /* size_t = long */
- flags += 8;
- }
- cp++;
- }
- else if (*cp == 't')
- {
- if (sizeof (ptrdiff_t) > sizeof (long))
- {
- /* ptrdiff_t = long long */
- flags += 16;
- }
- else if (sizeof (ptrdiff_t) > sizeof (int))
- {
- /* ptrdiff_t = long */
- flags += 8;
- }
- cp++;
- }
- else
- break;
- }
-
- /* Read the conversion character. */
- c = *cp++;
- switch (c)
- {
- case 'd': case 'i':
-#ifdef HAVE_LONG_LONG
- if (flags >= 16 || (flags & 4))
- type = TYPE_LONGLONGINT;
- else
-#endif
- if (flags >= 8)
- type = TYPE_LONGINT;
- else if (flags & 2)
- type = TYPE_SCHAR;
- else if (flags & 1)
- type = TYPE_SHORT;
- else
- type = TYPE_INT;
- break;
- case 'o': case 'u': case 'x': case 'X':
-#ifdef HAVE_LONG_LONG
- if (flags >= 16 || (flags & 4))
- type = TYPE_ULONGLONGINT;
- else
-#endif
- if (flags >= 8)
- type = TYPE_ULONGINT;
- else if (flags & 2)
- type = TYPE_UCHAR;
- else if (flags & 1)
- type = TYPE_USHORT;
- else
- type = TYPE_UINT;
- break;
- case 'f': case 'F': case 'e': case 'E': case 'g': case 'G':
- case 'a': case 'A':
-#ifdef HAVE_LONG_DOUBLE
- if (flags >= 16 || (flags & 4))
- type = TYPE_LONGDOUBLE;
- else
-#endif
- type = TYPE_DOUBLE;
- break;
- case 'c':
- if (flags >= 8)
-#ifdef HAVE_WINT_T
- type = TYPE_WIDE_CHAR;
-#else
- goto error;
-#endif
- else
- type = TYPE_CHAR;
- break;
-#ifdef HAVE_WINT_T
- case 'C':
- type = TYPE_WIDE_CHAR;
- c = 'c';
- break;
-#endif
- case 's':
- if (flags >= 8)
-#ifdef HAVE_WCHAR_T
- type = TYPE_WIDE_STRING;
-#else
- goto error;
-#endif
- else
- type = TYPE_STRING;
- break;
-#ifdef HAVE_WCHAR_T
- case 'S':
- type = TYPE_WIDE_STRING;
- c = 's';
- break;
-#endif
- case 'p':
- type = TYPE_POINTER;
- break;
- case 'n':
-#ifdef HAVE_LONG_LONG
- if (flags >= 16 || (flags & 4))
- type = TYPE_COUNT_LONGLONGINT_POINTER;
- else
-#endif
- if (flags >= 8)
- type = TYPE_COUNT_LONGINT_POINTER;
- else if (flags & 2)
- type = TYPE_COUNT_SCHAR_POINTER;
- else if (flags & 1)
- type = TYPE_COUNT_SHORT_POINTER;
- else
- type = TYPE_COUNT_INT_POINTER;
- break;
- case '%':
- type = TYPE_NONE;
- break;
- default:
- /* Unknown conversion character. */
- goto error;
- }
- }
-
- if (type != TYPE_NONE)
- {
- dp->arg_index = arg_index;
- if (dp->arg_index == ARG_NONE)
- {
- dp->arg_index = arg_posn++;
- if (dp->arg_index == ARG_NONE)
- /* arg_posn wrapped around. */
- goto error;
- }
- REGISTER_ARG (dp->arg_index, type);
- }
- dp->conversion = c;
- dp->dir_end = cp;
- }
-
- d->count++;
- if (d->count >= d_allocated)
- {
- size_t memory_size;
- DIRECTIVE *memory;
-
- d_allocated = xtimes (d_allocated, 2);
- memory_size = xtimes (d_allocated, sizeof (DIRECTIVE));
- if (size_overflow_p (memory_size))
- /* Overflow, would lead to out of memory. */
- goto error;
- memory = realloc (d->dir, memory_size);
- if (memory == NULL)
- /* Out of memory. */
- goto error;
- d->dir = memory;
- }
- }
- }
- d->dir[d->count].dir_start = cp;
-
- d->max_width_length = max_width_length;
- d->max_precision_length = max_precision_length;
- return 0;
-
-error:
- if (a->arg)
- free (a->arg);
- if (d->dir)
- free (d->dir);
- return -1;
-}
-
-#undef DIRECTIVES
-#undef DIRECTIVE
-#undef CHAR_T
-#undef PRINTF_PARSE
diff --git a/navit/support/gettext_intl/printf-parse.h b/navit/support/gettext_intl/printf-parse.h
deleted file mode 100644
index 8aec50e2a..000000000
--- a/navit/support/gettext_intl/printf-parse.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Parse printf format string.
- Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _PRINTF_PARSE_H
-#define _PRINTF_PARSE_H
-
-#include "printf-args.h"
-
-
-/* Flags */
-#define FLAG_GROUP 1 /* ' flag */
-#define FLAG_LEFT 2 /* - flag */
-#define FLAG_SHOWSIGN 4 /* + flag */
-#define FLAG_SPACE 8 /* space flag */
-#define FLAG_ALT 16 /* # flag */
-#define FLAG_ZERO 32
-
-/* arg_index value indicating that no argument is consumed. */
-#define ARG_NONE (~(size_t)0)
-
-/* A parsed directive. */
-typedef struct
-{
- const char* dir_start;
- const char* dir_end;
- int flags;
- const char* width_start;
- const char* width_end;
- size_t width_arg_index;
- const char* precision_start;
- const char* precision_end;
- size_t precision_arg_index;
- char conversion; /* d i o u x X f e E g G c s p n U % but not C S */
- size_t arg_index;
-}
-char_directive;
-
-/* A parsed format string. */
-typedef struct
-{
- size_t count;
- char_directive *dir;
- size_t max_width_length;
- size_t max_precision_length;
-}
-char_directives;
-
-
-/* Parses the format string. Fills in the number N of directives, and fills
- in directives[0], ..., directives[N-1], and sets directives[N].dir_start
- to the end of the format string. Also fills in the arg_type fields of the
- arguments and the needed count of arguments. */
-#ifdef STATIC
-STATIC
-#else
-extern
-#endif
-int printf_parse (const char *format, char_directives *d, arguments *a);
-
-#endif /* _PRINTF_PARSE_H */
diff --git a/navit/support/gettext_intl/printf.c b/navit/support/gettext_intl/printf.c
deleted file mode 100644
index 8e5840137..000000000
--- a/navit/support/gettext_intl/printf.c
+++ /dev/null
@@ -1,373 +0,0 @@
-/* Formatted output to strings, using POSIX/XSI format strings with positions.
- Copyright (C) 2003 Free Software Foundation, Inc.
- Written by Bruno Haible <bruno@clisp.org>, 2003.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-
-#ifdef __GNUC__
-# undef alloca
-# define alloca __builtin_alloca
-# define HAVE_ALLOCA 1
-#else
-# ifdef _MSC_VER
-# include <malloc.h>
-# define alloca _alloca
-# else
-# if defined HAVE_ALLOCA_H || defined _LIBC
-# include <alloca.h>
-# else
-# ifdef _AIX
- #pragma alloca
-# else
-# ifndef alloca
-char *alloca ();
-# endif
-# endif
-# endif
-# endif
-#endif
-
-#include <stdio.h>
-
-#if !HAVE_POSIX_PRINTF
-
-#include <string.h>
-
-/* When building a DLL, we must export some functions. Note that because
- the functions are only defined for binary backward compatibility, we
- don't need to use __declspec(dllimport) in any case. */
-#if defined _MSC_VER && BUILDING_DLL
-# define DLL_EXPORTED __declspec(dllexport)
-#else
-# define DLL_EXPORTED
-#endif
-
-#define STATIC static
-
-/* Define auxiliary functions declared in "printf-args.h". */
-#include "printf-args.c"
-
-/* Define auxiliary functions declared in "printf-parse.h". */
-#include "printf-parse.c"
-
-/* Define functions declared in "vasnprintf.h". */
-#define vasnprintf libintl_vasnprintf
-#include "vasnprintf.c"
-#if 0 /* not needed */
-#define asnprintf libintl_asnprintf
-#include "asnprintf.c"
-#endif
-
-DLL_EXPORTED
-int
-libintl_vfprintf (FILE *stream, const char *format, va_list args)
-{
- if (strchr (format, '$') == NULL)
- return vfprintf (stream, format, args);
- else
- {
- size_t length;
- char *result = libintl_vasnprintf (NULL, &length, format, args);
- int retval = -1;
- if (result != NULL)
- {
- if (fwrite (result, 1, length, stream) == length)
- retval = length;
- free (result);
- }
- return retval;
- }
-}
-
-DLL_EXPORTED
-int
-libintl_fprintf (FILE *stream, const char *format, ...)
-{
- va_list args;
- int retval;
-
- va_start (args, format);
- retval = libintl_vfprintf (stream, format, args);
- va_end (args);
- return retval;
-}
-
-DLL_EXPORTED
-int
-libintl_vprintf (const char *format, va_list args)
-{
- return libintl_vfprintf (stdout, format, args);
-}
-
-DLL_EXPORTED
-int
-libintl_printf (const char *format, ...)
-{
- va_list args;
- int retval;
-
- va_start (args, format);
- retval = libintl_vprintf (format, args);
- va_end (args);
- return retval;
-}
-
-DLL_EXPORTED
-int
-libintl_vsprintf (char *resultbuf, const char *format, va_list args)
-{
- if (strchr (format, '$') == NULL)
- return vsprintf (resultbuf, format, args);
- else
- {
- size_t length = (size_t) ~0 / (4 * sizeof (char));
- char *result = libintl_vasnprintf (resultbuf, &length, format, args);
- if (result != resultbuf)
- {
- free (result);
- return -1;
- }
- else
- return length;
- }
-}
-
-DLL_EXPORTED
-int
-libintl_sprintf (char *resultbuf, const char *format, ...)
-{
- va_list args;
- int retval;
-
- va_start (args, format);
- retval = libintl_vsprintf (resultbuf, format, args);
- va_end (args);
- return retval;
-}
-
-#if HAVE_SNPRINTF
-
-# if HAVE_DECL__SNPRINTF
- /* Windows. */
-# define system_vsnprintf _vsnprintf
-# else
- /* Unix. */
-# define system_vsnprintf vsnprintf
-# endif
-
-DLL_EXPORTED
-int
-libintl_vsnprintf (char *resultbuf, size_t length, const char *format, va_list args)
-{
- if (strchr (format, '$') == NULL)
- return system_vsnprintf (resultbuf, length, format, args);
- else
- {
- size_t maxlength = length;
- char *result = libintl_vasnprintf (resultbuf, &length, format, args);
- if (result != resultbuf)
- {
- if (maxlength > 0)
- {
- if (length < maxlength)
- abort ();
- memcpy (resultbuf, result, maxlength - 1);
- resultbuf[maxlength - 1] = '\0';
- }
- free (result);
- return -1;
- }
- else
- return length;
- }
-}
-
-DLL_EXPORTED
-int
-libintl_snprintf (char *resultbuf, size_t length, const char *format, ...)
-{
- va_list args;
- int retval;
-
- va_start (args, format);
- retval = libintl_vsnprintf (resultbuf, length, format, args);
- va_end (args);
- return retval;
-}
-
-#endif
-
-#if HAVE_ASPRINTF
-
-DLL_EXPORTED
-int
-libintl_vasprintf (char **resultp, const char *format, va_list args)
-{
- size_t length;
- char *result = libintl_vasnprintf (NULL, &length, format, args);
- if (result == NULL)
- return -1;
- *resultp = result;
- return length;
-}
-
-DLL_EXPORTED
-int
-libintl_asprintf (char **resultp, const char *format, ...)
-{
- va_list args;
- int retval;
-
- va_start (args, format);
- retval = libintl_vasprintf (resultp, format, args);
- va_end (args);
- return retval;
-}
-
-#endif
-
-#if HAVE_FWPRINTF
-
-#include <wchar.h>
-
-#define WIDE_CHAR_VERSION 1
-
-/* Define auxiliary functions declared in "wprintf-parse.h". */
-#include "printf-parse.c"
-
-/* Define functions declared in "vasnprintf.h". */
-#define vasnwprintf libintl_vasnwprintf
-#include "vasnprintf.c"
-#if 0 /* not needed */
-#define asnwprintf libintl_asnwprintf
-#include "asnprintf.c"
-#endif
-
-# if HAVE_DECL__SNWPRINTF
- /* Windows. */
-# define system_vswprintf _vsnwprintf
-# else
- /* Unix. */
-# define system_vswprintf vswprintf
-# endif
-
-DLL_EXPORTED
-int
-libintl_vfwprintf (FILE *stream, const wchar_t *format, va_list args)
-{
- if (wcschr (format, '$') == NULL)
- return vfwprintf (stream, format, args);
- else
- {
- size_t length;
- wchar_t *result = libintl_vasnwprintf (NULL, &length, format, args);
- int retval = -1;
- if (result != NULL)
- {
- size_t i;
- for (i = 0; i < length; i++)
- if (fputwc (result[i], stream) == WEOF)
- break;
- if (i == length)
- retval = length;
- free (result);
- }
- return retval;
- }
-}
-
-DLL_EXPORTED
-int
-libintl_fwprintf (FILE *stream, const wchar_t *format, ...)
-{
- va_list args;
- int retval;
-
- va_start (args, format);
- retval = libintl_vfwprintf (stream, format, args);
- va_end (args);
- return retval;
-}
-
-DLL_EXPORTED
-int
-libintl_vwprintf (const wchar_t *format, va_list args)
-{
- return libintl_vfwprintf (stdout, format, args);
-}
-
-DLL_EXPORTED
-int
-libintl_wprintf (const wchar_t *format, ...)
-{
- va_list args;
- int retval;
-
- va_start (args, format);
- retval = libintl_vwprintf (format, args);
- va_end (args);
- return retval;
-}
-
-DLL_EXPORTED
-int
-libintl_vswprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, va_list args)
-{
- if (wcschr (format, '$') == NULL)
- return system_vswprintf (resultbuf, length, format, args);
- else
- {
- size_t maxlength = length;
- wchar_t *result = libintl_vasnwprintf (resultbuf, &length, format, args);
- if (result != resultbuf)
- {
- if (maxlength > 0)
- {
- if (length < maxlength)
- abort ();
- memcpy (resultbuf, result, (maxlength - 1) * sizeof (wchar_t));
- resultbuf[maxlength - 1] = 0;
- }
- free (result);
- return -1;
- }
- else
- return length;
- }
-}
-
-DLL_EXPORTED
-int
-libintl_swprintf (wchar_t *resultbuf, size_t length, const wchar_t *format, ...)
-{
- va_list args;
- int retval;
-
- va_start (args, format);
- retval = libintl_vswprintf (resultbuf, length, format, args);
- va_end (args);
- return retval;
-}
-
-#endif
-
-#endif
diff --git a/navit/support/gettext_intl/ref-add.sin b/navit/support/gettext_intl/ref-add.sin
deleted file mode 100644
index 167374e3c..000000000
--- a/navit/support/gettext_intl/ref-add.sin
+++ /dev/null
@@ -1,31 +0,0 @@
-# Add this package to a list of references stored in a text file.
-#
-# Copyright (C) 2000 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Library 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
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-# USA.
-#
-# Written by Bruno Haible <haible@clisp.cons.org>.
-#
-/^# Packages using this file: / {
- s/# Packages using this file://
- ta
- :a
- s/ @PACKAGE@ / @PACKAGE@ /
- tb
- s/ $/ @PACKAGE@ /
- :b
- s/^/# Packages using this file:/
-}
diff --git a/navit/support/gettext_intl/ref-del.sin b/navit/support/gettext_intl/ref-del.sin
deleted file mode 100644
index 613cf37f3..000000000
--- a/navit/support/gettext_intl/ref-del.sin
+++ /dev/null
@@ -1,26 +0,0 @@
-# Remove this package from a list of references stored in a text file.
-#
-# Copyright (C) 2000 Free Software Foundation, Inc.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms of the GNU Library 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
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-# USA.
-#
-# Written by Bruno Haible <haible@clisp.cons.org>.
-#
-/^# Packages using this file: / {
- s/# Packages using this file://
- s/ @PACKAGE@ / /
- s/^/# Packages using this file:/
-}
diff --git a/navit/support/gettext_intl/relocatable.c b/navit/support/gettext_intl/relocatable.c
deleted file mode 100644
index b49446f3c..000000000
--- a/navit/support/gettext_intl/relocatable.c
+++ /dev/null
@@ -1,449 +0,0 @@
-/* Provide relocatable packages.
- Copyright (C) 2003 Free Software Foundation, Inc.
- Written by Bruno Haible <bruno@clisp.org>, 2003.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-
-/* Tell glibc's <stdio.h> to provide a prototype for getline().
- This must come before <config.h> because <config.h> may include
- <features.h>, and once <features.h> has been included, it's too late. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-/* Specification. */
-#include "relocatable.h"
-
-#if ENABLE_RELOCATABLE
-
-#include <stddef.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef NO_XMALLOC
-# define xmalloc malloc
-#else
-# include "xalloc.h"
-#endif
-
-#if defined _WIN32 || defined __WIN32__
-# define WIN32_LEAN_AND_MEAN
-# include <windows.h>
-#endif
-
-#if DEPENDS_ON_LIBCHARSET
-# include <libcharset.h>
-#endif
-#if DEPENDS_ON_LIBICONV && HAVE_ICONV
-# include <iconv.h>
-#endif
-#if DEPENDS_ON_LIBINTL && USE_NATIVE_LANGUAGE_SUPPORT
-# include <libintl.h>
-#endif
-
-/* Faked cheap 'bool'. */
-#undef bool
-#undef false
-#undef true
-#define bool int
-#define false 0
-#define true 1
-
-/* Pathname support.
- ISSLASH(C) tests whether C is a directory separator character.
- IS_PATH_WITH_DIR(P) tests whether P contains a directory specification.
- */
-#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
- /* Win32, OS/2, DOS */
-# define ISSLASH(C) ((C) == '/' || (C) == '\\')
-# define HAS_DEVICE(P) \
- ((((P)[0] >= 'A' && (P)[0] <= 'Z') || ((P)[0] >= 'a' && (P)[0] <= 'z')) \
- && (P)[1] == ':')
-# define IS_PATH_WITH_DIR(P) \
- (strchr (P, '/') != NULL || strchr (P, '\\') != NULL || HAS_DEVICE (P))
-# define FILESYSTEM_PREFIX_LEN(P) (HAS_DEVICE (P) ? 2 : 0)
-#else
- /* Unix */
-# define ISSLASH(C) ((C) == '/')
-# define IS_PATH_WITH_DIR(P) (strchr (P, '/') != NULL)
-# define FILESYSTEM_PREFIX_LEN(P) 0
-#endif
-
-/* Original installation prefix. */
-static char *orig_prefix;
-static size_t orig_prefix_len;
-/* Current installation prefix. */
-static char *curr_prefix;
-static size_t curr_prefix_len;
-/* These prefixes do not end in a slash. Anything that will be concatenated
- to them must start with a slash. */
-
-/* Sets the original and the current installation prefix of this module.
- Relocation simply replaces a pathname starting with the original prefix
- by the corresponding pathname with the current prefix instead. Both
- prefixes should be directory names without trailing slash (i.e. use ""
- instead of "/"). */
-static void
-set_this_relocation_prefix (const char *orig_prefix_arg,
- const char *curr_prefix_arg)
-{
- if (orig_prefix_arg != NULL && curr_prefix_arg != NULL
- /* Optimization: if orig_prefix and curr_prefix are equal, the
- relocation is a nop. */
- && strcmp (orig_prefix_arg, curr_prefix_arg) != 0)
- {
- /* Duplicate the argument strings. */
- char *memory;
-
- orig_prefix_len = strlen (orig_prefix_arg);
- curr_prefix_len = strlen (curr_prefix_arg);
- memory = (char *) xmalloc (orig_prefix_len + 1 + curr_prefix_len + 1);
-#ifdef NO_XMALLOC
- if (memory != NULL)
-#endif
- {
- memcpy (memory, orig_prefix_arg, orig_prefix_len + 1);
- orig_prefix = memory;
- memory += orig_prefix_len + 1;
- memcpy (memory, curr_prefix_arg, curr_prefix_len + 1);
- curr_prefix = memory;
- return;
- }
- }
- orig_prefix = NULL;
- curr_prefix = NULL;
- /* Don't worry about wasted memory here - this function is usually only
- called once. */
-}
-
-/* Sets the original and the current installation prefix of the package.
- Relocation simply replaces a pathname starting with the original prefix
- by the corresponding pathname with the current prefix instead. Both
- prefixes should be directory names without trailing slash (i.e. use ""
- instead of "/"). */
-void
-set_relocation_prefix (const char *orig_prefix_arg, const char *curr_prefix_arg)
-{
- set_this_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
-
- /* Now notify all dependent libraries. */
-#if DEPENDS_ON_LIBCHARSET
- libcharset_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
-#endif
-#if DEPENDS_ON_LIBICONV && HAVE_ICONV && _LIBICONV_VERSION >= 0x0109
- libiconv_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
-#endif
-#if DEPENDS_ON_LIBINTL && USE_NATIVE_LANGUAGE_SUPPORT && defined libintl_set_relocation_prefix
- libintl_set_relocation_prefix (orig_prefix_arg, curr_prefix_arg);
-#endif
-}
-
-#if !defined IN_LIBRARY || (defined PIC && defined INSTALLDIR)
-
-/* Convenience function:
- Computes the current installation prefix, based on the original
- installation prefix, the original installation directory of a particular
- file, and the current pathname of this file. Returns NULL upon failure. */
-#ifdef IN_LIBRARY
-#define compute_curr_prefix local_compute_curr_prefix
-static
-#endif
-const char *
-compute_curr_prefix (const char *orig_installprefix,
- const char *orig_installdir,
- const char *curr_pathname)
-{
- const char *curr_installdir;
- const char *rel_installdir;
-
- if (curr_pathname == NULL)
- return NULL;
-
- /* Determine the relative installation directory, relative to the prefix.
- This is simply the difference between orig_installprefix and
- orig_installdir. */
- if (strncmp (orig_installprefix, orig_installdir, strlen (orig_installprefix))
- != 0)
- /* Shouldn't happen - nothing should be installed outside $(prefix). */
- return NULL;
- rel_installdir = orig_installdir + strlen (orig_installprefix);
-
- /* Determine the current installation directory. */
- {
- const char *p_base = curr_pathname + FILESYSTEM_PREFIX_LEN (curr_pathname);
- const char *p = curr_pathname + strlen (curr_pathname);
- char *q;
-
- while (p > p_base)
- {
- p--;
- if (ISSLASH (*p))
- break;
- }
-
- q = (char *) xmalloc (p - curr_pathname + 1);
-#ifdef NO_XMALLOC
- if (q == NULL)
- return NULL;
-#endif
- memcpy (q, curr_pathname, p - curr_pathname);
- q[p - curr_pathname] = '\0';
- curr_installdir = q;
- }
-
- /* Compute the current installation prefix by removing the trailing
- rel_installdir from it. */
- {
- const char *rp = rel_installdir + strlen (rel_installdir);
- const char *cp = curr_installdir + strlen (curr_installdir);
- const char *cp_base =
- curr_installdir + FILESYSTEM_PREFIX_LEN (curr_installdir);
-
- while (rp > rel_installdir && cp > cp_base)
- {
- bool same = false;
- const char *rpi = rp;
- const char *cpi = cp;
-
- while (rpi > rel_installdir && cpi > cp_base)
- {
- rpi--;
- cpi--;
- if (ISSLASH (*rpi) || ISSLASH (*cpi))
- {
- if (ISSLASH (*rpi) && ISSLASH (*cpi))
- same = true;
- break;
- }
-#if defined _WIN32 || defined __WIN32__ || defined __EMX__ || defined __DJGPP__
- /* Win32, OS/2, DOS - case insignificant filesystem */
- if ((*rpi >= 'a' && *rpi <= 'z' ? *rpi - 'a' + 'A' : *rpi)
- != (*cpi >= 'a' && *cpi <= 'z' ? *cpi - 'a' + 'A' : *cpi))
- break;
-#else
- if (*rpi != *cpi)
- break;
-#endif
- }
- if (!same)
- break;
- /* The last pathname component was the same. opi and cpi now point
- to the slash before it. */
- rp = rpi;
- cp = cpi;
- }
-
- if (rp > rel_installdir)
- /* Unexpected: The curr_installdir does not end with rel_installdir. */
- return NULL;
-
- {
- size_t curr_prefix_len = cp - curr_installdir;
- char *curr_prefix;
-
- curr_prefix = (char *) xmalloc (curr_prefix_len + 1);
-#ifdef NO_XMALLOC
- if (curr_prefix == NULL)
- return NULL;
-#endif
- memcpy (curr_prefix, curr_installdir, curr_prefix_len);
- curr_prefix[curr_prefix_len] = '\0';
-
- return curr_prefix;
- }
- }
-}
-
-#endif /* !IN_LIBRARY || PIC */
-
-#if defined PIC && defined INSTALLDIR
-
-/* Full pathname of shared library, or NULL. */
-static char *shared_library_fullname;
-
-#if defined _WIN32 || defined __WIN32__
-
-/* Determine the full pathname of the shared library when it is loaded. */
-
-BOOL WINAPI
-DllMain (HINSTANCE module_handle, DWORD event, LPVOID reserved)
-{
- (void) reserved;
-
- if (event == DLL_PROCESS_ATTACH)
- {
- /* The DLL is being loaded into an application's address range. */
- static char location[MAX_PATH];
-
- if (!GetModuleFileName (module_handle, location, sizeof (location)))
- /* Shouldn't happen. */
- return FALSE;
-
- if (!IS_PATH_WITH_DIR (location))
- /* Shouldn't happen. */
- return FALSE;
-
- shared_library_fullname = strdup (location);
- }
-
- return TRUE;
-}
-
-#else /* Unix */
-
-static void
-find_shared_library_fullname ()
-{
-#if defined __linux__ && __GLIBC__ >= 2
- /* Linux has /proc/self/maps. glibc 2 has the getline() function. */
- FILE *fp;
-
- /* Open the current process' maps file. It describes one VMA per line. */
- fp = fopen ("/proc/self/maps", "r");
- if (fp)
- {
- unsigned long address = (unsigned long) &find_shared_library_fullname;
- for (;;)
- {
- unsigned long start, end;
- int c;
-
- if (fscanf (fp, "%lx-%lx", &start, &end) != 2)
- break;
- if (address >= start && address <= end - 1)
- {
- /* Found it. Now see if this line contains a filename. */
- while (c = getc (fp), c != EOF && c != '\n' && c != '/')
- continue;
- if (c == '/')
- {
- size_t size;
- int len;
-
- ungetc (c, fp);
- shared_library_fullname = NULL; size = 0;
- len = getline (&shared_library_fullname, &size, fp);
- if (len >= 0)
- {
- /* Success: filled shared_library_fullname. */
- if (len > 0 && shared_library_fullname[len - 1] == '\n')
- shared_library_fullname[len - 1] = '\0';
- }
- }
- break;
- }
- while (c = getc (fp), c != EOF && c != '\n')
- continue;
- }
- fclose (fp);
- }
-#endif
-}
-
-#endif /* WIN32 / Unix */
-
-/* Return the full pathname of the current shared library.
- Return NULL if unknown.
- Guaranteed to work only on Linux and Woe32. */
-static char *
-get_shared_library_fullname ()
-{
-#if !(defined _WIN32 || defined __WIN32__)
- static bool tried_find_shared_library_fullname;
- if (!tried_find_shared_library_fullname)
- {
- find_shared_library_fullname ();
- tried_find_shared_library_fullname = true;
- }
-#endif
- return shared_library_fullname;
-}
-
-#endif /* PIC */
-
-/* Returns the pathname, relocated according to the current installation
- directory. */
-const char *
-relocate (const char *pathname)
-{
-#if defined PIC && defined INSTALLDIR
- static int initialized;
-
- /* Initialization code for a shared library. */
- if (!initialized)
- {
- /* At this point, orig_prefix and curr_prefix likely have already been
- set through the main program's set_program_name_and_installdir
- function. This is sufficient in the case that the library has
- initially been installed in the same orig_prefix. But we can do
- better, to also cover the cases that 1. it has been installed
- in a different prefix before being moved to orig_prefix and (later)
- to curr_prefix, 2. unlike the program, it has not moved away from
- orig_prefix. */
- const char *orig_installprefix = INSTALLPREFIX;
- const char *orig_installdir = INSTALLDIR;
- const char *curr_prefix_better;
-
- curr_prefix_better =
- compute_curr_prefix (orig_installprefix, orig_installdir,
- get_shared_library_fullname ());
- if (curr_prefix_better == NULL)
- curr_prefix_better = curr_prefix;
-
- set_relocation_prefix (orig_installprefix, curr_prefix_better);
-
- initialized = 1;
- }
-#endif
-
- /* Note: It is not necessary to perform case insensitive comparison here,
- even for DOS-like filesystems, because the pathname argument was
- typically created from the same Makefile variable as orig_prefix came
- from. */
- if (orig_prefix != NULL && curr_prefix != NULL
- && strncmp (pathname, orig_prefix, orig_prefix_len) == 0)
- {
- if (pathname[orig_prefix_len] == '\0')
- /* pathname equals orig_prefix. */
- return curr_prefix;
- if (ISSLASH (pathname[orig_prefix_len]))
- {
- /* pathname starts with orig_prefix. */
- const char *pathname_tail = &pathname[orig_prefix_len];
- char *result =
- (char *) xmalloc (curr_prefix_len + strlen (pathname_tail) + 1);
-
-#ifdef NO_XMALLOC
- if (result != NULL)
-#endif
- {
- memcpy (result, curr_prefix, curr_prefix_len);
- strcpy (result + curr_prefix_len, pathname_tail);
- return result;
- }
- }
- }
- /* Nothing to relocate. */
- return pathname;
-}
-
-#endif
diff --git a/navit/support/gettext_intl/relocatable.h b/navit/support/gettext_intl/relocatable.h
deleted file mode 100644
index 48c5b71e2..000000000
--- a/navit/support/gettext_intl/relocatable.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/* Provide relocatable packages.
- Copyright (C) 2003 Free Software Foundation, Inc.
- Written by Bruno Haible <bruno@clisp.org>, 2003.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _RELOCATABLE_H
-#define _RELOCATABLE_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* This can be enabled through the configure --enable-relocatable option. */
-#if ENABLE_RELOCATABLE
-
-/* When building a DLL, we must export some functions. Note that because
- this is a private .h file, we don't need to use __declspec(dllimport)
- in any case. */
-#if defined _MSC_VER && BUILDING_DLL
-# define RELOCATABLE_DLL_EXPORTED __declspec(dllexport)
-#else
-# define RELOCATABLE_DLL_EXPORTED
-#endif
-
-/* Sets the original and the current installation prefix of the package.
- Relocation simply replaces a pathname starting with the original prefix
- by the corresponding pathname with the current prefix instead. Both
- prefixes should be directory names without trailing slash (i.e. use ""
- instead of "/"). */
-extern RELOCATABLE_DLL_EXPORTED void
- set_relocation_prefix (const char *orig_prefix,
- const char *curr_prefix);
-
-/* Returns the pathname, relocated according to the current installation
- directory. */
-extern const char * relocate (const char *pathname);
-
-/* Memory management: relocate() leaks memory, because it has to construct
- a fresh pathname. If this is a problem because your program calls
- relocate() frequently, think about caching the result. */
-
-/* Convenience function:
- Computes the current installation prefix, based on the original
- installation prefix, the original installation directory of a particular
- file, and the current pathname of this file. Returns NULL upon failure. */
-extern const char * compute_curr_prefix (const char *orig_installprefix,
- const char *orig_installdir,
- const char *curr_pathname);
-
-#else
-
-/* By default, we use the hardwired pathnames. */
-#define relocate(pathname) (pathname)
-
-#endif
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _RELOCATABLE_H */
diff --git a/navit/support/gettext_intl/textdomain.c b/navit/support/gettext_intl/textdomain.c
deleted file mode 100644
index 8745a8435..000000000
--- a/navit/support/gettext_intl/textdomain.c
+++ /dev/null
@@ -1,141 +0,0 @@
-/* Implementation of the textdomain(3) function.
- Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdlib.h>
-#include <string.h>
-
-#ifdef _LIBC
-# include <libintl.h>
-#else
-# include "libgnuintl.h"
-#endif
-#include "gettextP.h"
-
-#ifdef _LIBC
-/* We have to handle multi-threaded applications. */
-# include <bits/libc-lock.h>
-#else
-/* Provide dummy implementation if this is outside glibc. */
-# define __libc_rwlock_define(CLASS, NAME)
-# define __libc_rwlock_wrlock(NAME)
-# define __libc_rwlock_unlock(NAME)
-#endif
-
-/* The internal variables in the standalone libintl.a must have different
- names than the internal variables in GNU libc, otherwise programs
- using libintl.a cannot be linked statically. */
-#if !defined _LIBC
-# define _nl_default_default_domain libintl_nl_default_default_domain
-# define _nl_current_default_domain libintl_nl_current_default_domain
-#endif
-
-/* @@ end of prolog @@ */
-
-/* Name of the default text domain. */
-extern const char _nl_default_default_domain[] attribute_hidden;
-
-/* Default text domain in which entries for gettext(3) are to be found. */
-extern const char *_nl_current_default_domain attribute_hidden;
-
-
-/* Names for the libintl functions are a problem. They must not clash
- with existing names and they should follow ANSI C. But this source
- code is also used in GNU C Library where the names have a __
- prefix. So we have to make a difference here. */
-#ifdef _LIBC
-# define TEXTDOMAIN __textdomain
-# ifndef strdup
-# define strdup(str) __strdup (str)
-# endif
-#else
-# define TEXTDOMAIN libintl_textdomain
-#endif
-
-/* Lock variable to protect the global data in the gettext implementation. */
-__libc_rwlock_define (extern, _nl_state_lock attribute_hidden)
-
-/* Set the current default message catalog to DOMAINNAME.
- If DOMAINNAME is null, return the current default.
- If DOMAINNAME is "", reset to the default of "messages". */
-char *
-TEXTDOMAIN (const char *domainname)
-{
- char *new_domain;
- char *old_domain;
-
- /* A NULL pointer requests the current setting. */
- if (domainname == NULL)
- return (char *) _nl_current_default_domain;
-
- __libc_rwlock_wrlock (_nl_state_lock);
-
- old_domain = (char *) _nl_current_default_domain;
-
- /* If domain name is the null string set to default domain "messages". */
- if (domainname[0] == '\0'
- || strcmp (domainname, _nl_default_default_domain) == 0)
- {
- _nl_current_default_domain = _nl_default_default_domain;
- new_domain = (char *) _nl_current_default_domain;
- }
- else if (strcmp (domainname, old_domain) == 0)
- /* This can happen and people will use it to signal that some
- environment variable changed. */
- new_domain = old_domain;
- else
- {
- /* If the following malloc fails `_nl_current_default_domain'
- will be NULL. This value will be returned and so signals we
- are out of core. */
-#if defined _LIBC || defined HAVE_STRDUP
- new_domain = strdup (domainname);
-#else
- size_t len = strlen (domainname) + 1;
- new_domain = (char *) malloc (len);
- if (new_domain != NULL)
- memcpy (new_domain, domainname, len);
-#endif
-
- if (new_domain != NULL)
- _nl_current_default_domain = new_domain;
- }
-
- /* We use this possibility to signal a change of the loaded catalogs
- since this is most likely the case and there is no other easy we
- to do it. Do it only when the call was successful. */
- if (new_domain != NULL)
- {
- ++_nl_msg_cat_cntr;
-
- if (old_domain != new_domain && old_domain != _nl_default_default_domain)
- free (old_domain);
- }
-
- __libc_rwlock_unlock (_nl_state_lock);
-
- return new_domain;
-}
-
-#ifdef _LIBC
-/* Alias for function name in GNU C Library. */
-weak_alias (__textdomain, textdomain);
-#endif
diff --git a/navit/support/gettext_intl/vasnprintf.c b/navit/support/gettext_intl/vasnprintf.c
deleted file mode 100644
index 6c201a4e5..000000000
--- a/navit/support/gettext_intl/vasnprintf.c
+++ /dev/null
@@ -1,897 +0,0 @@
-/* vsprintf with automatic memory allocation.
- Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-/* Tell glibc's <stdio.h> to provide a prototype for snprintf().
- This must come before <config.h> because <config.h> may include
- <features.h>, and once <features.h> has been included, it's too late. */
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-#ifndef IN_LIBINTL
-# include <alloca.h>
-#endif
-
-/* Specification. */
-#if WIDE_CHAR_VERSION
-# include "vasnwprintf.h"
-#else
-# include "vasnprintf.h"
-#endif
-
-#include <stdio.h> /* snprintf(), sprintf() */
-#include <stdlib.h> /* abort(), malloc(), realloc(), free() */
-#include <string.h> /* memcpy(), strlen() */
-#include <errno.h> /* errno */
-#include <limits.h> /* CHAR_BIT */
-#include <float.h> /* DBL_MAX_EXP, LDBL_MAX_EXP */
-#if WIDE_CHAR_VERSION
-# include "wprintf-parse.h"
-#else
-# include "printf-parse.h"
-#endif
-
-/* Checked size_t computations. */
-#include "xsize.h"
-
-#ifdef HAVE_WCHAR_T
-# ifdef HAVE_WCSLEN
-# define local_wcslen wcslen
-# else
- /* Solaris 2.5.1 has wcslen() in a separate library libw.so. To avoid
- a dependency towards this library, here is a local substitute.
- Define this substitute only once, even if this file is included
- twice in the same compilation unit. */
-# ifndef local_wcslen_defined
-# define local_wcslen_defined 1
-static size_t
-local_wcslen (const wchar_t *s)
-{
- const wchar_t *ptr;
-
- for (ptr = s; *ptr != (wchar_t) 0; ptr++)
- ;
- return ptr - s;
-}
-# endif
-# endif
-#endif
-
-#if WIDE_CHAR_VERSION
-# define VASNPRINTF vasnwprintf
-# define CHAR_T wchar_t
-# define DIRECTIVE wchar_t_directive
-# define DIRECTIVES wchar_t_directives
-# define PRINTF_PARSE wprintf_parse
-# define USE_SNPRINTF 1
-# if HAVE_DECL__SNWPRINTF
- /* On Windows, the function swprintf() has a different signature than
- on Unix; we use the _snwprintf() function instead. */
-# define SNPRINTF _snwprintf
-# else
- /* Unix. */
-# define SNPRINTF swprintf
-# endif
-#else
-# define VASNPRINTF vasnprintf
-# define CHAR_T char
-# define DIRECTIVE char_directive
-# define DIRECTIVES char_directives
-# define PRINTF_PARSE printf_parse
-# define USE_SNPRINTF (HAVE_DECL__SNPRINTF || HAVE_SNPRINTF)
-# if HAVE_DECL__SNPRINTF
- /* Windows. */
-# define SNPRINTF _snprintf
-# else
- /* Unix. */
-# define SNPRINTF snprintf
-# endif
-#endif
-
-CHAR_T *
-VASNPRINTF (CHAR_T *resultbuf, size_t *lengthp, const CHAR_T *format, va_list args)
-{
- DIRECTIVES d;
- arguments a;
-#ifdef _MSC_VER
-#ifndef _WIN32_WCE
- static int notFirstTime=0;
- if(!notFirstTime)
- {
- _set_printf_count_output( 1 );
- notFirstTime = 1;
- }
-#endif
-#endif
-
- if (PRINTF_PARSE (format, &d, &a) < 0)
- {
- errno = EINVAL;
- return NULL;
- }
-
-#define CLEANUP() \
- free (d.dir); \
- if (a.arg) \
- free (a.arg);
-
- if (printf_fetchargs (args, &a) < 0)
- {
- CLEANUP ();
- errno = EINVAL;
- return NULL;
- }
-
- {
- size_t buf_neededlength;
- CHAR_T *buf;
- CHAR_T *buf_malloced;
- const CHAR_T *cp;
- size_t i;
- DIRECTIVE *dp;
- /* Output string accumulator. */
- CHAR_T *result;
- size_t allocated;
- size_t length;
-
- /* Allocate a small buffer that will hold a directive passed to
- sprintf or snprintf. */
- buf_neededlength =
- xsum4 (7, d.max_width_length, d.max_precision_length, 6);
-#if HAVE_ALLOCA
- if (buf_neededlength < 4000 / sizeof (CHAR_T))
- {
- buf = (CHAR_T *) alloca (buf_neededlength * sizeof (CHAR_T));
- buf_malloced = NULL;
- }
- else
-#endif
- {
- size_t buf_memsize = xtimes (buf_neededlength, sizeof (CHAR_T));
- if (size_overflow_p (buf_memsize))
- goto out_of_memory_1;
- buf = (CHAR_T *) malloc (buf_memsize);
- if (buf == NULL)
- goto out_of_memory_1;
- buf_malloced = buf;
- }
-
- if (resultbuf != NULL)
- {
- result = resultbuf;
- allocated = *lengthp;
- }
- else
- {
- result = NULL;
- allocated = 0;
- }
- length = 0;
- /* Invariants:
- result is either == resultbuf or == NULL or malloc-allocated.
- If length > 0, then result != NULL. */
-
- /* Ensures that allocated >= needed. Aborts through a jump to
- out_of_memory if needed is SIZE_MAX or otherwise too big. */
-#define ENSURE_ALLOCATION(needed) \
- if ((needed) > allocated) \
- { \
- size_t memory_size; \
- CHAR_T *memory; \
- \
- allocated = (allocated > 0 ? xtimes (allocated, 2) : 12); \
- if ((needed) > allocated) \
- allocated = (needed); \
- memory_size = xtimes (allocated, sizeof (CHAR_T)); \
- if (size_overflow_p (memory_size)) \
- goto out_of_memory; \
- if (result == resultbuf || result == NULL) \
- memory = (CHAR_T *) malloc (memory_size); \
- else \
- memory = (CHAR_T *) realloc (result, memory_size); \
- if (memory == NULL) \
- goto out_of_memory; \
- if (result == resultbuf && length > 0) \
- memcpy (memory, result, length * sizeof (CHAR_T)); \
- result = memory; \
- }
-
- for (cp = format, i = 0, dp = &d.dir[0]; ; cp = dp->dir_end, i++, dp++)
- {
- if (cp != dp->dir_start)
- {
- size_t n = dp->dir_start - cp;
- size_t augmented_length = xsum (length, n);
-
- ENSURE_ALLOCATION (augmented_length);
- memcpy (result + length, cp, n * sizeof (CHAR_T));
- length = augmented_length;
- }
- if (i == d.count)
- break;
-
- /* Execute a single directive. */
- if (dp->conversion == '%')
- {
- size_t augmented_length;
-
- if (!(dp->arg_index == ARG_NONE))
- abort ();
- augmented_length = xsum (length, 1);
- ENSURE_ALLOCATION (augmented_length);
- result[length] = '%';
- length = augmented_length;
- }
- else
- {
- if (!(dp->arg_index != ARG_NONE))
- abort ();
-
- if (dp->conversion == 'n')
- {
- switch (a.arg[dp->arg_index].type)
- {
- case TYPE_COUNT_SCHAR_POINTER:
- *a.arg[dp->arg_index].a.a_count_schar_pointer = length;
- break;
- case TYPE_COUNT_SHORT_POINTER:
- *a.arg[dp->arg_index].a.a_count_short_pointer = length;
- break;
- case TYPE_COUNT_INT_POINTER:
- *a.arg[dp->arg_index].a.a_count_int_pointer = length;
- break;
- case TYPE_COUNT_LONGINT_POINTER:
- *a.arg[dp->arg_index].a.a_count_longint_pointer = length;
- break;
-#ifdef HAVE_LONG_LONG
- case TYPE_COUNT_LONGLONGINT_POINTER:
- *a.arg[dp->arg_index].a.a_count_longlongint_pointer = length;
- break;
-#endif
- default:
- abort ();
- }
- }
- else
- {
- arg_type type = a.arg[dp->arg_index].type;
- CHAR_T *p;
- unsigned int prefix_count;
- int prefixes[2];
-#if !USE_SNPRINTF
- size_t tmp_length;
- CHAR_T tmpbuf[700];
- CHAR_T *tmp;
-
- /* Allocate a temporary buffer of sufficient size for calling
- sprintf. */
- {
- size_t width;
- size_t precision;
-
- width = 0;
- if (dp->width_start != dp->width_end)
- {
- if (dp->width_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->width_arg_index].a.a_int;
- width = (arg < 0 ? (unsigned int) (-arg) : arg);
- }
- else
- {
- const CHAR_T *digitp = dp->width_start;
-
- do
- width = xsum (xtimes (width, 10), *digitp++ - '0');
- while (digitp != dp->width_end);
- }
- }
-
- precision = 6;
- if (dp->precision_start != dp->precision_end)
- {
- if (dp->precision_arg_index != ARG_NONE)
- {
- int arg;
-
- if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
- abort ();
- arg = a.arg[dp->precision_arg_index].a.a_int;
- precision = (arg < 0 ? 0 : arg);
- }
- else
- {
- const CHAR_T *digitp = dp->precision_start + 1;
-
- precision = 0;
- do
- precision = xsum (xtimes (precision, 10), *digitp++ - '0');
- while (digitp != dp->precision_end);
- }
- }
-
- switch (dp->conversion)
- {
-
- case 'd': case 'i': case 'u':
-# ifdef HAVE_LONG_LONG
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 1; /* account for leading sign */
- else
-# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 1; /* account for leading sign */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 1; /* account for leading sign */
- break;
-
- case 'o':
-# ifdef HAVE_LONG_LONG
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1 /* turn floor into ceil */
- + 1; /* account for leading sign */
- else
-# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1 /* turn floor into ceil */
- + 1; /* account for leading sign */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.333334 /* binary -> octal */
- )
- + 1 /* turn floor into ceil */
- + 1; /* account for leading sign */
- break;
-
- case 'x': case 'X':
-# ifdef HAVE_LONG_LONG
- if (type == TYPE_LONGLONGINT || type == TYPE_ULONGLONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long long) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1 /* turn floor into ceil */
- + 2; /* account for leading sign or alternate form */
- else
-# endif
- if (type == TYPE_LONGINT || type == TYPE_ULONGINT)
- tmp_length =
- (unsigned int) (sizeof (unsigned long) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1 /* turn floor into ceil */
- + 2; /* account for leading sign or alternate form */
- else
- tmp_length =
- (unsigned int) (sizeof (unsigned int) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1 /* turn floor into ceil */
- + 2; /* account for leading sign or alternate form */
- break;
-
- case 'f': case 'F':
-# ifdef HAVE_LONG_DOUBLE
- if (type == TYPE_LONGDOUBLE)
- tmp_length =
- (unsigned int) (LDBL_MAX_EXP
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 10; /* sign, decimal point etc. */
- else
-# endif
- tmp_length =
- (unsigned int) (DBL_MAX_EXP
- * 0.30103 /* binary -> decimal */
- * 2 /* estimate for FLAG_GROUP */
- )
- + 1 /* turn floor into ceil */
- + 10; /* sign, decimal point etc. */
- tmp_length = xsum (tmp_length, precision);
- break;
-
- case 'e': case 'E': case 'g': case 'G':
- case 'a': case 'A':
- tmp_length =
- 12; /* sign, decimal point, exponent etc. */
- tmp_length = xsum (tmp_length, precision);
- break;
-
- case 'c':
-# if defined HAVE_WINT_T && !WIDE_CHAR_VERSION
- if (type == TYPE_WIDE_CHAR)
- tmp_length = MB_CUR_MAX;
- else
-# endif
- tmp_length = 1;
- break;
-
- case 's':
-# ifdef HAVE_WCHAR_T
- if (type == TYPE_WIDE_STRING)
- {
- tmp_length =
- local_wcslen (a.arg[dp->arg_index].a.a_wide_string);
-
-# if !WIDE_CHAR_VERSION
- tmp_length = xtimes (tmp_length, MB_CUR_MAX);
-# endif
- }
- else
-# endif
- tmp_length = strlen (a.arg[dp->arg_index].a.a_string);
- break;
-
- case 'p':
- tmp_length =
- (unsigned int) (sizeof (void *) * CHAR_BIT
- * 0.25 /* binary -> hexadecimal */
- )
- + 1 /* turn floor into ceil */
- + 2; /* account for leading 0x */
- break;
-
- default:
- abort ();
- }
-
- if (tmp_length < width)
- tmp_length = width;
-
- tmp_length = xsum (tmp_length, 1); /* account for trailing NUL */
- }
-
- if (tmp_length <= sizeof (tmpbuf) / sizeof (CHAR_T))
- tmp = tmpbuf;
- else
- {
- size_t tmp_memsize = xtimes (tmp_length, sizeof (CHAR_T));
-
- if (size_overflow_p (tmp_memsize))
- /* Overflow, would lead to out of memory. */
- goto out_of_memory;
- tmp = (CHAR_T *) malloc (tmp_memsize);
- if (tmp == NULL)
- /* Out of memory. */
- goto out_of_memory;
- }
-#endif
-
- /* Construct the format string for calling snprintf or
- sprintf. */
- p = buf;
- *p++ = '%';
- if (dp->flags & FLAG_GROUP)
- *p++ = '\'';
- if (dp->flags & FLAG_LEFT)
- *p++ = '-';
- if (dp->flags & FLAG_SHOWSIGN)
- *p++ = '+';
- if (dp->flags & FLAG_SPACE)
- *p++ = ' ';
- if (dp->flags & FLAG_ALT)
- *p++ = '#';
- if (dp->flags & FLAG_ZERO)
- *p++ = '0';
- if (dp->width_start != dp->width_end)
- {
- size_t n = dp->width_end - dp->width_start;
- memcpy (p, dp->width_start, n * sizeof (CHAR_T));
- p += n;
- }
- if (dp->precision_start != dp->precision_end)
- {
- size_t n = dp->precision_end - dp->precision_start;
- memcpy (p, dp->precision_start, n * sizeof (CHAR_T));
- p += n;
- }
-
- switch (type)
- {
-#ifdef HAVE_LONG_LONG
- case TYPE_LONGLONGINT:
- case TYPE_ULONGLONGINT:
- *p++ = 'l';
- /*FALLTHROUGH*/
-#endif
- case TYPE_LONGINT:
- case TYPE_ULONGINT:
-#ifdef HAVE_WINT_T
- case TYPE_WIDE_CHAR:
-#endif
-#ifdef HAVE_WCHAR_T
- case TYPE_WIDE_STRING:
-#endif
- *p++ = 'l';
- break;
-#ifdef HAVE_LONG_DOUBLE
- case TYPE_LONGDOUBLE:
- *p++ = 'L';
- break;
-#endif
- default:
- break;
- }
- *p = dp->conversion;
-#if USE_SNPRINTF
- p[1] = '%';
- p[2] = 'n';
- p[3] = '\0';
-#else
- p[1] = '\0';
-#endif
-
- /* Construct the arguments for calling snprintf or sprintf. */
- prefix_count = 0;
- if (dp->width_arg_index != ARG_NONE)
- {
- if (!(a.arg[dp->width_arg_index].type == TYPE_INT))
- abort ();
- prefixes[prefix_count++] = a.arg[dp->width_arg_index].a.a_int;
- }
- if (dp->precision_arg_index != ARG_NONE)
- {
- if (!(a.arg[dp->precision_arg_index].type == TYPE_INT))
- abort ();
- prefixes[prefix_count++] = a.arg[dp->precision_arg_index].a.a_int;
- }
-
-#if USE_SNPRINTF
- /* Prepare checking whether snprintf returns the count
- via %n. */
- ENSURE_ALLOCATION (xsum (length, 1));
- result[length] = '\0';
-#endif
-
- for (;;)
- {
- size_t maxlen;
- int count;
- int retcount;
-
- maxlen = allocated - length;
- count = -1;
- retcount = 0;
-
-#if USE_SNPRINTF
-# define SNPRINTF_BUF(arg) \
- switch (prefix_count) \
- { \
- case 0: \
- retcount = SNPRINTF (result + length, maxlen, buf, \
- arg, &count); \
- break; \
- case 1: \
- retcount = SNPRINTF (result + length, maxlen, buf, \
- prefixes[0], arg, &count); \
- break; \
- case 2: \
- retcount = SNPRINTF (result + length, maxlen, buf, \
- prefixes[0], prefixes[1], arg, \
- &count); \
- break; \
- default: \
- abort (); \
- }
-#else
-# define SNPRINTF_BUF(arg) \
- switch (prefix_count) \
- { \
- case 0: \
- count = sprintf (tmp, buf, arg); \
- break; \
- case 1: \
- count = sprintf (tmp, buf, prefixes[0], arg); \
- break; \
- case 2: \
- count = sprintf (tmp, buf, prefixes[0], prefixes[1],\
- arg); \
- break; \
- default: \
- abort (); \
- }
-#endif
-
- switch (type)
- {
- case TYPE_SCHAR:
- {
- int arg = a.arg[dp->arg_index].a.a_schar;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_UCHAR:
- {
- unsigned int arg = a.arg[dp->arg_index].a.a_uchar;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_SHORT:
- {
- int arg = a.arg[dp->arg_index].a.a_short;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_USHORT:
- {
- unsigned int arg = a.arg[dp->arg_index].a.a_ushort;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_INT:
- {
- int arg = a.arg[dp->arg_index].a.a_int;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_UINT:
- {
- unsigned int arg = a.arg[dp->arg_index].a.a_uint;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_LONGINT:
- {
- long int arg = a.arg[dp->arg_index].a.a_longint;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_ULONGINT:
- {
- unsigned long int arg = a.arg[dp->arg_index].a.a_ulongint;
- SNPRINTF_BUF (arg);
- }
- break;
-#ifdef HAVE_LONG_LONG
- case TYPE_LONGLONGINT:
- {
- long long int arg = a.arg[dp->arg_index].a.a_longlongint;
- SNPRINTF_BUF (arg);
- }
- break;
- case TYPE_ULONGLONGINT:
- {
- unsigned long long int arg = a.arg[dp->arg_index].a.a_ulonglongint;
- SNPRINTF_BUF (arg);
- }
- break;
-#endif
- case TYPE_DOUBLE:
- {
- double arg = a.arg[dp->arg_index].a.a_double;
- SNPRINTF_BUF (arg);
- }
- break;
-#ifdef HAVE_LONG_DOUBLE
- case TYPE_LONGDOUBLE:
- {
- long double arg = a.arg[dp->arg_index].a.a_longdouble;
- SNPRINTF_BUF (arg);
- }
- break;
-#endif
- case TYPE_CHAR:
- {
- int arg = a.arg[dp->arg_index].a.a_char;
- SNPRINTF_BUF (arg);
- }
- break;
-#ifdef HAVE_WINT_T
- case TYPE_WIDE_CHAR:
- {
- wint_t arg = a.arg[dp->arg_index].a.a_wide_char;
- SNPRINTF_BUF (arg);
- }
- break;
-#endif
- case TYPE_STRING:
- {
- const char *arg = a.arg[dp->arg_index].a.a_string;
- SNPRINTF_BUF (arg);
- }
- break;
-#ifdef HAVE_WCHAR_T
- case TYPE_WIDE_STRING:
- {
- const wchar_t *arg = a.arg[dp->arg_index].a.a_wide_string;
- SNPRINTF_BUF (arg);
- }
- break;
-#endif
- case TYPE_POINTER:
- {
- void *arg = a.arg[dp->arg_index].a.a_pointer;
- SNPRINTF_BUF (arg);
- }
- break;
- default:
- abort ();
- }
-
-#if USE_SNPRINTF
- /* Portability: Not all implementations of snprintf()
- are ISO C 99 compliant. Determine the number of
- bytes that snprintf() has produced or would have
- produced. */
- if (count >= 0)
- {
- /* Verify that snprintf() has NUL-terminated its
- result. */
- if (count < maxlen && result[length + count] != '\0')
- abort ();
- /* Portability hack. */
- if (retcount > count)
- count = retcount;
- }
- else
- {
- /* snprintf() doesn't understand the '%n'
- directive. */
- if (p[1] != '\0')
- {
- /* Don't use the '%n' directive; instead, look
- at the snprintf() return value. */
- p[1] = '\0';
- continue;
- }
- else
- {
- /* Look at the snprintf() return value. */
- if (retcount < 0)
- {
- /* HP-UX 10.20 snprintf() is doubly deficient:
- It doesn't understand the '%n' directive,
- *and* it returns -1 (rather than the length
- that would have been required) when the
- buffer is too small. */
- size_t bigger_need =
- xsum (xtimes (allocated, 2), 12);
- ENSURE_ALLOCATION (bigger_need);
- continue;
- }
- else
- count = retcount;
- }
- }
-#endif
-
- /* Attempt to handle failure. */
- if (count < 0)
- {
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- errno = EINVAL;
- return NULL;
- }
-
-#if !USE_SNPRINTF
- if (count >= tmp_length)
- /* tmp_length was incorrectly calculated - fix the
- code above! */
- abort ();
-#endif
-
- /* Make room for the result. */
- if (count >= maxlen)
- {
- /* Need at least count bytes. But allocate
- proportionally, to avoid looping eternally if
- snprintf() reports a too small count. */
- size_t n =
- xmax (xsum (length, count), xtimes (allocated, 2));
-
- ENSURE_ALLOCATION (n);
-#if USE_SNPRINTF
- continue;
-#endif
- }
-
-#if USE_SNPRINTF
- /* The snprintf() result did fit. */
-#else
- /* Append the sprintf() result. */
- memcpy (result + length, tmp, count * sizeof (CHAR_T));
- if (tmp != tmpbuf)
- free (tmp);
-#endif
-
- length += count;
- break;
- }
- }
- }
- }
-
- /* Add the final NUL. */
- ENSURE_ALLOCATION (xsum (length, 1));
- result[length] = '\0';
-
- if (result != resultbuf && length + 1 < allocated)
- {
- /* Shrink the allocated memory if possible. */
- CHAR_T *memory;
-
- memory = (CHAR_T *) realloc (result, (length + 1) * sizeof (CHAR_T));
- if (memory != NULL)
- result = memory;
- }
-
- if (buf_malloced != NULL)
- free (buf_malloced);
- CLEANUP ();
- *lengthp = length;
- return result;
-
- out_of_memory:
- if (!(result == resultbuf || result == NULL))
- free (result);
- if (buf_malloced != NULL)
- free (buf_malloced);
- out_of_memory_1:
- CLEANUP ();
- errno = ENOMEM;
- return NULL;
- }
-}
-
-#undef SNPRINTF
-#undef USE_SNPRINTF
-#undef PRINTF_PARSE
-#undef DIRECTIVES
-#undef DIRECTIVE
-#undef CHAR_T
-#undef VASNPRINTF
diff --git a/navit/support/gettext_intl/vasnprintf.h b/navit/support/gettext_intl/vasnprintf.h
deleted file mode 100644
index 65f1bc13d..000000000
--- a/navit/support/gettext_intl/vasnprintf.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* vsprintf with automatic memory allocation.
- Copyright (C) 2002-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _VASNPRINTF_H
-#define _VASNPRINTF_H
-
-/* Get va_list. */
-#include <stdarg.h>
-
-/* Get size_t. */
-#include <stddef.h>
-
-#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || __STRICT_ANSI__
-# define __attribute__(Spec) /* empty */
-# endif
-/* The __-protected variants of `format' and `printf' attributes
- are accepted by gcc versions 2.6.4 (effectively 2.7) and later. */
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
-# define __format__ format
-# define __printf__ printf
-# endif
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Write formatted output to a string dynamically allocated with malloc().
- You can pass a preallocated buffer for the result in RESULTBUF and its
- size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
- If successful, return the address of the string (this may be = RESULTBUF
- if no dynamic memory allocation was necessary) and set *LENGTHP to the
- number of resulting bytes, excluding the trailing NUL. Upon error, set
- errno and return NULL. */
-extern char * asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...)
- __attribute__ ((__format__ (__printf__, 3, 4)));
-extern char * vasnprintf (char *resultbuf, size_t *lengthp, const char *format, va_list args)
- __attribute__ ((__format__ (__printf__, 3, 0)));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _VASNPRINTF_H */
diff --git a/navit/support/gettext_intl/vasnwprintf.h b/navit/support/gettext_intl/vasnwprintf.h
deleted file mode 100644
index d3cef4cbc..000000000
--- a/navit/support/gettext_intl/vasnwprintf.h
+++ /dev/null
@@ -1,46 +0,0 @@
-/* vswprintf with automatic memory allocation.
- Copyright (C) 2002-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _VASNWPRINTF_H
-#define _VASNWPRINTF_H
-
-/* Get va_list. */
-#include <stdarg.h>
-
-/* Get wchar_t, size_t. */
-#include <stddef.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Write formatted output to a string dynamically allocated with malloc().
- You can pass a preallocated buffer for the result in RESULTBUF and its
- size in *LENGTHP; otherwise you pass RESULTBUF = NULL.
- If successful, return the address of the string (this may be = RESULTBUF
- if no dynamic memory allocation was necessary) and set *LENGTHP to the
- number of resulting bytes, excluding the trailing NUL. Upon error, set
- errno and return NULL. */
-extern wchar_t * asnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, ...);
-extern wchar_t * vasnwprintf (wchar_t *resultbuf, size_t *lengthp, const wchar_t *format, va_list args);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _VASNWPRINTF_H */
diff --git a/navit/support/gettext_intl/wprintf-parse.h b/navit/support/gettext_intl/wprintf-parse.h
deleted file mode 100644
index 24a2cfc28..000000000
--- a/navit/support/gettext_intl/wprintf-parse.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/* Parse printf format string.
- Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _WPRINTF_PARSE_H
-#define _WPRINTF_PARSE_H
-
-#include "printf-args.h"
-
-
-/* Flags */
-#define FLAG_GROUP 1 /* ' flag */
-#define FLAG_LEFT 2 /* - flag */
-#define FLAG_SHOWSIGN 4 /* + flag */
-#define FLAG_SPACE 8 /* space flag */
-#define FLAG_ALT 16 /* # flag */
-#define FLAG_ZERO 32
-
-/* arg_index value indicating that no argument is consumed. */
-#define ARG_NONE (~(size_t)0)
-
-/* A parsed directive. */
-typedef struct
-{
- const wchar_t* dir_start;
- const wchar_t* dir_end;
- int flags;
- const wchar_t* width_start;
- const wchar_t* width_end;
- size_t width_arg_index;
- const wchar_t* precision_start;
- const wchar_t* precision_end;
- size_t precision_arg_index;
- wchar_t conversion; /* d i o u x X f e E g G c s p n U % but not C S */
- size_t arg_index;
-}
-wchar_t_directive;
-
-/* A parsed format string. */
-typedef struct
-{
- size_t count;
- wchar_t_directive *dir;
- size_t max_width_length;
- size_t max_precision_length;
-}
-wchar_t_directives;
-
-
-/* Parses the format string. Fills in the number N of directives, and fills
- in directives[0], ..., directives[N-1], and sets directives[N].dir_start
- to the end of the format string. Also fills in the arg_type fields of the
- arguments and the needed count of arguments. */
-#ifdef STATIC
-STATIC
-#else
-extern
-#endif
-int wprintf_parse (const wchar_t *format, wchar_t_directives *d, arguments *a);
-
-#endif /* _WPRINTF_PARSE_H */
diff --git a/navit/support/gettext_intl/xsize.h b/navit/support/gettext_intl/xsize.h
deleted file mode 100644
index f0bf71391..000000000
--- a/navit/support/gettext_intl/xsize.h
+++ /dev/null
@@ -1,109 +0,0 @@
-/* xsize.h -- Checked size_t computations.
-
- Copyright (C) 2003 Free Software Foundation, Inc.
-
- This program is free software; you can redistribute it and/or modify it
- under the terms of the GNU Library 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
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
- USA. */
-
-#ifndef _XSIZE_H
-#define _XSIZE_H
-
-/* Get size_t. */
-#include <stddef.h>
-
-/* Get SIZE_MAX. */
-#include <limits.h>
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-
-/* The size of memory objects is often computed through expressions of
- type size_t. Example:
- void* p = malloc (header_size + n * element_size).
- These computations can lead to overflow. When this happens, malloc()
- returns a piece of memory that is way too small, and the program then
- crashes while attempting to fill the memory.
- To avoid this, the functions and macros in this file check for overflow.
- The convention is that SIZE_MAX represents overflow.
- malloc (SIZE_MAX) is not guaranteed to fail -- think of a malloc
- implementation that uses mmap --, it's recommended to use size_overflow_p()
- or size_in_bounds_p() before invoking malloc().
- The example thus becomes:
- size_t size = xsum (header_size, xtimes (n, element_size));
- void *p = (size_in_bounds_p (size) ? malloc (size) : NULL);
-*/
-
-/* Convert an arbitrary value >= 0 to type size_t. */
-#define xcast_size_t(N) \
- ((N) <= SIZE_MAX ? (size_t) (N) : SIZE_MAX)
-
-/* Sum of two sizes, with overflow check. */
-static size_t
-#if __GNUC__ >= 3
-__attribute__ ((__pure__))
-#endif
-xsum (size_t size1, size_t size2)
-{
- size_t sum = size1 + size2;
- return (sum >= size1 ? sum : SIZE_MAX);
-}
-
-/* Sum of three sizes, with overflow check. */
-static size_t
-#if __GNUC__ >= 3
-__attribute__ ((__pure__))
-#endif
-xsum3 (size_t size1, size_t size2, size_t size3)
-{
- return xsum (xsum (size1, size2), size3);
-}
-
-/* Sum of four sizes, with overflow check. */
-static size_t
-#if __GNUC__ >= 3
-__attribute__ ((__pure__))
-#endif
-xsum4 (size_t size1, size_t size2, size_t size3, size_t size4)
-{
- return xsum (xsum (xsum (size1, size2), size3), size4);
-}
-
-/* Maximum of two sizes, with overflow check. */
-static size_t
-#if __GNUC__ >= 3
-__attribute__ ((__pure__))
-#endif
-xmax (size_t size1, size_t size2)
-{
- /* No explicit check is needed here, because for any n:
- max (SIZE_MAX, n) == SIZE_MAX and max (n, SIZE_MAX) == SIZE_MAX. */
- return (size1 >= size2 ? size1 : size2);
-}
-
-/* Multiplication of a count with an element size, with overflow check.
- The count must be >= 0 and the element size must be > 0.
- This is a macro, not an inline function, so that it works correctly even
- when N is of a wider tupe and N > SIZE_MAX. */
-#define xtimes(N, ELSIZE) \
- ((N) <= SIZE_MAX / (ELSIZE) ? (size_t) (N) * (ELSIZE) : SIZE_MAX)
-
-/* Check for overflow. */
-#define size_overflow_p(SIZE) \
- ((SIZE) == SIZE_MAX)
-/* Check against overflow. */
-#define size_in_bounds_p(SIZE) \
- ((SIZE) != SIZE_MAX)
-
-#endif /* _XSIZE_H */
diff --git a/navit/support/glib/CMakeLists.txt b/navit/support/glib/CMakeLists.txt
deleted file mode 100644
index 322d5467e..000000000
--- a/navit/support/glib/CMakeLists.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-supportlib_add_library(support_glib fake.c galiasdef.c gatomic.c gerror.c ghash.c
- glib_init.c glist.c gmem.c gmessages.c gprimes.c gprintf.c gslice.c gslist.c
- gstrfuncs.c gstring.c gutf8.c gutils.c)
diff --git a/navit/support/glib/fake.c b/navit/support/glib/fake.c
deleted file mode 100644
index 2dfe75832..000000000
--- a/navit/support/glib/fake.c
+++ /dev/null
@@ -1,119 +0,0 @@
-#include "fake.h"
-
-#include <stdlib.h> /* posix_memalign() */
-#include <string.h>
-#include <errno.h>
-#include "gmem.h" /* gslice.h */
-#include "gthreadprivate.h"
-#include "glib.h"
-#include "galias.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* sysconf() */
-#endif
-#ifdef G_OS_WIN32
-#include <windows.h>
-#include <process.h>
-#endif
-
-#include <stdio.h> /* fputs/fprintf */
-
-char* g_convert (const char *in,
- int len,
- const char *to_codeset,
- const char *from_codeset,
- int *bytes_read,
- int *bytes_written,
- void **error)
-{
- return g_strdup(in);
-}
-
-
-#if USE_POSIX_THREADS
-pthread_mutex_t* g_mutex_new_navit(void)
-{
- pthread_mutex_t *ret = malloc(sizeof(pthread_mutex_t));
- pthread_mutex_init(ret, NULL);
- return ret;
-}
-#else
-#if HAVE_API_WIN32_BASE
-CRITICAL_SECTION* g_mutex_new_navit(void)
-{
- CRITICAL_SECTION *ret = malloc(sizeof(CRITICAL_SECTION));
- InitializeCriticalSection(ret);
- return ret;
-}
-#endif
-#endif
-
-GPrivate
-g_private_new_navit ()
-{
-#if HAVE_API_WIN32_BASE
- int dwTlsIndex;
-
-#ifndef TLS_OUT_OF_INDEXES
-#define TLS_OUT_OF_INDEXES (-1)
-#endif
- if ((dwTlsIndex = TlsAlloc()) == TLS_OUT_OF_INDEXES)
- printf("TlsAlloc failed");
- printf("return dwTlsIndex = 0x%x\n",dwTlsIndex);
- return dwTlsIndex;
-#else
- pthread_key_t key;
- if (pthread_key_create(&key, NULL)) {
- fprintf(stderr,"pthread_key_create failed\n");
- }
- return key;
-#endif
-}
-
-/**
- * g_get_current_time:
- * @result: #GTimeVal structure in which to store current time.
- *
- * Equivalent to the UNIX gettimeofday() function, but portable.
- **/
-void
-g_get_current_time (GTimeVal *result)
-{
-#ifndef G_OS_WIN32
- struct timeval r;
-
- g_return_if_fail (result != NULL);
-
- /*this is required on alpha, there the timeval structs are int's
- not longs and a cast only would fail horribly*/
- gettimeofday (&r, NULL);
- result->tv_sec = r.tv_sec;
- result->tv_usec = r.tv_usec;
-#else
- FILETIME ft;
- guint64 time64;
-
- g_return_if_fail (result != NULL);
-
-#if defined(HAVE_API_WIN32_CE)
- GetCurrentFT(&ft);
-#else
- GetSystemTimeAsFileTime (&ft);
-#endif
- memmove (&time64, &ft, sizeof (FILETIME));
-
- /* Convert from 100s of nanoseconds since 1601-01-01
- * to Unix epoch. Yes, this is Y2038 unsafe.
- */
- time64 -= G_GINT64_CONSTANT (116444736000000000);
- time64 /= 10;
-
- result->tv_sec = time64 / 1000000;
- result->tv_usec = time64 % 1000000;
-#endif
-}
-
-// FIXME: should use real utf8-aware function
-gchar * g_utf8_casefold(const gchar *s, gssize len)
-{
- return g_ascii_strdown(s,len);
-}
diff --git a/navit/support/glib/fake.h b/navit/support/glib/fake.h
deleted file mode 100644
index ba9b17750..000000000
--- a/navit/support/glib/fake.h
+++ /dev/null
@@ -1,50 +0,0 @@
-#include "config.h"
-#ifndef HAVE_API_WIN32_BASE
-#define USE_POSIX_THREADS 1
-#endif
-#if USE_POSIX_THREADS
-#include <pthread.h>
-#endif
-#include "debug.h"
-
-#define g_return_if_fail
-
-
-#if USE_POSIX_THREADS
-# define GMutex pthread_mutex_t
-# define g_mutex_new g_mutex_new_navit
-# define g_mutex_lock(lock) ((lock == NULL) ? 0 : pthread_mutex_lock(lock))
-# define g_mutex_unlock(lock) ((lock == NULL) ? 0 : pthread_mutex_unlock(lock))
-# define g_mutex_trylock(lock) (((lock == NULL) ? 0 : pthread_mutex_trylock(lock)) == 0)
-# define GPrivate pthread_key_t
-# define g_private_new(xd) g_private_new_navit()
-# define g_private_get(xd) pthread_getspecific(xd)
-# define g_private_set(a,b) pthread_setspecific(a, b)
-#else
-# if HAVE_API_WIN32_BASE
-# define GMutex CRITICAL_SECTION
-# define g_mutex_new g_mutex_new_navit
-# define g_mutex_lock(lock) (EnterCriticalSection(lock))
-# define g_mutex_unlock(lock) (LeaveCriticalSection(lock))
-# define g_mutex_trylock(lock) (TryEnterCriticalSection(lock))
-# define GPrivate int
-# define g_private_new(xd) g_private_new_navit()
-# define g_private_get(xd) TlsGetValue(xd)
-# define g_private_set(a,b) TlsSetValue(a, b)
-# endif
-#endif
-
-char* g_convert (const char *str,
- int len,
- const char *to_codeset,
- const char *from_codeset,
- int *bytes_read,
- int *bytes_written,
- void **error);
-#define G_LOCK_DEFINE_STATIC(name) //void
-#define G_LOCK(name) //void //g_mutex_lock (&G_LOCK_NAME (name))
-#define G_UNLOCK(name) //void //g_mutex_unlock (&G_LOCK_NAME (name))
-
-#define g_thread_supported() TRUE
-
-#define g_assert(expr) dbg_assert (expr)
diff --git a/navit/support/glib/galias.h b/navit/support/glib/galias.h
deleted file mode 100644
index e69de29bb..000000000
--- a/navit/support/glib/galias.h
+++ /dev/null
diff --git a/navit/support/glib/galiasdef.c b/navit/support/glib/galiasdef.c
deleted file mode 100644
index e69de29bb..000000000
--- a/navit/support/glib/galiasdef.c
+++ /dev/null
diff --git a/navit/support/glib/galloca.h b/navit/support/glib/galloca.h
deleted file mode 100644
index 356587ff6..000000000
--- a/navit/support/glib/galloca.h
+++ /dev/null
@@ -1,63 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_ALLOCA_H__
-#define __G_ALLOCA_H__
-
-#include <glib/gtypes.h>
-
-#ifdef __GNUC__
-/* GCC does the right thing */
-# undef alloca
-# define alloca(size) __builtin_alloca (size)
-#elif defined (GLIB_HAVE_ALLOCA_H)
-/* a native and working alloca.h is there */
-# include <alloca.h>
-#else /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */
-# if defined(_MSC_VER) || defined(__DMC__)
-# include <malloc.h>
-# define alloca _alloca
-# else /* !_MSC_VER && !__DMC__ */
-# ifdef _AIX
-# pragma alloca
-# else /* !_AIX */
-# ifndef alloca /* predefined by HP cc +Olibcalls */
-G_BEGIN_DECLS
-char *alloca ();
-G_END_DECLS
-# endif /* !alloca */
-# endif /* !_AIX */
-# endif /* !_MSC_VER && !__DMC__ */
-#endif /* !__GNUC__ && !GLIB_HAVE_ALLOCA_H */
-
-#define g_alloca(size) alloca (size)
-#define g_newa(struct_type, n_structs) ((struct_type*) g_alloca (sizeof (struct_type) * (gsize) (n_structs)))
-
-#endif /* __G_ALLOCA_H__ */
diff --git a/navit/support/glib/gatomic.c b/navit/support/glib/gatomic.c
deleted file mode 100644
index c881ec68e..000000000
--- a/navit/support/glib/gatomic.c
+++ /dev/null
@@ -1,946 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * g_atomic_*: atomic operations.
- * Copyright (C) 2003 Sebastian Wilhelmi
- * Copyright (C) 2007 Nokia Corporation
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#if defined (G_ATOMIC_ARM)
-#include <sched.h>
-#endif
-
-#include "glib.h"
-#include "gthreadprivate.h"
-#include "galias.h"
-
-# if HAVE_API_WIN32_BASE
-#include <windows.h>
-#endif
-
-#if USE_POSIX_THREADS
-#include <pthread.h>
-#endif
-
-#if defined (__GNUC__)
-# if defined (G_ATOMIC_I486)
-/* Adapted from CVS version 1.10 of glibc's sysdeps/i386/i486/bits/atomic.h
- */
-gint
-g_atomic_int_exchange_and_add (volatile gint *atomic,
- gint val)
-{
- gint result;
-
- __asm__ __volatile__ ("lock; xaddl %0,%1"
- : "=r" (result), "=m" (*atomic)
- : "0" (val), "m" (*atomic));
- return result;
-}
-
-void
-g_atomic_int_add (volatile gint *atomic,
- gint val)
-{
- __asm__ __volatile__ ("lock; addl %1,%0"
- : "=m" (*atomic)
- : "ir" (val), "m" (*atomic));
-}
-
-gboolean
-g_atomic_int_compare_and_exchange (volatile gint *atomic,
- gint oldval,
- gint newval)
-{
- gint result;
-
- __asm__ __volatile__ ("lock; cmpxchgl %2, %1"
- : "=a" (result), "=m" (*atomic)
- : "r" (newval), "m" (*atomic), "0" (oldval));
-
- return result == oldval;
-}
-
-/* The same code as above, as on i386 gpointer is 32 bit as well.
- * Duplicating the code here seems more natural than casting the
- * arguments and calling the former function */
-
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gpointer result;
-
- __asm__ __volatile__ ("lock; cmpxchgl %2, %1"
- : "=a" (result), "=m" (*atomic)
- : "r" (newval), "m" (*atomic), "0" (oldval));
-
- return result == oldval;
-}
-
-# elif defined (G_ATOMIC_SPARCV9)
-/* Adapted from CVS version 1.3 of glibc's sysdeps/sparc/sparc64/bits/atomic.h
- */
-# define ATOMIC_INT_CMP_XCHG(atomic, oldval, newval) \
- ({ \
- gint __result; \
- __asm__ __volatile__ ("cas [%4], %2, %0" \
- : "=r" (__result), "=m" (*(atomic)) \
- : "r" (oldval), "m" (*(atomic)), "r" (atomic),\
- "0" (newval)); \
- __result == oldval; \
- })
-
-# if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gpointer result;
- __asm__ __volatile__ ("cas [%4], %2, %0"
- : "=r" (result), "=m" (*atomic)
- : "r" (oldval), "m" (*atomic), "r" (atomic),
- "0" (newval));
- return result == oldval;
-}
-# elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gpointer result;
- gpointer *a = atomic;
- __asm__ __volatile__ ("casx [%4], %2, %0"
- : "=r" (result), "=m" (*a)
- : "r" (oldval), "m" (*a), "r" (a),
- "0" (newval));
- return result == oldval;
-}
-# else /* What's that */
-# error "Your system has an unsupported pointer size"
-# endif /* GLIB_SIZEOF_VOID_P */
-# define G_ATOMIC_MEMORY_BARRIER \
- __asm__ __volatile__ ("membar #LoadLoad | #LoadStore" \
- " | #StoreLoad | #StoreStore" : : : "memory")
-
-# elif defined (G_ATOMIC_ALPHA)
-/* Adapted from CVS version 1.3 of glibc's sysdeps/alpha/bits/atomic.h
- */
-# define ATOMIC_INT_CMP_XCHG(atomic, oldval, newval) \
- ({ \
- gint __result; \
- gint __prev; \
- __asm__ __volatile__ ( \
- " mb\n" \
- "1: ldl_l %0,%2\n" \
- " cmpeq %0,%3,%1\n" \
- " beq %1,2f\n" \
- " mov %4,%1\n" \
- " stl_c %1,%2\n" \
- " beq %1,1b\n" \
- " mb\n" \
- "2:" \
- : "=&r" (__prev), \
- "=&r" (__result) \
- : "m" (*(atomic)), \
- "Ir" (oldval), \
- "Ir" (newval) \
- : "memory"); \
- __result != 0; \
- })
-# if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gint result;
- gpointer prev;
- __asm__ __volatile__ (
- " mb\n"
- "1: ldl_l %0,%2\n"
- " cmpeq %0,%3,%1\n"
- " beq %1,2f\n"
- " mov %4,%1\n"
- " stl_c %1,%2\n"
- " beq %1,1b\n"
- " mb\n"
- "2:"
- : "=&r" (prev),
- "=&r" (result)
- : "m" (*atomic),
- "Ir" (oldval),
- "Ir" (newval)
- : "memory");
- return result != 0;
-}
-# elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gint result;
- gpointer prev;
- __asm__ __volatile__ (
- " mb\n"
- "1: ldq_l %0,%2\n"
- " cmpeq %0,%3,%1\n"
- " beq %1,2f\n"
- " mov %4,%1\n"
- " stq_c %1,%2\n"
- " beq %1,1b\n"
- " mb\n"
- "2:"
- : "=&r" (prev),
- "=&r" (result)
- : "m" (*atomic),
- "Ir" (oldval),
- "Ir" (newval)
- : "memory");
- return result != 0;
-}
-# else /* What's that */
-# error "Your system has an unsupported pointer size"
-# endif /* GLIB_SIZEOF_VOID_P */
-# define G_ATOMIC_MEMORY_BARRIER __asm__ ("mb" : : : "memory")
-# elif defined (G_ATOMIC_X86_64)
-/* Adapted from CVS version 1.9 of glibc's sysdeps/x86_64/bits/atomic.h
- */
-gint
-g_atomic_int_exchange_and_add (volatile gint *atomic,
- gint val)
-{
- gint result;
-
- __asm__ __volatile__ ("lock; xaddl %0,%1"
- : "=r" (result), "=m" (*atomic)
- : "0" (val), "m" (*atomic));
- return result;
-}
-
-void
-g_atomic_int_add (volatile gint *atomic,
- gint val)
-{
- __asm__ __volatile__ ("lock; addl %1,%0"
- : "=m" (*atomic)
- : "ir" (val), "m" (*atomic));
-}
-
-gboolean
-g_atomic_int_compare_and_exchange (volatile gint *atomic,
- gint oldval,
- gint newval)
-{
- gint result;
-
- __asm__ __volatile__ ("lock; cmpxchgl %2, %1"
- : "=a" (result), "=m" (*atomic)
- : "r" (newval), "m" (*atomic), "0" (oldval));
-
- return result == oldval;
-}
-
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gpointer result;
-
- __asm__ __volatile__ ("lock; cmpxchgq %q2, %1"
- : "=a" (result), "=m" (*atomic)
- : "r" (newval), "m" (*atomic), "0" (oldval));
-
- return result == oldval;
-}
-
-# elif defined (G_ATOMIC_POWERPC)
-/* Adapted from CVS version 1.16 of glibc's sysdeps/powerpc/bits/atomic.h
- * and CVS version 1.4 of glibc's sysdeps/powerpc/powerpc32/bits/atomic.h
- * and CVS version 1.7 of glibc's sysdeps/powerpc/powerpc64/bits/atomic.h
- */
-# ifdef __OPTIMIZE__
-/* Non-optimizing compile bails on the following two asm statements
- * for reasons unknown to the author */
-gint
-g_atomic_int_exchange_and_add (volatile gint *atomic,
- gint val)
-{
- gint result, temp;
-#if ASM_NUMERIC_LABELS
- __asm__ __volatile__ ("1: lwarx %0,0,%3\n"
- " add %1,%0,%4\n"
- " stwcx. %1,0,%3\n"
- " bne- 1b"
- : "=&b" (result), "=&r" (temp), "=m" (*atomic)
- : "b" (atomic), "r" (val), "m" (*atomic)
- : "cr0", "memory");
-#else
- __asm__ __volatile__ (".Lieaa%=: lwarx %0,0,%3\n"
- " add %1,%0,%4\n"
- " stwcx. %1,0,%3\n"
- " bne- .Lieaa%="
- : "=&b" (result), "=&r" (temp), "=m" (*atomic)
- : "b" (atomic), "r" (val), "m" (*atomic)
- : "cr0", "memory");
-#endif
- return result;
-}
-
-/* The same as above, to save a function call repeated here */
-void
-g_atomic_int_add (volatile gint *atomic,
- gint val)
-{
- gint result, temp;
-#if ASM_NUMERIC_LABELS
- __asm__ __volatile__ ("1: lwarx %0,0,%3\n"
- " add %1,%0,%4\n"
- " stwcx. %1,0,%3\n"
- " bne- 1b"
- : "=&b" (result), "=&r" (temp), "=m" (*atomic)
- : "b" (atomic), "r" (val), "m" (*atomic)
- : "cr0", "memory");
-#else
- __asm__ __volatile__ (".Lia%=: lwarx %0,0,%3\n"
- " add %1,%0,%4\n"
- " stwcx. %1,0,%3\n"
- " bne- .Lia%="
- : "=&b" (result), "=&r" (temp), "=m" (*atomic)
- : "b" (atomic), "r" (val), "m" (*atomic)
- : "cr0", "memory");
-#endif
-}
-# else /* !__OPTIMIZE__ */
-gint
-g_atomic_int_exchange_and_add (volatile gint *atomic,
- gint val)
-{
- gint result;
- do
- result = *atomic;
- while (!g_atomic_int_compare_and_exchange (atomic, result, result + val));
-
- return result;
-}
-
-void
-g_atomic_int_add (volatile gint *atomic,
- gint val)
-{
- gint result;
- do
- result = *atomic;
- while (!g_atomic_int_compare_and_exchange (atomic, result, result + val));
-}
-# endif /* !__OPTIMIZE__ */
-
-# if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
-gboolean
-g_atomic_int_compare_and_exchange (volatile gint *atomic,
- gint oldval,
- gint newval)
-{
- gint result;
-#if ASM_NUMERIC_LABELS
- __asm__ __volatile__ ("sync\n"
- "1: lwarx %0,0,%1\n"
- " subf. %0,%2,%0\n"
- " bne 2f\n"
- " stwcx. %3,0,%1\n"
- " bne- 1b\n"
- "2: isync"
- : "=&r" (result)
- : "b" (atomic), "r" (oldval), "r" (newval)
- : "cr0", "memory");
-#else
- __asm__ __volatile__ ("sync\n"
- ".L1icae%=: lwarx %0,0,%1\n"
- " subf. %0,%2,%0\n"
- " bne .L2icae%=\n"
- " stwcx. %3,0,%1\n"
- " bne- .L1icae%=\n"
- ".L2icae%=: isync"
- : "=&r" (result)
- : "b" (atomic), "r" (oldval), "r" (newval)
- : "cr0", "memory");
-#endif
- return result == 0;
-}
-
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gpointer result;
-#if ASM_NUMERIC_LABELS
- __asm__ __volatile__ ("sync\n"
- "1: lwarx %0,0,%1\n"
- " subf. %0,%2,%0\n"
- " bne 2f\n"
- " stwcx. %3,0,%1\n"
- " bne- 1b\n"
- "2: isync"
- : "=&r" (result)
- : "b" (atomic), "r" (oldval), "r" (newval)
- : "cr0", "memory");
-#else
- __asm__ __volatile__ ("sync\n"
- ".L1pcae%=: lwarx %0,0,%1\n"
- " subf. %0,%2,%0\n"
- " bne .L2pcae%=\n"
- " stwcx. %3,0,%1\n"
- " bne- .L1pcae%=\n"
- ".L2pcae%=: isync"
- : "=&r" (result)
- : "b" (atomic), "r" (oldval), "r" (newval)
- : "cr0", "memory");
-#endif
- return result == 0;
-}
-# elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
-gboolean
-g_atomic_int_compare_and_exchange (volatile gint *atomic,
- gint oldval,
- gint newval)
-{
- gpointer result;
-#if ASM_NUMERIC_LABELS
- __asm__ __volatile__ ("sync\n"
- "1: lwarx %0,0,%1\n"
- " extsw %0,%0\n"
- " subf. %0,%2,%0\n"
- " bne 2f\n"
- " stwcx. %3,0,%1\n"
- " bne- 1b\n"
- "2: isync"
- : "=&r" (result)
- : "b" (atomic), "r" (oldval), "r" (newval)
- : "cr0", "memory");
-#else
- __asm__ __volatile__ ("sync\n"
- ".L1icae%=: lwarx %0,0,%1\n"
- " extsw %0,%0\n"
- " subf. %0,%2,%0\n"
- " bne .L2icae%=\n"
- " stwcx. %3,0,%1\n"
- " bne- .L1icae%=\n"
- ".L2icae%=: isync"
- : "=&r" (result)
- : "b" (atomic), "r" (oldval), "r" (newval)
- : "cr0", "memory");
-#endif
- return result == 0;
-}
-
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gpointer result;
-#if ASM_NUMERIC_LABELS
- __asm__ __volatile__ ("sync\n"
- "1: ldarx %0,0,%1\n"
- " subf. %0,%2,%0\n"
- " bne 2f\n"
- " stdcx. %3,0,%1\n"
- " bne- 1b\n"
- "2: isync"
- : "=&r" (result)
- : "b" (atomic), "r" (oldval), "r" (newval)
- : "cr0", "memory");
-#else
- __asm__ __volatile__ ("sync\n"
- ".L1pcae%=: ldarx %0,0,%1\n"
- " subf. %0,%2,%0\n"
- " bne .L2pcae%=\n"
- " stdcx. %3,0,%1\n"
- " bne- .L1pcae%=\n"
- ".L2pcae%=: isync"
- : "=&r" (result)
- : "b" (atomic), "r" (oldval), "r" (newval)
- : "cr0", "memory");
-#endif
- return result == 0;
-}
-# else /* What's that */
-# error "Your system has an unsupported pointer size"
-# endif /* GLIB_SIZEOF_VOID_P */
-
-# define G_ATOMIC_MEMORY_BARRIER __asm__ ("sync" : : : "memory")
-
-# elif defined (G_ATOMIC_IA64)
-/* Adapted from CVS version 1.8 of glibc's sysdeps/ia64/bits/atomic.h
- */
-gint
-g_atomic_int_exchange_and_add (volatile gint *atomic,
- gint val)
-{
- return __sync_fetch_and_add (atomic, val);
-}
-
-void
-g_atomic_int_add (volatile gint *atomic,
- gint val)
-{
- __sync_fetch_and_add (atomic, val);
-}
-
-gboolean
-g_atomic_int_compare_and_exchange (volatile gint *atomic,
- gint oldval,
- gint newval)
-{
- return __sync_bool_compare_and_swap (atomic, oldval, newval);
-}
-
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- return __sync_bool_compare_and_swap ((long *)atomic,
- (long)oldval, (long)newval);
-}
-
-# define G_ATOMIC_MEMORY_BARRIER __sync_synchronize ()
-# elif defined (G_ATOMIC_S390)
-/* Adapted from glibc's sysdeps/s390/bits/atomic.h
- */
-# define ATOMIC_INT_CMP_XCHG(atomic, oldval, newval) \
- ({ \
- gint __result = oldval; \
- __asm__ __volatile__ ("cs %0, %2, %1" \
- : "+d" (__result), "=Q" (*(atomic)) \
- : "d" (newval), "m" (*(atomic)) : "cc" ); \
- __result == oldval; \
- })
-
-# if GLIB_SIZEOF_VOID_P == 4 /* 32-bit system */
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gpointer result = oldval;
- __asm__ __volatile__ ("cs %0, %2, %1"
- : "+d" (result), "=Q" (*(atomic))
- : "d" (newval), "m" (*(atomic)) : "cc" );
- return result == oldval;
-}
-# elif GLIB_SIZEOF_VOID_P == 8 /* 64-bit system */
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gpointer result = oldval;
- gpointer *a = atomic;
- __asm__ __volatile__ ("csg %0, %2, %1"
- : "+d" (result), "=Q" (*a)
- : "d" ((long)(newval)), "m" (*a) : "cc" );
- return result == oldval;
-}
-# else /* What's that */
-# error "Your system has an unsupported pointer size"
-# endif /* GLIB_SIZEOF_VOID_P */
-# elif defined (G_ATOMIC_ARM)
-static volatile int atomic_spin = 0;
-
-static int atomic_spin_trylock (void)
-{
- int result;
-
- asm volatile (
- "swp %0, %1, [%2]\n"
- : "=&r,&r" (result)
- : "r,0" (1), "r,r" (&atomic_spin)
- : "memory");
- if (result == 0)
- return 0;
- else
- return -1;
-}
-
-static void atomic_spin_lock (void)
-{
- while (atomic_spin_trylock())
- sched_yield();
-}
-
-static void atomic_spin_unlock (void)
-{
- atomic_spin = 0;
-}
-
-gint
-g_atomic_int_exchange_and_add (volatile gint *atomic,
- gint val)
-{
- gint result;
-
- atomic_spin_lock();
- result = *atomic;
- *atomic += val;
- atomic_spin_unlock();
-
- return result;
-}
-
-void
-g_atomic_int_add (volatile gint *atomic,
- gint val)
-{
- atomic_spin_lock();
- *atomic += val;
- atomic_spin_unlock();
-}
-
-gboolean
-g_atomic_int_compare_and_exchange (volatile gint *atomic,
- gint oldval,
- gint newval)
-{
- gboolean result;
-
- atomic_spin_lock();
- if (*atomic == oldval)
- {
- result = TRUE;
- *atomic = newval;
- }
- else
- result = FALSE;
- atomic_spin_unlock();
-
- return result;
-}
-
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gboolean result;
-
- atomic_spin_lock();
- if (*atomic == oldval)
- {
- result = TRUE;
- *atomic = newval;
- }
- else
- result = FALSE;
- atomic_spin_unlock();
-
- return result;
-}
-# elif defined(G_PLATFORM_WIN32)
-# define DEFINE_WITH_WIN32_INTERLOCKED
-# else
-# define DEFINE_WITH_MUTEXES
-# endif /* G_ATOMIC_IA64 */
-#else /* !__GNUC__ */
-# ifdef G_PLATFORM_WIN32
-# define DEFINE_WITH_WIN32_INTERLOCKED
-# else
-# define DEFINE_WITH_MUTEXES
-# endif
-#endif /* __GNUC__ */
-
-#ifdef DEFINE_WITH_WIN32_INTERLOCKED
-# include <windows.h>
-/* Following indicates that InterlockedCompareExchangePointer is
- * declared in winbase.h (included by windows.h) and needs to be
- * commented out if not true. It is defined iff WINVER > 0x0400,
- * which is usually correct but can be wrong if WINVER is set before
- * windows.h is included.
- */
-# if WINVER > 0x0400
-# define HAVE_INTERLOCKED_COMPARE_EXCHANGE_POINTER
-# endif
-
-gint32
-g_atomic_int_exchange_and_add (volatile gint32 *atomic,
- gint32 val)
-{
- return InterlockedExchangeAdd (atomic, val);
-}
-
-void
-g_atomic_int_add (volatile gint32 *atomic,
- gint32 val)
-{
- InterlockedExchangeAdd (atomic, val);
-}
-
-gboolean
-g_atomic_int_compare_and_exchange (volatile gint32 *atomic,
- gint32 oldval,
- gint32 newval)
-{
-#ifndef HAVE_INTERLOCKED_COMPARE_EXCHANGE_POINTER
- return (guint32) InterlockedCompareExchange ((PVOID*)atomic,
- (PVOID)newval,
- (PVOID)oldval) == oldval;
-#else
- return InterlockedCompareExchange (atomic,
- newval,
- oldval) == oldval;
-#endif
-}
-
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
-# ifdef HAVE_INTERLOCKED_COMPARE_EXCHANGE_POINTER
- return InterlockedCompareExchangePointer (atomic, newval, oldval) == oldval;
-# else
-# if GLIB_SIZEOF_VOID_P != 4 /* no 32-bit system */
-# error "InterlockedCompareExchangePointer needed"
-# else
- return InterlockedCompareExchange (atomic, newval, oldval) == oldval;
-# endif
-# endif
-}
-#endif /* DEFINE_WITH_WIN32_INTERLOCKED */
-
-#ifdef DEFINE_WITH_MUTEXES
-/* We have to use the slow, but safe locking method */
-static GMutex *g_atomic_mutex;
-
-gint
-g_atomic_int_exchange_and_add (volatile gint *atomic,
- gint val)
-{
- gint result;
-
- g_mutex_lock (g_atomic_mutex);
- result = *atomic;
- *atomic += val;
- g_mutex_unlock (g_atomic_mutex);
-
- return result;
-}
-
-
-void
-g_atomic_int_add (volatile gint *atomic,
- gint val)
-{
- g_mutex_lock (g_atomic_mutex);
- *atomic += val;
- g_mutex_unlock (g_atomic_mutex);
-}
-
-gboolean
-g_atomic_int_compare_and_exchange (volatile gint *atomic,
- gint oldval,
- gint newval)
-{
- gboolean result;
-
- g_mutex_lock (g_atomic_mutex);
- if (*atomic == oldval)
- {
- result = TRUE;
- *atomic = newval;
- }
- else
- result = FALSE;
- g_mutex_unlock (g_atomic_mutex);
-
- return result;
-}
-
-gboolean
-g_atomic_pointer_compare_and_exchange (volatile gpointer *atomic,
- gpointer oldval,
- gpointer newval)
-{
- gboolean result;
-
- g_mutex_lock (g_atomic_mutex);
- if (*atomic == oldval)
- {
- result = TRUE;
- *atomic = newval;
- }
- else
- result = FALSE;
- g_mutex_unlock (g_atomic_mutex);
-
- return result;
-}
-
-#ifdef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
-gint
-g_atomic_int_get (volatile gint *atomic)
-{
- gint result;
-
- g_mutex_lock (g_atomic_mutex);
- result = *atomic;
- g_mutex_unlock (g_atomic_mutex);
-
- return result;
-}
-
-void
-g_atomic_int_set (volatile gint *atomic,
- gint newval)
-{
- g_mutex_lock (g_atomic_mutex);
- *atomic = newval;
- g_mutex_unlock (g_atomic_mutex);
-}
-
-gpointer
-g_atomic_pointer_get (volatile gpointer *atomic)
-{
- gpointer result;
-
- g_mutex_lock (g_atomic_mutex);
- result = *atomic;
- g_mutex_unlock (g_atomic_mutex);
-
- return result;
-}
-
-void
-g_atomic_pointer_set (volatile gpointer *atomic,
- gpointer newval)
-{
- g_mutex_lock (g_atomic_mutex);
- *atomic = newval;
- g_mutex_unlock (g_atomic_mutex);
-}
-#endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */
-#elif defined (G_ATOMIC_OP_MEMORY_BARRIER_NEEDED)
-gint
-g_atomic_int_get (volatile gint *atomic)
-{
- G_ATOMIC_MEMORY_BARRIER;
- return *atomic;
-}
-
-void
-g_atomic_int_set (volatile gint *atomic,
- gint newval)
-{
- *atomic = newval;
- G_ATOMIC_MEMORY_BARRIER;
-}
-
-gpointer
-g_atomic_pointer_get (volatile gpointer *atomic)
-{
- G_ATOMIC_MEMORY_BARRIER;
- return *atomic;
-}
-
-void
-g_atomic_pointer_set (volatile gpointer *atomic,
- gpointer newval)
-{
- *atomic = newval;
- G_ATOMIC_MEMORY_BARRIER;
-}
-#endif /* DEFINE_WITH_MUTEXES || G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */
-
-#ifdef ATOMIC_INT_CMP_XCHG
-gboolean
-g_atomic_int_compare_and_exchange (volatile gint *atomic,
- gint oldval,
- gint newval)
-{
- return ATOMIC_INT_CMP_XCHG (atomic, oldval, newval);
-}
-
-gint
-g_atomic_int_exchange_and_add (volatile gint *atomic,
- gint val)
-{
- gint result;
- do
- result = *atomic;
- while (!ATOMIC_INT_CMP_XCHG (atomic, result, result + val));
-
- return result;
-}
-
-void
-g_atomic_int_add (volatile gint *atomic,
- gint val)
-{
- gint result;
- do
- result = *atomic;
- while (!ATOMIC_INT_CMP_XCHG (atomic, result, result + val));
-}
-#endif /* ATOMIC_INT_CMP_XCHG */
-
-void
-_g_atomic_thread_init (void)
-{
-#ifdef DEFINE_WITH_MUTEXES
- g_atomic_mutex = g_mutex_new ();
-#endif /* DEFINE_WITH_MUTEXES */
-}
-
-#ifndef G_ATOMIC_OP_MEMORY_BARRIER_NEEDED
-gint
-(g_atomic_int_get) (volatile gint *atomic)
-{
- return g_atomic_int_get (atomic);
-}
-
-void
-(g_atomic_int_set) (volatile gint *atomic,
- gint newval)
-{
- g_atomic_int_set (atomic, newval);
-}
-
-gpointer
-(g_atomic_pointer_get) (volatile gpointer *atomic)
-{
- return g_atomic_pointer_get (atomic);
-}
-
-void
-(g_atomic_pointer_set) (volatile gpointer *atomic,
- gpointer newval)
-{
- g_atomic_pointer_set (atomic, newval);
-}
-#endif /* G_ATOMIC_OP_MEMORY_BARRIER_NEEDED */
-
-#define __G_ATOMIC_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gerror.c b/navit/support/glib/gerror.c
deleted file mode 100644
index 34d8c2841..000000000
--- a/navit/support/glib/gerror.c
+++ /dev/null
@@ -1,381 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#include "config.h"
-
-#include "glib.h"
-#include "galias.h"
-
-
-static GError*
-g_error_new_valist (GQuark domain,
- gint code,
- const gchar *format,
- va_list args)
-{
- GError *error;
-
- error = g_slice_new (GError);
-
- error->domain = domain;
- error->code = code;
- error->message = g_strdup_vprintf (format, args);
-
- return error;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-/**
- * g_error_new:
- * @domain: error domain
- * @code: error code
- * @format: printf()-style format for error message
- * @Varargs: parameters for message format
- *
- * Creates a new #GError with the given @domain and @code,
- * and a message formatted with @format.
- *
- * Return value: a new #GError
- **/
-GError*
-g_error_new (GQuark domain,
- gint code,
- const gchar *format,
- ...)
-{
- GError* error;
- va_list args;
-
- g_return_val_if_fail (format != NULL, NULL);
- g_return_val_if_fail (domain != 0, NULL);
-
- va_start (args, format);
- error = g_error_new_valist (domain, code, format, args);
- va_end (args);
-
- return error;
-}
-
-/**
- * g_error_new_literal:
- * @domain: error domain
- * @code: error code
- * @message: error message
- *
- * Creates a new #GError; unlike g_error_new(), @message is not
- * a printf()-style format string. Use this
- * function if @message contains text you don't have control over,
- * that could include printf() escape sequences.
- *
- * Return value: a new #GError
- **/
-GError*
-g_error_new_literal (GQuark domain,
- gint code,
- const gchar *message)
-{
- GError* err;
-
- g_return_val_if_fail (message != NULL, NULL);
- g_return_val_if_fail (domain != 0, NULL);
-
- err = g_slice_new (GError);
-
- err->domain = domain;
- err->code = code;
- err->message = g_strdup (message);
-
- return err;
-}
-
-/**
- * g_error_free:
- * @error: a #GError
- *
- * Frees a #GError and associated resources.
- *
- **/
-void
-g_error_free (GError *error)
-{
- g_return_if_fail (error != NULL);
-
- g_free (error->message);
-
- g_slice_free (GError, error);
-}
-
-/**
- * g_error_copy:
- * @error: a #GError
- *
- * Makes a copy of @error.
- *
- * Return value: a new #GError
- **/
-GError*
-g_error_copy (const GError *error)
-{
- GError *copy;
-
- g_return_val_if_fail (error != NULL, NULL);
-
- copy = g_slice_new (GError);
-
- *copy = *error;
-
- copy->message = g_strdup (error->message);
-
- return copy;
-}
-
-/**
- * g_error_matches:
- * @error: a #GError
- * @domain: an error domain
- * @code: an error code
- *
- * Returns %TRUE if @error matches @domain and @code, %FALSE
- * otherwise.
- *
- * Return value: whether @error has @domain and @code
- **/
-gboolean
-g_error_matches (const GError *error,
- GQuark domain,
- gint code)
-{
- return error &&
- error->domain == domain &&
- error->code == code;
-}
-
-#define ERROR_OVERWRITTEN_WARNING "GError set over the top of a previous GError or uninitialized memory.\n" \
- "This indicates a bug in someone's code. You must ensure an error is NULL before it's set.\n" \
- "The overwriting error message was: %s"
-#endif /* NOT_NEEDED_FOR_NAVIT */
-
-/**
- * g_set_error:
- * @err: a return location for a #GError, or %NULL
- * @domain: error domain
- * @code: error code
- * @format: printf()-style format
- * @Varargs: args for @format
- *
- * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err must
- * be %NULL. A new #GError is created and assigned to *@err.
- **/
-void
-g_set_error (GError **err,
- GQuark domain,
- gint code,
- const gchar *format,
- ...)
-{
- GError *new;
-
- va_list args;
-
- if (err == NULL)
- return;
-
- va_start (args, format);
- new = g_error_new_valist (domain, code, format, args);
- va_end (args);
-
- if (*err == NULL)
- *err = new;
-#if NOT_NEEDED_FOR_NAVIT
- else
- g_warning (ERROR_OVERWRITTEN_WARNING, new->message);
-#endif /* NOT_NEEDED_FOR_NAVIT */
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-/**
- * g_set_error_literal:
- * @err: a return location for a #GError, or %NULL
- * @domain: error domain
- * @code: error code
- * @message: error message
- *
- * Does nothing if @err is %NULL; if @err is non-%NULL, then *@err must
- * be %NULL. A new #GError is created and assigned to *@err.
- * Unlike g_set_error(), @message is not a printf()-style format string.
- * Use this function if @message contains text you don't have control over,
- * that could include printf() escape sequences.
- *
- * Since: 2.18
- **/
-void
-g_set_error_literal (GError **err,
- GQuark domain,
- gint code,
- const gchar *message)
-{
- GError *new;
-
- if (err == NULL)
- return;
-
- new = g_error_new_literal (domain, code, message);
- if (*err == NULL)
- *err = new;
- else
- g_warning (ERROR_OVERWRITTEN_WARNING, new->message);
-}
-
-/**
- * g_propagate_error:
- * @dest: error return location
- * @src: error to move into the return location
- *
- * If @dest is %NULL, free @src; otherwise, moves @src into *@dest.
- * The error variable @dest points to must be %NULL.
- **/
-void
-g_propagate_error (GError **dest,
- GError *src)
-{
- g_return_if_fail (src != NULL);
-
- if (dest == NULL)
- {
- if (src)
- g_error_free (src);
- return;
- }
- else
- {
- if (*dest != NULL)
- g_warning (ERROR_OVERWRITTEN_WARNING, src->message);
- else
- *dest = src;
- }
-}
-
-/**
- * g_clear_error:
- * @err: a #GError return location
- *
- * If @err is %NULL, does nothing. If @err is non-%NULL,
- * calls g_error_free() on *@err and sets *@err to %NULL.
- **/
-void
-g_clear_error (GError **err)
-{
- if (err && *err)
- {
- g_error_free (*err);
- *err = NULL;
- }
-}
-
-static void
-g_error_add_prefix (gchar **string,
- const gchar *format,
- va_list ap)
-{
- gchar *oldstring;
- gchar *prefix;
-
- prefix = g_strdup_vprintf (format, ap);
- oldstring = *string;
- *string = g_strconcat (prefix, oldstring, NULL);
- g_free (oldstring);
- g_free (prefix);
-}
-
-/**
- * g_prefix_error:
- * @err: a return location for a #GError, or %NULL
- * @format: printf()-style format string
- * @...: arguments to @format
- *
- * Formats a string according to @format and
- * prefix it to an existing error message. If
- * @err is %NULL (ie: no error variable) then do
- * nothing.
- *
- * If *@err is %NULL (ie: an error variable is
- * present but there is no error condition) then
- * also do nothing. Whether or not it makes
- * sense to take advantage of this feature is up
- * to you.
- *
- * Since: 2.16
- **/
-void
-g_prefix_error (GError **err,
- const gchar *format,
- ...)
-{
- if (err && *err)
- {
- va_list ap;
-
- va_start (ap, format);
- g_error_add_prefix (&(*err)->message, format, ap);
- va_end (ap);
- }
-}
-
-/**
- * g_propagate_prefixed_error:
- * @dest: error return location
- * @src: error to move into the return location
- * @format: printf()-style format string
- * @...: arguments to @format
- *
- * If @dest is %NULL, free @src; otherwise,
- * moves @src into *@dest. *@dest must be %NULL.
- * After the move, add a prefix as with
- * g_prefix_error().
- *
- * Since: 2.16
- **/
-void
-g_propagate_prefixed_error (GError **dest,
- GError *src,
- const gchar *format,
- ...)
-{
- g_propagate_error (dest, src);
-
- if (dest && *dest)
- {
- va_list ap;
-
- va_start (ap, format);
- g_error_add_prefix (&(*dest)->message, format, ap);
- va_end (ap);
- }
-}
-
-#endif /* NOT_NEEDED_FOR_NAVIT */
-#define __G_ERROR_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gerror.h b/navit/support/glib/gerror.h
deleted file mode 100644
index d3d42d59c..000000000
--- a/navit/support/glib/gerror.h
+++ /dev/null
@@ -1,92 +0,0 @@
-/* gerror.h - Error reporting system
- *
- * Copyright 2000 Red Hat, Inc.
- *
- * The Gnome Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * The Gnome Library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the Gnome Library; see the file COPYING.LIB. If not,
- * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_ERROR_H__
-#define __G_ERROR_H__
-
-#include <glib/gquark.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GError GError;
-
-struct _GError
-{
- GQuark domain;
- gint code;
- gchar *message;
-};
-
-GError* g_error_new (GQuark domain,
- gint code,
- const gchar *format,
- ...) G_GNUC_PRINTF (3, 4);
-
-GError* g_error_new_literal (GQuark domain,
- gint code,
- const gchar *message);
-
-void g_error_free (GError *error);
-GError* g_error_copy (const GError *error);
-
-gboolean g_error_matches (const GError *error,
- GQuark domain,
- gint code);
-
-/* if (err) *err = g_error_new(domain, code, format, ...), also has
- * some sanity checks.
- */
-void g_set_error (GError **err,
- GQuark domain,
- gint code,
- const gchar *format,
- ...) G_GNUC_PRINTF (4, 5);
-
-void g_set_error_literal (GError **err,
- GQuark domain,
- gint code,
- const gchar *message);
-
-/* if (dest) *dest = src; also has some sanity checks.
- */
-void g_propagate_error (GError **dest,
- GError *src);
-
-/* if (err && *err) { g_error_free(*err); *err = NULL; } */
-void g_clear_error (GError **err);
-
-/* if (err) prefix the formatted string to the ->message */
-void g_prefix_error (GError **err,
- const gchar *format,
- ...) G_GNUC_PRINTF (2, 3);
-
-/* g_propagate_error then g_error_prefix on dest */
-void g_propagate_prefixed_error (GError **dest,
- GError *src,
- const gchar *format,
- ...) G_GNUC_PRINTF (3, 4);
-
-G_END_DECLS
-
-#endif /* __G_ERROR_H__ */
diff --git a/navit/support/glib/ghash.c b/navit/support/glib/ghash.c
deleted file mode 100644
index e00b4c4cc..000000000
--- a/navit/support/glib/ghash.c
+++ /dev/null
@@ -1,1202 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * MT safe
- */
-
-#include "config.h"
-
-#include "glib.h"
-#include "galias.h"
-
-
-#define HASH_TABLE_MIN_SIZE 11
-#define HASH_TABLE_MAX_SIZE 13845163
-
-
-typedef struct _GHashNode GHashNode;
-
-struct _GHashNode
-{
- gpointer key;
- gpointer value;
- GHashNode *next;
- guint key_hash;
-};
-
-struct _GHashTable
-{
- gint size;
- gint nnodes;
- GHashNode **nodes;
- GHashFunc hash_func;
- GEqualFunc key_equal_func;
- volatile gint ref_count;
-#ifndef G_DISABLE_ASSERT
- /*
- * Tracks the structure of the hash table, not its contents: is only
- * incremented when a node is added or removed (is not incremented
- * when the key or data of a node is modified).
- */
- int version;
-#endif
- GDestroyNotify key_destroy_func;
- GDestroyNotify value_destroy_func;
-};
-
-typedef struct
-{
- GHashTable *hash_table;
- GHashNode *prev_node;
- GHashNode *node;
- int position;
- gboolean pre_advanced;
- int version;
-} RealIter;
-
-/*
- * g_hash_table_lookup_node:
- * @hash_table: our #GHashTable
- * @key: the key to lookup against
- * @hash_return: optional key hash return location
- * Return value: a pointer to the described #GHashNode pointer
- *
- * Performs a lookup in the hash table. Virtually all hash operations
- * will use this function internally.
- *
- * This function first computes the hash value of the key using the
- * user's hash function.
- *
- * If an entry in the table matching @key is found then this function
- * returns a pointer to the pointer to that entry in the table. In
- * the case that the entry is at the head of a chain, this pointer
- * will be an item in the nodes[] array. In the case that the entry
- * is not at the head of a chain, this pointer will be the ->next
- * pointer on the node that preceeds it.
- *
- * In the case that no matching entry exists in the table, a pointer
- * to a %NULL pointer will be returned. To insert a item, this %NULL
- * pointer should be updated to point to the new #GHashNode.
- *
- * If @hash_return is a pass-by-reference parameter. If it is
- * non-%NULL then the computed hash value is returned. This is to
- * save insertions from having to compute the hash record again for
- * the new record.
- */
-static inline GHashNode **
-g_hash_table_lookup_node (GHashTable *hash_table,
- gconstpointer key,
- guint *hash_return)
-{
- GHashNode **node_ptr, *node;
- guint hash_value;
-
- hash_value = (* hash_table->hash_func) (key);
- node_ptr = &hash_table->nodes[hash_value % hash_table->size];
-
- if (hash_return)
- *hash_return = hash_value;
-
- /* Hash table lookup needs to be fast.
- * We therefore remove the extra conditional of testing
- * whether to call the key_equal_func or not from
- * the inner loop.
- *
- * Additional optimisation: first check if our full hash
- * values are equal so we can avoid calling the full-blown
- * key equality function in most cases.
- */
- if (hash_table->key_equal_func)
- {
- while ((node = *node_ptr))
- {
- if (node->key_hash == hash_value &&
- hash_table->key_equal_func (node->key, key))
- break;
-
- node_ptr = &(*node_ptr)->next;
- }
- }
- else
- {
- while ((node = *node_ptr))
- {
- if (node->key == key)
- break;
-
- node_ptr = &(*node_ptr)->next;
- }
- }
-
- return node_ptr;
-}
-
-/*
- * g_hash_table_remove_node:
- * @hash_table: our #GHashTable
- * @node_ptr_ptr: a pointer to the return value from
- * g_hash_table_lookup_node()
- * @notify: %TRUE if the destroy notify handlers are to be called
- *
- * Removes a node from the hash table and updates the node count. The
- * node is freed. No table resize is performed.
- *
- * If @notify is %TRUE then the destroy notify functions are called
- * for the key and value of the hash node.
- *
- * @node_ptr_ptr is a pass-by-reference in/out parameter. When the
- * function is called, it should point to the pointer to the node to
- * remove. This level of indirection is required so that the pointer
- * may be updated appropriately once the node has been removed.
- *
- * Before the function returns, the pointer at @node_ptr_ptr will be
- * updated to point to the position in the table that contains the
- * pointer to the "next" node in the chain. This makes this function
- * convenient to use from functions that iterate over the entire
- * table. If there is no further item in the chain then the
- * #GHashNode pointer will be %NULL (ie: **node_ptr_ptr == %NULL).
- *
- * Since the pointer in the table to the removed node is replaced with
- * either a pointer to the next node or a %NULL pointer as
- * appropriate, the pointer at the end of @node_ptr_ptr will never be
- * modified at all. Stay tuned. :)
- */
-static void
-g_hash_table_remove_node (GHashTable *hash_table,
- GHashNode ***node_ptr_ptr,
- gboolean notify)
-{
- GHashNode **node_ptr, *node;
-
- node_ptr = *node_ptr_ptr;
- node = *node_ptr;
-
- *node_ptr = node->next;
-
- if (notify && hash_table->key_destroy_func)
- hash_table->key_destroy_func (node->key);
-
- if (notify && hash_table->value_destroy_func)
- hash_table->value_destroy_func (node->value);
-
- g_slice_free (GHashNode, node);
-
- hash_table->nnodes--;
-}
-
-/*
- * g_hash_table_remove_all_nodes:
- * @hash_table: our #GHashTable
- * @notify: %TRUE if the destroy notify handlers are to be called
- *
- * Removes all nodes from the table. Since this may be a precursor to
- * freeing the table entirely, no resize is performed.
- *
- * If @notify is %TRUE then the destroy notify functions are called
- * for the key and value of the hash node.
- */
-static void
-g_hash_table_remove_all_nodes (GHashTable *hash_table,
- gboolean notify)
-{
- GHashNode **node_ptr;
- int i;
-
- for (i = 0; i < hash_table->size; i++)
- for (node_ptr = &hash_table->nodes[i]; *node_ptr != NULL;)
- g_hash_table_remove_node (hash_table, &node_ptr, notify);
-
- hash_table->nnodes = 0;
-}
-
-/*
- * g_hash_table_resize:
- * @hash_table: our #GHashTable
- *
- * Resizes the hash table to the optimal size based on the number of
- * nodes currently held. If you call this function then a resize will
- * occur, even if one does not need to occur. Use
- * g_hash_table_maybe_resize() instead.
- */
-static void
-g_hash_table_resize (GHashTable *hash_table)
-{
- GHashNode **new_nodes;
- GHashNode *node;
- GHashNode *next;
- guint hash_val;
- gint new_size;
- gint i;
-
- new_size = g_spaced_primes_closest (hash_table->nnodes);
- new_size = CLAMP (new_size, HASH_TABLE_MIN_SIZE, HASH_TABLE_MAX_SIZE);
-
- new_nodes = g_new0 (GHashNode*, new_size);
-
- for (i = 0; i < hash_table->size; i++)
- for (node = hash_table->nodes[i]; node; node = next)
- {
- next = node->next;
-
- hash_val = node->key_hash % new_size;
-
- node->next = new_nodes[hash_val];
- new_nodes[hash_val] = node;
- }
-
- g_free (hash_table->nodes);
- hash_table->nodes = new_nodes;
- hash_table->size = new_size;
-}
-
-/*
- * g_hash_table_maybe_resize:
- * @hash_table: our #GHashTable
- *
- * Resizes the hash table, if needed.
- *
- * Essentially, calls g_hash_table_resize() if the table has strayed
- * too far from its ideal size for its number of nodes.
- */
-static inline void
-g_hash_table_maybe_resize (GHashTable *hash_table)
-{
- gint nnodes = hash_table->nnodes;
- gint size = hash_table->size;
-
- if ((size >= 3 * nnodes && size > HASH_TABLE_MIN_SIZE) ||
- (3 * size <= nnodes && size < HASH_TABLE_MAX_SIZE))
- g_hash_table_resize (hash_table);
-}
-
-/**
- * g_hash_table_new:
- * @hash_func: a function to create a hash value from a key.
- * Hash values are used to determine where keys are stored within the
- * #GHashTable data structure. The g_direct_hash(), g_int_hash() and
- * g_str_hash() functions are provided for some common types of keys.
- * If hash_func is %NULL, g_direct_hash() is used.
- * @key_equal_func: a function to check two keys for equality. This is
- * used when looking up keys in the #GHashTable. The g_direct_equal(),
- * g_int_equal() and g_str_equal() functions are provided for the most
- * common types of keys. If @key_equal_func is %NULL, keys are compared
- * directly in a similar fashion to g_direct_equal(), but without the
- * overhead of a function call.
- *
- * Creates a new #GHashTable with a reference count of 1.
- *
- * Return value: a new #GHashTable.
- **/
-GHashTable*
-g_hash_table_new (GHashFunc hash_func,
- GEqualFunc key_equal_func)
-{
- return g_hash_table_new_full (hash_func, key_equal_func, NULL, NULL);
-}
-
-
-/**
- * g_hash_table_new_full:
- * @hash_func: a function to create a hash value from a key.
- * @key_equal_func: a function to check two keys for equality.
- * @key_destroy_func: a function to free the memory allocated for the key
- * used when removing the entry from the #GHashTable or %NULL if you
- * don't want to supply such a function.
- * @value_destroy_func: a function to free the memory allocated for the
- * value used when removing the entry from the #GHashTable or %NULL if
- * you don't want to supply such a function.
- *
- * Creates a new #GHashTable like g_hash_table_new() with a reference count
- * of 1 and allows to specify functions to free the memory allocated for the
- * key and value that get called when removing the entry from the #GHashTable.
- *
- * Return value: a new #GHashTable.
- **/
-GHashTable*
-g_hash_table_new_full (GHashFunc hash_func,
- GEqualFunc key_equal_func,
- GDestroyNotify key_destroy_func,
- GDestroyNotify value_destroy_func)
-{
- GHashTable *hash_table;
-
- hash_table = g_slice_new (GHashTable);
- hash_table->size = HASH_TABLE_MIN_SIZE;
- hash_table->nnodes = 0;
- hash_table->hash_func = hash_func ? hash_func : g_direct_hash;
- hash_table->key_equal_func = key_equal_func;
- hash_table->ref_count = 1;
-#ifndef G_DISABLE_ASSERT
- hash_table->version = 0;
-#endif
- hash_table->key_destroy_func = key_destroy_func;
- hash_table->value_destroy_func = value_destroy_func;
- hash_table->nodes = g_new0 (GHashNode*, hash_table->size);
-
- return hash_table;
-}
-
-/**
- * g_hash_table_iter_init:
- * @iter: an uninitialized #GHashTableIter.
- * @hash_table: a #GHashTable.
- *
- * Initializes a key/value pair iterator and associates it with
- * @hash_table. Modifying the hash table after calling this function
- * invalidates the returned iterator.
- * |[
- * GHashTableIter iter;
- * gpointer key, value;
- *
- * g_hash_table_iter_init (&iter, hash_table);
- * while (g_hash_table_iter_next (&iter, &key, &value))
- * {
- * /&ast; do something with key and value &ast;/
- * }
- * ]|
- *
- * Since: 2.16
- **/
-void
-g_hash_table_iter_init (GHashTableIter *iter,
- GHashTable *hash_table)
-{
- RealIter *ri = (RealIter *) iter;
-
- g_return_if_fail (iter != NULL);
- g_return_if_fail (hash_table != NULL);
-
- ri->hash_table = hash_table;
- ri->prev_node = NULL;
- ri->node = NULL;
- ri->position = -1;
- ri->pre_advanced = FALSE;
-#ifndef G_DISABLE_ASSERT
- ri->version = hash_table->version;
-#endif
-}
-
-/**
- * g_hash_table_iter_next:
- * @iter: an initialized #GHashTableIter.
- * @key: a location to store the key, or %NULL.
- * @value: a location to store the value, or %NULL.
- *
- * Advances @iter and retrieves the key and/or value that are now
- * pointed to as a result of this advancement. If %FALSE is returned,
- * @key and @value are not set, and the iterator becomes invalid.
- *
- * Return value: %FALSE if the end of the #GHashTable has been reached.
- *
- * Since: 2.16
- **/
-gboolean
-g_hash_table_iter_next (GHashTableIter *iter,
- gpointer *key,
- gpointer *value)
-{
- RealIter *ri = (RealIter *) iter;
-
- g_return_val_if_fail (iter != NULL, FALSE);
-#ifndef G_DISABLE_ASSERT
- g_return_val_if_fail (ri->version == ri->hash_table->version, FALSE);
-#endif
-
- if (ri->pre_advanced)
- {
- ri->pre_advanced = FALSE;
-
- if (ri->node == NULL)
- return FALSE;
- }
- else
- {
- if (ri->node != NULL)
- {
- ri->prev_node = ri->node;
- ri->node = ri->node->next;
- }
-
- while (ri->node == NULL)
- {
- ri->position++;
- if (ri->position >= ri->hash_table->size)
- return FALSE;
-
- ri->prev_node = NULL;
- ri->node = ri->hash_table->nodes[ri->position];
- }
- }
-
- if (key != NULL)
- *key = ri->node->key;
- if (value != NULL)
- *value = ri->node->value;
-
- return TRUE;
-}
-
-/**
- * g_hash_table_iter_get_hash_table:
- * @iter: an initialized #GHashTableIter.
- *
- * Returns the #GHashTable associated with @iter.
- *
- * Return value: the #GHashTable associated with @iter.
- *
- * Since: 2.16
- **/
-GHashTable *
-g_hash_table_iter_get_hash_table (GHashTableIter *iter)
-{
- g_return_val_if_fail (iter != NULL, NULL);
-
- return ((RealIter *) iter)->hash_table;
-}
-
-static void
-iter_remove_or_steal (RealIter *ri, gboolean notify)
-{
- GHashNode *prev;
- GHashNode *node;
- int position;
-
- g_return_if_fail (ri != NULL);
-#ifndef G_DISABLE_ASSERT
- g_return_if_fail (ri->version == ri->hash_table->version);
-#endif
- g_return_if_fail (ri->node != NULL);
-
- prev = ri->prev_node;
- node = ri->node;
- position = ri->position;
-
- /* pre-advance the iterator since we will remove the node */
-
- ri->node = ri->node->next;
- /* ri->prev_node is still the correct previous node */
-
- while (ri->node == NULL)
- {
- ri->position++;
- if (ri->position >= ri->hash_table->size)
- break;
-
- ri->prev_node = NULL;
- ri->node = ri->hash_table->nodes[ri->position];
- }
-
- ri->pre_advanced = TRUE;
-
- /* remove the node */
-
- if (prev != NULL)
- prev->next = node->next;
- else
- ri->hash_table->nodes[position] = node->next;
-
- if (notify)
- {
- if (ri->hash_table->key_destroy_func)
- ri->hash_table->key_destroy_func(node->key);
- if (ri->hash_table->value_destroy_func)
- ri->hash_table->value_destroy_func(node->value);
- }
-
- g_slice_free (GHashNode, node);
-
- ri->hash_table->nnodes--;
-
-#ifndef G_DISABLE_ASSERT
- ri->version++;
- ri->hash_table->version++;
-#endif
-}
-
-/**
- * g_hash_table_iter_remove():
- * @iter: an initialized #GHashTableIter.
- *
- * Removes the key/value pair currently pointed to by the iterator
- * from its associated #GHashTable. Can only be called after
- * g_hash_table_iter_next() returned %TRUE, and cannot be called more
- * than once for the same key/value pair.
- *
- * If the #GHashTable was created using g_hash_table_new_full(), the
- * key and value are freed using the supplied destroy functions, otherwise
- * you have to make sure that any dynamically allocated values are freed
- * yourself.
- *
- * Since: 2.16
- **/
-void
-g_hash_table_iter_remove (GHashTableIter *iter)
-{
- iter_remove_or_steal ((RealIter *) iter, TRUE);
-}
-
-/**
- * g_hash_table_iter_steal():
- * @iter: an initialized #GHashTableIter.
- *
- * Removes the key/value pair currently pointed to by the iterator
- * from its associated #GHashTable, without calling the key and value
- * destroy functions. Can only be called after
- * g_hash_table_iter_next() returned %TRUE, and cannot be called more
- * than once for the same key/value pair.
- *
- * Since: 2.16
- **/
-void
-g_hash_table_iter_steal (GHashTableIter *iter)
-{
- iter_remove_or_steal ((RealIter *) iter, FALSE);
-}
-
-
-/**
- * g_hash_table_ref:
- * @hash_table: a valid #GHashTable.
- *
- * Atomically increments the reference count of @hash_table by one.
- * This function is MT-safe and may be called from any thread.
- *
- * Return value: the passed in #GHashTable.
- *
- * Since: 2.10
- **/
-GHashTable*
-g_hash_table_ref (GHashTable *hash_table)
-{
- g_return_val_if_fail (hash_table != NULL, NULL);
- g_return_val_if_fail (hash_table->ref_count > 0, hash_table);
-
- g_atomic_int_add (&hash_table->ref_count, 1);
- return hash_table;
-}
-
-/**
- * g_hash_table_unref:
- * @hash_table: a valid #GHashTable.
- *
- * Atomically decrements the reference count of @hash_table by one.
- * If the reference count drops to 0, all keys and values will be
- * destroyed, and all memory allocated by the hash table is released.
- * This function is MT-safe and may be called from any thread.
- *
- * Since: 2.10
- **/
-void
-g_hash_table_unref (GHashTable *hash_table)
-{
- g_return_if_fail (hash_table != NULL);
- g_return_if_fail (hash_table->ref_count > 0);
-
- if (g_atomic_int_exchange_and_add (&hash_table->ref_count, -1) - 1 == 0)
- {
- g_hash_table_remove_all_nodes (hash_table, TRUE);
- g_free (hash_table->nodes);
- g_slice_free (GHashTable, hash_table);
- }
-}
-
-/**
- * g_hash_table_destroy:
- * @hash_table: a #GHashTable.
- *
- * Destroys all keys and values in the #GHashTable and decrements its
- * reference count by 1. If keys and/or values are dynamically allocated,
- * you should either free them first or create the #GHashTable with destroy
- * notifiers using g_hash_table_new_full(). In the latter case the destroy
- * functions you supplied will be called on all keys and values during the
- * destruction phase.
- **/
-void
-g_hash_table_destroy (GHashTable *hash_table)
-{
- g_return_if_fail (hash_table != NULL);
- g_return_if_fail (hash_table->ref_count > 0);
-
- g_hash_table_remove_all (hash_table);
- g_hash_table_unref (hash_table);
-}
-
-/**
- * g_hash_table_lookup:
- * @hash_table: a #GHashTable.
- * @key: the key to look up.
- *
- * Looks up a key in a #GHashTable. Note that this function cannot
- * distinguish between a key that is not present and one which is present
- * and has the value %NULL. If you need this distinction, use
- * g_hash_table_lookup_extended().
- *
- * Return value: the associated value, or %NULL if the key is not found.
- **/
-gpointer
-g_hash_table_lookup (GHashTable *hash_table,
- gconstpointer key)
-{
- GHashNode *node;
-
- g_return_val_if_fail (hash_table != NULL, NULL);
-
- node = *g_hash_table_lookup_node (hash_table, key, NULL);
-
- return node ? node->value : NULL;
-}
-
-/**
- * g_hash_table_lookup_extended:
- * @hash_table: a #GHashTable.
- * @lookup_key: the key to look up.
- * @orig_key: returns the original key.
- * @value: returns the value associated with the key.
- *
- * Looks up a key in the #GHashTable, returning the original key and the
- * associated value and a #gboolean which is %TRUE if the key was found. This
- * is useful if you need to free the memory allocated for the original key,
- * for example before calling g_hash_table_remove().
- *
- * Return value: %TRUE if the key was found in the #GHashTable.
- **/
-gboolean
-g_hash_table_lookup_extended (GHashTable *hash_table,
- gconstpointer lookup_key,
- gpointer *orig_key,
- gpointer *value)
-{
- GHashNode *node;
-
- g_return_val_if_fail (hash_table != NULL, FALSE);
-
- node = *g_hash_table_lookup_node (hash_table, lookup_key, NULL);
-
- if (node == NULL)
- return FALSE;
-
- if (orig_key)
- *orig_key = node->key;
-
- if (value)
- *value = node->value;
-
- return TRUE;
-}
-
-/*
- * g_hash_table_insert_internal:
- * @hash_table: our #GHashTable
- * @key: the key to insert
- * @value: the value to insert
- * @keep_new_key: if %TRUE and this key already exists in the table
- * then call the destroy notify function on the old key. If %FALSE
- * then call the destroy notify function on the new key.
- *
- * Implements the common logic for the g_hash_table_insert() and
- * g_hash_table_replace() functions.
- *
- * Do a lookup of @key. If it is found, replace it with the new
- * @value (and perhaps the new @key). If it is not found, create a
- * new node.
- */
-static void
-g_hash_table_insert_internal (GHashTable *hash_table,
- gpointer key,
- gpointer value,
- gboolean keep_new_key)
-{
- GHashNode **node_ptr, *node;
- guint key_hash;
-
- g_return_if_fail (hash_table != NULL);
- g_return_if_fail (hash_table->ref_count > 0);
-
- node_ptr = g_hash_table_lookup_node (hash_table, key, &key_hash);
-
- if ((node = *node_ptr))
- {
- if (keep_new_key)
- {
- if (hash_table->key_destroy_func)
- hash_table->key_destroy_func (node->key);
- node->key = key;
- }
- else
- {
- if (hash_table->key_destroy_func)
- hash_table->key_destroy_func (key);
- }
-
- if (hash_table->value_destroy_func)
- hash_table->value_destroy_func (node->value);
-
- node->value = value;
- }
- else
- {
- node = g_slice_new (GHashNode);
-
- node->key = key;
- node->value = value;
- node->key_hash = key_hash;
- node->next = NULL;
-
- *node_ptr = node;
- hash_table->nnodes++;
- g_hash_table_maybe_resize (hash_table);
-
-#ifndef G_DISABLE_ASSERT
- hash_table->version++;
-#endif
- }
-}
-
-/**
- * g_hash_table_insert:
- * @hash_table: a #GHashTable.
- * @key: a key to insert.
- * @value: the value to associate with the key.
- *
- * Inserts a new key and value into a #GHashTable.
- *
- * If the key already exists in the #GHashTable its current value is replaced
- * with the new value. If you supplied a @value_destroy_func when creating the
- * #GHashTable, the old value is freed using that function. If you supplied
- * a @key_destroy_func when creating the #GHashTable, the passed key is freed
- * using that function.
- **/
-void
-g_hash_table_insert (GHashTable *hash_table,
- gpointer key,
- gpointer value)
-{
- g_hash_table_insert_internal (hash_table, key, value, FALSE);
-}
-
-/**
- * g_hash_table_replace:
- * @hash_table: a #GHashTable.
- * @key: a key to insert.
- * @value: the value to associate with the key.
- *
- * Inserts a new key and value into a #GHashTable similar to
- * g_hash_table_insert(). The difference is that if the key already exists
- * in the #GHashTable, it gets replaced by the new key. If you supplied a
- * @value_destroy_func when creating the #GHashTable, the old value is freed
- * using that function. If you supplied a @key_destroy_func when creating the
- * #GHashTable, the old key is freed using that function.
- **/
-void
-g_hash_table_replace (GHashTable *hash_table,
- gpointer key,
- gpointer value)
-{
- g_hash_table_insert_internal (hash_table, key, value, TRUE);
-}
-
-/*
- * g_hash_table_remove_internal:
- * @hash_table: our #GHashTable
- * @key: the key to remove
- * @notify: %TRUE if the destroy notify handlers are to be called
- * Return value: %TRUE if a node was found and removed, else %FALSE
- *
- * Implements the common logic for the g_hash_table_remove() and
- * g_hash_table_steal() functions.
- *
- * Do a lookup of @key and remove it if it is found, calling the
- * destroy notify handlers only if @notify is %TRUE.
- */
-static gboolean
-g_hash_table_remove_internal (GHashTable *hash_table,
- gconstpointer key,
- gboolean notify)
-{
- GHashNode **node_ptr;
-
- g_return_val_if_fail (hash_table != NULL, FALSE);
-
- node_ptr = g_hash_table_lookup_node (hash_table, key, NULL);
- if (*node_ptr == NULL)
- return FALSE;
-
- g_hash_table_remove_node (hash_table, &node_ptr, notify);
- g_hash_table_maybe_resize (hash_table);
-
-#ifndef G_DISABLE_ASSERT
- hash_table->version++;
-#endif
-
- return TRUE;
-}
-
-/**
- * g_hash_table_remove:
- * @hash_table: a #GHashTable.
- * @key: the key to remove.
- *
- * Removes a key and its associated value from a #GHashTable.
- *
- * If the #GHashTable was created using g_hash_table_new_full(), the
- * key and value are freed using the supplied destroy functions, otherwise
- * you have to make sure that any dynamically allocated values are freed
- * yourself.
- *
- * Return value: %TRUE if the key was found and removed from the #GHashTable.
- **/
-gboolean
-g_hash_table_remove (GHashTable *hash_table,
- gconstpointer key)
-{
- return g_hash_table_remove_internal (hash_table, key, TRUE);
-}
-
-/**
- * g_hash_table_steal:
- * @hash_table: a #GHashTable.
- * @key: the key to remove.
- *
- * Removes a key and its associated value from a #GHashTable without
- * calling the key and value destroy functions.
- *
- * Return value: %TRUE if the key was found and removed from the #GHashTable.
- **/
-gboolean
-g_hash_table_steal (GHashTable *hash_table,
- gconstpointer key)
-{
- return g_hash_table_remove_internal (hash_table, key, FALSE);
-}
-
-/**
- * g_hash_table_remove_all:
- * @hash_table: a #GHashTable
- *
- * Removes all keys and their associated values from a #GHashTable.
- *
- * If the #GHashTable was created using g_hash_table_new_full(), the keys
- * and values are freed using the supplied destroy functions, otherwise you
- * have to make sure that any dynamically allocated values are freed
- * yourself.
- *
- * Since: 2.12
- **/
-void
-g_hash_table_remove_all (GHashTable *hash_table)
-{
- g_return_if_fail (hash_table != NULL);
-
-#ifndef G_DISABLE_ASSERT
- if (hash_table->nnodes != 0)
- hash_table->version++;
-#endif
-
- g_hash_table_remove_all_nodes (hash_table, TRUE);
- g_hash_table_maybe_resize (hash_table);
-}
-
-/**
- * g_hash_table_steal_all:
- * @hash_table: a #GHashTable.
- *
- * Removes all keys and their associated values from a #GHashTable
- * without calling the key and value destroy functions.
- *
- * Since: 2.12
- **/
-void
-g_hash_table_steal_all (GHashTable *hash_table)
-{
- g_return_if_fail (hash_table != NULL);
-
-#ifndef G_DISABLE_ASSERT
- if (hash_table->nnodes != 0)
- hash_table->version++;
-#endif
-
- g_hash_table_remove_all_nodes (hash_table, FALSE);
- g_hash_table_maybe_resize (hash_table);
-}
-
-/*
- * g_hash_table_foreach_remove_or_steal:
- * @hash_table: our #GHashTable
- * @func: the user's callback function
- * @user_data: data for @func
- * @notify: %TRUE if the destroy notify handlers are to be called
- *
- * Implements the common logic for g_hash_table_foreach_remove() and
- * g_hash_table_foreach_steal().
- *
- * Iterates over every node in the table, calling @func with the key
- * and value of the node (and @user_data). If @func returns %TRUE the
- * node is removed from the table.
- *
- * If @notify is true then the destroy notify handlers will be called
- * for each removed node.
- */
-static guint
-g_hash_table_foreach_remove_or_steal (GHashTable *hash_table,
- GHRFunc func,
- gpointer user_data,
- gboolean notify)
-{
- GHashNode *node, **node_ptr;
- guint deleted = 0;
- gint i;
-
- for (i = 0; i < hash_table->size; i++)
- for (node_ptr = &hash_table->nodes[i]; (node = *node_ptr) != NULL;)
- if ((* func) (node->key, node->value, user_data))
- {
- g_hash_table_remove_node (hash_table, &node_ptr, notify);
- deleted++;
- }
- else
- node_ptr = &node->next;
-
- g_hash_table_maybe_resize (hash_table);
-
-#ifndef G_DISABLE_ASSERT
- if (deleted > 0)
- hash_table->version++;
-#endif
-
- return deleted;
-}
-
-/**
- * g_hash_table_foreach_remove:
- * @hash_table: a #GHashTable.
- * @func: the function to call for each key/value pair.
- * @user_data: user data to pass to the function.
- *
- * Calls the given function for each key/value pair in the #GHashTable.
- * If the function returns %TRUE, then the key/value pair is removed from the
- * #GHashTable. If you supplied key or value destroy functions when creating
- * the #GHashTable, they are used to free the memory allocated for the removed
- * keys and values.
- *
- * See #GHashTableIterator for an alternative way to loop over the
- * key/value pairs in the hash table.
- *
- * Return value: the number of key/value pairs removed.
- **/
-guint
-g_hash_table_foreach_remove (GHashTable *hash_table,
- GHRFunc func,
- gpointer user_data)
-{
- g_return_val_if_fail (hash_table != NULL, 0);
- g_return_val_if_fail (func != NULL, 0);
-
- return g_hash_table_foreach_remove_or_steal (hash_table, func, user_data, TRUE);
-}
-
-/**
- * g_hash_table_foreach_steal:
- * @hash_table: a #GHashTable.
- * @func: the function to call for each key/value pair.
- * @user_data: user data to pass to the function.
- *
- * Calls the given function for each key/value pair in the #GHashTable.
- * If the function returns %TRUE, then the key/value pair is removed from the
- * #GHashTable, but no key or value destroy functions are called.
- *
- * See #GHashTableIterator for an alternative way to loop over the
- * key/value pairs in the hash table.
- *
- * Return value: the number of key/value pairs removed.
- **/
-guint
-g_hash_table_foreach_steal (GHashTable *hash_table,
- GHRFunc func,
- gpointer user_data)
-{
- g_return_val_if_fail (hash_table != NULL, 0);
- g_return_val_if_fail (func != NULL, 0);
-
- return g_hash_table_foreach_remove_or_steal (hash_table, func, user_data, FALSE);
-}
-
-/**
- * g_hash_table_foreach:
- * @hash_table: a #GHashTable.
- * @func: the function to call for each key/value pair.
- * @user_data: user data to pass to the function.
- *
- * Calls the given function for each of the key/value pairs in the
- * #GHashTable. The function is passed the key and value of each
- * pair, and the given @user_data parameter. The hash table may not
- * be modified while iterating over it (you can't add/remove
- * items). To remove all items matching a predicate, use
- * g_hash_table_foreach_remove().
- *
- * See g_hash_table_find() for performance caveats for linear
- * order searches in contrast to g_hash_table_lookup().
- **/
-void
-g_hash_table_foreach (GHashTable *hash_table,
- GHFunc func,
- gpointer user_data)
-{
- GHashNode *node;
- gint i;
-
- g_return_if_fail (hash_table != NULL);
- g_return_if_fail (func != NULL);
-
- for (i = 0; i < hash_table->size; i++)
- for (node = hash_table->nodes[i]; node; node = node->next)
- (* func) (node->key, node->value, user_data);
-}
-
-/**
- * g_hash_table_find:
- * @hash_table: a #GHashTable.
- * @predicate: function to test the key/value pairs for a certain property.
- * @user_data: user data to pass to the function.
- *
- * Calls the given function for key/value pairs in the #GHashTable until
- * @predicate returns %TRUE. The function is passed the key and value of
- * each pair, and the given @user_data parameter. The hash table may not
- * be modified while iterating over it (you can't add/remove items).
- *
- * Note, that hash tables are really only optimized for forward lookups,
- * i.e. g_hash_table_lookup().
- * So code that frequently issues g_hash_table_find() or
- * g_hash_table_foreach() (e.g. in the order of once per every entry in a
- * hash table) should probably be reworked to use additional or different
- * data structures for reverse lookups (keep in mind that an O(n) find/foreach
- * operation issued for all n values in a hash table ends up needing O(n*n)
- * operations).
- *
- * Return value: The value of the first key/value pair is returned, for which
- * func evaluates to %TRUE. If no pair with the requested property is found,
- * %NULL is returned.
- *
- * Since: 2.4
- **/
-gpointer
-g_hash_table_find (GHashTable *hash_table,
- GHRFunc predicate,
- gpointer user_data)
-{
- GHashNode *node;
- gint i;
-
- g_return_val_if_fail (hash_table != NULL, NULL);
- g_return_val_if_fail (predicate != NULL, NULL);
-
- for (i = 0; i < hash_table->size; i++)
- for (node = hash_table->nodes[i]; node; node = node->next)
- if (predicate (node->key, node->value, user_data))
- return node->value;
- return NULL;
-}
-
-/**
- * g_hash_table_size:
- * @hash_table: a #GHashTable.
- *
- * Returns the number of elements contained in the #GHashTable.
- *
- * Return value: the number of key/value pairs in the #GHashTable.
- **/
-guint
-g_hash_table_size (GHashTable *hash_table)
-{
- g_return_val_if_fail (hash_table != NULL, 0);
-
- return hash_table->nnodes;
-}
-
-/**
- * g_hash_table_get_keys:
- * @hash_table: a #GHashTable
- *
- * Retrieves every key inside @hash_table. The returned data is valid
- * until @hash_table is modified.
- *
- * Return value: a #GList containing all the keys inside the hash
- * table. The content of the list is owned by the hash table and
- * should not be modified or freed. Use g_list_free() when done
- * using the list.
- *
- * Since: 2.14
- */
-GList *
-g_hash_table_get_keys (GHashTable *hash_table)
-{
- GHashNode *node;
- gint i;
- GList *retval;
-
- g_return_val_if_fail (hash_table != NULL, NULL);
-
- retval = NULL;
- for (i = 0; i < hash_table->size; i++)
- for (node = hash_table->nodes[i]; node; node = node->next)
- retval = g_list_prepend (retval, node->key);
-
- return retval;
-}
-
-/**
- * g_hash_table_get_values:
- * @hash_table: a #GHashTable
- *
- * Retrieves every value inside @hash_table. The returned data is
- * valid until @hash_table is modified.
- *
- * Return value: a #GList containing all the values inside the hash
- * table. The content of the list is owned by the hash table and
- * should not be modified or freed. Use g_list_free() when done
- * using the list.
- *
- * Since: 2.14
- */
-GList *
-g_hash_table_get_values (GHashTable *hash_table)
-{
- GHashNode *node;
- gint i;
- GList *retval;
-
- g_return_val_if_fail (hash_table != NULL, NULL);
-
- retval = NULL;
- for (i = 0; i < hash_table->size; i++)
- for (node = hash_table->nodes[i]; node; node = node->next)
- retval = g_list_prepend (retval, node->value);
-
- return retval;
-}
-
-#define __G_HASH_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/ghash.h b/navit/support/glib/ghash.h
deleted file mode 100644
index afdd07297..000000000
--- a/navit/support/glib/ghash.h
+++ /dev/null
@@ -1,145 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_HASH_H__
-#define __G_HASH_H__
-
-#include <glib/gtypes.h>
-#include <glib/glist.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GHashTable GHashTable;
-
-typedef gboolean (*GHRFunc) (gpointer key,
- gpointer value,
- gpointer user_data);
-
-typedef struct _GHashTableIter GHashTableIter;
-
-struct _GHashTableIter
-{
- /*< private >*/
- gpointer dummy1;
- gpointer dummy2;
- gpointer dummy3;
- int dummy4;
- gboolean dummy5;
- gpointer dummy6;
-};
-
-/* Hash tables
- */
-GHashTable* g_hash_table_new (GHashFunc hash_func,
- GEqualFunc key_equal_func);
-GHashTable* g_hash_table_new_full (GHashFunc hash_func,
- GEqualFunc key_equal_func,
- GDestroyNotify key_destroy_func,
- GDestroyNotify value_destroy_func);
-void g_hash_table_destroy (GHashTable *hash_table);
-void g_hash_table_insert (GHashTable *hash_table,
- gpointer key,
- gpointer value);
-void g_hash_table_replace (GHashTable *hash_table,
- gpointer key,
- gpointer value);
-gboolean g_hash_table_remove (GHashTable *hash_table,
- gconstpointer key);
-void g_hash_table_remove_all (GHashTable *hash_table);
-gboolean g_hash_table_steal (GHashTable *hash_table,
- gconstpointer key);
-void g_hash_table_steal_all (GHashTable *hash_table);
-gpointer g_hash_table_lookup (GHashTable *hash_table,
- gconstpointer key);
-gboolean g_hash_table_lookup_extended (GHashTable *hash_table,
- gconstpointer lookup_key,
- gpointer *orig_key,
- gpointer *value);
-void g_hash_table_foreach (GHashTable *hash_table,
- GHFunc func,
- gpointer user_data);
-gpointer g_hash_table_find (GHashTable *hash_table,
- GHRFunc predicate,
- gpointer user_data);
-guint g_hash_table_foreach_remove (GHashTable *hash_table,
- GHRFunc func,
- gpointer user_data);
-guint g_hash_table_foreach_steal (GHashTable *hash_table,
- GHRFunc func,
- gpointer user_data);
-guint g_hash_table_size (GHashTable *hash_table);
-GList * g_hash_table_get_keys (GHashTable *hash_table);
-GList * g_hash_table_get_values (GHashTable *hash_table);
-
-void g_hash_table_iter_init (GHashTableIter *iter,
- GHashTable *hash_table);
-gboolean g_hash_table_iter_next (GHashTableIter *iter,
- gpointer *key,
- gpointer *value);
-GHashTable* g_hash_table_iter_get_hash_table (GHashTableIter *iter);
-void g_hash_table_iter_remove (GHashTableIter *iter);
-void g_hash_table_iter_steal (GHashTableIter *iter);
-
-/* keeping hash tables alive */
-GHashTable* g_hash_table_ref (GHashTable *hash_table);
-void g_hash_table_unref (GHashTable *hash_table);
-
-#ifndef G_DISABLE_DEPRECATED
-
-/* The following two functions are deprecated and will be removed in
- * the next major release. They do no good. */
-#define g_hash_table_freeze(hash_table) ((void)0)
-#define g_hash_table_thaw(hash_table) ((void)0)
-
-#endif /* G_DISABLE_DEPRECATED */
-
-/* Hash Functions
- */
-gboolean g_str_equal (gconstpointer v1,
- gconstpointer v2);
-guint g_str_hash (gconstpointer v);
-
-gboolean g_int_equal (gconstpointer v1,
- gconstpointer v2);
-guint g_int_hash (gconstpointer v);
-
-/* This "hash" function will just return the key's address as an
- * unsigned integer. Useful for hashing on plain addresses or
- * simple integer values.
- * Passing NULL into g_hash_table_new() as GHashFunc has the
- * same effect as passing g_direct_hash().
- */
-guint g_direct_hash (gconstpointer v) G_GNUC_CONST;
-gboolean g_direct_equal (gconstpointer v1,
- gconstpointer v2) G_GNUC_CONST;
-
-G_END_DECLS
-
-#endif /* __G_HASH_H__ */
diff --git a/navit/support/glib/glib.h b/navit/support/glib/glib.h
deleted file mode 100644
index cd8644521..000000000
--- a/navit/support/glib/glib.h
+++ /dev/null
@@ -1,42 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __G_LIB_H__
-#define __G_LIB_H__
-
-#define __GLIB_H_INSIDE__
-#include <glib/galloca.h>
-#include <glib/gerror.h>
-#include <glib/fake.h>
-#include <glib/ghash.h>
-#include <glib/gmessages.h>
-#include <glib/gstrfuncs.h>
-#include <glib/gunicode.h>
-#include <glib/gutils.h>
-
-#undef __GLIB_H_INSIDE__
-
-#endif /* __G_LIB_H__ */
diff --git a/navit/support/glib/glib_init.c b/navit/support/glib/glib_init.c
deleted file mode 100644
index 32be387da..000000000
--- a/navit/support/glib/glib_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "plugin.h"
-
-void
-plugin_init(void)
-{
-}
diff --git a/navit/support/glib/glibconfig.h b/navit/support/glib/glibconfig.h
deleted file mode 100644
index 6baa58873..000000000
--- a/navit/support/glib/glibconfig.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/* glibconfig.h.win32.in Merged from two versions generated by configure for gcc and MSVC. */
-/* glibconfig.h
- *
- * This is a generated file. Please modify 'configure.in'
- */
-
-#ifndef __G_LIBCONFIG_H__
-#define __G_LIBCONFIG_H__
-
-#include <glib/gmacros.h>
-
-#include <limits.h>
-#include <float.h>
-#include "config.h"
-
-#ifdef HAVE_API_WIN32_BASE
-#include <libgnuintl.h>
-#endif
-
-G_BEGIN_DECLS
-
-#define G_MINFLOAT FLT_MIN
-#define G_MAXFLOAT FLT_MAX
-#define G_MINDOUBLE DBL_MIN
-#define G_MAXDOUBLE DBL_MAX
-#define G_MINSHORT SHRT_MIN
-#define G_MAXSHORT SHRT_MAX
-#define G_MAXUSHORT USHRT_MAX
-#define G_MININT INT_MIN
-#define G_MAXINT INT_MAX
-#define G_MAXUINT UINT_MAX
-#define G_MINLONG LONG_MIN
-#define G_MAXLONG LONG_MAX
-#define G_MAXULONG ULONG_MAX
-
-typedef signed char gint8;
-typedef unsigned char guint8;
-typedef signed short gint16;
-typedef unsigned short guint16;
-#define G_GINT16_MODIFIER "h"
-#define G_GINT16_FORMAT "hi"
-#define G_GUINT16_FORMAT "hu"
-typedef signed int gint32;
-typedef unsigned int guint32;
-#define G_GINT32_MODIFIER ""
-#define G_GINT32_FORMAT "i"
-#define G_GUINT32_FORMAT "u"
-#define G_HAVE_GINT64 1 /* deprecated, always true */
-
-#ifndef _MSC_VER
-G_GNUC_EXTENSION typedef signed long long gint64;
-G_GNUC_EXTENSION typedef unsigned long long guint64;
-#else /* _MSC_VER */
-typedef signed __int64 gint64;
-typedef unsigned __int64 guint64;
-#endif /* _MSC_VER */
-
-#ifndef _MSC_VER
-#define G_GINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##LL))
-#else /* _MSC_VER */
-#define G_GINT64_CONSTANT(val) (val##i64)
-#endif /* _MSC_VER */
-#ifndef _MSC_VER
-#define G_GUINT64_CONSTANT(val) (G_GNUC_EXTENSION (val##ULL))
-#else /* _MSC_VER */
-#define G_GUINT64_CONSTANT(val) (val##Ui64)
-#endif /* _MSC_VER */
-#define G_GINT64_MODIFIER "I64"
-#define G_GINT64_FORMAT "I64i"
-#define G_GUINT64_FORMAT "I64u"
-
-#if defined(_WIN64) || defined(_M_X64) || defined(_M_AMD64)
-
-#define GLIB_SIZEOF_VOID_P 8
-#define GLIB_SIZEOF_LONG 4
-#define GLIB_SIZEOF_SIZE_T 8
-
-typedef signed long long gssize;
-typedef unsigned long long gsize;
-#define G_GSIZE_MODIFIER "I64"
-#define G_GSSIZE_FORMAT "I64d"
-#define G_GSIZE_FORMAT "I64u"
-
-#define G_MAXSIZE G_MAXUINT64
-#define G_MINSSIZE G_MININT64
-#define G_MAXSSIZE G_MAXINT64
-
-#else
-
-#define GLIB_SIZEOF_VOID_P 4
-#define GLIB_SIZEOF_LONG 4
-#define GLIB_SIZEOF_SIZE_T 4
-
-typedef signed int gssize;
-typedef unsigned int gsize;
-#define G_GSIZE_MODIFIER ""
-#define G_GSSIZE_FORMAT "i"
-#define G_GSIZE_FORMAT "u"
-
-#define G_MAXSIZE G_MAXUINT
-#define G_MINSSIZE G_MININT
-#define G_MAXSSIZE G_MAXINT
-
-#endif
-
-typedef gint64 goffset;
-#define G_MINOFFSET G_MININT64
-#define G_MAXOFFSET G_MAXINT64
-
-#ifndef _WIN64
-
-#define GPOINTER_TO_INT(p) ((gint) (p))
-#define GPOINTER_TO_UINT(p) ((guint) (p))
-
-#define GINT_TO_POINTER(i) ((gpointer) (i))
-#define GUINT_TO_POINTER(u) ((gpointer) (u))
-
-typedef signed int gintptr;
-typedef unsigned int guintptr;
-
-#else
-
-#define GPOINTER_TO_INT(p) ((gint) (gint64) (p))
-#define GPOINTER_TO_UINT(p) ((guint) (guint64) (p))
-
-#define GINT_TO_POINTER(i) ((gpointer) (gint64) (i))
-#define GUINT_TO_POINTER(u) ((gpointer) (guint64) (u))
-
-#ifndef _MSC_VER
-typedef signed long long gintptr;
-typedef unsigned long long guintptr;
-#else
-typedef signed __int64 gintptr;
-typedef unsigned __int64 guintptr;
-#endif
-
-#endif
-
-#ifdef NeXT /* @#%@! NeXTStep */
-# define g_ATEXIT(proc) (!atexit (proc))
-#else
-# define g_ATEXIT(proc) (atexit (proc))
-#endif
-
-#define g_memmove(dest,src,len) G_STMT_START { memmove ((dest), (src), (len)); } G_STMT_END
-
-#define GLIB_MAJOR_VERSION 2
-#define GLIB_MINOR_VERSION 18
-#define GLIB_MICRO_VERSION 1
-
-#ifdef HAVE_API_WIN32_BASE
-#define G_OS_WIN32
-#define G_PLATFORM_WIN32
-#endif
-
-
-#ifndef _MSC_VER
-#define G_VA_COPY va_copy
-#endif /* not _MSC_VER */
-
-#ifdef __cplusplus
-#define G_HAVE_INLINE 1
-#else /* !__cplusplus */
-#ifndef _MSC_VER
-#define G_HAVE_INLINE 1
-#endif /* _MSC_VER */
-#define G_HAVE___INLINE 1
-#if !defined(_MSC_VER) && !defined(__DMC__)
-#define G_HAVE___INLINE__ 1
-#endif /* !_MSC_VER and !__DMC__ */
-#endif /* !__cplusplus */
-
-#define G_CAN_INLINE 1
-
-#ifndef _MSC_VER
-#define G_HAVE_ISO_VARARGS 1
-
-/* gcc-2.95.x supports both gnu style and ISO varargs, but if -ansi
- * is passed ISO vararg support is turned off, and there is no work
- * around to turn it on, so we unconditionally turn it off.
- */
-#if __GNUC__ == 2 && __GNUC_MINOR__ == 95
-# undef G_HAVE_ISO_VARARGS
-#endif
-
-#define G_HAVE_GNUC_VARARGS 1
-#else /* _MSC_VER */
-/* varargs macros available since msvc8 (vs2005) */
-# if _MSC_VER >= 1400
-# define G_HAVE_ISO_VARARGS 1
-# endif
-#endif /* not _MSC_VER */
-#define G_HAVE_GROWING_STACK 0
-
-#define G_GNUC_INTERNAL
-
-#define G_THREADS_ENABLED
-#define G_THREADS_IMPL_WIN32
-typedef struct _GMutex* GStaticMutex;
-#define G_STATIC_MUTEX_INIT NULL
-#define g_static_mutex_get_mutex(mutex) \
- (g_static_mutex_get_mutex_impl_shortcut (mutex))
-/* This represents a system thread as used by the implementation. An
- * alien implementaion, as loaded by g_thread_init can only count on
- * "sizeof (gpointer)" bytes to store their info. We however need more
- * for some of our native implementations. */
-typedef union _GSystemThread GSystemThread;
-union _GSystemThread
-{
-#ifndef _WIN64
- char data[4];
-#else
- char data[8];
-#endif
- double dummy_double;
- void *dummy_pointer;
- long dummy_long;
-};
-
-#define GINT16_TO_LE(val) ((gint16) (val))
-#define GUINT16_TO_LE(val) ((guint16) (val))
-#define GINT16_TO_BE(val) ((gint16) GUINT16_SWAP_LE_BE (val))
-#define GUINT16_TO_BE(val) (GUINT16_SWAP_LE_BE (val))
-#define GINT32_TO_LE(val) ((gint32) (val))
-#define GUINT32_TO_LE(val) ((guint32) (val))
-#define GINT32_TO_BE(val) ((gint32) GUINT32_SWAP_LE_BE (val))
-#define GUINT32_TO_BE(val) (GUINT32_SWAP_LE_BE (val))
-#define GINT64_TO_LE(val) ((gint64) (val))
-#define GUINT64_TO_LE(val) ((guint64) (val))
-#define GINT64_TO_BE(val) ((gint64) GUINT64_SWAP_LE_BE (val))
-#define GUINT64_TO_BE(val) (GUINT64_SWAP_LE_BE (val))
-#define GLONG_TO_LE(val) ((glong) GINT32_TO_LE (val))
-#define GULONG_TO_LE(val) ((gulong) GUINT32_TO_LE (val))
-#define GLONG_TO_BE(val) ((glong) GINT32_TO_BE (val))
-#define GULONG_TO_BE(val) ((gulong) GUINT32_TO_BE (val))
-#define GINT_TO_LE(val) ((gint) GINT32_TO_LE (val))
-#define GUINT_TO_LE(val) ((guint) GUINT32_TO_LE (val))
-#define GINT_TO_BE(val) ((gint) GINT32_TO_BE (val))
-#define GUINT_TO_BE(val) ((guint) GUINT32_TO_BE (val))
-#define G_BYTE_ORDER G_LITTLE_ENDIAN
-
-#define GLIB_SYSDEF_POLLIN =1
-#define GLIB_SYSDEF_POLLOUT =4
-#define GLIB_SYSDEF_POLLPRI =2
-#define GLIB_SYSDEF_POLLHUP =16
-#define GLIB_SYSDEF_POLLERR =8
-#define GLIB_SYSDEF_POLLNVAL =32
-
-#define G_MODULE_SUFFIX "dll"
-
-#define HAVE_GOOD_PRINTF
-#define NO_SYS_SIGLIST_DECL
-#define GLIB_STATIC_COMPILATION
-#define G_DISABLE_CHECKS
-/* A GPid is an abstraction for a process "handle". It is *not* an
- * abstraction for a process identifier in general. GPid is used in
- * GLib only for descendant processes spawned with the g_spawn*
- * functions. On POSIX there is no "process handle" concept as such,
- * but on Windows a GPid is a handle to a process, a kind of pointer,
- * not a process identifier.
- */
-typedef void * GPid;
-
-G_END_DECLS
-
-#endif /* GLIBCONFIG_H */
diff --git a/navit/support/glib/glibintl.h b/navit/support/glib/glibintl.h
deleted file mode 100644
index 13af202c8..000000000
--- a/navit/support/glib/glibintl.h
+++ /dev/null
@@ -1,43 +0,0 @@
-#ifndef __GLIBINTL_H__
-#define __GLIBINTL_H__
-
-#if NOT_NEEDED_FOR_NAVIT
-#ifndef SIZEOF_CHAR
-#error "config.h must be included prior to glibintl.h"
-#endif
-#endif /* NOT_NEEDED_FOR_NAVIT */
-
-G_CONST_RETURN gchar *glib_gettext (const gchar *str);
-
-#ifdef USE_NATIVE_LANGUAGE_SUPPORT
-
-#include "navit_nls.h"
-#undef _
-#undef gettext_noop
-#undef _n
-
-#define _(String) glib_gettext(String)
-/* Split out this in the code, but keep it in the same domain for now */
-#define P_(String) glib_gettext(String)
-
-#ifdef gettext_noop
-#define N_(String) gettext_noop(String)
-#else
-#define N_(String) (String)
-#endif
-#else /* NLS is disabled */
-#define _(String) (String)
-#define N_(String) (String)
-#define P_(String) (String)
-#define textdomain(String) (String)
-#define gettext(String) (String)
-#define dgettext(Domain,String) (String)
-#define dcgettext(Domain,String,Type) (String)
-#define dngettext(Domain,String1,String2,N) ((N) == 1 ? (String1) : (String2))
-#define bindtextdomain(Domain,Directory) (Domain)
-#endif
-
-/* not really I18N-related, but also a string marker macro */
-#define I_(string) g_intern_static_string (string)
-
-#endif /* __GLIBINTL_H__ */
diff --git a/navit/support/glib/glist.c b/navit/support/glib/glist.c
deleted file mode 100644
index b607abd68..000000000
--- a/navit/support/glib/glist.c
+++ /dev/null
@@ -1,999 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * MT safe
- */
-
-#include "config.h"
-
-#include "glib.h"
-#include "galias.h"
-
-
-void g_list_push_allocator (gpointer dummy) { /* present for binary compat only */ }
-void g_list_pop_allocator (void) { /* present for binary compat only */ }
-
-#define _g_list_alloc() g_slice_new (GList)
-#define _g_list_alloc0() g_slice_new0 (GList)
-#define _g_list_free1(list) g_slice_free (GList, list)
-
-GList*
-g_list_alloc (void)
-{
- return _g_list_alloc0 ();
-}
-
-/**
- * g_list_free:
- * @list: a #GList
- *
- * Frees all of the memory used by a #GList.
- * The freed elements are returned to the slice allocator.
- *
- * <note><para>
- * If list elements contain dynamically-allocated memory,
- * they should be freed first.
- * </para></note>
- */
-void
-g_list_free (GList *list)
-{
- g_slice_free_chain (GList, list, next);
-}
-
-/**
- * g_list_free_1:
- * @list: a #GList element
- *
- * Frees one #GList element.
- * It is usually used after g_list_remove_link().
- */
-void
-g_list_free_1 (GList *list)
-{
- _g_list_free1 (list);
-}
-
-/**
- * g_list_append:
- * @list: a pointer to a #GList
- * @data: the data for the new element
- *
- * Adds a new element on to the end of the list.
- *
- * <note><para>
- * The return value is the new start of the list, which
- * may have changed, so make sure you store the new value.
- * </para></note>
- *
- * <note><para>
- * Note that g_list_append() has to traverse the entire list
- * to find the end, which is inefficient when adding multiple
- * elements. A common idiom to avoid the inefficiency is to prepend
- * the elements and reverse the list when all elements have been added.
- * </para></note>
- *
- * |[
- * /&ast; Notice that these are initialized to the empty list. &ast;/
- * GList *list = NULL, *number_list = NULL;
- *
- * /&ast; This is a list of strings. &ast;/
- * list = g_list_append (list, "first");
- * list = g_list_append (list, "second");
- *
- * /&ast; This is a list of integers. &ast;/
- * number_list = g_list_append (number_list, GINT_TO_POINTER (27));
- * number_list = g_list_append (number_list, GINT_TO_POINTER (14));
- * ]|
- *
- * Returns: the new start of the #GList
- */
-GList*
-g_list_append (GList *list,
- gpointer data)
-{
- GList *new_list;
- GList *last;
-
- new_list = _g_list_alloc ();
- new_list->data = data;
- new_list->next = NULL;
-
- if (list)
- {
- last = g_list_last (list);
- /* g_assert (last != NULL); */
- last->next = new_list;
- new_list->prev = last;
-
- return list;
- }
- else
- {
- new_list->prev = NULL;
- return new_list;
- }
-}
-
-/**
- * g_list_prepend:
- * @list: a pointer to a #GList
- * @data: the data for the new element
- *
- * Adds a new element on to the start of the list.
- *
- * <note><para>
- * The return value is the new start of the list, which
- * may have changed, so make sure you store the new value.
- * </para></note>
- *
- * |[
- * /&ast; Notice that it is initialized to the empty list. &ast;/
- * GList *list = NULL;
- * list = g_list_prepend (list, "last");
- * list = g_list_prepend (list, "first");
- * ]|
- *
- * Returns: the new start of the #GList
- */
-GList*
-g_list_prepend (GList *list,
- gpointer data)
-{
- GList *new_list;
-
- new_list = _g_list_alloc ();
- new_list->data = data;
- new_list->next = list;
-
- if (list)
- {
- new_list->prev = list->prev;
- if (list->prev)
- list->prev->next = new_list;
- list->prev = new_list;
- }
- else
- new_list->prev = NULL;
-
- return new_list;
-}
-
-/**
- * g_list_insert:
- * @list: a pointer to a #GList
- * @data: the data for the new element
- * @position: the position to insert the element. If this is
- * negative, or is larger than the number of elements in the
- * list, the new element is added on to the end of the list.
- *
- * Inserts a new element into the list at the given position.
- *
- * Returns: the new start of the #GList
- */
-GList*
-g_list_insert (GList *list,
- gpointer data,
- gint position)
-{
- GList *new_list;
- GList *tmp_list;
-
- if (position < 0)
- return g_list_append (list, data);
- else if (position == 0)
- return g_list_prepend (list, data);
-
- tmp_list = g_list_nth (list, position);
- if (!tmp_list)
- return g_list_append (list, data);
-
- new_list = _g_list_alloc ();
- new_list->data = data;
- new_list->prev = tmp_list->prev;
- if (tmp_list->prev)
- tmp_list->prev->next = new_list;
- new_list->next = tmp_list;
- tmp_list->prev = new_list;
-
- if (tmp_list == list)
- return new_list;
- else
- return list;
-}
-
-/**
- * g_list_insert_before:
- * @list: a pointer to a #GList
- * @sibling: the list element before which the new element
- * is inserted or %NULL to insert at the end of the list
- * @data: the data for the new element
- *
- * Inserts a new element into the list before the given position.
- *
- * Returns: the new start of the #GList
- */
-GList*
-g_list_insert_before (GList *list,
- GList *sibling,
- gpointer data)
-{
- if (!list)
- {
- list = g_list_alloc ();
- list->data = data;
- g_return_val_if_fail (sibling == NULL, list);
- return list;
- }
- else if (sibling)
- {
- GList *node;
-
- node = _g_list_alloc ();
- node->data = data;
- node->prev = sibling->prev;
- node->next = sibling;
- sibling->prev = node;
- if (node->prev)
- {
- node->prev->next = node;
- return list;
- }
- else
- {
- g_return_val_if_fail (sibling == list, node);
- return node;
- }
- }
- else
- {
- GList *last;
-
- last = list;
- while (last->next)
- last = last->next;
-
- last->next = _g_list_alloc ();
- last->next->data = data;
- last->next->prev = last;
- last->next->next = NULL;
-
- return list;
- }
-}
-
-/**
- * g_list_concat:
- * @list1: a #GList
- * @list2: the #GList to add to the end of the first #GList
- *
- * Adds the second #GList onto the end of the first #GList.
- * Note that the elements of the second #GList are not copied.
- * They are used directly.
- *
- * Returns: the start of the new #GList
- */
-GList *
-g_list_concat (GList *list1, GList *list2)
-{
- GList *tmp_list;
-
- if (list2)
- {
- tmp_list = g_list_last (list1);
- if (tmp_list)
- tmp_list->next = list2;
- else
- list1 = list2;
- list2->prev = tmp_list;
- }
-
- return list1;
-}
-
-/**
- * g_list_remove:
- * @list: a #GList
- * @data: the data of the element to remove
- *
- * Removes an element from a #GList.
- * If two elements contain the same data, only the first is removed.
- * If none of the elements contain the data, the #GList is unchanged.
- *
- * Returns: the new start of the #GList
- */
-GList*
-g_list_remove (GList *list,
- gconstpointer data)
-{
- GList *tmp;
-
- tmp = list;
- while (tmp)
- {
- if (tmp->data != data)
- tmp = tmp->next;
- else
- {
- if (tmp->prev)
- tmp->prev->next = tmp->next;
- if (tmp->next)
- tmp->next->prev = tmp->prev;
-
- if (list == tmp)
- list = list->next;
-
- _g_list_free1 (tmp);
-
- break;
- }
- }
- return list;
-}
-
-/**
- * g_list_remove_all:
- * @list: a #GList
- * @data: data to remove
- *
- * Removes all list nodes with data equal to @data.
- * Returns the new head of the list. Contrast with
- * g_list_remove() which removes only the first node
- * matching the given data.
- *
- * Returns: new head of @list
- */
-GList*
-g_list_remove_all (GList *list,
- gconstpointer data)
-{
- GList *tmp = list;
-
- while (tmp)
- {
- if (tmp->data != data)
- tmp = tmp->next;
- else
- {
- GList *next = tmp->next;
-
- if (tmp->prev)
- tmp->prev->next = next;
- else
- list = next;
- if (next)
- next->prev = tmp->prev;
-
- _g_list_free1 (tmp);
- tmp = next;
- }
- }
- return list;
-}
-
-static inline GList*
-_g_list_remove_link (GList *list,
- GList *link)
-{
- if (link)
- {
- if (link->prev)
- link->prev->next = link->next;
- if (link->next)
- link->next->prev = link->prev;
-
- if (link == list)
- list = list->next;
-
- link->next = NULL;
- link->prev = NULL;
- }
-
- return list;
-}
-
-/**
- * g_list_remove_link:
- * @list: a #GList
- * @llink: an element in the #GList
- *
- * Removes an element from a #GList, without freeing the element.
- * The removed element's prev and next links are set to %NULL, so
- * that it becomes a self-contained list with one element.
- *
- * Returns: the new start of the #GList, without the element
- */
-GList*
-g_list_remove_link (GList *list,
- GList *llink)
-{
- return _g_list_remove_link (list, llink);
-}
-
-/**
- * g_list_delete_link:
- * @list: a #GList
- * @link_: node to delete from @list
- *
- * Removes the node link_ from the list and frees it.
- * Compare this to g_list_remove_link() which removes the node
- * without freeing it.
- *
- * Returns: the new head of @list
- */
-GList*
-g_list_delete_link (GList *list,
- GList *link_)
-{
- list = _g_list_remove_link (list, link_);
- _g_list_free1 (link_);
-
- return list;
-}
-
-/**
- * g_list_copy:
- * @list: a #GList
- *
- * Copies a #GList.
- *
- * <note><para>
- * Note that this is a "shallow" copy. If the list elements
- * consist of pointers to data, the pointers are copied but
- * the actual data is not.
- * </para></note>
- *
- * Returns: a copy of @list
- */
-GList*
-g_list_copy (GList *list)
-{
- GList *new_list = NULL;
-
- if (list)
- {
- GList *last;
-
- new_list = _g_list_alloc ();
- new_list->data = list->data;
- new_list->prev = NULL;
- last = new_list;
- list = list->next;
- while (list)
- {
- last->next = _g_list_alloc ();
- last->next->prev = last;
- last = last->next;
- last->data = list->data;
- list = list->next;
- }
- last->next = NULL;
- }
-
- return new_list;
-}
-
-/**
- * g_list_reverse:
- * @list: a #GList
- *
- * Reverses a #GList.
- * It simply switches the next and prev pointers of each element.
- *
- * Returns: the start of the reversed #GList
- */
-GList*
-g_list_reverse (GList *list)
-{
- GList *last;
-
- last = NULL;
- while (list)
- {
- last = list;
- list = last->next;
- last->next = last->prev;
- last->prev = list;
- }
-
- return last;
-}
-
-/**
- * g_list_nth:
- * @list: a #GList
- * @n: the position of the element, counting from 0
- *
- * Gets the element at the given position in a #GList.
- *
- * Returns: the element, or %NULL if the position is off
- * the end of the #GList
- */
-GList*
-g_list_nth (GList *list,
- guint n)
-{
- while ((n-- > 0) && list)
- list = list->next;
-
- return list;
-}
-
-/**
- * g_list_nth_prev:
- * @list: a #GList
- * @n: the position of the element, counting from 0
- *
- * Gets the element @n places before @list.
- *
- * Returns: the element, or %NULL if the position is
- * off the end of the #GList
- */
-GList*
-g_list_nth_prev (GList *list,
- guint n)
-{
- while ((n-- > 0) && list)
- list = list->prev;
-
- return list;
-}
-
-/**
- * g_list_nth_data:
- * @list: a #GList
- * @n: the position of the element
- *
- * Gets the data of the element at the given position.
- *
- * Returns: the element's data, or %NULL if the position
- * is off the end of the #GList
- */
-gpointer
-g_list_nth_data (GList *list,
- guint n)
-{
- while ((n-- > 0) && list)
- list = list->next;
-
- return list ? list->data : NULL;
-}
-
-/**
- * g_list_find:
- * @list: a #GList
- * @data: the element data to find
- *
- * Finds the element in a #GList which
- * contains the given data.
- *
- * Returns: the found #GList element,
- * or %NULL if it is not found
- */
-GList*
-g_list_find (GList *list,
- gconstpointer data)
-{
- while (list)
- {
- if (list->data == data)
- break;
- list = list->next;
- }
-
- return list;
-}
-
-/**
- * g_list_find_custom:
- * @list: a #GList
- * @data: user data passed to the function
- * @func: the function to call for each element.
- * It should return 0 when the desired element is found
- *
- * Finds an element in a #GList, using a supplied function to
- * find the desired element. It iterates over the list, calling
- * the given function which should return 0 when the desired
- * element is found. The function takes two #gconstpointer arguments,
- * the #GList element's data as the first argument and the
- * given user data.
- *
- * Returns: the found #GList element, or %NULL if it is not found
- */
-GList*
-g_list_find_custom (GList *list,
- gconstpointer data,
- GCompareFunc func)
-{
- g_return_val_if_fail (func != NULL, list);
-
- while (list)
- {
- if (! func (list->data, data))
- return list;
- list = list->next;
- }
-
- return NULL;
-}
-
-
-/**
- * g_list_position:
- * @list: a #GList
- * @llink: an element in the #GList
- *
- * Gets the position of the given element
- * in the #GList (starting from 0).
- *
- * Returns: the position of the element in the #GList,
- * or -1 if the element is not found
- */
-gint
-g_list_position (GList *list,
- GList *llink)
-{
- gint i;
-
- i = 0;
- while (list)
- {
- if (list == llink)
- return i;
- i++;
- list = list->next;
- }
-
- return -1;
-}
-
-/**
- * g_list_index:
- * @list: a #GList
- * @data: the data to find
- *
- * Gets the position of the element containing
- * the given data (starting from 0).
- *
- * Returns: the index of the element containing the data,
- * or -1 if the data is not found
- */
-gint
-g_list_index (GList *list,
- gconstpointer data)
-{
- gint i;
-
- i = 0;
- while (list)
- {
- if (list->data == data)
- return i;
- i++;
- list = list->next;
- }
-
- return -1;
-}
-
-/**
- * g_list_last:
- * @list: a #GList
- *
- * Gets the last element in a #GList.
- *
- * Returns: the last element in the #GList,
- * or %NULL if the #GList has no elements
- */
-GList*
-g_list_last (GList *list)
-{
- if (list)
- {
- while (list->next)
- list = list->next;
- }
-
- return list;
-}
-
-/**
- * g_list_first:
- * @list: a #GList
- *
- * Gets the first element in a #GList.
- *
- * Returns: the first element in the #GList,
- * or %NULL if the #GList has no elements
- */
-GList*
-g_list_first (GList *list)
-{
- if (list)
- {
- while (list->prev)
- list = list->prev;
- }
-
- return list;
-}
-
-/**
- * g_list_length:
- * @list: a #GList
- *
- * Gets the number of elements in a #GList.
- *
- * <note><para>
- * This function iterates over the whole list to
- * count its elements.
- * </para></note>
- *
- * Returns: the number of elements in the #GList
- */
-guint
-g_list_length (GList *list)
-{
- guint length;
-
- length = 0;
- while (list)
- {
- length++;
- list = list->next;
- }
-
- return length;
-}
-
-/**
- * g_list_foreach:
- * @list: a #GList
- * @func: the function to call with each element's data
- * @user_data: user data to pass to the function
- *
- * Calls a function for each element of a #GList.
- */
-void
-g_list_foreach (GList *list,
- GFunc func,
- gpointer user_data)
-{
- while (list)
- {
- GList *next = list->next;
- (*func) (list->data, user_data);
- list = next;
- }
-}
-
-static GList*
-g_list_insert_sorted_real (GList *list,
- gpointer data,
- GFunc func,
- gpointer user_data)
-{
- GList *tmp_list = list;
- GList *new_list;
- gint cmp;
-
- g_return_val_if_fail (func != NULL, list);
-
- if (!list)
- {
- new_list = _g_list_alloc0 ();
- new_list->data = data;
- return new_list;
- }
-
- cmp = ((GCompareDataFunc) func) (data, tmp_list->data, user_data);
-
- while ((tmp_list->next) && (cmp > 0))
- {
- tmp_list = tmp_list->next;
-
- cmp = ((GCompareDataFunc) func) (data, tmp_list->data, user_data);
- }
-
- new_list = _g_list_alloc0 ();
- new_list->data = data;
-
- if ((!tmp_list->next) && (cmp > 0))
- {
- tmp_list->next = new_list;
- new_list->prev = tmp_list;
- return list;
- }
-
- if (tmp_list->prev)
- {
- tmp_list->prev->next = new_list;
- new_list->prev = tmp_list->prev;
- }
- new_list->next = tmp_list;
- tmp_list->prev = new_list;
-
- if (tmp_list == list)
- return new_list;
- else
- return list;
-}
-
-/**
- * g_list_insert_sorted:
- * @list: a pointer to a #GList
- * @data: the data for the new element
- * @func: the function to compare elements in the list. It should
- * return a number > 0 if the first parameter comes after the
- * second parameter in the sort order.
- *
- * Inserts a new element into the list, using the given comparison
- * function to determine its position.
- *
- * Returns: the new start of the #GList
- */
-GList*
-g_list_insert_sorted (GList *list,
- gpointer data,
- GCompareFunc func)
-{
- return g_list_insert_sorted_real (list, data, (GFunc) func, NULL);
-}
-
-/**
- * g_list_insert_sorted_with_data:
- * @list: a pointer to a #GList
- * @data: the data for the new element
- * @func: the function to compare elements in the list.
- * It should return a number > 0 if the first parameter
- * comes after the second parameter in the sort order.
- * @user_data: user data to pass to comparison function.
- *
- * Inserts a new element into the list, using the given comparison
- * function to determine its position.
- *
- * Returns: the new start of the #GList
- *
- * Since: 2.10
- */
-GList*
-g_list_insert_sorted_with_data (GList *list,
- gpointer data,
- GCompareDataFunc func,
- gpointer user_data)
-{
- return g_list_insert_sorted_real (list, data, (GFunc) func, user_data);
-}
-
-static GList *
-g_list_sort_merge (GList *l1,
- GList *l2,
- GFunc compare_func,
- gpointer user_data)
-{
- GList list, *l, *lprev;
- gint cmp;
-
- l = &list;
- lprev = NULL;
-
- while (l1 && l2)
- {
- cmp = ((GCompareDataFunc) compare_func) (l1->data, l2->data, user_data);
-
- if (cmp <= 0)
- {
- l->next = l1;
- l1 = l1->next;
- }
- else
- {
- l->next = l2;
- l2 = l2->next;
- }
- l = l->next;
- l->prev = lprev;
- lprev = l;
- }
- l->next = l1 ? l1 : l2;
- l->next->prev = l;
-
- return list.next;
-}
-
-static GList*
-g_list_sort_real (GList *list,
- GFunc compare_func,
- gpointer user_data)
-{
- GList *l1, *l2;
-
- if (!list)
- return NULL;
- if (!list->next)
- return list;
-
- l1 = list;
- l2 = list->next;
-
- while ((l2 = l2->next) != NULL)
- {
- if ((l2 = l2->next) == NULL)
- break;
- l1 = l1->next;
- }
- l2 = l1->next;
- l1->next = NULL;
-
- return g_list_sort_merge (g_list_sort_real (list, compare_func, user_data),
- g_list_sort_real (l2, compare_func, user_data),
- compare_func,
- user_data);
-}
-
-/**
- * g_list_sort:
- * @list: a #GList
- * @compare_func: the comparison function used to sort the #GList.
- * This function is passed the data from 2 elements of the #GList
- * and should return 0 if they are equal, a negative value if the
- * first element comes before the second, or a positive value if
- * the first element comes after the second.
- *
- * Sorts a #GList using the given comparison function.
- *
- * Returns: the start of the sorted #GList
- */
-GList *
-g_list_sort (GList *list,
- GCompareFunc compare_func)
-{
- return g_list_sort_real (list, (GFunc) compare_func, NULL);
-
-}
-
-/**
- * g_list_sort_with_data:
- * @list: a #GList
- * @compare_func: comparison function
- * @user_data: user data to pass to comparison function
- *
- * Like g_list_sort(), but the comparison function accepts
- * a user data argument.
- *
- * Returns: the new head of @list
- */
-GList *
-g_list_sort_with_data (GList *list,
- GCompareDataFunc compare_func,
- gpointer user_data)
-{
- return g_list_sort_real (list, (GFunc) compare_func, user_data);
-}
-
-#define __G_LIST_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/glist.h b/navit/support/glib/glist.h
deleted file mode 100644
index e74ed96f1..000000000
--- a/navit/support/glib/glist.h
+++ /dev/null
@@ -1,120 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_LIST_H__
-#define __G_LIST_H__
-
-#include <glib/gmem.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GList GList;
-
-struct _GList
-{
- gpointer data;
- GList *next;
- GList *prev;
-};
-
-/* Doubly linked lists
- */
-GList* g_list_alloc (void) G_GNUC_WARN_UNUSED_RESULT;
-void g_list_free (GList *list);
-void g_list_free_1 (GList *list);
-#define g_list_free1 g_list_free_1
-GList* g_list_append (GList *list,
- gpointer data) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_prepend (GList *list,
- gpointer data) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_insert (GList *list,
- gpointer data,
- gint position) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_insert_sorted (GList *list,
- gpointer data,
- GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_insert_sorted_with_data (GList *list,
- gpointer data,
- GCompareDataFunc func,
- gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_insert_before (GList *list,
- GList *sibling,
- gpointer data) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_concat (GList *list1,
- GList *list2) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_remove (GList *list,
- gconstpointer data) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_remove_all (GList *list,
- gconstpointer data) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_remove_link (GList *list,
- GList *llink) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_delete_link (GList *list,
- GList *link_) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_reverse (GList *list) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_copy (GList *list) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_nth (GList *list,
- guint n);
-GList* g_list_nth_prev (GList *list,
- guint n);
-GList* g_list_find (GList *list,
- gconstpointer data);
-GList* g_list_find_custom (GList *list,
- gconstpointer data,
- GCompareFunc func);
-gint g_list_position (GList *list,
- GList *llink);
-gint g_list_index (GList *list,
- gconstpointer data);
-GList* g_list_last (GList *list);
-GList* g_list_first (GList *list);
-guint g_list_length (GList *list);
-void g_list_foreach (GList *list,
- GFunc func,
- gpointer user_data);
-GList* g_list_sort (GList *list,
- GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT;
-GList* g_list_sort_with_data (GList *list,
- GCompareDataFunc compare_func,
- gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
-gpointer g_list_nth_data (GList *list,
- guint n);
-
-
-#define g_list_previous(list) ((list) ? (((GList *)(list))->prev) : NULL)
-#define g_list_next(list) ((list) ? (((GList *)(list))->next) : NULL)
-
-#ifndef G_DISABLE_DEPRECATED
-void g_list_push_allocator (gpointer allocator);
-void g_list_pop_allocator (void);
-#endif
-
-G_END_DECLS
-
-#endif /* __G_LIST_H__ */
diff --git a/navit/support/glib/gmacros.h b/navit/support/glib/gmacros.h
deleted file mode 100644
index f87e932ce..000000000
--- a/navit/support/glib/gmacros.h
+++ /dev/null
@@ -1,273 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/* This file must not include any other glib header file and must thus
- * not refer to variables from glibconfig.h
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_MACROS_H__
-#define __G_MACROS_H__
-
-/* We include stddef.h to get the system's definition of NULL
- */
-#include <stddef.h>
-
-/* Here we provide G_GNUC_EXTENSION as an alias for __extension__,
- * where this is valid. This allows for warningless compilation of
- * "long long" types even in the presence of '-ansi -pedantic'.
- */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
-# define G_GNUC_EXTENSION __extension__
-#else
-# define G_GNUC_EXTENSION
-#endif
-
-/* Provide macros to feature the GCC function attribute.
- */
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)
-#define G_GNUC_PURE \
- __attribute__((__pure__))
-#define G_GNUC_MALLOC \
- __attribute__((__malloc__))
-#else
-#define G_GNUC_PURE
-#define G_GNUC_MALLOC
-#endif
-
-#if __GNUC__ >= 4
-#define G_GNUC_NULL_TERMINATED __attribute__((__sentinel__))
-#else
-#define G_GNUC_NULL_TERMINATED
-#endif
-
-#if (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)
-#define G_GNUC_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
-#define G_GNUC_ALLOC_SIZE2(x,y) __attribute__((__alloc_size__(x,y)))
-#else
-#define G_GNUC_ALLOC_SIZE(x)
-#define G_GNUC_ALLOC_SIZE2(x,y)
-#endif
-
-#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ > 4)
-#define G_GNUC_PRINTF( format_idx, arg_idx ) \
- __attribute__((__format__ (__printf__, format_idx, arg_idx)))
-#define G_GNUC_SCANF( format_idx, arg_idx ) \
- __attribute__((__format__ (__scanf__, format_idx, arg_idx)))
-#define G_GNUC_FORMAT( arg_idx ) \
- __attribute__((__format_arg__ (arg_idx)))
-#define G_GNUC_NORETURN \
- __attribute__((__noreturn__))
-#define G_GNUC_CONST \
- __attribute__((__const__))
-#define G_GNUC_UNUSED \
- __attribute__((__unused__))
-#define G_GNUC_NO_INSTRUMENT \
- __attribute__((__no_instrument_function__))
-#else /* !__GNUC__ */
-#define G_GNUC_PRINTF( format_idx, arg_idx )
-#define G_GNUC_SCANF( format_idx, arg_idx )
-#define G_GNUC_FORMAT( arg_idx )
-#define G_GNUC_NORETURN
-#define G_GNUC_CONST
-#define G_GNUC_UNUSED
-#define G_GNUC_NO_INSTRUMENT
-#endif /* !__GNUC__ */
-
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1)
-#define G_GNUC_DEPRECATED \
- __attribute__((__deprecated__))
-#else
-#define G_GNUC_DEPRECATED
-#endif /* __GNUC__ */
-
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3)
-# define G_GNUC_MAY_ALIAS __attribute__((may_alias))
-#else
-# define G_GNUC_MAY_ALIAS
-#endif
-
-#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)
-#define G_GNUC_WARN_UNUSED_RESULT \
- __attribute__((warn_unused_result))
-#else
-#define G_GNUC_WARN_UNUSED_RESULT
-#endif /* __GNUC__ */
-
-#ifndef G_DISABLE_DEPRECATED
-/* Wrap the gcc __PRETTY_FUNCTION__ and __FUNCTION__ variables with
- * macros, so we can refer to them as strings unconditionally.
- * usage not-recommended since gcc-3.0
- */
-#if defined (__GNUC__) && (__GNUC__ < 3)
-#define G_GNUC_FUNCTION __FUNCTION__
-#define G_GNUC_PRETTY_FUNCTION __PRETTY_FUNCTION__
-#else /* !__GNUC__ */
-#define G_GNUC_FUNCTION ""
-#define G_GNUC_PRETTY_FUNCTION ""
-#endif /* !__GNUC__ */
-#endif /* !G_DISABLE_DEPRECATED */
-
-#define G_STRINGIFY(macro_or_string) G_STRINGIFY_ARG (macro_or_string)
-#define G_STRINGIFY_ARG(contents) #contents
-
-/* Provide a string identifying the current code position */
-#if defined(__GNUC__) && (__GNUC__ < 3) && !defined(__cplusplus)
-# define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__) ":" __PRETTY_FUNCTION__ "()"
-#else
-# define G_STRLOC __FILE__ ":" G_STRINGIFY (__LINE__)
-#endif
-
-/* Provide a string identifying the current function, non-concatenatable */
-#if defined (__GNUC__)
-# define G_STRFUNC ((const char*) (__PRETTY_FUNCTION__))
-#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 19901L
-# define G_STRFUNC ((const char*) (__func__))
-#else
-# define G_STRFUNC ((const char*) ("???"))
-#endif
-
-/* Guard C code in headers, while including them from C++ */
-#ifdef __cplusplus
-# define G_BEGIN_DECLS extern "C" {
-# define G_END_DECLS }
-#else
-# define G_BEGIN_DECLS
-# define G_END_DECLS
-#endif
-
-/* Provide definitions for some commonly used macros.
- * Some of them are only provided if they haven't already
- * been defined. It is assumed that if they are already
- * defined then the current definition is correct.
- */
-#ifndef NULL
-# ifdef __cplusplus
-# define NULL (0L)
-# else /* !__cplusplus */
-# define NULL ((void*) 0)
-# endif /* !__cplusplus */
-#endif
-
-#ifndef FALSE
-#define FALSE (0)
-#endif
-
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
-#undef MAX
-#define MAX(a, b) (((a) > (b)) ? (a) : (b))
-
-#undef MIN
-#define MIN(a, b) (((a) < (b)) ? (a) : (b))
-
-#undef ABS
-#define ABS(a) (((a) < 0) ? -(a) : (a))
-
-#undef CLAMP
-#define CLAMP(x, low, high) (((x) > (high)) ? (high) : (((x) < (low)) ? (low) : (x)))
-
-/* Count the number of elements in an array. The array must be defined
- * as such; using this with a dynamically allocated array will give
- * incorrect results.
- */
-#define G_N_ELEMENTS(arr) (sizeof (arr) / sizeof ((arr)[0]))
-
-/* Macros by analogy to GINT_TO_POINTER, GPOINTER_TO_INT
- */
-#define GPOINTER_TO_SIZE(p) ((gsize) (p))
-#define GSIZE_TO_POINTER(s) ((gpointer) (gsize) (s))
-
-/* Provide convenience macros for handling structure
- * fields through their offsets.
- */
-
-#if defined(__GNUC__) && __GNUC__ >= 4
-# define G_STRUCT_OFFSET(struct_type, member) \
- ((glong) __builtin_offsetof (struct_type, member))
-#else
-# define G_STRUCT_OFFSET(struct_type, member) \
- ((glong) ((guint8*) &((struct_type*) 0)->member))
-#endif
-
-#define G_STRUCT_MEMBER_P(struct_p, struct_offset) \
- ((gpointer) ((guint8*) (struct_p) + (glong) (struct_offset)))
-#define G_STRUCT_MEMBER(member_type, struct_p, struct_offset) \
- (*(member_type*) G_STRUCT_MEMBER_P ((struct_p), (struct_offset)))
-
-/* Provide simple macro statement wrappers:
- * G_STMT_START { statements; } G_STMT_END;
- * This can be used as a single statement, like:
- * if (x) G_STMT_START { ... } G_STMT_END; else ...
- * This intentionally does not use compiler extensions like GCC's '({...})' to
- * avoid portability issue or side effects when compiled with different compilers.
- */
-#if !(defined (G_STMT_START) && defined (G_STMT_END))
-# define G_STMT_START do
-# define G_STMT_END while (0)
-#endif
-
-/* Allow the app programmer to select whether or not return values
- * (usually char*) are const or not. Don't try using this feature for
- * functions with C++ linkage.
- */
-#ifdef G_DISABLE_CONST_RETURNS
-#define G_CONST_RETURN
-#else
-#define G_CONST_RETURN const
-#endif
-
-/*
- * The G_LIKELY and G_UNLIKELY macros let the programmer give hints to
- * the compiler about the expected result of an expression. Some compilers
- * can use this information for optimizations.
- *
- * The _G_BOOLEAN_EXPR macro is intended to trigger a gcc warning when
- * putting assignments in g_return_if_fail ().
- */
-#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
-#define _G_BOOLEAN_EXPR(expr) \
- __extension__ ({ \
- int _g_boolean_var_; \
- if (expr) \
- _g_boolean_var_ = 1; \
- else \
- _g_boolean_var_ = 0; \
- _g_boolean_var_; \
-})
-#define G_LIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 1))
-#define G_UNLIKELY(expr) (__builtin_expect (_G_BOOLEAN_EXPR(expr), 0))
-#else
-#define G_LIKELY(expr) (expr)
-#define G_UNLIKELY(expr) (expr)
-#endif
-
-#endif /* __G_MACROS_H__ */
diff --git a/navit/support/glib/gmem.c b/navit/support/glib/gmem.c
deleted file mode 100644
index 2c6a00998..000000000
--- a/navit/support/glib/gmem.c
+++ /dev/null
@@ -1,742 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * MT safe
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <string.h>
-#include <signal.h>
-
-#include "glib.h"
-#include "gthreadprivate.h"
-#include "galias.h"
-
-#define MEM_PROFILE_TABLE_SIZE 4096
-
-
-/* notes on macros:
- * having G_DISABLE_CHECKS defined disables use of glib_mem_profiler_table and
- * g_mem_profile().
- * REALLOC_0_WORKS is defined if g_realloc (NULL, x) works.
- * SANE_MALLOC_PROTOS is defined if the systems malloc() and friends functions
- * match the corresponding GLib prototypes, keep configure.in and gmem.h in sync here.
- * g_mem_gc_friendly is TRUE, freed memory should be 0-wiped.
- */
-
-/* --- prototypes --- */
-static gboolean g_mem_initialized = FALSE;
-static void g_mem_init_nomessage (void);
-
-
-/* --- malloc wrappers --- */
-#ifndef REALLOC_0_WORKS
-static gpointer
-standard_realloc (gpointer mem,
- gsize n_bytes)
-{
- if (!mem)
- return malloc (n_bytes);
- else
- return realloc (mem, n_bytes);
-}
-#endif /* !REALLOC_0_WORKS */
-
-#ifdef SANE_MALLOC_PROTOS
-# define standard_malloc malloc
-# ifdef REALLOC_0_WORKS
-# define standard_realloc realloc
-# endif /* REALLOC_0_WORKS */
-# define standard_free free
-# define standard_calloc calloc
-# define standard_try_malloc malloc
-# define standard_try_realloc realloc
-#else /* !SANE_MALLOC_PROTOS */
-static gpointer
-standard_malloc (gsize n_bytes)
-{
- return malloc (n_bytes);
-}
-# ifdef REALLOC_0_WORKS
-static gpointer
-standard_realloc (gpointer mem,
- gsize n_bytes)
-{
- return realloc (mem, n_bytes);
-}
-# endif /* REALLOC_0_WORKS */
-static void
-standard_free (gpointer mem)
-{
- free (mem);
-}
-static gpointer
-standard_calloc (gsize n_blocks,
- gsize n_bytes)
-{
- return calloc (n_blocks, n_bytes);
-}
-#define standard_try_malloc standard_malloc
-#define standard_try_realloc standard_realloc
-#endif /* !SANE_MALLOC_PROTOS */
-
-
-/* --- variables --- */
-static GMemVTable glib_mem_vtable = {
- standard_malloc,
- standard_realloc,
- standard_free,
- standard_calloc,
- standard_try_malloc,
- standard_try_realloc,
-};
-
-
-/* --- functions --- */
-gpointer
-g_malloc (gsize n_bytes)
-{
- if (G_UNLIKELY (!g_mem_initialized))
- g_mem_init_nomessage();
- if (G_LIKELY (n_bytes))
- {
- gpointer mem;
-
- mem = glib_mem_vtable.vmalloc (n_bytes);
- if (mem)
- return mem;
-
-#if NOT_NEEDED_FOR_NAVIT
- g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes",
- G_STRLOC, n_bytes);
-#endif /* NOT_NEEDED_FOR_NAVIT */
- }
-
- return NULL;
-}
-
-gpointer
-g_malloc0 (gsize n_bytes)
-{
- if (G_UNLIKELY (!g_mem_initialized))
- g_mem_init_nomessage();
- if (G_LIKELY (n_bytes))
- {
- gpointer mem;
-
- mem = glib_mem_vtable.vcalloc (1, n_bytes);
- if (mem)
- return mem;
-
-#if NOT_NEEDED_FOR_NAVIT
- g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes",
- G_STRLOC, n_bytes);
-#endif /* NOT_NEEDED_FOR_NAVIT */
- }
-
- return NULL;
-}
-
-gpointer
-g_realloc (gpointer mem,
- gsize n_bytes)
-{
- if (G_UNLIKELY (!g_mem_initialized))
- g_mem_init_nomessage();
- if (G_LIKELY (n_bytes))
- {
- mem = glib_mem_vtable.vrealloc (mem, n_bytes);
- if (mem)
- return mem;
-
-#if NOT_NEEDED_FOR_NAVIT
- g_error ("%s: failed to allocate %"G_GSIZE_FORMAT" bytes",
- G_STRLOC, n_bytes);
-#endif /* NOT_NEEDED_FOR_NAVIT */
- }
-
- if (mem)
- glib_mem_vtable.vfree (mem);
-
- return NULL;
-}
-
-void
-g_free (gpointer mem)
-{
- if (G_UNLIKELY (!g_mem_initialized))
- g_mem_init_nomessage();
- if (G_LIKELY (mem))
- glib_mem_vtable.vfree (mem);
-}
-
-gpointer
-g_try_malloc (gsize n_bytes)
-{
- if (G_UNLIKELY (!g_mem_initialized))
- g_mem_init_nomessage();
- if (G_LIKELY (n_bytes))
- return glib_mem_vtable.vtry_malloc (n_bytes);
- else
- return NULL;
-}
-
-gpointer
-g_try_malloc0 (gsize n_bytes)
-{
- gpointer mem;
-
- mem = g_try_malloc (n_bytes);
-
- if (mem)
- memset (mem, 0, n_bytes);
-
- return mem;
-}
-
-gpointer
-g_try_realloc (gpointer mem,
- gsize n_bytes)
-{
- if (G_UNLIKELY (!g_mem_initialized))
- g_mem_init_nomessage();
- if (G_LIKELY (n_bytes))
- return glib_mem_vtable.vtry_realloc (mem, n_bytes);
-
- if (mem)
- glib_mem_vtable.vfree (mem);
-
- return NULL;
-}
-
-static gpointer
-fallback_calloc (gsize n_blocks,
- gsize n_block_bytes)
-{
- gsize l = n_blocks * n_block_bytes;
- gpointer mem = glib_mem_vtable.vmalloc (l);
-
- if (mem)
- memset (mem, 0, l);
-
- return mem;
-}
-
-static gboolean vtable_set = FALSE;
-
-/**
- * g_mem_is_system_malloc
- *
- * Checks whether the allocator used by g_malloc() is the system's
- * malloc implementation. If it returns %TRUE memory allocated with
- * malloc() can be used interchangeable with memory allocated using g_malloc().
- * This function is useful for avoiding an extra copy of allocated memory returned
- * by a non-GLib-based API.
- *
- * A different allocator can be set using g_mem_set_vtable().
- *
- * Return value: if %TRUE, malloc() and g_malloc() can be mixed.
- **/
-gboolean
-g_mem_is_system_malloc (void)
-{
- return !vtable_set;
-}
-
-void
-g_mem_set_vtable (GMemVTable *vtable)
-{
- if (!vtable_set)
- {
- if (vtable->vmalloc && vtable->vrealloc && vtable->vfree)
- {
- glib_mem_vtable.vmalloc = vtable->vmalloc;
- glib_mem_vtable.vrealloc = vtable->vrealloc;
- glib_mem_vtable.vfree = vtable->vfree;
- glib_mem_vtable.vcalloc = vtable->vcalloc ? vtable->vcalloc : fallback_calloc;
- glib_mem_vtable.vtry_malloc = vtable->vtry_malloc ? vtable->vtry_malloc : glib_mem_vtable.vmalloc;
- glib_mem_vtable.vtry_realloc = vtable->vtry_realloc ? vtable->vtry_realloc : glib_mem_vtable.vrealloc;
- vtable_set = TRUE;
- }
-#if NOT_NEEDED_FOR_NAVIT
- else
- g_warning (G_STRLOC ": memory allocation vtable lacks one of malloc(), realloc() or free()");
-#endif /* NOT_NEEDED_FOR_NAVIT */
- }
-#if NOT_NEEDED_FOR_NAVIT
- else
- g_warning (G_STRLOC ": memory allocation vtable can only be set once at startup");
-#endif /* NOT_NEEDED_FOR_NAVIT */
-}
-
-
-/* --- memory profiling and checking --- */
-#ifdef G_DISABLE_CHECKS
-GMemVTable *glib_mem_profiler_table = &glib_mem_vtable;
-void
-g_mem_profile (void)
-{
-}
-#else /* !G_DISABLE_CHECKS */
-typedef enum {
- PROFILER_FREE = 0,
- PROFILER_ALLOC = 1,
- PROFILER_RELOC = 2,
- PROFILER_ZINIT = 4
-} ProfilerJob;
-static guint *profile_data = NULL;
-static gsize profile_allocs = 0;
-static gsize profile_zinit = 0;
-static gsize profile_frees = 0;
-static GMutex *gmem_profile_mutex = NULL;
-#ifdef G_ENABLE_DEBUG
-static volatile gsize g_trap_free_size = 0;
-static volatile gsize g_trap_realloc_size = 0;
-static volatile gsize g_trap_malloc_size = 0;
-#endif /* G_ENABLE_DEBUG */
-
-#define PROFILE_TABLE(f1,f2,f3) ( ( ((f3) << 2) | ((f2) << 1) | (f1) ) * (MEM_PROFILE_TABLE_SIZE + 1))
-
-static void
-profiler_log (ProfilerJob job,
- gsize n_bytes,
- gboolean success)
-{
- g_mutex_lock (gmem_profile_mutex);
- if (!profile_data)
- {
- profile_data = standard_calloc ((MEM_PROFILE_TABLE_SIZE + 1) * 8,
- sizeof (profile_data[0]));
- if (!profile_data) /* memory system kiddin' me, eh? */
- {
- g_mutex_unlock (gmem_profile_mutex);
- return;
- }
- }
-
- if (n_bytes < MEM_PROFILE_TABLE_SIZE)
- profile_data[n_bytes + PROFILE_TABLE ((job & PROFILER_ALLOC) != 0,
- (job & PROFILER_RELOC) != 0,
- success != 0)] += 1;
- else
- profile_data[MEM_PROFILE_TABLE_SIZE + PROFILE_TABLE ((job & PROFILER_ALLOC) != 0,
- (job & PROFILER_RELOC) != 0,
- success != 0)] += 1;
- if (success)
- {
- if (job & PROFILER_ALLOC)
- {
- profile_allocs += n_bytes;
- if (job & PROFILER_ZINIT)
- profile_zinit += n_bytes;
- }
- else
- profile_frees += n_bytes;
- }
- g_mutex_unlock (gmem_profile_mutex);
-}
-
-static void
-profile_print_locked (guint *local_data,
- gboolean success)
-{
- gboolean need_header = TRUE;
- guint i;
-
- for (i = 0; i <= MEM_PROFILE_TABLE_SIZE; i++)
- {
- glong t_malloc = local_data[i + PROFILE_TABLE (1, 0, success)];
- glong t_realloc = local_data[i + PROFILE_TABLE (1, 1, success)];
- glong t_free = local_data[i + PROFILE_TABLE (0, 0, success)];
- glong t_refree = local_data[i + PROFILE_TABLE (0, 1, success)];
-
- if (!t_malloc && !t_realloc && !t_free && !t_refree)
- continue;
- else if (need_header)
- {
- need_header = FALSE;
- g_print (" blocks of | allocated | freed | allocated | freed | n_bytes \n");
- g_print (" n_bytes | n_times by | n_times by | n_times by | n_times by | remaining \n");
- g_print (" | malloc() | free() | realloc() | realloc() | \n");
- g_print ("===========|============|============|============|============|===========\n");
- }
- if (i < MEM_PROFILE_TABLE_SIZE)
- g_print ("%10u | %10ld | %10ld | %10ld | %10ld |%+11ld\n",
- i, t_malloc, t_free, t_realloc, t_refree,
- (t_malloc - t_free + t_realloc - t_refree) * i);
- else if (i >= MEM_PROFILE_TABLE_SIZE)
- g_print (" >%6u | %10ld | %10ld | %10ld | %10ld | ***\n",
- i, t_malloc, t_free, t_realloc, t_refree);
- }
- if (need_header)
- g_print (" --- none ---\n");
-}
-
-void
-g_mem_profile (void)
-{
- guint local_data[(MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0])];
- gsize local_allocs;
- gsize local_zinit;
- gsize local_frees;
-
- if (G_UNLIKELY (!g_mem_initialized))
- g_mem_init_nomessage();
-
- g_mutex_lock (gmem_profile_mutex);
-
- local_allocs = profile_allocs;
- local_zinit = profile_zinit;
- local_frees = profile_frees;
-
- if (!profile_data)
- {
- g_mutex_unlock (gmem_profile_mutex);
- return;
- }
-
- memcpy (local_data, profile_data,
- (MEM_PROFILE_TABLE_SIZE + 1) * 8 * sizeof (profile_data[0]));
-
- g_mutex_unlock (gmem_profile_mutex);
-
- g_print ("GLib Memory statistics (successful operations):\n");
- profile_print_locked (local_data, TRUE);
- g_print ("GLib Memory statistics (failing operations):\n");
- profile_print_locked (local_data, FALSE);
- g_print ("Total bytes: allocated=%"G_GSIZE_FORMAT", "
- "zero-initialized=%"G_GSIZE_FORMAT" (%.2f%%), "
- "freed=%"G_GSIZE_FORMAT" (%.2f%%), "
- "remaining=%"G_GSIZE_FORMAT"\n",
- local_allocs,
- local_zinit,
- ((gdouble) local_zinit) / local_allocs * 100.0,
- local_frees,
- ((gdouble) local_frees) / local_allocs * 100.0,
- local_allocs - local_frees);
-}
-
-static gpointer
-profiler_try_malloc (gsize n_bytes)
-{
- gsize *p;
-
-#ifdef G_ENABLE_DEBUG
- if (g_trap_malloc_size == n_bytes)
- G_BREAKPOINT ();
-#endif /* G_ENABLE_DEBUG */
-
- p = standard_malloc (sizeof (gsize) * 2 + n_bytes);
-
- if (p)
- {
- p[0] = 0; /* free count */
- p[1] = n_bytes; /* length */
- profiler_log (PROFILER_ALLOC, n_bytes, TRUE);
- p += 2;
- }
- else
- profiler_log (PROFILER_ALLOC, n_bytes, FALSE);
-
- return p;
-}
-
-static gpointer
-profiler_malloc (gsize n_bytes)
-{
- gpointer mem = profiler_try_malloc (n_bytes);
-
- if (!mem)
- g_mem_profile ();
-
- return mem;
-}
-
-static gpointer
-profiler_calloc (gsize n_blocks,
- gsize n_block_bytes)
-{
- gsize l = n_blocks * n_block_bytes;
- gsize *p;
-
-#ifdef G_ENABLE_DEBUG
- if (g_trap_malloc_size == l)
- G_BREAKPOINT ();
-#endif /* G_ENABLE_DEBUG */
-
- p = standard_calloc (1, sizeof (gsize) * 2 + l);
-
- if (p)
- {
- p[0] = 0; /* free count */
- p[1] = l; /* length */
- profiler_log (PROFILER_ALLOC | PROFILER_ZINIT, l, TRUE);
- p += 2;
- }
- else
- {
- profiler_log (PROFILER_ALLOC | PROFILER_ZINIT, l, FALSE);
- g_mem_profile ();
- }
-
- return p;
-}
-
-static void
-profiler_free (gpointer mem)
-{
- gsize *p = mem;
-
- p -= 2;
- if (p[0]) /* free count */
- {
- g_warning ("free(%p): memory has been freed %"G_GSIZE_FORMAT" times already",
- p + 2, p[0]);
- profiler_log (PROFILER_FREE,
- p[1], /* length */
- FALSE);
- }
- else
- {
-#ifdef G_ENABLE_DEBUG
- if (g_trap_free_size == p[1])
- G_BREAKPOINT ();
-#endif /* G_ENABLE_DEBUG */
-
- profiler_log (PROFILER_FREE,
- p[1], /* length */
- TRUE);
- memset (p + 2, 0xaa, p[1]);
-
- /* for all those that miss standard_free (p); in this place, yes,
- * we do leak all memory when profiling, and that is intentional
- * to catch double frees. patch submissions are futile.
- */
- }
- p[0] += 1;
-}
-
-static gpointer
-profiler_try_realloc (gpointer mem,
- gsize n_bytes)
-{
- gsize *p = mem;
-
- p -= 2;
-
-#ifdef G_ENABLE_DEBUG
- if (g_trap_realloc_size == n_bytes)
- G_BREAKPOINT ();
-#endif /* G_ENABLE_DEBUG */
-
- if (mem && p[0]) /* free count */
- {
- g_warning ("realloc(%p, %"G_GSIZE_FORMAT"): "
- "memory has been freed %"G_GSIZE_FORMAT" times already",
- p + 2, (gsize) n_bytes, p[0]);
- profiler_log (PROFILER_ALLOC | PROFILER_RELOC, n_bytes, FALSE);
-
- return NULL;
- }
- else
- {
- p = standard_realloc (mem ? p : NULL, sizeof (gsize) * 2 + n_bytes);
-
- if (p)
- {
- if (mem)
- profiler_log (PROFILER_FREE | PROFILER_RELOC, p[1], TRUE);
- p[0] = 0;
- p[1] = n_bytes;
- profiler_log (PROFILER_ALLOC | PROFILER_RELOC, p[1], TRUE);
- p += 2;
- }
- else
- profiler_log (PROFILER_ALLOC | PROFILER_RELOC, n_bytes, FALSE);
-
- return p;
- }
-}
-
-static gpointer
-profiler_realloc (gpointer mem,
- gsize n_bytes)
-{
- mem = profiler_try_realloc (mem, n_bytes);
-
- if (!mem)
- g_mem_profile ();
-
- return mem;
-}
-
-static GMemVTable profiler_table = {
- profiler_malloc,
- profiler_realloc,
- profiler_free,
- profiler_calloc,
- profiler_try_malloc,
- profiler_try_realloc,
-};
-GMemVTable *glib_mem_profiler_table = &profiler_table;
-
-#endif /* !G_DISABLE_CHECKS */
-
-/* --- MemChunks --- */
-#ifndef G_ALLOC_AND_FREE
-typedef struct _GAllocator GAllocator;
-typedef struct _GMemChunk GMemChunk;
-#define G_ALLOC_ONLY 1
-#define G_ALLOC_AND_FREE 2
-#endif
-
-struct _GMemChunk {
- guint alloc_size; /* the size of an atom */
-};
-
-GMemChunk*
-g_mem_chunk_new (const gchar *name,
- gint atom_size,
- gsize area_size,
- gint type)
-{
- GMemChunk *mem_chunk;
- g_return_val_if_fail (atom_size > 0, NULL);
-
- mem_chunk = g_slice_new (GMemChunk);
- mem_chunk->alloc_size = atom_size;
- return mem_chunk;
-}
-
-void
-g_mem_chunk_destroy (GMemChunk *mem_chunk)
-{
- g_return_if_fail (mem_chunk != NULL);
-
- g_slice_free (GMemChunk, mem_chunk);
-}
-
-gpointer
-g_mem_chunk_alloc (GMemChunk *mem_chunk)
-{
- g_return_val_if_fail (mem_chunk != NULL, NULL);
-
- return g_slice_alloc (mem_chunk->alloc_size);
-}
-
-gpointer
-g_mem_chunk_alloc0 (GMemChunk *mem_chunk)
-{
- g_return_val_if_fail (mem_chunk != NULL, NULL);
-
- return g_slice_alloc0 (mem_chunk->alloc_size);
-}
-
-void
-g_mem_chunk_free (GMemChunk *mem_chunk,
- gpointer mem)
-{
- g_return_if_fail (mem_chunk != NULL);
-
- g_slice_free1 (mem_chunk->alloc_size, mem);
-}
-
-void g_mem_chunk_clean (GMemChunk *mem_chunk) {}
-void g_mem_chunk_reset (GMemChunk *mem_chunk) {}
-void g_mem_chunk_print (GMemChunk *mem_chunk) {}
-void g_mem_chunk_info (void) {}
-void g_blow_chunks (void) {}
-
-GAllocator*
-g_allocator_new (const gchar *name,
- guint n_preallocs)
-{
- static struct _GAllocator {
- gchar *name;
- guint16 n_preallocs;
- guint is_unused : 1;
- guint type : 4;
- GAllocator *last;
- GMemChunk *mem_chunk;
- gpointer free_list;
- } dummy = {
- "GAllocator is deprecated", 1, TRUE, 0, NULL, NULL, NULL,
- };
- /* some (broken) GAllocator uses depend on non-NULL allocators */
- return (void*) &dummy;
-}
-
-void
-g_allocator_free (GAllocator *allocator)
-{
-}
-
-#ifdef ENABLE_GC_FRIENDLY_DEFAULT
-gboolean g_mem_gc_friendly = TRUE;
-#else
-gboolean g_mem_gc_friendly = FALSE;
-#endif
-
-static void
-g_mem_init_nomessage (void)
-{
-#if NOT_NEEDED_FOR_NAVIT
- gchar buffer[1024];
- const gchar *val;
- const GDebugKey keys[] = {
- { "gc-friendly", 1 },
- };
- gint flags;
- if (g_mem_initialized)
- return;
- /* don't use g_malloc/g_message here */
- val = _g_getenv_nomalloc ("G_DEBUG", buffer);
- flags = !val ? 0 : g_parse_debug_string (val, keys, G_N_ELEMENTS (keys));
- if (flags & 1) /* gc-friendly */
- {
- g_mem_gc_friendly = TRUE;
- }
-#endif /* NOT_NEEDED_FOR_NAVIT */
- g_mem_initialized = TRUE;
-}
-
-void
-_g_mem_thread_init_noprivate_nomessage (void)
-{
- /* we may only create mutexes here, locking/
- * unlocking a mutex does not yet work.
- */
- g_mem_init_nomessage();
-#ifndef G_DISABLE_CHECKS
- gmem_profile_mutex = g_mutex_new ();
-#endif
-}
-
-#define __G_MEM_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gmem.h b/navit/support/glib/gmem.h
deleted file mode 100644
index d5779e3b2..000000000
--- a/navit/support/glib/gmem.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_MEM_H__
-#define __G_MEM_H__
-
-#include <glib/gslice.h>
-#include <glib/gtypes.h>
-
-G_BEGIN_DECLS
-
-typedef struct _GMemVTable GMemVTable;
-
-
-#if GLIB_SIZEOF_VOID_P > GLIB_SIZEOF_LONG
-# define G_MEM_ALIGN GLIB_SIZEOF_VOID_P
-#else /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
-# define G_MEM_ALIGN GLIB_SIZEOF_LONG
-#endif /* GLIB_SIZEOF_VOID_P <= GLIB_SIZEOF_LONG */
-
-
-/* Memory allocation functions
- */
-gpointer g_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
-gpointer g_malloc0 (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
-gpointer g_realloc (gpointer mem,
- gsize n_bytes) G_GNUC_WARN_UNUSED_RESULT;
-void g_free (gpointer mem);
-gpointer g_try_malloc (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
-gpointer g_try_malloc0 (gsize n_bytes) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
-gpointer g_try_realloc (gpointer mem,
- gsize n_bytes) G_GNUC_WARN_UNUSED_RESULT;
-
-
-/* Convenience memory allocators
- */
-#define g_new(struct_type, n_structs) \
- ((struct_type *) g_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
-#define g_new0(struct_type, n_structs) \
- ((struct_type *) g_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
-#define g_renew(struct_type, mem, n_structs) \
- ((struct_type *) g_realloc ((mem), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
-
-#define g_try_new(struct_type, n_structs) \
- ((struct_type *) g_try_malloc (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
-#define g_try_new0(struct_type, n_structs) \
- ((struct_type *) g_try_malloc0 (((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
-#define g_try_renew(struct_type, mem, n_structs) \
- ((struct_type *) g_try_realloc ((mem), ((gsize) sizeof (struct_type)) * ((gsize) (n_structs))))
-
-
-/* Memory allocation virtualization for debugging purposes
- * g_mem_set_vtable() has to be the very first GLib function called
- * if being used
- */
-struct _GMemVTable
-{
- gpointer (*vmalloc) (gsize n_bytes);
- gpointer (*vrealloc) (gpointer mem,
- gsize n_bytes);
- void (*vfree) (gpointer mem);
- /* optional; set to NULL if not used ! */
- gpointer (*vcalloc) (gsize n_blocks,
- gsize n_block_bytes);
- gpointer (*vtry_malloc) (gsize n_bytes);
- gpointer (*vtry_realloc) (gpointer mem,
- gsize n_bytes);
-};
-void g_mem_set_vtable (GMemVTable *vtable);
-gboolean g_mem_is_system_malloc (void);
-
-GLIB_VAR gboolean g_mem_gc_friendly;
-
-/* Memory profiler and checker, has to be enabled via g_mem_set_vtable()
- */
-GLIB_VAR GMemVTable *glib_mem_profiler_table;
-void g_mem_profile (void);
-
-
-/* deprecated memchunks and allocators */
-#if !defined (G_DISABLE_DEPRECATED) || defined (GTK_COMPILATION) || defined (GDK_COMPILATION)
-typedef struct _GAllocator GAllocator;
-typedef struct _GMemChunk GMemChunk;
-#define g_mem_chunk_create(type, pre_alloc, alloc_type) ( \
- g_mem_chunk_new (#type " mem chunks (" #pre_alloc ")", \
- sizeof (type), \
- sizeof (type) * (pre_alloc), \
- (alloc_type)) \
-)
-#define g_chunk_new(type, chunk) ( \
- (type *) g_mem_chunk_alloc (chunk) \
-)
-#define g_chunk_new0(type, chunk) ( \
- (type *) g_mem_chunk_alloc0 (chunk) \
-)
-#define g_chunk_free(mem, mem_chunk) G_STMT_START { \
- g_mem_chunk_free ((mem_chunk), (mem)); \
-} G_STMT_END
-#define G_ALLOC_ONLY 1
-#define G_ALLOC_AND_FREE 2
-GMemChunk* g_mem_chunk_new (const gchar *name,
- gint atom_size,
- gsize area_size,
- gint type);
-void g_mem_chunk_destroy (GMemChunk *mem_chunk);
-gpointer g_mem_chunk_alloc (GMemChunk *mem_chunk);
-gpointer g_mem_chunk_alloc0 (GMemChunk *mem_chunk);
-void g_mem_chunk_free (GMemChunk *mem_chunk,
- gpointer mem);
-void g_mem_chunk_clean (GMemChunk *mem_chunk);
-void g_mem_chunk_reset (GMemChunk *mem_chunk);
-void g_mem_chunk_print (GMemChunk *mem_chunk);
-void g_mem_chunk_info (void);
-void g_blow_chunks (void);
-GAllocator*g_allocator_new (const gchar *name,
- guint n_preallocs);
-void g_allocator_free (GAllocator *allocator);
-#define G_ALLOCATOR_LIST (1)
-#define G_ALLOCATOR_SLIST (2)
-#define G_ALLOCATOR_NODE (3)
-#endif /* G_DISABLE_DEPRECATED */
-
-G_END_DECLS
-
-#endif /* __G_MEM_H__ */
diff --git a/navit/support/glib/gmessages.c b/navit/support/glib/gmessages.c
deleted file mode 100644
index 548a412c4..000000000
--- a/navit/support/glib/gmessages.c
+++ /dev/null
@@ -1,1126 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * MT safe
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <signal.h>
-#include <locale.h>
-#include <errno.h>
-
-#include "glib.h"
-#if NOT_NEEDED_FOR_NAVIT
-#include "gdebug.h"
-#endif /* NOT_NEEDED_FOR_NAVIT */
-#include "gprintfint.h"
-#include "gthreadprivate.h"
-#include "galias.h"
-#include "config.h"
-
-#if NOT_NEEDED_FOR_NAVIT
-#ifdef G_OS_WIN32
-#include <process.h> /* For getpid() */
-#include <io.h>
-# define STRICT /* Strict typing, please */
-# define _WIN32_WINDOWS 0x0401 /* to get IsDebuggerPresent */
-# include <windows.h>
-# undef STRICT
-#endif
-
-/* --- structures --- */
-typedef struct _GLogDomain GLogDomain;
-typedef struct _GLogHandler GLogHandler;
-struct _GLogDomain
-{
- gchar *log_domain;
- GLogLevelFlags fatal_mask;
- GLogHandler *handlers;
- GLogDomain *next;
-};
-struct _GLogHandler
-{
- guint id;
- GLogLevelFlags log_level;
- GLogFunc log_func;
- gpointer data;
- GLogHandler *next;
-};
-
-
-/* --- variables --- */
-static GMutex *g_messages_lock = NULL;
-static GLogDomain *g_log_domains = NULL;
-static GLogLevelFlags g_log_always_fatal = G_LOG_FATAL_MASK;
-static GPrintFunc glib_print_func = NULL;
-static GPrintFunc glib_printerr_func = NULL;
-static GPrivate *g_log_depth = NULL;
-static GLogLevelFlags g_log_msg_prefix = G_LOG_LEVEL_ERROR | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_DEBUG;
-static GLogFunc default_log_func = g_log_default_handler;
-static gpointer default_log_data = NULL;
-
-/* --- functions --- */
-#ifdef G_OS_WIN32
-# define STRICT
-# include <windows.h>
-# undef STRICT
-static gboolean win32_keep_fatal_message = FALSE;
-
-/* This default message will usually be overwritten. */
-/* Yes, a fixed size buffer is bad. So sue me. But g_error() is never
- * called with huge strings, is it?
- */
-static gchar fatal_msg_buf[1000] = "Unspecified fatal error encountered, aborting.";
-static gchar *fatal_msg_ptr = fatal_msg_buf;
-
-#undef write
-static inline int
-dowrite (int fd,
- const void *buf,
- unsigned int len)
-{
- if (win32_keep_fatal_message)
- {
- memcpy (fatal_msg_ptr, buf, len);
- fatal_msg_ptr += len;
- *fatal_msg_ptr = 0;
- return len;
- }
-
- write (fd, buf, len);
-
- return len;
-}
-#define write(fd, buf, len) dowrite(fd, buf, len)
-
-#endif
-
-static void
-write_string (int fd,
- const gchar *string)
-{
- write (fd, string, strlen (string));
-}
-
-static void
-g_messages_prefixed_init (void)
-{
- static gboolean initialized = FALSE;
-
- if (!initialized)
- {
- const gchar *val;
-
- initialized = TRUE;
- val = g_getenv ("G_MESSAGES_PREFIXED");
-
- if (val)
- {
- const GDebugKey keys[] = {
- { "error", G_LOG_LEVEL_ERROR },
- { "critical", G_LOG_LEVEL_CRITICAL },
- { "warning", G_LOG_LEVEL_WARNING },
- { "message", G_LOG_LEVEL_MESSAGE },
- { "info", G_LOG_LEVEL_INFO },
- { "debug", G_LOG_LEVEL_DEBUG }
- };
-
- g_log_msg_prefix = g_parse_debug_string (val, keys, G_N_ELEMENTS (keys));
- }
- }
-}
-
-static GLogDomain*
-g_log_find_domain_L (const gchar *log_domain)
-{
- register GLogDomain *domain;
-
- domain = g_log_domains;
- while (domain)
- {
- if (strcmp (domain->log_domain, log_domain) == 0)
- return domain;
- domain = domain->next;
- }
- return NULL;
-}
-
-static GLogDomain*
-g_log_domain_new_L (const gchar *log_domain)
-{
- register GLogDomain *domain;
-
- domain = g_new (GLogDomain, 1);
- domain->log_domain = g_strdup (log_domain);
- domain->fatal_mask = G_LOG_FATAL_MASK;
- domain->handlers = NULL;
-
- domain->next = g_log_domains;
- g_log_domains = domain;
-
- return domain;
-}
-
-static void
-g_log_domain_check_free_L (GLogDomain *domain)
-{
- if (domain->fatal_mask == G_LOG_FATAL_MASK &&
- domain->handlers == NULL)
- {
- register GLogDomain *last, *work;
-
- last = NULL;
-
- work = g_log_domains;
- while (work)
- {
- if (work == domain)
- {
- if (last)
- last->next = domain->next;
- else
- g_log_domains = domain->next;
- g_free (domain->log_domain);
- g_free (domain);
- break;
- }
- last = work;
- work = last->next;
- }
- }
-}
-
-static GLogFunc
-g_log_domain_get_handler_L (GLogDomain *domain,
- GLogLevelFlags log_level,
- gpointer *data)
-{
- if (domain && log_level)
- {
- register GLogHandler *handler;
-
- handler = domain->handlers;
- while (handler)
- {
- if ((handler->log_level & log_level) == log_level)
- {
- *data = handler->data;
- return handler->log_func;
- }
- handler = handler->next;
- }
- }
-
- *data = default_log_data;
- return default_log_func;
-}
-
-GLogLevelFlags
-g_log_set_always_fatal (GLogLevelFlags fatal_mask)
-{
- GLogLevelFlags old_mask;
-
- /* restrict the global mask to levels that are known to glib
- * since this setting applies to all domains
- */
- fatal_mask &= (1 << G_LOG_LEVEL_USER_SHIFT) - 1;
- /* force errors to be fatal */
- fatal_mask |= G_LOG_LEVEL_ERROR;
- /* remove bogus flag */
- fatal_mask &= ~G_LOG_FLAG_FATAL;
-
- g_mutex_lock (g_messages_lock);
- old_mask = g_log_always_fatal;
- g_log_always_fatal = fatal_mask;
- g_mutex_unlock (g_messages_lock);
-
- return old_mask;
-}
-
-GLogLevelFlags
-g_log_set_fatal_mask (const gchar *log_domain,
- GLogLevelFlags fatal_mask)
-{
- GLogLevelFlags old_flags;
- register GLogDomain *domain;
-
- if (!log_domain)
- log_domain = "";
-
- /* force errors to be fatal */
- fatal_mask |= G_LOG_LEVEL_ERROR;
- /* remove bogus flag */
- fatal_mask &= ~G_LOG_FLAG_FATAL;
-
- g_mutex_lock (g_messages_lock);
-
- domain = g_log_find_domain_L (log_domain);
- if (!domain)
- domain = g_log_domain_new_L (log_domain);
- old_flags = domain->fatal_mask;
-
- domain->fatal_mask = fatal_mask;
- g_log_domain_check_free_L (domain);
-
- g_mutex_unlock (g_messages_lock);
-
- return old_flags;
-}
-
-guint
-g_log_set_handler (const gchar *log_domain,
- GLogLevelFlags log_levels,
- GLogFunc log_func,
- gpointer user_data)
-{
- static guint handler_id = 0;
- GLogDomain *domain;
- GLogHandler *handler;
-
- g_return_val_if_fail ((log_levels & G_LOG_LEVEL_MASK) != 0, 0);
- g_return_val_if_fail (log_func != NULL, 0);
-
- if (!log_domain)
- log_domain = "";
-
- handler = g_new (GLogHandler, 1);
-
- g_mutex_lock (g_messages_lock);
-
- domain = g_log_find_domain_L (log_domain);
- if (!domain)
- domain = g_log_domain_new_L (log_domain);
-
- handler->id = ++handler_id;
- handler->log_level = log_levels;
- handler->log_func = log_func;
- handler->data = user_data;
- handler->next = domain->handlers;
- domain->handlers = handler;
-
- g_mutex_unlock (g_messages_lock);
-
- return handler_id;
-}
-
-GLogFunc
-g_log_set_default_handler (GLogFunc log_func,
- gpointer user_data)
-{
- GLogFunc old_log_func;
-
- g_mutex_lock (g_messages_lock);
- old_log_func = default_log_func;
- default_log_func = log_func;
- default_log_data = user_data;
- g_mutex_unlock (g_messages_lock);
-
- return old_log_func;
-}
-
-void
-g_log_remove_handler (const gchar *log_domain,
- guint handler_id)
-{
- register GLogDomain *domain;
-
- g_return_if_fail (handler_id > 0);
-
- if (!log_domain)
- log_domain = "";
-
- g_mutex_lock (g_messages_lock);
- domain = g_log_find_domain_L (log_domain);
- if (domain)
- {
- GLogHandler *work, *last;
-
- last = NULL;
- work = domain->handlers;
- while (work)
- {
- if (work->id == handler_id)
- {
- if (last)
- last->next = work->next;
- else
- domain->handlers = work->next;
- g_log_domain_check_free_L (domain);
- g_mutex_unlock (g_messages_lock);
- g_free (work);
- return;
- }
- last = work;
- work = last->next;
- }
- }
- g_mutex_unlock (g_messages_lock);
- g_warning ("%s: could not find handler with id `%d' for domain \"%s\"",
- G_STRLOC, handler_id, log_domain);
-}
-
-void
-g_logv (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *format,
- va_list args1)
-{
- gboolean was_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
- gboolean was_recursion = (log_level & G_LOG_FLAG_RECURSION) != 0;
- gint i;
-
- log_level &= G_LOG_LEVEL_MASK;
- if (!log_level)
- return;
-
- for (i = g_bit_nth_msf (log_level, -1); i >= 0; i = g_bit_nth_msf (log_level, i))
- {
- register GLogLevelFlags test_level;
-
- test_level = 1 << i;
- if (log_level & test_level)
- {
- guint depth = GPOINTER_TO_UINT (g_private_get (g_log_depth));
- GLogDomain *domain;
- GLogFunc log_func;
- GLogLevelFlags domain_fatal_mask;
- gpointer data = NULL;
-
- if (was_fatal)
- test_level |= G_LOG_FLAG_FATAL;
- if (was_recursion)
- test_level |= G_LOG_FLAG_RECURSION;
-
- /* check recursion and lookup handler */
- g_mutex_lock (g_messages_lock);
- domain = g_log_find_domain_L (log_domain ? log_domain : "");
- if (depth)
- test_level |= G_LOG_FLAG_RECURSION;
- depth++;
- domain_fatal_mask = domain ? domain->fatal_mask : G_LOG_FATAL_MASK;
- if ((domain_fatal_mask | g_log_always_fatal) & test_level)
- test_level |= G_LOG_FLAG_FATAL;
- if (test_level & G_LOG_FLAG_RECURSION)
- log_func = _g_log_fallback_handler;
- else
- log_func = g_log_domain_get_handler_L (domain, test_level, &data);
- domain = NULL;
- g_mutex_unlock (g_messages_lock);
-
- g_private_set (g_log_depth, GUINT_TO_POINTER (depth));
-
- /* had to defer debug initialization until we can keep track of recursion */
- if (!(test_level & G_LOG_FLAG_RECURSION) && !_g_debug_initialized)
- {
- GLogLevelFlags orig_test_level = test_level;
-
- _g_debug_init ();
- if ((domain_fatal_mask | g_log_always_fatal) & test_level)
- test_level |= G_LOG_FLAG_FATAL;
- if (test_level != orig_test_level)
- {
- /* need a relookup, not nice, but not too bad either */
- g_mutex_lock (g_messages_lock);
- domain = g_log_find_domain_L (log_domain ? log_domain : "");
- log_func = g_log_domain_get_handler_L (domain, test_level, &data);
- domain = NULL;
- g_mutex_unlock (g_messages_lock);
- }
- }
-
- if (test_level & G_LOG_FLAG_RECURSION)
- {
- /* we use a stack buffer of fixed size, since we're likely
- * in an out-of-memory situation
- */
- gchar buffer[1025];
- gint size;
- size = _g_vsnprintf (buffer, 1024, format, args1);
-
- log_func (log_domain, test_level, buffer, data);
- }
- else
- {
- gchar *msg = g_strdup_vprintf (format, args1);
-
- log_func (log_domain, test_level, msg, data);
-
- g_free (msg);
- }
-
- if (test_level & G_LOG_FLAG_FATAL)
- {
-#ifdef G_OS_WIN32
- gchar *locale_msg = g_locale_from_utf8 (fatal_msg_buf, -1, NULL, NULL, NULL);
-
- MessageBox (NULL, locale_msg, NULL,
- MB_ICONERROR|MB_SETFOREGROUND);
- if (IsDebuggerPresent () && !(test_level & G_LOG_FLAG_RECURSION))
- G_BREAKPOINT ();
- else
- abort ();
-#else
-#if defined (G_ENABLE_DEBUG) && defined (SIGTRAP)
- if (!(test_level & G_LOG_FLAG_RECURSION))
- G_BREAKPOINT ();
- else
- abort ();
-#else /* !G_ENABLE_DEBUG || !SIGTRAP */
- abort ();
-#endif /* !G_ENABLE_DEBUG || !SIGTRAP */
-#endif /* !G_OS_WIN32 */
- }
-
- depth--;
- g_private_set (g_log_depth, GUINT_TO_POINTER (depth));
- }
- }
-}
-
-void
-g_log (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *format,
- ...)
-{
- va_list args;
-
- va_start (args, format);
- g_logv (log_domain, log_level, format, args);
- va_end (args);
-}
-
-void
-g_return_if_fail_warning (const char *log_domain,
- const char *pretty_function,
- const char *expression)
-{
- /*
- * Omit the prefix used by the PLT-reduction
- * technique used in GTK+.
- */
- if (g_str_has_prefix (pretty_function, "IA__"))
- pretty_function += 4;
- g_log (log_domain,
- G_LOG_LEVEL_CRITICAL,
- "%s: assertion `%s' failed",
- pretty_function,
- expression);
-}
-
-void
-g_warn_message (const char *domain,
- const char *file,
- int line,
- const char *func,
- const char *warnexpr)
-{
- char *s, lstr[32];
- g_snprintf (lstr, 32, "%d", line);
- if (warnexpr)
- s = g_strconcat ("(", file, ":", lstr, "):",
- func, func[0] ? ":" : "",
- " runtime check failed: (", warnexpr, ")", NULL);
- else
- s = g_strconcat ("(", file, ":", lstr, "):",
- func, func[0] ? ":" : "",
- " ", "code should not be reached", NULL);
- g_log (domain, G_LOG_LEVEL_WARNING, "%s", s);
- g_free (s);
-}
-
-void
-g_assert_warning (const char *log_domain,
- const char *file,
- const int line,
- const char *pretty_function,
- const char *expression)
-{
- /*
- * Omit the prefix used by the PLT-reduction
- * technique used in GTK+.
- */
- if (g_str_has_prefix (pretty_function, "IA__"))
- pretty_function += 4;
- g_log (log_domain,
- G_LOG_LEVEL_ERROR,
- expression
- ? "file %s: line %d (%s): assertion failed: (%s)"
- : "file %s: line %d (%s): should not be reached",
- file,
- line,
- pretty_function,
- expression);
- abort ();
-}
-
-#define CHAR_IS_SAFE(wc) (!((wc < 0x20 && wc != '\t' && wc != '\n' && wc != '\r') || \
- (wc == 0x7f) || \
- (wc >= 0x80 && wc < 0xa0)))
-
-static gchar*
-strdup_convert (const gchar *string,
- const gchar *charset)
-{
- if (!g_utf8_validate (string, -1, NULL))
- {
- GString *gstring = g_string_new ("[Invalid UTF-8] ");
- guchar *p;
-
- for (p = (guchar *)string; *p; p++)
- {
- if (CHAR_IS_SAFE(*p) &&
- !(*p == '\r' && *(p + 1) != '\n') &&
- *p < 0x80)
- g_string_append_c (gstring, *p);
- else
- g_string_append_printf (gstring, "\\x%02x", (guint)(guchar)*p);
- }
-
- return g_string_free (gstring, FALSE);
- }
- else
- {
- GError *err = NULL;
-
- gchar *result = g_convert_with_fallback (string, -1, charset, "UTF-8", "?", NULL, NULL, &err);
- if (result)
- return result;
- else
- {
- /* Not thread-safe, but doesn't matter if we print the warning twice
- */
- static gboolean warned = FALSE;
- if (!warned)
- {
- warned = TRUE;
- _g_fprintf (stderr, "GLib: Cannot convert message: %s\n", err->message);
- }
- g_error_free (err);
-
- return g_strdup (string);
- }
- }
-}
-
-/* For a radix of 8 we need at most 3 output bytes for 1 input
- * byte. Additionally we might need up to 2 output bytes for the
- * readix prefix and 1 byte for the trailing NULL.
- */
-#define FORMAT_UNSIGNED_BUFSIZE ((GLIB_SIZEOF_LONG * 3) + 3)
-
-static void
-format_unsigned (gchar *buf,
- gulong num,
- guint radix)
-{
- gulong tmp;
- gchar c;
- gint i, n;
-
- /* we may not call _any_ GLib functions here (or macros like g_return_if_fail()) */
-
- if (radix != 8 && radix != 10 && radix != 16)
- {
- *buf = '\000';
- return;
- }
-
- if (!num)
- {
- *buf++ = '0';
- *buf = '\000';
- return;
- }
-
- if (radix == 16)
- {
- *buf++ = '0';
- *buf++ = 'x';
- }
- else if (radix == 8)
- {
- *buf++ = '0';
- }
-
- n = 0;
- tmp = num;
- while (tmp)
- {
- tmp /= radix;
- n++;
- }
-
- i = n;
-
- /* Again we can't use g_assert; actually this check should _never_ fail. */
- if (n > FORMAT_UNSIGNED_BUFSIZE - 3)
- {
- *buf = '\000';
- return;
- }
-
- while (num)
- {
- i--;
- c = (num % radix);
- if (c < 10)
- buf[i] = c + '0';
- else
- buf[i] = c + 'a' - 10;
- num /= radix;
- }
-
- buf[n] = '\000';
-}
-
-/* string size big enough to hold level prefix */
-#define STRING_BUFFER_SIZE (FORMAT_UNSIGNED_BUFSIZE + 32)
-
-#define ALERT_LEVELS (G_LOG_LEVEL_ERROR | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING)
-
-static int
-mklevel_prefix (gchar level_prefix[STRING_BUFFER_SIZE],
- GLogLevelFlags log_level)
-{
- gboolean to_stdout = TRUE;
-
- /* we may not call _any_ GLib functions here */
-
- switch (log_level & G_LOG_LEVEL_MASK)
- {
- case G_LOG_LEVEL_ERROR:
- strcpy (level_prefix, "ERROR");
- to_stdout = FALSE;
- break;
- case G_LOG_LEVEL_CRITICAL:
- strcpy (level_prefix, "CRITICAL");
- to_stdout = FALSE;
- break;
- case G_LOG_LEVEL_WARNING:
- strcpy (level_prefix, "WARNING");
- to_stdout = FALSE;
- break;
- case G_LOG_LEVEL_MESSAGE:
- strcpy (level_prefix, "Message");
- to_stdout = FALSE;
- break;
- case G_LOG_LEVEL_INFO:
- strcpy (level_prefix, "INFO");
- break;
- case G_LOG_LEVEL_DEBUG:
- strcpy (level_prefix, "DEBUG");
- break;
- default:
- if (log_level)
- {
- strcpy (level_prefix, "LOG-");
- format_unsigned (level_prefix + 4, log_level & G_LOG_LEVEL_MASK, 16);
- }
- else
- strcpy (level_prefix, "LOG");
- break;
- }
- if (log_level & G_LOG_FLAG_RECURSION)
- strcat (level_prefix, " (recursed)");
- if (log_level & ALERT_LEVELS)
- strcat (level_prefix, " **");
-
-#ifdef G_OS_WIN32
- win32_keep_fatal_message = (log_level & G_LOG_FLAG_FATAL) != 0;
-#endif
- return to_stdout ? 1 : 2;
-}
-
-void
-_g_log_fallback_handler (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer unused_data)
-{
- gchar level_prefix[STRING_BUFFER_SIZE];
-#ifndef G_OS_WIN32
- gchar pid_string[FORMAT_UNSIGNED_BUFSIZE];
-#endif
- gboolean is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
- int fd;
-
- /* we can not call _any_ GLib functions in this fallback handler,
- * which is why we skip UTF-8 conversion, etc.
- * since we either recursed or ran out of memory, we're in a pretty
- * pathologic situation anyways, what we can do is giving the
- * the process ID unconditionally however.
- */
-
- fd = mklevel_prefix (level_prefix, log_level);
- if (!message)
- message = "(NULL) message";
-
-#ifndef G_OS_WIN32
- format_unsigned (pid_string, getpid (), 10);
-#endif
-
- if (log_domain)
- write_string (fd, "\n");
- else
- write_string (fd, "\n** ");
-
-#ifndef G_OS_WIN32
- write_string (fd, "(process:");
- write_string (fd, pid_string);
- write_string (fd, "): ");
-#endif
-
- if (log_domain)
- {
- write_string (fd, log_domain);
- write_string (fd, "-");
- }
- write_string (fd, level_prefix);
- write_string (fd, ": ");
- write_string (fd, message);
- if (is_fatal)
- write_string (fd, "\naborting...\n");
- else
- write_string (fd, "\n");
-}
-
-static void
-escape_string (GString *string)
-{
- const char *p = string->str;
- gunichar wc;
-
- while (p < string->str + string->len)
- {
- gboolean safe;
-
- wc = g_utf8_get_char_validated (p, -1);
- if (wc == (gunichar)-1 || wc == (gunichar)-2)
- {
- gchar *tmp;
- guint pos;
-
- pos = p - string->str;
-
- /* Emit invalid UTF-8 as hex escapes
- */
- tmp = g_strdup_printf ("\\x%02x", (guint)(guchar)*p);
- g_string_erase (string, pos, 1);
- g_string_insert (string, pos, tmp);
-
- p = string->str + (pos + 4); /* Skip over escape sequence */
-
- g_free (tmp);
- continue;
- }
- if (wc == '\r')
- {
- safe = *(p + 1) == '\n';
- }
- else
- {
- safe = CHAR_IS_SAFE (wc);
- }
-
- if (!safe)
- {
- gchar *tmp;
- guint pos;
-
- pos = p - string->str;
-
- /* Largest char we escape is 0x0a, so we don't have to worry
- * about 8-digit \Uxxxxyyyy
- */
- tmp = g_strdup_printf ("\\u%04x", wc);
- g_string_erase (string, pos, g_utf8_next_char (p) - p);
- g_string_insert (string, pos, tmp);
- g_free (tmp);
-
- p = string->str + (pos + 6); /* Skip over escape sequence */
- }
- else
- p = g_utf8_next_char (p);
- }
-}
-
-void
-g_log_default_handler (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer unused_data)
-{
- gboolean is_fatal = (log_level & G_LOG_FLAG_FATAL) != 0;
- gchar level_prefix[STRING_BUFFER_SIZE], *string;
- GString *gstring;
- int fd;
-
- /* we can be called externally with recursion for whatever reason */
- if (log_level & G_LOG_FLAG_RECURSION)
- {
- _g_log_fallback_handler (log_domain, log_level, message, unused_data);
- return;
- }
-
- g_messages_prefixed_init ();
-
- fd = mklevel_prefix (level_prefix, log_level);
-
- gstring = g_string_new (NULL);
- if (log_level & ALERT_LEVELS)
- g_string_append (gstring, "\n");
- if (!log_domain)
- g_string_append (gstring, "** ");
-
- if ((g_log_msg_prefix & log_level) == log_level)
- {
- const gchar *prg_name = g_get_prgname ();
-
- if (!prg_name)
- g_string_append_printf (gstring, "(process:%lu): ", (gulong)getpid ());
- else
- g_string_append_printf (gstring, "(%s:%lu): ", prg_name, (gulong)getpid ());
- }
-
- if (log_domain)
- {
- g_string_append (gstring, log_domain);
- g_string_append_c (gstring, '-');
- }
- g_string_append (gstring, level_prefix);
-
- g_string_append (gstring, ": ");
- if (!message)
- g_string_append (gstring, "(NULL) message");
- else
- {
- GString *msg;
- const gchar *charset;
-
- msg = g_string_new (message);
- escape_string (msg);
-
- if (g_get_charset (&charset))
- g_string_append (gstring, msg->str); /* charset is UTF-8 already */
- else
- {
- string = strdup_convert (msg->str, charset);
- g_string_append (gstring, string);
- g_free (string);
- }
-
- g_string_free (msg, TRUE);
- }
- if (is_fatal)
- g_string_append (gstring, "\naborting...\n");
- else
- g_string_append (gstring, "\n");
-
- string = g_string_free (gstring, FALSE);
-
- write_string (fd, string);
- g_free (string);
-}
-
-GPrintFunc
-g_set_print_handler (GPrintFunc func)
-{
- GPrintFunc old_print_func;
-
- g_mutex_lock (g_messages_lock);
- old_print_func = glib_print_func;
- glib_print_func = func;
- g_mutex_unlock (g_messages_lock);
-
- return old_print_func;
-}
-
-void
-g_print (const gchar *format,
- ...)
-{
- va_list args;
- gchar *string;
- GPrintFunc local_glib_print_func;
-
- g_return_if_fail (format != NULL);
-
- va_start (args, format);
- string = g_strdup_vprintf (format, args);
- va_end (args);
-
- g_mutex_lock (g_messages_lock);
- local_glib_print_func = glib_print_func;
- g_mutex_unlock (g_messages_lock);
-
- if (local_glib_print_func)
- local_glib_print_func (string);
- else
- {
- const gchar *charset;
-
- if (g_get_charset (&charset))
- fputs (string, stdout); /* charset is UTF-8 already */
- else
- {
- gchar *lstring = strdup_convert (string, charset);
-
- fputs (lstring, stdout);
- g_free (lstring);
- }
- fflush (stdout);
- }
- g_free (string);
-}
-
-GPrintFunc
-g_set_printerr_handler (GPrintFunc func)
-{
- GPrintFunc old_printerr_func;
-
- g_mutex_lock (g_messages_lock);
- old_printerr_func = glib_printerr_func;
- glib_printerr_func = func;
- g_mutex_unlock (g_messages_lock);
-
- return old_printerr_func;
-}
-
-void
-g_printerr (const gchar *format,
- ...)
-{
- va_list args;
- gchar *string;
- GPrintFunc local_glib_printerr_func;
-
- g_return_if_fail (format != NULL);
-
- va_start (args, format);
- string = g_strdup_vprintf (format, args);
- va_end (args);
-
- g_mutex_lock (g_messages_lock);
- local_glib_printerr_func = glib_printerr_func;
- g_mutex_unlock (g_messages_lock);
-
- if (local_glib_printerr_func)
- local_glib_printerr_func (string);
- else
- {
- const gchar *charset;
-
- if (g_get_charset (&charset))
- fputs (string, stderr); /* charset is UTF-8 already */
- else
- {
- gchar *lstring = strdup_convert (string, charset);
-
- fputs (lstring, stderr);
- g_free (lstring);
- }
- fflush (stderr);
- }
- g_free (string);
-}
-
-#endif /* NOT_NEEDED_FOR_NAVIT */
-gsize
-g_printf_string_upper_bound (const gchar *format,
- va_list args)
-{
-#ifdef HAVE_API_WIN32_BASE
- gchar c[16384];
- return _g_vsnprintf (c, 16384, format, args) + 1;
-#else
- gchar c;
- return _g_vsnprintf (&c, 1, format, args) + 1;
-#endif
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-void
-_g_messages_thread_init_nomessage (void)
-{
- g_messages_lock = g_mutex_new ();
- g_log_depth = g_private_new (NULL);
- g_messages_prefixed_init ();
- _g_debug_init ();
-}
-
-gboolean _g_debug_initialized = FALSE;
-guint _g_debug_flags = 0;
-
-void
-_g_debug_init (void)
-{
- const gchar *val;
-
- _g_debug_initialized = TRUE;
-
- val = g_getenv ("G_DEBUG");
- if (val != NULL)
- {
- const GDebugKey keys[] = {
- {"fatal_warnings", G_DEBUG_FATAL_WARNINGS},
- {"fatal_criticals", G_DEBUG_FATAL_CRITICALS}
- };
-
- _g_debug_flags = g_parse_debug_string (val, keys, G_N_ELEMENTS (keys));
- }
-
- if (_g_debug_flags & G_DEBUG_FATAL_WARNINGS)
- {
- GLogLevelFlags fatal_mask;
-
- fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
- fatal_mask |= G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL;
- g_log_set_always_fatal (fatal_mask);
- }
-
- if (_g_debug_flags & G_DEBUG_FATAL_CRITICALS)
- {
- GLogLevelFlags fatal_mask;
-
- fatal_mask = g_log_set_always_fatal (G_LOG_FATAL_MASK);
- fatal_mask |= G_LOG_LEVEL_CRITICAL;
- g_log_set_always_fatal (fatal_mask);
- }
-}
-#endif /* NOT_NEEDED_FOR_NAVIT */
-
-#define __G_MESSAGES_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gmessages.h b/navit/support/glib/gmessages.h
deleted file mode 100644
index af5a826f8..000000000
--- a/navit/support/glib/gmessages.h
+++ /dev/null
@@ -1,341 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_MESSAGES_H__
-#define __G_MESSAGES_H__
-
-#include <stdarg.h>
-#include <glib/gtypes.h>
-#include <glib/gmacros.h>
-
-/* Suppress warnings when GCC is in -pedantic mode and not -std=c99
- */
-#if (__GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96))
-#pragma GCC system_header
-#endif
-
-G_BEGIN_DECLS
-
-/* calculate a string size, guaranteed to fit format + args.
- */
-gsize g_printf_string_upper_bound (const gchar* format,
- va_list args);
-
-/* Log level shift offset for user defined
- * log levels (0-7 are used by GLib).
- */
-#define G_LOG_LEVEL_USER_SHIFT (8)
-
-/* Glib log levels and flags.
- */
-typedef enum
-{
- /* log flags */
- G_LOG_FLAG_RECURSION = 1 << 0,
- G_LOG_FLAG_FATAL = 1 << 1,
-
- /* GLib log levels */
- G_LOG_LEVEL_ERROR = 1 << 2, /* always fatal */
- G_LOG_LEVEL_CRITICAL = 1 << 3,
- G_LOG_LEVEL_WARNING = 1 << 4,
- G_LOG_LEVEL_MESSAGE = 1 << 5,
- G_LOG_LEVEL_INFO = 1 << 6,
- G_LOG_LEVEL_DEBUG = 1 << 7,
-
- G_LOG_LEVEL_MASK = ~(G_LOG_FLAG_RECURSION | G_LOG_FLAG_FATAL)
-} GLogLevelFlags;
-
-/* GLib log levels that are considered fatal by default */
-#define G_LOG_FATAL_MASK (G_LOG_FLAG_RECURSION | G_LOG_LEVEL_ERROR)
-
-typedef void (*GLogFunc) (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer user_data);
-
-/* Logging mechanism
- */
-guint g_log_set_handler (const gchar *log_domain,
- GLogLevelFlags log_levels,
- GLogFunc log_func,
- gpointer user_data);
-void g_log_remove_handler (const gchar *log_domain,
- guint handler_id);
-void g_log_default_handler (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer unused_data);
-GLogFunc g_log_set_default_handler (GLogFunc log_func,
- gpointer user_data);
-void g_log (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *format,
- ...) G_GNUC_PRINTF (3, 4);
-void g_logv (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *format,
- va_list args);
-GLogLevelFlags g_log_set_fatal_mask (const gchar *log_domain,
- GLogLevelFlags fatal_mask);
-GLogLevelFlags g_log_set_always_fatal (GLogLevelFlags fatal_mask);
-
-/* internal */
-G_GNUC_INTERNAL void _g_log_fallback_handler (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer unused_data);
-
-/* Internal functions, used to implement the following macros */
-void g_return_if_fail_warning (const char *log_domain,
- const char *pretty_function,
- const char *expression);
-void g_warn_message (const char *domain,
- const char *file,
- int line,
- const char *func,
- const char *warnexpr);
-#ifndef G_DISABLE_DEPRECATED
-void g_assert_warning (const char *log_domain,
- const char *file,
- const int line,
- const char *pretty_function,
- const char *expression) G_GNUC_NORETURN;
-#endif /* !G_DISABLE_DEPRECATED */
-
-
-#ifndef G_LOG_DOMAIN
-#define G_LOG_DOMAIN ((gchar*) 0)
-#endif /* G_LOG_DOMAIN */
-#ifdef G_HAVE_ISO_VARARGS
-/* for(;;); so that GCC knows that control doesn't go past g_error() */
-#define g_error(...) G_STMT_START { \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_ERROR, \
- __VA_ARGS__); \
- for (;;); \
- } G_STMT_END
-
-#define g_message(...) g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_MESSAGE, \
- __VA_ARGS__)
-#define g_critical(...) g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_CRITICAL, \
- __VA_ARGS__)
-#define g_warning(...) g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_WARNING, \
- __VA_ARGS__)
-#define g_debug(...) g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_DEBUG, \
- __VA_ARGS__)
-#elif defined(G_HAVE_GNUC_VARARGS)
-#define g_error(format...) G_STMT_START { \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_ERROR, \
- format); \
- for (;;); \
- } G_STMT_END
-
-#define g_message(format...) g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_MESSAGE, \
- format)
-#define g_critical(format...) g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_CRITICAL, \
- format)
-#define g_warning(format...) g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_WARNING, \
- format)
-#define g_debug(format...) g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_DEBUG, \
- format)
-#else /* no varargs macros */
-static void
-g_error (const gchar *format,
- ...)
-{
- va_list args;
- va_start (args, format);
- g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, args);
- va_end (args);
-
- for(;;);
-}
-static void
-g_message (const gchar *format,
- ...)
-{
- va_list args;
- va_start (args, format);
- g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_MESSAGE, format, args);
- va_end (args);
-}
-static void
-g_critical (const gchar *format,
- ...)
-{
- va_list args;
- va_start (args, format);
- g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, args);
- va_end (args);
-}
-static void
-g_warning (const gchar *format,
- ...)
-{
- va_list args;
- va_start (args, format);
- g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, args);
- va_end (args);
-}
-static void
-g_debug (const gchar *format,
- ...)
-{
- va_list args;
- va_start (args, format);
- g_logv (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, args);
- va_end (args);
-}
-#endif /* !__GNUC__ */
-
-typedef void (*GPrintFunc) (const gchar *string);
-void g_print (const gchar *format,
- ...) G_GNUC_PRINTF (1, 2);
-GPrintFunc g_set_print_handler (GPrintFunc func);
-void g_printerr (const gchar *format,
- ...) G_GNUC_PRINTF (1, 2);
-GPrintFunc g_set_printerr_handler (GPrintFunc func);
-
-
-/* Provide macros for graceful error handling.
- * The "return" macros will return from the current function.
- * Two different definitions are given for the macros in
- * order to support gcc's __PRETTY_FUNCTION__ capability.
- */
-
-#define g_warn_if_reached() do { g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, NULL); } while (0)
-#define g_warn_if_fail(expr) do { if G_LIKELY (expr) ; else \
- g_warn_message (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, #expr); } while (0)
-
-#ifdef G_DISABLE_CHECKS
-
-#define g_return_if_fail(expr) G_STMT_START{ (void)0; }G_STMT_END
-#define g_return_val_if_fail(expr,val) G_STMT_START{ (void)0; }G_STMT_END
-#define g_return_if_reached() G_STMT_START{ return; }G_STMT_END
-#define g_return_val_if_reached(val) G_STMT_START{ return (val); }G_STMT_END
-
-#else /* !G_DISABLE_CHECKS */
-
-#ifdef __GNUC__
-
-#define g_return_if_fail(expr) G_STMT_START{ \
- if G_LIKELY(expr) { } else \
- { \
- g_return_if_fail_warning (G_LOG_DOMAIN, \
- __PRETTY_FUNCTION__, \
- #expr); \
- return; \
- }; }G_STMT_END
-
-#define g_return_val_if_fail(expr,val) G_STMT_START{ \
- if G_LIKELY(expr) { } else \
- { \
- g_return_if_fail_warning (G_LOG_DOMAIN, \
- __PRETTY_FUNCTION__, \
- #expr); \
- return (val); \
- }; }G_STMT_END
-
-#define g_return_if_reached() G_STMT_START{ \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_CRITICAL, \
- "file %s: line %d (%s): should not be reached", \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__); \
- return; }G_STMT_END
-
-#define g_return_val_if_reached(val) G_STMT_START{ \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_CRITICAL, \
- "file %s: line %d (%s): should not be reached", \
- __FILE__, \
- __LINE__, \
- __PRETTY_FUNCTION__); \
- return (val); }G_STMT_END
-
-#else /* !__GNUC__ */
-
-#define g_return_if_fail(expr) G_STMT_START{ \
- if (expr) { } else \
- { \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_CRITICAL, \
- "file %s: line %d: assertion `%s' failed", \
- __FILE__, \
- __LINE__, \
- #expr); \
- return; \
- }; }G_STMT_END
-
-#define g_return_val_if_fail(expr, val) G_STMT_START{ \
- if (expr) { } else \
- { \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_CRITICAL, \
- "file %s: line %d: assertion `%s' failed", \
- __FILE__, \
- __LINE__, \
- #expr); \
- return (val); \
- }; }G_STMT_END
-
-#define g_return_if_reached() G_STMT_START{ \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_CRITICAL, \
- "file %s: line %d: should not be reached", \
- __FILE__, \
- __LINE__); \
- return; }G_STMT_END
-
-#define g_return_val_if_reached(val) G_STMT_START{ \
- g_log (G_LOG_DOMAIN, \
- G_LOG_LEVEL_CRITICAL, \
- "file %s: line %d: should not be reached", \
- __FILE__, \
- __LINE__); \
- return (val); }G_STMT_END
-
-#endif /* !__GNUC__ */
-
-#endif /* !G_DISABLE_CHECKS */
-
-G_END_DECLS
-
-#endif /* __G_MESSAGES_H__ */
diff --git a/navit/support/glib/gprimes.c b/navit/support/glib/gprimes.c
deleted file mode 100644
index 7beca710c..000000000
--- a/navit/support/glib/gprimes.c
+++ /dev/null
@@ -1,90 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * MT safe
- */
-
-#include "config.h"
-
-#include "glib.h"
-#include "galias.h"
-
-
-static const guint g_primes[] =
-{
- 11,
- 19,
- 37,
- 73,
- 109,
- 163,
- 251,
- 367,
- 557,
- 823,
- 1237,
- 1861,
- 2777,
- 4177,
- 6247,
- 9371,
- 14057,
- 21089,
- 31627,
- 47431,
- 71143,
- 106721,
- 160073,
- 240101,
- 360163,
- 540217,
- 810343,
- 1215497,
- 1823231,
- 2734867,
- 4102283,
- 6153409,
- 9230113,
- 13845163,
-};
-
-static const guint g_nprimes = sizeof (g_primes) / sizeof (g_primes[0]);
-
-guint
-g_spaced_primes_closest (guint num)
-{
- gint i;
-
- for (i = 0; i < g_nprimes; i++)
- if (g_primes[i] > num)
- return g_primes[i];
-
- return g_primes[g_nprimes - 1];
-}
-
-#define __G_PRIMES_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gprintf.c b/navit/support/glib/gprintf.c
deleted file mode 100644
index 6cbb214d5..000000000
--- a/navit/support/glib/gprintf.c
+++ /dev/null
@@ -1,342 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997, 2002 Peter Mattis, Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#define _GNU_SOURCE /* For vasprintf */
-
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "glib.h"
-#include "gprintf.h"
-#include "gprintfint.h"
-
-#include "galias.h"
-
-/**
- * g_printf:
- * @format: a standard printf() format string, but notice
- * <link linkend="string-precision">string precision pitfalls</link>.
- * @Varargs: the arguments to insert in the output.
- *
- * An implementation of the standard printf() function which supports
- * positional parameters, as specified in the Single Unix Specification.
- *
- * Returns: the number of bytes printed.
- *
- * Since: 2.2
- **/
-gint
-g_printf (gchar const *format,
- ...)
-{
- va_list args;
- gint retval;
-
- va_start (args, format);
- retval = g_vprintf (format, args);
- va_end (args);
-
- return retval;
-}
-
-/**
- * g_fprintf:
- * @file: the stream to write to.
- * @format: a standard printf() format string, but notice
- * <link linkend="string-precision">string precision pitfalls</link>.
- * @Varargs: the arguments to insert in the output.
- *
- * An implementation of the standard fprintf() function which supports
- * positional parameters, as specified in the Single Unix Specification.
- *
- * Returns: the number of bytes printed.
- *
- * Since: 2.2
- **/
-gint
-g_fprintf (FILE *file,
- gchar const *format,
- ...)
-{
- va_list args;
- gint retval;
-
- va_start (args, format);
- retval = g_vfprintf (file, format, args);
- va_end (args);
-
- return retval;
-}
-
-/**
- * g_sprintf:
- * @string: A pointer to a memory buffer to contain the resulting string. It
- * is up to the caller to ensure that the allocated buffer is large
- * enough to hold the formatted result
- * @format: a standard printf() format string, but notice
- * <link linkend="string-precision">string precision pitfalls</link>.
- * @Varargs: the arguments to insert in the output.
- *
- * An implementation of the standard sprintf() function which supports
- * positional parameters, as specified in the Single Unix Specification.
- *
- * Returns: the number of bytes printed.
- *
- * Since: 2.2
- **/
-gint
-g_sprintf (gchar *string,
- gchar const *format,
- ...)
-{
- va_list args;
- gint retval;
-
- va_start (args, format);
- retval = g_vsprintf (string, format, args);
- va_end (args);
-
- return retval;
-}
-
-/**
- * g_snprintf:
- * @string: the buffer to hold the output.
- * @n: the maximum number of bytes to produce (including the
- * terminating nul character).
- * @format: a standard printf() format string, but notice
- * <link linkend="string-precision">string precision pitfalls</link>.
- * @Varargs: the arguments to insert in the output.
- *
- * A safer form of the standard sprintf() function. The output is guaranteed
- * to not exceed @n characters (including the terminating nul character), so
- * it is easy to ensure that a buffer overflow cannot occur.
- *
- * See also g_strdup_printf().
- *
- * In versions of GLib prior to 1.2.3, this function may return -1 if the
- * output was truncated, and the truncated string may not be nul-terminated.
- * In versions prior to 1.3.12, this function returns the length of the output
- * string.
- *
- * The return value of g_snprintf() conforms to the snprintf()
- * function as standardized in ISO C99. Note that this is different from
- * traditional snprintf(), which returns the length of the output string.
- *
- * The format string may contain positional parameters, as specified in
- * the Single Unix Specification.
- *
- * Returns: the number of bytes which would be produced if the buffer
- * was large enough.
- **/
-gint
-g_snprintf (gchar *string,
- gulong n,
- gchar const *format,
- ...)
-{
- va_list args;
- gint retval;
-
- va_start (args, format);
- retval = g_vsnprintf (string, n, format, args);
- va_end (args);
-
- return retval;
-}
-
-/**
- * g_vprintf:
- * @format: a standard printf() format string, but notice
- * <link linkend="string-precision">string precision pitfalls</link>.
- * @args: the list of arguments to insert in the output.
- *
- * An implementation of the standard vprintf() function which supports
- * positional parameters, as specified in the Single Unix Specification.
- *
- * Returns: the number of bytes printed.
- *
- * Since: 2.2
- **/
-gint
-g_vprintf (gchar const *format,
- va_list args)
-{
- g_return_val_if_fail (format != NULL, -1);
-
- return _g_vprintf (format, args);
-}
-
-/**
- * g_vfprintf:
- * @file: the stream to write to.
- * @format: a standard printf() format string, but notice
- * <link linkend="string-precision">string precision pitfalls</link>.
- * @args: the list of arguments to insert in the output.
- *
- * An implementation of the standard fprintf() function which supports
- * positional parameters, as specified in the Single Unix Specification.
- *
- * Returns: the number of bytes printed.
- *
- * Since: 2.2
- **/
-gint
-g_vfprintf (FILE *file,
- gchar const *format,
- va_list args)
-{
- g_return_val_if_fail (format != NULL, -1);
-
- return _g_vfprintf (file, format, args);
-}
-
-/**
- * g_vsprintf:
- * @string: the buffer to hold the output.
- * @format: a standard printf() format string, but notice
- * <link linkend="string-precision">string precision pitfalls</link>.
- * @args: the list of arguments to insert in the output.
- *
- * An implementation of the standard vsprintf() function which supports
- * positional parameters, as specified in the Single Unix Specification.
- *
- * Returns: the number of bytes printed.
- *
- * Since: 2.2
- **/
-gint
-g_vsprintf (gchar *string,
- gchar const *format,
- va_list args)
-{
- g_return_val_if_fail (string != NULL, -1);
- g_return_val_if_fail (format != NULL, -1);
-
- return _g_vsprintf (string, format, args);
-}
-
-/**
- * g_vsnprintf:
- * @string: the buffer to hold the output.
- * @n: the maximum number of bytes to produce (including the
- * terminating nul character).
- * @format: a standard printf() format string, but notice
- * <link linkend="string-precision">string precision pitfalls</link>.
- * @args: the list of arguments to insert in the output.
- *
- * A safer form of the standard vsprintf() function. The output is guaranteed
- * to not exceed @n characters (including the terminating nul character), so
- * it is easy to ensure that a buffer overflow cannot occur.
- *
- * See also g_strdup_vprintf().
- *
- * In versions of GLib prior to 1.2.3, this function may return -1 if the
- * output was truncated, and the truncated string may not be nul-terminated.
- * In versions prior to 1.3.12, this function returns the length of the output
- * string.
- *
- * The return value of g_vsnprintf() conforms to the vsnprintf() function
- * as standardized in ISO C99. Note that this is different from traditional
- * vsnprintf(), which returns the length of the output string.
- *
- * The format string may contain positional parameters, as specified in
- * the Single Unix Specification.
- *
- * Returns: the number of bytes which would be produced if the buffer
- * was large enough.
- */
-gint
-g_vsnprintf (gchar *string,
- gulong n,
- gchar const *format,
- va_list args)
-{
- g_return_val_if_fail (n == 0 || string != NULL, -1);
- g_return_val_if_fail (format != NULL, -1);
-
- return _g_vsnprintf (string, n, format, args);
-}
-
-/**
- * g_vasprintf:
- * @string: the return location for the newly-allocated string.
- * @format: a standard printf() format string, but notice
- * <link linkend="string-precision">string precision pitfalls</link>.
- * @args: the list of arguments to insert in the output.
- *
- * An implementation of the GNU vasprintf() function which supports
- * positional parameters, as specified in the Single Unix Specification.
- * This function is similar to g_vsprintf(), except that it allocates a
- * string to hold the output, instead of putting the output in a buffer
- * you allocate in advance.
- *
- * Returns: the number of bytes printed.
- *
- * Since: 2.4
- **/
-gint
-g_vasprintf (gchar **string,
- gchar const *format,
- va_list args)
-{
- gint len;
- g_return_val_if_fail (string != NULL, -1);
-
-#if !defined(HAVE_GOOD_PRINTF)
-
- len = _g_gnulib_vasprintf (string, format, args);
- if (len < 0)
- *string = NULL;
-
-#elif defined (HAVE_VASPRINTF)
-
- len = vasprintf (string, format, args);
- if (len < 0)
- *string = NULL;
- else if (!g_mem_is_system_malloc ())
- {
- /* vasprintf returns malloc-allocated memory */
- gchar *string1 = g_strndup (*string, len);
- free (*string);
- *string = string1;
- }
-
-#else
-
- {
- va_list args2;
-
- G_VA_COPY (args2, args);
-
- *string = g_new (gchar, g_printf_string_upper_bound (format, args));
-
- len = _g_vsprintf (*string, format, args2);
- va_end (args2);
- }
-#endif
-
- return len;
-}
-
-#define __G_PRINTF_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gprintf.h b/navit/support/glib/gprintf.h
deleted file mode 100644
index d96870fb4..000000000
--- a/navit/support/glib/gprintf.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997, 2002 Peter Mattis, Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __G_PRINTF_H__
-#define __G_PRINTF_H__
-
-#include <glib.h>
-#include <stdio.h>
-#include <stdarg.h>
-
-G_BEGIN_DECLS
-
-gint g_printf (gchar const *format,
- ...) G_GNUC_PRINTF (1, 2);
-gint g_fprintf (FILE *file,
- gchar const *format,
- ...) G_GNUC_PRINTF (2, 3);
-gint g_sprintf (gchar *string,
- gchar const *format,
- ...) G_GNUC_PRINTF (2, 3);
-
-gint g_vprintf (gchar const *format,
- va_list args);
-gint g_vfprintf (FILE *file,
- gchar const *format,
- va_list args);
-gint g_vsprintf (gchar *string,
- gchar const *format,
- va_list args);
-gint g_vasprintf (gchar **string,
- gchar const *format,
- va_list args);
-
-G_END_DECLS
-
-#endif /* __G_PRINTF_H__ */
diff --git a/navit/support/glib/gprintfint.h b/navit/support/glib/gprintfint.h
deleted file mode 100644
index 917856acd..000000000
--- a/navit/support/glib/gprintfint.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 2002. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#ifndef __G_PRINTFINT_H__
-#define __G_PRINTFINT_H__
-#ifdef HAVE_API_WIN32_BASE
-#include <glibintl.h>
-#endif
-#ifdef HAVE_API_WIN32_CE
-#include "libc.h"
-#endif
-
-#ifdef HAVE_GOOD_PRINTF
-
-#define _g_printf printf
-#define _g_fprintf fprintf
-#define _g_sprintf sprintf
-#ifdef _MSC_VER
-#define _g_snprintf _snprintf
-#else
-#define _g_snprintf snprintf
-#endif
-
-#define _g_vprintf vprintf
-#define _g_vfprintf vfprintf
-#define _g_vsprintf vsprintf
-#define _g_vsnprintf vsnprintf
-
-#else
-
-#include "gnulib/printf.h"
-
-#define _g_printf _g_gnulib_printf
-#define _g_fprintf _g_gnulib_fprintf
-#define _g_sprintf _g_gnulib_sprintf
-#define _g_snprintf _g_gnulib_snprintf
-
-#define _g_vprintf _g_gnulib_vprintf
-#define _g_vfprintf _g_gnulib_vfprintf
-#define _g_vsprintf _g_gnulib_vsprintf
-#define _g_vsnprintf _g_gnulib_vsnprintf
-
-#endif
-
-#endif /* __G_PRINTF_H__ */
-
diff --git a/navit/support/glib/gquark.h b/navit/support/glib/gquark.h
deleted file mode 100644
index a0cbe2fd7..000000000
--- a/navit/support/glib/gquark.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_QUARK_H__
-#define __G_QUARK_H__
-
-#include <glib/gtypes.h>
-
-G_BEGIN_DECLS
-
-typedef guint32 GQuark;
-
-/* Quarks (string<->id association)
- */
-GQuark g_quark_try_string (const gchar *string);
-GQuark g_quark_from_static_string (const gchar *string);
-GQuark g_quark_from_string (const gchar *string);
-G_CONST_RETURN gchar* g_quark_to_string (GQuark quark) G_GNUC_CONST;
-
-G_CONST_RETURN gchar* g_intern_string (const gchar *string);
-G_CONST_RETURN gchar* g_intern_static_string (const gchar *string);
-
-G_END_DECLS
-
-#endif /* __G_QUARK_H__ */
diff --git a/navit/support/glib/gslice.c b/navit/support/glib/gslice.c
deleted file mode 100644
index 29165bc5a..000000000
--- a/navit/support/glib/gslice.c
+++ /dev/null
@@ -1,1496 +0,0 @@
-/* GLIB sliced memory - fast concurrent memory chunk allocator
- * Copyright (C) 2005 Tim Janik
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-/* MT safe */
-
-#include "config.h"
-
-#if defined HAVE_POSIX_MEMALIGN && defined POSIX_MEMALIGN_WITH_COMPLIANT_ALLOCS
-# define HAVE_COMPLIANT_POSIX_MEMALIGN 1
-#endif
-
-#ifdef HAVE_COMPLIANT_POSIX_MEMALIGN
-#define _XOPEN_SOURCE 600 /* posix_memalign() */
-#endif
-#include <stdlib.h> /* posix_memalign() */
-#include <string.h>
-#include <errno.h>
-#include "gmem.h" /* gslice.h */
-#include "gthreadprivate.h"
-#include "glib.h"
-#include "galias.h"
-#ifdef HAVE_UNISTD_H
-#include <unistd.h> /* sysconf() */
-#endif
-#ifdef G_OS_WIN32
-#include <windows.h>
-#include <process.h>
-#endif
-
-#include <stdio.h> /* fputs/fprintf */
-
-
-/* the GSlice allocator is split up into 4 layers, roughly modelled after the slab
- * allocator and magazine extensions as outlined in:
- * + [Bonwick94] Jeff Bonwick, The slab allocator: An object-caching kernel
- * memory allocator. USENIX 1994, http://citeseer.ist.psu.edu/bonwick94slab.html
- * + [Bonwick01] Bonwick and Jonathan Adams, Magazines and vmem: Extending the
- * slab allocator to many cpu's and arbitrary resources.
- * USENIX 2001, http://citeseer.ist.psu.edu/bonwick01magazines.html
- * the layers are:
- * - the thread magazines. for each (aligned) chunk size, a magazine (a list)
- * of recently freed and soon to be allocated chunks is maintained per thread.
- * this way, most alloc/free requests can be quickly satisfied from per-thread
- * free lists which only require one g_private_get() call to retrive the
- * thread handle.
- * - the magazine cache. allocating and freeing chunks to/from threads only
- * occours at magazine sizes from a global depot of magazines. the depot
- * maintaines a 15 second working set of allocated magazines, so full
- * magazines are not allocated and released too often.
- * the chunk size dependent magazine sizes automatically adapt (within limits,
- * see [3]) to lock contention to properly scale performance across a variety
- * of SMP systems.
- * - the slab allocator. this allocator allocates slabs (blocks of memory) close
- * to the system page size or multiples thereof which have to be page aligned.
- * the blocks are divided into smaller chunks which are used to satisfy
- * allocations from the upper layers. the space provided by the reminder of
- * the chunk size division is used for cache colorization (random distribution
- * of chunk addresses) to improve processor cache utilization. multiple slabs
- * with the same chunk size are kept in a partially sorted ring to allow O(1)
- * freeing and allocation of chunks (as long as the allocation of an entirely
- * new slab can be avoided).
- * - the page allocator. on most modern systems, posix_memalign(3) or
- * memalign(3) should be available, so this is used to allocate blocks with
- * system page size based alignments and sizes or multiples thereof.
- * if no memalign variant is provided, valloc() is used instead and
- * block sizes are limited to the system page size (no multiples thereof).
- * as a fallback, on system without even valloc(), a malloc(3)-based page
- * allocator with alloc-only behaviour is used.
- *
- * NOTES:
- * [1] some systems memalign(3) implementations may rely on boundary tagging for
- * the handed out memory chunks. to avoid excessive page-wise fragmentation,
- * we reserve 2 * sizeof (void*) per block size for the systems memalign(3),
- * specified in NATIVE_MALLOC_PADDING.
- * [2] using the slab allocator alone already provides for a fast and efficient
- * allocator, it doesn't properly scale beyond single-threaded uses though.
- * also, the slab allocator implements eager free(3)-ing, i.e. does not
- * provide any form of caching or working set maintenance. so if used alone,
- * it's vulnerable to trashing for sequences of balanced (alloc, free) pairs
- * at certain thresholds.
- * [3] magazine sizes are bound by an implementation specific minimum size and
- * a chunk size specific maximum to limit magazine storage sizes to roughly
- * 16KB.
- * [4] allocating ca. 8 chunks per block/page keeps a good balance between
- * external and internal fragmentation (<= 12.5%). [Bonwick94]
- */
-
-/* --- macros and constants --- */
-#define LARGEALIGNMENT (256)
-#define P2ALIGNMENT (2 * sizeof (gsize)) /* fits 2 pointers (assumed to be 2 * GLIB_SIZEOF_SIZE_T below) */
-#define ALIGN(size, base) ((base) * (gsize) (((size) + (base) - 1) / (base)))
-#define NATIVE_MALLOC_PADDING 0 /* per-page padding left for native malloc(3) see [1] */
-#define SLAB_INFO_SIZE P2ALIGN (sizeof (SlabInfo) + NATIVE_MALLOC_PADDING)
-#define MAX_MAGAZINE_SIZE (256) /* see [3] and allocator_get_magazine_threshold() for this */
-#define MIN_MAGAZINE_SIZE (4)
-#define MAX_STAMP_COUNTER (7) /* distributes the load of gettimeofday() */
-#define MAX_SLAB_CHUNK_SIZE(al) (((al)->max_page_size - SLAB_INFO_SIZE) / 8) /* we want at last 8 chunks per page, see [4] */
-#define MAX_SLAB_INDEX(al) (SLAB_INDEX (al, MAX_SLAB_CHUNK_SIZE (al)) + 1)
-#define SLAB_INDEX(al, asize) ((asize) / P2ALIGNMENT - 1) /* asize must be P2ALIGNMENT aligned */
-#define SLAB_CHUNK_SIZE(al, ix) (((ix) + 1) * P2ALIGNMENT)
-#define SLAB_BPAGE_SIZE(al,csz) (8 * (csz) + SLAB_INFO_SIZE)
-
-/* optimized version of ALIGN (size, P2ALIGNMENT) */
-#if GLIB_SIZEOF_SIZE_T * 2 == 8 /* P2ALIGNMENT */
-#define P2ALIGN(size) (((size) + 0x7) & ~(gsize) 0x7)
-#elif GLIB_SIZEOF_SIZE_T * 2 == 16 /* P2ALIGNMENT */
-#define P2ALIGN(size) (((size) + 0xf) & ~(gsize) 0xf)
-#else
-#define P2ALIGN(size) ALIGN (size, P2ALIGNMENT)
-#endif
-
-/* special helpers to avoid gmessage.c dependency */
-static void mem_error (const char *format, ...) G_GNUC_PRINTF (1,2);
-#define mem_assert(cond) do { if (G_LIKELY (cond)) ; else mem_error ("assertion failed: %s", #cond); } while (0)
-
-/* --- structures --- */
-typedef struct _ChunkLink ChunkLink;
-typedef struct _SlabInfo SlabInfo;
-typedef struct _CachedMagazine CachedMagazine;
-struct _ChunkLink {
- ChunkLink *next;
- ChunkLink *data;
-};
-struct _SlabInfo {
- ChunkLink *chunks;
- guint n_allocated;
- SlabInfo *next, *prev;
-};
-typedef struct {
- ChunkLink *chunks;
- gsize count; /* approximative chunks list length */
-} Magazine;
-typedef struct {
- Magazine *magazine1; /* array of MAX_SLAB_INDEX (allocator) */
- Magazine *magazine2; /* array of MAX_SLAB_INDEX (allocator) */
-} ThreadMemory;
-typedef struct {
- gboolean always_malloc;
- gboolean bypass_magazines;
- gboolean debug_blocks;
- gsize working_set_msecs;
- guint color_increment;
-} SliceConfig;
-typedef struct {
- /* const after initialization */
- gsize min_page_size, max_page_size;
- SliceConfig config;
- gsize max_slab_chunk_size_for_magazine_cache;
- /* magazine cache */
- GMutex *magazine_mutex;
- ChunkLink **magazines; /* array of MAX_SLAB_INDEX (allocator) */
- guint *contention_counters; /* array of MAX_SLAB_INDEX (allocator) */
- gint mutex_counter;
- guint stamp_counter;
- guint last_stamp;
- /* slab allocator */
- GMutex *slab_mutex;
- SlabInfo **slab_stack; /* array of MAX_SLAB_INDEX (allocator) */
- guint color_accu;
-} Allocator;
-
-/* --- g-slice prototypes --- */
-static gpointer slab_allocator_alloc_chunk (gsize chunk_size);
-static void slab_allocator_free_chunk (gsize chunk_size,
- gpointer mem);
-static void private_thread_memory_cleanup (gpointer data);
-static gpointer allocator_memalign (gsize alignment,
- gsize memsize);
-static void allocator_memfree (gsize memsize,
- gpointer mem);
-static inline void magazine_cache_update_stamp (void);
-static inline gsize allocator_get_magazine_threshold (Allocator *allocator,
- guint ix);
-
-/* --- g-slice memory checker --- */
-static void smc_notify_alloc (void *pointer,
- size_t size);
-static int smc_notify_free (void *pointer,
- size_t size);
-
-/* --- variables --- */
-static GPrivate *private_thread_memory = NULL;
-static gsize sys_page_size = 0;
-static gsize sys_valignment = ((32*1024*1024));
-static guint8 *virtual_mem = 0;
-static Allocator allocator[1] = { { 0, }, };
-static SliceConfig slice_config = {
- FALSE, /* always_malloc */
- FALSE, /* bypass_magazines */
- FALSE, /* debug_blocks */
- 15 * 1000, /* working_set_msecs */
- 1, /* color increment, alt: 0x7fffffff */
-};
-static GMutex *smc_tree_mutex = NULL; /* mutex for G_SLICE=debug-blocks */
-
-/* --- auxillary funcitons --- */
-void
-g_slice_set_config (GSliceConfig ckey,
- gint64 value)
-{
- g_return_if_fail (sys_page_size == 0);
- switch (ckey)
- {
- case G_SLICE_CONFIG_ALWAYS_MALLOC:
- slice_config.always_malloc = value != 0;
- break;
- case G_SLICE_CONFIG_BYPASS_MAGAZINES:
- slice_config.bypass_magazines = value != 0;
- break;
- case G_SLICE_CONFIG_WORKING_SET_MSECS:
- slice_config.working_set_msecs = value;
- break;
- case G_SLICE_CONFIG_COLOR_INCREMENT:
- slice_config.color_increment = value;
- default: ;
- }
-}
-
-gint64
-g_slice_get_config (GSliceConfig ckey)
-{
- switch (ckey)
- {
- case G_SLICE_CONFIG_ALWAYS_MALLOC:
- return slice_config.always_malloc;
- case G_SLICE_CONFIG_BYPASS_MAGAZINES:
- return slice_config.bypass_magazines;
- case G_SLICE_CONFIG_WORKING_SET_MSECS:
- return slice_config.working_set_msecs;
- case G_SLICE_CONFIG_CHUNK_SIZES:
- return MAX_SLAB_INDEX (allocator);
- case G_SLICE_CONFIG_COLOR_INCREMENT:
- return slice_config.color_increment;
- default:
- return 0;
- }
-}
-
-gint64*
-g_slice_get_config_state (GSliceConfig ckey,
- gint64 address,
- guint *n_values)
-{
- guint i = 0;
- g_return_val_if_fail (n_values != NULL, NULL);
- *n_values = 0;
- switch (ckey)
- {
- gint64 array[64];
- case G_SLICE_CONFIG_CONTENTION_COUNTER:
- array[i++] = SLAB_CHUNK_SIZE (allocator, address);
- array[i++] = allocator->contention_counters[address];
- array[i++] = allocator_get_magazine_threshold (allocator, address);
- *n_values = i;
- return g_memdup (array, sizeof (array[0]) * *n_values);
- default:
- return NULL;
- }
-}
-
-static void
-slice_config_init (SliceConfig *config)
-{
- /* don't use g_malloc/g_message here */
-#if NOT_NEEDED_FOR_NAVIT
- gchar buffer[1024];
- const gchar *val = _g_getenv_nomalloc ("G_SLICE", buffer);
- const GDebugKey keys[] = {
- { "always-malloc", 1 << 0 },
- { "debug-blocks", 1 << 1 },
- };
- gint flags = !val ? 0 : g_parse_debug_string (val, keys, G_N_ELEMENTS (keys));
-#endif
- *config = slice_config;
-#if NOT_NEEDED_FOR_NAVIT
- if (flags & (1 << 0)) /* always-malloc */
- config->always_malloc = TRUE;
- if (flags & (1 << 1)) /* debug-blocks */
- config->debug_blocks = TRUE;
-#endif
-}
-
-static void
-g_slice_init_nomessage (void)
-{
- /* we may not use g_error() or friends here */
- mem_assert (sys_page_size == 0);
- mem_assert (MIN_MAGAZINE_SIZE >= 4);
-
-#ifdef G_OS_WIN32
- {
- SYSTEM_INFO system_info;
- GetSystemInfo (&system_info);
- sys_page_size = system_info.dwPageSize;
- virtual_mem = VirtualAlloc (NULL, sys_valignment, MEM_RESERVE, PAGE_NOACCESS);
-// sys_valignment = system_info.dwAllocationGranularity;
- //sys_valignment = 2*1024*1024 + sys_page_size;
- printf("SPAGE_SIZE: %d, SVALIGN:%d\n", sys_page_size, sys_valignment);
- }
-#else
- sys_page_size = sysconf (_SC_PAGESIZE); /* = sysconf (_SC_PAGE_SIZE); = getpagesize(); */
- sys_valignment = sys_page_size;
-#endif
- mem_assert (sys_page_size >= 2 * LARGEALIGNMENT);
- mem_assert ((sys_page_size & (sys_page_size - 1)) == 0);
- slice_config_init (&allocator->config);
- allocator->min_page_size = sys_page_size;
-#if HAVE_COMPLIANT_POSIX_MEMALIGN || HAVE_MEMALIGN
- /* allow allocation of pages up to 8KB (with 8KB alignment).
- * this is useful because many medium to large sized structures
- * fit less than 8 times (see [4]) into 4KB pages.
- * we allow very small page sizes here, to reduce wastage in
- * threads if only small allocations are required (this does
- * bear the risk of incresing allocation times and fragmentation
- * though).
- */
- allocator->min_page_size = MAX (allocator->min_page_size, 4096);
- allocator->max_page_size = MAX (allocator->min_page_size, 8192);
- allocator->min_page_size = MIN (allocator->min_page_size, 128);
-#else
- /* we can only align to system page size */
- allocator->max_page_size = sys_page_size;
-#endif
- allocator->magazine_mutex = NULL; /* _g_slice_thread_init_nomessage() */
- allocator->magazines = g_new0 (ChunkLink*, MAX_SLAB_INDEX (allocator));
- allocator->contention_counters = g_new0 (guint, MAX_SLAB_INDEX (allocator));
- allocator->mutex_counter = 0;
- allocator->stamp_counter = MAX_STAMP_COUNTER; /* force initial update */
- allocator->last_stamp = 0;
- allocator->slab_mutex = NULL; /* _g_slice_thread_init_nomessage() */
- allocator->slab_stack = g_new0 (SlabInfo*, MAX_SLAB_INDEX (allocator));
- allocator->color_accu = 0;
- magazine_cache_update_stamp();
- /* values cached for performance reasons */
- allocator->max_slab_chunk_size_for_magazine_cache = MAX_SLAB_CHUNK_SIZE (allocator);
- if (allocator->config.always_malloc || allocator->config.bypass_magazines)
- allocator->max_slab_chunk_size_for_magazine_cache = 0; /* non-optimized cases */
- /* at this point, g_mem_gc_friendly() should be initialized, this
- * should have been accomplished by the above g_malloc/g_new calls
- */
-}
-
-static inline guint
-allocator_categorize (gsize aligned_chunk_size)
-{
- /* speed up the likely path */
- if (G_LIKELY (aligned_chunk_size && aligned_chunk_size <= allocator->max_slab_chunk_size_for_magazine_cache))
- return 1; /* use magazine cache */
-
- /* the above will fail (max_slab_chunk_size_for_magazine_cache == 0) if the
- * allocator is still uninitialized, or if we are not configured to use the
- * magazine cache.
- */
- if (!sys_page_size)
- g_slice_init_nomessage ();
- if (!allocator->config.always_malloc &&
- aligned_chunk_size &&
- aligned_chunk_size <= MAX_SLAB_CHUNK_SIZE (allocator))
- {
- if (allocator->config.bypass_magazines)
- return 2; /* use slab allocator, see [2] */
- return 1; /* use magazine cache */
- }
- return 0; /* use malloc() */
-}
-
-void
-_g_slice_thread_init_nomessage (void)
-{
- /* we may not use g_error() or friends here */
- if (!sys_page_size)
- g_slice_init_nomessage();
- else
- {
- /* g_slice_init_nomessage() has been called already, probably due
- * to a g_slice_alloc1() before g_thread_init().
- */
- }
- private_thread_memory = g_private_new (private_thread_memory_cleanup);
- allocator->magazine_mutex = g_mutex_new();
- allocator->slab_mutex = g_mutex_new();
- if (allocator->config.debug_blocks)
- smc_tree_mutex = g_mutex_new();
-}
-
-static inline void
-g_mutex_lock_a (GMutex *mutex,
- guint *contention_counter)
-{
- gboolean contention = FALSE;
- if (!g_mutex_trylock (mutex))
- {
- g_mutex_lock (mutex);
- contention = TRUE;
- }
- if (contention)
- {
- allocator->mutex_counter++;
- if (allocator->mutex_counter >= 1) /* quickly adapt to contention */
- {
- allocator->mutex_counter = 0;
- *contention_counter = MIN (*contention_counter + 1, MAX_MAGAZINE_SIZE);
- }
- }
- else /* !contention */
- {
- allocator->mutex_counter--;
- if (allocator->mutex_counter < -11) /* moderately recover magazine sizes */
- {
- allocator->mutex_counter = 0;
- *contention_counter = MAX (*contention_counter, 1) - 1;
- }
- }
-}
-
-static inline ThreadMemory*
-thread_memory_from_self (void)
-{
- ThreadMemory *tmem = g_private_get (private_thread_memory);
- if (G_UNLIKELY (!tmem))
- {
- static ThreadMemory *single_thread_memory = NULL; /* remember single-thread info for multi-threaded case */
- if (single_thread_memory && g_thread_supported ())
- {
- g_mutex_lock (allocator->slab_mutex);
- if (single_thread_memory)
- {
- /* GSlice has been used before g_thread_init(), and now
- * we are running threaded. to cope with it, use the saved
- * thread memory structure from when we weren't threaded.
- */
- tmem = single_thread_memory;
- single_thread_memory = NULL; /* slab_mutex protected when multi-threaded */
- }
- g_mutex_unlock (allocator->slab_mutex);
- }
- if (!tmem)
- {
- const guint n_magazines = MAX_SLAB_INDEX (allocator);
- tmem = g_malloc0 (sizeof (ThreadMemory) + sizeof (Magazine) * 2 * n_magazines);
- tmem->magazine1 = (Magazine*) (tmem + 1);
- tmem->magazine2 = &tmem->magazine1[n_magazines];
- }
- /* g_private_get/g_private_set works in the single-threaded xor the multi-
- * threaded case. but not *across* g_thread_init(), after multi-thread
- * initialization it returns NULL for previously set single-thread data.
- */
- g_private_set (private_thread_memory, tmem);
- /* save single-thread thread memory structure, in case we need to
- * pick it up again after multi-thread initialization happened.
- */
- if (!single_thread_memory && !g_thread_supported ())
- single_thread_memory = tmem; /* no slab_mutex created yet */
- }
- return tmem;
-}
-
-static inline ChunkLink*
-magazine_chain_pop_head (ChunkLink **magazine_chunks)
-{
- /* magazine chains are linked via ChunkLink->next.
- * each ChunkLink->data of the toplevel chain may point to a subchain,
- * linked via ChunkLink->next. ChunkLink->data of the subchains just
- * contains uninitialized junk.
- */
- ChunkLink *chunk = (*magazine_chunks)->data;
- if (G_UNLIKELY (chunk))
- {
- /* allocating from freed list */
- (*magazine_chunks)->data = chunk->next;
- }
- else
- {
- chunk = *magazine_chunks;
- *magazine_chunks = chunk->next;
- }
- return chunk;
-}
-
-#if 0 /* useful for debugging */
-static guint
-magazine_count (ChunkLink *head)
-{
- guint count = 0;
- if (!head)
- return 0;
- while (head)
- {
- ChunkLink *child = head->data;
- count += 1;
- for (child = head->data; child; child = child->next)
- count += 1;
- head = head->next;
- }
- return count;
-}
-#endif
-
-static inline gsize
-allocator_get_magazine_threshold (Allocator *allocator,
- guint ix)
-{
- /* the magazine size calculated here has a lower bound of MIN_MAGAZINE_SIZE,
- * which is required by the implementation. also, for moderately sized chunks
- * (say >= 64 bytes), magazine sizes shouldn't be much smaller then the number
- * of chunks available per page/2 to avoid excessive traffic in the magazine
- * cache for small to medium sized structures.
- * the upper bound of the magazine size is effectively provided by
- * MAX_MAGAZINE_SIZE. for larger chunks, this number is scaled down so that
- * the content of a single magazine doesn't exceed ca. 16KB.
- */
- gsize chunk_size = SLAB_CHUNK_SIZE (allocator, ix);
- guint threshold = MAX (MIN_MAGAZINE_SIZE, allocator->max_page_size / MAX (5 * chunk_size, 5 * 32));
- guint contention_counter = allocator->contention_counters[ix];
- if (G_UNLIKELY (contention_counter)) /* single CPU bias */
- {
- /* adapt contention counter thresholds to chunk sizes */
- contention_counter = contention_counter * 64 / chunk_size;
- threshold = MAX (threshold, contention_counter);
- }
- return threshold;
-}
-
-/* --- magazine cache --- */
-static inline void
-magazine_cache_update_stamp (void)
-{
- if (allocator->stamp_counter >= MAX_STAMP_COUNTER)
- {
- GTimeVal tv;
- g_get_current_time (&tv);
- allocator->last_stamp = tv.tv_sec * 1000 + tv.tv_usec / 1000; /* milli seconds */
- allocator->stamp_counter = 0;
- }
- else
- allocator->stamp_counter++;
-}
-
-static inline ChunkLink*
-magazine_chain_prepare_fields (ChunkLink *magazine_chunks)
-{
- ChunkLink *chunk1;
- ChunkLink *chunk2;
- ChunkLink *chunk3;
- ChunkLink *chunk4;
- /* checked upon initialization: mem_assert (MIN_MAGAZINE_SIZE >= 4); */
- /* ensure a magazine with at least 4 unused data pointers */
- chunk1 = magazine_chain_pop_head (&magazine_chunks);
- chunk2 = magazine_chain_pop_head (&magazine_chunks);
- chunk3 = magazine_chain_pop_head (&magazine_chunks);
- chunk4 = magazine_chain_pop_head (&magazine_chunks);
- chunk4->next = magazine_chunks;
- chunk3->next = chunk4;
- chunk2->next = chunk3;
- chunk1->next = chunk2;
- return chunk1;
-}
-
-/* access the first 3 fields of a specially prepared magazine chain */
-#define magazine_chain_prev(mc) ((mc)->data)
-#define magazine_chain_stamp(mc) ((mc)->next->data)
-#define magazine_chain_uint_stamp(mc) GPOINTER_TO_UINT ((mc)->next->data)
-#define magazine_chain_next(mc) ((mc)->next->next->data)
-#define magazine_chain_count(mc) ((mc)->next->next->next->data)
-
-static void
-magazine_cache_trim (Allocator *allocator,
- guint ix,
- guint stamp)
-{
- /* g_mutex_lock (allocator->mutex); done by caller */
- /* trim magazine cache from tail */
- ChunkLink *current = magazine_chain_prev (allocator->magazines[ix]);
- ChunkLink *trash = NULL;
- while (ABS (stamp - magazine_chain_uint_stamp (current)) >= allocator->config.working_set_msecs)
- {
- /* unlink */
- ChunkLink *prev = magazine_chain_prev (current);
- ChunkLink *next = magazine_chain_next (current);
- magazine_chain_next (prev) = next;
- magazine_chain_prev (next) = prev;
- /* clear special fields, put on trash stack */
- magazine_chain_next (current) = NULL;
- magazine_chain_count (current) = NULL;
- magazine_chain_stamp (current) = NULL;
- magazine_chain_prev (current) = trash;
- trash = current;
- /* fixup list head if required */
- if (current == allocator->magazines[ix])
- {
- allocator->magazines[ix] = NULL;
- break;
- }
- current = prev;
- }
- g_mutex_unlock (allocator->magazine_mutex);
- /* free trash */
- if (trash)
- {
- const gsize chunk_size = SLAB_CHUNK_SIZE (allocator, ix);
- g_mutex_lock (allocator->slab_mutex);
- while (trash)
- {
- current = trash;
- trash = magazine_chain_prev (current);
- magazine_chain_prev (current) = NULL; /* clear special field */
- while (current)
- {
- ChunkLink *chunk = magazine_chain_pop_head (&current);
- slab_allocator_free_chunk (chunk_size, chunk);
- }
- }
- g_mutex_unlock (allocator->slab_mutex);
- }
-}
-
-static void
-magazine_cache_push_magazine (guint ix,
- ChunkLink *magazine_chunks,
- gsize count) /* must be >= MIN_MAGAZINE_SIZE */
-{
- ChunkLink *current = magazine_chain_prepare_fields (magazine_chunks);
- ChunkLink *next, *prev;
- g_mutex_lock (allocator->magazine_mutex);
- /* add magazine at head */
- next = allocator->magazines[ix];
- if (next)
- prev = magazine_chain_prev (next);
- else
- next = prev = current;
- magazine_chain_next (prev) = current;
- magazine_chain_prev (next) = current;
- magazine_chain_prev (current) = prev;
- magazine_chain_next (current) = next;
- magazine_chain_count (current) = (gpointer) count;
- /* stamp magazine */
- magazine_cache_update_stamp();
- magazine_chain_stamp (current) = GUINT_TO_POINTER (allocator->last_stamp);
- allocator->magazines[ix] = current;
- /* free old magazines beyond a certain threshold */
- magazine_cache_trim (allocator, ix, allocator->last_stamp);
- /* g_mutex_unlock (allocator->mutex); was done by magazine_cache_trim() */
-}
-
-static ChunkLink*
-magazine_cache_pop_magazine (guint ix,
- gsize *countp)
-{
- g_mutex_lock_a (allocator->magazine_mutex, &allocator->contention_counters[ix]);
- if (!allocator->magazines[ix])
- {
- guint magazine_threshold = allocator_get_magazine_threshold (allocator, ix);
- gsize i, chunk_size = SLAB_CHUNK_SIZE (allocator, ix);
- ChunkLink *chunk, *head;
- g_mutex_unlock (allocator->magazine_mutex);
- g_mutex_lock (allocator->slab_mutex);
- head = slab_allocator_alloc_chunk (chunk_size);
- head->data = NULL;
- chunk = head;
- for (i = 1; i < magazine_threshold; i++)
- {
- chunk->next = slab_allocator_alloc_chunk (chunk_size);
- chunk = chunk->next;
- chunk->data = NULL;
- }
- chunk->next = NULL;
- g_mutex_unlock (allocator->slab_mutex);
- *countp = i;
- return head;
- }
- else
- {
- ChunkLink *current = allocator->magazines[ix];
- ChunkLink *prev = magazine_chain_prev (current);
- ChunkLink *next = magazine_chain_next (current);
- /* unlink */
- magazine_chain_next (prev) = next;
- magazine_chain_prev (next) = prev;
- allocator->magazines[ix] = next == current ? NULL : next;
- g_mutex_unlock (allocator->magazine_mutex);
- /* clear special fields and hand out */
- *countp = (gsize) magazine_chain_count (current);
- magazine_chain_prev (current) = NULL;
- magazine_chain_next (current) = NULL;
- magazine_chain_count (current) = NULL;
- magazine_chain_stamp (current) = NULL;
- return current;
- }
-}
-
-/* --- thread magazines --- */
-static void
-private_thread_memory_cleanup (gpointer data)
-{
- ThreadMemory *tmem = data;
- const guint n_magazines = MAX_SLAB_INDEX (allocator);
- guint ix;
- for (ix = 0; ix < n_magazines; ix++)
- {
- Magazine *mags[2];
- guint j;
- mags[0] = &tmem->magazine1[ix];
- mags[1] = &tmem->magazine2[ix];
- for (j = 0; j < 2; j++)
- {
- Magazine *mag = mags[j];
- if (mag->count >= MIN_MAGAZINE_SIZE)
- magazine_cache_push_magazine (ix, mag->chunks, mag->count);
- else
- {
- const gsize chunk_size = SLAB_CHUNK_SIZE (allocator, ix);
- g_mutex_lock (allocator->slab_mutex);
- while (mag->chunks)
- {
- ChunkLink *chunk = magazine_chain_pop_head (&mag->chunks);
- slab_allocator_free_chunk (chunk_size, chunk);
- }
- g_mutex_unlock (allocator->slab_mutex);
- }
- }
- }
- g_free (tmem);
-}
-
-static void
-thread_memory_magazine1_reload (ThreadMemory *tmem,
- guint ix)
-{
- Magazine *mag = &tmem->magazine1[ix];
- mem_assert (mag->chunks == NULL); /* ensure that we may reset mag->count */
- mag->count = 0;
- mag->chunks = magazine_cache_pop_magazine (ix, &mag->count);
-}
-
-static void
-thread_memory_magazine2_unload (ThreadMemory *tmem,
- guint ix)
-{
- Magazine *mag = &tmem->magazine2[ix];
- magazine_cache_push_magazine (ix, mag->chunks, mag->count);
- mag->chunks = NULL;
- mag->count = 0;
-}
-
-static inline void
-thread_memory_swap_magazines (ThreadMemory *tmem,
- guint ix)
-{
- Magazine xmag = tmem->magazine1[ix];
- tmem->magazine1[ix] = tmem->magazine2[ix];
- tmem->magazine2[ix] = xmag;
-}
-
-static inline gboolean
-thread_memory_magazine1_is_empty (ThreadMemory *tmem,
- guint ix)
-{
- return tmem->magazine1[ix].chunks == NULL;
-}
-
-static inline gboolean
-thread_memory_magazine2_is_full (ThreadMemory *tmem,
- guint ix)
-{
- return tmem->magazine2[ix].count >= allocator_get_magazine_threshold (allocator, ix);
-}
-
-static inline gpointer
-thread_memory_magazine1_alloc (ThreadMemory *tmem,
- guint ix)
-{
- Magazine *mag = &tmem->magazine1[ix];
- ChunkLink *chunk = magazine_chain_pop_head (&mag->chunks);
- if (G_LIKELY (mag->count > 0))
- mag->count--;
- return chunk;
-}
-
-static inline void
-thread_memory_magazine2_free (ThreadMemory *tmem,
- guint ix,
- gpointer mem)
-{
- Magazine *mag = &tmem->magazine2[ix];
- ChunkLink *chunk = mem;
- chunk->data = NULL;
- chunk->next = mag->chunks;
- mag->chunks = chunk;
- mag->count++;
-}
-
-/* --- API functions --- */
-gpointer
-g_slice_alloc (gsize mem_size)
-{
- gsize chunk_size;
- gpointer mem;
- guint acat;
- chunk_size = P2ALIGN (mem_size);
- acat = allocator_categorize (chunk_size);
- if (G_LIKELY (acat == 1)) /* allocate through magazine layer */
- {
- ThreadMemory *tmem = thread_memory_from_self();
- guint ix = SLAB_INDEX (allocator, chunk_size);
- if (G_UNLIKELY (thread_memory_magazine1_is_empty (tmem, ix)))
- {
- thread_memory_swap_magazines (tmem, ix);
- if (G_UNLIKELY (thread_memory_magazine1_is_empty (tmem, ix)))
- thread_memory_magazine1_reload (tmem, ix);
- }
- mem = thread_memory_magazine1_alloc (tmem, ix);
- }
- else if (acat == 2) /* allocate through slab allocator */
- {
- g_mutex_lock (allocator->slab_mutex);
- mem = slab_allocator_alloc_chunk (chunk_size);
- g_mutex_unlock (allocator->slab_mutex);
- }
- else /* delegate to system malloc */
- mem = g_malloc (mem_size);
- if (G_UNLIKELY (allocator->config.debug_blocks))
- smc_notify_alloc (mem, mem_size);
- return mem;
-}
-
-gpointer
-g_slice_alloc0 (gsize mem_size)
-{
- gpointer mem = g_slice_alloc (mem_size);
- if (mem)
- memset (mem, 0, mem_size);
- return mem;
-}
-
-gpointer
-g_slice_copy (gsize mem_size,
- gconstpointer mem_block)
-{
- gpointer mem = g_slice_alloc (mem_size);
- if (mem)
- memcpy (mem, mem_block, mem_size);
- return mem;
-}
-
-void
-g_slice_free1 (gsize mem_size,
- gpointer mem_block)
-{
- gsize chunk_size = P2ALIGN (mem_size);
- guint acat = allocator_categorize (chunk_size);
- if (G_UNLIKELY (!mem_block))
- return;
- if (G_UNLIKELY (allocator->config.debug_blocks) &&
- !smc_notify_free (mem_block, mem_size))
- abort();
- if (G_LIKELY (acat == 1)) /* allocate through magazine layer */
- {
- ThreadMemory *tmem = thread_memory_from_self();
- guint ix = SLAB_INDEX (allocator, chunk_size);
- if (G_UNLIKELY (thread_memory_magazine2_is_full (tmem, ix)))
- {
- thread_memory_swap_magazines (tmem, ix);
- if (G_UNLIKELY (thread_memory_magazine2_is_full (tmem, ix)))
- thread_memory_magazine2_unload (tmem, ix);
- }
- if (G_UNLIKELY (g_mem_gc_friendly))
- memset (mem_block, 0, chunk_size);
- thread_memory_magazine2_free (tmem, ix, mem_block);
- }
- else if (acat == 2) /* allocate through slab allocator */
- {
- if (G_UNLIKELY (g_mem_gc_friendly))
- memset (mem_block, 0, chunk_size);
- g_mutex_lock (allocator->slab_mutex);
- slab_allocator_free_chunk (chunk_size, mem_block);
- g_mutex_unlock (allocator->slab_mutex);
- }
- else /* delegate to system malloc */
- {
- if (G_UNLIKELY (g_mem_gc_friendly))
- memset (mem_block, 0, mem_size);
- g_free (mem_block);
- }
-}
-
-void
-g_slice_free_chain_with_offset (gsize mem_size,
- gpointer mem_chain,
- gsize next_offset)
-{
- gpointer slice = mem_chain;
- /* while the thread magazines and the magazine cache are implemented so that
- * they can easily be extended to allow for free lists containing more free
- * lists for the first level nodes, which would allow O(1) freeing in this
- * function, the benefit of such an extension is questionable, because:
- * - the magazine size counts will become mere lower bounds which confuses
- * the code adapting to lock contention;
- * - freeing a single node to the thread magazines is very fast, so this
- * O(list_length) operation is multiplied by a fairly small factor;
- * - memory usage histograms on larger applications seem to indicate that
- * the amount of released multi node lists is negligible in comparison
- * to single node releases.
- * - the major performance bottle neck, namely g_private_get() or
- * g_mutex_lock()/g_mutex_unlock() has already been moved out of the
- * inner loop for freeing chained slices.
- */
- gsize chunk_size = P2ALIGN (mem_size);
- guint acat = allocator_categorize (chunk_size);
- if (G_LIKELY (acat == 1)) /* allocate through magazine layer */
- {
- ThreadMemory *tmem = thread_memory_from_self();
- guint ix = SLAB_INDEX (allocator, chunk_size);
- while (slice)
- {
- guint8 *current = slice;
- slice = *(gpointer*) (current + next_offset);
- if (G_UNLIKELY (allocator->config.debug_blocks) &&
- !smc_notify_free (current, mem_size))
- abort();
- if (G_UNLIKELY (thread_memory_magazine2_is_full (tmem, ix)))
- {
- thread_memory_swap_magazines (tmem, ix);
- if (G_UNLIKELY (thread_memory_magazine2_is_full (tmem, ix)))
- thread_memory_magazine2_unload (tmem, ix);
- }
- if (G_UNLIKELY (g_mem_gc_friendly))
- memset (current, 0, chunk_size);
- thread_memory_magazine2_free (tmem, ix, current);
- }
- }
- else if (acat == 2) /* allocate through slab allocator */
- {
- g_mutex_lock (allocator->slab_mutex);
- while (slice)
- {
- guint8 *current = slice;
- slice = *(gpointer*) (current + next_offset);
- if (G_UNLIKELY (allocator->config.debug_blocks) &&
- !smc_notify_free (current, mem_size))
- abort();
- if (G_UNLIKELY (g_mem_gc_friendly))
- memset (current, 0, chunk_size);
- slab_allocator_free_chunk (chunk_size, current);
- }
- g_mutex_unlock (allocator->slab_mutex);
- }
- else /* delegate to system malloc */
- while (slice)
- {
- guint8 *current = slice;
- slice = *(gpointer*) (current + next_offset);
- if (G_UNLIKELY (allocator->config.debug_blocks) &&
- !smc_notify_free (current, mem_size))
- abort();
- if (G_UNLIKELY (g_mem_gc_friendly))
- memset (current, 0, mem_size);
- g_free (current);
- }
-}
-
-/* --- single page allocator --- */
-static void
-allocator_slab_stack_push (Allocator *allocator,
- guint ix,
- SlabInfo *sinfo)
-{
- /* insert slab at slab ring head */
- if (!allocator->slab_stack[ix])
- {
- sinfo->next = sinfo;
- sinfo->prev = sinfo;
- }
- else
- {
- SlabInfo *next = allocator->slab_stack[ix], *prev = next->prev;
- next->prev = sinfo;
- prev->next = sinfo;
- sinfo->next = next;
- sinfo->prev = prev;
- }
- allocator->slab_stack[ix] = sinfo;
-}
-
-static gsize
-allocator_aligned_page_size (Allocator *allocator,
- gsize n_bytes)
-{
- gsize val = 1 << g_bit_storage (n_bytes - 1);
- val = MAX (val, allocator->min_page_size);
- return val;
-}
-
-static void
-allocator_add_slab (Allocator *allocator,
- guint ix,
- gsize chunk_size)
-{
- ChunkLink *chunk;
- SlabInfo *sinfo;
- gsize addr, padding, n_chunks, color = 0;
- gsize page_size = allocator_aligned_page_size (allocator, SLAB_BPAGE_SIZE (allocator, chunk_size));
- /* allocate 1 page for the chunks and the slab */
- gpointer aligned_memory = allocator_memalign (page_size, page_size - NATIVE_MALLOC_PADDING);
- guint8 *mem = aligned_memory;
- guint i;
- if (!mem)
- {
- const gchar *syserr = "unknown error";
-#if HAVE_STRERROR
- syserr = strerror (errno);
-#endif
- mem_error ("failed to allocate %u bytes (alignment: %u): %s\n",
- (guint) (page_size - NATIVE_MALLOC_PADDING), (guint) page_size, syserr);
- }
- /* mask page adress */
- addr = ((gsize) mem / page_size) * page_size;
- /* assert alignment */
- mem_assert (aligned_memory == (gpointer) addr);
- /* basic slab info setup */
- sinfo = (SlabInfo*) (mem + page_size - SLAB_INFO_SIZE);
- sinfo->n_allocated = 0;
- sinfo->chunks = NULL;
- /* figure cache colorization */
- n_chunks = ((guint8*) sinfo - mem) / chunk_size;
- padding = ((guint8*) sinfo - mem) - n_chunks * chunk_size;
- if (padding)
- {
- color = (allocator->color_accu * P2ALIGNMENT) % padding;
- allocator->color_accu += allocator->config.color_increment;
- }
- /* add chunks to free list */
- chunk = (ChunkLink*) (mem + color);
- sinfo->chunks = chunk;
- for (i = 0; i < n_chunks - 1; i++)
- {
- chunk->next = (ChunkLink*) ((guint8*) chunk + chunk_size);
- chunk = chunk->next;
- }
- chunk->next = NULL; /* last chunk */
- /* add slab to slab ring */
- allocator_slab_stack_push (allocator, ix, sinfo);
-}
-
-static gpointer
-slab_allocator_alloc_chunk (gsize chunk_size)
-{
- ChunkLink *chunk;
- guint ix = SLAB_INDEX (allocator, chunk_size);
- /* ensure non-empty slab */
- if (!allocator->slab_stack[ix] || !allocator->slab_stack[ix]->chunks)
- allocator_add_slab (allocator, ix, chunk_size);
- /* allocate chunk */
- chunk = allocator->slab_stack[ix]->chunks;
- allocator->slab_stack[ix]->chunks = chunk->next;
- allocator->slab_stack[ix]->n_allocated++;
- /* rotate empty slabs */
- if (!allocator->slab_stack[ix]->chunks)
- allocator->slab_stack[ix] = allocator->slab_stack[ix]->next;
- return chunk;
-}
-
-static void
-slab_allocator_free_chunk (gsize chunk_size,
- gpointer mem)
-{
- ChunkLink *chunk;
- gboolean was_empty;
- guint ix = SLAB_INDEX (allocator, chunk_size);
- gsize page_size = allocator_aligned_page_size (allocator, SLAB_BPAGE_SIZE (allocator, chunk_size));
- gsize addr = ((gsize) mem / page_size) * page_size;
- /* mask page adress */
- guint8 *page = (guint8*) addr;
- SlabInfo *sinfo = (SlabInfo*) (page + page_size - SLAB_INFO_SIZE);
- /* assert valid chunk count */
- mem_assert (sinfo->n_allocated > 0);
- /* add chunk to free list */
- was_empty = sinfo->chunks == NULL;
- chunk = (ChunkLink*) mem;
- chunk->next = sinfo->chunks;
- sinfo->chunks = chunk;
- sinfo->n_allocated--;
- /* keep slab ring partially sorted, empty slabs at end */
- if (was_empty)
- {
- /* unlink slab */
- SlabInfo *next = sinfo->next, *prev = sinfo->prev;
- next->prev = prev;
- prev->next = next;
- if (allocator->slab_stack[ix] == sinfo)
- allocator->slab_stack[ix] = next == sinfo ? NULL : next;
- /* insert slab at head */
- allocator_slab_stack_push (allocator, ix, sinfo);
- }
- /* eagerly free complete unused slabs */
- if (!sinfo->n_allocated)
- {
- /* unlink slab */
- SlabInfo *next = sinfo->next, *prev = sinfo->prev;
- next->prev = prev;
- prev->next = next;
- if (allocator->slab_stack[ix] == sinfo)
- allocator->slab_stack[ix] = next == sinfo ? NULL : next;
- /* free slab */
- allocator_memfree (page_size, page);
- }
-}
-
-/* --- memalign implementation --- */
-#ifdef HAVE_MALLOC_H
-#include <malloc.h> /* memalign() */
-#endif
-
-/* from config.h:
- * define HAVE_POSIX_MEMALIGN 1 // if free(posix_memalign(3)) works, <stdlib.h>
- * define HAVE_COMPLIANT_POSIX_MEMALIGN 1 // if free(posix_memalign(3)) works for sizes != 2^n, <stdlib.h>
- * define HAVE_MEMALIGN 1 // if free(memalign(3)) works, <malloc.h>
- * define HAVE_VALLOC 1 // if free(valloc(3)) works, <stdlib.h> or <malloc.h>
- * if none is provided, we implement malloc(3)-based alloc-only page alignment
- */
-
-#if !(HAVE_COMPLIANT_POSIX_MEMALIGN || HAVE_MEMALIGN || HAVE_VALLOC)
-static GTrashStack *compat_valloc_trash = NULL;
-#endif
-
-static gpointer
-allocator_memalign (gsize alignment,
- gsize memsize)
-{
- gpointer aligned_memory = NULL;
- gint err = ENOMEM;
-#if HAVE_COMPLIANT_POSIX_MEMALIGN
- err = posix_memalign (&aligned_memory, alignment, memsize);
-#elif HAVE_MEMALIGN
- errno = 0;
- aligned_memory = memalign (alignment, memsize);
- err = errno;
-#elif HAVE_VALLOC
- errno = 0;
- aligned_memory = valloc (memsize);
- err = errno;
-#else
- /* simplistic non-freeing page allocator */
- mem_assert (alignment == sys_page_size);
- mem_assert (memsize <= sys_page_size);
- if (!compat_valloc_trash)
-#ifdef G_OS_WIN32
- {
- aligned_memory = VirtualAlloc (virtual_mem, sys_page_size, MEM_COMMIT, PAGE_READWRITE);
- virtual_mem += sys_page_size;
- }
- else
-#else
- {
-
- const guint n_pages = 16;
- guint8 *mem = malloc (n_pages * sys_page_size);
- err = errno;
- if (mem)
- {
- gint i = n_pages;
- guint8 *amem = (guint8*) ALIGN ((gsize) mem, sys_page_size);
- if (amem != mem)
- i--; /* mem wasn't page aligned */
- while (--i >= 0)
- g_trash_stack_push (&compat_valloc_trash, amem + i * sys_page_size);
- }
- }
-#endif
- aligned_memory = g_trash_stack_pop (&compat_valloc_trash);
-#endif
- if (!aligned_memory)
- errno = err;
- return aligned_memory;
-}
-
-static void
-allocator_memfree (gsize memsize,
- gpointer mem)
-{
-#if HAVE_COMPLIANT_POSIX_MEMALIGN || HAVE_MEMALIGN || HAVE_VALLOC
- free (mem);
-#else
- mem_assert (memsize <= sys_page_size);
- g_trash_stack_push (&compat_valloc_trash, mem);
-#endif
-}
-
-static void
-mem_error (const char *format,
- ...)
-{
- const char *pname;
- va_list args;
- /* at least, put out "MEMORY-ERROR", in case we segfault during the rest of the function */
- fputs ("\n***MEMORY-ERROR***: ", stderr);
- pname = g_get_prgname();
- fprintf (stderr, "%s: GSlice: ", pname ? pname : "");
- va_start (args, format);
- vfprintf (stderr, format, args);
- va_end (args);
- fputs ("\n", stderr);
- abort();
- _exit (1);
-}
-
-/* --- g-slice memory checker tree --- */
-typedef size_t SmcKType; /* key type */
-typedef size_t SmcVType; /* value type */
-typedef struct {
- SmcKType key;
- SmcVType value;
-} SmcEntry;
-static void smc_tree_insert (SmcKType key,
- SmcVType value);
-static gboolean smc_tree_lookup (SmcKType key,
- SmcVType *value_p);
-static gboolean smc_tree_remove (SmcKType key);
-
-
-/* --- g-slice memory checker implementation --- */
-static void
-smc_notify_alloc (void *pointer,
- size_t size)
-{
- size_t adress = (size_t) pointer;
- if (pointer)
- smc_tree_insert (adress, size);
-}
-
-#if 0
-static void
-smc_notify_ignore (void *pointer)
-{
- size_t adress = (size_t) pointer;
- if (pointer)
- smc_tree_remove (adress);
-}
-#endif
-
-static int
-smc_notify_free (void *pointer,
- size_t size)
-{
- size_t adress = (size_t) pointer;
- SmcVType real_size;
- gboolean found_one;
-
- if (!pointer)
- return 1; /* ignore */
- found_one = smc_tree_lookup (adress, &real_size);
- if (!found_one)
- {
- fprintf (stderr, "GSlice: MemChecker: attempt to release non-allocated block: %p size=%" G_GSIZE_FORMAT "\n", pointer, size);
- return 0;
- }
- if (real_size != size && (real_size || size))
- {
- fprintf (stderr, "GSlice: MemChecker: attempt to release block with invalid size: %p size=%" G_GSIZE_FORMAT " invalid-size=%" G_GSIZE_FORMAT "\n", pointer, real_size, size);
- return 0;
- }
- if (!smc_tree_remove (adress))
- {
- fprintf (stderr, "GSlice: MemChecker: attempt to release non-allocated block: %p size=%" G_GSIZE_FORMAT "\n", pointer, size);
- return 0;
- }
- return 1; /* all fine */
-}
-
-/* --- g-slice memory checker tree implementation --- */
-#define SMC_TRUNK_COUNT (4093 /* 16381 */) /* prime, to distribute trunk collisions (big, allocated just once) */
-#define SMC_BRANCH_COUNT (511) /* prime, to distribute branch collisions */
-#define SMC_TRUNK_EXTENT (SMC_BRANCH_COUNT * 2039) /* key adress space per trunk, should distribute uniformly across BRANCH_COUNT */
-#define SMC_TRUNK_HASH(k) ((k / SMC_TRUNK_EXTENT) % SMC_TRUNK_COUNT) /* generate new trunk hash per megabyte (roughly) */
-#define SMC_BRANCH_HASH(k) (k % SMC_BRANCH_COUNT)
-
-typedef struct {
- SmcEntry *entries;
- unsigned int n_entries;
-} SmcBranch;
-
-static SmcBranch **smc_tree_root = NULL;
-
-static void
-smc_tree_abort (int errval)
-{
- const char *syserr = "unknown error";
-#if HAVE_STRERROR
- syserr = strerror (errval);
-#endif
- mem_error ("MemChecker: failure in debugging tree: %s", syserr);
-}
-
-static inline SmcEntry*
-smc_tree_branch_grow_L (SmcBranch *branch,
- unsigned int index)
-{
- unsigned int old_size = branch->n_entries * sizeof (branch->entries[0]);
- unsigned int new_size = old_size + sizeof (branch->entries[0]);
- SmcEntry *entry;
- mem_assert (index <= branch->n_entries);
- branch->entries = (SmcEntry*) realloc (branch->entries, new_size);
- if (!branch->entries)
- smc_tree_abort (errno);
- entry = branch->entries + index;
- g_memmove (entry + 1, entry, (branch->n_entries - index) * sizeof (entry[0]));
- branch->n_entries += 1;
- return entry;
-}
-
-static inline SmcEntry*
-smc_tree_branch_lookup_nearest_L (SmcBranch *branch,
- SmcKType key)
-{
- unsigned int n_nodes = branch->n_entries, offs = 0;
- SmcEntry *check = branch->entries;
- int cmp = 0;
- while (offs < n_nodes)
- {
- unsigned int i = (offs + n_nodes) >> 1;
- check = branch->entries + i;
- cmp = key < check->key ? -1 : key != check->key;
- if (cmp == 0)
- return check; /* return exact match */
- else if (cmp < 0)
- n_nodes = i;
- else /* (cmp > 0) */
- offs = i + 1;
- }
- /* check points at last mismatch, cmp > 0 indicates greater key */
- return cmp > 0 ? check + 1 : check; /* return insertion position for inexact match */
-}
-
-static void
-smc_tree_insert (SmcKType key,
- SmcVType value)
-{
- unsigned int ix0, ix1;
- SmcEntry *entry;
-
- g_mutex_lock (smc_tree_mutex);
- ix0 = SMC_TRUNK_HASH (key);
- ix1 = SMC_BRANCH_HASH (key);
- if (!smc_tree_root)
- {
- smc_tree_root = calloc (SMC_TRUNK_COUNT, sizeof (smc_tree_root[0]));
- if (!smc_tree_root)
- smc_tree_abort (errno);
- }
- if (!smc_tree_root[ix0])
- {
- smc_tree_root[ix0] = calloc (SMC_BRANCH_COUNT, sizeof (smc_tree_root[0][0]));
- if (!smc_tree_root[ix0])
- smc_tree_abort (errno);
- }
- entry = smc_tree_branch_lookup_nearest_L (&smc_tree_root[ix0][ix1], key);
- if (!entry || /* need create */
- entry >= smc_tree_root[ix0][ix1].entries + smc_tree_root[ix0][ix1].n_entries || /* need append */
- entry->key != key) /* need insert */
- entry = smc_tree_branch_grow_L (&smc_tree_root[ix0][ix1], entry - smc_tree_root[ix0][ix1].entries);
- entry->key = key;
- entry->value = value;
- g_mutex_unlock (smc_tree_mutex);
-}
-
-static gboolean
-smc_tree_lookup (SmcKType key,
- SmcVType *value_p)
-{
- SmcEntry *entry = NULL;
- unsigned int ix0 = SMC_TRUNK_HASH (key), ix1 = SMC_BRANCH_HASH (key);
- gboolean found_one = FALSE;
- *value_p = 0;
- g_mutex_lock (smc_tree_mutex);
- if (smc_tree_root && smc_tree_root[ix0])
- {
- entry = smc_tree_branch_lookup_nearest_L (&smc_tree_root[ix0][ix1], key);
- if (entry &&
- entry < smc_tree_root[ix0][ix1].entries + smc_tree_root[ix0][ix1].n_entries &&
- entry->key == key)
- {
- found_one = TRUE;
- *value_p = entry->value;
- }
- }
- g_mutex_unlock (smc_tree_mutex);
- return found_one;
-}
-
-static gboolean
-smc_tree_remove (SmcKType key)
-{
- unsigned int ix0 = SMC_TRUNK_HASH (key), ix1 = SMC_BRANCH_HASH (key);
- gboolean found_one = FALSE;
- g_mutex_lock (smc_tree_mutex);
- if (smc_tree_root && smc_tree_root[ix0])
- {
- SmcEntry *entry = smc_tree_branch_lookup_nearest_L (&smc_tree_root[ix0][ix1], key);
- if (entry &&
- entry < smc_tree_root[ix0][ix1].entries + smc_tree_root[ix0][ix1].n_entries &&
- entry->key == key)
- {
- unsigned int i = entry - smc_tree_root[ix0][ix1].entries;
- smc_tree_root[ix0][ix1].n_entries -= 1;
- g_memmove (entry, entry + 1, (smc_tree_root[ix0][ix1].n_entries - i) * sizeof (entry[0]));
- if (!smc_tree_root[ix0][ix1].n_entries)
- {
- /* avoid useless pressure on the memory system */
- free (smc_tree_root[ix0][ix1].entries);
- smc_tree_root[ix0][ix1].entries = NULL;
- }
- found_one = TRUE;
- }
- }
- g_mutex_unlock (smc_tree_mutex);
- return found_one;
-}
-
-#ifdef G_ENABLE_DEBUG
-void
-g_slice_debug_tree_statistics (void)
-{
- g_mutex_lock (smc_tree_mutex);
- if (smc_tree_root)
- {
- unsigned int i, j, t = 0, o = 0, b = 0, su = 0, ex = 0, en = 4294967295u;
- double tf, bf;
- for (i = 0; i < SMC_TRUNK_COUNT; i++)
- if (smc_tree_root[i])
- {
- t++;
- for (j = 0; j < SMC_BRANCH_COUNT; j++)
- if (smc_tree_root[i][j].n_entries)
- {
- b++;
- su += smc_tree_root[i][j].n_entries;
- en = MIN (en, smc_tree_root[i][j].n_entries);
- ex = MAX (ex, smc_tree_root[i][j].n_entries);
- }
- else if (smc_tree_root[i][j].entries)
- o++; /* formerly used, now empty */
- }
- en = b ? en : 0;
- tf = MAX (t, 1.0); /* max(1) to be a valid divisor */
- bf = MAX (b, 1.0); /* max(1) to be a valid divisor */
- fprintf (stderr, "GSlice: MemChecker: %u trunks, %u branches, %u old branches\n", t, b, o);
- fprintf (stderr, "GSlice: MemChecker: %f branches per trunk, %.2f%% utilization\n",
- b / tf,
- 100.0 - (SMC_BRANCH_COUNT - b / tf) / (0.01 * SMC_BRANCH_COUNT));
- fprintf (stderr, "GSlice: MemChecker: %f entries per branch, %u minimum, %u maximum\n",
- su / bf, en, ex);
- }
- else
- fprintf (stderr, "GSlice: MemChecker: root=NULL\n");
- g_mutex_unlock (smc_tree_mutex);
-
- /* sample statistics (beast + GSLice + 24h scripted core & GUI activity):
- * PID %CPU %MEM VSZ RSS COMMAND
- * 8887 30.3 45.8 456068 414856 beast-0.7.1 empty.bse
- * $ cat /proc/8887/statm # total-program-size resident-set-size shared-pages text/code data/stack library dirty-pages
- * 114017 103714 2354 344 0 108676 0
- * $ cat /proc/8887/status
- * Name: beast-0.7.1
- * VmSize: 456068 kB
- * VmLck: 0 kB
- * VmRSS: 414856 kB
- * VmData: 434620 kB
- * VmStk: 84 kB
- * VmExe: 1376 kB
- * VmLib: 13036 kB
- * VmPTE: 456 kB
- * Threads: 3
- * (gdb) print g_slice_debug_tree_statistics ()
- * GSlice: MemChecker: 422 trunks, 213068 branches, 0 old branches
- * GSlice: MemChecker: 504.900474 branches per trunk, 98.81% utilization
- * GSlice: MemChecker: 4.965039 entries per branch, 1 minimum, 37 maximum
- */
-}
-#endif /* G_ENABLE_DEBUG */
-
-#define __G_SLICE_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gslice.h b/navit/support/glib/gslice.h
deleted file mode 100644
index f9cc64426..000000000
--- a/navit/support/glib/gslice.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* GLIB sliced memory - fast threaded memory chunk allocator
- * Copyright (C) 2005 Tim Janik
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_SLICE_H__
-#define __G_SLICE_H__
-
-#ifndef __G_MEM_H__
-#error Include <glib.h> instead of <gslice.h>
-#endif
-
-#include <glib/gtypes.h>
-
-G_BEGIN_DECLS
-
-/* slices - fast allocation/release of small memory blocks
- */
-gpointer g_slice_alloc (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
-gpointer g_slice_alloc0 (gsize block_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
-gpointer g_slice_copy (gsize block_size,
- gconstpointer mem_block) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(1);
-void g_slice_free1 (gsize block_size,
- gpointer mem_block);
-void g_slice_free_chain_with_offset (gsize block_size,
- gpointer mem_chain,
- gsize next_offset);
-#define g_slice_new(type) ((type*) g_slice_alloc (sizeof (type)))
-#define g_slice_new0(type) ((type*) g_slice_alloc0 (sizeof (type)))
-/* MemoryBlockType *
- * g_slice_dup (MemoryBlockType,
- * MemoryBlockType *mem_block);
- * g_slice_free (MemoryBlockType,
- * MemoryBlockType *mem_block);
- * g_slice_free_chain (MemoryBlockType,
- * MemoryBlockType *first_chain_block,
- * memory_block_next_field);
- * pseudo prototypes for the macro
- * definitions following below.
- */
-
-/* we go through extra hoops to ensure type safety */
-#define g_slice_dup(type, mem) \
- (1 ? (type*) g_slice_copy (sizeof (type), (mem)) \
- : ((void) ((type*) 0 == (mem)), (type*) 0))
-#define g_slice_free(type, mem) do { \
- if (1) g_slice_free1 (sizeof (type), (mem)); \
- else (void) ((type*) 0 == (mem)); \
-} while (0)
-#define g_slice_free_chain(type, mem_chain, next) do { \
- if (1) g_slice_free_chain_with_offset (sizeof (type), \
- (mem_chain), G_STRUCT_OFFSET (type, next)); \
- else (void) ((type*) 0 == (mem_chain)); \
-} while (0)
-
-
-/* --- internal debugging API --- */
-typedef enum {
- G_SLICE_CONFIG_ALWAYS_MALLOC = 1,
- G_SLICE_CONFIG_BYPASS_MAGAZINES,
- G_SLICE_CONFIG_WORKING_SET_MSECS,
- G_SLICE_CONFIG_COLOR_INCREMENT,
- G_SLICE_CONFIG_CHUNK_SIZES,
- G_SLICE_CONFIG_CONTENTION_COUNTER
-} GSliceConfig;
-void g_slice_set_config (GSliceConfig ckey, gint64 value);
-gint64 g_slice_get_config (GSliceConfig ckey);
-gint64* g_slice_get_config_state (GSliceConfig ckey, gint64 address, guint *n_values);
-
-G_END_DECLS
-
-#endif /* __G_SLICE_H__ */
diff --git a/navit/support/glib/gslist.c b/navit/support/glib/gslist.c
deleted file mode 100644
index 0be54aaa2..000000000
--- a/navit/support/glib/gslist.c
+++ /dev/null
@@ -1,1088 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * MT safe
- */
-
-#include "config.h"
-
-#include "glib.h"
-#include "gslist.h"
-
-
-/**
- * SECTION:linked_lists_single
- * @title: Singly-Linked Lists
- * @short_description: linked lists containing integer values or
- * pointers to data, limited to iterating over the
- * list in one direction
- *
- * The #GSList structure and its associated functions provide a
- * standard singly-linked list data structure.
- *
- * Each element in the list contains a piece of data, together with a
- * pointer which links to the next element in the list. Using this
- * pointer it is possible to move through the list in one direction
- * only (unlike the <link
- * linkend="glib-Doubly-Linked-lists">Doubly-Linked Lists</link> which
- * allow movement in both directions).
- *
- * The data contained in each element can be either integer values, by
- * using one of the <link linkend="glib-Type-Conversion-Macros">Type
- * Conversion Macros</link>, or simply pointers to any type of data.
- *
- * List elements are allocated from the <link
- * linkend="glib-Memory-Slices">slice allocator</link>, which is more
- * efficient than allocating elements individually.
- *
- * Note that most of the #GSList functions expect to be passed a
- * pointer to the first element in the list. The functions which insert
- * elements return the new start of the list, which may have changed.
- *
- * There is no function to create a #GSList. %NULL is considered to be
- * the empty list so you simply set a #GSList* to %NULL.
- *
- * To add elements, use g_slist_append(), g_slist_prepend(),
- * g_slist_insert() and g_slist_insert_sorted().
- *
- * To remove elements, use g_slist_remove().
- *
- * To find elements in the list use g_slist_last(), g_slist_next(),
- * g_slist_nth(), g_slist_nth_data(), g_slist_find() and
- * g_slist_find_custom().
- *
- * To find the index of an element use g_slist_position() and
- * g_slist_index().
- *
- * To call a function for each element in the list use
- * g_slist_foreach().
- *
- * To free the entire list, use g_slist_free().
- **/
-
-/**
- * GSList:
- * @data: holds the element's data, which can be a pointer to any kind
- * of data, or any integer value using the <link
- * linkend="glib-Type-Conversion-Macros">Type Conversion
- * Macros</link>.
- * @next: contains the link to the next element in the list.
- *
- * The #GSList struct is used for each element in the singly-linked
- * list.
- **/
-
-/**
- * g_slist_next:
- * @slist: an element in a #GSList.
- * @Returns: the next element, or %NULL if there are no more elements.
- *
- * A convenience macro to get the next element in a #GSList.
- **/
-
-
-/**
- * g_slist_push_allocator:
- * @dummy: the #GAllocator to use when allocating #GSList elements.
- *
- * Sets the allocator to use to allocate #GSList elements. Use
- * g_slist_pop_allocator() to restore the previous allocator.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated: 2.10: It does nothing, since #GSList has been converted
- * to the <link linkend="glib-Memory-Slices">slice
- * allocator</link>
- **/
-void g_slist_push_allocator (gpointer dummy) { /* present for binary compat only */ }
-
-/**
- * g_slist_pop_allocator:
- *
- * Restores the previous #GAllocator, used when allocating #GSList
- * elements.
- *
- * Note that this function is not available if GLib has been compiled
- * with <option>--disable-mem-pools</option>
- *
- * Deprecated: 2.10: It does nothing, since #GSList has been converted
- * to the <link linkend="glib-Memory-Slices">slice
- * allocator</link>
- **/
-void g_slist_pop_allocator (void) { /* present for binary compat only */ }
-
-#define _g_slist_alloc0() g_slice_new0 (GSList)
-#define _g_slist_alloc() g_slice_new (GSList)
-#define _g_slist_free1(slist) g_slice_free (GSList, slist)
-
-/**
- * g_slist_alloc:
- * @Returns: a pointer to the newly-allocated #GSList element.
- *
- * Allocates space for one #GSList element. It is called by the
- * g_slist_append(), g_slist_prepend(), g_slist_insert() and
- * g_slist_insert_sorted() functions and so is rarely used on its own.
- **/
-GSList*
-g_slist_alloc (void)
-{
- return _g_slist_alloc0 ();
-}
-
-/**
- * g_slist_free:
- * @list: a #GSList
- *
- * Frees all of the memory used by a #GSList.
- * The freed elements are returned to the slice allocator.
- *
- * <note><para>
- * If list elements contain dynamically-allocated memory,
- * you should either use g_slist_free_full() or free them manually
- * first.
- * </para></note>
- */
-void
-g_slist_free (GSList *list)
-{
- g_slice_free_chain (GSList, list, next);
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-/**
- * g_slist_free_1:
- * @list: a #GSList element
- *
- * Frees one #GSList element.
- * It is usually used after g_slist_remove_link().
- */
-/**
- * g_slist_free1:
- *
- * A macro which does the same as g_slist_free_1().
- *
- * Since: 2.10
- **/
-void
-g_slist_free_1 (GSList *list)
-{
- _g_slist_free1 (list);
-}
-
-/**
- * g_slist_free_full:
- * @list: a pointer to a #GSList
- * @free_func: the function to be called to free each element's data
- *
- * Convenience method, which frees all the memory used by a #GSList, and
- * calls the specified destroy function on every element's data.
- *
- * Since: 2.28
- **/
-void
-g_slist_free_full (GSList *list,
- GDestroyNotify free_func)
-{
- g_slist_foreach (list, (GFunc) free_func, NULL);
- g_slist_free (list);
-}
-
-/**
- * g_slist_append:
- * @list: a #GSList
- * @data: the data for the new element
- *
- * Adds a new element on to the end of the list.
- *
- * <note><para>
- * The return value is the new start of the list, which may
- * have changed, so make sure you store the new value.
- * </para></note>
- *
- * <note><para>
- * Note that g_slist_append() has to traverse the entire list
- * to find the end, which is inefficient when adding multiple
- * elements. A common idiom to avoid the inefficiency is to prepend
- * the elements and reverse the list when all elements have been added.
- * </para></note>
- *
- * |[
- * /&ast; Notice that these are initialized to the empty list. &ast;/
- * GSList *list = NULL, *number_list = NULL;
- *
- * /&ast; This is a list of strings. &ast;/
- * list = g_slist_append (list, "first");
- * list = g_slist_append (list, "second");
- *
- * /&ast; This is a list of integers. &ast;/
- * number_list = g_slist_append (number_list, GINT_TO_POINTER (27));
- * number_list = g_slist_append (number_list, GINT_TO_POINTER (14));
- * ]|
- *
- * Returns: the new start of the #GSList
- */
-GSList*
-g_slist_append (GSList *list,
- gpointer data)
-{
- GSList *new_list;
- GSList *last;
-
- new_list = _g_slist_alloc ();
- new_list->data = data;
- new_list->next = NULL;
-
- if (list)
- {
- last = g_slist_last (list);
- /* g_assert (last != NULL); */
- last->next = new_list;
-
- return list;
- }
- else
- return new_list;
-}
-#endif
-
-/**
- * g_slist_prepend:
- * @list: a #GSList
- * @data: the data for the new element
- *
- * Adds a new element on to the start of the list.
- *
- * <note><para>
- * The return value is the new start of the list, which
- * may have changed, so make sure you store the new value.
- * </para></note>
- *
- * |[
- * /&ast; Notice that it is initialized to the empty list. &ast;/
- * GSList *list = NULL;
- * list = g_slist_prepend (list, "last");
- * list = g_slist_prepend (list, "first");
- * ]|
- *
- * Returns: the new start of the #GSList
- */
-GSList*
-g_slist_prepend (GSList *list,
- gpointer data)
-{
- GSList *new_list;
-
- new_list = _g_slist_alloc ();
- new_list->data = data;
- new_list->next = list;
-
- return new_list;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-/**
- * g_slist_insert:
- * @list: a #GSList
- * @data: the data for the new element
- * @position: the position to insert the element.
- * If this is negative, or is larger than the number
- * of elements in the list, the new element is added on
- * to the end of the list.
- *
- * Inserts a new element into the list at the given position.
- *
- * Returns: the new start of the #GSList
- */
-GSList*
-g_slist_insert (GSList *list,
- gpointer data,
- gint position)
-{
- GSList *prev_list;
- GSList *tmp_list;
- GSList *new_list;
-
- if (position < 0)
- return g_slist_append (list, data);
- else if (position == 0)
- return g_slist_prepend (list, data);
-
- new_list = _g_slist_alloc ();
- new_list->data = data;
-
- if (!list)
- {
- new_list->next = NULL;
- return new_list;
- }
-
- prev_list = NULL;
- tmp_list = list;
-
- while ((position-- > 0) && tmp_list)
- {
- prev_list = tmp_list;
- tmp_list = tmp_list->next;
- }
-
- if (prev_list)
- {
- new_list->next = prev_list->next;
- prev_list->next = new_list;
- }
- else
- {
- new_list->next = list;
- list = new_list;
- }
-
- return list;
-}
-
-
-/**
- * g_slist_insert_before:
- * @slist: a #GSList
- * @sibling: node to insert @data before
- * @data: data to put in the newly-inserted node
- *
- * Inserts a node before @sibling containing @data.
- *
- * Returns: the new head of the list.
- */
-GSList*
-g_slist_insert_before (GSList *slist,
- GSList *sibling,
- gpointer data)
-{
- if (!slist)
- {
- slist = _g_slist_alloc ();
- slist->data = data;
- slist->next = NULL;
- g_return_val_if_fail (sibling == NULL, slist);
- return slist;
- }
- else
- {
- GSList *node, *last = NULL;
-
- for (node = slist; node; last = node, node = last->next)
- if (node == sibling)
- break;
- if (!last)
- {
- node = _g_slist_alloc ();
- node->data = data;
- node->next = slist;
-
- return node;
- }
- else
- {
- node = _g_slist_alloc ();
- node->data = data;
- node->next = last->next;
- last->next = node;
-
- return slist;
- }
- }
-}
-
-
-/**
- * g_slist_concat:
- * @list1: a #GSList
- * @list2: the #GSList to add to the end of the first #GSList
- *
- * Adds the second #GSList onto the end of the first #GSList.
- * Note that the elements of the second #GSList are not copied.
- * They are used directly.
- *
- * Returns: the start of the new #GSList
- */
-GSList *
-g_slist_concat (GSList *list1, GSList *list2)
-{
- if (list2)
- {
- if (list1)
- g_slist_last (list1)->next = list2;
- else
- list1 = list2;
- }
-
- return list1;
-}
-
-/**
- * g_slist_remove:
- * @list: a #GSList
- * @data: the data of the element to remove
- *
- * Removes an element from a #GSList.
- * If two elements contain the same data, only the first is removed.
- * If none of the elements contain the data, the #GSList is unchanged.
- *
- * Returns: the new start of the #GSList
- */
-GSList*
-g_slist_remove (GSList *list,
- gconstpointer data)
-{
- GSList *tmp, *prev = NULL;
-
- tmp = list;
- while (tmp)
- {
- if (tmp->data == data)
- {
- if (prev)
- prev->next = tmp->next;
- else
- list = tmp->next;
-
- g_slist_free_1 (tmp);
- break;
- }
- prev = tmp;
- tmp = prev->next;
- }
-
- return list;
-}
-
-/**
- * g_slist_remove_all:
- * @list: a #GSList
- * @data: data to remove
- *
- * Removes all list nodes with data equal to @data.
- * Returns the new head of the list. Contrast with
- * g_slist_remove() which removes only the first node
- * matching the given data.
- *
- * Returns: new head of @list
- */
-GSList*
-g_slist_remove_all (GSList *list,
- gconstpointer data)
-{
- GSList *tmp, *prev = NULL;
-
- tmp = list;
- while (tmp)
- {
- if (tmp->data == data)
- {
- GSList *next = tmp->next;
-
- if (prev)
- prev->next = next;
- else
- list = next;
-
- g_slist_free_1 (tmp);
- tmp = next;
- }
- else
- {
- prev = tmp;
- tmp = prev->next;
- }
- }
-
- return list;
-}
-
-static inline GSList*
-_g_slist_remove_link (GSList *list,
- GSList *link)
-{
- GSList *tmp;
- GSList *prev;
-
- prev = NULL;
- tmp = list;
-
- while (tmp)
- {
- if (tmp == link)
- {
- if (prev)
- prev->next = tmp->next;
- if (list == tmp)
- list = list->next;
-
- tmp->next = NULL;
- break;
- }
-
- prev = tmp;
- tmp = tmp->next;
- }
-
- return list;
-}
-
-/**
- * g_slist_remove_link:
- * @list: a #GSList
- * @link_: an element in the #GSList
- *
- * Removes an element from a #GSList, without
- * freeing the element. The removed element's next
- * link is set to %NULL, so that it becomes a
- * self-contained list with one element.
- *
- * Returns: the new start of the #GSList, without the element
- */
-GSList*
-g_slist_remove_link (GSList *list,
- GSList *link_)
-{
- return _g_slist_remove_link (list, link_);
-}
-
-/**
- * g_slist_delete_link:
- * @list: a #GSList
- * @link_: node to delete
- *
- * Removes the node link_ from the list and frees it.
- * Compare this to g_slist_remove_link() which removes the node
- * without freeing it.
- *
- * Returns: the new head of @list
- */
-GSList*
-g_slist_delete_link (GSList *list,
- GSList *link_)
-{
- list = _g_slist_remove_link (list, link_);
- _g_slist_free1 (link_);
-
- return list;
-}
-
-/**
- * g_slist_copy:
- * @list: a #GSList
- *
- * Copies a #GSList.
- *
- * <note><para>
- * Note that this is a "shallow" copy. If the list elements
- * consist of pointers to data, the pointers are copied but
- * the actual data isn't.
- * </para></note>
- *
- * Returns: a copy of @list
- */
-GSList*
-g_slist_copy (GSList *list)
-{
- GSList *new_list = NULL;
-
- if (list)
- {
- GSList *last;
-
- new_list = _g_slist_alloc ();
- new_list->data = list->data;
- last = new_list;
- list = list->next;
- while (list)
- {
- last->next = _g_slist_alloc ();
- last = last->next;
- last->data = list->data;
- list = list->next;
- }
- last->next = NULL;
- }
-
- return new_list;
-}
-
-/**
- * g_slist_reverse:
- * @list: a #GSList
- *
- * Reverses a #GSList.
- *
- * Returns: the start of the reversed #GSList
- */
-GSList*
-g_slist_reverse (GSList *list)
-{
- GSList *prev = NULL;
-
- while (list)
- {
- GSList *next = list->next;
-
- list->next = prev;
-
- prev = list;
- list = next;
- }
-
- return prev;
-}
-
-/**
- * g_slist_nth:
- * @list: a #GSList
- * @n: the position of the element, counting from 0
- *
- * Gets the element at the given position in a #GSList.
- *
- * Returns: the element, or %NULL if the position is off
- * the end of the #GSList
- */
-GSList*
-g_slist_nth (GSList *list,
- guint n)
-{
- while (n-- > 0 && list)
- list = list->next;
-
- return list;
-}
-
-/**
- * g_slist_nth_data:
- * @list: a #GSList
- * @n: the position of the element
- *
- * Gets the data of the element at the given position.
- *
- * Returns: the element's data, or %NULL if the position
- * is off the end of the #GSList
- */
-gpointer
-g_slist_nth_data (GSList *list,
- guint n)
-{
- while (n-- > 0 && list)
- list = list->next;
-
- return list ? list->data : NULL;
-}
-
-/**
- * g_slist_find:
- * @list: a #GSList
- * @data: the element data to find
- *
- * Finds the element in a #GSList which
- * contains the given data.
- *
- * Returns: the found #GSList element,
- * or %NULL if it is not found
- */
-GSList*
-g_slist_find (GSList *list,
- gconstpointer data)
-{
- while (list)
- {
- if (list->data == data)
- break;
- list = list->next;
- }
-
- return list;
-}
-
-/**
- * g_slist_find_custom:
- * @list: a #GSList
- * @data: user data passed to the function
- * @func: the function to call for each element.
- * It should return 0 when the desired element is found
- *
- * Finds an element in a #GSList, using a supplied function to
- * find the desired element. It iterates over the list, calling
- * the given function which should return 0 when the desired
- * element is found. The function takes two #gconstpointer arguments,
- * the #GSList element's data as the first argument and the
- * given user data.
- *
- * Returns: the found #GSList element, or %NULL if it is not found
- */
-GSList*
-g_slist_find_custom (GSList *list,
- gconstpointer data,
- GCompareFunc func)
-{
- g_return_val_if_fail (func != NULL, list);
-
- while (list)
- {
- if (! func (list->data, data))
- return list;
- list = list->next;
- }
-
- return NULL;
-}
-
-/**
- * g_slist_position:
- * @list: a #GSList
- * @llink: an element in the #GSList
- *
- * Gets the position of the given element
- * in the #GSList (starting from 0).
- *
- * Returns: the position of the element in the #GSList,
- * or -1 if the element is not found
- */
-gint
-g_slist_position (GSList *list,
- GSList *llink)
-{
- gint i;
-
- i = 0;
- while (list)
- {
- if (list == llink)
- return i;
- i++;
- list = list->next;
- }
-
- return -1;
-}
-
-/**
- * g_slist_index:
- * @list: a #GSList
- * @data: the data to find
- *
- * Gets the position of the element containing
- * the given data (starting from 0).
- *
- * Returns: the index of the element containing the data,
- * or -1 if the data is not found
- */
-gint
-g_slist_index (GSList *list,
- gconstpointer data)
-{
- gint i;
-
- i = 0;
- while (list)
- {
- if (list->data == data)
- return i;
- i++;
- list = list->next;
- }
-
- return -1;
-}
-
-/**
- * g_slist_last:
- * @list: a #GSList
- *
- * Gets the last element in a #GSList.
- *
- * <note><para>
- * This function iterates over the whole list.
- * </para></note>
- *
- * Returns: the last element in the #GSList,
- * or %NULL if the #GSList has no elements
- */
-GSList*
-g_slist_last (GSList *list)
-{
- if (list)
- {
- while (list->next)
- list = list->next;
- }
-
- return list;
-}
-
-/**
- * g_slist_length:
- * @list: a #GSList
- *
- * Gets the number of elements in a #GSList.
- *
- * <note><para>
- * This function iterates over the whole list to
- * count its elements.
- * </para></note>
- *
- * Returns: the number of elements in the #GSList
- */
-guint
-g_slist_length (GSList *list)
-{
- guint length;
-
- length = 0;
- while (list)
- {
- length++;
- list = list->next;
- }
-
- return length;
-}
-
-/**
- * g_slist_foreach:
- * @list: a #GSList
- * @func: the function to call with each element's data
- * @user_data: user data to pass to the function
- *
- * Calls a function for each element of a #GSList.
- */
-void
-g_slist_foreach (GSList *list,
- GFunc func,
- gpointer user_data)
-{
- while (list)
- {
- GSList *next = list->next;
- (*func) (list->data, user_data);
- list = next;
- }
-}
-
-static GSList*
-g_slist_insert_sorted_real (GSList *list,
- gpointer data,
- GFunc func,
- gpointer user_data)
-{
- GSList *tmp_list = list;
- GSList *prev_list = NULL;
- GSList *new_list;
- gint cmp;
-
- g_return_val_if_fail (func != NULL, list);
-
- if (!list)
- {
- new_list = _g_slist_alloc ();
- new_list->data = data;
- new_list->next = NULL;
- return new_list;
- }
-
- cmp = ((GCompareDataFunc) func) (data, tmp_list->data, user_data);
-
- while ((tmp_list->next) && (cmp > 0))
- {
- prev_list = tmp_list;
- tmp_list = tmp_list->next;
-
- cmp = ((GCompareDataFunc) func) (data, tmp_list->data, user_data);
- }
-
- new_list = _g_slist_alloc ();
- new_list->data = data;
-
- if ((!tmp_list->next) && (cmp > 0))
- {
- tmp_list->next = new_list;
- new_list->next = NULL;
- return list;
- }
-
- if (prev_list)
- {
- prev_list->next = new_list;
- new_list->next = tmp_list;
- return list;
- }
- else
- {
- new_list->next = list;
- return new_list;
- }
-}
-
-/**
- * g_slist_insert_sorted:
- * @list: a #GSList
- * @data: the data for the new element
- * @func: the function to compare elements in the list.
- * It should return a number > 0 if the first parameter
- * comes after the second parameter in the sort order.
- *
- * Inserts a new element into the list, using the given
- * comparison function to determine its position.
- *
- * Returns: the new start of the #GSList
- */
-GSList*
-g_slist_insert_sorted (GSList *list,
- gpointer data,
- GCompareFunc func)
-{
- return g_slist_insert_sorted_real (list, data, (GFunc) func, NULL);
-}
-
-/**
- * g_slist_insert_sorted_with_data:
- * @list: a #GSList
- * @data: the data for the new element
- * @func: the function to compare elements in the list.
- * It should return a number > 0 if the first parameter
- * comes after the second parameter in the sort order.
- * @user_data: data to pass to comparison function
- *
- * Inserts a new element into the list, using the given
- * comparison function to determine its position.
- *
- * Returns: the new start of the #GSList
- *
- * Since: 2.10
- */
-GSList*
-g_slist_insert_sorted_with_data (GSList *list,
- gpointer data,
- GCompareDataFunc func,
- gpointer user_data)
-{
- return g_slist_insert_sorted_real (list, data, (GFunc) func, user_data);
-}
-
-static GSList *
-g_slist_sort_merge (GSList *l1,
- GSList *l2,
- GFunc compare_func,
- gpointer user_data)
-{
- GSList list, *l;
- gint cmp;
-
- l=&list;
-
- while (l1 && l2)
- {
- cmp = ((GCompareDataFunc) compare_func) (l1->data, l2->data, user_data);
-
- if (cmp <= 0)
- {
- l=l->next=l1;
- l1=l1->next;
- }
- else
- {
- l=l->next=l2;
- l2=l2->next;
- }
- }
- l->next= l1 ? l1 : l2;
-
- return list.next;
-}
-
-static GSList *
-g_slist_sort_real (GSList *list,
- GFunc compare_func,
- gpointer user_data)
-{
- GSList *l1, *l2;
-
- if (!list)
- return NULL;
- if (!list->next)
- return list;
-
- l1 = list;
- l2 = list->next;
-
- while ((l2 = l2->next) != NULL)
- {
- if ((l2 = l2->next) == NULL)
- break;
- l1=l1->next;
- }
- l2 = l1->next;
- l1->next = NULL;
-
- return g_slist_sort_merge (g_slist_sort_real (list, compare_func, user_data),
- g_slist_sort_real (l2, compare_func, user_data),
- compare_func,
- user_data);
-}
-
-/**
- * g_slist_sort:
- * @list: a #GSList
- * @compare_func: the comparison function used to sort the #GSList.
- * This function is passed the data from 2 elements of the #GSList
- * and should return 0 if they are equal, a negative value if the
- * first element comes before the second, or a positive value if
- * the first element comes after the second.
- *
- * Sorts a #GSList using the given comparison function.
- *
- * Returns: the start of the sorted #GSList
- */
-GSList *
-g_slist_sort (GSList *list,
- GCompareFunc compare_func)
-{
- return g_slist_sort_real (list, (GFunc) compare_func, NULL);
-}
-
-/**
- * g_slist_sort_with_data:
- * @list: a #GSList
- * @compare_func: comparison function
- * @user_data: data to pass to comparison function
- *
- * Like g_slist_sort(), but the sort function accepts a user data argument.
- *
- * Returns: new head of the list
- */
-GSList *
-g_slist_sort_with_data (GSList *list,
- GCompareDataFunc compare_func,
- gpointer user_data)
-{
- return g_slist_sort_real (list, (GFunc) compare_func, user_data);
-}
-#endif
diff --git a/navit/support/glib/gslist.h b/navit/support/glib/gslist.h
deleted file mode 100644
index 89c76a88c..000000000
--- a/navit/support/glib/gslist.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_SLIST_H__
-#define __G_SLIST_H__
-
-/* #include <glib/gmem.h> */
-
-G_BEGIN_DECLS
-
-typedef struct _GSList GSList;
-
-struct _GSList
-{
- gpointer data;
- GSList *next;
-};
-
-/* Singly linked lists
- */
-GSList* g_slist_alloc (void) G_GNUC_WARN_UNUSED_RESULT;
-void g_slist_free (GSList *list);
-void g_slist_free_1 (GSList *list);
-#define g_slist_free1 g_slist_free_1
-void g_slist_free_full (GSList *list,
- GDestroyNotify free_func);
-GSList* g_slist_append (GSList *list,
- gpointer data) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_prepend (GSList *list,
- gpointer data) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_insert (GSList *list,
- gpointer data,
- gint position) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_insert_sorted (GSList *list,
- gpointer data,
- GCompareFunc func) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_insert_sorted_with_data (GSList *list,
- gpointer data,
- GCompareDataFunc func,
- gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_insert_before (GSList *slist,
- GSList *sibling,
- gpointer data) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_concat (GSList *list1,
- GSList *list2) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_remove (GSList *list,
- gconstpointer data) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_remove_all (GSList *list,
- gconstpointer data) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_remove_link (GSList *list,
- GSList *link_) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_delete_link (GSList *list,
- GSList *link_) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_reverse (GSList *list) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_copy (GSList *list) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_nth (GSList *list,
- guint n);
-GSList* g_slist_find (GSList *list,
- gconstpointer data);
-GSList* g_slist_find_custom (GSList *list,
- gconstpointer data,
- GCompareFunc func);
-gint g_slist_position (GSList *list,
- GSList *llink);
-gint g_slist_index (GSList *list,
- gconstpointer data);
-GSList* g_slist_last (GSList *list);
-guint g_slist_length (GSList *list);
-void g_slist_foreach (GSList *list,
- GFunc func,
- gpointer user_data);
-GSList* g_slist_sort (GSList *list,
- GCompareFunc compare_func) G_GNUC_WARN_UNUSED_RESULT;
-GSList* g_slist_sort_with_data (GSList *list,
- GCompareDataFunc compare_func,
- gpointer user_data) G_GNUC_WARN_UNUSED_RESULT;
-gpointer g_slist_nth_data (GSList *list,
- guint n);
-
-#define g_slist_next(slist) ((slist) ? (((GSList *)(slist))->next) : NULL)
-
-#ifndef G_DISABLE_DEPRECATED
-void g_slist_push_allocator (gpointer dummy);
-void g_slist_pop_allocator (void);
-#endif
-
-G_END_DECLS
-
-#endif /* __G_SLIST_H__ */
diff --git a/navit/support/glib/gstrfuncs.c b/navit/support/glib/gstrfuncs.c
deleted file mode 100644
index 29b539b70..000000000
--- a/navit/support/glib/gstrfuncs.c
+++ /dev/null
@@ -1,3133 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * MT safe
- */
-
-#include "config.h"
-
-#define _GNU_SOURCE /* For stpcpy */
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <locale.h>
-#include <errno.h>
-#include <ctype.h> /* For tolower() */
-#if !defined (HAVE_STRSIGNAL) || !defined(NO_SYS_SIGLIST_DECL)
-#include <signal.h>
-#endif
-
-#include "glib.h"
-#include "gprintf.h"
-#include "gprintfint.h"
-#include "glibintl.h"
-
-#include "galias.h"
-#include "gslist.h"
-
-#ifdef G_OS_WIN32
-#include <windows.h>
-#endif
-
-/* do not include <unistd.h> in this place since it
- * interferes with g_strsignal() on some OSes
- */
-
-static const guint16 ascii_table_data[256] = {
- 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
- 0x004, 0x104, 0x104, 0x004, 0x104, 0x104, 0x004, 0x004,
- 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
- 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004, 0x004,
- 0x140, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
- 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
- 0x459, 0x459, 0x459, 0x459, 0x459, 0x459, 0x459, 0x459,
- 0x459, 0x459, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
- 0x0d0, 0x653, 0x653, 0x653, 0x653, 0x653, 0x653, 0x253,
- 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253,
- 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253, 0x253,
- 0x253, 0x253, 0x253, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x0d0,
- 0x0d0, 0x473, 0x473, 0x473, 0x473, 0x473, 0x473, 0x073,
- 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073,
- 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073, 0x073,
- 0x073, 0x073, 0x073, 0x0d0, 0x0d0, 0x0d0, 0x0d0, 0x004
- /* the upper 128 are all zeroes */
-};
-
-const guint16 * const g_ascii_table = ascii_table_data;
-
-gchar*
-g_strdup (const gchar *str)
-{
- gchar *new_str;
- gsize length;
-
- if (str)
- {
- length = strlen (str) + 1;
- new_str = g_new (char, length);
- memcpy (new_str, str, length);
- }
- else
- new_str = NULL;
-
- return new_str;
-}
-
-gpointer
-g_memdup (gconstpointer mem,
- guint byte_size)
-{
- gpointer new_mem;
-
- if (mem)
- {
- new_mem = g_malloc (byte_size);
- memcpy (new_mem, mem, byte_size);
- }
- else
- new_mem = NULL;
-
- return new_mem;
-}
-
-/**
- * g_strndup:
- * @str: the string to duplicate
- * @n: the maximum number of bytes to copy from @str
- *
- * Duplicates the first @n bytes of a string, returning a newly-allocated
- * buffer @n + 1 bytes long which will always be nul-terminated.
- * If @str is less than @n bytes long the buffer is padded with nuls.
- * If @str is %NULL it returns %NULL.
- * The returned value should be freed when no longer needed.
- *
- * <note><para>
- * To copy a number of characters from a UTF-8 encoded string, use
- * g_utf8_strncpy() instead.
- * </para></note>
- *
- * Returns: a newly-allocated buffer containing the first @n bytes
- * of @str, nul-terminated
- */
-gchar*
-g_strndup (const gchar *str,
- gsize n)
-{
- gchar *new_str;
-
- if (str)
- {
- new_str = g_new (gchar, n + 1);
- strncpy (new_str, str, n);
- new_str[n] = '\0';
- }
- else
- new_str = NULL;
-
- return new_str;
-}
-
-/**
- * g_strnfill:
- * @length: the length of the new string
- * @fill_char: the byte to fill the string with
- *
- * Creates a new string @length bytes long filled with @fill_char.
- * The returned string should be freed when no longer needed.
- *
- * Returns: a newly-allocated string filled the @fill_char
- */
-gchar*
-g_strnfill (gsize length,
- gchar fill_char)
-{
- gchar *str;
-
- str = g_new (gchar, length + 1);
- memset (str, (guchar)fill_char, length);
- str[length] = '\0';
-
- return str;
-}
-
-/**
- * g_stpcpy:
- * @dest: destination buffer.
- * @src: source string.
- *
- * Copies a nul-terminated string into the dest buffer, include the
- * trailing nul, and return a pointer to the trailing nul byte.
- * This is useful for concatenating multiple strings together
- * without having to repeatedly scan for the end.
- *
- * Return value: a pointer to trailing nul byte.
- **/
-gchar *
-g_stpcpy (gchar *dest,
- const gchar *src)
-{
-#ifdef HAVE_STPCPY
- g_return_val_if_fail (dest != NULL, NULL);
- g_return_val_if_fail (src != NULL, NULL);
- return stpcpy (dest, src);
-#else
- register gchar *d = dest;
- register const gchar *s = src;
-
- g_return_val_if_fail (dest != NULL, NULL);
- g_return_val_if_fail (src != NULL, NULL);
- do
- *d++ = *s;
- while (*s++ != '\0');
-
- return d - 1;
-#endif
-}
-
-gchar*
-g_strdup_vprintf (const gchar *format,
- va_list args)
-{
- gchar *string = NULL;
-
- g_vasprintf (&string, format, args);
-
- return string;
-}
-
-gchar*
-g_strdup_printf (const gchar *format,
- ...)
-{
- gchar *buffer;
- va_list args;
-
- va_start (args, format);
- buffer = g_strdup_vprintf (format, args);
- va_end (args);
-
- return buffer;
-}
-
-gchar*
-g_strconcat (const gchar *string1, ...)
-{
- gsize l;
- va_list args;
- gchar *s;
- gchar *concat;
- gchar *ptr;
-
- if (!string1)
- return NULL;
-
- l = 1 + strlen (string1);
- va_start (args, string1);
- s = va_arg (args, gchar*);
- while (s)
- {
- l += strlen (s);
- s = va_arg (args, gchar*);
- }
- va_end (args);
-
- concat = g_new (gchar, l);
- ptr = concat;
-
- ptr = g_stpcpy (ptr, string1);
- va_start (args, string1);
- s = va_arg (args, gchar*);
- while (s)
- {
- ptr = g_stpcpy (ptr, s);
- s = va_arg (args, gchar*);
- }
- va_end (args);
-
- return concat;
-}
-
-/**
- * g_strtod:
- * @nptr: the string to convert to a numeric value.
- * @endptr: if non-%NULL, it returns the character after
- * the last character used in the conversion.
- *
- * Converts a string to a #gdouble value.
- * It calls the standard strtod() function to handle the conversion, but
- * if the string is not completely converted it attempts the conversion
- * again with g_ascii_strtod(), and returns the best match.
- *
- * This function should seldomly be used. The normal situation when reading
- * numbers not for human consumption is to use g_ascii_strtod(). Only when
- * you know that you must expect both locale formatted and C formatted numbers
- * should you use this. Make sure that you don't pass strings such as comma
- * separated lists of values, since the commas may be interpreted as a decimal
- * point in some locales, causing unexpected results.
- *
- * Return value: the #gdouble value.
- **/
-gdouble
-g_strtod (const gchar *nptr,
- gchar **endptr)
-{
- gchar *fail_pos_1;
- gchar *fail_pos_2;
- gdouble val_1;
- gdouble val_2 = 0;
-
- g_return_val_if_fail (nptr != NULL, 0);
-
- fail_pos_1 = NULL;
- fail_pos_2 = NULL;
-
- val_1 = strtod (nptr, &fail_pos_1);
-
- if (fail_pos_1 && fail_pos_1[0] != 0)
- val_2 = g_ascii_strtod (nptr, &fail_pos_2);
-
- if (!fail_pos_1 || fail_pos_1[0] == 0 || fail_pos_1 >= fail_pos_2)
- {
- if (endptr)
- *endptr = fail_pos_1;
- return val_1;
- }
- else
- {
- if (endptr)
- *endptr = fail_pos_2;
- return val_2;
- }
-}
-
-/**
- * g_ascii_strtod:
- * @nptr: the string to convert to a numeric value.
- * @endptr: if non-%NULL, it returns the character after
- * the last character used in the conversion.
- *
- * Converts a string to a #gdouble value.
- *
- * This function behaves like the standard strtod() function
- * does in the C locale. It does this without actually changing
- * the current locale, since that would not be thread-safe.
- * A limitation of the implementation is that this function
- * will still accept localized versions of infinities and NANs.
- *
- * This function is typically used when reading configuration
- * files or other non-user input that should be locale independent.
- * To handle input from the user you should normally use the
- * locale-sensitive system strtod() function.
- *
- * To convert from a #gdouble to a string in a locale-insensitive
- * way, use g_ascii_dtostr().
- *
- * If the correct value would cause overflow, plus or minus %HUGE_VAL
- * is returned (according to the sign of the value), and %ERANGE is
- * stored in %errno. If the correct value would cause underflow,
- * zero is returned and %ERANGE is stored in %errno.
- *
- * This function resets %errno before calling strtod() so that
- * you can reliably detect overflow and underflow.
- *
- * Return value: the #gdouble value.
- **/
-gdouble
-g_ascii_strtod (const gchar *nptr,
- gchar **endptr)
-{
- gchar *fail_pos;
- gdouble val;
- struct lconv *locale_data;
- const char *decimal_point;
- int decimal_point_len;
- const char *p, *decimal_point_pos;
- const char *end = NULL; /* Silence gcc */
- int strtod_errno;
-
- g_return_val_if_fail (nptr != NULL, 0);
-
- fail_pos = NULL;
-
-#ifdef HAVE_API_ANDROID
- decimal_point = ".";
- decimal_point_len = 1;
-#else
- locale_data = localeconv ();
- decimal_point = locale_data->decimal_point;
- decimal_point_len = strlen (decimal_point);
-#endif
-
-#if NOT_NEEDED_FOR_NAVIT
- g_assert (decimal_point_len != 0);
-#endif /* NOT_NEEDED_FOR_NAVIT */
-
- decimal_point_pos = NULL;
- end = NULL;
-
- if (decimal_point[0] != '.' ||
- decimal_point[1] != 0)
- {
- p = nptr;
- /* Skip leading space */
- while (g_ascii_isspace (*p))
- p++;
-
- /* Skip leading optional sign */
- if (*p == '+' || *p == '-')
- p++;
-
- if (p[0] == '0' &&
- (p[1] == 'x' || p[1] == 'X'))
- {
- p += 2;
- /* HEX - find the (optional) decimal point */
-
- while (g_ascii_isxdigit (*p))
- p++;
-
- if (*p == '.')
- decimal_point_pos = p++;
-
- while (g_ascii_isxdigit (*p))
- p++;
-
- if (*p == 'p' || *p == 'P')
- p++;
- if (*p == '+' || *p == '-')
- p++;
- while (g_ascii_isdigit (*p))
- p++;
-
- end = p;
- }
- else if (g_ascii_isdigit (*p) || *p == '.')
- {
- while (g_ascii_isdigit (*p))
- p++;
-
- if (*p == '.')
- decimal_point_pos = p++;
-
- while (g_ascii_isdigit (*p))
- p++;
-
- if (*p == 'e' || *p == 'E')
- p++;
- if (*p == '+' || *p == '-')
- p++;
- while (g_ascii_isdigit (*p))
- p++;
-
- end = p;
- }
- /* For the other cases, we need not convert the decimal point */
- }
-
- if (decimal_point_pos)
- {
- char *copy, *c;
-
- /* We need to convert the '.' to the locale specific decimal point */
- copy = g_malloc (end - nptr + 1 + decimal_point_len);
-
- c = copy;
- memcpy (c, nptr, decimal_point_pos - nptr);
- c += decimal_point_pos - nptr;
- memcpy (c, decimal_point, decimal_point_len);
- c += decimal_point_len;
- memcpy (c, decimal_point_pos + 1, end - (decimal_point_pos + 1));
- c += end - (decimal_point_pos + 1);
- *c = 0;
-
- errno = 0;
- val = strtod (copy, &fail_pos);
- strtod_errno = errno;
-
- if (fail_pos)
- {
- if (fail_pos - copy > decimal_point_pos - nptr)
- fail_pos = (char *)nptr + (fail_pos - copy) - (decimal_point_len - 1);
- else
- fail_pos = (char *)nptr + (fail_pos - copy);
- }
-
- g_free (copy);
-
- }
- else if (end)
- {
- char *copy;
-
- copy = g_malloc (end - (char *)nptr + 1);
- memcpy (copy, nptr, end - nptr);
- *(copy + (end - (char *)nptr)) = 0;
-
- errno = 0;
- val = strtod (copy, &fail_pos);
- strtod_errno = errno;
-
- if (fail_pos)
- {
- fail_pos = (char *)nptr + (fail_pos - copy);
- }
-
- g_free (copy);
- }
- else
- {
- errno = 0;
- val = strtod (nptr, &fail_pos);
- strtod_errno = errno;
- }
-
- if (endptr)
- *endptr = fail_pos;
-
- errno = strtod_errno;
-
- return val;
-}
-
-
-/**
- * g_ascii_dtostr:
- * @buffer: A buffer to place the resulting string in
- * @buf_len: The length of the buffer.
- * @d: The #gdouble to convert
- *
- * Converts a #gdouble to a string, using the '.' as
- * decimal point.
- *
- * This functions generates enough precision that converting
- * the string back using g_ascii_strtod() gives the same machine-number
- * (on machines with IEEE compatible 64bit doubles). It is
- * guaranteed that the size of the resulting string will never
- * be larger than @G_ASCII_DTOSTR_BUF_SIZE bytes.
- *
- * Return value: The pointer to the buffer with the converted string.
- **/
-gchar *
-g_ascii_dtostr (gchar *buffer,
- gint buf_len,
- gdouble d)
-{
- return g_ascii_formatd (buffer, buf_len, "%.17g", d);
-}
-
-/**
- * g_ascii_formatd:
- * @buffer: A buffer to place the resulting string in
- * @buf_len: The length of the buffer.
- * @format: The printf()-style format to use for the
- * code to use for converting.
- * @d: The #gdouble to convert
- *
- * Converts a #gdouble to a string, using the '.' as
- * decimal point. To format the number you pass in
- * a printf()-style format string. Allowed conversion
- * specifiers are 'e', 'E', 'f', 'F', 'g' and 'G'.
- *
- * If you just want to want to serialize the value into a
- * string, use g_ascii_dtostr().
- *
- * Return value: The pointer to the buffer with the converted string.
- **/
-gchar *
-g_ascii_formatd (gchar *buffer,
- gint buf_len,
- const gchar *format,
- gdouble d)
-{
- struct lconv *locale_data;
- const char *decimal_point;
- int decimal_point_len;
- gchar *p;
- int rest_len;
- gchar format_char;
-
- g_return_val_if_fail (buffer != NULL, NULL);
- g_return_val_if_fail (format[0] == '%', NULL);
- g_return_val_if_fail (strpbrk (format + 1, "'l%") == NULL, NULL);
-
- format_char = format[strlen (format) - 1];
-
- g_return_val_if_fail (format_char == 'e' || format_char == 'E' ||
- format_char == 'f' || format_char == 'F' ||
- format_char == 'g' || format_char == 'G',
- NULL);
-
- if (format[0] != '%')
- return NULL;
-
- if (strpbrk (format + 1, "'l%"))
- return NULL;
-
- if (!(format_char == 'e' || format_char == 'E' ||
- format_char == 'f' || format_char == 'F' ||
- format_char == 'g' || format_char == 'G'))
- return NULL;
-
-
- _g_snprintf (buffer, buf_len, format, d);
-
-#ifdef HAVE_API_ANDROID
- decimal_point = ".";
- decimal_point_len = 1;
-#else
- locale_data = localeconv ();
- decimal_point = locale_data->decimal_point;
- decimal_point_len = strlen (decimal_point);
-#endif
-
-#if NOT_NEEDED_FOR_NAVIT
- g_assert (decimal_point_len != 0);
-#endif /* NOT_NEEDED_FOR_NAVIT */
-
- if (decimal_point[0] != '.' ||
- decimal_point[1] != 0)
- {
- p = buffer;
-
- while (g_ascii_isspace (*p))
- p++;
-
- if (*p == '+' || *p == '-')
- p++;
-
- while (isdigit ((guchar)*p))
- p++;
-
- if (strncmp (p, decimal_point, decimal_point_len) == 0)
- {
- *p = '.';
- p++;
- if (decimal_point_len > 1)
- {
- rest_len = strlen (p + (decimal_point_len-1));
- memmove (p, p + (decimal_point_len-1), rest_len);
- p[rest_len] = 0;
- }
- }
- }
-
- return buffer;
-}
-
-static guint64
-g_parse_long_long (const gchar *nptr,
- const gchar **endptr,
- guint base,
- gboolean *negative)
-{
- /* this code is based on on the strtol(3) code from GNU libc released under
- * the GNU Lesser General Public License.
- *
- * Copyright (C) 1991,92,94,95,96,97,98,99,2000,01,02
- * Free Software Foundation, Inc.
- */
-#define ISSPACE(c) ((c) == ' ' || (c) == '\f' || (c) == '\n' || \
- (c) == '\r' || (c) == '\t' || (c) == '\v')
-#define ISUPPER(c) ((c) >= 'A' && (c) <= 'Z')
-#define ISLOWER(c) ((c) >= 'a' && (c) <= 'z')
-#define ISALPHA(c) (ISUPPER (c) || ISLOWER (c))
-#define TOUPPER(c) (ISLOWER (c) ? (c) - 'a' + 'A' : (c))
-#define TOLOWER(c) (ISUPPER (c) ? (c) - 'A' + 'a' : (c))
- gboolean overflow;
- guint64 cutoff;
- guint64 cutlim;
- guint64 ui64;
- const gchar *s, *save;
- guchar c;
-
- g_return_val_if_fail (nptr != NULL, 0);
-
- *negative = FALSE;
- if (base == 1 || base > 36)
- {
- errno = EINVAL;
- if (endptr)
- *endptr = nptr;
- return 0;
- }
-
- save = s = nptr;
-
- /* Skip white space. */
- while (ISSPACE (*s))
- ++s;
-
- if (G_UNLIKELY (!*s))
- goto noconv;
-
- /* Check for a sign. */
- if (*s == '-')
- {
- *negative = TRUE;
- ++s;
- }
- else if (*s == '+')
- ++s;
-
- /* Recognize number prefix and if BASE is zero, figure it out ourselves. */
- if (*s == '0')
- {
- if ((base == 0 || base == 16) && TOUPPER (s[1]) == 'X')
- {
- s += 2;
- base = 16;
- }
- else if (base == 0)
- base = 8;
- }
- else if (base == 0)
- base = 10;
-
- /* Save the pointer so we can check later if anything happened. */
- save = s;
- cutoff = G_MAXUINT64 / base;
- cutlim = G_MAXUINT64 % base;
-
- overflow = FALSE;
- ui64 = 0;
- c = *s;
- for (; c; c = *++s)
- {
- if (c >= '0' && c <= '9')
- c -= '0';
- else if (ISALPHA (c))
- c = TOUPPER (c) - 'A' + 10;
- else
- break;
- if (c >= base)
- break;
- /* Check for overflow. */
- if (ui64 > cutoff || (ui64 == cutoff && c > cutlim))
- overflow = TRUE;
- else
- {
- ui64 *= base;
- ui64 += c;
- }
- }
-
- /* Check if anything actually happened. */
- if (s == save)
- goto noconv;
-
- /* Store in ENDPTR the address of one character
- past the last character we converted. */
- if (endptr)
- *endptr = s;
-
- if (G_UNLIKELY (overflow))
- {
- errno = ERANGE;
- return G_MAXUINT64;
- }
-
- return ui64;
-
- noconv:
- /* We must handle a special case here: the base is 0 or 16 and the
- first two characters are '0' and 'x', but the rest are no
- hexadecimal digits. This is no error case. We return 0 and
- ENDPTR points to the `x`. */
- if (endptr)
- {
- if (save - nptr >= 2 && TOUPPER (save[-1]) == 'X'
- && save[-2] == '0')
- *endptr = &save[-1];
- else
- /* There was no number to convert. */
- *endptr = nptr;
- }
- return 0;
-}
-
-/**
- * g_ascii_strtoull:
- * @nptr: the string to convert to a numeric value.
- * @endptr: if non-%NULL, it returns the character after
- * the last character used in the conversion.
- * @base: to be used for the conversion, 2..36 or 0
- *
- * Converts a string to a #guint64 value.
- * This function behaves like the standard strtoull() function
- * does in the C locale. It does this without actually
- * changing the current locale, since that would not be
- * thread-safe.
- *
- * This function is typically used when reading configuration
- * files or other non-user input that should be locale independent.
- * To handle input from the user you should normally use the
- * locale-sensitive system strtoull() function.
- *
- * If the correct value would cause overflow, %G_MAXUINT64
- * is returned, and %ERANGE is stored in %errno. If the base is
- * outside the valid range, zero is returned, and %EINVAL is stored
- * in %errno. If the string conversion fails, zero is returned, and
- * @endptr returns @nptr (if @endptr is non-%NULL).
- *
- * Return value: the #guint64 value or zero on error.
- *
- * Since: 2.2
- **/
-guint64
-g_ascii_strtoull (const gchar *nptr,
- gchar **endptr,
- guint base)
-{
- gboolean negative;
- guint64 result;
-
- result = g_parse_long_long (nptr, (const gchar **) endptr, base, &negative);
-
- /* Return the result of the appropriate sign. */
- return negative ? -result : result;
-}
-
-/**
- * g_ascii_strtoll:
- * @nptr: the string to convert to a numeric value.
- * @endptr: if non-%NULL, it returns the character after
- * the last character used in the conversion.
- * @base: to be used for the conversion, 2..36 or 0
- *
- * Converts a string to a #gint64 value.
- * This function behaves like the standard strtoll() function
- * does in the C locale. It does this without actually
- * changing the current locale, since that would not be
- * thread-safe.
- *
- * This function is typically used when reading configuration
- * files or other non-user input that should be locale independent.
- * To handle input from the user you should normally use the
- * locale-sensitive system strtoll() function.
- *
- * If the correct value would cause overflow, %G_MAXINT64 or %G_MININT64
- * is returned, and %ERANGE is stored in %errno. If the base is
- * outside the valid range, zero is returned, and %EINVAL is stored
- * in %errno. If the string conversion fails, zero is returned, and
- * @endptr returns @nptr (if @endptr is non-%NULL).
- *
- * Return value: the #gint64 value or zero on error.
- *
- * Since: 2.12
- **/
-gint64
-g_ascii_strtoll (const gchar *nptr,
- gchar **endptr,
- guint base)
-{
- gboolean negative;
- guint64 result;
-
- result = g_parse_long_long (nptr, (const gchar **) endptr, base, &negative);
-
- if (negative && result > (guint64) G_MININT64)
- {
- errno = ERANGE;
- return G_MININT64;
- }
- else if (!negative && result > (guint64) G_MAXINT64)
- {
- errno = ERANGE;
- return G_MAXINT64;
- }
- else if (negative)
- return - (gint64) result;
- else
- return (gint64) result;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-G_CONST_RETURN gchar*
-g_strerror (gint errnum)
-{
- static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
- char *msg;
- int saved_errno = errno;
-
-#ifdef HAVE_STRERROR
- const char *msg_locale;
-
- msg_locale = strerror (errnum);
- if (g_get_charset (NULL))
- {
- errno = saved_errno;
- return msg_locale;
- }
- else
- {
- gchar *msg_utf8 = g_locale_to_utf8 (msg_locale, -1, NULL, NULL, NULL);
- if (msg_utf8)
- {
- /* Stick in the quark table so that we can return a static result
- */
- GQuark msg_quark = g_quark_from_string (msg_utf8);
- g_free (msg_utf8);
-
- msg_utf8 = (gchar *) g_quark_to_string (msg_quark);
- errno = saved_errno;
- return msg_utf8;
- }
- }
-#elif NO_SYS_ERRLIST
- switch (errnum)
- {
-#ifdef E2BIG
- case E2BIG: return "argument list too long";
-#endif
-#ifdef EACCES
- case EACCES: return "permission denied";
-#endif
-#ifdef EADDRINUSE
- case EADDRINUSE: return "address already in use";
-#endif
-#ifdef EADDRNOTAVAIL
- case EADDRNOTAVAIL: return "can't assign requested address";
-#endif
-#ifdef EADV
- case EADV: return "advertise error";
-#endif
-#ifdef EAFNOSUPPORT
- case EAFNOSUPPORT: return "address family not supported by protocol family";
-#endif
-#ifdef EAGAIN
- case EAGAIN: return "try again";
-#endif
-#ifdef EALIGN
- case EALIGN: return "EALIGN";
-#endif
-#ifdef EALREADY
- case EALREADY: return "operation already in progress";
-#endif
-#ifdef EBADE
- case EBADE: return "bad exchange descriptor";
-#endif
-#ifdef EBADF
- case EBADF: return "bad file number";
-#endif
-#ifdef EBADFD
- case EBADFD: return "file descriptor in bad state";
-#endif
-#ifdef EBADMSG
- case EBADMSG: return "not a data message";
-#endif
-#ifdef EBADR
- case EBADR: return "bad request descriptor";
-#endif
-#ifdef EBADRPC
- case EBADRPC: return "RPC structure is bad";
-#endif
-#ifdef EBADRQC
- case EBADRQC: return "bad request code";
-#endif
-#ifdef EBADSLT
- case EBADSLT: return "invalid slot";
-#endif
-#ifdef EBFONT
- case EBFONT: return "bad font file format";
-#endif
-#ifdef EBUSY
- case EBUSY: return "mount device busy";
-#endif
-#ifdef ECHILD
- case ECHILD: return "no children";
-#endif
-#ifdef ECHRNG
- case ECHRNG: return "channel number out of range";
-#endif
-#ifdef ECOMM
- case ECOMM: return "communication error on send";
-#endif
-#ifdef ECONNABORTED
- case ECONNABORTED: return "software caused connection abort";
-#endif
-#ifdef ECONNREFUSED
- case ECONNREFUSED: return "connection refused";
-#endif
-#ifdef ECONNRESET
- case ECONNRESET: return "connection reset by peer";
-#endif
-#if defined(EDEADLK) && (!defined(EWOULDBLOCK) || (EDEADLK != EWOULDBLOCK))
- case EDEADLK: return "resource deadlock avoided";
-#endif
-#ifdef EDEADLOCK
- case EDEADLOCK: return "resource deadlock avoided";
-#endif
-#ifdef EDESTADDRREQ
- case EDESTADDRREQ: return "destination address required";
-#endif
-#ifdef EDIRTY
- case EDIRTY: return "mounting a dirty fs w/o force";
-#endif
-#ifdef EDOM
- case EDOM: return "math argument out of range";
-#endif
-#ifdef EDOTDOT
- case EDOTDOT: return "cross mount point";
-#endif
-#ifdef EDQUOT
- case EDQUOT: return "disk quota exceeded";
-#endif
-#ifdef EDUPPKG
- case EDUPPKG: return "duplicate package name";
-#endif
-#ifdef EEXIST
- case EEXIST: return "file already exists";
-#endif
-#ifdef EFAULT
- case EFAULT: return "bad address in system call argument";
-#endif
-#ifdef EFBIG
- case EFBIG: return "file too large";
-#endif
-#ifdef EHOSTDOWN
- case EHOSTDOWN: return "host is down";
-#endif
-#ifdef EHOSTUNREACH
- case EHOSTUNREACH: return "host is unreachable";
-#endif
-#ifdef EIDRM
- case EIDRM: return "identifier removed";
-#endif
-#ifdef EINIT
- case EINIT: return "initialization error";
-#endif
-#ifdef EINPROGRESS
- case EINPROGRESS: return "operation now in progress";
-#endif
-#ifdef EINTR
- case EINTR: return "interrupted system call";
-#endif
-#ifdef EINVAL
- case EINVAL: return "invalid argument";
-#endif
-#ifdef EIO
- case EIO: return "I/O error";
-#endif
-#ifdef EISCONN
- case EISCONN: return "socket is already connected";
-#endif
-#ifdef EISDIR
- case EISDIR: return "is a directory";
-#endif
-#ifdef EISNAME
- case EISNAM: return "is a name file";
-#endif
-#ifdef ELBIN
- case ELBIN: return "ELBIN";
-#endif
-#ifdef EL2HLT
- case EL2HLT: return "level 2 halted";
-#endif
-#ifdef EL2NSYNC
- case EL2NSYNC: return "level 2 not synchronized";
-#endif
-#ifdef EL3HLT
- case EL3HLT: return "level 3 halted";
-#endif
-#ifdef EL3RST
- case EL3RST: return "level 3 reset";
-#endif
-#ifdef ELIBACC
- case ELIBACC: return "can not access a needed shared library";
-#endif
-#ifdef ELIBBAD
- case ELIBBAD: return "accessing a corrupted shared library";
-#endif
-#ifdef ELIBEXEC
- case ELIBEXEC: return "can not exec a shared library directly";
-#endif
-#ifdef ELIBMAX
- case ELIBMAX: return "attempting to link in more shared libraries than system limit";
-#endif
-#ifdef ELIBSCN
- case ELIBSCN: return ".lib section in a.out corrupted";
-#endif
-#ifdef ELNRNG
- case ELNRNG: return "link number out of range";
-#endif
-#ifdef ELOOP
- case ELOOP: return "too many levels of symbolic links";
-#endif
-#ifdef EMFILE
- case EMFILE: return "too many open files";
-#endif
-#ifdef EMLINK
- case EMLINK: return "too many links";
-#endif
-#ifdef EMSGSIZE
- case EMSGSIZE: return "message too long";
-#endif
-#ifdef EMULTIHOP
- case EMULTIHOP: return "multihop attempted";
-#endif
-#ifdef ENAMETOOLONG
- case ENAMETOOLONG: return "file name too long";
-#endif
-#ifdef ENAVAIL
- case ENAVAIL: return "not available";
-#endif
-#ifdef ENET
- case ENET: return "ENET";
-#endif
-#ifdef ENETDOWN
- case ENETDOWN: return "network is down";
-#endif
-#ifdef ENETRESET
- case ENETRESET: return "network dropped connection on reset";
-#endif
-#ifdef ENETUNREACH
- case ENETUNREACH: return "network is unreachable";
-#endif
-#ifdef ENFILE
- case ENFILE: return "file table overflow";
-#endif
-#ifdef ENOANO
- case ENOANO: return "anode table overflow";
-#endif
-#if defined(ENOBUFS) && (!defined(ENOSR) || (ENOBUFS != ENOSR))
- case ENOBUFS: return "no buffer space available";
-#endif
-#ifdef ENOCSI
- case ENOCSI: return "no CSI structure available";
-#endif
-#ifdef ENODATA
- case ENODATA: return "no data available";
-#endif
-#ifdef ENODEV
- case ENODEV: return "no such device";
-#endif
-#ifdef ENOENT
- case ENOENT: return "no such file or directory";
-#endif
-#ifdef ENOEXEC
- case ENOEXEC: return "exec format error";
-#endif
-#ifdef ENOLCK
- case ENOLCK: return "no locks available";
-#endif
-#ifdef ENOLINK
- case ENOLINK: return "link has be severed";
-#endif
-#ifdef ENOMEM
- case ENOMEM: return "not enough memory";
-#endif
-#ifdef ENOMSG
- case ENOMSG: return "no message of desired type";
-#endif
-#ifdef ENONET
- case ENONET: return "machine is not on the network";
-#endif
-#ifdef ENOPKG
- case ENOPKG: return "package not installed";
-#endif
-#ifdef ENOPROTOOPT
- case ENOPROTOOPT: return "bad proocol option";
-#endif
-#ifdef ENOSPC
- case ENOSPC: return "no space left on device";
-#endif
-#ifdef ENOSR
- case ENOSR: return "out of stream resources";
-#endif
-#ifdef ENOSTR
- case ENOSTR: return "not a stream device";
-#endif
-#ifdef ENOSYM
- case ENOSYM: return "unresolved symbol name";
-#endif
-#ifdef ENOSYS
- case ENOSYS: return "function not implemented";
-#endif
-#ifdef ENOTBLK
- case ENOTBLK: return "block device required";
-#endif
-#ifdef ENOTCONN
- case ENOTCONN: return "socket is not connected";
-#endif
-#ifdef ENOTDIR
- case ENOTDIR: return "not a directory";
-#endif
-#ifdef ENOTEMPTY
- case ENOTEMPTY: return "directory not empty";
-#endif
-#ifdef ENOTNAM
- case ENOTNAM: return "not a name file";
-#endif
-#ifdef ENOTSOCK
- case ENOTSOCK: return "socket operation on non-socket";
-#endif
-#ifdef ENOTTY
- case ENOTTY: return "inappropriate device for ioctl";
-#endif
-#ifdef ENOTUNIQ
- case ENOTUNIQ: return "name not unique on network";
-#endif
-#ifdef ENXIO
- case ENXIO: return "no such device or address";
-#endif
-#ifdef EOPNOTSUPP
- case EOPNOTSUPP: return "operation not supported on socket";
-#endif
-#ifdef EPERM
- case EPERM: return "not owner";
-#endif
-#ifdef EPFNOSUPPORT
- case EPFNOSUPPORT: return "protocol family not supported";
-#endif
-#ifdef EPIPE
- case EPIPE: return "broken pipe";
-#endif
-#ifdef EPROCLIM
- case EPROCLIM: return "too many processes";
-#endif
-#ifdef EPROCUNAVAIL
- case EPROCUNAVAIL: return "bad procedure for program";
-#endif
-#ifdef EPROGMISMATCH
- case EPROGMISMATCH: return "program version wrong";
-#endif
-#ifdef EPROGUNAVAIL
- case EPROGUNAVAIL: return "RPC program not available";
-#endif
-#ifdef EPROTO
- case EPROTO: return "protocol error";
-#endif
-#ifdef EPROTONOSUPPORT
- case EPROTONOSUPPORT: return "protocol not suppored";
-#endif
-#ifdef EPROTOTYPE
- case EPROTOTYPE: return "protocol wrong type for socket";
-#endif
-#ifdef ERANGE
- case ERANGE: return "math result unrepresentable";
-#endif
-#if defined(EREFUSED) && (!defined(ECONNREFUSED) || (EREFUSED != ECONNREFUSED))
- case EREFUSED: return "EREFUSED";
-#endif
-#ifdef EREMCHG
- case EREMCHG: return "remote address changed";
-#endif
-#ifdef EREMDEV
- case EREMDEV: return "remote device";
-#endif
-#ifdef EREMOTE
- case EREMOTE: return "pathname hit remote file system";
-#endif
-#ifdef EREMOTEIO
- case EREMOTEIO: return "remote i/o error";
-#endif
-#ifdef EREMOTERELEASE
- case EREMOTERELEASE: return "EREMOTERELEASE";
-#endif
-#ifdef EROFS
- case EROFS: return "read-only file system";
-#endif
-#ifdef ERPCMISMATCH
- case ERPCMISMATCH: return "RPC version is wrong";
-#endif
-#ifdef ERREMOTE
- case ERREMOTE: return "object is remote";
-#endif
-#ifdef ESHUTDOWN
- case ESHUTDOWN: return "can't send afer socket shutdown";
-#endif
-#ifdef ESOCKTNOSUPPORT
- case ESOCKTNOSUPPORT: return "socket type not supported";
-#endif
-#ifdef ESPIPE
- case ESPIPE: return "invalid seek";
-#endif
-#ifdef ESRCH
- case ESRCH: return "no such process";
-#endif
-#ifdef ESRMNT
- case ESRMNT: return "srmount error";
-#endif
-#ifdef ESTALE
- case ESTALE: return "stale remote file handle";
-#endif
-#ifdef ESUCCESS
- case ESUCCESS: return "Error 0";
-#endif
-#ifdef ETIME
- case ETIME: return "timer expired";
-#endif
-#ifdef ETIMEDOUT
- case ETIMEDOUT: return "connection timed out";
-#endif
-#ifdef ETOOMANYREFS
- case ETOOMANYREFS: return "too many references: can't splice";
-#endif
-#ifdef ETXTBSY
- case ETXTBSY: return "text file or pseudo-device busy";
-#endif
-#ifdef EUCLEAN
- case EUCLEAN: return "structure needs cleaning";
-#endif
-#ifdef EUNATCH
- case EUNATCH: return "protocol driver not attached";
-#endif
-#ifdef EUSERS
- case EUSERS: return "too many users";
-#endif
-#ifdef EVERSION
- case EVERSION: return "version mismatch";
-#endif
-#if defined(EWOULDBLOCK) && (!defined(EAGAIN) || (EWOULDBLOCK != EAGAIN))
- case EWOULDBLOCK: return "operation would block";
-#endif
-#ifdef EXDEV
- case EXDEV: return "cross-domain link";
-#endif
-#ifdef EXFULL
- case EXFULL: return "message tables full";
-#endif
- }
-#else /* NO_SYS_ERRLIST */
-#if NOT_NEEDED_FOR_NAVIT
- extern int sys_nerr;
- extern char *sys_errlist[];
-
- if ((errnum > 0) && (errnum <= sys_nerr))
- return sys_errlist [errnum];
-#else /* NOT_NEEDED_FOR_NAVIT */
- return NULL;
-#endif /* NOT_NEEDED_FOR_NAVIT */
-#endif /* NO_SYS_ERRLIST */
-
- msg = g_static_private_get (&msg_private);
- if (!msg)
- {
- msg = g_new (gchar, 64);
- g_static_private_set (&msg_private, msg, g_free);
- }
-
- _g_sprintf (msg, "unknown error (%d)", errnum);
-
- errno = saved_errno;
- return msg;
-}
-
-G_CONST_RETURN gchar*
-g_strsignal (gint signum)
-{
- static GStaticPrivate msg_private = G_STATIC_PRIVATE_INIT;
- char *msg;
-
-#ifdef HAVE_STRSIGNAL
- const char *msg_locale;
-
-#if defined(G_OS_BEOS) || defined(G_WITH_CYGWIN)
-extern const char *strsignal(int);
-#else
- /* this is declared differently (const) in string.h on BeOS */
- extern char *strsignal (int sig);
-#endif /* !G_OS_BEOS && !G_WITH_CYGWIN */
- msg_locale = strsignal (signum);
- if (g_get_charset (NULL))
- return msg_locale;
- else
- {
- gchar *msg_utf8 = g_locale_to_utf8 (msg_locale, -1, NULL, NULL, NULL);
- if (msg_utf8)
- {
- /* Stick in the quark table so that we can return a static result
- */
- GQuark msg_quark = g_quark_from_string (msg_utf8);
- g_free (msg_utf8);
-
- return g_quark_to_string (msg_quark);
- }
- }
-#elif NO_SYS_SIGLIST
- switch (signum)
- {
-#ifdef SIGHUP
- case SIGHUP: return "Hangup";
-#endif
-#ifdef SIGINT
- case SIGINT: return "Interrupt";
-#endif
-#ifdef SIGQUIT
- case SIGQUIT: return "Quit";
-#endif
-#ifdef SIGILL
- case SIGILL: return "Illegal instruction";
-#endif
-#ifdef SIGTRAP
- case SIGTRAP: return "Trace/breakpoint trap";
-#endif
-#ifdef SIGABRT
- case SIGABRT: return "IOT trap/Abort";
-#endif
-#ifdef SIGBUS
- case SIGBUS: return "Bus error";
-#endif
-#ifdef SIGFPE
- case SIGFPE: return "Floating point exception";
-#endif
-#ifdef SIGKILL
- case SIGKILL: return "Killed";
-#endif
-#ifdef SIGUSR1
- case SIGUSR1: return "User defined signal 1";
-#endif
-#ifdef SIGSEGV
- case SIGSEGV: return "Segmentation fault";
-#endif
-#ifdef SIGUSR2
- case SIGUSR2: return "User defined signal 2";
-#endif
-#ifdef SIGPIPE
- case SIGPIPE: return "Broken pipe";
-#endif
-#ifdef SIGALRM
- case SIGALRM: return "Alarm clock";
-#endif
-#ifdef SIGTERM
- case SIGTERM: return "Terminated";
-#endif
-#ifdef SIGSTKFLT
- case SIGSTKFLT: return "Stack fault";
-#endif
-#ifdef SIGCHLD
- case SIGCHLD: return "Child exited";
-#endif
-#ifdef SIGCONT
- case SIGCONT: return "Continued";
-#endif
-#ifdef SIGSTOP
- case SIGSTOP: return "Stopped (signal)";
-#endif
-#ifdef SIGTSTP
- case SIGTSTP: return "Stopped";
-#endif
-#ifdef SIGTTIN
- case SIGTTIN: return "Stopped (tty input)";
-#endif
-#ifdef SIGTTOU
- case SIGTTOU: return "Stopped (tty output)";
-#endif
-#ifdef SIGURG
- case SIGURG: return "Urgent condition";
-#endif
-#ifdef SIGXCPU
- case SIGXCPU: return "CPU time limit exceeded";
-#endif
-#ifdef SIGXFSZ
- case SIGXFSZ: return "File size limit exceeded";
-#endif
-#ifdef SIGVTALRM
- case SIGVTALRM: return "Virtual time alarm";
-#endif
-#ifdef SIGPROF
- case SIGPROF: return "Profile signal";
-#endif
-#ifdef SIGWINCH
- case SIGWINCH: return "Window size changed";
-#endif
-#ifdef SIGIO
- case SIGIO: return "Possible I/O";
-#endif
-#ifdef SIGPWR
- case SIGPWR: return "Power failure";
-#endif
-#ifdef SIGUNUSED
- case SIGUNUSED: return "Unused signal";
-#endif
- }
-#else /* NO_SYS_SIGLIST */
-
-#if NOT_NEEDED_FOR_NAVIT
-#ifdef NO_SYS_SIGLIST_DECL
- extern char *sys_siglist[]; /*(see Tue Jan 19 00:44:24 1999 in changelog)*/
-#endif
-
- return (char*) /* this function should return const --josh */ sys_siglist [signum];
-#else /* NOT_NEEDED_FOR_NAVIT */
- return NULL;
-#endif /* NOT_NEEDED_FOR_NAVIT */
-#endif /* NO_SYS_SIGLIST */
-
- msg = g_static_private_get (&msg_private);
- if (!msg)
- {
- msg = g_new (gchar, 64);
- g_static_private_set (&msg_private, msg, g_free);
- }
-
- _g_sprintf (msg, "unknown signal (%d)", signum);
-
- return msg;
-}
-#endif /* NOT_NEEDED_FOR_NAVIT */
-
-/* Functions g_strlcpy and g_strlcat were originally developed by
- * Todd C. Miller <Todd.Miller@courtesan.com> to simplify writing secure code.
- * See ftp://ftp.openbsd.org/pub/OpenBSD/src/lib/libc/string/strlcpy.3
- * for more information.
- */
-
-#ifdef HAVE_STRLCPY
-/* Use the native ones, if available; they might be implemented in assembly */
-gsize
-g_strlcpy (gchar *dest,
- const gchar *src,
- gsize dest_size)
-{
- g_return_val_if_fail (dest != NULL, 0);
- g_return_val_if_fail (src != NULL, 0);
-
- return strlcpy (dest, src, dest_size);
-}
-
-gsize
-g_strlcat (gchar *dest,
- const gchar *src,
- gsize dest_size)
-{
- g_return_val_if_fail (dest != NULL, 0);
- g_return_val_if_fail (src != NULL, 0);
-
- return strlcat (dest, src, dest_size);
-}
-
-#else /* ! HAVE_STRLCPY */
-/* g_strlcpy
- *
- * Copy string src to buffer dest (of buffer size dest_size). At most
- * dest_size-1 characters will be copied. Always NUL terminates
- * (unless dest_size == 0). This function does NOT allocate memory.
- * Unlike strncpy, this function doesn't pad dest (so it's often faster).
- * Returns size of attempted result, strlen(src),
- * so if retval >= dest_size, truncation occurred.
- */
-gsize
-g_strlcpy (gchar *dest,
- const gchar *src,
- gsize dest_size)
-{
- register gchar *d = dest;
- register const gchar *s = src;
- register gsize n = dest_size;
-
- g_return_val_if_fail (dest != NULL, 0);
- g_return_val_if_fail (src != NULL, 0);
-
- /* Copy as many bytes as will fit */
- if (n != 0 && --n != 0)
- do
- {
- register gchar c = *s++;
-
- *d++ = c;
- if (c == 0)
- break;
- }
- while (--n != 0);
-
- /* If not enough room in dest, add NUL and traverse rest of src */
- if (n == 0)
- {
- if (dest_size != 0)
- *d = 0;
- while (*s++)
- ;
- }
-
- return s - src - 1; /* count does not include NUL */
-}
-
-/* g_strlcat
- *
- * Appends string src to buffer dest (of buffer size dest_size).
- * At most dest_size-1 characters will be copied.
- * Unlike strncat, dest_size is the full size of dest, not the space left over.
- * This function does NOT allocate memory.
- * This always NUL terminates (unless siz == 0 or there were no NUL characters
- * in the dest_size characters of dest to start with).
- * Returns size of attempted result, which is
- * MIN (dest_size, strlen (original dest)) + strlen (src),
- * so if retval >= dest_size, truncation occurred.
- */
-gsize
-g_strlcat (gchar *dest,
- const gchar *src,
- gsize dest_size)
-{
- register gchar *d = dest;
- register const gchar *s = src;
- register gsize bytes_left = dest_size;
- gsize dlength; /* Logically, MIN (strlen (d), dest_size) */
-
- g_return_val_if_fail (dest != NULL, 0);
- g_return_val_if_fail (src != NULL, 0);
-
- /* Find the end of dst and adjust bytes left but don't go past end */
- while (*d != 0 && bytes_left-- != 0)
- d++;
- dlength = d - dest;
- bytes_left = dest_size - dlength;
-
- if (bytes_left == 0)
- return dlength + strlen (s);
-
- while (*s != 0)
- {
- if (bytes_left != 1)
- {
- *d++ = *s;
- bytes_left--;
- }
- s++;
- }
- *d = 0;
-
- return dlength + (s - src); /* count does not include NUL */
-}
-#endif /* ! HAVE_STRLCPY */
-
-/**
- * g_ascii_strdown:
- * @str: a string.
- * @len: length of @str in bytes, or -1 if @str is nul-terminated.
- *
- * Converts all upper case ASCII letters to lower case ASCII letters.
- *
- * Return value: a newly-allocated string, with all the upper case
- * characters in @str converted to lower case, with
- * semantics that exactly match g_ascii_tolower(). (Note
- * that this is unlike the old g_strdown(), which modified
- * the string in place.)
- **/
-gchar*
-g_ascii_strdown (const gchar *str,
- gssize len)
-{
- gchar *result, *s;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- if (len < 0)
- len = strlen (str);
-
- result = g_strndup (str, len);
- for (s = result; *s; s++)
- *s = g_ascii_tolower (*s);
-
- return result;
-}
-
-/**
- * g_ascii_strup:
- * @str: a string.
- * @len: length of @str in bytes, or -1 if @str is nul-terminated.
- *
- * Converts all lower case ASCII letters to upper case ASCII letters.
- *
- * Return value: a newly allocated string, with all the lower case
- * characters in @str converted to upper case, with
- * semantics that exactly match g_ascii_toupper(). (Note
- * that this is unlike the old g_strup(), which modified
- * the string in place.)
- **/
-gchar*
-g_ascii_strup (const gchar *str,
- gssize len)
-{
- gchar *result, *s;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- if (len < 0)
- len = strlen (str);
-
- result = g_strndup (str, len);
- for (s = result; *s; s++)
- *s = g_ascii_toupper (*s);
-
- return result;
-}
-
-/**
- * g_strdown:
- * @string: the string to convert.
- *
- * Converts a string to lower case.
- *
- * Return value: the string
- *
- * Deprecated:2.2: This function is totally broken for the reasons discussed
- * in the g_strncasecmp() docs - use g_ascii_strdown() or g_utf8_strdown()
- * instead.
- **/
-gchar*
-g_strdown (gchar *string)
-{
- register guchar *s;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- s = (guchar *) string;
-
- while (*s)
- {
- if (isupper (*s))
- *s = tolower (*s);
- s++;
- }
-
- return (gchar *) string;
-}
-
-/**
- * g_strup:
- * @string: the string to convert.
- *
- * Converts a string to upper case.
- *
- * Return value: the string
- *
- * Deprecated:2.2: This function is totally broken for the reasons discussed
- * in the g_strncasecmp() docs - use g_ascii_strup() or g_utf8_strup() instead.
- **/
-gchar*
-g_strup (gchar *string)
-{
- register guchar *s;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- s = (guchar *) string;
-
- while (*s)
- {
- if (islower (*s))
- *s = toupper (*s);
- s++;
- }
-
- return (gchar *) string;
-}
-
-gchar*
-g_strreverse (gchar *string)
-{
- g_return_val_if_fail (string != NULL, NULL);
-
- if (*string)
- {
- register gchar *h, *t;
-
- h = string;
- t = string + strlen (string) - 1;
-
- while (h < t)
- {
- register gchar c;
-
- c = *h;
- *h = *t;
- h++;
- *t = c;
- t--;
- }
- }
-
- return string;
-}
-
-/**
- * g_ascii_tolower:
- * @c: any character.
- *
- * Convert a character to ASCII lower case.
- *
- * Unlike the standard C library tolower() function, this only
- * recognizes standard ASCII letters and ignores the locale, returning
- * all non-ASCII characters unchanged, even if they are lower case
- * letters in a particular character set. Also unlike the standard
- * library function, this takes and returns a char, not an int, so
- * don't call it on %EOF but no need to worry about casting to #guchar
- * before passing a possibly non-ASCII character in.
- *
- * Return value: the result of converting @c to lower case.
- * If @c is not an ASCII upper case letter,
- * @c is returned unchanged.
- **/
-gchar
-g_ascii_tolower (gchar c)
-{
- return g_ascii_isupper (c) ? c - 'A' + 'a' : c;
-}
-
-/**
- * g_ascii_toupper:
- * @c: any character.
- *
- * Convert a character to ASCII upper case.
- *
- * Unlike the standard C library toupper() function, this only
- * recognizes standard ASCII letters and ignores the locale, returning
- * all non-ASCII characters unchanged, even if they are upper case
- * letters in a particular character set. Also unlike the standard
- * library function, this takes and returns a char, not an int, so
- * don't call it on %EOF but no need to worry about casting to #guchar
- * before passing a possibly non-ASCII character in.
- *
- * Return value: the result of converting @c to upper case.
- * If @c is not an ASCII lower case letter,
- * @c is returned unchanged.
- **/
-gchar
-g_ascii_toupper (gchar c)
-{
- return g_ascii_islower (c) ? c - 'a' + 'A' : c;
-}
-
-/**
- * g_ascii_digit_value:
- * @c: an ASCII character.
- *
- * Determines the numeric value of a character as a decimal
- * digit. Differs from g_unichar_digit_value() because it takes
- * a char, so there's no worry about sign extension if characters
- * are signed.
- *
- * Return value: If @c is a decimal digit (according to
- * g_ascii_isdigit()), its numeric value. Otherwise, -1.
- **/
-int
-g_ascii_digit_value (gchar c)
-{
- if (g_ascii_isdigit (c))
- return c - '0';
- return -1;
-}
-
-/**
- * g_ascii_xdigit_value:
- * @c: an ASCII character.
- *
- * Determines the numeric value of a character as a hexidecimal
- * digit. Differs from g_unichar_xdigit_value() because it takes
- * a char, so there's no worry about sign extension if characters
- * are signed.
- *
- * Return value: If @c is a hex digit (according to
- * g_ascii_isxdigit()), its numeric value. Otherwise, -1.
- **/
-int
-g_ascii_xdigit_value (gchar c)
-{
- if (c >= 'A' && c <= 'F')
- return c - 'A' + 10;
- if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
- return g_ascii_digit_value (c);
-}
-
-/**
- * g_ascii_strcasecmp:
- * @s1: string to compare with @s2.
- * @s2: string to compare with @s1.
- *
- * Compare two strings, ignoring the case of ASCII characters.
- *
- * Unlike the BSD strcasecmp() function, this only recognizes standard
- * ASCII letters and ignores the locale, treating all non-ASCII
- * bytes as if they are not letters.
- *
- * This function should be used only on strings that are known to be
- * in encodings where the bytes corresponding to ASCII letters always
- * represent themselves. This includes UTF-8 and the ISO-8859-*
- * charsets, but not for instance double-byte encodings like the
- * Windows Codepage 932, where the trailing bytes of double-byte
- * characters include all ASCII letters. If you compare two CP932
- * strings using this function, you will get false matches.
- *
- * Return value: 0 if the strings match, a negative value if @s1 &lt; @s2,
- * or a positive value if @s1 &gt; @s2.
- **/
-gint
-g_ascii_strcasecmp (const gchar *s1,
- const gchar *s2)
-{
- gint c1, c2;
-
- g_return_val_if_fail (s1 != NULL, 0);
- g_return_val_if_fail (s2 != NULL, 0);
-
- while (*s1 && *s2)
- {
- c1 = (gint)(guchar) TOLOWER (*s1);
- c2 = (gint)(guchar) TOLOWER (*s2);
- if (c1 != c2)
- return (c1 - c2);
- s1++; s2++;
- }
-
- return (((gint)(guchar) *s1) - ((gint)(guchar) *s2));
-}
-
-/**
- * g_ascii_strncasecmp:
- * @s1: string to compare with @s2.
- * @s2: string to compare with @s1.
- * @n: number of characters to compare.
- *
- * Compare @s1 and @s2, ignoring the case of ASCII characters and any
- * characters after the first @n in each string.
- *
- * Unlike the BSD strcasecmp() function, this only recognizes standard
- * ASCII letters and ignores the locale, treating all non-ASCII
- * characters as if they are not letters.
- *
- * The same warning as in g_ascii_strcasecmp() applies: Use this
- * function only on strings known to be in encodings where bytes
- * corresponding to ASCII letters always represent themselves.
- *
- * Return value: 0 if the strings match, a negative value if @s1 &lt; @s2,
- * or a positive value if @s1 &gt; @s2.
- **/
-gint
-g_ascii_strncasecmp (const gchar *s1,
- const gchar *s2,
- gsize n)
-{
- gint c1, c2;
-
- g_return_val_if_fail (s1 != NULL, 0);
- g_return_val_if_fail (s2 != NULL, 0);
-
- while (n && *s1 && *s2)
- {
- n -= 1;
- c1 = (gint)(guchar) TOLOWER (*s1);
- c2 = (gint)(guchar) TOLOWER (*s2);
- if (c1 != c2)
- return (c1 - c2);
- s1++; s2++;
- }
-
- if (n)
- return (((gint) (guchar) *s1) - ((gint) (guchar) *s2));
- else
- return 0;
-}
-
-/**
- * g_strcasecmp:
- * @s1: a string.
- * @s2: a string to compare with @s1.
- *
- * A case-insensitive string comparison, corresponding to the standard
- * strcasecmp() function on platforms which support it.
- *
- * Return value: 0 if the strings match, a negative value if @s1 &lt; @s2,
- * or a positive value if @s1 &gt; @s2.
- *
- * Deprecated:2.2: See g_strncasecmp() for a discussion of why this function
- * is deprecated and how to replace it.
- **/
-gint
-g_strcasecmp (const gchar *s1,
- const gchar *s2)
-{
-#ifdef HAVE_STRCASECMP
- g_return_val_if_fail (s1 != NULL, 0);
- g_return_val_if_fail (s2 != NULL, 0);
-
- return strcasecmp (s1, s2);
-#else
- gint c1, c2;
-
- g_return_val_if_fail (s1 != NULL, 0);
- g_return_val_if_fail (s2 != NULL, 0);
-
- while (*s1 && *s2)
- {
- /* According to A. Cox, some platforms have islower's that
- * don't work right on non-uppercase
- */
- c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1;
- c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2;
- if (c1 != c2)
- return (c1 - c2);
- s1++; s2++;
- }
-
- return (((gint)(guchar) *s1) - ((gint)(guchar) *s2));
-#endif
-}
-
-/**
- * g_strncasecmp:
- * @s1: a string.
- * @s2: a string to compare with @s1.
- * @n: the maximum number of characters to compare.
- *
- * A case-insensitive string comparison, corresponding to the standard
- * strncasecmp() function on platforms which support it.
- * It is similar to g_strcasecmp() except it only compares the first @n
- * characters of the strings.
- *
- * Return value: 0 if the strings match, a negative value if @s1 &lt; @s2,
- * or a positive value if @s1 &gt; @s2.
- *
- * Deprecated:2.2: The problem with g_strncasecmp() is that it does the
- * comparison by calling toupper()/tolower(). These functions are
- * locale-specific and operate on single bytes. However, it is impossible
- * to handle things correctly from an I18N standpoint by operating on
- * bytes, since characters may be multibyte. Thus g_strncasecmp() is
- * broken if your string is guaranteed to be ASCII, since it's
- * locale-sensitive, and it's broken if your string is localized, since
- * it doesn't work on many encodings at all, including UTF-8, EUC-JP,
- * etc.
- *
- * There are therefore two replacement functions: g_ascii_strncasecmp(),
- * which only works on ASCII and is not locale-sensitive, and
- * g_utf8_casefold(), which is good for case-insensitive sorting of UTF-8.
- **/
-gint
-g_strncasecmp (const gchar *s1,
- const gchar *s2,
- guint n)
-{
-#ifdef HAVE_STRNCASECMP
- return strncasecmp (s1, s2, n);
-#else
- gint c1, c2;
-
- g_return_val_if_fail (s1 != NULL, 0);
- g_return_val_if_fail (s2 != NULL, 0);
-
- while (n && *s1 && *s2)
- {
- n -= 1;
- /* According to A. Cox, some platforms have islower's that
- * don't work right on non-uppercase
- */
- c1 = isupper ((guchar)*s1) ? tolower ((guchar)*s1) : *s1;
- c2 = isupper ((guchar)*s2) ? tolower ((guchar)*s2) : *s2;
- if (c1 != c2)
- return (c1 - c2);
- s1++; s2++;
- }
-
- if (n)
- return (((gint) (guchar) *s1) - ((gint) (guchar) *s2));
- else
- return 0;
-#endif
-}
-
-gchar*
-g_strdelimit (gchar *string,
- const gchar *delimiters,
- gchar new_delim)
-{
- register gchar *c;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- if (!delimiters)
- delimiters = G_STR_DELIMITERS;
-
- for (c = string; *c; c++)
- {
- if (strchr (delimiters, *c))
- *c = new_delim;
- }
-
- return string;
-}
-
-gchar*
-g_strcanon (gchar *string,
- const gchar *valid_chars,
- gchar substitutor)
-{
- register gchar *c;
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (valid_chars != NULL, NULL);
-
- for (c = string; *c; c++)
- {
- if (!strchr (valid_chars, *c))
- *c = substitutor;
- }
-
- return string;
-}
-
-gchar*
-g_strcompress (const gchar *source)
-{
- const gchar *p = source, *octal;
- gchar *dest = g_malloc (strlen (source) + 1);
- gchar *q = dest;
-
- while (*p)
- {
- if (*p == '\\')
- {
- p++;
- switch (*p)
- {
- case '\0':
-#if NOT_NEEDED_FOR_NAVIT
- g_warning ("g_strcompress: trailing \\");
-#endif /* NOT_NEEDED_FOR_NAVIT */
- goto out;
- case '0': case '1': case '2': case '3': case '4':
- case '5': case '6': case '7':
- *q = 0;
- octal = p;
- while ((p < octal + 3) && (*p >= '0') && (*p <= '7'))
- {
- *q = (*q * 8) + (*p - '0');
- p++;
- }
- q++;
- p--;
- break;
- case 'b':
- *q++ = '\b';
- break;
- case 'f':
- *q++ = '\f';
- break;
- case 'n':
- *q++ = '\n';
- break;
- case 'r':
- *q++ = '\r';
- break;
- case 't':
- *q++ = '\t';
- break;
- default: /* Also handles \" and \\ */
- *q++ = *p;
- break;
- }
- }
- else
- *q++ = *p;
- p++;
- }
-out:
- *q = 0;
-
- return dest;
-}
-
-gchar *
-g_strescape (const gchar *source,
- const gchar *exceptions)
-{
- const guchar *p;
- gchar *dest;
- gchar *q;
- guchar excmap[256];
-
- g_return_val_if_fail (source != NULL, NULL);
-
- p = (guchar *) source;
- /* Each source byte needs maximally four destination chars (\777) */
- q = dest = g_malloc (strlen (source) * 4 + 1);
-
- memset (excmap, 0, 256);
- if (exceptions)
- {
- guchar *e = (guchar *) exceptions;
-
- while (*e)
- {
- excmap[*e] = 1;
- e++;
- }
- }
-
- while (*p)
- {
- if (excmap[*p])
- *q++ = *p;
- else
- {
- switch (*p)
- {
- case '\b':
- *q++ = '\\';
- *q++ = 'b';
- break;
- case '\f':
- *q++ = '\\';
- *q++ = 'f';
- break;
- case '\n':
- *q++ = '\\';
- *q++ = 'n';
- break;
- case '\r':
- *q++ = '\\';
- *q++ = 'r';
- break;
- case '\t':
- *q++ = '\\';
- *q++ = 't';
- break;
- case '\\':
- *q++ = '\\';
- *q++ = '\\';
- break;
- case '"':
- *q++ = '\\';
- *q++ = '"';
- break;
- default:
- if ((*p < ' ') || (*p >= 0177))
- {
- *q++ = '\\';
- *q++ = '0' + (((*p) >> 6) & 07);
- *q++ = '0' + (((*p) >> 3) & 07);
- *q++ = '0' + ((*p) & 07);
- }
- else
- *q++ = *p;
- break;
- }
- }
- p++;
- }
- *q = 0;
- return dest;
-}
-
-gchar*
-g_strchug (gchar *string)
-{
- guchar *start;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- for (start = (guchar*) string; *start && g_ascii_isspace (*start); start++)
- ;
-
- g_memmove (string, start, strlen ((gchar *) start) + 1);
-
- return string;
-}
-
-gchar*
-g_strchomp (gchar *string)
-{
- gsize len;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- len = strlen (string);
- while (len--)
- {
- if (g_ascii_isspace ((guchar) string[len]))
- string[len] = '\0';
- else
- break;
- }
-
- return string;
-}
-
-/**
- * g_strsplit:
- * @string: a string to split.
- * @delimiter: a string which specifies the places at which to split the string.
- * The delimiter is not included in any of the resulting strings, unless
- * @max_tokens is reached.
- * @max_tokens: the maximum number of pieces to split @string into. If this is
- * less than 1, the string is split completely.
- *
- * Splits a string into a maximum of @max_tokens pieces, using the given
- * @delimiter. If @max_tokens is reached, the remainder of @string is appended
- * to the last token.
- *
- * As a special case, the result of splitting the empty string "" is an empty
- * vector, not a vector containing a single string. The reason for this
- * special case is that being able to represent a empty vector is typically
- * more useful than consistent handling of empty elements. If you do need
- * to represent empty elements, you'll need to check for the empty string
- * before calling g_strsplit().
- *
- * Return value: a newly-allocated %NULL-terminated array of strings. Use
- * g_strfreev() to free it.
- **/
-gchar**
-g_strsplit (const gchar *string,
- const gchar *delimiter,
- gint max_tokens)
-{
- GSList *string_list = NULL, *slist;
- gchar **str_array, *s;
- guint n = 0;
- const gchar *remainder;
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (delimiter != NULL, NULL);
- g_return_val_if_fail (delimiter[0] != '\0', NULL);
-
- if (max_tokens < 1)
- max_tokens = G_MAXINT;
-
- remainder = string;
- s = strstr (remainder, delimiter);
- if (s)
- {
- gsize delimiter_len = strlen (delimiter);
-
- while (--max_tokens && s)
- {
- gsize len;
-
- len = s - remainder;
- string_list = g_slist_prepend (string_list,
- g_strndup (remainder, len));
- n++;
- remainder = s + delimiter_len;
- s = strstr (remainder, delimiter);
- }
- }
- if (*string)
- {
- n++;
- string_list = g_slist_prepend (string_list, g_strdup (remainder));
- }
-
- str_array = g_new (gchar*, n + 1);
-
- str_array[n--] = NULL;
- for (slist = string_list; slist; slist = slist->next)
- str_array[n--] = slist->data;
-
- g_slist_free (string_list);
-
- return str_array;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-/**
- * g_strsplit_set:
- * @string: The string to be tokenized
- * @delimiters: A nul-terminated string containing bytes that are used
- * to split the string.
- * @max_tokens: The maximum number of tokens to split @string into.
- * If this is less than 1, the string is split completely
- *
- * Splits @string into a number of tokens not containing any of the characters
- * in @delimiter. A token is the (possibly empty) longest string that does not
- * contain any of the characters in @delimiters. If @max_tokens is reached, the
- * remainder is appended to the last token.
- *
- * For example the result of g_strsplit_set ("abc:def/ghi", ":/", -1) is a
- * %NULL-terminated vector containing the three strings "abc", "def",
- * and "ghi".
- *
- * The result if g_strsplit_set (":def/ghi:", ":/", -1) is a %NULL-terminated
- * vector containing the four strings "", "def", "ghi", and "".
- *
- * As a special case, the result of splitting the empty string "" is an empty
- * vector, not a vector containing a single string. The reason for this
- * special case is that being able to represent a empty vector is typically
- * more useful than consistent handling of empty elements. If you do need
- * to represent empty elements, you'll need to check for the empty string
- * before calling g_strsplit_set().
- *
- * Note that this function works on bytes not characters, so it can't be used
- * to delimit UTF-8 strings for anything but ASCII characters.
- *
- * Return value: a newly-allocated %NULL-terminated array of strings. Use
- * g_strfreev() to free it.
- *
- * Since: 2.4
- **/
-gchar **
-g_strsplit_set (const gchar *string,
- const gchar *delimiters,
- gint max_tokens)
-{
- gboolean delim_table[256];
- GSList *tokens, *list;
- gint n_tokens;
- const gchar *s;
- const gchar *current;
- gchar *token;
- gchar **result;
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (delimiters != NULL, NULL);
-
- if (max_tokens < 1)
- max_tokens = G_MAXINT;
-
- if (*string == '\0')
- {
- result = g_new (char *, 1);
- result[0] = NULL;
- return result;
- }
-
- memset (delim_table, FALSE, sizeof (delim_table));
- for (s = delimiters; *s != '\0'; ++s)
- delim_table[*(guchar *)s] = TRUE;
-
- tokens = NULL;
- n_tokens = 0;
-
- s = current = string;
- while (*s != '\0')
- {
- if (delim_table[*(guchar *)s] && n_tokens + 1 < max_tokens)
- {
- gchar *token;
-
- token = g_strndup (current, s - current);
- tokens = g_slist_prepend (tokens, token);
- ++n_tokens;
-
- current = s + 1;
- }
-
- ++s;
- }
-
- token = g_strndup (current, s - current);
- tokens = g_slist_prepend (tokens, token);
- ++n_tokens;
-
- result = g_new (gchar *, n_tokens + 1);
-
- result[n_tokens] = NULL;
- for (list = tokens; list != NULL; list = list->next)
- result[--n_tokens] = list->data;
-
- g_slist_free (tokens);
-
- return result;
-}
-#endif /* NOT_NEEDED_FOR_NAVIT */
-
-/**
- * g_strfreev:
- * @str_array: a %NULL-terminated array of strings to free.
-
- * Frees a %NULL-terminated array of strings, and the array itself.
- * If called on a %NULL value, g_strfreev() simply returns.
- **/
-void
-g_strfreev (gchar **str_array)
-{
- if (str_array)
- {
- int i;
-
- for (i = 0; str_array[i] != NULL; i++)
- g_free (str_array[i]);
-
- g_free (str_array);
- }
-}
-
-/**
- * g_strdupv:
- * @str_array: %NULL-terminated array of strings.
- *
- * Copies %NULL-terminated array of strings. The copy is a deep copy;
- * the new array should be freed by first freeing each string, then
- * the array itself. g_strfreev() does this for you. If called
- * on a %NULL value, g_strdupv() simply returns %NULL.
- *
- * Return value: a new %NULL-terminated array of strings.
- **/
-gchar**
-g_strdupv (gchar **str_array)
-{
- if (str_array)
- {
- gint i;
- gchar **retval;
-
- i = 0;
- while (str_array[i])
- ++i;
-
- retval = g_new (gchar*, i + 1);
-
- i = 0;
- while (str_array[i])
- {
- retval[i] = g_strdup (str_array[i]);
- ++i;
- }
- retval[i] = NULL;
-
- return retval;
- }
- else
- return NULL;
-}
-
-gchar*
-g_strjoinv (const gchar *separator,
- gchar **str_array)
-{
- gchar *string;
- gchar *ptr;
-
- g_return_val_if_fail (str_array != NULL, NULL);
-
- if (separator == NULL)
- separator = "";
-
- if (*str_array)
- {
- gint i;
- gsize len;
- gsize separator_len;
-
- separator_len = strlen (separator);
- /* First part, getting length */
- len = 1 + strlen (str_array[0]);
- for (i = 1; str_array[i] != NULL; i++)
- len += strlen (str_array[i]);
- len += separator_len * (i - 1);
-
- /* Second part, building string */
- string = g_new (gchar, len);
- ptr = g_stpcpy (string, *str_array);
- for (i = 1; str_array[i] != NULL; i++)
- {
- ptr = g_stpcpy (ptr, separator);
- ptr = g_stpcpy (ptr, str_array[i]);
- }
- }
- else
- string = g_strdup ("");
-
- return string;
-}
-
-gchar*
-g_strjoin (const gchar *separator,
- ...)
-{
- gchar *string, *s;
- va_list args;
- gsize len;
- gsize separator_len;
- gchar *ptr;
-
- if (separator == NULL)
- separator = "";
-
- separator_len = strlen (separator);
-
- va_start (args, separator);
-
- s = va_arg (args, gchar*);
-
- if (s)
- {
- /* First part, getting length */
- len = 1 + strlen (s);
-
- s = va_arg (args, gchar*);
- while (s)
- {
- len += separator_len + strlen (s);
- s = va_arg (args, gchar*);
- }
- va_end (args);
-
- /* Second part, building string */
- string = g_new (gchar, len);
-
- va_start (args, separator);
-
- s = va_arg (args, gchar*);
- ptr = g_stpcpy (string, s);
-
- s = va_arg (args, gchar*);
- while (s)
- {
- ptr = g_stpcpy (ptr, separator);
- ptr = g_stpcpy (ptr, s);
- s = va_arg (args, gchar*);
- }
- }
- else
- string = g_strdup ("");
-
- va_end (args);
-
- return string;
-}
-
-/**
- * g_strstr_len:
- * @haystack: a string.
- * @haystack_len: the maximum length of @haystack. Note that -1 is
- * a valid length, if @haystack is nul-terminated, meaning it will
- * search through the whole string.
- * @needle: the string to search for.
- *
- * Searches the string @haystack for the first occurrence
- * of the string @needle, limiting the length of the search
- * to @haystack_len.
- *
- * Return value: a pointer to the found occurrence, or
- * %NULL if not found.
- **/
-gchar *
-g_strstr_len (const gchar *haystack,
- gssize haystack_len,
- const gchar *needle)
-{
- g_return_val_if_fail (haystack != NULL, NULL);
- g_return_val_if_fail (needle != NULL, NULL);
-
- if (haystack_len < 0)
- return strstr (haystack, needle);
- else
- {
- const gchar *p = haystack;
- gsize needle_len = strlen (needle);
- const gchar *end;
- gsize i;
-
- if (needle_len == 0)
- return (gchar *)haystack;
-
- if (haystack_len < needle_len)
- return NULL;
-
- end = haystack + haystack_len - needle_len;
-
- while (p <= end && *p)
- {
- for (i = 0; i < needle_len; i++)
- if (p[i] != needle[i])
- goto next;
-
- return (gchar *)p;
-
- next:
- p++;
- }
-
- return NULL;
- }
-}
-
-/**
- * g_strrstr:
- * @haystack: a nul-terminated string.
- * @needle: the nul-terminated string to search for.
- *
- * Searches the string @haystack for the last occurrence
- * of the string @needle.
- *
- * Return value: a pointer to the found occurrence, or
- * %NULL if not found.
- **/
-gchar *
-g_strrstr (const gchar *haystack,
- const gchar *needle)
-{
- gsize i;
- gsize needle_len;
- gsize haystack_len;
- const gchar *p;
-
- g_return_val_if_fail (haystack != NULL, NULL);
- g_return_val_if_fail (needle != NULL, NULL);
-
- needle_len = strlen (needle);
- haystack_len = strlen (haystack);
-
- if (needle_len == 0)
- return (gchar *)haystack;
-
- if (haystack_len < needle_len)
- return NULL;
-
- p = haystack + haystack_len - needle_len;
-
- while (p >= haystack)
- {
- for (i = 0; i < needle_len; i++)
- if (p[i] != needle[i])
- goto next;
-
- return (gchar *)p;
-
- next:
- p--;
- }
-
- return NULL;
-}
-
-/**
- * g_strrstr_len:
- * @haystack: a nul-terminated string.
- * @haystack_len: the maximum length of @haystack.
- * @needle: the nul-terminated string to search for.
- *
- * Searches the string @haystack for the last occurrence
- * of the string @needle, limiting the length of the search
- * to @haystack_len.
- *
- * Return value: a pointer to the found occurrence, or
- * %NULL if not found.
- **/
-gchar *
-g_strrstr_len (const gchar *haystack,
- gssize haystack_len,
- const gchar *needle)
-{
- g_return_val_if_fail (haystack != NULL, NULL);
- g_return_val_if_fail (needle != NULL, NULL);
-
- if (haystack_len < 0)
- return g_strrstr (haystack, needle);
- else
- {
- gsize needle_len = strlen (needle);
- const gchar *haystack_max = haystack + haystack_len;
- const gchar *p = haystack;
- gsize i;
-
- while (p < haystack_max && *p)
- p++;
-
- if (p < haystack + needle_len)
- return NULL;
-
- p -= needle_len;
-
- while (p >= haystack)
- {
- for (i = 0; i < needle_len; i++)
- if (p[i] != needle[i])
- goto next;
-
- return (gchar *)p;
-
- next:
- p--;
- }
-
- return NULL;
- }
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-/**
- * g_str_has_suffix:
- * @str: a nul-terminated string.
- * @suffix: the nul-terminated suffix to look for.
- *
- * Looks whether the string @str ends with @suffix.
- *
- * Return value: %TRUE if @str end with @suffix, %FALSE otherwise.
- *
- * Since: 2.2
- **/
-gboolean
-g_str_has_suffix (const gchar *str,
- const gchar *suffix)
-{
- int str_len;
- int suffix_len;
-
- g_return_val_if_fail (str != NULL, FALSE);
- g_return_val_if_fail (suffix != NULL, FALSE);
-
- str_len = strlen (str);
- suffix_len = strlen (suffix);
-
- if (str_len < suffix_len)
- return FALSE;
-
- return strcmp (str + str_len - suffix_len, suffix) == 0;
-}
-
-/**
- * g_str_has_prefix:
- * @str: a nul-terminated string.
- * @prefix: the nul-terminated prefix to look for.
- *
- * Looks whether the string @str begins with @prefix.
- *
- * Return value: %TRUE if @str begins with @prefix, %FALSE otherwise.
- *
- * Since: 2.2
- **/
-gboolean
-g_str_has_prefix (const gchar *str,
- const gchar *prefix)
-{
- int str_len;
- int prefix_len;
-
- g_return_val_if_fail (str != NULL, FALSE);
- g_return_val_if_fail (prefix != NULL, FALSE);
-
- str_len = strlen (str);
- prefix_len = strlen (prefix);
-
- if (str_len < prefix_len)
- return FALSE;
-
- return strncmp (str, prefix, prefix_len) == 0;
-}
-
-
-/**
- * g_strip_context:
- * @msgid: a string
- * @msgval: another string
- *
- * An auxiliary function for gettext() support (see Q_()).
- *
- * Return value: @msgval, unless @msgval is identical to @msgid and contains
- * a '|' character, in which case a pointer to the substring of msgid after
- * the first '|' character is returned.
- *
- * Since: 2.4
- **/
-G_CONST_RETURN gchar *
-g_strip_context (const gchar *msgid,
- const gchar *msgval)
-{
- if (msgval == msgid)
- {
- const char *c = strchr (msgid, '|');
- if (c != NULL)
- return c + 1;
- }
-
- return msgval;
-}
-#endif
-
-
-/**
- * g_strv_length:
- * @str_array: a %NULL-terminated array of strings.
- *
- * Returns the length of the given %NULL-terminated
- * string array @str_array.
- *
- * Return value: length of @str_array.
- *
- * Since: 2.6
- **/
-guint
-g_strv_length (gchar **str_array)
-{
- guint i = 0;
-
- g_return_val_if_fail (str_array != NULL, 0);
-
- while (str_array[i])
- ++i;
-
- return i;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-/**
- * g_dpgettext:
- * @domain: the translation domain to use, or %NULL to use
- * the domain set with textdomain()
- * @msgctxtid: a combined message context and message id, separated
- * by a \004 character
- * @msgidoffset: the offset of the message id in @msgctxid
- *
- * This function is a variant of g_dgettext() which supports
- * a disambiguating message context. GNU gettext uses the
- * '\004' character to separate the message context and
- * message id in @msgctxtid.
- * If 0 is passed as @msgidoffset, this function will fall back to
- * trying to use the deprecated convention of using "|" as a separation
- * character.
- *
- * This uses g_dgettext() internally. See that functions for differences
- * with dgettext() proper.
- *
- * Applications should normally not use this function directly,
- * but use the C_() macro for translations with context.
- *
- * Returns: The translated string
- *
- * Since: 2.16
- */
-G_CONST_RETURN gchar *
-g_dpgettext (const gchar *domain,
- const gchar *msgctxtid,
- gsize msgidoffset)
-{
- const gchar *translation;
- gchar *sep;
-
- translation = g_dgettext (domain, msgctxtid);
-
- if (translation == msgctxtid)
- {
- if (msgidoffset > 0)
- return msgctxtid + msgidoffset;
-
- sep = strchr (msgctxtid, '|');
-
- if (sep)
- {
- /* try with '\004' instead of '|', in case
- * xgettext -kQ_:1g was used
- */
- gchar *tmp = g_alloca (strlen (msgctxtid) + 1);
- strcpy (tmp, msgctxtid);
- tmp[sep - msgctxtid] = '\004';
-
- translation = g_dgettext (domain, tmp);
-
- if (translation == tmp)
- return sep + 1;
- }
- }
-
- return translation;
-}
-
-/* This function is taken from gettext.h
- * GNU gettext uses '\004' to separate context and msgid in .mo files.
- */
-/**
- * g_dpgettext2:
- * @domain: the translation domain to use, or %NULL to use
- * the domain set with textdomain()
- * @context: the message context
- * @msgid: the message
- *
- * This function is a variant of g_dgettext() which supports
- * a disambiguating message context. GNU gettext uses the
- * '\004' character to separate the message context and
- * message id in @msgctxtid.
- *
- * This uses g_dgettext() internally. See that functions for differences
- * with dgettext() proper.
- *
- * This function differs from C_() in that it is not a macro and
- * thus you may use non-string-literals as context and msgid arguments.
- *
- * Returns: The translated string
- *
- * Since: 2.18
- */
-G_CONST_RETURN char *
-g_dpgettext2 (const char *domain,
- const char *msgctxt,
- const char *msgid)
-{
- size_t msgctxt_len = strlen (msgctxt) + 1;
- size_t msgid_len = strlen (msgid) + 1;
- const char *translation;
- char* msg_ctxt_id;
-
- msg_ctxt_id = g_alloca (msgctxt_len + msgid_len);
-
- memcpy (msg_ctxt_id, msgctxt, msgctxt_len - 1);
- msg_ctxt_id[msgctxt_len - 1] = '\004';
- memcpy (msg_ctxt_id + msgctxt_len, msgid, msgid_len);
-
- translation = g_dgettext (domain, msg_ctxt_id);
-
- if (translation == msg_ctxt_id)
- {
- /* try the old way of doing message contexts, too */
- msg_ctxt_id[msgctxt_len - 1] = '|';
- translation = g_dgettext (domain, msg_ctxt_id);
-
- if (translation == msg_ctxt_id)
- return msgid;
- }
-
- return translation;
-}
-
-static gboolean
-_g_dgettext_should_translate (void)
-{
- static gsize translate = 0;
- enum {
- SHOULD_TRANSLATE = 1,
- SHOULD_NOT_TRANSLATE = 2
- };
-
- if (G_UNLIKELY (g_once_init_enter (&translate)))
- {
- gboolean should_translate = TRUE;
-
- const char *default_domain = textdomain (NULL);
- const char *translator_comment = gettext ("");
-#ifndef G_OS_WIN32
- const char *translate_locale = setlocale (LC_MESSAGES, NULL);
-#else
- const char *translate_locale = g_win32_getlocale ();
-#endif
- /* We should NOT translate only if all the following hold:
- * - user has called textdomain() and set textdomain to non-default
- * - default domain has no translations
- * - locale does not start with "en_" and is not "C"
- *
- * Rationale:
- * - If text domain is still the default domain, maybe user calls
- * it later. Continue with old behavior of translating.
- * - If locale starts with "en_", we can continue using the
- * translations even if the app doesn't have translations for
- * this locale. That is, en_UK and en_CA for example.
- * - If locale is "C", maybe user calls setlocale(LC_ALL,"") later.
- * Continue with old behavior of translating.
- */
- if (0 != strcmp (default_domain, "messages") &&
- '\0' == *translator_comment &&
- 0 != strncmp (translate_locale, "en_", 3) &&
- 0 != strcmp (translate_locale, "C"))
- should_translate = FALSE;
-
- g_once_init_leave (&translate,
- should_translate ?
- SHOULD_TRANSLATE :
- SHOULD_NOT_TRANSLATE);
- }
-
- return translate == SHOULD_TRANSLATE;
-}
-
-/**
- * g_dgettext:
- * @domain: the translation domain to use, or %NULL to use
- * the domain set with textdomain()
- * @msgid: message to translate
- *
- * This function is a wrapper of dgettext() which does not translate
- * the message if the default domain as set with textdomain() has no
- * translations for the current locale.
- *
- * The advantage of using this function over dgettext() proper is that
- * libraries using this function (like GTK+) will not use translations
- * if the application using the library does not have translations for
- * the current locale. This results in a consistent English-only
- * interface instead of one having partial translations. For this
- * feature to work, the call to textdomain() and setlocale() should
- * precede any g_dgettext() invocations. For GTK+, it means calling
- * textdomain() before gtk_init or its variants.
- *
- * This function disables translations if and only if upon its first
- * call all the following conditions hold:
- * <itemizedlist>
- * <listitem>@domain is not %NULL</listitem>
- * <listitem>textdomain() has been called to set a default text domain</listitem>
- * <listitem>there is no translations available for the default text domain
- * and the current locale</listitem>
- * <listitem>current locale is not "C" or any English locales (those
- * starting with "en_")</listitem>
- * </itemizedlist>
- *
- * Note that this behavior may not be desired for example if an application
- * has its untranslated messages in a language other than English. In those
- * cases the application should call textdomain() after initializing GTK+.
- *
- * Applications should normally not use this function directly,
- * but use the _() macro for translations.
- *
- * Returns: The translated string
- *
- * Since: 2.18
- */
-G_CONST_RETURN gchar *
-g_dgettext (const gchar *domain,
- const gchar *msgid)
-{
- if (domain && G_UNLIKELY (!_g_dgettext_should_translate ()))
- return msgid;
-
- return dgettext (domain, msgid);
-}
-
-/**
- * g_dngettext:
- * @domain: the translation domain to use, or %NULL to use
- * the domain set with textdomain()
- * @msgid: message to translate
- * @msgid_plural: plural form of the message
- * @n: the quantity for which translation is needed
- *
- * This function is a wrapper of dngettext() which does not translate
- * the message if the default domain as set with textdomain() has no
- * translations for the current locale.
- *
- * See g_dgettext() for details of how this differs from dngettext()
- * proper.
- *
- * Returns: The translated string
- *
- * Since: 2.18
- */
-G_CONST_RETURN gchar *
-g_dngettext (const gchar *domain,
- const gchar *msgid,
- const gchar *msgid_plural,
- gulong n)
-{
- if (domain && G_UNLIKELY (!_g_dgettext_should_translate ()))
- return n == 1 ? msgid : msgid_plural;
-
- return dngettext (domain, msgid, msgid_plural, n);
-}
-
-#endif /* NOT_NEEDED_FOR_NAVIT */
-
-#define __G_STRFUNCS_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gstrfuncs.h b/navit/support/glib/gstrfuncs.h
deleted file mode 100644
index ee291f80f..000000000
--- a/navit/support/glib/gstrfuncs.h
+++ /dev/null
@@ -1,266 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_STRFUNCS_H__
-#define __G_STRFUNCS_H__
-
-#include <stdarg.h>
-#include <glib/gtypes.h>
-
-G_BEGIN_DECLS
-
-/* Functions like the ones in <ctype.h> that are not affected by locale. */
-typedef enum {
- G_ASCII_ALNUM = 1 << 0,
- G_ASCII_ALPHA = 1 << 1,
- G_ASCII_CNTRL = 1 << 2,
- G_ASCII_DIGIT = 1 << 3,
- G_ASCII_GRAPH = 1 << 4,
- G_ASCII_LOWER = 1 << 5,
- G_ASCII_PRINT = 1 << 6,
- G_ASCII_PUNCT = 1 << 7,
- G_ASCII_SPACE = 1 << 8,
- G_ASCII_UPPER = 1 << 9,
- G_ASCII_XDIGIT = 1 << 10
-} GAsciiType;
-
-GLIB_VAR const guint16 * const g_ascii_table;
-
-#define g_ascii_isalnum(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_ALNUM) != 0)
-
-#define g_ascii_isalpha(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_ALPHA) != 0)
-
-#define g_ascii_iscntrl(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_CNTRL) != 0)
-
-#define g_ascii_isdigit(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_DIGIT) != 0)
-
-#define g_ascii_isgraph(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_GRAPH) != 0)
-
-#define g_ascii_islower(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_LOWER) != 0)
-
-#define g_ascii_isprint(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_PRINT) != 0)
-
-#define g_ascii_ispunct(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_PUNCT) != 0)
-
-#define g_ascii_isspace(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_SPACE) != 0)
-
-#define g_ascii_isupper(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_UPPER) != 0)
-
-#define g_ascii_isxdigit(c) \
- ((g_ascii_table[(guchar) (c)] & G_ASCII_XDIGIT) != 0)
-
-gchar g_ascii_tolower (gchar c) G_GNUC_CONST;
-gchar g_ascii_toupper (gchar c) G_GNUC_CONST;
-
-gint g_ascii_digit_value (gchar c) G_GNUC_CONST;
-gint g_ascii_xdigit_value (gchar c) G_GNUC_CONST;
-
-/* String utility functions that modify a string argument or
- * return a constant string that must not be freed.
- */
-#define G_STR_DELIMITERS "_-|> <."
-gchar* g_strdelimit (gchar *string,
- const gchar *delimiters,
- gchar new_delimiter);
-gchar* g_strcanon (gchar *string,
- const gchar *valid_chars,
- gchar substitutor);
-G_CONST_RETURN gchar* g_strerror (gint errnum) G_GNUC_CONST;
-G_CONST_RETURN gchar* g_strsignal (gint signum) G_GNUC_CONST;
-gchar* g_strreverse (gchar *string);
-gsize g_strlcpy (gchar *dest,
- const gchar *src,
- gsize dest_size);
-gsize g_strlcat (gchar *dest,
- const gchar *src,
- gsize dest_size);
-gchar * g_strstr_len (const gchar *haystack,
- gssize haystack_len,
- const gchar *needle);
-gchar * g_strrstr (const gchar *haystack,
- const gchar *needle);
-gchar * g_strrstr_len (const gchar *haystack,
- gssize haystack_len,
- const gchar *needle);
-
-gboolean g_str_has_suffix (const gchar *str,
- const gchar *suffix);
-gboolean g_str_has_prefix (const gchar *str,
- const gchar *prefix);
-
-/* String to/from double conversion functions */
-
-gdouble g_strtod (const gchar *nptr,
- gchar **endptr);
-gdouble g_ascii_strtod (const gchar *nptr,
- gchar **endptr);
-guint64 g_ascii_strtoull (const gchar *nptr,
- gchar **endptr,
- guint base);
-gint64 g_ascii_strtoll (const gchar *nptr,
- gchar **endptr,
- guint base);
-/* 29 bytes should enough for all possible values that
- * g_ascii_dtostr can produce.
- * Then add 10 for good measure */
-#define G_ASCII_DTOSTR_BUF_SIZE (29 + 10)
-gchar * g_ascii_dtostr (gchar *buffer,
- gint buf_len,
- gdouble d);
-gchar * g_ascii_formatd (gchar *buffer,
- gint buf_len,
- const gchar *format,
- gdouble d);
-
-/* removes leading spaces */
-gchar* g_strchug (gchar *string);
-/* removes trailing spaces */
-gchar* g_strchomp (gchar *string);
-/* removes leading & trailing spaces */
-#define g_strstrip( string ) g_strchomp (g_strchug (string))
-
-gint g_ascii_strcasecmp (const gchar *s1,
- const gchar *s2);
-gint g_ascii_strncasecmp (const gchar *s1,
- const gchar *s2,
- gsize n);
-gchar* g_ascii_strdown (const gchar *str,
- gssize len) G_GNUC_MALLOC;
-gchar* g_ascii_strup (const gchar *str,
- gssize len) G_GNUC_MALLOC;
-
-#ifndef G_DISABLE_DEPRECATED
-
-/* The following four functions are deprecated and will be removed in
- * the next major release. They use the locale-specific tolower and
- * toupper, which is almost never the right thing.
- */
-
-gint g_strcasecmp (const gchar *s1,
- const gchar *s2);
-gint g_strncasecmp (const gchar *s1,
- const gchar *s2,
- guint n);
-gchar* g_strdown (gchar *string);
-gchar* g_strup (gchar *string);
-
-#endif /* G_DISABLE_DEPRECATED */
-
-/* String utility functions that return a newly allocated string which
- * ought to be freed with g_free from the caller at some point.
- */
-gchar* g_strdup (const gchar *str) G_GNUC_MALLOC;
-gchar* g_strdup_printf (const gchar *format,
- ...) G_GNUC_PRINTF (1, 2) G_GNUC_MALLOC;
-gchar* g_strdup_vprintf (const gchar *format,
- va_list args) G_GNUC_MALLOC;
-gchar* g_strndup (const gchar *str,
- gsize n) G_GNUC_MALLOC;
-gchar* g_strnfill (gsize length,
- gchar fill_char) G_GNUC_MALLOC;
-gchar* g_strconcat (const gchar *string1,
- ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
-gchar* g_strjoin (const gchar *separator,
- ...) G_GNUC_MALLOC G_GNUC_NULL_TERMINATED;
-
-/* Make a copy of a string interpreting C string -style escape
- * sequences. Inverse of g_strescape. The recognized sequences are \b
- * \f \n \r \t \\ \" and the octal format.
- */
-gchar* g_strcompress (const gchar *source) G_GNUC_MALLOC;
-
-/* Copy a string escaping nonprintable characters like in C strings.
- * Inverse of g_strcompress. The exceptions parameter, if non-NULL, points
- * to a string containing characters that are not to be escaped.
- *
- * Deprecated API: gchar* g_strescape (const gchar *source);
- * Luckily this function wasn't used much, using NULL as second parameter
- * provides mostly identical semantics.
- */
-gchar* g_strescape (const gchar *source,
- const gchar *exceptions) G_GNUC_MALLOC;
-
-gpointer g_memdup (gconstpointer mem,
- guint byte_size) G_GNUC_MALLOC G_GNUC_ALLOC_SIZE(2);
-
-/* NULL terminated string arrays.
- * g_strsplit(), g_strsplit_set() split up string into max_tokens tokens
- * at delim and return a newly allocated string array.
- * g_strjoinv() concatenates all of str_array's strings, sliding in an
- * optional separator, the returned string is newly allocated.
- * g_strfreev() frees the array itself and all of its strings.
- * g_strdupv() copies a NULL-terminated array of strings
- * g_strv_length() returns the length of a NULL-terminated array of strings
- */
-gchar** g_strsplit (const gchar *string,
- const gchar *delimiter,
- gint max_tokens) G_GNUC_MALLOC;
-gchar ** g_strsplit_set (const gchar *string,
- const gchar *delimiters,
- gint max_tokens) G_GNUC_MALLOC;
-gchar* g_strjoinv (const gchar *separator,
- gchar **str_array) G_GNUC_MALLOC;
-void g_strfreev (gchar **str_array);
-gchar** g_strdupv (gchar **str_array) G_GNUC_MALLOC;
-guint g_strv_length (gchar **str_array);
-
-gchar* g_stpcpy (gchar *dest,
- const char *src);
-
-G_CONST_RETURN gchar *g_strip_context (const gchar *msgid,
- const gchar *msgval) G_GNUC_FORMAT(1);
-
-G_CONST_RETURN gchar *g_dgettext (const gchar *domain,
- const gchar *msgid) G_GNUC_FORMAT(2);
-
-G_CONST_RETURN gchar *g_dngettext (const gchar *domain,
- const gchar *msgid,
- const gchar *msgid_plural,
- gulong n) G_GNUC_FORMAT(3);
-G_CONST_RETURN gchar *g_dpgettext (const gchar *domain,
- const gchar *msgctxtid,
- gsize msgidoffset) G_GNUC_FORMAT(2);
-G_CONST_RETURN gchar *g_dpgettext2 (const gchar *domain,
- const gchar *context,
- const gchar *msgid) G_GNUC_FORMAT(3);
-
-G_END_DECLS
-
-#endif /* __G_STRFUNCS_H__ */
diff --git a/navit/support/glib/gstring.c b/navit/support/glib/gstring.c
deleted file mode 100644
index 9a7bb6a95..000000000
--- a/navit/support/glib/gstring.c
+++ /dev/null
@@ -1,1488 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * MT safe
- */
-
-#include "config.h"
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "glib.h"
-#include "gprintf.h"
-
-#include "galias.h"
-
-#if NOT_NEEDED_FOR_NAVIT
-struct _GStringChunk
-{
- GHashTable *const_table;
- GSList *storage_list;
- gsize storage_next;
- gsize this_size;
- gsize default_size;
-};
-#endif /* NOT_NEEDED_FOR_NAVIT */
-
-/* Hash Functions.
- */
-
-/**
- * g_str_equal:
- * @v1: a key
- * @v2: a key to compare with @v1
- *
- * Compares two strings for byte-by-byte equality and returns %TRUE
- * if they are equal. It can be passed to g_hash_table_new() as the
- * @key_equal_func parameter, when using strings as keys in a #GHashTable.
- *
- * Returns: %TRUE if the two keys match
- */
-gboolean
-g_str_equal (gconstpointer v1,
- gconstpointer v2)
-{
- const gchar *string1 = v1;
- const gchar *string2 = v2;
-
- return strcmp (string1, string2) == 0;
-}
-
-/**
- * g_str_hash:
- * @v: a string key
- *
- * Converts a string to a hash value.
- * It can be passed to g_hash_table_new() as the @hash_func
- * parameter, when using strings as keys in a #GHashTable.
- *
- * Returns: a hash value corresponding to the key
- */
-guint
-g_str_hash (gconstpointer v)
-{
- /* 31 bit hash function */
- const signed char *p = v;
- guint32 h = *p;
-
- if (h)
- for (p += 1; *p != '\0'; p++)
- h = (h << 5) - h + *p;
-
- return h;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-#define MY_MAXSIZE ((gsize)-1)
-
-static inline gsize
-nearest_power (gsize base, gsize num)
-{
- if (num > MY_MAXSIZE / 2)
- {
- return MY_MAXSIZE;
- }
- else
- {
- gsize n = base;
-
- while (n < num)
- n <<= 1;
-
- return n;
- }
-}
-
-/* String Chunks.
- */
-
-/**
- * g_string_chunk_new:
- * @size: the default size of the blocks of memory which are
- * allocated to store the strings. If a particular string
- * is larger than this default size, a larger block of
- * memory will be allocated for it.
- *
- * Creates a new #GStringChunk.
- *
- * Returns: a new #GStringChunk
- */
-GStringChunk*
-g_string_chunk_new (gsize size)
-{
- GStringChunk *new_chunk = g_new (GStringChunk, 1);
- gsize actual_size = 1;
-
- actual_size = nearest_power (1, size);
-
- new_chunk->const_table = NULL;
- new_chunk->storage_list = NULL;
- new_chunk->storage_next = actual_size;
- new_chunk->default_size = actual_size;
- new_chunk->this_size = actual_size;
-
- return new_chunk;
-}
-
-/**
- * g_string_chunk_free:
- * @chunk: a #GStringChunk
- *
- * Frees all memory allocated by the #GStringChunk.
- * After calling g_string_chunk_free() it is not safe to
- * access any of the strings which were contained within it.
- */
-void
-g_string_chunk_free (GStringChunk *chunk)
-{
- GSList *tmp_list;
-
- g_return_if_fail (chunk != NULL);
-
- if (chunk->storage_list)
- {
- for (tmp_list = chunk->storage_list; tmp_list; tmp_list = tmp_list->next)
- g_free (tmp_list->data);
-
- g_slist_free (chunk->storage_list);
- }
-
- if (chunk->const_table)
- g_hash_table_destroy (chunk->const_table);
-
- g_free (chunk);
-}
-
-/**
- * g_string_chunk_clear:
- * @chunk: a #GStringChunk
- *
- * Frees all strings contained within the #GStringChunk.
- * After calling g_string_chunk_clear() it is not safe to
- * access any of the strings which were contained within it.
- *
- * Since: 2.14
- */
-void
-g_string_chunk_clear (GStringChunk *chunk)
-{
- GSList *tmp_list;
-
- g_return_if_fail (chunk != NULL);
-
- if (chunk->storage_list)
- {
- for (tmp_list = chunk->storage_list; tmp_list; tmp_list = tmp_list->next)
- g_free (tmp_list->data);
-
- g_slist_free (chunk->storage_list);
-
- chunk->storage_list = NULL;
- chunk->storage_next = chunk->default_size;
- chunk->this_size = chunk->default_size;
- }
-
- if (chunk->const_table)
- g_hash_table_remove_all (chunk->const_table);
-}
-
-/**
- * g_string_chunk_insert:
- * @chunk: a #GStringChunk
- * @string: the string to add
- *
- * Adds a copy of @string to the #GStringChunk.
- * It returns a pointer to the new copy of the string
- * in the #GStringChunk. The characters in the string
- * can be changed, if necessary, though you should not
- * change anything after the end of the string.
- *
- * Unlike g_string_chunk_insert_const(), this function
- * does not check for duplicates. Also strings added
- * with g_string_chunk_insert() will not be searched
- * by g_string_chunk_insert_const() when looking for
- * duplicates.
- *
- * Returns: a pointer to the copy of @string within
- * the #GStringChunk
- */
-gchar*
-g_string_chunk_insert (GStringChunk *chunk,
- const gchar *string)
-{
- g_return_val_if_fail (chunk != NULL, NULL);
-
- return g_string_chunk_insert_len (chunk, string, -1);
-}
-
-/**
- * g_string_chunk_insert_const:
- * @chunk: a #GStringChunk
- * @string: the string to add
- *
- * Adds a copy of @string to the #GStringChunk, unless the same
- * string has already been added to the #GStringChunk with
- * g_string_chunk_insert_const().
- *
- * This function is useful if you need to copy a large number
- * of strings but do not want to waste space storing duplicates.
- * But you must remember that there may be several pointers to
- * the same string, and so any changes made to the strings
- * should be done very carefully.
- *
- * Note that g_string_chunk_insert_const() will not return a
- * pointer to a string added with g_string_chunk_insert(), even
- * if they do match.
- *
- * Returns: a pointer to the new or existing copy of @string
- * within the #GStringChunk
- */
-gchar*
-g_string_chunk_insert_const (GStringChunk *chunk,
- const gchar *string)
-{
- char* lookup;
-
- g_return_val_if_fail (chunk != NULL, NULL);
-
- if (!chunk->const_table)
- chunk->const_table = g_hash_table_new (g_str_hash, g_str_equal);
-
- lookup = (char*) g_hash_table_lookup (chunk->const_table, (gchar *)string);
-
- if (!lookup)
- {
- lookup = g_string_chunk_insert (chunk, string);
- g_hash_table_insert (chunk->const_table, lookup, lookup);
- }
-
- return lookup;
-}
-
-/**
- * g_string_chunk_insert_len:
- * @chunk: a #GStringChunk
- * @string: bytes to insert
- * @len: number of bytes of @string to insert, or -1 to insert a
- * nul-terminated string
- *
- * Adds a copy of the first @len bytes of @string to the #GStringChunk.
- * The copy is nul-terminated.
- *
- * Since this function does not stop at nul bytes, it is the caller's
- * responsibility to ensure that @string has at least @len addressable
- * bytes.
- *
- * The characters in the returned string can be changed, if necessary,
- * though you should not change anything after the end of the string.
- *
- * Return value: a pointer to the copy of @string within the #GStringChunk
- *
- * Since: 2.4
- **/
-gchar*
-g_string_chunk_insert_len (GStringChunk *chunk,
- const gchar *string,
- gssize len)
-{
- gssize size;
- gchar* pos;
-
- g_return_val_if_fail (chunk != NULL, NULL);
-
- if (len < 0)
- size = strlen (string);
- else
- size = len;
-
- if ((chunk->storage_next + size + 1) > chunk->this_size)
- {
- gsize new_size = nearest_power (chunk->default_size, size + 1);
-
- chunk->storage_list = g_slist_prepend (chunk->storage_list,
- g_new (gchar, new_size));
-
- chunk->this_size = new_size;
- chunk->storage_next = 0;
- }
-
- pos = ((gchar *) chunk->storage_list->data) + chunk->storage_next;
-
- *(pos + size) = '\0';
-
- strncpy (pos, string, size);
- if (len > 0)
- size = strlen (pos);
-
- chunk->storage_next += size + 1;
-
- return pos;
-}
-
-/* Strings.
- */
-static void
-g_string_maybe_expand (GString* string,
- gsize len)
-{
- if (string->len + len >= string->allocated_len)
- {
- string->allocated_len = nearest_power (1, string->len + len + 1);
- string->str = g_realloc (string->str, string->allocated_len);
- }
-}
-
-/**
- * g_string_sized_new:
- * @dfl_size: the default size of the space allocated to
- * hold the string
- *
- * Creates a new #GString, with enough space for @dfl_size
- * bytes. This is useful if you are going to add a lot of
- * text to the string and don't want it to be reallocated
- * too often.
- *
- * Returns: the new #GString
- */
-GString*
-g_string_sized_new (gsize dfl_size)
-{
- GString *string = g_slice_new (GString);
-
- string->allocated_len = 0;
- string->len = 0;
- string->str = NULL;
-
- g_string_maybe_expand (string, MAX (dfl_size, 2));
- string->str[0] = 0;
-
- return string;
-}
-
-/**
- * g_string_new:
- * @init: the initial text to copy into the string
- *
- * Creates a new #GString, initialized with the given string.
- *
- * Returns: the new #GString
- */
-GString*
-g_string_new (const gchar *init)
-{
- GString *string;
-
- if (init == NULL || *init == '\0')
- string = g_string_sized_new (2);
- else
- {
- gint len;
-
- len = strlen (init);
- string = g_string_sized_new (len + 2);
-
- g_string_append_len (string, init, len);
- }
-
- return string;
-}
-
-/**
- * g_string_new_len:
- * @init: initial contents of the string
- * @len: length of @init to use
- *
- * Creates a new #GString with @len bytes of the @init buffer.
- * Because a length is provided, @init need not be nul-terminated,
- * and can contain embedded nul bytes.
- *
- * Since this function does not stop at nul bytes, it is the caller's
- * responsibility to ensure that @init has at least @len addressable
- * bytes.
- *
- * Returns: a new #GString
- */
-GString*
-g_string_new_len (const gchar *init,
- gssize len)
-{
- GString *string;
-
- if (len < 0)
- return g_string_new (init);
- else
- {
- string = g_string_sized_new (len);
-
- if (init)
- g_string_append_len (string, init, len);
-
- return string;
- }
-}
-
-/**
- * g_string_free:
- * @string: a #GString
- * @free_segment: if %TRUE the actual character data is freed as well
- *
- * Frees the memory allocated for the #GString.
- * If @free_segment is %TRUE it also frees the character data.
- *
- * Returns: the character data of @string
- * (i.e. %NULL if @free_segment is %TRUE)
- */
-gchar*
-g_string_free (GString *string,
- gboolean free_segment)
-{
- gchar *segment;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- if (free_segment)
- {
- g_free (string->str);
- segment = NULL;
- }
- else
- segment = string->str;
-
- g_slice_free (GString, string);
-
- return segment;
-}
-
-/**
- * g_string_equal:
- * @v: a #GString
- * @v2: another #GString
- *
- * Compares two strings for equality, returning %TRUE if they are equal.
- * For use with #GHashTable.
- *
- * Returns: %TRUE if they strings are the same length and contain the
- * same bytes
- */
-gboolean
-g_string_equal (const GString *v,
- const GString *v2)
-{
- gchar *p, *q;
- GString *string1 = (GString *) v;
- GString *string2 = (GString *) v2;
- gsize i = string1->len;
-
- if (i != string2->len)
- return FALSE;
-
- p = string1->str;
- q = string2->str;
- while (i)
- {
- if (*p != *q)
- return FALSE;
- p++;
- q++;
- i--;
- }
- return TRUE;
-}
-
-/**
- * g_string_hash:
- * @str: a string to hash
- *
- * Creates a hash code for @str; for use with #GHashTable.
- *
- * Returns: hash code for @str
- */
-/* 31 bit hash function */
-guint
-g_string_hash (const GString *str)
-{
- const gchar *p = str->str;
- gsize n = str->len;
- guint h = 0;
-
- while (n--)
- {
- h = (h << 5) - h + *p;
- p++;
- }
-
- return h;
-}
-
-/**
- * g_string_assign:
- * @string: the destination #GString. Its current contents
- * are destroyed.
- * @rval: the string to copy into @string
- *
- * Copies the bytes from a string into a #GString,
- * destroying any previous contents. It is rather like
- * the standard strcpy() function, except that you do not
- * have to worry about having enough space to copy the string.
- *
- * Returns: @string
- */
-GString*
-g_string_assign (GString *string,
- const gchar *rval)
-{
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (rval != NULL, string);
-
- /* Make sure assigning to itself doesn't corrupt the string. */
- if (string->str != rval)
- {
- /* Assigning from substring should be ok since g_string_truncate
- does not realloc. */
- g_string_truncate (string, 0);
- g_string_append (string, rval);
- }
-
- return string;
-}
-
-/**
- * g_string_truncate:
- * @string: a #GString
- * @len: the new size of @string
- *
- * Cuts off the end of the GString, leaving the first @len bytes.
- *
- * Returns: @string
- */
-GString*
-g_string_truncate (GString *string,
- gsize len)
-{
- g_return_val_if_fail (string != NULL, NULL);
-
- string->len = MIN (len, string->len);
- string->str[string->len] = 0;
-
- return string;
-}
-
-/**
- * g_string_set_size:
- * @string: a #GString
- * @len: the new length
- *
- * Sets the length of a #GString. If the length is less than
- * the current length, the string will be truncated. If the
- * length is greater than the current length, the contents
- * of the newly added area are undefined. (However, as
- * always, string->str[string->len] will be a nul byte.)
- *
- * Return value: @string
- **/
-GString*
-g_string_set_size (GString *string,
- gsize len)
-{
- g_return_val_if_fail (string != NULL, NULL);
-
- if (len >= string->allocated_len)
- g_string_maybe_expand (string, len - string->len);
-
- string->len = len;
- string->str[len] = 0;
-
- return string;
-}
-
-/**
- * g_string_insert_len:
- * @string: a #GString
- * @pos: position in @string where insertion should
- * happen, or -1 for at the end
- * @val: bytes to insert
- * @len: number of bytes of @val to insert
- *
- * Inserts @len bytes of @val into @string at @pos.
- * Because @len is provided, @val may contain embedded
- * nuls and need not be nul-terminated. If @pos is -1,
- * bytes are inserted at the end of the string.
- *
- * Since this function does not stop at nul bytes, it is
- * the caller's responsibility to ensure that @val has at
- * least @len addressable bytes.
- *
- * Returns: @string
- */
-GString*
-g_string_insert_len (GString *string,
- gssize pos,
- const gchar *val,
- gssize len)
-{
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (val != NULL, string);
-
- if (len < 0)
- len = strlen (val);
-
- if (pos < 0)
- pos = string->len;
- else
- g_return_val_if_fail (pos <= string->len, string);
-
- /* Check whether val represents a substring of string. This test
- probably violates chapter and verse of the C standards, since
- ">=" and "<=" are only valid when val really is a substring.
- In practice, it will work on modern archs. */
- if (val >= string->str && val <= string->str + string->len)
- {
- gsize offset = val - string->str;
- gsize precount = 0;
-
- g_string_maybe_expand (string, len);
- val = string->str + offset;
- /* At this point, val is valid again. */
-
- /* Open up space where we are going to insert. */
- if (pos < string->len)
- g_memmove (string->str + pos + len, string->str + pos, string->len - pos);
-
- /* Move the source part before the gap, if any. */
- if (offset < pos)
- {
- precount = MIN (len, pos - offset);
- memcpy (string->str + pos, val, precount);
- }
-
- /* Move the source part after the gap, if any. */
- if (len > precount)
- memcpy (string->str + pos + precount,
- val + /* Already moved: */ precount + /* Space opened up: */ len,
- len - precount);
- }
- else
- {
- g_string_maybe_expand (string, len);
-
- /* If we aren't appending at the end, move a hunk
- * of the old string to the end, opening up space
- */
- if (pos < string->len)
- g_memmove (string->str + pos + len, string->str + pos, string->len - pos);
-
- /* insert the new string */
- if (len == 1)
- string->str[pos] = *val;
- else
- memcpy (string->str + pos, val, len);
- }
-
- string->len += len;
-
- string->str[string->len] = 0;
-
- return string;
-}
-
-#define SUB_DELIM_CHARS "!$&'()*+,;="
-
-static gboolean
-is_valid (char c, const char *reserved_chars_allowed)
-{
- if (g_ascii_isalnum (c) ||
- c == '-' ||
- c == '.' ||
- c == '_' ||
- c == '~')
- return TRUE;
-
- if (reserved_chars_allowed &&
- strchr (reserved_chars_allowed, c) != NULL)
- return TRUE;
-
- return FALSE;
-}
-
-static gboolean
-gunichar_ok (gunichar c)
-{
- return
- (c != (gunichar) -2) &&
- (c != (gunichar) -1);
-}
-
-/**
- * g_string_append_uri_escaped:
- * @string: a #GString
- * @unescaped: a string
- * @reserved_chars_allowed: a string of reserved characters allowed to be used
- * @allow_utf8: set %TRUE if the escaped string may include UTF8 characters
- *
- * Appends @unescaped to @string, escaped any characters that
- * are reserved in URIs using URI-style escape sequences.
- *
- * Returns: @string
- *
- * Since: 2.16
- **/
-GString *
-g_string_append_uri_escaped (GString *string,
- const char *unescaped,
- const char *reserved_chars_allowed,
- gboolean allow_utf8)
-{
- unsigned char c;
- const char *end;
- static const gchar hex[16] = "0123456789ABCDEF";
-
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (unescaped != NULL, NULL);
-
- end = unescaped + strlen (unescaped);
-
- while ((c = *unescaped) != 0)
- {
- if (c >= 0x80 && allow_utf8 &&
- gunichar_ok (g_utf8_get_char_validated (unescaped, end - unescaped)))
- {
- int len = g_utf8_skip [c];
- g_string_append_len (string, unescaped, len);
- unescaped += len;
- }
- else if (is_valid (c, reserved_chars_allowed))
- {
- g_string_append_c (string, c);
- unescaped++;
- }
- else
- {
- g_string_append_c (string, '%');
- g_string_append_c (string, hex[((guchar)c) >> 4]);
- g_string_append_c (string, hex[((guchar)c) & 0xf]);
- unescaped++;
- }
- }
-
- return string;
-}
-
-/**
- * g_string_append:
- * @string: a #GString
- * @val: the string to append onto the end of @string
- *
- * Adds a string onto the end of a #GString, expanding
- * it if necessary.
- *
- * Returns: @string
- */
-GString*
-g_string_append (GString *string,
- const gchar *val)
-{
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (val != NULL, string);
-
- return g_string_insert_len (string, -1, val, -1);
-}
-
-/**
- * g_string_append_len:
- * @string: a #GString
- * @val: bytes to append
- * @len: number of bytes of @val to use
- *
- * Appends @len bytes of @val to @string. Because @len is
- * provided, @val may contain embedded nuls and need not
- * be nul-terminated.
- *
- * Since this function does not stop at nul bytes, it is
- * the caller's responsibility to ensure that @val has at
- * least @len addressable bytes.
- *
- * Returns: @string
- */
-GString*
-g_string_append_len (GString *string,
- const gchar *val,
- gssize len)
-{
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (val != NULL, string);
-
- return g_string_insert_len (string, -1, val, len);
-}
-
-/**
- * g_string_append_c:
- * @string: a #GString
- * @c: the byte to append onto the end of @string
- *
- * Adds a byte onto the end of a #GString, expanding
- * it if necessary.
- *
- * Returns: @string
- */
-#undef g_string_append_c
-GString*
-g_string_append_c (GString *string,
- gchar c)
-{
- g_return_val_if_fail (string != NULL, NULL);
-
- return g_string_insert_c (string, -1, c);
-}
-
-/**
- * g_string_append_unichar:
- * @string: a #GString
- * @wc: a Unicode character
- *
- * Converts a Unicode character into UTF-8, and appends it
- * to the string.
- *
- * Return value: @string
- **/
-GString*
-g_string_append_unichar (GString *string,
- gunichar wc)
-{
- g_return_val_if_fail (string != NULL, NULL);
-
- return g_string_insert_unichar (string, -1, wc);
-}
-
-/**
- * g_string_prepend:
- * @string: a #GString
- * @val: the string to prepend on the start of @string
- *
- * Adds a string on to the start of a #GString,
- * expanding it if necessary.
- *
- * Returns: @string
- */
-GString*
-g_string_prepend (GString *string,
- const gchar *val)
-{
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (val != NULL, string);
-
- return g_string_insert_len (string, 0, val, -1);
-}
-
-/**
- * g_string_prepend_len:
- * @string: a #GString
- * @val: bytes to prepend
- * @len: number of bytes in @val to prepend
- *
- * Prepends @len bytes of @val to @string.
- * Because @len is provided, @val may contain
- * embedded nuls and need not be nul-terminated.
- *
- * Since this function does not stop at nul bytes,
- * it is the caller's responsibility to ensure that
- * @val has at least @len addressable bytes.
- *
- * Returns: @string
- */
-GString*
-g_string_prepend_len (GString *string,
- const gchar *val,
- gssize len)
-{
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (val != NULL, string);
-
- return g_string_insert_len (string, 0, val, len);
-}
-
-/**
- * g_string_prepend_c:
- * @string: a #GString
- * @c: the byte to prepend on the start of the #GString
- *
- * Adds a byte onto the start of a #GString,
- * expanding it if necessary.
- *
- * Returns: @string
- */
-GString*
-g_string_prepend_c (GString *string,
- gchar c)
-{
- g_return_val_if_fail (string != NULL, NULL);
-
- return g_string_insert_c (string, 0, c);
-}
-
-/**
- * g_string_prepend_unichar:
- * @string: a #GString
- * @wc: a Unicode character
- *
- * Converts a Unicode character into UTF-8, and prepends it
- * to the string.
- *
- * Return value: @string
- **/
-GString*
-g_string_prepend_unichar (GString *string,
- gunichar wc)
-{
- g_return_val_if_fail (string != NULL, NULL);
-
- return g_string_insert_unichar (string, 0, wc);
-}
-
-/**
- * g_string_insert:
- * @string: a #GString
- * @pos: the position to insert the copy of the string
- * @val: the string to insert
- *
- * Inserts a copy of a string into a #GString,
- * expanding it if necessary.
- *
- * Returns: @string
- */
-GString*
-g_string_insert (GString *string,
- gssize pos,
- const gchar *val)
-{
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (val != NULL, string);
- if (pos >= 0)
- g_return_val_if_fail (pos <= string->len, string);
-
- return g_string_insert_len (string, pos, val, -1);
-}
-
-/**
- * g_string_insert_c:
- * @string: a #GString
- * @pos: the position to insert the byte
- * @c: the byte to insert
- *
- * Inserts a byte into a #GString, expanding it if necessary.
- *
- * Returns: @string
- */
-GString*
-g_string_insert_c (GString *string,
- gssize pos,
- gchar c)
-{
- g_return_val_if_fail (string != NULL, NULL);
-
- g_string_maybe_expand (string, 1);
-
- if (pos < 0)
- pos = string->len;
- else
- g_return_val_if_fail (pos <= string->len, string);
-
- /* If not just an append, move the old stuff */
- if (pos < string->len)
- g_memmove (string->str + pos + 1, string->str + pos, string->len - pos);
-
- string->str[pos] = c;
-
- string->len += 1;
-
- string->str[string->len] = 0;
-
- return string;
-}
-
-/**
- * g_string_insert_unichar:
- * @string: a #GString
- * @pos: the position at which to insert character, or -1 to
- * append at the end of the string
- * @wc: a Unicode character
- *
- * Converts a Unicode character into UTF-8, and insert it
- * into the string at the given position.
- *
- * Return value: @string
- **/
-GString*
-g_string_insert_unichar (GString *string,
- gssize pos,
- gunichar wc)
-{
- gint charlen, first, i;
- gchar *dest;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- /* Code copied from g_unichar_to_utf() */
- if (wc < 0x80)
- {
- first = 0;
- charlen = 1;
- }
- else if (wc < 0x800)
- {
- first = 0xc0;
- charlen = 2;
- }
- else if (wc < 0x10000)
- {
- first = 0xe0;
- charlen = 3;
- }
- else if (wc < 0x200000)
- {
- first = 0xf0;
- charlen = 4;
- }
- else if (wc < 0x4000000)
- {
- first = 0xf8;
- charlen = 5;
- }
- else
- {
- first = 0xfc;
- charlen = 6;
- }
- /* End of copied code */
-
- g_string_maybe_expand (string, charlen);
-
- if (pos < 0)
- pos = string->len;
- else
- g_return_val_if_fail (pos <= string->len, string);
-
- /* If not just an append, move the old stuff */
- if (pos < string->len)
- g_memmove (string->str + pos + charlen, string->str + pos, string->len - pos);
-
- dest = string->str + pos;
- /* Code copied from g_unichar_to_utf() */
- for (i = charlen - 1; i > 0; --i)
- {
- dest[i] = (wc & 0x3f) | 0x80;
- wc >>= 6;
- }
- dest[0] = wc | first;
- /* End of copied code */
-
- string->len += charlen;
-
- string->str[string->len] = 0;
-
- return string;
-}
-
-/**
- * g_string_overwrite:
- * @string: a #GString
- * @pos: the position at which to start overwriting
- * @val: the string that will overwrite the @string starting at @pos
- *
- * Overwrites part of a string, lengthening it if necessary.
- *
- * Return value: @string
- *
- * Since: 2.14
- **/
-GString *
-g_string_overwrite (GString *string,
- gsize pos,
- const gchar *val)
-{
- g_return_val_if_fail (val != NULL, string);
- return g_string_overwrite_len (string, pos, val, strlen (val));
-}
-
-/**
- * g_string_overwrite_len:
- * @string: a #GString
- * @pos: the position at which to start overwriting
- * @val: the string that will overwrite the @string starting at @pos
- * @len: the number of bytes to write from @val
- *
- * Overwrites part of a string, lengthening it if necessary.
- * This function will work with embedded nuls.
- *
- * Return value: @string
- *
- * Since: 2.14
- **/
-GString *
-g_string_overwrite_len (GString *string,
- gsize pos,
- const gchar *val,
- gssize len)
-{
- gsize end;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- if (!len)
- return string;
-
- g_return_val_if_fail (val != NULL, string);
- g_return_val_if_fail (pos <= string->len, string);
-
- if (len < 0)
- len = strlen (val);
-
- end = pos + len;
-
- if (end > string->len)
- g_string_maybe_expand (string, end - string->len);
-
- memcpy (string->str + pos, val, len);
-
- if (end > string->len)
- {
- string->str[end] = '\0';
- string->len = end;
- }
-
- return string;
-}
-
-/**
- * g_string_erase:
- * @string: a #GString
- * @pos: the position of the content to remove
- * @len: the number of bytes to remove, or -1 to remove all
- * following bytes
- *
- * Removes @len bytes from a #GString, starting at position @pos.
- * The rest of the #GString is shifted down to fill the gap.
- *
- * Returns: @string
- */
-GString*
-g_string_erase (GString *string,
- gssize pos,
- gssize len)
-{
- g_return_val_if_fail (string != NULL, NULL);
- g_return_val_if_fail (pos >= 0, string);
- g_return_val_if_fail (pos <= string->len, string);
-
- if (len < 0)
- len = string->len - pos;
- else
- {
- g_return_val_if_fail (pos + len <= string->len, string);
-
- if (pos + len < string->len)
- g_memmove (string->str + pos, string->str + pos + len, string->len - (pos + len));
- }
-
- string->len -= len;
-
- string->str[string->len] = 0;
-
- return string;
-}
-
-/**
- * g_string_ascii_down:
- * @string: a GString
- *
- * Converts all upper case ASCII letters to lower case ASCII letters.
- *
- * Return value: passed-in @string pointer, with all the upper case
- * characters converted to lower case in place, with
- * semantics that exactly match g_ascii_tolower().
- **/
-GString*
-g_string_ascii_down (GString *string)
-{
- gchar *s;
- gint n;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- n = string->len;
- s = string->str;
-
- while (n)
- {
- *s = g_ascii_tolower (*s);
- s++;
- n--;
- }
-
- return string;
-}
-
-/**
- * g_string_ascii_up:
- * @string: a GString
- *
- * Converts all lower case ASCII letters to upper case ASCII letters.
- *
- * Return value: passed-in @string pointer, with all the lower case
- * characters converted to upper case in place, with
- * semantics that exactly match g_ascii_toupper().
- **/
-GString*
-g_string_ascii_up (GString *string)
-{
- gchar *s;
- gint n;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- n = string->len;
- s = string->str;
-
- while (n)
- {
- *s = g_ascii_toupper (*s);
- s++;
- n--;
- }
-
- return string;
-}
-
-/**
- * g_string_down:
- * @string: a #GString
- *
- * Converts a #GString to lowercase.
- *
- * Returns: the #GString.
- *
- * Deprecated:2.2: This function uses the locale-specific
- * tolower() function, which is almost never the right thing.
- * Use g_string_ascii_down() or g_utf8_strdown() instead.
- */
-GString*
-g_string_down (GString *string)
-{
- guchar *s;
- glong n;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- n = string->len;
- s = (guchar *) string->str;
-
- while (n)
- {
- if (isupper (*s))
- *s = tolower (*s);
- s++;
- n--;
- }
-
- return string;
-}
-
-/**
- * g_string_up:
- * @string: a #GString
- *
- * Converts a #GString to uppercase.
- *
- * Return value: @string
- *
- * Deprecated:2.2: This function uses the locale-specific
- * toupper() function, which is almost never the right thing.
- * Use g_string_ascii_up() or g_utf8_strup() instead.
- **/
-GString*
-g_string_up (GString *string)
-{
- guchar *s;
- glong n;
-
- g_return_val_if_fail (string != NULL, NULL);
-
- n = string->len;
- s = (guchar *) string->str;
-
- while (n)
- {
- if (islower (*s))
- *s = toupper (*s);
- s++;
- n--;
- }
-
- return string;
-}
-
-/**
- * g_string_append_vprintf:
- * @string: a #GString
- * @format: the string format. See the printf() documentation
- * @args: the list of arguments to insert in the output
- *
- * Appends a formatted string onto the end of a #GString.
- * This function is similar to g_string_append_printf()
- * except that the arguments to the format string are passed
- * as a va_list.
- *
- * Since: 2.14
- */
-void
-g_string_append_vprintf (GString *string,
- const gchar *format,
- va_list args)
-{
- gchar *buf;
- gint len;
-
- g_return_if_fail (string != NULL);
- g_return_if_fail (format != NULL);
-
- len = g_vasprintf (&buf, format, args);
-
- if (len >= 0)
- {
- g_string_maybe_expand (string, len);
- memcpy (string->str + string->len, buf, len + 1);
- string->len += len;
- g_free (buf);
- }
-}
-
-/**
- * g_string_vprintf:
- * @string: a #GString
- * @format: the string format. See the printf() documentation
- * @args: the parameters to insert into the format string
- *
- * Writes a formatted string into a #GString.
- * This function is similar to g_string_printf() except that
- * the arguments to the format string are passed as a va_list.
- *
- * Since: 2.14
- */
-void
-g_string_vprintf (GString *string,
- const gchar *format,
- va_list args)
-{
- g_string_truncate (string, 0);
- g_string_append_vprintf (string, format, args);
-}
-
-/**
- * g_string_sprintf:
- * @string: a #GString
- * @format: the string format. See the sprintf() documentation
- * @Varargs: the parameters to insert into the format string
- *
- * Writes a formatted string into a #GString.
- * This is similar to the standard sprintf() function,
- * except that the #GString buffer automatically expands
- * to contain the results. The previous contents of the
- * #GString are destroyed.
- *
- * Deprecated: This function has been renamed to g_string_printf().
- */
-
-/**
- * g_string_printf:
- * @string: a #GString
- * @format: the string format. See the printf() documentation
- * @Varargs: the parameters to insert into the format string
- *
- * Writes a formatted string into a #GString.
- * This is similar to the standard sprintf() function,
- * except that the #GString buffer automatically expands
- * to contain the results. The previous contents of the
- * #GString are destroyed.
- */
-void
-g_string_printf (GString *string,
- const gchar *format,
- ...)
-{
- va_list args;
-
- g_string_truncate (string, 0);
-
- va_start (args, format);
- g_string_append_vprintf (string, format, args);
- va_end (args);
-}
-
-/**
- * g_string_sprintfa:
- * @string: a #GString
- * @format: the string format. See the sprintf() documentation
- * @Varargs: the parameters to insert into the format string
- *
- * Appends a formatted string onto the end of a #GString.
- * This function is similar to g_string_sprintf() except that
- * the text is appended to the #GString.
- *
- * Deprecated: This function has been renamed to g_string_append_printf()
- */
-
-/**
- * g_string_append_printf:
- * @string: a #GString
- * @format: the string format. See the printf() documentation
- * @Varargs: the parameters to insert into the format string
- *
- * Appends a formatted string onto the end of a #GString.
- * This function is similar to g_string_printf() except
- * that the text is appended to the #GString.
- */
-void
-g_string_append_printf (GString *string,
- const gchar *format,
- ...)
-{
- va_list args;
-
- va_start (args, format);
- g_string_append_vprintf (string, format, args);
- va_end (args);
-}
-
-#endif /* NOT_NEEDED_FOR_NAVIT */
-#define __G_STRING_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gthreadprivate.h b/navit/support/glib/gthreadprivate.h
deleted file mode 100644
index c9b5fa50d..000000000
--- a/navit/support/glib/gthreadprivate.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- *
- * gthreadprivate.h - GLib internal thread system related declarations.
- *
- * Copyright (C) 2003 Sebastian Wilhelmi
- *
- * The Gnome Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * The Gnome Library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the Gnome Library; see the file COPYING.LIB. If not,
- * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#ifndef __G_THREADPRIVATE_H__
-#define __G_THREADPRIVATE_H__
-
-G_BEGIN_DECLS
-
-/* System thread identifier comparision and assignment */
-#if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P
-# define g_system_thread_equal_simple(thread1, thread2) \
- ((thread1).dummy_pointer == (thread2).dummy_pointer)
-# define g_system_thread_assign(dest, src) \
- ((dest).dummy_pointer = (src).dummy_pointer)
-#else /* GLIB_SIZEOF_SYSTEM_THREAD != SIZEOF_VOID_P */
-# define g_system_thread_equal_simple(thread1, thread2) \
- (memcmp (&(thread1), &(thread2), GLIB_SIZEOF_SYSTEM_THREAD) == 0)
-# define g_system_thread_assign(dest, src) \
- (memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD))
-#endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */
-
-#define g_system_thread_equal(thread1, thread2) \
- (g_thread_functions_for_glib_use.thread_equal ? \
- g_thread_functions_for_glib_use.thread_equal (&(thread1), &(thread2)) :\
- g_system_thread_equal_simple((thread1), (thread2)))
-
-/* Is called from gthread/gthread-impl.c */
-void g_thread_init_glib (void);
-
-/* base initializers, may only use g_mutex_new(), g_cond_new() */
-G_GNUC_INTERNAL void _g_mem_thread_init_noprivate_nomessage (void);
-/* initializers that may also use g_private_new() */
-G_GNUC_INTERNAL void _g_slice_thread_init_nomessage (void);
-G_GNUC_INTERNAL void _g_messages_thread_init_nomessage (void);
-
-/* full fledged initializers */
-G_GNUC_INTERNAL void _g_convert_thread_init (void);
-G_GNUC_INTERNAL void _g_rand_thread_init (void);
-G_GNUC_INTERNAL void _g_main_thread_init (void);
-G_GNUC_INTERNAL void _g_atomic_thread_init (void);
-G_GNUC_INTERNAL void _g_utils_thread_init (void);
-
-#ifdef G_OS_WIN32
-G_GNUC_INTERNAL void _g_win32_thread_init (void);
-#endif /* G_OS_WIN32 */
-
-G_END_DECLS
-
-#endif /* __G_THREADPRIVATE_H__ */
diff --git a/navit/support/glib/gtypes.h b/navit/support/glib/gtypes.h
deleted file mode 100644
index 3ac98fd4a..000000000
--- a/navit/support/glib/gtypes.h
+++ /dev/null
@@ -1,432 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_TYPES_H__
-#define __G_TYPES_H__
-
-#include <glibconfig.h>
-
-G_BEGIN_DECLS
-
-/* Provide type definitions for commonly used types.
- * These are useful because a "gint8" can be adjusted
- * to be 1 byte (8 bits) on all platforms. Similarly and
- * more importantly, "gint32" can be adjusted to be
- * 4 bytes (32 bits) on all platforms.
- */
-
-typedef char gchar;
-typedef short gshort;
-typedef long glong;
-typedef int gint;
-typedef gint gboolean;
-
-typedef unsigned char guchar;
-typedef unsigned short gushort;
-typedef unsigned long gulong;
-typedef unsigned int guint;
-
-typedef float gfloat;
-typedef double gdouble;
-
-/* Define min and max constants for the fixed size numerical types */
-#define G_MININT8 ((gint8) 0x80)
-#define G_MAXINT8 ((gint8) 0x7f)
-#define G_MAXUINT8 ((guint8) 0xff)
-
-#define G_MININT16 ((gint16) 0x8000)
-#define G_MAXINT16 ((gint16) 0x7fff)
-#define G_MAXUINT16 ((guint16) 0xffff)
-
-#define G_MININT32 ((gint32) 0x80000000)
-#define G_MAXINT32 ((gint32) 0x7fffffff)
-#define G_MAXUINT32 ((guint32) 0xffffffff)
-
-#define G_MININT64 ((gint64) G_GINT64_CONSTANT(0x8000000000000000))
-#define G_MAXINT64 G_GINT64_CONSTANT(0x7fffffffffffffff)
-#define G_MAXUINT64 G_GINT64_CONSTANT(0xffffffffffffffffU)
-
-typedef void* gpointer;
-typedef const void *gconstpointer;
-
-typedef gint (*GCompareFunc) (gconstpointer a,
- gconstpointer b);
-typedef gint (*GCompareDataFunc) (gconstpointer a,
- gconstpointer b,
- gpointer user_data);
-typedef gboolean (*GEqualFunc) (gconstpointer a,
- gconstpointer b);
-typedef void (*GDestroyNotify) (gpointer data);
-typedef void (*GFunc) (gpointer data,
- gpointer user_data);
-typedef guint (*GHashFunc) (gconstpointer key);
-typedef void (*GHFunc) (gpointer key,
- gpointer value,
- gpointer user_data);
-typedef void (*GFreeFunc) (gpointer data);
-typedef const gchar * (*GTranslateFunc) (const gchar *str,
- gpointer data);
-
-
-/* Define some mathematical constants that aren't available
- * symbolically in some strict ISO C implementations.
- *
- * Note that the large number of digits used in these definitions
- * doesn't imply that GLib or current computers in general would be
- * able to handle floating point numbers with an accuracy like this.
- * It's mostly an exercise in futility and future proofing. For
- * extended precision floating point support, look somewhere else
- * than GLib.
- */
-#define G_E 2.7182818284590452353602874713526624977572470937000
-#define G_LN2 0.69314718055994530941723212145817656807550013436026
-#define G_LN10 2.3025850929940456840179914546843642076011014886288
-#define G_PI 3.1415926535897932384626433832795028841971693993751
-#define G_PI_2 1.5707963267948966192313216916397514420985846996876
-#define G_PI_4 0.78539816339744830961566084581987572104929234984378
-#define G_SQRT2 1.4142135623730950488016887242096980785696718753769
-
-/* Portable endian checks and conversions
- *
- * glibconfig.h defines G_BYTE_ORDER which expands to one of
- * the below macros.
- */
-#define G_LITTLE_ENDIAN 1234
-#define G_BIG_ENDIAN 4321
-#define G_PDP_ENDIAN 3412 /* unused, need specific PDP check */
-
-
-/* Basic bit swapping functions
- */
-#define GUINT16_SWAP_LE_BE_CONSTANT(val) ((guint16) ( \
- (guint16) ((guint16) (val) >> 8) | \
- (guint16) ((guint16) (val) << 8)))
-
-#define GUINT32_SWAP_LE_BE_CONSTANT(val) ((guint32) ( \
- (((guint32) (val) & (guint32) 0x000000ffU) << 24) | \
- (((guint32) (val) & (guint32) 0x0000ff00U) << 8) | \
- (((guint32) (val) & (guint32) 0x00ff0000U) >> 8) | \
- (((guint32) (val) & (guint32) 0xff000000U) >> 24)))
-
-#define GUINT64_SWAP_LE_BE_CONSTANT(val) ((guint64) ( \
- (((guint64) (val) & \
- (guint64) G_GINT64_CONSTANT (0x00000000000000ffU)) << 56) | \
- (((guint64) (val) & \
- (guint64) G_GINT64_CONSTANT (0x000000000000ff00U)) << 40) | \
- (((guint64) (val) & \
- (guint64) G_GINT64_CONSTANT (0x0000000000ff0000U)) << 24) | \
- (((guint64) (val) & \
- (guint64) G_GINT64_CONSTANT (0x00000000ff000000U)) << 8) | \
- (((guint64) (val) & \
- (guint64) G_GINT64_CONSTANT (0x000000ff00000000U)) >> 8) | \
- (((guint64) (val) & \
- (guint64) G_GINT64_CONSTANT (0x0000ff0000000000U)) >> 24) | \
- (((guint64) (val) & \
- (guint64) G_GINT64_CONSTANT (0x00ff000000000000U)) >> 40) | \
- (((guint64) (val) & \
- (guint64) G_GINT64_CONSTANT (0xff00000000000000U)) >> 56)))
-
-/* Arch specific stuff for speed
- */
-#if defined (__GNUC__) && (__GNUC__ >= 2) && defined (__OPTIMIZE__)
-# if defined (__i386__)
-# define GUINT16_SWAP_LE_BE_IA32(val) \
- (__extension__ \
- ({ register guint16 __v, __x = ((guint16) (val)); \
- if (__builtin_constant_p (__x)) \
- __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \
- else \
- __asm__ ("rorw $8, %w0" \
- : "=r" (__v) \
- : "0" (__x) \
- : "cc"); \
- __v; }))
-# if !defined (__i486__) && !defined (__i586__) \
- && !defined (__pentium__) && !defined (__i686__) \
- && !defined (__pentiumpro__) && !defined (__pentium4__)
-# define GUINT32_SWAP_LE_BE_IA32(val) \
- (__extension__ \
- ({ register guint32 __v, __x = ((guint32) (val)); \
- if (__builtin_constant_p (__x)) \
- __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \
- else \
- __asm__ ("rorw $8, %w0\n\t" \
- "rorl $16, %0\n\t" \
- "rorw $8, %w0" \
- : "=r" (__v) \
- : "0" (__x) \
- : "cc"); \
- __v; }))
-# else /* 486 and higher has bswap */
-# define GUINT32_SWAP_LE_BE_IA32(val) \
- (__extension__ \
- ({ register guint32 __v, __x = ((guint32) (val)); \
- if (__builtin_constant_p (__x)) \
- __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \
- else \
- __asm__ ("bswap %0" \
- : "=r" (__v) \
- : "0" (__x)); \
- __v; }))
-# endif /* processor specific 32-bit stuff */
-# define GUINT64_SWAP_LE_BE_IA32(val) \
- (__extension__ \
- ({ union { guint64 __ll; \
- guint32 __l[2]; } __w, __r; \
- __w.__ll = ((guint64) (val)); \
- if (__builtin_constant_p (__w.__ll)) \
- __r.__ll = GUINT64_SWAP_LE_BE_CONSTANT (__w.__ll); \
- else \
- { \
- __r.__l[0] = GUINT32_SWAP_LE_BE (__w.__l[1]); \
- __r.__l[1] = GUINT32_SWAP_LE_BE (__w.__l[0]); \
- } \
- __r.__ll; }))
- /* Possibly just use the constant version and let gcc figure it out? */
-# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA32 (val))
-# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA32 (val))
-# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA32 (val))
-# elif defined (__ia64__)
-# define GUINT16_SWAP_LE_BE_IA64(val) \
- (__extension__ \
- ({ register guint16 __v, __x = ((guint16) (val)); \
- if (__builtin_constant_p (__x)) \
- __v = GUINT16_SWAP_LE_BE_CONSTANT (__x); \
- else \
- __asm__ __volatile__ ("shl %0 = %1, 48 ;;" \
- "mux1 %0 = %0, @rev ;;" \
- : "=r" (__v) \
- : "r" (__x)); \
- __v; }))
-# define GUINT32_SWAP_LE_BE_IA64(val) \
- (__extension__ \
- ({ register guint32 __v, __x = ((guint32) (val)); \
- if (__builtin_constant_p (__x)) \
- __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \
- else \
- __asm__ __volatile__ ("shl %0 = %1, 32 ;;" \
- "mux1 %0 = %0, @rev ;;" \
- : "=r" (__v) \
- : "r" (__x)); \
- __v; }))
-# define GUINT64_SWAP_LE_BE_IA64(val) \
- (__extension__ \
- ({ register guint64 __v, __x = ((guint64) (val)); \
- if (__builtin_constant_p (__x)) \
- __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \
- else \
- __asm__ __volatile__ ("mux1 %0 = %1, @rev ;;" \
- : "=r" (__v) \
- : "r" (__x)); \
- __v; }))
-# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_IA64 (val))
-# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_IA64 (val))
-# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_IA64 (val))
-# elif defined (__x86_64__)
-# define GUINT32_SWAP_LE_BE_X86_64(val) \
- (__extension__ \
- ({ register guint32 __v, __x = ((guint32) (val)); \
- if (__builtin_constant_p (__x)) \
- __v = GUINT32_SWAP_LE_BE_CONSTANT (__x); \
- else \
- __asm__ ("bswapl %0" \
- : "=r" (__v) \
- : "0" (__x)); \
- __v; }))
-# define GUINT64_SWAP_LE_BE_X86_64(val) \
- (__extension__ \
- ({ register guint64 __v, __x = ((guint64) (val)); \
- if (__builtin_constant_p (__x)) \
- __v = GUINT64_SWAP_LE_BE_CONSTANT (__x); \
- else \
- __asm__ ("bswapq %0" \
- : "=r" (__v) \
- : "0" (__x)); \
- __v; }))
- /* gcc seems to figure out optimal code for this on its own */
-# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
-# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_X86_64 (val))
-# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_X86_64 (val))
-# else /* generic gcc */
-# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
-# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val))
-# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val))
-# endif
-#else /* generic */
-# define GUINT16_SWAP_LE_BE(val) (GUINT16_SWAP_LE_BE_CONSTANT (val))
-# define GUINT32_SWAP_LE_BE(val) (GUINT32_SWAP_LE_BE_CONSTANT (val))
-# define GUINT64_SWAP_LE_BE(val) (GUINT64_SWAP_LE_BE_CONSTANT (val))
-#endif /* generic */
-
-#define GUINT16_SWAP_LE_PDP(val) ((guint16) (val))
-#define GUINT16_SWAP_BE_PDP(val) (GUINT16_SWAP_LE_BE (val))
-#define GUINT32_SWAP_LE_PDP(val) ((guint32) ( \
- (((guint32) (val) & (guint32) 0x0000ffffU) << 16) | \
- (((guint32) (val) & (guint32) 0xffff0000U) >> 16)))
-#define GUINT32_SWAP_BE_PDP(val) ((guint32) ( \
- (((guint32) (val) & (guint32) 0x00ff00ffU) << 8) | \
- (((guint32) (val) & (guint32) 0xff00ff00U) >> 8)))
-
-/* The G*_TO_?E() macros are defined in glibconfig.h.
- * The transformation is symmetric, so the FROM just maps to the TO.
- */
-#define GINT16_FROM_LE(val) (GINT16_TO_LE (val))
-#define GUINT16_FROM_LE(val) (GUINT16_TO_LE (val))
-#define GINT16_FROM_BE(val) (GINT16_TO_BE (val))
-#define GUINT16_FROM_BE(val) (GUINT16_TO_BE (val))
-#define GINT32_FROM_LE(val) (GINT32_TO_LE (val))
-#define GUINT32_FROM_LE(val) (GUINT32_TO_LE (val))
-#define GINT32_FROM_BE(val) (GINT32_TO_BE (val))
-#define GUINT32_FROM_BE(val) (GUINT32_TO_BE (val))
-
-#define GINT64_FROM_LE(val) (GINT64_TO_LE (val))
-#define GUINT64_FROM_LE(val) (GUINT64_TO_LE (val))
-#define GINT64_FROM_BE(val) (GINT64_TO_BE (val))
-#define GUINT64_FROM_BE(val) (GUINT64_TO_BE (val))
-
-#define GLONG_FROM_LE(val) (GLONG_TO_LE (val))
-#define GULONG_FROM_LE(val) (GULONG_TO_LE (val))
-#define GLONG_FROM_BE(val) (GLONG_TO_BE (val))
-#define GULONG_FROM_BE(val) (GULONG_TO_BE (val))
-
-#define GINT_FROM_LE(val) (GINT_TO_LE (val))
-#define GUINT_FROM_LE(val) (GUINT_TO_LE (val))
-#define GINT_FROM_BE(val) (GINT_TO_BE (val))
-#define GUINT_FROM_BE(val) (GUINT_TO_BE (val))
-
-
-/* Portable versions of host-network order stuff
- */
-#define g_ntohl(val) (GUINT32_FROM_BE (val))
-#define g_ntohs(val) (GUINT16_FROM_BE (val))
-#define g_htonl(val) (GUINT32_TO_BE (val))
-#define g_htons(val) (GUINT16_TO_BE (val))
-
-/* IEEE Standard 754 Single Precision Storage Format (gfloat):
- *
- * 31 30 23 22 0
- * +--------+---------------+---------------+
- * | s 1bit | e[30:23] 8bit | f[22:0] 23bit |
- * +--------+---------------+---------------+
- * B0------------------->B1------->B2-->B3-->
- *
- * IEEE Standard 754 Double Precision Storage Format (gdouble):
- *
- * 63 62 52 51 32 31 0
- * +--------+----------------+----------------+ +---------------+
- * | s 1bit | e[62:52] 11bit | f[51:32] 20bit | | f[31:0] 32bit |
- * +--------+----------------+----------------+ +---------------+
- * B0--------------->B1---------->B2--->B3----> B4->B5->B6->B7->
- */
-/* subtract from biased_exponent to form base2 exponent (normal numbers) */
-typedef union _GDoubleIEEE754 GDoubleIEEE754;
-typedef union _GFloatIEEE754 GFloatIEEE754;
-#define G_IEEE754_FLOAT_BIAS (127)
-#define G_IEEE754_DOUBLE_BIAS (1023)
-/* multiply with base2 exponent to get base10 exponent (normal numbers) */
-#define G_LOG_2_BASE_10 (0.30102999566398119521)
-#if G_BYTE_ORDER == G_LITTLE_ENDIAN
-union _GFloatIEEE754
-{
- gfloat v_float;
- struct {
- guint mantissa : 23;
- guint biased_exponent : 8;
- guint sign : 1;
- } mpn;
-};
-union _GDoubleIEEE754
-{
- gdouble v_double;
- struct {
- guint mantissa_low : 32;
- guint mantissa_high : 20;
- guint biased_exponent : 11;
- guint sign : 1;
- } mpn;
-};
-#elif G_BYTE_ORDER == G_BIG_ENDIAN
-union _GFloatIEEE754
-{
- gfloat v_float;
- struct {
- guint sign : 1;
- guint biased_exponent : 8;
- guint mantissa : 23;
- } mpn;
-};
-union _GDoubleIEEE754
-{
- gdouble v_double;
- struct {
- guint sign : 1;
- guint biased_exponent : 11;
- guint mantissa_high : 20;
- guint mantissa_low : 32;
- } mpn;
-};
-#else /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
-#error unknown ENDIAN type
-#endif /* !G_LITTLE_ENDIAN && !G_BIG_ENDIAN */
-
-typedef struct _GTimeVal GTimeVal;
-
-struct _GTimeVal
-{
- glong tv_sec;
- glong tv_usec;
-};
-
-G_END_DECLS
-
-/* We prefix variable declarations so they can
- * properly get exported in Windows DLLs.
- */
-#ifndef GLIB_VAR
-# ifdef G_PLATFORM_WIN32
-# ifdef GLIB_STATIC_COMPILATION
-# define GLIB_VAR extern
-# else /* !GLIB_STATIC_COMPILATION */
-# ifdef GLIB_COMPILATION
-# ifdef DLL_EXPORT
-# define GLIB_VAR __declspec(dllexport)
-# else /* !DLL_EXPORT */
-# define GLIB_VAR extern
-# endif /* !DLL_EXPORT */
-# else /* !GLIB_COMPILATION */
-# define GLIB_VAR extern __declspec(dllimport)
-# endif /* !GLIB_COMPILATION */
-# endif /* !GLIB_STATIC_COMPILATION */
-# else /* !G_PLATFORM_WIN32 */
-# define GLIB_VAR extern
-# endif /* !G_PLATFORM_WIN32 */
-#endif /* GLIB_VAR */
-
-#endif /* __G_TYPES_H__ */
diff --git a/navit/support/glib/gunicode.h b/navit/support/glib/gunicode.h
deleted file mode 100644
index 78b259e44..000000000
--- a/navit/support/glib/gunicode.h
+++ /dev/null
@@ -1,404 +0,0 @@
-/* gunicode.h - Unicode manipulation functions
- *
- * Copyright (C) 1999, 2000 Tom Tromey
- * Copyright 2000, 2005 Red Hat, Inc.
- *
- * The Gnome Library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * The Gnome Library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with the Gnome Library; see the file COPYING.LIB. If not,
- * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_UNICODE_H__
-#define __G_UNICODE_H__
-
-#include <glib/gerror.h>
-#include <glib/gtypes.h>
-
-G_BEGIN_DECLS
-
-typedef guint32 gunichar;
-typedef guint16 gunichar2;
-
-/* These are the possible character classifications.
- * See http://www.unicode.org/Public/UNIDATA/UCD.html#General_Category_Values
- */
-typedef enum
-{
- G_UNICODE_CONTROL,
- G_UNICODE_FORMAT,
- G_UNICODE_UNASSIGNED,
- G_UNICODE_PRIVATE_USE,
- G_UNICODE_SURROGATE,
- G_UNICODE_LOWERCASE_LETTER,
- G_UNICODE_MODIFIER_LETTER,
- G_UNICODE_OTHER_LETTER,
- G_UNICODE_TITLECASE_LETTER,
- G_UNICODE_UPPERCASE_LETTER,
- G_UNICODE_COMBINING_MARK,
- G_UNICODE_ENCLOSING_MARK,
- G_UNICODE_NON_SPACING_MARK,
- G_UNICODE_DECIMAL_NUMBER,
- G_UNICODE_LETTER_NUMBER,
- G_UNICODE_OTHER_NUMBER,
- G_UNICODE_CONNECT_PUNCTUATION,
- G_UNICODE_DASH_PUNCTUATION,
- G_UNICODE_CLOSE_PUNCTUATION,
- G_UNICODE_FINAL_PUNCTUATION,
- G_UNICODE_INITIAL_PUNCTUATION,
- G_UNICODE_OTHER_PUNCTUATION,
- G_UNICODE_OPEN_PUNCTUATION,
- G_UNICODE_CURRENCY_SYMBOL,
- G_UNICODE_MODIFIER_SYMBOL,
- G_UNICODE_MATH_SYMBOL,
- G_UNICODE_OTHER_SYMBOL,
- G_UNICODE_LINE_SEPARATOR,
- G_UNICODE_PARAGRAPH_SEPARATOR,
- G_UNICODE_SPACE_SEPARATOR
-} GUnicodeType;
-
-/* These are the possible line break classifications.
- * Note that new types may be added in the future.
- * Implementations may regard unknown values like G_UNICODE_BREAK_UNKNOWN
- * See http://www.unicode.org/unicode/reports/tr14/
- */
-typedef enum
-{
- G_UNICODE_BREAK_MANDATORY,
- G_UNICODE_BREAK_CARRIAGE_RETURN,
- G_UNICODE_BREAK_LINE_FEED,
- G_UNICODE_BREAK_COMBINING_MARK,
- G_UNICODE_BREAK_SURROGATE,
- G_UNICODE_BREAK_ZERO_WIDTH_SPACE,
- G_UNICODE_BREAK_INSEPARABLE,
- G_UNICODE_BREAK_NON_BREAKING_GLUE,
- G_UNICODE_BREAK_CONTINGENT,
- G_UNICODE_BREAK_SPACE,
- G_UNICODE_BREAK_AFTER,
- G_UNICODE_BREAK_BEFORE,
- G_UNICODE_BREAK_BEFORE_AND_AFTER,
- G_UNICODE_BREAK_HYPHEN,
- G_UNICODE_BREAK_NON_STARTER,
- G_UNICODE_BREAK_OPEN_PUNCTUATION,
- G_UNICODE_BREAK_CLOSE_PUNCTUATION,
- G_UNICODE_BREAK_QUOTATION,
- G_UNICODE_BREAK_EXCLAMATION,
- G_UNICODE_BREAK_IDEOGRAPHIC,
- G_UNICODE_BREAK_NUMERIC,
- G_UNICODE_BREAK_INFIX_SEPARATOR,
- G_UNICODE_BREAK_SYMBOL,
- G_UNICODE_BREAK_ALPHABETIC,
- G_UNICODE_BREAK_PREFIX,
- G_UNICODE_BREAK_POSTFIX,
- G_UNICODE_BREAK_COMPLEX_CONTEXT,
- G_UNICODE_BREAK_AMBIGUOUS,
- G_UNICODE_BREAK_UNKNOWN,
- G_UNICODE_BREAK_NEXT_LINE,
- G_UNICODE_BREAK_WORD_JOINER,
- G_UNICODE_BREAK_HANGUL_L_JAMO,
- G_UNICODE_BREAK_HANGUL_V_JAMO,
- G_UNICODE_BREAK_HANGUL_T_JAMO,
- G_UNICODE_BREAK_HANGUL_LV_SYLLABLE,
- G_UNICODE_BREAK_HANGUL_LVT_SYLLABLE
-} GUnicodeBreakType;
-
-typedef enum
-{ /* ISO 15924 code */
- G_UNICODE_SCRIPT_INVALID_CODE = -1,
- G_UNICODE_SCRIPT_COMMON = 0, /* Zyyy */
- G_UNICODE_SCRIPT_INHERITED, /* Qaai */
- G_UNICODE_SCRIPT_ARABIC, /* Arab */
- G_UNICODE_SCRIPT_ARMENIAN, /* Armn */
- G_UNICODE_SCRIPT_BENGALI, /* Beng */
- G_UNICODE_SCRIPT_BOPOMOFO, /* Bopo */
- G_UNICODE_SCRIPT_CHEROKEE, /* Cher */
- G_UNICODE_SCRIPT_COPTIC, /* Qaac */
- G_UNICODE_SCRIPT_CYRILLIC, /* Cyrl (Cyrs) */
- G_UNICODE_SCRIPT_DESERET, /* Dsrt */
- G_UNICODE_SCRIPT_DEVANAGARI, /* Deva */
- G_UNICODE_SCRIPT_ETHIOPIC, /* Ethi */
- G_UNICODE_SCRIPT_GEORGIAN, /* Geor (Geon, Geoa) */
- G_UNICODE_SCRIPT_GOTHIC, /* Goth */
- G_UNICODE_SCRIPT_GREEK, /* Grek */
- G_UNICODE_SCRIPT_GUJARATI, /* Gujr */
- G_UNICODE_SCRIPT_GURMUKHI, /* Guru */
- G_UNICODE_SCRIPT_HAN, /* Hani */
- G_UNICODE_SCRIPT_HANGUL, /* Hang */
- G_UNICODE_SCRIPT_HEBREW, /* Hebr */
- G_UNICODE_SCRIPT_HIRAGANA, /* Hira */
- G_UNICODE_SCRIPT_KANNADA, /* Knda */
- G_UNICODE_SCRIPT_KATAKANA, /* Kana */
- G_UNICODE_SCRIPT_KHMER, /* Khmr */
- G_UNICODE_SCRIPT_LAO, /* Laoo */
- G_UNICODE_SCRIPT_LATIN, /* Latn (Latf, Latg) */
- G_UNICODE_SCRIPT_MALAYALAM, /* Mlym */
- G_UNICODE_SCRIPT_MONGOLIAN, /* Mong */
- G_UNICODE_SCRIPT_MYANMAR, /* Mymr */
- G_UNICODE_SCRIPT_OGHAM, /* Ogam */
- G_UNICODE_SCRIPT_OLD_ITALIC, /* Ital */
- G_UNICODE_SCRIPT_ORIYA, /* Orya */
- G_UNICODE_SCRIPT_RUNIC, /* Runr */
- G_UNICODE_SCRIPT_SINHALA, /* Sinh */
- G_UNICODE_SCRIPT_SYRIAC, /* Syrc (Syrj, Syrn, Syre) */
- G_UNICODE_SCRIPT_TAMIL, /* Taml */
- G_UNICODE_SCRIPT_TELUGU, /* Telu */
- G_UNICODE_SCRIPT_THAANA, /* Thaa */
- G_UNICODE_SCRIPT_THAI, /* Thai */
- G_UNICODE_SCRIPT_TIBETAN, /* Tibt */
- G_UNICODE_SCRIPT_CANADIAN_ABORIGINAL, /* Cans */
- G_UNICODE_SCRIPT_YI, /* Yiii */
- G_UNICODE_SCRIPT_TAGALOG, /* Tglg */
- G_UNICODE_SCRIPT_HANUNOO, /* Hano */
- G_UNICODE_SCRIPT_BUHID, /* Buhd */
- G_UNICODE_SCRIPT_TAGBANWA, /* Tagb */
-
- /* Unicode-4.0 additions */
- G_UNICODE_SCRIPT_BRAILLE, /* Brai */
- G_UNICODE_SCRIPT_CYPRIOT, /* Cprt */
- G_UNICODE_SCRIPT_LIMBU, /* Limb */
- G_UNICODE_SCRIPT_OSMANYA, /* Osma */
- G_UNICODE_SCRIPT_SHAVIAN, /* Shaw */
- G_UNICODE_SCRIPT_LINEAR_B, /* Linb */
- G_UNICODE_SCRIPT_TAI_LE, /* Tale */
- G_UNICODE_SCRIPT_UGARITIC, /* Ugar */
-
- /* Unicode-4.1 additions */
- G_UNICODE_SCRIPT_NEW_TAI_LUE, /* Talu */
- G_UNICODE_SCRIPT_BUGINESE, /* Bugi */
- G_UNICODE_SCRIPT_GLAGOLITIC, /* Glag */
- G_UNICODE_SCRIPT_TIFINAGH, /* Tfng */
- G_UNICODE_SCRIPT_SYLOTI_NAGRI, /* Sylo */
- G_UNICODE_SCRIPT_OLD_PERSIAN, /* Xpeo */
- G_UNICODE_SCRIPT_KHAROSHTHI, /* Khar */
-
- /* Unicode-5.0 additions */
- G_UNICODE_SCRIPT_UNKNOWN, /* Zzzz */
- G_UNICODE_SCRIPT_BALINESE, /* Bali */
- G_UNICODE_SCRIPT_CUNEIFORM, /* Xsux */
- G_UNICODE_SCRIPT_PHOENICIAN, /* Phnx */
- G_UNICODE_SCRIPT_PHAGS_PA, /* Phag */
- G_UNICODE_SCRIPT_NKO, /* Nkoo */
-
- /* Unicode-5.1 additions */
- G_UNICODE_SCRIPT_KAYAH_LI, /* Kali */
- G_UNICODE_SCRIPT_LEPCHA, /* Lepc */
- G_UNICODE_SCRIPT_REJANG, /* Rjng */
- G_UNICODE_SCRIPT_SUNDANESE, /* Sund */
- G_UNICODE_SCRIPT_SAURASHTRA, /* Saur */
- G_UNICODE_SCRIPT_CHAM, /* Cham */
- G_UNICODE_SCRIPT_OL_CHIKI, /* Olck */
- G_UNICODE_SCRIPT_VAI, /* Vaii */
- G_UNICODE_SCRIPT_CARIAN, /* Cari */
- G_UNICODE_SCRIPT_LYCIAN, /* Lyci */
- G_UNICODE_SCRIPT_LYDIAN /* Lydi */
-} GUnicodeScript;
-
-/* Returns TRUE if current locale uses UTF-8 charset. If CHARSET is
- * not null, sets *CHARSET to the name of the current locale's
- * charset. This value is statically allocated, and should be copied
- * in case the locale's charset will be changed later using setlocale()
- * or in some other way.
- */
-gboolean g_get_charset (G_CONST_RETURN char **charset);
-
-/* These are all analogs of the <ctype.h> functions.
- */
-gboolean g_unichar_isalnum (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_isalpha (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_iscntrl (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_isdigit (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_isgraph (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_islower (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_isprint (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_ispunct (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_isspace (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_isupper (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_isxdigit (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_istitle (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_isdefined (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_iswide (gunichar c) G_GNUC_CONST;
-gboolean g_unichar_iswide_cjk(gunichar c) G_GNUC_CONST;
-gboolean g_unichar_iszerowidth(gunichar c) G_GNUC_CONST;
-gboolean g_unichar_ismark (gunichar c) G_GNUC_CONST;
-
-/* More <ctype.h> functions. These convert between the three cases.
- * See the Unicode book to understand title case. */
-gunichar g_unichar_toupper (gunichar c) G_GNUC_CONST;
-gunichar g_unichar_tolower (gunichar c) G_GNUC_CONST;
-gunichar g_unichar_totitle (gunichar c) G_GNUC_CONST;
-
-/* If C is a digit (according to `g_unichar_isdigit'), then return its
- numeric value. Otherwise return -1. */
-gint g_unichar_digit_value (gunichar c) G_GNUC_CONST;
-
-gint g_unichar_xdigit_value (gunichar c) G_GNUC_CONST;
-
-/* Return the Unicode character type of a given character. */
-GUnicodeType g_unichar_type (gunichar c) G_GNUC_CONST;
-
-/* Return the line break property for a given character */
-GUnicodeBreakType g_unichar_break_type (gunichar c) G_GNUC_CONST;
-
-/* Returns the combining class for a given character */
-gint g_unichar_combining_class (gunichar uc) G_GNUC_CONST;
-
-
-/* Compute canonical ordering of a string in-place. This rearranges
- decomposed characters in the string according to their combining
- classes. See the Unicode manual for more information. */
-void g_unicode_canonical_ordering (gunichar *string,
- gsize len);
-
-/* Compute canonical decomposition of a character. Returns g_malloc()d
- string of Unicode characters. RESULT_LEN is set to the resulting
- length of the string. */
-gunichar *g_unicode_canonical_decomposition (gunichar ch,
- gsize *result_len) G_GNUC_MALLOC;
-
-/* Array of skip-bytes-per-initial character.
- */
-GLIB_VAR const gchar * const g_utf8_skip;
-
-#define g_utf8_next_char(p) (char *)((p) + g_utf8_skip[*(const guchar *)(p)])
-
-gunichar g_utf8_get_char (const gchar *p) G_GNUC_PURE;
-gunichar g_utf8_get_char_validated (const gchar *p,
- gssize max_len) G_GNUC_PURE;
-
-gchar* g_utf8_offset_to_pointer (const gchar *str,
- glong offset) G_GNUC_PURE;
-glong g_utf8_pointer_to_offset (const gchar *str,
- const gchar *pos) G_GNUC_PURE;
-gchar* g_utf8_prev_char (const gchar *p) G_GNUC_PURE;
-gchar* g_utf8_find_next_char (const gchar *p,
- const gchar *end) G_GNUC_PURE;
-gchar* g_utf8_find_prev_char (const gchar *str,
- const gchar *p) G_GNUC_PURE;
-
-glong g_utf8_strlen (const gchar *p,
- gssize max) G_GNUC_PURE;
-
-/* Copies n characters from src to dest */
-gchar* g_utf8_strncpy (gchar *dest,
- const gchar *src,
- gsize n);
-
-/* Find the UTF-8 character corresponding to ch, in string p. These
- functions are equivalants to strchr and strrchr */
-gchar* g_utf8_strchr (const gchar *p,
- gssize len,
- gunichar c);
-gchar* g_utf8_strrchr (const gchar *p,
- gssize len,
- gunichar c);
-gchar* g_utf8_strreverse (const gchar *str,
- gssize len);
-
-gunichar2 *g_utf8_to_utf16 (const gchar *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error) G_GNUC_MALLOC;
-gunichar * g_utf8_to_ucs4 (const gchar *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error) G_GNUC_MALLOC;
-gunichar * g_utf8_to_ucs4_fast (const gchar *str,
- glong len,
- glong *items_written) G_GNUC_MALLOC;
-gunichar * g_utf16_to_ucs4 (const gunichar2 *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error) G_GNUC_MALLOC;
-gchar* g_utf16_to_utf8 (const gunichar2 *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error) G_GNUC_MALLOC;
-gunichar2 *g_ucs4_to_utf16 (const gunichar *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error) G_GNUC_MALLOC;
-gchar* g_ucs4_to_utf8 (const gunichar *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error) G_GNUC_MALLOC;
-
-/* Convert a single character into UTF-8. outbuf must have at
- * least 6 bytes of space. Returns the number of bytes in the
- * result.
- */
-gint g_unichar_to_utf8 (gunichar c,
- gchar *outbuf);
-
-/* Validate a UTF8 string, return TRUE if valid, put pointer to
- * first invalid char in **end
- */
-
-gboolean g_utf8_validate (const gchar *str,
- gssize max_len,
- const gchar **end);
-
-/* Validate a Unicode character */
-gboolean g_unichar_validate (gunichar ch) G_GNUC_CONST;
-
-gchar *g_utf8_strup (const gchar *str,
- gssize len) G_GNUC_MALLOC;
-gchar *g_utf8_strdown (const gchar *str,
- gssize len) G_GNUC_MALLOC;
-gchar *g_utf8_casefold (const gchar *str,
- gssize len) G_GNUC_MALLOC;
-
-typedef enum {
- G_NORMALIZE_DEFAULT,
- G_NORMALIZE_NFD = G_NORMALIZE_DEFAULT,
- G_NORMALIZE_DEFAULT_COMPOSE,
- G_NORMALIZE_NFC = G_NORMALIZE_DEFAULT_COMPOSE,
- G_NORMALIZE_ALL,
- G_NORMALIZE_NFKD = G_NORMALIZE_ALL,
- G_NORMALIZE_ALL_COMPOSE,
- G_NORMALIZE_NFKC = G_NORMALIZE_ALL_COMPOSE
-} GNormalizeMode;
-
-gchar *g_utf8_normalize (const gchar *str,
- gssize len,
- GNormalizeMode mode) G_GNUC_MALLOC;
-
-gint g_utf8_collate (const gchar *str1,
- const gchar *str2) G_GNUC_PURE;
-gchar *g_utf8_collate_key (const gchar *str,
- gssize len) G_GNUC_MALLOC;
-gchar *g_utf8_collate_key_for_filename (const gchar *str,
- gssize len) G_GNUC_MALLOC;
-
-gboolean g_unichar_get_mirror_char (gunichar ch,
- gunichar *mirrored_ch);
-
-GUnicodeScript g_unichar_get_script (gunichar ch) G_GNUC_CONST;
-
-
-/* private */
-
-gchar *_g_utf8_make_valid (const gchar *name);
-
-G_END_DECLS
-
-#endif /* __G_UNICODE_H__ */
diff --git a/navit/support/glib/gutf8.c b/navit/support/glib/gutf8.c
deleted file mode 100644
index d6cd83bbf..000000000
--- a/navit/support/glib/gutf8.c
+++ /dev/null
@@ -1,1891 +0,0 @@
-/* gutf8.c - Operations on UTF-8 strings.
- *
- * Copyright (C) 1999 Tom Tromey
- * Copyright (C) 2000 Red Hat, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-#include "config.h"
-
-#include <stdlib.h>
-#ifdef HAVE_CODESET
-#include <langinfo.h>
-#endif
-#include <string.h>
-
-#include "glib.h"
-
-#ifdef G_PLATFORM_WIN32
-#include <stdio.h>
-#define STRICT
-#include <windows.h>
-#undef STRICT
-#endif
-
-#ifdef NOT_NEEDED_FOR_NAVIT
-#include "libcharset/libcharset.h"
-
-#include "glibintl.h"
-#include "galias.h"
-#endif
-
-#define UTF8_COMPUTE(Char, Mask, Len) \
- if (Char < 128) \
- { \
- Len = 1; \
- Mask = 0x7f; \
- } \
- else if ((Char & 0xe0) == 0xc0) \
- { \
- Len = 2; \
- Mask = 0x1f; \
- } \
- else if ((Char & 0xf0) == 0xe0) \
- { \
- Len = 3; \
- Mask = 0x0f; \
- } \
- else if ((Char & 0xf8) == 0xf0) \
- { \
- Len = 4; \
- Mask = 0x07; \
- } \
- else if ((Char & 0xfc) == 0xf8) \
- { \
- Len = 5; \
- Mask = 0x03; \
- } \
- else if ((Char & 0xfe) == 0xfc) \
- { \
- Len = 6; \
- Mask = 0x01; \
- } \
- else \
- Len = -1;
-
-#define UTF8_LENGTH(Char) \
- ((Char) < 0x80 ? 1 : \
- ((Char) < 0x800 ? 2 : \
- ((Char) < 0x10000 ? 3 : \
- ((Char) < 0x200000 ? 4 : \
- ((Char) < 0x4000000 ? 5 : 6)))))
-
-
-#define UTF8_GET(Result, Chars, Count, Mask, Len) \
- (Result) = (Chars)[0] & (Mask); \
- for ((Count) = 1; (Count) < (Len); ++(Count)) \
- { \
- if (((Chars)[(Count)] & 0xc0) != 0x80) \
- { \
- (Result) = -1; \
- break; \
- } \
- (Result) <<= 6; \
- (Result) |= ((Chars)[(Count)] & 0x3f); \
- }
-
-#define UNICODE_VALID(Char) \
- ((Char) < 0x110000 && \
- (((Char) & 0xFFFFF800) != 0xD800) && \
- ((Char) < 0xFDD0 || (Char) > 0xFDEF) && \
- ((Char) & 0xFFFE) != 0xFFFE)
-
-
-static const gchar utf8_skip_data[256] = {
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
- 3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,6,6,1,1
-};
-
-const gchar * const g_utf8_skip = utf8_skip_data;
-
-/**
- * g_utf8_find_prev_char:
- * @str: pointer to the beginning of a UTF-8 encoded string
- * @p: pointer to some position within @str
- *
- * Given a position @p with a UTF-8 encoded string @str, find the start
- * of the previous UTF-8 character starting before @p. Returns %NULL if no
- * UTF-8 characters are present in @str before @p.
- *
- * @p does not have to be at the beginning of a UTF-8 character. No check
- * is made to see if the character found is actually valid other than
- * it starts with an appropriate byte.
- *
- * Return value: a pointer to the found character or %NULL.
- **/
-gchar *
-g_utf8_find_prev_char (const char *str,
- const char *p)
-{
- for (--p; p >= str; --p)
- {
- if ((*p & 0xc0) != 0x80)
- return (gchar *)p;
- }
- return NULL;
-}
-
-/**
- * g_utf8_find_next_char:
- * @p: a pointer to a position within a UTF-8 encoded string
- * @end: a pointer to the byte following the end of the string,
- * or %NULL to indicate that the string is nul-terminated.
- *
- * Finds the start of the next UTF-8 character in the string after @p.
- *
- * @p does not have to be at the beginning of a UTF-8 character. No check
- * is made to see if the character found is actually valid other than
- * it starts with an appropriate byte.
- *
- * Return value: a pointer to the found character or %NULL
- **/
-gchar *
-g_utf8_find_next_char (const gchar *p,
- const gchar *end)
-{
- if (*p)
- {
- if (end)
- for (++p; p < end && (*p & 0xc0) == 0x80; ++p)
- ;
- else
- for (++p; (*p & 0xc0) == 0x80; ++p)
- ;
- }
- return (p == end) ? NULL : (gchar *)p;
-}
-
-/**
- * g_utf8_prev_char:
- * @p: a pointer to a position within a UTF-8 encoded string
- *
- * Finds the previous UTF-8 character in the string before @p.
- *
- * @p does not have to be at the beginning of a UTF-8 character. No check
- * is made to see if the character found is actually valid other than
- * it starts with an appropriate byte. If @p might be the first
- * character of the string, you must use g_utf8_find_prev_char() instead.
- *
- * Return value: a pointer to the found character.
- **/
-gchar *
-g_utf8_prev_char (const gchar *p)
-{
- while (TRUE)
- {
- p--;
- if ((*p & 0xc0) != 0x80)
- return (gchar *)p;
- }
-}
-
-/**
- * g_utf8_strlen:
- * @p: pointer to the start of a UTF-8 encoded string.
- * @max: the maximum number of bytes to examine. If @max
- * is less than 0, then the string is assumed to be
- * nul-terminated. If @max is 0, @p will not be examined and
- * may be %NULL.
- *
- * Returns the length of the string in characters.
- *
- * Return value: the length of the string in characters
- **/
-glong
-g_utf8_strlen (const gchar *p,
- gssize max)
-{
- glong len = 0;
- const gchar *start = p;
- g_return_val_if_fail (p != NULL || max == 0, 0);
-
- if (max < 0)
- {
- while (*p)
- {
- p = g_utf8_next_char (p);
- ++len;
- }
- }
- else
- {
- if (max == 0 || !*p)
- return 0;
-
- p = g_utf8_next_char (p);
-
- while (p - start < max && *p)
- {
- ++len;
- p = g_utf8_next_char (p);
- }
-
- /* only do the last len increment if we got a complete
- * char (don't count partial chars)
- */
- if (p - start <= max)
- ++len;
- }
-
- return len;
-}
-
-/**
- * g_utf8_get_char:
- * @p: a pointer to Unicode character encoded as UTF-8
- *
- * Converts a sequence of bytes encoded as UTF-8 to a Unicode character.
- * If @p does not point to a valid UTF-8 encoded character, results are
- * undefined. If you are not sure that the bytes are complete
- * valid Unicode characters, you should use g_utf8_get_char_validated()
- * instead.
- *
- * Return value: the resulting character
- **/
-gunichar
-g_utf8_get_char (const gchar *p)
-{
- int i, mask = 0, len;
- gunichar result;
- unsigned char c = (unsigned char) *p;
-
- UTF8_COMPUTE (c, mask, len);
- if (len == -1)
- return (gunichar)-1;
- UTF8_GET (result, p, i, mask, len);
-
- return result;
-}
-
-
-/**
- * g_utf8_offset_to_pointer:
- * @str: a UTF-8 encoded string
- * @offset: a character offset within @str
- *
- * Converts from an integer character offset to a pointer to a position
- * within the string.
- *
- * Since 2.10, this function allows to pass a negative @offset to
- * step backwards. It is usually worth stepping backwards from the end
- * instead of forwards if @offset is in the last fourth of the string,
- * since moving forward is about 3 times faster than moving backward.
- *
- * Return value: the resulting pointer
- **/
-gchar *
-g_utf8_offset_to_pointer (const gchar *str,
- glong offset)
-{
- const gchar *s = str;
-
- if (offset > 0)
- while (offset--)
- s = g_utf8_next_char (s);
- else
- {
- const char *s1;
-
- /* This nice technique for fast backwards stepping
- * through a UTF-8 string was dubbed "stutter stepping"
- * by its inventor, Larry Ewing.
- */
- while (offset)
- {
- s1 = s;
- s += offset;
- while ((*s & 0xc0) == 0x80)
- s--;
-
- offset += g_utf8_pointer_to_offset (s, s1);
- }
- }
-
- return (gchar *)s;
-}
-
-/**
- * g_utf8_pointer_to_offset:
- * @str: a UTF-8 encoded string
- * @pos: a pointer to a position within @str
- *
- * Converts from a pointer to position within a string to a integer
- * character offset.
- *
- * Since 2.10, this function allows @pos to be before @str, and returns
- * a negative offset in this case.
- *
- * Return value: the resulting character offset
- **/
-glong
-g_utf8_pointer_to_offset (const gchar *str,
- const gchar *pos)
-{
- const gchar *s = str;
- glong offset = 0;
-
- if (pos < str)
- offset = - g_utf8_pointer_to_offset (pos, str);
- else
- while (s < pos)
- {
- s = g_utf8_next_char (s);
- offset++;
- }
-
- return offset;
-}
-
-
-/**
- * g_utf8_strncpy:
- * @dest: buffer to fill with characters from @src
- * @src: UTF-8 encoded string
- * @n: character count
- *
- * Like the standard C strncpy() function, but
- * copies a given number of characters instead of a given number of
- * bytes. The @src string must be valid UTF-8 encoded text.
- * (Use g_utf8_validate() on all text before trying to use UTF-8
- * utility functions with it.)
- *
- * Return value: @dest
- **/
-gchar *
-g_utf8_strncpy (gchar *dest,
- const gchar *src,
- gsize n)
-{
- const gchar *s = src;
- while (n && *s)
- {
- s = g_utf8_next_char(s);
- n--;
- }
- strncpy(dest, src, s - src);
- dest[s - src] = 0;
- return dest;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-G_LOCK_DEFINE_STATIC (aliases);
-
-static GHashTable *
-get_alias_hash (void)
-{
- static GHashTable *alias_hash = NULL;
- const char *aliases;
-
- G_LOCK (aliases);
-
- if (!alias_hash)
- {
- alias_hash = g_hash_table_new (g_str_hash, g_str_equal);
-
- aliases = _g_locale_get_charset_aliases ();
- while (*aliases != '\0')
- {
- const char *canonical;
- const char *alias;
- const char **alias_array;
- int count = 0;
-
- alias = aliases;
- aliases += strlen (aliases) + 1;
- canonical = aliases;
- aliases += strlen (aliases) + 1;
-
- alias_array = g_hash_table_lookup (alias_hash, canonical);
- if (alias_array)
- {
- while (alias_array[count])
- count++;
- }
-
- alias_array = g_renew (const char *, alias_array, count + 2);
- alias_array[count] = alias;
- alias_array[count + 1] = NULL;
-
- g_hash_table_insert (alias_hash, (char *)canonical, alias_array);
- }
- }
-
- G_UNLOCK (aliases);
-
- return alias_hash;
-}
-
-/* As an abuse of the alias table, the following routines gets
- * the charsets that are aliases for the canonical name.
- */
-G_GNUC_INTERNAL const char **
-_g_charset_get_aliases (const char *canonical_name)
-{
- GHashTable *alias_hash = get_alias_hash ();
-
- return g_hash_table_lookup (alias_hash, canonical_name);
-}
-
-static gboolean
-g_utf8_get_charset_internal (const char *raw_data,
- const char **a)
-{
- const char *charset = getenv("CHARSET");
-
- if (charset && *charset)
- {
- *a = charset;
-
- if (charset && strstr (charset, "UTF-8"))
- return TRUE;
- else
- return FALSE;
- }
-
- /* The libcharset code tries to be thread-safe without
- * a lock, but has a memory leak and a missing memory
- * barrier, so we lock for it
- */
- G_LOCK (aliases);
- charset = _g_locale_charset_unalias (raw_data);
- G_UNLOCK (aliases);
-
- if (charset && *charset)
- {
- *a = charset;
-
- if (charset && strstr (charset, "UTF-8"))
- return TRUE;
- else
- return FALSE;
- }
-
- /* Assume this for compatibility at present. */
- *a = "US-ASCII";
-
- return FALSE;
-}
-
-typedef struct _GCharsetCache GCharsetCache;
-
-struct _GCharsetCache {
- gboolean is_utf8;
- gchar *raw;
- gchar *charset;
-};
-
-static void
-charset_cache_free (gpointer data)
-{
- GCharsetCache *cache = data;
- g_free (cache->raw);
- g_free (cache->charset);
- g_free (cache);
-}
-
-/**
- * g_get_charset:
- * @charset: return location for character set name
- *
- * Obtains the character set for the <link linkend="setlocale">current
- * locale</link>; you might use this character set as an argument to
- * g_convert(), to convert from the current locale's encoding to some
- * other encoding. (Frequently g_locale_to_utf8() and g_locale_from_utf8()
- * are nice shortcuts, though.)
- *
- * On Windows the character set returned by this function is the
- * so-called system default ANSI code-page. That is the character set
- * used by the "narrow" versions of C library and Win32 functions that
- * handle file names. It might be different from the character set
- * used by the C library's current locale.
- *
- * The return value is %TRUE if the locale's encoding is UTF-8, in that
- * case you can perhaps avoid calling g_convert().
- *
- * The string returned in @charset is not allocated, and should not be
- * freed.
- *
- * Return value: %TRUE if the returned charset is UTF-8
- **/
-gboolean
-g_get_charset (G_CONST_RETURN char **charset)
-{
- static GStaticPrivate cache_private = G_STATIC_PRIVATE_INIT;
- GCharsetCache *cache = g_static_private_get (&cache_private);
- const gchar *raw;
-
- if (!cache)
- {
- cache = g_new0 (GCharsetCache, 1);
- g_static_private_set (&cache_private, cache, charset_cache_free);
- }
-
- raw = _g_locale_charset_raw ();
-
- if (!(cache->raw && strcmp (cache->raw, raw) == 0))
- {
- const gchar *new_charset;
-
- g_free (cache->raw);
- g_free (cache->charset);
- cache->raw = g_strdup (raw);
- cache->is_utf8 = g_utf8_get_charset_internal (raw, &new_charset);
- cache->charset = g_strdup (new_charset);
- }
-
- if (charset)
- *charset = cache->charset;
-
- return cache->is_utf8;
-}
-#endif
-
-/* unicode_strchr */
-
-/**
- * g_unichar_to_utf8:
- * @c: a Unicode character code
- * @outbuf: output buffer, must have at least 6 bytes of space.
- * If %NULL, the length will be computed and returned
- * and nothing will be written to @outbuf.
- *
- * Converts a single character to UTF-8.
- *
- * Return value: number of bytes written
- **/
-int
-g_unichar_to_utf8 (gunichar c,
- gchar *outbuf)
-{
- /* If this gets modified, also update the copy in g_string_insert_unichar() */
- guint len = 0;
- int first;
- int i;
-
- if (c < 0x80)
- {
- first = 0;
- len = 1;
- }
- else if (c < 0x800)
- {
- first = 0xc0;
- len = 2;
- }
- else if (c < 0x10000)
- {
- first = 0xe0;
- len = 3;
- }
- else if (c < 0x200000)
- {
- first = 0xf0;
- len = 4;
- }
- else if (c < 0x4000000)
- {
- first = 0xf8;
- len = 5;
- }
- else
- {
- first = 0xfc;
- len = 6;
- }
-
- if (outbuf)
- {
- for (i = len - 1; i > 0; --i)
- {
- outbuf[i] = (c & 0x3f) | 0x80;
- c >>= 6;
- }
- outbuf[0] = c | first;
- }
-
- return len;
-}
-
-/**
- * g_utf8_strchr:
- * @p: a nul-terminated UTF-8 encoded string
- * @len: the maximum length of @p
- * @c: a Unicode character
- *
- * Finds the leftmost occurrence of the given Unicode character
- * in a UTF-8 encoded string, while limiting the search to @len bytes.
- * If @len is -1, allow unbounded search.
- *
- * Return value: %NULL if the string does not contain the character,
- * otherwise, a pointer to the start of the leftmost occurrence of
- * the character in the string.
- **/
-gchar *
-g_utf8_strchr (const char *p,
- gssize len,
- gunichar c)
-{
- gchar ch[10];
-
- gint charlen = g_unichar_to_utf8 (c, ch);
- ch[charlen] = '\0';
-
- return g_strstr_len (p, len, ch);
-}
-
-
-/**
- * g_utf8_strrchr:
- * @p: a nul-terminated UTF-8 encoded string
- * @len: the maximum length of @p
- * @c: a Unicode character
- *
- * Find the rightmost occurrence of the given Unicode character
- * in a UTF-8 encoded string, while limiting the search to @len bytes.
- * If @len is -1, allow unbounded search.
- *
- * Return value: %NULL if the string does not contain the character,
- * otherwise, a pointer to the start of the rightmost occurrence of the
- * character in the string.
- **/
-gchar *
-g_utf8_strrchr (const char *p,
- gssize len,
- gunichar c)
-{
- gchar ch[10];
-
- gint charlen = g_unichar_to_utf8 (c, ch);
- ch[charlen] = '\0';
-
- return g_strrstr_len (p, len, ch);
-}
-
-
-/* Like g_utf8_get_char, but take a maximum length
- * and return (gunichar)-2 on incomplete trailing character
- */
-static inline gunichar
-g_utf8_get_char_extended (const gchar *p,
- gssize max_len)
-{
- guint i, len;
- gunichar wc = (guchar) *p;
-
- if (wc < 0x80)
- {
- return wc;
- }
- else if (wc < 0xc0)
- {
- return (gunichar)-1;
- }
- else if (wc < 0xe0)
- {
- len = 2;
- wc &= 0x1f;
- }
- else if (wc < 0xf0)
- {
- len = 3;
- wc &= 0x0f;
- }
- else if (wc < 0xf8)
- {
- len = 4;
- wc &= 0x07;
- }
- else if (wc < 0xfc)
- {
- len = 5;
- wc &= 0x03;
- }
- else if (wc < 0xfe)
- {
- len = 6;
- wc &= 0x01;
- }
- else
- {
- return (gunichar)-1;
- }
-
- if (max_len >= 0 && len > max_len)
- {
- for (i = 1; i < max_len; i++)
- {
- if ((((guchar *)p)[i] & 0xc0) != 0x80)
- return (gunichar)-1;
- }
- return (gunichar)-2;
- }
-
- for (i = 1; i < len; ++i)
- {
- gunichar ch = ((guchar *)p)[i];
-
- if ((ch & 0xc0) != 0x80)
- {
- if (ch)
- return (gunichar)-1;
- else
- return (gunichar)-2;
- }
-
- wc <<= 6;
- wc |= (ch & 0x3f);
- }
-
- if (UTF8_LENGTH(wc) != len)
- return (gunichar)-1;
-
- return wc;
-}
-
-/**
- * g_utf8_get_char_validated:
- * @p: a pointer to Unicode character encoded as UTF-8
- * @max_len: the maximum number of bytes to read, or -1, for no maximum or
- * if @p is nul-terminated
- *
- * Convert a sequence of bytes encoded as UTF-8 to a Unicode character.
- * This function checks for incomplete characters, for invalid characters
- * such as characters that are out of the range of Unicode, and for
- * overlong encodings of valid characters.
- *
- * Return value: the resulting character. If @p points to a partial
- * sequence at the end of a string that could begin a valid
- * character (or if @max_len is zero), returns (gunichar)-2;
- * otherwise, if @p does not point to a valid UTF-8 encoded
- * Unicode character, returns (gunichar)-1.
- **/
-gunichar
-g_utf8_get_char_validated (const gchar *p,
- gssize max_len)
-{
- gunichar result;
-
- if (max_len == 0)
- return (gunichar)-2;
-
- result = g_utf8_get_char_extended (p, max_len);
-
- if (result & 0x80000000)
- return result;
- else if (!UNICODE_VALID (result))
- return (gunichar)-1;
- else
- return result;
-}
-
-/**
- * g_utf8_to_ucs4_fast:
- * @str: a UTF-8 encoded string
- * @len: the maximum length of @str to use, in bytes. If @len < 0,
- * then the string is nul-terminated.
- * @items_written: location to store the number of characters in the
- * result, or %NULL.
- *
- * Convert a string from UTF-8 to a 32-bit fixed width
- * representation as UCS-4, assuming valid UTF-8 input.
- * This function is roughly twice as fast as g_utf8_to_ucs4()
- * but does no error checking on the input.
- *
- * Return value: a pointer to a newly allocated UCS-4 string.
- * This value must be freed with g_free().
- **/
-gunichar *
-g_utf8_to_ucs4_fast (const gchar *str,
- glong len,
- glong *items_written)
-{
- gint j, charlen;
- gunichar *result;
- gint n_chars, i;
- const gchar *p;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- p = str;
- n_chars = 0;
- if (len < 0)
- {
- while (*p)
- {
- p = g_utf8_next_char (p);
- ++n_chars;
- }
- }
- else
- {
- while (p < str + len && *p)
- {
- p = g_utf8_next_char (p);
- ++n_chars;
- }
- }
-
- result = g_new (gunichar, n_chars + 1);
-
- p = str;
- for (i=0; i < n_chars; i++)
- {
- gunichar wc = ((unsigned char *)p)[0];
-
- if (wc < 0x80)
- {
- result[i] = wc;
- p++;
- }
- else
- {
- if (wc < 0xe0)
- {
- charlen = 2;
- wc &= 0x1f;
- }
- else if (wc < 0xf0)
- {
- charlen = 3;
- wc &= 0x0f;
- }
- else if (wc < 0xf8)
- {
- charlen = 4;
- wc &= 0x07;
- }
- else if (wc < 0xfc)
- {
- charlen = 5;
- wc &= 0x03;
- }
- else
- {
- charlen = 6;
- wc &= 0x01;
- }
-
- for (j = 1; j < charlen; j++)
- {
- wc <<= 6;
- wc |= ((unsigned char *)p)[j] & 0x3f;
- }
-
- result[i] = wc;
- p += charlen;
- }
- }
- result[i] = 0;
-
- if (items_written)
- *items_written = i;
-
- return result;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-/**
- * g_utf8_to_ucs4:
- * @str: a UTF-8 encoded string
- * @len: the maximum length of @str to use, in bytes. If @len < 0,
- * then the string is nul-terminated.
- * @items_read: location to store number of bytes read, or %NULL.
- * If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
- * returned in case @str contains a trailing partial
- * character. If an error occurs then the index of the
- * invalid input is stored here.
- * @items_written: location to store number of characters written or %NULL.
- * The value here stored does not include the trailing 0
- * character.
- * @error: location to store the error occuring, or %NULL to ignore
- * errors. Any of the errors in #GConvertError other than
- * %G_CONVERT_ERROR_NO_CONVERSION may occur.
- *
- * Convert a string from UTF-8 to a 32-bit fixed width
- * representation as UCS-4. A trailing 0 will be added to the
- * string after the converted text.
- *
- * Return value: a pointer to a newly allocated UCS-4 string.
- * This value must be freed with g_free(). If an
- * error occurs, %NULL will be returned and
- * @error set.
- **/
-gunichar *
-g_utf8_to_ucs4 (const gchar *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error)
-{
- gunichar *result = NULL;
- gint n_chars, i;
- const gchar *in;
-
- in = str;
- n_chars = 0;
- while ((len < 0 || str + len - in > 0) && *in)
- {
- gunichar wc = g_utf8_get_char_extended (in, len < 0 ? 6 : str + len - in);
- if (wc & 0x80000000)
- {
- if (wc == (gunichar)-2)
- {
- if (items_read)
- break;
- else
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
- _("Partial character sequence at end of input"));
- }
- else
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- _("Invalid byte sequence in conversion input"));
-
- goto err_out;
- }
-
- n_chars++;
-
- in = g_utf8_next_char (in);
- }
-
- result = g_new (gunichar, n_chars + 1);
-
- in = str;
- for (i=0; i < n_chars; i++)
- {
- result[i] = g_utf8_get_char (in);
- in = g_utf8_next_char (in);
- }
- result[i] = 0;
-
- if (items_written)
- *items_written = n_chars;
-
- err_out:
- if (items_read)
- *items_read = in - str;
-
- return result;
-}
-
-/**
- * g_ucs4_to_utf8:
- * @str: a UCS-4 encoded string
- * @len: the maximum length (number of characters) of @str to use.
- * If @len < 0, then the string is nul-terminated.
- * @items_read: location to store number of characters read, or %NULL.
- * @items_written: location to store number of bytes written or %NULL.
- * The value here stored does not include the trailing 0
- * byte.
- * @error: location to store the error occuring, or %NULL to ignore
- * errors. Any of the errors in #GConvertError other than
- * %G_CONVERT_ERROR_NO_CONVERSION may occur.
- *
- * Convert a string from a 32-bit fixed width representation as UCS-4.
- * to UTF-8. The result will be terminated with a 0 byte.
- *
- * Return value: a pointer to a newly allocated UTF-8 string.
- * This value must be freed with g_free(). If an
- * error occurs, %NULL will be returned and
- * @error set. In that case, @items_read will be
- * set to the position of the first invalid input
- * character.
- **/
-gchar *
-g_ucs4_to_utf8 (const gunichar *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error)
-{
- gint result_length;
- gchar *result = NULL;
- gchar *p;
- gint i;
-
- result_length = 0;
- for (i = 0; len < 0 || i < len ; i++)
- {
- if (!str[i])
- break;
-
- if (str[i] >= 0x80000000)
- {
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- _("Character out of range for UTF-8"));
- goto err_out;
- }
-
- result_length += UTF8_LENGTH (str[i]);
- }
-
- result = g_malloc (result_length + 1);
- p = result;
-
- i = 0;
- while (p < result + result_length)
- p += g_unichar_to_utf8 (str[i++], p);
-
- *p = '\0';
-
- if (items_written)
- *items_written = p - result;
-
- err_out:
- if (items_read)
- *items_read = i;
-
- return result;
-}
-#endif
-#define SURROGATE_VALUE(h,l) (((h) - 0xd800) * 0x400 + (l) - 0xdc00 + 0x10000)
-
-/**
- * g_utf16_to_utf8:
- * @str: a UTF-16 encoded string
- * @len: the maximum length (number of <type>gunichar2</type>) of @str to use.
- * If @len < 0, then the string is nul-terminated.
- * @items_read: location to store number of words read, or %NULL.
- * If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
- * returned in case @str contains a trailing partial
- * character. If an error occurs then the index of the
- * invalid input is stored here.
- * @items_written: location to store number of bytes written, or %NULL.
- * The value stored here does not include the trailing
- * 0 byte.
- * @error: location to store the error occuring, or %NULL to ignore
- * errors. Any of the errors in #GConvertError other than
- * %G_CONVERT_ERROR_NO_CONVERSION may occur.
- *
- * Convert a string from UTF-16 to UTF-8. The result will be
- * terminated with a 0 byte.
- *
- * Note that the input is expected to be already in native endianness,
- * an initial byte-order-mark character is not handled specially.
- * g_convert() can be used to convert a byte buffer of UTF-16 data of
- * ambiguous endianess.
- *
- * Return value: a pointer to a newly allocated UTF-8 string.
- * This value must be freed with g_free(). If an
- * error occurs, %NULL will be returned and
- * @error set.
- **/
-gchar *
-g_utf16_to_utf8 (const gunichar2 *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error)
-{
- /* This function and g_utf16_to_ucs4 are almost exactly identical - The lines that differ
- * are marked.
- */
- const gunichar2 *in;
- gchar *out;
- gchar *result = NULL;
- gint n_bytes;
- gunichar high_surrogate;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- n_bytes = 0;
- in = str;
- high_surrogate = 0;
- while ((len < 0 || in - str < len) && *in)
- {
- gunichar2 c = *in;
- gunichar wc;
-
- if (c >= 0xdc00 && c < 0xe000) /* low surrogate */
- {
- if (high_surrogate)
- {
- wc = SURROGATE_VALUE (high_surrogate, c);
- high_surrogate = 0;
- }
- else
- {
-#if NOT_NEEDED_FOR_NAVIT
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- _("Invalid sequence in conversion input"));
-#endif
- goto err_out;
- }
- }
- else
- {
- if (high_surrogate)
- {
-#if NOT_NEEDED_FOR_NAVIT
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- _("Invalid sequence in conversion input"));
-#endif
- goto err_out;
- }
-
- if (c >= 0xd800 && c < 0xdc00) /* high surrogate */
- {
- high_surrogate = c;
- goto next1;
- }
- else
- wc = c;
- }
-
- /********** DIFFERENT for UTF8/UCS4 **********/
- n_bytes += UTF8_LENGTH (wc);
-
- next1:
- in++;
- }
-
- if (high_surrogate && !items_read)
- {
-#if NOT_NEEDED_FOR_NAVIT
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
- _("Partial character sequence at end of input"));
-#endif
- goto err_out;
- }
-
- /* At this point, everything is valid, and we just need to convert
- */
- /********** DIFFERENT for UTF8/UCS4 **********/
- result = g_malloc (n_bytes + 1);
-
- high_surrogate = 0;
- out = result;
- in = str;
- while (out < result + n_bytes)
- {
- gunichar2 c = *in;
- gunichar wc;
-
- if (c >= 0xdc00 && c < 0xe000) /* low surrogate */
- {
- wc = SURROGATE_VALUE (high_surrogate, c);
- high_surrogate = 0;
- }
- else if (c >= 0xd800 && c < 0xdc00) /* high surrogate */
- {
- high_surrogate = c;
- goto next2;
- }
- else
- wc = c;
-
- /********** DIFFERENT for UTF8/UCS4 **********/
- out += g_unichar_to_utf8 (wc, out);
-
- next2:
- in++;
- }
-
- /********** DIFFERENT for UTF8/UCS4 **********/
- *out = '\0';
-
- if (items_written)
- /********** DIFFERENT for UTF8/UCS4 **********/
- *items_written = out - result;
-
- err_out:
- if (items_read)
- *items_read = in - str;
-
- return result;
-}
-
-/**
- * g_utf16_to_ucs4:
- * @str: a UTF-16 encoded string
- * @len: the maximum length (number of <type>gunichar2</type>) of @str to use.
- * If @len < 0, then the string is nul-terminated.
- * @items_read: location to store number of words read, or %NULL.
- * If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
- * returned in case @str contains a trailing partial
- * character. If an error occurs then the index of the
- * invalid input is stored here.
- * @items_written: location to store number of characters written, or %NULL.
- * The value stored here does not include the trailing
- * 0 character.
- * @error: location to store the error occuring, or %NULL to ignore
- * errors. Any of the errors in #GConvertError other than
- * %G_CONVERT_ERROR_NO_CONVERSION may occur.
- *
- * Convert a string from UTF-16 to UCS-4. The result will be
- * nul-terminated.
- *
- * Return value: a pointer to a newly allocated UCS-4 string.
- * This value must be freed with g_free(). If an
- * error occurs, %NULL will be returned and
- * @error set.
- **/
-gunichar *
-g_utf16_to_ucs4 (const gunichar2 *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error)
-{
- const gunichar2 *in;
- gchar *out;
- gchar *result = NULL;
- gint n_bytes;
- gunichar high_surrogate;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- n_bytes = 0;
- in = str;
- high_surrogate = 0;
- while ((len < 0 || in - str < len) && *in)
- {
- gunichar2 c = *in;
- gunichar wc;
-
- if (c >= 0xdc00 && c < 0xe000) /* low surrogate */
- {
- if (high_surrogate)
- {
- wc = SURROGATE_VALUE (high_surrogate, c);
- high_surrogate = 0;
- }
- else
- {
-#if NOT_NEEDED_FOR_NAVIT
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- _("Invalid sequence in conversion input"));
-#endif
- goto err_out;
- }
- }
- else
- {
- if (high_surrogate)
- {
-#if NOT_NEEDED_FOR_NAVIT
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- _("Invalid sequence in conversion input"));
-#endif
- goto err_out;
- }
-
- if (c >= 0xd800 && c < 0xdc00) /* high surrogate */
- {
- high_surrogate = c;
- goto next1;
- }
- else
- wc = c;
- }
-
- /********** DIFFERENT for UTF8/UCS4 **********/
- n_bytes += sizeof (gunichar);
-
- next1:
- in++;
- }
-
- if (high_surrogate && !items_read)
- {
-#if NOT_NEEDED_FOR_NAVIT
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
- _("Partial character sequence at end of input"));
-#endif
- goto err_out;
- }
-
- /* At this point, everything is valid, and we just need to convert
- */
- /********** DIFFERENT for UTF8/UCS4 **********/
- result = g_malloc (n_bytes + 4);
-
- high_surrogate = 0;
- out = result;
- in = str;
- while (out < result + n_bytes)
- {
- gunichar2 c = *in;
- gunichar wc;
-
- if (c >= 0xdc00 && c < 0xe000) /* low surrogate */
- {
- wc = SURROGATE_VALUE (high_surrogate, c);
- high_surrogate = 0;
- }
- else if (c >= 0xd800 && c < 0xdc00) /* high surrogate */
- {
- high_surrogate = c;
- goto next2;
- }
- else
- wc = c;
-
- /********** DIFFERENT for UTF8/UCS4 **********/
- *(gunichar *)out = wc;
- out += sizeof (gunichar);
-
- next2:
- in++;
- }
-
- /********** DIFFERENT for UTF8/UCS4 **********/
- *(gunichar *)out = 0;
-
- if (items_written)
- /********** DIFFERENT for UTF8/UCS4 **********/
- *items_written = (out - result) / sizeof (gunichar);
-
- err_out:
- if (items_read)
- *items_read = in - str;
-
- return (gunichar *)result;
-}
-
-/**
- * g_utf8_to_utf16:
- * @str: a UTF-8 encoded string
- * @len: the maximum length (number of characters) of @str to use.
- * If @len < 0, then the string is nul-terminated.
- * @items_read: location to store number of bytes read, or %NULL.
- * If %NULL, then %G_CONVERT_ERROR_PARTIAL_INPUT will be
- * returned in case @str contains a trailing partial
- * character. If an error occurs then the index of the
- * invalid input is stored here.
- * @items_written: location to store number of <type>gunichar2</type> written,
- * or %NULL.
- * The value stored here does not include the trailing 0.
- * @error: location to store the error occuring, or %NULL to ignore
- * errors. Any of the errors in #GConvertError other than
- * %G_CONVERT_ERROR_NO_CONVERSION may occur.
- *
- * Convert a string from UTF-8 to UTF-16. A 0 character will be
- * added to the result after the converted text.
- *
- * Return value: a pointer to a newly allocated UTF-16 string.
- * This value must be freed with g_free(). If an
- * error occurs, %NULL will be returned and
- * @error set.
- **/
-gunichar2 *
-g_utf8_to_utf16 (const gchar *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error)
-{
- gunichar2 *result = NULL;
- gint n16;
- const gchar *in;
- gint i;
-
- g_return_val_if_fail (str != NULL, NULL);
-
- in = str;
- n16 = 0;
- while ((len < 0 || str + len - in > 0) && *in)
- {
- gunichar wc = g_utf8_get_char_extended (in, len < 0 ? 6 : str + len - in);
- if (wc & 0x80000000)
- {
- if (wc == (gunichar)-2)
- {
- if (items_read)
- break;
-#if NOT_NEEDED_FOR_NAVIT
- else
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_PARTIAL_INPUT,
- _("Partial character sequence at end of input"));
-#endif
- }
-#if NOT_NEEDED_FOR_NAVIT
- else
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- _("Invalid byte sequence in conversion input"));
-#endif
- goto err_out;
- }
-
- if (wc < 0xd800)
- n16 += 1;
- else if (wc < 0xe000)
- {
-#if NOT_NEEDED_FOR_NAVIT
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- _("Invalid sequence in conversion input"));
-#endif
-
- goto err_out;
- }
- else if (wc < 0x10000)
- n16 += 1;
- else if (wc < 0x110000)
- n16 += 2;
- else
- {
-#if NOT_NEEDED_FOR_NAVIT
-// g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
-// _("Character out of range for UTF-16"));
-#endif
-
- goto err_out;
- }
-
- in = g_utf8_next_char (in);
- }
-
- result = g_new (gunichar2, n16 + 1);
-
- in = str;
- for (i = 0; i < n16;)
- {
- gunichar wc = g_utf8_get_char (in);
-
- if (wc < 0x10000)
- {
- result[i++] = wc;
- }
- else
- {
- result[i++] = (wc - 0x10000) / 0x400 + 0xd800;
- result[i++] = (wc - 0x10000) % 0x400 + 0xdc00;
- }
-
- in = g_utf8_next_char (in);
- }
-
- result[i] = 0;
-
- if (items_written)
- *items_written = n16;
-
- err_out:
- if (items_read)
- *items_read = in - str;
-
- return result;
-}
-
-/**
- * g_ucs4_to_utf16:
- * @str: a UCS-4 encoded string
- * @len: the maximum length (number of characters) of @str to use.
- * If @len < 0, then the string is nul-terminated.
- * @items_read: location to store number of bytes read, or %NULL.
- * If an error occurs then the index of the invalid input
- * is stored here.
- * @items_written: location to store number of <type>gunichar2</type>
- * written, or %NULL. The value stored here does not
- * include the trailing 0.
- * @error: location to store the error occuring, or %NULL to ignore
- * errors. Any of the errors in #GConvertError other than
- * %G_CONVERT_ERROR_NO_CONVERSION may occur.
- *
- * Convert a string from UCS-4 to UTF-16. A 0 character will be
- * added to the result after the converted text.
- *
- * Return value: a pointer to a newly allocated UTF-16 string.
- * This value must be freed with g_free(). If an
- * error occurs, %NULL will be returned and
- * @error set.
- **/
-gunichar2 *
-g_ucs4_to_utf16 (const gunichar *str,
- glong len,
- glong *items_read,
- glong *items_written,
- GError **error)
-{
- gunichar2 *result = NULL;
- gint n16;
- gint i, j;
-
- n16 = 0;
- i = 0;
- while ((len < 0 || i < len) && str[i])
- {
- gunichar wc = str[i];
-
- if (wc < 0xd800)
- n16 += 1;
- else if (wc < 0xe000)
- {
-#if NOT_NEEDED_FOR_NAVIT
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- _("Invalid sequence in conversion input"));
-#endif
-
- goto err_out;
- }
- else if (wc < 0x10000)
- n16 += 1;
- else if (wc < 0x110000)
- n16 += 2;
- else
- {
-#if NOT_NEEDED_FOR_NAVIT
- g_set_error_literal (error, G_CONVERT_ERROR, G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
- _("Character out of range for UTF-16"));
-#endif
-
- goto err_out;
- }
-
- i++;
- }
-
- result = g_new (gunichar2, n16 + 1);
-
- for (i = 0, j = 0; j < n16; i++)
- {
- gunichar wc = str[i];
-
- if (wc < 0x10000)
- {
- result[j++] = wc;
- }
- else
- {
- result[j++] = (wc - 0x10000) / 0x400 + 0xd800;
- result[j++] = (wc - 0x10000) % 0x400 + 0xdc00;
- }
- }
- result[j] = 0;
-
- if (items_written)
- *items_written = n16;
-
- err_out:
- if (items_read)
- *items_read = i;
-
- return result;
-}
-
-#define CONTINUATION_CHAR \
- G_STMT_START { \
- if ((*(guchar *)p & 0xc0) != 0x80) /* 10xxxxxx */ \
- goto error; \
- val <<= 6; \
- val |= (*(guchar *)p) & 0x3f; \
- } G_STMT_END
-
-static const gchar *
-fast_validate (const char *str)
-
-{
- gunichar val = 0;
- gunichar min = 0;
- const gchar *p;
-
- for (p = str; *p; p++)
- {
- if (*(guchar *)p < 128)
- /* done */;
- else
- {
- const gchar *last;
-
- last = p;
- if ((*(guchar *)p & 0xe0) == 0xc0) /* 110xxxxx */
- {
- if (G_UNLIKELY ((*(guchar *)p & 0x1e) == 0))
- goto error;
- p++;
- if (G_UNLIKELY ((*(guchar *)p & 0xc0) != 0x80)) /* 10xxxxxx */
- goto error;
- }
- else
- {
- if ((*(guchar *)p & 0xf0) == 0xe0) /* 1110xxxx */
- {
- min = (1 << 11);
- val = *(guchar *)p & 0x0f;
- goto TWO_REMAINING;
- }
- else if ((*(guchar *)p & 0xf8) == 0xf0) /* 11110xxx */
- {
- min = (1 << 16);
- val = *(guchar *)p & 0x07;
- }
- else
- goto error;
-
- p++;
- CONTINUATION_CHAR;
- TWO_REMAINING:
- p++;
- CONTINUATION_CHAR;
- p++;
- CONTINUATION_CHAR;
-
- if (G_UNLIKELY (val < min))
- goto error;
-
- if (G_UNLIKELY (!UNICODE_VALID(val)))
- goto error;
- }
-
- continue;
-
- error:
- return last;
- }
- }
-
- return p;
-}
-
-static const gchar *
-fast_validate_len (const char *str,
- gssize max_len)
-
-{
- gunichar val = 0;
- gunichar min = 0;
- const gchar *p;
-
- g_assert (max_len >= 0);
-
- for (p = str; ((p - str) < max_len) && *p; p++)
- {
- if (*(guchar *)p < 128)
- /* done */;
- else
- {
- const gchar *last;
-
- last = p;
- if ((*(guchar *)p & 0xe0) == 0xc0) /* 110xxxxx */
- {
- if (G_UNLIKELY (max_len - (p - str) < 2))
- goto error;
-
- if (G_UNLIKELY ((*(guchar *)p & 0x1e) == 0))
- goto error;
- p++;
- if (G_UNLIKELY ((*(guchar *)p & 0xc0) != 0x80)) /* 10xxxxxx */
- goto error;
- }
- else
- {
- if ((*(guchar *)p & 0xf0) == 0xe0) /* 1110xxxx */
- {
- if (G_UNLIKELY (max_len - (p - str) < 3))
- goto error;
-
- min = (1 << 11);
- val = *(guchar *)p & 0x0f;
- goto TWO_REMAINING;
- }
- else if ((*(guchar *)p & 0xf8) == 0xf0) /* 11110xxx */
- {
- if (G_UNLIKELY (max_len - (p - str) < 4))
- goto error;
-
- min = (1 << 16);
- val = *(guchar *)p & 0x07;
- }
- else
- goto error;
-
- p++;
- CONTINUATION_CHAR;
- TWO_REMAINING:
- p++;
- CONTINUATION_CHAR;
- p++;
- CONTINUATION_CHAR;
-
- if (G_UNLIKELY (val < min))
- goto error;
- if (G_UNLIKELY (!UNICODE_VALID(val)))
- goto error;
- }
-
- continue;
-
- error:
- return last;
- }
- }
-
- return p;
-}
-
-/**
- * g_utf8_validate:
- * @str: a pointer to character data
- * @max_len: max bytes to validate, or -1 to go until NUL
- * @end: return location for end of valid data
- *
- * Validates UTF-8 encoded text. @str is the text to validate;
- * if @str is nul-terminated, then @max_len can be -1, otherwise
- * @max_len should be the number of bytes to validate.
- * If @end is non-%NULL, then the end of the valid range
- * will be stored there (i.e. the start of the first invalid
- * character if some bytes were invalid, or the end of the text
- * being validated otherwise).
- *
- * Note that g_utf8_validate() returns %FALSE if @max_len is
- * positive and NUL is met before @max_len bytes have been read.
- *
- * Returns %TRUE if all of @str was valid. Many GLib and GTK+
- * routines <emphasis>require</emphasis> valid UTF-8 as input;
- * so data read from a file or the network should be checked
- * with g_utf8_validate() before doing anything else with it.
- *
- * Return value: %TRUE if the text was valid UTF-8
- **/
-gboolean
-g_utf8_validate (const char *str,
- gssize max_len,
- const gchar **end)
-
-{
- const gchar *p;
-
- if (max_len < 0)
- p = fast_validate (str);
- else
- p = fast_validate_len (str, max_len);
-
- if (end)
- *end = p;
-
- if ((max_len >= 0 && p != str + max_len) ||
- (max_len < 0 && *p != '\0'))
- return FALSE;
- else
- return TRUE;
-}
-
-/**
- * g_unichar_validate:
- * @ch: a Unicode character
- *
- * Checks whether @ch is a valid Unicode character. Some possible
- * integer values of @ch will not be valid. 0 is considered a valid
- * character, though it's normally a string terminator.
- *
- * Return value: %TRUE if @ch is a valid Unicode character
- **/
-gboolean
-g_unichar_validate (gunichar ch)
-{
- return UNICODE_VALID (ch);
-}
-
-/**
- * g_utf8_strreverse:
- * @str: a UTF-8 encoded string
- * @len: the maximum length of @str to use, in bytes. If @len < 0,
- * then the string is nul-terminated.
- *
- * Reverses a UTF-8 string. @str must be valid UTF-8 encoded text.
- * (Use g_utf8_validate() on all text before trying to use UTF-8
- * utility functions with it.)
- *
- * This function is intended for programmatic uses of reversed strings.
- * It pays no attention to decomposed characters, combining marks, byte
- * order marks, directional indicators (LRM, LRO, etc) and similar
- * characters which might need special handling when reversing a string
- * for display purposes.
- *
- * Note that unlike g_strreverse(), this function returns
- * newly-allocated memory, which should be freed with g_free() when
- * no longer needed.
- *
- * Returns: a newly-allocated string which is the reverse of @str.
- *
- * Since: 2.2
- */
-gchar *
-g_utf8_strreverse (const gchar *str,
- gssize len)
-{
- gchar *r, *result;
- const gchar *p;
-
- if (len < 0)
- len = strlen (str);
-
- result = g_new (gchar, len + 1);
- r = result + len;
- p = str;
- while (r > result)
- {
- gchar *m, skip = g_utf8_skip[*(guchar*) p];
- r -= skip;
- for (m = r; skip; skip--)
- *m++ = *p++;
- }
- result[len] = 0;
-
- return result;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-
-gchar *
-_g_utf8_make_valid (const gchar *name)
-{
- GString *string;
- const gchar *remainder, *invalid;
- gint remaining_bytes, valid_bytes;
-
- string = NULL;
- remainder = name;
- remaining_bytes = strlen (name);
-
- while (remaining_bytes != 0)
- {
- if (g_utf8_validate (remainder, remaining_bytes, &invalid))
- break;
- valid_bytes = invalid - remainder;
-
- if (string == NULL)
- string = g_string_sized_new (remaining_bytes);
-
- g_string_append_len (string, remainder, valid_bytes);
- /* append U+FFFD REPLACEMENT CHARACTER */
- g_string_append (string, "\357\277\275");
-
- remaining_bytes -= valid_bytes + 1;
- remainder = invalid + 1;
- }
-
- if (string == NULL)
- return g_strdup (name);
-
- g_string_append (string, remainder);
-
- g_assert (g_utf8_validate (string->str, -1, NULL));
-
- return g_string_free (string, FALSE);
-}
-#endif
-
-#define __G_UTF8_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gutils.c b/navit/support/glib/gutils.c
deleted file mode 100644
index 6d3fda447..000000000
--- a/navit/support/glib/gutils.c
+++ /dev/null
@@ -1,3420 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1998 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-/*
- * MT safe for the unix part, FIXME: make the win32 part MT safe as well.
- */
-
-#include "config.h"
-
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#include <stdarg.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <locale.h>
-#include <string.h>
-#include <ctype.h> /* For tolower() */
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#ifdef HAVE_PWD_H
-#include <pwd.h>
-#endif
-#include <sys/types.h>
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-#ifdef HAVE_CRT_EXTERNS_H
-#include <crt_externs.h> /* for _NSGetEnviron */
-#endif
-
-/* implement gutils's inline functions
- */
-#define G_IMPLEMENT_INLINES 1
-#define __G_UTILS_C__
-#include "glib.h"
-#include "gprintfint.h"
-#include "gthreadprivate.h"
-#include "glibintl.h"
-#include "galias.h"
-
-#ifdef MAXPATHLEN
-#define G_PATH_LENGTH MAXPATHLEN
-#elif defined (PATH_MAX)
-#define G_PATH_LENGTH PATH_MAX
-#elif defined (_PC_PATH_MAX)
-#define G_PATH_LENGTH sysconf(_PC_PATH_MAX)
-#else
-#define G_PATH_LENGTH 2048
-#endif
-
-#ifdef G_PLATFORM_WIN32
-# define STRICT /* Strict typing, please */
-# include <windows.h>
-# undef STRICT
-# ifndef GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS
-# define GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT 2
-# define GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS 4
-# endif
-# include <lmcons.h> /* For UNLEN */
-#endif /* G_PLATFORM_WIN32 */
-
-#ifdef G_OS_WIN32
-#if NOT_NEEDED_FOR_NAVIT
-# include <direct.h>
-#endif /* NOT_NEEDED_FOR_NAVIT */
-# include <shlobj.h>
- /* older SDK (e.g. msvc 5.0) does not have these*/
-# ifndef CSIDL_MYMUSIC
-# define CSIDL_MYMUSIC 13
-# endif
-# ifndef CSIDL_MYVIDEO
-# define CSIDL_MYVIDEO 14
-# endif
-# ifndef CSIDL_INTERNET_CACHE
-# define CSIDL_INTERNET_CACHE 32
-# endif
-# ifndef CSIDL_COMMON_APPDATA
-# define CSIDL_COMMON_APPDATA 35
-# endif
-# ifndef CSIDL_MYPICTURES
-# define CSIDL_MYPICTURES 0x27
-# endif
-# ifndef CSIDL_COMMON_DOCUMENTS
-# define CSIDL_COMMON_DOCUMENTS 46
-# endif
-# ifndef CSIDL_PROFILE
-# define CSIDL_PROFILE 40
-# endif
-# include <process.h>
-#endif
-
-#ifdef HAVE_CARBON
-#include <CoreServices/CoreServices.h>
-#endif
-
-#ifdef HAVE_CODESET
-#include <langinfo.h>
-#endif
-
-#ifdef HAVE_BIND_TEXTDOMAIN_CODESET
-#include <libintl.h>
-#endif
-
-#if NOT_NEEDED_FOR_NAVIT
-const guint glib_major_version = GLIB_MAJOR_VERSION;
-const guint glib_minor_version = GLIB_MINOR_VERSION;
-const guint glib_micro_version = GLIB_MICRO_VERSION;
-const guint glib_interface_age = GLIB_INTERFACE_AGE;
-const guint glib_binary_age = GLIB_BINARY_AGE;
-
-#ifdef G_PLATFORM_WIN32
-
-static HMODULE glib_dll = NULL;
-
-#ifdef DLL_EXPORT
-
-BOOL WINAPI
-DllMain (HINSTANCE hinstDLL,
- DWORD fdwReason,
- LPVOID lpvReserved)
-{
- if (fdwReason == DLL_PROCESS_ATTACH)
- glib_dll = hinstDLL;
-
- return TRUE;
-}
-
-#endif
-
-gchar *
-_glib_get_installation_directory (void)
-{
-#ifdef DLL_EXPORT
- if (glib_dll == NULL)
- return NULL;
-#endif
- /* In a static build of GLib just use the application's .exe file's
- * installation directory...
- */
- return g_win32_get_package_installation_directory_of_module (glib_dll);
-}
-
-#endif
-
-/**
- * glib_check_version:
- * @required_major: the required major version.
- * @required_minor: the required minor version.
- * @required_micro: the required micro version.
- *
- * Checks that the GLib library in use is compatible with the
- * given version. Generally you would pass in the constants
- * #GLIB_MAJOR_VERSION, #GLIB_MINOR_VERSION, #GLIB_MICRO_VERSION
- * as the three arguments to this function; that produces
- * a check that the library in use is compatible with
- * the version of GLib the application or module was compiled
- * against.
- *
- * Compatibility is defined by two things: first the version
- * of the running library is newer than the version
- * @required_major.required_minor.@required_micro. Second
- * the running library must be binary compatible with the
- * version @required_major.required_minor.@required_micro
- * (same major version.)
- *
- * Return value: %NULL if the GLib library is compatible with the
- * given version, or a string describing the version mismatch.
- * The returned string is owned by GLib and must not be modified
- * or freed.
- *
- * Since: 2.6
- **/
-const gchar *
-glib_check_version (guint required_major,
- guint required_minor,
- guint required_micro)
-{
- gint glib_effective_micro = 100 * GLIB_MINOR_VERSION + GLIB_MICRO_VERSION;
- gint required_effective_micro = 100 * required_minor + required_micro;
-
- if (required_major > GLIB_MAJOR_VERSION)
- return "GLib version too old (major mismatch)";
- if (required_major < GLIB_MAJOR_VERSION)
- return "GLib version too new (major mismatch)";
- if (required_effective_micro < glib_effective_micro - GLIB_BINARY_AGE)
- return "GLib version too new (micro mismatch)";
- if (required_effective_micro > glib_effective_micro)
- return "GLib version too old (micro mismatch)";
- return NULL;
-}
-
-#if !defined (HAVE_MEMMOVE) && !defined (HAVE_WORKING_BCOPY)
-/**
- * g_memmove:
- * @dest: the destination address to copy the bytes to.
- * @src: the source address to copy the bytes from.
- * @len: the number of bytes to copy.
- *
- * Copies a block of memory @len bytes long, from @src to @dest.
- * The source and destination areas may overlap.
- *
- * In order to use this function, you must include
- * <filename>string.h</filename> yourself, because this macro will
- * typically simply resolve to memmove() and GLib does not include
- * <filename>string.h</filename> for you.
- */
-void
-g_memmove (gpointer dest,
- gconstpointer src,
- gulong len)
-{
- gchar* destptr = dest;
- const gchar* srcptr = src;
- if (src + len < dest || dest + len < src)
- {
- bcopy (src, dest, len);
- return;
- }
- else if (dest <= src)
- {
- while (len--)
- *(destptr++) = *(srcptr++);
- }
- else
- {
- destptr += len;
- srcptr += len;
- while (len--)
- *(--destptr) = *(--srcptr);
- }
-}
-#endif /* !HAVE_MEMMOVE && !HAVE_WORKING_BCOPY */
-
-#ifdef G_OS_WIN32
-#undef g_atexit
-#endif
-
-/**
- * g_atexit:
- * @func: the function to call on normal program termination.
- *
- * Specifies a function to be called at normal program termination.
- *
- * Since GLib 2.8.2, on Windows g_atexit() actually is a preprocessor
- * macro that maps to a call to the atexit() function in the C
- * library. This means that in case the code that calls g_atexit(),
- * i.e. atexit(), is in a DLL, the function will be called when the
- * DLL is detached from the program. This typically makes more sense
- * than that the function is called when the GLib DLL is detached,
- * which happened earlier when g_atexit() was a function in the GLib
- * DLL.
- *
- * The behaviour of atexit() in the context of dynamically loaded
- * modules is not formally specified and varies wildly.
- *
- * On POSIX systems, calling g_atexit() (or atexit()) in a dynamically
- * loaded module which is unloaded before the program terminates might
- * well cause a crash at program exit.
- *
- * Some POSIX systems implement atexit() like Windows, and have each
- * dynamically loaded module maintain an own atexit chain that is
- * called when the module is unloaded.
- *
- * On other POSIX systems, before a dynamically loaded module is
- * unloaded, the registered atexit functions (if any) residing in that
- * module are called, regardless where the code that registered them
- * resided. This is presumably the most robust approach.
- *
- * As can be seen from the above, for portability it's best to avoid
- * calling g_atexit() (or atexit()) except in the main executable of a
- * program.
- */
-void
-g_atexit (GVoidFunc func)
-{
- gint result;
- const gchar *error = NULL;
-
- /* keep this in sync with glib.h */
-
-#ifdef G_NATIVE_ATEXIT
- result = ATEXIT (func);
- if (result)
- error = g_strerror (errno);
-#elif defined (HAVE_ATEXIT)
-# ifdef NeXT /* @#%@! NeXTStep */
- result = !atexit ((void (*)(void)) func);
- if (result)
- error = g_strerror (errno);
-# else
- result = atexit ((void (*)(void)) func);
- if (result)
- error = g_strerror (errno);
-# endif /* NeXT */
-#elif defined (HAVE_ON_EXIT)
- result = on_exit ((void (*)(int, void *)) func, NULL);
- if (result)
- error = g_strerror (errno);
-#else
- result = 0;
- error = "no implementation";
-#endif /* G_NATIVE_ATEXIT */
-
- if (error)
- g_error ("Could not register atexit() function: %s", error);
-}
-
-/* Based on execvp() from GNU Libc.
- * Some of this code is cut-and-pasted into gspawn.c
- */
-
-static gchar*
-my_strchrnul (const gchar *str,
- gchar c)
-{
- gchar *p = (gchar*)str;
- while (*p && (*p != c))
- ++p;
-
- return p;
-}
-
-#ifdef G_OS_WIN32
-
-static gchar *inner_find_program_in_path (const gchar *program);
-
-gchar*
-g_find_program_in_path (const gchar *program)
-{
- const gchar *last_dot = strrchr (program, '.');
-
- if (last_dot == NULL ||
- strchr (last_dot, '\\') != NULL ||
- strchr (last_dot, '/') != NULL)
- {
- const gint program_length = strlen (program);
- gchar *pathext = g_build_path (";",
- ".exe;.cmd;.bat;.com",
- g_getenv ("PATHEXT"),
- NULL);
- gchar *p;
- gchar *decorated_program;
- gchar *retval;
-
- p = pathext;
- do
- {
- gchar *q = my_strchrnul (p, ';');
-
- decorated_program = g_malloc (program_length + (q-p) + 1);
- memcpy (decorated_program, program, program_length);
- memcpy (decorated_program+program_length, p, q-p);
- decorated_program [program_length + (q-p)] = '\0';
-
- retval = inner_find_program_in_path (decorated_program);
- g_free (decorated_program);
-
- if (retval != NULL)
- {
- g_free (pathext);
- return retval;
- }
- p = q;
- } while (*p++ != '\0');
- g_free (pathext);
- return NULL;
- }
- else
- return inner_find_program_in_path (program);
-}
-
-#endif
-
-/**
- * g_find_program_in_path:
- * @program: a program name in the GLib file name encoding
- *
- * Locates the first executable named @program in the user's path, in the
- * same way that execvp() would locate it. Returns an allocated string
- * with the absolute path name, or %NULL if the program is not found in
- * the path. If @program is already an absolute path, returns a copy of
- * @program if @program exists and is executable, and %NULL otherwise.
- *
- * On Windows, if @program does not have a file type suffix, tries
- * with the suffixes .exe, .cmd, .bat and .com, and the suffixes in
- * the <envar>PATHEXT</envar> environment variable.
- *
- * On Windows, it looks for the file in the same way as CreateProcess()
- * would. This means first in the directory where the executing
- * program was loaded from, then in the current directory, then in the
- * Windows 32-bit system directory, then in the Windows directory, and
- * finally in the directories in the <envar>PATH</envar> environment
- * variable. If the program is found, the return value contains the
- * full name including the type suffix.
- *
- * Return value: absolute path, or %NULL
- **/
-#ifdef G_OS_WIN32
-static gchar *
-inner_find_program_in_path (const gchar *program)
-#else
-gchar*
-g_find_program_in_path (const gchar *program)
-#endif
-{
- const gchar *path, *p;
- gchar *name, *freeme;
-#ifdef G_OS_WIN32
- const gchar *path_copy;
- gchar *filename = NULL, *appdir = NULL;
- gchar *sysdir = NULL, *windir = NULL;
- int n;
- wchar_t wfilename[MAXPATHLEN], wsysdir[MAXPATHLEN],
- wwindir[MAXPATHLEN];
-#endif
- gsize len;
- gsize pathlen;
-
- g_return_val_if_fail (program != NULL, NULL);
-
- /* If it is an absolute path, or a relative path including subdirectories,
- * don't look in PATH.
- */
- if (g_path_is_absolute (program)
- || strchr (program, G_DIR_SEPARATOR) != NULL
-#ifdef G_OS_WIN32
- || strchr (program, '/') != NULL
-#endif
- )
- {
- if (g_file_test (program, G_FILE_TEST_IS_EXECUTABLE) &&
- !g_file_test (program, G_FILE_TEST_IS_DIR))
- return g_strdup (program);
- else
- return NULL;
- }
-
- path = g_getenv ("PATH");
-#if defined(G_OS_UNIX) || defined(G_OS_BEOS)
- if (path == NULL)
- {
- /* There is no `PATH' in the environment. The default
- * search path in GNU libc is the current directory followed by
- * the path `confstr' returns for `_CS_PATH'.
- */
-
- /* In GLib we put . last, for security, and don't use the
- * unportable confstr(); UNIX98 does not actually specify
- * what to search if PATH is unset. POSIX may, dunno.
- */
-
- path = "/bin:/usr/bin:.";
- }
-#else
- n = GetModuleFileNameW (NULL, wfilename, MAXPATHLEN);
- if (n > 0 && n < MAXPATHLEN)
- filename = g_utf16_to_utf8 (wfilename, -1, NULL, NULL, NULL);
-
- n = GetSystemDirectoryW (wsysdir, MAXPATHLEN);
- if (n > 0 && n < MAXPATHLEN)
- sysdir = g_utf16_to_utf8 (wsysdir, -1, NULL, NULL, NULL);
-
- n = GetWindowsDirectoryW (wwindir, MAXPATHLEN);
- if (n > 0 && n < MAXPATHLEN)
- windir = g_utf16_to_utf8 (wwindir, -1, NULL, NULL, NULL);
-
- if (filename)
- {
- appdir = g_path_get_dirname (filename);
- g_free (filename);
- }
-
- path = g_strdup (path);
-
- if (windir)
- {
- const gchar *tem = path;
- path = g_strconcat (windir, ";", path, NULL);
- g_free ((gchar *) tem);
- g_free (windir);
- }
-
- if (sysdir)
- {
- const gchar *tem = path;
- path = g_strconcat (sysdir, ";", path, NULL);
- g_free ((gchar *) tem);
- g_free (sysdir);
- }
-
- {
- const gchar *tem = path;
- path = g_strconcat (".;", path, NULL);
- g_free ((gchar *) tem);
- }
-
- if (appdir)
- {
- const gchar *tem = path;
- path = g_strconcat (appdir, ";", path, NULL);
- g_free ((gchar *) tem);
- g_free (appdir);
- }
-
- path_copy = path;
-#endif
-
- len = strlen (program) + 1;
- pathlen = strlen (path);
- freeme = name = g_malloc (pathlen + len + 1);
-
- /* Copy the file name at the top, including '\0' */
- memcpy (name + pathlen + 1, program, len);
- name = name + pathlen;
- /* And add the slash before the filename */
- *name = G_DIR_SEPARATOR;
-
- p = path;
- do
- {
- char *startp;
-
- path = p;
- p = my_strchrnul (path, G_SEARCHPATH_SEPARATOR);
-
- if (p == path)
- /* Two adjacent colons, or a colon at the beginning or the end
- * of `PATH' means to search the current directory.
- */
- startp = name + 1;
- else
- startp = memcpy (name - (p - path), path, p - path);
-
- if (g_file_test (startp, G_FILE_TEST_IS_EXECUTABLE) &&
- !g_file_test (startp, G_FILE_TEST_IS_DIR))
- {
- gchar *ret;
- ret = g_strdup (startp);
- g_free (freeme);
-#ifdef G_OS_WIN32
- g_free ((gchar *) path_copy);
-#endif
- return ret;
- }
- }
- while (*p++ != '\0');
-
- g_free (freeme);
-#ifdef G_OS_WIN32
- g_free ((gchar *) path_copy);
-#endif
-
- return NULL;
-}
-
-static gboolean
-debug_key_matches (const gchar *key,
- const gchar *token,
- guint length)
-{
- for (; length; length--, key++, token++)
- {
- char k = (*key == '_') ? '-' : tolower (*key );
- char t = (*token == '_') ? '-' : tolower (*token);
-
- if (k != t)
- return FALSE;
- }
-
- return *key == '\0';
-}
-
-/**
- * g_parse_debug_string:
- * @string: a list of debug options separated by colons, spaces, or
- * commas; or the string "all" to set all flags, or %NULL.
- * @keys: pointer to an array of #GDebugKey which associate
- * strings with bit flags.
- * @nkeys: the number of #GDebugKey<!-- -->s in the array.
- *
- * Parses a string containing debugging options
- * into a %guint containing bit flags. This is used
- * within GDK and GTK+ to parse the debug options passed on the
- * command line or through environment variables.
- *
- * Returns: the combined set of bit flags.
- */
-guint
-g_parse_debug_string (const gchar *string,
- const GDebugKey *keys,
- guint nkeys)
-{
- guint i;
- guint result = 0;
-
- if (string == NULL)
- return 0;
-
- /* this function is used by gmem.c/gslice.c initialization code,
- * so introducing malloc dependencies here would require adaptions
- * of those code portions.
- */
-
- if (!g_ascii_strcasecmp (string, "all"))
- {
- for (i=0; i<nkeys; i++)
- result |= keys[i].value;
- }
- else
- {
- const gchar *p = string;
- const gchar *q;
-
- while (*p)
- {
- q = strpbrk (p, ":;, \t");
- if (!q)
- q = p + strlen(p);
-
- for (i = 0; i < nkeys; i++)
- if (debug_key_matches (keys[i].key, p, q - p))
- result |= keys[i].value;
-
- p = q;
- if (*p)
- p++;
- }
- }
-
- return result;
-}
-
-/**
- * g_basename:
- * @file_name: the name of the file.
- *
- * Gets the name of the file without any leading directory components.
- * It returns a pointer into the given file name string.
- *
- * Return value: the name of the file without any leading directory components.
- *
- * Deprecated:2.2: Use g_path_get_basename() instead, but notice that
- * g_path_get_basename() allocates new memory for the returned string, unlike
- * this function which returns a pointer into the argument.
- **/
-G_CONST_RETURN gchar*
-g_basename (const gchar *file_name)
-{
- register gchar *base;
-
- g_return_val_if_fail (file_name != NULL, NULL);
-
- base = strrchr (file_name, G_DIR_SEPARATOR);
-
-#ifdef G_OS_WIN32
- {
- gchar *q = strrchr (file_name, '/');
- if (base == NULL || (q != NULL && q > base))
- base = q;
- }
-#endif
-
- if (base)
- return base + 1;
-
-#ifdef G_OS_WIN32
- if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
- return (gchar*) file_name + 2;
-#endif /* G_OS_WIN32 */
-
- return (gchar*) file_name;
-}
-#endif
-
-/**
- * g_path_get_basename:
- * @file_name: the name of the file.
- *
- * Gets the last component of the filename. If @file_name ends with a
- * directory separator it gets the component before the last slash. If
- * @file_name consists only of directory separators (and on Windows,
- * possibly a drive letter), a single separator is returned. If
- * @file_name is empty, it gets ".".
- *
- * Return value: a newly allocated string containing the last component of
- * the filename.
- */
-gchar*
-g_path_get_basename (const gchar *file_name)
-{
- register gssize base;
- register gssize last_nonslash;
- gsize len;
- gchar *retval;
-
- g_return_val_if_fail (file_name != NULL, NULL);
-
- if (file_name[0] == '\0')
- /* empty string */
- return g_strdup (".");
-
- last_nonslash = strlen (file_name) - 1;
-
- while (last_nonslash >= 0 && G_IS_DIR_SEPARATOR (file_name [last_nonslash]))
- last_nonslash--;
-
- if (last_nonslash == -1)
- /* string only containing slashes */
- return g_strdup (G_DIR_SEPARATOR_S);
-
-#ifdef G_OS_WIN32
- if (last_nonslash == 1 && g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
- /* string only containing slashes and a drive */
- return g_strdup (G_DIR_SEPARATOR_S);
-#endif /* G_OS_WIN32 */
-
- base = last_nonslash;
-
- while (base >=0 && !G_IS_DIR_SEPARATOR (file_name [base]))
- base--;
-
-#ifdef G_OS_WIN32
- if (base == -1 && g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
- base = 1;
-#endif /* G_OS_WIN32 */
-
- len = last_nonslash - base;
- retval = g_malloc (len + 1);
- memcpy (retval, file_name + base + 1, len);
- retval [len] = '\0';
- return retval;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-/**
- * g_path_is_absolute:
- * @file_name: a file name.
- *
- * Returns %TRUE if the given @file_name is an absolute file name,
- * i.e. it contains a full path from the root directory such as "/usr/local"
- * on UNIX or "C:\windows" on Windows systems.
- *
- * Returns: %TRUE if @file_name is an absolute path.
- */
-gboolean
-g_path_is_absolute (const gchar *file_name)
-{
- g_return_val_if_fail (file_name != NULL, FALSE);
-
- if (G_IS_DIR_SEPARATOR (file_name[0]))
- return TRUE;
-
-#ifdef G_OS_WIN32
- /* Recognize drive letter on native Windows */
- if (g_ascii_isalpha (file_name[0]) &&
- file_name[1] == ':' && G_IS_DIR_SEPARATOR (file_name[2]))
- return TRUE;
-#endif /* G_OS_WIN32 */
-
- return FALSE;
-}
-
-/**
- * g_path_skip_root:
- * @file_name: a file name.
- *
- * Returns a pointer into @file_name after the root component, i.e. after
- * the "/" in UNIX or "C:\" under Windows. If @file_name is not an absolute
- * path it returns %NULL.
- *
- * Returns: a pointer into @file_name after the root component.
- */
-G_CONST_RETURN gchar*
-g_path_skip_root (const gchar *file_name)
-{
- g_return_val_if_fail (file_name != NULL, NULL);
-
-#ifdef G_PLATFORM_WIN32
- /* Skip \\server\share or //server/share */
- if (G_IS_DIR_SEPARATOR (file_name[0]) &&
- G_IS_DIR_SEPARATOR (file_name[1]) &&
- file_name[2] &&
- !G_IS_DIR_SEPARATOR (file_name[2]))
- {
- gchar *p;
-
- p = strchr (file_name + 2, G_DIR_SEPARATOR);
-#ifdef G_OS_WIN32
- {
- gchar *q = strchr (file_name + 2, '/');
- if (p == NULL || (q != NULL && q < p))
- p = q;
- }
-#endif
- if (p &&
- p > file_name + 2 &&
- p[1])
- {
- file_name = p + 1;
-
- while (file_name[0] && !G_IS_DIR_SEPARATOR (file_name[0]))
- file_name++;
-
- /* Possibly skip a backslash after the share name */
- if (G_IS_DIR_SEPARATOR (file_name[0]))
- file_name++;
-
- return (gchar *)file_name;
- }
- }
-#endif
-
- /* Skip initial slashes */
- if (G_IS_DIR_SEPARATOR (file_name[0]))
- {
- while (G_IS_DIR_SEPARATOR (file_name[0]))
- file_name++;
- return (gchar *)file_name;
- }
-
-#ifdef G_OS_WIN32
- /* Skip X:\ */
- if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':' && G_IS_DIR_SEPARATOR (file_name[2]))
- return (gchar *)file_name + 3;
-#endif
-
- return NULL;
-}
-
-/**
- * g_path_get_dirname:
- * @file_name: the name of the file.
- *
- * Gets the directory components of a file name. If the file name has no
- * directory components "." is returned. The returned string should be
- * freed when no longer needed.
- *
- * Returns: the directory components of the file.
- */
-gchar*
-g_path_get_dirname (const gchar *file_name)
-{
- register gchar *base;
- register gsize len;
-
- g_return_val_if_fail (file_name != NULL, NULL);
-
- base = strrchr (file_name, G_DIR_SEPARATOR);
-#ifdef G_OS_WIN32
- {
- gchar *q = strrchr (file_name, '/');
- if (base == NULL || (q != NULL && q > base))
- base = q;
- }
-#endif
- if (!base)
- {
-#ifdef G_OS_WIN32
- if (g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
- {
- gchar drive_colon_dot[4];
-
- drive_colon_dot[0] = file_name[0];
- drive_colon_dot[1] = ':';
- drive_colon_dot[2] = '.';
- drive_colon_dot[3] = '\0';
-
- return g_strdup (drive_colon_dot);
- }
-#endif
- return g_strdup (".");
- }
-
- while (base > file_name && G_IS_DIR_SEPARATOR (*base))
- base--;
-
-#ifdef G_OS_WIN32
- /* base points to the char before the last slash.
- *
- * In case file_name is the root of a drive (X:\) or a child of the
- * root of a drive (X:\foo), include the slash.
- *
- * In case file_name is the root share of an UNC path
- * (\\server\share), add a slash, returning \\server\share\ .
- *
- * In case file_name is a direct child of a share in an UNC path
- * (\\server\share\foo), include the slash after the share name,
- * returning \\server\share\ .
- */
- if (base == file_name + 1 && g_ascii_isalpha (file_name[0]) && file_name[1] == ':')
- base++;
- else if (G_IS_DIR_SEPARATOR (file_name[0]) &&
- G_IS_DIR_SEPARATOR (file_name[1]) &&
- file_name[2] &&
- !G_IS_DIR_SEPARATOR (file_name[2]) &&
- base >= file_name + 2)
- {
- const gchar *p = file_name + 2;
- while (*p && !G_IS_DIR_SEPARATOR (*p))
- p++;
- if (p == base + 1)
- {
- len = (guint) strlen (file_name) + 1;
- base = g_new (gchar, len + 1);
- strcpy (base, file_name);
- base[len-1] = G_DIR_SEPARATOR;
- base[len] = 0;
- return base;
- }
- if (G_IS_DIR_SEPARATOR (*p))
- {
- p++;
- while (*p && !G_IS_DIR_SEPARATOR (*p))
- p++;
- if (p == base + 1)
- base++;
- }
- }
-#endif
-
- len = (guint) 1 + base - file_name;
-
- base = g_new (gchar, len + 1);
- g_memmove (base, file_name, len);
- base[len] = 0;
-
- return base;
-}
-
-/**
- * g_get_current_dir:
- *
- * Gets the current directory.
- * The returned string should be freed when no longer needed. The encoding
- * of the returned string is system defined. On Windows, it is always UTF-8.
- *
- * Returns: the current directory.
- */
-gchar*
-g_get_current_dir (void)
-{
-#ifdef G_OS_WIN32
-
- gchar *dir = NULL;
- wchar_t dummy[2], *wdir;
- int len;
-
- len = GetCurrentDirectoryW (2, dummy);
- wdir = g_new (wchar_t, len);
-
- if (GetCurrentDirectoryW (len, wdir) == len - 1)
- dir = g_utf16_to_utf8 (wdir, -1, NULL, NULL, NULL);
-
- g_free (wdir);
-
- if (dir == NULL)
- dir = g_strdup ("\\");
-
- return dir;
-
-#else
-
- gchar *buffer = NULL;
- gchar *dir = NULL;
- static gulong max_len = 0;
-
- if (max_len == 0)
- max_len = (G_PATH_LENGTH == -1) ? 2048 : G_PATH_LENGTH;
-
- /* We don't use getcwd(3) on SUNOS, because, it does a popen("pwd")
- * and, if that wasn't bad enough, hangs in doing so.
- */
-#if (defined (sun) && !defined (__SVR4)) || !defined(HAVE_GETCWD)
- buffer = g_new (gchar, max_len + 1);
- *buffer = 0;
- dir = getwd (buffer);
-#else /* !sun || !HAVE_GETCWD */
- while (max_len < G_MAXULONG / 2)
- {
- g_free (buffer);
- buffer = g_new (gchar, max_len + 1);
- *buffer = 0;
- dir = getcwd (buffer, max_len);
-
- if (dir || errno != ERANGE)
- break;
-
- max_len *= 2;
- }
-#endif /* !sun || !HAVE_GETCWD */
-
- if (!dir || !*buffer)
- {
- /* hm, should we g_error() out here?
- * this can happen if e.g. "./" has mode \0000
- */
- buffer[0] = G_DIR_SEPARATOR;
- buffer[1] = 0;
- }
-
- dir = g_strdup (buffer);
- g_free (buffer);
-
- return dir;
-#endif /* !Win32 */
-}
-
-/**
- * g_getenv:
- * @variable: the environment variable to get, in the GLib file name encoding.
- *
- * Returns the value of an environment variable. The name and value
- * are in the GLib file name encoding. On UNIX, this means the actual
- * bytes which might or might not be in some consistent character set
- * and encoding. On Windows, it is in UTF-8. On Windows, in case the
- * environment variable's value contains references to other
- * environment variables, they are expanded.
- *
- * Return value: the value of the environment variable, or %NULL if
- * the environment variable is not found. The returned string may be
- * overwritten by the next call to g_getenv(), g_setenv() or
- * g_unsetenv().
- **/
-G_CONST_RETURN gchar*
-g_getenv (const gchar *variable)
-{
-#ifndef G_OS_WIN32
-
- g_return_val_if_fail (variable != NULL, NULL);
-
- return getenv (variable);
-
-#else /* G_OS_WIN32 */
-
- GQuark quark;
- gchar *value;
- wchar_t dummy[2], *wname, *wvalue;
- int len;
-
- g_return_val_if_fail (variable != NULL, NULL);
- g_return_val_if_fail (g_utf8_validate (variable, -1, NULL), NULL);
-
- /* On Windows NT, it is relatively typical that environment
- * variables contain references to other environment variables. If
- * so, use ExpandEnvironmentStrings(). (In an ideal world, such
- * environment variables would be stored in the Registry as
- * REG_EXPAND_SZ type values, and would then get automatically
- * expanded before a program sees them. But there is broken software
- * that stores environment variables as REG_SZ values even if they
- * contain references to other environment variables.)
- */
-
- wname = g_utf8_to_utf16 (variable, -1, NULL, NULL, NULL);
-
- len = GetEnvironmentVariableW (wname, dummy, 2);
-
- if (len == 0)
- {
- g_free (wname);
- return NULL;
- }
- else if (len == 1)
- len = 2;
-
- wvalue = g_new (wchar_t, len);
-
- if (GetEnvironmentVariableW (wname, wvalue, len) != len - 1)
- {
- g_free (wname);
- g_free (wvalue);
- return NULL;
- }
-
- if (wcschr (wvalue, L'%') != NULL)
- {
- wchar_t *tem = wvalue;
-
- len = ExpandEnvironmentStringsW (wvalue, dummy, 2);
-
- if (len > 0)
- {
- wvalue = g_new (wchar_t, len);
-
- if (ExpandEnvironmentStringsW (tem, wvalue, len) != len)
- {
- g_free (wvalue);
- wvalue = tem;
- }
- else
- g_free (tem);
- }
- }
-
- value = g_utf16_to_utf8 (wvalue, -1, NULL, NULL, NULL);
-
- g_free (wname);
- g_free (wvalue);
-
- quark = g_quark_from_string (value);
- g_free (value);
-
- return g_quark_to_string (quark);
-
-#endif /* G_OS_WIN32 */
-}
-
-/* _g_getenv_nomalloc
- * this function does a getenv() without doing any kind of allocation
- * through glib. it's suitable for chars <= 127 only (both, for the
- * variable name and the contents) and for contents < 1024 chars in
- * length. also, it aliases "" to a NULL return value.
- **/
-const gchar*
-_g_getenv_nomalloc (const gchar *variable,
- gchar buffer[1024])
-{
- const gchar *retval = getenv (variable);
- if (retval && retval[0])
- {
- gint l = strlen (retval);
- if (l < 1024)
- {
- strncpy (buffer, retval, l);
- buffer[l] = 0;
- return buffer;
- }
- }
- return NULL;
-}
-
-/**
- * g_setenv:
- * @variable: the environment variable to set, must not contain '='.
- * @value: the value for to set the variable to.
- * @overwrite: whether to change the variable if it already exists.
- *
- * Sets an environment variable. Both the variable's name and value
- * should be in the GLib file name encoding. On UNIX, this means that
- * they can be any sequence of bytes. On Windows, they should be in
- * UTF-8.
- *
- * Note that on some systems, when variables are overwritten, the memory
- * used for the previous variables and its value isn't reclaimed.
- *
- * Returns: %FALSE if the environment variable couldn't be set.
- *
- * Since: 2.4
- */
-gboolean
-g_setenv (const gchar *variable,
- const gchar *value,
- gboolean overwrite)
-{
-#ifndef G_OS_WIN32
-
- gint result;
-#ifndef HAVE_SETENV
- gchar *string;
-#endif
-
- g_return_val_if_fail (variable != NULL, FALSE);
- g_return_val_if_fail (strchr (variable, '=') == NULL, FALSE);
-
-#ifdef HAVE_SETENV
- result = setenv (variable, value, overwrite);
-#else
- if (!overwrite && getenv (variable) != NULL)
- return TRUE;
-
- /* This results in a leak when you overwrite existing
- * settings. It would be fairly easy to fix this by keeping
- * our own parallel array or hash table.
- */
- string = g_strconcat (variable, "=", value, NULL);
- result = putenv (string);
-#endif
- return result == 0;
-
-#else /* G_OS_WIN32 */
-
- gboolean retval;
- wchar_t *wname, *wvalue, *wassignment;
- gchar *tem;
-
- g_return_val_if_fail (variable != NULL, FALSE);
- g_return_val_if_fail (strchr (variable, '=') == NULL, FALSE);
- g_return_val_if_fail (g_utf8_validate (variable, -1, NULL), FALSE);
- g_return_val_if_fail (g_utf8_validate (value, -1, NULL), FALSE);
-
- if (!overwrite && g_getenv (variable) != NULL)
- return TRUE;
-
- /* We want to (if possible) set both the environment variable copy
- * kept by the C runtime and the one kept by the system.
- *
- * We can't use only the C runtime's putenv or _wputenv() as that
- * won't work for arbitrary Unicode strings in a "non-Unicode" app
- * (with main() and not wmain()). In a "main()" app the C runtime
- * initializes the C runtime's environment table by converting the
- * real (wide char) environment variables to system codepage, thus
- * breaking those that aren't representable in the system codepage.
- *
- * As the C runtime's putenv() will also set the system copy, we do
- * the putenv() first, then call SetEnvironmentValueW ourselves.
- */
-
- wname = g_utf8_to_utf16 (variable, -1, NULL, NULL, NULL);
- wvalue = g_utf8_to_utf16 (value, -1, NULL, NULL, NULL);
- tem = g_strconcat (variable, "=", value, NULL);
- wassignment = g_utf8_to_utf16 (tem, -1, NULL, NULL, NULL);
-
- g_free (tem);
- _wputenv (wassignment);
- g_free (wassignment);
-
- retval = (SetEnvironmentVariableW (wname, wvalue) != 0);
-
- g_free (wname);
- g_free (wvalue);
-
- return retval;
-
-#endif /* G_OS_WIN32 */
-}
-
-#ifdef HAVE__NSGETENVIRON
-#define environ (*_NSGetEnviron())
-#elif !defined(G_OS_WIN32)
-
-/* According to the Single Unix Specification, environ is not in
- * any system header, although unistd.h often declares it.
- */
-extern char **environ;
-#endif
-
-/**
- * g_unsetenv:
- * @variable: the environment variable to remove, must not contain '='.
- *
- * Removes an environment variable from the environment.
- *
- * Note that on some systems, when variables are overwritten, the memory
- * used for the previous variables and its value isn't reclaimed.
- * Furthermore, this function can't be guaranteed to operate in a
- * threadsafe way.
- *
- * Since: 2.4
- **/
-void
-g_unsetenv (const gchar *variable)
-{
-#ifndef G_OS_WIN32
-
-#ifdef HAVE_UNSETENV
- g_return_if_fail (variable != NULL);
- g_return_if_fail (strchr (variable, '=') == NULL);
-
- unsetenv (variable);
-#else /* !HAVE_UNSETENV */
- int len;
- gchar **e, **f;
-
- g_return_if_fail (variable != NULL);
- g_return_if_fail (strchr (variable, '=') == NULL);
-
- len = strlen (variable);
-
- /* Mess directly with the environ array.
- * This seems to be the only portable way to do this.
- *
- * Note that we remove *all* environment entries for
- * the variable name, not just the first.
- */
- e = f = environ;
- while (*e != NULL)
- {
- if (strncmp (*e, variable, len) != 0 || (*e)[len] != '=')
- {
- *f = *e;
- f++;
- }
- e++;
- }
- *f = NULL;
-#endif /* !HAVE_UNSETENV */
-
-#else /* G_OS_WIN32 */
-
- wchar_t *wname, *wassignment;
- gchar *tem;
-
- g_return_if_fail (variable != NULL);
- g_return_if_fail (strchr (variable, '=') == NULL);
- g_return_if_fail (g_utf8_validate (variable, -1, NULL));
-
- wname = g_utf8_to_utf16 (variable, -1, NULL, NULL, NULL);
- tem = g_strconcat (variable, "=", NULL);
- wassignment = g_utf8_to_utf16 (tem, -1, NULL, NULL, NULL);
-
- g_free (tem);
- _wputenv (wassignment);
- g_free (wassignment);
-
- SetEnvironmentVariableW (wname, NULL);
-
- g_free (wname);
-
-#endif /* G_OS_WIN32 */
-}
-
-/**
- * g_listenv:
- *
- * Gets the names of all variables set in the environment.
- *
- * Returns: a %NULL-terminated list of strings which must be freed
- * with g_strfreev().
- *
- * Programs that want to be portable to Windows should typically use
- * this function and g_getenv() instead of using the environ array
- * from the C library directly. On Windows, the strings in the environ
- * array are in system codepage encoding, while in most of the typical
- * use cases for environment variables in GLib-using programs you want
- * the UTF-8 encoding that this function and g_getenv() provide.
- *
- * Since: 2.8
- */
-gchar **
-g_listenv (void)
-{
-#ifndef G_OS_WIN32
- gchar **result, *eq;
- gint len, i, j;
-
- len = g_strv_length (environ);
- result = g_new0 (gchar *, len + 1);
-
- j = 0;
- for (i = 0; i < len; i++)
- {
- eq = strchr (environ[i], '=');
- if (eq)
- result[j++] = g_strndup (environ[i], eq - environ[i]);
- }
-
- result[j] = NULL;
-
- return result;
-#else
- gchar **result, *eq;
- gint len = 0, j;
- wchar_t *p, *q;
-
- p = (wchar_t *) GetEnvironmentStringsW ();
- if (p != NULL)
- {
- q = p;
- while (*q)
- {
- q += wcslen (q) + 1;
- len++;
- }
- }
- result = g_new0 (gchar *, len + 1);
-
- j = 0;
- q = p;
- while (*q)
- {
- result[j] = g_utf16_to_utf8 (q, -1, NULL, NULL, NULL);
- if (result[j] != NULL)
- {
- eq = strchr (result[j], '=');
- if (eq && eq > result[j])
- {
- *eq = '\0';
- j++;
- }
- else
- g_free (result[j]);
- }
- q += wcslen (q) + 1;
- }
- result[j] = NULL;
- FreeEnvironmentStringsW (p);
-
- return result;
-#endif
-}
-
-G_LOCK_DEFINE_STATIC (g_utils_global);
-
-static gchar *g_tmp_dir = NULL;
-static gchar *g_user_name = NULL;
-static gchar *g_real_name = NULL;
-static gchar *g_home_dir = NULL;
-static gchar *g_host_name = NULL;
-
-#ifdef G_OS_WIN32
-/* System codepage versions of the above, kept at file level so that they,
- * too, are produced only once.
- */
-static gchar *g_tmp_dir_cp = NULL;
-static gchar *g_user_name_cp = NULL;
-static gchar *g_real_name_cp = NULL;
-static gchar *g_home_dir_cp = NULL;
-#endif
-
-static gchar *g_user_data_dir = NULL;
-static gchar **g_system_data_dirs = NULL;
-static gchar *g_user_cache_dir = NULL;
-static gchar *g_user_config_dir = NULL;
-static gchar **g_system_config_dirs = NULL;
-
-static gchar **g_user_special_dirs = NULL;
-
-/* fifteen minutes of fame for everybody */
-#define G_USER_DIRS_EXPIRE 15 * 60
-
-#ifdef G_OS_WIN32
-
-static gchar *
-get_special_folder (int csidl)
-{
- wchar_t path[MAX_PATH+1];
- HRESULT hr;
- LPITEMIDLIST pidl = NULL;
- BOOL b;
- gchar *retval = NULL;
-
- hr = SHGetSpecialFolderLocation (NULL, csidl, &pidl);
- if (hr == S_OK)
- {
- b = SHGetPathFromIDListW (pidl, path);
- if (b)
- retval = g_utf16_to_utf8 (path, -1, NULL, NULL, NULL);
- CoTaskMemFree (pidl);
- }
- return retval;
-}
-
-static char *
-get_windows_directory_root (void)
-{
- wchar_t wwindowsdir[MAX_PATH];
-
- if (GetWindowsDirectoryW (wwindowsdir, G_N_ELEMENTS (wwindowsdir)))
- {
- /* Usually X:\Windows, but in terminal server environments
- * might be an UNC path, AFAIK.
- */
- char *windowsdir = g_utf16_to_utf8 (wwindowsdir, -1, NULL, NULL, NULL);
- char *p;
-
- if (windowsdir == NULL)
- return g_strdup ("C:\\");
-
- p = (char *) g_path_skip_root (windowsdir);
- if (G_IS_DIR_SEPARATOR (p[-1]) && p[-2] != ':')
- p--;
- *p = '\0';
- return windowsdir;
- }
- else
- return g_strdup ("C:\\");
-}
-
-#endif
-
-/* HOLDS: g_utils_global_lock */
-static void
-g_get_any_init_do (void)
-{
- gchar hostname[100];
-
- g_tmp_dir = g_strdup (g_getenv ("TMPDIR"));
- if (!g_tmp_dir)
- g_tmp_dir = g_strdup (g_getenv ("TMP"));
- if (!g_tmp_dir)
- g_tmp_dir = g_strdup (g_getenv ("TEMP"));
-
-#ifdef G_OS_WIN32
- if (!g_tmp_dir)
- g_tmp_dir = get_windows_directory_root ();
-#else
-#ifdef P_tmpdir
- if (!g_tmp_dir)
- {
- gsize k;
- g_tmp_dir = g_strdup (P_tmpdir);
- k = strlen (g_tmp_dir);
- if (k > 1 && G_IS_DIR_SEPARATOR (g_tmp_dir[k - 1]))
- g_tmp_dir[k - 1] = '\0';
- }
-#endif
-
- if (!g_tmp_dir)
- {
- g_tmp_dir = g_strdup ("/tmp");
- }
-#endif /* !G_OS_WIN32 */
-
-#ifdef G_OS_WIN32
- /* We check $HOME first for Win32, though it is a last resort for Unix
- * where we prefer the results of getpwuid().
- */
- g_home_dir = g_strdup (g_getenv ("HOME"));
-
- /* Only believe HOME if it is an absolute path and exists */
- if (g_home_dir)
- {
- if (!(g_path_is_absolute (g_home_dir) &&
- g_file_test (g_home_dir, G_FILE_TEST_IS_DIR)))
- {
- g_free (g_home_dir);
- g_home_dir = NULL;
- }
- }
-
- /* In case HOME is Unix-style (it happens), convert it to
- * Windows style.
- */
- if (g_home_dir)
- {
- gchar *p;
- while ((p = strchr (g_home_dir, '/')) != NULL)
- *p = '\\';
- }
-
- if (!g_home_dir)
- {
- /* USERPROFILE is probably the closest equivalent to $HOME? */
- if (g_getenv ("USERPROFILE") != NULL)
- g_home_dir = g_strdup (g_getenv ("USERPROFILE"));
- }
-
- if (!g_home_dir)
- g_home_dir = get_special_folder (CSIDL_PROFILE);
-
- if (!g_home_dir)
- g_home_dir = get_windows_directory_root ();
-#endif /* G_OS_WIN32 */
-
-#ifdef HAVE_PWD_H
- {
- struct passwd *pw = NULL;
- gpointer buffer = NULL;
- gint error;
- gchar *logname;
-
-# if defined (HAVE_POSIX_GETPWUID_R) || defined (HAVE_NONPOSIX_GETPWUID_R)
- struct passwd pwd;
-# ifdef _SC_GETPW_R_SIZE_MAX
- /* This reurns the maximum length */
- glong bufsize = sysconf (_SC_GETPW_R_SIZE_MAX);
-
- if (bufsize < 0)
- bufsize = 64;
-# else /* _SC_GETPW_R_SIZE_MAX */
- glong bufsize = 64;
-# endif /* _SC_GETPW_R_SIZE_MAX */
-
- logname = (gchar *) g_getenv ("LOGNAME");
-
- do
- {
- g_free (buffer);
- /* we allocate 6 extra bytes to work around a bug in
- * Mac OS < 10.3. See #156446
- */
- buffer = g_malloc (bufsize + 6);
- errno = 0;
-
-# ifdef HAVE_POSIX_GETPWUID_R
- if (logname) {
- error = getpwnam_r (logname, &pwd, buffer, bufsize, &pw);
- if (!pw || (pw->pw_uid != getuid ())) {
- /* LOGNAME is lying, fall back to looking up the uid */
- error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
- }
- } else {
- error = getpwuid_r (getuid (), &pwd, buffer, bufsize, &pw);
- }
- error = error < 0 ? errno : error;
-# else /* HAVE_NONPOSIX_GETPWUID_R */
- /* HPUX 11 falls into the HAVE_POSIX_GETPWUID_R case */
-# if defined(_AIX) || defined(__hpux)
- error = getpwuid_r (getuid (), &pwd, buffer, bufsize);
- pw = error == 0 ? &pwd : NULL;
-# else /* !_AIX */
- if (logname) {
- pw = getpwnam_r (logname, &pwd, buffer, bufsize);
- if (!pw || (pw->pw_uid != getuid ())) {
- /* LOGNAME is lying, fall back to looking up the uid */
- pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
- }
- } else {
- pw = getpwuid_r (getuid (), &pwd, buffer, bufsize);
- }
- error = pw ? 0 : errno;
-# endif /* !_AIX */
-# endif /* HAVE_NONPOSIX_GETPWUID_R */
-
- if (!pw)
- {
- /* we bail out prematurely if the user id can't be found
- * (should be pretty rare case actually), or if the buffer
- * should be sufficiently big and lookups are still not
- * successfull.
- */
- if (error == 0 || error == ENOENT)
- {
- g_warning ("getpwuid_r(): failed due to unknown user id (%lu)",
- (gulong) getuid ());
- break;
- }
- if (bufsize > 32 * 1024)
- {
- g_warning ("getpwuid_r(): failed due to: %s.",
- g_strerror (error));
- break;
- }
-
- bufsize *= 2;
- }
- }
- while (!pw);
-# endif /* HAVE_POSIX_GETPWUID_R || HAVE_NONPOSIX_GETPWUID_R */
-
- if (!pw)
- {
- setpwent ();
- pw = getpwuid (getuid ());
- endpwent ();
- }
- if (pw)
- {
- g_user_name = g_strdup (pw->pw_name);
-
- if (pw->pw_gecos && *pw->pw_gecos != '\0')
- {
- gchar **gecos_fields;
- gchar **name_parts;
-
- /* split the gecos field and substitute '&' */
- gecos_fields = g_strsplit (pw->pw_gecos, ",", 0);
- name_parts = g_strsplit (gecos_fields[0], "&", 0);
- pw->pw_name[0] = g_ascii_toupper (pw->pw_name[0]);
- g_real_name = g_strjoinv (pw->pw_name, name_parts);
- g_strfreev (gecos_fields);
- g_strfreev (name_parts);
- }
-
- if (!g_home_dir)
- g_home_dir = g_strdup (pw->pw_dir);
- }
- g_free (buffer);
- }
-
-#else /* !HAVE_PWD_H */
-
-#ifdef G_OS_WIN32
- {
- guint len = UNLEN+1;
- wchar_t buffer[UNLEN+1];
-
- if (GetUserNameW (buffer, (LPDWORD) &len))
- {
- g_user_name = g_utf16_to_utf8 (buffer, -1, NULL, NULL, NULL);
- g_real_name = g_strdup (g_user_name);
- }
- }
-#endif /* G_OS_WIN32 */
-
-#endif /* !HAVE_PWD_H */
-
-#ifndef G_OS_WIN32
- if (!g_home_dir)
- g_home_dir = g_strdup (g_getenv ("HOME"));
-#endif
-
-#ifdef __EMX__
- /* change '\\' in %HOME% to '/' */
- g_strdelimit (g_home_dir, "\\",'/');
-#endif
- if (!g_user_name)
- g_user_name = g_strdup ("somebody");
- if (!g_real_name)
- g_real_name = g_strdup ("Unknown");
-
- {
-#ifndef G_OS_WIN32
- gboolean hostname_fail = (gethostname (hostname, sizeof (hostname)) == -1);
-#else
- DWORD size = sizeof (hostname);
- gboolean hostname_fail = (!GetComputerName (hostname, &size));
-#endif
- g_host_name = g_strdup (hostname_fail ? "localhost" : hostname);
- }
-
-#ifdef G_OS_WIN32
- g_tmp_dir_cp = g_locale_from_utf8 (g_tmp_dir, -1, NULL, NULL, NULL);
- g_user_name_cp = g_locale_from_utf8 (g_user_name, -1, NULL, NULL, NULL);
- g_real_name_cp = g_locale_from_utf8 (g_real_name, -1, NULL, NULL, NULL);
-
- if (!g_tmp_dir_cp)
- g_tmp_dir_cp = g_strdup ("\\");
- if (!g_user_name_cp)
- g_user_name_cp = g_strdup ("somebody");
- if (!g_real_name_cp)
- g_real_name_cp = g_strdup ("Unknown");
-
- /* home_dir might be NULL, unlike tmp_dir, user_name and
- * real_name.
- */
- if (g_home_dir)
- g_home_dir_cp = g_locale_from_utf8 (g_home_dir, -1, NULL, NULL, NULL);
- else
- g_home_dir_cp = NULL;
-#endif /* G_OS_WIN32 */
-}
-
-static inline void
-g_get_any_init (void)
-{
- if (!g_tmp_dir)
- g_get_any_init_do ();
-}
-
-static inline void
-g_get_any_init_locked (void)
-{
- G_LOCK (g_utils_global);
- g_get_any_init ();
- G_UNLOCK (g_utils_global);
-}
-
-
-/**
- * g_get_user_name:
- *
- * Gets the user name of the current user. The encoding of the returned
- * string is system-defined. On UNIX, it might be the preferred file name
- * encoding, or something else, and there is no guarantee that it is even
- * consistent on a machine. On Windows, it is always UTF-8.
- *
- * Returns: the user name of the current user.
- */
-G_CONST_RETURN gchar*
-g_get_user_name (void)
-{
- g_get_any_init_locked ();
- return g_user_name;
-}
-
-/**
- * g_get_real_name:
- *
- * Gets the real name of the user. This usually comes from the user's entry
- * in the <filename>passwd</filename> file. The encoding of the returned
- * string is system-defined. (On Windows, it is, however, always UTF-8.)
- * If the real user name cannot be determined, the string "Unknown" is
- * returned.
- *
- * Returns: the user's real name.
- */
-G_CONST_RETURN gchar*
-g_get_real_name (void)
-{
- g_get_any_init_locked ();
- return g_real_name;
-}
-
-/**
- * g_get_home_dir:
- *
- * Gets the current user's home directory as defined in the
- * password database.
- *
- * Note that in contrast to traditional UNIX tools, this function
- * prefers <filename>passwd</filename> entries over the <envar>HOME</envar>
- * environment variable.
- *
- * One of the reasons for this decision is that applications in many
- * cases need special handling to deal with the case where
- * <envar>HOME</envar> is
- * <simplelist>
- * <member>Not owned by the user</member>
- * <member>Not writeable</member>
- * <member>Not even readable</member>
- * </simplelist>
- * Since applications are in general <emphasis>not</emphasis> written
- * to deal with these situations it was considered better to make
- * g_get_home_dir() not pay attention to <envar>HOME</envar> and to
- * return the real home directory for the user. If applications
- * want to pay attention to <envar>HOME</envar>, they can do:
- * |[
- * const char *homedir = g_getenv ("HOME");
- * if (!homedir)
- * homedir = g_get_home_dir (<!-- -->);
- * ]|
- *
- * Returns: the current user's home directory
- */
-G_CONST_RETURN gchar*
-g_get_home_dir (void)
-{
- g_get_any_init_locked ();
- return g_home_dir;
-}
-
-/**
- * g_get_tmp_dir:
- *
- * Gets the directory to use for temporary files. This is found from
- * inspecting the environment variables <envar>TMPDIR</envar>,
- * <envar>TMP</envar>, and <envar>TEMP</envar> in that order. If none
- * of those are defined "/tmp" is returned on UNIX and "C:\" on Windows.
- * The encoding of the returned string is system-defined. On Windows,
- * it is always UTF-8. The return value is never %NULL.
- *
- * Returns: the directory to use for temporary files.
- */
-G_CONST_RETURN gchar*
-g_get_tmp_dir (void)
-{
- g_get_any_init_locked ();
- return g_tmp_dir;
-}
-
-/**
- * g_get_host_name:
- *
- * Return a name for the machine.
- *
- * The returned name is not necessarily a fully-qualified domain name,
- * or even present in DNS or some other name service at all. It need
- * not even be unique on your local network or site, but usually it
- * is. Callers should not rely on the return value having any specific
- * properties like uniqueness for security purposes. Even if the name
- * of the machine is changed while an application is running, the
- * return value from this function does not change. The returned
- * string is owned by GLib and should not be modified or freed. If no
- * name can be determined, a default fixed string "localhost" is
- * returned.
- *
- * Returns: the host name of the machine.
- *
- * Since: 2.8
- */
-const gchar *
-g_get_host_name (void)
-{
- g_get_any_init_locked ();
- return g_host_name;
-}
-#endif
-
-G_LOCK_DEFINE_STATIC (g_prgname);
-static gchar *g_prgname = NULL;
-
-/**
- * g_get_prgname:
- *
- * Gets the name of the program. This name should <emphasis>not</emphasis>
- * be localized, contrast with g_get_application_name().
- * (If you are using GDK or GTK+ the program name is set in gdk_init(),
- * which is called by gtk_init(). The program name is found by taking
- * the last component of <literal>argv[0]</literal>.)
- *
- * Returns: the name of the program. The returned string belongs
- * to GLib and must not be modified or freed.
- */
-gchar*
-g_get_prgname (void)
-{
- gchar* retval =NULL;
-
-// G_LOCK (g_prgname);
-//#ifdef G_OS_WIN32
-// if (g_prgname == NULL)
-// {
-// static gboolean beenhere = FALSE;
-//
-// if (!beenhere)
-// {
-// gchar *utf8_buf = NULL;
-// wchar_t buf[MAX_PATH+1];
-//
-// beenhere = TRUE;
-// if (GetModuleFileNameW (GetModuleHandle (NULL),
-// buf, G_N_ELEMENTS (buf)) > 0)
-// utf8_buf = g_utf16_to_utf8 (buf, -1, NULL, NULL, NULL);
-//
-// if (utf8_buf)
-// {
-// g_prgname = g_path_get_basename (utf8_buf);
-// g_free (utf8_buf);
-// }
-// }
-// }
-//#endif
-// retval = g_prgname;
-// G_UNLOCK (g_prgname);
-//
- return retval;
-}
-
-/**
- * g_set_prgname:
- * @prgname: the name of the program.
- *
- * Sets the name of the program. This name should <emphasis>not</emphasis>
- * be localized, contrast with g_set_application_name(). Note that for
- * thread-safety reasons this function can only be called once.
- */
-void
-g_set_prgname (const gchar *prgname)
-{
- G_LOCK (g_prgname);
- g_free (g_prgname);
- g_prgname = g_strdup (prgname);
- G_UNLOCK (g_prgname);
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-G_LOCK_DEFINE_STATIC (g_application_name);
-static gchar *g_application_name = NULL;
-
-/**
- * g_get_application_name:
- *
- * Gets a human-readable name for the application, as set by
- * g_set_application_name(). This name should be localized if
- * possible, and is intended for display to the user. Contrast with
- * g_get_prgname(), which gets a non-localized name. If
- * g_set_application_name() has not been called, returns the result of
- * g_get_prgname() (which may be %NULL if g_set_prgname() has also not
- * been called).
- *
- * Return value: human-readable application name. may return %NULL
- *
- * Since: 2.2
- **/
-G_CONST_RETURN gchar*
-g_get_application_name (void)
-{
- gchar* retval;
-
- G_LOCK (g_application_name);
- retval = g_application_name;
- G_UNLOCK (g_application_name);
-
- if (retval == NULL)
- return g_get_prgname ();
-
- return retval;
-}
-
-/**
- * g_set_application_name:
- * @application_name: localized name of the application
- *
- * Sets a human-readable name for the application. This name should be
- * localized if possible, and is intended for display to the user.
- * Contrast with g_set_prgname(), which sets a non-localized name.
- * g_set_prgname() will be called automatically by gtk_init(),
- * but g_set_application_name() will not.
- *
- * Note that for thread safety reasons, this function can only
- * be called once.
- *
- * The application name will be used in contexts such as error messages,
- * or when displaying an application's name in the task list.
- *
- * Since: 2.2
- **/
-void
-g_set_application_name (const gchar *application_name)
-{
- gboolean already_set = FALSE;
-
- G_LOCK (g_application_name);
- if (g_application_name)
- already_set = TRUE;
- else
- g_application_name = g_strdup (application_name);
- G_UNLOCK (g_application_name);
-
- if (already_set)
- g_warning ("g_set_application() name called multiple times");
-}
-
-/**
- * g_get_user_data_dir:
- *
- * Returns a base directory in which to access application data such
- * as icons that is customized for a particular user.
- *
- * On UNIX platforms this is determined using the mechanisms described in
- * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
- * XDG Base Directory Specification</ulink>
- *
- * Return value: a string owned by GLib that must not be modified
- * or freed.
- * Since: 2.6
- **/
-G_CONST_RETURN gchar*
-g_get_user_data_dir (void)
-{
- gchar *data_dir;
-
- G_LOCK (g_utils_global);
-
- if (!g_user_data_dir)
- {
-#ifdef G_OS_WIN32
- data_dir = get_special_folder (CSIDL_PERSONAL);
-#else
- data_dir = (gchar *) g_getenv ("XDG_DATA_HOME");
-
- if (data_dir && data_dir[0])
- data_dir = g_strdup (data_dir);
-#endif
- if (!data_dir || !data_dir[0])
- {
- g_get_any_init ();
-
- if (g_home_dir)
- data_dir = g_build_filename (g_home_dir, ".local",
- "share", NULL);
- else
- data_dir = g_build_filename (g_tmp_dir, g_user_name, ".local",
- "share", NULL);
- }
-
- g_user_data_dir = data_dir;
- }
- else
- data_dir = g_user_data_dir;
-
- G_UNLOCK (g_utils_global);
-
- return data_dir;
-}
-
-static void
-g_init_user_config_dir (void)
-{
- gchar *config_dir;
-
- if (!g_user_config_dir)
- {
-#ifdef G_OS_WIN32
- config_dir = get_special_folder (CSIDL_APPDATA);
-#else
- config_dir = (gchar *) g_getenv ("XDG_CONFIG_HOME");
-
- if (config_dir && config_dir[0])
- config_dir = g_strdup (config_dir);
-#endif
- if (!config_dir || !config_dir[0])
- {
- g_get_any_init ();
-
- if (g_home_dir)
- config_dir = g_build_filename (g_home_dir, ".config", NULL);
- else
- config_dir = g_build_filename (g_tmp_dir, g_user_name, ".config", NULL);
- }
-
- g_user_config_dir = config_dir;
- }
-}
-
-/**
- * g_get_user_config_dir:
- *
- * Returns a base directory in which to store user-specific application
- * configuration information such as user preferences and settings.
- *
- * On UNIX platforms this is determined using the mechanisms described in
- * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
- * XDG Base Directory Specification</ulink>
- *
- * Return value: a string owned by GLib that must not be modified
- * or freed.
- * Since: 2.6
- **/
-G_CONST_RETURN gchar*
-g_get_user_config_dir (void)
-{
- G_LOCK (g_utils_global);
-
- g_init_user_config_dir ();
-
- G_UNLOCK (g_utils_global);
-
- return g_user_config_dir;
-}
-
-/**
- * g_get_user_cache_dir:
- *
- * Returns a base directory in which to store non-essential, cached
- * data specific to particular user.
- *
- * On UNIX platforms this is determined using the mechanisms described in
- * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
- * XDG Base Directory Specification</ulink>
- *
- * Return value: a string owned by GLib that must not be modified
- * or freed.
- * Since: 2.6
- **/
-G_CONST_RETURN gchar*
-g_get_user_cache_dir (void)
-{
- gchar *cache_dir;
-
- G_LOCK (g_utils_global);
-
- if (!g_user_cache_dir)
- {
-#ifdef G_OS_WIN32
- cache_dir = get_special_folder (CSIDL_INTERNET_CACHE); /* XXX correct? */
-#else
- cache_dir = (gchar *) g_getenv ("XDG_CACHE_HOME");
-
- if (cache_dir && cache_dir[0])
- cache_dir = g_strdup (cache_dir);
-#endif
- if (!cache_dir || !cache_dir[0])
- {
- g_get_any_init ();
-
- if (g_home_dir)
- cache_dir = g_build_filename (g_home_dir, ".cache", NULL);
- else
- cache_dir = g_build_filename (g_tmp_dir, g_user_name, ".cache", NULL);
- }
- g_user_cache_dir = cache_dir;
- }
- else
- cache_dir = g_user_cache_dir;
-
- G_UNLOCK (g_utils_global);
-
- return cache_dir;
-}
-
-#ifdef HAVE_CARBON
-
-static gchar *
-find_folder (OSType type)
-{
- gchar *filename = NULL;
- FSRef found;
-
- if (FSFindFolder (kUserDomain, type, kDontCreateFolder, &found) == noErr)
- {
- CFURLRef url = CFURLCreateFromFSRef (kCFAllocatorSystemDefault, &found);
-
- if (url)
- {
- CFStringRef path = CFURLCopyFileSystemPath (url, kCFURLPOSIXPathStyle);
-
- if (path)
- {
- filename = g_strdup (CFStringGetCStringPtr (path, kCFStringEncodingUTF8));
-
- if (! filename)
- {
- filename = g_new0 (gchar, CFStringGetLength (path) * 3 + 1);
-
- CFStringGetCString (path, filename,
- CFStringGetLength (path) * 3 + 1,
- kCFStringEncodingUTF8);
- }
-
- CFRelease (path);
- }
-
- CFRelease (url);
- }
- }
-
- return filename;
-}
-
-static void
-load_user_special_dirs (void)
-{
- g_user_special_dirs[G_USER_DIRECTORY_DESKTOP] = find_folder (kDesktopFolderType);
- g_user_special_dirs[G_USER_DIRECTORY_DOCUMENTS] = find_folder (kDocumentsFolderType);
- g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = find_folder (kDesktopFolderType); /* XXX correct ? */
- g_user_special_dirs[G_USER_DIRECTORY_MUSIC] = find_folder (kMusicDocumentsFolderType);
- g_user_special_dirs[G_USER_DIRECTORY_PICTURES] = find_folder (kPictureDocumentsFolderType);
- g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = NULL;
- g_user_special_dirs[G_USER_DIRECTORY_TEMPLATES] = NULL;
- g_user_special_dirs[G_USER_DIRECTORY_VIDEOS] = find_folder (kMovieDocumentsFolderType);
-}
-
-#endif /* HAVE_CARBON */
-
-#if defined(G_OS_WIN32)
-static void
-load_user_special_dirs (void)
-{
- typedef HRESULT (WINAPI *t_SHGetKnownFolderPath) (const GUID *rfid,
- DWORD dwFlags,
- HANDLE hToken,
- PWSTR *ppszPath);
- t_SHGetKnownFolderPath p_SHGetKnownFolderPath;
- static const GUID FOLDERID_Downloads =
- { 0x374de290, 0x123f, 0x4565, { 0x91, 0x64, 0x39, 0xc4, 0x92, 0x5e, 0x46, 0x7b } };
- static const GUID FOLDERID_Public =
- { 0xDFDF76A2, 0xC82A, 0x4D63, { 0x90, 0x6A, 0x56, 0x44, 0xAC, 0x45, 0x73, 0x85 } };
- wchar_t *wcp;
-
- p_SHGetKnownFolderPath = (t_SHGetKnownFolderPath) GetProcAddress (LoadLibrary ("shell32.dll"),
- "SHGetKnownFolderPath");
-
- g_user_special_dirs[G_USER_DIRECTORY_DESKTOP] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
- g_user_special_dirs[G_USER_DIRECTORY_DOCUMENTS] = get_special_folder (CSIDL_PERSONAL);
-
- if (p_SHGetKnownFolderPath == NULL)
- {
- g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
- }
- else
- {
- wcp = NULL;
- (*p_SHGetKnownFolderPath) (&FOLDERID_Downloads, 0, NULL, &wcp);
- g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = g_utf16_to_utf8 (wcp, -1, NULL, NULL, NULL);
- if (g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] == NULL)
- g_user_special_dirs[G_USER_DIRECTORY_DOWNLOAD] = get_special_folder (CSIDL_DESKTOPDIRECTORY);
- CoTaskMemFree (wcp);
- }
-
- g_user_special_dirs[G_USER_DIRECTORY_MUSIC] = get_special_folder (CSIDL_MYMUSIC);
- g_user_special_dirs[G_USER_DIRECTORY_PICTURES] = get_special_folder (CSIDL_MYPICTURES);
-
- if (p_SHGetKnownFolderPath == NULL)
- {
- /* XXX */
- g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = get_special_folder (CSIDL_COMMON_DOCUMENTS);
- }
- else
- {
- wcp = NULL;
- (*p_SHGetKnownFolderPath) (&FOLDERID_Public, 0, NULL, &wcp);
- g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = g_utf16_to_utf8 (wcp, -1, NULL, NULL, NULL);
- if (g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] == NULL)
- g_user_special_dirs[G_USER_DIRECTORY_PUBLIC_SHARE] = get_special_folder (CSIDL_COMMON_DOCUMENTS);
- CoTaskMemFree (wcp);
- }
-
- g_user_special_dirs[G_USER_DIRECTORY_TEMPLATES] = get_special_folder (CSIDL_TEMPLATES);
- g_user_special_dirs[G_USER_DIRECTORY_VIDEOS] = get_special_folder (CSIDL_MYVIDEO);
-}
-#endif /* G_OS_WIN32 */
-
-static void g_init_user_config_dir (void);
-
-#if defined(G_OS_UNIX) && !defined(HAVE_CARBON)
-
-/* adapted from xdg-user-dir-lookup.c
- *
- * Copyright (C) 2007 Red Hat Inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-static void
-load_user_special_dirs (void)
-{
- gchar *config_file;
- gchar *data;
- gchar **lines;
- gint n_lines, i;
-
- g_init_user_config_dir ();
- config_file = g_build_filename (g_user_config_dir,
- "user-dirs.dirs",
- NULL);
-
- if (!g_file_get_contents (config_file, &data, NULL, NULL))
- {
- g_free (config_file);
- return;
- }
-
- lines = g_strsplit (data, "\n", -1);
- n_lines = g_strv_length (lines);
- g_free (data);
-
- for (i = 0; i < n_lines; i++)
- {
- gchar *buffer = lines[i];
- gchar *d, *p;
- gint len;
- gboolean is_relative = FALSE;
- GUserDirectory directory;
-
- /* Remove newline at end */
- len = strlen (buffer);
- if (len > 0 && buffer[len - 1] == '\n')
- buffer[len - 1] = 0;
-
- p = buffer;
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (strncmp (p, "XDG_DESKTOP_DIR", strlen ("XDG_DESKTOP_DIR")) == 0)
- {
- directory = G_USER_DIRECTORY_DESKTOP;
- p += strlen ("XDG_DESKTOP_DIR");
- }
- else if (strncmp (p, "XDG_DOCUMENTS_DIR", strlen ("XDG_DOCUMENTS_DIR")) == 0)
- {
- directory = G_USER_DIRECTORY_DOCUMENTS;
- p += strlen ("XDG_DOCUMENTS_DIR");
- }
- else if (strncmp (p, "XDG_DOWNLOAD_DIR", strlen ("XDG_DOWNLOAD_DIR")) == 0)
- {
- directory = G_USER_DIRECTORY_DOWNLOAD;
- p += strlen ("XDG_DOWNLOAD_DIR");
- }
- else if (strncmp (p, "XDG_MUSIC_DIR", strlen ("XDG_MUSIC_DIR")) == 0)
- {
- directory = G_USER_DIRECTORY_MUSIC;
- p += strlen ("XDG_MUSIC_DIR");
- }
- else if (strncmp (p, "XDG_PICTURES_DIR", strlen ("XDG_PICTURES_DIR")) == 0)
- {
- directory = G_USER_DIRECTORY_PICTURES;
- p += strlen ("XDG_PICTURES_DIR");
- }
- else if (strncmp (p, "XDG_PUBLICSHARE_DIR", strlen ("XDG_PUBLICSHARE_DIR")) == 0)
- {
- directory = G_USER_DIRECTORY_PUBLIC_SHARE;
- p += strlen ("XDG_PUBLICSHARE_DIR");
- }
- else if (strncmp (p, "XDG_TEMPLATES_DIR", strlen ("XDG_TEMPLATES_DIR")) == 0)
- {
- directory = G_USER_DIRECTORY_TEMPLATES;
- p += strlen ("XDG_TEMPLATES_DIR");
- }
- else if (strncmp (p, "XDG_VIDEOS_DIR", strlen ("XDG_VIDEOS_DIR")) == 0)
- {
- directory = G_USER_DIRECTORY_VIDEOS;
- p += strlen ("XDG_VIDEOS_DIR");
- }
- else
- continue;
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (*p != '=')
- continue;
- p++;
-
- while (*p == ' ' || *p == '\t')
- p++;
-
- if (*p != '"')
- continue;
- p++;
-
- if (strncmp (p, "$HOME", 5) == 0)
- {
- p += 5;
- is_relative = TRUE;
- }
- else if (*p != '/')
- continue;
-
- d = strrchr (p, '"');
- if (!d)
- continue;
- *d = 0;
-
- d = p;
-
- /* remove trailing slashes */
- len = strlen (d);
- if (d[len - 1] == '/')
- d[len - 1] = 0;
-
- if (is_relative)
- {
- g_get_any_init ();
- g_user_special_dirs[directory] = g_build_filename (g_home_dir, d, NULL);
- }
- else
- g_user_special_dirs[directory] = g_strdup (d);
- }
-
- g_strfreev (lines);
- g_free (config_file);
-}
-
-#endif /* G_OS_UNIX && !HAVE_CARBON */
-
-/**
- * g_get_user_special_dir:
- * @directory: the logical id of special directory
- *
- * Returns the full path of a special directory using its logical id.
- *
- * On Unix this is done using the XDG special user directories.
- * For compatibility with existing practise, %G_USER_DIRECTORY_DESKTOP
- * falls back to <filename>$HOME/Desktop</filename> when XDG special
- * user directories have not been set up.
- *
- * Depending on the platform, the user might be able to change the path
- * of the special directory without requiring the session to restart; GLib
- * will not reflect any change once the special directories are loaded.
- *
- * Return value: the path to the specified special directory, or %NULL
- * if the logical id was not found. The returned string is owned by
- * GLib and should not be modified or freed.
- *
- * Since: 2.14
- */
-G_CONST_RETURN gchar *
-g_get_user_special_dir (GUserDirectory directory)
-{
- g_return_val_if_fail (directory >= G_USER_DIRECTORY_DESKTOP &&
- directory < G_USER_N_DIRECTORIES, NULL);
-
- G_LOCK (g_utils_global);
-
- if (G_UNLIKELY (g_user_special_dirs == NULL))
- {
- g_user_special_dirs = g_new0 (gchar *, G_USER_N_DIRECTORIES);
-
- load_user_special_dirs ();
-
- /* Special-case desktop for historical compatibility */
- if (g_user_special_dirs[G_USER_DIRECTORY_DESKTOP] == NULL)
- {
- g_get_any_init ();
-
- g_user_special_dirs[G_USER_DIRECTORY_DESKTOP] =
- g_build_filename (g_home_dir, "Desktop", NULL);
- }
- }
-
- G_UNLOCK (g_utils_global);
-
- return g_user_special_dirs[directory];
-}
-
-#ifdef G_OS_WIN32
-
-#undef g_get_system_data_dirs
-
-static HMODULE
-get_module_for_address (gconstpointer address)
-{
- /* Holds the g_utils_global lock */
-
- static gboolean beenhere = FALSE;
- typedef BOOL (WINAPI *t_GetModuleHandleExA) (DWORD, LPCTSTR, HMODULE *);
- static t_GetModuleHandleExA p_GetModuleHandleExA = NULL;
- HMODULE hmodule = NULL;
-
- if (!address)
- return NULL;
-
- if (!beenhere)
- {
- p_GetModuleHandleExA =
- (t_GetModuleHandleExA) GetProcAddress (LoadLibrary ("kernel32.dll"),
- "GetModuleHandleExA");
- beenhere = TRUE;
- }
-
- if (p_GetModuleHandleExA == NULL ||
- !(*p_GetModuleHandleExA) (GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT |
- GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
- address, &hmodule))
- {
- MEMORY_BASIC_INFORMATION mbi;
- VirtualQuery (address, &mbi, sizeof (mbi));
- hmodule = (HMODULE) mbi.AllocationBase;
- }
-
- return hmodule;
-}
-
-static gchar *
-get_module_share_dir (gconstpointer address)
-{
- HMODULE hmodule;
- gchar *filename;
- gchar *retval;
-
- hmodule = get_module_for_address (address);
- if (hmodule == NULL)
- return NULL;
-
- filename = g_win32_get_package_installation_directory_of_module (hmodule);
- retval = g_build_filename (filename, "share", NULL);
- g_free (filename);
-
- return retval;
-}
-
-G_CONST_RETURN gchar * G_CONST_RETURN *
-g_win32_get_system_data_dirs_for_module (gconstpointer address)
-{
- GArray *data_dirs;
- HMODULE hmodule;
- static GHashTable *per_module_data_dirs = NULL;
- gchar **retval;
- gchar *p;
- gchar *exe_root;
-
- if (address)
- {
- G_LOCK (g_utils_global);
- hmodule = get_module_for_address (address);
- if (hmodule != NULL)
- {
- if (per_module_data_dirs == NULL)
- per_module_data_dirs = g_hash_table_new (NULL, NULL);
- else
- {
- retval = g_hash_table_lookup (per_module_data_dirs, hmodule);
-
- if (retval != NULL)
- {
- G_UNLOCK (g_utils_global);
- return (G_CONST_RETURN gchar * G_CONST_RETURN *) retval;
- }
- }
- }
- }
-
- data_dirs = g_array_new (TRUE, TRUE, sizeof (char *));
-
- /* Documents and Settings\All Users\Application Data */
- p = get_special_folder (CSIDL_COMMON_APPDATA);
- if (p)
- g_array_append_val (data_dirs, p);
-
- /* Documents and Settings\All Users\Documents */
- p = get_special_folder (CSIDL_COMMON_DOCUMENTS);
- if (p)
- g_array_append_val (data_dirs, p);
-
- /* Using the above subfolders of Documents and Settings perhaps
- * makes sense from a Windows perspective.
- *
- * But looking at the actual use cases of this function in GTK+
- * and GNOME software, what we really want is the "share"
- * subdirectory of the installation directory for the package
- * our caller is a part of.
- *
- * The address parameter, if non-NULL, points to a function in the
- * calling module. Use that to determine that module's installation
- * folder, and use its "share" subfolder.
- *
- * Additionally, also use the "share" subfolder of the installation
- * locations of GLib and the .exe file being run.
- *
- * To guard against none of the above being what is really wanted,
- * callers of this function should have Win32-specific code to look
- * up their installation folder themselves, and handle a subfolder
- * "share" of it in the same way as the folders returned from this
- * function.
- */
-
- p = get_module_share_dir (address);
- if (p)
- g_array_append_val (data_dirs, p);
-
- if (glib_dll != NULL)
- {
- gchar *glib_root = g_win32_get_package_installation_directory_of_module (glib_dll);
- p = g_build_filename (glib_root, "share", NULL);
- if (p)
- g_array_append_val (data_dirs, p);
- g_free (glib_root);
- }
-
- exe_root = g_win32_get_package_installation_directory_of_module (NULL);
- p = g_build_filename (exe_root, "share", NULL);
- if (p)
- g_array_append_val (data_dirs, p);
- g_free (exe_root);
-
- retval = (gchar **) g_array_free (data_dirs, FALSE);
-
- if (address)
- {
- if (hmodule != NULL)
- g_hash_table_insert (per_module_data_dirs, hmodule, retval);
- G_UNLOCK (g_utils_global);
- }
-
- return (G_CONST_RETURN gchar * G_CONST_RETURN *) retval;
-}
-
-#endif
-
-/**
- * g_get_system_data_dirs:
- *
- * Returns an ordered list of base directories in which to access
- * system-wide application data.
- *
- * On UNIX platforms this is determined using the mechanisms described in
- * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
- * XDG Base Directory Specification</ulink>
- *
- * On Windows the first elements in the list are the Application Data
- * and Documents folders for All Users. (These can be determined only
- * on Windows 2000 or later and are not present in the list on other
- * Windows versions.) See documentation for CSIDL_COMMON_APPDATA and
- * CSIDL_COMMON_DOCUMENTS.
- *
- * Then follows the "share" subfolder in the installation folder for
- * the package containing the DLL that calls this function, if it can
- * be determined.
- *
- * Finally the list contains the "share" subfolder in the installation
- * folder for GLib, and in the installation folder for the package the
- * application's .exe file belongs to.
- *
- * The installation folders above are determined by looking up the
- * folder where the module (DLL or EXE) in question is located. If the
- * folder's name is "bin", its parent is used, otherwise the folder
- * itself.
- *
- * Note that on Windows the returned list can vary depending on where
- * this function is called.
- *
- * Return value: a %NULL-terminated array of strings owned by GLib that must
- * not be modified or freed.
- * Since: 2.6
- **/
-G_CONST_RETURN gchar * G_CONST_RETURN *
-g_get_system_data_dirs (void)
-{
- gchar **data_dir_vector;
-
- G_LOCK (g_utils_global);
-
- if (!g_system_data_dirs)
- {
-#ifdef G_OS_WIN32
- data_dir_vector = (gchar **) g_win32_get_system_data_dirs_for_module (NULL);
-#else
- gchar *data_dirs = (gchar *) g_getenv ("XDG_DATA_DIRS");
-
- if (!data_dirs || !data_dirs[0])
- data_dirs = "/usr/local/share/:/usr/share/";
-
- data_dir_vector = g_strsplit (data_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
-#endif
-
- g_system_data_dirs = data_dir_vector;
- }
- else
- data_dir_vector = g_system_data_dirs;
-
- G_UNLOCK (g_utils_global);
-
- return (G_CONST_RETURN gchar * G_CONST_RETURN *) data_dir_vector;
-}
-
-/**
- * g_get_system_config_dirs:
- *
- * Returns an ordered list of base directories in which to access
- * system-wide configuration information.
- *
- * On UNIX platforms this is determined using the mechanisms described in
- * the <ulink url="http://www.freedesktop.org/Standards/basedir-spec">
- * XDG Base Directory Specification</ulink>
- *
- * Return value: a %NULL-terminated array of strings owned by GLib that must
- * not be modified or freed.
- * Since: 2.6
- **/
-G_CONST_RETURN gchar * G_CONST_RETURN *
-g_get_system_config_dirs (void)
-{
- gchar *conf_dirs, **conf_dir_vector;
-
- G_LOCK (g_utils_global);
-
- if (!g_system_config_dirs)
- {
-#ifdef G_OS_WIN32
- conf_dirs = get_special_folder (CSIDL_COMMON_APPDATA);
- if (conf_dirs)
- {
- conf_dir_vector = g_strsplit (conf_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
- g_free (conf_dirs);
- }
- else
- {
- /* Return empty list */
- conf_dir_vector = g_strsplit ("", G_SEARCHPATH_SEPARATOR_S, 0);
- }
-#else
- conf_dirs = (gchar *) g_getenv ("XDG_CONFIG_DIRS");
-
- if (!conf_dirs || !conf_dirs[0])
- conf_dirs = "/etc/xdg";
-
- conf_dir_vector = g_strsplit (conf_dirs, G_SEARCHPATH_SEPARATOR_S, 0);
-#endif
-
- g_system_config_dirs = conf_dir_vector;
- }
- else
- conf_dir_vector = g_system_config_dirs;
- G_UNLOCK (g_utils_global);
-
- return (G_CONST_RETURN gchar * G_CONST_RETURN *) conf_dir_vector;
-}
-
-#ifndef G_OS_WIN32
-
-static GHashTable *alias_table = NULL;
-
-/* read an alias file for the locales */
-static void
-read_aliases (gchar *file)
-{
- FILE *fp;
- char buf[256];
-
- if (!alias_table)
- alias_table = g_hash_table_new (g_str_hash, g_str_equal);
- fp = fopen (file,"r");
- if (!fp)
- return;
- while (fgets (buf, 256, fp))
- {
- char *p, *q;
-
- g_strstrip (buf);
-
- /* Line is a comment */
- if ((buf[0] == '#') || (buf[0] == '\0'))
- continue;
-
- /* Reads first column */
- for (p = buf, q = NULL; *p; p++) {
- if ((*p == '\t') || (*p == ' ') || (*p == ':')) {
- *p = '\0';
- q = p+1;
- while ((*q == '\t') || (*q == ' ')) {
- q++;
- }
- break;
- }
- }
- /* The line only had one column */
- if (!q || *q == '\0')
- continue;
-
- /* Read second column */
- for (p = q; *p; p++) {
- if ((*p == '\t') || (*p == ' ')) {
- *p = '\0';
- break;
- }
- }
-
- /* Add to alias table if necessary */
- if (!g_hash_table_lookup (alias_table, buf)) {
- g_hash_table_insert (alias_table, g_strdup (buf), g_strdup (q));
- }
- }
- fclose (fp);
-}
-
-#endif
-
-static char *
-unalias_lang (char *lang)
-{
-#ifndef G_OS_WIN32
- char *p;
- int i;
-
- if (!alias_table)
- read_aliases ("/usr/share/locale/locale.alias");
-
- i = 0;
- while ((p = g_hash_table_lookup (alias_table, lang)) && (strcmp (p, lang) != 0))
- {
- lang = p;
- if (i++ == 30)
- {
- static gboolean said_before = FALSE;
- if (!said_before)
- g_warning ("Too many alias levels for a locale, "
- "may indicate a loop");
- said_before = TRUE;
- return lang;
- }
- }
-#endif
- return lang;
-}
-
-/* Mask for components of locale spec. The ordering here is from
- * least significant to most significant
- */
-enum
-{
- COMPONENT_CODESET = 1 << 0,
- COMPONENT_TERRITORY = 1 << 1,
- COMPONENT_MODIFIER = 1 << 2
-};
-
-/* Break an X/Open style locale specification into components
- */
-static guint
-explode_locale (const gchar *locale,
- gchar **language,
- gchar **territory,
- gchar **codeset,
- gchar **modifier)
-{
- const gchar *uscore_pos;
- const gchar *at_pos;
- const gchar *dot_pos;
-
- guint mask = 0;
-
- uscore_pos = strchr (locale, '_');
- dot_pos = strchr (uscore_pos ? uscore_pos : locale, '.');
- at_pos = strchr (dot_pos ? dot_pos : (uscore_pos ? uscore_pos : locale), '@');
-
- if (at_pos)
- {
- mask |= COMPONENT_MODIFIER;
- *modifier = g_strdup (at_pos);
- }
- else
- at_pos = locale + strlen (locale);
-
- if (dot_pos)
- {
- mask |= COMPONENT_CODESET;
- *codeset = g_strndup (dot_pos, at_pos - dot_pos);
- }
- else
- dot_pos = at_pos;
-
- if (uscore_pos)
- {
- mask |= COMPONENT_TERRITORY;
- *territory = g_strndup (uscore_pos, dot_pos - uscore_pos);
- }
- else
- uscore_pos = dot_pos;
-
- *language = g_strndup (locale, uscore_pos - locale);
-
- return mask;
-}
-
-/*
- * Compute all interesting variants for a given locale name -
- * by stripping off different components of the value.
- *
- * For simplicity, we assume that the locale is in
- * X/Open format: language[_territory][.codeset][@modifier]
- *
- * TODO: Extend this to handle the CEN format (see the GNUlibc docs)
- * as well. We could just copy the code from glibc wholesale
- * but it is big, ugly, and complicated, so I'm reluctant
- * to do so when this should handle 99% of the time...
- */
-GSList *
-_g_compute_locale_variants (const gchar *locale)
-{
- GSList *retval = NULL;
-
- gchar *language = NULL;
- gchar *territory = NULL;
- gchar *codeset = NULL;
- gchar *modifier = NULL;
-
- guint mask;
- guint i;
-
- g_return_val_if_fail (locale != NULL, NULL);
-
- mask = explode_locale (locale, &language, &territory, &codeset, &modifier);
-
- /* Iterate through all possible combinations, from least attractive
- * to most attractive.
- */
- for (i = 0; i <= mask; i++)
- if ((i & ~mask) == 0)
- {
- gchar *val = g_strconcat (language,
- (i & COMPONENT_TERRITORY) ? territory : "",
- (i & COMPONENT_CODESET) ? codeset : "",
- (i & COMPONENT_MODIFIER) ? modifier : "",
- NULL);
- retval = g_slist_prepend (retval, val);
- }
-
- g_free (language);
- if (mask & COMPONENT_CODESET)
- g_free (codeset);
- if (mask & COMPONENT_TERRITORY)
- g_free (territory);
- if (mask & COMPONENT_MODIFIER)
- g_free (modifier);
-
- return retval;
-}
-
-/* The following is (partly) taken from the gettext package.
- Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc. */
-
-static const gchar *
-guess_category_value (const gchar *category_name)
-{
- const gchar *retval;
-
- /* The highest priority value is the `LANGUAGE' environment
- variable. This is a GNU extension. */
- retval = g_getenv ("LANGUAGE");
- if ((retval != NULL) && (retval[0] != '\0'))
- return retval;
-
- /* `LANGUAGE' is not set. So we have to proceed with the POSIX
- methods of looking to `LC_ALL', `LC_xxx', and `LANG'. On some
- systems this can be done by the `setlocale' function itself. */
-
- /* Setting of LC_ALL overwrites all other. */
- retval = g_getenv ("LC_ALL");
- if ((retval != NULL) && (retval[0] != '\0'))
- return retval;
-
- /* Next comes the name of the desired category. */
- retval = g_getenv (category_name);
- if ((retval != NULL) && (retval[0] != '\0'))
- return retval;
-
- /* Last possibility is the LANG environment variable. */
- retval = g_getenv ("LANG");
- if ((retval != NULL) && (retval[0] != '\0'))
- return retval;
-
-#ifdef G_PLATFORM_WIN32
- /* g_win32_getlocale() first checks for LC_ALL, LC_MESSAGES and
- * LANG, which we already did above. Oh well. The main point of
- * calling g_win32_getlocale() is to get the thread's locale as used
- * by Windows and the Microsoft C runtime (in the "English_United
- * States" format) translated into the Unixish format.
- */
- retval = g_win32_getlocale ();
- if ((retval != NULL) && (retval[0] != '\0'))
- return retval;
-#endif
-
- return NULL;
-}
-
-typedef struct _GLanguageNamesCache GLanguageNamesCache;
-
-struct _GLanguageNamesCache {
- gchar *languages;
- gchar **language_names;
-};
-
-static void
-language_names_cache_free (gpointer data)
-{
- GLanguageNamesCache *cache = data;
- g_free (cache->languages);
- g_strfreev (cache->language_names);
- g_free (cache);
-}
-
-/**
- * g_get_language_names:
- *
- * Computes a list of applicable locale names, which can be used to
- * e.g. construct locale-dependent filenames or search paths. The returned
- * list is sorted from most desirable to least desirable and always contains
- * the default locale "C".
- *
- * For example, if LANGUAGE=de:en_US, then the returned list is
- * "de", "en_US", "en", "C".
- *
- * This function consults the environment variables <envar>LANGUAGE</envar>,
- * <envar>LC_ALL</envar>, <envar>LC_MESSAGES</envar> and <envar>LANG</envar>
- * to find the list of locales specified by the user.
- *
- * Return value: a %NULL-terminated array of strings owned by GLib
- * that must not be modified or freed.
- *
- * Since: 2.6
- **/
-G_CONST_RETURN gchar * G_CONST_RETURN *
-g_get_language_names (void)
-{
- static GStaticPrivate cache_private = G_STATIC_PRIVATE_INIT;
- GLanguageNamesCache *cache = g_static_private_get (&cache_private);
- const gchar *value;
-
- if (!cache)
- {
- cache = g_new0 (GLanguageNamesCache, 1);
- g_static_private_set (&cache_private, cache, language_names_cache_free);
- }
-
- value = guess_category_value ("LC_MESSAGES");
- if (!value)
- value = "C";
-
- if (!(cache->languages && strcmp (cache->languages, value) == 0))
- {
- gchar **languages;
- gchar **alist, **a;
- GSList *list, *l;
- gint i;
-
- g_free (cache->languages);
- g_strfreev (cache->language_names);
- cache->languages = g_strdup (value);
-
- alist = g_strsplit (value, ":", 0);
- list = NULL;
- for (a = alist; *a; a++)
- {
- gchar *b = unalias_lang (*a);
- list = g_slist_concat (list, _g_compute_locale_variants (b));
- }
- g_strfreev (alist);
- list = g_slist_append (list, g_strdup ("C"));
-
- cache->language_names = languages = g_new (gchar *, g_slist_length (list) + 1);
- for (l = list, i = 0; l; l = l->next, i++)
- languages[i] = l->data;
- languages[i] = NULL;
-
- g_slist_free (list);
- }
-
- return (G_CONST_RETURN gchar * G_CONST_RETURN *) cache->language_names;
-}
-
-#endif /* NOT_NEEDED_FOR_NAVIT */
-/**
- * g_direct_hash:
- * @v: a #gpointer key
- *
- * Converts a gpointer to a hash value.
- * It can be passed to g_hash_table_new() as the @hash_func parameter,
- * when using pointers as keys in a #GHashTable.
- *
- * Returns: a hash value corresponding to the key.
- */
-guint
-g_direct_hash (gconstpointer v)
-{
- return GPOINTER_TO_UINT (v);
-}
-
-/**
- * g_direct_equal:
- * @v1: a key.
- * @v2: a key to compare with @v1.
- *
- * Compares two #gpointer arguments and returns %TRUE if they are equal.
- * It can be passed to g_hash_table_new() as the @key_equal_func
- * parameter, when using pointers as keys in a #GHashTable.
- *
- * Returns: %TRUE if the two keys match.
- */
-gboolean
-g_direct_equal (gconstpointer v1,
- gconstpointer v2)
-{
- return v1 == v2;
-}
-
-/**
- * g_int_equal:
- * @v1: a pointer to a #gint key.
- * @v2: a pointer to a #gint key to compare with @v1.
- *
- * Compares the two #gint values being pointed to and returns
- * %TRUE if they are equal.
- * It can be passed to g_hash_table_new() as the @key_equal_func
- * parameter, when using pointers to integers as keys in a #GHashTable.
- *
- * Returns: %TRUE if the two keys match.
- */
-gboolean
-g_int_equal (gconstpointer v1,
- gconstpointer v2)
-{
- return *((const gint*) v1) == *((const gint*) v2);
-}
-
-/**
- * g_int_hash:
- * @v: a pointer to a #gint key
- *
- * Converts a pointer to a #gint to a hash value.
- * It can be passed to g_hash_table_new() as the @hash_func parameter,
- * when using pointers to integers values as keys in a #GHashTable.
- *
- * Returns: a hash value corresponding to the key.
- */
-guint
-g_int_hash (gconstpointer v)
-{
- return *(const gint*) v;
-}
-
-#if NOT_NEEDED_FOR_NAVIT
-/**
- * g_nullify_pointer:
- * @nullify_location: the memory address of the pointer.
- *
- * Set the pointer at the specified location to %NULL.
- **/
-void
-g_nullify_pointer (gpointer *nullify_location)
-{
- g_return_if_fail (nullify_location != NULL);
-
- *nullify_location = NULL;
-}
-
-/**
- * g_get_codeset:
- *
- * Get the codeset for the current locale.
- *
- * Return value: a newly allocated string containing the name
- * of the codeset. This string must be freed with g_free().
- **/
-gchar *
-g_get_codeset (void)
-{
- const gchar *charset;
-
- g_get_charset (&charset);
-
- return g_strdup (charset);
-}
-
-/* This is called from g_thread_init(). It's used to
- * initialize some static data in a threadsafe way.
- */
-void
-_g_utils_thread_init (void)
-{
- g_get_language_names ();
-}
-
-#ifdef G_OS_WIN32
-
-/**
- * _glib_get_locale_dir:
- *
- * Return the path to the share\locale or lib\locale subfolder of the
- * GLib installation folder. The path is in the system codepage. We
- * have to use system codepage as bindtextdomain() doesn't have a
- * UTF-8 interface.
- */
-static gchar *
-_glib_get_locale_dir (void)
-{
- gchar *install_dir = NULL, *locale_dir;
- gchar *retval = NULL;
-
- if (glib_dll != NULL)
- install_dir = g_win32_get_package_installation_directory_of_module (glib_dll);
-
- if (install_dir)
- {
- /*
- * Append "/share/locale" or "/lib/locale" depending on whether
- * autoconfigury detected GNU gettext or not.
- */
- const char *p = GLIB_LOCALE_DIR + strlen (GLIB_LOCALE_DIR);
- while (*--p != '/')
- ;
- while (*--p != '/')
- ;
-
- locale_dir = g_build_filename (install_dir, p, NULL);
-
- retval = g_win32_locale_filename_from_utf8 (locale_dir);
-
- g_free (install_dir);
- g_free (locale_dir);
- }
-
- if (retval)
- return retval;
- else
- return g_strdup ("");
-}
-
-#undef GLIB_LOCALE_DIR
-
-#endif /* G_OS_WIN32 */
-
-/**
- * glib_gettext:
- * @str: The string to be translated
- *
- * Returns the translated string from the glib translations.
- * This is an internal function and should only be used by
- * the internals of glib (such as libgio).
- *
- * Returns: the transation of @str to the current locale
- */
-G_CONST_RETURN gchar *
-glib_gettext (const gchar *str)
-{
- static gboolean _glib_gettext_initialized = FALSE;
-
- if (!_glib_gettext_initialized)
- {
-#ifdef G_OS_WIN32
- gchar *tmp = _glib_get_locale_dir ();
- bindtextdomain (GETTEXT_PACKAGE, tmp);
- g_free (tmp);
-#else
- bindtextdomain (GETTEXT_PACKAGE, GLIB_LOCALE_DIR);
-#endif
-# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
- bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
-# endif
- _glib_gettext_initialized = TRUE;
- }
-
- return g_dgettext (GETTEXT_PACKAGE, str);
-}
-
-#if defined (G_OS_WIN32) && !defined (_WIN64)
-
-/* Binary compatibility versions. Not for newly compiled code. */
-
-#undef g_find_program_in_path
-
-gchar*
-g_find_program_in_path (const gchar *program)
-{
- gchar *utf8_program = g_locale_to_utf8 (program, -1, NULL, NULL, NULL);
- gchar *utf8_retval = g_find_program_in_path_utf8 (utf8_program);
- gchar *retval;
-
- g_free (utf8_program);
- if (utf8_retval == NULL)
- return NULL;
- retval = g_locale_from_utf8 (utf8_retval, -1, NULL, NULL, NULL);
- g_free (utf8_retval);
-
- return retval;
-}
-
-#undef g_get_current_dir
-
-gchar*
-g_get_current_dir (void)
-{
- gchar *utf8_dir = g_get_current_dir_utf8 ();
- gchar *dir = g_locale_from_utf8 (utf8_dir, -1, NULL, NULL, NULL);
- g_free (utf8_dir);
- return dir;
-}
-
-#undef g_getenv
-
-G_CONST_RETURN gchar*
-g_getenv (const gchar *variable)
-{
- gchar *utf8_variable = g_locale_to_utf8 (variable, -1, NULL, NULL, NULL);
- const gchar *utf8_value = g_getenv_utf8 (utf8_variable);
- gchar *value;
- GQuark quark;
-
- g_free (utf8_variable);
- if (!utf8_value)
- return NULL;
- value = g_locale_from_utf8 (utf8_value, -1, NULL, NULL, NULL);
- quark = g_quark_from_string (value);
- g_free (value);
-
- return g_quark_to_string (quark);
-}
-
-#undef g_setenv
-
-gboolean
-g_setenv (const gchar *variable,
- const gchar *value,
- gboolean overwrite)
-{
- gchar *utf8_variable = g_locale_to_utf8 (variable, -1, NULL, NULL, NULL);
- gchar *utf8_value = g_locale_to_utf8 (value, -1, NULL, NULL, NULL);
- gboolean retval = g_setenv_utf8 (utf8_variable, utf8_value, overwrite);
-
- g_free (utf8_variable);
- g_free (utf8_value);
-
- return retval;
-}
-
-#undef g_unsetenv
-
-void
-g_unsetenv (const gchar *variable)
-{
- gchar *utf8_variable = g_locale_to_utf8 (variable, -1, NULL, NULL, NULL);
-
- g_unsetenv_utf8 (utf8_variable);
-
- g_free (utf8_variable);
-}
-
-#undef g_get_user_name
-
-G_CONST_RETURN gchar*
-g_get_user_name (void)
-{
- g_get_any_init_locked ();
- return g_user_name_cp;
-}
-
-#undef g_get_real_name
-
-G_CONST_RETURN gchar*
-g_get_real_name (void)
-{
- g_get_any_init_locked ();
- return g_real_name_cp;
-}
-
-#undef g_get_home_dir
-
-G_CONST_RETURN gchar*
-g_get_home_dir (void)
-{
- g_get_any_init_locked ();
- return g_home_dir_cp;
-}
-
-#undef g_get_tmp_dir
-
-G_CONST_RETURN gchar*
-g_get_tmp_dir (void)
-{
- g_get_any_init_locked ();
- return g_tmp_dir_cp;
-}
-
-#endif
-#endif /* NOT_NEEDED_FOR_NAVIT */
-
-#define __G_UTILS_C__
-#include "galiasdef.c"
diff --git a/navit/support/glib/gutils.h b/navit/support/glib/gutils.h
deleted file mode 100755
index e1f382027..000000000
--- a/navit/support/glib/gutils.h
+++ /dev/null
@@ -1,490 +0,0 @@
-/* GLIB - Library of useful routines for C programming
- * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
- */
-
-/*
- * Modified by the GLib Team and others 1997-2000. See the AUTHORS
- * file for a list of people on the GLib Team. See the ChangeLog
- * files for a list of changes. These files are distributed with
- * GLib at ftp://ftp.gtk.org/pub/gtk/.
- */
-
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
-#ifndef __G_UTILS_H__
-#define __G_UTILS_H__
-
-#include <glib/gtypes.h>
-#include <stdarg.h>
-
-G_BEGIN_DECLS
-
-#ifdef G_OS_WIN32
-
-/* On Win32, the canonical directory separator is the backslash, and
- * the search path separator is the semicolon. Note that also the
- * (forward) slash works as directory separator.
- */
-#define G_DIR_SEPARATOR '\\'
-#define G_DIR_SEPARATOR_S "\\"
-#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR || (c) == '/')
-#define G_SEARCHPATH_SEPARATOR ';'
-#define G_SEARCHPATH_SEPARATOR_S ";"
-
-#else /* !G_OS_WIN32 */
-
-/* Unix */
-
-#define G_DIR_SEPARATOR '/'
-#define G_DIR_SEPARATOR_S "/"
-#define G_IS_DIR_SEPARATOR(c) ((c) == G_DIR_SEPARATOR)
-#define G_SEARCHPATH_SEPARATOR ':'
-#define G_SEARCHPATH_SEPARATOR_S ":"
-
-#endif /* !G_OS_WIN32 */
-
-/* Define G_VA_COPY() to do the right thing for copying va_list variables.
- * glibconfig.h may have already defined G_VA_COPY as va_copy or __va_copy.
- */
-#if !defined (G_VA_COPY)
-# if defined (__GNUC__) && defined (__PPC__) && (defined (_CALL_SYSV) || defined (_WIN32))
-# define G_VA_COPY(ap1, ap2) (*(ap1) = *(ap2))
-# elif defined (G_VA_COPY_AS_ARRAY)
-# define G_VA_COPY(ap1, ap2) g_memmove ((ap1), (ap2), sizeof (va_list))
-# else /* va_list is a pointer */
-# define G_VA_COPY(ap1, ap2) ((ap1) = (ap2))
-# endif /* va_list is a pointer */
-#endif /* !G_VA_COPY */
-
-/* inlining hassle. for compilers that don't allow the `inline' keyword,
- * mostly because of strict ANSI C compliance or dumbness, we try to fall
- * back to either `__inline__' or `__inline'.
- * G_CAN_INLINE is defined in glibconfig.h if the compiler seems to be
- * actually *capable* to do function inlining, in which case inline
- * function bodies do make sense. we also define G_INLINE_FUNC to properly
- * export the function prototypes if no inlining can be performed.
- * inline function bodies have to be special cased with G_CAN_INLINE and a
- * .c file specific macro to allow one compiled instance with extern linkage
- * of the functions by defining G_IMPLEMENT_INLINES and the .c file macro.
- */
-#if defined (G_HAVE_INLINE) && defined (__GNUC__) && defined (__STRICT_ANSI__)
-# undef inline
-# define inline __inline__
-#elif !defined (G_HAVE_INLINE)
-# undef inline
-# if defined (G_HAVE___INLINE__)
-# define inline __inline__
-# elif defined (G_HAVE___INLINE)
-# define inline __inline
-# else /* !inline && !__inline__ && !__inline */
-# define inline /* don't inline, then */
-# endif
-#endif
-#ifdef G_IMPLEMENT_INLINES
-# define G_INLINE_FUNC
-# undef G_CAN_INLINE
-#elif defined (__GNUC__)
-# define G_INLINE_FUNC static __inline __attribute__ ((unused))
-#elif defined (G_CAN_INLINE)
-# define G_INLINE_FUNC static inline
-#else /* can't inline */
-# define G_INLINE_FUNC
-#endif /* !G_INLINE_FUNC */
-
-/* Retrive static string info
- */
-#ifdef G_OS_WIN32
-#define g_get_user_name g_get_user_name_utf8
-#define g_get_real_name g_get_real_name_utf8
-#define g_get_home_dir g_get_home_dir_utf8
-#define g_get_tmp_dir g_get_tmp_dir_utf8
-#endif
-
-G_CONST_RETURN gchar* g_get_user_name (void);
-G_CONST_RETURN gchar* g_get_real_name (void);
-G_CONST_RETURN gchar* g_get_home_dir (void);
-G_CONST_RETURN gchar* g_get_tmp_dir (void);
-G_CONST_RETURN gchar* g_get_host_name (void);
-gchar* g_get_prgname (void);
-void g_set_prgname (const gchar *prgname);
-G_CONST_RETURN gchar* g_get_application_name (void);
-void g_set_application_name (const gchar *application_name);
-
-void g_reload_user_special_dirs_cache (void);
-G_CONST_RETURN gchar* g_get_user_data_dir (void);
-G_CONST_RETURN gchar* g_get_user_config_dir (void);
-G_CONST_RETURN gchar* g_get_user_cache_dir (void);
-G_CONST_RETURN gchar* G_CONST_RETURN * g_get_system_data_dirs (void);
-
-#ifdef G_OS_WIN32
-/* This functions is not part of the public GLib API */
-G_CONST_RETURN gchar* G_CONST_RETURN * g_win32_get_system_data_dirs_for_module (void (*address_of_function)(void));
-#endif
-
-#if defined (G_OS_WIN32) && defined (G_CAN_INLINE) && !defined (__cplusplus)
-/* This function is not part of the public GLib API either. Just call
- * g_get_system_data_dirs() in your code, never mind that that is
- * actually a macro and you will in fact call this inline function.
- */
-static inline G_CONST_RETURN gchar * G_CONST_RETURN *
-_g_win32_get_system_data_dirs (void)
-{
- return g_win32_get_system_data_dirs_for_module ((void (*)(void)) &_g_win32_get_system_data_dirs);
-}
-#define g_get_system_data_dirs _g_win32_get_system_data_dirs
-#endif
-
-G_CONST_RETURN gchar* G_CONST_RETURN * g_get_system_config_dirs (void);
-
-G_CONST_RETURN gchar* G_CONST_RETURN * g_get_language_names (void);
-
-/**
- * GUserDirectory:
- * @G_USER_DIRECTORY_DESKTOP: the user's Desktop directory
- * @G_USER_DIRECTORY_DOCUMENTS: the user's Documents directory
- * @G_USER_DIRECTORY_DOWNLOAD: the user's Downloads directory
- * @G_USER_DIRECTORY_MUSIC: the user's Music directory
- * @G_USER_DIRECTORY_PICTURES: the user's Pictures directory
- * @G_USER_DIRECTORY_PUBLIC_SHARE: the user's shared directory
- * @G_USER_DIRECTORY_TEMPLATES: the user's Templates directory
- * @G_USER_DIRECTORY_VIDEOS: the user's Movies directory
- * @G_USER_N_DIRECTORIES: the number of enum values
- *
- * These are logical ids for special directories which are defined
- * depending on the platform used. You should use g_get_user_special_dir()
- * to retrieve the full path associated to the logical id.
- *
- * The #GUserDirectory enumeration can be extended at later date. Not
- * every platform has a directory for every logical id in this
- * enumeration.
- *
- * Since: 2.14
- */
-typedef enum {
- G_USER_DIRECTORY_DESKTOP,
- G_USER_DIRECTORY_DOCUMENTS,
- G_USER_DIRECTORY_DOWNLOAD,
- G_USER_DIRECTORY_MUSIC,
- G_USER_DIRECTORY_PICTURES,
- G_USER_DIRECTORY_PUBLIC_SHARE,
- G_USER_DIRECTORY_TEMPLATES,
- G_USER_DIRECTORY_VIDEOS,
-
- G_USER_N_DIRECTORIES
-} GUserDirectory;
-
-G_CONST_RETURN gchar* g_get_user_special_dir (GUserDirectory directory);
-
-typedef struct _GDebugKey GDebugKey;
-struct _GDebugKey
-{
- const gchar *key;
- guint value;
-};
-
-/* Miscellaneous utility functions
- */
-guint g_parse_debug_string (const gchar *string,
- const GDebugKey *keys,
- guint nkeys);
-
-gint g_snprintf (gchar *string,
- gulong n,
- gchar const *format,
- ...) G_GNUC_PRINTF (3, 4);
-gint g_vsnprintf (gchar *string,
- gulong n,
- gchar const *format,
- va_list args);
-
-/* Check if a file name is an absolute path */
-gboolean g_path_is_absolute (const gchar *file_name);
-
-/* In case of absolute paths, skip the root part */
-G_CONST_RETURN gchar* g_path_skip_root (const gchar *file_name);
-
-#ifndef G_DISABLE_DEPRECATED
-
-/* These two functions are deprecated and will be removed in the next
- * major release of GLib. Use g_path_get_dirname/g_path_get_basename
- * instead. Whatch out! The string returned by g_path_get_basename
- * must be g_freed, while the string returned by g_basename must not.*/
-G_CONST_RETURN gchar* g_basename (const gchar *file_name);
-#define g_dirname g_path_get_dirname
-
-#endif /* G_DISABLE_DEPRECATED */
-
-#ifdef G_OS_WIN32
-#define g_get_current_dir g_get_current_dir_utf8
-#endif
-
-/* The returned strings are newly allocated with g_malloc() */
-gchar* g_get_current_dir (void);
-gchar* g_path_get_basename (const gchar *file_name) G_GNUC_MALLOC;
-gchar* g_path_get_dirname (const gchar *file_name) G_GNUC_MALLOC;
-
-/* Set the pointer at the specified location to NULL */
-void g_nullify_pointer (gpointer *nullify_location);
-
-/* return the environment string for the variable. The returned memory
- * must not be freed. */
-#ifdef G_OS_WIN32
-#define g_getenv g_getenv_utf8
-#define g_setenv g_setenv_utf8
-#define g_unsetenv g_unsetenv_utf8
-#define g_find_program_in_path g_find_program_in_path_utf8
-#endif
-
-G_CONST_RETURN gchar* g_getenv (const gchar *variable);
-gboolean g_setenv (const gchar *variable,
- const gchar *value,
- gboolean overwrite);
-void g_unsetenv (const gchar *variable);
-gchar** g_listenv (void);
-
-/* private */
-const gchar* _g_getenv_nomalloc (const gchar *variable,
- gchar buffer[1024]);
-
-/* we try to provide a useful equivalent for ATEXIT if it is
- * not defined, but use is actually abandoned. people should
- * use g_atexit() instead.
- */
-typedef void (*GVoidFunc) (void);
-#ifndef ATEXIT
-# define ATEXIT(proc) g_ATEXIT(proc)
-#else
-# define G_NATIVE_ATEXIT
-#endif /* ATEXIT */
-/* we use a GLib function as a replacement for ATEXIT, so
- * the programmer is not required to check the return value
- * (if there is any in the implementation) and doesn't encounter
- * missing include files.
- */
-void g_atexit (GVoidFunc func);
-
-#ifdef G_OS_WIN32
-/* It's a bad idea to wrap atexit() on Windows. If the GLib DLL calls
- * atexit(), the function will be called when the GLib DLL is detached
- * from the program, which is not what the caller wants. The caller
- * wants the function to be called when it *itself* exits (or is
- * detached, in case the caller, too, is a DLL).
- */
-#if (defined(__MINGW_H) && !defined(_STDLIB_H_)) || (defined(_MSC_VER) && !defined(_INC_STDLIB))
-int atexit (void (*)(void));
-#endif
-#define g_atexit(func) atexit(func)
-#endif
-
-/* Look for an executable in PATH, following execvp() rules */
-gchar* g_find_program_in_path (const gchar *program);
-
-/* Bit tests
- */
-G_INLINE_FUNC gint g_bit_nth_lsf (gulong mask,
- gint nth_bit) G_GNUC_CONST;
-G_INLINE_FUNC gint g_bit_nth_msf (gulong mask,
- gint nth_bit) G_GNUC_CONST;
-G_INLINE_FUNC guint g_bit_storage (gulong number) G_GNUC_CONST;
-
-/* Trash Stacks
- * elements need to be >= sizeof (gpointer)
- */
-typedef struct _GTrashStack GTrashStack;
-struct _GTrashStack
-{
- GTrashStack *next;
-};
-
-G_INLINE_FUNC void g_trash_stack_push (GTrashStack **stack_p,
- gpointer data_p);
-G_INLINE_FUNC gpointer g_trash_stack_pop (GTrashStack **stack_p);
-G_INLINE_FUNC gpointer g_trash_stack_peek (GTrashStack **stack_p);
-G_INLINE_FUNC guint g_trash_stack_height (GTrashStack **stack_p);
-
-/* inline function implementations
- */
-#if defined (G_CAN_INLINE) || defined (__G_UTILS_C__)
-G_INLINE_FUNC gint
-g_bit_nth_lsf (gulong mask,
- gint nth_bit)
-{
- if (G_UNLIKELY (nth_bit < -1))
- nth_bit = -1;
- while (nth_bit < ((GLIB_SIZEOF_LONG * 8) - 1))
- {
- nth_bit++;
- if (mask & (1UL << nth_bit))
- return nth_bit;
- }
- return -1;
-}
-G_INLINE_FUNC gint
-g_bit_nth_msf (gulong mask,
- gint nth_bit)
-{
- if (nth_bit < 0 || G_UNLIKELY (nth_bit > GLIB_SIZEOF_LONG * 8))
- nth_bit = GLIB_SIZEOF_LONG * 8;
- while (nth_bit > 0)
- {
- nth_bit--;
- if (mask & (1UL << nth_bit))
- return nth_bit;
- }
- return -1;
-}
-G_INLINE_FUNC guint
-g_bit_storage (gulong number)
-{
-#if defined(__GNUC__) && (__GNUC__ >= 4) && defined(__OPTIMIZE__) && !defined(__ARM_ARCH_4T__)
- return G_LIKELY (number) ?
- ((GLIB_SIZEOF_LONG * 8 - 1) ^ __builtin_clzl(number)) + 1 : 1;
-#else
- register guint n_bits = 0;
-
- do
- {
- n_bits++;
- number >>= 1;
- }
- while (number);
- return n_bits;
-#endif
-}
-G_INLINE_FUNC void
-g_trash_stack_push (GTrashStack **stack_p,
- gpointer data_p)
-{
- GTrashStack *data = (GTrashStack *) data_p;
-
- data->next = *stack_p;
- *stack_p = data;
-}
-G_INLINE_FUNC gpointer
-g_trash_stack_pop (GTrashStack **stack_p)
-{
- GTrashStack *data;
-
- data = *stack_p;
- if (data)
- {
- *stack_p = data->next;
- /* NULLify private pointer here, most platforms store NULL as
- * subsequent 0 bytes
- */
- data->next = NULL;
- }
-
- return data;
-}
-G_INLINE_FUNC gpointer
-g_trash_stack_peek (GTrashStack **stack_p)
-{
- GTrashStack *data;
-
- data = *stack_p;
-
- return data;
-}
-G_INLINE_FUNC guint
-g_trash_stack_height (GTrashStack **stack_p)
-{
- GTrashStack *data;
- guint i = 0;
-
- for (data = *stack_p; data; data = data->next)
- i++;
-
- return i;
-}
-#endif /* G_CAN_INLINE || __G_UTILS_C__ */
-
-/* Glib version.
- * we prefix variable declarations so they can
- * properly get exported in windows dlls.
- */
-GLIB_VAR const guint glib_major_version;
-GLIB_VAR const guint glib_minor_version;
-GLIB_VAR const guint glib_micro_version;
-GLIB_VAR const guint glib_interface_age;
-GLIB_VAR const guint glib_binary_age;
-
-const gchar * glib_check_version (guint required_major,
- guint required_minor,
- guint required_micro);
-
-#define GLIB_CHECK_VERSION(major,minor,micro) \
- (GLIB_MAJOR_VERSION > (major) || \
- (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION > (minor)) || \
- (GLIB_MAJOR_VERSION == (major) && GLIB_MINOR_VERSION == (minor) && \
- GLIB_MICRO_VERSION >= (micro)))
-
-G_END_DECLS
-
-#ifndef G_DISABLE_DEPRECATED
-
-/*
- * This macro is deprecated. This DllMain() is too complex. It is
- * recommended to write an explicit minimal DLlMain() that just saves
- * the handle to the DLL and then use that handle instead, for
- * instance passing it to
- * g_win32_get_package_installation_directory_of_module().
- *
- * On Windows, this macro defines a DllMain function that stores the
- * actual DLL name that the code being compiled will be included in.
- * STATIC should be empty or 'static'. DLL_NAME is the name of the
- * (pointer to the) char array where the DLL name will be stored. If
- * this is used, you must also include <windows.h>. If you need a more complex
- * DLL entry point function, you cannot use this.
- *
- * On non-Windows platforms, expands to nothing.
- */
-
-#ifndef G_PLATFORM_WIN32
-# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name)
-#else
-# define G_WIN32_DLLMAIN_FOR_DLL_NAME(static, dll_name) \
-static char *dll_name; \
- \
-BOOL WINAPI \
-DllMain (HINSTANCE hinstDLL, \
- DWORD fdwReason, \
- LPVOID lpvReserved) \
-{ \
- wchar_t wcbfr[1000]; \
- char *tem; \
- switch (fdwReason) \
- { \
- case DLL_PROCESS_ATTACH: \
- GetModuleFileNameW ((HMODULE) hinstDLL, wcbfr, G_N_ELEMENTS (wcbfr)); \
- tem = g_utf16_to_utf8 (wcbfr, -1, NULL, NULL, NULL); \
- dll_name = g_path_get_basename (tem); \
- g_free (tem); \
- break; \
- } \
- \
- return TRUE; \
-}
-
-#endif /* !G_DISABLE_DEPRECATED */
-
-#endif /* G_PLATFORM_WIN32 */
-
-#endif /* __G_UTILS_H__ */
diff --git a/navit/support/libc/CMakeLists.txt b/navit/support/libc/CMakeLists.txt
deleted file mode 100644
index 9a91d41b6..000000000
--- a/navit/support/libc/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-supportlib_add_library(support_libc libc.c libc_init.c unlink.c rename.c time.c open.c abort.c mkdir.c lseek.c stat.c close.c chsize.c read.c write.c strcasecmp.c localtime.c gmtime.c mktime.c timeutil.c calloc.c bsearch.c)
diff --git a/navit/support/libc/_mingw.h b/navit/support/libc/_mingw.h
deleted file mode 100644
index 977334d1a..000000000
--- a/navit/support/libc/_mingw.h
+++ /dev/null
@@ -1,304 +0,0 @@
-#ifndef __MINGW_H
-/*
- * _mingw.h
- *
- * Mingw specific macros included by ALL include files.
- *
- * This file is part of the Mingw32 package.
- *
- * Contributors:
- * Created by Mumit Khan <khan@xraylith.wisc.edu>
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAIMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- */
-#define __MINGW_H
-
-#define __MINGW32_VERSION 3.16
-#define __MINGW32_MAJOR_VERSION 3
-#define __MINGW32_MINOR_VERSION 16
-#define __MINGW32_PATCHLEVEL 0
-
-#if __GNUC__ >= 3
-#pragma GCC system_header
-#endif
-
-/* These are defined by the user (or the compiler)
- to specify how identifiers are imported from a DLL.
-
- __DECLSPEC_SUPPORTED Defined if dllimport attribute is supported.
- __MINGW_IMPORT The attribute definition to specify imported
- variables/functions.
- _CRTIMP As above. For MS compatibility.
- __MINGW32_VERSION Runtime version.
- __MINGW32_MAJOR_VERSION Runtime major version.
- __MINGW32_MINOR_VERSION Runtime minor version.
- __MINGW32_BUILD_DATE Runtime build date.
-
- Macros to enable MinGW features which deviate from standard MSVC
- compatible behaviour; these may be specified directly in user code,
- activated implicitly, (e.g. by specifying _POSIX_C_SOURCE or such),
- or by inclusion in __MINGW_FEATURES__:
-
- __USE_MINGW_ANSI_STDIO Select a more ANSI C99 compatible
- implementation of printf() and friends.
-
- Other macros:
-
- __int64 define to be long long. Using a typedef
- doesn't work for "unsigned __int64"
-
- All headers should include this first, and then use __DECLSPEC_SUPPORTED
- to choose between the old ``__imp__name'' style or __MINGW_IMPORT
- style declarations. */
-
-
-/* Manifest definitions identifying the flag bits, controlling activation
- * of MinGW features, as specified by the user in __MINGW_FEATURES__.
- */
-#define __MINGW_ANSI_STDIO__ 0x0000000000000001ULL
-/*
- * The following three are not yet formally supported; they are
- * included here, to document anticipated future usage.
- */
-#define __MINGW_LC_EXTENSIONS__ 0x0000000000000050ULL
-#define __MINGW_LC_MESSAGES__ 0x0000000000000010ULL
-#define __MINGW_LC_ENVVARS__ 0x0000000000000040ULL
-
-/* Try to avoid problems with outdated checks for GCC __attribute__ support. */
-#undef __attribute__
-
-#if defined (__PCC__)
-# undef __DECLSPEC_SUPPORTED
-# ifndef __MINGW_IMPORT
-# define __MINGW_IMPORT extern
-# endif
-# ifndef _CRTIMP
-# define _CRTIMP
-# endif
-# ifndef __cdecl
-# define __cdecl _Pragma("cdecl")
-# endif
-# ifndef __stdcall
-# define __stdcall _Pragma("stdcall")
-# endif
-# ifndef __int64
-# define __int64 long long
-# endif
-# ifndef __int32
-# define __int32 long
-# endif
-# ifndef __int16
-# define __int16 short
-# endif
-# ifndef __int8
-# define __int8 char
-# endif
-# ifndef __small
-# define __small char
-# endif
-# ifndef __hyper
-# define __hyper long long
-# endif
-# ifndef __volatile__
-# define __volatile__ volatile
-# endif
-# ifndef __restrict__
-# define __restrict__ restrict
-# endif
-# define NONAMELESSUNION
-#elif defined(__GNUC__)
-# ifdef __declspec
-# ifndef __MINGW_IMPORT
- /* Note the extern. This is needed to work around GCC's
- limitations in handling dllimport attribute. */
-# define __MINGW_IMPORT extern __attribute__ ((__dllimport__))
-# endif
-# ifndef _CRTIMP
-# ifdef __USE_CRTIMP
-# define _CRTIMP __attribute__ ((dllimport))
-# else
-# define _CRTIMP
-# endif
-# endif
-# define __DECLSPEC_SUPPORTED
-# else /* __declspec */
-# undef __DECLSPEC_SUPPORTED
-# undef __MINGW_IMPORT
-# ifndef _CRTIMP
-# define _CRTIMP
-# endif
-# endif /* __declspec */
-/*
- * The next two defines can cause problems if user code adds the
- * __cdecl attribute like so:
- * void __attribute__ ((__cdecl)) foo(void);
- */
-# ifndef __cdecl
-# define __cdecl __attribute__ ((__cdecl__))
-# endif
-# ifndef __stdcall
-# define __stdcall __attribute__ ((__stdcall__))
-# endif
-# ifndef __int64
-# define __int64 long long
-# endif
-# ifndef __int32
-# define __int32 long
-# endif
-# ifndef __int16
-# define __int16 short
-# endif
-# ifndef __int8
-# define __int8 char
-# endif
-# ifndef __small
-# define __small char
-# endif
-# ifndef __hyper
-# define __hyper long long
-# endif
-#else /* ! __GNUC__ && ! __PCC__ */
-# ifndef __MINGW_IMPORT
-# define __MINGW_IMPORT __declspec(dllimport)
-# endif
-# ifndef _CRTIMP
-# define _CRTIMP __declspec(dllimport)
-# endif
-# define __DECLSPEC_SUPPORTED
-# define __attribute__(x) /* nothing */
-#endif
-
-#if defined (__GNUC__) && defined (__GNUC_MINOR__)
-#define __MINGW_GNUC_PREREQ(major, minor) \
- (__GNUC__ > (major) \
- || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
-#else
-#define __MINGW_GNUC_PREREQ(major, minor) 0
-#endif
-
-#ifdef __cplusplus
-# define __CRT_INLINE inline
-#else
-# if __GNUC_STDC_INLINE__
-# define __CRT_INLINE extern inline __attribute__((__gnu_inline__))
-# else
-# ifdef __COREDLL__
- /* There isn't any out-of-line version of most of
- these functions in coredll.dll, so we need this for -O0,
- or for -fno-inline. This is still problematic if the user
- tries t o take the address of these functions. We will slowly
- add out-of-line copies as those cases are found.
- Note: We can't use static inline here, as most of these functions
- will be declared elsew here with external linkage, and gcc will
- barf on that. */
-# define __CRT_INLINE extern __inline__ __attribute__((__always_inline__))
-# else
-# define __CRT_INLINE
-# endif
-# endif
-#endif
-
-#ifdef __cplusplus
-# define __UNUSED_PARAM(x)
-#else
-# ifdef __GNUC__
-# define __UNUSED_PARAM(x) x __attribute__ ((__unused__))
-# else
-# define __UNUSED_PARAM(x) x
-# endif
-#endif
-
-#ifdef __GNUC__
-#define __MINGW_ATTRIB_NORETURN __attribute__ ((__noreturn__))
-#define __MINGW_ATTRIB_CONST __attribute__ ((__const__))
-#else
-#define __MINGW_ATTRIB_NORETURN
-#define __MINGW_ATTRIB_CONST
-#endif
-
-#if __MINGW_GNUC_PREREQ (3, 0)
-#define __MINGW_ATTRIB_MALLOC __attribute__ ((__malloc__))
-#define __MINGW_ATTRIB_PURE __attribute__ ((__pure__))
-#else
-#define __MINGW_ATTRIB_MALLOC
-#define __MINGW_ATTRIB_PURE
-#endif
-
-/* Attribute `nonnull' was valid as of gcc 3.3. We don't use GCC's
- variadiac macro facility, because variadic macros cause syntax
- errors with --traditional-cpp. */
-#if __MINGW_GNUC_PREREQ (3, 3)
-#define __MINGW_ATTRIB_NONNULL(arg) __attribute__ ((__nonnull__ (arg)))
-#else
-#define __MINGW_ATTRIB_NONNULL(arg)
-#endif /* GNUC >= 3.3 */
-
-#if defined(UNDER_CE) && defined(__arm__)
-/* ARM Windows CE is not underscored. */
-# define __U(SYM) _ ## SYM
-# define __IMP(S) __imp_ ## S
-#elif defined(UNDER_CE) && defined(i386)
-/* i386 Windows CE versions are underscored. */
-# define __U(SYM) SYM
-# define __IMP(S) _imp__ ## S
-#else
-/* Desktop i386 Windows versions are underscored. */
-# define __U(SYM) SYM
-# define __IMP(S) _imp__ ## S
-#endif
-
-#if __MINGW_GNUC_PREREQ (3, 1)
-#define __MINGW_ATTRIB_DEPRECATED __attribute__ ((__deprecated__))
-#else
-#define __MINGW_ATTRIB_DEPRECATED
-#endif /* GNUC >= 3.1 */
-
-#if __MINGW_GNUC_PREREQ (3, 3)
-#define __MINGW_NOTHROW __attribute__ ((__nothrow__))
-#else
-#define __MINGW_NOTHROW
-#endif /* GNUC >= 3.3 */
-
-
-/* TODO: Mark (almost) all CRT functions as __MINGW_NOTHROW. This will
-allow GCC to optimize away some EH unwind code, at least in DW2 case. */
-
-#if defined __MSVCRT__ && !defined (__MSVCRT_VERSION__)
-/* High byte is the major version, low byte is the minor. */
-# define __MSVCRT_VERSION__ 0x0600
-#endif
-
-/* Activation of MinGW specific extended features:
- */
-#ifndef __USE_MINGW_ANSI_STDIO
-/*
- * If user didn't specify it explicitly...
- */
-# if defined __STRICT_ANSI__ || defined _ISOC99_SOURCE \
- || defined _POSIX_SOURCE || defined _POSIX_C_SOURCE \
- || defined _XOPEN_SOURCE || defined _XOPEN_SOURCE_EXTENDED \
- || defined _GNU_SOURCE || defined _BSD_SOURCE \
- || defined _SVID_SOURCE
- /*
- * but where any of these source code qualifiers are specified,
- * then assume ANSI I/O standards are preferred over Microsoft's...
- */
-# define __USE_MINGW_ANSI_STDIO 1
-# else
- /*
- * otherwise use whatever __MINGW_FEATURES__ specifies...
- */
-# define __USE_MINGW_ANSI_STDIO (__MINGW_FEATURES__ & __MINGW_ANSI_STDIO__)
-# endif
-#endif
-
-#endif /* __MINGW_H */
diff --git a/navit/support/libc/abort.c b/navit/support/libc/abort.c
deleted file mode 100644
index 11d405c5b..000000000
--- a/navit/support/libc/abort.c
+++ /dev/null
@@ -1,9 +0,0 @@
-#include <windows.h>
-
-/* Only needed on Windows CE. */
-
-void abort(void)
-{
- TerminateProcess (GetCurrentProcess(), 1);
- while (1); /* Kill 'noreturn function does return' warning. */
-}
diff --git a/navit/support/libc/bsearch.c b/navit/support/libc/bsearch.c
deleted file mode 100644
index 2708688ce..000000000
--- a/navit/support/libc/bsearch.c
+++ /dev/null
@@ -1,81 +0,0 @@
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/* <wince> */
-
-/* bsearch is in both stdlib.h and search.h. We include both
- to catch possible differences. */
-#include <stdlib.h>
-/* #include <search.h> */
-#include <stdint.h>
-
-/* </wince> */
-
-
-/*
- * Perform a binary search.
- *
- * The code below is a bit sneaky. After a comparison fails, we
- * divide the work in half by moving either left or right. If lim
- * is odd, moving left simply involves halving lim: e.g., when lim
- * is 5 we look at item 2, so we change lim to 2 so that we will
- * look at items 0 & 1. If lim is even, the same applies. If lim
- * is odd, moving right again involes halving lim, this time moving
- * the base up one item past p: e.g., when lim is 5 we change base
- * to item 3 and make lim 2 so that we will look at items 3 and 4.
- * If lim is even, however, we have to shrink it by one before
- * halving: e.g., when lim is 4, we still looked at item 2, so we
- * have to make lim 3, then halve, obtaining 1, so that we will only
- * look at item 3.
- */
-void *
-bsearch(key, base0, nmemb, size, compar)
- const void *key;
- const void *base0;
- size_t nmemb;
- size_t size;
- int (*compar)(const void *, const void *);
-{
- const char *base = base0;
- size_t lim;
- int cmp;
- const void *p;
-
- for (lim = nmemb; lim != 0; lim >>= 1) {
- p = base + (lim >> 1) * size;
- cmp = (*compar)(key, p);
- if (cmp == 0)
- return ((void *)(unsigned int *)p);
- if (cmp > 0) { /* key > p: move right */
- base = (const char *)p + size;
- lim--;
- } /* else move left */
- }
- return (NULL);
-}
diff --git a/navit/support/libc/calloc.c b/navit/support/libc/calloc.c
deleted file mode 100644
index 147ea73a4..000000000
--- a/navit/support/libc/calloc.c
+++ /dev/null
@@ -1,8 +0,0 @@
-void *
-calloc(int nelem, int size)
-{
- void *ret=malloc(nelem*size);
- if (ret)
- memset(ret, 0, nelem*size);
- return ret;
-}
diff --git a/navit/support/libc/chsize.c b/navit/support/libc/chsize.c
deleted file mode 100644
index 778949a46..000000000
--- a/navit/support/libc/chsize.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * chsize.c: _chsize and chsize implementations for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public
- * Domain. This file is a part of the mingw32ce package. No
- * warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> 24 Jun 2007
- *
- */
-
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
-int
-_chsize (int fd, long size)
-{
- DWORD cur;
- DWORD new;
- HANDLE h;
- BOOL ret;
-
- h = (HANDLE) fd;
- if (h == INVALID_HANDLE_VALUE)
- {
- SetLastError (ERROR_INVALID_PARAMETER);
- return -1;
- }
-
- cur = SetFilePointer (h, 0, NULL, FILE_CURRENT);
- if (cur == 0xffffffff)
- return -1;
-
- /* Move to where we want it. */
- new = SetFilePointer (h, size, NULL, FILE_BEGIN);
- if (new == 0xffffffff)
- return -1;
-
- /* And commit it as eof, effectivelly growing or shrinking. */
- ret = SetEndOfFile (h);
-
- SetFilePointer (h, cur, NULL, FILE_BEGIN);
-
- return ret ? 0 : -1;
-}
-
-int
-chsize (int fd, long size)
-{
- return _chsize (fd, size);
-}
diff --git a/navit/support/libc/close.c b/navit/support/libc/close.c
deleted file mode 100644
index 3b04734ce..000000000
--- a/navit/support/libc/close.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * close.c: close implementation for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-
-#include <windows.h>
-#include <unistd.h>
-
-int
-_close (int fildes)
-{
- if (CloseHandle ((HANDLE) fildes))
- return 0;
- return -1;
-}
-
-int
-close (int fildes)
-{
- return _close (fildes);
-}
diff --git a/navit/support/libc/errno.h b/navit/support/libc/errno.h
deleted file mode 100644
index 9b7104e89..000000000
--- a/navit/support/libc/errno.h
+++ /dev/null
@@ -1,72 +0,0 @@
-/**
- * errno.h
- * included from mingw32ce/../errno.h
- */
-
-#ifndef _ERRNO_2_H_
-#define _ERRNO_2_H_
-
-#ifndef RC_INVOKED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int errno;
-int* _errno(void);
-char *strerror(int num);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* Not RC_INVOKED */
-
-
-#define EPERM 1 /* Operation not permitted */
-#define ENOFILE 2 /* No such file or directory */
-#define ENOENT 2
-#define ESRCH 3 /* No such process */
-#define EINTR 4 /* Interrupted function call */
-#define EIO 5 /* Input/output error */
-#define ENXIO 6 /* No such device or address */
-#define E2BIG 7 /* Arg list too long */
-#define ENOEXEC 8 /* Exec format error */
-#define EBADF 9 /* Bad file descriptor */
-#define ECHILD 10 /* No child processes */
-#define EAGAIN 11 /* Resource temporarily unavailable */
-#define ENOMEM 12 /* Not enough space */
-#define EACCES 13 /* Permission denied */
-#define EFAULT 14 /* Bad address */
-/* 15 - Unknown Error */
-#define EBUSY 16 /* strerror reports "Resource device" */
-#define EEXIST 17 /* File exists */
-#define EXDEV 18 /* Improper link (cross-device link?) */
-#define ENODEV 19 /* No such device */
-#define ENOTDIR 20 /* Not a directory */
-#define EISDIR 21 /* Is a directory */
-#define EINVAL 22 /* Invalid argument */
-#define ENFILE 23 /* Too many open files in system */
-#define EMFILE 24 /* Too many open files */
-#define ENOTTY 25 /* Inappropriate I/O control operation */
-/* 26 - Unknown Error */
-#define EFBIG 27 /* File too large */
-#define ENOSPC 28 /* No space left on device */
-#define ESPIPE 29 /* Invalid seek (seek on a pipe?) */
-#define EROFS 30 /* Read-only file system */
-#define EMLINK 31 /* Too many links */
-#define EPIPE 32 /* Broken pipe */
-#define EDOM 33 /* Domain error (math functions) */
-#define ERANGE 34 /* Result too large (possibly too small) */
-/* 35 - Unknown Error */
-#define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */
-#define EDEADLK 36
-/* 37 - Unknown Error */
-#define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */
-#define ENOLCK 39 /* No locks available (46 in Cyg?) */
-#define ENOSYS 40 /* Function not implemented (88 in Cyg?) */
-#define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */
-#define EILSEQ 42 /* Illegal byte sequence */
-
-#endif /* Not _ERRNO_2_H_ */
-
diff --git a/navit/support/libc/fcntl.h b/navit/support/libc/fcntl.h
deleted file mode 100644
index 9bff9352a..000000000
--- a/navit/support/libc/fcntl.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * fcntl.h
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Access constants for _open. Note that the permissions constants are
- * in sys/stat.h (ick).
- *
- */
-#ifndef _FCNTL_H_
-#define _FCNTL_H_
-
-/* All the headers include this file. */
-#include <_mingw.h>
-
-/*
- * It appears that fcntl.h should include io.h for compatibility...
- */
-#include <io.h>
-
-/* Specifiy one of these flags to define the access mode. */
-#define _O_RDONLY 0
-#define _O_WRONLY 1
-#define _O_RDWR 2
-
-/* Mask for access mode bits in the _open flags. */
-#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR)
-
-#define _O_APPEND 0x0008 /* Writes will add to the end of the file. */
-
-#define _O_RANDOM 0x0010
-#define _O_SEQUENTIAL 0x0020
-#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing.
- * WARNING: Even if not created by _open! */
-#define _O_NOINHERIT 0x0080
-
-#define _O_CREAT 0x0100 /* Create the file if it does not exist. */
-#define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */
-#define _O_EXCL 0x0400 /* Open only if the file does not exist. */
-
-#define _O_SHORT_LIVED 0x1000
-
-/* NOTE: Text is the default even if the given _O_TEXT bit is not on. */
-#define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */
-#define _O_BINARY 0x8000 /* Input and output is not translated. */
-#define _O_RAW _O_BINARY
-
-#if (__MSVCRT_VERSION__ >= 0x0800)
-#define _O_WTEXT 0x10000
-#define _O_U16TEXT 0x20000
-#define _O_U8TEXT 0x40000
-#endif
-
-#ifndef _NO_OLDNAMES
-
-/* POSIX/Non-ANSI names for increased portability */
-#define O_RDONLY _O_RDONLY
-#define O_WRONLY _O_WRONLY
-#define O_RDWR _O_RDWR
-#define O_ACCMODE _O_ACCMODE
-#define O_APPEND _O_APPEND
-#define O_CREAT _O_CREAT
-#define O_TRUNC _O_TRUNC
-#define O_EXCL _O_EXCL
-#define O_TEXT _O_TEXT
-#define O_BINARY _O_BINARY
-#define O_TEMPORARY _O_TEMPORARY
-#define O_NOINHERIT _O_NOINHERIT
-#define O_SEQUENTIAL _O_SEQUENTIAL
-#define O_RANDOM _O_RANDOM
-
-#endif /* Not _NO_OLDNAMES */
-
-#endif /* Not _FCNTL_H_ */
diff --git a/navit/support/libc/getopt.h b/navit/support/libc/getopt.h
deleted file mode 100644
index 406bbf594..000000000
--- a/navit/support/libc/getopt.h
+++ /dev/null
@@ -1,111 +0,0 @@
-#ifndef __GETOPT_H__
-/*
- * getopt.h
- *
- * $Id: getopt.h,v 1.4 2009/01/04 17:35:36 keithmarshall Exp $
- *
- * Defines constants and function prototypes required to implement
- * the `getopt', `getopt_long' and `getopt_long_only' APIs.
- *
- * This file is part of the MinGW32 package set.
- *
- * Contributed by Keith Marshall <keithmarshall@users.sourceforge.net>
- *
- *
- * THIS SOFTWARE IS NOT COPYRIGHTED
- *
- * This source code is offered for use in the public domain. You may
- * use, modify or distribute it freely.
- *
- * This code is distributed in the hope that it will be useful but
- * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
- * DISCLAIMED. This includes but is not limited to warranties of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * $Revision: 1.4 $
- * $Author: keithmarshall $
- * $Date: 2009/01/04 17:35:36 $
- *
- */
-#define __GETOPT_H__
-
-/* All the headers include this file. */
-#include <_mingw.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int optind; /* index of first non-option in argv */
-extern int optopt; /* single option character, as parsed */
-extern int opterr; /* flag to enable built-in diagnostics... */
- /* (user may set to zero, to suppress) */
-
-extern char *optarg; /* pointer to argument of current option */
-
-extern int getopt( int, char * const [], const char * );
-
-#ifdef _BSD_SOURCE
-/*
- * BSD adds the non-standard `optreset' feature, for reinitialisation
- * of `getopt' parsing. We support this feature, for applications which
- * proclaim their BSD heritage, before including this header; however,
- * to maintain portability, developers are advised to avoid it.
- */
-# define optreset __mingw_optreset
-
-extern int optreset;
-#endif
-#ifdef __cplusplus
-}
-#endif
-/*
- * POSIX requires the `getopt' API to be specified in `unistd.h';
- * thus, `unistd.h' includes this header. However, we do not want
- * to expose the `getopt_long' or `getopt_long_only' APIs, when
- * included in this manner. Thus, close the standard __GETOPT_H__
- * declarations block, and open an additional __GETOPT_LONG_H__
- * specific block, only when *not* __UNISTD_H_SOURCED__, in which
- * to declare the extended API.
- */
-#endif /* !defined(__GETOPT_H__) */
-#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
-#define __GETOPT_LONG_H__
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct option /* specification for a long form option... */
-{
- const char *name; /* option name, without leading hyphens */
- int has_arg; /* does it take an argument? */
- int *flag; /* where to save its status, or NULL */
- int val; /* its associated status value */
-};
-
-enum /* permitted values for its `has_arg' field... */
-{
- no_argument = 0, /* option never takes an argument */
- required_argument, /* option always requires an argument */
- optional_argument /* option may take an argument */
-};
-
-extern int getopt_long( int, char * const [], const char *, const struct option *, int * );
-extern int getopt_long_only( int, char * const [], const char *, const struct option *, int * );
-/*
- * Previous MinGW implementation had...
- */
-#ifndef HAVE_DECL_GETOPT
-/*
- * ...for the long form API only; keep this for compatibility.
- */
-# define HAVE_DECL_GETOPT 1
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
-/* $RCSfile: getopt.h,v $Revision: 1.4 $: end of file */
diff --git a/navit/support/libc/gmtime.c b/navit/support/libc/gmtime.c
deleted file mode 100644
index aa33e0906..000000000
--- a/navit/support/libc/gmtime.c
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * gmtime.c: gmtime implementation for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-
-#include "timeutil.h"
-
-struct tm *
-gmtime(const time_t *t)
-{
- FILETIME f;
- SYSTEMTIME s;
- static struct tm tms;
-
- __time_t_to_FILETIME (*t, &f);
- FileTimeToSystemTime (&f, &s);
- __SYSTEMTIME_to_tm (&s, &tms);
- return &tms;
-}
diff --git a/navit/support/libc/io.h b/navit/support/libc/io.h
deleted file mode 100644
index 9c3da7c5d..000000000
--- a/navit/support/libc/io.h
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * io.h
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * System level I/O functions and types.
- *
- */
-#ifndef _IO_H_
-#define _IO_H_
-
-/* All the headers include this file. */
-#include <_mingw.h>
-
-/* MSVC's io.h contains the stuff from dir.h, so I will too.
- * NOTE: This also defines off_t, the file offset type, through
- * an inclusion of sys/types.h */
-
-#include <sys/types.h> /* To get time_t. */
-
-/*
- * Attributes of files as returned by _findfirst et al.
- */
-#define _A_NORMAL 0x00000000
-#define _A_RDONLY 0x00000001
-#define _A_HIDDEN 0x00000002
-#define _A_SYSTEM 0x00000004
-#define _A_VOLID 0x00000008
-#define _A_SUBDIR 0x00000010
-#define _A_ARCH 0x00000020
-
-
-#ifndef RC_INVOKED
-
-#ifndef _INTPTR_T_DEFINED
-#define _INTPTR_T_DEFINED
-#ifdef _WIN64
- typedef __int64 intptr_t;
-#else
- typedef int intptr_t;
-#endif
-#endif
-
-#ifndef _FSIZE_T_DEFINED
-typedef unsigned long _fsize_t;
-#define _FSIZE_T_DEFINED
-#endif
-
-/*
- * The maximum length of a file name. You should use GetVolumeInformation
- * instead of this constant. But hey, this works.
- * Also defined in stdio.h.
- */
-#ifndef FILENAME_MAX
-#define FILENAME_MAX (260)
-#endif
-
-/*
- * The following structure is filled in by _findfirst or _findnext when
- * they succeed in finding a match.
- */
-#ifndef _FINDDATA_T_DEFINED
-struct _finddata_t
-{
- unsigned attrib; /* Attributes, see constants above. */
- time_t time_create;
- time_t time_access; /* always midnight local time */
- time_t time_write;
- _fsize_t size;
- char name[FILENAME_MAX]; /* may include spaces. */
-};
-
-#ifndef __COREDLL__
-
-struct _finddatai64_t {
- unsigned attrib;
- time_t time_create;
- time_t time_access;
- time_t time_write;
- __int64 size;
- char name[FILENAME_MAX];
-};
-
-#if __MSVCRT_VERSION__ >= 0x0601
-struct __finddata64_t {
- unsigned attrib;
- __time64_t time_create;
- __time64_t time_access;
- __time64_t time_write;
-/* 8 bytes are returned so it can't be _fsize_t */
- __int64 size;
- char name[FILENAME_MAX];
-};
-#endif
-
-#endif
-
-#define _FINDDATA_T_DEFINED
-#endif /* _FINDDATA_T_DEFINED */
-
-#ifndef _WFINDDATA_T_DEFINED
-struct _wfinddata_t {
- unsigned attrib;
- time_t time_create; /* -1 for FAT file systems */
- time_t time_access; /* -1 for FAT file systems */
- time_t time_write;
- _fsize_t size;
- wchar_t name[FILENAME_MAX]; /* may include spaces. */
-};
-
-#ifndef __COREDLL__
-
-struct _wfinddatai64_t {
- unsigned attrib;
- time_t time_create;
- time_t time_access;
- time_t time_write;
- __int64 size;
- wchar_t name[FILENAME_MAX];
-};
-
-#if __MSVCRT_VERSION__ >= 0x0601
-struct __wfinddata64_t {
- unsigned attrib;
- __time64_t time_create;
- __time64_t time_access;
- __time64_t time_write;
-/* 8 bytes are returned so it can't be _fsize_t */
- __int64 size;
- wchar_t name[FILENAME_MAX];
-};
-#endif
-
-#endif /* __COREDLL__ */
-
-#define _WFINDDATA_T_DEFINED
-#endif
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * Functions for searching for files. _findfirst returns -1 if no match
- * is found. Otherwise it returns a handle to be used in _findnext and
- * _findclose calls. _findnext also returns -1 if no match could be found,
- * and 0 if a match was found. Call _findclose when you are finished.
- */
-/* FIXME: Should these all use intptr_t, as per recent MSDN docs? */
-_CRTIMP long __cdecl __MINGW_NOTHROW _findfirst (const char*, struct _finddata_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _findnext (long, struct _finddata_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _findclose (long);
-
-#ifndef UNDER_CE
-_CRTIMP int __cdecl __MINGW_NOTHROW _chdir (const char*);
-_CRTIMP char* __cdecl __MINGW_NOTHROW _getcwd (char*, int);
-_CRTIMP char* __cdecl __MINGW_NOTHROW _mktemp (char*);
-#endif
-_CRTIMP int __cdecl __MINGW_NOTHROW _mkdir (const char*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _rmdir (const char*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _chmod (const char*, int);
-
-#ifdef __MSVCRT__
-_CRTIMP __int64 __cdecl __MINGW_NOTHROW _filelengthi64(int);
-_CRTIMP long __cdecl __MINGW_NOTHROW _findfirsti64(const char*, struct _finddatai64_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _findnexti64(long, struct _finddatai64_t*);
-_CRTIMP __int64 __cdecl __MINGW_NOTHROW _lseeki64(int, __int64, int);
-_CRTIMP __int64 __cdecl __MINGW_NOTHROW _telli64(int);
-/* These require newer versions of msvcrt.dll (6.1 or higher). */
-#if __MSVCRT_VERSION__ >= 0x0601
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findfirst64(const char*, struct __finddata64_t*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _findnext64(intptr_t, struct __finddata64_t*);
-#endif /* __MSVCRT_VERSION__ >= 0x0601 */
-#ifndef __NO_MINGW_LFS
-__CRT_INLINE off64_t lseek64 (int, off64_t, int);
-__CRT_INLINE off64_t lseek64 (int fd, off64_t offset, int whence)
-{
- return _lseeki64(fd, (__int64) offset, whence);
-}
-#endif
-
-#endif /* __MSVCRT__ */
-
-#ifndef _NO_OLDNAMES
-
-#ifndef _UWIN
-#ifndef UNDER_CE
-_CRTIMP int __cdecl __MINGW_NOTHROW chdir (const char*);
-_CRTIMP char* __cdecl __MINGW_NOTHROW getcwd (char*, int);
-_CRTIMP char* __cdecl __MINGW_NOTHROW mktemp (char*);
-#endif
-_CRTIMP int __cdecl __MINGW_NOTHROW mkdir (const char*);
-_CRTIMP int __cdecl __MINGW_NOTHROW rmdir (const char*);
-_CRTIMP int __cdecl __MINGW_NOTHROW chmod (const char*, int);
-#endif /* _UWIN */
-
-#endif /* Not _NO_OLDNAMES */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* Not RC_INVOKED */
-
-/* TODO: Maximum number of open handles has not been tested, I just set
- * it the same as FOPEN_MAX. */
-#define HANDLE_MAX FOPEN_MAX
-
-/* Some defines for _access nAccessMode (MS doesn't define them, but
- * it doesn't seem to hurt to add them). */
-#define F_OK 0 /* Check for file existence */
-/* Well maybe it does hurt. On newer versions of MSVCRT, an access mode
- of 1 causes invalid parameter error. */
-#define X_OK 1 /* MS access() doesn't check for execute permission. */
-#define W_OK 2 /* Check for write permission */
-#define R_OK 4 /* Check for read permission */
-
-#ifndef RC_INVOKED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-_CRTIMP int __cdecl __MINGW_NOTHROW _access (const char*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _chsize (int, long);
-_CRTIMP int __cdecl __MINGW_NOTHROW _close (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _commit(int);
-
-/* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80),
- * the "owner write permission" bit (on FAT). */
-_CRTIMP int __cdecl __MINGW_NOTHROW _creat (const char*, int);
-
-_CRTIMP int __cdecl __MINGW_NOTHROW _dup (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _dup2 (int, int);
-_CRTIMP long __cdecl __MINGW_NOTHROW _filelength (int);
-_CRTIMP long __cdecl __MINGW_NOTHROW _get_osfhandle (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _isatty (int);
-
-/* In a very odd turn of events this function is excluded from those
- * files which define _STREAM_COMPAT. This is required in order to
- * build GNU libio because of a conflict with _eof in streambuf.h
- * line 107. Actually I might just be able to change the name of
- * the enum member in streambuf.h... we'll see. TODO */
-#ifndef _STREAM_COMPAT
-_CRTIMP int __cdecl __MINGW_NOTHROW _eof (int);
-#endif
-
-/* LK_... locking commands defined in sys/locking.h. */
-_CRTIMP int __cdecl __MINGW_NOTHROW _locking (int, int, long);
-
-_CRTIMP long __cdecl __MINGW_NOTHROW _lseek (int, long, int);
-
-/* Optional third argument is unsigned unPermissions. */
-_CRTIMP int __cdecl __MINGW_NOTHROW _open (const char*, int, ...);
-
-#ifndef __COREDLL__
-_CRTIMP int __cdecl __MINGW_NOTHROW _open_osfhandle (long, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _pipe (int *, unsigned int, int);
-#endif /* __COREDLL__ */
-_CRTIMP int __cdecl __MINGW_NOTHROW _read (int, void*, unsigned int);
-#ifndef __COREDLL__
-_CRTIMP int __cdecl __MINGW_NOTHROW _setmode (int, int);
-/* MS puts remove & rename (but not wide versions) in io.h as well
- as in stdio.h. */
-_CRTIMP int __cdecl __MINGW_NOTHROW remove (const char*);
-#endif
-_CRTIMP int __cdecl __MINGW_NOTHROW rename (const char*, const char*);
-#ifndef __COREDLL__
-/* SH_... flags for nShFlags defined in share.h
- * Optional fourth argument is unsigned unPermissions */
-_CRTIMP int __cdecl __MINGW_NOTHROW _sopen (const char*, int, int, ...);
-
-_CRTIMP long __cdecl __MINGW_NOTHROW _tell (int);
-/* Should umask be in sys/stat.h and/or sys/types.h instead? */
-_CRTIMP int __cdecl __MINGW_NOTHROW _umask (int);
-#endif /* __COREDLL__ */
-_CRTIMP int __cdecl __MINGW_NOTHROW _unlink (const char*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _write (int, const void*, unsigned int);
-
-/* Wide character versions. Also declared in wchar.h. */
-/* Not in crtdll.dll */
-#if !defined (_WIO_DEFINED)
-#if defined (__MSVCRT__)
-_CRTIMP int __cdecl __MINGW_NOTHROW _waccess(const wchar_t*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wchmod(const wchar_t*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wcreat(const wchar_t*, int);
-#endif
-#if defined (__MSVCRT__) || defined (__COREDLL__)
-_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirst(const wchar_t*, struct _wfinddata_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnext(long, struct _wfinddata_t *);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wopen(const wchar_t*, int, ...);
-#endif
-#if defined (__MSVCRT__)
-_CRTIMP int __cdecl __MINGW_NOTHROW _wunlink(const wchar_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wsopen(const wchar_t*, int, int, ...);
-_CRTIMP wchar_t * __cdecl __MINGW_NOTHROW _wmktemp(wchar_t*);
-_CRTIMP long __cdecl __MINGW_NOTHROW _wfindfirsti64(const wchar_t*, struct _wfinddatai64_t*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wfindnexti64(long, struct _wfinddatai64_t*);
-#if __MSVCRT_VERSION__ >= 0x0601
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindfirst64(const wchar_t*, struct __wfinddata64_t*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _wfindnext64(intptr_t, struct __wfinddata64_t*);
-#endif
-#endif /* defined (__MSVCRT__) */
-#define _WIO_DEFINED
-#endif /* _WIO_DEFINED */
-
-#ifndef _NO_OLDNAMES
-/*
- * Non-underscored versions of non-ANSI functions to improve portability.
- * These functions live in libmoldname.a.
- */
-
-#ifndef _UWIN
-_CRTIMP int __cdecl __MINGW_NOTHROW access (const char*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW chsize (int, long );
-_CRTIMP int __cdecl __MINGW_NOTHROW close (int);
-#ifndef __COREDLL__
-_CRTIMP int __cdecl __MINGW_NOTHROW creat (const char*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW dup (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW dup2 (int, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW eof (int);
-_CRTIMP long __cdecl __MINGW_NOTHROW filelength (int);
-#endif /* __COREDLL__ */
-_CRTIMP int __cdecl __MINGW_NOTHROW isatty (int);
-_CRTIMP long __cdecl __MINGW_NOTHROW lseek (int, long, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW open (const char*, int, ...);
-_CRTIMP int __cdecl __MINGW_NOTHROW read (int, void*, unsigned int);
-#ifndef __COREDLL__
-_CRTIMP int __cdecl __MINGW_NOTHROW setmode (int, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW sopen (const char*, int, int, ...);
-_CRTIMP long __cdecl __MINGW_NOTHROW tell (int);
-_CRTIMP int __cdecl __MINGW_NOTHROW umask (int);
-#endif /* __COREDLL__ */
-_CRTIMP int __cdecl __MINGW_NOTHROW unlink (const char*);
-_CRTIMP int __cdecl __MINGW_NOTHROW write (int, const void*, unsigned int);
-#endif /* _UWIN */
-
-#ifdef __USE_MINGW_ACCESS
-/* Old versions of MSVCRT access() just ignored X_OK, while the version
- shipped with Vista, returns an error code. This will restore the
- old behaviour */
-static inline int __mingw_access (const char* __fname, int __mode)
- { return _access (__fname, __mode & ~X_OK); }
-#define access(__f,__m) __mingw_access (__f, __m)
-#endif
-
-/* Wide character versions. Also declared in wchar.h. */
-/* Where do these live? Not in libmoldname.a nor in libmsvcrt.a */
-#if 0
-int waccess(const wchar_t *, int);
-int wchmod(const wchar_t *, int);
-int wcreat(const wchar_t *, int);
-long wfindfirst(wchar_t *, struct _wfinddata_t *);
-int wfindnext(long, struct _wfinddata_t *);
-int wunlink(const wchar_t *);
-int wrename(const wchar_t *, const wchar_t *);
-int wopen(const wchar_t *, int, ...);
-int wsopen(const wchar_t *, int, int, ...);
-wchar_t * wmktemp(wchar_t *);
-#endif
-
-#endif /* Not _NO_OLDNAMES */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* Not RC_INVOKED */
-
-#endif /* _IO_H_ not defined */
diff --git a/navit/support/libc/libc.c b/navit/support/libc/libc.c
deleted file mode 100644
index a71f32994..000000000
--- a/navit/support/libc/libc.c
+++ /dev/null
@@ -1,254 +0,0 @@
-#include "locale.h"
-#include <stdlib.h>
-#include <string.h>
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef PLATFORM_WINDOWS
-#include "windows.h"
-#endif
-
-int errno;
-
-#define MAXENV 32
-static char *envnames[MAXENV];
-static char *envvars[MAXENV];
-
-static void cleanup_libc(void)
-#ifndef _MSC_VER
-__attribute__((destructor))
-#endif
-;
-static void cleanup_libc(void)
-{
- int i;
- for (i=0; i <MAXENV; i++) {
- if (envnames[i])
- free(envnames[i]);
- if (envvars[i])
- free(envvars[i]);
- }
-}
-
-char *
-getenv(const char *name)
-{
- int i;
- for (i=0; i < MAXENV; i++) {
- if (envnames[i] && !strcmp(envnames[i], name))
- return envvars[i];
- }
- return NULL;
-}
-
-int
-setenv(const char *name, const char *value, int overwrite)
-{
- int i;
- char *val;
- for (i=0; i < MAXENV; i++) {
- if (envnames[i] && !strcmp(envnames[i], name)) {
- if (overwrite) {
- val = g_strdup(value);
- if (!val)
- return -1;
- if (envvars[i])
- free(envvars[i]);
- envvars[i] = val;
- }
- return 0;
- }
- }
- for (i=0; i < MAXENV; i++) {
- if (!envnames[i]) {
- envnames[i] = g_strdup(name);
- envvars[i] = g_strdup(value);
- if (!envnames[i] || !envvars[i]) {
- if (envnames[i])
- free(envnames[i]);
- if (envvars[i])
- free(envvars[i]);
- envnames[i] = NULL;
- envvars[i] = NULL;
- return -1;
- }
- return 0;
- }
- }
- return -1;
-}
-
-int unsetenv(const char *name)
-{
- int i;
- for (i=0; i < MAXENV; i++) {
- if (envnames[i] && !strcmp(envnames[i], name)) {
- free(envnames[i]);
- envnames[i] = NULL;
- if (envvars[i])
- free(envvars[i]);
- envvars[i] = NULL;
- }
- }
- return 0;
-}
-
-char *
-getcwd(char *buf, int size)
-{
- return "dummy";
-}
-
-char *
-getwd(char *buf)
-{
- return "dummy";
-}
-
-char *strtok_r(char *str, const char *delim, char **saveptr)
-{
- return strtok(str, delim);
-}
-
-void
-perror(const char *x)
-{
-}
-
-void
-raise(int signal)
-{
-}
-
-void *
-popen(void)
-{
- return 0;
-}
-
-int pclose(FILE *stream)
-{
- return 0;
-}
-
-void
-rewind(void)
-{
-}
-
-int
-GetThreadLocale(void)
-{
- return 0;
-}
-
-int signal(int signum, int handler)
-{
- return 0;
-}
-
-char * setlocale ( int category, const char * locale )
-{
- return 0;
-}
-
-static struct lconv localedata={"."};
-
-struct lconv *
-localeconv(void)
-{
- return &localedata;
-}
-
-unsigned int
-alarm(unsigned int seconds)
-{
- return 0;
-}
-
-char *
-strerror(int num)
-{
- return "unknown";
-}
-
-#ifdef _MSC_VER
-
-size_t strftime (char *s, size_t maxsize, const char *format, const struct tm *tp)
-{
- return 0;
-}
-
-__int64 _lseeki64(int FileHandle, __int64 Offset, int Origin)
-{
- return 0;
-}
-
-int * _get_osfhandle(int FileHandle)
-{
- return 0;
-}
-
-#ifdef _MSC_VER
-
-HANDLE FindFirstFileA(char* pFileName, LPWIN32_FIND_DATAA pFindFileData)
-{
- HANDLE hRetVal = INVALID_HANDLE_VALUE;
- WIN32_FIND_DATAW wFindFileData;
- wchar_t wFileName[MAX_PATH];
-
- if (MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, pFileName, -1, wFileName, MAX_PATH) != 0)
- {
- hRetVal = FindFirstFileW(wFileName, &wFindFileData);
-
- pFindFileData->dwFileAttributes = wFindFileData.dwFileAttributes;
- pFindFileData->ftCreationTime = wFindFileData.ftCreationTime;
- pFindFileData->ftLastAccessTime = wFindFileData.ftLastAccessTime;
- pFindFileData->ftLastWriteTime = wFindFileData.ftLastWriteTime;
- pFindFileData->nFileSizeHigh = wFindFileData.nFileSizeHigh;
- pFindFileData->nFileSizeLow = wFindFileData.nFileSizeLow;
-
- if (WideCharToMultiByte(CP_UTF8, WC_SEPCHARS, wFileName, -1, pFindFileData->cFileName, MAX_PATH, NULL, NULL) == 0)
- {
- hRetVal = INVALID_HANDLE_VALUE;
- }
- }
-
- return hRetVal;
-}
-
-BOOL FindNextFileA(HANDLE hFindFile, LPWIN32_FIND_DATAA pFindFileData)
-{
- BOOL boRetVal = FALSE;
- WIN32_FIND_DATAW wFindFileData;
-
- wFindFileData.dwFileAttributes = pFindFileData->dwFileAttributes;
- wFindFileData.ftCreationTime = pFindFileData->ftCreationTime;
- wFindFileData.ftLastAccessTime = pFindFileData->ftLastAccessTime;
- wFindFileData.ftLastWriteTime = pFindFileData->ftLastWriteTime;
- wFindFileData.nFileSizeHigh = pFindFileData->nFileSizeHigh;
- wFindFileData.nFileSizeLow = pFindFileData->nFileSizeLow;
-
- if (MultiByteToWideChar(CP_UTF8, MB_PRECOMPOSED, pFindFileData->cFileName, -1, wFindFileData.cFileName, MAX_PATH) != 0)
- {
- boRetVal = FindNextFileW(hFindFile, &wFindFileData);
-
- pFindFileData->dwFileAttributes = wFindFileData.dwFileAttributes;
- pFindFileData->ftCreationTime = wFindFileData.ftCreationTime;
- pFindFileData->ftLastAccessTime = wFindFileData.ftLastAccessTime;
- pFindFileData->ftLastWriteTime = wFindFileData.ftLastWriteTime;
- pFindFileData->nFileSizeHigh = wFindFileData.nFileSizeHigh;
- pFindFileData->nFileSizeLow = wFindFileData.nFileSizeLow;
-
- if (WideCharToMultiByte(CP_UTF8, WC_SEPCHARS, wFindFileData.cFileName, -1, pFindFileData->cFileName, MAX_PATH, NULL, NULL) == 0)
- {
- boRetVal = FALSE;
- }
- }
-
- return boRetVal;
-}
-
-#endif
-
-#endif
diff --git a/navit/support/libc/libc.h b/navit/support/libc/libc.h
deleted file mode 100644
index 4125fa735..000000000
--- a/navit/support/libc/libc.h
+++ /dev/null
@@ -1,51 +0,0 @@
-#ifndef _SUPPORT_LIBC_H
-#define _SUPPORT_LIBC_H 1
-
-
-void *popen(const char *command, const char *type);
-
-int pclose(void *stream);
-
-char* getenv (const char*);
-
-int setenv(const char *name, const char *value, int overwrite);
-
-void raise(int signal);
-
-char * setlocale ( int category, const char * locale );
-
-struct lconv *localeconv(void);
-
-int signal(int signum, void *handler);
-
-#ifdef _MSC_VER
-
-#define GetWindowLongPtr GetWindowLong
-#define SetWindowLongPtr SetWindowLong
-
-#define DWLP_MSGRESULT 0
-#define DWLP_DLGPROC DWLP_MSGRESULT + sizeof(LRESULT)
-#define DWLP_USER DWLP_DLGPROC + sizeof(DLGPROC)
-
-struct tm *localtime (const time_t *t);
-
-size_t strftime (char *s, size_t maxsize, const char *format, const struct tm *tp);
-
-#define mkdir _mkdir
-#define open _open
-#define close _close
-#define read _read
-#define write _write
-#define lseek _lseek
-#define vsnprintf _vsnprintf
-
-#else
-
-#ifndef _GNU_SOURCE
-# define _GNU_SOURCE 1
-#endif
-
-#endif
-
-
-#endif
diff --git a/navit/support/libc/libc_init.c b/navit/support/libc/libc_init.c
deleted file mode 100644
index 32be387da..000000000
--- a/navit/support/libc/libc_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "plugin.h"
-
-void
-plugin_init(void)
-{
-}
diff --git a/navit/support/libc/locale.h b/navit/support/libc/locale.h
deleted file mode 100644
index 320c3ac2d..000000000
--- a/navit/support/libc/locale.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef _LOCALE_H
-#define _LOCALE_H 1
-
-#ifndef SUBLANG_BENGALI_BANGLADESH
-#define SUBLANG_BENGALI_BANGLADESH 0x02
-#endif
-#ifndef SUBLANG_PUNJABI_PAKISTAN
-#define SUBLANG_PUNJABI_PAKISTAN 0x02
-#endif
-#ifndef SUBLANG_ROMANIAN_MOLDOVA
-#define SUBLANG_ROMANIAN_MOLDOVA 0x02
-#endif
-struct lconv {
- char *decimal_point;
-};
-
-#define LC_ALL 1
-#define LC_NUMERIC 2
-#ifndef PATH_MAX
-#define PATH_MAX 1024
-#endif
-#endif
diff --git a/navit/support/libc/localtime.c b/navit/support/libc/localtime.c
deleted file mode 100644
index 245b51c5a..000000000
--- a/navit/support/libc/localtime.c
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * localtime.c: localtime implementation for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-
-#include "timeutil.h"
-
-struct tm *
-localtime(const time_t *timer)
-{
- SYSTEMTIME ss, ls, s;
- FILETIME sf, lf, f;
- long long t, diff;
-
- static struct tm tms;
-
- GetSystemTime (&ss);
- GetLocalTime (&ls);
-
- SystemTimeToFileTime (&ss, &sf);
- SystemTimeToFileTime (&ls, &lf);
-
- diff = __FILETIME_to_ll (&sf) - __FILETIME_to_ll (&lf);
-
- __time_t_to_FILETIME (*timer, &f);
- t = __FILETIME_to_ll (&f) - diff;
- __ll_to_FILETIME (t, &f);
- FileTimeToSystemTime (&f, &s);
- __SYSTEMTIME_to_tm (&s, &tms);
-
- return &tms;
-}
diff --git a/navit/support/libc/lseek.c b/navit/support/libc/lseek.c
deleted file mode 100644
index 4600c0d11..000000000
--- a/navit/support/libc/lseek.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * lseek.c: lseek implementation for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-
-#include <windows.h>
-#include <unistd.h>
-
-long
-_lseek (int fildes, long offset, int whence)
-{
- DWORD mode;
- switch (whence)
- {
- case SEEK_SET:
- mode = FILE_BEGIN;
- break;
- case SEEK_CUR:
- mode = FILE_CURRENT;
- break;
- case SEEK_END:
- mode = FILE_END;
- break;
- default:
- /* Specify an invalid mode so SetFilePointer catches it. */
- mode = (DWORD)-1;
- }
- return (long) SetFilePointer ((HANDLE) fildes, offset, NULL, mode);
-}
-
-long
-lseek (int fildes, long offset, int whence)
-{
- return _lseek (fildes, offset, whence);
-}
diff --git a/navit/support/libc/math.h b/navit/support/libc/math.h
deleted file mode 100644
index e85a89455..000000000
--- a/navit/support/libc/math.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#define M_E 2.7182818284590452354
-#define M_LOG2E 1.4426950408889634074
-#define M_LOG10E 0.43429448190325182765
-#define M_LN2 0.69314718055994530942
-#define M_LN10 2.30258509299404568402
-#define M_PI 3.14159265358979323846
-#define M_PI_2 1.57079632679489661923
-#define M_PI_4 0.78539816339744830962
-#define M_1_PI 0.31830988618379067154
-#define M_2_PI 0.63661977236758134308
-#define M_2_SQRTPI 1.12837916709551257390
-#define M_SQRT2 1.41421356237309504880
-#define M_SQRT1_2 0.70710678118654752440
diff --git a/navit/support/libc/mkdir.c b/navit/support/libc/mkdir.c
deleted file mode 100644
index ae8d21d85..000000000
--- a/navit/support/libc/mkdir.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * mkdir.c: mkdir implementation for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public
- * Domain. This file is a part of the mingw32ce package. No
- * warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> 24 Jun 2007
- *
- */
-
-#include <windows.h>
-#include <io.h>
-
-int
-_mkdir (const char *dirname)
-{
- wchar_t dirnamew[MAX_PATH];
- mbstowcs (dirnamew, dirname, MAX_PATH);
- if (!CreateDirectoryW (dirnamew, NULL))
- return -1;
- return 0;
-}
-
-int
-mkdir (const char *dirname)
-{
- return _mkdir (dirname);
-}
diff --git a/navit/support/libc/mktime.c b/navit/support/libc/mktime.c
deleted file mode 100644
index bd34fbf61..000000000
--- a/navit/support/libc/mktime.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * mktime.c: mktime implementation for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-
-#include "timeutil.h"
-
-time_t
-mktime (struct tm *pt)
-{
- SYSTEMTIME ss, ls, s;
- FILETIME sf, lf, f;
- long long diff;
-
- GetSystemTime (&ss);
- GetLocalTime (&ls);
- SystemTimeToFileTime (&ss, &sf);
- SystemTimeToFileTime (&ls, &lf);
-
- diff = __FILETIME_to_ll (&lf) - __FILETIME_to_ll (&sf);
- diff /= _onesec_in100ns;
-
- __tm_to_SYSTEMTIME (pt, &s);
- SystemTimeToFileTime (&s, &f);
- return __FILETIME_to_time_t (&f) - (time_t)diff;
-}
diff --git a/navit/support/libc/open.c b/navit/support/libc/open.c
deleted file mode 100644
index 210281706..000000000
--- a/navit/support/libc/open.c
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * open.c: open, _open and_wopen implementations for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-
-#include <windows.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-
-static int
-vwopen (const wchar_t *wpath, int oflag, va_list ap)
-{
- DWORD fileaccess;
- DWORD fileshare;
- DWORD filecreate;
- DWORD fileattrib;
- HANDLE hnd;
-
- switch (oflag & (O_RDONLY | O_WRONLY | O_RDWR))
- {
- case O_RDONLY:
- fileaccess = GENERIC_READ;
- break;
- case O_WRONLY:
- fileaccess = GENERIC_WRITE;
- break;
- case O_RDWR:
- fileaccess = GENERIC_READ | GENERIC_WRITE;
- break;
- default:
- return -1;
- }
-
- switch (oflag & (O_CREAT | O_EXCL | O_TRUNC))
- {
- case 0:
- case O_EXCL: /* ignore EXCL w/o CREAT */
- filecreate = OPEN_EXISTING;
- break;
- case O_CREAT:
- filecreate = OPEN_ALWAYS;
- break;
- case O_CREAT | O_EXCL:
- case O_CREAT | O_TRUNC | O_EXCL:
- filecreate = CREATE_NEW;
- break;
-
- case O_TRUNC:
- case O_TRUNC | O_EXCL: /* ignore EXCL w/o CREAT */
- filecreate = TRUNCATE_EXISTING;
- break;
- case O_CREAT | O_TRUNC:
- filecreate = CREATE_ALWAYS;
- break;
- default:
- /* this can't happen ... all cases are covered */
- return -1;
- }
-
- fileshare = 0;
- if (oflag & O_CREAT)
- {
- int pmode = va_arg (ap, int);
- if ((pmode & S_IREAD) == S_IREAD)
- fileshare |= FILE_SHARE_READ;
- if ((pmode & S_IWRITE) == S_IWRITE)
- fileshare |= FILE_SHARE_WRITE;
- }
-
- fileattrib = FILE_ATTRIBUTE_NORMAL;
-
- hnd = CreateFileW (wpath, fileaccess, fileshare, NULL, filecreate,
- fileattrib, NULL);
- if (hnd == INVALID_HANDLE_VALUE)
- return -1;
-
- if (oflag & O_APPEND)
- SetFilePointer (hnd, 0, NULL, FILE_END);
-
- return (int) hnd;
-}
-
-static int
-vopen (const char *path, int oflag, va_list ap)
-{
- wchar_t wpath[MAX_PATH];
-
- size_t path_len = strlen (path);
- if (path_len >= MAX_PATH)
- return -1;
-
- mbstowcs (wpath, path, path_len + 1);
-
- return vwopen (wpath, oflag, ap);
-}
-
-int
-_open (const char *path, int oflag, ...)
-{
- va_list ap;
- int ret;
- va_start (ap, oflag);
- ret = vopen (path, oflag, ap);
- va_end (ap);
- return ret;
-}
-
-int
-open (const char *path, int oflag, ...)
-{
- va_list ap;
- int ret;
- va_start (ap, oflag);
- ret = vopen (path, oflag, ap);
- va_end (ap);
- return ret;
-}
-
-int
-_wopen (const wchar_t *path, int oflag, ...)
-{
- va_list ap;
- int ret;
- va_start (ap, oflag);
- ret = vwopen (path, oflag, ap);
- va_end (ap);
- return ret;
-}
diff --git a/navit/support/libc/process.h b/navit/support/libc/process.h
deleted file mode 100644
index ecd67a555..000000000
--- a/navit/support/libc/process.h
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * process.h
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Function calls for spawning child processes.
- *
- */
-
-#ifndef _PROCESS_H_
-#define _PROCESS_H_
-#if 0
-
-/* All the headers include this file. */
-#include <_mingw.h>
-
-#include <sys/types.h> /* For _pid_t and pid_t. */
-#include <stdint.h> /* For intptr_t. */
-/*
- * Constants for cwait actions.
- * Obsolete for Win32.
- */
-#define _WAIT_CHILD 0
-#define _WAIT_GRANDCHILD 1
-
-#ifndef _NO_OLDNAMES
-#define WAIT_CHILD _WAIT_CHILD
-#define WAIT_GRANDCHILD _WAIT_GRANDCHILD
-#endif /* Not _NO_OLDNAMES */
-
-/*
- * Mode constants for spawn functions.
- */
-#define _P_WAIT 0
-#define _P_NOWAIT 1
-#define _P_OVERLAY 2
-#define _OLD_P_OVERLAY _P_OVERLAY
-#define _P_NOWAITO 3
-#define _P_DETACH 4
-
-#ifndef _NO_OLDNAMES
-#define P_WAIT _P_WAIT
-#define P_NOWAIT _P_NOWAIT
-#define P_OVERLAY _P_OVERLAY
-#define OLD_P_OVERLAY _OLD_P_OVERLAY
-#define P_NOWAITO _P_NOWAITO
-#define P_DETACH _P_DETACH
-#endif /* Not _NO_OLDNAMES */
-
-
-#ifndef RC_INVOKED
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef __COREDLL__
-
-_CRTIMP void __cdecl __MINGW_NOTHROW _cexit(void);
-_CRTIMP void __cdecl __MINGW_NOTHROW _c_exit(void);
-
-_CRTIMP int __cdecl __MINGW_NOTHROW _cwait (int*, _pid_t, int);
-
-_CRTIMP _pid_t __cdecl __MINGW_NOTHROW _getpid(void);
-
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execl (const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execle (const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execlp (const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execlpe (const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execv (const char*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execve (const char*, const char* const*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execvp (const char*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _execvpe (const char*, const char* const*, const char* const*);
-
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnl (int, const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnle (int, const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnlp (int, const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnlpe (int, const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnv (int, const char*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnve (int, const char*, const char* const*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnvp (int, const char*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW _spawnvpe (int, const char*, const char* const*, const char* const*);
-
-#endif /* !__COREDLL__*/
-
-/*
- * The functions _beginthreadex and _endthreadex are not provided by CRTDLL.
- * They are provided by MSVCRT.
- *
- * NOTE: Apparently _endthread calls CloseHandle on the handle of the thread,
- * making for race conditions if you are not careful. Basically you have to
- * make sure that no-one is going to do *anything* with the thread handle
- * after the thread calls _endthread or returns from the thread function.
- *
- * NOTE: No old names for these functions. Use the underscore.
- */
-#if defined (__MSVCRT__) || defined (__CRTDLL__)
-_CRTIMP unsigned long __cdecl __MINGW_NOTHROW
- _beginthread (void (*)(void *), unsigned, void*);
-_CRTIMP void __cdecl __MINGW_NOTHROW _endthread (void);
-#endif
-
-#ifdef __MSVCRT__
-_CRTIMP unsigned long __cdecl __MINGW_NOTHROW
- _beginthreadex (void *, unsigned, unsigned (__stdcall *) (void *),
- void*, unsigned, unsigned*);
-_CRTIMP void __cdecl __MINGW_NOTHROW _endthreadex (unsigned);
-#endif
-
-
-#ifndef _NO_OLDNAMES
-#ifndef __COREDLL__
-/*
- * Functions without the leading underscore, for portability. These functions
- * live in liboldnames.a.
- */
-_CRTIMP int __cdecl __MINGW_NOTHROW cwait (int*, pid_t, int);
-_CRTIMP pid_t __cdecl __MINGW_NOTHROW getpid (void);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execl (const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execle (const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execlp (const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execlpe (const char*, const char*,...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execv (const char*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execve (const char*, const char* const*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execvp (const char*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW execvpe (const char*, const char* const*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnl (int, const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnle (int, const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnlp (int, const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnlpe (int, const char*, const char*, ...);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnv (int, const char*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnve (int, const char*, const char* const*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnvp (int, const char*, const char* const*);
-_CRTIMP intptr_t __cdecl __MINGW_NOTHROW spawnvpe (int, const char*, const char* const*, const char* const*);
-#endif /* Not __COREDLL__ */
-
-#endif /* Not _NO_OLDNAMES */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* Not RC_INVOKED */
-#endif
-
-#endif /* _PROCESS_H_ not defined */
diff --git a/navit/support/libc/read.c b/navit/support/libc/read.c
deleted file mode 100644
index 8ce99d8ff..000000000
--- a/navit/support/libc/read.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * read.c: read and _read implementations for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-
-#include <windows.h>
-#include <unistd.h>
-
-int
-_read (int fildes, void *buf, unsigned int bufsize)
-{
- DWORD NumberOfBytesRead;
- if (bufsize > 0x7fffffff)
- bufsize = 0x7fffffff;
- if (!ReadFile ((HANDLE) fildes, buf, bufsize, &NumberOfBytesRead, NULL))
- return -1;
- return (int) NumberOfBytesRead;
-}
-
-int
-read (int fildes, void *buf, unsigned int bufsize)
-{
- return _read (fildes, buf, bufsize);
-}
diff --git a/navit/support/libc/rename.c b/navit/support/libc/rename.c
deleted file mode 100644
index 23ca19630..000000000
--- a/navit/support/libc/rename.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * rename.c: rename implementation for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-
-#include <windows.h>
-
-/* We return an error if the TO file already exists,
- like the Windows NT/9x 'rename' does. */
-
-int
-rename (const char* from, const char* to)
-{
- wchar_t fromw[MAX_PATH + 1];
- wchar_t tow[MAX_PATH + 1];
- mbstowcs (fromw, from, MAX_PATH);
- mbstowcs (tow, to, MAX_PATH);
- if (MoveFileW (fromw, tow))
- return 0;
- return -1;
-}
diff --git a/navit/support/libc/signal.h b/navit/support/libc/signal.h
deleted file mode 100644
index 18b65399b..000000000
--- a/navit/support/libc/signal.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#define SIGFPE 8
-#define SIGSEGV 11
diff --git a/navit/support/libc/stat.c b/navit/support/libc/stat.c
deleted file mode 100644
index 586dcf714..000000000
--- a/navit/support/libc/stat.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * stat.c: _stat, stat and fstat implementations for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> 10 Feb 2007
- *
- */
-
-#include <windows.h>
-#include <time.h>
-#include <fcntl.h>
-#include <io.h>
-#include <sys/stat.h>
-#include <stdio.h>
-#include "debug.h"
-
-#include "timeutil.h"
-
-struct stat_file_info_t
-{
- DWORD dwFileAttributes;
- FILETIME ftLastWriteTime;
- FILETIME ftCreationTime;
- FILETIME ftLastAccessTime;
- DWORD nFileSizeLow;
-};
-
-#define COPY_MEMBER(DEST, SRC, MEMBER) \
- do { \
- (DEST)->MEMBER = (SRC)->MEMBER; \
- } while (0)
-
-#define TO_STAT_FILE_INFO(DEST, SRC) \
- do { \
- COPY_MEMBER (DEST, SRC, dwFileAttributes); \
- COPY_MEMBER (DEST, SRC, ftLastWriteTime); \
- COPY_MEMBER (DEST, SRC, ftCreationTime); \
- COPY_MEMBER (DEST, SRC, ftLastAccessTime); \
- COPY_MEMBER (DEST, SRC, nFileSizeLow); \
- } while (0)
-
-static int
-__stat_by_file_info (struct stat_file_info_t *fi, struct _stat *st, int exec)
-{
- int permission = _S_IREAD;
-
- memset (st, 0, sizeof (*st));
-
- st->st_size = fi->nFileSizeLow;
- st->st_mode = _S_IFREG;
-
- if((fi->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0)
- st->st_mode = _S_IFDIR | _S_IEXEC;
- else if (exec)
- permission |= _S_IEXEC;
-
- if((fi->dwFileAttributes & FILE_ATTRIBUTE_READONLY) == 0)
- permission |= _S_IWRITE;
-
- st->st_mode |= permission | (permission >> 3) | (permission >> 6);
-
- st->st_nlink = 1; /* always 1? */
- st->st_rdev = 1; /* Where to get drive info? */
- st->st_ino = 0; /* always 0 on Windows */
-
- st->st_mtime = __FILETIME_to_time_t (&fi->ftLastWriteTime);
- st->st_ctime = __FILETIME_to_time_t (&fi->ftCreationTime);
- st->st_atime = __FILETIME_to_time_t (&fi->ftLastAccessTime);
-
- /* Looks like the code below is never triggered.
- Windows CE always only keeps the LastWriteTime, and
- copies it to the CreationTime and LastAccessTime fields. */
- if (st->st_ctime == 0)
- st->st_ctime = st->st_mtime;
- if (st->st_atime == 0)
- {
- /* On XP, at least, the st_atime is always set to the same as
- the st_mtime, except the hour/min/sec == 00:00:00. */
- SYSTEMTIME s;
- FILETIME f = fi->ftLastWriteTime;
- FileTimeToSystemTime (&f, &s);
- s.wHour = 0; s.wMinute = 0;
- s.wSecond = 0; s.wMilliseconds = 0;
- SystemTimeToFileTime (&s, &f);
- st->st_atime = __FILETIME_to_time_t (&f);
- /* st->st_atime = st->st_mtime; */
- }
- return 0;
-}
-
-int
-_fstat (int fd, struct _stat *st)
-{
- BY_HANDLE_FILE_INFORMATION fi;
- struct stat_file_info_t sfi;
-
- if (!GetFileInformationByHandle ((HANDLE) fd, &fi))
- return -1;
- TO_STAT_FILE_INFO (&sfi, &fi);
- return __stat_by_file_info (&sfi, st, 0);
-}
-
-int
-fstat (int fd, struct stat *st)
-{
- return _fstat (fd, (struct _stat *)st);
-}
-
-int
-_stat (const char *path, struct _stat *st)
-{
- WIN32_FIND_DATAW fd;
- HANDLE h;
- int ret;
- struct stat_file_info_t sfi;
- wchar_t pathw[MAX_PATH + 1];
- size_t len;
- int exec;
-
- dbg(lvl_debug,"path=%s\n",path);
- mbstowcs (pathw, path, MAX_PATH);
- dbg(lvl_debug,"wide path=%S\n",pathw);
- if((h = FindFirstFileW (pathw, &fd)) == INVALID_HANDLE_VALUE)
- {
- DWORD dwError = GetLastError ();
- dbg(lvl_error,"no file\n");
- if(dwError == ERROR_NO_MORE_FILES)
- /* Convert error to something more sensible. */
- SetLastError (ERROR_FILE_NOT_FOUND);
- return -1;
- }
-
- TO_STAT_FILE_INFO (&sfi, &fd);
-
- len = strlen (path);
- exec = (len >= 4
- && strcasecmp (path + len - 4, ".exe") == 0);
- ret = __stat_by_file_info (&sfi, st, exec);
- dbg(lvl_debug,"ret=%d\n",ret);
- FindClose (h);
- return ret;
-}
-
-int
-stat (const char *path, struct stat *st)
-{
- return _stat (path, (struct _stat *)st);
-}
diff --git a/navit/support/libc/strcasecmp.c b/navit/support/libc/strcasecmp.c
deleted file mode 100644
index a238e22f2..000000000
--- a/navit/support/libc/strcasecmp.c
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * strcasecmp.c
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Oldnames from ANSI header string.h
- *
- * Some wrapper functions for those old name functions whose appropriate
- * equivalents are not simply underscore prefixed.
- *
- */
-
-#include <string.h>
-
-int
-strcasecmp (const char *sz1, const char *sz2)
-{
- return _stricmp (sz1, sz2);
-}
-
diff --git a/navit/support/libc/sys/stat.h b/navit/support/libc/sys/stat.h
deleted file mode 100644
index 3bd462714..000000000
--- a/navit/support/libc/sys/stat.h
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * stat.h
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Symbolic constants for opening and creating files, also stat, fstat and
- * chmod functions.
- *
- */
-
-#ifndef _STAT_H_
-#define _STAT_H_
-
-/* All the headers include this file. */
-#include <_mingw.h>
-
-#define __need_size_t
-#define __need_wchar_t
-#ifndef RC_INVOKED
-#include <stddef.h>
-#endif /* Not RC_INVOKED */
-
-#include <sys/types.h>
-
-/*
- * Constants for the stat st_mode member.
- */
-#define _S_IFIFO 0x1000 /* FIFO */
-#define _S_IFCHR 0x2000 /* Character */
-#define _S_IFBLK 0x3000 /* Block: Is this ever set under w32? */
-#define _S_IFDIR 0x4000 /* Directory */
-#define _S_IFREG 0x8000 /* Regular */
-
-#define _S_IFMT 0xF000 /* File type mask */
-
-#define _S_IEXEC 0x0040
-#define _S_IWRITE 0x0080
-#define _S_IREAD 0x0100
-
-#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC)
-#define _S_IXUSR _S_IEXEC
-#define _S_IWUSR _S_IWRITE
-#define _S_IRUSR _S_IREAD
-
-#define _S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
-#define _S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
-#define _S_ISCHR(m) (((m) & _S_IFMT) == _S_IFCHR)
-#define _S_ISBLK(m) (((m) & _S_IFMT) == _S_IFBLK)
-#define _S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
-
-#ifndef _NO_OLDNAMES
-
-#define S_IFIFO _S_IFIFO
-#define S_IFCHR _S_IFCHR
-#define S_IFBLK _S_IFBLK
-#define S_IFDIR _S_IFDIR
-#define S_IFREG _S_IFREG
-#define S_IFMT _S_IFMT
-#define S_IEXEC _S_IEXEC
-#define S_IWRITE _S_IWRITE
-#define S_IREAD _S_IREAD
-#define S_IRWXU _S_IRWXU
-#define S_IXUSR _S_IXUSR
-#define S_IWUSR _S_IWUSR
-#define S_IRUSR _S_IRUSR
-
-#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
-#define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
-#define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
-#define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
-#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
-
-#endif /* Not _NO_OLDNAMES */
-
-#ifndef RC_INVOKED
-
-#ifndef _STAT_DEFINED
-/*
- * The structure manipulated and returned by stat and fstat.
- *
- * NOTE: If called on a directory the values in the time fields are not only
- * invalid, they will cause localtime et. al. to return NULL. And calling
- * asctime with a NULL pointer causes an Invalid Page Fault. So watch it!
- */
-struct _stat
-{
- _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
- _ino_t st_ino; /* Always zero ? */
- _mode_t st_mode; /* See above constants */
- short st_nlink; /* Number of links. */
- short st_uid; /* User: Maybe significant on NT ? */
- short st_gid; /* Group: Ditto */
- _dev_t st_rdev; /* Seems useless (not even filled in) */
- _off_t st_size; /* File size in bytes */
- time_t st_atime; /* Accessed date (always 00:00 hrs local
- * on FAT) */
- time_t st_mtime; /* Modified time */
- time_t st_ctime; /* Creation time */
-};
-
-#ifndef _NO_OLDNAMES
-/* NOTE: Must be the same as _stat above. */
-struct stat
-{
- dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */
- ino_t st_ino; /* Always zero ? */
- mode_t st_mode; /* See above constants */
- short st_nlink; /* Number of links. */
- short st_uid; /* User: Maybe significant on NT ? */
- short st_gid; /* Group: Ditto */
- dev_t st_rdev; /* Seems useless (not even filled in) */
- off_t st_size; /* File size in bytes */
- time_t st_atime; /* Accessed date (always 00:00 hrs local
- * on FAT) */
- time_t st_mtime; /* Modified time */
- time_t st_ctime; /* Creation time */
-};
-#endif /* _NO_OLDNAMES */
-
-#if defined (__MSVCRT__)
-struct _stati64 {
- _dev_t st_dev;
- _ino_t st_ino;
- _mode_t st_mode;
- short st_nlink;
- short st_uid;
- short st_gid;
- _dev_t st_rdev;
- __int64 st_size;
- time_t st_atime;
- time_t st_mtime;
- time_t st_ctime;
-};
-#if __MSVCRT_VERSION__ >= 0x0601
-struct __stat64
-{
- _dev_t st_dev;
- _ino_t st_ino;
- _mode_t st_mode;
- short st_nlink;
- short st_uid;
- short st_gid;
- _dev_t st_rdev;
- __int64 st_size;
- __time64_t st_atime;
- __time64_t st_mtime;
- __time64_t st_ctime;
-};
-#endif /* __MSVCRT_VERSION__ */
-#endif /* __MSVCRT__ */
-#define _STAT_DEFINED
-#endif /* _STAT_DEFINED */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-_CRTIMP int __cdecl __MINGW_NOTHROW _fstat (int, struct _stat*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _chmod (const char*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW _stat (const char*, struct _stat*);
-
-#ifndef _NO_OLDNAMES
-
-/* These functions live in liboldnames.a. */
-_CRTIMP int __cdecl __MINGW_NOTHROW fstat (int, struct stat*);
-_CRTIMP int __cdecl __MINGW_NOTHROW chmod (const char*, int);
-_CRTIMP int __cdecl __MINGW_NOTHROW stat (const char*, struct stat*);
-
-#endif /* Not _NO_OLDNAMES */
-
-#if defined (__MSVCRT__)
-_CRTIMP int __cdecl __MINGW_NOTHROW _fstati64(int, struct _stati64 *);
-_CRTIMP int __cdecl __MINGW_NOTHROW _stati64(const char *, struct _stati64 *);
-/* These require newer versions of msvcrt.dll (6.10 or higher). */
-#if __MSVCRT_VERSION__ >= 0x0601
-_CRTIMP int __cdecl __MINGW_NOTHROW _fstat64 (int, struct __stat64*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _stat64 (const char*, struct __stat64*);
-#endif /* __MSVCRT_VERSION__ >= 0x0601 */
-#if !defined ( _WSTAT_DEFINED) /* also declared in wchar.h */
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstat(const wchar_t*, struct _stat*);
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstati64 (const wchar_t*, struct _stati64*);
-#if __MSVCRT_VERSION__ >= 0x0601
-_CRTIMP int __cdecl __MINGW_NOTHROW _wstat64 (const wchar_t*, struct __stat64*);
-#endif /* __MSVCRT_VERSION__ >= 0x0601 */
-#define _WSTAT_DEFINED
-#endif /* _WSTAT_DEFIND */
-#endif /* __MSVCRT__ */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* Not RC_INVOKED */
-
-#endif /* Not _STAT_H_ */
diff --git a/navit/support/libc/sys/time.h b/navit/support/libc/sys/time.h
deleted file mode 100644
index 871da3f1b..000000000
--- a/navit/support/libc/sys/time.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef _SYS_TIME_H_
-#define _SYS_TIME_H_
-#include <time.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef _TIMEVAL_DEFINED /* also in winsock[2].h */
-#define _TIMEVAL_DEFINED
-struct timeval {
- long tv_sec;
- long tv_usec;
-};
-#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
-#define timercmp(tvp, uvp, cmp) \
- (((tvp)->tv_sec != (uvp)->tv_sec) ? \
- ((tvp)->tv_sec cmp (uvp)->tv_sec) : \
- ((tvp)->tv_usec cmp (uvp)->tv_usec))
-#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
-#endif /* _TIMEVAL_DEFINED */
-
-/* Provided for compatibility with code that assumes that
- the presence of gettimeofday function implies a definition
- of struct timezone. */
-#ifndef _TIMEZONE_DEFINED
-struct timezone
-{
- int tz_minuteswest; /* of Greenwich */
- int tz_dsttime; /* type of dst correction to apply */
-};
-#define _TIMEZONE_DEFINED
-#endif
-
-/*
- Implementation as per:
- The Open Group Base Specifications, Issue 6
- IEEE Std 1003.1, 2004 Edition
-
- The timezone pointer arg is ignored. Errors are ignored.
-*/
-
-#if 0
-#define __restrict__
-int __cdecl __MINGW_NOTHROW gettimeofday(struct timeval *__restrict__,
- void *__restrict__ /* tzp (unused) */);
-#else
-int gettimeofday(struct timeval *, void *);
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-
-#endif /* _SYS_TIME_H_ */
diff --git a/navit/support/libc/sys/types.h b/navit/support/libc/sys/types.h
deleted file mode 100644
index ed25e5270..000000000
--- a/navit/support/libc/sys/types.h
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * types.h
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * The definition of constants, data types and global variables.
- *
- */
-
-#ifndef _TYPES_H_
-#define _TYPES_H_
-
-/* All the headers include this file. */
-#include <_mingw.h>
-
-#define __need_wchar_t
-#define __need_size_t
-#define __need_ptrdiff_t
-#ifndef RC_INVOKED
-#include <stddef.h>
-#endif /* Not RC_INVOKED */
-
-#ifndef RC_INVOKED
-
-#ifndef _TIME_T_DEFINED
-typedef long time_t;
-#define _TIME_T_DEFINED
-#endif
-
-#ifndef _TIME64_T_DEFINED
-typedef __int64 __time64_t;
-#define _TIME64_T_DEFINED
-#endif
-
-#ifndef _OFF_T_
-#define _OFF_T_
-typedef long _off_t;
-
-#ifndef _NO_OLDNAMES
-typedef _off_t off_t;
-#endif
-#endif /* Not _OFF_T_ */
-
-
-#ifndef _DEV_T_
-#define _DEV_T_
-#ifdef __MSVCRT__
-typedef unsigned int _dev_t;
-#else
-typedef short _dev_t;
-#endif
-
-#ifndef _NO_OLDNAMES
-typedef _dev_t dev_t;
-#endif
-#endif /* Not _DEV_T_ */
-
-
-#ifndef _INO_T_
-#define _INO_T_
-typedef short _ino_t;
-
-#ifndef _NO_OLDNAMES
-typedef _ino_t ino_t;
-#endif
-#endif /* Not _INO_T_ */
-
-
-#ifndef _PID_T_
-#define _PID_T_
-typedef int _pid_t;
-
-#ifndef _NO_OLDNAMES
-typedef _pid_t pid_t;
-#endif
-#endif /* Not _PID_T_ */
-
-
-#ifndef _MODE_T_
-#define _MODE_T_
-typedef unsigned short _mode_t;
-
-#ifndef _NO_OLDNAMES
-typedef _mode_t mode_t;
-#endif
-#endif /* Not _MODE_T_ */
-
-
-#ifndef _SIGSET_T_
-#define _SIGSET_T_
-typedef int _sigset_t;
-
-#ifndef _NO_OLDNAMES
-typedef _sigset_t sigset_t;
-#endif
-#endif /* Not _SIGSET_T_ */
-
-#ifndef _SSIZE_T_
-#define _SSIZE_T_
-typedef long _ssize_t;
-
-#ifndef _NO_OLDNAMES
-typedef _ssize_t ssize_t;
-#endif
-#endif /* Not _SSIZE_T_ */
-
-#ifndef _FPOS64_T_
-#define _FPOS64_T_
-typedef long long fpos64_t;
-#endif
-
-#ifndef _OFF64_T_
-#define _OFF64_T_
-typedef long long off64_t;
-#endif
-
-#if !defined __NO_ISOCEXT
-typedef unsigned int useconds_t;
-#endif /* Not __NO_ISOCEXT */
-
-#endif /* Not RC_INVOKED */
-
-#endif /* Not _TYPES_H_ */
diff --git a/navit/support/libc/time.c b/navit/support/libc/time.c
deleted file mode 100644
index b167d5e30..000000000
--- a/navit/support/libc/time.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * time.c: time implementation for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-
-#include "timeutil.h"
-
-time_t
-time (time_t *timer)
-{
- SYSTEMTIME s;
- FILETIME f;
- time_t t;
-
- if (timer == NULL)
- timer = &t;
-
- GetSystemTime (&s);
- SystemTimeToFileTime (&s, &f);
- *timer = __FILETIME_to_time_t (&f);
- return *timer;
-}
diff --git a/navit/support/libc/timeutil.c b/navit/support/libc/timeutil.c
deleted file mode 100644
index 433bbbb58..000000000
--- a/navit/support/libc/timeutil.c
+++ /dev/null
@@ -1,126 +0,0 @@
-#include "timeutil.h"
-
-/* Originally based on code found in the Ruby WinCE support, which
- had the following notice: */
-
-/* start original header */
-
-/***************************************************************
- time.c
-
- author : uema2
- date : Nov 30, 2002
-
- You can freely use, copy, modify, and redistribute
- the whole contents.
-***************************************************************/
-
-/* end original header */
-
-/* Note: The original filename was: wince/time_wce.c */
-
-/* Adapted to mingw32ce by Pedro Alves <pedro_alves@portugalmail.pt>
- 10 Feb 2007 - Initial revision. */
-
-#define DELTA_EPOCH 116444736000000000LL
-
-#if 0
-how_to_calc_delta_epoch ()
-{
- FILETIME f1601, f1970;
- __FILETIME_from_Year (1601, &f1601);
- __FILETIME_from_Year (1970, &f1970);
- DELTA_EPOCH = __FILETIME_to_ll (&f1970) - __FILETIME_to_ll (&f1601);
-}
-#endif
-
-long long
-__FILETIME_to_ll (const FILETIME *f)
-{
- long long t;
- t = (long long)f->dwHighDateTime << 32;
- t |= f->dwLowDateTime;
- return t;
-}
-
-void
-__ll_to_FILETIME (long long t, FILETIME* f)
-{
- f->dwHighDateTime = (DWORD)((t >> 32) & 0x00000000FFFFFFFF);
- f->dwLowDateTime = (DWORD)(t & 0x00000000FFFFFFFF);
-}
-
-void
-__tm_to_SYSTEMTIME (struct tm *t, SYSTEMTIME *s)
-{
- s->wYear = t->tm_year + 1900;
- s->wMonth = t->tm_mon + 1;
- s->wDayOfWeek = t->tm_wday;
- s->wDay = t->tm_mday;
- s->wHour = t->tm_hour;
- s->wMinute = t->tm_min;
- s->wSecond = t->tm_sec;
- s->wMilliseconds = 0;
-}
-
-static void
-__FILETIME_from_Year (WORD year, FILETIME *f)
-{
- SYSTEMTIME s = {0};
-
- s.wYear = year;
- s.wMonth = 1;
- s.wDayOfWeek = 1;
- s.wDay = 1;
-
- SystemTimeToFileTime (&s, f);
-}
-
-static int
-__Yday_from_SYSTEMTIME (const SYSTEMTIME *s)
-{
- long long t;
- FILETIME f1, f2;
-
- __FILETIME_from_Year (s->wYear, &f1);
- SystemTimeToFileTime (s, &f2);
-
- t = __FILETIME_to_ll (&f2) - __FILETIME_to_ll (&f1);
-
- return ((t / _onesec_in100ns) / (60 * 60 * 24));
-}
-
-void
-__SYSTEMTIME_to_tm (SYSTEMTIME *s, struct tm *tm)
-{
- tm->tm_year = s->wYear - 1900;
- tm->tm_mon = s->wMonth- 1;
- tm->tm_wday = s->wDayOfWeek;
- tm->tm_mday = s->wDay;
- tm->tm_yday = __Yday_from_SYSTEMTIME (s);
- tm->tm_hour = s->wHour;
- tm->tm_min = s->wMinute;
- tm->tm_sec = s->wSecond;
- tm->tm_isdst = 0;
-}
-
-time_t
-__FILETIME_to_time_t (const FILETIME* f)
-{
- long long t;
- t = __FILETIME_to_ll (f);
- t -= DELTA_EPOCH;
- return (time_t)(t / _onesec_in100ns);
-}
-
-void
-__time_t_to_FILETIME (time_t t, FILETIME *f)
-{
- long long time;
-
- time = t;
- time *= _onesec_in100ns;
- time += DELTA_EPOCH;
-
- __ll_to_FILETIME (time, f);
-}
diff --git a/navit/support/libc/timeutil.h b/navit/support/libc/timeutil.h
deleted file mode 100644
index 9e5f70886..000000000
--- a/navit/support/libc/timeutil.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef __TIMEUTIL_H
-#define __TIMEUTIL_H
-
-#include <windows.h>
-#include <sys/time.h>
-#include <_mingw.h>
-
-#define _onesec_in100ns 10000000LL
-
-extern long long __FILETIME_to_ll (const FILETIME *f);
-extern void __ll_to_FILETIME (long long t, FILETIME* f);
-extern void __tm_to_SYSTEMTIME (struct tm *, SYSTEMTIME *);
-extern void __SYSTEMTIME_to_tm (SYSTEMTIME *, struct tm *);
-extern time_t __FILETIME_to_time_t (const FILETIME *);
-extern void __time_t_to_FILETIME (time_t, FILETIME *);
-
-#endif
diff --git a/navit/support/libc/unistd.h b/navit/support/libc/unistd.h
deleted file mode 100644
index d1a435168..000000000
--- a/navit/support/libc/unistd.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef _UNISTD_H
-/*
- * This file is part of the Mingw32 package.
- *
- * unistd.h maps (roughly) to io.h
- * Other headers included by unistd.h may be selectively processed;
- * __UNISTD_H_SOURCED__ enables such selective processing.
- */
-#define _UNISTD_H
-#define __UNISTD_H_SOURCED__ 1
-
-#include <io.h>
-#include <process.h>
-#include <getopt.h>
-
-/* These are also defined in stdio.h. */
-#ifndef SEEK_SET
-#define SEEK_SET 0
-#endif
-
-#ifndef SEEK_CUR
-#define SEEK_CUR 1
-#endif
-
-#ifndef SEEK_END
-#define SEEK_END 2
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if !defined __NO_ISOCEXT
-#include <sys/types.h> /* For useconds_t. */
-
-int __cdecl __MINGW_NOTHROW usleep(useconds_t useconds);
-#endif /* Not __NO_ISOCEXT */
-
-/* This is defined as a real library function to allow autoconf
- to verify its existence. */
-int ftruncate(int, off_t);
-
-#ifdef __cplusplus
-}
-#endif
-
-#undef __UNISTD_H_SOURCED__
-#endif /* _UNISTD_H */
diff --git a/navit/support/libc/unlink.c b/navit/support/libc/unlink.c
deleted file mode 100644
index 9e3f9b582..000000000
--- a/navit/support/libc/unlink.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * unlink.c: unlink and _unlink implementations for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-
-#include <stdio.h>
-#include <windows.h>
-
-int
-_unlink (const char *file)
-{
- wchar_t wfile[MAX_PATH];
- size_t conv = mbstowcs (wfile, file, MAX_PATH);
- if (conv > 0 && conv < MAX_PATH && DeleteFileW (wfile))
- return 0;
- return -1;
-}
-
-int
-unlink (const char *file)
-{
- return _unlink (file);
-}
diff --git a/navit/support/libc/write.c b/navit/support/libc/write.c
deleted file mode 100644
index b9521aefc..000000000
--- a/navit/support/libc/write.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * write.c: write and _write implementations for WinCE.
- *
- * This file has no copyright assigned and is placed in the Public Domain.
- * This file is a part of the mingw-runtime package.
- * No warranty is given; refer to the file DISCLAIMER within the package.
- *
- * Written by Pedro Alves <pedro_alves@portugalmail.pt> Feb 2007
- *
- */
-#include <windows.h>
-#include <unistd.h>
-
-int
-_write (int fildes, const void *buf, unsigned int bufsize)
-{
- DWORD NumberOfBytesWritten;
- if (bufsize > 0x7fffffff)
- bufsize = 0x7fffffff;
- if (!WriteFile ((HANDLE) fildes, buf, bufsize, &NumberOfBytesWritten, NULL))
- return -1;
- return (int) NumberOfBytesWritten;
-}
-
-int
-write (int fildes, const void *buf, unsigned int bufsize)
-{
- return _write (fildes, buf, bufsize);
-}
diff --git a/navit/support/libpng/CMakeLists.txt b/navit/support/libpng/CMakeLists.txt
deleted file mode 100644
index 3aa3362be..000000000
--- a/navit/support/libpng/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-supportlib_add_library(support_libpng png.c pngerror.c pngget.c pngmem.c pngread.c pngrio.c pngrtran.c pngrutil.c pngset.c pngtrans.c libpng_init.c)
-
diff --git a/navit/support/libpng/libpng_init.c b/navit/support/libpng/libpng_init.c
deleted file mode 100644
index 32be387da..000000000
--- a/navit/support/libpng/libpng_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "plugin.h"
-
-void
-plugin_init(void)
-{
-}
diff --git a/navit/support/libpng/png.c b/navit/support/libpng/png.c
deleted file mode 100644
index e1c066690..000000000
--- a/navit/support/libpng/png.c
+++ /dev/null
@@ -1,912 +0,0 @@
-
-/* png.c - location for general purpose libpng functions
- *
- * Last changed in libpng 1.2.34 [December 18, 2008]
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2008 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- */
-
-#define PNG_INTERNAL
-#define PNG_NO_EXTERN
-#include "png.h"
-
-/* Generate a compiler error if there is an old png.h in the search path. */
-typedef version_1_2_36 Your_png_h_is_not_version_1_2_36;
-
-/* Version information for C files. This had better match the version
- * string defined in png.h. */
-
-#ifdef PNG_USE_GLOBAL_ARRAYS
-/* png_libpng_ver was changed to a function in version 1.0.5c */
-PNG_CONST char png_libpng_ver[18] = PNG_LIBPNG_VER_STRING;
-
-#ifdef PNG_READ_SUPPORTED
-
-/* png_sig was changed to a function in version 1.0.5c */
-/* Place to hold the signature string for a PNG file. */
-PNG_CONST png_byte FARDATA png_sig[8] = {137, 80, 78, 71, 13, 10, 26, 10};
-#endif /* PNG_READ_SUPPORTED */
-
-/* Invoke global declarations for constant strings for known chunk types */
-PNG_IHDR;
-PNG_IDAT;
-PNG_IEND;
-PNG_PLTE;
-PNG_bKGD;
-PNG_cHRM;
-PNG_gAMA;
-PNG_hIST;
-PNG_iCCP;
-PNG_iTXt;
-PNG_oFFs;
-PNG_pCAL;
-PNG_sCAL;
-PNG_pHYs;
-PNG_sBIT;
-PNG_sPLT;
-PNG_sRGB;
-PNG_tEXt;
-PNG_tIME;
-PNG_tRNS;
-PNG_zTXt;
-
-#ifdef PNG_READ_SUPPORTED
-/* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
-/* start of interlace block */
-PNG_CONST int FARDATA png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
-
-/* offset to next interlace block */
-PNG_CONST int FARDATA png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
-
-/* start of interlace block in the y direction */
-PNG_CONST int FARDATA png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
-
-/* offset to next interlace block in the y direction */
-PNG_CONST int FARDATA png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
-
-/* Height of interlace block. This is not currently used - if you need
- * it, uncomment it here and in png.h
-PNG_CONST int FARDATA png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
-*/
-
-/* Mask to determine which pixels are valid in a pass */
-PNG_CONST int FARDATA png_pass_mask[] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
-
-/* Mask to determine which pixels to overwrite while displaying */
-PNG_CONST int FARDATA png_pass_dsp_mask[]
- = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff};
-
-#endif /* PNG_READ_SUPPORTED */
-#endif /* PNG_USE_GLOBAL_ARRAYS */
-
-/* Tells libpng that we have already handled the first "num_bytes" bytes
- * of the PNG file signature. If the PNG data is embedded into another
- * stream we can set num_bytes = 8 so that libpng will not attempt to read
- * or write any of the magic bytes before it starts on the IHDR.
- */
-
-#ifdef PNG_READ_SUPPORTED
-void PNGAPI
-png_set_sig_bytes(png_structp png_ptr, int num_bytes)
-{
- if (png_ptr == NULL) return;
- png_debug(1, "in png_set_sig_bytes");
- if (num_bytes > 8)
- png_error(png_ptr, "Too many bytes for PNG signature.");
-
- png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes);
-}
-
-/* Checks whether the supplied bytes match the PNG signature. We allow
- * checking less than the full 8-byte signature so that those apps that
- * already read the first few bytes of a file to determine the file type
- * can simply check the remaining bytes for extra assurance. Returns
- * an integer less than, equal to, or greater than zero if sig is found,
- * respectively, to be less than, to match, or be greater than the correct
- * PNG signature (this is the same behaviour as strcmp, memcmp, etc).
- */
-int PNGAPI
-png_sig_cmp(png_bytep sig, png_size_t start, png_size_t num_to_check)
-{
- png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
- if (num_to_check > 8)
- num_to_check = 8;
- else if (num_to_check < 1)
- return (-1);
-
- if (start > 7)
- return (-1);
-
- if (start + num_to_check > 8)
- num_to_check = 8 - start;
-
- return ((int)(png_memcmp(&sig[start], &png_signature[start], num_to_check)));
-}
-
-#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
-/* (Obsolete) function to check signature bytes. It does not allow one
- * to check a partial signature. This function might be removed in the
- * future - use png_sig_cmp(). Returns true (nonzero) if the file is PNG.
- */
-int PNGAPI
-png_check_sig(png_bytep sig, int num)
-{
- return ((int)!png_sig_cmp(sig, (png_size_t)0, (png_size_t)num));
-}
-#endif
-#endif /* PNG_READ_SUPPORTED */
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-/* Function to allocate memory for zlib and clear it to 0. */
-#ifdef PNG_1_0_X
-voidpf PNGAPI
-#else
-voidpf /* private */
-#endif
-png_zalloc(voidpf png_ptr, uInt items, uInt size)
-{
- png_voidp ptr;
- png_structp p=(png_structp)png_ptr;
- png_uint_32 save_flags=p->flags;
- png_uint_32 num_bytes;
-
- if (png_ptr == NULL) return (NULL);
- if (items > PNG_UINT_32_MAX/size)
- {
- png_warning (p, "Potential overflow in png_zalloc()");
- return (NULL);
- }
- num_bytes = (png_uint_32)items * size;
-
- p->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
- ptr = (png_voidp)png_malloc((png_structp)png_ptr, num_bytes);
- p->flags=save_flags;
-
-#if defined(PNG_1_0_X) && !defined(PNG_NO_ZALLOC_ZERO)
- if (ptr == NULL)
- return ((voidpf)ptr);
-
- if (num_bytes > (png_uint_32)0x8000L)
- {
- png_memset(ptr, 0, (png_size_t)0x8000L);
- png_memset((png_bytep)ptr + (png_size_t)0x8000L, 0,
- (png_size_t)(num_bytes - (png_uint_32)0x8000L));
- }
- else
- {
- png_memset(ptr, 0, (png_size_t)num_bytes);
- }
-#endif
- return ((voidpf)ptr);
-}
-
-/* function to free memory for zlib */
-#ifdef PNG_1_0_X
-void PNGAPI
-#else
-void /* private */
-#endif
-png_zfree(voidpf png_ptr, voidpf ptr)
-{
- png_free((png_structp)png_ptr, (png_voidp)ptr);
-}
-
-/* Reset the CRC variable to 32 bits of 1's. Care must be taken
- * in case CRC is > 32 bits to leave the top bits 0.
- */
-void /* PRIVATE */
-png_reset_crc(png_structp png_ptr)
-{
- png_ptr->crc = crc32(0, Z_NULL, 0);
-}
-
-/* Calculate the CRC over a section of data. We can only pass as
- * much data to this routine as the largest single buffer size. We
- * also check that this data will actually be used before going to the
- * trouble of calculating it.
- */
-void /* PRIVATE */
-png_calculate_crc(png_structp png_ptr, png_bytep ptr, png_size_t length)
-{
- int need_crc = 1;
-
- if (png_ptr->chunk_name[0] & 0x20) /* ancillary */
- {
- if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
- (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
- need_crc = 0;
- }
- else /* critical */
- {
- if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
- need_crc = 0;
- }
-
- if (need_crc)
- png_ptr->crc = crc32(png_ptr->crc, ptr, (uInt)length);
-}
-
-/* Allocate the memory for an info_struct for the application. We don't
- * really need the png_ptr, but it could potentially be useful in the
- * future. This should be used in favour of malloc(png_sizeof(png_info))
- * and png_info_init() so that applications that want to use a shared
- * libpng don't have to be recompiled if png_info changes size.
- */
-png_infop PNGAPI
-png_create_info_struct(png_structp png_ptr)
-{
- png_infop info_ptr;
-
- png_debug(1, "in png_create_info_struct");
- if (png_ptr == NULL) return (NULL);
-#ifdef PNG_USER_MEM_SUPPORTED
- info_ptr = (png_infop)png_create_struct_2(PNG_STRUCT_INFO,
- png_ptr->malloc_fn, png_ptr->mem_ptr);
-#else
- info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
-#endif
- if (info_ptr != NULL)
- png_info_init_3(&info_ptr, png_sizeof(png_info));
-
- return (info_ptr);
-}
-
-/* This function frees the memory associated with a single info struct.
- * Normally, one would use either png_destroy_read_struct() or
- * png_destroy_write_struct() to free an info struct, but this may be
- * useful for some applications.
- */
-void PNGAPI
-png_destroy_info_struct(png_structp png_ptr, png_infopp info_ptr_ptr)
-{
- png_infop info_ptr = NULL;
- if (png_ptr == NULL) return;
-
- png_debug(1, "in png_destroy_info_struct");
- if (info_ptr_ptr != NULL)
- info_ptr = *info_ptr_ptr;
-
- if (info_ptr != NULL)
- {
- png_info_destroy(png_ptr, info_ptr);
-
-#ifdef PNG_USER_MEM_SUPPORTED
- png_destroy_struct_2((png_voidp)info_ptr, png_ptr->free_fn,
- png_ptr->mem_ptr);
-#else
- png_destroy_struct((png_voidp)info_ptr);
-#endif
- *info_ptr_ptr = NULL;
- }
-}
-
-/* Initialize the info structure. This is now an internal function (0.89)
- * and applications using it are urged to use png_create_info_struct()
- * instead.
- */
-#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
-#undef png_info_init
-void PNGAPI
-png_info_init(png_infop info_ptr)
-{
- /* We only come here via pre-1.0.12-compiled applications */
- png_info_init_3(&info_ptr, 0);
-}
-#endif
-
-void PNGAPI
-png_info_init_3(png_infopp ptr_ptr, png_size_t png_info_struct_size)
-{
- png_infop info_ptr = *ptr_ptr;
-
- if (info_ptr == NULL) return;
-
- png_debug(1, "in png_info_init_3");
-
- if (png_sizeof(png_info) > png_info_struct_size)
- {
- png_destroy_struct(info_ptr);
- info_ptr = (png_infop)png_create_struct(PNG_STRUCT_INFO);
- *ptr_ptr = info_ptr;
- }
-
- /* set everything to 0 */
- png_memset(info_ptr, 0, png_sizeof(png_info));
-}
-
-#ifdef PNG_FREE_ME_SUPPORTED
-void PNGAPI
-png_data_freer(png_structp png_ptr, png_infop info_ptr,
- int freer, png_uint_32 mask)
-{
- png_debug(1, "in png_data_freer");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
- if (freer == PNG_DESTROY_WILL_FREE_DATA)
- info_ptr->free_me |= mask;
- else if (freer == PNG_USER_WILL_FREE_DATA)
- info_ptr->free_me &= ~mask;
- else
- png_warning(png_ptr,
- "Unknown freer parameter in png_data_freer.");
-}
-#endif
-
-void PNGAPI
-png_free_data(png_structp png_ptr, png_infop info_ptr, png_uint_32 mask,
- int num)
-{
- png_debug(1, "in png_free_data");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
-#if defined(PNG_TEXT_SUPPORTED)
-/* free text item num or (if num == -1) all text items */
-#ifdef PNG_FREE_ME_SUPPORTED
-if ((mask & PNG_FREE_TEXT) & info_ptr->free_me)
-#else
-if (mask & PNG_FREE_TEXT)
-#endif
-{
- if (num != -1)
- {
- if (info_ptr->text && info_ptr->text[num].key)
- {
- png_free(png_ptr, info_ptr->text[num].key);
- info_ptr->text[num].key = NULL;
- }
- }
- else
- {
- int i;
- for (i = 0; i < info_ptr->num_text; i++)
- png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, i);
- png_free(png_ptr, info_ptr->text);
- info_ptr->text = NULL;
- info_ptr->num_text=0;
- }
-}
-#endif
-
-#if defined(PNG_tRNS_SUPPORTED)
-/* free any tRNS entry */
-#ifdef PNG_FREE_ME_SUPPORTED
-if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
-#else
-if ((mask & PNG_FREE_TRNS) && (png_ptr->flags & PNG_FLAG_FREE_TRNS))
-#endif
-{
- png_free(png_ptr, info_ptr->trans);
- info_ptr->trans = NULL;
- info_ptr->valid &= ~PNG_INFO_tRNS;
-#ifndef PNG_FREE_ME_SUPPORTED
- png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
-#endif
-}
-#endif
-
-#if defined(PNG_sCAL_SUPPORTED)
-/* free any sCAL entry */
-#ifdef PNG_FREE_ME_SUPPORTED
-if ((mask & PNG_FREE_SCAL) & info_ptr->free_me)
-#else
-if (mask & PNG_FREE_SCAL)
-#endif
-{
-#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
- png_free(png_ptr, info_ptr->scal_s_width);
- png_free(png_ptr, info_ptr->scal_s_height);
- info_ptr->scal_s_width = NULL;
- info_ptr->scal_s_height = NULL;
-#endif
- info_ptr->valid &= ~PNG_INFO_sCAL;
-}
-#endif
-
-#if defined(PNG_pCAL_SUPPORTED)
-/* free any pCAL entry */
-#ifdef PNG_FREE_ME_SUPPORTED
-if ((mask & PNG_FREE_PCAL) & info_ptr->free_me)
-#else
-if (mask & PNG_FREE_PCAL)
-#endif
-{
- png_free(png_ptr, info_ptr->pcal_purpose);
- png_free(png_ptr, info_ptr->pcal_units);
- info_ptr->pcal_purpose = NULL;
- info_ptr->pcal_units = NULL;
- if (info_ptr->pcal_params != NULL)
- {
- int i;
- for (i = 0; i < (int)info_ptr->pcal_nparams; i++)
- {
- png_free(png_ptr, info_ptr->pcal_params[i]);
- info_ptr->pcal_params[i]=NULL;
- }
- png_free(png_ptr, info_ptr->pcal_params);
- info_ptr->pcal_params = NULL;
- }
- info_ptr->valid &= ~PNG_INFO_pCAL;
-}
-#endif
-
-#if defined(PNG_iCCP_SUPPORTED)
-/* free any iCCP entry */
-#ifdef PNG_FREE_ME_SUPPORTED
-if ((mask & PNG_FREE_ICCP) & info_ptr->free_me)
-#else
-if (mask & PNG_FREE_ICCP)
-#endif
-{
- png_free(png_ptr, info_ptr->iccp_name);
- png_free(png_ptr, info_ptr->iccp_profile);
- info_ptr->iccp_name = NULL;
- info_ptr->iccp_profile = NULL;
- info_ptr->valid &= ~PNG_INFO_iCCP;
-}
-#endif
-
-#if defined(PNG_sPLT_SUPPORTED)
-/* free a given sPLT entry, or (if num == -1) all sPLT entries */
-#ifdef PNG_FREE_ME_SUPPORTED
-if ((mask & PNG_FREE_SPLT) & info_ptr->free_me)
-#else
-if (mask & PNG_FREE_SPLT)
-#endif
-{
- if (num != -1)
- {
- if (info_ptr->splt_palettes)
- {
- png_free(png_ptr, info_ptr->splt_palettes[num].name);
- png_free(png_ptr, info_ptr->splt_palettes[num].entries);
- info_ptr->splt_palettes[num].name = NULL;
- info_ptr->splt_palettes[num].entries = NULL;
- }
- }
- else
- {
- if (info_ptr->splt_palettes_num)
- {
- int i;
- for (i = 0; i < (int)info_ptr->splt_palettes_num; i++)
- png_free_data(png_ptr, info_ptr, PNG_FREE_SPLT, i);
-
- png_free(png_ptr, info_ptr->splt_palettes);
- info_ptr->splt_palettes = NULL;
- info_ptr->splt_palettes_num = 0;
- }
- info_ptr->valid &= ~PNG_INFO_sPLT;
- }
-}
-#endif
-
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
- if (png_ptr->unknown_chunk.data)
- {
- png_free(png_ptr, png_ptr->unknown_chunk.data);
- png_ptr->unknown_chunk.data = NULL;
- }
-
-#ifdef PNG_FREE_ME_SUPPORTED
-if ((mask & PNG_FREE_UNKN) & info_ptr->free_me)
-#else
-if (mask & PNG_FREE_UNKN)
-#endif
-{
- if (num != -1)
- {
- if (info_ptr->unknown_chunks)
- {
- png_free(png_ptr, info_ptr->unknown_chunks[num].data);
- info_ptr->unknown_chunks[num].data = NULL;
- }
- }
- else
- {
- int i;
-
- if (info_ptr->unknown_chunks_num)
- {
- for (i = 0; i < (int)info_ptr->unknown_chunks_num; i++)
- png_free_data(png_ptr, info_ptr, PNG_FREE_UNKN, i);
-
- png_free(png_ptr, info_ptr->unknown_chunks);
- info_ptr->unknown_chunks = NULL;
- info_ptr->unknown_chunks_num = 0;
- }
- }
-}
-#endif
-
-#if defined(PNG_hIST_SUPPORTED)
-/* free any hIST entry */
-#ifdef PNG_FREE_ME_SUPPORTED
-if ((mask & PNG_FREE_HIST) & info_ptr->free_me)
-#else
-if ((mask & PNG_FREE_HIST) && (png_ptr->flags & PNG_FLAG_FREE_HIST))
-#endif
-{
- png_free(png_ptr, info_ptr->hist);
- info_ptr->hist = NULL;
- info_ptr->valid &= ~PNG_INFO_hIST;
-#ifndef PNG_FREE_ME_SUPPORTED
- png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
-#endif
-}
-#endif
-
-/* free any PLTE entry that was internally allocated */
-#ifdef PNG_FREE_ME_SUPPORTED
-if ((mask & PNG_FREE_PLTE) & info_ptr->free_me)
-#else
-if ((mask & PNG_FREE_PLTE) && (png_ptr->flags & PNG_FLAG_FREE_PLTE))
-#endif
-{
- png_zfree(png_ptr, info_ptr->palette);
- info_ptr->palette = NULL;
- info_ptr->valid &= ~PNG_INFO_PLTE;
-#ifndef PNG_FREE_ME_SUPPORTED
- png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
-#endif
- info_ptr->num_palette = 0;
-}
-
-#if defined(PNG_INFO_IMAGE_SUPPORTED)
-/* free any image bits attached to the info structure */
-#ifdef PNG_FREE_ME_SUPPORTED
-if ((mask & PNG_FREE_ROWS) & info_ptr->free_me)
-#else
-if (mask & PNG_FREE_ROWS)
-#endif
-{
- if (info_ptr->row_pointers)
- {
- int row;
- for (row = 0; row < (int)info_ptr->height; row++)
- {
- png_free(png_ptr, info_ptr->row_pointers[row]);
- info_ptr->row_pointers[row]=NULL;
- }
- png_free(png_ptr, info_ptr->row_pointers);
- info_ptr->row_pointers=NULL;
- }
- info_ptr->valid &= ~PNG_INFO_IDAT;
-}
-#endif
-
-#ifdef PNG_FREE_ME_SUPPORTED
- if (num == -1)
- info_ptr->free_me &= ~mask;
- else
- info_ptr->free_me &= ~(mask & ~PNG_FREE_MUL);
-#endif
-}
-
-/* This is an internal routine to free any memory that the info struct is
- * pointing to before re-using it or freeing the struct itself. Recall
- * that png_free() checks for NULL pointers for us.
- */
-void /* PRIVATE */
-png_info_destroy(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_info_destroy");
-
- png_free_data(png_ptr, info_ptr, PNG_FREE_ALL, -1);
-
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
- if (png_ptr->num_chunk_list)
- {
- png_free(png_ptr, png_ptr->chunk_list);
- png_ptr->chunk_list=NULL;
- png_ptr->num_chunk_list = 0;
- }
-#endif
-
- png_info_init_3(&info_ptr, png_sizeof(png_info));
-}
-#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
-
-/* This function returns a pointer to the io_ptr associated with the user
- * functions. The application should free any memory associated with this
- * pointer before png_write_destroy() or png_read_destroy() are called.
- */
-png_voidp PNGAPI
-png_get_io_ptr(png_structp png_ptr)
-{
- if (png_ptr == NULL) return (NULL);
- return (png_ptr->io_ptr);
-}
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-#if !defined(PNG_NO_STDIO)
-/* Initialize the default input/output functions for the PNG file. If you
- * use your own read or write routines, you can call either png_set_read_fn()
- * or png_set_write_fn() instead of png_init_io(). If you have defined
- * PNG_NO_STDIO, you must use a function of your own because "FILE *" isn't
- * necessarily available.
- */
-void PNGAPI
-png_init_io(png_structp png_ptr, png_FILE_p fp)
-{
- png_debug(1, "in png_init_io");
- if (png_ptr == NULL) return;
- png_ptr->io_ptr = (png_voidp)fp;
-}
-#endif
-
-#if defined(PNG_TIME_RFC1123_SUPPORTED)
-/* Convert the supplied time into an RFC 1123 string suitable for use in
- * a "Creation Time" or other text-based time string.
- */
-png_charp PNGAPI
-png_convert_to_rfc1123(png_structp png_ptr, png_timep ptime)
-{
- static PNG_CONST char short_months[12][4] =
- {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
-
- if (png_ptr == NULL) return (NULL);
- if (png_ptr->time_buffer == NULL)
- {
- png_ptr->time_buffer = (png_charp)png_malloc(png_ptr, (png_uint_32)(29*
- png_sizeof(char)));
- }
-
-#if defined(_WIN32_WCE)
- {
- wchar_t time_buf[29];
- wsprintf(time_buf, TEXT("%d %S %d %02d:%02d:%02d +0000"),
- ptime->day % 32, short_months[(ptime->month - 1) % 12],
- ptime->year, ptime->hour % 24, ptime->minute % 60,
- ptime->second % 61);
- WideCharToMultiByte(CP_ACP, 0, time_buf, -1, png_ptr->time_buffer, 29,
- NULL, NULL);
- }
-#else
-#ifdef USE_FAR_KEYWORD
- {
- char near_time_buf[29];
- png_snprintf6(near_time_buf, 29, "%d %s %d %02d:%02d:%02d +0000",
- ptime->day % 32, short_months[(ptime->month - 1) % 12],
- ptime->year, ptime->hour % 24, ptime->minute % 60,
- ptime->second % 61);
- png_memcpy(png_ptr->time_buffer, near_time_buf,
- 29*png_sizeof(char));
- }
-#else
- png_snprintf6(png_ptr->time_buffer, 29, "%d %s %d %02d:%02d:%02d +0000",
- ptime->day % 32, short_months[(ptime->month - 1) % 12],
- ptime->year, ptime->hour % 24, ptime->minute % 60,
- ptime->second % 61);
-#endif
-#endif /* _WIN32_WCE */
- return ((png_charp)png_ptr->time_buffer);
-}
-#endif /* PNG_TIME_RFC1123_SUPPORTED */
-
-#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
-
-png_charp PNGAPI
-png_get_copyright(png_structp png_ptr)
-{
- png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
- return ((png_charp) "\n libpng version 1.2.36 - May 7, 2009\n\
- Copyright (c) 1998-2008 Glenn Randers-Pehrson\n\
- Copyright (c) 1996-1997 Andreas Dilger\n\
- Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.\n");
-}
-
-/* The following return the library version as a short string in the
- * format 1.0.0 through 99.99.99zz. To get the version of *.h files
- * used with your application, print out PNG_LIBPNG_VER_STRING, which
- * is defined in png.h.
- * Note: now there is no difference between png_get_libpng_ver() and
- * png_get_header_ver(). Due to the version_nn_nn_nn typedef guard,
- * it is guaranteed that png.c uses the correct version of png.h.
- */
-png_charp PNGAPI
-png_get_libpng_ver(png_structp png_ptr)
-{
- /* Version of *.c files used when building libpng */
- png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
- return ((png_charp) PNG_LIBPNG_VER_STRING);
-}
-
-png_charp PNGAPI
-png_get_header_ver(png_structp png_ptr)
-{
- /* Version of *.h files used when building libpng */
- png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
- return ((png_charp) PNG_LIBPNG_VER_STRING);
-}
-
-png_charp PNGAPI
-png_get_header_version(png_structp png_ptr)
-{
- /* Returns longer string containing both version and date */
- png_ptr = png_ptr; /* silence compiler warning about unused png_ptr */
- return ((png_charp) PNG_HEADER_VERSION_STRING
-#ifndef PNG_READ_SUPPORTED
- " (NO READ SUPPORT)"
-#endif
- "\n");
-}
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-int PNGAPI
-png_handle_as_unknown(png_structp png_ptr, png_bytep chunk_name)
-{
- /* check chunk_name and return "keep" value if it's on the list, else 0 */
- int i;
- png_bytep p;
- if (png_ptr == NULL || chunk_name == NULL || png_ptr->num_chunk_list<=0)
- return 0;
- p = png_ptr->chunk_list + png_ptr->num_chunk_list*5 - 5;
- for (i = png_ptr->num_chunk_list; i; i--, p -= 5)
- if (!png_memcmp(chunk_name, p, 4))
- return ((int)*(p + 4));
- return 0;
-}
-#endif
-
-/* This function, added to libpng-1.0.6g, is untested. */
-int PNGAPI
-png_reset_zstream(png_structp png_ptr)
-{
- if (png_ptr == NULL) return Z_STREAM_ERROR;
- return (inflateReset(&png_ptr->zstream));
-}
-#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
-
-/* This function was added to libpng-1.0.7 */
-png_uint_32 PNGAPI
-png_access_version_number(void)
-{
- /* Version of *.c files used when building libpng */
- return((png_uint_32) PNG_LIBPNG_VER);
-}
-
-
-#if defined(PNG_READ_SUPPORTED) && defined(PNG_ASSEMBLER_CODE_SUPPORTED)
-#if !defined(PNG_1_0_X)
-/* this function was added to libpng 1.2.0 */
-int PNGAPI
-png_mmx_support(void)
-{
- /* obsolete, to be removed from libpng-1.4.0 */
- return -1;
-}
-#endif /* PNG_1_0_X */
-#endif /* PNG_READ_SUPPORTED && PNG_ASSEMBLER_CODE_SUPPORTED */
-
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-#ifdef PNG_SIZE_T
-/* Added at libpng version 1.2.6 */
- PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
-png_size_t PNGAPI
-png_convert_size(size_t size)
-{
- if (size > (png_size_t)-1)
- PNG_ABORT(); /* We haven't got access to png_ptr, so no png_error() */
- return ((png_size_t)size);
-}
-#endif /* PNG_SIZE_T */
-
-/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
-#if defined(PNG_cHRM_SUPPORTED)
-#if !defined(PNG_NO_CHECK_cHRM)
-
-/*
- Multiply two 32-bit numbers, V1 and V2, using 32-bit
- arithmetic, to produce a 64 bit result in the HI/LO words.
-
- A B
- x C D
- ------
- AD || BD
-AC || CB || 0
-
- where A and B are the high and low 16-bit words of V1,
- C and D are the 16-bit words of V2, AD is the product of
- A and D, and X || Y is (X << 16) + Y.
-*/
-
-void png_64bit_product (long v1, long v2, unsigned long *hi_product,
- unsigned long *lo_product)
-{
- int a, b, c, d;
- long lo, hi, x, y;
-
- a = (v1 >> 16) & 0xffff;
- b = v1 & 0xffff;
- c = (v2 >> 16) & 0xffff;
- d = v2 & 0xffff;
-
- lo = b * d; /* BD */
- x = a * d + c * b; /* AD + CB */
- y = ((lo >> 16) & 0xffff) + x;
-
- lo = (lo & 0xffff) | ((y & 0xffff) << 16);
- hi = (y >> 16) & 0xffff;
-
- hi += a * c; /* AC */
-
- *hi_product = (unsigned long)hi;
- *lo_product = (unsigned long)lo;
-}
-int /* private */
-png_check_cHRM_fixed(png_structp png_ptr,
- png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
- png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
- png_fixed_point blue_x, png_fixed_point blue_y)
-{
- int ret = 1;
- unsigned long xy_hi,xy_lo,yx_hi,yx_lo;
-
- png_debug(1, "in function png_check_cHRM_fixed");
- if (png_ptr == NULL)
- return 0;
-
- if (white_x < 0 || white_y <= 0 ||
- red_x < 0 || red_y < 0 ||
- green_x < 0 || green_y < 0 ||
- blue_x < 0 || blue_y < 0)
- {
- png_warning(png_ptr,
- "Ignoring attempt to set negative chromaticity value");
- ret = 0;
- }
- if (white_x > (png_fixed_point) PNG_UINT_31_MAX ||
- white_y > (png_fixed_point) PNG_UINT_31_MAX ||
- red_x > (png_fixed_point) PNG_UINT_31_MAX ||
- red_y > (png_fixed_point) PNG_UINT_31_MAX ||
- green_x > (png_fixed_point) PNG_UINT_31_MAX ||
- green_y > (png_fixed_point) PNG_UINT_31_MAX ||
- blue_x > (png_fixed_point) PNG_UINT_31_MAX ||
- blue_y > (png_fixed_point) PNG_UINT_31_MAX )
- {
- png_warning(png_ptr,
- "Ignoring attempt to set chromaticity value exceeding 21474.83");
- ret = 0;
- }
- if (white_x > 100000L - white_y)
- {
- png_warning(png_ptr, "Invalid cHRM white point");
- ret = 0;
- }
- if (red_x > 100000L - red_y)
- {
- png_warning(png_ptr, "Invalid cHRM red point");
- ret = 0;
- }
- if (green_x > 100000L - green_y)
- {
- png_warning(png_ptr, "Invalid cHRM green point");
- ret = 0;
- }
- if (blue_x > 100000L - blue_y)
- {
- png_warning(png_ptr, "Invalid cHRM blue point");
- ret = 0;
- }
-
- png_64bit_product(green_x - red_x, blue_y - red_y, &xy_hi, &xy_lo);
- png_64bit_product(green_y - red_y, blue_x - red_x, &yx_hi, &yx_lo);
-
- if (xy_hi == yx_hi && xy_lo == yx_lo)
- {
- png_warning(png_ptr,
- "Ignoring attempt to set cHRM RGB triangle with zero area");
- ret = 0;
- }
-
- return ret;
-}
-#endif /* NO_PNG_CHECK_cHRM */
-#endif /* PNG_cHRM_SUPPORTED */
-#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
diff --git a/navit/support/libpng/png.h b/navit/support/libpng/png.h
deleted file mode 100644
index 267677ad6..000000000
--- a/navit/support/libpng/png.h
+++ /dev/null
@@ -1,3682 +0,0 @@
-/* png.h - header file for PNG reference library
- *
- * libpng version 1.2.36 - May 7, 2009
- * Copyright (c) 1998-2009 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * Authors and maintainers:
- * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
- * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
- * libpng versions 0.97, January 1998, through 1.2.36 - May 7, 2009: Glenn
- * See also "Contributing Authors", below.
- *
- * Note about libpng version numbers:
- *
- * Due to various miscommunications, unforeseen code incompatibilities
- * and occasional factors outside the authors' control, version numbering
- * on the library has not always been consistent and straightforward.
- * The following table summarizes matters since version 0.89c, which was
- * the first widely used release:
- *
- * source png.h png.h shared-lib
- * version string int version
- * ------- ------ ----- ----------
- * 0.89c "1.0 beta 3" 0.89 89 1.0.89
- * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90]
- * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95]
- * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96]
- * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97]
- * 0.97c 0.97 97 2.0.97
- * 0.98 0.98 98 2.0.98
- * 0.99 0.99 98 2.0.99
- * 0.99a-m 0.99 99 2.0.99
- * 1.00 1.00 100 2.1.0 [100 should be 10000]
- * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000]
- * 1.0.1 png.h string is 10001 2.1.0
- * 1.0.1a-e identical to the 10002 from here on, the shared library
- * 1.0.2 source version) 10002 is 2.V where V is the source code
- * 1.0.2a-b 10003 version, except as noted.
- * 1.0.3 10003
- * 1.0.3a-d 10004
- * 1.0.4 10004
- * 1.0.4a-f 10005
- * 1.0.5 (+ 2 patches) 10005
- * 1.0.5a-d 10006
- * 1.0.5e-r 10100 (not source compatible)
- * 1.0.5s-v 10006 (not binary compatible)
- * 1.0.6 (+ 3 patches) 10006 (still binary incompatible)
- * 1.0.6d-f 10007 (still binary incompatible)
- * 1.0.6g 10007
- * 1.0.6h 10007 10.6h (testing xy.z so-numbering)
- * 1.0.6i 10007 10.6i
- * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0)
- * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible)
- * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible)
- * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible)
- * 1.0.7 1 10007 (still compatible)
- * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4
- * 1.0.8rc1 1 10008 2.1.0.8rc1
- * 1.0.8 1 10008 2.1.0.8
- * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6
- * 1.0.9rc1 1 10009 2.1.0.9rc1
- * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10
- * 1.0.9rc2 1 10009 2.1.0.9rc2
- * 1.0.9 1 10009 2.1.0.9
- * 1.0.10beta1 1 10010 2.1.0.10beta1
- * 1.0.10rc1 1 10010 2.1.0.10rc1
- * 1.0.10 1 10010 2.1.0.10
- * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3
- * 1.0.11rc1 1 10011 2.1.0.11rc1
- * 1.0.11 1 10011 2.1.0.11
- * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2
- * 1.0.12rc1 2 10012 2.1.0.12rc1
- * 1.0.12 2 10012 2.1.0.12
- * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned)
- * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2
- * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5
- * 1.2.0rc1 3 10200 3.1.2.0rc1
- * 1.2.0 3 10200 3.1.2.0
- * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4
- * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2
- * 1.2.1 3 10201 3.1.2.1
- * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6
- * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1
- * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1
- * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1
- * 1.0.13 10 10013 10.so.0.1.0.13
- * 1.2.2 12 10202 12.so.0.1.2.2
- * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6
- * 1.2.3 12 10203 12.so.0.1.2.3
- * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3
- * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1
- * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1
- * 1.0.14 10 10014 10.so.0.1.0.14
- * 1.2.4 13 10204 12.so.0.1.2.4
- * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2
- * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3
- * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3
- * 1.0.15 10 10015 10.so.0.1.0.15
- * 1.2.5 13 10205 12.so.0.1.2.5
- * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4
- * 1.0.16 10 10016 10.so.0.1.0.16
- * 1.2.6 13 10206 12.so.0.1.2.6
- * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2
- * 1.0.17rc1 10 10017 10.so.0.1.0.17rc1
- * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1
- * 1.0.17 10 10017 10.so.0.1.0.17
- * 1.2.7 13 10207 12.so.0.1.2.7
- * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5
- * 1.0.18rc1-5 10 10018 10.so.0.1.0.18rc1-5
- * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5
- * 1.0.18 10 10018 10.so.0.1.0.18
- * 1.2.8 13 10208 12.so.0.1.2.8
- * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3
- * 1.2.9beta4-11 13 10209 12.so.0.9[.0]
- * 1.2.9rc1 13 10209 12.so.0.9[.0]
- * 1.2.9 13 10209 12.so.0.9[.0]
- * 1.2.10beta1-8 13 10210 12.so.0.10[.0]
- * 1.2.10rc1-3 13 10210 12.so.0.10[.0]
- * 1.2.10 13 10210 12.so.0.10[.0]
- * 1.2.11beta1-4 13 10211 12.so.0.11[.0]
- * 1.0.19rc1-5 10 10019 10.so.0.19[.0]
- * 1.2.11rc1-5 13 10211 12.so.0.11[.0]
- * 1.0.19 10 10019 10.so.0.19[.0]
- * 1.2.11 13 10211 12.so.0.11[.0]
- * 1.0.20 10 10020 10.so.0.20[.0]
- * 1.2.12 13 10212 12.so.0.12[.0]
- * 1.2.13beta1 13 10213 12.so.0.13[.0]
- * 1.0.21 10 10021 10.so.0.21[.0]
- * 1.2.13 13 10213 12.so.0.13[.0]
- * 1.2.14beta1-2 13 10214 12.so.0.14[.0]
- * 1.0.22rc1 10 10022 10.so.0.22[.0]
- * 1.2.14rc1 13 10214 12.so.0.14[.0]
- * 1.0.22 10 10022 10.so.0.22[.0]
- * 1.2.14 13 10214 12.so.0.14[.0]
- * 1.2.15beta1-6 13 10215 12.so.0.15[.0]
- * 1.0.23rc1-5 10 10023 10.so.0.23[.0]
- * 1.2.15rc1-5 13 10215 12.so.0.15[.0]
- * 1.0.23 10 10023 10.so.0.23[.0]
- * 1.2.15 13 10215 12.so.0.15[.0]
- * 1.2.16beta1-2 13 10216 12.so.0.16[.0]
- * 1.2.16rc1 13 10216 12.so.0.16[.0]
- * 1.0.24 10 10024 10.so.0.24[.0]
- * 1.2.16 13 10216 12.so.0.16[.0]
- * 1.2.17beta1-2 13 10217 12.so.0.17[.0]
- * 1.0.25rc1 10 10025 10.so.0.25[.0]
- * 1.2.17rc1-3 13 10217 12.so.0.17[.0]
- * 1.0.25 10 10025 10.so.0.25[.0]
- * 1.2.17 13 10217 12.so.0.17[.0]
- * 1.0.26 10 10026 10.so.0.26[.0]
- * 1.2.18 13 10218 12.so.0.18[.0]
- * 1.2.19beta1-31 13 10219 12.so.0.19[.0]
- * 1.0.27rc1-6 10 10027 10.so.0.27[.0]
- * 1.2.19rc1-6 13 10219 12.so.0.19[.0]
- * 1.0.27 10 10027 10.so.0.27[.0]
- * 1.2.19 13 10219 12.so.0.19[.0]
- * 1.2.20beta01-04 13 10220 12.so.0.20[.0]
- * 1.0.28rc1-6 10 10028 10.so.0.28[.0]
- * 1.2.20rc1-6 13 10220 12.so.0.20[.0]
- * 1.0.28 10 10028 10.so.0.28[.0]
- * 1.2.20 13 10220 12.so.0.20[.0]
- * 1.2.21beta1-2 13 10221 12.so.0.21[.0]
- * 1.2.21rc1-3 13 10221 12.so.0.21[.0]
- * 1.0.29 10 10029 10.so.0.29[.0]
- * 1.2.21 13 10221 12.so.0.21[.0]
- * 1.2.22beta1-4 13 10222 12.so.0.22[.0]
- * 1.0.30rc1 10 10030 10.so.0.30[.0]
- * 1.2.22rc1 13 10222 12.so.0.22[.0]
- * 1.0.30 10 10030 10.so.0.30[.0]
- * 1.2.22 13 10222 12.so.0.22[.0]
- * 1.2.23beta01-05 13 10223 12.so.0.23[.0]
- * 1.2.23rc01 13 10223 12.so.0.23[.0]
- * 1.2.23 13 10223 12.so.0.23[.0]
- * 1.2.24beta01-02 13 10224 12.so.0.24[.0]
- * 1.2.24rc01 13 10224 12.so.0.24[.0]
- * 1.2.24 13 10224 12.so.0.24[.0]
- * 1.2.25beta01-06 13 10225 12.so.0.25[.0]
- * 1.2.25rc01-02 13 10225 12.so.0.25[.0]
- * 1.0.31 10 10031 10.so.0.31[.0]
- * 1.2.25 13 10225 12.so.0.25[.0]
- * 1.2.26beta01-06 13 10226 12.so.0.26[.0]
- * 1.2.26rc01 13 10226 12.so.0.26[.0]
- * 1.2.26 13 10226 12.so.0.26[.0]
- * 1.0.32 10 10032 10.so.0.32[.0]
- * 1.2.27beta01-06 13 10227 12.so.0.27[.0]
- * 1.2.27rc01 13 10227 12.so.0.27[.0]
- * 1.0.33 10 10033 10.so.0.33[.0]
- * 1.2.27 13 10227 12.so.0.27[.0]
- * 1.0.34 10 10034 10.so.0.34[.0]
- * 1.2.28 13 10228 12.so.0.28[.0]
- * 1.2.29beta01-03 13 10229 12.so.0.29[.0]
- * 1.2.29rc01 13 10229 12.so.0.29[.0]
- * 1.0.35 10 10035 10.so.0.35[.0]
- * 1.2.29 13 10229 12.so.0.29[.0]
- * 1.0.37 10 10037 10.so.0.37[.0]
- * 1.2.30beta01-04 13 10230 12.so.0.30[.0]
- * 1.0.38rc01-08 10 10038 10.so.0.38[.0]
- * 1.2.30rc01-08 13 10230 12.so.0.30[.0]
- * 1.0.38 10 10038 10.so.0.38[.0]
- * 1.2.30 13 10230 12.so.0.30[.0]
- * 1.0.39rc01-03 10 10039 10.so.0.39[.0]
- * 1.2.31rc01-03 13 10231 12.so.0.31[.0]
- * 1.0.39 10 10039 10.so.0.39[.0]
- * 1.2.31 13 10231 12.so.0.31[.0]
- * 1.2.32beta01-02 13 10232 12.so.0.32[.0]
- * 1.0.40rc01 10 10040 10.so.0.40[.0]
- * 1.2.32rc01 13 10232 12.so.0.32[.0]
- * 1.0.40 10 10040 10.so.0.40[.0]
- * 1.2.32 13 10232 12.so.0.32[.0]
- * 1.2.33beta01-02 13 10233 12.so.0.33[.0]
- * 1.2.33rc01-02 13 10233 12.so.0.33[.0]
- * 1.0.41rc01 10 10041 10.so.0.41[.0]
- * 1.2.33 13 10233 12.so.0.33[.0]
- * 1.0.41 10 10041 10.so.0.41[.0]
- * 1.2.34beta01-07 13 10234 12.so.0.34[.0]
- * 1.0.42rc01 10 10042 10.so.0.42[.0]
- * 1.2.34rc01 13 10234 12.so.0.34[.0]
- * 1.0.42 10 10042 10.so.0.42[.0]
- * 1.2.34 13 10234 12.so.0.34[.0]
- * 1.2.35beta01-03 13 10235 12.so.0.35[.0]
- * 1.0.43rc01-02 10 10043 10.so.0.43[.0]
- * 1.2.35rc01-02 13 10235 12.so.0.35[.0]
- * 1.0.43 10 10043 10.so.0.43[.0]
- * 1.2.35 13 10235 12.so.0.35[.0]
- * 1.2.36beta01-05 13 10236 12.so.0.36[.0]
- * 1.2.36rc01 13 10236 12.so.0.36[.0]
- * 1.0.44 10 10044 10.so.0.44[.0]
- * 1.2.36 13 10236 12.so.0.36[.0]
- *
- * Henceforth the source version will match the shared-library major
- * and minor numbers; the shared-library major version number will be
- * used for changes in backward compatibility, as it is intended. The
- * PNG_LIBPNG_VER macro, which is not used within libpng but is available
- * for applications, is an unsigned integer of the form xyyzz corresponding
- * to the source version x.y.z (leading zeros in y and z). Beta versions
- * were given the previous public release number plus a letter, until
- * version 1.0.6j; from then on they were given the upcoming public
- * release number plus "betaNN" or "rcNN".
- *
- * Binary incompatibility exists only when applications make direct access
- * to the info_ptr or png_ptr members through png.h, and the compiled
- * application is loaded with a different version of the library.
- *
- * DLLNUM will change each time there are forward or backward changes
- * in binary compatibility (e.g., when a new feature is added).
- *
- * See libpng.txt or libpng.3 for more information. The PNG specification
- * is available as a W3C Recommendation and as an ISO Specification,
- * <http://www.w3.org/TR/2003/REC-PNG-20031110/
- */
-
-/*
- * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
- *
- * If you modify libpng you may insert additional notices immediately following
- * this sentence.
- *
- * libpng versions 1.2.6, August 15, 2004, through 1.2.36, May 7, 2009, are
- * Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are
- * distributed according to the same disclaimer and license as libpng-1.2.5
- * with the following individual added to the list of Contributing Authors:
- *
- * Cosmin Truta
- *
- * libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
- * Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
- * distributed according to the same disclaimer and license as libpng-1.0.6
- * with the following individuals added to the list of Contributing Authors:
- *
- * Simon-Pierre Cadieux
- * Eric S. Raymond
- * Gilles Vollant
- *
- * and with the following additions to the disclaimer:
- *
- * There is no warranty against interference with your enjoyment of the
- * library or against infringement. There is no warranty that our
- * efforts or the library will fulfill any of your particular purposes
- * or needs. This library is provided with all faults, and the entire
- * risk of satisfactory quality, performance, accuracy, and effort is with
- * the user.
- *
- * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
- * Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are
- * distributed according to the same disclaimer and license as libpng-0.96,
- * with the following individuals added to the list of Contributing Authors:
- *
- * Tom Lane
- * Glenn Randers-Pehrson
- * Willem van Schaik
- *
- * libpng versions 0.89, June 1996, through 0.96, May 1997, are
- * Copyright (c) 1996, 1997 Andreas Dilger
- * Distributed according to the same disclaimer and license as libpng-0.88,
- * with the following individuals added to the list of Contributing Authors:
- *
- * John Bowler
- * Kevin Bracey
- * Sam Bushell
- * Magnus Holmgren
- * Greg Roelofs
- * Tom Tanner
- *
- * libpng versions 0.5, May 1995, through 0.88, January 1996, are
- * Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
- *
- * For the purposes of this copyright and license, "Contributing Authors"
- * is defined as the following set of individuals:
- *
- * Andreas Dilger
- * Dave Martindale
- * Guy Eric Schalnat
- * Paul Schmidt
- * Tim Wegner
- *
- * The PNG Reference Library is supplied "AS IS". The Contributing Authors
- * and Group 42, Inc. disclaim all warranties, expressed or implied,
- * including, without limitation, the warranties of merchantability and of
- * fitness for any purpose. The Contributing Authors and Group 42, Inc.
- * assume no liability for direct, indirect, incidental, special, exemplary,
- * or consequential damages, which may result from the use of the PNG
- * Reference Library, even if advised of the possibility of such damage.
- *
- * Permission is hereby granted to use, copy, modify, and distribute this
- * source code, or portions hereof, for any purpose, without fee, subject
- * to the following restrictions:
- *
- * 1. The origin of this source code must not be misrepresented.
- *
- * 2. Altered versions must be plainly marked as such and
- * must not be misrepresented as being the original source.
- *
- * 3. This Copyright notice may not be removed or altered from
- * any source or altered source distribution.
- *
- * The Contributing Authors and Group 42, Inc. specifically permit, without
- * fee, and encourage the use of this source code as a component to
- * supporting the PNG file format in commercial products. If you use this
- * source code in a product, acknowledgment is not required but would be
- * appreciated.
- */
-
-/*
- * A "png_get_copyright" function is available, for convenient use in "about"
- * boxes and the like:
- *
- * printf("%s",png_get_copyright(NULL));
- *
- * Also, the PNG logo (in PNG format, of course) is supplied in the
- * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
- */
-
-/*
- * Libpng is OSI Certified Open Source Software. OSI Certified is a
- * certification mark of the Open Source Initiative.
- */
-
-/*
- * The contributing authors would like to thank all those who helped
- * with testing, bug fixes, and patience. This wouldn't have been
- * possible without all of you.
- *
- * Thanks to Frank J. T. Wojcik for helping with the documentation.
- */
-
-/*
- * Y2K compliance in libpng:
- * =========================
- *
- * May 7, 2009
- *
- * Since the PNG Development group is an ad-hoc body, we can't make
- * an official declaration.
- *
- * This is your unofficial assurance that libpng from version 0.71 and
- * upward through 1.2.36 are Y2K compliant. It is my belief that earlier
- * versions were also Y2K compliant.
- *
- * Libpng only has three year fields. One is a 2-byte unsigned integer
- * that will hold years up to 65535. The other two hold the date in text
- * format, and will hold years up to 9999.
- *
- * The integer is
- * "png_uint_16 year" in png_time_struct.
- *
- * The strings are
- * "png_charp time_buffer" in png_struct and
- * "near_time_buffer", which is a local character string in png.c.
- *
- * There are seven time-related functions:
- * png.c: png_convert_to_rfc_1123() in png.c
- * (formerly png_convert_to_rfc_1152() in error)
- * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c
- * png_convert_from_time_t() in pngwrite.c
- * png_get_tIME() in pngget.c
- * png_handle_tIME() in pngrutil.c, called in pngread.c
- * png_set_tIME() in pngset.c
- * png_write_tIME() in pngwutil.c, called in pngwrite.c
- *
- * All handle dates properly in a Y2K environment. The
- * png_convert_from_time_t() function calls gmtime() to convert from system
- * clock time, which returns (year - 1900), which we properly convert to
- * the full 4-digit year. There is a possibility that applications using
- * libpng are not passing 4-digit years into the png_convert_to_rfc_1123()
- * function, or that they are incorrectly passing only a 2-digit year
- * instead of "year - 1900" into the png_convert_from_struct_tm() function,
- * but this is not under our control. The libpng documentation has always
- * stated that it works with 4-digit years, and the APIs have been
- * documented as such.
- *
- * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned
- * integer to hold the year, and can hold years as large as 65535.
- *
- * zlib, upon which libpng depends, is also Y2K compliant. It contains
- * no date-related code.
- *
- * Glenn Randers-Pehrson
- * libpng maintainer
- * PNG Development Group
- */
-
-#ifndef PNG_H
-#define PNG_H
-
-/* This is not the place to learn how to use libpng. The file libpng.txt
- * describes how to use libpng, and the file example.c summarizes it
- * with some code on which to build. This file is useful for looking
- * at the actual function definitions and structure components.
- */
-
-/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.2.36"
-#define PNG_HEADER_VERSION_STRING \
- " libpng version 1.2.36 - May 7, 2009\n"
-
-#define PNG_LIBPNG_VER_SONUM 0
-#define PNG_LIBPNG_VER_DLLNUM 13
-
-/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
-#define PNG_LIBPNG_VER_MAJOR 1
-#define PNG_LIBPNG_VER_MINOR 2
-#define PNG_LIBPNG_VER_RELEASE 36
-/* This should match the numeric part of the final component of
- * PNG_LIBPNG_VER_STRING, omitting any leading zero: */
-
-#define PNG_LIBPNG_VER_BUILD 0
-
-/* Release Status */
-#define PNG_LIBPNG_BUILD_ALPHA 1
-#define PNG_LIBPNG_BUILD_BETA 2
-#define PNG_LIBPNG_BUILD_RC 3
-#define PNG_LIBPNG_BUILD_STABLE 4
-#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
-
-/* Release-Specific Flags */
-#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
- PNG_LIBPNG_BUILD_STABLE only */
-#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with
- PNG_LIBPNG_BUILD_SPECIAL */
-#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
- PNG_LIBPNG_BUILD_PRIVATE */
-
-#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
-
-/* Careful here. At one time, Guy wanted to use 082, but that would be octal.
- * We must not include leading zeros.
- * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only
- * version 1.0.0 was mis-numbered 100 instead of 10000). From
- * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release */
-#define PNG_LIBPNG_VER 10236 /* 1.2.36 */
-
-#ifndef PNG_VERSION_INFO_ONLY
-/* include the compression library's header */
-#include "zlib.h"
-#endif
-
-/* include all user configurable info, including optional assembler routines */
-#include "pngconf.h"
-
-/*
- * Added at libpng-1.2.8 */
-/* Ref MSDN: Private as priority over Special
- * VS_FF_PRIVATEBUILD File *was not* built using standard release
- * procedures. If this value is given, the StringFileInfo block must
- * contain a PrivateBuild string.
- *
- * VS_FF_SPECIALBUILD File *was* built by the original company using
- * standard release procedures but is a variation of the standard
- * file of the same version number. If this value is given, the
- * StringFileInfo block must contain a SpecialBuild string.
- */
-
-#if defined(PNG_USER_PRIVATEBUILD)
-# define PNG_LIBPNG_BUILD_TYPE \
- (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE)
-#else
-# if defined(PNG_LIBPNG_SPECIALBUILD)
-# define PNG_LIBPNG_BUILD_TYPE \
- (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL)
-# else
-# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE)
-# endif
-#endif
-
-#ifndef PNG_VERSION_INFO_ONLY
-
-/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/* This file is arranged in several sections. The first section contains
- * structure and type definitions. The second section contains the external
- * library functions, while the third has the internal library functions,
- * which applications aren't expected to use directly.
- */
-
-#ifndef PNG_NO_TYPECAST_NULL
-#define int_p_NULL (int *)NULL
-#define png_bytep_NULL (png_bytep)NULL
-#define png_bytepp_NULL (png_bytepp)NULL
-#define png_doublep_NULL (png_doublep)NULL
-#define png_error_ptr_NULL (png_error_ptr)NULL
-#define png_flush_ptr_NULL (png_flush_ptr)NULL
-#define png_free_ptr_NULL (png_free_ptr)NULL
-#define png_infopp_NULL (png_infopp)NULL
-#define png_malloc_ptr_NULL (png_malloc_ptr)NULL
-#define png_read_status_ptr_NULL (png_read_status_ptr)NULL
-#define png_rw_ptr_NULL (png_rw_ptr)NULL
-#define png_structp_NULL (png_structp)NULL
-#define png_uint_16p_NULL (png_uint_16p)NULL
-#define png_voidp_NULL (png_voidp)NULL
-#define png_write_status_ptr_NULL (png_write_status_ptr)NULL
-#else
-#define int_p_NULL NULL
-#define png_bytep_NULL NULL
-#define png_bytepp_NULL NULL
-#define png_doublep_NULL NULL
-#define png_error_ptr_NULL NULL
-#define png_flush_ptr_NULL NULL
-#define png_free_ptr_NULL NULL
-#define png_infopp_NULL NULL
-#define png_malloc_ptr_NULL NULL
-#define png_read_status_ptr_NULL NULL
-#define png_rw_ptr_NULL NULL
-#define png_structp_NULL NULL
-#define png_uint_16p_NULL NULL
-#define png_voidp_NULL NULL
-#define png_write_status_ptr_NULL NULL
-#endif
-
-/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
-#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
-/* Version information for C files, stored in png.c. This had better match
- * the version above.
- */
-#ifdef PNG_USE_GLOBAL_ARRAYS
-PNG_EXPORT_VAR (PNG_CONST char) png_libpng_ver[18];
- /* need room for 99.99.99beta99z */
-#else
-#define png_libpng_ver png_get_header_ver(NULL)
-#endif
-
-#ifdef PNG_USE_GLOBAL_ARRAYS
-/* This was removed in version 1.0.5c */
-/* Structures to facilitate easy interlacing. See png.c for more details */
-PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_start[7];
-PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_inc[7];
-PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_ystart[7];
-PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_yinc[7];
-PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_mask[7];
-PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_dsp_mask[7];
-/* This isn't currently used. If you need it, see png.c for more details.
-PNG_EXPORT_VAR (PNG_CONST int FARDATA) png_pass_height[7];
-*/
-#endif
-
-#endif /* PNG_NO_EXTERN */
-
-/* Three color definitions. The order of the red, green, and blue, (and the
- * exact size) is not important, although the size of the fields need to
- * be png_byte or png_uint_16 (as defined below).
- */
-typedef struct png_color_struct
-{
- png_byte red;
- png_byte green;
- png_byte blue;
-} png_color;
-typedef png_color FAR * png_colorp;
-typedef png_color FAR * FAR * png_colorpp;
-
-typedef struct png_color_16_struct
-{
- png_byte index; /* used for palette files */
- png_uint_16 red; /* for use in red green blue files */
- png_uint_16 green;
- png_uint_16 blue;
- png_uint_16 gray; /* for use in grayscale files */
-} png_color_16;
-typedef png_color_16 FAR * png_color_16p;
-typedef png_color_16 FAR * FAR * png_color_16pp;
-
-typedef struct png_color_8_struct
-{
- png_byte red; /* for use in red green blue files */
- png_byte green;
- png_byte blue;
- png_byte gray; /* for use in grayscale files */
- png_byte alpha; /* for alpha channel files */
-} png_color_8;
-typedef png_color_8 FAR * png_color_8p;
-typedef png_color_8 FAR * FAR * png_color_8pp;
-
-/*
- * The following two structures are used for the in-core representation
- * of sPLT chunks.
- */
-typedef struct png_sPLT_entry_struct
-{
- png_uint_16 red;
- png_uint_16 green;
- png_uint_16 blue;
- png_uint_16 alpha;
- png_uint_16 frequency;
-} png_sPLT_entry;
-typedef png_sPLT_entry FAR * png_sPLT_entryp;
-typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp;
-
-/* When the depth of the sPLT palette is 8 bits, the color and alpha samples
- * occupy the LSB of their respective members, and the MSB of each member
- * is zero-filled. The frequency member always occupies the full 16 bits.
- */
-
-typedef struct png_sPLT_struct
-{
- png_charp name; /* palette name */
- png_byte depth; /* depth of palette samples */
- png_sPLT_entryp entries; /* palette entries */
- png_int_32 nentries; /* number of palette entries */
-} png_sPLT_t;
-typedef png_sPLT_t FAR * png_sPLT_tp;
-typedef png_sPLT_t FAR * FAR * png_sPLT_tpp;
-
-#ifdef PNG_TEXT_SUPPORTED
-/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file,
- * and whether that contents is compressed or not. The "key" field
- * points to a regular zero-terminated C string. The "text", "lang", and
- * "lang_key" fields can be regular C strings, empty strings, or NULL pointers.
- * However, the * structure returned by png_get_text() will always contain
- * regular zero-terminated C strings (possibly empty), never NULL pointers,
- * so they can be safely used in printf() and other string-handling functions.
- */
-typedef struct png_text_struct
-{
- int compression; /* compression value:
- -1: tEXt, none
- 0: zTXt, deflate
- 1: iTXt, none
- 2: iTXt, deflate */
- png_charp key; /* keyword, 1-79 character description of "text" */
- png_charp text; /* comment, may be an empty string (ie "")
- or a NULL pointer */
- png_size_t text_length; /* length of the text string */
-#ifdef PNG_iTXt_SUPPORTED
- png_size_t itxt_length; /* length of the itxt string */
- png_charp lang; /* language code, 0-79 characters
- or a NULL pointer */
- png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
- chars or a NULL pointer */
-#endif
-} png_text;
-typedef png_text FAR * png_textp;
-typedef png_text FAR * FAR * png_textpp;
-#endif
-
-/* Supported compression types for text in PNG files (tEXt, and zTXt).
- * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */
-#define PNG_TEXT_COMPRESSION_NONE_WR -3
-#define PNG_TEXT_COMPRESSION_zTXt_WR -2
-#define PNG_TEXT_COMPRESSION_NONE -1
-#define PNG_TEXT_COMPRESSION_zTXt 0
-#define PNG_ITXT_COMPRESSION_NONE 1
-#define PNG_ITXT_COMPRESSION_zTXt 2
-#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */
-
-/* png_time is a way to hold the time in an machine independent way.
- * Two conversions are provided, both from time_t and struct tm. There
- * is no portable way to convert to either of these structures, as far
- * as I know. If you know of a portable way, send it to me. As a side
- * note - PNG has always been Year 2000 compliant!
- */
-typedef struct png_time_struct
-{
- png_uint_16 year; /* full year, as in, 1995 */
- png_byte month; /* month of year, 1 - 12 */
- png_byte day; /* day of month, 1 - 31 */
- png_byte hour; /* hour of day, 0 - 23 */
- png_byte minute; /* minute of hour, 0 - 59 */
- png_byte second; /* second of minute, 0 - 60 (for leap seconds) */
-} png_time;
-typedef png_time FAR * png_timep;
-typedef png_time FAR * FAR * png_timepp;
-
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
-/* png_unknown_chunk is a structure to hold queued chunks for which there is
- * no specific support. The idea is that we can use this to queue
- * up private chunks for output even though the library doesn't actually
- * know about their semantics.
- */
-#define PNG_CHUNK_NAME_LENGTH 5
-typedef struct png_unknown_chunk_t
-{
- png_byte name[PNG_CHUNK_NAME_LENGTH];
- png_byte *data;
- png_size_t size;
-
- /* libpng-using applications should NOT directly modify this byte. */
- png_byte location; /* mode of operation at read time */
-}
-png_unknown_chunk;
-typedef png_unknown_chunk FAR * png_unknown_chunkp;
-typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp;
-#endif
-
-/* png_info is a structure that holds the information in a PNG file so
- * that the application can find out the characteristics of the image.
- * If you are reading the file, this structure will tell you what is
- * in the PNG file. If you are writing the file, fill in the information
- * you want to put into the PNG file, then call png_write_info().
- * The names chosen should be very close to the PNG specification, so
- * consult that document for information about the meaning of each field.
- *
- * With libpng < 0.95, it was only possible to directly set and read the
- * the values in the png_info_struct, which meant that the contents and
- * order of the values had to remain fixed. With libpng 0.95 and later,
- * however, there are now functions that abstract the contents of
- * png_info_struct from the application, so this makes it easier to use
- * libpng with dynamic libraries, and even makes it possible to use
- * libraries that don't have all of the libpng ancillary chunk-handing
- * functionality.
- *
- * In any case, the order of the parameters in png_info_struct should NOT
- * be changed for as long as possible to keep compatibility with applications
- * that use the old direct-access method with png_info_struct.
- *
- * The following members may have allocated storage attached that should be
- * cleaned up before the structure is discarded: palette, trans, text,
- * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
- * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
- * are automatically freed when the info structure is deallocated, if they were
- * allocated internally by libpng. This behavior can be changed by means
- * of the png_data_freer() function.
- *
- * More allocation details: all the chunk-reading functions that
- * change these members go through the corresponding png_set_*
- * functions. A function to clear these members is available: see
- * png_free_data(). The png_set_* functions do not depend on being
- * able to point info structure members to any of the storage they are
- * passed (they make their own copies), EXCEPT that the png_set_text
- * functions use the same storage passed to them in the text_ptr or
- * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
- * functions do not make their own copies.
- */
-typedef struct png_info_struct
-{
- /* the following are necessary for every PNG file */
- png_uint_32 width; /* width of image in pixels (from IHDR) */
- png_uint_32 height; /* height of image in pixels (from IHDR) */
- png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
- png_uint_32 rowbytes; /* bytes needed to hold an untransformed row */
- png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
- png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
- png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
- png_byte bit_depth; /* 1, 2, 4, 8, or 16 bits/channel (from IHDR) */
- png_byte color_type; /* see PNG_COLOR_TYPE_ below (from IHDR) */
- /* The following three should have been named *_method not *_type */
- png_byte compression_type; /* must be PNG_COMPRESSION_TYPE_BASE (IHDR) */
- png_byte filter_type; /* must be PNG_FILTER_TYPE_BASE (from IHDR) */
- png_byte interlace_type; /* One of PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
-
- /* The following is informational only on read, and not used on writes. */
- png_byte channels; /* number of data channels per pixel (1, 2, 3, 4) */
- png_byte pixel_depth; /* number of bits per pixel */
- png_byte spare_byte; /* to align the data, and for future use */
- png_byte signature[8]; /* magic bytes read by libpng from start of file */
-
- /* The rest of the data is optional. If you are reading, check the
- * valid field to see if the information in these are valid. If you
- * are writing, set the valid field to those chunks you want written,
- * and initialize the appropriate fields below.
- */
-
-#if defined(PNG_gAMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
- /* The gAMA chunk describes the gamma characteristics of the system
- * on which the image was created, normally in the range [1.0, 2.5].
- * Data is valid if (valid & PNG_INFO_gAMA) is non-zero.
- */
- float gamma; /* gamma value of image, if (valid & PNG_INFO_gAMA) */
-#endif
-
-#if defined(PNG_sRGB_SUPPORTED)
- /* GR-P, 0.96a */
- /* Data valid if (valid & PNG_INFO_sRGB) non-zero. */
- png_byte srgb_intent; /* sRGB rendering intent [0, 1, 2, or 3] */
-#endif
-
-#if defined(PNG_TEXT_SUPPORTED)
- /* The tEXt, and zTXt chunks contain human-readable textual data in
- * uncompressed, compressed, and optionally compressed forms, respectively.
- * The data in "text" is an array of pointers to uncompressed,
- * null-terminated C strings. Each chunk has a keyword that describes the
- * textual data contained in that chunk. Keywords are not required to be
- * unique, and the text string may be empty. Any number of text chunks may
- * be in an image.
- */
- int num_text; /* number of comments read/to write */
- int max_text; /* current size of text array */
- png_textp text; /* array of comments read/to write */
-#endif /* PNG_TEXT_SUPPORTED */
-
-#if defined(PNG_tIME_SUPPORTED)
- /* The tIME chunk holds the last time the displayed image data was
- * modified. See the png_time struct for the contents of this struct.
- */
- png_time mod_time;
-#endif
-
-#if defined(PNG_sBIT_SUPPORTED)
- /* The sBIT chunk specifies the number of significant high-order bits
- * in the pixel data. Values are in the range [1, bit_depth], and are
- * only specified for the channels in the pixel data. The contents of
- * the low-order bits is not specified. Data is valid if
- * (valid & PNG_INFO_sBIT) is non-zero.
- */
- png_color_8 sig_bit; /* significant bits in color channels */
-#endif
-
-#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_EXPAND_SUPPORTED) || \
-defined(PNG_READ_BACKGROUND_SUPPORTED)
- /* The tRNS chunk supplies transparency data for paletted images and
- * other image types that don't need a full alpha channel. There are
- * "num_trans" transparency values for a paletted image, stored in the
- * same order as the palette colors, starting from index 0. Values
- * for the data are in the range [0, 255], ranging from fully transparent
- * to fully opaque, respectively. For non-paletted images, there is a
- * single color specified that should be treated as fully transparent.
- * Data is valid if (valid & PNG_INFO_tRNS) is non-zero.
- */
- png_bytep trans; /* transparent values for paletted image */
- png_color_16 trans_values; /* transparent color for non-palette image */
-#endif
-
-#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- /* The bKGD chunk gives the suggested image background color if the
- * display program does not have its own background color and the image
- * is needs to composited onto a background before display. The colors
- * in "background" are normally in the same color space/depth as the
- * pixel data. Data is valid if (valid & PNG_INFO_bKGD) is non-zero.
- */
- png_color_16 background;
-#endif
-
-#if defined(PNG_oFFs_SUPPORTED)
- /* The oFFs chunk gives the offset in "offset_unit_type" units rightwards
- * and downwards from the top-left corner of the display, page, or other
- * application-specific co-ordinate space. See the PNG_OFFSET_ defines
- * below for the unit types. Valid if (valid & PNG_INFO_oFFs) non-zero.
- */
- png_int_32 x_offset; /* x offset on page */
- png_int_32 y_offset; /* y offset on page */
- png_byte offset_unit_type; /* offset units type */
-#endif
-
-#if defined(PNG_pHYs_SUPPORTED)
- /* The pHYs chunk gives the physical pixel density of the image for
- * display or printing in "phys_unit_type" units (see PNG_RESOLUTION_
- * defines below). Data is valid if (valid & PNG_INFO_pHYs) is non-zero.
- */
- png_uint_32 x_pixels_per_unit; /* horizontal pixel density */
- png_uint_32 y_pixels_per_unit; /* vertical pixel density */
- png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
-#endif
-
-#if defined(PNG_hIST_SUPPORTED)
- /* The hIST chunk contains the relative frequency or importance of the
- * various palette entries, so that a viewer can intelligently select a
- * reduced-color palette, if required. Data is an array of "num_palette"
- * values in the range [0,65535]. Data valid if (valid & PNG_INFO_hIST)
- * is non-zero.
- */
- png_uint_16p hist;
-#endif
-
-#ifdef PNG_cHRM_SUPPORTED
- /* The cHRM chunk describes the CIE color characteristics of the monitor
- * on which the PNG was created. This data allows the viewer to do gamut
- * mapping of the input image to ensure that the viewer sees the same
- * colors in the image as the creator. Values are in the range
- * [0.0, 0.8]. Data valid if (valid & PNG_INFO_cHRM) non-zero.
- */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- float x_white;
- float y_white;
- float x_red;
- float y_red;
- float x_green;
- float y_green;
- float x_blue;
- float y_blue;
-#endif
-#endif
-
-#if defined(PNG_pCAL_SUPPORTED)
- /* The pCAL chunk describes a transformation between the stored pixel
- * values and original physical data values used to create the image.
- * The integer range [0, 2^bit_depth - 1] maps to the floating-point
- * range given by [pcal_X0, pcal_X1], and are further transformed by a
- * (possibly non-linear) transformation function given by "pcal_type"
- * and "pcal_params" into "pcal_units". Please see the PNG_EQUATION_
- * defines below, and the PNG-Group's PNG extensions document for a
- * complete description of the transformations and how they should be
- * implemented, and for a description of the ASCII parameter strings.
- * Data values are valid if (valid & PNG_INFO_pCAL) non-zero.
- */
- png_charp pcal_purpose; /* pCAL chunk description string */
- png_int_32 pcal_X0; /* minimum value */
- png_int_32 pcal_X1; /* maximum value */
- png_charp pcal_units; /* Latin-1 string giving physical units */
- png_charpp pcal_params; /* ASCII strings containing parameter values */
- png_byte pcal_type; /* equation type (see PNG_EQUATION_ below) */
- png_byte pcal_nparams; /* number of parameters given in pcal_params */
-#endif
-
-/* New members added in libpng-1.0.6 */
-#ifdef PNG_FREE_ME_SUPPORTED
- png_uint_32 free_me; /* flags items libpng is responsible for freeing */
-#endif
-
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
- /* storage for unknown chunks that the library doesn't recognize. */
- png_unknown_chunkp unknown_chunks;
- png_size_t unknown_chunks_num;
-#endif
-
-#if defined(PNG_iCCP_SUPPORTED)
- /* iCCP chunk data. */
- png_charp iccp_name; /* profile name */
- png_charp iccp_profile; /* International Color Consortium profile data */
- /* Note to maintainer: should be png_bytep */
- png_uint_32 iccp_proflen; /* ICC profile data length */
- png_byte iccp_compression; /* Always zero */
-#endif
-
-#if defined(PNG_sPLT_SUPPORTED)
- /* data on sPLT chunks (there may be more than one). */
- png_sPLT_tp splt_palettes;
- png_uint_32 splt_palettes_num;
-#endif
-
-#if defined(PNG_sCAL_SUPPORTED)
- /* The sCAL chunk describes the actual physical dimensions of the
- * subject matter of the graphic. The chunk contains a unit specification
- * a byte value, and two ASCII strings representing floating-point
- * values. The values are width and height corresponsing to one pixel
- * in the image. This external representation is converted to double
- * here. Data values are valid if (valid & PNG_INFO_sCAL) is non-zero.
- */
- png_byte scal_unit; /* unit of physical scale */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- double scal_pixel_width; /* width of one pixel */
- double scal_pixel_height; /* height of one pixel */
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
- png_charp scal_s_width; /* string containing height */
- png_charp scal_s_height; /* string containing width */
-#endif
-#endif
-
-#if defined(PNG_INFO_IMAGE_SUPPORTED)
- /* Memory has been allocated if (valid & PNG_ALLOCATED_INFO_ROWS) non-zero */
- /* Data valid if (valid & PNG_INFO_IDAT) non-zero */
- png_bytepp row_pointers; /* the image bits */
-#endif
-
-#if defined(PNG_FIXED_POINT_SUPPORTED) && defined(PNG_gAMA_SUPPORTED)
- png_fixed_point int_gamma; /* gamma of image, if (valid & PNG_INFO_gAMA) */
-#endif
-
-#if defined(PNG_cHRM_SUPPORTED) && defined(PNG_FIXED_POINT_SUPPORTED)
- png_fixed_point int_x_white;
- png_fixed_point int_y_white;
- png_fixed_point int_x_red;
- png_fixed_point int_y_red;
- png_fixed_point int_x_green;
- png_fixed_point int_y_green;
- png_fixed_point int_x_blue;
- png_fixed_point int_y_blue;
-#endif
-
-} png_info;
-
-typedef png_info FAR * png_infop;
-typedef png_info FAR * FAR * png_infopp;
-
-/* Maximum positive integer used in PNG is (2^31)-1 */
-#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
-#define PNG_UINT_32_MAX ((png_uint_32)(-1))
-#define PNG_SIZE_MAX ((png_size_t)(-1))
-#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
-/* PNG_MAX_UINT is deprecated; use PNG_UINT_31_MAX instead. */
-#define PNG_MAX_UINT PNG_UINT_31_MAX
-#endif
-
-/* These describe the color_type field in png_info. */
-/* color type masks */
-#define PNG_COLOR_MASK_PALETTE 1
-#define PNG_COLOR_MASK_COLOR 2
-#define PNG_COLOR_MASK_ALPHA 4
-
-/* color types. Note that not all combinations are legal */
-#define PNG_COLOR_TYPE_GRAY 0
-#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE)
-#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR)
-#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA)
-#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA)
-/* aliases */
-#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA
-#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA
-
-/* This is for compression type. PNG 1.0-1.2 only define the single type. */
-#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */
-#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE
-
-/* This is for filter type. PNG 1.0-1.2 only define the single type. */
-#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */
-#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */
-#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE
-
-/* These are for the interlacing type. These values should NOT be changed. */
-#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */
-#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */
-#define PNG_INTERLACE_LAST 2 /* Not a valid value */
-
-/* These are for the oFFs chunk. These values should NOT be changed. */
-#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */
-#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */
-#define PNG_OFFSET_LAST 2 /* Not a valid value */
-
-/* These are for the pCAL chunk. These values should NOT be changed. */
-#define PNG_EQUATION_LINEAR 0 /* Linear transformation */
-#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */
-#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */
-#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */
-#define PNG_EQUATION_LAST 4 /* Not a valid value */
-
-/* These are for the sCAL chunk. These values should NOT be changed. */
-#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */
-#define PNG_SCALE_METER 1 /* meters per pixel */
-#define PNG_SCALE_RADIAN 2 /* radians per pixel */
-#define PNG_SCALE_LAST 3 /* Not a valid value */
-
-/* These are for the pHYs chunk. These values should NOT be changed. */
-#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */
-#define PNG_RESOLUTION_METER 1 /* pixels/meter */
-#define PNG_RESOLUTION_LAST 2 /* Not a valid value */
-
-/* These are for the sRGB chunk. These values should NOT be changed. */
-#define PNG_sRGB_INTENT_PERCEPTUAL 0
-#define PNG_sRGB_INTENT_RELATIVE 1
-#define PNG_sRGB_INTENT_SATURATION 2
-#define PNG_sRGB_INTENT_ABSOLUTE 3
-#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */
-
-/* This is for text chunks */
-#define PNG_KEYWORD_MAX_LENGTH 79
-
-/* Maximum number of entries in PLTE/sPLT/tRNS arrays */
-#define PNG_MAX_PALETTE_LENGTH 256
-
-/* These determine if an ancillary chunk's data has been successfully read
- * from the PNG header, or if the application has filled in the corresponding
- * data in the info_struct to be written into the output file. The values
- * of the PNG_INFO_<chunk> defines should NOT be changed.
- */
-#define PNG_INFO_gAMA 0x0001
-#define PNG_INFO_sBIT 0x0002
-#define PNG_INFO_cHRM 0x0004
-#define PNG_INFO_PLTE 0x0008
-#define PNG_INFO_tRNS 0x0010
-#define PNG_INFO_bKGD 0x0020
-#define PNG_INFO_hIST 0x0040
-#define PNG_INFO_pHYs 0x0080
-#define PNG_INFO_oFFs 0x0100
-#define PNG_INFO_tIME 0x0200
-#define PNG_INFO_pCAL 0x0400
-#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */
-#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */
-#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */
-#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */
-#define PNG_INFO_IDAT 0x8000L /* ESR, 1.0.6 */
-
-/* This is used for the transformation routines, as some of them
- * change these values for the row. It also should enable using
- * the routines for other purposes.
- */
-typedef struct png_row_info_struct
-{
- png_uint_32 width; /* width of row */
- png_uint_32 rowbytes; /* number of bytes in row */
- png_byte color_type; /* color type of row */
- png_byte bit_depth; /* bit depth of row */
- png_byte channels; /* number of channels (1, 2, 3, or 4) */
- png_byte pixel_depth; /* bits per pixel (depth * channels) */
-} png_row_info;
-
-typedef png_row_info FAR * png_row_infop;
-typedef png_row_info FAR * FAR * png_row_infopp;
-
-/* These are the function types for the I/O functions and for the functions
- * that allow the user to override the default I/O functions with his or her
- * own. The png_error_ptr type should match that of user-supplied warning
- * and error functions, while the png_rw_ptr type should match that of the
- * user read/write data functions.
- */
-typedef struct png_struct_def png_struct;
-typedef png_struct FAR * png_structp;
-
-typedef void (PNGAPI *png_error_ptr) PNGARG((png_structp, png_const_charp));
-typedef void (PNGAPI *png_rw_ptr) PNGARG((png_structp, png_bytep, png_size_t));
-typedef void (PNGAPI *png_flush_ptr) PNGARG((png_structp));
-typedef void (PNGAPI *png_read_status_ptr) PNGARG((png_structp, png_uint_32,
- int));
-typedef void (PNGAPI *png_write_status_ptr) PNGARG((png_structp, png_uint_32,
- int));
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-typedef void (PNGAPI *png_progressive_info_ptr) PNGARG((png_structp, png_infop));
-typedef void (PNGAPI *png_progressive_end_ptr) PNGARG((png_structp, png_infop));
-typedef void (PNGAPI *png_progressive_row_ptr) PNGARG((png_structp, png_bytep,
- png_uint_32, int));
-#endif
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_LEGACY_SUPPORTED)
-typedef void (PNGAPI *png_user_transform_ptr) PNGARG((png_structp,
- png_row_infop, png_bytep));
-#endif
-
-#if defined(PNG_USER_CHUNKS_SUPPORTED)
-typedef int (PNGAPI *png_user_chunk_ptr) PNGARG((png_structp, png_unknown_chunkp));
-#endif
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
-typedef void (PNGAPI *png_unknown_chunk_ptr) PNGARG((png_structp));
-#endif
-
-/* Transform masks for the high-level interface */
-#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */
-#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */
-#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */
-#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */
-#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */
-#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */
-#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */
-#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */
-#define PNG_TRANSFORM_BGR 0x0080 /* read and write */
-#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */
-#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */
-#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */
-#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* WRITE only, deprecated */
-/* Added to libpng-1.2.34 */
-#define PNG_TRANSFORM_STRIP_FILLER_BEFORE 0x0800 /* WRITE only */
-#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* WRITE only */
-
-/* Flags for MNG supported features */
-#define PNG_FLAG_MNG_EMPTY_PLTE 0x01
-#define PNG_FLAG_MNG_FILTER_64 0x04
-#define PNG_ALL_MNG_FEATURES 0x05
-
-typedef png_voidp (*png_malloc_ptr) PNGARG((png_structp, png_size_t));
-typedef void (*png_free_ptr) PNGARG((png_structp, png_voidp));
-
-/* The structure that holds the information to read and write PNG files.
- * The only people who need to care about what is inside of this are the
- * people who will be modifying the library for their own special needs.
- * It should NOT be accessed directly by an application, except to store
- * the jmp_buf.
- */
-
-struct png_struct_def
-{
-#ifdef PNG_SETJMP_SUPPORTED
- jmp_buf jmpbuf; /* used in png_error */
-#endif
- png_error_ptr error_fn; /* function for printing errors and aborting */
- png_error_ptr warning_fn; /* function for printing warnings */
- png_voidp error_ptr; /* user supplied struct for error functions */
- png_rw_ptr write_data_fn; /* function for writing output data */
- png_rw_ptr read_data_fn; /* function for reading input data */
- png_voidp io_ptr; /* ptr to application struct for I/O functions */
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
- png_user_transform_ptr read_user_transform_fn; /* user read transform */
-#endif
-
-#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
- png_user_transform_ptr write_user_transform_fn; /* user write transform */
-#endif
-
-/* These were added in libpng-1.0.2 */
-#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
- png_voidp user_transform_ptr; /* user supplied struct for user transform */
- png_byte user_transform_depth; /* bit depth of user transformed pixels */
- png_byte user_transform_channels; /* channels in user transformed pixels */
-#endif
-#endif
-
- png_uint_32 mode; /* tells us where we are in the PNG file */
- png_uint_32 flags; /* flags indicating various things to libpng */
- png_uint_32 transformations; /* which transformations to perform */
-
- z_stream zstream; /* pointer to decompression structure (below) */
- png_bytep zbuf; /* buffer for zlib */
- png_size_t zbuf_size; /* size of zbuf */
- int zlib_level; /* holds zlib compression level */
- int zlib_method; /* holds zlib compression method */
- int zlib_window_bits; /* holds zlib compression window bits */
- int zlib_mem_level; /* holds zlib compression memory level */
- int zlib_strategy; /* holds zlib compression strategy */
-
- png_uint_32 width; /* width of image in pixels */
- png_uint_32 height; /* height of image in pixels */
- png_uint_32 num_rows; /* number of rows in current pass */
- png_uint_32 usr_width; /* width of row at start of write */
- png_uint_32 rowbytes; /* size of row in bytes */
- png_uint_32 irowbytes; /* size of current interlaced row in bytes */
- png_uint_32 iwidth; /* width of current interlaced row in pixels */
- png_uint_32 row_number; /* current row in interlace pass */
- png_bytep prev_row; /* buffer to save previous (unfiltered) row */
- png_bytep row_buf; /* buffer to save current (unfiltered) row */
-#ifndef PNG_NO_WRITE_FILTER
- png_bytep sub_row; /* buffer to save "sub" row when filtering */
- png_bytep up_row; /* buffer to save "up" row when filtering */
- png_bytep avg_row; /* buffer to save "avg" row when filtering */
- png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
-#endif
- png_row_info row_info; /* used for transformation routines */
-
- png_uint_32 idat_size; /* current IDAT size for read */
- png_uint_32 crc; /* current chunk CRC value */
- png_colorp palette; /* palette from the input file */
- png_uint_16 num_palette; /* number of color entries in palette */
- png_uint_16 num_trans; /* number of transparency values */
- png_byte chunk_name[5]; /* null-terminated name of current chunk */
- png_byte compression; /* file compression type (always 0) */
- png_byte filter; /* file filter type (always 0) */
- png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
- png_byte pass; /* current interlace pass (0 - 6) */
- png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
- png_byte color_type; /* color type of file */
- png_byte bit_depth; /* bit depth of file */
- png_byte usr_bit_depth; /* bit depth of users row */
- png_byte pixel_depth; /* number of bits per pixel */
- png_byte channels; /* number of channels in file */
- png_byte usr_channels; /* channels at start of write */
- png_byte sig_bytes; /* magic bytes read/written from start of file */
-
-#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
-#ifdef PNG_LEGACY_SUPPORTED
- png_byte filler; /* filler byte for pixel expansion */
-#else
- png_uint_16 filler; /* filler bytes for pixel expansion */
-#endif
-#endif
-
-#if defined(PNG_bKGD_SUPPORTED)
- png_byte background_gamma_type;
-# ifdef PNG_FLOATING_POINT_SUPPORTED
- float background_gamma;
-# endif
- png_color_16 background; /* background color in screen gamma space */
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- png_color_16 background_1; /* background normalized to gamma 1.0 */
-#endif
-#endif /* PNG_bKGD_SUPPORTED */
-
-#if defined(PNG_WRITE_FLUSH_SUPPORTED)
- png_flush_ptr output_flush_fn;/* Function for flushing output */
- png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
- png_uint_32 flush_rows; /* number of rows written since last flush */
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- int gamma_shift; /* number of "insignificant" bits 16-bit gamma */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- float gamma; /* file gamma value */
- float screen_gamma; /* screen gamma value (display_exponent) */
-#endif
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- png_bytep gamma_table; /* gamma table for 8-bit depth files */
- png_bytep gamma_from_1; /* converts from 1.0 to screen */
- png_bytep gamma_to_1; /* converts from file to 1.0 */
- png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
- png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
- png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
- png_color_8 sig_bit; /* significant bits in each available channel */
-#endif
-
-#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
- png_color_8 shift; /* shift for significant bit tranformation */
-#endif
-
-#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
- || defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- png_bytep trans; /* transparency values for paletted files */
- png_color_16 trans_values; /* transparency values for non-paletted files */
-#endif
-
- png_read_status_ptr read_row_fn; /* called after each row is decoded */
- png_write_status_ptr write_row_fn; /* called after each row is encoded */
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
- png_progressive_info_ptr info_fn; /* called after header data fully read */
- png_progressive_row_ptr row_fn; /* called after each prog. row is decoded */
- png_progressive_end_ptr end_fn; /* called after image is complete */
- png_bytep save_buffer_ptr; /* current location in save_buffer */
- png_bytep save_buffer; /* buffer for previously read data */
- png_bytep current_buffer_ptr; /* current location in current_buffer */
- png_bytep current_buffer; /* buffer for recently used data */
- png_uint_32 push_length; /* size of current input chunk */
- png_uint_32 skip_length; /* bytes to skip in input data */
- png_size_t save_buffer_size; /* amount of data now in save_buffer */
- png_size_t save_buffer_max; /* total size of save_buffer */
- png_size_t buffer_size; /* total amount of available input data */
- png_size_t current_buffer_size; /* amount of data now in current_buffer */
- int process_mode; /* what push library is currently doing */
- int cur_palette; /* current push library palette index */
-
-# if defined(PNG_TEXT_SUPPORTED)
- png_size_t current_text_size; /* current size of text input data */
- png_size_t current_text_left; /* how much text left to read in input */
- png_charp current_text; /* current text chunk buffer */
- png_charp current_text_ptr; /* current location in current_text */
-# endif /* PNG_TEXT_SUPPORTED */
-#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
-
-#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
-/* for the Borland special 64K segment handler */
- png_bytepp offset_table_ptr;
- png_bytep offset_table;
- png_uint_16 offset_table_number;
- png_uint_16 offset_table_count;
- png_uint_16 offset_table_count_free;
-#endif
-
-#if defined(PNG_READ_DITHER_SUPPORTED)
- png_bytep palette_lookup; /* lookup table for dithering */
- png_bytep dither_index; /* index translation for palette files */
-#endif
-
-#if defined(PNG_READ_DITHER_SUPPORTED) || defined(PNG_hIST_SUPPORTED)
- png_uint_16p hist; /* histogram */
-#endif
-
-#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED)
- png_byte heuristic_method; /* heuristic for row filter selection */
- png_byte num_prev_filters; /* number of weights for previous rows */
- png_bytep prev_filters; /* filter type(s) of previous row(s) */
- png_uint_16p filter_weights; /* weight(s) for previous line(s) */
- png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
- png_uint_16p filter_costs; /* relative filter calculation cost */
- png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
-#endif
-
-#if defined(PNG_TIME_RFC1123_SUPPORTED)
- png_charp time_buffer; /* String to hold RFC 1123 time text */
-#endif
-
-/* New members added in libpng-1.0.6 */
-
-#ifdef PNG_FREE_ME_SUPPORTED
- png_uint_32 free_me; /* flags items libpng is responsible for freeing */
-#endif
-
-#if defined(PNG_USER_CHUNKS_SUPPORTED)
- png_voidp user_chunk_ptr;
- png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
-#endif
-
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
- int num_chunk_list;
- png_bytep chunk_list;
-#endif
-
-/* New members added in libpng-1.0.3 */
-#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- png_byte rgb_to_gray_status;
- /* These were changed from png_byte in libpng-1.0.6 */
- png_uint_16 rgb_to_gray_red_coeff;
- png_uint_16 rgb_to_gray_green_coeff;
- png_uint_16 rgb_to_gray_blue_coeff;
-#endif
-
-/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
-#if defined(PNG_MNG_FEATURES_SUPPORTED) || \
- defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
- defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
-/* changed from png_byte to png_uint_32 at version 1.2.0 */
-#ifdef PNG_1_0_X
- png_byte mng_features_permitted;
-#else
- png_uint_32 mng_features_permitted;
-#endif /* PNG_1_0_X */
-#endif
-
-/* New member added in libpng-1.0.7 */
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- png_fixed_point int_gamma;
-#endif
-
-/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
-#if defined(PNG_MNG_FEATURES_SUPPORTED)
- png_byte filter_type;
-#endif
-
-#if defined(PNG_1_0_X)
-/* New member added in libpng-1.0.10, ifdef'ed out in 1.2.0 */
- png_uint_32 row_buf_size;
-#endif
-
-/* New members added in libpng-1.2.0 */
-#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
-# if !defined(PNG_1_0_X)
-# if defined(PNG_MMX_CODE_SUPPORTED)
- png_byte mmx_bitdepth_threshold;
- png_uint_32 mmx_rowbytes_threshold;
-# endif
- png_uint_32 asm_flags;
-# endif
-#endif
-
-/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
-#ifdef PNG_USER_MEM_SUPPORTED
- png_voidp mem_ptr; /* user supplied struct for mem functions */
- png_malloc_ptr malloc_fn; /* function for allocating memory */
- png_free_ptr free_fn; /* function for freeing memory */
-#endif
-
-/* New member added in libpng-1.0.13 and 1.2.0 */
- png_bytep big_row_buf; /* buffer to save current (unfiltered) row */
-
-#if defined(PNG_READ_DITHER_SUPPORTED)
-/* The following three members were added at version 1.0.14 and 1.2.4 */
- png_bytep dither_sort; /* working sort array */
- png_bytep index_to_palette; /* where the original index currently is */
- /* in the palette */
- png_bytep palette_to_index; /* which original index points to this */
- /* palette color */
-#endif
-
-/* New members added in libpng-1.0.16 and 1.2.6 */
- png_byte compression_type;
-
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
- png_uint_32 user_width_max;
- png_uint_32 user_height_max;
-#endif
-
-/* New member added in libpng-1.0.25 and 1.2.17 */
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
- /* storage for unknown chunk that the library doesn't recognize. */
- png_unknown_chunk unknown_chunk;
-#endif
-
-/* New members added in libpng-1.2.26 */
- png_uint_32 old_big_row_buf_size, old_prev_row_size;
-
-/* New member added in libpng-1.2.30 */
- png_charp chunkdata; /* buffer for reading chunk data */
-
-};
-
-
-/* This triggers a compiler error in png.c, if png.c and png.h
- * do not agree upon the version number.
- */
-typedef png_structp version_1_2_36;
-
-typedef png_struct FAR * FAR * png_structpp;
-
-/* Here are the function definitions most commonly used. This is not
- * the place to find out how to use libpng. See libpng.txt for the
- * full explanation, see example.c for the summary. This just provides
- * a simple one line description of the use of each function.
- */
-
-/* Returns the version number of the library */
-extern PNG_EXPORT(png_uint_32,png_access_version_number) PNGARG((void));
-
-/* Tell lib we have already handled the first <num_bytes> magic bytes.
- * Handling more than 8 bytes from the beginning of the file is an error.
- */
-extern PNG_EXPORT(void,png_set_sig_bytes) PNGARG((png_structp png_ptr,
- int num_bytes));
-
-/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
- * PNG file. Returns zero if the supplied bytes match the 8-byte PNG
- * signature, and non-zero otherwise. Having num_to_check == 0 or
- * start > 7 will always fail (ie return non-zero).
- */
-extern PNG_EXPORT(int,png_sig_cmp) PNGARG((png_bytep sig, png_size_t start,
- png_size_t num_to_check));
-
-/* Simple signature checking function. This is the same as calling
- * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
- */
-extern PNG_EXPORT(int,png_check_sig) PNGARG((png_bytep sig, int num));
-
-/* Allocate and initialize png_ptr struct for reading, and any other memory. */
-extern PNG_EXPORT(png_structp,png_create_read_struct)
- PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn));
-
-/* Allocate and initialize png_ptr struct for writing, and any other memory */
-extern PNG_EXPORT(png_structp,png_create_write_struct)
- PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn));
-
-#ifdef PNG_WRITE_SUPPORTED
-extern PNG_EXPORT(png_uint_32,png_get_compression_buffer_size)
- PNGARG((png_structp png_ptr));
-#endif
-
-#ifdef PNG_WRITE_SUPPORTED
-extern PNG_EXPORT(void,png_set_compression_buffer_size)
- PNGARG((png_structp png_ptr, png_uint_32 size));
-#endif
-
-/* Reset the compression stream */
-extern PNG_EXPORT(int,png_reset_zstream) PNGARG((png_structp png_ptr));
-
-/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
-#ifdef PNG_USER_MEM_SUPPORTED
-extern PNG_EXPORT(png_structp,png_create_read_struct_2)
- PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn));
-extern PNG_EXPORT(png_structp,png_create_write_struct_2)
- PNGARG((png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn));
-#endif
-
-/* Write a PNG chunk - size, type, (optional) data, CRC. */
-extern PNG_EXPORT(void,png_write_chunk) PNGARG((png_structp png_ptr,
- png_bytep chunk_name, png_bytep data, png_size_t length));
-
-/* Write the start of a PNG chunk - length and chunk name. */
-extern PNG_EXPORT(void,png_write_chunk_start) PNGARG((png_structp png_ptr,
- png_bytep chunk_name, png_uint_32 length));
-
-/* Write the data of a PNG chunk started with png_write_chunk_start(). */
-extern PNG_EXPORT(void,png_write_chunk_data) PNGARG((png_structp png_ptr,
- png_bytep data, png_size_t length));
-
-/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
-extern PNG_EXPORT(void,png_write_chunk_end) PNGARG((png_structp png_ptr));
-
-/* Allocate and initialize the info structure */
-extern PNG_EXPORT(png_infop,png_create_info_struct)
- PNGARG((png_structp png_ptr));
-
-#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
-/* Initialize the info structure (old interface - DEPRECATED) */
-extern PNG_EXPORT(void,png_info_init) PNGARG((png_infop info_ptr));
-#undef png_info_init
-#define png_info_init(info_ptr) png_info_init_3(&info_ptr,\
- png_sizeof(png_info));
-#endif
-
-extern PNG_EXPORT(void,png_info_init_3) PNGARG((png_infopp info_ptr,
- png_size_t png_info_struct_size));
-
-/* Writes all the PNG information before the image. */
-extern PNG_EXPORT(void,png_write_info_before_PLTE) PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-extern PNG_EXPORT(void,png_write_info) PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-/* read the information before the actual image data. */
-extern PNG_EXPORT(void,png_read_info) PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-#endif
-
-#if defined(PNG_TIME_RFC1123_SUPPORTED)
-extern PNG_EXPORT(png_charp,png_convert_to_rfc1123)
- PNGARG((png_structp png_ptr, png_timep ptime));
-#endif
-
-#if !defined(_WIN32_WCE)
-/* "time.h" functions are not supported on WindowsCE */
-#if defined(PNG_WRITE_tIME_SUPPORTED)
-/* convert from a struct tm to png_time */
-extern PNG_EXPORT(void,png_convert_from_struct_tm) PNGARG((png_timep ptime,
- struct tm FAR * ttime));
-
-/* convert from time_t to png_time. Uses gmtime() */
-extern PNG_EXPORT(void,png_convert_from_time_t) PNGARG((png_timep ptime,
- time_t ttime));
-#endif /* PNG_WRITE_tIME_SUPPORTED */
-#endif /* _WIN32_WCE */
-
-#if defined(PNG_READ_EXPAND_SUPPORTED)
-/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
-extern PNG_EXPORT(void,png_set_expand) PNGARG((png_structp png_ptr));
-#if !defined(PNG_1_0_X)
-extern PNG_EXPORT(void,png_set_expand_gray_1_2_4_to_8) PNGARG((png_structp
- png_ptr));
-#endif
-extern PNG_EXPORT(void,png_set_palette_to_rgb) PNGARG((png_structp png_ptr));
-extern PNG_EXPORT(void,png_set_tRNS_to_alpha) PNGARG((png_structp png_ptr));
-#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
-/* Deprecated */
-extern PNG_EXPORT(void,png_set_gray_1_2_4_to_8) PNGARG((png_structp png_ptr));
-#endif
-#endif
-
-#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
-/* Use blue, green, red order for pixels. */
-extern PNG_EXPORT(void,png_set_bgr) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
-/* Expand the grayscale to 24-bit RGB if necessary. */
-extern PNG_EXPORT(void,png_set_gray_to_rgb) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
-/* Reduce RGB to grayscale. */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(void,png_set_rgb_to_gray) PNGARG((png_structp png_ptr,
- int error_action, double red, double green ));
-#endif
-extern PNG_EXPORT(void,png_set_rgb_to_gray_fixed) PNGARG((png_structp png_ptr,
- int error_action, png_fixed_point red, png_fixed_point green ));
-extern PNG_EXPORT(png_byte,png_get_rgb_to_gray_status) PNGARG((png_structp
- png_ptr));
-#endif
-
-extern PNG_EXPORT(void,png_build_grayscale_palette) PNGARG((int bit_depth,
- png_colorp palette));
-
-#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
-extern PNG_EXPORT(void,png_set_strip_alpha) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
- defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
-extern PNG_EXPORT(void,png_set_swap_alpha) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
- defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
-extern PNG_EXPORT(void,png_set_invert_alpha) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
-/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */
-extern PNG_EXPORT(void,png_set_filler) PNGARG((png_structp png_ptr,
- png_uint_32 filler, int flags));
-/* The values of the PNG_FILLER_ defines should NOT be changed */
-#define PNG_FILLER_BEFORE 0
-#define PNG_FILLER_AFTER 1
-/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */
-#if !defined(PNG_1_0_X)
-extern PNG_EXPORT(void,png_set_add_alpha) PNGARG((png_structp png_ptr,
- png_uint_32 filler, int flags));
-#endif
-#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */
-
-#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-/* Swap bytes in 16-bit depth files. */
-extern PNG_EXPORT(void,png_set_swap) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
-/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
-extern PNG_EXPORT(void,png_set_packing) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-/* Swap packing order of pixels in bytes. */
-extern PNG_EXPORT(void,png_set_packswap) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
-/* Converts files to legal bit depths. */
-extern PNG_EXPORT(void,png_set_shift) PNGARG((png_structp png_ptr,
- png_color_8p true_bits));
-#endif
-
-#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
- defined(PNG_WRITE_INTERLACING_SUPPORTED)
-/* Have the code handle the interlacing. Returns the number of passes. */
-extern PNG_EXPORT(int,png_set_interlace_handling) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
-/* Invert monochrome files */
-extern PNG_EXPORT(void,png_set_invert_mono) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
-/* Handle alpha and tRNS by replacing with a background color. */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(void,png_set_background) PNGARG((png_structp png_ptr,
- png_color_16p background_color, int background_gamma_code,
- int need_expand, double background_gamma));
-#endif
-#define PNG_BACKGROUND_GAMMA_UNKNOWN 0
-#define PNG_BACKGROUND_GAMMA_SCREEN 1
-#define PNG_BACKGROUND_GAMMA_FILE 2
-#define PNG_BACKGROUND_GAMMA_UNIQUE 3
-#endif
-
-#if defined(PNG_READ_16_TO_8_SUPPORTED)
-/* strip the second byte of information from a 16-bit depth file. */
-extern PNG_EXPORT(void,png_set_strip_16) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_DITHER_SUPPORTED)
-/* Turn on dithering, and reduce the palette to the number of colors available. */
-extern PNG_EXPORT(void,png_set_dither) PNGARG((png_structp png_ptr,
- png_colorp palette, int num_palette, int maximum_colors,
- png_uint_16p histogram, int full_dither));
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED)
-/* Handle gamma correction. Screen_gamma=(display_exponent) */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(void,png_set_gamma) PNGARG((png_structp png_ptr,
- double screen_gamma, double default_file_gamma));
-#endif
-#endif
-
-#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
-#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
- defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
-/* Permit or disallow empty PLTE (0: not permitted, 1: permitted) */
-/* Deprecated and will be removed. Use png_permit_mng_features() instead. */
-extern PNG_EXPORT(void,png_permit_empty_plte) PNGARG((png_structp png_ptr,
- int empty_plte_permitted));
-#endif
-#endif
-
-#if defined(PNG_WRITE_FLUSH_SUPPORTED)
-/* Set how many lines between output flushes - 0 for no flushing */
-extern PNG_EXPORT(void,png_set_flush) PNGARG((png_structp png_ptr, int nrows));
-/* Flush the current PNG output buffer */
-extern PNG_EXPORT(void,png_write_flush) PNGARG((png_structp png_ptr));
-#endif
-
-/* optional update palette with requested transformations */
-extern PNG_EXPORT(void,png_start_read_image) PNGARG((png_structp png_ptr));
-
-/* optional call to update the users info structure */
-extern PNG_EXPORT(void,png_read_update_info) PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-/* read one or more rows of image data. */
-extern PNG_EXPORT(void,png_read_rows) PNGARG((png_structp png_ptr,
- png_bytepp row, png_bytepp display_row, png_uint_32 num_rows));
-#endif
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-/* read a row of data. */
-extern PNG_EXPORT(void,png_read_row) PNGARG((png_structp png_ptr,
- png_bytep row,
- png_bytep display_row));
-#endif
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-/* read the whole image into memory at once. */
-extern PNG_EXPORT(void,png_read_image) PNGARG((png_structp png_ptr,
- png_bytepp image));
-#endif
-
-/* write a row of image data */
-extern PNG_EXPORT(void,png_write_row) PNGARG((png_structp png_ptr,
- png_bytep row));
-
-/* write a few rows of image data */
-extern PNG_EXPORT(void,png_write_rows) PNGARG((png_structp png_ptr,
- png_bytepp row, png_uint_32 num_rows));
-
-/* write the image data */
-extern PNG_EXPORT(void,png_write_image) PNGARG((png_structp png_ptr,
- png_bytepp image));
-
-/* writes the end of the PNG file. */
-extern PNG_EXPORT(void,png_write_end) PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-/* read the end of the PNG file. */
-extern PNG_EXPORT(void,png_read_end) PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-#endif
-
-/* free any memory associated with the png_info_struct */
-extern PNG_EXPORT(void,png_destroy_info_struct) PNGARG((png_structp png_ptr,
- png_infopp info_ptr_ptr));
-
-/* free any memory associated with the png_struct and the png_info_structs */
-extern PNG_EXPORT(void,png_destroy_read_struct) PNGARG((png_structpp
- png_ptr_ptr, png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
-
-/* free all memory used by the read (old method - NOT DLL EXPORTED) */
-extern void png_read_destroy PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_infop end_info_ptr));
-
-/* free any memory associated with the png_struct and the png_info_structs */
-extern PNG_EXPORT(void,png_destroy_write_struct)
- PNGARG((png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
-
-/* free any memory used in png_ptr struct (old method - NOT DLL EXPORTED) */
-extern void png_write_destroy PNGARG((png_structp png_ptr));
-
-/* set the libpng method of handling chunk CRC errors */
-extern PNG_EXPORT(void,png_set_crc_action) PNGARG((png_structp png_ptr,
- int crit_action, int ancil_action));
-
-/* Values for png_set_crc_action() to say how to handle CRC errors in
- * ancillary and critical chunks, and whether to use the data contained
- * therein. Note that it is impossible to "discard" data in a critical
- * chunk. For versions prior to 0.90, the action was always error/quit,
- * whereas in version 0.90 and later, the action for CRC errors in ancillary
- * chunks is warn/discard. These values should NOT be changed.
- *
- * value action:critical action:ancillary
- */
-#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */
-#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */
-#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */
-#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */
-#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
-#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
-
-/* These functions give the user control over the scan-line filtering in
- * libpng and the compression methods used by zlib. These functions are
- * mainly useful for testing, as the defaults should work with most users.
- * Those users who are tight on memory or want faster performance at the
- * expense of compression can modify them. See the compression library
- * header file (zlib.h) for an explination of the compression functions.
- */
-
-/* set the filtering method(s) used by libpng. Currently, the only valid
- * value for "method" is 0.
- */
-extern PNG_EXPORT(void,png_set_filter) PNGARG((png_structp png_ptr, int method,
- int filters));
-
-/* Flags for png_set_filter() to say which filters to use. The flags
- * are chosen so that they don't conflict with real filter types
- * below, in case they are supplied instead of the #defined constants.
- * These values should NOT be changed.
- */
-#define PNG_NO_FILTERS 0x00
-#define PNG_FILTER_NONE 0x08
-#define PNG_FILTER_SUB 0x10
-#define PNG_FILTER_UP 0x20
-#define PNG_FILTER_AVG 0x40
-#define PNG_FILTER_PAETH 0x80
-#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
- PNG_FILTER_AVG | PNG_FILTER_PAETH)
-
-/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
- * These defines should NOT be changed.
- */
-#define PNG_FILTER_VALUE_NONE 0
-#define PNG_FILTER_VALUE_SUB 1
-#define PNG_FILTER_VALUE_UP 2
-#define PNG_FILTER_VALUE_AVG 3
-#define PNG_FILTER_VALUE_PAETH 4
-#define PNG_FILTER_VALUE_LAST 5
-
-#if defined(PNG_WRITE_WEIGHTED_FILTER_SUPPORTED) /* EXPERIMENTAL */
-/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
- * defines, either the default (minimum-sum-of-absolute-differences), or
- * the experimental method (weighted-minimum-sum-of-absolute-differences).
- *
- * Weights are factors >= 1.0, indicating how important it is to keep the
- * filter type consistent between rows. Larger numbers mean the current
- * filter is that many times as likely to be the same as the "num_weights"
- * previous filters. This is cumulative for each previous row with a weight.
- * There needs to be "num_weights" values in "filter_weights", or it can be
- * NULL if the weights aren't being specified. Weights have no influence on
- * the selection of the first row filter. Well chosen weights can (in theory)
- * improve the compression for a given image.
- *
- * Costs are factors >= 1.0 indicating the relative decoding costs of a
- * filter type. Higher costs indicate more decoding expense, and are
- * therefore less likely to be selected over a filter with lower computational
- * costs. There needs to be a value in "filter_costs" for each valid filter
- * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
- * setting the costs. Costs try to improve the speed of decompression without
- * unduly increasing the compressed image size.
- *
- * A negative weight or cost indicates the default value is to be used, and
- * values in the range [0.0, 1.0) indicate the value is to remain unchanged.
- * The default values for both weights and costs are currently 1.0, but may
- * change if good general weighting/cost heuristics can be found. If both
- * the weights and costs are set to 1.0, this degenerates the WEIGHTED method
- * to the UNWEIGHTED method, but with added encoding time/computation.
- */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(void,png_set_filter_heuristics) PNGARG((png_structp png_ptr,
- int heuristic_method, int num_weights, png_doublep filter_weights,
- png_doublep filter_costs));
-#endif
-#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */
-
-/* Heuristic used for row filter selection. These defines should NOT be
- * changed.
- */
-#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
-#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
-#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
-#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
-
-/* Set the library compression level. Currently, valid values range from
- * 0 - 9, corresponding directly to the zlib compression levels 0 - 9
- * (0 - no compression, 9 - "maximal" compression). Note that tests have
- * shown that zlib compression levels 3-6 usually perform as well as level 9
- * for PNG images, and do considerably fewer caclulations. In the future,
- * these values may not correspond directly to the zlib compression levels.
- */
-extern PNG_EXPORT(void,png_set_compression_level) PNGARG((png_structp png_ptr,
- int level));
-
-extern PNG_EXPORT(void,png_set_compression_mem_level)
- PNGARG((png_structp png_ptr, int mem_level));
-
-extern PNG_EXPORT(void,png_set_compression_strategy)
- PNGARG((png_structp png_ptr, int strategy));
-
-extern PNG_EXPORT(void,png_set_compression_window_bits)
- PNGARG((png_structp png_ptr, int window_bits));
-
-extern PNG_EXPORT(void,png_set_compression_method) PNGARG((png_structp png_ptr,
- int method));
-
-/* These next functions are called for input/output, memory, and error
- * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
- * and call standard C I/O routines such as fread(), fwrite(), and
- * fprintf(). These functions can be made to use other I/O routines
- * at run time for those applications that need to handle I/O in a
- * different manner by calling png_set_???_fn(). See libpng.txt for
- * more information.
- */
-
-#if !defined(PNG_NO_STDIO)
-/* Initialize the input/output for the PNG file to the default functions. */
-extern PNG_EXPORT(void,png_init_io) PNGARG((png_structp png_ptr, png_FILE_p fp));
-#endif
-
-/* Replace the (error and abort), and warning functions with user
- * supplied functions. If no messages are to be printed you must still
- * write and use replacement functions. The replacement error_fn should
- * still do a longjmp to the last setjmp location if you are using this
- * method of error handling. If error_fn or warning_fn is NULL, the
- * default function will be used.
- */
-
-extern PNG_EXPORT(void,png_set_error_fn) PNGARG((png_structp png_ptr,
- png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
-
-/* Return the user pointer associated with the error functions */
-extern PNG_EXPORT(png_voidp,png_get_error_ptr) PNGARG((png_structp png_ptr));
-
-/* Replace the default data output functions with a user supplied one(s).
- * If buffered output is not used, then output_flush_fn can be set to NULL.
- * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time
- * output_flush_fn will be ignored (and thus can be NULL).
- * It is probably a mistake to use NULL for output_flush_fn if
- * write_data_fn is not also NULL unless you have built libpng with
- * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's
- * default flush function, which uses the standard *FILE structure, will
- * be used.
- */
-extern PNG_EXPORT(void,png_set_write_fn) PNGARG((png_structp png_ptr,
- png_voidp io_ptr, png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
-
-/* Replace the default data input function with a user supplied one. */
-extern PNG_EXPORT(void,png_set_read_fn) PNGARG((png_structp png_ptr,
- png_voidp io_ptr, png_rw_ptr read_data_fn));
-
-/* Return the user pointer associated with the I/O functions */
-extern PNG_EXPORT(png_voidp,png_get_io_ptr) PNGARG((png_structp png_ptr));
-
-extern PNG_EXPORT(void,png_set_read_status_fn) PNGARG((png_structp png_ptr,
- png_read_status_ptr read_row_fn));
-
-extern PNG_EXPORT(void,png_set_write_status_fn) PNGARG((png_structp png_ptr,
- png_write_status_ptr write_row_fn));
-
-#ifdef PNG_USER_MEM_SUPPORTED
-/* Replace the default memory allocation functions with user supplied one(s). */
-extern PNG_EXPORT(void,png_set_mem_fn) PNGARG((png_structp png_ptr,
- png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
-/* Return the user pointer associated with the memory functions */
-extern PNG_EXPORT(png_voidp,png_get_mem_ptr) PNGARG((png_structp png_ptr));
-#endif
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_LEGACY_SUPPORTED)
-extern PNG_EXPORT(void,png_set_read_user_transform_fn) PNGARG((png_structp
- png_ptr, png_user_transform_ptr read_user_transform_fn));
-#endif
-
-#if defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_LEGACY_SUPPORTED)
-extern PNG_EXPORT(void,png_set_write_user_transform_fn) PNGARG((png_structp
- png_ptr, png_user_transform_ptr write_user_transform_fn));
-#endif
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_LEGACY_SUPPORTED)
-extern PNG_EXPORT(void,png_set_user_transform_info) PNGARG((png_structp
- png_ptr, png_voidp user_transform_ptr, int user_transform_depth,
- int user_transform_channels));
-/* Return the user pointer associated with the user transform functions */
-extern PNG_EXPORT(png_voidp,png_get_user_transform_ptr)
- PNGARG((png_structp png_ptr));
-#endif
-
-#ifdef PNG_USER_CHUNKS_SUPPORTED
-extern PNG_EXPORT(void,png_set_read_user_chunk_fn) PNGARG((png_structp png_ptr,
- png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
-extern PNG_EXPORT(png_voidp,png_get_user_chunk_ptr) PNGARG((png_structp
- png_ptr));
-#endif
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-/* Sets the function callbacks for the push reader, and a pointer to a
- * user-defined structure available to the callback functions.
- */
-extern PNG_EXPORT(void,png_set_progressive_read_fn) PNGARG((png_structp png_ptr,
- png_voidp progressive_ptr,
- png_progressive_info_ptr info_fn, png_progressive_row_ptr row_fn,
- png_progressive_end_ptr end_fn));
-
-/* returns the user pointer associated with the push read functions */
-extern PNG_EXPORT(png_voidp,png_get_progressive_ptr)
- PNGARG((png_structp png_ptr));
-
-/* function to be called when data becomes available */
-extern PNG_EXPORT(void,png_process_data) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_bytep buffer, png_size_t buffer_size));
-
-/* function that combines rows. Not very much different than the
- * png_combine_row() call. Is this even used?????
- */
-extern PNG_EXPORT(void,png_progressive_combine_row) PNGARG((png_structp png_ptr,
- png_bytep old_row, png_bytep new_row));
-#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
-
-extern PNG_EXPORT(png_voidp,png_malloc) PNGARG((png_structp png_ptr,
- png_uint_32 size));
-
-#if defined(PNG_1_0_X)
-# define png_malloc_warn png_malloc
-#else
-/* Added at libpng version 1.2.4 */
-extern PNG_EXPORT(png_voidp,png_malloc_warn) PNGARG((png_structp png_ptr,
- png_uint_32 size));
-#endif
-
-/* frees a pointer allocated by png_malloc() */
-extern PNG_EXPORT(void,png_free) PNGARG((png_structp png_ptr, png_voidp ptr));
-
-#if defined(PNG_1_0_X)
-/* Function to allocate memory for zlib. */
-extern PNG_EXPORT(voidpf,png_zalloc) PNGARG((voidpf png_ptr, uInt items,
- uInt size));
-
-/* Function to free memory for zlib */
-extern PNG_EXPORT(void,png_zfree) PNGARG((voidpf png_ptr, voidpf ptr));
-#endif
-
-/* Free data that was allocated internally */
-extern PNG_EXPORT(void,png_free_data) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 free_me, int num));
-#ifdef PNG_FREE_ME_SUPPORTED
-/* Reassign responsibility for freeing existing data, whether allocated
- * by libpng or by the application */
-extern PNG_EXPORT(void,png_data_freer) PNGARG((png_structp png_ptr,
- png_infop info_ptr, int freer, png_uint_32 mask));
-#endif
-/* assignments for png_data_freer */
-#define PNG_DESTROY_WILL_FREE_DATA 1
-#define PNG_SET_WILL_FREE_DATA 1
-#define PNG_USER_WILL_FREE_DATA 2
-/* Flags for png_ptr->free_me and info_ptr->free_me */
-#define PNG_FREE_HIST 0x0008
-#define PNG_FREE_ICCP 0x0010
-#define PNG_FREE_SPLT 0x0020
-#define PNG_FREE_ROWS 0x0040
-#define PNG_FREE_PCAL 0x0080
-#define PNG_FREE_SCAL 0x0100
-#define PNG_FREE_UNKN 0x0200
-#define PNG_FREE_LIST 0x0400
-#define PNG_FREE_PLTE 0x1000
-#define PNG_FREE_TRNS 0x2000
-#define PNG_FREE_TEXT 0x4000
-#define PNG_FREE_ALL 0x7fff
-#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
-
-#ifdef PNG_USER_MEM_SUPPORTED
-extern PNG_EXPORT(png_voidp,png_malloc_default) PNGARG((png_structp png_ptr,
- png_uint_32 size));
-extern PNG_EXPORT(void,png_free_default) PNGARG((png_structp png_ptr,
- png_voidp ptr));
-#endif
-
-extern PNG_EXPORT(png_voidp,png_memcpy_check) PNGARG((png_structp png_ptr,
- png_voidp s1, png_voidp s2, png_uint_32 size));
-
-extern PNG_EXPORT(png_voidp,png_memset_check) PNGARG((png_structp png_ptr,
- png_voidp s1, int value, png_uint_32 size));
-
-#if defined(USE_FAR_KEYWORD) /* memory model conversion function */
-extern void *png_far_to_near PNGARG((png_structp png_ptr,png_voidp ptr,
- int check));
-#endif /* USE_FAR_KEYWORD */
-
-#ifndef PNG_NO_ERROR_TEXT
-/* Fatal error in PNG image of libpng - can't continue */
-extern PNG_EXPORT(void,png_error) PNGARG((png_structp png_ptr,
- png_const_charp error_message));
-
-/* The same, but the chunk name is prepended to the error string. */
-extern PNG_EXPORT(void,png_chunk_error) PNGARG((png_structp png_ptr,
- png_const_charp error_message));
-#else
-/* Fatal error in PNG image of libpng - can't continue */
-extern PNG_EXPORT(void,png_err) PNGARG((png_structp png_ptr));
-#endif
-
-#ifndef PNG_NO_WARNINGS
-/* Non-fatal error in libpng. Can continue, but may have a problem. */
-extern PNG_EXPORT(void,png_warning) PNGARG((png_structp png_ptr,
- png_const_charp warning_message));
-
-#ifdef PNG_READ_SUPPORTED
-/* Non-fatal error in libpng, chunk name is prepended to message. */
-extern PNG_EXPORT(void,png_chunk_warning) PNGARG((png_structp png_ptr,
- png_const_charp warning_message));
-#endif /* PNG_READ_SUPPORTED */
-#endif /* PNG_NO_WARNINGS */
-
-/* The png_set_<chunk> functions are for storing values in the png_info_struct.
- * Similarly, the png_get_<chunk> calls are used to read values from the
- * png_info_struct, either storing the parameters in the passed variables, or
- * setting pointers into the png_info_struct where the data is stored. The
- * png_get_<chunk> functions return a non-zero value if the data was available
- * in info_ptr, or return zero and do not change any of the parameters if the
- * data was not available.
- *
- * These functions should be used instead of directly accessing png_info
- * to avoid problems with future changes in the size and internal layout of
- * png_info_struct.
- */
-/* Returns "flag" if chunk data is valid in info_ptr. */
-extern PNG_EXPORT(png_uint_32,png_get_valid) PNGARG((png_structp png_ptr,
-png_infop info_ptr, png_uint_32 flag));
-
-/* Returns number of bytes needed to hold a transformed row. */
-extern PNG_EXPORT(png_uint_32,png_get_rowbytes) PNGARG((png_structp png_ptr,
-png_infop info_ptr));
-
-#if defined(PNG_INFO_IMAGE_SUPPORTED)
-/* Returns row_pointers, which is an array of pointers to scanlines that was
-returned from png_read_png(). */
-extern PNG_EXPORT(png_bytepp,png_get_rows) PNGARG((png_structp png_ptr,
-png_infop info_ptr));
-/* Set row_pointers, which is an array of pointers to scanlines for use
-by png_write_png(). */
-extern PNG_EXPORT(void,png_set_rows) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_bytepp row_pointers));
-#endif
-
-/* Returns number of color channels in image. */
-extern PNG_EXPORT(png_byte,png_get_channels) PNGARG((png_structp png_ptr,
-png_infop info_ptr));
-
-#ifdef PNG_EASY_ACCESS_SUPPORTED
-/* Returns image width in pixels. */
-extern PNG_EXPORT(png_uint_32, png_get_image_width) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-
-/* Returns image height in pixels. */
-extern PNG_EXPORT(png_uint_32, png_get_image_height) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-
-/* Returns image bit_depth. */
-extern PNG_EXPORT(png_byte, png_get_bit_depth) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-
-/* Returns image color_type. */
-extern PNG_EXPORT(png_byte, png_get_color_type) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-
-/* Returns image filter_type. */
-extern PNG_EXPORT(png_byte, png_get_filter_type) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-
-/* Returns image interlace_type. */
-extern PNG_EXPORT(png_byte, png_get_interlace_type) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-
-/* Returns image compression_type. */
-extern PNG_EXPORT(png_byte, png_get_compression_type) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-
-/* Returns image resolution in pixels per meter, from pHYs chunk data. */
-extern PNG_EXPORT(png_uint_32, png_get_pixels_per_meter) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-extern PNG_EXPORT(png_uint_32, png_get_x_pixels_per_meter) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-extern PNG_EXPORT(png_uint_32, png_get_y_pixels_per_meter) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-
-/* Returns pixel aspect ratio, computed from pHYs chunk data. */
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(float, png_get_pixel_aspect_ratio) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-#endif
-
-/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
-extern PNG_EXPORT(png_int_32, png_get_x_offset_pixels) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-extern PNG_EXPORT(png_int_32, png_get_y_offset_pixels) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-extern PNG_EXPORT(png_int_32, png_get_x_offset_microns) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-extern PNG_EXPORT(png_int_32, png_get_y_offset_microns) PNGARG((png_structp
-png_ptr, png_infop info_ptr));
-
-#endif /* PNG_EASY_ACCESS_SUPPORTED */
-
-/* Returns pointer to signature string read from PNG header */
-extern PNG_EXPORT(png_bytep,png_get_signature) PNGARG((png_structp png_ptr,
-png_infop info_ptr));
-
-#if defined(PNG_bKGD_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_bKGD) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_color_16p *background));
-#endif
-
-#if defined(PNG_bKGD_SUPPORTED)
-extern PNG_EXPORT(void,png_set_bKGD) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_color_16p background));
-#endif
-
-#if defined(PNG_cHRM_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(png_uint_32,png_get_cHRM) PNGARG((png_structp png_ptr,
- png_infop info_ptr, double *white_x, double *white_y, double *red_x,
- double *red_y, double *green_x, double *green_y, double *blue_x,
- double *blue_y));
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
-extern PNG_EXPORT(png_uint_32,png_get_cHRM_fixed) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_fixed_point *int_white_x, png_fixed_point
- *int_white_y, png_fixed_point *int_red_x, png_fixed_point *int_red_y,
- png_fixed_point *int_green_x, png_fixed_point *int_green_y, png_fixed_point
- *int_blue_x, png_fixed_point *int_blue_y));
-#endif
-#endif
-
-#if defined(PNG_cHRM_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(void,png_set_cHRM) PNGARG((png_structp png_ptr,
- png_infop info_ptr, double white_x, double white_y, double red_x,
- double red_y, double green_x, double green_y, double blue_x, double blue_y));
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
-extern PNG_EXPORT(void,png_set_cHRM_fixed) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_fixed_point int_white_x, png_fixed_point int_white_y,
- png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
- int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
- png_fixed_point int_blue_y));
-#endif
-#endif
-
-#if defined(PNG_gAMA_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(png_uint_32,png_get_gAMA) PNGARG((png_structp png_ptr,
- png_infop info_ptr, double *file_gamma));
-#endif
-extern PNG_EXPORT(png_uint_32,png_get_gAMA_fixed) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_fixed_point *int_file_gamma));
-#endif
-
-#if defined(PNG_gAMA_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(void,png_set_gAMA) PNGARG((png_structp png_ptr,
- png_infop info_ptr, double file_gamma));
-#endif
-extern PNG_EXPORT(void,png_set_gAMA_fixed) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_fixed_point int_file_gamma));
-#endif
-
-#if defined(PNG_hIST_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_hIST) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_16p *hist));
-#endif
-
-#if defined(PNG_hIST_SUPPORTED)
-extern PNG_EXPORT(void,png_set_hIST) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_16p hist));
-#endif
-
-extern PNG_EXPORT(png_uint_32,png_get_IHDR) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 *width, png_uint_32 *height,
- int *bit_depth, int *color_type, int *interlace_method,
- int *compression_method, int *filter_method));
-
-extern PNG_EXPORT(void,png_set_IHDR) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
- int color_type, int interlace_method, int compression_method,
- int filter_method));
-
-#if defined(PNG_oFFs_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_oFFs) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
- int *unit_type));
-#endif
-
-#if defined(PNG_oFFs_SUPPORTED)
-extern PNG_EXPORT(void,png_set_oFFs) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_int_32 offset_x, png_int_32 offset_y,
- int unit_type));
-#endif
-
-#if defined(PNG_pCAL_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_pCAL) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
- int *type, int *nparams, png_charp *units, png_charpp *params));
-#endif
-
-#if defined(PNG_pCAL_SUPPORTED)
-extern PNG_EXPORT(void,png_set_pCAL) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_charp purpose, png_int_32 X0, png_int_32 X1,
- int type, int nparams, png_charp units, png_charpp params));
-#endif
-
-#if defined(PNG_pHYs_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_pHYs) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
-#endif
-
-#if defined(PNG_pHYs_SUPPORTED)
-extern PNG_EXPORT(void,png_set_pHYs) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
-#endif
-
-extern PNG_EXPORT(png_uint_32,png_get_PLTE) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_colorp *palette, int *num_palette));
-
-extern PNG_EXPORT(void,png_set_PLTE) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_colorp palette, int num_palette));
-
-#if defined(PNG_sBIT_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_sBIT) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_color_8p *sig_bit));
-#endif
-
-#if defined(PNG_sBIT_SUPPORTED)
-extern PNG_EXPORT(void,png_set_sBIT) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_color_8p sig_bit));
-#endif
-
-#if defined(PNG_sRGB_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_sRGB) PNGARG((png_structp png_ptr,
- png_infop info_ptr, int *intent));
-#endif
-
-#if defined(PNG_sRGB_SUPPORTED)
-extern PNG_EXPORT(void,png_set_sRGB) PNGARG((png_structp png_ptr,
- png_infop info_ptr, int intent));
-extern PNG_EXPORT(void,png_set_sRGB_gAMA_and_cHRM) PNGARG((png_structp png_ptr,
- png_infop info_ptr, int intent));
-#endif
-
-#if defined(PNG_iCCP_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_iCCP) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_charpp name, int *compression_type,
- png_charpp profile, png_uint_32 *proflen));
- /* Note to maintainer: profile should be png_bytepp */
-#endif
-
-#if defined(PNG_iCCP_SUPPORTED)
-extern PNG_EXPORT(void,png_set_iCCP) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_charp name, int compression_type,
- png_charp profile, png_uint_32 proflen));
- /* Note to maintainer: profile should be png_bytep */
-#endif
-
-#if defined(PNG_sPLT_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_sPLT) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_sPLT_tpp entries));
-#endif
-
-#if defined(PNG_sPLT_SUPPORTED)
-extern PNG_EXPORT(void,png_set_sPLT) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_sPLT_tp entries, int nentries));
-#endif
-
-#if defined(PNG_TEXT_SUPPORTED)
-/* png_get_text also returns the number of text chunks in *num_text */
-extern PNG_EXPORT(png_uint_32,png_get_text) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_textp *text_ptr, int *num_text));
-#endif
-
-/*
- * Note while png_set_text() will accept a structure whose text,
- * language, and translated keywords are NULL pointers, the structure
- * returned by png_get_text will always contain regular
- * zero-terminated C strings. They might be empty strings but
- * they will never be NULL pointers.
- */
-
-#if defined(PNG_TEXT_SUPPORTED)
-extern PNG_EXPORT(void,png_set_text) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_textp text_ptr, int num_text));
-#endif
-
-#if defined(PNG_tIME_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_tIME) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_timep *mod_time));
-#endif
-
-#if defined(PNG_tIME_SUPPORTED)
-extern PNG_EXPORT(void,png_set_tIME) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_timep mod_time));
-#endif
-
-#if defined(PNG_tRNS_SUPPORTED)
-extern PNG_EXPORT(png_uint_32,png_get_tRNS) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_bytep *trans, int *num_trans,
- png_color_16p *trans_values));
-#endif
-
-#if defined(PNG_tRNS_SUPPORTED)
-extern PNG_EXPORT(void,png_set_tRNS) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_bytep trans, int num_trans,
- png_color_16p trans_values));
-#endif
-
-#if defined(PNG_tRNS_SUPPORTED)
-#endif
-
-#if defined(PNG_sCAL_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(png_uint_32,png_get_sCAL) PNGARG((png_structp png_ptr,
- png_infop info_ptr, int *unit, double *width, double *height));
-#else
-#ifdef PNG_FIXED_POINT_SUPPORTED
-extern PNG_EXPORT(png_uint_32,png_get_sCAL_s) PNGARG((png_structp png_ptr,
- png_infop info_ptr, int *unit, png_charpp swidth, png_charpp sheight));
-#endif
-#endif
-#endif /* PNG_sCAL_SUPPORTED */
-
-#if defined(PNG_sCAL_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-extern PNG_EXPORT(void,png_set_sCAL) PNGARG((png_structp png_ptr,
- png_infop info_ptr, int unit, double width, double height));
-#else
-#ifdef PNG_FIXED_POINT_SUPPORTED
-extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
- png_infop info_ptr, int unit, png_charp swidth, png_charp sheight));
-#endif
-#endif
-#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
-
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
-/* provide a list of chunks and how they are to be handled, if the built-in
- handling or default unknown chunk handling is not desired. Any chunks not
- listed will be handled in the default manner. The IHDR and IEND chunks
- must not be listed.
- keep = 0: follow default behaviour
- = 1: do not keep
- = 2: keep only if safe-to-copy
- = 3: keep even if unsafe-to-copy
-*/
-extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
- png_ptr, int keep, png_bytep chunk_list, int num_chunks));
-extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
-extern PNG_EXPORT(void, png_set_unknown_chunk_location)
- PNGARG((png_structp png_ptr, png_infop info_ptr, int chunk, int location));
-extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
- png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
-#endif
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
- chunk_name));
-#endif
-
-/* Png_free_data() will turn off the "valid" flag for anything it frees.
- If you need to turn it off for a chunk that your application has freed,
- you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); */
-extern PNG_EXPORT(void, png_set_invalid) PNGARG((png_structp png_ptr,
- png_infop info_ptr, int mask));
-
-#if defined(PNG_INFO_IMAGE_SUPPORTED)
-/* The "params" pointer is currently not used and is for future expansion. */
-extern PNG_EXPORT(void, png_read_png) PNGARG((png_structp png_ptr,
- png_infop info_ptr,
- int transforms,
- png_voidp params));
-extern PNG_EXPORT(void, png_write_png) PNGARG((png_structp png_ptr,
- png_infop info_ptr,
- int transforms,
- png_voidp params));
-#endif
-
-/* Define PNG_DEBUG at compile time for debugging information. Higher
- * numbers for PNG_DEBUG mean more debugging information. This has
- * only been added since version 0.95 so it is not implemented throughout
- * libpng yet, but more support will be added as needed.
- */
-#ifdef PNG_DEBUG
-#if (PNG_DEBUG > 0)
-#if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER)
-#include <crtdbg.h>
-#if (PNG_DEBUG > 1)
-#ifndef _DEBUG
-# define _DEBUG
-#endif
-#ifndef png_debug
-#define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE)
-#endif
-#ifndef png_debug1
-#define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1)
-#endif
-#ifndef png_debug2
-#define png_debug2(l,m,p1,p2) _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2)
-#endif
-#endif
-#else /* PNG_DEBUG_FILE || !_MSC_VER */
-#ifndef PNG_DEBUG_FILE
-#define PNG_DEBUG_FILE stderr
-#endif /* PNG_DEBUG_FILE */
-
-#if (PNG_DEBUG > 1)
-/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
- * non-ISO compilers */
-# ifdef __STDC__
-# ifndef png_debug
-# define png_debug(l,m) \
- { \
- int num_tabs=l; \
- fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
- (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \
- }
-# endif
-# ifndef png_debug1
-# define png_debug1(l,m,p1) \
- { \
- int num_tabs=l; \
- fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
- (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \
- }
-# endif
-# ifndef png_debug2
-# define png_debug2(l,m,p1,p2) \
- { \
- int num_tabs=l; \
- fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \
- (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \
- }
-# endif
-# else /* __STDC __ */
-# ifndef png_debug
-# define png_debug(l,m) \
- { \
- int num_tabs=l; \
- char format[256]; \
- snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
- (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
- m,PNG_STRING_NEWLINE); \
- fprintf(PNG_DEBUG_FILE,format); \
- }
-# endif
-# ifndef png_debug1
-# define png_debug1(l,m,p1) \
- { \
- int num_tabs=l; \
- char format[256]; \
- snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
- (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
- m,PNG_STRING_NEWLINE); \
- fprintf(PNG_DEBUG_FILE,format,p1); \
- }
-# endif
-# ifndef png_debug2
-# define png_debug2(l,m,p1,p2) \
- { \
- int num_tabs=l; \
- char format[256]; \
- snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \
- (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \
- m,PNG_STRING_NEWLINE); \
- fprintf(PNG_DEBUG_FILE,format,p1,p2); \
- }
-# endif
-# endif /* __STDC __ */
-#endif /* (PNG_DEBUG > 1) */
-
-#endif /* _MSC_VER */
-#endif /* (PNG_DEBUG > 0) */
-#endif /* PNG_DEBUG */
-#ifndef png_debug
-#define png_debug(l, m)
-#endif
-#ifndef png_debug1
-#define png_debug1(l, m, p1)
-#endif
-#ifndef png_debug2
-#define png_debug2(l, m, p1, p2)
-#endif
-
-extern PNG_EXPORT(png_charp,png_get_copyright) PNGARG((png_structp png_ptr));
-extern PNG_EXPORT(png_charp,png_get_header_ver) PNGARG((png_structp png_ptr));
-extern PNG_EXPORT(png_charp,png_get_header_version) PNGARG((png_structp png_ptr));
-extern PNG_EXPORT(png_charp,png_get_libpng_ver) PNGARG((png_structp png_ptr));
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-extern PNG_EXPORT(png_uint_32,png_permit_mng_features) PNGARG((png_structp
- png_ptr, png_uint_32 mng_features_permitted));
-#endif
-
-/* For use in png_set_keep_unknown, added to version 1.2.6 */
-#define PNG_HANDLE_CHUNK_AS_DEFAULT 0
-#define PNG_HANDLE_CHUNK_NEVER 1
-#define PNG_HANDLE_CHUNK_IF_SAFE 2
-#define PNG_HANDLE_CHUNK_ALWAYS 3
-
-/* Added to version 1.2.0 */
-#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
-#if defined(PNG_MMX_CODE_SUPPORTED)
-#define PNG_ASM_FLAG_MMX_SUPPORT_COMPILED 0x01 /* not user-settable */
-#define PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU 0x02 /* not user-settable */
-#define PNG_ASM_FLAG_MMX_READ_COMBINE_ROW 0x04
-#define PNG_ASM_FLAG_MMX_READ_INTERLACE 0x08
-#define PNG_ASM_FLAG_MMX_READ_FILTER_SUB 0x10
-#define PNG_ASM_FLAG_MMX_READ_FILTER_UP 0x20
-#define PNG_ASM_FLAG_MMX_READ_FILTER_AVG 0x40
-#define PNG_ASM_FLAG_MMX_READ_FILTER_PAETH 0x80
-#define PNG_ASM_FLAGS_INITIALIZED 0x80000000 /* not user-settable */
-
-#define PNG_MMX_READ_FLAGS ( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
- | PNG_ASM_FLAG_MMX_READ_INTERLACE \
- | PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
- | PNG_ASM_FLAG_MMX_READ_FILTER_UP \
- | PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
- | PNG_ASM_FLAG_MMX_READ_FILTER_PAETH )
-#define PNG_MMX_WRITE_FLAGS ( 0 )
-
-#define PNG_MMX_FLAGS ( PNG_ASM_FLAG_MMX_SUPPORT_COMPILED \
- | PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU \
- | PNG_MMX_READ_FLAGS \
- | PNG_MMX_WRITE_FLAGS )
-
-#define PNG_SELECT_READ 1
-#define PNG_SELECT_WRITE 2
-#endif /* PNG_MMX_CODE_SUPPORTED */
-
-#if !defined(PNG_1_0_X)
-/* pngget.c */
-extern PNG_EXPORT(png_uint_32,png_get_mmx_flagmask)
- PNGARG((int flag_select, int *compilerID));
-
-/* pngget.c */
-extern PNG_EXPORT(png_uint_32,png_get_asm_flagmask)
- PNGARG((int flag_select));
-
-/* pngget.c */
-extern PNG_EXPORT(png_uint_32,png_get_asm_flags)
- PNGARG((png_structp png_ptr));
-
-/* pngget.c */
-extern PNG_EXPORT(png_byte,png_get_mmx_bitdepth_threshold)
- PNGARG((png_structp png_ptr));
-
-/* pngget.c */
-extern PNG_EXPORT(png_uint_32,png_get_mmx_rowbytes_threshold)
- PNGARG((png_structp png_ptr));
-
-/* pngset.c */
-extern PNG_EXPORT(void,png_set_asm_flags)
- PNGARG((png_structp png_ptr, png_uint_32 asm_flags));
-
-/* pngset.c */
-extern PNG_EXPORT(void,png_set_mmx_thresholds)
- PNGARG((png_structp png_ptr, png_byte mmx_bitdepth_threshold,
- png_uint_32 mmx_rowbytes_threshold));
-
-#endif /* PNG_1_0_X */
-
-#if !defined(PNG_1_0_X)
-/* png.c, pnggccrd.c, or pngvcrd.c */
-extern PNG_EXPORT(int,png_mmx_support) PNGARG((void));
-#endif /* PNG_1_0_X */
-#endif /* PNG_ASSEMBLER_CODE_SUPPORTED */
-
-/* Strip the prepended error numbers ("#nnn ") from error and warning
- * messages before passing them to the error or warning handler. */
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-extern PNG_EXPORT(void,png_set_strip_error_numbers) PNGARG((png_structp
- png_ptr, png_uint_32 strip_mode));
-#endif
-
-/* Added at libpng-1.2.6 */
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
-extern PNG_EXPORT(void,png_set_user_limits) PNGARG((png_structp
- png_ptr, png_uint_32 user_width_max, png_uint_32 user_height_max));
-extern PNG_EXPORT(png_uint_32,png_get_user_width_max) PNGARG((png_structp
- png_ptr));
-extern PNG_EXPORT(png_uint_32,png_get_user_height_max) PNGARG((png_structp
- png_ptr));
-#endif
-
-
-/* Maintainer: Put new public prototypes here ^, in libpng.3, and project defs */
-
-#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED
-/* With these routines we avoid an integer divide, which will be slower on
- * most machines. However, it does take more operations than the corresponding
- * divide method, so it may be slower on a few RISC systems. There are two
- * shifts (by 8 or 16 bits) and an addition, versus a single integer divide.
- *
- * Note that the rounding factors are NOT supposed to be the same! 128 and
- * 32768 are correct for the NODIV code; 127 and 32767 are correct for the
- * standard method.
- *
- * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ]
- */
-
- /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
-
-# define png_composite(composite, fg, alpha, bg) \
- { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) * (png_uint_16)(alpha) \
- + (png_uint_16)(bg)*(png_uint_16)(255 - \
- (png_uint_16)(alpha)) + (png_uint_16)128); \
- (composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
-
-# define png_composite_16(composite, fg, alpha, bg) \
- { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) * (png_uint_32)(alpha) \
- + (png_uint_32)(bg)*(png_uint_32)(65535L - \
- (png_uint_32)(alpha)) + (png_uint_32)32768L); \
- (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
-
-#else /* standard method using integer division */
-
-# define png_composite(composite, fg, alpha, bg) \
- (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
- (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
- (png_uint_16)127) / 255)
-
-# define png_composite_16(composite, fg, alpha, bg) \
- (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
- (png_uint_32)(bg)*(png_uint_32)(65535L - (png_uint_32)(alpha)) + \
- (png_uint_32)32767) / (png_uint_32)65535L)
-
-#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */
-
-/* Inline macros to do direct reads of bytes from the input buffer. These
- * require that you are using an architecture that uses PNG byte ordering
- * (MSB first) and supports unaligned data storage. I think that PowerPC
- * in big-endian mode and 680x0 are the only ones that will support this.
- * The x86 line of processors definitely do not. The png_get_int_32()
- * routine also assumes we are using two's complement format for negative
- * values, which is almost certainly true.
- */
-#if defined(PNG_READ_BIG_ENDIAN_SUPPORTED)
-# define png_get_uint_32(buf) ( *((png_uint_32p) (buf)))
-# define png_get_uint_16(buf) ( *((png_uint_16p) (buf)))
-# define png_get_int_32(buf) ( *((png_int_32p) (buf)))
-#else
-extern PNG_EXPORT(png_uint_32,png_get_uint_32) PNGARG((png_bytep buf));
-extern PNG_EXPORT(png_uint_16,png_get_uint_16) PNGARG((png_bytep buf));
-extern PNG_EXPORT(png_int_32,png_get_int_32) PNGARG((png_bytep buf));
-#endif /* !PNG_READ_BIG_ENDIAN_SUPPORTED */
-extern PNG_EXPORT(png_uint_32,png_get_uint_31)
- PNGARG((png_structp png_ptr, png_bytep buf));
-/* No png_get_int_16 -- may be added if there's a real need for it. */
-
-/* Place a 32-bit number into a buffer in PNG byte order (big-endian).
- */
-extern PNG_EXPORT(void,png_save_uint_32)
- PNGARG((png_bytep buf, png_uint_32 i));
-extern PNG_EXPORT(void,png_save_int_32)
- PNGARG((png_bytep buf, png_int_32 i));
-
-/* Place a 16-bit number into a buffer in PNG byte order.
- * The parameter is declared unsigned int, not png_uint_16,
- * just to avoid potential problems on pre-ANSI C compilers.
- */
-extern PNG_EXPORT(void,png_save_uint_16)
- PNGARG((png_bytep buf, unsigned int i));
-/* No png_save_int_16 -- may be added if there's a real need for it. */
-
-/* ************************************************************************* */
-
-/* These next functions are used internally in the code. They generally
- * shouldn't be used unless you are writing code to add or replace some
- * functionality in libpng. More information about most functions can
- * be found in the files where the functions are located.
- */
-
-
-/* Various modes of operation, that are visible to applications because
- * they are used for unknown chunk location.
- */
-#define PNG_HAVE_IHDR 0x01
-#define PNG_HAVE_PLTE 0x02
-#define PNG_HAVE_IDAT 0x04
-#define PNG_AFTER_IDAT 0x08 /* Have complete zlib datastream */
-#define PNG_HAVE_IEND 0x10
-
-#if defined(PNG_INTERNAL)
-
-/* More modes of operation. Note that after an init, mode is set to
- * zero automatically when the structure is created.
- */
-#define PNG_HAVE_gAMA 0x20
-#define PNG_HAVE_cHRM 0x40
-#define PNG_HAVE_sRGB 0x80
-#define PNG_HAVE_CHUNK_HEADER 0x100
-#define PNG_WROTE_tIME 0x200
-#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
-#define PNG_BACKGROUND_IS_GRAY 0x800
-#define PNG_HAVE_PNG_SIGNATURE 0x1000
-#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
-
-/* flags for the transformations the PNG library does on the image data */
-#define PNG_BGR 0x0001
-#define PNG_INTERLACE 0x0002
-#define PNG_PACK 0x0004
-#define PNG_SHIFT 0x0008
-#define PNG_SWAP_BYTES 0x0010
-#define PNG_INVERT_MONO 0x0020
-#define PNG_DITHER 0x0040
-#define PNG_BACKGROUND 0x0080
-#define PNG_BACKGROUND_EXPAND 0x0100
- /* 0x0200 unused */
-#define PNG_16_TO_8 0x0400
-#define PNG_RGBA 0x0800
-#define PNG_EXPAND 0x1000
-#define PNG_GAMMA 0x2000
-#define PNG_GRAY_TO_RGB 0x4000
-#define PNG_FILLER 0x8000L
-#define PNG_PACKSWAP 0x10000L
-#define PNG_SWAP_ALPHA 0x20000L
-#define PNG_STRIP_ALPHA 0x40000L
-#define PNG_INVERT_ALPHA 0x80000L
-#define PNG_USER_TRANSFORM 0x100000L
-#define PNG_RGB_TO_GRAY_ERR 0x200000L
-#define PNG_RGB_TO_GRAY_WARN 0x400000L
-#define PNG_RGB_TO_GRAY 0x600000L /* two bits, RGB_TO_GRAY_ERR|WARN */
- /* 0x800000L Unused */
-#define PNG_ADD_ALPHA 0x1000000L /* Added to libpng-1.2.7 */
-#define PNG_EXPAND_tRNS 0x2000000L /* Added to libpng-1.2.9 */
- /* 0x4000000L unused */
- /* 0x8000000L unused */
- /* 0x10000000L unused */
- /* 0x20000000L unused */
- /* 0x40000000L unused */
-
-/* flags for png_create_struct */
-#define PNG_STRUCT_PNG 0x0001
-#define PNG_STRUCT_INFO 0x0002
-
-/* Scaling factor for filter heuristic weighting calculations */
-#define PNG_WEIGHT_SHIFT 8
-#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
-#define PNG_COST_SHIFT 3
-#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
-
-/* flags for the png_ptr->flags rather than declaring a byte for each one */
-#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
-#define PNG_FLAG_ZLIB_CUSTOM_LEVEL 0x0002
-#define PNG_FLAG_ZLIB_CUSTOM_MEM_LEVEL 0x0004
-#define PNG_FLAG_ZLIB_CUSTOM_WINDOW_BITS 0x0008
-#define PNG_FLAG_ZLIB_CUSTOM_METHOD 0x0010
-#define PNG_FLAG_ZLIB_FINISHED 0x0020
-#define PNG_FLAG_ROW_INIT 0x0040
-#define PNG_FLAG_FILLER_AFTER 0x0080
-#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
-#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
-#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
-#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
-#define PNG_FLAG_FREE_PLTE 0x1000
-#define PNG_FLAG_FREE_TRNS 0x2000
-#define PNG_FLAG_FREE_HIST 0x4000
-#define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000L
-#define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000L
-#define PNG_FLAG_LIBRARY_MISMATCH 0x20000L
-#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000L
-#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000L
-#define PNG_FLAG_MALLOC_NULL_MEM_OK 0x100000L
-#define PNG_FLAG_ADD_ALPHA 0x200000L /* Added to libpng-1.2.8 */
-#define PNG_FLAG_STRIP_ALPHA 0x400000L /* Added to libpng-1.2.8 */
- /* 0x800000L unused */
- /* 0x1000000L unused */
- /* 0x2000000L unused */
- /* 0x4000000L unused */
- /* 0x8000000L unused */
- /* 0x10000000L unused */
- /* 0x20000000L unused */
- /* 0x40000000L unused */
-
-#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
- PNG_FLAG_CRC_ANCILLARY_NOWARN)
-
-#define PNG_FLAG_CRC_CRITICAL_MASK (PNG_FLAG_CRC_CRITICAL_USE | \
- PNG_FLAG_CRC_CRITICAL_IGNORE)
-
-#define PNG_FLAG_CRC_MASK (PNG_FLAG_CRC_ANCILLARY_MASK | \
- PNG_FLAG_CRC_CRITICAL_MASK)
-
-/* save typing and make code easier to understand */
-
-#define PNG_COLOR_DIST(c1, c2) (abs((int)((c1).red) - (int)((c2).red)) + \
- abs((int)((c1).green) - (int)((c2).green)) + \
- abs((int)((c1).blue) - (int)((c2).blue)))
-
-/* Added to libpng-1.2.6 JB */
-#define PNG_ROWBYTES(pixel_bits, width) \
- ((pixel_bits) >= 8 ? \
- ((width) * (((png_uint_32)(pixel_bits)) >> 3)) : \
- (( ((width) * ((png_uint_32)(pixel_bits))) + 7) >> 3) )
-
-/* PNG_OUT_OF_RANGE returns true if value is outside the range
- ideal-delta..ideal+delta. Each argument is evaluated twice.
- "ideal" and "delta" should be constants, normally simple
- integers, "value" a variable. Added to libpng-1.2.6 JB */
-#define PNG_OUT_OF_RANGE(value, ideal, delta) \
- ( (value) < (ideal)-(delta) || (value) > (ideal)+(delta) )
-
-/* variables declared in png.c - only it needs to define PNG_NO_EXTERN */
-#if !defined(PNG_NO_EXTERN) || defined(PNG_ALWAYS_EXTERN)
-/* place to hold the signature string for a PNG file. */
-#ifdef PNG_USE_GLOBAL_ARRAYS
- PNG_EXPORT_VAR (PNG_CONST png_byte FARDATA) png_sig[8];
-#else
-#endif
-#endif /* PNG_NO_EXTERN */
-
-/* Constant strings for known chunk types. If you need to add a chunk,
- * define the name here, and add an invocation of the macro in png.c and
- * wherever it's needed.
- */
-#define PNG_IHDR png_byte png_IHDR[5] = { 73, 72, 68, 82, '\0'}
-#define PNG_IDAT png_byte png_IDAT[5] = { 73, 68, 65, 84, '\0'}
-#define PNG_IEND png_byte png_IEND[5] = { 73, 69, 78, 68, '\0'}
-#define PNG_PLTE png_byte png_PLTE[5] = { 80, 76, 84, 69, '\0'}
-#define PNG_bKGD png_byte png_bKGD[5] = { 98, 75, 71, 68, '\0'}
-#define PNG_cHRM png_byte png_cHRM[5] = { 99, 72, 82, 77, '\0'}
-#define PNG_gAMA png_byte png_gAMA[5] = {103, 65, 77, 65, '\0'}
-#define PNG_hIST png_byte png_hIST[5] = {104, 73, 83, 84, '\0'}
-#define PNG_iCCP png_byte png_iCCP[5] = {105, 67, 67, 80, '\0'}
-#define PNG_iTXt png_byte png_iTXt[5] = {105, 84, 88, 116, '\0'}
-#define PNG_oFFs png_byte png_oFFs[5] = {111, 70, 70, 115, '\0'}
-#define PNG_pCAL png_byte png_pCAL[5] = {112, 67, 65, 76, '\0'}
-#define PNG_sCAL png_byte png_sCAL[5] = {115, 67, 65, 76, '\0'}
-#define PNG_pHYs png_byte png_pHYs[5] = {112, 72, 89, 115, '\0'}
-#define PNG_sBIT png_byte png_sBIT[5] = {115, 66, 73, 84, '\0'}
-#define PNG_sPLT png_byte png_sPLT[5] = {115, 80, 76, 84, '\0'}
-#define PNG_sRGB png_byte png_sRGB[5] = {115, 82, 71, 66, '\0'}
-#define PNG_tEXt png_byte png_tEXt[5] = {116, 69, 88, 116, '\0'}
-#define PNG_tIME png_byte png_tIME[5] = {116, 73, 77, 69, '\0'}
-#define PNG_tRNS png_byte png_tRNS[5] = {116, 82, 78, 83, '\0'}
-#define PNG_zTXt png_byte png_zTXt[5] = {122, 84, 88, 116, '\0'}
-
-#ifdef PNG_USE_GLOBAL_ARRAYS
-PNG_EXPORT_VAR (png_byte FARDATA) png_IHDR[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_IDAT[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_IEND[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_PLTE[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_bKGD[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_cHRM[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_gAMA[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_hIST[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_iCCP[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_iTXt[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_oFFs[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_pCAL[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_sCAL[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_pHYs[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_sBIT[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_sPLT[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_sRGB[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_tEXt[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_tIME[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_tRNS[5];
-PNG_EXPORT_VAR (png_byte FARDATA) png_zTXt[5];
-#endif /* PNG_USE_GLOBAL_ARRAYS */
-
-#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
-/* Initialize png_ptr struct for reading, and allocate any other memory.
- * (old interface - DEPRECATED - use png_create_read_struct instead).
- */
-extern PNG_EXPORT(void,png_read_init) PNGARG((png_structp png_ptr));
-#undef png_read_init
-#define png_read_init(png_ptr) png_read_init_3(&png_ptr, \
- PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
-#endif
-
-extern PNG_EXPORT(void,png_read_init_3) PNGARG((png_structpp ptr_ptr,
- png_const_charp user_png_ver, png_size_t png_struct_size));
-#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
-extern PNG_EXPORT(void,png_read_init_2) PNGARG((png_structp png_ptr,
- png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
- png_info_size));
-#endif
-
-#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
-/* Initialize png_ptr struct for writing, and allocate any other memory.
- * (old interface - DEPRECATED - use png_create_write_struct instead).
- */
-extern PNG_EXPORT(void,png_write_init) PNGARG((png_structp png_ptr));
-#undef png_write_init
-#define png_write_init(png_ptr) png_write_init_3(&png_ptr, \
- PNG_LIBPNG_VER_STRING, png_sizeof(png_struct));
-#endif
-
-extern PNG_EXPORT(void,png_write_init_3) PNGARG((png_structpp ptr_ptr,
- png_const_charp user_png_ver, png_size_t png_struct_size));
-extern PNG_EXPORT(void,png_write_init_2) PNGARG((png_structp png_ptr,
- png_const_charp user_png_ver, png_size_t png_struct_size, png_size_t
- png_info_size));
-
-/* Allocate memory for an internal libpng struct */
-PNG_EXTERN png_voidp png_create_struct PNGARG((int type));
-
-/* Free memory from internal libpng struct */
-PNG_EXTERN void png_destroy_struct PNGARG((png_voidp struct_ptr));
-
-PNG_EXTERN png_voidp png_create_struct_2 PNGARG((int type, png_malloc_ptr
- malloc_fn, png_voidp mem_ptr));
-PNG_EXTERN void png_destroy_struct_2 PNGARG((png_voidp struct_ptr,
- png_free_ptr free_fn, png_voidp mem_ptr));
-
-/* Free any memory that info_ptr points to and reset struct. */
-PNG_EXTERN void png_info_destroy PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-
-#ifndef PNG_1_0_X
-/* Function to allocate memory for zlib. */
-PNG_EXTERN voidpf png_zalloc PNGARG((voidpf png_ptr, uInt items, uInt size));
-
-/* Function to free memory for zlib */
-PNG_EXTERN void png_zfree PNGARG((voidpf png_ptr, voidpf ptr));
-
-#ifdef PNG_SIZE_T
-/* Function to convert a sizeof an item to png_sizeof item */
- PNG_EXTERN png_size_t PNGAPI png_convert_size PNGARG((size_t size));
-#endif
-
-/* Next four functions are used internally as callbacks. PNGAPI is required
- * but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3. */
-
-PNG_EXTERN void PNGAPI png_default_read_data PNGARG((png_structp png_ptr,
- png_bytep data, png_size_t length));
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-PNG_EXTERN void PNGAPI png_push_fill_buffer PNGARG((png_structp png_ptr,
- png_bytep buffer, png_size_t length));
-#endif
-
-PNG_EXTERN void PNGAPI png_default_write_data PNGARG((png_structp png_ptr,
- png_bytep data, png_size_t length));
-
-#if defined(PNG_WRITE_FLUSH_SUPPORTED)
-#if !defined(PNG_NO_STDIO)
-PNG_EXTERN void PNGAPI png_default_flush PNGARG((png_structp png_ptr));
-#endif
-#endif
-#else /* PNG_1_0_X */
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-PNG_EXTERN void png_push_fill_buffer PNGARG((png_structp png_ptr,
- png_bytep buffer, png_size_t length));
-#endif
-#endif /* PNG_1_0_X */
-
-/* Reset the CRC variable */
-PNG_EXTERN void png_reset_crc PNGARG((png_structp png_ptr));
-
-/* Write the "data" buffer to whatever output you are using. */
-PNG_EXTERN void png_write_data PNGARG((png_structp png_ptr, png_bytep data,
- png_size_t length));
-
-/* Read data from whatever input you are using into the "data" buffer */
-PNG_EXTERN void png_read_data PNGARG((png_structp png_ptr, png_bytep data,
- png_size_t length));
-
-/* Read bytes into buf, and update png_ptr->crc */
-PNG_EXTERN void png_crc_read PNGARG((png_structp png_ptr, png_bytep buf,
- png_size_t length));
-
-/* Decompress data in a chunk that uses compression */
-#if defined(PNG_zTXt_SUPPORTED) || defined(PNG_iTXt_SUPPORTED) || \
- defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
-PNG_EXTERN void png_decompress_chunk PNGARG((png_structp png_ptr,
- int comp_type, png_size_t chunklength,
- png_size_t prefix_length, png_size_t *data_length));
-#endif
-
-/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
-PNG_EXTERN int png_crc_finish PNGARG((png_structp png_ptr, png_uint_32 skip));
-
-/* Read the CRC from the file and compare it to the libpng calculated CRC */
-PNG_EXTERN int png_crc_error PNGARG((png_structp png_ptr));
-
-/* Calculate the CRC over a section of data. Note that we are only
- * passing a maximum of 64K on systems that have this as a memory limit,
- * since this is the maximum buffer size we can specify.
- */
-PNG_EXTERN void png_calculate_crc PNGARG((png_structp png_ptr, png_bytep ptr,
- png_size_t length));
-
-#if defined(PNG_WRITE_FLUSH_SUPPORTED)
-PNG_EXTERN void png_flush PNGARG((png_structp png_ptr));
-#endif
-
-/* simple function to write the signature */
-PNG_EXTERN void png_write_sig PNGARG((png_structp png_ptr));
-
-/* write various chunks */
-
-/* Write the IHDR chunk, and update the png_struct with the necessary
- * information.
- */
-PNG_EXTERN void png_write_IHDR PNGARG((png_structp png_ptr, png_uint_32 width,
- png_uint_32 height,
- int bit_depth, int color_type, int compression_method, int filter_method,
- int interlace_method));
-
-PNG_EXTERN void png_write_PLTE PNGARG((png_structp png_ptr, png_colorp palette,
- png_uint_32 num_pal));
-
-PNG_EXTERN void png_write_IDAT PNGARG((png_structp png_ptr, png_bytep data,
- png_size_t length));
-
-PNG_EXTERN void png_write_IEND PNGARG((png_structp png_ptr));
-
-#if defined(PNG_WRITE_gAMA_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-PNG_EXTERN void png_write_gAMA PNGARG((png_structp png_ptr, double file_gamma));
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
-PNG_EXTERN void png_write_gAMA_fixed PNGARG((png_structp png_ptr, png_fixed_point
- file_gamma));
-#endif
-#endif
-
-#if defined(PNG_WRITE_sBIT_SUPPORTED)
-PNG_EXTERN void png_write_sBIT PNGARG((png_structp png_ptr, png_color_8p sbit,
- int color_type));
-#endif
-
-#if defined(PNG_WRITE_cHRM_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-PNG_EXTERN void png_write_cHRM PNGARG((png_structp png_ptr,
- double white_x, double white_y,
- double red_x, double red_y, double green_x, double green_y,
- double blue_x, double blue_y));
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
-PNG_EXTERN void png_write_cHRM_fixed PNGARG((png_structp png_ptr,
- png_fixed_point int_white_x, png_fixed_point int_white_y,
- png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
- int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
- png_fixed_point int_blue_y));
-#endif
-#endif
-
-#if defined(PNG_WRITE_sRGB_SUPPORTED)
-PNG_EXTERN void png_write_sRGB PNGARG((png_structp png_ptr,
- int intent));
-#endif
-
-#if defined(PNG_WRITE_iCCP_SUPPORTED)
-PNG_EXTERN void png_write_iCCP PNGARG((png_structp png_ptr,
- png_charp name, int compression_type,
- png_charp profile, int proflen));
- /* Note to maintainer: profile should be png_bytep */
-#endif
-
-#if defined(PNG_WRITE_sPLT_SUPPORTED)
-PNG_EXTERN void png_write_sPLT PNGARG((png_structp png_ptr,
- png_sPLT_tp palette));
-#endif
-
-#if defined(PNG_WRITE_tRNS_SUPPORTED)
-PNG_EXTERN void png_write_tRNS PNGARG((png_structp png_ptr, png_bytep trans,
- png_color_16p values, int number, int color_type));
-#endif
-
-#if defined(PNG_WRITE_bKGD_SUPPORTED)
-PNG_EXTERN void png_write_bKGD PNGARG((png_structp png_ptr,
- png_color_16p values, int color_type));
-#endif
-
-#if defined(PNG_WRITE_hIST_SUPPORTED)
-PNG_EXTERN void png_write_hIST PNGARG((png_structp png_ptr, png_uint_16p hist,
- int num_hist));
-#endif
-
-#if defined(PNG_WRITE_TEXT_SUPPORTED) || defined(PNG_WRITE_pCAL_SUPPORTED) || \
- defined(PNG_WRITE_iCCP_SUPPORTED) || defined(PNG_WRITE_sPLT_SUPPORTED)
-PNG_EXTERN png_size_t png_check_keyword PNGARG((png_structp png_ptr,
- png_charp key, png_charpp new_key));
-#endif
-
-#if defined(PNG_WRITE_tEXt_SUPPORTED)
-PNG_EXTERN void png_write_tEXt PNGARG((png_structp png_ptr, png_charp key,
- png_charp text, png_size_t text_len));
-#endif
-
-#if defined(PNG_WRITE_zTXt_SUPPORTED)
-PNG_EXTERN void png_write_zTXt PNGARG((png_structp png_ptr, png_charp key,
- png_charp text, png_size_t text_len, int compression));
-#endif
-
-#if defined(PNG_WRITE_iTXt_SUPPORTED)
-PNG_EXTERN void png_write_iTXt PNGARG((png_structp png_ptr,
- int compression, png_charp key, png_charp lang, png_charp lang_key,
- png_charp text));
-#endif
-
-#if defined(PNG_TEXT_SUPPORTED) /* Added at version 1.0.14 and 1.2.4 */
-PNG_EXTERN int png_set_text_2 PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_textp text_ptr, int num_text));
-#endif
-
-#if defined(PNG_WRITE_oFFs_SUPPORTED)
-PNG_EXTERN void png_write_oFFs PNGARG((png_structp png_ptr,
- png_int_32 x_offset, png_int_32 y_offset, int unit_type));
-#endif
-
-#if defined(PNG_WRITE_pCAL_SUPPORTED)
-PNG_EXTERN void png_write_pCAL PNGARG((png_structp png_ptr, png_charp purpose,
- png_int_32 X0, png_int_32 X1, int type, int nparams,
- png_charp units, png_charpp params));
-#endif
-
-#if defined(PNG_WRITE_pHYs_SUPPORTED)
-PNG_EXTERN void png_write_pHYs PNGARG((png_structp png_ptr,
- png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
- int unit_type));
-#endif
-
-#if defined(PNG_WRITE_tIME_SUPPORTED)
-PNG_EXTERN void png_write_tIME PNGARG((png_structp png_ptr,
- png_timep mod_time));
-#endif
-
-#if defined(PNG_WRITE_sCAL_SUPPORTED)
-#if defined(PNG_FLOATING_POINT_SUPPORTED) && !defined(PNG_NO_STDIO)
-PNG_EXTERN void png_write_sCAL PNGARG((png_structp png_ptr,
- int unit, double width, double height));
-#else
-#ifdef PNG_FIXED_POINT_SUPPORTED
-PNG_EXTERN void png_write_sCAL_s PNGARG((png_structp png_ptr,
- int unit, png_charp width, png_charp height));
-#endif
-#endif
-#endif
-
-/* Called when finished processing a row of data */
-PNG_EXTERN void png_write_finish_row PNGARG((png_structp png_ptr));
-
-/* Internal use only. Called before first row of data */
-PNG_EXTERN void png_write_start_row PNGARG((png_structp png_ptr));
-
-#if defined(PNG_READ_GAMMA_SUPPORTED)
-PNG_EXTERN void png_build_gamma_table PNGARG((png_structp png_ptr));
-#endif
-
-/* combine a row of data, dealing with alpha, etc. if requested */
-PNG_EXTERN void png_combine_row PNGARG((png_structp png_ptr, png_bytep row,
- int mask));
-
-#if defined(PNG_READ_INTERLACING_SUPPORTED)
-/* expand an interlaced row */
-/* OLD pre-1.0.9 interface:
-PNG_EXTERN void png_do_read_interlace PNGARG((png_row_infop row_info,
- png_bytep row, int pass, png_uint_32 transformations));
- */
-PNG_EXTERN void png_do_read_interlace PNGARG((png_structp png_ptr));
-#endif
-
-/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */
-
-#if defined(PNG_WRITE_INTERLACING_SUPPORTED)
-/* grab pixels out of a row for an interlaced pass */
-PNG_EXTERN void png_do_write_interlace PNGARG((png_row_infop row_info,
- png_bytep row, int pass));
-#endif
-
-/* unfilter a row */
-PNG_EXTERN void png_read_filter_row PNGARG((png_structp png_ptr,
- png_row_infop row_info, png_bytep row, png_bytep prev_row, int filter));
-
-/* Choose the best filter to use and filter the row data */
-PNG_EXTERN void png_write_find_filter PNGARG((png_structp png_ptr,
- png_row_infop row_info));
-
-/* Write out the filtered row. */
-PNG_EXTERN void png_write_filtered_row PNGARG((png_structp png_ptr,
- png_bytep filtered_row));
-/* finish a row while reading, dealing with interlacing passes, etc. */
-PNG_EXTERN void png_read_finish_row PNGARG((png_structp png_ptr));
-
-/* initialize the row buffers, etc. */
-PNG_EXTERN void png_read_start_row PNGARG((png_structp png_ptr));
-/* optional call to update the users info structure */
-PNG_EXTERN void png_read_transform_info PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-
-/* these are the functions that do the transformations */
-#if defined(PNG_READ_FILLER_SUPPORTED)
-PNG_EXTERN void png_do_read_filler PNGARG((png_row_infop row_info,
- png_bytep row, png_uint_32 filler, png_uint_32 flags));
-#endif
-
-#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
-PNG_EXTERN void png_do_read_swap_alpha PNGARG((png_row_infop row_info,
- png_bytep row));
-#endif
-
-#if defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
-PNG_EXTERN void png_do_write_swap_alpha PNGARG((png_row_infop row_info,
- png_bytep row));
-#endif
-
-#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
-PNG_EXTERN void png_do_read_invert_alpha PNGARG((png_row_infop row_info,
- png_bytep row));
-#endif
-
-#if defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
-PNG_EXTERN void png_do_write_invert_alpha PNGARG((png_row_infop row_info,
- png_bytep row));
-#endif
-
-#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
- defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
-PNG_EXTERN void png_do_strip_filler PNGARG((png_row_infop row_info,
- png_bytep row, png_uint_32 flags));
-#endif
-
-#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-PNG_EXTERN void png_do_swap PNGARG((png_row_infop row_info, png_bytep row));
-#endif
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED) || defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-PNG_EXTERN void png_do_packswap PNGARG((png_row_infop row_info, png_bytep row));
-#endif
-
-#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
-PNG_EXTERN int png_do_rgb_to_gray PNGARG((png_structp png_ptr, png_row_infop
- row_info, png_bytep row));
-#endif
-
-#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
-PNG_EXTERN void png_do_gray_to_rgb PNGARG((png_row_infop row_info,
- png_bytep row));
-#endif
-
-#if defined(PNG_READ_PACK_SUPPORTED)
-PNG_EXTERN void png_do_unpack PNGARG((png_row_infop row_info, png_bytep row));
-#endif
-
-#if defined(PNG_READ_SHIFT_SUPPORTED)
-PNG_EXTERN void png_do_unshift PNGARG((png_row_infop row_info, png_bytep row,
- png_color_8p sig_bits));
-#endif
-
-#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
-PNG_EXTERN void png_do_invert PNGARG((png_row_infop row_info, png_bytep row));
-#endif
-
-#if defined(PNG_READ_16_TO_8_SUPPORTED)
-PNG_EXTERN void png_do_chop PNGARG((png_row_infop row_info, png_bytep row));
-#endif
-
-#if defined(PNG_READ_DITHER_SUPPORTED)
-PNG_EXTERN void png_do_dither PNGARG((png_row_infop row_info,
- png_bytep row, png_bytep palette_lookup, png_bytep dither_lookup));
-
-# if defined(PNG_CORRECT_PALETTE_SUPPORTED)
-PNG_EXTERN void png_correct_palette PNGARG((png_structp png_ptr,
- png_colorp palette, int num_palette));
-# endif
-#endif
-
-#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
-PNG_EXTERN void png_do_bgr PNGARG((png_row_infop row_info, png_bytep row));
-#endif
-
-#if defined(PNG_WRITE_PACK_SUPPORTED)
-PNG_EXTERN void png_do_pack PNGARG((png_row_infop row_info,
- png_bytep row, png_uint_32 bit_depth));
-#endif
-
-#if defined(PNG_WRITE_SHIFT_SUPPORTED)
-PNG_EXTERN void png_do_shift PNGARG((png_row_infop row_info, png_bytep row,
- png_color_8p bit_depth));
-#endif
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
-#if defined(PNG_READ_GAMMA_SUPPORTED)
-PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
- png_color_16p trans_values, png_color_16p background,
- png_color_16p background_1,
- png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
- png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
- png_uint_16pp gamma_16_to_1, int gamma_shift));
-#else
-PNG_EXTERN void png_do_background PNGARG((png_row_infop row_info, png_bytep row,
- png_color_16p trans_values, png_color_16p background));
-#endif
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED)
-PNG_EXTERN void png_do_gamma PNGARG((png_row_infop row_info, png_bytep row,
- png_bytep gamma_table, png_uint_16pp gamma_16_table,
- int gamma_shift));
-#endif
-
-#if defined(PNG_READ_EXPAND_SUPPORTED)
-PNG_EXTERN void png_do_expand_palette PNGARG((png_row_infop row_info,
- png_bytep row, png_colorp palette, png_bytep trans, int num_trans));
-PNG_EXTERN void png_do_expand PNGARG((png_row_infop row_info,
- png_bytep row, png_color_16p trans_value));
-#endif
-
-/* The following decodes the appropriate chunks, and does error correction,
- * then calls the appropriate callback for the chunk if it is valid.
- */
-
-/* decode the IHDR chunk */
-PNG_EXTERN void png_handle_IHDR PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-PNG_EXTERN void png_handle_PLTE PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-PNG_EXTERN void png_handle_IEND PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-
-#if defined(PNG_READ_bKGD_SUPPORTED)
-PNG_EXTERN void png_handle_bKGD PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_cHRM_SUPPORTED)
-PNG_EXTERN void png_handle_cHRM PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_gAMA_SUPPORTED)
-PNG_EXTERN void png_handle_gAMA PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_hIST_SUPPORTED)
-PNG_EXTERN void png_handle_hIST PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_iCCP_SUPPORTED)
-extern void png_handle_iCCP PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif /* PNG_READ_iCCP_SUPPORTED */
-
-#if defined(PNG_READ_iTXt_SUPPORTED)
-PNG_EXTERN void png_handle_iTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_oFFs_SUPPORTED)
-PNG_EXTERN void png_handle_oFFs PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_pCAL_SUPPORTED)
-PNG_EXTERN void png_handle_pCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_pHYs_SUPPORTED)
-PNG_EXTERN void png_handle_pHYs PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_sBIT_SUPPORTED)
-PNG_EXTERN void png_handle_sBIT PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_sCAL_SUPPORTED)
-PNG_EXTERN void png_handle_sCAL PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_sPLT_SUPPORTED)
-extern void png_handle_sPLT PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif /* PNG_READ_sPLT_SUPPORTED */
-
-#if defined(PNG_READ_sRGB_SUPPORTED)
-PNG_EXTERN void png_handle_sRGB PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_tEXt_SUPPORTED)
-PNG_EXTERN void png_handle_tEXt PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_tIME_SUPPORTED)
-PNG_EXTERN void png_handle_tIME PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_tRNS_SUPPORTED)
-PNG_EXTERN void png_handle_tRNS PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-#if defined(PNG_READ_zTXt_SUPPORTED)
-PNG_EXTERN void png_handle_zTXt PNGARG((png_structp png_ptr, png_infop info_ptr,
- png_uint_32 length));
-#endif
-
-PNG_EXTERN void png_handle_unknown PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 length));
-
-PNG_EXTERN void png_check_chunk_name PNGARG((png_structp png_ptr,
- png_bytep chunk_name));
-
-/* handle the transformations for reading and writing */
-PNG_EXTERN void png_do_read_transformations PNGARG((png_structp png_ptr));
-PNG_EXTERN void png_do_write_transformations PNGARG((png_structp png_ptr));
-
-PNG_EXTERN void png_init_read_transformations PNGARG((png_structp png_ptr));
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-PNG_EXTERN void png_push_read_chunk PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-PNG_EXTERN void png_push_read_sig PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-PNG_EXTERN void png_push_check_crc PNGARG((png_structp png_ptr));
-PNG_EXTERN void png_push_crc_skip PNGARG((png_structp png_ptr,
- png_uint_32 length));
-PNG_EXTERN void png_push_crc_finish PNGARG((png_structp png_ptr));
-PNG_EXTERN void png_push_save_buffer PNGARG((png_structp png_ptr));
-PNG_EXTERN void png_push_restore_buffer PNGARG((png_structp png_ptr,
- png_bytep buffer, png_size_t buffer_length));
-PNG_EXTERN void png_push_read_IDAT PNGARG((png_structp png_ptr));
-PNG_EXTERN void png_process_IDAT_data PNGARG((png_structp png_ptr,
- png_bytep buffer, png_size_t buffer_length));
-PNG_EXTERN void png_push_process_row PNGARG((png_structp png_ptr));
-PNG_EXTERN void png_push_handle_unknown PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 length));
-PNG_EXTERN void png_push_have_info PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-PNG_EXTERN void png_push_have_end PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-PNG_EXTERN void png_push_have_row PNGARG((png_structp png_ptr, png_bytep row));
-PNG_EXTERN void png_push_read_end PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-PNG_EXTERN void png_process_some_data PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-PNG_EXTERN void png_read_push_finish_row PNGARG((png_structp png_ptr));
-#if defined(PNG_READ_tEXt_SUPPORTED)
-PNG_EXTERN void png_push_handle_tEXt PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 length));
-PNG_EXTERN void png_push_read_tEXt PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-#endif
-#if defined(PNG_READ_zTXt_SUPPORTED)
-PNG_EXTERN void png_push_handle_zTXt PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 length));
-PNG_EXTERN void png_push_read_zTXt PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-#endif
-#if defined(PNG_READ_iTXt_SUPPORTED)
-PNG_EXTERN void png_push_handle_iTXt PNGARG((png_structp png_ptr,
- png_infop info_ptr, png_uint_32 length));
-PNG_EXTERN void png_push_read_iTXt PNGARG((png_structp png_ptr,
- png_infop info_ptr));
-#endif
-
-#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
-
-#ifdef PNG_MNG_FEATURES_SUPPORTED
-PNG_EXTERN void png_do_read_intrapixel PNGARG((png_row_infop row_info,
- png_bytep row));
-PNG_EXTERN void png_do_write_intrapixel PNGARG((png_row_infop row_info,
- png_bytep row));
-#endif
-
-#if defined(PNG_ASSEMBLER_CODE_SUPPORTED)
-#if defined(PNG_MMX_CODE_SUPPORTED)
-/* png.c */ /* PRIVATE */
-PNG_EXTERN void png_init_mmx_flags PNGARG((png_structp png_ptr));
-#endif
-#endif
-
-#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
-PNG_EXTERN png_uint_32 png_get_pixels_per_inch PNGARG((png_structp png_ptr,
-png_infop info_ptr));
-
-PNG_EXTERN png_uint_32 png_get_x_pixels_per_inch PNGARG((png_structp png_ptr,
-png_infop info_ptr));
-
-PNG_EXTERN png_uint_32 png_get_y_pixels_per_inch PNGARG((png_structp png_ptr,
-png_infop info_ptr));
-
-PNG_EXTERN float png_get_x_offset_inches PNGARG((png_structp png_ptr,
-png_infop info_ptr));
-
-PNG_EXTERN float png_get_y_offset_inches PNGARG((png_structp png_ptr,
-png_infop info_ptr));
-
-#if defined(PNG_pHYs_SUPPORTED)
-PNG_EXTERN png_uint_32 png_get_pHYs_dpi PNGARG((png_structp png_ptr,
-png_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
-#endif /* PNG_pHYs_SUPPORTED */
-#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
-
-/* Read the chunk header (length + type name) */
-PNG_EXTERN png_uint_32 png_read_chunk_header PNGARG((png_structp png_ptr));
-
-/* Added at libpng version 1.2.34 */
-#if defined(PNG_cHRM_SUPPORTED)
-PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
- png_fixed_point int_white_x, png_fixed_point int_white_y,
- png_fixed_point int_red_x, png_fixed_point int_red_y, png_fixed_point
- int_green_x, png_fixed_point int_green_y, png_fixed_point int_blue_x,
- png_fixed_point int_blue_y));
-#endif
-
-/* Maintainer: Put new private prototypes here ^ and in libpngpf.3 */
-
-#endif /* PNG_INTERNAL */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* PNG_VERSION_INFO_ONLY */
-/* do not put anything past this line */
-#endif /* PNG_H */
diff --git a/navit/support/libpng/pngconf.h b/navit/support/libpng/pngconf.h
deleted file mode 100644
index f5e5c59c8..000000000
--- a/navit/support/libpng/pngconf.h
+++ /dev/null
@@ -1,1496 +0,0 @@
-
-/* pngconf.h - machine configurable file for libpng
- *
- * libpng version 1.2.36 - May 7, 2009
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2009 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- */
-
-/* Any machine specific code is near the front of this file, so if you
- * are configuring libpng for a machine, you may want to read the section
- * starting here down to where it starts to typedef png_color, png_text,
- * and png_info.
- */
-
-#ifndef PNGCONF_H
-#define PNGCONF_H
-
-#define PNG_1_2_X
-
-/*
- * PNG_USER_CONFIG has to be defined on the compiler command line. This
- * includes the resource compiler for Windows DLL configurations.
- */
-#ifdef PNG_USER_CONFIG
-# ifndef PNG_USER_PRIVATEBUILD
-# define PNG_USER_PRIVATEBUILD
-# endif
-#include "pngusr.h"
-#endif
-
-/* PNG_CONFIGURE_LIBPNG is set by the "configure" script. */
-#ifdef PNG_CONFIGURE_LIBPNG
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-#endif
-
-/*
- * Added at libpng-1.2.8
- *
- * If you create a private DLL you need to define in "pngusr.h" the followings:
- * #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
- * the DLL was built>
- * e.g. #define PNG_USER_PRIVATEBUILD "Build by MyCompany for xyz reasons."
- * #define PNG_USER_DLLFNAME_POSTFIX <two-letter postfix that serve to
- * distinguish your DLL from those of the official release. These
- * correspond to the trailing letters that come after the version
- * number and must match your private DLL name>
- * e.g. // private DLL "libpng13gx.dll"
- * #define PNG_USER_DLLFNAME_POSTFIX "gx"
- *
- * The following macros are also at your disposal if you want to complete the
- * DLL VERSIONINFO structure.
- * - PNG_USER_VERSIONINFO_COMMENTS
- * - PNG_USER_VERSIONINFO_COMPANYNAME
- * - PNG_USER_VERSIONINFO_LEGALTRADEMARKS
- */
-
-#ifdef __STDC__
-#ifdef SPECIALBUILD
-# pragma message("PNG_LIBPNG_SPECIALBUILD (and deprecated SPECIALBUILD)\
- are now LIBPNG reserved macros. Use PNG_USER_PRIVATEBUILD instead.")
-#endif
-
-#ifdef PRIVATEBUILD
-# pragma message("PRIVATEBUILD is deprecated.\
- Use PNG_USER_PRIVATEBUILD instead.")
-# define PNG_USER_PRIVATEBUILD PRIVATEBUILD
-#endif
-#endif /* __STDC__ */
-
-#ifndef PNG_VERSION_INFO_ONLY
-
-/* End of material added to libpng-1.2.8 */
-
-/* Added at libpng-1.2.19, removed at libpng-1.2.20 because it caused trouble
- Restored at libpng-1.2.21 */
-#if !defined(PNG_NO_WARN_UNINITIALIZED_ROW) && \
- !defined(PNG_WARN_UNINITIALIZED_ROW)
-# define PNG_WARN_UNINITIALIZED_ROW 1
-#endif
-/* End of material added at libpng-1.2.19/1.2.21 */
-
-/* This is the size of the compression buffer, and thus the size of
- * an IDAT chunk. Make this whatever size you feel is best for your
- * machine. One of these will be allocated per png_struct. When this
- * is full, it writes the data to the disk, and does some other
- * calculations. Making this an extremely small size will slow
- * the library down, but you may want to experiment to determine
- * where it becomes significant, if you are concerned with memory
- * usage. Note that zlib allocates at least 32Kb also. For readers,
- * this describes the size of the buffer available to read the data in.
- * Unless this gets smaller than the size of a row (compressed),
- * it should not make much difference how big this is.
- */
-
-#ifndef PNG_ZBUF_SIZE
-# define PNG_ZBUF_SIZE 8192
-#endif
-
-/* Enable if you want a write-only libpng */
-
-#ifndef PNG_NO_READ_SUPPORTED
-# define PNG_READ_SUPPORTED
-#endif
-
-/* Enable if you want a read-only libpng */
-
-#ifndef PNG_NO_WRITE_SUPPORTED
-# define PNG_WRITE_SUPPORTED
-#endif
-
-/* Enabled by default in 1.2.0. You can disable this if you don't need to
- support PNGs that are embedded in MNG datastreams */
-#if !defined(PNG_1_0_X) && !defined(PNG_NO_MNG_FEATURES)
-# ifndef PNG_MNG_FEATURES_SUPPORTED
-# define PNG_MNG_FEATURES_SUPPORTED
-# endif
-#endif
-
-#ifndef PNG_NO_FLOATING_POINT_SUPPORTED
-# ifndef PNG_FLOATING_POINT_SUPPORTED
-# define PNG_FLOATING_POINT_SUPPORTED
-# endif
-#endif
-
-/* If you are running on a machine where you cannot allocate more
- * than 64K of memory at once, uncomment this. While libpng will not
- * normally need that much memory in a chunk (unless you load up a very
- * large file), zlib needs to know how big of a chunk it can use, and
- * libpng thus makes sure to check any memory allocation to verify it
- * will fit into memory.
-#define PNG_MAX_MALLOC_64K
- */
-#if defined(MAXSEG_64K) && !defined(PNG_MAX_MALLOC_64K)
-# define PNG_MAX_MALLOC_64K
-#endif
-
-/* Special munging to support doing things the 'cygwin' way:
- * 'Normal' png-on-win32 defines/defaults:
- * PNG_BUILD_DLL -- building dll
- * PNG_USE_DLL -- building an application, linking to dll
- * (no define) -- building static library, or building an
- * application and linking to the static lib
- * 'Cygwin' defines/defaults:
- * PNG_BUILD_DLL -- (ignored) building the dll
- * (no define) -- (ignored) building an application, linking to the dll
- * PNG_STATIC -- (ignored) building the static lib, or building an
- * application that links to the static lib.
- * ALL_STATIC -- (ignored) building various static libs, or building an
- * application that links to the static libs.
- * Thus,
- * a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
- * this bit of #ifdefs will define the 'correct' config variables based on
- * that. If a cygwin user *wants* to define 'PNG_USE_DLL' that's okay, but
- * unnecessary.
- *
- * Also, the precedence order is:
- * ALL_STATIC (since we can't #undef something outside our namespace)
- * PNG_BUILD_DLL
- * PNG_STATIC
- * (nothing) == PNG_USE_DLL
- *
- * CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
- * of auto-import in binutils, we no longer need to worry about
- * __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
- * we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
- * to __declspec() stuff. However, we DO need to worry about
- * PNG_BUILD_DLL and PNG_STATIC because those change some defaults
- * such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
- */
-#if defined(__CYGWIN__)
-# if defined(ALL_STATIC)
-# if defined(PNG_BUILD_DLL)
-# undef PNG_BUILD_DLL
-# endif
-# if defined(PNG_USE_DLL)
-# undef PNG_USE_DLL
-# endif
-# if defined(PNG_DLL)
-# undef PNG_DLL
-# endif
-# if !defined(PNG_STATIC)
-# define PNG_STATIC
-# endif
-# else
-# if defined (PNG_BUILD_DLL)
-# if defined(PNG_STATIC)
-# undef PNG_STATIC
-# endif
-# if defined(PNG_USE_DLL)
-# undef PNG_USE_DLL
-# endif
-# if !defined(PNG_DLL)
-# define PNG_DLL
-# endif
-# else
-# if defined(PNG_STATIC)
-# if defined(PNG_USE_DLL)
-# undef PNG_USE_DLL
-# endif
-# if defined(PNG_DLL)
-# undef PNG_DLL
-# endif
-# else
-# if !defined(PNG_USE_DLL)
-# define PNG_USE_DLL
-# endif
-# if !defined(PNG_DLL)
-# define PNG_DLL
-# endif
-# endif
-# endif
-# endif
-#endif
-
-/* This protects us against compilers that run on a windowing system
- * and thus don't have or would rather us not use the stdio types:
- * stdin, stdout, and stderr. The only one currently used is stderr
- * in png_error() and png_warning(). #defining PNG_NO_CONSOLE_IO will
- * prevent these from being compiled and used. #defining PNG_NO_STDIO
- * will also prevent these, plus will prevent the entire set of stdio
- * macros and functions (FILE *, printf, etc.) from being compiled and used,
- * unless (PNG_DEBUG > 0) has been #defined.
- *
- * #define PNG_NO_CONSOLE_IO
- * #define PNG_NO_STDIO
- */
-
-#if defined(_WIN32_WCE)
-# include <windows.h>
- /* Console I/O functions are not supported on WindowsCE */
-# define PNG_NO_CONSOLE_IO
- /* abort() may not be supported on some/all Windows CE platforms */
-# define PNG_ABORT() exit(-1)
-# ifdef PNG_DEBUG
-# undef PNG_DEBUG
-# endif
-#endif
-
-#ifdef PNG_BUILD_DLL
-# ifndef PNG_CONSOLE_IO_SUPPORTED
-# ifndef PNG_NO_CONSOLE_IO
-# define PNG_NO_CONSOLE_IO
-# endif
-# endif
-#endif
-
-# ifdef PNG_NO_STDIO
-# ifndef PNG_NO_CONSOLE_IO
-# define PNG_NO_CONSOLE_IO
-# endif
-# ifdef PNG_DEBUG
-# if (PNG_DEBUG > 0)
-# include <stdio.h>
-# endif
-# endif
-# else
-# if !defined(_WIN32_WCE)
-/* "stdio.h" functions are not supported on WindowsCE */
-# include <stdio.h>
-# endif
-# endif
-
-/* This macro protects us against machines that don't have function
- * prototypes (ie K&R style headers). If your compiler does not handle
- * function prototypes, define this macro and use the included ansi2knr.
- * I've always been able to use _NO_PROTO as the indicator, but you may
- * need to drag the empty declaration out in front of here, or change the
- * ifdef to suit your own needs.
- */
-#ifndef PNGARG
-
-#ifdef OF /* zlib prototype munger */
-# define PNGARG(arglist) OF(arglist)
-#else
-
-#ifdef _NO_PROTO
-# define PNGARG(arglist) ()
-# ifndef PNG_TYPECAST_NULL
-# define PNG_TYPECAST_NULL
-# endif
-#else
-# define PNGARG(arglist) arglist
-#endif /* _NO_PROTO */
-
-
-#endif /* OF */
-
-#endif /* PNGARG */
-
-/* Try to determine if we are compiling on a Mac. Note that testing for
- * just __MWERKS__ is not good enough, because the Codewarrior is now used
- * on non-Mac platforms.
- */
-#ifndef MACOS
-# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
- defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
-# define MACOS
-# endif
-#endif
-
-/* enough people need this for various reasons to include it here */
-#if !defined(MACOS) && !defined(RISCOS) && !defined(_WIN32_WCE)
-# include <sys/types.h>
-#endif
-
-#if !defined(PNG_SETJMP_NOT_SUPPORTED) && !defined(PNG_NO_SETJMP_SUPPORTED)
-# define PNG_SETJMP_SUPPORTED
-#endif
-
-#ifdef PNG_SETJMP_SUPPORTED
-/* This is an attempt to force a single setjmp behaviour on Linux. If
- * the X config stuff didn't define _BSD_SOURCE we wouldn't need this.
- *
- * You can bypass this test if you know that your application uses exactly
- * the same setjmp.h that was included when libpng was built. Only define
- * PNG_SKIP_SETJMP_CHECK while building your application, prior to the
- * application's '#include "png.h"'. Don't define PNG_SKIP_SETJMP_CHECK
- * while building a separate libpng library for general use.
- */
-
-# ifndef PNG_SKIP_SETJMP_CHECK
-# ifdef __linux__
-# ifdef _BSD_SOURCE
-# define PNG_SAVE_BSD_SOURCE
-# undef _BSD_SOURCE
-# endif
-# ifdef _SETJMP_H
- /* If you encounter a compiler error here, see the explanation
- * near the end of INSTALL.
- */
- __pngconf.h__ in libpng already includes setjmp.h;
- __dont__ include it again.;
-# endif
-# endif /* __linux__ */
-# endif /* PNG_SKIP_SETJMP_CHECK */
-
- /* include setjmp.h for error handling */
-# include <setjmp.h>
-
-# ifdef __linux__
-# ifdef PNG_SAVE_BSD_SOURCE
-# ifndef _BSD_SOURCE
-# define _BSD_SOURCE
-# endif
-# undef PNG_SAVE_BSD_SOURCE
-# endif
-# endif /* __linux__ */
-#endif /* PNG_SETJMP_SUPPORTED */
-
-#ifdef BSD
-# include <strings.h>
-#else
-# include <string.h>
-#endif
-
-/* Other defines for things like memory and the like can go here. */
-#ifdef PNG_INTERNAL
-
-#include <stdlib.h>
-
-/* The functions exported by PNG_EXTERN are PNG_INTERNAL functions, which
- * aren't usually used outside the library (as far as I know), so it is
- * debatable if they should be exported at all. In the future, when it is
- * possible to have run-time registry of chunk-handling functions, some of
- * these will be made available again.
-#define PNG_EXTERN extern
- */
-#define PNG_EXTERN
-
-/* Other defines specific to compilers can go here. Try to keep
- * them inside an appropriate ifdef/endif pair for portability.
- */
-
-#if defined(PNG_FLOATING_POINT_SUPPORTED)
-# if defined(MACOS)
- /* We need to check that <math.h> hasn't already been included earlier
- * as it seems it doesn't agree with <fp.h>, yet we should really use
- * <fp.h> if possible.
- */
-# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
-# include <fp.h>
-# endif
-# else
-# include <math.h>
-# endif
-# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
- /* Amiga SAS/C: We must include builtin FPU functions when compiling using
- * MATH=68881
- */
-# include <m68881.h>
-# endif
-#endif
-
-/* Codewarrior on NT has linking problems without this. */
-#if (defined(__MWERKS__) && defined(WIN32)) || defined(__STDC__)
-# define PNG_ALWAYS_EXTERN
-#endif
-
-/* This provides the non-ANSI (far) memory allocation routines. */
-#if defined(__TURBOC__) && defined(__MSDOS__)
-# include <mem.h>
-# include <alloc.h>
-#endif
-
-/* I have no idea why is this necessary... */
-#if defined(_MSC_VER) && (defined(WIN32) || defined(_Windows) || \
- defined(_WINDOWS) || defined(_WIN32) || defined(__WIN32__))
-# include <malloc.h>
-#endif
-
-/* This controls how fine the dithering gets. As this allocates
- * a largish chunk of memory (32K), those who are not as concerned
- * with dithering quality can decrease some or all of these.
- */
-#ifndef PNG_DITHER_RED_BITS
-# define PNG_DITHER_RED_BITS 5
-#endif
-#ifndef PNG_DITHER_GREEN_BITS
-# define PNG_DITHER_GREEN_BITS 5
-#endif
-#ifndef PNG_DITHER_BLUE_BITS
-# define PNG_DITHER_BLUE_BITS 5
-#endif
-
-/* This controls how fine the gamma correction becomes when you
- * are only interested in 8 bits anyway. Increasing this value
- * results in more memory being used, and more pow() functions
- * being called to fill in the gamma tables. Don't set this value
- * less then 8, and even that may not work (I haven't tested it).
- */
-
-#ifndef PNG_MAX_GAMMA_8
-# define PNG_MAX_GAMMA_8 11
-#endif
-
-/* This controls how much a difference in gamma we can tolerate before
- * we actually start doing gamma conversion.
- */
-#ifndef PNG_GAMMA_THRESHOLD
-# define PNG_GAMMA_THRESHOLD 0.05
-#endif
-
-#endif /* PNG_INTERNAL */
-
-/* The following uses const char * instead of char * for error
- * and warning message functions, so some compilers won't complain.
- * If you do not want to use const, define PNG_NO_CONST here.
- */
-
-#ifndef PNG_NO_CONST
-# define PNG_CONST const
-#else
-# define PNG_CONST
-#endif
-
-/* The following defines give you the ability to remove code from the
- * library that you will not be using. I wish I could figure out how to
- * automate this, but I can't do that without making it seriously hard
- * on the users. So if you are not using an ability, change the #define
- * to and #undef, and that part of the library will not be compiled. If
- * your linker can't find a function, you may want to make sure the
- * ability is defined here. Some of these depend upon some others being
- * defined. I haven't figured out all the interactions here, so you may
- * have to experiment awhile to get everything to compile. If you are
- * creating or using a shared library, you probably shouldn't touch this,
- * as it will affect the size of the structures, and this will cause bad
- * things to happen if the library and/or application ever change.
- */
-
-/* Any features you will not be using can be undef'ed here */
-
-/* GR-P, 0.96a: Set "*TRANSFORMS_SUPPORTED as default but allow user
- * to turn it off with "*TRANSFORMS_NOT_SUPPORTED" or *PNG_NO_*_TRANSFORMS
- * on the compile line, then pick and choose which ones to define without
- * having to edit this file. It is safe to use the *TRANSFORMS_NOT_SUPPORTED
- * if you only want to have a png-compliant reader/writer but don't need
- * any of the extra transformations. This saves about 80 kbytes in a
- * typical installation of the library. (PNG_NO_* form added in version
- * 1.0.1c, for consistency)
- */
-
-/* The size of the png_text structure changed in libpng-1.0.6 when
- * iTXt support was added. iTXt support was turned off by default through
- * libpng-1.2.x, to support old apps that malloc the png_text structure
- * instead of calling png_set_text() and letting libpng malloc it. It
- * was turned on by default in libpng-1.3.0.
- */
-
-#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
-# ifndef PNG_NO_iTXt_SUPPORTED
-# define PNG_NO_iTXt_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_iTXt
-# define PNG_NO_READ_iTXt
-# endif
-# ifndef PNG_NO_WRITE_iTXt
-# define PNG_NO_WRITE_iTXt
-# endif
-#endif
-
-#if !defined(PNG_NO_iTXt_SUPPORTED)
-# if !defined(PNG_READ_iTXt_SUPPORTED) && !defined(PNG_NO_READ_iTXt)
-# define PNG_READ_iTXt
-# endif
-# if !defined(PNG_WRITE_iTXt_SUPPORTED) && !defined(PNG_NO_WRITE_iTXt)
-# define PNG_WRITE_iTXt
-# endif
-#endif
-
-/* The following support, added after version 1.0.0, can be turned off here en
- * masse by defining PNG_LEGACY_SUPPORTED in case you need binary compatibility
- * with old applications that require the length of png_struct and png_info
- * to remain unchanged.
- */
-
-#ifdef PNG_LEGACY_SUPPORTED
-# define PNG_NO_FREE_ME
-# define PNG_NO_READ_UNKNOWN_CHUNKS
-# define PNG_NO_WRITE_UNKNOWN_CHUNKS
-# define PNG_NO_READ_USER_CHUNKS
-# define PNG_NO_READ_iCCP
-# define PNG_NO_WRITE_iCCP
-# define PNG_NO_READ_iTXt
-# define PNG_NO_WRITE_iTXt
-# define PNG_NO_READ_sCAL
-# define PNG_NO_WRITE_sCAL
-# define PNG_NO_READ_sPLT
-# define PNG_NO_WRITE_sPLT
-# define PNG_NO_INFO_IMAGE
-# define PNG_NO_READ_RGB_TO_GRAY
-# define PNG_NO_READ_USER_TRANSFORM
-# define PNG_NO_WRITE_USER_TRANSFORM
-# define PNG_NO_USER_MEM
-# define PNG_NO_READ_EMPTY_PLTE
-# define PNG_NO_MNG_FEATURES
-# define PNG_NO_FIXED_POINT_SUPPORTED
-#endif
-
-/* Ignore attempt to turn off both floating and fixed point support */
-#if !defined(PNG_FLOATING_POINT_SUPPORTED) || \
- !defined(PNG_NO_FIXED_POINT_SUPPORTED)
-# define PNG_FIXED_POINT_SUPPORTED
-#endif
-
-#ifndef PNG_NO_FREE_ME
-# define PNG_FREE_ME_SUPPORTED
-#endif
-
-#if defined(PNG_READ_SUPPORTED)
-
-#if !defined(PNG_READ_TRANSFORMS_NOT_SUPPORTED) && \
- !defined(PNG_NO_READ_TRANSFORMS)
-# define PNG_READ_TRANSFORMS_SUPPORTED
-#endif
-
-#ifdef PNG_READ_TRANSFORMS_SUPPORTED
-# ifndef PNG_NO_READ_EXPAND
-# define PNG_READ_EXPAND_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_SHIFT
-# define PNG_READ_SHIFT_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_PACK
-# define PNG_READ_PACK_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_BGR
-# define PNG_READ_BGR_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_SWAP
-# define PNG_READ_SWAP_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_PACKSWAP
-# define PNG_READ_PACKSWAP_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_INVERT
-# define PNG_READ_INVERT_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_DITHER
-# define PNG_READ_DITHER_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_BACKGROUND
-# define PNG_READ_BACKGROUND_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_16_TO_8
-# define PNG_READ_16_TO_8_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_FILLER
-# define PNG_READ_FILLER_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_GAMMA
-# define PNG_READ_GAMMA_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_GRAY_TO_RGB
-# define PNG_READ_GRAY_TO_RGB_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_SWAP_ALPHA
-# define PNG_READ_SWAP_ALPHA_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_INVERT_ALPHA
-# define PNG_READ_INVERT_ALPHA_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_STRIP_ALPHA
-# define PNG_READ_STRIP_ALPHA_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_USER_TRANSFORM
-# define PNG_READ_USER_TRANSFORM_SUPPORTED
-# endif
-# ifndef PNG_NO_READ_RGB_TO_GRAY
-# define PNG_READ_RGB_TO_GRAY_SUPPORTED
-# endif
-#endif /* PNG_READ_TRANSFORMS_SUPPORTED */
-
-#if !defined(PNG_NO_PROGRESSIVE_READ) && \
- !defined(PNG_PROGRESSIVE_READ_SUPPORTED) /* if you don't do progressive */
-# define PNG_PROGRESSIVE_READ_SUPPORTED /* reading. This is not talking */
-#endif /* about interlacing capability! You'll */
- /* still have interlacing unless you change the following line: */
-
-#define PNG_READ_INTERLACING_SUPPORTED /* required in PNG-compliant decoders */
-
-#ifndef PNG_NO_READ_COMPOSITE_NODIV
-# ifndef PNG_NO_READ_COMPOSITED_NODIV /* libpng-1.0.x misspelling */
-# define PNG_READ_COMPOSITE_NODIV_SUPPORTED /* well tested on Intel, SGI */
-# endif
-#endif
-
-#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
-/* Deprecated, will be removed from version 2.0.0.
- Use PNG_MNG_FEATURES_SUPPORTED instead. */
-#ifndef PNG_NO_READ_EMPTY_PLTE
-# define PNG_READ_EMPTY_PLTE_SUPPORTED
-#endif
-#endif
-
-#endif /* PNG_READ_SUPPORTED */
-
-#if defined(PNG_WRITE_SUPPORTED)
-
-# if !defined(PNG_WRITE_TRANSFORMS_NOT_SUPPORTED) && \
- !defined(PNG_NO_WRITE_TRANSFORMS)
-# define PNG_WRITE_TRANSFORMS_SUPPORTED
-#endif
-
-#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
-# ifndef PNG_NO_WRITE_SHIFT
-# define PNG_WRITE_SHIFT_SUPPORTED
-# endif
-# ifndef PNG_NO_WRITE_PACK
-# define PNG_WRITE_PACK_SUPPORTED
-# endif
-# ifndef PNG_NO_WRITE_BGR
-# define PNG_WRITE_BGR_SUPPORTED
-# endif
-# ifndef PNG_NO_WRITE_SWAP
-# define PNG_WRITE_SWAP_SUPPORTED
-# endif
-# ifndef PNG_NO_WRITE_PACKSWAP
-# define PNG_WRITE_PACKSWAP_SUPPORTED
-# endif
-# ifndef PNG_NO_WRITE_INVERT
-# define PNG_WRITE_INVERT_SUPPORTED
-# endif
-# ifndef PNG_NO_WRITE_FILLER
-# define PNG_WRITE_FILLER_SUPPORTED /* same as WRITE_STRIP_ALPHA */
-# endif
-# ifndef PNG_NO_WRITE_SWAP_ALPHA
-# define PNG_WRITE_SWAP_ALPHA_SUPPORTED
-# endif
-# ifndef PNG_NO_WRITE_INVERT_ALPHA
-# define PNG_WRITE_INVERT_ALPHA_SUPPORTED
-# endif
-# ifndef PNG_NO_WRITE_USER_TRANSFORM
-# define PNG_WRITE_USER_TRANSFORM_SUPPORTED
-# endif
-#endif /* PNG_WRITE_TRANSFORMS_SUPPORTED */
-
-#if !defined(PNG_NO_WRITE_INTERLACING_SUPPORTED) && \
- !defined(PNG_WRITE_INTERLACING_SUPPORTED)
-#define PNG_WRITE_INTERLACING_SUPPORTED /* not required for PNG-compliant
- encoders, but can cause trouble
- if left undefined */
-#endif
-
-#if !defined(PNG_NO_WRITE_WEIGHTED_FILTER) && \
- !defined(PNG_WRITE_WEIGHTED_FILTER) && \
- defined(PNG_FLOATING_POINT_SUPPORTED)
-# define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
-#endif
-
-#ifndef PNG_NO_WRITE_FLUSH
-# define PNG_WRITE_FLUSH_SUPPORTED
-#endif
-
-#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
-/* Deprecated, see PNG_MNG_FEATURES_SUPPORTED, above */
-#ifndef PNG_NO_WRITE_EMPTY_PLTE
-# define PNG_WRITE_EMPTY_PLTE_SUPPORTED
-#endif
-#endif
-
-#endif /* PNG_WRITE_SUPPORTED */
-
-#ifndef PNG_1_0_X
-# ifndef PNG_NO_ERROR_NUMBERS
-# define PNG_ERROR_NUMBERS_SUPPORTED
-# endif
-#endif /* PNG_1_0_X */
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
-# ifndef PNG_NO_USER_TRANSFORM_PTR
-# define PNG_USER_TRANSFORM_PTR_SUPPORTED
-# endif
-#endif
-
-#ifndef PNG_NO_STDIO
-# define PNG_TIME_RFC1123_SUPPORTED
-#endif
-
-/* This adds extra functions in pngget.c for accessing data from the
- * info pointer (added in version 0.99)
- * png_get_image_width()
- * png_get_image_height()
- * png_get_bit_depth()
- * png_get_color_type()
- * png_get_compression_type()
- * png_get_filter_type()
- * png_get_interlace_type()
- * png_get_pixel_aspect_ratio()
- * png_get_pixels_per_meter()
- * png_get_x_offset_pixels()
- * png_get_y_offset_pixels()
- * png_get_x_offset_microns()
- * png_get_y_offset_microns()
- */
-#if !defined(PNG_NO_EASY_ACCESS) && !defined(PNG_EASY_ACCESS_SUPPORTED)
-# define PNG_EASY_ACCESS_SUPPORTED
-#endif
-
-/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
- * and removed from version 1.2.20. The following will be removed
- * from libpng-1.4.0
-*/
-
-#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_OPTIMIZED_CODE)
-# ifndef PNG_OPTIMIZED_CODE_SUPPORTED
-# define PNG_OPTIMIZED_CODE_SUPPORTED
-# endif
-#endif
-
-#if defined(PNG_READ_SUPPORTED) && !defined(PNG_NO_ASSEMBLER_CODE)
-# ifndef PNG_ASSEMBLER_CODE_SUPPORTED
-# define PNG_ASSEMBLER_CODE_SUPPORTED
-# endif
-
-# if defined(__GNUC__) && defined(__x86_64__) && (__GNUC__ < 4)
- /* work around 64-bit gcc compiler bugs in gcc-3.x */
-# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
-# define PNG_NO_MMX_CODE
-# endif
-# endif
-
-# if defined(__APPLE__)
-# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
-# define PNG_NO_MMX_CODE
-# endif
-# endif
-
-# if (defined(__MWERKS__) && ((__MWERKS__ < 0x0900) || macintosh))
-# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
-# define PNG_NO_MMX_CODE
-# endif
-# endif
-
-# if !defined(PNG_MMX_CODE_SUPPORTED) && !defined(PNG_NO_MMX_CODE)
-# define PNG_MMX_CODE_SUPPORTED
-# endif
-
-#endif
-/* end of obsolete code to be removed from libpng-1.4.0 */
-
-#if !defined(PNG_1_0_X)
-#if !defined(PNG_NO_USER_MEM) && !defined(PNG_USER_MEM_SUPPORTED)
-# define PNG_USER_MEM_SUPPORTED
-#endif
-#endif /* PNG_1_0_X */
-
-/* Added at libpng-1.2.6 */
-#if !defined(PNG_1_0_X)
-#ifndef PNG_SET_USER_LIMITS_SUPPORTED
-#if !defined(PNG_NO_SET_USER_LIMITS) && !defined(PNG_SET_USER_LIMITS_SUPPORTED)
-# define PNG_SET_USER_LIMITS_SUPPORTED
-#endif
-#endif
-#endif /* PNG_1_0_X */
-
-/* Added at libpng-1.0.16 and 1.2.6. To accept all valid PNGS no matter
- * how large, set these limits to 0x7fffffffL
- */
-#ifndef PNG_USER_WIDTH_MAX
-# define PNG_USER_WIDTH_MAX 1000000L
-#endif
-#ifndef PNG_USER_HEIGHT_MAX
-# define PNG_USER_HEIGHT_MAX 1000000L
-#endif
-
-/* Added at libpng-1.2.34 and 1.4.0 */
-#ifndef PNG_STRING_NEWLINE
-#define PNG_STRING_NEWLINE "\n"
-#endif
-
-/* These are currently experimental features, define them if you want */
-
-/* very little testing */
-/*
-#ifdef PNG_READ_SUPPORTED
-# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
-# define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED
-# endif
-#endif
-*/
-
-/* This is only for PowerPC big-endian and 680x0 systems */
-/* some testing */
-/*
-#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
-# define PNG_READ_BIG_ENDIAN_SUPPORTED
-#endif
-*/
-
-/* Buggy compilers (e.g., gcc 2.7.2.2) need this */
-/*
-#define PNG_NO_POINTER_INDEXING
-*/
-
-/* These functions are turned off by default, as they will be phased out. */
-/*
-#define PNG_USELESS_TESTS_SUPPORTED
-#define PNG_CORRECT_PALETTE_SUPPORTED
-*/
-
-/* Any chunks you are not interested in, you can undef here. The
- * ones that allocate memory may be expecially important (hIST,
- * tEXt, zTXt, tRNS, pCAL). Others will just save time and make png_info
- * a bit smaller.
- */
-
-#if defined(PNG_READ_SUPPORTED) && \
- !defined(PNG_READ_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
- !defined(PNG_NO_READ_ANCILLARY_CHUNKS)
-# define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
-#endif
-
-#if defined(PNG_WRITE_SUPPORTED) && \
- !defined(PNG_WRITE_ANCILLARY_CHUNKS_NOT_SUPPORTED) && \
- !defined(PNG_NO_WRITE_ANCILLARY_CHUNKS)
-# define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
-#endif
-
-#ifdef PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
-
-#ifdef PNG_NO_READ_TEXT
-# define PNG_NO_READ_iTXt
-# define PNG_NO_READ_tEXt
-# define PNG_NO_READ_zTXt
-#endif
-#ifndef PNG_NO_READ_bKGD
-# define PNG_READ_bKGD_SUPPORTED
-# define PNG_bKGD_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_cHRM
-# define PNG_READ_cHRM_SUPPORTED
-# define PNG_cHRM_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_gAMA
-# define PNG_READ_gAMA_SUPPORTED
-# define PNG_gAMA_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_hIST
-# define PNG_READ_hIST_SUPPORTED
-# define PNG_hIST_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_iCCP
-# define PNG_READ_iCCP_SUPPORTED
-# define PNG_iCCP_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_iTXt
-# ifndef PNG_READ_iTXt_SUPPORTED
-# define PNG_READ_iTXt_SUPPORTED
-# endif
-# ifndef PNG_iTXt_SUPPORTED
-# define PNG_iTXt_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_READ_oFFs
-# define PNG_READ_oFFs_SUPPORTED
-# define PNG_oFFs_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_pCAL
-# define PNG_READ_pCAL_SUPPORTED
-# define PNG_pCAL_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_sCAL
-# define PNG_READ_sCAL_SUPPORTED
-# define PNG_sCAL_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_pHYs
-# define PNG_READ_pHYs_SUPPORTED
-# define PNG_pHYs_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_sBIT
-# define PNG_READ_sBIT_SUPPORTED
-# define PNG_sBIT_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_sPLT
-# define PNG_READ_sPLT_SUPPORTED
-# define PNG_sPLT_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_sRGB
-# define PNG_READ_sRGB_SUPPORTED
-# define PNG_sRGB_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_tEXt
-# define PNG_READ_tEXt_SUPPORTED
-# define PNG_tEXt_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_tIME
-# define PNG_READ_tIME_SUPPORTED
-# define PNG_tIME_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_tRNS
-# define PNG_READ_tRNS_SUPPORTED
-# define PNG_tRNS_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_zTXt
-# define PNG_READ_zTXt_SUPPORTED
-# define PNG_zTXt_SUPPORTED
-#endif
-#ifndef PNG_NO_READ_UNKNOWN_CHUNKS
-# define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
-# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
-# define PNG_UNKNOWN_CHUNKS_SUPPORTED
-# endif
-# ifndef PNG_NO_HANDLE_AS_UNKNOWN
-# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-# endif
-#endif
-#if !defined(PNG_NO_READ_USER_CHUNKS) && \
- defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
-# define PNG_READ_USER_CHUNKS_SUPPORTED
-# define PNG_USER_CHUNKS_SUPPORTED
-# ifdef PNG_NO_READ_UNKNOWN_CHUNKS
-# undef PNG_NO_READ_UNKNOWN_CHUNKS
-# endif
-# ifdef PNG_NO_HANDLE_AS_UNKNOWN
-# undef PNG_NO_HANDLE_AS_UNKNOWN
-# endif
-#endif
-#ifndef PNG_NO_READ_OPT_PLTE
-# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
-#endif /* optional PLTE chunk in RGB and RGBA images */
-#if defined(PNG_READ_iTXt_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) || \
- defined(PNG_READ_zTXt_SUPPORTED)
-# define PNG_READ_TEXT_SUPPORTED
-# define PNG_TEXT_SUPPORTED
-#endif
-
-#endif /* PNG_READ_ANCILLARY_CHUNKS_SUPPORTED */
-
-#ifdef PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
-
-#ifdef PNG_NO_WRITE_TEXT
-# define PNG_NO_WRITE_iTXt
-# define PNG_NO_WRITE_tEXt
-# define PNG_NO_WRITE_zTXt
-#endif
-#ifndef PNG_NO_WRITE_bKGD
-# define PNG_WRITE_bKGD_SUPPORTED
-# ifndef PNG_bKGD_SUPPORTED
-# define PNG_bKGD_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_cHRM
-# define PNG_WRITE_cHRM_SUPPORTED
-# ifndef PNG_cHRM_SUPPORTED
-# define PNG_cHRM_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_gAMA
-# define PNG_WRITE_gAMA_SUPPORTED
-# ifndef PNG_gAMA_SUPPORTED
-# define PNG_gAMA_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_hIST
-# define PNG_WRITE_hIST_SUPPORTED
-# ifndef PNG_hIST_SUPPORTED
-# define PNG_hIST_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_iCCP
-# define PNG_WRITE_iCCP_SUPPORTED
-# ifndef PNG_iCCP_SUPPORTED
-# define PNG_iCCP_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_iTXt
-# ifndef PNG_WRITE_iTXt_SUPPORTED
-# define PNG_WRITE_iTXt_SUPPORTED
-# endif
-# ifndef PNG_iTXt_SUPPORTED
-# define PNG_iTXt_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_oFFs
-# define PNG_WRITE_oFFs_SUPPORTED
-# ifndef PNG_oFFs_SUPPORTED
-# define PNG_oFFs_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_pCAL
-# define PNG_WRITE_pCAL_SUPPORTED
-# ifndef PNG_pCAL_SUPPORTED
-# define PNG_pCAL_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_sCAL
-# define PNG_WRITE_sCAL_SUPPORTED
-# ifndef PNG_sCAL_SUPPORTED
-# define PNG_sCAL_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_pHYs
-# define PNG_WRITE_pHYs_SUPPORTED
-# ifndef PNG_pHYs_SUPPORTED
-# define PNG_pHYs_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_sBIT
-# define PNG_WRITE_sBIT_SUPPORTED
-# ifndef PNG_sBIT_SUPPORTED
-# define PNG_sBIT_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_sPLT
-# define PNG_WRITE_sPLT_SUPPORTED
-# ifndef PNG_sPLT_SUPPORTED
-# define PNG_sPLT_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_sRGB
-# define PNG_WRITE_sRGB_SUPPORTED
-# ifndef PNG_sRGB_SUPPORTED
-# define PNG_sRGB_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_tEXt
-# define PNG_WRITE_tEXt_SUPPORTED
-# ifndef PNG_tEXt_SUPPORTED
-# define PNG_tEXt_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_tIME
-# define PNG_WRITE_tIME_SUPPORTED
-# ifndef PNG_tIME_SUPPORTED
-# define PNG_tIME_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_tRNS
-# define PNG_WRITE_tRNS_SUPPORTED
-# ifndef PNG_tRNS_SUPPORTED
-# define PNG_tRNS_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_zTXt
-# define PNG_WRITE_zTXt_SUPPORTED
-# ifndef PNG_zTXt_SUPPORTED
-# define PNG_zTXt_SUPPORTED
-# endif
-#endif
-#ifndef PNG_NO_WRITE_UNKNOWN_CHUNKS
-# define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
-# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
-# define PNG_UNKNOWN_CHUNKS_SUPPORTED
-# endif
-# ifndef PNG_NO_HANDLE_AS_UNKNOWN
-# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-# endif
-# endif
-#endif
-#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
- defined(PNG_WRITE_zTXt_SUPPORTED)
-# define PNG_WRITE_TEXT_SUPPORTED
-# ifndef PNG_TEXT_SUPPORTED
-# define PNG_TEXT_SUPPORTED
-# endif
-#endif
-
-#endif /* PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED */
-
-/* Turn this off to disable png_read_png() and
- * png_write_png() and leave the row_pointers member
- * out of the info structure.
- */
-#ifndef PNG_NO_INFO_IMAGE
-# define PNG_INFO_IMAGE_SUPPORTED
-#endif
-
-/* need the time information for reading tIME chunks */
-#if defined(PNG_tIME_SUPPORTED)
-# if !defined(_WIN32_WCE)
- /* "time.h" functions are not supported on WindowsCE */
-# include <time.h>
-# endif
-#endif
-
-/* Some typedefs to get us started. These should be safe on most of the
- * common platforms. The typedefs should be at least as large as the
- * numbers suggest (a png_uint_32 must be at least 32 bits long), but they
- * don't have to be exactly that size. Some compilers dislike passing
- * unsigned shorts as function parameters, so you may be better off using
- * unsigned int for png_uint_16. Likewise, for 64-bit systems, you may
- * want to have unsigned int for png_uint_32 instead of unsigned long.
- */
-
-typedef unsigned long png_uint_32;
-typedef long png_int_32;
-typedef unsigned short png_uint_16;
-typedef short png_int_16;
-typedef unsigned char png_byte;
-
-/* This is usually size_t. It is typedef'ed just in case you need it to
- change (I'm not sure if you will or not, so I thought I'd be safe) */
-#ifdef PNG_SIZE_T
- typedef PNG_SIZE_T png_size_t;
-# define png_sizeof(x) png_convert_size(sizeof(x))
-#else
- typedef size_t png_size_t;
-# define png_sizeof(x) sizeof(x)
-#endif
-
-/* The following is needed for medium model support. It cannot be in the
- * PNG_INTERNAL section. Needs modification for other compilers besides
- * MSC. Model independent support declares all arrays and pointers to be
- * large using the far keyword. The zlib version used must also support
- * model independent data. As of version zlib 1.0.4, the necessary changes
- * have been made in zlib. The USE_FAR_KEYWORD define triggers other
- * changes that are needed. (Tim Wegner)
- */
-
-/* Separate compiler dependencies (problem here is that zlib.h always
- defines FAR. (SJT) */
-#ifdef __BORLANDC__
-# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__)
-# define LDATA 1
-# else
-# define LDATA 0
-# endif
- /* GRR: why is Cygwin in here? Cygwin is not Borland C... */
-# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__)
-# define PNG_MAX_MALLOC_64K
-# if (LDATA != 1)
-# ifndef FAR
-# define FAR __far
-# endif
-# define USE_FAR_KEYWORD
-# endif /* LDATA != 1 */
- /* Possibly useful for moving data out of default segment.
- * Uncomment it if you want. Could also define FARDATA as
- * const if your compiler supports it. (SJT)
-# define FARDATA FAR
- */
-# endif /* __WIN32__, __FLAT__, __CYGWIN__ */
-#endif /* __BORLANDC__ */
-
-
-/* Suggest testing for specific compiler first before testing for
- * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM,
- * making reliance oncertain keywords suspect. (SJT)
- */
-
-/* MSC Medium model */
-#if defined(FAR)
-# if defined(M_I86MM)
-# define USE_FAR_KEYWORD
-# define FARDATA FAR
-# include <dos.h>
-# endif
-#endif
-
-/* SJT: default case */
-#ifndef FAR
-# define FAR
-#endif
-
-/* At this point FAR is always defined */
-#ifndef FARDATA
-# define FARDATA
-#endif
-
-/* Typedef for floating-point numbers that are converted
- to fixed-point with a multiple of 100,000, e.g., int_gamma */
-typedef png_int_32 png_fixed_point;
-
-/* Add typedefs for pointers */
-typedef void FAR * png_voidp;
-typedef png_byte FAR * png_bytep;
-typedef png_uint_32 FAR * png_uint_32p;
-typedef png_int_32 FAR * png_int_32p;
-typedef png_uint_16 FAR * png_uint_16p;
-typedef png_int_16 FAR * png_int_16p;
-typedef PNG_CONST char FAR * png_const_charp;
-typedef char FAR * png_charp;
-typedef png_fixed_point FAR * png_fixed_point_p;
-
-#ifndef PNG_NO_STDIO
-#if defined(_WIN32_WCE)
-typedef HANDLE png_FILE_p;
-#else
-typedef FILE * png_FILE_p;
-#endif
-#endif
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-typedef double FAR * png_doublep;
-#endif
-
-/* Pointers to pointers; i.e. arrays */
-typedef png_byte FAR * FAR * png_bytepp;
-typedef png_uint_32 FAR * FAR * png_uint_32pp;
-typedef png_int_32 FAR * FAR * png_int_32pp;
-typedef png_uint_16 FAR * FAR * png_uint_16pp;
-typedef png_int_16 FAR * FAR * png_int_16pp;
-typedef PNG_CONST char FAR * FAR * png_const_charpp;
-typedef char FAR * FAR * png_charpp;
-typedef png_fixed_point FAR * FAR * png_fixed_point_pp;
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-typedef double FAR * FAR * png_doublepp;
-#endif
-
-/* Pointers to pointers to pointers; i.e., pointer to array */
-typedef char FAR * FAR * FAR * png_charppp;
-
-#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
-/* SPC - Is this stuff deprecated? */
-/* It'll be removed as of libpng-1.3.0 - GR-P */
-/* libpng typedefs for types in zlib. If zlib changes
- * or another compression library is used, then change these.
- * Eliminates need to change all the source files.
- */
-typedef charf * png_zcharp;
-typedef charf * FAR * png_zcharpp;
-typedef z_stream FAR * png_zstreamp;
-#endif /* (PNG_1_0_X) || defined(PNG_1_2_X) */
-
-/*
- * Define PNG_BUILD_DLL if the module being built is a Windows
- * LIBPNG DLL.
- *
- * Define PNG_USE_DLL if you want to *link* to the Windows LIBPNG DLL.
- * It is equivalent to Microsoft predefined macro _DLL that is
- * automatically defined when you compile using the share
- * version of the CRT (C Run-Time library)
- *
- * The cygwin mods make this behavior a little different:
- * Define PNG_BUILD_DLL if you are building a dll for use with cygwin
- * Define PNG_STATIC if you are building a static library for use with cygwin,
- * -or- if you are building an application that you want to link to the
- * static library.
- * PNG_USE_DLL is defined by default (no user action needed) unless one of
- * the other flags is defined.
- */
-
-#if !defined(PNG_DLL) && (defined(PNG_BUILD_DLL) || defined(PNG_USE_DLL))
-# define PNG_DLL
-#endif
-/* If CYGWIN, then disallow GLOBAL ARRAYS unless building a static lib.
- * When building a static lib, default to no GLOBAL ARRAYS, but allow
- * command-line override
- */
-#if defined(__CYGWIN__)
-# if !defined(PNG_STATIC)
-# if defined(PNG_USE_GLOBAL_ARRAYS)
-# undef PNG_USE_GLOBAL_ARRAYS
-# endif
-# if !defined(PNG_USE_LOCAL_ARRAYS)
-# define PNG_USE_LOCAL_ARRAYS
-# endif
-# else
-# if defined(PNG_USE_LOCAL_ARRAYS) || defined(PNG_NO_GLOBAL_ARRAYS)
-# if defined(PNG_USE_GLOBAL_ARRAYS)
-# undef PNG_USE_GLOBAL_ARRAYS
-# endif
-# endif
-# endif
-# if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
-# define PNG_USE_LOCAL_ARRAYS
-# endif
-#endif
-
-/* Do not use global arrays (helps with building DLL's)
- * They are no longer used in libpng itself, since version 1.0.5c,
- * but might be required for some pre-1.0.5c applications.
- */
-#if !defined(PNG_USE_LOCAL_ARRAYS) && !defined(PNG_USE_GLOBAL_ARRAYS)
-# if defined(PNG_NO_GLOBAL_ARRAYS) || \
- (defined(__GNUC__) && defined(PNG_DLL)) || defined(_MSC_VER)
-# define PNG_USE_LOCAL_ARRAYS
-# else
-# define PNG_USE_GLOBAL_ARRAYS
-# endif
-#endif
-
-#if defined(__CYGWIN__)
-# undef PNGAPI
-# define PNGAPI __cdecl
-# undef PNG_IMPEXP
-# define PNG_IMPEXP
-#endif
-
-/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
- * you may get warnings regarding the linkage of png_zalloc and png_zfree.
- * Don't ignore those warnings; you must also reset the default calling
- * convention in your compiler to match your PNGAPI, and you must build
- * zlib and your applications the same way you build libpng.
- */
-
-#if defined(__MINGW32__) && !defined(PNG_MODULEDEF)
-# ifndef PNG_NO_MODULEDEF
-# define PNG_NO_MODULEDEF
-# endif
-#endif
-
-#if !defined(PNG_IMPEXP) && defined(PNG_BUILD_DLL) && !defined(PNG_NO_MODULEDEF)
-# define PNG_IMPEXP
-#endif
-
-#if defined(PNG_DLL) || defined(_DLL) || defined(__DLL__ ) || \
- (( defined(_Windows) || defined(_WINDOWS) || \
- defined(WIN32) || defined(_WIN32) || defined(__WIN32__) ))
-
-# ifndef PNGAPI
-# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
-# define PNGAPI __cdecl
-# else
-# define PNGAPI _cdecl
-# endif
-# endif
-
-# if !defined(PNG_IMPEXP) && (!defined(PNG_DLL) || \
- 0 /* WINCOMPILER_WITH_NO_SUPPORT_FOR_DECLIMPEXP */)
-# define PNG_IMPEXP
-# endif
-
-# if !defined(PNG_IMPEXP)
-
-# define PNG_EXPORT_TYPE1(type,symbol) PNG_IMPEXP type PNGAPI symbol
-# define PNG_EXPORT_TYPE2(type,symbol) type PNG_IMPEXP PNGAPI symbol
-
- /* Borland/Microsoft */
-# if defined(_MSC_VER) || defined(__BORLANDC__)
-# if (_MSC_VER >= 800) || (__BORLANDC__ >= 0x500)
-# define PNG_EXPORT PNG_EXPORT_TYPE1
-# else
-# define PNG_EXPORT PNG_EXPORT_TYPE2
-# if defined(PNG_BUILD_DLL)
-# define PNG_IMPEXP __export
-# else
-# define PNG_IMPEXP /*__import */ /* doesn't exist AFAIK in
- VC++ */
-# endif /* Exists in Borland C++ for
- C++ classes (== huge) */
-# endif
-# endif
-
-# if !defined(PNG_IMPEXP)
-# if defined(PNG_BUILD_DLL)
-# define PNG_IMPEXP __declspec(dllexport)
-# else
-# define PNG_IMPEXP __declspec(dllimport)
-# endif
-# endif
-# endif /* PNG_IMPEXP */
-#else /* !(DLL || non-cygwin WINDOWS) */
-# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
-# ifndef PNGAPI
-# define PNGAPI _System
-# endif
-# else
-# if 0 /* ... other platforms, with other meanings */
-# endif
-# endif
-#endif
-
-#ifndef PNGAPI
-# define PNGAPI
-#endif
-#ifndef PNG_IMPEXP
-# define PNG_IMPEXP
-#endif
-
-#ifdef PNG_BUILDSYMS
-# ifndef PNG_EXPORT
-# define PNG_EXPORT(type,symbol) PNG_FUNCTION_EXPORT symbol END
-# endif
-# ifdef PNG_USE_GLOBAL_ARRAYS
-# ifndef PNG_EXPORT_VAR
-# define PNG_EXPORT_VAR(type) PNG_DATA_EXPORT
-# endif
-# endif
-#endif
-
-#ifndef PNG_EXPORT
-# define PNG_EXPORT(type,symbol) PNG_IMPEXP type PNGAPI symbol
-#endif
-
-#ifdef PNG_USE_GLOBAL_ARRAYS
-# ifndef PNG_EXPORT_VAR
-# define PNG_EXPORT_VAR(type) extern PNG_IMPEXP type
-# endif
-#endif
-
-/* User may want to use these so they are not in PNG_INTERNAL. Any library
- * functions that are passed far data must be model independent.
- */
-
-#ifndef PNG_ABORT
-# define PNG_ABORT() abort()
-#endif
-
-#ifdef PNG_SETJMP_SUPPORTED
-# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
-#else
-# define png_jmpbuf(png_ptr) \
- (LIBPNG_WAS_COMPILED_WITH__PNG_SETJMP_NOT_SUPPORTED)
-#endif
-
-#if defined(USE_FAR_KEYWORD) /* memory model independent fns */
-/* use this to make far-to-near assignments */
-# define CHECK 1
-# define NOCHECK 0
-# define CVT_PTR(ptr) (png_far_to_near(png_ptr,ptr,CHECK))
-# define CVT_PTR_NOCHECK(ptr) (png_far_to_near(png_ptr,ptr,NOCHECK))
-# define png_snprintf _fsnprintf /* Added to v 1.2.19 */
-# define png_strlen _fstrlen
-# define png_memcmp _fmemcmp /* SJT: added */
-# define png_memcpy _fmemcpy
-# define png_memset _fmemset
-#else /* use the usual functions */
-# define CVT_PTR(ptr) (ptr)
-# define CVT_PTR_NOCHECK(ptr) (ptr)
-# ifndef PNG_NO_SNPRINTF
-# ifdef _MSC_VER
-# define png_snprintf _snprintf /* Added to v 1.2.19 */
-# define png_snprintf2 _snprintf
-# define png_snprintf6 _snprintf
-# else
-# define png_snprintf snprintf /* Added to v 1.2.19 */
-# define png_snprintf2 snprintf
-# define png_snprintf6 snprintf
-# endif
-# else
- /* You don't have or don't want to use snprintf(). Caution: Using
- * sprintf instead of snprintf exposes your application to accidental
- * or malevolent buffer overflows. If you don't have snprintf()
- * as a general rule you should provide one (you can get one from
- * Portable OpenSSH). */
-# define png_snprintf(s1,n,fmt,x1) sprintf(s1,fmt,x1)
-# define png_snprintf2(s1,n,fmt,x1,x2) sprintf(s1,fmt,x1,x2)
-# define png_snprintf6(s1,n,fmt,x1,x2,x3,x4,x5,x6) \
- sprintf(s1,fmt,x1,x2,x3,x4,x5,x6)
-# endif
-# define png_strlen strlen
-# define png_memcmp memcmp /* SJT: added */
-# define png_memcpy memcpy
-# define png_memset memset
-#endif
-/* End of memory model independent support */
-
-/* Just a little check that someone hasn't tried to define something
- * contradictory.
- */
-#if (PNG_ZBUF_SIZE > 65536L) && defined(PNG_MAX_MALLOC_64K)
-# undef PNG_ZBUF_SIZE
-# define PNG_ZBUF_SIZE 65536L
-#endif
-
-/* Added at libpng-1.2.8 */
-#endif /* PNG_VERSION_INFO_ONLY */
-
-#endif /* PNGCONF_H */
diff --git a/navit/support/libpng/pngerror.c b/navit/support/libpng/pngerror.c
deleted file mode 100644
index b85ee1165..000000000
--- a/navit/support/libpng/pngerror.c
+++ /dev/null
@@ -1,359 +0,0 @@
-
-/* pngerror.c - stub functions for i/o and memory allocation
- *
- * Last changed in libpng 1.2.36 [May 7, 2009]
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2009 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This file provides a location for all error handling. Users who
- * need special error handling are expected to write replacement functions
- * and use png_set_error_fn() to use those functions. See the instructions
- * at each function.
- */
-
-#define PNG_INTERNAL
-#include "png.h"
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-
-static void /* PRIVATE */
-png_default_error PNGARG((png_structp png_ptr,
- png_const_charp error_message));
-#ifndef PNG_NO_WARNINGS
-static void /* PRIVATE */
-png_default_warning PNGARG((png_structp png_ptr,
- png_const_charp warning_message));
-#endif /* PNG_NO_WARNINGS */
-
-/* This function is called whenever there is a fatal error. This function
- * should not be changed. If there is a need to handle errors differently,
- * you should supply a replacement error function and use png_set_error_fn()
- * to replace the error function at run-time.
- */
-#ifndef PNG_NO_ERROR_TEXT
-void PNGAPI
-png_error(png_structp png_ptr, png_const_charp error_message)
-{
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- char msg[16];
- if (png_ptr != NULL)
- {
- if (png_ptr->flags&
- (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
- {
- if (*error_message == '#')
- {
- /* Strip "#nnnn " from beginning of error message. */
- int offset;
- for (offset = 1; offset<15; offset++)
- if (error_message[offset] == ' ')
- break;
- if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
- {
- int i;
- for (i = 0; i < offset - 1; i++)
- msg[i] = error_message[i + 1];
- msg[i - 1] = '\0';
- error_message = msg;
- }
- else
- error_message += offset;
- }
- else
- {
- if (png_ptr->flags&PNG_FLAG_STRIP_ERROR_TEXT)
- {
- msg[0] = '0';
- msg[1] = '\0';
- error_message = msg;
- }
- }
- }
- }
-#endif
- if (png_ptr != NULL && png_ptr->error_fn != NULL)
- (*(png_ptr->error_fn))(png_ptr, error_message);
-
- /* If the custom handler doesn't exist, or if it returns,
- use the default handler, which will not return. */
- png_default_error(png_ptr, error_message);
-}
-#else
-void PNGAPI
-png_err(png_structp png_ptr)
-{
- if (png_ptr != NULL && png_ptr->error_fn != NULL)
- (*(png_ptr->error_fn))(png_ptr, '\0');
-
- /* If the custom handler doesn't exist, or if it returns,
- use the default handler, which will not return. */
- png_default_error(png_ptr, '\0');
-}
-#endif /* PNG_NO_ERROR_TEXT */
-
-#ifndef PNG_NO_WARNINGS
-/* This function is called whenever there is a non-fatal error. This function
- * should not be changed. If there is a need to handle warnings differently,
- * you should supply a replacement warning function and use
- * png_set_error_fn() to replace the warning function at run-time.
- */
-void PNGAPI
-png_warning(png_structp png_ptr, png_const_charp warning_message)
-{
- int offset = 0;
- if (png_ptr != NULL)
- {
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- if (png_ptr->flags&
- (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))
-#endif
- {
- if (*warning_message == '#')
- {
- for (offset = 1; offset < 15; offset++)
- if (warning_message[offset] == ' ')
- break;
- }
- }
- }
- if (png_ptr != NULL && png_ptr->warning_fn != NULL)
- (*(png_ptr->warning_fn))(png_ptr, warning_message + offset);
- else
- png_default_warning(png_ptr, warning_message + offset);
-}
-#endif /* PNG_NO_WARNINGS */
-
-
-/* These utilities are used internally to build an error message that relates
- * to the current chunk. The chunk name comes from png_ptr->chunk_name,
- * this is used to prefix the message. The message is limited in length
- * to 63 bytes, the name characters are output as hex digits wrapped in []
- * if the character is invalid.
- */
-#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
-static PNG_CONST char png_digit[16] = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
- 'A', 'B', 'C', 'D', 'E', 'F'
-};
-
-#define PNG_MAX_ERROR_TEXT 64
-
-#if !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT)
-static void /* PRIVATE */
-png_format_buffer(png_structp png_ptr, png_charp buffer, png_const_charp
- error_message)
-{
- int iout = 0, iin = 0;
-
- while (iin < 4)
- {
- int c = png_ptr->chunk_name[iin++];
- if (isnonalpha(c))
- {
- buffer[iout++] = '[';
- buffer[iout++] = png_digit[(c & 0xf0) >> 4];
- buffer[iout++] = png_digit[c & 0x0f];
- buffer[iout++] = ']';
- }
- else
- {
- buffer[iout++] = (png_byte)c;
- }
- }
-
- if (error_message == NULL)
- buffer[iout] = '\0';
- else
- {
- buffer[iout++] = ':';
- buffer[iout++] = ' ';
- png_memcpy(buffer + iout, error_message, PNG_MAX_ERROR_TEXT);
- buffer[iout + PNG_MAX_ERROR_TEXT - 1] = '\0';
- }
-}
-
-#ifdef PNG_READ_SUPPORTED
-void PNGAPI
-png_chunk_error(png_structp png_ptr, png_const_charp error_message)
-{
- char msg[18+PNG_MAX_ERROR_TEXT];
- if (png_ptr == NULL)
- png_error(png_ptr, error_message);
- else
- {
- png_format_buffer(png_ptr, msg, error_message);
- png_error(png_ptr, msg);
- }
-}
-#endif /* PNG_READ_SUPPORTED */
-#endif /* !defined(PNG_NO_WARNINGS) || !defined(PNG_NO_ERROR_TEXT) */
-
-#ifndef PNG_NO_WARNINGS
-void PNGAPI
-png_chunk_warning(png_structp png_ptr, png_const_charp warning_message)
-{
- char msg[18+PNG_MAX_ERROR_TEXT];
- if (png_ptr == NULL)
- png_warning(png_ptr, warning_message);
- else
- {
- png_format_buffer(png_ptr, msg, warning_message);
- png_warning(png_ptr, msg);
- }
-}
-#endif /* PNG_NO_WARNINGS */
-
-
-/* This is the default error handling function. Note that replacements for
- * this function MUST NOT RETURN, or the program will likely crash. This
- * function is used by default, or if the program supplies NULL for the
- * error function pointer in png_set_error_fn().
- */
-static void /* PRIVATE */
-png_default_error(png_structp png_ptr, png_const_charp error_message)
-{
-#ifndef PNG_NO_CONSOLE_IO
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- if (*error_message == '#')
- {
- /* Strip "#nnnn " from beginning of error message. */
- int offset;
- char error_number[16];
- for (offset = 0; offset<15; offset++)
- {
- error_number[offset] = error_message[offset + 1];
- if (error_message[offset] == ' ')
- break;
- }
- if ((offset > 1) && (offset < 15))
- {
- error_number[offset - 1] = '\0';
- fprintf(stderr, "libpng error no. %s: %s",
- error_number, error_message + offset + 1);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
- else
- fprintf(stderr, "libpng error: %s, offset=%d",
- error_message, offset);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
- else
-#endif
- {
- fprintf(stderr, "libpng error: %s", error_message);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
-#endif
-
-#ifdef PNG_SETJMP_SUPPORTED
- if (png_ptr)
- {
-# ifdef USE_FAR_KEYWORD
- {
- jmp_buf jmpbuf;
- png_memcpy(jmpbuf, png_ptr->jmpbuf, png_sizeof(jmp_buf));
- longjmp(jmpbuf, 1);
- }
-# else
- longjmp(png_ptr->jmpbuf, 1);
-# endif
- }
-#else
- PNG_ABORT();
-#endif
-#ifdef PNG_NO_CONSOLE_IO
- error_message = error_message; /* make compiler happy */
-#endif
-}
-
-#ifndef PNG_NO_WARNINGS
-/* This function is called when there is a warning, but the library thinks
- * it can continue anyway. Replacement functions don't have to do anything
- * here if you don't want them to. In the default configuration, png_ptr is
- * not used, but it is passed in case it may be useful.
- */
-static void /* PRIVATE */
-png_default_warning(png_structp png_ptr, png_const_charp warning_message)
-{
-#ifndef PNG_NO_CONSOLE_IO
-# ifdef PNG_ERROR_NUMBERS_SUPPORTED
- if (*warning_message == '#')
- {
- int offset;
- char warning_number[16];
- for (offset = 0; offset < 15; offset++)
- {
- warning_number[offset] = warning_message[offset + 1];
- if (warning_message[offset] == ' ')
- break;
- }
- if ((offset > 1) && (offset < 15))
- {
- warning_number[offset + 1] = '\0';
- fprintf(stderr, "libpng warning no. %s: %s",
- warning_number, warning_message + offset);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
- else
- {
- fprintf(stderr, "libpng warning: %s",
- warning_message);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
- }
- else
-# endif
- {
- fprintf(stderr, "libpng warning: %s", warning_message);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
-#else
- warning_message = warning_message; /* make compiler happy */
-#endif
- png_ptr = png_ptr; /* make compiler happy */
-}
-#endif /* PNG_NO_WARNINGS */
-
-/* This function is called when the application wants to use another method
- * of handling errors and warnings. Note that the error function MUST NOT
- * return to the calling routine or serious problems will occur. The return
- * method used in the default routine calls longjmp(png_ptr->jmpbuf, 1)
- */
-void PNGAPI
-png_set_error_fn(png_structp png_ptr, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warning_fn)
-{
- if (png_ptr == NULL)
- return;
- png_ptr->error_ptr = error_ptr;
- png_ptr->error_fn = error_fn;
- png_ptr->warning_fn = warning_fn;
-}
-
-
-/* This function returns a pointer to the error_ptr associated with the user
- * functions. The application should free any memory associated with this
- * pointer before png_write_destroy and png_read_destroy are called.
- */
-png_voidp PNGAPI
-png_get_error_ptr(png_structp png_ptr)
-{
- if (png_ptr == NULL)
- return NULL;
- return ((png_voidp)png_ptr->error_ptr);
-}
-
-
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-void PNGAPI
-png_set_strip_error_numbers(png_structp png_ptr, png_uint_32 strip_mode)
-{
- if (png_ptr != NULL)
- {
- png_ptr->flags &=
- ((~(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
- }
-}
-#endif
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
diff --git a/navit/support/libpng/pngget.c b/navit/support/libpng/pngget.c
deleted file mode 100644
index 3b2b64600..000000000
--- a/navit/support/libpng/pngget.c
+++ /dev/null
@@ -1,900 +0,0 @@
-
-/* pngget.c - retrieval of values from info struct
- *
- * Last changed in libpng 1.2.30 [August 15, 2008]
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2008 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- */
-
-#define PNG_INTERNAL
-#include "png.h"
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-
-png_uint_32 PNGAPI
-png_get_valid(png_structp png_ptr, png_infop info_ptr, png_uint_32 flag)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->valid & flag);
- else
- return(0);
-}
-
-png_uint_32 PNGAPI
-png_get_rowbytes(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->rowbytes);
- else
- return(0);
-}
-
-#if defined(PNG_INFO_IMAGE_SUPPORTED)
-png_bytepp PNGAPI
-png_get_rows(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->row_pointers);
- else
- return(0);
-}
-#endif
-
-#ifdef PNG_EASY_ACCESS_SUPPORTED
-/* easy access to info, added in libpng-0.99 */
-png_uint_32 PNGAPI
-png_get_image_width(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- {
- return info_ptr->width;
- }
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_image_height(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- {
- return info_ptr->height;
- }
- return (0);
-}
-
-png_byte PNGAPI
-png_get_bit_depth(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- {
- return info_ptr->bit_depth;
- }
- return (0);
-}
-
-png_byte PNGAPI
-png_get_color_type(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- {
- return info_ptr->color_type;
- }
- return (0);
-}
-
-png_byte PNGAPI
-png_get_filter_type(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- {
- return info_ptr->filter_type;
- }
- return (0);
-}
-
-png_byte PNGAPI
-png_get_interlace_type(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- {
- return info_ptr->interlace_type;
- }
- return (0);
-}
-
-png_byte PNGAPI
-png_get_compression_type(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- {
- return info_ptr->compression_type;
- }
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_x_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
-#if defined(PNG_pHYs_SUPPORTED)
- if (info_ptr->valid & PNG_INFO_pHYs)
- {
- png_debug1(1, "in %s retrieval function", "png_get_x_pixels_per_meter");
- if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
- return (0);
- else return (info_ptr->x_pixels_per_unit);
- }
-#else
- return (0);
-#endif
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_y_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
-#if defined(PNG_pHYs_SUPPORTED)
- if (info_ptr->valid & PNG_INFO_pHYs)
- {
- png_debug1(1, "in %s retrieval function", "png_get_y_pixels_per_meter");
- if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER)
- return (0);
- else return (info_ptr->y_pixels_per_unit);
- }
-#else
- return (0);
-#endif
- return (0);
-}
-
-png_uint_32 PNGAPI
-png_get_pixels_per_meter(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
-#if defined(PNG_pHYs_SUPPORTED)
- if (info_ptr->valid & PNG_INFO_pHYs)
- {
- png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
- if (info_ptr->phys_unit_type != PNG_RESOLUTION_METER ||
- info_ptr->x_pixels_per_unit != info_ptr->y_pixels_per_unit)
- return (0);
- else return (info_ptr->x_pixels_per_unit);
- }
-#else
- return (0);
-#endif
- return (0);
-}
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-float PNGAPI
-png_get_pixel_aspect_ratio(png_structp png_ptr, png_infop info_ptr)
- {
- if (png_ptr != NULL && info_ptr != NULL)
-#if defined(PNG_pHYs_SUPPORTED)
- if (info_ptr->valid & PNG_INFO_pHYs)
- {
- png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
- if (info_ptr->x_pixels_per_unit == 0)
- return ((float)0.0);
- else
- return ((float)((float)info_ptr->y_pixels_per_unit
- /(float)info_ptr->x_pixels_per_unit));
- }
-#else
- return (0.0);
-#endif
- return ((float)0.0);
-}
-#endif
-
-png_int_32 PNGAPI
-png_get_x_offset_microns(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
-#if defined(PNG_oFFs_SUPPORTED)
- if (info_ptr->valid & PNG_INFO_oFFs)
- {
- png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
- if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
- return (0);
- else return (info_ptr->x_offset);
- }
-#else
- return (0);
-#endif
- return (0);
-}
-
-png_int_32 PNGAPI
-png_get_y_offset_microns(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
-#if defined(PNG_oFFs_SUPPORTED)
- if (info_ptr->valid & PNG_INFO_oFFs)
- {
- png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
- if (info_ptr->offset_unit_type != PNG_OFFSET_MICROMETER)
- return (0);
- else return (info_ptr->y_offset);
- }
-#else
- return (0);
-#endif
- return (0);
-}
-
-png_int_32 PNGAPI
-png_get_x_offset_pixels(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
-#if defined(PNG_oFFs_SUPPORTED)
- if (info_ptr->valid & PNG_INFO_oFFs)
- {
- png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
- if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
- return (0);
- else return (info_ptr->x_offset);
- }
-#else
- return (0);
-#endif
- return (0);
-}
-
-png_int_32 PNGAPI
-png_get_y_offset_pixels(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
-#if defined(PNG_oFFs_SUPPORTED)
- if (info_ptr->valid & PNG_INFO_oFFs)
- {
- png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
- if (info_ptr->offset_unit_type != PNG_OFFSET_PIXEL)
- return (0);
- else return (info_ptr->y_offset);
- }
-#else
- return (0);
-#endif
- return (0);
-}
-
-#if defined(PNG_INCH_CONVERSIONS) && defined(PNG_FLOATING_POINT_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
-{
- return ((png_uint_32)((float)png_get_pixels_per_meter(png_ptr, info_ptr)
- *.0254 +.5));
-}
-
-png_uint_32 PNGAPI
-png_get_x_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
-{
- return ((png_uint_32)((float)png_get_x_pixels_per_meter(png_ptr, info_ptr)
- *.0254 +.5));
-}
-
-png_uint_32 PNGAPI
-png_get_y_pixels_per_inch(png_structp png_ptr, png_infop info_ptr)
-{
- return ((png_uint_32)((float)png_get_y_pixels_per_meter(png_ptr, info_ptr)
- *.0254 +.5));
-}
-
-float PNGAPI
-png_get_x_offset_inches(png_structp png_ptr, png_infop info_ptr)
-{
- return ((float)png_get_x_offset_microns(png_ptr, info_ptr)
- *.00003937);
-}
-
-float PNGAPI
-png_get_y_offset_inches(png_structp png_ptr, png_infop info_ptr)
-{
- return ((float)png_get_y_offset_microns(png_ptr, info_ptr)
- *.00003937);
-}
-
-#if defined(PNG_pHYs_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_pHYs_dpi(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
-{
- png_uint_32 retval = 0;
-
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
- {
- png_debug1(1, "in %s retrieval function", "pHYs");
- if (res_x != NULL)
- {
- *res_x = info_ptr->x_pixels_per_unit;
- retval |= PNG_INFO_pHYs;
- }
- if (res_y != NULL)
- {
- *res_y = info_ptr->y_pixels_per_unit;
- retval |= PNG_INFO_pHYs;
- }
- if (unit_type != NULL)
- {
- *unit_type = (int)info_ptr->phys_unit_type;
- retval |= PNG_INFO_pHYs;
- if (*unit_type == 1)
- {
- if (res_x != NULL) *res_x = (png_uint_32)(*res_x * .0254 + .50);
- if (res_y != NULL) *res_y = (png_uint_32)(*res_y * .0254 + .50);
- }
- }
- }
- return (retval);
-}
-#endif /* PNG_pHYs_SUPPORTED */
-#endif /* PNG_INCH_CONVERSIONS && PNG_FLOATING_POINT_SUPPORTED */
-
-/* png_get_channels really belongs in here, too, but it's been around longer */
-
-#endif /* PNG_EASY_ACCESS_SUPPORTED */
-
-png_byte PNGAPI
-png_get_channels(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->channels);
- else
- return (0);
-}
-
-png_bytep PNGAPI
-png_get_signature(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->signature);
- else
- return (NULL);
-}
-
-#if defined(PNG_bKGD_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_bKGD(png_structp png_ptr, png_infop info_ptr,
- png_color_16p *background)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD)
- && background != NULL)
- {
- png_debug1(1, "in %s retrieval function", "bKGD");
- *background = &(info_ptr->background);
- return (PNG_INFO_bKGD);
- }
- return (0);
-}
-#endif
-
-#if defined(PNG_cHRM_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_cHRM(png_structp png_ptr, png_infop info_ptr,
- double *white_x, double *white_y, double *red_x, double *red_y,
- double *green_x, double *green_y, double *blue_x, double *blue_y)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
- {
- png_debug1(1, "in %s retrieval function", "cHRM");
- if (white_x != NULL)
- *white_x = (double)info_ptr->x_white;
- if (white_y != NULL)
- *white_y = (double)info_ptr->y_white;
- if (red_x != NULL)
- *red_x = (double)info_ptr->x_red;
- if (red_y != NULL)
- *red_y = (double)info_ptr->y_red;
- if (green_x != NULL)
- *green_x = (double)info_ptr->x_green;
- if (green_y != NULL)
- *green_y = (double)info_ptr->y_green;
- if (blue_x != NULL)
- *blue_x = (double)info_ptr->x_blue;
- if (blue_y != NULL)
- *blue_y = (double)info_ptr->y_blue;
- return (PNG_INFO_cHRM);
- }
- return (0);
-}
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
- png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
- png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
- png_fixed_point *blue_x, png_fixed_point *blue_y)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
- {
- png_debug1(1, "in %s retrieval function", "cHRM");
- if (white_x != NULL)
- *white_x = info_ptr->int_x_white;
- if (white_y != NULL)
- *white_y = info_ptr->int_y_white;
- if (red_x != NULL)
- *red_x = info_ptr->int_x_red;
- if (red_y != NULL)
- *red_y = info_ptr->int_y_red;
- if (green_x != NULL)
- *green_x = info_ptr->int_x_green;
- if (green_y != NULL)
- *green_y = info_ptr->int_y_green;
- if (blue_x != NULL)
- *blue_x = info_ptr->int_x_blue;
- if (blue_y != NULL)
- *blue_y = info_ptr->int_y_blue;
- return (PNG_INFO_cHRM);
- }
- return (0);
-}
-#endif
-#endif
-
-#if defined(PNG_gAMA_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_gAMA(png_structp png_ptr, png_infop info_ptr, double *file_gamma)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
- && file_gamma != NULL)
- {
- png_debug1(1, "in %s retrieval function", "gAMA");
- *file_gamma = (double)info_ptr->gamma;
- return (PNG_INFO_gAMA);
- }
- return (0);
-}
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_gAMA_fixed(png_structp png_ptr, png_infop info_ptr,
- png_fixed_point *int_file_gamma)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
- && int_file_gamma != NULL)
- {
- png_debug1(1, "in %s retrieval function", "gAMA");
- *int_file_gamma = info_ptr->int_gamma;
- return (PNG_INFO_gAMA);
- }
- return (0);
-}
-#endif
-#endif
-
-#if defined(PNG_sRGB_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_sRGB(png_structp png_ptr, png_infop info_ptr, int *file_srgb_intent)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB)
- && file_srgb_intent != NULL)
- {
- png_debug1(1, "in %s retrieval function", "sRGB");
- *file_srgb_intent = (int)info_ptr->srgb_intent;
- return (PNG_INFO_sRGB);
- }
- return (0);
-}
-#endif
-
-#if defined(PNG_iCCP_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_iCCP(png_structp png_ptr, png_infop info_ptr,
- png_charpp name, int *compression_type,
- png_charpp profile, png_uint_32 *proflen)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP)
- && name != NULL && profile != NULL && proflen != NULL)
- {
- png_debug1(1, "in %s retrieval function", "iCCP");
- *name = info_ptr->iccp_name;
- *profile = info_ptr->iccp_profile;
- /* compression_type is a dummy so the API won't have to change
- if we introduce multiple compression types later. */
- *proflen = (int)info_ptr->iccp_proflen;
- *compression_type = (int)info_ptr->iccp_compression;
- return (PNG_INFO_iCCP);
- }
- return (0);
-}
-#endif
-
-#if defined(PNG_sPLT_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_sPLT(png_structp png_ptr, png_infop info_ptr,
- png_sPLT_tpp spalettes)
-{
- if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
- {
- *spalettes = info_ptr->splt_palettes;
- return ((png_uint_32)info_ptr->splt_palettes_num);
- }
- return (0);
-}
-#endif
-
-#if defined(PNG_hIST_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p *hist)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST)
- && hist != NULL)
- {
- png_debug1(1, "in %s retrieval function", "hIST");
- *hist = info_ptr->hist;
- return (PNG_INFO_hIST);
- }
- return (0);
-}
-#endif
-
-png_uint_32 PNGAPI
-png_get_IHDR(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 *width, png_uint_32 *height, int *bit_depth,
- int *color_type, int *interlace_type, int *compression_type,
- int *filter_type)
-
-{
- if (png_ptr != NULL && info_ptr != NULL && width != NULL && height != NULL &&
- bit_depth != NULL && color_type != NULL)
- {
- png_debug1(1, "in %s retrieval function", "IHDR");
- *width = info_ptr->width;
- *height = info_ptr->height;
- *bit_depth = info_ptr->bit_depth;
- if (info_ptr->bit_depth < 1 || info_ptr->bit_depth > 16)
- png_error(png_ptr, "Invalid bit depth");
- *color_type = info_ptr->color_type;
- if (info_ptr->color_type > 6)
- png_error(png_ptr, "Invalid color type");
- if (compression_type != NULL)
- *compression_type = info_ptr->compression_type;
- if (filter_type != NULL)
- *filter_type = info_ptr->filter_type;
- if (interlace_type != NULL)
- *interlace_type = info_ptr->interlace_type;
-
- /* check for potential overflow of rowbytes */
- if (*width == 0 || *width > PNG_UINT_31_MAX)
- png_error(png_ptr, "Invalid image width");
- if (*height == 0 || *height > PNG_UINT_31_MAX)
- png_error(png_ptr, "Invalid image height");
- if (info_ptr->width > (PNG_UINT_32_MAX
- >> 3) /* 8-byte RGBA pixels */
- - 64 /* bigrowbuf hack */
- - 1 /* filter byte */
- - 7*8 /* rounding of width to multiple of 8 pixels */
- - 8) /* extra max_pixel_depth pad */
- {
- png_warning(png_ptr,
- "Width too large for libpng to process image data.");
- }
- return (1);
- }
- return (0);
-}
-
-#if defined(PNG_oFFs_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_oFFs(png_structp png_ptr, png_infop info_ptr,
- png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs)
- && offset_x != NULL && offset_y != NULL && unit_type != NULL)
- {
- png_debug1(1, "in %s retrieval function", "oFFs");
- *offset_x = info_ptr->x_offset;
- *offset_y = info_ptr->y_offset;
- *unit_type = (int)info_ptr->offset_unit_type;
- return (PNG_INFO_oFFs);
- }
- return (0);
-}
-#endif
-
-#if defined(PNG_pCAL_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_pCAL(png_structp png_ptr, png_infop info_ptr,
- png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
- png_charp *units, png_charpp *params)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL)
- && purpose != NULL && X0 != NULL && X1 != NULL && type != NULL &&
- nparams != NULL && units != NULL && params != NULL)
- {
- png_debug1(1, "in %s retrieval function", "pCAL");
- *purpose = info_ptr->pcal_purpose;
- *X0 = info_ptr->pcal_X0;
- *X1 = info_ptr->pcal_X1;
- *type = (int)info_ptr->pcal_type;
- *nparams = (int)info_ptr->pcal_nparams;
- *units = info_ptr->pcal_units;
- *params = info_ptr->pcal_params;
- return (PNG_INFO_pCAL);
- }
- return (0);
-}
-#endif
-
-#if defined(PNG_sCAL_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_sCAL(png_structp png_ptr, png_infop info_ptr,
- int *unit, double *width, double *height)
-{
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL))
- {
- *unit = info_ptr->scal_unit;
- *width = info_ptr->scal_pixel_width;
- *height = info_ptr->scal_pixel_height;
- return (PNG_INFO_sCAL);
- }
- return(0);
-}
-#else
-#ifdef PNG_FIXED_POINT_SUPPORTED
-png_uint_32 PNGAPI
-png_get_sCAL_s(png_structp png_ptr, png_infop info_ptr,
- int *unit, png_charpp width, png_charpp height)
-{
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sCAL))
- {
- *unit = info_ptr->scal_unit;
- *width = info_ptr->scal_s_width;
- *height = info_ptr->scal_s_height;
- return (PNG_INFO_sCAL);
- }
- return(0);
-}
-#endif
-#endif
-#endif
-
-#if defined(PNG_pHYs_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_pHYs(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)
-{
- png_uint_32 retval = 0;
-
- if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_pHYs))
- {
- png_debug1(1, "in %s retrieval function", "pHYs");
- if (res_x != NULL)
- {
- *res_x = info_ptr->x_pixels_per_unit;
- retval |= PNG_INFO_pHYs;
- }
- if (res_y != NULL)
- {
- *res_y = info_ptr->y_pixels_per_unit;
- retval |= PNG_INFO_pHYs;
- }
- if (unit_type != NULL)
- {
- *unit_type = (int)info_ptr->phys_unit_type;
- retval |= PNG_INFO_pHYs;
- }
- }
- return (retval);
-}
-#endif
-
-png_uint_32 PNGAPI
-png_get_PLTE(png_structp png_ptr, png_infop info_ptr, png_colorp *palette,
- int *num_palette)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_PLTE)
- && palette != NULL)
- {
- png_debug1(1, "in %s retrieval function", "PLTE");
- *palette = info_ptr->palette;
- *num_palette = info_ptr->num_palette;
- png_debug1(3, "num_palette = %d", *num_palette);
- return (PNG_INFO_PLTE);
- }
- return (0);
-}
-
-#if defined(PNG_sBIT_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_sBIT(png_structp png_ptr, png_infop info_ptr, png_color_8p *sig_bit)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT)
- && sig_bit != NULL)
- {
- png_debug1(1, "in %s retrieval function", "sBIT");
- *sig_bit = &(info_ptr->sig_bit);
- return (PNG_INFO_sBIT);
- }
- return (0);
-}
-#endif
-
-#if defined(PNG_TEXT_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_text(png_structp png_ptr, png_infop info_ptr, png_textp *text_ptr,
- int *num_text)
-{
- if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
- {
- png_debug1(1, "in %s retrieval function",
- (png_ptr->chunk_name[0] == '\0' ? "text"
- : (png_const_charp)png_ptr->chunk_name));
- if (text_ptr != NULL)
- *text_ptr = info_ptr->text;
- if (num_text != NULL)
- *num_text = info_ptr->num_text;
- return ((png_uint_32)info_ptr->num_text);
- }
- if (num_text != NULL)
- *num_text = 0;
- return(0);
-}
-#endif
-
-#if defined(PNG_tIME_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_tIME(png_structp png_ptr, png_infop info_ptr, png_timep *mod_time)
-{
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME)
- && mod_time != NULL)
- {
- png_debug1(1, "in %s retrieval function", "tIME");
- *mod_time = &(info_ptr->mod_time);
- return (PNG_INFO_tIME);
- }
- return (0);
-}
-#endif
-
-#if defined(PNG_tRNS_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_tRNS(png_structp png_ptr, png_infop info_ptr,
- png_bytep *trans, int *num_trans, png_color_16p *trans_values)
-{
- png_uint_32 retval = 0;
- if (png_ptr != NULL && info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
- {
- png_debug1(1, "in %s retrieval function", "tRNS");
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (trans != NULL)
- {
- *trans = info_ptr->trans;
- retval |= PNG_INFO_tRNS;
- }
- if (trans_values != NULL)
- *trans_values = &(info_ptr->trans_values);
- }
- else /* if (info_ptr->color_type != PNG_COLOR_TYPE_PALETTE) */
- {
- if (trans_values != NULL)
- {
- *trans_values = &(info_ptr->trans_values);
- retval |= PNG_INFO_tRNS;
- }
- if (trans != NULL)
- *trans = NULL;
- }
- if (num_trans != NULL)
- {
- *num_trans = info_ptr->num_trans;
- retval |= PNG_INFO_tRNS;
- }
- }
- return (retval);
-}
-#endif
-
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
-png_uint_32 PNGAPI
-png_get_unknown_chunks(png_structp png_ptr, png_infop info_ptr,
- png_unknown_chunkpp unknowns)
-{
- if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
- {
- *unknowns = info_ptr->unknown_chunks;
- return ((png_uint_32)info_ptr->unknown_chunks_num);
- }
- return (0);
-}
-#endif
-
-#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
-png_byte PNGAPI
-png_get_rgb_to_gray_status (png_structp png_ptr)
-{
- return (png_byte)(png_ptr? png_ptr->rgb_to_gray_status : 0);
-}
-#endif
-
-#if defined(PNG_USER_CHUNKS_SUPPORTED)
-png_voidp PNGAPI
-png_get_user_chunk_ptr(png_structp png_ptr)
-{
- return (png_ptr? png_ptr->user_chunk_ptr : NULL);
-}
-#endif
-
-#ifdef PNG_WRITE_SUPPORTED
-png_uint_32 PNGAPI
-png_get_compression_buffer_size(png_structp png_ptr)
-{
- return (png_uint_32)(png_ptr? png_ptr->zbuf_size : 0L);
-}
-#endif
-
-#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
-#ifndef PNG_1_0_X
-/* this function was added to libpng 1.2.0 and should exist by default */
-png_uint_32 PNGAPI
-png_get_asm_flags (png_structp png_ptr)
-{
- /* obsolete, to be removed from libpng-1.4.0 */
- return (png_ptr? 0L: 0L);
-}
-
-/* this function was added to libpng 1.2.0 and should exist by default */
-png_uint_32 PNGAPI
-png_get_asm_flagmask (int flag_select)
-{
- /* obsolete, to be removed from libpng-1.4.0 */
- flag_select=flag_select;
- return 0L;
-}
-
- /* GRR: could add this: && defined(PNG_MMX_CODE_SUPPORTED) */
-/* this function was added to libpng 1.2.0 */
-png_uint_32 PNGAPI
-png_get_mmx_flagmask (int flag_select, int *compilerID)
-{
- /* obsolete, to be removed from libpng-1.4.0 */
- flag_select=flag_select;
- *compilerID = -1; /* unknown (i.e., no asm/MMX code compiled) */
- return 0L;
-}
-
-/* this function was added to libpng 1.2.0 */
-png_byte PNGAPI
-png_get_mmx_bitdepth_threshold (png_structp png_ptr)
-{
- /* obsolete, to be removed from libpng-1.4.0 */
- return (png_ptr? 0: 0);
-}
-
-/* this function was added to libpng 1.2.0 */
-png_uint_32 PNGAPI
-png_get_mmx_rowbytes_threshold (png_structp png_ptr)
-{
- /* obsolete, to be removed from libpng-1.4.0 */
- return (png_ptr? 0L: 0L);
-}
-#endif /* ?PNG_1_0_X */
-#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
-
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
-/* These functions were added to libpng 1.2.6 */
-png_uint_32 PNGAPI
-png_get_user_width_max (png_structp png_ptr)
-{
- return (png_ptr? png_ptr->user_width_max : 0);
-}
-png_uint_32 PNGAPI
-png_get_user_height_max (png_structp png_ptr)
-{
- return (png_ptr? png_ptr->user_height_max : 0);
-}
-#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
-
-
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
diff --git a/navit/support/libpng/pngm2pnm.c b/navit/support/libpng/pngm2pnm.c
deleted file mode 100644
index 010870a76..000000000
--- a/navit/support/libpng/pngm2pnm.c
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- * png2pnm.c --- conversion from PNG-file to PGM/PPM-file
- * copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
- *
- * version 1.0 - 1999.10.15 - First version.
- *
- * Permission to use, copy, modify, and distribute this software and
- * its documentation for any purpose and without fee is hereby granted,
- * provided that the above copyright notice appear in all copies and
- * that both that copyright notice and this permission notice appear in
- * supporting documentation. This software is provided "as is" without
- * express or implied warranty.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#ifdef __TURBOC__
-#include <mem.h>
-#include <fcntl.h>
-#endif
-
-#ifndef BOOL
-#define BOOL unsigned char
-#endif
-#ifndef TRUE
-#define TRUE (BOOL) 1
-#endif
-#ifndef FALSE
-#define FALSE (BOOL) 0
-#endif
-
-#ifdef __TURBOC__
-#define STDIN 0
-#define STDOUT 1
-#define STDERR 2
-#endif
-
-/* to make png2pnm verbose so we can find problems (needs to be before png.h) */
-#ifndef PNG_DEBUG
-#define PNG_DEBUG 0
-#endif
-
-#include "png.h"
-
-/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
-#ifndef png_jmpbuf
-# define png_jmpbuf(png_ptr) ((png_ptr)->jmpbuf)
-#endif
-
-/* function prototypes */
-
-int main (int argc, char *argv[]);
-void usage ();
-BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha);
-
-/*
- * main
- */
-
-int main(int argc, char *argv[])
-{
- FILE *fp_rd = stdin;
- FILE *fp_wr = stdout;
- FILE *fp_al = NULL;
- BOOL raw = TRUE;
- BOOL alpha = FALSE;
- int argi;
-
- for (argi = 1; argi < argc; argi++)
- {
- if (argv[argi][0] == '-')
- {
- switch (argv[argi][1])
- {
- case 'n':
- raw = FALSE;
- break;
- case 'r':
- raw = TRUE;
- break;
- case 'a':
- alpha = TRUE;
- argi++;
- if ((fp_al = fopen (argv[argi], "wb")) == NULL)
- {
- fprintf (stderr, "PNM2PNG\n");
- fprintf (stderr, "Error: can not create alpha-channel file %s\n", argv[argi]);
- exit (1);
- }
- break;
- case 'h':
- case '?':
- usage();
- exit(0);
- break;
- default:
- fprintf (stderr, "PNG2PNM\n");
- fprintf (stderr, "Error: unknown option %s\n", argv[argi]);
- usage();
- exit(1);
- break;
- } /* end switch */
- }
- else if (fp_rd == stdin)
- {
- if ((fp_rd = fopen (argv[argi], "rb")) == NULL)
- {
- fprintf (stderr, "PNG2PNM\n");
- fprintf (stderr, "Error: file %s does not exist\n", argv[argi]);
- exit (1);
- }
- }
- else if (fp_wr == stdout)
- {
- if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
- {
- fprintf (stderr, "PNG2PNM\n");
- fprintf (stderr, "Error: can not create file %s\n", argv[argi]);
- exit (1);
- }
- }
- else
- {
- fprintf (stderr, "PNG2PNM\n");
- fprintf (stderr, "Error: too many parameters\n");
- usage();
- exit(1);
- }
- } /* end for */
-
-#ifdef __TURBOC__
- /* set stdin/stdout if required to binary */
- if (fp_rd == stdin)
- {
- setmode (STDIN, O_BINARY);
- }
- if ((raw) && (fp_wr == stdout))
- {
- setmode (STDOUT, O_BINARY);
- }
-#endif
-
- /* call the conversion program itself */
- if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE)
- {
- fprintf (stderr, "PNG2PNM\n");
- fprintf (stderr, "Error: unsuccessful convertion of PNG-image\n");
- exit(1);
- }
-
- /* close input file */
- fclose (fp_rd);
- /* close output file */
- fclose (fp_wr);
- /* close alpha file */
- if (alpha)
- fclose (fp_al);
-
- return 0;
-}
-
-/*
- * usage
- */
-
-void usage()
-{
- fprintf (stderr, "PNG2PNM\n");
- fprintf (stderr, " by Willem van Schaik, 1999\n");
-#ifdef __TURBOC__
- fprintf (stderr, " for Turbo-C and Borland-C compilers\n");
-#else
- fprintf (stderr, " for Linux (and Unix) compilers\n");
-#endif
- fprintf (stderr, "Usage: png2pnm [options] <file>.png [<file>.pnm]\n");
- fprintf (stderr, " or: ... | png2pnm [options]\n");
- fprintf (stderr, "Options:\n");
- fprintf (stderr, " -r[aw] write pnm-file in binary format (P4/P5/P6) (default)\n");
- fprintf (stderr, " -n[oraw] write pnm-file in ascii format (P1/P2/P3)\n");
- fprintf (stderr, " -a[lpha] <file>.pgm write PNG alpha channel as pgm-file\n");
- fprintf (stderr, " -h | -? print this help-information\n");
-}
-
-/*
- * png2pnm
- */
-
-BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file, BOOL raw, BOOL alpha)
-{
- png_struct *png_ptr = NULL;
- png_info *info_ptr = NULL;
- png_byte buf[8];
- png_byte *png_pixels = NULL;
- png_byte **row_pointers = NULL;
- png_byte *pix_ptr = NULL;
- png_uint_32 row_bytes;
-
- png_uint_32 width;
- png_uint_32 height;
- int bit_depth;
- int channels;
- int color_type;
- int alpha_present;
- int row, col;
- int ret;
- int i;
- long dep_16;
-
- /* read and check signature in PNG file */
- ret = fread (buf, 1, 8, png_file);
- if (ret != 8)
- return FALSE;
-
- ret = png_check_sig (buf, 8);
- if (!ret)
- return FALSE;
-
- /* create png and info structures */
-
- png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING,
- NULL, NULL, NULL);
- if (!png_ptr)
- return FALSE; /* out of memory */
-
- info_ptr = png_create_info_struct (png_ptr);
- if (!info_ptr)
- {
- png_destroy_read_struct (&png_ptr, NULL, NULL);
- return FALSE; /* out of memory */
- }
-
- if (setjmp (png_jmpbuf(png_ptr)))
- {
- png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
- return FALSE;
- }
-
- /* set up the input control for C streams */
- png_init_io (png_ptr, png_file);
- png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */
-
- /* read the file information */
- png_read_info (png_ptr, info_ptr);
-
- /* get size and bit-depth of the PNG-image */
- png_get_IHDR (png_ptr, info_ptr,
- &width, &height, &bit_depth, &color_type,
- NULL, NULL, NULL);
-
- /* set-up the transformations */
-
- /* transform paletted images into full-color rgb */
- if (color_type == PNG_COLOR_TYPE_PALETTE)
- png_set_expand (png_ptr);
- /* expand images to bit-depth 8 (only applicable for grayscale images) */
- if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
- png_set_expand (png_ptr);
- /* transform transparency maps into full alpha-channel */
- if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
- png_set_expand (png_ptr);
-
-#ifdef NJET
- /* downgrade 16-bit images to 8 bit */
- if (bit_depth == 16)
- png_set_strip_16 (png_ptr);
- /* transform grayscale images into full-color */
- if (color_type == PNG_COLOR_TYPE_GRAY ||
- color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- png_set_gray_to_rgb (png_ptr);
- /* only if file has a file gamma, we do a correction */
- if (png_get_gAMA (png_ptr, info_ptr, &file_gamma))
- png_set_gamma (png_ptr, (double) 2.2, file_gamma);
-#endif
-
- /* all transformations have been registered; now update info_ptr data,
- * get rowbytes and channels, and allocate image memory */
-
- png_read_update_info (png_ptr, info_ptr);
-
- /* get the new color-type and bit-depth (after expansion/stripping) */
- png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
- NULL, NULL, NULL);
-
- /* check for 16-bit files */
- if (bit_depth == 16)
- {
- raw = FALSE;
-#ifdef __TURBOC__
- pnm_file->flags &= ~((unsigned) _F_BIN);
-#endif
- }
-
- /* calculate new number of channels and store alpha-presence */
- if (color_type == PNG_COLOR_TYPE_GRAY)
- channels = 1;
- else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- channels = 2;
- else if (color_type == PNG_COLOR_TYPE_RGB)
- channels = 3;
- else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- channels = 4;
- else
- channels = 0; /* should never happen */
- alpha_present = (channels - 1) % 2;
-
- /* check if alpha is expected to be present in file */
- if (alpha && !alpha_present)
- {
- fprintf (stderr, "PNG2PNM\n");
- fprintf (stderr, "Error: PNG-file doesn't contain alpha channel\n");
- exit (1);
- }
-
- /* row_bytes is the width x number of channels x (bit-depth / 8) */
- row_bytes = png_get_rowbytes (png_ptr, info_ptr);
-
- if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL) {
- png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
- return FALSE;
- }
-
- if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
- {
- png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
- free (png_pixels);
- png_pixels = NULL;
- return FALSE;
- }
-
- /* set the individual row_pointers to point at the correct offsets */
- for (i = 0; i < (height); i++)
- row_pointers[i] = png_pixels + i * row_bytes;
-
- /* now we can go ahead and just read the whole image */
- png_read_image (png_ptr, row_pointers);
-
- /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
- png_read_end (png_ptr, info_ptr);
-
- /* clean up after the read, and free any memory allocated - REQUIRED */
- png_destroy_read_struct (&png_ptr, &info_ptr, (png_infopp) NULL);
-
- /* write header of PNM file */
-
- if ((color_type == PNG_COLOR_TYPE_GRAY) ||
- (color_type == PNG_COLOR_TYPE_GRAY_ALPHA))
- {
- fprintf (pnm_file, "%s\n", (raw) ? "P5" : "P2");
- fprintf (pnm_file, "%d %d\n", (int) width, (int) height);
- fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L));
- }
- else if ((color_type == PNG_COLOR_TYPE_RGB) ||
- (color_type == PNG_COLOR_TYPE_RGB_ALPHA))
- {
- fprintf (pnm_file, "%s\n", (raw) ? "P6" : "P3");
- fprintf (pnm_file, "%d %d\n", (int) width, (int) height);
- fprintf (pnm_file, "%ld\n", ((1L << (int) bit_depth) - 1L));
- }
-
- /* write header of PGM file with alpha channel */
-
- if ((alpha) &&
- ((color_type == PNG_COLOR_TYPE_GRAY_ALPHA) ||
- (color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
- {
- fprintf (alpha_file, "%s\n", (raw) ? "P5" : "P2");
- fprintf (alpha_file, "%d %d\n", (int) width, (int) height);
- fprintf (alpha_file, "%ld\n", ((1L << (int) bit_depth) - 1L));
- }
-
- /* write data to PNM file */
- pix_ptr = png_pixels;
-
- for (row = 0; row < height; row++)
- {
- for (col = 0; col < width; col++)
- {
- for (i = 0; i < (channels - alpha_present); i++)
- {
- if (raw)
- fputc ((int) *pix_ptr++ , pnm_file);
- else
- if (bit_depth == 16){
- dep_16 = (long) *pix_ptr++;
- fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++));
- }
- else
- fprintf (pnm_file, "%ld ", (long) *pix_ptr++);
- }
- if (alpha_present)
- {
- if (!alpha)
- {
- pix_ptr++; /* alpha */
- if (bit_depth == 16)
- pix_ptr++;
- }
- else /* output alpha-channel as pgm file */
- {
- if (raw)
- fputc ((int) *pix_ptr++ , alpha_file);
- else
- if (bit_depth == 16){
- dep_16 = (long) *pix_ptr++;
- fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
- }
- else
- fprintf (alpha_file, "%ld ", (long) *pix_ptr++);
- }
- } /* if alpha_present */
-
- if (!raw)
- if (col % 4 == 3)
- fprintf (pnm_file, "\n");
- } /* end for col */
-
- if (!raw)
- if (col % 4 != 0)
- fprintf (pnm_file, "\n");
- } /* end for row */
-
- if (row_pointers != (unsigned char**) NULL)
- free (row_pointers);
- if (png_pixels != (unsigned char*) NULL)
- free (png_pixels);
-
- return TRUE;
-
-} /* end of source */
-
diff --git a/navit/support/libpng/pngmem.c b/navit/support/libpng/pngmem.c
deleted file mode 100644
index f3394d780..000000000
--- a/navit/support/libpng/pngmem.c
+++ /dev/null
@@ -1,610 +0,0 @@
-
-/* pngmem.c - stub functions for memory allocation
- *
- * Last changed in libpng 1.2.30 [August 15, 2008]
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2008 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This file provides a location for all memory allocation. Users who
- * need special memory handling are expected to supply replacement
- * functions for png_malloc() and png_free(), and to use
- * png_create_read_struct_2() and png_create_write_struct_2() to
- * identify the replacement functions.
- */
-
-#define PNG_INTERNAL
-#include "png.h"
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-
-/* Borland DOS special memory handler */
-#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
-/* if you change this, be sure to change the one in png.h also */
-
-/* Allocate memory for a png_struct. The malloc and memset can be replaced
- by a single call to calloc() if this is thought to improve performance. */
-png_voidp /* PRIVATE */
-png_create_struct(int type)
-{
-#ifdef PNG_USER_MEM_SUPPORTED
- return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL));
-}
-
-/* Alternate version of png_create_struct, for use with user-defined malloc. */
-png_voidp /* PRIVATE */
-png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
-{
-#endif /* PNG_USER_MEM_SUPPORTED */
- png_size_t size;
- png_voidp struct_ptr;
-
- if (type == PNG_STRUCT_INFO)
- size = png_sizeof(png_info);
- else if (type == PNG_STRUCT_PNG)
- size = png_sizeof(png_struct);
- else
- return (png_get_copyright(NULL));
-
-#ifdef PNG_USER_MEM_SUPPORTED
- if (malloc_fn != NULL)
- {
- png_struct dummy_struct;
- png_structp png_ptr = &dummy_struct;
- png_ptr->mem_ptr=mem_ptr;
- struct_ptr = (*(malloc_fn))(png_ptr, (png_uint_32)size);
- }
- else
-#endif /* PNG_USER_MEM_SUPPORTED */
- struct_ptr = (png_voidp)farmalloc(size);
- if (struct_ptr != NULL)
- png_memset(struct_ptr, 0, size);
- return (struct_ptr);
-}
-
-/* Free memory allocated by a png_create_struct() call */
-void /* PRIVATE */
-png_destroy_struct(png_voidp struct_ptr)
-{
-#ifdef PNG_USER_MEM_SUPPORTED
- png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL);
-}
-
-/* Free memory allocated by a png_create_struct() call */
-void /* PRIVATE */
-png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
- png_voidp mem_ptr)
-{
-#endif
- if (struct_ptr != NULL)
- {
-#ifdef PNG_USER_MEM_SUPPORTED
- if (free_fn != NULL)
- {
- png_struct dummy_struct;
- png_structp png_ptr = &dummy_struct;
- png_ptr->mem_ptr=mem_ptr;
- (*(free_fn))(png_ptr, struct_ptr);
- return;
- }
-#endif /* PNG_USER_MEM_SUPPORTED */
- farfree (struct_ptr);
- }
-}
-
-/* Allocate memory. For reasonable files, size should never exceed
- * 64K. However, zlib may allocate more then 64K if you don't tell
- * it not to. See zconf.h and png.h for more information. zlib does
- * need to allocate exactly 64K, so whatever you call here must
- * have the ability to do that.
- *
- * Borland seems to have a problem in DOS mode for exactly 64K.
- * It gives you a segment with an offset of 8 (perhaps to store its
- * memory stuff). zlib doesn't like this at all, so we have to
- * detect and deal with it. This code should not be needed in
- * Windows or OS/2 modes, and only in 16 bit mode. This code has
- * been updated by Alexander Lehmann for version 0.89 to waste less
- * memory.
- *
- * Note that we can't use png_size_t for the "size" declaration,
- * since on some systems a png_size_t is a 16-bit quantity, and as a
- * result, we would be truncating potentially larger memory requests
- * (which should cause a fatal error) and introducing major problems.
- */
-
-png_voidp PNGAPI
-png_malloc(png_structp png_ptr, png_uint_32 size)
-{
- png_voidp ret;
-
- if (png_ptr == NULL || size == 0)
- return (NULL);
-
-#ifdef PNG_USER_MEM_SUPPORTED
- if (png_ptr->malloc_fn != NULL)
- ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
- else
- ret = (png_malloc_default(png_ptr, size));
- if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
- png_error(png_ptr, "Out of memory!");
- return (ret);
-}
-
-png_voidp PNGAPI
-png_malloc_default(png_structp png_ptr, png_uint_32 size)
-{
- png_voidp ret;
-#endif /* PNG_USER_MEM_SUPPORTED */
-
- if (png_ptr == NULL || size == 0)
- return (NULL);
-
-#ifdef PNG_MAX_MALLOC_64K
- if (size > (png_uint_32)65536L)
- {
- png_warning(png_ptr, "Cannot Allocate > 64K");
- ret = NULL;
- }
- else
-#endif
-
- if (size != (size_t)size)
- ret = NULL;
- else if (size == (png_uint_32)65536L)
- {
- if (png_ptr->offset_table == NULL)
- {
- /* try to see if we need to do any of this fancy stuff */
- ret = farmalloc(size);
- if (ret == NULL || ((png_size_t)ret & 0xffff))
- {
- int num_blocks;
- png_uint_32 total_size;
- png_bytep table;
- int i;
- png_byte huge * hptr;
-
- if (ret != NULL)
- {
- farfree(ret);
- ret = NULL;
- }
-
- if (png_ptr->zlib_window_bits > 14)
- num_blocks = (int)(1 << (png_ptr->zlib_window_bits - 14));
- else
- num_blocks = 1;
- if (png_ptr->zlib_mem_level >= 7)
- num_blocks += (int)(1 << (png_ptr->zlib_mem_level - 7));
- else
- num_blocks++;
-
- total_size = ((png_uint_32)65536L) * (png_uint_32)num_blocks+16;
-
- table = farmalloc(total_size);
-
- if (table == NULL)
- {
-#ifndef PNG_USER_MEM_SUPPORTED
- if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
- png_error(png_ptr, "Out Of Memory."); /* Note "O" and "M" */
- else
- png_warning(png_ptr, "Out Of Memory.");
-#endif
- return (NULL);
- }
-
- if ((png_size_t)table & 0xfff0)
- {
-#ifndef PNG_USER_MEM_SUPPORTED
- if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
- png_error(png_ptr,
- "Farmalloc didn't return normalized pointer");
- else
- png_warning(png_ptr,
- "Farmalloc didn't return normalized pointer");
-#endif
- return (NULL);
- }
-
- png_ptr->offset_table = table;
- png_ptr->offset_table_ptr = farmalloc(num_blocks *
- png_sizeof(png_bytep));
-
- if (png_ptr->offset_table_ptr == NULL)
- {
-#ifndef PNG_USER_MEM_SUPPORTED
- if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
- png_error(png_ptr, "Out Of memory."); /* Note "O" and "M" */
- else
- png_warning(png_ptr, "Out Of memory.");
-#endif
- return (NULL);
- }
-
- hptr = (png_byte huge *)table;
- if ((png_size_t)hptr & 0xf)
- {
- hptr = (png_byte huge *)((long)(hptr) & 0xfffffff0L);
- hptr = hptr + 16L; /* "hptr += 16L" fails on Turbo C++ 3.0 */
- }
- for (i = 0; i < num_blocks; i++)
- {
- png_ptr->offset_table_ptr[i] = (png_bytep)hptr;
- hptr = hptr + (png_uint_32)65536L; /* "+=" fails on TC++3.0 */
- }
-
- png_ptr->offset_table_number = num_blocks;
- png_ptr->offset_table_count = 0;
- png_ptr->offset_table_count_free = 0;
- }
- }
-
- if (png_ptr->offset_table_count >= png_ptr->offset_table_number)
- {
-#ifndef PNG_USER_MEM_SUPPORTED
- if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
- png_error(png_ptr, "Out of Memory."); /* Note "o" and "M" */
- else
- png_warning(png_ptr, "Out of Memory.");
-#endif
- return (NULL);
- }
-
- ret = png_ptr->offset_table_ptr[png_ptr->offset_table_count++];
- }
- else
- ret = farmalloc(size);
-
-#ifndef PNG_USER_MEM_SUPPORTED
- if (ret == NULL)
- {
- if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
- png_error(png_ptr, "Out of memory."); /* Note "o" and "m" */
- else
- png_warning(png_ptr, "Out of memory."); /* Note "o" and "m" */
- }
-#endif
-
- return (ret);
-}
-
-/* free a pointer allocated by png_malloc(). In the default
- configuration, png_ptr is not used, but is passed in case it
- is needed. If ptr is NULL, return without taking any action. */
-
-void PNGAPI
-png_free(png_structp png_ptr, png_voidp ptr)
-{
- if (png_ptr == NULL || ptr == NULL)
- return;
-
-#ifdef PNG_USER_MEM_SUPPORTED
- if (png_ptr->free_fn != NULL)
- {
- (*(png_ptr->free_fn))(png_ptr, ptr);
- return;
- }
- else png_free_default(png_ptr, ptr);
-}
-
-void PNGAPI
-png_free_default(png_structp png_ptr, png_voidp ptr)
-{
-#endif /* PNG_USER_MEM_SUPPORTED */
-
- if (png_ptr == NULL || ptr == NULL) return;
-
- if (png_ptr->offset_table != NULL)
- {
- int i;
-
- for (i = 0; i < png_ptr->offset_table_count; i++)
- {
- if (ptr == png_ptr->offset_table_ptr[i])
- {
- ptr = NULL;
- png_ptr->offset_table_count_free++;
- break;
- }
- }
- if (png_ptr->offset_table_count_free == png_ptr->offset_table_count)
- {
- farfree(png_ptr->offset_table);
- farfree(png_ptr->offset_table_ptr);
- png_ptr->offset_table = NULL;
- png_ptr->offset_table_ptr = NULL;
- }
- }
-
- if (ptr != NULL)
- {
- farfree(ptr);
- }
-}
-
-#else /* Not the Borland DOS special memory handler */
-
-/* Allocate memory for a png_struct or a png_info. The malloc and
- memset can be replaced by a single call to calloc() if this is thought
- to improve performance noticably. */
-png_voidp /* PRIVATE */
-png_create_struct(int type)
-{
-#ifdef PNG_USER_MEM_SUPPORTED
- return (png_create_struct_2(type, png_malloc_ptr_NULL, png_voidp_NULL));
-}
-
-/* Allocate memory for a png_struct or a png_info. The malloc and
- memset can be replaced by a single call to calloc() if this is thought
- to improve performance noticably. */
-png_voidp /* PRIVATE */
-png_create_struct_2(int type, png_malloc_ptr malloc_fn, png_voidp mem_ptr)
-{
-#endif /* PNG_USER_MEM_SUPPORTED */
- png_size_t size;
- png_voidp struct_ptr;
-
- if (type == PNG_STRUCT_INFO)
- size = png_sizeof(png_info);
- else if (type == PNG_STRUCT_PNG)
- size = png_sizeof(png_struct);
- else
- return (NULL);
-
-#ifdef PNG_USER_MEM_SUPPORTED
- if (malloc_fn != NULL)
- {
- png_struct dummy_struct;
- png_structp png_ptr = &dummy_struct;
- png_ptr->mem_ptr=mem_ptr;
- struct_ptr = (*(malloc_fn))(png_ptr, size);
- if (struct_ptr != NULL)
- png_memset(struct_ptr, 0, size);
- return (struct_ptr);
- }
-#endif /* PNG_USER_MEM_SUPPORTED */
-
-#if defined(__TURBOC__) && !defined(__FLAT__)
- struct_ptr = (png_voidp)farmalloc(size);
-#else
-# if defined(_MSC_VER) && defined(MAXSEG_64K)
- struct_ptr = (png_voidp)halloc(size, 1);
-# else
- struct_ptr = (png_voidp)malloc(size);
-# endif
-#endif
- if (struct_ptr != NULL)
- png_memset(struct_ptr, 0, size);
-
- return (struct_ptr);
-}
-
-
-/* Free memory allocated by a png_create_struct() call */
-void /* PRIVATE */
-png_destroy_struct(png_voidp struct_ptr)
-{
-#ifdef PNG_USER_MEM_SUPPORTED
- png_destroy_struct_2(struct_ptr, png_free_ptr_NULL, png_voidp_NULL);
-}
-
-/* Free memory allocated by a png_create_struct() call */
-void /* PRIVATE */
-png_destroy_struct_2(png_voidp struct_ptr, png_free_ptr free_fn,
- png_voidp mem_ptr)
-{
-#endif /* PNG_USER_MEM_SUPPORTED */
- if (struct_ptr != NULL)
- {
-#ifdef PNG_USER_MEM_SUPPORTED
- if (free_fn != NULL)
- {
- png_struct dummy_struct;
- png_structp png_ptr = &dummy_struct;
- png_ptr->mem_ptr=mem_ptr;
- (*(free_fn))(png_ptr, struct_ptr);
- return;
- }
-#endif /* PNG_USER_MEM_SUPPORTED */
-#if defined(__TURBOC__) && !defined(__FLAT__)
- farfree(struct_ptr);
-#else
-# if defined(_MSC_VER) && defined(MAXSEG_64K)
- hfree(struct_ptr);
-# else
- free(struct_ptr);
-# endif
-#endif
- }
-}
-
-/* Allocate memory. For reasonable files, size should never exceed
- 64K. However, zlib may allocate more then 64K if you don't tell
- it not to. See zconf.h and png.h for more information. zlib does
- need to allocate exactly 64K, so whatever you call here must
- have the ability to do that. */
-
-
-png_voidp PNGAPI
-png_malloc(png_structp png_ptr, png_uint_32 size)
-{
- png_voidp ret;
-
-#ifdef PNG_USER_MEM_SUPPORTED
- if (png_ptr == NULL || size == 0)
- return (NULL);
-
- if (png_ptr->malloc_fn != NULL)
- ret = ((png_voidp)(*(png_ptr->malloc_fn))(png_ptr, (png_size_t)size));
- else
- ret = (png_malloc_default(png_ptr, size));
- if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
- png_error(png_ptr, "Out of Memory!");
- return (ret);
-}
-
-png_voidp PNGAPI
-png_malloc_default(png_structp png_ptr, png_uint_32 size)
-{
- png_voidp ret;
-#endif /* PNG_USER_MEM_SUPPORTED */
-
- if (png_ptr == NULL || size == 0)
- return (NULL);
-
-#ifdef PNG_MAX_MALLOC_64K
- if (size > (png_uint_32)65536L)
- {
-#ifndef PNG_USER_MEM_SUPPORTED
- if ((png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
- png_error(png_ptr, "Cannot Allocate > 64K");
- else
-#endif
- return NULL;
- }
-#endif
-
- /* Check for overflow */
-#if defined(__TURBOC__) && !defined(__FLAT__)
- if (size != (unsigned long)size)
- ret = NULL;
- else
- ret = farmalloc(size);
-#else
-# if defined(_MSC_VER) && defined(MAXSEG_64K)
- if (size != (unsigned long)size)
- ret = NULL;
- else
- ret = halloc(size, 1);
-# else
- if (size != (size_t)size)
- ret = NULL;
- else
- ret = malloc((size_t)size);
-# endif
-#endif
-
-#ifndef PNG_USER_MEM_SUPPORTED
- if (ret == NULL && (png_ptr->flags&PNG_FLAG_MALLOC_NULL_MEM_OK) == 0)
- png_error(png_ptr, "Out of Memory");
-#endif
-
- return (ret);
-}
-
-/* Free a pointer allocated by png_malloc(). If ptr is NULL, return
- without taking any action. */
-void PNGAPI
-png_free(png_structp png_ptr, png_voidp ptr)
-{
- if (png_ptr == NULL || ptr == NULL)
- return;
-
-#ifdef PNG_USER_MEM_SUPPORTED
- if (png_ptr->free_fn != NULL)
- {
- (*(png_ptr->free_fn))(png_ptr, ptr);
- return;
- }
- else png_free_default(png_ptr, ptr);
-}
-void PNGAPI
-png_free_default(png_structp png_ptr, png_voidp ptr)
-{
- if (png_ptr == NULL || ptr == NULL)
- return;
-
-#endif /* PNG_USER_MEM_SUPPORTED */
-
-#if defined(__TURBOC__) && !defined(__FLAT__)
- farfree(ptr);
-#else
-# if defined(_MSC_VER) && defined(MAXSEG_64K)
- hfree(ptr);
-# else
- free(ptr);
-# endif
-#endif
-}
-
-#endif /* Not Borland DOS special memory handler */
-
-#if defined(PNG_1_0_X)
-# define png_malloc_warn png_malloc
-#else
-/* This function was added at libpng version 1.2.3. The png_malloc_warn()
- * function will set up png_malloc() to issue a png_warning and return NULL
- * instead of issuing a png_error, if it fails to allocate the requested
- * memory.
- */
-png_voidp PNGAPI
-png_malloc_warn(png_structp png_ptr, png_uint_32 size)
-{
- png_voidp ptr;
- png_uint_32 save_flags;
- if (png_ptr == NULL) return (NULL);
-
- save_flags = png_ptr->flags;
- png_ptr->flags|=PNG_FLAG_MALLOC_NULL_MEM_OK;
- ptr = (png_voidp)png_malloc((png_structp)png_ptr, size);
- png_ptr->flags=save_flags;
- return(ptr);
-}
-#endif
-
-png_voidp PNGAPI
-png_memcpy_check (png_structp png_ptr, png_voidp s1, png_voidp s2,
- png_uint_32 length)
-{
- png_size_t size;
-
- size = (png_size_t)length;
- if ((png_uint_32)size != length)
- png_error(png_ptr, "Overflow in png_memcpy_check.");
-
- return(png_memcpy (s1, s2, size));
-}
-
-png_voidp PNGAPI
-png_memset_check (png_structp png_ptr, png_voidp s1, int value,
- png_uint_32 length)
-{
- png_size_t size;
-
- size = (png_size_t)length;
- if ((png_uint_32)size != length)
- png_error(png_ptr, "Overflow in png_memset_check.");
-
- return (png_memset (s1, value, size));
-
-}
-
-#ifdef PNG_USER_MEM_SUPPORTED
-/* This function is called when the application wants to use another method
- * of allocating and freeing memory.
- */
-void PNGAPI
-png_set_mem_fn(png_structp png_ptr, png_voidp mem_ptr, png_malloc_ptr
- malloc_fn, png_free_ptr free_fn)
-{
- if (png_ptr != NULL)
- {
- png_ptr->mem_ptr = mem_ptr;
- png_ptr->malloc_fn = malloc_fn;
- png_ptr->free_fn = free_fn;
- }
-}
-
-/* This function returns a pointer to the mem_ptr associated with the user
- * functions. The application should free any memory associated with this
- * pointer before png_write_destroy and png_read_destroy are called.
- */
-png_voidp PNGAPI
-png_get_mem_ptr(png_structp png_ptr)
-{
- if (png_ptr == NULL) return (NULL);
- return ((png_voidp)png_ptr->mem_ptr);
-}
-#endif /* PNG_USER_MEM_SUPPORTED */
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
diff --git a/navit/support/libpng/pngread.c b/navit/support/libpng/pngread.c
deleted file mode 100644
index 8e9c0cb74..000000000
--- a/navit/support/libpng/pngread.c
+++ /dev/null
@@ -1,1459 +0,0 @@
-
-/* pngread.c - read a PNG file
- *
- * Last changed in libpng 1.2.35 [February 14, 2009]
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2009 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This file contains routines that an application calls directly to
- * read a PNG file or stream.
- */
-
-#define PNG_INTERNAL
-#include "png.h"
-#if defined(PNG_READ_SUPPORTED)
-
-/* Create a PNG structure for reading, and allocate any memory needed. */
-png_structp PNGAPI
-png_create_read_struct(png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn)
-{
-
-#ifdef PNG_USER_MEM_SUPPORTED
- return (png_create_read_struct_2(user_png_ver, error_ptr, error_fn,
- warn_fn, png_voidp_NULL, png_malloc_ptr_NULL, png_free_ptr_NULL));
-}
-
-/* Alternate create PNG structure for reading, and allocate any memory needed. */
-png_structp PNGAPI
-png_create_read_struct_2(png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn)
-{
-#endif /* PNG_USER_MEM_SUPPORTED */
-
-#ifdef PNG_SETJMP_SUPPORTED
- volatile
-#endif
- png_structp png_ptr;
-
-#ifdef PNG_SETJMP_SUPPORTED
-#ifdef USE_FAR_KEYWORD
- jmp_buf jmpbuf;
-#endif
-#endif
-
- int i;
-
- png_debug(1, "in png_create_read_struct");
-#ifdef PNG_USER_MEM_SUPPORTED
- png_ptr = (png_structp)png_create_struct_2(PNG_STRUCT_PNG,
- (png_malloc_ptr)malloc_fn, (png_voidp)mem_ptr);
-#else
- png_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
-#endif
- if (png_ptr == NULL)
- return (NULL);
-
- /* added at libpng-1.2.6 */
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
- png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
- png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
-#endif
-
-#ifdef PNG_SETJMP_SUPPORTED
-#ifdef USE_FAR_KEYWORD
- if (setjmp(jmpbuf))
-#else
- if (setjmp(png_ptr->jmpbuf))
-#endif
- {
- png_free(png_ptr, png_ptr->zbuf);
- png_ptr->zbuf = NULL;
-#ifdef PNG_USER_MEM_SUPPORTED
- png_destroy_struct_2((png_voidp)png_ptr,
- (png_free_ptr)free_fn, (png_voidp)mem_ptr);
-#else
- png_destroy_struct((png_voidp)png_ptr);
-#endif
- return (NULL);
- }
-#ifdef USE_FAR_KEYWORD
- png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
-#endif
-#endif
-
-#ifdef PNG_USER_MEM_SUPPORTED
- png_set_mem_fn(png_ptr, mem_ptr, malloc_fn, free_fn);
-#endif
-
- png_set_error_fn(png_ptr, error_ptr, error_fn, warn_fn);
-
- if (user_png_ver)
- {
- i = 0;
- do
- {
- if (user_png_ver[i] != png_libpng_ver[i])
- png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
- } while (png_libpng_ver[i++]);
- }
- else
- png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
-
-
- if (png_ptr->flags & PNG_FLAG_LIBRARY_MISMATCH)
- {
- /* Libpng 0.90 and later are binary incompatible with libpng 0.89, so
- * we must recompile any applications that use any older library version.
- * For versions after libpng 1.0, we will be compatible, so we need
- * only check the first digit.
- */
- if (user_png_ver == NULL || user_png_ver[0] != png_libpng_ver[0] ||
- (user_png_ver[0] == '1' && user_png_ver[2] != png_libpng_ver[2]) ||
- (user_png_ver[0] == '0' && user_png_ver[2] < '9'))
- {
-#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
- char msg[80];
- if (user_png_ver)
- {
- png_snprintf(msg, 80,
- "Application was compiled with png.h from libpng-%.20s",
- user_png_ver);
- png_warning(png_ptr, msg);
- }
- png_snprintf(msg, 80,
- "Application is running with png.c from libpng-%.20s",
- png_libpng_ver);
- png_warning(png_ptr, msg);
-#endif
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- png_ptr->flags = 0;
-#endif
- png_error(png_ptr,
- "Incompatible libpng version in application and library");
- }
- }
-
- /* initialize zbuf - compression buffer */
- png_ptr->zbuf_size = PNG_ZBUF_SIZE;
- png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)png_ptr->zbuf_size);
- png_ptr->zstream.zalloc = png_zalloc;
- png_ptr->zstream.zfree = png_zfree;
- png_ptr->zstream.opaque = (voidpf)png_ptr;
-
- switch (inflateInit(&png_ptr->zstream))
- {
- case Z_OK: /* Do nothing */ break;
- case Z_MEM_ERROR:
- case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory error"); break;
- case Z_VERSION_ERROR: png_error(png_ptr, "zlib version error"); break;
- default: png_error(png_ptr, "Unknown zlib error");
- }
-
- png_ptr->zstream.next_out = png_ptr->zbuf;
- png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
-
- png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL);
-
-#ifdef PNG_SETJMP_SUPPORTED
-/* Applications that neglect to set up their own setjmp() and then encounter
- a png_error() will longjmp here. Since the jmpbuf is then meaningless we
- abort instead of returning. */
-#ifdef USE_FAR_KEYWORD
- if (setjmp(jmpbuf))
- PNG_ABORT();
- png_memcpy(png_ptr->jmpbuf, jmpbuf, png_sizeof(jmp_buf));
-#else
- if (setjmp(png_ptr->jmpbuf))
- PNG_ABORT();
-#endif
-#endif
- return (png_ptr);
-}
-
-#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
-/* Initialize PNG structure for reading, and allocate any memory needed.
- This interface is deprecated in favour of the png_create_read_struct(),
- and it will disappear as of libpng-1.3.0. */
-#undef png_read_init
-void PNGAPI
-png_read_init(png_structp png_ptr)
-{
- /* We only come here via pre-1.0.7-compiled applications */
- png_read_init_2(png_ptr, "1.0.6 or earlier", 0, 0);
-}
-
-void PNGAPI
-png_read_init_2(png_structp png_ptr, png_const_charp user_png_ver,
- png_size_t png_struct_size, png_size_t png_info_size)
-{
- /* We only come here via pre-1.0.12-compiled applications */
- if (png_ptr == NULL) return;
-#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
- if (png_sizeof(png_struct) > png_struct_size ||
- png_sizeof(png_info) > png_info_size)
- {
- char msg[80];
- png_ptr->warning_fn = NULL;
- if (user_png_ver)
- {
- png_snprintf(msg, 80,
- "Application was compiled with png.h from libpng-%.20s",
- user_png_ver);
- png_warning(png_ptr, msg);
- }
- png_snprintf(msg, 80,
- "Application is running with png.c from libpng-%.20s",
- png_libpng_ver);
- png_warning(png_ptr, msg);
- }
-#endif
- if (png_sizeof(png_struct) > png_struct_size)
- {
- png_ptr->error_fn = NULL;
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- png_ptr->flags = 0;
-#endif
- png_error(png_ptr,
- "The png struct allocated by the application for reading is too small.");
- }
- if (png_sizeof(png_info) > png_info_size)
- {
- png_ptr->error_fn = NULL;
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- png_ptr->flags = 0;
-#endif
- png_error(png_ptr,
- "The info struct allocated by application for reading is too small.");
- }
- png_read_init_3(&png_ptr, user_png_ver, png_struct_size);
-}
-#endif /* PNG_1_0_X || PNG_1_2_X */
-
-void PNGAPI
-png_read_init_3(png_structpp ptr_ptr, png_const_charp user_png_ver,
- png_size_t png_struct_size)
-{
-#ifdef PNG_SETJMP_SUPPORTED
- jmp_buf tmp_jmp; /* to save current jump buffer */
-#endif
-
- int i = 0;
-
- png_structp png_ptr=*ptr_ptr;
-
- if (png_ptr == NULL) return;
-
- do
- {
- if (user_png_ver[i] != png_libpng_ver[i])
- {
-#ifdef PNG_LEGACY_SUPPORTED
- png_ptr->flags |= PNG_FLAG_LIBRARY_MISMATCH;
-#else
- png_ptr->warning_fn = NULL;
- png_warning(png_ptr,
- "Application uses deprecated png_read_init() and should be recompiled.");
- break;
-#endif
- }
- } while (png_libpng_ver[i++]);
-
- png_debug(1, "in png_read_init_3");
-
-#ifdef PNG_SETJMP_SUPPORTED
- /* save jump buffer and error functions */
- png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
-#endif
-
- if (png_sizeof(png_struct) > png_struct_size)
- {
- png_destroy_struct(png_ptr);
- *ptr_ptr = (png_structp)png_create_struct(PNG_STRUCT_PNG);
- png_ptr = *ptr_ptr;
- }
-
- /* reset all variables to 0 */
- png_memset(png_ptr, 0, png_sizeof(png_struct));
-
-#ifdef PNG_SETJMP_SUPPORTED
- /* restore jump buffer */
- png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
-#endif
-
- /* added at libpng-1.2.6 */
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
- png_ptr->user_width_max=PNG_USER_WIDTH_MAX;
- png_ptr->user_height_max=PNG_USER_HEIGHT_MAX;
-#endif
-
- /* initialize zbuf - compression buffer */
- png_ptr->zbuf_size = PNG_ZBUF_SIZE;
- png_ptr->zbuf = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)png_ptr->zbuf_size);
- png_ptr->zstream.zalloc = png_zalloc;
- png_ptr->zstream.zfree = png_zfree;
- png_ptr->zstream.opaque = (voidpf)png_ptr;
-
- switch (inflateInit(&png_ptr->zstream))
- {
- case Z_OK: /* Do nothing */ break;
- case Z_MEM_ERROR:
- case Z_STREAM_ERROR: png_error(png_ptr, "zlib memory"); break;
- case Z_VERSION_ERROR: png_error(png_ptr, "zlib version"); break;
- default: png_error(png_ptr, "Unknown zlib error");
- }
-
- png_ptr->zstream.next_out = png_ptr->zbuf;
- png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
-
- png_set_read_fn(png_ptr, png_voidp_NULL, png_rw_ptr_NULL);
-}
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-/* Read the information before the actual image data. This has been
- * changed in v0.90 to allow reading a file that already has the magic
- * bytes read from the stream. You can tell libpng how many bytes have
- * been read from the beginning of the stream (up to the maximum of 8)
- * via png_set_sig_bytes(), and we will only check the remaining bytes
- * here. The application can then have access to the signature bytes we
- * read if it is determined that this isn't a valid PNG file.
- */
-void PNGAPI
-png_read_info(png_structp png_ptr, png_infop info_ptr)
-{
- if (png_ptr == NULL || info_ptr == NULL) return;
- png_debug(1, "in png_read_info");
- /* If we haven't checked all of the PNG signature bytes, do so now. */
- if (png_ptr->sig_bytes < 8)
- {
- png_size_t num_checked = png_ptr->sig_bytes,
- num_to_check = 8 - num_checked;
-
- png_read_data(png_ptr, &(info_ptr->signature[num_checked]), num_to_check);
- png_ptr->sig_bytes = 8;
-
- if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
- {
- if (num_checked < 4 &&
- png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
- png_error(png_ptr, "Not a PNG file");
- else
- png_error(png_ptr, "PNG file corrupted by ASCII conversion");
- }
- if (num_checked < 3)
- png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
- }
-
- for (;;)
- {
-#ifdef PNG_USE_LOCAL_ARRAYS
- PNG_CONST PNG_IHDR;
- PNG_CONST PNG_IDAT;
- PNG_CONST PNG_IEND;
- PNG_CONST PNG_PLTE;
-#if defined(PNG_READ_bKGD_SUPPORTED)
- PNG_CONST PNG_bKGD;
-#endif
-#if defined(PNG_READ_cHRM_SUPPORTED)
- PNG_CONST PNG_cHRM;
-#endif
-#if defined(PNG_READ_gAMA_SUPPORTED)
- PNG_CONST PNG_gAMA;
-#endif
-#if defined(PNG_READ_hIST_SUPPORTED)
- PNG_CONST PNG_hIST;
-#endif
-#if defined(PNG_READ_iCCP_SUPPORTED)
- PNG_CONST PNG_iCCP;
-#endif
-#if defined(PNG_READ_iTXt_SUPPORTED)
- PNG_CONST PNG_iTXt;
-#endif
-#if defined(PNG_READ_oFFs_SUPPORTED)
- PNG_CONST PNG_oFFs;
-#endif
-#if defined(PNG_READ_pCAL_SUPPORTED)
- PNG_CONST PNG_pCAL;
-#endif
-#if defined(PNG_READ_pHYs_SUPPORTED)
- PNG_CONST PNG_pHYs;
-#endif
-#if defined(PNG_READ_sBIT_SUPPORTED)
- PNG_CONST PNG_sBIT;
-#endif
-#if defined(PNG_READ_sCAL_SUPPORTED)
- PNG_CONST PNG_sCAL;
-#endif
-#if defined(PNG_READ_sPLT_SUPPORTED)
- PNG_CONST PNG_sPLT;
-#endif
-#if defined(PNG_READ_sRGB_SUPPORTED)
- PNG_CONST PNG_sRGB;
-#endif
-#if defined(PNG_READ_tEXt_SUPPORTED)
- PNG_CONST PNG_tEXt;
-#endif
-#if defined(PNG_READ_tIME_SUPPORTED)
- PNG_CONST PNG_tIME;
-#endif
-#if defined(PNG_READ_tRNS_SUPPORTED)
- PNG_CONST PNG_tRNS;
-#endif
-#if defined(PNG_READ_zTXt_SUPPORTED)
- PNG_CONST PNG_zTXt;
-#endif
-#endif /* PNG_USE_LOCAL_ARRAYS */
- png_uint_32 length = png_read_chunk_header(png_ptr);
- PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
-
- /* This should be a binary subdivision search or a hash for
- * matching the chunk name rather than a linear search.
- */
- if (!png_memcmp(chunk_name, png_IDAT, 4))
- if (png_ptr->mode & PNG_AFTER_IDAT)
- png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
-
- if (!png_memcmp(chunk_name, png_IHDR, 4))
- png_handle_IHDR(png_ptr, info_ptr, length);
- else if (!png_memcmp(chunk_name, png_IEND, 4))
- png_handle_IEND(png_ptr, info_ptr, length);
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- else if (png_handle_as_unknown(png_ptr, chunk_name))
- {
- if (!png_memcmp(chunk_name, png_IDAT, 4))
- png_ptr->mode |= PNG_HAVE_IDAT;
- png_handle_unknown(png_ptr, info_ptr, length);
- if (!png_memcmp(chunk_name, png_PLTE, 4))
- png_ptr->mode |= PNG_HAVE_PLTE;
- else if (!png_memcmp(chunk_name, png_IDAT, 4))
- {
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before IDAT");
- else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- !(png_ptr->mode & PNG_HAVE_PLTE))
- png_error(png_ptr, "Missing PLTE before IDAT");
- break;
- }
- }
-#endif
- else if (!png_memcmp(chunk_name, png_PLTE, 4))
- png_handle_PLTE(png_ptr, info_ptr, length);
- else if (!png_memcmp(chunk_name, png_IDAT, 4))
- {
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before IDAT");
- else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- !(png_ptr->mode & PNG_HAVE_PLTE))
- png_error(png_ptr, "Missing PLTE before IDAT");
-
- png_ptr->idat_size = length;
- png_ptr->mode |= PNG_HAVE_IDAT;
- break;
- }
-#if defined(PNG_READ_bKGD_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_bKGD, 4))
- png_handle_bKGD(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_cHRM_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_cHRM, 4))
- png_handle_cHRM(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_gAMA_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_gAMA, 4))
- png_handle_gAMA(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_hIST_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_hIST, 4))
- png_handle_hIST(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_oFFs_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_oFFs, 4))
- png_handle_oFFs(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_pCAL_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_pCAL, 4))
- png_handle_pCAL(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_sCAL_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_sCAL, 4))
- png_handle_sCAL(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_pHYs_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_pHYs, 4))
- png_handle_pHYs(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_sBIT_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_sBIT, 4))
- png_handle_sBIT(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_sRGB_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_sRGB, 4))
- png_handle_sRGB(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_iCCP_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_iCCP, 4))
- png_handle_iCCP(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_sPLT_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_sPLT, 4))
- png_handle_sPLT(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_tEXt_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_tEXt, 4))
- png_handle_tEXt(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_tIME_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_tIME, 4))
- png_handle_tIME(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_tRNS_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_tRNS, 4))
- png_handle_tRNS(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_zTXt_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_zTXt, 4))
- png_handle_zTXt(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_iTXt_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_iTXt, 4))
- png_handle_iTXt(png_ptr, info_ptr, length);
-#endif
- else
- png_handle_unknown(png_ptr, info_ptr, length);
- }
-}
-#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
-
-/* optional call to update the users info_ptr structure */
-void PNGAPI
-png_read_update_info(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_read_update_info");
- if (png_ptr == NULL) return;
- if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
- png_read_start_row(png_ptr);
- else
- png_warning(png_ptr,
- "Ignoring extra png_read_update_info() call; row buffer not reallocated");
- png_read_transform_info(png_ptr, info_ptr);
-}
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-/* Initialize palette, background, etc, after transformations
- * are set, but before any reading takes place. This allows
- * the user to obtain a gamma-corrected palette, for example.
- * If the user doesn't call this, we will do it ourselves.
- */
-void PNGAPI
-png_start_read_image(png_structp png_ptr)
-{
- png_debug(1, "in png_start_read_image");
- if (png_ptr == NULL) return;
- if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
- png_read_start_row(png_ptr);
-}
-#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-void PNGAPI
-png_read_row(png_structp png_ptr, png_bytep row, png_bytep dsp_row)
-{
-#ifdef PNG_USE_LOCAL_ARRAYS
- PNG_CONST PNG_IDAT;
- PNG_CONST int png_pass_dsp_mask[7] = {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55,
- 0xff};
- PNG_CONST int png_pass_mask[7] = {0x80, 0x08, 0x88, 0x22, 0xaa, 0x55, 0xff};
-#endif
- int ret;
- if (png_ptr == NULL) return;
- png_debug2(1, "in png_read_row (row %lu, pass %d)",
- png_ptr->row_number, png_ptr->pass);
- if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
- png_read_start_row(png_ptr);
- if (png_ptr->row_number == 0 && png_ptr->pass == 0)
- {
- /* check for transforms that have been set but were defined out */
-#if defined(PNG_WRITE_INVERT_SUPPORTED) && !defined(PNG_READ_INVERT_SUPPORTED)
- if (png_ptr->transformations & PNG_INVERT_MONO)
- png_warning(png_ptr, "PNG_READ_INVERT_SUPPORTED is not defined.");
-#endif
-#if defined(PNG_WRITE_FILLER_SUPPORTED) && !defined(PNG_READ_FILLER_SUPPORTED)
- if (png_ptr->transformations & PNG_FILLER)
- png_warning(png_ptr, "PNG_READ_FILLER_SUPPORTED is not defined.");
-#endif
-#if defined(PNG_WRITE_PACKSWAP_SUPPORTED) && !defined(PNG_READ_PACKSWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_PACKSWAP)
- png_warning(png_ptr, "PNG_READ_PACKSWAP_SUPPORTED is not defined.");
-#endif
-#if defined(PNG_WRITE_PACK_SUPPORTED) && !defined(PNG_READ_PACK_SUPPORTED)
- if (png_ptr->transformations & PNG_PACK)
- png_warning(png_ptr, "PNG_READ_PACK_SUPPORTED is not defined.");
-#endif
-#if defined(PNG_WRITE_SHIFT_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED)
- if (png_ptr->transformations & PNG_SHIFT)
- png_warning(png_ptr, "PNG_READ_SHIFT_SUPPORTED is not defined.");
-#endif
-#if defined(PNG_WRITE_BGR_SUPPORTED) && !defined(PNG_READ_BGR_SUPPORTED)
- if (png_ptr->transformations & PNG_BGR)
- png_warning(png_ptr, "PNG_READ_BGR_SUPPORTED is not defined.");
-#endif
-#if defined(PNG_WRITE_SWAP_SUPPORTED) && !defined(PNG_READ_SWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_SWAP_BYTES)
- png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined.");
-#endif
- }
-
-#if defined(PNG_READ_INTERLACING_SUPPORTED)
- /* if interlaced and we do not need a new row, combine row and return */
- if (png_ptr->interlaced && (png_ptr->transformations & PNG_INTERLACE))
- {
- switch (png_ptr->pass)
- {
- case 0:
- if (png_ptr->row_number & 0x07)
- {
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row,
- png_pass_dsp_mask[png_ptr->pass]);
- png_read_finish_row(png_ptr);
- return;
- }
- break;
- case 1:
- if ((png_ptr->row_number & 0x07) || png_ptr->width < 5)
- {
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row,
- png_pass_dsp_mask[png_ptr->pass]);
- png_read_finish_row(png_ptr);
- return;
- }
- break;
- case 2:
- if ((png_ptr->row_number & 0x07) != 4)
- {
- if (dsp_row != NULL && (png_ptr->row_number & 4))
- png_combine_row(png_ptr, dsp_row,
- png_pass_dsp_mask[png_ptr->pass]);
- png_read_finish_row(png_ptr);
- return;
- }
- break;
- case 3:
- if ((png_ptr->row_number & 3) || png_ptr->width < 3)
- {
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row,
- png_pass_dsp_mask[png_ptr->pass]);
- png_read_finish_row(png_ptr);
- return;
- }
- break;
- case 4:
- if ((png_ptr->row_number & 3) != 2)
- {
- if (dsp_row != NULL && (png_ptr->row_number & 2))
- png_combine_row(png_ptr, dsp_row,
- png_pass_dsp_mask[png_ptr->pass]);
- png_read_finish_row(png_ptr);
- return;
- }
- break;
- case 5:
- if ((png_ptr->row_number & 1) || png_ptr->width < 2)
- {
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row,
- png_pass_dsp_mask[png_ptr->pass]);
- png_read_finish_row(png_ptr);
- return;
- }
- break;
- case 6:
- if (!(png_ptr->row_number & 1))
- {
- png_read_finish_row(png_ptr);
- return;
- }
- break;
- }
- }
-#endif
-
- if (!(png_ptr->mode & PNG_HAVE_IDAT))
- png_error(png_ptr, "Invalid attempt to read row data");
-
- png_ptr->zstream.next_out = png_ptr->row_buf;
- png_ptr->zstream.avail_out = (uInt)png_ptr->irowbytes;
- do
- {
- if (!(png_ptr->zstream.avail_in))
- {
- while (!png_ptr->idat_size)
- {
- png_crc_finish(png_ptr, 0);
-
- png_ptr->idat_size = png_read_chunk_header(png_ptr);
- if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
- png_error(png_ptr, "Not enough image data");
- }
- png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
- png_ptr->zstream.next_in = png_ptr->zbuf;
- if (png_ptr->zbuf_size > png_ptr->idat_size)
- png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size;
- png_crc_read(png_ptr, png_ptr->zbuf,
- (png_size_t)png_ptr->zstream.avail_in);
- png_ptr->idat_size -= png_ptr->zstream.avail_in;
- }
- ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
- if (ret == Z_STREAM_END)
- {
- if (png_ptr->zstream.avail_out || png_ptr->zstream.avail_in ||
- png_ptr->idat_size)
- png_error(png_ptr, "Extra compressed data");
- png_ptr->mode |= PNG_AFTER_IDAT;
- png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
- break;
- }
- if (ret != Z_OK)
- png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :
- "Decompression error");
-
- } while (png_ptr->zstream.avail_out);
-
- png_ptr->row_info.color_type = png_ptr->color_type;
- png_ptr->row_info.width = png_ptr->iwidth;
- png_ptr->row_info.channels = png_ptr->channels;
- png_ptr->row_info.bit_depth = png_ptr->bit_depth;
- png_ptr->row_info.pixel_depth = png_ptr->pixel_depth;
- png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
- png_ptr->row_info.width);
-
- if (png_ptr->row_buf[0])
- png_read_filter_row(png_ptr, &(png_ptr->row_info),
- png_ptr->row_buf + 1, png_ptr->prev_row + 1,
- (int)(png_ptr->row_buf[0]));
-
- png_memcpy_check(png_ptr, png_ptr->prev_row, png_ptr->row_buf,
- png_ptr->rowbytes + 1);
-
-#if defined(PNG_MNG_FEATURES_SUPPORTED)
- if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
- (png_ptr->filter_type == PNG_INTRAPIXEL_DIFFERENCING))
- {
- /* Intrapixel differencing */
- png_do_read_intrapixel(&(png_ptr->row_info), png_ptr->row_buf + 1);
- }
-#endif
-
-
- if (png_ptr->transformations || (png_ptr->flags&PNG_FLAG_STRIP_ALPHA))
- png_do_read_transformations(png_ptr);
-
-#if defined(PNG_READ_INTERLACING_SUPPORTED)
- /* blow up interlaced rows to full size */
- if (png_ptr->interlaced &&
- (png_ptr->transformations & PNG_INTERLACE))
- {
- if (png_ptr->pass < 6)
-/* old interface (pre-1.0.9):
- png_do_read_interlace(&(png_ptr->row_info),
- png_ptr->row_buf + 1, png_ptr->pass, png_ptr->transformations);
- */
- png_do_read_interlace(png_ptr);
-
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row,
- png_pass_dsp_mask[png_ptr->pass]);
- if (row != NULL)
- png_combine_row(png_ptr, row,
- png_pass_mask[png_ptr->pass]);
- }
- else
-#endif
- {
- if (row != NULL)
- png_combine_row(png_ptr, row, 0xff);
- if (dsp_row != NULL)
- png_combine_row(png_ptr, dsp_row, 0xff);
- }
- png_read_finish_row(png_ptr);
-
- if (png_ptr->read_row_fn != NULL)
- (*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
-}
-#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-/* Read one or more rows of image data. If the image is interlaced,
- * and png_set_interlace_handling() has been called, the rows need to
- * contain the contents of the rows from the previous pass. If the
- * image has alpha or transparency, and png_handle_alpha()[*] has been
- * called, the rows contents must be initialized to the contents of the
- * screen.
- *
- * "row" holds the actual image, and pixels are placed in it
- * as they arrive. If the image is displayed after each pass, it will
- * appear to "sparkle" in. "display_row" can be used to display a
- * "chunky" progressive image, with finer detail added as it becomes
- * available. If you do not want this "chunky" display, you may pass
- * NULL for display_row. If you do not want the sparkle display, and
- * you have not called png_handle_alpha(), you may pass NULL for rows.
- * If you have called png_handle_alpha(), and the image has either an
- * alpha channel or a transparency chunk, you must provide a buffer for
- * rows. In this case, you do not have to provide a display_row buffer
- * also, but you may. If the image is not interlaced, or if you have
- * not called png_set_interlace_handling(), the display_row buffer will
- * be ignored, so pass NULL to it.
- *
- * [*] png_handle_alpha() does not exist yet, as of this version of libpng
- */
-
-void PNGAPI
-png_read_rows(png_structp png_ptr, png_bytepp row,
- png_bytepp display_row, png_uint_32 num_rows)
-{
- png_uint_32 i;
- png_bytepp rp;
- png_bytepp dp;
-
- png_debug(1, "in png_read_rows");
- if (png_ptr == NULL) return;
- rp = row;
- dp = display_row;
- if (rp != NULL && dp != NULL)
- for (i = 0; i < num_rows; i++)
- {
- png_bytep rptr = *rp++;
- png_bytep dptr = *dp++;
-
- png_read_row(png_ptr, rptr, dptr);
- }
- else if (rp != NULL)
- for (i = 0; i < num_rows; i++)
- {
- png_bytep rptr = *rp;
- png_read_row(png_ptr, rptr, png_bytep_NULL);
- rp++;
- }
- else if (dp != NULL)
- for (i = 0; i < num_rows; i++)
- {
- png_bytep dptr = *dp;
- png_read_row(png_ptr, png_bytep_NULL, dptr);
- dp++;
- }
-}
-#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-/* Read the entire image. If the image has an alpha channel or a tRNS
- * chunk, and you have called png_handle_alpha()[*], you will need to
- * initialize the image to the current image that PNG will be overlaying.
- * We set the num_rows again here, in case it was incorrectly set in
- * png_read_start_row() by a call to png_read_update_info() or
- * png_start_read_image() if png_set_interlace_handling() wasn't called
- * prior to either of these functions like it should have been. You can
- * only call this function once. If you desire to have an image for
- * each pass of a interlaced image, use png_read_rows() instead.
- *
- * [*] png_handle_alpha() does not exist yet, as of this version of libpng
- */
-void PNGAPI
-png_read_image(png_structp png_ptr, png_bytepp image)
-{
- png_uint_32 i, image_height;
- int pass, j;
- png_bytepp rp;
-
- png_debug(1, "in png_read_image");
- if (png_ptr == NULL) return;
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- pass = png_set_interlace_handling(png_ptr);
-#else
- if (png_ptr->interlaced)
- png_error(png_ptr,
- "Cannot read interlaced image -- interlace handler disabled.");
- pass = 1;
-#endif
-
-
- image_height=png_ptr->height;
- png_ptr->num_rows = image_height; /* Make sure this is set correctly */
-
- for (j = 0; j < pass; j++)
- {
- rp = image;
- for (i = 0; i < image_height; i++)
- {
- png_read_row(png_ptr, *rp, png_bytep_NULL);
- rp++;
- }
- }
-}
-#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-/* Read the end of the PNG file. Will not read past the end of the
- * file, will verify the end is accurate, and will read any comments
- * or time information at the end of the file, if info is not NULL.
- */
-void PNGAPI
-png_read_end(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_read_end");
- if (png_ptr == NULL) return;
- png_crc_finish(png_ptr, 0); /* Finish off CRC from last IDAT chunk */
-
- do
- {
-#ifdef PNG_USE_LOCAL_ARRAYS
- PNG_CONST PNG_IHDR;
- PNG_CONST PNG_IDAT;
- PNG_CONST PNG_IEND;
- PNG_CONST PNG_PLTE;
-#if defined(PNG_READ_bKGD_SUPPORTED)
- PNG_CONST PNG_bKGD;
-#endif
-#if defined(PNG_READ_cHRM_SUPPORTED)
- PNG_CONST PNG_cHRM;
-#endif
-#if defined(PNG_READ_gAMA_SUPPORTED)
- PNG_CONST PNG_gAMA;
-#endif
-#if defined(PNG_READ_hIST_SUPPORTED)
- PNG_CONST PNG_hIST;
-#endif
-#if defined(PNG_READ_iCCP_SUPPORTED)
- PNG_CONST PNG_iCCP;
-#endif
-#if defined(PNG_READ_iTXt_SUPPORTED)
- PNG_CONST PNG_iTXt;
-#endif
-#if defined(PNG_READ_oFFs_SUPPORTED)
- PNG_CONST PNG_oFFs;
-#endif
-#if defined(PNG_READ_pCAL_SUPPORTED)
- PNG_CONST PNG_pCAL;
-#endif
-#if defined(PNG_READ_pHYs_SUPPORTED)
- PNG_CONST PNG_pHYs;
-#endif
-#if defined(PNG_READ_sBIT_SUPPORTED)
- PNG_CONST PNG_sBIT;
-#endif
-#if defined(PNG_READ_sCAL_SUPPORTED)
- PNG_CONST PNG_sCAL;
-#endif
-#if defined(PNG_READ_sPLT_SUPPORTED)
- PNG_CONST PNG_sPLT;
-#endif
-#if defined(PNG_READ_sRGB_SUPPORTED)
- PNG_CONST PNG_sRGB;
-#endif
-#if defined(PNG_READ_tEXt_SUPPORTED)
- PNG_CONST PNG_tEXt;
-#endif
-#if defined(PNG_READ_tIME_SUPPORTED)
- PNG_CONST PNG_tIME;
-#endif
-#if defined(PNG_READ_tRNS_SUPPORTED)
- PNG_CONST PNG_tRNS;
-#endif
-#if defined(PNG_READ_zTXt_SUPPORTED)
- PNG_CONST PNG_zTXt;
-#endif
-#endif /* PNG_USE_LOCAL_ARRAYS */
- png_uint_32 length = png_read_chunk_header(png_ptr);
- PNG_CONST png_bytep chunk_name = png_ptr->chunk_name;
-
- if (!png_memcmp(chunk_name, png_IHDR, 4))
- png_handle_IHDR(png_ptr, info_ptr, length);
- else if (!png_memcmp(chunk_name, png_IEND, 4))
- png_handle_IEND(png_ptr, info_ptr, length);
-#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
- else if (png_handle_as_unknown(png_ptr, chunk_name))
- {
- if (!png_memcmp(chunk_name, png_IDAT, 4))
- {
- if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
- png_error(png_ptr, "Too many IDAT's found");
- }
- png_handle_unknown(png_ptr, info_ptr, length);
- if (!png_memcmp(chunk_name, png_PLTE, 4))
- png_ptr->mode |= PNG_HAVE_PLTE;
- }
-#endif
- else if (!png_memcmp(chunk_name, png_IDAT, 4))
- {
- /* Zero length IDATs are legal after the last IDAT has been
- * read, but not after other chunks have been read.
- */
- if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT))
- png_error(png_ptr, "Too many IDAT's found");
- png_crc_finish(png_ptr, length);
- }
- else if (!png_memcmp(chunk_name, png_PLTE, 4))
- png_handle_PLTE(png_ptr, info_ptr, length);
-#if defined(PNG_READ_bKGD_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_bKGD, 4))
- png_handle_bKGD(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_cHRM_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_cHRM, 4))
- png_handle_cHRM(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_gAMA_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_gAMA, 4))
- png_handle_gAMA(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_hIST_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_hIST, 4))
- png_handle_hIST(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_oFFs_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_oFFs, 4))
- png_handle_oFFs(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_pCAL_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_pCAL, 4))
- png_handle_pCAL(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_sCAL_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_sCAL, 4))
- png_handle_sCAL(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_pHYs_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_pHYs, 4))
- png_handle_pHYs(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_sBIT_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_sBIT, 4))
- png_handle_sBIT(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_sRGB_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_sRGB, 4))
- png_handle_sRGB(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_iCCP_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_iCCP, 4))
- png_handle_iCCP(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_sPLT_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_sPLT, 4))
- png_handle_sPLT(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_tEXt_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_tEXt, 4))
- png_handle_tEXt(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_tIME_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_tIME, 4))
- png_handle_tIME(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_tRNS_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_tRNS, 4))
- png_handle_tRNS(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_zTXt_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_zTXt, 4))
- png_handle_zTXt(png_ptr, info_ptr, length);
-#endif
-#if defined(PNG_READ_iTXt_SUPPORTED)
- else if (!png_memcmp(chunk_name, png_iTXt, 4))
- png_handle_iTXt(png_ptr, info_ptr, length);
-#endif
- else
- png_handle_unknown(png_ptr, info_ptr, length);
- } while (!(png_ptr->mode & PNG_HAVE_IEND));
-}
-#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
-
-/* free all memory used by the read */
-void PNGAPI
-png_destroy_read_struct(png_structpp png_ptr_ptr, png_infopp info_ptr_ptr,
- png_infopp end_info_ptr_ptr)
-{
- png_structp png_ptr = NULL;
- png_infop info_ptr = NULL, end_info_ptr = NULL;
-#ifdef PNG_USER_MEM_SUPPORTED
- png_free_ptr free_fn = NULL;
- png_voidp mem_ptr = NULL;
-#endif
-
- png_debug(1, "in png_destroy_read_struct");
- if (png_ptr_ptr != NULL)
- png_ptr = *png_ptr_ptr;
- if (png_ptr == NULL)
- return;
-
-#ifdef PNG_USER_MEM_SUPPORTED
- free_fn = png_ptr->free_fn;
- mem_ptr = png_ptr->mem_ptr;
-#endif
-
- if (info_ptr_ptr != NULL)
- info_ptr = *info_ptr_ptr;
-
- if (end_info_ptr_ptr != NULL)
- end_info_ptr = *end_info_ptr_ptr;
-
- png_read_destroy(png_ptr, info_ptr, end_info_ptr);
-
- if (info_ptr != NULL)
- {
-#if defined(PNG_TEXT_SUPPORTED)
- png_free_data(png_ptr, info_ptr, PNG_FREE_TEXT, -1);
-#endif
-
-#ifdef PNG_USER_MEM_SUPPORTED
- png_destroy_struct_2((png_voidp)info_ptr, (png_free_ptr)free_fn,
- (png_voidp)mem_ptr);
-#else
- png_destroy_struct((png_voidp)info_ptr);
-#endif
- *info_ptr_ptr = NULL;
- }
-
- if (end_info_ptr != NULL)
- {
-#if defined(PNG_READ_TEXT_SUPPORTED)
- png_free_data(png_ptr, end_info_ptr, PNG_FREE_TEXT, -1);
-#endif
-#ifdef PNG_USER_MEM_SUPPORTED
- png_destroy_struct_2((png_voidp)end_info_ptr, (png_free_ptr)free_fn,
- (png_voidp)mem_ptr);
-#else
- png_destroy_struct((png_voidp)end_info_ptr);
-#endif
- *end_info_ptr_ptr = NULL;
- }
-
- if (png_ptr != NULL)
- {
-#ifdef PNG_USER_MEM_SUPPORTED
- png_destroy_struct_2((png_voidp)png_ptr, (png_free_ptr)free_fn,
- (png_voidp)mem_ptr);
-#else
- png_destroy_struct((png_voidp)png_ptr);
-#endif
- *png_ptr_ptr = NULL;
- }
-}
-
-/* free all memory used by the read (old method) */
-void /* PRIVATE */
-png_read_destroy(png_structp png_ptr, png_infop info_ptr, png_infop end_info_ptr)
-{
-#ifdef PNG_SETJMP_SUPPORTED
- jmp_buf tmp_jmp;
-#endif
- png_error_ptr error_fn;
- png_error_ptr warning_fn;
- png_voidp error_ptr;
-#ifdef PNG_USER_MEM_SUPPORTED
- png_free_ptr free_fn;
-#endif
-
- png_debug(1, "in png_read_destroy");
- if (info_ptr != NULL)
- png_info_destroy(png_ptr, info_ptr);
-
- if (end_info_ptr != NULL)
- png_info_destroy(png_ptr, end_info_ptr);
-
- png_free(png_ptr, png_ptr->zbuf);
- png_free(png_ptr, png_ptr->big_row_buf);
- png_free(png_ptr, png_ptr->prev_row);
- png_free(png_ptr, png_ptr->chunkdata);
-#if defined(PNG_READ_DITHER_SUPPORTED)
- png_free(png_ptr, png_ptr->palette_lookup);
- png_free(png_ptr, png_ptr->dither_index);
-#endif
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- png_free(png_ptr, png_ptr->gamma_table);
-#endif
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
- png_free(png_ptr, png_ptr->gamma_from_1);
- png_free(png_ptr, png_ptr->gamma_to_1);
-#endif
-#ifdef PNG_FREE_ME_SUPPORTED
- if (png_ptr->free_me & PNG_FREE_PLTE)
- png_zfree(png_ptr, png_ptr->palette);
- png_ptr->free_me &= ~PNG_FREE_PLTE;
-#else
- if (png_ptr->flags & PNG_FLAG_FREE_PLTE)
- png_zfree(png_ptr, png_ptr->palette);
- png_ptr->flags &= ~PNG_FLAG_FREE_PLTE;
-#endif
-#if defined(PNG_tRNS_SUPPORTED) || \
- defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
-#ifdef PNG_FREE_ME_SUPPORTED
- if (png_ptr->free_me & PNG_FREE_TRNS)
- png_free(png_ptr, png_ptr->trans);
- png_ptr->free_me &= ~PNG_FREE_TRNS;
-#else
- if (png_ptr->flags & PNG_FLAG_FREE_TRNS)
- png_free(png_ptr, png_ptr->trans);
- png_ptr->flags &= ~PNG_FLAG_FREE_TRNS;
-#endif
-#endif
-#if defined(PNG_READ_hIST_SUPPORTED)
-#ifdef PNG_FREE_ME_SUPPORTED
- if (png_ptr->free_me & PNG_FREE_HIST)
- png_free(png_ptr, png_ptr->hist);
- png_ptr->free_me &= ~PNG_FREE_HIST;
-#else
- if (png_ptr->flags & PNG_FLAG_FREE_HIST)
- png_free(png_ptr, png_ptr->hist);
- png_ptr->flags &= ~PNG_FLAG_FREE_HIST;
-#endif
-#endif
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (png_ptr->gamma_16_table != NULL)
- {
- int i;
- int istop = (1 << (8 - png_ptr->gamma_shift));
- for (i = 0; i < istop; i++)
- {
- png_free(png_ptr, png_ptr->gamma_16_table[i]);
- }
- png_free(png_ptr, png_ptr->gamma_16_table);
- }
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
- if (png_ptr->gamma_16_from_1 != NULL)
- {
- int i;
- int istop = (1 << (8 - png_ptr->gamma_shift));
- for (i = 0; i < istop; i++)
- {
- png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
- }
- png_free(png_ptr, png_ptr->gamma_16_from_1);
- }
- if (png_ptr->gamma_16_to_1 != NULL)
- {
- int i;
- int istop = (1 << (8 - png_ptr->gamma_shift));
- for (i = 0; i < istop; i++)
- {
- png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
- }
- png_free(png_ptr, png_ptr->gamma_16_to_1);
- }
-#endif
-#endif
-#if defined(PNG_TIME_RFC1123_SUPPORTED)
- png_free(png_ptr, png_ptr->time_buffer);
-#endif
-
- inflateEnd(&png_ptr->zstream);
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
- png_free(png_ptr, png_ptr->save_buffer);
-#endif
-
-#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-#ifdef PNG_TEXT_SUPPORTED
- png_free(png_ptr, png_ptr->current_text);
-#endif /* PNG_TEXT_SUPPORTED */
-#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
-
- /* Save the important info out of the png_struct, in case it is
- * being used again.
- */
-#ifdef PNG_SETJMP_SUPPORTED
- png_memcpy(tmp_jmp, png_ptr->jmpbuf, png_sizeof(jmp_buf));
-#endif
-
- error_fn = png_ptr->error_fn;
- warning_fn = png_ptr->warning_fn;
- error_ptr = png_ptr->error_ptr;
-#ifdef PNG_USER_MEM_SUPPORTED
- free_fn = png_ptr->free_fn;
-#endif
-
- png_memset(png_ptr, 0, png_sizeof(png_struct));
-
- png_ptr->error_fn = error_fn;
- png_ptr->warning_fn = warning_fn;
- png_ptr->error_ptr = error_ptr;
-#ifdef PNG_USER_MEM_SUPPORTED
- png_ptr->free_fn = free_fn;
-#endif
-
-#ifdef PNG_SETJMP_SUPPORTED
- png_memcpy(png_ptr->jmpbuf, tmp_jmp, png_sizeof(jmp_buf));
-#endif
-
-}
-
-void PNGAPI
-png_set_read_status_fn(png_structp png_ptr, png_read_status_ptr read_row_fn)
-{
- if (png_ptr == NULL) return;
- png_ptr->read_row_fn = read_row_fn;
-}
-
-
-#ifndef PNG_NO_SEQUENTIAL_READ_SUPPORTED
-#if defined(PNG_INFO_IMAGE_SUPPORTED)
-void PNGAPI
-png_read_png(png_structp png_ptr, png_infop info_ptr,
- int transforms,
- voidp params)
-{
- int row;
-
- if (png_ptr == NULL) return;
-#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
- /* invert the alpha channel from opacity to transparency
- */
- if (transforms & PNG_TRANSFORM_INVERT_ALPHA)
- png_set_invert_alpha(png_ptr);
-#endif
-
- /* png_read_info() gives us all of the information from the
- * PNG file before the first IDAT (image data chunk).
- */
- png_read_info(png_ptr, info_ptr);
- if (info_ptr->height > PNG_UINT_32_MAX/png_sizeof(png_bytep))
- png_error(png_ptr, "Image is too high to process with png_read_png()");
-
- /* -------------- image transformations start here ------------------- */
-
-#if defined(PNG_READ_16_TO_8_SUPPORTED)
- /* tell libpng to strip 16 bit/color files down to 8 bits per color
- */
- if (transforms & PNG_TRANSFORM_STRIP_16)
- png_set_strip_16(png_ptr);
-#endif
-
-#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
- /* Strip alpha bytes from the input data without combining with
- * the background (not recommended).
- */
- if (transforms & PNG_TRANSFORM_STRIP_ALPHA)
- png_set_strip_alpha(png_ptr);
-#endif
-
-#if defined(PNG_READ_PACK_SUPPORTED) && !defined(PNG_READ_EXPAND_SUPPORTED)
- /* Extract multiple pixels with bit depths of 1, 2, or 4 from a single
- * byte into separate bytes (useful for paletted and grayscale images).
- */
- if (transforms & PNG_TRANSFORM_PACKING)
- png_set_packing(png_ptr);
-#endif
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)
- /* Change the order of packed pixels to least significant bit first
- * (not useful if you are using png_set_packing).
- */
- if (transforms & PNG_TRANSFORM_PACKSWAP)
- png_set_packswap(png_ptr);
-#endif
-
-#if defined(PNG_READ_EXPAND_SUPPORTED)
- /* Expand paletted colors into true RGB triplets
- * Expand grayscale images to full 8 bits from 1, 2, or 4 bits/pixel
- * Expand paletted or RGB images with transparency to full alpha
- * channels so the data will be available as RGBA quartets.
- */
- if (transforms & PNG_TRANSFORM_EXPAND)
- if ((png_ptr->bit_depth < 8) ||
- (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ||
- (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS)))
- png_set_expand(png_ptr);
-#endif
-
- /* We don't handle background color or gamma transformation or dithering.
- */
-
-#if defined(PNG_READ_INVERT_SUPPORTED)
- /* invert monochrome files to have 0 as white and 1 as black
- */
- if (transforms & PNG_TRANSFORM_INVERT_MONO)
- png_set_invert_mono(png_ptr);
-#endif
-
-#if defined(PNG_READ_SHIFT_SUPPORTED)
- /* If you want to shift the pixel values from the range [0,255] or
- * [0,65535] to the original [0,7] or [0,31], or whatever range the
- * colors were originally in:
- */
- if ((transforms & PNG_TRANSFORM_SHIFT)
- && png_get_valid(png_ptr, info_ptr, PNG_INFO_sBIT))
- {
- png_color_8p sig_bit;
-
- png_get_sBIT(png_ptr, info_ptr, &sig_bit);
- png_set_shift(png_ptr, sig_bit);
- }
-#endif
-
-#if defined(PNG_READ_BGR_SUPPORTED)
- /* flip the RGB pixels to BGR (or RGBA to BGRA)
- */
- if (transforms & PNG_TRANSFORM_BGR)
- png_set_bgr(png_ptr);
-#endif
-
-#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
- /* swap the RGBA or GA data to ARGB or AG (or BGRA to ABGR)
- */
- if (transforms & PNG_TRANSFORM_SWAP_ALPHA)
- png_set_swap_alpha(png_ptr);
-#endif
-
-#if defined(PNG_READ_SWAP_SUPPORTED)
- /* swap bytes of 16 bit files to least significant byte first
- */
- if (transforms & PNG_TRANSFORM_SWAP_ENDIAN)
- png_set_swap(png_ptr);
-#endif
-
- /* We don't handle adding filler bytes */
-
- /* Optional call to gamma correct and add the background to the palette
- * and update info structure. REQUIRED if you are expecting libpng to
- * update the palette for you (i.e., you selected such a transform above).
- */
- png_read_update_info(png_ptr, info_ptr);
-
- /* -------------- image transformations end here ------------------- */
-
-#ifdef PNG_FREE_ME_SUPPORTED
- png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
-#endif
- if (info_ptr->row_pointers == NULL)
- {
- info_ptr->row_pointers = (png_bytepp)png_malloc(png_ptr,
- info_ptr->height * png_sizeof(png_bytep));
- png_memset(info_ptr->row_pointers, 0, info_ptr->height
- * png_sizeof(png_bytep));
-#ifdef PNG_FREE_ME_SUPPORTED
- info_ptr->free_me |= PNG_FREE_ROWS;
-#endif
- for (row = 0; row < (int)info_ptr->height; row++)
- info_ptr->row_pointers[row] = (png_bytep)png_malloc(png_ptr,
- png_get_rowbytes(png_ptr, info_ptr));
- }
-
- png_read_image(png_ptr, info_ptr->row_pointers);
- info_ptr->valid |= PNG_INFO_IDAT;
-
- /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
- png_read_end(png_ptr, info_ptr);
-
- transforms = transforms; /* quiet compiler warnings */
- params = params;
-
-}
-#endif /* PNG_INFO_IMAGE_SUPPORTED */
-#endif /* PNG_NO_SEQUENTIAL_READ_SUPPORTED */
-#endif /* PNG_READ_SUPPORTED */
diff --git a/navit/support/libpng/pngrio.c b/navit/support/libpng/pngrio.c
deleted file mode 100644
index 44a99e2a2..000000000
--- a/navit/support/libpng/pngrio.c
+++ /dev/null
@@ -1,168 +0,0 @@
-
-/* pngrio.c - functions for data input
- *
- * Last changed in libpng 1.2.36 [May 7, 2009]
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2009 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This file provides a location for all input. Users who need
- * special handling are expected to write a function that has the same
- * arguments as this and performs a similar function, but that possibly
- * has a different input method. Note that you shouldn't change this
- * function, but rather write a replacement function and then make
- * libpng use it at run time with png_set_read_fn(...).
- */
-
-#define PNG_INTERNAL
-#include "png.h"
-#if defined(PNG_READ_SUPPORTED)
-
-/* Read the data from whatever input you are using. The default routine
- reads from a file pointer. Note that this routine sometimes gets called
- with very small lengths, so you should implement some kind of simple
- buffering if you are using unbuffered reads. This should never be asked
- to read more then 64K on a 16 bit machine. */
-void /* PRIVATE */
-png_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
-{
- png_debug1(4, "reading %d bytes", (int)length);
- if (png_ptr->read_data_fn != NULL)
- (*(png_ptr->read_data_fn))(png_ptr, data, length);
- else
- png_error(png_ptr, "Call to NULL read function");
-}
-
-#if !defined(PNG_NO_STDIO)
-/* This is the function that does the actual reading of data. If you are
- not reading from a standard C stream, you should create a replacement
- read_data function and use it at run time with png_set_read_fn(), rather
- than changing the library. */
-#ifndef USE_FAR_KEYWORD
-void PNGAPI
-png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
-{
- png_size_t check;
-
- if (png_ptr == NULL) return;
- /* fread() returns 0 on error, so it is OK to store this in a png_size_t
- * instead of an int, which is what fread() actually returns.
- */
-#if 0 /* defined(_WIN32_WCE) */
- if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
- check = 0;
-#else
- check = (png_size_t)fread(data, (png_size_t)1, length,
- (png_FILE_p)png_ptr->io_ptr);
-#endif
-
- if (check != length)
- png_error(png_ptr, "Read Error");
-}
-#else
-/* this is the model-independent version. Since the standard I/O library
- can't handle far buffers in the medium and small models, we have to copy
- the data.
-*/
-
-#define NEAR_BUF_SIZE 1024
-#define MIN(a,b) (a <= b ? a : b)
-
-static void PNGAPI
-png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
-{
- int check;
- png_byte *n_data;
- png_FILE_p io_ptr;
-
- if (png_ptr == NULL) return;
- /* Check if data really is near. If so, use usual code. */
- n_data = (png_byte *)CVT_PTR_NOCHECK(data);
- io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr);
- if ((png_bytep)n_data == data)
- {
-#if 0 /* defined(_WIN32_WCE) */
- if ( !ReadFile((HANDLE)(png_ptr->io_ptr), data, length, &check, NULL) )
- check = 0;
-#else
- check = fread(n_data, 1, length, io_ptr);
-#endif
- }
- else
- {
- png_byte buf[NEAR_BUF_SIZE];
- png_size_t read, remaining, err;
- check = 0;
- remaining = length;
- do
- {
- read = MIN(NEAR_BUF_SIZE, remaining);
-#if 0 /* defined(_WIN32_WCE) */
- if ( !ReadFile((HANDLE)(io_ptr), buf, read, &err, NULL) )
- err = 0;
-#else
- err = fread(buf, (png_size_t)1, read, io_ptr);
-#endif
- png_memcpy(data, buf, read); /* copy far buffer to near buffer */
- if (err != read)
- break;
- else
- check += err;
- data += read;
- remaining -= read;
- }
- while (remaining != 0);
- }
- if ((png_uint_32)check != (png_uint_32)length)
- png_error(png_ptr, "read Error");
-}
-#endif
-#endif
-
-/* This function allows the application to supply a new input function
- for libpng if standard C streams aren't being used.
-
- This function takes as its arguments:
- png_ptr - pointer to a png input data structure
- io_ptr - pointer to user supplied structure containing info about
- the input functions. May be NULL.
- read_data_fn - pointer to a new input function that takes as its
- arguments a pointer to a png_struct, a pointer to
- a location where input data can be stored, and a 32-bit
- unsigned int that is the number of bytes to be read.
- To exit and output any fatal error messages the new write
- function should call png_error(png_ptr, "Error msg").
- May be NULL, in which case libpng's default function will
- be used. */
-void PNGAPI
-png_set_read_fn(png_structp png_ptr, png_voidp io_ptr,
- png_rw_ptr read_data_fn)
-{
- if (png_ptr == NULL) return;
- png_ptr->io_ptr = io_ptr;
-
-#if !defined(PNG_NO_STDIO)
- if (read_data_fn != NULL)
- png_ptr->read_data_fn = read_data_fn;
- else
- png_ptr->read_data_fn = png_default_read_data;
-#else
- png_ptr->read_data_fn = read_data_fn;
-#endif
-
- /* It is an error to write to a read device */
- if (png_ptr->write_data_fn != NULL)
- {
- png_ptr->write_data_fn = NULL;
- png_warning(png_ptr,
- "It's an error to set both read_data_fn and write_data_fn in the ");
- png_warning(png_ptr,
- "same structure. Resetting write_data_fn to NULL.");
- }
-
-#if defined(PNG_WRITE_FLUSH_SUPPORTED)
- png_ptr->output_flush_fn = NULL;
-#endif
-}
-#endif /* PNG_READ_SUPPORTED */
diff --git a/navit/support/libpng/pngrtran.c b/navit/support/libpng/pngrtran.c
deleted file mode 100644
index d7dd8e77a..000000000
--- a/navit/support/libpng/pngrtran.c
+++ /dev/null
@@ -1,4296 +0,0 @@
-
-/* pngrtran.c - transforms the data in a row for PNG readers
- *
- * Last changed in libpng 1.2.35 [February 14, 2009]
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2009 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This file contains functions optionally called by an application
- * in order to tell libpng how to handle data when reading a PNG.
- * Transformations that are used in both reading and writing are
- * in pngtrans.c.
- */
-
-#define PNG_INTERNAL
-#include "png.h"
-#if defined(PNG_READ_SUPPORTED)
-
-/* Set the action on getting a CRC error for an ancillary or critical chunk. */
-void PNGAPI
-png_set_crc_action(png_structp png_ptr, int crit_action, int ancil_action)
-{
- png_debug(1, "in png_set_crc_action");
- /* Tell libpng how we react to CRC errors in critical chunks */
- if (png_ptr == NULL) return;
- switch (crit_action)
- {
- case PNG_CRC_NO_CHANGE: /* leave setting as is */
- break;
- case PNG_CRC_WARN_USE: /* warn/use data */
- png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
- png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE;
- break;
- case PNG_CRC_QUIET_USE: /* quiet/use data */
- png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
- png_ptr->flags |= PNG_FLAG_CRC_CRITICAL_USE |
- PNG_FLAG_CRC_CRITICAL_IGNORE;
- break;
- case PNG_CRC_WARN_DISCARD: /* not a valid action for critical data */
- png_warning(png_ptr,
- "Can't discard critical data on CRC error.");
- case PNG_CRC_ERROR_QUIT: /* error/quit */
- case PNG_CRC_DEFAULT:
- default:
- png_ptr->flags &= ~PNG_FLAG_CRC_CRITICAL_MASK;
- break;
- }
-
- switch (ancil_action)
- {
- case PNG_CRC_NO_CHANGE: /* leave setting as is */
- break;
- case PNG_CRC_WARN_USE: /* warn/use data */
- png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
- png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE;
- break;
- case PNG_CRC_QUIET_USE: /* quiet/use data */
- png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
- png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_USE |
- PNG_FLAG_CRC_ANCILLARY_NOWARN;
- break;
- case PNG_CRC_ERROR_QUIT: /* error/quit */
- png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
- png_ptr->flags |= PNG_FLAG_CRC_ANCILLARY_NOWARN;
- break;
- case PNG_CRC_WARN_DISCARD: /* warn/discard data */
- case PNG_CRC_DEFAULT:
- default:
- png_ptr->flags &= ~PNG_FLAG_CRC_ANCILLARY_MASK;
- break;
- }
-}
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
- defined(PNG_FLOATING_POINT_SUPPORTED)
-/* handle alpha and tRNS via a background color */
-void PNGAPI
-png_set_background(png_structp png_ptr,
- png_color_16p background_color, int background_gamma_code,
- int need_expand, double background_gamma)
-{
- png_debug(1, "in png_set_background");
- if (png_ptr == NULL) return;
- if (background_gamma_code == PNG_BACKGROUND_GAMMA_UNKNOWN)
- {
- png_warning(png_ptr, "Application must supply a known background gamma");
- return;
- }
-
- png_ptr->transformations |= PNG_BACKGROUND;
- png_memcpy(&(png_ptr->background), background_color,
- png_sizeof(png_color_16));
- png_ptr->background_gamma = (float)background_gamma;
- png_ptr->background_gamma_type = (png_byte)(background_gamma_code);
- png_ptr->transformations |= (need_expand ? PNG_BACKGROUND_EXPAND : 0);
-}
-#endif
-
-#if defined(PNG_READ_16_TO_8_SUPPORTED)
-/* strip 16 bit depth files to 8 bit depth */
-void PNGAPI
-png_set_strip_16(png_structp png_ptr)
-{
- png_debug(1, "in png_set_strip_16");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= PNG_16_TO_8;
-}
-#endif
-
-#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
-void PNGAPI
-png_set_strip_alpha(png_structp png_ptr)
-{
- png_debug(1, "in png_set_strip_alpha");
- if (png_ptr == NULL) return;
- png_ptr->flags |= PNG_FLAG_STRIP_ALPHA;
-}
-#endif
-
-#if defined(PNG_READ_DITHER_SUPPORTED)
-/* Dither file to 8 bit. Supply a palette, the current number
- * of elements in the palette, the maximum number of elements
- * allowed, and a histogram if possible. If the current number
- * of colors is greater then the maximum number, the palette will be
- * modified to fit in the maximum number. "full_dither" indicates
- * whether we need a dithering cube set up for RGB images, or if we
- * simply are reducing the number of colors in a paletted image.
- */
-
-typedef struct png_dsort_struct
-{
- struct png_dsort_struct FAR * next;
- png_byte left;
- png_byte right;
-} png_dsort;
-typedef png_dsort FAR * png_dsortp;
-typedef png_dsort FAR * FAR * png_dsortpp;
-
-void PNGAPI
-png_set_dither(png_structp png_ptr, png_colorp palette,
- int num_palette, int maximum_colors, png_uint_16p histogram,
- int full_dither)
-{
- png_debug(1, "in png_set_dither");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= PNG_DITHER;
-
- if (!full_dither)
- {
- int i;
-
- png_ptr->dither_index = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)(num_palette * png_sizeof(png_byte)));
- for (i = 0; i < num_palette; i++)
- png_ptr->dither_index[i] = (png_byte)i;
- }
-
- if (num_palette > maximum_colors)
- {
- if (histogram != NULL)
- {
- /* This is easy enough, just throw out the least used colors.
- Perhaps not the best solution, but good enough. */
-
- int i;
-
- /* initialize an array to sort colors */
- png_ptr->dither_sort = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)(num_palette * png_sizeof(png_byte)));
-
- /* initialize the dither_sort array */
- for (i = 0; i < num_palette; i++)
- png_ptr->dither_sort[i] = (png_byte)i;
-
- /* Find the least used palette entries by starting a
- bubble sort, and running it until we have sorted
- out enough colors. Note that we don't care about
- sorting all the colors, just finding which are
- least used. */
-
- for (i = num_palette - 1; i >= maximum_colors; i--)
- {
- int done; /* to stop early if the list is pre-sorted */
- int j;
-
- done = 1;
- for (j = 0; j < i; j++)
- {
- if (histogram[png_ptr->dither_sort[j]]
- < histogram[png_ptr->dither_sort[j + 1]])
- {
- png_byte t;
-
- t = png_ptr->dither_sort[j];
- png_ptr->dither_sort[j] = png_ptr->dither_sort[j + 1];
- png_ptr->dither_sort[j + 1] = t;
- done = 0;
- }
- }
- if (done)
- break;
- }
-
- /* swap the palette around, and set up a table, if necessary */
- if (full_dither)
- {
- int j = num_palette;
-
- /* put all the useful colors within the max, but don't
- move the others */
- for (i = 0; i < maximum_colors; i++)
- {
- if ((int)png_ptr->dither_sort[i] >= maximum_colors)
- {
- do
- j--;
- while ((int)png_ptr->dither_sort[j] >= maximum_colors);
- palette[i] = palette[j];
- }
- }
- }
- else
- {
- int j = num_palette;
-
- /* move all the used colors inside the max limit, and
- develop a translation table */
- for (i = 0; i < maximum_colors; i++)
- {
- /* only move the colors we need to */
- if ((int)png_ptr->dither_sort[i] >= maximum_colors)
- {
- png_color tmp_color;
-
- do
- j--;
- while ((int)png_ptr->dither_sort[j] >= maximum_colors);
-
- tmp_color = palette[j];
- palette[j] = palette[i];
- palette[i] = tmp_color;
- /* indicate where the color went */
- png_ptr->dither_index[j] = (png_byte)i;
- png_ptr->dither_index[i] = (png_byte)j;
- }
- }
-
- /* find closest color for those colors we are not using */
- for (i = 0; i < num_palette; i++)
- {
- if ((int)png_ptr->dither_index[i] >= maximum_colors)
- {
- int min_d, k, min_k, d_index;
-
- /* find the closest color to one we threw out */
- d_index = png_ptr->dither_index[i];
- min_d = PNG_COLOR_DIST(palette[d_index], palette[0]);
- for (k = 1, min_k = 0; k < maximum_colors; k++)
- {
- int d;
-
- d = PNG_COLOR_DIST(palette[d_index], palette[k]);
-
- if (d < min_d)
- {
- min_d = d;
- min_k = k;
- }
- }
- /* point to closest color */
- png_ptr->dither_index[i] = (png_byte)min_k;
- }
- }
- }
- png_free(png_ptr, png_ptr->dither_sort);
- png_ptr->dither_sort = NULL;
- }
- else
- {
- /* This is much harder to do simply (and quickly). Perhaps
- we need to go through a median cut routine, but those
- don't always behave themselves with only a few colors
- as input. So we will just find the closest two colors,
- and throw out one of them (chosen somewhat randomly).
- [We don't understand this at all, so if someone wants to
- work on improving it, be our guest - AED, GRP]
- */
- int i;
- int max_d;
- int num_new_palette;
- png_dsortp t;
- png_dsortpp hash;
-
- t = NULL;
-
- /* initialize palette index arrays */
- png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)(num_palette * png_sizeof(png_byte)));
- png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)(num_palette * png_sizeof(png_byte)));
-
- /* initialize the sort array */
- for (i = 0; i < num_palette; i++)
- {
- png_ptr->index_to_palette[i] = (png_byte)i;
- png_ptr->palette_to_index[i] = (png_byte)i;
- }
-
- hash = (png_dsortpp)png_malloc(png_ptr, (png_uint_32)(769 *
- png_sizeof(png_dsortp)));
- png_memset(hash, 0, 769 * png_sizeof(png_dsortp));
-
- num_new_palette = num_palette;
-
- /* initial wild guess at how far apart the farthest pixel
- pair we will be eliminating will be. Larger
- numbers mean more areas will be allocated, Smaller
- numbers run the risk of not saving enough data, and
- having to do this all over again.
-
- I have not done extensive checking on this number.
- */
- max_d = 96;
-
- while (num_new_palette > maximum_colors)
- {
- for (i = 0; i < num_new_palette - 1; i++)
- {
- int j;
-
- for (j = i + 1; j < num_new_palette; j++)
- {
- int d;
-
- d = PNG_COLOR_DIST(palette[i], palette[j]);
-
- if (d <= max_d)
- {
-
- t = (png_dsortp)png_malloc_warn(png_ptr,
- (png_uint_32)(png_sizeof(png_dsort)));
- if (t == NULL)
- break;
- t->next = hash[d];
- t->left = (png_byte)i;
- t->right = (png_byte)j;
- hash[d] = t;
- }
- }
- if (t == NULL)
- break;
- }
-
- if (t != NULL)
- for (i = 0; i <= max_d; i++)
- {
- if (hash[i] != NULL)
- {
- png_dsortp p;
-
- for (p = hash[i]; p; p = p->next)
- {
- if ((int)png_ptr->index_to_palette[p->left]
- < num_new_palette &&
- (int)png_ptr->index_to_palette[p->right]
- < num_new_palette)
- {
- int j, next_j;
-
- if (num_new_palette & 0x01)
- {
- j = p->left;
- next_j = p->right;
- }
- else
- {
- j = p->right;
- next_j = p->left;
- }
-
- num_new_palette--;
- palette[png_ptr->index_to_palette[j]]
- = palette[num_new_palette];
- if (!full_dither)
- {
- int k;
-
- for (k = 0; k < num_palette; k++)
- {
- if (png_ptr->dither_index[k] ==
- png_ptr->index_to_palette[j])
- png_ptr->dither_index[k] =
- png_ptr->index_to_palette[next_j];
- if ((int)png_ptr->dither_index[k] ==
- num_new_palette)
- png_ptr->dither_index[k] =
- png_ptr->index_to_palette[j];
- }
- }
-
- png_ptr->index_to_palette[png_ptr->palette_to_index
- [num_new_palette]] = png_ptr->index_to_palette[j];
- png_ptr->palette_to_index[png_ptr->index_to_palette[j]]
- = png_ptr->palette_to_index[num_new_palette];
-
- png_ptr->index_to_palette[j] = (png_byte)num_new_palette;
- png_ptr->palette_to_index[num_new_palette] = (png_byte)j;
- }
- if (num_new_palette <= maximum_colors)
- break;
- }
- if (num_new_palette <= maximum_colors)
- break;
- }
- }
-
- for (i = 0; i < 769; i++)
- {
- if (hash[i] != NULL)
- {
- png_dsortp p = hash[i];
- while (p)
- {
- t = p->next;
- png_free(png_ptr, p);
- p = t;
- }
- }
- hash[i] = 0;
- }
- max_d += 96;
- }
- png_free(png_ptr, hash);
- png_free(png_ptr, png_ptr->palette_to_index);
- png_free(png_ptr, png_ptr->index_to_palette);
- png_ptr->palette_to_index = NULL;
- png_ptr->index_to_palette = NULL;
- }
- num_palette = maximum_colors;
- }
- if (png_ptr->palette == NULL)
- {
- png_ptr->palette = palette;
- }
- png_ptr->num_palette = (png_uint_16)num_palette;
-
- if (full_dither)
- {
- int i;
- png_bytep distance;
- int total_bits = PNG_DITHER_RED_BITS + PNG_DITHER_GREEN_BITS +
- PNG_DITHER_BLUE_BITS;
- int num_red = (1 << PNG_DITHER_RED_BITS);
- int num_green = (1 << PNG_DITHER_GREEN_BITS);
- int num_blue = (1 << PNG_DITHER_BLUE_BITS);
- png_size_t num_entries = ((png_size_t)1 << total_bits);
- png_ptr->palette_lookup = (png_bytep )png_malloc(png_ptr,
- (png_uint_32)(num_entries * png_sizeof(png_byte)));
- png_memset(png_ptr->palette_lookup, 0, num_entries *
- png_sizeof(png_byte));
-
- distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
- png_sizeof(png_byte)));
-
- png_memset(distance, 0xff, num_entries * png_sizeof(png_byte));
-
- for (i = 0; i < num_palette; i++)
- {
- int ir, ig, ib;
- int r = (palette[i].red >> (8 - PNG_DITHER_RED_BITS));
- int g = (palette[i].green >> (8 - PNG_DITHER_GREEN_BITS));
- int b = (palette[i].blue >> (8 - PNG_DITHER_BLUE_BITS));
-
- for (ir = 0; ir < num_red; ir++)
- {
- /* int dr = abs(ir - r); */
- int dr = ((ir > r) ? ir - r : r - ir);
- int index_r = (ir << (PNG_DITHER_BLUE_BITS + PNG_DITHER_GREEN_BITS));
-
- for (ig = 0; ig < num_green; ig++)
- {
- /* int dg = abs(ig - g); */
- int dg = ((ig > g) ? ig - g : g - ig);
- int dt = dr + dg;
- int dm = ((dr > dg) ? dr : dg);
- int index_g = index_r | (ig << PNG_DITHER_BLUE_BITS);
-
- for (ib = 0; ib < num_blue; ib++)
- {
- int d_index = index_g | ib;
- /* int db = abs(ib - b); */
- int db = ((ib > b) ? ib - b : b - ib);
- int dmax = ((dm > db) ? dm : db);
- int d = dmax + dt + db;
-
- if (d < (int)distance[d_index])
- {
- distance[d_index] = (png_byte)d;
- png_ptr->palette_lookup[d_index] = (png_byte)i;
- }
- }
- }
- }
- }
-
- png_free(png_ptr, distance);
- }
-}
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
-/* Transform the image from the file_gamma to the screen_gamma. We
- * only do transformations on images where the file_gamma and screen_gamma
- * are not close reciprocals, otherwise it slows things down slightly, and
- * also needlessly introduces small errors.
- *
- * We will turn off gamma transformation later if no semitransparent entries
- * are present in the tRNS array for palette images. We can't do it here
- * because we don't necessarily have the tRNS chunk yet.
- */
-void PNGAPI
-png_set_gamma(png_structp png_ptr, double scrn_gamma, double file_gamma)
-{
- png_debug(1, "in png_set_gamma");
- if (png_ptr == NULL) return;
- if ((fabs(scrn_gamma * file_gamma - 1.0) > PNG_GAMMA_THRESHOLD) ||
- (png_ptr->color_type & PNG_COLOR_MASK_ALPHA) ||
- (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE))
- png_ptr->transformations |= PNG_GAMMA;
- png_ptr->gamma = (float)file_gamma;
- png_ptr->screen_gamma = (float)scrn_gamma;
-}
-#endif
-
-#if defined(PNG_READ_EXPAND_SUPPORTED)
-/* Expand paletted images to RGB, expand grayscale images of
- * less than 8-bit depth to 8-bit depth, and expand tRNS chunks
- * to alpha channels.
- */
-void PNGAPI
-png_set_expand(png_structp png_ptr)
-{
- png_debug(1, "in png_set_expand");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
- png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
-}
-
-/* GRR 19990627: the following three functions currently are identical
- * to png_set_expand(). However, it is entirely reasonable that someone
- * might wish to expand an indexed image to RGB but *not* expand a single,
- * fully transparent palette entry to a full alpha channel--perhaps instead
- * convert tRNS to the grayscale/RGB format (16-bit RGB value), or replace
- * the transparent color with a particular RGB value, or drop tRNS entirely.
- * IOW, a future version of the library may make the transformations flag
- * a bit more fine-grained, with separate bits for each of these three
- * functions.
- *
- * More to the point, these functions make it obvious what libpng will be
- * doing, whereas "expand" can (and does) mean any number of things.
- *
- * GRP 20060307: In libpng-1.4.0, png_set_gray_1_2_4_to_8() was modified
- * to expand only the sample depth but not to expand the tRNS to alpha.
- */
-
-/* Expand paletted images to RGB. */
-void PNGAPI
-png_set_palette_to_rgb(png_structp png_ptr)
-{
- png_debug(1, "in png_set_palette_to_rgb");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
- png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
-}
-
-#if !defined(PNG_1_0_X)
-/* Expand grayscale images of less than 8-bit depth to 8 bits. */
-void PNGAPI
-png_set_expand_gray_1_2_4_to_8(png_structp png_ptr)
-{
- png_debug(1, "in png_set_expand_gray_1_2_4_to_8");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= PNG_EXPAND;
- png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
-}
-#endif
-
-#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
-/* Expand grayscale images of less than 8-bit depth to 8 bits. */
-/* Deprecated as of libpng-1.2.9 */
-void PNGAPI
-png_set_gray_1_2_4_to_8(png_structp png_ptr)
-{
- png_debug(1, "in png_set_gray_1_2_4_to_8");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
-}
-#endif
-
-
-/* Expand tRNS chunks to alpha channels. */
-void PNGAPI
-png_set_tRNS_to_alpha(png_structp png_ptr)
-{
- png_debug(1, "in png_set_tRNS_to_alpha");
- png_ptr->transformations |= (PNG_EXPAND | PNG_EXPAND_tRNS);
- png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
-}
-#endif /* defined(PNG_READ_EXPAND_SUPPORTED) */
-
-#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
-void PNGAPI
-png_set_gray_to_rgb(png_structp png_ptr)
-{
- png_debug(1, "in png_set_gray_to_rgb");
- png_ptr->transformations |= PNG_GRAY_TO_RGB;
- png_ptr->flags &= ~PNG_FLAG_ROW_INIT;
-}
-#endif
-
-#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
-#if defined(PNG_FLOATING_POINT_SUPPORTED)
-/* Convert a RGB image to a grayscale of the same width. This allows us,
- * for example, to convert a 24 bpp RGB image into an 8 bpp grayscale image.
- */
-
-void PNGAPI
-png_set_rgb_to_gray(png_structp png_ptr, int error_action, double red,
- double green)
-{
- int red_fixed = (int)((float)red*100000.0 + 0.5);
- int green_fixed = (int)((float)green*100000.0 + 0.5);
- if (png_ptr == NULL) return;
- png_set_rgb_to_gray_fixed(png_ptr, error_action, red_fixed, green_fixed);
-}
-#endif
-
-void PNGAPI
-png_set_rgb_to_gray_fixed(png_structp png_ptr, int error_action,
- png_fixed_point red, png_fixed_point green)
-{
- png_debug(1, "in png_set_rgb_to_gray");
- if (png_ptr == NULL) return;
- switch(error_action)
- {
- case 1: png_ptr->transformations |= PNG_RGB_TO_GRAY;
- break;
- case 2: png_ptr->transformations |= PNG_RGB_TO_GRAY_WARN;
- break;
- case 3: png_ptr->transformations |= PNG_RGB_TO_GRAY_ERR;
- }
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
-#if defined(PNG_READ_EXPAND_SUPPORTED)
- png_ptr->transformations |= PNG_EXPAND;
-#else
- {
- png_warning(png_ptr,
- "Cannot do RGB_TO_GRAY without EXPAND_SUPPORTED.");
- png_ptr->transformations &= ~PNG_RGB_TO_GRAY;
- }
-#endif
- {
- png_uint_16 red_int, green_int;
- if (red < 0 || green < 0)
- {
- red_int = 6968; /* .212671 * 32768 + .5 */
- green_int = 23434; /* .715160 * 32768 + .5 */
- }
- else if (red + green < 100000L)
- {
- red_int = (png_uint_16)(((png_uint_32)red*32768L)/100000L);
- green_int = (png_uint_16)(((png_uint_32)green*32768L)/100000L);
- }
- else
- {
- png_warning(png_ptr, "ignoring out of range rgb_to_gray coefficients");
- red_int = 6968;
- green_int = 23434;
- }
- png_ptr->rgb_to_gray_red_coeff = red_int;
- png_ptr->rgb_to_gray_green_coeff = green_int;
- png_ptr->rgb_to_gray_blue_coeff =
- (png_uint_16)(32768 - red_int - green_int);
- }
-}
-#endif
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_LEGACY_SUPPORTED)
-void PNGAPI
-png_set_read_user_transform_fn(png_structp png_ptr, png_user_transform_ptr
- read_user_transform_fn)
-{
- png_debug(1, "in png_set_read_user_transform_fn");
- if (png_ptr == NULL) return;
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
- png_ptr->transformations |= PNG_USER_TRANSFORM;
- png_ptr->read_user_transform_fn = read_user_transform_fn;
-#endif
-#ifdef PNG_LEGACY_SUPPORTED
- if (read_user_transform_fn)
- png_warning(png_ptr,
- "This version of libpng does not support user transforms");
-#endif
-}
-#endif
-
-/* Initialize everything needed for the read. This includes modifying
- * the palette.
- */
-void /* PRIVATE */
-png_init_read_transformations(png_structp png_ptr)
-{
- png_debug(1, "in png_init_read_transformations");
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- if (png_ptr != NULL)
-#endif
- {
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) || defined(PNG_READ_SHIFT_SUPPORTED) \
- || defined(PNG_READ_GAMMA_SUPPORTED)
- int color_type = png_ptr->color_type;
-#endif
-
-#if defined(PNG_READ_EXPAND_SUPPORTED) && defined(PNG_READ_BACKGROUND_SUPPORTED)
-
-#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
- /* Detect gray background and attempt to enable optimization
- * for gray --> RGB case */
- /* Note: if PNG_BACKGROUND_EXPAND is set and color_type is either RGB or
- * RGB_ALPHA (in which case need_expand is superfluous anyway), the
- * background color might actually be gray yet not be flagged as such.
- * This is not a problem for the current code, which uses
- * PNG_BACKGROUND_IS_GRAY only to decide when to do the
- * png_do_gray_to_rgb() transformation.
- */
- if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
- !(color_type & PNG_COLOR_MASK_COLOR))
- {
- png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
- } else if ((png_ptr->transformations & PNG_BACKGROUND) &&
- !(png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
- (png_ptr->transformations & PNG_GRAY_TO_RGB) &&
- png_ptr->background.red == png_ptr->background.green &&
- png_ptr->background.red == png_ptr->background.blue)
- {
- png_ptr->mode |= PNG_BACKGROUND_IS_GRAY;
- png_ptr->background.gray = png_ptr->background.red;
- }
-#endif
-
- if ((png_ptr->transformations & PNG_BACKGROUND_EXPAND) &&
- (png_ptr->transformations & PNG_EXPAND))
- {
- if (!(color_type & PNG_COLOR_MASK_COLOR)) /* i.e., GRAY or GRAY_ALPHA */
- {
- /* expand background and tRNS chunks */
- switch (png_ptr->bit_depth)
- {
- case 1:
- png_ptr->background.gray *= (png_uint_16)0xff;
- png_ptr->background.red = png_ptr->background.green
- = png_ptr->background.blue = png_ptr->background.gray;
- if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
- {
- png_ptr->trans_values.gray *= (png_uint_16)0xff;
- png_ptr->trans_values.red = png_ptr->trans_values.green
- = png_ptr->trans_values.blue = png_ptr->trans_values.gray;
- }
- break;
- case 2:
- png_ptr->background.gray *= (png_uint_16)0x55;
- png_ptr->background.red = png_ptr->background.green
- = png_ptr->background.blue = png_ptr->background.gray;
- if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
- {
- png_ptr->trans_values.gray *= (png_uint_16)0x55;
- png_ptr->trans_values.red = png_ptr->trans_values.green
- = png_ptr->trans_values.blue = png_ptr->trans_values.gray;
- }
- break;
- case 4:
- png_ptr->background.gray *= (png_uint_16)0x11;
- png_ptr->background.red = png_ptr->background.green
- = png_ptr->background.blue = png_ptr->background.gray;
- if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
- {
- png_ptr->trans_values.gray *= (png_uint_16)0x11;
- png_ptr->trans_values.red = png_ptr->trans_values.green
- = png_ptr->trans_values.blue = png_ptr->trans_values.gray;
- }
- break;
- case 8:
- case 16:
- png_ptr->background.red = png_ptr->background.green
- = png_ptr->background.blue = png_ptr->background.gray;
- break;
- }
- }
- else if (color_type == PNG_COLOR_TYPE_PALETTE)
- {
- png_ptr->background.red =
- png_ptr->palette[png_ptr->background.index].red;
- png_ptr->background.green =
- png_ptr->palette[png_ptr->background.index].green;
- png_ptr->background.blue =
- png_ptr->palette[png_ptr->background.index].blue;
-
-#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
- if (png_ptr->transformations & PNG_INVERT_ALPHA)
- {
-#if defined(PNG_READ_EXPAND_SUPPORTED)
- if (!(png_ptr->transformations & PNG_EXPAND_tRNS))
-#endif
- {
- /* invert the alpha channel (in tRNS) unless the pixels are
- going to be expanded, in which case leave it for later */
- int i, istop;
- istop=(int)png_ptr->num_trans;
- for (i=0; i<istop; i++)
- png_ptr->trans[i] = (png_byte)(255 - png_ptr->trans[i]);
- }
- }
-#endif
-
- }
- }
-#endif
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
- png_ptr->background_1 = png_ptr->background;
-#endif
-#if defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
-
- if ((color_type == PNG_COLOR_TYPE_PALETTE && png_ptr->num_trans != 0)
- && (fabs(png_ptr->screen_gamma * png_ptr->gamma - 1.0)
- < PNG_GAMMA_THRESHOLD))
- {
- int i, k;
- k=0;
- for (i=0; i<png_ptr->num_trans; i++)
- {
- if (png_ptr->trans[i] != 0 && png_ptr->trans[i] != 0xff)
- k=1; /* partial transparency is present */
- }
- if (k == 0)
- png_ptr->transformations &= ~PNG_GAMMA;
- }
-
- if ((png_ptr->transformations & (PNG_GAMMA | PNG_RGB_TO_GRAY)) &&
- png_ptr->gamma != 0.0)
- {
- png_build_gamma_table(png_ptr);
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
- if (png_ptr->transformations & PNG_BACKGROUND)
- {
- if (color_type == PNG_COLOR_TYPE_PALETTE)
- {
- /* could skip if no transparency and
- */
- png_color back, back_1;
- png_colorp palette = png_ptr->palette;
- int num_palette = png_ptr->num_palette;
- int i;
- if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE)
- {
- back.red = png_ptr->gamma_table[png_ptr->background.red];
- back.green = png_ptr->gamma_table[png_ptr->background.green];
- back.blue = png_ptr->gamma_table[png_ptr->background.blue];
-
- back_1.red = png_ptr->gamma_to_1[png_ptr->background.red];
- back_1.green = png_ptr->gamma_to_1[png_ptr->background.green];
- back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue];
- }
- else
- {
- double g, gs;
-
- switch (png_ptr->background_gamma_type)
- {
- case PNG_BACKGROUND_GAMMA_SCREEN:
- g = (png_ptr->screen_gamma);
- gs = 1.0;
- break;
- case PNG_BACKGROUND_GAMMA_FILE:
- g = 1.0 / (png_ptr->gamma);
- gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
- break;
- case PNG_BACKGROUND_GAMMA_UNIQUE:
- g = 1.0 / (png_ptr->background_gamma);
- gs = 1.0 / (png_ptr->background_gamma *
- png_ptr->screen_gamma);
- break;
- default:
- g = 1.0; /* back_1 */
- gs = 1.0; /* back */
- }
-
- if ( fabs(gs - 1.0) < PNG_GAMMA_THRESHOLD)
- {
- back.red = (png_byte)png_ptr->background.red;
- back.green = (png_byte)png_ptr->background.green;
- back.blue = (png_byte)png_ptr->background.blue;
- }
- else
- {
- back.red = (png_byte)(pow(
- (double)png_ptr->background.red/255, gs) * 255.0 + .5);
- back.green = (png_byte)(pow(
- (double)png_ptr->background.green/255, gs) * 255.0 + .5);
- back.blue = (png_byte)(pow(
- (double)png_ptr->background.blue/255, gs) * 255.0 + .5);
- }
-
- back_1.red = (png_byte)(pow(
- (double)png_ptr->background.red/255, g) * 255.0 + .5);
- back_1.green = (png_byte)(pow(
- (double)png_ptr->background.green/255, g) * 255.0 + .5);
- back_1.blue = (png_byte)(pow(
- (double)png_ptr->background.blue/255, g) * 255.0 + .5);
- }
- for (i = 0; i < num_palette; i++)
- {
- if (i < (int)png_ptr->num_trans && png_ptr->trans[i] != 0xff)
- {
- if (png_ptr->trans[i] == 0)
- {
- palette[i] = back;
- }
- else /* if (png_ptr->trans[i] != 0xff) */
- {
- png_byte v, w;
-
- v = png_ptr->gamma_to_1[palette[i].red];
- png_composite(w, v, png_ptr->trans[i], back_1.red);
- palette[i].red = png_ptr->gamma_from_1[w];
-
- v = png_ptr->gamma_to_1[palette[i].green];
- png_composite(w, v, png_ptr->trans[i], back_1.green);
- palette[i].green = png_ptr->gamma_from_1[w];
-
- v = png_ptr->gamma_to_1[palette[i].blue];
- png_composite(w, v, png_ptr->trans[i], back_1.blue);
- palette[i].blue = png_ptr->gamma_from_1[w];
- }
- }
- else
- {
- palette[i].red = png_ptr->gamma_table[palette[i].red];
- palette[i].green = png_ptr->gamma_table[palette[i].green];
- palette[i].blue = png_ptr->gamma_table[palette[i].blue];
- }
- }
- /* Prevent the transformations being done again, and make sure
- * that the now spurious alpha channel is stripped - the code
- * has just reduced background composition and gamma correction
- * to a simple alpha channel strip.
- */
- png_ptr->transformations &= ~PNG_BACKGROUND;
- png_ptr->transformations &= ~PNG_GAMMA;
- png_ptr->transformations |= PNG_STRIP_ALPHA;
- }
- /* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
- else
- /* color_type != PNG_COLOR_TYPE_PALETTE */
- {
- double m = (double)(((png_uint_32)1 << png_ptr->bit_depth) - 1);
- double g = 1.0;
- double gs = 1.0;
-
- switch (png_ptr->background_gamma_type)
- {
- case PNG_BACKGROUND_GAMMA_SCREEN:
- g = (png_ptr->screen_gamma);
- gs = 1.0;
- break;
- case PNG_BACKGROUND_GAMMA_FILE:
- g = 1.0 / (png_ptr->gamma);
- gs = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
- break;
- case PNG_BACKGROUND_GAMMA_UNIQUE:
- g = 1.0 / (png_ptr->background_gamma);
- gs = 1.0 / (png_ptr->background_gamma *
- png_ptr->screen_gamma);
- break;
- }
-
- png_ptr->background_1.gray = (png_uint_16)(pow(
- (double)png_ptr->background.gray / m, g) * m + .5);
- png_ptr->background.gray = (png_uint_16)(pow(
- (double)png_ptr->background.gray / m, gs) * m + .5);
-
- if ((png_ptr->background.red != png_ptr->background.green) ||
- (png_ptr->background.red != png_ptr->background.blue) ||
- (png_ptr->background.red != png_ptr->background.gray))
- {
- /* RGB or RGBA with color background */
- png_ptr->background_1.red = (png_uint_16)(pow(
- (double)png_ptr->background.red / m, g) * m + .5);
- png_ptr->background_1.green = (png_uint_16)(pow(
- (double)png_ptr->background.green / m, g) * m + .5);
- png_ptr->background_1.blue = (png_uint_16)(pow(
- (double)png_ptr->background.blue / m, g) * m + .5);
- png_ptr->background.red = (png_uint_16)(pow(
- (double)png_ptr->background.red / m, gs) * m + .5);
- png_ptr->background.green = (png_uint_16)(pow(
- (double)png_ptr->background.green / m, gs) * m + .5);
- png_ptr->background.blue = (png_uint_16)(pow(
- (double)png_ptr->background.blue / m, gs) * m + .5);
- }
- else
- {
- /* GRAY, GRAY ALPHA, RGB, or RGBA with gray background */
- png_ptr->background_1.red = png_ptr->background_1.green
- = png_ptr->background_1.blue = png_ptr->background_1.gray;
- png_ptr->background.red = png_ptr->background.green
- = png_ptr->background.blue = png_ptr->background.gray;
- }
- }
- }
- else
- /* transformation does not include PNG_BACKGROUND */
-#endif /* PNG_READ_BACKGROUND_SUPPORTED */
- if (color_type == PNG_COLOR_TYPE_PALETTE)
- {
- png_colorp palette = png_ptr->palette;
- int num_palette = png_ptr->num_palette;
- int i;
-
- for (i = 0; i < num_palette; i++)
- {
- palette[i].red = png_ptr->gamma_table[palette[i].red];
- palette[i].green = png_ptr->gamma_table[palette[i].green];
- palette[i].blue = png_ptr->gamma_table[palette[i].blue];
- }
-
- /* Done the gamma correction. */
- png_ptr->transformations &= ~PNG_GAMMA;
- }
- }
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
- else
-#endif
-#endif /* PNG_READ_GAMMA_SUPPORTED && PNG_FLOATING_POINT_SUPPORTED */
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
- /* No GAMMA transformation */
- if ((png_ptr->transformations & PNG_BACKGROUND) &&
- (color_type == PNG_COLOR_TYPE_PALETTE))
- {
- int i;
- int istop = (int)png_ptr->num_trans;
- png_color back;
- png_colorp palette = png_ptr->palette;
-
- back.red = (png_byte)png_ptr->background.red;
- back.green = (png_byte)png_ptr->background.green;
- back.blue = (png_byte)png_ptr->background.blue;
-
- for (i = 0; i < istop; i++)
- {
- if (png_ptr->trans[i] == 0)
- {
- palette[i] = back;
- }
- else if (png_ptr->trans[i] != 0xff)
- {
- /* The png_composite() macro is defined in png.h */
- png_composite(palette[i].red, palette[i].red,
- png_ptr->trans[i], back.red);
- png_composite(palette[i].green, palette[i].green,
- png_ptr->trans[i], back.green);
- png_composite(palette[i].blue, palette[i].blue,
- png_ptr->trans[i], back.blue);
- }
- }
-
- /* Handled alpha, still need to strip the channel. */
- png_ptr->transformations &= ~PNG_BACKGROUND;
- png_ptr->transformations |= PNG_STRIP_ALPHA;
- }
-#endif /* PNG_READ_BACKGROUND_SUPPORTED */
-
-#if defined(PNG_READ_SHIFT_SUPPORTED)
- if ((png_ptr->transformations & PNG_SHIFT) &&
- (color_type == PNG_COLOR_TYPE_PALETTE))
- {
- png_uint_16 i;
- png_uint_16 istop = png_ptr->num_palette;
- int sr = 8 - png_ptr->sig_bit.red;
- int sg = 8 - png_ptr->sig_bit.green;
- int sb = 8 - png_ptr->sig_bit.blue;
-
- if (sr < 0 || sr > 8)
- sr = 0;
- if (sg < 0 || sg > 8)
- sg = 0;
- if (sb < 0 || sb > 8)
- sb = 0;
- for (i = 0; i < istop; i++)
- {
- png_ptr->palette[i].red >>= sr;
- png_ptr->palette[i].green >>= sg;
- png_ptr->palette[i].blue >>= sb;
- }
- }
-#endif /* PNG_READ_SHIFT_SUPPORTED */
- }
-#if !defined(PNG_READ_GAMMA_SUPPORTED) && !defined(PNG_READ_SHIFT_SUPPORTED) \
- && !defined(PNG_READ_BACKGROUND_SUPPORTED)
- if (png_ptr)
- return;
-#endif
-}
-
-/* Modify the info structure to reflect the transformations. The
- * info should be updated so a PNG file could be written with it,
- * assuming the transformations result in valid PNG data.
- */
-void /* PRIVATE */
-png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
-{
- png_debug(1, "in png_read_transform_info");
-#if defined(PNG_READ_EXPAND_SUPPORTED)
- if (png_ptr->transformations & PNG_EXPAND)
- {
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (png_ptr->num_trans &&
- (png_ptr->transformations & PNG_EXPAND_tRNS))
- info_ptr->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
- else
- info_ptr->color_type = PNG_COLOR_TYPE_RGB;
- info_ptr->bit_depth = 8;
- info_ptr->num_trans = 0;
- }
- else
- {
- if (png_ptr->num_trans)
- {
- if (png_ptr->transformations & PNG_EXPAND_tRNS)
- info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
-#if 0 /* Removed from libpng-1.2.27 */
- else
- info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
-#endif
- }
- if (info_ptr->bit_depth < 8)
- info_ptr->bit_depth = 8;
- info_ptr->num_trans = 0;
- }
- }
-#endif
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
- if (png_ptr->transformations & PNG_BACKGROUND)
- {
- info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA;
- info_ptr->num_trans = 0;
- info_ptr->background = png_ptr->background;
- }
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (png_ptr->transformations & PNG_GAMMA)
- {
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- info_ptr->gamma = png_ptr->gamma;
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
- info_ptr->int_gamma = png_ptr->int_gamma;
-#endif
- }
-#endif
-
-#if defined(PNG_READ_16_TO_8_SUPPORTED)
- if ((png_ptr->transformations & PNG_16_TO_8) && (info_ptr->bit_depth == 16))
- info_ptr->bit_depth = 8;
-#endif
-
-#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
- if (png_ptr->transformations & PNG_GRAY_TO_RGB)
- info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
-#endif
-
-#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- if (png_ptr->transformations & PNG_RGB_TO_GRAY)
- info_ptr->color_type &= ~PNG_COLOR_MASK_COLOR;
-#endif
-
-#if defined(PNG_READ_DITHER_SUPPORTED)
- if (png_ptr->transformations & PNG_DITHER)
- {
- if (((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
- (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)) &&
- png_ptr->palette_lookup && info_ptr->bit_depth == 8)
- {
- info_ptr->color_type = PNG_COLOR_TYPE_PALETTE;
- }
- }
-#endif
-
-#if defined(PNG_READ_PACK_SUPPORTED)
- if ((png_ptr->transformations & PNG_PACK) && (info_ptr->bit_depth < 8))
- info_ptr->bit_depth = 8;
-#endif
-
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- info_ptr->channels = 1;
- else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
- info_ptr->channels = 3;
- else
- info_ptr->channels = 1;
-
-#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
- if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)
- info_ptr->color_type &= ~PNG_COLOR_MASK_ALPHA;
-#endif
-
- if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
- info_ptr->channels++;
-
-#if defined(PNG_READ_FILLER_SUPPORTED)
- /* STRIP_ALPHA and FILLER allowed: MASK_ALPHA bit stripped above */
- if ((png_ptr->transformations & PNG_FILLER) &&
- ((info_ptr->color_type == PNG_COLOR_TYPE_RGB) ||
- (info_ptr->color_type == PNG_COLOR_TYPE_GRAY)))
- {
- info_ptr->channels++;
- /* if adding a true alpha channel not just filler */
-#if !defined(PNG_1_0_X)
- if (png_ptr->transformations & PNG_ADD_ALPHA)
- info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
-#endif
- }
-#endif
-
-#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED) && \
-defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
- if (png_ptr->transformations & PNG_USER_TRANSFORM)
- {
- if (info_ptr->bit_depth < png_ptr->user_transform_depth)
- info_ptr->bit_depth = png_ptr->user_transform_depth;
- if (info_ptr->channels < png_ptr->user_transform_channels)
- info_ptr->channels = png_ptr->user_transform_channels;
- }
-#endif
-
- info_ptr->pixel_depth = (png_byte)(info_ptr->channels *
- info_ptr->bit_depth);
-
- info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, info_ptr->width);
-
-#if !defined(PNG_READ_EXPAND_SUPPORTED)
- if (png_ptr)
- return;
-#endif
-}
-
-/* Transform the row. The order of transformations is significant,
- * and is very touchy. If you add a transformation, take care to
- * decide how it fits in with the other transformations here.
- */
-void /* PRIVATE */
-png_do_read_transformations(png_structp png_ptr)
-{
- png_debug(1, "in png_do_read_transformations");
- if (png_ptr->row_buf == NULL)
- {
-#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
- char msg[50];
-
- png_snprintf2(msg, 50,
- "NULL row buffer for row %ld, pass %d", (long)png_ptr->row_number,
- png_ptr->pass);
- png_error(png_ptr, msg);
-#else
- png_error(png_ptr, "NULL row buffer");
-#endif
- }
-#ifdef PNG_WARN_UNINITIALIZED_ROW
- if (!(png_ptr->flags & PNG_FLAG_ROW_INIT))
- /* Application has failed to call either png_read_start_image()
- * or png_read_update_info() after setting transforms that expand
- * pixels. This check added to libpng-1.2.19 */
-#if (PNG_WARN_UNINITIALIZED_ROW==1)
- png_error(png_ptr, "Uninitialized row");
-#else
- png_warning(png_ptr, "Uninitialized row");
-#endif
-#endif
-
-#if defined(PNG_READ_EXPAND_SUPPORTED)
- if (png_ptr->transformations & PNG_EXPAND)
- {
- if (png_ptr->row_info.color_type == PNG_COLOR_TYPE_PALETTE)
- {
- png_do_expand_palette(&(png_ptr->row_info), png_ptr->row_buf + 1,
- png_ptr->palette, png_ptr->trans, png_ptr->num_trans);
- }
- else
- {
- if (png_ptr->num_trans &&
- (png_ptr->transformations & PNG_EXPAND_tRNS))
- png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
- &(png_ptr->trans_values));
- else
- png_do_expand(&(png_ptr->row_info), png_ptr->row_buf + 1,
- NULL);
- }
- }
-#endif
-
-#if defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
- if (png_ptr->flags & PNG_FLAG_STRIP_ALPHA)
- png_do_strip_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
- PNG_FLAG_FILLER_AFTER | (png_ptr->flags & PNG_FLAG_STRIP_ALPHA));
-#endif
-
-#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- if (png_ptr->transformations & PNG_RGB_TO_GRAY)
- {
- int rgb_error =
- png_do_rgb_to_gray(png_ptr, &(png_ptr->row_info), png_ptr->row_buf + 1);
- if (rgb_error)
- {
- png_ptr->rgb_to_gray_status=1;
- if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
- PNG_RGB_TO_GRAY_WARN)
- png_warning(png_ptr, "png_do_rgb_to_gray found nongray pixel");
- if ((png_ptr->transformations & PNG_RGB_TO_GRAY) ==
- PNG_RGB_TO_GRAY_ERR)
- png_error(png_ptr, "png_do_rgb_to_gray found nongray pixel");
- }
- }
-#endif
-
-/*
-From Andreas Dilger e-mail to png-implement, 26 March 1998:
-
- In most cases, the "simple transparency" should be done prior to doing
- gray-to-RGB, or you will have to test 3x as many bytes to check if a
- pixel is transparent. You would also need to make sure that the
- transparency information is upgraded to RGB.
-
- To summarize, the current flow is:
- - Gray + simple transparency -> compare 1 or 2 gray bytes and composite
- with background "in place" if transparent,
- convert to RGB if necessary
- - Gray + alpha -> composite with gray background and remove alpha bytes,
- convert to RGB if necessary
-
- To support RGB backgrounds for gray images we need:
- - Gray + simple transparency -> convert to RGB + simple transparency, compare
- 3 or 6 bytes and composite with background
- "in place" if transparent (3x compare/pixel
- compared to doing composite with gray bkgrnd)
- - Gray + alpha -> convert to RGB + alpha, composite with background and
- remove alpha bytes (3x float operations/pixel
- compared with composite on gray background)
-
- Greg's change will do this. The reason it wasn't done before is for
- performance, as this increases the per-pixel operations. If we would check
- in advance if the background was gray or RGB, and position the gray-to-RGB
- transform appropriately, then it would save a lot of work/time.
- */
-
-#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
- /* if gray -> RGB, do so now only if background is non-gray; else do later
- * for performance reasons */
- if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
- !(png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
- png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
- if ((png_ptr->transformations & PNG_BACKGROUND) &&
- ((png_ptr->num_trans != 0 ) ||
- (png_ptr->color_type & PNG_COLOR_MASK_ALPHA)))
- png_do_background(&(png_ptr->row_info), png_ptr->row_buf + 1,
- &(png_ptr->trans_values), &(png_ptr->background)
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- , &(png_ptr->background_1),
- png_ptr->gamma_table, png_ptr->gamma_from_1,
- png_ptr->gamma_to_1, png_ptr->gamma_16_table,
- png_ptr->gamma_16_from_1, png_ptr->gamma_16_to_1,
- png_ptr->gamma_shift
-#endif
-);
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if ((png_ptr->transformations & PNG_GAMMA) &&
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
- !((png_ptr->transformations & PNG_BACKGROUND) &&
- ((png_ptr->num_trans != 0) ||
- (png_ptr->color_type & PNG_COLOR_MASK_ALPHA))) &&
-#endif
- (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE))
- png_do_gamma(&(png_ptr->row_info), png_ptr->row_buf + 1,
- png_ptr->gamma_table, png_ptr->gamma_16_table,
- png_ptr->gamma_shift);
-#endif
-
-#if defined(PNG_READ_16_TO_8_SUPPORTED)
- if (png_ptr->transformations & PNG_16_TO_8)
- png_do_chop(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_DITHER_SUPPORTED)
- if (png_ptr->transformations & PNG_DITHER)
- {
- png_do_dither((png_row_infop)&(png_ptr->row_info), png_ptr->row_buf + 1,
- png_ptr->palette_lookup, png_ptr->dither_index);
- if (png_ptr->row_info.rowbytes == (png_uint_32)0)
- png_error(png_ptr, "png_do_dither returned rowbytes=0");
- }
-#endif
-
-#if defined(PNG_READ_INVERT_SUPPORTED)
- if (png_ptr->transformations & PNG_INVERT_MONO)
- png_do_invert(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_SHIFT_SUPPORTED)
- if (png_ptr->transformations & PNG_SHIFT)
- png_do_unshift(&(png_ptr->row_info), png_ptr->row_buf + 1,
- &(png_ptr->shift));
-#endif
-
-#if defined(PNG_READ_PACK_SUPPORTED)
- if (png_ptr->transformations & PNG_PACK)
- png_do_unpack(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_BGR_SUPPORTED)
- if (png_ptr->transformations & PNG_BGR)
- png_do_bgr(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_PACKSWAP)
- png_do_packswap(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
- /* if gray -> RGB, do so now only if we did not do so above */
- if ((png_ptr->transformations & PNG_GRAY_TO_RGB) &&
- (png_ptr->mode & PNG_BACKGROUND_IS_GRAY))
- png_do_gray_to_rgb(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_FILLER_SUPPORTED)
- if (png_ptr->transformations & PNG_FILLER)
- png_do_read_filler(&(png_ptr->row_info), png_ptr->row_buf + 1,
- (png_uint_32)png_ptr->filler, png_ptr->flags);
-#endif
-
-#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
- if (png_ptr->transformations & PNG_INVERT_ALPHA)
- png_do_read_invert_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
- if (png_ptr->transformations & PNG_SWAP_ALPHA)
- png_do_read_swap_alpha(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_SWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_SWAP_BYTES)
- png_do_swap(&(png_ptr->row_info), png_ptr->row_buf + 1);
-#endif
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
- if (png_ptr->transformations & PNG_USER_TRANSFORM)
- {
- if (png_ptr->read_user_transform_fn != NULL)
- (*(png_ptr->read_user_transform_fn)) /* user read transform function */
- (png_ptr, /* png_ptr */
- &(png_ptr->row_info), /* row_info: */
- /* png_uint_32 width; width of row */
- /* png_uint_32 rowbytes; number of bytes in row */
- /* png_byte color_type; color type of pixels */
- /* png_byte bit_depth; bit depth of samples */
- /* png_byte channels; number of channels (1-4) */
- /* png_byte pixel_depth; bits per pixel (depth*channels) */
- png_ptr->row_buf + 1); /* start of pixel data for row */
-#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
- if (png_ptr->user_transform_depth)
- png_ptr->row_info.bit_depth = png_ptr->user_transform_depth;
- if (png_ptr->user_transform_channels)
- png_ptr->row_info.channels = png_ptr->user_transform_channels;
-#endif
- png_ptr->row_info.pixel_depth = (png_byte)(png_ptr->row_info.bit_depth *
- png_ptr->row_info.channels);
- png_ptr->row_info.rowbytes = PNG_ROWBYTES(png_ptr->row_info.pixel_depth,
- png_ptr->row_info.width);
- }
-#endif
-
-}
-
-#if defined(PNG_READ_PACK_SUPPORTED)
-/* Unpack pixels of 1, 2, or 4 bits per pixel into 1 byte per pixel,
- * without changing the actual values. Thus, if you had a row with
- * a bit depth of 1, you would end up with bytes that only contained
- * the numbers 0 or 1. If you would rather they contain 0 and 255, use
- * png_do_shift() after this.
- */
-void /* PRIVATE */
-png_do_unpack(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_unpack");
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- if (row != NULL && row_info != NULL && row_info->bit_depth < 8)
-#else
- if (row_info->bit_depth < 8)
-#endif
- {
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
-
- switch (row_info->bit_depth)
- {
- case 1:
- {
- png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
- png_bytep dp = row + (png_size_t)row_width - 1;
- png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);
- for (i = 0; i < row_width; i++)
- {
- *dp = (png_byte)((*sp >> shift) & 0x01);
- if (shift == 7)
- {
- shift = 0;
- sp--;
- }
- else
- shift++;
-
- dp--;
- }
- break;
- }
- case 2:
- {
-
- png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
- png_bytep dp = row + (png_size_t)row_width - 1;
- png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
- for (i = 0; i < row_width; i++)
- {
- *dp = (png_byte)((*sp >> shift) & 0x03);
- if (shift == 6)
- {
- shift = 0;
- sp--;
- }
- else
- shift += 2;
-
- dp--;
- }
- break;
- }
- case 4:
- {
- png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
- png_bytep dp = row + (png_size_t)row_width - 1;
- png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
- for (i = 0; i < row_width; i++)
- {
- *dp = (png_byte)((*sp >> shift) & 0x0f);
- if (shift == 4)
- {
- shift = 0;
- sp--;
- }
- else
- shift = 4;
-
- dp--;
- }
- break;
- }
- }
- row_info->bit_depth = 8;
- row_info->pixel_depth = (png_byte)(8 * row_info->channels);
- row_info->rowbytes = row_width * row_info->channels;
- }
-}
-#endif
-
-#if defined(PNG_READ_SHIFT_SUPPORTED)
-/* Reverse the effects of png_do_shift. This routine merely shifts the
- * pixels back to their significant bits values. Thus, if you have
- * a row of bit depth 8, but only 5 are significant, this will shift
- * the values back to 0 through 31.
- */
-void /* PRIVATE */
-png_do_unshift(png_row_infop row_info, png_bytep row, png_color_8p sig_bits)
-{
- png_debug(1, "in png_do_unshift");
- if (
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL && sig_bits != NULL &&
-#endif
- row_info->color_type != PNG_COLOR_TYPE_PALETTE)
- {
- int shift[4];
- int channels = 0;
- int c;
- png_uint_16 value = 0;
- png_uint_32 row_width = row_info->width;
-
- if (row_info->color_type & PNG_COLOR_MASK_COLOR)
- {
- shift[channels++] = row_info->bit_depth - sig_bits->red;
- shift[channels++] = row_info->bit_depth - sig_bits->green;
- shift[channels++] = row_info->bit_depth - sig_bits->blue;
- }
- else
- {
- shift[channels++] = row_info->bit_depth - sig_bits->gray;
- }
- if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
- {
- shift[channels++] = row_info->bit_depth - sig_bits->alpha;
- }
-
- for (c = 0; c < channels; c++)
- {
- if (shift[c] <= 0)
- shift[c] = 0;
- else
- value = 1;
- }
-
- if (!value)
- return;
-
- switch (row_info->bit_depth)
- {
- case 2:
- {
- png_bytep bp;
- png_uint_32 i;
- png_uint_32 istop = row_info->rowbytes;
-
- for (bp = row, i = 0; i < istop; i++)
- {
- *bp >>= 1;
- *bp++ &= 0x55;
- }
- break;
- }
- case 4:
- {
- png_bytep bp = row;
- png_uint_32 i;
- png_uint_32 istop = row_info->rowbytes;
- png_byte mask = (png_byte)((((int)0xf0 >> shift[0]) & (int)0xf0) |
- (png_byte)((int)0xf >> shift[0]));
-
- for (i = 0; i < istop; i++)
- {
- *bp >>= shift[0];
- *bp++ &= mask;
- }
- break;
- }
- case 8:
- {
- png_bytep bp = row;
- png_uint_32 i;
- png_uint_32 istop = row_width * channels;
-
- for (i = 0; i < istop; i++)
- {
- *bp++ >>= shift[i%channels];
- }
- break;
- }
- case 16:
- {
- png_bytep bp = row;
- png_uint_32 i;
- png_uint_32 istop = channels * row_width;
-
- for (i = 0; i < istop; i++)
- {
- value = (png_uint_16)((*bp << 8) + *(bp + 1));
- value >>= shift[i%channels];
- *bp++ = (png_byte)(value >> 8);
- *bp++ = (png_byte)(value & 0xff);
- }
- break;
- }
- }
- }
-}
-#endif
-
-#if defined(PNG_READ_16_TO_8_SUPPORTED)
-/* chop rows of bit depth 16 down to 8 */
-void /* PRIVATE */
-png_do_chop(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_chop");
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- if (row != NULL && row_info != NULL && row_info->bit_depth == 16)
-#else
- if (row_info->bit_depth == 16)
-#endif
- {
- png_bytep sp = row;
- png_bytep dp = row;
- png_uint_32 i;
- png_uint_32 istop = row_info->width * row_info->channels;
-
- for (i = 0; i<istop; i++, sp += 2, dp++)
- {
-#if defined(PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED)
- /* This does a more accurate scaling of the 16-bit color
- * value, rather than a simple low-byte truncation.
- *
- * What the ideal calculation should be:
- * *dp = (((((png_uint_32)(*sp) << 8) |
- * (png_uint_32)(*(sp + 1))) * 255 + 127) / (png_uint_32)65535L;
- *
- * GRR: no, I think this is what it really should be:
- * *dp = (((((png_uint_32)(*sp) << 8) |
- * (png_uint_32)(*(sp + 1))) + 128L) / (png_uint_32)257L;
- *
- * GRR: here's the exact calculation with shifts:
- * temp = (((png_uint_32)(*sp) << 8) | (png_uint_32)(*(sp + 1))) + 128L;
- * *dp = (temp - (temp >> 8)) >> 8;
- *
- * Approximate calculation with shift/add instead of multiply/divide:
- * *dp = ((((png_uint_32)(*sp) << 8) |
- * (png_uint_32)((int)(*(sp + 1)) - *sp)) + 128) >> 8;
- *
- * What we actually do to avoid extra shifting and conversion:
- */
-
- *dp = *sp + ((((int)(*(sp + 1)) - *sp) > 128) ? 1 : 0);
-#else
- /* Simply discard the low order byte */
- *dp = *sp;
-#endif
- }
- row_info->bit_depth = 8;
- row_info->pixel_depth = (png_byte)(8 * row_info->channels);
- row_info->rowbytes = row_info->width * row_info->channels;
- }
-}
-#endif
-
-#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED)
-void /* PRIVATE */
-png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_read_swap_alpha");
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- if (row != NULL && row_info != NULL)
-#endif
- {
- png_uint_32 row_width = row_info->width;
- if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- /* This converts from RGBA to ARGB */
- if (row_info->bit_depth == 8)
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_byte save;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- save = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = save;
- }
- }
- /* This converts from RRGGBBAA to AARRGGBB */
- else
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_byte save[2];
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- save[0] = *(--sp);
- save[1] = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = save[0];
- *(--dp) = save[1];
- }
- }
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- /* This converts from GA to AG */
- if (row_info->bit_depth == 8)
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_byte save;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- save = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = save;
- }
- }
- /* This converts from GGAA to AAGG */
- else
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_byte save[2];
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- save[0] = *(--sp);
- save[1] = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = save[0];
- *(--dp) = save[1];
- }
- }
- }
- }
-}
-#endif
-
-#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED)
-void /* PRIVATE */
-png_do_read_invert_alpha(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_read_invert_alpha");
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- if (row != NULL && row_info != NULL)
-#endif
- {
- png_uint_32 row_width = row_info->width;
- if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- /* This inverts the alpha channel in RGBA */
- if (row_info->bit_depth == 8)
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = (png_byte)(255 - *(--sp));
-
-/* This does nothing:
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- We can replace it with:
-*/
- sp-=3;
- dp=sp;
- }
- }
- /* This inverts the alpha channel in RRGGBBAA */
- else
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = (png_byte)(255 - *(--sp));
- *(--dp) = (png_byte)(255 - *(--sp));
-
-/* This does nothing:
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- We can replace it with:
-*/
- sp-=6;
- dp=sp;
- }
- }
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- /* This inverts the alpha channel in GA */
- if (row_info->bit_depth == 8)
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = (png_byte)(255 - *(--sp));
- *(--dp) = *(--sp);
- }
- }
- /* This inverts the alpha channel in GGAA */
- else
- {
- png_bytep sp = row + row_info->rowbytes;
- png_bytep dp = sp;
- png_uint_32 i;
-
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = (png_byte)(255 - *(--sp));
- *(--dp) = (png_byte)(255 - *(--sp));
-/*
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
-*/
- sp-=2;
- dp=sp;
- }
- }
- }
- }
-}
-#endif
-
-#if defined(PNG_READ_FILLER_SUPPORTED)
-/* Add filler channel if we have RGB color */
-void /* PRIVATE */
-png_do_read_filler(png_row_infop row_info, png_bytep row,
- png_uint_32 filler, png_uint_32 flags)
-{
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- png_byte hi_filler = (png_byte)((filler>>8) & 0xff);
- png_byte lo_filler = (png_byte)(filler & 0xff);
-
- png_debug(1, "in png_do_read_filler");
- if (
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL &&
-#endif
- row_info->color_type == PNG_COLOR_TYPE_GRAY)
- {
- if (row_info->bit_depth == 8)
- {
- /* This changes the data from G to GX */
- if (flags & PNG_FLAG_FILLER_AFTER)
- {
- png_bytep sp = row + (png_size_t)row_width;
- png_bytep dp = sp + (png_size_t)row_width;
- for (i = 1; i < row_width; i++)
- {
- *(--dp) = lo_filler;
- *(--dp) = *(--sp);
- }
- *(--dp) = lo_filler;
- row_info->channels = 2;
- row_info->pixel_depth = 16;
- row_info->rowbytes = row_width * 2;
- }
- /* This changes the data from G to XG */
- else
- {
- png_bytep sp = row + (png_size_t)row_width;
- png_bytep dp = sp + (png_size_t)row_width;
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = *(--sp);
- *(--dp) = lo_filler;
- }
- row_info->channels = 2;
- row_info->pixel_depth = 16;
- row_info->rowbytes = row_width * 2;
- }
- }
- else if (row_info->bit_depth == 16)
- {
- /* This changes the data from GG to GGXX */
- if (flags & PNG_FLAG_FILLER_AFTER)
- {
- png_bytep sp = row + (png_size_t)row_width * 2;
- png_bytep dp = sp + (png_size_t)row_width * 2;
- for (i = 1; i < row_width; i++)
- {
- *(--dp) = hi_filler;
- *(--dp) = lo_filler;
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- }
- *(--dp) = hi_filler;
- *(--dp) = lo_filler;
- row_info->channels = 2;
- row_info->pixel_depth = 32;
- row_info->rowbytes = row_width * 4;
- }
- /* This changes the data from GG to XXGG */
- else
- {
- png_bytep sp = row + (png_size_t)row_width * 2;
- png_bytep dp = sp + (png_size_t)row_width * 2;
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = hi_filler;
- *(--dp) = lo_filler;
- }
- row_info->channels = 2;
- row_info->pixel_depth = 32;
- row_info->rowbytes = row_width * 4;
- }
- }
- } /* COLOR_TYPE == GRAY */
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- {
- if (row_info->bit_depth == 8)
- {
- /* This changes the data from RGB to RGBX */
- if (flags & PNG_FLAG_FILLER_AFTER)
- {
- png_bytep sp = row + (png_size_t)row_width * 3;
- png_bytep dp = sp + (png_size_t)row_width;
- for (i = 1; i < row_width; i++)
- {
- *(--dp) = lo_filler;
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- }
- *(--dp) = lo_filler;
- row_info->channels = 4;
- row_info->pixel_depth = 32;
- row_info->rowbytes = row_width * 4;
- }
- /* This changes the data from RGB to XRGB */
- else
- {
- png_bytep sp = row + (png_size_t)row_width * 3;
- png_bytep dp = sp + (png_size_t)row_width;
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = lo_filler;
- }
- row_info->channels = 4;
- row_info->pixel_depth = 32;
- row_info->rowbytes = row_width * 4;
- }
- }
- else if (row_info->bit_depth == 16)
- {
- /* This changes the data from RRGGBB to RRGGBBXX */
- if (flags & PNG_FLAG_FILLER_AFTER)
- {
- png_bytep sp = row + (png_size_t)row_width * 6;
- png_bytep dp = sp + (png_size_t)row_width * 2;
- for (i = 1; i < row_width; i++)
- {
- *(--dp) = hi_filler;
- *(--dp) = lo_filler;
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- }
- *(--dp) = hi_filler;
- *(--dp) = lo_filler;
- row_info->channels = 4;
- row_info->pixel_depth = 64;
- row_info->rowbytes = row_width * 8;
- }
- /* This changes the data from RRGGBB to XXRRGGBB */
- else
- {
- png_bytep sp = row + (png_size_t)row_width * 6;
- png_bytep dp = sp + (png_size_t)row_width * 2;
- for (i = 0; i < row_width; i++)
- {
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = *(--sp);
- *(--dp) = hi_filler;
- *(--dp) = lo_filler;
- }
- row_info->channels = 4;
- row_info->pixel_depth = 64;
- row_info->rowbytes = row_width * 8;
- }
- }
- } /* COLOR_TYPE == RGB */
-}
-#endif
-
-#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
-/* expand grayscale files to RGB, with or without alpha */
-void /* PRIVATE */
-png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
-{
- png_uint_32 i;
- png_uint_32 row_width = row_info->width;
-
- png_debug(1, "in png_do_gray_to_rgb");
- if (row_info->bit_depth >= 8 &&
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL &&
-#endif
- !(row_info->color_type & PNG_COLOR_MASK_COLOR))
- {
- if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
- {
- if (row_info->bit_depth == 8)
- {
- png_bytep sp = row + (png_size_t)row_width - 1;
- png_bytep dp = sp + (png_size_t)row_width * 2;
- for (i = 0; i < row_width; i++)
- {
- *(dp--) = *sp;
- *(dp--) = *sp;
- *(dp--) = *(sp--);
- }
- }
- else
- {
- png_bytep sp = row + (png_size_t)row_width * 2 - 1;
- png_bytep dp = sp + (png_size_t)row_width * 4;
- for (i = 0; i < row_width; i++)
- {
- *(dp--) = *sp;
- *(dp--) = *(sp - 1);
- *(dp--) = *sp;
- *(dp--) = *(sp - 1);
- *(dp--) = *(sp--);
- *(dp--) = *(sp--);
- }
- }
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- if (row_info->bit_depth == 8)
- {
- png_bytep sp = row + (png_size_t)row_width * 2 - 1;
- png_bytep dp = sp + (png_size_t)row_width * 2;
- for (i = 0; i < row_width; i++)
- {
- *(dp--) = *(sp--);
- *(dp--) = *sp;
- *(dp--) = *sp;
- *(dp--) = *(sp--);
- }
- }
- else
- {
- png_bytep sp = row + (png_size_t)row_width * 4 - 1;
- png_bytep dp = sp + (png_size_t)row_width * 4;
- for (i = 0; i < row_width; i++)
- {
- *(dp--) = *(sp--);
- *(dp--) = *(sp--);
- *(dp--) = *sp;
- *(dp--) = *(sp - 1);
- *(dp--) = *sp;
- *(dp--) = *(sp - 1);
- *(dp--) = *(sp--);
- *(dp--) = *(sp--);
- }
- }
- }
- row_info->channels += (png_byte)2;
- row_info->color_type |= PNG_COLOR_MASK_COLOR;
- row_info->pixel_depth = (png_byte)(row_info->channels *
- row_info->bit_depth);
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
-}
-#endif
-
-#if defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
-/* reduce RGB files to grayscale, with or without alpha
- * using the equation given in Poynton's ColorFAQ at
- * <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008)
- * New link:
- * <http://www.poynton.com/notes/colour_and_gamma/>
- * Charles Poynton poynton at poynton.com
- *
- * Y = 0.212671 * R + 0.715160 * G + 0.072169 * B
- *
- * We approximate this with
- *
- * Y = 0.21268 * R + 0.7151 * G + 0.07217 * B
- *
- * which can be expressed with integers as
- *
- * Y = (6969 * R + 23434 * G + 2365 * B)/32768
- *
- * The calculation is to be done in a linear colorspace.
- *
- * Other integer coefficents can be used via png_set_rgb_to_gray().
- */
-int /* PRIVATE */
-png_do_rgb_to_gray(png_structp png_ptr, png_row_infop row_info, png_bytep row)
-
-{
- png_uint_32 i;
-
- png_uint_32 row_width = row_info->width;
- int rgb_error = 0;
-
- png_debug(1, "in png_do_rgb_to_gray");
- if (
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL &&
-#endif
- (row_info->color_type & PNG_COLOR_MASK_COLOR))
- {
- png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
- png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
- png_uint_32 bc = png_ptr->rgb_to_gray_blue_coeff;
-
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- {
- if (row_info->bit_depth == 8)
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)
- {
- png_bytep sp = row;
- png_bytep dp = row;
-
- for (i = 0; i < row_width; i++)
- {
- png_byte red = png_ptr->gamma_to_1[*(sp++)];
- png_byte green = png_ptr->gamma_to_1[*(sp++)];
- png_byte blue = png_ptr->gamma_to_1[*(sp++)];
- if (red != green || red != blue)
- {
- rgb_error |= 1;
- *(dp++) = png_ptr->gamma_from_1[
- (rc*red + gc*green + bc*blue)>>15];
- }
- else
- *(dp++) = *(sp - 1);
- }
- }
- else
-#endif
- {
- png_bytep sp = row;
- png_bytep dp = row;
- for (i = 0; i < row_width; i++)
- {
- png_byte red = *(sp++);
- png_byte green = *(sp++);
- png_byte blue = *(sp++);
- if (red != green || red != blue)
- {
- rgb_error |= 1;
- *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
- }
- else
- *(dp++) = *(sp - 1);
- }
- }
- }
-
- else /* RGB bit_depth == 16 */
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- if (png_ptr->gamma_16_to_1 != NULL &&
- png_ptr->gamma_16_from_1 != NULL)
- {
- png_bytep sp = row;
- png_bytep dp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 red, green, blue, w;
-
- red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
- green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
- blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
-
- if (red == green && red == blue)
- w = red;
- else
- {
- png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >>
- png_ptr->gamma_shift][red>>8];
- png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >>
- png_ptr->gamma_shift][green>>8];
- png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
- png_ptr->gamma_shift][blue>>8];
- png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
- + bc*blue_1)>>15);
- w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
- png_ptr->gamma_shift][gray16 >> 8];
- rgb_error |= 1;
- }
-
- *(dp++) = (png_byte)((w>>8) & 0xff);
- *(dp++) = (png_byte)(w & 0xff);
- }
- }
- else
-#endif
- {
- png_bytep sp = row;
- png_bytep dp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 red, green, blue, gray16;
-
- red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
- green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
- blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
-
- if (red != green || red != blue)
- rgb_error |= 1;
- gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
- *(dp++) = (png_byte)((gray16>>8) & 0xff);
- *(dp++) = (png_byte)(gray16 & 0xff);
- }
- }
- }
- }
- if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- if (row_info->bit_depth == 8)
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- if (png_ptr->gamma_from_1 != NULL && png_ptr->gamma_to_1 != NULL)
- {
- png_bytep sp = row;
- png_bytep dp = row;
- for (i = 0; i < row_width; i++)
- {
- png_byte red = png_ptr->gamma_to_1[*(sp++)];
- png_byte green = png_ptr->gamma_to_1[*(sp++)];
- png_byte blue = png_ptr->gamma_to_1[*(sp++)];
- if (red != green || red != blue)
- rgb_error |= 1;
- *(dp++) = png_ptr->gamma_from_1
- [(rc*red + gc*green + bc*blue)>>15];
- *(dp++) = *(sp++); /* alpha */
- }
- }
- else
-#endif
- {
- png_bytep sp = row;
- png_bytep dp = row;
- for (i = 0; i < row_width; i++)
- {
- png_byte red = *(sp++);
- png_byte green = *(sp++);
- png_byte blue = *(sp++);
- if (red != green || red != blue)
- rgb_error |= 1;
- *(dp++) = (png_byte)((rc*red + gc*green + bc*blue)>>15);
- *(dp++) = *(sp++); /* alpha */
- }
- }
- }
- else /* RGBA bit_depth == 16 */
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
- if (png_ptr->gamma_16_to_1 != NULL &&
- png_ptr->gamma_16_from_1 != NULL)
- {
- png_bytep sp = row;
- png_bytep dp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 red, green, blue, w;
-
- red = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
- green = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
- blue = (png_uint_16)(((*(sp))<<8) | *(sp+1)); sp+=2;
-
- if (red == green && red == blue)
- w = red;
- else
- {
- png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff) >>
- png_ptr->gamma_shift][red>>8];
- png_uint_16 green_1 = png_ptr->gamma_16_to_1[(green&0xff) >>
- png_ptr->gamma_shift][green>>8];
- png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff) >>
- png_ptr->gamma_shift][blue>>8];
- png_uint_16 gray16 = (png_uint_16)((rc * red_1
- + gc * green_1 + bc * blue_1)>>15);
- w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
- png_ptr->gamma_shift][gray16 >> 8];
- rgb_error |= 1;
- }
-
- *(dp++) = (png_byte)((w>>8) & 0xff);
- *(dp++) = (png_byte)(w & 0xff);
- *(dp++) = *(sp++); /* alpha */
- *(dp++) = *(sp++);
- }
- }
- else
-#endif
- {
- png_bytep sp = row;
- png_bytep dp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 red, green, blue, gray16;
- red = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
- green = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
- blue = (png_uint_16)((*(sp)<<8) | *(sp+1)); sp+=2;
- if (red != green || red != blue)
- rgb_error |= 1;
- gray16 = (png_uint_16)((rc*red + gc*green + bc*blue)>>15);
- *(dp++) = (png_byte)((gray16>>8) & 0xff);
- *(dp++) = (png_byte)(gray16 & 0xff);
- *(dp++) = *(sp++); /* alpha */
- *(dp++) = *(sp++);
- }
- }
- }
- }
- row_info->channels -= (png_byte)2;
- row_info->color_type &= ~PNG_COLOR_MASK_COLOR;
- row_info->pixel_depth = (png_byte)(row_info->channels *
- row_info->bit_depth);
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
- return rgb_error;
-}
-#endif
-
-/* Build a grayscale palette. Palette is assumed to be 1 << bit_depth
- * large of png_color. This lets grayscale images be treated as
- * paletted. Most useful for gamma correction and simplification
- * of code.
- */
-void PNGAPI
-png_build_grayscale_palette(int bit_depth, png_colorp palette)
-{
- int num_palette;
- int color_inc;
- int i;
- int v;
-
- png_debug(1, "in png_do_build_grayscale_palette");
- if (palette == NULL)
- return;
-
- switch (bit_depth)
- {
- case 1:
- num_palette = 2;
- color_inc = 0xff;
- break;
- case 2:
- num_palette = 4;
- color_inc = 0x55;
- break;
- case 4:
- num_palette = 16;
- color_inc = 0x11;
- break;
- case 8:
- num_palette = 256;
- color_inc = 1;
- break;
- default:
- num_palette = 0;
- color_inc = 0;
- break;
- }
-
- for (i = 0, v = 0; i < num_palette; i++, v += color_inc)
- {
- palette[i].red = (png_byte)v;
- palette[i].green = (png_byte)v;
- palette[i].blue = (png_byte)v;
- }
-}
-
-/* This function is currently unused. Do we really need it? */
-#if defined(PNG_READ_DITHER_SUPPORTED) && defined(PNG_CORRECT_PALETTE_SUPPORTED)
-void /* PRIVATE */
-png_correct_palette(png_structp png_ptr, png_colorp palette,
- int num_palette)
-{
- png_debug(1, "in png_correct_palette");
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) && \
- defined(PNG_READ_GAMMA_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
- if (png_ptr->transformations & (PNG_GAMMA | PNG_BACKGROUND))
- {
- png_color back, back_1;
-
- if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_FILE)
- {
- back.red = png_ptr->gamma_table[png_ptr->background.red];
- back.green = png_ptr->gamma_table[png_ptr->background.green];
- back.blue = png_ptr->gamma_table[png_ptr->background.blue];
-
- back_1.red = png_ptr->gamma_to_1[png_ptr->background.red];
- back_1.green = png_ptr->gamma_to_1[png_ptr->background.green];
- back_1.blue = png_ptr->gamma_to_1[png_ptr->background.blue];
- }
- else
- {
- double g;
-
- g = 1.0 / (png_ptr->background_gamma * png_ptr->screen_gamma);
-
- if (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_SCREEN ||
- fabs(g - 1.0) < PNG_GAMMA_THRESHOLD)
- {
- back.red = png_ptr->background.red;
- back.green = png_ptr->background.green;
- back.blue = png_ptr->background.blue;
- }
- else
- {
- back.red =
- (png_byte)(pow((double)png_ptr->background.red/255, g) *
- 255.0 + 0.5);
- back.green =
- (png_byte)(pow((double)png_ptr->background.green/255, g) *
- 255.0 + 0.5);
- back.blue =
- (png_byte)(pow((double)png_ptr->background.blue/255, g) *
- 255.0 + 0.5);
- }
-
- g = 1.0 / png_ptr->background_gamma;
-
- back_1.red =
- (png_byte)(pow((double)png_ptr->background.red/255, g) *
- 255.0 + 0.5);
- back_1.green =
- (png_byte)(pow((double)png_ptr->background.green/255, g) *
- 255.0 + 0.5);
- back_1.blue =
- (png_byte)(pow((double)png_ptr->background.blue/255, g) *
- 255.0 + 0.5);
- }
-
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- png_uint_32 i;
-
- for (i = 0; i < (png_uint_32)num_palette; i++)
- {
- if (i < png_ptr->num_trans && png_ptr->trans[i] == 0)
- {
- palette[i] = back;
- }
- else if (i < png_ptr->num_trans && png_ptr->trans[i] != 0xff)
- {
- png_byte v, w;
-
- v = png_ptr->gamma_to_1[png_ptr->palette[i].red];
- png_composite(w, v, png_ptr->trans[i], back_1.red);
- palette[i].red = png_ptr->gamma_from_1[w];
-
- v = png_ptr->gamma_to_1[png_ptr->palette[i].green];
- png_composite(w, v, png_ptr->trans[i], back_1.green);
- palette[i].green = png_ptr->gamma_from_1[w];
-
- v = png_ptr->gamma_to_1[png_ptr->palette[i].blue];
- png_composite(w, v, png_ptr->trans[i], back_1.blue);
- palette[i].blue = png_ptr->gamma_from_1[w];
- }
- else
- {
- palette[i].red = png_ptr->gamma_table[palette[i].red];
- palette[i].green = png_ptr->gamma_table[palette[i].green];
- palette[i].blue = png_ptr->gamma_table[palette[i].blue];
- }
- }
- }
- else
- {
- int i;
-
- for (i = 0; i < num_palette; i++)
- {
- if (palette[i].red == (png_byte)png_ptr->trans_values.gray)
- {
- palette[i] = back;
- }
- else
- {
- palette[i].red = png_ptr->gamma_table[palette[i].red];
- palette[i].green = png_ptr->gamma_table[palette[i].green];
- palette[i].blue = png_ptr->gamma_table[palette[i].blue];
- }
- }
- }
- }
- else
-#endif
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (png_ptr->transformations & PNG_GAMMA)
- {
- int i;
-
- for (i = 0; i < num_palette; i++)
- {
- palette[i].red = png_ptr->gamma_table[palette[i].red];
- palette[i].green = png_ptr->gamma_table[palette[i].green];
- palette[i].blue = png_ptr->gamma_table[palette[i].blue];
- }
- }
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
- else
-#endif
-#endif
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
- if (png_ptr->transformations & PNG_BACKGROUND)
- {
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- png_color back;
-
- back.red = (png_byte)png_ptr->background.red;
- back.green = (png_byte)png_ptr->background.green;
- back.blue = (png_byte)png_ptr->background.blue;
-
- for (i = 0; i < (int)png_ptr->num_trans; i++)
- {
- if (png_ptr->trans[i] == 0)
- {
- palette[i].red = back.red;
- palette[i].green = back.green;
- palette[i].blue = back.blue;
- }
- else if (png_ptr->trans[i] != 0xff)
- {
- png_composite(palette[i].red, png_ptr->palette[i].red,
- png_ptr->trans[i], back.red);
- png_composite(palette[i].green, png_ptr->palette[i].green,
- png_ptr->trans[i], back.green);
- png_composite(palette[i].blue, png_ptr->palette[i].blue,
- png_ptr->trans[i], back.blue);
- }
- }
- }
- else /* assume grayscale palette (what else could it be?) */
- {
- int i;
-
- for (i = 0; i < num_palette; i++)
- {
- if (i == (png_byte)png_ptr->trans_values.gray)
- {
- palette[i].red = (png_byte)png_ptr->background.red;
- palette[i].green = (png_byte)png_ptr->background.green;
- palette[i].blue = (png_byte)png_ptr->background.blue;
- }
- }
- }
- }
-#endif
-}
-#endif
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED)
-/* Replace any alpha or transparency with the supplied background color.
- * "background" is already in the screen gamma, while "background_1" is
- * at a gamma of 1.0. Paletted files have already been taken care of.
- */
-void /* PRIVATE */
-png_do_background(png_row_infop row_info, png_bytep row,
- png_color_16p trans_values, png_color_16p background
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- , png_color_16p background_1,
- png_bytep gamma_table, png_bytep gamma_from_1, png_bytep gamma_to_1,
- png_uint_16pp gamma_16, png_uint_16pp gamma_16_from_1,
- png_uint_16pp gamma_16_to_1, int gamma_shift
-#endif
- )
-{
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
- int shift;
-
- png_debug(1, "in png_do_background");
- if (background != NULL &&
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL &&
-#endif
- (!(row_info->color_type & PNG_COLOR_MASK_ALPHA) ||
- (row_info->color_type != PNG_COLOR_TYPE_PALETTE && trans_values)))
- {
- switch (row_info->color_type)
- {
- case PNG_COLOR_TYPE_GRAY:
- {
- switch (row_info->bit_depth)
- {
- case 1:
- {
- sp = row;
- shift = 7;
- for (i = 0; i < row_width; i++)
- {
- if ((png_uint_16)((*sp >> shift) & 0x01)
- == trans_values->gray)
- {
- *sp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
- *sp |= (png_byte)(background->gray << shift);
- }
- if (!shift)
- {
- shift = 7;
- sp++;
- }
- else
- shift--;
- }
- break;
- }
- case 2:
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (gamma_table != NULL)
- {
- sp = row;
- shift = 6;
- for (i = 0; i < row_width; i++)
- {
- if ((png_uint_16)((*sp >> shift) & 0x03)
- == trans_values->gray)
- {
- *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
- *sp |= (png_byte)(background->gray << shift);
- }
- else
- {
- png_byte p = (png_byte)((*sp >> shift) & 0x03);
- png_byte g = (png_byte)((gamma_table [p | (p << 2) |
- (p << 4) | (p << 6)] >> 6) & 0x03);
- *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
- *sp |= (png_byte)(g << shift);
- }
- if (!shift)
- {
- shift = 6;
- sp++;
- }
- else
- shift -= 2;
- }
- }
- else
-#endif
- {
- sp = row;
- shift = 6;
- for (i = 0; i < row_width; i++)
- {
- if ((png_uint_16)((*sp >> shift) & 0x03)
- == trans_values->gray)
- {
- *sp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
- *sp |= (png_byte)(background->gray << shift);
- }
- if (!shift)
- {
- shift = 6;
- sp++;
- }
- else
- shift -= 2;
- }
- }
- break;
- }
- case 4:
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (gamma_table != NULL)
- {
- sp = row;
- shift = 4;
- for (i = 0; i < row_width; i++)
- {
- if ((png_uint_16)((*sp >> shift) & 0x0f)
- == trans_values->gray)
- {
- *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
- *sp |= (png_byte)(background->gray << shift);
- }
- else
- {
- png_byte p = (png_byte)((*sp >> shift) & 0x0f);
- png_byte g = (png_byte)((gamma_table[p |
- (p << 4)] >> 4) & 0x0f);
- *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
- *sp |= (png_byte)(g << shift);
- }
- if (!shift)
- {
- shift = 4;
- sp++;
- }
- else
- shift -= 4;
- }
- }
- else
-#endif
- {
- sp = row;
- shift = 4;
- for (i = 0; i < row_width; i++)
- {
- if ((png_uint_16)((*sp >> shift) & 0x0f)
- == trans_values->gray)
- {
- *sp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
- *sp |= (png_byte)(background->gray << shift);
- }
- if (!shift)
- {
- shift = 4;
- sp++;
- }
- else
- shift -= 4;
- }
- }
- break;
- }
- case 8:
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (gamma_table != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp++)
- {
- if (*sp == trans_values->gray)
- {
- *sp = (png_byte)background->gray;
- }
- else
- {
- *sp = gamma_table[*sp];
- }
- }
- }
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp++)
- {
- if (*sp == trans_values->gray)
- {
- *sp = (png_byte)background->gray;
- }
- }
- }
- break;
- }
- case 16:
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (gamma_16 != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 2)
- {
- png_uint_16 v;
-
- v = (png_uint_16)(((*sp) << 8) + *(sp + 1));
- if (v == trans_values->gray)
- {
- /* background is already in screen gamma */
- *sp = (png_byte)((background->gray >> 8) & 0xff);
- *(sp + 1) = (png_byte)(background->gray & 0xff);
- }
- else
- {
- v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- }
- }
- }
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 2)
- {
- png_uint_16 v;
-
- v = (png_uint_16)(((*sp) << 8) + *(sp + 1));
- if (v == trans_values->gray)
- {
- *sp = (png_byte)((background->gray >> 8) & 0xff);
- *(sp + 1) = (png_byte)(background->gray & 0xff);
- }
- }
- }
- break;
- }
- }
- break;
- }
- case PNG_COLOR_TYPE_RGB:
- {
- if (row_info->bit_depth == 8)
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (gamma_table != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 3)
- {
- if (*sp == trans_values->red &&
- *(sp + 1) == trans_values->green &&
- *(sp + 2) == trans_values->blue)
- {
- *sp = (png_byte)background->red;
- *(sp + 1) = (png_byte)background->green;
- *(sp + 2) = (png_byte)background->blue;
- }
- else
- {
- *sp = gamma_table[*sp];
- *(sp + 1) = gamma_table[*(sp + 1)];
- *(sp + 2) = gamma_table[*(sp + 2)];
- }
- }
- }
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 3)
- {
- if (*sp == trans_values->red &&
- *(sp + 1) == trans_values->green &&
- *(sp + 2) == trans_values->blue)
- {
- *sp = (png_byte)background->red;
- *(sp + 1) = (png_byte)background->green;
- *(sp + 2) = (png_byte)background->blue;
- }
- }
- }
- }
- else /* if (row_info->bit_depth == 16) */
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (gamma_16 != NULL)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 6)
- {
- png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));
- png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3));
- png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5));
- if (r == trans_values->red && g == trans_values->green &&
- b == trans_values->blue)
- {
- /* background is already in screen gamma */
- *sp = (png_byte)((background->red >> 8) & 0xff);
- *(sp + 1) = (png_byte)(background->red & 0xff);
- *(sp + 2) = (png_byte)((background->green >> 8) & 0xff);
- *(sp + 3) = (png_byte)(background->green & 0xff);
- *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff);
- *(sp + 5) = (png_byte)(background->blue & 0xff);
- }
- else
- {
- png_uint_16 v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
- *(sp + 2) = (png_byte)((v >> 8) & 0xff);
- *(sp + 3) = (png_byte)(v & 0xff);
- v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
- *(sp + 4) = (png_byte)((v >> 8) & 0xff);
- *(sp + 5) = (png_byte)(v & 0xff);
- }
- }
- }
- else
-#endif
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp += 6)
- {
- png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp+1));
- png_uint_16 g = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3));
- png_uint_16 b = (png_uint_16)(((*(sp+4)) << 8) + *(sp+5));
-
- if (r == trans_values->red && g == trans_values->green &&
- b == trans_values->blue)
- {
- *sp = (png_byte)((background->red >> 8) & 0xff);
- *(sp + 1) = (png_byte)(background->red & 0xff);
- *(sp + 2) = (png_byte)((background->green >> 8) & 0xff);
- *(sp + 3) = (png_byte)(background->green & 0xff);
- *(sp + 4) = (png_byte)((background->blue >> 8) & 0xff);
- *(sp + 5) = (png_byte)(background->blue & 0xff);
- }
- }
- }
- }
- break;
- }
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- {
- if (row_info->bit_depth == 8)
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (gamma_to_1 != NULL && gamma_from_1 != NULL &&
- gamma_table != NULL)
- {
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++, sp += 2, dp++)
- {
- png_uint_16 a = *(sp + 1);
-
- if (a == 0xff)
- {
- *dp = gamma_table[*sp];
- }
- else if (a == 0)
- {
- /* background is already in screen gamma */
- *dp = (png_byte)background->gray;
- }
- else
- {
- png_byte v, w;
-
- v = gamma_to_1[*sp];
- png_composite(w, v, a, background_1->gray);
- *dp = gamma_from_1[w];
- }
- }
- }
- else
-#endif
- {
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++, sp += 2, dp++)
- {
- png_byte a = *(sp + 1);
-
- if (a == 0xff)
- {
- *dp = *sp;
- }
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- else if (a == 0)
- {
- *dp = (png_byte)background->gray;
- }
- else
- {
- png_composite(*dp, *sp, a, background_1->gray);
- }
-#else
- *dp = (png_byte)background->gray;
-#endif
- }
- }
- }
- else /* if (png_ptr->bit_depth == 16) */
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (gamma_16 != NULL && gamma_16_from_1 != NULL &&
- gamma_16_to_1 != NULL)
- {
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++, sp += 4, dp += 2)
- {
- png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3));
-
- if (a == (png_uint_16)0xffff)
- {
- png_uint_16 v;
-
- v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
- *dp = (png_byte)((v >> 8) & 0xff);
- *(dp + 1) = (png_byte)(v & 0xff);
- }
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- else if (a == 0)
-#else
- else
-#endif
- {
- /* background is already in screen gamma */
- *dp = (png_byte)((background->gray >> 8) & 0xff);
- *(dp + 1) = (png_byte)(background->gray & 0xff);
- }
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- else
- {
- png_uint_16 g, v, w;
-
- g = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
- png_composite_16(v, g, a, background_1->gray);
- w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];
- *dp = (png_byte)((w >> 8) & 0xff);
- *(dp + 1) = (png_byte)(w & 0xff);
- }
-#endif
- }
- }
- else
-#endif
- {
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++, sp += 4, dp += 2)
- {
- png_uint_16 a = (png_uint_16)(((*(sp+2)) << 8) + *(sp+3));
- if (a == (png_uint_16)0xffff)
- {
- png_memcpy(dp, sp, 2);
- }
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- else if (a == 0)
-#else
- else
-#endif
- {
- *dp = (png_byte)((background->gray >> 8) & 0xff);
- *(dp + 1) = (png_byte)(background->gray & 0xff);
- }
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- else
- {
- png_uint_16 g, v;
-
- g = (png_uint_16)(((*sp) << 8) + *(sp + 1));
- png_composite_16(v, g, a, background_1->gray);
- *dp = (png_byte)((v >> 8) & 0xff);
- *(dp + 1) = (png_byte)(v & 0xff);
- }
-#endif
- }
- }
- }
- break;
- }
- case PNG_COLOR_TYPE_RGB_ALPHA:
- {
- if (row_info->bit_depth == 8)
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (gamma_to_1 != NULL && gamma_from_1 != NULL &&
- gamma_table != NULL)
- {
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++, sp += 4, dp += 3)
- {
- png_byte a = *(sp + 3);
-
- if (a == 0xff)
- {
- *dp = gamma_table[*sp];
- *(dp + 1) = gamma_table[*(sp + 1)];
- *(dp + 2) = gamma_table[*(sp + 2)];
- }
- else if (a == 0)
- {
- /* background is already in screen gamma */
- *dp = (png_byte)background->red;
- *(dp + 1) = (png_byte)background->green;
- *(dp + 2) = (png_byte)background->blue;
- }
- else
- {
- png_byte v, w;
-
- v = gamma_to_1[*sp];
- png_composite(w, v, a, background_1->red);
- *dp = gamma_from_1[w];
- v = gamma_to_1[*(sp + 1)];
- png_composite(w, v, a, background_1->green);
- *(dp + 1) = gamma_from_1[w];
- v = gamma_to_1[*(sp + 2)];
- png_composite(w, v, a, background_1->blue);
- *(dp + 2) = gamma_from_1[w];
- }
- }
- }
- else
-#endif
- {
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++, sp += 4, dp += 3)
- {
- png_byte a = *(sp + 3);
-
- if (a == 0xff)
- {
- *dp = *sp;
- *(dp + 1) = *(sp + 1);
- *(dp + 2) = *(sp + 2);
- }
- else if (a == 0)
- {
- *dp = (png_byte)background->red;
- *(dp + 1) = (png_byte)background->green;
- *(dp + 2) = (png_byte)background->blue;
- }
- else
- {
- png_composite(*dp, *sp, a, background->red);
- png_composite(*(dp + 1), *(sp + 1), a,
- background->green);
- png_composite(*(dp + 2), *(sp + 2), a,
- background->blue);
- }
- }
- }
- }
- else /* if (row_info->bit_depth == 16) */
- {
-#if defined(PNG_READ_GAMMA_SUPPORTED)
- if (gamma_16 != NULL && gamma_16_from_1 != NULL &&
- gamma_16_to_1 != NULL)
- {
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++, sp += 8, dp += 6)
- {
- png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))
- << 8) + (png_uint_16)(*(sp + 7)));
- if (a == (png_uint_16)0xffff)
- {
- png_uint_16 v;
-
- v = gamma_16[*(sp + 1) >> gamma_shift][*sp];
- *dp = (png_byte)((v >> 8) & 0xff);
- *(dp + 1) = (png_byte)(v & 0xff);
- v = gamma_16[*(sp + 3) >> gamma_shift][*(sp + 2)];
- *(dp + 2) = (png_byte)((v >> 8) & 0xff);
- *(dp + 3) = (png_byte)(v & 0xff);
- v = gamma_16[*(sp + 5) >> gamma_shift][*(sp + 4)];
- *(dp + 4) = (png_byte)((v >> 8) & 0xff);
- *(dp + 5) = (png_byte)(v & 0xff);
- }
- else if (a == 0)
- {
- /* background is already in screen gamma */
- *dp = (png_byte)((background->red >> 8) & 0xff);
- *(dp + 1) = (png_byte)(background->red & 0xff);
- *(dp + 2) = (png_byte)((background->green >> 8) & 0xff);
- *(dp + 3) = (png_byte)(background->green & 0xff);
- *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff);
- *(dp + 5) = (png_byte)(background->blue & 0xff);
- }
- else
- {
- png_uint_16 v, w, x;
-
- v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
- png_composite_16(w, v, a, background_1->red);
- x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
- *dp = (png_byte)((x >> 8) & 0xff);
- *(dp + 1) = (png_byte)(x & 0xff);
- v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
- png_composite_16(w, v, a, background_1->green);
- x = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >> 8];
- *(dp + 2) = (png_byte)((x >> 8) & 0xff);
- *(dp + 3) = (png_byte)(x & 0xff);
- v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
- png_composite_16(w, v, a, background_1->blue);
- x = gamma_16_from_1[(w & 0xff) >> gamma_shift][w >> 8];
- *(dp + 4) = (png_byte)((x >> 8) & 0xff);
- *(dp + 5) = (png_byte)(x & 0xff);
- }
- }
- }
- else
-#endif
- {
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++, sp += 8, dp += 6)
- {
- png_uint_16 a = (png_uint_16)(((png_uint_16)(*(sp + 6))
- << 8) + (png_uint_16)(*(sp + 7)));
- if (a == (png_uint_16)0xffff)
- {
- png_memcpy(dp, sp, 6);
- }
- else if (a == 0)
- {
- *dp = (png_byte)((background->red >> 8) & 0xff);
- *(dp + 1) = (png_byte)(background->red & 0xff);
- *(dp + 2) = (png_byte)((background->green >> 8) & 0xff);
- *(dp + 3) = (png_byte)(background->green & 0xff);
- *(dp + 4) = (png_byte)((background->blue >> 8) & 0xff);
- *(dp + 5) = (png_byte)(background->blue & 0xff);
- }
- else
- {
- png_uint_16 v;
-
- png_uint_16 r = (png_uint_16)(((*sp) << 8) + *(sp + 1));
- png_uint_16 g = (png_uint_16)(((*(sp + 2)) << 8)
- + *(sp + 3));
- png_uint_16 b = (png_uint_16)(((*(sp + 4)) << 8)
- + *(sp + 5));
-
- png_composite_16(v, r, a, background->red);
- *dp = (png_byte)((v >> 8) & 0xff);
- *(dp + 1) = (png_byte)(v & 0xff);
- png_composite_16(v, g, a, background->green);
- *(dp + 2) = (png_byte)((v >> 8) & 0xff);
- *(dp + 3) = (png_byte)(v & 0xff);
- png_composite_16(v, b, a, background->blue);
- *(dp + 4) = (png_byte)((v >> 8) & 0xff);
- *(dp + 5) = (png_byte)(v & 0xff);
- }
- }
- }
- }
- break;
- }
- }
-
- if (row_info->color_type & PNG_COLOR_MASK_ALPHA)
- {
- row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
- row_info->channels--;
- row_info->pixel_depth = (png_byte)(row_info->channels *
- row_info->bit_depth);
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
- }
-}
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED)
-/* Gamma correct the image, avoiding the alpha channel. Make sure
- * you do this after you deal with the transparency issue on grayscale
- * or RGB images. If your bit depth is 8, use gamma_table, if it
- * is 16, use gamma_16_table and gamma_shift. Build these with
- * build_gamma_table().
- */
-void /* PRIVATE */
-png_do_gamma(png_row_infop row_info, png_bytep row,
- png_bytep gamma_table, png_uint_16pp gamma_16_table,
- int gamma_shift)
-{
- png_bytep sp;
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
-
- png_debug(1, "in png_do_gamma");
- if (
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL &&
-#endif
- ((row_info->bit_depth <= 8 && gamma_table != NULL) ||
- (row_info->bit_depth == 16 && gamma_16_table != NULL)))
- {
- switch (row_info->color_type)
- {
- case PNG_COLOR_TYPE_RGB:
- {
- if (row_info->bit_depth == 8)
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- *sp = gamma_table[*sp];
- sp++;
- *sp = gamma_table[*sp];
- sp++;
- *sp = gamma_table[*sp];
- sp++;
- }
- }
- else /* if (row_info->bit_depth == 16) */
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 v;
-
- v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
- v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
- v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
- }
- }
- break;
- }
- case PNG_COLOR_TYPE_RGB_ALPHA:
- {
- if (row_info->bit_depth == 8)
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- *sp = gamma_table[*sp];
- sp++;
- *sp = gamma_table[*sp];
- sp++;
- *sp = gamma_table[*sp];
- sp++;
- sp++;
- }
- }
- else /* if (row_info->bit_depth == 16) */
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
- v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
- v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 4;
- }
- }
- break;
- }
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- {
- if (row_info->bit_depth == 8)
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- *sp = gamma_table[*sp];
- sp += 2;
- }
- }
- else /* if (row_info->bit_depth == 16) */
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 4;
- }
- }
- break;
- }
- case PNG_COLOR_TYPE_GRAY:
- {
- if (row_info->bit_depth == 2)
- {
- sp = row;
- for (i = 0; i < row_width; i += 4)
- {
- int a = *sp & 0xc0;
- int b = *sp & 0x30;
- int c = *sp & 0x0c;
- int d = *sp & 0x03;
-
- *sp = (png_byte)(
- ((((int)gamma_table[a|(a>>2)|(a>>4)|(a>>6)]) ) & 0xc0)|
- ((((int)gamma_table[(b<<2)|b|(b>>2)|(b>>4)])>>2) & 0x30)|
- ((((int)gamma_table[(c<<4)|(c<<2)|c|(c>>2)])>>4) & 0x0c)|
- ((((int)gamma_table[(d<<6)|(d<<4)|(d<<2)|d])>>6) ));
- sp++;
- }
- }
- if (row_info->bit_depth == 4)
- {
- sp = row;
- for (i = 0; i < row_width; i += 2)
- {
- int msb = *sp & 0xf0;
- int lsb = *sp & 0x0f;
-
- *sp = (png_byte)((((int)gamma_table[msb | (msb >> 4)]) & 0xf0)
- | (((int)gamma_table[(lsb << 4) | lsb]) >> 4));
- sp++;
- }
- }
- else if (row_info->bit_depth == 8)
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- *sp = gamma_table[*sp];
- sp++;
- }
- }
- else if (row_info->bit_depth == 16)
- {
- sp = row;
- for (i = 0; i < row_width; i++)
- {
- png_uint_16 v = gamma_16_table[*(sp + 1) >> gamma_shift][*sp];
- *sp = (png_byte)((v >> 8) & 0xff);
- *(sp + 1) = (png_byte)(v & 0xff);
- sp += 2;
- }
- }
- break;
- }
- }
- }
-}
-#endif
-
-#if defined(PNG_READ_EXPAND_SUPPORTED)
-/* Expands a palette row to an RGB or RGBA row depending
- * upon whether you supply trans and num_trans.
- */
-void /* PRIVATE */
-png_do_expand_palette(png_row_infop row_info, png_bytep row,
- png_colorp palette, png_bytep trans, int num_trans)
-{
- int shift, value;
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
-
- png_debug(1, "in png_do_expand_palette");
- if (
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL &&
-#endif
- row_info->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (row_info->bit_depth < 8)
- {
- switch (row_info->bit_depth)
- {
- case 1:
- {
- sp = row + (png_size_t)((row_width - 1) >> 3);
- dp = row + (png_size_t)row_width - 1;
- shift = 7 - (int)((row_width + 7) & 0x07);
- for (i = 0; i < row_width; i++)
- {
- if ((*sp >> shift) & 0x01)
- *dp = 1;
- else
- *dp = 0;
- if (shift == 7)
- {
- shift = 0;
- sp--;
- }
- else
- shift++;
-
- dp--;
- }
- break;
- }
- case 2:
- {
- sp = row + (png_size_t)((row_width - 1) >> 2);
- dp = row + (png_size_t)row_width - 1;
- shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
- for (i = 0; i < row_width; i++)
- {
- value = (*sp >> shift) & 0x03;
- *dp = (png_byte)value;
- if (shift == 6)
- {
- shift = 0;
- sp--;
- }
- else
- shift += 2;
-
- dp--;
- }
- break;
- }
- case 4:
- {
- sp = row + (png_size_t)((row_width - 1) >> 1);
- dp = row + (png_size_t)row_width - 1;
- shift = (int)((row_width & 0x01) << 2);
- for (i = 0; i < row_width; i++)
- {
- value = (*sp >> shift) & 0x0f;
- *dp = (png_byte)value;
- if (shift == 4)
- {
- shift = 0;
- sp--;
- }
- else
- shift += 4;
-
- dp--;
- }
- break;
- }
- }
- row_info->bit_depth = 8;
- row_info->pixel_depth = 8;
- row_info->rowbytes = row_width;
- }
- switch (row_info->bit_depth)
- {
- case 8:
- {
- if (trans != NULL)
- {
- sp = row + (png_size_t)row_width - 1;
- dp = row + (png_size_t)(row_width << 2) - 1;
-
- for (i = 0; i < row_width; i++)
- {
- if ((int)(*sp) >= num_trans)
- *dp-- = 0xff;
- else
- *dp-- = trans[*sp];
- *dp-- = palette[*sp].blue;
- *dp-- = palette[*sp].green;
- *dp-- = palette[*sp].red;
- sp--;
- }
- row_info->bit_depth = 8;
- row_info->pixel_depth = 32;
- row_info->rowbytes = row_width * 4;
- row_info->color_type = 6;
- row_info->channels = 4;
- }
- else
- {
- sp = row + (png_size_t)row_width - 1;
- dp = row + (png_size_t)(row_width * 3) - 1;
-
- for (i = 0; i < row_width; i++)
- {
- *dp-- = palette[*sp].blue;
- *dp-- = palette[*sp].green;
- *dp-- = palette[*sp].red;
- sp--;
- }
- row_info->bit_depth = 8;
- row_info->pixel_depth = 24;
- row_info->rowbytes = row_width * 3;
- row_info->color_type = 2;
- row_info->channels = 3;
- }
- break;
- }
- }
- }
-}
-
-/* If the bit depth < 8, it is expanded to 8. Also, if the already
- * expanded transparency value is supplied, an alpha channel is built.
- */
-void /* PRIVATE */
-png_do_expand(png_row_infop row_info, png_bytep row,
- png_color_16p trans_value)
-{
- int shift, value;
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
-
- png_debug(1, "in png_do_expand");
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- if (row != NULL && row_info != NULL)
-#endif
- {
- if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
- {
- png_uint_16 gray = (png_uint_16)(trans_value ? trans_value->gray : 0);
-
- if (row_info->bit_depth < 8)
- {
- switch (row_info->bit_depth)
- {
- case 1:
- {
- gray = (png_uint_16)((gray&0x01)*0xff);
- sp = row + (png_size_t)((row_width - 1) >> 3);
- dp = row + (png_size_t)row_width - 1;
- shift = 7 - (int)((row_width + 7) & 0x07);
- for (i = 0; i < row_width; i++)
- {
- if ((*sp >> shift) & 0x01)
- *dp = 0xff;
- else
- *dp = 0;
- if (shift == 7)
- {
- shift = 0;
- sp--;
- }
- else
- shift++;
-
- dp--;
- }
- break;
- }
- case 2:
- {
- gray = (png_uint_16)((gray&0x03)*0x55);
- sp = row + (png_size_t)((row_width - 1) >> 2);
- dp = row + (png_size_t)row_width - 1;
- shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
- for (i = 0; i < row_width; i++)
- {
- value = (*sp >> shift) & 0x03;
- *dp = (png_byte)(value | (value << 2) | (value << 4) |
- (value << 6));
- if (shift == 6)
- {
- shift = 0;
- sp--;
- }
- else
- shift += 2;
-
- dp--;
- }
- break;
- }
- case 4:
- {
- gray = (png_uint_16)((gray&0x0f)*0x11);
- sp = row + (png_size_t)((row_width - 1) >> 1);
- dp = row + (png_size_t)row_width - 1;
- shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
- for (i = 0; i < row_width; i++)
- {
- value = (*sp >> shift) & 0x0f;
- *dp = (png_byte)(value | (value << 4));
- if (shift == 4)
- {
- shift = 0;
- sp--;
- }
- else
- shift = 4;
-
- dp--;
- }
- break;
- }
- }
- row_info->bit_depth = 8;
- row_info->pixel_depth = 8;
- row_info->rowbytes = row_width;
- }
-
- if (trans_value != NULL)
- {
- if (row_info->bit_depth == 8)
- {
- gray = gray & 0xff;
- sp = row + (png_size_t)row_width - 1;
- dp = row + (png_size_t)(row_width << 1) - 1;
- for (i = 0; i < row_width; i++)
- {
- if (*sp == gray)
- *dp-- = 0;
- else
- *dp-- = 0xff;
- *dp-- = *sp--;
- }
- }
- else if (row_info->bit_depth == 16)
- {
- png_byte gray_high = (gray >> 8) & 0xff;
- png_byte gray_low = gray & 0xff;
- sp = row + row_info->rowbytes - 1;
- dp = row + (row_info->rowbytes << 1) - 1;
- for (i = 0; i < row_width; i++)
- {
- if (*(sp - 1) == gray_high && *(sp) == gray_low)
- {
- *dp-- = 0;
- *dp-- = 0;
- }
- else
- {
- *dp-- = 0xff;
- *dp-- = 0xff;
- }
- *dp-- = *sp--;
- *dp-- = *sp--;
- }
- }
- row_info->color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
- row_info->channels = 2;
- row_info->pixel_depth = (png_byte)(row_info->bit_depth << 1);
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth,
- row_width);
- }
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB && trans_value)
- {
- if (row_info->bit_depth == 8)
- {
- png_byte red = trans_value->red & 0xff;
- png_byte green = trans_value->green & 0xff;
- png_byte blue = trans_value->blue & 0xff;
- sp = row + (png_size_t)row_info->rowbytes - 1;
- dp = row + (png_size_t)(row_width << 2) - 1;
- for (i = 0; i < row_width; i++)
- {
- if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)
- *dp-- = 0;
- else
- *dp-- = 0xff;
- *dp-- = *sp--;
- *dp-- = *sp--;
- *dp-- = *sp--;
- }
- }
- else if (row_info->bit_depth == 16)
- {
- png_byte red_high = (trans_value->red >> 8) & 0xff;
- png_byte green_high = (trans_value->green >> 8) & 0xff;
- png_byte blue_high = (trans_value->blue >> 8) & 0xff;
- png_byte red_low = trans_value->red & 0xff;
- png_byte green_low = trans_value->green & 0xff;
- png_byte blue_low = trans_value->blue & 0xff;
- sp = row + row_info->rowbytes - 1;
- dp = row + (png_size_t)(row_width << 3) - 1;
- for (i = 0; i < row_width; i++)
- {
- if (*(sp - 5) == red_high &&
- *(sp - 4) == red_low &&
- *(sp - 3) == green_high &&
- *(sp - 2) == green_low &&
- *(sp - 1) == blue_high &&
- *(sp ) == blue_low)
- {
- *dp-- = 0;
- *dp-- = 0;
- }
- else
- {
- *dp-- = 0xff;
- *dp-- = 0xff;
- }
- *dp-- = *sp--;
- *dp-- = *sp--;
- *dp-- = *sp--;
- *dp-- = *sp--;
- *dp-- = *sp--;
- *dp-- = *sp--;
- }
- }
- row_info->color_type = PNG_COLOR_TYPE_RGB_ALPHA;
- row_info->channels = 4;
- row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
- }
-}
-#endif
-
-#if defined(PNG_READ_DITHER_SUPPORTED)
-void /* PRIVATE */
-png_do_dither(png_row_infop row_info, png_bytep row,
- png_bytep palette_lookup, png_bytep dither_lookup)
-{
- png_bytep sp, dp;
- png_uint_32 i;
- png_uint_32 row_width=row_info->width;
-
- png_debug(1, "in png_do_dither");
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- if (row != NULL && row_info != NULL)
-#endif
- {
- if (row_info->color_type == PNG_COLOR_TYPE_RGB &&
- palette_lookup && row_info->bit_depth == 8)
- {
- int r, g, b, p;
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++)
- {
- r = *sp++;
- g = *sp++;
- b = *sp++;
-
- /* this looks real messy, but the compiler will reduce
- it down to a reasonable formula. For example, with
- 5 bits per color, we get:
- p = (((r >> 3) & 0x1f) << 10) |
- (((g >> 3) & 0x1f) << 5) |
- ((b >> 3) & 0x1f);
- */
- p = (((r >> (8 - PNG_DITHER_RED_BITS)) &
- ((1 << PNG_DITHER_RED_BITS) - 1)) <<
- (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) |
- (((g >> (8 - PNG_DITHER_GREEN_BITS)) &
- ((1 << PNG_DITHER_GREEN_BITS) - 1)) <<
- (PNG_DITHER_BLUE_BITS)) |
- ((b >> (8 - PNG_DITHER_BLUE_BITS)) &
- ((1 << PNG_DITHER_BLUE_BITS) - 1));
-
- *dp++ = palette_lookup[p];
- }
- row_info->color_type = PNG_COLOR_TYPE_PALETTE;
- row_info->channels = 1;
- row_info->pixel_depth = row_info->bit_depth;
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
- palette_lookup != NULL && row_info->bit_depth == 8)
- {
- int r, g, b, p;
- sp = row;
- dp = row;
- for (i = 0; i < row_width; i++)
- {
- r = *sp++;
- g = *sp++;
- b = *sp++;
- sp++;
-
- p = (((r >> (8 - PNG_DITHER_RED_BITS)) &
- ((1 << PNG_DITHER_RED_BITS) - 1)) <<
- (PNG_DITHER_GREEN_BITS + PNG_DITHER_BLUE_BITS)) |
- (((g >> (8 - PNG_DITHER_GREEN_BITS)) &
- ((1 << PNG_DITHER_GREEN_BITS) - 1)) <<
- (PNG_DITHER_BLUE_BITS)) |
- ((b >> (8 - PNG_DITHER_BLUE_BITS)) &
- ((1 << PNG_DITHER_BLUE_BITS) - 1));
-
- *dp++ = palette_lookup[p];
- }
- row_info->color_type = PNG_COLOR_TYPE_PALETTE;
- row_info->channels = 1;
- row_info->pixel_depth = row_info->bit_depth;
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
- dither_lookup && row_info->bit_depth == 8)
- {
- sp = row;
- for (i = 0; i < row_width; i++, sp++)
- {
- *sp = dither_lookup[*sp];
- }
- }
- }
-}
-#endif
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-#if defined(PNG_READ_GAMMA_SUPPORTED)
-static PNG_CONST int png_gamma_shift[] =
- {0x10, 0x21, 0x42, 0x84, 0x110, 0x248, 0x550, 0xff0, 0x00};
-
-/* We build the 8- or 16-bit gamma tables here. Note that for 16-bit
- * tables, we don't make a full table if we are reducing to 8-bit in
- * the future. Note also how the gamma_16 tables are segmented so that
- * we don't need to allocate > 64K chunks for a full 16-bit table.
- */
-void /* PRIVATE */
-png_build_gamma_table(png_structp png_ptr)
-{
- png_debug(1, "in png_build_gamma_table");
-
- if (png_ptr->bit_depth <= 8)
- {
- int i;
- double g;
-
- if (png_ptr->screen_gamma > .000001)
- g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
- else
- g = 1.0;
-
- png_ptr->gamma_table = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)256);
-
- for (i = 0; i < 256; i++)
- {
- png_ptr->gamma_table[i] = (png_byte)(pow((double)i / 255.0,
- g) * 255.0 + .5);
- }
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
- defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- if (png_ptr->transformations & ((PNG_BACKGROUND) | PNG_RGB_TO_GRAY))
- {
-
- g = 1.0 / (png_ptr->gamma);
-
- png_ptr->gamma_to_1 = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)256);
-
- for (i = 0; i < 256; i++)
- {
- png_ptr->gamma_to_1[i] = (png_byte)(pow((double)i / 255.0,
- g) * 255.0 + .5);
- }
-
-
- png_ptr->gamma_from_1 = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)256);
-
- if (png_ptr->screen_gamma > 0.000001)
- g = 1.0 / png_ptr->screen_gamma;
- else
- g = png_ptr->gamma; /* probably doing rgb_to_gray */
-
- for (i = 0; i < 256; i++)
- {
- png_ptr->gamma_from_1[i] = (png_byte)(pow((double)i / 255.0,
- g) * 255.0 + .5);
-
- }
- }
-#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */
- }
- else
- {
- double g;
- int i, j, shift, num;
- int sig_bit;
- png_uint_32 ig;
-
- if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
- {
- sig_bit = (int)png_ptr->sig_bit.red;
- if ((int)png_ptr->sig_bit.green > sig_bit)
- sig_bit = png_ptr->sig_bit.green;
- if ((int)png_ptr->sig_bit.blue > sig_bit)
- sig_bit = png_ptr->sig_bit.blue;
- }
- else
- {
- sig_bit = (int)png_ptr->sig_bit.gray;
- }
-
- if (sig_bit > 0)
- shift = 16 - sig_bit;
- else
- shift = 0;
-
- if (png_ptr->transformations & PNG_16_TO_8)
- {
- if (shift < (16 - PNG_MAX_GAMMA_8))
- shift = (16 - PNG_MAX_GAMMA_8);
- }
-
- if (shift > 8)
- shift = 8;
- if (shift < 0)
- shift = 0;
-
- png_ptr->gamma_shift = (png_byte)shift;
-
- num = (1 << (8 - shift));
-
- if (png_ptr->screen_gamma > .000001)
- g = 1.0 / (png_ptr->gamma * png_ptr->screen_gamma);
- else
- g = 1.0;
-
- png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
- (png_uint_32)(num * png_sizeof(png_uint_16p)));
- png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p));
-
- if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
- {
- double fin, fout;
- png_uint_32 last, max;
-
- for (i = 0; i < num; i++)
- {
- png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
- (png_uint_32)(256 * png_sizeof(png_uint_16)));
- }
-
- g = 1.0 / g;
- last = 0;
- for (i = 0; i < 256; i++)
- {
- fout = ((double)i + 0.5) / 256.0;
- fin = pow(fout, g);
- max = (png_uint_32)(fin * (double)((png_uint_32)num << 8));
- while (last <= max)
- {
- png_ptr->gamma_16_table[(int)(last & (0xff >> shift))]
- [(int)(last >> (8 - shift))] = (png_uint_16)(
- (png_uint_16)i | ((png_uint_16)i << 8));
- last++;
- }
- }
- while (last < ((png_uint_32)num << 8))
- {
- png_ptr->gamma_16_table[(int)(last & (0xff >> shift))]
- [(int)(last >> (8 - shift))] = (png_uint_16)65535L;
- last++;
- }
- }
- else
- {
- for (i = 0; i < num; i++)
- {
- png_ptr->gamma_16_table[i] = (png_uint_16p)png_malloc(png_ptr,
- (png_uint_32)(256 * png_sizeof(png_uint_16)));
-
- ig = (((png_uint_32)i * (png_uint_32)png_gamma_shift[shift]) >> 4);
- for (j = 0; j < 256; j++)
- {
- png_ptr->gamma_16_table[i][j] =
- (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) /
- 65535.0, g) * 65535.0 + .5);
- }
- }
- }
-
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
- defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
- if (png_ptr->transformations & (PNG_BACKGROUND | PNG_RGB_TO_GRAY))
- {
-
- g = 1.0 / (png_ptr->gamma);
-
- png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
- (png_uint_32)(num * png_sizeof(png_uint_16p )));
- png_memset(png_ptr->gamma_16_to_1, 0, num * png_sizeof(png_uint_16p));
-
- for (i = 0; i < num; i++)
- {
- png_ptr->gamma_16_to_1[i] = (png_uint_16p)png_malloc(png_ptr,
- (png_uint_32)(256 * png_sizeof(png_uint_16)));
-
- ig = (((png_uint_32)i *
- (png_uint_32)png_gamma_shift[shift]) >> 4);
- for (j = 0; j < 256; j++)
- {
- png_ptr->gamma_16_to_1[i][j] =
- (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) /
- 65535.0, g) * 65535.0 + .5);
- }
- }
-
- if (png_ptr->screen_gamma > 0.000001)
- g = 1.0 / png_ptr->screen_gamma;
- else
- g = png_ptr->gamma; /* probably doing rgb_to_gray */
-
- png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
- (png_uint_32)(num * png_sizeof(png_uint_16p)));
- png_memset(png_ptr->gamma_16_from_1, 0,
- num * png_sizeof(png_uint_16p));
-
- for (i = 0; i < num; i++)
- {
- png_ptr->gamma_16_from_1[i] = (png_uint_16p)png_malloc(png_ptr,
- (png_uint_32)(256 * png_sizeof(png_uint_16)));
-
- ig = (((png_uint_32)i *
- (png_uint_32)png_gamma_shift[shift]) >> 4);
- for (j = 0; j < 256; j++)
- {
- png_ptr->gamma_16_from_1[i][j] =
- (png_uint_16)(pow((double)(ig + ((png_uint_32)j << 8)) /
- 65535.0, g) * 65535.0 + .5);
- }
- }
- }
-#endif /* PNG_READ_BACKGROUND_SUPPORTED || PNG_RGB_TO_GRAY_SUPPORTED */
- }
-}
-#endif
-/* To do: install integer version of png_build_gamma_table here */
-#endif
-
-#if defined(PNG_MNG_FEATURES_SUPPORTED)
-/* undoes intrapixel differencing */
-void /* PRIVATE */
-png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_read_intrapixel");
- if (
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL &&
-#endif
- (row_info->color_type & PNG_COLOR_MASK_COLOR))
- {
- int bytes_per_pixel;
- png_uint_32 row_width = row_info->width;
- if (row_info->bit_depth == 8)
- {
- png_bytep rp;
- png_uint_32 i;
-
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- bytes_per_pixel = 3;
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- bytes_per_pixel = 4;
- else
- return;
-
- for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
- {
- *(rp) = (png_byte)((256 + *rp + *(rp+1))&0xff);
- *(rp+2) = (png_byte)((256 + *(rp+2) + *(rp+1))&0xff);
- }
- }
- else if (row_info->bit_depth == 16)
- {
- png_bytep rp;
- png_uint_32 i;
-
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- bytes_per_pixel = 6;
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- bytes_per_pixel = 8;
- else
- return;
-
- for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
- {
- png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
- png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
- png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
- png_uint_32 red = (png_uint_32)((s0 + s1 + 65536L) & 0xffffL);
- png_uint_32 blue = (png_uint_32)((s2 + s1 + 65536L) & 0xffffL);
- *(rp ) = (png_byte)((red >> 8) & 0xff);
- *(rp+1) = (png_byte)(red & 0xff);
- *(rp+4) = (png_byte)((blue >> 8) & 0xff);
- *(rp+5) = (png_byte)(blue & 0xff);
- }
- }
- }
-}
-#endif /* PNG_MNG_FEATURES_SUPPORTED */
-#endif /* PNG_READ_SUPPORTED */
diff --git a/navit/support/libpng/pngrutil.c b/navit/support/libpng/pngrutil.c
deleted file mode 100644
index f6f98598f..000000000
--- a/navit/support/libpng/pngrutil.c
+++ /dev/null
@@ -1,3223 +0,0 @@
-
-/* pngrutil.c - utilities to read a PNG file
- *
- * Last changed in libpng 1.2.36 [May 7, 2009]
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2009 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * This file contains routines that are only called from within
- * libpng itself during the course of reading an image.
- */
-
-#define PNG_INTERNAL
-#include "png.h"
-#if defined(PNG_READ_SUPPORTED)
-
-#if defined(_WIN32_WCE) && (_WIN32_WCE<0x500)
-# define WIN32_WCE_OLD
-#endif
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-# if defined(WIN32_WCE_OLD)
-/* strtod() function is not supported on WindowsCE */
-__inline double png_strtod(png_structp png_ptr, PNG_CONST char *nptr, char **endptr)
-{
- double result = 0;
- int len;
- wchar_t *str, *end;
-
- len = MultiByteToWideChar(CP_ACP, 0, nptr, -1, NULL, 0);
- str = (wchar_t *)png_malloc(png_ptr, len * png_sizeof(wchar_t));
- if ( NULL != str )
- {
- MultiByteToWideChar(CP_ACP, 0, nptr, -1, str, len);
- result = wcstod(str, &end);
- len = WideCharToMultiByte(CP_ACP, 0, end, -1, NULL, 0, NULL, NULL);
- *endptr = (char *)nptr + (png_strlen(nptr) - len + 1);
- png_free(png_ptr, str);
- }
- return result;
-}
-# else
-# define png_strtod(p,a,b) strtod(a,b)
-# endif
-#endif
-
-png_uint_32 PNGAPI
-png_get_uint_31(png_structp png_ptr, png_bytep buf)
-{
-#ifdef PNG_READ_BIG_ENDIAN_SUPPORTED
- png_uint_32 i = png_get_uint_32(buf);
-#else
- /* Avoid an extra function call by inlining the result. */
- png_uint_32 i = ((png_uint_32)(*buf) << 24) +
- ((png_uint_32)(*(buf + 1)) << 16) +
- ((png_uint_32)(*(buf + 2)) << 8) +
- (png_uint_32)(*(buf + 3));
-#endif
- if (i > PNG_UINT_31_MAX)
- png_error(png_ptr, "PNG unsigned integer out of range.");
- return (i);
-}
-#ifndef PNG_READ_BIG_ENDIAN_SUPPORTED
-/* Grab an unsigned 32-bit integer from a buffer in big-endian format. */
-png_uint_32 PNGAPI
-png_get_uint_32(png_bytep buf)
-{
- png_uint_32 i = ((png_uint_32)(*buf) << 24) +
- ((png_uint_32)(*(buf + 1)) << 16) +
- ((png_uint_32)(*(buf + 2)) << 8) +
- (png_uint_32)(*(buf + 3));
-
- return (i);
-}
-
-/* Grab a signed 32-bit integer from a buffer in big-endian format. The
- * data is stored in the PNG file in two's complement format, and it is
- * assumed that the machine format for signed integers is the same. */
-png_int_32 PNGAPI
-png_get_int_32(png_bytep buf)
-{
- png_int_32 i = ((png_int_32)(*buf) << 24) +
- ((png_int_32)(*(buf + 1)) << 16) +
- ((png_int_32)(*(buf + 2)) << 8) +
- (png_int_32)(*(buf + 3));
-
- return (i);
-}
-
-/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
-png_uint_16 PNGAPI
-png_get_uint_16(png_bytep buf)
-{
- png_uint_16 i = (png_uint_16)(((png_uint_16)(*buf) << 8) +
- (png_uint_16)(*(buf + 1)));
-
- return (i);
-}
-#endif /* PNG_READ_BIG_ENDIAN_SUPPORTED */
-
-/* Read the chunk header (length + type name).
- * Put the type name into png_ptr->chunk_name, and return the length.
- */
-png_uint_32 /* PRIVATE */
-png_read_chunk_header(png_structp png_ptr)
-{
- png_byte buf[8];
- png_uint_32 length;
-
- /* read the length and the chunk name */
- png_read_data(png_ptr, buf, 8);
- length = png_get_uint_31(png_ptr, buf);
-
- /* put the chunk name into png_ptr->chunk_name */
- png_memcpy(png_ptr->chunk_name, buf + 4, 4);
-
- png_debug2(0, "Reading %s chunk, length = %lu",
- png_ptr->chunk_name, length);
-
- /* reset the crc and run it over the chunk name */
- png_reset_crc(png_ptr);
- png_calculate_crc(png_ptr, png_ptr->chunk_name, 4);
-
- /* check to see if chunk name is valid */
- png_check_chunk_name(png_ptr, png_ptr->chunk_name);
-
- return length;
-}
-
-/* Read data, and (optionally) run it through the CRC. */
-void /* PRIVATE */
-png_crc_read(png_structp png_ptr, png_bytep buf, png_size_t length)
-{
- if (png_ptr == NULL) return;
- png_read_data(png_ptr, buf, length);
- png_calculate_crc(png_ptr, buf, length);
-}
-
-/* Optionally skip data and then check the CRC. Depending on whether we
- are reading a ancillary or critical chunk, and how the program has set
- things up, we may calculate the CRC on the data and print a message.
- Returns '1' if there was a CRC error, '0' otherwise. */
-int /* PRIVATE */
-png_crc_finish(png_structp png_ptr, png_uint_32 skip)
-{
- png_size_t i;
- png_size_t istop = png_ptr->zbuf_size;
-
- for (i = (png_size_t)skip; i > istop; i -= istop)
- {
- png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zbuf_size);
- }
- if (i)
- {
- png_crc_read(png_ptr, png_ptr->zbuf, i);
- }
-
- if (png_crc_error(png_ptr))
- {
- if (((png_ptr->chunk_name[0] & 0x20) && /* Ancillary */
- !(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)) ||
- (!(png_ptr->chunk_name[0] & 0x20) && /* Critical */
- (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE)))
- {
- png_chunk_warning(png_ptr, "CRC error");
- }
- else
- {
- png_chunk_error(png_ptr, "CRC error");
- }
- return (1);
- }
-
- return (0);
-}
-
-/* Compare the CRC stored in the PNG file with that calculated by libpng from
- the data it has read thus far. */
-int /* PRIVATE */
-png_crc_error(png_structp png_ptr)
-{
- png_byte crc_bytes[4];
- png_uint_32 crc;
- int need_crc = 1;
-
- if (png_ptr->chunk_name[0] & 0x20) /* ancillary */
- {
- if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
- (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
- need_crc = 0;
- }
- else /* critical */
- {
- if (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE)
- need_crc = 0;
- }
-
- png_read_data(png_ptr, crc_bytes, 4);
-
- if (need_crc)
- {
- crc = png_get_uint_32(crc_bytes);
- return ((int)(crc != png_ptr->crc));
- }
- else
- return (0);
-}
-
-#if defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) || \
- defined(PNG_READ_iCCP_SUPPORTED)
-/*
- * Decompress trailing data in a chunk. The assumption is that chunkdata
- * points at an allocated area holding the contents of a chunk with a
- * trailing compressed part. What we get back is an allocated area
- * holding the original prefix part and an uncompressed version of the
- * trailing part (the malloc area passed in is freed).
- */
-void /* PRIVATE */
-png_decompress_chunk(png_structp png_ptr, int comp_type,
- png_size_t chunklength,
- png_size_t prefix_size, png_size_t *newlength)
-{
- static PNG_CONST char msg[] = "Error decoding compressed text";
- png_charp text;
- png_size_t text_size;
-
- if (comp_type == PNG_COMPRESSION_TYPE_BASE)
- {
- int ret = Z_OK;
- png_ptr->zstream.next_in = (png_bytep)(png_ptr->chunkdata + prefix_size);
- png_ptr->zstream.avail_in = (uInt)(chunklength - prefix_size);
- png_ptr->zstream.next_out = png_ptr->zbuf;
- png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
-
- text_size = 0;
- text = NULL;
-
- while (png_ptr->zstream.avail_in)
- {
- ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
- if (ret != Z_OK && ret != Z_STREAM_END)
- {
- if (png_ptr->zstream.msg != NULL)
- png_warning(png_ptr, png_ptr->zstream.msg);
- else
- png_warning(png_ptr, msg);
- inflateReset(&png_ptr->zstream);
- png_ptr->zstream.avail_in = 0;
-
- if (text == NULL)
- {
- text_size = prefix_size + png_sizeof(msg) + 1;
- text = (png_charp)png_malloc_warn(png_ptr, text_size);
- if (text == NULL)
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_error(png_ptr, "Not enough memory to decompress chunk");
- }
- png_memcpy(text, png_ptr->chunkdata, prefix_size);
- }
-
- text[text_size - 1] = 0x00;
-
- /* Copy what we can of the error message into the text chunk */
- text_size = (png_size_t)(chunklength -
- (text - png_ptr->chunkdata) - 1);
- if (text_size > png_sizeof(msg))
- text_size = png_sizeof(msg);
- png_memcpy(text + prefix_size, msg, text_size);
- break;
- }
- if (!png_ptr->zstream.avail_out || ret == Z_STREAM_END)
- {
- if (text == NULL)
- {
- text_size = prefix_size +
- png_ptr->zbuf_size - png_ptr->zstream.avail_out;
- text = (png_charp)png_malloc_warn(png_ptr, text_size + 1);
- if (text == NULL)
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_error(png_ptr,
- "Not enough memory to decompress chunk.");
- }
- png_memcpy(text + prefix_size, png_ptr->zbuf,
- text_size - prefix_size);
- png_memcpy(text, png_ptr->chunkdata, prefix_size);
- *(text + text_size) = 0x00;
- }
- else
- {
- png_charp tmp;
-
- tmp = text;
- text = (png_charp)png_malloc_warn(png_ptr,
- (png_uint_32)(text_size +
- png_ptr->zbuf_size - png_ptr->zstream.avail_out + 1));
- if (text == NULL)
- {
- png_free(png_ptr, tmp);
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_error(png_ptr,
- "Not enough memory to decompress chunk..");
- }
- png_memcpy(text, tmp, text_size);
- png_free(png_ptr, tmp);
- png_memcpy(text + text_size, png_ptr->zbuf,
- (png_ptr->zbuf_size - png_ptr->zstream.avail_out));
- text_size += png_ptr->zbuf_size - png_ptr->zstream.avail_out;
- *(text + text_size) = 0x00;
- }
- if (ret == Z_STREAM_END)
- break;
- else
- {
- png_ptr->zstream.next_out = png_ptr->zbuf;
- png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
- }
- }
- }
- if (ret != Z_STREAM_END)
- {
-#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
- char umsg[52];
-
- if (ret == Z_BUF_ERROR)
- png_snprintf(umsg, 52,
- "Buffer error in compressed datastream in %s chunk",
- png_ptr->chunk_name);
- else if (ret == Z_DATA_ERROR)
- png_snprintf(umsg, 52,
- "Data error in compressed datastream in %s chunk",
- png_ptr->chunk_name);
- else
- png_snprintf(umsg, 52,
- "Incomplete compressed datastream in %s chunk",
- png_ptr->chunk_name);
- png_warning(png_ptr, umsg);
-#else
- png_warning(png_ptr,
- "Incomplete compressed datastream in chunk other than IDAT");
-#endif
- text_size = prefix_size;
- if (text == NULL)
- {
- text = (png_charp)png_malloc_warn(png_ptr, text_size+1);
- if (text == NULL)
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_error(png_ptr, "Not enough memory for text.");
- }
- png_memcpy(text, png_ptr->chunkdata, prefix_size);
- }
- *(text + text_size) = 0x00;
- }
-
- inflateReset(&png_ptr->zstream);
- png_ptr->zstream.avail_in = 0;
-
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = text;
- *newlength=text_size;
- }
- else /* if (comp_type != PNG_COMPRESSION_TYPE_BASE) */
- {
-#if !defined(PNG_NO_STDIO) && !defined(_WIN32_WCE)
- char umsg[50];
-
- png_snprintf(umsg, 50, "Unknown zTXt compression type %d", comp_type);
- png_warning(png_ptr, umsg);
-#else
- png_warning(png_ptr, "Unknown zTXt compression type");
-#endif
-
- *(png_ptr->chunkdata + prefix_size) = 0x00;
- *newlength = prefix_size;
- }
-}
-#endif
-
-/* read and check the IDHR chunk */
-void /* PRIVATE */
-png_handle_IHDR(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_byte buf[13];
- png_uint_32 width, height;
- int bit_depth, color_type, compression_type, filter_type;
- int interlace_type;
-
- png_debug(1, "in png_handle_IHDR");
-
- if (png_ptr->mode & PNG_HAVE_IHDR)
- png_error(png_ptr, "Out of place IHDR");
-
- /* check the length */
- if (length != 13)
- png_error(png_ptr, "Invalid IHDR chunk");
-
- png_ptr->mode |= PNG_HAVE_IHDR;
-
- png_crc_read(png_ptr, buf, 13);
- png_crc_finish(png_ptr, 0);
-
- width = png_get_uint_31(png_ptr, buf);
- height = png_get_uint_31(png_ptr, buf + 4);
- bit_depth = buf[8];
- color_type = buf[9];
- compression_type = buf[10];
- filter_type = buf[11];
- interlace_type = buf[12];
-
- /* set internal variables */
- png_ptr->width = width;
- png_ptr->height = height;
- png_ptr->bit_depth = (png_byte)bit_depth;
- png_ptr->interlaced = (png_byte)interlace_type;
- png_ptr->color_type = (png_byte)color_type;
-#if defined(PNG_MNG_FEATURES_SUPPORTED)
- png_ptr->filter_type = (png_byte)filter_type;
-#endif
- png_ptr->compression_type = (png_byte)compression_type;
-
- /* find number of channels */
- switch (png_ptr->color_type)
- {
- case PNG_COLOR_TYPE_GRAY:
- case PNG_COLOR_TYPE_PALETTE:
- png_ptr->channels = 1;
- break;
- case PNG_COLOR_TYPE_RGB:
- png_ptr->channels = 3;
- break;
- case PNG_COLOR_TYPE_GRAY_ALPHA:
- png_ptr->channels = 2;
- break;
- case PNG_COLOR_TYPE_RGB_ALPHA:
- png_ptr->channels = 4;
- break;
- }
-
- /* set up other useful info */
- png_ptr->pixel_depth = (png_byte)(png_ptr->bit_depth *
- png_ptr->channels);
- png_ptr->rowbytes = PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->width);
- png_debug1(3, "bit_depth = %d", png_ptr->bit_depth);
- png_debug1(3, "channels = %d", png_ptr->channels);
- png_debug1(3, "rowbytes = %lu", png_ptr->rowbytes);
- png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
- color_type, interlace_type, compression_type, filter_type);
-}
-
-/* read and check the palette */
-void /* PRIVATE */
-png_handle_PLTE(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_color palette[PNG_MAX_PALETTE_LENGTH];
- int num, i;
-#ifndef PNG_NO_POINTER_INDEXING
- png_colorp pal_ptr;
-#endif
-
- png_debug(1, "in png_handle_PLTE");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before PLTE");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid PLTE after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (png_ptr->mode & PNG_HAVE_PLTE)
- png_error(png_ptr, "Duplicate PLTE chunk");
-
- png_ptr->mode |= PNG_HAVE_PLTE;
-
- if (!(png_ptr->color_type&PNG_COLOR_MASK_COLOR))
- {
- png_warning(png_ptr,
- "Ignoring PLTE chunk in grayscale PNG");
- png_crc_finish(png_ptr, length);
- return;
- }
-#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
- if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
- {
- png_crc_finish(png_ptr, length);
- return;
- }
-#endif
-
- if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3)
- {
- if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
- {
- png_warning(png_ptr, "Invalid palette chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
- else
- {
- png_error(png_ptr, "Invalid palette chunk");
- }
- }
-
- num = (int)length / 3;
-
-#ifndef PNG_NO_POINTER_INDEXING
- for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)
- {
- png_byte buf[3];
-
- png_crc_read(png_ptr, buf, 3);
- pal_ptr->red = buf[0];
- pal_ptr->green = buf[1];
- pal_ptr->blue = buf[2];
- }
-#else
- for (i = 0; i < num; i++)
- {
- png_byte buf[3];
-
- png_crc_read(png_ptr, buf, 3);
- /* don't depend upon png_color being any order */
- palette[i].red = buf[0];
- palette[i].green = buf[1];
- palette[i].blue = buf[2];
- }
-#endif
-
- /* If we actually NEED the PLTE chunk (ie for a paletted image), we do
- whatever the normal CRC configuration tells us. However, if we
- have an RGB image, the PLTE can be considered ancillary, so
- we will act as though it is. */
-#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
-#endif
- {
- png_crc_finish(png_ptr, 0);
- }
-#if !defined(PNG_READ_OPT_PLTE_SUPPORTED)
- else if (png_crc_error(png_ptr)) /* Only if we have a CRC error */
- {
- /* If we don't want to use the data from an ancillary chunk,
- we have two options: an error abort, or a warning and we
- ignore the data in this chunk (which should be OK, since
- it's considered ancillary for a RGB or RGBA image). */
- if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE))
- {
- if (png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN)
- {
- png_chunk_error(png_ptr, "CRC error");
- }
- else
- {
- png_chunk_warning(png_ptr, "CRC error");
- return;
- }
- }
- /* Otherwise, we (optionally) emit a warning and use the chunk. */
- else if (!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN))
- {
- png_chunk_warning(png_ptr, "CRC error");
- }
- }
-#endif
-
- png_set_PLTE(png_ptr, info_ptr, palette, num);
-
-#if defined(PNG_READ_tRNS_SUPPORTED)
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
- {
- if (png_ptr->num_trans > (png_uint_16)num)
- {
- png_warning(png_ptr, "Truncating incorrect tRNS chunk length");
- png_ptr->num_trans = (png_uint_16)num;
- }
- if (info_ptr->num_trans > (png_uint_16)num)
- {
- png_warning(png_ptr, "Truncating incorrect info tRNS chunk length");
- info_ptr->num_trans = (png_uint_16)num;
- }
- }
- }
-#endif
-
-}
-
-void /* PRIVATE */
-png_handle_IEND(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_debug(1, "in png_handle_IEND");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR) || !(png_ptr->mode & PNG_HAVE_IDAT))
- {
- png_error(png_ptr, "No image in file");
- }
-
- png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND);
-
- if (length != 0)
- {
- png_warning(png_ptr, "Incorrect IEND chunk length");
- }
- png_crc_finish(png_ptr, length);
-
- info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
-}
-
-#if defined(PNG_READ_gAMA_SUPPORTED)
-void /* PRIVATE */
-png_handle_gAMA(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_fixed_point igamma;
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- float file_gamma;
-#endif
- png_byte buf[4];
-
- png_debug(1, "in png_handle_gAMA");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before gAMA");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid gAMA after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (png_ptr->mode & PNG_HAVE_PLTE)
- /* Should be an error, but we can cope with it */
- png_warning(png_ptr, "Out of place gAMA chunk");
-
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA)
-#if defined(PNG_READ_sRGB_SUPPORTED)
- && !(info_ptr->valid & PNG_INFO_sRGB)
-#endif
- )
- {
- png_warning(png_ptr, "Duplicate gAMA chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (length != 4)
- {
- png_warning(png_ptr, "Incorrect gAMA chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, buf, 4);
- if (png_crc_finish(png_ptr, 0))
- return;
-
- igamma = (png_fixed_point)png_get_uint_32(buf);
- /* check for zero gamma */
- if (igamma == 0)
- {
- png_warning(png_ptr,
- "Ignoring gAMA chunk with gamma=0");
- return;
- }
-
-#if defined(PNG_READ_sRGB_SUPPORTED)
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
- if (PNG_OUT_OF_RANGE(igamma, 45500L, 500))
- {
- png_warning(png_ptr,
- "Ignoring incorrect gAMA value when sRGB is also present");
-#ifndef PNG_NO_CONSOLE_IO
- fprintf(stderr, "gamma = (%d/100000)", (int)igamma);
-#endif
- return;
- }
-#endif /* PNG_READ_sRGB_SUPPORTED */
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- file_gamma = (float)igamma / (float)100000.0;
-# ifdef PNG_READ_GAMMA_SUPPORTED
- png_ptr->gamma = file_gamma;
-# endif
- png_set_gAMA(png_ptr, info_ptr, file_gamma);
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
- png_set_gAMA_fixed(png_ptr, info_ptr, igamma);
-#endif
-}
-#endif
-
-#if defined(PNG_READ_sBIT_SUPPORTED)
-void /* PRIVATE */
-png_handle_sBIT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_size_t truelen;
- png_byte buf[4];
-
- png_debug(1, "in png_handle_sBIT");
-
- buf[0] = buf[1] = buf[2] = buf[3] = 0;
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before sBIT");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid sBIT after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (png_ptr->mode & PNG_HAVE_PLTE)
- {
- /* Should be an error, but we can cope with it */
- png_warning(png_ptr, "Out of place sBIT chunk");
- }
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT))
- {
- png_warning(png_ptr, "Duplicate sBIT chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- truelen = 3;
- else
- truelen = (png_size_t)png_ptr->channels;
-
- if (length != truelen || length > 4)
- {
- png_warning(png_ptr, "Incorrect sBIT chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, buf, truelen);
- if (png_crc_finish(png_ptr, 0))
- return;
-
- if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
- {
- png_ptr->sig_bit.red = buf[0];
- png_ptr->sig_bit.green = buf[1];
- png_ptr->sig_bit.blue = buf[2];
- png_ptr->sig_bit.alpha = buf[3];
- }
- else
- {
- png_ptr->sig_bit.gray = buf[0];
- png_ptr->sig_bit.red = buf[0];
- png_ptr->sig_bit.green = buf[0];
- png_ptr->sig_bit.blue = buf[0];
- png_ptr->sig_bit.alpha = buf[1];
- }
- png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit));
-}
-#endif
-
-#if defined(PNG_READ_cHRM_SUPPORTED)
-void /* PRIVATE */
-png_handle_cHRM(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_byte buf[32];
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
-#endif
- png_fixed_point int_x_white, int_y_white, int_x_red, int_y_red, int_x_green,
- int_y_green, int_x_blue, int_y_blue;
-
- png_uint_32 uint_x, uint_y;
-
- png_debug(1, "in png_handle_cHRM");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before cHRM");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid cHRM after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (png_ptr->mode & PNG_HAVE_PLTE)
- /* Should be an error, but we can cope with it */
- png_warning(png_ptr, "Missing PLTE before cHRM");
-
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM)
-#if defined(PNG_READ_sRGB_SUPPORTED)
- && !(info_ptr->valid & PNG_INFO_sRGB)
-#endif
- )
- {
- png_warning(png_ptr, "Duplicate cHRM chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (length != 32)
- {
- png_warning(png_ptr, "Incorrect cHRM chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, buf, 32);
- if (png_crc_finish(png_ptr, 0))
- return;
-
- uint_x = png_get_uint_32(buf);
- uint_y = png_get_uint_32(buf + 4);
- int_x_white = (png_fixed_point)uint_x;
- int_y_white = (png_fixed_point)uint_y;
-
- uint_x = png_get_uint_32(buf + 8);
- uint_y = png_get_uint_32(buf + 12);
- int_x_red = (png_fixed_point)uint_x;
- int_y_red = (png_fixed_point)uint_y;
-
- uint_x = png_get_uint_32(buf + 16);
- uint_y = png_get_uint_32(buf + 20);
- int_x_green = (png_fixed_point)uint_x;
- int_y_green = (png_fixed_point)uint_y;
-
- uint_x = png_get_uint_32(buf + 24);
- uint_y = png_get_uint_32(buf + 28);
- int_x_blue = (png_fixed_point)uint_x;
- int_y_blue = (png_fixed_point)uint_y;
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- white_x = (float)int_x_white / (float)100000.0;
- white_y = (float)int_y_white / (float)100000.0;
- red_x = (float)int_x_red / (float)100000.0;
- red_y = (float)int_y_red / (float)100000.0;
- green_x = (float)int_x_green / (float)100000.0;
- green_y = (float)int_y_green / (float)100000.0;
- blue_x = (float)int_x_blue / (float)100000.0;
- blue_y = (float)int_y_blue / (float)100000.0;
-#endif
-
-#if defined(PNG_READ_sRGB_SUPPORTED)
- if ((info_ptr != NULL) && (info_ptr->valid & PNG_INFO_sRGB))
- {
- if (PNG_OUT_OF_RANGE(int_x_white, 31270, 1000) ||
- PNG_OUT_OF_RANGE(int_y_white, 32900, 1000) ||
- PNG_OUT_OF_RANGE(int_x_red, 64000L, 1000) ||
- PNG_OUT_OF_RANGE(int_y_red, 33000, 1000) ||
- PNG_OUT_OF_RANGE(int_x_green, 30000, 1000) ||
- PNG_OUT_OF_RANGE(int_y_green, 60000L, 1000) ||
- PNG_OUT_OF_RANGE(int_x_blue, 15000, 1000) ||
- PNG_OUT_OF_RANGE(int_y_blue, 6000, 1000))
- {
- png_warning(png_ptr,
- "Ignoring incorrect cHRM value when sRGB is also present");
-#ifndef PNG_NO_CONSOLE_IO
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- fprintf(stderr, "wx=%f, wy=%f, rx=%f, ry=%f\n",
- white_x, white_y, red_x, red_y);
- fprintf(stderr, "gx=%f, gy=%f, bx=%f, by=%f\n",
- green_x, green_y, blue_x, blue_y);
-#else
- fprintf(stderr, "wx=%ld, wy=%ld, rx=%ld, ry=%ld\n",
- int_x_white, int_y_white, int_x_red, int_y_red);
- fprintf(stderr, "gx=%ld, gy=%ld, bx=%ld, by=%ld\n",
- int_x_green, int_y_green, int_x_blue, int_y_blue);
-#endif
-#endif /* PNG_NO_CONSOLE_IO */
- }
- return;
- }
-#endif /* PNG_READ_sRGB_SUPPORTED */
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- png_set_cHRM(png_ptr, info_ptr,
- white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
- png_set_cHRM_fixed(png_ptr, info_ptr,
- int_x_white, int_y_white, int_x_red, int_y_red, int_x_green,
- int_y_green, int_x_blue, int_y_blue);
-#endif
-}
-#endif
-
-#if defined(PNG_READ_sRGB_SUPPORTED)
-void /* PRIVATE */
-png_handle_sRGB(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- int intent;
- png_byte buf[1];
-
- png_debug(1, "in png_handle_sRGB");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before sRGB");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid sRGB after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (png_ptr->mode & PNG_HAVE_PLTE)
- /* Should be an error, but we can cope with it */
- png_warning(png_ptr, "Out of place sRGB chunk");
-
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sRGB))
- {
- png_warning(png_ptr, "Duplicate sRGB chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (length != 1)
- {
- png_warning(png_ptr, "Incorrect sRGB chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, buf, 1);
- if (png_crc_finish(png_ptr, 0))
- return;
-
- intent = buf[0];
- /* check for bad intent */
- if (intent >= PNG_sRGB_INTENT_LAST)
- {
- png_warning(png_ptr, "Unknown sRGB intent");
- return;
- }
-
-#if defined(PNG_READ_gAMA_SUPPORTED) && defined(PNG_READ_GAMMA_SUPPORTED)
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_gAMA))
- {
- png_fixed_point igamma;
-#ifdef PNG_FIXED_POINT_SUPPORTED
- igamma=info_ptr->int_gamma;
-#else
-# ifdef PNG_FLOATING_POINT_SUPPORTED
- igamma=(png_fixed_point)(info_ptr->gamma * 100000.);
-# endif
-#endif
- if (PNG_OUT_OF_RANGE(igamma, 45500L, 500))
- {
- png_warning(png_ptr,
- "Ignoring incorrect gAMA value when sRGB is also present");
-#ifndef PNG_NO_CONSOLE_IO
-# ifdef PNG_FIXED_POINT_SUPPORTED
- fprintf(stderr, "incorrect gamma=(%d/100000)\n",
- (int)png_ptr->int_gamma);
-# else
-# ifdef PNG_FLOATING_POINT_SUPPORTED
- fprintf(stderr, "incorrect gamma=%f\n", png_ptr->gamma);
-# endif
-# endif
-#endif
- }
- }
-#endif /* PNG_READ_gAMA_SUPPORTED */
-
-#ifdef PNG_READ_cHRM_SUPPORTED
-#ifdef PNG_FIXED_POINT_SUPPORTED
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cHRM))
- if (PNG_OUT_OF_RANGE(info_ptr->int_x_white, 31270, 1000) ||
- PNG_OUT_OF_RANGE(info_ptr->int_y_white, 32900, 1000) ||
- PNG_OUT_OF_RANGE(info_ptr->int_x_red, 64000L, 1000) ||
- PNG_OUT_OF_RANGE(info_ptr->int_y_red, 33000, 1000) ||
- PNG_OUT_OF_RANGE(info_ptr->int_x_green, 30000, 1000) ||
- PNG_OUT_OF_RANGE(info_ptr->int_y_green, 60000L, 1000) ||
- PNG_OUT_OF_RANGE(info_ptr->int_x_blue, 15000, 1000) ||
- PNG_OUT_OF_RANGE(info_ptr->int_y_blue, 6000, 1000))
- {
- png_warning(png_ptr,
- "Ignoring incorrect cHRM value when sRGB is also present");
- }
-#endif /* PNG_FIXED_POINT_SUPPORTED */
-#endif /* PNG_READ_cHRM_SUPPORTED */
-
- png_set_sRGB_gAMA_and_cHRM(png_ptr, info_ptr, intent);
-}
-#endif /* PNG_READ_sRGB_SUPPORTED */
-
-#if defined(PNG_READ_iCCP_SUPPORTED)
-void /* PRIVATE */
-png_handle_iCCP(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-/* Note: this does not properly handle chunks that are > 64K under DOS */
-{
- png_byte compression_type;
- png_bytep pC;
- png_charp profile;
- png_uint_32 skip = 0;
- png_uint_32 profile_size, profile_length;
- png_size_t slength, prefix_length, data_length;
-
- png_debug(1, "in png_handle_iCCP");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before iCCP");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid iCCP after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (png_ptr->mode & PNG_HAVE_PLTE)
- /* Should be an error, but we can cope with it */
- png_warning(png_ptr, "Out of place iCCP chunk");
-
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_iCCP))
- {
- png_warning(png_ptr, "Duplicate iCCP chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
-#ifdef PNG_MAX_MALLOC_64K
- if (length > (png_uint_32)65535L)
- {
- png_warning(png_ptr, "iCCP chunk too large to fit in memory");
- skip = length - (png_uint_32)65535L;
- length = (png_uint_32)65535L;
- }
-#endif
-
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
- slength = (png_size_t)length;
- png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
-
- if (png_crc_finish(png_ptr, skip))
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
- png_ptr->chunkdata[slength] = 0x00;
-
- for (profile = png_ptr->chunkdata; *profile; profile++)
- /* empty loop to find end of name */ ;
-
- ++profile;
-
- /* there should be at least one zero (the compression type byte)
- following the separator, and we should be on it */
- if ( profile >= png_ptr->chunkdata + slength - 1)
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_warning(png_ptr, "Malformed iCCP chunk");
- return;
- }
-
- /* compression_type should always be zero */
- compression_type = *profile++;
- if (compression_type)
- {
- png_warning(png_ptr, "Ignoring nonzero compression type in iCCP chunk");
- compression_type = 0x00; /* Reset it to zero (libpng-1.0.6 through 1.0.8
- wrote nonzero) */
- }
-
- prefix_length = profile - png_ptr->chunkdata;
- png_decompress_chunk(png_ptr, compression_type,
- slength, prefix_length, &data_length);
-
- profile_length = data_length - prefix_length;
-
- if ( prefix_length > data_length || profile_length < 4)
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_warning(png_ptr, "Profile size field missing from iCCP chunk");
- return;
- }
-
- /* Check the profile_size recorded in the first 32 bits of the ICC profile */
- pC = (png_bytep)(png_ptr->chunkdata + prefix_length);
- profile_size = ((*(pC ))<<24) |
- ((*(pC + 1))<<16) |
- ((*(pC + 2))<< 8) |
- ((*(pC + 3)) );
-
- if (profile_size < profile_length)
- profile_length = profile_size;
-
- if (profile_size > profile_length)
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_warning(png_ptr, "Ignoring truncated iCCP profile.");
- return;
- }
-
- png_set_iCCP(png_ptr, info_ptr, png_ptr->chunkdata,
- compression_type, png_ptr->chunkdata + prefix_length, profile_length);
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
-}
-#endif /* PNG_READ_iCCP_SUPPORTED */
-
-#if defined(PNG_READ_sPLT_SUPPORTED)
-void /* PRIVATE */
-png_handle_sPLT(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-/* Note: this does not properly handle chunks that are > 64K under DOS */
-{
- png_bytep entry_start;
- png_sPLT_t new_palette;
-#ifdef PNG_NO_POINTER_INDEXING
- png_sPLT_entryp pp;
-#endif
- int data_length, entry_size, i;
- png_uint_32 skip = 0;
- png_size_t slength;
-
- png_debug(1, "in png_handle_sPLT");
-
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before sPLT");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid sPLT after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
-
-#ifdef PNG_MAX_MALLOC_64K
- if (length > (png_uint_32)65535L)
- {
- png_warning(png_ptr, "sPLT chunk too large to fit in memory");
- skip = length - (png_uint_32)65535L;
- length = (png_uint_32)65535L;
- }
-#endif
-
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = (png_charp)png_malloc(png_ptr, length + 1);
- slength = (png_size_t)length;
- png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
-
- if (png_crc_finish(png_ptr, skip))
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
- png_ptr->chunkdata[slength] = 0x00;
-
- for (entry_start = (png_bytep)png_ptr->chunkdata; *entry_start; entry_start++)
- /* empty loop to find end of name */ ;
- ++entry_start;
-
- /* a sample depth should follow the separator, and we should be on it */
- if (entry_start > (png_bytep)png_ptr->chunkdata + slength - 2)
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_warning(png_ptr, "malformed sPLT chunk");
- return;
- }
-
- new_palette.depth = *entry_start++;
- entry_size = (new_palette.depth == 8 ? 6 : 10);
- data_length = (slength - (entry_start - (png_bytep)png_ptr->chunkdata));
-
- /* integrity-check the data length */
- if (data_length % entry_size)
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_warning(png_ptr, "sPLT chunk has bad length");
- return;
- }
-
- new_palette.nentries = (png_int_32) ( data_length / entry_size);
- if ((png_uint_32) new_palette.nentries >
- (png_uint_32) (PNG_SIZE_MAX / png_sizeof(png_sPLT_entry)))
- {
- png_warning(png_ptr, "sPLT chunk too long");
- return;
- }
- new_palette.entries = (png_sPLT_entryp)png_malloc_warn(
- png_ptr, new_palette.nentries * png_sizeof(png_sPLT_entry));
- if (new_palette.entries == NULL)
- {
- png_warning(png_ptr, "sPLT chunk requires too much memory");
- return;
- }
-
-#ifndef PNG_NO_POINTER_INDEXING
- for (i = 0; i < new_palette.nentries; i++)
- {
- png_sPLT_entryp pp = new_palette.entries + i;
-
- if (new_palette.depth == 8)
- {
- pp->red = *entry_start++;
- pp->green = *entry_start++;
- pp->blue = *entry_start++;
- pp->alpha = *entry_start++;
- }
- else
- {
- pp->red = png_get_uint_16(entry_start); entry_start += 2;
- pp->green = png_get_uint_16(entry_start); entry_start += 2;
- pp->blue = png_get_uint_16(entry_start); entry_start += 2;
- pp->alpha = png_get_uint_16(entry_start); entry_start += 2;
- }
- pp->frequency = png_get_uint_16(entry_start); entry_start += 2;
- }
-#else
- pp = new_palette.entries;
- for (i = 0; i < new_palette.nentries; i++)
- {
-
- if (new_palette.depth == 8)
- {
- pp[i].red = *entry_start++;
- pp[i].green = *entry_start++;
- pp[i].blue = *entry_start++;
- pp[i].alpha = *entry_start++;
- }
- else
- {
- pp[i].red = png_get_uint_16(entry_start); entry_start += 2;
- pp[i].green = png_get_uint_16(entry_start); entry_start += 2;
- pp[i].blue = png_get_uint_16(entry_start); entry_start += 2;
- pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2;
- }
- pp->frequency = png_get_uint_16(entry_start); entry_start += 2;
- }
-#endif
-
- /* discard all chunk data except the name and stash that */
- new_palette.name = png_ptr->chunkdata;
-
- png_set_sPLT(png_ptr, info_ptr, &new_palette, 1);
-
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_free(png_ptr, new_palette.entries);
-}
-#endif /* PNG_READ_sPLT_SUPPORTED */
-
-#if defined(PNG_READ_tRNS_SUPPORTED)
-void /* PRIVATE */
-png_handle_tRNS(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_byte readbuf[PNG_MAX_PALETTE_LENGTH];
-
- png_debug(1, "in png_handle_tRNS");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before tRNS");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid tRNS after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS))
- {
- png_warning(png_ptr, "Duplicate tRNS chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
- {
- png_byte buf[2];
-
- if (length != 2)
- {
- png_warning(png_ptr, "Incorrect tRNS chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, buf, 2);
- png_ptr->num_trans = 1;
- png_ptr->trans_values.gray = png_get_uint_16(buf);
- }
- else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
- {
- png_byte buf[6];
-
- if (length != 6)
- {
- png_warning(png_ptr, "Incorrect tRNS chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
- png_crc_read(png_ptr, buf, (png_size_t)length);
- png_ptr->num_trans = 1;
- png_ptr->trans_values.red = png_get_uint_16(buf);
- png_ptr->trans_values.green = png_get_uint_16(buf + 2);
- png_ptr->trans_values.blue = png_get_uint_16(buf + 4);
- }
- else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (!(png_ptr->mode & PNG_HAVE_PLTE))
- {
- /* Should be an error, but we can cope with it. */
- png_warning(png_ptr, "Missing PLTE before tRNS");
- }
- if (length > (png_uint_32)png_ptr->num_palette ||
- length > PNG_MAX_PALETTE_LENGTH)
- {
- png_warning(png_ptr, "Incorrect tRNS chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
- if (length == 0)
- {
- png_warning(png_ptr, "Zero length tRNS chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
- png_crc_read(png_ptr, readbuf, (png_size_t)length);
- png_ptr->num_trans = (png_uint_16)length;
- }
- else
- {
- png_warning(png_ptr, "tRNS chunk not allowed with alpha channel");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (png_crc_finish(png_ptr, 0))
- {
- png_ptr->num_trans = 0;
- return;
- }
-
- png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
- &(png_ptr->trans_values));
-}
-#endif
-
-#if defined(PNG_READ_bKGD_SUPPORTED)
-void /* PRIVATE */
-png_handle_bKGD(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_size_t truelen;
- png_byte buf[6];
-
- png_debug(1, "in png_handle_bKGD");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before bKGD");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid bKGD after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- !(png_ptr->mode & PNG_HAVE_PLTE))
- {
- png_warning(png_ptr, "Missing PLTE before bKGD");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD))
- {
- png_warning(png_ptr, "Duplicate bKGD chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- truelen = 1;
- else if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
- truelen = 6;
- else
- truelen = 2;
-
- if (length != truelen)
- {
- png_warning(png_ptr, "Incorrect bKGD chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, buf, truelen);
- if (png_crc_finish(png_ptr, 0))
- return;
-
- /* We convert the index value into RGB components so that we can allow
- * arbitrary RGB values for background when we have transparency, and
- * so it is easy to determine the RGB values of the background color
- * from the info_ptr struct. */
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- png_ptr->background.index = buf[0];
- if (info_ptr && info_ptr->num_palette)
- {
- if (buf[0] >= info_ptr->num_palette)
- {
- png_warning(png_ptr, "Incorrect bKGD chunk index value");
- return;
- }
- png_ptr->background.red =
- (png_uint_16)png_ptr->palette[buf[0]].red;
- png_ptr->background.green =
- (png_uint_16)png_ptr->palette[buf[0]].green;
- png_ptr->background.blue =
- (png_uint_16)png_ptr->palette[buf[0]].blue;
- }
- }
- else if (!(png_ptr->color_type & PNG_COLOR_MASK_COLOR)) /* GRAY */
- {
- png_ptr->background.red =
- png_ptr->background.green =
- png_ptr->background.blue =
- png_ptr->background.gray = png_get_uint_16(buf);
- }
- else
- {
- png_ptr->background.red = png_get_uint_16(buf);
- png_ptr->background.green = png_get_uint_16(buf + 2);
- png_ptr->background.blue = png_get_uint_16(buf + 4);
- }
-
- png_set_bKGD(png_ptr, info_ptr, &(png_ptr->background));
-}
-#endif
-
-#if defined(PNG_READ_hIST_SUPPORTED)
-void /* PRIVATE */
-png_handle_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- unsigned int num, i;
- png_uint_16 readbuf[PNG_MAX_PALETTE_LENGTH];
-
- png_debug(1, "in png_handle_hIST");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before hIST");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid hIST after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (!(png_ptr->mode & PNG_HAVE_PLTE))
- {
- png_warning(png_ptr, "Missing PLTE before hIST");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST))
- {
- png_warning(png_ptr, "Duplicate hIST chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- num = length / 2 ;
- if (num != (unsigned int) png_ptr->num_palette || num >
- (unsigned int) PNG_MAX_PALETTE_LENGTH)
- {
- png_warning(png_ptr, "Incorrect hIST chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- for (i = 0; i < num; i++)
- {
- png_byte buf[2];
-
- png_crc_read(png_ptr, buf, 2);
- readbuf[i] = png_get_uint_16(buf);
- }
-
- if (png_crc_finish(png_ptr, 0))
- return;
-
- png_set_hIST(png_ptr, info_ptr, readbuf);
-}
-#endif
-
-#if defined(PNG_READ_pHYs_SUPPORTED)
-void /* PRIVATE */
-png_handle_pHYs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_byte buf[9];
- png_uint_32 res_x, res_y;
- int unit_type;
-
- png_debug(1, "in png_handle_pHYs");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before pHYs");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid pHYs after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs))
- {
- png_warning(png_ptr, "Duplicate pHYs chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (length != 9)
- {
- png_warning(png_ptr, "Incorrect pHYs chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, buf, 9);
- if (png_crc_finish(png_ptr, 0))
- return;
-
- res_x = png_get_uint_32(buf);
- res_y = png_get_uint_32(buf + 4);
- unit_type = buf[8];
- png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type);
-}
-#endif
-
-#if defined(PNG_READ_oFFs_SUPPORTED)
-void /* PRIVATE */
-png_handle_oFFs(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_byte buf[9];
- png_int_32 offset_x, offset_y;
- int unit_type;
-
- png_debug(1, "in png_handle_oFFs");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before oFFs");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid oFFs after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs))
- {
- png_warning(png_ptr, "Duplicate oFFs chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (length != 9)
- {
- png_warning(png_ptr, "Incorrect oFFs chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, buf, 9);
- if (png_crc_finish(png_ptr, 0))
- return;
-
- offset_x = png_get_int_32(buf);
- offset_y = png_get_int_32(buf + 4);
- unit_type = buf[8];
- png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type);
-}
-#endif
-
-#if defined(PNG_READ_pCAL_SUPPORTED)
-/* read the pCAL chunk (described in the PNG Extensions document) */
-void /* PRIVATE */
-png_handle_pCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_int_32 X0, X1;
- png_byte type, nparams;
- png_charp buf, units, endptr;
- png_charpp params;
- png_size_t slength;
- int i;
-
- png_debug(1, "in png_handle_pCAL");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before pCAL");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid pCAL after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL))
- {
- png_warning(png_ptr, "Duplicate pCAL chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_debug1(2, "Allocating and reading pCAL chunk data (%lu bytes)",
- length + 1);
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
- if (png_ptr->chunkdata == NULL)
- {
- png_warning(png_ptr, "No memory for pCAL purpose.");
- return;
- }
- slength = (png_size_t)length;
- png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
-
- if (png_crc_finish(png_ptr, 0))
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
- png_ptr->chunkdata[slength] = 0x00; /* null terminate the last string */
-
- png_debug(3, "Finding end of pCAL purpose string");
- for (buf = png_ptr->chunkdata; *buf; buf++)
- /* empty loop */ ;
-
- endptr = png_ptr->chunkdata + slength;
-
- /* We need to have at least 12 bytes after the purpose string
- in order to get the parameter information. */
- if (endptr <= buf + 12)
- {
- png_warning(png_ptr, "Invalid pCAL data");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
- png_debug(3, "Reading pCAL X0, X1, type, nparams, and units");
- X0 = png_get_int_32((png_bytep)buf+1);
- X1 = png_get_int_32((png_bytep)buf+5);
- type = buf[9];
- nparams = buf[10];
- units = buf + 11;
-
- png_debug(3, "Checking pCAL equation type and number of parameters");
- /* Check that we have the right number of parameters for known
- equation types. */
- if ((type == PNG_EQUATION_LINEAR && nparams != 2) ||
- (type == PNG_EQUATION_BASE_E && nparams != 3) ||
- (type == PNG_EQUATION_ARBITRARY && nparams != 3) ||
- (type == PNG_EQUATION_HYPERBOLIC && nparams != 4))
- {
- png_warning(png_ptr, "Invalid pCAL parameters for equation type");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
- else if (type >= PNG_EQUATION_LAST)
- {
- png_warning(png_ptr, "Unrecognized equation type for pCAL chunk");
- }
-
- for (buf = units; *buf; buf++)
- /* Empty loop to move past the units string. */ ;
-
- png_debug(3, "Allocating pCAL parameters array");
- params = (png_charpp)png_malloc_warn(png_ptr,
- (png_uint_32)(nparams * png_sizeof(png_charp))) ;
- if (params == NULL)
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_warning(png_ptr, "No memory for pCAL params.");
- return;
- }
-
- /* Get pointers to the start of each parameter string. */
- for (i = 0; i < (int)nparams; i++)
- {
- buf++; /* Skip the null string terminator from previous parameter. */
-
- png_debug1(3, "Reading pCAL parameter %d", i);
- for (params[i] = buf; buf <= endptr && *buf != 0x00; buf++)
- /* Empty loop to move past each parameter string */ ;
-
- /* Make sure we haven't run out of data yet */
- if (buf > endptr)
- {
- png_warning(png_ptr, "Invalid pCAL data");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_free(png_ptr, params);
- return;
- }
- }
-
- png_set_pCAL(png_ptr, info_ptr, png_ptr->chunkdata, X0, X1, type, nparams,
- units, params);
-
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_free(png_ptr, params);
-}
-#endif
-
-#if defined(PNG_READ_sCAL_SUPPORTED)
-/* read the sCAL chunk */
-void /* PRIVATE */
-png_handle_sCAL(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_charp ep;
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- double width, height;
- png_charp vp;
-#else
-#ifdef PNG_FIXED_POINT_SUPPORTED
- png_charp swidth, sheight;
-#endif
-#endif
- png_size_t slength;
-
- png_debug(1, "in png_handle_sCAL");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before sCAL");
- else if (png_ptr->mode & PNG_HAVE_IDAT)
- {
- png_warning(png_ptr, "Invalid sCAL after IDAT");
- png_crc_finish(png_ptr, length);
- return;
- }
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL))
- {
- png_warning(png_ptr, "Duplicate sCAL chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_debug1(2, "Allocating and reading sCAL chunk data (%lu bytes)",
- length + 1);
- png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
- if (png_ptr->chunkdata == NULL)
- {
- png_warning(png_ptr, "Out of memory while processing sCAL chunk");
- return;
- }
- slength = (png_size_t)length;
- png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
-
- if (png_crc_finish(png_ptr, 0))
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
- png_ptr->chunkdata[slength] = 0x00; /* null terminate the last string */
-
- ep = png_ptr->chunkdata + 1; /* skip unit byte */
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- width = png_strtod(png_ptr, ep, &vp);
- if (*vp)
- {
- png_warning(png_ptr, "malformed width string in sCAL chunk");
- return;
- }
-#else
-#ifdef PNG_FIXED_POINT_SUPPORTED
- swidth = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
- if (swidth == NULL)
- {
- png_warning(png_ptr, "Out of memory while processing sCAL chunk width");
- return;
- }
- png_memcpy(swidth, ep, (png_size_t)png_strlen(ep));
-#endif
-#endif
-
- for (ep = png_ptr->chunkdata; *ep; ep++)
- /* empty loop */ ;
- ep++;
-
- if (png_ptr->chunkdata + slength < ep)
- {
- png_warning(png_ptr, "Truncated sCAL chunk");
-#if defined(PNG_FIXED_POINT_SUPPORTED) && \
- !defined(PNG_FLOATING_POINT_SUPPORTED)
- png_free(png_ptr, swidth);
-#endif
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- height = png_strtod(png_ptr, ep, &vp);
- if (*vp)
- {
- png_warning(png_ptr, "malformed height string in sCAL chunk");
- return;
- }
-#else
-#ifdef PNG_FIXED_POINT_SUPPORTED
- sheight = (png_charp)png_malloc_warn(png_ptr, png_strlen(ep) + 1);
- if (sheight == NULL)
- {
- png_warning(png_ptr, "Out of memory while processing sCAL chunk height");
- return;
- }
- png_memcpy(sheight, ep, (png_size_t)png_strlen(ep));
-#endif
-#endif
-
- if (png_ptr->chunkdata + slength < ep
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- || width <= 0. || height <= 0.
-#endif
- )
- {
- png_warning(png_ptr, "Invalid sCAL data");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
-#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
- png_free(png_ptr, swidth);
- png_free(png_ptr, sheight);
-#endif
- return;
- }
-
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- png_set_sCAL(png_ptr, info_ptr, png_ptr->chunkdata[0], width, height);
-#else
-#ifdef PNG_FIXED_POINT_SUPPORTED
- png_set_sCAL_s(png_ptr, info_ptr, png_ptr->chunkdata[0], swidth, sheight);
-#endif
-#endif
-
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
-#if defined(PNG_FIXED_POINT_SUPPORTED) && !defined(PNG_FLOATING_POINT_SUPPORTED)
- png_free(png_ptr, swidth);
- png_free(png_ptr, sheight);
-#endif
-}
-#endif
-
-#if defined(PNG_READ_tIME_SUPPORTED)
-void /* PRIVATE */
-png_handle_tIME(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_byte buf[7];
- png_time mod_time;
-
- png_debug(1, "in png_handle_tIME");
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Out of place tIME chunk");
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME))
- {
- png_warning(png_ptr, "Duplicate tIME chunk");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- if (png_ptr->mode & PNG_HAVE_IDAT)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
- if (length != 7)
- {
- png_warning(png_ptr, "Incorrect tIME chunk length");
- png_crc_finish(png_ptr, length);
- return;
- }
-
- png_crc_read(png_ptr, buf, 7);
- if (png_crc_finish(png_ptr, 0))
- return;
-
- mod_time.second = buf[6];
- mod_time.minute = buf[5];
- mod_time.hour = buf[4];
- mod_time.day = buf[3];
- mod_time.month = buf[2];
- mod_time.year = png_get_uint_16(buf);
-
- png_set_tIME(png_ptr, info_ptr, &mod_time);
-}
-#endif
-
-#if defined(PNG_READ_tEXt_SUPPORTED)
-/* Note: this does not properly handle chunks that are > 64K under DOS */
-void /* PRIVATE */
-png_handle_tEXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_textp text_ptr;
- png_charp key;
- png_charp text;
- png_uint_32 skip = 0;
- png_size_t slength;
- int ret;
-
- png_debug(1, "in png_handle_tEXt");
-
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before tEXt");
-
- if (png_ptr->mode & PNG_HAVE_IDAT)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
-#ifdef PNG_MAX_MALLOC_64K
- if (length > (png_uint_32)65535L)
- {
- png_warning(png_ptr, "tEXt chunk too large to fit in memory");
- skip = length - (png_uint_32)65535L;
- length = (png_uint_32)65535L;
- }
-#endif
-
- png_free(png_ptr, png_ptr->chunkdata);
-
- png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
- if (png_ptr->chunkdata == NULL)
- {
- png_warning(png_ptr, "No memory to process text chunk.");
- return;
- }
- slength = (png_size_t)length;
- png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
-
- if (png_crc_finish(png_ptr, skip))
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
- key = png_ptr->chunkdata;
-
- key[slength] = 0x00;
-
- for (text = key; *text; text++)
- /* empty loop to find end of key */ ;
-
- if (text != key + slength)
- text++;
-
- text_ptr = (png_textp)png_malloc_warn(png_ptr,
- (png_uint_32)png_sizeof(png_text));
- if (text_ptr == NULL)
- {
- png_warning(png_ptr, "Not enough memory to process text chunk.");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
- text_ptr->compression = PNG_TEXT_COMPRESSION_NONE;
- text_ptr->key = key;
-#ifdef PNG_iTXt_SUPPORTED
- text_ptr->lang = NULL;
- text_ptr->lang_key = NULL;
- text_ptr->itxt_length = 0;
-#endif
- text_ptr->text = text;
- text_ptr->text_length = png_strlen(text);
-
- ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
-
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- png_free(png_ptr, text_ptr);
- if (ret)
- png_warning(png_ptr, "Insufficient memory to process text chunk.");
-}
-#endif
-
-#if defined(PNG_READ_zTXt_SUPPORTED)
-/* note: this does not correctly handle chunks that are > 64K under DOS */
-void /* PRIVATE */
-png_handle_zTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_textp text_ptr;
- png_charp text;
- int comp_type;
- int ret;
- png_size_t slength, prefix_len, data_len;
-
- png_debug(1, "in png_handle_zTXt");
-
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before zTXt");
-
- if (png_ptr->mode & PNG_HAVE_IDAT)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
-#ifdef PNG_MAX_MALLOC_64K
- /* We will no doubt have problems with chunks even half this size, but
- there is no hard and fast rule to tell us where to stop. */
- if (length > (png_uint_32)65535L)
- {
- png_warning(png_ptr, "zTXt chunk too large to fit in memory");
- png_crc_finish(png_ptr, length);
- return;
- }
-#endif
-
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
- if (png_ptr->chunkdata == NULL)
- {
- png_warning(png_ptr, "Out of memory processing zTXt chunk.");
- return;
- }
- slength = (png_size_t)length;
- png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
- if (png_crc_finish(png_ptr, 0))
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
- png_ptr->chunkdata[slength] = 0x00;
-
- for (text = png_ptr->chunkdata; *text; text++)
- /* empty loop */ ;
-
- /* zTXt must have some text after the chunkdataword */
- if (text >= png_ptr->chunkdata + slength - 2)
- {
- png_warning(png_ptr, "Truncated zTXt chunk");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
- else
- {
- comp_type = *(++text);
- if (comp_type != PNG_TEXT_COMPRESSION_zTXt)
- {
- png_warning(png_ptr, "Unknown compression type in zTXt chunk");
- comp_type = PNG_TEXT_COMPRESSION_zTXt;
- }
- text++; /* skip the compression_method byte */
- }
- prefix_len = text - png_ptr->chunkdata;
-
- png_decompress_chunk(png_ptr, comp_type,
- (png_size_t)length, prefix_len, &data_len);
-
- text_ptr = (png_textp)png_malloc_warn(png_ptr,
- (png_uint_32)png_sizeof(png_text));
- if (text_ptr == NULL)
- {
- png_warning(png_ptr, "Not enough memory to process zTXt chunk.");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
- text_ptr->compression = comp_type;
- text_ptr->key = png_ptr->chunkdata;
-#ifdef PNG_iTXt_SUPPORTED
- text_ptr->lang = NULL;
- text_ptr->lang_key = NULL;
- text_ptr->itxt_length = 0;
-#endif
- text_ptr->text = png_ptr->chunkdata + prefix_len;
- text_ptr->text_length = data_len;
-
- ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
-
- png_free(png_ptr, text_ptr);
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- if (ret)
- png_error(png_ptr, "Insufficient memory to store zTXt chunk.");
-}
-#endif
-
-#if defined(PNG_READ_iTXt_SUPPORTED)
-/* note: this does not correctly handle chunks that are > 64K under DOS */
-void /* PRIVATE */
-png_handle_iTXt(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_textp text_ptr;
- png_charp key, lang, text, lang_key;
- int comp_flag;
- int comp_type = 0;
- int ret;
- png_size_t slength, prefix_len, data_len;
-
- png_debug(1, "in png_handle_iTXt");
-
-
- if (!(png_ptr->mode & PNG_HAVE_IHDR))
- png_error(png_ptr, "Missing IHDR before iTXt");
-
- if (png_ptr->mode & PNG_HAVE_IDAT)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
-#ifdef PNG_MAX_MALLOC_64K
- /* We will no doubt have problems with chunks even half this size, but
- there is no hard and fast rule to tell us where to stop. */
- if (length > (png_uint_32)65535L)
- {
- png_warning(png_ptr, "iTXt chunk too large to fit in memory");
- png_crc_finish(png_ptr, length);
- return;
- }
-#endif
-
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = (png_charp)png_malloc_warn(png_ptr, length + 1);
- if (png_ptr->chunkdata == NULL)
- {
- png_warning(png_ptr, "No memory to process iTXt chunk.");
- return;
- }
- slength = (png_size_t)length;
- png_crc_read(png_ptr, (png_bytep)png_ptr->chunkdata, slength);
- if (png_crc_finish(png_ptr, 0))
- {
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
- png_ptr->chunkdata[slength] = 0x00;
-
- for (lang = png_ptr->chunkdata; *lang; lang++)
- /* empty loop */ ;
- lang++; /* skip NUL separator */
-
- /* iTXt must have a language tag (possibly empty), two compression bytes,
- translated keyword (possibly empty), and possibly some text after the
- keyword */
-
- if (lang >= png_ptr->chunkdata + slength - 3)
- {
- png_warning(png_ptr, "Truncated iTXt chunk");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
- else
- {
- comp_flag = *lang++;
- comp_type = *lang++;
- }
-
- for (lang_key = lang; *lang_key; lang_key++)
- /* empty loop */ ;
- lang_key++; /* skip NUL separator */
-
- if (lang_key >= png_ptr->chunkdata + slength)
- {
- png_warning(png_ptr, "Truncated iTXt chunk");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
- for (text = lang_key; *text; text++)
- /* empty loop */ ;
- text++; /* skip NUL separator */
- if (text >= png_ptr->chunkdata + slength)
- {
- png_warning(png_ptr, "Malformed iTXt chunk");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
-
- prefix_len = text - png_ptr->chunkdata;
-
- key=png_ptr->chunkdata;
- if (comp_flag)
- png_decompress_chunk(png_ptr, comp_type,
- (size_t)length, prefix_len, &data_len);
- else
- data_len = png_strlen(png_ptr->chunkdata + prefix_len);
- text_ptr = (png_textp)png_malloc_warn(png_ptr,
- (png_uint_32)png_sizeof(png_text));
- if (text_ptr == NULL)
- {
- png_warning(png_ptr, "Not enough memory to process iTXt chunk.");
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- return;
- }
- text_ptr->compression = (int)comp_flag + 1;
- text_ptr->lang_key = png_ptr->chunkdata + (lang_key - key);
- text_ptr->lang = png_ptr->chunkdata + (lang - key);
- text_ptr->itxt_length = data_len;
- text_ptr->text_length = 0;
- text_ptr->key = png_ptr->chunkdata;
- text_ptr->text = png_ptr->chunkdata + prefix_len;
-
- ret = png_set_text_2(png_ptr, info_ptr, text_ptr, 1);
-
- png_free(png_ptr, text_ptr);
- png_free(png_ptr, png_ptr->chunkdata);
- png_ptr->chunkdata = NULL;
- if (ret)
- png_error(png_ptr, "Insufficient memory to store iTXt chunk.");
-}
-#endif
-
-/* This function is called when we haven't found a handler for a
- chunk. If there isn't a problem with the chunk itself (ie bad
- chunk name, CRC, or a critical chunk), the chunk is silently ignored
- -- unless the PNG_FLAG_UNKNOWN_CHUNKS_SUPPORTED flag is on in which
- case it will be saved away to be written out later. */
-void /* PRIVATE */
-png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
-{
- png_uint_32 skip = 0;
-
- png_debug(1, "in png_handle_unknown");
-
-
- if (png_ptr->mode & PNG_HAVE_IDAT)
- {
-#ifdef PNG_USE_LOCAL_ARRAYS
- PNG_CONST PNG_IDAT;
-#endif
- if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4)) /* not an IDAT */
- png_ptr->mode |= PNG_AFTER_IDAT;
- }
-
- if (!(png_ptr->chunk_name[0] & 0x20))
- {
-#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
- if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
- PNG_HANDLE_CHUNK_ALWAYS
-#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
- && png_ptr->read_user_chunk_fn == NULL
-#endif
- )
-#endif
- png_chunk_error(png_ptr, "unknown critical chunk");
- }
-
-#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
- if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) ||
- (png_ptr->read_user_chunk_fn != NULL))
- {
-#ifdef PNG_MAX_MALLOC_64K
- if (length > (png_uint_32)65535L)
- {
- png_warning(png_ptr, "unknown chunk too large to fit in memory");
- skip = length - (png_uint_32)65535L;
- length = (png_uint_32)65535L;
- }
-#endif
- png_memcpy((png_charp)png_ptr->unknown_chunk.name,
- (png_charp)png_ptr->chunk_name,
- png_sizeof(png_ptr->unknown_chunk.name));
- png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1] = '\0';
- png_ptr->unknown_chunk.size = (png_size_t)length;
- if (length == 0)
- png_ptr->unknown_chunk.data = NULL;
- else
- {
- png_ptr->unknown_chunk.data = (png_bytep)png_malloc(png_ptr, length);
- png_crc_read(png_ptr, (png_bytep)png_ptr->unknown_chunk.data, length);
- }
-#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
- if (png_ptr->read_user_chunk_fn != NULL)
- {
- /* callback to user unknown chunk handler */
- int ret;
- ret = (*(png_ptr->read_user_chunk_fn))
- (png_ptr, &png_ptr->unknown_chunk);
- if (ret < 0)
- png_chunk_error(png_ptr, "error in user chunk");
- if (ret == 0)
- {
- if (!(png_ptr->chunk_name[0] & 0x20))
- if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
- PNG_HANDLE_CHUNK_ALWAYS)
- png_chunk_error(png_ptr, "unknown critical chunk");
- png_set_unknown_chunks(png_ptr, info_ptr,
- &png_ptr->unknown_chunk, 1);
- }
- }
- else
-#endif
- png_set_unknown_chunks(png_ptr, info_ptr, &png_ptr->unknown_chunk, 1);
- png_free(png_ptr, png_ptr->unknown_chunk.data);
- png_ptr->unknown_chunk.data = NULL;
- }
- else
-#endif
- skip = length;
-
- png_crc_finish(png_ptr, skip);
-
-#if !defined(PNG_READ_USER_CHUNKS_SUPPORTED)
- info_ptr = info_ptr; /* quiet compiler warnings about unused info_ptr */
-#endif
-}
-
-/* This function is called to verify that a chunk name is valid.
- This function can't have the "critical chunk check" incorporated
- into it, since in the future we will need to be able to call user
- functions to handle unknown critical chunks after we check that
- the chunk name itself is valid. */
-
-#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
-
-void /* PRIVATE */
-png_check_chunk_name(png_structp png_ptr, png_bytep chunk_name)
-{
- png_debug(1, "in png_check_chunk_name");
- if (isnonalpha(chunk_name[0]) || isnonalpha(chunk_name[1]) ||
- isnonalpha(chunk_name[2]) || isnonalpha(chunk_name[3]))
- {
- png_chunk_error(png_ptr, "invalid chunk type");
- }
-}
-
-/* Combines the row recently read in with the existing pixels in the
- row. This routine takes care of alpha and transparency if requested.
- This routine also handles the two methods of progressive display
- of interlaced images, depending on the mask value.
- The mask value describes which pixels are to be combined with
- the row. The pattern always repeats every 8 pixels, so just 8
- bits are needed. A one indicates the pixel is to be combined,
- a zero indicates the pixel is to be skipped. This is in addition
- to any alpha or transparency value associated with the pixel. If
- you want all pixels to be combined, pass 0xff (255) in mask. */
-
-void /* PRIVATE */
-png_combine_row(png_structp png_ptr, png_bytep row, int mask)
-{
- png_debug(1, "in png_combine_row");
- if (mask == 0xff)
- {
- png_memcpy(row, png_ptr->row_buf + 1,
- PNG_ROWBYTES(png_ptr->row_info.pixel_depth, png_ptr->width));
- }
- else
- {
- switch (png_ptr->row_info.pixel_depth)
- {
- case 1:
- {
- png_bytep sp = png_ptr->row_buf + 1;
- png_bytep dp = row;
- int s_inc, s_start, s_end;
- int m = 0x80;
- int shift;
- png_uint_32 i;
- png_uint_32 row_width = png_ptr->width;
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_PACKSWAP)
- {
- s_start = 0;
- s_end = 7;
- s_inc = 1;
- }
- else
-#endif
- {
- s_start = 7;
- s_end = 0;
- s_inc = -1;
- }
-
- shift = s_start;
-
- for (i = 0; i < row_width; i++)
- {
- if (m & mask)
- {
- int value;
-
- value = (*sp >> shift) & 0x01;
- *dp &= (png_byte)((0x7f7f >> (7 - shift)) & 0xff);
- *dp |= (png_byte)(value << shift);
- }
-
- if (shift == s_end)
- {
- shift = s_start;
- sp++;
- dp++;
- }
- else
- shift += s_inc;
-
- if (m == 1)
- m = 0x80;
- else
- m >>= 1;
- }
- break;
- }
- case 2:
- {
- png_bytep sp = png_ptr->row_buf + 1;
- png_bytep dp = row;
- int s_start, s_end, s_inc;
- int m = 0x80;
- int shift;
- png_uint_32 i;
- png_uint_32 row_width = png_ptr->width;
- int value;
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_PACKSWAP)
- {
- s_start = 0;
- s_end = 6;
- s_inc = 2;
- }
- else
-#endif
- {
- s_start = 6;
- s_end = 0;
- s_inc = -2;
- }
-
- shift = s_start;
-
- for (i = 0; i < row_width; i++)
- {
- if (m & mask)
- {
- value = (*sp >> shift) & 0x03;
- *dp &= (png_byte)((0x3f3f >> (6 - shift)) & 0xff);
- *dp |= (png_byte)(value << shift);
- }
-
- if (shift == s_end)
- {
- shift = s_start;
- sp++;
- dp++;
- }
- else
- shift += s_inc;
- if (m == 1)
- m = 0x80;
- else
- m >>= 1;
- }
- break;
- }
- case 4:
- {
- png_bytep sp = png_ptr->row_buf + 1;
- png_bytep dp = row;
- int s_start, s_end, s_inc;
- int m = 0x80;
- int shift;
- png_uint_32 i;
- png_uint_32 row_width = png_ptr->width;
- int value;
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)
- if (png_ptr->transformations & PNG_PACKSWAP)
- {
- s_start = 0;
- s_end = 4;
- s_inc = 4;
- }
- else
-#endif
- {
- s_start = 4;
- s_end = 0;
- s_inc = -4;
- }
- shift = s_start;
-
- for (i = 0; i < row_width; i++)
- {
- if (m & mask)
- {
- value = (*sp >> shift) & 0xf;
- *dp &= (png_byte)((0xf0f >> (4 - shift)) & 0xff);
- *dp |= (png_byte)(value << shift);
- }
-
- if (shift == s_end)
- {
- shift = s_start;
- sp++;
- dp++;
- }
- else
- shift += s_inc;
- if (m == 1)
- m = 0x80;
- else
- m >>= 1;
- }
- break;
- }
- default:
- {
- png_bytep sp = png_ptr->row_buf + 1;
- png_bytep dp = row;
- png_size_t pixel_bytes = (png_ptr->row_info.pixel_depth >> 3);
- png_uint_32 i;
- png_uint_32 row_width = png_ptr->width;
- png_byte m = 0x80;
-
-
- for (i = 0; i < row_width; i++)
- {
- if (m & mask)
- {
- png_memcpy(dp, sp, pixel_bytes);
- }
-
- sp += pixel_bytes;
- dp += pixel_bytes;
-
- if (m == 1)
- m = 0x80;
- else
- m >>= 1;
- }
- break;
- }
- }
- }
-}
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
-/* OLD pre-1.0.9 interface:
-void png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
- png_uint_32 transformations)
- */
-void /* PRIVATE */
-png_do_read_interlace(png_structp png_ptr)
-{
- png_row_infop row_info = &(png_ptr->row_info);
- png_bytep row = png_ptr->row_buf + 1;
- int pass = png_ptr->pass;
- png_uint_32 transformations = png_ptr->transformations;
-#ifdef PNG_USE_LOCAL_ARRAYS
- /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
- /* offset to next interlace block */
- PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-#endif
-
- png_debug(1, "in png_do_read_interlace");
- if (row != NULL && row_info != NULL)
- {
- png_uint_32 final_width;
-
- final_width = row_info->width * png_pass_inc[pass];
-
- switch (row_info->pixel_depth)
- {
- case 1:
- {
- png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
- png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
- int sshift, dshift;
- int s_start, s_end, s_inc;
- int jstop = png_pass_inc[pass];
- png_byte v;
- png_uint_32 i;
- int j;
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)
- if (transformations & PNG_PACKSWAP)
- {
- sshift = (int)((row_info->width + 7) & 0x07);
- dshift = (int)((final_width + 7) & 0x07);
- s_start = 7;
- s_end = 0;
- s_inc = -1;
- }
- else
-#endif
- {
- sshift = 7 - (int)((row_info->width + 7) & 0x07);
- dshift = 7 - (int)((final_width + 7) & 0x07);
- s_start = 0;
- s_end = 7;
- s_inc = 1;
- }
-
- for (i = 0; i < row_info->width; i++)
- {
- v = (png_byte)((*sp >> sshift) & 0x01);
- for (j = 0; j < jstop; j++)
- {
- *dp &= (png_byte)((0x7f7f >> (7 - dshift)) & 0xff);
- *dp |= (png_byte)(v << dshift);
- if (dshift == s_end)
- {
- dshift = s_start;
- dp--;
- }
- else
- dshift += s_inc;
- }
- if (sshift == s_end)
- {
- sshift = s_start;
- sp--;
- }
- else
- sshift += s_inc;
- }
- break;
- }
- case 2:
- {
- png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
- png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
- int sshift, dshift;
- int s_start, s_end, s_inc;
- int jstop = png_pass_inc[pass];
- png_uint_32 i;
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)
- if (transformations & PNG_PACKSWAP)
- {
- sshift = (int)(((row_info->width + 3) & 0x03) << 1);
- dshift = (int)(((final_width + 3) & 0x03) << 1);
- s_start = 6;
- s_end = 0;
- s_inc = -2;
- }
- else
-#endif
- {
- sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1);
- dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1);
- s_start = 0;
- s_end = 6;
- s_inc = 2;
- }
-
- for (i = 0; i < row_info->width; i++)
- {
- png_byte v;
- int j;
-
- v = (png_byte)((*sp >> sshift) & 0x03);
- for (j = 0; j < jstop; j++)
- {
- *dp &= (png_byte)((0x3f3f >> (6 - dshift)) & 0xff);
- *dp |= (png_byte)(v << dshift);
- if (dshift == s_end)
- {
- dshift = s_start;
- dp--;
- }
- else
- dshift += s_inc;
- }
- if (sshift == s_end)
- {
- sshift = s_start;
- sp--;
- }
- else
- sshift += s_inc;
- }
- break;
- }
- case 4:
- {
- png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
- png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
- int sshift, dshift;
- int s_start, s_end, s_inc;
- png_uint_32 i;
- int jstop = png_pass_inc[pass];
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)
- if (transformations & PNG_PACKSWAP)
- {
- sshift = (int)(((row_info->width + 1) & 0x01) << 2);
- dshift = (int)(((final_width + 1) & 0x01) << 2);
- s_start = 4;
- s_end = 0;
- s_inc = -4;
- }
- else
-#endif
- {
- sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2);
- dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2);
- s_start = 0;
- s_end = 4;
- s_inc = 4;
- }
-
- for (i = 0; i < row_info->width; i++)
- {
- png_byte v = (png_byte)((*sp >> sshift) & 0xf);
- int j;
-
- for (j = 0; j < jstop; j++)
- {
- *dp &= (png_byte)((0xf0f >> (4 - dshift)) & 0xff);
- *dp |= (png_byte)(v << dshift);
- if (dshift == s_end)
- {
- dshift = s_start;
- dp--;
- }
- else
- dshift += s_inc;
- }
- if (sshift == s_end)
- {
- sshift = s_start;
- sp--;
- }
- else
- sshift += s_inc;
- }
- break;
- }
- default:
- {
- png_size_t pixel_bytes = (row_info->pixel_depth >> 3);
- png_bytep sp = row + (png_size_t)(row_info->width - 1) * pixel_bytes;
- png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
-
- int jstop = png_pass_inc[pass];
- png_uint_32 i;
-
- for (i = 0; i < row_info->width; i++)
- {
- png_byte v[8];
- int j;
-
- png_memcpy(v, sp, pixel_bytes);
- for (j = 0; j < jstop; j++)
- {
- png_memcpy(dp, v, pixel_bytes);
- dp -= pixel_bytes;
- }
- sp -= pixel_bytes;
- }
- break;
- }
- }
- row_info->width = final_width;
- row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, final_width);
- }
-#if !defined(PNG_READ_PACKSWAP_SUPPORTED)
- transformations = transformations; /* silence compiler warning */
-#endif
-}
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
-
-void /* PRIVATE */
-png_read_filter_row(png_structp png_ptr, png_row_infop row_info, png_bytep row,
- png_bytep prev_row, int filter)
-{
- png_debug(1, "in png_read_filter_row");
- png_debug2(2, "row = %lu, filter = %d", png_ptr->row_number, filter);
- switch (filter)
- {
- case PNG_FILTER_VALUE_NONE:
- break;
- case PNG_FILTER_VALUE_SUB:
- {
- png_uint_32 i;
- png_uint_32 istop = row_info->rowbytes;
- png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3;
- png_bytep rp = row + bpp;
- png_bytep lp = row;
-
- for (i = bpp; i < istop; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*lp++)) & 0xff);
- rp++;
- }
- break;
- }
- case PNG_FILTER_VALUE_UP:
- {
- png_uint_32 i;
- png_uint_32 istop = row_info->rowbytes;
- png_bytep rp = row;
- png_bytep pp = prev_row;
-
- for (i = 0; i < istop; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
- rp++;
- }
- break;
- }
- case PNG_FILTER_VALUE_AVG:
- {
- png_uint_32 i;
- png_bytep rp = row;
- png_bytep pp = prev_row;
- png_bytep lp = row;
- png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3;
- png_uint_32 istop = row_info->rowbytes - bpp;
-
- for (i = 0; i < bpp; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- ((int)(*pp++) / 2 )) & 0xff);
- rp++;
- }
-
- for (i = 0; i < istop; i++)
- {
- *rp = (png_byte)(((int)(*rp) +
- (int)(*pp++ + *lp++) / 2 ) & 0xff);
- rp++;
- }
- break;
- }
- case PNG_FILTER_VALUE_PAETH:
- {
- png_uint_32 i;
- png_bytep rp = row;
- png_bytep pp = prev_row;
- png_bytep lp = row;
- png_bytep cp = prev_row;
- png_uint_32 bpp = (row_info->pixel_depth + 7) >> 3;
- png_uint_32 istop=row_info->rowbytes - bpp;
-
- for (i = 0; i < bpp; i++)
- {
- *rp = (png_byte)(((int)(*rp) + (int)(*pp++)) & 0xff);
- rp++;
- }
-
- for (i = 0; i < istop; i++) /* use leftover rp,pp */
- {
- int a, b, c, pa, pb, pc, p;
-
- a = *lp++;
- b = *pp++;
- c = *cp++;
-
- p = b - c;
- pc = a - c;
-
-#ifdef PNG_USE_ABS
- pa = abs(p);
- pb = abs(pc);
- pc = abs(p + pc);
-#else
- pa = p < 0 ? -p : p;
- pb = pc < 0 ? -pc : pc;
- pc = (p + pc) < 0 ? -(p + pc) : p + pc;
-#endif
-
- /*
- if (pa <= pb && pa <= pc)
- p = a;
- else if (pb <= pc)
- p = b;
- else
- p = c;
- */
-
- p = (pa <= pb && pa <= pc) ? a : (pb <= pc) ? b : c;
-
- *rp = (png_byte)(((int)(*rp) + p) & 0xff);
- rp++;
- }
- break;
- }
- default:
- png_warning(png_ptr, "Ignoring bad adaptive filter type");
- *row = 0;
- break;
- }
-}
-
-void /* PRIVATE */
-png_read_finish_row(png_structp png_ptr)
-{
-#ifdef PNG_USE_LOCAL_ARRAYS
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
- /* start of interlace block */
- PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
- /* offset to next interlace block */
- PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
- /* start of interlace block in the y direction */
- PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
- /* offset to next interlace block in the y direction */
- PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
-#endif
-
- png_debug(1, "in png_read_finish_row");
- png_ptr->row_number++;
- if (png_ptr->row_number < png_ptr->num_rows)
- return;
-
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- if (png_ptr->interlaced)
- {
- png_ptr->row_number = 0;
- png_memset_check(png_ptr, png_ptr->prev_row, 0,
- png_ptr->rowbytes + 1);
- do
- {
- png_ptr->pass++;
- if (png_ptr->pass >= 7)
- break;
- png_ptr->iwidth = (png_ptr->width +
- png_pass_inc[png_ptr->pass] - 1 -
- png_pass_start[png_ptr->pass]) /
- png_pass_inc[png_ptr->pass];
-
- png_ptr->irowbytes = PNG_ROWBYTES(png_ptr->pixel_depth,
- png_ptr->iwidth) + 1;
-
- if (!(png_ptr->transformations & PNG_INTERLACE))
- {
- png_ptr->num_rows = (png_ptr->height +
- png_pass_yinc[png_ptr->pass] - 1 -
- png_pass_ystart[png_ptr->pass]) /
- png_pass_yinc[png_ptr->pass];
- if (!(png_ptr->num_rows))
- continue;
- }
- else /* if (png_ptr->transformations & PNG_INTERLACE) */
- break;
- } while (png_ptr->iwidth == 0);
-
- if (png_ptr->pass < 7)
- return;
- }
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
-
- if (!(png_ptr->flags & PNG_FLAG_ZLIB_FINISHED))
- {
-#ifdef PNG_USE_LOCAL_ARRAYS
- PNG_CONST PNG_IDAT;
-#endif
- char extra;
- int ret;
-
- png_ptr->zstream.next_out = (Byte *)&extra;
- png_ptr->zstream.avail_out = (uInt)1;
- for (;;)
- {
- if (!(png_ptr->zstream.avail_in))
- {
- while (!png_ptr->idat_size)
- {
- png_byte chunk_length[4];
-
- png_crc_finish(png_ptr, 0);
-
- png_read_data(png_ptr, chunk_length, 4);
- png_ptr->idat_size = png_get_uint_31(png_ptr, chunk_length);
- png_reset_crc(png_ptr);
- png_crc_read(png_ptr, png_ptr->chunk_name, 4);
- if (png_memcmp(png_ptr->chunk_name, png_IDAT, 4))
- png_error(png_ptr, "Not enough image data");
-
- }
- png_ptr->zstream.avail_in = (uInt)png_ptr->zbuf_size;
- png_ptr->zstream.next_in = png_ptr->zbuf;
- if (png_ptr->zbuf_size > png_ptr->idat_size)
- png_ptr->zstream.avail_in = (uInt)png_ptr->idat_size;
- png_crc_read(png_ptr, png_ptr->zbuf, png_ptr->zstream.avail_in);
- png_ptr->idat_size -= png_ptr->zstream.avail_in;
- }
- ret = inflate(&png_ptr->zstream, Z_PARTIAL_FLUSH);
- if (ret == Z_STREAM_END)
- {
- if (!(png_ptr->zstream.avail_out) || png_ptr->zstream.avail_in ||
- png_ptr->idat_size)
- png_warning(png_ptr, "Extra compressed data");
- png_ptr->mode |= PNG_AFTER_IDAT;
- png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
- break;
- }
- if (ret != Z_OK)
- png_error(png_ptr, png_ptr->zstream.msg ? png_ptr->zstream.msg :
- "Decompression Error");
-
- if (!(png_ptr->zstream.avail_out))
- {
- png_warning(png_ptr, "Extra compressed data.");
- png_ptr->mode |= PNG_AFTER_IDAT;
- png_ptr->flags |= PNG_FLAG_ZLIB_FINISHED;
- break;
- }
-
- }
- png_ptr->zstream.avail_out = 0;
- }
-
- if (png_ptr->idat_size || png_ptr->zstream.avail_in)
- png_warning(png_ptr, "Extra compression data");
-
- inflateReset(&png_ptr->zstream);
-
- png_ptr->mode |= PNG_AFTER_IDAT;
-}
-
-void /* PRIVATE */
-png_read_start_row(png_structp png_ptr)
-{
-#ifdef PNG_USE_LOCAL_ARRAYS
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- /* arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
- /* start of interlace block */
- PNG_CONST int png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
- /* offset to next interlace block */
- PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
- /* start of interlace block in the y direction */
- PNG_CONST int png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
- /* offset to next interlace block in the y direction */
- PNG_CONST int png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-#endif
-#endif
-
- int max_pixel_depth;
- png_size_t row_bytes;
-
- png_debug(1, "in png_read_start_row");
- png_ptr->zstream.avail_in = 0;
- png_init_read_transformations(png_ptr);
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- if (png_ptr->interlaced)
- {
- if (!(png_ptr->transformations & PNG_INTERLACE))
- png_ptr->num_rows = (png_ptr->height + png_pass_yinc[0] - 1 -
- png_pass_ystart[0]) / png_pass_yinc[0];
- else
- png_ptr->num_rows = png_ptr->height;
-
- png_ptr->iwidth = (png_ptr->width +
- png_pass_inc[png_ptr->pass] - 1 -
- png_pass_start[png_ptr->pass]) /
- png_pass_inc[png_ptr->pass];
-
- png_ptr->irowbytes =
- PNG_ROWBYTES(png_ptr->pixel_depth, png_ptr->iwidth) + 1;
- }
- else
-#endif /* PNG_READ_INTERLACING_SUPPORTED */
- {
- png_ptr->num_rows = png_ptr->height;
- png_ptr->iwidth = png_ptr->width;
- png_ptr->irowbytes = png_ptr->rowbytes + 1;
- }
- max_pixel_depth = png_ptr->pixel_depth;
-
-#if defined(PNG_READ_PACK_SUPPORTED)
- if ((png_ptr->transformations & PNG_PACK) && png_ptr->bit_depth < 8)
- max_pixel_depth = 8;
-#endif
-
-#if defined(PNG_READ_EXPAND_SUPPORTED)
- if (png_ptr->transformations & PNG_EXPAND)
- {
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- {
- if (png_ptr->num_trans)
- max_pixel_depth = 32;
- else
- max_pixel_depth = 24;
- }
- else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
- {
- if (max_pixel_depth < 8)
- max_pixel_depth = 8;
- if (png_ptr->num_trans)
- max_pixel_depth *= 2;
- }
- else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
- {
- if (png_ptr->num_trans)
- {
- max_pixel_depth *= 4;
- max_pixel_depth /= 3;
- }
- }
- }
-#endif
-
-#if defined(PNG_READ_FILLER_SUPPORTED)
- if (png_ptr->transformations & (PNG_FILLER))
- {
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- max_pixel_depth = 32;
- else if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
- {
- if (max_pixel_depth <= 8)
- max_pixel_depth = 16;
- else
- max_pixel_depth = 32;
- }
- else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
- {
- if (max_pixel_depth <= 32)
- max_pixel_depth = 32;
- else
- max_pixel_depth = 64;
- }
- }
-#endif
-
-#if defined(PNG_READ_GRAY_TO_RGB_SUPPORTED)
- if (png_ptr->transformations & PNG_GRAY_TO_RGB)
- {
- if (
-#if defined(PNG_READ_EXPAND_SUPPORTED)
- (png_ptr->num_trans && (png_ptr->transformations & PNG_EXPAND)) ||
-#endif
-#if defined(PNG_READ_FILLER_SUPPORTED)
- (png_ptr->transformations & (PNG_FILLER)) ||
-#endif
- png_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
- {
- if (max_pixel_depth <= 16)
- max_pixel_depth = 32;
- else
- max_pixel_depth = 64;
- }
- else
- {
- if (max_pixel_depth <= 8)
- {
- if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- max_pixel_depth = 32;
- else
- max_pixel_depth = 24;
- }
- else if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- max_pixel_depth = 64;
- else
- max_pixel_depth = 48;
- }
- }
-#endif
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) && \
-defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
- if (png_ptr->transformations & PNG_USER_TRANSFORM)
- {
- int user_pixel_depth = png_ptr->user_transform_depth*
- png_ptr->user_transform_channels;
- if (user_pixel_depth > max_pixel_depth)
- max_pixel_depth=user_pixel_depth;
- }
-#endif
-
- /* align the width on the next larger 8 pixels. Mainly used
- for interlacing */
- row_bytes = ((png_ptr->width + 7) & ~((png_uint_32)7));
- /* calculate the maximum bytes needed, adding a byte and a pixel
- for safety's sake */
- row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +
- 1 + ((max_pixel_depth + 7) >> 3);
-#ifdef PNG_MAX_MALLOC_64K
- if (row_bytes > (png_uint_32)65536L)
- png_error(png_ptr, "This image requires a row greater than 64KB");
-#endif
-
- if (row_bytes + 64 > png_ptr->old_big_row_buf_size)
- {
- png_free(png_ptr, png_ptr->big_row_buf);
- png_ptr->big_row_buf = (png_bytep)png_malloc(png_ptr, row_bytes + 64);
- if (png_ptr->interlaced)
- png_memset(png_ptr->big_row_buf, 0, png_ptr->rowbytes + 64);
- png_ptr->row_buf = png_ptr->big_row_buf + 32;
- png_ptr->old_big_row_buf_size = row_bytes + 64;
- }
-
-#ifdef PNG_MAX_MALLOC_64K
- if ((png_uint_32)png_ptr->rowbytes + 1 > (png_uint_32)65536L)
- png_error(png_ptr, "This image requires a row greater than 64KB");
-#endif
- if ((png_uint_32)png_ptr->rowbytes > (png_uint_32)(PNG_SIZE_MAX - 1))
- png_error(png_ptr, "Row has too many bytes to allocate in memory.");
-
- if (png_ptr->rowbytes+1 > png_ptr->old_prev_row_size)
- {
- png_free(png_ptr, png_ptr->prev_row);
- png_ptr->prev_row = (png_bytep)png_malloc(png_ptr, (png_uint_32)(
- png_ptr->rowbytes + 1));
- png_ptr->old_prev_row_size = png_ptr->rowbytes+1;
- }
-
- png_memset_check(png_ptr, png_ptr->prev_row, 0, png_ptr->rowbytes + 1);
-
- png_debug1(3, "width = %lu,", png_ptr->width);
- png_debug1(3, "height = %lu,", png_ptr->height);
- png_debug1(3, "iwidth = %lu,", png_ptr->iwidth);
- png_debug1(3, "num_rows = %lu,", png_ptr->num_rows);
- png_debug1(3, "rowbytes = %lu,", png_ptr->rowbytes);
- png_debug1(3, "irowbytes = %lu", png_ptr->irowbytes);
-
- png_ptr->flags |= PNG_FLAG_ROW_INIT;
-}
-#endif /* PNG_READ_SUPPORTED */
diff --git a/navit/support/libpng/pngset.c b/navit/support/libpng/pngset.c
deleted file mode 100644
index 9aa29f12e..000000000
--- a/navit/support/libpng/pngset.c
+++ /dev/null
@@ -1,1253 +0,0 @@
-
-/* pngset.c - storage of image information into info struct
- *
- * Last changed in libpng 1.2.36 [May 7, 2009]
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2009 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- *
- * The functions here are used during reads to store data from the file
- * into the info struct, and during writes to store application data
- * into the info struct for writing into the file. This abstracts the
- * info struct and allows us to change the structure in the future.
- */
-
-#define PNG_INTERNAL
-#include "png.h"
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-
-#if defined(PNG_bKGD_SUPPORTED)
-void PNGAPI
-png_set_bKGD(png_structp png_ptr, png_infop info_ptr, png_color_16p background)
-{
- png_debug1(1, "in %s storage function", "bKGD");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- png_memcpy(&(info_ptr->background), background, png_sizeof(png_color_16));
- info_ptr->valid |= PNG_INFO_bKGD;
-}
-#endif
-
-#if defined(PNG_cHRM_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_cHRM(png_structp png_ptr, png_infop info_ptr,
- double white_x, double white_y, double red_x, double red_y,
- double green_x, double green_y, double blue_x, double blue_y)
-{
- png_debug1(1, "in %s storage function", "cHRM");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- info_ptr->x_white = (float)white_x;
- info_ptr->y_white = (float)white_y;
- info_ptr->x_red = (float)red_x;
- info_ptr->y_red = (float)red_y;
- info_ptr->x_green = (float)green_x;
- info_ptr->y_green = (float)green_y;
- info_ptr->x_blue = (float)blue_x;
- info_ptr->y_blue = (float)blue_y;
-#ifdef PNG_FIXED_POINT_SUPPORTED
- info_ptr->int_x_white = (png_fixed_point)(white_x*100000.+0.5);
- info_ptr->int_y_white = (png_fixed_point)(white_y*100000.+0.5);
- info_ptr->int_x_red = (png_fixed_point)( red_x*100000.+0.5);
- info_ptr->int_y_red = (png_fixed_point)( red_y*100000.+0.5);
- info_ptr->int_x_green = (png_fixed_point)(green_x*100000.+0.5);
- info_ptr->int_y_green = (png_fixed_point)(green_y*100000.+0.5);
- info_ptr->int_x_blue = (png_fixed_point)( blue_x*100000.+0.5);
- info_ptr->int_y_blue = (png_fixed_point)( blue_y*100000.+0.5);
-#endif
- info_ptr->valid |= PNG_INFO_cHRM;
-}
-#endif /* PNG_FLOATING_POINT_SUPPORTED */
-
-#ifdef PNG_FIXED_POINT_SUPPORTED
-void PNGAPI
-png_set_cHRM_fixed(png_structp png_ptr, png_infop info_ptr,
- png_fixed_point white_x, png_fixed_point white_y, png_fixed_point red_x,
- png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
- png_fixed_point blue_x, png_fixed_point blue_y)
-{
- png_debug1(1, "in %s storage function", "cHRM fixed");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
-#if !defined(PNG_NO_CHECK_cHRM)
- if (png_check_cHRM_fixed(png_ptr,
- white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y))
-#endif
- {
- info_ptr->int_x_white = white_x;
- info_ptr->int_y_white = white_y;
- info_ptr->int_x_red = red_x;
- info_ptr->int_y_red = red_y;
- info_ptr->int_x_green = green_x;
- info_ptr->int_y_green = green_y;
- info_ptr->int_x_blue = blue_x;
- info_ptr->int_y_blue = blue_y;
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- info_ptr->x_white = (float)(white_x/100000.);
- info_ptr->y_white = (float)(white_y/100000.);
- info_ptr->x_red = (float)( red_x/100000.);
- info_ptr->y_red = (float)( red_y/100000.);
- info_ptr->x_green = (float)(green_x/100000.);
- info_ptr->y_green = (float)(green_y/100000.);
- info_ptr->x_blue = (float)( blue_x/100000.);
- info_ptr->y_blue = (float)( blue_y/100000.);
-#endif
- info_ptr->valid |= PNG_INFO_cHRM;
- }
-}
-#endif /* PNG_FIXED_POINT_SUPPORTED */
-#endif /* PNG_cHRM_SUPPORTED */
-
-#if defined(PNG_gAMA_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_gAMA(png_structp png_ptr, png_infop info_ptr, double file_gamma)
-{
- double png_gamma;
- png_debug1(1, "in %s storage function", "gAMA");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- /* Check for overflow */
- if (file_gamma > 21474.83)
- {
- png_warning(png_ptr, "Limiting gamma to 21474.83");
- png_gamma=21474.83;
- }
- else
- png_gamma = file_gamma;
- info_ptr->gamma = (float)png_gamma;
-#ifdef PNG_FIXED_POINT_SUPPORTED
- info_ptr->int_gamma = (int)(png_gamma*100000.+.5);
-#endif
- info_ptr->valid |= PNG_INFO_gAMA;
- if (png_gamma == 0.0)
- png_warning(png_ptr, "Setting gamma=0");
-}
-#endif
-void PNGAPI
-png_set_gAMA_fixed(png_structp png_ptr, png_infop info_ptr, png_fixed_point
- int_gamma)
-{
- png_fixed_point png_gamma;
-
- png_debug1(1, "in %s storage function", "gAMA");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- if (int_gamma > (png_fixed_point) PNG_UINT_31_MAX)
- {
- png_warning(png_ptr, "Limiting gamma to 21474.83");
- png_gamma=PNG_UINT_31_MAX;
- }
- else
- {
- if (int_gamma < 0)
- {
- png_warning(png_ptr, "Setting negative gamma to zero");
- png_gamma = 0;
- }
- else
- png_gamma = int_gamma;
- }
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- info_ptr->gamma = (float)(png_gamma/100000.);
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
- info_ptr->int_gamma = png_gamma;
-#endif
- info_ptr->valid |= PNG_INFO_gAMA;
- if (png_gamma == 0)
- png_warning(png_ptr, "Setting gamma=0");
-}
-#endif
-
-#if defined(PNG_hIST_SUPPORTED)
-void PNGAPI
-png_set_hIST(png_structp png_ptr, png_infop info_ptr, png_uint_16p hist)
-{
- int i;
-
- png_debug1(1, "in %s storage function", "hIST");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
- if (info_ptr->num_palette == 0 || info_ptr->num_palette
- > PNG_MAX_PALETTE_LENGTH)
- {
- png_warning(png_ptr,
- "Invalid palette size, hIST allocation skipped.");
- return;
- }
-
-#ifdef PNG_FREE_ME_SUPPORTED
- png_free_data(png_ptr, info_ptr, PNG_FREE_HIST, 0);
-#endif
- /* Changed from info->num_palette to PNG_MAX_PALETTE_LENGTH in version
- 1.2.1 */
- png_ptr->hist = (png_uint_16p)png_malloc_warn(png_ptr,
- (png_uint_32)(PNG_MAX_PALETTE_LENGTH * png_sizeof(png_uint_16)));
- if (png_ptr->hist == NULL)
- {
- png_warning(png_ptr, "Insufficient memory for hIST chunk data.");
- return;
- }
-
- for (i = 0; i < info_ptr->num_palette; i++)
- png_ptr->hist[i] = hist[i];
- info_ptr->hist = png_ptr->hist;
- info_ptr->valid |= PNG_INFO_hIST;
-
-#ifdef PNG_FREE_ME_SUPPORTED
- info_ptr->free_me |= PNG_FREE_HIST;
-#else
- png_ptr->flags |= PNG_FLAG_FREE_HIST;
-#endif
-}
-#endif
-
-void PNGAPI
-png_set_IHDR(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 width, png_uint_32 height, int bit_depth,
- int color_type, int interlace_type, int compression_type,
- int filter_type)
-{
- png_debug1(1, "in %s storage function", "IHDR");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- /* check for width and height valid values */
- if (width == 0 || height == 0)
- png_error(png_ptr, "Image width or height is zero in IHDR");
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (width > png_ptr->user_width_max || height > png_ptr->user_height_max)
- png_error(png_ptr, "image size exceeds user limits in IHDR");
-#else
- if (width > PNG_USER_WIDTH_MAX || height > PNG_USER_HEIGHT_MAX)
- png_error(png_ptr, "image size exceeds user limits in IHDR");
-#endif
- if (width > PNG_UINT_31_MAX || height > PNG_UINT_31_MAX)
- png_error(png_ptr, "Invalid image size in IHDR");
- if ( width > (PNG_UINT_32_MAX
- >> 3) /* 8-byte RGBA pixels */
- - 64 /* bigrowbuf hack */
- - 1 /* filter byte */
- - 7*8 /* rounding of width to multiple of 8 pixels */
- - 8) /* extra max_pixel_depth pad */
- png_warning(png_ptr, "Width is too large for libpng to process pixels");
-
- /* check other values */
- if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
- bit_depth != 8 && bit_depth != 16)
- png_error(png_ptr, "Invalid bit depth in IHDR");
-
- if (color_type < 0 || color_type == 1 ||
- color_type == 5 || color_type > 6)
- png_error(png_ptr, "Invalid color type in IHDR");
-
- if (((color_type == PNG_COLOR_TYPE_PALETTE) && bit_depth > 8) ||
- ((color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_GRAY_ALPHA ||
- color_type == PNG_COLOR_TYPE_RGB_ALPHA) && bit_depth < 8))
- png_error(png_ptr, "Invalid color type/bit depth combination in IHDR");
-
- if (interlace_type >= PNG_INTERLACE_LAST)
- png_error(png_ptr, "Unknown interlace method in IHDR");
-
- if (compression_type != PNG_COMPRESSION_TYPE_BASE)
- png_error(png_ptr, "Unknown compression method in IHDR");
-
-#if defined(PNG_MNG_FEATURES_SUPPORTED)
- /* Accept filter_method 64 (intrapixel differencing) only if
- * 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
- * 2. Libpng did not read a PNG signature (this filter_method is only
- * used in PNG datastreams that are embedded in MNG datastreams) and
- * 3. The application called png_permit_mng_features with a mask that
- * included PNG_FLAG_MNG_FILTER_64 and
- * 4. The filter_method is 64 and
- * 5. The color_type is RGB or RGBA
- */
- if ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)&&png_ptr->mng_features_permitted)
- png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
- if (filter_type != PNG_FILTER_TYPE_BASE)
- {
- if (!((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
- (filter_type == PNG_INTRAPIXEL_DIFFERENCING) &&
- ((png_ptr->mode&PNG_HAVE_PNG_SIGNATURE) == 0) &&
- (color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_RGB_ALPHA)))
- png_error(png_ptr, "Unknown filter method in IHDR");
- if (png_ptr->mode&PNG_HAVE_PNG_SIGNATURE)
- png_warning(png_ptr, "Invalid filter method in IHDR");
- }
-#else
- if (filter_type != PNG_FILTER_TYPE_BASE)
- png_error(png_ptr, "Unknown filter method in IHDR");
-#endif
-
- info_ptr->width = width;
- info_ptr->height = height;
- info_ptr->bit_depth = (png_byte)bit_depth;
- info_ptr->color_type =(png_byte) color_type;
- info_ptr->compression_type = (png_byte)compression_type;
- info_ptr->filter_type = (png_byte)filter_type;
- info_ptr->interlace_type = (png_byte)interlace_type;
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- info_ptr->channels = 1;
- else if (info_ptr->color_type & PNG_COLOR_MASK_COLOR)
- info_ptr->channels = 3;
- else
- info_ptr->channels = 1;
- if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
- info_ptr->channels++;
- info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
-
- /* check for potential overflow */
- if (width > (PNG_UINT_32_MAX
- >> 3) /* 8-byte RGBA pixels */
- - 64 /* bigrowbuf hack */
- - 1 /* filter byte */
- - 7*8 /* rounding of width to multiple of 8 pixels */
- - 8) /* extra max_pixel_depth pad */
- info_ptr->rowbytes = (png_size_t)0;
- else
- info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
-}
-
-#if defined(PNG_oFFs_SUPPORTED)
-void PNGAPI
-png_set_oFFs(png_structp png_ptr, png_infop info_ptr,
- png_int_32 offset_x, png_int_32 offset_y, int unit_type)
-{
- png_debug1(1, "in %s storage function", "oFFs");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- info_ptr->x_offset = offset_x;
- info_ptr->y_offset = offset_y;
- info_ptr->offset_unit_type = (png_byte)unit_type;
- info_ptr->valid |= PNG_INFO_oFFs;
-}
-#endif
-
-#if defined(PNG_pCAL_SUPPORTED)
-void PNGAPI
-png_set_pCAL(png_structp png_ptr, png_infop info_ptr,
- png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
- png_charp units, png_charpp params)
-{
- png_uint_32 length;
- int i;
-
- png_debug1(1, "in %s storage function", "pCAL");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- length = png_strlen(purpose) + 1;
- png_debug1(3, "allocating purpose for info (%lu bytes)",
- (unsigned long)length);
- info_ptr->pcal_purpose = (png_charp)png_malloc_warn(png_ptr, length);
- if (info_ptr->pcal_purpose == NULL)
- {
- png_warning(png_ptr, "Insufficient memory for pCAL purpose.");
- return;
- }
- png_memcpy(info_ptr->pcal_purpose, purpose, (png_size_t)length);
-
- png_debug(3, "storing X0, X1, type, and nparams in info");
- info_ptr->pcal_X0 = X0;
- info_ptr->pcal_X1 = X1;
- info_ptr->pcal_type = (png_byte)type;
- info_ptr->pcal_nparams = (png_byte)nparams;
-
- length = png_strlen(units) + 1;
- png_debug1(3, "allocating units for info (%lu bytes)",
- (unsigned long)length);
- info_ptr->pcal_units = (png_charp)png_malloc_warn(png_ptr, length);
- if (info_ptr->pcal_units == NULL)
- {
- png_warning(png_ptr, "Insufficient memory for pCAL units.");
- return;
- }
- png_memcpy(info_ptr->pcal_units, units, (png_size_t)length);
-
- info_ptr->pcal_params = (png_charpp)png_malloc_warn(png_ptr,
- (png_uint_32)((nparams + 1) * png_sizeof(png_charp)));
- if (info_ptr->pcal_params == NULL)
- {
- png_warning(png_ptr, "Insufficient memory for pCAL params.");
- return;
- }
-
- png_memset(info_ptr->pcal_params, 0, (nparams + 1) * png_sizeof(png_charp));
-
- for (i = 0; i < nparams; i++)
- {
- length = png_strlen(params[i]) + 1;
- png_debug2(3, "allocating parameter %d for info (%lu bytes)", i,
- (unsigned long)length);
- info_ptr->pcal_params[i] = (png_charp)png_malloc_warn(png_ptr, length);
- if (info_ptr->pcal_params[i] == NULL)
- {
- png_warning(png_ptr, "Insufficient memory for pCAL parameter.");
- return;
- }
- png_memcpy(info_ptr->pcal_params[i], params[i], (png_size_t)length);
- }
-
- info_ptr->valid |= PNG_INFO_pCAL;
-#ifdef PNG_FREE_ME_SUPPORTED
- info_ptr->free_me |= PNG_FREE_PCAL;
-#endif
-}
-#endif
-
-#if defined(PNG_READ_sCAL_SUPPORTED) || defined(PNG_WRITE_sCAL_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
-void PNGAPI
-png_set_sCAL(png_structp png_ptr, png_infop info_ptr,
- int unit, double width, double height)
-{
- png_debug1(1, "in %s storage function", "sCAL");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- info_ptr->scal_unit = (png_byte)unit;
- info_ptr->scal_pixel_width = width;
- info_ptr->scal_pixel_height = height;
-
- info_ptr->valid |= PNG_INFO_sCAL;
-}
-#else
-#ifdef PNG_FIXED_POINT_SUPPORTED
-void PNGAPI
-png_set_sCAL_s(png_structp png_ptr, png_infop info_ptr,
- int unit, png_charp swidth, png_charp sheight)
-{
- png_uint_32 length;
-
- png_debug1(1, "in %s storage function", "sCAL");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- info_ptr->scal_unit = (png_byte)unit;
-
- length = png_strlen(swidth) + 1;
- png_debug1(3, "allocating unit for info (%u bytes)",
- (unsigned int)length);
- info_ptr->scal_s_width = (png_charp)png_malloc_warn(png_ptr, length);
- if (info_ptr->scal_s_width == NULL)
- {
- png_warning(png_ptr,
- "Memory allocation failed while processing sCAL.");
- return;
- }
- png_memcpy(info_ptr->scal_s_width, swidth, (png_size_t)length);
-
- length = png_strlen(sheight) + 1;
- png_debug1(3, "allocating unit for info (%u bytes)",
- (unsigned int)length);
- info_ptr->scal_s_height = (png_charp)png_malloc_warn(png_ptr, length);
- if (info_ptr->scal_s_height == NULL)
- {
- png_free (png_ptr, info_ptr->scal_s_width);
- info_ptr->scal_s_width = NULL;
- png_warning(png_ptr,
- "Memory allocation failed while processing sCAL.");
- return;
- }
- png_memcpy(info_ptr->scal_s_height, sheight, (png_size_t)length);
- info_ptr->valid |= PNG_INFO_sCAL;
-#ifdef PNG_FREE_ME_SUPPORTED
- info_ptr->free_me |= PNG_FREE_SCAL;
-#endif
-}
-#endif
-#endif
-#endif
-
-#if defined(PNG_pHYs_SUPPORTED)
-void PNGAPI
-png_set_pHYs(png_structp png_ptr, png_infop info_ptr,
- png_uint_32 res_x, png_uint_32 res_y, int unit_type)
-{
- png_debug1(1, "in %s storage function", "pHYs");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- info_ptr->x_pixels_per_unit = res_x;
- info_ptr->y_pixels_per_unit = res_y;
- info_ptr->phys_unit_type = (png_byte)unit_type;
- info_ptr->valid |= PNG_INFO_pHYs;
-}
-#endif
-
-void PNGAPI
-png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
- png_colorp palette, int num_palette)
-{
-
- png_debug1(1, "in %s storage function", "PLTE");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
- {
- if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- png_error(png_ptr, "Invalid palette length");
- else
- {
- png_warning(png_ptr, "Invalid palette length");
- return;
- }
- }
-
- /*
- * It may not actually be necessary to set png_ptr->palette here;
- * we do it for backward compatibility with the way the png_handle_tRNS
- * function used to do the allocation.
- */
-#ifdef PNG_FREE_ME_SUPPORTED
- png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
-#endif
-
- /* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
- of num_palette entries,
- in case of an invalid PNG file that has too-large sample values. */
- png_ptr->palette = (png_colorp)png_malloc(png_ptr,
- PNG_MAX_PALETTE_LENGTH * png_sizeof(png_color));
- png_memset(png_ptr->palette, 0, PNG_MAX_PALETTE_LENGTH *
- png_sizeof(png_color));
- png_memcpy(png_ptr->palette, palette, num_palette * png_sizeof(png_color));
- info_ptr->palette = png_ptr->palette;
- info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
-
-#ifdef PNG_FREE_ME_SUPPORTED
- info_ptr->free_me |= PNG_FREE_PLTE;
-#else
- png_ptr->flags |= PNG_FLAG_FREE_PLTE;
-#endif
-
- info_ptr->valid |= PNG_INFO_PLTE;
-}
-
-#if defined(PNG_sBIT_SUPPORTED)
-void PNGAPI
-png_set_sBIT(png_structp png_ptr, png_infop info_ptr,
- png_color_8p sig_bit)
-{
- png_debug1(1, "in %s storage function", "sBIT");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- png_memcpy(&(info_ptr->sig_bit), sig_bit, png_sizeof(png_color_8));
- info_ptr->valid |= PNG_INFO_sBIT;
-}
-#endif
-
-#if defined(PNG_sRGB_SUPPORTED)
-void PNGAPI
-png_set_sRGB(png_structp png_ptr, png_infop info_ptr, int intent)
-{
- png_debug1(1, "in %s storage function", "sRGB");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- info_ptr->srgb_intent = (png_byte)intent;
- info_ptr->valid |= PNG_INFO_sRGB;
-}
-
-void PNGAPI
-png_set_sRGB_gAMA_and_cHRM(png_structp png_ptr, png_infop info_ptr,
- int intent)
-{
-#if defined(PNG_gAMA_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- float file_gamma;
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
- png_fixed_point int_file_gamma;
-#endif
-#endif
-#if defined(PNG_cHRM_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- float white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
-#endif
- png_fixed_point int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
- int_green_y, int_blue_x, int_blue_y;
-#endif
- png_debug1(1, "in %s storage function", "sRGB_gAMA_and_cHRM");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- png_set_sRGB(png_ptr, info_ptr, intent);
-
-#if defined(PNG_gAMA_SUPPORTED)
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- file_gamma = (float).45455;
- png_set_gAMA(png_ptr, info_ptr, file_gamma);
-#endif
-#ifdef PNG_FIXED_POINT_SUPPORTED
- int_file_gamma = 45455L;
- png_set_gAMA_fixed(png_ptr, info_ptr, int_file_gamma);
-#endif
-#endif
-
-#if defined(PNG_cHRM_SUPPORTED)
- int_white_x = 31270L;
- int_white_y = 32900L;
- int_red_x = 64000L;
- int_red_y = 33000L;
- int_green_x = 30000L;
- int_green_y = 60000L;
- int_blue_x = 15000L;
- int_blue_y = 6000L;
-
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- white_x = (float).3127;
- white_y = (float).3290;
- red_x = (float).64;
- red_y = (float).33;
- green_x = (float).30;
- green_y = (float).60;
- blue_x = (float).15;
- blue_y = (float).06;
-#endif
-
-#if !defined(PNG_NO_CHECK_cHRM)
- if (png_check_cHRM_fixed(png_ptr,
- int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
- int_green_y, int_blue_x, int_blue_y))
-#endif
- {
-#ifdef PNG_FIXED_POINT_SUPPORTED
- png_set_cHRM_fixed(png_ptr, info_ptr,
- int_white_x, int_white_y, int_red_x, int_red_y, int_green_x,
- int_green_y, int_blue_x, int_blue_y);
-#endif
-#ifdef PNG_FLOATING_POINT_SUPPORTED
- png_set_cHRM(png_ptr, info_ptr,
- white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y);
-#endif
- }
-#endif /* cHRM */
-}
-#endif /* sRGB */
-
-
-#if defined(PNG_iCCP_SUPPORTED)
-void PNGAPI
-png_set_iCCP(png_structp png_ptr, png_infop info_ptr,
- png_charp name, int compression_type,
- png_charp profile, png_uint_32 proflen)
-{
- png_charp new_iccp_name;
- png_charp new_iccp_profile;
- png_uint_32 length;
-
- png_debug1(1, "in %s storage function", "iCCP");
- if (png_ptr == NULL || info_ptr == NULL || name == NULL || profile == NULL)
- return;
-
- length = png_strlen(name)+1;
- new_iccp_name = (png_charp)png_malloc_warn(png_ptr, length);
- if (new_iccp_name == NULL)
- {
- png_warning(png_ptr, "Insufficient memory to process iCCP chunk.");
- return;
- }
- png_memcpy(new_iccp_name, name, length);
- new_iccp_profile = (png_charp)png_malloc_warn(png_ptr, proflen);
- if (new_iccp_profile == NULL)
- {
- png_free (png_ptr, new_iccp_name);
- png_warning(png_ptr,
- "Insufficient memory to process iCCP profile.");
- return;
- }
- png_memcpy(new_iccp_profile, profile, (png_size_t)proflen);
-
- png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, 0);
-
- info_ptr->iccp_proflen = proflen;
- info_ptr->iccp_name = new_iccp_name;
- info_ptr->iccp_profile = new_iccp_profile;
- /* Compression is always zero but is here so the API and info structure
- * does not have to change if we introduce multiple compression types */
- info_ptr->iccp_compression = (png_byte)compression_type;
-#ifdef PNG_FREE_ME_SUPPORTED
- info_ptr->free_me |= PNG_FREE_ICCP;
-#endif
- info_ptr->valid |= PNG_INFO_iCCP;
-}
-#endif
-
-#if defined(PNG_TEXT_SUPPORTED)
-void PNGAPI
-png_set_text(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
- int num_text)
-{
- int ret;
- ret = png_set_text_2(png_ptr, info_ptr, text_ptr, num_text);
- if (ret)
- png_error(png_ptr, "Insufficient memory to store text");
-}
-
-int /* PRIVATE */
-png_set_text_2(png_structp png_ptr, png_infop info_ptr, png_textp text_ptr,
- int num_text)
-{
- int i;
-
- png_debug1(1, "in %s storage function", (png_ptr->chunk_name[0] == '\0' ?
- "text" : (png_const_charp)png_ptr->chunk_name));
-
- if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
- return(0);
-
- /* Make sure we have enough space in the "text" array in info_struct
- * to hold all of the incoming text_ptr objects.
- */
- if (info_ptr->num_text + num_text > info_ptr->max_text)
- {
- if (info_ptr->text != NULL)
- {
- png_textp old_text;
- int old_max;
-
- old_max = info_ptr->max_text;
- info_ptr->max_text = info_ptr->num_text + num_text + 8;
- old_text = info_ptr->text;
- info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
- (png_uint_32)(info_ptr->max_text * png_sizeof(png_text)));
- if (info_ptr->text == NULL)
- {
- png_free(png_ptr, old_text);
- return(1);
- }
- png_memcpy(info_ptr->text, old_text, (png_size_t)(old_max *
- png_sizeof(png_text)));
- png_free(png_ptr, old_text);
- }
- else
- {
- info_ptr->max_text = num_text + 8;
- info_ptr->num_text = 0;
- info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
- (png_uint_32)(info_ptr->max_text * png_sizeof(png_text)));
- if (info_ptr->text == NULL)
- return(1);
-#ifdef PNG_FREE_ME_SUPPORTED
- info_ptr->free_me |= PNG_FREE_TEXT;
-#endif
- }
- png_debug1(3, "allocated %d entries for info_ptr->text",
- info_ptr->max_text);
- }
- for (i = 0; i < num_text; i++)
- {
- png_size_t text_length, key_len;
- png_size_t lang_len, lang_key_len;
- png_textp textp = &(info_ptr->text[info_ptr->num_text]);
-
- if (text_ptr[i].key == NULL)
- continue;
-
- key_len = png_strlen(text_ptr[i].key);
-
- if (text_ptr[i].compression <= 0)
- {
- lang_len = 0;
- lang_key_len = 0;
- }
- else
-#ifdef PNG_iTXt_SUPPORTED
- {
- /* set iTXt data */
- if (text_ptr[i].lang != NULL)
- lang_len = png_strlen(text_ptr[i].lang);
- else
- lang_len = 0;
- if (text_ptr[i].lang_key != NULL)
- lang_key_len = png_strlen(text_ptr[i].lang_key);
- else
- lang_key_len = 0;
- }
-#else
- {
- png_warning(png_ptr, "iTXt chunk not supported.");
- continue;
- }
-#endif
-
- if (text_ptr[i].text == NULL || text_ptr[i].text[0] == '\0')
- {
- text_length = 0;
-#ifdef PNG_iTXt_SUPPORTED
- if (text_ptr[i].compression > 0)
- textp->compression = PNG_ITXT_COMPRESSION_NONE;
- else
-#endif
- textp->compression = PNG_TEXT_COMPRESSION_NONE;
- }
- else
- {
- text_length = png_strlen(text_ptr[i].text);
- textp->compression = text_ptr[i].compression;
- }
-
- textp->key = (png_charp)png_malloc_warn(png_ptr,
- (png_uint_32)
- (key_len + text_length + lang_len + lang_key_len + 4));
- if (textp->key == NULL)
- return(1);
- png_debug2(2, "Allocated %lu bytes at %x in png_set_text",
- (png_uint_32)
- (key_len + lang_len + lang_key_len + text_length + 4),
- (int)textp->key);
-
- png_memcpy(textp->key, text_ptr[i].key,
- (png_size_t)(key_len));
- *(textp->key + key_len) = '\0';
-#ifdef PNG_iTXt_SUPPORTED
- if (text_ptr[i].compression > 0)
- {
- textp->lang = textp->key + key_len + 1;
- png_memcpy(textp->lang, text_ptr[i].lang, lang_len);
- *(textp->lang + lang_len) = '\0';
- textp->lang_key = textp->lang + lang_len + 1;
- png_memcpy(textp->lang_key, text_ptr[i].lang_key, lang_key_len);
- *(textp->lang_key + lang_key_len) = '\0';
- textp->text = textp->lang_key + lang_key_len + 1;
- }
- else
-#endif
- {
-#ifdef PNG_iTXt_SUPPORTED
- textp->lang=NULL;
- textp->lang_key=NULL;
-#endif
- textp->text = textp->key + key_len + 1;
- }
- if (text_length)
- png_memcpy(textp->text, text_ptr[i].text,
- (png_size_t)(text_length));
- *(textp->text + text_length) = '\0';
-
-#ifdef PNG_iTXt_SUPPORTED
- if (textp->compression > 0)
- {
- textp->text_length = 0;
- textp->itxt_length = text_length;
- }
- else
-#endif
- {
- textp->text_length = text_length;
-#ifdef PNG_iTXt_SUPPORTED
- textp->itxt_length = 0;
-#endif
- }
- info_ptr->num_text++;
- png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
- }
- return(0);
-}
-#endif
-
-#if defined(PNG_tIME_SUPPORTED)
-void PNGAPI
-png_set_tIME(png_structp png_ptr, png_infop info_ptr, png_timep mod_time)
-{
- png_debug1(1, "in %s storage function", "tIME");
- if (png_ptr == NULL || info_ptr == NULL ||
- (png_ptr->mode & PNG_WROTE_tIME))
- return;
-
- png_memcpy(&(info_ptr->mod_time), mod_time, png_sizeof(png_time));
- info_ptr->valid |= PNG_INFO_tIME;
-}
-#endif
-
-#if defined(PNG_tRNS_SUPPORTED)
-void PNGAPI
-png_set_tRNS(png_structp png_ptr, png_infop info_ptr,
- png_bytep trans, int num_trans, png_color_16p trans_values)
-{
- png_debug1(1, "in %s storage function", "tRNS");
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- if (trans != NULL)
- {
- /*
- * It may not actually be necessary to set png_ptr->trans here;
- * we do it for backward compatibility with the way the png_handle_tRNS
- * function used to do the allocation.
- */
-
-#ifdef PNG_FREE_ME_SUPPORTED
- png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
-#endif
-
- /* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
- png_ptr->trans = info_ptr->trans = (png_bytep)png_malloc(png_ptr,
- (png_uint_32)PNG_MAX_PALETTE_LENGTH);
- if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
- png_memcpy(info_ptr->trans, trans, (png_size_t)num_trans);
- }
-
- if (trans_values != NULL)
- {
- int sample_max = (1 << info_ptr->bit_depth);
- if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
- (int)trans_values->gray > sample_max) ||
- (info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
- ((int)trans_values->red > sample_max ||
- (int)trans_values->green > sample_max ||
- (int)trans_values->blue > sample_max)))
- png_warning(png_ptr,
- "tRNS chunk has out-of-range samples for bit_depth");
- png_memcpy(&(info_ptr->trans_values), trans_values,
- png_sizeof(png_color_16));
- if (num_trans == 0)
- num_trans = 1;
- }
-
- info_ptr->num_trans = (png_uint_16)num_trans;
- if (num_trans != 0)
- {
- info_ptr->valid |= PNG_INFO_tRNS;
-#ifdef PNG_FREE_ME_SUPPORTED
- info_ptr->free_me |= PNG_FREE_TRNS;
-#else
- png_ptr->flags |= PNG_FLAG_FREE_TRNS;
-#endif
- }
-}
-#endif
-
-#if defined(PNG_sPLT_SUPPORTED)
-void PNGAPI
-png_set_sPLT(png_structp png_ptr,
- png_infop info_ptr, png_sPLT_tp entries, int nentries)
-/*
- * entries - array of png_sPLT_t structures
- * to be added to the list of palettes
- * in the info structure.
- * nentries - number of palette structures to be
- * added.
- */
-{
- png_sPLT_tp np;
- int i;
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- np = (png_sPLT_tp)png_malloc_warn(png_ptr,
- (info_ptr->splt_palettes_num + nentries) *
- (png_uint_32)png_sizeof(png_sPLT_t));
- if (np == NULL)
- {
- png_warning(png_ptr, "No memory for sPLT palettes.");
- return;
- }
-
- png_memcpy(np, info_ptr->splt_palettes,
- info_ptr->splt_palettes_num * png_sizeof(png_sPLT_t));
- png_free(png_ptr, info_ptr->splt_palettes);
- info_ptr->splt_palettes=NULL;
-
- for (i = 0; i < nentries; i++)
- {
- png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
- png_sPLT_tp from = entries + i;
- png_uint_32 length;
-
- length = png_strlen(from->name) + 1;
- to->name = (png_charp)png_malloc_warn(png_ptr, length);
- if (to->name == NULL)
- {
- png_warning(png_ptr,
- "Out of memory while processing sPLT chunk");
- continue;
- }
- png_memcpy(to->name, from->name, length);
- to->entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
- (png_uint_32)(from->nentries * png_sizeof(png_sPLT_entry)));
- if (to->entries == NULL)
- {
- png_warning(png_ptr,
- "Out of memory while processing sPLT chunk");
- png_free(png_ptr, to->name);
- to->name = NULL;
- continue;
- }
- png_memcpy(to->entries, from->entries,
- from->nentries * png_sizeof(png_sPLT_entry));
- to->nentries = from->nentries;
- to->depth = from->depth;
- }
-
- info_ptr->splt_palettes = np;
- info_ptr->splt_palettes_num += nentries;
- info_ptr->valid |= PNG_INFO_sPLT;
-#ifdef PNG_FREE_ME_SUPPORTED
- info_ptr->free_me |= PNG_FREE_SPLT;
-#endif
-}
-#endif /* PNG_sPLT_SUPPORTED */
-
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
-void PNGAPI
-png_set_unknown_chunks(png_structp png_ptr,
- png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
-{
- png_unknown_chunkp np;
- int i;
-
- if (png_ptr == NULL || info_ptr == NULL || num_unknowns == 0)
- return;
-
- np = (png_unknown_chunkp)png_malloc_warn(png_ptr,
- (png_uint_32)((info_ptr->unknown_chunks_num + num_unknowns) *
- png_sizeof(png_unknown_chunk)));
- if (np == NULL)
- {
- png_warning(png_ptr,
- "Out of memory while processing unknown chunk.");
- return;
- }
-
- png_memcpy(np, info_ptr->unknown_chunks,
- info_ptr->unknown_chunks_num * png_sizeof(png_unknown_chunk));
- png_free(png_ptr, info_ptr->unknown_chunks);
- info_ptr->unknown_chunks=NULL;
-
- for (i = 0; i < num_unknowns; i++)
- {
- png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
- png_unknown_chunkp from = unknowns + i;
-
- png_memcpy((png_charp)to->name,
- (png_charp)from->name,
- png_sizeof(from->name));
- to->name[png_sizeof(to->name)-1] = '\0';
- to->size = from->size;
- /* note our location in the read or write sequence */
- to->location = (png_byte)(png_ptr->mode & 0xff);
-
- if (from->size == 0)
- to->data=NULL;
- else
- {
- to->data = (png_bytep)png_malloc_warn(png_ptr,
- (png_uint_32)from->size);
- if (to->data == NULL)
- {
- png_warning(png_ptr,
- "Out of memory while processing unknown chunk.");
- to->size = 0;
- }
- else
- png_memcpy(to->data, from->data, from->size);
- }
- }
-
- info_ptr->unknown_chunks = np;
- info_ptr->unknown_chunks_num += num_unknowns;
-#ifdef PNG_FREE_ME_SUPPORTED
- info_ptr->free_me |= PNG_FREE_UNKN;
-#endif
-}
-void PNGAPI
-png_set_unknown_chunk_location(png_structp png_ptr, png_infop info_ptr,
- int chunk, int location)
-{
- if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 && chunk <
- (int)info_ptr->unknown_chunks_num)
- info_ptr->unknown_chunks[chunk].location = (png_byte)location;
-}
-#endif
-
-#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
-#if defined(PNG_READ_EMPTY_PLTE_SUPPORTED) || \
- defined(PNG_WRITE_EMPTY_PLTE_SUPPORTED)
-void PNGAPI
-png_permit_empty_plte (png_structp png_ptr, int empty_plte_permitted)
-{
- /* This function is deprecated in favor of png_permit_mng_features()
- and will be removed from libpng-1.3.0 */
- png_debug(1, "in png_permit_empty_plte, DEPRECATED.");
- if (png_ptr == NULL)
- return;
- png_ptr->mng_features_permitted = (png_byte)
- ((png_ptr->mng_features_permitted & (~PNG_FLAG_MNG_EMPTY_PLTE)) |
- ((empty_plte_permitted & PNG_FLAG_MNG_EMPTY_PLTE)));
-}
-#endif
-#endif
-
-#if defined(PNG_MNG_FEATURES_SUPPORTED)
-png_uint_32 PNGAPI
-png_permit_mng_features (png_structp png_ptr, png_uint_32 mng_features)
-{
- png_debug(1, "in png_permit_mng_features");
- if (png_ptr == NULL)
- return (png_uint_32)0;
- png_ptr->mng_features_permitted =
- (png_byte)(mng_features & PNG_ALL_MNG_FEATURES);
- return (png_uint_32)png_ptr->mng_features_permitted;
-}
-#endif
-
-#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
-void PNGAPI
-png_set_keep_unknown_chunks(png_structp png_ptr, int keep, png_bytep
- chunk_list, int num_chunks)
-{
- png_bytep new_list, p;
- int i, old_num_chunks;
- if (png_ptr == NULL)
- return;
- if (num_chunks == 0)
- {
- if (keep == PNG_HANDLE_CHUNK_ALWAYS || keep == PNG_HANDLE_CHUNK_IF_SAFE)
- png_ptr->flags |= PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
- else
- png_ptr->flags &= ~PNG_FLAG_KEEP_UNKNOWN_CHUNKS;
-
- if (keep == PNG_HANDLE_CHUNK_ALWAYS)
- png_ptr->flags |= PNG_FLAG_KEEP_UNSAFE_CHUNKS;
- else
- png_ptr->flags &= ~PNG_FLAG_KEEP_UNSAFE_CHUNKS;
- return;
- }
- if (chunk_list == NULL)
- return;
- old_num_chunks = png_ptr->num_chunk_list;
- new_list=(png_bytep)png_malloc(png_ptr,
- (png_uint_32)
- (5*(num_chunks + old_num_chunks)));
- if (png_ptr->chunk_list != NULL)
- {
- png_memcpy(new_list, png_ptr->chunk_list,
- (png_size_t)(5*old_num_chunks));
- png_free(png_ptr, png_ptr->chunk_list);
- png_ptr->chunk_list=NULL;
- }
- png_memcpy(new_list + 5*old_num_chunks, chunk_list,
- (png_size_t)(5*num_chunks));
- for (p = new_list + 5*old_num_chunks + 4, i = 0; i<num_chunks; i++, p += 5)
- *p=(png_byte)keep;
- png_ptr->num_chunk_list = old_num_chunks + num_chunks;
- png_ptr->chunk_list = new_list;
-#ifdef PNG_FREE_ME_SUPPORTED
- png_ptr->free_me |= PNG_FREE_LIST;
-#endif
-}
-#endif
-
-#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
-void PNGAPI
-png_set_read_user_chunk_fn(png_structp png_ptr, png_voidp user_chunk_ptr,
- png_user_chunk_ptr read_user_chunk_fn)
-{
- png_debug(1, "in png_set_read_user_chunk_fn");
- if (png_ptr == NULL)
- return;
- png_ptr->read_user_chunk_fn = read_user_chunk_fn;
- png_ptr->user_chunk_ptr = user_chunk_ptr;
-}
-#endif
-
-#if defined(PNG_INFO_IMAGE_SUPPORTED)
-void PNGAPI
-png_set_rows(png_structp png_ptr, png_infop info_ptr, png_bytepp row_pointers)
-{
- png_debug1(1, "in %s storage function", "rows");
-
- if (png_ptr == NULL || info_ptr == NULL)
- return;
-
- if (info_ptr->row_pointers && (info_ptr->row_pointers != row_pointers))
- png_free_data(png_ptr, info_ptr, PNG_FREE_ROWS, 0);
- info_ptr->row_pointers = row_pointers;
- if (row_pointers)
- info_ptr->valid |= PNG_INFO_IDAT;
-}
-#endif
-
-#ifdef PNG_WRITE_SUPPORTED
-void PNGAPI
-png_set_compression_buffer_size(png_structp png_ptr,
- png_uint_32 size)
-{
- if (png_ptr == NULL)
- return;
- png_free(png_ptr, png_ptr->zbuf);
- png_ptr->zbuf_size = (png_size_t)size;
- png_ptr->zbuf = (png_bytep)png_malloc(png_ptr, size);
- png_ptr->zstream.next_out = png_ptr->zbuf;
- png_ptr->zstream.avail_out = (uInt)png_ptr->zbuf_size;
-}
-#endif
-
-void PNGAPI
-png_set_invalid(png_structp png_ptr, png_infop info_ptr, int mask)
-{
- if (png_ptr && info_ptr)
- info_ptr->valid &= ~mask;
-}
-
-
-#ifndef PNG_1_0_X
-#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
-/* function was added to libpng 1.2.0 and should always exist by default */
-void PNGAPI
-png_set_asm_flags (png_structp png_ptr, png_uint_32 asm_flags)
-{
-/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
- if (png_ptr != NULL)
- png_ptr->asm_flags = 0;
- asm_flags = asm_flags; /* Quiet the compiler */
-}
-
-/* this function was added to libpng 1.2.0 */
-void PNGAPI
-png_set_mmx_thresholds (png_structp png_ptr,
- png_byte mmx_bitdepth_threshold,
- png_uint_32 mmx_rowbytes_threshold)
-{
-/* Obsolete as of libpng-1.2.20 and will be removed from libpng-1.4.0 */
- if (png_ptr == NULL)
- return;
- /* Quiet the compiler */
- mmx_bitdepth_threshold = mmx_bitdepth_threshold;
- mmx_rowbytes_threshold = mmx_rowbytes_threshold;
-}
-#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
-
-#ifdef PNG_SET_USER_LIMITS_SUPPORTED
-/* this function was added to libpng 1.2.6 */
-void PNGAPI
-png_set_user_limits (png_structp png_ptr, png_uint_32 user_width_max,
- png_uint_32 user_height_max)
-{
- /* Images with dimensions larger than these limits will be
- * rejected by png_set_IHDR(). To accept any PNG datastream
- * regardless of dimensions, set both limits to 0x7ffffffL.
- */
- if (png_ptr == NULL) return;
- png_ptr->user_width_max = user_width_max;
- png_ptr->user_height_max = user_height_max;
-}
-#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
-
-#endif /* ?PNG_1_0_X */
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
diff --git a/navit/support/libpng/pngtrans.c b/navit/support/libpng/pngtrans.c
deleted file mode 100644
index f92f4b02d..000000000
--- a/navit/support/libpng/pngtrans.c
+++ /dev/null
@@ -1,662 +0,0 @@
-
-/* pngtrans.c - transforms the data in a row (used by both readers and writers)
- *
- * Last changed in libpng 1.2.30 [August 15, 2008]
- * For conditions of distribution and use, see copyright notice in png.h
- * Copyright (c) 1998-2008 Glenn Randers-Pehrson
- * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
- * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
- */
-
-#define PNG_INTERNAL
-#include "png.h"
-#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-
-#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
-/* turn on BGR-to-RGB mapping */
-void PNGAPI
-png_set_bgr(png_structp png_ptr)
-{
- png_debug(1, "in png_set_bgr");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= PNG_BGR;
-}
-#endif
-
-#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-/* turn on 16 bit byte swapping */
-void PNGAPI
-png_set_swap(png_structp png_ptr)
-{
- png_debug(1, "in png_set_swap");
- if (png_ptr == NULL) return;
- if (png_ptr->bit_depth == 16)
- png_ptr->transformations |= PNG_SWAP_BYTES;
-}
-#endif
-
-#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
-/* turn on pixel packing */
-void PNGAPI
-png_set_packing(png_structp png_ptr)
-{
- png_debug(1, "in png_set_packing");
- if (png_ptr == NULL) return;
- if (png_ptr->bit_depth < 8)
- {
- png_ptr->transformations |= PNG_PACK;
- png_ptr->usr_bit_depth = 8;
- }
-}
-#endif
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-/* turn on packed pixel swapping */
-void PNGAPI
-png_set_packswap(png_structp png_ptr)
-{
- png_debug(1, "in png_set_packswap");
- if (png_ptr == NULL) return;
- if (png_ptr->bit_depth < 8)
- png_ptr->transformations |= PNG_PACKSWAP;
-}
-#endif
-
-#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
-void PNGAPI
-png_set_shift(png_structp png_ptr, png_color_8p true_bits)
-{
- png_debug(1, "in png_set_shift");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= PNG_SHIFT;
- png_ptr->shift = *true_bits;
-}
-#endif
-
-#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
- defined(PNG_WRITE_INTERLACING_SUPPORTED)
-int PNGAPI
-png_set_interlace_handling(png_structp png_ptr)
-{
- png_debug(1, "in png_set_interlace handling");
- if (png_ptr && png_ptr->interlaced)
- {
- png_ptr->transformations |= PNG_INTERLACE;
- return (7);
- }
-
- return (1);
-}
-#endif
-
-#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
-/* Add a filler byte on read, or remove a filler or alpha byte on write.
- * The filler type has changed in v0.95 to allow future 2-byte fillers
- * for 48-bit input data, as well as to avoid problems with some compilers
- * that don't like bytes as parameters.
- */
-void PNGAPI
-png_set_filler(png_structp png_ptr, png_uint_32 filler, int filler_loc)
-{
- png_debug(1, "in png_set_filler");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= PNG_FILLER;
- png_ptr->filler = (png_byte)filler;
- if (filler_loc == PNG_FILLER_AFTER)
- png_ptr->flags |= PNG_FLAG_FILLER_AFTER;
- else
- png_ptr->flags &= ~PNG_FLAG_FILLER_AFTER;
-
- /* This should probably go in the "do_read_filler" routine.
- * I attempted to do that in libpng-1.0.1a but that caused problems
- * so I restored it in libpng-1.0.2a
- */
-
- if (png_ptr->color_type == PNG_COLOR_TYPE_RGB)
- {
- png_ptr->usr_channels = 4;
- }
-
- /* Also I added this in libpng-1.0.2a (what happens when we expand
- * a less-than-8-bit grayscale to GA? */
-
- if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY && png_ptr->bit_depth >= 8)
- {
- png_ptr->usr_channels = 2;
- }
-}
-
-#if !defined(PNG_1_0_X)
-/* Added to libpng-1.2.7 */
-void PNGAPI
-png_set_add_alpha(png_structp png_ptr, png_uint_32 filler, int filler_loc)
-{
- png_debug(1, "in png_set_add_alpha");
- if (png_ptr == NULL) return;
- png_set_filler(png_ptr, filler, filler_loc);
- png_ptr->transformations |= PNG_ADD_ALPHA;
-}
-#endif
-
-#endif
-
-#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
- defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
-void PNGAPI
-png_set_swap_alpha(png_structp png_ptr)
-{
- png_debug(1, "in png_set_swap_alpha");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= PNG_SWAP_ALPHA;
-}
-#endif
-
-#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
- defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
-void PNGAPI
-png_set_invert_alpha(png_structp png_ptr)
-{
- png_debug(1, "in png_set_invert_alpha");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= PNG_INVERT_ALPHA;
-}
-#endif
-
-#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
-void PNGAPI
-png_set_invert_mono(png_structp png_ptr)
-{
- png_debug(1, "in png_set_invert_mono");
- if (png_ptr == NULL) return;
- png_ptr->transformations |= PNG_INVERT_MONO;
-}
-
-/* invert monochrome grayscale data */
-void /* PRIVATE */
-png_do_invert(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_invert");
- /* This test removed from libpng version 1.0.13 and 1.2.0:
- * if (row_info->bit_depth == 1 &&
- */
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- if (row == NULL || row_info == NULL)
- return;
-#endif
- if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
- {
- png_bytep rp = row;
- png_uint_32 i;
- png_uint_32 istop = row_info->rowbytes;
-
- for (i = 0; i < istop; i++)
- {
- *rp = (png_byte)(~(*rp));
- rp++;
- }
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
- row_info->bit_depth == 8)
- {
- png_bytep rp = row;
- png_uint_32 i;
- png_uint_32 istop = row_info->rowbytes;
-
- for (i = 0; i < istop; i+=2)
- {
- *rp = (png_byte)(~(*rp));
- rp+=2;
- }
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
- row_info->bit_depth == 16)
- {
- png_bytep rp = row;
- png_uint_32 i;
- png_uint_32 istop = row_info->rowbytes;
-
- for (i = 0; i < istop; i+=4)
- {
- *rp = (png_byte)(~(*rp));
- *(rp+1) = (png_byte)(~(*(rp+1)));
- rp+=4;
- }
- }
-}
-#endif
-
-#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-/* swaps byte order on 16 bit depth images */
-void /* PRIVATE */
-png_do_swap(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_swap");
- if (
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL &&
-#endif
- row_info->bit_depth == 16)
- {
- png_bytep rp = row;
- png_uint_32 i;
- png_uint_32 istop= row_info->width * row_info->channels;
-
- for (i = 0; i < istop; i++, rp += 2)
- {
- png_byte t = *rp;
- *rp = *(rp + 1);
- *(rp + 1) = t;
- }
- }
-}
-#endif
-
-#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-static PNG_CONST png_byte onebppswaptable[256] = {
- 0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
- 0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
- 0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
- 0x18, 0x98, 0x58, 0xD8, 0x38, 0xB8, 0x78, 0xF8,
- 0x04, 0x84, 0x44, 0xC4, 0x24, 0xA4, 0x64, 0xE4,
- 0x14, 0x94, 0x54, 0xD4, 0x34, 0xB4, 0x74, 0xF4,
- 0x0C, 0x8C, 0x4C, 0xCC, 0x2C, 0xAC, 0x6C, 0xEC,
- 0x1C, 0x9C, 0x5C, 0xDC, 0x3C, 0xBC, 0x7C, 0xFC,
- 0x02, 0x82, 0x42, 0xC2, 0x22, 0xA2, 0x62, 0xE2,
- 0x12, 0x92, 0x52, 0xD2, 0x32, 0xB2, 0x72, 0xF2,
- 0x0A, 0x8A, 0x4A, 0xCA, 0x2A, 0xAA, 0x6A, 0xEA,
- 0x1A, 0x9A, 0x5A, 0xDA, 0x3A, 0xBA, 0x7A, 0xFA,
- 0x06, 0x86, 0x46, 0xC6, 0x26, 0xA6, 0x66, 0xE6,
- 0x16, 0x96, 0x56, 0xD6, 0x36, 0xB6, 0x76, 0xF6,
- 0x0E, 0x8E, 0x4E, 0xCE, 0x2E, 0xAE, 0x6E, 0xEE,
- 0x1E, 0x9E, 0x5E, 0xDE, 0x3E, 0xBE, 0x7E, 0xFE,
- 0x01, 0x81, 0x41, 0xC1, 0x21, 0xA1, 0x61, 0xE1,
- 0x11, 0x91, 0x51, 0xD1, 0x31, 0xB1, 0x71, 0xF1,
- 0x09, 0x89, 0x49, 0xC9, 0x29, 0xA9, 0x69, 0xE9,
- 0x19, 0x99, 0x59, 0xD9, 0x39, 0xB9, 0x79, 0xF9,
- 0x05, 0x85, 0x45, 0xC5, 0x25, 0xA5, 0x65, 0xE5,
- 0x15, 0x95, 0x55, 0xD5, 0x35, 0xB5, 0x75, 0xF5,
- 0x0D, 0x8D, 0x4D, 0xCD, 0x2D, 0xAD, 0x6D, 0xED,
- 0x1D, 0x9D, 0x5D, 0xDD, 0x3D, 0xBD, 0x7D, 0xFD,
- 0x03, 0x83, 0x43, 0xC3, 0x23, 0xA3, 0x63, 0xE3,
- 0x13, 0x93, 0x53, 0xD3, 0x33, 0xB3, 0x73, 0xF3,
- 0x0B, 0x8B, 0x4B, 0xCB, 0x2B, 0xAB, 0x6B, 0xEB,
- 0x1B, 0x9B, 0x5B, 0xDB, 0x3B, 0xBB, 0x7B, 0xFB,
- 0x07, 0x87, 0x47, 0xC7, 0x27, 0xA7, 0x67, 0xE7,
- 0x17, 0x97, 0x57, 0xD7, 0x37, 0xB7, 0x77, 0xF7,
- 0x0F, 0x8F, 0x4F, 0xCF, 0x2F, 0xAF, 0x6F, 0xEF,
- 0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
-};
-
-static PNG_CONST png_byte twobppswaptable[256] = {
- 0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
- 0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
- 0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
- 0x24, 0x64, 0xA4, 0xE4, 0x34, 0x74, 0xB4, 0xF4,
- 0x08, 0x48, 0x88, 0xC8, 0x18, 0x58, 0x98, 0xD8,
- 0x28, 0x68, 0xA8, 0xE8, 0x38, 0x78, 0xB8, 0xF8,
- 0x0C, 0x4C, 0x8C, 0xCC, 0x1C, 0x5C, 0x9C, 0xDC,
- 0x2C, 0x6C, 0xAC, 0xEC, 0x3C, 0x7C, 0xBC, 0xFC,
- 0x01, 0x41, 0x81, 0xC1, 0x11, 0x51, 0x91, 0xD1,
- 0x21, 0x61, 0xA1, 0xE1, 0x31, 0x71, 0xB1, 0xF1,
- 0x05, 0x45, 0x85, 0xC5, 0x15, 0x55, 0x95, 0xD5,
- 0x25, 0x65, 0xA5, 0xE5, 0x35, 0x75, 0xB5, 0xF5,
- 0x09, 0x49, 0x89, 0xC9, 0x19, 0x59, 0x99, 0xD9,
- 0x29, 0x69, 0xA9, 0xE9, 0x39, 0x79, 0xB9, 0xF9,
- 0x0D, 0x4D, 0x8D, 0xCD, 0x1D, 0x5D, 0x9D, 0xDD,
- 0x2D, 0x6D, 0xAD, 0xED, 0x3D, 0x7D, 0xBD, 0xFD,
- 0x02, 0x42, 0x82, 0xC2, 0x12, 0x52, 0x92, 0xD2,
- 0x22, 0x62, 0xA2, 0xE2, 0x32, 0x72, 0xB2, 0xF2,
- 0x06, 0x46, 0x86, 0xC6, 0x16, 0x56, 0x96, 0xD6,
- 0x26, 0x66, 0xA6, 0xE6, 0x36, 0x76, 0xB6, 0xF6,
- 0x0A, 0x4A, 0x8A, 0xCA, 0x1A, 0x5A, 0x9A, 0xDA,
- 0x2A, 0x6A, 0xAA, 0xEA, 0x3A, 0x7A, 0xBA, 0xFA,
- 0x0E, 0x4E, 0x8E, 0xCE, 0x1E, 0x5E, 0x9E, 0xDE,
- 0x2E, 0x6E, 0xAE, 0xEE, 0x3E, 0x7E, 0xBE, 0xFE,
- 0x03, 0x43, 0x83, 0xC3, 0x13, 0x53, 0x93, 0xD3,
- 0x23, 0x63, 0xA3, 0xE3, 0x33, 0x73, 0xB3, 0xF3,
- 0x07, 0x47, 0x87, 0xC7, 0x17, 0x57, 0x97, 0xD7,
- 0x27, 0x67, 0xA7, 0xE7, 0x37, 0x77, 0xB7, 0xF7,
- 0x0B, 0x4B, 0x8B, 0xCB, 0x1B, 0x5B, 0x9B, 0xDB,
- 0x2B, 0x6B, 0xAB, 0xEB, 0x3B, 0x7B, 0xBB, 0xFB,
- 0x0F, 0x4F, 0x8F, 0xCF, 0x1F, 0x5F, 0x9F, 0xDF,
- 0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
-};
-
-static PNG_CONST png_byte fourbppswaptable[256] = {
- 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
- 0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
- 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
- 0x81, 0x91, 0xA1, 0xB1, 0xC1, 0xD1, 0xE1, 0xF1,
- 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72,
- 0x82, 0x92, 0xA2, 0xB2, 0xC2, 0xD2, 0xE2, 0xF2,
- 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73,
- 0x83, 0x93, 0xA3, 0xB3, 0xC3, 0xD3, 0xE3, 0xF3,
- 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74,
- 0x84, 0x94, 0xA4, 0xB4, 0xC4, 0xD4, 0xE4, 0xF4,
- 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75,
- 0x85, 0x95, 0xA5, 0xB5, 0xC5, 0xD5, 0xE5, 0xF5,
- 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76,
- 0x86, 0x96, 0xA6, 0xB6, 0xC6, 0xD6, 0xE6, 0xF6,
- 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77,
- 0x87, 0x97, 0xA7, 0xB7, 0xC7, 0xD7, 0xE7, 0xF7,
- 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78,
- 0x88, 0x98, 0xA8, 0xB8, 0xC8, 0xD8, 0xE8, 0xF8,
- 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79,
- 0x89, 0x99, 0xA9, 0xB9, 0xC9, 0xD9, 0xE9, 0xF9,
- 0x0A, 0x1A, 0x2A, 0x3A, 0x4A, 0x5A, 0x6A, 0x7A,
- 0x8A, 0x9A, 0xAA, 0xBA, 0xCA, 0xDA, 0xEA, 0xFA,
- 0x0B, 0x1B, 0x2B, 0x3B, 0x4B, 0x5B, 0x6B, 0x7B,
- 0x8B, 0x9B, 0xAB, 0xBB, 0xCB, 0xDB, 0xEB, 0xFB,
- 0x0C, 0x1C, 0x2C, 0x3C, 0x4C, 0x5C, 0x6C, 0x7C,
- 0x8C, 0x9C, 0xAC, 0xBC, 0xCC, 0xDC, 0xEC, 0xFC,
- 0x0D, 0x1D, 0x2D, 0x3D, 0x4D, 0x5D, 0x6D, 0x7D,
- 0x8D, 0x9D, 0xAD, 0xBD, 0xCD, 0xDD, 0xED, 0xFD,
- 0x0E, 0x1E, 0x2E, 0x3E, 0x4E, 0x5E, 0x6E, 0x7E,
- 0x8E, 0x9E, 0xAE, 0xBE, 0xCE, 0xDE, 0xEE, 0xFE,
- 0x0F, 0x1F, 0x2F, 0x3F, 0x4F, 0x5F, 0x6F, 0x7F,
- 0x8F, 0x9F, 0xAF, 0xBF, 0xCF, 0xDF, 0xEF, 0xFF
-};
-
-/* swaps pixel packing order within bytes */
-void /* PRIVATE */
-png_do_packswap(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_packswap");
- if (
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL &&
-#endif
- row_info->bit_depth < 8)
- {
- png_bytep rp, end, table;
-
- end = row + row_info->rowbytes;
-
- if (row_info->bit_depth == 1)
- table = (png_bytep)onebppswaptable;
- else if (row_info->bit_depth == 2)
- table = (png_bytep)twobppswaptable;
- else if (row_info->bit_depth == 4)
- table = (png_bytep)fourbppswaptable;
- else
- return;
-
- for (rp = row; rp < end; rp++)
- *rp = table[*rp];
- }
-}
-#endif /* PNG_READ_PACKSWAP_SUPPORTED or PNG_WRITE_PACKSWAP_SUPPORTED */
-
-#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
- defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
-/* remove filler or alpha byte(s) */
-void /* PRIVATE */
-png_do_strip_filler(png_row_infop row_info, png_bytep row, png_uint_32 flags)
-{
- png_debug(1, "in png_do_strip_filler");
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- if (row != NULL && row_info != NULL)
-#endif
- {
- png_bytep sp=row;
- png_bytep dp=row;
- png_uint_32 row_width=row_info->width;
- png_uint_32 i;
-
- if ((row_info->color_type == PNG_COLOR_TYPE_RGB ||
- (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA &&
- (flags & PNG_FLAG_STRIP_ALPHA))) &&
- row_info->channels == 4)
- {
- if (row_info->bit_depth == 8)
- {
- /* This converts from RGBX or RGBA to RGB */
- if (flags & PNG_FLAG_FILLER_AFTER)
- {
- dp+=3; sp+=4;
- for (i = 1; i < row_width; i++)
- {
- *dp++ = *sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- sp++;
- }
- }
- /* This converts from XRGB or ARGB to RGB */
- else
- {
- for (i = 0; i < row_width; i++)
- {
- sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- }
- }
- row_info->pixel_depth = 24;
- row_info->rowbytes = row_width * 3;
- }
- else /* if (row_info->bit_depth == 16) */
- {
- if (flags & PNG_FLAG_FILLER_AFTER)
- {
- /* This converts from RRGGBBXX or RRGGBBAA to RRGGBB */
- sp += 8; dp += 6;
- for (i = 1; i < row_width; i++)
- {
- /* This could be (although png_memcpy is probably slower):
- png_memcpy(dp, sp, 6);
- sp += 8;
- dp += 6;
- */
-
- *dp++ = *sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- sp += 2;
- }
- }
- else
- {
- /* This converts from XXRRGGBB or AARRGGBB to RRGGBB */
- for (i = 0; i < row_width; i++)
- {
- /* This could be (although png_memcpy is probably slower):
- png_memcpy(dp, sp, 6);
- sp += 8;
- dp += 6;
- */
-
- sp+=2;
- *dp++ = *sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- *dp++ = *sp++;
- }
- }
- row_info->pixel_depth = 48;
- row_info->rowbytes = row_width * 6;
- }
- row_info->channels = 3;
- }
- else if ((row_info->color_type == PNG_COLOR_TYPE_GRAY ||
- (row_info->color_type == PNG_COLOR_TYPE_GRAY_ALPHA &&
- (flags & PNG_FLAG_STRIP_ALPHA))) &&
- row_info->channels == 2)
- {
- if (row_info->bit_depth == 8)
- {
- /* This converts from GX or GA to G */
- if (flags & PNG_FLAG_FILLER_AFTER)
- {
- for (i = 0; i < row_width; i++)
- {
- *dp++ = *sp++;
- sp++;
- }
- }
- /* This converts from XG or AG to G */
- else
- {
- for (i = 0; i < row_width; i++)
- {
- sp++;
- *dp++ = *sp++;
- }
- }
- row_info->pixel_depth = 8;
- row_info->rowbytes = row_width;
- }
- else /* if (row_info->bit_depth == 16) */
- {
- if (flags & PNG_FLAG_FILLER_AFTER)
- {
- /* This converts from GGXX or GGAA to GG */
- sp += 4; dp += 2;
- for (i = 1; i < row_width; i++)
- {
- *dp++ = *sp++;
- *dp++ = *sp++;
- sp += 2;
- }
- }
- else
- {
- /* This converts from XXGG or AAGG to GG */
- for (i = 0; i < row_width; i++)
- {
- sp += 2;
- *dp++ = *sp++;
- *dp++ = *sp++;
- }
- }
- row_info->pixel_depth = 16;
- row_info->rowbytes = row_width * 2;
- }
- row_info->channels = 1;
- }
- if (flags & PNG_FLAG_STRIP_ALPHA)
- row_info->color_type &= ~PNG_COLOR_MASK_ALPHA;
- }
-}
-#endif
-
-#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
-/* swaps red and blue bytes within a pixel */
-void /* PRIVATE */
-png_do_bgr(png_row_infop row_info, png_bytep row)
-{
- png_debug(1, "in png_do_bgr");
- if (
-#if defined(PNG_USELESS_TESTS_SUPPORTED)
- row != NULL && row_info != NULL &&
-#endif
- (row_info->color_type & PNG_COLOR_MASK_COLOR))
- {
- png_uint_32 row_width = row_info->width;
- if (row_info->bit_depth == 8)
- {
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- {
- png_bytep rp;
- png_uint_32 i;
-
- for (i = 0, rp = row; i < row_width; i++, rp += 3)
- {
- png_byte save = *rp;
- *rp = *(rp + 2);
- *(rp + 2) = save;
- }
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- png_bytep rp;
- png_uint_32 i;
-
- for (i = 0, rp = row; i < row_width; i++, rp += 4)
- {
- png_byte save = *rp;
- *rp = *(rp + 2);
- *(rp + 2) = save;
- }
- }
- }
- else if (row_info->bit_depth == 16)
- {
- if (row_info->color_type == PNG_COLOR_TYPE_RGB)
- {
- png_bytep rp;
- png_uint_32 i;
-
- for (i = 0, rp = row; i < row_width; i++, rp += 6)
- {
- png_byte save = *rp;
- *rp = *(rp + 4);
- *(rp + 4) = save;
- save = *(rp + 1);
- *(rp + 1) = *(rp + 5);
- *(rp + 5) = save;
- }
- }
- else if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
- {
- png_bytep rp;
- png_uint_32 i;
-
- for (i = 0, rp = row; i < row_width; i++, rp += 8)
- {
- png_byte save = *rp;
- *rp = *(rp + 4);
- *(rp + 4) = save;
- save = *(rp + 1);
- *(rp + 1) = *(rp + 5);
- *(rp + 5) = save;
- }
- }
- }
- }
-}
-#endif /* PNG_READ_BGR_SUPPORTED or PNG_WRITE_BGR_SUPPORTED */
-
-#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) || \
- defined(PNG_LEGACY_SUPPORTED)
-void PNGAPI
-png_set_user_transform_info(png_structp png_ptr, png_voidp
- user_transform_ptr, int user_transform_depth, int user_transform_channels)
-{
- png_debug(1, "in png_set_user_transform_info");
- if (png_ptr == NULL) return;
-#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
- png_ptr->user_transform_ptr = user_transform_ptr;
- png_ptr->user_transform_depth = (png_byte)user_transform_depth;
- png_ptr->user_transform_channels = (png_byte)user_transform_channels;
-#else
- if (user_transform_ptr || user_transform_depth || user_transform_channels)
- png_warning(png_ptr,
- "This version of libpng does not support user transform info");
-#endif
-}
-#endif
-
-/* This function returns a pointer to the user_transform_ptr associated with
- * the user transform functions. The application should free any memory
- * associated with this pointer before png_write_destroy and png_read_destroy
- * are called.
- */
-png_voidp PNGAPI
-png_get_user_transform_ptr(png_structp png_ptr)
-{
- if (png_ptr == NULL) return (NULL);
-#if defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
- return ((png_voidp)png_ptr->user_transform_ptr);
-#else
- return (NULL);
-#endif
-}
-#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
diff --git a/navit/support/shapefile/CMakeLists.txt b/navit/support/shapefile/CMakeLists.txt
deleted file mode 100644
index 03c964329..000000000
--- a/navit/support/shapefile/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-supportlib_add_library(support_shapefile dbfopen.c shpopen.c shptree.c)
diff --git a/navit/support/shapefile/dbfopen.c b/navit/support/shapefile/dbfopen.c
deleted file mode 100644
index 148e593a4..000000000
--- a/navit/support/shapefile/dbfopen.c
+++ /dev/null
@@ -1,2405 +0,0 @@
-/******************************************************************************
- * $Id: dbfopen.c,v 1.92 2016-12-05 18:44:08 erouault Exp $
- *
- * Project: Shapelib
- * Purpose: Implementation of .dbf access API documented in dbf_api.html.
- * Author: Frank Warmerdam, warmerdam@pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, Frank Warmerdam
- * Copyright (c) 2012-2013, Even Rouault <even dot rouault at mines-paris dot org>
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see COPYING). This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log: dbfopen.c,v $
- * Revision 1.92 2016-12-05 18:44:08 erouault
- * * dbfopen.c, shapefil.h: write DBF end-of-file character 0x1A by default.
- * This behaviour can be controlled with the DBFSetWriteEndOfFileChar()
- * function.
- *
- * Revision 1.91 2016-12-05 12:44:05 erouault
- * * Major overhaul of Makefile build system to use autoconf/automake.
- *
- * * Warning fixes in contrib/
- *
- * Revision 1.90 2016-12-04 15:30:15 erouault
- * * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with
- * GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo
- * structures extended with new members. New functions:
- * DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX,
- * SHPSetFastModeReadObject
- *
- * * sbnsearch.c: new file to implement original ESRI .sbn spatial
- * index reading. (no write support). New functions:
- * SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
- * SBNSearchDiskTreeInteger, SBNSearchFreeIds
- *
- * * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates
- * with new file and symbols.
- *
- * * commit: helper script to cvs commit
- *
- * Revision 1.89 2011-07-24 05:59:25 fwarmerdam
- * minimize use of CPLError in favor of SAHooks.Error()
- *
- * Revision 1.88 2011-05-13 17:35:17 fwarmerdam
- * added DBFReorderFields() and DBFAlterFields() functions (from Even)
- *
- * Revision 1.87 2011-05-07 22:41:02 fwarmerdam
- * ensure pending record is flushed when adding a native field (GDAL #4073)
- *
- * Revision 1.86 2011-04-17 15:15:29 fwarmerdam
- * Removed unused variable.
- *
- * Revision 1.85 2010-12-06 16:09:34 fwarmerdam
- * fix buffer read overrun fetching code page (bug 2276)
- *
- * Revision 1.84 2009-10-29 19:59:48 fwarmerdam
- * avoid crash on truncated header (gdal #3093)
- *
- * Revision 1.83 2008/11/12 14:28:15 fwarmerdam
- * DBFCreateField() now works on files with records
- *
- * Revision 1.82 2008/11/11 17:47:09 fwarmerdam
- * added DBFDeleteField() function
- *
- * Revision 1.81 2008/01/03 17:48:13 bram
- * in DBFCreate, use default code page LDID/87 (= 0x57, ANSI)
- * instead of LDID/3. This seems to be the same as what ESRI
- * would be doing by default.
- *
- * Revision 1.80 2007/12/30 14:36:39 fwarmerdam
- * avoid syntax issue with last comment.
- *
- * Revision 1.79 2007/12/30 14:35:48 fwarmerdam
- * Avoid char* / unsigned char* warnings.
- *
- * Revision 1.78 2007/12/18 18:28:07 bram
- * - create hook for client specific atof (bugzilla ticket 1615)
- * - check for NULL handle before closing cpCPG file, and close after reading.
- *
- * Revision 1.77 2007/12/15 20:25:21 bram
- * dbfopen.c now reads the Code Page information from the DBF file, and exports
- * this information as a string through the DBFGetCodePage function. This is
- * either the number from the LDID header field ("LDID/<number>") or as the
- * content of an accompanying .CPG file. When creating a DBF file, the code can
- * be set using DBFCreateEx.
- *
- * Revision 1.76 2007/12/12 22:21:32 bram
- * DBFClose: check for NULL psDBF handle before trying to close it.
- *
- * Revision 1.75 2007/12/06 13:58:19 fwarmerdam
- * make sure file offset calculations are done in as SAOffset
- *
- * Revision 1.74 2007/12/06 07:00:25 fwarmerdam
- * dbfopen now using SAHooks for fileio
- *
- * Revision 1.73 2007/09/03 19:48:11 fwarmerdam
- * move DBFReadAttribute() static dDoubleField into dbfinfo
- *
- * Revision 1.72 2007/09/03 19:34:06 fwarmerdam
- * Avoid use of static tuple buffer in DBFReadTuple()
- *
- * Revision 1.71 2006/06/22 14:37:18 fwarmerdam
- * avoid memory leak if dbfopen fread fails
- *
- * Revision 1.70 2006/06/17 17:47:05 fwarmerdam
- * use calloc() for dbfinfo in DBFCreate
- *
- * Revision 1.69 2006/06/17 15:34:32 fwarmerdam
- * disallow creating fields wider than 255
- *
- * Revision 1.68 2006/06/17 15:12:40 fwarmerdam
- * Fixed C++ style comments.
- *
- * Revision 1.67 2006/06/17 00:24:53 fwarmerdam
- * Don't treat non-zero decimals values as high order byte for length
- * for strings. It causes serious corruption for some files.
- * http://bugzilla.remotesensing.org/show_bug.cgi?id=1202
- *
- * Revision 1.66 2006/03/29 18:26:20 fwarmerdam
- * fixed bug with size of pachfieldtype in dbfcloneempty
- *
- * Revision 1.65 2006/02/15 01:14:30 fwarmerdam
- * added DBFAddNativeFieldType
- *
- * Revision 1.64 2006/02/09 00:29:04 fwarmerdam
- * Changed to put spaces into string fields that are NULL as
- * per http://bugzilla.maptools.org/show_bug.cgi?id=316.
- *
- * Revision 1.63 2006/01/25 15:35:43 fwarmerdam
- * check success on DBFFlushRecord
- *
- * Revision 1.62 2006/01/10 16:28:03 fwarmerdam
- * Fixed typo in CPLError.
- *
- * Revision 1.61 2006/01/10 16:26:29 fwarmerdam
- * Push loading record buffer into DBFLoadRecord.
- * Implement CPL error reporting if USE_CPL defined.
- *
- * Revision 1.60 2006/01/05 01:27:27 fwarmerdam
- * added dbf deletion mark/fetch
- *
- * Revision 1.59 2005/03/14 15:20:28 fwarmerdam
- * Fixed last change.
- *
- * Revision 1.58 2005/03/14 15:18:54 fwarmerdam
- * Treat very wide fields with no decimals as double. This is
- * more than 32bit integer fields.
- *
- * Revision 1.57 2005/02/10 20:16:54 fwarmerdam
- * Make the pszStringField buffer for DBFReadAttribute() static char [256]
- * as per bug 306.
- *
- * Revision 1.56 2005/02/10 20:07:56 fwarmerdam
- * Fixed bug 305 in DBFCloneEmpty() - header length problem.
- *
- * Revision 1.55 2004/09/26 20:23:46 fwarmerdam
- * avoid warnings with rcsid and signed/unsigned stuff
- *
- * Revision 1.54 2004/09/15 16:26:10 fwarmerdam
- * Treat all blank numeric fields as null too.
- */
-
-#include "shapefil.h"
-
-#include <math.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <string.h>
-
-#ifdef USE_CPL
-#include "cpl_string.h"
-#else
-
-#if defined(_MSC_VER)
-# if _MSC_VER < 1900
-# define snprintf _snprintf
-# endif
-#elif defined(WIN32) || defined(_WIN32)
-# ifndef snprintf
-# define snprintf _snprintf
-# endif
-#endif
-
-#define CPLsprintf sprintf
-#define CPLsnprintf snprintf
-#endif
-
-SHP_CVSID("$Id: dbfopen.c,v 1.92 2016-12-05 18:44:08 erouault Exp $")
-
-#ifndef FALSE
-# define FALSE 0
-# define TRUE 1
-#endif
-
-/* File header size */
-#define XBASE_FILEHDR_SZ 32
-
-#define HEADER_RECORD_TERMINATOR 0x0D
-
-/* See http://www.manmrk.net/tutorials/database/xbase/dbf.html */
-#define END_OF_FILE_CHARACTER 0x1A
-
-#ifdef USE_CPL
-CPL_INLINE static void CPL_IGNORE_RET_VAL_INT(CPL_UNUSED int unused) {}
-#else
-#define CPL_IGNORE_RET_VAL_INT(x) x
-#endif
-
-/************************************************************************/
-/* SfRealloc() */
-/* */
-/* A realloc cover function that will access a NULL pointer as */
-/* a valid input. */
-/************************************************************************/
-
-static void * SfRealloc( void * pMem, int nNewSize )
-
-{
- if( pMem == NULL )
- return( (void *) malloc(nNewSize) );
- else
- return( (void *) realloc(pMem,nNewSize) );
-}
-
-/************************************************************************/
-/* DBFWriteHeader() */
-/* */
-/* This is called to write out the file header, and field */
-/* descriptions before writing any actual data records. This */
-/* also computes all the DBFDataSet field offset/size/decimals */
-/* and so forth values. */
-/************************************************************************/
-
-static void DBFWriteHeader(DBFHandle psDBF)
-
-{
- unsigned char abyHeader[XBASE_FILEHDR_SZ] = { 0 };
-
- if( !psDBF->bNoHeader )
- return;
-
- psDBF->bNoHeader = FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Initialize the file header information. */
-/* -------------------------------------------------------------------- */
- abyHeader[0] = 0x03; /* memo field? - just copying */
-
- /* write out update date */
- abyHeader[1] = (unsigned char) psDBF->nUpdateYearSince1900;
- abyHeader[2] = (unsigned char) psDBF->nUpdateMonth;
- abyHeader[3] = (unsigned char) psDBF->nUpdateDay;
-
- /* record count preset at zero */
-
- abyHeader[8] = (unsigned char) (psDBF->nHeaderLength % 256);
- abyHeader[9] = (unsigned char) (psDBF->nHeaderLength / 256);
-
- abyHeader[10] = (unsigned char) (psDBF->nRecordLength % 256);
- abyHeader[11] = (unsigned char) (psDBF->nRecordLength / 256);
-
- abyHeader[29] = (unsigned char) (psDBF->iLanguageDriver);
-
-/* -------------------------------------------------------------------- */
-/* Write the initial 32 byte file header, and all the field */
-/* descriptions. */
-/* -------------------------------------------------------------------- */
- psDBF->sHooks.FSeek( psDBF->fp, 0, 0 );
- psDBF->sHooks.FWrite( abyHeader, XBASE_FILEHDR_SZ, 1, psDBF->fp );
- psDBF->sHooks.FWrite( psDBF->pszHeader, XBASE_FLDHDR_SZ, psDBF->nFields,
- psDBF->fp );
-
-/* -------------------------------------------------------------------- */
-/* Write out the newline character if there is room for it. */
-/* -------------------------------------------------------------------- */
- if( psDBF->nHeaderLength > XBASE_FLDHDR_SZ*psDBF->nFields +
- XBASE_FLDHDR_SZ )
- {
- char cNewline;
-
- cNewline = HEADER_RECORD_TERMINATOR;
- psDBF->sHooks.FWrite( &cNewline, 1, 1, psDBF->fp );
- }
-
-/* -------------------------------------------------------------------- */
-/* If the file is new, add a EOF character. */
-/* -------------------------------------------------------------------- */
- if( psDBF->nRecords == 0 && psDBF->bWriteEndOfFileChar )
- {
- char ch = END_OF_FILE_CHARACTER;
-
- psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp );
- }
-}
-
-/************************************************************************/
-/* DBFFlushRecord() */
-/* */
-/* Write out the current record if there is one. */
-/************************************************************************/
-
-static int DBFFlushRecord( DBFHandle psDBF )
-
-{
- SAOffset nRecordOffset;
-
- if( psDBF->bCurrentRecordModified && psDBF->nCurrentRecord > -1 )
- {
- psDBF->bCurrentRecordModified = FALSE;
-
- nRecordOffset =
- psDBF->nRecordLength * (SAOffset) psDBF->nCurrentRecord
- + psDBF->nHeaderLength;
-
- if( psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 ) != 0
- || psDBF->sHooks.FWrite( psDBF->pszCurrentRecord,
- psDBF->nRecordLength,
- 1, psDBF->fp ) != 1 )
- {
- char szMessage[128];
- snprintf( szMessage, sizeof(szMessage), "Failure writing DBF record %d.",
- psDBF->nCurrentRecord );
- psDBF->sHooks.Error( szMessage );
- return FALSE;
- }
-
- if( psDBF->nCurrentRecord == psDBF->nRecords - 1 )
- {
- if( psDBF->bWriteEndOfFileChar )
- {
- char ch = END_OF_FILE_CHARACTER;
- psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp );
- }
- }
- }
-
- return TRUE;
-}
-
-/************************************************************************/
-/* DBFLoadRecord() */
-/************************************************************************/
-
-static int DBFLoadRecord( DBFHandle psDBF, int iRecord )
-
-{
- if( psDBF->nCurrentRecord != iRecord )
- {
- SAOffset nRecordOffset;
-
- if( !DBFFlushRecord( psDBF ) )
- return FALSE;
-
- nRecordOffset =
- psDBF->nRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
-
- if( psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, SEEK_SET ) != 0 )
- {
- char szMessage[128];
- snprintf( szMessage, sizeof(szMessage), "fseek(%ld) failed on DBF file.",
- (long) nRecordOffset );
- psDBF->sHooks.Error( szMessage );
- return FALSE;
- }
-
- if( psDBF->sHooks.FRead( psDBF->pszCurrentRecord,
- psDBF->nRecordLength, 1, psDBF->fp ) != 1 )
- {
- char szMessage[128];
- snprintf( szMessage, sizeof(szMessage), "fread(%d) failed on DBF file.",
- psDBF->nRecordLength );
- psDBF->sHooks.Error( szMessage );
- return FALSE;
- }
-
- psDBF->nCurrentRecord = iRecord;
- }
-
- return TRUE;
-}
-
-/************************************************************************/
-/* DBFUpdateHeader() */
-/************************************************************************/
-
-void SHPAPI_CALL
-DBFUpdateHeader( DBFHandle psDBF )
-
-{
- unsigned char abyFileHeader[XBASE_FILEHDR_SZ];
-
- if( psDBF->bNoHeader )
- DBFWriteHeader( psDBF );
-
- if( !DBFFlushRecord( psDBF ) )
- return;
-
- psDBF->sHooks.FSeek( psDBF->fp, 0, 0 );
- psDBF->sHooks.FRead( abyFileHeader, sizeof(abyFileHeader), 1, psDBF->fp );
-
- abyFileHeader[1] = (unsigned char) psDBF->nUpdateYearSince1900;
- abyFileHeader[2] = (unsigned char) psDBF->nUpdateMonth;
- abyFileHeader[3] = (unsigned char) psDBF->nUpdateDay;
- abyFileHeader[4] = (unsigned char) (psDBF->nRecords % 256);
- abyFileHeader[5] = (unsigned char) ((psDBF->nRecords/256) % 256);
- abyFileHeader[6] = (unsigned char) ((psDBF->nRecords/(256*256)) % 256);
- abyFileHeader[7] = (unsigned char) ((psDBF->nRecords/(256*256*256)) % 256);
-
- psDBF->sHooks.FSeek( psDBF->fp, 0, 0 );
- psDBF->sHooks.FWrite( abyFileHeader, sizeof(abyFileHeader), 1, psDBF->fp );
-
- psDBF->sHooks.FFlush( psDBF->fp );
-}
-
-/************************************************************************/
-/* DBFSetLastModifiedDate() */
-/************************************************************************/
-
-void SHPAPI_CALL
-DBFSetLastModifiedDate( DBFHandle psDBF, int nYYSince1900, int nMM, int nDD )
-{
- psDBF->nUpdateYearSince1900 = nYYSince1900;
- psDBF->nUpdateMonth = nMM;
- psDBF->nUpdateDay = nDD;
-}
-
-/************************************************************************/
-/* DBFOpen() */
-/* */
-/* Open a .dbf file. */
-/************************************************************************/
-
-DBFHandle SHPAPI_CALL
-DBFOpen( const char * pszFilename, const char * pszAccess )
-
-{
- SAHooks sHooks;
-
- SASetupDefaultHooks( &sHooks );
-
- return DBFOpenLL( pszFilename, pszAccess, &sHooks );
-}
-
-/************************************************************************/
-/* DBFOpen() */
-/* */
-/* Open a .dbf file. */
-/************************************************************************/
-
-DBFHandle SHPAPI_CALL
-DBFOpenLL( const char * pszFilename, const char * pszAccess, SAHooks *psHooks )
-
-{
- DBFHandle psDBF;
- SAFile pfCPG;
- unsigned char *pabyBuf;
- int nFields, nHeadLen, iField, i;
- char *pszBasename, *pszFullname;
- int nBufSize = 500;
- size_t nFullnameLen;
-
-/* -------------------------------------------------------------------- */
-/* We only allow the access strings "rb" and "r+". */
-/* -------------------------------------------------------------------- */
- if( strcmp(pszAccess,"r") != 0 && strcmp(pszAccess,"r+") != 0
- && strcmp(pszAccess,"rb") != 0 && strcmp(pszAccess,"rb+") != 0
- && strcmp(pszAccess,"r+b") != 0 )
- return( NULL );
-
- if( strcmp(pszAccess,"r") == 0 )
- pszAccess = "rb";
-
- if( strcmp(pszAccess,"r+") == 0 )
- pszAccess = "rb+";
-
-/* -------------------------------------------------------------------- */
-/* Compute the base (layer) name. If there is any extension */
-/* on the passed in filename we will strip it off. */
-/* -------------------------------------------------------------------- */
- pszBasename = (char *) malloc(strlen(pszFilename)+5);
- strcpy( pszBasename, pszFilename );
- for( i = (int)strlen(pszBasename)-1;
- i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
- && pszBasename[i] != '\\';
- i-- ) {}
-
- if( pszBasename[i] == '.' )
- pszBasename[i] = '\0';
-
- nFullnameLen = strlen(pszBasename) + 5;
- pszFullname = (char *) malloc(nFullnameLen);
- snprintf( pszFullname, nFullnameLen, "%s.dbf", pszBasename );
-
- psDBF = (DBFHandle) calloc( 1, sizeof(DBFInfo) );
- psDBF->fp = psHooks->FOpen( pszFullname, pszAccess );
- memcpy( &(psDBF->sHooks), psHooks, sizeof(SAHooks) );
-
- if( psDBF->fp == NULL )
- {
- snprintf( pszFullname, nFullnameLen, "%s.DBF", pszBasename );
- psDBF->fp = psDBF->sHooks.FOpen(pszFullname, pszAccess );
- }
-
- snprintf( pszFullname, nFullnameLen, "%s.cpg", pszBasename );
- pfCPG = psHooks->FOpen( pszFullname, "r" );
- if( pfCPG == NULL )
- {
- snprintf( pszFullname, nFullnameLen, "%s.CPG", pszBasename );
- pfCPG = psHooks->FOpen( pszFullname, "r" );
- }
-
- free( pszBasename );
- free( pszFullname );
-
- if( psDBF->fp == NULL )
- {
- free( psDBF );
- if( pfCPG ) psHooks->FClose( pfCPG );
- return( NULL );
- }
-
- psDBF->bNoHeader = FALSE;
- psDBF->nCurrentRecord = -1;
- psDBF->bCurrentRecordModified = FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Read Table Header info */
-/* -------------------------------------------------------------------- */
- pabyBuf = (unsigned char *) malloc(nBufSize);
- if( psDBF->sHooks.FRead( pabyBuf, XBASE_FILEHDR_SZ, 1, psDBF->fp ) != 1 )
- {
- psDBF->sHooks.FClose( psDBF->fp );
- if( pfCPG ) psDBF->sHooks.FClose( pfCPG );
- free( pabyBuf );
- free( psDBF );
- return NULL;
- }
-
- DBFSetLastModifiedDate(psDBF, pabyBuf[1], pabyBuf[2], pabyBuf[3]);
-
- psDBF->nRecords =
- pabyBuf[4] + pabyBuf[5]*256 + pabyBuf[6]*256*256 + (pabyBuf[7] & 0x7f) *256*256*256;
-
- psDBF->nHeaderLength = nHeadLen = pabyBuf[8] + pabyBuf[9]*256;
- psDBF->nRecordLength = pabyBuf[10] + pabyBuf[11]*256;
- psDBF->iLanguageDriver = pabyBuf[29];
-
- if (psDBF->nRecordLength == 0 || nHeadLen < XBASE_FILEHDR_SZ)
- {
- psDBF->sHooks.FClose( psDBF->fp );
- if( pfCPG ) psDBF->sHooks.FClose( pfCPG );
- free( pabyBuf );
- free( psDBF );
- return NULL;
- }
-
- psDBF->nFields = nFields = (nHeadLen - XBASE_FILEHDR_SZ) / XBASE_FLDHDR_SZ;
-
- psDBF->pszCurrentRecord = (char *) malloc(psDBF->nRecordLength);
-
-/* -------------------------------------------------------------------- */
-/* Figure out the code page from the LDID and CPG */
-/* -------------------------------------------------------------------- */
-
- psDBF->pszCodePage = NULL;
- if( pfCPG )
- {
- size_t n;
- memset( pabyBuf, 0, nBufSize);
- psDBF->sHooks.FRead( pabyBuf, nBufSize - 1, 1, pfCPG );
- n = strcspn( (char *) pabyBuf, "\n\r" );
- if( n > 0 )
- {
- pabyBuf[n] = '\0';
- psDBF->pszCodePage = (char *) malloc(n + 1);
- memcpy( psDBF->pszCodePage, pabyBuf, n + 1 );
- }
- psDBF->sHooks.FClose( pfCPG );
- }
- if( psDBF->pszCodePage == NULL && pabyBuf[29] != 0 )
- {
- snprintf( (char *) pabyBuf, nBufSize, "LDID/%d", psDBF->iLanguageDriver );
- psDBF->pszCodePage = (char *) malloc(strlen((char*)pabyBuf) + 1);
- strcpy( psDBF->pszCodePage, (char *) pabyBuf );
- }
-
-/* -------------------------------------------------------------------- */
-/* Read in Field Definitions */
-/* -------------------------------------------------------------------- */
-
- pabyBuf = (unsigned char *) SfRealloc(pabyBuf,nHeadLen);
- psDBF->pszHeader = (char *) pabyBuf;
-
- psDBF->sHooks.FSeek( psDBF->fp, XBASE_FILEHDR_SZ, 0 );
- if( psDBF->sHooks.FRead( pabyBuf, nHeadLen-XBASE_FILEHDR_SZ, 1,
- psDBF->fp ) != 1 )
- {
- psDBF->sHooks.FClose( psDBF->fp );
- free( pabyBuf );
- free( psDBF->pszCurrentRecord );
- free( psDBF );
- return NULL;
- }
-
- psDBF->panFieldOffset = (int *) malloc(sizeof(int) * nFields);
- psDBF->panFieldSize = (int *) malloc(sizeof(int) * nFields);
- psDBF->panFieldDecimals = (int *) malloc(sizeof(int) * nFields);
- psDBF->pachFieldType = (char *) malloc(sizeof(char) * nFields);
-
- for( iField = 0; iField < nFields; iField++ )
- {
- unsigned char *pabyFInfo;
-
- pabyFInfo = pabyBuf+iField*XBASE_FLDHDR_SZ;
-
- if( pabyFInfo[11] == 'N' || pabyFInfo[11] == 'F' )
- {
- psDBF->panFieldSize[iField] = pabyFInfo[16];
- psDBF->panFieldDecimals[iField] = pabyFInfo[17];
- }
- else
- {
- psDBF->panFieldSize[iField] = pabyFInfo[16];
- psDBF->panFieldDecimals[iField] = 0;
-
-/*
-** The following seemed to be used sometimes to handle files with long
-** string fields, but in other cases (such as bug 1202) the decimals field
-** just seems to indicate some sort of preferred formatting, not very
-** wide fields. So I have disabled this code. FrankW.
- psDBF->panFieldSize[iField] = pabyFInfo[16] + pabyFInfo[17]*256;
- psDBF->panFieldDecimals[iField] = 0;
-*/
- }
-
- psDBF->pachFieldType[iField] = (char) pabyFInfo[11];
- if( iField == 0 )
- psDBF->panFieldOffset[iField] = 1;
- else
- psDBF->panFieldOffset[iField] =
- psDBF->panFieldOffset[iField-1] + psDBF->panFieldSize[iField-1];
- }
-
- DBFSetWriteEndOfFileChar( psDBF, TRUE );
-
- return( psDBF );
-}
-
-/************************************************************************/
-/* DBFClose() */
-/************************************************************************/
-
-void SHPAPI_CALL
-DBFClose(DBFHandle psDBF)
-{
- if( psDBF == NULL )
- return;
-
-/* -------------------------------------------------------------------- */
-/* Write out header if not already written. */
-/* -------------------------------------------------------------------- */
- if( psDBF->bNoHeader )
- DBFWriteHeader( psDBF );
-
- CPL_IGNORE_RET_VAL_INT(DBFFlushRecord( psDBF ));
-
-/* -------------------------------------------------------------------- */
-/* Update last access date, and number of records if we have */
-/* write access. */
-/* -------------------------------------------------------------------- */
- if( psDBF->bUpdated )
- DBFUpdateHeader( psDBF );
-
-/* -------------------------------------------------------------------- */
-/* Close, and free resources. */
-/* -------------------------------------------------------------------- */
- psDBF->sHooks.FClose( psDBF->fp );
-
- if( psDBF->panFieldOffset != NULL )
- {
- free( psDBF->panFieldOffset );
- free( psDBF->panFieldSize );
- free( psDBF->panFieldDecimals );
- free( psDBF->pachFieldType );
- }
-
- if( psDBF->pszWorkField != NULL )
- free( psDBF->pszWorkField );
-
- free( psDBF->pszHeader );
- free( psDBF->pszCurrentRecord );
- free( psDBF->pszCodePage );
-
- free( psDBF );
-}
-
-/************************************************************************/
-/* DBFCreate() */
-/* */
-/* Create a new .dbf file with default code page LDID/87 (0x57) */
-/************************************************************************/
-
-DBFHandle SHPAPI_CALL
-DBFCreate( const char * pszFilename )
-
-{
- return DBFCreateEx( pszFilename, "LDID/87" ); // 0x57
-}
-
-/************************************************************************/
-/* DBFCreateEx() */
-/* */
-/* Create a new .dbf file. */
-/************************************************************************/
-
-DBFHandle SHPAPI_CALL
-DBFCreateEx( const char * pszFilename, const char* pszCodePage )
-
-{
- SAHooks sHooks;
-
- SASetupDefaultHooks( &sHooks );
-
- return DBFCreateLL( pszFilename, pszCodePage , &sHooks );
-}
-
-/************************************************************************/
-/* DBFCreate() */
-/* */
-/* Create a new .dbf file. */
-/************************************************************************/
-
-DBFHandle SHPAPI_CALL
-DBFCreateLL( const char * pszFilename, const char * pszCodePage, SAHooks *psHooks )
-
-{
- DBFHandle psDBF;
- SAFile fp;
- char *pszFullname, *pszBasename;
- int i, ldid = -1;
- char chZero = '\0';
- size_t nFullnameLen;
-
-/* -------------------------------------------------------------------- */
-/* Compute the base (layer) name. If there is any extension */
-/* on the passed in filename we will strip it off. */
-/* -------------------------------------------------------------------- */
- pszBasename = (char *) malloc(strlen(pszFilename)+5);
- strcpy( pszBasename, pszFilename );
- for( i = (int)strlen(pszBasename)-1;
- i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
- && pszBasename[i] != '\\';
- i-- ) {}
-
- if( pszBasename[i] == '.' )
- pszBasename[i] = '\0';
-
- nFullnameLen = strlen(pszBasename) + 5;
- pszFullname = (char *) malloc(nFullnameLen);
- snprintf( pszFullname, nFullnameLen, "%s.dbf", pszBasename );
-
-/* -------------------------------------------------------------------- */
-/* Create the file. */
-/* -------------------------------------------------------------------- */
- fp = psHooks->FOpen( pszFullname, "wb" );
- if( fp == NULL )
- {
- free( pszBasename );
- free( pszFullname );
- return( NULL );
- }
-
- psHooks->FWrite( &chZero, 1, 1, fp );
- psHooks->FClose( fp );
-
- fp = psHooks->FOpen( pszFullname, "rb+" );
- if( fp == NULL )
- {
- free( pszBasename );
- free( pszFullname );
- return( NULL );
- }
-
- snprintf( pszFullname, nFullnameLen, "%s.cpg", pszBasename );
- if( pszCodePage != NULL )
- {
- if( strncmp( pszCodePage, "LDID/", 5 ) == 0 )
- {
- ldid = atoi( pszCodePage + 5 );
- if( ldid > 255 )
- ldid = -1; // don't use 0 to indicate out of range as LDID/0 is a valid one
- }
- if( ldid < 0 )
- {
- SAFile fpCPG = psHooks->FOpen( pszFullname, "w" );
- psHooks->FWrite( (char*) pszCodePage, strlen(pszCodePage), 1, fpCPG );
- psHooks->FClose( fpCPG );
- }
- }
- if( pszCodePage == NULL || ldid >= 0 )
- {
- psHooks->Remove( pszFullname );
- }
-
- free( pszBasename );
- free( pszFullname );
-
-/* -------------------------------------------------------------------- */
-/* Create the info structure. */
-/* -------------------------------------------------------------------- */
- psDBF = (DBFHandle) calloc(1,sizeof(DBFInfo));
-
- memcpy( &(psDBF->sHooks), psHooks, sizeof(SAHooks) );
- psDBF->fp = fp;
- psDBF->nRecords = 0;
- psDBF->nFields = 0;
- psDBF->nRecordLength = 1;
- psDBF->nHeaderLength = XBASE_FILEHDR_SZ + 1; /* + 1 for HEADER_RECORD_TERMINATOR */
-
- psDBF->panFieldOffset = NULL;
- psDBF->panFieldSize = NULL;
- psDBF->panFieldDecimals = NULL;
- psDBF->pachFieldType = NULL;
- psDBF->pszHeader = NULL;
-
- psDBF->nCurrentRecord = -1;
- psDBF->bCurrentRecordModified = FALSE;
- psDBF->pszCurrentRecord = NULL;
-
- psDBF->bNoHeader = TRUE;
-
- psDBF->iLanguageDriver = ldid > 0 ? ldid : 0;
- psDBF->pszCodePage = NULL;
- if( pszCodePage )
- {
- psDBF->pszCodePage = (char * ) malloc( strlen(pszCodePage) + 1 );
- strcpy( psDBF->pszCodePage, pszCodePage );
- }
- DBFSetLastModifiedDate(psDBF, 95, 7, 26); /* dummy date */
-
- DBFSetWriteEndOfFileChar(psDBF, TRUE);
-
- return( psDBF );
-}
-
-/************************************************************************/
-/* DBFAddField() */
-/* */
-/* Add a field to a newly created .dbf or to an existing one */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFAddField(DBFHandle psDBF, const char * pszFieldName,
- DBFFieldType eType, int nWidth, int nDecimals )
-
-{
- char chNativeType = 'C';
-
- if( eType == FTLogical )
- chNativeType = 'L';
- else if( eType == FTString )
- chNativeType = 'C';
- else
- chNativeType = 'N';
-
- return DBFAddNativeFieldType( psDBF, pszFieldName, chNativeType,
- nWidth, nDecimals );
-}
-
-/************************************************************************/
-/* DBFGetNullCharacter() */
-/************************************************************************/
-
-static char DBFGetNullCharacter(char chType)
-{
- switch (chType)
- {
- case 'N':
- case 'F':
- return '*';
- case 'D':
- return '0';
- case 'L':
- return '?';
- default:
- return ' ';
- }
-}
-
-/************************************************************************/
-/* DBFAddField() */
-/* */
-/* Add a field to a newly created .dbf file before any records */
-/* are written. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFAddNativeFieldType(DBFHandle psDBF, const char * pszFieldName,
- char chType, int nWidth, int nDecimals )
-
-{
- char *pszFInfo;
- int i;
- int nOldRecordLength, nOldHeaderLength;
- char *pszRecord;
- char chFieldFill;
- SAOffset nRecordOffset;
-
- /* make sure that everything is written in .dbf */
- if( !DBFFlushRecord( psDBF ) )
- return -1;
-
- if( psDBF->nHeaderLength + XBASE_FLDHDR_SZ > 65535 )
- {
- char szMessage[128];
- snprintf( szMessage, sizeof(szMessage),
- "Cannot add field %s. Header length limit reached "
- "(max 65535 bytes, 2046 fields).",
- pszFieldName );
- psDBF->sHooks.Error( szMessage );
- return -1;
- }
-
-/* -------------------------------------------------------------------- */
-/* Do some checking to ensure we can add records to this file. */
-/* -------------------------------------------------------------------- */
- if( nWidth < 1 )
- return -1;
-
- if( nWidth > XBASE_FLD_MAX_WIDTH )
- nWidth = XBASE_FLD_MAX_WIDTH;
-
- if( psDBF->nRecordLength + nWidth > 65535 )
- {
- char szMessage[128];
- snprintf( szMessage, sizeof(szMessage),
- "Cannot add field %s. Record length limit reached "
- "(max 65535 bytes).",
- pszFieldName );
- psDBF->sHooks.Error( szMessage );
- return -1;
- }
-
- nOldRecordLength = psDBF->nRecordLength;
- nOldHeaderLength = psDBF->nHeaderLength;
-
-/* -------------------------------------------------------------------- */
-/* SfRealloc all the arrays larger to hold the additional field */
-/* information. */
-/* -------------------------------------------------------------------- */
- psDBF->nFields++;
-
- psDBF->panFieldOffset = (int *)
- SfRealloc( psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
-
- psDBF->panFieldSize = (int *)
- SfRealloc( psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
-
- psDBF->panFieldDecimals = (int *)
- SfRealloc( psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
-
- psDBF->pachFieldType = (char *)
- SfRealloc( psDBF->pachFieldType, sizeof(char) * psDBF->nFields );
-
-/* -------------------------------------------------------------------- */
-/* Assign the new field information fields. */
-/* -------------------------------------------------------------------- */
- psDBF->panFieldOffset[psDBF->nFields-1] = psDBF->nRecordLength;
- psDBF->nRecordLength += nWidth;
- psDBF->panFieldSize[psDBF->nFields-1] = nWidth;
- psDBF->panFieldDecimals[psDBF->nFields-1] = nDecimals;
- psDBF->pachFieldType[psDBF->nFields-1] = chType;
-
-/* -------------------------------------------------------------------- */
-/* Extend the required header information. */
-/* -------------------------------------------------------------------- */
- psDBF->nHeaderLength += XBASE_FLDHDR_SZ;
- psDBF->bUpdated = FALSE;
-
- psDBF->pszHeader = (char *) SfRealloc(psDBF->pszHeader,
- psDBF->nFields*XBASE_FLDHDR_SZ);
-
- pszFInfo = psDBF->pszHeader + XBASE_FLDHDR_SZ * (psDBF->nFields-1);
-
- for( i = 0; i < XBASE_FLDHDR_SZ; i++ )
- pszFInfo[i] = '\0';
-
- strncpy( pszFInfo, pszFieldName, XBASE_FLDNAME_LEN_WRITE );
-
- pszFInfo[11] = psDBF->pachFieldType[psDBF->nFields-1];
-
- if( chType == 'C' )
- {
- pszFInfo[16] = (unsigned char) (nWidth % 256);
- pszFInfo[17] = (unsigned char) (nWidth / 256);
- }
- else
- {
- pszFInfo[16] = (unsigned char) nWidth;
- pszFInfo[17] = (unsigned char) nDecimals;
- }
-
-/* -------------------------------------------------------------------- */
-/* Make the current record buffer appropriately larger. */
-/* -------------------------------------------------------------------- */
- psDBF->pszCurrentRecord = (char *) SfRealloc(psDBF->pszCurrentRecord,
- psDBF->nRecordLength);
-
- /* we're done if dealing with new .dbf */
- if( psDBF->bNoHeader )
- return( psDBF->nFields - 1 );
-
-/* -------------------------------------------------------------------- */
-/* For existing .dbf file, shift records */
-/* -------------------------------------------------------------------- */
-
- /* alloc record */
- pszRecord = (char *) malloc(sizeof(char) * psDBF->nRecordLength);
-
- chFieldFill = DBFGetNullCharacter(chType);
-
- for (i = psDBF->nRecords-1; i >= 0; --i)
- {
- nRecordOffset = nOldRecordLength * (SAOffset) i + nOldHeaderLength;
-
- /* load record */
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp );
-
- /* set new field's value to NULL */
- memset(pszRecord + nOldRecordLength, chFieldFill, nWidth);
-
- nRecordOffset = psDBF->nRecordLength * (SAOffset) i + psDBF->nHeaderLength;
-
- /* move record to the new place*/
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FWrite( pszRecord, psDBF->nRecordLength, 1, psDBF->fp );
- }
-
- if( psDBF->bWriteEndOfFileChar )
- {
- char ch = END_OF_FILE_CHARACTER;
-
- nRecordOffset =
- psDBF->nRecordLength * (SAOffset) psDBF->nRecords + psDBF->nHeaderLength;
-
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp );
- }
-
- /* free record */
- free(pszRecord);
-
- /* force update of header with new header, record length and new field */
- psDBF->bNoHeader = TRUE;
- DBFUpdateHeader( psDBF );
-
- psDBF->nCurrentRecord = -1;
- psDBF->bCurrentRecordModified = FALSE;
- psDBF->bUpdated = TRUE;
-
- return( psDBF->nFields-1 );
-}
-
-/************************************************************************/
-/* DBFReadAttribute() */
-/* */
-/* Read one of the attribute fields of a record. */
-/************************************************************************/
-
-static void *DBFReadAttribute(DBFHandle psDBF, int hEntity, int iField,
- char chReqType )
-
-{
- unsigned char *pabyRec;
- void *pReturnField = NULL;
-
-/* -------------------------------------------------------------------- */
-/* Verify selection. */
-/* -------------------------------------------------------------------- */
- if( hEntity < 0 || hEntity >= psDBF->nRecords )
- return( NULL );
-
- if( iField < 0 || iField >= psDBF->nFields )
- return( NULL );
-
-/* -------------------------------------------------------------------- */
-/* Have we read the record? */
-/* -------------------------------------------------------------------- */
- if( !DBFLoadRecord( psDBF, hEntity ) )
- return NULL;
-
- pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
-
-/* -------------------------------------------------------------------- */
-/* Ensure we have room to extract the target field. */
-/* -------------------------------------------------------------------- */
- if( psDBF->panFieldSize[iField] >= psDBF->nWorkFieldLength )
- {
- psDBF->nWorkFieldLength = psDBF->panFieldSize[iField] + 100;
- if( psDBF->pszWorkField == NULL )
- psDBF->pszWorkField = (char *) malloc(psDBF->nWorkFieldLength);
- else
- psDBF->pszWorkField = (char *) realloc(psDBF->pszWorkField,
- psDBF->nWorkFieldLength);
- }
-
-/* -------------------------------------------------------------------- */
-/* Extract the requested field. */
-/* -------------------------------------------------------------------- */
- memcpy( psDBF->pszWorkField,
- ((const char *) pabyRec) + psDBF->panFieldOffset[iField],
- psDBF->panFieldSize[iField] );
- psDBF->pszWorkField[psDBF->panFieldSize[iField]] = '\0';
-
- pReturnField = psDBF->pszWorkField;
-
-/* -------------------------------------------------------------------- */
-/* Decode the field. */
-/* -------------------------------------------------------------------- */
- if( chReqType == 'I' )
- {
- psDBF->fieldValue.nIntField = atoi(psDBF->pszWorkField);
-
- pReturnField = &(psDBF->fieldValue.nIntField);
- }
- else if( chReqType == 'N' )
- {
- psDBF->fieldValue.dfDoubleField = psDBF->sHooks.Atof(psDBF->pszWorkField);
-
- pReturnField = &(psDBF->fieldValue.dfDoubleField);
- }
-
-/* -------------------------------------------------------------------- */
-/* Should we trim white space off the string attribute value? */
-/* -------------------------------------------------------------------- */
-#ifdef TRIM_DBF_WHITESPACE
- else
- {
- char *pchSrc, *pchDst;
-
- pchDst = pchSrc = psDBF->pszWorkField;
- while( *pchSrc == ' ' )
- pchSrc++;
-
- while( *pchSrc != '\0' )
- *(pchDst++) = *(pchSrc++);
- *pchDst = '\0';
-
- while( pchDst != psDBF->pszWorkField && *(--pchDst) == ' ' )
- *pchDst = '\0';
- }
-#endif
-
- return( pReturnField );
-}
-
-/************************************************************************/
-/* DBFReadIntAttribute() */
-/* */
-/* Read an integer attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFReadIntegerAttribute( DBFHandle psDBF, int iRecord, int iField )
-
-{
- int *pnValue;
-
- pnValue = (int *) DBFReadAttribute( psDBF, iRecord, iField, 'I' );
-
- if( pnValue == NULL )
- return 0;
- else
- return( *pnValue );
-}
-
-/************************************************************************/
-/* DBFReadDoubleAttribute() */
-/* */
-/* Read a double attribute. */
-/************************************************************************/
-
-double SHPAPI_CALL
-DBFReadDoubleAttribute( DBFHandle psDBF, int iRecord, int iField )
-
-{
- double *pdValue;
-
- pdValue = (double *) DBFReadAttribute( psDBF, iRecord, iField, 'N' );
-
- if( pdValue == NULL )
- return 0.0;
- else
- return( *pdValue );
-}
-
-/************************************************************************/
-/* DBFReadStringAttribute() */
-/* */
-/* Read a string attribute. */
-/************************************************************************/
-
-const char SHPAPI_CALL1(*)
-DBFReadStringAttribute( DBFHandle psDBF, int iRecord, int iField )
-
-{
- return( (const char *) DBFReadAttribute( psDBF, iRecord, iField, 'C' ) );
-}
-
-/************************************************************************/
-/* DBFReadLogicalAttribute() */
-/* */
-/* Read a logical attribute. */
-/************************************************************************/
-
-const char SHPAPI_CALL1(*)
-DBFReadLogicalAttribute( DBFHandle psDBF, int iRecord, int iField )
-
-{
- return( (const char *) DBFReadAttribute( psDBF, iRecord, iField, 'L' ) );
-}
-
-
-/************************************************************************/
-/* DBFIsValueNULL() */
-/* */
-/* Return TRUE if the passed string is NULL. */
-/************************************************************************/
-
-static int DBFIsValueNULL( char chType, const char* pszValue )
-{
- int i;
-
- if( pszValue == NULL )
- return TRUE;
-
- switch(chType)
- {
- case 'N':
- case 'F':
- /*
- ** We accept all asterisks or all blanks as NULL
- ** though according to the spec I think it should be all
- ** asterisks.
- */
- if( pszValue[0] == '*' )
- return TRUE;
-
- for( i = 0; pszValue[i] != '\0'; i++ )
- {
- if( pszValue[i] != ' ' )
- return FALSE;
- }
- return TRUE;
-
- case 'D':
- /* NULL date fields have value "00000000" */
- return strncmp(pszValue,"00000000",8) == 0;
-
- case 'L':
- /* NULL boolean fields have value "?" */
- return pszValue[0] == '?';
-
- default:
- /* empty string fields are considered NULL */
- return strlen(pszValue) == 0;
- }
-}
-
-/************************************************************************/
-/* DBFIsAttributeNULL() */
-/* */
-/* Return TRUE if value for field is NULL. */
-/* */
-/* Contributed by Jim Matthews. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFIsAttributeNULL( DBFHandle psDBF, int iRecord, int iField )
-
-{
- const char *pszValue;
-
- pszValue = DBFReadStringAttribute( psDBF, iRecord, iField );
-
- if( pszValue == NULL )
- return TRUE;
-
- return DBFIsValueNULL( psDBF->pachFieldType[iField], pszValue );
-}
-
-/************************************************************************/
-/* DBFGetFieldCount() */
-/* */
-/* Return the number of fields in this table. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFGetFieldCount( DBFHandle psDBF )
-
-{
- return( psDBF->nFields );
-}
-
-/************************************************************************/
-/* DBFGetRecordCount() */
-/* */
-/* Return the number of records in this table. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFGetRecordCount( DBFHandle psDBF )
-
-{
- return( psDBF->nRecords );
-}
-
-/************************************************************************/
-/* DBFGetFieldInfo() */
-/* */
-/* Return any requested information about the field. */
-/* pszFieldName must be at least XBASE_FLDNAME_LEN_READ+1 (=12) */
-/* bytes long. */
-/************************************************************************/
-
-DBFFieldType SHPAPI_CALL
-DBFGetFieldInfo( DBFHandle psDBF, int iField, char * pszFieldName,
- int * pnWidth, int * pnDecimals )
-
-{
- if( iField < 0 || iField >= psDBF->nFields )
- return( FTInvalid );
-
- if( pnWidth != NULL )
- *pnWidth = psDBF->panFieldSize[iField];
-
- if( pnDecimals != NULL )
- *pnDecimals = psDBF->panFieldDecimals[iField];
-
- if( pszFieldName != NULL )
- {
- int i;
-
- strncpy( pszFieldName, (char *) psDBF->pszHeader+iField*XBASE_FLDHDR_SZ,
- XBASE_FLDNAME_LEN_READ );
- pszFieldName[XBASE_FLDNAME_LEN_READ] = '\0';
- for( i = XBASE_FLDNAME_LEN_READ - 1; i > 0 && pszFieldName[i] == ' '; i-- )
- pszFieldName[i] = '\0';
- }
-
- if ( psDBF->pachFieldType[iField] == 'L' )
- return( FTLogical);
-
- else if( psDBF->pachFieldType[iField] == 'N'
- || psDBF->pachFieldType[iField] == 'F' )
- {
- if( psDBF->panFieldDecimals[iField] > 0
- || psDBF->panFieldSize[iField] >= 10 )
- return( FTDouble );
- else
- return( FTInteger );
- }
- else
- {
- return( FTString );
- }
-}
-
-/************************************************************************/
-/* DBFWriteAttribute() */
-/* */
-/* Write an attribute record to the file. */
-/************************************************************************/
-
-static int DBFWriteAttribute(DBFHandle psDBF, int hEntity, int iField,
- void * pValue )
-
-{
- int i, j, nRetResult = TRUE;
- unsigned char *pabyRec;
- char szSField[XBASE_FLD_MAX_WIDTH+1], szFormat[20];
-
-/* -------------------------------------------------------------------- */
-/* Is this a valid record? */
-/* -------------------------------------------------------------------- */
- if( hEntity < 0 || hEntity > psDBF->nRecords )
- return( FALSE );
-
- if( psDBF->bNoHeader )
- DBFWriteHeader(psDBF);
-
-/* -------------------------------------------------------------------- */
-/* Is this a brand new record? */
-/* -------------------------------------------------------------------- */
- if( hEntity == psDBF->nRecords )
- {
- if( !DBFFlushRecord( psDBF ) )
- return FALSE;
-
- psDBF->nRecords++;
- for( i = 0; i < psDBF->nRecordLength; i++ )
- psDBF->pszCurrentRecord[i] = ' ';
-
- psDBF->nCurrentRecord = hEntity;
- }
-
-/* -------------------------------------------------------------------- */
-/* Is this an existing record, but different than the last one */
-/* we accessed? */
-/* -------------------------------------------------------------------- */
- if( !DBFLoadRecord( psDBF, hEntity ) )
- return FALSE;
-
- pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
-
- psDBF->bCurrentRecordModified = TRUE;
- psDBF->bUpdated = TRUE;
-
-/* -------------------------------------------------------------------- */
-/* Translate NULL value to valid DBF file representation. */
-/* */
-/* Contributed by Jim Matthews. */
-/* -------------------------------------------------------------------- */
- if( pValue == NULL )
- {
- memset( (char *) (pabyRec+psDBF->panFieldOffset[iField]),
- DBFGetNullCharacter(psDBF->pachFieldType[iField]),
- psDBF->panFieldSize[iField] );
- return TRUE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Assign all the record fields. */
-/* -------------------------------------------------------------------- */
- switch( psDBF->pachFieldType[iField] )
- {
- case 'D':
- case 'N':
- case 'F':
- {
- int nWidth = psDBF->panFieldSize[iField];
-
- if( (int) sizeof(szSField)-2 < nWidth )
- nWidth = sizeof(szSField)-2;
-
- snprintf( szFormat, sizeof(szFormat), "%%%d.%df",
- nWidth, psDBF->panFieldDecimals[iField] );
- CPLsnprintf(szSField, sizeof(szSField), szFormat, *((double *) pValue) );
- if( (int) strlen(szSField) > psDBF->panFieldSize[iField] )
- {
- szSField[psDBF->panFieldSize[iField]] = '\0';
- nRetResult = FALSE;
- }
- strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
- szSField, strlen(szSField) );
- break;
- }
-
- case 'L':
- if (psDBF->panFieldSize[iField] >= 1 &&
- (*(char*)pValue == 'F' || *(char*)pValue == 'T'))
- *(pabyRec+psDBF->panFieldOffset[iField]) = *(char*)pValue;
- break;
-
- default:
- if( (int) strlen((char *) pValue) > psDBF->panFieldSize[iField] )
- {
- j = psDBF->panFieldSize[iField];
- nRetResult = FALSE;
- }
- else
- {
- memset( pabyRec+psDBF->panFieldOffset[iField], ' ',
- psDBF->panFieldSize[iField] );
- j = (int)strlen((char *) pValue);
- }
-
- strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
- (char *) pValue, j );
- break;
- }
-
- return( nRetResult );
-}
-
-/************************************************************************/
-/* DBFWriteAttributeDirectly() */
-/* */
-/* Write an attribute record to the file, but without any */
-/* reformatting based on type. The provided buffer is written */
-/* as is to the field position in the record. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField,
- void * pValue )
-
-{
- int i, j;
- unsigned char *pabyRec;
-
-/* -------------------------------------------------------------------- */
-/* Is this a valid record? */
-/* -------------------------------------------------------------------- */
- if( hEntity < 0 || hEntity > psDBF->nRecords )
- return( FALSE );
-
- if( psDBF->bNoHeader )
- DBFWriteHeader(psDBF);
-
-/* -------------------------------------------------------------------- */
-/* Is this a brand new record? */
-/* -------------------------------------------------------------------- */
- if( hEntity == psDBF->nRecords )
- {
- if( !DBFFlushRecord( psDBF ) )
- return FALSE;
-
- psDBF->nRecords++;
- for( i = 0; i < psDBF->nRecordLength; i++ )
- psDBF->pszCurrentRecord[i] = ' ';
-
- psDBF->nCurrentRecord = hEntity;
- }
-
-/* -------------------------------------------------------------------- */
-/* Is this an existing record, but different than the last one */
-/* we accessed? */
-/* -------------------------------------------------------------------- */
- if( !DBFLoadRecord( psDBF, hEntity ) )
- return FALSE;
-
- pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
-
-/* -------------------------------------------------------------------- */
-/* Assign all the record fields. */
-/* -------------------------------------------------------------------- */
- if( (int)strlen((char *) pValue) > psDBF->panFieldSize[iField] )
- j = psDBF->panFieldSize[iField];
- else
- {
- memset( pabyRec+psDBF->panFieldOffset[iField], ' ',
- psDBF->panFieldSize[iField] );
- j = (int)strlen((char *) pValue);
- }
-
- strncpy((char *) (pabyRec+psDBF->panFieldOffset[iField]),
- (char *) pValue, j );
-
- psDBF->bCurrentRecordModified = TRUE;
- psDBF->bUpdated = TRUE;
-
- return( TRUE );
-}
-
-/************************************************************************/
-/* DBFWriteDoubleAttribute() */
-/* */
-/* Write a double attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteDoubleAttribute( DBFHandle psDBF, int iRecord, int iField,
- double dValue )
-
-{
- return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) &dValue ) );
-}
-
-/************************************************************************/
-/* DBFWriteIntegerAttribute() */
-/* */
-/* Write a integer attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteIntegerAttribute( DBFHandle psDBF, int iRecord, int iField,
- int nValue )
-
-{
- double dValue = nValue;
-
- return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) &dValue ) );
-}
-
-/************************************************************************/
-/* DBFWriteStringAttribute() */
-/* */
-/* Write a string attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteStringAttribute( DBFHandle psDBF, int iRecord, int iField,
- const char * pszValue )
-
-{
- return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) pszValue ) );
-}
-
-/************************************************************************/
-/* DBFWriteNULLAttribute() */
-/* */
-/* Write a string attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteNULLAttribute( DBFHandle psDBF, int iRecord, int iField )
-
-{
- return( DBFWriteAttribute( psDBF, iRecord, iField, NULL ) );
-}
-
-/************************************************************************/
-/* DBFWriteLogicalAttribute() */
-/* */
-/* Write a logical attribute. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteLogicalAttribute( DBFHandle psDBF, int iRecord, int iField,
- const char lValue)
-
-{
- return( DBFWriteAttribute( psDBF, iRecord, iField, (void *) (&lValue) ) );
-}
-
-/************************************************************************/
-/* DBFWriteTuple() */
-/* */
-/* Write an attribute record to the file. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple )
-
-{
- int i;
- unsigned char *pabyRec;
-
-/* -------------------------------------------------------------------- */
-/* Is this a valid record? */
-/* -------------------------------------------------------------------- */
- if( hEntity < 0 || hEntity > psDBF->nRecords )
- return( FALSE );
-
- if( psDBF->bNoHeader )
- DBFWriteHeader(psDBF);
-
-/* -------------------------------------------------------------------- */
-/* Is this a brand new record? */
-/* -------------------------------------------------------------------- */
- if( hEntity == psDBF->nRecords )
- {
- if( !DBFFlushRecord( psDBF ) )
- return FALSE;
-
- psDBF->nRecords++;
- for( i = 0; i < psDBF->nRecordLength; i++ )
- psDBF->pszCurrentRecord[i] = ' ';
-
- psDBF->nCurrentRecord = hEntity;
- }
-
-/* -------------------------------------------------------------------- */
-/* Is this an existing record, but different than the last one */
-/* we accessed? */
-/* -------------------------------------------------------------------- */
- if( !DBFLoadRecord( psDBF, hEntity ) )
- return FALSE;
-
- pabyRec = (unsigned char *) psDBF->pszCurrentRecord;
-
- memcpy ( pabyRec, pRawTuple, psDBF->nRecordLength );
-
- psDBF->bCurrentRecordModified = TRUE;
- psDBF->bUpdated = TRUE;
-
- return( TRUE );
-}
-
-/************************************************************************/
-/* DBFReadTuple() */
-/* */
-/* Read a complete record. Note that the result is only valid */
-/* till the next record read for any reason. */
-/************************************************************************/
-
-const char SHPAPI_CALL1(*)
-DBFReadTuple(DBFHandle psDBF, int hEntity )
-
-{
- if( hEntity < 0 || hEntity >= psDBF->nRecords )
- return( NULL );
-
- if( !DBFLoadRecord( psDBF, hEntity ) )
- return NULL;
-
- return (const char *) psDBF->pszCurrentRecord;
-}
-
-/************************************************************************/
-/* DBFCloneEmpty() */
-/* */
-/* Read one of the attribute fields of a record. */
-/************************************************************************/
-
-DBFHandle SHPAPI_CALL
-DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename )
-{
- DBFHandle newDBF;
-
- newDBF = DBFCreateEx ( pszFilename, psDBF->pszCodePage );
- if ( newDBF == NULL ) return ( NULL );
-
- newDBF->nFields = psDBF->nFields;
- newDBF->nRecordLength = psDBF->nRecordLength;
- newDBF->nHeaderLength = psDBF->nHeaderLength;
-
- if( psDBF->pszHeader )
- {
- newDBF->pszHeader = (char *) malloc ( XBASE_FLDHDR_SZ * psDBF->nFields );
- memcpy ( newDBF->pszHeader, psDBF->pszHeader, XBASE_FLDHDR_SZ * psDBF->nFields );
- }
-
- newDBF->panFieldOffset = (int *) malloc ( sizeof(int) * psDBF->nFields );
- memcpy ( newDBF->panFieldOffset, psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
- newDBF->panFieldSize = (int *) malloc ( sizeof(int) * psDBF->nFields );
- memcpy ( newDBF->panFieldSize, psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
- newDBF->panFieldDecimals = (int *) malloc ( sizeof(int) * psDBF->nFields );
- memcpy ( newDBF->panFieldDecimals, psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
- newDBF->pachFieldType = (char *) malloc ( sizeof(char) * psDBF->nFields );
- memcpy ( newDBF->pachFieldType, psDBF->pachFieldType, sizeof(char)*psDBF->nFields );
-
- newDBF->bNoHeader = TRUE;
- newDBF->bUpdated = TRUE;
- newDBF->bWriteEndOfFileChar = psDBF->bWriteEndOfFileChar;
-
- DBFWriteHeader ( newDBF );
- DBFClose ( newDBF );
-
- newDBF = DBFOpen ( pszFilename, "rb+" );
- newDBF->bWriteEndOfFileChar = psDBF->bWriteEndOfFileChar;
-
- return ( newDBF );
-}
-
-/************************************************************************/
-/* DBFGetNativeFieldType() */
-/* */
-/* Return the DBase field type for the specified field. */
-/* */
-/* Value can be one of: 'C' (String), 'D' (Date), 'F' (Float), */
-/* 'N' (Numeric, with or without decimal), */
-/* 'L' (Logical), */
-/* 'M' (Memo: 10 digits .DBT block ptr) */
-/************************************************************************/
-
-char SHPAPI_CALL
-DBFGetNativeFieldType( DBFHandle psDBF, int iField )
-
-{
- if( iField >=0 && iField < psDBF->nFields )
- return psDBF->pachFieldType[iField];
-
- return ' ';
-}
-
-/************************************************************************/
-/* str_to_upper() */
-/************************************************************************/
-
-static void str_to_upper (char *string)
-{
- int len;
- int i = -1;
-
- len = (int)strlen (string);
-
- while (++i < len)
- if (isalpha(string[i]) && islower(string[i]))
- string[i] = (char) toupper ((int)string[i]);
-}
-
-/************************************************************************/
-/* DBFGetFieldIndex() */
-/* */
-/* Get the index number for a field in a .dbf file. */
-/* */
-/* Contributed by Jim Matthews. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName)
-
-{
- char name[XBASE_FLDNAME_LEN_READ+1],
- name1[XBASE_FLDNAME_LEN_READ+1],
- name2[XBASE_FLDNAME_LEN_READ+1];
- int i;
-
- strncpy(name1, pszFieldName,XBASE_FLDNAME_LEN_READ);
- name1[XBASE_FLDNAME_LEN_READ] = '\0';
- str_to_upper(name1);
-
- for( i = 0; i < DBFGetFieldCount(psDBF); i++ )
- {
- DBFGetFieldInfo( psDBF, i, name, NULL, NULL );
- strncpy(name2,name,XBASE_FLDNAME_LEN_READ);
- name2[XBASE_FLDNAME_LEN_READ] = '\0';
- str_to_upper(name2);
-
- if(!strcmp(name1,name2))
- return(i);
- }
- return(-1);
-}
-
-/************************************************************************/
-/* DBFIsRecordDeleted() */
-/* */
-/* Returns TRUE if the indicated record is deleted, otherwise */
-/* it returns FALSE. */
-/************************************************************************/
-
-int SHPAPI_CALL DBFIsRecordDeleted( DBFHandle psDBF, int iShape )
-
-{
-/* -------------------------------------------------------------------- */
-/* Verify selection. */
-/* -------------------------------------------------------------------- */
- if( iShape < 0 || iShape >= psDBF->nRecords )
- return TRUE;
-
-/* -------------------------------------------------------------------- */
-/* Have we read the record? */
-/* -------------------------------------------------------------------- */
- if( !DBFLoadRecord( psDBF, iShape ) )
- return FALSE;
-
-/* -------------------------------------------------------------------- */
-/* '*' means deleted. */
-/* -------------------------------------------------------------------- */
- return psDBF->pszCurrentRecord[0] == '*';
-}
-
-/************************************************************************/
-/* DBFMarkRecordDeleted() */
-/************************************************************************/
-
-int SHPAPI_CALL DBFMarkRecordDeleted( DBFHandle psDBF, int iShape,
- int bIsDeleted )
-
-{
- char chNewFlag;
-
-/* -------------------------------------------------------------------- */
-/* Verify selection. */
-/* -------------------------------------------------------------------- */
- if( iShape < 0 || iShape >= psDBF->nRecords )
- return FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Is this an existing record, but different than the last one */
-/* we accessed? */
-/* -------------------------------------------------------------------- */
- if( !DBFLoadRecord( psDBF, iShape ) )
- return FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Assign value, marking record as dirty if it changes. */
-/* -------------------------------------------------------------------- */
- if( bIsDeleted )
- chNewFlag = '*';
- else
- chNewFlag = ' ';
-
- if( psDBF->pszCurrentRecord[0] != chNewFlag )
- {
- psDBF->bCurrentRecordModified = TRUE;
- psDBF->bUpdated = TRUE;
- psDBF->pszCurrentRecord[0] = chNewFlag;
- }
-
- return TRUE;
-}
-
-/************************************************************************/
-/* DBFGetCodePage */
-/************************************************************************/
-
-const char SHPAPI_CALL1(*)
-DBFGetCodePage(DBFHandle psDBF )
-{
- if( psDBF == NULL )
- return NULL;
- return psDBF->pszCodePage;
-}
-
-/************************************************************************/
-/* DBFDeleteField() */
-/* */
-/* Remove a field from a .dbf file */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFDeleteField(DBFHandle psDBF, int iField)
-{
- int nOldRecordLength, nOldHeaderLength;
- int nDeletedFieldOffset, nDeletedFieldSize;
- SAOffset nRecordOffset;
- char* pszRecord;
- int i, iRecord;
-
- if (iField < 0 || iField >= psDBF->nFields)
- return FALSE;
-
- /* make sure that everything is written in .dbf */
- if( !DBFFlushRecord( psDBF ) )
- return FALSE;
-
- /* get information about field to be deleted */
- nOldRecordLength = psDBF->nRecordLength;
- nOldHeaderLength = psDBF->nHeaderLength;
- nDeletedFieldOffset = psDBF->panFieldOffset[iField];
- nDeletedFieldSize = psDBF->panFieldSize[iField];
-
- /* update fields info */
- for (i = iField + 1; i < psDBF->nFields; i++)
- {
- psDBF->panFieldOffset[i-1] = psDBF->panFieldOffset[i] - nDeletedFieldSize;
- psDBF->panFieldSize[i-1] = psDBF->panFieldSize[i];
- psDBF->panFieldDecimals[i-1] = psDBF->panFieldDecimals[i];
- psDBF->pachFieldType[i-1] = psDBF->pachFieldType[i];
- }
-
- /* resize fields arrays */
- psDBF->nFields--;
-
- psDBF->panFieldOffset = (int *)
- SfRealloc( psDBF->panFieldOffset, sizeof(int) * psDBF->nFields );
-
- psDBF->panFieldSize = (int *)
- SfRealloc( psDBF->panFieldSize, sizeof(int) * psDBF->nFields );
-
- psDBF->panFieldDecimals = (int *)
- SfRealloc( psDBF->panFieldDecimals, sizeof(int) * psDBF->nFields );
-
- psDBF->pachFieldType = (char *)
- SfRealloc( psDBF->pachFieldType, sizeof(char) * psDBF->nFields );
-
- /* update header information */
- psDBF->nHeaderLength -= XBASE_FLDHDR_SZ;
- psDBF->nRecordLength -= nDeletedFieldSize;
-
- /* overwrite field information in header */
- memmove(psDBF->pszHeader + iField*XBASE_FLDHDR_SZ,
- psDBF->pszHeader + (iField+1)*XBASE_FLDHDR_SZ,
- sizeof(char) * (psDBF->nFields - iField)*XBASE_FLDHDR_SZ);
-
- psDBF->pszHeader = (char *) SfRealloc(psDBF->pszHeader,
- psDBF->nFields*XBASE_FLDHDR_SZ);
-
- /* update size of current record appropriately */
- psDBF->pszCurrentRecord = (char *) SfRealloc(psDBF->pszCurrentRecord,
- psDBF->nRecordLength);
-
- /* we're done if we're dealing with not yet created .dbf */
- if ( psDBF->bNoHeader && psDBF->nRecords == 0 )
- return TRUE;
-
- /* force update of header with new header and record length */
- psDBF->bNoHeader = TRUE;
- DBFUpdateHeader( psDBF );
-
- /* alloc record */
- pszRecord = (char *) malloc(sizeof(char) * nOldRecordLength);
-
- /* shift records to their new positions */
- for (iRecord = 0; iRecord < psDBF->nRecords; iRecord++)
- {
- nRecordOffset =
- nOldRecordLength * (SAOffset) iRecord + nOldHeaderLength;
-
- /* load record */
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp );
-
- nRecordOffset =
- psDBF->nRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
-
- /* move record in two steps */
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FWrite( pszRecord, nDeletedFieldOffset, 1, psDBF->fp );
- psDBF->sHooks.FWrite( pszRecord + nDeletedFieldOffset + nDeletedFieldSize,
- nOldRecordLength - nDeletedFieldOffset - nDeletedFieldSize,
- 1, psDBF->fp );
-
- }
-
- if( psDBF->bWriteEndOfFileChar )
- {
- char ch = END_OF_FILE_CHARACTER;
- psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp );
- }
-
- /* TODO: truncate file */
-
- /* free record */
- free(pszRecord);
-
- psDBF->nCurrentRecord = -1;
- psDBF->bCurrentRecordModified = FALSE;
- psDBF->bUpdated = TRUE;
-
- return TRUE;
-}
-
-/************************************************************************/
-/* DBFReorderFields() */
-/* */
-/* Reorder the fields of a .dbf file */
-/* */
-/* panMap must be exactly psDBF->nFields long and be a permutation */
-/* of [0, psDBF->nFields-1]. This assumption will not be asserted in the*/
-/* code of DBFReorderFields. */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFReorderFields( DBFHandle psDBF, int* panMap )
-{
- SAOffset nRecordOffset;
- int i, iRecord;
- int *panFieldOffsetNew;
- int *panFieldSizeNew;
- int *panFieldDecimalsNew;
- char *pachFieldTypeNew;
- char *pszHeaderNew;
- char *pszRecord;
- char *pszRecordNew;
-
- if ( psDBF->nFields == 0 )
- return TRUE;
-
- /* make sure that everything is written in .dbf */
- if( !DBFFlushRecord( psDBF ) )
- return FALSE;
-
- /* a simple malloc() would be enough, but calloc() helps clang static analyzer */
- panFieldOffsetNew = (int *) calloc(sizeof(int), psDBF->nFields);
- panFieldSizeNew = (int *) calloc(sizeof(int), psDBF->nFields);
- panFieldDecimalsNew = (int *) calloc(sizeof(int), psDBF->nFields);
- pachFieldTypeNew = (char *) calloc(sizeof(char), psDBF->nFields);
- pszHeaderNew = (char*) malloc(sizeof(char) * XBASE_FLDHDR_SZ *
- psDBF->nFields);
-
- /* shuffle fields definitions */
- for(i=0; i < psDBF->nFields; i++)
- {
- panFieldSizeNew[i] = psDBF->panFieldSize[panMap[i]];
- panFieldDecimalsNew[i] = psDBF->panFieldDecimals[panMap[i]];
- pachFieldTypeNew[i] = psDBF->pachFieldType[panMap[i]];
- memcpy(pszHeaderNew + i * XBASE_FLDHDR_SZ,
- psDBF->pszHeader + panMap[i] * XBASE_FLDHDR_SZ, XBASE_FLDHDR_SZ);
- }
- panFieldOffsetNew[0] = 1;
- for(i=1; i < psDBF->nFields; i++)
- {
- panFieldOffsetNew[i] = panFieldOffsetNew[i - 1] + panFieldSizeNew[i - 1];
- }
-
- free(psDBF->pszHeader);
- psDBF->pszHeader = pszHeaderNew;
-
- /* we're done if we're dealing with not yet created .dbf */
- if ( !(psDBF->bNoHeader && psDBF->nRecords == 0) )
- {
- /* force update of header with new header and record length */
- psDBF->bNoHeader = TRUE;
- DBFUpdateHeader( psDBF );
-
- /* alloc record */
- pszRecord = (char *) malloc(sizeof(char) * psDBF->nRecordLength);
- pszRecordNew = (char *) malloc(sizeof(char) * psDBF->nRecordLength);
-
- /* shuffle fields in records */
- for (iRecord = 0; iRecord < psDBF->nRecords; iRecord++)
- {
- nRecordOffset =
- psDBF->nRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
-
- /* load record */
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FRead( pszRecord, psDBF->nRecordLength, 1, psDBF->fp );
-
- pszRecordNew[0] = pszRecord[0];
-
- for(i=0; i < psDBF->nFields; i++)
- {
- memcpy(pszRecordNew + panFieldOffsetNew[i],
- pszRecord + psDBF->panFieldOffset[panMap[i]],
- psDBF->panFieldSize[panMap[i]]);
- }
-
- /* write record */
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FWrite( pszRecordNew, psDBF->nRecordLength, 1, psDBF->fp );
- }
-
- /* free record */
- free(pszRecord);
- free(pszRecordNew);
- }
-
- free(psDBF->panFieldOffset);
- free(psDBF->panFieldSize);
- free(psDBF->panFieldDecimals);
- free(psDBF->pachFieldType);
-
- psDBF->panFieldOffset = panFieldOffsetNew;
- psDBF->panFieldSize = panFieldSizeNew;
- psDBF->panFieldDecimals =panFieldDecimalsNew;
- psDBF->pachFieldType = pachFieldTypeNew;
-
- psDBF->nCurrentRecord = -1;
- psDBF->bCurrentRecordModified = FALSE;
- psDBF->bUpdated = TRUE;
-
- return TRUE;
-}
-
-
-/************************************************************************/
-/* DBFAlterFieldDefn() */
-/* */
-/* Alter a field definition in a .dbf file */
-/************************************************************************/
-
-int SHPAPI_CALL
-DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName,
- char chType, int nWidth, int nDecimals )
-{
- int i;
- int iRecord;
- int nOffset;
- int nOldWidth;
- int nOldRecordLength;
- SAOffset nRecordOffset;
- char* pszFInfo;
- char chOldType;
- int bIsNULL;
- char chFieldFill;
-
- if (iField < 0 || iField >= psDBF->nFields)
- return FALSE;
-
- /* make sure that everything is written in .dbf */
- if( !DBFFlushRecord( psDBF ) )
- return FALSE;
-
- chFieldFill = DBFGetNullCharacter(chType);
-
- chOldType = psDBF->pachFieldType[iField];
- nOffset = psDBF->panFieldOffset[iField];
- nOldWidth = psDBF->panFieldSize[iField];
- nOldRecordLength = psDBF->nRecordLength;
-
-/* -------------------------------------------------------------------- */
-/* Do some checking to ensure we can add records to this file. */
-/* -------------------------------------------------------------------- */
- if( nWidth < 1 )
- return -1;
-
- if( nWidth > XBASE_FLD_MAX_WIDTH )
- nWidth = XBASE_FLD_MAX_WIDTH;
-
-/* -------------------------------------------------------------------- */
-/* Assign the new field information fields. */
-/* -------------------------------------------------------------------- */
- psDBF->panFieldSize[iField] = nWidth;
- psDBF->panFieldDecimals[iField] = nDecimals;
- psDBF->pachFieldType[iField] = chType;
-
-/* -------------------------------------------------------------------- */
-/* Update the header information. */
-/* -------------------------------------------------------------------- */
- pszFInfo = psDBF->pszHeader + XBASE_FLDHDR_SZ * iField;
-
- for( i = 0; i < XBASE_FLDHDR_SZ; i++ )
- pszFInfo[i] = '\0';
-
- strncpy( pszFInfo, pszFieldName, XBASE_FLDNAME_LEN_WRITE );
-
- pszFInfo[11] = psDBF->pachFieldType[iField];
-
- if( chType == 'C' )
- {
- pszFInfo[16] = (unsigned char) (nWidth % 256);
- pszFInfo[17] = (unsigned char) (nWidth / 256);
- }
- else
- {
- pszFInfo[16] = (unsigned char) nWidth;
- pszFInfo[17] = (unsigned char) nDecimals;
- }
-
-/* -------------------------------------------------------------------- */
-/* Update offsets */
-/* -------------------------------------------------------------------- */
- if (nWidth != nOldWidth)
- {
- for (i = iField + 1; i < psDBF->nFields; i++)
- psDBF->panFieldOffset[i] += nWidth - nOldWidth;
- psDBF->nRecordLength += nWidth - nOldWidth;
-
- psDBF->pszCurrentRecord = (char *) SfRealloc(psDBF->pszCurrentRecord,
- psDBF->nRecordLength);
- }
-
- /* we're done if we're dealing with not yet created .dbf */
- if ( psDBF->bNoHeader && psDBF->nRecords == 0 )
- return TRUE;
-
- /* force update of header with new header and record length */
- psDBF->bNoHeader = TRUE;
- DBFUpdateHeader( psDBF );
-
- if (nWidth < nOldWidth || (nWidth == nOldWidth && chType != chOldType))
- {
- char* pszRecord = (char *) malloc(sizeof(char) * nOldRecordLength);
- char* pszOldField = (char *) malloc(sizeof(char) * (nOldWidth + 1));
-
- /* cppcheck-suppress uninitdata */
- pszOldField[nOldWidth] = 0;
-
- /* move records to their new positions */
- for (iRecord = 0; iRecord < psDBF->nRecords; iRecord++)
- {
- nRecordOffset =
- nOldRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
-
- /* load record */
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp );
-
- memcpy(pszOldField, pszRecord + nOffset, nOldWidth);
- bIsNULL = DBFIsValueNULL( chOldType, pszOldField );
-
- if (nWidth != nOldWidth)
- {
- if ((chOldType == 'N' || chOldType == 'F') && pszOldField[0] == ' ')
- {
- /* Strip leading spaces when truncating a numeric field */
- memmove( pszRecord + nOffset,
- pszRecord + nOffset + nOldWidth - nWidth,
- nWidth );
- }
- if (nOffset + nOldWidth < nOldRecordLength)
- {
- memmove( pszRecord + nOffset + nWidth,
- pszRecord + nOffset + nOldWidth,
- nOldRecordLength - (nOffset + nOldWidth));
- }
- }
-
- /* Convert null value to the appropriate value of the new type */
- if (bIsNULL)
- {
- memset( pszRecord + nOffset, chFieldFill, nWidth);
- }
-
- nRecordOffset =
- psDBF->nRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
-
- /* write record */
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FWrite( pszRecord, psDBF->nRecordLength, 1, psDBF->fp );
- }
-
- if( psDBF->bWriteEndOfFileChar )
- {
- char ch = END_OF_FILE_CHARACTER;
-
- nRecordOffset =
- psDBF->nRecordLength * (SAOffset) psDBF->nRecords + psDBF->nHeaderLength;
-
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp );
- }
- /* TODO: truncate file */
-
- free(pszRecord);
- free(pszOldField);
- }
- else if (nWidth > nOldWidth)
- {
- char* pszRecord = (char *) malloc(sizeof(char) * psDBF->nRecordLength);
- char* pszOldField = (char *) malloc(sizeof(char) * (nOldWidth + 1));
-
- /* cppcheck-suppress uninitdata */
- pszOldField[nOldWidth] = 0;
-
- /* move records to their new positions */
- for (iRecord = psDBF->nRecords - 1; iRecord >= 0; iRecord--)
- {
- nRecordOffset =
- nOldRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
-
- /* load record */
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FRead( pszRecord, nOldRecordLength, 1, psDBF->fp );
-
- memcpy(pszOldField, pszRecord + nOffset, nOldWidth);
- bIsNULL = DBFIsValueNULL( chOldType, pszOldField );
-
- if (nOffset + nOldWidth < nOldRecordLength)
- {
- memmove( pszRecord + nOffset + nWidth,
- pszRecord + nOffset + nOldWidth,
- nOldRecordLength - (nOffset + nOldWidth));
- }
-
- /* Convert null value to the appropriate value of the new type */
- if (bIsNULL)
- {
- memset( pszRecord + nOffset, chFieldFill, nWidth);
- }
- else
- {
- if ((chOldType == 'N' || chOldType == 'F'))
- {
- /* Add leading spaces when expanding a numeric field */
- memmove( pszRecord + nOffset + nWidth - nOldWidth,
- pszRecord + nOffset, nOldWidth );
- memset( pszRecord + nOffset, ' ', nWidth - nOldWidth );
- }
- else
- {
- /* Add trailing spaces */
- memset(pszRecord + nOffset + nOldWidth, ' ', nWidth - nOldWidth);
- }
- }
-
- nRecordOffset =
- psDBF->nRecordLength * (SAOffset) iRecord + psDBF->nHeaderLength;
-
- /* write record */
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FWrite( pszRecord, psDBF->nRecordLength, 1, psDBF->fp );
- }
-
- if( psDBF->bWriteEndOfFileChar )
- {
- char ch = END_OF_FILE_CHARACTER;
-
- nRecordOffset =
- psDBF->nRecordLength * (SAOffset) psDBF->nRecords + psDBF->nHeaderLength;
-
- psDBF->sHooks.FSeek( psDBF->fp, nRecordOffset, 0 );
- psDBF->sHooks.FWrite( &ch, 1, 1, psDBF->fp );
- }
-
- free(pszRecord);
- free(pszOldField);
- }
-
- psDBF->nCurrentRecord = -1;
- psDBF->bCurrentRecordModified = FALSE;
- psDBF->bUpdated = TRUE;
-
- return TRUE;
-}
-
-/************************************************************************/
-/* DBFSetWriteEndOfFileChar() */
-/************************************************************************/
-
-void SHPAPI_CALL DBFSetWriteEndOfFileChar( DBFHandle psDBF, int bWriteFlag )
-{
- psDBF->bWriteEndOfFileChar = bWriteFlag;
-}
diff --git a/navit/support/shapefile/shapefil.h b/navit/support/shapefile/shapefil.h
deleted file mode 100644
index 08c645996..000000000
--- a/navit/support/shapefile/shapefil.h
+++ /dev/null
@@ -1,747 +0,0 @@
-#ifndef SHAPEFILE_H_INCLUDED
-#define SHAPEFILE_H_INCLUDED
-
-/******************************************************************************
- * $Id: shapefil.h,v 1.55 2016-12-05 18:44:08 erouault Exp $
- *
- * Project: Shapelib
- * Purpose: Primary include file for Shapelib.
- * Author: Frank Warmerdam, warmerdam@pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, Frank Warmerdam
- * Copyright (c) 2012-2016, Even Rouault <even dot rouault at mines-paris dot org>
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see COPYING). This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log: shapefil.h,v $
- * Revision 1.55 2016-12-05 18:44:08 erouault
- * * dbfopen.c, shapefil.h: write DBF end-of-file character 0x1A by default.
- * This behaviour can be controlled with the DBFSetWriteEndOfFileChar()
- * function.
- *
- * Revision 1.54 2016-12-05 12:44:05 erouault
- * * Major overhaul of Makefile build system to use autoconf/automake.
- *
- * * Warning fixes in contrib/
- *
- * Revision 1.53 2016-12-04 15:30:15 erouault
- * * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with
- * GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo
- * structures extended with new members. New functions:
- * DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX,
- * SHPSetFastModeReadObject
- *
- * * sbnsearch.c: new file to implement original ESRI .sbn spatial
- * index reading. (no write support). New functions:
- * SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
- * SBNSearchDiskTreeInteger, SBNSearchFreeIds
- *
- * * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates
- * with new file and symbols.
- *
- * * commit: helper script to cvs commit
- *
- * Revision 1.52 2011-12-11 22:26:46 fwarmerdam
- * upgrade .qix access code to use SAHooks (gdal #3365)
- *
- * Revision 1.51 2011-07-24 05:59:25 fwarmerdam
- * minimize use of CPLError in favor of SAHooks.Error()
- *
- * Revision 1.50 2011-05-13 17:35:17 fwarmerdam
- * added DBFReorderFields() and DBFAlterFields() functions (from Even)
- *
- * Revision 1.49 2011-04-16 14:38:21 fwarmerdam
- * avoid warnings with gcc on SHP_CVSID
- *
- * Revision 1.48 2010-08-27 23:42:52 fwarmerdam
- * add SHPAPI_CALL attribute in code
- *
- * Revision 1.47 2010-01-28 11:34:34 fwarmerdam
- * handle the shape file length limits more gracefully (#3236)
- *
- * Revision 1.46 2008-11-12 14:28:15 fwarmerdam
- * DBFCreateField() now works on files with records
- *
- * Revision 1.45 2008/11/11 17:47:10 fwarmerdam
- * added DBFDeleteField() function
- *
- * Revision 1.44 2008/01/16 20:05:19 bram
- * Add file hooks that accept UTF-8 encoded filenames on some platforms. Use SASetupUtf8Hooks
- * tosetup the hooks and check SHPAPI_UTF8_HOOKS for its availability. Currently, this
- * is only available on the Windows platform that decodes the UTF-8 filenames to wide
- * character strings and feeds them to _wfopen and _wremove.
- *
- * Revision 1.43 2008/01/10 16:35:30 fwarmerdam
- * avoid _ prefix on #defined symbols (bug 1840)
- *
- * Revision 1.42 2007/12/18 18:28:14 bram
- * - create hook for client specific atof (bugzilla ticket 1615)
- * - check for NULL handle before closing cpCPG file, and close after reading.
- *
- * Revision 1.41 2007/12/15 20:25:32 bram
- * dbfopen.c now reads the Code Page information from the DBF file, and exports
- * this information as a string through the DBFGetCodePage function. This is
- * either the number from the LDID header field ("LDID/<number>") or as the
- * content of an accompanying .CPG file. When creating a DBF file, the code can
- * be set using DBFCreateEx.
- *
- * Revision 1.40 2007/12/06 07:00:25 fwarmerdam
- * dbfopen now using SAHooks for fileio
- *
- * Revision 1.39 2007/12/04 20:37:56 fwarmerdam
- * preliminary implementation of hooks api for io and errors
- *
- * Revision 1.38 2007/11/21 22:39:56 fwarmerdam
- * close shx file in readonly mode (GDAL #1956)
- *
- * Revision 1.37 2007/10/27 03:31:14 fwarmerdam
- * limit default depth of tree to 12 levels (gdal ticket #1594)
- *
- * Revision 1.36 2007/09/10 23:33:15 fwarmerdam
- * Upstreamed support for visibility flag in SHPAPI_CALL for the needs
- * of GDAL (gdal ticket #1810).
- *
- * Revision 1.35 2007/09/03 19:48:10 fwarmerdam
- * move DBFReadAttribute() static dDoubleField into dbfinfo
- *
- * Revision 1.34 2006/06/17 15:33:32 fwarmerdam
- * added pszWorkField - bug 1202 (rso)
- *
- * Revision 1.33 2006/02/15 01:14:30 fwarmerdam
- * added DBFAddNativeFieldType
- *
- * Revision 1.32 2006/01/26 15:07:32 fwarmerdam
- * add bMeasureIsUsed flag from Craig Bruce: Bug 1249
- *
- * Revision 1.31 2006/01/05 01:27:27 fwarmerdam
- * added dbf deletion mark/fetch
- *
- * Revision 1.30 2005/01/03 22:30:13 fwarmerdam
- * added support for saved quadtrees
- *
- * Revision 1.29 2004/09/26 20:09:35 fwarmerdam
- * avoid rcsid warnings
- *
- * Revision 1.28 2003/12/29 06:02:18 fwarmerdam
- * added cpl_error.h option
- *
- * Revision 1.27 2003/04/21 18:30:37 warmerda
- * added header write/update public methods
- *
- * Revision 1.26 2002/09/29 00:00:08 warmerda
- * added FTLogical and logical attribute read/write calls
- *
- * Revision 1.25 2002/05/07 13:46:30 warmerda
- * added DBFWriteAttributeDirectly().
- *
- * Revision 1.24 2002/04/10 16:59:54 warmerda
- * added SHPRewindObject
- *
- * Revision 1.23 2002/01/15 14:36:07 warmerda
- * updated email address
- *
- * Revision 1.22 2002/01/15 14:32:00 warmerda
- * try to improve SHPAPI_CALL docs
- */
-
-#include <stdio.h>
-
-#ifdef USE_DBMALLOC
-#include <dbmalloc.h>
-#endif
-
-#ifdef USE_CPL
-#include "cpl_conv.h"
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/************************************************************************/
-/* Configuration options. */
-/************************************************************************/
-
-/* -------------------------------------------------------------------- */
-/* Should the DBFReadStringAttribute() strip leading and */
-/* trailing white space? */
-/* -------------------------------------------------------------------- */
-#define TRIM_DBF_WHITESPACE
-
-/* -------------------------------------------------------------------- */
-/* Should we write measure values to the Multipatch object? */
-/* Reportedly ArcView crashes if we do write it, so for now it */
-/* is disabled. */
-/* -------------------------------------------------------------------- */
-#define DISABLE_MULTIPATCH_MEASURE
-
-/* -------------------------------------------------------------------- */
-/* SHPAPI_CALL */
-/* */
-/* The following two macros are present to allow forcing */
-/* various calling conventions on the Shapelib API. */
-/* */
-/* To force __stdcall conventions (needed to call Shapelib */
-/* from Visual Basic and/or Dephi I believe) the makefile could */
-/* be modified to define: */
-/* */
-/* /DSHPAPI_CALL=__stdcall */
-/* */
-/* If it is desired to force export of the Shapelib API without */
-/* using the shapelib.def file, use the following definition. */
-/* */
-/* /DSHAPELIB_DLLEXPORT */
-/* */
-/* To get both at once it will be necessary to hack this */
-/* include file to define: */
-/* */
-/* #define SHPAPI_CALL __declspec(dllexport) __stdcall */
-/* #define SHPAPI_CALL1 __declspec(dllexport) * __stdcall */
-/* */
-/* The complexity of the situation is partly caused by the */
-/* peculiar requirement of Visual C++ that __stdcall appear */
-/* after any "*"'s in the return value of a function while the */
-/* __declspec(dllexport) must appear before them. */
-/* -------------------------------------------------------------------- */
-
-#ifdef SHAPELIB_DLLEXPORT
-# define SHPAPI_CALL __declspec(dllexport)
-# define SHPAPI_CALL1(x) __declspec(dllexport) x
-#endif
-
-#ifndef SHPAPI_CALL
-# if defined(USE_GCC_VISIBILITY_FLAG)
-# define SHPAPI_CALL __attribute__ ((visibility("default")))
-# define SHPAPI_CALL1(x) __attribute__ ((visibility("default"))) x
-# else
-# define SHPAPI_CALL
-# endif
-#endif
-
-#ifndef SHPAPI_CALL1
-# define SHPAPI_CALL1(x) x SHPAPI_CALL
-#endif
-
-/* -------------------------------------------------------------------- */
-/* Macros for controlling CVSID and ensuring they don't appear */
-/* as unreferenced variables resulting in lots of warnings. */
-/* -------------------------------------------------------------------- */
-#ifndef DISABLE_CVSID
-# if defined(__GNUC__) && __GNUC__ >= 4
-# define SHP_CVSID(string) static const char cpl_cvsid[] __attribute__((used)) = string;
-# else
-# define SHP_CVSID(string) static const char cpl_cvsid[] = string; \
-static const char *cvsid_aw() { return( cvsid_aw() ? NULL : cpl_cvsid ); }
-# endif
-#else
-# define SHP_CVSID(string)
-#endif
-
-/* -------------------------------------------------------------------- */
-/* On some platforms, additional file IO hooks are defined that */
-/* UTF-8 encoded filenames Unicode filenames */
-/* -------------------------------------------------------------------- */
-#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
-# define SHPAPI_WINDOWS
-# define SHPAPI_UTF8_HOOKS
-#endif
-
-/* -------------------------------------------------------------------- */
-/* IO/Error hook functions. */
-/* -------------------------------------------------------------------- */
-typedef int *SAFile;
-
-#ifndef SAOffset
-typedef unsigned long SAOffset;
-#endif
-
-typedef struct {
- SAFile (*FOpen) ( const char *filename, const char *access);
- SAOffset (*FRead) ( void *p, SAOffset size, SAOffset nmemb, SAFile file);
- SAOffset (*FWrite)( void *p, SAOffset size, SAOffset nmemb, SAFile file);
- SAOffset (*FSeek) ( SAFile file, SAOffset offset, int whence );
- SAOffset (*FTell) ( SAFile file );
- int (*FFlush)( SAFile file );
- int (*FClose)( SAFile file );
- int (*Remove) ( const char *filename );
-
- void (*Error) ( const char *message );
- double (*Atof) ( const char *str );
-} SAHooks;
-
-void SHPAPI_CALL SASetupDefaultHooks( SAHooks *psHooks );
-#ifdef SHPAPI_UTF8_HOOKS
-void SHPAPI_CALL SASetupUtf8Hooks( SAHooks *psHooks );
-#endif
-
-/************************************************************************/
-/* SHP Support. */
-/************************************************************************/
-typedef struct tagSHPObject SHPObject;
-
-typedef struct
-{
- SAHooks sHooks;
-
- SAFile fpSHP;
- SAFile fpSHX;
-
- int nShapeType; /* SHPT_* */
-
- unsigned int nFileSize; /* SHP file */
-
- int nRecords;
- int nMaxRecords;
- unsigned int*panRecOffset;
- unsigned int *panRecSize;
-
- double adBoundsMin[4];
- double adBoundsMax[4];
-
- int bUpdated;
-
- unsigned char *pabyRec;
- int nBufSize;
-
- int bFastModeReadObject;
- unsigned char *pabyObjectBuf;
- int nObjectBufSize;
- SHPObject* psCachedObject;
-} SHPInfo;
-
-typedef SHPInfo * SHPHandle;
-
-/* -------------------------------------------------------------------- */
-/* Shape types (nSHPType) */
-/* -------------------------------------------------------------------- */
-#define SHPT_NULL 0
-#define SHPT_POINT 1
-#define SHPT_ARC 3
-#define SHPT_POLYGON 5
-#define SHPT_MULTIPOINT 8
-#define SHPT_POINTZ 11
-#define SHPT_ARCZ 13
-#define SHPT_POLYGONZ 15
-#define SHPT_MULTIPOINTZ 18
-#define SHPT_POINTM 21
-#define SHPT_ARCM 23
-#define SHPT_POLYGONM 25
-#define SHPT_MULTIPOINTM 28
-#define SHPT_MULTIPATCH 31
-
-/* -------------------------------------------------------------------- */
-/* Part types - everything but SHPT_MULTIPATCH just uses */
-/* SHPP_RING. */
-/* -------------------------------------------------------------------- */
-
-#define SHPP_TRISTRIP 0
-#define SHPP_TRIFAN 1
-#define SHPP_OUTERRING 2
-#define SHPP_INNERRING 3
-#define SHPP_FIRSTRING 4
-#define SHPP_RING 5
-
-/* -------------------------------------------------------------------- */
-/* SHPObject - represents on shape (without attributes) read */
-/* from the .shp file. */
-/* -------------------------------------------------------------------- */
-struct tagSHPObject
-{
- int nSHPType;
-
- int nShapeId; /* -1 is unknown/unassigned */
-
- int nParts;
- int *panPartStart;
- int *panPartType;
-
- int nVertices;
- double *padfX;
- double *padfY;
- double *padfZ;
- double *padfM;
-
- double dfXMin;
- double dfYMin;
- double dfZMin;
- double dfMMin;
-
- double dfXMax;
- double dfYMax;
- double dfZMax;
- double dfMMax;
-
- int bMeasureIsUsed;
- int bFastModeReadObject;
-};
-
-/* -------------------------------------------------------------------- */
-/* SHP API Prototypes */
-/* -------------------------------------------------------------------- */
-
-/* If pszAccess is read-only, the fpSHX field of the returned structure */
-/* will be NULL as it is not necessary to keep the SHX file open */
-SHPHandle SHPAPI_CALL
- SHPOpen( const char * pszShapeFile, const char * pszAccess );
-SHPHandle SHPAPI_CALL
- SHPOpenLL( const char *pszShapeFile, const char *pszAccess,
- SAHooks *psHooks );
-SHPHandle SHPAPI_CALL
- SHPOpenLLEx( const char *pszShapeFile, const char *pszAccess,
- SAHooks *psHooks, int bRestoreSHX );
-
-int SHPAPI_CALL
- SHPRestoreSHX( const char *pszShapeFile, const char *pszAccess,
- SAHooks *psHooks );
-
-/* If setting bFastMode = TRUE, the content of SHPReadObject() is owned by the SHPHandle. */
-/* So you cannot have 2 valid instances of SHPReadObject() simultaneously. */
-/* The SHPObject padfZ and padfM members may be NULL depending on the geometry */
-/* type. It is illegal to free at hand any of the pointer members of the SHPObject structure */
-void SHPAPI_CALL SHPSetFastModeReadObject( SHPHandle hSHP, int bFastMode );
-
-SHPHandle SHPAPI_CALL
- SHPCreate( const char * pszShapeFile, int nShapeType );
-SHPHandle SHPAPI_CALL
- SHPCreateLL( const char * pszShapeFile, int nShapeType,
- SAHooks *psHooks );
-void SHPAPI_CALL
- SHPGetInfo( SHPHandle hSHP, int * pnEntities, int * pnShapeType,
- double * padfMinBound, double * padfMaxBound );
-
-SHPObject SHPAPI_CALL1(*)
- SHPReadObject( SHPHandle hSHP, int iShape );
-int SHPAPI_CALL
- SHPWriteObject( SHPHandle hSHP, int iShape, SHPObject * psObject );
-
-void SHPAPI_CALL
- SHPDestroyObject( SHPObject * psObject );
-void SHPAPI_CALL
- SHPComputeExtents( SHPObject * psObject );
-SHPObject SHPAPI_CALL1(*)
- SHPCreateObject( int nSHPType, int nShapeId, int nParts,
- const int * panPartStart, const int * panPartType,
- int nVertices,
- const double * padfX, const double * padfY,
- const double * padfZ, const double * padfM );
-SHPObject SHPAPI_CALL1(*)
- SHPCreateSimpleObject( int nSHPType, int nVertices,
- const double * padfX,
- const double * padfY,
- const double * padfZ );
-
-int SHPAPI_CALL
- SHPRewindObject( SHPHandle hSHP, SHPObject * psObject );
-
-void SHPAPI_CALL SHPClose( SHPHandle hSHP );
-void SHPAPI_CALL SHPWriteHeader( SHPHandle hSHP );
-
-const char SHPAPI_CALL1(*)
- SHPTypeName( int nSHPType );
-const char SHPAPI_CALL1(*)
- SHPPartTypeName( int nPartType );
-
-/* -------------------------------------------------------------------- */
-/* Shape quadtree indexing API. */
-/* -------------------------------------------------------------------- */
-
-/* this can be two or four for binary or quad tree */
-#define MAX_SUBNODE 4
-
-/* upper limit of tree levels for automatic estimation */
-#define MAX_DEFAULT_TREE_DEPTH 12
-
-typedef struct shape_tree_node
-{
- /* region covered by this node */
- double adfBoundsMin[4];
- double adfBoundsMax[4];
-
- /* list of shapes stored at this node. The papsShapeObj pointers
- or the whole list can be NULL */
- int nShapeCount;
- int *panShapeIds;
- SHPObject **papsShapeObj;
-
- int nSubNodes;
- struct shape_tree_node *apsSubNode[MAX_SUBNODE];
-
-} SHPTreeNode;
-
-typedef struct
-{
- SHPHandle hSHP;
-
- int nMaxDepth;
- int nDimension;
- int nTotalCount;
-
- SHPTreeNode *psRoot;
-} SHPTree;
-
-SHPTree SHPAPI_CALL1(*)
- SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth,
- double *padfBoundsMin, double *padfBoundsMax );
-void SHPAPI_CALL
- SHPDestroyTree( SHPTree * hTree );
-
-int SHPAPI_CALL
- SHPWriteTree( SHPTree *hTree, const char * pszFilename );
-
-int SHPAPI_CALL
- SHPTreeAddShapeId( SHPTree * hTree, SHPObject * psObject );
-int SHPAPI_CALL
- SHPTreeRemoveShapeId( SHPTree * hTree, int nShapeId );
-
-void SHPAPI_CALL
- SHPTreeTrimExtraNodes( SHPTree * hTree );
-
-int SHPAPI_CALL1(*)
- SHPTreeFindLikelyShapes( SHPTree * hTree,
- double * padfBoundsMin,
- double * padfBoundsMax,
- int * );
-int SHPAPI_CALL
- SHPCheckBoundsOverlap( double *, double *, double *, double *, int );
-
-int SHPAPI_CALL1(*)
-SHPSearchDiskTree( FILE *fp,
- double *padfBoundsMin, double *padfBoundsMax,
- int *pnShapeCount );
-
-typedef struct SHPDiskTreeInfo* SHPTreeDiskHandle;
-
-SHPTreeDiskHandle SHPAPI_CALL
- SHPOpenDiskTree( const char* pszQIXFilename,
- SAHooks *psHooks );
-
-void SHPAPI_CALL
- SHPCloseDiskTree( SHPTreeDiskHandle hDiskTree );
-
-int SHPAPI_CALL1(*)
-SHPSearchDiskTreeEx( SHPTreeDiskHandle hDiskTree,
- double *padfBoundsMin, double *padfBoundsMax,
- int *pnShapeCount );
-
-int SHPAPI_CALL
- SHPWriteTreeLL(SHPTree *hTree, const char *pszFilename, SAHooks *psHooks );
-
-/* -------------------------------------------------------------------- */
-/* SBN Search API */
-/* -------------------------------------------------------------------- */
-
-typedef struct SBNSearchInfo* SBNSearchHandle;
-
-SBNSearchHandle SHPAPI_CALL
- SBNOpenDiskTree( const char* pszSBNFilename,
- SAHooks *psHooks );
-
-void SHPAPI_CALL
- SBNCloseDiskTree( SBNSearchHandle hSBN );
-
-int SHPAPI_CALL1(*)
-SBNSearchDiskTree( SBNSearchHandle hSBN,
- double *padfBoundsMin, double *padfBoundsMax,
- int *pnShapeCount );
-
-int SHPAPI_CALL1(*)
-SBNSearchDiskTreeInteger( SBNSearchHandle hSBN,
- int bMinX, int bMinY, int bMaxX, int bMaxY,
- int *pnShapeCount );
-
-void SHPAPI_CALL SBNSearchFreeIds( int* panShapeId );
-
-/************************************************************************/
-/* DBF Support. */
-/************************************************************************/
-typedef struct
-{
- SAHooks sHooks;
-
- SAFile fp;
-
- int nRecords;
-
- int nRecordLength; /* Must fit on uint16 */
- int nHeaderLength; /* File header length (32) + field
- descriptor length + spare space.
- Must fit on uint16 */
- int nFields;
- int *panFieldOffset;
- int *panFieldSize;
- int *panFieldDecimals;
- char *pachFieldType;
-
- char *pszHeader; /* Field descriptors */
-
- int nCurrentRecord;
- int bCurrentRecordModified;
- char *pszCurrentRecord;
-
- int nWorkFieldLength;
- char *pszWorkField;
-
- int bNoHeader;
- int bUpdated;
-
- union
- {
- double dfDoubleField;
- int nIntField;
- } fieldValue;
-
- int iLanguageDriver;
- char *pszCodePage;
-
- int nUpdateYearSince1900; /* 0-255 */
- int nUpdateMonth; /* 1-12 */
- int nUpdateDay; /* 1-31 */
-
- int bWriteEndOfFileChar; /* defaults to TRUE */
-} DBFInfo;
-
-typedef DBFInfo * DBFHandle;
-
-typedef enum {
- FTString,
- FTInteger,
- FTDouble,
- FTLogical,
- FTInvalid
-} DBFFieldType;
-
-/* Field descriptor/header size */
-#define XBASE_FLDHDR_SZ 32
-/* Shapelib read up to 11 characters, even if only 10 should normally be used */
-#define XBASE_FLDNAME_LEN_READ 11
-/* On writing, we limit to 10 characters */
-#define XBASE_FLDNAME_LEN_WRITE 10
-/* Normally only 254 characters should be used. We tolerate 255 historically */
-#define XBASE_FLD_MAX_WIDTH 255
-
-DBFHandle SHPAPI_CALL
- DBFOpen( const char * pszDBFFile, const char * pszAccess );
-DBFHandle SHPAPI_CALL
- DBFOpenLL( const char * pszDBFFile, const char * pszAccess,
- SAHooks *psHooks );
-DBFHandle SHPAPI_CALL
- DBFCreate( const char * pszDBFFile );
-DBFHandle SHPAPI_CALL
- DBFCreateEx( const char * pszDBFFile, const char * pszCodePage );
-DBFHandle SHPAPI_CALL
- DBFCreateLL( const char * pszDBFFile, const char * pszCodePage, SAHooks *psHooks );
-
-int SHPAPI_CALL
- DBFGetFieldCount( DBFHandle psDBF );
-int SHPAPI_CALL
- DBFGetRecordCount( DBFHandle psDBF );
-int SHPAPI_CALL
- DBFAddField( DBFHandle hDBF, const char * pszFieldName,
- DBFFieldType eType, int nWidth, int nDecimals );
-
-int SHPAPI_CALL
- DBFAddNativeFieldType( DBFHandle hDBF, const char * pszFieldName,
- char chType, int nWidth, int nDecimals );
-
-int SHPAPI_CALL
- DBFDeleteField( DBFHandle hDBF, int iField );
-
-int SHPAPI_CALL
- DBFReorderFields( DBFHandle psDBF, int* panMap );
-
-int SHPAPI_CALL
- DBFAlterFieldDefn( DBFHandle psDBF, int iField, const char * pszFieldName,
- char chType, int nWidth, int nDecimals );
-
-DBFFieldType SHPAPI_CALL
- DBFGetFieldInfo( DBFHandle psDBF, int iField,
- char * pszFieldName, int * pnWidth, int * pnDecimals );
-
-int SHPAPI_CALL
- DBFGetFieldIndex(DBFHandle psDBF, const char *pszFieldName);
-
-int SHPAPI_CALL
- DBFReadIntegerAttribute( DBFHandle hDBF, int iShape, int iField );
-double SHPAPI_CALL
- DBFReadDoubleAttribute( DBFHandle hDBF, int iShape, int iField );
-const char SHPAPI_CALL1(*)
- DBFReadStringAttribute( DBFHandle hDBF, int iShape, int iField );
-const char SHPAPI_CALL1(*)
- DBFReadLogicalAttribute( DBFHandle hDBF, int iShape, int iField );
-int SHPAPI_CALL
- DBFIsAttributeNULL( DBFHandle hDBF, int iShape, int iField );
-
-int SHPAPI_CALL
- DBFWriteIntegerAttribute( DBFHandle hDBF, int iShape, int iField,
- int nFieldValue );
-int SHPAPI_CALL
- DBFWriteDoubleAttribute( DBFHandle hDBF, int iShape, int iField,
- double dFieldValue );
-int SHPAPI_CALL
- DBFWriteStringAttribute( DBFHandle hDBF, int iShape, int iField,
- const char * pszFieldValue );
-int SHPAPI_CALL
- DBFWriteNULLAttribute( DBFHandle hDBF, int iShape, int iField );
-
-int SHPAPI_CALL
- DBFWriteLogicalAttribute( DBFHandle hDBF, int iShape, int iField,
- const char lFieldValue);
-int SHPAPI_CALL
- DBFWriteAttributeDirectly(DBFHandle psDBF, int hEntity, int iField,
- void * pValue );
-const char SHPAPI_CALL1(*)
- DBFReadTuple(DBFHandle psDBF, int hEntity );
-int SHPAPI_CALL
- DBFWriteTuple(DBFHandle psDBF, int hEntity, void * pRawTuple );
-
-int SHPAPI_CALL DBFIsRecordDeleted( DBFHandle psDBF, int iShape );
-int SHPAPI_CALL DBFMarkRecordDeleted( DBFHandle psDBF, int iShape,
- int bIsDeleted );
-
-DBFHandle SHPAPI_CALL
- DBFCloneEmpty(DBFHandle psDBF, const char * pszFilename );
-
-void SHPAPI_CALL
- DBFClose( DBFHandle hDBF );
-void SHPAPI_CALL
- DBFUpdateHeader( DBFHandle hDBF );
-char SHPAPI_CALL
- DBFGetNativeFieldType( DBFHandle hDBF, int iField );
-
-const char SHPAPI_CALL1(*)
- DBFGetCodePage(DBFHandle psDBF );
-
-void SHPAPI_CALL
- DBFSetLastModifiedDate( DBFHandle psDBF, int nYYSince1900, int nMM, int nDD );
-
-void SHPAPI_CALL DBFSetWriteEndOfFileChar( DBFHandle psDBF, int bWriteFlag );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ndef SHAPEFILE_H_INCLUDED */
diff --git a/navit/support/shapefile/shpopen.c b/navit/support/shapefile/shpopen.c
deleted file mode 100644
index 2ace6843b..000000000
--- a/navit/support/shapefile/shpopen.c
+++ /dev/null
@@ -1,3030 +0,0 @@
-/******************************************************************************
- * $Id: shpopen.c,v 1.75 2016-12-05 12:44:05 erouault Exp $
- *
- * Project: Shapelib
- * Purpose: Implementation of core Shapefile read/write functions.
- * Author: Frank Warmerdam, warmerdam@pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, 2001, Frank Warmerdam
- * Copyright (c) 2011-2013, Even Rouault <even dot rouault at mines-paris dot org>
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see COPYING). This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log: shpopen.c,v $
- * Revision 1.75 2016-12-05 12:44:05 erouault
- * * Major overhaul of Makefile build system to use autoconf/automake.
- *
- * * Warning fixes in contrib/
- *
- * Revision 1.74 2016-12-04 15:30:15 erouault
- * * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with
- * GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo
- * structures extended with new members. New functions:
- * DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX,
- * SHPSetFastModeReadObject
- *
- * * sbnsearch.c: new file to implement original ESRI .sbn spatial
- * index reading. (no write support). New functions:
- * SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
- * SBNSearchDiskTreeInteger, SBNSearchFreeIds
- *
- * * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates
- * with new file and symbols.
- *
- * * commit: helper script to cvs commit
- *
- * Revision 1.73 2012-01-24 22:33:01 fwarmerdam
- * fix memory leak on failure to open .shp (gdal #4410)
- *
- * Revision 1.72 2011-12-11 22:45:28 fwarmerdam
- * fix failure return from SHPOpenLL.
- *
- * Revision 1.71 2011-09-15 03:33:58 fwarmerdam
- * fix missing cast (#2344)
- *
- * Revision 1.70 2011-07-24 05:59:25 fwarmerdam
- * minimize use of CPLError in favor of SAHooks.Error()
- *
- * Revision 1.69 2011-07-24 03:24:22 fwarmerdam
- * fix memory leaks in error cases creating shapefiles (#2061)
- *
- * Revision 1.68 2010-08-27 23:42:52 fwarmerdam
- * add SHPAPI_CALL attribute in code
- *
- * Revision 1.67 2010-07-01 08:15:48 fwarmerdam
- * do not error out on an object with zero vertices
- *
- * Revision 1.66 2010-07-01 07:58:57 fwarmerdam
- * minor cleanup of error handling
- *
- * Revision 1.65 2010-07-01 07:27:13 fwarmerdam
- * white space formatting adjustments
- *
- * Revision 1.64 2010-01-28 11:34:34 fwarmerdam
- * handle the shape file length limits more gracefully (#3236)
- *
- * Revision 1.63 2010-01-28 04:04:40 fwarmerdam
- * improve numerical accuracy of SHPRewind() algs (gdal #3363)
- *
- * Revision 1.62 2010-01-17 05:34:13 fwarmerdam
- * Remove asserts on x/y being null (#2148).
- *
- * Revision 1.61 2010-01-16 05:07:42 fwarmerdam
- * allow 0/nulls in shpcreateobject (#2148)
- *
- * Revision 1.60 2009-09-17 20:50:02 bram
- * on Win32, define snprintf as alias to _snprintf
- *
- * Revision 1.59 2008-03-14 05:25:31 fwarmerdam
- * Correct crash on buggy geometries (gdal #2218)
- *
- * Revision 1.58 2008/01/08 23:28:26 bram
- * on line 2095, use a float instead of a double to avoid a compiler warning
- *
- * Revision 1.57 2007/12/06 07:00:25 fwarmerdam
- * dbfopen now using SAHooks for fileio
- *
- * Revision 1.56 2007/12/04 20:37:56 fwarmerdam
- * preliminary implementation of hooks api for io and errors
- *
- * Revision 1.55 2007/11/21 22:39:56 fwarmerdam
- * close shx file in readonly mode (GDAL #1956)
- *
- * Revision 1.54 2007/11/15 00:12:47 mloskot
- * Backported recent changes from GDAL (Ticket #1415) to Shapelib.
- *
- * Revision 1.53 2007/11/14 22:31:08 fwarmerdam
- * checks after mallocs to detect for corrupted/voluntary broken shapefiles.
- * http://trac.osgeo.org/gdal/ticket/1991
- *
- * Revision 1.52 2007/06/21 15:58:33 fwarmerdam
- * fix for SHPRewindObject when rings touch at one vertex (gdal #976)
- *
- * Revision 1.51 2006/09/04 15:24:01 fwarmerdam
- * Fixed up log message for 1.49.
- *
- * Revision 1.50 2006/09/04 15:21:39 fwarmerdam
- * fix of last fix
- *
- * Revision 1.49 2006/09/04 15:21:00 fwarmerdam
- * MLoskot: Added stronger test of Shapefile reading failures, e.g. truncated
- * files. The problem was discovered by Tim Sutton and reported here
- * https://svn.qgis.org/trac/ticket/200
- *
- * Revision 1.48 2006/01/26 15:07:32 fwarmerdam
- * add bMeasureIsUsed flag from Craig Bruce: Bug 1249
- *
- * Revision 1.47 2006/01/04 20:07:23 fwarmerdam
- * In SHPWriteObject() make sure that the record length is updated
- * when rewriting an existing record.
- *
- * Revision 1.46 2005/02/11 17:17:46 fwarmerdam
- * added panPartStart[0] validation
- *
- * Revision 1.45 2004/09/26 20:09:48 fwarmerdam
- * const correctness changes
- *
- * Revision 1.44 2003/12/29 00:18:39 fwarmerdam
- * added error checking for failed IO and optional CPL error reporting
- *
- * Revision 1.43 2003/12/01 16:20:08 warmerda
- * be careful of zero vertex shapes
- *
- * Revision 1.42 2003/12/01 14:58:27 warmerda
- * added degenerate object check in SHPRewindObject()
- *
- * Revision 1.41 2003/07/08 15:22:43 warmerda
- * avoid warning
- *
- * Revision 1.40 2003/04/21 18:30:37 warmerda
- * added header write/update public methods
- *
- * Revision 1.39 2002/08/26 06:46:56 warmerda
- * avoid c++ comments
- *
- * Revision 1.38 2002/05/07 16:43:39 warmerda
- * Removed debugging printf.
- *
- * Revision 1.37 2002/04/10 17:35:22 warmerda
- * fixed bug in ring reversal code
- *
- * Revision 1.36 2002/04/10 16:59:54 warmerda
- * added SHPRewindObject
- *
- * Revision 1.35 2001/12/07 15:10:44 warmerda
- * fix if .shx fails to open
- *
- * Revision 1.34 2001/11/01 16:29:55 warmerda
- * move pabyRec into SHPInfo for thread safety
- *
- * Revision 1.33 2001/07/03 12:18:15 warmerda
- * Improved cleanup if SHX not found, provided by Riccardo Cohen.
- *
- * Revision 1.32 2001/06/22 01:58:07 warmerda
- * be more careful about establishing initial bounds in face of NULL shapes
- *
- * Revision 1.31 2001/05/31 19:35:29 warmerda
- * added support for writing null shapes
- *
- * Revision 1.30 2001/05/28 12:46:29 warmerda
- * Add some checking on reasonableness of record count when opening.
- *
- * Revision 1.29 2001/05/23 13:36:52 warmerda
- * added use of SHPAPI_CALL
- *
- * Revision 1.28 2001/02/06 22:25:06 warmerda
- * fixed memory leaks when SHPOpen() fails
- *
- * Revision 1.27 2000/07/18 15:21:33 warmerda
- * added better enforcement of -1 for append in SHPWriteObject
- *
- * Revision 1.26 2000/02/16 16:03:51 warmerda
- * added null shape support
- *
- * Revision 1.25 1999/12/15 13:47:07 warmerda
- * Fixed record size settings in .shp file (was 4 words too long)
- * Added stdlib.h.
- *
- * Revision 1.24 1999/11/05 14:12:04 warmerda
- * updated license terms
- *
- * Revision 1.23 1999/07/27 00:53:46 warmerda
- * added support for rewriting shapes
- *
- * Revision 1.22 1999/06/11 19:19:11 warmerda
- * Cleanup pabyRec static buffer on SHPClose().
- *
- * Revision 1.21 1999/06/02 14:57:56 kshih
- * Remove unused variables
- *
- * Revision 1.20 1999/04/19 21:04:17 warmerda
- * Fixed syntax error.
- *
- * Revision 1.19 1999/04/19 21:01:57 warmerda
- * Force access string to binary in SHPOpen().
- *
- * Revision 1.18 1999/04/01 18:48:07 warmerda
- * Try upper case extensions if lower case doesn't work.
- *
- * Revision 1.17 1998/12/31 15:29:39 warmerda
- * Disable writing measure values to multipatch objects if
- * DISABLE_MULTIPATCH_MEASURE is defined.
- *
- * Revision 1.16 1998/12/16 05:14:33 warmerda
- * Added support to write MULTIPATCH. Fixed reading Z coordinate of
- * MULTIPATCH. Fixed record size written for all feature types.
- *
- * Revision 1.15 1998/12/03 16:35:29 warmerda
- * r+b is proper binary access string, not rb+.
- *
- * Revision 1.14 1998/12/03 15:47:56 warmerda
- * Fixed setting of nVertices in SHPCreateObject().
- *
- * Revision 1.13 1998/12/03 15:33:54 warmerda
- * Made SHPCalculateExtents() separately callable.
- *
- * Revision 1.12 1998/11/11 20:01:50 warmerda
- * Fixed bug writing ArcM/Z, and PolygonM/Z for big endian machines.
- *
- * Revision 1.11 1998/11/09 20:56:44 warmerda
- * Fixed up handling of file wide bounds.
- *
- * Revision 1.10 1998/11/09 20:18:51 warmerda
- * Converted to support 3D shapefiles, and use of SHPObject.
- *
- * Revision 1.9 1998/02/24 15:09:05 warmerda
- * Fixed memory leak.
- *
- * Revision 1.8 1997/12/04 15:40:29 warmerda
- * Fixed byte swapping of record number, and record length fields in the
- * .shp file.
- *
- * Revision 1.7 1995/10/21 03:15:58 warmerda
- * Added support for binary file access, the magic cookie 9997
- * and tried to improve the int32 selection logic for 16bit systems.
- *
- * Revision 1.6 1995/09/04 04:19:41 warmerda
- * Added fix for file bounds.
- *
- * Revision 1.5 1995/08/25 15:16:44 warmerda
- * Fixed a couple of problems with big endian systems ... one with bounds
- * and the other with multipart polygons.
- *
- * Revision 1.4 1995/08/24 18:10:17 warmerda
- * Switch to use SfRealloc() to avoid problems with pre-ANSI realloc()
- * functions (such as on the Sun).
- *
- * Revision 1.3 1995/08/23 02:23:15 warmerda
- * Added support for reading bounds, and fixed up problems in setting the
- * file wide bounds.
- *
- * Revision 1.2 1995/08/04 03:16:57 warmerda
- * Added header.
- *
- */
-
-#include "shapefil.h"
-
-#include <math.h>
-#include <limits.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-#include <errno.h>
-
-SHP_CVSID("$Id: shpopen.c,v 1.75 2016-12-05 12:44:05 erouault Exp $")
-
-typedef unsigned char uchar;
-
-#if UINT_MAX == 65535
-typedef unsigned long int32;
-#else
-typedef unsigned int int32;
-#endif
-
-#ifndef FALSE
-# define FALSE 0
-# define TRUE 1
-#endif
-
-#define ByteCopy( a, b, c ) memcpy( b, a, c )
-#ifndef MAX
-# define MIN(a,b) ((a<b) ? a : b)
-# define MAX(a,b) ((a>b) ? a : b)
-#endif
-
-#ifndef USE_CPL
-#if defined(_MSC_VER)
-# if _MSC_VER < 1900
-# define snprintf _snprintf
-# endif
-#elif defined(WIN32) || defined(_WIN32)
-# ifndef snprintf
-# define snprintf _snprintf
-# endif
-#endif
-#endif
-
-#ifndef CPL_UNUSED
-#if defined(__GNUC__) && __GNUC__ >= 4
-# define CPL_UNUSED __attribute((__unused__))
-#else
-# define CPL_UNUSED
-#endif
-#endif
-
-#if defined(CPL_LSB)
-#define bBigEndian FALSE
-#elif defined(CPL_MSB)
-#define bBigEndian TRUE
-#else
-static int bBigEndian;
-#endif
-
-/************************************************************************/
-/* SwapWord() */
-/* */
-/* Swap a 2, 4 or 8 byte word. */
-/************************************************************************/
-
-static void SwapWord( int length, void * wordP )
-
-{
- int i;
- uchar temp;
-
- for( i=0; i < length/2; i++ )
- {
- temp = ((uchar *) wordP)[i];
- ((uchar *)wordP)[i] = ((uchar *) wordP)[length-i-1];
- ((uchar *) wordP)[length-i-1] = temp;
- }
-}
-
-/************************************************************************/
-/* SfRealloc() */
-/* */
-/* A realloc cover function that will access a NULL pointer as */
-/* a valid input. */
-/************************************************************************/
-
-static void * SfRealloc( void * pMem, int nNewSize )
-
-{
- if( pMem == NULL )
- return( (void *) malloc(nNewSize) );
- else
- return( (void *) realloc(pMem,nNewSize) );
-}
-
-/************************************************************************/
-/* SHPWriteHeader() */
-/* */
-/* Write out a header for the .shp and .shx files as well as the */
-/* contents of the index (.shx) file. */
-/************************************************************************/
-
-void SHPAPI_CALL SHPWriteHeader( SHPHandle psSHP )
-
-{
- uchar abyHeader[100] = { 0 };
- int i;
- int32 i32;
- double dValue;
- int32 *panSHX;
-
- if (psSHP->fpSHX == NULL)
- {
- psSHP->sHooks.Error( "SHPWriteHeader failed : SHX file is closed");
- return;
- }
-
-/* -------------------------------------------------------------------- */
-/* Prepare header block for .shp file. */
-/* -------------------------------------------------------------------- */
-
- abyHeader[2] = 0x27; /* magic cookie */
- abyHeader[3] = 0x0a;
-
- i32 = psSHP->nFileSize/2; /* file size */
- ByteCopy( &i32, abyHeader+24, 4 );
- if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
-
- i32 = 1000; /* version */
- ByteCopy( &i32, abyHeader+28, 4 );
- if( bBigEndian ) SwapWord( 4, abyHeader+28 );
-
- i32 = psSHP->nShapeType; /* shape type */
- ByteCopy( &i32, abyHeader+32, 4 );
- if( bBigEndian ) SwapWord( 4, abyHeader+32 );
-
- dValue = psSHP->adBoundsMin[0]; /* set bounds */
- ByteCopy( &dValue, abyHeader+36, 8 );
- if( bBigEndian ) SwapWord( 8, abyHeader+36 );
-
- dValue = psSHP->adBoundsMin[1];
- ByteCopy( &dValue, abyHeader+44, 8 );
- if( bBigEndian ) SwapWord( 8, abyHeader+44 );
-
- dValue = psSHP->adBoundsMax[0];
- ByteCopy( &dValue, abyHeader+52, 8 );
- if( bBigEndian ) SwapWord( 8, abyHeader+52 );
-
- dValue = psSHP->adBoundsMax[1];
- ByteCopy( &dValue, abyHeader+60, 8 );
- if( bBigEndian ) SwapWord( 8, abyHeader+60 );
-
- dValue = psSHP->adBoundsMin[2]; /* z */
- ByteCopy( &dValue, abyHeader+68, 8 );
- if( bBigEndian ) SwapWord( 8, abyHeader+68 );
-
- dValue = psSHP->adBoundsMax[2];
- ByteCopy( &dValue, abyHeader+76, 8 );
- if( bBigEndian ) SwapWord( 8, abyHeader+76 );
-
- dValue = psSHP->adBoundsMin[3]; /* m */
- ByteCopy( &dValue, abyHeader+84, 8 );
- if( bBigEndian ) SwapWord( 8, abyHeader+84 );
-
- dValue = psSHP->adBoundsMax[3];
- ByteCopy( &dValue, abyHeader+92, 8 );
- if( bBigEndian ) SwapWord( 8, abyHeader+92 );
-
-/* -------------------------------------------------------------------- */
-/* Write .shp file header. */
-/* -------------------------------------------------------------------- */
- if( psSHP->sHooks.FSeek( psSHP->fpSHP, 0, 0 ) != 0
- || psSHP->sHooks.FWrite( abyHeader, 100, 1, psSHP->fpSHP ) != 1 )
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Failure writing .shp header: %s", strerror(errno) );
- psSHP->sHooks.Error( szError );
- return;
- }
-
-/* -------------------------------------------------------------------- */
-/* Prepare, and write .shx file header. */
-/* -------------------------------------------------------------------- */
- i32 = (psSHP->nRecords * 2 * sizeof(int32) + 100)/2; /* file size */
- ByteCopy( &i32, abyHeader+24, 4 );
- if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
-
- if( psSHP->sHooks.FSeek( psSHP->fpSHX, 0, 0 ) != 0
- || psSHP->sHooks.FWrite( abyHeader, 100, 1, psSHP->fpSHX ) != 1 )
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Failure writing .shx header: %s", strerror(errno) );
- psSHP->sHooks.Error( szError );
-
- return;
- }
-
-/* -------------------------------------------------------------------- */
-/* Write out the .shx contents. */
-/* -------------------------------------------------------------------- */
- panSHX = (int32 *) malloc(sizeof(int32) * 2 * psSHP->nRecords);
- if( panSHX == NULL )
- {
- psSHP->sHooks.Error( "Failure allocatin panSHX" );
- return;
- }
-
- for( i = 0; i < psSHP->nRecords; i++ )
- {
- panSHX[i*2 ] = psSHP->panRecOffset[i]/2;
- panSHX[i*2+1] = psSHP->panRecSize[i]/2;
- if( !bBigEndian ) SwapWord( 4, panSHX+i*2 );
- if( !bBigEndian ) SwapWord( 4, panSHX+i*2+1 );
- }
-
- if( (int)psSHP->sHooks.FWrite( panSHX, sizeof(int32)*2, psSHP->nRecords, psSHP->fpSHX )
- != psSHP->nRecords )
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Failure writing .shx contents: %s", strerror(errno) );
- psSHP->sHooks.Error( szError );
- }
-
- free( panSHX );
-
-/* -------------------------------------------------------------------- */
-/* Flush to disk. */
-/* -------------------------------------------------------------------- */
- psSHP->sHooks.FFlush( psSHP->fpSHP );
- psSHP->sHooks.FFlush( psSHP->fpSHX );
-}
-
-/************************************************************************/
-/* SHPOpen() */
-/************************************************************************/
-
-SHPHandle SHPAPI_CALL
-SHPOpen( const char * pszLayer, const char * pszAccess )
-
-{
- SAHooks sHooks;
-
- SASetupDefaultHooks( &sHooks );
-
- return SHPOpenLL( pszLayer, pszAccess, &sHooks );
-}
-
-/************************************************************************/
-/* SHPOpen() */
-/* */
-/* Open the .shp and .shx files based on the basename of the */
-/* files or either file name. */
-/************************************************************************/
-
-SHPHandle SHPAPI_CALL
-SHPOpenLL( const char * pszLayer, const char * pszAccess, SAHooks *psHooks )
-
-{
- char *pszFullname, *pszBasename;
- SHPHandle psSHP;
-
- uchar *pabyBuf;
- int i;
- double dValue;
- int bLazySHXLoading = FALSE;
- size_t nFullnameLen;
-
-/* -------------------------------------------------------------------- */
-/* Ensure the access string is one of the legal ones. We */
-/* ensure the result string indicates binary to avoid common */
-/* problems on Windows. */
-/* -------------------------------------------------------------------- */
- if( strcmp(pszAccess,"rb+") == 0 || strcmp(pszAccess,"r+b") == 0
- || strcmp(pszAccess,"r+") == 0 )
- pszAccess = "r+b";
- else
- {
- bLazySHXLoading = strchr(pszAccess, 'l') != NULL;
- pszAccess = "rb";
- }
-
-/* -------------------------------------------------------------------- */
-/* Establish the byte order on this machine. */
-/* -------------------------------------------------------------------- */
-#if !defined(bBigEndian)
- i = 1;
- if( *((uchar *) &i) == 1 )
- bBigEndian = FALSE;
- else
- bBigEndian = TRUE;
-#endif
-
-/* -------------------------------------------------------------------- */
-/* Initialize the info structure. */
-/* -------------------------------------------------------------------- */
- psSHP = (SHPHandle) calloc(sizeof(SHPInfo),1);
-
- psSHP->bUpdated = FALSE;
- memcpy( &(psSHP->sHooks), psHooks, sizeof(SAHooks) );
-
-/* -------------------------------------------------------------------- */
-/* Compute the base (layer) name. If there is any extension */
-/* on the passed in filename we will strip it off. */
-/* -------------------------------------------------------------------- */
- pszBasename = (char *) malloc(strlen(pszLayer)+5);
- strcpy( pszBasename, pszLayer );
- for( i = (int)strlen(pszBasename)-1;
- i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
- && pszBasename[i] != '\\';
- i-- ) {}
-
- if( pszBasename[i] == '.' )
- pszBasename[i] = '\0';
-
-/* -------------------------------------------------------------------- */
-/* Open the .shp and .shx files. Note that files pulled from */
-/* a PC to Unix with upper case filenames won't work! */
-/* -------------------------------------------------------------------- */
- nFullnameLen = strlen(pszBasename) + 5;
- pszFullname = (char *) malloc(nFullnameLen);
- snprintf( pszFullname, nFullnameLen, "%s.shp", pszBasename ) ;
- psSHP->fpSHP = psSHP->sHooks.FOpen(pszFullname, pszAccess );
- if( psSHP->fpSHP == NULL )
- {
- snprintf( pszFullname, nFullnameLen, "%s.SHP", pszBasename );
- psSHP->fpSHP = psSHP->sHooks.FOpen(pszFullname, pszAccess );
- }
-
- if( psSHP->fpSHP == NULL )
- {
- size_t nMessageLen = strlen(pszBasename)*2+256;
- char *pszMessage = (char *) malloc(nMessageLen);
- snprintf( pszMessage, nMessageLen, "Unable to open %s.shp or %s.SHP.",
- pszBasename, pszBasename );
- psHooks->Error( pszMessage );
- free( pszMessage );
-
- free( psSHP );
- free( pszBasename );
- free( pszFullname );
-
- return NULL;
- }
-
- snprintf( pszFullname, nFullnameLen, "%s.shx", pszBasename );
- psSHP->fpSHX = psSHP->sHooks.FOpen(pszFullname, pszAccess );
- if( psSHP->fpSHX == NULL )
- {
- snprintf( pszFullname, nFullnameLen, "%s.SHX", pszBasename );
- psSHP->fpSHX = psSHP->sHooks.FOpen(pszFullname, pszAccess );
- }
-
- if( psSHP->fpSHX == NULL )
- {
- size_t nMessageLen = strlen(pszBasename)*2+256;
- char *pszMessage = (char *) malloc(nMessageLen);
- snprintf( pszMessage, nMessageLen, "Unable to open %s.shx or %s.SHX."
- "Try --config SHAPE_RESTORE_SHX true to restore or create it",
- pszBasename, pszBasename );
- psHooks->Error( pszMessage );
- free( pszMessage );
-
- psSHP->sHooks.FClose( psSHP->fpSHP );
- free( psSHP );
- free( pszBasename );
- free( pszFullname );
- return( NULL );
- }
-
- free( pszFullname );
- free( pszBasename );
-
-/* -------------------------------------------------------------------- */
-/* Read the file size from the SHP file. */
-/* -------------------------------------------------------------------- */
- pabyBuf = (uchar *) malloc(100);
- psSHP->sHooks.FRead( pabyBuf, 100, 1, psSHP->fpSHP );
-
- psSHP->nFileSize = ((unsigned int)pabyBuf[24] * 256 * 256 * 256
- + (unsigned int)pabyBuf[25] * 256 * 256
- + (unsigned int)pabyBuf[26] * 256
- + (unsigned int)pabyBuf[27]);
- if( psSHP->nFileSize < 0xFFFFFFFFU / 2 )
- psSHP->nFileSize *= 2;
- else
- psSHP->nFileSize = 0xFFFFFFFEU;
-
-/* -------------------------------------------------------------------- */
-/* Read SHX file Header info */
-/* -------------------------------------------------------------------- */
- if( psSHP->sHooks.FRead( pabyBuf, 100, 1, psSHP->fpSHX ) != 1
- || pabyBuf[0] != 0
- || pabyBuf[1] != 0
- || pabyBuf[2] != 0x27
- || (pabyBuf[3] != 0x0a && pabyBuf[3] != 0x0d) )
- {
- psSHP->sHooks.Error( ".shx file is unreadable, or corrupt." );
- psSHP->sHooks.FClose( psSHP->fpSHP );
- psSHP->sHooks.FClose( psSHP->fpSHX );
- free( psSHP );
-
- return( NULL );
- }
-
- psSHP->nRecords = pabyBuf[27] + pabyBuf[26] * 256
- + pabyBuf[25] * 256 * 256 + (pabyBuf[24] & 0x7F) * 256 * 256 * 256;
- psSHP->nRecords = (psSHP->nRecords - 50) / 4;
-
- psSHP->nShapeType = pabyBuf[32];
-
- if( psSHP->nRecords < 0 || psSHP->nRecords > 256000000 )
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Record count in .shp header is %d, which seems\n"
- "unreasonable. Assuming header is corrupt.",
- psSHP->nRecords );
- psSHP->sHooks.Error( szError );
- psSHP->sHooks.FClose( psSHP->fpSHP );
- psSHP->sHooks.FClose( psSHP->fpSHX );
- free( psSHP );
- free(pabyBuf);
-
- return( NULL );
- }
-
- /* If a lot of records are advertized, check that the file is big enough */
- /* to hold them */
- if( psSHP->nRecords >= 1024 * 1024 )
- {
- SAOffset nFileSize;
- psSHP->sHooks.FSeek( psSHP->fpSHX, 0, 2 );
- nFileSize = psSHP->sHooks.FTell( psSHP->fpSHX );
- if( nFileSize > 100 &&
- nFileSize/2 < (SAOffset)(psSHP->nRecords * 4 + 50) )
- {
- psSHP->nRecords = (int)((nFileSize - 100) / 8);
- }
- psSHP->sHooks.FSeek( psSHP->fpSHX, 100, 0 );
- }
-
-/* -------------------------------------------------------------------- */
-/* Read the bounds. */
-/* -------------------------------------------------------------------- */
- if( bBigEndian ) SwapWord( 8, pabyBuf+36 );
- memcpy( &dValue, pabyBuf+36, 8 );
- psSHP->adBoundsMin[0] = dValue;
-
- if( bBigEndian ) SwapWord( 8, pabyBuf+44 );
- memcpy( &dValue, pabyBuf+44, 8 );
- psSHP->adBoundsMin[1] = dValue;
-
- if( bBigEndian ) SwapWord( 8, pabyBuf+52 );
- memcpy( &dValue, pabyBuf+52, 8 );
- psSHP->adBoundsMax[0] = dValue;
-
- if( bBigEndian ) SwapWord( 8, pabyBuf+60 );
- memcpy( &dValue, pabyBuf+60, 8 );
- psSHP->adBoundsMax[1] = dValue;
-
- if( bBigEndian ) SwapWord( 8, pabyBuf+68 ); /* z */
- memcpy( &dValue, pabyBuf+68, 8 );
- psSHP->adBoundsMin[2] = dValue;
-
- if( bBigEndian ) SwapWord( 8, pabyBuf+76 );
- memcpy( &dValue, pabyBuf+76, 8 );
- psSHP->adBoundsMax[2] = dValue;
-
- if( bBigEndian ) SwapWord( 8, pabyBuf+84 ); /* z */
- memcpy( &dValue, pabyBuf+84, 8 );
- psSHP->adBoundsMin[3] = dValue;
-
- if( bBigEndian ) SwapWord( 8, pabyBuf+92 );
- memcpy( &dValue, pabyBuf+92, 8 );
- psSHP->adBoundsMax[3] = dValue;
-
- free( pabyBuf );
-
-/* -------------------------------------------------------------------- */
-/* Read the .shx file to get the offsets to each record in */
-/* the .shp file. */
-/* -------------------------------------------------------------------- */
- psSHP->nMaxRecords = psSHP->nRecords;
-
- psSHP->panRecOffset = (unsigned int *)
- malloc(sizeof(unsigned int) * MAX(1,psSHP->nMaxRecords) );
- psSHP->panRecSize = (unsigned int *)
- malloc(sizeof(unsigned int) * MAX(1,psSHP->nMaxRecords) );
- if( bLazySHXLoading )
- pabyBuf = NULL;
- else
- pabyBuf = (uchar *) malloc(8 * MAX(1,psSHP->nRecords) );
-
- if (psSHP->panRecOffset == NULL ||
- psSHP->panRecSize == NULL ||
- (!bLazySHXLoading && pabyBuf == NULL))
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Not enough memory to allocate requested memory (nRecords=%d).\n"
- "Probably broken SHP file",
- psSHP->nRecords );
- psSHP->sHooks.Error( szError );
- psSHP->sHooks.FClose( psSHP->fpSHP );
- psSHP->sHooks.FClose( psSHP->fpSHX );
- if (psSHP->panRecOffset) free( psSHP->panRecOffset );
- if (psSHP->panRecSize) free( psSHP->panRecSize );
- if (pabyBuf) free( pabyBuf );
- free( psSHP );
- return( NULL );
- }
-
- if( bLazySHXLoading )
- {
- memset(psSHP->panRecOffset, 0, sizeof(unsigned int) * MAX(1,psSHP->nMaxRecords) );
- memset(psSHP->panRecSize, 0, sizeof(unsigned int) * MAX(1,psSHP->nMaxRecords) );
- return( psSHP );
- }
-
- if( (int) psSHP->sHooks.FRead( pabyBuf, 8, psSHP->nRecords, psSHP->fpSHX )
- != psSHP->nRecords )
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Failed to read all values for %d records in .shx file: %s.",
- psSHP->nRecords, strerror(errno) );
- psSHP->sHooks.Error( szError );
-
- /* SHX is short or unreadable for some reason. */
- psSHP->sHooks.FClose( psSHP->fpSHP );
- psSHP->sHooks.FClose( psSHP->fpSHX );
- free( psSHP->panRecOffset );
- free( psSHP->panRecSize );
- free( pabyBuf );
- free( psSHP );
-
- return( NULL );
- }
-
- /* In read-only mode, we can close the SHX now */
- if (strcmp(pszAccess, "rb") == 0)
- {
- psSHP->sHooks.FClose( psSHP->fpSHX );
- psSHP->fpSHX = NULL;
- }
-
- for( i = 0; i < psSHP->nRecords; i++ )
- {
- unsigned int nOffset, nLength;
-
- memcpy( &nOffset, pabyBuf + i * 8, 4 );
- if( !bBigEndian ) SwapWord( 4, &nOffset );
-
- memcpy( &nLength, pabyBuf + i * 8 + 4, 4 );
- if( !bBigEndian ) SwapWord( 4, &nLength );
-
- if( nOffset > (unsigned int)INT_MAX )
- {
- char str[128];
- snprintf( str, sizeof(str),
- "Invalid offset for entity %d", i);
-
- psSHP->sHooks.Error( str );
- SHPClose(psSHP);
- free( pabyBuf );
- return NULL;
- }
- if( nLength > (unsigned int)(INT_MAX / 2 - 4) )
- {
- char str[128];
- snprintf( str, sizeof(str),
- "Invalid length for entity %d", i);
-
- psSHP->sHooks.Error( str );
- SHPClose(psSHP);
- free( pabyBuf );
- return NULL;
- }
- psSHP->panRecOffset[i] = nOffset*2;
- psSHP->panRecSize[i] = nLength*2;
- }
- free( pabyBuf );
-
- return( psSHP );
-}
-
-/************************************************************************/
-/* SHPOpenLLEx() */
-/* */
-/* Open the .shp and .shx files based on the basename of the */
-/* files or either file name. It generally invokes SHPRestoreSHX() */
-/* in case when bRestoreSHX equals true. */
-/************************************************************************/
-
-SHPHandle SHPAPI_CALL
-SHPOpenLLEx( const char * pszLayer, const char * pszAccess, SAHooks *psHooks,
- int bRestoreSHX )
-
-{
- if ( !bRestoreSHX ) return SHPOpenLL ( pszLayer, pszAccess, psHooks );
- else
- {
- if ( SHPRestoreSHX ( pszLayer, pszAccess, psHooks ) )
- {
- return SHPOpenLL ( pszLayer, pszAccess, psHooks );
- }
- }
-
- return( NULL );
-}
-
-/************************************************************************/
-/* SHPRestoreSHX() */
-/* */
-/* Restore .SHX file using associated .SHP file. */
-/* */
-/************************************************************************/
-
-int SHPAPI_CALL
-SHPRestoreSHX ( const char * pszLayer, const char * pszAccess, SAHooks *psHooks )
-
-{
- char *pszFullname, *pszBasename;
- SAFile fpSHP, fpSHX;
-
-
- uchar *pabyBuf;
- int i;
- size_t nFullnameLen;
- unsigned int nSHPFilesize;
-
- size_t nMessageLen;
- char *pszMessage;
-
- unsigned int nCurrentRecordOffset = 0;
- unsigned int nCurrentSHPOffset = 100;
- size_t nRealSHXContentSize = 100;
-
- const char pszSHXAccess[] = "w+b";
- char *pabySHXHeader;
- char abyReadedRecord[8];
- unsigned int niRecord = 0;
- unsigned int nRecordLength = 0;
- unsigned int nRecordOffset = 50;
-
-/* -------------------------------------------------------------------- */
-/* Ensure the access string is one of the legal ones. We */
-/* ensure the result string indicates binary to avoid common */
-/* problems on Windows. */
-/* -------------------------------------------------------------------- */
- if( strcmp(pszAccess,"rb+") == 0 || strcmp(pszAccess,"r+b") == 0
- || strcmp(pszAccess,"r+") == 0 )
- pszAccess = "r+b";
- else
- {
- pszAccess = "rb";
- }
-
-/* -------------------------------------------------------------------- */
-/* Establish the byte order on this machine. */
-/* -------------------------------------------------------------------- */
-#if !defined(bBigEndian)
- i = 1;
- if( *((uchar *) &i) == 1 )
- bBigEndian = FALSE;
- else
- bBigEndian = TRUE;
-#endif
-
-/* -------------------------------------------------------------------- */
-/* Compute the base (layer) name. If there is any extension */
-/* on the passed in filename we will strip it off. */
-/* -------------------------------------------------------------------- */
- pszBasename = (char *) malloc(strlen(pszLayer)+5);
- strcpy( pszBasename, pszLayer );
- for( i = (int)strlen(pszBasename)-1;
- i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
- && pszBasename[i] != '\\';
- i-- ) {}
-
- if( pszBasename[i] == '.' )
- pszBasename[i] = '\0';
-
-/* -------------------------------------------------------------------- */
-/* Open the .shp file. Note that files pulled from */
-/* a PC to Unix with upper case filenames won't work! */
-/* -------------------------------------------------------------------- */
- nFullnameLen = strlen(pszBasename) + 5;
- pszFullname = (char *) malloc(nFullnameLen);
- snprintf( pszFullname, nFullnameLen, "%s.shp", pszBasename ) ;
- fpSHP = psHooks->FOpen(pszFullname, pszAccess );
- if( fpSHP == NULL )
- {
- snprintf( pszFullname, nFullnameLen, "%s.SHP", pszBasename );
- fpSHP = psHooks->FOpen(pszFullname, pszAccess );
- }
-
- if( fpSHP == NULL )
- {
- nMessageLen = strlen(pszBasename)*2+256;
- pszMessage = (char *) malloc(nMessageLen);
- snprintf( pszMessage, nMessageLen, "Unable to open %s.shp or %s.SHP.",
- pszBasename, pszBasename );
- psHooks->Error( pszMessage );
- free( pszMessage );
-
- free( pszBasename );
- free( pszFullname );
-
- return( 0 );
- }
-
-/* -------------------------------------------------------------------- */
-/* Read the file size from the SHP file. */
-/* -------------------------------------------------------------------- */
- pabyBuf = (uchar *) malloc(100);
- psHooks->FRead( pabyBuf, 100, 1, fpSHP );
-
- nSHPFilesize = ((unsigned int)pabyBuf[24] * 256 * 256 * 256
- + (unsigned int)pabyBuf[25] * 256 * 256
- + (unsigned int)pabyBuf[26] * 256
- + (unsigned int)pabyBuf[27]);
- if( nSHPFilesize < 0xFFFFFFFFU / 2 )
- nSHPFilesize *= 2;
- else
- nSHPFilesize = 0xFFFFFFFEU;
-
- snprintf( pszFullname, nFullnameLen, "%s.shx", pszBasename );
- fpSHX = psHooks->FOpen( pszFullname, pszSHXAccess );
-
- if( fpSHX == NULL )
- {
- nMessageLen = strlen( pszBasename ) * 2 + 256;
- pszMessage = (char *) malloc( nMessageLen );
- snprintf( pszMessage, nMessageLen, "Error opening file %s.shx for writing",
- pszBasename );
- psHooks->Error( pszMessage );
- free( pszMessage );
-
- psHooks->FClose( fpSHX );
-
- free( pabyBuf );
- free( pszBasename );
- free( pszFullname );
-
- return( 0 );
- }
-
-/* -------------------------------------------------------------------- */
-/* Open SHX and create it using SHP file content. */
-/* -------------------------------------------------------------------- */
- psHooks->FSeek( fpSHP, 100, 0 );
- pabySHXHeader = (char *) malloc ( 100 );
- memcpy( pabySHXHeader, pabyBuf, 100 );
- psHooks->FWrite( pabySHXHeader, 100, 1, fpSHX );
-
- while( nCurrentSHPOffset < nSHPFilesize )
- {
- if( psHooks->FRead( &niRecord, 4, 1, fpSHP ) == 1 &&
- psHooks->FRead( &nRecordLength, 4, 1, fpSHP ) == 1)
- {
- if( !bBigEndian ) SwapWord( 4, &nRecordOffset );
- memcpy( abyReadedRecord, &nRecordOffset, 4 );
- memcpy( abyReadedRecord + 4, &nRecordLength, 4 );
-
- psHooks->FWrite( abyReadedRecord, 8, 1, fpSHX );
-
- if ( !bBigEndian ) SwapWord( 4, &nRecordOffset );
- if ( !bBigEndian ) SwapWord( 4, &nRecordLength );
- nRecordOffset += nRecordLength + 4;
- nCurrentRecordOffset += 8;
- nCurrentSHPOffset += 8 + nRecordLength * 2;
-
- psHooks->FSeek( fpSHP, nCurrentSHPOffset, 0 );
- nRealSHXContentSize += 8;
- }
- else
- {
- nMessageLen = strlen( pszBasename ) * 2 + 256;
- pszMessage = (char *) malloc( nMessageLen );
- snprintf( pszMessage, nMessageLen, "Error parsing .shp to restore .shx" );
- psHooks->Error( pszMessage );
- free( pszMessage );
-
- psHooks->FClose( fpSHX );
- psHooks->FClose( fpSHP );
-
- free( pabySHXHeader );
- free( pszBasename );
- free( pszFullname );
-
- return( 0 );
- }
- }
-
- nRealSHXContentSize /= 2; // Bytes counted -> WORDs
- if( !bBigEndian ) SwapWord( 4, &nRealSHXContentSize );
- psHooks->FSeek( fpSHX, 24, 0 );
- psHooks->FWrite( &nRealSHXContentSize, 4, 1, fpSHX );
-
- psHooks->FClose( fpSHP );
- psHooks->FClose( fpSHX );
-
- free ( pabyBuf );
- free ( pszFullname );
- free ( pszBasename );
- free ( pabySHXHeader );
-
- return( 1 );
-}
-
-/************************************************************************/
-/* SHPClose() */
-/* */
-/* Close the .shp and .shx files. */
-/************************************************************************/
-
-void SHPAPI_CALL
-SHPClose(SHPHandle psSHP )
-
-{
- if( psSHP == NULL )
- return;
-
-/* -------------------------------------------------------------------- */
-/* Update the header if we have modified anything. */
-/* -------------------------------------------------------------------- */
- if( psSHP->bUpdated )
- SHPWriteHeader( psSHP );
-
-/* -------------------------------------------------------------------- */
-/* Free all resources, and close files. */
-/* -------------------------------------------------------------------- */
- free( psSHP->panRecOffset );
- free( psSHP->panRecSize );
-
- if ( psSHP->fpSHX != NULL)
- psSHP->sHooks.FClose( psSHP->fpSHX );
- psSHP->sHooks.FClose( psSHP->fpSHP );
-
- if( psSHP->pabyRec != NULL )
- {
- free( psSHP->pabyRec );
- }
-
- if( psSHP->pabyObjectBuf != NULL )
- {
- free( psSHP->pabyObjectBuf );
- }
- if( psSHP->psCachedObject != NULL )
- {
- free( psSHP->psCachedObject );
- }
-
- free( psSHP );
-}
-
-/************************************************************************/
-/* SHPSetFastModeReadObject() */
-/************************************************************************/
-
-/* If setting bFastMode = TRUE, the content of SHPReadObject() is owned by the SHPHandle. */
-/* So you cannot have 2 valid instances of SHPReadObject() simultaneously. */
-/* The SHPObject padfZ and padfM members may be NULL depending on the geometry */
-/* type. It is illegal to free at hand any of the pointer members of the SHPObject structure */
-void SHPAPI_CALL SHPSetFastModeReadObject( SHPHandle hSHP, int bFastMode )
-{
- if( bFastMode )
- {
- if( hSHP->psCachedObject == NULL )
- {
- hSHP->psCachedObject = (SHPObject*) calloc(1, sizeof(SHPObject));
- assert( hSHP->psCachedObject != NULL );
- }
- }
-
- hSHP->bFastModeReadObject = bFastMode;
-}
-
-/************************************************************************/
-/* SHPGetInfo() */
-/* */
-/* Fetch general information about the shape file. */
-/************************************************************************/
-
-void SHPAPI_CALL
-SHPGetInfo(SHPHandle psSHP, int * pnEntities, int * pnShapeType,
- double * padfMinBound, double * padfMaxBound )
-
-{
- int i;
-
- if( psSHP == NULL )
- return;
-
- if( pnEntities != NULL )
- *pnEntities = psSHP->nRecords;
-
- if( pnShapeType != NULL )
- *pnShapeType = psSHP->nShapeType;
-
- for( i = 0; i < 4; i++ )
- {
- if( padfMinBound != NULL )
- padfMinBound[i] = psSHP->adBoundsMin[i];
- if( padfMaxBound != NULL )
- padfMaxBound[i] = psSHP->adBoundsMax[i];
- }
-}
-
-/************************************************************************/
-/* SHPCreate() */
-/* */
-/* Create a new shape file and return a handle to the open */
-/* shape file with read/write access. */
-/************************************************************************/
-
-SHPHandle SHPAPI_CALL
-SHPCreate( const char * pszLayer, int nShapeType )
-
-{
- SAHooks sHooks;
-
- SASetupDefaultHooks( &sHooks );
-
- return SHPCreateLL( pszLayer, nShapeType, &sHooks );
-}
-
-/************************************************************************/
-/* SHPCreate() */
-/* */
-/* Create a new shape file and return a handle to the open */
-/* shape file with read/write access. */
-/************************************************************************/
-
-SHPHandle SHPAPI_CALL
-SHPCreateLL( const char * pszLayer, int nShapeType, SAHooks *psHooks )
-
-{
- char *pszBasename = NULL, *pszFullname = NULL;
- int i;
- SAFile fpSHP = NULL, fpSHX = NULL;
- uchar abyHeader[100];
- int32 i32;
- double dValue;
- size_t nFullnameLen;
-
-/* -------------------------------------------------------------------- */
-/* Establish the byte order on this system. */
-/* -------------------------------------------------------------------- */
-#if !defined(bBigEndian)
- i = 1;
- if( *((uchar *) &i) == 1 )
- bBigEndian = FALSE;
- else
- bBigEndian = TRUE;
-#endif
-
-/* -------------------------------------------------------------------- */
-/* Compute the base (layer) name. If there is any extension */
-/* on the passed in filename we will strip it off. */
-/* -------------------------------------------------------------------- */
- pszBasename = (char *) malloc(strlen(pszLayer)+5);
- strcpy( pszBasename, pszLayer );
- for( i = (int)strlen(pszBasename)-1;
- i > 0 && pszBasename[i] != '.' && pszBasename[i] != '/'
- && pszBasename[i] != '\\';
- i-- ) {}
-
- if( pszBasename[i] == '.' )
- pszBasename[i] = '\0';
-
-/* -------------------------------------------------------------------- */
-/* Open the two files so we can write their headers. */
-/* -------------------------------------------------------------------- */
- nFullnameLen = strlen(pszBasename) + 5;
- pszFullname = (char *) malloc(nFullnameLen);
- snprintf( pszFullname, nFullnameLen, "%s.shp", pszBasename );
- fpSHP = psHooks->FOpen(pszFullname, "wb" );
- if( fpSHP == NULL )
- {
- psHooks->Error( "Failed to create file .shp file." );
- goto error;
- }
-
- snprintf( pszFullname, nFullnameLen, "%s.shx", pszBasename );
- fpSHX = psHooks->FOpen(pszFullname, "wb" );
- if( fpSHX == NULL )
- {
- psHooks->Error( "Failed to create file .shx file." );
- goto error;
- }
-
- free( pszFullname ); pszFullname = NULL;
- free( pszBasename ); pszBasename = NULL;
-
-/* -------------------------------------------------------------------- */
-/* Prepare header block for .shp file. */
-/* -------------------------------------------------------------------- */
- memset( abyHeader, 0, sizeof(abyHeader) );
-
- abyHeader[2] = 0x27; /* magic cookie */
- abyHeader[3] = 0x0a;
-
- i32 = 50; /* file size */
- ByteCopy( &i32, abyHeader+24, 4 );
- if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
-
- i32 = 1000; /* version */
- ByteCopy( &i32, abyHeader+28, 4 );
- if( bBigEndian ) SwapWord( 4, abyHeader+28 );
-
- i32 = nShapeType; /* shape type */
- ByteCopy( &i32, abyHeader+32, 4 );
- if( bBigEndian ) SwapWord( 4, abyHeader+32 );
-
- dValue = 0.0; /* set bounds */
- ByteCopy( &dValue, abyHeader+36, 8 );
- ByteCopy( &dValue, abyHeader+44, 8 );
- ByteCopy( &dValue, abyHeader+52, 8 );
- ByteCopy( &dValue, abyHeader+60, 8 );
-
-/* -------------------------------------------------------------------- */
-/* Write .shp file header. */
-/* -------------------------------------------------------------------- */
- if( psHooks->FWrite( abyHeader, 100, 1, fpSHP ) != 1 )
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Failed to write .shp header: %s", strerror(errno) );
- psHooks->Error( szError );
-
- goto error;
- }
-
-/* -------------------------------------------------------------------- */
-/* Prepare, and write .shx file header. */
-/* -------------------------------------------------------------------- */
- i32 = 50; /* file size */
- ByteCopy( &i32, abyHeader+24, 4 );
- if( !bBigEndian ) SwapWord( 4, abyHeader+24 );
-
- if( psHooks->FWrite( abyHeader, 100, 1, fpSHX ) != 1 )
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Failure writing .shx header: %s", strerror(errno) );
- psHooks->Error( szError );
-
- goto error;
- }
-
-/* -------------------------------------------------------------------- */
-/* Close the files, and then open them as regular existing files. */
-/* -------------------------------------------------------------------- */
- psHooks->FClose( fpSHP );
- psHooks->FClose( fpSHX );
-
- return( SHPOpenLL( pszLayer, "r+b", psHooks ) );
-
-error:
- if (pszFullname) free(pszFullname);
- if (pszBasename) free(pszBasename);
- if (fpSHP) psHooks->FClose( fpSHP );
- if (fpSHX) psHooks->FClose( fpSHX );
- return NULL;
-}
-
-/************************************************************************/
-/* _SHPSetBounds() */
-/* */
-/* Compute a bounds rectangle for a shape, and set it into the */
-/* indicated location in the record. */
-/************************************************************************/
-
-static void _SHPSetBounds( uchar * pabyRec, SHPObject * psShape )
-
-{
- ByteCopy( &(psShape->dfXMin), pabyRec + 0, 8 );
- ByteCopy( &(psShape->dfYMin), pabyRec + 8, 8 );
- ByteCopy( &(psShape->dfXMax), pabyRec + 16, 8 );
- ByteCopy( &(psShape->dfYMax), pabyRec + 24, 8 );
-
- if( bBigEndian )
- {
- SwapWord( 8, pabyRec + 0 );
- SwapWord( 8, pabyRec + 8 );
- SwapWord( 8, pabyRec + 16 );
- SwapWord( 8, pabyRec + 24 );
- }
-}
-
-/************************************************************************/
-/* SHPComputeExtents() */
-/* */
-/* Recompute the extents of a shape. Automatically done by */
-/* SHPCreateObject(). */
-/************************************************************************/
-
-void SHPAPI_CALL
-SHPComputeExtents( SHPObject * psObject )
-
-{
- int i;
-
-/* -------------------------------------------------------------------- */
-/* Build extents for this object. */
-/* -------------------------------------------------------------------- */
- if( psObject->nVertices > 0 )
- {
- psObject->dfXMin = psObject->dfXMax = psObject->padfX[0];
- psObject->dfYMin = psObject->dfYMax = psObject->padfY[0];
- psObject->dfZMin = psObject->dfZMax = psObject->padfZ[0];
- psObject->dfMMin = psObject->dfMMax = psObject->padfM[0];
- }
-
- for( i = 0; i < psObject->nVertices; i++ )
- {
- psObject->dfXMin = MIN(psObject->dfXMin, psObject->padfX[i]);
- psObject->dfYMin = MIN(psObject->dfYMin, psObject->padfY[i]);
- psObject->dfZMin = MIN(psObject->dfZMin, psObject->padfZ[i]);
- psObject->dfMMin = MIN(psObject->dfMMin, psObject->padfM[i]);
-
- psObject->dfXMax = MAX(psObject->dfXMax, psObject->padfX[i]);
- psObject->dfYMax = MAX(psObject->dfYMax, psObject->padfY[i]);
- psObject->dfZMax = MAX(psObject->dfZMax, psObject->padfZ[i]);
- psObject->dfMMax = MAX(psObject->dfMMax, psObject->padfM[i]);
- }
-}
-
-/************************************************************************/
-/* SHPCreateObject() */
-/* */
-/* Create a shape object. It should be freed with */
-/* SHPDestroyObject(). */
-/************************************************************************/
-
-SHPObject SHPAPI_CALL1(*)
-SHPCreateObject( int nSHPType, int nShapeId, int nParts,
- const int * panPartStart, const int * panPartType,
- int nVertices, const double *padfX, const double *padfY,
- const double * padfZ, const double * padfM )
-
-{
- SHPObject *psObject;
- int i, bHasM, bHasZ;
-
- psObject = (SHPObject *) calloc(1,sizeof(SHPObject));
- psObject->nSHPType = nSHPType;
- psObject->nShapeId = nShapeId;
- psObject->bMeasureIsUsed = FALSE;
-
-/* -------------------------------------------------------------------- */
-/* Establish whether this shape type has M, and Z values. */
-/* -------------------------------------------------------------------- */
- if( nSHPType == SHPT_ARCM
- || nSHPType == SHPT_POINTM
- || nSHPType == SHPT_POLYGONM
- || nSHPType == SHPT_MULTIPOINTM )
- {
- bHasM = TRUE;
- bHasZ = FALSE;
- }
- else if( nSHPType == SHPT_ARCZ
- || nSHPType == SHPT_POINTZ
- || nSHPType == SHPT_POLYGONZ
- || nSHPType == SHPT_MULTIPOINTZ
- || nSHPType == SHPT_MULTIPATCH )
- {
- bHasM = TRUE;
- bHasZ = TRUE;
- }
- else
- {
- bHasM = FALSE;
- bHasZ = FALSE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Capture parts. Note that part type is optional, and */
-/* defaults to ring. */
-/* -------------------------------------------------------------------- */
- if( nSHPType == SHPT_ARC || nSHPType == SHPT_POLYGON
- || nSHPType == SHPT_ARCM || nSHPType == SHPT_POLYGONM
- || nSHPType == SHPT_ARCZ || nSHPType == SHPT_POLYGONZ
- || nSHPType == SHPT_MULTIPATCH )
- {
- psObject->nParts = MAX(1,nParts);
-
- psObject->panPartStart = (int *)
- calloc(sizeof(int), psObject->nParts);
- psObject->panPartType = (int *)
- malloc(sizeof(int) * psObject->nParts);
-
- psObject->panPartStart[0] = 0;
- psObject->panPartType[0] = SHPP_RING;
-
- for( i = 0; i < nParts; i++ )
- {
- if( panPartStart != NULL )
- psObject->panPartStart[i] = panPartStart[i];
-
- if( panPartType != NULL )
- psObject->panPartType[i] = panPartType[i];
- else
- psObject->panPartType[i] = SHPP_RING;
- }
-
- if( psObject->panPartStart[0] != 0 )
- psObject->panPartStart[0] = 0;
- }
-
-/* -------------------------------------------------------------------- */
-/* Capture vertices. Note that X, Y, Z and M are optional. */
-/* -------------------------------------------------------------------- */
- if( nVertices > 0 )
- {
- psObject->padfX = (double *) calloc(sizeof(double),nVertices);
- psObject->padfY = (double *) calloc(sizeof(double),nVertices);
- psObject->padfZ = (double *) calloc(sizeof(double),nVertices);
- psObject->padfM = (double *) calloc(sizeof(double),nVertices);
-
- for( i = 0; i < nVertices; i++ )
- {
- if( padfX != NULL )
- psObject->padfX[i] = padfX[i];
- if( padfY != NULL )
- psObject->padfY[i] = padfY[i];
- if( padfZ != NULL && bHasZ )
- psObject->padfZ[i] = padfZ[i];
- if( padfM != NULL && bHasM )
- psObject->padfM[i] = padfM[i];
- }
- if( padfM != NULL && bHasM )
- psObject->bMeasureIsUsed = TRUE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Compute the extents. */
-/* -------------------------------------------------------------------- */
- psObject->nVertices = nVertices;
- SHPComputeExtents( psObject );
-
- return( psObject );
-}
-
-/************************************************************************/
-/* SHPCreateSimpleObject() */
-/* */
-/* Create a simple (common) shape object. Destroy with */
-/* SHPDestroyObject(). */
-/************************************************************************/
-
-SHPObject SHPAPI_CALL1(*)
-SHPCreateSimpleObject( int nSHPType, int nVertices,
- const double * padfX, const double * padfY,
- const double * padfZ )
-
-{
- return( SHPCreateObject( nSHPType, -1, 0, NULL, NULL,
- nVertices, padfX, padfY, padfZ, NULL ) );
-}
-
-/************************************************************************/
-/* SHPWriteObject() */
-/* */
-/* Write out the vertices of a new structure. Note that it is */
-/* only possible to write vertices at the end of the file. */
-/************************************************************************/
-
-int SHPAPI_CALL
-SHPWriteObject(SHPHandle psSHP, int nShapeId, SHPObject * psObject )
-
-{
- unsigned int nRecordOffset, nRecordSize=0;
- int i;
- uchar *pabyRec;
- int32 i32;
- int bExtendFile = FALSE;
-
- psSHP->bUpdated = TRUE;
-
-/* -------------------------------------------------------------------- */
-/* Ensure that shape object matches the type of the file it is */
-/* being written to. */
-/* -------------------------------------------------------------------- */
- assert( psObject->nSHPType == psSHP->nShapeType
- || psObject->nSHPType == SHPT_NULL );
-
-/* -------------------------------------------------------------------- */
-/* Ensure that -1 is used for appends. Either blow an */
-/* assertion, or if they are disabled, set the shapeid to -1 */
-/* for appends. */
-/* -------------------------------------------------------------------- */
- assert( nShapeId == -1
- || (nShapeId >= 0 && nShapeId < psSHP->nRecords) );
-
- if( nShapeId != -1 && nShapeId >= psSHP->nRecords )
- nShapeId = -1;
-
-/* -------------------------------------------------------------------- */
-/* Add the new entity to the in memory index. */
-/* -------------------------------------------------------------------- */
- if( nShapeId == -1 && psSHP->nRecords+1 > psSHP->nMaxRecords )
- {
- int nNewMaxRecords = psSHP->nMaxRecords + psSHP->nMaxRecords / 3 + 100;
- unsigned int* panRecOffsetNew;
- unsigned int* panRecSizeNew;
-
- panRecOffsetNew = (unsigned int *)
- SfRealloc(psSHP->panRecOffset,sizeof(unsigned int) * nNewMaxRecords );
- if( panRecOffsetNew == NULL )
- return -1;
- psSHP->panRecOffset = panRecOffsetNew;
-
- panRecSizeNew = (unsigned int *)
- SfRealloc(psSHP->panRecSize,sizeof(unsigned int) * nNewMaxRecords );
- if( panRecSizeNew == NULL )
- return -1;
- psSHP->panRecSize = panRecSizeNew;
-
- psSHP->nMaxRecords = nNewMaxRecords;
- }
-
-/* -------------------------------------------------------------------- */
-/* Initialize record. */
-/* -------------------------------------------------------------------- */
- pabyRec = (uchar *) malloc(psObject->nVertices * 4 * sizeof(double)
- + psObject->nParts * 8 + 128);
- if( pabyRec == NULL )
- return -1;
-
-/* -------------------------------------------------------------------- */
-/* Extract vertices for a Polygon or Arc. */
-/* -------------------------------------------------------------------- */
- if( psObject->nSHPType == SHPT_POLYGON
- || psObject->nSHPType == SHPT_POLYGONZ
- || psObject->nSHPType == SHPT_POLYGONM
- || psObject->nSHPType == SHPT_ARC
- || psObject->nSHPType == SHPT_ARCZ
- || psObject->nSHPType == SHPT_ARCM
- || psObject->nSHPType == SHPT_MULTIPATCH )
- {
- int32 nPoints, nParts;
-
- nPoints = psObject->nVertices;
- nParts = psObject->nParts;
-
- _SHPSetBounds( pabyRec + 12, psObject );
-
- if( bBigEndian ) SwapWord( 4, &nPoints );
- if( bBigEndian ) SwapWord( 4, &nParts );
-
- ByteCopy( &nPoints, pabyRec + 40 + 8, 4 );
- ByteCopy( &nParts, pabyRec + 36 + 8, 4 );
-
- nRecordSize = 52;
-
- /*
- * Write part start positions.
- */
- ByteCopy( psObject->panPartStart, pabyRec + 44 + 8,
- 4 * psObject->nParts );
- for( i = 0; i < psObject->nParts; i++ )
- {
- if( bBigEndian ) SwapWord( 4, pabyRec + 44 + 8 + 4*i );
- nRecordSize += 4;
- }
-
- /*
- * Write multipatch part types if needed.
- */
- if( psObject->nSHPType == SHPT_MULTIPATCH )
- {
- memcpy( pabyRec + nRecordSize, psObject->panPartType,
- 4*psObject->nParts );
- for( i = 0; i < psObject->nParts; i++ )
- {
- if( bBigEndian ) SwapWord( 4, pabyRec + nRecordSize );
- nRecordSize += 4;
- }
- }
-
- /*
- * Write the (x,y) vertex values.
- */
- for( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfX + i, pabyRec + nRecordSize, 8 );
- ByteCopy( psObject->padfY + i, pabyRec + nRecordSize + 8, 8 );
-
- if( bBigEndian )
- SwapWord( 8, pabyRec + nRecordSize );
-
- if( bBigEndian )
- SwapWord( 8, pabyRec + nRecordSize + 8 );
-
- nRecordSize += 2 * 8;
- }
-
- /*
- * Write the Z coordinates (if any).
- */
- if( psObject->nSHPType == SHPT_POLYGONZ
- || psObject->nSHPType == SHPT_ARCZ
- || psObject->nSHPType == SHPT_MULTIPATCH )
- {
- ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- for( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
- }
-
- /*
- * Write the M values, if any.
- */
- if( psObject->bMeasureIsUsed
- && (psObject->nSHPType == SHPT_POLYGONM
- || psObject->nSHPType == SHPT_ARCM
-#ifndef DISABLE_MULTIPATCH_MEASURE
- || psObject->nSHPType == SHPT_MULTIPATCH
-#endif
- || psObject->nSHPType == SHPT_POLYGONZ
- || psObject->nSHPType == SHPT_ARCZ) )
- {
- ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- for( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* Extract vertices for a MultiPoint. */
-/* -------------------------------------------------------------------- */
- else if( psObject->nSHPType == SHPT_MULTIPOINT
- || psObject->nSHPType == SHPT_MULTIPOINTZ
- || psObject->nSHPType == SHPT_MULTIPOINTM )
- {
- int32 nPoints;
-
- nPoints = psObject->nVertices;
-
- _SHPSetBounds( pabyRec + 12, psObject );
-
- if( bBigEndian ) SwapWord( 4, &nPoints );
- ByteCopy( &nPoints, pabyRec + 44, 4 );
-
- for( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfX + i, pabyRec + 48 + i*16, 8 );
- ByteCopy( psObject->padfY + i, pabyRec + 48 + i*16 + 8, 8 );
-
- if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 );
- if( bBigEndian ) SwapWord( 8, pabyRec + 48 + i*16 + 8 );
- }
-
- nRecordSize = 48 + 16 * psObject->nVertices;
-
- if( psObject->nSHPType == SHPT_MULTIPOINTZ )
- {
- ByteCopy( &(psObject->dfZMin), pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- ByteCopy( &(psObject->dfZMax), pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- for( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfZ + i, pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
- }
-
- if( psObject->bMeasureIsUsed
- && (psObject->nSHPType == SHPT_MULTIPOINTZ
- || psObject->nSHPType == SHPT_MULTIPOINTM) )
- {
- ByteCopy( &(psObject->dfMMin), pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- ByteCopy( &(psObject->dfMMax), pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
-
- for( i = 0; i < psObject->nVertices; i++ )
- {
- ByteCopy( psObject->padfM + i, pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* Write point. */
-/* -------------------------------------------------------------------- */
- else if( psObject->nSHPType == SHPT_POINT
- || psObject->nSHPType == SHPT_POINTZ
- || psObject->nSHPType == SHPT_POINTM )
- {
- ByteCopy( psObject->padfX, pabyRec + 12, 8 );
- ByteCopy( psObject->padfY, pabyRec + 20, 8 );
-
- if( bBigEndian ) SwapWord( 8, pabyRec + 12 );
- if( bBigEndian ) SwapWord( 8, pabyRec + 20 );
-
- nRecordSize = 28;
-
- if( psObject->nSHPType == SHPT_POINTZ )
- {
- ByteCopy( psObject->padfZ, pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
-
- if( psObject->bMeasureIsUsed
- && (psObject->nSHPType == SHPT_POINTZ
- || psObject->nSHPType == SHPT_POINTM) )
- {
- ByteCopy( psObject->padfM, pabyRec + nRecordSize, 8 );
- if( bBigEndian ) SwapWord( 8, pabyRec + nRecordSize );
- nRecordSize += 8;
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* Not much to do for null geometries. */
-/* -------------------------------------------------------------------- */
- else if( psObject->nSHPType == SHPT_NULL )
- {
- nRecordSize = 12;
- }
-
- else
- {
- /* unknown type */
- assert( FALSE );
- }
-
-/* -------------------------------------------------------------------- */
-/* Establish where we are going to put this record. If we are */
-/* rewriting and existing record, and it will fit, then put it */
-/* back where the original came from. Otherwise write at the end. */
-/* -------------------------------------------------------------------- */
- if( nShapeId == -1 || psSHP->panRecSize[nShapeId] < nRecordSize-8 )
- {
- unsigned int nExpectedSize = psSHP->nFileSize + nRecordSize;
- if( nExpectedSize < psSHP->nFileSize ) // due to unsigned int overflow
- {
- char str[128];
- snprintf( str, sizeof(str), "Failed to write shape object. "
- "File size cannot reach %u + %u.",
- psSHP->nFileSize, nRecordSize );
- psSHP->sHooks.Error( str );
- free( pabyRec );
- return -1;
- }
-
- bExtendFile = TRUE;
- nRecordOffset = psSHP->nFileSize;
- }
- else
- {
- nRecordOffset = psSHP->panRecOffset[nShapeId];
- }
-
-/* -------------------------------------------------------------------- */
-/* Set the shape type, record number, and record size. */
-/* -------------------------------------------------------------------- */
- i32 = (nShapeId < 0) ? psSHP->nRecords+1 : nShapeId+1; /* record # */
- if( !bBigEndian ) SwapWord( 4, &i32 );
- ByteCopy( &i32, pabyRec, 4 );
-
- i32 = (nRecordSize-8)/2; /* record size */
- if( !bBigEndian ) SwapWord( 4, &i32 );
- ByteCopy( &i32, pabyRec + 4, 4 );
-
- i32 = psObject->nSHPType; /* shape type */
- if( bBigEndian ) SwapWord( 4, &i32 );
- ByteCopy( &i32, pabyRec + 8, 4 );
-
-/* -------------------------------------------------------------------- */
-/* Write out record. */
-/* -------------------------------------------------------------------- */
- if( psSHP->sHooks.FSeek( psSHP->fpSHP, nRecordOffset, 0 ) != 0 )
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Error in psSHP->sHooks.FSeek() while writing object to .shp file: %s",
- strerror(errno) );
- psSHP->sHooks.Error( szError );
-
- free( pabyRec );
- return -1;
- }
- if( psSHP->sHooks.FWrite( pabyRec, nRecordSize, 1, psSHP->fpSHP ) < 1 )
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Error in psSHP->sHooks.FWrite() while writing object of %u bytes to .shp file: %s",
- nRecordSize, strerror(errno) );
- psSHP->sHooks.Error( szError );
-
- free( pabyRec );
- return -1;
- }
-
- free( pabyRec );
-
- if( bExtendFile )
- {
- if( nShapeId == -1 )
- nShapeId = psSHP->nRecords++;
-
- psSHP->panRecOffset[nShapeId] = psSHP->nFileSize;
- psSHP->nFileSize += nRecordSize;
- }
- psSHP->panRecSize[nShapeId] = nRecordSize-8;
-
-/* -------------------------------------------------------------------- */
-/* Expand file wide bounds based on this shape. */
-/* -------------------------------------------------------------------- */
- if( psSHP->adBoundsMin[0] == 0.0
- && psSHP->adBoundsMax[0] == 0.0
- && psSHP->adBoundsMin[1] == 0.0
- && psSHP->adBoundsMax[1] == 0.0 )
- {
- if( psObject->nSHPType == SHPT_NULL || psObject->nVertices == 0 )
- {
- psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = 0.0;
- psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = 0.0;
- psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = 0.0;
- psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = 0.0;
- }
- else
- {
- psSHP->adBoundsMin[0] = psSHP->adBoundsMax[0] = psObject->padfX[0];
- psSHP->adBoundsMin[1] = psSHP->adBoundsMax[1] = psObject->padfY[0];
- psSHP->adBoundsMin[2] = psSHP->adBoundsMax[2] = psObject->padfZ ? psObject->padfZ[0] : 0.0;
- psSHP->adBoundsMin[3] = psSHP->adBoundsMax[3] = psObject->padfM ? psObject->padfM[0] : 0.0;
- }
- }
-
- for( i = 0; i < psObject->nVertices; i++ )
- {
- psSHP->adBoundsMin[0] = MIN(psSHP->adBoundsMin[0],psObject->padfX[i]);
- psSHP->adBoundsMin[1] = MIN(psSHP->adBoundsMin[1],psObject->padfY[i]);
- psSHP->adBoundsMax[0] = MAX(psSHP->adBoundsMax[0],psObject->padfX[i]);
- psSHP->adBoundsMax[1] = MAX(psSHP->adBoundsMax[1],psObject->padfY[i]);
- if( psObject->padfZ )
- {
- psSHP->adBoundsMin[2] = MIN(psSHP->adBoundsMin[2],psObject->padfZ[i]);
- psSHP->adBoundsMax[2] = MAX(psSHP->adBoundsMax[2],psObject->padfZ[i]);
- }
- if( psObject->padfM )
- {
- psSHP->adBoundsMin[3] = MIN(psSHP->adBoundsMin[3],psObject->padfM[i]);
- psSHP->adBoundsMax[3] = MAX(psSHP->adBoundsMax[3],psObject->padfM[i]);
- }
- }
-
- return( nShapeId );
-}
-
-/************************************************************************/
-/* SHPAllocBuffer() */
-/************************************************************************/
-
-static void* SHPAllocBuffer(unsigned char** pBuffer, int nSize)
-{
- unsigned char* pRet;
-
- if( pBuffer == NULL )
- return calloc(1, nSize);
-
- pRet = *pBuffer;
- if( pRet == NULL )
- return NULL;
-
- (*pBuffer) += nSize;
- return pRet;
-}
-
-/************************************************************************/
-/* SHPReallocObjectBufIfNecessary() */
-/************************************************************************/
-
-static unsigned char* SHPReallocObjectBufIfNecessary ( SHPHandle psSHP,
- int nObjectBufSize )
-{
- unsigned char* pBuffer;
- if( nObjectBufSize == 0 )
- {
- nObjectBufSize = 4 * sizeof(double);
- }
- if( nObjectBufSize > psSHP->nObjectBufSize )
- {
- pBuffer = (unsigned char*) realloc( psSHP->pabyObjectBuf, nObjectBufSize );
- if( pBuffer != NULL )
- {
- psSHP->pabyObjectBuf = pBuffer;
- psSHP->nObjectBufSize = nObjectBufSize;
- }
- }
- else
- pBuffer = psSHP->pabyObjectBuf;
- return pBuffer;
-}
-
-/************************************************************************/
-/* SHPReadObject() */
-/* */
-/* Read the vertices, parts, and other non-attribute information */
-/* for one shape. */
-/************************************************************************/
-
-SHPObject SHPAPI_CALL1(*)
-SHPReadObject( SHPHandle psSHP, int hEntity )
-
-{
- int nEntitySize, nRequiredSize;
- SHPObject *psShape;
- char szErrorMsg[128];
- int nSHPType;
- int nBytesRead;
-
-/* -------------------------------------------------------------------- */
-/* Validate the record/entity number. */
-/* -------------------------------------------------------------------- */
- if( hEntity < 0 || hEntity >= psSHP->nRecords )
- return( NULL );
-
-/* -------------------------------------------------------------------- */
-/* Read offset/length from SHX loading if necessary. */
-/* -------------------------------------------------------------------- */
- if( psSHP->panRecOffset[hEntity] == 0 && psSHP->fpSHX != NULL )
- {
- unsigned int nOffset, nLength;
-
- if( psSHP->sHooks.FSeek( psSHP->fpSHX, 100 + 8 * hEntity, 0 ) != 0 ||
- psSHP->sHooks.FRead( &nOffset, 1, 4, psSHP->fpSHX ) != 4 ||
- psSHP->sHooks.FRead( &nLength, 1, 4, psSHP->fpSHX ) != 4 )
- {
- char str[128];
- snprintf( str, sizeof(str),
- "Error in fseek()/fread() reading object from .shx file at offset %d",
- 100 + 8 * hEntity);
-
- psSHP->sHooks.Error( str );
- return NULL;
- }
- if( !bBigEndian ) SwapWord( 4, &nOffset );
- if( !bBigEndian ) SwapWord( 4, &nLength );
-
- if( nOffset > (unsigned int)INT_MAX )
- {
- char str[128];
- snprintf( str, sizeof(str),
- "Invalid offset for entity %d", hEntity);
-
- psSHP->sHooks.Error( str );
- return NULL;
- }
- if( nLength > (unsigned int)(INT_MAX / 2 - 4) )
- {
- char str[128];
- snprintf( str, sizeof(str),
- "Invalid length for entity %d", hEntity);
-
- psSHP->sHooks.Error( str );
- return NULL;
- }
-
- psSHP->panRecOffset[hEntity] = nOffset*2;
- psSHP->panRecSize[hEntity] = nLength*2;
- }
-
-/* -------------------------------------------------------------------- */
-/* Ensure our record buffer is large enough. */
-/* -------------------------------------------------------------------- */
- nEntitySize = psSHP->panRecSize[hEntity]+8;
- if( nEntitySize > psSHP->nBufSize )
- {
- uchar* pabyRecNew;
- int nNewBufSize = nEntitySize;
- if( nNewBufSize < INT_MAX - nNewBufSize / 3 )
- nNewBufSize += nNewBufSize / 3;
- else
- nNewBufSize = INT_MAX;
-
- /* Before allocating too much memory, check that the file is big enough */
- if( nEntitySize >= 10 * 1024 * 1024 &&
- (psSHP->panRecOffset[hEntity] >= psSHP->nFileSize ||
- (unsigned int)nEntitySize > psSHP->nFileSize - psSHP->panRecOffset[hEntity]) )
- {
- /* We do as is we didn't trust the file size in the header */
- SAOffset nFileSize;
- psSHP->sHooks.FSeek( psSHP->fpSHP, 0, 2 );
- nFileSize = psSHP->sHooks.FTell(psSHP->fpSHP);
- if( nFileSize >= 0xFFFFFFFFU )
- psSHP->nFileSize = 0xFFFFFFFFU;
- else
- psSHP->nFileSize = (unsigned int)nFileSize;
-
- if( psSHP->panRecOffset[hEntity] >= psSHP->nFileSize ||
- (unsigned int)nEntitySize > psSHP->nFileSize - psSHP->panRecOffset[hEntity] )
- {
- char str[128];
- snprintf( str, sizeof(str),
- "Error in fread() reading object of size %d at offset %u from .shp file",
- nEntitySize, psSHP->panRecOffset[hEntity] );
-
- psSHP->sHooks.Error( str );
- return NULL;
- }
- }
-
- pabyRecNew = (uchar *) SfRealloc(psSHP->pabyRec,nNewBufSize);
- if (pabyRecNew == NULL)
- {
- char szError[200];
-
- snprintf( szError, sizeof(szError),
- "Not enough memory to allocate requested memory (nNewBufSize=%d). "
- "Probably broken SHP file", nNewBufSize);
- psSHP->sHooks.Error( szError );
- return NULL;
- }
-
- /* Only set new buffer size after successful alloc */
- psSHP->pabyRec = pabyRecNew;
- psSHP->nBufSize = nNewBufSize;
- }
-
- /* In case we were not able to reallocate the buffer on a previous step */
- if (psSHP->pabyRec == NULL)
- {
- return NULL;
- }
-
-/* -------------------------------------------------------------------- */
-/* Read the record. */
-/* -------------------------------------------------------------------- */
- if( psSHP->sHooks.FSeek( psSHP->fpSHP, psSHP->panRecOffset[hEntity], 0 ) != 0 )
- {
- /*
- * TODO - mloskot: Consider detailed diagnostics of shape file,
- * for example to detect if file is truncated.
- */
- char str[128];
- snprintf( str, sizeof(str),
- "Error in fseek() reading object from .shp file at offset %u",
- psSHP->panRecOffset[hEntity]);
-
- psSHP->sHooks.Error( str );
- return NULL;
- }
-
- nBytesRead = (int)psSHP->sHooks.FRead( psSHP->pabyRec, 1, nEntitySize, psSHP->fpSHP );
-
- /* Special case for a shapefile whose .shx content length field is not equal */
- /* to the content length field of the .shp, which is a violation of "The */
- /* content length stored in the index record is the same as the value stored in the main */
- /* file record header." (http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf, page 24) */
- /* Actually in that case the .shx content length is equal to the .shp content length + */
- /* 4 (16 bit words), representing the 8 bytes of the record header... */
- if( nBytesRead >= 8 && nBytesRead == nEntitySize - 8 )
- {
- /* Do a sanity check */
- int nSHPContentLength;
- memcpy( &nSHPContentLength, psSHP->pabyRec + 4, 4 );
- if( !bBigEndian ) SwapWord( 4, &(nSHPContentLength) );
- if( nSHPContentLength < 0 ||
- nSHPContentLength > INT_MAX / 2 - 4 ||
- 2 * nSHPContentLength + 8 != nBytesRead )
- {
- char str[128];
- snprintf( str, sizeof(str),
- "Sanity check failed when trying to recover from inconsistent .shx/.shp with shape %d",
- hEntity );
-
- psSHP->sHooks.Error( str );
- return NULL;
- }
- }
- else if( nBytesRead != nEntitySize )
- {
- /*
- * TODO - mloskot: Consider detailed diagnostics of shape file,
- * for example to detect if file is truncated.
- */
- char str[128];
- snprintf( str, sizeof(str),
- "Error in fread() reading object of size %d at offset %u from .shp file",
- nEntitySize, psSHP->panRecOffset[hEntity] );
-
- psSHP->sHooks.Error( str );
- return NULL;
- }
-
- if ( 8 + 4 > nEntitySize )
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Corrupted .shp file : shape %d : nEntitySize = %d",
- hEntity, nEntitySize);
- psSHP->sHooks.Error( szErrorMsg );
- return NULL;
- }
- memcpy( &nSHPType, psSHP->pabyRec + 8, 4 );
-
- if( bBigEndian ) SwapWord( 4, &(nSHPType) );
-
-/* -------------------------------------------------------------------- */
-/* Allocate and minimally initialize the object. */
-/* -------------------------------------------------------------------- */
- if( psSHP->bFastModeReadObject )
- {
- if( psSHP->psCachedObject->bFastModeReadObject )
- {
- psSHP->sHooks.Error( "Invalid read pattern in fast read mode. "
- "SHPDestroyObject() should be called." );
- return NULL;
- }
-
- psShape = psSHP->psCachedObject;
- memset(psShape, 0, sizeof(SHPObject));
- }
- else
- psShape = (SHPObject *) calloc(1,sizeof(SHPObject));
- psShape->nShapeId = hEntity;
- psShape->nSHPType = nSHPType;
- psShape->bMeasureIsUsed = FALSE;
- psShape->bFastModeReadObject = psSHP->bFastModeReadObject;
-
-/* ==================================================================== */
-/* Extract vertices for a Polygon or Arc. */
-/* ==================================================================== */
- if( psShape->nSHPType == SHPT_POLYGON || psShape->nSHPType == SHPT_ARC
- || psShape->nSHPType == SHPT_POLYGONZ
- || psShape->nSHPType == SHPT_POLYGONM
- || psShape->nSHPType == SHPT_ARCZ
- || psShape->nSHPType == SHPT_ARCM
- || psShape->nSHPType == SHPT_MULTIPATCH )
- {
- int32 nPoints, nParts;
- int i, nOffset;
- unsigned char* pBuffer = NULL;
- unsigned char** ppBuffer = NULL;
-
- if ( 40 + 8 + 4 > nEntitySize )
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Corrupted .shp file : shape %d : nEntitySize = %d",
- hEntity, nEntitySize);
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
-/* -------------------------------------------------------------------- */
-/* Get the X/Y bounds. */
-/* -------------------------------------------------------------------- */
- memcpy( &(psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8 );
- memcpy( &(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 );
- memcpy( &(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 );
- memcpy( &(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 );
-
- if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) );
- if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) );
- if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) );
- if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) );
-
-/* -------------------------------------------------------------------- */
-/* Extract part/point count, and build vertex and part arrays */
-/* to proper size. */
-/* -------------------------------------------------------------------- */
- memcpy( &nPoints, psSHP->pabyRec + 40 + 8, 4 );
- memcpy( &nParts, psSHP->pabyRec + 36 + 8, 4 );
-
- if( bBigEndian ) SwapWord( 4, &nPoints );
- if( bBigEndian ) SwapWord( 4, &nParts );
-
- /* nPoints and nParts are unsigned */
- if (/* nPoints < 0 || nParts < 0 || */
- nPoints > 50 * 1000 * 1000 || nParts > 10 * 1000 * 1000)
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Corrupted .shp file : shape %d, nPoints=%u, nParts=%u.",
- hEntity, nPoints, nParts);
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
-
- /* With the previous checks on nPoints and nParts, */
- /* we should not overflow here and after */
- /* since 50 M * (16 + 8 + 8) = 1 600 MB */
- nRequiredSize = 44 + 8 + 4 * nParts + 16 * nPoints;
- if ( psShape->nSHPType == SHPT_POLYGONZ
- || psShape->nSHPType == SHPT_ARCZ
- || psShape->nSHPType == SHPT_MULTIPATCH )
- {
- nRequiredSize += 16 + 8 * nPoints;
- }
- if( psShape->nSHPType == SHPT_MULTIPATCH )
- {
- nRequiredSize += 4 * nParts;
- }
- if (nRequiredSize > nEntitySize)
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Corrupted .shp file : shape %d, nPoints=%u, nParts=%u, nEntitySize=%d.",
- hEntity, nPoints, nParts, nEntitySize);
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
-
- if( psShape->bFastModeReadObject )
- {
- int nObjectBufSize = 4 * sizeof(double) * nPoints + 2 * sizeof(int) * nParts;
- pBuffer = SHPReallocObjectBufIfNecessary(psSHP, nObjectBufSize);
- ppBuffer = &pBuffer;
- }
-
- psShape->nVertices = nPoints;
- psShape->padfX = (double *) SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints);
- psShape->padfY = (double *) SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints);
- psShape->padfZ = (double *) SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints);
- psShape->padfM = (double *) SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints);
-
- psShape->nParts = nParts;
- psShape->panPartStart = (int *) SHPAllocBuffer(ppBuffer, nParts * sizeof(int));
- psShape->panPartType = (int *) SHPAllocBuffer(ppBuffer, nParts * sizeof(int));
-
- if (psShape->padfX == NULL ||
- psShape->padfY == NULL ||
- psShape->padfZ == NULL ||
- psShape->padfM == NULL ||
- psShape->panPartStart == NULL ||
- psShape->panPartType == NULL)
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Not enough memory to allocate requested memory (nPoints=%u, nParts=%u) for shape %d. "
- "Probably broken SHP file", nPoints, nParts, hEntity );
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
-
- for( i = 0; (int32)i < nParts; i++ )
- psShape->panPartType[i] = SHPP_RING;
-
-/* -------------------------------------------------------------------- */
-/* Copy out the part array from the record. */
-/* -------------------------------------------------------------------- */
- memcpy( psShape->panPartStart, psSHP->pabyRec + 44 + 8, 4 * nParts );
- for( i = 0; (int32)i < nParts; i++ )
- {
- if( bBigEndian ) SwapWord( 4, psShape->panPartStart+i );
-
- /* We check that the offset is inside the vertex array */
- if (psShape->panPartStart[i] < 0
- || (psShape->panPartStart[i] >= psShape->nVertices
- && psShape->nVertices > 0)
- || (psShape->panPartStart[i] > 0 && psShape->nVertices == 0) )
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Corrupted .shp file : shape %d : panPartStart[%d] = %d, nVertices = %d",
- hEntity, i, psShape->panPartStart[i], psShape->nVertices);
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
- if (i > 0 && psShape->panPartStart[i] <= psShape->panPartStart[i-1])
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Corrupted .shp file : shape %d : panPartStart[%d] = %d, panPartStart[%d] = %d",
- hEntity, i, psShape->panPartStart[i], i - 1, psShape->panPartStart[i - 1]);
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
- }
-
- nOffset = 44 + 8 + 4*nParts;
-
-/* -------------------------------------------------------------------- */
-/* If this is a multipatch, we will also have parts types. */
-/* -------------------------------------------------------------------- */
- if( psShape->nSHPType == SHPT_MULTIPATCH )
- {
- memcpy( psShape->panPartType, psSHP->pabyRec + nOffset, 4*nParts );
- for( i = 0; (int32)i < nParts; i++ )
- {
- if( bBigEndian ) SwapWord( 4, psShape->panPartType+i );
- }
-
- nOffset += 4*nParts;
- }
-
-/* -------------------------------------------------------------------- */
-/* Copy out the vertices from the record. */
-/* -------------------------------------------------------------------- */
- for( i = 0; (int32)i < nPoints; i++ )
- {
- memcpy(psShape->padfX + i,
- psSHP->pabyRec + nOffset + i * 16,
- 8 );
-
- memcpy(psShape->padfY + i,
- psSHP->pabyRec + nOffset + i * 16 + 8,
- 8 );
-
- if( bBigEndian ) SwapWord( 8, psShape->padfX + i );
- if( bBigEndian ) SwapWord( 8, psShape->padfY + i );
- }
-
- nOffset += 16*nPoints;
-
-/* -------------------------------------------------------------------- */
-/* If we have a Z coordinate, collect that now. */
-/* -------------------------------------------------------------------- */
- if( psShape->nSHPType == SHPT_POLYGONZ
- || psShape->nSHPType == SHPT_ARCZ
- || psShape->nSHPType == SHPT_MULTIPATCH )
- {
- memcpy( &(psShape->dfZMin), psSHP->pabyRec + nOffset, 8 );
- memcpy( &(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 );
-
- if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) );
- if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) );
-
- for( i = 0; (int32)i < nPoints; i++ )
- {
- memcpy( psShape->padfZ + i,
- psSHP->pabyRec + nOffset + 16 + i*8, 8 );
- if( bBigEndian ) SwapWord( 8, psShape->padfZ + i );
- }
-
- nOffset += 16 + 8*nPoints;
- }
- else if( psShape->bFastModeReadObject )
- {
- psShape->padfZ = NULL;
- }
-
-/* -------------------------------------------------------------------- */
-/* If we have a M measure value, then read it now. We assume */
-/* that the measure can be present for any shape if the size is */
-/* big enough, but really it will only occur for the Z shapes */
-/* (options), and the M shapes. */
-/* -------------------------------------------------------------------- */
- if( nEntitySize >= (int)(nOffset + 16 + 8*nPoints) )
- {
- memcpy( &(psShape->dfMMin), psSHP->pabyRec + nOffset, 8 );
- memcpy( &(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 );
-
- if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) );
- if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) );
-
- for( i = 0; (int32)i < nPoints; i++ )
- {
- memcpy( psShape->padfM + i,
- psSHP->pabyRec + nOffset + 16 + i*8, 8 );
- if( bBigEndian ) SwapWord( 8, psShape->padfM + i );
- }
- psShape->bMeasureIsUsed = TRUE;
- }
- else if( psShape->bFastModeReadObject )
- {
- psShape->padfM = NULL;
- }
- }
-
-/* ==================================================================== */
-/* Extract vertices for a MultiPoint. */
-/* ==================================================================== */
- else if( psShape->nSHPType == SHPT_MULTIPOINT
- || psShape->nSHPType == SHPT_MULTIPOINTM
- || psShape->nSHPType == SHPT_MULTIPOINTZ )
- {
- int32 nPoints;
- int i, nOffset;
- unsigned char* pBuffer = NULL;
- unsigned char** ppBuffer = NULL;
-
- if ( 44 + 4 > nEntitySize )
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Corrupted .shp file : shape %d : nEntitySize = %d",
- hEntity, nEntitySize);
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
- memcpy( &nPoints, psSHP->pabyRec + 44, 4 );
-
- if( bBigEndian ) SwapWord( 4, &nPoints );
-
- /* nPoints is unsigned */
- if (/* nPoints < 0 || */ nPoints > 50 * 1000 * 1000)
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Corrupted .shp file : shape %d : nPoints = %u",
- hEntity, nPoints);
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
-
- nRequiredSize = 48 + nPoints * 16;
- if( psShape->nSHPType == SHPT_MULTIPOINTZ )
- {
- nRequiredSize += 16 + nPoints * 8;
- }
- if (nRequiredSize > nEntitySize)
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Corrupted .shp file : shape %d : nPoints = %u, nEntitySize = %d",
- hEntity, nPoints, nEntitySize);
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
-
- if( psShape->bFastModeReadObject )
- {
- int nObjectBufSize = 4 * sizeof(double) * nPoints;
- pBuffer = SHPReallocObjectBufIfNecessary(psSHP, nObjectBufSize);
- ppBuffer = &pBuffer;
- }
-
- psShape->nVertices = nPoints;
-
- psShape->padfX = (double *) SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints);
- psShape->padfY = (double *) SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints);
- psShape->padfZ = (double *) SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints);
- psShape->padfM = (double *) SHPAllocBuffer(ppBuffer, sizeof(double) * nPoints);
-
- if (psShape->padfX == NULL ||
- psShape->padfY == NULL ||
- psShape->padfZ == NULL ||
- psShape->padfM == NULL)
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Not enough memory to allocate requested memory (nPoints=%u) for shape %d. "
- "Probably broken SHP file", nPoints, hEntity );
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
-
- for( i = 0; (int32)i < nPoints; i++ )
- {
- memcpy(psShape->padfX+i, psSHP->pabyRec + 48 + 16 * i, 8 );
- memcpy(psShape->padfY+i, psSHP->pabyRec + 48 + 16 * i + 8, 8 );
-
- if( bBigEndian ) SwapWord( 8, psShape->padfX + i );
- if( bBigEndian ) SwapWord( 8, psShape->padfY + i );
- }
-
- nOffset = 48 + 16*nPoints;
-
-/* -------------------------------------------------------------------- */
-/* Get the X/Y bounds. */
-/* -------------------------------------------------------------------- */
- memcpy( &(psShape->dfXMin), psSHP->pabyRec + 8 + 4, 8 );
- memcpy( &(psShape->dfYMin), psSHP->pabyRec + 8 + 12, 8 );
- memcpy( &(psShape->dfXMax), psSHP->pabyRec + 8 + 20, 8 );
- memcpy( &(psShape->dfYMax), psSHP->pabyRec + 8 + 28, 8 );
-
- if( bBigEndian ) SwapWord( 8, &(psShape->dfXMin) );
- if( bBigEndian ) SwapWord( 8, &(psShape->dfYMin) );
- if( bBigEndian ) SwapWord( 8, &(psShape->dfXMax) );
- if( bBigEndian ) SwapWord( 8, &(psShape->dfYMax) );
-
-/* -------------------------------------------------------------------- */
-/* If we have a Z coordinate, collect that now. */
-/* -------------------------------------------------------------------- */
- if( psShape->nSHPType == SHPT_MULTIPOINTZ )
- {
- memcpy( &(psShape->dfZMin), psSHP->pabyRec + nOffset, 8 );
- memcpy( &(psShape->dfZMax), psSHP->pabyRec + nOffset + 8, 8 );
-
- if( bBigEndian ) SwapWord( 8, &(psShape->dfZMin) );
- if( bBigEndian ) SwapWord( 8, &(psShape->dfZMax) );
-
- for( i = 0; (int32)i < nPoints; i++ )
- {
- memcpy( psShape->padfZ + i,
- psSHP->pabyRec + nOffset + 16 + i*8, 8 );
- if( bBigEndian ) SwapWord( 8, psShape->padfZ + i );
- }
-
- nOffset += 16 + 8*nPoints;
- }
- else if( psShape->bFastModeReadObject )
- psShape->padfZ = NULL;
-
-/* -------------------------------------------------------------------- */
-/* If we have a M measure value, then read it now. We assume */
-/* that the measure can be present for any shape if the size is */
-/* big enough, but really it will only occur for the Z shapes */
-/* (options), and the M shapes. */
-/* -------------------------------------------------------------------- */
- if( nEntitySize >= (int)(nOffset + 16 + 8*nPoints) )
- {
- memcpy( &(psShape->dfMMin), psSHP->pabyRec + nOffset, 8 );
- memcpy( &(psShape->dfMMax), psSHP->pabyRec + nOffset + 8, 8 );
-
- if( bBigEndian ) SwapWord( 8, &(psShape->dfMMin) );
- if( bBigEndian ) SwapWord( 8, &(psShape->dfMMax) );
-
- for( i = 0; (int32)i < nPoints; i++ )
- {
- memcpy( psShape->padfM + i,
- psSHP->pabyRec + nOffset + 16 + i*8, 8 );
- if( bBigEndian ) SwapWord( 8, psShape->padfM + i );
- }
- psShape->bMeasureIsUsed = TRUE;
- }
- else if( psShape->bFastModeReadObject )
- psShape->padfM = NULL;
- }
-
-/* ==================================================================== */
-/* Extract vertices for a point. */
-/* ==================================================================== */
- else if( psShape->nSHPType == SHPT_POINT
- || psShape->nSHPType == SHPT_POINTM
- || psShape->nSHPType == SHPT_POINTZ )
- {
- int nOffset;
-
- psShape->nVertices = 1;
- if( psShape->bFastModeReadObject )
- {
- psShape->padfX = &(psShape->dfXMin);
- psShape->padfY = &(psShape->dfYMin);
- psShape->padfZ = &(psShape->dfZMin);
- psShape->padfM = &(psShape->dfMMin);
- psShape->padfZ[0] = 0.0;
- psShape->padfM[0] = 0.0;
- }
- else
- {
- psShape->padfX = (double *) calloc(1,sizeof(double));
- psShape->padfY = (double *) calloc(1,sizeof(double));
- psShape->padfZ = (double *) calloc(1,sizeof(double));
- psShape->padfM = (double *) calloc(1,sizeof(double));
- }
-
- if (20 + 8 + (( psShape->nSHPType == SHPT_POINTZ ) ? 8 : 0)> nEntitySize)
- {
- snprintf(szErrorMsg, sizeof(szErrorMsg),
- "Corrupted .shp file : shape %d : nEntitySize = %d",
- hEntity, nEntitySize);
- psSHP->sHooks.Error( szErrorMsg );
- SHPDestroyObject(psShape);
- return NULL;
- }
- memcpy( psShape->padfX, psSHP->pabyRec + 12, 8 );
- memcpy( psShape->padfY, psSHP->pabyRec + 20, 8 );
-
- if( bBigEndian ) SwapWord( 8, psShape->padfX );
- if( bBigEndian ) SwapWord( 8, psShape->padfY );
-
- nOffset = 20 + 8;
-
-/* -------------------------------------------------------------------- */
-/* If we have a Z coordinate, collect that now. */
-/* -------------------------------------------------------------------- */
- if( psShape->nSHPType == SHPT_POINTZ )
- {
- memcpy( psShape->padfZ, psSHP->pabyRec + nOffset, 8 );
-
- if( bBigEndian ) SwapWord( 8, psShape->padfZ );
-
- nOffset += 8;
- }
-
-/* -------------------------------------------------------------------- */
-/* If we have a M measure value, then read it now. We assume */
-/* that the measure can be present for any shape if the size is */
-/* big enough, but really it will only occur for the Z shapes */
-/* (options), and the M shapes. */
-/* -------------------------------------------------------------------- */
- if( nEntitySize >= nOffset + 8 )
- {
- memcpy( psShape->padfM, psSHP->pabyRec + nOffset, 8 );
-
- if( bBigEndian ) SwapWord( 8, psShape->padfM );
- psShape->bMeasureIsUsed = TRUE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Since no extents are supplied in the record, we will apply */
-/* them from the single vertex. */
-/* -------------------------------------------------------------------- */
- psShape->dfXMin = psShape->dfXMax = psShape->padfX[0];
- psShape->dfYMin = psShape->dfYMax = psShape->padfY[0];
- psShape->dfZMin = psShape->dfZMax = psShape->padfZ[0];
- psShape->dfMMin = psShape->dfMMax = psShape->padfM[0];
- }
-
- return( psShape );
-}
-
-/************************************************************************/
-/* SHPTypeName() */
-/************************************************************************/
-
-const char SHPAPI_CALL1(*)
-SHPTypeName( int nSHPType )
-
-{
- switch( nSHPType )
- {
- case SHPT_NULL:
- return "NullShape";
-
- case SHPT_POINT:
- return "Point";
-
- case SHPT_ARC:
- return "Arc";
-
- case SHPT_POLYGON:
- return "Polygon";
-
- case SHPT_MULTIPOINT:
- return "MultiPoint";
-
- case SHPT_POINTZ:
- return "PointZ";
-
- case SHPT_ARCZ:
- return "ArcZ";
-
- case SHPT_POLYGONZ:
- return "PolygonZ";
-
- case SHPT_MULTIPOINTZ:
- return "MultiPointZ";
-
- case SHPT_POINTM:
- return "PointM";
-
- case SHPT_ARCM:
- return "ArcM";
-
- case SHPT_POLYGONM:
- return "PolygonM";
-
- case SHPT_MULTIPOINTM:
- return "MultiPointM";
-
- case SHPT_MULTIPATCH:
- return "MultiPatch";
-
- default:
- return "UnknownShapeType";
- }
-}
-
-/************************************************************************/
-/* SHPPartTypeName() */
-/************************************************************************/
-
-const char SHPAPI_CALL1(*)
-SHPPartTypeName( int nPartType )
-
-{
- switch( nPartType )
- {
- case SHPP_TRISTRIP:
- return "TriangleStrip";
-
- case SHPP_TRIFAN:
- return "TriangleFan";
-
- case SHPP_OUTERRING:
- return "OuterRing";
-
- case SHPP_INNERRING:
- return "InnerRing";
-
- case SHPP_FIRSTRING:
- return "FirstRing";
-
- case SHPP_RING:
- return "Ring";
-
- default:
- return "UnknownPartType";
- }
-}
-
-/************************************************************************/
-/* SHPDestroyObject() */
-/************************************************************************/
-
-void SHPAPI_CALL
-SHPDestroyObject( SHPObject * psShape )
-
-{
- if( psShape == NULL )
- return;
-
- if( psShape->bFastModeReadObject )
- {
- psShape->bFastModeReadObject = FALSE;
- return;
- }
-
- if( psShape->padfX != NULL )
- free( psShape->padfX );
- if( psShape->padfY != NULL )
- free( psShape->padfY );
- if( psShape->padfZ != NULL )
- free( psShape->padfZ );
- if( psShape->padfM != NULL )
- free( psShape->padfM );
-
- if( psShape->panPartStart != NULL )
- free( psShape->panPartStart );
- if( psShape->panPartType != NULL )
- free( psShape->panPartType );
-
- free( psShape );
-}
-
-/************************************************************************/
-/* SHPRewindObject() */
-/* */
-/* Reset the winding of polygon objects to adhere to the */
-/* specification. */
-/************************************************************************/
-
-int SHPAPI_CALL
-SHPRewindObject( CPL_UNUSED SHPHandle hSHP,
- SHPObject * psObject )
-{
- int iOpRing, bAltered = 0;
-
-/* -------------------------------------------------------------------- */
-/* Do nothing if this is not a polygon object. */
-/* -------------------------------------------------------------------- */
- if( psObject->nSHPType != SHPT_POLYGON
- && psObject->nSHPType != SHPT_POLYGONZ
- && psObject->nSHPType != SHPT_POLYGONM )
- return 0;
-
- if( psObject->nVertices == 0 || psObject->nParts == 0 )
- return 0;
-
-/* -------------------------------------------------------------------- */
-/* Process each of the rings. */
-/* -------------------------------------------------------------------- */
- for( iOpRing = 0; iOpRing < psObject->nParts; iOpRing++ )
- {
- int bInner, iVert, nVertCount, nVertStart, iCheckRing;
- double dfSum, dfTestX, dfTestY;
-
-/* -------------------------------------------------------------------- */
-/* Determine if this ring is an inner ring or an outer ring */
-/* relative to all the other rings. For now we assume the */
-/* first ring is outer and all others are inner, but eventually */
-/* we need to fix this to handle multiple island polygons and */
-/* unordered sets of rings. */
-/* */
-/* -------------------------------------------------------------------- */
-
- /* Use point in the middle of segment to avoid testing
- * common points of rings.
- */
- dfTestX = ( psObject->padfX[psObject->panPartStart[iOpRing]]
- + psObject->padfX[psObject->panPartStart[iOpRing] + 1] ) / 2;
- dfTestY = ( psObject->padfY[psObject->panPartStart[iOpRing]]
- + psObject->padfY[psObject->panPartStart[iOpRing] + 1] ) / 2;
-
- bInner = FALSE;
- for( iCheckRing = 0; iCheckRing < psObject->nParts; iCheckRing++ )
- {
- int iEdge;
-
- if( iCheckRing == iOpRing )
- continue;
-
- nVertStart = psObject->panPartStart[iCheckRing];
-
- if( iCheckRing == psObject->nParts-1 )
- nVertCount = psObject->nVertices
- - psObject->panPartStart[iCheckRing];
- else
- nVertCount = psObject->panPartStart[iCheckRing+1]
- - psObject->panPartStart[iCheckRing];
-
- for( iEdge = 0; iEdge < nVertCount; iEdge++ )
- {
- int iNext;
-
- if( iEdge < nVertCount-1 )
- iNext = iEdge+1;
- else
- iNext = 0;
-
- /* Rule #1:
- * Test whether the edge 'straddles' the horizontal ray from the test point (dfTestY,dfTestY)
- * The rule #1 also excludes edges colinear with the ray.
- */
- if ( ( psObject->padfY[iEdge+nVertStart] < dfTestY
- && dfTestY <= psObject->padfY[iNext+nVertStart] )
- || ( psObject->padfY[iNext+nVertStart] < dfTestY
- && dfTestY <= psObject->padfY[iEdge+nVertStart] ) )
- {
- /* Rule #2:
- * Test if edge-ray intersection is on the right from the test point (dfTestY,dfTestY)
- */
- double const intersect =
- ( psObject->padfX[iEdge+nVertStart]
- + ( dfTestY - psObject->padfY[iEdge+nVertStart] )
- / ( psObject->padfY[iNext+nVertStart] - psObject->padfY[iEdge+nVertStart] )
- * ( psObject->padfX[iNext+nVertStart] - psObject->padfX[iEdge+nVertStart] ) );
-
- if (intersect < dfTestX)
- {
- bInner = !bInner;
- }
- }
- }
- } /* for iCheckRing */
-
-/* -------------------------------------------------------------------- */
-/* Determine the current order of this ring so we will know if */
-/* it has to be reversed. */
-/* -------------------------------------------------------------------- */
- nVertStart = psObject->panPartStart[iOpRing];
-
- if( iOpRing == psObject->nParts-1 )
- nVertCount = psObject->nVertices - psObject->panPartStart[iOpRing];
- else
- nVertCount = psObject->panPartStart[iOpRing+1]
- - psObject->panPartStart[iOpRing];
-
- if (nVertCount < 2)
- continue;
-
- dfSum = psObject->padfX[nVertStart] * (psObject->padfY[nVertStart+1] - psObject->padfY[nVertStart+nVertCount-1]);
- for( iVert = nVertStart + 1; iVert < nVertStart+nVertCount-1; iVert++ )
- {
- dfSum += psObject->padfX[iVert] * (psObject->padfY[iVert+1] - psObject->padfY[iVert-1]);
- }
-
- dfSum += psObject->padfX[iVert] * (psObject->padfY[nVertStart] - psObject->padfY[iVert-1]);
-
-/* -------------------------------------------------------------------- */
-/* Reverse if necessary. */
-/* -------------------------------------------------------------------- */
- if( (dfSum < 0.0 && bInner) || (dfSum > 0.0 && !bInner) )
- {
- int i;
-
- bAltered++;
- for( i = 0; i < nVertCount/2; i++ )
- {
- double dfSaved;
-
- /* Swap X */
- dfSaved = psObject->padfX[nVertStart+i];
- psObject->padfX[nVertStart+i] =
- psObject->padfX[nVertStart+nVertCount-i-1];
- psObject->padfX[nVertStart+nVertCount-i-1] = dfSaved;
-
- /* Swap Y */
- dfSaved = psObject->padfY[nVertStart+i];
- psObject->padfY[nVertStart+i] =
- psObject->padfY[nVertStart+nVertCount-i-1];
- psObject->padfY[nVertStart+nVertCount-i-1] = dfSaved;
-
- /* Swap Z */
- if( psObject->padfZ )
- {
- dfSaved = psObject->padfZ[nVertStart+i];
- psObject->padfZ[nVertStart+i] =
- psObject->padfZ[nVertStart+nVertCount-i-1];
- psObject->padfZ[nVertStart+nVertCount-i-1] = dfSaved;
- }
-
- /* Swap M */
- if( psObject->padfM )
- {
- dfSaved = psObject->padfM[nVertStart+i];
- psObject->padfM[nVertStart+i] =
- psObject->padfM[nVertStart+nVertCount-i-1];
- psObject->padfM[nVertStart+nVertCount-i-1] = dfSaved;
- }
- }
- }
- }
-
- return bAltered;
-}
diff --git a/navit/support/shapefile/shptree.c b/navit/support/shapefile/shptree.c
deleted file mode 100644
index d81533c95..000000000
--- a/navit/support/shapefile/shptree.c
+++ /dev/null
@@ -1,1266 +0,0 @@
-/******************************************************************************
- * $Id: shptree.c,v 1.19 2016-12-05 12:44:06 erouault Exp $
- *
- * Project: Shapelib
- * Purpose: Implementation of quadtree building and searching functions.
- * Author: Frank Warmerdam, warmerdam@pobox.com
- *
- ******************************************************************************
- * Copyright (c) 1999, Frank Warmerdam
- * Copyright (c) 2012, Even Rouault <even dot rouault at mines-paris dot org>
- *
- * This software is available under the following "MIT Style" license,
- * or at the option of the licensee under the LGPL (see COPYING). This
- * option is discussed in more detail in shapelib.html.
- *
- * --
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- ******************************************************************************
- *
- * $Log: shptree.c,v $
- * Revision 1.19 2016-12-05 12:44:06 erouault
- * * Major overhaul of Makefile build system to use autoconf/automake.
- *
- * * Warning fixes in contrib/
- *
- * Revision 1.18 2016-12-04 15:30:15 erouault
- * * shpopen.c, dbfopen.c, shptree.c, shapefil.h: resync with
- * GDAL Shapefile driver. Mostly cleanups. SHPObject and DBFInfo
- * structures extended with new members. New functions:
- * DBFSetLastModifiedDate, SHPOpenLLEx, SHPRestoreSHX,
- * SHPSetFastModeReadObject
- *
- * * sbnsearch.c: new file to implement original ESRI .sbn spatial
- * index reading. (no write support). New functions:
- * SBNOpenDiskTree, SBNCloseDiskTree, SBNSearchDiskTree,
- * SBNSearchDiskTreeInteger, SBNSearchFreeIds
- *
- * * Makefile, makefile.vc, CMakeLists.txt, shapelib.def: updates
- * with new file and symbols.
- *
- * * commit: helper script to cvs commit
- *
- * Revision 1.17 2012-01-27 21:09:26 fwarmerdam
- * optimize .qix output (gdal #4472)
- *
- * Revision 1.16 2011-12-11 22:26:46 fwarmerdam
- * upgrade .qix access code to use SAHooks (gdal #3365)
- *
- * Revision 1.15 2011-07-24 05:59:25 fwarmerdam
- * minimize use of CPLError in favor of SAHooks.Error()
- *
- * Revision 1.14 2010-08-27 23:43:27 fwarmerdam
- * add SHPAPI_CALL attribute in code
- *
- * Revision 1.13 2010-06-29 05:50:15 fwarmerdam
- * fix sign of Z/M comparisons in SHPCheckObjectContained (#2223)
- *
- * Revision 1.12 2008-11-12 15:39:50 fwarmerdam
- * improve safety in face of buggy .shp file.
- *
- * Revision 1.11 2007/10/27 03:31:14 fwarmerdam
- * limit default depth of tree to 12 levels (gdal ticket #1594)
- *
- * Revision 1.10 2005/01/03 22:30:13 fwarmerdam
- * added support for saved quadtrees
- *
- * Revision 1.9 2003/01/28 15:53:41 warmerda
- * Avoid build warnings.
- *
- * Revision 1.8 2002/05/07 13:07:45 warmerda
- * use qsort() - patch from Bernhard Herzog
- *
- * Revision 1.7 2002/01/15 14:36:07 warmerda
- * updated email address
- *
- * Revision 1.6 2001/05/23 13:36:52 warmerda
- * added use of SHPAPI_CALL
- *
- * Revision 1.5 1999/11/05 14:12:05 warmerda
- * updated license terms
- *
- * Revision 1.4 1999/06/02 18:24:21 warmerda
- * added trimming code
- *
- * Revision 1.3 1999/06/02 17:56:12 warmerda
- * added quad'' subnode support for trees
- *
- * Revision 1.2 1999/05/18 19:11:11 warmerda
- * Added example searching capability
- *
- * Revision 1.1 1999/05/18 17:49:20 warmerda
- * New
- *
- */
-
-#include "shapefil.h"
-
-#include <math.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-
-#ifdef USE_CPL
-#include "cpl_error.h"
-#endif
-
-SHP_CVSID("$Id: shptree.c,v 1.19 2016-12-05 12:44:06 erouault Exp $")
-
-#ifndef TRUE
-# define TRUE 1
-# define FALSE 0
-#endif
-
-static int bBigEndian = 0;
-
-
-/* -------------------------------------------------------------------- */
-/* If the following is 0.5, nodes will be split in half. If it */
-/* is 0.6 then each subnode will contain 60% of the parent */
-/* node, with 20% representing overlap. This can be help to */
-/* prevent small objects on a boundary from shifting too high */
-/* up the tree. */
-/* -------------------------------------------------------------------- */
-
-#define SHP_SPLIT_RATIO 0.55
-
-/************************************************************************/
-/* SfRealloc() */
-/* */
-/* A realloc cover function that will access a NULL pointer as */
-/* a valid input. */
-/************************************************************************/
-
-static void * SfRealloc( void * pMem, int nNewSize )
-
-{
- if( pMem == NULL )
- return( (void *) malloc(nNewSize) );
- else
- return( (void *) realloc(pMem,nNewSize) );
-}
-
-/************************************************************************/
-/* SHPTreeNodeInit() */
-/* */
-/* Initialize a tree node. */
-/************************************************************************/
-
-static SHPTreeNode *SHPTreeNodeCreate( double * padfBoundsMin,
- double * padfBoundsMax )
-
-{
- SHPTreeNode *psTreeNode;
-
- psTreeNode = (SHPTreeNode *) malloc(sizeof(SHPTreeNode));
- if( NULL == psTreeNode )
- return NULL;
-
- psTreeNode->nShapeCount = 0;
- psTreeNode->panShapeIds = NULL;
- psTreeNode->papsShapeObj = NULL;
-
- psTreeNode->nSubNodes = 0;
-
- if( padfBoundsMin != NULL )
- memcpy( psTreeNode->adfBoundsMin, padfBoundsMin, sizeof(double) * 4 );
-
- if( padfBoundsMax != NULL )
- memcpy( psTreeNode->adfBoundsMax, padfBoundsMax, sizeof(double) * 4 );
-
- return psTreeNode;
-}
-
-
-/************************************************************************/
-/* SHPCreateTree() */
-/************************************************************************/
-
-SHPTree SHPAPI_CALL1(*)
- SHPCreateTree( SHPHandle hSHP, int nDimension, int nMaxDepth,
- double *padfBoundsMin, double *padfBoundsMax )
-
-{
- SHPTree *psTree;
-
- if( padfBoundsMin == NULL && hSHP == NULL )
- return NULL;
-
-/* -------------------------------------------------------------------- */
-/* Allocate the tree object */
-/* -------------------------------------------------------------------- */
- psTree = (SHPTree *) malloc(sizeof(SHPTree));
- if( NULL == psTree )
- {
- return NULL;
- }
-
- psTree->hSHP = hSHP;
- psTree->nMaxDepth = nMaxDepth;
- psTree->nDimension = nDimension;
- psTree->nTotalCount = 0;
-
-/* -------------------------------------------------------------------- */
-/* If no max depth was defined, try to select a reasonable one */
-/* that implies approximately 8 shapes per node. */
-/* -------------------------------------------------------------------- */
- if( psTree->nMaxDepth == 0 && hSHP != NULL )
- {
- int nMaxNodeCount = 1;
- int nShapeCount;
-
- SHPGetInfo( hSHP, &nShapeCount, NULL, NULL, NULL );
- while( nMaxNodeCount*4 < nShapeCount )
- {
- psTree->nMaxDepth += 1;
- nMaxNodeCount = nMaxNodeCount * 2;
- }
-
-#ifdef USE_CPL
- CPLDebug( "Shape",
- "Estimated spatial index tree depth: %d",
- psTree->nMaxDepth );
-#endif
-
- /* NOTE: Due to problems with memory allocation for deep trees,
- * automatically estimated depth is limited up to 12 levels.
- * See Ticket #1594 for detailed discussion.
- */
- if( psTree->nMaxDepth > MAX_DEFAULT_TREE_DEPTH )
- {
- psTree->nMaxDepth = MAX_DEFAULT_TREE_DEPTH;
-
-#ifdef USE_CPL
- CPLDebug( "Shape",
- "Falling back to max number of allowed index tree levels (%d).",
- MAX_DEFAULT_TREE_DEPTH );
-#endif
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* Allocate the root node. */
-/* -------------------------------------------------------------------- */
- psTree->psRoot = SHPTreeNodeCreate( padfBoundsMin, padfBoundsMax );
- if( NULL == psTree->psRoot )
- {
- free( psTree );
- return NULL;
- }
-
-/* -------------------------------------------------------------------- */
-/* Assign the bounds to the root node. If none are passed in, */
-/* use the bounds of the provided file otherwise the create */
-/* function will have already set the bounds. */
-/* -------------------------------------------------------------------- */
- if( padfBoundsMin == NULL )
- {
- SHPGetInfo( hSHP, NULL, NULL,
- psTree->psRoot->adfBoundsMin,
- psTree->psRoot->adfBoundsMax );
- }
-
-/* -------------------------------------------------------------------- */
-/* If we have a file, insert all it's shapes into the tree. */
-/* -------------------------------------------------------------------- */
- if( hSHP != NULL )
- {
- int iShape, nShapeCount;
-
- SHPGetInfo( hSHP, &nShapeCount, NULL, NULL, NULL );
-
- for( iShape = 0; iShape < nShapeCount; iShape++ )
- {
- SHPObject *psShape;
-
- psShape = SHPReadObject( hSHP, iShape );
- if( psShape != NULL )
- {
- SHPTreeAddShapeId( psTree, psShape );
- SHPDestroyObject( psShape );
- }
- }
- }
-
- return psTree;
-}
-
-/************************************************************************/
-/* SHPDestroyTreeNode() */
-/************************************************************************/
-
-static void SHPDestroyTreeNode( SHPTreeNode * psTreeNode )
-
-{
- int i;
-
- assert( NULL != psTreeNode );
-
- for( i = 0; i < psTreeNode->nSubNodes; i++ )
- {
- if( psTreeNode->apsSubNode[i] != NULL )
- SHPDestroyTreeNode( psTreeNode->apsSubNode[i] );
- }
-
- if( psTreeNode->panShapeIds != NULL )
- free( psTreeNode->panShapeIds );
-
- if( psTreeNode->papsShapeObj != NULL )
- {
- for( i = 0; i < psTreeNode->nShapeCount; i++ )
- {
- if( psTreeNode->papsShapeObj[i] != NULL )
- SHPDestroyObject( psTreeNode->papsShapeObj[i] );
- }
-
- free( psTreeNode->papsShapeObj );
- }
-
- free( psTreeNode );
-}
-
-/************************************************************************/
-/* SHPDestroyTree() */
-/************************************************************************/
-
-void SHPAPI_CALL
-SHPDestroyTree( SHPTree * psTree )
-
-{
- SHPDestroyTreeNode( psTree->psRoot );
- free( psTree );
-}
-
-/************************************************************************/
-/* SHPCheckBoundsOverlap() */
-/* */
-/* Do the given boxes overlap at all? */
-/************************************************************************/
-
-int SHPAPI_CALL
-SHPCheckBoundsOverlap( double * padfBox1Min, double * padfBox1Max,
- double * padfBox2Min, double * padfBox2Max,
- int nDimension )
-
-{
- int iDim;
-
- for( iDim = 0; iDim < nDimension; iDim++ )
- {
- if( padfBox2Max[iDim] < padfBox1Min[iDim] )
- return FALSE;
-
- if( padfBox1Max[iDim] < padfBox2Min[iDim] )
- return FALSE;
- }
-
- return TRUE;
-}
-
-/************************************************************************/
-/* SHPCheckObjectContained() */
-/* */
-/* Does the given shape fit within the indicated extents? */
-/************************************************************************/
-
-static int SHPCheckObjectContained( SHPObject * psObject, int nDimension,
- double * padfBoundsMin, double * padfBoundsMax )
-
-{
- if( psObject->dfXMin < padfBoundsMin[0]
- || psObject->dfXMax > padfBoundsMax[0] )
- return FALSE;
-
- if( psObject->dfYMin < padfBoundsMin[1]
- || psObject->dfYMax > padfBoundsMax[1] )
- return FALSE;
-
- if( nDimension == 2 )
- return TRUE;
-
- if( psObject->dfZMin < padfBoundsMin[2]
- || psObject->dfZMax > padfBoundsMax[2] )
- return FALSE;
-
- if( nDimension == 3 )
- return TRUE;
-
- if( psObject->dfMMin < padfBoundsMin[3]
- || psObject->dfMMax > padfBoundsMax[3] )
- return FALSE;
-
- return TRUE;
-}
-
-/************************************************************************/
-/* SHPTreeSplitBounds() */
-/* */
-/* Split a region into two subregion evenly, cutting along the */
-/* longest dimension. */
-/************************************************************************/
-
-static void
-SHPTreeSplitBounds( double *padfBoundsMinIn, double *padfBoundsMaxIn,
- double *padfBoundsMin1, double * padfBoundsMax1,
- double *padfBoundsMin2, double * padfBoundsMax2 )
-
-{
-/* -------------------------------------------------------------------- */
-/* The output bounds will be very similar to the input bounds, */
-/* so just copy over to start. */
-/* -------------------------------------------------------------------- */
- memcpy( padfBoundsMin1, padfBoundsMinIn, sizeof(double) * 4 );
- memcpy( padfBoundsMax1, padfBoundsMaxIn, sizeof(double) * 4 );
- memcpy( padfBoundsMin2, padfBoundsMinIn, sizeof(double) * 4 );
- memcpy( padfBoundsMax2, padfBoundsMaxIn, sizeof(double) * 4 );
-
-/* -------------------------------------------------------------------- */
-/* Split in X direction. */
-/* -------------------------------------------------------------------- */
- if( (padfBoundsMaxIn[0] - padfBoundsMinIn[0])
- > (padfBoundsMaxIn[1] - padfBoundsMinIn[1]) )
- {
- double dfRange = padfBoundsMaxIn[0] - padfBoundsMinIn[0];
-
- padfBoundsMax1[0] = padfBoundsMinIn[0] + dfRange * SHP_SPLIT_RATIO;
- padfBoundsMin2[0] = padfBoundsMaxIn[0] - dfRange * SHP_SPLIT_RATIO;
- }
-
-/* -------------------------------------------------------------------- */
-/* Otherwise split in Y direction. */
-/* -------------------------------------------------------------------- */
- else
- {
- double dfRange = padfBoundsMaxIn[1] - padfBoundsMinIn[1];
-
- padfBoundsMax1[1] = padfBoundsMinIn[1] + dfRange * SHP_SPLIT_RATIO;
- padfBoundsMin2[1] = padfBoundsMaxIn[1] - dfRange * SHP_SPLIT_RATIO;
- }
-}
-
-/************************************************************************/
-/* SHPTreeNodeAddShapeId() */
-/************************************************************************/
-
-static int
-SHPTreeNodeAddShapeId( SHPTreeNode * psTreeNode, SHPObject * psObject,
- int nMaxDepth, int nDimension )
-
-{
- int i;
-
-/* -------------------------------------------------------------------- */
-/* If there are subnodes, then consider whether this object */
-/* will fit in them. */
-/* -------------------------------------------------------------------- */
- if( nMaxDepth > 1 && psTreeNode->nSubNodes > 0 )
- {
- for( i = 0; i < psTreeNode->nSubNodes; i++ )
- {
- if( SHPCheckObjectContained(psObject, nDimension,
- psTreeNode->apsSubNode[i]->adfBoundsMin,
- psTreeNode->apsSubNode[i]->adfBoundsMax))
- {
- return SHPTreeNodeAddShapeId( psTreeNode->apsSubNode[i],
- psObject, nMaxDepth-1,
- nDimension );
- }
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* Otherwise, consider creating four subnodes if could fit into */
-/* them, and adding to the appropriate subnode. */
-/* -------------------------------------------------------------------- */
-#if MAX_SUBNODE == 4
- else if( nMaxDepth > 1 && psTreeNode->nSubNodes == 0 )
- {
- double adfBoundsMinH1[4], adfBoundsMaxH1[4];
- double adfBoundsMinH2[4], adfBoundsMaxH2[4];
- double adfBoundsMin1[4], adfBoundsMax1[4];
- double adfBoundsMin2[4], adfBoundsMax2[4];
- double adfBoundsMin3[4], adfBoundsMax3[4];
- double adfBoundsMin4[4], adfBoundsMax4[4];
-
- SHPTreeSplitBounds( psTreeNode->adfBoundsMin,
- psTreeNode->adfBoundsMax,
- adfBoundsMinH1, adfBoundsMaxH1,
- adfBoundsMinH2, adfBoundsMaxH2 );
-
- SHPTreeSplitBounds( adfBoundsMinH1, adfBoundsMaxH1,
- adfBoundsMin1, adfBoundsMax1,
- adfBoundsMin2, adfBoundsMax2 );
-
- SHPTreeSplitBounds( adfBoundsMinH2, adfBoundsMaxH2,
- adfBoundsMin3, adfBoundsMax3,
- adfBoundsMin4, adfBoundsMax4 );
-
- if( SHPCheckObjectContained(psObject, nDimension,
- adfBoundsMin1, adfBoundsMax1)
- || SHPCheckObjectContained(psObject, nDimension,
- adfBoundsMin2, adfBoundsMax2)
- || SHPCheckObjectContained(psObject, nDimension,
- adfBoundsMin3, adfBoundsMax3)
- || SHPCheckObjectContained(psObject, nDimension,
- adfBoundsMin4, adfBoundsMax4) )
- {
- psTreeNode->nSubNodes = 4;
- psTreeNode->apsSubNode[0] = SHPTreeNodeCreate( adfBoundsMin1,
- adfBoundsMax1 );
- psTreeNode->apsSubNode[1] = SHPTreeNodeCreate( adfBoundsMin2,
- adfBoundsMax2 );
- psTreeNode->apsSubNode[2] = SHPTreeNodeCreate( adfBoundsMin3,
- adfBoundsMax3 );
- psTreeNode->apsSubNode[3] = SHPTreeNodeCreate( adfBoundsMin4,
- adfBoundsMax4 );
-
- /* recurse back on this node now that it has subnodes */
- return( SHPTreeNodeAddShapeId( psTreeNode, psObject,
- nMaxDepth, nDimension ) );
- }
- }
-#endif /* MAX_SUBNODE == 4 */
-
-/* -------------------------------------------------------------------- */
-/* Otherwise, consider creating two subnodes if could fit into */
-/* them, and adding to the appropriate subnode. */
-/* -------------------------------------------------------------------- */
-#if MAX_SUBNODE == 2
- else if( nMaxDepth > 1 && psTreeNode->nSubNodes == 0 )
- {
- double adfBoundsMin1[4], adfBoundsMax1[4];
- double adfBoundsMin2[4], adfBoundsMax2[4];
-
- SHPTreeSplitBounds( psTreeNode->adfBoundsMin, psTreeNode->adfBoundsMax,
- adfBoundsMin1, adfBoundsMax1,
- adfBoundsMin2, adfBoundsMax2 );
-
- if( SHPCheckObjectContained(psObject, nDimension,
- adfBoundsMin1, adfBoundsMax1))
- {
- psTreeNode->nSubNodes = 2;
- psTreeNode->apsSubNode[0] = SHPTreeNodeCreate( adfBoundsMin1,
- adfBoundsMax1 );
- psTreeNode->apsSubNode[1] = SHPTreeNodeCreate( adfBoundsMin2,
- adfBoundsMax2 );
-
- return( SHPTreeNodeAddShapeId( psTreeNode->apsSubNode[0], psObject,
- nMaxDepth - 1, nDimension ) );
- }
- else if( SHPCheckObjectContained(psObject, nDimension,
- adfBoundsMin2, adfBoundsMax2) )
- {
- psTreeNode->nSubNodes = 2;
- psTreeNode->apsSubNode[0] = SHPTreeNodeCreate( adfBoundsMin1,
- adfBoundsMax1 );
- psTreeNode->apsSubNode[1] = SHPTreeNodeCreate( adfBoundsMin2,
- adfBoundsMax2 );
-
- return( SHPTreeNodeAddShapeId( psTreeNode->apsSubNode[1], psObject,
- nMaxDepth - 1, nDimension ) );
- }
- }
-#endif /* MAX_SUBNODE == 2 */
-
-/* -------------------------------------------------------------------- */
-/* If none of that worked, just add it to this nodes list. */
-/* -------------------------------------------------------------------- */
- psTreeNode->nShapeCount++;
-
- psTreeNode->panShapeIds = (int *)
- SfRealloc( psTreeNode->panShapeIds,
- sizeof(int) * psTreeNode->nShapeCount );
- psTreeNode->panShapeIds[psTreeNode->nShapeCount-1] = psObject->nShapeId;
-
- if( psTreeNode->papsShapeObj != NULL )
- {
- psTreeNode->papsShapeObj = (SHPObject **)
- SfRealloc( psTreeNode->papsShapeObj,
- sizeof(void *) * psTreeNode->nShapeCount );
- psTreeNode->papsShapeObj[psTreeNode->nShapeCount-1] = NULL;
- }
-
- return TRUE;
-}
-
-/************************************************************************/
-/* SHPTreeAddShapeId() */
-/* */
-/* Add a shape to the tree, but don't keep a pointer to the */
-/* object data, just keep the shapeid. */
-/************************************************************************/
-
-int SHPAPI_CALL
-SHPTreeAddShapeId( SHPTree * psTree, SHPObject * psObject )
-
-{
- psTree->nTotalCount++;
-
- return( SHPTreeNodeAddShapeId( psTree->psRoot, psObject,
- psTree->nMaxDepth, psTree->nDimension ) );
-}
-
-/************************************************************************/
-/* SHPTreeCollectShapesIds() */
-/* */
-/* Work function implementing SHPTreeFindLikelyShapes() on a */
-/* tree node by tree node basis. */
-/************************************************************************/
-
-static void
-SHPTreeCollectShapeIds( SHPTree *hTree, SHPTreeNode * psTreeNode,
- double * padfBoundsMin, double * padfBoundsMax,
- int * pnShapeCount, int * pnMaxShapes,
- int ** ppanShapeList )
-
-{
- int i;
-
-/* -------------------------------------------------------------------- */
-/* Does this node overlap the area of interest at all? If not, */
-/* return without adding to the list at all. */
-/* -------------------------------------------------------------------- */
- if( !SHPCheckBoundsOverlap( psTreeNode->adfBoundsMin,
- psTreeNode->adfBoundsMax,
- padfBoundsMin,
- padfBoundsMax,
- hTree->nDimension ) )
- return;
-
-/* -------------------------------------------------------------------- */
-/* Grow the list to hold the shapes on this node. */
-/* -------------------------------------------------------------------- */
- if( *pnShapeCount + psTreeNode->nShapeCount > *pnMaxShapes )
- {
- *pnMaxShapes = (*pnShapeCount + psTreeNode->nShapeCount) * 2 + 20;
- *ppanShapeList = (int *)
- SfRealloc(*ppanShapeList,sizeof(int) * *pnMaxShapes);
- }
-
-/* -------------------------------------------------------------------- */
-/* Add the local nodes shapeids to the list. */
-/* -------------------------------------------------------------------- */
- for( i = 0; i < psTreeNode->nShapeCount; i++ )
- {
- (*ppanShapeList)[(*pnShapeCount)++] = psTreeNode->panShapeIds[i];
- }
-
-/* -------------------------------------------------------------------- */
-/* Recurse to subnodes if they exist. */
-/* -------------------------------------------------------------------- */
- for( i = 0; i < psTreeNode->nSubNodes; i++ )
- {
- if( psTreeNode->apsSubNode[i] != NULL )
- SHPTreeCollectShapeIds( hTree, psTreeNode->apsSubNode[i],
- padfBoundsMin, padfBoundsMax,
- pnShapeCount, pnMaxShapes,
- ppanShapeList );
- }
-}
-
-/************************************************************************/
-/* SHPTreeFindLikelyShapes() */
-/* */
-/* Find all shapes within tree nodes for which the tree node */
-/* bounding box overlaps the search box. The return value is */
-/* an array of shapeids terminated by a -1. The shapeids will */
-/* be in order, as hopefully this will result in faster (more */
-/* sequential) reading from the file. */
-/************************************************************************/
-
-/* helper for qsort */
-static int
-compare_ints( const void * a, const void * b)
-{
- return (*(int*)a) - (*(int*)b);
-}
-
-int SHPAPI_CALL1(*)
-SHPTreeFindLikelyShapes( SHPTree * hTree,
- double * padfBoundsMin, double * padfBoundsMax,
- int * pnShapeCount )
-
-{
- int *panShapeList=NULL, nMaxShapes = 0;
-
-/* -------------------------------------------------------------------- */
-/* Perform the search by recursive descent. */
-/* -------------------------------------------------------------------- */
- *pnShapeCount = 0;
-
- SHPTreeCollectShapeIds( hTree, hTree->psRoot,
- padfBoundsMin, padfBoundsMax,
- pnShapeCount, &nMaxShapes,
- &panShapeList );
-
-/* -------------------------------------------------------------------- */
-/* Sort the id array */
-/* -------------------------------------------------------------------- */
-
- if( panShapeList != NULL )
- qsort(panShapeList, *pnShapeCount, sizeof(int), compare_ints);
-
- return panShapeList;
-}
-
-/************************************************************************/
-/* SHPTreeNodeTrim() */
-/* */
-/* This is the recursive version of SHPTreeTrimExtraNodes() that */
-/* walks the tree cleaning it up. */
-/************************************************************************/
-
-static int SHPTreeNodeTrim( SHPTreeNode * psTreeNode )
-
-{
- int i;
-
-/* -------------------------------------------------------------------- */
-/* Trim subtrees, and free subnodes that come back empty. */
-/* -------------------------------------------------------------------- */
- for( i = 0; i < psTreeNode->nSubNodes; i++ )
- {
- if( SHPTreeNodeTrim( psTreeNode->apsSubNode[i] ) )
- {
- SHPDestroyTreeNode( psTreeNode->apsSubNode[i] );
-
- psTreeNode->apsSubNode[i] =
- psTreeNode->apsSubNode[psTreeNode->nSubNodes-1];
-
- psTreeNode->nSubNodes--;
-
- i--; /* process the new occupant of this subnode entry */
- }
- }
-
-/* -------------------------------------------------------------------- */
-/* If the current node has 1 subnode and no shapes, promote that */
-/* subnode to the current node position. */
-/* -------------------------------------------------------------------- */
- if( psTreeNode->nSubNodes == 1 && psTreeNode->nShapeCount == 0)
- {
- SHPTreeNode* psSubNode = psTreeNode->apsSubNode[0];
-
- memcpy(psTreeNode->adfBoundsMin, psSubNode->adfBoundsMin,
- sizeof(psSubNode->adfBoundsMin));
- memcpy(psTreeNode->adfBoundsMax, psSubNode->adfBoundsMax,
- sizeof(psSubNode->adfBoundsMax));
- psTreeNode->nShapeCount = psSubNode->nShapeCount;
- assert(psTreeNode->panShapeIds == NULL);
- psTreeNode->panShapeIds = psSubNode->panShapeIds;
- assert(psTreeNode->papsShapeObj == NULL);
- psTreeNode->papsShapeObj = psSubNode->papsShapeObj;
- psTreeNode->nSubNodes = psSubNode->nSubNodes;
- for( i = 0; i < psSubNode->nSubNodes; i++ )
- psTreeNode->apsSubNode[i] = psSubNode->apsSubNode[i];
- free(psSubNode);
- }
-
-/* -------------------------------------------------------------------- */
-/* We should be trimmed if we have no subnodes, and no shapes. */
-/* -------------------------------------------------------------------- */
- return( psTreeNode->nSubNodes == 0 && psTreeNode->nShapeCount == 0 );
-}
-
-/************************************************************************/
-/* SHPTreeTrimExtraNodes() */
-/* */
-/* Trim empty nodes from the tree. Note that we never trim an */
-/* empty root node. */
-/************************************************************************/
-
-void SHPAPI_CALL
-SHPTreeTrimExtraNodes( SHPTree * hTree )
-
-{
- SHPTreeNodeTrim( hTree->psRoot );
-}
-
-/************************************************************************/
-/* SwapWord() */
-/* */
-/* Swap a 2, 4 or 8 byte word. */
-/************************************************************************/
-
-static void SwapWord( int length, void * wordP )
-
-{
- int i;
- unsigned char temp;
-
- for( i=0; i < length/2; i++ )
- {
- temp = ((unsigned char *) wordP)[i];
- ((unsigned char *)wordP)[i] = ((unsigned char *) wordP)[length-i-1];
- ((unsigned char *) wordP)[length-i-1] = temp;
- }
-}
-
-
-struct SHPDiskTreeInfo
-{
- SAHooks sHooks;
- SAFile fpQIX;
-};
-
-/************************************************************************/
-/* SHPOpenDiskTree() */
-/************************************************************************/
-
-SHPTreeDiskHandle SHPOpenDiskTree( const char* pszQIXFilename,
- SAHooks *psHooks )
-{
- SHPTreeDiskHandle hDiskTree;
-
- hDiskTree = (SHPTreeDiskHandle) calloc(sizeof(struct SHPDiskTreeInfo),1);
-
- if (psHooks == NULL)
- SASetupDefaultHooks( &(hDiskTree->sHooks) );
- else
- memcpy( &(hDiskTree->sHooks), psHooks, sizeof(SAHooks) );
-
- hDiskTree->fpQIX = hDiskTree->sHooks.FOpen(pszQIXFilename, "rb");
- if (hDiskTree->fpQIX == NULL)
- {
- free(hDiskTree);
- return NULL;
- }
-
- return hDiskTree;
-}
-
-/***********************************************************************/
-/* SHPCloseDiskTree() */
-/************************************************************************/
-
-void SHPCloseDiskTree( SHPTreeDiskHandle hDiskTree )
-{
- if (hDiskTree == NULL)
- return;
-
- hDiskTree->sHooks.FClose(hDiskTree->fpQIX);
- free(hDiskTree);
-}
-
-/************************************************************************/
-/* SHPSearchDiskTreeNode() */
-/************************************************************************/
-
-static int
-SHPSearchDiskTreeNode( SHPTreeDiskHandle hDiskTree, double *padfBoundsMin, double *padfBoundsMax,
- int **ppanResultBuffer, int *pnBufferMax,
- int *pnResultCount, int bNeedSwap, int nRecLevel )
-
-{
- unsigned int i;
- unsigned int offset;
- unsigned int numshapes, numsubnodes;
- double adfNodeBoundsMin[2], adfNodeBoundsMax[2];
- int nFReadAcc;
-
-/* -------------------------------------------------------------------- */
-/* Read and unswap first part of node info. */
-/* -------------------------------------------------------------------- */
- nFReadAcc = (int)hDiskTree->sHooks.FRead( &offset, 4, 1, hDiskTree->fpQIX );
- if ( bNeedSwap ) SwapWord ( 4, &offset );
-
- nFReadAcc += (int)hDiskTree->sHooks.FRead( adfNodeBoundsMin, sizeof(double), 2, hDiskTree->fpQIX );
- nFReadAcc += (int)hDiskTree->sHooks.FRead( adfNodeBoundsMax, sizeof(double), 2, hDiskTree->fpQIX );
- if ( bNeedSwap )
- {
- SwapWord( 8, adfNodeBoundsMin + 0 );
- SwapWord( 8, adfNodeBoundsMin + 1 );
- SwapWord( 8, adfNodeBoundsMax + 0 );
- SwapWord( 8, adfNodeBoundsMax + 1 );
- }
-
- nFReadAcc += (int)hDiskTree->sHooks.FRead( &numshapes, 4, 1, hDiskTree->fpQIX );
- if ( bNeedSwap ) SwapWord ( 4, &numshapes );
-
- /* Check that we could read all previous values */
- if( nFReadAcc != 1 + 2 + 2 + 1 )
- {
- hDiskTree->sHooks.Error("I/O error");
- return FALSE;
- }
-
- /* Sanity checks to avoid int overflows in later computation */
- if( offset > INT_MAX - sizeof(int) )
- {
- hDiskTree->sHooks.Error("Invalid value for offset");
- return FALSE;
- }
-
- if( numshapes > (INT_MAX - offset - sizeof(int)) / sizeof(int) ||
- numshapes > INT_MAX / sizeof(int) - *pnResultCount )
- {
- hDiskTree->sHooks.Error("Invalid value for numshapes");
- return FALSE;
- }
-
-/* -------------------------------------------------------------------- */
-/* If we don't overlap this node at all, we can just fseek() */
-/* pass this node info and all subnodes. */
-/* -------------------------------------------------------------------- */
- if( !SHPCheckBoundsOverlap( adfNodeBoundsMin, adfNodeBoundsMax,
- padfBoundsMin, padfBoundsMax, 2 ) )
- {
- offset += numshapes*sizeof(int) + sizeof(int);
- hDiskTree->sHooks.FSeek(hDiskTree->fpQIX, offset, SEEK_CUR);
- return TRUE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Add all the shapeids at this node to our list. */
-/* -------------------------------------------------------------------- */
- if(numshapes > 0)
- {
- if( *pnResultCount + numshapes > (unsigned int)*pnBufferMax )
- {
- int* pNewBuffer;
-
- *pnBufferMax = (*pnResultCount + numshapes + 100) * 5 / 4;
-
- if( (size_t)*pnBufferMax > INT_MAX / sizeof(int) )
- *pnBufferMax = *pnResultCount + numshapes;
-
- pNewBuffer = (int *)
- SfRealloc( *ppanResultBuffer, *pnBufferMax * sizeof(int) );
-
- if( pNewBuffer == NULL )
- {
- hDiskTree->sHooks.Error("Out of memory error");
- return FALSE;
- }
-
- *ppanResultBuffer = pNewBuffer;
- }
-
- if( hDiskTree->sHooks.FRead( *ppanResultBuffer + *pnResultCount,
- sizeof(int), numshapes, hDiskTree->fpQIX ) != numshapes )
- {
- hDiskTree->sHooks.Error("I/O error");
- return FALSE;
- }
-
- if (bNeedSwap )
- {
- for( i=0; i<numshapes; i++ )
- SwapWord( 4, *ppanResultBuffer + *pnResultCount + i );
- }
-
- *pnResultCount += numshapes;
- }
-
-/* -------------------------------------------------------------------- */
-/* Process the subnodes. */
-/* -------------------------------------------------------------------- */
- if( hDiskTree->sHooks.FRead( &numsubnodes, 4, 1, hDiskTree->fpQIX ) != 1 )
- {
- hDiskTree->sHooks.Error("I/O error");
- return FALSE;
- }
- if ( bNeedSwap ) SwapWord ( 4, &numsubnodes );
- if( numsubnodes > 0 && nRecLevel == 32 )
- {
- hDiskTree->sHooks.Error("Shape tree is too deep");
- return FALSE;
- }
-
- for(i=0; i<numsubnodes; i++)
- {
- if( !SHPSearchDiskTreeNode( hDiskTree, padfBoundsMin, padfBoundsMax,
- ppanResultBuffer, pnBufferMax,
- pnResultCount, bNeedSwap, nRecLevel + 1 ) )
- return FALSE;
- }
-
- return TRUE;
-}
-
-/************************************************************************/
-/* SHPTreeReadLibc() */
-/************************************************************************/
-
-static
-SAOffset SHPTreeReadLibc( void *p, SAOffset size, SAOffset nmemb, SAFile file )
-
-{
- return (SAOffset) fread( p, (size_t) size, (size_t) nmemb,
- (FILE *) file );
-}
-
-/************************************************************************/
-/* SHPTreeSeekLibc() */
-/************************************************************************/
-
-static
-SAOffset SHPTreeSeekLibc( SAFile file, SAOffset offset, int whence )
-
-{
- return (SAOffset) fseek( (FILE *) file, (long) offset, whence );
-}
-
-/************************************************************************/
-/* SHPSearchDiskTree() */
-/************************************************************************/
-
-int SHPAPI_CALL1(*)
-SHPSearchDiskTree( FILE *fp,
- double *padfBoundsMin, double *padfBoundsMax,
- int *pnShapeCount )
-{
- struct SHPDiskTreeInfo sDiskTree;
- memset(&sDiskTree.sHooks, 0, sizeof(sDiskTree.sHooks));
-
- /* We do not use SASetupDefaultHooks() because the FILE* */
- /* is a libc FILE* */
- sDiskTree.sHooks.FSeek = SHPTreeSeekLibc;
- sDiskTree.sHooks.FRead = SHPTreeReadLibc;
-
- sDiskTree.fpQIX = (SAFile)fp;
-
- return SHPSearchDiskTreeEx( &sDiskTree, padfBoundsMin, padfBoundsMax,
- pnShapeCount );
-}
-
-/***********************************************************************/
-/* SHPSearchDiskTreeEx() */
-/************************************************************************/
-
-int* SHPSearchDiskTreeEx( SHPTreeDiskHandle hDiskTree,
- double *padfBoundsMin, double *padfBoundsMax,
- int *pnShapeCount )
-
-{
- int i, bNeedSwap, nBufferMax = 0;
- unsigned char abyBuf[16];
- int *panResultBuffer = NULL;
-
- *pnShapeCount = 0;
-
-/* -------------------------------------------------------------------- */
-/* Establish the byte order on this machine. */
-/* -------------------------------------------------------------------- */
- i = 1;
- if( *((unsigned char *) &i) == 1 )
- bBigEndian = FALSE;
- else
- bBigEndian = TRUE;
-
-/* -------------------------------------------------------------------- */
-/* Read the header. */
-/* -------------------------------------------------------------------- */
- hDiskTree->sHooks.FSeek( hDiskTree->fpQIX, 0, SEEK_SET );
- hDiskTree->sHooks.FRead( abyBuf, 16, 1, hDiskTree->fpQIX );
-
- if( memcmp( abyBuf, "SQT", 3 ) != 0 )
- return NULL;
-
- if( (abyBuf[3] == 2 && bBigEndian)
- || (abyBuf[3] == 1 && !bBigEndian) )
- bNeedSwap = FALSE;
- else
- bNeedSwap = TRUE;
-
-/* -------------------------------------------------------------------- */
-/* Search through root node and it's descendants. */
-/* -------------------------------------------------------------------- */
- if( !SHPSearchDiskTreeNode( hDiskTree, padfBoundsMin, padfBoundsMax,
- &panResultBuffer, &nBufferMax,
- pnShapeCount, bNeedSwap, 0 ) )
- {
- if( panResultBuffer != NULL )
- free( panResultBuffer );
- *pnShapeCount = 0;
- return NULL;
- }
-/* -------------------------------------------------------------------- */
-/* Sort the id array */
-/* -------------------------------------------------------------------- */
-
- /* To distinguish between empty intersection from error case */
- if( panResultBuffer == NULL )
- panResultBuffer = (int*) calloc(1, sizeof(int));
- else
- qsort(panResultBuffer, *pnShapeCount, sizeof(int), compare_ints);
-
-
- return panResultBuffer;
-}
-
-/************************************************************************/
-/* SHPGetSubNodeOffset() */
-/* */
-/* Determine how big all the subnodes of this node (and their */
-/* children) will be. This will allow disk based searchers to */
-/* seek past them all efficiently. */
-/************************************************************************/
-
-static int SHPGetSubNodeOffset( SHPTreeNode *node)
-{
- int i;
- int offset=0;
-
- for(i=0; i<node->nSubNodes; i++ )
- {
- if(node->apsSubNode[i])
- {
- offset += 4*sizeof(double)
- + (node->apsSubNode[i]->nShapeCount+3)*sizeof(int);
- offset += SHPGetSubNodeOffset(node->apsSubNode[i]);
- }
- }
-
- return(offset);
-}
-
-/************************************************************************/
-/* SHPWriteTreeNode() */
-/************************************************************************/
-
-static void SHPWriteTreeNode( SAFile fp, SHPTreeNode *node, SAHooks* psHooks)
-{
- int i,j;
- int offset;
- unsigned char *pabyRec = NULL;
- assert( NULL != node );
-
- offset = SHPGetSubNodeOffset(node);
-
- pabyRec = (unsigned char *)
- malloc(sizeof(double) * 4
- + (3 * sizeof(int)) + (node->nShapeCount * sizeof(int)) );
- if( NULL == pabyRec )
- {
-#ifdef USE_CPL
- CPLError( CE_Fatal, CPLE_OutOfMemory, "Memory allocation failure");
-#endif
- assert( 0 );
- return;
- }
-
- memcpy( pabyRec, &offset, 4);
-
- /* minx, miny, maxx, maxy */
- memcpy( pabyRec+ 4, node->adfBoundsMin+0, sizeof(double) );
- memcpy( pabyRec+12, node->adfBoundsMin+1, sizeof(double) );
- memcpy( pabyRec+20, node->adfBoundsMax+0, sizeof(double) );
- memcpy( pabyRec+28, node->adfBoundsMax+1, sizeof(double) );
-
- memcpy( pabyRec+36, &node->nShapeCount, 4);
- j = node->nShapeCount * sizeof(int);
- if( j )
- memcpy( pabyRec+40, node->panShapeIds, j);
- memcpy( pabyRec+j+40, &node->nSubNodes, 4);
-
- psHooks->FWrite( pabyRec, 44+j, 1, fp );
- free (pabyRec);
-
- for(i=0; i<node->nSubNodes; i++ )
- {
- if(node->apsSubNode[i])
- SHPWriteTreeNode( fp, node->apsSubNode[i], psHooks);
- }
-}
-
-/************************************************************************/
-/* SHPWriteTree() */
-/************************************************************************/
-
-int SHPAPI_CALL SHPWriteTree(SHPTree *tree, const char *filename )
-{
- SAHooks sHooks;
-
- SASetupDefaultHooks( &sHooks );
-
- return SHPWriteTreeLL(tree, filename, &sHooks);
-}
-
-/************************************************************************/
-/* SHPWriteTreeLL() */
-/************************************************************************/
-
-int SHPWriteTreeLL(SHPTree *tree, const char *filename, SAHooks* psHooks )
-{
- char signature[4] = "SQT";
- int i;
- char abyBuf[32];
- SAFile fp;
-
- SAHooks sHooks;
- if (psHooks == NULL)
- {
- SASetupDefaultHooks( &sHooks );
- psHooks = &sHooks;
- }
-
-/* -------------------------------------------------------------------- */
-/* Open the output file. */
-/* -------------------------------------------------------------------- */
- fp = psHooks->FOpen(filename, "wb");
- if( fp == NULL )
- {
- return FALSE;
- }
-
-/* -------------------------------------------------------------------- */
-/* Establish the byte order on this machine. */
-/* -------------------------------------------------------------------- */
- i = 1;
- if( *((unsigned char *) &i) == 1 )
- bBigEndian = FALSE;
- else
- bBigEndian = TRUE;
-
-/* -------------------------------------------------------------------- */
-/* Write the header. */
-/* -------------------------------------------------------------------- */
- memcpy( abyBuf+0, signature, 3 );
-
- if( bBigEndian )
- abyBuf[3] = 2; /* New MSB */
- else
- abyBuf[3] = 1; /* New LSB */
-
- abyBuf[4] = 1; /* version */
- abyBuf[5] = 0; /* next 3 reserved */
- abyBuf[6] = 0;
- abyBuf[7] = 0;
-
- psHooks->FWrite( abyBuf, 8, 1, fp );
-
- psHooks->FWrite( &(tree->nTotalCount), 4, 1, fp );
-
- /* write maxdepth */
-
- psHooks->FWrite( &(tree->nMaxDepth), 4, 1, fp );
-
-/* -------------------------------------------------------------------- */
-/* Write all the nodes "in order". */
-/* -------------------------------------------------------------------- */
-
- SHPWriteTreeNode( fp, tree->psRoot, psHooks );
-
- psHooks->FClose( fp );
-
- return TRUE;
-}
diff --git a/navit/support/win32/CMakeLists.txt b/navit/support/win32/CMakeLists.txt
deleted file mode 100644
index 244084762..000000000
--- a/navit/support/win32/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-supportlib_add_library(support_win32 mmap.c win32_init.c ConvertUTF.c serial_io.c addwinsock.c)
-
diff --git a/navit/support/win32/ConvertUTF.c b/navit/support/win32/ConvertUTF.c
deleted file mode 100644
index 9b3deebd6..000000000
--- a/navit/support/win32/ConvertUTF.c
+++ /dev/null
@@ -1,539 +0,0 @@
-/*
- * Copyright 2001-2004 Unicode, Inc.
- *
- * Disclaimer
- *
- * This source code is provided as is by Unicode, Inc. No claims are
- * made as to fitness for any particular purpose. No warranties of any
- * kind are expressed or implied. The recipient agrees to determine
- * applicability of information provided. If this file has been
- * purchased on magnetic or optical media from Unicode, Inc., the
- * sole remedy for any claim will be exchange of defective media
- * within 90 days of receipt.
- *
- * Limitations on Rights to Redistribute This Code
- *
- * Unicode, Inc. hereby grants the right to freely use the information
- * supplied in this file in the creation of products supporting the
- * Unicode Standard, and to make copies of this file in any form
- * for internal or external distribution as long as this notice
- * remains attached.
- */
-
-/* ---------------------------------------------------------------------
-
- Conversions between UTF32, UTF-16, and UTF-8. Source code file.
- Author: Mark E. Davis, 1994.
- Rev History: Rick McGowan, fixes & updates May 2001.
- Sept 2001: fixed const & error conditions per
- mods suggested by S. Parent & A. Lillich.
- June 2002: Tim Dodd added detection and handling of incomplete
- source sequences, enhanced error detection, added casts
- to eliminate compiler warnings.
- July 2003: slight mods to back out aggressive FFFE detection.
- Jan 2004: updated switches in from-UTF8 conversions.
- Oct 2004: updated to use UNI_MAX_LEGAL_UTF32 in UTF-32 conversions.
-
- See the header file "ConvertUTF.h" for complete documentation.
-
------------------------------------------------------------------------- */
-
-
-#include "ConvertUTF.h"
-#ifdef CVTUTF_DEBUG
-#include <stdio.h>
-#endif
-
-static const int halfShift = 10; /* used for shifting by 10 bits */
-
-static const UTF32 halfBase = 0x0010000UL;
-static const UTF32 halfMask = 0x3FFUL;
-
-#define UNI_SUR_HIGH_START (UTF32)0xD800
-#define UNI_SUR_HIGH_END (UTF32)0xDBFF
-#define UNI_SUR_LOW_START (UTF32)0xDC00
-#define UNI_SUR_LOW_END (UTF32)0xDFFF
-#define false 0
-#define true 1
-
-/* --------------------------------------------------------------------- */
-
-ConversionResult ConvertUTF32toUTF16 (
- const UTF32** sourceStart, const UTF32* sourceEnd,
- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
- ConversionResult result = conversionOK;
- const UTF32* source = *sourceStart;
- UTF16* target = *targetStart;
- while (source < sourceEnd) {
- UTF32 ch;
- if (target >= targetEnd) {
- result = targetExhausted; break;
- }
- ch = *source++;
- if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
- /* UTF-16 surrogate values are illegal in UTF-32; 0xffff or 0xfffe are both reserved values */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- if (flags == strictConversion) {
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- *target++ = (UTF16)ch; /* normal case */
- }
- } else if (ch > UNI_MAX_LEGAL_UTF32) {
- if (flags == strictConversion) {
- result = sourceIllegal;
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- /* target is a character in range 0xFFFF - 0x10FFFF. */
- if (target + 1 >= targetEnd) {
- --source; /* Back up source pointer! */
- result = targetExhausted; break;
- }
- ch -= halfBase;
- *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
- *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
- }
- }
- *sourceStart = source;
- *targetStart = target;
- return result;
-}
-
-/* --------------------------------------------------------------------- */
-
-ConversionResult ConvertUTF16toUTF32 (
- const UTF16** sourceStart, const UTF16* sourceEnd,
- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
- ConversionResult result = conversionOK;
- const UTF16* source = *sourceStart;
- UTF32* target = *targetStart;
- UTF32 ch, ch2;
- while (source < sourceEnd) {
- const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
- ch = *source++;
- /* If we have a surrogate pair, convert to UTF32 first. */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
- /* If the 16 bits following the high surrogate are in the source buffer... */
- if (source < sourceEnd) {
- ch2 = *source;
- /* If it's a low surrogate, convert to UTF32. */
- if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
- ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
- + (ch2 - UNI_SUR_LOW_START) + halfBase;
- ++source;
- } else if (flags == strictConversion) { /* it's an unpaired high surrogate */
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- } else { /* We don't have the 16 bits following the high surrogate. */
- --source; /* return to the high surrogate */
- result = sourceExhausted;
- break;
- }
- } else if (flags == strictConversion) {
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- }
- if (target >= targetEnd) {
- source = oldSource; /* Back up source pointer! */
- result = targetExhausted; break;
- }
- *target++ = ch;
- }
- *sourceStart = source;
- *targetStart = target;
-#ifdef CVTUTF_DEBUG
-if (result == sourceIllegal) {
- fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2);
- fflush(stderr);
-}
-#endif
- return result;
-}
-
-/* --------------------------------------------------------------------- */
-
-/*
- * Index into the table below with the first byte of a UTF-8 sequence to
- * get the number of trailing bytes that are supposed to follow it.
- * Note that *legal* UTF-8 values can't have 4 or 5-bytes. The table is
- * left as-is for anyone who may want to do such conversion, which was
- * allowed in earlier algorithms.
- */
-static const char trailingBytesForUTF8[256] = {
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
- 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
-};
-
-/*
- * Magic values subtracted from a buffer value during UTF8 conversion.
- * This table contains as many values as there might be trailing bytes
- * in a UTF-8 sequence.
- */
-static const UTF32 offsetsFromUTF8[6] = { 0x00000000UL, 0x00003080UL, 0x000E2080UL,
- 0x03C82080UL, 0xFA082080UL, 0x82082080UL };
-
-/*
- * Once the bits are split out into bytes of UTF-8, this is a mask OR-ed
- * into the first byte, depending on how many bytes follow. There are
- * as many entries in this table as there are UTF-8 sequence types.
- * (I.e., one byte sequence, two byte... etc.). Remember that sequencs
- * for *legal* UTF-8 will be 4 or fewer bytes total.
- */
-static const UTF8 firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC };
-
-/* --------------------------------------------------------------------- */
-
-/* The interface converts a whole buffer to avoid function-call overhead.
- * Constants have been gathered. Loops & conditionals have been removed as
- * much as possible for efficiency, in favor of drop-through switches.
- * (See "Note A" at the bottom of the file for equivalent code.)
- * If your compiler supports it, the "isLegalUTF8" call can be turned
- * into an inline function.
- */
-
-/* --------------------------------------------------------------------- */
-
-ConversionResult ConvertUTF16toUTF8 (
- const UTF16** sourceStart, const UTF16* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
- ConversionResult result = conversionOK;
- const UTF16* source = *sourceStart;
- UTF8* target = *targetStart;
- while (source < sourceEnd) {
- UTF32 ch;
- unsigned short bytesToWrite = 0;
- const UTF32 byteMask = 0xBF;
- const UTF32 byteMark = 0x80;
- const UTF16* oldSource = source; /* In case we have to back up because of target overflow. */
- ch = *source++;
- /* If we have a surrogate pair, convert to UTF32 first. */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_HIGH_END) {
- /* If the 16 bits following the high surrogate are in the source buffer... */
- if (source < sourceEnd) {
- UTF32 ch2 = *source;
- /* If it's a low surrogate, convert to UTF32. */
- if (ch2 >= UNI_SUR_LOW_START && ch2 <= UNI_SUR_LOW_END) {
- ch = ((ch - UNI_SUR_HIGH_START) << halfShift)
- + (ch2 - UNI_SUR_LOW_START) + halfBase;
- ++source;
- } else if (flags == strictConversion) { /* it's an unpaired high surrogate */
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- } else { /* We don't have the 16 bits following the high surrogate. */
- --source; /* return to the high surrogate */
- result = sourceExhausted;
- break;
- }
- } else if (flags == strictConversion) {
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_LOW_START && ch <= UNI_SUR_LOW_END) {
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- }
- /* Figure out how many bytes the result will require */
- if (ch < (UTF32)0x80) { bytesToWrite = 1;
- } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
- } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
- } else if (ch < (UTF32)0x110000) { bytesToWrite = 4;
- } else { bytesToWrite = 3;
- ch = UNI_REPLACEMENT_CHAR;
- }
-
- target += bytesToWrite;
- if (target > targetEnd) {
- source = oldSource; /* Back up source pointer! */
- target -= bytesToWrite; result = targetExhausted; break;
- }
- switch (bytesToWrite) { /* note: everything falls through. */
- case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 1: *--target = (UTF8)(ch | firstByteMark[bytesToWrite]);
- }
- target += bytesToWrite;
- }
- *sourceStart = source;
- *targetStart = target;
- return result;
-}
-
-/* --------------------------------------------------------------------- */
-
-/*
- * Utility routine to tell whether a sequence of bytes is legal UTF-8.
- * This must be called with the length pre-determined by the first byte.
- * If not calling this from ConvertUTF8to*, then the length can be set by:
- * length = trailingBytesForUTF8[*source]+1;
- * and the sequence is illegal right away if there aren't that many bytes
- * available.
- * If presented with a length > 4, this returns false. The Unicode
- * definition of UTF-8 goes up to 4-byte sequences.
- */
-
-static Boolean isLegalUTF8(const UTF8 *source, int length) {
- UTF8 a;
- const UTF8 *srcptr = source+length;
- switch (length) {
- default: return false;
- /* Everything else falls through when "true"... */
- case 4: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
- case 3: if ((a = (*--srcptr)) < 0x80 || a > 0xBF) return false;
- case 2: if ((a = (*--srcptr)) > 0xBF) return false;
-
- switch (*source) {
- /* no fall-through in this inner switch */
- case 0xE0: if (a < 0xA0) return false; break;
- case 0xED: if (a > 0x9F) return false; break;
- case 0xF0: if (a < 0x90) return false; break;
- case 0xF4: if (a > 0x8F) return false; break;
- default: if (a < 0x80) return false;
- }
-
- case 1: if (*source >= 0x80 && *source < 0xC2) return false;
- }
- if (*source > 0xF4) return false;
- return true;
-}
-
-/* --------------------------------------------------------------------- */
-
-/*
- * Exported function to return whether a UTF-8 sequence is legal or not.
- * This is not used here; it's just exported.
- */
-Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd) {
- int length = trailingBytesForUTF8[*source]+1;
- if (source+length > sourceEnd) {
- return false;
- }
- return isLegalUTF8(source, length);
-}
-
-/* --------------------------------------------------------------------- */
-
-ConversionResult ConvertUTF8toUTF16 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags) {
- ConversionResult result = conversionOK;
- const UTF8* source = *sourceStart;
- UTF16* target = *targetStart;
- while (source < sourceEnd) {
- UTF32 ch = 0;
- unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
- if (source + extraBytesToRead >= sourceEnd) {
- result = sourceExhausted; break;
- }
- /* Do this check whether lenient or strict */
- if (! isLegalUTF8(source, extraBytesToRead+1)) {
- result = sourceIllegal;
- break;
- }
- /*
- * The cases all fall through. See "Note A" below.
- */
- switch (extraBytesToRead) {
- case 5: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
- case 4: ch += *source++; ch <<= 6; /* remember, illegal UTF-8 */
- case 3: ch += *source++; ch <<= 6;
- case 2: ch += *source++; ch <<= 6;
- case 1: ch += *source++; ch <<= 6;
- case 0: ch += *source++;
- }
- ch -= offsetsFromUTF8[extraBytesToRead];
-
- if (target >= targetEnd) {
- source -= (extraBytesToRead+1); /* Back up source pointer! */
- result = targetExhausted; break;
- }
- if (ch <= UNI_MAX_BMP) { /* Target is a character <= 0xFFFF */
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- if (flags == strictConversion) {
- source -= (extraBytesToRead+1); /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- *target++ = (UTF16)ch; /* normal case */
- }
- } else if (ch > UNI_MAX_UTF16) {
- if (flags == strictConversion) {
- result = sourceIllegal;
- source -= (extraBytesToRead+1); /* return to the start */
- break; /* Bail out; shouldn't continue */
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- /* target is a character in range 0xFFFF - 0x10FFFF. */
- if (target + 1 >= targetEnd) {
- source -= (extraBytesToRead+1); /* Back up source pointer! */
- result = targetExhausted; break;
- }
- ch -= halfBase;
- *target++ = (UTF16)((ch >> halfShift) + UNI_SUR_HIGH_START);
- *target++ = (UTF16)((ch & halfMask) + UNI_SUR_LOW_START);
- }
- }
- *sourceStart = source;
- *targetStart = target;
- return result;
-}
-
-/* --------------------------------------------------------------------- */
-
-ConversionResult ConvertUTF32toUTF8 (
- const UTF32** sourceStart, const UTF32* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags) {
- ConversionResult result = conversionOK;
- const UTF32* source = *sourceStart;
- UTF8* target = *targetStart;
- while (source < sourceEnd) {
- UTF32 ch;
- unsigned short bytesToWrite = 0;
- const UTF32 byteMask = 0xBF;
- const UTF32 byteMark = 0x80;
- ch = *source++;
- if (flags == strictConversion ) {
- /* UTF-16 surrogate values are illegal in UTF-32 */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- --source; /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- }
- }
- /*
- * Figure out how many bytes the result will require. Turn any
- * illegally large UTF32 things (> Plane 17) into replacement chars.
- */
- if (ch < (UTF32)0x80) { bytesToWrite = 1;
- } else if (ch < (UTF32)0x800) { bytesToWrite = 2;
- } else if (ch < (UTF32)0x10000) { bytesToWrite = 3;
- } else if (ch <= UNI_MAX_LEGAL_UTF32) { bytesToWrite = 4;
- } else { bytesToWrite = 3;
- ch = UNI_REPLACEMENT_CHAR;
- result = sourceIllegal;
- }
-
- target += bytesToWrite;
- if (target > targetEnd) {
- --source; /* Back up source pointer! */
- target -= bytesToWrite; result = targetExhausted; break;
- }
- switch (bytesToWrite) { /* note: everything falls through. */
- case 4: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 3: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 2: *--target = (UTF8)((ch | byteMark) & byteMask); ch >>= 6;
- case 1: *--target = (UTF8) (ch | firstByteMark[bytesToWrite]);
- }
- target += bytesToWrite;
- }
- *sourceStart = source;
- *targetStart = target;
- return result;
-}
-
-/* --------------------------------------------------------------------- */
-
-ConversionResult ConvertUTF8toUTF32 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags) {
- ConversionResult result = conversionOK;
- const UTF8* source = *sourceStart;
- UTF32* target = *targetStart;
- while (source < sourceEnd) {
- UTF32 ch = 0;
- unsigned short extraBytesToRead = trailingBytesForUTF8[*source];
- if (source + extraBytesToRead >= sourceEnd) {
- result = sourceExhausted; break;
- }
- /* Do this check whether lenient or strict */
- if (! isLegalUTF8(source, extraBytesToRead+1)) {
- result = sourceIllegal;
- break;
- }
- /*
- * The cases all fall through. See "Note A" below.
- */
- switch (extraBytesToRead) {
- case 5: ch += *source++; ch <<= 6;
- case 4: ch += *source++; ch <<= 6;
- case 3: ch += *source++; ch <<= 6;
- case 2: ch += *source++; ch <<= 6;
- case 1: ch += *source++; ch <<= 6;
- case 0: ch += *source++;
- }
- ch -= offsetsFromUTF8[extraBytesToRead];
-
- if (target >= targetEnd) {
- source -= (extraBytesToRead+1); /* Back up the source pointer! */
- result = targetExhausted; break;
- }
- if (ch <= UNI_MAX_LEGAL_UTF32) {
- /*
- * UTF-16 surrogate values are illegal in UTF-32, and anything
- * over Plane 17 (> 0x10FFFF) is illegal.
- */
- if (ch >= UNI_SUR_HIGH_START && ch <= UNI_SUR_LOW_END) {
- if (flags == strictConversion) {
- source -= (extraBytesToRead+1); /* return to the illegal value itself */
- result = sourceIllegal;
- break;
- } else {
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- } else {
- *target++ = ch;
- }
- } else { /* i.e., ch > UNI_MAX_LEGAL_UTF32 */
- result = sourceIllegal;
- *target++ = UNI_REPLACEMENT_CHAR;
- }
- }
- *sourceStart = source;
- *targetStart = target;
- return result;
-}
-
-/* ---------------------------------------------------------------------
-
- Note A.
- The fall-through switches in UTF-8 reading code save a
- temp variable, some decrements & conditionals. The switches
- are equivalent to the following loop:
- {
- int tmpBytesToRead = extraBytesToRead+1;
- do {
- ch += *source++;
- --tmpBytesToRead;
- if (tmpBytesToRead) ch <<= 6;
- } while (tmpBytesToRead > 0);
- }
- In UTF-8 writing code, the switches on "bytesToWrite" are
- similarly unrolled loops.
-
- --------------------------------------------------------------------- */
diff --git a/navit/support/win32/ConvertUTF.h b/navit/support/win32/ConvertUTF.h
deleted file mode 100644
index e26491536..000000000
--- a/navit/support/win32/ConvertUTF.h
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright 2001-2004 Unicode, Inc.
- *
- * Disclaimer
- *
- * This source code is provided as is by Unicode, Inc. No claims are
- * made as to fitness for any particular purpose. No warranties of any
- * kind are expressed or implied. The recipient agrees to determine
- * applicability of information provided. If this file has been
- * purchased on magnetic or optical media from Unicode, Inc., the
- * sole remedy for any claim will be exchange of defective media
- * within 90 days of receipt.
- *
- * Limitations on Rights to Redistribute This Code
- *
- * Unicode, Inc. hereby grants the right to freely use the information
- * supplied in this file in the creation of products supporting the
- * Unicode Standard, and to make copies of this file in any form
- * for internal or external distribution as long as this notice
- * remains attached.
- */
-
-/* ---------------------------------------------------------------------
-
- Conversions between UTF32, UTF-16, and UTF-8. Header file.
-
- Several funtions are included here, forming a complete set of
- conversions between the three formats. UTF-7 is not included
- here, but is handled in a separate source file.
-
- Each of these routines takes pointers to input buffers and output
- buffers. The input buffers are const.
-
- Each routine converts the text between *sourceStart and sourceEnd,
- putting the result into the buffer between *targetStart and
- targetEnd. Note: the end pointers are *after* the last item: e.g.
- *(sourceEnd - 1) is the last item.
-
- The return result indicates whether the conversion was successful,
- and if not, whether the problem was in the source or target buffers.
- (Only the first encountered problem is indicated.)
-
- After the conversion, *sourceStart and *targetStart are both
- updated to point to the end of last text successfully converted in
- the respective buffers.
-
- Input parameters:
- sourceStart - pointer to a pointer to the source buffer.
- The contents of this are modified on return so that
- it points at the next thing to be converted.
- targetStart - similarly, pointer to pointer to the target buffer.
- sourceEnd, targetEnd - respectively pointers to the ends of the
- two buffers, for overflow checking only.
-
- These conversion functions take a ConversionFlags argument. When this
- flag is set to strict, both irregular sequences and isolated surrogates
- will cause an error. When the flag is set to lenient, both irregular
- sequences and isolated surrogates are converted.
-
- Whether the flag is strict or lenient, all illegal sequences will cause
- an error return. This includes sequences such as: <F4 90 80 80>, <C0 80>,
- or <A0> in UTF-8, and values above 0x10FFFF in UTF-32. Conformant code
- must check for illegal sequences.
-
- When the flag is set to lenient, characters over 0x10FFFF are converted
- to the replacement character; otherwise (when the flag is set to strict)
- they constitute an error.
-
- Output parameters:
- The value "sourceIllegal" is returned from some routines if the input
- sequence is malformed. When "sourceIllegal" is returned, the source
- value will point to the illegal value that caused the problem. E.g.,
- in UTF-8 when a sequence is malformed, it points to the start of the
- malformed sequence.
-
- Author: Mark E. Davis, 1994.
- Rev History: Rick McGowan, fixes & updates May 2001.
- Fixes & updates, Sept 2001.
-
------------------------------------------------------------------------- */
-
-/* ---------------------------------------------------------------------
- The following 4 definitions are compiler-specific.
- The C standard does not guarantee that wchar_t has at least
- 16 bits, so wchar_t is no less portable than unsigned short!
- All should be unsigned values to avoid sign extension during
- bit mask & shift operations.
------------------------------------------------------------------------- */
-
-typedef unsigned long UTF32; /* at least 32 bits */
-typedef unsigned short UTF16; /* at least 16 bits */
-typedef unsigned char UTF8; /* typically 8 bits */
-typedef unsigned char Boolean; /* 0 or 1 */
-
-/* Some fundamental constants */
-#define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD
-#define UNI_MAX_BMP (UTF32)0x0000FFFF
-#define UNI_MAX_UTF16 (UTF32)0x0010FFFF
-#define UNI_MAX_UTF32 (UTF32)0x7FFFFFFF
-#define UNI_MAX_LEGAL_UTF32 (UTF32)0x0010FFFF
-
-typedef enum {
- conversionOK, /* conversion successful */
- sourceExhausted, /* partial character in source, but hit end */
- targetExhausted, /* insuff. room in target for conversion */
- sourceIllegal /* source sequence is illegal/malformed */
-} ConversionResult;
-
-typedef enum {
- strictConversion = 0,
- lenientConversion
-} ConversionFlags;
-
-/* This is for C++ and does no harm in C */
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-ConversionResult ConvertUTF8toUTF16 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
-
-ConversionResult ConvertUTF16toUTF8 (
- const UTF16** sourceStart, const UTF16* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
-
-ConversionResult ConvertUTF8toUTF32 (
- const UTF8** sourceStart, const UTF8* sourceEnd,
- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
-
-ConversionResult ConvertUTF32toUTF8 (
- const UTF32** sourceStart, const UTF32* sourceEnd,
- UTF8** targetStart, UTF8* targetEnd, ConversionFlags flags);
-
-ConversionResult ConvertUTF16toUTF32 (
- const UTF16** sourceStart, const UTF16* sourceEnd,
- UTF32** targetStart, UTF32* targetEnd, ConversionFlags flags);
-
-ConversionResult ConvertUTF32toUTF16 (
- const UTF32** sourceStart, const UTF32* sourceEnd,
- UTF16** targetStart, UTF16* targetEnd, ConversionFlags flags);
-
-Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd);
-
-#ifdef __cplusplus
-}
-#endif
-
-/* --------------------------------------------------------------------- */
diff --git a/navit/support/win32/X11/XF86keysym.h b/navit/support/win32/X11/XF86keysym.h
deleted file mode 100644
index ff4980457..000000000
--- a/navit/support/win32/X11/XF86keysym.h
+++ /dev/null
@@ -1,189 +0,0 @@
-/* $XFree86: xc/include/XF86keysym.h,v 1.16 2003/02/11 02:51:10 dawes Exp $ */
-
-/*
- * XFree86 vendor specific keysyms.
- *
- * The XFree86 keysym range is 0x10080001 - 0x1008FFFF.
- *
- * When adding new entries, the xc/lib/XKeysymDB file should also be
- * updated to make the new entries visible to Xlib.
- */
-
-/*
- * ModeLock
- *
- * This one is old, and not really used any more since XKB offers this
- * functionality.
- */
-
-#define XF86XK_ModeLock 0x1008FF01 /* Mode Switch Lock */
-
-/*
- * Note, 0x1008FF02 - 0x1008FF0F are free and should be used for misc new
- * keysyms that don't fit into any of the groups below.
- *
- * 0x1008FF64, 0x1008FF6F, 0x1008FF71, 0x1008FF83 are no longer used,
- * and should be used first for new keysyms.
- *
- * Check in keysymdef.h for generic symbols before adding new XFree86-specific
- * symbols here.
- */
-
-
-/*
- * Keys found on some "Internet" keyboards.
- */
-#define XF86XK_Standby 0x1008FF10
-#define XF86XK_AudioLowerVolume 0x1008FF11
-#define XF86XK_AudioMute 0x1008FF12
-#define XF86XK_AudioRaiseVolume 0x1008FF13
-#define XF86XK_AudioPlay 0x1008FF14
-#define XF86XK_AudioStop 0x1008FF15
-#define XF86XK_AudioPrev 0x1008FF16
-#define XF86XK_AudioNext 0x1008FF17
-#define XF86XK_HomePage 0x1008FF18
-#define XF86XK_Mail 0x1008FF19
-#define XF86XK_Start 0x1008FF1A
-#define XF86XK_Search 0x1008FF1B
-#define XF86XK_AudioRecord 0x1008FF1C
-
-/* These are sometimes found on PDA's (e.g. Palm, PocketPC or elsewhere) */
-#define XF86XK_Calculator 0x1008FF1D
-#define XF86XK_Memo 0x1008FF1E
-#define XF86XK_ToDoList 0x1008FF1F
-#define XF86XK_Calendar 0x1008FF20
-#define XF86XK_PowerDown 0x1008FF21
-#define XF86XK_ContrastAdjust 0x1008FF22
-#define XF86XK_RockerUp 0x1008FF23
-#define XF86XK_RockerDown 0x1008FF24
-#define XF86XK_RockerEnter 0x1008FF25
-
-/* Some more "Internet" keyboard symbols */
-#define XF86XK_Back 0x1008FF26
-#define XF86XK_Forward 0x1008FF27
-#define XF86XK_Stop 0x1008FF28
-#define XF86XK_Refresh 0x1008FF29
-#define XF86XK_PowerOff 0x1008FF2A
-#define XF86XK_WakeUp 0x1008FF2B
-#define XF86XK_Eject 0x1008FF2C
-#define XF86XK_ScreenSaver 0x1008FF2D
-#define XF86XK_WWW 0x1008FF2E
-#define XF86XK_Sleep 0x1008FF2F
-#define XF86XK_Favorites 0x1008FF30
-#define XF86XK_AudioPause 0x1008FF31
-#define XF86XK_AudioMedia 0x1008FF32
-#define XF86XK_MyComputer 0x1008FF33
-#define XF86XK_VendorHome 0x1008FF34
-#define XF86XK_LightBulb 0x1008FF35
-#define XF86XK_Shop 0x1008FF36
-#define XF86XK_History 0x1008FF37
-#define XF86XK_OpenURL 0x1008FF38
-#define XF86XK_AddFavorite 0x1008FF39
-#define XF86XK_HotLinks 0x1008FF3A
-#define XF86XK_BrightnessAdjust 0x1008FF3B
-#define XF86XK_Finance 0x1008FF3C
-#define XF86XK_Community 0x1008FF3D
-#define XF86XK_AudioRewind 0x1008FF3E
-#define XF86XK_XF86BackForward 0x1008FF3F
-#define XF86XK_Launch0 0x1008FF40
-#define XF86XK_Launch1 0x1008FF41
-#define XF86XK_Launch2 0x1008FF42
-#define XF86XK_Launch3 0x1008FF43
-#define XF86XK_Launch4 0x1008FF44
-#define XF86XK_Launch5 0x1008FF45
-#define XF86XK_Launch6 0x1008FF46
-#define XF86XK_Launch7 0x1008FF47
-#define XF86XK_Launch8 0x1008FF48
-#define XF86XK_Launch9 0x1008FF49
-#define XF86XK_LaunchA 0x1008FF4A
-#define XF86XK_LaunchB 0x1008FF4B
-#define XF86XK_LaunchC 0x1008FF4C
-#define XF86XK_LaunchD 0x1008FF4D
-#define XF86XK_LaunchE 0x1008FF4E
-#define XF86XK_LaunchF 0x1008FF4F
-
-#define XF86XK_ApplicationLeft 0x1008FF50
-#define XF86XK_ApplicationRight 0x1008FF51
-#define XF86XK_Book 0x1008FF52
-#define XF86XK_CD 0x1008FF53
-#define XF86XK_Calculater 0x1008FF54
-#define XF86XK_Clear 0x1008FF55
-#define XF86XK_Close 0x1008FF56
-#define XF86XK_Copy 0x1008FF57
-#define XF86XK_Cut 0x1008FF58
-#define XF86XK_Display 0x1008FF59
-#define XF86XK_DOS 0x1008FF5A
-#define XF86XK_Documents 0x1008FF5B
-#define XF86XK_Excel 0x1008FF5C
-#define XF86XK_Explorer 0x1008FF5D
-#define XF86XK_Game 0x1008FF5E
-#define XF86XK_Go 0x1008FF5F
-#define XF86XK_iTouch 0x1008FF60
-#define XF86XK_LogOff 0x1008FF61
-#define XF86XK_Market 0x1008FF62
-#define XF86XK_Meeting 0x1008FF63
-#define XF86XK_MenuKB 0x1008FF65
-#define XF86XK_MenuPB 0x1008FF66
-#define XF86XK_MySites 0x1008FF67
-#define XF86XK_New 0x1008FF68
-#define XF86XK_News 0x1008FF69
-#define XF86XK_OfficeHome 0x1008FF6A
-#define XF86XK_Open 0x1008FF6B
-#define XF86XK_Option 0x1008FF6C
-#define XF86XK_Paste 0x1008FF6D
-#define XF86XK_Phone 0x1008FF6E
-#define XF86XK_Q 0x1008FF70
-#define XF86XK_Reply 0x1008FF72
-#define XF86XK_Reload 0x1008FF73
-#define XF86XK_RotateWindows 0x1008FF74
-#define XF86XK_RotationPB 0x1008FF75
-#define XF86XK_RotationKB 0x1008FF76
-#define XF86XK_Save 0x1008FF77
-#define XF86XK_ScrollUp 0x1008FF78
-#define XF86XK_ScrollDown 0x1008FF79
-#define XF86XK_ScrollClick 0x1008FF7A
-#define XF86XK_Send 0x1008FF7B
-#define XF86XK_Spell 0x1008FF7C
-#define XF86XK_SplitScreen 0x1008FF7D
-#define XF86XK_Support 0x1008FF7E
-#define XF86XK_TaskPane 0x1008FF7F
-#define XF86XK_Terminal 0x1008FF80
-#define XF86XK_Tools 0x1008FF81
-#define XF86XK_Travel 0x1008FF82
-#define XF86XK_UserPB 0x1008FF84
-#define XF86XK_User1KB 0x1008FF85
-#define XF86XK_User2KB 0x1008FF86
-#define XF86XK_Video 0x1008FF87
-#define XF86XK_WheelButton 0x1008FF88
-#define XF86XK_Word 0x1008FF89
-#define XF86XK_Xfer 0x1008FF8A
-#define XF86XK_ZoomIn 0x1008FF8B
-#define XF86XK_ZoomOut 0x1008FF8C
-
-#define XF86XK_Away 0x1008FF8D
-#define XF86XK_Messenger 0x1008FF8E
-#define XF86XK_WebCam 0x1008FF8F
-#define XF86XK_MailForward 0x1008FF90
-#define XF86XK_Pictures 0x1008FF91
-#define XF86XK_Music 0x1008FF92
-
-/* Keys for special action keys (hot keys) */
-#define XF86XK_Switch_VT_1 0x1008FE01
-#define XF86XK_Switch_VT_2 0x1008FE02
-#define XF86XK_Switch_VT_3 0x1008FE03
-#define XF86XK_Switch_VT_4 0x1008FE04
-#define XF86XK_Switch_VT_5 0x1008FE05
-#define XF86XK_Switch_VT_6 0x1008FE06
-#define XF86XK_Switch_VT_7 0x1008FE07
-#define XF86XK_Switch_VT_8 0x1008FE08
-#define XF86XK_Switch_VT_9 0x1008FE09
-#define XF86XK_Switch_VT_10 0x1008FE0A
-#define XF86XK_Switch_VT_11 0x1008FE0B
-#define XF86XK_Switch_VT_12 0x1008FE0C
-
-#define XF86XK_Ungrab 0x1008FE20
-#define XF86XK_ClearGrab 0x1008FE21
-#define XF86XK_Next_VMode 0x1008FE22
-#define XF86XK_Prev_VMode 0x1008FE23
-
-
diff --git a/navit/support/win32/addwinsock.c b/navit/support/win32/addwinsock.c
deleted file mode 100644
index 63ae968d5..000000000
--- a/navit/support/win32/addwinsock.c
+++ /dev/null
@@ -1,8 +0,0 @@
-#include "addwinsock.h"
-
-int inet_aton(const char *cp, struct in_addr *inp)
-{
- unsigned long addr = inet_addr(cp);
- inp->S_un.S_addr = addr;
- return addr != -1;
-}
diff --git a/navit/support/win32/addwinsock.h b/navit/support/win32/addwinsock.h
deleted file mode 100644
index 49dfdc0cb..000000000
--- a/navit/support/win32/addwinsock.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef ADD_WINSOCK
-#define ADD_WINSOCK
-
-#include <winsock2.h>
-
-int inet_aton(const char *cp, struct in_addr *inp);
-
-#endif
diff --git a/navit/support/win32/mmap.c b/navit/support/win32/mmap.c
deleted file mode 100644
index 008ffa66f..000000000
--- a/navit/support/win32/mmap.c
+++ /dev/null
@@ -1,43 +0,0 @@
-#include <windows.h>
-#include "sys/mman.h"
-
-void * mmap_readonly_win32( const char* name, long* map_handle_ptr, long* map_file_ptr )
-{
- void * mapped_ptr = NULL;
-#if defined(__CEGCC__)
-
- wchar_t filename[MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, strlen(name), 0, 0)];
- MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, strlen(name), filename, wcslen(filename)) ;
-
- HANDLE hFile = CreateFile (filename, GENERIC_READ, FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
-#else
- HANDLE hFile = CreateFile (name, GENERIC_READ, FILE_SHARE_READ,0,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0);
-#endif
- *map_file_ptr = (long)hFile;
- *map_handle_ptr = 0;
-
- if ( hFile != HFILE_ERROR )
- {
- HANDLE hMapping = CreateFileMapping( (HANDLE)hFile, NULL, PAGE_READONLY, 0, 0, NULL);
- mapped_ptr = MapViewOfFile(hMapping, FILE_MAP_READ, 0 , 0, 0 );
- *map_handle_ptr = (long)hMapping;
- }
-
- return mapped_ptr;
-}
-
-void mmap_unmap_win32( void* mem_ptr, long map_handle, long map_file )
-{
- if ( mem_ptr != NULL )
- {
- UnmapViewOfFile( mem_ptr );
- }
- if ( map_handle != 0)
- {
- CloseHandle( (HANDLE)map_handle );
- }
- if ( map_file != 0 )
- {
- CloseHandle( (HANDLE)map_file );
- }
-}
diff --git a/navit/support/win32/serial_io.c b/navit/support/win32/serial_io.c
deleted file mode 100644
index 2eba8ece1..000000000
--- a/navit/support/win32/serial_io.c
+++ /dev/null
@@ -1,166 +0,0 @@
-#include <stdio.h>
-#include <windows.h>
-#include <glib.h>
-#include "serial_io.h"
-#include "debug.h"
-
-//***************************************************************************
-/** @fn int serial_io_init( const char* port, const char* strsettings )
-*****************************************************************************
-* @b Description: initialise a serial port communication
-*****************************************************************************
-* @param port : port name
-* example 'COM7'
-* @param strsettings : port settings
-* example ; 'baud=115200 parity=N data=8 stop=1'
-*****************************************************************************
-* @return file descriptor
-* -1 if error
-*****************************************************************************
-**/
-int serial_io_init( const char* port, const char* strsettings )
-{
- HANDLE hCom = NULL;
- DCB dcb;
- COMMTIMEOUTS sCT;
-
- char strport[16];
- g_snprintf( strport, sizeof( strport ), "\\\\.\\%s", port );
-
- hCom = CreateFile(
- strport,
- GENERIC_WRITE | GENERIC_READ,
- 0,
- 0,
- OPEN_EXISTING,
- 0,
- NULL);
-
- if (hCom == INVALID_HANDLE_VALUE)
- {
- LPVOID lpMsgBuf;
-
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) &lpMsgBuf,
- 0,
- NULL
- );
- dbg(lvl_warning, "return (fd) : '-1' : serial_io_init error : '%s'\n", lpMsgBuf);
-
- LocalFree( lpMsgBuf ); // Free the buffer.
- return -1;
- }
-
- ZeroMemory(&dcb, sizeof(DCB));
-
- GetCommState(hCom, &dcb);
-
- BuildCommDCB( strsettings, &dcb);
-
- SetupComm(hCom, 4096, 4096);
-
- SetCommState(hCom, &dcb);
-
- memset(&sCT, 0, sizeof(sCT));
- sCT.ReadTotalTimeoutConstant = 10;
-
- SetCommTimeouts(hCom, &sCT);
-
- dbg(lvl_debug, "serial_io_init return (fd) : '%d'\n", (int)hCom);
-
- return (int)hCom;
-}
-
-//***************************************************************************
-/** @fn int serial_io_read( int fd, char * buffer, int buffer_size )
-*****************************************************************************
-* @b Description: Read bytes on the serial port
-*****************************************************************************
-* @param fd : file descriptor
-* @param buffer : buffer for data
-* @param buffer_size : size in byte of the buffer
-*****************************************************************************
-* @return number of bytes read
-*****************************************************************************
-* @remarks buffer must be allocated by the caller
-*****************************************************************************
-**/
-int serial_io_read( int fd, char * buffer, int buffer_size )
-{
- DWORD dwBytesIn = 0;
- dbg(lvl_debug, "serial_io_read fd = %d buffer_size = %d\n", fd, buffer_size);
-
-
- if (fd <= 0)
- {
- dbg(lvl_debug, "serial_io_read return (dwBytesIn) : '0'\n");
- *buffer = 0;
- return 0;
- }
-
- ReadFile( (HANDLE)fd, buffer, buffer_size - 1, &dwBytesIn, NULL);
-
- if (dwBytesIn >= 0)
- {
- buffer[dwBytesIn] = 0;
- }
- else
- {
- dwBytesIn = 0;
- buffer[0] = 0;
- }
- if (dwBytesIn > 0)
- {
- dbg(lvl_debug,"GPS < %s\n",buffer );
- }
- buffer[buffer_size - 1] = 0;
-
- dbg(lvl_info, "serial_io_read return (dwBytesIn) : '%d'\n", dwBytesIn);
- return dwBytesIn;
-}
-
-//***************************************************************************
-/** @fn int serial_io_write(int fd, const char * buffer)
-*****************************************************************************
-* @b Description: Write bytes on the serial port
-*****************************************************************************
-* @param fd : file descriptor
-* @param buffer : data buffer (null terminated)
-*****************************************************************************
-* @return number of bytes written
-*****************************************************************************
-**/
-int serial_io_write(int fd, const char * buffer)
-{
- DWORD dwBytesOut = 0;
- dbg(lvl_debug, "serial_io_write fd = %d buffer = '%s'\n",fd, buffer);
-
-
- WriteFile((HANDLE)fd, buffer, strlen(buffer), &dwBytesOut, NULL);
-
- return dwBytesOut;
-}
-
-//***************************************************************************
-/** @fn void serial_io_shutdown(int fd )
-*****************************************************************************
-* @b Description: Terminate serial communication
-*****************************************************************************
-* @param fd : file descriptor
-*****************************************************************************
-**/
-void serial_io_shutdown(int fd )
-{
- dbg(lvl_debug, "serial_io_shutdown fd = %d\n",fd);
-
- if (fd > 0)
- {
- CloseHandle((HANDLE)fd);
- }
-}
diff --git a/navit/support/win32/serial_io.h b/navit/support/win32/serial_io.h
deleted file mode 100644
index 0526a217a..000000000
--- a/navit/support/win32/serial_io.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef SERIAL_IO_H_INCLUDED
-#define SERIAL_IO_H_INCLUDED
-
-int serial_io_init( const char* port, const char* strsettings );
-int serial_io_read(int fd, char * buffer, int buffer_size );
-int serial_io_write(int fd, const char * buffer);
-void serial_io_shutdown(int fd );
-typedef unsigned int speed_t;
-
-#define B0 0000000
-#define B50 0000001
-#define B75 0000002
-#define B110 0000003
-#define B134 0000004
-#define B150 0000005
-#define B200 0000006
-#define B300 0000007
-#define B600 0000010
-#define B1200 0000011
-#define B1800 0000012
-#define B2400 0000013
-#define B4800 0000014
-#define B9600 0000015
-#define B19200 0000016
-#define B38400 0000017
-#define B57600 0010001
-#define B115200 0010002
-#define B230400 0010003
-#define B460800 0010004
-#define B500000 0010005
-#define B576000 0010006
-#define B921600 0010007
-#define B1000000 0010010
-#define B1152000 0010011
-#define B1500000 0010012
-#define B2000000 0010013
-#define B2500000 0010014
-#define B3000000 0010015
-#define B3500000 0010016
-#define B4000000 0010017
-
-#endif
diff --git a/navit/support/win32/stdint.h b/navit/support/win32/stdint.h
deleted file mode 100644
index 785a6398f..000000000
--- a/navit/support/win32/stdint.h
+++ /dev/null
@@ -1,13 +0,0 @@
-#ifndef _MSC_VER
-#include_next <stdint.h>
-#else
-typedef signed char int8_t;
-typedef unsigned char uint8_t;
-typedef short int16_t;
-typedef unsigned short uint16_t;
-typedef int int32_t;
-typedef unsigned uint32_t;
-typedef long long int64_t;
-typedef unsigned long long uint64_t;
-typedef unsigned long long uintmax_t;
-#endif /* _MSC_VER */
diff --git a/navit/support/win32/sys/mman.h b/navit/support/win32/sys/mman.h
deleted file mode 100644
index 37e59b9ec..000000000
--- a/navit/support/win32/sys/mman.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef _WIN32_MMAN_H_INCLUDED
-#define _WIN32_MMAN_H_INCLUDED
-
-void * mmap_readonly_win32( const char* name, long* map_handle_ptr, long* map_file_ptr );
-void mmap_unmap_win32( void* mem_ptr, long map_handle, long map_file );
-
-#endif /* !_WIN32_MMAN_H_INCLUDED */
-
diff --git a/navit/support/win32/win32_init.c b/navit/support/win32/win32_init.c
deleted file mode 100644
index 32be387da..000000000
--- a/navit/support/win32/win32_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "plugin.h"
-
-void
-plugin_init(void)
-{
-}
diff --git a/navit/support/wordexp/CMakeLists.txt b/navit/support/wordexp/CMakeLists.txt
deleted file mode 100644
index 650c9d1de..000000000
--- a/navit/support/wordexp/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-supportlib_add_library(support_wordexp wordexp.c wordexp_init.c glob.c)
diff --git a/navit/support/wordexp/glob.c b/navit/support/wordexp/glob.c
deleted file mode 100644
index 8337367dd..000000000
--- a/navit/support/wordexp/glob.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/**
- * Navit, a modular navigation system.
- * Copyright (C) 2005-2008 Navit Team
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * version 2 as published by the Free Software Foundation.
- *
- * 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., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
- */
-
-/*
- * @file glob.c
- */
-
-#include <config.h>
-
-#ifndef HAVE_GLOB
-#if defined _WIN32 || defined _WIN32_WCE
-#include <windows.h>
-#include "glob.h"
-
-/*
- * @brief searches for all the pathnames matching pattern according to the rules
- * which is similar to the rules used by common shells.
- * here: expanding of ´*´ and ´?´ only in filenames
- * @param pattern: no tilde expansion or parameter substitution is done.
- * @param flags: not supported here
- * @param errfunc: not supported here
- * @param pglob: struct with array containing the matched files/directories
- * @return FALSE on error.
- */
-int glob(const char *pattern, int flags,
- int (*errfunc)(const char *epath, int eerrno),
- glob_t *pglob)
-{
- char *pathend,
- *filename;
- int pathlen;
- HANDLE hFiles;
-#ifndef UNICODE
- WIN32_FIND_DATA xFindData;
- hFiles = FindFirstFile (pattern, &xFindData);
-#else
- int len = strlen(pattern) * sizeof(wchar_t*);
- wchar_t *pathname = malloc(len);
- WIN32_FIND_DATAW xFindData;
- mbstowcs (pathname, pattern, len);
- hFiles = FindFirstFile (pathname, &xFindData);
-#endif
-
- if(hFiles == INVALID_HANDLE_VALUE)
- {
- return 1;
- }
- /* store the path information */
- pathend = max (strrchr (pattern, '\\'), strrchr (pattern, '/'));
- pathlen = pathend ? (pathend - pattern + 1) : 0;
-
- /* glob */
- pglob->gl_pathc = 0; /* number of founded files */
- pglob->gl_offs = 0; /* not needed */
- pglob->gl_pathv = malloc(sizeof(char*)); /* list of file names */
-
- do
- {
- pglob->gl_pathc++;
- pglob->gl_pathv = realloc (pglob->gl_pathv, pglob->gl_pathc * sizeof(char*));
-#ifndef UNICODE
- filename = xFindData.cFileName;
-#else
- len = wcslen(xFindData.cFileName) * sizeof(char*);
- filename = malloc (len);
- wcstombs (filename, xFindData.cFileName, len);
-#endif
- pglob->gl_pathv[pglob->gl_pathc - 1] = malloc ((pathlen + strlen (filename) + 1) * sizeof(char*));
- strncpy (pglob->gl_pathv[pglob->gl_pathc - 1], pattern, pathlen);
- // strcpy (pglob->gl_pathv[pglob->gl_pathc - 1] + pathlen - 1, filename);
- // The above line should be uncommented later. Currently, the blow line needs to be in use.
- // If not, navit on WinCE / Win32 cannot "find" the maps and bookmarks folder
- strcpy (pglob->gl_pathv[pglob->gl_pathc - 1] + pathlen, filename);
- } while (FindNextFile (hFiles, &xFindData));
-
- FindClose(hFiles);
- return 0;
-}
-#else
-
-#include <dirent.h>
-#include <string.h>
-#include <fnmatch.h>
-#include "debug.h"
-#include "glob.h"
-
-static int
-glob_requires_match(const char *pattern, int flags)
-{
- for (;;) {
- switch (*pattern++) {
- case '\0':
- return 0;
- case '?':
- case '*':
- case '[':
- return 1;
- case '\\':
- if (!*pattern++)
- return 0;
- }
- }
- return 0;
-}
-
-static int
-glob_recursive(const char *path1, const char *path2, const char *pattern, int flags, int (*errfunc) (const char *epath, int eerrno), glob_t *pglob)
-{
- const char *next;
- char *fname,*path=malloc(strlen(path1)+strlen(path2)+2);
- int flen;
- strcpy(path, path1);
- if (path1[0] && path2[0] && (path1[1] != '\0' || path1[0] != '/'))
- strcat(path, "/");
- strcat(path, path2);
- if (!strlen(pattern)) {
- dbg(lvl_debug,"found %s\n",path);
- pglob->gl_pathv=realloc(pglob->gl_pathv, (pglob->gl_pathc+1)*sizeof(char *));
- if (!pglob->gl_pathv) {
- pglob->gl_pathc=0;
- return GLOB_NOSPACE;
- }
- pglob->gl_pathv[pglob->gl_pathc++]=path;
- return 0;
- }
- dbg(lvl_debug,"searching for %s in %s\n",pattern,path);
- flen=strcspn(pattern,"/");
- next=pattern+flen;
- if (*next == '/')
- next++;
- fname=malloc(flen+1);
- strncpy(fname, pattern, flen);
- fname[flen]='\0';
- if (glob_requires_match(fname, 0)) {
- DIR *dh;
- struct dirent *de;
- dbg(lvl_debug,"in dir %s search for %s\n",path,fname);
- dh=opendir(path);
- if (dh) {
- while ((de=readdir(dh))) {
- if (fnmatch(fname,de->d_name,0) == 0) {
- glob_recursive(path, de->d_name, next, flags, errfunc, pglob);
- }
- }
- closedir(dh);
- }
- } else {
- glob_recursive(path, fname, next, flags, errfunc, pglob);
- }
- free(fname);
- free(path);
- return 0;
-}
-
-int
-glob(const char *pattern, int flags, int (*errfunc) (const char *epath, int eerrno), glob_t *pglob)
-{
- pglob->gl_pathc=0;
- pglob->gl_pathv=NULL;
- if (pattern[0] == '/')
- return glob_recursive("/", "", pattern+1, flags, errfunc, pglob);
- else
- return glob_recursive("", "", pattern, flags, errfunc, pglob);
-}
-
-#endif /* _WIN32 || _WIN32_WCE */
-
-void globfree(glob_t *pglob)
-{
- int i;
-
- for (i=0; i < pglob->gl_pathc; i++)
- {
- free (pglob->gl_pathv[i]);
- }
- free (pglob->gl_pathv);
- pglob->gl_pathc = 0;
-}
-
-#endif /* HAVE_GLOB */
diff --git a/navit/support/wordexp/glob.h b/navit/support/wordexp/glob.h
deleted file mode 100644
index d36ac29e6..000000000
--- a/navit/support/wordexp/glob.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef _GLOB_H_
-#define _GLOB_H_
-
-#ifndef HAVE_GLOB
-
-typedef struct {
- size_t gl_pathc; /* count of file names */
- char **gl_pathv; /* list of file names */
- size_t gl_offs; /* slots to reserve in gl_pathv */
-} glob_t;
-
-int glob(const char *pattern, int flags, int (*errfunc)(const char *epath, int eerrno), glob_t *pglob);
-void globfree(glob_t *pglob);
-
-#define GLOB_NOSPACE 1
-
-#endif
-
-#endif /* _GLOB_H_ */
diff --git a/navit/support/wordexp/wordexp.c b/navit/support/wordexp/wordexp.c
deleted file mode 100644
index 6b080d1f7..000000000
--- a/navit/support/wordexp/wordexp.c
+++ /dev/null
@@ -1,136 +0,0 @@
-
-#include <config.h>
-
-#include <sys/types.h>
-#include <assert.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#ifndef _MSC_VER
-#include <unistd.h>
-#endif /* _MSC_VER */
-#include "wordexp.h"
-#include "glob.h"
-#include <glib.h>
-
-
-static int
-is_valid_variable_char(char c, int pos)
-{
- if ( (pos && c >= '0' && c <= '9') ||
- c == '_' ||
- (c >= 'a' && c <= 'z') ||
- (c >= 'A' && c <= 'Z'))
- return 1;
- return 0;
-}
-
-/*
- * @brief replace all names of $NAME ${NAME}
- * with the corresponding environment variable
- * @ param in: the string to be checked
- * @ return the expanded string or a copy of the existing string
- * must be free() by the calling function
-*/
-static char *
-expand_variables(const char *in)
-{
- char *var,*pos,*ret=g_strdup(in);
- char *val,*str;
- pos=ret;
- while ((var=strchr(pos, '$'))) {
- char *name,*begin=var+1;
- int npos=0,bpos=0,slen,elen;
- *var='\0';
- if (var[1] == '{') {
- begin++;
- while (begin[npos]) {
- bpos=npos;
- if (begin[npos++] == '}')
- break;
- }
- } else {
- while (is_valid_variable_char(begin[npos],npos))
- npos++;
- bpos=npos;
- }
- name=g_strdup(begin);
- name[bpos]='\0';
- val=getenv(name);
- free(name);
- if (! val)
- val="";
- slen=strlen(ret)+strlen(val);
- elen=strlen(begin+npos);
- str=malloc(slen+elen+1);
- strcpy(str,ret);
- strcat(str,val);
- strcat(str,begin+npos);
- free(ret);
- ret=str;
- pos=ret+slen;
- }
- return ret;
-}
-
-/*
- * @brief minimal realization of wordexp according to IEEE standard
- * shall perform word expansion as described in the Shell
- * expansion of ´$NAME´ or ´${NAME}´
- * expansion of ´*´ and ´?´
- * @param words: pointer to a string containing one or more words to be expanded
- * but here only one word supported
- */
-int
-wordexp(const char *words, wordexp_t *we, int flags)
-{
- int i;
- int error = 0;
- char *words_expanded;
- glob_t pglob;
-
- assert(we != NULL);
- assert(words != NULL);
-
- /* expansion of ´$NAME´ or ´${NAME}´ */
- words_expanded=expand_variables(words);
- /* expansion of ´*´, ´?´ */
- error=glob(words_expanded, 0, NULL, &pglob);
- if (!error)
- {
- /* copy the content of struct of glob into struct of wordexp */
- we->we_wordc = pglob.gl_pathc;
- we->we_offs = pglob.gl_offs;
- we->we_wordv = malloc(we->we_wordc * sizeof(char*));
- for (i=0; i<we->we_wordc; i++)
- {
- we->we_wordv[i] = g_strdup(pglob.gl_pathv[i]);
- }
- globfree(&pglob);
- free(words_expanded);
- }
- else
- {
- we->we_wordc = 1;
- we->we_wordv = malloc(sizeof(char*));
- we->we_wordv[0] = words_expanded;
- }
-
-
- return error;
-}
-
-
-void wordfree(wordexp_t *we)
-{
- int i;
-
- for (i=0; i < we->we_wordc; i++)
- {
- free (we->we_wordv[i]);
- }
-
- free (we->we_wordv);
- we->we_wordc = 0;
-}
diff --git a/navit/support/wordexp/wordexp.h b/navit/support/wordexp/wordexp.h
deleted file mode 100644
index ad18c7854..000000000
--- a/navit/support/wordexp/wordexp.h
+++ /dev/null
@@ -1,42 +0,0 @@
-#ifndef _WORDEXP_H_
-#define _WORDEXP_H_
-
-
-typedef struct {
- size_t we_wordc; /* count of words matched */
- char **we_wordv; /* pointer to list of words */
- size_t we_offs; /* slots to reserve in we_wordv */
- /* following are internals */
- char *we_strings; /* storage for wordv strings */
- size_t we_nbytes; /* size of we_strings */
-} wordexp_t;
-
-/*
- * Flags for wordexp().
- */
-#define WRDE_APPEND 0x1 /* append to previously generated */
-#define WRDE_DOOFFS 0x2 /* we_offs member is valid */
-#define WRDE_NOCMD 0x4 /* disallow command substitution */
-#define WRDE_REUSE 0x8 /* reuse wordexp_t */
-#define WRDE_SHOWERR 0x10 /* don't redirect stderr to /dev/null */
-#define WRDE_UNDEF 0x20 /* disallow undefined shell vars */
-
-/*
- * Return values from wordexp().
- */
-#define WRDE_BADCHAR 1 /* unquoted special character */
-#define WRDE_BADVAL 2 /* undefined variable */
-#define WRDE_CMDSUB 3 /* command substitution not allowed */
-#define WRDE_NOSPACE 4 /* no memory for result */
-#if (_XOPEN_SOURCE - 0) >= 4 || defined(_NETBSD_SOURCE)
-#define WRDE_NOSYS 5 /* obsolete, reserved */
-#endif
-#define WRDE_SYNTAX 6 /* shell syntax error */
-#define WRDE_ERRNO 7 /* other errors see errno */
-
-void wordfree(wordexp_t *);
-int wordexp(const char * words, wordexp_t * we, int flags);
-
-
-#endif /* !_WORDEXP_H_ */
-
diff --git a/navit/support/wordexp/wordexp_init.c b/navit/support/wordexp/wordexp_init.c
deleted file mode 100644
index 32be387da..000000000
--- a/navit/support/wordexp/wordexp_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "plugin.h"
-
-void
-plugin_init(void)
-{
-}
diff --git a/navit/support/xgetopt/CMakeLists.txt b/navit/support/xgetopt/CMakeLists.txt
deleted file mode 100644
index 98a333f82..000000000
--- a/navit/support/xgetopt/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-supportlib_add_library(support_xgetopt XGetopt.c getopt_long.c)
-
diff --git a/navit/support/xgetopt/XGetopt.c b/navit/support/xgetopt/XGetopt.c
deleted file mode 100644
index d6174d826..000000000
--- a/navit/support/xgetopt/XGetopt.c
+++ /dev/null
@@ -1,216 +0,0 @@
-// XGetopt.cpp Version 1.2
-//
-// Author: Hans Dietrich
-// hdietrich2@hotmail.com
-//
-// Description:
-// XGetopt.cpp implements getopt(), a function to parse command lines.
-//
-// History
-// Version 1.2 - 2003 May 17
-// - Added Unicode support
-//
-// Version 1.1 - 2002 March 10
-// - Added example to XGetopt.cpp module header
-//
-// This software is released into the public domain.
-// You are free to use it in any way you like.
-//
-// This software is provided "as is" with no expressed
-// or implied warranty. I accept no liability for any
-// damage or loss of business that this software may cause.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-
-
-///////////////////////////////////////////////////////////////////////////////
-// if you are not using precompiled headers then include these lines:
-#include <windows.h>
-#include <stdio.h>
-///////////////////////////////////////////////////////////////////////////////
-
-
-#include "XGetopt.h"
-
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// X G e t o p t . c p p
-//
-//
-// NAME
-// getopt -- parse command line options
-//
-// SYNOPSIS
-// int getopt(int argc, char *argv[], char *optstring)
-//
-// extern char *optarg;
-// extern int optind;
-//
-// DESCRIPTION
-// The getopt() function parses the command line arguments. Its
-// arguments argc and argv are the argument count and array as
-// passed into the application on program invocation. In the case
-// of Visual C++ programs, argc and argv are available via the
-// variables __argc and __argv (double underscores), respectively.
-// getopt returns the next option letter in argv that matches a
-// letter in optstring. (Note: Unicode programs should use
-// __targv instead of __argv. Also, all character and string
-// literals should be enclosed in _T( ) ).
-//
-// optstring is a string of recognized option letters; if a letter
-// is followed by a colon, the option is expected to have an argument
-// that may or may not be separated from it by white space. optarg
-// is set to point to the start of the option argument on return from
-// getopt.
-//
-// Option letters may be combined, e.g., "-ab" is equivalent to
-// "-a -b". Option letters are case sensitive.
-//
-// getopt places in the external variable optind the argv index
-// of the next argument to be processed. optind is initialized
-// to 0 before the first call to getopt.
-//
-// When all options have been processed (i.e., up to the first
-// non-option argument), getopt returns EOF, optarg will point
-// to the argument, and optind will be set to the argv index of
-// the argument. If there are no non-option arguments, optarg
-// will be set to NULL.
-//
-// The special option "--" may be used to delimit the end of the
-// options; EOF will be returned, and "--" (and everything after it)
-// will be skipped.
-//
-// RETURN VALUE
-// For option letters contained in the string optstring, getopt
-// will return the option letter. getopt returns a question mark (?)
-// when it encounters an option letter not included in optstring.
-// EOF is returned when processing is finished.
-//
-// BUGS
-// 1) Long options are not supported.
-// 2) The GNU double-colon extension is not supported.
-// 3) The environment variable POSIXLY_CORRECT is not supported.
-// 4) The + syntax is not supported.
-// 5) The automatic permutation of arguments is not supported.
-// 6) This implementation of getopt() returns EOF if an error is
-// encountered, instead of -1 as the latest standard requires.
-//
-// EXAMPLE
-// BOOL CMyApp::ProcessCommandLine(int argc, char *argv[])
-// {
-// int c;
-//
-// while ((c = getopt(argc, argv, "aBn:")) != EOF)
-// {
-// switch (c)
-// {
-// case 'a':
-// TRACE("option a\n");
-// //
-// // set some flag here
-// //
-// break;
-//
-// case 'B':
-// TRACE( "option B\n");
-// //
-// // set some other flag here
-// //
-// break;
-//
-// case 'n':
-// TRACE("option n: value=%d\n", atoi(optarg));
-// //
-// // do something with value here
-// //
-// break;
-//
-// case '?':
-// TRACE("ERROR: illegal option %s\n", argv[optind-1]);
-// return FALSE;
-// break;
-//
-// default:
-// TRACE("WARNING: no handler for option %c\n", c);
-// return FALSE;
-// break;
-// }
-// }
-// //
-// // check for non-option args here
-// //
-// return TRUE;
-// }
-//
-///////////////////////////////////////////////////////////////////////////////
-
-char *optarg; // global argument pointer
-int optind = 0; // global argv index
-
-int getopt(int argc, char *argv[], char *optstring)
-{
- static char *next = NULL;
- char c;
- char *cp;
-
- if (optind == 0)
- next = NULL;
-
- optarg = NULL;
-
- if (next == NULL || *next == '\0')
- {
- if (optind == 0)
- optind++;
-
- if (optind >= argc || argv[optind][0] != '-' || argv[optind][1] == '\0')
- {
- optarg = NULL;
- if (optind < argc)
- optarg = argv[optind];
- return EOF;
- }
-
- if (strcmp(argv[optind], "--") == 0)
- {
- optind++;
- optarg = NULL;
- if (optind < argc)
- optarg = argv[optind];
- return EOF;
- }
-
- next = argv[optind];
- next++; // skip past -
- optind++;
- }
-
- c = *next++;
- cp = strchr(optstring, c);
-
- if (cp == NULL || c == ':')
- return '?';
-
- cp++;
- if (*cp == ':')
- {
- if (*next != '\0')
- {
- optarg = next;
- next = NULL;
- }
- else if (optind < argc)
- {
- optarg = argv[optind];
- optind++;
- }
- else
- {
- return '?';
- }
- }
-
- return c;
-}
diff --git a/navit/support/xgetopt/XGetopt.h b/navit/support/xgetopt/XGetopt.h
deleted file mode 100644
index b975026c1..000000000
--- a/navit/support/xgetopt/XGetopt.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// XGetopt.h Version 1.2
-//
-// Author: Hans Dietrich
-// hdietrich2@hotmail.com
-//
-// This software is released into the public domain.
-// You are free to use it in any way you like.
-//
-// This software is provided "as is" with no expressed
-// or implied warranty. I accept no liability for any
-// damage or loss of business that this software may cause.
-//
-///////////////////////////////////////////////////////////////////////////////
-
-#ifndef XGETOPT_H
-#define XGETOPT_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int optind, opterr;
-extern char *optarg;
-
-int getopt(int argc, char *argv[], char *optstring);
-#ifdef __cplusplus
-}
-#endif
-#endif //XGETOPT_H
diff --git a/navit/support/xgetopt/getopt_long.c b/navit/support/xgetopt/getopt_long.c
deleted file mode 100644
index b5cce831c..000000000
--- a/navit/support/xgetopt/getopt_long.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * getopt_long() -- long options parser
- *
- * Portions Copyright (c) 1987, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Portions Copyright (c) 2003
- * PostgreSQL Global Development Group
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * src/port/getopt_long.c
- */
-
-#include <stdio.h>
-#include <string.h>
-
-#include "getopt_long.h"
-
-int opterr;
-int optopt;
-
-#define BADCH '?'
-#define BADARG ':'
-#define EMSG ""
-
-
-/*
- * getopt_long
- * Parse argc/argv argument vector, with long options.
- *
- * This implementation does not use optreset. Instead, we guarantee that
- * it can be restarted on a new argv array after a previous call returned -1,
- * if the caller resets optind to 1 before the first call of the new series.
- * (Internally, this means we must be sure to reset "place" to EMSG before
- * returning -1.)
- */
-int
-getopt_long(int argc, char *const argv[],
- const char *optstring,
- const struct option * longopts, int *longindex)
-{
- static char *place = EMSG; /* option letter processing */
- char *oli; /* option letter list index */
-
- /* getopt initialises optind to 1, but XGetopt defines it as 0 which breaks getopt_long */
- if(optind == 0)
- optind=1;
-
- if (!*place)
- { /* update scanning pointer */
- if (optind >= argc)
- {
- place = EMSG;
- return -1;
- }
-
- place = argv[optind];
-
- if (place[0] != '-')
- {
- place = EMSG;
- return -1;
- }
-
- place++;
-
- if (place[0] && place[0] == '-' && place[1] == '\0')
- { /* found "--" */
- ++optind;
- place = EMSG;
- return -1;
- }
-
- if (place[0] && place[0] == '-' && place[1])
- {
- /* long option */
- size_t namelen;
- int i;
-
- place++;
-
- namelen = strcspn(place, "=");
- for (i = 0; longopts[i].name != NULL; i++)
- {
- if (strlen(longopts[i].name) == namelen
- && strncmp(place, longopts[i].name, namelen) == 0)
- {
- if (longopts[i].has_arg)
- {
- if (place[namelen] == '=')
- optarg = place + namelen + 1;
- else if (optind < argc - 1)
- {
- optind++;
- optarg = argv[optind];
- }
- else
- {
- if (optstring[0] == ':')
- return BADARG;
- if (opterr)
- fprintf(stderr,
- "%s: option requires an argument -- %s\n",
- argv[0], place);
- place = EMSG;
- optind++;
- return BADCH;
- }
- }
- else
- {
- optarg = NULL;
- if (place[namelen] != 0)
- {
- /* XXX error? */
- }
- }
-
- optind++;
-
- if (longindex)
- *longindex = i;
-
- place = EMSG;
-
- if (longopts[i].flag == NULL)
- return longopts[i].val;
- else
- {
- *longopts[i].flag = longopts[i].val;
- return 0;
- }
- }
- }
-
- if (opterr && optstring[0] != ':')
- fprintf(stderr,
- "%s: illegal option -- %s\n", argv[0], place);
- place = EMSG;
- optind++;
- return BADCH;
- }
- }
-
- /* short option */
- optopt = (int) *place++;
-
- oli = strchr(optstring, optopt);
- if (!oli)
- {
- if (!*place)
- ++optind;
- if (opterr && *optstring != ':')
- fprintf(stderr,
- "%s: illegal option -- %c\n", argv[0], optopt);
- return BADCH;
- }
-
- if (oli[1] != ':')
- { /* don't need argument */
- optarg = NULL;
- if (!*place)
- ++optind;
- }
- else
- { /* need an argument */
- if (*place) /* no white space */
- optarg = place;
- else if (argc <= ++optind)
- { /* no arg */
- place = EMSG;
- if (*optstring == ':')
- return BADARG;
- if (opterr)
- fprintf(stderr,
- "%s: option requires an argument -- %c\n",
- argv[0], optopt);
- return BADCH;
- }
- else
- /* white space */
- optarg = argv[optind];
- place = EMSG;
- ++optind;
- }
- return optopt;
-}
diff --git a/navit/support/xgetopt/getopt_long.h b/navit/support/xgetopt/getopt_long.h
deleted file mode 100644
index 5d16ca4b1..000000000
--- a/navit/support/xgetopt/getopt_long.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Portions Copyright (c) 1987, 1993, 1994
- * The Regents of the University of California. All rights reserved.
- *
- * Portions Copyright (c) 2003-2011, PostgreSQL Global Development Group
- *
- * src/include/getopt_long.h
- */
-#ifndef GETOPT_LONG_H
-#define GETOPT_LONG_H
-
-#ifdef HAVE_GETOPT_H
-#include <getopt.h>
-#endif
-
-/* These are picked up from the system's getopt() facility. */
-extern int opterr;
-extern int optind;
-extern int optopt;
-extern char *optarg;
-
-#ifndef HAVE_STRUCT_OPTION
-
-struct option
-{
- const char *name;
- int has_arg;
- int *flag;
- int val;
-};
-
-#define no_argument 0
-#define required_argument 1
-#endif
-
-#ifndef HAVE_GETOPT_LONG
-
-extern int getopt_long(int argc, char *const argv[],
- const char *optstring,
- const struct option * longopts, int *longindex);
-#endif
-
-#endif /* GETOPT_LONG_H */
diff --git a/navit/support/zlib/CMakeLists.txt b/navit/support/zlib/CMakeLists.txt
deleted file mode 100644
index 66d30198c..000000000
--- a/navit/support/zlib/CMakeLists.txt
+++ /dev/null
@@ -1 +0,0 @@
-supportlib_add_library(support_zlib adler32.c crc32.c infback.c inffast.c inflate.c inftrees.c zutil.c zlib_init.c)
diff --git a/navit/support/zlib/adler32.c b/navit/support/zlib/adler32.c
deleted file mode 100644
index 007ba2627..000000000
--- a/navit/support/zlib/adler32.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/* adler32.c -- compute the Adler-32 checksum of a data stream
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-#define BASE 65521UL /* largest prime smaller than 65536 */
-#define NMAX 5552
-/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
-
-#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
-#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
-#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
-#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
-#define DO16(buf) DO8(buf,0); DO8(buf,8);
-
-/* use NO_DIVIDE if your processor does not do division in hardware */
-#ifdef NO_DIVIDE
-# define MOD(a) \
- do { \
- if (a >= (BASE << 16)) a -= (BASE << 16); \
- if (a >= (BASE << 15)) a -= (BASE << 15); \
- if (a >= (BASE << 14)) a -= (BASE << 14); \
- if (a >= (BASE << 13)) a -= (BASE << 13); \
- if (a >= (BASE << 12)) a -= (BASE << 12); \
- if (a >= (BASE << 11)) a -= (BASE << 11); \
- if (a >= (BASE << 10)) a -= (BASE << 10); \
- if (a >= (BASE << 9)) a -= (BASE << 9); \
- if (a >= (BASE << 8)) a -= (BASE << 8); \
- if (a >= (BASE << 7)) a -= (BASE << 7); \
- if (a >= (BASE << 6)) a -= (BASE << 6); \
- if (a >= (BASE << 5)) a -= (BASE << 5); \
- if (a >= (BASE << 4)) a -= (BASE << 4); \
- if (a >= (BASE << 3)) a -= (BASE << 3); \
- if (a >= (BASE << 2)) a -= (BASE << 2); \
- if (a >= (BASE << 1)) a -= (BASE << 1); \
- if (a >= BASE) a -= BASE; \
- } while (0)
-# define MOD4(a) \
- do { \
- if (a >= (BASE << 4)) a -= (BASE << 4); \
- if (a >= (BASE << 3)) a -= (BASE << 3); \
- if (a >= (BASE << 2)) a -= (BASE << 2); \
- if (a >= (BASE << 1)) a -= (BASE << 1); \
- if (a >= BASE) a -= BASE; \
- } while (0)
-#else
-# define MOD(a) a %= BASE
-# define MOD4(a) a %= BASE
-#endif
-
-/* ========================================================================= */
-uLong ZEXPORT adler32(adler, buf, len)
- uLong adler;
- const Bytef *buf;
- uInt len;
-{
- unsigned long sum2;
- unsigned n;
-
- /* split Adler-32 into component sums */
- sum2 = (adler >> 16) & 0xffff;
- adler &= 0xffff;
-
- /* in case user likes doing a byte at a time, keep it fast */
- if (len == 1) {
- adler += buf[0];
- if (adler >= BASE)
- adler -= BASE;
- sum2 += adler;
- if (sum2 >= BASE)
- sum2 -= BASE;
- return adler | (sum2 << 16);
- }
-
- /* initial Adler-32 value (deferred check for len == 1 speed) */
- if (buf == Z_NULL)
- return 1L;
-
- /* in case short lengths are provided, keep it somewhat fast */
- if (len < 16) {
- while (len--) {
- adler += *buf++;
- sum2 += adler;
- }
- if (adler >= BASE)
- adler -= BASE;
- MOD4(sum2); /* only added so many BASE's */
- return adler | (sum2 << 16);
- }
-
- /* do length NMAX blocks -- requires just one modulo operation */
- while (len >= NMAX) {
- len -= NMAX;
- n = NMAX / 16; /* NMAX is divisible by 16 */
- do {
- DO16(buf); /* 16 sums unrolled */
- buf += 16;
- } while (--n);
- MOD(adler);
- MOD(sum2);
- }
-
- /* do remaining bytes (less than NMAX, still just one modulo) */
- if (len) { /* avoid modulos if none remaining */
- while (len >= 16) {
- len -= 16;
- DO16(buf);
- buf += 16;
- }
- while (len--) {
- adler += *buf++;
- sum2 += adler;
- }
- MOD(adler);
- MOD(sum2);
- }
-
- /* return recombined sums */
- return adler | (sum2 << 16);
-}
-
-/* ========================================================================= */
-uLong ZEXPORT adler32_combine(adler1, adler2, len2)
- uLong adler1;
- uLong adler2;
- z_off_t len2;
-{
- unsigned long sum1;
- unsigned long sum2;
- unsigned rem;
-
- /* the derivation of this formula is left as an exercise for the reader */
- rem = (unsigned)(len2 % BASE);
- sum1 = adler1 & 0xffff;
- sum2 = rem * sum1;
- MOD(sum2);
- sum1 += (adler2 & 0xffff) + BASE - 1;
- sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum1 > BASE) sum1 -= BASE;
- if (sum2 > (BASE << 1)) sum2 -= (BASE << 1);
- if (sum2 > BASE) sum2 -= BASE;
- return sum1 | (sum2 << 16);
-}
diff --git a/navit/support/zlib/crc32.c b/navit/support/zlib/crc32.c
deleted file mode 100644
index f658a9ef5..000000000
--- a/navit/support/zlib/crc32.c
+++ /dev/null
@@ -1,423 +0,0 @@
-/* crc32.c -- compute the CRC-32 of a data stream
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- *
- * Thanks to Rodney Brown <rbrown64@csc.com.au> for his contribution of faster
- * CRC methods: exclusive-oring 32 bits of data at a time, and pre-computing
- * tables for updating the shift register in one step with three exclusive-ors
- * instead of four steps with four exclusive-ors. This results in about a
- * factor of two increase in speed on a Power PC G4 (PPC7455) using gcc -O3.
- */
-
-/* @(#) $Id$ */
-
-/*
- Note on the use of DYNAMIC_CRC_TABLE: there is no mutex or semaphore
- protection on the static variables used to control the first-use generation
- of the crc tables. Therefore, if you #define DYNAMIC_CRC_TABLE, you should
- first call get_crc_table() to initialize the tables before allowing more than
- one thread to use crc32().
- */
-
-#ifdef MAKECRCH
-# include <stdio.h>
-# ifndef DYNAMIC_CRC_TABLE
-# define DYNAMIC_CRC_TABLE
-# endif /* !DYNAMIC_CRC_TABLE */
-#endif /* MAKECRCH */
-
-#include "zutil.h" /* for STDC and FAR definitions */
-
-#define local static
-
-/* Find a four-byte integer type for crc32_little() and crc32_big(). */
-#ifndef NOBYFOUR
-# ifdef STDC /* need ANSI C limits.h to determine sizes */
-# include <limits.h>
-# define BYFOUR
-# if (UINT_MAX == 0xffffffffUL)
- typedef unsigned int u4;
-# else
-# if (ULONG_MAX == 0xffffffffUL)
- typedef unsigned long u4;
-# else
-# if (USHRT_MAX == 0xffffffffUL)
- typedef unsigned short u4;
-# else
-# undef BYFOUR /* can't find a four-byte integer type! */
-# endif
-# endif
-# endif
-# endif /* STDC */
-#endif /* !NOBYFOUR */
-
-/* Definitions for doing the crc four data bytes at a time. */
-#ifdef BYFOUR
-# define REV(w) (((w)>>24)+(((w)>>8)&0xff00)+ \
- (((w)&0xff00)<<8)+(((w)&0xff)<<24))
- local unsigned long crc32_little OF((unsigned long,
- const unsigned char FAR *, unsigned));
- local unsigned long crc32_big OF((unsigned long,
- const unsigned char FAR *, unsigned));
-# define TBLS 8
-#else
-# define TBLS 1
-#endif /* BYFOUR */
-
-/* Local functions for crc concatenation */
-local unsigned long gf2_matrix_times OF((unsigned long *mat,
- unsigned long vec));
-local void gf2_matrix_square OF((unsigned long *square, unsigned long *mat));
-
-#ifdef DYNAMIC_CRC_TABLE
-
-local volatile int crc_table_empty = 1;
-local unsigned long FAR crc_table[TBLS][256];
-local void make_crc_table OF((void));
-#ifdef MAKECRCH
- local void write_table OF((FILE *, const unsigned long FAR *));
-#endif /* MAKECRCH */
-/*
- Generate tables for a byte-wise 32-bit CRC calculation on the polynomial:
- x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
-
- Polynomials over GF(2) are represented in binary, one bit per coefficient,
- with the lowest powers in the most significant bit. Then adding polynomials
- is just exclusive-or, and multiplying a polynomial by x is a right shift by
- one. If we call the above polynomial p, and represent a byte as the
- polynomial q, also with the lowest power in the most significant bit (so the
- byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
- where a mod b means the remainder after dividing a by b.
-
- This calculation is done using the shift-register method of multiplying and
- taking the remainder. The register is initialized to zero, and for each
- incoming bit, x^32 is added mod p to the register if the bit is a one (where
- x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
- x (which is shifting right by one and adding x^32 mod p if the bit shifted
- out is a one). We start with the highest power (least significant bit) of
- q and repeat for all eight bits of q.
-
- The first table is simply the CRC of all possible eight bit values. This is
- all the information needed to generate CRCs on data a byte at a time for all
- combinations of CRC register values and incoming bytes. The remaining tables
- allow for word-at-a-time CRC calculation for both big-endian and little-
- endian machines, where a word is four bytes.
-*/
-local void make_crc_table()
-{
- unsigned long c;
- int n, k;
- unsigned long poly; /* polynomial exclusive-or pattern */
- /* terms of polynomial defining this crc (except x^32): */
- static volatile int first = 1; /* flag to limit concurrent making */
- static const unsigned char p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
-
- /* See if another task is already doing this (not thread-safe, but better
- than nothing -- significantly reduces duration of vulnerability in
- case the advice about DYNAMIC_CRC_TABLE is ignored) */
- if (first) {
- first = 0;
-
- /* make exclusive-or pattern from polynomial (0xedb88320UL) */
- poly = 0UL;
- for (n = 0; n < sizeof(p)/sizeof(unsigned char); n++)
- poly |= 1UL << (31 - p[n]);
-
- /* generate a crc for every 8-bit value */
- for (n = 0; n < 256; n++) {
- c = (unsigned long)n;
- for (k = 0; k < 8; k++)
- c = c & 1 ? poly ^ (c >> 1) : c >> 1;
- crc_table[0][n] = c;
- }
-
-#ifdef BYFOUR
- /* generate crc for each value followed by one, two, and three zeros,
- and then the byte reversal of those as well as the first table */
- for (n = 0; n < 256; n++) {
- c = crc_table[0][n];
- crc_table[4][n] = REV(c);
- for (k = 1; k < 4; k++) {
- c = crc_table[0][c & 0xff] ^ (c >> 8);
- crc_table[k][n] = c;
- crc_table[k + 4][n] = REV(c);
- }
- }
-#endif /* BYFOUR */
-
- crc_table_empty = 0;
- }
- else { /* not first */
- /* wait for the other guy to finish (not efficient, but rare) */
- while (crc_table_empty)
- ;
- }
-
-#ifdef MAKECRCH
- /* write out CRC tables to crc32.h */
- {
- FILE *out;
-
- out = fopen("crc32.h", "w");
- if (out == NULL) return;
- fprintf(out, "/* crc32.h -- tables for rapid CRC calculation\n");
- fprintf(out, " * Generated automatically by crc32.c\n */\n\n");
- fprintf(out, "local const unsigned long FAR ");
- fprintf(out, "crc_table[TBLS][256] =\n{\n {\n");
- write_table(out, crc_table[0]);
-# ifdef BYFOUR
- fprintf(out, "#ifdef BYFOUR\n");
- for (k = 1; k < 8; k++) {
- fprintf(out, " },\n {\n");
- write_table(out, crc_table[k]);
- }
- fprintf(out, "#endif\n");
-# endif /* BYFOUR */
- fprintf(out, " }\n};\n");
- fclose(out);
- }
-#endif /* MAKECRCH */
-}
-
-#ifdef MAKECRCH
-local void write_table(out, table)
- FILE *out;
- const unsigned long FAR *table;
-{
- int n;
-
- for (n = 0; n < 256; n++)
- fprintf(out, "%s0x%08lxUL%s", n % 5 ? "" : " ", table[n],
- n == 255 ? "\n" : (n % 5 == 4 ? ",\n" : ", "));
-}
-#endif /* MAKECRCH */
-
-#else /* !DYNAMIC_CRC_TABLE */
-/* ========================================================================
- * Tables of CRC-32s of all single-byte values, made by make_crc_table().
- */
-#include "crc32.h"
-#endif /* DYNAMIC_CRC_TABLE */
-
-/* =========================================================================
- * This function can be used by asm versions of crc32()
- */
-const unsigned long FAR * ZEXPORT get_crc_table()
-{
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
- return (const unsigned long FAR *)crc_table;
-}
-
-/* ========================================================================= */
-#define DO1 crc = crc_table[0][((int)crc ^ (*buf++)) & 0xff] ^ (crc >> 8)
-#define DO8 DO1; DO1; DO1; DO1; DO1; DO1; DO1; DO1
-
-/* ========================================================================= */
-unsigned long ZEXPORT crc32(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- if (buf == Z_NULL) return 0UL;
-
-#ifdef DYNAMIC_CRC_TABLE
- if (crc_table_empty)
- make_crc_table();
-#endif /* DYNAMIC_CRC_TABLE */
-
-#ifdef BYFOUR
- if (sizeof(void *) == sizeof(ptrdiff_t)) {
- u4 endian;
-
- endian = 1;
- if (*((unsigned char *)(&endian)))
- return crc32_little(crc, buf, len);
- else
- return crc32_big(crc, buf, len);
- }
-#endif /* BYFOUR */
- crc = crc ^ 0xffffffffUL;
- while (len >= 8) {
- DO8;
- len -= 8;
- }
- if (len) do {
- DO1;
- } while (--len);
- return crc ^ 0xffffffffUL;
-}
-
-#ifdef BYFOUR
-
-/* ========================================================================= */
-#define DOLIT4 c ^= *buf4++; \
- c = crc_table[3][c & 0xff] ^ crc_table[2][(c >> 8) & 0xff] ^ \
- crc_table[1][(c >> 16) & 0xff] ^ crc_table[0][c >> 24]
-#define DOLIT32 DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4; DOLIT4
-
-/* ========================================================================= */
-local unsigned long crc32_little(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register u4 c;
- register const u4 FAR *buf4;
-
- c = (u4)crc;
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- len--;
- }
-
- buf4 = (const u4 FAR *)(const void FAR *)buf;
- while (len >= 32) {
- DOLIT32;
- len -= 32;
- }
- while (len >= 4) {
- DOLIT4;
- len -= 4;
- }
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[0][(c ^ *buf++) & 0xff] ^ (c >> 8);
- } while (--len);
- c = ~c;
- return (unsigned long)c;
-}
-
-/* ========================================================================= */
-#define DOBIG4 c ^= *++buf4; \
- c = crc_table[4][c & 0xff] ^ crc_table[5][(c >> 8) & 0xff] ^ \
- crc_table[6][(c >> 16) & 0xff] ^ crc_table[7][c >> 24]
-#define DOBIG32 DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4; DOBIG4
-
-/* ========================================================================= */
-local unsigned long crc32_big(crc, buf, len)
- unsigned long crc;
- const unsigned char FAR *buf;
- unsigned len;
-{
- register u4 c;
- register const u4 FAR *buf4;
-
- c = REV((u4)crc);
- c = ~c;
- while (len && ((ptrdiff_t)buf & 3)) {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- len--;
- }
-
- buf4 = (const u4 FAR *)(const void FAR *)buf;
- buf4--;
- while (len >= 32) {
- DOBIG32;
- len -= 32;
- }
- while (len >= 4) {
- DOBIG4;
- len -= 4;
- }
- buf4++;
- buf = (const unsigned char FAR *)buf4;
-
- if (len) do {
- c = crc_table[4][(c >> 24) ^ *buf++] ^ (c << 8);
- } while (--len);
- c = ~c;
- return (unsigned long)(REV(c));
-}
-
-#endif /* BYFOUR */
-
-#define GF2_DIM 32 /* dimension of GF(2) vectors (length of CRC) */
-
-/* ========================================================================= */
-local unsigned long gf2_matrix_times(mat, vec)
- unsigned long *mat;
- unsigned long vec;
-{
- unsigned long sum;
-
- sum = 0;
- while (vec) {
- if (vec & 1)
- sum ^= *mat;
- vec >>= 1;
- mat++;
- }
- return sum;
-}
-
-/* ========================================================================= */
-local void gf2_matrix_square(square, mat)
- unsigned long *square;
- unsigned long *mat;
-{
- int n;
-
- for (n = 0; n < GF2_DIM; n++)
- square[n] = gf2_matrix_times(mat, mat[n]);
-}
-
-/* ========================================================================= */
-uLong ZEXPORT crc32_combine(crc1, crc2, len2)
- uLong crc1;
- uLong crc2;
- z_off_t len2;
-{
- int n;
- unsigned long row;
- unsigned long even[GF2_DIM]; /* even-power-of-two zeros operator */
- unsigned long odd[GF2_DIM]; /* odd-power-of-two zeros operator */
-
- /* degenerate case */
- if (len2 == 0)
- return crc1;
-
- /* put operator for one zero bit in odd */
- odd[0] = 0xedb88320L; /* CRC-32 polynomial */
- row = 1;
- for (n = 1; n < GF2_DIM; n++) {
- odd[n] = row;
- row <<= 1;
- }
-
- /* put operator for two zero bits in even */
- gf2_matrix_square(even, odd);
-
- /* put operator for four zero bits in odd */
- gf2_matrix_square(odd, even);
-
- /* apply len2 zeros to crc1 (first square will put the operator for one
- zero byte, eight zero bits, in even) */
- do {
- /* apply zeros operator for this bit of len2 */
- gf2_matrix_square(even, odd);
- if (len2 & 1)
- crc1 = gf2_matrix_times(even, crc1);
- len2 >>= 1;
-
- /* if no more bits set, then done */
- if (len2 == 0)
- break;
-
- /* another iteration of the loop with odd and even swapped */
- gf2_matrix_square(odd, even);
- if (len2 & 1)
- crc1 = gf2_matrix_times(odd, crc1);
- len2 >>= 1;
-
- /* if no more bits set, then done */
- } while (len2 != 0);
-
- /* return combined crc */
- crc1 ^= crc2;
- return crc1;
-}
diff --git a/navit/support/zlib/crc32.h b/navit/support/zlib/crc32.h
deleted file mode 100644
index 8053b6117..000000000
--- a/navit/support/zlib/crc32.h
+++ /dev/null
@@ -1,441 +0,0 @@
-/* crc32.h -- tables for rapid CRC calculation
- * Generated automatically by crc32.c
- */
-
-local const unsigned long FAR crc_table[TBLS][256] =
-{
- {
- 0x00000000UL, 0x77073096UL, 0xee0e612cUL, 0x990951baUL, 0x076dc419UL,
- 0x706af48fUL, 0xe963a535UL, 0x9e6495a3UL, 0x0edb8832UL, 0x79dcb8a4UL,
- 0xe0d5e91eUL, 0x97d2d988UL, 0x09b64c2bUL, 0x7eb17cbdUL, 0xe7b82d07UL,
- 0x90bf1d91UL, 0x1db71064UL, 0x6ab020f2UL, 0xf3b97148UL, 0x84be41deUL,
- 0x1adad47dUL, 0x6ddde4ebUL, 0xf4d4b551UL, 0x83d385c7UL, 0x136c9856UL,
- 0x646ba8c0UL, 0xfd62f97aUL, 0x8a65c9ecUL, 0x14015c4fUL, 0x63066cd9UL,
- 0xfa0f3d63UL, 0x8d080df5UL, 0x3b6e20c8UL, 0x4c69105eUL, 0xd56041e4UL,
- 0xa2677172UL, 0x3c03e4d1UL, 0x4b04d447UL, 0xd20d85fdUL, 0xa50ab56bUL,
- 0x35b5a8faUL, 0x42b2986cUL, 0xdbbbc9d6UL, 0xacbcf940UL, 0x32d86ce3UL,
- 0x45df5c75UL, 0xdcd60dcfUL, 0xabd13d59UL, 0x26d930acUL, 0x51de003aUL,
- 0xc8d75180UL, 0xbfd06116UL, 0x21b4f4b5UL, 0x56b3c423UL, 0xcfba9599UL,
- 0xb8bda50fUL, 0x2802b89eUL, 0x5f058808UL, 0xc60cd9b2UL, 0xb10be924UL,
- 0x2f6f7c87UL, 0x58684c11UL, 0xc1611dabUL, 0xb6662d3dUL, 0x76dc4190UL,
- 0x01db7106UL, 0x98d220bcUL, 0xefd5102aUL, 0x71b18589UL, 0x06b6b51fUL,
- 0x9fbfe4a5UL, 0xe8b8d433UL, 0x7807c9a2UL, 0x0f00f934UL, 0x9609a88eUL,
- 0xe10e9818UL, 0x7f6a0dbbUL, 0x086d3d2dUL, 0x91646c97UL, 0xe6635c01UL,
- 0x6b6b51f4UL, 0x1c6c6162UL, 0x856530d8UL, 0xf262004eUL, 0x6c0695edUL,
- 0x1b01a57bUL, 0x8208f4c1UL, 0xf50fc457UL, 0x65b0d9c6UL, 0x12b7e950UL,
- 0x8bbeb8eaUL, 0xfcb9887cUL, 0x62dd1ddfUL, 0x15da2d49UL, 0x8cd37cf3UL,
- 0xfbd44c65UL, 0x4db26158UL, 0x3ab551ceUL, 0xa3bc0074UL, 0xd4bb30e2UL,
- 0x4adfa541UL, 0x3dd895d7UL, 0xa4d1c46dUL, 0xd3d6f4fbUL, 0x4369e96aUL,
- 0x346ed9fcUL, 0xad678846UL, 0xda60b8d0UL, 0x44042d73UL, 0x33031de5UL,
- 0xaa0a4c5fUL, 0xdd0d7cc9UL, 0x5005713cUL, 0x270241aaUL, 0xbe0b1010UL,
- 0xc90c2086UL, 0x5768b525UL, 0x206f85b3UL, 0xb966d409UL, 0xce61e49fUL,
- 0x5edef90eUL, 0x29d9c998UL, 0xb0d09822UL, 0xc7d7a8b4UL, 0x59b33d17UL,
- 0x2eb40d81UL, 0xb7bd5c3bUL, 0xc0ba6cadUL, 0xedb88320UL, 0x9abfb3b6UL,
- 0x03b6e20cUL, 0x74b1d29aUL, 0xead54739UL, 0x9dd277afUL, 0x04db2615UL,
- 0x73dc1683UL, 0xe3630b12UL, 0x94643b84UL, 0x0d6d6a3eUL, 0x7a6a5aa8UL,
- 0xe40ecf0bUL, 0x9309ff9dUL, 0x0a00ae27UL, 0x7d079eb1UL, 0xf00f9344UL,
- 0x8708a3d2UL, 0x1e01f268UL, 0x6906c2feUL, 0xf762575dUL, 0x806567cbUL,
- 0x196c3671UL, 0x6e6b06e7UL, 0xfed41b76UL, 0x89d32be0UL, 0x10da7a5aUL,
- 0x67dd4accUL, 0xf9b9df6fUL, 0x8ebeeff9UL, 0x17b7be43UL, 0x60b08ed5UL,
- 0xd6d6a3e8UL, 0xa1d1937eUL, 0x38d8c2c4UL, 0x4fdff252UL, 0xd1bb67f1UL,
- 0xa6bc5767UL, 0x3fb506ddUL, 0x48b2364bUL, 0xd80d2bdaUL, 0xaf0a1b4cUL,
- 0x36034af6UL, 0x41047a60UL, 0xdf60efc3UL, 0xa867df55UL, 0x316e8eefUL,
- 0x4669be79UL, 0xcb61b38cUL, 0xbc66831aUL, 0x256fd2a0UL, 0x5268e236UL,
- 0xcc0c7795UL, 0xbb0b4703UL, 0x220216b9UL, 0x5505262fUL, 0xc5ba3bbeUL,
- 0xb2bd0b28UL, 0x2bb45a92UL, 0x5cb36a04UL, 0xc2d7ffa7UL, 0xb5d0cf31UL,
- 0x2cd99e8bUL, 0x5bdeae1dUL, 0x9b64c2b0UL, 0xec63f226UL, 0x756aa39cUL,
- 0x026d930aUL, 0x9c0906a9UL, 0xeb0e363fUL, 0x72076785UL, 0x05005713UL,
- 0x95bf4a82UL, 0xe2b87a14UL, 0x7bb12baeUL, 0x0cb61b38UL, 0x92d28e9bUL,
- 0xe5d5be0dUL, 0x7cdcefb7UL, 0x0bdbdf21UL, 0x86d3d2d4UL, 0xf1d4e242UL,
- 0x68ddb3f8UL, 0x1fda836eUL, 0x81be16cdUL, 0xf6b9265bUL, 0x6fb077e1UL,
- 0x18b74777UL, 0x88085ae6UL, 0xff0f6a70UL, 0x66063bcaUL, 0x11010b5cUL,
- 0x8f659effUL, 0xf862ae69UL, 0x616bffd3UL, 0x166ccf45UL, 0xa00ae278UL,
- 0xd70dd2eeUL, 0x4e048354UL, 0x3903b3c2UL, 0xa7672661UL, 0xd06016f7UL,
- 0x4969474dUL, 0x3e6e77dbUL, 0xaed16a4aUL, 0xd9d65adcUL, 0x40df0b66UL,
- 0x37d83bf0UL, 0xa9bcae53UL, 0xdebb9ec5UL, 0x47b2cf7fUL, 0x30b5ffe9UL,
- 0xbdbdf21cUL, 0xcabac28aUL, 0x53b39330UL, 0x24b4a3a6UL, 0xbad03605UL,
- 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
- 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
- 0x2d02ef8dUL
-#ifdef BYFOUR
- },
- {
- 0x00000000UL, 0x191b3141UL, 0x32366282UL, 0x2b2d53c3UL, 0x646cc504UL,
- 0x7d77f445UL, 0x565aa786UL, 0x4f4196c7UL, 0xc8d98a08UL, 0xd1c2bb49UL,
- 0xfaefe88aUL, 0xe3f4d9cbUL, 0xacb54f0cUL, 0xb5ae7e4dUL, 0x9e832d8eUL,
- 0x87981ccfUL, 0x4ac21251UL, 0x53d92310UL, 0x78f470d3UL, 0x61ef4192UL,
- 0x2eaed755UL, 0x37b5e614UL, 0x1c98b5d7UL, 0x05838496UL, 0x821b9859UL,
- 0x9b00a918UL, 0xb02dfadbUL, 0xa936cb9aUL, 0xe6775d5dUL, 0xff6c6c1cUL,
- 0xd4413fdfUL, 0xcd5a0e9eUL, 0x958424a2UL, 0x8c9f15e3UL, 0xa7b24620UL,
- 0xbea97761UL, 0xf1e8e1a6UL, 0xe8f3d0e7UL, 0xc3de8324UL, 0xdac5b265UL,
- 0x5d5daeaaUL, 0x44469febUL, 0x6f6bcc28UL, 0x7670fd69UL, 0x39316baeUL,
- 0x202a5aefUL, 0x0b07092cUL, 0x121c386dUL, 0xdf4636f3UL, 0xc65d07b2UL,
- 0xed705471UL, 0xf46b6530UL, 0xbb2af3f7UL, 0xa231c2b6UL, 0x891c9175UL,
- 0x9007a034UL, 0x179fbcfbUL, 0x0e848dbaUL, 0x25a9de79UL, 0x3cb2ef38UL,
- 0x73f379ffUL, 0x6ae848beUL, 0x41c51b7dUL, 0x58de2a3cUL, 0xf0794f05UL,
- 0xe9627e44UL, 0xc24f2d87UL, 0xdb541cc6UL, 0x94158a01UL, 0x8d0ebb40UL,
- 0xa623e883UL, 0xbf38d9c2UL, 0x38a0c50dUL, 0x21bbf44cUL, 0x0a96a78fUL,
- 0x138d96ceUL, 0x5ccc0009UL, 0x45d73148UL, 0x6efa628bUL, 0x77e153caUL,
- 0xbabb5d54UL, 0xa3a06c15UL, 0x888d3fd6UL, 0x91960e97UL, 0xded79850UL,
- 0xc7cca911UL, 0xece1fad2UL, 0xf5facb93UL, 0x7262d75cUL, 0x6b79e61dUL,
- 0x4054b5deUL, 0x594f849fUL, 0x160e1258UL, 0x0f152319UL, 0x243870daUL,
- 0x3d23419bUL, 0x65fd6ba7UL, 0x7ce65ae6UL, 0x57cb0925UL, 0x4ed03864UL,
- 0x0191aea3UL, 0x188a9fe2UL, 0x33a7cc21UL, 0x2abcfd60UL, 0xad24e1afUL,
- 0xb43fd0eeUL, 0x9f12832dUL, 0x8609b26cUL, 0xc94824abUL, 0xd05315eaUL,
- 0xfb7e4629UL, 0xe2657768UL, 0x2f3f79f6UL, 0x362448b7UL, 0x1d091b74UL,
- 0x04122a35UL, 0x4b53bcf2UL, 0x52488db3UL, 0x7965de70UL, 0x607eef31UL,
- 0xe7e6f3feUL, 0xfefdc2bfUL, 0xd5d0917cUL, 0xcccba03dUL, 0x838a36faUL,
- 0x9a9107bbUL, 0xb1bc5478UL, 0xa8a76539UL, 0x3b83984bUL, 0x2298a90aUL,
- 0x09b5fac9UL, 0x10aecb88UL, 0x5fef5d4fUL, 0x46f46c0eUL, 0x6dd93fcdUL,
- 0x74c20e8cUL, 0xf35a1243UL, 0xea412302UL, 0xc16c70c1UL, 0xd8774180UL,
- 0x9736d747UL, 0x8e2de606UL, 0xa500b5c5UL, 0xbc1b8484UL, 0x71418a1aUL,
- 0x685abb5bUL, 0x4377e898UL, 0x5a6cd9d9UL, 0x152d4f1eUL, 0x0c367e5fUL,
- 0x271b2d9cUL, 0x3e001cddUL, 0xb9980012UL, 0xa0833153UL, 0x8bae6290UL,
- 0x92b553d1UL, 0xddf4c516UL, 0xc4eff457UL, 0xefc2a794UL, 0xf6d996d5UL,
- 0xae07bce9UL, 0xb71c8da8UL, 0x9c31de6bUL, 0x852aef2aUL, 0xca6b79edUL,
- 0xd37048acUL, 0xf85d1b6fUL, 0xe1462a2eUL, 0x66de36e1UL, 0x7fc507a0UL,
- 0x54e85463UL, 0x4df36522UL, 0x02b2f3e5UL, 0x1ba9c2a4UL, 0x30849167UL,
- 0x299fa026UL, 0xe4c5aeb8UL, 0xfdde9ff9UL, 0xd6f3cc3aUL, 0xcfe8fd7bUL,
- 0x80a96bbcUL, 0x99b25afdUL, 0xb29f093eUL, 0xab84387fUL, 0x2c1c24b0UL,
- 0x350715f1UL, 0x1e2a4632UL, 0x07317773UL, 0x4870e1b4UL, 0x516bd0f5UL,
- 0x7a468336UL, 0x635db277UL, 0xcbfad74eUL, 0xd2e1e60fUL, 0xf9ccb5ccUL,
- 0xe0d7848dUL, 0xaf96124aUL, 0xb68d230bUL, 0x9da070c8UL, 0x84bb4189UL,
- 0x03235d46UL, 0x1a386c07UL, 0x31153fc4UL, 0x280e0e85UL, 0x674f9842UL,
- 0x7e54a903UL, 0x5579fac0UL, 0x4c62cb81UL, 0x8138c51fUL, 0x9823f45eUL,
- 0xb30ea79dUL, 0xaa1596dcUL, 0xe554001bUL, 0xfc4f315aUL, 0xd7626299UL,
- 0xce7953d8UL, 0x49e14f17UL, 0x50fa7e56UL, 0x7bd72d95UL, 0x62cc1cd4UL,
- 0x2d8d8a13UL, 0x3496bb52UL, 0x1fbbe891UL, 0x06a0d9d0UL, 0x5e7ef3ecUL,
- 0x4765c2adUL, 0x6c48916eUL, 0x7553a02fUL, 0x3a1236e8UL, 0x230907a9UL,
- 0x0824546aUL, 0x113f652bUL, 0x96a779e4UL, 0x8fbc48a5UL, 0xa4911b66UL,
- 0xbd8a2a27UL, 0xf2cbbce0UL, 0xebd08da1UL, 0xc0fdde62UL, 0xd9e6ef23UL,
- 0x14bce1bdUL, 0x0da7d0fcUL, 0x268a833fUL, 0x3f91b27eUL, 0x70d024b9UL,
- 0x69cb15f8UL, 0x42e6463bUL, 0x5bfd777aUL, 0xdc656bb5UL, 0xc57e5af4UL,
- 0xee530937UL, 0xf7483876UL, 0xb809aeb1UL, 0xa1129ff0UL, 0x8a3fcc33UL,
- 0x9324fd72UL
- },
- {
- 0x00000000UL, 0x01c26a37UL, 0x0384d46eUL, 0x0246be59UL, 0x0709a8dcUL,
- 0x06cbc2ebUL, 0x048d7cb2UL, 0x054f1685UL, 0x0e1351b8UL, 0x0fd13b8fUL,
- 0x0d9785d6UL, 0x0c55efe1UL, 0x091af964UL, 0x08d89353UL, 0x0a9e2d0aUL,
- 0x0b5c473dUL, 0x1c26a370UL, 0x1de4c947UL, 0x1fa2771eUL, 0x1e601d29UL,
- 0x1b2f0bacUL, 0x1aed619bUL, 0x18abdfc2UL, 0x1969b5f5UL, 0x1235f2c8UL,
- 0x13f798ffUL, 0x11b126a6UL, 0x10734c91UL, 0x153c5a14UL, 0x14fe3023UL,
- 0x16b88e7aUL, 0x177ae44dUL, 0x384d46e0UL, 0x398f2cd7UL, 0x3bc9928eUL,
- 0x3a0bf8b9UL, 0x3f44ee3cUL, 0x3e86840bUL, 0x3cc03a52UL, 0x3d025065UL,
- 0x365e1758UL, 0x379c7d6fUL, 0x35dac336UL, 0x3418a901UL, 0x3157bf84UL,
- 0x3095d5b3UL, 0x32d36beaUL, 0x331101ddUL, 0x246be590UL, 0x25a98fa7UL,
- 0x27ef31feUL, 0x262d5bc9UL, 0x23624d4cUL, 0x22a0277bUL, 0x20e69922UL,
- 0x2124f315UL, 0x2a78b428UL, 0x2bbade1fUL, 0x29fc6046UL, 0x283e0a71UL,
- 0x2d711cf4UL, 0x2cb376c3UL, 0x2ef5c89aUL, 0x2f37a2adUL, 0x709a8dc0UL,
- 0x7158e7f7UL, 0x731e59aeUL, 0x72dc3399UL, 0x7793251cUL, 0x76514f2bUL,
- 0x7417f172UL, 0x75d59b45UL, 0x7e89dc78UL, 0x7f4bb64fUL, 0x7d0d0816UL,
- 0x7ccf6221UL, 0x798074a4UL, 0x78421e93UL, 0x7a04a0caUL, 0x7bc6cafdUL,
- 0x6cbc2eb0UL, 0x6d7e4487UL, 0x6f38fadeUL, 0x6efa90e9UL, 0x6bb5866cUL,
- 0x6a77ec5bUL, 0x68315202UL, 0x69f33835UL, 0x62af7f08UL, 0x636d153fUL,
- 0x612bab66UL, 0x60e9c151UL, 0x65a6d7d4UL, 0x6464bde3UL, 0x662203baUL,
- 0x67e0698dUL, 0x48d7cb20UL, 0x4915a117UL, 0x4b531f4eUL, 0x4a917579UL,
- 0x4fde63fcUL, 0x4e1c09cbUL, 0x4c5ab792UL, 0x4d98dda5UL, 0x46c49a98UL,
- 0x4706f0afUL, 0x45404ef6UL, 0x448224c1UL, 0x41cd3244UL, 0x400f5873UL,
- 0x4249e62aUL, 0x438b8c1dUL, 0x54f16850UL, 0x55330267UL, 0x5775bc3eUL,
- 0x56b7d609UL, 0x53f8c08cUL, 0x523aaabbUL, 0x507c14e2UL, 0x51be7ed5UL,
- 0x5ae239e8UL, 0x5b2053dfUL, 0x5966ed86UL, 0x58a487b1UL, 0x5deb9134UL,
- 0x5c29fb03UL, 0x5e6f455aUL, 0x5fad2f6dUL, 0xe1351b80UL, 0xe0f771b7UL,
- 0xe2b1cfeeUL, 0xe373a5d9UL, 0xe63cb35cUL, 0xe7fed96bUL, 0xe5b86732UL,
- 0xe47a0d05UL, 0xef264a38UL, 0xeee4200fUL, 0xeca29e56UL, 0xed60f461UL,
- 0xe82fe2e4UL, 0xe9ed88d3UL, 0xebab368aUL, 0xea695cbdUL, 0xfd13b8f0UL,
- 0xfcd1d2c7UL, 0xfe976c9eUL, 0xff5506a9UL, 0xfa1a102cUL, 0xfbd87a1bUL,
- 0xf99ec442UL, 0xf85cae75UL, 0xf300e948UL, 0xf2c2837fUL, 0xf0843d26UL,
- 0xf1465711UL, 0xf4094194UL, 0xf5cb2ba3UL, 0xf78d95faUL, 0xf64fffcdUL,
- 0xd9785d60UL, 0xd8ba3757UL, 0xdafc890eUL, 0xdb3ee339UL, 0xde71f5bcUL,
- 0xdfb39f8bUL, 0xddf521d2UL, 0xdc374be5UL, 0xd76b0cd8UL, 0xd6a966efUL,
- 0xd4efd8b6UL, 0xd52db281UL, 0xd062a404UL, 0xd1a0ce33UL, 0xd3e6706aUL,
- 0xd2241a5dUL, 0xc55efe10UL, 0xc49c9427UL, 0xc6da2a7eUL, 0xc7184049UL,
- 0xc25756ccUL, 0xc3953cfbUL, 0xc1d382a2UL, 0xc011e895UL, 0xcb4dafa8UL,
- 0xca8fc59fUL, 0xc8c97bc6UL, 0xc90b11f1UL, 0xcc440774UL, 0xcd866d43UL,
- 0xcfc0d31aUL, 0xce02b92dUL, 0x91af9640UL, 0x906dfc77UL, 0x922b422eUL,
- 0x93e92819UL, 0x96a63e9cUL, 0x976454abUL, 0x9522eaf2UL, 0x94e080c5UL,
- 0x9fbcc7f8UL, 0x9e7eadcfUL, 0x9c381396UL, 0x9dfa79a1UL, 0x98b56f24UL,
- 0x99770513UL, 0x9b31bb4aUL, 0x9af3d17dUL, 0x8d893530UL, 0x8c4b5f07UL,
- 0x8e0de15eUL, 0x8fcf8b69UL, 0x8a809decUL, 0x8b42f7dbUL, 0x89044982UL,
- 0x88c623b5UL, 0x839a6488UL, 0x82580ebfUL, 0x801eb0e6UL, 0x81dcdad1UL,
- 0x8493cc54UL, 0x8551a663UL, 0x8717183aUL, 0x86d5720dUL, 0xa9e2d0a0UL,
- 0xa820ba97UL, 0xaa6604ceUL, 0xaba46ef9UL, 0xaeeb787cUL, 0xaf29124bUL,
- 0xad6fac12UL, 0xacadc625UL, 0xa7f18118UL, 0xa633eb2fUL, 0xa4755576UL,
- 0xa5b73f41UL, 0xa0f829c4UL, 0xa13a43f3UL, 0xa37cfdaaUL, 0xa2be979dUL,
- 0xb5c473d0UL, 0xb40619e7UL, 0xb640a7beUL, 0xb782cd89UL, 0xb2cddb0cUL,
- 0xb30fb13bUL, 0xb1490f62UL, 0xb08b6555UL, 0xbbd72268UL, 0xba15485fUL,
- 0xb853f606UL, 0xb9919c31UL, 0xbcde8ab4UL, 0xbd1ce083UL, 0xbf5a5edaUL,
- 0xbe9834edUL
- },
- {
- 0x00000000UL, 0xb8bc6765UL, 0xaa09c88bUL, 0x12b5afeeUL, 0x8f629757UL,
- 0x37def032UL, 0x256b5fdcUL, 0x9dd738b9UL, 0xc5b428efUL, 0x7d084f8aUL,
- 0x6fbde064UL, 0xd7018701UL, 0x4ad6bfb8UL, 0xf26ad8ddUL, 0xe0df7733UL,
- 0x58631056UL, 0x5019579fUL, 0xe8a530faUL, 0xfa109f14UL, 0x42acf871UL,
- 0xdf7bc0c8UL, 0x67c7a7adUL, 0x75720843UL, 0xcdce6f26UL, 0x95ad7f70UL,
- 0x2d111815UL, 0x3fa4b7fbUL, 0x8718d09eUL, 0x1acfe827UL, 0xa2738f42UL,
- 0xb0c620acUL, 0x087a47c9UL, 0xa032af3eUL, 0x188ec85bUL, 0x0a3b67b5UL,
- 0xb28700d0UL, 0x2f503869UL, 0x97ec5f0cUL, 0x8559f0e2UL, 0x3de59787UL,
- 0x658687d1UL, 0xdd3ae0b4UL, 0xcf8f4f5aUL, 0x7733283fUL, 0xeae41086UL,
- 0x525877e3UL, 0x40edd80dUL, 0xf851bf68UL, 0xf02bf8a1UL, 0x48979fc4UL,
- 0x5a22302aUL, 0xe29e574fUL, 0x7f496ff6UL, 0xc7f50893UL, 0xd540a77dUL,
- 0x6dfcc018UL, 0x359fd04eUL, 0x8d23b72bUL, 0x9f9618c5UL, 0x272a7fa0UL,
- 0xbafd4719UL, 0x0241207cUL, 0x10f48f92UL, 0xa848e8f7UL, 0x9b14583dUL,
- 0x23a83f58UL, 0x311d90b6UL, 0x89a1f7d3UL, 0x1476cf6aUL, 0xaccaa80fUL,
- 0xbe7f07e1UL, 0x06c36084UL, 0x5ea070d2UL, 0xe61c17b7UL, 0xf4a9b859UL,
- 0x4c15df3cUL, 0xd1c2e785UL, 0x697e80e0UL, 0x7bcb2f0eUL, 0xc377486bUL,
- 0xcb0d0fa2UL, 0x73b168c7UL, 0x6104c729UL, 0xd9b8a04cUL, 0x446f98f5UL,
- 0xfcd3ff90UL, 0xee66507eUL, 0x56da371bUL, 0x0eb9274dUL, 0xb6054028UL,
- 0xa4b0efc6UL, 0x1c0c88a3UL, 0x81dbb01aUL, 0x3967d77fUL, 0x2bd27891UL,
- 0x936e1ff4UL, 0x3b26f703UL, 0x839a9066UL, 0x912f3f88UL, 0x299358edUL,
- 0xb4446054UL, 0x0cf80731UL, 0x1e4da8dfUL, 0xa6f1cfbaUL, 0xfe92dfecUL,
- 0x462eb889UL, 0x549b1767UL, 0xec277002UL, 0x71f048bbUL, 0xc94c2fdeUL,
- 0xdbf98030UL, 0x6345e755UL, 0x6b3fa09cUL, 0xd383c7f9UL, 0xc1366817UL,
- 0x798a0f72UL, 0xe45d37cbUL, 0x5ce150aeUL, 0x4e54ff40UL, 0xf6e89825UL,
- 0xae8b8873UL, 0x1637ef16UL, 0x048240f8UL, 0xbc3e279dUL, 0x21e91f24UL,
- 0x99557841UL, 0x8be0d7afUL, 0x335cb0caUL, 0xed59b63bUL, 0x55e5d15eUL,
- 0x47507eb0UL, 0xffec19d5UL, 0x623b216cUL, 0xda874609UL, 0xc832e9e7UL,
- 0x708e8e82UL, 0x28ed9ed4UL, 0x9051f9b1UL, 0x82e4565fUL, 0x3a58313aUL,
- 0xa78f0983UL, 0x1f336ee6UL, 0x0d86c108UL, 0xb53aa66dUL, 0xbd40e1a4UL,
- 0x05fc86c1UL, 0x1749292fUL, 0xaff54e4aUL, 0x322276f3UL, 0x8a9e1196UL,
- 0x982bbe78UL, 0x2097d91dUL, 0x78f4c94bUL, 0xc048ae2eUL, 0xd2fd01c0UL,
- 0x6a4166a5UL, 0xf7965e1cUL, 0x4f2a3979UL, 0x5d9f9697UL, 0xe523f1f2UL,
- 0x4d6b1905UL, 0xf5d77e60UL, 0xe762d18eUL, 0x5fdeb6ebUL, 0xc2098e52UL,
- 0x7ab5e937UL, 0x680046d9UL, 0xd0bc21bcUL, 0x88df31eaUL, 0x3063568fUL,
- 0x22d6f961UL, 0x9a6a9e04UL, 0x07bda6bdUL, 0xbf01c1d8UL, 0xadb46e36UL,
- 0x15080953UL, 0x1d724e9aUL, 0xa5ce29ffUL, 0xb77b8611UL, 0x0fc7e174UL,
- 0x9210d9cdUL, 0x2aacbea8UL, 0x38191146UL, 0x80a57623UL, 0xd8c66675UL,
- 0x607a0110UL, 0x72cfaefeUL, 0xca73c99bUL, 0x57a4f122UL, 0xef189647UL,
- 0xfdad39a9UL, 0x45115eccUL, 0x764dee06UL, 0xcef18963UL, 0xdc44268dUL,
- 0x64f841e8UL, 0xf92f7951UL, 0x41931e34UL, 0x5326b1daUL, 0xeb9ad6bfUL,
- 0xb3f9c6e9UL, 0x0b45a18cUL, 0x19f00e62UL, 0xa14c6907UL, 0x3c9b51beUL,
- 0x842736dbUL, 0x96929935UL, 0x2e2efe50UL, 0x2654b999UL, 0x9ee8defcUL,
- 0x8c5d7112UL, 0x34e11677UL, 0xa9362eceUL, 0x118a49abUL, 0x033fe645UL,
- 0xbb838120UL, 0xe3e09176UL, 0x5b5cf613UL, 0x49e959fdUL, 0xf1553e98UL,
- 0x6c820621UL, 0xd43e6144UL, 0xc68bceaaUL, 0x7e37a9cfUL, 0xd67f4138UL,
- 0x6ec3265dUL, 0x7c7689b3UL, 0xc4caeed6UL, 0x591dd66fUL, 0xe1a1b10aUL,
- 0xf3141ee4UL, 0x4ba87981UL, 0x13cb69d7UL, 0xab770eb2UL, 0xb9c2a15cUL,
- 0x017ec639UL, 0x9ca9fe80UL, 0x241599e5UL, 0x36a0360bUL, 0x8e1c516eUL,
- 0x866616a7UL, 0x3eda71c2UL, 0x2c6fde2cUL, 0x94d3b949UL, 0x090481f0UL,
- 0xb1b8e695UL, 0xa30d497bUL, 0x1bb12e1eUL, 0x43d23e48UL, 0xfb6e592dUL,
- 0xe9dbf6c3UL, 0x516791a6UL, 0xccb0a91fUL, 0x740cce7aUL, 0x66b96194UL,
- 0xde0506f1UL
- },
- {
- 0x00000000UL, 0x96300777UL, 0x2c610eeeUL, 0xba510999UL, 0x19c46d07UL,
- 0x8ff46a70UL, 0x35a563e9UL, 0xa395649eUL, 0x3288db0eUL, 0xa4b8dc79UL,
- 0x1ee9d5e0UL, 0x88d9d297UL, 0x2b4cb609UL, 0xbd7cb17eUL, 0x072db8e7UL,
- 0x911dbf90UL, 0x6410b71dUL, 0xf220b06aUL, 0x4871b9f3UL, 0xde41be84UL,
- 0x7dd4da1aUL, 0xebe4dd6dUL, 0x51b5d4f4UL, 0xc785d383UL, 0x56986c13UL,
- 0xc0a86b64UL, 0x7af962fdUL, 0xecc9658aUL, 0x4f5c0114UL, 0xd96c0663UL,
- 0x633d0ffaUL, 0xf50d088dUL, 0xc8206e3bUL, 0x5e10694cUL, 0xe44160d5UL,
- 0x727167a2UL, 0xd1e4033cUL, 0x47d4044bUL, 0xfd850dd2UL, 0x6bb50aa5UL,
- 0xfaa8b535UL, 0x6c98b242UL, 0xd6c9bbdbUL, 0x40f9bcacUL, 0xe36cd832UL,
- 0x755cdf45UL, 0xcf0dd6dcUL, 0x593dd1abUL, 0xac30d926UL, 0x3a00de51UL,
- 0x8051d7c8UL, 0x1661d0bfUL, 0xb5f4b421UL, 0x23c4b356UL, 0x9995bacfUL,
- 0x0fa5bdb8UL, 0x9eb80228UL, 0x0888055fUL, 0xb2d90cc6UL, 0x24e90bb1UL,
- 0x877c6f2fUL, 0x114c6858UL, 0xab1d61c1UL, 0x3d2d66b6UL, 0x9041dc76UL,
- 0x0671db01UL, 0xbc20d298UL, 0x2a10d5efUL, 0x8985b171UL, 0x1fb5b606UL,
- 0xa5e4bf9fUL, 0x33d4b8e8UL, 0xa2c90778UL, 0x34f9000fUL, 0x8ea80996UL,
- 0x18980ee1UL, 0xbb0d6a7fUL, 0x2d3d6d08UL, 0x976c6491UL, 0x015c63e6UL,
- 0xf4516b6bUL, 0x62616c1cUL, 0xd8306585UL, 0x4e0062f2UL, 0xed95066cUL,
- 0x7ba5011bUL, 0xc1f40882UL, 0x57c40ff5UL, 0xc6d9b065UL, 0x50e9b712UL,
- 0xeab8be8bUL, 0x7c88b9fcUL, 0xdf1ddd62UL, 0x492dda15UL, 0xf37cd38cUL,
- 0x654cd4fbUL, 0x5861b24dUL, 0xce51b53aUL, 0x7400bca3UL, 0xe230bbd4UL,
- 0x41a5df4aUL, 0xd795d83dUL, 0x6dc4d1a4UL, 0xfbf4d6d3UL, 0x6ae96943UL,
- 0xfcd96e34UL, 0x468867adUL, 0xd0b860daUL, 0x732d0444UL, 0xe51d0333UL,
- 0x5f4c0aaaUL, 0xc97c0dddUL, 0x3c710550UL, 0xaa410227UL, 0x10100bbeUL,
- 0x86200cc9UL, 0x25b56857UL, 0xb3856f20UL, 0x09d466b9UL, 0x9fe461ceUL,
- 0x0ef9de5eUL, 0x98c9d929UL, 0x2298d0b0UL, 0xb4a8d7c7UL, 0x173db359UL,
- 0x810db42eUL, 0x3b5cbdb7UL, 0xad6cbac0UL, 0x2083b8edUL, 0xb6b3bf9aUL,
- 0x0ce2b603UL, 0x9ad2b174UL, 0x3947d5eaUL, 0xaf77d29dUL, 0x1526db04UL,
- 0x8316dc73UL, 0x120b63e3UL, 0x843b6494UL, 0x3e6a6d0dUL, 0xa85a6a7aUL,
- 0x0bcf0ee4UL, 0x9dff0993UL, 0x27ae000aUL, 0xb19e077dUL, 0x44930ff0UL,
- 0xd2a30887UL, 0x68f2011eUL, 0xfec20669UL, 0x5d5762f7UL, 0xcb676580UL,
- 0x71366c19UL, 0xe7066b6eUL, 0x761bd4feUL, 0xe02bd389UL, 0x5a7ada10UL,
- 0xcc4add67UL, 0x6fdfb9f9UL, 0xf9efbe8eUL, 0x43beb717UL, 0xd58eb060UL,
- 0xe8a3d6d6UL, 0x7e93d1a1UL, 0xc4c2d838UL, 0x52f2df4fUL, 0xf167bbd1UL,
- 0x6757bca6UL, 0xdd06b53fUL, 0x4b36b248UL, 0xda2b0dd8UL, 0x4c1b0aafUL,
- 0xf64a0336UL, 0x607a0441UL, 0xc3ef60dfUL, 0x55df67a8UL, 0xef8e6e31UL,
- 0x79be6946UL, 0x8cb361cbUL, 0x1a8366bcUL, 0xa0d26f25UL, 0x36e26852UL,
- 0x95770cccUL, 0x03470bbbUL, 0xb9160222UL, 0x2f260555UL, 0xbe3bbac5UL,
- 0x280bbdb2UL, 0x925ab42bUL, 0x046ab35cUL, 0xa7ffd7c2UL, 0x31cfd0b5UL,
- 0x8b9ed92cUL, 0x1daede5bUL, 0xb0c2649bUL, 0x26f263ecUL, 0x9ca36a75UL,
- 0x0a936d02UL, 0xa906099cUL, 0x3f360eebUL, 0x85670772UL, 0x13570005UL,
- 0x824abf95UL, 0x147ab8e2UL, 0xae2bb17bUL, 0x381bb60cUL, 0x9b8ed292UL,
- 0x0dbed5e5UL, 0xb7efdc7cUL, 0x21dfdb0bUL, 0xd4d2d386UL, 0x42e2d4f1UL,
- 0xf8b3dd68UL, 0x6e83da1fUL, 0xcd16be81UL, 0x5b26b9f6UL, 0xe177b06fUL,
- 0x7747b718UL, 0xe65a0888UL, 0x706a0fffUL, 0xca3b0666UL, 0x5c0b0111UL,
- 0xff9e658fUL, 0x69ae62f8UL, 0xd3ff6b61UL, 0x45cf6c16UL, 0x78e20aa0UL,
- 0xeed20dd7UL, 0x5483044eUL, 0xc2b30339UL, 0x612667a7UL, 0xf71660d0UL,
- 0x4d476949UL, 0xdb776e3eUL, 0x4a6ad1aeUL, 0xdc5ad6d9UL, 0x660bdf40UL,
- 0xf03bd837UL, 0x53aebca9UL, 0xc59ebbdeUL, 0x7fcfb247UL, 0xe9ffb530UL,
- 0x1cf2bdbdUL, 0x8ac2bacaUL, 0x3093b353UL, 0xa6a3b424UL, 0x0536d0baUL,
- 0x9306d7cdUL, 0x2957de54UL, 0xbf67d923UL, 0x2e7a66b3UL, 0xb84a61c4UL,
- 0x021b685dUL, 0x942b6f2aUL, 0x37be0bb4UL, 0xa18e0cc3UL, 0x1bdf055aUL,
- 0x8def022dUL
- },
- {
- 0x00000000UL, 0x41311b19UL, 0x82623632UL, 0xc3532d2bUL, 0x04c56c64UL,
- 0x45f4777dUL, 0x86a75a56UL, 0xc796414fUL, 0x088ad9c8UL, 0x49bbc2d1UL,
- 0x8ae8effaUL, 0xcbd9f4e3UL, 0x0c4fb5acUL, 0x4d7eaeb5UL, 0x8e2d839eUL,
- 0xcf1c9887UL, 0x5112c24aUL, 0x1023d953UL, 0xd370f478UL, 0x9241ef61UL,
- 0x55d7ae2eUL, 0x14e6b537UL, 0xd7b5981cUL, 0x96848305UL, 0x59981b82UL,
- 0x18a9009bUL, 0xdbfa2db0UL, 0x9acb36a9UL, 0x5d5d77e6UL, 0x1c6c6cffUL,
- 0xdf3f41d4UL, 0x9e0e5acdUL, 0xa2248495UL, 0xe3159f8cUL, 0x2046b2a7UL,
- 0x6177a9beUL, 0xa6e1e8f1UL, 0xe7d0f3e8UL, 0x2483dec3UL, 0x65b2c5daUL,
- 0xaaae5d5dUL, 0xeb9f4644UL, 0x28cc6b6fUL, 0x69fd7076UL, 0xae6b3139UL,
- 0xef5a2a20UL, 0x2c09070bUL, 0x6d381c12UL, 0xf33646dfUL, 0xb2075dc6UL,
- 0x715470edUL, 0x30656bf4UL, 0xf7f32abbUL, 0xb6c231a2UL, 0x75911c89UL,
- 0x34a00790UL, 0xfbbc9f17UL, 0xba8d840eUL, 0x79dea925UL, 0x38efb23cUL,
- 0xff79f373UL, 0xbe48e86aUL, 0x7d1bc541UL, 0x3c2ade58UL, 0x054f79f0UL,
- 0x447e62e9UL, 0x872d4fc2UL, 0xc61c54dbUL, 0x018a1594UL, 0x40bb0e8dUL,
- 0x83e823a6UL, 0xc2d938bfUL, 0x0dc5a038UL, 0x4cf4bb21UL, 0x8fa7960aUL,
- 0xce968d13UL, 0x0900cc5cUL, 0x4831d745UL, 0x8b62fa6eUL, 0xca53e177UL,
- 0x545dbbbaUL, 0x156ca0a3UL, 0xd63f8d88UL, 0x970e9691UL, 0x5098d7deUL,
- 0x11a9ccc7UL, 0xd2fae1ecUL, 0x93cbfaf5UL, 0x5cd76272UL, 0x1de6796bUL,
- 0xdeb55440UL, 0x9f844f59UL, 0x58120e16UL, 0x1923150fUL, 0xda703824UL,
- 0x9b41233dUL, 0xa76bfd65UL, 0xe65ae67cUL, 0x2509cb57UL, 0x6438d04eUL,
- 0xa3ae9101UL, 0xe29f8a18UL, 0x21cca733UL, 0x60fdbc2aUL, 0xafe124adUL,
- 0xeed03fb4UL, 0x2d83129fUL, 0x6cb20986UL, 0xab2448c9UL, 0xea1553d0UL,
- 0x29467efbUL, 0x687765e2UL, 0xf6793f2fUL, 0xb7482436UL, 0x741b091dUL,
- 0x352a1204UL, 0xf2bc534bUL, 0xb38d4852UL, 0x70de6579UL, 0x31ef7e60UL,
- 0xfef3e6e7UL, 0xbfc2fdfeUL, 0x7c91d0d5UL, 0x3da0cbccUL, 0xfa368a83UL,
- 0xbb07919aUL, 0x7854bcb1UL, 0x3965a7a8UL, 0x4b98833bUL, 0x0aa99822UL,
- 0xc9fab509UL, 0x88cbae10UL, 0x4f5def5fUL, 0x0e6cf446UL, 0xcd3fd96dUL,
- 0x8c0ec274UL, 0x43125af3UL, 0x022341eaUL, 0xc1706cc1UL, 0x804177d8UL,
- 0x47d73697UL, 0x06e62d8eUL, 0xc5b500a5UL, 0x84841bbcUL, 0x1a8a4171UL,
- 0x5bbb5a68UL, 0x98e87743UL, 0xd9d96c5aUL, 0x1e4f2d15UL, 0x5f7e360cUL,
- 0x9c2d1b27UL, 0xdd1c003eUL, 0x120098b9UL, 0x533183a0UL, 0x9062ae8bUL,
- 0xd153b592UL, 0x16c5f4ddUL, 0x57f4efc4UL, 0x94a7c2efUL, 0xd596d9f6UL,
- 0xe9bc07aeUL, 0xa88d1cb7UL, 0x6bde319cUL, 0x2aef2a85UL, 0xed796bcaUL,
- 0xac4870d3UL, 0x6f1b5df8UL, 0x2e2a46e1UL, 0xe136de66UL, 0xa007c57fUL,
- 0x6354e854UL, 0x2265f34dUL, 0xe5f3b202UL, 0xa4c2a91bUL, 0x67918430UL,
- 0x26a09f29UL, 0xb8aec5e4UL, 0xf99fdefdUL, 0x3accf3d6UL, 0x7bfde8cfUL,
- 0xbc6ba980UL, 0xfd5ab299UL, 0x3e099fb2UL, 0x7f3884abUL, 0xb0241c2cUL,
- 0xf1150735UL, 0x32462a1eUL, 0x73773107UL, 0xb4e17048UL, 0xf5d06b51UL,
- 0x3683467aUL, 0x77b25d63UL, 0x4ed7facbUL, 0x0fe6e1d2UL, 0xccb5ccf9UL,
- 0x8d84d7e0UL, 0x4a1296afUL, 0x0b238db6UL, 0xc870a09dUL, 0x8941bb84UL,
- 0x465d2303UL, 0x076c381aUL, 0xc43f1531UL, 0x850e0e28UL, 0x42984f67UL,
- 0x03a9547eUL, 0xc0fa7955UL, 0x81cb624cUL, 0x1fc53881UL, 0x5ef42398UL,
- 0x9da70eb3UL, 0xdc9615aaUL, 0x1b0054e5UL, 0x5a314ffcUL, 0x996262d7UL,
- 0xd85379ceUL, 0x174fe149UL, 0x567efa50UL, 0x952dd77bUL, 0xd41ccc62UL,
- 0x138a8d2dUL, 0x52bb9634UL, 0x91e8bb1fUL, 0xd0d9a006UL, 0xecf37e5eUL,
- 0xadc26547UL, 0x6e91486cUL, 0x2fa05375UL, 0xe836123aUL, 0xa9070923UL,
- 0x6a542408UL, 0x2b653f11UL, 0xe479a796UL, 0xa548bc8fUL, 0x661b91a4UL,
- 0x272a8abdUL, 0xe0bccbf2UL, 0xa18dd0ebUL, 0x62defdc0UL, 0x23efe6d9UL,
- 0xbde1bc14UL, 0xfcd0a70dUL, 0x3f838a26UL, 0x7eb2913fUL, 0xb924d070UL,
- 0xf815cb69UL, 0x3b46e642UL, 0x7a77fd5bUL, 0xb56b65dcUL, 0xf45a7ec5UL,
- 0x370953eeUL, 0x763848f7UL, 0xb1ae09b8UL, 0xf09f12a1UL, 0x33cc3f8aUL,
- 0x72fd2493UL
- },
- {
- 0x00000000UL, 0x376ac201UL, 0x6ed48403UL, 0x59be4602UL, 0xdca80907UL,
- 0xebc2cb06UL, 0xb27c8d04UL, 0x85164f05UL, 0xb851130eUL, 0x8f3bd10fUL,
- 0xd685970dUL, 0xe1ef550cUL, 0x64f91a09UL, 0x5393d808UL, 0x0a2d9e0aUL,
- 0x3d475c0bUL, 0x70a3261cUL, 0x47c9e41dUL, 0x1e77a21fUL, 0x291d601eUL,
- 0xac0b2f1bUL, 0x9b61ed1aUL, 0xc2dfab18UL, 0xf5b56919UL, 0xc8f23512UL,
- 0xff98f713UL, 0xa626b111UL, 0x914c7310UL, 0x145a3c15UL, 0x2330fe14UL,
- 0x7a8eb816UL, 0x4de47a17UL, 0xe0464d38UL, 0xd72c8f39UL, 0x8e92c93bUL,
- 0xb9f80b3aUL, 0x3cee443fUL, 0x0b84863eUL, 0x523ac03cUL, 0x6550023dUL,
- 0x58175e36UL, 0x6f7d9c37UL, 0x36c3da35UL, 0x01a91834UL, 0x84bf5731UL,
- 0xb3d59530UL, 0xea6bd332UL, 0xdd011133UL, 0x90e56b24UL, 0xa78fa925UL,
- 0xfe31ef27UL, 0xc95b2d26UL, 0x4c4d6223UL, 0x7b27a022UL, 0x2299e620UL,
- 0x15f32421UL, 0x28b4782aUL, 0x1fdeba2bUL, 0x4660fc29UL, 0x710a3e28UL,
- 0xf41c712dUL, 0xc376b32cUL, 0x9ac8f52eUL, 0xada2372fUL, 0xc08d9a70UL,
- 0xf7e75871UL, 0xae591e73UL, 0x9933dc72UL, 0x1c259377UL, 0x2b4f5176UL,
- 0x72f11774UL, 0x459bd575UL, 0x78dc897eUL, 0x4fb64b7fUL, 0x16080d7dUL,
- 0x2162cf7cUL, 0xa4748079UL, 0x931e4278UL, 0xcaa0047aUL, 0xfdcac67bUL,
- 0xb02ebc6cUL, 0x87447e6dUL, 0xdefa386fUL, 0xe990fa6eUL, 0x6c86b56bUL,
- 0x5bec776aUL, 0x02523168UL, 0x3538f369UL, 0x087faf62UL, 0x3f156d63UL,
- 0x66ab2b61UL, 0x51c1e960UL, 0xd4d7a665UL, 0xe3bd6464UL, 0xba032266UL,
- 0x8d69e067UL, 0x20cbd748UL, 0x17a11549UL, 0x4e1f534bUL, 0x7975914aUL,
- 0xfc63de4fUL, 0xcb091c4eUL, 0x92b75a4cUL, 0xa5dd984dUL, 0x989ac446UL,
- 0xaff00647UL, 0xf64e4045UL, 0xc1248244UL, 0x4432cd41UL, 0x73580f40UL,
- 0x2ae64942UL, 0x1d8c8b43UL, 0x5068f154UL, 0x67023355UL, 0x3ebc7557UL,
- 0x09d6b756UL, 0x8cc0f853UL, 0xbbaa3a52UL, 0xe2147c50UL, 0xd57ebe51UL,
- 0xe839e25aUL, 0xdf53205bUL, 0x86ed6659UL, 0xb187a458UL, 0x3491eb5dUL,
- 0x03fb295cUL, 0x5a456f5eUL, 0x6d2fad5fUL, 0x801b35e1UL, 0xb771f7e0UL,
- 0xeecfb1e2UL, 0xd9a573e3UL, 0x5cb33ce6UL, 0x6bd9fee7UL, 0x3267b8e5UL,
- 0x050d7ae4UL, 0x384a26efUL, 0x0f20e4eeUL, 0x569ea2ecUL, 0x61f460edUL,
- 0xe4e22fe8UL, 0xd388ede9UL, 0x8a36abebUL, 0xbd5c69eaUL, 0xf0b813fdUL,
- 0xc7d2d1fcUL, 0x9e6c97feUL, 0xa90655ffUL, 0x2c101afaUL, 0x1b7ad8fbUL,
- 0x42c49ef9UL, 0x75ae5cf8UL, 0x48e900f3UL, 0x7f83c2f2UL, 0x263d84f0UL,
- 0x115746f1UL, 0x944109f4UL, 0xa32bcbf5UL, 0xfa958df7UL, 0xcdff4ff6UL,
- 0x605d78d9UL, 0x5737bad8UL, 0x0e89fcdaUL, 0x39e33edbUL, 0xbcf571deUL,
- 0x8b9fb3dfUL, 0xd221f5ddUL, 0xe54b37dcUL, 0xd80c6bd7UL, 0xef66a9d6UL,
- 0xb6d8efd4UL, 0x81b22dd5UL, 0x04a462d0UL, 0x33cea0d1UL, 0x6a70e6d3UL,
- 0x5d1a24d2UL, 0x10fe5ec5UL, 0x27949cc4UL, 0x7e2adac6UL, 0x494018c7UL,
- 0xcc5657c2UL, 0xfb3c95c3UL, 0xa282d3c1UL, 0x95e811c0UL, 0xa8af4dcbUL,
- 0x9fc58fcaUL, 0xc67bc9c8UL, 0xf1110bc9UL, 0x740744ccUL, 0x436d86cdUL,
- 0x1ad3c0cfUL, 0x2db902ceUL, 0x4096af91UL, 0x77fc6d90UL, 0x2e422b92UL,
- 0x1928e993UL, 0x9c3ea696UL, 0xab546497UL, 0xf2ea2295UL, 0xc580e094UL,
- 0xf8c7bc9fUL, 0xcfad7e9eUL, 0x9613389cUL, 0xa179fa9dUL, 0x246fb598UL,
- 0x13057799UL, 0x4abb319bUL, 0x7dd1f39aUL, 0x3035898dUL, 0x075f4b8cUL,
- 0x5ee10d8eUL, 0x698bcf8fUL, 0xec9d808aUL, 0xdbf7428bUL, 0x82490489UL,
- 0xb523c688UL, 0x88649a83UL, 0xbf0e5882UL, 0xe6b01e80UL, 0xd1dadc81UL,
- 0x54cc9384UL, 0x63a65185UL, 0x3a181787UL, 0x0d72d586UL, 0xa0d0e2a9UL,
- 0x97ba20a8UL, 0xce0466aaUL, 0xf96ea4abUL, 0x7c78ebaeUL, 0x4b1229afUL,
- 0x12ac6fadUL, 0x25c6adacUL, 0x1881f1a7UL, 0x2feb33a6UL, 0x765575a4UL,
- 0x413fb7a5UL, 0xc429f8a0UL, 0xf3433aa1UL, 0xaafd7ca3UL, 0x9d97bea2UL,
- 0xd073c4b5UL, 0xe71906b4UL, 0xbea740b6UL, 0x89cd82b7UL, 0x0cdbcdb2UL,
- 0x3bb10fb3UL, 0x620f49b1UL, 0x55658bb0UL, 0x6822d7bbUL, 0x5f4815baUL,
- 0x06f653b8UL, 0x319c91b9UL, 0xb48adebcUL, 0x83e01cbdUL, 0xda5e5abfUL,
- 0xed3498beUL
- },
- {
- 0x00000000UL, 0x6567bcb8UL, 0x8bc809aaUL, 0xeeafb512UL, 0x5797628fUL,
- 0x32f0de37UL, 0xdc5f6b25UL, 0xb938d79dUL, 0xef28b4c5UL, 0x8a4f087dUL,
- 0x64e0bd6fUL, 0x018701d7UL, 0xb8bfd64aUL, 0xddd86af2UL, 0x3377dfe0UL,
- 0x56106358UL, 0x9f571950UL, 0xfa30a5e8UL, 0x149f10faUL, 0x71f8ac42UL,
- 0xc8c07bdfUL, 0xada7c767UL, 0x43087275UL, 0x266fcecdUL, 0x707fad95UL,
- 0x1518112dUL, 0xfbb7a43fUL, 0x9ed01887UL, 0x27e8cf1aUL, 0x428f73a2UL,
- 0xac20c6b0UL, 0xc9477a08UL, 0x3eaf32a0UL, 0x5bc88e18UL, 0xb5673b0aUL,
- 0xd00087b2UL, 0x6938502fUL, 0x0c5fec97UL, 0xe2f05985UL, 0x8797e53dUL,
- 0xd1878665UL, 0xb4e03addUL, 0x5a4f8fcfUL, 0x3f283377UL, 0x8610e4eaUL,
- 0xe3775852UL, 0x0dd8ed40UL, 0x68bf51f8UL, 0xa1f82bf0UL, 0xc49f9748UL,
- 0x2a30225aUL, 0x4f579ee2UL, 0xf66f497fUL, 0x9308f5c7UL, 0x7da740d5UL,
- 0x18c0fc6dUL, 0x4ed09f35UL, 0x2bb7238dUL, 0xc518969fUL, 0xa07f2a27UL,
- 0x1947fdbaUL, 0x7c204102UL, 0x928ff410UL, 0xf7e848a8UL, 0x3d58149bUL,
- 0x583fa823UL, 0xb6901d31UL, 0xd3f7a189UL, 0x6acf7614UL, 0x0fa8caacUL,
- 0xe1077fbeUL, 0x8460c306UL, 0xd270a05eUL, 0xb7171ce6UL, 0x59b8a9f4UL,
- 0x3cdf154cUL, 0x85e7c2d1UL, 0xe0807e69UL, 0x0e2fcb7bUL, 0x6b4877c3UL,
- 0xa20f0dcbUL, 0xc768b173UL, 0x29c70461UL, 0x4ca0b8d9UL, 0xf5986f44UL,
- 0x90ffd3fcUL, 0x7e5066eeUL, 0x1b37da56UL, 0x4d27b90eUL, 0x284005b6UL,
- 0xc6efb0a4UL, 0xa3880c1cUL, 0x1ab0db81UL, 0x7fd76739UL, 0x9178d22bUL,
- 0xf41f6e93UL, 0x03f7263bUL, 0x66909a83UL, 0x883f2f91UL, 0xed589329UL,
- 0x546044b4UL, 0x3107f80cUL, 0xdfa84d1eUL, 0xbacff1a6UL, 0xecdf92feUL,
- 0x89b82e46UL, 0x67179b54UL, 0x027027ecUL, 0xbb48f071UL, 0xde2f4cc9UL,
- 0x3080f9dbUL, 0x55e74563UL, 0x9ca03f6bUL, 0xf9c783d3UL, 0x176836c1UL,
- 0x720f8a79UL, 0xcb375de4UL, 0xae50e15cUL, 0x40ff544eUL, 0x2598e8f6UL,
- 0x73888baeUL, 0x16ef3716UL, 0xf8408204UL, 0x9d273ebcUL, 0x241fe921UL,
- 0x41785599UL, 0xafd7e08bUL, 0xcab05c33UL, 0x3bb659edUL, 0x5ed1e555UL,
- 0xb07e5047UL, 0xd519ecffUL, 0x6c213b62UL, 0x094687daUL, 0xe7e932c8UL,
- 0x828e8e70UL, 0xd49eed28UL, 0xb1f95190UL, 0x5f56e482UL, 0x3a31583aUL,
- 0x83098fa7UL, 0xe66e331fUL, 0x08c1860dUL, 0x6da63ab5UL, 0xa4e140bdUL,
- 0xc186fc05UL, 0x2f294917UL, 0x4a4ef5afUL, 0xf3762232UL, 0x96119e8aUL,
- 0x78be2b98UL, 0x1dd99720UL, 0x4bc9f478UL, 0x2eae48c0UL, 0xc001fdd2UL,
- 0xa566416aUL, 0x1c5e96f7UL, 0x79392a4fUL, 0x97969f5dUL, 0xf2f123e5UL,
- 0x05196b4dUL, 0x607ed7f5UL, 0x8ed162e7UL, 0xebb6de5fUL, 0x528e09c2UL,
- 0x37e9b57aUL, 0xd9460068UL, 0xbc21bcd0UL, 0xea31df88UL, 0x8f566330UL,
- 0x61f9d622UL, 0x049e6a9aUL, 0xbda6bd07UL, 0xd8c101bfUL, 0x366eb4adUL,
- 0x53090815UL, 0x9a4e721dUL, 0xff29cea5UL, 0x11867bb7UL, 0x74e1c70fUL,
- 0xcdd91092UL, 0xa8beac2aUL, 0x46111938UL, 0x2376a580UL, 0x7566c6d8UL,
- 0x10017a60UL, 0xfeaecf72UL, 0x9bc973caUL, 0x22f1a457UL, 0x479618efUL,
- 0xa939adfdUL, 0xcc5e1145UL, 0x06ee4d76UL, 0x6389f1ceUL, 0x8d2644dcUL,
- 0xe841f864UL, 0x51792ff9UL, 0x341e9341UL, 0xdab12653UL, 0xbfd69aebUL,
- 0xe9c6f9b3UL, 0x8ca1450bUL, 0x620ef019UL, 0x07694ca1UL, 0xbe519b3cUL,
- 0xdb362784UL, 0x35999296UL, 0x50fe2e2eUL, 0x99b95426UL, 0xfcdee89eUL,
- 0x12715d8cUL, 0x7716e134UL, 0xce2e36a9UL, 0xab498a11UL, 0x45e63f03UL,
- 0x208183bbUL, 0x7691e0e3UL, 0x13f65c5bUL, 0xfd59e949UL, 0x983e55f1UL,
- 0x2106826cUL, 0x44613ed4UL, 0xaace8bc6UL, 0xcfa9377eUL, 0x38417fd6UL,
- 0x5d26c36eUL, 0xb389767cUL, 0xd6eecac4UL, 0x6fd61d59UL, 0x0ab1a1e1UL,
- 0xe41e14f3UL, 0x8179a84bUL, 0xd769cb13UL, 0xb20e77abUL, 0x5ca1c2b9UL,
- 0x39c67e01UL, 0x80fea99cUL, 0xe5991524UL, 0x0b36a036UL, 0x6e511c8eUL,
- 0xa7166686UL, 0xc271da3eUL, 0x2cde6f2cUL, 0x49b9d394UL, 0xf0810409UL,
- 0x95e6b8b1UL, 0x7b490da3UL, 0x1e2eb11bUL, 0x483ed243UL, 0x2d596efbUL,
- 0xc3f6dbe9UL, 0xa6916751UL, 0x1fa9b0ccUL, 0x7ace0c74UL, 0x9461b966UL,
- 0xf10605deUL
-#endif
- }
-};
diff --git a/navit/support/zlib/infback.c b/navit/support/zlib/infback.c
deleted file mode 100644
index 455dbc9ee..000000000
--- a/navit/support/zlib/infback.c
+++ /dev/null
@@ -1,623 +0,0 @@
-/* infback.c -- inflate using a call-back interface
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- This code is largely copied from inflate.c. Normally either infback.o or
- inflate.o would be linked into an application--not both. The interface
- with inffast.c is retained so that optimized assembler-coded versions of
- inflate_fast() can be used with either inflate.c or infback.c.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-
-/*
- strm provides memory allocation functions in zalloc and zfree, or
- Z_NULL to use the library memory allocation functions.
-
- windowBits is in the range 8..15, and window is a user-supplied
- window and output buffer that is 2**windowBits bytes.
- */
-int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size)
-z_streamp strm;
-int windowBits;
-unsigned char FAR *window;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL || window == Z_NULL ||
- windowBits < 8 || windowBits > 15)
- return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)ZALLOC(strm, 1,
- sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (struct internal_state FAR *)state;
- state->dmax = 32768U;
- state->wbits = windowBits;
- state->wsize = 1U << windowBits;
- state->window = window;
- state->write = 0;
- state->whave = 0;
- return Z_OK;
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-/* Macros for inflateBack(): */
-
-/* Load returned state from inflate_fast() */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Set state from registers for inflate_fast() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Assure that some input is available. If input is requested, but denied,
- then return a Z_BUF_ERROR from inflateBack(). */
-#define PULL() \
- do { \
- if (have == 0) { \
- have = in(in_desc, &next); \
- if (have == 0) { \
- next = Z_NULL; \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflateBack()
- with an error if there is no input available. */
-#define PULLBYTE() \
- do { \
- PULL(); \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflateBack() with
- an error. */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Assure that some output space is available, by writing out the window
- if it's full. If the write fails, return from inflateBack() with a
- Z_BUF_ERROR. */
-#define ROOM() \
- do { \
- if (left == 0) { \
- put = state->window; \
- left = state->wsize; \
- state->whave = left; \
- if (out(out_desc, put, left)) { \
- ret = Z_BUF_ERROR; \
- goto inf_leave; \
- } \
- } \
- } while (0)
-
-/*
- strm provides the memory allocation functions and window buffer on input,
- and provides information on the unused input on return. For Z_DATA_ERROR
- returns, strm will also provide an error message.
-
- in() and out() are the call-back input and output functions. When
- inflateBack() needs more input, it calls in(). When inflateBack() has
- filled the window with output, or when it completes with data in the
- window, it calls out() to write out the data. The application must not
- change the provided input until in() is called again or inflateBack()
- returns. The application must not change the window/output buffer until
- inflateBack() returns.
-
- in() and out() are called with a descriptor parameter provided in the
- inflateBack() call. This parameter can be a structure that provides the
- information required to do the read or write, as well as accumulated
- information on the input and output such as totals and check values.
-
- in() should return zero on failure. out() should return non-zero on
- failure. If either in() or out() fails, than inflateBack() returns a
- Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
- was in() or out() that caused in the error. Otherwise, inflateBack()
- returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
- error, or Z_MEM_ERROR if it could not allocate memory for the state.
- inflateBack() can also return Z_STREAM_ERROR if the input parameters
- are not correct, i.e. strm is Z_NULL or the state was not initialized.
- */
-int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc)
-z_streamp strm;
-in_func in;
-void FAR *in_desc;
-out_func out;
-void FAR *out_desc;
-{
- struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- /* Check that the strm exists and that the state was initialized */
- if (strm == Z_NULL || strm->state == Z_NULL)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
-
- /* Reset the state */
- strm->msg = Z_NULL;
- state->mode = TYPE;
- state->last = 0;
- state->whave = 0;
- next = strm->next_in;
- have = next != Z_NULL ? strm->avail_in : 0;
- hold = 0;
- bits = 0;
- put = state->window;
- left = state->wsize;
-
- /* Inflate until end of block marked as last */
- for (;;)
- switch (state->mode) {
- case TYPE:
- /* determine and dispatch block type */
- if (state->last) {
- BYTEBITS();
- state->mode = DONE;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
-
- case STORED:
- /* get and verify stored block length */
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
-
- /* copy stored block from input to output */
- while (state->length != 0) {
- copy = state->length;
- PULL();
- ROOM();
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
-
- case TABLE:
- /* get dynamic table entries descriptor */
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = (char *)"too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
-
- /* get code length code lengths (not a typo) */
- state->have = 0;
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
-
- /* get length and distance code code lengths */
- state->have = 0;
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = (unsigned)(state->lens[state->have - 1]);
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (state->mode == BAD) break;
-
- /* build code tables */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
-
- case LEN:
- /* use inflate_fast() if we have enough input and output */
- if (have >= 6 && left >= 258) {
- RESTORE();
- if (state->whave < state->wsize)
- state->whave = state->wsize - left;
- inflate_fast(strm, state->wsize);
- LOAD();
- break;
- }
-
- /* get a literal, length, or end-of-block code */
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
-
- /* process literal */
- if (this.op == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- ROOM();
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- }
-
- /* process end of block */
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
-
- /* invalid code */
- if (this.op & 64) {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
-
- /* length code -- get extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
-
- /* get distance code */
- for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)this.val;
-
- /* get distance extra bits, if any */
- state->extra = (unsigned)(this.op) & 15;
- if (state->extra != 0) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
- if (state->offset > state->wsize - (state->whave < state->wsize ?
- left : 0)) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
-
- /* copy match from window to output */
- do {
- ROOM();
- copy = state->wsize - state->offset;
- if (copy < left) {
- from = put + copy;
- copy = left - copy;
- }
- else {
- from = put - state->offset;
- copy = left;
- }
- if (copy > state->length) copy = state->length;
- state->length -= copy;
- left -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- } while (state->length != 0);
- break;
-
- case DONE:
- /* inflate stream terminated properly -- write leftover output */
- ret = Z_STREAM_END;
- if (left < state->wsize) {
- if (out(out_desc, state->window, state->wsize - left))
- ret = Z_BUF_ERROR;
- }
- goto inf_leave;
-
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
-
- default: /* can't happen, but makes compilers happy */
- ret = Z_STREAM_ERROR;
- goto inf_leave;
- }
-
- /* Return unused input */
- inf_leave:
- strm->next_in = next;
- strm->avail_in = have;
- return ret;
-}
-
-int ZEXPORT inflateBackEnd(strm)
-z_streamp strm;
-{
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
diff --git a/navit/support/zlib/inffast.c b/navit/support/zlib/inffast.c
deleted file mode 100644
index bbee92ed1..000000000
--- a/navit/support/zlib/inffast.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* inffast.c -- fast decoding
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifndef ASMINF
-
-/* Allow machine dependent optimization for post-increment or pre-increment.
- Based on testing to date,
- Pre-increment preferred for:
- - PowerPC G3 (Adler)
- - MIPS R5000 (Randers-Pehrson)
- Post-increment preferred for:
- - none
- No measurable difference:
- - Pentium III (Anderson)
- - M68060 (Nikl)
- */
-#ifdef POSTINC
-# define OFF 0
-# define PUP(a) *(a)++
-#else
-# define OFF 1
-# define PUP(a) *++(a)
-#endif
-
-/*
- Decode literal, length, and distance codes and write out the resulting
- literal and match bytes until either not enough input or output is
- available, an end-of-block is encountered, or a data error is encountered.
- When large enough input and output buffers are supplied to inflate(), for
- example, a 16K input buffer and a 64K output buffer, more than 95% of the
- inflate execution time is spent in this routine.
-
- Entry assumptions:
-
- state->mode == LEN
- strm->avail_in >= 6
- strm->avail_out >= 258
- start >= strm->avail_out
- state->bits < 8
-
- On return, state->mode is one of:
-
- LEN -- ran out of enough output space or enough available input
- TYPE -- reached end of block code, inflate() to interpret next block
- BAD -- error in block data
-
- Notes:
-
- - The maximum input bits used by a length/distance pair is 15 bits for the
- length code, 5 bits for the length extra, 15 bits for the distance code,
- and 13 bits for the distance extra. This totals 48 bits, or six bytes.
- Therefore if strm->avail_in >= 6, then there is enough input to avoid
- checking for available input while decoding.
-
- - The maximum bytes that a single length/distance pair can output is 258
- bytes, which is the maximum length that can be coded. inflate_fast()
- requires strm->avail_out >= 258 for each loop to avoid checking for
- output space.
- */
-void inflate_fast(strm, start)
-z_streamp strm;
-unsigned start; /* inflate()'s starting value for strm->avail_out */
-{
- struct inflate_state FAR *state;
- unsigned char FAR *in; /* local strm->next_in */
- unsigned char FAR *last; /* while in < last, enough input available */
- unsigned char FAR *out; /* local strm->next_out */
- unsigned char FAR *beg; /* inflate()'s initial strm->next_out */
- unsigned char FAR *end; /* while out < end, enough space available */
-#ifdef INFLATE_STRICT
- unsigned dmax; /* maximum distance from zlib header */
-#endif
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */
- unsigned long hold; /* local strm->hold */
- unsigned bits; /* local strm->bits */
- code const FAR *lcode; /* local strm->lencode */
- code const FAR *dcode; /* local strm->distcode */
- unsigned lmask; /* mask for first level of length codes */
- unsigned dmask; /* mask for first level of distance codes */
- code this; /* retrieved table entry */
- unsigned op; /* code bits, operation, extra bits, or */
- /* window position, window bytes to copy */
- unsigned len; /* match length, unused bytes */
- unsigned dist; /* match distance */
- unsigned char FAR *from; /* where to copy match from */
-
- /* copy state to local variables */
- state = (struct inflate_state FAR *)strm->state;
- in = strm->next_in - OFF;
- last = in + (strm->avail_in - 5);
- out = strm->next_out - OFF;
- beg = out - (start - strm->avail_out);
- end = out + (strm->avail_out - 257);
-#ifdef INFLATE_STRICT
- dmax = state->dmax;
-#endif
- wsize = state->wsize;
- whave = state->whave;
- write = state->write;
- window = state->window;
- hold = state->hold;
- bits = state->bits;
- lcode = state->lencode;
- dcode = state->distcode;
- lmask = (1U << state->lenbits) - 1;
- dmask = (1U << state->distbits) - 1;
-
- /* decode literals and length/distances until end-of-block or not enough
- input data or output space */
- do {
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- this = lcode[hold & lmask];
- dolen:
- op = (unsigned)(this.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(this.op);
- if (op == 0) { /* literal */
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- PUP(out) = (unsigned char)(this.val);
- }
- else if (op & 16) { /* length base */
- len = (unsigned)(this.val);
- op &= 15; /* number of extra bits */
- if (op) {
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- len += (unsigned)hold & ((1U << op) - 1);
- hold >>= op;
- bits -= op;
- }
- Tracevv((stderr, "inflate: length %u\n", len));
- if (bits < 15) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- this = dcode[hold & dmask];
- dodist:
- op = (unsigned)(this.bits);
- hold >>= op;
- bits -= op;
- op = (unsigned)(this.op);
- if (op & 16) { /* distance base */
- dist = (unsigned)(this.val);
- op &= 15; /* number of extra bits */
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- if (bits < op) {
- hold += (unsigned long)(PUP(in)) << bits;
- bits += 8;
- }
- }
- dist += (unsigned)hold & ((1U << op) - 1);
-#ifdef INFLATE_STRICT
- if (dist > dmax) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#endif
- hold >>= op;
- bits -= op;
- Tracevv((stderr, "inflate: distance %u\n", dist));
- op = (unsigned)(out - beg); /* max distance in output */
- if (dist > op) { /* see if copy from window */
- op = dist - op; /* distance back in window */
- if (op > whave) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- from = window - OFF;
- if (write == 0) { /* very common case */
- from += wsize - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- else if (write < op) { /* wrap around window */
- from += wsize + write - op;
- op -= write;
- if (op < len) { /* some from end of window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = window - OFF;
- if (write < len) { /* some from start of window */
- op = write;
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- }
- else { /* contiguous in window */
- from += write - op;
- if (op < len) { /* some from window */
- len -= op;
- do {
- PUP(out) = PUP(from);
- } while (--op);
- from = out - dist; /* rest from output */
- }
- }
- while (len > 2) {
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- }
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- else {
- from = out - dist; /* copy direct from output */
- do { /* minimum length is three */
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- PUP(out) = PUP(from);
- len -= 3;
- } while (len > 2);
- if (len) {
- PUP(out) = PUP(from);
- if (len > 1)
- PUP(out) = PUP(from);
- }
- }
- }
- else if ((op & 64) == 0) { /* 2nd level distance code */
- this = dcode[this.val + (hold & ((1U << op) - 1))];
- goto dodist;
- }
- else {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- }
- else if ((op & 64) == 0) { /* 2nd level length code */
- this = lcode[this.val + (hold & ((1U << op) - 1))];
- goto dolen;
- }
- else if (op & 32) { /* end-of-block */
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- else {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
- } while (in < last && out < end);
-
- /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
- len = bits >> 3;
- in -= len;
- bits -= len << 3;
- hold &= (1U << bits) - 1;
-
- /* update state and return */
- strm->next_in = in + OFF;
- strm->next_out = out + OFF;
- strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
- strm->avail_out = (unsigned)(out < end ?
- 257 + (end - out) : 257 - (out - end));
- state->hold = hold;
- state->bits = bits;
- return;
-}
-
-/*
- inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
- - Using bit fields for code structure
- - Different op definition to avoid & for extra bits (do & for table bits)
- - Three separate decoding do-loops for direct, window, and write == 0
- - Special case for distance > 1 copies to do overlapped load and store copy
- - Explicit branch predictions (based on measured branch probabilities)
- - Deferring match copy and interspersed it with decoding subsequent codes
- - Swapping literal/length else
- - Swapping window/direct else
- - Larger unrolled copy loops (three is about right)
- - Moving len -= 3 statement into middle of loop
- */
-
-#endif /* !ASMINF */
diff --git a/navit/support/zlib/inffast.h b/navit/support/zlib/inffast.h
deleted file mode 100644
index 1e88d2d97..000000000
--- a/navit/support/zlib/inffast.h
+++ /dev/null
@@ -1,11 +0,0 @@
-/* inffast.h -- header to use inffast.c
- * Copyright (C) 1995-2003 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-void inflate_fast OF((z_streamp strm, unsigned start));
diff --git a/navit/support/zlib/inffixed.h b/navit/support/zlib/inffixed.h
deleted file mode 100644
index 75ed4b597..000000000
--- a/navit/support/zlib/inffixed.h
+++ /dev/null
@@ -1,94 +0,0 @@
- /* inffixed.h -- table for decoding fixed codes
- * Generated automatically by makefixed().
- */
-
- /* WARNING: this file should *not* be used by applications. It
- is part of the implementation of the compression library and
- is subject to change. Applications should only use zlib.h.
- */
-
- static const code lenfix[512] = {
- {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
- {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
- {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
- {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
- {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
- {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
- {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
- {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
- {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
- {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
- {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
- {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
- {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
- {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
- {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
- {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
- {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
- {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
- {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
- {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
- {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
- {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
- {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
- {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
- {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
- {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
- {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
- {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
- {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
- {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
- {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
- {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
- {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
- {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
- {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
- {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
- {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
- {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
- {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
- {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
- {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
- {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
- {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
- {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
- {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
- {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
- {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
- {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
- {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
- {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
- {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
- {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
- {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
- {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
- {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
- {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
- {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
- {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
- {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
- {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
- {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
- {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
- {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
- {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
- {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
- {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
- {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
- {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
- {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
- {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
- {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
- {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
- {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
- {0,9,255}
- };
-
- static const code distfix[32] = {
- {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
- {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
- {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
- {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
- {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
- {22,5,193},{64,5,0}
- };
diff --git a/navit/support/zlib/inflate.c b/navit/support/zlib/inflate.c
deleted file mode 100644
index 792fdee8e..000000000
--- a/navit/support/zlib/inflate.c
+++ /dev/null
@@ -1,1368 +0,0 @@
-/* inflate.c -- zlib decompression
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/*
- * Change history:
- *
- * 1.2.beta0 24 Nov 2002
- * - First version -- complete rewrite of inflate to simplify code, avoid
- * creation of window when not needed, minimize use of window when it is
- * needed, make inffast.c even faster, implement gzip decoding, and to
- * improve code readability and style over the previous zlib inflate code
- *
- * 1.2.beta1 25 Nov 2002
- * - Use pointers for available input and output checking in inffast.c
- * - Remove input and output counters in inffast.c
- * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
- * - Remove unnecessary second byte pull from length extra in inffast.c
- * - Unroll direct copy to three copies per loop in inffast.c
- *
- * 1.2.beta2 4 Dec 2002
- * - Change external routine names to reduce potential conflicts
- * - Correct filename to inffixed.h for fixed tables in inflate.c
- * - Make hbuf[] unsigned char to match parameter type in inflate.c
- * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
- * to avoid negation problem on Alphas (64 bit) in inflate.c
- *
- * 1.2.beta3 22 Dec 2002
- * - Add comments on state->bits assertion in inffast.c
- * - Add comments on op field in inftrees.h
- * - Fix bug in reuse of allocated window after inflateReset()
- * - Remove bit fields--back to byte structure for speed
- * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
- * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
- * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
- * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
- * - Use local copies of stream next and avail values, as well as local bit
- * buffer and bit count in inflate()--for speed when inflate_fast() not used
- *
- * 1.2.beta4 1 Jan 2003
- * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
- * - Move a comment on output buffer sizes from inffast.c to inflate.c
- * - Add comments in inffast.c to introduce the inflate_fast() routine
- * - Rearrange window copies in inflate_fast() for speed and simplification
- * - Unroll last copy for window match in inflate_fast()
- * - Use local copies of window variables in inflate_fast() for speed
- * - Pull out common write == 0 case for speed in inflate_fast()
- * - Make op and len in inflate_fast() unsigned for consistency
- * - Add FAR to lcode and dcode declarations in inflate_fast()
- * - Simplified bad distance check in inflate_fast()
- * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
- * source file infback.c to provide a call-back interface to inflate for
- * programs like gzip and unzip -- uses window as output buffer to avoid
- * window copying
- *
- * 1.2.beta5 1 Jan 2003
- * - Improved inflateBack() interface to allow the caller to provide initial
- * input in strm.
- * - Fixed stored blocks bug in inflateBack()
- *
- * 1.2.beta6 4 Jan 2003
- * - Added comments in inffast.c on effectiveness of POSTINC
- * - Typecasting all around to reduce compiler warnings
- * - Changed loops from while (1) or do {} while (1) to for (;;), again to
- * make compilers happy
- * - Changed type of window in inflateBackInit() to unsigned char *
- *
- * 1.2.beta7 27 Jan 2003
- * - Changed many types to unsigned or unsigned short to avoid warnings
- * - Added inflateCopy() function
- *
- * 1.2.0 9 Mar 2003
- * - Changed inflateBack() interface to provide separate opaque descriptors
- * for the in() and out() functions
- * - Changed inflateBack() argument and in_func typedef to swap the length
- * and buffer address return values for the input function
- * - Check next_in and next_out for Z_NULL on entry to inflate()
- *
- * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-#include "inflate.h"
-#include "inffast.h"
-
-#ifdef MAKEFIXED
-# ifndef BUILDFIXED
-# define BUILDFIXED
-# endif
-#endif
-
-/* function prototypes */
-local void fixedtables OF((struct inflate_state FAR *state));
-local int updatewindow OF((z_streamp strm, unsigned out));
-#ifdef BUILDFIXED
- void makefixed OF((void));
-#endif
-local unsigned syncsearch OF((unsigned FAR *have, unsigned char FAR *buf,
- unsigned len));
-
-int ZEXPORT inflateReset(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- strm->total_in = strm->total_out = state->total = 0;
- strm->msg = Z_NULL;
- strm->adler = 1; /* to support ill-conceived Java test suite */
- state->mode = HEAD;
- state->last = 0;
- state->havedict = 0;
- state->dmax = 32768U;
- state->head = Z_NULL;
- state->wsize = 0;
- state->whave = 0;
- state->write = 0;
- state->hold = 0;
- state->bits = 0;
- state->lencode = state->distcode = state->next = state->codes;
- Tracev((stderr, "inflate: reset\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflatePrime(strm, bits, value)
-z_streamp strm;
-int bits;
-int value;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (bits > 16 || state->bits + bits > 32) return Z_STREAM_ERROR;
- value &= (1L << bits) - 1;
- state->hold += value << state->bits;
- state->bits += bits;
- return Z_OK;
-}
-
-int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
-z_streamp strm;
-int windowBits;
-const char *version;
-int stream_size;
-{
- struct inflate_state FAR *state;
-
- if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
- stream_size != (int)(sizeof(z_stream)))
- return Z_VERSION_ERROR;
- if (strm == Z_NULL) return Z_STREAM_ERROR;
- strm->msg = Z_NULL; /* in case we return an error */
- if (strm->zalloc == (alloc_func)0) {
- strm->zalloc = zcalloc;
- strm->opaque = (voidpf)0;
- }
- if (strm->zfree == (free_func)0) strm->zfree = zcfree;
- state = (struct inflate_state FAR *)
- ZALLOC(strm, 1, sizeof(struct inflate_state));
- if (state == Z_NULL) return Z_MEM_ERROR;
- Tracev((stderr, "inflate: allocated\n"));
- strm->state = (struct internal_state FAR *)state;
- if (windowBits < 0) {
- state->wrap = 0;
- windowBits = -windowBits;
- }
- else {
- state->wrap = (windowBits >> 4) + 1;
-#ifdef GUNZIP
- if (windowBits < 48) windowBits &= 15;
-#endif
- }
- if (windowBits < 8 || windowBits > 15) {
- ZFREE(strm, state);
- strm->state = Z_NULL;
- return Z_STREAM_ERROR;
- }
- state->wbits = (unsigned)windowBits;
- state->window = Z_NULL;
- return inflateReset(strm);
-}
-
-int ZEXPORT inflateInit_(strm, version, stream_size)
-z_streamp strm;
-const char *version;
-int stream_size;
-{
- return inflateInit2_(strm, DEF_WBITS, version, stream_size);
-}
-
-/*
- Return state with length and distance decoding tables and index sizes set to
- fixed code decoding. Normally this returns fixed tables from inffixed.h.
- If BUILDFIXED is defined, then instead this routine builds the tables the
- first time it's called, and returns those tables the first time and
- thereafter. This reduces the size of the code by about 2K bytes, in
- exchange for a little execution time. However, BUILDFIXED should not be
- used for threaded applications, since the rewriting of the tables and virgin
- may not be thread-safe.
- */
-local void fixedtables(state)
-struct inflate_state FAR *state;
-{
-#ifdef BUILDFIXED
- static int virgin = 1;
- static code *lenfix, *distfix;
- static code fixed[544];
-
- /* build fixed huffman tables if first call (may not be thread safe) */
- if (virgin) {
- unsigned sym, bits;
- static code *next;
-
- /* literal/length table */
- sym = 0;
- while (sym < 144) state->lens[sym++] = 8;
- while (sym < 256) state->lens[sym++] = 9;
- while (sym < 280) state->lens[sym++] = 7;
- while (sym < 288) state->lens[sym++] = 8;
- next = fixed;
- lenfix = next;
- bits = 9;
- inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
-
- /* distance table */
- sym = 0;
- while (sym < 32) state->lens[sym++] = 5;
- distfix = next;
- bits = 5;
- inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
-
- /* do this just once */
- virgin = 0;
- }
-#else /* !BUILDFIXED */
-# include "inffixed.h"
-#endif /* BUILDFIXED */
- state->lencode = lenfix;
- state->lenbits = 9;
- state->distcode = distfix;
- state->distbits = 5;
-}
-
-#ifdef MAKEFIXED
-#include <stdio.h>
-
-/*
- Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also
- defines BUILDFIXED, so the tables are built on the fly. makefixed() writes
- those tables to stdout, which would be piped to inffixed.h. A small program
- can simply call makefixed to do this:
-
- void makefixed(void);
-
- int main(void)
- {
- makefixed();
- return 0;
- }
-
- Then that can be linked with zlib built with MAKEFIXED defined and run:
-
- a.out > inffixed.h
- */
-void makefixed()
-{
- unsigned low, size;
- struct inflate_state state;
-
- fixedtables(&state);
- puts(" /* inffixed.h -- table for decoding fixed codes");
- puts(" * Generated automatically by makefixed().");
- puts(" */");
- puts("");
- puts(" /* WARNING: this file should *not* be used by applications.");
- puts(" It is part of the implementation of this library and is");
- puts(" subject to change. Applications should only use zlib.h.");
- puts(" */");
- puts("");
- size = 1U << 9;
- printf(" static const code lenfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 7) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits,
- state.lencode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
- size = 1U << 5;
- printf("\n static const code distfix[%u] = {", size);
- low = 0;
- for (;;) {
- if ((low % 6) == 0) printf("\n ");
- printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
- state.distcode[low].val);
- if (++low == size) break;
- putchar(',');
- }
- puts("\n };");
-}
-#endif /* MAKEFIXED */
-
-/*
- Update the window with the last wsize (normally 32K) bytes written before
- returning. If window does not exist yet, create it. This is only called
- when a window is already in use, or when output has been written during this
- inflate call, but the end of the deflate stream has not been reached yet.
- It is also called to create a window for dictionary data when a dictionary
- is loaded.
-
- Providing output buffers larger than 32K to inflate() should provide a speed
- advantage, since only the last 32K of output is copied to the sliding window
- upon return from inflate(), and since all distances after the first 32K of
- output will fall in the output data, making match copies simpler and faster.
- The advantage may be dependent on the size of the processor's data caches.
- */
-local int updatewindow(strm, out)
-z_streamp strm;
-unsigned out;
-{
- struct inflate_state FAR *state;
- unsigned copy, dist;
-
- state = (struct inflate_state FAR *)strm->state;
-
- /* if it hasn't been done already, allocate space for the window */
- if (state->window == Z_NULL) {
- state->window = (unsigned char FAR *)
- ZALLOC(strm, 1U << state->wbits,
- sizeof(unsigned char));
- if (state->window == Z_NULL) return 1;
- }
-
- /* if window not in use yet, initialize */
- if (state->wsize == 0) {
- state->wsize = 1U << state->wbits;
- state->write = 0;
- state->whave = 0;
- }
-
- /* copy state->wsize or less output bytes into the circular window */
- copy = out - strm->avail_out;
- if (copy >= state->wsize) {
- zmemcpy(state->window, strm->next_out - state->wsize, state->wsize);
- state->write = 0;
- state->whave = state->wsize;
- }
- else {
- dist = state->wsize - state->write;
- if (dist > copy) dist = copy;
- zmemcpy(state->window + state->write, strm->next_out - copy, dist);
- copy -= dist;
- if (copy) {
- zmemcpy(state->window, strm->next_out - copy, copy);
- state->write = copy;
- state->whave = state->wsize;
- }
- else {
- state->write += dist;
- if (state->write == state->wsize) state->write = 0;
- if (state->whave < state->wsize) state->whave += dist;
- }
- }
- return 0;
-}
-
-/* Macros for inflate(): */
-
-/* check function to use adler32() for zlib or crc32() for gzip */
-#ifdef GUNZIP
-# define UPDATE(check, buf, len) \
- (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
-#else
-# define UPDATE(check, buf, len) adler32(check, buf, len)
-#endif
-
-/* check macros for header crc */
-#ifdef GUNZIP
-# define CRC2(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- check = crc32(check, hbuf, 2); \
- } while (0)
-
-# define CRC4(check, word) \
- do { \
- hbuf[0] = (unsigned char)(word); \
- hbuf[1] = (unsigned char)((word) >> 8); \
- hbuf[2] = (unsigned char)((word) >> 16); \
- hbuf[3] = (unsigned char)((word) >> 24); \
- check = crc32(check, hbuf, 4); \
- } while (0)
-#endif
-
-/* Load registers with state in inflate() for speed */
-#define LOAD() \
- do { \
- put = strm->next_out; \
- left = strm->avail_out; \
- next = strm->next_in; \
- have = strm->avail_in; \
- hold = state->hold; \
- bits = state->bits; \
- } while (0)
-
-/* Restore state from registers in inflate() */
-#define RESTORE() \
- do { \
- strm->next_out = put; \
- strm->avail_out = left; \
- strm->next_in = next; \
- strm->avail_in = have; \
- state->hold = hold; \
- state->bits = bits; \
- } while (0)
-
-/* Clear the input bit accumulator */
-#define INITBITS() \
- do { \
- hold = 0; \
- bits = 0; \
- } while (0)
-
-/* Get a byte of input into the bit accumulator, or return from inflate()
- if there is no input available. */
-#define PULLBYTE() \
- do { \
- if (have == 0) goto inf_leave; \
- have--; \
- hold += (unsigned long)(*next++) << bits; \
- bits += 8; \
- } while (0)
-
-/* Assure that there are at least n bits in the bit accumulator. If there is
- not enough available input to do that, then return from inflate(). */
-#define NEEDBITS(n) \
- do { \
- while (bits < (unsigned)(n)) \
- PULLBYTE(); \
- } while (0)
-
-/* Return the low n bits of the bit accumulator (n < 16) */
-#define BITS(n) \
- ((unsigned)hold & ((1U << (n)) - 1))
-
-/* Remove n bits from the bit accumulator */
-#define DROPBITS(n) \
- do { \
- hold >>= (n); \
- bits -= (unsigned)(n); \
- } while (0)
-
-/* Remove zero to seven bits as needed to go to a byte boundary */
-#define BYTEBITS() \
- do { \
- hold >>= bits & 7; \
- bits -= bits & 7; \
- } while (0)
-
-/* Reverse the bytes in a 32-bit value */
-#define REVERSE(q) \
- ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
- (((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
-
-/*
- inflate() uses a state machine to process as much input data and generate as
- much output data as possible before returning. The state machine is
- structured roughly as follows:
-
- for (;;) switch (state) {
- ...
- case STATEn:
- if (not enough input data or output space to make progress)
- return;
- ... make progress ...
- state = STATEm;
- break;
- ...
- }
-
- so when inflate() is called again, the same case is attempted again, and
- if the appropriate resources are provided, the machine proceeds to the
- next state. The NEEDBITS() macro is usually the way the state evaluates
- whether it can proceed or should return. NEEDBITS() does the return if
- the requested bits are not available. The typical use of the BITS macros
- is:
-
- NEEDBITS(n);
- ... do something with BITS(n) ...
- DROPBITS(n);
-
- where NEEDBITS(n) either returns from inflate() if there isn't enough
- input left to load n bits into the accumulator, or it continues. BITS(n)
- gives the low n bits in the accumulator. When done, DROPBITS(n) drops
- the low n bits off the accumulator. INITBITS() clears the accumulator
- and sets the number of available bits to zero. BYTEBITS() discards just
- enough bits to put the accumulator on a byte boundary. After BYTEBITS()
- and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
-
- NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
- if there is no input available. The decoding of variable length codes uses
- PULLBYTE() directly in order to pull just enough bytes to decode the next
- code, and no more.
-
- Some states loop until they get enough input, making sure that enough
- state information is maintained to continue the loop where it left off
- if NEEDBITS() returns in the loop. For example, want, need, and keep
- would all have to actually be part of the saved state in case NEEDBITS()
- returns:
-
- case STATEw:
- while (want < need) {
- NEEDBITS(n);
- keep[want++] = BITS(n);
- DROPBITS(n);
- }
- state = STATEx;
- case STATEx:
-
- As shown above, if the next state is also the next case, then the break
- is omitted.
-
- A state may also return if there is not enough output space available to
- complete that state. Those states are copying stored data, writing a
- literal byte, and copying a matching string.
-
- When returning, a "goto inf_leave" is used to update the total counters,
- update the check value, and determine whether any progress has been made
- during that inflate() call in order to return the proper return code.
- Progress is defined as a change in either strm->avail_in or strm->avail_out.
- When there is a window, goto inf_leave will update the window with the last
- output written. If a goto inf_leave occurs in the middle of decompression
- and there is no window currently, goto inf_leave will create one and copy
- output to the window for the next call of inflate().
-
- In this implementation, the flush parameter of inflate() only affects the
- return code (per zlib.h). inflate() always writes as much as possible to
- strm->next_out, given the space available and the provided input--the effect
- documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers
- the allocation of and copying into a sliding window until necessary, which
- provides the effect documented in zlib.h for Z_FINISH when the entire input
- stream available. So the only thing the flush parameter actually does is:
- when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it
- will return Z_BUF_ERROR if it has not reached the end of the stream.
- */
-
-int ZEXPORT inflate(strm, flush)
-z_streamp strm;
-int flush;
-{
- struct inflate_state FAR *state;
- unsigned char FAR *next; /* next input */
- unsigned char FAR *put; /* next output */
- unsigned have, left; /* available input and output */
- unsigned long hold; /* bit buffer */
- unsigned bits; /* bits in bit buffer */
- unsigned in, out; /* save starting available input and output */
- unsigned copy; /* number of stored or match bytes to copy */
- unsigned char FAR *from; /* where to copy match bytes from */
- code this; /* current decoding table entry */
- code last; /* parent table entry */
- unsigned len; /* length to copy for repeats, bits to drop */
- int ret; /* return code */
-#ifdef GUNZIP
- unsigned char hbuf[4]; /* buffer for gzip header crc calculation */
-#endif
- static const unsigned short order[19] = /* permutation of code lengths */
- {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
-
- if (strm == Z_NULL || strm->state == Z_NULL || strm->next_out == Z_NULL ||
- (strm->next_in == Z_NULL && strm->avail_in != 0))
- return Z_STREAM_ERROR;
-
- state = (struct inflate_state FAR *)strm->state;
- if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */
- LOAD();
- in = have;
- out = left;
- ret = Z_OK;
- for (;;)
- switch (state->mode) {
- case HEAD:
- if (state->wrap == 0) {
- state->mode = TYPEDO;
- break;
- }
- NEEDBITS(16);
-#ifdef GUNZIP
- if ((state->wrap & 2) && hold == 0x8b1f) { /* gzip header */
- state->check = crc32(0L, Z_NULL, 0);
- CRC2(state->check, hold);
- INITBITS();
- state->mode = FLAGS;
- break;
- }
- state->flags = 0; /* expect zlib header */
- if (state->head != Z_NULL)
- state->head->done = -1;
- if (!(state->wrap & 1) || /* check if zlib header allowed */
-#else
- if (
-#endif
- ((BITS(8) << 8) + (hold >> 8)) % 31) {
- strm->msg = (char *)"incorrect header check";
- state->mode = BAD;
- break;
- }
- if (BITS(4) != Z_DEFLATED) {
- strm->msg = (char *)"unknown compression method";
- state->mode = BAD;
- break;
- }
- DROPBITS(4);
- len = BITS(4) + 8;
- if (len > state->wbits) {
- strm->msg = (char *)"invalid window size";
- state->mode = BAD;
- break;
- }
- state->dmax = 1U << len;
- Tracev((stderr, "inflate: zlib header ok\n"));
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = hold & 0x200 ? DICTID : TYPE;
- INITBITS();
- break;
-#ifdef GUNZIP
- case FLAGS:
- NEEDBITS(16);
- state->flags = (int)(hold);
- if ((state->flags & 0xff) != Z_DEFLATED) {
- strm->msg = (char *)"unknown compression method";
- state->mode = BAD;
- break;
- }
- if (state->flags & 0xe000) {
- strm->msg = (char *)"unknown header flags set";
- state->mode = BAD;
- break;
- }
- if (state->head != Z_NULL)
- state->head->text = (int)((hold >> 8) & 1);
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = TIME;
- case TIME:
- NEEDBITS(32);
- if (state->head != Z_NULL)
- state->head->time = hold;
- if (state->flags & 0x0200) CRC4(state->check, hold);
- INITBITS();
- state->mode = OS;
- case OS:
- NEEDBITS(16);
- if (state->head != Z_NULL) {
- state->head->xflags = (int)(hold & 0xff);
- state->head->os = (int)(hold >> 8);
- }
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- state->mode = EXLEN;
- case EXLEN:
- if (state->flags & 0x0400) {
- NEEDBITS(16);
- state->length = (unsigned)(hold);
- if (state->head != Z_NULL)
- state->head->extra_len = (unsigned)hold;
- if (state->flags & 0x0200) CRC2(state->check, hold);
- INITBITS();
- }
- else if (state->head != Z_NULL)
- state->head->extra = Z_NULL;
- state->mode = EXTRA;
- case EXTRA:
- if (state->flags & 0x0400) {
- copy = state->length;
- if (copy > have) copy = have;
- if (copy) {
- if (state->head != Z_NULL &&
- state->head->extra != Z_NULL) {
- len = state->head->extra_len - state->length;
- zmemcpy(state->head->extra + len, next,
- len + copy > state->head->extra_max ?
- state->head->extra_max - len : copy);
- }
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- state->length -= copy;
- }
- if (state->length) goto inf_leave;
- }
- state->length = 0;
- state->mode = NAME;
- case NAME:
- if (state->flags & 0x0800) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- if (state->head != Z_NULL &&
- state->head->name != Z_NULL &&
- state->length < state->head->name_max)
- state->head->name[state->length++] = len;
- } while (len && copy < have);
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- else if (state->head != Z_NULL)
- state->head->name = Z_NULL;
- state->length = 0;
- state->mode = COMMENT;
- case COMMENT:
- if (state->flags & 0x1000) {
- if (have == 0) goto inf_leave;
- copy = 0;
- do {
- len = (unsigned)(next[copy++]);
- if (state->head != Z_NULL &&
- state->head->comment != Z_NULL &&
- state->length < state->head->comm_max)
- state->head->comment[state->length++] = len;
- } while (len && copy < have);
- if (state->flags & 0x0200)
- state->check = crc32(state->check, next, copy);
- have -= copy;
- next += copy;
- if (len) goto inf_leave;
- }
- else if (state->head != Z_NULL)
- state->head->comment = Z_NULL;
- state->mode = HCRC;
- case HCRC:
- if (state->flags & 0x0200) {
- NEEDBITS(16);
- if (hold != (state->check & 0xffff)) {
- strm->msg = (char *)"header crc mismatch";
- state->mode = BAD;
- break;
- }
- INITBITS();
- }
- if (state->head != Z_NULL) {
- state->head->hcrc = (int)((state->flags >> 9) & 1);
- state->head->done = 1;
- }
- strm->adler = state->check = crc32(0L, Z_NULL, 0);
- state->mode = TYPE;
- break;
-#endif
- case DICTID:
- NEEDBITS(32);
- strm->adler = state->check = REVERSE(hold);
- INITBITS();
- state->mode = DICT;
- case DICT:
- if (state->havedict == 0) {
- RESTORE();
- return Z_NEED_DICT;
- }
- strm->adler = state->check = adler32(0L, Z_NULL, 0);
- state->mode = TYPE;
- case TYPE:
- if (flush == Z_BLOCK) goto inf_leave;
- case TYPEDO:
- if (state->last) {
- BYTEBITS();
- state->mode = CHECK;
- break;
- }
- NEEDBITS(3);
- state->last = BITS(1);
- DROPBITS(1);
- switch (BITS(2)) {
- case 0: /* stored block */
- Tracev((stderr, "inflate: stored block%s\n",
- state->last ? " (last)" : ""));
- state->mode = STORED;
- break;
- case 1: /* fixed block */
- fixedtables(state);
- Tracev((stderr, "inflate: fixed codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = LEN; /* decode codes */
- break;
- case 2: /* dynamic block */
- Tracev((stderr, "inflate: dynamic codes block%s\n",
- state->last ? " (last)" : ""));
- state->mode = TABLE;
- break;
- case 3:
- strm->msg = (char *)"invalid block type";
- state->mode = BAD;
- }
- DROPBITS(2);
- break;
- case STORED:
- BYTEBITS(); /* go to byte boundary */
- NEEDBITS(32);
- if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
- strm->msg = (char *)"invalid stored block lengths";
- state->mode = BAD;
- break;
- }
- state->length = (unsigned)hold & 0xffff;
- Tracev((stderr, "inflate: stored length %u\n",
- state->length));
- INITBITS();
- state->mode = COPY;
- case COPY:
- copy = state->length;
- if (copy) {
- if (copy > have) copy = have;
- if (copy > left) copy = left;
- if (copy == 0) goto inf_leave;
- zmemcpy(put, next, copy);
- have -= copy;
- next += copy;
- left -= copy;
- put += copy;
- state->length -= copy;
- break;
- }
- Tracev((stderr, "inflate: stored end\n"));
- state->mode = TYPE;
- break;
- case TABLE:
- NEEDBITS(14);
- state->nlen = BITS(5) + 257;
- DROPBITS(5);
- state->ndist = BITS(5) + 1;
- DROPBITS(5);
- state->ncode = BITS(4) + 4;
- DROPBITS(4);
-#ifndef PKZIP_BUG_WORKAROUND
- if (state->nlen > 286 || state->ndist > 30) {
- strm->msg = (char *)"too many length or distance symbols";
- state->mode = BAD;
- break;
- }
-#endif
- Tracev((stderr, "inflate: table sizes ok\n"));
- state->have = 0;
- state->mode = LENLENS;
- case LENLENS:
- while (state->have < state->ncode) {
- NEEDBITS(3);
- state->lens[order[state->have++]] = (unsigned short)BITS(3);
- DROPBITS(3);
- }
- while (state->have < 19)
- state->lens[order[state->have++]] = 0;
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 7;
- ret = inflate_table(CODES, state->lens, 19, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid code lengths set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: code lengths ok\n"));
- state->have = 0;
- state->mode = CODELENS;
- case CODELENS:
- while (state->have < state->nlen + state->ndist) {
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.val < 16) {
- NEEDBITS(this.bits);
- DROPBITS(this.bits);
- state->lens[state->have++] = this.val;
- }
- else {
- if (this.val == 16) {
- NEEDBITS(this.bits + 2);
- DROPBITS(this.bits);
- if (state->have == 0) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- len = state->lens[state->have - 1];
- copy = 3 + BITS(2);
- DROPBITS(2);
- }
- else if (this.val == 17) {
- NEEDBITS(this.bits + 3);
- DROPBITS(this.bits);
- len = 0;
- copy = 3 + BITS(3);
- DROPBITS(3);
- }
- else {
- NEEDBITS(this.bits + 7);
- DROPBITS(this.bits);
- len = 0;
- copy = 11 + BITS(7);
- DROPBITS(7);
- }
- if (state->have + copy > state->nlen + state->ndist) {
- strm->msg = (char *)"invalid bit length repeat";
- state->mode = BAD;
- break;
- }
- while (copy--)
- state->lens[state->have++] = (unsigned short)len;
- }
- }
-
- /* handle error breaks in while */
- if (state->mode == BAD) break;
-
- /* build code tables */
- state->next = state->codes;
- state->lencode = (code const FAR *)(state->next);
- state->lenbits = 9;
- ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
- &(state->lenbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid literal/lengths set";
- state->mode = BAD;
- break;
- }
- state->distcode = (code const FAR *)(state->next);
- state->distbits = 6;
- ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
- &(state->next), &(state->distbits), state->work);
- if (ret) {
- strm->msg = (char *)"invalid distances set";
- state->mode = BAD;
- break;
- }
- Tracev((stderr, "inflate: codes ok\n"));
- state->mode = LEN;
- case LEN:
- if (have >= 6 && left >= 258) {
- RESTORE();
- inflate_fast(strm, out);
- LOAD();
- break;
- }
- for (;;) {
- this = state->lencode[BITS(state->lenbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if (this.op && (this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->lencode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- state->length = (unsigned)this.val;
- if ((int)(this.op) == 0) {
- Tracevv((stderr, this.val >= 0x20 && this.val < 0x7f ?
- "inflate: literal '%c'\n" :
- "inflate: literal 0x%02x\n", this.val));
- state->mode = LIT;
- break;
- }
- if (this.op & 32) {
- Tracevv((stderr, "inflate: end of block\n"));
- state->mode = TYPE;
- break;
- }
- if (this.op & 64) {
- strm->msg = (char *)"invalid literal/length code";
- state->mode = BAD;
- break;
- }
- state->extra = (unsigned)(this.op) & 15;
- state->mode = LENEXT;
- case LENEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->length += BITS(state->extra);
- DROPBITS(state->extra);
- }
- Tracevv((stderr, "inflate: length %u\n", state->length));
- state->mode = DIST;
- case DIST:
- for (;;) {
- this = state->distcode[BITS(state->distbits)];
- if ((unsigned)(this.bits) <= bits) break;
- PULLBYTE();
- }
- if ((this.op & 0xf0) == 0) {
- last = this;
- for (;;) {
- this = state->distcode[last.val +
- (BITS(last.bits + last.op) >> last.bits)];
- if ((unsigned)(last.bits + this.bits) <= bits) break;
- PULLBYTE();
- }
- DROPBITS(last.bits);
- }
- DROPBITS(this.bits);
- if (this.op & 64) {
- strm->msg = (char *)"invalid distance code";
- state->mode = BAD;
- break;
- }
- state->offset = (unsigned)this.val;
- state->extra = (unsigned)(this.op) & 15;
- state->mode = DISTEXT;
- case DISTEXT:
- if (state->extra) {
- NEEDBITS(state->extra);
- state->offset += BITS(state->extra);
- DROPBITS(state->extra);
- }
-#ifdef INFLATE_STRICT
- if (state->offset > state->dmax) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
-#endif
- if (state->offset > state->whave + out - left) {
- strm->msg = (char *)"invalid distance too far back";
- state->mode = BAD;
- break;
- }
- Tracevv((stderr, "inflate: distance %u\n", state->offset));
- state->mode = MATCH;
- case MATCH:
- if (left == 0) goto inf_leave;
- copy = out - left;
- if (state->offset > copy) { /* copy from window */
- copy = state->offset - copy;
- if (copy > state->write) {
- copy -= state->write;
- from = state->window + (state->wsize - copy);
- }
- else
- from = state->window + (state->write - copy);
- if (copy > state->length) copy = state->length;
- }
- else { /* copy from output */
- from = put - state->offset;
- copy = state->length;
- }
- if (copy > left) copy = left;
- left -= copy;
- state->length -= copy;
- do {
- *put++ = *from++;
- } while (--copy);
- if (state->length == 0) state->mode = LEN;
- break;
- case LIT:
- if (left == 0) goto inf_leave;
- *put++ = (unsigned char)(state->length);
- left--;
- state->mode = LEN;
- break;
- case CHECK:
- if (state->wrap) {
- NEEDBITS(32);
- out -= left;
- strm->total_out += out;
- state->total += out;
- if (out)
- strm->adler = state->check =
- UPDATE(state->check, put - out, out);
- out = left;
- if ((
-#ifdef GUNZIP
- state->flags ? hold :
-#endif
- REVERSE(hold)) != state->check) {
- strm->msg = (char *)"incorrect data check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: check matches trailer\n"));
- }
-#ifdef GUNZIP
- state->mode = LENGTH;
- case LENGTH:
- if (state->wrap && state->flags) {
- NEEDBITS(32);
- if (hold != (state->total & 0xffffffffUL)) {
- strm->msg = (char *)"incorrect length check";
- state->mode = BAD;
- break;
- }
- INITBITS();
- Tracev((stderr, "inflate: length matches trailer\n"));
- }
-#endif
- state->mode = DONE;
- case DONE:
- ret = Z_STREAM_END;
- goto inf_leave;
- case BAD:
- ret = Z_DATA_ERROR;
- goto inf_leave;
- case MEM:
- return Z_MEM_ERROR;
- case SYNC:
- default:
- return Z_STREAM_ERROR;
- }
-
- /*
- Return from inflate(), updating the total counts and the check value.
- If there was no progress during the inflate() call, return a buffer
- error. Call updatewindow() to create and/or update the window state.
- Note: a memory error from inflate() is non-recoverable.
- */
- inf_leave:
- RESTORE();
- if (state->wsize || (state->mode < CHECK && out != strm->avail_out))
- if (updatewindow(strm, out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- in -= strm->avail_in;
- out -= strm->avail_out;
- strm->total_in += in;
- strm->total_out += out;
- state->total += out;
- if (state->wrap && out)
- strm->adler = state->check =
- UPDATE(state->check, strm->next_out - out, out);
- strm->data_type = state->bits + (state->last ? 64 : 0) +
- (state->mode == TYPE ? 128 : 0);
- if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
- ret = Z_BUF_ERROR;
- return ret;
-}
-
-int ZEXPORT inflateEnd(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
- if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->window != Z_NULL) ZFREE(strm, state->window);
- ZFREE(strm, strm->state);
- strm->state = Z_NULL;
- Tracev((stderr, "inflate: end\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
-z_streamp strm;
-const Bytef *dictionary;
-uInt dictLength;
-{
- struct inflate_state FAR *state;
- unsigned long id;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (state->wrap != 0 && state->mode != DICT)
- return Z_STREAM_ERROR;
-
- /* check for correct dictionary id */
- if (state->mode == DICT) {
- id = adler32(0L, Z_NULL, 0);
- id = adler32(id, dictionary, dictLength);
- if (id != state->check)
- return Z_DATA_ERROR;
- }
-
- /* copy dictionary to window */
- if (updatewindow(strm, strm->avail_out)) {
- state->mode = MEM;
- return Z_MEM_ERROR;
- }
- if (dictLength > state->wsize) {
- zmemcpy(state->window, dictionary + dictLength - state->wsize,
- state->wsize);
- state->whave = state->wsize;
- }
- else {
- zmemcpy(state->window + state->wsize - dictLength, dictionary,
- dictLength);
- state->whave = dictLength;
- }
- state->havedict = 1;
- Tracev((stderr, "inflate: dictionary set\n"));
- return Z_OK;
-}
-
-int ZEXPORT inflateGetHeader(strm, head)
-z_streamp strm;
-gz_headerp head;
-{
- struct inflate_state FAR *state;
-
- /* check state */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
-
- /* save header structure */
- state->head = head;
- head->done = 0;
- return Z_OK;
-}
-
-/*
- Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found
- or when out of input. When called, *have is the number of pattern bytes
- found in order so far, in 0..3. On return *have is updated to the new
- state. If on return *have equals four, then the pattern was found and the
- return value is how many bytes were read including the last byte of the
- pattern. If *have is less than four, then the pattern has not been found
- yet and the return value is len. In the latter case, syncsearch() can be
- called again with more data and the *have state. *have is initialized to
- zero for the first call.
- */
-local unsigned syncsearch(have, buf, len)
-unsigned FAR *have;
-unsigned char FAR *buf;
-unsigned len;
-{
- unsigned got;
- unsigned next;
-
- got = *have;
- next = 0;
- while (next < len && got < 4) {
- if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
- got++;
- else if (buf[next])
- got = 0;
- else
- got = 4 - got;
- next++;
- }
- *have = got;
- return next;
-}
-
-int ZEXPORT inflateSync(strm)
-z_streamp strm;
-{
- unsigned len; /* number of bytes to look at or looked at */
- unsigned long in, out; /* temporary to save total_in and total_out */
- unsigned char buf[4]; /* to restore bit buffer to byte string */
- struct inflate_state FAR *state;
-
- /* check parameters */
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
-
- /* if first time, start search in bit buffer */
- if (state->mode != SYNC) {
- state->mode = SYNC;
- state->hold <<= state->bits & 7;
- state->bits -= state->bits & 7;
- len = 0;
- while (state->bits >= 8) {
- buf[len++] = (unsigned char)(state->hold);
- state->hold >>= 8;
- state->bits -= 8;
- }
- state->have = 0;
- syncsearch(&(state->have), buf, len);
- }
-
- /* search available input */
- len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
- strm->avail_in -= len;
- strm->next_in += len;
- strm->total_in += len;
-
- /* return no joy or set up to restart inflate() on a new block */
- if (state->have != 4) return Z_DATA_ERROR;
- in = strm->total_in; out = strm->total_out;
- inflateReset(strm);
- strm->total_in = in; strm->total_out = out;
- state->mode = TYPE;
- return Z_OK;
-}
-
-/*
- Returns true if inflate is currently at the end of a block generated by
- Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
- implementation to provide an additional safety check. PPP uses
- Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
- block. When decompressing, PPP checks that at the end of input packet,
- inflate is waiting for these length bytes.
- */
-int ZEXPORT inflateSyncPoint(strm)
-z_streamp strm;
-{
- struct inflate_state FAR *state;
-
- if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)strm->state;
- return state->mode == STORED && state->bits == 0;
-}
-
-int ZEXPORT inflateCopy(dest, source)
-z_streamp dest;
-z_streamp source;
-{
- struct inflate_state FAR *state;
- struct inflate_state FAR *copy;
- unsigned char FAR *window;
- unsigned wsize;
-
- /* check input */
- if (dest == Z_NULL || source == Z_NULL || source->state == Z_NULL ||
- source->zalloc == (alloc_func)0 || source->zfree == (free_func)0)
- return Z_STREAM_ERROR;
- state = (struct inflate_state FAR *)source->state;
-
- /* allocate space */
- copy = (struct inflate_state FAR *)
- ZALLOC(source, 1, sizeof(struct inflate_state));
- if (copy == Z_NULL) return Z_MEM_ERROR;
- window = Z_NULL;
- if (state->window != Z_NULL) {
- window = (unsigned char FAR *)
- ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
- if (window == Z_NULL) {
- ZFREE(source, copy);
- return Z_MEM_ERROR;
- }
- }
-
- /* copy state */
- zmemcpy(dest, source, sizeof(z_stream));
- zmemcpy(copy, state, sizeof(struct inflate_state));
- if (state->lencode >= state->codes &&
- state->lencode <= state->codes + ENOUGH - 1) {
- copy->lencode = copy->codes + (state->lencode - state->codes);
- copy->distcode = copy->codes + (state->distcode - state->codes);
- }
- copy->next = copy->codes + (state->next - state->codes);
- if (window != Z_NULL) {
- wsize = 1U << state->wbits;
- zmemcpy(window, state->window, wsize);
- }
- copy->window = window;
- dest->state = (struct internal_state FAR *)copy;
- return Z_OK;
-}
diff --git a/navit/support/zlib/inflate.h b/navit/support/zlib/inflate.h
deleted file mode 100644
index 07bd3e78a..000000000
--- a/navit/support/zlib/inflate.h
+++ /dev/null
@@ -1,115 +0,0 @@
-/* inflate.h -- internal inflate state definition
- * Copyright (C) 1995-2004 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* define NO_GZIP when compiling if you want to disable gzip header and
- trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
- the crc code when it is not needed. For shared libraries, gzip decoding
- should be left enabled. */
-#ifndef NO_GZIP
-# define GUNZIP
-#endif
-
-/* Possible inflate modes between inflate() calls */
-typedef enum {
- HEAD, /* i: waiting for magic header */
- FLAGS, /* i: waiting for method and flags (gzip) */
- TIME, /* i: waiting for modification time (gzip) */
- OS, /* i: waiting for extra flags and operating system (gzip) */
- EXLEN, /* i: waiting for extra length (gzip) */
- EXTRA, /* i: waiting for extra bytes (gzip) */
- NAME, /* i: waiting for end of file name (gzip) */
- COMMENT, /* i: waiting for end of comment (gzip) */
- HCRC, /* i: waiting for header crc (gzip) */
- DICTID, /* i: waiting for dictionary check value */
- DICT, /* waiting for inflateSetDictionary() call */
- TYPE, /* i: waiting for type bits, including last-flag bit */
- TYPEDO, /* i: same, but skip check to exit inflate on new block */
- STORED, /* i: waiting for stored size (length and complement) */
- COPY, /* i/o: waiting for input or output to copy stored block */
- TABLE, /* i: waiting for dynamic block table lengths */
- LENLENS, /* i: waiting for code length code lengths */
- CODELENS, /* i: waiting for length/lit and distance code lengths */
- LEN, /* i: waiting for length/lit code */
- LENEXT, /* i: waiting for length extra bits */
- DIST, /* i: waiting for distance code */
- DISTEXT, /* i: waiting for distance extra bits */
- MATCH, /* o: waiting for output space to copy string */
- LIT, /* o: waiting for output space to write literal */
- CHECK, /* i: waiting for 32-bit check value */
- LENGTH, /* i: waiting for 32-bit length (gzip) */
- DONE, /* finished check, done -- remain here until reset */
- BAD, /* got a data error -- remain here until reset */
- MEM, /* got an inflate() memory error -- remain here until reset */
- SYNC /* looking for synchronization bytes to restart inflate() */
-} inflate_mode;
-
-/*
- State transitions between above modes -
-
- (most modes can go to the BAD or MEM mode -- not shown for clarity)
-
- Process header:
- HEAD -> (gzip) or (zlib)
- (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME
- NAME -> COMMENT -> HCRC -> TYPE
- (zlib) -> DICTID or TYPE
- DICTID -> DICT -> TYPE
- Read deflate blocks:
- TYPE -> STORED or TABLE or LEN or CHECK
- STORED -> COPY -> TYPE
- TABLE -> LENLENS -> CODELENS -> LEN
- Read deflate codes:
- LEN -> LENEXT or LIT or TYPE
- LENEXT -> DIST -> DISTEXT -> MATCH -> LEN
- LIT -> LEN
- Process trailer:
- CHECK -> LENGTH -> DONE
- */
-
-/* state maintained between inflate() calls. Approximately 7K bytes. */
-struct inflate_state {
- inflate_mode mode; /* current inflate mode */
- int last; /* true if processing last block */
- int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
- int havedict; /* true if dictionary provided */
- int flags; /* gzip header method and flags (0 if zlib) */
- unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
- unsigned long check; /* protected copy of check value */
- unsigned long total; /* protected copy of output count */
- gz_headerp head; /* where to save gzip header information */
- /* sliding window */
- unsigned wbits; /* log base 2 of requested window size */
- unsigned wsize; /* window size or zero if not using window */
- unsigned whave; /* valid bytes in the window */
- unsigned write; /* window write index */
- unsigned char FAR *window; /* allocated sliding window, if needed */
- /* bit accumulator */
- unsigned long hold; /* input bit accumulator */
- unsigned bits; /* number of bits in "in" */
- /* for string and stored block copying */
- unsigned length; /* literal or length of data to copy */
- unsigned offset; /* distance back to copy string from */
- /* for table and code decoding */
- unsigned extra; /* extra bits needed */
- /* fixed and dynamic code tables */
- code const FAR *lencode; /* starting table for length/literal codes */
- code const FAR *distcode; /* starting table for distance codes */
- unsigned lenbits; /* index bits for lencode */
- unsigned distbits; /* index bits for distcode */
- /* dynamic table building */
- unsigned ncode; /* number of code length code lengths */
- unsigned nlen; /* number of length code lengths */
- unsigned ndist; /* number of distance code lengths */
- unsigned have; /* number of code lengths in lens[] */
- code FAR *next; /* next available space in codes[] */
- unsigned short lens[320]; /* temporary storage for code lengths */
- unsigned short work[288]; /* work area for code table building */
- code codes[ENOUGH]; /* space for code tables */
-};
diff --git a/navit/support/zlib/inftrees.c b/navit/support/zlib/inftrees.c
deleted file mode 100644
index 8a9c13ff0..000000000
--- a/navit/support/zlib/inftrees.c
+++ /dev/null
@@ -1,329 +0,0 @@
-/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-#include "zutil.h"
-#include "inftrees.h"
-
-#define MAXBITS 15
-
-const char inflate_copyright[] =
- " inflate 1.2.3 Copyright 1995-2005 Mark Adler ";
-/*
- If you use the zlib library in a product, an acknowledgment is welcome
- in the documentation of your product. If for some reason you cannot
- include such an acknowledgment, I would appreciate that you keep this
- copyright string in the executable of your product.
- */
-
-/*
- Build a set of tables to decode the provided canonical Huffman code.
- The code lengths are lens[0..codes-1]. The result starts at *table,
- whose indices are 0..2^bits-1. work is a writable array of at least
- lens shorts, which is used as a work area. type is the type of code
- to be generated, CODES, LENS, or DISTS. On return, zero is success,
- -1 is an invalid code, and +1 means that ENOUGH isn't enough. table
- on return points to the next available entry's address. bits is the
- requested root table index bits, and on return it is the actual root
- table index bits. It will differ if the request is greater than the
- longest code or if it is less than the shortest code.
- */
-int inflate_table(type, lens, codes, table, bits, work)
-codetype type;
-unsigned short FAR *lens;
-unsigned codes;
-code FAR * FAR *table;
-unsigned FAR *bits;
-unsigned short FAR *work;
-{
- unsigned len; /* a code's length in bits */
- unsigned sym; /* index of code symbols */
- unsigned min, max; /* minimum and maximum code lengths */
- unsigned root; /* number of index bits for root table */
- unsigned curr; /* number of index bits for current table */
- unsigned drop; /* code bits to drop for sub-table */
- int left; /* number of prefix codes available */
- unsigned used; /* code entries in table used */
- unsigned huff; /* Huffman code */
- unsigned incr; /* for incrementing code, index */
- unsigned fill; /* index for replicating entries */
- unsigned low; /* low bits for current root entry */
- unsigned mask; /* mask for low root bits */
- code this; /* table entry for duplication */
- code FAR *next; /* next available space in table */
- const unsigned short FAR *base; /* base value table to use */
- const unsigned short FAR *extra; /* extra bits table to use */
- int end; /* use base and extra for symbol > end */
- unsigned short count[MAXBITS+1]; /* number of codes of each length */
- unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
- static const unsigned short lbase[31] = { /* Length codes 257..285 base */
- 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
- 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
- static const unsigned short lext[31] = { /* Length codes 257..285 extra */
- 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 201, 196};
- static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
- 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
- 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
- 8193, 12289, 16385, 24577, 0, 0};
- static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
- 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
- 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
- 28, 28, 29, 29, 64, 64};
-
- /*
- Process a set of code lengths to create a canonical Huffman code. The
- code lengths are lens[0..codes-1]. Each length corresponds to the
- symbols 0..codes-1. The Huffman code is generated by first sorting the
- symbols by length from short to long, and retaining the symbol order
- for codes with equal lengths. Then the code starts with all zero bits
- for the first code of the shortest length, and the codes are integer
- increments for the same length, and zeros are appended as the length
- increases. For the deflate format, these bits are stored backwards
- from their more natural integer increment ordering, and so when the
- decoding tables are built in the large loop below, the integer codes
- are incremented backwards.
-
- This routine assumes, but does not check, that all of the entries in
- lens[] are in the range 0..MAXBITS. The caller must assure this.
- 1..MAXBITS is interpreted as that code length. zero means that that
- symbol does not occur in this code.
-
- The codes are sorted by computing a count of codes for each length,
- creating from that a table of starting indices for each length in the
- sorted table, and then entering the symbols in order in the sorted
- table. The sorted table is work[], with that space being provided by
- the caller.
-
- The length counts are used for other purposes as well, i.e. finding
- the minimum and maximum length codes, determining if there are any
- codes at all, checking for a valid set of lengths, and looking ahead
- at length counts to determine sub-table sizes when building the
- decoding tables.
- */
-
- /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
- for (len = 0; len <= MAXBITS; len++)
- count[len] = 0;
- for (sym = 0; sym < codes; sym++)
- count[lens[sym]]++;
-
- /* bound code lengths, force root to be within code lengths */
- root = *bits;
- for (max = MAXBITS; max >= 1; max--)
- if (count[max] != 0) break;
- if (root > max) root = max;
- if (max == 0) { /* no symbols to code at all */
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)1;
- this.val = (unsigned short)0;
- *(*table)++ = this; /* make a table to force an error */
- *(*table)++ = this;
- *bits = 1;
- return 0; /* no symbols, but wait for decoding to report error */
- }
- for (min = 1; min <= MAXBITS; min++)
- if (count[min] != 0) break;
- if (root < min) root = min;
-
- /* check for an over-subscribed or incomplete set of lengths */
- left = 1;
- for (len = 1; len <= MAXBITS; len++) {
- left <<= 1;
- left -= count[len];
- if (left < 0) return -1; /* over-subscribed */
- }
- if (left > 0 && (type == CODES || max != 1))
- return -1; /* incomplete set */
-
- /* generate offsets into symbol table for each length for sorting */
- offs[1] = 0;
- for (len = 1; len < MAXBITS; len++)
- offs[len + 1] = offs[len] + count[len];
-
- /* sort symbols by length, by symbol order within each length */
- for (sym = 0; sym < codes; sym++)
- if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
-
- /*
- Create and fill in decoding tables. In this loop, the table being
- filled is at next and has curr index bits. The code being used is huff
- with length len. That code is converted to an index by dropping drop
- bits off of the bottom. For codes where len is less than drop + curr,
- those top drop + curr - len bits are incremented through all values to
- fill the table with replicated entries.
-
- root is the number of index bits for the root table. When len exceeds
- root, sub-tables are created pointed to by the root entry with an index
- of the low root bits of huff. This is saved in low to check for when a
- new sub-table should be started. drop is zero when the root table is
- being filled, and drop is root when sub-tables are being filled.
-
- When a new sub-table is needed, it is necessary to look ahead in the
- code lengths to determine what size sub-table is needed. The length
- counts are used for this, and so count[] is decremented as codes are
- entered in the tables.
-
- used keeps track of how many table entries have been allocated from the
- provided *table space. It is checked when a LENS table is being made
- against the space in *table, ENOUGH, minus the maximum space needed by
- the worst case distance code, MAXD. This should never happen, but the
- sufficiency of ENOUGH has not been proven exhaustively, hence the check.
- This assumes that when type == LENS, bits == 9.
-
- sym increments through all symbols, and the loop terminates when
- all codes of length max, i.e. all codes, have been processed. This
- routine permits incomplete codes, so another loop after this one fills
- in the rest of the decoding tables with invalid code markers.
- */
-
- /* set up for code type */
- switch (type) {
- case CODES:
- base = extra = work; /* dummy value--not used */
- end = 19;
- break;
- case LENS:
- base = lbase;
- base -= 257;
- extra = lext;
- extra -= 257;
- end = 256;
- break;
- default: /* DISTS */
- base = dbase;
- extra = dext;
- end = -1;
- }
-
- /* initialize state for loop */
- huff = 0; /* starting code */
- sym = 0; /* starting code symbol */
- len = min; /* starting code length */
- next = *table; /* current table to fill in */
- curr = root; /* current table index bits */
- drop = 0; /* current bits to drop from code for index */
- low = (unsigned)(-1); /* trigger new sub-table when len > root */
- used = 1U << root; /* use root table entries */
- mask = used - 1; /* mask for comparing low */
-
- /* check available table space */
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* process all codes and make table entries */
- for (;;) {
- /* create table entry */
- this.bits = (unsigned char)(len - drop);
- if ((int)(work[sym]) < end) {
- this.op = (unsigned char)0;
- this.val = work[sym];
- }
- else if ((int)(work[sym]) > end) {
- this.op = (unsigned char)(extra[work[sym]]);
- this.val = base[work[sym]];
- }
- else {
- this.op = (unsigned char)(32 + 64); /* end of block */
- this.val = 0;
- }
-
- /* replicate for those indices with low len bits equal to huff */
- incr = 1U << (len - drop);
- fill = 1U << curr;
- min = fill; /* save offset to next table */
- do {
- fill -= incr;
- next[(huff >> drop) + fill] = this;
- } while (fill != 0);
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
-
- /* go to next symbol, update count, len */
- sym++;
- if (--(count[len]) == 0) {
- if (len == max) break;
- len = lens[work[sym]];
- }
-
- /* create new sub-table if needed */
- if (len > root && (huff & mask) != low) {
- /* if first time, transition to sub-tables */
- if (drop == 0)
- drop = root;
-
- /* increment past last table */
- next += min; /* here min is 1 << curr */
-
- /* determine length of next table */
- curr = len - drop;
- left = (int)(1 << curr);
- while (curr + drop < max) {
- left -= count[curr + drop];
- if (left <= 0) break;
- curr++;
- left <<= 1;
- }
-
- /* check for enough space */
- used += 1U << curr;
- if (type == LENS && used >= ENOUGH - MAXD)
- return 1;
-
- /* point entry in root table to sub-table */
- low = huff & mask;
- (*table)[low].op = (unsigned char)curr;
- (*table)[low].bits = (unsigned char)root;
- (*table)[low].val = (unsigned short)(next - *table);
- }
- }
-
- /*
- Fill in rest of table for incomplete codes. This loop is similar to the
- loop above in incrementing huff for table indices. It is assumed that
- len is equal to curr + drop, so there is no loop needed to increment
- through high index bits. When the current sub-table is filled, the loop
- drops back to the root table to fill in any remaining entries there.
- */
- this.op = (unsigned char)64; /* invalid code marker */
- this.bits = (unsigned char)(len - drop);
- this.val = (unsigned short)0;
- while (huff != 0) {
- /* when done with sub-table, drop back to root table */
- if (drop != 0 && (huff & mask) != low) {
- drop = 0;
- len = root;
- next = *table;
- this.bits = (unsigned char)len;
- }
-
- /* put invalid code marker in table */
- next[huff >> drop] = this;
-
- /* backwards increment the len-bit code huff */
- incr = 1U << (len - 1);
- while (huff & incr)
- incr >>= 1;
- if (incr != 0) {
- huff &= incr - 1;
- huff += incr;
- }
- else
- huff = 0;
- }
-
- /* set return parameters */
- *table += used;
- *bits = root;
- return 0;
-}
diff --git a/navit/support/zlib/inftrees.h b/navit/support/zlib/inftrees.h
deleted file mode 100644
index b1104c87e..000000000
--- a/navit/support/zlib/inftrees.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* inftrees.h -- header to use inftrees.c
- * Copyright (C) 1995-2005 Mark Adler
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* Structure for decoding tables. Each entry provides either the
- information needed to do the operation requested by the code that
- indexed that table entry, or it provides a pointer to another
- table that indexes more bits of the code. op indicates whether
- the entry is a pointer to another table, a literal, a length or
- distance, an end-of-block, or an invalid code. For a table
- pointer, the low four bits of op is the number of index bits of
- that table. For a length or distance, the low four bits of op
- is the number of extra bits to get after the code. bits is
- the number of bits in this code or part of the code to drop off
- of the bit buffer. val is the actual byte to output in the case
- of a literal, the base length or distance, or the offset from
- the current table to the next table. Each entry is four bytes. */
-typedef struct {
- unsigned char op; /* operation, extra bits, table bits */
- unsigned char bits; /* bits in this part of the code */
- unsigned short val; /* offset in table or code value */
-} code;
-
-/* op values as set by inflate_table():
- 00000000 - literal
- 0000tttt - table link, tttt != 0 is the number of table index bits
- 0001eeee - length or distance, eeee is the number of extra bits
- 01100000 - end of block
- 01000000 - invalid code
- */
-
-/* Maximum size of dynamic tree. The maximum found in a long but non-
- exhaustive search was 1444 code structures (852 for length/literals
- and 592 for distances, the latter actually the result of an
- exhaustive search). The true maximum is not known, but the value
- below is more than safe. */
-#define ENOUGH 2048
-#define MAXD 592
-
-/* Type of code to build for inftable() */
-typedef enum {
- CODES,
- LENS,
- DISTS
-} codetype;
-
-extern int inflate_table OF((codetype type, unsigned short FAR *lens,
- unsigned codes, code FAR * FAR *table,
- unsigned FAR *bits, unsigned short FAR *work));
diff --git a/navit/support/zlib/zconf.h b/navit/support/zlib/zconf.h
deleted file mode 100644
index 03a9431c8..000000000
--- a/navit/support/zlib/zconf.h
+++ /dev/null
@@ -1,332 +0,0 @@
-/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZCONF_H
-#define ZCONF_H
-
-/*
- * If you *really* need a unique prefix for all types and library functions,
- * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
- */
-#ifdef Z_PREFIX
-# define deflateInit_ z_deflateInit_
-# define deflate z_deflate
-# define deflateEnd z_deflateEnd
-# define inflateInit_ z_inflateInit_
-# define inflate z_inflate
-# define inflateEnd z_inflateEnd
-# define deflateInit2_ z_deflateInit2_
-# define deflateSetDictionary z_deflateSetDictionary
-# define deflateCopy z_deflateCopy
-# define deflateReset z_deflateReset
-# define deflateParams z_deflateParams
-# define deflateBound z_deflateBound
-# define deflatePrime z_deflatePrime
-# define inflateInit2_ z_inflateInit2_
-# define inflateSetDictionary z_inflateSetDictionary
-# define inflateSync z_inflateSync
-# define inflateSyncPoint z_inflateSyncPoint
-# define inflateCopy z_inflateCopy
-# define inflateReset z_inflateReset
-# define inflateBack z_inflateBack
-# define inflateBackEnd z_inflateBackEnd
-# define compress z_compress
-# define compress2 z_compress2
-# define compressBound z_compressBound
-# define uncompress z_uncompress
-# define adler32 z_adler32
-# define crc32 z_crc32
-# define get_crc_table z_get_crc_table
-# define zError z_zError
-
-# define alloc_func z_alloc_func
-# define free_func z_free_func
-# define in_func z_in_func
-# define out_func z_out_func
-# define Byte z_Byte
-# define uInt z_uInt
-# define uLong z_uLong
-# define Bytef z_Bytef
-# define charf z_charf
-# define intf z_intf
-# define uIntf z_uIntf
-# define uLongf z_uLongf
-# define voidpf z_voidpf
-# define voidp z_voidp
-#endif
-
-#if defined(__MSDOS__) && !defined(MSDOS)
-# define MSDOS
-#endif
-#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
-# define OS2
-#endif
-#if defined(_WINDOWS) && !defined(WINDOWS)
-# define WINDOWS
-#endif
-#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
-# ifndef WIN32
-# define WIN32
-# endif
-#endif
-#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
-# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
-# ifndef SYS16BIT
-# define SYS16BIT
-# endif
-# endif
-#endif
-
-/*
- * Compile with -DMAXSEG_64K if the alloc function cannot allocate more
- * than 64k bytes at a time (needed on systems with 16-bit int).
- */
-#ifdef SYS16BIT
-# define MAXSEG_64K
-#endif
-#ifdef MSDOS
-# define UNALIGNED_OK
-#endif
-
-#ifdef __STDC_VERSION__
-# ifndef STDC
-# define STDC
-# endif
-# if __STDC_VERSION__ >= 199901L
-# ifndef STDC99
-# define STDC99
-# endif
-# endif
-#endif
-#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
-# define STDC
-#endif
-#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
-# define STDC
-#endif
-
-#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
-# define STDC
-#endif
-
-#ifndef STDC
-# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
-# define const /* note: need a more gentle solution here */
-# endif
-#endif
-
-/* Some Mac compilers merge all .h files incorrectly: */
-#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
-# define NO_DUMMY_DECL
-#endif
-
-/* Maximum value for memLevel in deflateInit2 */
-#ifndef MAX_MEM_LEVEL
-# ifdef MAXSEG_64K
-# define MAX_MEM_LEVEL 8
-# else
-# define MAX_MEM_LEVEL 9
-# endif
-#endif
-
-/* Maximum value for windowBits in deflateInit2 and inflateInit2.
- * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
- * created by gzip. (Files created by minigzip can still be extracted by
- * gzip.)
- */
-#ifndef MAX_WBITS
-# define MAX_WBITS 15 /* 32K LZ77 window */
-#endif
-
-/* The memory requirements for deflate are (in bytes):
- (1 << (windowBits+2)) + (1 << (memLevel+9))
- that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
- plus a few kilobytes for small objects. For example, if you want to reduce
- the default memory requirements from 256K to 128K, compile with
- make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
- Of course this will generally degrade compression (there's no free lunch).
-
- The memory requirements for inflate are (in bytes) 1 << windowBits
- that is, 32K for windowBits=15 (default value) plus a few kilobytes
- for small objects.
-*/
-
- /* Type declarations */
-
-#ifndef OF /* function prototypes */
-# ifdef STDC
-# define OF(args) args
-# else
-# define OF(args) ()
-# endif
-#endif
-
-/* The following definitions for FAR are needed only for MSDOS mixed
- * model programming (small or medium model with some far allocations).
- * This was tested only with MSC; for other MSDOS compilers you may have
- * to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
- * just define FAR to be empty.
- */
-#ifdef SYS16BIT
-# if defined(M_I86SM) || defined(M_I86MM)
- /* MSC small or medium model */
-# define SMALL_MEDIUM
-# ifdef _MSC_VER
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-# if (defined(__SMALL__) || defined(__MEDIUM__))
- /* Turbo C small or medium model */
-# define SMALL_MEDIUM
-# ifdef __BORLANDC__
-# define FAR _far
-# else
-# define FAR far
-# endif
-# endif
-#endif
-
-#if defined(WINDOWS) || defined(WIN32)
- /* If building or using zlib as a DLL, define ZLIB_DLL.
- * This is not mandatory, but it offers a little performance increase.
- */
-# ifdef ZLIB_DLL
-# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
-# ifdef ZLIB_INTERNAL
-# define ZEXTERN extern __declspec(dllexport)
-# else
-# define ZEXTERN extern __declspec(dllimport)
-# endif
-# endif
-# endif /* ZLIB_DLL */
- /* If building or using zlib with the WINAPI/WINAPIV calling convention,
- * define ZLIB_WINAPI.
- * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
- */
-# ifdef ZLIB_WINAPI
-# ifdef FAR
-# undef FAR
-# endif
-# include <windows.h>
- /* No need for _export, use ZLIB.DEF instead. */
- /* For complete Windows compatibility, use WINAPI, not __stdcall. */
-# define ZEXPORT WINAPI
-# ifdef WIN32
-# define ZEXPORTVA WINAPIV
-# else
-# define ZEXPORTVA FAR CDECL
-# endif
-# endif
-#endif
-
-#if defined (__BEOS__)
-# ifdef ZLIB_DLL
-# ifdef ZLIB_INTERNAL
-# define ZEXPORT __declspec(dllexport)
-# define ZEXPORTVA __declspec(dllexport)
-# else
-# define ZEXPORT __declspec(dllimport)
-# define ZEXPORTVA __declspec(dllimport)
-# endif
-# endif
-#endif
-
-#ifndef ZEXTERN
-# define ZEXTERN extern
-#endif
-#ifndef ZEXPORT
-# define ZEXPORT
-#endif
-#ifndef ZEXPORTVA
-# define ZEXPORTVA
-#endif
-
-#ifndef FAR
-# define FAR
-#endif
-
-#if !defined(__MACTYPES__)
-typedef unsigned char Byte; /* 8 bits */
-#endif
-typedef unsigned int uInt; /* 16 bits or more */
-typedef unsigned long uLong; /* 32 bits or more */
-
-#ifdef SMALL_MEDIUM
- /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
-# define Bytef Byte FAR
-#else
- typedef Byte FAR Bytef;
-#endif
-typedef char FAR charf;
-typedef int FAR intf;
-typedef uInt FAR uIntf;
-typedef uLong FAR uLongf;
-
-#ifdef STDC
- typedef void const *voidpc;
- typedef void FAR *voidpf;
- typedef void *voidp;
-#else
- typedef Byte const *voidpc;
- typedef Byte FAR *voidpf;
- typedef Byte *voidp;
-#endif
-
-#if 0 /* HAVE_UNISTD_H -- this line is updated by ./configure */
-# include <sys/types.h> /* for off_t */
-# include <unistd.h> /* for SEEK_* and off_t */
-# ifdef VMS
-# include <unixio.h> /* for off_t */
-# endif
-# define z_off_t off_t
-#endif
-#ifndef SEEK_SET
-# define SEEK_SET 0 /* Seek from beginning of file. */
-# define SEEK_CUR 1 /* Seek from current position. */
-# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
-#endif
-#ifndef z_off_t
-# define z_off_t long
-#endif
-
-#if defined(__OS400__)
-# define NO_vsnprintf
-#endif
-
-#if defined(__MVS__)
-# define NO_vsnprintf
-# ifdef FAR
-# undef FAR
-# endif
-#endif
-
-/* MVS linker does not support external names larger than 8 bytes */
-#if defined(__MVS__)
-# pragma map(deflateInit_,"DEIN")
-# pragma map(deflateInit2_,"DEIN2")
-# pragma map(deflateEnd,"DEEND")
-# pragma map(deflateBound,"DEBND")
-# pragma map(inflateInit_,"ININ")
-# pragma map(inflateInit2_,"ININ2")
-# pragma map(inflateEnd,"INEND")
-# pragma map(inflateSync,"INSY")
-# pragma map(inflateSetDictionary,"INSEDI")
-# pragma map(compressBound,"CMBND")
-# pragma map(inflate_table,"INTABL")
-# pragma map(inflate_fast,"INFA")
-# pragma map(inflate_copyright,"INCOPY")
-#endif
-
-#endif /* ZCONF_H */
diff --git a/navit/support/zlib/zlib.h b/navit/support/zlib/zlib.h
deleted file mode 100644
index 022817927..000000000
--- a/navit/support/zlib/zlib.h
+++ /dev/null
@@ -1,1357 +0,0 @@
-/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.2.3, July 18th, 2005
-
- Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
-
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
-
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
-
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
-
- Jean-loup Gailly Mark Adler
- jloup@gzip.org madler@alumni.caltech.edu
-
-
- The data format used by the zlib library is described by RFCs (Request for
- Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
- (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
-*/
-
-#ifndef ZLIB_H
-#define ZLIB_H
-
-#include "zconf.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define ZLIB_VERSION "1.2.3"
-#define ZLIB_VERNUM 0x1230
-
-/*
- The 'zlib' compression library provides in-memory compression and
- decompression functions, including integrity checks of the uncompressed
- data. This version of the library supports only one compression method
- (deflation) but other algorithms will be added later and will have the same
- stream interface.
-
- Compression can be done in a single step if the buffers are large
- enough (for example if an input file is mmap'ed), or can be done by
- repeated calls of the compression function. In the latter case, the
- application must provide more input and/or consume the output
- (providing more output space) before each call.
-
- The compressed data format used by default by the in-memory functions is
- the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped
- around a deflate stream, which is itself documented in RFC 1951.
-
- The library also supports reading and writing files in gzip (.gz) format
- with an interface similar to that of stdio using the functions that start
- with "gz". The gzip format is different from the zlib format. gzip is a
- gzip wrapper, documented in RFC 1952, wrapped around a deflate stream.
-
- This library can optionally read and write gzip streams in memory as well.
-
- The zlib format was designed to be compact and fast for use in memory
- and on communications channels. The gzip format was designed for single-
- file compression on file systems, has a larger header than zlib to maintain
- directory information, and uses a different, slower check method than zlib.
-
- The library does not install any signal handler. The decoder checks
- the consistency of the compressed data, so the library should never
- crash even in case of corrupted input.
-*/
-
-typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size));
-typedef void (*free_func) OF((voidpf opaque, voidpf address));
-
-struct internal_state;
-
-typedef struct z_stream_s {
- Bytef *next_in; /* next input byte */
- uInt avail_in; /* number of bytes available at next_in */
- uLong total_in; /* total nb of input bytes read so far */
-
- Bytef *next_out; /* next output byte should be put there */
- uInt avail_out; /* remaining free space at next_out */
- uLong total_out; /* total nb of bytes output so far */
-
- char *msg; /* last error message, NULL if no error */
- struct internal_state FAR *state; /* not visible by applications */
-
- alloc_func zalloc; /* used to allocate the internal state */
- free_func zfree; /* used to free the internal state */
- voidpf opaque; /* private data object passed to zalloc and zfree */
-
- int data_type; /* best guess about the data type: binary or text */
- uLong adler; /* adler32 value of the uncompressed data */
- uLong reserved; /* reserved for future use */
-} z_stream;
-
-typedef z_stream FAR *z_streamp;
-
-/*
- gzip header information passed to and from zlib routines. See RFC 1952
- for more details on the meanings of these fields.
-*/
-typedef struct gz_header_s {
- int text; /* true if compressed data believed to be text */
- uLong time; /* modification time */
- int xflags; /* extra flags (not used when writing a gzip file) */
- int os; /* operating system */
- Bytef *extra; /* pointer to extra field or Z_NULL if none */
- uInt extra_len; /* extra field length (valid if extra != Z_NULL) */
- uInt extra_max; /* space at extra (only when reading header) */
- Bytef *name; /* pointer to zero-terminated file name or Z_NULL */
- uInt name_max; /* space at name (only when reading header) */
- Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */
- uInt comm_max; /* space at comment (only when reading header) */
- int hcrc; /* true if there was or will be a header crc */
- int done; /* true when done reading gzip header (not used
- when writing a gzip file) */
-} gz_header;
-
-typedef gz_header FAR *gz_headerp;
-
-/*
- The application must update next_in and avail_in when avail_in has
- dropped to zero. It must update next_out and avail_out when avail_out
- has dropped to zero. The application must initialize zalloc, zfree and
- opaque before calling the init function. All other fields are set by the
- compression library and must not be updated by the application.
-
- The opaque value provided by the application will be passed as the first
- parameter for calls of zalloc and zfree. This can be useful for custom
- memory management. The compression library attaches no meaning to the
- opaque value.
-
- zalloc must return Z_NULL if there is not enough memory for the object.
- If zlib is used in a multi-threaded application, zalloc and zfree must be
- thread safe.
-
- On 16-bit systems, the functions zalloc and zfree must be able to allocate
- exactly 65536 bytes, but will not be required to allocate more than this
- if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS,
- pointers returned by zalloc for objects of exactly 65536 bytes *must*
- have their offset normalized to zero. The default allocation function
- provided by this library ensures this (see zutil.c). To reduce memory
- requirements and avoid any allocation of 64K objects, at the expense of
- compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h).
-
- The fields total_in and total_out can be used for statistics or
- progress reports. After compression, total_in holds the total size of
- the uncompressed data and may be saved for use in the decompressor
- (particularly if the decompressor wants to decompress everything in
- a single step).
-*/
-
- /* constants */
-
-#define Z_NO_FLUSH 0
-#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */
-#define Z_SYNC_FLUSH 2
-#define Z_FULL_FLUSH 3
-#define Z_FINISH 4
-#define Z_BLOCK 5
-/* Allowed flush values; see deflate() and inflate() below for details */
-
-#define Z_OK 0
-#define Z_STREAM_END 1
-#define Z_NEED_DICT 2
-#define Z_ERRNO (-1)
-#define Z_STREAM_ERROR (-2)
-#define Z_DATA_ERROR (-3)
-#define Z_MEM_ERROR (-4)
-#define Z_BUF_ERROR (-5)
-#define Z_VERSION_ERROR (-6)
-/* Return codes for the compression/decompression functions. Negative
- * values are errors, positive values are used for special but normal events.
- */
-
-#define Z_NO_COMPRESSION 0
-#define Z_BEST_SPEED 1
-#define Z_BEST_COMPRESSION 9
-#define Z_DEFAULT_COMPRESSION (-1)
-/* compression levels */
-
-#define Z_FILTERED 1
-#define Z_HUFFMAN_ONLY 2
-#define Z_RLE 3
-#define Z_FIXED 4
-#define Z_DEFAULT_STRATEGY 0
-/* compression strategy; see deflateInit2() below for details */
-
-#define Z_BINARY 0
-#define Z_TEXT 1
-#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */
-#define Z_UNKNOWN 2
-/* Possible values of the data_type field (though see inflate()) */
-
-#define Z_DEFLATED 8
-/* The deflate compression method (the only one supported in this version) */
-
-#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */
-
-#define zlib_version zlibVersion()
-/* for compatibility with versions < 1.0.2 */
-
- /* basic functions */
-
-ZEXTERN const char * ZEXPORT zlibVersion OF((void));
-/* The application can compare zlibVersion and ZLIB_VERSION for consistency.
- If the first character differs, the library code actually used is
- not compatible with the zlib.h header file used by the application.
- This check is automatically made by deflateInit and inflateInit.
- */
-
-/*
-ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level));
-
- Initializes the internal stream state for compression. The fields
- zalloc, zfree and opaque must be initialized before by the caller.
- If zalloc and zfree are set to Z_NULL, deflateInit updates them to
- use default allocation functions.
-
- The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9:
- 1 gives best speed, 9 gives best compression, 0 gives no compression at
- all (the input data is simply copied a block at a time).
- Z_DEFAULT_COMPRESSION requests a default compromise between speed and
- compression (currently equivalent to level 6).
-
- deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if level is not a valid compression level,
- Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible
- with the version assumed by the caller (ZLIB_VERSION).
- msg is set to null if there is no error message. deflateInit does not
- perform any compression: this will be done by deflate().
-*/
-
-
-ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
-/*
- deflate compresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce some
- output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. deflate performs one or both of the
- following actions:
-
- - Compress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in and avail_in are updated and
- processing will resume at this point for the next call of deflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. This action is forced if the parameter flush is non zero.
- Forcing flush frequently degrades the compression ratio, so this parameter
- should be set only when necessary (in interactive applications).
- Some output may be provided even if flush is not set.
-
- Before the call of deflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating avail_in or avail_out accordingly; avail_out
- should never be zero before the call. The application can consume the
- compressed output when it wants, for example when the output buffer is full
- (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK
- and with zero avail_out, it must be called again after making room in the
- output buffer because there might be more output pending.
-
- Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to
- decide how much data to accumualte before producing output, in order to
- maximize compression.
-
- If the parameter flush is set to Z_SYNC_FLUSH, all pending output is
- flushed to the output buffer and the output is aligned on a byte boundary, so
- that the decompressor can get all input data available so far. (In particular
- avail_in is zero after the call if enough output space has been provided
- before the call.) Flushing may degrade compression for some compression
- algorithms and so it should be used only when necessary.
-
- If flush is set to Z_FULL_FLUSH, all output is flushed as with
- Z_SYNC_FLUSH, and the compression state is reset so that decompression can
- restart from this point if previous compressed data has been damaged or if
- random access is desired. Using Z_FULL_FLUSH too often can seriously degrade
- compression.
-
- If deflate returns with avail_out == 0, this function must be called again
- with the same value of the flush parameter and more output space (updated
- avail_out), until the flush is complete (deflate returns with non-zero
- avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that
- avail_out is greater than six to avoid repeated flush markers due to
- avail_out == 0 on return.
-
- If the parameter flush is set to Z_FINISH, pending input is processed,
- pending output is flushed and deflate returns with Z_STREAM_END if there
- was enough output space; if deflate returns with Z_OK, this function must be
- called again with Z_FINISH and more output space (updated avail_out) but no
- more input data, until it returns with Z_STREAM_END or an error. After
- deflate has returned Z_STREAM_END, the only possible operations on the
- stream are deflateReset or deflateEnd.
-
- Z_FINISH can be used immediately after deflateInit if all the compression
- is to be done in a single step. In this case, avail_out must be at least
- the value returned by deflateBound (see below). If deflate does not return
- Z_STREAM_END, then it must be called again as described above.
-
- deflate() sets strm->adler to the adler32 checksum of all input read
- so far (that is, total_in bytes).
-
- deflate() may update strm->data_type if it can make a good guess about
- the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered
- binary. This field is only for information purposes and does not affect
- the compression algorithm in any manner.
-
- deflate() returns Z_OK if some progress has been made (more input
- processed or more output produced), Z_STREAM_END if all input has been
- consumed and all output has been produced (only when flush is set to
- Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example
- if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible
- (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not
- fatal, and deflate() can be called again with more input and more output
- space to continue compressing.
-*/
-
-
-ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the
- stream state was inconsistent, Z_DATA_ERROR if the stream was freed
- prematurely (some input or output was discarded). In the error case,
- msg may be set but then points to a static string (which must not be
- deallocated).
-*/
-
-
-/*
-ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm));
-
- Initializes the internal stream state for decompression. The fields
- next_in, avail_in, zalloc, zfree and opaque must be initialized before by
- the caller. If next_in is not Z_NULL and avail_in is large enough (the exact
- value depends on the compression method), inflateInit determines the
- compression method from the zlib header and allocates all data structures
- accordingly; otherwise the allocation will be deferred to the first call of
- inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to
- use default allocation functions.
-
- inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_VERSION_ERROR if the zlib library version is incompatible with the
- version assumed by the caller. msg is set to null if there is no error
- message. inflateInit does not perform any decompression apart from reading
- the zlib header if present: this will be done by inflate(). (So next_in and
- avail_in may be modified, but next_out and avail_out are unchanged.)
-*/
-
-
-ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
-/*
- inflate decompresses as much data as possible, and stops when the input
- buffer becomes empty or the output buffer becomes full. It may introduce
- some output latency (reading input without producing any output) except when
- forced to flush.
-
- The detailed semantics are as follows. inflate performs one or both of the
- following actions:
-
- - Decompress more input starting at next_in and update next_in and avail_in
- accordingly. If not all input can be processed (because there is not
- enough room in the output buffer), next_in is updated and processing
- will resume at this point for the next call of inflate().
-
- - Provide more output starting at next_out and update next_out and avail_out
- accordingly. inflate() provides as much output as possible, until there
- is no more input data or no more space in the output buffer (see below
- about the flush parameter).
-
- Before the call of inflate(), the application should ensure that at least
- one of the actions is possible, by providing more input and/or consuming
- more output, and updating the next_* and avail_* values accordingly.
- The application can consume the uncompressed output when it wants, for
- example when the output buffer is full (avail_out == 0), or after each
- call of inflate(). If inflate returns Z_OK and with zero avail_out, it
- must be called again after making room in the output buffer because there
- might be more output pending.
-
- The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH,
- Z_FINISH, or Z_BLOCK. Z_SYNC_FLUSH requests that inflate() flush as much
- output as possible to the output buffer. Z_BLOCK requests that inflate() stop
- if and when it gets to the next deflate block boundary. When decoding the
- zlib or gzip format, this will cause inflate() to return immediately after
- the header and before the first block. When doing a raw inflate, inflate()
- will go ahead and process the first block, and will return when it gets to
- the end of that block, or when it runs out of data.
-
- The Z_BLOCK option assists in appending to or combining deflate streams.
- Also to assist in this, on return inflate() will set strm->data_type to the
- number of unused bits in the last byte taken from strm->next_in, plus 64
- if inflate() is currently decoding the last block in the deflate stream,
- plus 128 if inflate() returned immediately after decoding an end-of-block
- code or decoding the complete header up to just before the first byte of the
- deflate stream. The end-of-block will not be indicated until all of the
- uncompressed data from that block has been written to strm->next_out. The
- number of unused bits may in general be greater than seven, except when
- bit 7 of data_type is set, in which case the number of unused bits will be
- less than eight.
-
- inflate() should normally be called until it returns Z_STREAM_END or an
- error. However if all decompression is to be performed in a single step
- (a single call of inflate), the parameter flush should be set to
- Z_FINISH. In this case all pending input is processed and all pending
- output is flushed; avail_out must be large enough to hold all the
- uncompressed data. (The size of the uncompressed data may have been saved
- by the compressor for this purpose.) The next operation on this stream must
- be inflateEnd to deallocate the decompression state. The use of Z_FINISH
- is never required, but can be used to inform inflate that a faster approach
- may be used for the single inflate() call.
-
- In this implementation, inflate() always flushes as much output as
- possible to the output buffer, and always uses the faster approach on the
- first call. So the only effect of the flush parameter in this implementation
- is on the return value of inflate(), as noted below, or when it returns early
- because Z_BLOCK is used.
-
- If a preset dictionary is needed after this call (see inflateSetDictionary
- below), inflate sets strm->adler to the adler32 checksum of the dictionary
- chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
- strm->adler to the adler32 checksum of all output produced so far (that is,
- total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
- below. At the end of the stream, inflate() checks that its computed adler32
- checksum is equal to that saved by the compressor and returns Z_STREAM_END
- only if the checksum is correct.
-
- inflate() will decompress and check either zlib-wrapped or gzip-wrapped
- deflate data. The header type is detected automatically. Any information
- contained in the gzip header is not retained, so applications that need that
- information should instead use raw inflate, see inflateInit2() below, or
- inflateBack() and perform their own processing of the gzip header and
- trailer.
-
- inflate() returns Z_OK if some progress has been made (more input processed
- or more output produced), Z_STREAM_END if the end of the compressed data has
- been reached and all uncompressed output has been produced, Z_NEED_DICT if a
- preset dictionary is needed at this point, Z_DATA_ERROR if the input data was
- corrupted (input stream not conforming to the zlib format or incorrect check
- value), Z_STREAM_ERROR if the stream structure was inconsistent (for example
- if next_in or next_out was NULL), Z_MEM_ERROR if there was not enough memory,
- Z_BUF_ERROR if no progress is possible or if there was not enough room in the
- output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and
- inflate() can be called again with more input and more output space to
- continue decompressing. If Z_DATA_ERROR is returned, the application may then
- call inflateSync() to look for a good compression block if a partial recovery
- of the data is desired.
-*/
-
-
-ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm));
-/*
- All dynamically allocated data structures for this stream are freed.
- This function discards any unprocessed input and does not flush any
- pending output.
-
- inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state
- was inconsistent. In the error case, msg may be set but then points to a
- static string (which must not be deallocated).
-*/
-
- /* Advanced functions */
-
-/*
- The following functions are needed only in some special applications.
-*/
-
-/*
-ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm,
- int level,
- int method,
- int windowBits,
- int memLevel,
- int strategy));
-
- This is another version of deflateInit with more compression options. The
- fields next_in, zalloc, zfree and opaque must be initialized before by
- the caller.
-
- The method parameter is the compression method. It must be Z_DEFLATED in
- this version of the library.
-
- The windowBits parameter is the base two logarithm of the window size
- (the size of the history buffer). It should be in the range 8..15 for this
- version of the library. Larger values of this parameter result in better
- compression at the expense of memory usage. The default value is 15 if
- deflateInit is used instead.
-
- windowBits can also be -8..-15 for raw deflate. In this case, -windowBits
- determines the window size. deflate() will then generate raw deflate data
- with no zlib header or trailer, and will not compute an adler32 check value.
-
- windowBits can also be greater than 15 for optional gzip encoding. Add
- 16 to windowBits to write a simple gzip header and trailer around the
- compressed data instead of a zlib wrapper. The gzip header will have no
- file name, no extra data, no comment, no modification time (set to zero),
- no header crc, and the operating system will be set to 255 (unknown). If a
- gzip stream is being written, strm->adler is a crc32 instead of an adler32.
-
- The memLevel parameter specifies how much memory should be allocated
- for the internal compression state. memLevel=1 uses minimum memory but
- is slow and reduces compression ratio; memLevel=9 uses maximum memory
- for optimal speed. The default value is 8. See zconf.h for total memory
- usage as a function of windowBits and memLevel.
-
- The strategy parameter is used to tune the compression algorithm. Use the
- value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a
- filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no
- string match), or Z_RLE to limit match distances to one (run-length
- encoding). Filtered data consists mostly of small values with a somewhat
- random distribution. In this case, the compression algorithm is tuned to
- compress them better. The effect of Z_FILTERED is to force more Huffman
- coding and less string matching; it is somewhat intermediate between
- Z_DEFAULT and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as
- Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy
- parameter only affects the compression ratio but not the correctness of the
- compressed output even if it is not set appropriately. Z_FIXED prevents the
- use of dynamic Huffman codes, allowing for a simpler decoder for special
- applications.
-
- deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid
- method). msg is set to null if there is no error message. deflateInit2 does
- not perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the compression dictionary from the given byte sequence
- without producing any compressed output. This function must be called
- immediately after deflateInit, deflateInit2 or deflateReset, before any
- call of deflate. The compressor and decompressor must use exactly the same
- dictionary (see inflateSetDictionary).
-
- The dictionary should consist of strings (byte sequences) that are likely
- to be encountered later in the data to be compressed, with the most commonly
- used strings preferably put towards the end of the dictionary. Using a
- dictionary is most useful when the data to be compressed is short and can be
- predicted with good accuracy; the data can then be compressed better than
- with the default empty dictionary.
-
- Depending on the size of the compression data structures selected by
- deflateInit or deflateInit2, a part of the dictionary may in effect be
- discarded, for example if the dictionary is larger than the window size in
- deflate or deflate2. Thus the strings most likely to be useful should be
- put at the end of the dictionary, not at the front. In addition, the
- current implementation of deflate will use at most the window size minus
- 262 bytes of the provided dictionary.
-
- Upon return of this function, strm->adler is set to the adler32 value
- of the dictionary; the decompressor may later use this value to determine
- which dictionary has been used by the compressor. (The adler32 value
- applies to the whole dictionary even if only a subset of the dictionary is
- actually used by the compressor.) If a raw deflate was requested, then the
- adler32 value is not computed and strm->adler is not set.
-
- deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent (for example if deflate has already been called for this stream
- or if the compression method is bsort). deflateSetDictionary does not
- perform any compression: this will be done by deflate().
-*/
-
-ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when several compression strategies will be
- tried, for example when there are several ways of pre-processing the input
- data with a filter. The streams that will be discarded should then be freed
- by calling deflateEnd. Note that deflateCopy duplicates the internal
- compression state which can be quite large, so this strategy is slow and
- can consume lots of memory.
-
- deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm));
-/*
- This function is equivalent to deflateEnd followed by deflateInit,
- but does not free and reallocate all the internal compression state.
- The stream will keep the same compression level and any other attributes
- that may have been set by deflateInit2.
-
- deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm,
- int level,
- int strategy));
-/*
- Dynamically update the compression level and compression strategy. The
- interpretation of level and strategy is as in deflateInit2. This can be
- used to switch between compression and straight copy of the input data, or
- to switch to a different kind of input data requiring a different
- strategy. If the compression level is changed, the input available so far
- is compressed with the old level (and may be flushed); the new level will
- take effect only at the next call of deflate().
-
- Before the call of deflateParams, the stream state must be set as for
- a call of deflate(), since the currently available input may have to
- be compressed and flushed. In particular, strm->avail_out must be non-zero.
-
- deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source
- stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR
- if strm->avail_out was zero.
-*/
-
-ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm,
- int good_length,
- int max_lazy,
- int nice_length,
- int max_chain));
-/*
- Fine tune deflate's internal compression parameters. This should only be
- used by someone who understands the algorithm used by zlib's deflate for
- searching for the best matching string, and even then only by the most
- fanatic optimizer trying to squeeze out the last compressed bit for their
- specific input data. Read the deflate.c source code for the meaning of the
- max_lazy, good_length, nice_length, and max_chain parameters.
-
- deflateTune() can be called after deflateInit() or deflateInit2(), and
- returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream.
- */
-
-ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
- uLong sourceLen));
-/*
- deflateBound() returns an upper bound on the compressed size after
- deflation of sourceLen bytes. It must be called after deflateInit()
- or deflateInit2(). This would be used to allocate an output buffer
- for deflation in a single pass, and so would be called before deflate().
-*/
-
-ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- deflatePrime() inserts bits in the deflate output stream. The intent
- is that this function is used to start off the deflate output with the
- bits leftover from a previous deflate stream when appending to it. As such,
- this function can only be used for raw deflate, and must be used before the
- first deflate() call after a deflateInit2() or deflateReset(). bits must be
- less than or equal to 16, and that many of the least significant bits of
- value will be inserted in the output.
-
- deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
- gz_headerp head));
-/*
- deflateSetHeader() provides gzip header information for when a gzip
- stream is requested by deflateInit2(). deflateSetHeader() may be called
- after deflateInit2() or deflateReset() and before the first call of
- deflate(). The text, time, os, extra field, name, and comment information
- in the provided gz_header structure are written to the gzip header (xflag is
- ignored -- the extra flags are set according to the compression level). The
- caller must assure that, if not Z_NULL, name and comment are terminated with
- a zero byte, and that if extra is not Z_NULL, that extra_len bytes are
- available there. If hcrc is true, a gzip header crc is included. Note that
- the current versions of the command-line version of gzip (up through version
- 1.3.x) do not support header crc's, and will report that it is a "multi-part
- gzip file" and give up.
-
- If deflateSetHeader is not used, the default gzip header has text false,
- the time set to zero, and os set to 255, with no extra, name, or comment
- fields. The gzip header is returned to the default state by deflateReset().
-
- deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm,
- int windowBits));
-
- This is another version of inflateInit with an extra parameter. The
- fields next_in, avail_in, zalloc, zfree and opaque must be initialized
- before by the caller.
-
- The windowBits parameter is the base two logarithm of the maximum window
- size (the size of the history buffer). It should be in the range 8..15 for
- this version of the library. The default value is 15 if inflateInit is used
- instead. windowBits must be greater than or equal to the windowBits value
- provided to deflateInit2() while compressing, or it must be equal to 15 if
- deflateInit2() was not used. If a compressed stream with a larger window
- size is given as input, inflate() will return with the error code
- Z_DATA_ERROR instead of trying to allocate a larger window.
-
- windowBits can also be -8..-15 for raw inflate. In this case, -windowBits
- determines the window size. inflate() will then process raw deflate data,
- not looking for a zlib or gzip header, not generating a check value, and not
- looking for any check values for comparison at the end of the stream. This
- is for use with other formats that use the deflate compressed data format
- such as zip. Those formats provide their own check values. If a custom
- format is developed using the raw deflate format for compressed data, it is
- recommended that a check value such as an adler32 or a crc32 be applied to
- the uncompressed data as is done in the zlib, gzip, and zip formats. For
- most applications, the zlib format should be used as is. Note that comments
- above on the use in deflateInit2() applies to the magnitude of windowBits.
-
- windowBits can also be greater than 15 for optional gzip decoding. Add
- 32 to windowBits to enable zlib and gzip decoding with automatic header
- detection, or add 16 to decode only the gzip format (the zlib format will
- return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is
- a crc32 instead of an adler32.
-
- inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_STREAM_ERROR if a parameter is invalid (such as a null strm). msg
- is set to null if there is no error message. inflateInit2 does not perform
- any decompression apart from reading the zlib header if present: this will
- be done by inflate(). (So next_in and avail_in may be modified, but next_out
- and avail_out are unchanged.)
-*/
-
-ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
- const Bytef *dictionary,
- uInt dictLength));
-/*
- Initializes the decompression dictionary from the given uncompressed byte
- sequence. This function must be called immediately after a call of inflate,
- if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
- can be determined from the adler32 value returned by that call of inflate.
- The compressor and decompressor must use exactly the same dictionary (see
- deflateSetDictionary). For raw inflate, this function can be called
- immediately after inflateInit2() or inflateReset() and before any call of
- inflate() to set the dictionary. The application must insure that the
- dictionary that was used for compression is provided.
-
- inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
- parameter is invalid (such as NULL dictionary) or the stream state is
- inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the
- expected one (incorrect adler32 value). inflateSetDictionary does not
- perform any decompression: this will be done by subsequent calls of
- inflate().
-*/
-
-ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
-/*
- Skips invalid compressed data until a full flush point (see above the
- description of deflate with Z_FULL_FLUSH) can be found, or until all
- available input is skipped. No output is provided.
-
- inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
- if no more input was provided, Z_DATA_ERROR if no flush point has been found,
- or Z_STREAM_ERROR if the stream structure was inconsistent. In the success
- case, the application may save the current current value of total_in which
- indicates where valid compressed data was found. In the error case, the
- application may repeatedly call inflateSync, providing more input each time,
- until success or end of the input data.
-*/
-
-ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
- z_streamp source));
-/*
- Sets the destination stream as a complete copy of the source stream.
-
- This function can be useful when randomly accessing a large stream. The
- first pass through the stream can periodically record the inflate state,
- allowing restarting inflate at those points when randomly accessing the
- stream.
-
- inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_STREAM_ERROR if the source stream state was inconsistent
- (such as zalloc being NULL). msg is left unchanged in both source and
- destination.
-*/
-
-ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm));
-/*
- This function is equivalent to inflateEnd followed by inflateInit,
- but does not free and reallocate all the internal decompression state.
- The stream will keep attributes that may have been set by inflateInit2.
-
- inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent (such as zalloc or state being NULL).
-*/
-
-ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm,
- int bits,
- int value));
-/*
- This function inserts bits in the inflate input stream. The intent is
- that this function is used to start inflating at a bit position in the
- middle of a byte. The provided bits will be used before any bytes are used
- from next_in. This function should only be used with raw inflate, and
- should be used before the first inflate() call after inflateInit2() or
- inflateReset(). bits must be less than or equal to 16, and that many of the
- least significant bits of value will be inserted in the input.
-
- inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm,
- gz_headerp head));
-/*
- inflateGetHeader() requests that gzip header information be stored in the
- provided gz_header structure. inflateGetHeader() may be called after
- inflateInit2() or inflateReset(), and before the first call of inflate().
- As inflate() processes the gzip stream, head->done is zero until the header
- is completed, at which time head->done is set to one. If a zlib stream is
- being decoded, then head->done is set to -1 to indicate that there will be
- no gzip header information forthcoming. Note that Z_BLOCK can be used to
- force inflate() to return immediately after header processing is complete
- and before any actual data is decompressed.
-
- The text, time, xflags, and os fields are filled in with the gzip header
- contents. hcrc is set to true if there is a header CRC. (The header CRC
- was valid if done is set to one.) If extra is not Z_NULL, then extra_max
- contains the maximum number of bytes to write to extra. Once done is true,
- extra_len contains the actual extra field length, and extra contains the
- extra field, or that field truncated if extra_max is less than extra_len.
- If name is not Z_NULL, then up to name_max characters are written there,
- terminated with a zero unless the length is greater than name_max. If
- comment is not Z_NULL, then up to comm_max characters are written there,
- terminated with a zero unless the length is greater than comm_max. When
- any of extra, name, or comment are not Z_NULL and the respective field is
- not present in the header, then that field is set to Z_NULL to signal its
- absence. This allows the use of deflateSetHeader() with the returned
- structure to duplicate the header. However if those fields are set to
- allocated memory, then the application will need to save those pointers
- elsewhere so that they can be eventually freed.
-
- If inflateGetHeader is not used, then the header information is simply
- discarded. The header is always checked for validity, including the header
- CRC if present. inflateReset() will reset the process to discard the header
- information. The application would need to call inflateGetHeader() again to
- retrieve the header from the next gzip stream.
-
- inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source
- stream state was inconsistent.
-*/
-
-/*
-ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
- unsigned char FAR *window));
-
- Initialize the internal stream state for decompression using inflateBack()
- calls. The fields zalloc, zfree and opaque in strm must be initialized
- before the call. If zalloc and zfree are Z_NULL, then the default library-
- derived memory allocation routines are used. windowBits is the base two
- logarithm of the window size, in the range 8..15. window is a caller
- supplied buffer of that size. Except for special applications where it is
- assured that deflate was used with small window sizes, windowBits must be 15
- and a 32K byte window must be supplied to be able to decompress general
- deflate streams.
-
- See inflateBack() for the usage of these routines.
-
- inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
- the paramaters are invalid, Z_MEM_ERROR if the internal state could not
- be allocated, or Z_VERSION_ERROR if the version of the library does not
- match the version of the header file.
-*/
-
-typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
-typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
-
-ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
- in_func in, void FAR *in_desc,
- out_func out, void FAR *out_desc));
-/*
- inflateBack() does a raw inflate with a single call using a call-back
- interface for input and output. This is more efficient than inflate() for
- file i/o applications in that it avoids copying between the output and the
- sliding window by simply making the window itself the output buffer. This
- function trusts the application to not change the output buffer passed by
- the output function, at least until inflateBack() returns.
-
- inflateBackInit() must be called first to allocate the internal state
- and to initialize the state with the user-provided window buffer.
- inflateBack() may then be used multiple times to inflate a complete, raw
- deflate stream with each call. inflateBackEnd() is then called to free
- the allocated state.
-
- A raw deflate stream is one with no zlib or gzip header or trailer.
- This routine would normally be used in a utility that reads zip or gzip
- files and writes out uncompressed files. The utility would decode the
- header and process the trailer on its own, hence this routine expects
- only the raw deflate stream to decompress. This is different from the
- normal behavior of inflate(), which expects either a zlib or gzip header and
- trailer around the deflate stream.
-
- inflateBack() uses two subroutines supplied by the caller that are then
- called by inflateBack() for input and output. inflateBack() calls those
- routines until it reads a complete deflate stream and writes out all of the
- uncompressed data, or until it encounters an error. The function's
- parameters and return types are defined above in the in_func and out_func
- typedefs. inflateBack() will call in(in_desc, &buf) which should return the
- number of bytes of provided input, and a pointer to that input in buf. If
- there is no input available, in() must return zero--buf is ignored in that
- case--and inflateBack() will return a buffer error. inflateBack() will call
- out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out()
- should return zero on success, or non-zero on failure. If out() returns
- non-zero, inflateBack() will return with an error. Neither in() nor out()
- are permitted to change the contents of the window provided to
- inflateBackInit(), which is also the buffer that out() uses to write from.
- The length written by out() will be at most the window size. Any non-zero
- amount of input may be provided by in().
-
- For convenience, inflateBack() can be provided input on the first call by
- setting strm->next_in and strm->avail_in. If that input is exhausted, then
- in() will be called. Therefore strm->next_in must be initialized before
- calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called
- immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in
- must also be initialized, and then if strm->avail_in is not zero, input will
- initially be taken from strm->next_in[0 .. strm->avail_in - 1].
-
- The in_desc and out_desc parameters of inflateBack() is passed as the
- first parameter of in() and out() respectively when they are called. These
- descriptors can be optionally used to pass any information that the caller-
- supplied in() and out() functions need to do their job.
-
- On return, inflateBack() will set strm->next_in and strm->avail_in to
- pass back any unused input that was provided by the last in() call. The
- return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR
- if in() or out() returned an error, Z_DATA_ERROR if there was a format
- error in the deflate stream (in which case strm->msg is set to indicate the
- nature of the error), or Z_STREAM_ERROR if the stream was not properly
- initialized. In the case of Z_BUF_ERROR, an input or output error can be
- distinguished using strm->next_in which will be Z_NULL only if in() returned
- an error. If strm->next is not Z_NULL, then the Z_BUF_ERROR was due to
- out() returning non-zero. (in() will always be called before out(), so
- strm->next_in is assured to be defined if out() returns non-zero.) Note
- that inflateBack() cannot return Z_OK.
-*/
-
-ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm));
-/*
- All memory allocated by inflateBackInit() is freed.
-
- inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream
- state was inconsistent.
-*/
-
-ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
-/* Return flags indicating compile-time options.
-
- Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other:
- 1.0: size of uInt
- 3.2: size of uLong
- 5.4: size of voidpf (pointer)
- 7.6: size of z_off_t
-
- Compiler, assembler, and debug options:
- 8: DEBUG
- 9: ASMV or ASMINF -- use ASM code
- 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention
- 11: 0 (reserved)
-
- One-time table building (smaller code, but not thread-safe if true):
- 12: BUILDFIXED -- build static block decoding tables when needed
- 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed
- 14,15: 0 (reserved)
-
- Library content (indicates missing functionality):
- 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking
- deflate code when not needed)
- 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect
- and decode gzip streams (to avoid linking crc code)
- 18-19: 0 (reserved)
-
- Operation variations (changes in library functionality):
- 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate
- 21: FASTEST -- deflate algorithm with only one, lowest compression level
- 22,23: 0 (reserved)
-
- The sprintf variant used by gzprintf (zero is best):
- 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format
- 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure!
- 26: 0 = returns value, 1 = void -- 1 means inferred string length returned
-
- Remainder:
- 27-31: 0 (reserved)
- */
-
-
- /* utility functions */
-
-/*
- The following utility functions are implemented on top of the
- basic stream-oriented functions. To simplify the interface, some
- default options are assumed (compression level and memory usage,
- standard memory allocation functions). The source code of these
- utility functions can easily be modified if you need special options.
-*/
-
-ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Compresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be at least the value returned
- by compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
- This function can be used to compress a whole file at once if the
- input file is mmap'ed.
- compress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer.
-*/
-
-ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen,
- int level));
-/*
- Compresses the source buffer into the destination buffer. The level
- parameter has the same meaning as in deflateInit. sourceLen is the byte
- length of the source buffer. Upon entry, destLen is the total size of the
- destination buffer, which must be at least the value returned by
- compressBound(sourceLen). Upon exit, destLen is the actual size of the
- compressed buffer.
-
- compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
- memory, Z_BUF_ERROR if there was not enough room in the output buffer,
- Z_STREAM_ERROR if the level parameter is invalid.
-*/
-
-ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen));
-/*
- compressBound() returns an upper bound on the compressed size after
- compress() or compress2() on sourceLen bytes. It would be used before
- a compress() or compress2() call to allocate the destination buffer.
-*/
-
-ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
- const Bytef *source, uLong sourceLen));
-/*
- Decompresses the source buffer into the destination buffer. sourceLen is
- the byte length of the source buffer. Upon entry, destLen is the total
- size of the destination buffer, which must be large enough to hold the
- entire uncompressed data. (The size of the uncompressed data must have
- been saved previously by the compressor and transmitted to the decompressor
- by some mechanism outside the scope of this compression library.)
- Upon exit, destLen is the actual size of the compressed buffer.
- This function can be used to decompress a whole file at once if the
- input file is mmap'ed.
-
- uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
- enough memory, Z_BUF_ERROR if there was not enough room in the output
- buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
-*/
-
-
-typedef voidp gzFile;
-
-ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
-/*
- Opens a gzip (.gz) file for reading or writing. The mode parameter
- is as in fopen ("rb" or "wb") but can also include a compression level
- ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for
- Huffman only compression as in "wb1h", or 'R' for run-length encoding
- as in "wb1R". (See the description of deflateInit2 for more information
- about the strategy parameter.)
-
- gzopen can be used to read a file which is not in gzip format; in this
- case gzread will directly read from the file without decompression.
-
- gzopen returns NULL if the file could not be opened or if there was
- insufficient memory to allocate the (de)compression state; errno
- can be checked to distinguish the two cases (if errno is zero, the
- zlib error is Z_MEM_ERROR). */
-
-ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
-/*
- gzdopen() associates a gzFile with the file descriptor fd. File
- descriptors are obtained from calls like open, dup, creat, pipe or
- fileno (in the file has been previously opened with fopen).
- The mode parameter is as in gzopen.
- The next call of gzclose on the returned gzFile will also close the
- file descriptor fd, just like fclose(fdopen(fd), mode) closes the file
- descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode).
- gzdopen returns NULL if there was insufficient memory to allocate
- the (de)compression state.
-*/
-
-ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
-/*
- Dynamically update the compression level or strategy. See the description
- of deflateInit2 for the meaning of these parameters.
- gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not
- opened for writing.
-*/
-
-ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
-/*
- Reads the given number of uncompressed bytes from the compressed file.
- If the input file was not in gzip format, gzread copies the given number
- of bytes into the buffer.
- gzread returns the number of uncompressed bytes actually read (0 for
- end of file, -1 for error). */
-
-ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
- voidpc buf, unsigned len));
-/*
- Writes the given number of uncompressed bytes into the compressed file.
- gzwrite returns the number of uncompressed bytes actually written
- (0 in case of error).
-*/
-
-ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
-/*
- Converts, formats, and writes the args to the compressed file under
- control of the format string, as in fprintf. gzprintf returns the number of
- uncompressed bytes actually written (0 in case of error). The number of
- uncompressed bytes written is limited to 4095. The caller should assure that
- this limit is not exceeded. If it is exceeded, then gzprintf() will return
- return an error (0) with nothing written. In this case, there may also be a
- buffer overflow with unpredictable consequences, which is possible only if
- zlib was compiled with the insecure functions sprintf() or vsprintf()
- because the secure snprintf() or vsnprintf() functions were not available.
-*/
-
-ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s));
-/*
- Writes the given null-terminated string to the compressed file, excluding
- the terminating null character.
- gzputs returns the number of characters written, or -1 in case of error.
-*/
-
-ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len));
-/*
- Reads bytes from the compressed file until len-1 characters are read, or
- a newline character is read and transferred to buf, or an end-of-file
- condition is encountered. The string is then terminated with a null
- character.
- gzgets returns buf, or Z_NULL in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
-/*
- Writes c, converted to an unsigned char, into the compressed file.
- gzputc returns the value that was written, or -1 in case of error.
-*/
-
-ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
-/*
- Reads one byte from the compressed file. gzgetc returns this byte
- or -1 in case of end of file or error.
-*/
-
-ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
-/*
- Push one character back onto the stream to be read again later.
- Only one character of push-back is allowed. gzungetc() returns the
- character pushed, or -1 on failure. gzungetc() will fail if a
- character has been pushed but not read yet, or if c is -1. The pushed
- character will be discarded if the stream is repositioned with gzseek()
- or gzrewind().
-*/
-
-ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush));
-/*
- Flushes all pending output into the compressed file. The parameter
- flush is as in the deflate() function. The return value is the zlib
- error number (see function gzerror below). gzflush returns Z_OK if
- the flush parameter is Z_FINISH and all output could be flushed.
- gzflush should be called only when strictly necessary because it can
- degrade compression.
-*/
-
-ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file,
- z_off_t offset, int whence));
-/*
- Sets the starting position for the next gzread or gzwrite on the
- given compressed file. The offset represents a number of bytes in the
- uncompressed data stream. The whence parameter is defined as in lseek(2);
- the value SEEK_END is not supported.
- If the file is opened for reading, this function is emulated but can be
- extremely slow. If the file is opened for writing, only forward seeks are
- supported; gzseek then compresses a sequence of zeroes up to the new
- starting position.
-
- gzseek returns the resulting offset location as measured in bytes from
- the beginning of the uncompressed stream, or -1 in case of error, in
- particular if the file is opened for writing and the new starting position
- would be before the current position.
-*/
-
-ZEXTERN int ZEXPORT gzrewind OF((gzFile file));
-/*
- Rewinds the given file. This function is supported only for reading.
-
- gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET)
-*/
-
-ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file));
-/*
- Returns the starting position for the next gzread or gzwrite on the
- given compressed file. This position represents a number of bytes in the
- uncompressed data stream.
-
- gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR)
-*/
-
-ZEXTERN int ZEXPORT gzeof OF((gzFile file));
-/*
- Returns 1 when EOF has previously been detected reading the given
- input stream, otherwise zero.
-*/
-
-ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
-/*
- Returns 1 if file is being read directly without decompression, otherwise
- zero.
-*/
-
-ZEXTERN int ZEXPORT gzclose OF((gzFile file));
-/*
- Flushes all pending output if necessary, closes the compressed file
- and deallocates all the (de)compression state. The return value is the zlib
- error number (see function gzerror below).
-*/
-
-ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum));
-/*
- Returns the error message for the last error which occurred on the
- given compressed file. errnum is set to zlib error number. If an
- error occurred in the file system and not in the compression library,
- errnum is set to Z_ERRNO and the application may consult errno
- to get the exact error code.
-*/
-
-ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
-/*
- Clears the error and end-of-file flags for file. This is analogous to the
- clearerr() function in stdio. This is useful for continuing to read a gzip
- file that is being written concurrently.
-*/
-
- /* checksum functions */
-
-/*
- These functions are not related to compression but are exported
- anyway because they might be useful in applications using the
- compression library.
-*/
-
-ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len));
-/*
- Update a running Adler-32 checksum with the bytes buf[0..len-1] and
- return the updated checksum. If buf is NULL, this function returns
- the required initial value for the checksum.
- An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
- much faster. Usage example:
-
- uLong adler = adler32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- adler = adler32(adler, buffer, length);
- }
- if (adler != original_adler) error();
-*/
-
-ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
- z_off_t len2));
-/*
- Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
- and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
- each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
- seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
-*/
-
-ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
-/*
- Update a running CRC-32 with the bytes buf[0..len-1] and return the
- updated CRC-32. If buf is NULL, this function returns the required initial
- value for the for the crc. Pre- and post-conditioning (one's complement) is
- performed within this function so it shouldn't be done by the application.
- Usage example:
-
- uLong crc = crc32(0L, Z_NULL, 0);
-
- while (read_buffer(buffer, length) != EOF) {
- crc = crc32(crc, buffer, length);
- }
- if (crc != original_crc) error();
-*/
-
-ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2));
-
-/*
- Combine two CRC-32 check values into one. For two sequences of bytes,
- seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
- calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
- check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
- len2.
-*/
-
-
- /* various hacks, don't look :) */
-
-/* deflateInit and inflateInit are macros to allow checking the zlib version
- * and the compiler's view of z_stream:
- */
-ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method,
- int windowBits, int memLevel,
- int strategy, const char *version,
- int stream_size));
-ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits,
- const char *version, int stream_size));
-ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
- unsigned char FAR *window,
- const char *version,
- int stream_size));
-#define deflateInit(strm, level) \
- deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit(strm) \
- inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
-#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
- deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
- (strategy), ZLIB_VERSION, sizeof(z_stream))
-#define inflateInit2(strm, windowBits) \
- inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
-#define inflateBackInit(strm, windowBits, window) \
- inflateBackInit_((strm), (windowBits), (window), \
- ZLIB_VERSION, sizeof(z_stream))
-
-
-#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
- struct internal_state {int dummy;}; /* hack for buggy compilers */
-#endif
-
-ZEXTERN const char * ZEXPORT zError OF((int));
-ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp z));
-ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZLIB_H */
diff --git a/navit/support/zlib/zlib_init.c b/navit/support/zlib/zlib_init.c
deleted file mode 100644
index 32be387da..000000000
--- a/navit/support/zlib/zlib_init.c
+++ /dev/null
@@ -1,6 +0,0 @@
-#include "plugin.h"
-
-void
-plugin_init(void)
-{
-}
diff --git a/navit/support/zlib/zutil.c b/navit/support/zlib/zutil.c
deleted file mode 100644
index d55f5948a..000000000
--- a/navit/support/zlib/zutil.c
+++ /dev/null
@@ -1,318 +0,0 @@
-/* zutil.c -- target dependent utility functions for the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* @(#) $Id$ */
-
-#include "zutil.h"
-
-#ifndef NO_DUMMY_DECL
-struct internal_state {int dummy;}; /* for buggy compilers */
-#endif
-
-const char * const z_errmsg[10] = {
-"need dictionary", /* Z_NEED_DICT 2 */
-"stream end", /* Z_STREAM_END 1 */
-"", /* Z_OK 0 */
-"file error", /* Z_ERRNO (-1) */
-"stream error", /* Z_STREAM_ERROR (-2) */
-"data error", /* Z_DATA_ERROR (-3) */
-"insufficient memory", /* Z_MEM_ERROR (-4) */
-"buffer error", /* Z_BUF_ERROR (-5) */
-"incompatible version",/* Z_VERSION_ERROR (-6) */
-""};
-
-
-const char * ZEXPORT zlibVersion()
-{
- return ZLIB_VERSION;
-}
-
-uLong ZEXPORT zlibCompileFlags()
-{
- uLong flags;
-
- flags = 0;
- switch (sizeof(uInt)) {
- case 2: break;
- case 4: flags += 1; break;
- case 8: flags += 2; break;
- default: flags += 3;
- }
- switch (sizeof(uLong)) {
- case 2: break;
- case 4: flags += 1 << 2; break;
- case 8: flags += 2 << 2; break;
- default: flags += 3 << 2;
- }
- switch (sizeof(voidpf)) {
- case 2: break;
- case 4: flags += 1 << 4; break;
- case 8: flags += 2 << 4; break;
- default: flags += 3 << 4;
- }
- switch (sizeof(z_off_t)) {
- case 2: break;
- case 4: flags += 1 << 6; break;
- case 8: flags += 2 << 6; break;
- default: flags += 3 << 6;
- }
-#ifdef DEBUG
- flags += 1 << 8;
-#endif
-#if defined(ASMV) || defined(ASMINF)
- flags += 1 << 9;
-#endif
-#ifdef ZLIB_WINAPI
- flags += 1 << 10;
-#endif
-#ifdef BUILDFIXED
- flags += 1 << 12;
-#endif
-#ifdef DYNAMIC_CRC_TABLE
- flags += 1 << 13;
-#endif
-#ifdef NO_GZCOMPRESS
- flags += 1L << 16;
-#endif
-#ifdef NO_GZIP
- flags += 1L << 17;
-#endif
-#ifdef PKZIP_BUG_WORKAROUND
- flags += 1L << 20;
-#endif
-#ifdef FASTEST
- flags += 1L << 21;
-#endif
-#ifdef STDC
-# ifdef NO_vsnprintf
- flags += 1L << 25;
-# ifdef HAS_vsprintf_void
- flags += 1L << 26;
-# endif
-# else
-# ifdef HAS_vsnprintf_void
- flags += 1L << 26;
-# endif
-# endif
-#else
- flags += 1L << 24;
-# ifdef NO_snprintf
- flags += 1L << 25;
-# ifdef HAS_sprintf_void
- flags += 1L << 26;
-# endif
-# else
-# ifdef HAS_snprintf_void
- flags += 1L << 26;
-# endif
-# endif
-#endif
- return flags;
-}
-
-#ifdef DEBUG
-
-# ifndef verbose
-# define verbose 0
-# endif
-int z_verbose = verbose;
-
-void z_error (m)
- char *m;
-{
- fprintf(stderr, "%s\n", m);
- exit(1);
-}
-#endif
-
-/* exported to allow conversion of error code to string for compress() and
- * uncompress()
- */
-const char * ZEXPORT zError(err)
- int err;
-{
- return ERR_MSG(err);
-}
-
-#if defined(_WIN32_WCE)
- /* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno. We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used.
- */
- int errno = 0;
-#endif
-
-#ifndef HAVE_MEMCPY
-
-void zmemcpy(dest, source, len)
- Bytef* dest;
- const Bytef* source;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = *source++; /* ??? to be unrolled */
- } while (--len != 0);
-}
-
-int zmemcmp(s1, s2, len)
- const Bytef* s1;
- const Bytef* s2;
- uInt len;
-{
- uInt j;
-
- for (j = 0; j < len; j++) {
- if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1;
- }
- return 0;
-}
-
-void zmemzero(dest, len)
- Bytef* dest;
- uInt len;
-{
- if (len == 0) return;
- do {
- *dest++ = 0; /* ??? to be unrolled */
- } while (--len != 0);
-}
-#endif
-
-
-#ifdef SYS16BIT
-
-#ifdef __TURBOC__
-/* Turbo C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-/* Turbo C malloc() does not allow dynamic allocation of 64K bytes
- * and farmalloc(64K) returns a pointer with an offset of 8, so we
- * must fix the pointer. Warning: the pointer must be put back to its
- * original form in order to free it, use zcfree().
- */
-
-#define MAX_PTR 10
-/* 10*64K = 640K */
-
-local int next_ptr = 0;
-
-typedef struct ptr_table_s {
- voidpf org_ptr;
- voidpf new_ptr;
-} ptr_table;
-
-local ptr_table table[MAX_PTR];
-/* This table is used to remember the original form of pointers
- * to large buffers (64K). Such pointers are normalized with a zero offset.
- * Since MSDOS is not a preemptive multitasking OS, this table is not
- * protected from concurrent access. This hack doesn't work anyway on
- * a protected system like OS/2. Use Microsoft C instead.
- */
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- voidpf buf = opaque; /* just to make some compilers happy */
- ulg bsize = (ulg)items*size;
-
- /* If we allocate less than 65520 bytes, we assume that farmalloc
- * will return a usable pointer which doesn't have to be normalized.
- */
- if (bsize < 65520L) {
- buf = farmalloc(bsize);
- if (*(ush*)&buf != 0) return buf;
- } else {
- buf = farmalloc(bsize + 16L);
- }
- if (buf == NULL || next_ptr >= MAX_PTR) return NULL;
- table[next_ptr].org_ptr = buf;
-
- /* Normalize the pointer to seg:0 */
- *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4;
- *(ush*)&buf = 0;
- table[next_ptr++].new_ptr = buf;
- return buf;
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- int n;
- if (*(ush*)&ptr != 0) { /* object < 64K */
- farfree(ptr);
- return;
- }
- /* Find the original pointer */
- for (n = 0; n < next_ptr; n++) {
- if (ptr != table[n].new_ptr) continue;
-
- farfree(table[n].org_ptr);
- while (++n < next_ptr) {
- table[n-1] = table[n];
- }
- next_ptr--;
- return;
- }
- ptr = opaque; /* just to make some compilers happy */
- Assert(0, "zcfree: ptr not found");
-}
-
-#endif /* __TURBOC__ */
-
-
-#ifdef M_I86
-/* Microsoft C in 16-bit mode */
-
-# define MY_ZCALLOC
-
-#if (!defined(_MSC_VER) || (_MSC_VER <= 600))
-# define _halloc halloc
-# define _hfree hfree
-#endif
-
-voidpf zcalloc (voidpf opaque, unsigned items, unsigned size)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- return _halloc((long)items, size);
-}
-
-void zcfree (voidpf opaque, voidpf ptr)
-{
- if (opaque) opaque = 0; /* to make compiler happy */
- _hfree(ptr);
-}
-
-#endif /* M_I86 */
-
-#endif /* SYS16BIT */
-
-
-#ifndef MY_ZCALLOC /* Any system without a special alloc function */
-
-#ifndef STDC
-extern voidp malloc OF((uInt size));
-extern voidp calloc OF((uInt items, uInt size));
-extern void free OF((voidpf ptr));
-#endif
-
-voidpf zcalloc (opaque, items, size)
- voidpf opaque;
- unsigned items;
- unsigned size;
-{
- if (opaque) items += size - size; /* make compiler happy */
- return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) :
- (voidpf)calloc(items, size);
-}
-
-void zcfree (opaque, ptr)
- voidpf opaque;
- voidpf ptr;
-{
- free(ptr);
- if (opaque) return; /* make compiler happy */
-}
-
-#endif /* MY_ZCALLOC */
diff --git a/navit/support/zlib/zutil.h b/navit/support/zlib/zutil.h
deleted file mode 100644
index 6cca50b99..000000000
--- a/navit/support/zlib/zutil.h
+++ /dev/null
@@ -1,269 +0,0 @@
-/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2005 Jean-loup Gailly.
- * For conditions of distribution and use, see copyright notice in zlib.h
- */
-
-/* WARNING: this file should *not* be used by applications. It is
- part of the implementation of the compression library and is
- subject to change. Applications should only use zlib.h.
- */
-
-/* @(#) $Id$ */
-
-#ifndef ZUTIL_H
-#define ZUTIL_H
-
-#define ZLIB_INTERNAL
-#include "zlib.h"
-
-#ifdef STDC
-# ifndef _WIN32_WCE
-# include <stddef.h>
-# endif
-# include <string.h>
-# include <stdlib.h>
-#endif
-#ifdef NO_ERRNO_H
-# ifdef _WIN32_WCE
- /* The Microsoft C Run-Time Library for Windows CE doesn't have
- * errno. We define it as a global variable to simplify porting.
- * Its value is always 0 and should not be used. We rename it to
- * avoid conflict with other libraries that use the same workaround.
- */
-# define errno z_errno
-# endif
- extern int errno;
-#else
-# ifndef _WIN32_WCE
-# include <errno.h>
-# endif
-#endif
-
-#ifndef local
-# define local static
-#endif
-/* compile with -Dlocal if your debugger can't find static symbols */
-
-typedef unsigned char uch;
-typedef uch FAR uchf;
-typedef unsigned short ush;
-typedef ush FAR ushf;
-typedef unsigned long ulg;
-
-extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
-/* (size given to avoid silly warnings with Visual C++) */
-
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
-
-#define ERR_RETURN(strm,err) \
- return (strm->msg = (char*)ERR_MSG(err), (err))
-/* To be used only when the state is known to be valid */
-
- /* common constants */
-
-#ifndef DEF_WBITS
-# define DEF_WBITS MAX_WBITS
-#endif
-/* default windowBits for decompression. MAX_WBITS is for compression only */
-
-#if MAX_MEM_LEVEL >= 8
-# define DEF_MEM_LEVEL 8
-#else
-# define DEF_MEM_LEVEL MAX_MEM_LEVEL
-#endif
-/* default memLevel */
-
-#define STORED_BLOCK 0
-#define STATIC_TREES 1
-#define DYN_TREES 2
-/* The three kinds of block type */
-
-#define MIN_MATCH 3
-#define MAX_MATCH 258
-/* The minimum and maximum match lengths */
-
-#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
-
- /* target dependencies */
-
-#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
-# define OS_CODE 0x00
-# if defined(__TURBOC__) || defined(__BORLANDC__)
-# if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
- /* Allow compilation with ANSI keywords only enabled */
- void _Cdecl farfree( void *block );
- void *_Cdecl farmalloc( unsigned long nbytes );
-# else
-# include <alloc.h>
-# endif
-# else /* MSC or DJGPP */
-# include <malloc.h>
-# endif
-#endif
-
-#ifdef AMIGA
-# define OS_CODE 0x01
-#endif
-
-#if defined(VAXC) || defined(VMS)
-# define OS_CODE 0x02
-# define F_OPEN(name, mode) \
- fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512")
-#endif
-
-#if defined(ATARI) || defined(atarist)
-# define OS_CODE 0x05
-#endif
-
-#ifdef OS2
-# define OS_CODE 0x06
-# ifdef M_I86
- #include <malloc.h>
-# endif
-#endif
-
-#if defined(MACOS) || defined(TARGET_OS_MAC)
-# define OS_CODE 0x07
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
-# endif
-#endif
-
-#ifdef TOPS20
-# define OS_CODE 0x0a
-#endif
-
-#ifdef WIN32
-# ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */
-# define OS_CODE 0x0b
-# endif
-#endif
-
-#ifdef __50SERIES /* Prime/PRIMOS */
-# define OS_CODE 0x0f
-#endif
-
-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600)) || defined(__MINGW32__)
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# ifndef _PTRDIFF_T_DEFINED
- typedef int ptrdiff_t;
-# define _PTRDIFF_T_DEFINED
-# endif
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
-#endif
-
- /* common defaults */
-
-#ifndef OS_CODE
-# define OS_CODE 0x03 /* assume Unix */
-#endif
-
-#ifndef F_OPEN
-# define F_OPEN(name, mode) fopen((name), (mode))
-#endif
-
- /* functions */
-
-#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-#if defined(__CYGWIN__)
-# ifndef HAVE_VSNPRINTF
-# define HAVE_VSNPRINTF
-# endif
-#endif
-#ifndef HAVE_VSNPRINTF
-# ifdef MSDOS
- /* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
- but for now we just assume it doesn't. */
-# define NO_vsnprintf
-# endif
-# ifdef __TURBOC__
-# define NO_vsnprintf
-# endif
-# ifdef WIN32
- /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
-# if !defined(vsnprintf) && !defined(NO_vsnprintf)
-# define vsnprintf _vsnprintf
-# endif
-# endif
-# ifdef __SASC
-# define NO_vsnprintf
-# endif
-#endif
-#ifdef VMS
-# define NO_vsnprintf
-#endif
-
-#if defined(pyr)
-# define NO_MEMCPY
-#endif
-#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
- /* Use our own functions for small and medium model with MSC <= 5.0.
- * You may have to use the same strategy for Borland C (untested).
- * The __SC__ check is for Symantec.
- */
-# define NO_MEMCPY
-#endif
-#if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY)
-# define HAVE_MEMCPY
-#endif
-#ifdef HAVE_MEMCPY
-# ifdef SMALL_MEDIUM /* MSDOS small or medium model */
-# define zmemcpy _fmemcpy
-# define zmemcmp _fmemcmp
-# define zmemzero(dest, len) _fmemset(dest, 0, len)
-# else
-# define zmemcpy memcpy
-# define zmemcmp memcmp
-# define zmemzero(dest, len) memset(dest, 0, len)
-# endif
-#else
- extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len));
- extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len));
- extern void zmemzero OF((Bytef* dest, uInt len));
-#endif
-
-/* Diagnostic functions */
-#ifdef DEBUG
-# include <stdio.h>
- extern int z_verbose;
- extern void z_error OF((char *m));
-# define Assert(cond,msg) {if(!(cond)) z_error(msg);}
-# define Trace(x) {if (z_verbose>=0) fprintf x ;}
-# define Tracev(x) {if (z_verbose>0) fprintf x ;}
-# define Tracevv(x) {if (z_verbose>1) fprintf x ;}
-# define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;}
-# define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;}
-#else
-# define Assert(cond,msg)
-# define Trace(x)
-# define Tracev(x)
-# define Tracevv(x)
-# define Tracec(c,x)
-# define Tracecv(c,x)
-#endif
-
-
-voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size));
-void zcfree OF((voidpf opaque, voidpf ptr));
-
-#define ZALLOC(strm, items, size) \
- (*((strm)->zalloc))((strm)->opaque, (items), (size))
-#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
-#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
-
-#endif /* ZUTIL_H */