18 #ifndef MAGICKCORE_STRING_PRIVATE_H
19 #define MAGICKCORE_STRING_PRIVATE_H
22 #include "magick/locale_.h"
24 #if defined(__cplusplus) || defined(c_plusplus)
28 static inline double SiPrefixToDoubleInterval(
const char *
string,
29 const double interval)
37 value=InterpretSiPrefixValue(
string,&q);
39 value*=interval/100.0;
43 static inline const char *StringLocateSubstring(
const char *haystack,
46 #if defined(MAGICKCORE_HAVE_STRCASESTR)
47 return(strcasestr(haystack,needle));
57 if (!haystack || !needle)
59 length_needle=strlen(needle);
60 length_haystack=strlen(haystack)-length_needle+1;
61 for (i=0; i < length_haystack; i++)
66 for (j=0; j < length_needle; j++)
68 unsigned char c1 = (
unsigned char) haystack[i+j];
69 unsigned char c2 = (
unsigned char) needle[j];
70 if (toupper((
int) c1) != toupper((
int) c2))
73 return((
char *) haystack+i);
77 return((
char *) NULL);
82 static inline double StringToDouble(
const char *magick_restrict
string,
83 char **magick_restrict sentinal)
85 return(InterpretLocaleValue(
string,sentinal));
88 static inline double StringToDoubleInterval(
const char *
string,
89 const double interval)
97 value=InterpretLocaleValue(
string,&q);
99 value*=interval/100.0;
103 static inline int StringToInteger(
const char *magick_restrict value)
105 if (value == (
const char *) NULL)
107 return((
int) strtol(value,(
char **) NULL,10));
110 static inline long StringToLong(
const char *magick_restrict value)
112 if (value == (
const char *) NULL)
114 return(strtol(value,(
char **) NULL,10));
117 static inline size_t StringToSizeType(
const char *
string,
const double interval)
122 value=SiPrefixToDoubleInterval(
string,interval);
123 if (value >= (
double) MagickULLConstant(~0))
125 return((
size_t) value);
128 static inline unsigned long StringToUnsignedLong(
129 const char *magick_restrict value)
131 if (value == (
const char *) NULL)
133 return(strtoul(value,(
char **) NULL,10));
136 #if defined(__cplusplus) || defined(c_plusplus)