VirtualBox

source: vbox/trunk/src/libs/libxml2-2.13.2/os400/wrappers.c@ 106165

最後變更 在這個檔案從106165是 105420,由 vboxsync 提交於 4 月 前

libxml2-2.12.6: Applied and adjusted our libxml2 changes to 2.12.6. bugref:10730

  • 屬性 svn:eol-style 設為 native
檔案大小: 3.4 KB
 
1/**
2*** UTF-8/EBCDIC wrappers to system and C library procedures.
3***
4*** See Copyright for the status of this software.
5***
6*** Author: Patrick Monnerat <[email protected]>, DATASPHERE S.A.
7**/
8
9#include <sys/types.h>
10#include <sys/socket.h>
11#include <arpa/inet.h>
12#include <stdlib.h>
13#include <dlfcn.h>
14#include <netdb.h>
15#include <errno.h>
16
17#include "config.h"
18
19#include "libxml/xmlmemory.h"
20
21#include "transcode.h"
22
23
24static const char * lxdles = NULL;
25
26
27int
28_lx_getaddrinfo(const char * node, const char * service,
29 const struct addrinfo * hints, struct addrinfo * * res)
30
31{
32 xmlDictPtr d = NULL;
33 int i;
34
35 i = getaddrinfo(xmlTranscodeResult(node, NULL, &d, NULL),
36 xmlTranscodeResult(service, NULL, &d, NULL), hints, res);
37 xmlZapDict(&d);
38 return i;
39}
40
41
42const char *
43_lx_inet_ntop(int af, const void * src, char * dst, socklen_t size)
44
45{
46 const char * cp1 = inet_ntop(af, src, dst, size);
47 char const * cp2;
48 int i;
49
50 if (!cp1)
51 return cp1;
52
53 if (!(cp2 = xmlTranscodeString(cp1, NULL, NULL)))
54 return cp2;
55
56 i = strlen(cp2);
57
58 if (i >= size) {
59 xmlFree((char *) cp2);
60 errno = ENOSPC;
61 return (const char *) NULL;
62 }
63
64 memcpy(dst, cp2, i + 1);
65 xmlFree((char *) cp2);
66 return dst;
67}
68
69
70void *
71_lx_dlopen(const char * filename, int flag)
72
73{
74 xmlDictPtr d = NULL;
75 void * result;
76
77 result = dlopen(xmlTranscodeResult(filename, NULL, &d, NULL), flag);
78 xmlZapDict(&d);
79 return result;
80}
81
82
83void *
84_lx_dlsym(void * handle, const char * symbol)
85
86{
87 xmlDictPtr d = NULL;
88 void * result;
89
90 result = dlsym(handle, xmlTranscodeResult(symbol, NULL, &d, NULL));
91 xmlZapDict(&d);
92 return result;
93}
94
95
96char *
97_lx_dlerror(void)
98
99{
100 char * cp1 = (char *) dlerror();
101
102 if (!cp1)
103 return cp1;
104
105 if (lxdles)
106 xmlFree((char *) lxdles);
107
108 lxdles = (const char *) xmlTranscodeString(cp1, NULL, NULL);
109 return (char *) lxdles;
110}
111
112
113#ifdef LIBXML_ZLIB_ENABLED
114#include <zlib.h>
115
116gzFile
117_lx_gzopen(const char * path, const char * mode)
118
119{
120 xmlDictPtr d = NULL;
121 gzFile f;
122
123 f = gzopen(xmlTranscodeResult(path, NULL, &d, NULL),
124 xmlTranscodeResult(mode, NULL, &d, NULL));
125 xmlZapDict(&d);
126 return f;
127}
128
129
130gzFile
131_lx_gzdopen(int fd, const char * mode)
132
133{
134 xmlDictPtr d = NULL;
135 gzFile f;
136
137 f = gzdopen(fd, xmlTranscodeResult(mode, NULL, &d, NULL));
138 xmlZapDict(&d);
139 return f;
140}
141
142int
143_lx_inflateInit2_(z_streamp strm, int windowBits,
144 const char * version, int stream_size)
145
146{
147 xmlDictPtr d = NULL;
148 int r;
149
150 r = inflateInit2_(strm, windowBits,
151 xmlTranscodeResult(version, NULL, &d, NULL), stream_size);
152 xmlZapDict(&d);
153 return r;
154}
155
156int
157_lx_deflateInit2_(z_streamp strm, int level, int method, int windowBits,
158 int memLevel, int strategy, const char * version, int stream_size)
159
160{
161 xmlDictPtr d = NULL;
162 int r;
163
164 r = deflateInit2_(strm, level, method, windowBits, memLevel, strategy,
165 xmlTranscodeResult(version, NULL, &d, NULL), stream_size);
166 xmlZapDict(&d);
167 return r;
168}
169
170#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette