* xmlInitializeCatalog: * * Do the catalog initialization. * this function is not thread safe, catalog initialization should * preferably be done once at startup */
| 3067 | * preferably be done once at startup |
| 3068 | */ |
| 3069 | void |
| 3070 | xmlInitializeCatalog(void) { |
| 3071 | if (xmlCatalogInitialized != 0) |
| 3072 | return; |
| 3073 | |
| 3074 | xmlInitializeCatalogData(); |
| 3075 | xmlRMutexLock(xmlCatalogMutex); |
| 3076 | |
| 3077 | if (getenv("XML_DEBUG_CATALOG")) |
| 3078 | xmlDebugCatalogs = 1; |
| 3079 | |
| 3080 | if (xmlDefaultCatalog == NULL) { |
| 3081 | const char *catalogs; |
| 3082 | char *path; |
| 3083 | const char *cur, *paths; |
| 3084 | xmlCatalogPtr catal; |
| 3085 | xmlCatalogEntryPtr *nextent; |
| 3086 | |
| 3087 | catalogs = (const char *) getenv("XML_CATALOG_FILES"); |
| 3088 | if (catalogs == NULL) |
| 3089 | catalogs = XML_XML_DEFAULT_CATALOG; |
| 3090 | |
| 3091 | catal = xmlCreateNewCatalog(XML_XML_CATALOG_TYPE, |
| 3092 | xmlCatalogDefaultPrefer); |
| 3093 | if (catal != NULL) { |
| 3094 | /* the XML_CATALOG_FILES envvar is allowed to contain a |
| 3095 | space-separated list of entries. */ |
| 3096 | cur = catalogs; |
| 3097 | nextent = &catal->xml; |
| 3098 | while (*cur != '\0') { |
| 3099 | while (xmlIsBlank_ch(*cur)) |
| 3100 | cur++; |
| 3101 | if (*cur != 0) { |
| 3102 | paths = cur; |
| 3103 | while ((*cur != 0) && (!xmlIsBlank_ch(*cur))) |
| 3104 | cur++; |
| 3105 | path = (char *) xmlStrndup((const xmlChar *)paths, cur - paths); |
| 3106 | if (path != NULL) { |
| 3107 | *nextent = xmlNewCatalogEntry(XML_CATA_CATALOG, NULL, |
| 3108 | NULL, BAD_CAST path, xmlCatalogDefaultPrefer, NULL); |
| 3109 | if (*nextent != NULL) |
| 3110 | nextent = &((*nextent)->next); |
| 3111 | xmlFree(path); |
| 3112 | } |
| 3113 | } |
| 3114 | } |
| 3115 | xmlDefaultCatalog = catal; |
| 3116 | } |
| 3117 | } |
| 3118 | |
| 3119 | xmlRMutexUnlock(xmlCatalogMutex); |
| 3120 | } |
| 3121 | |
| 3122 | |
| 3123 | /** |
no test coverage detected