]> granicus.if.org Git - imagemagick/blobdiff - MagickWand/wandcli.c
(no commit message)
[imagemagick] / MagickWand / wandcli.c
index 7fd4d8a1ff7a3dd67335764879aa8d6af2425f75..79b41b9b032d68870e47b9b3d63d923ae1f0c187 100644 (file)
@@ -17,7 +17,7 @@
 %                                 April 2011                                  %
 %                                                                             %
 %                                                                             %
-%  Copyright 1999-2013 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  %
@@ -253,6 +253,52 @@ WandExport MagickBooleanType CLICatchException(MagickCLI *cli_wand,
   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
@@ -267,7 +313,7 @@ WandExport MagickBooleanType CLICatchException(MagickCLI *cli_wand,
 %                                                                             %
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %
-% 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,
@@ -287,10 +333,9 @@ 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);