Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define VITASDK
- #include <psp2/sysmodule.h>
- #include <psp2/kernel/processmgr.h>
- #include <psp2/display.h>
- #include <psp2/net/net.h>
- #include <psp2/net/netctl.h>
- #include <psp2/net/http.h>
- #include <psp2/io/fcntl.h>
- #include <stdio.h>
- #include <malloc.h>
- #include <string.h>
- #include "debugScreen.h"
- void netInit() {
- psvDebugScreenPrintf("Loading module SCE_SYSMODULE_NET\n");
- sceSysmoduleLoadModule(SCE_SYSMODULE_NET);
- psvDebugScreenPrintf("Running sceNetInit\n");
- SceNetInitParam netInitParam;
- int size = 1*1024*1024;
- netInitParam.memory = malloc(size);
- netInitParam.size = size;
- netInitParam.flags = 0;
- sceNetInit(&netInitParam);
- psvDebugScreenPrintf("Running sceNetCtlInit\n");
- sceNetCtlInit();
- }
- void netTerm() {
- psvDebugScreenPrintf("Running sceNetCtlTerm\n");
- sceNetCtlTerm();
- psvDebugScreenPrintf("Running sceNetTerm\n");
- sceNetTerm();
- psvDebugScreenPrintf("Unloading module SCE_SYSMODULE_NET\n");
- sceSysmoduleUnloadModule(SCE_SYSMODULE_NET);
- }
- void httpInit() {
- psvDebugScreenPrintf("Loading module SCE_SYSMODULE_HTTP\n");
- sceSysmoduleLoadModule(SCE_SYSMODULE_HTTP);
- psvDebugScreenPrintf("Running sceHttpInit\n");
- sceHttpInit(1*1024*1024);
- }
- void httpTerm() {
- psvDebugScreenPrintf("Running sceHttpTerm\n");
- sceHttpTerm();
- psvDebugScreenPrintf("Unloading module SCE_SYSMODULE_HTTP\n");
- sceSysmoduleUnloadModule(SCE_SYSMODULE_HTTP);
- }
- int main(int argc, char *argv[]) {
- psvDebugScreenInit();
- psvDebugScreenPrintf("(HTTP Sample v.1.0 by barooney) modified\n\n");
- netInit();
- httpInit();
- /*
- RELEVANT
- */
- char* url = "http://192.168.1.234/test.php";
- char* dest = "ux0:data/VSDK00009/index.html";
- char* postData="test=happyman";
- // Create template with user agend "PS Vita Sample App"
- int tpl = sceHttpCreateTemplate("PS Vita Sample App", 1, 1);
- // set url on the template
- int conn = sceHttpCreateConnectionWithURL(tpl, url, 0);
- // create the request with the correct method
- int request = sceHttpCreateRequestWithURL(conn, SCE_HTTP_METHOD_POST, url, strlen(postData));
- // send the actual request. Second parameter would be POST data, third would be length of it.
- int handle = sceHttpSendRequest(request, postData, strlen(postData));
- /*
- Less RELEVANT?
- */
- int fh = sceIoOpen(dest, SCE_O_WRONLY | SCE_O_CREAT, 0777);
- unsigned char data[16*1024];
- int read = 0;
- while ((read = sceHttpReadData(request, &data, sizeof(data))) > 0) {
- int write = sceIoWrite(fh, data, read);
- }
- // close file
- sceIoClose(fh);
- httpTerm();
- netTerm();
- sceKernelExitProcess(0);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement