78#if !defined(WIZARDSTOOLKIT_HAVE_STRCASECMP) || !defined(WIZARDSTOOLKIT_HAVE_STRNCASECMP)
79static const unsigned char
82 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
83 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
84 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23,
85 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
86 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
87 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
88 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73,
89 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
90 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
91 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
92 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, 0x80, 0x81, 0x82, 0x83,
93 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
94 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
95 0x9c, 0x9d, 0x9e, 0x9f, 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
96 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3,
97 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
98 0xc0, 0xe1, 0xe2, 0xe3, 0xe4, 0xc5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb,
99 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
100 0xf8, 0xf9, 0xfa, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, 0xe0, 0xe1, 0xe2, 0xe3,
101 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
102 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb,
103 0xfc, 0xfd, 0xfe, 0xff,
142 if (source != (
char *) NULL)
143 length+=strlen(source);
147 sizeof(*destination));
148 if (destination == (
char *) NULL)
151 if (source != (
char *) NULL)
152 (
void) memcpy(destination,source,length*
sizeof(*destination));
153 destination[length]=
'\0';
187 (void) memset(string_info,0,
sizeof(*string_info));
188 string_info->
timestamp=time((time_t *) NULL);
190 string_info->
length=length;
191 string_info->
datum=(
unsigned char *) NULL;
195 if (string_info->
datum == (
unsigned char *) NULL)
198 sizeof(*string_info->
datum));
234 string_info->
length=length;
235 if (string_info->
datum == (
unsigned char *) NULL)
241 if (string_info->
datum == (
unsigned char *) NULL)
246 if (blob != (
const void *) NULL)
247 (void) memcpy(string_info->
datum,blob,length);
249 (
void) memset(string_info->
datum,0,length*
sizeof(*string_info->
datum));
251 sizeof(*string_info->
datum));
286 if (source == (
const char *) NULL)
288 if (*destination != (
char *) NULL)
290 return(*destination);
292 if (*destination == (
char *) NULL)
295 return(*destination);
297 length=strlen(source);
301 sizeof(**destination));
302 if (*destination == (
char *) NULL)
305 (void) memcpy(*destination,source,length*
sizeof(**destination));
306 (*destination)[length]=
'\0';
307 return(*destination);
340 if (string_info->
length != 0)
425 assert(destination != (
char **) NULL);
426 if (*destination == (
char *) NULL)
431 destination_length=strlen(*destination);
432 source_length=strlen(source);
433 length=destination_length;
434 if (~length < source_length)
436 length+=source_length;
441 if (*destination == (
char *) NULL)
443 if (source_length != 0)
444 (void) memcpy((*destination)+destination_length,source,source_length);
445 (*destination)[length]=
'\0';
479 const char *source,
const size_t length)
481#if !defined(WIZARDSTOOLKIT_HAVE_STRLCAT)
494 assert(destination != (
char *) NULL);
495 assert(source != (
const char *) NULL);
500 while ((i-- != 0) && (*q !=
'\0'))
502 count=(size_t) (q-destination);
505 return(count+strlen(p));
516 return(count+(p-source));
518 return(strlcat(destination,source,length));
576 length=(size_t) offset;
577 string=(
char *) NULL;
581 if (
string == (
char *) NULL)
587 if (map != (
void *) NULL)
589 (void) memcpy(
string,map,length);
600 (void) lseek(file,0,SEEK_SET);
601 for (i=0; i < length; i+=count)
603 count=read(file,
string+i,(
size_t)
WizardMin(length-i,(
size_t)
623 string_info->
length=length;
624 if (string_info->
datum != (
unsigned char *) NULL)
627 string_info->
datum=(
unsigned char *)
string;
664 if (source != (
char *) NULL)
665 length+=strlen(source);
666 destination=(
char *) NULL;
669 if (destination == (
char *) NULL)
672 if (source != (
char *) NULL)
673 (
void) memcpy(destination,source,length*
sizeof(*destination));
674 destination[length]=
'\0';
713 length=string_info->
length;
714 if (~length < source->length)
719 string_info->
length=length;
720 if (string_info->
datum == (
unsigned char *) NULL)
726 sizeof(*string_info->
datum));
727 if (string_info->
datum == (
unsigned char *) NULL)
776 for (n=length; n > 4; n-=4)
780 return((
size_t) (p-source-1));
784 return((
size_t) (p-source-1));
788 return((
size_t) (p-source-1));
792 return((
size_t) (p-source-1));
796 for (n--; n != 0; n--)
800 return((
size_t) (p-source-1));
805 return((
size_t) (p-source-1));
861 if (string_info->
datum != (
unsigned char *) NULL)
864 string_info->
signature=(~WizardSignature);
896 assert(list != (
char **) NULL);
897 for (i=0; list[i] != (
char *) NULL; i++)
939 return((
char *)
FileToBlob(filename,extent,&length,exception));
980 if (string_info->
datum != (
unsigned char *) NULL)
984 &string_info->
length,exception);
985 if (string_info->
datum == (
unsigned char *) NULL)
1044 "",
"Ki",
"Mi",
"Gi",
"Ti",
"Pi",
"Ei",
"Zi",
"Yi", (
char *) NULL
1046 *traditional_units[] =
1048 "",
"K",
"M",
"G",
"T",
"P",
"E",
"Z",
"Y", (
char *) NULL
1052 units=traditional_units;
1058#if defined(_MSC_VER) && (_MSC_VER == 1200)
1061 extent=(double) size;
1063 for (i=0; (extent >= bytes) && (units[i+1] != (
const char *) NULL); i++)
1066 for (j=2; j < 12; j++)
1070 if (strchr(format,
'+') == (
char *) NULL)
1118 assert(timestamp != (
char *) NULL);
1119#if defined(WIZARDSTOOLKIT_HAVE_LOCALTIME_R)
1120 (void) localtime_r(&time,&local_time);
1126 my_time=localtime(&time);
1127 if (my_time != (
struct tm *) NULL)
1128 (void) memcpy(&local_time,my_time,
sizeof(local_time));
1131#if defined(WIZARDSTOOLKIT_HAVE_GMTIME_R)
1132 (void) gmtime_r(&time,&gm_time);
1138 my_time=gmtime(&time);
1139 if (my_time != (
struct tm *) NULL)
1140 (void) memcpy(&gm_time,my_time,
sizeof(gm_time));
1143 timezone=(time_t) ((local_time.tm_min-gm_time.tm_min)/60+
1144 local_time.tm_hour-gm_time.tm_hour+24*((local_time.tm_year-
1145 gm_time.tm_year) != 0 ? (local_time.tm_year-gm_time.tm_year) :
1146 (local_time.tm_yday-gm_time.tm_yday)));
1148 "%04d-%02d-%02dT%02d:%02d:%02d%+03ld:00",local_time.tm_year+1900,
1149 local_time.tm_mon+1,local_time.tm_mday,local_time.tm_hour,
1150 local_time.tm_min,local_time.tm_sec,(
long) timezone);
1182 environment=getenv(name);
1183 if (environment == (
const char *) NULL)
1184 return((
char *) NULL);
1255 return(string_info->
datum);
1284 return(string_info->
length);
1313 return(string_info->
path);
1357 (void) memset(hex_digits,0,
sizeof(hex_digits));
1358 hex_digits[(int)
'0']=0;
1359 hex_digits[(int)
'1']=1;
1360 hex_digits[(int)
'2']=2;
1361 hex_digits[(int)
'3']=3;
1362 hex_digits[(int)
'4']=4;
1363 hex_digits[(int)
'5']=5;
1364 hex_digits[(int)
'6']=6;
1365 hex_digits[(int)
'7']=7;
1366 hex_digits[(int)
'8']=8;
1367 hex_digits[(int)
'9']=9;
1368 hex_digits[(int)
'a']=10;
1369 hex_digits[(int)
'b']=11;
1370 hex_digits[(int)
'c']=12;
1371 hex_digits[(int)
'd']=13;
1372 hex_digits[(int)
'e']=14;
1373 hex_digits[(int)
'f']=15;
1374 hex_digits[(int)
'A']=10;
1375 hex_digits[(int)
'B']=11;
1376 hex_digits[(int)
'C']=12;
1377 hex_digits[(int)
'D']=13;
1378 hex_digits[(int)
'E']=14;
1379 hex_digits[(int)
'F']=15;
1380 p=(
unsigned char *)
string;
1381 q=string_info->
datum;
1382 for (i=0; i < (ssize_t) string_info->
length; i++)
1384 *q=hex_digits[*p++] << 4;
1385 *q|=hex_digits[*p++];
1388 return(string_info);
1429 if ((*q >=
'E') && (*q <=
'z'))
1434 switch ((
int) ((
unsigned char) *q))
1436 case 'y': e=(-24.0);
break;
1437 case 'z': e=(-21.0);
break;
1438 case 'a': e=(-18.0);
break;
1439 case 'f': e=(-15.0);
break;
1440 case 'p': e=(-12.0);
break;
1441 case 'n': e=(-9.0);
break;
1442 case 'u': e=(-6.0);
break;
1443 case 'm': e=(-3.0);
break;
1444 case 'c': e=(-2.0);
break;
1445 case 'd': e=(-1.0);
break;
1446 case 'h': e=2.0;
break;
1447 case 'k': e=3.0;
break;
1448 case 'K': e=3.0;
break;
1449 case 'M': e=6.0;
break;
1450 case 'G': e=9.0;
break;
1451 case 'T': e=12.0;
break;
1452 case 'P': e=15.0;
break;
1453 case 'E': e=18.0;
break;
1454 case 'Z': e=21.0;
break;
1455 case 'Y': e=24.0;
break;
1456 default: e=0.0;
break;
1462 value*=pow(2.0,e/0.3);
1472 if ((*q ==
'B') || (*q ==
'P'))
1475 if (sentinal != (
char **) NULL)
1512 if ((p == (
char *) NULL) && (q == (
char *) NULL))
1514 if (p == (
char *) NULL)
1516 if (q == (
char *) NULL)
1518#if defined(WIZARDSTOOLKIT_HAVE_STRCASECMP)
1519 return(strcasecmp(p,q));
1528 c=(int) *((
unsigned char *) p);
1529 d=(int) *((
unsigned char *) q);
1568 assert(
string != (
char *) NULL);
1569 for (q=
string; *q !=
'\0'; q++)
1570 *q=(
char) tolower((
int) *q);
1610 if ((p == (
char *) NULL) && (q == (
char *) NULL))
1612 if (p == (
char *) NULL)
1614 if (q == (
char *) NULL)
1616#if defined(WIZARDSTOOLKIT_HAVE_STRNCASECMP)
1617 return(strncasecmp(p,q,length));
1627 for (i=length; i != 0; i--)
1629 c=(int) *((
unsigned char *) p);
1630 d=(int) *((
unsigned char *) q);
1679 va_start(operands,format);
1684 return((ssize_t) fwrite(
string,(
size_t) length,1,file));
1722 for (p=string_info->
datum; p < q; p++)
1724 if (((
int) *p < 32) && (isspace((
int) ((
unsigned char) *p)) == 0))
1726 if (isascii((
int) ((
unsigned char) *p)) == 0)
1731 for (p=string_info->
datum; p < q; p++)
1734 for (p=string_info->
datum; p < q; p++)
1765 (void) memset(string_info->
datum,0,string_info->
length);
1799 if (string_info->
length == 0)
1801 (void) memset(string_info->
datum,0,string_info->
length);
1802 (void) memcpy(string_info->
datum,source->
datum,
1833 const unsigned char *source)
1837 if (string_info->
length != 0)
1838 (void) memcpy(string_info->
datum,source,string_info->
length);
1866 const size_t length)
1870 string_info->
length=length;
1873 if (string_info->
datum == (
unsigned char *) NULL)
1879 if (string_info->
datum == (
unsigned char *) NULL)
1938 const size_t offset)
1945 if (offset > string_info->
length)
1949 (void) memmove(string_info->
datum,string_info->
datum+offset,
1997 length=string_info->
length;
2001 if (
string == (
char *) NULL)
2019 p=string_info->
datum;
2020 q=(
unsigned char *)
string;
2021 for (i=0; i < (ssize_t) string_info->
length; i++)
2023 *q++=hex_digits[(*p >> 4) & 0x0f];
2024 *q++=hex_digits[*p & 0x0f];
2061 string=(
char *) NULL;
2062 length=string_info->
length;
2065 if (
string == (
char *) NULL)
2066 return((
char *) NULL);
2067 (void) memcpy(
string,(
char *) string_info->
datum,length*
sizeof(*string));
2068 string[length]=
'\0';
2113 if (text == (
char *) NULL)
2114 return((
char **) NULL);
2118 for (p=text; *p !=
'\0'; )
2120 while (isspace((
int) ((
unsigned char) *p)) != 0)
2126 for (p++; (*p !=
'"') && (*p !=
'\0'); p++) ;
2128 for (p++; (*p !=
'\'') && (*p !=
'\0'); p++) ;
2129 while ((isspace((
int) ((
unsigned char) *p)) == 0) && (*p !=
'\0'))
2133 if (argv == (
char **) NULL)
2139 for (i=0; i < (ssize_t) *argc; i++)
2141 while (isspace((
int) ((
unsigned char) *p)) != 0)
2147 for (q++; (*q !=
'"') && (*q !=
'\0'); q++) ;
2153 for (q++; (*q !=
'\'') && (*q !=
'\0'); q++) ;
2156 while ((isspace((
int) ((
unsigned char) *q)) == 0) && (*q !=
'\0'))
2160 if (argv[i] == (
char *) NULL)
2162 for (i--; i >= 0; i--)
2167 (void) memcpy(argv[i],p,(
size_t) (q-p));
2170 while ((isspace((
int) ((
unsigned char) *p)) == 0) && (*p !=
'\0'))
2173 argv[i]=(
char *) NULL;
2207 return(string_info);
2242 assert(message != (
char *) NULL);
2243 if (*message ==
'\0')
2245 length=strlen(message);
2247 while (isspace((
int) ((
unsigned char) *p)) != 0)
2249 if ((*p ==
'\'') || (*p ==
'"'))
2252 while ((isspace((
int) ((
unsigned char) *q)) != 0) && (q > p))
2255 if ((*q ==
'\'') || (*q ==
'"'))
2257 (void) memmove(message,p,(
size_t) (q-p+1));
2258 message[q-p+1]=
'\0';
2259 for (p=message; *p !=
'\0'; p++)
2296 const char *search,
const char *replace)
2315 for (p=strchr(*
string,*search); p != (
char *) NULL; p=strchr(p+1,*search))
2317 if (search_extent == 0)
2318 search_extent=strlen(search);
2319 if (strncmp(p,search,search_extent) != 0)
2325 if (replace_extent == 0)
2326 replace_extent=strlen(replace);
2327 if (replace_extent > search_extent)
2332 offset=(ssize_t) (p-(*
string));
2333 extent=strlen(*
string)+replace_extent-search_extent+1;
2336 if (*
string == (
char *) NULL)
2338 "memory allocation failed `%s'");
2344 if (search_extent != replace_extent)
2346 strlen(p+search_extent)+1);
2348 p+=replace_extent-1;
WizardExport WizardBooleanType UnmapBlob(void *map, const size_t length)
WizardExport void * FileToBlob(const char *filename, const size_t extent, size_t *length, ExceptionInfo *exception)
WizardExport void * MapBlob(int file, const MapMode mode, const WizardOffsetType offset, const size_t length)
#define MaxCipherBlocksize
WizardExport CRC64Info * DestroyCRC64Info(CRC64Info *crc_info)
WizardExport WizardBooleanType InitializeCRC64(CRC64Info *crc_info)
WizardExport CRC64Info * AcquireCRC64Info(void)
WizardExport WizardSizeType GetCRC64CyclicRedundancyCheck(const CRC64Info *crc64_info)
WizardExport WizardBooleanType FinalizeCRC64(CRC64Info *crc_info)
WizardExport WizardBooleanType UpdateCRC64(CRC64Info *crc_info, const StringInfo *message)
#define WizardAssert(domain, predicate)
#define ThrowFatalException(severity, tag)
WizardExport ssize_t FormatLocaleStringList(char *string, const size_t length, const char *format, va_list operands)
WizardExport double InterpretLocaleValue(const char *string, char **sentinal)
WizardExport ssize_t FormatLocaleString(char *string, const size_t length, const char *format,...)
WizardBooleanType LogWizardEvent(const LogEventType type, const char *module, const char *function, const size_t line, const char *format,...)
#define GetWizardModule()
static size_t OverAllocateMemory(const size_t length)
WizardExport void * AcquireWizardMemory(const size_t size)
WizardExport void * CopyWizardMemory(void *destination, const void *source, const size_t size)
WizardExport void * AcquireQuantumMemory(const size_t count, const size_t quantum)
WizardExport void * RelinquishWizardMemory(void *memory)
WizardExport void * ResizeQuantumMemory(void *memory, const size_t count, const size_t quantum)
WizardExport StringInfo * FileToStringInfo(const char *filename, const size_t extent, ExceptionInfo *exception)
WizardExport WizardSizeType GetStringInfoCRC(const StringInfo *string_info)
WizardExport char * CloneString(char **destination, const char *source)
WizardExport void SetStringInfoLength(StringInfo *string_info, const size_t length)
WizardExport char * FileToString(const char *filename, const size_t extent, ExceptionInfo *exception)
WizardExport int LocaleNCompare(const char *p, const char *q, const size_t length)
static const unsigned char AsciiMap[]
WizardExport void SetStringInfo(StringInfo *string_info, const StringInfo *source)
WizardExport double InterpretSiPrefixValue(const char *string, char **sentinal)
WizardExport char * DestroyString(char *string)
WizardExport WizardBooleanType SubstituteString(char **string, const char *search, const char *replace)
WizardExport StringInfo * HexStringToStringInfo(const char *string)
WizardExport void StripString(char *message)
WizardExport char ** StringToArgv(const char *text, int *argc)
WizardExport ssize_t FormatWizardSize(const WizardSizeType size, const WizardBooleanType bi, const size_t length, char *format)
WizardExport int LocaleCompare(const char *p, const char *q)
WizardExport void LocaleLower(char *string)
WizardExport char * StringInfoToHexString(const StringInfo *string_info)
WizardExport void SetStringInfoPath(StringInfo *string_info, const char *path)
WizardExport char * ConstantString(const char *source)
WizardExport StringInfo * SplitStringInfo(StringInfo *string_info, const size_t offset)
WizardExport size_t GetStringInfoLength(const StringInfo *string_info)
WizardExport size_t ConcatenateWizardString(char *destination, const char *source, const size_t length)
WizardExport StringInfo * AcquireStringInfo(const size_t length)
WizardExport int CompareStringInfo(const StringInfo *target, const StringInfo *source)
WizardExport StringInfo * ConfigureFileToStringInfo(const char *filename)
WizardExport StringInfo * CloneStringInfo(const StringInfo *string_info)
WizardExport char * AcquireString(const char *source)
WizardExport WizardBooleanType ConcatenateString(char **destination, const char *source)
WizardExport char * StringInfoToString(const StringInfo *string_info)
WizardExport void SetStringInfoDatum(StringInfo *string_info, const unsigned char *source)
WizardExport ssize_t FormatWizardTime(const time_t time, const size_t length, char *timestamp)
WizardExport void ConcatenateStringInfo(StringInfo *string_info, const StringInfo *source)
WizardExport StringInfo * BlobToStringInfo(const void *blob, const size_t length)
WizardExport unsigned char * GetStringInfoDatum(const StringInfo *string_info)
WizardExport void PrintStringInfo(FILE *file, const char *id, const StringInfo *string_info)
WizardExport char * GetEnvironmentValue(const char *name)
WizardExport void ResetStringInfo(StringInfo *string_info)
WizardExport size_t CopyWizardString(char *destination, const char *source, const size_t length)
WizardExport char ** DestroyStringList(char **list)
WizardExport StringInfo * StringToStringInfo(const char *string)
WizardExport const char * GetStringInfoPath(const StringInfo *string_info)
WizardExport ssize_t PrintWizardString(FILE *file, const char *format,...)
WizardExport StringInfo * DestroyStringInfo(StringInfo *string_info)
char path[WizardPathExtent]
static int open_utf8(const char *path, int flags, mode_t mode)