/* % Copyright (C) 2003-2016 GraphicsMagick Group % Copyright (C) 2002 ImageMagick Studio % % This program is covered by multiple licenses, which are described in % Copyright.txt. You should have received a copy of Copyright.txt with this % package; otherwise see http://www.graphicsmagick.org/www/Copyright.html. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L OOO CCCC AAA L EEEEE % % L O O C A A L E % % L O O C AAAAA L EEE % % L O O C A A L E % % LLLLL OOO CCCC A A LLLLL EEEEE % % % % Read/Write GraphicsMagick Locale Files % % % % % % Software Design % % John Cristy % % Kyle Shorter % % September 2002 % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % */ /* Include declarations. */ #include "magick/studio.h" #include "magick/attribute.h" #include "magick/blob.h" #include "magick/list.h" #include "magick/log.h" #include "magick/magick.h" #include "magick/utility.h" /* Forward declarations. */ static unsigned int WriteLOCALEImage(const ImageInfo *,Image *); /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + R e a d C o n f i g u r e F i l e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadConfigureFile() reads the locale configuration file which maps text % strings to localized forms. % % The format of the ReadConfigureFile method is: % % unsigned int ReadConfigureFile(Image *image,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 image: The image. % % o basename: The color configuration filename. % % o depth: depth of statements. % % o exception: Return any errors or warnings in this structure. % % */ static void ChopLocaleComponents(char *path,const unsigned long components) { long count; register char *p; if (*path == '\0') return; p=path+strlen(path)-1; if (*p == '/') *p='\0'; for (count=0; (count < (long) components) && (p > path); p--) if (*p == '/') { *p='\0'; count++; } } static unsigned int ReadConfigureFile(Image *image,const char *basename, const unsigned long depth,ExceptionInfo *exception) { char keyword[MaxTextExtent], locale[MaxTextExtent], message[MaxTextExtent], path[MaxTextExtent], *q, *token, *xml; register char *p; size_t length, token_max_length; /* Read the locale configure file. */ (void) strlcpy(path,basename,sizeof(path)); xml=(char *) FileToBlob(basename,&length,exception); if (xml == (char *) NULL) return(False); (void) strlcpy(locale,"/",sizeof(locale)); token=AllocateString(xml); token_max_length=strlen(token); for (q=xml; *q != '\0'; ) { /* Interpret XML. */ MagickGetToken(q,&q,token,token_max_length); if (*token == '\0') break; (void) strlcpy(keyword,token,MaxTextExtent); if (LocaleNCompare(keyword,"