Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 8743 → Rev 8744

/programs/develop/libraries/kolibri-libc/include/stdio.h
96,8 → 96,7
#define getc() _FUNC(fgetc)(stdin)
extern int _FUNC(getchar)(void);
extern int _FUNC(printf)(const char *restrict, ...);
extern int _FUNC(putc)(int, FILE *);
extern int _FUNC(putchar)(int);
#define putc(ch) _FUNC(fputc)(ch, stdout)
extern int _FUNC(puts)(const char *);
extern int _FUNC(scanf)(const char *restrict, ...);
extern char* _FUNC(gets)(char *str);
136,6 → 135,4
 
extern int _FUNC(getchar)(void);
 
extern void _FUNC(con_set_title)(const char*);
 
#endif // _STDIO_H_
/programs/develop/libraries/kolibri-libc/include/sys/dirent.h
24,11 → 24,11
}DIR;
 
 
int _FUNC(closedir)(DIR *dir);
DIR* _FUNC(opendir)(const char *path);
struct dirent* _FUNC(readdir)(DIR *);
void _FUNC(rewinddir)(DIR *dir);
void _FUNC(seekdir)(DIR *dir, unsigned pos);
unsigned _FUNC(telldir)(DIR *dir);
extern int _FUNC(closedir)(DIR *dir);
extern DIR* _FUNC(opendir)(const char *path);
extern struct dirent* _FUNC(readdir)(DIR *);
extern void _FUNC(rewinddir)(DIR *dir);
extern void _FUNC(seekdir)(DIR *dir, unsigned pos);
extern unsigned _FUNC(telldir)(DIR *dir);
 
#endif // _DIRENT_H_
/programs/develop/libraries/kolibri-libc/lib/libc.obj.a
Cannot display: file marked as a binary type.
svn:mime-type = application/x-archive
/programs/develop/libraries/kolibri-libc/samples/dir_example.c
0,0 → 1,45
#include <sys/dirent.h>
#include <sys/dir.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
 
const char *folder_type = "Folder";
const char *file_type = "File";
 
int main()
{
char *path=getcwd(NULL, PATH_MAX);
printf("Current directory: %s\n", path);
if(mkdir("test")){
puts("Test folder created!");
}
else{
puts("Error creating folder!");
}
DIR *mydir = opendir(path);
if(!mydir){
puts("File system error.");
return -1;
}
 
struct dirent *file_info;
char *str_type=NULL;
putc(' ');
while((file_info = readdir(mydir))!=NULL){
if(file_info->d_type==IS_FOLDER){
(*con_set_flags)(CON_COLOR_GREEN);
str_type = (char*)folder_type;
}else {
(*con_set_flags)(7);
str_type = (char*)file_type;
}
printf("%3d %20s %s\n ", file_info->d_ino ,file_info->d_name, str_type);
};
 
setcwd("/sys/develop");
path=getcwd(NULL, PATH_MAX);
printf("Move to the directory: %s\n", path);
free(path);
}
/programs/develop/libraries/kolibri-libc/source/libc.c
14,6 → 14,7
#include "sys/opendir.c"
#include "sys/telldir.c"
#include "sys/closedir.c"
#include "sys/dir.c"
 
#include "stdio/clearerr.c"
#include "stdio/gets.c"
/programs/develop/libraries/kolibri-libc/source/stdio/conio.h
File deleted
/programs/develop/libraries/kolibri-libc/source/stdio/conio.c
1,5 → 1,6
#include <sys/ksys.h>
#include "conio.h"
#include <conio.h>
#include "stdio.h"
 
static char* __con_caption = "Console application";
static char* __con_dllname = "/sys/lib/console.obj";
6,22 → 7,29
 
int __con_is_load = 0;
 
void stdcall (*__con_init_hidden)(int wnd_width, int wnd_height,int scr_width, int scr_height, const char* title);
void stdcall (*__con_write_asciiz)(const char* str);
void stdcall (*__con_write_string)(const char* str, unsigned length);
int stdcall (*__con_getch)(void);
short stdcall (*__con_getch2)(void);
int stdcall (*__con_kbhit)(void);
char* stdcall (*__con_gets)(char* str, int n);
char* stdcall (*__con_gets2)(__con_gets2_callback callback, char* str, int n);
void stdcall (*__con_exit)(int status);
void stdcall (*__con_set_title)(const char* title);
void stdcall (*__con_init_hidden)(int wnd_width, unsigned wnd_height, int scr_width, int scr_height, const char* title);
void stdcall (*con_exit)(int);
void stdcall (*con_set_title)(const char* title);
void stdcall (*con_write_asciiz)(const char* str);
void stdcall (*con_write_string)(const char* str, dword length);
int cdecl (*con_printf)(const char* format, ...);
dword stdcall (*con_get_flags)(void);
dword stdcall (*con_set_flags)(dword new_flags);
int stdcall (*con_get_font_height)(void);
int stdcall (*con_get_cursor_height)(void);
int stdcall (*con_set_cursor_height)(int new_height);
int stdcall (*con_getch)(void);
word stdcall (*con_getch2)(void);
int stdcall (*con_kbhit)(void);
char* stdcall (*con_gets)(char* str, int n);
char* stdcall (*con_gets2)(con_gets2_callback callback, char* str, int n);
void stdcall (*con_cls)();
void stdcall (*con_get_cursor_pos)(int* px, int* py);
void stdcall (*con_set_cursor_pos)(int x, int y);
 
static void __con_panic(char* func_name)
{
_ksys_debug_puts("libc.obj: ");
_ksys_debug_puts(func_name);
_ksys_debug_puts(" = NULL\n");
debug_printf("In console.obj %s=NULL!\n", func_name);
_ksys_exit();
}
 
28,30 → 36,28
static void __con_lib_link(ksys_coff_etable_t *exp)
{
__con_init_hidden = _ksys_get_coff_func(exp, "con_init", __con_panic);
__con_write_asciiz = _ksys_get_coff_func(exp, "con_write_asciiz", __con_panic);
__con_write_string = _ksys_get_coff_func(exp, "con_write_string", __con_panic);
__con_getch = _ksys_get_coff_func(exp, "con_getch", __con_panic);
__con_getch2 = _ksys_get_coff_func(exp, "con_getch2", __con_panic);
__con_kbhit = _ksys_get_coff_func(exp, "con_kbhit", __con_panic);
__con_gets = _ksys_get_coff_func(exp, "con_gets", __con_panic);
__con_gets2 = _ksys_get_coff_func(exp, "con_gets2", __con_panic);
__con_exit = _ksys_get_coff_func(exp, "con_exit", __con_panic);
__con_set_title = _ksys_get_coff_func(exp, "con_set_title", __con_panic);
con_exit = _ksys_get_coff_func(exp, "con_exit", __con_panic);
con_set_title = _ksys_get_coff_func(exp, "con_set_title", __con_panic);
con_write_asciiz = _ksys_get_coff_func(exp, "con_write_asciiz", __con_panic);
con_write_string = _ksys_get_coff_func(exp, "con_write_string", __con_panic);
con_printf = _ksys_get_coff_func(exp, "con_printf", __con_panic);
con_get_flags = _ksys_get_coff_func(exp, "con_get_flags", __con_panic);
con_set_flags = _ksys_get_coff_func(exp, "con_set_flags", __con_panic);
con_get_font_height = _ksys_get_coff_func(exp, "con_get_font_height", __con_panic);
con_get_cursor_height = _ksys_get_coff_func(exp, "con_get_cursor_height", __con_panic);
con_set_cursor_height = _ksys_get_coff_func(exp, "con_set_cursor_height", __con_panic);
con_getch = _ksys_get_coff_func(exp, "con_getch", __con_panic);
con_getch2 = _ksys_get_coff_func(exp, "con_getch2", __con_panic);
con_kbhit = _ksys_get_coff_func(exp, "con_kbhit", __con_panic);
con_gets = _ksys_get_coff_func(exp, "con_gets", __con_panic);
con_gets2 = _ksys_get_coff_func(exp, "con_gets2", __con_panic);
con_cls = _ksys_get_coff_func(exp, "con_cls", __con_panic);
con_get_cursor_pos = _ksys_get_coff_func(exp, "con_get_cursor_pos", __con_panic);
con_set_cursor_pos = _ksys_get_coff_func(exp, "con_set_cursor_pos", __con_panic);
}
 
 
int __con_init(void)
int con_init_opt(dword wnd_width, dword wnd_height, dword scr_width, dword scr_height, const char* title)
{
return __con_init_opt(-1, -1, -1, -1, __con_caption);
}
 
void con_set_title(const char* title){
__con_init();
__con_set_title(title);
}
 
int __con_init_opt(int wnd_width, int wnd_height,int scr_width, int scr_height, const char* title)
{
if(!__con_is_load){
ksys_coff_etable_t *__con_lib;
__con_lib = _ksys_load_coff(__con_dllname);
66,3 → 72,10
}
return 1;
}
 
 
int con_init(void)
{
return con_init_opt(-1, -1, -1, -1, __con_caption);
}
 
/programs/develop/libraries/kolibri-libc/source/stdio/fread.c
13,8 → 13,8
}
if(stream==stdin){
__con_init();
__con_gets((char*)ptr, bytes_count+1);
con_init();
con_gets((char*)ptr, bytes_count+1);
return nmemb;
}
 
/programs/develop/libraries/kolibri-libc/source/stdio/fwrite.c
3,7 → 3,6
#include <sys/ksys.h>
#include <errno.h>
 
 
size_t fwrite(const void *restrict ptr, size_t size, size_t nmemb, FILE *restrict stream) {
unsigned bytes_written = 0;
unsigned bytes_count = size * nmemb;
14,8 → 13,8
}
if(stream==stdout){
__con_init();
__con_write_string((char*)ptr, bytes_count);
con_init();
con_write_string((char*)ptr, bytes_count);
return nmemb;
}
else if(stream==stderr){
/programs/develop/libraries/kolibri-libc/source/stdio/getchar.c
1,10 → 1,10
#include <stdio.h>
#include "conio.h"
#include <conio.h>
 
int getchar(void) {
__con_init();
con_init();
char c = 0;
__con_gets(&c, 2);
con_gets(&c, 2);
if (c == 0) {
c = EOF;
}
/programs/develop/libraries/kolibri-libc/source/stdio/gets.c
6,8 → 6,8
 
char *gets(char* str)
{
__con_init();
if(__con_gets(str, STDIO_MAX_MEM)==NULL){
con_init();
if(con_gets(str, STDIO_MAX_MEM)==NULL){
errno = EIO;
return NULL;
}
/programs/develop/libraries/kolibri-libc/source/stdio/puts.c
7,8 → 7,8
 
int puts(const char *str)
{
__con_init();
__con_write_asciiz(str);
__con_write_asciiz("\n");
con_init();
con_write_asciiz(str);
con_write_asciiz("\n");
return strlen(str);
}
/programs/develop/libraries/kolibri-libc/source/stdio/vprintf.c
18,9 → 18,9
errno = ENOMEM;
return errno;
}
__con_init();
con_init();
len = vsnprintf(s, STDIO_MAX_MEM, format, arg);
__con_write_string(s, len);
con_write_string(s, len);
free(s);
return(len);
}
/programs/develop/libraries/kolibri-libc/source/stdlib/libtcc1.c
File deleted
/programs/develop/libraries/kolibri-libc/source/stdlib/exit.c
1,12 → 1,12
/* Copyright (C) 2021 Logaev Maxim (turbocat2001), GPLv2 */
 
#include "../stdio/conio.h"
#include <conio.h>
#include <sys/ksys.h>
 
void exit(int status)
{
if(__con_is_load){
__con_exit(status);
con_exit(status);
}
_ksys_exit();
}
/programs/develop/libraries/kolibri-libc/source/stdlib/localtime.c
15,7 → 15,7
int bcd_year = (kos_date & 0xFF);
buffertime.tm_mday = ((bcd_day & 0xF0)>>4)*10 + (bcd_day & 0x0F);
buffertime.tm_mon = ((bcd_mon & 0xF0)>>4)*10 + (bcd_mon & 0x0F) - 1;
buffertime.tm_year = ((bcd_year & 0xF0)>>4)*10 + (bcd_year & 0x0F) + 100;
buffertime.tm_year = ((bcd_year & 0xF0)>>4)*10 + (bcd_year & 0x0F);
buffertime.tm_wday = buffertime.tm_yday = buffertime.tm_isdst = -1; /* temporary */
/programs/develop/libraries/kolibri-libc/source/symbols.txt
96,6 → 96,11
rewinddir
seekdir
telldir
getcwd
mkdir
rmdir
setcwd
getcwd
!____UNISTD____
!____MATH____
acosh
132,5 → 137,24
toupper
!___CONIO___
con_set_title
con_init
con_init_opt
con_write_asciiz
con_write_string
con_printf
con_exit
con_get_flags
con_set_flags
con_kbhit
con_getch
con_getch2
con_gets
con_gets2
con_get_font_height
con_get_cursor_height
con_set_cursor_height
con_cls
con_get_cursor_pos
con_set_cursor_pos
!___LIBC_VERSION___
_libc_get_version
_libc_get_version
/programs/develop/libraries/kolibri-libc/source/sys/dir.c
0,0 → 1,25
#include <sys/ksys.h>
#include <sys/dir.h>
#include <stdlib.h>
 
char *getcwd(char *buf, unsigned size){
if(!buf){
if((buf = malloc(size))==NULL){
return NULL;
}
}
_ksys_getcwd(buf, size);
return(buf);
}
 
void setcwd(const char* cwd){
_ksys_setcwd((char*)cwd);
}
 
int rmdir(const char* dir){
return _ksys_file_delete(dir);
}
 
int mkdir(const char* dir){
return _ksys_mkdir(dir);
}