File: mysnprintf.c

package info (click to toggle)
pure-ftpd 1.0.47-3
  • links: PTS
  • area: main
  • in suites:
  • size: 3,212 kB
  • sloc: ansic: 29,132; sh: 1,632; makefile: 500; perl: 280
file content (42 lines) | stat: -rw-r--r-- 708 bytes parent folder | download | duplicates (4)
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
#include <config.h>

#include <stdio.h>
#ifdef STDC_HEADERS
# include <stdlib.h>
# include <stddef.h>
# include <stdarg.h>
#else
# ifdef HAVE_STDLIB_H
#  include <stdlib.h>
# endif
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
#include <sys/types.h>
#include "mysnprintf.h"

#ifdef WITH_DMALLOC
# include <dmalloc.h>
#endif

#ifdef SNPRINTF_IS_BOGUS
int workaround_snprintf(char *str, size_t size, const char *format, ...)
{
    int v;
    int r = 0;

    va_list va;
    va_start(va, format);
    v = vsnprintf(str, size, format, va);
    if (v < 0 || (ssize_t) v >= (ssize_t) size) {
        r--;
    }
    va_end(va);

    return r;
}
#endif