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 double SiPrefixToDoubleInterval(
const char *
string,
29 const double interval)
37 value=InterpretSiPrefixValue(
string,&q);
39 value*=interval/100.0;
43static inline double StringToDouble(
const char *magick_restrict
string,
44 char *magick_restrict *sentinel)
46 return(InterpretLocaleValue(
string,sentinel));
49static inline const char *StringLocateSubstring(
const char *haystack,
52#if defined(MAGICKCORE_HAVE_STRCASESTR)
53 return(strcasestr(haystack,needle));
63 if (!haystack || !needle)
65 length_needle=strlen(needle);
66 length_haystack=strlen(haystack)-length_needle+1;
67 for (i=0; i < length_haystack; i++)
72 for (j=0; j < length_needle; j++)
74 unsigned char c1 = (
unsigned char) haystack[i+j];
75 unsigned char c2 = (
unsigned char) needle[j];
76 if (toupper((
int) c1) != toupper((
int) c2))
79 return((
char *) haystack+i);
83 return((
char *) NULL);
88static inline double StringToDoubleInterval(
const char *
string,
89 const double interval)
97 value=InterpretLocaleValue(
string,&q);
99 value*=interval/100.0;
103static inline int StringToInteger(
const char *magick_restrict value)
105 if (value == (
const char *) NULL)
107 return((
int) strtol(value,(
char **) NULL,10));
110static inline long StringToLong(
const char *magick_restrict value)
112 if (value == (
const char *) NULL)
114 return(strtol(value,(
char **) NULL,10));
117static inline MagickOffsetType StringToMagickOffsetType(
const char *
string,
118 const double interval)
123 value=SiPrefixToDoubleInterval(
string,interval);
124 if (value >= (
double) MagickULLConstant(~0))
125 return((MagickOffsetType) MagickULLConstant(~0));
126 return((MagickOffsetType) value);
129static inline MagickSizeType StringToMagickSizeType(
const char *
string,
130 const double interval)
135 value=SiPrefixToDoubleInterval(
string,interval);
136 if (value >= (
double) MagickULLConstant(~0))
137 return(MagickULLConstant(~0));
138 return((MagickSizeType) value);
141static inline size_t StringToSizeType(
const char *
string,
const double interval)
146 value=SiPrefixToDoubleInterval(
string,interval);
147 if (value >= (
double) MagickULLConstant(~0))
149 return((
size_t) value);
152static inline unsigned long StringToUnsignedLong(
153 const char *magick_restrict value)
155 if (value == (
const char *) NULL)
157 return(strtoul(value,(
char **) NULL,10));
160#if defined(__cplusplus) || defined(c_plusplus)