File: Svprintf.c

package info (click to toggle)
dmucs 0.6.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 3,240 kB
  • sloc: ansic: 5,053; sh: 3,557; cpp: 2,397; makefile: 64; perl: 26
file content (64 lines) | stat: -rw-r--r-- 1,850 bytes parent folder | download | duplicates (2)
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
60
61
62
63
64
/* Svprintf.c:
 * Authors:      Charles E. Campbell, Jr.
 *               Terry McRoberts
 * Copyright:    Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1
 *               Permission is hereby granted to use and distribute this code,
 *               with or without modifications, provided that this copyright
 *               notice is copied with it. Like anything else that's free,
 *               Svprintf.c is provided *as is* and comes with no warranty
 *               of any kind, either expressed or implied. By using this
 *               software, you agree that in no event will the copyright
 *               holder be liable for any damages resulting from the use
 *               of this software.
 * Date:         Aug 22, 2005
 */
#include <stdio.h>
#include "sockets.h"

/* --------------------------------------------------------------------- */

/* Svprintf:
 *
 *   Returns: count of bytes sent, which may be 0
 *
 *   This function is like vprintf; it takes a Socket pointer, a format
 *   string, and an argument list.  Note that it actually "prints" the
 *   string into a local buffer first of PM_BIGBUF bytes (originally 1024
 *   bytes).  So, please insure that you don't put more info than will fit
 *   into PM_BIGBUF bytes!  It then squirts the resulting string through
 *   a call to Swrite.
 */
#ifdef __PROTOTYPE__
int Svprintf(
  Socket *skt,
  char   *fmt,
  va_list args)
#else
int Svprintf(skt,fmt,args)
Socket *skt;
char   *fmt;
va_list args;
#endif
{
int         ret;
static char buf[PM_BIGBUF];


/* sanity check */
if(!skt) {
	return 0;
	}

#ifdef AS400
ret= vsprintf(buf,fmt,__va_list args);
#else
ret= vsprintf(buf,fmt,args);
#endif
Swrite(skt,buf,strlen(buf)+1);	/* send the null byte, too */

return ret;
}

/* ---------------------------------------------------------------------
 * vim: ts=4
 */