File: irc_sprintf.c

package info (click to toggle)
ircd-irc2 2.11.2p2%2Bdfsg-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 3,288 kB
  • ctags: 3,280
  • sloc: ansic: 39,088; sh: 3,287; makefile: 379
file content (59 lines) | stat: -rw-r--r-- 1,465 bytes parent folder | download | duplicates (11)
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
52
53
54
55
56
57
58
59
/*
 *   IRC - Internet Relay Chat, common/irc_sprintf.c
 *   Copyright (C) 2002 Piotr Kucharski
 *
 *   BSD licence applies. Yeah!
 *
 */

#ifndef lint
static const volatile char rcsid[] = "$Id: irc_sprintf.c,v 1.5 2004/10/01 20:22:12 chopin Exp $";
#endif

#define IRC_SPRINTF_C
#include "irc_sprintf_ext.h"
#undef IRC_SPRINTF_C

/*
 * Our sprintf. Currently supports:
 * formats: %s, %d, %i, %u, %c, %%, %x, %X, %o
 * flags: l, ll, '-', '+', space, 0 (zeropadding), 0-9 (width),
 * '#' (for o,x,X only), '*' (width), '.' (precision)
 * 
 * Soon will handle: %y/%Y returning ->name or ->uid
 * from an aClient pointer, depending on target.
 */

#define	MAXDIGS	32
#undef _NOLONGLONG

#define	MEMSET(c, n){register int k = n; while (k--) *buf++ = c;}
#define	MEMCPY(s, n){register int k = n; while (k--) *buf++ = *s++;}

static char	dtmpbuf[MAXDIGS];	/* scratch buffer for numbers */

int irc_sprintf(aClient *target, char *buf, char *format, ...)
#include "irc_sprintf_body.c"

#define IRC_SPRINTF_V 1

int irc_vsprintf(aClient *target, char *buf, char *format, va_list ap)
#include "irc_sprintf_body.c"

#if 0
error SN version is unsafe so far, sorry

#define IRC_SPRINTF_SN 1

int irc_vsnprintf(aClient *target, char *buf, size_t size, char *format, va_list ap)
#include "irc_sprintf_body.c"

#undef IRC_SPRINTF_V

int irc_snprintf(aClient *target, char *buf, size_t size, char *format, ...)
#include "irc_sprintf_body.c"

#undef IRC_SPRINTF_SN

#endif /* 0 */