FreeTDS API
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
replacements.h
1 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
2  * Copyright (C) 1998-1999 Brian Bruns
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19 
20 #ifndef _replacements_h_
21 #define _replacements_h_
22 
23 /* $Id: replacements.h,v 1.28.2.1 2011-07-07 07:27:33 freddy77 Exp $ */
24 
25 #include <stdarg.h>
26 #include "tds_sysdep_public.h"
27 
28 #ifndef HAVE_READPASSPHRASE
29 # include <replacements/readpassphrase.h>
30 #else
31 # include <readpassphrase.h>
32 #endif
33 
34 /* these headers are needed for basename */
35 #ifdef HAVE_STRING_H
36 # include <string.h>
37 #endif
38 #ifdef HAVE_LIBGEN_H
39 # include <libgen.h>
40 #endif
41 
42 #if !HAVE_POLL
43 #include <fakepoll.h>
44 #define poll(fds, nfds, timeout) fakepoll((fds), (nfds), (timeout))
45 #endif /* !HAVE_POLL */
46 
47 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
48 #pragma GCC visibility push(hidden)
49 #endif
50 
51 #ifdef __cplusplus
52 extern "C"
53 {
54 #endif
55 
56 #if !HAVE_VSNPRINTF
57 #if HAVE__VSNPRINTF
58 #undef vsnprintf
59 #define vsnprintf _vsnprintf
60 #else
61 int vsnprintf(char *ret, size_t max, const char *fmt, va_list ap);
62 #endif /* !HAVE__VSNPRINTF */
63 #endif /* HAVE_VSNPRINTF */
64 
65 #if !HAVE_ASPRINTF
66 int asprintf(char **ret, const char *fmt, ...);
67 #endif /* !HAVE_ASPRINTF */
68 
69 #if !HAVE_VASPRINTF
70 int vasprintf(char **ret, const char *fmt, va_list ap);
71 #endif /* !HAVE_VASPRINTF */
72 
73 #if !HAVE_ATOLL
74 tds_sysdep_int64_type atoll(const char *nptr);
75 #endif /* !HAVE_ATOLL */
76 
77 #if !HAVE_STRTOK_R
78 char *strtok_r(char *str, const char *sep, char **lasts);
79 #endif /* !HAVE_STRTOK_R */
80 
81 #if HAVE_STRLCPY
82 #define tds_strlcpy(d,s,l) strlcpy(d,s,l)
83 #else
84 size_t tds_strlcpy(char *dest, const char *src, size_t len);
85 #endif
86 
87 #if HAVE_STRLCAT
88 #define tds_strlcat(d,s,l) strlcat(d,s,l)
89 #else
90 size_t tds_strlcat(char *dest, const char *src, size_t len);
91 #endif
92 
93 #if HAVE_BASENAME
94 #define tds_basename(s) basename(s)
95 #else
96 char *tds_basename(char *path);
97 #endif
98 
99 /*
100  * Microsoft's C Runtime library is missing strcasecmp and strncasecmp.
101  * Other Win32 C runtime libraries, notably minwg, may define it.
102  * There is no symbol uniquely defined in Microsoft's header files that
103  * can be used by the preprocessor to know whether we're compiling for
104  * Microsoft's library or not (or which version). Thus there's no
105  * way to automatically decide whether or not to define strcasecmp
106  * in terms of stricmp.
107  *
108  * The Microsoft *compiler* defines _MSC_VER. On the assumption that
109  * anyone using their compiler is also using their library, the below
110  * tests check _MSC_VER as a proxy.
111  */
112 #if defined(_WIN32)
113 # if !defined(strcasecmp) && defined(_MSC_VER)
114 # define strcasecmp(A, B) stricmp((A), (B))
115 # endif
116 # if !defined(strncasecmp) && defined(_MSC_VER)
117 # define strncasecmp(x,y,z) strnicmp((x),(y),(z))
118 # endif
119 int gettimeofday (struct timeval *tv, void *tz);
120 int getopt(int argc, char * const argv[], const char *optstring);
121 extern char *optarg;
122 extern int optind, offset, opterr, optreset;
123 #endif
124 
125 #ifdef __cplusplus
126 }
127 #endif
128 
129 #if defined(__GNUC__) && __GNUC__ >= 4 && !defined(__MINGW32__)
130 #pragma GCC visibility pop
131 #endif
132 
133 #endif