18#ifndef MAGICKCORE_DELEGATE_PRIVATE_H
19#define MAGICKCORE_DELEGATE_PRIVATE_H
21#include "MagickCore/locale_.h"
22#include "MagickCore/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
43typedef struct gs_main_instance_s
47#if !defined(MagickDLLCall)
48# if defined(MAGICKCORE_WINDOWS_SUPPORT)
49# define MagickDLLCall __stdcall
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_arg_encoding)(gs_main_instance*, int);
76 (MagickDLLCall *set_stdio)(gs_main_instance *,int(MagickDLLCall *)(
void *,
77 char *,int),
int(MagickDLLCall *)(
void *,
const char *,int),
78 int(MagickDLLCall *)(
void *,
const char *,int));
84static inline char *SanitizeDelegateString(
const char *source)
96#if defined(MAGICKCORE_WINDOWS_SUPPORT)
98 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
99 "$-_.+!;*(),{}|^~[]`\'><#%/?:@&=";
102 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 "
103 "$-_.+!;*(),{}|\\^~[]`\"><#%/?:@&=";
106 sanitize_source=AcquireString(source);
108 q=sanitize_source+strlen(sanitize_source);
109 for (p+=strspn(p,allowlist); p != q; p+=(ptrdiff_t) strspn(p,allowlist))
111 return(sanitize_source);
114#if defined(MAGICKCORE_WINDOWS_SUPPORT)
115static inline void FormatSanitizedDelegateOption(
char *
string,
116 const size_t length,
const char *windows_format,
117 const char *magick_unused(non_windows_format),
const char *option)
122 magick_unreferenced(non_windows_format);
123 sanitized_option=SanitizeDelegateString(option);
124 (void) FormatLocaleString(
string,length,windows_format,sanitized_option);
125 sanitized_option=DestroyString(sanitized_option);
128static inline void FormatSanitizedDelegateOption(
char *
string,
129 const size_t length,
const char *magick_unused(windows_format),
130 const char *non_windows_format,
const char *option)
135 magick_unreferenced(windows_format);
136 sanitized_option=SanitizeDelegateString(option);
137 (void) FormatLocaleString(
string,length,non_windows_format,sanitized_option);
138 sanitized_option=DestroyString(sanitized_option);
142extern MagickPrivate MagickBooleanType
143 DelegateComponentGenesis(
void);
145extern MagickPrivate
void
146 DelegateComponentTerminus(
void);
148#if defined(__cplusplus) || defined(c_plusplus)