summaryrefslogtreecommitdiff
path: root/lib/stdio.c
blob: 7eac64cf4b479f36ea2216c8b084997d5593247c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>

_syscall1(int, puts, char*, s);
_syscall1(int, ctty, int, ctty);
_syscall2(ssize_t, read, void*, buf, size_t, len);

int printf(char *fmt, ...) {
  int ret;
  char buf[1024];
  va_list ap;

  va_start(ap, fmt);
  ret = vsprintf(buf, fmt, ap);
  va_end(ap);

  puts(buf);
  return ret;
}

int sprintf(char *str, char *fmt, ...) {
  int ret;
  va_list ap;

  va_start(ap, fmt);
  ret = vsprintf(str, fmt, ap);
  va_end(ap);

  return ret;
}