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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
/**
* @file kio.h
*
* @author Freya Murphy <freya@freyacat.org>
*
* Kernel I/O definitions.
*/
#ifndef _KIO_H
#define _KIO_H
#include <stddef.h>
#include <stdarg.h>
/**
* Prints out a char
*
* @param c - the char
*/
void kputc(char c);
/**
* Prints out a null terminated string
*
* @param s - the string
*/
void kputs(const char *s);
#ifdef TRACING
#define TRACE(format, ...) \
do { \
kprintf("[TRACE] %s ", __FUNCTION__); \
kprintf(format, ##__VA_ARGS__); \
} while (0)
#else
#define TRACE(format, ...)
#endif
/**
* prints out a formatted string
*
* @param format - the format string
* @param ... - variable args for the format
* @returns number of bytes written
*/
__attribute__((format(printf, 1, 2))) int kprintf(const char *format, ...);
/**
* prints out a formatted string to a buffer
*
* @param s - the string to write to
* @param format - the format string
* @param ... - variable args for the format
* @returns number of bytes written
*/
__attribute__((format(printf, 2, 3))) int ksprintf(char *restrict s,
const char *format, ...);
/**
* prints out a formatted string to a buffer with a given max length
*
* @param s - the string to write to
* @param maxlen - the max len of the buffer
* @param format - the format string
* @param ... - variable args for the format
* @returns number of bytes written
* @returns number of bytes that would of been written (past maxlen)
*/
__attribute__((format(printf, 3, 4))) int
ksnprintf(char *restrict s, size_t maxlen, const char *format, ...);
/**
* prints out a formatted string
*
* @param format - the format string
* @param args - variable arg list for the format
* @returns number of bytes written
*/
int kvprintf(const char *format, va_list args);
/**
* prints out a formatted string to a buffer
*
* @param s - the string to write to
* @param format - the format string
* @param args - variable arg list for the format
* @returns number of bytes written
*/
int kvsprintf(char *restrict s, const char *format, va_list args);
/**
* prints out a formatted string to a buffer with a given max length
*
* @param s - the string to write to
* @param maxlen - the max len of the buffer
* @param format - the format string
* @param args - variable arg list for the format
* @returns number of bytes that would of been written (past maxlen)
*/
int kvsnprintf(char *restrict s, size_t maxlen, const char *format,
va_list args);
#endif /* kio.h */
|