Question about kernel libc

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Question about kernel libc

Post by kralyk »

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...
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

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...
sauron_le_noir
Posts: 203
Joined: Sat Jul 05, 2008 8:03 am

Post by sauron_le_noir »

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
kralyk
Posts: 114
Joined: Sun Apr 06, 2008 8:18 pm
Location: Czech Republic, central EU

Post by kralyk »

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

Code: Select all

#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 &#40;&#40;ctx->idx++&#41; < TEMP_LEN&#41;
  &#123;
    if &#40;ch != 0x201&#41;
    &#123;
      ctx->str&#91;ctx->idx&#93; = &#40;char&#41;ch;
    &#125; else
    &#123;
      ctx->str&#91;ctx->idx&#93; = '\0';
      ctx->done = 1;
    &#125;
  &#125; else if &#40;ch == 0x201&#41;
  &#123;
    ctx->str&#91;TEMP_LEN-1&#93; = '\0';
    ctx->done = 1;
  &#125;
&#125;

int my_func&#40;int type, char * message, ...&#41;
&#123;
  //Some code here...
  //&#40;args does get initialised, dont worry&#41;

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


  va_end&#40;args&#41;;
  //Some code here...
&#125;
Do you think that delay of 1ms is appropriate?
...sorry for my english...
slasher2661996
Posts: 91
Joined: Sun Feb 22, 2009 8:32 am
Location: Melbourne Australia ZOMG

Post by slasher2661996 »

There are no loops, so i would say you don't need it.
User avatar
Jim
Posts: 476
Joined: Sat Jul 02, 2005 10:06 pm
Location: Sydney
Contact:

Post by Jim »

apart from the while loop.
Post Reply