18 #ifndef MAGICKCORE_DELEGATE_PRIVATE_H
19 #define MAGICKCORE_DELEGATE_PRIVATE_H
21 #include "magick/locale_.h"
22 #include "magick/string_.h"
24 #if defined(MAGICKCORE_GS_DELEGATE)
25 #include "ghostscript/iapi.h"
26 #include "ghostscript/ierrors.h"
31 const char *copyright;
37 #if defined(__cplusplus) || defined(c_plusplus)
41 #ifndef gs_main_instance_DEFINED
42 # define gs_main_instance_DEFINED
43 typedef struct gs_main_instance_s
47 #if !defined(MagickDLLCall)
48 # if defined(MAGICKCORE_WINDOWS_SUPPORT)
49 # define MagickDLLCall __stdcall
51 # define MagickDLLCall
58 (MagickDLLCall *delete_instance)(gs_main_instance *);
61 (MagickDLLCall *exit)(gs_main_instance *);
64 (MagickDLLCall *init_with_args)(gs_main_instance *,int,
char **);
67 (MagickDLLCall *new_instance)(gs_main_instance **,
void *);
70 (MagickDLLCall *run_string)(gs_main_instance *,
const char *,int,
int *);
73 (MagickDLLCall *set_stdio)(gs_main_instance *,int(MagickDLLCall *)(
void *,
74 char *,int),
int(MagickDLLCall *)(
void *,
const char *,int),
75 int(MagickDLLCall *)(
void *,
const char *,int));
81 static inline char *SanitizeDelegateString(
const char *source)
93 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
95 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
96 "$-_.+!;*(),{}|^~[]`\'><#%/?:@&=";
99 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
100 "$-_.+!;*(),{}|\\^~[]`\"><#%/?:@&=";
103 sanitize_source=AcquireString(source);
105 q=sanitize_source+strlen(sanitize_source);
106 for (p+=strspn(p,allowlist); p != q; p+=strspn(p,allowlist))
108 return(sanitize_source);
111 #if defined(MAGICKCORE_WINDOWS_SUPPORT)
112 static inline void FormatSanitizedDelegateOption(
char *
string,
113 const size_t length,
const char *windows_format,
114 const char *magick_unused(non_windows_format),
const char *option)
119 magick_unreferenced(non_windows_format);
120 sanitized_option=SanitizeDelegateString(option);
121 (void) FormatLocaleString(
string,length,windows_format,sanitized_option);
122 sanitized_option=DestroyString(sanitized_option);
125 static inline void FormatSanitizedDelegateOption(
char *
string,
126 const size_t length,
const char *magick_unused(windows_format),
127 const char *non_windows_format,
const char *option)
132 magick_unreferenced(windows_format);
133 sanitized_option=SanitizeDelegateString(option);
134 (void) FormatLocaleString(
string,length,non_windows_format,sanitized_option);
135 sanitized_option=DestroyString(sanitized_option);
139 #if defined(__cplusplus) || defined(c_plusplus)