aboutsummaryrefslogtreecommitdiff
path: root/lib/stdio.h
blob: 9a0c41e63766bdbefda1ee3c17833d8b7cb2ec00 (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once

#include <stdarg.h>

#ifdef __cplusplus
/** An object type used for streams */
struct kIoDevice {
  /** Function that prints a character to the stream */
  virtual void putc(char) = 0;
  /** Function that prints a string to the stream */
  virtual int puts(const char *, int) = 0;
  /** Flush write buffers */
  virtual void flush() = 0;
};
typedef kIoDevice FILE;
#else
typedef void FILE;
#endif

/** A FILE value corresponding to stdin, the keyboard buffer */
extern FILE *stdin;
/** A FILE value corresponding to stdout, the display */
extern FILE *stdout;
/** A FILE value corresponding to stderr, the uart */
extern FILE *stderr;

#ifdef __cplusplus
extern "C" {
#endif
/**
 * Write the formatted string to stdout
 *
 * Supports ``%s`` (string), ``%d`` (decimal), ``%u`` (unsigned), ``%x`` (hexadecimal)
 */
int printf(const char *restrict format, ...);

/**
 * Write the formatted string to stream; see printf
 */
int fprintf(FILE *restrict stream, const char *restrict format, ...);

/**
 * Write the formatted string to stream; see printf
 */
int vfprintf(FILE *restrict stream, const char *restrict format, va_list ap);
#ifdef __cplusplus
}
#endif