├── .github ├── FUNDING.yml └── workflows │ └── main.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE.txt ├── README.md ├── archive_pck.c ├── archive_pkg.c ├── archive_tar.c ├── archive_uz2.c ├── archive_zip.c ├── buildver.c ├── bzip2 ├── blocksort.c ├── bzlib.c ├── bzlib.h ├── bzlib_private.h ├── compress.c ├── crctable.c ├── decompress.c ├── huffman.c ├── randtable.c └── version.txt ├── checksum_crc32.c ├── checksum_md5.c ├── checksum_sha1.c ├── docs.txt ├── examples ├── aquaria │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── braid │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── build-example.sh ├── cogs │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── dearesther │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── duke3d │ ├── data │ │ ├── duke3d.png │ │ ├── duke3d_readme.txt │ │ ├── gpl.txt │ │ └── mojosetup_readme.txt │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── dungeondefenders │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── hammerfight │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── limbo │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ └── config.lua ├── lugaru │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── postal1 │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── postal2 │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── postal2aw │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── prey-demo │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── prey │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── psychonauts │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── shank │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ ├── app_localization.lua │ │ └── config.lua ├── spaz │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ └── config.lua ├── supermeatboy │ ├── details.txt │ ├── meta │ │ └── splash.bmp │ └── scripts │ │ └── config.lua ├── ut3-dedicated-patches │ ├── data │ │ ├── README-ut3-patch2.txt │ │ └── UT3-linux-server-EULA.txt │ ├── details.txt │ └── scripts │ │ └── config.lua └── ut3-dedicated │ ├── details.txt │ └── scripts │ └── config.lua ├── fileio.c ├── fileio.h ├── gui.c ├── gui.h ├── gui_cocoa.m ├── gui_gtkplus2.c ├── gui_gtkplus3.c ├── gui_ncurses.c ├── gui_stdio.c ├── gui_www.c ├── libfetch ├── README.txt ├── common.c ├── common.h ├── fetch.c ├── fetch.h ├── ftp.c ├── ftp.errors ├── ftperr.h ├── http.c ├── http.errors ├── httperr.h ├── mojosetup_libfetch.h └── regen_error_headers.sh ├── liblzma ├── README.txt ├── api │ ├── lzma.h │ └── lzma │ │ ├── base.h │ │ ├── bcj.h │ │ ├── block.h │ │ ├── check.h │ │ ├── container.h │ │ ├── delta.h │ │ ├── filter.h │ │ ├── hardware.h │ │ ├── index.h │ │ ├── index_hash.h │ │ ├── lzma.h │ │ ├── stream_flags.h │ │ ├── version.h │ │ └── vli.h ├── check │ ├── check.c │ ├── check.h │ └── crc_macros.h ├── common │ ├── alone_decoder.c │ ├── alone_decoder.h │ ├── block_buffer_decoder.c │ ├── block_decoder.c │ ├── block_decoder.h │ ├── block_header_decoder.c │ ├── block_util.c │ ├── common.c │ ├── common.h │ ├── easy_decoder_memusage.c │ ├── easy_preset.c │ ├── easy_preset.h │ ├── filter_buffer_decoder.c │ ├── filter_common.c │ ├── filter_common.h │ ├── filter_decoder.c │ ├── filter_decoder.h │ ├── filter_flags_decoder.c │ ├── index.c │ ├── index.h │ ├── index_decoder.c │ ├── index_hash.c │ ├── mythread.h │ ├── stream_decoder.c │ ├── stream_decoder.h │ ├── stream_flags_common.c │ ├── stream_flags_common.h │ ├── stream_flags_decoder.c │ ├── sysdefs.h │ ├── tuklib_common.h │ ├── tuklib_config.h │ ├── tuklib_integer.h │ ├── vli_decoder.c │ └── vli_size.c ├── delta │ ├── delta_common.c │ ├── delta_common.h │ ├── delta_decoder.c │ ├── delta_decoder.h │ └── delta_private.h ├── lz │ ├── lz_decoder.c │ └── lz_decoder.h ├── lzma │ ├── lzma2_decoder.c │ ├── lzma2_decoder.h │ ├── lzma_common.h │ ├── lzma_decoder.c │ ├── lzma_decoder.h │ └── lzma_encoder_presets.c ├── rangecoder │ ├── range_common.h │ ├── range_decoder.h │ └── range_encoder.h └── simple │ ├── arm.c │ ├── armthumb.c │ ├── ia64.c │ ├── powerpc.c │ ├── simple_coder.c │ ├── simple_coder.h │ ├── simple_decoder.c │ ├── simple_decoder.h │ ├── simple_private.h │ ├── sparc.c │ └── x86.c ├── lua ├── Makefile ├── README ├── doc │ ├── contents.html │ ├── logo.gif │ ├── lua.1 │ ├── lua.css │ ├── luac.1 │ ├── manual.css │ ├── manual.html │ ├── osi-certified-72x60.png │ └── readme.html └── src │ ├── Makefile │ ├── lapi.c │ ├── lapi.h │ ├── lauxlib.c │ ├── lauxlib.h │ ├── lbaselib.c │ ├── lbitlib.c │ ├── lcode.c │ ├── lcode.h │ ├── lcorolib.c │ ├── lctype.c │ ├── lctype.h │ ├── ldblib.c │ ├── ldebug.c │ ├── ldebug.h │ ├── ldo.c │ ├── ldo.h │ ├── ldump.c │ ├── lfunc.c │ ├── lfunc.h │ ├── lgc.c │ ├── lgc.h │ ├── linit.c │ ├── liolib.c │ ├── llex.c │ ├── llex.h │ ├── llimits.h │ ├── lmathlib.c │ ├── lmem.c │ ├── lmem.h │ ├── loadlib.c │ ├── lobject.c │ ├── lobject.h │ ├── lopcodes.c │ ├── lopcodes.h │ ├── loslib.c │ ├── lparser.c │ ├── lparser.h │ ├── lstate.c │ ├── lstate.h │ ├── lstring.c │ ├── lstring.h │ ├── lstrlib.c │ ├── ltable.c │ ├── ltable.h │ ├── ltablib.c │ ├── ltm.c │ ├── ltm.h │ ├── lua.c │ ├── lua.h │ ├── lua.hpp │ ├── luac.c │ ├── luaconf.h │ ├── lualib.h │ ├── lundump.c │ ├── lundump.h │ ├── lvm.c │ ├── lvm.h │ ├── lzio.c │ └── lzio.h ├── lua_glue.c ├── lua_glue.h ├── meta └── xdg-utils │ ├── xdg-desktop-menu │ └── xdg-open ├── miniz.c ├── miniz.h ├── misc ├── FindCurses.cmake ├── MacAppBundleSkeleton │ └── Contents │ │ ├── Info.plist │ │ ├── PkgInfo │ │ └── Resources │ │ └── mojosetup.icns ├── MojoSetup.xib ├── cp.cmake ├── find_localizable_strings.sh ├── launchpad-import.sh ├── localization2pot.pl ├── make_self_extracting.c ├── po2localization.pl └── shrinksh.pl ├── mojosetup.c ├── platform.h ├── platform_beos.cpp ├── platform_unix.c ├── platform_windows.c ├── scripts ├── app_localization.lua ├── config.lua ├── localization.lua ├── mojosetup_init.lua └── mojosetup_mainline.lua ├── stb_image.c └── universal.h /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [icculus] 2 | patreon: icculus 3 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | Build: 7 | name: ${{ matrix.platform.name }} 8 | runs-on: ${{ matrix.platform.os }} 9 | strategy: 10 | matrix: 11 | platform: 12 | - { name: Linux, os: ubuntu-20.04, flags: -GNinja } 13 | #- { name: Windows, os: windows-latest } 14 | #- { name: MacOS, os: macos-latest } 15 | steps: 16 | - name: Setup Linux dependencies 17 | if: runner.os == 'Linux' 18 | run: | 19 | sudo apt-get update 20 | sudo apt-get install cmake ninja-build libgtk2.0-dev libgtk-3-dev libncursesw5-dev 21 | - name: Get mojosetup sources 22 | uses: actions/checkout@v3 23 | - name: Configure CMake 24 | run: cmake -B build ${{ matrix.platform.flags }} 25 | - name: Build 26 | run: cmake --build build/ 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | cmake-build 2 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006-2021 Ryan C. Gordon . 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | 19 | 20 | (Please note that other pieces of code in MojoSetup fall under BSD-like and/or 21 | public domain licenses: lua, libfetch, zlib, bzlib, liblzma, stb_image, etc. 22 | All software statically linked to MojoSetup was explicitly chosen to be 23 | friendly with closed-source software, in case the installer needs a 24 | proprietary change. I am not a lawyer and this is not legal advice. Please 25 | have a lawyer consider the licenses if you have any concerns.) 26 | 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MojoSetup 2 | 3 | MojoSetup is a standalone installer for Linux, designed to help third-party 4 | developers that need to ship software outside of traditional package 5 | management infrastructure. 6 | 7 | The long, technical explanation of features and design can be read 8 | [in the original announcement email](https://icculus.org/pipermail/lokisetup/2007-May/000810.html). 9 | 10 | **We always need help with localization!** If you can contribute a sentence or 11 | two of translation from English to your native language, we are extremely 12 | grateful. You can do this [at launchpad.net](https://translations.launchpad.net/mojosetup/). 13 | 14 | Please read docs.txt for all the gritty details about building an installer. 15 | -------------------------------------------------------------------------------- /buildver.c: -------------------------------------------------------------------------------- 1 | /** 2 | * MojoSetup; a portable, flexible installation application. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | /* 10 | * This is in a separate file so that we can recompile it every time 11 | * without it forcing a recompile on something ccache would otherwise not 12 | * have to rebuild...this file's checksum changes every time you build it 13 | * due to the __DATE__ and __TIME__ macros. 14 | * 15 | * The makefile will rebuild this file every time it relinks an executable 16 | * so that we'll always have a unique build string. 17 | * 18 | * APPNAME and APPREV need to be predefined in the build system. 19 | * The rest are supposed to be supplied by the compiler. 20 | */ 21 | 22 | #ifndef APPID 23 | #error Please define APPID in the build system. 24 | #endif 25 | 26 | #ifndef APPREV 27 | #error Please define APPREV in the build system. 28 | #endif 29 | 30 | #if (defined __clang__) 31 | # define VERSTR2(x) #x 32 | # define VERSTR(x) VERSTR2(x) 33 | # define COMPILERVER " " VERSTR(__clang_major__) "." VERSTR(__clang_minor__) "." VERSTR(__clang_patchlevel__) 34 | #elif (defined __GNUC__) 35 | # define VERSTR2(x) #x 36 | # define VERSTR(x) VERSTR2(x) 37 | # define COMPILERVER " " VERSTR(__GNUC__) "." VERSTR(__GNUC_MINOR__) "." VERSTR(__GNUC_PATCHLEVEL__) 38 | #elif (defined __SUNPRO_C) 39 | # define VERSTR2(x) #x 40 | # define VERSTR(x) VERSTR2(x) 41 | # define COMPILERVER " " VERSTR(__SUNPRO_C) 42 | #elif (defined __VERSION__) 43 | # define COMPILERVER " " __VERSION__ 44 | #else 45 | # define COMPILERVER "" 46 | #endif 47 | 48 | #ifndef __DATE__ 49 | #define __DATE__ "(Unknown build date)" 50 | #endif 51 | 52 | #ifndef __TIME__ 53 | #define __TIME__ "(Unknown build time)" 54 | #endif 55 | 56 | #ifndef COMPILER 57 | #if (defined __clang__) && defined(__apple_build_version__) // Apple reports version differently than LLVM Clang, note difference here. 58 | #define COMPILER "Apple Clang" 59 | #elif (defined __clang__) 60 | #define COMPILER "Clang" 61 | #elif (defined __GNUC__) 62 | #define COMPILER "GCC" 63 | #elif (defined _MSC_VER) 64 | #define COMPILER "Visual Studio" 65 | #elif (defined __SUNPRO_C) 66 | #define COMPILER "Sun Studio" 67 | #else 68 | #error Please define your platform. 69 | #endif 70 | #endif 71 | 72 | // macro mess so we can turn APPID and APPREV into a string literal... 73 | #define MAKEBUILDVERSTRINGLITERAL2(id, rev) \ 74 | #id ", revision " #rev ", built " __DATE__ " " __TIME__ \ 75 | ", by " COMPILER COMPILERVER 76 | 77 | #define MAKEBUILDVERSTRINGLITERAL(id, rev) MAKEBUILDVERSTRINGLITERAL2(id, rev) 78 | 79 | const char *GBuildVer = MAKEBUILDVERSTRINGLITERAL(APPID, APPREV); 80 | 81 | // end of buildver.c ... 82 | 83 | -------------------------------------------------------------------------------- /bzip2/version.txt: -------------------------------------------------------------------------------- 1 | bzip2-1.0.6 2 | -------------------------------------------------------------------------------- /checksum_crc32.c: -------------------------------------------------------------------------------- 1 | /** 2 | * MojoSetup; a portable, flexible installation application. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #include "universal.h" 10 | 11 | #if SUPPORT_CRC32 12 | 13 | void MojoCrc32_init(MojoCrc32 *context) 14 | { 15 | *context = (MojoCrc32) 0xFFFFFFFF; 16 | } // MojoCrc32_init 17 | 18 | 19 | void MojoCrc32_append(MojoCrc32 *_crc, const uint8 *buf, uint32 len) 20 | { 21 | uint32 crc = (uint32) *_crc; 22 | 23 | uint32 n; 24 | for (n = 0; n < len; n++) 25 | { 26 | uint32 xorval = (uint32) ((crc ^ buf[n]) & 0xFF); 27 | xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); 28 | xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); 29 | xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); 30 | xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); 31 | xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); 32 | xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); 33 | xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); 34 | xorval = ((xorval & 1) ? (0xEDB88320 ^ (xorval >> 1)) : (xorval >> 1)); 35 | crc = xorval ^ (crc >> 8); 36 | } // for 37 | 38 | *_crc = (MojoCrc32) crc; 39 | } // MojoCrc32_append 40 | 41 | 42 | void MojoCrc32_finish(MojoCrc32 *context, uint32 *digest) 43 | { 44 | *digest = (*context ^ 0xFFFFFFFF); 45 | } // MojoCrc32_finish 46 | 47 | 48 | #endif // SUPPORT_CRC32 49 | 50 | #if TEST_CRC32 51 | int main(int argc, char **argv) 52 | { 53 | int i = 0; 54 | for (i = 1; i < argc; i++) 55 | { 56 | FILE *in = NULL; 57 | MojoCrc32 ctx; 58 | MojoCrc32_init(&ctx); 59 | in = fopen(argv[i], "rb"); 60 | if (!in) 61 | perror("fopen"); 62 | else 63 | { 64 | uint32 digest = 0; 65 | int err = 0; 66 | while ( (!err) && (!feof(in)) ) 67 | { 68 | uint8 buf[1024]; 69 | size_t rc = fread(buf, 1, sizeof (buf), in); 70 | if (rc > 0) 71 | MojoCrc32_append(&ctx, buf, rc); 72 | err = ferror(in); 73 | } // while 74 | 75 | if (err) 76 | perror("fread"); 77 | fclose(in); 78 | MojoCrc32_finish(&ctx, &digest); 79 | if (!err) 80 | printf("%s: %X\n", argv[i], (unsigned int) digest); 81 | } // else 82 | } // for 83 | 84 | return 0; 85 | } // main 86 | #endif 87 | 88 | // end of checksum_crc32.c ... 89 | 90 | -------------------------------------------------------------------------------- /examples/aquaria/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Aquaria Installer" 2 | DATAFILE="data/_mods/jukebox.xml" 3 | -------------------------------------------------------------------------------- /examples/aquaria/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/aquaria/meta/splash.bmp -------------------------------------------------------------------------------- /examples/aquaria/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Uninstall complete"] = { 7 | en = "Uninstall complete. You may also delete '.Aquaria' in your home directory to remove personal savegames and settings.", 8 | de = "Deinstallation komplett. Du kannst auch '.Aquaria' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.", 9 | es = "Desinstalación completa. Puedes borrar '.Aquaria' en tu directorio home para borrar configuraciones personales y tus juegos grabados.", 10 | pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć '.Aquaria' z domowego katalogu.", 11 | it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella '.Aquaria' nella tua directory home.", 12 | }; 13 | 14 | ["Aquaria README"] = { 15 | de = "Aquaria-README", 16 | es = "LEEME", 17 | pl = "Aquaria README", 18 | it = "Informazioni su Aquaria", 19 | }; 20 | 21 | ["Aquaria License"] = { 22 | en_GB = "Aquaria Licence", 23 | en_CA = "Aquaria Licence", 24 | de = "Aquaria-Lizenz", 25 | es = "Licencia de uso de Aquaria", 26 | pl = "Licencja Aquaria", 27 | it = "Licenza di Aquaria", 28 | }; 29 | 30 | }; 31 | 32 | -- end of app_localization.lua ... 33 | 34 | -------------------------------------------------------------------------------- /examples/aquaria/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 227436679; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "bit-blot.com", 8 | id = "aquaria", 9 | description = "Aquaria", 10 | version = "1.1.3", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("Aquaria README"), 25 | source = _("README-linux.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | value = true, 31 | required = true, 32 | disabled = false, 33 | bytes = TOTAL_INSTALL_SIZE, 34 | description = "Aquaria", 35 | 36 | Setup.File 37 | { 38 | -- Just install everything we see... 39 | }, 40 | 41 | Setup.DesktopMenuItem 42 | { 43 | disabled = false, 44 | name = "Aquaria", 45 | genericname = "Aquaria", 46 | tooltip = _("Underwater exploration adventure video game"), 47 | builtin_icon = false, 48 | icon = "aquaria.png", 49 | commandline = "%0/aquaria", 50 | category = "Game" 51 | } 52 | } 53 | } 54 | 55 | -- end of config.lua ... 56 | 57 | -------------------------------------------------------------------------------- /examples/braid/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Braid Installer" 2 | DATAFILE="data/gamedata/data/package0.zip" 3 | -------------------------------------------------------------------------------- /examples/braid/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/braid/meta/splash.bmp -------------------------------------------------------------------------------- /examples/braid/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Uninstall complete"] = { 7 | en = "Uninstall complete. You may also delete '.Braid' in your home directory to remove personal savegames and settings.", 8 | de = "Deinstallation komplett. Du kannst auch '.Braid' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.", 9 | es = "Desinstalación completa. Puedes borrar '.Braid' en tu directorio home para borrar configuraciones personales y tus juegos grabados.", 10 | pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć '.Braid' z domowego katalogu.", 11 | it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella '.Braid' nella tua directory home.", 12 | }; 13 | 14 | ["Braid README"] = { 15 | de = "Braid-README", 16 | es = "LEEME", 17 | pl = "Braid README", 18 | it = "Informazioni su Braid", 19 | }; 20 | }; 21 | 22 | -- end of app_localization.lua ... 23 | 24 | -------------------------------------------------------------------------------- /examples/cogs/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Cogs Installer" 2 | DATAFILE="data/data/pipes/pipe01i-valve.strip" 3 | -------------------------------------------------------------------------------- /examples/cogs/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/cogs/meta/splash.bmp -------------------------------------------------------------------------------- /examples/cogs/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Uninstall complete"] = { 7 | en = "Uninstall complete. You may also delete 'Cogs' in your home directory to remove personal savegames and settings.", 8 | de = "Deinstallation komplett. Du kannst auch 'Cogs' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.", 9 | es = "Desinstalación completa. Puedes borrar 'Cogs' en tu directorio home para borrar configuraciones personales y tus juegos grabados.", 10 | pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć 'Cogs' z domowego katalogu.", 11 | it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella 'Cogs' nella tua directory home.", 12 | }; 13 | 14 | ["Cogs README"] = { 15 | de = "Cogs-README", 16 | es = "LEEME", 17 | pl = "Cogs README", 18 | it = "Informazioni su Cogs", 19 | }; 20 | }; 21 | 22 | -- end of app_localization.lua ... 23 | 24 | -------------------------------------------------------------------------------- /examples/cogs/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 308206076; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "lazy8studios.com", 8 | id = "cogs", 9 | description = "Cogs", 10 | version = "1.0", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("Cogs README"), 25 | source = _("README-linux.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | -- !!! FIXME: All this filter nonsense is because 31 | -- !!! FIXME: source = "base:///some_dir_in_basepath/" 32 | -- !!! FIXME: doesn't work, since it wants a file when drilling 33 | -- !!! FIXME: for the final archive, not a directory. Fixing this 34 | -- !!! FIXME: properly is a little awkward, though. 35 | 36 | value = true, 37 | required = true, 38 | disabled = false, 39 | bytes = TOTAL_INSTALL_SIZE, 40 | description = "Cogs", 41 | 42 | Setup.File 43 | { 44 | wildcards = "*"; 45 | }, 46 | 47 | Setup.DesktopMenuItem 48 | { 49 | disabled = false, 50 | name = "Cogs", 51 | genericname = "Cogs", 52 | tooltip = _("A steampunk puzzle game"), 53 | builtin_icon = false, 54 | icon = "cogs.png", 55 | commandline = "%0/Cogs", 56 | workingdir = "%0", 57 | category = "Game" 58 | } 59 | } 60 | } 61 | 62 | -- end of config.lua ... 63 | 64 | -------------------------------------------------------------------------------- /examples/dearesther/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Dear Esther Installer" 2 | DATAFILE="data/dearesther/dearesther.fgd" 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/dearesther/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/dearesther/meta/splash.bmp -------------------------------------------------------------------------------- /examples/dearesther/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Dear Esther README"] = { 7 | de = "Dear Esther-README", 8 | es = "LEEME", 9 | pl = "Dear Esther README", 10 | it = "Informazioni su Dear Esther", 11 | }; 12 | }; 13 | 14 | -- end of app_localization.lua ... 15 | 16 | -------------------------------------------------------------------------------- /examples/duke3d/data/duke3d.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/duke3d/data/duke3d.png -------------------------------------------------------------------------------- /examples/duke3d/data/duke3d_readme.txt: -------------------------------------------------------------------------------- 1 | 2 | What is this? 3 | 4 | This is icculus.org's port of Duke Nukem 3D. 5 | 6 | The included installer can use the PC retail version of the game (the 7 | "Atomic Edition"). If you don't have a retail disc, the installer can 8 | also install the shareware data files, which leaves you with only 9 | episode one, and various other shareware nagging. 10 | 11 | Retail discs can be found on eBay or in bargain bins for dirt cheap. 12 | 3DRealms actually did a new print run of discs in 2003 or so, and as of 13 | this writing, sells them from their online store at 14 | 15 | http://www.3drealms.com/ 16 | 17 | Duke3D is not "Abandonware"...please do not pirate the game! There are 18 | several legitimate channels to obtain a copy of the retail version. 19 | 20 | We do not provide support for this version of Duke3D, nor will 3DRealms. 21 | We accept bug reports here... 22 | 23 | https://bugzilla.icculus.org/ 24 | 25 | ...but don't promise to ever act on them. If it breaks, you get to keep 26 | both shiny pieces. 27 | 28 | The editor is not necessarily obvious to use, but basically works like 29 | the DOS version, so you can get the old school manual off the Internet. 30 | 31 | Networking is included, but is flakey, so we're not documenting it 32 | here. Google might turn up some info for the brave. 33 | 34 | 35 | Special thanks: 36 | 37 | 3DRealms and Ken Silverman for releasing the Duke/Build sources. 38 | I hope we've all lived up to your expectations! 39 | 40 | Dirk for the help with the French MacSoft disc 41 | Adam Betts for the disc image graphics and icons 42 | Forrest Walter for the installer splash graphic 43 | Steven Fuller for picking at the MacSoft installer format and all the 44 | porting work 45 | Dan Olson for months battling Build. 46 | The rest of the duke/rott/build crew 47 | The icculus.org Mac Ninjas 48 | Many others, thanks! 49 | 50 | --ryan. 51 | 52 | 53 | Changelog: 54 | 55 | 05122007: Initial release. 56 | 57 | -------------------------------------------------------------------------------- /examples/duke3d/data/mojosetup_readme.txt: -------------------------------------------------------------------------------- 1 | 2 | This is MojoSetup, a new installer application. 3 | 4 | This is a work in progress, so if you download this same installer later, 5 | it may look radically different, or work better or worse. 6 | 7 | We are using this Duke3D installation as an initial testbed for MojoSetup. 8 | 9 | Please report bugs and irritations in this installer to Ryan: 10 | 11 | icculus@icculus.org 12 | 13 | 14 | All suggestions are welcome. 15 | 16 | Please make sure you have the latest copy of this installer: 17 | 18 | http://icculus.org/mojosetup/example/duke3d/ 19 | 20 | 21 | Please note that bug reports about Duke Nukem 3D are also welcome, but this 22 | isn't an officially supported build. Don't expect game fixes from either 23 | Ryan or 3DRealms for this build. Source code to Duke3D is here: 24 | 25 | http://icculus.org/duke3d/ 26 | 27 | 28 | There is still a lot to be done with MojoSetup. Check back often! 29 | 30 | Enjoy, 31 | --ryan. 32 | 33 | 34 | CHANGELOG: 35 | 36 | 05122007: Initial release. 37 | 38 | -------------------------------------------------------------------------------- /examples/duke3d/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Duke Nukem 3D Installer" 2 | DATAFILE="data/duke3d.png" 3 | NEEDHTTP=1 4 | 5 | -------------------------------------------------------------------------------- /examples/duke3d/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/duke3d/meta/splash.bmp -------------------------------------------------------------------------------- /examples/duke3d/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | -- Window title when showing the GPL. 7 | ["GNU General Public License"] = { 8 | }; 9 | 10 | -- As you add GPL translations, change the filename here. 11 | ["gpl.txt"] = { 12 | }; 13 | 14 | -- Window title when showing game's README file. 15 | ["Duke Nukem 3D README"] = { 16 | }; 17 | 18 | -- As you add README translations, change the filename here. 19 | ["duke3d_readme.txt"] = { 20 | }; 21 | 22 | -- Window title when showing MojoSetup README file. 23 | ["Duke Nukem 3D README"] = { 24 | }; 25 | 26 | -- As you add README translations, change the filename here. 27 | ["mojosetup_readme.txt"] = { 28 | }; 29 | 30 | -- Name of disc published by MacSoft (as in "Please insert 'Disc Name'") 31 | ["MacSoft Duke3D CD-ROM"] = { 32 | }; 33 | 34 | -- Name of disc published for DOS (as in "Please insert 'Disc Name'") 35 | ["PC Atomic Edition CD-ROM"] = { 36 | }; 37 | 38 | -- Name of option section. 39 | ["Installation type"] = { 40 | }; 41 | 42 | -- This is a kind of useless tooltip; I'm just using it for testing. 43 | -- This is a command to the user. 44 | ["Pick your installation type"] = { 45 | }; 46 | 47 | -- One possible installation option that user can click. 48 | ["Install Shareware version"] = { 49 | }; 50 | 51 | -- Tooltip text for "Install Shareware version". 52 | ["This does not need a retail copy of the game. It's free!"] = { 53 | }; 54 | 55 | -- One possible installation option that user can click. 56 | ["Install full game from Atomic Edition disc"] = { 57 | }; 58 | 59 | -- Tooltip text for "Install full game from Atomic Edition disc". 60 | ["Pick this if you have a retail game disc from 3DRealms."] = { 61 | }; 62 | 63 | -- One possible installation option that user can click. 64 | ["Install full game from MacSoft disc"] = { 65 | }; 66 | 67 | -- Tooltip text for "Install full game from MacSoft disc". 68 | ["Pick this if you have a retail game disc from MacSoft."] = { 69 | }; 70 | }; 71 | 72 | -- end of app_localization.lua ... 73 | 74 | -------------------------------------------------------------------------------- /examples/dungeondefenders/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Dungeon Defenders Installer" 2 | DATAFILE="data/UDKGame/Config/DefaultDunDef.ini" 3 | 4 | -------------------------------------------------------------------------------- /examples/dungeondefenders/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/dungeondefenders/meta/splash.bmp -------------------------------------------------------------------------------- /examples/dungeondefenders/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Dungeon Defenders README"] = { 7 | de = "Dungeon Defenders-README", 8 | es = "LEEME", 9 | pl = "Dungeon Defenders README", 10 | it = "Informazioni su Dungeon Defenders", 11 | }; 12 | }; 13 | 14 | -- end of app_localization.lua ... 15 | 16 | -------------------------------------------------------------------------------- /examples/dungeondefenders/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 6027721827; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "trendyent.com", 8 | id = "dungeondefenders", 9 | description = "Dungeon Defenders", 10 | version = "7.48", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("Dungeon Defenders README"), 25 | source = _("README-linux.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | -- !!! FIXME: All this filter nonsense is because 31 | -- !!! FIXME: source = "base:///some_dir_in_basepath/" 32 | -- !!! FIXME: doesn't work, since it wants a file when drilling 33 | -- !!! FIXME: for the final archive, not a directory. Fixing this 34 | -- !!! FIXME: properly is a little awkward, though. 35 | 36 | value = true, 37 | required = true, 38 | disabled = false, 39 | bytes = TOTAL_INSTALL_SIZE, 40 | description = "Dungeon Defenders", 41 | 42 | Setup.File 43 | { 44 | wildcards = "*"; 45 | filter = function(dest) 46 | if dest == "DungeonDefenders" then 47 | return dest, "0755" -- make sure it's executable. 48 | end 49 | if dest == "UDKGame/Binaries/DungeonDefenders-x86" then 50 | return dest, "0755" -- make sure it's executable. 51 | end 52 | if dest == "UDKGame/Binaries/libSDL2-2.0.so.0" then 53 | return dest, "0755" -- make sure it's executable. 54 | end 55 | if dest == "UDKGame/Binaries/libopenal.so.1" then 56 | return dest, "0755" -- make sure it's executable. 57 | end 58 | if dest == "UDKGame/Binaries/xdg-open" then 59 | return dest, "0755" -- make sure it's executable. 60 | end 61 | return dest -- everything else just goes through as-is. 62 | end 63 | }, 64 | 65 | Setup.DesktopMenuItem 66 | { 67 | disabled = false, 68 | name = "Dungeon Defenders", 69 | genericname = "Dungeon Defenders", 70 | tooltip = _("Dungeon Defenders"), 71 | builtin_icon = false, 72 | icon = "DunDefIcon.png", 73 | commandline = "%0/DungeonDefenders", 74 | workingdir = "%0", 75 | category = "Game" 76 | } 77 | } 78 | } 79 | 80 | -- end of config.lua ... 81 | 82 | -------------------------------------------------------------------------------- /examples/hammerfight/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Hammerfight Installer" 2 | DATAFILE="data/Objects/Weapons/blade_hisaian.seria" 3 | -------------------------------------------------------------------------------- /examples/hammerfight/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/hammerfight/meta/splash.bmp -------------------------------------------------------------------------------- /examples/hammerfight/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Uninstall complete"] = { 7 | en = "Uninstall complete. You may also delete 'Hammerfight' in your home directory to remove personal savegames and settings.", 8 | de = "Deinstallation komplett. Du kannst auch 'Hammerfight' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.", 9 | es = "Desinstalación completa. Puedes borrar 'Hammerfight' en tu directorio home para borrar configuraciones personales y tus juegos grabados.", 10 | pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć 'Hammerfight' z domowego katalogu.", 11 | it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella 'Hammerfight' nella tua directory home.", 12 | }; 13 | 14 | ["Hammerfight README"] = { 15 | de = "Hammerfight-README", 16 | es = "LEEME", 17 | pl = "Hammerfight README", 18 | it = "Informazioni su Hammerfight", 19 | }; 20 | }; 21 | 22 | -- end of app_localization.lua ... 23 | 24 | -------------------------------------------------------------------------------- /examples/hammerfight/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 126978833; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "kranx.com", 8 | id = "hammerfight", 9 | description = "Hammerfight", 10 | version = "1.0", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("Hammerfight README"), 25 | source = _("README-linux.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | -- !!! FIXME: All this filter nonsense is because 31 | -- !!! FIXME: source = "base:///some_dir_in_basepath/" 32 | -- !!! FIXME: doesn't work, since it wants a file when drilling 33 | -- !!! FIXME: for the final archive, not a directory. Fixing this 34 | -- !!! FIXME: properly is a little awkward, though. 35 | 36 | value = true, 37 | required = true, 38 | disabled = false, 39 | bytes = TOTAL_INSTALL_SIZE, 40 | description = "Hammerfight", 41 | 42 | Setup.File 43 | { 44 | wildcards = "*"; 45 | }, 46 | 47 | Setup.DesktopMenuItem 48 | { 49 | disabled = false, 50 | name = "Hammerfight", 51 | genericname = "Hammerfight", 52 | tooltip = _("A game of flying, battling machines"), 53 | builtin_icon = false, 54 | icon = "hammerfight.png", 55 | commandline = "%0/Hammerfight", 56 | workingdir = "%0", 57 | category = "Game" 58 | } 59 | } 60 | } 61 | 62 | -- end of config.lua ... 63 | 64 | -------------------------------------------------------------------------------- /examples/limbo/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="LIMBO Installer" 2 | DATAFILE="data/limbo_mac_runtime.pkg" 3 | 4 | 5 | -------------------------------------------------------------------------------- /examples/limbo/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/limbo/meta/splash.bmp -------------------------------------------------------------------------------- /examples/limbo/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 113202507; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "limbogame.org", 8 | id = "limbo", 9 | description = "LIMBO", 10 | version = "1.0", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("LIMBO README"), 25 | source = _("README-linux.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | -- !!! FIXME: All this filter nonsense is because 31 | -- !!! FIXME: source = "base:///some_dir_in_basepath/" 32 | -- !!! FIXME: doesn't work, since it wants a file when drilling 33 | -- !!! FIXME: for the final archive, not a directory. Fixing this 34 | -- !!! FIXME: properly is a little awkward, though. 35 | 36 | value = true, 37 | required = true, 38 | disabled = false, 39 | bytes = TOTAL_INSTALL_SIZE, 40 | description = "LIMBO", 41 | 42 | Setup.File 43 | { 44 | wildcards = "*"; 45 | }, 46 | 47 | Setup.DesktopMenuItem 48 | { 49 | disabled = false, 50 | name = "LIMBO", 51 | genericname = "LIMBO", 52 | tooltip = _("Uncertain of his sister's fate, a boy enters LIMBO"), 53 | builtin_icon = false, 54 | icon = "limbo.png", 55 | commandline = "%0/limbo", 56 | workingdir = "%0", 57 | category = "Game" 58 | } 59 | } 60 | } 61 | 62 | -- end of config.lua ... 63 | 64 | -------------------------------------------------------------------------------- /examples/lugaru/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Lugaru Installer" 2 | DATAFILE="data/Data/Animations/Rabbitkick" 3 | -------------------------------------------------------------------------------- /examples/lugaru/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/lugaru/meta/splash.bmp -------------------------------------------------------------------------------- /examples/lugaru/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Uninstall complete"] = { 7 | en = "Uninstall complete. You may also delete '.lugaru' in your home directory to remove personal savegames and settings.", 8 | de = "Deinstallation komplett. Du kannst auch '.lugaru' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.", 9 | es = "Desinstalación completa. Puedes borrar '.lugaru' en tu directorio home para borrar configuraciones personales y tus juegos grabados.", 10 | pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć '.lugaru' z domowego katalogu.", 11 | it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella '.lugaru' nella tua directory home.", 12 | }; 13 | 14 | ["Lugaru README"] = { 15 | de = "Lugaru-README", 16 | es = "LEEME", 17 | pl = "Lugaru README", 18 | it = "Informazioni su Lugaru", 19 | }; 20 | 21 | ["Lugaru License"] = { 22 | en_GB = "Lugaru Licence", 23 | en_CA = "Lugaru Licence", 24 | de = "Lugaru-Lizenz", 25 | es = "Licencia de uso de Lugaru", 26 | pl = "Licencja Lugaru", 27 | it = "Licenza di Lugaru", 28 | }; 29 | 30 | }; 31 | 32 | -- end of app_localization.lua ... 33 | 34 | -------------------------------------------------------------------------------- /examples/lugaru/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 37997185; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "wolfire.com", 8 | id = "lugaru", 9 | description = _("Lugaru: The Rabbit's Foot"), 10 | version = "1.0d", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("Lugaru README"), 25 | source = _("README-linux.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | value = true, 31 | required = true, 32 | disabled = false, 33 | bytes = TOTAL_INSTALL_SIZE, 34 | description = _("Lugaru: The Rabbit's Foot"), 35 | 36 | Setup.File 37 | { 38 | -- Just install everything we see... 39 | }, 40 | 41 | Setup.DesktopMenuItem 42 | { 43 | disabled = false, 44 | name = _("Lugaru"), 45 | genericname = _("Lugaru"), 46 | tooltip = _("Kung-Fu Rabbit Adventure Video Game"), 47 | builtin_icon = false, 48 | icon = "lugaru.png", 49 | commandline = "%0/lugaru", 50 | category = "Game" 51 | } 52 | } 53 | } 54 | 55 | -- end of config.lua ... 56 | 57 | -------------------------------------------------------------------------------- /examples/postal1/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Postal 1 Installer" 2 | DATAFILE="data/res/hoods/ghetto.sak" 3 | -------------------------------------------------------------------------------- /examples/postal1/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/postal1/meta/splash.bmp -------------------------------------------------------------------------------- /examples/postal1/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Uninstall complete"] = { 7 | en = "Uninstall complete. You may also delete '.postal1' in your home directory to remove personal savegames and settings.", 8 | de = "Deinstallation komplett. Du kannst auch '.postal1' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.", 9 | es = "Desinstalación completa. Puedes borrar '.postal1' en tu directorio home para borrar configuraciones personales y tus juegos grabados.", 10 | pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć '.postal1' z domowego katalogu.", 11 | it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella '.postal1' nella tua directory home.", 12 | }; 13 | 14 | ["Postal README"] = { 15 | de = "Postal-README", 16 | es = "LEEME", 17 | pl = "Postal README", 18 | it = "Informazioni su Postal", 19 | }; 20 | 21 | ["Postal License"] = { 22 | en_GB = "Postal Licence", 23 | en_CA = "Postal Licence", 24 | de = "Postal-Lizenz", 25 | es = "Licencia de uso de Postal", 26 | pl = "Licencja Postal", 27 | it = "Licenza di Postal", 28 | }; 29 | 30 | }; 31 | 32 | -- end of app_localization.lua ... 33 | 34 | -------------------------------------------------------------------------------- /examples/postal1/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 245613846; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "runningwithscissors.com", 8 | id = "postal1", 9 | description = _("Postal 1"), 10 | version = "1.0", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | postinstall = function(package) 23 | MojoSetup.launchbrowser(MojoSetup.destination .. "/postal1_guide.html") 24 | end, 25 | 26 | Setup.Eula 27 | { 28 | description = _("Postal License"), 29 | source = _("postal1_license.txt") 30 | }, 31 | 32 | Setup.Option 33 | { 34 | value = true, 35 | required = true, 36 | disabled = false, 37 | bytes = TOTAL_INSTALL_SIZE, 38 | description = _("Postal 1"), 39 | 40 | Setup.File 41 | { 42 | -- Just install everything we see... 43 | }, 44 | 45 | Setup.DesktopMenuItem 46 | { 47 | disabled = false, 48 | name = _("Postal 1"), 49 | genericname = _("Postal 1"), 50 | tooltip = _("Politically incorrect shoot-em-up from Running With Scissors"), 51 | builtin_icon = false, 52 | icon = "rws.png", 53 | commandline = "%0/postal1", 54 | category = "Game" 55 | } 56 | } 57 | } 58 | 59 | -- end of config.lua ... 60 | 61 | -------------------------------------------------------------------------------- /examples/postal2/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Postal 2: Share the Pain Installer" 2 | DATAFILE="data/System/postal2-bin" 3 | -------------------------------------------------------------------------------- /examples/postal2/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/postal2/meta/splash.bmp -------------------------------------------------------------------------------- /examples/postal2/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Uninstall complete"] = { 7 | en = "Uninstall complete. You may also delete '.postal2' in your home directory to remove personal savegames and settings.", 8 | de = "Deinstallation komplett. Du kannst auch '.postal2' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.", 9 | es = "Desinstalación completa. Puedes borrar '.postal2' en tu directorio home para borrar configuraciones personales y tus juegos grabados.", 10 | pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć '.postal2' z domowego katalogu.", 11 | it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella '.postal2' nella tua directory home.", 12 | }; 13 | 14 | ["Postal README"] = { 15 | de = "Postal-README", 16 | es = "LEEME", 17 | pl = "Postal README", 18 | it = "Informazioni su Postal", 19 | }; 20 | 21 | ["Postal License"] = { 22 | en_GB = "Postal Licence", 23 | en_CA = "Postal Licence", 24 | de = "Postal-Lizenz", 25 | es = "Licencia de uso de Postal", 26 | pl = "Licencja Postal", 27 | it = "Licenza di Postal", 28 | }; 29 | 30 | }; 31 | 32 | -- end of app_localization.lua ... 33 | 34 | -------------------------------------------------------------------------------- /examples/postal2/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 1401484620; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "runningwithscissors.com", 8 | id = "postal2", 9 | description = _("Postal 2: Share the Pain"), 10 | version = "1.0", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Eula 23 | { 24 | description = _("Postal License"), 25 | source = _("postal2_license.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | value = true, 31 | required = true, 32 | disabled = false, 33 | bytes = TOTAL_INSTALL_SIZE, 34 | description = _("Postal 2: Share the Pain"), 35 | 36 | Setup.File 37 | { 38 | -- Just install everything we see... 39 | }, 40 | 41 | Setup.DesktopMenuItem 42 | { 43 | disabled = false, 44 | name = _("Postal 2: Share the Pain"), 45 | genericname = _("Postal 2"), 46 | tooltip = _("Politically incorrect first person shooter from Running With Scissors"), 47 | builtin_icon = false, 48 | icon = "rws.png", 49 | commandline = "%0/postal2", 50 | category = "Game" 51 | } 52 | } 53 | } 54 | 55 | -- end of config.lua ... 56 | 57 | -------------------------------------------------------------------------------- /examples/postal2aw/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Postal 2: Apocalypse Weekend Installer" 2 | DATAFILE="data/ApocalypseWeekend/System/AW7FX.u" 3 | -------------------------------------------------------------------------------- /examples/postal2aw/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/postal2aw/meta/splash.bmp -------------------------------------------------------------------------------- /examples/postal2aw/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Uninstall complete"] = { 7 | en = "Uninstall complete. You may also delete '.postal2' in your home directory to remove personal savegames and settings.", 8 | de = "Deinstallation komplett. Du kannst auch '.postal2' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.", 9 | es = "Desinstalación completa. Puedes borrar '.postal2' en tu directorio home para borrar configuraciones personales y tus juegos grabados.", 10 | pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć '.postal2' z domowego katalogu.", 11 | it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella '.postal2' nella tua directory home.", 12 | }; 13 | 14 | ["Postal README"] = { 15 | de = "Postal-README", 16 | es = "LEEME", 17 | pl = "Postal README", 18 | it = "Informazioni su Postal", 19 | }; 20 | 21 | ["Postal License"] = { 22 | en_GB = "Postal Licence", 23 | en_CA = "Postal Licence", 24 | de = "Postal-Lizenz", 25 | es = "Licencia de uso de Postal", 26 | pl = "Licencja Postal", 27 | it = "Licenza di Postal", 28 | }; 29 | 30 | }; 31 | 32 | -- end of app_localization.lua ... 33 | 34 | -------------------------------------------------------------------------------- /examples/postal2aw/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 886535138; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | -- We override MojoSetup.gui.destination to make sure we have a real p2:stp 6 | -- install at that point. This happens to work at the moment, but hooks an 7 | -- internal, undocumented API. We'll add a formal hook later. Don't emulate 8 | -- this behaviour! 9 | local origdestfn = MojoSetup.gui.destination 10 | MojoSetup.gui.destination = function(recommend, thisstage, maxstage) 11 | -- Trim the game id off of the recommends... 12 | local newrec = nil 13 | if recommend ~= nil then 14 | newrec = {} 15 | for i,v in ipairs(recommend) do 16 | newrec[i] = string.gsub(recommend[i], "/postal2aw$", "") 17 | end 18 | recommend = newrec 19 | end 20 | 21 | while true do 22 | local rc, dst = origdestfn(recommend, thisstage, maxstage) 23 | if rc ~= 1 then 24 | return rc, dst 25 | end 26 | 27 | if MojoSetup.platform.exists(dst .. "/System/Postal2Game.u") then 28 | return rc, dst 29 | end 30 | 31 | -- Some versions (Postal 10th Anniversary disc) have several titles 32 | -- installed in one base dir. 33 | if MojoSetup.platform.exists(dst .. "/postal2game/System/Postal2Game.u") then 34 | dst = dst .. "/postal2game" 35 | return rc, dst 36 | end 37 | 38 | MojoSetup.msgbox(_("Wrong path"), _("We don't see a copy of Postal 2: Share the Pain in that directory. You need Share the Pain to install Apocalypse Weekend. Please pick another directory.")); 39 | end 40 | end 41 | 42 | Setup.Package 43 | { 44 | vendor = "runningwithscissors.com", 45 | id = "postal2aw", 46 | description = _("Postal 2: Apocalypse Weekend"), 47 | version = "1.0", 48 | splash = "splash.bmp", 49 | superuser = false, 50 | write_manifest = true, 51 | support_uninstall = true, 52 | recommended_destinations = 53 | { 54 | MojoSetup.info.homedir .. "/postal2", 55 | "/opt/games/postal2", 56 | "/usr/local/games/postal2", 57 | MojoSetup.info.homedir .. "/postal_10th_anniversary/postal2game", 58 | "/opt/games/postal_10th_anniversary/postal2game", 59 | "/usr/local/games/postal_10th_anniversary/postal2game", 60 | MojoSetup.info.homedir .. "/postal_fudge_pack/postal2game", 61 | "/opt/games/postal_fudge_pack/postal2game", 62 | "/usr/local/games/postal_fudge_pack/postal2game" 63 | }, 64 | 65 | Setup.Eula 66 | { 67 | description = _("Postal License"), 68 | source = _("postal2aw_license.txt") 69 | }, 70 | 71 | Setup.Option 72 | { 73 | value = true, 74 | required = true, 75 | disabled = false, 76 | bytes = TOTAL_INSTALL_SIZE, 77 | description = _("Postal 2: Apocalypse Weekend"), 78 | 79 | Setup.File 80 | { 81 | -- Just install everything we see... 82 | }, 83 | 84 | Setup.DesktopMenuItem 85 | { 86 | disabled = false, 87 | name = _("Postal 2: Apocalypse Weekend"), 88 | genericname = _("Postal 2"), 89 | tooltip = _("Politically incorrect expansion pack from Running With Scissors"), 90 | builtin_icon = false, 91 | icon = "p2aw_rws.png", 92 | commandline = "%0/postal2aw", 93 | category = "Game" 94 | } 95 | } 96 | } 97 | 98 | -- end of config.lua ... 99 | 100 | -------------------------------------------------------------------------------- /examples/prey-demo/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Prey Demo Installer" 2 | DATAFILE="data/prey-demo-linux-data/libNvidiaVidMemTest.so" 3 | 4 | -------------------------------------------------------------------------------- /examples/prey-demo/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/prey-demo/meta/splash.bmp -------------------------------------------------------------------------------- /examples/prey/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Prey Installer" 2 | DATAFILE="data/prey-linux-data/base/guis/mainmenu/mainmenu_credits.guifragment" 3 | 4 | -------------------------------------------------------------------------------- /examples/prey/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/prey/meta/splash.bmp -------------------------------------------------------------------------------- /examples/psychonauts/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Psychonauts Installer" 2 | DATAFILE="data/PsychonautsData2.pkg" 3 | -------------------------------------------------------------------------------- /examples/psychonauts/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/psychonauts/meta/splash.bmp -------------------------------------------------------------------------------- /examples/psychonauts/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Uninstall complete"] = { 7 | en = "Uninstall complete. You may also delete 'Psychonauts' in your home directory to remove personal savegames and settings.", 8 | de = "Deinstallation komplett. Du kannst auch 'Psychonauts' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.", 9 | es = "Desinstalación completa. Puedes borrar 'Psychonauts' en tu directorio home para borrar configuraciones personales y tus juegos grabados.", 10 | pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć 'Psychonauts' z domowego katalogu.", 11 | it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella 'Psychonauts' nella tua directory home.", 12 | }; 13 | 14 | ["Psychonauts README"] = { 15 | de = "Psychonauts-README", 16 | es = "LEEME", 17 | pl = "Psychonauts README", 18 | it = "Informazioni su Psychonauts", 19 | }; 20 | }; 21 | 22 | -- end of app_localization.lua ... 23 | 24 | -------------------------------------------------------------------------------- /examples/psychonauts/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 5485393918; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "doublefine.com", 8 | id = "psychonauts", 9 | description = "Psychonauts", 10 | version = "1.0", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("Psychonauts README"), 25 | source = _("README-linux.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | -- !!! FIXME: All this filter nonsense is because 31 | -- !!! FIXME: source = "base:///some_dir_in_basepath/" 32 | -- !!! FIXME: doesn't work, since it wants a file when drilling 33 | -- !!! FIXME: for the final archive, not a directory. Fixing this 34 | -- !!! FIXME: properly is a little awkward, though. 35 | 36 | value = true, 37 | required = true, 38 | disabled = false, 39 | bytes = TOTAL_INSTALL_SIZE, 40 | description = "Psychonauts", 41 | 42 | Setup.File 43 | { 44 | wildcards = "*"; 45 | filter = function(dest) 46 | if dest == "Psychonauts" then 47 | return dest, "0755" -- make sure it's executable. 48 | end 49 | if dest == "libSDL-1.2.so.0" then 50 | return dest, "0755" -- make sure it's executable. 51 | end 52 | if dest == "libopenal.so.1" then 53 | return dest, "0755" -- make sure it's executable. 54 | end 55 | return dest -- everything else just goes through as-is. 56 | end 57 | }, 58 | 59 | Setup.DesktopMenuItem 60 | { 61 | disabled = false, 62 | name = "Psychonauts", 63 | genericname = "Psychonauts", 64 | tooltip = _("A mind-bending platforming adventure"), 65 | builtin_icon = false, 66 | icon = "psychonauts.png", 67 | commandline = "%0/Psychonauts", 68 | workingdir = "%0", 69 | category = "Game" 70 | } 71 | } 72 | } 73 | 74 | -- end of config.lua ... 75 | 76 | -------------------------------------------------------------------------------- /examples/shank/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Shank Installer" 2 | DATAFILE="data/data-pc/bootstrap/movies/introscee.ogv" 3 | -------------------------------------------------------------------------------- /examples/shank/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/shank/meta/splash.bmp -------------------------------------------------------------------------------- /examples/shank/scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- Lines starting with "--" are comments in this file. 2 | -- You should add your installer's strings here, instead of localization.lua, 3 | -- but localization.lua has instructions on how this file is formatted. 4 | 5 | MojoSetup.applocalization = { 6 | ["Uninstall complete"] = { 7 | en = "Uninstall complete. You may also delete 'Shank' in your home directory to remove personal savegames and settings.", 8 | de = "Deinstallation komplett. Du kannst auch 'Shank' in deinem Heimverzeichnis löschen, um eigene Spielstände und Einstellungen zu entfernen.", 9 | es = "Desinstalación completa. Puedes borrar 'Shank' en tu directorio home para borrar configuraciones personales y tus juegos grabados.", 10 | pl = "Usuwanie zakończone. By usunąć zapisane stany gry i ustawienia, można również usunąć 'Shank' z domowego katalogu.", 11 | it = "Disinstallazione completata. Se desideri cancellare i salvataggi e le impostazione cancella 'Shank' nella tua directory home.", 12 | }; 13 | 14 | ["Shank README"] = { 15 | de = "Shank-README", 16 | es = "LEEME", 17 | pl = "Shank README", 18 | it = "Informazioni su Shank", 19 | }; 20 | }; 21 | 22 | -- end of app_localization.lua ... 23 | 24 | -------------------------------------------------------------------------------- /examples/shank/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 2375134192; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "kleientertainment.com", 8 | id = "shank", 9 | description = "Shank", 10 | version = "1.0", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("Shank README"), 25 | source = _("README-linux.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | -- !!! FIXME: All this filter nonsense is because 31 | -- !!! FIXME: source = "base:///some_dir_in_basepath/" 32 | -- !!! FIXME: doesn't work, since it wants a file when drilling 33 | -- !!! FIXME: for the final archive, not a directory. Fixing this 34 | -- !!! FIXME: properly is a little awkward, though. 35 | 36 | value = true, 37 | required = true, 38 | disabled = false, 39 | bytes = TOTAL_INSTALL_SIZE, 40 | description = "Shank", 41 | 42 | Setup.File 43 | { 44 | wildcards = "*"; 45 | }, 46 | 47 | Setup.DesktopMenuItem 48 | { 49 | disabled = false, 50 | name = "Shank", 51 | genericname = "Shank", 52 | tooltip = _("A video game tale of revenge"), 53 | builtin_icon = false, 54 | icon = "shank.png", 55 | commandline = "%0/bin/Shank", 56 | workingdir = "%0/bin", 57 | category = "Game" 58 | } 59 | } 60 | } 61 | 62 | -- end of config.lua ... 63 | 64 | -------------------------------------------------------------------------------- /examples/spaz/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Space Pirates and Zombies Installer" 2 | DATAFILE="data/game/data/audio/chatter.zom" 3 | 4 | -------------------------------------------------------------------------------- /examples/spaz/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/spaz/meta/splash.bmp -------------------------------------------------------------------------------- /examples/spaz/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 168345717; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "spacepiratesandzombies.com", 8 | id = "spaz", 9 | description = "Space Pirates and Zombies", 10 | version = "1.0", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("Space Pirates and Zombies README"), 25 | source = _("README-linux.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | -- !!! FIXME: All this filter nonsense is because 31 | -- !!! FIXME: source = "base:///some_dir_in_basepath/" 32 | -- !!! FIXME: doesn't work, since it wants a file when drilling 33 | -- !!! FIXME: for the final archive, not a directory. Fixing this 34 | -- !!! FIXME: properly is a little awkward, though. 35 | 36 | value = true, 37 | required = true, 38 | disabled = false, 39 | bytes = TOTAL_INSTALL_SIZE, 40 | description = "Space Pirates and Zombies", 41 | 42 | Setup.File 43 | { 44 | wildcards = "*"; 45 | }, 46 | 47 | Setup.DesktopMenuItem 48 | { 49 | disabled = false, 50 | name = "Space Pirates and Zombies", 51 | genericname = "Space Pirates and Zombies", 52 | tooltip = _("A space odyssey. With pirates. And zombies."), 53 | builtin_icon = false, 54 | icon = "SPAZ.png", 55 | commandline = "%0/SPAZ", 56 | workingdir = "%0", 57 | category = "Game" 58 | } 59 | } 60 | } 61 | 62 | -- end of config.lua ... 63 | 64 | -------------------------------------------------------------------------------- /examples/supermeatboy/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Super Meat Boy Installer" 2 | DATAFILE="data/resources/Fonts/Chinese.fnt" 3 | 4 | -------------------------------------------------------------------------------- /examples/supermeatboy/meta/splash.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/examples/supermeatboy/meta/splash.bmp -------------------------------------------------------------------------------- /examples/supermeatboy/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 258158137; 2 | 3 | local _ = MojoSetup.translate 4 | 5 | Setup.Package 6 | { 7 | vendor = "supermeatboy.com", 8 | id = "supermeatboy", 9 | description = "Super Meat Boy", 10 | version = "1.0", 11 | splash = "splash.bmp", 12 | superuser = false, 13 | write_manifest = true, 14 | support_uninstall = true, 15 | recommended_destinations = 16 | { 17 | MojoSetup.info.homedir, 18 | "/opt/games", 19 | "/usr/local/games" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("Super Meat Boy README"), 25 | source = _("README-linux.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | -- !!! FIXME: All this filter nonsense is because 31 | -- !!! FIXME: source = "base:///some_dir_in_basepath/" 32 | -- !!! FIXME: doesn't work, since it wants a file when drilling 33 | -- !!! FIXME: for the final archive, not a directory. Fixing this 34 | -- !!! FIXME: properly is a little awkward, though. 35 | 36 | value = true, 37 | required = true, 38 | disabled = false, 39 | bytes = TOTAL_INSTALL_SIZE, 40 | description = "Super Meat Boy", 41 | 42 | Setup.File 43 | { 44 | wildcards = "*"; 45 | }, 46 | 47 | Setup.DesktopMenuItem 48 | { 49 | disabled = false, 50 | name = "Super Meat Boy", 51 | genericname = "Super Meat Boy", 52 | tooltip = _("An insanely hard and delightfully meaty platformer"), 53 | builtin_icon = false, 54 | icon = "supermeatboy.png", 55 | commandline = "%0/SuperMeatBoy", 56 | workingdir = "%0", 57 | category = "Game" 58 | } 59 | } 60 | } 61 | 62 | -- end of config.lua ... 63 | 64 | -------------------------------------------------------------------------------- /examples/ut3-dedicated-patches/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Unreal Tournament 3 Dedicated Server Updater" 2 | DATAFILE="data/UTGame/Config/DefaultCompat.ini" 3 | MINIMAL=1 4 | -------------------------------------------------------------------------------- /examples/ut3-dedicated-patches/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 678963902; 2 | local _ = MojoSetup.translate 3 | 4 | Setup.Package 5 | { 6 | vendor = "epicgames.com", 7 | id = "ut3-dedicated", 8 | description = "Unreal Tournament 3 Dedicated Server", 9 | version = "2.1", 10 | write_manifest = false, -- don't want to update... 11 | support_uninstall = false, -- ...or uninstall. This is just a fancy unzip. 12 | 13 | recommended_destinations = 14 | { 15 | MojoSetup.info.homedir, 16 | "/opt/games", 17 | "/opt", 18 | "/usr/local/games", 19 | "/usr/local" 20 | }, 21 | 22 | Setup.Readme 23 | { 24 | description = _("README"), 25 | source = _("README-ut3-patch5.txt") 26 | }, 27 | 28 | Setup.Eula 29 | { 30 | description = _("End User License Agreement"), 31 | source = _("UT3-linux-server-EULA.txt") 32 | }, 33 | 34 | Setup.Option 35 | { 36 | value = true, 37 | required = true, 38 | disabled = false, 39 | bytes = TOTAL_INSTALL_SIZE, 40 | description = _("Dedicated Server"), 41 | Setup.File 42 | { 43 | allowoverwrite = true, -- just replace files that we update. 44 | -- ...and just copy the whole archive. 45 | }, 46 | }, 47 | } 48 | 49 | -- end of config.lua ... 50 | 51 | -------------------------------------------------------------------------------- /examples/ut3-dedicated/details.txt: -------------------------------------------------------------------------------- 1 | APPTITLE="Unreal Tournament 3 Dedicated Server Installer" 2 | DATAFILE="data/UTGame/CookedPC/Private/Maps/CTF-Coret.ut3" 3 | MINIMAL=1 4 | -------------------------------------------------------------------------------- /examples/ut3-dedicated/scripts/config.lua: -------------------------------------------------------------------------------- 1 | local TOTAL_INSTALL_SIZE = 2575422952; 2 | local _ = MojoSetup.translate 3 | 4 | Setup.Package 5 | { 6 | vendor = "epicgames.com", 7 | id = "ut3-dedicated", 8 | description = "Unreal Tournament 3 Dedicated Server", 9 | version = "3487", 10 | write_manifest = false, -- don't want to update... 11 | support_uninstall = false, -- ...or uninstall. This is just a fancy unzip. 12 | 13 | recommended_destinations = 14 | { 15 | MojoSetup.info.homedir, 16 | "/opt/games", 17 | "/opt", 18 | "/usr/local/games", 19 | "/usr/local" 20 | }, 21 | 22 | Setup.Eula 23 | { 24 | description = _("End User License Agreement"), 25 | source = _("UT3-linux-server-EULA.txt") 26 | }, 27 | 28 | Setup.Option 29 | { 30 | value = true, 31 | required = true, 32 | disabled = false, 33 | bytes = TOTAL_INSTALL_SIZE, 34 | description = _("Dedicated Server"), 35 | Setup.File {}, -- Just copies the whole thing. 36 | }, 37 | } 38 | 39 | -- end of config.lua ... 40 | 41 | -------------------------------------------------------------------------------- /libfetch/README.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/libfetch/README.txt -------------------------------------------------------------------------------- /libfetch/common.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/libfetch/common.c -------------------------------------------------------------------------------- /libfetch/common.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/libfetch/common.h -------------------------------------------------------------------------------- /libfetch/fetch.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/libfetch/fetch.c -------------------------------------------------------------------------------- /libfetch/fetch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/libfetch/fetch.h -------------------------------------------------------------------------------- /libfetch/ftp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/libfetch/ftp.c -------------------------------------------------------------------------------- /libfetch/ftp.errors: -------------------------------------------------------------------------------- 1 | # $FreeBSD: src/lib/libfetch/ftp.errors,v 1.6 2002/10/30 06:06:16 des Exp $ 2 | # 3 | # This list is taken from RFC 959. 4 | # It probably needs a going over. 5 | # 6 | 110 OK Restart marker reply 7 | 120 TEMP Service ready in a few minutes 8 | 125 OK Data connection already open; transfer starting 9 | 150 OK File status okay; about to open data connection 10 | 200 OK Command okay 11 | 202 PROTO Command not implemented, superfluous at this site 12 | 211 INFO System status, or system help reply 13 | 212 INFO Directory status 14 | 213 INFO File status 15 | 214 INFO Help message 16 | 215 INFO Set system type 17 | 220 OK Service ready for new user 18 | 221 OK Service closing control connection 19 | 225 OK Data connection open; no transfer in progress 20 | 226 OK Requested file action successful 21 | 227 OK Entering Passive Mode 22 | 229 OK Entering Extended Passive Mode 23 | 230 OK User logged in, proceed 24 | 250 OK Requested file action okay, completed 25 | 257 OK File/directory created 26 | 331 AUTH User name okay, need password 27 | 332 AUTH Need account for login 28 | 350 OK Requested file action pending further information 29 | 421 DOWN Service not available, closing control connection 30 | 425 NETWORK Can't open data connection 31 | 426 ABORT Connection closed; transfer aborted 32 | 450 UNAVAIL File unavailable (e.g., file busy) 33 | 451 SERVER Requested action aborted: local error in processing 34 | 452 FULL Insufficient storage space in system 35 | 500 PROTO Syntax error, command unrecognized 36 | 501 PROTO Syntax error in parameters or arguments 37 | 502 PROTO Command not implemented 38 | 503 PROTO Bad sequence of commands 39 | 504 PROTO Command not implemented for that parameter 40 | 530 AUTH Not logged in 41 | 532 AUTH Need account for storing files 42 | 535 PROTO Bug in MediaHawk Video Kernel FTP server 43 | 550 UNAVAIL File unavailable (e.g., file not found, no access) 44 | 551 PROTO Requested action aborted. Page type unknown 45 | 552 FULL Exceeded storage allocation 46 | 553 EXISTS File name not allowed 47 | 999 PROTO Protocol error 48 | -------------------------------------------------------------------------------- /libfetch/ftperr.h: -------------------------------------------------------------------------------- 1 | static struct fetcherr _ftp_errlist[] = { 2 | { 110, FETCH_OK, "Restart marker reply" }, 3 | { 120, FETCH_TEMP, "Service ready in a few minutes" }, 4 | { 125, FETCH_OK, "Data connection already open; transfer starting" }, 5 | { 150, FETCH_OK, "File status okay; about to open data connection" }, 6 | { 200, FETCH_OK, "Command okay" }, 7 | { 202, FETCH_PROTO, "Command not implemented, superfluous at this site" }, 8 | { 211, FETCH_INFO, "System status, or system help reply" }, 9 | { 212, FETCH_INFO, "Directory status" }, 10 | { 213, FETCH_INFO, "File status" }, 11 | { 214, FETCH_INFO, "Help message" }, 12 | { 215, FETCH_INFO, "Set system type" }, 13 | { 220, FETCH_OK, "Service ready for new user" }, 14 | { 221, FETCH_OK, "Service closing control connection" }, 15 | { 225, FETCH_OK, "Data connection open; no transfer in progress" }, 16 | { 226, FETCH_OK, "Requested file action successful" }, 17 | { 227, FETCH_OK, "Entering Passive Mode" }, 18 | { 229, FETCH_OK, "Entering Extended Passive Mode" }, 19 | { 230, FETCH_OK, "User logged in, proceed" }, 20 | { 250, FETCH_OK, "Requested file action okay, completed" }, 21 | { 257, FETCH_OK, "File/directory created" }, 22 | { 331, FETCH_AUTH, "User name okay, need password" }, 23 | { 332, FETCH_AUTH, "Need account for login" }, 24 | { 350, FETCH_OK, "Requested file action pending further information" }, 25 | { 421, FETCH_DOWN, "Service not available, closing control connection" }, 26 | { 425, FETCH_NETWORK, "Can't open data connection" }, 27 | { 426, FETCH_ABORT, "Connection closed; transfer aborted" }, 28 | { 450, FETCH_UNAVAIL, "File unavailable (e.g., file busy)" }, 29 | { 451, FETCH_SERVER, "Requested action aborted: local error in processing" }, 30 | { 452, FETCH_FULL, "Insufficient storage space in system" }, 31 | { 500, FETCH_PROTO, "Syntax error, command unrecognized" }, 32 | { 501, FETCH_PROTO, "Syntax error in parameters or arguments" }, 33 | { 502, FETCH_PROTO, "Command not implemented" }, 34 | { 503, FETCH_PROTO, "Bad sequence of commands" }, 35 | { 504, FETCH_PROTO, "Command not implemented for that parameter" }, 36 | { 530, FETCH_AUTH, "Not logged in" }, 37 | { 532, FETCH_AUTH, "Need account for storing files" }, 38 | { 535, FETCH_PROTO, "Bug in MediaHawk Video Kernel FTP server" }, 39 | { 550, FETCH_UNAVAIL, "File unavailable (e.g., file not found, no access)" }, 40 | { 551, FETCH_PROTO, "Requested action aborted. Page type unknown" }, 41 | { 552, FETCH_FULL, "Exceeded storage allocation" }, 42 | { 553, FETCH_EXISTS, "File name not allowed" }, 43 | { 999, FETCH_PROTO, "Protocol error" }, 44 | { -1, FETCH_UNKNOWN, "Unknown FTP error" } 45 | }; 46 | 47 | -------------------------------------------------------------------------------- /libfetch/http.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/libfetch/http.c -------------------------------------------------------------------------------- /libfetch/http.errors: -------------------------------------------------------------------------------- 1 | # $FreeBSD: src/lib/libfetch/http.errors,v 1.5 2001/05/23 18:52:02 des Exp $ 2 | # 3 | # This list is taken from RFC 2068. 4 | # 5 | 100 OK Continue 6 | 101 OK Switching Protocols 7 | 200 OK OK 8 | 201 OK Created 9 | 202 OK Accepted 10 | 203 INFO Non-Authoritative Information 11 | 204 OK No Content 12 | 205 OK Reset Content 13 | 206 OK Partial Content 14 | 300 MOVED Multiple Choices 15 | 301 MOVED Moved Permanently 16 | 302 MOVED Moved Temporarily 17 | 303 MOVED See Other 18 | 304 OK Not Modified 19 | 305 INFO Use Proxy 20 | 307 MOVED Temporary Redirect 21 | 400 PROTO Bad Request 22 | 401 AUTH Unauthorized 23 | 402 AUTH Payment Required 24 | 403 AUTH Forbidden 25 | 404 UNAVAIL Not Found 26 | 405 PROTO Method Not Allowed 27 | 406 PROTO Not Acceptable 28 | 407 AUTH Proxy Authentication Required 29 | 408 TIMEOUT Request Time-out 30 | 409 EXISTS Conflict 31 | 410 UNAVAIL Gone 32 | 411 PROTO Length Required 33 | 412 SERVER Precondition Failed 34 | 413 PROTO Request Entity Too Large 35 | 414 PROTO Request-URI Too Large 36 | 415 PROTO Unsupported Media Type 37 | 416 UNAVAIL Requested Range Not Satisfiable 38 | 417 SERVER Expectation Failed 39 | 500 SERVER Internal Server Error 40 | 501 PROTO Not Implemented 41 | 502 SERVER Bad Gateway 42 | 503 TEMP Service Unavailable 43 | 504 TIMEOUT Gateway Time-out 44 | 505 PROTO HTTP Version not supported 45 | 999 PROTO Protocol error 46 | -------------------------------------------------------------------------------- /libfetch/httperr.h: -------------------------------------------------------------------------------- 1 | static struct fetcherr _http_errlist[] = { 2 | { 100, FETCH_OK, "Continue" }, 3 | { 101, FETCH_OK, "Switching Protocols" }, 4 | { 200, FETCH_OK, "OK" }, 5 | { 201, FETCH_OK, "Created" }, 6 | { 202, FETCH_OK, "Accepted" }, 7 | { 203, FETCH_INFO, "Non-Authoritative Information" }, 8 | { 204, FETCH_OK, "No Content" }, 9 | { 205, FETCH_OK, "Reset Content" }, 10 | { 206, FETCH_OK, "Partial Content" }, 11 | { 300, FETCH_MOVED, "Multiple Choices" }, 12 | { 301, FETCH_MOVED, "Moved Permanently" }, 13 | { 302, FETCH_MOVED, "Moved Temporarily" }, 14 | { 303, FETCH_MOVED, "See Other" }, 15 | { 304, FETCH_OK, "Not Modified" }, 16 | { 305, FETCH_INFO, "Use Proxy" }, 17 | { 307, FETCH_MOVED, "Temporary Redirect" }, 18 | { 400, FETCH_PROTO, "Bad Request" }, 19 | { 401, FETCH_AUTH, "Unauthorized" }, 20 | { 402, FETCH_AUTH, "Payment Required" }, 21 | { 403, FETCH_AUTH, "Forbidden" }, 22 | { 404, FETCH_UNAVAIL, "Not Found" }, 23 | { 405, FETCH_PROTO, "Method Not Allowed" }, 24 | { 406, FETCH_PROTO, "Not Acceptable" }, 25 | { 407, FETCH_AUTH, "Proxy Authentication Required" }, 26 | { 408, FETCH_TIMEOUT, "Request Time-out" }, 27 | { 409, FETCH_EXISTS, "Conflict" }, 28 | { 410, FETCH_UNAVAIL, "Gone" }, 29 | { 411, FETCH_PROTO, "Length Required" }, 30 | { 412, FETCH_SERVER, "Precondition Failed" }, 31 | { 413, FETCH_PROTO, "Request Entity Too Large" }, 32 | { 414, FETCH_PROTO, "Request-URI Too Large" }, 33 | { 415, FETCH_PROTO, "Unsupported Media Type" }, 34 | { 416, FETCH_UNAVAIL, "Requested Range Not Satisfiable" }, 35 | { 417, FETCH_SERVER, "Expectation Failed" }, 36 | { 500, FETCH_SERVER, "Internal Server Error" }, 37 | { 501, FETCH_PROTO, "Not Implemented" }, 38 | { 502, FETCH_SERVER, "Bad Gateway" }, 39 | { 503, FETCH_TEMP, "Service Unavailable" }, 40 | { 504, FETCH_TIMEOUT, "Gateway Time-out" }, 41 | { 505, FETCH_PROTO, "HTTP Version not supported" }, 42 | { 999, FETCH_PROTO, "Protocol error" }, 43 | { -1, FETCH_UNKNOWN, "Unknown HTTP error" } 44 | }; 45 | -------------------------------------------------------------------------------- /libfetch/mojosetup_libfetch.h: -------------------------------------------------------------------------------- 1 | #ifndef _INCL_MOJOSETUP_LIBFETCH_H_ 2 | #define _INCL_MOJOSETUP_LIBFETCH_H_ 3 | 4 | #include "../universal.h" 5 | #include "../platform.h" 6 | #include "../fileio.h" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #if sun 15 | #ifdef u_int32_t 16 | #undef u_int32_t 17 | #endif 18 | #define u_int32_t uint32_t 19 | #endif 20 | 21 | int MOJOSETUP_vasprintf(char **strp, const char *fmt, va_list ap); 22 | #define vasprintf MOJOSETUP_vasprintf 23 | int MOJOSETUP_asprintf(char **strp, const char *fmt, ...) ISPRINTF(2,3); 24 | #define asprintf MOJOSETUP_asprintf 25 | 26 | #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__) 27 | #ifndef FREEBSD 28 | #define FREEBSD 1 29 | #endif 30 | #endif 31 | 32 | // Things FreeBSD defines elsewhere... 33 | 34 | #ifndef __FBSDID 35 | #define __FBSDID(x) 36 | #endif 37 | 38 | #ifndef __DECONST 39 | #define __DECONST(type, var) ((type) var) 40 | #endif 41 | 42 | #ifndef __unused 43 | #define __unused 44 | #endif 45 | 46 | // apparently this is 17 in FreeBSD. 47 | #ifndef MAXLOGNAME 48 | #define MAXLOGNAME (17) 49 | #endif 50 | 51 | #undef calloc 52 | #define calloc(x, y) xmalloc(x * y) 53 | 54 | #undef malloc 55 | #define malloc(x) xmalloc(x) 56 | 57 | #undef realloc 58 | #define realloc(x, y) xrealloc(x, y) 59 | 60 | #undef strdup 61 | #define strdup(x) xstrdup(x) 62 | 63 | #undef strncpy 64 | #define strncpy(x, y, z) xstrncpy(x, y, z) 65 | 66 | #if !FREEBSD 67 | #ifndef TCP_NOPUSH 68 | #define TCP_NOPUSH TCP_CORK 69 | #endif 70 | #define EAUTH EPERM 71 | boolean ishexnumber(char ch); 72 | // Linux has had this since glibc 4.6.8, but doesn't expose it in the headers 73 | // without _XOPEN_SOURCE or _GNU_SOURCE, which breaks other things. 74 | // ...just force a declaration here, then. 75 | #ifdef __linux__ 76 | char *strptime(const char *s, const char *format, struct tm *tm); 77 | #endif 78 | #endif 79 | 80 | time_t timegm_portable(struct tm *tm); 81 | #ifdef timegm 82 | #undef timegm 83 | #endif 84 | #define timegm timegm_portable 85 | 86 | #endif 87 | 88 | // end of mojosetup_libfetch.h ... 89 | 90 | -------------------------------------------------------------------------------- /libfetch/regen_error_headers.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "static struct fetcherr _http_errlist[] = {" > httperr.h 4 | cat http.errors \ 5 | | grep -v ^# \ 6 | | sort \ 7 | | while read NUM CAT STRING; do \ 8 | echo " { ${NUM}, FETCH_${CAT}, \"${STRING}\" },"; \ 9 | done >> httperr.h 10 | echo " { -1, FETCH_UNKNOWN, \"Unknown HTTP error\" }" >> httperr.h 11 | echo "};" >> httperr.h 12 | echo >> httpderr.h 13 | 14 | echo "static struct fetcherr _ftp_errlist[] = {" > ftperr.h 15 | cat ftp.errors \ 16 | | grep -v ^# \ 17 | | sort \ 18 | | while read NUM CAT STRING; do \ 19 | echo " { ${NUM}, FETCH_${CAT}, \"${STRING}\" },"; \ 20 | done >> ftperr.h 21 | echo " { -1, FETCH_UNKNOWN, \"Unknown FTP error\" }" >> ftperr.h 22 | echo "};" >> ftperr.h 23 | echo >> ftperr.h 24 | 25 | 26 | -------------------------------------------------------------------------------- /liblzma/README.txt: -------------------------------------------------------------------------------- 1 | 2 | This is the source code to liblzma from XZ Utils: 3 | 4 | http://tukaani.org/xz/ 5 | 6 | This is a snapshot of the xz-5.0.4 release. Changes I've made to it are 7 | wrapped in #if __MOJOSETUP__ blocks. I've tried to aggressively delete files 8 | we don't use at all, too. 9 | 10 | The source code in this directory is public domain. 11 | 12 | --ryan. 13 | 14 | -------------------------------------------------------------------------------- /liblzma/api/lzma/bcj.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file lzma/bcj.h 3 | * \brief Branch/Call/Jump conversion filters 4 | */ 5 | 6 | /* 7 | * Author: Lasse Collin 8 | * 9 | * This file has been put into the public domain. 10 | * You can do whatever you want with this file. 11 | * 12 | * See ../lzma.h for information about liblzma as a whole. 13 | */ 14 | 15 | #ifndef LZMA_H_INTERNAL 16 | # error Never include this file directly. Use instead. 17 | #endif 18 | 19 | 20 | /* Filter IDs for lzma_filter.id */ 21 | 22 | #define LZMA_FILTER_X86 LZMA_VLI_C(0x04) 23 | /**< 24 | * Filter for x86 binaries 25 | */ 26 | 27 | #define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05) 28 | /**< 29 | * Filter for Big endian PowerPC binaries 30 | */ 31 | 32 | #define LZMA_FILTER_IA64 LZMA_VLI_C(0x06) 33 | /**< 34 | * Filter for IA-64 (Itanium) binaries. 35 | */ 36 | 37 | #define LZMA_FILTER_ARM LZMA_VLI_C(0x07) 38 | /**< 39 | * Filter for ARM binaries. 40 | */ 41 | 42 | #define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08) 43 | /**< 44 | * Filter for ARM-Thumb binaries. 45 | */ 46 | 47 | #define LZMA_FILTER_SPARC LZMA_VLI_C(0x09) 48 | /**< 49 | * Filter for SPARC binaries. 50 | */ 51 | 52 | 53 | /** 54 | * \brief Options for BCJ filters 55 | * 56 | * The BCJ filters never change the size of the data. Specifying options 57 | * for them is optional: if pointer to options is NULL, default value is 58 | * used. You probably never need to specify options to BCJ filters, so just 59 | * set the options pointer to NULL and be happy. 60 | * 61 | * If options with non-default values have been specified when encoding, 62 | * the same options must also be specified when decoding. 63 | * 64 | * \note At the moment, none of the BCJ filters support 65 | * LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified, 66 | * LZMA_OPTIONS_ERROR will be returned. If there is need, 67 | * partial support for LZMA_SYNC_FLUSH can be added in future. 68 | * Partial means that flushing would be possible only at 69 | * offsets that are multiple of 2, 4, or 16 depending on 70 | * the filter, except x86 which cannot be made to support 71 | * LZMA_SYNC_FLUSH predictably. 72 | */ 73 | typedef struct { 74 | /** 75 | * \brief Start offset for conversions 76 | * 77 | * This setting is useful only when the same filter is used 78 | * _separately_ for multiple sections of the same executable file, 79 | * and the sections contain cross-section branch/call/jump 80 | * instructions. In that case it is beneficial to set the start 81 | * offset of the non-first sections so that the relative addresses 82 | * of the cross-section branch/call/jump instructions will use the 83 | * same absolute addresses as in the first section. 84 | * 85 | * When the pointer to options is NULL, the default value (zero) 86 | * is used. 87 | */ 88 | uint32_t start_offset; 89 | 90 | } lzma_options_bcj; 91 | -------------------------------------------------------------------------------- /liblzma/api/lzma/delta.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file lzma/delta.h 3 | * \brief Delta filter 4 | */ 5 | 6 | /* 7 | * Author: Lasse Collin 8 | * 9 | * This file has been put into the public domain. 10 | * You can do whatever you want with this file. 11 | * 12 | * See ../lzma.h for information about liblzma as a whole. 13 | */ 14 | 15 | #ifndef LZMA_H_INTERNAL 16 | # error Never include this file directly. Use instead. 17 | #endif 18 | 19 | 20 | /** 21 | * \brief Filter ID 22 | * 23 | * Filter ID of the Delta filter. This is used as lzma_filter.id. 24 | */ 25 | #define LZMA_FILTER_DELTA LZMA_VLI_C(0x03) 26 | 27 | 28 | /** 29 | * \brief Type of the delta calculation 30 | * 31 | * Currently only byte-wise delta is supported. Other possible types could 32 | * be, for example, delta of 16/32/64-bit little/big endian integers, but 33 | * these are not currently planned since byte-wise delta is almost as good. 34 | */ 35 | typedef enum { 36 | LZMA_DELTA_TYPE_BYTE 37 | } lzma_delta_type; 38 | 39 | 40 | /** 41 | * \brief Options for the Delta filter 42 | * 43 | * These options are needed by both encoder and decoder. 44 | */ 45 | typedef struct { 46 | /** For now, this must always be LZMA_DELTA_TYPE_BYTE. */ 47 | lzma_delta_type type; 48 | 49 | /** 50 | * \brief Delta distance 51 | * 52 | * With the only currently supported type, LZMA_DELTA_TYPE_BYTE, 53 | * the distance is as bytes. 54 | * 55 | * Examples: 56 | * - 16-bit stereo audio: distance = 4 bytes 57 | * - 24-bit RGB image data: distance = 3 bytes 58 | */ 59 | uint32_t dist; 60 | # define LZMA_DELTA_DIST_MIN 1 61 | # define LZMA_DELTA_DIST_MAX 256 62 | 63 | /* 64 | * Reserved space to allow possible future extensions without 65 | * breaking the ABI. You should not touch these, because the names 66 | * of these variables may change. These are and will never be used 67 | * when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these 68 | * uninitialized. 69 | */ 70 | uint32_t reserved_int1; 71 | uint32_t reserved_int2; 72 | uint32_t reserved_int3; 73 | uint32_t reserved_int4; 74 | void *reserved_ptr1; 75 | void *reserved_ptr2; 76 | 77 | } lzma_options_delta; 78 | -------------------------------------------------------------------------------- /liblzma/api/lzma/hardware.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file lzma/hardware.h 3 | * \brief Hardware information 4 | * 5 | * Since liblzma can consume a lot of system resources, it also provides 6 | * ways to limit the resource usage. Applications linking against liblzma 7 | * need to do the actual decisions how much resources to let liblzma to use. 8 | * To ease making these decisions, liblzma provides functions to find out 9 | * the relevant capabilities of the underlaying hardware. Currently there 10 | * is only a function to find out the amount of RAM, but in the future there 11 | * will be also a function to detect how many concurrent threads the system 12 | * can run. 13 | * 14 | * \note On some operating systems, these function may temporarily 15 | * load a shared library or open file descriptor(s) to find out 16 | * the requested hardware information. Unless the application 17 | * assumes that specific file descriptors are not touched by 18 | * other threads, this should have no effect on thread safety. 19 | * Possible operations involving file descriptors will restart 20 | * the syscalls if they return EINTR. 21 | */ 22 | 23 | /* 24 | * Author: Lasse Collin 25 | * 26 | * This file has been put into the public domain. 27 | * You can do whatever you want with this file. 28 | * 29 | * See ../lzma.h for information about liblzma as a whole. 30 | */ 31 | 32 | #ifndef LZMA_H_INTERNAL 33 | # error Never include this file directly. Use instead. 34 | #endif 35 | 36 | 37 | /** 38 | * \brief Get the total amount of physical memory (RAM) in bytes 39 | * 40 | * This function may be useful when determining a reasonable memory 41 | * usage limit for decompressing or how much memory it is OK to use 42 | * for compressing. 43 | * 44 | * \return On success, the total amount of physical memory in bytes 45 | * is returned. If the amount of RAM cannot be determined, 46 | * zero is returned. This can happen if an error occurs 47 | * or if there is no code in liblzma to detect the amount 48 | * of RAM on the specific operating system. 49 | */ 50 | extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow; 51 | -------------------------------------------------------------------------------- /liblzma/check/check.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file check.h 4 | /// \brief Internal API to different integrity check functions 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_CHECK_H 14 | #define LZMA_CHECK_H 15 | 16 | #include "common.h" 17 | 18 | #if __MOJOSETUP__ 19 | #define HAVE_CHECK_CRC32 1 20 | #endif 21 | 22 | // Index hashing needs the best possible hash function (preferably 23 | // a cryptographic hash) for maximum reliability. 24 | #if defined(HAVE_CHECK_SHA256) 25 | # define LZMA_CHECK_BEST LZMA_CHECK_SHA256 26 | #elif defined(HAVE_CHECK_CRC64) 27 | # define LZMA_CHECK_BEST LZMA_CHECK_CRC64 28 | #else 29 | # define LZMA_CHECK_BEST LZMA_CHECK_CRC32 30 | #endif 31 | 32 | 33 | /// \brief Structure to hold internal state of the check being calculated 34 | /// 35 | /// \note This is not in the public API because this structure may 36 | /// change in future if new integrity check algorithms are added. 37 | typedef struct { 38 | /// Buffer to hold the final result and a temporary buffer for SHA256. 39 | union { 40 | uint8_t u8[64]; 41 | uint32_t u32[16]; 42 | uint64_t u64[8]; 43 | } buffer; 44 | 45 | /// Check-specific data 46 | union { 47 | uint32_t crc32; 48 | uint64_t crc64; 49 | 50 | struct { 51 | /// Internal state 52 | uint32_t state[8]; 53 | 54 | /// Size of the message excluding padding 55 | uint64_t size; 56 | } sha256; 57 | } state; 58 | 59 | } lzma_check_state; 60 | 61 | 62 | /// lzma_crc32_table[0] is needed by LZ encoder so we need to keep 63 | /// the array two-dimensional. 64 | #ifdef HAVE_SMALL 65 | extern uint32_t lzma_crc32_table[1][256]; 66 | extern void lzma_crc32_init(void); 67 | #else 68 | extern const uint32_t lzma_crc32_table[8][256]; 69 | extern const uint64_t lzma_crc64_table[4][256]; 70 | #endif 71 | 72 | 73 | /// \brief Initialize *check depending on type 74 | /// 75 | /// \return LZMA_OK on success. LZMA_UNSUPPORTED_CHECK if the type is not 76 | /// supported by the current version or build of liblzma. 77 | /// LZMA_PROG_ERROR if type > LZMA_CHECK_ID_MAX. 78 | extern void lzma_check_init(lzma_check_state *check, lzma_check type); 79 | 80 | /// Update the check state 81 | extern void lzma_check_update(lzma_check_state *check, lzma_check type, 82 | const uint8_t *buf, size_t size); 83 | 84 | /// Finish the check calculation and store the result to check->buffer.u8. 85 | extern void lzma_check_finish(lzma_check_state *check, lzma_check type); 86 | 87 | 88 | /// Prepare SHA-256 state for new input. 89 | extern void lzma_sha256_init(lzma_check_state *check); 90 | 91 | /// Update the SHA-256 hash state 92 | extern void lzma_sha256_update( 93 | const uint8_t *buf, size_t size, lzma_check_state *check); 94 | 95 | /// Finish the SHA-256 calculation and store the result to check->buffer.u8. 96 | extern void lzma_sha256_finish(lzma_check_state *check); 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /liblzma/check/crc_macros.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file crc_macros.h 4 | /// \brief Some endian-dependent macros for CRC32 and CRC64 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifdef WORDS_BIGENDIAN 14 | # define A(x) ((x) >> 24) 15 | # define B(x) (((x) >> 16) & 0xFF) 16 | # define C(x) (((x) >> 8) & 0xFF) 17 | # define D(x) ((x) & 0xFF) 18 | 19 | # define S8(x) ((x) << 8) 20 | # define S32(x) ((x) << 32) 21 | 22 | #else 23 | # define A(x) ((x) & 0xFF) 24 | # define B(x) (((x) >> 8) & 0xFF) 25 | # define C(x) (((x) >> 16) & 0xFF) 26 | # define D(x) ((x) >> 24) 27 | 28 | # define S8(x) ((x) >> 8) 29 | # define S32(x) ((x) >> 32) 30 | #endif 31 | -------------------------------------------------------------------------------- /liblzma/common/alone_decoder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file alone_decoder.h 4 | /// \brief Decoder for LZMA_Alone files 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_ALONE_DECODER_H 14 | #define LZMA_ALONE_DECODER_H 15 | 16 | #include "common.h" 17 | 18 | 19 | extern lzma_ret lzma_alone_decoder_init(lzma_next_coder *next, 20 | lzma_allocator *allocator, uint64_t memlimit); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /liblzma/common/block_buffer_decoder.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file block_buffer_decoder.c 4 | /// \brief Single-call .xz Block decoder 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "block_decoder.h" 14 | 15 | 16 | extern LZMA_API(lzma_ret) 17 | lzma_block_buffer_decode(lzma_block *block, lzma_allocator *allocator, 18 | const uint8_t *in, size_t *in_pos, size_t in_size, 19 | uint8_t *out, size_t *out_pos, size_t out_size) 20 | { 21 | if (in_pos == NULL || (in == NULL && *in_pos != in_size) 22 | || *in_pos > in_size || out_pos == NULL 23 | || (out == NULL && *out_pos != out_size) 24 | || *out_pos > out_size) 25 | return LZMA_PROG_ERROR; 26 | 27 | // Initialize the Block decoder. 28 | lzma_next_coder block_decoder = LZMA_NEXT_CODER_INIT; 29 | lzma_ret ret = lzma_block_decoder_init( 30 | &block_decoder, allocator, block); 31 | 32 | if (ret == LZMA_OK) { 33 | // Save the positions so that we can restore them in case 34 | // an error occurs. 35 | const size_t in_start = *in_pos; 36 | const size_t out_start = *out_pos; 37 | 38 | // Do the actual decoding. 39 | ret = block_decoder.code(block_decoder.coder, allocator, 40 | in, in_pos, in_size, out, out_pos, out_size, 41 | LZMA_FINISH); 42 | 43 | if (ret == LZMA_STREAM_END) { 44 | ret = LZMA_OK; 45 | } else { 46 | if (ret == LZMA_OK) { 47 | // Either the input was truncated or the 48 | // output buffer was too small. 49 | assert(*in_pos == in_size 50 | || *out_pos == out_size); 51 | 52 | // If all the input was consumed, then the 53 | // input is truncated, even if the output 54 | // buffer is also full. This is because 55 | // processing the last byte of the Block 56 | // never produces output. 57 | // 58 | // NOTE: This assumption may break when new 59 | // filters are added, if the end marker of 60 | // the filter doesn't consume at least one 61 | // complete byte. 62 | if (*in_pos == in_size) 63 | ret = LZMA_DATA_ERROR; 64 | else 65 | ret = LZMA_BUF_ERROR; 66 | } 67 | 68 | // Restore the positions. 69 | *in_pos = in_start; 70 | *out_pos = out_start; 71 | } 72 | } 73 | 74 | // Free the decoder memory. This needs to be done even if 75 | // initialization fails, because the internal API doesn't 76 | // require the initialization function to free its memory on error. 77 | lzma_next_end(&block_decoder, allocator); 78 | 79 | return ret; 80 | } 81 | -------------------------------------------------------------------------------- /liblzma/common/block_decoder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file block_decoder.h 4 | /// \brief Decodes .xz Blocks 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_BLOCK_DECODER_H 14 | #define LZMA_BLOCK_DECODER_H 15 | 16 | #include "common.h" 17 | 18 | 19 | extern lzma_ret lzma_block_decoder_init(lzma_next_coder *next, 20 | lzma_allocator *allocator, lzma_block *block); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /liblzma/common/block_util.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file block_header.c 4 | /// \brief Utility functions to handle lzma_block 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "common.h" 14 | #include "index.h" 15 | 16 | 17 | extern LZMA_API(lzma_ret) 18 | lzma_block_compressed_size(lzma_block *block, lzma_vli unpadded_size) 19 | { 20 | // Validate everything but Uncompressed Size and filters. 21 | if (lzma_block_unpadded_size(block) == 0) 22 | return LZMA_PROG_ERROR; 23 | 24 | const uint32_t container_size = block->header_size 25 | + lzma_check_size(block->check); 26 | 27 | // Validate that Compressed Size will be greater than zero. 28 | if (unpadded_size <= container_size) 29 | return LZMA_DATA_ERROR; 30 | 31 | // Calculate what Compressed Size is supposed to be. 32 | // If Compressed Size was present in Block Header, 33 | // compare that the new value matches it. 34 | const lzma_vli compressed_size = unpadded_size - container_size; 35 | if (block->compressed_size != LZMA_VLI_UNKNOWN 36 | && block->compressed_size != compressed_size) 37 | return LZMA_DATA_ERROR; 38 | 39 | block->compressed_size = compressed_size; 40 | 41 | return LZMA_OK; 42 | } 43 | 44 | 45 | extern LZMA_API(lzma_vli) 46 | lzma_block_unpadded_size(const lzma_block *block) 47 | { 48 | // Validate the values that we are interested in i.e. all but 49 | // Uncompressed Size and the filters. 50 | // 51 | // NOTE: This function is used for validation too, so it is 52 | // essential that these checks are always done even if 53 | // Compressed Size is unknown. 54 | if (block == NULL || block->version != 0 55 | || block->header_size < LZMA_BLOCK_HEADER_SIZE_MIN 56 | || block->header_size > LZMA_BLOCK_HEADER_SIZE_MAX 57 | || (block->header_size & 3) 58 | || !lzma_vli_is_valid(block->compressed_size) 59 | || block->compressed_size == 0 60 | || (unsigned int)(block->check) > LZMA_CHECK_ID_MAX) 61 | return 0; 62 | 63 | // If Compressed Size is unknown, return that we cannot know 64 | // size of the Block either. 65 | if (block->compressed_size == LZMA_VLI_UNKNOWN) 66 | return LZMA_VLI_UNKNOWN; 67 | 68 | // Calculate Unpadded Size and validate it. 69 | const lzma_vli unpadded_size = block->compressed_size 70 | + block->header_size 71 | + lzma_check_size(block->check); 72 | 73 | assert(unpadded_size >= UNPADDED_SIZE_MIN); 74 | if (unpadded_size > UNPADDED_SIZE_MAX) 75 | return 0; 76 | 77 | return unpadded_size; 78 | } 79 | 80 | 81 | extern LZMA_API(lzma_vli) 82 | lzma_block_total_size(const lzma_block *block) 83 | { 84 | lzma_vli unpadded_size = lzma_block_unpadded_size(block); 85 | 86 | if (unpadded_size != LZMA_VLI_UNKNOWN) 87 | unpadded_size = vli_ceil4(unpadded_size); 88 | 89 | return unpadded_size; 90 | } 91 | -------------------------------------------------------------------------------- /liblzma/common/easy_decoder_memusage.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file easy_decoder_memusage.c 4 | /// \brief Decoder memory usage calculation to match easy encoder presets 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "easy_preset.h" 14 | 15 | 16 | extern LZMA_API(uint64_t) 17 | lzma_easy_decoder_memusage(uint32_t preset) 18 | { 19 | lzma_options_easy opt_easy; 20 | if (lzma_easy_preset(&opt_easy, preset)) 21 | return UINT32_MAX; 22 | 23 | return lzma_raw_decoder_memusage(opt_easy.filters); 24 | } 25 | -------------------------------------------------------------------------------- /liblzma/common/easy_preset.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file easy_preset.c 4 | /// \brief Preset handling for easy encoder and decoder 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "easy_preset.h" 14 | 15 | 16 | extern bool 17 | lzma_easy_preset(lzma_options_easy *opt_easy, uint32_t preset) 18 | { 19 | if (lzma_lzma_preset(&opt_easy->opt_lzma, preset)) 20 | return true; 21 | 22 | opt_easy->filters[0].id = LZMA_FILTER_LZMA2; 23 | opt_easy->filters[0].options = &opt_easy->opt_lzma; 24 | opt_easy->filters[1].id = LZMA_VLI_UNKNOWN; 25 | 26 | return false; 27 | } 28 | -------------------------------------------------------------------------------- /liblzma/common/easy_preset.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file easy_preset.h 4 | /// \brief Preset handling for easy encoder and decoder 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "common.h" 14 | 15 | 16 | typedef struct { 17 | /// We need to keep the filters array available in case 18 | /// LZMA_FULL_FLUSH is used. 19 | lzma_filter filters[LZMA_FILTERS_MAX + 1]; 20 | 21 | /// Options for LZMA2 22 | lzma_options_lzma opt_lzma; 23 | 24 | // Options for more filters can be added later, so this struct 25 | // is not ready to be put into the public API. 26 | 27 | } lzma_options_easy; 28 | 29 | 30 | /// Set *easy to the settings given by the preset. Returns true on error, 31 | /// false on success. 32 | extern bool lzma_easy_preset(lzma_options_easy *easy, uint32_t preset); 33 | -------------------------------------------------------------------------------- /liblzma/common/filter_buffer_decoder.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file filter_buffer_decoder.c 4 | /// \brief Single-call raw decoding 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "filter_decoder.h" 14 | 15 | 16 | extern LZMA_API(lzma_ret) 17 | lzma_raw_buffer_decode(const lzma_filter *filters, lzma_allocator *allocator, 18 | const uint8_t *in, size_t *in_pos, size_t in_size, 19 | uint8_t *out, size_t *out_pos, size_t out_size) 20 | { 21 | // Validate what isn't validated later in filter_common.c. 22 | if (in == NULL || in_pos == NULL || *in_pos > in_size || out == NULL 23 | || out_pos == NULL || *out_pos > out_size) 24 | return LZMA_PROG_ERROR; 25 | 26 | // Initialize the decoer. 27 | lzma_next_coder next = LZMA_NEXT_CODER_INIT; 28 | return_if_error(lzma_raw_decoder_init(&next, allocator, filters)); 29 | 30 | // Store the positions so that we can restore them if something 31 | // goes wrong. 32 | const size_t in_start = *in_pos; 33 | const size_t out_start = *out_pos; 34 | 35 | // Do the actual decoding and free decoder's memory. 36 | lzma_ret ret = next.code(next.coder, allocator, in, in_pos, in_size, 37 | out, out_pos, out_size, LZMA_FINISH); 38 | 39 | if (ret == LZMA_STREAM_END) { 40 | ret = LZMA_OK; 41 | } else { 42 | if (ret == LZMA_OK) { 43 | // Either the input was truncated or the 44 | // output buffer was too small. 45 | assert(*in_pos == in_size || *out_pos == out_size); 46 | 47 | if (*in_pos != in_size) { 48 | // Since input wasn't consumed completely, 49 | // the output buffer became full and is 50 | // too small. 51 | ret = LZMA_BUF_ERROR; 52 | 53 | } else if (*out_pos != out_size) { 54 | // Since output didn't became full, the input 55 | // has to be truncated. 56 | ret = LZMA_DATA_ERROR; 57 | 58 | } else { 59 | // All the input was consumed and output 60 | // buffer is full. Now we don't immediately 61 | // know the reason for the error. Try 62 | // decoding one more byte. If it succeeds, 63 | // then the output buffer was too small. If 64 | // we cannot get a new output byte, the input 65 | // is truncated. 66 | uint8_t tmp[1]; 67 | size_t tmp_pos = 0; 68 | (void)next.code(next.coder, allocator, 69 | in, in_pos, in_size, 70 | tmp, &tmp_pos, 1, LZMA_FINISH); 71 | 72 | if (tmp_pos == 1) 73 | ret = LZMA_BUF_ERROR; 74 | else 75 | ret = LZMA_DATA_ERROR; 76 | } 77 | } 78 | 79 | // Restore the positions. 80 | *in_pos = in_start; 81 | *out_pos = out_start; 82 | } 83 | 84 | lzma_next_end(&next, allocator); 85 | 86 | return ret; 87 | } 88 | -------------------------------------------------------------------------------- /liblzma/common/filter_common.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file filter_common.c 4 | /// \brief Filter-specific stuff common for both encoder and decoder 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_FILTER_COMMON_H 14 | #define LZMA_FILTER_COMMON_H 15 | 16 | #include "common.h" 17 | 18 | 19 | /// Both lzma_filter_encoder and lzma_filter_decoder begin with these members. 20 | typedef struct { 21 | /// Filter ID 22 | lzma_vli id; 23 | 24 | /// Initializes the filter encoder and calls lzma_next_filter_init() 25 | /// for filters + 1. 26 | lzma_init_function init; 27 | 28 | /// Calculates memory usage of the encoder. If the options are 29 | /// invalid, UINT64_MAX is returned. 30 | uint64_t (*memusage)(const void *options); 31 | 32 | } lzma_filter_coder; 33 | 34 | 35 | typedef const lzma_filter_coder *(*lzma_filter_find)(lzma_vli id); 36 | 37 | 38 | extern lzma_ret lzma_raw_coder_init( 39 | lzma_next_coder *next, lzma_allocator *allocator, 40 | const lzma_filter *filters, 41 | lzma_filter_find coder_find, bool is_encoder); 42 | 43 | 44 | extern uint64_t lzma_raw_coder_memusage(lzma_filter_find coder_find, 45 | const lzma_filter *filters); 46 | 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /liblzma/common/filter_decoder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file filter_decoder.c 4 | /// \brief Filter ID mapping to filter-specific functions 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_FILTER_DECODER_H 14 | #define LZMA_FILTER_DECODER_H 15 | 16 | #include "common.h" 17 | 18 | 19 | extern lzma_ret lzma_raw_decoder_init( 20 | lzma_next_coder *next, lzma_allocator *allocator, 21 | const lzma_filter *options); 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /liblzma/common/filter_flags_decoder.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file filter_flags_decoder.c 4 | /// \brief Decodes a Filter Flags field 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "filter_decoder.h" 14 | 15 | 16 | extern LZMA_API(lzma_ret) 17 | lzma_filter_flags_decode( 18 | lzma_filter *filter, lzma_allocator *allocator, 19 | const uint8_t *in, size_t *in_pos, size_t in_size) 20 | { 21 | // Set the pointer to NULL so the caller can always safely free it. 22 | filter->options = NULL; 23 | 24 | // Filter ID 25 | return_if_error(lzma_vli_decode(&filter->id, NULL, 26 | in, in_pos, in_size)); 27 | 28 | if (filter->id >= LZMA_FILTER_RESERVED_START) 29 | return LZMA_DATA_ERROR; 30 | 31 | // Size of Properties 32 | lzma_vli props_size; 33 | return_if_error(lzma_vli_decode(&props_size, NULL, 34 | in, in_pos, in_size)); 35 | 36 | // Filter Properties 37 | if (in_size - *in_pos < props_size) 38 | return LZMA_DATA_ERROR; 39 | 40 | const lzma_ret ret = lzma_properties_decode( 41 | filter, allocator, in + *in_pos, props_size); 42 | 43 | *in_pos += props_size; 44 | 45 | return ret; 46 | } 47 | -------------------------------------------------------------------------------- /liblzma/common/index.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file index.h 4 | /// \brief Handling of Index 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_INDEX_H 14 | #define LZMA_INDEX_H 15 | 16 | #include "common.h" 17 | 18 | 19 | /// Minimum Unpadded Size 20 | #define UNPADDED_SIZE_MIN LZMA_VLI_C(5) 21 | 22 | /// Maximum Unpadded Size 23 | #define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3)) 24 | 25 | 26 | /// Get the size of the Index Padding field. This is needed by Index encoder 27 | /// and decoder, but applications should have no use for this. 28 | extern uint32_t lzma_index_padding_size(const lzma_index *i); 29 | 30 | 31 | /// Set for how many Records to allocate memory the next time 32 | /// lzma_index_append() needs to allocate space for a new Record. 33 | /// This is used only by the Index decoder. 34 | extern void lzma_index_prealloc(lzma_index *i, lzma_vli records); 35 | 36 | 37 | /// Round the variable-length integer to the next multiple of four. 38 | static inline lzma_vli 39 | vli_ceil4(lzma_vli vli) 40 | { 41 | assert(vli <= LZMA_VLI_MAX); 42 | return (vli + 3) & ~LZMA_VLI_C(3); 43 | } 44 | 45 | 46 | /// Calculate the size of the Index field excluding Index Padding 47 | static inline lzma_vli 48 | index_size_unpadded(lzma_vli count, lzma_vli index_list_size) 49 | { 50 | // Index Indicator + Number of Records + List of Records + CRC32 51 | return 1 + lzma_vli_size(count) + index_list_size + 4; 52 | } 53 | 54 | 55 | /// Calculate the size of the Index field including Index Padding 56 | static inline lzma_vli 57 | index_size(lzma_vli count, lzma_vli index_list_size) 58 | { 59 | return vli_ceil4(index_size_unpadded(count, index_list_size)); 60 | } 61 | 62 | 63 | /// Calculate the total size of the Stream 64 | static inline lzma_vli 65 | index_stream_size(lzma_vli blocks_size, 66 | lzma_vli count, lzma_vli index_list_size) 67 | { 68 | return LZMA_STREAM_HEADER_SIZE + blocks_size 69 | + index_size(count, index_list_size) 70 | + LZMA_STREAM_HEADER_SIZE; 71 | } 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /liblzma/common/mythread.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file mythread.h 4 | /// \brief Wrappers for threads 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "sysdefs.h" 14 | 15 | 16 | #ifdef HAVE_PTHREAD 17 | # include 18 | 19 | # define mythread_once(func) \ 20 | do { \ 21 | static pthread_once_t once_ = PTHREAD_ONCE_INIT; \ 22 | pthread_once(&once_, &func); \ 23 | } while (0) 24 | 25 | # define mythread_sigmask(how, set, oset) \ 26 | pthread_sigmask(how, set, oset) 27 | 28 | #else 29 | 30 | # define mythread_once(func) \ 31 | do { \ 32 | static bool once_ = false; \ 33 | if (!once_) { \ 34 | func(); \ 35 | once_ = true; \ 36 | } \ 37 | } while (0) 38 | 39 | # define mythread_sigmask(how, set, oset) \ 40 | sigprocmask(how, set, oset) 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /liblzma/common/stream_decoder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file stream_decoder.h 4 | /// \brief Decodes .xz Streams 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_STREAM_DECODER_H 14 | #define LZMA_STREAM_DECODER_H 15 | 16 | #include "common.h" 17 | 18 | extern lzma_ret lzma_stream_decoder_init(lzma_next_coder *next, 19 | lzma_allocator *allocator, uint64_t memlimit, uint32_t flags); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /liblzma/common/stream_flags_common.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file stream_flags_common.c 4 | /// \brief Common stuff for Stream flags coders 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "stream_flags_common.h" 14 | 15 | 16 | const uint8_t lzma_header_magic[6] = { 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00 }; 17 | const uint8_t lzma_footer_magic[2] = { 0x59, 0x5A }; 18 | 19 | 20 | extern LZMA_API(lzma_ret) 21 | lzma_stream_flags_compare( 22 | const lzma_stream_flags *a, const lzma_stream_flags *b) 23 | { 24 | // We can compare only version 0 structures. 25 | if (a->version != 0 || b->version != 0) 26 | return LZMA_OPTIONS_ERROR; 27 | 28 | // Check type 29 | if ((unsigned int)(a->check) > LZMA_CHECK_ID_MAX 30 | || (unsigned int)(b->check) > LZMA_CHECK_ID_MAX) 31 | return LZMA_PROG_ERROR; 32 | 33 | if (a->check != b->check) 34 | return LZMA_DATA_ERROR; 35 | 36 | // Backward Sizes are compared only if they are known in both. 37 | if (a->backward_size != LZMA_VLI_UNKNOWN 38 | && b->backward_size != LZMA_VLI_UNKNOWN) { 39 | if (!is_backward_size_valid(a) || !is_backward_size_valid(b)) 40 | return LZMA_PROG_ERROR; 41 | 42 | if (a->backward_size != b->backward_size) 43 | return LZMA_DATA_ERROR; 44 | } 45 | 46 | return LZMA_OK; 47 | } 48 | -------------------------------------------------------------------------------- /liblzma/common/stream_flags_common.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file stream_flags_common.h 4 | /// \brief Common stuff for Stream flags coders 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_STREAM_FLAGS_COMMON_H 14 | #define LZMA_STREAM_FLAGS_COMMON_H 15 | 16 | #include "common.h" 17 | 18 | /// Size of the Stream Flags field 19 | #define LZMA_STREAM_FLAGS_SIZE 2 20 | 21 | extern const uint8_t lzma_header_magic[6]; 22 | extern const uint8_t lzma_footer_magic[2]; 23 | 24 | 25 | static inline bool 26 | is_backward_size_valid(const lzma_stream_flags *options) 27 | { 28 | return options->backward_size >= LZMA_BACKWARD_SIZE_MIN 29 | && options->backward_size <= LZMA_BACKWARD_SIZE_MAX 30 | && (options->backward_size & 3) == 0; 31 | } 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /liblzma/common/stream_flags_decoder.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file stream_flags_decoder.c 4 | /// \brief Decodes Stream Header and Stream Footer from .xz files 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "stream_flags_common.h" 14 | 15 | 16 | static bool 17 | stream_flags_decode(lzma_stream_flags *options, const uint8_t *in) 18 | { 19 | // Reserved bits must be unset. 20 | if (in[0] != 0x00 || (in[1] & 0xF0)) 21 | return true; 22 | 23 | options->version = 0; 24 | options->check = in[1] & 0x0F; 25 | 26 | return false; 27 | } 28 | 29 | 30 | extern LZMA_API(lzma_ret) 31 | lzma_stream_header_decode(lzma_stream_flags *options, const uint8_t *in) 32 | { 33 | // Magic 34 | if (memcmp(in, lzma_header_magic, sizeof(lzma_header_magic)) != 0) 35 | return LZMA_FORMAT_ERROR; 36 | 37 | // Verify the CRC32 so we can distinguish between corrupt 38 | // and unsupported files. 39 | const uint32_t crc = lzma_crc32(in + sizeof(lzma_header_magic), 40 | LZMA_STREAM_FLAGS_SIZE, 0); 41 | if (crc != unaligned_read32le(in + sizeof(lzma_header_magic) 42 | + LZMA_STREAM_FLAGS_SIZE)) 43 | return LZMA_DATA_ERROR; 44 | 45 | // Stream Flags 46 | if (stream_flags_decode(options, in + sizeof(lzma_header_magic))) 47 | return LZMA_OPTIONS_ERROR; 48 | 49 | // Set Backward Size to indicate unknown value. That way 50 | // lzma_stream_flags_compare() can be used to compare Stream Header 51 | // and Stream Footer while keeping it useful also for comparing 52 | // two Stream Footers. 53 | options->backward_size = LZMA_VLI_UNKNOWN; 54 | 55 | return LZMA_OK; 56 | } 57 | 58 | 59 | extern LZMA_API(lzma_ret) 60 | lzma_stream_footer_decode(lzma_stream_flags *options, const uint8_t *in) 61 | { 62 | // Magic 63 | if (memcmp(in + sizeof(uint32_t) * 2 + LZMA_STREAM_FLAGS_SIZE, 64 | lzma_footer_magic, sizeof(lzma_footer_magic)) != 0) 65 | return LZMA_FORMAT_ERROR; 66 | 67 | // CRC32 68 | const uint32_t crc = lzma_crc32(in + sizeof(uint32_t), 69 | sizeof(uint32_t) + LZMA_STREAM_FLAGS_SIZE, 0); 70 | if (crc != unaligned_read32le(in)) 71 | return LZMA_DATA_ERROR; 72 | 73 | // Stream Flags 74 | if (stream_flags_decode(options, in + sizeof(uint32_t) * 2)) 75 | return LZMA_OPTIONS_ERROR; 76 | 77 | // Backward Size 78 | options->backward_size = unaligned_read32le(in + sizeof(uint32_t)); 79 | options->backward_size = (options->backward_size + 1) * 4; 80 | 81 | return LZMA_OK; 82 | } 83 | -------------------------------------------------------------------------------- /liblzma/common/tuklib_common.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file tuklib_common.h 4 | /// \brief Common definitions for tuklib modules 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef TUKLIB_COMMON_H 14 | #define TUKLIB_COMMON_H 15 | 16 | // The config file may be replaced by a package-specific file. 17 | // It should include at least stddef.h, inttypes.h, and limits.h. 18 | #include "tuklib_config.h" 19 | 20 | // TUKLIB_SYMBOL_PREFIX is prefixed to all symbols exported by 21 | // the tuklib modules. If you use a tuklib module in a library, 22 | // you should use TUKLIB_SYMBOL_PREFIX to make sure that there 23 | // are no symbol conflicts in case someone links your library 24 | // into application that also uses the same tuklib module. 25 | #ifndef TUKLIB_SYMBOL_PREFIX 26 | # define TUKLIB_SYMBOL_PREFIX 27 | #endif 28 | 29 | #define TUKLIB_CAT_X(a, b) a ## b 30 | #define TUKLIB_CAT(a, b) TUKLIB_CAT_X(a, b) 31 | 32 | #ifndef TUKLIB_SYMBOL 33 | # define TUKLIB_SYMBOL(sym) TUKLIB_CAT(TUKLIB_SYMBOL_PREFIX, sym) 34 | #endif 35 | 36 | #ifndef TUKLIB_DECLS_BEGIN 37 | # ifdef __cplusplus 38 | # define TUKLIB_DECLS_BEGIN extern "C" { 39 | # else 40 | # define TUKLIB_DECLS_BEGIN 41 | # endif 42 | #endif 43 | 44 | #ifndef TUKLIB_DECLS_END 45 | # ifdef __cplusplus 46 | # define TUKLIB_DECLS_END } 47 | # else 48 | # define TUKLIB_DECLS_END 49 | # endif 50 | #endif 51 | 52 | #if defined(__GNUC__) && defined(__GNUC_MINOR__) 53 | # define TUKLIB_GNUC_REQ(major, minor) \ 54 | ((__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)) \ 55 | || __GNUC__ > (major)) 56 | #else 57 | # define TUKLIB_GNUC_REQ(major, minor) 0 58 | #endif 59 | 60 | #if TUKLIB_GNUC_REQ(2, 5) 61 | # define tuklib_attr_noreturn __attribute__((__noreturn__)) 62 | #else 63 | # define tuklib_attr_noreturn 64 | #endif 65 | 66 | #if (defined(_WIN32) && !defined(__CYGWIN__)) \ 67 | || defined(__OS2__) || defined(__MSDOS__) 68 | # define TUKLIB_DOSLIKE 1 69 | #endif 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /liblzma/common/tuklib_config.h: -------------------------------------------------------------------------------- 1 | #ifdef HAVE_CONFIG_H 2 | # include "sysdefs.h" 3 | #else 4 | # include 5 | # include 6 | # include 7 | #endif 8 | -------------------------------------------------------------------------------- /liblzma/common/vli_decoder.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file vli_decoder.c 4 | /// \brief Decodes variable-length integers 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "common.h" 14 | 15 | 16 | extern LZMA_API(lzma_ret) 17 | lzma_vli_decode(lzma_vli *restrict vli, size_t *vli_pos, 18 | const uint8_t *restrict in, size_t *restrict in_pos, 19 | size_t in_size) 20 | { 21 | // If we haven't been given vli_pos, work in single-call mode. 22 | size_t vli_pos_internal = 0; 23 | if (vli_pos == NULL) { 24 | vli_pos = &vli_pos_internal; 25 | *vli = 0; 26 | 27 | // If there's no input, use LZMA_DATA_ERROR. This way it is 28 | // easy to decode VLIs from buffers that have known size, 29 | // and get the correct error code in case the buffer is 30 | // too short. 31 | if (*in_pos >= in_size) 32 | return LZMA_DATA_ERROR; 33 | 34 | } else { 35 | // Initialize *vli when starting to decode a new integer. 36 | if (*vli_pos == 0) 37 | *vli = 0; 38 | 39 | // Validate the arguments. 40 | if (*vli_pos >= LZMA_VLI_BYTES_MAX 41 | || (*vli >> (*vli_pos * 7)) != 0) 42 | return LZMA_PROG_ERROR;; 43 | 44 | if (*in_pos >= in_size) 45 | return LZMA_BUF_ERROR; 46 | } 47 | 48 | do { 49 | // Read the next byte. Use a temporary variable so that we 50 | // can update *in_pos immediately. 51 | const uint8_t byte = in[*in_pos]; 52 | ++*in_pos; 53 | 54 | // Add the newly read byte to *vli. 55 | *vli += (lzma_vli)(byte & 0x7F) << (*vli_pos * 7); 56 | ++*vli_pos; 57 | 58 | // Check if this is the last byte of a multibyte integer. 59 | if ((byte & 0x80) == 0) { 60 | // We don't allow using variable-length integers as 61 | // padding i.e. the encoding must use the most the 62 | // compact form. 63 | if (byte == 0x00 && *vli_pos > 1) 64 | return LZMA_DATA_ERROR; 65 | 66 | return vli_pos == &vli_pos_internal 67 | ? LZMA_OK : LZMA_STREAM_END; 68 | } 69 | 70 | // There is at least one more byte coming. If we have already 71 | // read maximum number of bytes, the integer is considered 72 | // corrupt. 73 | // 74 | // If we need bigger integers in future, old versions liblzma 75 | // will confusingly indicate the file being corrupt istead of 76 | // unsupported. I suppose it's still better this way, because 77 | // in the foreseeable future (writing this in 2008) the only 78 | // reason why files would appear having over 63-bit integers 79 | // is that the files are simply corrupt. 80 | if (*vli_pos == LZMA_VLI_BYTES_MAX) 81 | return LZMA_DATA_ERROR; 82 | 83 | } while (*in_pos < in_size); 84 | 85 | return vli_pos == &vli_pos_internal ? LZMA_DATA_ERROR : LZMA_OK; 86 | } 87 | -------------------------------------------------------------------------------- /liblzma/common/vli_size.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file vli_size.c 4 | /// \brief Calculates the encoded size of a variable-length integer 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "common.h" 14 | 15 | 16 | extern LZMA_API(uint32_t) 17 | lzma_vli_size(lzma_vli vli) 18 | { 19 | if (vli > LZMA_VLI_MAX) 20 | return 0; 21 | 22 | uint32_t i = 0; 23 | do { 24 | vli >>= 7; 25 | ++i; 26 | } while (vli != 0); 27 | 28 | assert(i <= LZMA_VLI_BYTES_MAX); 29 | return i; 30 | } 31 | -------------------------------------------------------------------------------- /liblzma/delta/delta_common.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file delta_common.c 4 | /// \brief Common stuff for Delta encoder and decoder 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "delta_common.h" 14 | #include "delta_private.h" 15 | 16 | 17 | static void 18 | delta_coder_end(lzma_coder *coder, lzma_allocator *allocator) 19 | { 20 | lzma_next_end(&coder->next, allocator); 21 | lzma_free(coder, allocator); 22 | return; 23 | } 24 | 25 | 26 | extern lzma_ret 27 | lzma_delta_coder_init(lzma_next_coder *next, lzma_allocator *allocator, 28 | const lzma_filter_info *filters) 29 | { 30 | // Allocate memory for the decoder if needed. 31 | if (next->coder == NULL) { 32 | next->coder = lzma_alloc(sizeof(lzma_coder), allocator); 33 | if (next->coder == NULL) 34 | return LZMA_MEM_ERROR; 35 | 36 | // End function is the same for encoder and decoder. 37 | next->end = &delta_coder_end; 38 | next->coder->next = LZMA_NEXT_CODER_INIT; 39 | } 40 | 41 | // Validate the options. 42 | if (lzma_delta_coder_memusage(filters[0].options) == UINT64_MAX) 43 | return LZMA_OPTIONS_ERROR; 44 | 45 | // Set the delta distance. 46 | const lzma_options_delta *opt = filters[0].options; 47 | next->coder->distance = opt->dist; 48 | 49 | // Initialize the rest of the variables. 50 | next->coder->pos = 0; 51 | memzero(next->coder->history, LZMA_DELTA_DIST_MAX); 52 | 53 | // Initialize the next decoder in the chain, if any. 54 | return lzma_next_filter_init(&next->coder->next, 55 | allocator, filters + 1); 56 | } 57 | 58 | 59 | extern uint64_t 60 | lzma_delta_coder_memusage(const void *options) 61 | { 62 | const lzma_options_delta *opt = options; 63 | 64 | if (opt == NULL || opt->type != LZMA_DELTA_TYPE_BYTE 65 | || opt->dist < LZMA_DELTA_DIST_MIN 66 | || opt->dist > LZMA_DELTA_DIST_MAX) 67 | return UINT64_MAX; 68 | 69 | return sizeof(lzma_coder); 70 | } 71 | -------------------------------------------------------------------------------- /liblzma/delta/delta_common.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file delta_common.h 4 | /// \brief Common stuff for Delta encoder and decoder 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_DELTA_COMMON_H 14 | #define LZMA_DELTA_COMMON_H 15 | 16 | #include "common.h" 17 | 18 | extern uint64_t lzma_delta_coder_memusage(const void *options); 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /liblzma/delta/delta_decoder.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file delta_decoder.c 4 | /// \brief Delta filter decoder 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "delta_decoder.h" 14 | #include "delta_private.h" 15 | 16 | 17 | static void 18 | decode_buffer(lzma_coder *coder, uint8_t *buffer, size_t size) 19 | { 20 | const size_t distance = coder->distance; 21 | 22 | #if __MOJOSETUP__ 23 | size_t i; 24 | for (i = 0; i < size; ++i) { 25 | #else 26 | for (size_t i = 0; i < size; ++i) { 27 | #endif 28 | buffer[i] += coder->history[(distance + coder->pos) & 0xFF]; 29 | coder->history[coder->pos-- & 0xFF] = buffer[i]; 30 | } 31 | } 32 | 33 | 34 | static lzma_ret 35 | delta_decode(lzma_coder *coder, lzma_allocator *allocator, 36 | const uint8_t *restrict in, size_t *restrict in_pos, 37 | size_t in_size, uint8_t *restrict out, 38 | size_t *restrict out_pos, size_t out_size, lzma_action action) 39 | { 40 | assert(coder->next.code != NULL); 41 | 42 | const size_t out_start = *out_pos; 43 | 44 | const lzma_ret ret = coder->next.code(coder->next.coder, allocator, 45 | in, in_pos, in_size, out, out_pos, out_size, 46 | action); 47 | 48 | decode_buffer(coder, out + out_start, *out_pos - out_start); 49 | 50 | return ret; 51 | } 52 | 53 | 54 | extern lzma_ret 55 | lzma_delta_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, 56 | const lzma_filter_info *filters) 57 | { 58 | next->code = &delta_decode; 59 | return lzma_delta_coder_init(next, allocator, filters); 60 | } 61 | 62 | 63 | extern lzma_ret 64 | lzma_delta_props_decode(void **options, lzma_allocator *allocator, 65 | const uint8_t *props, size_t props_size) 66 | { 67 | if (props_size != 1) 68 | return LZMA_OPTIONS_ERROR; 69 | 70 | lzma_options_delta *opt 71 | = lzma_alloc(sizeof(lzma_options_delta), allocator); 72 | if (opt == NULL) 73 | return LZMA_MEM_ERROR; 74 | 75 | opt->type = LZMA_DELTA_TYPE_BYTE; 76 | opt->dist = props[0] + 1; 77 | 78 | *options = opt; 79 | 80 | return LZMA_OK; 81 | } 82 | -------------------------------------------------------------------------------- /liblzma/delta/delta_decoder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file delta_decoder.h 4 | /// \brief Delta filter decoder 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_DELTA_DECODER_H 14 | #define LZMA_DELTA_DECODER_H 15 | 16 | #include "delta_common.h" 17 | 18 | extern lzma_ret lzma_delta_decoder_init(lzma_next_coder *next, 19 | lzma_allocator *allocator, const lzma_filter_info *filters); 20 | 21 | extern lzma_ret lzma_delta_props_decode( 22 | void **options, lzma_allocator *allocator, 23 | const uint8_t *props, size_t props_size); 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /liblzma/delta/delta_private.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file delta_private.h 4 | /// \brief Private common stuff for Delta encoder and decoder 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_DELTA_PRIVATE_H 14 | #define LZMA_DELTA_PRIVATE_H 15 | 16 | #include "delta_common.h" 17 | 18 | struct lzma_coder_s { 19 | /// Next coder in the chain 20 | lzma_next_coder next; 21 | 22 | /// Delta distance 23 | size_t distance; 24 | 25 | /// Position in history[] 26 | uint8_t pos; 27 | 28 | /// Buffer to hold history of the original data 29 | uint8_t history[LZMA_DELTA_DIST_MAX]; 30 | }; 31 | 32 | 33 | extern lzma_ret lzma_delta_coder_init( 34 | lzma_next_coder *next, lzma_allocator *allocator, 35 | const lzma_filter_info *filters); 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /liblzma/lzma/lzma2_decoder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file lzma2_decoder.h 4 | /// \brief LZMA2 decoder 5 | /// 6 | // Authors: Igor Pavlov 7 | // Lasse Collin 8 | // 9 | // This file has been put into the public domain. 10 | // You can do whatever you want with this file. 11 | // 12 | /////////////////////////////////////////////////////////////////////////////// 13 | 14 | #ifndef LZMA_LZMA2_DECODER_H 15 | #define LZMA_LZMA2_DECODER_H 16 | 17 | #include "common.h" 18 | 19 | extern lzma_ret lzma_lzma2_decoder_init(lzma_next_coder *next, 20 | lzma_allocator *allocator, const lzma_filter_info *filters); 21 | 22 | extern uint64_t lzma_lzma2_decoder_memusage(const void *options); 23 | 24 | extern lzma_ret lzma_lzma2_props_decode( 25 | void **options, lzma_allocator *allocator, 26 | const uint8_t *props, size_t props_size); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /liblzma/lzma/lzma_decoder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file lzma_decoder.h 4 | /// \brief LZMA decoder API 5 | /// 6 | // Authors: Igor Pavlov 7 | // Lasse Collin 8 | // 9 | // This file has been put into the public domain. 10 | // You can do whatever you want with this file. 11 | // 12 | /////////////////////////////////////////////////////////////////////////////// 13 | 14 | #ifndef LZMA_LZMA_DECODER_H 15 | #define LZMA_LZMA_DECODER_H 16 | 17 | #include "common.h" 18 | 19 | 20 | /// Allocates and initializes LZMA decoder 21 | extern lzma_ret lzma_lzma_decoder_init(lzma_next_coder *next, 22 | lzma_allocator *allocator, const lzma_filter_info *filters); 23 | 24 | extern uint64_t lzma_lzma_decoder_memusage(const void *options); 25 | 26 | extern lzma_ret lzma_lzma_props_decode( 27 | void **options, lzma_allocator *allocator, 28 | const uint8_t *props, size_t props_size); 29 | 30 | 31 | /// \brief Decodes the LZMA Properties byte (lc/lp/pb) 32 | /// 33 | /// \return true if error occurred, false on success 34 | /// 35 | extern bool lzma_lzma_lclppb_decode( 36 | lzma_options_lzma *options, uint8_t byte); 37 | 38 | 39 | #ifdef LZMA_LZ_DECODER_H 40 | /// Allocate and setup function pointers only. This is used by LZMA1 and 41 | /// LZMA2 decoders. 42 | extern lzma_ret lzma_lzma_decoder_create( 43 | lzma_lz_decoder *lz, lzma_allocator *allocator, 44 | const void *opt, lzma_lz_options *lz_options); 45 | 46 | /// Gets memory usage without validating lc/lp/pb. This is used by LZMA2 47 | /// decoder, because raw LZMA2 decoding doesn't need lc/lp/pb. 48 | extern uint64_t lzma_lzma_decoder_memusage_nocheck(const void *options); 49 | 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /liblzma/lzma/lzma_encoder_presets.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file lzma_encoder_presets.c 4 | /// \brief Encoder presets 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "common.h" 14 | 15 | 16 | extern LZMA_API(lzma_bool) 17 | lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset) 18 | { 19 | const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK; 20 | const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK; 21 | const uint32_t supported_flags = LZMA_PRESET_EXTREME; 22 | 23 | if (level > 9 || (flags & ~supported_flags)) 24 | return true; 25 | 26 | options->preset_dict = NULL; 27 | options->preset_dict_size = 0; 28 | 29 | options->lc = LZMA_LC_DEFAULT; 30 | options->lp = LZMA_LP_DEFAULT; 31 | options->pb = LZMA_PB_DEFAULT; 32 | 33 | options->dict_size = UINT32_C(1) << (uint8_t []){ 34 | 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 }[level]; 35 | 36 | if (level <= 3) { 37 | options->mode = LZMA_MODE_FAST; 38 | options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4; 39 | options->nice_len = level <= 1 ? 128 : 273; 40 | options->depth = (uint8_t []){ 4, 8, 24, 48 }[level]; 41 | } else { 42 | options->mode = LZMA_MODE_NORMAL; 43 | options->mf = LZMA_MF_BT4; 44 | options->nice_len = level == 4 ? 16 : level == 5 ? 32 : 64; 45 | options->depth = 0; 46 | } 47 | 48 | if (flags & LZMA_PRESET_EXTREME) { 49 | options->mode = LZMA_MODE_NORMAL; 50 | options->mf = LZMA_MF_BT4; 51 | if (level == 3 || level == 5) { 52 | options->nice_len = 192; 53 | options->depth = 0; 54 | } else { 55 | options->nice_len = 273; 56 | options->depth = 512; 57 | } 58 | } 59 | 60 | return false; 61 | } 62 | -------------------------------------------------------------------------------- /liblzma/rangecoder/range_common.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file range_common.h 4 | /// \brief Common things for range encoder and decoder 5 | /// 6 | // Authors: Igor Pavlov 7 | // Lasse Collin 8 | // 9 | // This file has been put into the public domain. 10 | // You can do whatever you want with this file. 11 | // 12 | /////////////////////////////////////////////////////////////////////////////// 13 | 14 | #ifndef LZMA_RANGE_COMMON_H 15 | #define LZMA_RANGE_COMMON_H 16 | 17 | #if __MOJOSETUP__ 18 | #include "common.h" 19 | #else 20 | #ifdef HAVE_CONFIG_H 21 | # include "common.h" 22 | #endif 23 | #endif 24 | 25 | /////////////// 26 | // Constants // 27 | /////////////// 28 | 29 | #define RC_SHIFT_BITS 8 30 | #define RC_TOP_BITS 24 31 | #define RC_TOP_VALUE (UINT32_C(1) << RC_TOP_BITS) 32 | #define RC_BIT_MODEL_TOTAL_BITS 11 33 | #define RC_BIT_MODEL_TOTAL (UINT32_C(1) << RC_BIT_MODEL_TOTAL_BITS) 34 | #define RC_MOVE_BITS 5 35 | 36 | 37 | //////////// 38 | // Macros // 39 | //////////// 40 | 41 | // Resets the probability so that both 0 and 1 have probability of 50 % 42 | #define bit_reset(prob) \ 43 | prob = RC_BIT_MODEL_TOTAL >> 1 44 | 45 | // This does the same for a complete bit tree. 46 | // (A tree represented as an array.) 47 | #if __MOJOSETUP__ 48 | #define bittree_reset(probs, bit_levels) \ 49 | do { \ 50 | uint32_t bt_i; \ 51 | for (bt_i = 0; bt_i < (1 << (bit_levels)); ++bt_i) \ 52 | bit_reset((probs)[bt_i]); \ 53 | } while (0) 54 | #else 55 | #define bittree_reset(probs, bit_levels) \ 56 | for (uint32_t bt_i = 0; bt_i < (1 << (bit_levels)); ++bt_i) \ 57 | bit_reset((probs)[bt_i]) 58 | #endif 59 | 60 | 61 | ////////////////////// 62 | // Type definitions // 63 | ////////////////////// 64 | 65 | /// \brief Type of probabilities used with range coder 66 | /// 67 | /// This needs to be at least 12-bit integer, so uint16_t is a logical choice. 68 | /// However, on some architecture and compiler combinations, a bigger type 69 | /// may give better speed, because the probability variables are accessed 70 | /// a lot. On the other hand, bigger probability type increases cache 71 | /// footprint, since there are 2 to 14 thousand probability variables in 72 | /// LZMA (assuming the limit of lc + lp <= 4; with lc + lp <= 12 there 73 | /// would be about 1.5 million variables). 74 | /// 75 | /// With malicious files, the initialization speed of the LZMA decoder can 76 | /// become important. In that case, smaller probability variables mean that 77 | /// there is less bytes to write to RAM, which makes initialization faster. 78 | /// With big probability type, the initialization can become so slow that it 79 | /// can be a problem e.g. for email servers doing virus scanning. 80 | /// 81 | /// I will be sticking to uint16_t unless some specific architectures 82 | /// are *much* faster (20-50 %) with uint32_t. 83 | typedef uint16_t probability; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /liblzma/simple/arm.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file arm.c 4 | /// \brief Filter for ARM binaries 5 | /// 6 | // Authors: Igor Pavlov 7 | // Lasse Collin 8 | // 9 | // This file has been put into the public domain. 10 | // You can do whatever you want with this file. 11 | // 12 | /////////////////////////////////////////////////////////////////////////////// 13 | 14 | #include "simple_private.h" 15 | 16 | 17 | static size_t 18 | arm_code(lzma_simple *simple lzma_attribute((__unused__)), 19 | uint32_t now_pos, bool is_encoder, 20 | uint8_t *buffer, size_t size) 21 | { 22 | size_t i; 23 | for (i = 0; i + 4 <= size; i += 4) { 24 | if (buffer[i + 3] == 0xEB) { 25 | uint32_t src = (buffer[i + 2] << 16) 26 | | (buffer[i + 1] << 8) 27 | | (buffer[i + 0]); 28 | src <<= 2; 29 | 30 | uint32_t dest; 31 | if (is_encoder) 32 | dest = now_pos + (uint32_t)(i) + 8 + src; 33 | else 34 | dest = src - (now_pos + (uint32_t)(i) + 8); 35 | 36 | dest >>= 2; 37 | buffer[i + 2] = (dest >> 16); 38 | buffer[i + 1] = (dest >> 8); 39 | buffer[i + 0] = dest; 40 | } 41 | } 42 | 43 | return i; 44 | } 45 | 46 | 47 | static lzma_ret 48 | arm_coder_init(lzma_next_coder *next, lzma_allocator *allocator, 49 | const lzma_filter_info *filters, bool is_encoder) 50 | { 51 | return lzma_simple_coder_init(next, allocator, filters, 52 | &arm_code, 0, 4, 4, is_encoder); 53 | } 54 | 55 | 56 | extern lzma_ret 57 | lzma_simple_arm_encoder_init(lzma_next_coder *next, lzma_allocator *allocator, 58 | const lzma_filter_info *filters) 59 | { 60 | return arm_coder_init(next, allocator, filters, true); 61 | } 62 | 63 | 64 | extern lzma_ret 65 | lzma_simple_arm_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, 66 | const lzma_filter_info *filters) 67 | { 68 | return arm_coder_init(next, allocator, filters, false); 69 | } 70 | -------------------------------------------------------------------------------- /liblzma/simple/armthumb.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file armthumb.c 4 | /// \brief Filter for ARM-Thumb binaries 5 | /// 6 | // Authors: Igor Pavlov 7 | // Lasse Collin 8 | // 9 | // This file has been put into the public domain. 10 | // You can do whatever you want with this file. 11 | // 12 | /////////////////////////////////////////////////////////////////////////////// 13 | 14 | #include "simple_private.h" 15 | 16 | 17 | static size_t 18 | armthumb_code(lzma_simple *simple lzma_attribute((__unused__)), 19 | uint32_t now_pos, bool is_encoder, 20 | uint8_t *buffer, size_t size) 21 | { 22 | size_t i; 23 | for (i = 0; i + 4 <= size; i += 2) { 24 | if ((buffer[i + 1] & 0xF8) == 0xF0 25 | && (buffer[i + 3] & 0xF8) == 0xF8) { 26 | uint32_t src = ((buffer[i + 1] & 0x7) << 19) 27 | | (buffer[i + 0] << 11) 28 | | ((buffer[i + 3] & 0x7) << 8) 29 | | (buffer[i + 2]); 30 | 31 | src <<= 1; 32 | 33 | uint32_t dest; 34 | if (is_encoder) 35 | dest = now_pos + (uint32_t)(i) + 4 + src; 36 | else 37 | dest = src - (now_pos + (uint32_t)(i) + 4); 38 | 39 | dest >>= 1; 40 | buffer[i + 1] = 0xF0 | ((dest >> 19) & 0x7); 41 | buffer[i + 0] = (dest >> 11); 42 | buffer[i + 3] = 0xF8 | ((dest >> 8) & 0x7); 43 | buffer[i + 2] = (dest); 44 | i += 2; 45 | } 46 | } 47 | 48 | return i; 49 | } 50 | 51 | 52 | static lzma_ret 53 | armthumb_coder_init(lzma_next_coder *next, lzma_allocator *allocator, 54 | const lzma_filter_info *filters, bool is_encoder) 55 | { 56 | return lzma_simple_coder_init(next, allocator, filters, 57 | &armthumb_code, 0, 4, 2, is_encoder); 58 | } 59 | 60 | 61 | extern lzma_ret 62 | lzma_simple_armthumb_encoder_init(lzma_next_coder *next, 63 | lzma_allocator *allocator, const lzma_filter_info *filters) 64 | { 65 | return armthumb_coder_init(next, allocator, filters, true); 66 | } 67 | 68 | 69 | extern lzma_ret 70 | lzma_simple_armthumb_decoder_init(lzma_next_coder *next, 71 | lzma_allocator *allocator, const lzma_filter_info *filters) 72 | { 73 | return armthumb_coder_init(next, allocator, filters, false); 74 | } 75 | -------------------------------------------------------------------------------- /liblzma/simple/powerpc.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file powerpc.c 4 | /// \brief Filter for PowerPC (big endian) binaries 5 | /// 6 | // Authors: Igor Pavlov 7 | // Lasse Collin 8 | // 9 | // This file has been put into the public domain. 10 | // You can do whatever you want with this file. 11 | // 12 | /////////////////////////////////////////////////////////////////////////////// 13 | 14 | #include "simple_private.h" 15 | 16 | 17 | static size_t 18 | powerpc_code(lzma_simple *simple lzma_attribute((__unused__)), 19 | uint32_t now_pos, bool is_encoder, 20 | uint8_t *buffer, size_t size) 21 | { 22 | size_t i; 23 | for (i = 0; i + 4 <= size; i += 4) { 24 | // PowerPC branch 6(48) 24(Offset) 1(Abs) 1(Link) 25 | if ((buffer[i] >> 2) == 0x12 26 | && ((buffer[i + 3] & 3) == 1)) { 27 | 28 | const uint32_t src = ((buffer[i + 0] & 3) << 24) 29 | | (buffer[i + 1] << 16) 30 | | (buffer[i + 2] << 8) 31 | | (buffer[i + 3] & (~3)); 32 | 33 | uint32_t dest; 34 | if (is_encoder) 35 | dest = now_pos + (uint32_t)(i) + src; 36 | else 37 | dest = src - (now_pos + (uint32_t)(i)); 38 | 39 | buffer[i + 0] = 0x48 | ((dest >> 24) & 0x03); 40 | buffer[i + 1] = (dest >> 16); 41 | buffer[i + 2] = (dest >> 8); 42 | buffer[i + 3] &= 0x03; 43 | buffer[i + 3] |= dest; 44 | } 45 | } 46 | 47 | return i; 48 | } 49 | 50 | 51 | static lzma_ret 52 | powerpc_coder_init(lzma_next_coder *next, lzma_allocator *allocator, 53 | const lzma_filter_info *filters, bool is_encoder) 54 | { 55 | return lzma_simple_coder_init(next, allocator, filters, 56 | &powerpc_code, 0, 4, 4, is_encoder); 57 | } 58 | 59 | 60 | extern lzma_ret 61 | lzma_simple_powerpc_encoder_init(lzma_next_coder *next, 62 | lzma_allocator *allocator, const lzma_filter_info *filters) 63 | { 64 | return powerpc_coder_init(next, allocator, filters, true); 65 | } 66 | 67 | 68 | extern lzma_ret 69 | lzma_simple_powerpc_decoder_init(lzma_next_coder *next, 70 | lzma_allocator *allocator, const lzma_filter_info *filters) 71 | { 72 | return powerpc_coder_init(next, allocator, filters, false); 73 | } 74 | -------------------------------------------------------------------------------- /liblzma/simple/simple_coder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file simple_coder.h 4 | /// \brief Wrapper for simple filters 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_SIMPLE_CODER_H 14 | #define LZMA_SIMPLE_CODER_H 15 | 16 | #include "common.h" 17 | 18 | 19 | extern lzma_ret lzma_simple_x86_encoder_init(lzma_next_coder *next, 20 | lzma_allocator *allocator, const lzma_filter_info *filters); 21 | 22 | extern lzma_ret lzma_simple_x86_decoder_init(lzma_next_coder *next, 23 | lzma_allocator *allocator, const lzma_filter_info *filters); 24 | 25 | 26 | extern lzma_ret lzma_simple_powerpc_encoder_init(lzma_next_coder *next, 27 | lzma_allocator *allocator, const lzma_filter_info *filters); 28 | 29 | extern lzma_ret lzma_simple_powerpc_decoder_init(lzma_next_coder *next, 30 | lzma_allocator *allocator, const lzma_filter_info *filters); 31 | 32 | 33 | extern lzma_ret lzma_simple_ia64_encoder_init(lzma_next_coder *next, 34 | lzma_allocator *allocator, const lzma_filter_info *filters); 35 | 36 | extern lzma_ret lzma_simple_ia64_decoder_init(lzma_next_coder *next, 37 | lzma_allocator *allocator, const lzma_filter_info *filters); 38 | 39 | 40 | extern lzma_ret lzma_simple_arm_encoder_init(lzma_next_coder *next, 41 | lzma_allocator *allocator, const lzma_filter_info *filters); 42 | 43 | extern lzma_ret lzma_simple_arm_decoder_init(lzma_next_coder *next, 44 | lzma_allocator *allocator, const lzma_filter_info *filters); 45 | 46 | 47 | extern lzma_ret lzma_simple_armthumb_encoder_init(lzma_next_coder *next, 48 | lzma_allocator *allocator, const lzma_filter_info *filters); 49 | 50 | extern lzma_ret lzma_simple_armthumb_decoder_init(lzma_next_coder *next, 51 | lzma_allocator *allocator, const lzma_filter_info *filters); 52 | 53 | 54 | extern lzma_ret lzma_simple_sparc_encoder_init(lzma_next_coder *next, 55 | lzma_allocator *allocator, const lzma_filter_info *filters); 56 | 57 | extern lzma_ret lzma_simple_sparc_decoder_init(lzma_next_coder *next, 58 | lzma_allocator *allocator, const lzma_filter_info *filters); 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /liblzma/simple/simple_decoder.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file simple_decoder.c 4 | /// \brief Properties decoder for simple filters 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #include "simple_decoder.h" 14 | 15 | 16 | extern lzma_ret 17 | lzma_simple_props_decode(void **options, lzma_allocator *allocator, 18 | const uint8_t *props, size_t props_size) 19 | { 20 | if (props_size == 0) 21 | return LZMA_OK; 22 | 23 | if (props_size != 4) 24 | return LZMA_OPTIONS_ERROR; 25 | 26 | lzma_options_bcj *opt = lzma_alloc( 27 | sizeof(lzma_options_bcj), allocator); 28 | if (opt == NULL) 29 | return LZMA_MEM_ERROR; 30 | 31 | opt->start_offset = unaligned_read32le(props); 32 | 33 | // Don't leave an options structure allocated if start_offset is zero. 34 | if (opt->start_offset == 0) 35 | lzma_free(opt, allocator); 36 | else 37 | *options = opt; 38 | 39 | return LZMA_OK; 40 | } 41 | -------------------------------------------------------------------------------- /liblzma/simple/simple_decoder.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file simple_decoder.h 4 | /// \brief Properties decoder for simple filters 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_SIMPLE_DECODER_H 14 | #define LZMA_SIMPLE_DECODER_H 15 | 16 | #include "simple_coder.h" 17 | 18 | extern lzma_ret lzma_simple_props_decode( 19 | void **options, lzma_allocator *allocator, 20 | const uint8_t *props, size_t props_size); 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /liblzma/simple/simple_private.h: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file simple_private.h 4 | /// \brief Private definitions for so called simple filters 5 | // 6 | // Author: Lasse Collin 7 | // 8 | // This file has been put into the public domain. 9 | // You can do whatever you want with this file. 10 | // 11 | /////////////////////////////////////////////////////////////////////////////// 12 | 13 | #ifndef LZMA_SIMPLE_PRIVATE_H 14 | #define LZMA_SIMPLE_PRIVATE_H 15 | 16 | #include "simple_coder.h" 17 | 18 | 19 | typedef struct lzma_simple_s lzma_simple; 20 | 21 | struct lzma_coder_s { 22 | /// Next filter in the chain 23 | lzma_next_coder next; 24 | 25 | /// True if the next coder in the chain has returned LZMA_STREAM_END. 26 | bool end_was_reached; 27 | 28 | /// True if filter() should encode the data; false to decode. 29 | /// Currently all simple filters use the same function for encoding 30 | /// and decoding, because the difference between encoders and decoders 31 | /// is very small. 32 | bool is_encoder; 33 | 34 | /// Pointer to filter-specific function, which does 35 | /// the actual filtering. 36 | size_t (*filter)(lzma_simple *simple, uint32_t now_pos, 37 | bool is_encoder, uint8_t *buffer, size_t size); 38 | 39 | /// Pointer to filter-specific data, or NULL if filter doesn't need 40 | /// any extra data. 41 | lzma_simple *simple; 42 | 43 | /// The lowest 32 bits of the current position in the data. Most 44 | /// filters need this to do conversions between absolute and relative 45 | /// addresses. 46 | uint32_t now_pos; 47 | 48 | /// Size of the memory allocated for the buffer. 49 | size_t allocated; 50 | 51 | /// Flushing position in the temporary buffer. buffer[pos] is the 52 | /// next byte to be copied to out[]. 53 | size_t pos; 54 | 55 | /// buffer[filtered] is the first unfiltered byte. When pos is smaller 56 | /// than filtered, there is unflushed filtered data in the buffer. 57 | size_t filtered; 58 | 59 | /// Total number of bytes (both filtered and unfiltered) currently 60 | /// in the temporary buffer. 61 | size_t size; 62 | 63 | /// Temporary buffer 64 | uint8_t buffer[]; 65 | }; 66 | 67 | 68 | extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next, 69 | lzma_allocator *allocator, const lzma_filter_info *filters, 70 | size_t (*filter)(lzma_simple *simple, uint32_t now_pos, 71 | bool is_encoder, uint8_t *buffer, size_t size), 72 | size_t simple_size, size_t unfiltered_max, 73 | uint32_t alignment, bool is_encoder); 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /liblzma/simple/sparc.c: -------------------------------------------------------------------------------- 1 | /////////////////////////////////////////////////////////////////////////////// 2 | // 3 | /// \file sparc.c 4 | /// \brief Filter for SPARC binaries 5 | /// 6 | // Authors: Igor Pavlov 7 | // Lasse Collin 8 | // 9 | // This file has been put into the public domain. 10 | // You can do whatever you want with this file. 11 | // 12 | /////////////////////////////////////////////////////////////////////////////// 13 | 14 | #include "simple_private.h" 15 | 16 | 17 | static size_t 18 | sparc_code(lzma_simple *simple lzma_attribute((__unused__)), 19 | uint32_t now_pos, bool is_encoder, 20 | uint8_t *buffer, size_t size) 21 | { 22 | size_t i; 23 | for (i = 0; i + 4 <= size; i += 4) { 24 | 25 | if ((buffer[i] == 0x40 && (buffer[i + 1] & 0xC0) == 0x00) 26 | || (buffer[i] == 0x7F 27 | && (buffer[i + 1] & 0xC0) == 0xC0)) { 28 | 29 | uint32_t src = ((uint32_t)buffer[i + 0] << 24) 30 | | ((uint32_t)buffer[i + 1] << 16) 31 | | ((uint32_t)buffer[i + 2] << 8) 32 | | ((uint32_t)buffer[i + 3]); 33 | 34 | src <<= 2; 35 | 36 | uint32_t dest; 37 | if (is_encoder) 38 | dest = now_pos + (uint32_t)(i) + src; 39 | else 40 | dest = src - (now_pos + (uint32_t)(i)); 41 | 42 | dest >>= 2; 43 | 44 | dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) 45 | | (dest & 0x3FFFFF) 46 | | 0x40000000; 47 | 48 | buffer[i + 0] = (uint8_t)(dest >> 24); 49 | buffer[i + 1] = (uint8_t)(dest >> 16); 50 | buffer[i + 2] = (uint8_t)(dest >> 8); 51 | buffer[i + 3] = (uint8_t)(dest); 52 | } 53 | } 54 | 55 | return i; 56 | } 57 | 58 | 59 | static lzma_ret 60 | sparc_coder_init(lzma_next_coder *next, lzma_allocator *allocator, 61 | const lzma_filter_info *filters, bool is_encoder) 62 | { 63 | return lzma_simple_coder_init(next, allocator, filters, 64 | &sparc_code, 0, 4, 4, is_encoder); 65 | } 66 | 67 | 68 | extern lzma_ret 69 | lzma_simple_sparc_encoder_init(lzma_next_coder *next, 70 | lzma_allocator *allocator, const lzma_filter_info *filters) 71 | { 72 | return sparc_coder_init(next, allocator, filters, true); 73 | } 74 | 75 | 76 | extern lzma_ret 77 | lzma_simple_sparc_decoder_init(lzma_next_coder *next, 78 | lzma_allocator *allocator, const lzma_filter_info *filters) 79 | { 80 | return sparc_coder_init(next, allocator, filters, false); 81 | } 82 | -------------------------------------------------------------------------------- /lua/README: -------------------------------------------------------------------------------- 1 | 2 | This is Lua 5.2.2, released on 21 Mar 2013. 3 | 4 | For installation instructions, license details, and 5 | further information about Lua, see doc/readme.html. 6 | 7 | -------------------------------------------------------------------------------- /lua/doc/logo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/lua/doc/logo.gif -------------------------------------------------------------------------------- /lua/doc/lua.1: -------------------------------------------------------------------------------- 1 | .\" $Id: lua.man,v 1.13 2011/11/16 17:16:53 lhf Exp $ 2 | .TH LUA 1 "$Date: 2011/11/16 17:16:53 $" 3 | .SH NAME 4 | lua \- Lua interpreter 5 | .SH SYNOPSIS 6 | .B lua 7 | [ 8 | .I options 9 | ] 10 | [ 11 | .I script 12 | [ 13 | .I args 14 | ] 15 | ] 16 | .SH DESCRIPTION 17 | .B lua 18 | is the standalone Lua interpreter. 19 | It loads and executes Lua programs, 20 | either in textual source form or 21 | in precompiled binary form. 22 | (Precompiled binaries are output by 23 | .BR luac , 24 | the Lua compiler.) 25 | .B lua 26 | can be used as a batch interpreter and also interactively. 27 | .LP 28 | The given 29 | .I options 30 | are handled in order and then 31 | the Lua program in file 32 | .I script 33 | is loaded and executed. 34 | The given 35 | .I args 36 | are available to 37 | .I script 38 | as strings in a global table named 39 | .BR arg . 40 | If no options or arguments are given, 41 | then 42 | .B "\-v \-i" 43 | is assumed when the standard input is a terminal; 44 | otherwise, 45 | .B "\-" 46 | is assumed. 47 | .LP 48 | In interactive mode, 49 | .B lua 50 | prompts the user, 51 | reads lines from the standard input, 52 | and executes them as they are read. 53 | If a line does not contain a complete statement, 54 | then a secondary prompt is displayed and 55 | lines are read until a complete statement is formed or 56 | a syntax error is found. 57 | If a line starts with 58 | .BR '=' , 59 | then 60 | .B lua 61 | evaluates and displays 62 | the values of the expressions in the remainder of the line. 63 | .LP 64 | At the very start, 65 | before even handling the command line, 66 | .B lua 67 | checks the contents of the environment variables 68 | .B LUA_INIT_5_2 69 | or 70 | .BR LUA_INIT , 71 | in that order. 72 | If the contents is of the form 73 | .RI '@ filename ', 74 | then 75 | .I filename 76 | is executed. 77 | Otherwise, the string is assumed to be a Lua statement and is executed. 78 | .SH OPTIONS 79 | .TP 80 | .BI \-e " stat" 81 | execute statement 82 | .IR stat . 83 | .TP 84 | .B \-i 85 | enter interactive mode after executing 86 | .IR script . 87 | .TP 88 | .BI \-l " name" 89 | execute the equivalent of 90 | .IB name =require(' name ') 91 | before executing 92 | .IR script . 93 | .TP 94 | .B \-v 95 | show version information. 96 | .TP 97 | .B \-E 98 | ignore environment variables. 99 | .TP 100 | .B \-\- 101 | stop handling options. 102 | .TP 103 | .B \- 104 | stop handling options and execute the standard input as a file. 105 | .SH "SEE ALSO" 106 | .BR luac (1) 107 | .br 108 | The documentation at lua.org, 109 | especially section 7 of the reference manual. 110 | .SH DIAGNOSTICS 111 | Error messages should be self explanatory. 112 | .SH AUTHORS 113 | R. Ierusalimschy, 114 | L. H. de Figueiredo, 115 | W. Celes 116 | .\" EOF 117 | -------------------------------------------------------------------------------- /lua/doc/lua.css: -------------------------------------------------------------------------------- 1 | body { 2 | color: #000000 ; 3 | background-color: #FFFFFF ; 4 | font-family: Helvetica, Arial, sans-serif ; 5 | text-align: justify ; 6 | margin-right: 30px ; 7 | margin-left: 30px ; 8 | } 9 | 10 | h1, h2, h3, h4 { 11 | font-family: Verdana, Geneva, sans-serif ; 12 | font-weight: normal ; 13 | font-style: italic ; 14 | } 15 | 16 | h2 { 17 | padding-top: 0.4em ; 18 | padding-bottom: 0.4em ; 19 | padding-left: 1em ; 20 | padding-right: 1em ; 21 | background-color: #E0E0FF ; 22 | border-radius: 8px ; 23 | } 24 | 25 | h3 { 26 | padding-left: 0.5em ; 27 | border-left: solid #E0E0FF 1em ; 28 | } 29 | 30 | table h3 { 31 | padding-left: 0px ; 32 | border-left: none ; 33 | } 34 | 35 | a:link { 36 | color: #000080 ; 37 | background-color: inherit ; 38 | text-decoration: none ; 39 | } 40 | 41 | a:visited { 42 | background-color: inherit ; 43 | text-decoration: none ; 44 | } 45 | 46 | a:link:hover, a:visited:hover { 47 | color: #000080 ; 48 | background-color: #E0E0FF ; 49 | } 50 | 51 | a:link:active, a:visited:active { 52 | color: #FF0000 ; 53 | } 54 | 55 | hr { 56 | border: 0 ; 57 | height: 1px ; 58 | color: #a0a0a0 ; 59 | background-color: #a0a0a0 ; 60 | } 61 | 62 | :target { 63 | background-color: #F8F8F8 ; 64 | padding: 8px ; 65 | border: solid #a0a0a0 2px ; 66 | } 67 | 68 | .footer { 69 | color: gray ; 70 | font-size: small ; 71 | } 72 | 73 | input[type=text] { 74 | border: solid #a0a0a0 2px ; 75 | border-radius: 2em ; 76 | -moz-border-radius: 2em ; 77 | background-image: url('images/search.png') ; 78 | background-repeat: no-repeat; 79 | background-position: 4px center ; 80 | padding-left: 20px ; 81 | height: 2em ; 82 | } 83 | 84 | -------------------------------------------------------------------------------- /lua/doc/manual.css: -------------------------------------------------------------------------------- 1 | h3 code { 2 | font-family: inherit ; 3 | font-size: inherit ; 4 | } 5 | 6 | pre, code { 7 | font-size: 12pt ; 8 | } 9 | 10 | span.apii { 11 | float: right ; 12 | font-family: inherit ; 13 | font-style: normal ; 14 | font-size: small ; 15 | color: gray ; 16 | } 17 | 18 | p+h1, ul+h1 { 19 | padding-top: 0.4em ; 20 | padding-bottom: 0.4em ; 21 | padding-left: 24px ; 22 | margin-left: -24px ; 23 | background-color: #E0E0FF ; 24 | border-radius: 8px ; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /lua/doc/osi-certified-72x60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/lua/doc/osi-certified-72x60.png -------------------------------------------------------------------------------- /lua/src/lapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lapi.h,v 2.7 2009/11/27 15:37:59 roberto Exp $ 3 | ** Auxiliary functions from Lua API 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lapi_h 8 | #define lapi_h 9 | 10 | 11 | #include "llimits.h" 12 | #include "lstate.h" 13 | 14 | #define api_incr_top(L) {L->top++; api_check(L, L->top <= L->ci->top, \ 15 | "stack overflow");} 16 | 17 | #define adjustresults(L,nres) \ 18 | { if ((nres) == LUA_MULTRET && L->ci->top < L->top) L->ci->top = L->top; } 19 | 20 | #define api_checknelems(L,n) api_check(L, (n) < (L->top - L->ci->func), \ 21 | "not enough elements in the stack") 22 | 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /lua/src/lcode.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lcode.h,v 1.58 2011/08/30 16:26:41 roberto Exp $ 3 | ** Code generator for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lcode_h 8 | #define lcode_h 9 | 10 | #include "llex.h" 11 | #include "lobject.h" 12 | #include "lopcodes.h" 13 | #include "lparser.h" 14 | 15 | 16 | /* 17 | ** Marks the end of a patch list. It is an invalid value both as an absolute 18 | ** address, and as a list link (would link an element to itself). 19 | */ 20 | #define NO_JUMP (-1) 21 | 22 | 23 | /* 24 | ** grep "ORDER OPR" if you change these enums (ORDER OP) 25 | */ 26 | typedef enum BinOpr { 27 | OPR_ADD, OPR_SUB, OPR_MUL, OPR_DIV, OPR_MOD, OPR_POW, 28 | OPR_CONCAT, 29 | OPR_EQ, OPR_LT, OPR_LE, 30 | OPR_NE, OPR_GT, OPR_GE, 31 | OPR_AND, OPR_OR, 32 | OPR_NOBINOPR 33 | } BinOpr; 34 | 35 | 36 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; 37 | 38 | 39 | #define getcode(fs,e) ((fs)->f->code[(e)->u.info]) 40 | 41 | #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx) 42 | 43 | #define luaK_setmultret(fs,e) luaK_setreturns(fs, e, LUA_MULTRET) 44 | 45 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) 46 | 47 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); 48 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); 49 | LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); 50 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); 51 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); 52 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); 53 | LUAI_FUNC void luaK_checkstack (FuncState *fs, int n); 54 | LUAI_FUNC int luaK_stringK (FuncState *fs, TString *s); 55 | LUAI_FUNC int luaK_numberK (FuncState *fs, lua_Number r); 56 | LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e); 57 | LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e); 58 | LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e); 59 | LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e); 60 | LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e); 61 | LUAI_FUNC int luaK_exp2RK (FuncState *fs, expdesc *e); 62 | LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key); 63 | LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); 64 | LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e); 65 | LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e); 66 | LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); 67 | LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults); 68 | LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e); 69 | LUAI_FUNC int luaK_jump (FuncState *fs); 70 | LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret); 71 | LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target); 72 | LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list); 73 | LUAI_FUNC void luaK_patchclose (FuncState *fs, int list, int level); 74 | LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2); 75 | LUAI_FUNC int luaK_getlabel (FuncState *fs); 76 | LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line); 77 | LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); 78 | LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, 79 | expdesc *v2, int line); 80 | LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore); 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /lua/src/lctype.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.c,v 1.11 2011/10/03 16:19:23 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #define lctype_c 8 | #define LUA_CORE 9 | 10 | #include "lctype.h" 11 | 12 | #if !LUA_USE_CTYPE /* { */ 13 | 14 | #include 15 | 16 | LUAI_DDEF const lu_byte luai_ctype_[UCHAR_MAX + 2] = { 17 | 0x00, /* EOZ */ 18 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0. */ 19 | 0x00, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, 20 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 1. */ 21 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 22 | 0x0c, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, /* 2. */ 23 | 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 24 | 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, 0x16, /* 3. */ 25 | 0x16, 0x16, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 26 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 4. */ 27 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 28 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 5. */ 29 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x05, 30 | 0x04, 0x15, 0x15, 0x15, 0x15, 0x15, 0x15, 0x05, /* 6. */ 31 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 32 | 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, 0x05, /* 7. */ 33 | 0x05, 0x05, 0x05, 0x04, 0x04, 0x04, 0x04, 0x00, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 8. */ 35 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 36 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 9. */ 37 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 38 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* a. */ 39 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* b. */ 41 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 42 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* c. */ 43 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 44 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* d. */ 45 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 46 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* e. */ 47 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 48 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* f. */ 49 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 50 | }; 51 | 52 | #endif /* } */ 53 | -------------------------------------------------------------------------------- /lua/src/lctype.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $ 3 | ** 'ctype' functions for Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lctype_h 8 | #define lctype_h 9 | 10 | #include "lua.h" 11 | 12 | 13 | /* 14 | ** WARNING: the functions defined here do not necessarily correspond 15 | ** to the similar functions in the standard C ctype.h. They are 16 | ** optimized for the specific needs of Lua 17 | */ 18 | 19 | #if !defined(LUA_USE_CTYPE) 20 | 21 | #if 'A' == 65 && '0' == 48 22 | /* ASCII case: can use its own tables; faster and fixed */ 23 | #define LUA_USE_CTYPE 0 24 | #else 25 | /* must use standard C ctype */ 26 | #define LUA_USE_CTYPE 1 27 | #endif 28 | 29 | #endif 30 | 31 | 32 | #if !LUA_USE_CTYPE /* { */ 33 | 34 | #include 35 | 36 | #include "llimits.h" 37 | 38 | 39 | #define ALPHABIT 0 40 | #define DIGITBIT 1 41 | #define PRINTBIT 2 42 | #define SPACEBIT 3 43 | #define XDIGITBIT 4 44 | 45 | 46 | #define MASK(B) (1 << (B)) 47 | 48 | 49 | /* 50 | ** add 1 to char to allow index -1 (EOZ) 51 | */ 52 | #define testprop(c,p) (luai_ctype_[(c)+1] & (p)) 53 | 54 | /* 55 | ** 'lalpha' (Lua alphabetic) and 'lalnum' (Lua alphanumeric) both include '_' 56 | */ 57 | #define lislalpha(c) testprop(c, MASK(ALPHABIT)) 58 | #define lislalnum(c) testprop(c, (MASK(ALPHABIT) | MASK(DIGITBIT))) 59 | #define lisdigit(c) testprop(c, MASK(DIGITBIT)) 60 | #define lisspace(c) testprop(c, MASK(SPACEBIT)) 61 | #define lisprint(c) testprop(c, MASK(PRINTBIT)) 62 | #define lisxdigit(c) testprop(c, MASK(XDIGITBIT)) 63 | 64 | /* 65 | ** this 'ltolower' only works for alphabetic characters 66 | */ 67 | #define ltolower(c) ((c) | ('A' ^ 'a')) 68 | 69 | 70 | /* two more entries for 0 and -1 (EOZ) */ 71 | LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2]; 72 | 73 | 74 | #else /* }{ */ 75 | 76 | /* 77 | ** use standard C ctypes 78 | */ 79 | 80 | #include 81 | 82 | 83 | #define lislalpha(c) (isalpha(c) || (c) == '_') 84 | #define lislalnum(c) (isalnum(c) || (c) == '_') 85 | #define lisdigit(c) (isdigit(c)) 86 | #define lisspace(c) (isspace(c)) 87 | #define lisprint(c) (isprint(c)) 88 | #define lisxdigit(c) (isxdigit(c)) 89 | 90 | #define ltolower(c) (tolower(c)) 91 | 92 | #endif /* } */ 93 | 94 | #endif 95 | 96 | -------------------------------------------------------------------------------- /lua/src/ldebug.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldebug.h,v 2.7 2011/10/07 20:45:19 roberto Exp $ 3 | ** Auxiliary functions from Debug Interface module 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldebug_h 8 | #define ldebug_h 9 | 10 | 11 | #include "lstate.h" 12 | 13 | 14 | #define pcRel(pc, p) (cast(int, (pc) - (p)->code) - 1) 15 | 16 | #define getfuncline(f,pc) (((f)->lineinfo) ? (f)->lineinfo[pc] : 0) 17 | 18 | #define resethookcount(L) (L->hookcount = L->basehookcount) 19 | 20 | /* Active Lua function (given call info) */ 21 | #define ci_func(ci) (clLvalue((ci)->func)) 22 | 23 | 24 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, 25 | const char *opname); 26 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2); 27 | LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, 28 | const TValue *p2); 29 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, 30 | const TValue *p2); 31 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); 32 | LUAI_FUNC l_noret luaG_errormsg (lua_State *L); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lua/src/ldo.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ldo.h,v 2.20 2011/11/29 15:55:08 roberto Exp $ 3 | ** Stack and Call structure of Lua 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ldo_h 8 | #define ldo_h 9 | 10 | 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | #include "lzio.h" 14 | 15 | 16 | #define luaD_checkstack(L,n) if (L->stack_last - L->top <= (n)) \ 17 | luaD_growstack(L, n); else condmovestack(L); 18 | 19 | 20 | #define incr_top(L) {L->top++; luaD_checkstack(L,0);} 21 | 22 | #define savestack(L,p) ((char *)(p) - (char *)L->stack) 23 | #define restorestack(L,n) ((TValue *)((char *)L->stack + (n))) 24 | 25 | 26 | /* type of protected functions, to be ran by `runprotected' */ 27 | typedef void (*Pfunc) (lua_State *L, void *ud); 28 | 29 | LUAI_FUNC int luaD_protectedparser (lua_State *L, ZIO *z, const char *name, 30 | const char *mode); 31 | LUAI_FUNC void luaD_hook (lua_State *L, int event, int line); 32 | LUAI_FUNC int luaD_precall (lua_State *L, StkId func, int nresults); 33 | LUAI_FUNC void luaD_call (lua_State *L, StkId func, int nResults, 34 | int allowyield); 35 | LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, 36 | ptrdiff_t oldtop, ptrdiff_t ef); 37 | LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); 38 | LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); 39 | LUAI_FUNC void luaD_growstack (lua_State *L, int n); 40 | LUAI_FUNC void luaD_shrinkstack (lua_State *L); 41 | 42 | LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode); 43 | LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /lua/src/lfunc.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lfunc.h,v 2.8 2012/05/08 13:53:33 roberto Exp $ 3 | ** Auxiliary functions to manipulate prototypes and closures 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lfunc_h 8 | #define lfunc_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | #define sizeCclosure(n) (cast(int, sizeof(CClosure)) + \ 15 | cast(int, sizeof(TValue)*((n)-1))) 16 | 17 | #define sizeLclosure(n) (cast(int, sizeof(LClosure)) + \ 18 | cast(int, sizeof(TValue *)*((n)-1))) 19 | 20 | 21 | LUAI_FUNC Proto *luaF_newproto (lua_State *L); 22 | LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems); 23 | LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems); 24 | LUAI_FUNC UpVal *luaF_newupval (lua_State *L); 25 | LUAI_FUNC UpVal *luaF_findupval (lua_State *L, StkId level); 26 | LUAI_FUNC void luaF_close (lua_State *L, StkId level); 27 | LUAI_FUNC void luaF_freeproto (lua_State *L, Proto *f); 28 | LUAI_FUNC void luaF_freeupval (lua_State *L, UpVal *uv); 29 | LUAI_FUNC const char *luaF_getlocalname (const Proto *func, int local_number, 30 | int pc); 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /lua/src/linit.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.32 2011/04/08 19:17:36 roberto Exp $ 3 | ** Initialization of libraries for lua.c and other clients 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | /* 9 | ** If you embed Lua in your program and need to open the standard 10 | ** libraries, call luaL_openlibs in your program. If you need a 11 | ** different set of libraries, copy this file to your project and edit 12 | ** it to suit your needs. 13 | */ 14 | 15 | 16 | #define linit_c 17 | #define LUA_LIB 18 | 19 | #include "lua.h" 20 | 21 | #include "lualib.h" 22 | #include "lauxlib.h" 23 | 24 | 25 | /* 26 | ** these libs are loaded by lua.c and are readily available to any Lua 27 | ** program 28 | */ 29 | static const luaL_Reg loadedlibs[] = { 30 | {"_G", luaopen_base}, 31 | {LUA_LOADLIBNAME, luaopen_package}, 32 | {LUA_COLIBNAME, luaopen_coroutine}, 33 | {LUA_TABLIBNAME, luaopen_table}, 34 | {LUA_IOLIBNAME, luaopen_io}, 35 | {LUA_OSLIBNAME, luaopen_os}, 36 | {LUA_STRLIBNAME, luaopen_string}, 37 | {LUA_BITLIBNAME, luaopen_bit32}, 38 | {LUA_MATHLIBNAME, luaopen_math}, 39 | {LUA_DBLIBNAME, luaopen_debug}, 40 | {NULL, NULL} 41 | }; 42 | 43 | 44 | /* 45 | ** these libs are preloaded and must be required before used 46 | */ 47 | static const luaL_Reg preloadedlibs[] = { 48 | {NULL, NULL} 49 | }; 50 | 51 | 52 | LUALIB_API void luaL_openlibs (lua_State *L) { 53 | const luaL_Reg *lib; 54 | /* call open functions from 'loadedlibs' and set results to global table */ 55 | for (lib = loadedlibs; lib->func; lib++) { 56 | luaL_requiref(L, lib->name, lib->func, 1); 57 | lua_pop(L, 1); /* remove lib */ 58 | } 59 | /* add open functions from 'preloadedlibs' into 'package.preload' table */ 60 | luaL_getsubtable(L, LUA_REGISTRYINDEX, "_PRELOAD"); 61 | for (lib = preloadedlibs; lib->func; lib++) { 62 | lua_pushcfunction(L, lib->func); 63 | lua_setfield(L, -2, lib->name); 64 | } 65 | lua_pop(L, 1); /* remove _PRELOAD table */ 66 | } 67 | 68 | -------------------------------------------------------------------------------- /lua/src/llex.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: llex.h,v 1.72 2011/11/30 12:43:51 roberto Exp $ 3 | ** Lexical Analyzer 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef llex_h 8 | #define llex_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | 14 | #define FIRST_RESERVED 257 15 | 16 | 17 | 18 | /* 19 | * WARNING: if you change the order of this enumeration, 20 | * grep "ORDER RESERVED" 21 | */ 22 | enum RESERVED { 23 | /* terminal symbols denoted by reserved words */ 24 | TK_AND = FIRST_RESERVED, TK_BREAK, 25 | TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION, 26 | TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT, 27 | TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE, 28 | /* other terminal symbols */ 29 | TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS, 30 | TK_NUMBER, TK_NAME, TK_STRING 31 | }; 32 | 33 | /* number of reserved words */ 34 | #define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1)) 35 | 36 | 37 | typedef union { 38 | lua_Number r; 39 | TString *ts; 40 | } SemInfo; /* semantics information */ 41 | 42 | 43 | typedef struct Token { 44 | int token; 45 | SemInfo seminfo; 46 | } Token; 47 | 48 | 49 | /* state of the lexer plus state of the parser when shared by all 50 | functions */ 51 | typedef struct LexState { 52 | int current; /* current character (charint) */ 53 | int linenumber; /* input line counter */ 54 | int lastline; /* line of last token `consumed' */ 55 | Token t; /* current token */ 56 | Token lookahead; /* look ahead token */ 57 | struct FuncState *fs; /* current function (parser) */ 58 | struct lua_State *L; 59 | ZIO *z; /* input stream */ 60 | Mbuffer *buff; /* buffer for tokens */ 61 | struct Dyndata *dyd; /* dynamic structures used by the parser */ 62 | TString *source; /* current source name */ 63 | TString *envn; /* environment variable name */ 64 | char decpoint; /* locale decimal point */ 65 | } LexState; 66 | 67 | 68 | LUAI_FUNC void luaX_init (lua_State *L); 69 | LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, 70 | TString *source, int firstchar); 71 | LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l); 72 | LUAI_FUNC void luaX_next (LexState *ls); 73 | LUAI_FUNC int luaX_lookahead (LexState *ls); 74 | LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s); 75 | LUAI_FUNC const char *luaX_token2str (LexState *ls, int token); 76 | 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /lua/src/lmem.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.c,v 1.84 2012/05/23 15:41:53 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lmem_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "ldebug.h" 16 | #include "ldo.h" 17 | #include "lgc.h" 18 | #include "lmem.h" 19 | #include "lobject.h" 20 | #include "lstate.h" 21 | 22 | 23 | 24 | /* 25 | ** About the realloc function: 26 | ** void * frealloc (void *ud, void *ptr, size_t osize, size_t nsize); 27 | ** (`osize' is the old size, `nsize' is the new size) 28 | ** 29 | ** * frealloc(ud, NULL, x, s) creates a new block of size `s' (no 30 | ** matter 'x'). 31 | ** 32 | ** * frealloc(ud, p, x, 0) frees the block `p' 33 | ** (in this specific case, frealloc must return NULL); 34 | ** particularly, frealloc(ud, NULL, 0, 0) does nothing 35 | ** (which is equivalent to free(NULL) in ANSI C) 36 | ** 37 | ** frealloc returns NULL if it cannot create or reallocate the area 38 | ** (any reallocation to an equal or smaller size cannot fail!) 39 | */ 40 | 41 | 42 | 43 | #define MINSIZEARRAY 4 44 | 45 | 46 | void *luaM_growaux_ (lua_State *L, void *block, int *size, size_t size_elems, 47 | int limit, const char *what) { 48 | void *newblock; 49 | int newsize; 50 | if (*size >= limit/2) { /* cannot double it? */ 51 | if (*size >= limit) /* cannot grow even a little? */ 52 | luaG_runerror(L, "too many %s (limit is %d)", what, limit); 53 | newsize = limit; /* still have at least one free place */ 54 | } 55 | else { 56 | newsize = (*size)*2; 57 | if (newsize < MINSIZEARRAY) 58 | newsize = MINSIZEARRAY; /* minimum size */ 59 | } 60 | newblock = luaM_reallocv(L, block, *size, newsize, size_elems); 61 | *size = newsize; /* update only when everything else is OK */ 62 | return newblock; 63 | } 64 | 65 | 66 | l_noret luaM_toobig (lua_State *L) { 67 | luaG_runerror(L, "memory allocation error: block too big"); 68 | } 69 | 70 | 71 | 72 | /* 73 | ** generic allocation routine. 74 | */ 75 | void *luaM_realloc_ (lua_State *L, void *block, size_t osize, size_t nsize) { 76 | void *newblock; 77 | global_State *g = G(L); 78 | size_t realosize = (block) ? osize : 0; 79 | lua_assert((realosize == 0) == (block == NULL)); 80 | #if defined(HARDMEMTESTS) 81 | if (nsize > realosize && g->gcrunning) 82 | luaC_fullgc(L, 1); /* force a GC whenever possible */ 83 | #endif 84 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); 85 | if (newblock == NULL && nsize > 0) { 86 | api_check(L, nsize > realosize, 87 | "realloc cannot fail when shrinking a block"); 88 | if (g->gcrunning) { 89 | luaC_fullgc(L, 1); /* try to free some memory... */ 90 | newblock = (*g->frealloc)(g->ud, block, osize, nsize); /* try again */ 91 | } 92 | if (newblock == NULL) 93 | luaD_throw(L, LUA_ERRMEM); 94 | } 95 | lua_assert((nsize == 0) == (newblock == NULL)); 96 | g->GCdebt = (g->GCdebt + nsize) - realosize; 97 | return newblock; 98 | } 99 | 100 | -------------------------------------------------------------------------------- /lua/src/lmem.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lmem.h,v 1.40 2013/02/20 14:08:21 roberto Exp $ 3 | ** Interface to Memory Manager 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lmem_h 8 | #define lmem_h 9 | 10 | 11 | #include 12 | 13 | #include "llimits.h" 14 | #include "lua.h" 15 | 16 | 17 | /* 18 | ** This macro avoids the runtime division MAX_SIZET/(e), as 'e' is 19 | ** always constant. 20 | ** The macro is somewhat complex to avoid warnings: 21 | ** +1 avoids warnings of "comparison has constant result"; 22 | ** cast to 'void' avoids warnings of "value unused". 23 | */ 24 | #define luaM_reallocv(L,b,on,n,e) \ 25 | (cast(void, \ 26 | (cast(size_t, (n)+1) > MAX_SIZET/(e)) ? (luaM_toobig(L), 0) : 0), \ 27 | luaM_realloc_(L, (b), (on)*(e), (n)*(e))) 28 | 29 | #define luaM_freemem(L, b, s) luaM_realloc_(L, (b), (s), 0) 30 | #define luaM_free(L, b) luaM_realloc_(L, (b), sizeof(*(b)), 0) 31 | #define luaM_freearray(L, b, n) luaM_reallocv(L, (b), n, 0, sizeof((b)[0])) 32 | 33 | #define luaM_malloc(L,s) luaM_realloc_(L, NULL, 0, (s)) 34 | #define luaM_new(L,t) cast(t *, luaM_malloc(L, sizeof(t))) 35 | #define luaM_newvector(L,n,t) \ 36 | cast(t *, luaM_reallocv(L, NULL, 0, n, sizeof(t))) 37 | 38 | #define luaM_newobject(L,tag,s) luaM_realloc_(L, NULL, tag, (s)) 39 | 40 | #define luaM_growvector(L,v,nelems,size,t,limit,e) \ 41 | if ((nelems)+1 > (size)) \ 42 | ((v)=cast(t *, luaM_growaux_(L,v,&(size),sizeof(t),limit,e))) 43 | 44 | #define luaM_reallocvector(L, v,oldn,n,t) \ 45 | ((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) 46 | 47 | LUAI_FUNC l_noret luaM_toobig (lua_State *L); 48 | 49 | /* not to be called directly */ 50 | LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, 51 | size_t size); 52 | LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, 53 | size_t size_elem, int limit, 54 | const char *what); 55 | 56 | #endif 57 | 58 | -------------------------------------------------------------------------------- /lua/src/lstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lstring.h,v 1.49 2012/02/01 21:57:15 roberto Exp $ 3 | ** String table (keep all strings handled by Lua) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lstring_h 8 | #define lstring_h 9 | 10 | #include "lgc.h" 11 | #include "lobject.h" 12 | #include "lstate.h" 13 | 14 | 15 | #define sizestring(s) (sizeof(union TString)+((s)->len+1)*sizeof(char)) 16 | 17 | #define sizeudata(u) (sizeof(union Udata)+(u)->len) 18 | 19 | #define luaS_newliteral(L, s) (luaS_newlstr(L, "" s, \ 20 | (sizeof(s)/sizeof(char))-1)) 21 | 22 | #define luaS_fix(s) l_setbit((s)->tsv.marked, FIXEDBIT) 23 | 24 | 25 | /* 26 | ** test whether a string is a reserved word 27 | */ 28 | #define isreserved(s) ((s)->tsv.tt == LUA_TSHRSTR && (s)->tsv.extra > 0) 29 | 30 | 31 | /* 32 | ** equality for short strings, which are always internalized 33 | */ 34 | #define eqshrstr(a,b) check_exp((a)->tsv.tt == LUA_TSHRSTR, (a) == (b)) 35 | 36 | 37 | LUAI_FUNC unsigned int luaS_hash (const char *str, size_t l, unsigned int seed); 38 | LUAI_FUNC int luaS_eqlngstr (TString *a, TString *b); 39 | LUAI_FUNC int luaS_eqstr (TString *a, TString *b); 40 | LUAI_FUNC void luaS_resize (lua_State *L, int newsize); 41 | LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); 42 | LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); 43 | LUAI_FUNC TString *luaS_new (lua_State *L, const char *str); 44 | 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /lua/src/ltable.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltable.h,v 2.16 2011/08/17 20:26:47 roberto Exp $ 3 | ** Lua tables (hash) 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltable_h 8 | #define ltable_h 9 | 10 | #include "lobject.h" 11 | 12 | 13 | #define gnode(t,i) (&(t)->node[i]) 14 | #define gkey(n) (&(n)->i_key.tvk) 15 | #define gval(n) (&(n)->i_val) 16 | #define gnext(n) ((n)->i_key.nk.next) 17 | 18 | #define invalidateTMcache(t) ((t)->flags = 0) 19 | 20 | 21 | LUAI_FUNC const TValue *luaH_getint (Table *t, int key); 22 | LUAI_FUNC void luaH_setint (lua_State *L, Table *t, int key, TValue *value); 23 | LUAI_FUNC const TValue *luaH_getstr (Table *t, TString *key); 24 | LUAI_FUNC const TValue *luaH_get (Table *t, const TValue *key); 25 | LUAI_FUNC TValue *luaH_newkey (lua_State *L, Table *t, const TValue *key); 26 | LUAI_FUNC TValue *luaH_set (lua_State *L, Table *t, const TValue *key); 27 | LUAI_FUNC Table *luaH_new (lua_State *L); 28 | LUAI_FUNC void luaH_resize (lua_State *L, Table *t, int nasize, int nhsize); 29 | LUAI_FUNC void luaH_resizearray (lua_State *L, Table *t, int nasize); 30 | LUAI_FUNC void luaH_free (lua_State *L, Table *t); 31 | LUAI_FUNC int luaH_next (lua_State *L, Table *t, StkId key); 32 | LUAI_FUNC int luaH_getn (Table *t); 33 | 34 | 35 | #if defined(LUA_DEBUG) 36 | LUAI_FUNC Node *luaH_mainposition (const Table *t, const TValue *key); 37 | LUAI_FUNC int luaH_isdummy (Node *n); 38 | #endif 39 | 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /lua/src/ltm.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.c,v 2.14 2011/06/02 19:31:40 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define ltm_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "lobject.h" 16 | #include "lstate.h" 17 | #include "lstring.h" 18 | #include "ltable.h" 19 | #include "ltm.h" 20 | 21 | 22 | static const char udatatypename[] = "userdata"; 23 | 24 | LUAI_DDEF const char *const luaT_typenames_[LUA_TOTALTAGS] = { 25 | "no value", 26 | "nil", "boolean", udatatypename, "number", 27 | "string", "table", "function", udatatypename, "thread", 28 | "proto", "upval" /* these last two cases are used for tests only */ 29 | }; 30 | 31 | 32 | void luaT_init (lua_State *L) { 33 | static const char *const luaT_eventname[] = { /* ORDER TM */ 34 | "__index", "__newindex", 35 | "__gc", "__mode", "__len", "__eq", 36 | "__add", "__sub", "__mul", "__div", "__mod", 37 | "__pow", "__unm", "__lt", "__le", 38 | "__concat", "__call" 39 | }; 40 | int i; 41 | for (i=0; itmname[i] = luaS_new(L, luaT_eventname[i]); 43 | luaS_fix(G(L)->tmname[i]); /* never collect these names */ 44 | } 45 | } 46 | 47 | 48 | /* 49 | ** function to be used with macro "fasttm": optimized for absence of 50 | ** tag methods 51 | */ 52 | const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { 53 | const TValue *tm = luaH_getstr(events, ename); 54 | lua_assert(event <= TM_EQ); 55 | if (ttisnil(tm)) { /* no tag method? */ 56 | events->flags |= cast_byte(1u<metatable; 68 | break; 69 | case LUA_TUSERDATA: 70 | mt = uvalue(o)->metatable; 71 | break; 72 | default: 73 | mt = G(L)->mt[ttypenv(o)]; 74 | } 75 | return (mt ? luaH_getstr(mt, G(L)->tmname[event]) : luaO_nilobject); 76 | } 77 | 78 | -------------------------------------------------------------------------------- /lua/src/ltm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: ltm.h,v 2.11 2011/02/28 17:32:10 roberto Exp $ 3 | ** Tag methods 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef ltm_h 8 | #define ltm_h 9 | 10 | 11 | #include "lobject.h" 12 | 13 | 14 | /* 15 | * WARNING: if you change the order of this enumeration, 16 | * grep "ORDER TM" 17 | */ 18 | typedef enum { 19 | TM_INDEX, 20 | TM_NEWINDEX, 21 | TM_GC, 22 | TM_MODE, 23 | TM_LEN, 24 | TM_EQ, /* last tag method with `fast' access */ 25 | TM_ADD, 26 | TM_SUB, 27 | TM_MUL, 28 | TM_DIV, 29 | TM_MOD, 30 | TM_POW, 31 | TM_UNM, 32 | TM_LT, 33 | TM_LE, 34 | TM_CONCAT, 35 | TM_CALL, 36 | TM_N /* number of elements in the enum */ 37 | } TMS; 38 | 39 | 40 | 41 | #define gfasttm(g,et,e) ((et) == NULL ? NULL : \ 42 | ((et)->flags & (1u<<(e))) ? NULL : luaT_gettm(et, e, (g)->tmname[e])) 43 | 44 | #define fasttm(l,et,e) gfasttm(G(l), et, e) 45 | 46 | #define ttypename(x) luaT_typenames_[(x) + 1] 47 | #define objtypename(x) ttypename(ttypenv(x)) 48 | 49 | LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS]; 50 | 51 | 52 | LUAI_FUNC const TValue *luaT_gettm (Table *events, TMS event, TString *ename); 53 | LUAI_FUNC const TValue *luaT_gettmbyobj (lua_State *L, const TValue *o, 54 | TMS event); 55 | LUAI_FUNC void luaT_init (lua_State *L); 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /lua/src/lua.hpp: -------------------------------------------------------------------------------- 1 | // lua.hpp 2 | // Lua header files for C++ 3 | // <> not supplied automatically because Lua also compiles as C++ 4 | 5 | extern "C" { 6 | #include "lua.h" 7 | #include "lualib.h" 8 | #include "lauxlib.h" 9 | } 10 | -------------------------------------------------------------------------------- /lua/src/lualib.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.43 2011/12/08 12:11:37 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lualib_h 9 | #define lualib_h 10 | 11 | #include "lua.h" 12 | 13 | 14 | 15 | LUAMOD_API int (luaopen_base) (lua_State *L); 16 | 17 | #define LUA_COLIBNAME "coroutine" 18 | LUAMOD_API int (luaopen_coroutine) (lua_State *L); 19 | 20 | #define LUA_TABLIBNAME "table" 21 | LUAMOD_API int (luaopen_table) (lua_State *L); 22 | 23 | #define LUA_IOLIBNAME "io" 24 | LUAMOD_API int (luaopen_io) (lua_State *L); 25 | 26 | #define LUA_OSLIBNAME "os" 27 | LUAMOD_API int (luaopen_os) (lua_State *L); 28 | 29 | #define LUA_STRLIBNAME "string" 30 | LUAMOD_API int (luaopen_string) (lua_State *L); 31 | 32 | #define LUA_BITLIBNAME "bit32" 33 | LUAMOD_API int (luaopen_bit32) (lua_State *L); 34 | 35 | #define LUA_MATHLIBNAME "math" 36 | LUAMOD_API int (luaopen_math) (lua_State *L); 37 | 38 | #define LUA_DBLIBNAME "debug" 39 | LUAMOD_API int (luaopen_debug) (lua_State *L); 40 | 41 | #define LUA_LOADLIBNAME "package" 42 | LUAMOD_API int (luaopen_package) (lua_State *L); 43 | 44 | 45 | /* open all previous libraries */ 46 | LUALIB_API void (luaL_openlibs) (lua_State *L); 47 | 48 | 49 | 50 | #if !defined(lua_assert) 51 | #define lua_assert(x) ((void)0) 52 | #endif 53 | 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /lua/src/lundump.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lundump.h,v 1.39 2012/05/08 13:53:33 roberto Exp $ 3 | ** load precompiled Lua chunks 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lundump_h 8 | #define lundump_h 9 | 10 | #include "lobject.h" 11 | #include "lzio.h" 12 | 13 | /* load one chunk; from lundump.c */ 14 | LUAI_FUNC Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name); 15 | 16 | /* make header; from lundump.c */ 17 | LUAI_FUNC void luaU_header (lu_byte* h); 18 | 19 | /* dump one chunk; from ldump.c */ 20 | LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); 21 | 22 | /* data to catch conversion errors */ 23 | #define LUAC_TAIL "\x19\x93\r\n\x1a\n" 24 | 25 | /* size in bytes of header of binary files */ 26 | #define LUAC_HEADERSIZE (sizeof(LUA_SIGNATURE)-sizeof(char)+2+6+sizeof(LUAC_TAIL)-sizeof(char)) 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /lua/src/lvm.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lvm.h,v 2.18 2013/01/08 14:06:55 roberto Exp $ 3 | ** Lua virtual machine 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | #ifndef lvm_h 8 | #define lvm_h 9 | 10 | 11 | #include "ldo.h" 12 | #include "lobject.h" 13 | #include "ltm.h" 14 | 15 | 16 | #define tostring(L,o) (ttisstring(o) || (luaV_tostring(L, o))) 17 | 18 | #define tonumber(o,n) (ttisnumber(o) || (((o) = luaV_tonumber(o,n)) != NULL)) 19 | 20 | #define equalobj(L,o1,o2) (ttisequal(o1, o2) && luaV_equalobj_(L, o1, o2)) 21 | 22 | #define luaV_rawequalobj(o1,o2) equalobj(NULL,o1,o2) 23 | 24 | 25 | /* not to called directly */ 26 | LUAI_FUNC int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2); 27 | 28 | 29 | LUAI_FUNC int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r); 30 | LUAI_FUNC int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r); 31 | LUAI_FUNC const TValue *luaV_tonumber (const TValue *obj, TValue *n); 32 | LUAI_FUNC int luaV_tostring (lua_State *L, StkId obj); 33 | LUAI_FUNC void luaV_gettable (lua_State *L, const TValue *t, TValue *key, 34 | StkId val); 35 | LUAI_FUNC void luaV_settable (lua_State *L, const TValue *t, TValue *key, 36 | StkId val); 37 | LUAI_FUNC void luaV_finishOp (lua_State *L); 38 | LUAI_FUNC void luaV_execute (lua_State *L); 39 | LUAI_FUNC void luaV_concat (lua_State *L, int total); 40 | LUAI_FUNC void luaV_arith (lua_State *L, StkId ra, const TValue *rb, 41 | const TValue *rc, TMS op); 42 | LUAI_FUNC void luaV_objlen (lua_State *L, StkId ra, const TValue *rb); 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /lua/src/lzio.c: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.c,v 1.35 2012/05/14 13:34:18 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #include 9 | 10 | #define lzio_c 11 | #define LUA_CORE 12 | 13 | #include "lua.h" 14 | 15 | #include "llimits.h" 16 | #include "lmem.h" 17 | #include "lstate.h" 18 | #include "lzio.h" 19 | 20 | 21 | int luaZ_fill (ZIO *z) { 22 | size_t size; 23 | lua_State *L = z->L; 24 | const char *buff; 25 | lua_unlock(L); 26 | buff = z->reader(L, z->data, &size); 27 | lua_lock(L); 28 | if (buff == NULL || size == 0) 29 | return EOZ; 30 | z->n = size - 1; /* discount char being returned */ 31 | z->p = buff; 32 | return cast_uchar(*(z->p++)); 33 | } 34 | 35 | 36 | void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, void *data) { 37 | z->L = L; 38 | z->reader = reader; 39 | z->data = data; 40 | z->n = 0; 41 | z->p = NULL; 42 | } 43 | 44 | 45 | /* --------------------------------------------------------------- read --- */ 46 | size_t luaZ_read (ZIO *z, void *b, size_t n) { 47 | while (n) { 48 | size_t m; 49 | if (z->n == 0) { /* no bytes in buffer? */ 50 | if (luaZ_fill(z) == EOZ) /* try to read more */ 51 | return n; /* no more input; return number of missing bytes */ 52 | else { 53 | z->n++; /* luaZ_fill consumed first byte; put it back */ 54 | z->p--; 55 | } 56 | } 57 | m = (n <= z->n) ? n : z->n; /* min. between n and z->n */ 58 | memcpy(b, z->p, m); 59 | z->n -= m; 60 | z->p += m; 61 | b = (char *)b + m; 62 | n -= m; 63 | } 64 | return 0; 65 | } 66 | 67 | /* ------------------------------------------------------------------------ */ 68 | char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n) { 69 | if (n > buff->buffsize) { 70 | if (n < LUA_MINBUFFER) n = LUA_MINBUFFER; 71 | luaZ_resizebuffer(L, buff, n); 72 | } 73 | return buff->buffer; 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /lua/src/lzio.h: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lzio.h,v 1.26 2011/07/15 12:48:03 roberto Exp $ 3 | ** Buffered streams 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | 8 | #ifndef lzio_h 9 | #define lzio_h 10 | 11 | #include "lua.h" 12 | 13 | #include "lmem.h" 14 | 15 | 16 | #define EOZ (-1) /* end of stream */ 17 | 18 | typedef struct Zio ZIO; 19 | 20 | #define zgetc(z) (((z)->n--)>0 ? cast_uchar(*(z)->p++) : luaZ_fill(z)) 21 | 22 | 23 | typedef struct Mbuffer { 24 | char *buffer; 25 | size_t n; 26 | size_t buffsize; 27 | } Mbuffer; 28 | 29 | #define luaZ_initbuffer(L, buff) ((buff)->buffer = NULL, (buff)->buffsize = 0) 30 | 31 | #define luaZ_buffer(buff) ((buff)->buffer) 32 | #define luaZ_sizebuffer(buff) ((buff)->buffsize) 33 | #define luaZ_bufflen(buff) ((buff)->n) 34 | 35 | #define luaZ_resetbuffer(buff) ((buff)->n = 0) 36 | 37 | 38 | #define luaZ_resizebuffer(L, buff, size) \ 39 | (luaM_reallocvector(L, (buff)->buffer, (buff)->buffsize, size, char), \ 40 | (buff)->buffsize = size) 41 | 42 | #define luaZ_freebuffer(L, buff) luaZ_resizebuffer(L, buff, 0) 43 | 44 | 45 | LUAI_FUNC char *luaZ_openspace (lua_State *L, Mbuffer *buff, size_t n); 46 | LUAI_FUNC void luaZ_init (lua_State *L, ZIO *z, lua_Reader reader, 47 | void *data); 48 | LUAI_FUNC size_t luaZ_read (ZIO* z, void* b, size_t n); /* read next n bytes */ 49 | 50 | 51 | 52 | /* --------- Private Part ------------------ */ 53 | 54 | struct Zio { 55 | size_t n; /* bytes still unread */ 56 | const char *p; /* current position in buffer */ 57 | lua_Reader reader; /* reader function */ 58 | void* data; /* additional data */ 59 | lua_State *L; /* Lua state (for reader) */ 60 | }; 61 | 62 | 63 | LUAI_FUNC int luaZ_fill (ZIO *z); 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /lua_glue.h: -------------------------------------------------------------------------------- 1 | /** 2 | * MojoSetup; a portable, flexible installation application. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #ifndef _INCL_LUA_GLUE_H_ 10 | #define _INCL_LUA_GLUE_H_ 11 | 12 | #include "universal.h" 13 | 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | // License text for MojoSetup. 19 | extern const char *GMojoSetupLicense; 20 | 21 | // License text for Lua. 22 | extern const char *GLuaLicense; 23 | 24 | 25 | boolean MojoLua_initLua(void); 26 | void MojoLua_deinitLua(void); 27 | boolean MojoLua_initialized(void); 28 | 29 | // Run the code in a given Lua file. This is JUST the base filename. 30 | // We will look for it in GBaseArchive in the (dir) directory, both as 31 | // fname.luac and fname.lua. This code chunk will accept no arguments, and 32 | // return no results, but it can change the global state and alter tables, 33 | // etc, so it can have lasting side effects. 34 | // Will return false if the file couldn't be loaded, or true if the chunk 35 | // successfully ran. Will not return if there's a runtime error in the 36 | // chunk, as it will call fatal() instead. 37 | boolean MojoLua_runFileFromDir(const char *dir, const char *name); 38 | 39 | // This is shorthand for MojoLua_runFileFromDir("scripts", fname); 40 | boolean MojoLua_runFile(const char *fname); 41 | 42 | // Call a function in Lua. This calls MojoSetup.funcname, if it exists and 43 | // is a function. It will not pass any parameters and it will not return 44 | // any values. The call is made unprotected, so if Lua triggers an error, 45 | // this C function will not return. Don't use this if you don't know what 46 | // you're doing. 47 | // Returns true if function was called, false otherwise. 48 | boolean MojoLua_callProcedure(const char *funcname); 49 | 50 | // Set a Lua variable in the MojoSetup namespace to a string: 51 | // MojoLua_setString("bob", "name"); 52 | // in Lua: print(MojoSetup.name) -- outputs: bob 53 | void MojoLua_setString(const char *str, const char *sym); 54 | 55 | // Same as MojoLua_setString, but it creates an ordered table (array). 56 | void MojoLua_setStringArray(int argc, const char **argv, const char *sym); 57 | 58 | void MojoLua_collectGarbage(void); 59 | 60 | void MojoLua_debugger(void); 61 | 62 | #ifdef __cplusplus 63 | } 64 | #endif 65 | 66 | #endif 67 | 68 | // end of lua_glue.h ... 69 | 70 | -------------------------------------------------------------------------------- /meta/xdg-utils/xdg-open: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | #(obfuscated for size by shrinksh.sh) 3 | #Copyright 2006, Kevin Krammer 4 | #Copyright 2006, Jeremy White 5 | #LICENSE: 6 | #Permission is hereby granted, free of charge, to any person obtaining a 7 | #copy of this software and associated documentation files (the "Software"), 8 | #to deal in the Software without restriction, including without limitation 9 | #the rights to use, copy, modify, merge, publish, distribute, sublicense, 10 | #and/or sell copies of the Software, and to permit persons to whom the 11 | #Software is furnished to do so, subject to the following conditions: 12 | #The above copyright notice and this permission notice shall be included 13 | #in all copies or substantial portions of the Software. 14 | #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | #OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | #THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 | #OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 | #ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 | #OTHER DEALINGS IN THE SOFTWARE. 21 | f1() 22 | { 23 | if [ $# -gt 0 ]; then 24 | echo "$@" 25 | echo 26 | fi 27 | exit 0 28 | } 29 | f2() 30 | { 31 | exit 1 32 | } 33 | f3() 34 | { 35 | exit 3 36 | } 37 | f4() 38 | { 39 | exit 4 40 | } 41 | f5() 42 | { 43 | if [ x"$KDE_FULL_SESSION" = x"true" ]; then DE=kde; 44 | elif [ x"$GNOME_DESKTOP_SESSION_ID" != x"" ]; then DE=gnome; 45 | elif xprop -root _DT_SAVE_MODE | grep ' = \"xfce4\"$' >/dev/null 2>&1; then DE=xfce; 46 | fi 47 | } 48 | f6() 49 | { 50 | version=`kde-config --version 2>/dev/null | grep KDE` 51 | major=`echo $version | sed 's/KDE: \([0-9]\).*/\1/'` 52 | minor=`echo $version | sed 's/KDE: [0-9]*\.\([0-9]\).*/\1/'` 53 | release=`echo $version | sed 's/KDE: [0-9]*\.[0-9]*\.\([0-9]\).*/\1/'` 54 | test "$major" -gt 3 && return $1 55 | test "$minor" -gt 5 && return $1 56 | test "$release" -gt 4 && return $1 57 | return 0 58 | } 59 | f7() 60 | { 61 | kfmclient exec "$1" 62 | f6 $? 63 | if [ $? -eq 0 ]; then 64 | f1 65 | else 66 | f4 67 | fi 68 | } 69 | f8() 70 | { 71 | gnome-open "$1" 72 | if [ $? -eq 0 ]; then 73 | f1 74 | else 75 | f4 76 | fi 77 | } 78 | f9() 79 | { 80 | exo-open "$1" 81 | if [ $? -eq 0 ]; then 82 | f1 83 | else 84 | f4 85 | fi 86 | } 87 | f10() 88 | { 89 | IFS=":" 90 | for browser in $BROWSER; do 91 | if [ x"$browser" != x"" ]; then 92 | browser_with_arg=`echo "$browser" | sed s#%s#"$1"#` 93 | if [ x"$browser_with_arg" = x"$browser" ]; then "$browser" "$1"; 94 | else $browser_with_arg; 95 | fi 96 | if [ $? -eq 0 ]; then f1; 97 | fi 98 | fi 99 | done 100 | f3 101 | } 102 | [ x"$1" != x"" ] || f2 103 | url= 104 | while [ $# -gt 0 ] ; do 105 | parm="$1" 106 | shift 107 | case "$parm" in 108 | -*) 109 | f2 110 | ;; 111 | *) 112 | if [ -n "$url" ] ; then 113 | f2 114 | fi 115 | url="$parm" 116 | ;; 117 | esac 118 | done 119 | if [ -z "${url}" ] ; then 120 | f2 121 | fi 122 | f5 123 | if [ x"$DE" = x"" ]; then 124 | if [ x"$BROWSER" = x"" ]; then 125 | BROWSER=firefox:mozilla:netscape 126 | fi 127 | DE=generic 128 | fi 129 | case "$DE" in 130 | kde) 131 | f7 "$url" 132 | ;; 133 | gnome) 134 | f8 "$url" 135 | ;; 136 | xfce) 137 | f9 "$url" 138 | ;; 139 | generic) 140 | f10 "$url" 141 | ;; 142 | *) 143 | f3 144 | ;; 145 | esac 146 | -------------------------------------------------------------------------------- /miniz.c: -------------------------------------------------------------------------------- 1 | /** 2 | * MojoSetup; a portable, flexible installation application. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | #define MINIZ_INCLUDE_IMPLEMENTATION 1 10 | #include "miniz.h" 11 | 12 | // end of miniz.c ... 13 | 14 | -------------------------------------------------------------------------------- /misc/MacAppBundleSkeleton/Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleExecutable 8 | mojosetup 9 | CFBundleIdentifier 10 | org.icculus.mojosetup 11 | CFBundleIconFile 12 | mojosetup.icns 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundlePackageType 16 | APPL 17 | CFBundleSignature 18 | MjSt 19 | CFBundleShortVersionString 20 | 1.0 21 | CSResourcesFileMapped 22 | 23 | CFBundleName 24 | YOUR_APPLICATION_NAME_HERE 25 | 26 | 27 | -------------------------------------------------------------------------------- /misc/MacAppBundleSkeleton/Contents/PkgInfo: -------------------------------------------------------------------------------- 1 | APPLMjSt -------------------------------------------------------------------------------- /misc/MacAppBundleSkeleton/Contents/Resources/mojosetup.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/icculus/mojosetup/f601d115a3b32467e4f861f1ab73a5f26c4f0de1/misc/MacAppBundleSkeleton/Contents/Resources/mojosetup.icns -------------------------------------------------------------------------------- /misc/cp.cmake: -------------------------------------------------------------------------------- 1 | # CMake 2.4.3 lacks a "CMake -E copy" command that handles wildcards. 2 | # 3 | # INPUT: 4 | # 5 | # FROM - absolute pathname with wildcards to copy 6 | # TO - absolute pathname of directory to copy to 7 | # 8 | # TYPICAL USAGE, from inside a custom target or rule: 9 | # 10 | # COMMAND ${CMAKE_COMMAND} 11 | # -D FROM=${mydirectory}/*.dll 12 | # -D TO=${yourdirectory} 13 | # -P ${CMAKE_HOME_DIRECTORY}/cp.cmake 14 | 15 | FILE(GLOB FILELIST "${FROM}") 16 | 17 | FOREACH(LOOPER ${FILELIST}) 18 | MESSAGE(STATUS "Copying ${LOOPER} to ${TO}") 19 | EXEC_PROGRAM("${CMAKE_COMMAND}" ARGS "-E copy '${LOOPER}' '${TO}'" 20 | OUTPUT_VARIABLE EXECOUT 21 | RETURN_VALUE RC 22 | ) 23 | # !!! FIXME: how do you do NOT EQUALS? 24 | IF(NOT RC EQUAL 0) 25 | MESSAGE(STATUS "${EXECOUT}") 26 | MESSAGE(FATAL_ERROR "Copy of '${LOOPER}' failed!") 27 | ENDIF(NOT RC EQUAL 0) 28 | ENDFOREACH(LOOPER) 29 | 30 | -------------------------------------------------------------------------------- /misc/find_localizable_strings.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | grep -n '_("' *.[chm] scripts/*.lua |perl -w -p -e 's/\A.*?_\((".*?")\).*?\Z/$1/;' |sort |uniq |perl -w -p -e 'chomp; $_ = " [$_] = {\n };\n\n";' 4 | 5 | -------------------------------------------------------------------------------- /misc/launchpad-import.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e 4 | set -x 5 | 6 | cd `hg root` 7 | hg fetch # will only work on a unmodified working directory. 8 | rm -rf launchpad 9 | mkdir $_ 10 | cd $_ 11 | tar -xzf ~/Downloads/launchpad-export.tar.gz 12 | ../misc/po2localization.pl *.po mojosetup/mojosetup.pot >../scripts/localization.lua 13 | hg diff ../scripts/localization.lua |less 14 | set +x 15 | echo "enter to commit, ctrl-c to abort." 16 | read 17 | set -x 18 | hg commit -m "Latest translations from launchpad.net ..." ../scripts/localization.lua 19 | cd .. 20 | rm -rf launchpad ~/Downloads/launchpad-export.tar.gz 21 | exit 0 22 | -------------------------------------------------------------------------------- /misc/shrinksh.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | 3 | use strict; 4 | use Shell::Parser; 5 | 6 | my $sawnewline = 1; 7 | my $sawwhitespace = 1; 8 | my $funccount = 0; 9 | my $braces = 0; 10 | my $currentfn = undef; 11 | my %funcmap; 12 | my %funcstart; 13 | my %funcend; 14 | my %funcused; 15 | my @output; 16 | 17 | my $parser = new Shell::Parser handlers => { default => \&dumpnode }; 18 | $parser->parse(join '', <>); 19 | 20 | sub dumpnode { 21 | my $self = shift; 22 | my %args = @_; 23 | 24 | my $token = $args{token}; 25 | my $type = $args{type}; 26 | 27 | if (($type eq 'comment') or ($token eq '')) { 28 | return; 29 | } elsif ($token eq "\n") { 30 | return if ($sawnewline); 31 | $sawnewline = 1; 32 | $sawwhitespace = 1; 33 | push @output, "\n"; 34 | return; 35 | } elsif ($token =~ /\A\s+\Z/) { 36 | return if ($sawwhitespace); 37 | $sawwhitespace = 1; 38 | push @output, ' '; 39 | return; 40 | } else { 41 | $sawnewline = 0; 42 | $sawwhitespace = 0; 43 | 44 | # shrink function names down to "fX" 45 | if ($token eq ')') { 46 | my $prev1 = pop @output; 47 | if ((not defined $prev1) or ($prev1 ne '(')) { 48 | push @output, $prev1; 49 | } else { 50 | my $prev2 = pop @output; 51 | if (defined $prev2) { 52 | $funccount = $funccount + 1; 53 | my $mappedfn = "f${funccount}"; 54 | $currentfn = $prev2; 55 | $funcmap{$currentfn} = $mappedfn; 56 | $funcused{$currentfn} = 0; 57 | $funcstart{$currentfn} = scalar(@output); 58 | $prev2 = $mappedfn; 59 | } 60 | push @output, $prev2; 61 | push @output, $prev1; 62 | } 63 | } elsif ($token eq '{') { 64 | $braces++; 65 | } elsif ($token eq '}') { 66 | $braces--; 67 | if (($braces == 0) and (defined $currentfn)) { 68 | $funcend{$currentfn} = scalar(@output) + 1; 69 | $currentfn = undef; 70 | } 71 | } elsif (defined $funcmap{$token}) { 72 | $funcused{$token} = 1; 73 | $token = $funcmap{$token}; 74 | } 75 | 76 | push @output, $token; 77 | } 78 | } 79 | 80 | foreach my $fn (keys(%funcused)) { 81 | #print STDERR "funcused{'" . $fn . "'} == '" . $funcused{$fn} . "';\n"; 82 | #print STDERR "funcstart{'" . $fn . "'} == '" . $funcstart{$fn} . "';\n"; 83 | #print STDERR "funcend{'" . $fn . "'} == '" . $funcend{$fn} . "';\n"; 84 | #print STDERR "\n"; 85 | next if $funcused{$fn}; 86 | my $fnstart = $funcstart{$fn}; 87 | my $fnend = $funcend{$fn}; 88 | my $len = $fnend - $fnstart; 89 | for (my $i = $fnstart; $i <= $fnend; $i++) { 90 | $output[$i] = undef; 91 | } 92 | #print STDERR "Removed unused function $fn ($len tokens)\n"; 93 | } 94 | 95 | foreach (@output) { 96 | print($_) if defined $_; 97 | } 98 | 99 | -------------------------------------------------------------------------------- /platform_beos.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * MojoSetup; a portable, flexible installation application. 3 | * 4 | * Please see the file LICENSE.txt in the source's root directory. 5 | * 6 | * This file written by Ryan C. Gordon. 7 | */ 8 | 9 | // You also need to compile unix.c, but this lets us add some things that 10 | // cause conflicts between the Be headers and MojoSetup, and use C++. These 11 | // are largely POSIX things that are missing from BeOS 5...keeping them here 12 | // even on Zeta lets us be binary compatible across everything, I think. 13 | 14 | #if PLATFORM_BEOS 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | extern "C" { int beos_launchBrowser(const char *url); } 23 | int beos_launchBrowser(const char *url) 24 | { 25 | static struct { const char *prot, const char *mime } protmimemap[] = 26 | { 27 | { "http://", "text/html" }, 28 | { "https://", "text/html" }, 29 | { "file://", "text/html" }, // let the web browser handle this. 30 | { "ftp://", "application/x-vnd.Be.URL.ftp" }, 31 | { "mailto:", "text/x-email" }, 32 | { NULL, NULL } 33 | }; 34 | 35 | const char *mime = NULL; 36 | 37 | for (int i = 0; protmimemap[i].prot != NULL; i++) 38 | { 39 | const char *prot = protmimemap[i].prot; 40 | if (strncmp(url, prot, strlen(prot)) == 0) 41 | { 42 | mime = protmimemap[i].mime; 43 | break; 44 | } // if 45 | } // for 46 | 47 | if (mime == NULL) 48 | return false; // no handler for this protocol. 49 | 50 | // be_roster is a global object supplied by the system runtime. 51 | return (be_roster->Launch(mime, 1, &url) == B_OK); 52 | } // beos_launchBrowser 53 | 54 | 55 | extern "C" { void *beos_dlopen(const char *fname, int unused); } 56 | void *beos_dlopen(const char *fname, int unused) 57 | { 58 | const image_id lib = load_add_on(fname); 59 | (void) unused; 60 | if (lib < 0) 61 | return NULL; 62 | return (void *) lib; 63 | } // beos_dlopen 64 | 65 | 66 | extern "C" { void *beos_dlsym(void *lib, const char *sym); } 67 | void *beos_dlsym(void *lib, const char *sym) 68 | { 69 | void *addr = NULL; 70 | if (get_image_symbol((image_id) lib, sym, B_SYMBOL_TYPE_TEXT, &addr)) 71 | return NULL; 72 | return addr; 73 | } // beos_dlsym 74 | 75 | 76 | extern "C" { void beos_dlclose(void *lib); } 77 | void beos_dlclose(void *lib) 78 | { 79 | unload_add_on((image_id) lib); 80 | } // beos_dlclose 81 | 82 | 83 | extern "C" { void beos_usleep(unsigned long microseconds); } 84 | void beos_usleep(unsigned long microseconds) 85 | { 86 | snooze(microseconds); 87 | } // beos_usleep 88 | 89 | #endif // PLATFORM_BEOS 90 | 91 | // end of beos.c ... 92 | 93 | -------------------------------------------------------------------------------- /scripts/app_localization.lua: -------------------------------------------------------------------------------- 1 | -- MojoSetup; a portable, flexible installation application. 2 | -- 3 | -- Please see the file LICENSE.txt in the source's root directory. 4 | -- 5 | -- This file written by Ryan C. Gordon. 6 | -- 7 | -- Lines starting with "--" are comments in this file. 8 | -- 9 | -- You should add your installer's strings to this file; localization.lua is 10 | -- for strings used internally by MojoSetup itself. Your app can override any 11 | -- individual string in that file, though. 12 | -- 13 | -- NOTE: If you care about Unicode or ASCII chars above 127, this file _MUST_ 14 | -- be UTF-8 encoded! If you think you're using a certain high-ASCII codepage, 15 | -- you're wrong! 16 | -- 17 | -- Most of the MojoSetup table isn't set up when this code is run, so you 18 | -- shouldn't rely on any of it. For most purposes, you should treat this 19 | -- file more like a data description language and less like a turing-complete 20 | -- scripting language. 21 | -- 22 | -- The format of an entry looks like this: 23 | -- 24 | -- ["Hello"] = { 25 | -- es = "Hola", 26 | -- de = "Hallo", 27 | -- fr = "Bonjour", 28 | -- }; 29 | -- 30 | -- So you just fill in the translation of the English for your language code. 31 | -- Note that locales work, too: 32 | -- 33 | -- ["Color"] = { 34 | -- en_GB = "Colour", 35 | -- }; 36 | -- 37 | -- Specific locales are favored, falling back to specific languages, eventually 38 | -- ending up on the untranslated version (which is technically en_US). 39 | -- 40 | -- Whenever you see a %x sequence, that is replaced with a string at runtime. 41 | -- So if you see, ["Hello, %0, my name is %1."], then this might become 42 | -- "Hello, Alice, my name is Bob." at runtime. If your culture would find 43 | -- introducing yourself second to be rude, you might translate this to: 44 | -- "My name is %1, hello %0." If you need a literal '%' char, write "%%": 45 | -- "Operation is %0%% complete" might give "Operation is 3% complete." 46 | -- All strings, from your locale or otherwise, are checked for formatter 47 | -- correctness at startup. This is to prevent the installer working fine 48 | -- in all reasonable tests, then finding out that one guy in Ghana has a 49 | -- crashing installer because his localization forgot to add a %1 somewhere. 50 | -- 51 | -- Occasionally you might see a "\n" ... that's a newline character. "\t" is 52 | -- a tab character, and "\\" turns into a single "\" character. 53 | -- 54 | -- The table you create here goes away shortly after creation, as the relevant 55 | -- parts of it get moved somewhere else. You should call MojoSetup.translate() 56 | -- to get the proper translation for a given string. 57 | -- 58 | -- Questions about the intent of a specific string can go to Ryan C. Gordon 59 | -- (icculus@icculus.org). 60 | 61 | MojoSetup.applocalization = { 62 | }; 63 | 64 | -- end of app_localization.lua ... 65 | 66 | 67 | 68 | --------------------------------------------------------------------------------