1180104Sdas/*- 2180104Sdas * Copyright (c) 1990, 1993 3180104Sdas * The Regents of the University of California. All rights reserved. 4180104Sdas * 5180104Sdas * This code is derived from software contributed to Berkeley by 6180104Sdas * Chris Torek. 7180104Sdas * 8180104Sdas * Redistribution and use in source and binary forms, with or without 9180104Sdas * modification, are permitted provided that the following conditions 10180104Sdas * are met: 11180104Sdas * 1. Redistributions of source code must retain the above copyright 12180104Sdas * notice, this list of conditions and the following disclaimer. 13180104Sdas * 2. Redistributions in binary form must reproduce the above copyright 14180104Sdas * notice, this list of conditions and the following disclaimer in the 15180104Sdas * documentation and/or other materials provided with the distribution. 16180104Sdas * 4. Neither the name of the University nor the names of its contributors 17180104Sdas * may be used to endorse or promote products derived from this software 18180104Sdas * without specific prior written permission. 19180104Sdas * 20180104Sdas * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 21180104Sdas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22180104Sdas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23180104Sdas * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 24180104Sdas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25180104Sdas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 26180104Sdas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27180104Sdas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 28180104Sdas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 29180104Sdas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 30180104Sdas * SUCH DAMAGE. 31180104Sdas * 32180104Sdas * $FreeBSD$ 33180104Sdas */ 34180104Sdas 35180104Sdas/* 36180104Sdas * Flags used during conversion. 37180104Sdas */ 38180104Sdas#define ALT 0x001 /* alternate form */ 39180104Sdas#define LADJUST 0x004 /* left adjustment */ 40180104Sdas#define LONGDBL 0x008 /* long double */ 41180104Sdas#define LONGINT 0x010 /* long integer */ 42180104Sdas#define LLONGINT 0x020 /* long long integer */ 43180104Sdas#define SHORTINT 0x040 /* short integer */ 44180104Sdas#define ZEROPAD 0x080 /* zero (as opposed to blank) pad */ 45180104Sdas#define FPT 0x100 /* Floating point number */ 46180104Sdas#define GROUPING 0x200 /* use grouping ("'" flag) */ 47180104Sdas /* C99 additional size modifiers: */ 48180104Sdas#define SIZET 0x400 /* size_t */ 49180104Sdas#define PTRDIFFT 0x800 /* ptrdiff_t */ 50180104Sdas#define INTMAXT 0x1000 /* intmax_t */ 51180104Sdas#define CHARINT 0x2000 /* print char using int format */ 52180104Sdas 53180104Sdas/* 54180104Sdas * Macros for converting digits to letters and vice versa 55180104Sdas */ 56180104Sdas#define to_digit(c) ((c) - '0') 57180104Sdas#define is_digit(c) ((unsigned)to_digit(c) <= 9) 58180104Sdas#define to_char(n) ((n) + '0') 59180104Sdas 60180104Sdas/* Size of the static argument table. */ 61180104Sdas#define STATIC_ARG_TBL_SIZE 8 62180104Sdas 63180104Sdasunion arg { 64180104Sdas int intarg; 65180104Sdas u_int uintarg; 66180104Sdas long longarg; 67180104Sdas u_long ulongarg; 68180104Sdas long long longlongarg; 69180104Sdas unsigned long long ulonglongarg; 70180104Sdas ptrdiff_t ptrdiffarg; 71180104Sdas size_t sizearg; 72180104Sdas intmax_t intmaxarg; 73180104Sdas uintmax_t uintmaxarg; 74180104Sdas void *pvoidarg; 75180104Sdas char *pchararg; 76180104Sdas signed char *pschararg; 77180104Sdas short *pshortarg; 78180104Sdas int *pintarg; 79180104Sdas long *plongarg; 80180104Sdas long long *plonglongarg; 81180104Sdas ptrdiff_t *pptrdiffarg; 82189268Sdas ssize_t *pssizearg; 83180104Sdas intmax_t *pintmaxarg; 84180104Sdas#ifndef NO_FLOATING_POINT 85180104Sdas double doublearg; 86180104Sdas long double longdoublearg; 87180104Sdas#endif 88180104Sdas wint_t wintarg; 89180104Sdas wchar_t *pwchararg; 90180104Sdas}; 91180104Sdas 92180104Sdas/* Handle positional parameters. */ 93180106Sdasint __find_arguments(const char *, va_list, union arg **); 94180106Sdasint __find_warguments(const wchar_t *, va_list, union arg **); 95