]> granicus.if.org Git - imagemagick/blob - MagickWand/wandcli-private.h
(no commit message)
[imagemagick] / MagickWand / wandcli-private.h
1 /*
2   Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization
3   dedicated to making software imaging solutions freely available.
4
5   You may not use this file except in compliance with the License.
6   obtain a copy of the License at
7
8     http://www.imagemagick.org/script/license.php
9
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15
16   ImageMagick pixel wand API.
17 */
18 #ifndef _MAGCIKWAND_WANDCLI_PRIVATE_H
19 #define _MAGCIKWAND_WANDCLI_PRIVATE_H
20
21 #if defined(__cplusplus) || defined(c_plusplus)
22 extern "C" {
23 #endif
24
25 #define CLIWandException(severity,tag,option) \
26   (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
27        "'%s'",option)
28
29 #define CLIWandExceptionArg(severity,tag,option,arg) \
30   (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
31        "'%s' '%s'",option, arg)
32
33 #define CLIWandWarnReplaced(message) \
34   if ( (cli_wand->process_flags & ProcessWarnDepreciated) != 0 ) \
35     (void) CLIThrowException(cli_wand,GetMagickModule(),OptionWarning, \
36        "ReplacedOption", "'%s', use \"%s\"",option,message)
37
38 #define CLIWandExceptionFile(severity,tag,context) \
39 { char *message=GetExceptionMessage(errno); \
40   (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
41        "'%s': %s",context,message); \
42   message=DestroyString(message); \
43 }
44
45 #define CLIWandExceptionBreak(severity,tag,option) \
46   { CLIWandException(severity,tag,option); break; }
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   { CLIWandExceptionArg(severity,tag,option,arg); return; }
56
57
58
59 /* Define how options should be processed */
60 typedef enum
61 {
62   /* NonOption Handling */
63   ProcessNonOptionImageRead   = 0x0001,  /* A non-option is a image read
64                                             If not set then skip implied read
65                                             without producing an error.
66                                             For use with "mogrify" handling */
67
68   /* Special Option Handling */
69   ProcessExitOption           = 0x0100,  /* allow '-exit' use */
70   ProcessScriptOption         = 0x0200,  /* allow '-script' use */
71   ProcessReadOption           = 0x0400,  /* allow '-read' use */
72   ProcessWarnDepreciated      = 0x0800,  /* warn about depreciated options */
73
74   /* Option Processing Flags */
75   ProcessOneOptionOnly        = 0x4000,  /* Process one option only */
76   ProcessImpliedWrite         = 0x8000,  /* Last arg is an implied write */
77
78   /* Flag Groups for specific Situations */
79   MagickCommandOptionFlags    = 0x8F0F,  /* Magick Command Flags */
80   ConvertCommandOptionFlags   = 0x800F,  /* Convert Command Flags */
81   MagickScriptArgsFlags       = 0x000F,  /* Script CLI Process Args Flags */
82 } ProcessOptionFlags;
83
84
85 /* Define a generic stack linked list, for pushing and popping
86    user defined ImageInfo settings, and Image lists.
87    See '(' ')' and '-clone' CLI options.
88 */
89 typedef struct _Stack
90 {
91   struct _Stack  *next;
92   void           *data;
93 } Stack;
94
95 /* Note this defines an extension to the normal MagickWand
96    Which adds extra elements specific to the Shell API interface
97    while still allowing the Wand to be passed to MagickWand API
98    for specific operations.
99 */
100 struct _MagickCLI       /* CLI interface version of MagickWand */
101 {
102   struct _MagickWand    /* this must be the first structure */
103      wand;
104
105   QuantizeInfo
106     *quantize_info;     /* for CLI API usage, not used by MagickWand API */
107
108   DrawInfo
109     *draw_info;         /* for CLI API usage, not used by MagickWand API */
110
111   ProcessOptionFlags
112     process_flags;      /* When handling CLI, what options do we process? */
113
114   const OptionInfo
115     *command;           /* The option entry that is being processed */
116
117   Stack
118     *image_list_stack,  /* Stacks of Image Lists and Image Info settings */
119     *image_info_stack;
120
121   const char            /* Location of option being processed for exception */
122     *location,          /* location format string for exception reports */
123     *filename;          /* "CLI", "unknown", or the script filename */
124
125   size_t
126     line,               /* location of current option from source */
127     column;             /* note: line also used for cli argument count */
128
129   size_t
130     signature;
131 };
132
133
134
135 #if defined(__cplusplus) || defined(c_plusplus)
136 }
137 #endif
138
139 #endif