#error REDO, convert from C++ to C /*============================================================================= * drt/sys/kprintf.h * DRT formatted printing functions, ala POSIX printf(). * * History * 0.01, 1999-08-08, David R. Tribble. * First cut. * * [Public] * Copyright ©1999 by David R. Tribble, all rights reserved. * See "drt/sys/copyr.txt" for more information. *----------------------------------------------------------------------------*/ #ifndef drt_sys_kprintf_h #define drt_sys_kprintf_h 001 #ifdef __cplusplus extern "C" { #endif /* Identification */ #ifndef NO_H_IDENT static const char drt_sys_kprintf_h_id[] = "@(#)drt/sys/kprintf.h 0.01"; #endif /* System includes */ #ifndef drt_std_stdarg_h #include #define drt_std_stdarg_h 1 #endif /* Special includes */ #ifndef drt_sys_kdefs_h #include "kdefs.h" #endif /* Local wrappers */ #include "klib1.h" /* Forward declarations */ typedef unsigned short DrtChar; struct DrtIOStream; typedef struct DrtIOStream DrtIOStream; REDO /*----------------------------------------------------------------------------- * Class DrtPrint * Formatted printing functions, ala POSIX printf(). * * Usage * The printf() member functions print out zero or more arguments in a * formatted form. They follow the behavior of the POSIX family of * printf() functions. * * The format string is composed of zero or more characters and format * specifiers, and is terminated by a NUL ('\0') character. Non-format * characters are printed as is. * * Format specifiers are composed of the following components (optional * components are enclosed within brackets): * * % [num $] [flag...] [width] [. [prec]] type * * The 'num' component specifies the argument number to be used for the * field specification. If any field specifier contains a '$' component, * then all field specifiers must contain a '$' component. The first * argument is numbered '1$', the second is '2$', and so on. The number * can have more than one digit, but should not have a leading zero digit. * * The 'flags' component specifies modifiers for the field to be printed, * which affect the way the field value is printed. Supported formatting * flags are: * * space The padding character is a space (' '). * * 0 The padding character is a zero ('0'). * * # Octal integer fields are prefixed with a '0', and * hexadecimal integer and floating-point fields are * prefixed with a '0x'. * * h The argument was converted from a 'short' integer. * * hh The argument was converted from a 'char' type. * * j ...INCOMPLETE... * * l Numeric integer arg is 'long int', floating-point arg * is 'double' (no effect), string arg is 'wchar_t'. * * ll Numeric integer arg is 'long long int'. * * L Floating-point arg is 'long double'. * * The 'width' component specifies the minimum number of characters to be * written for the field. A negative width (i.e., a width preceded by a * '-') indicates that the field will be left-justified. * * The 'prec' component specifies the precision of the field. For integer * fields, this is the minimum number of least-significant digits that * will be printed; for floating-point fields, this is the number of * fraction digits to the right of the decimal point; for string fields, * this is the maximum number of characters to be printed from the source * string. * * The 'type' component specifies the data type of the field. The * following formatting types are supported: * * a Hexdecimal floating-point, lowercase. * A Hexdecimal floating-point, uppercase. * c Character. * C Unicode character (type DrtChar). * d Decimal integer. * e Floating-point, the least wide of '%f' or '%g'. * E Same as 'e' except with an uppercase exponent 'E'. * f Floating-point, no exponent. * g Floating-point, with exponent. * n Current count of characters printed. * o Octal integer. * O Object pointer (which is derived from class DrtPrintable). * p Pointer. * s Character string. * S Character (class DrtChar) string. * u Unsigned decimal integer. * x Hexdecimal integer, lowercase. * X Hexdecimal integer, uppercase. * * Keywords * print, printf, format, I/O, formatted. * * History * 100, 1999-08-08, David R. Tribble. * First cut. *----------------------------------------------------------------------------*/ #define DrtPrint_VERS 100 /* Library version number */ /* Public variables */ extern const int drt_printf_VS; /* Library version number */ /* Public functions */ extern int DRTFUNC drt_printf(const char *fmt, ...); /* Formatted printing to stdout */ extern int DRTFUNC drt_vprintf(const char *fmt, va_list ap); /* Formatted printing to stdout */ extern int DRTFUNC drt_fprintf(FILE *o, const char *fmt, ...); /* Formatted printing to file */ extern int DRTFUNC drt_vfprintf(FILE *o, const char *fmt, va_list ap); /* Formatted printing to file */ extern int DRTFUNC drt_sprintf(char *s, const char *fmt, ...); /* Formatted printing to string */ extern int DRTFUNC drt_vsprintf(char *s, const char *fmt, va_list ap); /* Formatted printing to string */ extern int DRTFUNC drt_printfu(const DrtChar *fmt, ...); /* Formatted printing to stdout */ extern int DRTFUNC drt_vprintfu(const DrtChar *fmt, va_list ap); /* Formatted printing to stdout */ extern int DRTFUNC drt_fprintfu(FILE *o, const DrtChar *fmt, ...); /* Formatted printing to file */ extern int DRTFUNC drt_vfprintfu(FILE *o, const DrtChar *fmt, va_list ap); /* Formatted printing to file */ extern int DRTFUNC drt_sprintfu(DrtChar *s, const DrtChar *fmt, ...); /* Formatted printing to string */ extern int DRTFUNC drt_vsprintfu(DrtChar *s, const DrtChar *fmt, va_list ap); /* Formatted printing to string */ REDO +++ extern int DRTFUNC drt_print_a(DrtFile *fp, double v, int width, int prec, char fill); extern int DRTFUNC drt_print_A(DrtFile *fp, double v, int width, int prec, char fill); extern int DRTFUNC drt_print_b(DrtFile *fp, unsigned long v, int width, int prec, char fill); extern int DRTFUNC drt_print_c(DrtFile *fp, int v, int width, int prec, char fill); extern int DRTFUNC drt_print_C(DrtFile *fp, DrtChar v, int width, int prec, char fill); extern int DRTFUNC drt_print_d(DrtFile *fp, signed long v, int width, int prec, char fill); extern int DRTFUNC drt_print_e(DrtFile *fp, double v, int width, int prec, char fill); extern int DRTFUNC drt_print_E(DrtFile *fp, double v, int width, int prec, char fill); extern int DRTFUNC drt_print_f(DrtFile *fp, double v, int width, int prec, char fill); extern int DRTFUNC drt_print_g(DrtFile *fp, double v, int width, int prec, char fill); extern int DRTFUNC drt_print_o(DrtFile *fp, unsigned long v, int width, int prec, char fill); extern int DRTFUNC drt_print_O(DrtFile *fp, const DrtPrintable &v, int width, int prec, char fill); extern int DRTFUNC drt_print_p(DrtFile *fp, const void *v, int width, int prec, char fill); extern int DRTFUNC drt_print_s(DrtFile *fp, const DrtChar *v, int width, int prec, char fill); extern int DRTFUNC drt_print_u(DrtFile *fp, unsigned long v, int width, int prec, char fill); extern int DRTFUNC drt_print_x(DrtFile *fp, unsigned long v, int width, int prec, char fill); extern int DRTFUNC drt_print_X(DrtFile *fp, unsigned long v, int width, int prec, char fill); +++ #include "klib2.h" #ifdef __cplusplus } #endif #endif /* drt_sys_kprintf_h */ /* End kprintf.h */