~ubuntu-branches/debian/sid/gdal/sid

« back to all changes in this revision

Viewing changes to ogr/ogr_expat.cpp

  • Committer: Package Import Robot
  • Author(s): Francesco Paolo Lovergine
  • Date: 2012-05-07 15:04:42 UTC
  • mfrom: (5.5.16 experimental)
  • Revision ID: package-import@ubuntu.com-20120507150442-2eks97loeh6rq005
Tags: 1.9.0-1
* Ready for sid, starting transition.
* All symfiles updated to latest builds.
* Added dh_numpy call in debian/rules to depend on numpy ABI.
* Policy bumped to 3.9.3, no changes required.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/******************************************************************************
2
 
 * $Id: ogr_expat.cpp 18063 2009-11-21 21:11:49Z warmerdam $
 
2
 * $Id: ogr_expat.cpp 18832 2010-02-14 12:57:50Z rouault $
3
3
 *
4
4
 * Project:  OGR
5
5
 * Purpose:  Convenience function for parsing with Expat library
32
32
#include "ogr_expat.h"
33
33
#include "cpl_error.h"
34
34
 
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 $");
36
36
 
37
37
#define OGR_EXPAT_MAX_ALLOWED_ALLOC 10000000
38
38
 
 
39
/************************************************************************/
 
40
/*                          OGRExpatMalloc()                            */
 
41
/************************************************************************/
 
42
 
39
43
static void* OGRExpatMalloc(size_t size)
40
44
{
41
45
    if (size < OGR_EXPAT_MAX_ALLOWED_ALLOC)
48
52
    }
49
53
}
50
54
 
 
55
/************************************************************************/
 
56
/*                         OGRExpatRealloc()                            */
 
57
/************************************************************************/
 
58
 
51
59
static void* OGRExpatRealloc(void *ptr, size_t size)
52
60
{
53
61
    if (size < OGR_EXPAT_MAX_ALLOWED_ALLOC)
61
69
    }
62
70
}
63
71
 
 
72
/************************************************************************/
 
73
/*                  OGRExpatUnknownEncodingHandler()                    */
 
74
/************************************************************************/
 
75
 
 
76
static int OGRExpatUnknownEncodingHandler (void *unused_encodingHandlerData,
 
77
                                           const XML_Char *name,
 
78
                                           XML_Encoding *info)
 
79
{
 
80
    if (!(EQUAL(name, "WINDOWS-1252")))
 
81
        return XML_STATUS_ERROR;
 
82
 
 
83
    /* Map CP1252 bytes to Unicode values */
 
84
    int i;
 
85
    for(i=0;i<0x80;i++)
 
86
        info->map[i] = i;
 
87
 
 
88
    info->map[0x80] = 0x20AC;
 
89
    info->map[0x81] = -1;
 
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;
 
120
 
 
121
    for(i=0xA0;i<=0xFF;i++)
 
122
        info->map[i] = i;
 
123
 
 
124
    info->data    = NULL;
 
125
    info->convert = NULL;
 
126
    info->release = NULL;
 
127
 
 
128
    return XML_STATUS_OK;
 
129
}
 
130
 
 
131
/************************************************************************/
 
132
/*                       OGRCreateExpatXMLParser()                      */
 
133
/************************************************************************/
 
134
 
64
135
XML_Parser OGRCreateExpatXMLParser()
65
136
{
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);
 
142
 
 
143
    XML_SetUnknownEncodingHandler(hParser,
 
144
                                  OGRExpatUnknownEncodingHandler,
 
145
                                  NULL);
 
146
 
 
147
    return hParser;
71
148
}
72
149
 
73
150
#endif