diff --git a/programs/develop/libraries/kolibri-libc/include/sys/ksys.h b/programs/develop/libraries/kolibri-libc/include/sys/ksys.h index 2e79619179..849e00af2d 100644 --- a/programs/develop/libraries/kolibri-libc/include/sys/ksys.h +++ b/programs/develop/libraries/kolibri-libc/include/sys/ksys.h @@ -349,7 +349,7 @@ unsigned _ksys_get_skin_height() } static inline -void _ksys_get_colors(ksys_colors_table_t *color_table) +void _ksys_get_system_colors(ksys_colors_table_t *color_table) { asm_inline( "int $0x40" @@ -1015,6 +1015,7 @@ ksys_drv_hand_t _ksys_load_driver(char *driver_name) return driver_h; } +static inline ksys_drv_hand_t _ksys_load_pe_driver(char *driver_path, char *cmd_line) { ksys_drv_hand_t driver_h; diff --git a/programs/develop/libraries/kolibri-libc/lib/crt0.o b/programs/develop/libraries/kolibri-libc/lib/crt0.o new file mode 100644 index 0000000000..fbd17a270a Binary files /dev/null and b/programs/develop/libraries/kolibri-libc/lib/crt0.o differ diff --git a/programs/develop/libraries/kolibri-libc/lib/libc.obj.a b/programs/develop/libraries/kolibri-libc/lib/libc.obj.a new file mode 100644 index 0000000000..eef019ae87 Binary files /dev/null and b/programs/develop/libraries/kolibri-libc/lib/libc.obj.a differ diff --git a/programs/develop/libraries/kolibri-libc/samples/Makefile b/programs/develop/libraries/kolibri-libc/samples/Makefile index ebf5b7b2b3..2d42ee7c16 100644 --- a/programs/develop/libraries/kolibri-libc/samples/Makefile +++ b/programs/develop/libraries/kolibri-libc/samples/Makefile @@ -11,7 +11,8 @@ math_test.kex \ string_test.kex \ whois.kex \ file_io.kex \ -tmpdisk_work.kex +tmpdisk_work.kex \ +exp_drv_work.kex all: $(BIN) diff --git a/programs/develop/libraries/kolibri-libc/source/stdio/fgetc.c b/programs/develop/libraries/kolibri-libc/source/stdio/fgetc.c index b773d7aaf6..326539027b 100644 --- a/programs/develop/libraries/kolibri-libc/source/stdio/fgetc.c +++ b/programs/develop/libraries/kolibri-libc/source/stdio/fgetc.c @@ -1,38 +1,11 @@ #include -#include -#include int fgetc(FILE* stream) { - unsigned bytes_read; - char c; - - unsigned status = _ksys_file_read_file(stream->name, stream->position, 1, &c, &bytes_read); - - if (status != KSYS_FS_ERR_SUCCESS) { - switch (status) { - case KSYS_FS_ERR_EOF: - stream->eof = 1; - break; - case KSYS_FS_ERR_1: - case KSYS_FS_ERR_2: - case KSYS_FS_ERR_3: - case KSYS_FS_ERR_4: - case KSYS_FS_ERR_5: - case KSYS_FS_ERR_7: - case KSYS_FS_ERR_8: - case KSYS_FS_ERR_9: - case KSYS_FS_ERR_10: - case KSYS_FS_ERR_11: - default: - // Just some IO error, who knows what exactly happened - errno = EIO; - stream->error = errno; - break; - } + int c=EOF; + if(fwrite(&c, sizeof(int), 1, stream)==1){ + return c; + }else{ return EOF; } - - stream->position++; - return c; } diff --git a/programs/develop/libraries/kolibri-libc/source/stdio/fread.c b/programs/develop/libraries/kolibri-libc/source/stdio/fread.c index 31bb3ab5aa..594b3ba561 100644 --- a/programs/develop/libraries/kolibri-libc/source/stdio/fread.c +++ b/programs/develop/libraries/kolibri-libc/source/stdio/fread.c @@ -1,20 +1,34 @@ #include +#include +#include "conio.h" +#include "sys/ksys.h" size_t fread(void *restrict ptr, size_t size, size_t nmemb, FILE *restrict stream) { unsigned bytes_read = 0; unsigned bytes_count = size * nmemb; - - for (size_t i = 0; i < bytes_count; i++) { - char c = fgetc(stream); - - if (c == EOF) { - break; - } - - *(char*)(ptr+i) = c; - - bytes_read++; + + if(!stream){ + errno = EINVAL; + return 0; + } + + if(stream==stdin){ + __con_init(); + __con_gets((char*)ptr, bytes_count); + return nmemb; } - return bytes_read / size; + else{ + if(stream->mode != _STDIO_F_W){ + unsigned status = _ksys_file_read_file(stream->name, stream->position, bytes_count, ptr , &bytes_read); + if (status != KSYS_FS_ERR_SUCCESS) { + errno = EIO; + stream->error = errno; + return 0; + }else { + stream->position+=bytes_read; + } + } + } + return bytes_read; } diff --git a/programs/develop/libraries/kolibri-libc/source/symbols.txt b/programs/develop/libraries/kolibri-libc/source/symbols.txt index 50acbeb28f..662baf0a2f 100644 --- a/programs/develop/libraries/kolibri-libc/source/symbols.txt +++ b/programs/develop/libraries/kolibri-libc/source/symbols.txt @@ -69,6 +69,7 @@ memmove memset strncat strchr +strcat strcmp strcoll strcpy