strcmp() added

This commit is contained in:
shockrah 2019-12-05 02:13:58 -08:00
parent 16041ec1d5
commit e3b14232ea
2 changed files with 16 additions and 0 deletions

12
stlio.c
View File

@ -22,6 +22,15 @@ u32 strlen(const char* buffer) {
return i;
}
u32 strcmp(const char* left, const char* right) {
u32 s = strlen(left);
for(u32 i = 0; i<s; i++) {
if(left[i] != right[i]) {
return 1;
}
}
return 0;
}
u32 write(const char* buffer, const u32 size) {
u32 i;
for(i = 0; i < size; i++) {
@ -54,6 +63,9 @@ u32 read(char* buffer, u32 size) {
__char_set(&state, kbd_state);
if(pit_timer_ticks - kbd_time < 0x20 && state == KBD_RELEASE) {
__char_set(&(buffer[bytes]), (u8)kbd_key);
if(kbd_key == '\n') {
return bytes;
}
bytes++;
__char_set(&kbd_state, KBD_WAITING); // reset the kbd_state since we've now used it
putch(kbd_key);

View File

@ -5,8 +5,12 @@
// Frame buffer driver
// NOTE: not getting computed at compile time so we always have a call
#define LINE_LENGTH COLUMNS
u32 strlen(const char*);
u32 strcmp(const char*, const char*);
u32 write(const char*, const u32);
u32 read(char*, u32);