From da310946f00ce2069afc748a681db714636e5538 Mon Sep 17 00:00:00 2001 From: turbocat Date: Fri, 30 Apr 2021 22:00:07 +0000 Subject: [PATCH] kolibri-libc: - Fixed fwrite. - Added strcat to the export table. - Fixed two functions in ksys.h. - Added binaries for autobuild git-svn-id: svn://kolibrios.org@8705 a494cfbc-eb01-0410-851d-a64ba20cac60 --- .../libraries/kolibri-libc/include/sys/ksys.h | 3 +- .../develop/libraries/kolibri-libc/lib/crt0.o | Bin 0 -> 1404 bytes .../libraries/kolibri-libc/lib/libc.obj.a | Bin 0 -> 62030 bytes .../libraries/kolibri-libc/samples/Makefile | 3 +- .../kolibri-libc/source/stdio/fgetc.c | 35 ++-------------- .../kolibri-libc/source/stdio/fread.c | 38 ++++++++++++------ .../libraries/kolibri-libc/source/symbols.txt | 1 + 7 files changed, 35 insertions(+), 45 deletions(-) create mode 100644 programs/develop/libraries/kolibri-libc/lib/crt0.o create mode 100644 programs/develop/libraries/kolibri-libc/lib/libc.obj.a 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 0000000000000000000000000000000000000000..fbd17a270a1746904389943663564a3b80a42ae4 GIT binary patch literal 1404 zcma)5O=uHA6rN2sajTKG{#5)Wh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0!>0KWX=8|_8E+ayytML z4_LH0uHAh7#g|{QiHw(rO}O$!DFHm3f9}pTx8>R2*w_~io2VKXmDMG&^J-cg<9LYTM%pQ0F4Ax#_PJ`y34V4aLUpSyZ%apaj zS>u3aTRDcnx4Fh+@q)nq(-$yg>Fm6?J6msJ*0o2n^0-oc;lPo;Aka7vqRtaUjSxA=;$PH3z6JkQ4ho;(&xE&CXI;VM zi=wH%VAe4NX+q^O-TK3U3N(gO3K|CjZ4(Ufp}punY=r~jC4o;I5YVLAnLJk+PQ4+kpHq}iD~PaH_gs-P7Pq~7)&;wu7X<;lVvaUhKk6wQG) zIDqAG-TLDPD$qDkAhA8Jz)i!usRp#hy#bZ$)IoqEpUL!W6Jc$ z4^*HroKny@5aK(cwA1eRaw<>i(i0A7&?MAC*6bhR`0_NO9p=ggVbeY!FR#!eC48}e zrV0jaqM&ggNFTsfDz{^a7fi_bke$nM#j~wTMJuCA#rnbl1)79f$eR6w^Z|oWx7RNh zt8d%~WaSllq=YZ_SD-PRQqVXMqz@R3a21xKDcJZkVQR|b+VqD5s0t2kqNH&k#P@^i zT|U92X+Myc$8_rn2Q+95rxY{}gy;v>Tb^f@m&erU3kUvR=b5eBNuYUkFx3ytxGq&u y9%F$wZGw&93A9|){6UE8Qmu -#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