openblt

a hobby OS from the late 90s
git clone http://frotz.net/git/openblt.git
Log | Files | Refs | LICENSE

printf.c (906B)


      1 /* Copyright 1999, Sidney Cammeresi. All rights reserved.
      2 ** Distributed under the terms of the OpenBLT License
      3 */
      4 
      5 #include <stdarg.h>
      6 #include <string.h>
      7 #include <blt/namer.h>
      8 #include <blt/syscall.h>
      9 #include <blt/libsyms.h>
     10 
     11 void va_snprintf (char *s, int len, const char *fmt, ...);
     12 
     13 void __libc_bind_console(void);
     14 ssize_t __libc_write_console(const void *buf, ssize_t len);
     15 ssize_t __libc_read_console(void *buf, ssize_t);
     16 
     17 void __libc_init_console (void)
     18 {
     19 	__libc_bind_console ();
     20 }
     21 
     22 weak_alias (_printf, __libc_printf)
     23 weak_alias (_printf, printf)
     24 link_warning (__libc_printf, "warning: __libc_printf is deprecated; use printf instead.")
     25 
     26 init_info __init_posix_console = {
     27 	&__libc_init_console,
     28 	2
     29 };
     30 
     31 int _printf(char *fmt,...)
     32 {   
     33 	char buf[256];
     34 
     35 	va_list pvar;
     36 	va_start(pvar,fmt);
     37 	va_snprintf(buf,256,fmt,pvar);
     38 	va_end(pvar);
     39 	
     40 	__libc_write_console(buf, strlen(buf));
     41 	
     42 	return 0;
     43 }
     44