anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 1 | /* |
Cristy | 7ce65e7 | 2015-12-12 18:03:16 -0500 | [diff] [blame] | 2 | Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 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 | */ |
anthony | 756cd0d | 2012-04-08 12:41:44 +0000 | [diff] [blame] | 18 | #ifndef _MAGCIKWAND_WANDCLI_PRIVATE_H |
| 19 | #define _MAGCIKWAND_WANDCLI_PRIVATE_H |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 20 | |
| 21 | #if defined(__cplusplus) || defined(c_plusplus) |
| 22 | extern "C" { |
| 23 | #endif |
| 24 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 25 | #define CLIWandException(severity,tag,option) \ |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 26 | (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \ |
cristy | efe601c | 2013-01-05 17:51:12 +0000 | [diff] [blame] | 27 | "`%s'",option) |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 28 | |
| 29 | #define CLIWandExceptionArg(severity,tag,option,arg) \ |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 30 | (void) CLIThrowException(cli_wand,GetMagickModule(),severity,tag, \ |
| 31 | "'%s' '%s'",option, arg) |
| 32 | |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 33 | #define CLIWandWarnReplaced(message) \ |
dirk | ab5c745 | 2014-10-11 19:14:52 +0000 | [diff] [blame] | 34 | if ( (cli_wand->process_flags & ProcessWarnDeprecated) != 0 ) \ |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 35 | (void) CLIThrowException(cli_wand,GetMagickModule(),OptionWarning, \ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 36 | "ReplacedOption", "'%s', use \"%s\"",option,message) |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 37 | |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 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 | } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 44 | |
| 45 | #define CLIWandExceptionBreak(severity,tag,option) \ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 46 | { CLIWandException(severity,tag,option); break; } |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 47 | |
| 48 | #define CLIWandExceptionReturn(severity,tag,option) \ |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 49 | { CLIWandException(severity,tag,option); return; } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 50 | |
| 51 | #define CLIWandExceptArgBreak(severity,tag,option,arg) \ |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 52 | { CLIWandExceptionArg(severity,tag,option,arg); break; } |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 53 | |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 54 | #define CLIWandExceptArgReturn(severity,tag,option,arg) \ |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 55 | { CLIWandExceptionArg(severity,tag,option,arg); return; } |
| 56 | |
| 57 | |
anthony | 975a8d7 | 2012-04-12 13:54:36 +0000 | [diff] [blame] | 58 | |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 59 | /* Define how options should be processed */ |
| 60 | typedef enum |
| 61 | { |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 62 | /* General Option Handling */ |
| 63 | ProcessImplictRead = 0x0001, /* Non-options are image reads. |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 64 | If not set then skip implied read |
| 65 | without producing an error. |
| 66 | For use with "mogrify" handling */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 67 | ProcessInterpretProperities = 0x0010, /* allow general escapes in args */ |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 68 | |
| 69 | /* Special Option Handling */ |
| 70 | ProcessExitOption = 0x0100, /* allow '-exit' use */ |
| 71 | ProcessScriptOption = 0x0200, /* allow '-script' use */ |
| 72 | ProcessReadOption = 0x0400, /* allow '-read' use */ |
dirk | ab5c745 | 2014-10-11 19:14:52 +0000 | [diff] [blame] | 73 | ProcessWarnDeprecated = 0x0800, /* warn about deprecated options */ |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 74 | |
| 75 | /* Option Processing Flags */ |
| 76 | ProcessOneOptionOnly = 0x4000, /* Process one option only */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 77 | ProcessImplictWrite = 0x8000, /* Last arg is an implict write */ |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 78 | |
| 79 | /* Flag Groups for specific Situations */ |
anthony | 964d28e | 2012-05-17 23:39:46 +0000 | [diff] [blame] | 80 | MagickCommandOptionFlags = 0x8FFF, /* Magick Command Flags */ |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 81 | ConvertCommandOptionFlags = 0x800F, /* Convert Command Flags */ |
| 82 | MagickScriptArgsFlags = 0x000F, /* Script CLI Process Args Flags */ |
| 83 | } ProcessOptionFlags; |
anthony | 0ea037a | 2012-04-03 12:14:39 +0000 | [diff] [blame] | 84 | |
anthony | afa3dfc | 2012-03-03 11:31:30 +0000 | [diff] [blame] | 85 | |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 86 | /* 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 | */ |
| 90 | typedef 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 | */ |
| 101 | struct _MagickCLI /* CLI interface version of MagickWand */ |
| 102 | { |
anthony | caa5a72 | 2012-08-09 05:02:21 +0000 | [diff] [blame] | 103 | struct _MagickWand /* This must be the first structure */ |
| 104 | wand; /* The Image List and Global Option Settings */ |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 105 | |
| 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 | |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 112 | 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 | |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 118 | Stack |
| 119 | *image_list_stack, /* Stacks of Image Lists and Image Info settings */ |
| 120 | *image_info_stack; |
| 121 | |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 122 | const char /* Location of option being processed for exception */ |
| 123 | *location, /* location format string for exception reports */ |
anthony | 464f1c4 | 2012-04-22 08:51:01 +0000 | [diff] [blame] | 124 | *filename; /* "CLI", "unknown", or the script filename */ |
anthony | 92c93bd | 2012-03-19 14:02:47 +0000 | [diff] [blame] | 125 | |
anthony | 1cdc5b7 | 2012-03-03 02:31:18 +0000 | [diff] [blame] | 126 | size_t |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 127 | line, /* location of current option from source */ |
| 128 | column; /* note: line also used for cli argument count */ |
anthony | 1cdc5b7 | 2012-03-03 02:31:18 +0000 | [diff] [blame] | 129 | |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 130 | size_t |
| 131 | signature; |
| 132 | }; |
| 133 | |
| 134 | |
anthony | 5216f82 | 2012-04-10 13:02:37 +0000 | [diff] [blame] | 135 | |
anthony | 2052d27 | 2012-02-28 12:48:29 +0000 | [diff] [blame] | 136 | #if defined(__cplusplus) || defined(c_plusplus) |
| 137 | } |
| 138 | #endif |
| 139 | |
| 140 | #endif |