Пример #1
0
int nb_cleanup(char *cname)
{
    char temp[256];

    strcpy(temp, "\\clients\\client1");
    SubstituteString(temp, "client1", cname, sizeof(temp));
    SubstituteString(temp, "clients", HostName, sizeof(temp));
    nb_deltree(temp);
    return(0);
}
Пример #2
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
+   L o a d T y p e C a c h e                                                 %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  LoadTypeCache() loads the type configurations which provides a mapping
%  between type attributes and a type name.
%
%  The format of the LoadTypeCache method is:
%
%      MagickBooleanType LoadTypeCache(SplayTreeInfo *type_cache,
%        const char *xml,const char *filename,const size_t depth,
%        ExceptionInfo *exception)
%
%  A description of each parameter follows:
%
%    o xml:  The type list in XML format.
%
%    o filename:  The type list filename.
%
%    o depth: depth of <include /> statements.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static inline MagickBooleanType SetTypeNodePath(const char *filename,
  char *font_path,const char *token,char **target)
{
  char
   *path;

  path=ConstantString(token);
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
  if (strchr(path,'@') != (char *) NULL)
    SubstituteString(&path,"@ghostscript_font_path@",font_path);
#endif
  if (IsPathAccessible(path) == MagickFalse)
    {
      /*
        Relative path.
      */
      path=DestroyString(path);
      GetPathComponent(filename,HeadPath,font_path);
      (void) ConcatenateMagickString(font_path,DirectorySeparator,
        MaxTextExtent);
      (void) ConcatenateMagickString(font_path,token,MaxTextExtent);
      path=ConstantString(font_path);
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
      if (strchr(path,'@') != (char *) NULL)
        SubstituteString(&path,"@ghostscript_font_path@","");
#endif
      if (IsPathAccessible(path) == MagickFalse)
        {
          path=DestroyString(path);
          return(MagickFalse);
        }
    }

  *target=path;
  return(MagickTrue);
}
Пример #3
0
static MagickBooleanType LoadTypeList(const char *xml,const char *filename,
  const size_t depth,ExceptionInfo *exception)
{
  char
    font_path[MaxTextExtent],
    keyword[MaxTextExtent],
    *token;

  const char
    *q;

  MagickBooleanType
    status;

  TypeInfo
    *type_info;

  /*
    Load the type map file.
  */
  (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
    "Loading type configure file \"%s\" ...",filename);
  if (xml == (const char *) NULL)
    return(MagickFalse);
  if (type_list == (SplayTreeInfo *) NULL)
    {
      type_list=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
        DestroyTypeNode);
      if (type_list == (SplayTreeInfo *) NULL)
        {
          ThrowFileException(exception,ResourceLimitError,
            "MemoryAllocationFailed",filename);
          return(MagickFalse);
        }
    }
  status=MagickTrue;
  type_info=(TypeInfo *) NULL;
  token=AcquireString(xml);
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
  /*
    Determine the Ghostscript font path.
  */
  *font_path='\0';
  if (NTGhostscriptFonts(font_path,MaxTextExtent-2))
    (void) ConcatenateMagickString(font_path,DirectorySeparator,MaxTextExtent);
#endif
  for (q=(char *) xml; *q != '\0'; )
  {
    /*
      Interpret XML.
    */
    GetMagickToken(q,&q,token);
    if (*token == '\0')
      break;
    (void) CopyMagickString(keyword,token,MaxTextExtent);
    if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
      {
        /*
          Doctype element.
        */
        while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
          GetMagickToken(q,&q,token);
        continue;
      }
    if (LocaleNCompare(keyword,"<!--",4) == 0)
      {
        /*
          Comment element.
        */
        while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
          GetMagickToken(q,&q,token);
        continue;
      }
    if (LocaleCompare(keyword,"<include") == 0)
      {
        /*
          Include element.
        */
        while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
        {
          (void) CopyMagickString(keyword,token,MaxTextExtent);
          GetMagickToken(q,&q,token);
          if (*token != '=')
            continue;
          GetMagickToken(q,&q,token);
          if (LocaleCompare(keyword,"file") == 0)
            {
              if (depth > 200)
                (void) ThrowMagickException(exception,GetMagickModule(),
                  ConfigureError,"IncludeNodeNestedTooDeeply","`%s'",token);
              else
                {
                  char
                    path[MaxTextExtent],
                    *xml;

                  ExceptionInfo
                    *sans_exception;

                  *path='\0';
                  GetPathComponent(filename,HeadPath,path);
                  if (*path != '\0')
                    (void) ConcatenateMagickString(path,DirectorySeparator,
                      MaxTextExtent);
                  if (*token == *DirectorySeparator)
                    (void) CopyMagickString(path,token,MaxTextExtent);
                  else
                    (void) ConcatenateMagickString(path,token,MaxTextExtent);
                  sans_exception=AcquireExceptionInfo();
                  xml=FileToString(path,~0UL,sans_exception);
                  sans_exception=DestroyExceptionInfo(sans_exception);
                  if (xml != (char *) NULL)
                    {
                      status=LoadTypeList(xml,path,depth+1,exception);
                      xml=(char *) RelinquishMagickMemory(xml);
                    }
                }
            }
        }
        continue;
      }
    if (LocaleCompare(keyword,"<type") == 0)
      {
        /*
          Type element.
        */
        type_info=(TypeInfo *) AcquireMagickMemory(sizeof(*type_info));
        if (type_info == (TypeInfo *) NULL)
          ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
        (void) ResetMagickMemory(type_info,0,sizeof(*type_info));
        type_info->path=ConstantString(filename);
        type_info->signature=MagickSignature;
        continue;
      }
    if (type_info == (TypeInfo *) NULL)
      continue;
    if (LocaleCompare(keyword,"/>") == 0)
      {
        status=AddValueToSplayTree(type_list,type_info->name,type_info);
        if (status == MagickFalse)
          (void) ThrowMagickException(exception,GetMagickModule(),
            ResourceLimitError,"MemoryAllocationFailed","`%s'",type_info->name);
        type_info=(TypeInfo *) NULL;
      }
    GetMagickToken(q,(const char **) NULL,token);
    if (*token != '=')
      continue;
    GetMagickToken(q,&q,token);
    GetMagickToken(q,&q,token);
    switch (*keyword)
    {
      case 'E':
      case 'e':
      {
        if (LocaleCompare((char *) keyword,"encoding") == 0)
          {
            type_info->encoding=ConstantString(token);
            break;
          }
        break;
      }
      case 'F':
      case 'f':
      {
        if (LocaleCompare((char *) keyword,"face") == 0)
          {
            type_info->face=StringToUnsignedLong(token);
            break;
          }
        if (LocaleCompare((char *) keyword,"family") == 0)
          {
            type_info->family=ConstantString(token);
            break;
          }
        if (LocaleCompare((char *) keyword,"format") == 0)
          {
            type_info->format=ConstantString(token);
            break;
          }
        if (LocaleCompare((char *) keyword,"foundry") == 0)
          {
            type_info->foundry=ConstantString(token);
            break;
          }
        if (LocaleCompare((char *) keyword,"fullname") == 0)
          {
            type_info->description=ConstantString(token);
            break;
          }
        break;
      }
      case 'G':
      case 'g':
      {
        if (LocaleCompare((char *) keyword,"glyphs") == 0)
          {
            char
              *path;

            path=ConstantString(token);
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
            if (strchr(path,'@') != (char *) NULL)
              SubstituteString(&path,"@ghostscript_font_path@",font_path);
#endif
            if (IsPathAccessible(path) == MagickFalse)
              {
                /*
                  Relative path.
                */
                path=DestroyString(path);
                GetPathComponent(filename,HeadPath,font_path);
                (void) ConcatenateMagickString(font_path,DirectorySeparator,
                  MaxTextExtent);
                (void) ConcatenateMagickString(font_path,token,MaxTextExtent);
                path=ConstantString(font_path);
                if (IsPathAccessible(path) == MagickFalse)
                  {
                    path=DestroyString(path);
                    path=ConstantString(token);
                  }
              }
            type_info->glyphs=path;
            break;
          }
        break;
      }
      case 'M':
      case 'm':
      {
        if (LocaleCompare((char *) keyword,"metrics") == 0)
          {
            char
              *path;

            path=ConstantString(token);
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
            if (strchr(path,'@') != (char *) NULL)
              SubstituteString(&path,"@ghostscript_font_path@",font_path);
#endif
            if (IsPathAccessible(path) == MagickFalse)
              {
                /*
                  Relative path.
                */
                path=DestroyString(path);
                GetPathComponent(filename,HeadPath,font_path);
                (void) ConcatenateMagickString(font_path,DirectorySeparator,
                  MaxTextExtent);
                (void) ConcatenateMagickString(font_path,token,MaxTextExtent);
                path=ConstantString(font_path);
              }
            type_info->metrics=path;
            break;
          }
        break;
      }
      case 'N':
      case 'n':
      {
        if (LocaleCompare((char *) keyword,"name") == 0)
          {
            type_info->name=ConstantString(token);
            break;
          }
        break;
      }
      case 'S':
      case 's':
      {
        if (LocaleCompare((char *) keyword,"stealth") == 0)
          {
            type_info->stealth=IsStringTrue(token);
            break;
          }
        if (LocaleCompare((char *) keyword,"stretch") == 0)
          {
            type_info->stretch=(StretchType) ParseCommandOption(
              MagickStretchOptions,MagickFalse,token);
            break;
          }
        if (LocaleCompare((char *) keyword,"style") == 0)
          {
            type_info->style=(StyleType) ParseCommandOption(MagickStyleOptions,
              MagickFalse,token);
            break;
          }
        break;
      }
      case 'W':
      case 'w':
      {
        if (LocaleCompare((char *) keyword,"weight") == 0)
          {
            type_info->weight=StringToUnsignedLong(token);
            if (LocaleCompare(token,"bold") == 0)
              type_info->weight=700;
            if (LocaleCompare(token,"normal") == 0)
              type_info->weight=400;
            break;
          }
        break;
      }
      default:
        break;
    }
  }
  token=(char *) RelinquishMagickMemory(token);
  return(status);
}
Пример #4
0
MagickExport MagickBooleanType LoadFontConfigFonts(SplayTreeInfo *type_list,
  ExceptionInfo *exception)
{
#if !defined(FC_FULLNAME)
#define FC_FULLNAME "fullname"
#endif

  char
    extension[MaxTextExtent],
    name[MaxTextExtent];

  FcChar8
    *family,
    *file,
    *fullname,
    *style;

  FcConfig
    *font_config;

  FcFontSet
    *font_set;

  FcObjectSet
    *object_set;

  FcPattern
    *pattern;

  FcResult
    status;

  int
    slant,
    width,
    weight;

  register ssize_t
    i;

  TypeInfo
    *type_info;

  /*
    Load system fonts.
  */
  (void) exception;
  font_config=FcInitLoadConfigAndFonts();
  if (font_config == (FcConfig *) NULL)
    return(MagickFalse);
  font_set=(FcFontSet *) NULL;
  object_set=FcObjectSetBuild(FC_FULLNAME,FC_FAMILY,FC_STYLE,FC_SLANT,
    FC_WIDTH,FC_WEIGHT,FC_FILE,(char *) NULL);
  if (object_set != (FcObjectSet *) NULL)
    {
      pattern=FcPatternCreate();
      if (pattern != (FcPattern *) NULL)
        {
          font_set=FcFontList(0,pattern,object_set);
          FcPatternDestroy(pattern);
        }
      FcObjectSetDestroy(object_set);
    }
  if (font_set == (FcFontSet *) NULL)
    {
      FcConfigDestroy(font_config);
      return(MagickFalse);
    }
  for (i=0; i < (ssize_t) font_set->nfont; i++)
  {
    status=FcPatternGetString(font_set->fonts[i],FC_FAMILY,0,&family);
    if (status != FcResultMatch)
      continue;
    status=FcPatternGetString(font_set->fonts[i],FC_FILE,0,&file);
    if (status != FcResultMatch)
      continue;
    *extension='\0';
    GetPathComponent((const char *) file,ExtensionPath,extension);
    if ((*extension != '\0') && (LocaleCompare(extension,"gz") == 0))
      continue;
    type_info=(TypeInfo *) AcquireMagickMemory(sizeof(*type_info));
    if (type_info == (TypeInfo *) NULL)
      continue;
    (void) ResetMagickMemory(type_info,0,sizeof(*type_info));
    type_info->path=ConstantString("System Fonts");
    type_info->signature=MagickSignature;
    (void) CopyMagickString(name,"Unknown",MaxTextExtent);
    status=FcPatternGetString(font_set->fonts[i],FC_FULLNAME,0,&fullname);
    if ((status == FcResultMatch) && (fullname != (FcChar8 *) NULL))
      (void) CopyMagickString(name,(const char *) fullname,MaxTextExtent);
    else
      {
        if (family != (FcChar8 *) NULL)
          (void) CopyMagickString(name,(const char *) family,MaxTextExtent);
        status=FcPatternGetString(font_set->fonts[i],FC_STYLE,0,&style);
        if ((status == FcResultMatch) && (style != (FcChar8 *) NULL) &&
            (LocaleCompare((const char *) style,"Regular") != 0))
          {
            (void) ConcatenateMagickString(name," ",MaxTextExtent);
            (void) ConcatenateMagickString(name,(const char *) style,
              MaxTextExtent);
          }
      }
    type_info->name=ConstantString(name);
    (void) SubstituteString(&type_info->name," ","-");
    type_info->family=ConstantString((const char *) family);
    status=FcPatternGetInteger(font_set->fonts[i],FC_SLANT,0,&slant);
    type_info->style=NormalStyle;
    if (slant == FC_SLANT_ITALIC)
      type_info->style=ItalicStyle;
    if (slant == FC_SLANT_OBLIQUE)
      type_info->style=ObliqueStyle;
    status=FcPatternGetInteger(font_set->fonts[i],FC_WIDTH,0,&width);
    type_info->stretch=NormalStretch;
    if (width >= FC_WIDTH_ULTRACONDENSED)
      type_info->stretch=UltraCondensedStretch;
    if (width >= FC_WIDTH_EXTRACONDENSED)
      type_info->stretch=ExtraCondensedStretch;
    if (width >= FC_WIDTH_CONDENSED)
      type_info->stretch=CondensedStretch;
    if (width >= FC_WIDTH_SEMICONDENSED)
      type_info->stretch=SemiCondensedStretch;
    if (width >= FC_WIDTH_NORMAL)
      type_info->stretch=NormalStretch;
    if (width >= FC_WIDTH_SEMIEXPANDED)
      type_info->stretch=SemiExpandedStretch;
    if (width >= FC_WIDTH_EXPANDED)
      type_info->stretch=ExpandedStretch;
    if (width >= FC_WIDTH_EXTRAEXPANDED)
      type_info->stretch=ExtraExpandedStretch;
    if (width >= FC_WIDTH_ULTRAEXPANDED)
      type_info->stretch=UltraExpandedStretch;
    type_info->weight=400;
    status=FcPatternGetInteger(font_set->fonts[i],FC_WEIGHT,0,&weight);
    if (weight >= FC_WEIGHT_THIN)
      type_info->weight=100;
    if (weight >= FC_WEIGHT_EXTRALIGHT)
      type_info->weight=200;
    if (weight >= FC_WEIGHT_LIGHT)
      type_info->weight=300;
    if (weight >= FC_WEIGHT_NORMAL)
      type_info->weight=400;
    if (weight >= FC_WEIGHT_MEDIUM)
      type_info->weight=500;
    if (weight >= FC_WEIGHT_DEMIBOLD)
      type_info->weight=600;
    if (weight >= FC_WEIGHT_BOLD)
      type_info->weight=700;
    if (weight >= FC_WEIGHT_EXTRABOLD)
      type_info->weight=800;
    if (weight >= FC_WEIGHT_BLACK)
      type_info->weight=900;
    type_info->glyphs=ConstantString((const char *) file);
    (void) AddValueToSplayTree(type_list,type_info->name,type_info);
  }
  FcFontSetDestroy(font_set);
  FcConfigDestroy(font_config);
  return(MagickTrue);
}
Пример #5
0
int main(int argc, char **argv)
{
  char
    *xml;

  const char
    *acronym,
    *data_type,
    *description,
    *endian,
    *mask,
    *mime_type,
    *offset,
    *pattern,
    *priority,
    *match_type,
    *value;

  ExceptionInfo
    *exception;

  size_t
    length;
 
  static char
    *doc_type =
    {
      "<!DOCTYPE mimemap [\n"
      "  <!ELEMENT mimemap (mime+)>\n"
      "  <!ELEMENT mime (#PCDATA)>\n"
      "  <!ATTLIST mime type CDATA #REQUIRED>\n"
      "  <!ATTLIST mime acronym CDATA #IMPLIED>\n"
      "  <!ATTLIST mime description CDATA #IMPLIED>\n"
      "  <!ATTLIST mime pattern CDATA #IMPLIED>\n"
      "  <!ATTLIST mime offset CDATA #IMPLIED>\n"
      "  <!ATTLIST mime data-type (string|byte|short|ssize_t) #IMPLIED>\n"
      "  <!ATTLIST mime endian (lsb|msb) #IMPLIED>\n"
      "  <!ATTLIST mime magic CDATA #IMPLIED>\n"
      "  <!ATTLIST mime mask CDATA #IMPLIED>\n"
      "  <!ATTLIST mime priority CDATA #IMPLIED>\n"
      "]>"
    };

  XMLTreeInfo
    *comment,
    *expanded_acronym,
    *glob,
    *magic,
    *match,
    *type,
    *xml_info;

  if (argc != 2)
    return(fprintf(stderr,"usage: %s xml-file\n", argv[0]));
  exception=AcquireExceptionInfo();
  xml=(char *) FileToBlob(argv[1],~0UL,&length,exception);
  if (xml == (char *) NULL)
    return(fprintf(stderr,"%s: unable to read file\n",argv[1]));
  xml_info=NewXMLTree(xml,exception);
  xml=(char *) RelinquishWizardMemory(xml);
  if (xml_info == (XMLTreeInfo *) NULL)
    return(fprintf(stderr,"%s: unable to parse xml-file\n",argv[1]));
  (void) printf("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
  (void) printf("%s\n",doc_type);
  (void) printf("<mimemap>\n");
  type=GetXMLTreeChild(xml_info,"mime-type");
	while (type != (XMLTreeInfo *) NULL)
  {
    mime_type=GetXMLTreeAttribute(type,"type");
    acronym=(const char *) NULL;
    expanded_acronym=GetXMLTreeChild(type,"acronym");
    if (expanded_acronym != (XMLTreeInfo *) NULL)
      acronym=GetXMLTreeContent(expanded_acronym);
    expanded_acronym=GetXMLTreeChild(type,"expanded-acronym");
    description=(const char *) NULL;
    comment=GetXMLTreeChild(type,"comment");
    if (comment != (XMLTreeInfo *) NULL)
      description=GetXMLTreeContent(comment);
    if (expanded_acronym != (XMLTreeInfo *) NULL)
      description=GetXMLTreeContent(expanded_acronym);
    magic=GetXMLTreeChild(type,"magic");
    priority=(char *) NULL;
    match=(XMLTreeInfo *) NULL;
    if (magic != (XMLTreeInfo *) NULL)
      {
        priority=GetXMLTreeAttribute(magic,"priority");
        match=GetXMLTreeChild(magic,"match");
      }
  	while (match != (XMLTreeInfo *) NULL)
    {
      value=(char *) NULL;
      match_type=(char *) NULL;
      mask=(char *) NULL;
      offset=(char *) NULL;
      if (match != (XMLTreeInfo *) NULL)
        {
          value=GetXMLTreeAttribute(match,"value");
          match_type=GetXMLTreeAttribute(match,"type");
          offset=GetXMLTreeAttribute(match,"offset");
          mask=GetXMLTreeAttribute(match,"mask");
        }
      (void) printf("  <mime");
      if (mime_type != (const char *) NULL)
        (void) printf(" type=\"%s\"",mime_type);
      if (description != (const char *) NULL)
        (void) printf(" description=\"%s\"",description);
      if (match_type != (const char *) NULL)
        {
          data_type="string";
          endian="undefined";
          if (strncmp(match_type,"little",6) == 0)
            endian="LSB";
          if (strncmp(match_type,"big",3) == 0)
            endian="MSB";
          if (strcmp(match_type,"byte") == 0)
            data_type="byte";
          if (strcmp(match_type+strlen(match_type)-2,"16") == 0)
            data_type="short";
          if (strcmp(match_type+strlen(match_type)-2,"32") == 0)
            data_type="ssize_t";
          (void) printf(" data-type=\"%s\"",data_type);
          if (strcmp(endian,"undefined") != 0)
            (void) printf(" endian=\"%s\"",endian);
        }
      if (offset != (const char *) NULL)
        (void) printf(" offset=\"%s\"",offset);
      if (mask != (const char *) NULL)
        (void) printf(" mask=\"%s\"",mask);
      if (value != (const char *) NULL)
        {
          char
            *magic;

          magic=AcquireString(value);
          SubstituteString(&magic,"<","&lt;");
          SubstituteString(&magic,">","&gt;");
          SubstituteString(&magic,"\"","&quot;");
          (void) printf(" magic=\"%s\"",magic);
          magic=(char *) RelinquishWizardMemory(magic);
        }
      if (priority != (const char *) NULL)
        (void) printf(" priority=\"%s\"",priority);
      (void) printf(" />\n");
		  match=GetNextXMLTreeTag(match);
    }
    glob=GetXMLTreeChild(type,"glob");
    while (glob != (XMLTreeInfo *) NULL)
    {
      pattern=GetXMLTreeAttribute(glob,"pattern");
      value=(char *) NULL;
      if (match)
        value=GetXMLTreeAttribute(match,"value");
      (void) printf("  <mime");
      if (mime_type != (const char *) NULL)
        (void) printf(" type=\"%s\"",mime_type);
      if (acronym != (const char *) NULL)
        (void) printf(" acronym=\"%s\"",acronym);
      if (description != (const char *) NULL)
        (void) printf(" description=\"%s\"",description);
      (void) printf(" priority=\"100\"");
      if (pattern != (const char *) NULL)
        (void) printf(" pattern=\"%s\"",pattern);
      (void) printf(" />\n");
      glob=GetNextXMLTreeTag(glob);
    }
    type=GetNextXMLTreeTag(type);
  }
  (void) printf("</mimemap>\n");
  xml=XMLTreeInfoToXML(xml_info);
  (void) fprintf(stderr,"%s\n",xml);
  xml=(char *) RelinquishWizardMemory(xml);
  DestroyXMLTree(xml_info);
  exception=DestroyExceptionInfo(exception);
  return(0);
}
Пример #6
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
%   W r i t e U I L I m a g e                                                 %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Procedure WriteUILImage() writes an image to a file in the X-Motif UIL table
%  format.
%
%  The format of the WriteUILImage method is:
%
%      MagickBooleanType WriteUILImage(const ImageInfo *image_info,
%        Image *image,ExceptionInfo *exception)
%
%  A description of each parameter follows.
%
%    o image_info: the image info.
%
%    o image:  The image.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType WriteUILImage(const ImageInfo *image_info,Image *image,
                                       ExceptionInfo *exception)
{
#define MaxCixels  92

    char
    basename[MagickPathExtent],
             buffer[MagickPathExtent],
             name[MagickPathExtent],
             *symbol;

    int
    j;

    MagickBooleanType
    status,
    transparent;

    MagickSizeType
    number_pixels;

    PixelInfo
    pixel;

    register const Quantum
    *p;

    register ssize_t
    i,
    x;

    size_t
    characters_per_pixel,
    colors;

    ssize_t
    k,
    y;

    static const char
    Cixel[MaxCixels+1] = " .XoO+@#$%&*=-;:>,<1234567890qwertyuipasdfghjk"
                         "lzxcvbnmMNBVCZASDFGHJKLPIUYTREWQ!~^/()_`'][{}|";

    /*
      Open output image file.
    */
    assert(image_info != (const ImageInfo *) NULL);
    assert(image_info->signature == MagickCoreSignature);
    assert(image != (Image *) NULL);
    assert(image->signature == MagickCoreSignature);
    if (image->debug != MagickFalse)
        (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
    assert(exception != (ExceptionInfo *) NULL);
    assert(exception->signature == MagickCoreSignature);
    status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
    if (status == MagickFalse)
        return(status);
    (void) TransformImageColorspace(image,sRGBColorspace,exception);
    transparent=MagickFalse;
    i=0;
    p=(const Quantum *) NULL;
    if (image->storage_class == PseudoClass)
        colors=image->colors;
    else
    {
        unsigned char
        *matte_image;

        /*
          Convert DirectClass to PseudoClass image.
        */
        matte_image=(unsigned char *) NULL;
        if (image->alpha_trait != UndefinedPixelTrait)
        {
            /*
              Map all the transparent pixels.
            */
            number_pixels=(MagickSizeType) image->columns*image->rows;
            if (number_pixels != ((MagickSizeType) (size_t) number_pixels))
                ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
            matte_image=(unsigned char *) AcquireQuantumMemory(image->columns,
                        image->rows*sizeof(*matte_image));
            if (matte_image == (unsigned char *) NULL)
                ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
            for (y=0; y < (ssize_t) image->rows; y++)
            {
                p=GetVirtualPixels(image,0,y,image->columns,1,exception);
                if (p == (const Quantum *) NULL)
                    break;
                for (x=0; x < (ssize_t) image->columns; x++)
                {
                    matte_image[i]=(unsigned char) (GetPixelAlpha(image,p) ==
                                                    (Quantum) TransparentAlpha ? 1 : 0);
                    if (matte_image[i] != 0)
                        transparent=MagickTrue;
                    i++;
                    p+=GetPixelChannels(image);
                }
            }
        }
        (void) SetImageType(image,PaletteType,exception);
        colors=image->colors;
        if (transparent != MagickFalse)
        {
            register Quantum
            *q;

            colors++;
            for (y=0; y < (ssize_t) image->rows; y++)
            {
                q=GetAuthenticPixels(image,0,y,image->columns,1,exception);
                if (q == (Quantum *) NULL)
                    break;
                for (x=0; x < (ssize_t) image->columns; x++)
                {
                    if (matte_image[i] != 0)
                        SetPixelIndex(image,(Quantum) image->colors,q);
                    q+=GetPixelChannels(image);
                }
            }
        }
        if (matte_image != (unsigned char *) NULL)
            matte_image=(unsigned char *) RelinquishMagickMemory(matte_image);
    }
    /*
      Compute the character per pixel.
    */
    characters_per_pixel=1;
    for (k=MaxCixels; (ssize_t) colors > k; k*=MaxCixels)
        characters_per_pixel++;
    /*
      UIL header.
    */
    symbol=AcquireString("");
    (void) WriteBlobString(image,"/* UIL */\n");
    GetPathComponent(image->filename,BasePath,basename);
    (void) FormatLocaleString(buffer,MagickPathExtent,
                              "value\n  %s_ct : color_table(\n",basename);
    (void) WriteBlobString(image,buffer);
    GetPixelInfo(image,&pixel);
    for (i=0; i < (ssize_t) colors; i++)
    {
        /*
          Define UIL color.
        */
        pixel=image->colormap[i];
        pixel.colorspace=sRGBColorspace;
        pixel.depth=8;
        pixel.alpha=(double) OpaqueAlpha;
        GetColorTuple(&pixel,MagickTrue,name);
        if (transparent != MagickFalse)
            if (i == (ssize_t) (colors-1))
                (void) CopyMagickString(name,"None",MagickPathExtent);
        /*
          Write UIL color.
        */
        k=i % MaxCixels;
        symbol[0]=Cixel[k];
        for (j=1; j < (int) characters_per_pixel; j++)
        {
            k=((i-k)/MaxCixels) % MaxCixels;
            symbol[j]=Cixel[k];
        }
        symbol[j]='\0';
        (void) SubstituteString(&symbol,"'","''");
        if (LocaleCompare(name,"None") == 0)
            (void) FormatLocaleString(buffer,MagickPathExtent,
                                      "    background color = '%s'",symbol);
        else
            (void) FormatLocaleString(buffer,MagickPathExtent,
                                      "    color('%s',%s) = '%s'",name,
                                      GetPixelInfoIntensity(image,image->colormap+i) <
                                      (QuantumRange/2.0) ? "background" : "foreground",symbol);
        (void) WriteBlobString(image,buffer);
        (void) FormatLocaleString(buffer,MagickPathExtent,"%s",
                                  (i == (ssize_t) (colors-1) ? ");\n" : ",\n"));
        (void) WriteBlobString(image,buffer);
    }
    /*
      Define UIL pixels.
    */
    GetPathComponent(image->filename,BasePath,basename);
    (void) FormatLocaleString(buffer,MagickPathExtent,
                              "  %s_icon : icon(color_table = %s_ct,\n",basename,basename);
    (void) WriteBlobString(image,buffer);
    for (y=0; y < (ssize_t) image->rows; y++)
    {
        p=GetVirtualPixels(image,0,y,image->columns,1,exception);
        if (p == (const Quantum *) NULL)
            break;
        (void) WriteBlobString(image,"    \"");
        for (x=0; x < (ssize_t) image->columns; x++)
        {
            k=((ssize_t) GetPixelIndex(image,p) % MaxCixels);
            symbol[0]=Cixel[k];
            for (j=1; j < (int) characters_per_pixel; j++)
            {
                k=(((int) GetPixelIndex(image,p)-k)/MaxCixels) %
                  MaxCixels;
                symbol[j]=Cixel[k];
            }
            symbol[j]='\0';
            (void) CopyMagickString(buffer,symbol,MagickPathExtent);
            (void) WriteBlobString(image,buffer);
            p+=GetPixelChannels(image);
        }
        (void) FormatLocaleString(buffer,MagickPathExtent,"\"%s\n",
                                  (y == (ssize_t) (image->rows-1) ? ");" : ","));
        (void) WriteBlobString(image,buffer);
        status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
                                image->rows);
        if (status == MagickFalse)
            break;
    }
    symbol=DestroyString(symbol);
    (void) CloseBlob(image);
    return(MagickTrue);
}
Пример #7
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
+   L o a d M i m e C a c h e                                                 %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  LoadMimeCache() loads the mime configurations which provides a mapping
%  between mime attributes and a mime name.
%
%  The format of the LoadMimeCache method is:
%
%      MagickBooleanType LoadMimeCache(LinkedListInfo *cache,const char *xml,
%        const char *filename,const size_t depth,ExceptionInfo *exception)
%
%  A description of each parameter follows:
%
%    o xml:  The mime list in XML format.
%
%    o filename:  The mime list filename.
%
%    o depth: depth of <include /> statements.
%
%    o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType LoadMimeCache(LinkedListInfo *cache,const char *xml,
  const char *filename,const size_t depth,ExceptionInfo *exception)
{
  const char
    *attribute;

  MimeInfo
    *mime_info = (MimeInfo *) NULL;

  MagickStatusType
    status;

  XMLTreeInfo
    *mime,
    *mime_map,
    *include;

  /*
    Load the mime map file.
  */
  (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
    "Loading mime map \"%s\" ...",filename);
  if (xml == (const char *) NULL)
    return(MagickFalse);
  mime_map=NewXMLTree(xml,exception);
  if (mime_map == (XMLTreeInfo *) NULL)
    return(MagickFalse);
  status=MagickTrue;
  include=GetXMLTreeChild(mime_map,"include");
  while (include != (XMLTreeInfo *) NULL)
  {
    /*
      Process include element.
    */
    attribute=GetXMLTreeAttribute(include,"file");
    if (attribute != (const char *) NULL)
      {
        if (depth > 200)
          (void) ThrowMagickException(exception,GetMagickModule(),
            ConfigureError,"IncludeElementNestedTooDeeply","`%s'",filename);
        else
          {
            char
              path[MagickPathExtent],
              *file_xml;

            GetPathComponent(filename,HeadPath,path);
            if (*path != '\0')
              (void) ConcatenateMagickString(path,DirectorySeparator,
                MagickPathExtent);
            if (*attribute == *DirectorySeparator)
              (void) CopyMagickString(path,attribute,MagickPathExtent);
            else
              (void) ConcatenateMagickString(path,attribute,MagickPathExtent);
            file_xml=FileToXML(path,~0UL);
            if (file_xml != (char *) NULL)
              {
                status&=LoadMimeCache(cache,file_xml,path,depth+1,exception);
                file_xml=DestroyString(file_xml);
              }
          }
      }
    include=GetNextXMLTreeTag(include);
  }
  mime=GetXMLTreeChild(mime_map,"mime");
  while (mime != (XMLTreeInfo *) NULL)
  {
    /*
      Process mime element.
    */
    mime_info=(MimeInfo *) AcquireCriticalMemory(sizeof(*mime_info));
    (void) ResetMagickMemory(mime_info,0,sizeof(*mime_info));
    mime_info->path=ConstantString(filename);
    mime_info->signature=MagickCoreSignature;
    attribute=GetXMLTreeAttribute(mime,"data-type");
    if (attribute != (const char *) NULL)
      mime_info->data_type=(DataType) ParseCommandOption(MagickDataTypeOptions,
        MagickTrue,attribute);
    attribute=GetXMLTreeAttribute(mime,"description");
    if (attribute != (const char *) NULL)
      mime_info->description=ConstantString(attribute);
    attribute=GetXMLTreeAttribute(mime,"endian");
    if (attribute != (const char *) NULL)
      mime_info->endian=(EndianType) ParseCommandOption(MagickEndianOptions,
        MagickTrue,attribute);
    attribute=GetXMLTreeAttribute(mime,"magic");
    if (attribute != (const char *) NULL)
      {
        char
          *token;

        const char
          *p;

        register unsigned char
          *q;

        token=AcquireString(attribute);
        (void) SubstituteString((char **) &token,"&lt;","<");
        (void) SubstituteString((char **) &token,"&amp;","&");
        (void) SubstituteString((char **) &token,"&quot;","\"");
        mime_info->magic=(unsigned char *) AcquireString(token);
        q=mime_info->magic;
        for (p=token; *p != '\0'; )
        {
          if (*p == '\\')
            {
              p++;
              if (isdigit((int) ((unsigned char) *p)) != 0)
                {
                  char
                    *end;

                  *q++=(unsigned char) strtol(p,&end,8);
                  p+=(end-p);
                  mime_info->length++;
                  continue;
                }
              switch (*p)
              {
                case 'b': *q='\b'; break;
                case 'f': *q='\f'; break;
                case 'n': *q='\n'; break;
                case 'r': *q='\r'; break;
                case 't': *q='\t'; break;
                case 'v': *q='\v'; break;
                case 'a': *q='a'; break;
                case '?': *q='\?'; break;
                default: *q=(unsigned char) (*p); break;
              }
              p++;
              q++;
              mime_info->length++;
              continue;
            }
          *q++=(unsigned char) (*p++);
          mime_info->length++;
        }
        token=DestroyString(token);
        if (mime_info->data_type != StringData)
          mime_info->value=(ssize_t) strtoul((char *) mime_info->magic,
            (char **) NULL,0);
      }
    attribute=GetXMLTreeAttribute(mime,"mask");
    if (attribute != (const char *) NULL)
      mime_info->mask=(ssize_t) strtoul(attribute,(char **) NULL,0);
    attribute=GetXMLTreeAttribute(mime,"offset");
    if (attribute != (const char *) NULL)
      {
        char
          *c;

        mime_info->offset=(MagickOffsetType) strtol(attribute,&c,0);
        if (*c == ':')
          mime_info->extent=(size_t) strtol(c+1,(char **) NULL,0);
      }
    attribute=GetXMLTreeAttribute(mime,"pattern");
    if (attribute != (const char *) NULL)
      mime_info->pattern=ConstantString(attribute);
    attribute=GetXMLTreeAttribute(mime,"priority");
    if (attribute != (const char *) NULL)
      mime_info->priority=(ssize_t) strtol(attribute,(char **) NULL,0);
    attribute=GetXMLTreeAttribute(mime,"stealth");
    if (attribute != (const char *) NULL)
      mime_info->stealth=IsStringTrue(attribute);
    attribute=GetXMLTreeAttribute(mime,"type");
    if (attribute != (const char *) NULL)
      mime_info->type=ConstantString(attribute);
    status=AppendValueToLinkedList(cache,mime_info);
    if (status == MagickFalse)
      (void) ThrowMagickException(exception,GetMagickModule(),
        ResourceLimitError,"MemoryAllocationFailed","`%s'",filename);
    mime=GetNextXMLTreeTag(mime);
  }
  mime_map=DestroyXMLTree(mime_map);
  return(status != 0 ? MagickTrue : MagickFalse);
}
Пример #8
0
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                                                             %
%                                                                             %
%                                                                             %
+   R e a d C o n f i g u r e F i l e                                         %
%                                                                             %
%                                                                             %
%                                                                             %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%  Method ReadConfigureFile reads the color configuration file which maps
%  color strings with a particular image format.
%
%  The format of the ReadConfigureFile method is:
%
%      unsigned int ReadConfigureFile(const char *basename,
%        const unsigned long depth,ExceptionInfo *exception)
%
%  A description of each parameter follows:
%
%    o status: Method ReadConfigureFile returns True if at least one color
%      is defined otherwise False.
%
%    o basename:  The color configuration filename.
%
%    o depth: depth of <include /> statements.
%
%    o exception: Return any errors or warnings in this structure.
%
%
*/
#if defined(MSWINDOWS)
static void CatDelegatePath(char *path,
			    const char *binpath,
			    const char *command)
{
  strcpy(path,binpath);
  strcat(path,command);
  if (IsAccessibleNoLogging(path))
    return;

  strcpy(path,command);
  return;
}
#endif /* defined(MSWINDOWS) */
static unsigned int ReadConfigureFile(const char *basename,
  const unsigned long depth,ExceptionInfo *exception)
{
  char
    keyword[MaxTextExtent],
    path[MaxTextExtent],
    *q,
    *token,
    *xml;

  size_t
    length;

  /*
    Read the delegates configure file.
  */
  (void) strcpy(path,basename);
  if (depth == 0)
    xml=(char *) GetConfigureBlob(basename,path,&length,exception);
  else
    xml=(char *) FileToBlob(basename,&length,exception);
  if (xml == (char *) NULL)
    xml=AllocateString(DelegateMap);
  token=AllocateString(xml);
  for (q=xml; *q != '\0'; )
    {
      /*
        Interpret XML.
      */
      GetToken(q,&q,token);
      if (*token == '\0')
        break;
      (void) strlcpy(keyword,token,MaxTextExtent);
      if (LocaleNCompare(keyword,"<!--",4) == 0)
        {
          /*
            Comment element.
          */
          while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
            GetToken(q,&q,token);
          continue;
        }
      if (LocaleCompare(keyword,"<include") == 0)
        {
          /*
            Include element.
          */
          while ((*token != '>') && (*q != '\0'))
            {
              (void) strlcpy(keyword,token,MaxTextExtent);
              GetToken(q,&q,token);
              if (*token != '=')
                continue;
              GetToken(q,&q,token);
              if (LocaleCompare(keyword,"file") == 0)
                {
                  if (depth > 200)
                    ThrowException(exception,ConfigureError,IncludeElementNestedTooDeeply,path);
                  else
                    {
                      char
                        filename[MaxTextExtent];

                      GetPathComponent(path,HeadPath,filename);
                      if (*filename != '\0')
                        (void) strlcat(filename,DirectorySeparator,MaxTextExtent);
                      (void) strlcat(filename,token,MaxTextExtent);
                      (void) ReadConfigureFile(filename,depth+1,exception);
                    }
                  if (delegate_list != (DelegateInfo *) NULL)
                    while (delegate_list->next != (DelegateInfo *) NULL)
                      delegate_list=delegate_list->next;
                }
            }
          continue;
        }
      if (LocaleCompare(keyword,"<delegate") == 0)
        {
          DelegateInfo
            *delegate_info;

          /*
            Allocate memory for the delegate list.
          */
          delegate_info=MagickAllocateMemory(DelegateInfo *,sizeof(DelegateInfo));
          if (delegate_info == (DelegateInfo *) NULL)
            MagickFatalError3(ResourceLimitFatalError,MemoryAllocationFailed,
                             UnableToAllocateDelegateInfo);
          (void) memset(delegate_info,0,sizeof(DelegateInfo));
          delegate_info->path=AcquireString(path);
          delegate_info->signature=MagickSignature;
          if (delegate_list == (DelegateInfo *) NULL)
            {
              delegate_list=delegate_info;
              continue;
            }
          delegate_list->next=delegate_info;
          delegate_info->previous=delegate_list;
          delegate_list=delegate_list->next;
          continue;
        }
      if (delegate_list == (DelegateInfo *) NULL)
        continue;
      GetToken(q,(char **) NULL,token);
      if (*token != '=')
        continue;
      GetToken(q,&q,token);
      GetToken(q,&q,token);
      switch (*keyword)
        {
        case 'C':
        case 'c':
          {
            if (LocaleCompare((char *) keyword,"command") == 0)
              {
                delegate_list->commands=AllocateString(token);
#if defined(MSWINDOWS)
                if (strchr(delegate_list->commands,'@') != (char *) NULL)
                  {
                    char
                      BinPath[MaxTextExtent],
                      path[MaxTextExtent];

                    BinPath[0]=0;
                    /* Substitute @PSDelegate@ with path to Ghostscript */
                    NTGhostscriptEXE(path,MaxTextExtent-1);
                    SubstituteString((char **) &delegate_list->commands,
                                     "@PSDelegate@",path);

# if defined(UseInstalledMagick)
#  if defined(MagickBinPath)
                    strcpy(BinPath,MagickBinPath);
#  else
                    {
                      char
                        *key,
                        *key_value;
                    
                      /* Obtain installation path from registry */
                      key="BinPath";
                      key_value=NTRegistryKeyLookup(key);
                      if (!key_value)
                        {
                          ThrowException(exception,ConfigureError,
                              RegistryKeyLookupFailed,key);
                        }
                      else
                        {
                          strcpy(BinPath,key_value);
                          MagickFreeMemory(key_value);
                        }
                    }
#  endif /* defined(MagickBinPath) */
# else
                    /* Base path off of client path */
                    strcpy(BinPath,SetClientPath(NULL));
# endif /* defined(UseInstalledMagick) */
                    if ((BinPath[0] != 0) &&
                        (BinPath[strlen(BinPath)-1] != *DirectorySeparator))
                      strcat(BinPath,DirectorySeparator);

                    /* Substitute @GMDelegate@ with path to gm.exe */
                    CatDelegatePath(path,BinPath,"gm.exe");
                    SubstituteString((char **) &delegate_list->commands,
                                     "@GMDelegate@",path);

                    /* Substitute @GMDisplayDelegate@ with path to
                       gmdisplay.exe */
                    CatDelegatePath(path,BinPath,"gmdisplay.exe");
                    SubstituteString((char **) &delegate_list->commands,
                                     "@GMDisplayDelegate@",path);

                    /* Substitute @MPEGDecodeDelegate@ with path to
                       mpeg2dec.exe */
                    CatDelegatePath(path,BinPath,"mpeg2dec.exe");
                    SubstituteString((char **) &delegate_list->commands,
                                     "@MPEGDecodeDelegate@",path);

                    /* Substitute @MPEGEncodeDelegate@ with path to
                       mpeg2enc.exe */
                    CatDelegatePath(path,BinPath,"mpeg2enc.exe");
                    SubstituteString((char **) &delegate_list->commands,
                                     "@MPEGEncodeDelegate@",path);

                    /* Substitute @HPGLDecodeDelegate@ with path to
                       hp2xx.exe */
                    CatDelegatePath(path,BinPath,"hp2xx.exe");
                    SubstituteString((char **) &delegate_list->commands,
                                     "@HPGLDecodeDelegate@",path);
                  }
#endif /* defined(MSWINDOWS) */
              } /* LocaleCompare */
            break;
          }
        case 'D':
        case 'd':
          {
            if (LocaleCompare((char *) keyword,"decode") == 0)
              {
                delegate_list->decode=AcquireString(token);
                delegate_list->mode=1;
                break;
              }
            break;
          }
        case 'E':
        case 'e':
          {
            if (LocaleCompare((char *) keyword,"encode") == 0)
              {
                delegate_list->encode=AcquireString(token);
                delegate_list->mode=(-1);
                break;
              }
            break;
          }
        case 'M':
        case 'm':
          {
            if (LocaleCompare((char *) keyword,"mode") == 0)
              {
                delegate_list->mode=1;
                if (LocaleCompare(token,"bi") == 0)
                  delegate_list->mode=0;
                else
                  if (LocaleCompare(token,"encode") == 0)
                    delegate_list->mode=(-1);
                break;
              }
            break;
          }
        case 'S':
        case 's':
          {
            if (LocaleCompare((char *) keyword,"stealth") == 0)
              {
                delegate_list->stealth=LocaleCompare(token,"True") == 0;
                break;
              }
            break;
          }
        default:
          break;
        }
    }
Пример #9
0
static MagickBooleanType LoadTypeList(const char *xml,const char *filename,
  const unsigned long depth,ExceptionInfo *exception)
{
  char
    font_path[MaxTextExtent];

  const char
    *attribute;

  TypeInfo
    *type_info = (TypeInfo *) NULL;

  MagickBooleanType
    status;

  XMLTreeInfo
    *type,
    *type_map,
    *include;

  /*
    Load the type map file.
  */
  (void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
    "Loading type map \"%s\" ...",filename);
  if (xml == (const char *) NULL)
    return(MagickFalse);
  if (type_list == (SplayTreeInfo *) NULL)
    {
      type_list=NewSplayTree(CompareSplayTreeString,(void *(*)(void *)) NULL,
        DestroyTypeNode);
      if (type_list == (SplayTreeInfo *) NULL)
        {
          ThrowFileException(exception,ResourceLimitError,
            "MemoryAllocationFailed",filename);
          return(MagickFalse);
        }
    }
  type_map=NewXMLTree(xml,exception);
  if (type_map == (XMLTreeInfo *) NULL)
    return(MagickFalse);
  status=MagickTrue;
  include=GetXMLTreeChild(type_map,"include");
  while (include != (XMLTreeInfo *) NULL)
  {
    /*
      Process include element.
    */
    attribute=GetXMLTreeAttribute(include,"file");
    if (attribute != (const char *) NULL)
      {
        if (depth > 200)
          (void) ThrowMagickException(exception,GetMagickModule(),
            ConfigureError,"IncludeElementNestedTooDeeply","`%s'",attribute);
        else
          {
            char
              path[MaxTextExtent],
              *xml;

            ExceptionInfo
              *sans_exception;

            GetPathComponent(filename,HeadPath,path);
            if (*path != '\0')
              (void) ConcatenateMagickString(path,DirectorySeparator,
                MaxTextExtent);
            (void) ConcatenateMagickString(path,attribute,MaxTextExtent);
            sans_exception=AcquireExceptionInfo();
            xml=FileToString(path,~0,sans_exception);
            sans_exception=DestroyExceptionInfo(sans_exception);
            if (xml != (char *) NULL)
              {
                status=LoadTypeList(xml,path,depth+1,exception);
                xml=DestroyString(xml);
              }
          }
      }
    include=GetNextXMLTreeTag(include);
  }
  *font_path='\0';
#if defined(__WINDOWS__)
  if (NTGhostscriptFonts(font_path,MaxTextExtent-2))
    (void) ConcatenateMagickString(font_path,DirectorySeparator,MaxTextExtent);
#endif
  type=GetXMLTreeChild(type_map,"type");
  while (type != (XMLTreeInfo *) NULL)
  {
    /*
      Process type element.
    */
    type_info=(TypeInfo *) AcquireMagickMemory(sizeof(*type_info));
    if (type_info == (TypeInfo *) NULL)
      ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
    (void) ResetMagickMemory(type_info,0,sizeof(*type_info));
    type_info->path=ConstantString(filename);
    type_info->signature=MagickSignature;
    attribute=GetXMLTreeAttribute(type,"encoding");
    if (attribute != (const char *) NULL)
      type_info->encoding=ConstantString(attribute);
    attribute=GetXMLTreeAttribute(type,"face");
    if (attribute != (const char *) NULL)
      type_info->face=(unsigned long) atol(attribute);
    attribute=GetXMLTreeAttribute(type,"family");
    if (attribute != (const char *) NULL)
      type_info->family=ConstantString(attribute);
    attribute=GetXMLTreeAttribute(type,"format");
    if (attribute != (const char *) NULL)
      type_info->format=ConstantString(attribute);
    attribute=GetXMLTreeAttribute(type,"foundry");
    if (attribute != (const char *) NULL)
      type_info->foundry=ConstantString(attribute);
    attribute=GetXMLTreeAttribute(type,"fullname");
    if (attribute != (const char *) NULL)
      type_info->description=ConstantString(attribute);
    attribute=GetXMLTreeAttribute(type,"glyphs");
    if (attribute != (const char *) NULL)
      {
        char
          *path;

        path=ConstantString(attribute);
#if defined(__WINDOWS__)
        if (strchr(path,'@') != (char *) NULL)
          (void) SubstituteString(&path,"@ghostscript_font_path@",font_path);
#endif
        type_info->glyphs=path;
      }
    attribute=GetXMLTreeAttribute(type,"metrics");
    if (attribute != (const char *) NULL)
      {
        char
          *path;

        path=ConstantString(attribute);
#if defined(__WINDOWS__)
        if (strchr(path,'@') != (char *) NULL)
          (void) SubstituteString(&path,"@ghostscript_font_path@",font_path);
#endif
        type_info->metrics=path;
      }
    attribute=GetXMLTreeAttribute(type,"name");
    if (attribute != (const char *) NULL)
      type_info->name=ConstantString(attribute);
    attribute=GetXMLTreeAttribute(type,"stealth");
    if (attribute != (const char *) NULL)
      type_info->stealth=IsMagickTrue(attribute);
    attribute=GetXMLTreeAttribute(type,"stretch");
    if (attribute != (const char *) NULL)
      type_info->stretch=(StretchType) ParseMagickOption(MagickStretchOptions,
        MagickFalse,attribute);
    attribute=GetXMLTreeAttribute(type,"style");
    if (attribute != (const char *) NULL)
      type_info->style=(StyleType) ParseMagickOption(MagickStyleOptions,
        MagickFalse,attribute);
    attribute=GetXMLTreeAttribute(type,"weight");
    if (attribute != (const char *) NULL)
      {
        type_info->weight=(unsigned long) atol(attribute);
        if (LocaleCompare(attribute,"bold") == 0)
          type_info->weight=700;
        if (LocaleCompare(attribute,"normal") == 0)
          type_info->weight=400;
      }
    status=AddValueToSplayTree(type_list,type_info->name,type_info);
    if (status == MagickFalse)
      (void) ThrowMagickException(exception,GetMagickModule(),
        ResourceLimitError,"MemoryAllocationFailed","`%s'",filename);
    type=GetNextXMLTreeTag(type);
  }
  type_map=DestroyXMLTree(type_map);
  return(status);
}