Blame intl/printf-parse.h

Packit 8a864e
/* Parse printf format string.
Packit 8a864e
   Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc.
Packit 8a864e
Packit 8a864e
   This program is free software; you can redistribute it and/or modify it
Packit 8a864e
   under the terms of the GNU Library General Public License as published
Packit 8a864e
   by the Free Software Foundation; either version 2, or (at your option)
Packit 8a864e
   any later version.
Packit 8a864e
Packit 8a864e
   This program is distributed in the hope that it will be useful,
Packit 8a864e
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8a864e
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 8a864e
   Library General Public License for more details.
Packit 8a864e
Packit 8a864e
   You should have received a copy of the GNU Library General Public
Packit 8a864e
   License along with this program; if not, write to the Free Software
Packit 8a864e
   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
Packit 8a864e
   USA.  */
Packit 8a864e
Packit 8a864e
#ifndef _PRINTF_PARSE_H
Packit 8a864e
#define _PRINTF_PARSE_H
Packit 8a864e
Packit 8a864e
#include "printf-args.h"
Packit 8a864e
Packit 8a864e
Packit 8a864e
/* Flags */
Packit 8a864e
#define FLAG_GROUP	 1	/* ' flag */
Packit 8a864e
#define FLAG_LEFT	 2	/* - flag */
Packit 8a864e
#define FLAG_SHOWSIGN	 4	/* + flag */
Packit 8a864e
#define FLAG_SPACE	 8	/* space flag */
Packit 8a864e
#define FLAG_ALT	16	/* # flag */
Packit 8a864e
#define FLAG_ZERO	32
Packit 8a864e
Packit 8a864e
/* arg_index value indicating that no argument is consumed.  */
Packit 8a864e
#define ARG_NONE	(~(size_t)0)
Packit 8a864e
Packit 8a864e
/* A parsed directive.  */
Packit 8a864e
typedef struct
Packit 8a864e
{
Packit 8a864e
  const char* dir_start;
Packit 8a864e
  const char* dir_end;
Packit 8a864e
  int flags;
Packit 8a864e
  const char* width_start;
Packit 8a864e
  const char* width_end;
Packit 8a864e
  size_t width_arg_index;
Packit 8a864e
  const char* precision_start;
Packit 8a864e
  const char* precision_end;
Packit 8a864e
  size_t precision_arg_index;
Packit 8a864e
  char conversion; /* d i o u x X f e E g G c s p n U % but not C S */
Packit 8a864e
  size_t arg_index;
Packit 8a864e
}
Packit 8a864e
char_directive;
Packit 8a864e
Packit 8a864e
/* A parsed format string.  */
Packit 8a864e
typedef struct
Packit 8a864e
{
Packit 8a864e
  size_t count;
Packit 8a864e
  char_directive *dir;
Packit 8a864e
  size_t max_width_length;
Packit 8a864e
  size_t max_precision_length;
Packit 8a864e
}
Packit 8a864e
char_directives;
Packit 8a864e
Packit 8a864e
Packit 8a864e
/* Parses the format string.  Fills in the number N of directives, and fills
Packit 8a864e
   in directives[0], ..., directives[N-1], and sets directives[N].dir_start
Packit 8a864e
   to the end of the format string.  Also fills in the arg_type fields of the
Packit 8a864e
   arguments and the needed count of arguments.  */
Packit 8a864e
#ifdef STATIC
Packit 8a864e
STATIC
Packit 8a864e
#else
Packit 8a864e
extern
Packit 8a864e
#endif
Packit 8a864e
int printf_parse (const char *format, char_directives *d, arguments *a);
Packit 8a864e
Packit 8a864e
#endif /* _PRINTF_PARSE_H */