Ignore:
Timestamp:
04/10/12 09:02:37 (14 months ago)
Author:
anthony
Message:

Exception handling for CLI Wands.
Preparations to disable depreciation meessages in "convert"

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ImageMagick/trunk/MagickWand/wandcli.c

    r7403 r7436  
    4848#include "MagickWand/wandcli.h" 
    4949#include "MagickWand/wandcli-private.h" 
     50#include "MagickCore/exception.h" 
    5051 
    5152/* 
     
    119120  cli_wand->image_list_stack=(Stack *)NULL; 
    120121  cli_wand->image_info_stack=(Stack *)NULL; 
    121   cli_wand->location="'%s'";      /* option location not known by default */ 
    122   cli_wand->location2="'%s' '%s'"; 
    123   cli_wand->filename=cli_wand->wand.name; 
     122  cli_wand->process_flags=MagickCommandOptionFlags;  /* assume "magick" CLI */ 
     123 
     124  /* default exception location... 
     125     EG: sprintf(locaiton, filename, line, column); 
     126  */ 
     127  cli_wand->location="from \"%s\"";   /* location format: */ 
     128  cli_wand->filename="unknown";       /* unknown source */ 
    124129  cli_wand->line=0; 
    125130  cli_wand->column=0; 
     131 
    126132  cli_wand->signature=WandSignature; 
    127  
    128133  if (IfMagickTrue(cli_wand->wand.debug)) 
    129134    (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name); 
     
    243248  return(status); 
    244249} 
     250 
     251/* 
     252%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     253%                                                                             % 
     254%                                                                             % 
     255%                                                                             % 
     256+   C L I T h r o w E x c e p t i o n                                         % 
     257%                                                                             % 
     258%                                                                             % 
     259%                                                                             % 
     260%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
     261% 
     262% CLIThrowException() formats and records an exception condition, adding to 
     263% it the location of the option that caused the exception to occur. 
     264*/ 
     265WandExport MagickBooleanType CLIThrowException(MagickCLI *cli_wand, 
     266       const char *module,const char *function,const size_t line, 
     267       const ExceptionType severity,const char *tag,const char *format,...) 
     268{ 
     269  char 
     270    new_format[MaxTextExtent]; 
     271 
     272  size_t 
     273    len; 
     274 
     275  MagickBooleanType 
     276    status; 
     277 
     278  va_list 
     279    operands; 
     280 
     281  /* HACK - append location to format string. 
     282     The better way would be append location formats and add more arguments to 
     283     operands, but that does not appear to be posible! 
     284     Note:  ThrowMagickExceptionList() was exported specifically for 
     285     the use of this function. 
     286  */ 
     287  (void) CopyMagickString(new_format,format,MaxTextExtent); 
     288  (void) ConcatenateMagickString(new_format," ",MaxTextExtent); 
     289 
     290  len=strlen(new_format); 
     291  (void) FormatLocaleString(new_format+len,MaxTextExtent-len,cli_wand->location, 
     292       cli_wand->filename, cli_wand->line, cli_wand->column); 
     293 
     294  va_start(operands,format); 
     295  status=ThrowMagickExceptionList(cli_wand->wand.exception, 
     296              module,function,line, 
     297              severity,tag,new_format,operands); 
     298  va_end(operands); 
     299  return(status); 
     300} 
Note: See TracChangeset for help on using the changeset viewer.