% April 2011 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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 %
/* Initialize CLI Part of MagickCLI */
cli_wand->draw_info=CloneDrawInfo(cli_wand->wand.image_info,(DrawInfo *) NULL);
cli_wand->quantize_info=AcquireQuantizeInfo(cli_wand->wand.image_info);
+ cli_wand->process_flags=MagickCommandOptionFlags; /* assume "magick" CLI */
+ cli_wand->command=(const OptionInfo *)NULL; /* no option at this time */
cli_wand->image_list_stack=(Stack *)NULL;
cli_wand->image_info_stack=(Stack *)NULL;
- cli_wand->process_flags=MagickCommandOptionFlags; /* assume "magick" CLI */
/* default exception location...
EG: sprintf(locaiton, filename, line, column);
*/
- cli_wand->location="from \"%s\""; /* location format: */
- cli_wand->filename="unknown"; /* unknown source */
- cli_wand->line=0;
- cli_wand->column=0;
+ cli_wand->location="from \"%s\""; /* location format using arguments: */
+ /* filename, line, column */
+ cli_wand->filename="unknown"; /* script filename, unknown source */
+ cli_wand->line=0; /* line from script OR CLI argument */
+ cli_wand->column=0; /* column from script */
cli_wand->signature=WandSignature;
if (IfMagickTrue(cli_wand->wand.debug))
% CLICatchException() will report exceptions, either just non-fatal warnings
% only, or all errors, according to 'all_execeptions' boolean argument.
%
-% The function returns true is errors are fatal, in which case the caller
+% The function returns true if errors are fatal, in which case the caller
% should abort and re-call with an 'all_exceptions' argument of true before
% quitting.
%
% MagickBooleanType CLICatchException(MagickCLI *cli_wand,
% const MagickBooleanType all_exceptions );
%
+% Arguments are
+%
+% o cli_wand: The Wand CLI that holds the exception Information
+%
+% o all_exceptions: Report all exceptions, including the fatal one
+%
*/
WandExport MagickBooleanType CLICatchException(MagickCLI *cli_wand,
const MagickBooleanType all_exceptions )
if ( IfMagickFalse(status) || IfMagickTrue(all_exceptions) )
CatchException(cli_wand->wand.exception); /* output and clear exceptions */
+ return(status);
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
++ C L I L o g E v e n t %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% CLILogEvent() is a wrapper around LogMagickEvent(), adding to it the
+% location of the option that is (about) to be executed.
+%
+*/
+WandExport MagickBooleanType CLILogEvent(MagickCLI *cli_wand,
+ const LogEventType type,const char *module,const char *function,
+ const size_t line,const char *format,...)
+{
+ char
+ new_format[MaxTextExtent];
+
+ MagickBooleanType
+ status;
+
+ va_list
+ operands;
+
+ /* HACK - prepend the CLI location to format string.
+ The better way would be add more arguments to to the 'va' oparands
+ list, but that does not appear to be possible! So we do some
+ pre-formating of the location info here.
+ */
+ (void) FormatLocaleString(new_format,MaxTextExtent,cli_wand->location,
+ cli_wand->filename, cli_wand->line, cli_wand->column);
+ (void) ConcatenateMagickString(new_format," ",MaxTextExtent);
+ (void) ConcatenateMagickString(new_format,format,MaxTextExtent);
+
+ va_start(operands,format);
+ status=LogMagickEventList(type,module,function,line,new_format,operands);
+ va_end(operands);
+
+
return(status);
}
\f
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% CLIThrowException() formats and records an exception condition, adding to
+% CLIThrowException() is a wrapper around ThrowMagickException(), adding to
% it the location of the option that caused the exception to occur.
*/
WandExport MagickBooleanType CLIThrowException(MagickCLI *cli_wand,
operands;
/* HACK - append location to format string.
- The better way would be append location formats and add more arguments to
- operands, but that does not appear to be posible!
- Note: ThrowMagickExceptionList() was exported specifically for
- the use of this function.
+ The better way would be add more arguments to to the 'va' oparands
+ list, but that does not appear to be possible! So we do some
+ pre-formating of the location info here.
*/
(void) CopyMagickString(new_format,format,MaxTextExtent);
(void) ConcatenateMagickString(new_format," ",MaxTextExtent);