Example #1
0
pstr  STDCALL str_sprintf( pstr ps, pstr output, pcollect pclt ) 
{
   uint  args[32];
   uint  len = ps->use - 1;
   uint  i, k = 0, itype;

   str_expand( ps, 1024 );
   for ( i = 0; i < collect_count( pclt ); i++ )
   {
      itype = collect_gettype( pclt, i );
      if ( itype == TDouble || itype == TLong || itype == TUlong )
      {
         args[k++] = *( puint )collect_index( pclt, i );
         args[k++] = *(( puint )collect_index( pclt, i ) + 1 );
      }
      else
      {
         args[k++] = *( puint )collect_index( pclt, i );
         if ( itype == TStr )
            args[k - 1] = (uint)(( pstr )args[k - 1])->data;
      }
   }
   str_setlen( ps, len + vsprintf( ps->data + len, output->data, (pubyte)args ));

   return ps;
}
Example #2
0
void str_copy(str_t* dest, str_t* src)
{
    while (dest->size < src->n + 1) str_expand(dest);
    str_clear(dest);
    memcpy(dest->s, src->s, src->n);
    dest->n = src->n;
    dest->s[dest->n] = '\0';
}
Example #3
0
pstr  CDECLCALL str_printf( pstr ps, pubyte output, ... ) 
{
   va_list args;
   uint    len = ps->use - 1;

   str_expand( ps, 512 );
   va_start( args, output );
   str_setlen( ps, len + vsprintf( ps->data + len, output, args ));
   va_end( args );

   return ps;
}
Example #4
0
static void str_append(str_t* s, char c)
{
    if (s->n + 1 >= s->size) str_expand(s);
    s->s[s->n++] = c;
}