snprintf.c File Reference

#include "db_config.h"
#include <sys/types.h>
#include <stdio.h>
#include "db_int.h"

Go to the source code of this file.

Functions

int snprintf (char *str, size_t n, const char *fmt, va_alist)

Variables

static const char revid [] = "$Id: snprintf.c,v 11.10 2002/01/11 15:51:28 bostic Exp $"


Function Documentation

int snprintf char *  str,
size_t  n,
const char *  fmt,
va_alist 
 

Definition at line 35 of file snprintf.c.

References buf, COMPQUIET, and len.

00041 {
00042         static int ret_charpnt = -1;
00043         va_list ap;
00044         int len;
00045 
00046         COMPQUIET(n, 0);
00047 
00048         /*
00049          * Some old versions of sprintf return a pointer to the first argument
00050          * instead of a character count.  Assume the return value of snprintf,
00051          * vsprintf, etc. will be the same as sprintf, and check the easy one.
00052          *
00053          * We do this test at run-time because it's not a test we can do in a
00054          * cross-compilation environment.
00055          */
00056         if (ret_charpnt == -1) {
00057                 char buf[10];
00058 
00059                 ret_charpnt =
00060                     sprintf(buf, "123") != 3 ||
00061                     sprintf(buf, "123456789") != 9 ||
00062                     sprintf(buf, "1234") != 4;
00063         }
00064 
00065 #ifdef __STDC__
00066         va_start(ap, fmt);
00067 #else
00068         va_start(ap);
00069 #endif
00070         len = vsprintf(str, fmt, ap);
00071         va_end(ap);
00072         return (ret_charpnt ? (int)strlen(str) : len);
00073 }


Variable Documentation

const char revid[] = "$Id: snprintf.c,v 11.10 2002/01/11 15:51:28 bostic Exp $" [static]
 

Definition at line 11 of file snprintf.c.


Generated on Wed Jul 20 21:06:36 2005 for MySQL 5.0.9 Beta by  doxygen 1.4.3