skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

lolstdio.html (3453B)


      1 <html>
      2   <head>
      3     <meta name="viewport" content="width=device-width, initial-scale=1.0" />
      4     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      5     <meta http-equiv="Content-Language" content="en" />
      6     <title>skalibs: the lolstdio library interface</title>
      7     <meta name="Description" content="skalibs: the lolstdio library interface" />
      8     <meta name="Keywords" content="skalibs c unix stdio lol printf fprintf library libstddjb" />
      9     <!-- <link rel="stylesheet" type="text/css" href="//skarnet.org/default.css" /> -->
     10   </head>
     11 <body>
     12 
     13 <p>
     14 <a href="index.html">libstddjb</a><br />
     15 <a href="../libskarnet.html">libskarnet</a><br />
     16 <a href="../index.html">skalibs</a><br />
     17 <a href="//skarnet.org/software/">Software</a><br />
     18 <a href="//skarnet.org/">skarnet.org</a>
     19 </p>
     20 
     21 <h1> The <tt>lolstdio</tt> library interface </h1>
     22 
     23 <p>
     24  The following functions are declared in the <tt>skalibs/lolstdio.h</tt> header,
     25 and implemented in the <tt>libskarnet.a</tt> or <tt>libskarnet.so</tt> library.
     26 </p>
     27 
     28 <h2> General information </h2>
     29 
     30 <p>
     31  <tt>lolstdio</tt> is a set of convenience functions providing
     32 <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html">printf</a>-style
     33 formatting but interacting with <a href="buffer.html">buffers</a> or
     34 <a href="bufalloc.html">bufallocs</a> instead of stdio FILEs.
     35 </p>
     36 
     37 <p>
     38  Like any printf-style functions, the lolstdio functions are rather
     39 complex and inefficient, and not recommended for general use; they are
     40 provided as a quick and dirty way to debug or test things. Programmers
     41 are advised to use type-specific formatting functions instead in
     42 production-quality code.
     43 </p>
     44 
     45 <p>
     46  Be aware that functions writing into buffers interact badly with
     47 non-blocking fds (and asynchronism in general) - just as you cannot
     48 use FILEs with non-blocking output. Functions writing into bufallocs,
     49 however, are fine, because bufallocs are much more suited to asynchronous
     50 writing than fixed-size buffers or FILEs are.
     51 </p>
     52 
     53 <p>
     54  The current lolstdio implementation relies on the libc's
     55 <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/vsnprintf.html">vsnprintf</a>
     56 function.
     57 </p>
     58 
     59 <h2> Functions </h2>
     60 
     61 <p>
     62 <code> int vbprintf (buffer *b, char const *format, va_list args) </code> <br />
     63 Like <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/vfprintf.html">vfprintf</a>
     64 except that the result is written to the buffer <em>b</em>.
     65 </p>
     66 
     67 <p>
     68 <code> int bprintf (buffer *b, char const *format, ...) </code> <br />
     69 Like <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html">fprintf</a>
     70 except that the result is written to the buffer <em>b</em>.
     71 </p>
     72 
     73 <p>
     74 <code> int lolprintf (char const *format, ...) </code> <br />
     75 Like <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/printf.html">printf</a>
     76 except that the result is written to the buffer <tt>buffer_1</tt>.
     77 </p>
     78 
     79 <p>
     80 <code> int vbaprintf (bufalloc *ba, char const *format, va_list args) </code> <br />
     81 Like <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/vfprintf.html">vfprintf</a>
     82 except that the result is written to the bufalloc <em>ba</em>.
     83 </p>
     84 
     85 <p>
     86 <code> int baprintf (bufalloc *ba, char const *format, ...) </code> <br />
     87 Like <a href="https://pubs.opengroup.org/onlinepubs/9699919799/functions/fprintf.html">fprintf</a>
     88 except that the result is written to the bufalloc <em>ba</em>.
     89 </p>
     90 
     91 </body>
     92 </html>