| Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 1 | /* Copyright (c) 2005-2006 ActiveState Software Inc. | 
 | 2 |  * | 
 | 3 |  * Namespace all expat exported symbols to avoid dynamic loading symbol | 
 | 4 |  * collisions when embedding Python. | 
 | 5 |  * | 
 | 6 |  * The Problem: | 
 | 7 |  * - you embed Python in some app | 
 | 8 |  * - the app dynamically loads libexpat of version X | 
 | 9 |  * - the embedded Python imports pyexpat (which was built against | 
 | 10 |  *   libexpat version X+n) | 
 | 11 |  * --> pyexpat gets the expat symbols from the already loaded and *older* | 
 | 12 |  *     libexpat: crash (Specifically the crash we observed was in | 
 | 13 |  *     getting an old XML_ErrorString (from xmlparse.c) and then calling | 
 | 14 |  *     it with newer values in the XML_Error enum: | 
 | 15 |  * | 
 | 16 |  *       // pyexpat.c, line 1970 | 
 | 17 |  *       ... | 
 | 18 |  *       // Added in Expat 1.95.7. | 
 | 19 |  *       MYCONST(XML_ERROR_UNBOUND_PREFIX); | 
 | 20 |  *       ... | 
 | 21 |  * | 
 | 22 |  * | 
 | 23 |  * The Solution: | 
 | 24 |  * Prefix all a exported symbols with "PyExpat_". This is similar to | 
 | 25 |  * what Mozilla does for some common libs: | 
 | 26 |  * http://lxr.mozilla.org/seamonkey/source/modules/libimg/png/mozpngconf.h#115 | 
 | 27 |  * | 
 | 28 |  * The list of relevant exported symbols can be had with this command: | 
 | 29 |  *  | 
 | 30 |        nm pyexpat.so \ | 
 | 31 |            | grep -v " [a-zBUA] " \ | 
 | 32 |            | grep -v "_fini\|_init\|initpyexpat" | 
 | 33 |  * | 
 | 34 |  * If any of those symbols are NOT prefixed with "PyExpat_" then | 
 | 35 |  * a #define should be added for it here. | 
 | 36 |  */ | 
 | 37 |  | 
 | 38 | #ifndef PYEXPATNS_H | 
 | 39 | #define PYEXPATNS_H | 
 | 40 |  | 
 | 41 | #define XML_DefaultCurrent              PyExpat_XML_DefaultCurrent | 
 | 42 | #define XML_ErrorString                 PyExpat_XML_ErrorString | 
 | 43 | #define XML_ExpatVersion                PyExpat_XML_ExpatVersion | 
 | 44 | #define XML_ExpatVersionInfo            PyExpat_XML_ExpatVersionInfo | 
 | 45 | #define XML_ExternalEntityParserCreate  PyExpat_XML_ExternalEntityParserCreate | 
 | 46 | #define XML_FreeContentModel            PyExpat_XML_FreeContentModel | 
 | 47 | #define XML_GetBase                     PyExpat_XML_GetBase | 
 | 48 | #define XML_GetBuffer                   PyExpat_XML_GetBuffer | 
 | 49 | #define XML_GetCurrentByteCount         PyExpat_XML_GetCurrentByteCount | 
 | 50 | #define XML_GetCurrentByteIndex         PyExpat_XML_GetCurrentByteIndex | 
 | 51 | #define XML_GetCurrentColumnNumber      PyExpat_XML_GetCurrentColumnNumber | 
 | 52 | #define XML_GetCurrentLineNumber        PyExpat_XML_GetCurrentLineNumber | 
 | 53 | #define XML_GetErrorCode                PyExpat_XML_GetErrorCode | 
 | 54 | #define XML_GetFeatureList              PyExpat_XML_GetFeatureList | 
 | 55 | #define XML_GetIdAttributeIndex         PyExpat_XML_GetIdAttributeIndex | 
 | 56 | #define XML_GetInputContext             PyExpat_XML_GetInputContext | 
 | 57 | #define XML_GetParsingStatus            PyExpat_XML_GetParsingStatus | 
 | 58 | #define XML_GetSpecifiedAttributeCount  PyExpat_XML_GetSpecifiedAttributeCount | 
 | 59 | #define XmlGetUtf16InternalEncoding     PyExpat_XmlGetUtf16InternalEncoding | 
 | 60 | #define XmlGetUtf16InternalEncodingNS   PyExpat_XmlGetUtf16InternalEncodingNS | 
 | 61 | #define XmlGetUtf8InternalEncoding      PyExpat_XmlGetUtf8InternalEncoding | 
 | 62 | #define XmlGetUtf8InternalEncodingNS    PyExpat_XmlGetUtf8InternalEncodingNS | 
 | 63 | #define XmlInitEncoding                 PyExpat_XmlInitEncoding | 
 | 64 | #define XmlInitEncodingNS               PyExpat_XmlInitEncodingNS | 
 | 65 | #define XmlInitUnknownEncoding          PyExpat_XmlInitUnknownEncoding | 
 | 66 | #define XmlInitUnknownEncodingNS        PyExpat_XmlInitUnknownEncodingNS | 
 | 67 | #define XML_MemFree                     PyExpat_XML_MemFree | 
 | 68 | #define XML_MemMalloc                   PyExpat_XML_MemMalloc | 
 | 69 | #define XML_MemRealloc                  PyExpat_XML_MemRealloc | 
 | 70 | #define XML_Parse                       PyExpat_XML_Parse | 
 | 71 | #define XML_ParseBuffer                 PyExpat_XML_ParseBuffer | 
 | 72 | #define XML_ParserCreate                PyExpat_XML_ParserCreate | 
 | 73 | #define XML_ParserCreate_MM             PyExpat_XML_ParserCreate_MM | 
 | 74 | #define XML_ParserCreateNS              PyExpat_XML_ParserCreateNS | 
 | 75 | #define XML_ParserFree                  PyExpat_XML_ParserFree | 
 | 76 | #define XML_ParserReset                 PyExpat_XML_ParserReset | 
 | 77 | #define XmlParseXmlDecl                 PyExpat_XmlParseXmlDecl | 
 | 78 | #define XmlParseXmlDeclNS               PyExpat_XmlParseXmlDeclNS | 
 | 79 | #define XmlPrologStateInit              PyExpat_XmlPrologStateInit | 
 | 80 | #define XmlPrologStateInitExternalEntity    PyExpat_XmlPrologStateInitExternalEntity | 
 | 81 | #define XML_ResumeParser                PyExpat_XML_ResumeParser | 
 | 82 | #define XML_SetAttlistDeclHandler       PyExpat_XML_SetAttlistDeclHandler | 
 | 83 | #define XML_SetBase                     PyExpat_XML_SetBase | 
 | 84 | #define XML_SetCdataSectionHandler      PyExpat_XML_SetCdataSectionHandler | 
 | 85 | #define XML_SetCharacterDataHandler     PyExpat_XML_SetCharacterDataHandler | 
 | 86 | #define XML_SetCommentHandler           PyExpat_XML_SetCommentHandler | 
 | 87 | #define XML_SetDefaultHandler           PyExpat_XML_SetDefaultHandler | 
 | 88 | #define XML_SetDefaultHandlerExpand     PyExpat_XML_SetDefaultHandlerExpand | 
 | 89 | #define XML_SetDoctypeDeclHandler       PyExpat_XML_SetDoctypeDeclHandler | 
 | 90 | #define XML_SetElementDeclHandler       PyExpat_XML_SetElementDeclHandler | 
 | 91 | #define XML_SetElementHandler           PyExpat_XML_SetElementHandler | 
 | 92 | #define XML_SetEncoding                 PyExpat_XML_SetEncoding | 
 | 93 | #define XML_SetEndCdataSectionHandler   PyExpat_XML_SetEndCdataSectionHandler | 
 | 94 | #define XML_SetEndDoctypeDeclHandler    PyExpat_XML_SetEndDoctypeDeclHandler | 
 | 95 | #define XML_SetEndElementHandler        PyExpat_XML_SetEndElementHandler | 
 | 96 | #define XML_SetEndNamespaceDeclHandler  PyExpat_XML_SetEndNamespaceDeclHandler | 
 | 97 | #define XML_SetEntityDeclHandler        PyExpat_XML_SetEntityDeclHandler | 
 | 98 | #define XML_SetExternalEntityRefHandler PyExpat_XML_SetExternalEntityRefHandler | 
 | 99 | #define XML_SetExternalEntityRefHandlerArg  PyExpat_XML_SetExternalEntityRefHandlerArg | 
| Gregory P. Smith | 8e91cf6 | 2012-03-14 14:26:55 -0700 | [diff] [blame] | 100 | #define XML_SetHashSalt                 PyExpat_XML_SetHashSalt | 
| Thomas Wouters | 0e3f591 | 2006-08-11 14:57:12 +0000 | [diff] [blame] | 101 | #define XML_SetNamespaceDeclHandler     PyExpat_XML_SetNamespaceDeclHandler | 
 | 102 | #define XML_SetNotationDeclHandler      PyExpat_XML_SetNotationDeclHandler | 
 | 103 | #define XML_SetNotStandaloneHandler     PyExpat_XML_SetNotStandaloneHandler | 
 | 104 | #define XML_SetParamEntityParsing       PyExpat_XML_SetParamEntityParsing | 
 | 105 | #define XML_SetProcessingInstructionHandler PyExpat_XML_SetProcessingInstructionHandler | 
 | 106 | #define XML_SetReturnNSTriplet          PyExpat_XML_SetReturnNSTriplet | 
 | 107 | #define XML_SetSkippedEntityHandler     PyExpat_XML_SetSkippedEntityHandler | 
 | 108 | #define XML_SetStartCdataSectionHandler PyExpat_XML_SetStartCdataSectionHandler | 
 | 109 | #define XML_SetStartDoctypeDeclHandler  PyExpat_XML_SetStartDoctypeDeclHandler | 
 | 110 | #define XML_SetStartElementHandler      PyExpat_XML_SetStartElementHandler | 
 | 111 | #define XML_SetStartNamespaceDeclHandler    PyExpat_XML_SetStartNamespaceDeclHandler | 
 | 112 | #define XML_SetUnknownEncodingHandler   PyExpat_XML_SetUnknownEncodingHandler | 
 | 113 | #define XML_SetUnparsedEntityDeclHandler    PyExpat_XML_SetUnparsedEntityDeclHandler | 
 | 114 | #define XML_SetUserData                 PyExpat_XML_SetUserData | 
 | 115 | #define XML_SetXmlDeclHandler           PyExpat_XML_SetXmlDeclHandler | 
 | 116 | #define XmlSizeOfUnknownEncoding        PyExpat_XmlSizeOfUnknownEncoding | 
 | 117 | #define XML_StopParser                  PyExpat_XML_StopParser | 
 | 118 | #define XML_UseForeignDTD               PyExpat_XML_UseForeignDTD | 
 | 119 | #define XML_UseParserAsHandlerArg       PyExpat_XML_UseParserAsHandlerArg | 
 | 120 | #define XmlUtf16Encode                  PyExpat_XmlUtf16Encode | 
 | 121 | #define XmlUtf8Encode                   PyExpat_XmlUtf8Encode | 
 | 122 |  | 
 | 123 |  | 
 | 124 | #endif /* !PYEXPATNS_H */ | 
 | 125 |  |