diff --git a/include/private/buf.h b/include/private/buf.h index bff213df..c18eed42 100644 --- a/include/private/buf.h +++ b/include/private/buf.h @@ -3,45 +3,68 @@ #include -xmlBufPtr xmlBufCreate(void); -xmlBufPtr xmlBufCreateSize(size_t size); +XML_HIDDEN xmlBufPtr +xmlBufCreate(void); +XML_HIDDEN xmlBufPtr +xmlBufCreateSize(size_t size); -int xmlBufSetAllocationScheme(xmlBufPtr buf, - xmlBufferAllocationScheme scheme); -int xmlBufGetAllocationScheme(xmlBufPtr buf); +XML_HIDDEN int +xmlBufSetAllocationScheme(xmlBufPtr buf, xmlBufferAllocationScheme scheme); +XML_HIDDEN int +xmlBufGetAllocationScheme(xmlBufPtr buf); -void xmlBufFree(xmlBufPtr buf); -void xmlBufEmpty(xmlBufPtr buf); +XML_HIDDEN void +xmlBufFree(xmlBufPtr buf); +XML_HIDDEN void +xmlBufEmpty(xmlBufPtr buf); /* size_t xmlBufShrink(xmlBufPtr buf, size_t len); */ -int xmlBufGrow(xmlBufPtr buf, int len); -int xmlBufResize(xmlBufPtr buf, size_t len); +XML_HIDDEN int +xmlBufGrow(xmlBufPtr buf, int len); +XML_HIDDEN int +xmlBufResize(xmlBufPtr buf, size_t len); -int xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len); -int xmlBufCat(xmlBufPtr buf, const xmlChar *str); -int xmlBufCCat(xmlBufPtr buf, const char *str); -int xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string); +XML_HIDDEN int +xmlBufAdd(xmlBufPtr buf, const xmlChar *str, int len); +XML_HIDDEN int +xmlBufCat(xmlBufPtr buf, const xmlChar *str); +XML_HIDDEN int +xmlBufCCat(xmlBufPtr buf, const char *str); +XML_HIDDEN int +xmlBufWriteQuotedString(xmlBufPtr buf, const xmlChar *string); -size_t xmlBufAvail(const xmlBufPtr buf); -size_t xmlBufLength(const xmlBufPtr buf); +XML_HIDDEN size_t +xmlBufAvail(const xmlBufPtr buf); +XML_HIDDEN size_t +xmlBufLength(const xmlBufPtr buf); /* size_t xmlBufUse(const xmlBufPtr buf); */ -int xmlBufIsEmpty(const xmlBufPtr buf); -int xmlBufAddLen(xmlBufPtr buf, size_t len); +XML_HIDDEN int +xmlBufIsEmpty(const xmlBufPtr buf); +XML_HIDDEN int +xmlBufAddLen(xmlBufPtr buf, size_t len); /* const xmlChar * xmlBufContent(const xmlBuf *buf); */ /* const xmlChar * xmlBufEnd(xmlBufPtr buf); */ -xmlChar * xmlBufDetach(xmlBufPtr buf); +XML_HIDDEN xmlChar * +xmlBufDetach(xmlBufPtr buf); -size_t xmlBufDump(FILE *file, xmlBufPtr buf); +XML_HIDDEN size_t +xmlBufDump(FILE *file, xmlBufPtr buf); -xmlBufPtr xmlBufFromBuffer(xmlBufferPtr buffer); -xmlBufferPtr xmlBufBackToBuffer(xmlBufPtr buf); -int xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer); +XML_HIDDEN xmlBufPtr +xmlBufFromBuffer(xmlBufferPtr buffer); +XML_HIDDEN xmlBufferPtr +xmlBufBackToBuffer(xmlBufPtr buf); +XML_HIDDEN int +xmlBufMergeBuffer(xmlBufPtr buf, xmlBufferPtr buffer); -int xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input); -size_t xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input); -int xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input, - size_t base, size_t cur); +XML_HIDDEN int +xmlBufResetInput(xmlBufPtr buf, xmlParserInputPtr input); +XML_HIDDEN size_t +xmlBufGetInputBase(xmlBufPtr buf, xmlParserInputPtr input); +XML_HIDDEN int +xmlBufSetInputBaseCur(xmlBufPtr buf, xmlParserInputPtr input, + size_t base, size_t cur); #endif /* XML_BUF_H_PRIVATE__ */ diff --git a/include/private/dict.h b/include/private/dict.h index 42bebffb..fcc10bac 100644 --- a/include/private/dict.h +++ b/include/private/dict.h @@ -1,8 +1,11 @@ #ifndef XML_DICT_H_PRIVATE__ #define XML_DICT_H_PRIVATE__ -int __xmlInitializeDict(void); -void xmlCleanupDictInternal(void); -int __xmlRandom(void); +XML_HIDDEN int +__xmlInitializeDict(void); +XML_HIDDEN void +xmlCleanupDictInternal(void); +XML_HIDDEN int +__xmlRandom(void); #endif /* XML_DICT_H_PRIVATE__ */ diff --git a/include/private/enc.h b/include/private/enc.h index 77a5b98d..ddfc8aea 100644 --- a/include/private/enc.h +++ b/include/private/enc.h @@ -4,10 +4,14 @@ #include #include -void xmlInitEncodingInternal(void); +XML_HIDDEN void +xmlInitEncodingInternal(void); -int xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len); -int xmlCharEncInput(xmlParserInputBufferPtr input, int flush); -int xmlCharEncOutput(xmlOutputBufferPtr output, int init); +XML_HIDDEN int +xmlCharEncFirstLineInput(xmlParserInputBufferPtr input, int len); +XML_HIDDEN int +xmlCharEncInput(xmlParserInputBufferPtr input, int flush); +XML_HIDDEN int +xmlCharEncOutput(xmlOutputBufferPtr output, int init); #endif /* XML_ENC_H_PRIVATE__ */ diff --git a/include/private/entities.h b/include/private/entities.h index 9be17bb3..1118c6d0 100644 --- a/include/private/entities.h +++ b/include/private/entities.h @@ -4,6 +4,7 @@ #include #include -xmlChar *xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input); +XML_HIDDEN xmlChar * +xmlEncodeAttributeEntities(xmlDocPtr doc, const xmlChar *input); #endif /* XML_ENTITIES_H_PRIVATE__ */ diff --git a/include/private/error.h b/include/private/error.h index c76e0733..7f284f98 100644 --- a/include/private/error.h +++ b/include/private/error.h @@ -4,17 +4,17 @@ #include #include -void +XML_HIDDEN void __xmlRaiseError(xmlStructuredErrorFunc schannel, xmlGenericErrorFunc channel, void *data, void *ctx, void *nod, int domain, int code, xmlErrorLevel level, const char *file, int line, const char *str1, const char *str2, const char *str3, int int1, int col, const char *msg, ...) LIBXML_ATTR_FORMAT(16,17); -void +XML_HIDDEN void __xmlSimpleError(int domain, int code, xmlNodePtr node, const char *msg, const char *extra) LIBXML_ATTR_FORMAT(4,0); -void +XML_HIDDEN void xmlGenericErrorDefaultFunc(void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3); diff --git a/include/private/globals.h b/include/private/globals.h index 3ec179b7..5f3f1122 100644 --- a/include/private/globals.h +++ b/include/private/globals.h @@ -1,7 +1,9 @@ #ifndef XML_GLOBALS_H_PRIVATE__ #define XML_GLOBALS_H_PRIVATE__ -void xmlInitGlobalsInternal(void); -void xmlCleanupGlobalsInternal(void); +XML_HIDDEN void +xmlInitGlobalsInternal(void); +XML_HIDDEN void +xmlCleanupGlobalsInternal(void); #endif /* XML_GLOBALS_H_PRIVATE__ */ diff --git a/include/private/html.h b/include/private/html.h index 8f77d338..6b499296 100644 --- a/include/private/html.h +++ b/include/private/html.h @@ -5,7 +5,8 @@ #ifdef LIBXML_HTML_ENABLED -void __htmlParseContent(void *ctx); +XML_HIDDEN void +__htmlParseContent(void *ctx); #endif /* LIBXML_HTML_ENABLED */ diff --git a/include/private/io.h b/include/private/io.h index 9a1e684e..86a72e15 100644 --- a/include/private/io.h +++ b/include/private/io.h @@ -5,12 +5,14 @@ #include #include -void __xmlIOErr(int domain, int code, const char *extra); -void __xmlLoaderErr(void *ctx, const char *msg, - const char *filename) LIBXML_ATTR_FORMAT(2,0); +XML_HIDDEN void +__xmlIOErr(int domain, int code, const char *extra); +XML_HIDDEN void +__xmlLoaderErr(void *ctx, const char *msg, + const char *filename) LIBXML_ATTR_FORMAT(2,0); #ifdef LIBXML_OUTPUT_ENABLED -xmlOutputBufferPtr +XML_HIDDEN xmlOutputBufferPtr xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder); #endif diff --git a/include/private/memory.h b/include/private/memory.h index 273447fb..ef0497c6 100644 --- a/include/private/memory.h +++ b/include/private/memory.h @@ -1,7 +1,9 @@ #ifndef XML_MEMORY_H_PRIVATE__ #define XML_MEMORY_H_PRIVATE__ -void xmlInitMemoryInternal(void); -void xmlCleanupMemoryInternal(void); +XML_HIDDEN void +xmlInitMemoryInternal(void); +XML_HIDDEN void +xmlCleanupMemoryInternal(void); #endif /* XML_MEMORY_H_PRIVATE__ */ diff --git a/include/private/parser.h b/include/private/parser.h index 1bf9ee35..43945f9e 100644 --- a/include/private/parser.h +++ b/include/private/parser.h @@ -17,9 +17,11 @@ */ #define XML_VCTXT_USE_PCTXT (1u << 1) -void xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra); -void __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, - const char *msg, const xmlChar *str1, - const xmlChar *str2) LIBXML_ATTR_FORMAT(3,0); +XML_HIDDEN void +xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra); +XML_HIDDEN void +__xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors xmlerr, + const char *msg, const xmlChar *str1, + const xmlChar *str2) LIBXML_ATTR_FORMAT(3,0); #endif /* XML_PARSER_H_PRIVATE__ */ diff --git a/include/private/regexp.h b/include/private/regexp.h index 3ffb378a..f2024939 100644 --- a/include/private/regexp.h +++ b/include/private/regexp.h @@ -3,6 +3,7 @@ #include -void xmlAutomataSetFlags(xmlAutomataPtr am, int flags); +XML_HIDDEN void +xmlAutomataSetFlags(xmlAutomataPtr am, int flags); #endif /* XML_REGEXP_H_PRIVATE__ */ diff --git a/include/private/save.h b/include/private/save.h index ec970851..873aad76 100644 --- a/include/private/save.h +++ b/include/private/save.h @@ -6,9 +6,11 @@ #ifdef LIBXML_OUTPUT_ENABLED -void xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc, - xmlAttrPtr attr, const xmlChar * string); -void xmlNsListDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur); +XML_HIDDEN void +xmlBufAttrSerializeTxtContent(xmlBufPtr buf, xmlDocPtr doc, + xmlAttrPtr attr, const xmlChar * string); +XML_HIDDEN void +xmlNsListDumpOutput(xmlOutputBufferPtr buf, xmlNsPtr cur); #endif /* LIBXML_OUTPUT_ENABLED */ diff --git a/include/private/string.h b/include/private/string.h index 0c4bf541..9665fc47 100644 --- a/include/private/string.h +++ b/include/private/string.h @@ -3,6 +3,7 @@ #include -xmlChar *xmlEscapeFormatString(xmlChar **msg); +XML_HIDDEN xmlChar * +xmlEscapeFormatString(xmlChar **msg); #endif /* XML_STRING_H_PRIVATE__ */ diff --git a/include/private/threads.h b/include/private/threads.h index efb64cf0..b337bfa0 100644 --- a/include/private/threads.h +++ b/include/private/threads.h @@ -30,14 +30,21 @@ struct _xmlMutex { #endif }; -void __xmlGlobalInitMutexLock(void); -void __xmlGlobalInitMutexUnlock(void); -void __xmlGlobalInitMutexDestroy(void); +XML_HIDDEN void +__xmlGlobalInitMutexLock(void); +XML_HIDDEN void +__xmlGlobalInitMutexUnlock(void); +XML_HIDDEN void +__xmlGlobalInitMutexDestroy(void); -void xmlInitThreadsInternal(void); -void xmlCleanupThreadsInternal(void); +XML_HIDDEN void +xmlInitThreadsInternal(void); +XML_HIDDEN void +xmlCleanupThreadsInternal(void); -void xmlInitMutex(xmlMutexPtr mutex); -void xmlCleanupMutex(xmlMutexPtr mutex); +XML_HIDDEN void +xmlInitMutex(xmlMutexPtr mutex); +XML_HIDDEN void +xmlCleanupMutex(xmlMutexPtr mutex); #endif /* XML_THREADS_H_PRIVATE__ */ diff --git a/include/private/tree.h b/include/private/tree.h index e5fd83ba..fb5e1623 100644 --- a/include/private/tree.h +++ b/include/private/tree.h @@ -6,12 +6,13 @@ * node creation/destruction. It avoids spending a lot of time in locking * function while checking if the callback exists. */ -extern int __xmlRegisterCallbacks; +XML_HIDDEN extern int +__xmlRegisterCallbacks; -xmlNodePtr +XML_HIDDEN xmlNodePtr xmlStaticCopyNode(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent, int extended); -xmlNodePtr +XML_HIDDEN xmlNodePtr xmlStaticCopyNodeList(xmlNodePtr node, xmlDocPtr doc, xmlNodePtr parent); #endif /* XML_TREE_H_PRIVATE__ */ diff --git a/include/private/xinclude.h b/include/private/xinclude.h index ef9b0f02..abd0dc01 100644 --- a/include/private/xinclude.h +++ b/include/private/xinclude.h @@ -3,6 +3,7 @@ #include -int xmlXIncludeSetStreamingMode(xmlXIncludeCtxtPtr ctxt, int mode); +XML_HIDDEN int +xmlXIncludeSetStreamingMode(xmlXIncludeCtxtPtr ctxt, int mode); #endif /* XML_IO_H_PRIVATE__ */ diff --git a/include/private/xpath.h b/include/private/xpath.h index 52b29745..0e8d7525 100644 --- a/include/private/xpath.h +++ b/include/private/xpath.h @@ -1,6 +1,7 @@ #ifndef XML_XPATH_H_PRIVATE__ #define XML_XPATH_H_PRIVATE__ -void xmlInitXPathInternal(void); +XML_HIDDEN void +xmlInitXPathInternal(void); #endif /* XML_XPATH_H_PRIVATE__ */ diff --git a/include/private/xzlib.h b/include/private/xzlib.h index 001854e5..b3326980 100644 --- a/include/private/xzlib.h +++ b/include/private/xzlib.h @@ -16,11 +16,16 @@ typedef void *xzFile; /* opaque lzma file descriptor */ -xzFile __libxml2_xzopen(const char *path, const char *mode); -xzFile __libxml2_xzdopen(int fd, const char *mode); -int __libxml2_xzread(xzFile file, void *buf, unsigned len); -int __libxml2_xzclose(xzFile file); -int __libxml2_xzcompressed(xzFile f); +XML_HIDDEN xzFile +__libxml2_xzopen(const char *path, const char *mode); +XML_HIDDEN xzFile +__libxml2_xzdopen(int fd, const char *mode); +XML_HIDDEN int +__libxml2_xzread(xzFile file, void *buf, unsigned len); +XML_HIDDEN int +__libxml2_xzclose(xzFile file); +XML_HIDDEN int +__libxml2_xzcompressed(xzFile f); #endif /* LIBXML_LZMA_ENABLED */ diff --git a/libxml.h b/libxml.h index 59294473..5e881e97 100644 --- a/libxml.h +++ b/libxml.h @@ -54,6 +54,15 @@ int vfprintf(FILE *, const char *, va_list); #include "trio.h" #endif +#if !defined(_WIN32) && \ + !defined(__CYGWIN__) && \ + (defined(__clang__) || \ + (defined(__GNUC__) && (__GNUC__ >= 4))) +#define XML_HIDDEN __attribute__((visibility("hidden"))) +#else +#define XML_HIDDEN +#endif + #if defined(__clang__) || \ (defined(__GNUC__) && (__GNUC__ >= 8)) #define ATTRIBUTE_NO_SANITIZE(arg) __attribute__((no_sanitize(arg)))