2008-12-11 20:30:53 +00:00
|
|
|
/*
|
2006-04-26 15:08:19 +00:00
|
|
|
* Creation Date: <2003/10/18 13:52:32 samuel>
|
|
|
|
|
* Time-stamp: <2003/10/18 13:54:24 samuel>
|
2008-12-11 20:30:53 +00:00
|
|
|
*
|
2006-04-26 15:08:19 +00:00
|
|
|
* <extra.c>
|
2008-12-11 20:30:53 +00:00
|
|
|
*
|
2006-04-26 15:08:19 +00:00
|
|
|
* Libc extras
|
2008-12-11 20:30:53 +00:00
|
|
|
*
|
2006-04-26 15:08:19 +00:00
|
|
|
* Copyright (C) 2003 Samuel Rydh (samuel@ibrium.se)
|
2008-12-11 20:30:53 +00:00
|
|
|
*
|
2006-04-26 15:08:19 +00:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* version 2
|
2008-12-11 20:30:53 +00:00
|
|
|
*
|
2006-04-26 15:08:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "openbios/config.h"
|
|
|
|
|
#include "libc/string.h"
|
2009-11-22 09:50:54 +00:00
|
|
|
#include "libc/vsprintf.h"
|
2010-03-14 15:05:53 +00:00
|
|
|
#include "libopenbios/bindings.h"
|
2006-04-26 15:08:19 +00:00
|
|
|
|
|
|
|
|
/* strncpy without 0-pad */
|
|
|
|
|
char *
|
|
|
|
|
strncpy_nopad( char *dest, const char *src, size_t n )
|
|
|
|
|
{
|
|
|
|
|
int len = MIN( n, strlen(src)+1 );
|
|
|
|
|
return memcpy( dest, src, len );
|
|
|
|
|
}
|
2009-11-22 09:50:54 +00:00
|
|
|
|
|
|
|
|
/* printf */
|
|
|
|
|
|
|
|
|
|
int forth_printf( const char *fmt, ... )
|
|
|
|
|
{
|
|
|
|
|
char buf[512];
|
|
|
|
|
va_list args;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
|
i = vsnprintf(buf, sizeof(buf), fmt, args);
|
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
|
|
PUSH((ucell)buf);
|
|
|
|
|
PUSH(i);
|
|
|
|
|
fword("type");
|
|
|
|
|
|
|
|
|
|
return i;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|