FreeTDS API
include
freetds
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
#include <stdarg.h>
24
#include "tds_sysdep_public.h"
25
#include <freetds/sysdep_private.h>
26
27
#include <freetds/replacements/readpassphrase.h>
28
29
/* these headers are needed for basename */
30
#ifdef HAVE_STRING_H
31
# include <string.h>
32
#endif
33
#ifdef HAVE_LIBGEN_H
34
# include <libgen.h>
35
#endif
36
#ifdef HAVE_GETOPT_H
37
# include <getopt.h>
38
#endif
39
40
#if !HAVE_POLL
41
#include <
freetds/replacements/poll.h
>
42
#endif
/* !HAVE_POLL */
43
44
#include <freetds/pushvis.h>
45
46
#ifdef __cplusplus
47
extern
"C"
48
{
49
#endif
50
51
#if !HAVE_ASPRINTF
52
#undef asprintf
53
int
tds_asprintf(
char
**ret,
const
char
*fmt, ...);
54
#define asprintf tds_asprintf
55
#endif
/* !HAVE_ASPRINTF */
56
57
#if !HAVE_VASPRINTF
58
#undef vasprintf
59
int
tds_vasprintf(
char
**ret,
const
char
*fmt, va_list ap);
60
#define vasprintf tds_vasprintf
61
#endif
/* !HAVE_VASPRINTF */
62
63
#if !HAVE_STRTOK_R
64
/* Some MinGW define strtok_r macro thread-safe but not reentrant but we
65
need both so avoid using the macro */
66
#undef strtok_r
67
#if defined(_WIN32) && HAVE_STRTOK_S
68
#define strtok_r strtok_s
69
#else
70
char
*tds_strtok_r(
char
*str,
const
char
*sep,
char
**lasts);
71
#define strtok_r tds_strtok_r
72
#endif
73
#endif
/* !HAVE_STRTOK_R */
74
75
#if !HAVE_STRSEP
76
#undef strsep
77
char
*tds_strsep(
char
**stringp,
const
char
*delim);
78
#define strsep tds_strsep
79
#endif
/* !HAVE_STRSEP */
80
81
#if !HAVE_STRLCPY
82
size_t
tds_strlcpy(
char
*dest,
const
char
*src,
size_t
len);
83
#undef strlcpy
84
#define strlcpy(d,s,l) tds_strlcpy(d,s,l)
85
#endif
86
87
#if !HAVE_GETADDRINFO
88
typedef
struct
tds_addrinfo
{
89
int
ai_flags;
90
int
ai_family;
91
int
ai_socktype;
92
int
ai_protocol;
93
size_t
ai_addrlen;
94
struct
sockaddr *ai_addr;
95
char
*ai_canonname;
96
struct
tds_addrinfo
*ai_next;
97
}
tds_addrinfo
;
98
99
int
tds_getaddrinfo(
const
char
*node,
const
char
*service,
const
struct
tds_addrinfo
*hints,
struct
tds_addrinfo
**res);
100
int
tds_getnameinfo(
const
struct
sockaddr *sa,
size_t
salen,
char
*host,
size_t
hostlen,
char
*serv,
size_t
servlen,
int
flags);
101
void
tds_freeaddrinfo(
struct
tds_addrinfo
*addr);
102
#define addrinfo tds_addrinfo
103
#define getaddrinfo(n,s,h,r) tds_getaddrinfo(n,s,h,r)
104
#define getnameinfo(a,b,c,d,e,f,g) tds_getnameinfo(a,b,c,d,e,f,g)
105
#define freeaddrinfo(a) tds_freeaddrinfo(a)
106
#endif
107
108
#ifndef AI_FQDN
109
#define AI_FQDN 0
110
#endif
111
112
#if !HAVE_STRLCAT
113
size_t
tds_strlcat(
char
*dest,
const
char
*src,
size_t
len);
114
#undef strlcat
115
#define strlcat(d,s,l) tds_strlcat(d,s,l)
116
#endif
117
118
#if !HAVE_BASENAME
119
char
*tds_basename(
char
*path);
120
#define basename(path) tds_basename(path)
121
#endif
122
123
/*
124
* Microsoft's C Runtime library is missing strcasecmp and strncasecmp.
125
* Other Win32 C runtime libraries, notably MinGW, may define it.
126
* There is no symbol uniquely defined in Microsoft's header files that
127
* can be used by the preprocessor to know whether we're compiling for
128
* Microsoft's library or not (or which version). Thus there's no
129
* way to automatically decide whether or not to define strcasecmp
130
* in terms of stricmp.
131
*
132
* The Microsoft *compiler* defines _MSC_VER. On the assumption that
133
* anyone using their compiler is also using their library, the below
134
* tests check _MSC_VER as a proxy.
135
*/
136
#if defined(_WIN32)
137
# if !defined(strcasecmp) && defined(_MSC_VER)
138
# define strcasecmp(A, B) stricmp((A), (B))
139
# endif
140
# if !defined(strncasecmp) && defined(_MSC_VER)
141
# define strncasecmp(x,y,z) strnicmp((x),(y),(z))
142
# endif
143
144
#undef gettimeofday
145
int
tds_gettimeofday (
struct
timeval *tv,
void
*tz);
146
#define gettimeofday tds_gettimeofday
147
148
/* Older MinGW-w64 versions don't define these flags. */
149
#if defined(__MINGW32__) && !defined(AI_ADDRCONFIG)
150
# define AI_ADDRCONFIG 0x00000400
151
#endif
152
#if defined(__MINGW32__) && !defined(AI_V4MAPPED)
153
# define AI_V4MAPPED 0x00000800
154
#endif
155
156
#endif
157
158
#if defined(_WIN32) && defined(_MSC_VER)
159
#define tds_strtoll _strtoi64
160
#else
161
#define tds_strtoll strtoll
162
#endif
163
164
#if !HAVE_GETOPT
165
#undef getopt
166
int
tds_getopt(
int
argc,
char
*
const
argv[],
const
char
*optstring);
167
#define getopt tds_getopt
168
169
extern
char
*optarg;
170
extern
int
optind, offset, opterr, optreset;
171
#endif
172
173
#if !HAVE_SOCKETPAIR
174
int
tds_socketpair(
int
domain,
int
type,
int
protocol, TDS_SYS_SOCKET sv[2]);
175
#define socketpair(d,t,p,s) tds_socketpair(d,t,p,s)
176
#endif
177
178
#if !HAVE_DAEMON
179
int
tds_daemon(
int
no_chdir,
int
no_close);
180
#define daemon(d,c) tds_daemon(d,c)
181
#endif
182
183
#if !HAVE_SETENV
184
int
tds_setenv(
const
char
*name,
const
char
*value,
int
overwrite);
185
#define setenv(n,v,o) tds_setenv(n,v,o)
186
int
tds_unsetenv(
const
char
*name);
187
#define unsetenv(n) tds_unsetenv(n)
188
#endif
189
190
#ifdef __cplusplus
191
}
192
#endif
193
194
#include <freetds/popvis.h>
195
196
#endif
poll.h
Provide poll call where missing.
tds_addrinfo
Definition:
replacements.h:88
Generated by
1.8.20