FreeTDS API
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
include
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.31 2011-09-01 07:52:44 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
#include <freetds/pushvis.h>
48
49
#ifdef __cplusplus
50
extern
"C"
51
{
52
#endif
53
54
#if !HAVE_VSNPRINTF
55
#if HAVE__VSNPRINTF
56
#undef vsnprintf
57
#define vsnprintf _vsnprintf
58
#else
59
int
vsnprintf(
char
*ret,
size_t
max,
const
char
*fmt, va_list ap);
60
#endif
/* !HAVE__VSNPRINTF */
61
#endif
/* HAVE_VSNPRINTF */
62
63
#if !HAVE_ASPRINTF
64
int
asprintf(
char
**ret,
const
char
*fmt, ...);
65
#endif
/* !HAVE_ASPRINTF */
66
67
#if !HAVE_VASPRINTF
68
int
vasprintf(
char
**ret,
const
char
*fmt, va_list ap);
69
#endif
/* !HAVE_VASPRINTF */
70
71
#if !HAVE_STRTOK_R
72
/* Some MingW define strtok_r macro thread-safe but not reentrant but we
73
need both so avoid using the macro */
74
#undef strtok_r
75
char
*strtok_r(
char
*str,
const
char
*sep,
char
**lasts);
76
#endif
/* !HAVE_STRTOK_R */
77
78
#if !HAVE_STRSEP
79
char
*strsep(
char
**stringp,
const
char
*delim);
80
#endif
/* !HAVE_STRSEP */
81
82
#if HAVE_STRLCPY
83
#define tds_strlcpy(d,s,l) strlcpy(d,s,l)
84
#else
85
size_t
tds_strlcpy(
char
*dest,
const
char
*src,
size_t
len);
86
#endif
87
88
#if HAVE_GETADDRINFO
89
#define tds_addrinfo addrinfo
90
#define tds_getaddrinfo getaddrinfo
91
#define tds_getnameinfo getnameinfo
92
#define tds_freeaddrinfo freeaddrinfo
93
#else
94
typedef
struct
tds_addrinfo {
95
int
ai_flags;
96
int
ai_family;
97
int
ai_socktype;
98
int
ai_protocol;
99
size_t
ai_addrlen;
100
struct
sockaddr *ai_addr;
101
char
*ai_canonname;
102
struct
tds_addrinfo *ai_next;
103
} tds_addrinfo;
104
105
int
tds_getaddrinfo(
const
char
*node,
const
char
*service,
const
struct
tds_addrinfo *hints,
struct
tds_addrinfo **res);
106
int
tds_getnameinfo(
const
struct
sockaddr *sa,
size_t
salen,
char
*host,
size_t
hostlen,
char
*serv,
size_t
servlen,
int
flags);
107
void
tds_freeaddrinfo(
struct
tds_addrinfo *addr);
108
#endif
109
110
#ifndef AI_FQDN
111
#define AI_FQDN 0
112
#endif
113
114
#if HAVE_STRLCAT
115
#define tds_strlcat(d,s,l) strlcat(d,s,l)
116
#else
117
size_t
tds_strlcat(
char
*dest,
const
char
*src,
size_t
len);
118
#endif
119
120
#if HAVE_BASENAME
121
#define tds_basename(s) basename(s)
122
#else
123
char
*tds_basename(
char
*path);
124
#endif
125
126
char
*getpassarg(
char
*arg);
127
128
/*
129
* Microsoft's C Runtime library is missing strcasecmp and strncasecmp.
130
* Other Win32 C runtime libraries, notably minwg, may define it.
131
* There is no symbol uniquely defined in Microsoft's header files that
132
* can be used by the preprocessor to know whether we're compiling for
133
* Microsoft's library or not (or which version). Thus there's no
134
* way to automatically decide whether or not to define strcasecmp
135
* in terms of stricmp.
136
*
137
* The Microsoft *compiler* defines _MSC_VER. On the assumption that
138
* anyone using their compiler is also using their library, the below
139
* tests check _MSC_VER as a proxy.
140
*/
141
#if defined(_WIN32)
142
# if !defined(strcasecmp) && defined(_MSC_VER)
143
# define strcasecmp(A, B) stricmp((A), (B))
144
# endif
145
# if !defined(strncasecmp) && defined(_MSC_VER)
146
# define strncasecmp(x,y,z) strnicmp((x),(y),(z))
147
# endif
148
int
gettimeofday (
struct
timeval *tv,
void
*tz);
149
int
getopt(
int
argc,
char
*
const
argv[],
const
char
*optstring);
150
extern
char
*optarg;
151
extern
int
optind, offset, opterr, optreset;
152
#endif
153
154
#if HAVE_SOCKETPAIR
155
#define tds_socketpair(d,t,p,s) socketpair(d,t,p,s)
156
#else
157
int
tds_socketpair(
int
domain,
int
type,
int
protocol,
int
sv[2]);
158
#endif
159
160
void
tds_sleep_s(
unsigned
sec);
161
void
tds_sleep_ms(
unsigned
ms);
162
163
#ifdef __cplusplus
164
}
165
#endif
166
167
#include <freetds/popvis.h>
168
169
#endif
fakepoll.h
Provide poll call where missing.
Generated on Mon Jun 22 2015 09:00:33 for FreeTDS API by
1.8.8