13 const char *
wkdayArray[] = {
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Set",
"Sun"};
14 const char *
monthArray[] = {
"Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec"};
16 int strRcmp(
const char *str,
const char *str1)
18 int ret = (str ? strlen(str) : 0) - (str1 ? strlen(str1) : 0);
19 if(ret == 0 && str && str1)
24 if(static_cast<char>(tolower(str[i])) ==
static_cast<char>(tolower(str1[i])))
47 const char *
strRstr(
const char *str,
const char *str1)
49 const char *ret = NULL;
55 while(static_cast<char>(tolower(str[i])) == static_cast<char>(tolower(str1[y])))
89 while(str[i] != 0 && str1[i] != 0)
91 if(static_cast<char>(tolower(str[i])) != static_cast<char>(tolower(str1[i])))
103 if((str[i] == 0) && (str1[i] != 0))
118 while(str[i] != 0 && str1[i] != 0)
120 if(str[i] != str1[i])
127 if((str[i] == 0) && (str1[i] != 0))
141 unsigned int len = strlen(buff);
144 unsigned int localLen = strlen(strSeparate);
145 unsigned int count = 0;
146 char *baseBuff = NULL;
147 char *find =
const_cast<char *
>(buff);
148 while((find = strstr(find, strSeparate)) != NULL)
174 ret =
new char *[count];
175 stringsCount = count;
176 for(
unsigned int i = 0; i < count; i++)
178 ret[i] =
new char[len + 1];
181 baseBuff = find =
const_cast<char *
>(buff);
183 while((find = strstr(find, strSeparate)) != NULL)
191 memcpy_arjanv_interleave(ret[count], baseBuff, find - baseBuff);
192 ret[count][find - baseBuff] = 0;
197 if(baseBuff < buff + len)
199 memcpy_arjanv_interleave(ret[count], baseBuff, buff + len + 1 - baseBuff);
206 ret[0] =
new char [len + 1];
207 memcpy_arjanv_interleave(ret[0], buff, len + 1);
223 while(buff[y] != 0x00)
225 if(buff[y] == symbol)
227 if(y > 0 && buff[y - 1] != symbol)
234 if(y > 0 && buff[y] != symbol)
243 ret =
new char* [stringsCount];
244 for(
unsigned int i = 0; i < stringsCount; i++)
246 ret[i] =
new char[size + 1];
249 while(buff[y] != 0x00 )
251 if(buff[y] == symbol)
253 if(y > 0 && buff[y - 1] != symbol)
273 if(massStrings && stringsCount > 0 && subStr)
275 for(
unsigned int i = 0; i < stringsCount; i++)
277 if(massStrings[i] && (strstr(massStrings[i], subStr) == massStrings[i]) && strcmp(massStrings[i], subStr) != 0)
279 memmove(massStrings[i], massStrings[i] + strlen(subStr), strlen(massStrings[i]) - strlen(subStr) + 1);
285 const char *
strRepl(
const char *baseStr,
const char **replFrom,
const char **replTo,
unsigned int replCount,
bool chg)
288 if(baseStr && replFrom && replTo && replCount)
290 unsigned int size = strlen(baseStr);
291 unsigned int len = size;
292 unsigned int *replSizeFrom =
new unsigned int[replCount];
293 unsigned int *replSizeTo =
new unsigned int[replCount];
295 for(
unsigned int i = 0; i < replCount; i++)
297 buff =
const_cast<char *
>(baseStr);
298 if(replFrom[i] && replTo[i])
300 replSizeFrom[i] = strlen(replFrom[i]);
301 replSizeTo[i] = strlen(replTo[i]);
304 buff = strstr(buff, replFrom[i]);
307 size += replSizeTo[i];
308 buff += replSizeFrom[i];
315 char *buff1 =
new char[size + 1];
316 char *buff2 =
new char[size + 1];
317 unsigned int num1 = 0;
318 unsigned int num2 = 0;
319 memcpy_arjanv_interleave(buff1, baseStr, len + 1);
320 char *tmpBuff = NULL;
321 for(
unsigned int i = 0; i < replCount; i++)
326 if(replFrom[i] && replTo[i])
330 tmpBuff = strstr(tmpBuff, replFrom[i]);
333 strncpy(buff2 + num2, buff1 + num1, tmpBuff - (buff1 + num1));
334 num2 += tmpBuff - (buff1 + num1);
338 strcat(buff2, replTo[i]);
339 num2 += replSizeTo[i];
341 tmpBuff += replSizeFrom[i];
342 num1 = tmpBuff - buff1;
348 strncpy(buff2 + num2, buff1 + num1, strlen(buff1) - num1);
349 buff2[num2 + strlen(buff1) - num1] = 0;
363 ret =
const_cast<char *
>(baseStr);
375 unsigned int size = strlen(str);
376 if(strstr(str,
"https://") == str)
380 else if(strstr(str,
"http://") == str)
384 while(str[i] !=
'/' && str[i] != 0)
390 while(str[i] !=
'.' && str[i] != 0)
397 ret =
new char[size + 1];
398 while(str[i] !=
'?' && str[i] != 0)
421 char localFname[1024];
422 unsigned int fNameLen = strlen(fName);
423 unsigned int additionChar = 0;
424 if(stat(fName, &sStat) == 0)
426 if(sStat.st_mode & S_IFDIR)
428 DIR *fDir = opendir(fName);
431 struct dirent *dirEntr = NULL;
432 while((dirEntr = readdir(fDir)) != NULL)
435 if(strcmp(dirEntr->d_name,
".") != 0 && strcmp(dirEntr->d_name,
"..") != 0)
437 if((fNameLen + strlen(dirEntr->d_name)) < 1022)
439 memcpy(localFname, fName, fNameLen);
440 if(localFname[fNameLen - 1] !=
'/')
442 localFname[fNameLen] =
'/';
445 memcpy(localFname + fNameLen + additionChar, dirEntr->d_name, strlen(dirEntr->d_name) + 1);
459 if(timeVal > 0 && ret)
461 struct tm *localTime = gmtime(&timeVal);
464 sprintf(ret,
"%s%s, %02d %s %4d %02d:%02d:%02d GMT", (previousStr ? previousStr :
""),
465 wkdayArray[localTime->tm_wday ? (localTime->tm_wday - 1) : 6], localTime->tm_mday,
monthArray[localTime->tm_mon],
466 localTime->tm_year + 1900, localTime->tm_hour, localTime->tm_min, localTime->tm_sec);
476 struct tm *localTime = gmtime(&timeVal);
479 ret =
new char[(previousStr ? strlen(previousStr) : 0 ) + 256];
480 sprintf(ret,
"%s%s, %02d %s %4d %02d:%02d:%02d GMT", (previousStr ? previousStr :
""),
481 wkdayArray[localTime->tm_wday ? (localTime->tm_wday - 1) : 6], localTime->tm_mday,
monthArray[localTime->tm_mon],
482 localTime->tm_year + 1900, localTime->tm_hour, localTime->tm_min, localTime->tm_sec);