32
32
#include "ogr_expat.h"
33
33
#include "cpl_error.h"
35
CPL_CVSID("$Id: ogr_expat.cpp 18063 2009-11-21 21:11:49Z warmerdam $");
35
CPL_CVSID("$Id: ogr_expat.cpp 18832 2010-02-14 12:57:50Z rouault $");
37
37
#define OGR_EXPAT_MAX_ALLOWED_ALLOC 10000000
39
/************************************************************************/
40
/* OGRExpatMalloc() */
41
/************************************************************************/
39
43
static void* OGRExpatMalloc(size_t size)
41
45
if (size < OGR_EXPAT_MAX_ALLOWED_ALLOC)
72
/************************************************************************/
73
/* OGRExpatUnknownEncodingHandler() */
74
/************************************************************************/
76
static int OGRExpatUnknownEncodingHandler (void *unused_encodingHandlerData,
80
if (!(EQUAL(name, "WINDOWS-1252")))
81
return XML_STATUS_ERROR;
83
/* Map CP1252 bytes to Unicode values */
88
info->map[0x80] = 0x20AC;
90
info->map[0x82] = 0x201A;
91
info->map[0x83] = 0x0192;
92
info->map[0x84] = 0x201E;
93
info->map[0x85] = 0x2026;
94
info->map[0x86] = 0x2020;
95
info->map[0x87] = 0x2021;
96
info->map[0x88] = 0x02C6;
97
info->map[0x89] = 0x2030;
98
info->map[0x8A] = 0x0160;
99
info->map[0x8B] = 0x2039;
100
info->map[0x8C] = 0x0152;
101
info->map[0x8D] = -1;
102
info->map[0x8E] = 0x017D;
103
info->map[0x8F] = -1;
104
info->map[0x90] = -1;
105
info->map[0x91] = 0x2018;
106
info->map[0x92] = 0x2019;
107
info->map[0x93] = 0x201C;
108
info->map[0x94] = 0x201D;
109
info->map[0x95] = 0x2022;
110
info->map[0x96] = 0x2013;
111
info->map[0x97] = 0x2014;
112
info->map[0x98] = 0x02DC;
113
info->map[0x99] = 0x2122;
114
info->map[0x9A] = 0x0161;
115
info->map[0x9B] = 0x203A;
116
info->map[0x9C] = 0x0153;
117
info->map[0x9D] = -1;
118
info->map[0x9E] = 0x017E;
119
info->map[0x9F] = 0x0178;
121
for(i=0xA0;i<=0xFF;i++)
125
info->convert = NULL;
126
info->release = NULL;
128
return XML_STATUS_OK;
131
/************************************************************************/
132
/* OGRCreateExpatXMLParser() */
133
/************************************************************************/
64
135
XML_Parser OGRCreateExpatXMLParser()
66
137
XML_Memory_Handling_Suite memsuite;
67
138
memsuite.malloc_fcn = OGRExpatMalloc;
68
139
memsuite.realloc_fcn = OGRExpatRealloc;
69
140
memsuite.free_fcn = free;
70
return XML_ParserCreate_MM(NULL, &memsuite, NULL);
141
XML_Parser hParser = XML_ParserCreate_MM(NULL, &memsuite, NULL);
143
XML_SetUnknownEncodingHandler(hParser,
144
OGRExpatUnknownEncodingHandler,