blob: 2c96e94180828543eb0a127cb7769171e3bb9c69 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (c) 2013 Travis Geiselbrecht
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23#include <debug.h>
24#include <stdio.h>
25#include <stdarg.h>
26#include <sys/types.h>
27#include <platform/debug.h>
28
29int fputc(int c, FILE *fp)
30{
31 return fp->fputc(fp->ctx, c);
32}
33
34int putchar(int c)
35{
36 return fputc(c, stdout);
37}
38
39int puts(const char *str)
40{
41 int err = fputs(str, stdout);
42 if (err >= 0)
43 err = fputc('\n', stdout);
44 return err;
45}
46
47int fputs(const char *s, FILE *fp)
48{
49 return fp->fputs(fp->ctx, s);
50}
51
52int getc(FILE *fp)
53{
54 return fp->fgetc(fp->ctx);
55}
56
57int getchar(void)
58{
59 return getc(stdin);
60}
61
62int vfprintf(FILE *fp, const char *fmt, va_list ap)
63{
64 return fp->vfprintf(fp->ctx, fmt, ap);
65}
66
67int fprintf(FILE *fp, const char *fmt, ...)
68{
69 va_list ap;
70 int err;
71
72 va_start(ap, fmt);
73 err = vfprintf(fp, fmt, ap);
74 va_end(ap);
75 return err;
76}
77
78int _printf(const char *fmt, ...)
79{
80 va_list ap;
81 int err;
82
83 va_start(ap, fmt);
84 err = vfprintf(stdout, fmt, ap);
85 va_end(ap);
86
87 return err;
88}