blob: 542981c2fdbb9b9daaaa60837649d4d6461090ec [file] [log] [blame]
anthony2052d272012-02-28 12:48:29 +00001/*
Cristy7ce65e72015-12-12 18:03:16 -05002 Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization
anthony2052d272012-02-28 12:48:29 +00003 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*/
anthony756cd0d2012-04-08 12:41:44 +000018#ifndef _MAGCIKWAND_WANDCLI_PRIVATE_H
19#define _MAGCIKWAND_WANDCLI_PRIVATE_H
anthony2052d272012-02-28 12:48:29 +000020
21#if defined(__cplusplus) || defined(c_plusplus)
22extern "C" {
23#endif
24
anthonyafa3dfc2012-03-03 11:31:30 +000025#define CLIWandException(severity,tag,option) \
anthony5216f822012-04-10 13:02:37 +000026 (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
cristyefe601c2013-01-05 17:51:12 +000027 "`%s'",option)
anthony92c93bd2012-03-19 14:02:47 +000028
29#define CLIWandExceptionArg(severity,tag,option,arg) \
anthony5216f822012-04-10 13:02:37 +000030 (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \
31 "'%s' '%s'",option, arg)
32
anthony464f1c42012-04-22 08:51:01 +000033#define CLIWandWarnReplaced(message) \
dirkab5c7452014-10-11 19:14:52 +000034 if ( (cli_wand->process_flags & ProcessWarnDeprecated) != 0 ) \
anthony975a8d72012-04-12 13:54:36 +000035 (void) CLIThrowException(cli_wand,GetMagickModule(),OptionWarning, \
anthony464f1c42012-04-22 08:51:01 +000036 "ReplacedOption", "'%s', use \"%s\"",option,message)
anthony975a8d72012-04-12 13:54:36 +000037
anthony5216f822012-04-10 13:02:37 +000038#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}
anthonyafa3dfc2012-03-03 11:31:30 +000044
45#define CLIWandExceptionBreak(severity,tag,option) \
anthony92c93bd2012-03-19 14:02:47 +000046 { CLIWandException(severity,tag,option); break; }
anthonyafa3dfc2012-03-03 11:31:30 +000047
48#define CLIWandExceptionReturn(severity,tag,option) \
anthony5216f822012-04-10 13:02:37 +000049 { CLIWandException(severity,tag,option); return; }
anthony92c93bd2012-03-19 14:02:47 +000050
51#define CLIWandExceptArgBreak(severity,tag,option,arg) \
anthony5216f822012-04-10 13:02:37 +000052 { CLIWandExceptionArg(severity,tag,option,arg); break; }
anthony92c93bd2012-03-19 14:02:47 +000053
anthony0ea037a2012-04-03 12:14:39 +000054#define CLIWandExceptArgReturn(severity,tag,option,arg) \
anthony5216f822012-04-10 13:02:37 +000055 { CLIWandExceptionArg(severity,tag,option,arg); return; }
56
57
anthony975a8d72012-04-12 13:54:36 +000058
anthony5216f822012-04-10 13:02:37 +000059/* Define how options should be processed */
60typedef enum
61{
anthony964d28e2012-05-17 23:39:46 +000062 /* General Option Handling */
63 ProcessImplictRead = 0x0001, /* Non-options are image reads.
anthony5216f822012-04-10 13:02:37 +000064 If not set then skip implied read
65 without producing an error.
66 For use with "mogrify" handling */
anthony964d28e2012-05-17 23:39:46 +000067 ProcessInterpretProperities = 0x0010, /* allow general escapes in args */
anthony5216f822012-04-10 13:02:37 +000068
69 /* Special Option Handling */
70 ProcessExitOption = 0x0100, /* allow '-exit' use */
71 ProcessScriptOption = 0x0200, /* allow '-script' use */
72 ProcessReadOption = 0x0400, /* allow '-read' use */
dirkab5c7452014-10-11 19:14:52 +000073 ProcessWarnDeprecated = 0x0800, /* warn about deprecated options */
anthony5216f822012-04-10 13:02:37 +000074
75 /* Option Processing Flags */
76 ProcessOneOptionOnly = 0x4000, /* Process one option only */
anthony964d28e2012-05-17 23:39:46 +000077 ProcessImplictWrite = 0x8000, /* Last arg is an implict write */
anthony5216f822012-04-10 13:02:37 +000078
79 /* Flag Groups for specific Situations */
anthony964d28e2012-05-17 23:39:46 +000080 MagickCommandOptionFlags = 0x8FFF, /* Magick Command Flags */
anthony5216f822012-04-10 13:02:37 +000081 ConvertCommandOptionFlags = 0x800F, /* Convert Command Flags */
82 MagickScriptArgsFlags = 0x000F, /* Script CLI Process Args Flags */
83} ProcessOptionFlags;
anthony0ea037a2012-04-03 12:14:39 +000084
anthonyafa3dfc2012-03-03 11:31:30 +000085
anthony2052d272012-02-28 12:48:29 +000086/* Define a generic stack linked list, for pushing and popping
87 user defined ImageInfo settings, and Image lists.
88 See '(' ')' and '-clone' CLI options.
89*/
90typedef struct _Stack
91{
92 struct _Stack *next;
93 void *data;
94} Stack;
95
96/* Note this defines an extension to the normal MagickWand
97 Which adds extra elements specific to the Shell API interface
98 while still allowing the Wand to be passed to MagickWand API
99 for specific operations.
100*/
101struct _MagickCLI /* CLI interface version of MagickWand */
102{
anthonycaa5a722012-08-09 05:02:21 +0000103 struct _MagickWand /* This must be the first structure */
104 wand; /* The Image List and Global Option Settings */
anthony2052d272012-02-28 12:48:29 +0000105
106 QuantizeInfo
107 *quantize_info; /* for CLI API usage, not used by MagickWand API */
108
109 DrawInfo
110 *draw_info; /* for CLI API usage, not used by MagickWand API */
111
anthony464f1c42012-04-22 08:51:01 +0000112 ProcessOptionFlags
113 process_flags; /* When handling CLI, what options do we process? */
114
115 const OptionInfo
116 *command; /* The option entry that is being processed */
117
anthony2052d272012-02-28 12:48:29 +0000118 Stack
119 *image_list_stack, /* Stacks of Image Lists and Image Info settings */
120 *image_info_stack;
121
anthony5216f822012-04-10 13:02:37 +0000122 const char /* Location of option being processed for exception */
123 *location, /* location format string for exception reports */
anthony464f1c42012-04-22 08:51:01 +0000124 *filename; /* "CLI", "unknown", or the script filename */
anthony92c93bd2012-03-19 14:02:47 +0000125
anthony1cdc5b72012-03-03 02:31:18 +0000126 size_t
anthony5216f822012-04-10 13:02:37 +0000127 line, /* location of current option from source */
128 column; /* note: line also used for cli argument count */
anthony1cdc5b72012-03-03 02:31:18 +0000129
anthony2052d272012-02-28 12:48:29 +0000130 size_t
131 signature;
132};
133
134
anthony5216f822012-04-10 13:02:37 +0000135
anthony2052d272012-02-28 12:48:29 +0000136#if defined(__cplusplus) || defined(c_plusplus)
137}
138#endif
139
140#endif