64 #define CharsPerLine 0x14 103 if (source != (
char *) NULL)
104 length+=strlen(source);
108 sizeof(*destination));
109 if (destination == (
char *) NULL)
111 if (source != (
char *) NULL)
112 (
void) memcpy(destination,source,length*
sizeof(*destination));
113 destination[length]=
'\0';
146 (void) memset(string_info,0,
sizeof(*string_info));
157 string_info->
length=length;
161 if (string_info->
datum == (
unsigned char *) NULL)
164 sizeof(*string_info->
datum));
201 string_info->
length=length;
204 if (string_info->
datum == (
unsigned char *) NULL)
209 if (blob != (
const void *) NULL)
210 (void) memcpy(string_info->
datum,blob,length);
212 (
void) memset(string_info->
datum,0,length*
sizeof(*string_info->
datum));
214 sizeof(*string_info->
datum));
255 assert(destination != (
char **) NULL);
256 if (source == (
const char *) NULL)
258 if (*destination != (
char *) NULL)
260 return(*destination);
262 if (*destination == (
char *) NULL)
265 return(*destination);
267 length=strlen(source);
272 if (*destination == (
char *) NULL)
275 (void) memcpy(*destination,source,length*
sizeof(**destination));
276 (*destination)[length]=
'\0';
277 return(*destination);
312 if (string_info->
length != 0)
407 assert(destination != (
char *) NULL);
408 assert(source != (
const char *) NULL);
413 while ((i-- != 0) && (*q !=
'\0'))
415 count=(size_t) (q-destination);
418 return(count+strlen(p));
429 return(count+(p-source));
466 assert(destination != (
char **) NULL);
467 if (source == (
const char *) NULL)
469 if (*destination == (
char *) NULL)
474 destination_length=strlen(*destination);
475 source_length=strlen(source);
476 length=destination_length;
477 if (~length < source_length)
479 length+=source_length;
484 if (*destination == (
char *) NULL)
486 if (source_length != 0)
487 (void) memcpy((*destination)+destination_length,source,source_length);
488 (*destination)[length]=
'\0';
527 length=string_info->
length;
528 if (~length < source->length)
578 assert(filename != (
const char *) NULL);
588 length=(size_t) offset;
589 string=(
char *) NULL;
593 if (
string == (
char *) NULL)
599 if (
map != (
void *) NULL)
601 (void) memcpy(
string,
map,length);
612 (void) lseek(file,0,SEEK_SET);
613 for (i=0; i < length; i+=count)
615 count=read(file,
string+i,(
size_t)
MagickMin(length-i,(
size_t)
635 string_info->
length=length;
636 string_info->
datum=(
unsigned char *)
string;
675 if (source != (
char *) NULL)
676 length+=strlen(source);
677 destination=(
char *) NULL;
680 if (destination == (
char *) NULL)
682 if (source != (
char *) NULL)
683 (
void) memcpy(destination,source,length*
sizeof(*destination));
684 destination[length]=
'\0';
733 for (n=length; n > 4; n-=4)
735 if (((*q++)=(*p++)) ==
'\0')
736 return((
size_t) (p-source-1));
737 if (((*q++)=(*p++)) ==
'\0')
738 return((
size_t) (p-source-1));
739 if (((*q++)=(*p++)) ==
'\0')
740 return((
size_t) (p-source-1));
741 if (((*q++)=(*p++)) ==
'\0')
742 return((
size_t) (p-source-1));
747 if (((*q++)=(*p++)) ==
'\0')
748 return((
size_t) (p-source-1));
751 return((
size_t) (p-source));
807 if (string_info->
datum != (
unsigned char *) NULL)
810 if (string_info->
name != (
char *) NULL)
812 if (string_info->
path != (
char *) NULL)
846 assert(list != (
char **) NULL);
847 for (i=0; list[i] != (
char *) NULL; i++)
896 assert(source != (
const char *) NULL);
898 for (p=source; *p !=
'\0'; p++)
900 if ((*p ==
'\\') || (*p == escape))
908 destination=(
char *) NULL;
911 sizeof(*destination));
912 if (destination == (
char *) NULL)
916 for (p=source; *p !=
'\0'; p++)
918 if ((*p ==
'\\') || (*p == escape))
959 assert(filename != (
const char *) NULL);
998 assert(filename != (
const char *) NULL);
1005 if (string_info->
datum == (
unsigned char *) NULL)
1010 return(string_info);
1070 "",
"Ki",
"Mi",
"Gi",
"Ti",
"Pi",
"Ei",
"Zi",
"Yi", (
char *) NULL
1072 *traditional_units[] =
1074 "",
"K",
"M",
"G",
"T",
"P",
"E",
"Z",
"Y", (
char *) NULL
1078 units=traditional_units;
1084 #if defined(_MSC_VER) && (_MSC_VER == 1200) 1087 extent=(double) size;
1092 if (strtod(p,(
char **) NULL) == strtod(q,(
char **) NULL))
1094 if (suffix == (
const char *) NULL)
1101 for (i=0; (extent >= bytes) && (units[i+1] != (
const char *) NULL); i++)
1103 if (suffix == (
const char *) NULL)
1108 extent,units[i],suffix);
1140 environment=getenv(name);
1141 if (environment == (
const char *) NULL)
1142 return((
char *) NULL);
1172 return(string_info->
datum);
1201 return(string_info->
length);
1230 return(string_info->
name);
1259 return(string_info->
path);
1301 if ((*q >=
'E') && (*q <=
'z'))
1306 switch ((
int) ((
unsigned char) *q))
1308 case 'y': e=(-24.0);
break;
1309 case 'z': e=(-21.0);
break;
1310 case 'a': e=(-18.0);
break;
1311 case 'f': e=(-15.0);
break;
1312 case 'p': e=(-12.0);
break;
1313 case 'n': e=(-9.0);
break;
1314 case 'u': e=(-6.0);
break;
1315 case 'm': e=(-3.0);
break;
1316 case 'c': e=(-2.0);
break;
1317 case 'd': e=(-1.0);
break;
1318 case 'h': e=2.0;
break;
1319 case 'k': e=3.0;
break;
1320 case 'K': e=3.0;
break;
1321 case 'M': e=6.0;
break;
1322 case 'G': e=9.0;
break;
1323 case 'T': e=12.0;
break;
1324 case 'P': e=15.0;
break;
1325 case 'E': e=18.0;
break;
1326 case 'Z': e=21.0;
break;
1327 case 'Y': e=24.0;
break;
1328 default: e=0.0;
break;
1334 value*=pow(2.0,e/0.3);
1344 if ((*q ==
'B') || (*q ==
'P'))
1347 if (sentinal != (
char **) NULL)
1380 if (value == (
const char *) NULL)
1421 if (value == (
const char *) NULL)
1471 assert(
id != (
const char *) NULL);
1474 p=(
char *) string_info->
datum;
1475 for (i=0; i < string_info->
length; i++)
1477 if (((
int) ((
unsigned char) *p) < 32) &&
1478 (isspace((
int) ((
unsigned char) *p)) == 0))
1483 if (i == string_info->
length)
1485 for (i=0; i < string_info->
length; i++)
1486 (
void) fputc(string_info->
datum[i],file);
1487 (void) fputc(
'\n',file);
1493 p=(
char *) string_info->
datum;
1500 if ((j % 0x04) == 0)
1501 (
void) fputc(
' ',file);
1505 (void) fputc(
' ',file);
1506 (void) fputc(
' ',file);
1507 if ((j % 0x04) == 0)
1508 (
void) fputc(
' ',file);
1510 (void) fputc(
' ',file);
1513 if (isprint((
int) ((
unsigned char) *p)) != 0)
1514 (
void) fputc(*p,file);
1516 (
void) fputc(
'-',file);
1519 (void) fputc(
'\n',file);
1549 (void) memset(string_info->
datum,0,string_info->
length);
1590 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 " 1591 "$-_.+!*'(),{}|\\^~[]`\"><#%;/?:@&=";
1595 q=sanitize_source+strlen(sanitize_source);
1596 for (p+=strspn(p,allowlist); p != q; p+=strspn(p,allowlist))
1598 return(sanitize_source);
1632 if (string_info->
length == 0)
1634 (void) memset(string_info->
datum,0,string_info->
length);
1666 const unsigned char *source)
1670 if (string_info->
length != 0)
1671 (void) memcpy(string_info->
datum,source,string_info->
length);
1699 const size_t length)
1703 if (string_info->
length == length)
1707 string_info->
length=length;
1708 if (string_info->
datum == (
unsigned char *) NULL)
1714 if (string_info->
datum == (
unsigned char *) NULL)
1746 assert(name != (
const char *) NULL);
1778 assert(path != (
const char *) NULL);
1805 const size_t offset)
1812 if (offset > string_info->
length)
1816 (void) memmove(string_info->
datum,string_info->
datum+offset,
1852 string=(
char *) NULL;
1853 length=string_info->
length;
1857 if (
string == (
char *) NULL)
1858 return((
char *) NULL);
1859 (void) memcpy(
string,(
char *) string_info->
datum,length*
sizeof(*string));
1860 string[length]=
'\0';
1906 length=string_info->
length;
1911 if (
string == (
char *) NULL)
1929 p=string_info->
datum;
1930 q=(
unsigned char *)
string;
1931 for (i=0; i < (ssize_t) string_info->
length; i++)
1933 *q++=hex_digits[(*p >> 4) & 0x0f];
1934 *q++=hex_digits[*p & 0x0f];
1988 if (text == (
char *) NULL)
1989 return((
char **) NULL);
1993 for (p=text; *p !=
'\0'; )
1995 while (isspace((
int) ((
unsigned char) *p)) != 0)
2001 for (p++; (*p !=
'"') && (*p !=
'\0'); p++) ;
2003 for (p++; (*p !=
'\'') && (*p !=
'\0'); p++) ;
2004 while ((isspace((
int) ((
unsigned char) *p)) == 0) && (*p !=
'\0'))
2009 if (argv == (
char **) NULL)
2016 for (i=1; i < (ssize_t) *argc; i++)
2018 while (isspace((
int) ((
unsigned char) *p)) != 0)
2024 for (q++; (*q !=
'"') && (*q !=
'\0'); q++) ;
2030 for (q++; (*q !=
'\'') && (*q !=
'\0'); q++) ;
2033 while ((isspace((
int) ((
unsigned char) *q)) == 0) && (*q !=
'\0'))
2037 if (argv[i] == (
char *) NULL)
2039 for (i--; i >= 0; i--)
2043 "UnableToConvertStringToARGV");
2045 (void) memcpy(argv[i],p,(
size_t) (q-p));
2048 while ((isspace((
int) ((
unsigned char) *p)) == 0) && (*p !=
'\0'))
2051 argv[i]=(
char *) NULL;
2111 if (
string == (
char *) NULL)
2112 return((
double *) NULL);
2119 return((
double *) NULL);
2122 while (isspace((
int) ((
unsigned char) *p)) != 0)
2126 while (isspace((
int) ((
unsigned char) *p)) != 0)
2134 if (array == (
double *) NULL)
2138 return((
double *) NULL);
2145 while ((*p !=
'\0') && (i < *count))
2149 while ((isspace((
int) ((
unsigned char) *p)) != 0) || (*p ==
','))
2205 if (p == (
char *) NULL)
2206 return((
char *) NULL);
2224 }
while (d !=
'\0');
2297 if (text == (
char *) NULL)
2299 if (count != (
size_t *) NULL)
2301 return((
char **) NULL);
2303 for (p=text; *p !=
'\0'; p++)
2304 if (((
int) ((
unsigned char) *p) < 32) &&
2305 (isspace((
int) ((
unsigned char) *p)) == 0))
2316 for (p=text; *p !=
'\0'; p++)
2321 if (textlist == (
char **) NULL)
2324 for (i=0; i < (ssize_t) lines; i++)
2326 for (q=p; *q !=
'\0'; q++)
2327 if ((*q ==
'\r') || (*q ==
'\n'))
2330 sizeof(**textlist));
2331 if (textlist[i] == (
char *) NULL)
2333 (void) memcpy(textlist[i],p,(
size_t) (q-p));
2334 textlist[i][q-p]=
'\0';
2357 if (textlist == (
char **) NULL)
2360 for (i=0; i < (ssize_t) lines; i++)
2366 sizeof(**textlist));
2367 if (textlist[i] == (
char *) NULL)
2371 q=textlist[i]+strlen(textlist[i]);
2378 if ((j % 0x04) == 0)
2385 if ((j % 0x04) == 0)
2391 if (isprint((
int) ((
unsigned char) *p)) != 0)
2399 textlist[i]+1),
sizeof(**textlist));
2400 if (textlist[i] == (
char *) NULL)
2404 if (count != (
size_t *) NULL)
2406 textlist[i]=(
char *) NULL;
2437 assert(
string != (
const char *) NULL);
2440 return(string_info);
2475 assert(message != (
char *) NULL);
2476 if (*message ==
'\0')
2478 length=strlen(message);
2480 while (isspace((
int) ((
unsigned char) *p)) != 0)
2482 if ((*p ==
'\'') || (*p ==
'"'))
2485 while ((isspace((
int) ((
unsigned char) *q)) != 0) && (q > p))
2488 if ((*q ==
'\'') || (*q ==
'"'))
2490 (void) memmove(message,p,(
size_t) (q-p+1));
2491 message[q-p+1]=
'\0';
2492 for (p=message; *p !=
'\0'; p++)
2529 const char *search,
const char *replace)
2548 for (p=strchr(*
string,*search); p != (
char *) NULL; p=strchr(p+1,*search))
2550 if (search_extent == 0)
2551 search_extent=strlen(search);
2552 if (strncmp(p,search,search_extent) != 0)
2558 if (replace_extent == 0)
2559 replace_extent=strlen(replace);
2560 if (replace_extent > search_extent)
2565 offset=(ssize_t) (p-(*
string));
2566 extent=strlen(*
string)+replace_extent-search_extent+1;
2569 if (*
string == (
char *) NULL)
2576 if (search_extent != replace_extent)
2577 (void) memmove(p+replace_extent,p+search_extent,
2578 strlen(p+search_extent)+1);
2579 (void) memcpy(p,replace,replace_extent);
2580 p+=replace_extent-1;
MagickExport double InterpretSiPrefixValue(const char *magick_restrict string, char **magick_restrict sentinal)
MagickExport ssize_t FormatMagickSize(const MagickSizeType size, const MagickBooleanType bi, const char *suffix, const size_t length, char *format)
MagickExport MagickBooleanType IsStringFalse(const char *value)
MagickExport int CompareStringInfo(const StringInfo *target, const StringInfo *source)
MagickExport StringInfo * StringToStringInfo(const char *string)
MagickExport size_t ConcatenateMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
MagickExport void SetStringInfoPath(StringInfo *string_info, const char *path)
static StringInfo * AcquireStringInfoContainer()
#define ThrowFatalException(severity, tag)
MagickExport char * EscapeString(const char *source, const char escape)
static double StringToDouble(const char *magick_restrict string, char **magick_restrict sentinal)
MagickExport char * SanitizeString(const char *source)
MagickExport void ConcatenateStringInfo(StringInfo *string_info, const StringInfo *source)
MagickExport ssize_t FormatLocaleString(char *magick_restrict string, const size_t length, const char *magick_restrict format,...)
MagickExport size_t CopyMagickString(char *magick_restrict destination, const char *magick_restrict source, const size_t length)
MagickExport void * ResizeQuantumMemory(void *memory, const size_t count, const size_t quantum)
MagickExport void StripString(char *message)
MagickExport char * FileToString(const char *filename, const size_t extent, ExceptionInfo *exception)
#define MagickCoreSignature
MagickExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
MagickExport ssize_t FormatLocaleFile(FILE *file, const char *magick_restrict format,...)
MagickExport char ** StringToList(const char *text)
MagickExport char * AcquireString(const char *source)
MagickExport void * FileToBlob(const char *filename, const size_t extent, size_t *length, ExceptionInfo *exception)
MagickExport void * AcquireCriticalMemory(const size_t size)
MagickExport StringInfo * FileToStringInfo(const char *filename, const size_t extent, ExceptionInfo *exception)
MagickExport StringInfo * DestroyStringInfo(StringInfo *string_info)
MagickExport void ResetStringInfo(StringInfo *string_info)
MagickExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
MagickExport void PrintStringInfo(FILE *file, const char *id, const StringInfo *string_info)
MagickExport MagickBooleanType IsStringTrue(const char *value)
MagickExport int GetMagickPrecision(void)
MagickExport StringInfo * BlobToStringInfo(const void *blob, const size_t length)
MagickExport MagickBooleanType ThrowMagickException(ExceptionInfo *exception, const char *module, const char *function, const size_t line, const ExceptionType severity, const char *tag, const char *format,...)
MagickExport MagickBooleanType LogMagickEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
static int open_utf8(const char *path, int flags, mode_t mode)
ExceptionInfo * exception
MagickExport double * StringToArrayOfDoubles(const char *string, ssize_t *count, ExceptionInfo *exception)
MagickExport MagickBooleanType SubstituteString(char **string, const char *search, const char *replace)
MagickExport char * GetEnvironmentValue(const char *name)
MagickExport StringInfo * ConfigureFileToStringInfo(const char *filename)
MagickExport StringInfo * AcquireStringInfo(const size_t length)
MagickExport int LocaleCompare(const char *p, const char *q)
#define GetMagickModule()
MagickExport const char * GetStringInfoPath(const StringInfo *string_info)
MagickExport void SetStringInfoName(StringInfo *string_info, const char *name)
MagickExport char * StringToken(const char *delimiters, char **string)
MagickExport void SetStringInfoLength(StringInfo *string_info, const size_t length)
MagickExport char * DestroyString(char *string)
MagickExport char ** DestroyStringList(char **list)
MagickExport MagickBooleanType ConcatenateString(char **magick_restrict destination, const char *magick_restrict source)
MagickExport void * RelinquishMagickMemory(void *memory)
MagickExport MagickBooleanType UnmapBlob(void *, const size_t)
MagickExport char * CloneString(char **destination, const char *source)
MagickExport char ** StringToStrings(const char *text, size_t *count)
MagickExport StringInfo * SplitStringInfo(StringInfo *string_info, const size_t offset)
MagickExport char * StringInfoToString(const StringInfo *string_info)
MagickExport char * StringInfoToHexString(const StringInfo *string_info)
MagickExport char ** StringToArgv(const char *text, int *argc)
MagickExport size_t GetStringInfoLength(const StringInfo *string_info)
MagickExport const char * GetStringInfoName(const StringInfo *string_info)
MagickExport char * ConstantString(const char *source)
MagickExport StringInfo * CloneStringInfo(const StringInfo *string_info)
MagickExport void SetStringInfoDatum(StringInfo *string_info, const unsigned char *source)
MagickExport void * MapBlob(int, const MapMode, const MagickOffsetType, const size_t)
MagickExport void SetStringInfo(StringInfo *string_info, const StringInfo *source)
MagickExport double InterpretLocaleValue(const char *magick_restrict string, char **magick_restrict sentinal)