 |
forums.ps2dev.org Homebrew PS2, PSP & PS3 Development Discussions
|
| View previous topic :: View next topic |
| Author |
Message |
carvalhotk
Joined: 22 Oct 2009 Posts: 4
|
Posted: Mon Oct 26, 2009 1:37 am Post subject: How to handle stdout and stderr on PSP? |
|
|
Hello, there.
The question is that: how is the right way to handle stdout and stderr on the PSP? I mean, I can't just use pspDebugScreenPrintf, because the libraries that are extern to my program don't use it. So, I fell like I have to redirect the output to files, but as I have seen, it's not a good way to do it.
For example, if I use the following code:
| Code: | FILE *fp_out = NULL;
FILE *fp_err = NULL;
void PSP_quit()
{
if (fp_out) {
fclose(fp_out);
}
if (fp_err) {
fclose(fp_err);
}
sceKernelExitGame();
}
int main(int argc, char **argv)
{
[ setup the exit callback... ]
fp_out = freopen("stdout", "w", stdout);
fp_err = freopen("stderr", "w", stderr);
atexit(PSP_quit);
[ run my program, use puts on my Ruby scripts, and so ...]
exit(EXIT_SUCCESS);
} |
It'll not work. Ive tried to run the following ruby script:
| Code: | i = 0
while i < 100
puts "Iteration #{i.to_s}"
i += 1
end |
The program runs fine, finalizes fine, but my stdout looks like:
| Code: | Iteration 0
Iteration 1
[...]
Iteration 76
Iterat
EOF |
Thank you guys. |
|
| Back to top |
|
 |
jimparis
Joined: 10 Jun 2005 Posts: 1179 Location: Boston
|
Posted: Mon Oct 26, 2009 2:43 am Post subject: |
|
|
| Are you sure the atexit handler is being called? |
|
| Back to top |
|
 |
willow :--)
Joined: 13 Jan 2007 Posts: 126
|
Posted: Mon Oct 26, 2009 12:18 pm Post subject: |
|
|
stderr works correctly if you test your application through PSPLink, no Voodoo magic is required, so I'm not entirely sure what you're trying to accomplish... _________________ Wagic. Play that card game against an AI on your PSP |
|
| Back to top |
|
 |
liberty
Joined: 16 Sep 2009 Posts: 35
|
Posted: Thu Oct 29, 2009 6:14 am Post subject: Re: How to handle stdout and stderr on PSP? |
|
|
| carvalhotk wrote: | Hello, there.
The question is that: how is the right way to handle stdout and stderr on the PSP? I mean, I can't just use pspDebugScreenPrintf, because the libraries that are extern to my program don't use it. So, I fell like I have to redirect the output to files, but as I have seen, it's not a good way to do it.
For example, if I use the following code:
| Code: | FILE *fp_out = NULL;
FILE *fp_err = NULL;
void PSP_quit()
{
if (fp_out) {
fclose(fp_out);
}
if (fp_err) {
fclose(fp_err);
}
sceKernelExitGame();
}
int main(int argc, char **argv)
{
[ setup the exit callback... ]
fp_out = freopen("stdout", "w", stdout);
fp_err = freopen("stderr", "w", stderr);
atexit(PSP_quit);
[ run my program, use puts on my Ruby scripts, and so ...]
exit(EXIT_SUCCESS);
} |
It'll not work. Ive tried to run the following ruby script:
| Code: | i = 0
while i < 100
puts "Iteration #{i.to_s}"
i += 1
end |
The program runs fine, finalizes fine, but my stdout looks like:
| Code: | Iteration 0
Iteration 1
[...]
Iteration 76
Iterat
EOF |
Thank you guys. |
You can just include stdio.h and do not redefine printf then you can use standard C library and get output from PSPLink, |
|
| Back to top |
|
 |
carvalhotk
Joined: 22 Oct 2009 Posts: 4
|
Posted: Tue Nov 03, 2009 3:41 am Post subject: |
|
|
| Thank you, guys. This psplink thing is amazing! |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|