Jim wrote:It's only guaranteed to be 0 if you declare it at global scope or you declare it as 'static' (and your C runtime is clearing it out at startup) . Otherwise automatic variables at function scope are undefined.
Jim
Yes, first posted, I corrected the startup code, see the new one:
Code: Select all
void loadmodules(int free)
{
scr_printf("Carregando modulos");
s32 ret;
int rv;
char* IP = "192.168.2.12";
char* NM = "255.255.255.0";
char* GW = "192.168.2.1";
char *args = malloc(strlen(IP) + strlen(NM) + strlen(GW));
int a = 0;
rv=SifExecModuleBuffer(freesio2, size_freesio2, 0, NULL, &ret);
scr_printf("Carregando freesio2: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(freepad, size_freepad, 0, NULL, &ret);
scr_printf("Carregando freepad: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(usbd, size_usbd, 0, NULL, &ret);
scr_printf("Carregando usbd: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(usb_mass, size_usb_mass, 0, NULL, &ret);
scr_printf("Carregando usb_mass: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(poweroff, size_poweroff, 0, NULL, &ret);
scr_printf("Carregando poweroff: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(ps2dev9, size_ps2dev9, 0, NULL, &ret);
scr_printf("Carregando dev9: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(ps2ip, size_ps2ip, 0, NULL, &ret);
scr_printf("Carregando ps2ip: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(dns, size_dns, 0, NULL, &ret);
scr_printf("Carregando dns: %d\n", rv);
if(rv<0) SleepThread();
rv=SifExecModuleBuffer(ps2ips, size_ps2ips, 0, NULL, &ret);
scr_printf("Carregando ps2ips: %d\n", rv);
if(rv<0) SleepThread();
/* load up smap with static settings */
strcpy(&args[a], IP); a += strlen(IP) + 1;
strcpy(&args[a], NM); a += strlen(NM) + 1;
strcpy(&args[a], GW); a += strlen(GW) + 1;
rv=SifExecModuleBuffer(ps2smap, size_ps2smap, a, args, &ret);
scr_printf("Carregando freesio2: %d", rv);
//if(rv<0) SleepThread();
}
Now I could receive a 70KB zipped file and save it to the memory card, whihout (much) problems.
And... why didn't I see THIS:
Code: Select all
poweroff_IMPORTS_start
I_AddPowerOffHandler
poweroff_IMPORTS_end
on the imports.lst file!? Maybe it's my eyes :S
And I didn't know that SifExecModuleBuffer returns an int like SifLoadModule.
Now my little program is fully functional(I just need to don't close the socket on the client, that sends the file, because of the buffered data), I need only to remove the scr_printf's and make my GUI for the program,
Cya!
ps.: If you are interested on my program (veeeery simple), post here or send me a message, It have a server/client for PC and a server for the PS2 (i'm still developing the client). The PC side was built using Visual Studio 2005 (C++.NET), but can be easily ported to C for Windows, Linux, etc.