18#ifndef MAGICKCORE_STRING_PRIVATE_H
19#define MAGICKCORE_STRING_PRIVATE_H
22#include "MagickCore/locale_.h"
24#if defined(__cplusplus) || defined(c_plusplus)
28static inline int MagickSscanf(
const char *buffer,
const char *format,...)
40 va_start(args,format);
43 #pragma warning(disable:4996)
45 ret=vsscanf(buffer,format,args);
53static inline double SiPrefixToDoubleInterval(
const char *
string,
54 const double interval)
62 value=InterpretSiPrefixValue(
string,&q);
64 value*=interval/100.0;
68static inline double StringToDouble(
const char *magick_restrict
string,
69 char *magick_restrict *sentinel)
71 return(InterpretLocaleValue(
string,sentinel));
74static inline float StringToFloat(
const char *magick_restrict
string,
75 char *magick_restrict *sentinel)
77 return((
float) InterpretLocaleValue(
string,sentinel));
80static inline const char *StringLocateSubstring(
const char *haystack,
83#if defined(MAGICKCORE_HAVE_STRCASESTR)
84 return(strcasestr(haystack,needle));
94 if (!haystack || !needle)
96 length_needle=strlen(needle);
97 length_haystack=strlen(haystack)-length_needle+1;
98 for (i=0; i < length_haystack; i++)
103 for (j=0; j < length_needle; j++)
105 unsigned char c1 = (
unsigned char) haystack[i+j];
106 unsigned char c2 = (
unsigned char) needle[j];
107 if (toupper((
int) c1) != toupper((
int) c2))
110 return((
char *) haystack+i);
114 return((
char *) NULL);
119static inline double StringToDoubleInterval(
const char *
string,
120 const double interval)
128 value=InterpretLocaleValue(
string,&q);
130 value*=interval/100.0;
134static inline int StringToInteger(
const char *magick_restrict value)
136 if (value == (
const char *) NULL)
138 return((
int) strtol(value,(
char **) NULL,10));
141static inline long StringToLong(
const char *magick_restrict value)
143 if (value == (
const char *) NULL)
145 return(strtol(value,(
char **) NULL,10));
148static inline MagickOffsetType StringToMagickOffsetType(
const char *
string,
149 const double interval)
154 value=SiPrefixToDoubleInterval(
string,interval);
155 if (value >= (
double) MagickULLConstant(~0))
156 return((MagickOffsetType) MagickULLConstant(~0));
157 return((MagickOffsetType) value);
160static inline MagickSizeType StringToMagickSizeType(
const char *
string,
161 const double interval)
166 value=SiPrefixToDoubleInterval(
string,interval);
167 if (value >= (
double) MagickULLConstant(~0))
168 return(MagickULLConstant(~0));
169 return((MagickSizeType) value);
172static inline size_t StringToSizeType(
const char *
string,
const double interval)
177 value=SiPrefixToDoubleInterval(
string,interval);
178 if (value >= (
double) MagickULLConstant(~0))
180 return((
size_t) value);
183static inline unsigned long StringToUnsignedLong(
184 const char *magick_restrict value)
186 if (value == (
const char *) NULL)
188 return(strtoul(value,(
char **) NULL,10));
191#if defined(__cplusplus) || defined(c_plusplus)