我有一个。不过在这里发帖有点大。通过电子邮件与我联系 - 查看我的个人资料。
这是标题,因此您对要进入的内容有所了解:
/*
@(#)File: $RCSfile: printfmt.h,v $
@(#)Version: $Revision: 2.1 $
@(#)Last changed: $Date: 2011/07/18 16:30:54 $
@(#)Purpose: Parse printf() format string for conversion specification
@(#)Author: J Leffler
@(#)Copyright: (C) JLSS 2011
@(#)Product: :PRODUCT:
*/
/*TABSTOP=4*/
#ifndef JLSS_ID_PRINTFMT_H
#define JLSS_ID_PRINTFMT_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#ifdef MAIN_PROGRAM
#ifndef lint
/* Prevent over-aggressive optimizers from eliminating ID string */
extern const char jlss_id_printfmt_h[];
const char jlss_id_printfmt_h[] = "@(#)$Id: printfmt.h,v 2.1 2011/07/18 16:30:54 jleffler Exp $";
#endif /* lint */
#endif /* MAIN_PROGRAM */
typedef enum PFP_Errno
{
PFE_NoError, /* No error */
PFE_InvalidFormat, /* Found % with no valid conversion specifier */
PFE_NumberOverflow, /* Number too big (max: 16,383) (should not be seen by users) */
PFE_WidthOverflow, /* Field width too big (max: 16,383) */
PFE_PrecOverflow, /* Field precision too big (max: 16,383) */
PFE_InvalidModifier, /* Invalid modifier characters */
PFE_MissingNDollar, /* One n$ was present and others were missing */
PFE_RepeatedFlag, /* One of the flags was repeated */
PFE_DollarOverflow, /* Value in n$ too big (max: 16,383) */
PFE_InvalidError, /* Error number is not recognized */
PFE_BufferTooSmall, /* Buffer too small */
PFE_BogusWidth, /* Faulty width specification */
PFE_BogusPrecision, /* Faulty precision specification */
} PFP_Errno;
enum
{
FWP_None = -1,
FWP_Star = -2,
};
typedef enum PFP_Status
{
PFP_Found = +1,
PFP_Error = -1,
PFP_Finish = 0,
} PFP_Status;
typedef struct PrintFormat
{
const char *start; /* Pointer to % symbol */
const char *end; /* Pointer to conversion specifier */
PFP_Errno error; /* Conversion error number */
short width; /* Field width (FPW_None for none, FPW_Star for *) */
short precision; /* Field precision (FPW_None for none, FPW_Star for *) */
short conv_num; /* n of %n$ (0 for none) */
short width_num; /* n of *n$ for width (0 for none) */
short prec_num; /* n of *n$ for precision (0 for none) */
char flags[6]; /* [+-0# ] */
char modifier[3]; /* hh|h|l|ll|j|z|t|L */
char convspec; /* [diouxXfFeEgGAascp] */
} PrintFormat;
/*
** print_format_parse() - isolate and parse next printf() conversion specification
**
** PrintFormat pf;
** PFP_Status rc;
** const char *format = "...%3$+-*2$.*1$llX...";
** const char *start = format;
** while ((rc = print_format_parse(start, &pf)) == PFP_Found)
** {
** ...use filled in pf to identify format...
** start = pf.end + 1;
** }
** if (rc == PFP_Error)
** ...report error, possibly using print_format_error(pf.error)...
*/
extern PFP_Status print_format_parse(const char *src, PrintFormat *pf);
extern const char *print_format_error(PFP_Errno err);
extern PFP_Status print_format_create(PrintFormat *pf, char *buffer, size_t buflen);
#ifdef __cplusplus
}
#endif
#endif /* JLSS_ID_PRINTFMT_H */