% September 2002 %
% %
% %
-% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2017 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 %
% obtain a copy of the License at %
% %
-% http://www.imagemagick.org/script/license.php %
+% https://www.imagemagick.org/script/license.php %
% %
% Unless required by applicable law or agreed to in writing, software %
% distributed under the License is distributed on an "AS IS" BASIS, %
#include "MagickCore/configure-private.h"
#include "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
-#include "MagickCore/hashmap.h"
+#include "MagickCore/linked-list.h"
#include "MagickCore/log.h"
#include "MagickCore/log-private.h"
#include "MagickCore/memory_.h"
Static declarations.
*/
static const HandlerInfo
- LogHandlers[] =
+ LogHandlers[32] =
{
{ "Console", ConsoleHandler },
{ "Debug", DebugHandler },
{ "None", NoHandler },
{ "Stderr", StderrHandler },
{ "Stdout", StdoutHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
+ { (char *) NULL, UndefinedHandler },
{ (char *) NULL, UndefinedHandler }
};
};
static char
- log_name[MaxTextExtent] = "Magick";
+ log_name[MagickPathExtent] = "Magick";
static LinkedListInfo
*log_cache = (LinkedListInfo *) NULL;
static LinkedListInfo *AcquireLogCache(const char *filename,
ExceptionInfo *exception)
{
- const StringInfo
- *option;
-
LinkedListInfo
- *log_cache,
- *options;
+ *cache;
MagickStatusType
status;
/*
Load external log map.
*/
- log_cache=NewLinkedList(0);
- if (log_cache == (LinkedListInfo *) NULL)
+ cache=NewLinkedList(0);
+ if (cache == (LinkedListInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
status=MagickTrue;
- options=GetConfigureOptions(filename,exception);
- option=(const StringInfo *) GetNextValueInLinkedList(options);
- while (option != (const StringInfo *) NULL)
+#if !defined(MAGICKCORE_ZERO_CONFIGURATION_SUPPORT)
{
- status&=LoadLogCache(log_cache,(const char *) GetStringInfoDatum(option),
- GetStringInfoPath(option),0,exception);
+ const StringInfo
+ *option;
+
+ LinkedListInfo
+ *options;
+
+ options=GetConfigureOptions(filename,exception);
option=(const StringInfo *) GetNextValueInLinkedList(options);
+ while (option != (const StringInfo *) NULL)
+ {
+ status&=LoadLogCache(cache,(const char *) GetStringInfoDatum(option),
+ GetStringInfoPath(option),0,exception);
+ option=(const StringInfo *) GetNextValueInLinkedList(options);
+ }
+ options=DestroyConfigureOptions(options);
}
- options=DestroyConfigureOptions(options);
+#endif
/*
Load built-in log map.
*/
log_info->handler_mask=p->handler_mask;
log_info->filename=ConstantString(p->filename);
log_info->format=ConstantString(p->format);
- log_info->signature=MagickSignature;
- status&=AppendValueToLinkedList(log_cache,log_info);
+ log_info->signature=MagickCoreSignature;
+ status&=AppendValueToLinkedList(cache,log_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",log_info->name);
}
- return(log_cache);
+ return(cache);
}
\f
/*
}
#endif
-MagickExport char **GetLogList(const char *pattern,
- size_t *number_preferences,ExceptionInfo *exception)
+MagickExport char **GetLogList(const char *pattern,size_t *number_preferences,
+ ExceptionInfo *exception)
{
char
**preferences;
size_t
mask;
+ if (LogHandlers[j].name == (const char *) NULL)
+ break;
mask=1;
mask<<=j;
if ((log_info[i]->handler_mask & mask) != 0)
(void) FormatLocaleFile(file,"%s ",LogHandlers[j].name);
length+=strlen(LogHandlers[j].name);
}
- if (LogHandlers[j].name == (const char * NULL))
- break;
}
for (j=(ssize_t) length; j <= 12; j++)
(void) FormatLocaleFile(file," ");
% o format: the output format.
%
*/
-static char *TranslateEvent(const LogEventType magick_unused(type),
- const char *module,const char *function,const size_t line,
- const char *domain,const char *event)
+static char *TranslateEvent(const char *module,const char *function,
+ const size_t line,const char *domain,const char *event)
{
char
*text;
text=AcquireString(event);
if (log_info->format == (char *) NULL)
return(text);
- extent=strlen(event)+MaxTextExtent;
+ extent=strlen(event)+MagickPathExtent;
if (LocaleCompare(log_info->format,"xml") == 0)
{
char
- timestamp[MaxTextExtent];
+ timestamp[MagickPathExtent];
/*
Translate event in "XML" format.
for (p=log_info->format; *p != '\0'; p++)
{
*q='\0';
- if ((size_t) (q-text+MaxTextExtent) >= extent)
+ if ((size_t) (q-text+MagickPathExtent) >= extent)
{
- extent+=MaxTextExtent;
- text=(char *) ResizeQuantumMemory(text,extent+MaxTextExtent,
+ extent+=MagickPathExtent;
+ text=(char *) ResizeQuantumMemory(text,extent+MagickPathExtent,
sizeof(*text));
if (text == (char *) NULL)
return((char *) NULL);
assert(log_info != (LogInfo *) NULL);
assert(log_info->filename != (char *) NULL);
filename=AcquireString((char *) NULL);
- extent=MaxTextExtent;
+ extent=MagickPathExtent;
q=filename;
for (p=log_info->filename; *p != '\0'; p++)
{
*q='\0';
- if ((size_t) (q-filename+MaxTextExtent) >= extent)
+ if ((size_t) (q-filename+MagickPathExtent) >= extent)
{
- extent+=MaxTextExtent;
- filename=(char *) ResizeQuantumMemory(filename,extent+MaxTextExtent,
+ extent+=MagickPathExtent;
+ filename=(char *) ResizeQuantumMemory(filename,extent+MagickPathExtent,
sizeof(*filename));
if (filename == (char *) NULL)
return((char *) NULL);
}
MagickBooleanType LogMagickEventList(const LogEventType type,const char *module,
- const char *function,const size_t line,const char *format,
- va_list operands)
+ const char *function,const size_t line,const char *format,va_list operands)
{
char
- event[MaxTextExtent],
+ event[MagickPathExtent],
*text;
const char
}
domain=CommandOptionToMnemonic(MagickLogEventOptions,type);
#if defined(MAGICKCORE_HAVE_VSNPRINTF)
- n=vsnprintf(event,MaxTextExtent,format,operands);
+ n=vsnprintf(event,MagickPathExtent,format,operands);
#else
n=vsprintf(event,format,operands);
#endif
if (n < 0)
- event[MaxTextExtent-1]='\0';
- text=TranslateEvent(type,module,function,line,domain,event);
+ event[MagickPathExtent-1]='\0';
+ text=TranslateEvent(module,function,line,domain,event);
if (text == (char *) NULL)
{
(void) ContinueTimer((TimerInfo *) &log_info->timer);
% %
% %
% %
-+ L o a d L o g L i s t %
++ L o a d L o g C a c h e %
% %
% %
% %
%
% The format of the LoadLogCache method is:
%
-% MagickBooleanType LoadLogCache(LinkedListInfo *log_cache,const char *xml,
+% MagickBooleanType LoadLogCache(LinkedListInfo *cache,const char *xml,
% const char *filename,const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
% o exception: return any errors or warnings in this structure.
%
*/
-static MagickBooleanType LoadLogCache(LinkedListInfo *log_cache,const char *xml,
+static MagickBooleanType LoadLogCache(LinkedListInfo *cache,const char *xml,
const char *filename,const size_t depth,ExceptionInfo *exception)
{
char
- keyword[MaxTextExtent],
+ keyword[MagickPathExtent],
*token;
const char
MagickStatusType
status;
+ size_t
+ extent;
+
/*
Load the log map file.
*/
if (xml == (const char *) NULL)
return(MagickFalse);
status=MagickTrue;
- token=AcquireString((const char *) xml);
+ token=AcquireString(xml);
+ extent=strlen(token)+MagickPathExtent;
for (q=(const char *) xml; *q != '\0'; )
{
/*
Interpret XML.
*/
- GetMagickToken(q,&q,token);
+ GetNextToken(q,&q,extent,token);
if (*token == '\0')
break;
- (void) CopyMagickString(keyword,token,MaxTextExtent);
+ (void) CopyMagickString(keyword,token,MagickPathExtent);
if (LocaleNCompare(keyword,"<!DOCTYPE",9) == 0)
{
/*
Doctype element.
*/
while ((LocaleNCompare(q,"]>",2) != 0) && (*q != '\0'))
- GetMagickToken(q,&q,token);
+ GetNextToken(q,&q,extent,token);
continue;
}
if (LocaleNCompare(keyword,"<!--",4) == 0)
Comment element.
*/
while ((LocaleNCompare(q,"->",2) != 0) && (*q != '\0'))
- GetMagickToken(q,&q,token);
+ GetNextToken(q,&q,extent,token);
continue;
}
if (LocaleCompare(keyword,"<include") == 0)
*/
while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
{
- (void) CopyMagickString(keyword,token,MaxTextExtent);
- GetMagickToken(q,&q,token);
+ (void) CopyMagickString(keyword,token,MagickPathExtent);
+ GetNextToken(q,&q,extent,token);
if (*token != '=')
continue;
- GetMagickToken(q,&q,token);
+ GetNextToken(q,&q,extent,token);
if (LocaleCompare(keyword,"file") == 0)
{
if (depth > 200)
else
{
char
- path[MaxTextExtent],
- *xml;
+ path[MagickPathExtent],
+ *file_xml;
GetPathComponent(filename,HeadPath,path);
if (*path != '\0')
(void) ConcatenateMagickString(path,DirectorySeparator,
- MaxTextExtent);
+ MagickPathExtent);
if (*token == *DirectorySeparator)
- (void) CopyMagickString(path,token,MaxTextExtent);
+ (void) CopyMagickString(path,token,MagickPathExtent);
else
- (void) ConcatenateMagickString(path,token,MaxTextExtent);
- xml=FileToXML(path,~0UL);
- if (xml != (char *) NULL)
+ (void) ConcatenateMagickString(path,token,MagickPathExtent);
+ file_xml=FileToXML(path,~0UL);
+ if (file_xml != (char *) NULL)
{
- status&=LoadLogCache(log_cache,xml,path,depth+1,
+ status&=LoadLogCache(cache,file_xml,path,depth+1,
exception);
- xml=DestroyString(xml);
+ file_xml=DestroyString(file_xml);
}
}
}
(void) ResetMagickMemory(log_info,0,sizeof(*log_info));
log_info->path=ConstantString(filename);
GetTimerInfo((TimerInfo *) &log_info->timer);
- log_info->signature=MagickSignature;
+ log_info->signature=MagickCoreSignature;
continue;
}
if (log_info == (LogInfo *) NULL)
continue;
if (LocaleCompare(keyword,"</logmap>") == 0)
{
- status=AppendValueToLinkedList(log_cache,log_info);
+ status=AppendValueToLinkedList(cache,log_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",filename);
log_info=(LogInfo *) NULL;
continue;
}
- GetMagickToken(q,(const char **) NULL,token);
+ GetNextToken(q,(const char **) NULL,extent,token);
if (*token != '=')
continue;
- GetMagickToken(q,&q,token);
- GetMagickToken(q,&q,token);
+ GetNextToken(q,&q,extent,token);
+ GetNextToken(q,&q,extent,token);
switch (*keyword)
{
case 'E':
}
}
token=DestroyString(token);
- if (log_cache == (LinkedListInfo *) NULL)
+ if (cache == (LinkedListInfo *) NULL)
return(MagickFalse);
return(status != 0 ? MagickTrue : MagickFalse);
}
MagickExport const char *SetLogName(const char *name)
{
if ((name != (char *) NULL) && (*name != '\0'))
- (void) CopyMagickString(log_name,name,MaxTextExtent);
+ (void) CopyMagickString(log_name,name,MagickPathExtent);
return(log_name);
}