22 #include <sys/types.h>
29 static void *G__memccpy(
void *,
const void *,
int,
size_t);
30 static int _strncasecmp(
const char *,
const char *,
int);
49 return _strncasecmp(
x, y, -1);
71 return _strncasecmp(
x, y, n);
160 char *
G_strchg(
char *bug,
char character,
char new)
165 if (*help == character)
198 if (old_str ==
NULL || new_str ==
NULL)
205 B = strstr(buffer, old_str);
210 if (strlen(new_str) > strlen(old_str)) {
213 len = strlen(old_str);
215 while (B !=
NULL && *B !=
'\0') {
216 B = strstr(B, old_str);
223 len =
count * (strlen(new_str) - strlen(old_str)) + strlen(buffer);
226 len = strlen(buffer);
236 len = strlen(old_str);
238 if (*B == old_str[0] && strncmp(B, old_str, len) == 0) {
267 char *
G_str_concat(
const char **src_strings,
int num_strings,
const char *sep,
270 if (maxsize < 1 || num_strings < 1)
273 char *concat_str =
NULL;
275 char *buffer =
G_malloc(maxsize *
sizeof(
char));
276 char *end = buffer + maxsize;
278 memset(buffer, 0, maxsize);
279 for (
int i = 0; i < num_strings; i++) {
281 p = (
char *)G__memccpy(buffer, src_strings[i],
'\0', maxsize);
284 p = (
char *)G__memccpy(p - 1, sep,
'\0', end - p);
286 p = (
char *)G__memccpy(p - 1, src_strings[i],
'\0', end - p);
305 for (a =
b = buf; *a ==
' ' || *a ==
'\t'; a++)
308 while ((*
b++ = *a++))
311 for (a = buf; *a; a++)
314 for (a--; *a ==
' ' || *a ==
'\t'; a--)
334 char *f = line, *
t = line;
346 while (isspace(*--
t))
373 str[i] = toupper(str[i]);
391 str[i] = tolower(str[i]);
417 if (!(*c >=
'A' && *c <=
'Z') && !(*c >=
'a' && *c <=
'z') &&
418 !(*c >=
'0' && *c <=
'9')) {
426 if (!(*c >=
'A' && *c <=
'Z') && !(*c >=
'a' && *c <=
'z')) {
448 char *f = line, *
t = line;
462 l = strlen(line) - 1;
463 if (*(line +
l) ==
'\n')
485 length = strlen(substr);
489 while (*q !=
'\0' && toupper(*q) != toupper(*p)) {
492 }
while (*q !=
'\0' &&
G_strncasecmp(p, q, length) != 0 && q++);
521 static void *G__memccpy(
void *dst,
const void *src,
int c,
size_t n)
526 for (ret = dst; n; ++ret, ++s, --n) {
528 if ((
unsigned char)*ret == (
unsigned char)c)
535 static int _strncasecmp(
const char *
x,
const char *y,
int n)
548 if (xx >=
'A' && xx <=
'Z')
550 if (yy >=
'A' && yy <=
'Z')
557 if (n > -1 && i >= n)
void G_free(void *)
Free allocated memory.
char * G_store(const char *s)
Copy string to allocated memory.
int G_str_to_sql(char *str)
Make string SQL compliant.
char * G_strcasestr(const char *str, const char *substr)
Finds the first occurrence of the sub-string in the null-terminated string ignoring case (upper or lo...
int G_strncasecmp(const char *x, const char *y, int n)
String compare ignoring case (upper or lower) - limited number of characters.
char * G_store_upper(const char *s)
Copy string to allocated memory and convert copied string to upper case.
void G_str_to_upper(char *str)
Convert string to upper case.
char * G_str_concat(const char **src_strings, int num_strings, const char *sep, int maxsize)
String concatenation.
void G_str_to_lower(char *str)
Convert string to lower case.
char * G_store_lower(const char *s)
Copy string to allocated memory and convert copied string to lower case.
int G_strcasecmp(const char *x, const char *y)
String compare ignoring case (upper or lower)
void G_squeeze(char *line)
Remove superfluous white space.
char * G_str_replace(const char *buffer, const char *old_str, const char *new_str)
Replace all occurrences of old_str in buffer with new_str.
void G_strip(char *buf)
Removes all leading and trailing white space from string.
char * G_strchg(char *bug, char character, char new)
Replace all occurrences of character in string bug with new.
char * G_chop(char *line)
Chop leading and trailing white spaces.