From 0c5c99b56671fb2c67cdd3f2e00dcf9ab2d9f767 Mon Sep 17 00:00:00 2001 From: Lionel Debroux Date: Wed, 4 Sep 2019 23:33:12 +0200 Subject: [PATCH] libtifiles: add two variable types which are normally for internal use only; tifileutil: add the initial version of an in-tree libtifiles front-end (issue #31), so that it can be used by the libticalcs build; libticalcs: use tifileutil instead of tf2hex + tipack; require a C++11 compiler and autoconf-archive; remove tf2hex. Signed-off-by: Lionel Debroux --- .travis.yml | 4 +- .travis/script.sh | 7 + CMakeLists.txt | 1 + libticalcs/trunk/configure.ac | 21 +- libticalcs/trunk/src/Makefile.am | 57 +- libticalcs/trunk/src/rom73.h | 6 +- libticalcs/trunk/src/rom82.h | 6 +- libticalcs/trunk/src/rom83.h | 6 +- libticalcs/trunk/src/rom834pceu.h | 6 +- libticalcs/trunk/src/rom83p.h | 6 +- libticalcs/trunk/src/rom84p.h | 6 +- libticalcs/trunk/src/rom84pc.h | 6 +- libticalcs/trunk/src/rom84pcu.h | 6 +- libticalcs/trunk/src/rom85.h | 6 +- libticalcs/trunk/src/rom86.h | 6 +- libticalcs/trunk/src/rom89.h | 2 +- libticalcs/trunk/src/rom89t.h | 2 +- libticalcs/trunk/src/rom92f2.h | 2 +- .../trunk/src/romdump_834pce_usb/Makefile.am | 2 +- .../trunk/src/romdump_84p_usb/Makefile.am | 4 +- libticalcs/trunk/src/romdump_8x/Makefile.am | 14 +- libticalcs/trunk/src/tf2hex/Makefile.am | 7 - libticalcs/trunk/src/tf2hex/net.bat | 17 - libticalcs/trunk/src/tf2hex/tf2hex.cc | 75 -- libticalcs/trunk/src/tf2hex/tf2hex.dsp | 101 --- libticalcs/trunk/src/tf2hex/tf2hex.dsw | 29 - libtifiles/trunk/po/de.po | 4 + libtifiles/trunk/po/fr.po | 4 + libtifiles/trunk/po/libtifiles2.pot | 4 + libtifiles/trunk/src/types83p.cc | 4 +- libtifiles/trunk/src/types83p.h | 2 + libtifiles/trunk/src/types84p.h | 2 + tifileutil/AUTHORS | 22 + tifileutil/COPYING | 339 ++++++++ tifileutil/ChangeLog | 0 tifileutil/Makefile.am | 18 + tifileutil/NEWS | 0 tifileutil/README | 0 tifileutil/RELEASE | 0 tifileutil/build/Makefile.am | 2 + tifileutil/build/mingw/Makefile.am | 15 + tifileutil/build/mingw/tifileutil.rc | 43 + tifileutil/configure.ac | 196 +++++ tifileutil/man/Makefile.am | 20 + tifileutil/man/Manpage.txt | 104 +++ tifileutil/man/cleaner.c | 113 +++ tifileutil/man/tifileutil.1 | 67 ++ tifileutil/po/LINGUAS | 2 + tifileutil/po/Makefile.in.in | 222 +++++ tifileutil/po/POTFILES.in | 1 + tifileutil/po/fr.po | 31 + tifileutil/src/Makefile.am | 23 + tifileutil/src/gettext.h | 88 ++ tifileutil/src/logging.h | 40 + tifileutil/src/main.cc | 761 ++++++++++++++++++ tifileutil/trunk | 1 + 56 files changed, 2216 insertions(+), 317 deletions(-) delete mode 100644 libticalcs/trunk/src/tf2hex/Makefile.am delete mode 100644 libticalcs/trunk/src/tf2hex/net.bat delete mode 100644 libticalcs/trunk/src/tf2hex/tf2hex.cc delete mode 100644 libticalcs/trunk/src/tf2hex/tf2hex.dsp delete mode 100644 libticalcs/trunk/src/tf2hex/tf2hex.dsw create mode 100644 tifileutil/AUTHORS create mode 100644 tifileutil/COPYING create mode 100644 tifileutil/ChangeLog create mode 100644 tifileutil/Makefile.am create mode 100644 tifileutil/NEWS create mode 100644 tifileutil/README create mode 100644 tifileutil/RELEASE create mode 100644 tifileutil/build/Makefile.am create mode 100644 tifileutil/build/mingw/Makefile.am create mode 100644 tifileutil/build/mingw/tifileutil.rc create mode 100644 tifileutil/configure.ac create mode 100644 tifileutil/man/Makefile.am create mode 100644 tifileutil/man/Manpage.txt create mode 100644 tifileutil/man/cleaner.c create mode 100644 tifileutil/man/tifileutil.1 create mode 100644 tifileutil/po/LINGUAS create mode 100644 tifileutil/po/Makefile.in.in create mode 100644 tifileutil/po/POTFILES.in create mode 100644 tifileutil/po/fr.po create mode 100644 tifileutil/src/Makefile.am create mode 100644 tifileutil/src/gettext.h create mode 100644 tifileutil/src/logging.h create mode 100644 tifileutil/src/main.cc create mode 120000 tifileutil/trunk diff --git a/.travis.yml b/.travis.yml index 7fcbb9221..64f7dbb7d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ _linuxpackages: &_linuxpackages - zlib1g-dev - libusb-1.0-0-dev - gettext + - intltool - bison - flex - groff @@ -22,6 +23,7 @@ _linuxpackages: &_linuxpackages - ninja-build - liblz4-dev - liblzma-dev + - autoconf-archive matrix: include: @@ -58,7 +60,7 @@ matrix: env: PREBUILDER=cmake BUILDER=ninja install: - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake ninja gettext libarchive libtool glib libusb bison flex texinfo libiconv intltool ; brew link --force gettext libarchive ; export PKG_CONFIG_PATH="/usr/local/opt/libarchive/lib/pkgconfig"; fi + - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then HOMEBREW_NO_AUTO_UPDATE=1 brew install cmake ninja gettext libarchive libtool glib libusb bison flex texinfo libiconv intltool autoconf-archive ; brew link --force gettext libarchive ; export PKG_CONFIG_PATH="/usr/local/opt/libarchive/lib/pkgconfig"; fi - which gcc ; gcc --version - which cmake ; cmake --version - which ninja ; ninja --version diff --git a/.travis/script.sh b/.travis/script.sh index 54ae7bbf9..250e13c1d 100755 --- a/.travis/script.sh +++ b/.travis/script.sh @@ -16,6 +16,8 @@ if [ "$PREBUILDER" == "autotools" ]; then mkdir m4; autoreconf -ivf & cd ../../libtifiles/trunk mkdir m4; autoreconf -ivf & + cd ../../tifileutil/trunk + mkdir m4; autoreconf -ivf & cd ../../libticables/trunk mkdir m4; autoreconf -ivf & cd ../../libticalcs/trunk @@ -30,6 +32,11 @@ if [ "$PREBUILDER" == "autotools" ]; then ./configure --prefix=${prefixpath} make -j${NPROC} check make -j${NPROC} install + cd ../../tifileutil/trunk + cd po; make tifileutil.pot-update; make update-po; cd .. + ./configure --prefix=${prefixpath} + make -j${NPROC} check + make -j${NPROC} install cd ../../libticables/trunk cd po; make libticables2.pot-update; make update-po; cd .. ./configure --prefix=${prefixpath} --enable-logging --enable-libusb10 diff --git a/CMakeLists.txt b/CMakeLists.txt index 3cd3d9bdb..3705600c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,7 @@ project(tilibs C CXX) # - probably doesn't work very well with ancient toolchains or on uncommon OSes # # In the future...: +# - TODO: add support to build tifileutil # - TODO: add support to build the ROM dumpers (will end up just launching the external tools...) # - WISH: do not hardcode the (auto-generated...) potfiles_* target names # - WISH: better expose each lib's generated install target (NTS: look at cmake's components feature?) diff --git a/libticalcs/trunk/configure.ac b/libticalcs/trunk/configure.ac index 3ec257ed3..68319a897 100644 --- a/libticalcs/trunk/configure.ac +++ b/libticalcs/trunk/configure.ac @@ -36,7 +36,6 @@ AC_CONFIG_FILES([ docs/Makefile po/Makefile.in src/Makefile - src/tf2hex/Makefile src/romdump_8x/Makefile src/romdump_84p_usb/Makefile src/romdump_9x/Makefile @@ -204,12 +203,12 @@ AC_ARG_ENABLE([builtin-rom-dumpers], [], [enable_builtin_rom_dumpers=yes]) AC_ARG_VAR([SPASM], [SPASM Z80 assembler]) -AC_ARG_VAR([TIPACK], [Tool for creating TI variable files]) +AC_ARG_VAR([TIFILEUTIL], [Tool for creating TI variable files]) have_spasm=no -have_tipack=no +have_tifileutil=no have_tigcc=no : ${SPASM=spasm} -: ${TIPACK=tipack} +: ${TIFILEUTIL=tifileutil} if test "x$enable_builtin_rom_dumpers" != "xyes" ; then AC_MSG_CHECKING([whether $SPASM works]) @@ -224,13 +223,11 @@ EOF fi AC_MSG_RESULT([$have_spasm]) - if test "x$have_spasm" = "xyes" ; then - AC_MSG_CHECKING([whether $TIPACK works]) - if "$TIPACK" conftest.bin -p -o conftest.8xp >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then - have_tipack=yes - fi - AC_MSG_RESULT([$have_tipack]) + AC_MSG_CHECKING([whether $TIFILEUTIL works]) + if "$TIFILEUTIL" wrap conftest.bin -p -o conftest.8xp >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then + have_tifileutil=yes fi + AC_MSG_RESULT([$have_tifileutil]) AC_MSG_CHECKING([whether tigcc works]) cat >conftest.c < -#include -#include -#include - -#define STEP 8 - -int main(int argc, char **argv) -{ - const char *src_name; - const char *dst_name; - FILE *fi, *fo; - struct stat st; - long length, lenread; - static unsigned char data[65536]; - int i, j; - const char *pat; - - if(argc != 4) - { - fprintf(stderr, "Usage: tf2hex input_file output_file suffix\n"); - return 1; - } - - src_name = argv[1]; - dst_name = argv[2]; - pat = argv[3]; - - // read input file - fi = fopen(src_name, "rb"); - if(fi == NULL) - { - fprintf(stderr, "Unable to open input file.\n"); - return 1; - } - - fstat(fileno(fi), &st); - length = st.st_size; - - lenread = fread(data, sizeof(char), length, fi); - fprintf(stdout, "Read %ld bytes.\n", lenread); - - fclose(fi); - - if (lenread == length) - { - // write output file - fo = fopen(dst_name, "wt"); - if(fo == NULL) - { - fprintf(stderr, "Unable to open output file.\n"); - return 1; - } - - fprintf(fo, "static unsigned char romDump%s[] = {\n", pat); - for(i = 0; i < length; i += STEP) - { - for(j = 0; (j < STEP) && (i+j < length); j++) - { - fprintf(fo, "0x%02x, ", data[i + j]); - } - fprintf(fo, "\n"); - } - fprintf(fo, "};\nstatic unsigned int romDumpSize%s = %ld;\n", pat, length); - - fclose(fo); - } - else - { - fprintf(stderr, "Was unable to read the entire input file.\n"); - return 1; - } - - return 0; -} diff --git a/libticalcs/trunk/src/tf2hex/tf2hex.dsp b/libticalcs/trunk/src/tf2hex/tf2hex.dsp deleted file mode 100644 index 6d662d189..000000000 --- a/libticalcs/trunk/src/tf2hex/tf2hex.dsp +++ /dev/null @@ -1,101 +0,0 @@ -# Microsoft Developer Studio Project File - Name="tf2hex" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=tf2hex - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "tf2hex.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "tf2hex.mak" CFG="tf2hex - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "tf2hex - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "tf2hex - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "tf2hex - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "tf2hex - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD BASE RSC /l 0x40c /d "_DEBUG" -# ADD RSC /l 0x40c /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"tf2hex.exe" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "tf2hex - Win32 Release" -# Name "tf2hex - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\tf2hex.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project diff --git a/libticalcs/trunk/src/tf2hex/tf2hex.dsw b/libticalcs/trunk/src/tf2hex/tf2hex.dsw deleted file mode 100644 index 250de3be3..000000000 --- a/libticalcs/trunk/src/tf2hex/tf2hex.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "tf2hex"=.\tf2hex.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/libtifiles/trunk/po/de.po b/libtifiles/trunk/po/de.po index 697631653..6eed74896 100644 --- a/libtifiles/trunk/po/de.po +++ b/libtifiles/trunk/po/de.po @@ -367,6 +367,10 @@ msgstr "Zoom" msgid "Table Setup" msgstr "Tabellen Einstellungen" +#: src/types83p.cc:55 +msgid "App Obj" +msgstr "" + #: src/types83p.cc:56 src/typesoldz80.cc:66 msgid "App Var" msgstr "Anwendungsvariablen" diff --git a/libtifiles/trunk/po/fr.po b/libtifiles/trunk/po/fr.po index bc5f46ccc..5ed9e50a9 100644 --- a/libtifiles/trunk/po/fr.po +++ b/libtifiles/trunk/po/fr.po @@ -367,6 +367,10 @@ msgstr "Zoom" msgid "Table Setup" msgstr "Config Table" +#: src/types83p.cc:55 +msgid "App Obj" +msgstr "Objet Application" + #: src/types83p.cc:56 src/typesoldz80.cc:66 msgid "App Var" msgstr "Variable Application" diff --git a/libtifiles/trunk/po/libtifiles2.pot b/libtifiles/trunk/po/libtifiles2.pot index 7f69227cc..5aacc61fd 100644 --- a/libtifiles/trunk/po/libtifiles2.pot +++ b/libtifiles/trunk/po/libtifiles2.pot @@ -359,6 +359,10 @@ msgstr "" msgid "Table Setup" msgstr "" +#: src/types83p.cc:55 +msgid "App Obj" +msgstr "" + #: src/types83p.cc:56 src/typesoldz80.cc:66 msgid "App Var" msgstr "" diff --git a/libtifiles/trunk/src/types83p.cc b/libtifiles/trunk/src/types83p.cc index 56c58346b..27d0aba51 100644 --- a/libtifiles/trunk/src/types83p.cc +++ b/libtifiles/trunk/src/types83p.cc @@ -52,9 +52,9 @@ const TI83p_DATA TI83p_CONST[TI83p_MAXTYPES + 1] = {"TABLE", "8Xt", "8Xt", "8Xt", "8Xt", "8Xt", "8Xt", "Table Setup", N_("Table Setup")}, {"", "8X?", "8X?", "8X?", "8X?", "8X?", "8X?", "Unknown", N_("Unknown")}, {"BKUP", "8Xb", "8Xb", "8Xb", "8Xb", "8Xb", "8Xb", "Backup", N_("Backup")}, - {"", "8X?", "8X?", "8X?", "8X?", "8X?", "8X?", "Unknown", N_("Unknown")}, // 20, 0x14 + {"APPOBJ", "8Xv", "8Xv", "8Xv", "8Xv", "8Xv", "8Xv", "Unknown", N_("App Obj")}, /* AppObj */ // 20, 0x14 {"APPV", "8Xv", "8Xv", "8Xv", "8Xv", "8Xv", "8Xv", "App Var", N_("App Var")}, - {"TPRGM", "8Xp", "8Xp", "8Xp", "8Xp", "8Xp", "8Xp", "Program", N_("Program")}, /* TempProg */ + {"TPRGM", "8Xp", "8Xp", "8Xp", "8Xp", "8Xp", "8Xp", "Program", N_("Program")}, /* TempProgObj */ {"GRP", "8Xo", "8Xo", "8Xo", "8Xo", "8Xo", "8Xo", "Group Var", N_("Group Var")}, // Also 8Xg {"REAL", "8Xn", "8Xn", "8Xn", "8Xn", "8Xn", "8Xn", "Real", N_("Real")}, /* Fraction */ {"DIR", "8X?", "8X?", "8X?", "8X?", "8X?", "8X?", "Unknown", N_("Unknown")}, // 25, 0x19 diff --git a/libtifiles/trunk/src/types83p.h b/libtifiles/trunk/src/types83p.h index 0d2c0dcbc..c587f0652 100644 --- a/libtifiles/trunk/src/types83p.h +++ b/libtifiles/trunk/src/types83p.h @@ -44,8 +44,10 @@ #define TI83p_TAB 0x11 //deprecated #define TI83p_TABLE 0x11 #define TI83p_BKUP 0x13 +#define TI83p_APPOBJ 0x14 #define TI83p_APPVAR 0x15 //deprecated #define TI83p_APPV 0x15 +#define TI83p_TEMPPROGOBJ 0x16 #define TI83p_GRP 0x17 #define TI83p_DIR 0x19 #define TI83p_AMS 0x23 diff --git a/libtifiles/trunk/src/types84p.h b/libtifiles/trunk/src/types84p.h index e7d5315dd..8ced576bf 100644 --- a/libtifiles/trunk/src/types84p.h +++ b/libtifiles/trunk/src/types84p.h @@ -49,8 +49,10 @@ #define TI84p_TAB 0x11 //deprecated #define TI84p_TABLE 0x11 #define TI84p_BKUP 0x13 +#define TI84p_APPOBJ 0x14 #define TI84p_APPVAR 0x15 //deprecated #define TI84p_APPV 0x15 +#define TI84p_TEMPPROGOBJ 0x16 #define TI84p_GROUP 0x17 #define TI83pce_SIMPLEFRAC 0x18 #define TI84p_DIR 0x19 diff --git a/tifileutil/AUTHORS b/tifileutil/AUTHORS new file mode 100644 index 000000000..4765bc044 --- /dev/null +++ b/tifileutil/AUTHORS @@ -0,0 +1,22 @@ +Lionel Debroux: maintainer (2009-): tifileutil +============================================== + +web: http://lpg.ticalc.org/prj_tilp , http://tict.ticalc.org , https://tiplanet.org +mail: lionel_debroux@yahoo.fr + +Benjamin Moody (FloppusMaximus): tipack, etc. +============================================= + +web: http://lpg.ticalc.org/prj_tilem/index.html +mail: benjamin.moody@gmail.com + +Romain Liévin (roms): former maintainer (1999-2009), tf2hex +=========================================================== + +web: http://lpg.ticalc.org/prj_tilp +mail: roms@tilp.info + +Jon Sturm (Jonimus): titools +============================ + +mail: jonimoose@gmail.com diff --git a/tifileutil/COPYING b/tifileutil/COPYING new file mode 100644 index 000000000..d159169d1 --- /dev/null +++ b/tifileutil/COPYING @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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 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., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/tifileutil/ChangeLog b/tifileutil/ChangeLog new file mode 100644 index 000000000..e69de29bb diff --git a/tifileutil/Makefile.am b/tifileutil/Makefile.am new file mode 100644 index 000000000..746895514 --- /dev/null +++ b/tifileutil/Makefile.am @@ -0,0 +1,18 @@ +## Process this file with automake to produce Makefile.in + +ACLOCAL_AMFLAGS=-I m4 + +# subdirectories to scan +SUBDIRS = build po src + +if USE_GROFF + SUBDIRS += man +endif + +dist_pkgdata_DATA = COPYING RELEASE + +DISTCLEANFILES = ... intltool-extract intltool-merge intltool-update po/.intltool-merge-cache + +EXTRA_DIST = README.* TODO + +INTLTOOL_FILES = intltool-extract.in intltool-merge.in intltool-update.in diff --git a/tifileutil/NEWS b/tifileutil/NEWS new file mode 100644 index 000000000..e69de29bb diff --git a/tifileutil/README b/tifileutil/README new file mode 100644 index 000000000..e69de29bb diff --git a/tifileutil/RELEASE b/tifileutil/RELEASE new file mode 100644 index 000000000..e69de29bb diff --git a/tifileutil/build/Makefile.am b/tifileutil/build/Makefile.am new file mode 100644 index 000000000..764db6345 --- /dev/null +++ b/tifileutil/build/Makefile.am @@ -0,0 +1,2 @@ +SUBDIRS = mingw +EXTRA_DIST = mingw diff --git a/tifileutil/build/mingw/Makefile.am b/tifileutil/build/mingw/Makefile.am new file mode 100644 index 000000000..a59b7b1bc --- /dev/null +++ b/tifileutil/build/mingw/Makefile.am @@ -0,0 +1,15 @@ +BASE = tifileutil +RC ?= windres + +EXTRA_DIST = $(BASE).rc + +if OS_WIN32 + noinst_DATA = $(BASE)-rc.o +endif + +if OS_WIN32 +all: $(BASE)-rc.o + +$(BASE)-rc.o : $(BASE).rc + $(RC) $(BASE).rc $@ +endif diff --git a/tifileutil/build/mingw/tifileutil.rc b/tifileutil/build/mingw/tifileutil.rc new file mode 100644 index 000000000..a9473d542 --- /dev/null +++ b/tifileutil/build/mingw/tifileutil.rc @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +#include "winver.h" + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 0,1,0,0 + PRODUCTVERSION 0,1,0,0 + FILEFLAGSMASK VS_FFI_FILEFLAGSMASK +#ifdef _DEBUG + FILEFLAGS (VS_FF_PRERELEASE | VS_FF_DEBUG) +#else + FILEFLAGS (VS_FF_PRERELEASE) +#endif + FILEOS VOS_NT_WINDOWS32 + FILETYPE VFT_APP + FILESUBTYPE VFT2_UNKNOWN +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904b0" + BEGIN + VALUE "Comments", "This program is placed under GPL license. The license can be found on www.gnu.org\0" + VALUE "CompanyName", "Linux Programmer Group\0" + VALUE "FileDescription", "TI calculators file modification utility\0" + VALUE "FileVersion", "0.1.0\0" + VALUE "InternalName", "tifileutil\0" + VALUE "LegalCopyright", "Copyright \xA9 1999-2019, Romain Li\xE9vin, Julien Blache and contributors\0" + VALUE "LegalTrademarks", "The TiLP Team\0" + VALUE "OriginalFilename", "tifileutil.exe\0" + VALUE "PrivateBuild", "\0" + VALUE "ProductName", "TI file software for Linux, Windows Vista/7/8/8.1/10, Mac OS X and FreeBSD.\0" + VALUE "ProductVersion", "0.1.0\0" + VALUE "SpecialBuild", "Windows Vista/7/8/8.1/10 version\0" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x409, 1252 + END +END diff --git a/tifileutil/configure.ac b/tifileutil/configure.ac new file mode 100644 index 000000000..b28da3867 --- /dev/null +++ b/tifileutil/configure.ac @@ -0,0 +1,196 @@ +dnl Process this file with autoconf to produce a configure script. +dnl $Id$ + +# Init. +AC_PREREQ(2.57) +AC_INIT(TIFILEUTIL, 0.1, [tilp-users@lists.sourceforge.net]) + +dnl Release versioning info +VERSION="0.1" +AC_SUBST(VERSION) + +AM_INIT_AUTOMAKE([dist-bzip2]) +AM_MAINTAINER_MODE +AC_CONFIG_MACRO_DIR([m4]) + +AC_PREFIX_DEFAULT(/usr/local) + +# Files to configure. +AC_CONFIG_SRCDIR([src/main.cc]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_FILES([ + Makefile + build/Makefile + build/mingw/Makefile + man/Makefile + src/Makefile +]) + +# Setup libtool. +AC_DISABLE_STATIC +AC_LIBTOOL_WIN32_DLL +LT_INIT + +# Checks for programs. +AC_PROG_CC +AC_PROG_CXX +AM_PROG_CC_C_O +AC_PROG_INSTALL +AC_PROG_MAKE_SET +AC_PROG_LN_S +AC_ISC_POSIX +AC_PROG_AWK +AC_CHECK_PROG(GROFF, groff, yes, no) +AM_CONDITIONAL(USE_GROFF, test "$GROFF" != "no") +AC_CHECK_TOOL(RC, windres, windres) + +# Translation +AC_PROG_INTLTOOL([0.40.0]) + +GETTEXT_PACKAGE=tifileutil +AC_SUBST(GETTEXT_PACKAGE) +AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [tifileutil]) +AM_GLIB_GNU_GETTEXT + +# Checks for libraries. +PKG_CHECK_MODULES(TICONV, ticonv >= 1.1.6) +AC_SUBST(TICONV_CFLAGS) +AC_SUBST(TICONV_LIBS) + +PKG_CHECK_MODULES(TIFILES, tifiles2 >= 1.1.8) +AC_SUBST(TIFILES_CFLAGS) +AC_SUBST(TIFILES_LIBS) + +PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.6.0) +AC_SUBST(GLIB_CFLAGS) +AC_SUBST(GLIB_LIBS) + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([stdlib.h string.h unistd.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_C_RESTRICT +AX_CXX_COMPILE_STDCXX_11(noext, mandatory) +AC_HEADER_STAT +AC_TYPE_UID_T +AC_TYPE_MODE_T +AC_TYPE_OFF_T +AC_STRUCT_TM + +# Checks for library functions. +AC_PROG_GCC_TRADITIONAL +AC_TYPE_SIGNAL +AC_FUNC_STAT +AC_CHECK_FUNCS([memset strchr strdup strrchr localtime_r]) + +# Platform specific tests. +dnl AC_CANONICAL_HOST +case "$host" in + *-*-mingw*) ARCH="-D__WIN32__ -D__MINGW32__ -mwindows" ;; + *-*-cygwin) ARCH="-D__WIN32__ -D__CYGWIN__ -mwindows -mno-cygwin" ;; + *-*-*bsd*) ARCH="-D__BSD__" ;; + *) ARCH="-D__LINUX__" ;; +esac +CFLAGS="$CFLAGS $ARCH" + +# Ensure MSVC-compatible struct packing convention is used when +# compiling for Win32 with gcc. +# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while +# gcc2 uses "-fnative-struct". +case $host_os in +*mingw*|*cygwin*) + if test x$GCC = xyes; then + msnative_struct='' + AC_MSG_CHECKING([how to get MSVC-compatible struct packing]) + if test -z "$ac_cv_prog_CC"; then + our_gcc="$CC" + else + our_gcc="$ac_cv_prog_CC" + fi + case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in + 2.) + if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then + msnative_struct='-fnative-struct' + fi + ;; + *) + if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then + msnative_struct='-mms-bitfields' + fi + ;; + esac + if test x"$msnative_struct" = x ; then + AC_MSG_RESULT([no way]) + AC_MSG_WARN([produced libraries might be incompatible with MSVC-compiled code]) + else + CFLAGS="$CFLAGS $msnative_struct" + AC_MSG_RESULT([${msnative_struct}]) + fi + fi + ;; +esac + +AM_CONDITIONAL(OS_WIN32, test "$msnative_struct") + +# Check for the new -fvisibility=hidden flag introduced in gcc 4.0 +# Allow to reduce shared library size and avoid symbol clash +case $host_os in +*mingw*) + ;; +*) + if test x$GCC = xyes; then + visibility_flag='' + AC_MSG_CHECKING([whether gcc accepts -fvisibility]) + if test -z "$ac_cv_prog_CC"; then + our_gcc="$CC" + else + our_gcc="$ac_cv_prog_CC" + fi + if $our_gcc -v --help 2>/dev/null | grep "fvisibility" >/dev/null; then + visibility_flag='-fvisibility=hidden' + fi + if test x"$visibility_flag" = x ; then + AC_MSG_RESULT([no]) + else + CFLAGS="$CFLAGS $visibility_flag" + AC_MSG_RESULT([${visibility_flag}]) + AC_DEFINE(HAVE_FVISIBILITY, 1, [Use -fvisibility=hidden flag]) + fi + fi + ;; +esac + +# Find a C compiler for the build system (needed for compiling cleaner) +AC_ARG_VAR([CC_FOR_BUILD], [C compiler for programs to be run on the build system]) +AC_ARG_VAR([CFLAGS_FOR_BUILD], [C compiler flags for CC_FOR_BUILD]) +AC_MSG_CHECKING([for the host compiler]) +if test "x$build" == "x$host" ; then + # Not cross-compiling. + CC_FOR_BUILD=$CC + CFLAGS_FOR_BUILD=$CFLAGS + AC_MSG_RESULT([${CC_FOR_BUILD}]) +else + # Try to find the host CC among several choices + AC_CHECK_PROGS(CC_FOR_BUILD, [gcc cc clang c89 c99], [false]) + if test "x$CC_FOR_BUILD" = "xfalse" ; then + AC_MSG_FAILURE([not found.]) + else + AC_MSG_RESULT([${CC_FOR_BUILD}]) + fi +fi + +# some extra flags +CXXFLAGS="$CFLAGS -fno-rtti -fno-exceptions" + +AC_SUBST(CFLAGS) +AC_SUBST(LDFLAGS) +AC_SUBST(CXXFLAGS) + +# Output. +AC_OUTPUT([ +po/Makefile.in +]) + +echo "Now, you can type 'make' and 'make install'." diff --git a/tifileutil/man/Makefile.am b/tifileutil/man/Makefile.am new file mode 100644 index 000000000..3367959dd --- /dev/null +++ b/tifileutil/man/Makefile.am @@ -0,0 +1,20 @@ +man_MANS = tifileutil.1 +pkgdata_DATA = Manpage.txt + +EXTRA_DIST = $(man_MANS) cleaner.c Manpage.txt + +all: dist_win + +view: $(man_MANS) + groff -Tascii -man $(man_MANS) | less + +Manpage.txt: + groff -Tascii -man $(man_MANS) > Manpage + C_INCLUDE_PATH="" LIBRARY_PATH="" $(CC_FOR_BUILD) $(CFLAGS_FOR_BUILD) cleaner.c -o cleaner + ./cleaner Manpage + rm -f Manpage cleaner + +dist_win: $(man_MANS) Manpage.txt + +clean: + rm -f Manpage.txt cleaner diff --git a/tifileutil/man/Manpage.txt b/tifileutil/man/Manpage.txt new file mode 100644 index 000000000..073f8fd46 --- /dev/null +++ b/tifileutil/man/Manpage.txt @@ -0,0 +1,104 @@ +TIFILEUTIL(1) General Commands Manual TIFILEUTIL(1) + + + +NAME + tifileutil - a program for manipulating computer files suitable for TI + graphing calculators + + +SYNOPSIS + tifileutil [-h / --help] [-v / --version] [command] [arguments] + + +DESCRIPTION + The tifileutil program allows you to perform various operations on com- + puter files suitable for the TI-Z80, TI-eZ80 and TI-68k series of + graphing calculators. + + +OPTIONS + tifileutil accepts the following options: + + + -h, --help + Display a list of all command line options and commands. + + + -v, --version + Output the version info. + + +EXAMPLES + Dump a file supposed to be suitable for TI calculators as a C hex array + to an output file: + + + tifileutil dump -f chexarray romdump_9x/romdump.89z -o rom89.h -n rom- + Dump89 -s romDumpSize89 -c 8 -m 64 + + + Create TI file header and footer for a raw binary: + + + tifileutil wrap -n 'ROMDUMP' dump83p.bin -p -o dump83p.8xp + + +COPYRIGHT + Copyright (C) 2006-2010 Benjamin Moody + + Copyright (C) 2010 Jon Sturm + + Copyright (C) 1999-2009 Romain Lievin + + Copyright (C) 2009-2021 Lionel Debroux + + Permission to use, copy, modify, and distribute this software and its + documentation for any purpose and without fee is hereby granted, pro- + vided that the above copyright notice appear in all copies and that + both that copyright notice and this permission notice appear in sup- + porting documentation. + + This program and its source code is distributed under the terms of the + terms of the GNU General Public License as published by the Free Soft- + ware Foundation; either version 2 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 MER- + CHANTABILITY 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. + + +SUGGESTIONS AND BUG REPORTS + The canonical place to find tifileutil and some miscellaneous informa- + tion is at https://github.com/debrouxl/tilibs (www.tilp.info). + + You can also look at http://lpg.ticalc.org and http://www.ticalc.org + for others TI related programs for Linux. French people can also look + at http://www.ti-fr.org and http://tiplanet.org. + + +AUTHOR + Original authors: Romain Lievin (tf2hex), Benjamin Moody (tipack & + titools). + + tifileutil unified design and implementation, including modifications + to the original tools: Lionel Debroux. + + +THANKS + Thanks to the original authors of the code blocks embedded into + tifileutil. + + +SEE ALSO + tilp(1) + + + + January 1, 2021 TIFILEUTIL(1) diff --git a/tifileutil/man/cleaner.c b/tifileutil/man/cleaner.c new file mode 100644 index 000000000..d715d48aa --- /dev/null +++ b/tifileutil/man/cleaner.c @@ -0,0 +1,113 @@ +/* manpage_cleaner - remove the repetition of characters + * Copyright (C) 2000 Romain Liévin + * Copyright (C) 2009 Kevin Kofler + * Copyright (C) 2009 Lionel Debroux + * + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include + +int main(int argc, char **argv) +{ + char *filename = NULL; + char *filename2 = NULL; + FILE *in; + FILE *out; + char buffer[3]; + size_t len; + int retval = 0; + + /* Retrieve the command line argument */ + if(argc < 2) + { + fprintf(stderr, "You must give a filename on the command line.\n"); + retval = 1; + goto end; + } + + len = strlen(argv[1]); + filename = malloc(len+1); + filename2 = malloc(len+5); + if(filename == NULL || filename2 == NULL) + { + fprintf(stderr, "Cannot allocate memory.\n"); + retval = 1; + goto end; + } + strcpy(filename, argv[1]); + strcpy(filename2, filename); + strcat(filename2 + len, ".txt"); + + fprintf(stdout, "Processing file <%s>:\n", filename); + fprintf(stdout, "Pass 1... "); + + /* Open input file */ + in = fopen(filename, "rb"); + if(in == NULL) + { + fprintf(stderr, "Unable to open this file: <%s>\n", filename); + retval = 1; + goto end; + } + + /* Open output file */ + out = fopen(filename2, "wb"); + if(out == NULL) + { + fclose(in); + fprintf(stderr, "Unable to open this file: <%s>\n", filename2); + retval = 1; + goto end; + } + + /* Process the file for removing backspace sequences */ + while(!feof(in)) + { + buffer[0] = fgetc(in); + if(feof(in)) break; + buffer[1] = fgetc(in); + if(feof(in)) + { + fputc(buffer[0], out); + break; + } + + if(buffer[0] == '\b') + { + continue; // Skip the char and BS + } + if(buffer[1] == '\b') + { + fputc(fgetc(in), out); // Skip the 2 previous chars + continue; + } + fputc(buffer[0], out); + fputc(buffer[1], out); + } + fprintf(stdout, "Done.\n"); + + /* Close the files */ + fclose(in); + fclose(out); + +end: + free(filename2); + free(filename); + + return retval; +} diff --git a/tifileutil/man/tifileutil.1 b/tifileutil/man/tifileutil.1 new file mode 100644 index 000000000..905b5565f --- /dev/null +++ b/tifileutil/man/tifileutil.1 @@ -0,0 +1,67 @@ +.TH TIFILEUTIL 1 "January 1, 2021" + +.SH NAME +tifileutil - a program for manipulating computer files suitable for TI graphing calculators + +.SH SYNOPSIS +\fBtifileutil\fP [\-h / \-\-help] [\-v / \-\-version] [command] [arguments] + +.SH DESCRIPTION +The \fBtifileutil\fP program allows you to perform various operations on computer files suitable for the TI-Z80, TI-eZ80 and TI-68k series of graphing calculators. + +.SH OPTIONS +\fBtifileutil\fP accepts the following options: + +.TP +\fB\-h, \-\-help\fP +Display a list of all command line options and commands. + +.TP +\fB\-v, \-\-version\fP +Output the version info. + +.SH EXAMPLES +Dump a file supposed to be suitable for TI calculators as a C hex array to an output file: + +.TP +tifileutil dump -f chexarray romdump_9x/romdump.89z -o rom89.h -n romDump89 -s romDumpSize89 -c 8 -m 64 + +.TP +Create TI file header and footer for a raw binary: + +.TP +tifileutil wrap \-n 'ROMDUMP' dump83p.bin \-p \-o dump83p.8xp + +.SH COPYRIGHT +Copyright (C) 2006-2010 Benjamin Moody + +Copyright (C) 2010 Jon Sturm + +Copyright (C) 1999-2009 Romain Lievin + +Copyright (C) 2009-2021 Lionel Debroux + +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 program and its source code is distributed under the terms of the +terms of the GNU General Public License as published by the Free Software Foundation; either version 2 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +.SH SUGGESTIONS AND BUG REPORTS +The canonical place to find tifileutil and some miscellaneous information is at https://github.com/debrouxl/tilibs (www.tilp.info). + +You can also look at http://lpg.ticalc.org and http://www.ticalc.org for others TI related programs for Linux. French people can also look at http://www.ti-fr.org and http://tiplanet.org. + +.SH AUTHOR +Original authors: Romain Lievin (tf2hex), Benjamin Moody (tipack & titools). + +tifileutil unified design and implementation, including modifications to the original tools: Lionel Debroux. + +.SH THANKS +Thanks to the original authors of the code blocks embedded into tifileutil. + +.SH SEE ALSO +tilp(1) diff --git a/tifileutil/po/LINGUAS b/tifileutil/po/LINGUAS new file mode 100644 index 000000000..d6751a7ed --- /dev/null +++ b/tifileutil/po/LINGUAS @@ -0,0 +1,2 @@ +# Set of available languages. +fr diff --git a/tifileutil/po/Makefile.in.in b/tifileutil/po/Makefile.in.in new file mode 100644 index 000000000..06a8cfe92 --- /dev/null +++ b/tifileutil/po/Makefile.in.in @@ -0,0 +1,222 @@ +# Makefile for program source directory in GNU NLS utilities package. +# Copyright (C) 1995, 1996, 1997 by Ulrich Drepper +# Copyright (C) 2004-2008 Rodney Dawes +# +# This file may be copied and used freely without restrictions. It may +# be used in projects which are not available under a GNU Public License, +# but which still want to provide support for the GNU gettext functionality. +# +# - Modified by Owen Taylor to use GETTEXT_PACKAGE +# instead of PACKAGE and to look for po2tbl in ./ not in intl/ +# +# - Modified by jacob berkman to install +# Makefile.in.in and po2tbl.sed.in for use with glib-gettextize +# +# - Modified by Rodney Dawes for use with intltool +# +# We have the following line for use by intltoolize: +# INTLTOOL_MAKEFILE + +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = @SHELL@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +top_builddir = @top_builddir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datadir = @datadir@ +datarootdir = @datarootdir@ +libdir = @libdir@ +DATADIRNAME = @DATADIRNAME@ +itlocaledir = $(prefix)/$(DATADIRNAME)/locale +subdir = po +install_sh = @install_sh@ +# Automake >= 1.8 provides @mkdir_p@. +# Until it can be supposed, use the safe fallback: +mkdir_p = $(install_sh) -d + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ + +GMSGFMT = @GMSGFMT@ +MSGFMT = @MSGFMT@ +XGETTEXT = @XGETTEXT@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +MSGMERGE = INTLTOOL_EXTRACT="$(INTLTOOL_EXTRACT)" XGETTEXT="$(XGETTEXT)" srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --dist +GENPOT = INTLTOOL_EXTRACT="$(INTLTOOL_EXTRACT)" XGETTEXT="$(XGETTEXT)" srcdir=$(srcdir) $(INTLTOOL_UPDATE) --gettext-package $(GETTEXT_PACKAGE) --pot + +ALL_LINGUAS = @ALL_LINGUAS@ + +PO_LINGUAS=$(shell if test -r $(srcdir)/LINGUAS; then grep -v "^\#" $(srcdir)/LINGUAS; else echo "$(ALL_LINGUAS)"; fi) + +USER_LINGUAS=$(shell if test -n "$(LINGUAS)"; then LLINGUAS="$(LINGUAS)"; ALINGUAS="$(ALL_LINGUAS)"; for lang in $$LLINGUAS; do if test -n "`grep \^$$lang$$ $(srcdir)/LINGUAS 2>/dev/null`" -o -n "`echo $$ALINGUAS|tr ' ' '\n'|grep \^$$lang$$`"; then printf "$$lang "; fi; done; fi) + +USE_LINGUAS=$(shell if test -n "$(USER_LINGUAS)" -o -n "$(LINGUAS)"; then LLINGUAS="$(USER_LINGUAS)"; else if test -n "$(PO_LINGUAS)"; then LLINGUAS="$(PO_LINGUAS)"; else LLINGUAS="$(ALL_LINGUAS)"; fi; fi; for lang in $$LLINGUAS; do printf "$$lang "; done) + +POFILES=$(shell LINGUAS="$(PO_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.po "; done) + +DISTFILES = Makefile.in.in POTFILES.in $(POFILES) +EXTRA_DISTFILES = ChangeLog POTFILES.skip Makevars LINGUAS + +POTFILES = \ +# This comment gets stripped out + +CATALOGS=$(shell LINGUAS="$(USE_LINGUAS)"; for lang in $$LINGUAS; do printf "$$lang.gmo "; done) + +.SUFFIXES: +.SUFFIXES: .po .pox .gmo .mo .msg .cat + +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +INTLTOOL_V_MSGFMT = $(INTLTOOL__v_MSGFMT_$(V)) +INTLTOOL__v_MSGFMT_= $(INTLTOOL__v_MSGFMT_$(AM_DEFAULT_VERBOSITY)) +INTLTOOL__v_MSGFMT_0 = @echo " MSGFMT" $@; + +.po.pox: + $(MAKE) $(GETTEXT_PACKAGE).pot + $(MSGMERGE) $< $(GETTEXT_PACKAGE).pot -o $*.pox + +.po.mo: + $(INTLTOOL_V_MSGFMT)$(MSGFMT) -o $@ $< + +.po.gmo: + $(INTLTOOL_V_MSGFMT)file=`echo $* | sed 's,.*/,,'`.gmo \ + && rm -f $$file && $(GMSGFMT) -o $$file $< + +.po.cat: + sed -f ../intl/po2msg.sed < $< > $*.msg \ + && rm -f $@ && gencat $@ $*.msg + + +all: all-@USE_NLS@ + +all-yes: $(CATALOGS) +all-no: + +$(GETTEXT_PACKAGE).pot: $(POTFILES) + $(GENPOT) + +install: install-data +install-data: install-data-@USE_NLS@ +install-data-no: all +install-data-yes: all + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + dir=$(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES; \ + $(mkdir_p) $$dir; \ + if test -r $$lang.gmo; then \ + $(INSTALL_DATA) $$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ + echo "installing $$lang.gmo as $$dir/$(GETTEXT_PACKAGE).mo"; \ + else \ + $(INSTALL_DATA) $(srcdir)/$$lang.gmo $$dir/$(GETTEXT_PACKAGE).mo; \ + echo "installing $(srcdir)/$$lang.gmo as" \ + "$$dir/$(GETTEXT_PACKAGE).mo"; \ + fi; \ + if test -r $$lang.gmo.m; then \ + $(INSTALL_DATA) $$lang.gmo.m $$dir/$(GETTEXT_PACKAGE).mo.m; \ + echo "installing $$lang.gmo.m as $$dir/$(GETTEXT_PACKAGE).mo.m"; \ + else \ + if test -r $(srcdir)/$$lang.gmo.m ; then \ + $(INSTALL_DATA) $(srcdir)/$$lang.gmo.m \ + $$dir/$(GETTEXT_PACKAGE).mo.m; \ + echo "installing $(srcdir)/$$lang.gmo.m as" \ + "$$dir/$(GETTEXT_PACKAGE).mo.m"; \ + else \ + true; \ + fi; \ + fi; \ + done + +# Empty stubs to satisfy archaic automake needs +dvi info ctags tags CTAGS TAGS ID: + +# Define this as empty until I found a useful application. +install-exec installcheck: + +uninstall: + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo; \ + rm -f $(DESTDIR)$(itlocaledir)/$$lang/LC_MESSAGES/$(GETTEXT_PACKAGE).mo.m; \ + done + +check: all $(GETTEXT_PACKAGE).pot + rm -f missing notexist + srcdir=$(srcdir) $(INTLTOOL_UPDATE) -m + if [ -r missing -o -r notexist ]; then \ + exit 1; \ + fi + +mostlyclean: + rm -f *.pox $(GETTEXT_PACKAGE).pot *.old.po cat-id-tbl.tmp + rm -f .intltool-merge-cache + +clean: mostlyclean + +distclean: clean + rm -f Makefile Makefile.in POTFILES stamp-it + rm -f *.mo *.msg *.cat *.cat.m *.gmo + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f Makefile.in.in + +distdir = ../$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: $(DISTFILES) + dists="$(DISTFILES)"; \ + extra_dists="$(EXTRA_DISTFILES)"; \ + for file in $$extra_dists; do \ + test -f $(srcdir)/$$file && dists="$$dists $(srcdir)/$$file"; \ + done; \ + for file in $$dists; do \ + test -f $$file || file="$(srcdir)/$$file"; \ + ln $$file $(distdir) 2> /dev/null \ + || cp -p $$file $(distdir); \ + done + +update-po: Makefile + $(MAKE) $(GETTEXT_PACKAGE).pot + tmpdir=`pwd`; \ + linguas="$(USE_LINGUAS)"; \ + for lang in $$linguas; do \ + echo "$$lang:"; \ + result="`$(MSGMERGE) -o $$tmpdir/$$lang.new.po $$lang`"; \ + if $$result; then \ + if cmp $(srcdir)/$$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "msgmerge for $$lang.gmo failed!"; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi; \ + done + +Makefile POTFILES: stamp-it + @if test ! -f $@; then \ + rm -f stamp-it; \ + $(MAKE) stamp-it; \ + fi + +stamp-it: Makefile.in.in $(top_builddir)/config.status POTFILES.in + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/Makefile.in CONFIG_HEADERS= CONFIG_LINKS= \ + $(SHELL) ./config.status + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/tifileutil/po/POTFILES.in b/tifileutil/po/POTFILES.in new file mode 100644 index 000000000..0c8abadab --- /dev/null +++ b/tifileutil/po/POTFILES.in @@ -0,0 +1 @@ +src/main.cc diff --git a/tifileutil/po/fr.po b/tifileutil/po/fr.po new file mode 100644 index 000000000..a0d0ead82 --- /dev/null +++ b/tifileutil/po/fr.po @@ -0,0 +1,31 @@ +# French locale for tifileutil +# Copyright (C) 2019 Lionel Debroux +# This file is distributed under the same license as the tifileutil package. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: tifileutil 0.1.0\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2021-01-01 23:24+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: Lionel Debroux \n" +"Language-Team: Français \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: ../src/main.cc:709 +#, c-format +msgid "libticonv library version is %s but %s mini required.\n" +msgstr "" +"la version de la librairie libticonv est %s mais la version minimum est %s.\n" + +#: ../src/main.cc:715 +#, c-format +msgid "libtifiles library version is %s but %s mini required.\n" +msgstr "" +"la version de la librairie libtifiles est %s mais la version minimum est " +"%s.\n" diff --git a/tifileutil/src/Makefile.am b/tifileutil/src/Makefile.am new file mode 100644 index 000000000..95465bf69 --- /dev/null +++ b/tifileutil/src/Makefile.am @@ -0,0 +1,23 @@ +## Process this file with automake to produce Makefile.in + +AM_CFLAGS = -Wall + +# programs and files to compile and install +bin_PROGRAMS = tifileutil + +# build instructions +tifileutil_CPPFLAGS = -I$(top_srcdir)/intl \ + @TIFILES_CFLAGS@ @TICONV_CFLAGS@ \ + @GLIB_CFLAGS@ \ + -DSHARE_DIR=\"$(pkgdatadir)\" \ + -DLOCALEDIR=\"$(datadir)/locale\" \ + -DSYSCONFDIR=\"$(sysconfdir)\" +tifileutil_LDFLAGS = +tifileutil_LDADD = @GLIB_LIBS@ @TIFILES_LIBS@ @TICONV_LIBS@ +tifileutil_SOURCES = *.h \ + main.cc + +if OS_WIN32 + tifileutil_DEPENDENCIES = ../build/mingw/tifileutil-rc.o + tifileutil_LDFLAGS += -Wl,../build/mingw/tifileutil-rc.o +endif diff --git a/tifileutil/src/gettext.h b/tifileutil/src/gettext.h new file mode 100644 index 000000000..606a0d0d9 --- /dev/null +++ b/tifileutil/src/gettext.h @@ -0,0 +1,88 @@ +/* Convenience header for conditional use of GNU . + Copyright (C) 1995-1998, 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. */ + +#ifndef _LIBGETTEXT_H +#define _LIBGETTEXT_H 1 + +/* NLS can be disabled through the configure --disable-nls option. */ +#if ENABLE_NLS + +/* Get declarations of GNU message catalog functions. */ +# include + +#else + +/* Solaris /usr/include/locale.h includes /usr/include/libintl.h, which + chokes if dcgettext is defined as a macro. So include it now, to make + later inclusions of a NOP. We don't include + as well because people using "gettext.h" will not include , + and also including would fail on SunOS 4, whereas + is OK. */ +#if defined(__sun) +# include +#endif + +/* Many header files from the libstdc++ coming with g++ 3.3 or newer include + , which chokes if dcgettext is defined as a macro. So include + it now, to make later inclusions of a NOP. */ +#if defined(__cplusplus) && defined(__GNUG__) && (__GNUC__ >= 3) +# include +# if (__GLIBC__ >= 2) || _GLIBCXX_HAVE_LIBINTL_H +# include +# endif +#endif + +/* Disabled NLS. + The casts to 'const char *' serve the purpose of producing warnings + for invalid uses of the value returned from these functions. + On pre-ANSI systems without 'const', the config.h file is supposed to + contain "#define const". */ +# define gettext(Msgid) ((const char *) (Msgid)) +# define dgettext(Domainname, Msgid) ((const char *) (Msgid)) +# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid)) +# define ngettext(Msgid1, Msgid2, N) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define dngettext(Domainname, Msgid1, Msgid2, N) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \ + ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) +# define textdomain(Domainname) ((const char *) (Domainname)) +# define bindtextdomain(Domainname, Dirname) ((const char *) (Dirname)) +# define bind_textdomain_codeset(Domainname, Codeset) ((const char *) (Codeset)) + +#endif + +/* A pseudo function call that serves as a marker for the automated + extraction of messages, but does not call gettext(). The run-time + translation is done at a different place in the code. + The argument, String, should be a literal string. Concatenated strings + and other string expressions won't work. + The macro's expansion is not parenthesized, so that it is suitable as + initializer for static 'char[]' or 'const char[]' variables. */ +#define gettext_noop(String) String + +/* Short gettext aliases. */ +#define _(String) dgettext(PACKAGE, String) +#define N_(String) gettext_noop(String) + +#if defined(__WIN32__) && !defined(__MINGW32__) +# undef PACKAGE +# define PACKAGE "libticalcs2" // name of package +#endif + +#endif /* _LIBGETTEXT_H */ diff --git a/tifileutil/src/logging.h b/tifileutil/src/logging.h new file mode 100644 index 000000000..be4afc1b0 --- /dev/null +++ b/tifileutil/src/logging.h @@ -0,0 +1,40 @@ +/* Hey EMACS -*- linux-c -*- */ + +/* libtifiles - Ti File Format library, a part of the TiLP project + * Copyright (C) 1999-2006 Romain Lievin + * Copyright (C) 2019 Lionel Debroux + * + * 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* + Domain name logging. +*/ + +#ifndef __TIFILEUTIL_LOG_H__ +#define __TIFILEUTIL_LOG_H__ + +#include + +#define LOG_DOMAIN "tifileutil" + +#define tifileutil_debug(format, ...) g_log(LOG_DOMAIN, G_LOG_LEVEL_DEBUG, format, ##__VA_ARGS__) +#define tifileutil_info(format, ...) g_log(LOG_DOMAIN, G_LOG_LEVEL_INFO, format, ##__VA_ARGS__) +#define tifileutil_warning(format, ...) g_log(LOG_DOMAIN, G_LOG_LEVEL_WARNING, format, ##__VA_ARGS__) +#define tifileutil_critical(format, ...) g_log(LOG_DOMAIN, G_LOG_LEVEL_CRITICAL, format, ##__VA_ARGS__) +#define tifileutil_error(format, ...) g_log(LOG_DOMAIN, G_LOG_LEVEL_ERROR, format, ##__VA_ARGS__) + +#endif + diff --git a/tifileutil/src/main.cc b/tifileutil/src/main.cc new file mode 100644 index 000000000..215b0872f --- /dev/null +++ b/tifileutil/src/main.cc @@ -0,0 +1,761 @@ +/* + * tifileutil -- program to create / manipulate TI data files + * + * Copyright (C) 2006-2010 Benjamin Moody (tipack, titools) + * Copyright (C) 2010 Jon Sturm (titools) + * Copyright (C) 1999-2009 Romain Lievin (tf2hex) + * Copyright (C) 2009-2019 Lionel Debroux (tf2hex) + * + * 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 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "config.h" +#include "gettext.h" +#include "logging.h" + +#define TIFILEUTIL_REQUIRES_LIBTICONV_VERSION "1.1.6" +#define TIFILEUTIL_REQUIRES_LIBTIFILES2_VERSION "1.1.8" + +static char * progname = NULL; + +static int err_print(const char* func, int errcode) +{ + char* p; + if (errcode) { + tifiles_error_get(errcode, &p); + tifileutil_critical("error in %s:\n%s\n", func, p); + tifiles_error_free(p); + } + return errcode; +} + +static int type_name_is_tokenized(CalcModel model, uint8_t type_id) +{ + if (model == CALC_TI73) { + return (type_id != TI73_PRGM && type_id != TI73_ASM && type_id != TI73_DIR && type_id != TI73_AVAR && type_id < 0x20); + } + + if (model == CALC_TI82 || model == CALC_TI83 || model == CALC_TI83P || model == CALC_TI84P || model == CALC_TI84PC) { + return ( type_id != TI82_PRGM && type_id != TI82_PPGM && type_id != TI83p_APPOBJ && type_id != TI83p_APPVAR + && type_id != TI83p_TEMPPROGOBJ && type_id != TI83p_GRP && type_id < 0x20); + } + + // Other models and types. + return 0; +} + +static int type_has_length(CalcModel model, uint8_t type_id) +{ + if (!tifiles_calc_is_ti8x(model)) { + return 0; + } + + if (model == CALC_TI85 || model == CALC_TI86) { + return (type_id == TI85_EQU || type_id == TI85_STRNG || type_id == TI85_PICT || type_id == TI85_PRGM); + } + + if (model == CALC_TI82 || model == CALC_TI83) { + return (type_id == TI82_YVAR || type_id == TI83_STRNG || type_id == TI82_PRGM || type_id == TI82_PPGM || type_id == TI82_PIC); + } + + if (model == CALC_TI73) { + return (type_id == TI73_EQU || type_id == TI73_STRNG || type_id == TI73_PRGM || type_id == TI73_ASM || type_id == TI73_PIC || type_id == TI73_AVAR); + } + + return (type_id == TI83p_EQU || type_id == TI83p_STRNG || type_id == TI83p_PRGM || type_id == TI83p_ASM || type_id == TI83p_PIC || type_id == TI83p_APPVAR); +} + +static int protect_type(CalcModel model, uint8_t type_id) +{ + return (( tifiles_calc_is_ti8x(model) + && model != CALC_TI85 + && model != CALC_TI86 + && type_id == TI82_PRGM) ? type_id + 1 + : type_id); +} + +static int complexify_type(CalcModel model, uint8_t type_id) +{ + if (tifiles_calc_is_ti9x(model)) { + return ((type_id == TI89_LIST || type_id == TI89_MAT) ? type_id + 1 : type_id); + } + + if (model == CALC_TI85 || model == CALC_TI86) { + return ( (type_id == TI85_REAL || type_id == TI85_VECTR + || type_id == TI85_LIST || type_id == TI85_MATRX + || type_id == TI85_CONS) ? type_id + 1 + : type_id); + } + + if (model == CALC_TI82 || model == CALC_TI73) { + return type_id; + } + + return ((type_id == TI83_REAL || type_id == TI83_LIST) ? type_id + TI83_CPLX : type_id); +} + +typedef int (*FNCT_USAGE) (int *, char ***); +typedef int (*FNCT_MENU) (int *, char ***, unsigned int); + +static int tifileutil_wrap_usage(int * argc, char *** argv) +{ + fprintf(stderr, "Usage: %s wrap [OPTIONS] [FILE | -]\n" +"Where OPTIONS may include:\n" +" -o FILE: output result to FILE\n" +" -n NAME: set on-calc variable name to NAME\n" +" -f NAME: set on-calc variable folder to NAME\n" +" -t TYPE: set variable type to TYPE (e.g. 82p)\n" +" -c COMMENT: set file comment (strftime format string)\n" +" -p: protect program\n" +" -C: number/list/matrix is complex\n" +" -a: send file to archive\n" +" -r: raw mode (no length bytes)\n" +" -v: be verbose\n", (*argv)[0]); + return 1; +} + +static int tifileutil_wrap(int * argc, char *** argv, unsigned int offset) +{ + int ret; + + const char * infilename = NULL; + char * outfilename = NULL; + char * varname = NULL; + char * foldername = NULL; + char * vartype = NULL; + const char * comment = "Created by " PACKAGE " " PACKAGE_VERSION; + int protect = 0; + int complexify = 0; + int archive = 0; + int rawmode = 0; + int verbose = 0; + CalcModel model; + uint8_t type_id; + FILE * infile; + FileContent * fc; + VarEntry * ve; + uint8_t * data = NULL; + unsigned long dsize, dalloc; + + int i, j; + char * p; + const char * cp; + time_t t; + + for (i = offset + 1; i < *argc; i++) { + if ((*argv)[i][0] == '-' && (*argv)[i][1]) { + for (j = 1; (*argv)[i][j]; j++) { + switch ((*argv)[i][j]) { + case 'o': + if ((*argv)[i][++j]) { + outfilename = &((*argv)[i][j]); + } + else { + outfilename = (*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + break; + + case 'n': + if ((*argv)[i][++j]) { + varname = &((*argv)[i][j]); + } + else { + varname = (*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + break; + + case 'f': + if ((*argv)[i][++j]) { + foldername = &((*argv)[i][j]); + } + else { + foldername = (*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + break; + + case 't': + if ((*argv)[i][++j]) { + vartype = &((*argv)[i][j]); + } + else { + vartype = (*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + break; + + case 'c': + if ((*argv)[i][++j]) { + comment = (const char *)&((*argv)[i][j]); + } + else { + comment = (const char *)(*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + break; + + case 'p': + protect = 1; + break; + + case 'C': + complexify = 1; + break; + + case 'a': + archive = 1; + break; + + case 'r': + rawmode = 1; + break; + + case 'v': + verbose = 1; + break; + + default: + tifileutil_critical("%s: unknown option -%c\n", (*argv)[0], (*argv)[i][j]); + return tifileutil_wrap_usage(argc, argv); + } + } + } + else if ((*argv)[i][0] != '-') { + infilename = (const char *)(*argv)[i]; + } + } + + /* Set default outfilename or vartype */ + + if (!outfilename && vartype) { + if (infilename) { + outfilename = (char *)malloc(strlen(infilename) + strlen(vartype) + 2); + strcpy(outfilename, infilename); + if ((p = strrchr(outfilename, '.'))) { + *p = 0; + } + strcat(outfilename, "."); + strcat(outfilename, vartype); + } + else { + outfilename = (char *)malloc(strlen(vartype) + 3); + sprintf(outfilename, "a.%s", vartype); + } + } + else if (outfilename && !vartype) { + if ((p = strrchr(outfilename, '.'))) { + vartype = &(p[1]); + } + } + + if (!vartype) { + tifileutil_critical("%s: no variable type specified.", (*argv)[0]); + return 1; + } + + + p = (char *)malloc(strlen(vartype) + 2); + sprintf(p, "a.%s", vartype); + model = tifiles_file_get_model(p); + free(p); + + if (!model) { + tifileutil_critical("%s: invalid variable type %s\n", (*argv)[0], vartype); + ret = 1; + goto end; + } + + type_id = tifiles_fext2vartype(model, vartype); + cp = tifiles_vartype2fext(model, type_id); + if (!cp || !cp[0]) { + tifileutil_critical("%s: invalid variable type %s\n", (*argv)[0], vartype); + ret = 1; + goto end; + } + + if (protect) { + type_id = protect_type(model, type_id); + } + if (complexify) { + type_id = complexify_type(model, type_id); + } + + if (!varname) { + p = strrchr(outfilename, '.'); + if (p) { + *p = 0; + } + if (type_name_is_tokenized(model, type_id)) { + varname = ticonv_varname_tokenize(model, outfilename, type_id); + } + else { + varname = (char *)malloc(strlen(outfilename) + 1); + for (i = 0; outfilename[i]; i++) { + if (outfilename[i] >= 'A' && outfilename[i] <= 'Z') { + varname[i] = outfilename[i]; + } + else if (outfilename[i] >= 'a' && outfilename[i] <= 'z') { + varname[i] = outfilename[i] + 'A' - 'a'; + } + else if (outfilename[i] >= '0' && outfilename[i] <= '9') { + varname[i] = outfilename[i]; + } + else { + varname[i] = '['; + } + } + varname[i] = 0; + } + if (p) { + *p = '.'; + } + } + + if (infilename) { + infile = fopen(infilename, "rb"); + if (!infile) { + perror(infilename); + ret = 2; + goto end; + } + } + else { + infilename = "(standard input)"; + infile = stdin; + } + + data = (uint8_t *)malloc(dalloc = 1024); + if (!rawmode && type_has_length(model, type_id)) { + dsize = 2; + } + else { + dsize = 0; + } + + i = fgetc(infile); + while (!feof(infile) && !ferror(infile)) { + if (dsize >= dalloc) { + dalloc += 1024; + data = (uint8_t *)realloc(data, dalloc); + } + data[dsize++] = i; + i = fgetc(infile); + } + + if (infile != stdin) { + fclose(infile); + } + + if (!rawmode && type_has_length(model, type_id)) { + data[0] = (dsize - 2) & 0xff; + data[1] = ((dsize - 2) >> 8) & 0xff; + } + + fc = tifiles_content_create_regular(model); + + if (comment) { + if (strchr(comment, '%')) { + time(&t); + strftime(fc->comment, 40, comment, localtime(&t)); + } + else { + strncpy(fc->comment, comment, 40); + fc->comment[40 - 1] = 0; + } + } + + ve = tifiles_ve_create_with_data2(dsize, data); + memset(ve->folder, 0, FLDNAME_MAX); + if (NULL != foldername) { + strncpy(ve->folder, foldername, VARNAME_MAX); + } + memset(ve->name, 0, VARNAME_MAX); + strncpy(ve->name, varname, VARNAME_MAX); + ve->type = type_id; + ve->attr = archive ? ATTRB_ARCHIVED : 0; + ve->size = dsize; + + tifiles_content_add_entry(fc, ve); + + i = err_print("tifiles_file_write_regular", tifiles_file_write_regular(outfilename, fc, 0)); + + if (!i && verbose) { + tifiles_file_display_regular(fc); + } + + tifiles_content_delete_regular(fc); + + ret = i ? 3 : 0; + +end: + return ret; +} + +static int tifileutil_dump_usage(int * argc, char *** argv) +{ + fprintf(stderr, "Usage: %s dump [OPTIONS] [FILE | -]\n" +"Where OPTIONS may include:\n" +" -f FORMAT: format result as FORMAT (only 'chexarray' is supported for now)\n" +" -o FILE: output result to FILE\n" +" -n NAME: set C hex array name to NAME\n" +" -s NAME: set C hex size variable name to NAME\n" +" -c COUNT: print COUNT items per line of the array\n" +" -m MINSIZE: set minimum file size\n" +" -v: be verbose\n", (*argv)[0]); + return 1; +} + +static int tifileutil_dump(int * argc, char *** argv, unsigned int offset) +{ + int ret = 1; + + const char * format = NULL; + const char * infilename = NULL; + const char * outfilename = NULL; + const char * arrayname = NULL; + const char * arraysizename = NULL; + const char * itemsperlinestr = NULL; + const char * minsizestr = NULL; + int verbose = 0; + FILE * infile, * outfile = NULL; + struct stat st; + unsigned long length, lenread, itemsperline = 8, minsize = 64; + unsigned char data[65636]; // +100 for the header and footer. + unsigned long i, j; + + if (NULL == (*argv)[2]) { + return tifileutil_dump_usage(argc, argv); + } + + for (i = offset + 3; i < (unsigned long)*argc; i++) { + if ((*argv)[i][0] == '-' && (*argv)[i][1]) { + for (j = 1; (*argv)[i][j]; j++) { + switch ((*argv)[i][j]) { + case 'f': + if ((*argv)[i][++j]) { + format = &((*argv)[i][j]); + } + else { + format = (*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + break; + + case 'o': + if ((*argv)[i][++j]) { + outfilename = &((*argv)[i][j]); + } + else { + outfilename = (*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + break; + + case 'n': + if ((*argv)[i][++j]) { + arrayname = &((*argv)[i][j]); + } + else { + arrayname = (*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + break; + + case 's': + if ((*argv)[i][++j]) { + arraysizename = &((*argv)[i][j]); + } + else { + arraysizename = (*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + break; + + case 'c': + if ((*argv)[i][++j]) { + itemsperlinestr = &((*argv)[i][j]); + } + else { + itemsperlinestr = (*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + errno = 0; + itemsperline = strtoul(itemsperlinestr, NULL, 0); + if (errno != 0 || itemsperline < 1 || itemsperline > sizeof(data)) { + tifileutil_critical("%s: invalid number of items per line.\n", (*argv)[0]); + return ret; + } + break; + + case 'm': + if ((*argv)[i][++j]) { + minsizestr = &((*argv)[i][j]); + } + else { + minsizestr = (*argv)[++i]; + } + j = strlen((*argv)[i]) - 1; + errno = 0; + minsize = strtoul(minsizestr, NULL, 0); + if (errno != 0 || minsize > sizeof(data)) { + tifileutil_critical("%s: invalid minimum size.\n", (*argv)[0]); + return ret; + } + break; + + case 'v': + verbose = 1; + break; + + default: + tifileutil_critical("%s: unknown option -%c\n", (*argv)[0], (*argv)[i][j]); + return tifileutil_dump_usage(argc, argv); + } + } + } + else if ((*argv)[i][0] != '-') { + infilename = (const char *)(*argv)[i]; + } + } + + if (NULL != format && strcmp(format, "chexarray")) { + tifileutil_critical("%s: unsupported format %s\n", (*argv)[0], format); + return ret; + } + + if (minsize < 64) { + tifileutil_warning("%s: the specified minimum size is too small for a valid TI graphing calculator file.\n", (*argv)[0]); + } + + // read input file + if (NULL == infilename || (infilename[0] == '-' && infilename[1] == 0)) { + infile = stdin; + } + else { + infile = fopen(infilename, "rb"); + if (NULL == infile) { + tifileutil_critical("%s: unable to open input file.\n", (*argv)[0]); + return ret; + } + } + + if (outfilename[0] == '-' && outfilename[1] == 0) { + outfile = stdout; + } + + fstat(fileno(infile), &st); + length = st.st_size; + + lenread = fread(data, sizeof(char), length < sizeof(data) ? length : sizeof(data), infile); + + if (infile != stdin) { + fclose(infile); + } + + if (outfile != stdout && verbose) { + fprintf(stdout, "Read %ld bytes.\n", lenread); + } + + if (length < minsize) { + tifileutil_critical("%s: file is smaller than the specified minimum size.\n", (*argv)[0]); + return ret; + } + + if (lenread == length) { + // write output file + if (NULL == outfile) { + outfile = fopen(outfilename, "wt"); + if (NULL == outfile) { + tifileutil_critical("%s: unable to open output file.\n", (*argv)[0]); + return ret; + } + } + + // Produce hex digits while checking / computing checksum. + fprintf(outfile, "static unsigned char %s[] = {\n", arrayname); + for (i = 0; i < length; i += itemsperline) { + for (j = 0; (j < itemsperline) && (i + j < length); j++) { + fprintf(outfile, "0x%02x, ", data[i + j]); + } + fputc('\n', outfile); + } + // TODO: 2 last digits. + fprintf(outfile, "};\nstatic unsigned int %s = sizeof(%s)/sizeof(%s[0]); // %ld\n", arraysizename, arrayname, arrayname, length); + + if (outfile != stdout) { + fclose(outfile); + } + + ret = 0; + } + else { + tifileutil_critical("%s: unable to read the entire input file.\n", (*argv)[0]); + return ret; + } + + return ret; +} + +typedef struct +{ + const char * desc; + const char * scriptable_name; + uint32_t scriptable_name_len; + FNCT_MENU fnct; + FNCT_USAGE usage; +} menu_entry; + +static menu_entry fnct_menu[] = +{ +#define DEFINE_MENU_ENTRY(desc, method) \ + { desc, #method, sizeof(#method) - 1, tifileutil_##method, tifileutil_##method##_usage } +// Used for signaling that a newline should be printed +#define NULL_ENTRY \ + { NULL, NULL, 0, NULL, NULL } + + // IMPORTANT NOTES: for backwards compatibility, after a scriptable name was defined, it shall never be changed. + NULL_ENTRY, // 0 + { "Exit now", "exit", 4, NULL, NULL }, + DEFINE_MENU_ENTRY("Wrap data to variable", wrap), + DEFINE_MENU_ENTRY("Dump data from file", dump), + NULL_ENTRY, +#undef NULL_ENTRY +#undef DEFINE_MENU_ENTRY +}; + +static int tifileutil_scan_parameters(int * argc, char *** argv) +{ + int ret = 0; + unsigned int choice = 0; + + // tipack compatibility mode. + if (!strcmp((*argv)[0], "tipack")) { + ret = tifileutil_wrap(argc, argv, 0U); + } + else if (*argc >= 2) { + if (!strcmp((*argv)[1], "-h") || !strcmp((*argv)[1], "--help")) { + goto print_usage; + } + else if (!strcmp((*argv)[1], "-v") || !strcmp((*argv)[1], "--version")) { + fputs(PACKAGE " " PACKAGE_VERSION "\n", stderr); + } + for (unsigned int i = 1; i < sizeof(fnct_menu) / sizeof(fnct_menu[0]); i++) { + if (NULL != fnct_menu[i].scriptable_name) { + if (!strcmp((*argv)[1], fnct_menu[i].scriptable_name)) { + choice = i; + break; + } + } + } + if (choice != 0) { + if (NULL != fnct_menu[choice].fnct) { + ret = (*fnct_menu[choice].fnct)(argc, argv, 0U); + } + else { + ret = 0; + } + } + else { + ret = 1; +print_usage: + fputs(PACKAGE " " PACKAGE_VERSION "\n", stderr); + for (unsigned int i = 1; i < sizeof(fnct_menu) / sizeof(fnct_menu[0]); i++) { + if (NULL != fnct_menu[i].usage) { + (void)((*fnct_menu[i].usage)(argc, argv)); + } + } + } + } + else { + goto print_usage; + } + + return ret; +} + +static int tifileutil_init(int * argc, char *** argv) +{ + int ret = 0; + + /* Check the version of libraries and init framework */ + if (strcmp(ticonv_version_get(), TIFILEUTIL_REQUIRES_LIBTICONV_VERSION) < 0) + { + tifileutil_critical(_("libticonv library version is %s but %s mini required.\n"), ticonv_version_get(), TIFILEUTIL_REQUIRES_LIBTICONV_VERSION); + return 1; + } + + if (strcmp(tifiles_version_get(), TIFILEUTIL_REQUIRES_LIBTIFILES2_VERSION) < 0) + { + tifileutil_critical(_("libtifiles library version is %s but %s mini required.\n"), tifiles_version_get(), TIFILEUTIL_REQUIRES_LIBTIFILES2_VERSION); + return 1; + } + + tifiles_library_init(); + + /* Init i18n support */ +#if 0 // #ifdef ENABLE_NLS + tifileutil_info("setlocale: %s", setlocale(LC_ALL, "")); + tifileutil_info("bindtextdomain: %s", bindtextdomain(PACKAGE, LOCALEDIR)); + bind_textdomain_codeset(PACKAGE, "UTF-8"/*"ISO-8859-15"*/); + tifileutil_info("textdomain: %s", textdomain(PACKAGE)); +#endif + + ret = tifileutil_scan_parameters(argc, argv); + + return ret; +} + +static int tifileutil_exit() +{ + tifiles_library_exit(); + + return 0; +} + +int main(int argc, char ** argv) +{ + int ret; + +#ifdef ENABLE_NLS +// char * locale_dir = g_strconcat(SHARE_DIR, G_DIR_SEPARATOR_S, LOCALEDIR, "/", NULL); +#endif + + // Force GLib 2.32+ to print info and debug messages like older versions did, unless this variable is already set. + // No effect on earlier GLib versions. + // Commented out because this interferes with stdout mode for e.g. dump. + //g_setenv("G_MESSAGES_DEBUG", "all", /* overwrite = */ FALSE); + + progname = argv[0]; + + ret = tifileutil_init(&argc, &argv); + + tifileutil_exit(); + + return ret; +} diff --git a/tifileutil/trunk b/tifileutil/trunk new file mode 120000 index 000000000..945c9b46d --- /dev/null +++ b/tifileutil/trunk @@ -0,0 +1 @@ +. \ No newline at end of file