quark/src/kernel/lib/string.c
Arnau Camprubí be55b8121c Floppy disk controller, new keyboard and PIT driver interface, many things
- Implemented basic FDC capable of reading floppy disc sectors
 - Now PIT timer can be used, as it counts the ticks
 - Now the keyboard is buffered, instead of being accessed only during the interrupt itself
 - HAL for sleep()
 - gets()
 - atoi()
 - Now shell is not called by the IRQ, but it's a procedure that reads the key buffer
2022-08-15 01:34:15 +02:00

31 líneas
515 B
C

#include "string.h"
int strlen(char *s){
int len = 0;
while(*(s++)) len++;
return len;
}
int strcmp(char *s1, char *s2){
while(*s1 && (*s1 == *s2)) {s1++; s2++;}
return *(const unsigned char *)s1 - *(const unsigned char *)s2;
}
void strcpy(char *dest, char *src){
while(*src){
*(dest++) = *(src++);
}
*dest = '\0';
}
int atoi(char *str){
int res = 0;
for(int i = 0; i < strlen(str); i++){
res *= 10;
res += str[i] - '0';
}
return res;
}