-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubprintf.c
54 lines (50 loc) · 936 Bytes
/
subprintf.c
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
/*
* $Log: subprintf.c,v $
* Revision 1.1 2014-09-01 20:03:34+05:30 Cprogrammer
* Initial revision
*
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#ifdef HAVE_STDARG_H
#include <stdarg.h>
#else
#include <varargs.h>
#endif
#include "substdio.h"
#include <stdio.h>
#ifdef HAVE_STDARG_H
int
subprintf(substdio *ssout, char *fmt, ...)
#else
int
subprintf(va_alist)
va_dcl
#endif
{
va_list ap;
char *ptr;
char buf[2048];
int i;
#ifdef SUN41
int len;
#else
unsigned len;
#endif
#ifndef HAVE_STDARG_H
substdio *ssout;
char *fmt;
#endif
#ifdef HAVE_STDARG_H
va_start(ap, fmt);
#else
va_start(ap);
ssout = va_arg(ap, substdio *); /* substdio descriptor */
fmt = va_arg(ap, char *);
#endif
(void) vsnprintf(buf, sizeof (buf), fmt, ap);
va_end(ap);
for (len = 0, ptr = buf; *ptr++; len++);
return ((i = substdio_put(ssout, buf, len)));
}