wandcli-private.h 4.78 KB
Newer Older
1
/*
Cristy's avatar
Cristy committed
2
  Copyright 1999-2019 ImageMagick Studio LLC, a non-profit organization
3 4
  dedicated to making software imaging solutions freely available.

5
  You may not use this file except in compliance with the License.  You may
6 7
  obtain a copy of the License at

Cristy's avatar
Cristy committed
8
    https://imagemagick.org/script/license.php
9 10 11 12 13 14 15 16 17

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.

  ImageMagick pixel wand API.
*/
18 19
#ifndef MAGICKWAND_WANDCLI_PRIVATE_H
#define MAGICKWAND_WANDCLI_PRIVATE_H
20 21 22 23 24

#if defined(__cplusplus) || defined(c_plusplus)
extern "C" {
#endif

anthony's avatar
anthony committed
25
#define CLIWandException(severity,tag,option) \
26
  (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
cristy's avatar
cristy committed
27
       "`%s'",option)
28 29

#define CLIWandExceptionArg(severity,tag,option,arg) \
30 31 32
  (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
       "'%s' '%s'",option, arg)

anthony's avatar
anthony committed
33
#define CLIWandWarnReplaced(message) \
dirk's avatar
dirk committed
34
  if ( (cli_wand->process_flags & ProcessWarnDeprecated) != 0 ) \
35
    (void) CLIThrowException(cli_wand,GetMagickModule(),OptionWarning, \
anthony's avatar
anthony committed
36
       "ReplacedOption", "'%s', use \"%s\"",option,message)
37

38 39 40 41 42 43
#define CLIWandExceptionFile(severity,tag,context) \
{ char *message=GetExceptionMessage(errno); \
  (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
       "'%s': %s",context,message); \
  message=DestroyString(message); \
}
anthony's avatar
anthony committed
44 45

#define CLIWandExceptionBreak(severity,tag,option) \
46
  { CLIWandException(severity,tag,option); break; }
anthony's avatar
anthony committed
47 48

#define CLIWandExceptionReturn(severity,tag,option) \
49
  { CLIWandException(severity,tag,option); return; }
50 51

#define CLIWandExceptArgBreak(severity,tag,option,arg) \
52
  { CLIWandExceptionArg(severity,tag,option,arg); break; }
53

54
#define CLIWandExceptArgReturn(severity,tag,option,arg) \
55 56 57
  { CLIWandExceptionArg(severity,tag,option,arg); return; }


58

59 60 61
/* Define how options should be processed */
typedef enum
{
62 63
  /* General Option Handling */
  ProcessImplictRead          = 0x0001,  /* Non-options are image reads.
64 65 66
                                            If not set then skip implied read
                                            without producing an error.
                                            For use with "mogrify" handling */
67
  ProcessInterpretProperities = 0x0010,  /* allow general escapes in args */
68 69 70 71 72

  /* Special Option Handling */
  ProcessExitOption           = 0x0100,  /* allow '-exit' use */
  ProcessScriptOption         = 0x0200,  /* allow '-script' use */
  ProcessReadOption           = 0x0400,  /* allow '-read' use */
dirk's avatar
dirk committed
73
  ProcessWarnDeprecated       = 0x0800,  /* warn about deprecated options */
74 75 76

  /* Option Processing Flags */
  ProcessOneOptionOnly        = 0x4000,  /* Process one option only */
77
  ProcessImplictWrite         = 0x8000,  /* Last arg is an implict write */
78 79

  /* Flag Groups for specific Situations */
80
  MagickCommandOptionFlags    = 0x8FFF,  /* Magick Command Flags */
81 82 83
  ConvertCommandOptionFlags   = 0x800F,  /* Convert Command Flags */
  MagickScriptArgsFlags       = 0x000F,  /* Script CLI Process Args Flags */
} ProcessOptionFlags;
84

anthony's avatar
anthony committed
85

86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
/* Define a generic stack linked list, for pushing and popping
   user defined ImageInfo settings, and Image lists.
   See '(' ')' and '-clone' CLI options.
*/
typedef struct _Stack
{
  struct _Stack  *next;
  void           *data;
} Stack;

/* Note this defines an extension to the normal MagickWand
   Which adds extra elements specific to the Shell API interface
   while still allowing the Wand to be passed to MagickWand API
   for specific operations.
*/
struct _MagickCLI       /* CLI interface version of MagickWand */
{
anthony's avatar
anthony committed
103 104
  struct _MagickWand    /* This must be the first structure */
     wand;              /* The Image List and Global Option Settings */
105 106 107 108 109 110 111

  QuantizeInfo
    *quantize_info;     /* for CLI API usage, not used by MagickWand API */

  DrawInfo
    *draw_info;         /* for CLI API usage, not used by MagickWand API */

anthony's avatar
anthony committed
112 113 114 115 116 117
  ProcessOptionFlags
    process_flags;      /* When handling CLI, what options do we process? */

  const OptionInfo
    *command;           /* The option entry that is being processed */

118 119 120 121
  Stack
    *image_list_stack,  /* Stacks of Image Lists and Image Info settings */
    *image_info_stack;

122 123
  const char            /* Location of option being processed for exception */
    *location,          /* location format string for exception reports */
anthony's avatar
anthony committed
124
    *filename;          /* "CLI", "unknown", or the script filename */
125

126
  size_t
127 128
    line,               /* location of current option from source */
    column;             /* note: line also used for cli argument count */
129

130 131 132 133 134
  size_t
    signature;
};


135

136 137 138 139 140
#if defined(__cplusplus) || defined(c_plusplus)
}
#endif

#endif