3 * Generalized string formatting
5 * (c) 2023 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software: you can redistribute it and/or modify it under
13 * the terms of the GNU Library General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
17 * mLib is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 * License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib. If not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 #ifndef MLIB_GPRINTF_H
29 #define MLIB_GPRINTF_H
35 /*----- Header files ------------------------------------------------------*/
43 /*----- Data structures ---------------------------------------------------*/
46 int (*putch)(void */*out*/, int /*ch*/);
47 int (*putm)(void */*out*/, const char */*p*/, size_t /*sz*/);
48 PRINTF_LIKE(3, 4) int (*nputf)
49 (void */*out*/, size_t /*maxsz*/, const char */*p*/, ...);
52 extern const struct gprintf_ops file_printops;
54 /*----- Functions provided ------------------------------------------------*/
56 /* --- @vgprintf@ --- *
58 * Arguments: @const struct gprintf_ops *ops@ = output operations
59 * @void *out@ = context for output operations
60 * @const char *p@ = pointer to @printf@-style format string
61 * @va_list *ap@ = argument handle
63 * Returns: The number of characters written to the string.
65 * Use: As for @gprintf@, but takes a reified argument tail.
68 extern int vgprintf(const struct gprintf_ops */*ops*/, void */*out*/,
69 const char */*p*/, va_list */*ap*/);
71 /* --- @gprintf@ --- *
73 * Arguments: @const struct gprintf_ops *ops@ = output operations
74 * @void *out@ = context for output operations
75 * @const char *p@ = pointer to @printf@-style format string
76 * @...@ = argument handle
78 * Returns: The number of characters written to the string.
80 * Use: Formats a @printf@-like message and writes the result using
81 * the given output operations. This is the backend machinery
82 * for @dstr_putf@, for example.
85 extern int PRINTF_LIKE(3, 4)
86 gprintf(const struct gprintf_ops */*ops*/, void */*out*/,
87 const char */*p*/, ...);
89 /*----- That's all, folks -------------------------------------------------*/