18#ifndef MAGICKCORE_STRING_PRIVATE_H
19#define MAGICKCORE_STRING_PRIVATE_H
22#include "MagickCore/locale_.h"
24#if defined(__cplusplus) || defined(c_plusplus)
29static inline int MagickSscanf(
const char* buffer,
const char* format, ...)
36 va_start(args,format);
39 #pragma warning(disable:4996)
41 ret=vsscanf(buffer,format,args);
49static inline double SiPrefixToDoubleInterval(
const char *
string,
50 const double interval)
58 value=InterpretSiPrefixValue(
string,&q);
60 value*=interval/100.0;
64static inline double StringToDouble(
const char *magick_restrict
string,
65 char *magick_restrict *sentinel)
67 return(InterpretLocaleValue(
string,sentinel));
70static inline const char *StringLocateSubstring(
const char *haystack,
73#if defined(MAGICKCORE_HAVE_STRCASESTR)
74 return(strcasestr(haystack,needle));
84 if (!haystack || !needle)
86 length_needle=strlen(needle);
87 length_haystack=strlen(haystack)-length_needle+1;
88 for (i=0; i < length_haystack; i++)
93 for (j=0; j < length_needle; j++)
95 unsigned char c1 = (
unsigned char) haystack[i+j];
96 unsigned char c2 = (
unsigned char) needle[j];
97 if (toupper((
int) c1) != toupper((
int) c2))
100 return((
char *) haystack+i);
104 return((
char *) NULL);
109static inline double StringToDoubleInterval(
const char *
string,
110 const double interval)
118 value=InterpretLocaleValue(
string,&q);
120 value*=interval/100.0;
124static inline int StringToInteger(
const char *magick_restrict value)
126 if (value == (
const char *) NULL)
128 return((
int) strtol(value,(
char **) NULL,10));
131static inline long StringToLong(
const char *magick_restrict value)
133 if (value == (
const char *) NULL)
135 return(strtol(value,(
char **) NULL,10));
138static inline MagickOffsetType StringToMagickOffsetType(
const char *
string,
139 const double interval)
144 value=SiPrefixToDoubleInterval(
string,interval);
145 if (value >= (
double) MagickULLConstant(~0))
146 return((MagickOffsetType) MagickULLConstant(~0));
147 return((MagickOffsetType) value);
150static inline MagickSizeType StringToMagickSizeType(
const char *
string,
151 const double interval)
156 value=SiPrefixToDoubleInterval(
string,interval);
157 if (value >= (
double) MagickULLConstant(~0))
158 return(MagickULLConstant(~0));
159 return((MagickSizeType) value);
162static inline size_t StringToSizeType(
const char *
string,
const double interval)
167 value=SiPrefixToDoubleInterval(
string,interval);
168 if (value >= (
double) MagickULLConstant(~0))
170 return((
size_t) value);
173static inline unsigned long StringToUnsignedLong(
174 const char *magick_restrict value)
176 if (value == (
const char *) NULL)
178 return(strtoul(value,(
char **) NULL,10));
181#if defined(__cplusplus) || defined(c_plusplus)