├── .gitignore ├── README.md ├── orbislink ├── libps4link │ ├── include │ │ ├── jailbreak.h │ │ ├── kmain.h │ │ ├── ps4link.h │ │ └── ps4link_internal.h │ ├── Makefile │ └── source │ │ ├── kmain.c │ │ ├── jailbreak.c │ │ └── ps4link.c ├── libdebugnet │ ├── Makefile │ ├── include │ │ └── debugnet.h │ └── source │ │ └── debugnet.c └── libelfloader │ ├── Makefile │ └── include │ └── elfloader.h ├── liborbisAudio ├── README.md ├── include │ ├── logdebug.h │ └── orbisAudio.h └── Makefile ├── eboot_plugin ├── script.ld ├── Makefile └── source │ └── eboot_plugin.c ├── portlibs ├── zlib │ ├── include │ │ ├── inffast.h │ │ ├── inftrees.h │ │ ├── inffixed.h │ │ ├── inflate.h │ │ ├── zutil.h │ │ └── trees.h │ ├── Makefile │ └── source │ │ ├── uncompr.c │ │ ├── compress.c │ │ ├── adler32.c │ │ ├── zutil.c │ │ └── minigzip.c └── libpng │ ├── Makefile │ ├── source │ ├── pngrio.c │ └── pngwio.c │ └── include │ ├── pngdebug.h │ └── pnglibconf.h ├── liborbis2d ├── include │ ├── logdebug.h │ └── orbis2d.h ├── Makefile └── source │ ├── orbis2dTexture.c │ ├── orbis2dImagePng.c │ └── orbis2d.c ├── liborbisPad ├── include │ ├── logdebug.h │ └── orbisPad.h ├── Makefile └── source │ └── orbisPad.c ├── liborbisFileBrowser ├── include │ ├── logdebug.h │ └── orbisFileBrowser.h ├── Makefile └── source │ └── orbisFileBrowser.c ├── liborbisKeyboard ├── include │ ├── logdebug.h │ ├── orbisKeyboard.h │ └── kb.h └── Makefile ├── libmod ├── Makefile └── include │ ├── modplayer.h │ └── modplayeri.h └── liborbisXbmFont ├── Makefile ├── include └── orbisXbmFont.h └── source └── orbisXbmFont.c /.gitignore: -------------------------------------------------------------------------------- 1 | *.exe 2 | *.elf 3 | *.self 4 | *.pkg 5 | *.o 6 | *.a 7 | *.d 8 | .DS_Store 9 | ._* 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # liborbis 2 | Libraries and samples for PlayStation 4 3 | 4 | 5 | DEPRECATED go to https://github.com/orbisdev 6 | 7 | -------------------------------------------------------------------------------- /orbislink/libps4link/include/jailbreak.h: -------------------------------------------------------------------------------- 1 | #ifndef JAILBREAKH 2 | #define JAILBREAKH 3 | int jailbreak(struct thread *td, void *uap); 4 | #endif 5 | -------------------------------------------------------------------------------- /liborbisAudio/README.md: -------------------------------------------------------------------------------- 1 | # liborbisAudio 2 | Credits must go to frangarcj from psplib4vita and Akop Karapetyan from psplib. You can use it in the same way. 3 | -------------------------------------------------------------------------------- /eboot_plugin/script.ld: -------------------------------------------------------------------------------- 1 | SECTIONS 2 | { 3 | . = 0x10000; 4 | .text : { *(.text) } 5 | . = 0x8000000; 6 | .data : { *(.data) } 7 | .bss : { *(.bss) } 8 | } 9 | -------------------------------------------------------------------------------- /orbislink/libps4link/include/kmain.h: -------------------------------------------------------------------------------- 1 | #ifndef KMainH 2 | #define KMainH 3 | 4 | #include 5 | 6 | int path_self_mmap_check_function(struct thread *td, void *uap); 7 | int unpath_self_mmap_check_function(struct thread *td, void *uap); 8 | 9 | #endif 10 | -------------------------------------------------------------------------------- /portlibs/zlib/include/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /liborbis2d/include/logdebug.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | uint64_t syscall2(uint64_t i_rdi, ...); 5 | #define sys_log(args...) {\ 6 | char logbuf[400];\ 7 | snprintf(logbuf, 400, args);\ 8 | syscall2(308, 2, logbuf); \ 9 | } 10 | __asm__("syscall2: \n\ 11 | push %r10\n\ 12 | push %r11\n\ 13 | mov $0x93a4FFFF8, %r11\n\ 14 | mov (%r11), %r11\n\ 15 | mov %rcx, %r10\n\ 16 | mov $0, %rax;\n\ 17 | call *%r11\n\ 18 | pop %r11\n\ 19 | pop %r10\n\ 20 | ret"); 21 | 22 | 23 | -------------------------------------------------------------------------------- /liborbisAudio/include/logdebug.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | uint64_t syscall2(uint64_t i_rdi, ...); 5 | #define sys_log(args...) {\ 6 | char logbuf[400];\ 7 | snprintf(logbuf, 400, args);\ 8 | syscall2(308, 2, logbuf); \ 9 | } 10 | __asm__("syscall2: \n\ 11 | push %r10\n\ 12 | push %r11\n\ 13 | mov $0x93a4FFFF8, %r11\n\ 14 | mov (%r11), %r11\n\ 15 | mov %rcx, %r10\n\ 16 | mov $0, %rax;\n\ 17 | call *%r11\n\ 18 | pop %r11\n\ 19 | pop %r10\n\ 20 | ret"); 21 | 22 | 23 | -------------------------------------------------------------------------------- /liborbisPad/include/logdebug.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | uint64_t syscall2(uint64_t i_rdi, ...); 5 | #define sys_log(args...) {\ 6 | char logbuf[400];\ 7 | snprintf(logbuf, 400, args);\ 8 | syscall2(308, 2, logbuf); \ 9 | } 10 | __asm__("syscall2: \n\ 11 | push %r10\n\ 12 | push %r11\n\ 13 | mov $0x93a4FFFF8, %r11\n\ 14 | mov (%r11), %r11\n\ 15 | mov %rcx, %r10\n\ 16 | mov $0, %rax;\n\ 17 | call *%r11\n\ 18 | pop %r11\n\ 19 | pop %r10\n\ 20 | ret"); 21 | 22 | 23 | -------------------------------------------------------------------------------- /liborbisFileBrowser/include/logdebug.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | uint64_t syscall2(uint64_t i_rdi, ...); 5 | #define sys_log(args...) {\ 6 | char logbuf[400];\ 7 | snprintf(logbuf, 400, args);\ 8 | syscall2(308, 2, logbuf); \ 9 | } 10 | __asm__("syscall2: \n\ 11 | push %r10\n\ 12 | push %r11\n\ 13 | mov $0x93a4FFFF8, %r11\n\ 14 | mov (%r11), %r11\n\ 15 | mov %rcx, %r10\n\ 16 | mov $0, %rax;\n\ 17 | call *%r11\n\ 18 | pop %r11\n\ 19 | pop %r10\n\ 20 | ret"); 21 | 22 | 23 | -------------------------------------------------------------------------------- /liborbisKeyboard/include/logdebug.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | 4 | uint64_t syscall2(uint64_t i_rdi, ...); 5 | #define sys_log(args...) {\ 6 | char logbuf[400];\ 7 | snprintf(logbuf, 400, args);\ 8 | syscall2(308, 2, logbuf); \ 9 | } 10 | __asm__("syscall2: \n\ 11 | push %r10\n\ 12 | push %r11\n\ 13 | mov $0x93a4FFFF8, %r11\n\ 14 | mov (%r11), %r11\n\ 15 | mov %rcx, %r10\n\ 16 | mov $0, %rax;\n\ 17 | call *%r11\n\ 18 | pop %r11\n\ 19 | pop %r10\n\ 20 | ret"); 21 | 22 | 23 | -------------------------------------------------------------------------------- /libmod/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := libmod 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/modplayer.h $(Ps4Sdk)/include 28 | @echo "Installed!" 29 | -------------------------------------------------------------------------------- /orbislink/libdebugnet/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := libdebugnet 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/debugnet.h $(Ps4Sdk)/include 28 | @echo "Installed!" 29 | -------------------------------------------------------------------------------- /eboot_plugin/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | keepelf = True 14 | target ?= ps4_elf 15 | 16 | #need to add this flags 17 | #-Wl,-T script.ld 18 | 19 | ################################### 20 | 21 | Libraries := -ldebugnet -lps4link -lelfloader -lorbis2d -lorbisPad -lorbisAudio -lmod -lSceNet_stub -lSceAudioOut_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub 22 | 23 | include $(Ps4Sdk)/make/ps4sdk.mk 24 | 25 | -------------------------------------------------------------------------------- /portlibs/zlib/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := libz 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/zlib.h $(Ps4Sdk)/include 28 | @cp include/zconf.h $(Ps4Sdk)/include 29 | @echo "Installed!" 30 | -------------------------------------------------------------------------------- /liborbis2d/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := liborbis2d 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/orbis2d.h $(Ps4Sdk)/include 28 | @cp include/logdebug.h $(Ps4Sdk)/include 29 | @echo "Installed!" 30 | -------------------------------------------------------------------------------- /orbislink/libelfloader/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := libelfloader 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 21 | $(dirp) 22 | $(archive) 23 | all:: $(OutPath)/$(TargetFile).a 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/elfloader.h $(Ps4Sdk)/include 28 | @echo "Installed!" 29 | -------------------------------------------------------------------------------- /liborbisPad/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := liborbisPad 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/orbisPad.h $(Ps4Sdk)/include 28 | @cp include/logdebug.h $(Ps4Sdk)/include 29 | @echo "Installed!" 30 | -------------------------------------------------------------------------------- /liborbisAudio/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := liborbisAudio 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/orbisAudio.h $(Ps4Sdk)/include 28 | @cp include/logdebug.h $(Ps4Sdk)/include 29 | @echo "Installed!" 30 | -------------------------------------------------------------------------------- /orbislink/libps4link/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := libps4link 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/ps4link.h $(Ps4Sdk)/include 28 | @cp include/jailbreak.h $(Ps4Sdk)/include 29 | @echo "Installed!" 30 | -------------------------------------------------------------------------------- /liborbisXbmFont/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := liborbisXbmFont 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/orbisXbmFont.h $(Ps4Sdk)/include 28 | @cp include/xbm_font.h $(Ps4Sdk)/include 29 | @echo "Installed!" 30 | -------------------------------------------------------------------------------- /liborbisFileBrowser/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := liborbisFileBrowser 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/orbisFileBrowser.h $(Ps4Sdk)/include 28 | @cp include/logdebug.h $(Ps4Sdk)/include 29 | @echo "Installed!" 30 | -------------------------------------------------------------------------------- /liborbisKeyboard/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := liborbisKeyboard 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/orbisKeyboard.h $(Ps4Sdk)/include 28 | @cp include/kb.h $(Ps4Sdk)/include 29 | @cp include/logdebug.h $(Ps4Sdk)/include 30 | @echo "Installed!" 31 | -------------------------------------------------------------------------------- /portlibs/libpng/Makefile: -------------------------------------------------------------------------------- 1 | ifndef Ps4Sdk 2 | ifdef ps4sdk 3 | Ps4Sdk := $(ps4sdk) 4 | endif 5 | ifdef PS4SDK 6 | Ps4Sdk := $(PS4SDK) 7 | endif 8 | ifndef Ps4Sdk 9 | $(error Neither PS4SDK, Ps4Sdk nor ps4sdk set) 10 | endif 11 | endif 12 | 13 | target := ps4_lib 14 | OutPath := lib 15 | TargetFile := libpng 16 | AllTarget = $(OutPath)/$(TargetFile).a 17 | 18 | include $(Ps4Sdk)/make/ps4sdk.mk 19 | 20 | 21 | $(OutPath)/$(TargetFile).a: $(ObjectFiles) 22 | $(dirp) 23 | $(archive) 24 | 25 | install: 26 | @cp $(OutPath)/$(TargetFile).a $(Ps4Sdk)/lib 27 | @cp include/png.h $(Ps4Sdk)/include 28 | @cp include/pngconf.h $(Ps4Sdk)/include 29 | @cp include/pnglibconf.h $(Ps4Sdk)/include 30 | @cp include/pngstruct.h $(Ps4Sdk)/include 31 | @cp include/pnginfo.h $(Ps4Sdk)/include 32 | @echo "Installed!" 33 | -------------------------------------------------------------------------------- /orbislink/libdebugnet/include/debugnet.h: -------------------------------------------------------------------------------- 1 | /* 2 | * debugnet library for PlayStation 4 3 | * Copyright (C) 2010,2016 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/ps4link 5 | */ 6 | #ifndef _DEBUGNET_H_ 7 | #define _DEBUGNET_H_ 8 | 9 | 10 | #define NONE 0 11 | #define INFO 1 12 | #define ERROR 2 13 | #define DEBUG 3 14 | 15 | typedef struct debugNetConfiguration 16 | { 17 | int debugnet_initialized; 18 | int SocketFD; 19 | int logLevel; 20 | 21 | } debugNetConfiguration; 22 | 23 | int debugNetInit(char *serverIp, int port, int level); 24 | int debugNetInitWithConf(debugNetConfiguration *conf); 25 | debugNetConfiguration *debugNetGetConf(); 26 | int debugNetSetConf(debugNetConfiguration *conf); 27 | void debugNetFinish(); 28 | void debugNetPrintf(int level, char* format, ...); 29 | void debugNetSetLogLevel(int level); 30 | int debugNetCreateConf(); 31 | 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /liborbis2d/source/orbis2dTexture.c: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/liborbis 5 | */ 6 | #include 7 | #include 8 | #include "orbis2d.h" 9 | 10 | 11 | Orbis2dTexture * orbis2dCreateEmptyTexture(unsigned int w, unsigned int h) 12 | { 13 | 14 | Orbis2dTexture *img=NULL; 15 | img=malloc(sizeof(Orbis2dTexture)); 16 | if(img!=NULL) 17 | { 18 | img->datap=malloc(w*h*4); 19 | if(img->datap==NULL) 20 | { 21 | free(img); 22 | return NULL; 23 | } 24 | img->width=w; 25 | img->height=h; 26 | img->depth=32; 27 | } 28 | return img; 29 | } 30 | void orbis2dDestroyTexture(Orbis2dTexture *texture) 31 | { 32 | 33 | if(texture!=NULL) 34 | { 35 | if(texture->datap!=NULL) 36 | { 37 | free(texture->datap); 38 | } 39 | } 40 | free(texture); 41 | } 42 | uint32_t *orbis2dTextureGetDataPointer(Orbis2dTexture *texture) 43 | { 44 | return texture->datap; 45 | } 46 | uint32_t orbis2dTextureGetStride(Orbis2dTexture *texture) 47 | { 48 | return texture->width; 49 | } 50 | void orbis2dDrawTexture(Orbis2dTexture *texture,unsigned int x, unsigned int y) 51 | { 52 | uint32_t *buf=NULL; 53 | if(texture!=NULL) 54 | { 55 | buf=orbis2dTextureGetDataPointer(texture); 56 | if(buf!=NULL) 57 | { 58 | orbis2dPutImage2(buf,0,0,texture->width,texture->height); 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /orbislink/libps4link/source/kmain.c: -------------------------------------------------------------------------------- 1 | #undef _SYS_CDEFS_H_ 2 | #undef _SYS_TYPES_H_ 3 | #undef _SYS_PARAM_H_ 4 | #undef _SYS_MALLOC_H_ 5 | 6 | #define _XOPEN_SOURCE 700 7 | #define __BSD_VISIBLE 1 8 | #define _KERNEL 9 | #define _WANT_UCRED 10 | 11 | #include 12 | #include 13 | // #include 14 | // #include 15 | // #include 16 | // #include 17 | // #include 18 | // #include 19 | // #include 20 | // #include 21 | // #include 22 | // #include 23 | 24 | #include 25 | 26 | #include "kmain.h" 27 | 28 | int myhook1(struct thread *td, Ps4KernelFunctionHookArgument *arg) 29 | { 30 | arg->returns->rax = 1; 31 | return PS4_KERNEL_FUNCTION_HOOK_CONTROL_CONTINUE; 32 | } 33 | 34 | int myhook2(struct thread *td, Ps4KernelFunctionHookArgument *arg) 35 | { 36 | arg->returns->rax = 0; 37 | return PS4_KERNEL_FUNCTION_HOOK_CONTROL_CONTINUE; 38 | } 39 | 40 | int path_self_mmap_check_function(struct thread *td, void *uap) 41 | { 42 | void *func1 = ps4KernelDlSym("sceSblACMgrIsAllowedToMmapSelf"); 43 | void *func2 = ps4KernelDlSym("sceSblAuthMgrIsLoadable"); 44 | ps4KernelFunctionPosthook(func1, myhook1); 45 | ps4KernelFunctionPosthook(func2, myhook2); 46 | return 0; 47 | } 48 | 49 | int unpath_self_mmap_check_function(struct thread *td, void *uap) 50 | { 51 | void *func1 = ps4KernelDlSym("sceSblACMgrIsAllowedToMmapSelf"); 52 | void *func2 = ps4KernelDlSym("sceSblAuthMgrIsLoadable"); 53 | ps4KernelFunctionUnhook(func1); 54 | ps4KernelFunctionUnhook(func2); 55 | return 0; 56 | } 57 | 58 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /libmod/include/modplayer.h: -------------------------------------------------------------------------------- 1 | // modplayer.h: headers for psp modplayer code 2 | // 3 | // All public functions for modplayer 4 | // 5 | ////////////////////////////////////////////////////////////////////// 6 | #ifndef _MODPLAYER_GENERAL_H 7 | #define _MODPLAYER_GENERAL_H 8 | 9 | static int modplayint_channel; 10 | typedef void (*fd_initFunc) (int); 11 | typedef int (*fd_loadFunc) (char *); 12 | typedef int (*fd_playFunc) (void); 13 | typedef void (*fd_pauseFunc) (void); 14 | typedef int (*fd_stopFunc) (void); 15 | typedef void (*fd_endFunc) (void); 16 | typedef void (*fd_tickFunc) (void); 17 | typedef void (*fd_timeFunc) (char *); 18 | typedef int (*fd_EOSFunc) (void); 19 | /* Define printf, just to make typing easier */ 20 | //#define printf pspDebugScreenPrintf 21 | typedef struct { 22 | fd_initFunc init; 23 | fd_loadFunc load; 24 | fd_playFunc play; 25 | fd_pauseFunc pause; 26 | fd_stopFunc stop; 27 | fd_endFunc end; 28 | fd_tickFunc tick; 29 | fd_timeFunc time; 30 | fd_EOSFunc eos; // have we reached end of playback.. ie for non-loop mode 31 | char extension[200]; // 4 byte entries. eg mp3\0 or \0\0\0\0 to terminate list 32 | } codecStubs; 33 | 34 | 35 | #ifdef __cplusplus 36 | extern "C" { 37 | #endif 38 | 39 | // Function prototypes for public functions 40 | void MODsetStubs(codecStubs * stubs); 41 | 42 | // Function prototypes for private functions 43 | void Mod_Init(int channel); 44 | int Mod_Play(); 45 | void Mod_Pause(); 46 | int Mod_Stop(); 47 | void Mod_End(); 48 | int Mod_Load(char *filename); 49 | void Mod_Tick(); 50 | void Mod_Close(); 51 | int Mod_EndOfStream(); 52 | 53 | void Mod_GetTimeString(char *); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | #endif 59 | -------------------------------------------------------------------------------- /orbislink/libps4link/include/ps4link.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | 8 | typedef struct ps4LinkConfiguration 9 | { 10 | int ps4link_fileio_active; 11 | int ps4link_cmdsio_active; 12 | 13 | int ps4link_requests_port; 14 | int ps4link_commands_port; 15 | int ps4link_debug_port; 16 | 17 | int ps4link_fileio_sock; 18 | 19 | int ps4link_initialized; 20 | 21 | int ps4link_commands_sock; 22 | int ps4link_requests_sock; 23 | 24 | debugNetConfiguration *debugconf; 25 | 26 | 27 | 28 | } ps4LinkConfiguration; 29 | typedef enum ps4LinkValue 30 | { 31 | FILEIO_ACTIVE=1, 32 | CMDSIO_ACTIVE=2, 33 | DEBUGNET_ACTIVE=3, 34 | PS4LINK_ACTIVE=4, 35 | REQUESTS_PORT=5, 36 | COMMANDS_PORT=6, 37 | DEBUG_PORT=7, 38 | FILEIO_SOCK=8, 39 | REQUESTS_SOCK=9, 40 | COMMANDS_SOCK=10, 41 | DEBUG_SOCK=11, 42 | LOG_LEVEL=12, 43 | } ps4LinkValue; 44 | 45 | 46 | int ps4LinkOpen(const char *file, int flags, int mode); 47 | int ps4LinkClose(int fd); 48 | int ps4LinkRead(int fd, void *data, size_t size); 49 | int ps4LinkWrite(int fd, const void *data, size_t size); 50 | int ps4LinkLseek(int fd, int offset, int whence); 51 | int ps4LinkRemove(const char *file); 52 | int ps4LinkMkdir(const char *dirname, int mode); 53 | int ps4LinkRmdir(const char *dirname); 54 | int ps4LinkDopen(const char *dirname); 55 | int ps4LinkDread(int fd, struct dirent *dir); 56 | int ps4LinkDclose(int fd); 57 | //int ps4LinkConnect(); 58 | 59 | 60 | 61 | 62 | void ps4LinkRequestsAbort(); 63 | int ps4LinkRequestsIsConnected(); 64 | int ps4LinkGetValue(ps4LinkValue val); 65 | ps4LinkConfiguration *ps4LinkGetConfig(); 66 | int ps4LinkInitWithConf(ps4LinkConfiguration *conf); 67 | int ps4LinkCreateConf(); 68 | int ps4LinkInit(char *serverIp, int requestPort,int debugPort, int commandPort, int level); 69 | void ps4LinkFinish(); 70 | -------------------------------------------------------------------------------- /liborbisPad/include/orbisPad.h: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/liborbis 5 | */ 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | 15 | #define ORBISPAD_L3 0x00000002 16 | #define ORBISPAD_R3 0x00000004 17 | #define ORBISPAD_OPTIONS 0x00000008 18 | #define ORBISPAD_UP 0x00000010 19 | #define ORBISPAD_RIGHT 0x00000020 20 | #define ORBISPAD_DOWN 0x00000040 21 | #define ORBISPAD_LEFT 0x00000080 22 | #define ORBISPAD_L2 0x00000100 23 | #define ORBISPAD_R2 0x00000200 24 | #define ORBISPAD_L1 0x00000400 25 | #define ORBISPAD_R1 0x00000800 26 | #define ORBISPAD_TRIANGLE 0x00001000 27 | #define ORBISPAD_CIRCLE 0x00002000 28 | #define ORBISPAD_CROSS 0x00004000 29 | #define ORBISPAD_SQUARE 0x00008000 30 | #define ORBISPAD_TOUCH_PAD 0x00100000 31 | #define ORBISPAD_INTERCEPTED 0x80000000 32 | 33 | 34 | typedef struct OrbisPadConfig 35 | { 36 | SceUserServiceUserId userId; 37 | ScePadData *padDataCurrent; 38 | ScePadData *padDataLast; 39 | unsigned int buttonsPressed; 40 | unsigned int buttonsReleased; 41 | unsigned int buttonsHold; 42 | int padHandle; 43 | int orbispad_initialized; 44 | 45 | }OrbisPadConfig; 46 | 47 | int orbisPadInit(); 48 | void orbisPadFinish(); 49 | OrbisPadConfig *orbisPadGetConf(); 50 | int orbisPadCreateConf(); 51 | int orbisPadSetConf(OrbisPadConfig *conf); 52 | int orbisPadInitWithConf(OrbisPadConfig *conf); 53 | bool orbisPadGetButtonHold(unsigned int filter); 54 | bool orbisPadGetButtonPressed(unsigned int filter); 55 | bool orbisPadGetButtonReleased(unsigned int filter); 56 | unsigned int orbisPadGetCurrentButtonsPressed(); 57 | unsigned int orbisPadGetCurrentButtonsReleased(); 58 | void orbisPadSetCurrentButtonsPressed(unsigned int buttons); 59 | void orbisPadSetCurrentButtonsReleased(unsigned int buttons); 60 | int orbisPadUpdate(); 61 | -------------------------------------------------------------------------------- /portlibs/zlib/source/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (Bytef * dest, uLongf * destLen, const Bytef * source, uLong sourceLen) 25 | { 26 | z_stream stream; 27 | int err; 28 | 29 | stream.next_in = (Bytef*)source; 30 | stream.avail_in = (uInt)sourceLen; 31 | /* Check for source > 64K on 16-bit machine: */ 32 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 33 | 34 | stream.next_out = dest; 35 | stream.avail_out = (uInt)*destLen; 36 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 37 | 38 | stream.zalloc = (alloc_func)0; 39 | stream.zfree = (free_func)0; 40 | 41 | err = inflateInit(&stream); 42 | if (err != Z_OK) return err; 43 | 44 | err = inflate(&stream, Z_FINISH); 45 | if (err != Z_STREAM_END) { 46 | inflateEnd(&stream); 47 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 48 | return Z_DATA_ERROR; 49 | return err; 50 | } 51 | *destLen = stream.total_out; 52 | 53 | err = inflateEnd(&stream); 54 | return err; 55 | } 56 | -------------------------------------------------------------------------------- /liborbisXbmFont/include/orbisXbmFont.h: -------------------------------------------------------------------------------- 1 | /* 2 | Example: 3 | update_gradient(&c1, &c2); 4 | sprintf(tmp_ln, "0x%p, %d bytes:", data, data->len); 5 | x = get_aligned_x(tmp_ln, CENTER); 6 | print_text(x, y, tmp_ln); 7 | */ 8 | 9 | 10 | /* generate with genXBMfonts, https://github.com/masterzorag/xbm_tools */ 11 | #include "xbm_font.h" 12 | 13 | 14 | // for text alignment, sorting matters! 15 | #define LEFT 0 // useless 16 | #define RIGHT 1 17 | #define CENTER 2 18 | 19 | #define SHADOW_PX 2 20 | #define SIMPLE_GRADIENT_STEPS ((uint8_t)(FONT_H /2)) // steps we split delta 21 | 22 | 23 | // compose ARGB color by components 24 | #define ARGB(a, r, g, b) ( \ 25 | (((a) &0xFF) <<24) | (((r) &0xFF) <<16) | \ 26 | (((g) &0xFF) << 8) | (((b) &0xFF) << 0)) 27 | 28 | // extract single component form ARGB color 29 | #define GET_A(color) ((color >>24) &0xFF) 30 | #define GET_R(color) ((color >>16) &0xFF) 31 | #define GET_G(color) ((color >> 8) &0xFF) 32 | #define GET_B(color) ((color >> 0) &0xFF) 33 | 34 | 35 | /*********************************************************************** 36 | * update_gradient 37 | * 38 | * precompute palette to use in print_text() and setup colors range 39 | * 40 | * uint32_t *a = pointer to start color 41 | * uint32_t *b = pointer to end color 42 | ***********************************************************************/ 43 | void update_gradient(const uint32_t *a, const uint32_t *b); 44 | 45 | 46 | /*********************************************************************** 47 | * compute x to align text into canvas 48 | * 49 | * const char *str = referring string 50 | * uint8_t align. = RIGHT / CENTER 51 | ***********************************************************************/ 52 | uint16_t get_aligned_x(const char *str, const uint8_t alignment); 53 | 54 | 55 | /*********************************************************************** 56 | * print text, with bitmap data from xbm_font.h 57 | * 58 | * int32_t x = start x coordinate into canvas 59 | * int32_t y = start y coordinate into canvas 60 | * const char *str = string to print 61 | ***********************************************************************/ 62 | int32_t print_text(int32_t x, int32_t y, const char *str); 63 | -------------------------------------------------------------------------------- /liborbisFileBrowser/include/orbisFileBrowser.h: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/liborbis 5 | */ 6 | #ifndef _ORBISFILEBROWSER_H_ 7 | #define _ORBISFILEBROWSER_H_ 8 | 9 | #define ROOT_PATH "root" 10 | #define DIR_UP ".." 11 | #define DIR_ACT "." 12 | 13 | #define MAX_PATH_LENGTH 1024 14 | #define MAX_NAME_LENGTH 256 15 | #define MAX_SHORT_NAME_LENGTH 64 16 | #define MAX_MOUNT_POINT_LENGTH 2 17 | 18 | // Max entries 19 | #define MAX_POSITION 16 20 | #define MAX_ENTRIES 17 21 | #define MAX_DIR_LEVELS 1024 22 | 23 | enum FileTypes { 24 | FILE_TYPE_UNKNOWN, 25 | FILE_TYPE_FOLDER, 26 | FILE_TYPE_ROM, 27 | FILE_TYPE_SYSTEM_ROM, 28 | FILE_TYPE_GAME_ROM, 29 | FILE_TYPE_DSK, 30 | FILE_TYPE_GAME_DSK, 31 | FILE_TYPE_CAS, 32 | FILE_TYPE_CONFIG, 33 | }; 34 | 35 | 36 | enum SortFlags { 37 | SORT_NONE, 38 | SORT_BY_NAME_AND_FOLDER, 39 | }; 40 | 41 | 42 | #define NUM_DEVICES (sizeof(devices) / sizeof(char **)) 43 | 44 | 45 | typedef struct OrbisFileBrowserListEntry { 46 | struct OrbisFileBrowserListEntry *next; 47 | struct OrbisFileBrowserListEntry *previous; 48 | char name[MAX_NAME_LENGTH]; 49 | int type; 50 | } OrbisFileBrowserListEntry; 51 | 52 | typedef struct OrbisFileBrowserList { 53 | OrbisFileBrowserListEntry *head; 54 | OrbisFileBrowserListEntry *tail; 55 | int length; 56 | char path[MAX_PATH_LENGTH]; 57 | } OrbisFileBrowserList; 58 | 59 | typedef struct ExtensionType { 60 | char *extension; 61 | int type; 62 | } ExtensionType; 63 | 64 | int orbisFileBrowserGetDirLevel(); 65 | int orbisFileBrowserGetBasePos(); 66 | int orbisFileBrowserGetRelPos(); 67 | int orbisFileBrowserGetListLength(); 68 | void orbisFileBrowserSetListPath(char *path); 69 | void orbisFileBrowserEntryDown(); 70 | void orbisFileBrowserEntryUp(); 71 | int orbisFileBrowserGetFileType(char *file); 72 | void orbisFileBrowserDirLevelUp(); 73 | void orbisFileBrowserDirUp(); 74 | void orbisFileBrowserListClean(); 75 | int orbisFileBrowserListRefresh(); 76 | OrbisFileBrowserListEntry *orbisFileBrowserListGetNthEntry(int n); 77 | void orbisFileBrowserListAddEntry(OrbisFileBrowserListEntry *entry,int sort); 78 | int orbisFileBrowserGetDirectoryEntries(char *path); 79 | int orbisFileBrowserGetDevices(); 80 | int orbisFileBrowserListGetEntries(char *path); 81 | int orbisFileBrowserInit(char *path); 82 | void orbisFileBrowserFinish(); 83 | 84 | 85 | 86 | 87 | 88 | #endif 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /liborbisAudio/include/orbisAudio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/liborbis 5 | */ 6 | #include 7 | 8 | #include 9 | 10 | 11 | 12 | 13 | 14 | #define ORBISAUDIO_ALIGN_SAMPLE(x,y) ((((x)+((y)-1))/(y))*(y)) 15 | #define ORBISAUDIO_MIN_LEN 256 16 | #define ORBISAUDIO_MAX_LEN 2048 17 | #define ORBISAUDIO_CHANNELS 5 18 | #define ORBISAUDIO_CHANNEL_MAIN 0 19 | #define ORBISAUDIO_CHANNEL_BGM 1 20 | #define ORBISAUDIO_CHANNEL_VOICE 2 21 | #define ORBISAUDIO_CHANNEL_PERSONAL 3 22 | #define ORBISAUDIO_CHANNEL_AUX 4 23 | #define ORBISAUDIO_NUM_BUFFERS 2 24 | #define ORBISAUDIO_VOLUME_MAX 32768 25 | #define ORBISAUDIO_VOLUME_FLAG_LEFT_CHANNEL 0 26 | #define ORBISAUDIO_VOLUME_FLAG_RIGHT_CHANNEL 1 27 | #define ORBISAUDIO_FORMAT_S16_MONO 0 28 | #define ORBISAUDIO_FORMAT_S16_STEREO 1 29 | 30 | typedef struct OrbisAudioStereoSample 31 | { 32 | short l; 33 | short r; 34 | } OrbisAudioStereoSample; 35 | 36 | typedef struct OrbisAudioMonoSample 37 | { 38 | short ch; 39 | } OrbisAudioMonoSample; 40 | 41 | typedef union OrbisAudioSample 42 | { 43 | OrbisAudioStereoSample stereo; 44 | OrbisAudioMonoSample mono; 45 | } OrbisAudioSample; 46 | 47 | typedef void (*OrbisAudioCallback)(OrbisAudioSample *buffer,unsigned int samples,void *user_data); 48 | 49 | typedef struct OrbisAudioChannel 50 | { 51 | ScePthread threadHandle; 52 | int audioHandle; 53 | unsigned int leftVol; 54 | unsigned int rightVol; 55 | OrbisAudioCallback callback; 56 | void *userData; 57 | short *sampleBuffer[2]; 58 | unsigned int samples[2]; 59 | unsigned char paused; 60 | unsigned char stereo; 61 | unsigned int currentBuffer; 62 | int orbisaudiochannel_initialized; 63 | }OrbisAudioChannel; 64 | 65 | typedef struct OrbisAudioConfig 66 | { 67 | OrbisAudioChannel *channels[ORBISAUDIO_CHANNELS]; 68 | unsigned char orbisaudio_stop; 69 | int orbisaudio_initialized; 70 | } OrbisAudioConfig; 71 | 72 | 73 | int orbisAudioInit(); 74 | void orbisAudioFinish(); 75 | int orbisAudioInitChannel(unsigned int channel, unsigned int samples, unsigned int frequency, int format); 76 | int orbisAudioPause(unsigned int channel); 77 | int orbisAudioResume(unsigned int channel); 78 | int orbisAudioStop(); 79 | int orbisAudioSetCallback(unsigned int channel,OrbisAudioCallback callback,void *userdata); 80 | int orbisAudioInitWithConf(OrbisAudioConfig *conf); 81 | OrbisAudioConfig *orbisAudioGetConf(); 82 | -------------------------------------------------------------------------------- /portlibs/zlib/source/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2005 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen, int level) 23 | { 24 | z_stream stream; 25 | int err; 26 | 27 | stream.next_in = (Bytef*)source; 28 | stream.avail_in = (uInt)sourceLen; 29 | #ifdef MAXSEG_64K 30 | /* Check for source > 64K on 16-bit machine: */ 31 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 32 | #endif 33 | stream.next_out = dest; 34 | stream.avail_out = (uInt)*destLen; 35 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 36 | 37 | stream.zalloc = (alloc_func)0; 38 | stream.zfree = (free_func)0; 39 | stream.opaque = (voidpf)0; 40 | 41 | err = deflateInit(&stream, level); 42 | if (err != Z_OK) return err; 43 | 44 | err = deflate(&stream, Z_FINISH); 45 | if (err != Z_STREAM_END) { 46 | deflateEnd(&stream); 47 | return err == Z_OK ? Z_BUF_ERROR : err; 48 | } 49 | *destLen = stream.total_out; 50 | 51 | err = deflateEnd(&stream); 52 | return err; 53 | } 54 | 55 | /* =========================================================================== 56 | */ 57 | int ZEXPORT compress (Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen) 58 | { 59 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 60 | } 61 | 62 | /* =========================================================================== 63 | If the default memLevel or windowBits for deflateInit() is changed, then 64 | this function needs to be updated. 65 | */ 66 | uLong ZEXPORT compressBound (uLong sourceLen) 67 | { 68 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 69 | (sourceLen >> 25) + 13; 70 | } 71 | -------------------------------------------------------------------------------- /liborbis2d/include/orbis2d.h: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/liborbis 5 | */ 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | 12 | #define ORBIS2D_DISPLAY_BUFFER_NUM 2 13 | #define ORBIS2D_FLIP_RATE 0 14 | #define ORBIS2D_FLIP_MODE_VSYNC 1 15 | #define ORBIS2D_FLIP_MODE_HSYNC 2 16 | #define ORBIS2D_FLIP_MODE_WINDOW 3 17 | #define ORBIS2D_MODE_TILE 0 18 | #define ORBIS2D_MODE_LINEAR 1 19 | 20 | 21 | #define ATTR_WIDTH 1280 22 | #define ATTR_HEIGHT 720 23 | 24 | 25 | 26 | 27 | typedef struct Orbis2dConfig 28 | { 29 | uint32_t bgColor; 30 | uint64_t videoMemStackAddr; 31 | uint32_t videoMemStackSize; 32 | uint64_t videoMemStackTopAddr; 33 | uint64_t videoMemStackBaseAddr; 34 | off_t videoMemOffset; 35 | int width; 36 | int pitch; 37 | int height; 38 | int pixelFormat; 39 | int bytesPerPixel; 40 | int tilingMode; 41 | void *surfaceAddr[ORBIS2D_DISPLAY_BUFFER_NUM]; 42 | int64_t flipArgLog[ORBIS2D_DISPLAY_BUFFER_NUM]; 43 | int flipMode; 44 | int flipRate; 45 | SceKernelEqueue flipQueue; 46 | int videoHandle; 47 | int currentBuffer; 48 | int orbis2d_initialized; 49 | 50 | }Orbis2dConfig; 51 | 52 | typedef struct Orbis2dTexture 53 | { 54 | uint32_t *datap; 55 | unsigned int width; 56 | unsigned int height; 57 | unsigned int depth; 58 | }Orbis2dTexture; 59 | 60 | int orbis2dInit(); 61 | void orbis2dFinish(); 62 | int orbis2dInitWithConf(Orbis2dConfig *conf); 63 | int orbis2dSetConf(Orbis2dConfig *conf); 64 | int orbis2dCreateConf(); 65 | Orbis2dConfig *orbis2dGetConf(); 66 | void orbis2dSwapBuffers(); 67 | void orbis2dClearBuffer(); 68 | void orbis2dDrawRectColor(int x, int w, int y, int h, uint32_t color); 69 | void orbis2dWritePixelColor(int x, int y, uint32_t pixelColor); 70 | void orbis2dStartDrawing(); 71 | void orbis2dFinishDrawing(int64_t flipArg); 72 | void orbis2dPutImage(uint32_t *buf,int x, int y, int w, int h); 73 | void orbis2dPutImage2(uint32_t *buf,int x, int y, int w, int h); 74 | void orbis2dPutImage3(uint32_t *buf,int x, int y, int w, int h); 75 | void orbis2dPutImage4(uint32_t *buf,int x, int y, int w, int h); 76 | void orbis2dPutImage5(uint32_t *buf,int x, int y, int w, int h); 77 | Orbis2dTexture * orbis2dCreateEmptyTexture(unsigned int w, unsigned int h); 78 | void orbis2dDestroyTexture(Orbis2dTexture *texture); 79 | uint32_t *orbis2dTextureGetDataPointer(Orbis2dTexture *texture); 80 | uint32_t orbis2dTextureGetStride(Orbis2dTexture *texture); 81 | Orbis2dTexture *orbis2dLoadPngFromBuffer(const void *buffer); 82 | Orbis2dTexture *orbis2dLoadPngFromHost(const char *filename); 83 | void orbis2dDrawTexture(Orbis2dTexture *texture,unsigned int x, unsigned int y); 84 | -------------------------------------------------------------------------------- /liborbisKeyboard/include/orbisKeyboard.h: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/liborbis 5 | */ 6 | #include 7 | #include 8 | 9 | #define ORBIS_IME_MODULE 0x0095 10 | 11 | typedef enum OrbisKeyboardEventId{ 12 | ORBIS_KEYBOARD_EVENT_OPEN = 256, 13 | ORBIS_KEYBOARD_EVENT_KEYCODE_DOWN = 257, 14 | ORBIS_KEYBOARD_EVENT_KEYCODE_UP = 258, 15 | ORBIS_KEYBOARD_EVENT_KEYCODE_REPEAT = 259, 16 | ORBIS_KEYBOARD_EVENT_CONNECTION = 260, 17 | ORBIS_KEYBOARD_EVENT_DISCONNECTION = 261, 18 | ORBIS_KEYBOARD_EVENT_ABORT = 262, 19 | } OrbisKeyboardEventId; 20 | 21 | typedef struct OrbisKeyboardConfig 22 | { 23 | SceUserServiceUserId userId; 24 | int status; 25 | int caps_key; 26 | int control_key_left; 27 | int control_key_right; 28 | int shift_key_left; 29 | int shift_key_right; 30 | int alt_key_left; 31 | int alt_key_right; 32 | int cmd_key_left; 33 | int cmd_key_right; 34 | uint8_t key; 35 | uint8_t key_status; 36 | int orbiskeyboard_initialized; 37 | 38 | }OrbisKeyboardConfig; 39 | 40 | 41 | typedef struct 42 | { 43 | SceUserServiceUserId userId; 44 | uint32_t resourceId[5]; 45 | } OrbisKeyboardResourceIdArray; 46 | 47 | typedef struct 48 | { 49 | uint16_t keycode; 50 | uint32_t status;//1.76 51 | uint32_t unknown1; 52 | SceUserServiceUserId userId; 53 | uint32_t resourceId; 54 | uint32_t unknown2; 55 | uint64_t timestamp; 56 | } OrbisKeyboardKeycode; 57 | 58 | typedef union 59 | { 60 | int8_t notused[84]; 61 | OrbisKeyboardKeycode keycode; 62 | OrbisKeyboardResourceIdArray resourceIdArray; 63 | void *candidateWord; 64 | int32_t candidateIndex; 65 | int32_t deviceType; 66 | uint32_t inputMethodState; 67 | int8_t reserved[64]; 68 | } OrbisKeyboardEventParam; 69 | 70 | typedef struct OrbisKeyboardEvent { 71 | OrbisKeyboardEventId id; 72 | OrbisKeyboardEventParam param; 73 | } OrbisKeyboardEvent; 74 | 75 | typedef void (*OrbisKeyboardEventHandler)( 76 | void *arg, 77 | const OrbisKeyboardEvent *e 78 | ); 79 | 80 | typedef struct OrbisKeyboardParam { 81 | uint32_t option; 82 | int8_t unknown1[4]; 83 | void *arg; 84 | OrbisKeyboardEventHandler handler; 85 | int8_t unknown2[8]; 86 | } OrbisKeyboardParam; 87 | 88 | 89 | int orbisKeyboardInit(); 90 | void orbisKeyboardFinish(); 91 | int orbisKeyboardOpen(); 92 | int orbisKeyboardRegisterUpdateHandler(void *arg,OrbisKeyboardEventHandler handler); 93 | void orbisKeybordGetSpecialKeys(const OrbisKeyboardEvent *e); 94 | uint8_t orbisKeyboardGetMsxKey(); 95 | uint8_t orbisKeyboardGetMsxKeyShift(); 96 | uint8_t orbisKeyboardGetMsxKeyCtrl(); 97 | uint8_t orbisKeyboardGetMsxKeyStatus(); 98 | void orbisKeyboardUpdate(); 99 | int sceImeUpdate(OrbisKeyboardEventHandler handler); 100 | int sceImeKeyboardOpen(SceUserServiceUserId userId,const OrbisKeyboardParam *param); 101 | int sceImeKeyboardClose(SceUserServiceUserId userId); 102 | 103 | 104 | -------------------------------------------------------------------------------- /portlibs/zlib/include/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of the dynamic table. The maximum number of code structures is 39 | 1444, which is the sum of 852 for literal/length codes and 592 for distance 40 | codes. These values were found by exhaustive searches using the program 41 | examples/enough.c found in the zlib distribtution. The arguments to that 42 | program are the number of symbols, the initial root table size, and the 43 | maximum bit length of a code. "enough 286 9 15" for literal/length codes 44 | returns returns 852, and "enough 30 6 15" for distance codes returns 592. 45 | The initial root table size (9 or 6) is found in the fifth argument of the 46 | inflate_table() calls in inflate.c and infback.c. If the root table size is 47 | changed, then these maximum sizes would be need to be recalculated and 48 | updated. */ 49 | #define ENOUGH_LENS 852 50 | #define ENOUGH_DISTS 592 51 | #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) 52 | 53 | /* Type of code to build for inflate_table() */ 54 | typedef enum { 55 | CODES, 56 | LENS, 57 | DISTS 58 | } codetype; 59 | 60 | int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, 61 | unsigned codes, code FAR * FAR *table, 62 | unsigned FAR *bits, unsigned short FAR *work)); 63 | -------------------------------------------------------------------------------- /libmod/include/modplayeri.h: -------------------------------------------------------------------------------- 1 | // modplayeri.h: headers for psp modplayer code 2 | // 3 | // NOTE: this is only for including in modplayer.c, use 'modplayer.h' 4 | // for including the public funcs in your own code 5 | // 6 | ////////////////////////////////////////////////////////////////////// 7 | 8 | #ifndef _MODPLAYER_H 9 | #define _MODPLAYER_H 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | // These next few lines determine how the sound will be mixed. 16 | // Set PLAYBACK_FREQ to whatever you want. 17 | #define PLAYBACK_FREQ 48000 18 | 19 | // OVERSAMPLE can be commented out to disable that function 20 | // (takes up less CPU time, but doesnt sound as good). 21 | #define OVERSAMPLE 22 | 23 | // The NoteData structure stores the information for a single note and/or effect. 24 | typedef struct { 25 | int sample_num; // The sample number (ie "instrument") to play, 1->31 26 | int period_index; // This effectively stores the frequency to play the 27 | // sample, although it's actually an index into 28 | // PeriodTable. 29 | int effect; // Contains the effect code 30 | int effect_parms; // Used to store control parameters for the 31 | // various effects 32 | } NoteData; 33 | 34 | // RowData stores all the information for a single row. If there are 8 tracks 35 | // in this mod then this structure will be filled with 8 elements of NoteData, 36 | // one for each track. 37 | typedef struct { 38 | int numnotes; 39 | NoteData *note; 40 | } RowData; 41 | 42 | // Pattern contains all the information for a single pattern. 43 | // It is filled with 64 elements of type RowData. 44 | typedef struct { 45 | int numrows; 46 | RowData *row; 47 | } Pattern; 48 | 49 | // The Sample structure is used to store all the information for a single 50 | // sample, or "instrument". Most of the member's should be self-explanatory. 51 | // The "data" member is an array of bytes containing the raw sample data 52 | // in 8-bit signed format. 53 | typedef struct { 54 | char szName[100]; 55 | int nLength, nFineTune, nVolume, nLoopStart, nLoopLength, nLoopEnd; 56 | int data_length; 57 | char *data; 58 | } Sample; 59 | 60 | 61 | // TrackData is used to store ongoing information about a particular track. 62 | typedef struct { 63 | int sample; // The current sample being played (0 for none) 64 | int pos; // The current playback position in the sample, 65 | // stored in fixed-point format 66 | int period_index; // Which note to play, stored as an index into the 67 | // PeriodTable array 68 | int period; // The period number that period_index corresponds to 69 | // (needed for various effects) 70 | float freq; // This is the actual frequency used to do the mixing. 71 | // It's a combination of the value calculated from the 72 | // period member and an "adjustment" made by various effects. 73 | int volume; // Volume that this track is to be mixed at 74 | int mixvol; // This is the actual volume used to do the mixing. 75 | // It's a combination of the volume member and an 76 | // "adjustment" made by various effects. 77 | int porta; // Used by the porta effect, this stores the note we're 78 | // porta-ing (?) to 79 | int portasp; // The speed at which to porta 80 | int vibspe; // Vibrato speed 81 | int vibdep; // Vibrato depth 82 | int tremspe; // Tremolo speed 83 | int tremdep; // Tremolo depth 84 | int panval; // Pan value....this player doesn't actually do panning, 85 | // so this member is ignored (but included for future use) 86 | int sinepos; // These next two values are pointers to the sine table. 87 | // They're used to do 88 | int sineneg; // various effects. 89 | } TrackData; 90 | 91 | #ifdef __cplusplus 92 | } 93 | #endif 94 | #endif 95 | -------------------------------------------------------------------------------- /orbislink/libps4link/source/jailbreak.c: -------------------------------------------------------------------------------- 1 | #include 2 | struct auditinfo_addr { 3 | /* 4 | 4 ai_auid; 5 | 8 ai_mask; 6 | 24 ai_termid; 7 | 4 ai_asid; 8 | 8 ai_flags;r 9 | */ 10 | char useless[184]; 11 | }; 12 | 13 | struct ucred { 14 | uint32_t useless1; 15 | uint32_t cr_uid; // effective user id 16 | uint32_t cr_ruid; // real user id 17 | uint32_t useless2; 18 | uint32_t useless3; 19 | uint32_t cr_rgid; // real group id 20 | uint32_t useless4; 21 | void *useless5; 22 | void *useless6; 23 | void *cr_prison; // jail(2) 24 | void *useless7; 25 | uint32_t useless8; 26 | void *useless9[2]; 27 | void *useless10; 28 | struct auditinfo_addr useless11; 29 | uint32_t *cr_groups; // groups 30 | uint32_t useless12; 31 | }; 32 | 33 | struct proc { 34 | char useless[64]; 35 | struct ucred *p_ucred; 36 | }; 37 | 38 | struct thread { 39 | void *useless; 40 | struct proc *td_proc; 41 | }; 42 | 43 | struct fileops { 44 | void *fo_read; 45 | void *fo_write; 46 | void *fo_truncate; 47 | void *fo_ioctl; 48 | void *fo_poll; 49 | void *fo_kqfilter; 50 | void *fo_stat; 51 | void *fo_close; 52 | void *fo_chmod; 53 | void *fo_chown; 54 | int fo_flags; /* DFLAG_* below */ 55 | }; 56 | 57 | 58 | int jailbreak(struct thread *td, void *uap) { 59 | struct ucred *cred; 60 | 61 | // Disable write protection 62 | ps4KernelProtectionWriteDisable(); 63 | //sysctl_machdep_rcmgr_debug_menu and sysctl_machdep_rcmgr_store_moe 64 | //*(uint16_t *)0xFFFFFFFF82607C46 = 0x9090; 65 | //*(uint16_t *)0xFFFFFFFF82607826 = 0x9090; 66 | 67 | //*(char *)0xFFFFFFFF8332431A = 1; 68 | //*(char *)0xFFFFFFFF83324338 = 1; 69 | 70 | //dex 71 | //*(char *)0xFFFFFFFF833242FD = 0x81; 72 | 73 | //Fully enable Debug Settings: 74 | //*(uint32_t*) 0xFFFFFFFF8269C07C=0; 75 | //*(uint32_t*) 0xFFFFFFFF8269B56F=0; 76 | 77 | //spoof 78 | //((uint64_t *) 0xFFFFFFFF8323A4E0)[0] = 0x9000000; 79 | // Disable Process ASLR - Thanks to ZiL0G80 80 | *(uint16_t *)0xFFFFFFFF82649C9C = 0x63EB; 81 | 82 | // Restore write protection 83 | ps4KernelProtectionWriteEnable(); 84 | // Resolve creds 85 | cred = td->td_proc->p_ucred; 86 | 87 | // Escalate process to root 88 | cred->cr_uid = 0; 89 | cred->cr_ruid = 0; 90 | cred->cr_rgid = 0; 91 | cred->cr_groups[0] = 0; 92 | 93 | void *td_ucred = *(void **)(((char *)td) + 304); // p_ucred == td_ucred 94 | 95 | // sceSblACMgrIsSystemUcred 96 | uint64_t *sonyCred = (uint64_t *)(((char *)td_ucred) + 96); 97 | *sonyCred = 0xffffffffffffffffULL; 98 | 99 | // sceSblACMgrGetDeviceAccessType 100 | uint64_t *sceProcType = (uint64_t *)(((char *)td_ucred) + 88); 101 | *sceProcType = 0x3801000000000013ULL; // Max access 102 | 103 | // sceSblACMgrHasSceProcessCapability 104 | uint64_t *sceProcCap = (uint64_t *)(((char *)td_ucred) + 104); 105 | *sceProcCap = 0xffffffffffffffffULL; // Sce Process 106 | 107 | 108 | ((uint64_t *)0xFFFFFFFF832CC2E8ULL)[0] = 0x123456; //priv_check_cred bypass with suser_enabled=true 109 | ((uint64_t *)0xFFFFFFFF8323DA18ULL)[0] = 0; // bypass priv_check 110 | 111 | // Jailbreak ;) 112 | cred->cr_prison = (void *)0xFFFFFFFF83237250ULL; //&prison0 113 | 114 | // Break out of the sandbox 115 | void *td_fdp = *(void **)(((char *)td->td_proc) + 72); 116 | uint64_t *td_fdp_fd_rdir = (uint64_t *)(((char *)td_fdp) + 24); 117 | uint64_t *td_fdp_fd_jdir = (uint64_t *)(((char *)td_fdp) + 32); 118 | uint64_t *rootvnode = (uint64_t *)0xFFFFFFFF832EF920ULL; 119 | *td_fdp_fd_rdir = *rootvnode; 120 | *td_fdp_fd_jdir = *rootvnode; 121 | 122 | return 0; 123 | } 124 | -------------------------------------------------------------------------------- /liborbisKeyboard/include/kb.h: -------------------------------------------------------------------------------- 1 | #define KEY_A 0x04 // Keyboard a and A 2 | #define KEY_B 0x05 // Keyboard b and B 3 | #define KEY_C 0x06 // Keyboard c and C 4 | #define KEY_D 0x07 // Keyboard d and D 5 | #define KEY_E 0x08 // Keyboard e and E 6 | #define KEY_F 0x09 // Keyboard f and F 7 | #define KEY_G 0x0a // Keyboard g and G 8 | #define KEY_H 0x0b // Keyboard h and H 9 | #define KEY_I 0x0c // Keyboard i and I 10 | #define KEY_J 0x0d // Keyboard j and J 11 | #define KEY_K 0x0e // Keyboard k and K 12 | #define KEY_L 0x0f // Keyboard l and L 13 | #define KEY_M 0x10 // Keyboard m and M 14 | #define KEY_N 0x11 // Keyboard n and N 15 | #define KEY_O 0x12 // Keyboard o and O 16 | #define KEY_P 0x13 // Keyboard p and P 17 | #define KEY_Q 0x14 // Keyboard q and Q 18 | #define KEY_R 0x15 // Keyboard r and R 19 | #define KEY_S 0x16 // Keyboard s and S 20 | #define KEY_T 0x17 // Keyboard t and T 21 | #define KEY_U 0x18 // Keyboard u and U 22 | #define KEY_V 0x19 // Keyboard v and V 23 | #define KEY_W 0x1a // Keyboard w and W 24 | #define KEY_X 0x1b // Keyboard x and X 25 | #define KEY_Y 0x1c // Keyboard y and Y 26 | #define KEY_Z 0x1d // Keyboard z and Z 27 | 28 | #define KEY_1 0x1e // Keyboard 1 and ! 29 | #define KEY_2 0x1f // Keyboard 2 and @ 30 | #define KEY_3 0x20 // Keyboard 3 and # 31 | #define KEY_4 0x21 // Keyboard 4 and $ 32 | #define KEY_5 0x22 // Keyboard 5 and % 33 | #define KEY_6 0x23 // Keyboard 6 and ^ 34 | #define KEY_7 0x24 // Keyboard 7 and & 35 | #define KEY_8 0x25 // Keyboard 8 and * 36 | #define KEY_9 0x26 // Keyboard 9 and ( 37 | #define KEY_0 0x27 // Keyboard 0 and ) 38 | 39 | #define KEY_ENTER 0x28 // Keyboard Return (ENTER) 40 | #define KEY_ESC 0x29 // Keyboard ESCAPE 41 | #define KEY_BACKSPACE 0x2a // Keyboard DELETE (Backspace) 42 | #define KEY_TAB 0x2b // Keyboard Tab 43 | #define KEY_SPACE 0x2c // Keyboard Spacebar 44 | #define KEY_MINUS 0x2d // Keyboard - and _ 45 | #define KEY_EQUAL 0x2e // Keyboard = and + 46 | #define KEY_LEFTBRACE 0x2f // Keyboard [ and { 47 | #define KEY_RIGHTBRACE 0x30 // Keyboard ] and } 48 | #define KEY_BACKSLASH 0x31 // Keyboard \ and | 49 | #define KEY_HASHTILDE 0x32 // Keyboard Non-US # and ~ 50 | #define KEY_SEMICOLON 0x33 // Keyboard ; and : 51 | #define KEY_APOSTROPHE 0x34 // Keyboard ' and " 52 | #define KEY_GRAVE 0x35 // Keyboard ` and ~ 53 | #define KEY_COMMA 0x36 // Keyboard , and < 54 | #define KEY_DOT 0x37 // Keyboard . and > 55 | #define KEY_SLASH 0x38 // Keyboard / and ? 56 | #define KEY_CAPSLOCK 0x39 // Keyboard Caps Lock 57 | 58 | #define KEY_F1 0x3a // Keyboard F1 59 | #define KEY_F2 0x3b // Keyboard F2 60 | #define KEY_F3 0x3c // Keyboard F3 61 | #define KEY_F4 0x3d // Keyboard F4 62 | #define KEY_F5 0x3e // Keyboard F5 63 | #define KEY_F6 0x3f // Keyboard F6 64 | #define KEY_F7 0x40 // Keyboard F7 65 | #define KEY_F8 0x41 // Keyboard F8 66 | #define KEY_F9 0x42 // Keyboard F9 67 | #define KEY_F10 0x43 // Keyboard F10 68 | #define KEY_F11 0x44 // Keyboard F11 69 | #define KEY_F12 0x45 // Keyboard F12 70 | 71 | #define KEY_SYSRQ 0x46 // Keyboard Print Screen 72 | #define KEY_SCROLLLOCK 0x47 // Keyboard Scroll Lock 73 | #define KEY_PAUSE 0x48 // Keyboard Pause 74 | #define KEY_INSERT 0x49 // Keyboard Insert 75 | #define KEY_HOME 0x4a // Keyboard Home 76 | #define KEY_PAGEUP 0x4b // Keyboard Page Up 77 | #define KEY_DELETE 0x4c // Keyboard Delete Forward 78 | #define KEY_END 0x4d // Keyboard End 79 | #define KEY_PAGEDOWN 0x4e // Keyboard Page Down 80 | #define KEY_RIGHT 0x4f // Keyboard Right Arrow 81 | #define KEY_LEFT 0x50 // Keyboard Left Arrow 82 | #define KEY_DOWN 0x51 // Keyboard Down Arrow 83 | #define KEY_UP 0x52 // Keyboard Up Arrow 84 | #define KEY_NONUS_BACKSLASH 0x0064 //non us keyboard 85 | #define KEY_LEFTCONTROL 0x00E0 // Left Control 86 | #define KEY_LEFTSHIFT 0x00E1 // Left Shift 87 | #define KEY_LEFTALT 0x00E2 // Keypad Left Alt 88 | #define KEY_LEFTGUI 0x00E3 // Keypad Left Gui 89 | #define KEY_RIGHTCONTROL 0x00E4 // Keypad Right Control 90 | #define KEY_RIGHTSHIFT 0x00E5 // Keypad Right Shift 91 | #define KEY_RIGHTALT 0x00E6 // Keypad Right Alt 92 | #define KEY_RIGHTGUI 0x00E7 // Keypad Right Gui 93 | -------------------------------------------------------------------------------- /liborbisXbmFont/source/orbisXbmFont.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include // orbis2dDrawPixelColor() 4 | 5 | #include "orbisXbmFont.h" 6 | 7 | 8 | static uint32_t fading_color[SIMPLE_GRADIENT_STEPS]; // precomputed gradient [0-7] 9 | 10 | 11 | /*********************************************************************** 12 | * simple gradient (ARGB) 13 | * 14 | * uint32_t *a = pointer to start color 15 | * uint32_t *b = pointer to end color 16 | * uint8_t steps = number of steps we split fade 17 | * uint8_t step = which step we compute and return 18 | ***********************************************************************/ 19 | typedef float float4 __attribute__((ext_vector_type(4))); 20 | 21 | static uint32_t simple_gradient(const uint32_t *a, const uint32_t *b, const uint8_t steps, const uint8_t step) 22 | { 23 | float4 fr4, to4, col; // use .xyzw vector components as ARGB color components 24 | 25 | // load vectors 26 | fr4 = (float4){ GET_A(*a), GET_R(*a), GET_G(*a), GET_B(*a) }; 27 | to4 = (float4){ GET_A(*b), GET_R(*b), GET_G(*b), GET_B(*b) }; 28 | 29 | // compute which color we return 30 | col = ((to4 - fr4) / ( (float)(steps -1) )); // num of slices 31 | 32 | fr4 += col * ( (float)(step) ); // requested slice 33 | 34 | return ARGB( (uint8_t)fr4.x, (uint8_t)fr4.y, (uint8_t)fr4.z, (uint8_t)fr4.w ); 35 | } 36 | 37 | 38 | /*********************************************************************** 39 | * update_gradient 40 | * 41 | * precompute palette to use in print_text() and setup colors range 42 | * 43 | * uint32_t *a = pointer to start color 44 | * uint32_t *b = pointer to end color 45 | ***********************************************************************/ 46 | void update_gradient(const uint32_t *a, const uint32_t *b) 47 | { 48 | for(uint8_t i = 0; i < SIMPLE_GRADIENT_STEPS; i++) 49 | { 50 | fading_color[i] = (*a == *b) ? *a : simple_gradient(a, b, SIMPLE_GRADIENT_STEPS, i); 51 | } 52 | } 53 | 54 | 55 | /*********************************************************************** 56 | * compute x to align text into canvas 57 | * 58 | * const char *str = referring string 59 | * uint8_t align. = RIGHT / CENTER (1/2) 60 | ***********************************************************************/ 61 | uint16_t get_aligned_x(const char *str, const uint8_t alignment) 62 | { 63 | uint16_t len = (strlen(str) * FONT_W); // monospaced font 64 | 65 | return (uint16_t)((ATTR_WIDTH - len) / alignment); 66 | } 67 | 68 | 69 | /*********************************************************************** 70 | * print text, with bitmap data from xbm_font.h 71 | * 72 | * int32_t x = start x coordinate into canvas 73 | * int32_t y = start y coordinate into canvas 74 | * const char *str = string to print 75 | ***********************************************************************/ 76 | int32_t print_text(int32_t x, int32_t y, const char *str) 77 | { 78 | char *bit = NULL; 79 | uint8_t *c, i, j, tx = 0, ty = 0; 80 | 81 | while(*str != '\0') 82 | { 83 | c = (uint8_t*)str++; // address the current char 84 | 85 | if(*c < LOWER_ASCII_CODE 86 | || *c > UPPER_ASCII_CODE) 87 | { x += FONT_W; continue; } // skipped, move one char in canvas 88 | 89 | bit = xbmFont[*c - LOWER_ASCII_CODE]; 90 | 91 | // dump bits map (bytes_per_line 2, size 32 char of 8 bit) 92 | for(i = 0; i < ((FONT_W * FONT_H) / BITS_IN_BYTE); i++) 93 | { 94 | for(j = 0; j < BITS_IN_BYTE; j++) 95 | { 96 | if(bit[i] & (1 << j)) // least significant bit first 97 | { 98 | /* draw to screen via liborbis2d */ 99 | orbis2dDrawPixelColor( 100 | (x + tx * BITS_IN_BYTE + j), 101 | (y + ty), 102 | fading_color[ty /2]); // paint FG pixel with precomputed fading color 103 | 104 | // displace shadow by (+SHADOW_PX, +SHADOW_PX) 105 | orbis2dDrawPixelColor( 106 | (x + tx * BITS_IN_BYTE + j) + SHADOW_PX, 107 | (y + ty) + SHADOW_PX, 108 | 0x80000000); // paint SHADOW pixel with fixed color 109 | } 110 | } 111 | tx++; 112 | if(tx == (FONT_W / BITS_IN_BYTE)) 113 | tx = 0, ty++; // step to decrease gradient 114 | } 115 | // glyph painted, move one char right in text 116 | x += FONT_W, ty = 0; 117 | } 118 | 119 | return x; 120 | } 121 | -------------------------------------------------------------------------------- /liborbis2d/source/orbis2dImagePng.c: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/liborbis 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include "orbis2d.h" 12 | 13 | #define PNG_SIGSIZE (8) 14 | 15 | static void orbis2dReadPngFromHost(png_structp png_ptr, png_bytep data, png_size_t length) 16 | { 17 | int fd = *(int *)png_get_io_ptr(png_ptr); 18 | ps4LinkRead(fd,data,length); 19 | } 20 | 21 | 22 | static void orbis2dReadPngFromBuffer(png_structp png_ptr, png_bytep data, png_size_t length) 23 | { 24 | uint64_t *address = png_get_io_ptr(png_ptr); 25 | memcpy(data, (void *)*address, length); 26 | *address += length; 27 | } 28 | 29 | static Orbis2dTexture *orbis2dLoadPngGeneric(const void *io_ptr,png_rw_ptr read_data_fn) 30 | { 31 | png_structp png_ptr=png_create_read_struct(PNG_LIBPNG_VER_STRING,NULL,NULL,NULL); 32 | if (png_ptr==NULL) 33 | { 34 | goto error_create_read; 35 | } 36 | 37 | png_infop info_ptr=png_create_info_struct(png_ptr); 38 | if (info_ptr==NULL) 39 | { 40 | goto error_create_info; 41 | } 42 | 43 | png_bytep *row_ptrs=NULL; 44 | 45 | if (setjmp(png_jmpbuf(png_ptr))) 46 | { 47 | png_destroy_read_struct(&png_ptr,&info_ptr,(png_infopp)0); 48 | if (row_ptrs!=NULL) 49 | { 50 | free(row_ptrs); 51 | } 52 | return NULL; 53 | } 54 | 55 | png_set_read_fn(png_ptr,(png_voidp)io_ptr,read_data_fn); 56 | png_set_sig_bytes(png_ptr,PNG_SIGSIZE); 57 | png_read_info(png_ptr,info_ptr); 58 | 59 | unsigned int width, height; 60 | int bit_depth, color_type; 61 | 62 | png_get_IHDR(png_ptr,info_ptr,&width,&height,&bit_depth,&color_type,NULL,NULL,NULL); 63 | 64 | if ((color_type==PNG_COLOR_TYPE_PALETTE && bit_depth<=8) 65 | || (color_type==PNG_COLOR_TYPE_GRAY && bit_depth<8) 66 | || png_get_valid(png_ptr,info_ptr,PNG_INFO_tRNS) 67 | || (bit_depth==16)) 68 | { 69 | png_set_expand(png_ptr); 70 | } 71 | 72 | if (bit_depth == 16) 73 | png_set_scale_16(png_ptr); 74 | 75 | if (bit_depth==8 && color_type==PNG_COLOR_TYPE_RGB) 76 | png_set_filler(png_ptr,0xFF,PNG_FILLER_AFTER); 77 | 78 | if (color_type==PNG_COLOR_TYPE_GRAY || 79 | color_type==PNG_COLOR_TYPE_GRAY_ALPHA) 80 | png_set_gray_to_rgb(png_ptr); 81 | 82 | if (color_type==PNG_COLOR_TYPE_PALETTE) { 83 | png_set_palette_to_rgb(png_ptr); 84 | png_set_filler(png_ptr,0xFF,PNG_FILLER_AFTER); 85 | } 86 | 87 | if (color_type==PNG_COLOR_TYPE_GRAY && bit_depth < 8) 88 | png_set_expand_gray_1_2_4_to_8(png_ptr); 89 | 90 | if (png_get_valid(png_ptr,info_ptr,PNG_INFO_tRNS)) 91 | png_set_tRNS_to_alpha(png_ptr); 92 | 93 | if (bit_depth<8) 94 | png_set_packing(png_ptr); 95 | 96 | png_read_update_info(png_ptr, info_ptr); 97 | 98 | row_ptrs = (png_bytep *)malloc(sizeof(png_bytep)*height); 99 | if (!row_ptrs) 100 | goto error_alloc_rows; 101 | 102 | Orbis2dTexture *texture = orbis2dCreateEmptyTexture(width,height); 103 | if (!texture) 104 | goto error_create_tex; 105 | 106 | uint32_t *texture_data=orbis2dTextureGetDataPointer(texture); 107 | unsigned int stride=orbis2dTextureGetStride(texture); 108 | 109 | int i; 110 | for (i=0;i 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #include "debugnet.h" 15 | 16 | 17 | int debugnet_external_conf=0; 18 | debugNetConfiguration *dconfig=NULL; 19 | 20 | /*static int debugnet_initialized=0; 21 | int SocketFD = -1; 22 | int logLevel=INFO;*/ 23 | 24 | /** 25 | * UDP printf for debugnet library 26 | * 27 | * @par Example: 28 | * @code 29 | * debugNetUDPPrintf("This is a test\n"); 30 | * @endcode 31 | */ 32 | void debugNetUDPPrintf(const char* fmt, ...) 33 | { 34 | char buffer[0x800]; 35 | va_list arg; 36 | va_start(arg, fmt); 37 | vsnprintf(buffer, sizeof(buffer), fmt, arg); 38 | va_end(arg); 39 | sceNetSend(dconfig->SocketFD, buffer, strlen(buffer), 0); 40 | } 41 | /** 42 | * Log Level printf for debugnet library 43 | * 44 | * @par Example: 45 | * @code 46 | * debugNetPrintf(INFO,"This is a test\n"); 47 | * @endcode 48 | * 49 | * @param level - NONE,INFO,ERROR or DEBUG 50 | */ 51 | void debugNetPrintf(int level, char* format, ...) 52 | { 53 | char msgbuf[0x800]; 54 | va_list args; 55 | 56 | if (level>dconfig->logLevel) 57 | return; 58 | 59 | va_start(args, format); 60 | vsnprintf(msgbuf,2048, format, args); 61 | msgbuf[2047] = 0; 62 | va_end(args); 63 | switch(level) 64 | { 65 | case INFO: 66 | debugNetUDPPrintf("[PS4][INFO]: %s",msgbuf); 67 | break; 68 | case ERROR: 69 | debugNetUDPPrintf("[PS4][ERROR]: %s",msgbuf); 70 | break; 71 | case DEBUG: 72 | debugNetUDPPrintf("[PS4][DEBUG]: %s",msgbuf); 73 | break; 74 | case NONE: 75 | break; 76 | default: 77 | debugNetUDPPrintf("%s",msgbuf); 78 | 79 | } 80 | } 81 | /** 82 | * Set log level for debugnet library 83 | * 84 | * @par Example: 85 | * @code 86 | * debugNetSetLogLevel(DEBUG); 87 | * @endcode 88 | * @param level - DEBUG,ERROR,INFO or NONE 89 | */ 90 | void debugNetSetLogLevel(int level) 91 | { 92 | if(dconfig) 93 | { 94 | dconfig->logLevel=level; 95 | } 96 | } 97 | /** 98 | * Init debugnet library 99 | * 100 | * @par Example: 101 | * @code 102 | * #define LOGLEVEL 3 103 | * int ret; 104 | * ret = debugNetInit("172.26.0.2", 18194, DEBUG); 105 | * @endcode 106 | * 107 | * @param serverIP - your pc/mac server ip 108 | * @param port - udp port server 109 | * @param level - DEBUG,ERROR,INFO or NONE 110 | */ 111 | int debugNetInit(char *serverIp, int port, int level) 112 | { 113 | 114 | 115 | // struct SceNetSockaddrIn stSockAddr; SceNet data types not yet in libps3 116 | struct sockaddr_in stSockAddr; 117 | if(debugNetCreateConf()) 118 | { 119 | return dconfig->debugnet_initialized; 120 | } 121 | 122 | debugNetSetLogLevel(level); 123 | 124 | 125 | //network initialization code is not needed on PS4 is started at boot 126 | 127 | /* Create datagram udp socket*/ 128 | dconfig->SocketFD = sceNetSocket("debugnet_socket",AF_INET , SOCK_DGRAM, IPPROTO_UDP); 129 | 130 | memset(&stSockAddr, 0, sizeof stSockAddr); 131 | 132 | /*Populate SceNetSockaddrIn structure values*/ 133 | 134 | stSockAddr.sin_family = AF_INET; 135 | stSockAddr.sin_port = sceNetHtons(port); 136 | sceNetInetPton(AF_INET, serverIp, &stSockAddr.sin_addr); 137 | 138 | /*Connect socket to server*/ 139 | sceNetConnect(dconfig->SocketFD, (struct sockaddr *)&stSockAddr, sizeof stSockAddr); 140 | 141 | /*Show log on pc/mac side*/ 142 | debugNetPrintf(INFO,"debugnet initialized\n"); 143 | debugNetPrintf(INFO,"Copyright (C) 2010,2016 Antonio Jose Ramos Marquez aka bigboss @psxdev\n"); 144 | debugNetPrintf(INFO,"ready to have a lot of fun...\n"); 145 | 146 | /*library debugnet initialized*/ 147 | dconfig->debugnet_initialized = 1; 148 | 149 | return dconfig->debugnet_initialized; 150 | } 151 | debugNetConfiguration *debugNetGetConf() 152 | { 153 | if(dconfig) 154 | { 155 | return dconfig; 156 | } 157 | 158 | return NULL; 159 | } 160 | int debugNetSetConf(debugNetConfiguration *conf) 161 | { 162 | if(conf) 163 | { 164 | dconfig=conf; 165 | debugnet_external_conf=1; 166 | return dconfig->debugnet_initialized; 167 | } 168 | 169 | return 0; 170 | } 171 | int debugNetInitWithConf(debugNetConfiguration *conf) 172 | { 173 | int ret; 174 | ret=debugNetSetConf(conf); 175 | if(ret) 176 | { 177 | debugNetPrintf(INFO,"debugnet already initialized using configuration from ps4link\n"); 178 | debugNetPrintf(INFO,"debugnet_initialized=%d SocketFD=%d logLevel=%d\n",dconfig->debugnet_initialized,dconfig->SocketFD,dconfig->logLevel); 179 | debugNetPrintf(INFO,"ready to have a lot of fun...\n"); 180 | return dconfig->debugnet_initialized; 181 | } 182 | else 183 | { 184 | return 0; 185 | } 186 | 187 | } 188 | int debugNetCreateConf() 189 | { 190 | if(!dconfig) 191 | { 192 | dconfig=malloc(sizeof(debugNetConfiguration)); 193 | dconfig->debugnet_initialized=0; 194 | dconfig->SocketFD = -1; 195 | dconfig->logLevel=INFO; 196 | return 0; 197 | } 198 | 199 | if(dconfig->debugnet_initialized) 200 | { 201 | return 1; 202 | } 203 | return 0; 204 | } 205 | 206 | 207 | /** 208 | * Finish debugnet library 209 | * 210 | * @par Example: 211 | * @code 212 | * debugNetFinish(); 213 | * @endcode 214 | */ 215 | void debugNetFinish() 216 | { 217 | if(!debugnet_external_conf) 218 | { 219 | if (dconfig->debugnet_initialized) { 220 | dconfig->debugnet_initialized = 0; 221 | dconfig->SocketFD=-1; 222 | } 223 | } 224 | } 225 | -------------------------------------------------------------------------------- /portlibs/zlib/source/adler32.c: -------------------------------------------------------------------------------- 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2007 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | 10 | #define local static 11 | 12 | local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2); 13 | 14 | #define BASE 65521UL /* largest prime smaller than 65536 */ 15 | #define NMAX 5552 16 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 17 | 18 | #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} 19 | #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 20 | #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 21 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 22 | #define DO16(buf) DO8(buf,0); DO8(buf,8); 23 | 24 | /* use NO_DIVIDE if your processor does not do division in hardware */ 25 | #ifdef NO_DIVIDE 26 | # define MOD(a) \ 27 | do { \ 28 | if (a >= (BASE << 16)) a -= (BASE << 16); \ 29 | if (a >= (BASE << 15)) a -= (BASE << 15); \ 30 | if (a >= (BASE << 14)) a -= (BASE << 14); \ 31 | if (a >= (BASE << 13)) a -= (BASE << 13); \ 32 | if (a >= (BASE << 12)) a -= (BASE << 12); \ 33 | if (a >= (BASE << 11)) a -= (BASE << 11); \ 34 | if (a >= (BASE << 10)) a -= (BASE << 10); \ 35 | if (a >= (BASE << 9)) a -= (BASE << 9); \ 36 | if (a >= (BASE << 8)) a -= (BASE << 8); \ 37 | if (a >= (BASE << 7)) a -= (BASE << 7); \ 38 | if (a >= (BASE << 6)) a -= (BASE << 6); \ 39 | if (a >= (BASE << 5)) a -= (BASE << 5); \ 40 | if (a >= (BASE << 4)) a -= (BASE << 4); \ 41 | if (a >= (BASE << 3)) a -= (BASE << 3); \ 42 | if (a >= (BASE << 2)) a -= (BASE << 2); \ 43 | if (a >= (BASE << 1)) a -= (BASE << 1); \ 44 | if (a >= BASE) a -= BASE; \ 45 | } while (0) 46 | # define MOD4(a) \ 47 | do { \ 48 | if (a >= (BASE << 4)) a -= (BASE << 4); \ 49 | if (a >= (BASE << 3)) a -= (BASE << 3); \ 50 | if (a >= (BASE << 2)) a -= (BASE << 2); \ 51 | if (a >= (BASE << 1)) a -= (BASE << 1); \ 52 | if (a >= BASE) a -= BASE; \ 53 | } while (0) 54 | #else 55 | # define MOD(a) a %= BASE 56 | # define MOD4(a) a %= BASE 57 | #endif 58 | 59 | /* ========================================================================= */ 60 | uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) 61 | { 62 | unsigned long sum2; 63 | unsigned n; 64 | 65 | /* split Adler-32 into component sums */ 66 | sum2 = (adler >> 16) & 0xffff; 67 | adler &= 0xffff; 68 | 69 | /* in case user likes doing a byte at a time, keep it fast */ 70 | if (len == 1) { 71 | adler += buf[0]; 72 | if (adler >= BASE) 73 | adler -= BASE; 74 | sum2 += adler; 75 | if (sum2 >= BASE) 76 | sum2 -= BASE; 77 | return adler | (sum2 << 16); 78 | } 79 | 80 | /* initial Adler-32 value (deferred check for len == 1 speed) */ 81 | if (buf == Z_NULL) 82 | return 1L; 83 | 84 | /* in case short lengths are provided, keep it somewhat fast */ 85 | if (len < 16) { 86 | while (len--) { 87 | adler += *buf++; 88 | sum2 += adler; 89 | } 90 | if (adler >= BASE) 91 | adler -= BASE; 92 | MOD4(sum2); /* only added so many BASE's */ 93 | return adler | (sum2 << 16); 94 | } 95 | 96 | /* do length NMAX blocks -- requires just one modulo operation */ 97 | while (len >= NMAX) { 98 | len -= NMAX; 99 | n = NMAX / 16; /* NMAX is divisible by 16 */ 100 | do { 101 | DO16(buf); /* 16 sums unrolled */ 102 | buf += 16; 103 | } while (--n); 104 | MOD(adler); 105 | MOD(sum2); 106 | } 107 | 108 | /* do remaining bytes (less than NMAX, still just one modulo) */ 109 | if (len) { /* avoid modulos if none remaining */ 110 | while (len >= 16) { 111 | len -= 16; 112 | DO16(buf); 113 | buf += 16; 114 | } 115 | while (len--) { 116 | adler += *buf++; 117 | sum2 += adler; 118 | } 119 | MOD(adler); 120 | MOD(sum2); 121 | } 122 | 123 | /* return recombined sums */ 124 | return adler | (sum2 << 16); 125 | } 126 | 127 | /* ========================================================================= */ 128 | local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) 129 | { 130 | unsigned long sum1; 131 | unsigned long sum2; 132 | unsigned rem; 133 | 134 | /* the derivation of this formula is left as an exercise for the reader */ 135 | rem = (unsigned)(len2 % BASE); 136 | sum1 = adler1 & 0xffff; 137 | sum2 = rem * sum1; 138 | MOD(sum2); 139 | sum1 += (adler2 & 0xffff) + BASE - 1; 140 | sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; 141 | if (sum1 >= BASE) sum1 -= BASE; 142 | if (sum1 >= BASE) sum1 -= BASE; 143 | if (sum2 >= (BASE << 1)) sum2 -= (BASE << 1); 144 | if (sum2 >= BASE) sum2 -= BASE; 145 | return sum1 | (sum2 << 16); 146 | } 147 | 148 | /* ========================================================================= */ 149 | uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) 150 | { 151 | return adler32_combine_(adler1, adler2, len2); 152 | } 153 | 154 | uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) 155 | { 156 | return adler32_combine_(adler1, adler2, len2); 157 | } 158 | -------------------------------------------------------------------------------- /liborbisPad/source/orbisPad.c: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/liborbis 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "orbisPad.h" 13 | #include "logdebug.h" 14 | 15 | OrbisPadConfig *orbisPadConf=NULL; 16 | 17 | int orbispad_external_conf=-1; 18 | 19 | void orbisPadFinish() 20 | { 21 | int ret; 22 | if(orbispad_external_conf!=1) 23 | { 24 | if(orbisPadConf->orbispad_initialized==1) 25 | { 26 | ret=scePadClose(orbisPadConf->padHandle); 27 | 28 | sys_log("liborbis2d scePadClose return 0x%8x\n",ret); 29 | } 30 | orbisPadConf->orbispad_initialized=-1; 31 | 32 | sys_log("liborbisPad finished"); 33 | } 34 | } 35 | 36 | OrbisPadConfig *orbisPadGetConf() 37 | { 38 | if(orbisPadConf) 39 | { 40 | return orbisPadConf; 41 | } 42 | 43 | return NULL; 44 | } 45 | int orbisPadCreateConf() 46 | { 47 | if(!orbisPadConf) 48 | { 49 | orbisPadConf=(OrbisPadConfig *)malloc(sizeof(OrbisPadConfig)); 50 | 51 | orbisPadConf->userId=0; 52 | orbisPadConf->padHandle=-1; 53 | 54 | orbisPadConf->padDataCurrent=(ScePadData *)malloc(sizeof(ScePadData)); 55 | orbisPadConf->padDataLast=(ScePadData *)malloc(sizeof(ScePadData)); 56 | 57 | orbisPadConf->buttonsPressed=0; 58 | orbisPadConf->buttonsReleased=0; 59 | orbisPadConf->buttonsHold=0; 60 | 61 | orbisPadConf->orbispad_initialized=-1; 62 | 63 | return 0; 64 | } 65 | 66 | if(orbisPadConf->orbispad_initialized==1) 67 | { 68 | return orbisPadConf->orbispad_initialized; 69 | } 70 | //something weird happened 71 | return -1; 72 | } 73 | int orbisPadSetConf(OrbisPadConfig *conf) 74 | { 75 | if(conf) 76 | { 77 | orbisPadConf=conf; 78 | orbispad_external_conf=1; 79 | return orbisPadConf->orbispad_initialized; 80 | } 81 | 82 | return 0; 83 | } 84 | int orbisPadInitWithConf(OrbisPadConfig *conf) 85 | { 86 | int ret; 87 | ret=orbisPadSetConf(conf); 88 | if(ret) 89 | { 90 | sys_log("liborbisPad already initialized using configuration external\n"); 91 | sys_log("orbispad_initialized=%d\n",orbisPadConf->orbispad_initialized); 92 | sys_log("ready to have a lot of fun...\n"); 93 | return orbisPadConf->orbispad_initialized; 94 | } 95 | else 96 | { 97 | return 0; 98 | } 99 | } 100 | unsigned int orbisPadGetCurrentButtonsPressed() 101 | { 102 | return orbisPadConf->buttonsPressed; 103 | } 104 | void orbisPadSetCurrentButtonsPressed(unsigned int buttons) 105 | { 106 | orbisPadConf->buttonsPressed=buttons; 107 | } 108 | unsigned int orbisPadGetCurrentButtonsReleased() 109 | { 110 | return orbisPadConf->buttonsReleased; 111 | } 112 | void orbisPadSetCurrentButtonsReleased(unsigned int buttons) 113 | { 114 | orbisPadConf->buttonsReleased=buttons; 115 | } 116 | 117 | bool orbisPadGetButtonHold(unsigned int filter) 118 | { 119 | if((orbisPadConf->buttonsHold&filter)==filter) 120 | { 121 | return 1; 122 | } 123 | return 0; 124 | } 125 | bool orbisPadGetButtonPressed(unsigned int filter) 126 | { 127 | if((orbisPadConf->buttonsPressed&filter)==filter) 128 | { 129 | return 1; 130 | } 131 | return 0; 132 | } 133 | bool orbisPadGetButtonReleased(unsigned int filter) 134 | { 135 | if((orbisPadConf->buttonsReleased&filter)==filter) 136 | { 137 | if(~(orbisPadConf->padDataLast->buttons)&filter) 138 | { 139 | return 0; 140 | } 141 | return 1; 142 | } 143 | return 0; 144 | } 145 | int orbisPadUpdate() 146 | { 147 | int ret; 148 | unsigned int actualButtons=0; 149 | unsigned int lastButtons=0; 150 | memcpy(orbisPadConf->padDataLast,orbisPadConf->padDataCurrent,sizeof(ScePadData)); 151 | 152 | ret=scePadReadState(orbisPadConf->padHandle,orbisPadConf->padDataCurrent); 153 | 154 | if(ret==0 && orbisPadConf->padDataCurrent->connected==1) 155 | { 156 | actualButtons=orbisPadConf->padDataCurrent->buttons; 157 | lastButtons=orbisPadConf->padDataLast->buttons; 158 | orbisPadConf->buttonsPressed=(actualButtons)&(~lastButtons); 159 | if(actualButtons!=lastButtons) 160 | { 161 | orbisPadConf->buttonsReleased=(~actualButtons)&(lastButtons); 162 | } 163 | else 164 | { 165 | orbisPadConf->buttonsReleased=0; 166 | 167 | } 168 | orbisPadConf->buttonsHold=actualButtons&lastButtons; 169 | return 0; 170 | 171 | } 172 | else 173 | { 174 | return -1; 175 | } 176 | } 177 | int orbisPadInit() 178 | { 179 | int ret; 180 | 181 | int param=700; 182 | 183 | if(orbisPadCreateConf()==1) 184 | { 185 | return orbisPadConf->orbispad_initialized; 186 | } 187 | if (orbisPadConf->orbispad_initialized==1) 188 | { 189 | sys_log("liborbispad is already initialized!\n"); 190 | return orbisPadConf->orbispad_initialized; 191 | } 192 | ret=sceUserServiceInitialize(¶m); 193 | 194 | 195 | if(ret==0) 196 | { 197 | ret=scePadInit(); 198 | if(ret<0) 199 | { 200 | sys_log("liborbispad scePadInit return error 0x%8x\n",ret); 201 | return -1; 202 | } 203 | sys_log("liborbispad scePadInit return %d\n",ret); 204 | if(ret==0) 205 | { 206 | 207 | ret=sceUserServiceGetInitialUser(&orbisPadConf->userId); 208 | if(ret<0) 209 | { 210 | sys_log("liborbispad sceUserServiceGetInitialUser return error 0x%8x\n",ret); 211 | return -1; 212 | 213 | } 214 | orbisPadConf->padHandle=scePadOpen(orbisPadConf->userId, 0, 0, NULL); 215 | if(orbisPadConf->padHandle<0) 216 | { 217 | sys_log("liborbispad scePadOpen return error 0x%8x\n",orbisPadConf->padHandle); 218 | return -1; 219 | } 220 | sys_log("liborbispad scePadOpen return handle 0x%8x\n",orbisPadConf->padHandle); 221 | if(orbisPadConf->padHandle>0) 222 | { 223 | orbisPadConf->orbispad_initialized=1; 224 | 225 | } 226 | 227 | } 228 | } 229 | 230 | return orbisPadConf->orbispad_initialized; 231 | } 232 | 233 | -------------------------------------------------------------------------------- /portlibs/libpng/source/pngrio.c: -------------------------------------------------------------------------------- 1 | 2 | /* pngrio.c - functions for data input 3 | * 4 | * Last changed in libpng 1.5.0 [January 6, 2011] 5 | * Copyright (c) 1998-2011 Glenn Randers-Pehrson 6 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 | * 9 | * This code is released under the libpng license. 10 | * For conditions of distribution and use, see the disclaimer 11 | * and license in png.h 12 | * 13 | * This file provides a location for all input. Users who need 14 | * special handling are expected to write a function that has the same 15 | * arguments as this and performs a similar function, but that possibly 16 | * has a different input method. Note that you shouldn't change this 17 | * function, but rather write a replacement function and then make 18 | * libpng use it at run time with png_set_read_fn(...). 19 | */ 20 | 21 | #include "pngpriv.h" 22 | 23 | #ifdef PNG_READ_SUPPORTED 24 | 25 | /* Read the data from whatever input you are using. The default routine 26 | * reads from a file pointer. Note that this routine sometimes gets called 27 | * with very small lengths, so you should implement some kind of simple 28 | * buffering if you are using unbuffered reads. This should never be asked 29 | * to read more then 64K on a 16 bit machine. 30 | */ 31 | void /* PRIVATE */ 32 | png_read_data(png_structp png_ptr, png_bytep data, png_size_t length) 33 | { 34 | png_debug1(4, "reading %d bytes", (int)length); 35 | 36 | if (png_ptr->read_data_fn != NULL) 37 | (*(png_ptr->read_data_fn))(png_ptr, data, length); 38 | 39 | else 40 | png_error(png_ptr, "Call to NULL read function"); 41 | } 42 | 43 | #ifdef PNG_STDIO_SUPPORTED 44 | /* This is the function that does the actual reading of data. If you are 45 | * not reading from a standard C stream, you should create a replacement 46 | * read_data function and use it at run time with png_set_read_fn(), rather 47 | * than changing the library. 48 | */ 49 | # ifndef USE_FAR_KEYWORD 50 | void PNGCBAPI 51 | png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) 52 | { 53 | png_size_t check; 54 | 55 | if (png_ptr == NULL) 56 | return; 57 | 58 | /* fread() returns 0 on error, so it is OK to store this in a png_size_t 59 | * instead of an int, which is what fread() actually returns. 60 | */ 61 | check = fread(data, 1, length, (png_FILE_p)png_ptr->io_ptr); 62 | 63 | if (check != length) 64 | png_error(png_ptr, "Read Error"); 65 | } 66 | # else 67 | /* This is the model-independent version. Since the standard I/O library 68 | can't handle far buffers in the medium and small models, we have to copy 69 | the data. 70 | */ 71 | 72 | #define NEAR_BUF_SIZE 1024 73 | #define MIN(a,b) (a <= b ? a : b) 74 | 75 | static void PNGCBAPI 76 | png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length) 77 | { 78 | png_size_t check; 79 | png_byte *n_data; 80 | png_FILE_p io_ptr; 81 | 82 | if (png_ptr == NULL) 83 | return; 84 | 85 | /* Check if data really is near. If so, use usual code. */ 86 | n_data = (png_byte *)CVT_PTR_NOCHECK(data); 87 | io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); 88 | 89 | if ((png_bytep)n_data == data) 90 | { 91 | check = fread(n_data, 1, length, io_ptr); 92 | } 93 | 94 | else 95 | { 96 | png_byte buf[NEAR_BUF_SIZE]; 97 | png_size_t read, remaining, err; 98 | check = 0; 99 | remaining = length; 100 | 101 | do 102 | { 103 | read = MIN(NEAR_BUF_SIZE, remaining); 104 | err = fread(buf, 1, read, io_ptr); 105 | png_memcpy(data, buf, read); /* copy far buffer to near buffer */ 106 | 107 | if (err != read) 108 | break; 109 | 110 | else 111 | check += err; 112 | 113 | data += read; 114 | remaining -= read; 115 | } 116 | while (remaining != 0); 117 | } 118 | 119 | if ((png_uint_32)check != (png_uint_32)length) 120 | png_error(png_ptr, "read Error"); 121 | } 122 | # endif 123 | #endif 124 | 125 | /* This function allows the application to supply a new input function 126 | * for libpng if standard C streams aren't being used. 127 | * 128 | * This function takes as its arguments: 129 | * 130 | * png_ptr - pointer to a png input data structure 131 | * 132 | * io_ptr - pointer to user supplied structure containing info about 133 | * the input functions. May be NULL. 134 | * 135 | * read_data_fn - pointer to a new input function that takes as its 136 | * arguments a pointer to a png_struct, a pointer to 137 | * a location where input data can be stored, and a 32-bit 138 | * unsigned int that is the number of bytes to be read. 139 | * To exit and output any fatal error messages the new write 140 | * function should call png_error(png_ptr, "Error msg"). 141 | * May be NULL, in which case libpng's default function will 142 | * be used. 143 | */ 144 | void PNGAPI 145 | png_set_read_fn(png_structp png_ptr, png_voidp io_ptr, 146 | png_rw_ptr read_data_fn) 147 | { 148 | if (png_ptr == NULL) 149 | return; 150 | 151 | png_ptr->io_ptr = io_ptr; 152 | 153 | #ifdef PNG_STDIO_SUPPORTED 154 | if (read_data_fn != NULL) 155 | png_ptr->read_data_fn = read_data_fn; 156 | 157 | else 158 | png_ptr->read_data_fn = png_default_read_data; 159 | #else 160 | png_ptr->read_data_fn = read_data_fn; 161 | #endif 162 | 163 | /* It is an error to write to a read device */ 164 | if (png_ptr->write_data_fn != NULL) 165 | { 166 | png_ptr->write_data_fn = NULL; 167 | png_warning(png_ptr, 168 | "Can't set both read_data_fn and write_data_fn in the" 169 | " same structure"); 170 | } 171 | 172 | #ifdef PNG_WRITE_FLUSH_SUPPORTED 173 | png_ptr->output_flush_fn = NULL; 174 | #endif 175 | } 176 | #endif /* PNG_READ_SUPPORTED */ 177 | -------------------------------------------------------------------------------- /portlibs/libpng/include/pngdebug.h: -------------------------------------------------------------------------------- 1 | 2 | /* pngdebug.h - Debugging macros for libpng, also used in pngtest.c 3 | * 4 | * Copyright (c) 1998-2011 Glenn Randers-Pehrson 5 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 6 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 7 | * 8 | * Last changed in libpng 1.5.0 [January 6, 2011] 9 | * 10 | * This code is released under the libpng license. 11 | * For conditions of distribution and use, see the disclaimer 12 | * and license in png.h 13 | */ 14 | 15 | /* Define PNG_DEBUG at compile time for debugging information. Higher 16 | * numbers for PNG_DEBUG mean more debugging information. This has 17 | * only been added since version 0.95 so it is not implemented throughout 18 | * libpng yet, but more support will be added as needed. 19 | * 20 | * png_debug[1-2]?(level, message ,arg{0-2}) 21 | * Expands to a statement (either a simple expression or a compound 22 | * do..while(0) statement) that outputs a message with parameter 23 | * substitution if PNG_DEBUG is defined to 2 or more. If PNG_DEBUG 24 | * is undefined, 0 or 1 every png_debug expands to a simple expression 25 | * (actually ((void)0)). 26 | * 27 | * level: level of detail of message, starting at 0. A level 'n' 28 | * message is preceded by 'n' tab characters (not implemented 29 | * on Microsoft compilers unless PNG_DEBUG_FILE is also 30 | * defined, to allow debug DLL compilation with no standard IO). 31 | * message: a printf(3) style text string. A trailing '\n' is added 32 | * to the message. 33 | * arg: 0 to 2 arguments for printf(3) style substitution in message. 34 | */ 35 | #ifndef PNGDEBUG_H 36 | #define PNGDEBUG_H 37 | /* These settings control the formatting of messages in png.c and pngerror.c */ 38 | /* Moved to pngdebug.h at 1.5.0 */ 39 | # ifndef PNG_LITERAL_SHARP 40 | # define PNG_LITERAL_SHARP 0x23 41 | # endif 42 | # ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET 43 | # define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b 44 | # endif 45 | # ifndef PNG_LITERAL_RIGHT_SQUARE_BRACKET 46 | # define PNG_LITERAL_RIGHT_SQUARE_BRACKET 0x5d 47 | # endif 48 | # ifndef PNG_STRING_NEWLINE 49 | # define PNG_STRING_NEWLINE "\n" 50 | # endif 51 | 52 | #ifdef PNG_DEBUG 53 | # if (PNG_DEBUG > 0) 54 | # if !defined(PNG_DEBUG_FILE) && defined(_MSC_VER) 55 | # include 56 | # if (PNG_DEBUG > 1) 57 | # ifndef _DEBUG 58 | # define _DEBUG 59 | # endif 60 | # ifndef png_debug 61 | # define png_debug(l,m) _RPT0(_CRT_WARN,m PNG_STRING_NEWLINE) 62 | # endif 63 | # ifndef png_debug1 64 | # define png_debug1(l,m,p1) _RPT1(_CRT_WARN,m PNG_STRING_NEWLINE,p1) 65 | # endif 66 | # ifndef png_debug2 67 | # define png_debug2(l,m,p1,p2) \ 68 | _RPT2(_CRT_WARN,m PNG_STRING_NEWLINE,p1,p2) 69 | # endif 70 | # endif 71 | # else /* PNG_DEBUG_FILE || !_MSC_VER */ 72 | # ifndef PNG_STDIO_SUPPORTED 73 | # include /* not included yet */ 74 | # endif 75 | # ifndef PNG_DEBUG_FILE 76 | # define PNG_DEBUG_FILE stderr 77 | # endif /* PNG_DEBUG_FILE */ 78 | 79 | # if (PNG_DEBUG > 1) 80 | /* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on 81 | * non-ISO compilers 82 | */ 83 | # ifdef __STDC__ 84 | # ifndef png_debug 85 | # define png_debug(l,m) \ 86 | do { \ 87 | int num_tabs=l; \ 88 | fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ 89 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ 90 | } while (0) 91 | # endif 92 | # ifndef png_debug1 93 | # define png_debug1(l,m,p1) \ 94 | do { \ 95 | int num_tabs=l; \ 96 | fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ 97 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ 98 | } while (0) 99 | # endif 100 | # ifndef png_debug2 101 | # define png_debug2(l,m,p1,p2) \ 102 | do { \ 103 | int num_tabs=l; \ 104 | fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ 105 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ 106 | } while (0) 107 | # endif 108 | # else /* __STDC __ */ 109 | # ifndef png_debug 110 | # define png_debug(l,m) \ 111 | do { \ 112 | int num_tabs=l; \ 113 | char format[256]; \ 114 | snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ 115 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ 116 | m,PNG_STRING_NEWLINE); \ 117 | fprintf(PNG_DEBUG_FILE,format); \ 118 | } while (0) 119 | # endif 120 | # ifndef png_debug1 121 | # define png_debug1(l,m,p1) \ 122 | do { \ 123 | int num_tabs=l; \ 124 | char format[256]; \ 125 | snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ 126 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ 127 | m,PNG_STRING_NEWLINE); \ 128 | fprintf(PNG_DEBUG_FILE,format,p1); \ 129 | } while (0) 130 | # endif 131 | # ifndef png_debug2 132 | # define png_debug2(l,m,p1,p2) \ 133 | do { \ 134 | int num_tabs=l; \ 135 | char format[256]; \ 136 | snprintf(format,256,"%s%s%s",(num_tabs==1 ? "\t" : \ 137 | (num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))), \ 138 | m,PNG_STRING_NEWLINE); \ 139 | fprintf(PNG_DEBUG_FILE,format,p1,p2); \ 140 | } while (0) 141 | # endif 142 | # endif /* __STDC __ */ 143 | # endif /* (PNG_DEBUG > 1) */ 144 | 145 | # endif /* _MSC_VER */ 146 | # endif /* (PNG_DEBUG > 0) */ 147 | #endif /* PNG_DEBUG */ 148 | #ifndef png_debug 149 | # define png_debug(l, m) ((void)0) 150 | #endif 151 | #ifndef png_debug1 152 | # define png_debug1(l, m, p1) ((void)0) 153 | #endif 154 | #ifndef png_debug2 155 | # define png_debug2(l, m, p1, p2) ((void)0) 156 | #endif 157 | #endif /* PNGDEBUG_H */ 158 | -------------------------------------------------------------------------------- /portlibs/zlib/include/inffixed.h: -------------------------------------------------------------------------------- 1 | /* inffixed.h -- table for decoding fixed codes 2 | * Generated automatically by makefixed(). 3 | */ 4 | 5 | /* WARNING: this file should *not* be used by applications. It 6 | is part of the implementation of the compression library and 7 | is subject to change. Applications should only use zlib.h. 8 | */ 9 | 10 | static const code lenfix[512] = { 11 | {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, 12 | {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, 13 | {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, 14 | {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, 15 | {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, 16 | {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, 17 | {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, 18 | {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, 19 | {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, 20 | {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, 21 | {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, 22 | {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, 23 | {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, 24 | {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, 25 | {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, 26 | {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, 27 | {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, 28 | {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, 29 | {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, 30 | {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, 31 | {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, 32 | {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, 33 | {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, 34 | {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, 35 | {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, 36 | {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, 37 | {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, 38 | {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, 39 | {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, 40 | {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, 41 | {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, 42 | {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, 43 | {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, 44 | {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, 45 | {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, 46 | {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, 47 | {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, 48 | {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, 49 | {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, 50 | {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, 51 | {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, 52 | {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, 53 | {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, 54 | {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, 55 | {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, 56 | {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, 57 | {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, 58 | {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, 59 | {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, 60 | {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, 61 | {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, 62 | {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, 63 | {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, 64 | {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, 65 | {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, 66 | {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, 67 | {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, 68 | {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, 69 | {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, 70 | {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, 71 | {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, 72 | {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, 73 | {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, 74 | {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, 75 | {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, 76 | {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, 77 | {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, 78 | {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, 79 | {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, 80 | {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, 81 | {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, 82 | {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, 83 | {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, 84 | {0,9,255} 85 | }; 86 | 87 | static const code distfix[32] = { 88 | {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, 89 | {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, 90 | {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, 91 | {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, 92 | {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, 93 | {22,5,193},{64,5,0} 94 | }; 95 | -------------------------------------------------------------------------------- /eboot_plugin/source/eboot_plugin.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | 15 | int x=1280/2; 16 | int y=720/2; 17 | int w=1280/64; 18 | int h=1280/64; 19 | int step=10; 20 | 21 | 22 | int64_t flipArg=0; 23 | int R,G,B; 24 | uint32_t color=0x80ff0000; 25 | int flag=0; 26 | 27 | Orbis2dConfig *conf; 28 | OrbisPadConfig *confPad; 29 | 30 | 31 | void updateController() 32 | { 33 | int ret; 34 | unsigned int buttons=0; 35 | ret=orbisPadUpdate(); 36 | if(ret==0) 37 | { 38 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R2)) 39 | { 40 | sys_log("Combo L2R2 pressed\n"); 41 | buttons=orbisPadGetCurrentButtonsPressed(); 42 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R2); 43 | orbisPadSetCurrentButtonsPressed(buttons); 44 | } 45 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R1) ) 46 | { 47 | sys_log("Combo L1R1 pressed\n"); 48 | buttons=orbisPadGetCurrentButtonsPressed(); 49 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R1); 50 | orbisPadSetCurrentButtonsPressed(buttons); 51 | 52 | } 53 | if(orbisPadGetButtonPressed(ORBISPAD_L1|ORBISPAD_R2) || orbisPadGetButtonHold(ORBISPAD_L1|ORBISPAD_R2)) 54 | { 55 | sys_log("Combo L1R2 pressed\n"); 56 | buttons=orbisPadGetCurrentButtonsPressed(); 57 | buttons&= ~(ORBISPAD_L1|ORBISPAD_R2); 58 | orbisPadSetCurrentButtonsPressed(buttons); 59 | 60 | 61 | } 62 | if(orbisPadGetButtonPressed(ORBISPAD_L2|ORBISPAD_R1) || orbisPadGetButtonHold(ORBISPAD_L2|ORBISPAD_R1) ) 63 | { 64 | sys_log("Combo L2R1 pressed\n"); 65 | buttons=orbisPadGetCurrentButtonsPressed(); 66 | buttons&= ~(ORBISPAD_L2|ORBISPAD_R1); 67 | orbisPadSetCurrentButtonsPressed(buttons); 68 | 69 | } 70 | if(orbisPadGetButtonPressed(ORBISPAD_UP) || orbisPadGetButtonHold(ORBISPAD_UP)) 71 | { 72 | sys_log("Up pressed\n"); 73 | 74 | if(y-step>=0) 75 | { 76 | y=y-step; 77 | } 78 | else 79 | { 80 | y=0; 81 | } 82 | } 83 | if(orbisPadGetButtonPressed(ORBISPAD_DOWN) || orbisPadGetButtonHold(ORBISPAD_DOWN)) 84 | { 85 | sys_log("Down pressed\n"); 86 | 87 | if(y+stepheight-1) 88 | { 89 | y=y+step; 90 | } 91 | else 92 | { 93 | y=conf->height-1-step; 94 | } 95 | } 96 | if(orbisPadGetButtonPressed(ORBISPAD_RIGHT) || orbisPadGetButtonHold(ORBISPAD_RIGHT)) 97 | { 98 | sys_log("Right pressed\n"); 99 | 100 | if(x+stepwidth-1) 101 | { 102 | x=x+step; 103 | } 104 | else 105 | { 106 | x=conf->width-1-step; 107 | } 108 | } 109 | if(orbisPadGetButtonPressed(ORBISPAD_LEFT) || orbisPadGetButtonHold(ORBISPAD_LEFT)) 110 | { 111 | sys_log("Left pressed\n"); 112 | 113 | if(x-step>=0) 114 | { 115 | x=x-step; 116 | } 117 | else 118 | { 119 | x=0; 120 | } 121 | } 122 | if(orbisPadGetButtonPressed(ORBISPAD_TRIANGLE)) 123 | { 124 | sys_log("Triangle pressed exit\n"); 125 | 126 | flag=0; 127 | 128 | } 129 | if(orbisPadGetButtonPressed(ORBISPAD_CIRCLE)) 130 | { 131 | sys_log("Circle pressed reset position and color red\n"); 132 | x=1280/2; 133 | y=720/2; 134 | color=0x80ff0000; 135 | orbisAudioResume(0); 136 | 137 | } 138 | if(orbisPadGetButtonPressed(ORBISPAD_CROSS)) 139 | { 140 | sys_log("Cross pressed rand color\n"); 141 | R=rand()%256; 142 | G=rand()%256; 143 | B=rand()%256; 144 | color=0x80000000|R<<16|G<<8|B; 145 | orbisAudioStop(); 146 | 147 | } 148 | if(orbisPadGetButtonPressed(ORBISPAD_SQUARE)) 149 | { 150 | sys_log("Square pressed\n"); 151 | orbisAudioPause(0); 152 | 153 | } 154 | if(orbisPadGetButtonPressed(ORBISPAD_L1)) 155 | { 156 | sys_log("L1 pressed\n"); 157 | 158 | } 159 | if(orbisPadGetButtonPressed(ORBISPAD_L2)) 160 | { 161 | sys_log("L2 pressed\n"); 162 | 163 | } 164 | if(orbisPadGetButtonPressed(ORBISPAD_R1)) 165 | { 166 | sys_log("R1 pressed\n"); 167 | 168 | } 169 | if(orbisPadGetButtonPressed(ORBISPAD_R2)) 170 | { 171 | sys_log("R2 pressed\n"); 172 | 173 | } 174 | 175 | 176 | } 177 | } 178 | void finishApp() 179 | { 180 | orbisAudioFinish(); 181 | orbisPadFinish(); 182 | 183 | orbis2dFinish(); 184 | 185 | ps4LinkFinish(); 186 | 187 | } 188 | void initApp() 189 | { 190 | int ret; 191 | 192 | ret=ps4LinkInit("192.168.1.3",0x4711,0x4712,0x4712,DEBUG); 193 | if(!ret) 194 | { 195 | ps4LinkFinish(); 196 | return; 197 | } 198 | while(!ps4LinkRequestsIsConnected()) 199 | { 200 | 201 | } 202 | debugNetPrintf(DEBUG,"[PS4LINK] Initialized and connected from pc/mac ready to receive commands\n"); 203 | 204 | //hide playroom splash 205 | sceSystemServiceHideSplashScreen(); 206 | 207 | 208 | ret=orbisPadInit(); 209 | 210 | if(ret==1) 211 | { 212 | 213 | confPad=orbisPadGetConf(); 214 | 215 | ret=orbis2dInit(); 216 | if(ret==1) 217 | { 218 | conf=orbis2dGetConf(); 219 | flag=1; 220 | ret=orbisAudioInit(); 221 | if(ret==1) 222 | { 223 | ret=orbisAudioInitChannel(ORBISAUDIO_CHANNEL_MAIN,1024,48000,ORBISAUDIO_FORMAT_S16_STEREO); 224 | } 225 | } 226 | } 227 | 228 | } 229 | int main(uint64_t stackbase, uint64_t othervalue) 230 | { 231 | int ret; 232 | 233 | initApp(); 234 | 235 | Mod_Init(0); 236 | Mod_Load("host0:zweifeld.mod"); 237 | Mod_Play(); 238 | orbisAudioResume(0); 239 | 240 | 241 | 242 | 243 | while(flag) 244 | { 245 | //capture pad data and populate positions 246 | // X random color 247 | // O reset to center position and red color 248 | // /\ to exit 249 | // dpad move rectangle 250 | updateController(); 251 | 252 | 253 | //wait for current display buffer 254 | orbis2dStartDrawing(); 255 | 256 | // clear with background (default white) to the current display buffer 257 | orbis2dClearBuffer(); 258 | 259 | //default red is here press X to random color 260 | orbis2dDrawRectColor(x,w,y,h,color); 261 | 262 | //flush and flip 263 | orbis2dFinishDrawing(flipArg); 264 | 265 | //swap buffers 266 | orbis2dSwapBuffers(); 267 | flipArg++; 268 | } 269 | 270 | orbisAudioResume(0); 271 | Mod_End(); 272 | //wait for current display buffer 273 | orbis2dStartDrawing(); 274 | 275 | // clear with background (default white) to the current display buffer 276 | orbis2dClearBuffer(); 277 | 278 | //flush and flip 279 | orbis2dFinishDrawing(flipArg); 280 | 281 | //swap buffers 282 | orbis2dSwapBuffers(); 283 | 284 | finishApp(); 285 | 286 | exit(0); 287 | 288 | return 0; 289 | } 290 | -------------------------------------------------------------------------------- /portlibs/zlib/include/inflate.h: -------------------------------------------------------------------------------- 1 | /* inflate.h -- internal inflate state definition 2 | * Copyright (C) 1995-2009 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* define NO_GZIP when compiling if you want to disable gzip header and 12 | trailer decoding by inflate(). NO_GZIP would be used to avoid linking in 13 | the crc code when it is not needed. For shared libraries, gzip decoding 14 | should be left enabled. */ 15 | #ifndef NO_GZIP 16 | # define GUNZIP 17 | #endif 18 | 19 | /* Possible inflate modes between inflate() calls */ 20 | typedef enum { 21 | HEAD, /* i: waiting for magic header */ 22 | FLAGS, /* i: waiting for method and flags (gzip) */ 23 | TIME, /* i: waiting for modification time (gzip) */ 24 | OS, /* i: waiting for extra flags and operating system (gzip) */ 25 | EXLEN, /* i: waiting for extra length (gzip) */ 26 | EXTRA, /* i: waiting for extra bytes (gzip) */ 27 | NAME, /* i: waiting for end of file name (gzip) */ 28 | COMMENT, /* i: waiting for end of comment (gzip) */ 29 | HCRC, /* i: waiting for header crc (gzip) */ 30 | DICTID, /* i: waiting for dictionary check value */ 31 | DICT, /* waiting for inflateSetDictionary() call */ 32 | TYPE, /* i: waiting for type bits, including last-flag bit */ 33 | TYPEDO, /* i: same, but skip check to exit inflate on new block */ 34 | STORED, /* i: waiting for stored size (length and complement) */ 35 | COPY_, /* i/o: same as COPY below, but only first time in */ 36 | COPY, /* i/o: waiting for input or output to copy stored block */ 37 | TABLE, /* i: waiting for dynamic block table lengths */ 38 | LENLENS, /* i: waiting for code length code lengths */ 39 | CODELENS, /* i: waiting for length/lit and distance code lengths */ 40 | LEN_, /* i: same as LEN below, but only first time in */ 41 | LEN, /* i: waiting for length/lit/eob code */ 42 | LENEXT, /* i: waiting for length extra bits */ 43 | DIST, /* i: waiting for distance code */ 44 | DISTEXT, /* i: waiting for distance extra bits */ 45 | MATCH, /* o: waiting for output space to copy string */ 46 | LIT, /* o: waiting for output space to write literal */ 47 | CHECK, /* i: waiting for 32-bit check value */ 48 | LENGTH, /* i: waiting for 32-bit length (gzip) */ 49 | DONE, /* finished check, done -- remain here until reset */ 50 | BAD, /* got a data error -- remain here until reset */ 51 | MEM, /* got an inflate() memory error -- remain here until reset */ 52 | SYNC /* looking for synchronization bytes to restart inflate() */ 53 | } inflate_mode; 54 | 55 | /* 56 | State transitions between above modes - 57 | 58 | (most modes can go to BAD or MEM on error -- not shown for clarity) 59 | 60 | Process header: 61 | HEAD -> (gzip) or (zlib) or (raw) 62 | (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME -> COMMENT -> 63 | HCRC -> TYPE 64 | (zlib) -> DICTID or TYPE 65 | DICTID -> DICT -> TYPE 66 | (raw) -> TYPEDO 67 | Read deflate blocks: 68 | TYPE -> TYPEDO -> STORED or TABLE or LEN_ or CHECK 69 | STORED -> COPY_ -> COPY -> TYPE 70 | TABLE -> LENLENS -> CODELENS -> LEN_ 71 | LEN_ -> LEN 72 | Read deflate codes in fixed or dynamic block: 73 | LEN -> LENEXT or LIT or TYPE 74 | LENEXT -> DIST -> DISTEXT -> MATCH -> LEN 75 | LIT -> LEN 76 | Process trailer: 77 | CHECK -> LENGTH -> DONE 78 | */ 79 | 80 | /* state maintained between inflate() calls. Approximately 10K bytes. */ 81 | struct inflate_state { 82 | inflate_mode mode; /* current inflate mode */ 83 | int last; /* true if processing last block */ 84 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ 85 | int havedict; /* true if dictionary provided */ 86 | int flags; /* gzip header method and flags (0 if zlib) */ 87 | unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */ 88 | unsigned long check; /* protected copy of check value */ 89 | unsigned long total; /* protected copy of output count */ 90 | gz_headerp head; /* where to save gzip header information */ 91 | /* sliding window */ 92 | unsigned wbits; /* log base 2 of requested window size */ 93 | unsigned wsize; /* window size or zero if not using window */ 94 | unsigned whave; /* valid bytes in the window */ 95 | unsigned wnext; /* window write index */ 96 | unsigned char FAR *window; /* allocated sliding window, if needed */ 97 | /* bit accumulator */ 98 | unsigned long hold; /* input bit accumulator */ 99 | unsigned bits; /* number of bits in "in" */ 100 | /* for string and stored block copying */ 101 | unsigned length; /* literal or length of data to copy */ 102 | unsigned offset; /* distance back to copy string from */ 103 | /* for table and code decoding */ 104 | unsigned extra; /* extra bits needed */ 105 | /* fixed and dynamic code tables */ 106 | code const FAR *lencode; /* starting table for length/literal codes */ 107 | code const FAR *distcode; /* starting table for distance codes */ 108 | unsigned lenbits; /* index bits for lencode */ 109 | unsigned distbits; /* index bits for distcode */ 110 | /* dynamic table building */ 111 | unsigned ncode; /* number of code length code lengths */ 112 | unsigned nlen; /* number of length code lengths */ 113 | unsigned ndist; /* number of distance code lengths */ 114 | unsigned have; /* number of code lengths in lens[] */ 115 | code FAR *next; /* next available space in codes[] */ 116 | unsigned short lens[320]; /* temporary storage for code lengths */ 117 | unsigned short work[288]; /* work area for code table building */ 118 | code codes[ENOUGH]; /* space for code tables */ 119 | int sane; /* if false, allow invalid distance too far */ 120 | int back; /* bits back of last unprocessed length/lit */ 121 | unsigned was; /* initial length of match */ 122 | }; 123 | -------------------------------------------------------------------------------- /orbislink/libelfloader/include/elfloader.h: -------------------------------------------------------------------------------- 1 | #ifndef ElfLoader_H 2 | #define ElfLoader_H 3 | 4 | #include 5 | 6 | /* Warning, written for 64bit systems - need to adapt stuff for 32 */ 7 | #if ULONG_MAX == 0xffffffff 8 | #define __ELF_WORD_SIZE 32 9 | #error Elf loader currently does not support 32 bit arches 10 | #else 11 | #define __ELF_WORD_SIZE 64 12 | #endif 13 | 14 | #include 15 | 16 | /* Defines which may be missing*/ 17 | 18 | #ifndef __ElfN 19 | #define __ElfNC_(x,y) x ## y 20 | #define __ElfNC(x,y) __ElfNC_(x,y) 21 | #define __ElfN(x) __ElfNC(__ElfNC(__ElfNC(Elf,__ELF_WORD_SIZE),_),x) 22 | #endif 23 | #ifndef __ELFN 24 | #define __ELFNC_(x,y) x ## y 25 | #define __ELFNC(x,y) __ElfNC_(x,y) 26 | #define __ELFN(x) __ElfNC(__ElfNC(__ElfNC(ELF,__ELF_WORD_SIZE),_),x) 27 | #endif 28 | 29 | #ifndef R_X86_64_JMP_SLOT 30 | #define R_X86_64_JMP_SLOT 7 31 | #endif 32 | 33 | #ifndef IS_ELF 34 | #define IS_ELF(ehdr) \ 35 | ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \ 36 | (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \ 37 | (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \ 38 | (ehdr).e_ident[EI_MAG3] == ELFMAG3) 39 | #endif 40 | 41 | /* Neat Types */ 42 | 43 | typedef __ElfN(Ehdr) ElfHeader; 44 | typedef __ElfN(Phdr) ElfSegment; 45 | typedef __ElfN(Shdr) ElfSection; 46 | typedef __ElfN(Sym) ElfSymbol; 47 | //typedef Elf_Rel ElfRelocation; 48 | typedef __ElfN(Rela) ElfAddendRelocation; 49 | typedef __ElfN(Dyn) ElfDynamic; 50 | 51 | /* Type */ 52 | 53 | typedef struct Elf Elf; 54 | 55 | /* Enums*/ 56 | 57 | typedef enum 58 | { 59 | ELF_LOADER_RETURN_OK = 0, 60 | ELF_LOADER_RETURN_ELF_NULL = -1, 61 | ELF_LOADER_RETURN_NO_WRITABLE_MEMORY = -2, 62 | ELF_LOADER_RETURN_NO_EXECUTABLE_MEMORY = -3, 63 | ELF_LOADER_RETURN_NO_ELF = -4, 64 | ELF_LOADER_RETURN_UNKNOWN_RELOCATION = -5, 65 | ELF_LOADER_RETURN_ADDRESS_NOT_FOUND = -6, 66 | ELF_LOADER_RETURN_NO_SECTIONS_OR_SEGMENTS = -7, 67 | ELF_LOADER_RETURN_IS_NOT_LOADABLE = -8 68 | } 69 | ElfLoaderReturn; 70 | 71 | typedef enum 72 | { 73 | ELF_SECTION_ATTRIBUTE_NONE = 0, 74 | ELF_SECTION_ATTRIBUTE_NAME, 75 | ELF_SECTION_ATTRIBUTE_TYPE, 76 | ELF_SECTION_ATTRIBUTE_FLAGS, 77 | ELF_SECTION_ATTRIBUTE_ADDRESS, 78 | ELF_SECTION_ATTRIBUTE_OFFSET, 79 | ELF_SECTION_ATTRIBUTE_SIZE, 80 | ELF_SECTION_ATTRIBUTE_LINK, 81 | ELF_SECTION_ATTRIBUTE_INFO, 82 | ELF_SECTION_ATTRIBUTE_MEMORY_ALIGNMENT, 83 | ELF_SECTION_ATTRIBUTE_ENTRY_SIZE, 84 | } 85 | ElfSectionAttribute; 86 | 87 | typedef enum 88 | { 89 | ELF_SEGMENT_ATTRIBUTE_NONE = 0, 90 | ELF_SEGMENT_ATTRIBUTE_TYPE, 91 | ELF_SEGMENT_ATTRIBUTE_FLAGS, 92 | ELF_SEGMENT_ATTRIBUTE_OFFSET, 93 | ELF_SEGMENT_ATTRIBUTE_VIRTUAL_ADDRESS, 94 | ELF_SEGMENT_ATTRIBUTE_PHYSICAL_ADDRESS, 95 | ELF_SEGMENT_ATTRIBUTE_FILE_SIZE, 96 | ELF_SEGMENT_ATTRIBUTE_MEMORY_SIZE, 97 | ELF_SEGMENT_ATTRIBUTE_ALIGNMENT, 98 | } 99 | ElfSegmentAttribute; 100 | 101 | typedef enum 102 | { 103 | ELF_DYNAMIC_ATTRIBUTE_NONE = 0, 104 | ELF_DYNAMIC_ATTRIBUTE_TAG, 105 | ELF_DYNAMIC_ATTRIBUTE_VALUE, 106 | ELF_DYNAMIC_ATTRIBUTE_POINTER 107 | } 108 | ElfDynamicAttribute; 109 | 110 | typedef enum 111 | { 112 | ELF_RELOCATION_ATTRIBUTE_NONE = 0, 113 | ELF_RELOCATION_ATTRIBUTE_OFFSET, 114 | ELF_RELOCATION_ATTRIBUTE_INFO 115 | } 116 | ElfRelocationAttribute; 117 | 118 | typedef enum 119 | { 120 | ELF_ADDEND_RELOCATION_ATTRIBUTE_NONE = 0, 121 | ELF_ADDEND_RELOCATION_ATTRIBUTE_OFFSET, 122 | ELF_ADDEND_RELOCATION_ATTRIBUTE_INFO, 123 | ELF_ADDEND_RELOCATION_ATTRIBUTE_ADDEND 124 | } 125 | ElfAddendRelocationAttribute; 126 | 127 | typedef enum 128 | { 129 | ELF_SYMBOL_ATTRIBUTE_NONE = 0, 130 | ELF_SYMBOL_ATTRIBUTE_NAME, 131 | ELF_SYMBOL_ATTRIBUTE_INFO, 132 | ELF_SYMBOL_ATTRIBUTE_UNUSED, 133 | ELF_SYMBOL_ATTRIBUTE_SECTION_INDEX, 134 | ELF_SYMBOL_ATTRIBUTE_VALUE, 135 | ELF_SYMBOL_ATTRIBUTE_SIZE, 136 | } 137 | ElfSymbolAttribute; 138 | 139 | /* --- inlined getters FIXME: Hint inline */ 140 | 141 | ElfHeader *elfHeader(Elf *elf); 142 | size_t elfGetSize(Elf *elf); 143 | uint8_t *elfGetData(Elf *elf); 144 | 145 | uint8_t elfIsElf(Elf *elf); 146 | uint8_t elfClass(Elf *elf); 147 | uint8_t elfEncoding(Elf *elf); 148 | uint8_t elfVersion(Elf *elf); 149 | uint8_t elfABI(Elf *elf); 150 | uint64_t elfEntry(Elf *elf); 151 | 152 | uint64_t elfLargestAlignment(Elf *elf); 153 | uint64_t elfMemorySize(Elf *elf); 154 | 155 | uint64_t elfSectionAttribute(ElfSection *elfSection, ElfSectionAttribute attribute); 156 | ElfSection *elfSections(Elf *elf, uint16_t *size, uint16_t *length); 157 | ElfSection *elfSection(Elf *elf, uint16_t *index, ElfSectionAttribute attribute, uint64_t value); 158 | 159 | uint64_t elfSegmentAttribute(ElfSegment *elfSegment, ElfSegmentAttribute attribute); 160 | ElfSegment *elfSegments(Elf *elf, uint16_t *size, uint16_t *length); 161 | ElfSegment *elfSegment(Elf *elf, uint16_t *index, ElfSegmentAttribute attribute, uint64_t value); 162 | 163 | /* dynamic (if exists) */ 164 | 165 | uint64_t elfDynamicAttribute(ElfDynamic *elfDynamic, ElfDynamicAttribute attribute); 166 | ElfDynamic *elfDynamics(Elf *elf, uint16_t *size, uint16_t *length); 167 | ElfDynamic *elfDynamic(Elf *elf, uint16_t *index, ElfDynamicAttribute attribute, uint64_t value); 168 | ElfDynamic *elfLoadedDynamics(Elf *elf, uint16_t *size, uint16_t *length); 169 | ElfDynamic *elfLoadedDynamic(Elf *elf, uint16_t *index, ElfDynamicAttribute attribute, uint64_t value); 170 | 171 | /* specifics (if exists) */ 172 | 173 | char *elfSectionStrings(Elf *elf, uint64_t *size); 174 | char *elfStringFromIndex(char *mem, uint64_t size, uint32_t index); 175 | uint32_t elfStringToIndex(char *mem, uint64_t size, char *str); 176 | char *elfStringFromOffset(char *mem, uint64_t size, uint32_t index); 177 | uint32_t elfStringToOffset(char *mem, uint64_t size, char *str); 178 | 179 | ElfSection *elfSectionByName(Elf *elf, char *name); 180 | 181 | uint64_t elfAddendRelocationAttribute(ElfAddendRelocation *elfAddendRelocation, ElfAddendRelocationAttribute attribute); 182 | ElfAddendRelocation *elfAddendRelocations(Elf *elf, char *name, uint16_t *size, uint16_t *length); 183 | //ElfAddendRelocation *elfAddendRelocation(Elf *elf, char *name, uint16_t *index, ElfAddendRelocationAttribute attribute, uint64_t value); 184 | 185 | uint32_t elfRelocationSymbol(uint64_t info); 186 | uint32_t elfRelocationType(uint64_t info); 187 | 188 | /*relocs here*/ 189 | 190 | uint64_t elfSymbolAttribute(ElfSymbol *elfSymbol, ElfSymbolAttribute attribute); 191 | ElfSymbol *elfSymbols(Elf *elf, char *name, uint16_t *size, uint16_t *length); 192 | //ElfSymbol *elfSymbol(Elf *elf, char *name, uint16_t *index, ElfSymbolAttribute attribute, uint64_t value); 193 | 194 | uint8_t elfSymbolType(uint8_t info); 195 | uint8_t elfSymbolBind(uint8_t info); 196 | 197 | /* --- actions */ 198 | 199 | Elf *elfCreate(void *data, uint64_t size); 200 | Elf *elfCreateLocal(void *elfl, void *data, size_t size); 201 | Elf *elfCreateLocalUnchecked(void *elfl, void *data, size_t size); 202 | void *elfDestroy(Elf *elf); 203 | void elfDestroyAndFree(Elf *elf); 204 | 205 | /* --- loader --- */ 206 | 207 | int elfLoaderIsLoadable(Elf *elf); 208 | int elfLoaderInstantiate(Elf *elf, void *memory); 209 | int elfLoaderRelocate(Elf *elf, void *writable, void *executable); 210 | int elfLoaderLoad(Elf *elf, void *writable, void *executable); 211 | int elfLoaderLoadKernel(Elf *elf, void *writable, void *executable); 212 | 213 | #endif 214 | -------------------------------------------------------------------------------- /portlibs/libpng/include/pnglibconf.h: -------------------------------------------------------------------------------- 1 | 2 | /* libpng STANDARD API DEFINITION */ 3 | 4 | /* pnglibconf.h - library build configuration */ 5 | 6 | /* Libpng 1.5.10 - March 29, 2012 */ 7 | 8 | /* Copyright (c) 1998-2012 Glenn Randers-Pehrson */ 9 | 10 | /* This code is released under the libpng license. */ 11 | /* For conditions of distribution and use, see the disclaimer */ 12 | /* and license in png.h */ 13 | 14 | /* pnglibconf.h */ 15 | /* Derived from: scripts/pnglibconf.dfa */ 16 | /* If you edit this file by hand you must obey the rules expressed in */ 17 | /* pnglibconf.dfa with respect to the dependencies between the following */ 18 | /* symbols. It is much better to generate a new file using */ 19 | /* scripts/libpngconf.mak */ 20 | 21 | #ifndef PNGLCONF_H 22 | #define PNGLCONF_H 23 | /* settings */ 24 | #define PNG_API_RULE 0 25 | #define PNG_CALLOC_SUPPORTED 26 | #define PNG_COST_SHIFT 3 27 | #define PNG_DEFAULT_READ_MACROS 1 28 | #define PNG_GAMMA_THRESHOLD_FIXED 5000 29 | #define PNG_MAX_GAMMA_8 11 30 | #define PNG_QUANTIZE_BLUE_BITS 5 31 | #define PNG_QUANTIZE_GREEN_BITS 5 32 | #define PNG_QUANTIZE_RED_BITS 5 33 | #define PNG_sCAL_PRECISION 5 34 | #define PNG_WEIGHT_SHIFT 8 35 | #define PNG_ZBUF_SIZE 8192 36 | /* end of settings */ 37 | /* options */ 38 | #define PNG_16BIT_SUPPORTED 39 | #define PNG_ALIGN_MEMORY_SUPPORTED 40 | #define PNG_BENIGN_ERRORS_SUPPORTED 41 | #define PNG_bKGD_SUPPORTED 42 | #define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED 43 | #define PNG_CHECK_cHRM_SUPPORTED 44 | #define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED 45 | #define PNG_cHRM_SUPPORTED 46 | #define PNG_CONSOLE_IO_SUPPORTED 47 | #define PNG_CONVERT_tIME_SUPPORTED 48 | #define PNG_EASY_ACCESS_SUPPORTED 49 | /*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ 50 | #define PNG_ERROR_TEXT_SUPPORTED 51 | #define PNG_FIXED_POINT_SUPPORTED 52 | #define PNG_FLOATING_ARITHMETIC_SUPPORTED 53 | #define PNG_FLOATING_POINT_SUPPORTED 54 | #define PNG_gAMA_SUPPORTED 55 | #define PNG_HANDLE_AS_UNKNOWN_SUPPORTED 56 | #define PNG_hIST_SUPPORTED 57 | #define PNG_iCCP_SUPPORTED 58 | #define PNG_INCH_CONVERSIONS_SUPPORTED 59 | #define PNG_INFO_IMAGE_SUPPORTED 60 | #define PNG_IO_STATE_SUPPORTED 61 | #define PNG_iTXt_SUPPORTED 62 | #define PNG_MNG_FEATURES_SUPPORTED 63 | #define PNG_oFFs_SUPPORTED 64 | #define PNG_pCAL_SUPPORTED 65 | #define PNG_pHYs_SUPPORTED 66 | #define PNG_POINTER_INDEXING_SUPPORTED 67 | #define PNG_PROGRESSIVE_READ_SUPPORTED 68 | #define PNG_READ_16BIT_SUPPORTED 69 | #define PNG_READ_ALPHA_MODE_SUPPORTED 70 | #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED 71 | #define PNG_READ_BACKGROUND_SUPPORTED 72 | #define PNG_READ_BGR_SUPPORTED 73 | #define PNG_READ_bKGD_SUPPORTED 74 | #define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED 75 | #define PNG_READ_cHRM_SUPPORTED 76 | #define PNG_READ_COMPOSITE_NODIV_SUPPORTED 77 | #define PNG_READ_COMPRESSED_TEXT_SUPPORTED 78 | #define PNG_READ_EXPAND_16_SUPPORTED 79 | #define PNG_READ_EXPAND_SUPPORTED 80 | #define PNG_READ_FILLER_SUPPORTED 81 | #define PNG_READ_gAMA_SUPPORTED 82 | #define PNG_READ_GAMMA_SUPPORTED 83 | #define PNG_READ_GRAY_TO_RGB_SUPPORTED 84 | #define PNG_READ_hIST_SUPPORTED 85 | #define PNG_READ_iCCP_SUPPORTED 86 | #define PNG_READ_INTERLACING_SUPPORTED 87 | #define PNG_READ_INT_FUNCTIONS_SUPPORTED 88 | #define PNG_READ_INVERT_ALPHA_SUPPORTED 89 | #define PNG_READ_INVERT_SUPPORTED 90 | #define PNG_READ_iTXt_SUPPORTED 91 | #define PNG_READ_oFFs_SUPPORTED 92 | #define PNG_READ_OPT_PLTE_SUPPORTED 93 | #define PNG_READ_PACK_SUPPORTED 94 | #define PNG_READ_PACKSWAP_SUPPORTED 95 | #define PNG_READ_pCAL_SUPPORTED 96 | #define PNG_READ_pHYs_SUPPORTED 97 | #define PNG_READ_QUANTIZE_SUPPORTED 98 | #define PNG_READ_RGB_TO_GRAY_SUPPORTED 99 | #define PNG_READ_sBIT_SUPPORTED 100 | #define PNG_READ_SCALE_16_TO_8_SUPPORTED 101 | #define PNG_READ_sCAL_SUPPORTED 102 | #define PNG_READ_SHIFT_SUPPORTED 103 | #define PNG_READ_sPLT_SUPPORTED 104 | #define PNG_READ_sRGB_SUPPORTED 105 | #define PNG_READ_STRIP_16_TO_8_SUPPORTED 106 | #define PNG_READ_STRIP_ALPHA_SUPPORTED 107 | #define PNG_READ_SUPPORTED 108 | #define PNG_READ_SWAP_ALPHA_SUPPORTED 109 | #define PNG_READ_SWAP_SUPPORTED 110 | #define PNG_READ_tEXt_SUPPORTED 111 | #define PNG_READ_TEXT_SUPPORTED 112 | #define PNG_READ_tIME_SUPPORTED 113 | #define PNG_READ_TRANSFORMS_SUPPORTED 114 | #define PNG_READ_tRNS_SUPPORTED 115 | #define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED 116 | #define PNG_READ_USER_CHUNKS_SUPPORTED 117 | #define PNG_READ_USER_TRANSFORM_SUPPORTED 118 | #define PNG_READ_zTXt_SUPPORTED 119 | #define PNG_SAVE_INT_32_SUPPORTED 120 | #define PNG_sBIT_SUPPORTED 121 | #define PNG_sCAL_SUPPORTED 122 | #define PNG_SEQUENTIAL_READ_SUPPORTED 123 | #define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED 124 | #define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED 125 | #define PNG_SETJMP_SUPPORTED 126 | #define PNG_SET_USER_LIMITS_SUPPORTED 127 | #define PNG_sPLT_SUPPORTED 128 | #define PNG_sRGB_SUPPORTED 129 | #define PNG_STDIO_SUPPORTED 130 | #define PNG_tEXt_SUPPORTED 131 | #define PNG_TEXT_SUPPORTED 132 | #define PNG_TIME_RFC1123_SUPPORTED 133 | #define PNG_tIME_SUPPORTED 134 | #define PNG_tRNS_SUPPORTED 135 | #define PNG_UNKNOWN_CHUNKS_SUPPORTED 136 | #define PNG_USER_CHUNKS_SUPPORTED 137 | #define PNG_USER_LIMITS_SUPPORTED 138 | #define PNG_USER_MEM_SUPPORTED 139 | #define PNG_USER_TRANSFORM_INFO_SUPPORTED 140 | #define PNG_USER_TRANSFORM_PTR_SUPPORTED 141 | #define PNG_WARNINGS_SUPPORTED 142 | #define PNG_WRITE_16BIT_SUPPORTED 143 | #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED 144 | #define PNG_WRITE_BGR_SUPPORTED 145 | #define PNG_WRITE_bKGD_SUPPORTED 146 | #define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED 147 | #define PNG_WRITE_cHRM_SUPPORTED 148 | #define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED 149 | #define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED 150 | #define PNG_WRITE_FILLER_SUPPORTED 151 | #define PNG_WRITE_FILTER_SUPPORTED 152 | #define PNG_WRITE_FLUSH_SUPPORTED 153 | #define PNG_WRITE_gAMA_SUPPORTED 154 | #define PNG_WRITE_hIST_SUPPORTED 155 | #define PNG_WRITE_iCCP_SUPPORTED 156 | #define PNG_WRITE_INTERLACING_SUPPORTED 157 | #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED 158 | #define PNG_WRITE_INVERT_ALPHA_SUPPORTED 159 | #define PNG_WRITE_INVERT_SUPPORTED 160 | #define PNG_WRITE_iTXt_SUPPORTED 161 | #define PNG_WRITE_oFFs_SUPPORTED 162 | #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED 163 | #define PNG_WRITE_PACK_SUPPORTED 164 | #define PNG_WRITE_PACKSWAP_SUPPORTED 165 | #define PNG_WRITE_pCAL_SUPPORTED 166 | #define PNG_WRITE_pHYs_SUPPORTED 167 | #define PNG_WRITE_sBIT_SUPPORTED 168 | #define PNG_WRITE_sCAL_SUPPORTED 169 | #define PNG_WRITE_SHIFT_SUPPORTED 170 | #define PNG_WRITE_sPLT_SUPPORTED 171 | #define PNG_WRITE_sRGB_SUPPORTED 172 | #define PNG_WRITE_SUPPORTED 173 | #define PNG_WRITE_SWAP_ALPHA_SUPPORTED 174 | #define PNG_WRITE_SWAP_SUPPORTED 175 | #define PNG_WRITE_tEXt_SUPPORTED 176 | #define PNG_WRITE_TEXT_SUPPORTED 177 | #define PNG_WRITE_tIME_SUPPORTED 178 | #define PNG_WRITE_TRANSFORMS_SUPPORTED 179 | #define PNG_WRITE_tRNS_SUPPORTED 180 | #define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED 181 | #define PNG_WRITE_USER_TRANSFORM_SUPPORTED 182 | #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED 183 | #define PNG_WRITE_zTXt_SUPPORTED 184 | #define PNG_zTXt_SUPPORTED 185 | /* end of options */ 186 | #endif /* PNGLCONF_H */ 187 | -------------------------------------------------------------------------------- /portlibs/zlib/include/zutil.h: -------------------------------------------------------------------------------- 1 | /* zutil.h -- internal interface and configuration of the compression library 2 | * Copyright (C) 1995-2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* @(#) $Id$ */ 12 | 13 | #ifndef ZUTIL_H 14 | #define ZUTIL_H 15 | 16 | #if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ) 17 | # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) 18 | #else 19 | # define ZLIB_INTERNAL 20 | #endif 21 | 22 | #include "zlib.h" 23 | 24 | #ifdef STDC 25 | # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) 26 | # include 27 | # endif 28 | # include 29 | # include 30 | #endif 31 | 32 | #ifndef local 33 | # define local static 34 | #endif 35 | /* compile with -Dlocal if your debugger can't find static symbols */ 36 | 37 | typedef unsigned char uch; 38 | typedef uch FAR uchf; 39 | typedef unsigned short ush; 40 | typedef ush FAR ushf; 41 | typedef unsigned long ulg; 42 | 43 | extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 44 | /* (size given to avoid silly warnings with Visual C++) */ 45 | 46 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 47 | 48 | #define ERR_RETURN(strm,err) \ 49 | return (strm->msg = (char*)ERR_MSG(err), (err)) 50 | /* To be used only when the state is known to be valid */ 51 | 52 | /* common constants */ 53 | 54 | #ifndef DEF_WBITS 55 | # define DEF_WBITS MAX_WBITS 56 | #endif 57 | /* default windowBits for decompression. MAX_WBITS is for compression only */ 58 | 59 | #if MAX_MEM_LEVEL >= 8 60 | # define DEF_MEM_LEVEL 8 61 | #else 62 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL 63 | #endif 64 | /* default memLevel */ 65 | 66 | #define STORED_BLOCK 0 67 | #define STATIC_TREES 1 68 | #define DYN_TREES 2 69 | /* The three kinds of block type */ 70 | 71 | #define MIN_MATCH 3 72 | #define MAX_MATCH 258 73 | /* The minimum and maximum match lengths */ 74 | 75 | #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 76 | 77 | /* target dependencies */ 78 | 79 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 80 | # define OS_CODE 0x00 81 | # if defined(__TURBOC__) || defined(__BORLANDC__) 82 | # if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 83 | /* Allow compilation with ANSI keywords only enabled */ 84 | void _Cdecl farfree( void *block ); 85 | void *_Cdecl farmalloc( unsigned long nbytes ); 86 | # else 87 | # include 88 | # endif 89 | # else /* MSC or DJGPP */ 90 | # include 91 | # endif 92 | #endif 93 | 94 | #ifdef AMIGA 95 | # define OS_CODE 0x01 96 | #endif 97 | 98 | #if defined(VAXC) || defined(VMS) 99 | # define OS_CODE 0x02 100 | # define F_OPEN(name, mode) \ 101 | fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 102 | #endif 103 | 104 | #if defined(ATARI) || defined(atarist) 105 | # define OS_CODE 0x05 106 | #endif 107 | 108 | #ifdef OS2 109 | # define OS_CODE 0x06 110 | # ifdef M_I86 111 | # include 112 | # endif 113 | #endif 114 | 115 | #if defined(MACOS) || defined(TARGET_OS_MAC) 116 | # define OS_CODE 0x07 117 | # ifndef fdopen 118 | # define fdopen(fd,mode) NULL /* No fdopen() */ 119 | # endif 120 | #endif 121 | 122 | #ifdef TOPS20 123 | # define OS_CODE 0x0a 124 | #endif 125 | 126 | #ifdef WIN32 127 | # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 128 | # define OS_CODE 0x0b 129 | # endif 130 | #endif 131 | 132 | #ifdef __50SERIES /* Prime/PRIMOS */ 133 | # define OS_CODE 0x0f 134 | #endif 135 | 136 | #if defined(_BEOS_) || defined(RISCOS) 137 | # define fdopen(fd,mode) NULL /* No fdopen() */ 138 | #endif 139 | 140 | #if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX 141 | # if defined(_WIN32_WCE) 142 | # define fdopen(fd,mode) NULL /* No fdopen() */ 143 | # ifndef _PTRDIFF_T_DEFINED 144 | typedef int ptrdiff_t; 145 | # define _PTRDIFF_T_DEFINED 146 | # endif 147 | # else 148 | # define fdopen(fd,type) _fdopen(fd,type) 149 | # endif 150 | #endif 151 | 152 | #if defined(__BORLANDC__) 153 | #pragma warn -8004 154 | #pragma warn -8008 155 | #pragma warn -8066 156 | #endif 157 | 158 | /* provide prototypes for these when building zlib without LFS */ 159 | #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 160 | ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); 161 | ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); 162 | #endif 163 | 164 | /* common defaults */ 165 | 166 | #ifndef OS_CODE 167 | # define OS_CODE 0x03 /* assume Unix */ 168 | #endif 169 | 170 | #ifndef F_OPEN 171 | # define F_OPEN(name, mode) fopen((name), (mode)) 172 | #endif 173 | 174 | /* functions */ 175 | 176 | #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) 177 | # ifndef HAVE_VSNPRINTF 178 | # define HAVE_VSNPRINTF 179 | # endif 180 | #endif 181 | #if defined(__CYGWIN__) 182 | # ifndef HAVE_VSNPRINTF 183 | # define HAVE_VSNPRINTF 184 | # endif 185 | #endif 186 | #ifndef HAVE_VSNPRINTF 187 | # ifdef MSDOS 188 | /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), 189 | but for now we just assume it doesn't. */ 190 | # define NO_vsnprintf 191 | # endif 192 | # ifdef __TURBOC__ 193 | # define NO_vsnprintf 194 | # endif 195 | # ifdef WIN32 196 | /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ 197 | # if !defined(vsnprintf) && !defined(NO_vsnprintf) 198 | # if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 ) 199 | # define vsnprintf _vsnprintf 200 | # endif 201 | # endif 202 | # endif 203 | # ifdef __SASC 204 | # define NO_vsnprintf 205 | # endif 206 | #endif 207 | #ifdef VMS 208 | # define NO_vsnprintf 209 | #endif 210 | 211 | #if defined(pyr) 212 | # define NO_MEMCPY 213 | #endif 214 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 215 | /* Use our own functions for small and medium model with MSC <= 5.0. 216 | * You may have to use the same strategy for Borland C (untested). 217 | * The __SC__ check is for Symantec. 218 | */ 219 | # define NO_MEMCPY 220 | #endif 221 | #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 222 | # define HAVE_MEMCPY 223 | #endif 224 | #ifdef HAVE_MEMCPY 225 | # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 226 | # define zmemcpy _fmemcpy 227 | # define zmemcmp _fmemcmp 228 | # define zmemzero(dest, len) _fmemset(dest, 0, len) 229 | # else 230 | # define zmemcpy memcpy 231 | # define zmemcmp memcmp 232 | # define zmemzero(dest, len) memset(dest, 0, len) 233 | # endif 234 | #else 235 | void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 236 | int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 237 | void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); 238 | #endif 239 | 240 | /* Diagnostic functions */ 241 | #ifdef DEBUG 242 | # include 243 | extern int ZLIB_INTERNAL z_verbose; 244 | extern void ZLIB_INTERNAL z_error OF((char *m)); 245 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} 246 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} 247 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} 248 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} 249 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 250 | # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 251 | #else 252 | # define Assert(cond,msg) 253 | # define Trace(x) 254 | # define Tracev(x) 255 | # define Tracevv(x) 256 | # define Tracec(c,x) 257 | # define Tracecv(c,x) 258 | #endif 259 | 260 | 261 | voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, 262 | unsigned size)); 263 | void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); 264 | 265 | #define ZALLOC(strm, items, size) \ 266 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) 267 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 268 | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 269 | 270 | #endif /* ZUTIL_H */ 271 | -------------------------------------------------------------------------------- /portlibs/zlib/source/zutil.c: -------------------------------------------------------------------------------- 1 | /* zutil.c -- target dependent utility functions for the compression library 2 | * Copyright (C) 1995-2005, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #include "zutil.h" 9 | 10 | #ifndef NO_DUMMY_DECL 11 | struct internal_state {int dummy;}; /* for buggy compilers */ 12 | #endif 13 | 14 | const char * const z_errmsg[10] = { 15 | "need dictionary", /* Z_NEED_DICT 2 */ 16 | "stream end", /* Z_STREAM_END 1 */ 17 | "", /* Z_OK 0 */ 18 | "file error", /* Z_ERRNO (-1) */ 19 | "stream error", /* Z_STREAM_ERROR (-2) */ 20 | "data error", /* Z_DATA_ERROR (-3) */ 21 | "insufficient memory", /* Z_MEM_ERROR (-4) */ 22 | "buffer error", /* Z_BUF_ERROR (-5) */ 23 | "incompatible version",/* Z_VERSION_ERROR (-6) */ 24 | ""}; 25 | 26 | 27 | const char * ZEXPORT zlibVersion() 28 | { 29 | return ZLIB_VERSION; 30 | } 31 | 32 | uLong ZEXPORT zlibCompileFlags() 33 | { 34 | uLong flags; 35 | 36 | flags = 0; 37 | switch ((int)(sizeof(uInt))) { 38 | case 2: break; 39 | case 4: flags += 1; break; 40 | case 8: flags += 2; break; 41 | default: flags += 3; 42 | } 43 | switch ((int)(sizeof(uLong))) { 44 | case 2: break; 45 | case 4: flags += 1 << 2; break; 46 | case 8: flags += 2 << 2; break; 47 | default: flags += 3 << 2; 48 | } 49 | switch ((int)(sizeof(voidpf))) { 50 | case 2: break; 51 | case 4: flags += 1 << 4; break; 52 | case 8: flags += 2 << 4; break; 53 | default: flags += 3 << 4; 54 | } 55 | switch ((int)(sizeof(z_off_t))) { 56 | case 2: break; 57 | case 4: flags += 1 << 6; break; 58 | case 8: flags += 2 << 6; break; 59 | default: flags += 3 << 6; 60 | } 61 | #ifdef DEBUG 62 | flags += 1 << 8; 63 | #endif 64 | #if defined(ASMV) || defined(ASMINF) 65 | flags += 1 << 9; 66 | #endif 67 | #ifdef ZLIB_WINAPI 68 | flags += 1 << 10; 69 | #endif 70 | #ifdef BUILDFIXED 71 | flags += 1 << 12; 72 | #endif 73 | #ifdef DYNAMIC_CRC_TABLE 74 | flags += 1 << 13; 75 | #endif 76 | #ifdef NO_GZCOMPRESS 77 | flags += 1L << 16; 78 | #endif 79 | #ifdef NO_GZIP 80 | flags += 1L << 17; 81 | #endif 82 | #ifdef PKZIP_BUG_WORKAROUND 83 | flags += 1L << 20; 84 | #endif 85 | #ifdef FASTEST 86 | flags += 1L << 21; 87 | #endif 88 | #ifdef STDC 89 | # ifdef NO_vsnprintf 90 | flags += 1L << 25; 91 | # ifdef HAS_vsprintf_void 92 | flags += 1L << 26; 93 | # endif 94 | # else 95 | # ifdef HAS_vsnprintf_void 96 | flags += 1L << 26; 97 | # endif 98 | # endif 99 | #else 100 | flags += 1L << 24; 101 | # ifdef NO_snprintf 102 | flags += 1L << 25; 103 | # ifdef HAS_sprintf_void 104 | flags += 1L << 26; 105 | # endif 106 | # else 107 | # ifdef HAS_snprintf_void 108 | flags += 1L << 26; 109 | # endif 110 | # endif 111 | #endif 112 | return flags; 113 | } 114 | 115 | #ifdef DEBUG 116 | 117 | # ifndef verbose 118 | # define verbose 0 119 | # endif 120 | int ZLIB_INTERNAL z_verbose = verbose; 121 | 122 | void ZLIB_INTERNAL z_error (m) 123 | char *m; 124 | { 125 | fprintf(stderr, "%s\n", m); 126 | exit(1); 127 | } 128 | #endif 129 | 130 | /* exported to allow conversion of error code to string for compress() and 131 | * uncompress() 132 | */ 133 | const char * ZEXPORT zError(int err) 134 | { 135 | return ERR_MSG(err); 136 | } 137 | 138 | #if defined(_WIN32_WCE) 139 | /* The Microsoft C Run-Time Library for Windows CE doesn't have 140 | * errno. We define it as a global variable to simplify porting. 141 | * Its value is always 0 and should not be used. 142 | */ 143 | int errno = 0; 144 | #endif 145 | 146 | #ifndef HAVE_MEMCPY 147 | 148 | void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) 149 | { 150 | if (len == 0) return; 151 | do { 152 | *dest++ = *source++; /* ??? to be unrolled */ 153 | } while (--len != 0); 154 | } 155 | 156 | int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) 157 | { 158 | uInt j; 159 | 160 | for (j = 0; j < len; j++) { 161 | if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; 162 | } 163 | return 0; 164 | } 165 | 166 | void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) 167 | { 168 | if (len == 0) return; 169 | do { 170 | *dest++ = 0; /* ??? to be unrolled */ 171 | } while (--len != 0); 172 | } 173 | #endif 174 | 175 | 176 | #ifdef SYS16BIT 177 | 178 | #ifdef __TURBOC__ 179 | /* Turbo C in 16-bit mode */ 180 | 181 | # define MY_ZCALLOC 182 | 183 | /* Turbo C malloc() does not allow dynamic allocation of 64K bytes 184 | * and farmalloc(64K) returns a pointer with an offset of 8, so we 185 | * must fix the pointer. Warning: the pointer must be put back to its 186 | * original form in order to free it, use zcfree(). 187 | */ 188 | 189 | #define MAX_PTR 10 190 | /* 10*64K = 640K */ 191 | 192 | local int next_ptr = 0; 193 | 194 | typedef struct ptr_table_s { 195 | voidpf org_ptr; 196 | voidpf new_ptr; 197 | } ptr_table; 198 | 199 | local ptr_table table[MAX_PTR]; 200 | /* This table is used to remember the original form of pointers 201 | * to large buffers (64K). Such pointers are normalized with a zero offset. 202 | * Since MSDOS is not a preemptive multitasking OS, this table is not 203 | * protected from concurrent access. This hack doesn't work anyway on 204 | * a protected system like OS/2. Use Microsoft C instead. 205 | */ 206 | 207 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) 208 | { 209 | voidpf buf = opaque; /* just to make some compilers happy */ 210 | ulg bsize = (ulg)items*size; 211 | 212 | /* If we allocate less than 65520 bytes, we assume that farmalloc 213 | * will return a usable pointer which doesn't have to be normalized. 214 | */ 215 | if (bsize < 65520L) { 216 | buf = farmalloc(bsize); 217 | if (*(ush*)&buf != 0) return buf; 218 | } else { 219 | buf = farmalloc(bsize + 16L); 220 | } 221 | if (buf == NULL || next_ptr >= MAX_PTR) return NULL; 222 | table[next_ptr].org_ptr = buf; 223 | 224 | /* Normalize the pointer to seg:0 */ 225 | *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; 226 | *(ush*)&buf = 0; 227 | table[next_ptr++].new_ptr = buf; 228 | return buf; 229 | } 230 | 231 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) 232 | { 233 | int n; 234 | if (*(ush*)&ptr != 0) { /* object < 64K */ 235 | farfree(ptr); 236 | return; 237 | } 238 | /* Find the original pointer */ 239 | for (n = 0; n < next_ptr; n++) { 240 | if (ptr != table[n].new_ptr) continue; 241 | 242 | farfree(table[n].org_ptr); 243 | while (++n < next_ptr) { 244 | table[n-1] = table[n]; 245 | } 246 | next_ptr--; 247 | return; 248 | } 249 | ptr = opaque; /* just to make some compilers happy */ 250 | Assert(0, "zcfree: ptr not found"); 251 | } 252 | 253 | #endif /* __TURBOC__ */ 254 | 255 | 256 | #ifdef M_I86 257 | /* Microsoft C in 16-bit mode */ 258 | 259 | # define MY_ZCALLOC 260 | 261 | #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) 262 | # define _halloc halloc 263 | # define _hfree hfree 264 | #endif 265 | 266 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, uInt items, uInt size) 267 | { 268 | if (opaque) opaque = 0; /* to make compiler happy */ 269 | return _halloc((long)items, size); 270 | } 271 | 272 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) 273 | { 274 | if (opaque) opaque = 0; /* to make compiler happy */ 275 | _hfree(ptr); 276 | } 277 | 278 | #endif /* M_I86 */ 279 | 280 | #endif /* SYS16BIT */ 281 | 282 | 283 | #ifndef MY_ZCALLOC /* Any system without a special alloc function */ 284 | 285 | #ifndef STDC 286 | extern voidp malloc OF((uInt size)); 287 | extern voidp calloc OF((uInt items, uInt size)); 288 | extern void free OF((voidpf ptr)); 289 | #endif 290 | 291 | voidpf ZLIB_INTERNAL zcalloc (voidpf opaque, unsigned items, unsigned size) 292 | { 293 | if (opaque) items += size - size; /* make compiler happy */ 294 | return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : 295 | (voidpf)calloc(items, size); 296 | } 297 | 298 | void ZLIB_INTERNAL zcfree (voidpf opaque, voidpf ptr) 299 | { 300 | free(ptr); 301 | if (opaque) return; /* make compiler happy */ 302 | } 303 | 304 | #endif /* MY_ZCALLOC */ 305 | -------------------------------------------------------------------------------- /portlibs/zlib/include/trees.h: -------------------------------------------------------------------------------- 1 | /* header created automatically with -DGEN_TREES_H */ 2 | 3 | local const ct_data static_ltree[L_CODES+2] = { 4 | {{ 12},{ 8}}, {{140},{ 8}}, {{ 76},{ 8}}, {{204},{ 8}}, {{ 44},{ 8}}, 5 | {{172},{ 8}}, {{108},{ 8}}, {{236},{ 8}}, {{ 28},{ 8}}, {{156},{ 8}}, 6 | {{ 92},{ 8}}, {{220},{ 8}}, {{ 60},{ 8}}, {{188},{ 8}}, {{124},{ 8}}, 7 | {{252},{ 8}}, {{ 2},{ 8}}, {{130},{ 8}}, {{ 66},{ 8}}, {{194},{ 8}}, 8 | {{ 34},{ 8}}, {{162},{ 8}}, {{ 98},{ 8}}, {{226},{ 8}}, {{ 18},{ 8}}, 9 | {{146},{ 8}}, {{ 82},{ 8}}, {{210},{ 8}}, {{ 50},{ 8}}, {{178},{ 8}}, 10 | {{114},{ 8}}, {{242},{ 8}}, {{ 10},{ 8}}, {{138},{ 8}}, {{ 74},{ 8}}, 11 | {{202},{ 8}}, {{ 42},{ 8}}, {{170},{ 8}}, {{106},{ 8}}, {{234},{ 8}}, 12 | {{ 26},{ 8}}, {{154},{ 8}}, {{ 90},{ 8}}, {{218},{ 8}}, {{ 58},{ 8}}, 13 | {{186},{ 8}}, {{122},{ 8}}, {{250},{ 8}}, {{ 6},{ 8}}, {{134},{ 8}}, 14 | {{ 70},{ 8}}, {{198},{ 8}}, {{ 38},{ 8}}, {{166},{ 8}}, {{102},{ 8}}, 15 | {{230},{ 8}}, {{ 22},{ 8}}, {{150},{ 8}}, {{ 86},{ 8}}, {{214},{ 8}}, 16 | {{ 54},{ 8}}, {{182},{ 8}}, {{118},{ 8}}, {{246},{ 8}}, {{ 14},{ 8}}, 17 | {{142},{ 8}}, {{ 78},{ 8}}, {{206},{ 8}}, {{ 46},{ 8}}, {{174},{ 8}}, 18 | {{110},{ 8}}, {{238},{ 8}}, {{ 30},{ 8}}, {{158},{ 8}}, {{ 94},{ 8}}, 19 | {{222},{ 8}}, {{ 62},{ 8}}, {{190},{ 8}}, {{126},{ 8}}, {{254},{ 8}}, 20 | {{ 1},{ 8}}, {{129},{ 8}}, {{ 65},{ 8}}, {{193},{ 8}}, {{ 33},{ 8}}, 21 | {{161},{ 8}}, {{ 97},{ 8}}, {{225},{ 8}}, {{ 17},{ 8}}, {{145},{ 8}}, 22 | {{ 81},{ 8}}, {{209},{ 8}}, {{ 49},{ 8}}, {{177},{ 8}}, {{113},{ 8}}, 23 | {{241},{ 8}}, {{ 9},{ 8}}, {{137},{ 8}}, {{ 73},{ 8}}, {{201},{ 8}}, 24 | {{ 41},{ 8}}, {{169},{ 8}}, {{105},{ 8}}, {{233},{ 8}}, {{ 25},{ 8}}, 25 | {{153},{ 8}}, {{ 89},{ 8}}, {{217},{ 8}}, {{ 57},{ 8}}, {{185},{ 8}}, 26 | {{121},{ 8}}, {{249},{ 8}}, {{ 5},{ 8}}, {{133},{ 8}}, {{ 69},{ 8}}, 27 | {{197},{ 8}}, {{ 37},{ 8}}, {{165},{ 8}}, {{101},{ 8}}, {{229},{ 8}}, 28 | {{ 21},{ 8}}, {{149},{ 8}}, {{ 85},{ 8}}, {{213},{ 8}}, {{ 53},{ 8}}, 29 | {{181},{ 8}}, {{117},{ 8}}, {{245},{ 8}}, {{ 13},{ 8}}, {{141},{ 8}}, 30 | {{ 77},{ 8}}, {{205},{ 8}}, {{ 45},{ 8}}, {{173},{ 8}}, {{109},{ 8}}, 31 | {{237},{ 8}}, {{ 29},{ 8}}, {{157},{ 8}}, {{ 93},{ 8}}, {{221},{ 8}}, 32 | {{ 61},{ 8}}, {{189},{ 8}}, {{125},{ 8}}, {{253},{ 8}}, {{ 19},{ 9}}, 33 | {{275},{ 9}}, {{147},{ 9}}, {{403},{ 9}}, {{ 83},{ 9}}, {{339},{ 9}}, 34 | {{211},{ 9}}, {{467},{ 9}}, {{ 51},{ 9}}, {{307},{ 9}}, {{179},{ 9}}, 35 | {{435},{ 9}}, {{115},{ 9}}, {{371},{ 9}}, {{243},{ 9}}, {{499},{ 9}}, 36 | {{ 11},{ 9}}, {{267},{ 9}}, {{139},{ 9}}, {{395},{ 9}}, {{ 75},{ 9}}, 37 | {{331},{ 9}}, {{203},{ 9}}, {{459},{ 9}}, {{ 43},{ 9}}, {{299},{ 9}}, 38 | {{171},{ 9}}, {{427},{ 9}}, {{107},{ 9}}, {{363},{ 9}}, {{235},{ 9}}, 39 | {{491},{ 9}}, {{ 27},{ 9}}, {{283},{ 9}}, {{155},{ 9}}, {{411},{ 9}}, 40 | {{ 91},{ 9}}, {{347},{ 9}}, {{219},{ 9}}, {{475},{ 9}}, {{ 59},{ 9}}, 41 | {{315},{ 9}}, {{187},{ 9}}, {{443},{ 9}}, {{123},{ 9}}, {{379},{ 9}}, 42 | {{251},{ 9}}, {{507},{ 9}}, {{ 7},{ 9}}, {{263},{ 9}}, {{135},{ 9}}, 43 | {{391},{ 9}}, {{ 71},{ 9}}, {{327},{ 9}}, {{199},{ 9}}, {{455},{ 9}}, 44 | {{ 39},{ 9}}, {{295},{ 9}}, {{167},{ 9}}, {{423},{ 9}}, {{103},{ 9}}, 45 | {{359},{ 9}}, {{231},{ 9}}, {{487},{ 9}}, {{ 23},{ 9}}, {{279},{ 9}}, 46 | {{151},{ 9}}, {{407},{ 9}}, {{ 87},{ 9}}, {{343},{ 9}}, {{215},{ 9}}, 47 | {{471},{ 9}}, {{ 55},{ 9}}, {{311},{ 9}}, {{183},{ 9}}, {{439},{ 9}}, 48 | {{119},{ 9}}, {{375},{ 9}}, {{247},{ 9}}, {{503},{ 9}}, {{ 15},{ 9}}, 49 | {{271},{ 9}}, {{143},{ 9}}, {{399},{ 9}}, {{ 79},{ 9}}, {{335},{ 9}}, 50 | {{207},{ 9}}, {{463},{ 9}}, {{ 47},{ 9}}, {{303},{ 9}}, {{175},{ 9}}, 51 | {{431},{ 9}}, {{111},{ 9}}, {{367},{ 9}}, {{239},{ 9}}, {{495},{ 9}}, 52 | {{ 31},{ 9}}, {{287},{ 9}}, {{159},{ 9}}, {{415},{ 9}}, {{ 95},{ 9}}, 53 | {{351},{ 9}}, {{223},{ 9}}, {{479},{ 9}}, {{ 63},{ 9}}, {{319},{ 9}}, 54 | {{191},{ 9}}, {{447},{ 9}}, {{127},{ 9}}, {{383},{ 9}}, {{255},{ 9}}, 55 | {{511},{ 9}}, {{ 0},{ 7}}, {{ 64},{ 7}}, {{ 32},{ 7}}, {{ 96},{ 7}}, 56 | {{ 16},{ 7}}, {{ 80},{ 7}}, {{ 48},{ 7}}, {{112},{ 7}}, {{ 8},{ 7}}, 57 | {{ 72},{ 7}}, {{ 40},{ 7}}, {{104},{ 7}}, {{ 24},{ 7}}, {{ 88},{ 7}}, 58 | {{ 56},{ 7}}, {{120},{ 7}}, {{ 4},{ 7}}, {{ 68},{ 7}}, {{ 36},{ 7}}, 59 | {{100},{ 7}}, {{ 20},{ 7}}, {{ 84},{ 7}}, {{ 52},{ 7}}, {{116},{ 7}}, 60 | {{ 3},{ 8}}, {{131},{ 8}}, {{ 67},{ 8}}, {{195},{ 8}}, {{ 35},{ 8}}, 61 | {{163},{ 8}}, {{ 99},{ 8}}, {{227},{ 8}} 62 | }; 63 | 64 | local const ct_data static_dtree[D_CODES] = { 65 | {{ 0},{ 5}}, {{16},{ 5}}, {{ 8},{ 5}}, {{24},{ 5}}, {{ 4},{ 5}}, 66 | {{20},{ 5}}, {{12},{ 5}}, {{28},{ 5}}, {{ 2},{ 5}}, {{18},{ 5}}, 67 | {{10},{ 5}}, {{26},{ 5}}, {{ 6},{ 5}}, {{22},{ 5}}, {{14},{ 5}}, 68 | {{30},{ 5}}, {{ 1},{ 5}}, {{17},{ 5}}, {{ 9},{ 5}}, {{25},{ 5}}, 69 | {{ 5},{ 5}}, {{21},{ 5}}, {{13},{ 5}}, {{29},{ 5}}, {{ 3},{ 5}}, 70 | {{19},{ 5}}, {{11},{ 5}}, {{27},{ 5}}, {{ 7},{ 5}}, {{23},{ 5}} 71 | }; 72 | 73 | const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = { 74 | 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 75 | 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 10, 10, 10, 10, 10, 10, 76 | 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 77 | 11, 11, 11, 11, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 78 | 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 79 | 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 80 | 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 81 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 82 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 83 | 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 84 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 85 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 86 | 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 0, 0, 16, 17, 87 | 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22, 22, 22, 88 | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 89 | 24, 24, 24, 24, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 90 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 91 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 92 | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 93 | 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 94 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 95 | 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 96 | 28, 28, 28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 97 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 98 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 99 | 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29 100 | }; 101 | 102 | const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= { 103 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 12, 12, 104 | 13, 13, 13, 13, 14, 14, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 105 | 17, 17, 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 106 | 19, 19, 19, 19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 107 | 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 108 | 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 109 | 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 110 | 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 111 | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 112 | 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 26, 113 | 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 114 | 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 115 | 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28 116 | }; 117 | 118 | local const int base_length[LENGTH_CODES] = { 119 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 16, 20, 24, 28, 32, 40, 48, 56, 120 | 64, 80, 96, 112, 128, 160, 192, 224, 0 121 | }; 122 | 123 | local const int base_dist[D_CODES] = { 124 | 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 125 | 32, 48, 64, 96, 128, 192, 256, 384, 512, 768, 126 | 1024, 1536, 2048, 3072, 4096, 6144, 8192, 12288, 16384, 24576 127 | }; 128 | 129 | -------------------------------------------------------------------------------- /portlibs/libpng/source/pngwio.c: -------------------------------------------------------------------------------- 1 | 2 | /* pngwio.c - functions for data output 3 | * 4 | * Last changed in libpng 1.5.0 [January 6, 2011] 5 | * Copyright (c) 1998-2011 Glenn Randers-Pehrson 6 | * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) 7 | * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) 8 | * 9 | * This code is released under the libpng license. 10 | * For conditions of distribution and use, see the disclaimer 11 | * and license in png.h 12 | * 13 | * This file provides a location for all output. Users who need 14 | * special handling are expected to write functions that have the same 15 | * arguments as these and perform similar functions, but that possibly 16 | * use different output methods. Note that you shouldn't change these 17 | * functions, but rather write replacement functions and then change 18 | * them at run time with png_set_write_fn(...). 19 | */ 20 | 21 | #include "pngpriv.h" 22 | 23 | #ifdef PNG_WRITE_SUPPORTED 24 | 25 | /* Write the data to whatever output you are using. The default routine 26 | * writes to a file pointer. Note that this routine sometimes gets called 27 | * with very small lengths, so you should implement some kind of simple 28 | * buffering if you are using unbuffered writes. This should never be asked 29 | * to write more than 64K on a 16 bit machine. 30 | */ 31 | 32 | void /* PRIVATE */ 33 | png_write_data(png_structp png_ptr, png_const_bytep data, png_size_t length) 34 | { 35 | /* NOTE: write_data_fn must not change the buffer! */ 36 | if (png_ptr->write_data_fn != NULL ) 37 | (*(png_ptr->write_data_fn))(png_ptr, (png_bytep)data, length); 38 | 39 | else 40 | png_error(png_ptr, "Call to NULL write function"); 41 | } 42 | 43 | #ifdef PNG_STDIO_SUPPORTED 44 | /* This is the function that does the actual writing of data. If you are 45 | * not writing to a standard C stream, you should create a replacement 46 | * write_data function and use it at run time with png_set_write_fn(), rather 47 | * than changing the library. 48 | */ 49 | #ifndef USE_FAR_KEYWORD 50 | void PNGCBAPI 51 | png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) 52 | { 53 | png_size_t check; 54 | 55 | if (png_ptr == NULL) 56 | return; 57 | 58 | check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr)); 59 | 60 | if (check != length) 61 | png_error(png_ptr, "Write Error"); 62 | } 63 | #else 64 | /* This is the model-independent version. Since the standard I/O library 65 | * can't handle far buffers in the medium and small models, we have to copy 66 | * the data. 67 | */ 68 | 69 | #define NEAR_BUF_SIZE 1024 70 | #define MIN(a,b) (a <= b ? a : b) 71 | 72 | void PNGCBAPI 73 | png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length) 74 | { 75 | png_uint_32 check; 76 | png_byte *near_data; /* Needs to be "png_byte *" instead of "png_bytep" */ 77 | png_FILE_p io_ptr; 78 | 79 | if (png_ptr == NULL) 80 | return; 81 | 82 | /* Check if data really is near. If so, use usual code. */ 83 | near_data = (png_byte *)CVT_PTR_NOCHECK(data); 84 | io_ptr = (png_FILE_p)CVT_PTR(png_ptr->io_ptr); 85 | 86 | if ((png_bytep)near_data == data) 87 | { 88 | check = fwrite(near_data, 1, length, io_ptr); 89 | } 90 | 91 | else 92 | { 93 | png_byte buf[NEAR_BUF_SIZE]; 94 | png_size_t written, remaining, err; 95 | check = 0; 96 | remaining = length; 97 | 98 | do 99 | { 100 | written = MIN(NEAR_BUF_SIZE, remaining); 101 | png_memcpy(buf, data, written); /* Copy far buffer to near buffer */ 102 | err = fwrite(buf, 1, written, io_ptr); 103 | 104 | if (err != written) 105 | break; 106 | 107 | else 108 | check += err; 109 | 110 | data += written; 111 | remaining -= written; 112 | } 113 | while (remaining != 0); 114 | } 115 | 116 | if (check != length) 117 | png_error(png_ptr, "Write Error"); 118 | } 119 | 120 | #endif 121 | #endif 122 | 123 | /* This function is called to output any data pending writing (normally 124 | * to disk). After png_flush is called, there should be no data pending 125 | * writing in any buffers. 126 | */ 127 | #ifdef PNG_WRITE_FLUSH_SUPPORTED 128 | void /* PRIVATE */ 129 | png_flush(png_structp png_ptr) 130 | { 131 | if (png_ptr->output_flush_fn != NULL) 132 | (*(png_ptr->output_flush_fn))(png_ptr); 133 | } 134 | 135 | # ifdef PNG_STDIO_SUPPORTED 136 | void PNGCBAPI 137 | png_default_flush(png_structp png_ptr) 138 | { 139 | png_FILE_p io_ptr; 140 | 141 | if (png_ptr == NULL) 142 | return; 143 | 144 | io_ptr = (png_FILE_p)CVT_PTR((png_ptr->io_ptr)); 145 | fflush(io_ptr); 146 | } 147 | # endif 148 | #endif 149 | 150 | /* This function allows the application to supply new output functions for 151 | * libpng if standard C streams aren't being used. 152 | * 153 | * This function takes as its arguments: 154 | * png_ptr - pointer to a png output data structure 155 | * io_ptr - pointer to user supplied structure containing info about 156 | * the output functions. May be NULL. 157 | * write_data_fn - pointer to a new output function that takes as its 158 | * arguments a pointer to a png_struct, a pointer to 159 | * data to be written, and a 32-bit unsigned int that is 160 | * the number of bytes to be written. The new write 161 | * function should call png_error(png_ptr, "Error msg") 162 | * to exit and output any fatal error messages. May be 163 | * NULL, in which case libpng's default function will 164 | * be used. 165 | * flush_data_fn - pointer to a new flush function that takes as its 166 | * arguments a pointer to a png_struct. After a call to 167 | * the flush function, there should be no data in any buffers 168 | * or pending transmission. If the output method doesn't do 169 | * any buffering of output, a function prototype must still be 170 | * supplied although it doesn't have to do anything. If 171 | * PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile 172 | * time, output_flush_fn will be ignored, although it must be 173 | * supplied for compatibility. May be NULL, in which case 174 | * libpng's default function will be used, if 175 | * PNG_WRITE_FLUSH_SUPPORTED is defined. This is not 176 | * a good idea if io_ptr does not point to a standard 177 | * *FILE structure. 178 | */ 179 | void PNGAPI 180 | png_set_write_fn(png_structp png_ptr, png_voidp io_ptr, 181 | png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn) 182 | { 183 | if (png_ptr == NULL) 184 | return; 185 | 186 | png_ptr->io_ptr = io_ptr; 187 | 188 | #ifdef PNG_STDIO_SUPPORTED 189 | if (write_data_fn != NULL) 190 | png_ptr->write_data_fn = write_data_fn; 191 | 192 | else 193 | png_ptr->write_data_fn = png_default_write_data; 194 | #else 195 | png_ptr->write_data_fn = write_data_fn; 196 | #endif 197 | 198 | #ifdef PNG_WRITE_FLUSH_SUPPORTED 199 | # ifdef PNG_STDIO_SUPPORTED 200 | 201 | if (output_flush_fn != NULL) 202 | png_ptr->output_flush_fn = output_flush_fn; 203 | 204 | else 205 | png_ptr->output_flush_fn = png_default_flush; 206 | 207 | # else 208 | png_ptr->output_flush_fn = output_flush_fn; 209 | # endif 210 | #endif /* PNG_WRITE_FLUSH_SUPPORTED */ 211 | 212 | /* It is an error to read while writing a png file */ 213 | if (png_ptr->read_data_fn != NULL) 214 | { 215 | png_ptr->read_data_fn = NULL; 216 | 217 | png_warning(png_ptr, 218 | "Can't set both read_data_fn and write_data_fn in the" 219 | " same structure"); 220 | } 221 | } 222 | 223 | #ifdef USE_FAR_KEYWORD 224 | # ifdef _MSC_VER 225 | void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) 226 | { 227 | void *near_ptr; 228 | void FAR *far_ptr; 229 | FP_OFF(near_ptr) = FP_OFF(ptr); 230 | far_ptr = (void FAR *)near_ptr; 231 | 232 | if (check != 0) 233 | if (FP_SEG(ptr) != FP_SEG(far_ptr)) 234 | png_error(png_ptr, "segment lost in conversion"); 235 | 236 | return(near_ptr); 237 | } 238 | # else 239 | void *png_far_to_near(png_structp png_ptr, png_voidp ptr, int check) 240 | { 241 | void *near_ptr; 242 | void FAR *far_ptr; 243 | near_ptr = (void FAR *)ptr; 244 | far_ptr = (void FAR *)near_ptr; 245 | 246 | if (check != 0) 247 | if (far_ptr != ptr) 248 | png_error(png_ptr, "segment lost in conversion"); 249 | 250 | return(near_ptr); 251 | } 252 | # endif 253 | #endif 254 | #endif /* PNG_WRITE_SUPPORTED */ 255 | -------------------------------------------------------------------------------- /orbislink/libps4link/source/ps4link.c: -------------------------------------------------------------------------------- 1 | /* 2 | * PS4link library for PlayStation 4 to communicate and use host file system with ps4sh host tool 3 | * Copyright (C) 2003,2015,2016 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/ps4link 5 | * based on ps2vfs, ps2client, ps2link, ps2http tools. 6 | * Credits goes for all people involved in ps2dev project https://github.com/ps2dev 7 | * This file is subject to the terms and conditions of the PS4Link License. 8 | * See the file LICENSE in the main directory of this distribution for more 9 | * details. 10 | */ 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | 21 | 22 | 23 | #include "ps4link_internal.h" 24 | #include "ps4link.h" 25 | #include "jailbreak.h" 26 | 27 | 28 | /*int ps4link_initialized; 29 | int ps4link_requests_port; 30 | int ps4link_commands_port; 31 | int ps4link_fileio_active; 32 | int ps4link_cmdio_active;*/ 33 | 34 | ScePthread server_request_thid; 35 | ScePthread server_command_thid; 36 | //ScePthread server_payload_thid; 37 | 38 | ps4LinkConfiguration *configuration=NULL; 39 | 40 | int external_conf=0; 41 | 42 | extern int ps4KernelExecute(void *fn, void *uap, int64_t *ret0, int64_t *ret1); 43 | /** 44 | * Init ps4link library 45 | * 46 | * @par Example: 47 | * @code 48 | * int ret; 49 | * ret = psp2LinkInit("172.26.0.2",0x4711,0x4712,0x4712, DEBUG); 50 | * @endcode 51 | * 52 | * @param serverIp - server ip for udp debug 53 | * @param requestPort - ps4 port server for fileio requests 54 | * @param debugPort - udp port for debug 55 | * @param commandPort - ps4 port server for commands 56 | * @param level - DEBUG,ERROR,INFO or NONE 57 | */ 58 | int ps4LinkInit(char *serverIp, int requestPort,int debugPort, int commandPort,int level) 59 | { 60 | int ret; 61 | int64_t ret1; 62 | 63 | if(ps4LinkCreateConf()) 64 | { 65 | return ps4LinkGetValue(PS4LINK_ACTIVE); 66 | } 67 | configuration->ps4link_requests_port=requestPort; 68 | configuration->ps4link_commands_port=commandPort; 69 | configuration->ps4link_debug_port=commandPort; 70 | 71 | 72 | if(debugNetInit(serverIp,debugPort,level)) 73 | { 74 | sleep(2); 75 | 76 | configuration->debugconf=debugNetGetConf(); 77 | 78 | 79 | /* ret=scePthreadCreate(&server_payload_thid, NULL, payload_thread, NULL, "ps4link_request_server_thread"); 80 | if(ret==0) 81 | { 82 | debugNetPrintf(DEBUG,"[PS4LINK] Server payload thread UID: 0x%08X\n", server_payload_thid); 83 | 84 | } 85 | else 86 | { 87 | debugNetPrintf(DEBUG,"[PS4LINK] Server payload thread could not create error: 0x%08X\n", ret); 88 | scePthreadCancel(server_payload_thid); 89 | 90 | 91 | }*/ 92 | 93 | 94 | //scePthreadJoin(server_payload_thid, NULL); 95 | // debugNetPrintf(DEBUG,"getuid() : %d\n", getuid()); 96 | //if (getuid() != 0) { 97 | // debugNetPrintf(DEBUG,"executing privilege scalation \n"); 98 | 99 | //ps4KernelExecute((void*)jailbreak, NULL, &ret1, NULL); 100 | //debugNetPrintf(DEBUG,"ps4KernelExecute ret=%d \n",ret1); 101 | 102 | //debugNetPrintf(DEBUG,"getuid() : %d\n", getuid()); 103 | 104 | //} 105 | 106 | ret=scePthreadCreate(&server_request_thid, NULL, ps4link_requests_thread, NULL, "ps4link_request_server_thread"); 107 | 108 | 109 | if(ret==0) 110 | { 111 | debugNetPrintf(DEBUG,"[PS4LINK] Server request thread UID: 0x%08X\n", server_request_thid); 112 | 113 | } 114 | else 115 | { 116 | debugNetPrintf(DEBUG,"[PS4LINK] Server request thread could not create error: 0x%08X\n", ret); 117 | scePthreadCancel(server_request_thid); 118 | ps4LinkFinish(); 119 | return 0; 120 | } 121 | 122 | ret=scePthreadCreate(&server_command_thid, NULL, ps4link_commands_thread, NULL, "ps4link_command_server_thread"); 123 | 124 | if(ret==0) 125 | { 126 | debugNetPrintf(DEBUG,"[PS4LINK] Server command thread UID: 0x%08X\n", server_command_thid); 127 | } 128 | else 129 | { 130 | debugNetPrintf(DEBUG,"[PS4LINK] Server command thread could not create error: 0x%08X\n", server_command_thid); 131 | scePthreadCancel(server_request_thid); 132 | scePthreadCancel(server_command_thid); 133 | ps4LinkFinish(); 134 | return 0; 135 | } 136 | 137 | /*ret=scePthreadCancel(server_payload_thid); 138 | if(ret==0) 139 | { 140 | debugNetPrintf(DEBUG,"[PS4LINK] Server payload thread terminated\n"); 141 | } 142 | else 143 | { 144 | debugNetPrintf(DEBUG,"[PS4LINK] Server payload thread terminated error: 0x%08X\n", ret); 145 | 146 | }*/ 147 | 148 | /*ps4link library initialized*/ 149 | configuration->ps4link_initialized = 1; 150 | 151 | } 152 | else 153 | { 154 | configuration->ps4link_initialized = 0; 155 | } 156 | sleep(2); 157 | return ps4LinkGetValue(PS4LINK_ACTIVE); 158 | } 159 | int ps4LinkSetConfig(ps4LinkConfiguration *conf) 160 | { 161 | if(!conf) 162 | { 163 | return 0; 164 | } 165 | configuration=conf; 166 | external_conf=1; 167 | return 1; 168 | } 169 | ps4LinkConfiguration *ps4LinkGetConfig() 170 | { 171 | if(!configuration) 172 | { 173 | return NULL; 174 | } 175 | return configuration; 176 | } 177 | int ps4LinkInitWithConf(ps4LinkConfiguration *conf) 178 | { 179 | 180 | int ret; 181 | ret=ps4LinkSetConfig(conf); 182 | if(ret) 183 | { 184 | if(debugNetInitWithConf(conf->debugconf)) 185 | { 186 | 187 | debugNetPrintf(INFO,"ps4link already initialized using configuration from ps4link\n"); 188 | debugNetPrintf(INFO,"ps4link_fileio_active=%d\n",ps4LinkGetValue(FILEIO_ACTIVE)); 189 | debugNetPrintf(INFO,"ps4link_cmdsio_active=%d\n",ps4LinkGetValue(CMDSIO_ACTIVE)); 190 | debugNetPrintf(INFO,"ps4link_initialized=%d\n",ps4LinkGetValue(PS4LINK_ACTIVE)); 191 | debugNetPrintf(INFO,"ps4link_requests_port=%d\n",ps4LinkGetValue(REQUESTS_PORT)); 192 | debugNetPrintf(INFO,"ps4link_commands_port=%d\n",ps4LinkGetValue(COMMANDS_PORT)); 193 | debugNetPrintf(INFO,"ps4link_debug_port=%d\n",ps4LinkGetValue(DEBUG_PORT)); 194 | debugNetPrintf(INFO,"ps4link_fileio_sock=%d\n",ps4LinkGetValue(FILEIO_SOCK)); 195 | debugNetPrintf(INFO,"ps4link_requests_sock=%d\n",ps4LinkGetValue(REQUESTS_SOCK)); 196 | debugNetPrintf(INFO,"ps4link_commands_sock=%d\n",ps4LinkGetValue(COMMANDS_SOCK)); 197 | return ps4LinkGetValue(PS4LINK_ACTIVE); 198 | } 199 | else 200 | { 201 | return 0; 202 | } 203 | } 204 | else 205 | { 206 | return 0; 207 | } 208 | } 209 | int ps4LinkCreateConf() 210 | { 211 | if(!configuration) 212 | { 213 | configuration=malloc(sizeof(ps4LinkConfiguration)); 214 | configuration->ps4link_fileio_active=1; 215 | configuration->ps4link_cmdsio_active=1; 216 | configuration->ps4link_initialized=0; 217 | configuration->ps4link_fileio_sock=-1; 218 | configuration->ps4link_requests_sock=-1; 219 | configuration->ps4link_commands_sock=-1; 220 | return 0; 221 | } 222 | if(configuration->ps4link_initialized) 223 | { 224 | return 1; 225 | } 226 | return 0; 227 | } 228 | 229 | 230 | /** 231 | * Get configuration values from PS4Link library 232 | * 233 | * @par Example: 234 | * @code 235 | * ps4LinkGetValue(PS4LINK_ACTIVE); 236 | * @endcode 237 | */ 238 | int ps4LinkGetValue(ps4LinkValue val) 239 | { 240 | int ret; 241 | switch(val) 242 | { 243 | case FILEIO_ACTIVE: 244 | ret=configuration->ps4link_fileio_active; 245 | break; 246 | case CMDSIO_ACTIVE: 247 | ret=configuration->ps4link_cmdsio_active; 248 | break; 249 | case DEBUGNET_ACTIVE: 250 | ret=configuration->debugconf->debugnet_initialized; 251 | break; 252 | case PS4LINK_ACTIVE: 253 | ret=configuration->ps4link_initialized; 254 | break; 255 | case REQUESTS_PORT: 256 | ret=configuration->ps4link_requests_port; 257 | break; 258 | case COMMANDS_PORT: 259 | ret=configuration->ps4link_commands_port; 260 | break; 261 | case DEBUG_PORT: 262 | ret=configuration->ps4link_debug_port; 263 | break; 264 | case FILEIO_SOCK: 265 | ret=configuration->ps4link_fileio_sock; 266 | break; 267 | case REQUESTS_SOCK: 268 | ret=configuration->ps4link_requests_sock; 269 | break; 270 | case COMMANDS_SOCK: 271 | ret=configuration->ps4link_commands_sock; 272 | break; 273 | case DEBUG_SOCK: 274 | ret=configuration->debugconf->SocketFD; 275 | break; 276 | case LOG_LEVEL: 277 | ret=configuration->debugconf->logLevel; 278 | break; 279 | default: 280 | ret=0; 281 | break; 282 | } 283 | return ret; 284 | } 285 | /** 286 | * Finish PS4Link library 287 | * 288 | * @par Example: 289 | * @code 290 | * ps4LinkFinish(); 291 | * @endcode 292 | */ 293 | void ps4LinkFinish() 294 | { 295 | if(!external_conf) 296 | { 297 | configuration->ps4link_fileio_active=0; 298 | configuration->ps4link_cmdsio_active=0; 299 | configuration->ps4link_initialized=0; 300 | ps4LinkRequestsAbort(); 301 | while(ps4LinkRequestsIsConnected()) 302 | { 303 | 304 | } 305 | debugNetFinish(); 306 | } 307 | } 308 | -------------------------------------------------------------------------------- /liborbisFileBrowser/source/orbisFileBrowser.c: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/liborbis 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include "orbisFileBrowser.h" 14 | 15 | int orbisFileBrowserInitialized=0; 16 | OrbisFileBrowserList *browserList; 17 | 18 | // Position 19 | int basePos = 0, relPos = 0; 20 | int basePosList[MAX_DIR_LEVELS]; 21 | int relPosList[MAX_DIR_LEVELS]; 22 | int dirLevel=0; 23 | 24 | char *devices[] = { 25 | "host0:", 26 | }; 27 | 28 | ExtensionType extensionTypes[] = { 29 | { ".ROM", FILE_TYPE_ROM }, 30 | { ".DSK", FILE_TYPE_DSK }, 31 | { ".CAS", FILE_TYPE_CAS }, 32 | 33 | }; 34 | int orbisFileBrowserGetDirLevel() 35 | { 36 | return dirLevel; 37 | } 38 | int orbisFileBrowserGetBasePos() 39 | { 40 | return basePos; 41 | } 42 | int orbisFileBrowserGetRelPos() 43 | { 44 | return relPos; 45 | } 46 | int orbisFileBrowserGetListLength() 47 | { 48 | return browserList->length; 49 | } 50 | void orbisFileBrowserSetListPath(char *path) 51 | { 52 | int len = strlen(browserList->path); 53 | if (dirLevel==0) 54 | { 55 | strcpy(browserList->path, path); 56 | } 57 | else 58 | { 59 | if(dirLevel > 1) 60 | { 61 | if(lenpath[len-1]!='/') 64 | { 65 | strcat(browserList->path,"/"); 66 | } 67 | } 68 | } 69 | strcat(browserList->path, path); 70 | } 71 | } 72 | void orbisFileBrowserEntryDown() 73 | { 74 | if((relPos+1)length) 75 | { 76 | if((relPos+1)length) 83 | { 84 | basePos++; 85 | } 86 | } 87 | } 88 | } 89 | void orbisFileBrowserEntryUp() 90 | { 91 | if(relPos>0) 92 | { 93 | relPos--; 94 | } 95 | else 96 | { 97 | if(basePos>0) 98 | { 99 | basePos--; 100 | } 101 | } 102 | } 103 | int orbisFileBrowserGetFileType(char *file) 104 | { 105 | char *p=strrchr(file,'.'); 106 | if(p) 107 | { 108 | int i; 109 | for(i=0;i<(sizeof(extensionTypes)/sizeof(ExtensionType));i++) 110 | { 111 | if(strcasecmp(p,extensionTypes[i].extension)==0) 112 | { 113 | return extensionTypes[i].type; 114 | } 115 | } 116 | } 117 | 118 | return FILE_TYPE_UNKNOWN; 119 | } 120 | void orbisFileBrowserDirLevelUp() 121 | { 122 | basePosList[dirLevel]=basePos; 123 | relPosList[dirLevel]=relPos; 124 | dirLevel++; 125 | basePosList[dirLevel]=0; 126 | relPosList[dirLevel]=0; 127 | basePos=0; 128 | relPos=0; 129 | } 130 | void orbisFileBrowserDirUp() 131 | { 132 | 133 | char *p; 134 | 135 | p=strrchr(browserList->path,'/'); 136 | if(p) 137 | { 138 | p[1]='\0'; 139 | dirLevel--; 140 | goto DIR_UP_RETURN; 141 | } 142 | 143 | p=strrchr(browserList->path,':'); 144 | if(p) 145 | { 146 | if (strlen(browserList->path)-((p+1)-browserList->path)>0) 147 | { 148 | p[1]='\0'; 149 | dirLevel--; 150 | goto DIR_UP_RETURN; 151 | } 152 | } 153 | 154 | strcpy(browserList->path, ROOT_PATH); 155 | dirLevel=0; 156 | 157 | DIR_UP_RETURN: 158 | basePos=basePosList[dirLevel]; 159 | relPos=relPosList[dirLevel]; 160 | } 161 | 162 | void orbisFileBrowserListClean() 163 | { 164 | if(browserList) 165 | { 166 | if(browserList->head) 167 | { OrbisFileBrowserListEntry *entry=browserList->head; 168 | while(entry) 169 | { 170 | if(entry->next) 171 | { 172 | OrbisFileBrowserListEntry *next=entry->next; 173 | free(entry); 174 | entry=next; 175 | } 176 | } 177 | } 178 | browserList->head=NULL; 179 | browserList->tail=NULL; 180 | browserList->length=0; 181 | } 182 | 183 | } 184 | int orbisFileBrowserListRefresh() 185 | { 186 | int ret=0,res=0; 187 | 188 | do 189 | { 190 | orbisFileBrowserListClean(); 191 | 192 | res=orbisFileBrowserListGetEntries(browserList->path); 193 | 194 | if(res<0) 195 | { 196 | ret=res; 197 | orbisFileBrowserDirUp(); 198 | } 199 | }while(res<0); 200 | 201 | // Correct position after deleting the latest entry of the file list 202 | while((basePos+relPos)>=browserList->length) 203 | { 204 | if(basePos>0) 205 | { 206 | basePos--; 207 | } 208 | else 209 | { 210 | if(relPos>0) 211 | { 212 | relPos--; 213 | } 214 | } 215 | } 216 | 217 | // Correct position after deleting an entry while the scrollbar is on the bottom 218 | if(browserList->length>=MAX_POSITION) { 219 | while((basePos+MAX_POSITION-1)>=browserList->length) 220 | { 221 | if(basePos>0) 222 | { 223 | basePos--; 224 | relPos++; 225 | } 226 | } 227 | } 228 | 229 | return ret; 230 | } 231 | OrbisFileBrowserListEntry *orbisFileBrowserListGetNthEntry(int n) 232 | { 233 | OrbisFileBrowserListEntry *entry; 234 | int i; 235 | if(nlength/2) 236 | { 237 | entry=browserList->head; 238 | for(i=0;inext; 241 | } 242 | } 243 | else 244 | { 245 | entry=browserList->tail; 246 | for(i=browserList->length-1;i>n;i--) 247 | { 248 | entry=entry->previous; 249 | } 250 | 251 | } 252 | return entry; 253 | } 254 | 255 | void orbisFileBrowserListAddEntry(OrbisFileBrowserListEntry *entry,int sort) 256 | { 257 | entry->next=NULL; 258 | entry->previous=NULL; 259 | 260 | if(browserList->head==NULL) 261 | { 262 | browserList->head=entry; 263 | browserList->tail=entry; 264 | } 265 | else 266 | { 267 | if(sort!=SORT_NONE) 268 | { 269 | int entry_length=strlen(entry->name); 270 | 271 | OrbisFileBrowserListEntry *p=browserList->head; 272 | OrbisFileBrowserListEntry *previous=NULL; 273 | 274 | while(p) 275 | { 276 | // Sort by type 277 | if(entry->type>p->type) 278 | break; 279 | 280 | // '..' is always at first 281 | if(strcmp(entry->name,"..")==0) 282 | break; 283 | 284 | if(strcmp(p->name,"..")!=0) 285 | { 286 | // Get the minimum length without / 287 | int name_length=strlen(p->name); 288 | int len=(((entry_length) < (name_length)) ? (entry_length) : (name_length)); 289 | if(entry->name[len - 1]=='/' || p->name[len - 1]=='/') 290 | len--; 291 | 292 | // Sort by name 293 | if(entry->type==p->type) 294 | { 295 | int diff=strncasecmp(entry->name,p->name,len); 296 | if (diff<0 || (diff==0 && entry_lengthnext; 305 | } 306 | 307 | if(previous==NULL) 308 | { // Order: entry (new head) -> p (old head) 309 | entry->next=p; 310 | p->previous=entry; 311 | browserList->head=entry; 312 | } 313 | else if(previous->next == NULL) 314 | { // Order: p (old tail) -> entry (new tail) 315 | OrbisFileBrowserListEntry *tail=browserList->tail; 316 | tail->next=entry; 317 | entry->previous=tail; 318 | browserList->tail=entry; 319 | } 320 | else 321 | { // Order: previous -> entry -> p 322 | previous->next=entry; 323 | entry->previous=previous; 324 | entry->next=p; 325 | p->previous=entry; 326 | } 327 | } 328 | else 329 | { 330 | OrbisFileBrowserListEntry *tail=browserList->tail; 331 | tail->next=entry; 332 | browserList->tail=entry; 333 | } 334 | } 335 | 336 | browserList->length++; 337 | } 338 | int orbisFileBrowserGetDirectoryEntries(char *path) 339 | { 340 | int type=0; 341 | int dfd=ps4LinkDopen(path); 342 | if (dfd<0) 343 | return dfd; 344 | 345 | OrbisFileBrowserListEntry *entry=malloc(sizeof(OrbisFileBrowserListEntry)); 346 | strcpy(entry->name,DIR_UP); 347 | entry->type=FILE_TYPE_FOLDER; 348 | orbisFileBrowserListAddEntry(entry,SORT_BY_NAME_AND_FOLDER); 349 | 350 | int res=0; 351 | 352 | do 353 | { 354 | struct dirent dir; 355 | memset(&dir,0,sizeof(struct dirent)); 356 | 357 | res=ps4LinkDread(dfd,&dir); 358 | if(res>0) 359 | { 360 | if(strcmp(dir.d_name,".")==0 || strcmp(dir.d_name,"..")==0) 361 | continue; 362 | 363 | OrbisFileBrowserListEntry *entry=malloc(sizeof(OrbisFileBrowserListEntry)); 364 | 365 | strcpy(entry->name,dir.d_name); 366 | 367 | if(dir.d_type!=DT_DIR) 368 | { 369 | type=orbisFileBrowserGetFileType(entry->name); 370 | if(type==FILE_TYPE_ROM) 371 | { 372 | if(strcmp(path,"system")==0) 373 | { 374 | entry->type=FILE_TYPE_SYSTEM_ROM; 375 | } 376 | else 377 | { 378 | entry->type=FILE_TYPE_GAME_ROM; 379 | 380 | } 381 | } 382 | if(type==FILE_TYPE_DSK) 383 | { 384 | entry->type=FILE_TYPE_GAME_DSK; 385 | 386 | } 387 | if(type==FILE_TYPE_CAS) 388 | { 389 | entry->type=FILE_TYPE_CAS; 390 | 391 | } 392 | } 393 | else 394 | { 395 | entry->type=dir.d_type; 396 | } 397 | orbisFileBrowserListAddEntry(entry,SORT_BY_NAME_AND_FOLDER); 398 | } 399 | }while(res>0); 400 | 401 | ps4LinkDclose(dfd); 402 | 403 | return 0; 404 | } 405 | 406 | int orbisFileBrowserGetDevices() 407 | { 408 | int i; 409 | for(i=0;iname,devices[i]); 416 | entry->type=FILE_TYPE_FOLDER; 417 | orbisFileBrowserListAddEntry(entry,SORT_BY_NAME_AND_FOLDER); 418 | 419 | } 420 | } 421 | 422 | return 0; 423 | } 424 | int orbisFileBrowserListGetEntries(char *path) 425 | { 426 | 427 | if(strcmp(path,ROOT_PATH)==0) 428 | { 429 | return orbisFileBrowserGetDevices(); 430 | } 431 | 432 | return orbisFileBrowserGetDirectoryEntries(path); 433 | 434 | } 435 | int orbisFileBrowserInit(char *path) 436 | { 437 | if(!orbisFileBrowserInitialized) 438 | { 439 | 440 | browserList=malloc(sizeof(OrbisFileBrowserList)); 441 | if(browserList) 442 | { 443 | orbisFileBrowserListClean(); 444 | if(path==NULL) 445 | { 446 | strcpy(browserList->path, ROOT_PATH); 447 | } 448 | else 449 | { 450 | strcpy(browserList->path, path); 451 | 452 | } 453 | orbisFileBrowserListGetEntries(browserList->path); 454 | 455 | } 456 | else 457 | { 458 | return -1; 459 | } 460 | orbisFileBrowserInitialized=1; 461 | } 462 | else 463 | { 464 | orbisFileBrowserListClean(); 465 | } 466 | strcpy(browserList->path, ROOT_PATH); 467 | return orbisFileBrowserInitialized; 468 | } 469 | void orbisFileBrowserFinish() 470 | { 471 | orbisFileBrowserListClean(); 472 | if(browserList) 473 | free(browserList); 474 | orbisFileBrowserInitialized=0; 475 | } 476 | -------------------------------------------------------------------------------- /liborbis2d/source/orbis2d.c: -------------------------------------------------------------------------------- 1 | /* 2 | * liborbis 3 | * Copyright (C) 2015,2016,2017 Antonio Jose Ramos Marquez (aka bigboss) @psxdev on twitter 4 | * Repository https://github.com/psxdev/liborbis 5 | */ 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #include "orbis2d.h" 19 | #include "logdebug.h" 20 | 21 | Orbis2dConfig *orbconf=NULL; 22 | int orbis2d_external_conf=-1; 23 | int64_t flipArgCounter=0; 24 | 25 | void orbis2dFinish() 26 | { 27 | int ret; 28 | if(orbis2d_external_conf!=1) 29 | { 30 | if(orbconf->orbis2d_initialized==1) 31 | { 32 | ret=sceVideoOutClose(orbconf->videoHandle); 33 | 34 | sys_log("liborbis2d sceVideoOutClose return 0x%8x\n",ret); 35 | } 36 | orbconf->orbis2d_initialized=-1; 37 | sys_log("liborbis2d finished\n"); 38 | } 39 | } 40 | 41 | Orbis2dConfig *orbis2dGetConf() 42 | { 43 | if(orbconf) 44 | { 45 | return orbconf; 46 | } 47 | 48 | return NULL; 49 | } 50 | int orbis2dCreateConf() 51 | { 52 | if(!orbconf) 53 | { 54 | orbconf=(Orbis2dConfig *)malloc(sizeof(Orbis2dConfig)); 55 | 56 | orbconf->bgColor=0x80ffffff; //white 57 | orbconf->videoMemStackAddr=0; 58 | orbconf->videoMemStackSize=1024*1024* 192; 59 | orbconf->videoMemStackTopAddr=0; 60 | orbconf->videoMemStackBaseAddr=0; 61 | orbconf->videoMemOffset=0; 62 | orbconf->width=ATTR_WIDTH; 63 | orbconf->pitch=ATTR_WIDTH; 64 | orbconf->height=ATTR_HEIGHT; 65 | orbconf->pixelFormat=0x80000000; 66 | orbconf->bytesPerPixel=4; 67 | orbconf->tilingMode=ORBIS2D_MODE_LINEAR; 68 | orbconf->flipMode=ORBIS2D_FLIP_MODE_VSYNC; 69 | orbconf->flipRate=ORBIS2D_FLIP_RATE; 70 | orbconf->videoHandle=-1; 71 | orbconf->currentBuffer=0; 72 | orbconf->orbis2d_initialized=-1; 73 | 74 | return 0; 75 | } 76 | 77 | if(orbconf->orbis2d_initialized==1) 78 | { 79 | return orbconf->orbis2d_initialized; 80 | } 81 | //something weird happened 82 | return -1; 83 | } 84 | int orbis2dSetConf(Orbis2dConfig *conf) 85 | { 86 | if(conf) 87 | { 88 | orbconf=conf; 89 | orbis2d_external_conf=1; 90 | return orbconf->orbis2d_initialized; 91 | } 92 | 93 | return 0; 94 | } 95 | int orbis2dInitWithConf(Orbis2dConfig *conf) 96 | { 97 | int ret; 98 | ret=orbis2dSetConf(conf); 99 | if(ret) 100 | { 101 | sys_log("liborbis2d already initialized using configuration external\n"); 102 | sys_log("orbis2d_initialized=%d\n",orbconf->orbis2d_initialized); 103 | sys_log("ready to have a lot of fun...\n"); 104 | return orbconf->orbis2d_initialized; 105 | } 106 | else 107 | { 108 | return 0; 109 | } 110 | } 111 | 112 | int orbis2dWaitFlipArg(SceKernelEqueue *flipQueue) 113 | { 114 | int ret; 115 | int event_out; 116 | SceKernelEvent event; 117 | 118 | 119 | while(1) 120 | { 121 | SceVideoOutFlipStatus status; 122 | ret=sceVideoOutGetFlipStatus(orbconf->videoHandle, &status); 123 | if(ret>=0) 124 | { 125 | 126 | if(status.flipArg>=(orbconf->flipArgLog[orbconf->currentBuffer] +1)) 127 | { 128 | return 0; 129 | } 130 | 131 | ret=sceKernelWaitEqueue(*flipQueue, &event, 1, &event_out, 0); 132 | if(ret>=0) 133 | { 134 | //sys_log("liborbis2d sceKernelWaitEqueue return %d\n",ret); 135 | 136 | } 137 | else 138 | { 139 | sys_log("liborbis2d sceKernelWaitEqueue return error 0x%8x\n",ret); 140 | } 141 | } 142 | else 143 | { 144 | sys_log("liborbis2d sceVideoOutGetFlipStatus return error 0x%8x\n",ret); 145 | 146 | } 147 | 148 | } 149 | 150 | 151 | return 0; 152 | 153 | } 154 | void orbis2dFinishDrawing(int64_t flipArg) 155 | { 156 | int ret; 157 | 158 | sceGnmFlushGarlic(); 159 | 160 | // request flip to the buffer 161 | ret=sceVideoOutSubmitFlip(orbconf->videoHandle, orbconf->currentBuffer, orbconf->flipMode, flipArg); 162 | 163 | orbconf->flipArgLog[orbconf->currentBuffer]=flipArg; 164 | 165 | } 166 | void orbis2dStartDrawing() 167 | { 168 | 169 | orbis2dWaitFlipArg(&orbconf->flipQueue); 170 | 171 | } 172 | 173 | void orbis2dDrawPixelColor(int x, int y, uint32_t pixelColor) 174 | { 175 | int color; 176 | int pixel = (y * orbconf->pitch) + x; 177 | 178 | color=pixelColor; 179 | 180 | 181 | ((uint32_t *)orbconf->surfaceAddr[orbconf->currentBuffer])[pixel]=color; 182 | 183 | } 184 | void orbis2dPutImage(uint32_t *buf,int x, int y, int w, int h) 185 | { 186 | int x0, y0; 187 | unsigned int R,G,B; 188 | for(y0=0;y0>24; 209 | B=(buf[y0*w+x0]&0xFF0000)>>16; 210 | G=(buf[y0*w+x0]&0x00FF00)>>8; 211 | R=(buf[y0*w+x0]&0x0000FF); 212 | orbis2dDrawPixelColor(x0,y0,A<<24|R<<16|G<<8|B); 213 | } 214 | } 215 | } 216 | void orbis2dPutImage3(uint32_t *buf,int x, int y, int w, int h) 217 | { 218 | int x0, y0; 219 | unsigned int R,G,B,A; 220 | for(y0=0;y0>24; 225 | B=(buf[y0*w+x0]&0xFF0000)>>16; 226 | G=(buf[y0*w+x0]&0x00FF00)>>8; 227 | R=(buf[y0*w+x0]&0x0000FF); 228 | orbis2dDrawPixelColor(x0,y0,A<<24|B<<16|G<<8|R); 229 | } 230 | } 231 | } 232 | void orbis2dPutImage4(uint32_t *buf,int x, int y, int w, int h) 233 | { 234 | int x0, y0; 235 | unsigned int R,G,B,A; 236 | for(y0=0;y0>24; 241 | B=(buf[y0*w+x0]&0xFF0000)>>16; 242 | G=(buf[y0*w+x0]&0x00FF00)>>8; 243 | R=(buf[y0*w+x0]&0x0000FF); 244 | orbis2dDrawPixelColor(x0,y0,0x80<<24|B<<16|G<<8|R); 245 | } 246 | } 247 | } 248 | void orbis2dPutImage5(uint32_t *buf,int x, int y, int w, int h) 249 | { 250 | int x0, y0; 251 | unsigned int R,G,B,A; 252 | for(y0=0;y0>24; 257 | B=(buf[y0*w+x0]&0xFF0000)>>16; 258 | G=(buf[y0*w+x0]&0x00FF00)>>8; 259 | R=(buf[y0*w+x0]&0x0000FF); 260 | orbis2dDrawPixelColor(x0,y0,0x80<<24|R<<16|G<<8|B); 261 | } 262 | } 263 | } 264 | void orbis2dDrawRectColor(int x, int w, int y, int h, uint32_t color) 265 | { 266 | int x0, y0; 267 | for(y0=y;y0width, 0, orbconf->height, orbconf->bgColor); 278 | } 279 | void orbis2dSwapBuffers() 280 | { 281 | orbconf->currentBuffer=(orbconf->currentBuffer+1)%ORBIS2D_DISPLAY_BUFFER_NUM; 282 | //sys_log("liborbis2d currentBuffer %d\n",orbconf->currentBuffer); 283 | 284 | } 285 | void *orbis2dMalloc(int size) 286 | { 287 | uint64_t offset=orbconf->videoMemStackAddr; 288 | 289 | if((orbconf->videoMemStackAddr+size)>orbconf->videoMemStackTopAddr) 290 | { 291 | sys_log("orbis2dMalloc videoMemStackAddr 0x%lx greater than videoMemStackTopAddr 0x%lx \n",orbconf->videoMemStackAddr,orbconf->videoMemStackTopAddr); 292 | 293 | return NULL; 294 | } 295 | orbconf->videoMemStackAddr+=size; 296 | 297 | return (void *)(offset); 298 | } 299 | void orbis2dAllocDisplayBuffer(int displayBufNum) 300 | { 301 | int i; 302 | 303 | int bufSize=orbconf->pitch*orbconf->height*orbconf->bytesPerPixel; 304 | for (i=0;isurfaceAddr[i]= orbis2dMalloc(bufSize); 307 | sys_log("liborbis2d orbis2dMalloc buffer %d, new pointer %p \n",i, orbconf->surfaceAddr[i]); 308 | 309 | } 310 | sys_log("liborbis2d orbis2dAllocDisplayBuffer done\n"); 311 | } 312 | int orbis2dInitDisplayBuffer(int num, int bufIndexStart) 313 | { 314 | SceVideoOutBufferAttribute attr; 315 | int ret; 316 | sceVideoOutSetBufferAttribute(&attr,orbconf->pixelFormat,orbconf->tilingMode,0,orbconf->width,orbconf->height,orbconf->pitch); 317 | 318 | sys_log("liborbis2d sceVideoOutSetBufferAttribute done\n"); 319 | 320 | ret=sceVideoOutRegisterBuffers(orbconf->videoHandle, bufIndexStart, orbconf->surfaceAddr, num, &attr); 321 | 322 | sys_log("liborbis2d sceVideoOutRegisterBuffers return 0x%8x\n",ret); 323 | 324 | return ret; 325 | } 326 | int orbis2dInitMemory() 327 | { 328 | int ret; 329 | off_t start; 330 | 331 | const uint32_t align=2*1024*1024; 332 | 333 | ret=sceKernelAllocateDirectMemory(0,sceKernelGetDirectMemorySize(),orbconf->videoMemStackSize,align,3,&start); 334 | if(ret==0) 335 | { 336 | 337 | orbconf->videoMemOffset=start; 338 | 339 | void* pointer=NULL; 340 | 341 | ret=sceKernelMapDirectMemory(&pointer,orbconf->videoMemStackSize,0x33,0,start,align); 342 | if(ret==0) 343 | { 344 | orbconf->videoMemStackBaseAddr=(uintptr_t)pointer; 345 | orbconf->videoMemStackTopAddr=orbconf->videoMemStackBaseAddr+orbconf->videoMemStackSize; 346 | orbconf->videoMemStackAddr=orbconf->videoMemStackBaseAddr; 347 | } 348 | } 349 | return ret; 350 | 351 | } 352 | int orbis2dInitVideoHandle() 353 | { 354 | int handle; 355 | int ret; 356 | 357 | handle=sceVideoOutOpen(0xff, 0, 0, NULL); 358 | 359 | if(handle<0) 360 | { 361 | sys_log("liborbis2d sceVideoOutOpen return error 0x%8x\n",handle); 362 | 363 | } 364 | else 365 | { 366 | sys_log("liborbis2d sceVideoOutOpen return video handle 0x%8x\n",handle); 367 | 368 | if(handle>0) 369 | { 370 | ret=sceKernelCreateEqueue(&orbconf->flipQueue,"queue to wait flip"); 371 | if(ret==0) 372 | { 373 | sys_log("sceKernelCreateEqueue return %d\n",ret); 374 | 375 | ret=sceVideoOutAddFlipEvent(orbconf->flipQueue, handle, NULL); 376 | if(ret<0) 377 | { 378 | sys_log("liborbis2d sceVideoOutAddFlipEvent return 0x%8x\n",ret); 379 | ret=sceVideoOutClose(handle); 380 | sys_log("liborbis2d sceVideoOutClose return %d\n",ret); 381 | handle=-1; 382 | } 383 | else 384 | { 385 | sys_log("liborbis2d sceVideoOutAddFlipEvent return %d\n",ret); 386 | } 387 | } 388 | else 389 | { 390 | sys_log("sceKernelCreateEqueue return error 0x%8x\n",ret); 391 | ret=sceVideoOutClose(handle); 392 | sys_log("liborbis2d sceVideoOutClose return %d\n",ret); 393 | 394 | handle=-1; 395 | } 396 | } 397 | } 398 | return handle; 399 | } 400 | int orbis2dInit() 401 | { 402 | int ret; 403 | int bufIndex; 404 | 405 | if(orbis2dCreateConf()==1) 406 | { 407 | return orbconf->orbis2d_initialized; 408 | } 409 | if (orbconf->orbis2d_initialized==1) 410 | { 411 | sys_log("liborbis2d is already initialized!\n"); 412 | return orbconf->orbis2d_initialized; 413 | } 414 | //Get video handle 415 | orbconf->videoHandle=orbis2dInitVideoHandle(); 416 | 417 | 418 | if(orbconf->videoHandle>0) 419 | { 420 | //init memory 421 | ret=orbis2dInitMemory(); 422 | 423 | if(ret==0) 424 | { 425 | sys_log("liborbis2d video memory initialized\n"); 426 | 427 | //init memory for display buffers 428 | orbis2dAllocDisplayBuffer(ORBIS2D_DISPLAY_BUFFER_NUM); 429 | 430 | // register display buffers 431 | orbis2dInitDisplayBuffer(ORBIS2D_DISPLAY_BUFFER_NUM,0); 432 | 433 | // set status of each buffer with flipArg 434 | for(bufIndex=0;bufIndexflipArgLog[bufIndex]= -2; 437 | } 438 | 439 | // prepare initial clear color to the display buffers 440 | for (bufIndex=0;bufIndexvideoHandle,ORBIS2D_FLIP_RATE); 447 | } 448 | 449 | 450 | 451 | orbconf->orbis2d_initialized=1; 452 | sys_log("liborbis2d initialized\n"); 453 | 454 | } 455 | return orbconf->orbis2d_initialized; 456 | } 457 | 458 | -------------------------------------------------------------------------------- /portlibs/zlib/source/minigzip.c: -------------------------------------------------------------------------------- 1 | /* minigzip.c -- simulate gzip using the zlib compression library 2 | * Copyright (C) 1995-2006, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* 7 | * minigzip is a minimal implementation of the gzip utility. This is 8 | * only an example of using zlib and isn't meant to replace the 9 | * full-featured gzip. No attempt is made to deal with file systems 10 | * limiting names to 14 or 8+3 characters, etc... Error checking is 11 | * very limited. So use minigzip only for testing; use gzip for the 12 | * real thing. On MSDOS, use only on file names without extension 13 | * or in pipe mode. 14 | */ 15 | 16 | /* @(#) $Id$ */ 17 | 18 | #include "zlib.h" 19 | #include 20 | 21 | #ifdef STDC 22 | # include 23 | # include 24 | #endif 25 | 26 | #ifdef USE_MMAP 27 | # include 28 | # include 29 | # include 30 | #endif 31 | 32 | #if defined(MSDOS) || defined(OS2) || defined(WIN32) || defined(__CYGWIN__) 33 | # include 34 | # include 35 | # ifdef UNDER_CE 36 | # include 37 | # endif 38 | # define SET_BINARY_MODE(file) setmode(fileno(file), O_BINARY) 39 | #else 40 | # define SET_BINARY_MODE(file) 41 | #endif 42 | 43 | #ifdef VMS 44 | # define unlink delete 45 | # define GZ_SUFFIX "-gz" 46 | #endif 47 | #ifdef RISCOS 48 | # define unlink remove 49 | # define GZ_SUFFIX "-gz" 50 | # define fileno(file) file->__file 51 | #endif 52 | 53 | #if !defined(Z_HAVE_UNISTD_H) && !defined(_LARGEFILE64_SOURCE) 54 | #ifndef WIN32 /* unlink already in stdio.h for WIN32 */ 55 | extern int unlink OF((const char *)); 56 | #endif 57 | #endif 58 | 59 | #if defined(UNDER_CE) 60 | # include 61 | # define perror(s) pwinerror(s) 62 | 63 | /* Map the Windows error number in ERROR to a locale-dependent error 64 | message string and return a pointer to it. Typically, the values 65 | for ERROR come from GetLastError. 66 | 67 | The string pointed to shall not be modified by the application, 68 | but may be overwritten by a subsequent call to strwinerror 69 | 70 | The strwinerror function does not change the current setting 71 | of GetLastError. */ 72 | 73 | static char *strwinerror (error) 74 | DWORD error; 75 | { 76 | static char buf[1024]; 77 | 78 | wchar_t *msgbuf; 79 | DWORD lasterr = GetLastError(); 80 | DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM 81 | | FORMAT_MESSAGE_ALLOCATE_BUFFER, 82 | NULL, 83 | error, 84 | 0, /* Default language */ 85 | (LPVOID)&msgbuf, 86 | 0, 87 | NULL); 88 | if (chars != 0) { 89 | /* If there is an \r\n appended, zap it. */ 90 | if (chars >= 2 91 | && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { 92 | chars -= 2; 93 | msgbuf[chars] = 0; 94 | } 95 | 96 | if (chars > sizeof (buf) - 1) { 97 | chars = sizeof (buf) - 1; 98 | msgbuf[chars] = 0; 99 | } 100 | 101 | wcstombs(buf, msgbuf, chars + 1); 102 | LocalFree(msgbuf); 103 | } 104 | else { 105 | sprintf(buf, "unknown win32 error (%ld)", error); 106 | } 107 | 108 | SetLastError(lasterr); 109 | return buf; 110 | } 111 | 112 | static void pwinerror (s) 113 | const char *s; 114 | { 115 | if (s && *s) 116 | fprintf(stderr, "%s: %s\n", s, strwinerror(GetLastError ())); 117 | else 118 | fprintf(stderr, "%s\n", strwinerror(GetLastError ())); 119 | } 120 | 121 | #endif /* UNDER_CE */ 122 | 123 | #ifndef GZ_SUFFIX 124 | # define GZ_SUFFIX ".gz" 125 | #endif 126 | #define SUFFIX_LEN (sizeof(GZ_SUFFIX)-1) 127 | 128 | #define BUFLEN 16384 129 | #define MAX_NAME_LEN 1024 130 | 131 | #ifdef MAXSEG_64K 132 | # define local static 133 | /* Needed for systems with limitation on stack size. */ 134 | #else 135 | # define local 136 | #endif 137 | 138 | char *prog; 139 | 140 | void error OF((const char *msg)); 141 | void gz_compress OF((FILE *in, gzFile out)); 142 | #ifdef USE_MMAP 143 | int gz_compress_mmap OF((FILE *in, gzFile out)); 144 | #endif 145 | void gz_uncompress OF((gzFile in, FILE *out)); 146 | void file_compress OF((char *file, char *mode)); 147 | void file_uncompress OF((char *file)); 148 | int main OF((int argc, char *argv[])); 149 | 150 | /* =========================================================================== 151 | * Display error message and exit 152 | */ 153 | void error(msg) 154 | const char *msg; 155 | { 156 | fprintf(stderr, "%s: %s\n", prog, msg); 157 | exit(1); 158 | } 159 | 160 | /* =========================================================================== 161 | * Compress input to output then close both files. 162 | */ 163 | 164 | void gz_compress(in, out) 165 | FILE *in; 166 | gzFile out; 167 | { 168 | local char buf[BUFLEN]; 169 | int len; 170 | int err; 171 | 172 | #ifdef USE_MMAP 173 | /* Try first compressing with mmap. If mmap fails (minigzip used in a 174 | * pipe), use the normal fread loop. 175 | */ 176 | if (gz_compress_mmap(in, out) == Z_OK) return; 177 | #endif 178 | for (;;) { 179 | len = (int)fread(buf, 1, sizeof(buf), in); 180 | if (ferror(in)) { 181 | perror("fread"); 182 | exit(1); 183 | } 184 | if (len == 0) break; 185 | 186 | if (gzwrite(out, buf, (unsigned)len) != len) error(gzerror(out, &err)); 187 | } 188 | fclose(in); 189 | if (gzclose(out) != Z_OK) error("failed gzclose"); 190 | } 191 | 192 | #ifdef USE_MMAP /* MMAP version, Miguel Albrecht */ 193 | 194 | /* Try compressing the input file at once using mmap. Return Z_OK if 195 | * if success, Z_ERRNO otherwise. 196 | */ 197 | int gz_compress_mmap(in, out) 198 | FILE *in; 199 | gzFile out; 200 | { 201 | int len; 202 | int err; 203 | int ifd = fileno(in); 204 | caddr_t buf; /* mmap'ed buffer for the entire input file */ 205 | off_t buf_len; /* length of the input file */ 206 | struct stat sb; 207 | 208 | /* Determine the size of the file, needed for mmap: */ 209 | if (fstat(ifd, &sb) < 0) return Z_ERRNO; 210 | buf_len = sb.st_size; 211 | if (buf_len <= 0) return Z_ERRNO; 212 | 213 | /* Now do the actual mmap: */ 214 | buf = mmap((caddr_t) 0, buf_len, PROT_READ, MAP_SHARED, ifd, (off_t)0); 215 | if (buf == (caddr_t)(-1)) return Z_ERRNO; 216 | 217 | /* Compress the whole file at once: */ 218 | len = gzwrite(out, (char *)buf, (unsigned)buf_len); 219 | 220 | if (len != (int)buf_len) error(gzerror(out, &err)); 221 | 222 | munmap(buf, buf_len); 223 | fclose(in); 224 | if (gzclose(out) != Z_OK) error("failed gzclose"); 225 | return Z_OK; 226 | } 227 | #endif /* USE_MMAP */ 228 | 229 | /* =========================================================================== 230 | * Uncompress input to output then close both files. 231 | */ 232 | void gz_uncompress(in, out) 233 | gzFile in; 234 | FILE *out; 235 | { 236 | local char buf[BUFLEN]; 237 | int len; 238 | int err; 239 | 240 | for (;;) { 241 | len = gzread(in, buf, sizeof(buf)); 242 | if (len < 0) error (gzerror(in, &err)); 243 | if (len == 0) break; 244 | 245 | if ((int)fwrite(buf, 1, (unsigned)len, out) != len) { 246 | error("failed fwrite"); 247 | } 248 | } 249 | if (fclose(out)) error("failed fclose"); 250 | 251 | if (gzclose(in) != Z_OK) error("failed gzclose"); 252 | } 253 | 254 | 255 | /* =========================================================================== 256 | * Compress the given file: create a corresponding .gz file and remove the 257 | * original. 258 | */ 259 | void file_compress(file, mode) 260 | char *file; 261 | char *mode; 262 | { 263 | local char outfile[MAX_NAME_LEN]; 264 | FILE *in; 265 | gzFile out; 266 | 267 | if (strlen(file) + strlen(GZ_SUFFIX) >= sizeof(outfile)) { 268 | fprintf(stderr, "%s: filename too long\n", prog); 269 | exit(1); 270 | } 271 | 272 | strcpy(outfile, file); 273 | strcat(outfile, GZ_SUFFIX); 274 | 275 | in = fopen(file, "rb"); 276 | if (in == NULL) { 277 | perror(file); 278 | exit(1); 279 | } 280 | out = gzopen(outfile, mode); 281 | if (out == NULL) { 282 | fprintf(stderr, "%s: can't gzopen %s\n", prog, outfile); 283 | exit(1); 284 | } 285 | gz_compress(in, out); 286 | 287 | unlink(file); 288 | } 289 | 290 | 291 | /* =========================================================================== 292 | * Uncompress the given file and remove the original. 293 | */ 294 | void file_uncompress(file) 295 | char *file; 296 | { 297 | local char buf[MAX_NAME_LEN]; 298 | char *infile, *outfile; 299 | FILE *out; 300 | gzFile in; 301 | size_t len = strlen(file); 302 | 303 | if (len + strlen(GZ_SUFFIX) >= sizeof(buf)) { 304 | fprintf(stderr, "%s: filename too long\n", prog); 305 | exit(1); 306 | } 307 | 308 | strcpy(buf, file); 309 | 310 | if (len > SUFFIX_LEN && strcmp(file+len-SUFFIX_LEN, GZ_SUFFIX) == 0) { 311 | infile = file; 312 | outfile = buf; 313 | outfile[len-3] = '\0'; 314 | } else { 315 | outfile = file; 316 | infile = buf; 317 | strcat(infile, GZ_SUFFIX); 318 | } 319 | in = gzopen(infile, "rb"); 320 | if (in == NULL) { 321 | fprintf(stderr, "%s: can't gzopen %s\n", prog, infile); 322 | exit(1); 323 | } 324 | out = fopen(outfile, "wb"); 325 | if (out == NULL) { 326 | perror(file); 327 | exit(1); 328 | } 329 | 330 | gz_uncompress(in, out); 331 | 332 | unlink(infile); 333 | } 334 | 335 | 336 | /* =========================================================================== 337 | * Usage: minigzip [-c] [-d] [-f] [-h] [-r] [-1 to -9] [files...] 338 | * -c : write to standard output 339 | * -d : decompress 340 | * -f : compress with Z_FILTERED 341 | * -h : compress with Z_HUFFMAN_ONLY 342 | * -r : compress with Z_RLE 343 | * -1 to -9 : compression level 344 | */ 345 | 346 | int main(argc, argv) 347 | int argc; 348 | char *argv[]; 349 | { 350 | int copyout = 0; 351 | int uncompr = 0; 352 | gzFile file; 353 | char *bname, outmode[20]; 354 | 355 | strcpy(outmode, "wb6 "); 356 | 357 | prog = argv[0]; 358 | bname = strrchr(argv[0], '/'); 359 | if (bname) 360 | bname++; 361 | else 362 | bname = argv[0]; 363 | argc--, argv++; 364 | 365 | if (!strcmp(bname, "gunzip")) 366 | uncompr = 1; 367 | else if (!strcmp(bname, "zcat")) 368 | copyout = uncompr = 1; 369 | 370 | while (argc > 0) { 371 | if (strcmp(*argv, "-c") == 0) 372 | copyout = 1; 373 | else if (strcmp(*argv, "-d") == 0) 374 | uncompr = 1; 375 | else if (strcmp(*argv, "-f") == 0) 376 | outmode[3] = 'f'; 377 | else if (strcmp(*argv, "-h") == 0) 378 | outmode[3] = 'h'; 379 | else if (strcmp(*argv, "-r") == 0) 380 | outmode[3] = 'R'; 381 | else if ((*argv)[0] == '-' && (*argv)[1] >= '1' && (*argv)[1] <= '9' && 382 | (*argv)[2] == 0) 383 | outmode[2] = (*argv)[1]; 384 | else 385 | break; 386 | argc--, argv++; 387 | } 388 | if (outmode[3] == ' ') 389 | outmode[3] = 0; 390 | if (argc == 0) { 391 | SET_BINARY_MODE(stdin); 392 | SET_BINARY_MODE(stdout); 393 | if (uncompr) { 394 | file = gzdopen(fileno(stdin), "rb"); 395 | if (file == NULL) error("can't gzdopen stdin"); 396 | gz_uncompress(file, stdout); 397 | } else { 398 | file = gzdopen(fileno(stdout), outmode); 399 | if (file == NULL) error("can't gzdopen stdout"); 400 | gz_compress(stdin, file); 401 | } 402 | } else { 403 | if (copyout) { 404 | SET_BINARY_MODE(stdout); 405 | } 406 | do { 407 | if (uncompr) { 408 | if (copyout) { 409 | file = gzopen(*argv, "rb"); 410 | if (file == NULL) 411 | fprintf(stderr, "%s: can't gzopen %s\n", prog, *argv); 412 | else 413 | gz_uncompress(file, stdout); 414 | } else { 415 | file_uncompress(*argv); 416 | } 417 | } else { 418 | if (copyout) { 419 | FILE * in = fopen(*argv, "rb"); 420 | 421 | if (in == NULL) { 422 | perror(*argv); 423 | } else { 424 | file = gzdopen(fileno(stdout), outmode); 425 | if (file == NULL) error("can't gzdopen stdout"); 426 | 427 | gz_compress(in, file); 428 | } 429 | 430 | } else { 431 | file_compress(*argv, outmode); 432 | } 433 | } 434 | } while (argv++, --argc); 435 | } 436 | return 0; 437 | } 438 | --------------------------------------------------------------------------------