-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpsnprntf.h
53 lines (40 loc) · 1.35 KB
/
psnprntf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef PSNPRINTF_H
#define PSNPRINTF_H
int psnprintf(char *str, size_t n, const char *format, ...);
int pvsnprintf(char *str, size_t n, const char *format, va_list ap);
/* haleyjd 08/01/09: rewritten to use a structure */
typedef struct psvnfmt_vars_s
{
char *pinsertion;
size_t nmax;
const char *fmt;
int flags;
int width;
int precision;
char prefix;
} pvsnfmt_vars;
/* Use these directly if you want to avoid overhead of psnprintf
* Return value is number of characters printed (or number printed
* if there had been enough room).
*/
int pvsnfmt_char(pvsnfmt_vars *info, char c);
typedef union pvsnfmt_intparm_u
{
int i;
void *p;
} pvsnfmt_intparm_t;
int pvsnfmt_int(pvsnfmt_vars *info, pvsnfmt_intparm_t *ip);
int pvsnfmt_str(pvsnfmt_vars *info, const char *s);
int pvsnfmt_double(pvsnfmt_vars *info, double d);
/* These are the flags you need (use logical OR) for the flags parameter of
* fmt functions above.
*/
#define FLAG_DEFAULT 0x00
#define FLAG_LEFT_ALIGN 0x01 // -
#define FLAG_SIGNED 0x02 // +
#define FLAG_ZERO_PAD 0x04 // 0
#define FLAG_SIGN_PAD 0x08 // ' '
#define FLAG_HASH 0x10 // #
/* Portable strnlen function (doesn't exist on all systems!) */
size_t pstrnlen(const char *s, size_t count);
#endif /* ifdef PSNPRINTF_H */