]> granicus.if.org Git - imagemagick/blobdiff - MagickWand/wandcli-private.h
(no commit message)
[imagemagick] / MagickWand / wandcli-private.h
index e0b8a834f7e9b7e6314775d151046ff644b704d5..4e84a6d1576233ccb39fa1fab0907da90af89159 100644 (file)
@@ -23,26 +23,64 @@ extern "C" {
 #endif
 
 #define CLIWandException(severity,tag,option) \
-  (void) ThrowMagickException(cli_wand->wand.exception,GetMagickModule(), \
-       severity,tag,cli_wand->location,option,cli_wand->filename, \
-       cli_wand->line,cli_wand->column)
+  (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
+       "'%s'",option)
 
 #define CLIWandExceptionArg(severity,tag,option,arg) \
-  (void) ThrowMagickException(cli_wand->wand.exception,GetMagickModule(), \
-       severity,tag,cli_wand->location2,option,arg,cli_wand->filename, \
-       cli_wand->line,cli_wand->column)
+  (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
+       "'%s' '%s'",option, arg)
+
+#define CLIWandWarnReplaced(message) \
+  if ( (cli_wand->process_flags & ProcessWarnDepreciated) != 0 ) \
+    (void) CLIThrowException(cli_wand,GetMagickModule(),OptionWarning, \
+       "ReplacedOption", "'%s', use \"%s\"",option,message)
+
+#define CLIWandExceptionFile(severity,tag,context) \
+{ char *message=GetExceptionMessage(errno); \
+  (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
+       "'%s': %s",context,message); \
+  message=DestroyString(message); \
+}
 
 #define CLIWandExceptionBreak(severity,tag,option) \
   { CLIWandException(severity,tag,option); break; }
 
 #define CLIWandExceptionReturn(severity,tag,option) \
-   { CLIWandException(severity,tag,option); return; }
+  { CLIWandException(severity,tag,option); return; }
 
 #define CLIWandExceptArgBreak(severity,tag,option,arg) \
-   { CLIWandExceptionArg(severity,tag,option,arg); break; }
+  { CLIWandExceptionArg(severity,tag,option,arg); break; }
 
 #define CLIWandExceptArgReturn(severity,tag,option,arg) \
-   { CLIWandExceptionArg(severity,tag,option,arg); return; }
+  { CLIWandExceptionArg(severity,tag,option,arg); return; }
+
+
+
+/* Define how options should be processed */
+typedef enum
+{
+  /* General Option Handling */
+  ProcessImplictRead          = 0x0001,  /* Non-options are image reads.
+                                            If not set then skip implied read
+                                            without producing an error.
+                                            For use with "mogrify" handling */
+  ProcessInterpretProperities = 0x0010,  /* allow general escapes in args */
+
+  /* Special Option Handling */
+  ProcessExitOption           = 0x0100,  /* allow '-exit' use */
+  ProcessScriptOption         = 0x0200,  /* allow '-script' use */
+  ProcessReadOption           = 0x0400,  /* allow '-read' use */
+  ProcessWarnDepreciated      = 0x0800,  /* warn about depreciated options */
+
+  /* Option Processing Flags */
+  ProcessOneOptionOnly        = 0x4000,  /* Process one option only */
+  ProcessImplictWrite         = 0x8000,  /* Last arg is an implict write */
+
+  /* Flag Groups for specific Situations */
+  MagickCommandOptionFlags    = 0x8FFF,  /* Magick Command Flags */
+  ConvertCommandOptionFlags   = 0x800F,  /* Convert Command Flags */
+  MagickScriptArgsFlags       = 0x000F,  /* Script CLI Process Args Flags */
+} ProcessOptionFlags;
 
 
 /* Define a generic stack linked list, for pushing and popping
@@ -71,26 +109,30 @@ struct _MagickCLI       /* CLI interface version of MagickWand */
   DrawInfo
     *draw_info;         /* for CLI API usage, not used by MagickWand API */
 
+  ProcessOptionFlags
+    process_flags;      /* When handling CLI, what options do we process? */
+
+  const OptionInfo
+    *command;           /* The option entry that is being processed */
+
   Stack
     *image_list_stack,  /* Stacks of Image Lists and Image Info settings */
     *image_info_stack;
 
-  const char            /* Location string for exception reporting */
-    *filename,          /* See CLIWandException() macro above */
-    *location,          /* EG: "'%s' @ \"%s\" line %u column %u"
-                               option, filename, line, column   */
-    *location2;         /* EG: "'%s' '%s' @ \"%s\" line %u column %u"
-                               option, arg, filename, line, column   */
+  const char            /* Location of option being processed for exception */
+    *location,          /* location format string for exception reports */
+    *filename;          /* "CLI", "unknown", or the script filename */
 
   size_t
-    line,               /* location of current option for error above */
-    column;
+    line,               /* location of current option from source */
+    column;             /* note: line also used for cli argument count */
 
   size_t
     signature;
 };
 
 
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif