kuro/util.c

30 lines
489 B
C
Raw Normal View History

2024-01-22 07:50:23 +00:00
#include "dat.h"
#include "fns.h"
int strequ(char* s1, char* s2) {
return strcmp(s1, s2) == 0;
}
char* strcsw(char* s, char a, char b) {
int i = 0;
char c;
while ((c = s[i])) {
s[i++] = c == a ? b : c;
}
return s;
}
char* uvlong_to_hex(uvlong input, char* buf) {
2024-01-27 05:39:39 +00:00
sprintf(buf, "%08x\0", input);
2024-01-22 07:50:23 +00:00
return buf;
2024-01-27 05:39:39 +00:00
}
int ensure(char* path) {
int f = create(path, OREAD, DMDIR | 0777);
if (f < 0) {
return 0;
} else {
close(f);
return 1;
}
2024-01-22 07:50:23 +00:00
}