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 float StringToFloat(
const char *magick_restrict
string,
71 char *magick_restrict *sentinel)
73 return((
float) InterpretLocaleValue(
string,sentinel));
76static inline const char *StringLocateSubstring(
const char *haystack,
79#if defined(MAGICKCORE_HAVE_STRCASESTR)
80 return(strcasestr(haystack,needle));
90 if (!haystack || !needle)
92 length_needle=strlen(needle);
93 length_haystack=strlen(haystack)-length_needle+1;
94 for (i=0; i < length_haystack; i++)
99 for (j=0; j < length_needle; j++)
101 unsigned char c1 = (
unsigned char) haystack[i+j];
102 unsigned char c2 = (
unsigned char) needle[j];
103 if (toupper((
int) c1) != toupper((
int) c2))
106 return((
char *) haystack+i);
110 return((
char *) NULL);
115static inline double StringToDoubleInterval(
const char *
string,
116 const double interval)
124 value=InterpretLocaleValue(
string,&q);
126 value*=interval/100.0;
130static inline int StringToInteger(
const char *magick_restrict value)
132 if (value == (
const char *) NULL)
134 return((
int) strtol(value,(
char **) NULL,10));
137static inline long StringToLong(
const char *magick_restrict value)
139 if (value == (
const char *) NULL)
141 return(strtol(value,(
char **) NULL,10));
144static inline MagickOffsetType StringToMagickOffsetType(
const char *
string,
145 const double interval)
150 value=SiPrefixToDoubleInterval(
string,interval);
151 if (value >= (
double) MagickULLConstant(~0))
152 return((MagickOffsetType) MagickULLConstant(~0));
153 return((MagickOffsetType) value);
156static inline MagickSizeType StringToMagickSizeType(
const char *
string,
157 const double interval)
162 value=SiPrefixToDoubleInterval(
string,interval);
163 if (value >= (
double) MagickULLConstant(~0))
164 return(MagickULLConstant(~0));
165 return((MagickSizeType) value);
168static inline size_t StringToSizeType(
const char *
string,
const double interval)
173 value=SiPrefixToDoubleInterval(
string,interval);
174 if (value >= (
double) MagickULLConstant(~0))
176 return((
size_t) value);
179static inline unsigned long StringToUnsignedLong(
180 const char *magick_restrict value)
182 if (value == (
const char *) NULL)
184 return(strtoul(value,(
char **) NULL,10));
187#if defined(__cplusplus) || defined(c_plusplus)