toaruos/boot/util.c

49 lines
831 B
C
Raw Normal View History

2021-06-14 05:11:37 +03:00
#include "util.h"
int strcmp(const char * l, const char * r) {
for (; *l == *r && *l; l++, r++);
return *(unsigned char *)l - *(unsigned char *)r;
}
char * strchr(const char * s, int c) {
while (*s) {
if (*s == c) {
return (char *)s;
}
s++;
}
return 0;
}
2021-08-21 01:55:48 +03:00
unsigned long strlen(const char *s) {
unsigned long out = 0;
while (*s) {
out++;
s++;
}
return out;
}
2021-06-14 05:11:37 +03:00
char * strcat(char *dest, const char *src) {
char * end = dest;
while (*end != '\0') {
++end;
}
while (*src) {
*end = *src;
end++;
src++;
}
*end = '\0';
return dest;
}
void copy_sectors(unsigned long lba, unsigned char * buf, int sectors) {
memcpy(buf, (char*)(lba * 2048 + DATA_LOAD_BASE), sectors * 2048);
}
void copy_sector(unsigned long lba, unsigned char * buf) {
memcpy(buf, (char*)(lba * 2048 + DATA_LOAD_BASE), 2048);
}