forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Question about kernel libc

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
kralyk



Joined: 06 Apr 2008
Posts: 114
Location: Czech Republic, central EU

PostPosted: Mon Jun 22, 2009 1:13 am    Post subject: Question about kernel libc Reply with quote

Hi,

I found myself in a need of functions like vsprintf and/or vfprintf in my vsh plugin prx, but those function can't be found in kernel libc.

Is there any chance I could get those functions in kernel libc?
Or are there any other with similar functionality in kernel libc that I could use?
_________________
...sorry for my english...
Back to top
View user's profile Send private message
kralyk



Joined: 06 Apr 2008
Posts: 114
Location: Czech Republic, central EU

PostPosted: Mon Jun 22, 2009 5:28 am    Post subject: Reply with quote

Allright, I found the prnt() function: http://dark-alex.org/pspsdk_docs/pspsysclib_8h.html
How do I use it? Using it via a callback isn't really convenient... :/ oh well...
_________________
...sorry for my english...
Back to top
View user's profile Send private message
sauron_le_noir



Joined: 05 Jul 2008
Posts: 229

PostPosted: Mon Jun 22, 2009 6:06 am    Post subject: Reply with quote

look at this site the code of the printf function
without stdarg
http://www.menie.org/georges/embedded/printf.c
with stdarg
http://www.menie.org/georges/embedded/printf-stdarg.c
Back to top
View user's profile Send private message Send e-mail MSN Messenger
kralyk



Joined: 06 Apr 2008
Posts: 114
Location: Czech Republic, central EU

PostPosted: Mon Jun 22, 2009 6:15 am    Post subject: Reply with quote

Thank you, but I just resolved the problem using buit in prnt() function
Here goes the code:

Code:

#define TEMP_LEN 1024

typedef struct
{
  char str[TEMP_LEN];
  int idx;
  int done;
} prnt_cb_ctx;

void prnt_cb(prnt_cb_ctx * ctx, int ch)
{
  if (!ctx || (ch == 0x200)) return;
  if ((ctx->idx++) < TEMP_LEN)
  {
    if (ch != 0x201)
    {
      ctx->str[ctx->idx] = (char)ch;
    } else
    {
      ctx->str[ctx->idx] = '\0';
      ctx->done = 1;
    }
  } else if (ch == 0x201)
  {
    ctx->str[TEMP_LEN-1] = '\0';
    ctx->done = 1;
  }
}

int my_func(int type, char * message, ...)
{
  //Some code here...
  //(args does get initialised, dont worry)

      ctx.idx = -1;
      ctx.done = 0;
      prnt(&prnt_cb, &ctx, message, args);
      while (!ctx.done) sceKernelDelayThreadCB(1000);
      written += sceIoWrite(file, ctx.str, strlen(ctx.str));
      written += sceIoWrite(file, "\r\n", 2);
      sceIoClose(file);


  va_end(args);
  //Some code here...
}

Do you think that delay of 1ms is appropriate?
_________________
...sorry for my english...
Back to top
View user's profile Send private message
slasher2661996



Joined: 22 Feb 2009
Posts: 91
Location: Melbourne Australia ZOMG

PostPosted: Mon Jun 22, 2009 2:49 pm    Post subject: Reply with quote

There are no loops, so i would say you don't need it.
Back to top
View user's profile Send private message
Jim



Joined: 02 Jul 2005
Posts: 487
Location: Sydney

PostPosted: Mon Jun 22, 2009 8:33 pm    Post subject: Reply with quote

apart from the while loop.
_________________
http://www.dbfinteractive.com
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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