about summary refs log tree commit diff
path: root/doc/libstddjb/lolstdio.html
blob: 57ce81d2993b8911b162baf7f24363661163c8a1 (plain) (blame)
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
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta http-equiv="Content-Language" content="en" />
    <title>skalibs: the lolstdio library interface</title>
    <meta name="Description" content="skalibs: the lolstdio library interface" />
    <meta name="Keywords" content="skalibs c unix stdio lol printf fprintf library libstddjb" />
    <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
  </head>
<body>

<p>
<a href="index.html">libstddjb</a><br />
<a href="../libskarnet.html">libskarnet</a><br />
<a href="../index.html">skalibs</a><br />
<a href="//skarnet.org/software/">Software</a><br />
<a href="//skarnet.org/">skarnet.org</a>
</p>

<h1> The <tt>lolstdio</tt> library interface </h1>

<p>
 The following functions are declared in the <tt>skalibs/lolstdio.h</tt> header,
and implemented in the <tt>libskarnet.a</tt> or <tt>libskarnet.so</tt> library.
</p>

<h2> General information </h2>

<p>
 <tt>lolstdio</tt> is a set of convenience functions providing
<a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html">printf</a>-style
formatting but interacting with <a href="buffer.html">buffers</a> or
<a href="bufalloc.html">bufallocs</a> instead of stdio FILEs.
</p>

<p>
 Like any printf-style functions, the lolstdio functions are rather
complex and inefficient, and not recommended for general use; they are
provided as a quick and dirty way to debug or test things. Programmers
are advised to use type-specific formatting functions instead in
production-quality code.
</p>

<p>
 Be aware that functions writing into buffers interact badly with
non-blocking fds (and asynchronism in general) - just as you cannot
use FILEs with non-blocking output. Functions writing into bufallocs,
however, are fine, because bufallocs are much more suited to asynchronous
writing than fixed-size buffers or FILEs are.
</p>

<p>
 The current lolstdio implementation relies on the libc's
<a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/vsnprintf.html">vsnprintf</a>
function.
</p>

<h2> Functions </h2>

<p>
<code> int vbprintf (buffer *b, char const *format, va_list args) </code> <br />
Like <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/vfprintf.html">vfprintf</a>
except that the result is written to the buffer <em>b</em>.
</p>

<p>
<code> int bprintf (buffer *b, char const *format, ...) </code> <br />
Like <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html">fprintf</a>
except that the result is written to the buffer <em>b</em>.
</p>

<p>
<code> int lolprintf (char const *format, ...) </code> <br />
Like <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html">printf</a>
except that the result is written to the buffer <tt>buffer_1</tt>.
</p>

<p>
<code> int vbaprintf (bufalloc *ba, char const *format, va_list args) </code> <br />
Like <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/vfprintf.html">vfprintf</a>
except that the result is written to the bufalloc <em>ba</em>.
</p>

<p>
<code> int baprintf (bufalloc *ba, char const *format, ...) </code> <br />
Like <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html">fprintf</a>
except that the result is written to the bufalloc <em>ba</em>.
</p>

</body>
</html>