orbisdev / liborbis

Libraries and samples for PlayStation 4
63 stars 22 forks source link

Network examples #24

Open pquerner opened 5 years ago

pquerner commented 5 years ago

Is it possible to add light example code for http networking? I've read through the sdk chm and tried to get demo code running, however it fails at compiling.

libhttp.h file used https://raw.githubusercontent.com/lammertb/libhttp/master/include/libhttp.h (dont know if this is correct)

clang  -c source/main.c -std=c11 -O3 -Wall -m64 -mcmodel=large -Wno-zero-length-array -Wno-format-pedantic -I. -Iinclude  -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-stack-protector -D__PS4__ -I/usr/local/ps4dev/ps4sdk/include -I /usr/local/ps4dev/ps4sdk/include/sce -target x86_64-scei-ps4 -fPIE -o build/main.c.o
source/main.c:330:22: warning: implicit declaration of function 'sceHttpCreateTemplate' is invalid in C99 [-Wimplicit-function-declaration]
        templateId = sceHttpCreateTemplate(libhttpCtxId, USER_AGENT,
                     ^
source/main.c:330:44: error: use of undeclared identifier 'libhttpCtxId'
        templateId = sceHttpCreateTemplate(libhttpCtxId, USER_AGENT,
                                           ^
source/main.c:331:44: error: use of undeclared identifier 'SCE_HTTP_VERSION_1_1'
                                           SCE_HTTP_VERSION_1_1, SCE_TRUE);
                                           ^
source/main.c:331:66: error: use of undeclared identifier 'SCE_TRUE'
                                           SCE_HTTP_VERSION_1_1, SCE_TRUE);
                                                                 ^
source/main.c:336:24: warning: implicit declaration of function 'sceHttpCreateConnection' is invalid in C99 [-Wimplicit-function-declaration]
        connectionId = sceHttpCreateConnection(templateId, SERVER, SCHEME,
                       ^
source/main.c:337:54: error: use of undeclared identifier 'SCE_TRUE'
                                               PORT, SCE_TRUE);
                                                     ^
source/main.c:341:27: error: expected expression
        if (connectionId) < 0){
                          ^
source/main.c:350:9: error: use of undeclared identifier 'requestId'
        requestId = sceHttpCreateRequestWithURL(connectionId, SCE_HTTP_METHOD_GET,
        ^
source/main.c:350:21: warning: implicit declaration of function 'sceHttpCreateRequestWithURL' is invalid in C99 [-Wimplicit-function-declaration]
        requestId = sceHttpCreateRequestWithURL(connectionId, SCE_HTTP_METHOD_GET,
                    ^
source/main.c:350:63: error: use of undeclared identifier 'SCE_HTTP_METHOD_GET'
        requestId = sceHttpCreateRequestWithURL(connectionId, SCE_HTTP_METHOD_GET,
                                                              ^
source/main.c:352:10: error: expected expression
        */
         ^
source/main.c:353:9: error: expected expression
        if (requestId < 0){
        ^
source/main.c:361:15: warning: implicit declaration of function 'sceHttpSendRequest' is invalid in C99 [-Wimplicit-function-declaration]
        ret = sceHttpSendRequest(requestId, NULL, 0);
              ^
source/main.c:361:34: error: use of undeclared identifier 'requestId'
        ret = sceHttpSendRequest(requestId, NULL, 0);
                                 ^
source/main.c:367:15: error: expected ';' after expression
        uint64 t contentLength;
              ^
              ;
source/main.c:367:9: error: use of undeclared identifier 'uint64'
        uint64 t contentLength;
        ^
source/main.c:367:16: error: use of undeclared identifier 't'
        uint64 t contentLength;
               ^
source/main.c:370:15: warning: implicit declaration of function 'sceHttpGetStatusCode' is invalid in C99 [-Wimplicit-function-declaration]
        ret = sceHttpGetStatusCode(requestId, &statusCode);
              ^
source/main.c:370:36: error: use of undeclared identifier 'requestId'
        ret = sceHttpGetStatusCode(requestId, &statusCode);
                                   ^
source/main.c:375:15: warning: implicit declaration of function 'sceHttpGetResponseContentLength' is invalid in C99 [-Wimplicit-function-declaration]
        ret = sceHttpGetResponseContentLength(requestId, &result, &contentLength);
              ^
source/main.c:375:47: error: use of undeclared identifier 'requestId'
        ret = sceHttpGetResponseContentLength(requestId, &result, &contentLength);
                                              ^
source/main.c:375:68: error: use of undeclared identifier 'contentLength'
        ret = sceHttpGetResponseContentLength(requestId, &result, &contentLength);
                                                                   ^
6 warnings and 16 errors generated.
/usr/local/ps4dev/ps4sdk/make/ps4sdk.mk:178: recipe for target 'build/main.c.o' failed
make: *** [build/main.c.o] Error 1
LinkerFlags+=-ldebugnet -lps4link -lelfloader -lorbis2d -lorbisPad -lorbisAudio -lorbisXbmFont -lmod -lSceNet_stub -lSceAudioOut_stub -lSceHttp_stub -lSceVideoOut_stub -lSceSystemService_stub -lSceUserService_stub -lSceGnmDriver_stub -lScePad_stub
pquerner commented 5 years ago

My understanding now is, that a "wrapper" is missing for now. (Like libdebugnet is a wrapper for the sceSocket stuff)

Maybe https://github.com/vitasdk/samples/blob/master/net_http/src/main.c helps porting this, as it looks quite similar. I will try this evening.

psxdev commented 5 years ago

you will need add stubs for libraries that are not there right now, check https://github.com/idc/ps4libdoc forn name functions of each stub that you need to use

on ps4sdk check core directory there are the different stubs to generate libraries