]> git.proxmox.com Git - mirror_frr.git/blame - lib/printf/printflocal.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / printf / printflocal.h
CommitLineData
ea0b6afe
DL
1/*-
2 * SPDX-License-Identifier: BSD-3-Clause
3 *
4 * Copyright (c) 1990, 1993
5 * The Regents of the University of California. All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * Chris Torek.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * $FreeBSD$
35 */
36
8be3678a 37#include "compiler.h"
5c25bd87 38#include "printfrr.h"
8be3678a 39
ea0b6afe
DL
40/*
41 * Flags used during conversion.
42 */
43#define ALT 0x001 /* alternate form */
44#define LADJUST 0x004 /* left adjustment */
45#define LONGDBL 0x008 /* long double */
46#define LONGINT 0x010 /* long integer */
47#define LLONGINT 0x020 /* long long integer */
48#define SHORTINT 0x040 /* short integer */
49#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */
50#define FPT 0x100 /* Floating point number */
51#define GROUPING 0x200 /* use grouping ("'" flag) */
52 /* C99 additional size modifiers: */
53#define SIZET 0x400 /* size_t */
54#define PTRDIFFT 0x800 /* ptrdiff_t */
55#define INTMAXT 0x1000 /* intmax_t */
56#define CHARINT 0x2000 /* print char using int format */
57
58/*
59 * Macros for converting digits to letters and vice versa
60 */
61#define to_digit(c) ((c) - '0')
62#define is_digit(c) ((unsigned)to_digit(c) <= 9)
63#define to_char(n) ((n) + '0')
64
65/* Size of the static argument table. */
66#define STATIC_ARG_TBL_SIZE 8
67
68union arg {
69 int intarg;
70 u_int uintarg;
71 long longarg;
72 u_long ulongarg;
73 long long longlongarg;
74 unsigned long long ulonglongarg;
75 ptrdiff_t ptrdiffarg;
76 size_t sizearg;
77 intmax_t intmaxarg;
78 uintmax_t uintmaxarg;
79 void *pvoidarg;
80 char *pchararg;
81 signed char *pschararg;
82 short *pshortarg;
83 int *pintarg;
84 long *plongarg;
85 long long *plonglongarg;
86 ptrdiff_t *pptrdiffarg;
87 ssize_t *pssizearg;
88 intmax_t *pintmaxarg;
89#ifndef NO_FLOATING_POINT
90 double doublearg;
91 long double longdoublearg;
92#endif
93 wint_t wintarg;
94 wchar_t *pwchararg;
95};
96
97/* Handle positional parameters. */
8be3678a 98int _frr_find_arguments(const char *, va_list, union arg **) DSO_LOCAL;
e8c672ea 99#ifdef WCHAR_SUPPORT
8be3678a 100int _frr_find_warguments(const wchar_t *, va_list, union arg **) DSO_LOCAL;
e8c672ea 101#endif
bf4d3d80 102
212e04e5 103/* returns number of bytes needed for full output, or -1 */
3ea79430
DL
104ssize_t printfrr_extp(struct fbuf *, struct printfrr_eargs *ea, const void *)
105 DSO_LOCAL;
106ssize_t printfrr_exti(struct fbuf *, struct printfrr_eargs *ea, uintmax_t)
212e04e5 107 DSO_LOCAL;