2022-10-12 02:03:57 +00:00
|
|
|
#include "oslib.h"
|
|
|
|
|
|
|
|
char *strcatn(char *d, const char *s, SInt32 max) {
|
2022-10-12 17:07:57 +00:00
|
|
|
char *p;
|
2022-10-12 02:03:57 +00:00
|
|
|
|
2022-10-12 17:07:57 +00:00
|
|
|
p = d + strlen(d);
|
|
|
|
while (*s && (p - d) + 1 < max)
|
|
|
|
*(p++) = *(s++);
|
|
|
|
|
|
|
|
*p = 0;
|
|
|
|
return d;
|
2022-10-12 02:03:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
char *strcpyn(char *d, const char *s, SInt32 len, SInt32 max) {
|
2022-10-12 17:07:57 +00:00
|
|
|
char *p;
|
|
|
|
|
|
|
|
p = d;
|
|
|
|
while (len-- && *s && (p - d) + 1 < max)
|
|
|
|
*(p++) = *(s++);
|
2022-10-12 02:03:57 +00:00
|
|
|
|
2022-10-12 17:07:57 +00:00
|
|
|
*p = 0;
|
|
|
|
return d;
|
2022-10-12 02:03:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ustrcmp(const char *src, const char *dst) {
|
2022-10-12 17:07:57 +00:00
|
|
|
int x;
|
2022-10-12 02:03:57 +00:00
|
|
|
|
2022-10-12 17:07:57 +00:00
|
|
|
do {
|
|
|
|
x = tolower(*src) - tolower(*(dst++));
|
|
|
|
if (x)
|
|
|
|
return x;
|
|
|
|
} while (*(src++));
|
|
|
|
|
|
|
|
return 0;
|
2022-10-12 02:03:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int ustrncmp(const char *src, const char *dst, UInt32 len) {
|
2022-10-12 17:07:57 +00:00
|
|
|
int x;
|
|
|
|
|
|
|
|
while (len--) {
|
|
|
|
x = tolower(*src) - tolower(*(dst++));
|
|
|
|
if (x)
|
|
|
|
return x;
|
|
|
|
if (!*(src++))
|
|
|
|
return 0;
|
|
|
|
}
|
2022-10-12 02:03:57 +00:00
|
|
|
|
2022-10-12 17:07:57 +00:00
|
|
|
return 0;
|
2022-10-12 02:03:57 +00:00
|
|
|
}
|