first commit

This commit is contained in:
snarmph 2021-09-30 17:42:28 +02:00
commit efd4d9c750
13 changed files with 1950 additions and 0 deletions

31
strutils.c Normal file
View file

@ -0,0 +1,31 @@
#include "strutils.h"
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
void strToLower(char *str) {
for(char *beg = str; *beg; ++beg) {
*beg = tolower(*beg);
}
}
void strnToLower(char *str, size_t len) {
for(size_t i = 0; i < len; ++i) {
str[i] = tolower(str[i]);
}
}
char *cstrdup(const char *str) {
size_t len = strlen(str);
char *buf = malloc(len + 1);
memcpy(buf, str, len);
buf[len] = '\0';
return buf;
}
char *cstrToLower(const char *str) {
char *buf = cstrdup(str);
strToLower(buf);
return buf;
}