| 1 |
/* Sprintf.c: |
| 2 |
* Authors: Charles E. Campbell, Jr. |
| 3 |
* Terry McRoberts |
| 4 |
* Copyright: Copyright (C) 1999-2005 Charles E. Campbell, Jr. {{{1 |
| 5 |
* Permission is hereby granted to use and distribute this code, |
| 6 |
* with or without modifications, provided that this copyright |
| 7 |
* notice is copied with it. Like anything else that's free, |
| 8 |
* Sprintf.c is provided *as is* and comes with no warranty |
| 9 |
* of any kind, either expressed or implied. By using this |
| 10 |
* software, you agree that in no event will the copyright |
| 11 |
* holder be liable for any damages resulting from the use |
| 12 |
* of this software. |
| 13 |
* Date: Aug 22, 2005 |
| 14 |
*/ |
| 15 |
#include <stdio.h> |
| 16 |
#include "sockets.h" |
| 17 |
|
| 18 |
/* Sprintf: */ |
| 19 |
/*VARARGS*/ |
| 20 |
#ifdef __PROTOTYPE__ |
| 21 |
int Sprintf( |
| 22 |
Socket *skt, |
| 23 |
char *fmt, |
| 24 |
...) |
| 25 |
#else |
| 26 |
int Sprintf(skt,va_alist) |
| 27 |
Socket *skt; |
| 28 |
va_dcl |
| 29 |
#endif |
| 30 |
{ |
| 31 |
va_list args; |
| 32 |
int ret; |
| 33 |
static char buf[PM_BIGBUF]; |
| 34 |
|
| 35 |
#ifndef __PROTOTYPE__ |
| 36 |
char *fmt=NULL; |
| 37 |
#endif |
| 38 |
|
| 39 |
|
| 40 |
/* sanity check */ |
| 41 |
if(!skt) { |
| 42 |
return 0; |
| 43 |
} |
| 44 |
|
| 45 |
#ifdef __PROTOTYPE__ |
| 46 |
va_start(args,fmt); |
| 47 |
#else |
| 48 |
va_start(args); |
| 49 |
fmt = va_arg(args,char *); |
| 50 |
#endif |
| 51 |
fflush(stdout); |
| 52 |
|
| 53 |
ret= vsprintf(buf,fmt,args); |
| 54 |
Swrite(skt,buf,strlen(buf)+1); /* send the null byte, too */ |
| 55 |
va_end(args); |
| 56 |
|
| 57 |
return ret; |
| 58 |
} |
| 59 |
|
| 60 |
/* --------------------------------------------------------------------- |
| 61 |
* vim: ts=4 |
| 62 |
*/ |