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
|
/* Sprintf.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,
* Sprintf.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"
/* Sprintf: */
/*VARARGS*/
#ifdef __PROTOTYPE__
int Sprintf(
Socket *skt,
char *fmt,
...)
#else
int Sprintf(skt,va_alist)
Socket *skt;
va_dcl
#endif
{
va_list args;
int ret;
static char buf[PM_BIGBUF];
#ifndef __PROTOTYPE__
char *fmt=NULL;
#endif
/* sanity check */
if(!skt) {
return 0;
}
#ifdef __PROTOTYPE__
va_start(args,fmt);
#else
va_start(args);
fmt = va_arg(args,char *);
#endif
fflush(stdout);
ret= vsprintf(buf,fmt,args);
Swrite(skt,buf,strlen(buf)+1); /* send the null byte, too */
va_end(args);
return ret;
}
/* ---------------------------------------------------------------------
* vim: ts=4
*/
|