Watt-32 tcp/ip  2.2 dev-rel.10
sock_prn.c
Go to the documentation of this file.
1 
4 #include <stdio.h>
5 #include <stdarg.h>
6 #include <string.h>
7 
8 #include "copyrigh.h"
9 #include "wattcp.h"
10 #include "strings.h"
11 #include "language.h"
12 #include "pcconfig.h"
13 #include "pctcp.h"
14 
15 int MS_CDECL sock_printf (sock_type *s, const char *fmt, ...)
16 {
17  char buf [tcp_MaxBufSize];
18  int len;
19  va_list args;
20 
21  va_start (args, fmt);
22 
23 #if defined(VSNPRINTF)
24  len = VSNPRINTF (buf, sizeof(buf)-1, fmt, args);
25 
26  /* Some versions of snprintf return -1 if they'd truncate
27  * the output. Others return <buf_size> or greater.
28  */
29  if (len < 0 || len >= SIZEOF(buf)-1)
30  {
31  outsnl (_LANG("ERROR: sock_printf() overrun"));
32  len = sizeof(buf)-1;
33  buf [len] = '\0';
34  }
35 #else
36  len = vsprintf (buf, fmt, args);
37  if (len > SIZEOF(buf))
38  {
39  outsnl (_LANG("ERROR: sock_printf() overrun"));
40  return (0);
41  }
42 #endif
43 
44  sock_puts (s, (const BYTE*)buf);
45 
46  va_end (args);
47  return (len);
48 }
49 
int W32_CALL sock_puts(sock_type *s, const BYTE *data)
Definition: sock_io.c:39
Core definitions.