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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
/**
*** UTF-8/EBCDIC wrappers to system and C library procedures.
***
*** See Copyright for the status of this software.
***
*** Author: Patrick Monnerat <pm@datasphere.ch>, DATASPHERE S.A.
**/
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <dlfcn.h>
#include <netdb.h>
#include <errno.h>
#include "config.h"
#include "libxml/xmlmemory.h"
#include "transcode.h"
static const char * lxdles = NULL;
int
_lx_getaddrinfo(const char * node, const char * service,
const struct addrinfo * hints, struct addrinfo * * res)
{
xmlDictPtr d = NULL;
int i;
i = getaddrinfo(xmlTranscodeResult(node, NULL, &d, NULL),
xmlTranscodeResult(service, NULL, &d, NULL), hints, res);
xmlZapDict(&d);
return i;
}
const char *
_lx_inet_ntop(int af, const void * src, char * dst, socklen_t size)
{
const char * cp1 = inet_ntop(af, src, dst, size);
char const * cp2;
int i;
if (!cp1)
return cp1;
if (!(cp2 = xmlTranscodeString(cp1, NULL, NULL)))
return cp2;
i = strlen(cp2);
if (i >= size) {
xmlFree((char *) cp2);
errno = ENOSPC;
return (const char *) NULL;
}
memcpy(dst, cp2, i + 1);
xmlFree((char *) cp2);
return dst;
}
void *
_lx_dlopen(const char * filename, int flag)
{
xmlDictPtr d = NULL;
void * result;
result = dlopen(xmlTranscodeResult(filename, NULL, &d, NULL), flag);
xmlZapDict(&d);
return result;
}
void *
_lx_dlsym(void * handle, const char * symbol)
{
xmlDictPtr d = NULL;
void * result;
result = dlsym(handle, xmlTranscodeResult(symbol, NULL, &d, NULL));
xmlZapDict(&d);
return result;
}
char *
_lx_dlerror(void)
{
char * cp1 = (char *) dlerror();
if (!cp1)
return cp1;
if (lxdles)
xmlFree((char *) lxdles);
lxdles = (const char *) xmlTranscodeString(cp1, NULL, NULL);
return (char *) lxdles;
}
#ifdef HAVE_ZLIB_H
#include <zlib.h>
gzFile
_lx_gzopen(const char * path, const char * mode)
{
xmlDictPtr d = NULL;
gzFile f;
f = gzopen(xmlTranscodeResult(path, NULL, &d, NULL),
xmlTranscodeResult(mode, NULL, &d, NULL));
xmlZapDict(&d);
return f;
}
gzFile
_lx_gzdopen(int fd, const char * mode)
{
xmlDictPtr d = NULL;
gzFile f;
f = gzdopen(fd, xmlTranscodeResult(mode, NULL, &d, NULL));
xmlZapDict(&d);
return f;
}
int
_lx_inflateInit2_(z_streamp strm, int windowBits,
const char * version, int stream_size)
{
xmlDictPtr d = NULL;
int r;
r = inflateInit2_(strm, windowBits,
xmlTranscodeResult(version, NULL, &d, NULL), stream_size);
xmlZapDict(&d);
return r;
}
int
_lx_deflateInit2_(z_streamp strm, int level, int method, int windowBits,
int memLevel, int strategy, const char * version, int stream_size)
{
xmlDictPtr d = NULL;
int r;
r = deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
xmlTranscodeResult(version, NULL, &d, NULL), stream_size);
xmlZapDict(&d);
return r;
}
#endif
|