]> granicus.if.org Git - imagemagick/blobdiff - MagickCore/configure.c
(no commit message)
[imagemagick] / MagickCore / configure.c
index 83051b3d5cadab66f2916f4c3393270ba2cadb2b..75ca67acd691354eaaf642dfd9ec6d6ce775c66c 100644 (file)
@@ -17,7 +17,7 @@
 %                                 July 2003                                   %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization      %
+%  Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization      %
 %  dedicated to making software imaging solutions freely available.           %
 %                                                                             %
 %  You may not use this file except in compliance with the License.  You may  %
 #include "MagickCore/memory_.h"
 #include "MagickCore/semaphore.h"
 #include "MagickCore/string_.h"
+#include "MagickCore/string-private.h"
 #include "MagickCore/token.h"
 #include "MagickCore/utility.h"
+#include "MagickCore/utility-private.h"
 #include "MagickCore/xml-tree.h"
 \f
 /*
@@ -572,23 +574,25 @@ MagickExport LinkedListInfo *GetConfigureOptions(const char *filename,
       paths=DestroyLinkedList(paths,RelinquishMagickMemory);
     }
 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
-  {
-    char
-      *blob;
+  if (GetNumberOfElementsInLinkedList(options) == 0)
+    {
+      char
+        *blob;
 
-    blob=(char *) NTResourceToBlob(filename);
-    if (blob != (char *) NULL)
-      {
-        xml=StringToStringInfo(blob);
-        SetStringInfoPath(xml,filename);
-        (void) AppendValueToLinkedList(options,xml);
-        blob=DestroyString(blob);
-      }
-  }
+      blob=(char *) NTResourceToBlob(filename);
+      if (blob != (char *) NULL)
+        {
+          xml=AcquireStringInfo(0);
+          SetStringInfoLength(xml,strlen(blob)+1);
+          SetStringInfoDatum(xml,(unsigned char *) blob);
+          SetStringInfoPath(xml,filename);
+          (void) AppendValueToLinkedList(options,xml);
+        }
+    }
 #endif
   if (GetNumberOfElementsInLinkedList(options) == 0)
     (void) ThrowMagickException(exception,GetMagickModule(),ConfigureWarning,
-      "UnableToOpenConfigureFile","`%s'",filename);
+      "UnableToOpenConfigureFile","'%s'",filename);
   ResetLinkedListIterator(options);
   return(options);
 }
@@ -622,6 +626,10 @@ MagickExport LinkedListInfo *GetConfigureOptions(const char *filename,
 MagickExport LinkedListInfo *GetConfigurePaths(const char *filename,
   ExceptionInfo *exception)
 {
+#define RegistryKey  "ConfigurePath"
+#define MagickCoreDLL  "CORE_RL_MagickCore_.dll"
+#define MagickCoreDebugDLL  "CORE_DB_MagickCore_.dll"
+
   char
     path[MaxTextExtent];
 
@@ -665,8 +673,11 @@ MagickExport LinkedListInfo *GetConfigurePaths(const char *filename,
   }
 #if defined(MAGICKCORE_INSTALLED_SUPPORT)
 #if defined(MAGICKCORE_SHARE_PATH)
+  (void) AppendValueToLinkedList(paths,ConstantString(MAGICKCORE_SHARE_PATH));
+#endif
+#if defined(MAGICKCORE_SHAREARCH_PATH)
   (void) AppendValueToLinkedList(paths,ConstantString(
-    MAGICKCORE_SHARE_PATH));
+    MAGICKCORE_SHAREARCH_PATH));
 #endif
 #if defined(MAGICKCORE_CONFIGURE_PATH)
   (void) AppendValueToLinkedList(paths,ConstantString(
@@ -678,17 +689,13 @@ MagickExport LinkedListInfo *GetConfigurePaths(const char *filename,
 #endif
 #if defined(MAGICKCORE_WINDOWS_SUPPORT) && !(defined(MAGICKCORE_CONFIGURE_PATH) || defined(MAGICKCORE_SHARE_PATH))
   {
-    char
-      *registry_key;
-
     unsigned char
       *key_value;
 
     /*
       Locate file via registry key.
     */
-    registry_key="ConfigurePath";
-    key_value=NTRegistryKeyLookup(registry_key);
+    key_value=NTRegistryKeyLookup(RegistryKey);
     if (key_value != (unsigned char *) NULL)
       {
         (void) FormatLocaleString(path,MaxTextExtent,"%s%s",(char *) key_value,
@@ -775,21 +782,22 @@ MagickExport LinkedListInfo *GetConfigurePaths(const char *filename,
     char
       module_path[MaxTextExtent];
 
-    if ((NTGetModulePath("CORE_RL_magick_.dll",module_path) != MagickFalse) ||
-        (NTGetModulePath("CORE_DB_magick_.dll",module_path) != MagickFalse))
+    if ((NTGetModulePath(MagickCoreDLL,module_path) != MagickFalse) ||
+        (NTGetModulePath(MagickCoreDebugDLL,module_path) != MagickFalse))
       {
-        char
-          *element;
+        unsigned char
+          *key_value;
 
         /*
           Search module path.
         */
         (void) FormatLocaleString(path,MaxTextExtent,"%s%s",module_path,
           DirectorySeparator);
-        element=(char *) RemoveElementByValueFromLinkedList(paths,path);
-        if (element != (char *) NULL)
-          element=DestroyString(element);
-        (void) AppendValueToLinkedList(paths,ConstantString(path));
+        key_value=NTRegistryKeyLookup(RegistryKey);
+        if (key_value == (unsigned char *) NULL)
+          (void) AppendValueToLinkedList(paths,ConstantString(path));
+        else
+          key_value=(unsigned char *) RelinquishMagickMemory(key_value);
       }
     if (NTGetModulePath("Magick.dll",module_path) != MagickFalse)
       {
@@ -1071,7 +1079,7 @@ static MagickBooleanType LoadConfigureList(const char *xml,const char *filename,
             {
               if (depth > 200)
                 (void) ThrowMagickException(exception,GetMagickModule(),
-                  ConfigureError,"IncludeElementNestedTooDeeply","`%s'",token);
+                  ConfigureError,"IncludeElementNestedTooDeeply","'%s'",token);
               else
                 {
                   char
@@ -1119,7 +1127,7 @@ static MagickBooleanType LoadConfigureList(const char *xml,const char *filename,
         status=AppendValueToLinkedList(configure_list,configure_info);
         if (status == MagickFalse)
           (void) ThrowMagickException(exception,GetMagickModule(),
-            ResourceLimitError,"MemoryAllocationFailed","`%s'",
+            ResourceLimitError,"MemoryAllocationFailed","'%s'",
             configure_info->name);
         configure_info=(ConfigureInfo *) NULL;
       }
@@ -1148,7 +1156,7 @@ static MagickBooleanType LoadConfigureList(const char *xml,const char *filename,
       {
         if (LocaleCompare((char *) keyword,"stealth") == 0)
           {
-            configure_info->stealth=IsMagickTrue(token);
+            configure_info->stealth=IsStringTrue(token);
             break;
           }
         break;
@@ -1240,7 +1248,7 @@ static MagickBooleanType LoadConfigureLists(const char *filename,
     if (configure_info == (ConfigureInfo *) NULL)
       {
         (void) ThrowMagickException(exception,GetMagickModule(),
-          ResourceLimitError,"MemoryAllocationFailed","`%s'",
+          ResourceLimitError,"MemoryAllocationFailed","'%s'",
           configure_info->name);
         continue;
       }
@@ -1253,7 +1261,7 @@ static MagickBooleanType LoadConfigureLists(const char *filename,
     status=AppendValueToLinkedList(configure_list,configure_info);
     if (status == MagickFalse)
       (void) ThrowMagickException(exception,GetMagickModule(),
-        ResourceLimitError,"MemoryAllocationFailed","`%s'",
+        ResourceLimitError,"MemoryAllocationFailed","'%s'",
         configure_info->name);
   }
   /*