]> Git repositories of Nishi - tewi.git/commitdiff
kinda works
authorNishi <nishi@nishi.boats>
Sat, 28 Sep 2024 00:07:34 +0000 (00:07 +0000)
committerNishi <nishi@nishi.boats>
Sat, 28 Sep 2024 00:07:34 +0000 (00:07 +0000)
git-svn-id: file:///raid/svn-personal/tewi/trunk@187 8739d7e6-ffea-ec47-b151-bdff447c6205

Platform/ps3.mk [new file with mode: 0644]
Server/Makefile
Server/config.c
Server/http.c
Server/main.c
Server/module.c
Server/server.c
Server/tw_config.h
Server/version.c
config.h.tmpl
psp.sh

diff --git a/Platform/ps3.mk b/Platform/ps3.mk
new file mode 100644 (file)
index 0000000..345fa99
--- /dev/null
@@ -0,0 +1,14 @@
+# $Id$
+
+PREFIX = /dev_hdd0/httpd
+
+CC = ppu-gcc
+AR = ppu-ar
+CFLAGS = -g -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -I /usr/local/ps3dev/ppu/include
+LDFLAGS = -L /usr/local/ps3dev/ppu/lib
+LIBS = -lnet -lsysmodule -lsysutil -lrt -llv2
+EXEC = .elf
+LIB = .so
+MODULE =
+SERVADD = ppu-strip tewi.elf -o tewi_strip.elf
+TARGET = tewi.pkg
index 59c05b624ba3c0017d9cb8f18d1fb049ac832224..306be72be862ef6dc5ffc652793cfaadf35f9ecc 100644 (file)
@@ -21,6 +21,19 @@ tewi.pbp: tewi_strip$(EXEC) param.sfo
 param.sfo:
        mksfoex -d MEMSIZE=1 'Tewi HTTPd' $@
 
+tewi.self: tewi_strip$(EXEC)
+       sprxlinker tewi_strip$(EXEC)
+       make_self_npdrm tewi_strip$(EXEC) $@ UP0001-TEWI_00-0000000000000000
+       fself tewi_strip$(EXEC) tewi.fake.self
+
+tewi.pkg: tewi.self
+       mkdir -p pkg/USRDIR
+       cp /usr/local/ps3dev/bin/ICON0.PNG pkg/ICON0.PNG
+       make_self_npdrm tewi.elf pkg/USRDIR/EBOOT.BIN UP0001-TEWI_00-0000000000000000
+       sfo.py --title "Tewi HTTPd" --appid "TEWI" -f /usr/local/ps3dev/bin/sfo.xml pkg/PARAM.SFO
+       pkg.py --contentid UP0001-TEWI_00-0000000000000000 pkg/ $@
+       rm -rf pkg
+
 .c.o:
        $(CC) $(CFLAGS) $(EXTCFLAGS) -c -o $@ $<
 
@@ -28,4 +41,4 @@ tewi.res: tewi.rc ../Binary/tewi.ico
        $(WINDRES) tewi.rc -O coff -o $@
 
 clean:
-       rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp
+       rm -f *.o tewi *.exe *.res *.elf *.sfo *.pbp *.self *.pkg
index 6c3f0c01093fea5501e2c1cf76b0783945a18cc8..a76cd1aaffce6a312d87df200dbfd59fc9fa04bc 100644 (file)
@@ -101,8 +101,10 @@ void tw_config_init(void) {
        config.server_root = cm_strdup(PREFIX);
        config.server_admin = cm_strdup(SERVER_ADMIN);
        config.defined[0] = NULL;
-#ifdef _PSP
+#if defined(_PSP)
        strcpy(config.hostname, "psp");
+#elif defined(__PPU__)
+       strcpy(config.hostname, "ps3");
 #else
        gethostname(config.hostname, 1024);
 #endif
index 60292647cf0a65e96a91aeb0295d65afb4b502c0..c6d83c066e20ac83f48bcffbd1a60b9714f92f04 100644 (file)
 #include <winsock2.h>
 #else
 #ifdef USE_POLL
+#ifdef __PPU__
+#include <net/poll.h>
+#else
 #include <poll.h>
+#endif
 #else
 #include <sys/select.h>
 #endif
index cc827b203de16595407667e41366c2492953830f..9e902e86561bff28acbc22dd5f380de3438c2d30 100644 (file)
@@ -240,6 +240,9 @@ int main(int argc, char** argv) {
                sceKernelExitGame();
        }
        printf("Connected, My IP is %s\n", info.ip);
+#elif defined(__PPU__)
+       printf("PS3 Bootstrap, Tewi/%s\n", tw_get_version());
+       netInitialize();
 #endif
        int st = startup(argc, argv);
        if(st != -1) {
index 0fc9057ca418f0195e585c50c95fa33351f5b930..f5eb5e68adf32fa1642eccc4f50a61c690aa1113 100644 (file)
@@ -15,7 +15,7 @@
 
 extern struct tw_config config;
 
-#ifdef _PSP
+#if defined(_PSP) || defined(__PPU__)
 void* tw_module_load(const char* path) { return NULL; }
 
 void* tw_module_symbol(void* mod, const char* sym) { return NULL; }
index 5e295c1b92e81876e2c2812ddcf4ce6d9a83bffb..193bf42fbc06f4b1dea7b56964dc809116a255ab 100644 (file)
 #include "strptime.h"
 #else
 #ifdef USE_POLL
+#ifdef __PPU__
+#include <net/poll.h>
+#else
 #include <poll.h>
+#endif
 #else
 #include <sys/select.h>
 #endif
 #include <sys/socket.h>
 #include <arpa/inet.h>
 #include <netinet/in.h>
+#ifndef __PPU__
 #include <netinet/tcp.h>
+#endif
 #ifndef NO_GETADDRINFO
 #include <netdb.h>
 #endif
@@ -135,11 +141,13 @@ int tw_server_init(void) {
                        cm_log("Server", "setsockopt failure (reuseaddr)");
                        return 1;
                }
+#ifndef __PPU__
                if(setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void*)&yes, sizeof(yes)) < 0) {
                        close_socket(sock);
                        cm_log("Server", "setsockopt failure (nodelay)");
                        return 1;
                }
+#endif
 #ifndef NO_IPV6
                int no = 0;
                if(setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (void*)&no, sizeof(no)) < 0) {
@@ -430,10 +438,10 @@ struct pass_entry {
 unsigned int WINAPI tw_server_pass(void* ptr) {
 #elif defined(__HAIKU__)
 int32_t tw_server_pass(void* ptr) {
-#elif defined(_PSP)
+#elif defined(_PSP) || defined(__PPU__)
 int tw_server_pass(void* ptr) {
 #endif
-#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP)
+#if defined(__HAIKU__) || defined(__MINGW32__) || defined(_PSP) || defined(__PPU__)
        int sock = ((struct pass_entry*)ptr)->sock;
        bool ssl = ((struct pass_entry*)ptr)->ssl;
        int port = ((struct pass_entry*)ptr)->port;
@@ -513,7 +521,7 @@ int tw_server_pass(void* ptr) {
                                } else if(cm_strcaseequ(req.headers[i], "If-Modified-Since")) {
                                        struct tm tm;
                                        strptime(req.headers[i + 1], "%a, %d %b %Y %H:%M:%S GMT", &tm);
-#if defined(__MINGW32__) || defined(_PSP)
+#if defined(__MINGW32__) || defined(_PSP) || defined(__PPU__)
                                        time_t t = 0;
                                        struct tm* btm = localtime(&t);
                                        cmtime = mktime(&tm);
@@ -918,7 +926,7 @@ void tw_server_loop(void) {
                                        socklen_t clen = sizeof(claddr);
                                        int sock = accept(sockets[i], (struct sockaddr*)&claddr, &clen);
                                        cm_log("Server", "New connection accepted");
-#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP)
+#if defined(__MINGW32__) || defined(__HAIKU__) || defined(_PSP) || defined(__PPU__)
                                        struct pass_entry* e = malloc(sizeof(*e));
                                        e->sock = sock;
                                        e->ssl = config.ports[i] & (1ULL << 32);
@@ -944,7 +952,7 @@ void tw_server_loop(void) {
                                                        break;
                                                }
                                        }
-#elif defined(_PSP)
+#elif defined(_PSP) || defined(__PPU__)
                                                tw_server_pass(e);
 #elif defined(__HAIKU__)
                                        int j;
index e5485e6fc3626f0ad2bcfa4d3ee2a5e8ecae6930..3e66276919e70194a07746fd2a392ddbb2fdfe29 100644 (file)
@@ -18,6 +18,9 @@ extern "C" {
 #include <winsock2.h>
 #define NO_IPV6
 #else
+#ifdef __PPU__
+#include <net/net.h>
+#endif
 #include <netinet/in.h>
 #ifdef __HAIKU__
 #define NO_IPV6
index 3d49ce3b2cd9363685ce03cecf82c8189c322092..93568a0a8395ba5fa15d6dd3fc2d1ec188a8b715 100644 (file)
@@ -21,6 +21,8 @@ const char* tw_platform =
     "Cygwin"
 #elif defined(_PSP)
     "PSP"
+#elif defined(__PPU__)
+    "PS3"
 #else
     "Unix"
 #endif
index 4b73646ff20af2b21af6aaef121375ce941df466..ac30b97a83507771fd39103ab2c0ae39cfa9dcab 100644 (file)
 /* Windows should not have chroot */
 #endif
 
-#if defined(_PSP) && !defined(NO_IPV6)
+#if (defined(_PSP) || defined(__PPU__)) && !defined(NO_IPV6)
 #define NO_IPV6
-/* PSP does not have IPv6 */
+/* PSP/PS3 does not have IPv6 */
 #endif
 
-#if defined(_PSP) && defined(USE_POLL)
+#if (defined(_PSP)) && defined(USE_POLL)
 #undef USE_POLL
 /* Force select(2) for PSP */
 #endif
 
-#if defined(_PSP) && defined(HAS_CHROOT)
+#if (defined(_PSP) || defined(__PPU__)) && defined(HAS_CHROOT)
 #undef HAS_CHROOT
-/* PSP should not have chroot */
+/* PSP/PS3 should not have chroot */
 #endif
 
-#if defined(_PSP) && !defined(NO_GETADDRINFO)
+#if (defined(_PSP) || defined(__PPU__)) && !defined(NO_GETADDRINFO)
 #define NO_GETADDRINFO
-/* PSP should not have getaddrinfo */
+/* PSP/PS3 should not have getaddrinfo */
 #endif
 
 #endif
diff --git a/psp.sh b/psp.sh
index ad7f58d4e95abb0e4b384415eff2b7cc369b88fe..fe455ab67a31aa58dbf3a2861fc3da001f141b5b 100755 (executable)
--- a/psp.sh
+++ b/psp.sh
@@ -2,6 +2,7 @@
 # $Id$
 export PSPDEV=/usr/local/pspdev
 export PATH=$PATH:/usr/local/pspdev/bin
+cat config.h.tmpl | sed -E 's/#undef (NO_SSL)/#define \1/g' > config.h
 rm -rf httpd
 make PLATFORM=psp DESTDIR=httpd/ install
 mv httpd/ms0:/PSP/GAME/httpd/* httpd/