Import Upstream version 1.8.5
[hcoop/debian/openafs.git] / src / opr / fmt.h
1 /*
2 * Copyright 2014, Nathaniel Wesley Filardo.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the
6 * "Software"), to deal in the Software without restriction, including
7 * without limitation the rights to use, copy, modify, merge, publish,
8 * distribute, sublicense, and/or sell copies of the Software, and to permit
9 * persons to whom the Software is furnished to do so, subject to the
10 * following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
18 * NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24 #ifndef _OPR_FMT_H_
25 #define _OPR_FMT_H_
26
27 typedef struct opr_fmt_ctx_priv_s opr_fmt_ctx_priv;
28 typedef struct opr_fmt_ctx_s opr_fmt_ctx;
29
30 typedef int (*opr_fmtr)(opr_fmt_ctx *, char, va_list);
31
32 struct opr_fmt_ctx_s {
33 opr_fmtr *fmtrs; /* Byte-wise dispatch table; 256 entries */
34 void *user; /* User-controlled private data */
35 void (*put)(opr_fmt_ctx *, char); /* Write a character to the buffer */
36
37 opr_fmt_ctx_priv *priv; /* Private for internals of opr_fmt */
38 };
39
40 int opr_fmt(opr_fmtr *fmtrs, void *user, char *out, int n, const char *fstr, ...);
41
42 #endif