Update skipped files in previous commit

git-svn-id: svn://kolibrios.org@9766 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2022-04-15 09:11:49 +00:00
parent cde4fa851d
commit 99922e4c2c
51 changed files with 1967 additions and 2487 deletions

View File

@ -66,11 +66,8 @@ qsort
strtod strtod
__assert_fail __assert_fail
;____STRING____ ;____STRING____
;memcpy
memchr memchr
memcmp memcmp
!memmove
!memset
strncat strncat
strchr strchr
strcat strcat
@ -90,7 +87,7 @@ strspn
strstr strstr
strtok strtok
strxfrm strxfrm
_errno __errno
;____SYS____ ;____SYS____
closedir closedir
opendir opendir

View File

@ -0,0 +1,6 @@
# Format Style Options - Created with Clang Power Tools
---
BasedOnStyle: WebKit
AlignTrailingComments: true
AlignConsecutiveMacros: true
...

View File

@ -4,6 +4,10 @@
#include <stddef.h> #include <stddef.h>
#include <stdlib.h> #include <stdlib.h>
#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__),0))) #ifdef NDEBUG
#define assert(x) (void)0
#else
#define assert(x) ((void)((x) || (__assert_fail(#x, __FILE__, __LINE__, __func__), 0)))
#endif
#endif // _ASSERT_H_ #endif // _ASSERT_H_

View File

@ -3,9 +3,9 @@
#ifndef KOLIBRI_BOXLIB_H #ifndef KOLIBRI_BOXLIB_H
#define KOLIBRI_BOXLIB_H #define KOLIBRI_BOXLIB_H
#include <sys/ksys.h>
#include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h>
#include <sys/ksys.h>
typedef unsigned color_t; typedef unsigned color_t;
int kolibri_boxlib_init(void); int kolibri_boxlib_init(void);
@ -67,7 +67,7 @@ typedef struct {
uint32_t work_size; uint32_t work_size;
uint32_t all_redraw; // need to be set =1 before each redraw uint32_t all_redraw; // need to be set =1 before each redraw
uint32_t ar_offset; uint32_t ar_offset;
} __attribute__ ((__packed__)) scrollbar; } __attribute__((__packed__)) scrollbar;
extern void __stdcall (*scrollbar_h_draw)(scrollbar*); extern void __stdcall (*scrollbar_h_draw)(scrollbar*);
extern void __stdcall (*scrollbar_h_mouse)(scrollbar*); extern void __stdcall (*scrollbar_h_mouse)(scrollbar*);
@ -82,16 +82,16 @@ typedef struct {
unsigned int color; unsigned int color;
unsigned int border_color; unsigned int border_color;
unsigned int text_color; unsigned int text_color;
char *text; char* text;
unsigned int flags; unsigned int flags;
/* Users can use members above this */ /* Users can use members above this */
unsigned int size_of_str; unsigned int size_of_str;
}check_box; } check_box;
extern void __stdcall (*check_box_draw2)(check_box *); extern void __stdcall (*check_box_draw2)(check_box*);
extern void __stdcall (*check_box_mouse2)(check_box *); extern void __stdcall (*check_box_mouse2)(check_box*);
extern void __stdcall (*init_checkbox2)(check_box *); extern void __stdcall (*init_checkbox2)(check_box*);
// DBUTTON // DBUTTON
typedef struct { typedef struct {
@ -111,12 +111,12 @@ typedef struct {
uint32_t click; // clicked - 1, zero it after tested uint32_t click; // clicked - 1, zero it after tested
} pict_button; } pict_button;
extern void __stdcall (*dynamic_button_draw)(pict_button *); extern void __stdcall (*dynamic_button_draw)(pict_button*);
extern void __stdcall (*dynamic_button_mouse)(pict_button *); extern void __stdcall (*dynamic_button_mouse)(pict_button*);
// EDITBOX // EDITBOX
#pragma pack(push,1) #pragma pack(push, 1)
typedef struct edit_box_t { typedef struct edit_box_t {
unsigned int width; unsigned int width;
unsigned int left; unsigned int left;
@ -127,13 +127,13 @@ typedef struct edit_box_t {
unsigned int blur_border_color; unsigned int blur_border_color;
unsigned int text_color; unsigned int text_color;
unsigned int max; unsigned int max;
char *text; char* text;
void *mouse_variable; // must be pointer edit_box** to save focused editbox void* mouse_variable; // must be pointer edit_box** to save focused editbox
unsigned int flags; unsigned int flags;
unsigned int size; // used symbols in buffer without trailing zero unsigned int size; // used symbols in buffer without trailing zero
unsigned int pos; // cursor position unsigned int pos; // cursor position
/* The following struct members are not used by the users of API */ /* The following struct members are not used by the users of API */
unsigned int offset; unsigned int offset;
unsigned int cl_curs_x; unsigned int cl_curs_x;
unsigned int cl_curs_y; unsigned int cl_curs_y;
@ -141,15 +141,15 @@ typedef struct edit_box_t {
unsigned int shift_old; unsigned int shift_old;
unsigned int height; unsigned int height;
unsigned int char_width; unsigned int char_width;
}edit_box; } edit_box;
#pragma pack(pop) #pragma pack(pop)
extern void __stdcall (*edit_box_draw)(edit_box *); extern void __stdcall (*edit_box_draw)(edit_box*);
extern void __stdcall (*edit_box_key)(edit_box *, unsigned int key_val); extern void __stdcall (*edit_box_key)(edit_box*, unsigned int key_val);
extern void __stdcall (*edit_box_mouse)(edit_box *); extern void __stdcall (*edit_box_mouse)(edit_box*);
extern void __stdcall (*edit_box_set_text)(edit_box *, char *); extern void __stdcall (*edit_box_set_text)(edit_box*, char*);
extern void __stdcall (*edit_box_key_safe)(edit_box *e, ksys_oskey_t ch); extern void __stdcall (*edit_box_key_safe)(edit_box* e, ksys_oskey_t ch);
// FRAME // FRAME
typedef struct { typedef struct {
@ -159,15 +159,15 @@ typedef struct {
color_t ext_col; color_t ext_col;
color_t int_col; color_t int_col;
uint32_t flags; uint32_t flags;
char *text_pointer; char* text_pointer;
uint32_t text_position; uint32_t text_position;
uint32_t font_number; uint32_t font_number;
uint32_t font_size_y; uint32_t font_size_y;
color_t font_color; color_t font_color;
color_t font_bg_color; color_t font_bg_color;
}frame; } frame;
extern void __stdcall (*frame_draw)(frame *); extern void __stdcall (*frame_draw)(frame*);
// MENUBAR // MENUBAR
typedef struct typedef struct
@ -208,13 +208,13 @@ typedef struct
uint32_t get_mouse_flag; uint32_t get_mouse_flag;
} menubar; } menubar;
extern void __stdcall (*menu_bar_draw)(menubar *); extern void __stdcall (*menu_bar_draw)(menubar*);
extern void __stdcall (*menu_bar_mouse)(menubar *); extern void __stdcall (*menu_bar_mouse)(menubar*);
extern void __stdcall (*menu_bar_activate)(menubar *); extern void __stdcall (*menu_bar_activate)(menubar*);
// OPTIONBOX // OPTIONBOX
typedef struct option_box_t { typedef struct option_box_t {
struct option_box_t **selected; struct option_box_t** selected;
uint16_t posx; uint16_t posx;
uint16_t posy; uint16_t posy;
uint32_t text_margin; // = 4 ðàññòîÿíèå îò ïðÿìîóãîëüíèêà ÷åê áîêñà äî íàäïèñè uint32_t text_margin; // = 4 ðàññòîÿíèå îò ïðÿìîóãîëüíèêà ÷åê áîêñà äî íàäïèñè
@ -222,13 +222,13 @@ typedef struct option_box_t {
color_t color; color_t color;
color_t border_color; // individual border color_t border_color; // individual border
color_t text_color; color_t text_color;
char *text; char* text;
uint32_t text_len; uint32_t text_len;
uint32_t flags; uint32_t flags;
} __attribute__ ((__packed__)) option_box; } __attribute__((__packed__)) option_box;
extern void __stdcall (*option_box_draw)(option_box **); extern void __stdcall (*option_box_draw)(option_box**);
extern void __stdcall (*option_box_mouse)(option_box **); extern void __stdcall (*option_box_mouse)(option_box**);
// PATHSHOW // PATHSHOW
typedef struct { typedef struct {
@ -243,10 +243,10 @@ typedef struct {
char* text_pointer; // 4096 ? char* text_pointer; // 4096 ?
char* work_area_pointer; // 4096 ? char* work_area_pointer; // 4096 ?
uint32_t temp_text_length; uint32_t temp_text_length;
} __attribute__ ((__packed__)) pathview; } __attribute__((__packed__)) pathview;
extern void __stdcall (*path_show_prepare)(pathview *); extern void __stdcall (*path_show_prepare)(pathview*);
extern void __stdcall (*path_show_draw)(pathview *); extern void __stdcall (*path_show_draw)(pathview*);
// PROGRESSBAR // PROGRESSBAR
typedef struct { typedef struct {
@ -263,7 +263,7 @@ typedef struct {
unsigned int frame_color; unsigned int frame_color;
} progressbar; } progressbar;
extern void __stdcall (*progressbar_draw)(progressbar *); extern void __stdcall (*progressbar_draw)(progressbar*);
extern void __stdcall (*progressbar_progress)(progressbar *); extern void __stdcall (*progressbar_progress)(progressbar*);
#endif /* KOLIBRI_BOXLIB_H */ #endif /* KOLIBRI_BOXLIB_H */

View File

@ -1,19 +1,19 @@
#ifndef KOLIBRI_BUF2D_H #ifndef KOLIBRI_BUF2D_H
#define KOLIBRI_BUF2D_H #define KOLIBRI_BUF2D_H
#include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <sys/ksys.h> #include <sys/ksys.h>
#include <stddef.h>
typedef struct { typedef struct {
unsigned int *buf_pointer; unsigned int* buf_pointer;
uint16_t left; uint16_t left;
uint16_t top; uint16_t top;
unsigned int width; unsigned int width;
unsigned int height; unsigned int height;
unsigned int bgcolor; unsigned int bgcolor;
uint8_t color_bit; uint8_t color_bit;
} __attribute__ ((__packed__))buf2d_struct; } __attribute__((__packed__)) buf2d_struct;
enum BUF2D_ALGORITM_FILTR { enum BUF2D_ALGORITM_FILTR {
SIERRA_LITE, SIERRA_LITE,
@ -32,52 +32,52 @@ enum BUF2D_OPT_CROP {
int kolibri_buf2d_init(void); int kolibri_buf2d_init(void);
extern void __stdcall (*buf2d_create_asm)(buf2d_struct *); extern void __stdcall (*buf2d_create_asm)(buf2d_struct*);
extern void __stdcall (*buf2d_curve_bezier_asm)(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int); extern void __stdcall (*buf2d_curve_bezier_asm)(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int);
buf2d_struct* buf2d_create(uint16_t tlx, uint16_t tly, unsigned int sizex, unsigned int sizey, unsigned int font_bgcolor, uint8_t color_bit) buf2d_struct* buf2d_create(uint16_t tlx, uint16_t tly, unsigned int sizex, unsigned int sizey, unsigned int font_bgcolor, uint8_t color_bit)
{ {
buf2d_struct *new_buf2d_struct = (buf2d_struct *)_ksys_alloc(sizeof(buf2d_struct)); buf2d_struct* new_buf2d_struct = (buf2d_struct*)_ksys_alloc(sizeof(buf2d_struct));
new_buf2d_struct -> left = tlx; new_buf2d_struct->left = tlx;
new_buf2d_struct -> top = tly; new_buf2d_struct->top = tly;
new_buf2d_struct -> width = sizex; new_buf2d_struct->width = sizex;
new_buf2d_struct -> height = sizey; new_buf2d_struct->height = sizey;
new_buf2d_struct -> bgcolor = font_bgcolor; new_buf2d_struct->bgcolor = font_bgcolor;
new_buf2d_struct -> color_bit = color_bit; new_buf2d_struct->color_bit = color_bit;
buf2d_create_asm(new_buf2d_struct); buf2d_create_asm(new_buf2d_struct);
return new_buf2d_struct; return new_buf2d_struct;
} }
void buf2d_curve_bezier(buf2d_struct *buf, unsigned int p0_x, unsigned int p0_y, unsigned int p1_x, unsigned int p1_y, unsigned int p2_x, unsigned int p2_y, unsigned int color) void buf2d_curve_bezier(buf2d_struct* buf, unsigned int p0_x, unsigned int p0_y, unsigned int p1_x, unsigned int p1_y, unsigned int p2_x, unsigned int p2_y, unsigned int color)
{ {
buf2d_curve_bezier_asm(buf, (p0_x<<16)+p0_y, (p1_x<<16)+p1_y, (p2_x<<16)+p2_y, color); buf2d_curve_bezier_asm(buf, (p0_x << 16) + p0_y, (p1_x << 16) + p1_y, (p2_x << 16) + p2_y, color);
} }
extern void __stdcall (*buf2d_draw)(buf2d_struct *); extern void __stdcall (*buf2d_draw)(buf2d_struct*);
extern void __stdcall (*buf2d_clear)(buf2d_struct *, unsigned int); extern void __stdcall (*buf2d_clear)(buf2d_struct*, unsigned int);
extern void __stdcall (*buf2d_delete)(buf2d_struct *); extern void __stdcall (*buf2d_delete)(buf2d_struct*);
extern void __stdcall (*buf2d_rotate)(buf2d_struct *, unsigned int); extern void __stdcall (*buf2d_rotate)(buf2d_struct*, unsigned int);
extern void __stdcall (*buf2d_resize)(buf2d_struct *, unsigned int, unsigned int, unsigned int); extern void __stdcall (*buf2d_resize)(buf2d_struct*, unsigned int, unsigned int, unsigned int);
extern void __stdcall (*buf2d_line)(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); extern void __stdcall (*buf2d_line)(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
extern void __stdcall (*buf2d_line_sm)(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int); extern void __stdcall (*buf2d_line_sm)(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int);
extern void __stdcall (*buf2d_rect_by_size)(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); extern void __stdcall (*buf2d_rect_by_size)(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
extern void __stdcall (*buf2d_filled_rect_by_size)(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int); extern void __stdcall (*buf2d_filled_rect_by_size)(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
extern void __stdcall (*buf2d_circle)(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int); extern void __stdcall (*buf2d_circle)(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int);
extern void __stdcall (*buf2d_img_hdiv2)(buf2d_struct *); extern void __stdcall (*buf2d_img_hdiv2)(buf2d_struct*);
extern void __stdcall (*buf2d_img_wdiv2)(buf2d_struct *); extern void __stdcall (*buf2d_img_wdiv2)(buf2d_struct*);
extern void __stdcall (*buf2d_conv_24_to_8)(buf2d_struct *, unsigned int); extern void __stdcall (*buf2d_conv_24_to_8)(buf2d_struct*, unsigned int);
extern void __stdcall (*buf2d_conv_24_to_32)(buf2d_struct *, unsigned int); extern void __stdcall (*buf2d_conv_24_to_32)(buf2d_struct*, unsigned int);
extern void __stdcall (*buf2d_bit_blt_transp)(buf2d_struct *, unsigned int, unsigned int, buf2d_struct *); extern void __stdcall (*buf2d_bit_blt_transp)(buf2d_struct*, unsigned int, unsigned int, buf2d_struct*);
extern void __stdcall (*buf2d_bit_blt_alpha)(buf2d_struct *, unsigned int, unsigned int, buf2d_struct *); extern void __stdcall (*buf2d_bit_blt_alpha)(buf2d_struct*, unsigned int, unsigned int, buf2d_struct*);
extern void __stdcall (*buf2d_convert_text_matrix)(buf2d_struct *); extern void __stdcall (*buf2d_convert_text_matrix)(buf2d_struct*);
extern void __stdcall (*buf2d_draw_text)(buf2d_struct *, buf2d_struct *, const char *, unsigned int, unsigned int); extern void __stdcall (*buf2d_draw_text)(buf2d_struct*, buf2d_struct*, const char*, unsigned int, unsigned int);
extern void __stdcall (*buf2d_crop_color)(buf2d_struct *, unsigned int, unsigned int); extern void __stdcall (*buf2d_crop_color)(buf2d_struct*, unsigned int, unsigned int);
extern void __stdcall (*buf2d_offset_h)(buf2d_struct *, unsigned int, unsigned int, unsigned int); extern void __stdcall (*buf2d_offset_h)(buf2d_struct*, unsigned int, unsigned int, unsigned int);
extern void __stdcall (*buf2d_flood_fill)(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int); extern void __stdcall (*buf2d_flood_fill)(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int);
extern void __stdcall (*buf2d_set_pixel)(buf2d_struct *, unsigned int, unsigned int, unsigned int); extern void __stdcall (*buf2d_set_pixel)(buf2d_struct*, unsigned int, unsigned int, unsigned int);
extern unsigned __stdcall (*buf2d_get_pixel)(buf2d_struct *, unsigned int, unsigned int); extern unsigned __stdcall (*buf2d_get_pixel)(buf2d_struct*, unsigned int, unsigned int);
extern void __stdcall (*buf2d_flip_h)(buf2d_struct *); extern void __stdcall (*buf2d_flip_h)(buf2d_struct*);
extern void __stdcall (*buf2d_flip_v)(buf2d_struct *); extern void __stdcall (*buf2d_flip_v)(buf2d_struct*);
extern void __stdcall (*buf2d_filter_dither)(buf2d_struct *, unsigned int); extern void __stdcall (*buf2d_filter_dither)(buf2d_struct*, unsigned int);
#endif /* KOLIBRI_BUF2D_H */ #endif /* KOLIBRI_BUF2D_H */

View File

@ -22,7 +22,7 @@ enum open_dialog_mode {
typedef struct { typedef struct {
unsigned int size; unsigned int size;
unsigned char end; unsigned char end;
}od_filter __attribute__ ((__packed__)); } od_filter __attribute__((__packed__));
typedef struct { typedef struct {
unsigned int mode; unsigned int mode;
@ -41,10 +41,9 @@ typedef struct {
unsigned short x_start; unsigned short x_start;
unsigned short y_size; unsigned short y_size;
unsigned short y_start; unsigned short y_start;
}open_dialog __attribute__ ((__packed__)); } open_dialog __attribute__((__packed__));
typedef struct {
typedef struct{
unsigned int type; unsigned int type;
char* procinfo; char* procinfo;
char* com_area_name; char* com_area_name;
@ -58,70 +57,70 @@ typedef struct{
unsigned short y_start; unsigned short y_start;
unsigned int color_type; unsigned int color_type;
unsigned int color; unsigned int color;
}color_dialog __attribute__ ((__packed__)); } color_dialog __attribute__((__packed__));
void fake_on_redraw(void) {} void fake_on_redraw(void) { }
open_dialog* kolibri_new_open_dialog(unsigned int mode, unsigned short tlx, unsigned short tly, unsigned short x_size, unsigned short y_size) open_dialog* kolibri_new_open_dialog(unsigned int mode, unsigned short tlx, unsigned short tly, unsigned short x_size, unsigned short y_size)
{ {
open_dialog *new_opendialog = (open_dialog *)malloc(sizeof(open_dialog)); open_dialog* new_opendialog = (open_dialog*)malloc(sizeof(open_dialog));
od_filter *new_od_filter = (od_filter *)malloc(sizeof(od_filter)); od_filter* new_od_filter = (od_filter*)malloc(sizeof(od_filter));
char *plugin_path = (char *)calloc(4096, sizeof(char)); char* plugin_path = (char*)calloc(4096, sizeof(char));
char *openfile_path = (char *)calloc(4096, sizeof(char)); char* openfile_path = (char*)calloc(4096, sizeof(char));
char *proc_info = (char *)calloc(1024, sizeof(char)); char* proc_info = (char*)calloc(1024, sizeof(char));
char *filename_area = (char *)calloc(256, sizeof(char)); char* filename_area = (char*)calloc(256, sizeof(char));
new_od_filter -> size = 0; new_od_filter->size = 0;
new_od_filter -> end = 0; new_od_filter->end = 0;
new_opendialog -> mode = mode; new_opendialog->mode = mode;
new_opendialog -> procinfo = proc_info; new_opendialog->procinfo = proc_info;
new_opendialog -> com_area_name = sz_com_area_name; new_opendialog->com_area_name = sz_com_area_name;
new_opendialog -> com_area = 0; new_opendialog->com_area = 0;
new_opendialog -> opendir_path = plugin_path; new_opendialog->opendir_path = plugin_path;
new_opendialog -> dir_default_path = sz_dir_default_path; new_opendialog->dir_default_path = sz_dir_default_path;
new_opendialog -> start_path = sz_start_path; new_opendialog->start_path = sz_start_path;
new_opendialog -> draw_window = &fake_on_redraw; new_opendialog->draw_window = &fake_on_redraw;
new_opendialog -> status = 0; new_opendialog->status = 0;
new_opendialog -> openfile_path = openfile_path; new_opendialog->openfile_path = openfile_path;
new_opendialog -> filename_area = filename_area; new_opendialog->filename_area = filename_area;
new_opendialog -> filter_area = new_od_filter; new_opendialog->filter_area = new_od_filter;
new_opendialog -> x_size = x_size; new_opendialog->x_size = x_size;
new_opendialog -> x_start = tlx; new_opendialog->x_start = tlx;
new_opendialog -> y_size = y_size; new_opendialog->y_size = y_size;
new_opendialog -> y_start = tly; new_opendialog->y_start = tly;
return new_opendialog; return new_opendialog;
} }
void cd_fake_on_redraw(void) {} void cd_fake_on_redraw(void) { }
color_dialog* kolibri_new_color_dialog(unsigned int type, unsigned short tlx, unsigned short tly, unsigned short x_size, unsigned short y_size) color_dialog* kolibri_new_color_dialog(unsigned int type, unsigned short tlx, unsigned short tly, unsigned short x_size, unsigned short y_size)
{ {
color_dialog *new_colordialog = (color_dialog *)malloc(sizeof(color_dialog)); color_dialog* new_colordialog = (color_dialog*)malloc(sizeof(color_dialog));
char *proc_info = (char *)calloc(1024, sizeof(char)); char* proc_info = (char*)calloc(1024, sizeof(char));
new_colordialog -> type = type; new_colordialog->type = type;
new_colordialog -> procinfo = proc_info; new_colordialog->procinfo = proc_info;
new_colordialog -> com_area_name = cd_com_area_name; new_colordialog->com_area_name = cd_com_area_name;
new_colordialog -> com_area = 0; new_colordialog->com_area = 0;
new_colordialog -> start_path = cd_start_path; new_colordialog->start_path = cd_start_path;
new_colordialog -> draw_window = &cd_fake_on_redraw; new_colordialog->draw_window = &cd_fake_on_redraw;
new_colordialog -> status = 0; new_colordialog->status = 0;
new_colordialog -> x_size = x_size; new_colordialog->x_size = x_size;
new_colordialog -> x_start = tlx; new_colordialog->x_start = tlx;
new_colordialog -> y_size = y_size; new_colordialog->y_size = y_size;
new_colordialog -> y_start = tly; new_colordialog->y_start = tly;
new_colordialog -> color_type = 0; new_colordialog->color_type = 0;
new_colordialog -> color = 0; new_colordialog->color = 0;
return new_colordialog; return new_colordialog;
} }
void kolibri_dialog_init(); void kolibri_dialog_init();
extern void __stdcall (*OpenDialog_init)(open_dialog *); extern void __stdcall (*OpenDialog_init)(open_dialog*);
extern void __stdcall (*OpenDialog_start)(open_dialog *); extern void __stdcall (*OpenDialog_start)(open_dialog*);
extern void __stdcall (*ColorDialog_init)(color_dialog *); extern void __stdcall (*ColorDialog_init)(color_dialog*);
extern void __stdcall (*ColorDialog_start)(color_dialog *); extern void __stdcall (*ColorDialog_start)(color_dialog*);
#endif #endif

View File

@ -6,18 +6,18 @@ typedef struct
{ {
int w; int w;
int h; int h;
char *bmp; char* bmp;
char *alpha; char* alpha;
} GB_BMP; } GB_BMP;
#pragma pack(pop) #pragma pack(pop)
void gb_pixel_set(GB_BMP *b, int x, int y, unsigned c); void gb_pixel_set(GB_BMP* b, int x, int y, unsigned c);
int gb_pixel_get(GB_BMP *b, int x, int y, unsigned *c); int gb_pixel_get(GB_BMP* b, int x, int y, unsigned* c);
void gb_line(GB_BMP *b, int x1, int y1, int x2, int y2, unsigned c); void gb_line(GB_BMP* b, int x1, int y1, int x2, int y2, unsigned c);
void gb_rect(GB_BMP *b, int x, int y, int w, int h, unsigned c); void gb_rect(GB_BMP* b, int x, int y, int w, int h, unsigned c);
void gb_bar(GB_BMP *b, int x, int y, int w, int h, unsigned c); void gb_bar(GB_BMP* b, int x, int y, int w, int h, unsigned c);
void gb_circle(GB_BMP *b, int x, int y, int r, unsigned c); void gb_circle(GB_BMP* b, int x, int y, int r, unsigned c);
void gb_image_set(GB_BMP *b_dest, int x_d, int y_d, GB_BMP *b_src, int x_s, int y_s, int w, int h); void gb_image_set(GB_BMP* b_dest, int x_d, int y_d, GB_BMP* b_src, int x_s, int y_s, int w, int h);
void gb_image_set_t(GB_BMP *b_dest, int x_d, int y_d, GB_BMP *b_src, int x_s, int y_s, int w, int h, unsigned c); void gb_image_set_t(GB_BMP* b_dest, int x_d, int y_d, GB_BMP* b_src, int x_s, int y_s, int w, int h, unsigned c);
#endif // KOLIBRI_GB_H #endif // KOLIBRI_GB_H

View File

@ -1,5 +1,4 @@
/* /*
This is adapded thunk for console.obj sys library This is adapded thunk for console.obj sys library
.h is equal to svn:\programs\develop\libraries\console\console_en.txt .h is equal to svn:\programs\develop\libraries\console\console_en.txt
@ -49,7 +48,7 @@ extern int __stdcall _FUNC((*con_getch))(void);
extern word __stdcall _FUNC((*con_getch2))(void); extern word __stdcall _FUNC((*con_getch2))(void);
extern int __stdcall _FUNC((*con_kbhit))(void); extern int __stdcall _FUNC((*con_kbhit))(void);
extern char* __stdcall _FUNC((*con_gets))(char* str, int n); extern char* __stdcall _FUNC((*con_gets))(char* str, int n);
typedef int __stdcall _FUNC(* con_gets2_callback)(int keycode, char** pstr, int* pn, int* ppos); typedef int __stdcall _FUNC (*con_gets2_callback)(int keycode, char** pstr, int* pn, int* ppos);
extern char* __stdcall _FUNC((*con_gets2))(con_gets2_callback callback, char* str, int n); extern char* __stdcall _FUNC((*con_gets2))(con_gets2_callback callback, char* str, int n);
extern void __stdcall _FUNC((*con_cls))(); extern void __stdcall _FUNC((*con_cls))();
extern void __stdcall _FUNC((*con_get_cursor_pos))(int* px, int* py); extern void __stdcall _FUNC((*con_get_cursor_pos))(int* px, int* py);

View File

@ -23,22 +23,22 @@
#ifdef _BUILD_LIBC #ifdef _BUILD_LIBC
extern unsigned short __is[129]; extern unsigned short __is[129];
#else #else
extern unsigned short *__is; extern unsigned short* __is;
#endif #endif
#define isalnum(c)(__is[c+1] & __ALNUM ) /* 'a'-'z', 'A'-'Z', '0'-'9' */ #define isalnum(c) (__is[c + 1] & __ALNUM) /* 'a'-'z', 'A'-'Z', '0'-'9' */
#define isalpha(c)(__is[c+1] & __ALPHA ) /* 'a'-'z', 'A'-'Z' */ #define isalpha(c) (__is[c + 1] & __ALPHA) /* 'a'-'z', 'A'-'Z' */
#define iscntrl(c)(__is[c+1] & __CNTRL ) /* 0-31, 127 */ #define iscntrl(c) (__is[c + 1] & __CNTRL) /* 0-31, 127 */
#define isdigit(c)(__is[c+1] & __DIGIT ) /* '0'-'9' */ #define isdigit(c) (__is[c + 1] & __DIGIT) /* '0'-'9' */
#define isgraph(c)(__is[c+1] & __GRAPH ) /* '!'-'~' */ #define isgraph(c) (__is[c + 1] & __GRAPH) /* '!'-'~' */
#define islower(c)(__is[c+1] & __LOWER ) /* 'a'-'z' */ #define islower(c) (__is[c + 1] & __LOWER) /* 'a'-'z' */
#define isprint(c)(__is[c+1] & __PRINT ) /* ' '-'~' */ #define isprint(c) (__is[c + 1] & __PRINT) /* ' '-'~' */
#define ispunct(c)(__is[c+1] & __PUNCT ) /* !alnum && !cntrl && !space */ #define ispunct(c) (__is[c + 1] & __PUNCT) /* !alnum && !cntrl && !space */
#define isspace(c)(__is[c+1] & __BLANK ) /* HT, LF, VT, FF, CR, ' ' */ #define isspace(c) (__is[c + 1] & __BLANK) /* HT, LF, VT, FF, CR, ' ' */
#define isupper(c)(__is[c+1] & __UPPER ) /* 'A'-'Z' */ #define isupper(c) (__is[c + 1] & __UPPER) /* 'A'-'Z' */
#define isxdigit(c)(__is[c+1] & __XDIGIT) /* '0'-'9', 'a'-'f', 'A'-'F' */ #define isxdigit(c) (__is[c + 1] & __XDIGIT) /* '0'-'9', 'a'-'f', 'A'-'F' */
#define isascii(c) (!((c)&(~0x7f))) #define isascii(c) (!((c) & (~0x7f)))
#define toascii(c) ((c)&0x7f) #define toascii(c) ((c)&0x7f)
extern int _FUNC(tolower)(int c); extern int _FUNC(tolower)(int c);

View File

@ -3,148 +3,58 @@
#include <stddef.h> #include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#ifdef _BUILD_LIBC #ifdef _BUILD_LIBC
extern int _errno; #define errno __errno
#define errno _errno extern int __errno;
#else #else
extern int* _errno; extern int* __errno;
#define errno *_errno #define errno *__errno
#endif #endif
#define EPERM 1 /* Operation not permitted */ #define ENOTSUP 2 // Function is not supported
#define ENOENT 2 /* No such file or directory */ #define EUNKNFS 3 // Unknown file system
#define ESRCH 3 /* No such process */ #define ENOTFOUND 5 // File not found
#define EINTR 4 /* Interrupted system call */ #define EEOF 6 // End of file
#define EIO 5 /* Input/output error */ #define EFAULT 7 // Pointer lies outside of application memory
#define ENXIO 6 /* Device not configured */ #define EDQUOT 8 // Disk is full
#define E2BIG 7 /* Argument list too long */ #define EFS 9 // File system error
#define ENOEXEC 8 /* Exec format error */ #define EACCES 10 // Access denied
#define EBADF 9 /* Bad file descriptor */ #define EDEV 11 // Device error
#define ECHILD 10 /* No child processes */ #define ENOMEMFS 12 // File system requires more memory
#define EDEADLK 11 /* Resource deadlock avoided */
/* 11 was EAGAIN */
#define ENOMEM 12 /* Cannot allocate memory */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Device / Resource busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* Operation not supported by device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* Too many open files in system */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Inappropriate ioctl for device */
#define ETXTBSY 26 /* Text file busy */
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
#define EROFS 30 /* Read-only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
/* math software */ #define ENOMEM 30 // Not enough memory
#define EDOM 33 /* Numerical argument out of domain */ #define ENOEXEC 31 // Is not executable
#define ERANGE 34 /* Result too large */ #define EPROCLIM 32 // Too many processes
#define EINVAL 33 // Invalid argument
/* non-blocking and interrupt i/o */ #define EDOM 50 // Numerical argument out of domain
#define EAGAIN 35 /* Resource temporarily unavailable */ #define ERANGE 51 // Result too large
#define EWOULDBLOCK EAGAIN /* Operation would block */ #define EILSEQ 52 // Illegal byte sequence
#define EINPROGRESS 36 /* Operation now in progress */
#define EALREADY 37 /* Operation already in progress */
/* ipc/network software -- argument errors */ #define ENOBUFS 60 // Broken buffer
#define ENOTSOCK 38 /* Socket operation on non-socket */ #define EINPROGRESS 61 // Operation now in progress
#define EDESTADDRREQ 39 /* Destination address required */ #define EOPNOTSUPP 62 // Operation not supported on transport endpoint
#define EMSGSIZE 40 /* Message too long */ #define EWOULDBLOCK 63 // Operation would block
#define EPROTOTYPE 41 /* Protocol wrong type for socket */ #define ENOTCONN 64 // Transport endpoint is not connected
#define ENOPROTOOPT 42 /* Protocol not available */ #define EALREADY 65 // Operation already in progress
#define EPROTONOSUPPORT 43 /* Protocol not supported */ #define EMSGSIZE 66 // Message too long
#define ESOCKTNOSUPPORT 44 /* Socket type not supported */ #define EADDRINUSE 67 // Address already in use
#define ENOTSUP 45 /* Operation not supported */ #define ECONNREFUSED 68 // Connection refused
#define EOPNOTSUPP ENOTSUP /* Operation not supported on socket */ #define ECONNRESET 69 // Connection reset by peer
#define EPFNOSUPPORT 46 /* Protocol family not supported */ #define EISCONN 70 // Transport endpoint is already connected
#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */ #define ETIMEDOUT 71 // Connection timed out
#define EADDRINUSE 48 /* Address already in use */ #define ECONNABORTED 72 // Software caused connection abort
#define EADDRNOTAVAIL 49 /* Can't assign requested address */
/* ipc/network software -- operational errors */ /*
#define ENETDOWN 50 /* Network is down */ * UNIX-like errno
#define ENETUNREACH 51 /* Network is unreachable */ * Will be removed after changing STDIO.
#define ENETRESET 52 /* Network dropped connection on reset */ */
#define ECONNABORTED 53 /* Software caused connection abort */
#define ECONNRESET 54 /* Connection reset by peer */
#define ENOBUFS 55 /* No buffer space available */
#define EISCONN 56 /* Socket is already connected */
#define ENOTCONN 57 /* Socket is not connected */
#define ESHUTDOWN 58 /* Can't send after socket shutdown */
#define ETOOMANYREFS 59 /* Too many references: can't splice */
#define ETIMEDOUT 60 /* Operation timed out */
#define ECONNREFUSED 61 /* Connection refused */
#define ELOOP 62 /* Too many levels of symbolic links */
#define ENAMETOOLONG 63 /* File name too long */
/* should be rearranged */ #define ENOTDIR 80
#define EHOSTDOWN 64 /* Host is down */ #define EBADF 81
#define EHOSTUNREACH 65 /* No route to host */ #define EIO 82
#define ENOTEMPTY 66 /* Directory not empty */ #define EISDIR 83
#define ENOENT 84
/* quotas & mush */ #define EOVERFLOW 85
#define EPROCLIM 67 /* Too many processes */
#define EUSERS 68 /* Too many users */
#define EDQUOT 69 /* Disc quota exceeded */
/* Network File System */
#define ESTALE 70 /* Stale NFS file handle */
#define EREMOTE 71 /* Too many levels of remote in path */
#define EBADRPC 72 /* RPC struct is bad */
#define ERPCMISMATCH 73 /* RPC version wrong */
#define EPROGUNAVAIL 74 /* RPC prog. not avail */
#define EPROGMISMATCH 75 /* Program version wrong */
#define EPROCUNAVAIL 76 /* Bad procedure for program */
#define ENOLCK 77 /* No locks available */
#define ENOSYS 78 /* Function not implemented */
#define EFTYPE 79 /* Inappropriate file type or format */
#define EAUTH 80 /* Authentication error */
#define ENEEDAUTH 81 /* Need authenticator */
/* Intelligent device errors */
#define EPWROFF 82 /* Device power is off */
#define EDEVERR 83 /* Device error, e.g. paper out */
#define EOVERFLOW 84 /* Value too large to be stored in data type */
/* Program loading errors */
#define EBADEXEC 85 /* Bad executable */
#define EBADARCH 86 /* Bad CPU type in executable */
#define ESHLIBVERS 87 /* Shared library version mismatch */
#define EBADMACHO 88 /* Malformed Macho file */
#define ECANCELED 89 /* Operation canceled */
#define EIDRM 90 /* Identifier removed */
#define ENOMSG 91 /* No message of desired type */
#define EILSEQ 92 /* Illegal byte sequence */
#define ENOATTR 93 /* Attribute not found */
#define EBADMSG 94 /* Bad message */
#define EMULTIHOP 95 /* Reserved */
#define ENODATA 96 /* No message available on STREAM */
#define ENOLINK 97 /* Reserved */
#define ENOSR 98 /* No STREAM resources */
#define ENOSTR 99 /* Not a STREAM */
#define EPROTO 100 /* Protocol error */
#define ETIME 101 /* STREAM ioctl timeout */
#define ENOPOLICY 103 /* No such policy registered */
#define ENOTRECOVERABLE 104 /* State not recoverable */
#define EOWNERDEAD 105 /* Previous owner died */
#define EQFULL 106 /* Interface output queue is full */
#define ELAST 106 /* Must be equal largest errno */
#ifdef __cplusplus
}
#endif
#endif // _ERRNO_H_ #endif // _ERRNO_H_

View File

@ -55,11 +55,11 @@
#endif #endif
#ifndef NAN #ifndef NAN
# define NAN (__nan__) #define NAN (__nan__)
#endif #endif
#ifndef INFINITY #ifndef INFINITY
# define INFINITY (__inf__) #define INFINITY (__inf__)
#endif #endif
#endif /* _FLOAT_H_ */ #endif /* _FLOAT_H_ */

View File

@ -5,9 +5,9 @@
#define CHAR_MAX 127 #define CHAR_MAX 127
#define CHAR_MIN (-128) #define CHAR_MIN (-128)
#define INT_MAX 2147483647 #define INT_MAX 2147483647
#define INT_MIN (-2147483647-1) #define INT_MIN (-2147483647 - 1)
#define LONG_MAX 2147483647L #define LONG_MAX 2147483647L
#define LONG_MIN (-2147483647L-1L) #define LONG_MIN (-2147483647L - 1L)
#define MB_LEN_MAX 5 #define MB_LEN_MAX 5
#define SCHAR_MAX 127 #define SCHAR_MAX 127
#define SCHAR_MIN (-128) #define SCHAR_MIN (-128)
@ -23,7 +23,7 @@
#define WINT_MAX 32767 #define WINT_MAX 32767
#define SSIZE_MAX 2147483647 #define SSIZE_MAX 2147483647
#define LLONG_MIN (-9223372036854775807LL-1LL) #define LLONG_MIN (-9223372036854775807LL - 1LL)
#define LLONG_MAX 9223372036854775807LL #define LLONG_MAX 9223372036854775807LL
#define ULLONG_MAX 18446744073709551615ULL #define ULLONG_MAX 18446744073709551615ULL
@ -32,7 +32,6 @@
#define LONG_LONG_MAX LLONG_MAX #define LONG_LONG_MAX LLONG_MAX
#define ULONG_LONG_MAX ULLONG_MAX #define ULONG_LONG_MAX ULLONG_MAX
#ifndef ARG_MAX #ifndef ARG_MAX
#define ARG_MAX 4096 #define ARG_MAX 4096
#endif #endif

View File

@ -6,10 +6,6 @@
#include <stddef.h> #include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
extern double _FUNC(acos)(double _x); extern double _FUNC(acos)(double _x);
extern double _FUNC(asin)(double _x); extern double _FUNC(asin)(double _x);
extern double _FUNC(atan)(double _x); extern double _FUNC(atan)(double _x);
@ -21,17 +17,24 @@ extern double _FUNC(exp)(double _x);
extern double _FUNC(fabs)(double _x); extern double _FUNC(fabs)(double _x);
extern double _FUNC(floor)(double _x); extern double _FUNC(floor)(double _x);
extern double _FUNC(fmod)(double _x, double _y); extern double _FUNC(fmod)(double _x, double _y);
extern double _FUNC(frexp)(double _x, int *_pexp); extern double _FUNC(frexp)(double _x, int* _pexp);
extern double _FUNC(ldexp)(double _x, int _exp); extern double _FUNC(ldexp)(double _x, int _exp);
extern double _FUNC(log)(double _y); extern double _FUNC(log)(double _y);
extern double _FUNC(log10)(double _x); extern double _FUNC(log10)(double _x);
extern double _FUNC(modf)(double _x, double *_pint); extern double _FUNC(modf)(double _x, double* _pint);
extern double _FUNC(pow)(double _x, double _y); extern double _FUNC(pow)(double _x, double _y);
extern double _FUNC(sin)(double _x); extern double _FUNC(sin)(double _x);
extern double _FUNC(sinh)(double _x); extern double _FUNC(sinh)(double _x);
extern double _FUNC(sqrt)(double _x); extern double _FUNC(sqrt)(double _x);
extern double _FUNC(tan)(double _x); extern double _FUNC(tan)(double _x);
extern double _FUNC(tanh)(double _x); extern double _FUNC(tanh)(double _x);
extern double _FUNC(acosh)(double);
extern double _FUNC(asinh)(double);
extern double _FUNC(atanh)(double);
extern double _FUNC(hypot)(double, double);
extern long double _FUNC(modfl)(long double _x, long double* _pint);
extern double _FUNC(pow10)(double _x);
extern double _FUNC(pow2)(double _x);
#define M_E 2.7182818284590452354 #define M_E 2.7182818284590452354
#define M_LOG2E 1.4426950408889634074 #define M_LOG2E 1.4426950408889634074
@ -49,123 +52,13 @@ extern double _FUNC(tanh)(double _x);
#define PI M_PI #define PI M_PI
#define PI2 M_PI_2 #define PI2 M_PI_2
extern double _FUNC(acosh)(double);
extern double _FUNC(asinh)(double);
extern double _FUNC(atanh)(double);
extern double _FUNC(cbrt)(double);
extern double _FUNC(exp10)(double _x);
extern double _FUNC(exp2)(double _x);
extern double _FUNC(expm1)(double);
extern double _FUNC(hypot)(double, double);
extern double _FUNC(log1p)(double);
extern double _FUNC(log2)(double _x);
extern long double _FUNC(modfl)(long double _x, long double *_pint);
extern double _FUNC(pow10)(double _x);
extern double _FUNC(pow2)(double _x);
extern double _FUNC(powi)(double, int);
extern void _FUNC(sincos)(double, double *, double *);
/* These are in libm.a (Cygnus). You must link -lm to get these */
/* See libm/math.h for comments */
#ifndef __cplusplus
struct exception { struct exception {
int type; int type;
const char *name; const char* name;
double arg1; double arg1;
double arg2; double arg2;
double retval; double retval;
int err; int err;
}; };
#endif
extern double _FUNC(erf)(double);
extern double _FUNC(erfc)(double);
extern double _FUNC(gamma)(double);
extern int _FUNC(isinf)(double);
extern int _FUNC(isnan)(double);
extern int _FUNC(finite)(double);
extern double _FUNC(j0)(double);
extern double _FUNC(j1)(double);
extern double _FUNC(jn)(int, double);
extern double _FUNC(lgamma)(double);
extern double _FUNC(nan)(const char*);
extern double _FUNC(y0)(double);
extern double _FUNC(y1)(double);
extern double _FUNC(yn)(int, double);
extern double _FUNC(logb)(double);
extern double _FUNC(nextafter)(double, double);
extern double _FUNC(remainder)(double, double);
extern double _FUNC(scalb)(double, double);
#ifndef __cplusplus
extern int _FUNC(matherr)(struct exception *);
#endif
extern double _FUNC(significand)(double);
extern double _FUNC(copysign)(double, double);
extern int _FUNC(ilogb)(double);
extern double _FUNC(rint)(double);
extern double _FUNC(scalbn)(double, int);
extern double _FUNC(drem)(double, double);
extern double _FUNC(gamma_r)(double, int *);
extern double _FUNC(lgamma_r)(double, int *);
extern float _FUNC(acosf)(float);
extern float _FUNC(asinf)(float);
extern float _FUNC(atanf)(float);
extern float _FUNC(atan2f)(float, float);
extern float _FUNC(cosf)(float);
extern float _FUNC(sinf)(float);
extern float _FUNC(tanf)(float);
extern float _FUNC(coshf)(float);
extern float _FUNC(sinhf)(float);
extern float _FUNC(tanhf)(float);
extern float _FUNC(expf)(float);
extern float _FUNC(frexpf)(float, int *);
extern float _FUNC(ldexpf)(float, int);
extern float _FUNC(logf)(float);
extern float _FUNC(log10f)(float);
extern float _FUNC(modff)(float, float *);
extern float _FUNC(powf)(float, float);
extern float _FUNC(sqrtf)(float);
extern float _FUNC(ceilf)(float);
extern float _FUNC(fabsf)(float);
extern float _FUNC(floorf)(float);
extern float _FUNC(fmodf)(float, float);
extern float _FUNC(erff)(float);
extern float _FUNC(erfcf)(float);
extern float _FUNC(gammaf)(float);
extern float _FUNC(hypotf)(float, float);
extern int _FUNC(isinff)(float);
extern int _FUNC(isnanf)(float);
extern int _FUNC(finitef)(float);
extern float _FUNC(j0f)(float);
extern float _FUNC(j1f)(float);
extern float _FUNC(jnf)(int, float);
extern float _FUNC(lgammaf)(float);
extern float _FUNC(nanf)(const char*);
extern float _FUNC(y0f)(float);
extern float _FUNC(y1f)(float);
extern float _FUNC(ynf)(int, float);
extern float _FUNC(acoshf)(float);
extern float _FUNC(asinhf)(float);
extern float _FUNC(atanhf)(float);
extern float _FUNC(cbrtf)(float);
extern float _FUNC(logbf)(float);
extern float _FUNC(nextafterf)(float, float);
extern float _FUNC(remainderf)(float, float);
extern float _FUNC(scalbf)(float, float);
extern float _FUNC(significandf)(float);
extern float _FUNC(copysignf)(float, float);
extern int _FUNC(ilogbf)(float);
extern float _FUNC(rintf)(float);
extern float _FUNC(scalbnf)(float, int);
extern float _FUNC(dremf)(float, float);
extern float _FUNC(expm1f)(float);
extern float _FUNC(log1pf)(float);
extern float _FUNC(gammaf_r)(float, int *);
extern float _FUNC(lgammaf_r)(float, int *);
#ifdef __cplusplus
}
#endif
#endif /* _MATH_H_ */ #endif /* _MATH_H_ */

View File

@ -8,7 +8,7 @@ typedef unsigned long __jmp_buf[6];
typedef struct __jmp_buf_tag { typedef struct __jmp_buf_tag {
__jmp_buf __jb; __jmp_buf __jb;
unsigned long __fl; unsigned long __fl;
unsigned long __ss[128/sizeof(long)]; unsigned long __ss[128 / sizeof(long)];
} jmp_buf[1]; } jmp_buf[1];
extern int _FUNC(setjmp)(jmp_buf env); extern int _FUNC(setjmp)(jmp_buf env);

View File

@ -13,25 +13,27 @@
#define SHELL_PID 7 #define SHELL_PID 7
#define SHELL_PING 8 #define SHELL_PING 8
#define SHELL_SHM_MAX 1024*16 #define SHELL_SHM_MAX 1024 * 16
extern char __shell_shm_name[32]; extern char __shell_shm_name[32];
extern char *__shell_shm; extern char* __shell_shm;
extern int __shell_is_init; extern int __shell_is_init;
extern void __shell_init(); extern void __shell_init();
#define __SHELL_WAIT() while (*__shell_shm) _ksys_delay(5) #define __SHELL_WAIT() \
while (*__shell_shm) \
_ksys_delay(5)
extern int shell_ping(); extern int shell_ping();
extern unsigned shell_get_pid(); extern unsigned shell_get_pid();
extern void shell_exit(); extern void shell_exit();
extern char shell_getc(); extern char shell_getc();
extern void shell_gets(char *str, int n); extern void shell_gets(char* str, int n);
extern void shell_putc(char c); extern void shell_putc(char c);
extern void shell_puts(const char *str); extern void shell_puts(const char* str);
extern void shell_printf(const char *format,...); extern void shell_printf(const char* format, ...);
extern void shell_cls(); extern void shell_cls();
#endif #endif

View File

@ -3,73 +3,12 @@
#include <stddef.h> #include <stddef.h>
#ifdef __x86_64__ typedef char* va_list;
#ifndef _WIN64 #define va_start(ap, last) ap = ((char*)&(last)) + ((sizeof(last) + 3) & ~3)
#define va_arg(ap, type) (ap += (sizeof(type) + 3) & ~3, *(type*)(ap - ((sizeof(type) + 3) & ~3)))
//This should be in sync with the declaration on our lib/libtcc1.c
/* GCC compatible definition of va_list. */
typedef struct {
unsigned int gp_offset;
unsigned int fp_offset;
union {
unsigned int overflow_offset;
char *overflow_arg_area;
};
char *reg_save_area;
} __va_list_struct;
typedef __va_list_struct va_list[1];
extern void _FUNC(__va_start)(__va_list_struct *ap, void *fp);
extern void* _FUNC(__va_arg)(__va_list_struct *ap, int arg_type, int size, int align);
#define va_start(ap, last) __va_start(ap, __builtin_frame_address(0))
#define va_arg(ap, type) \
(*(type *)(__va_arg(ap, __builtin_va_arg_types(type), sizeof(type), __alignof__(type))))
#define va_copy(dest, src) (*(dest) = *(src))
#define va_end(ap)
#else /* _WIN64 */
typedef char *va_list;
#define va_start(ap,last) __builtin_va_start(ap,last)
#define va_arg(ap,type) (ap += 8, sizeof(type)<=8 ? *(type*)ap : **(type**)ap)
#define va_copy(dest, src) ((dest) = (src))
#define va_end(ap)
#endif
#elif __arm__
typedef char *va_list;
#define _tcc_alignof(type) ((int)&((struct {char c;type x;} *)0)->x)
#define _tcc_align(addr,type) (((unsigned)addr + _tcc_alignof(type) - 1) \
& ~(_tcc_alignof(type) - 1))
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
#define va_arg(ap,type) (ap = (void *) ((_tcc_align(ap,type)+sizeof(type)+3) \
&~3), *(type *)(ap - ((sizeof(type)+3)&~3)))
#define va_copy(dest, src) (dest) = (src) #define va_copy(dest, src) (dest) = (src)
#define va_end(ap) #define va_end(ap)
#elif defined(__aarch64__)
typedef struct {
void *__stack;
void *__gr_top;
void *__vr_top;
int __gr_offs;
int __vr_offs;
} va_list;
#define va_start(ap, last) __va_start(ap, last)
#define va_arg(ap, type) __va_arg(ap, type)
#define va_end(ap)
#define va_copy(dest, src) ((dest) = (src))
#else /* __i386__ */
typedef char *va_list;
/* only correct for i386 */
#define va_start(ap,last) ap = ((char *)&(last)) + ((sizeof(last)+3)&~3)
#define va_arg(ap,type) (ap += (sizeof(type)+3)&~3, *(type *)(ap - ((sizeof(type)+3)&~3)))
#define va_copy(dest, src) (dest) = (src)
#define va_end(ap)
#endif
/* fix a buggy dependency on GCC in libio.h */ /* fix a buggy dependency on GCC in libio.h */
typedef va_list __gnuc_va_list; typedef va_list __gnuc_va_list;
#define _VA_LIST_DEFINED #define _VA_LIST_DEFINED

View File

@ -8,38 +8,24 @@ typedef __PTRDIFF_TYPE__ ptrdiff_t;
typedef __PTRDIFF_TYPE__ intptr_t; typedef __PTRDIFF_TYPE__ intptr_t;
typedef __SIZE_TYPE__ uintptr_t; typedef __SIZE_TYPE__ uintptr_t;
#ifndef __int8_t_defined
#define __int8_t_defined
typedef signed char int8_t;
typedef signed short int int16_t;
typedef signed int int32_t;
typedef signed long long int int64_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
#endif
#ifndef NULL #ifndef NULL
#define NULL ((void*)0) #define NULL ((void*)0)
#endif #endif
#ifdef _BUILD_LIBC #ifdef _BUILD_LIBC
#define _FUNC(func) func #define _FUNC(func) func
#else #else
#define _FUNC(func) (*func) #define _FUNC(func) (*func)
#endif #endif
#define offsetof(type, field) ((size_t)&((type *)0)->field) #define offsetof(type, field) ((size_t) & ((type*)0)->field)
#ifndef __stdcall #ifndef __stdcall
#define __stdcall __attribute__((stdcall)) #define __stdcall __attribute__((stdcall))
#endif #endif
#ifndef __cdecl #ifndef __cdecl
#define __cdecl __attribute__((cdecl)) #define __cdecl __attribute__((cdecl))
#endif #endif
#endif /* _STDDEF_H_ */ #endif /* _STDDEF_H_ */

View File

@ -11,22 +11,26 @@
#define INT16_MAX (32767) #define INT16_MAX (32767)
#define UINT16_MAX (65535) #define UINT16_MAX (65535)
#define INT32_MIN (-2147483647L-1) #define INT32_MIN (-2147483647L - 1)
#define INT32_MAX (2147483647L) #define INT32_MAX (2147483647L)
#define UINT32_MAX (4294967295UL) #define UINT32_MAX (4294967295UL)
#if __have_long64
#define INT64_MIN (-9223372036854775807L-1L)
#define INT64_MAX (9223372036854775807L)
#define UINT64_MAX (18446744073709551615U)
#elif __have_longlong64
#define INT64_MIN (-9223372036854775807LL-1LL)
#define INT64_MAX (9223372036854775807LL)
#define UINT64_MAX (18446744073709551615ULL)
#else
#define INT64_MAX 0x7fffffffffffffffLL #define INT64_MAX 0x7fffffffffffffffLL
#define INT64_MIN (-INT64_MAX - 1LL) #define INT64_MIN (-INT64_MAX - 1LL)
#define UINT64_MAX (__CONCAT(INT64_MAX, U) * 2ULL + 1ULL) #define UINT64_MAX (__CONCAT(INT64_MAX, U) * 2ULL + 1ULL)
#ifndef __int8_t_defined
#define __int8_t_defined
typedef signed char int8_t;
typedef signed short int int16_t;
typedef signed int int32_t;
typedef signed long long int int64_t;
typedef unsigned char uint8_t;
typedef unsigned short int uint16_t;
typedef unsigned int uint32_t;
typedef unsigned long long int uint64_t;
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
#endif #endif
#define SIZE_MAX UINT32_MAX #define SIZE_MAX UINT32_MAX

View File

@ -35,7 +35,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stddef.h> #include <stddef.h>
extern int _FUNC(puts)(const char *str); extern int _FUNC(puts)(const char* str);
extern int _FUNC(printf)(const char* format, ...); extern int _FUNC(printf)(const char* format, ...);
extern int _FUNC(sprintf)(char* buffer, const char* format, ...); extern int _FUNC(sprintf)(char* buffer, const char* format, ...);
extern int _FUNC(snprintf)(char* buffer, size_t count, const char* format, ...); extern int _FUNC(snprintf)(char* buffer, size_t count, const char* format, ...);
@ -53,7 +53,7 @@ typedef size_t fpos_t;
#define _FILEMODE_PLUS 1 << 3 // Plus #define _FILEMODE_PLUS 1 << 3 // Plus
typedef struct FILE_s { typedef struct FILE_s {
char *name; char* name;
fpos_t position; fpos_t position;
int error; int error;
int eof; int eof;
@ -85,54 +85,54 @@ typedef struct FILE_s {
#define stdin (FILE*)1 #define stdin (FILE*)1
#define stdout (FILE*)2 #define stdout (FILE*)2
extern int _FUNC(fgetc)(FILE *); extern int _FUNC(fgetc)(FILE*);
extern char* _FUNC(fgets)(char *restrict, int, FILE *restrict); extern char* _FUNC(fgets)(char* restrict, int, FILE* restrict);
extern int _FUNC(fprintf)(FILE *restrict, const char *restrict, ...); extern int _FUNC(fprintf)(FILE* restrict, const char* restrict, ...);
extern int _FUNC(fputc)(int, FILE *); extern int _FUNC(fputc)(int, FILE*);
extern int _FUNC(fputs)(const char *restrict, FILE *restrict); extern int _FUNC(fputs)(const char* restrict, FILE* restrict);
extern size_t _FUNC(fread)(void *restrict, size_t size, size_t count, FILE *restrict); extern size_t _FUNC(fread)(void* restrict, size_t size, size_t count, FILE* restrict);
extern int _FUNC(fscanf)(FILE *restrict, const char *restrict, ...); extern int _FUNC(fscanf)(FILE* restrict, const char* restrict, ...);
extern size_t _FUNC(fwrite)(const void *restrict, size_t size, size_t count, FILE *restrict); extern size_t _FUNC(fwrite)(const void* restrict, size_t size, size_t count, FILE* restrict);
extern int _FUNC(getc)(FILE *); extern int _FUNC(getc)(FILE*);
#define getc() _FUNC(fgetc)(stdin) #define getc() _FUNC(fgetc)(stdin)
extern int _FUNC(getchar)(void); extern int _FUNC(getchar)(void);
extern int _FUNC(printf)(const char *restrict, ...); extern int _FUNC(printf)(const char* restrict, ...);
#define putc(ch) _FUNC(fputc)(ch, stdout) #define putc(ch) _FUNC(fputc)(ch, stdout)
extern int _FUNC(puts)(const char *); extern int _FUNC(puts)(const char*);
extern int _FUNC(scanf)(const char *restrict, ...); extern int _FUNC(scanf)(const char* restrict, ...);
extern char* _FUNC(gets)(char *str); extern char* _FUNC(gets)(char* str);
extern int _FUNC(ungetc)(int, FILE *); extern int _FUNC(ungetc)(int, FILE*);
extern int _FUNC(vfprintf)(FILE *restrict, const char *restrict, va_list); extern int _FUNC(vfprintf)(FILE* restrict, const char* restrict, va_list);
extern int _FUNC(vfscanf)(FILE *restrict, const char *restrict, va_list); extern int _FUNC(vfscanf)(FILE* restrict, const char* restrict, va_list);
extern int _FUNC(vprintf)(const char *restrict, va_list); extern int _FUNC(vprintf)(const char* restrict, va_list);
extern int _FUNC(vscanf)(const char *restrict, va_list); extern int _FUNC(vscanf)(const char* restrict, va_list);
extern int _FUNC(sscanf)(const char*, const char *restrict, ...); extern int _FUNC(sscanf)(const char*, const char* restrict, ...);
extern int _FUNC(vsscanf)(const char *, const char*, va_list); extern int _FUNC(vsscanf)(const char*, const char*, va_list);
extern int _FUNC(remove)(const char *); extern int _FUNC(remove)(const char*);
extern int _FUNC(rename)(const char *, const char *); extern int _FUNC(rename)(const char*, const char*);
extern FILE* _FUNC(tmpfile)(void); extern FILE* _FUNC(tmpfile)(void);
extern char* _FUNC(tmpnam)(char *); extern char* _FUNC(tmpnam)(char*);
extern int _FUNC(fclose)(FILE *); extern int _FUNC(fclose)(FILE*);
extern int _FUNC(fflush)(FILE *); extern int _FUNC(fflush)(FILE*);
extern FILE* _FUNC(fopen)(const char *restrict, const char *restrict); extern FILE* _FUNC(fopen)(const char* restrict, const char* restrict);
extern FILE* _FUNC(freopen)(const char *restrict, const char *restrict, FILE *restrict); extern FILE* _FUNC(freopen)(const char* restrict, const char* restrict, FILE* restrict);
extern void _FUNC(setbuf)(FILE *restrict, char *restrict); extern void _FUNC(setbuf)(FILE* restrict, char* restrict);
extern int _FUNC(setvbuf)(FILE *restrict, char *restrict, int, size_t); extern int _FUNC(setvbuf)(FILE* restrict, char* restrict, int, size_t);
extern int _FUNC(fgetpos)(FILE *restrict, fpos_t *restrict); extern int _FUNC(fgetpos)(FILE* restrict, fpos_t* restrict);
extern int _FUNC(fseek)(FILE *, long, int); extern int _FUNC(fseek)(FILE*, long, int);
extern int _FUNC(fsetpos)(FILE *, const fpos_t *); extern int _FUNC(fsetpos)(FILE*, const fpos_t*);
extern long _FUNC(ftell)(FILE *); extern long _FUNC(ftell)(FILE*);
extern void _FUNC(rewind)(FILE *); extern void _FUNC(rewind)(FILE*);
extern void _FUNC(clearerr)(FILE *); extern void _FUNC(clearerr)(FILE*);
extern int _FUNC(feof)(FILE *); extern int _FUNC(feof)(FILE*);
extern int _FUNC(ferror)(FILE *); extern int _FUNC(ferror)(FILE*);
extern void _FUNC(perror)(const char *); extern void _FUNC(perror)(const char*);
extern size_t _FUNC(fread)(void *restrict, size_t, size_t, FILE *restrict); extern size_t _FUNC(fread)(void* restrict, size_t, size_t, FILE* restrict);
extern int _FUNC(getchar)(void); extern int _FUNC(getchar)(void);

View File

@ -5,20 +5,11 @@
#define RAND_MAX 65535 #define RAND_MAX 65535
#ifndef NULL #ifndef NULL
# define NULL ((void*)0) #define NULL ((void*)0)
#endif #endif
#define min(a, b) ((a)<(b) ? (a) : (b)) #define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a)>(b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b))
extern int _FUNC(atoi)(const char *s);
extern long _FUNC(atol)(const char *);
extern long long _FUNC(atoll)(const char *);
extern void _FUNC(itoa)(int n, char* s);
extern int _FUNC(abs)(int);
extern long _FUNC(labs)(long);
extern long long _FUNC(llabs)(long long);
typedef struct { typedef struct {
int quot; int quot;
@ -35,25 +26,25 @@ typedef struct {
long long rem; long long rem;
} lldiv_t; } lldiv_t;
static inline static inline div_t div(int num, int den)
div_t div(int num, int den) { {
return (div_t){ num/den, num%den }; return (div_t) { num / den, num % den };
} }
static inline static inline ldiv_t ldiv(long num, long den)
ldiv_t ldiv(long num, long den) { {
return (ldiv_t){ num/den, num%den }; return (ldiv_t) { num / den, num % den };
} }
static inline static inline lldiv_t lldiv(long long num, long long den)
lldiv_t lldiv(long long num, long long den) { {
return (lldiv_t){ num/den, num%den }; return (lldiv_t) { num / den, num % den };
} }
extern void* _FUNC(malloc)(size_t size); extern void* _FUNC(malloc)(size_t size);
extern void* _FUNC(calloc)(size_t num, size_t size); extern void* _FUNC(calloc)(size_t num, size_t size);
extern void* _FUNC(realloc)(void *ptr, size_t newsize); extern void* _FUNC(realloc)(void* ptr, size_t newsize);
extern void _FUNC(free)(void *ptr); extern void _FUNC(free)(void* ptr);
extern long int _FUNC(strtol)(const char* str, char** endptr, int base); extern long int _FUNC(strtol)(const char* str, char** endptr, int base);
@ -62,10 +53,19 @@ extern void _FUNC(exit)(int status);
extern void _FUNC(srand)(unsigned s); extern void _FUNC(srand)(unsigned s);
extern int _FUNC(rand)(void); extern int _FUNC(rand)(void);
extern void _FUNC(__assert_fail)(const char *expr, const char *file, int line, const char *func); extern void _FUNC(__assert_fail)(const char* expr, const char* file, int line, const char* func);
extern void _FUNC(qsort)(void *base0, size_t n, size_t size, int (*compar)(const void *, const void *)); extern void _FUNC(qsort)(void* base0, size_t n, size_t size, int (*compar)(const void*, const void*));
extern double _FUNC(strtod)(const char *s, char **sret); extern double _FUNC(strtod)(const char* s, char** sret);
extern double _FUNC(atof)(const char *ascii); extern double _FUNC(atof)(const char* ascii);
extern int _FUNC(atoi)(const char* s);
extern long _FUNC(atol)(const char*);
extern long long _FUNC(atoll)(const char*);
extern void _FUNC(itoa)(int n, char* s);
extern int _FUNC(abs)(int);
extern long _FUNC(labs)(long);
extern long long _FUNC(llabs)(long long);
#endif #endif

View File

@ -1,34 +1,9 @@
/* String handling <string.h>
This file is part of the Public Domain C Library (PDCLib).
Permission is granted to use, modify, and / or redistribute at will.
*/
#ifndef _STRING_H_ #ifndef _STRING_H_
#define _STRING_H_ #define _STRING_H_
#include <stddef.h> #include <stddef.h>
#ifdef __cplusplus extern void* _FUNC(memccpy)(void* restrict dest, const void* restrict src, int c, size_t n);
extern "C" {
#endif
/* String function conventions */
/*
In any of the following functions taking a size_t n to specify the length of
an array or size of a memory region, n may be 0, but the pointer arguments to
the call shall still be valid unless otherwise stated.
*/
/* Copying functions */
extern void* _FUNC(memccpy)(void *restrict dest, const void *restrict src, int c, size_t n);
/* Copy a number of n characters from the memory area pointed to by s2 to the
area pointed to by s1. If the two areas overlap, behaviour is undefined.
Returns the value of s1.
*/
#ifdef __TINYC__ #ifdef __TINYC__
extern void* memcpy(void* s1, const void* s2, size_t n); extern void* memcpy(void* s1, const void* s2, size_t n);
@ -40,142 +15,26 @@ extern void* _FUNC(memset)(void* s, int c, size_t n);
extern void* _FUNC(memmove)(void* s1, const void* s2, size_t n); extern void* _FUNC(memmove)(void* s1, const void* s2, size_t n);
#endif #endif
/* Copy the character array s2 (including terminating '\0' byte) into the
character array s1.
Returns the value of s1.
*/
extern char* _FUNC(strcpy)(char* s1, const char* s2); extern char* _FUNC(strcpy)(char* s1, const char* s2);
/* Copy a maximum of n characters from the character array s2 into the character
array s1. If s2 is shorter than n characters, '\0' bytes will be appended to
the copy in s1 until n characters have been written. If s2 is longer than n
characters, NO terminating '\0' will be written to s1. If the arrays overlap,
behaviour is undefined.
Returns the value of s1.
*/
extern char* _FUNC(strncpy)(char* s1, const char* s2, size_t n); extern char* _FUNC(strncpy)(char* s1, const char* s2, size_t n);
/* Concatenation functions */
/* Append the contents of the character array s2 (including terminating '\0') to
the character array s1 (first character of s2 overwriting the '\0' of s1). If
the arrays overlap, behaviour is undefined.
Returns the value of s1.
*/
extern char* _FUNC(strcat)(char* s1, const char* s2); extern char* _FUNC(strcat)(char* s1, const char* s2);
/* Append a maximum of n characters from the character array s2 to the character
array s1 (first character of s2 overwriting the '\0' of s1). A terminating
'\0' is ALWAYS appended, even if the full n characters have already been
written. If the arrays overlap, behaviour is undefined.
Returns the value of s1.
*/
extern char* _FUNC(strncat)(char* s1, const char* s2, size_t n); extern char* _FUNC(strncat)(char* s1, const char* s2, size_t n);
extern int _FUNC(memcmp)(const void* s1, const void* s2, size_t n);
/* Comparison functions */ extern int _FUNC(strcmp)(const char* s1, const char* s2);
/* Compare the first n characters of the memory areas pointed to by s1 and s2.
Returns 0 if s1 == s2, a negative number if s1 < s2, and a positive number if
s1 > s2.
*/
extern int _FUNC(memcmp)(const void * s1, const void* s2, size_t n);
/* Compare the character arrays s1 and s2.
Returns 0 if s1 == s2, a negative number if s1 < s2, and a positive number if
s1 > s2.
*/
extern int _FUNC(strcmp)(const char * s1, const char* s2);
/* Compare the character arrays s1 and s2, interpreted as specified by the
LC_COLLATE category of the current locale.
Returns 0 if s1 == s2, a negative number if s1 < s2, and a positive number if
s1 > s2.
TODO: Currently a dummy wrapper for strcmp() as PDCLib does not yet support
locales.
*/
extern int _FUNC(strcoll)(const char* s1, const char* s2); extern int _FUNC(strcoll)(const char* s1, const char* s2);
/* Compare no more than the first n characters of the character arrays s1 and
s2.
Returns 0 if s1 == s2, a negative number if s1 < s2, and a positive number if
s1 > s2.
*/
extern int _FUNC(strncmp)(const char* s1, const char* s2, size_t n); extern int _FUNC(strncmp)(const char* s1, const char* s2, size_t n);
/* Transform the character array s2 as appropriate for the LC_COLLATE setting of
the current locale. If length of resulting string is less than n, store it in
the character array pointed to by s1. Return the length of the resulting
string.
*/
extern size_t _FUNC(strxfrm)(char* s1, const char* s2, size_t n); extern size_t _FUNC(strxfrm)(char* s1, const char* s2, size_t n);
/* Search functions */
/* Search the first n characters in the memory area pointed to by s for the
character c (interpreted as unsigned char).
Returns a pointer to the first instance found, or NULL.
*/
extern void* _FUNC(memchr)(const void* s, int c, size_t n); extern void* _FUNC(memchr)(const void* s, int c, size_t n);
/* Search the character array s (including terminating '\0') for the character c
(interpreted as char).
Returns a pointer to the first instance found, or NULL.
*/
extern char* _FUNC(strchr)(const char* s, int c); extern char* _FUNC(strchr)(const char* s, int c);
/* Determine the length of the initial substring of character array s1 which
consists only of characters not from the character array s2.
Returns the length of that substring.
*/
extern size_t _FUNC(strcspn)(const char* s1, const char* s2); extern size_t _FUNC(strcspn)(const char* s1, const char* s2);
/* Search the character array s1 for any character from the character array s2.
Returns a pointer to the first occurrence, or NULL.
*/
extern char* _FUNC(strpbrk)(const char* s1, const char* s2); extern char* _FUNC(strpbrk)(const char* s1, const char* s2);
extern char* _FUNC(strrchr)(const char* s, int c);
/* Search the character array s (including terminating '\0') for the character c extern size_t _FUNC(strspn)(const char* s1, const char* s2);
(interpreted as char). extern char* _FUNC(strstr)(const char* s1, const char* s2);
Returns a pointer to the last instance found, or NULL.
*/
extern char* _FUNC(strrchr)(const char * s, int c );
/* Determine the length of the initial substring of character array s1 which
consists only of characters from the character array s2.
Returns the length of that substring.
*/
extern size_t _FUNC(strspn)(const char * s1, const char * s2);
/* Search the character array s1 for the substring in character array s2.
Returns a pointer to that sbstring, or NULL. If s2 is of length zero,
returns s1.
*/
extern char* _FUNC(strstr)(const char * s1, const char * s2);
/* In a series of subsequent calls, parse a C string into tokens.
On the first call to strtok(), the first argument is a pointer to the to-be-
parsed C string. On subsequent calls, the first argument is NULL unless you
want to start parsing a new string. s2 holds an array of separator characters
which can differ from call to call. Leading separators are skipped, the first
trailing separator overwritten with '\0'.
Returns a pointer to the next token.
WARNING: This function uses static storage, and as such is not reentrant.
*/
extern char* _FUNC(strtok)(char* s1, const char* s2); extern char* _FUNC(strtok)(char* s1, const char* s2);
/* Map an error number to a (locale-specific) error message string. Error
numbers are typically errno values, but any number is mapped to a message.
TODO: PDCLib does not yet support locales.
*/
extern char* _FUNC(strerror)(int errnum); extern char* _FUNC(strerror)(int errnum);
extern size_t _FUNC(strlen)(const char* s);
/* Returns the length of the string s (excluding terminating '\0').*/ extern char* _FUNC(strrev)(char* str);
extern size_t _FUNC(strlen)(const char * s); extern char* _FUNC(strdup)(const char* str);
/* The function reverses the sequence of characters in the string pointed to by str. */
extern char* _FUNC(strrev)(char *str);
/* The strdup function executes the function pointed to by the str argument. */
extern char* _FUNC(strdup)(const char *str);
#endif #endif

View File

@ -3,7 +3,7 @@
#include <stddef.h> #include <stddef.h>
extern char* _FUNC(getcwd)(char *buf, unsigned size); extern char* _FUNC(getcwd)(char* buf, unsigned size);
extern void _FUNC(setcwd)(const char* cwd); extern void _FUNC(setcwd)(const char* cwd);
extern int _FUNC(rmdir)(const char* dir); extern int _FUNC(rmdir)(const char* dir);
extern int _FUNC(mkdir)(const char* dir); extern int _FUNC(mkdir)(const char* dir);

View File

@ -3,32 +3,31 @@
#ifndef _DIRENT_H_ #ifndef _DIRENT_H_
#define _DIRENT_H_ #define _DIRENT_H_
#include <stddef.h>
#include <limits.h> #include <limits.h>
#include <stddef.h>
#define IS_FOLDER 16 #define IS_FOLDER 16
#define IS_FILE 0 #define IS_FILE 0
typedef unsigned ino_t; typedef unsigned ino_t;
struct dirent{ struct dirent {
ino_t d_ino; //File serial number. ino_t d_ino; //File serial number.
char d_name[PATH_MAX]; // Name of entry. char d_name[PATH_MAX]; // Name of entry.
unsigned d_type; unsigned d_type;
}; };
typedef struct{ typedef struct {
struct dirent* objs; struct dirent* objs;
ino_t pos; ino_t pos;
ino_t num_objs; ino_t num_objs;
}DIR; } DIR;
extern int _FUNC(closedir)(DIR* dir);
extern int _FUNC(closedir)(DIR *dir); extern DIR* _FUNC(opendir)(const char* path);
extern DIR* _FUNC(opendir)(const char *path); extern struct dirent* _FUNC(readdir)(DIR*);
extern struct dirent* _FUNC(readdir)(DIR *); extern void _FUNC(rewinddir)(DIR* dir);
extern void _FUNC(rewinddir)(DIR *dir); extern void _FUNC(seekdir)(DIR* dir, unsigned pos);
extern void _FUNC(seekdir)(DIR *dir, unsigned pos); extern unsigned _FUNC(telldir)(DIR* dir);
extern unsigned _FUNC(telldir)(DIR *dir);
#endif // _DIRENT_H_ #endif // _DIRENT_H_

File diff suppressed because it is too large Load Diff

View File

@ -3,9 +3,9 @@
#ifndef _SOCKET_H_ #ifndef _SOCKET_H_
#define _SOCKET_H_ #define _SOCKET_H_
#include <errno.h>
#include <stddef.h> #include <stddef.h>
#include <sys/ksys.h> #include <sys/ksys.h>
#include <errno.h>
// Socket Types // Socket Types
#define SOCK_STREAM 1 #define SOCK_STREAM 1
@ -38,13 +38,13 @@
#define AI_SUPPORTED 0x40F #define AI_SUPPORTED 0x40F
// for system function 76 // for system function 76
#define API_ETH (0<<16) #define API_ETH (0 << 16)
#define API_IPv4 (1<<16) #define API_IPv4 (1 << 16)
#define API_ICMP (2<<16) #define API_ICMP (2 << 16)
#define API_UDP (3<<16) #define API_UDP (3 << 16)
#define API_TCP (4<<16) #define API_TCP (4 << 16)
#define API_ARP (5<<16) #define API_ARP (5 << 16)
#define API_PPPOE (6<<16) #define API_PPPOE (6 << 16)
// Socket flags for user calls // Socket flags for user calls
#define MSG_NOFLAG 0 #define MSG_NOFLAG 0
@ -54,38 +54,38 @@
// Socket levels // Socket levels
#define SOL_SOCKET 0xffff #define SOL_SOCKET 0xffff
//Socket options // Socket options
#define SO_BINDTODEVICE (1<<9) #define SO_BINDTODEVICE (1 << 9)
#define SO_NONBLOCK (1<<31) #define SO_NONBLOCK (1 << 31)
#define PORT(X) (X<<8) #define PORT(X) (X << 8)
#pragma pack(push,1) #pragma pack(push, 1)
struct sockaddr{ struct sockaddr {
unsigned short sin_family; unsigned short sin_family;
unsigned short sin_port; unsigned short sin_port;
unsigned int sin_addr; unsigned int sin_addr;
unsigned long long sin_zero; unsigned long long sin_zero;
}; };
typedef struct{ typedef struct {
unsigned int level; unsigned int level;
unsigned int optionname; unsigned int optionname;
unsigned int optlenght; unsigned int optlenght;
unsigned char options; unsigned char options;
}optstruct; } optstruct;
#pragma pack(pop) #pragma pack(pop)
extern int _FUNC(socket)(int domain, int type, int protocol); extern int _FUNC(socket)(int domain, int type, int protocol);
extern int _FUNC(close)(int socket); extern int _FUNC(close)(int socket);
extern int _FUNC(bind)(int socket, const struct sockaddr *addres, int addres_len); extern int _FUNC(bind)(int socket, const struct sockaddr* addres, int addres_len);
extern int _FUNC(listen)(int socket, int backlog); extern int _FUNC(listen)(int socket, int backlog);
extern int _FUNC(connect)(int socket, const struct sockaddr* address, int socket_len); extern int _FUNC(connect)(int socket, const struct sockaddr* address, int socket_len);
extern int _FUNC(accept)(int socket, const struct sockaddr *address, int address_len); extern int _FUNC(accept)(int socket, const struct sockaddr* address, int address_len);
extern int _FUNC(send)(int socket, const void *message, size_t msg_len, int flag); extern int _FUNC(send)(int socket, const void* message, size_t msg_len, int flag);
extern int _FUNC(recv)(int socket, void *buffer, size_t buff_len, int flag); extern int _FUNC(recv)(int socket, void* buffer, size_t buff_len, int flag);
extern int _FUNC(setsockopt)(int socket,const optstruct* opt); extern int _FUNC(setsockopt)(int socket, const optstruct* opt);
extern int _FUNC(getsockopt)(int socket, optstruct* opt); extern int _FUNC(getsockopt)(int socket, optstruct* opt);
extern int _FUNC(socketpair)(int *socket1, int *socket2); extern int _FUNC(socketpair)(int* socket1, int* socket2);
#endif //_SOCKET_H_ #endif //_SOCKET_H_

View File

@ -22,10 +22,10 @@ struct tm {
}; };
#pragma pack(pop) #pragma pack(pop)
extern time_t _FUNC(mktime)(struct tm * timeptr); extern time_t _FUNC(mktime)(struct tm* timeptr);
extern time_t _FUNC(time)(time_t* timer); extern time_t _FUNC(time)(time_t* timer);
extern struct tm * _FUNC(localtime)(const time_t * timer); extern struct tm* _FUNC(localtime)(const time_t* timer);
extern double _FUNC(difftime)(time_t end, time_t beginning); extern double _FUNC(difftime)(time_t end, time_t beginning);
extern char* _FUNC(asctime)(const struct tm *tm); extern char* _FUNC(asctime)(const struct tm* tm);
#endif #endif

View File

@ -1,9 +0,0 @@
format ELF
include '__lib__.inc'
section '.text'
public lib_name
lib_name db 0x55, 0xAA, lib_name_str, 0

View File

@ -1,2 +0,0 @@
lib_name equ @libc.obj
lib_name_str equ '/sys/lib/libc.obj'

View File

@ -1,9 +1,10 @@
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
int a=431; int a = 431;
int b=532; int b = 532;
int main(){ int main()
assert(a!=b); {
assert(a==b); assert(a != b);
assert(a == b);
} }

View File

@ -1,7 +1,7 @@
#include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <stdarg.h>
#include <sys/ksys.h> #include <sys/ksys.h>
ksys_colors_table_t sys_color_table; ksys_colors_table_t sys_color_table;
@ -10,8 +10,7 @@ char statusbar[255];
ksys_thread_t proc_info; ksys_thread_t proc_info;
char text_line[255]; char text_line[255];
enum BUTTONS enum BUTTONS {
{
BTN_QUIT = 1, BTN_QUIT = 1,
BTN_POP = 10, BTN_POP = 10,
BTN_UNLOCK = 11 BTN_UNLOCK = 11
@ -30,28 +29,31 @@ void draw_window()
// define&draw window // define&draw window
_ksys_create_window(10, 40, 600, 400, "My window", sys_color_table.work_area, 0x13); _ksys_create_window(10, 40, 600, 400, "My window", sys_color_table.work_area, 0x13);
_ksys_thread_info(&proc_info, -1); _ksys_thread_info(&proc_info, -1);
F
win_width = proc_info.winx_size; win_width
= proc_info.winx_size;
win_hight = proc_info.winy_size; win_hight = proc_info.winy_size;
_ksys_define_button(10, 30, 70, 20, BTN_POP, sys_color_table.work_button); _ksys_define_button(10, 30, 70, 20, BTN_POP, sys_color_table.work_button);
_ksys_draw_text("BUTTON1", 15, 34, 0, 0x90000000 | sys_color_table.work_button_text); //0x80000000 asciiz _ksys_draw_text("BUTTON1", 15, 34, 0, 0x90000000 | sys_color_table.work_button_text); // 0x80000000 asciiz
_ksys_define_button(100, 30, 80, 20, BTN_UNLOCK, sys_color_table.work_button); _ksys_define_button(100, 30, 80, 20, BTN_UNLOCK, sys_color_table.work_button);
_ksys_draw_text("BUTTTON2", 110, 34, 0, 0x90000000 | sys_color_table.work_button_text); _ksys_draw_text("BUTTTON2", 110, 34, 0, 0x90000000 | sys_color_table.work_button_text);
// display statusbar // display statusbar
_ksys_draw_bar(6, win_hight - 17, win_width - 11, 12, 0x80000000 | sys_color_table.work_area); //0x80000000 gradient _ksys_draw_bar(6, win_hight - 17, win_width - 11, 12, 0x80000000 | sys_color_table.work_area); // 0x80000000 gradient
_ksys_draw_text(statusbar, 10, win_hight - 15, 0, 0x80000000 | sys_color_table.work_text); _ksys_draw_text(statusbar, 10, win_hight - 15, 0, 0x80000000 | sys_color_table.work_text);
// display strings // display strings
for (i = LINES; i > 0; i--){ for (i = LINES; i > 0; i--) {
snprintf (text_line, sizeof text_line, "Line[%d]<<Just a text>>", i); snprintf(text_line, sizeof text_line, "Line[%d]<<Just a text>>", i);
text_line[(win_width - 10 - 5) / FONT_W + 1] = '\0'; // clip text size, seems to big lines crashing OS, and form len by window size text_line[(win_width - 10 - 5) / FONT_W + 1] = '\0'; // clip text size, seems to big lines crashing OS, and form len by window size
_ksys_draw_text(text_line, 5, pos_y, 0, 0x90000000 | sys_color_table.work_text); _ksys_draw_text(text_line, 5, pos_y, 0, 0x90000000 | sys_color_table.work_text);
pos_y += FONT_H; pos_y += FONT_H;
if(pos_y + 29 > win_hight) break; // 12 font + 12 statusbar + 5 border if (pos_y + 29 > win_hight)
break; // 12 font + 12 statusbar + 5 border
} }
// end redraw // end redraw
_ksys_end_draw(); _ksys_end_draw();
@ -67,10 +69,9 @@ int main()
_ksys_get_system_colors(&sys_color_table); _ksys_get_system_colors(&sys_color_table);
_ksys_set_event_mask(0xC0000027); // mouse events only when focused window and mouse inside _ksys_set_event_mask(0xC0000027); // mouse events only when focused window and mouse inside
do{ do {
gui_event = _ksys_get_event(); gui_event = _ksys_get_event();
switch(gui_event) switch (gui_event) {
{
case KSYS_EVENT_NONE: case KSYS_EVENT_NONE:
break; break;
case KSYS_EVENT_REDRAW: case KSYS_EVENT_REDRAW:
@ -80,8 +81,7 @@ int main()
break; break;
case KSYS_EVENT_BUTTON: case KSYS_EVENT_BUTTON:
pressed_button = _ksys_get_button(); pressed_button = _ksys_get_button();
switch (pressed_button) switch (pressed_button) {
{
case BTN_POP: case BTN_POP:
strcpy(statusbar, "POP pressed...."); strcpy(statusbar, "POP pressed....");
draw_window(); draw_window();
@ -99,17 +99,18 @@ int main()
mouse_pos = _ksys_get_mouse_pos(KSYS_MOUSE_WINDOW_POS); // window relative mouse_pos = _ksys_get_mouse_pos(KSYS_MOUSE_WINDOW_POS); // window relative
mouse_button = _ksys_get_mouse_eventstate(); mouse_button = _ksys_get_mouse_eventstate();
debug_printf("mouse ev (%d,%d)%x\n", mouse_pos.x, mouse_pos.y, mouse_button); debug_printf("mouse ev (%d,%d)%x\n", mouse_pos.x, mouse_pos.y, mouse_button);
if (mouse_button & (1<<24)) // double click if (mouse_button & (1 << 24)) // double click
{ {
int n = (mouse_pos.y - 60) / FONT_H; int n = (mouse_pos.y - 60) / FONT_H;
if (n < 0 || n >= LINES) break; if (n < 0 || n >= LINES)
break;
debug_printf("click on str(%d), clip slot(%d)\n", n, LINES - n - 1); debug_printf("click on str(%d), clip slot(%d)\n", n, LINES - n - 1);
sprintf(statusbar, "click on str(%d), clip slot(%d)\n", n, LINES - n - 1); sprintf(statusbar, "click on str(%d), clip slot(%d)\n", n, LINES - n - 1);
draw_window(); draw_window();
} }
break; break;
} }
} while(1) ; /* End of main activity loop */ } while (1); /* End of main activity loop */
return 0; return 0;
} }

View File

@ -1,11 +1,11 @@
// BOXLIB EXAMPLE (scrollbar, progressbar, editbox and checkbox) // BOXLIB EXAMPLE (scrollbar, progressbar, editbox and checkbox)
// Writed by maxcodehack and superturbocat2001 // Writed by maxcodehack and superturbocat2001
#include <sys/ksys.h>
#include <stdlib.h>
#include <string.h>
#include <clayer/boxlib.h> #include <clayer/boxlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ksys.h>
#define WIN_W 640 #define WIN_W 640
#define WIN_H 563 #define WIN_H 563
@ -17,24 +17,25 @@
#define BLACK 0x000000 #define BLACK 0x000000
#define WHITE 0xFFFFFF #define WHITE 0xFFFFFF
#define BLUE 0x0000FF #define BLUE 0x0000FF
#define X_W(X, W) ((X<<16)+W) #define X_W(X, W) ((X << 16) + W)
#define Y_H X_W #define Y_H X_W
uint32_t wheels; uint32_t wheels;
char* title = "Boxlib example"; char* title = "Boxlib example";
char ed_buff[ED_BUFF_LEN]; char ed_buff[ED_BUFF_LEN];
scrollbar scroll = {15, WIN_W - 26, WIN_H - 29, 0, 0, 2, 215, SCROLL_BUTTON_SIZE, 0,0x707070,0xD2CED0,0x555555}; scrollbar scroll = { 15, WIN_W - 26, WIN_H - 29, 0, 0, 2, 215, SCROLL_BUTTON_SIZE, 0, 0x707070, 0xD2CED0, 0x555555 };
progressbar pg = {0, 10, 10, 270, 35, 1, 0, 200, 0xB4B4B4, 0x2728FF, 0xA9A9A9}; progressbar pg = { 0, 10, 10, 270, 35, 1, 0, 200, 0xB4B4B4, 0x2728FF, 0xA9A9A9 };
edit_box ed={WIN_W-140,10,60,0xFFFFFF,0x6a9480,0,0x6a9480, BLACK | TEXT_SIZE, ED_BUFF_LEN, ed_buff,NULL,ed_focus}; edit_box ed = { WIN_W - 140, 10, 60, 0xFFFFFF, 0x6a9480, 0, 0x6a9480, BLACK | TEXT_SIZE, ED_BUFF_LEN, ed_buff, NULL, ed_focus };
check_box output_off={X_W(10, 15), Y_H(120,15), 10, WHITE, BLUE, BLACK | TEXT_SIZE, "Disable duplicate output",0}; check_box output_off = { X_W(10, 15), Y_H(120, 15), 10, WHITE, BLUE, BLACK | TEXT_SIZE, "Disable duplicate output", 0 };
void draw_window(){ void draw_window()
{
_ksys_start_draw(); _ksys_start_draw();
_ksys_create_window(215,100,WIN_W,WIN_H,title, 0x858585, 0x34); _ksys_create_window(215, 100, WIN_W, WIN_H, title, 0x858585, 0x34);
edit_box_draw(&ed); edit_box_draw(&ed);
check_box_draw2(&output_off); check_box_draw2(&output_off);
if(!output_off.flags){ if (!output_off.flags) {
_ksys_draw_text(ed_buff, 10, 90, strlen(ed_buff), BLACK | TEXT_SIZE); _ksys_draw_text(ed_buff, 10, 90, strlen(ed_buff), BLACK | TEXT_SIZE);
} }
scrollbar_v_draw(&scroll); scrollbar_v_draw(&scroll);
@ -45,11 +46,12 @@ void draw_window(){
int main() int main()
{ {
init_checkbox2(&output_off); init_checkbox2(&output_off);
_ksys_set_event_mask(KSYS_EVM_REDRAW + KSYS_EVM_KEY + KSYS_EVM_BUTTON + KSYS_EVM_MOUSE+ KSYS_EVM_MOUSE_FILTER); _ksys_set_event_mask(KSYS_EVM_REDRAW + KSYS_EVM_KEY + KSYS_EVM_BUTTON + KSYS_EVM_MOUSE + KSYS_EVM_MOUSE_FILTER);
while(1){ while (1) {
switch(_ksys_get_event()){ switch (_ksys_get_event()) {
case KSYS_EVENT_BUTTON: case KSYS_EVENT_BUTTON:
if (_ksys_get_button() == 1) return 0; if (_ksys_get_button() == 1)
return 0;
break; break;
case KSYS_EVENT_KEY: case KSYS_EVENT_KEY:
@ -69,16 +71,16 @@ int main()
check_box_mouse2(&output_off); check_box_mouse2(&output_off);
unsigned int scroll_strong = 10; unsigned int scroll_strong = 10;
wheels = _ksys_get_mouse_wheels(); wheels = _ksys_get_mouse_wheels();
if(wheels & 0xFFFF){ if (wheels & 0xFFFF) {
if((short)wheels > 0){ if ((short)wheels > 0) {
scroll.position += scroll_strong; scroll.position += scroll_strong;
if(scroll.position>scroll.max_area-scroll.cur_area){ if (scroll.position > scroll.max_area - scroll.cur_area) {
scroll.position=scroll.max_area-scroll.cur_area; scroll.position = scroll.max_area - scroll.cur_area;
} }
}else if((short)wheels < 0 && scroll.position > 0){ } else if ((short)wheels < 0 && scroll.position > 0) {
scroll.position -= scroll_strong; scroll.position -= scroll_strong;
if((int)scroll.position<0){ if ((int)scroll.position < 0) {
scroll.position=0; scroll.position = 0;
} }
} }
scrollbar_v_draw(&scroll); scrollbar_v_draw(&scroll);

View File

@ -1,28 +1,28 @@
#include <sys/ksys.h>
#include <clayer/dialog.h> #include <clayer/dialog.h>
#include <stdio.h> #include <stdio.h>
#include <sys/ksys.h>
int main() int main()
{ {
open_dialog *dlg_open = kolibri_new_open_dialog(OPEN, 10, 10, 420, 320); // create opendialog struct open_dialog* dlg_open = kolibri_new_open_dialog(OPEN, 10, 10, 420, 320); // create opendialog struct
OpenDialog_init(dlg_open); // Initializing an open dialog box. OpenDialog_init(dlg_open); // Initializing an open dialog box.
OpenDialog_start(dlg_open); // Show open dialog box OpenDialog_start(dlg_open); // Show open dialog box
color_dialog *color_select = kolibri_new_color_dialog(SELECT, 10, 10,420,320); // create colordialog struct color_dialog* color_select = kolibri_new_color_dialog(SELECT, 10, 10, 420, 320); // create colordialog struct
ColorDialog_init(color_select); // Initializing an color dialog box. ColorDialog_init(color_select); // Initializing an color dialog box.
ColorDialog_start(color_select); // Show color dialog ColorDialog_start(color_select); // Show color dialog
if(dlg_open->status == SUCCESS){ if (dlg_open->status == SUCCESS) {
printf("File selected '%s'\n",dlg_open->openfile_path); printf("File selected '%s'\n", dlg_open->openfile_path);
}else{ } else {
puts("No file selected!"); puts("No file selected!");
} }
if(color_select->status == SUCCESS){ if (color_select->status == SUCCESS) {
printf("Color selected: #%06X\n",color_select->color); printf("Color selected: #%06X\n", color_select->color);
rgb_t color_rgb = (rgb_t)color_select->color; rgb_t color_rgb = (rgb_t)color_select->color;
printf("Red:%d Green:%d Blue:%d", color_rgb.red, color_rgb.green, color_rgb.blue); printf("Red:%d Green:%d Blue:%d", color_rgb.red, color_rgb.green, color_rgb.blue);
}else{ } else {
puts("No color selected!"); puts("No color selected!");
} }
free(dlg_open); free(dlg_open);

View File

@ -1,9 +1,9 @@
/* Written by turbocat2001 (Logaev Maxim) */ /* Written by turbocat2001 (Logaev Maxim) */
#include <clayer/libimg.h>
#include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <stddef.h>
#include <clayer/libimg.h>
#include <sys/ksys.h> #include <sys/ksys.h>
#define NEW_IMG_H 128 #define NEW_IMG_H 128
@ -12,12 +12,13 @@
#define IMG_H 256 #define IMG_H 256
#define IMG_W 256 #define IMG_W 256
Image *image_blend; // Create image struct Image* image_blend; // Create image struct
ksys_colors_table_t sys_color_table; // Create system colors table ksys_colors_table_t sys_color_table; // Create system colors table
void* load_img(char* fname, uint32_t* read_sz){ // Image file upload function void* load_img(char* fname, uint32_t* read_sz)
FILE *f = fopen(fname, "rb"); { // Image file upload function
FILE* f = fopen(fname, "rb");
if (!f) { if (!f) {
printf("Can't open file: %s\n", fname); printf("Can't open file: %s\n", fname);
return NULL; return NULL;
@ -29,7 +30,7 @@ void* load_img(char* fname, uint32_t* read_sz){ // Image file upload function
int filesize = ftell(f); int filesize = ftell(f);
rewind(f); rewind(f);
void* fdata = malloc(filesize); void* fdata = malloc(filesize);
if(!fdata) { if (!fdata) {
printf("No memory for file %s\n", fname); printf("No memory for file %s\n", fname);
return NULL; return NULL;
} }
@ -42,20 +43,22 @@ void* load_img(char* fname, uint32_t* read_sz){ // Image file upload function
return fdata; return fdata;
} }
void draw_gui(){ void draw_gui()
{
_ksys_start_draw(); _ksys_start_draw();
_ksys_create_window(10, 40, (IMG_W+NEW_IMG_W)+50, IMG_H+50, "Libimg", sys_color_table.work_area, 0x34); _ksys_create_window(10, 40, (IMG_W + NEW_IMG_W) + 50, IMG_H + 50, "Libimg", sys_color_table.work_area, 0x34);
img_draw(image_blend, 10, 10, IMG_W*2, IMG_H , 0, 0); // Draw blended image to window img_draw(image_blend, 10, 10, IMG_W * 2, IMG_H, 0, 0); // Draw blended image to window
_ksys_end_draw(); _ksys_end_draw();
} }
int main(){ int main()
{
_ksys_get_system_colors(&sys_color_table); // Get system colors theme _ksys_get_system_colors(&sys_color_table); // Get system colors theme
_ksys_set_event_mask(0xC0000027); _ksys_set_event_mask(0xC0000027);
uint32_t img_size; uint32_t img_size;
void *file_data = load_img("logo.png", &img_size); // Get RAW data and size void* file_data = load_img("logo.png", &img_size); // Get RAW data and size
if(!file_data){ if (!file_data) {
return 1; return 1;
} }
@ -69,24 +72,24 @@ int main(){
} }
} }
image_blend = img_create(IMG_W+NEW_IMG_W, IMG_H, IMAGE_BPP32); // Create an empty layer image_blend = img_create(IMG_W + NEW_IMG_W, IMG_H, IMAGE_BPP32); // Create an empty layer
img_fill_color(image_blend, IMG_W+NEW_IMG_W, IMG_H, sys_color_table.work_area); // Fill the layer with one color img_fill_color(image_blend, IMG_W + NEW_IMG_W, IMG_H, sys_color_table.work_area); // Fill the layer with one color
img_blend(image_blend, image, 0, 0, 0, 0, IMG_W, IMG_H); // Blending images to display the alpha channel. img_blend(image_blend, image, 0, 0, 0, 0, IMG_W, IMG_H); // Blending images to display the alpha channel.
/* Reduce image size from 256x256 to 128x128 */ /* Reduce image size from 256x256 to 128x128 */
image = img_scale(image, 0, 0, IMG_W, IMG_H, NULL, LIBIMG_SCALE_STRETCH , LIBIMG_INTER_BILINEAR, NEW_IMG_W, NEW_IMG_H); image = img_scale(image, 0, 0, IMG_W, IMG_H, NULL, LIBIMG_SCALE_STRETCH, LIBIMG_INTER_BILINEAR, NEW_IMG_W, NEW_IMG_H);
img_blend(image_blend, image, 256, 0, 0, 0, NEW_IMG_W, NEW_IMG_H); img_blend(image_blend, image, 256, 0, 0, 0, NEW_IMG_W, NEW_IMG_H);
img_destroy(image); // Destroy image structure img_destroy(image); // Destroy image structure
free(file_data); // Free allocated file_data buffer free(file_data); // Free allocated file_data buffer
/* Main event loop */ /* Main event loop */
while (1) { while (1) {
switch(_ksys_get_event()){ switch (_ksys_get_event()) {
case KSYS_EVENT_REDRAW: case KSYS_EVENT_REDRAW:
draw_gui(); draw_gui();
break; break;
case KSYS_EVENT_BUTTON: case KSYS_EVENT_BUTTON:
if (_ksys_get_button()==1){ if (_ksys_get_button() == 1) {
return 0; return 0;
} }
break; break;

View File

@ -2,7 +2,7 @@
int main() int main()
{ {
msgbox *msg1 = NULL; msgbox* msg1 = NULL;
msg1 = kolibri_new_msgbox("Title", "Text in window", 0, "Ok"); msg1 = kolibri_new_msgbox("Title", "Text in window", 0, "Ok");
kolibri_start_msgbox(msg1, NULL); kolibri_start_msgbox(msg1, NULL);
} }

View File

@ -1,8 +1,7 @@
#include <stdlib.h> #include <clayer/rasterworks.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/ksys.h> #include <sys/ksys.h>
#include <clayer/rasterworks.h>
// Sizes // Sizes
int x_size = 768, y_size = 256; int x_size = 768, y_size = 256;
@ -16,11 +15,11 @@ int main()
int ln_str = countUTF8Z(string, -1); int ln_str = countUTF8Z(string, -1);
// Create image buffer // Create image buffer
void *buffi = malloc(x_size * y_size * 3 * sizeof(char) + 8); void* buffi = malloc(x_size * y_size * 3 * sizeof(char) + 8);
// Set sizes // Set sizes
*((int*)buffi) = x_size; *((int*)buffi) = x_size;
*((int*)buffi+1) = y_size; *((int*)buffi + 1) = y_size;
// Fill color // Fill color
memset((char*)buffi + 8, 0xFF, x_size * y_size * 3); memset((char*)buffi + 8, 0xFF, x_size * y_size * 3);
@ -34,7 +33,7 @@ int main()
drawText(buffi, 5, 160, string, ln_str, 0xFF000000, 0x0F031428); drawText(buffi, 5, 160, string, ln_str, 0xFF000000, 0x0F031428);
while (1) { while (1) {
switch (_ksys_get_event()){ switch (_ksys_get_event()) {
case KSYS_EVENT_REDRAW: case KSYS_EVENT_REDRAW:
_ksys_start_draw(); _ksys_start_draw();
_ksys_create_window(50, 50, 800, 300, "Rasterworks Example", 0x999999, 0x34); _ksys_create_window(50, 50, 800, 300, "Rasterworks Example", 0x999999, 0x34);
@ -43,7 +42,8 @@ int main()
break; break;
case KSYS_EVENT_BUTTON: case KSYS_EVENT_BUTTON:
if(_ksys_get_button() == 1) exit(0); if (_ksys_get_button() == 1)
exit(0);
break; break;
}; };
} }

View File

@ -5,12 +5,13 @@
int main() int main()
{ {
if(con_init()) return 1; // init fail if (con_init())
(*con_set_title)("Console colors"); return 1; // init fail
(*con_set_tsitle)("Console colors");
// con_write_asciiz("\033[0;31;42m test \n"); // red on green bk // con_write_asciiz("\033[0;31;42m test \n"); // red on green bk
for(int i = 30; i < 48; i++){ for (int i = 30; i < 48; i++) {
(*con_printf)("\033[%dmColor 0x%02X: ", i, i); (*con_printf)("\033[%dmColor 0x%02X: ", i, i);
(*con_write_asciiz)("Text sample."); (*con_write_asciiz)("Text sample.");
(*con_printf)(" printf %s test %d\n", "small", i); (*con_printf)(" printf %s test %d\n", "small", i);

View File

@ -1,7 +1,7 @@
#include "stddef.h" #include <libgen.h>
#include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <libgen.h>
#include <string.h> #include <string.h>
#include <sys/ksys.h> #include <sys/ksys.h>
@ -12,26 +12,28 @@ enum ARGV_FILE {
OUT = 2 OUT = 2
}; };
void show_help(void){ void show_help(void)
{
puts("Usage: defgen [lib.obj] [lib.def]"); puts("Usage: defgen [lib.obj] [lib.def]");
} }
int main(int argc, char** argv){ int main(int argc, char** argv)
{
if(argc!=ARGC_VALID){ if (argc != ARGC_VALID) {
show_help(); show_help();
return 0; return 0;
} }
ksys_dll_t *obj_dll = _ksys_dlopen(argv[IN]); ksys_dll_t* obj_dll = _ksys_dlopen(argv[IN]);
FILE* outfile = fopen(argv[OUT], "w"); FILE* outfile = fopen(argv[OUT], "w");
if(!obj_dll){ if (!obj_dll) {
printf("File '%s' not found!\n", argv[IN]); printf("File '%s' not found!\n", argv[IN]);
return 1; return 1;
} }
if(!outfile){ if (!outfile) {
printf("Unable to create file:'%s'!\n", argv[OUT]); printf("Unable to create file:'%s'!\n", argv[OUT]);
return 2; return 2;
} }
@ -39,9 +41,9 @@ int main(int argc, char** argv){
fprintf(outfile, "LIBRARY %s\n\n", basename(argv[IN])); fprintf(outfile, "LIBRARY %s\n\n", basename(argv[IN]));
fputs("EXPORTS\n", outfile); fputs("EXPORTS\n", outfile);
int i=0; int i = 0;
while(obj_dll[i].func_name){ while (obj_dll[i].func_name) {
fprintf(outfile,"%s\n", obj_dll[i].func_name); fprintf(outfile, "%s\n", obj_dll[i].func_name);
i++; i++;
} }
fclose(outfile); fclose(outfile);

View File

@ -1,45 +1,44 @@
#include <sys/dirent.h> #include <conio.h>
#include <sys/dir.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <conio.h> #include <sys/dir.h>
#include <sys/dirent.h>
const char *folder_type = "Folder"; const char* folder_type = "Folder";
const char *file_type = "File"; const char* file_type = "File";
int main() int main()
{ {
char *path=getcwd(NULL, PATH_MAX); char* path = getcwd(NULL, PATH_MAX);
printf("Current directory: %s\n", path); printf("Current directory: %s\n", path);
if(mkdir("test")){ if (mkdir("test")) {
puts("Test folder created!"); puts("Test folder created!");
} } else {
else{
puts("Error creating folder!"); puts("Error creating folder!");
} }
DIR *mydir = opendir(path); DIR* mydir = opendir(path);
if(!mydir){ if (!mydir) {
puts("File system error."); puts("File system error.");
return -1; return -1;
} }
struct dirent *file_info; struct dirent* file_info;
char *str_type=NULL; char* str_type = NULL;
putc(' '); putc(' ');
while((file_info = readdir(mydir))!=NULL){ while ((file_info = readdir(mydir)) != NULL) {
if(file_info->d_type==IS_FOLDER){ if (file_info->d_type == IS_FOLDER) {
(*con_set_flags)(CON_COLOR_GREEN); (*con_set_flags)(CON_COLOR_GREEN);
str_type = (char*)folder_type; str_type = (char*)folder_type;
}else { } else {
(*con_set_flags)(7); (*con_set_flags)(7);
str_type = (char*)file_type; str_type = (char*)file_type;
} }
printf("%3d %20s %s\n ", file_info->d_ino ,file_info->d_name, str_type); printf("%3d %20s %s\n ", file_info->d_ino, file_info->d_name, str_type);
}; };
setcwd("/sys/develop"); setcwd("/sys/develop");
path=getcwd(NULL, PATH_MAX); path = getcwd(NULL, PATH_MAX);
printf("Move to the directory: %s\n", path); printf("Move to the directory: %s\n", path);
free(path); free(path);
} }

View File

@ -1,49 +1,49 @@
#include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <errno.h>
#define READ_MAX 255 #define READ_MAX 255
static char test_str1[] = "123454567890abcdefghijklmnopqrstufvwxyz"; static char test_str1[] = "123454567890abcdefghijklmnopqrstufvwxyz";
static char test_str2[READ_MAX]; static char test_str2[READ_MAX];
int main(int argc, char **argv) int main(int argc, char** argv)
{ {
int i=0; int i = 0;
FILE *f; FILE* f;
//write to file // write to file
debug_printf("Write file...\n"); debug_printf("Write file...\n");
f=fopen("testfile.txt","w"); f = fopen("testfile.txt", "w");
while(test_str1[i]!='a'){ while (test_str1[i] != 'a') {
fputc(test_str1[i],f); fputc(test_str1[i], f);
i++; i++;
} }
fclose(f); fclose(f);
//append to file // append to file
debug_printf("Apend file...\n"); debug_printf("Apend file...\n");
f=fopen("testfile.txt","a"); f = fopen("testfile.txt", "a");
fputs(test_str1+i,f); fputs(test_str1 + i, f);
char null_term = '\0'; char null_term = '\0';
fwrite(&null_term, sizeof(char), 1, f); fwrite(&null_term, sizeof(char), 1, f);
printf("Error: %s\n",strerror(errno)); printf("Error: %s\n", strerror(errno));
fclose(f); fclose(f);
//copy from testfile.txt to copyfile.txt // copy from testfile.txt to copyfile.txt
debug_printf("Read file...\n"); debug_printf("Read file...\n");
f=fopen("testfile.txt","r"); f = fopen("testfile.txt", "r");
i=0; i = 0;
while((test_str2[i]=fgetc(f))!=EOF && i<READ_MAX){ while ((test_str2[i] = fgetc(f)) != EOF && i < READ_MAX) {
fputc(test_str2[i], stdout); fputc(test_str2[i], stdout);
i++; i++;
} }
printf("\n%s\n", test_str1); printf("\n%s\n", test_str1);
if(!strcmp(test_str2, test_str1)){ if (!strcmp(test_str2, test_str1)) {
puts("TEST: OK!"); puts("TEST: OK!");
}else{ } else {
puts("TEST: FAIL!"); puts("TEST: FAIL!");
} }
fclose(f); fclose(f);

View File

@ -1,14 +1,16 @@
#include <clayer/network.h> #include <clayer/network.h>
#include <string.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
int main() { int main()
char *host = "kolibrios.org"; {
char* host = "kolibrios.org";
int port = 80; int port = 80;
printf("Connecting to %s on port %d\n", host, port); printf("Connecting to %s on port %d\n", host, port);
struct addrinfo *addr_info; struct addrinfo* addr_info;
char port_str[16]; sprintf(port_str, "%d", port); char port_str[16];
sprintf(port_str, "%d", port);
struct addrinfo hints; struct addrinfo hints;
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC; // IPv4 or IPv6 doesnt matter hints.ai_family = AF_UNSPEC; // IPv4 or IPv6 doesnt matter
@ -19,7 +21,7 @@ int main() {
exit(-1); exit(-1);
} }
printf("IP address of %s is %s\n", host, inet_ntoa(addr_info->ai_addr->sin_addr)); printf("IP address of %s is %s\n", host, inet_ntoa(addr_info->ai_addr->sin_addr));
//printf("Host port = %d\n", addr_info->ai_addr->sin_port >> 8); // printf("Host port = %d\n", addr_info->ai_addr->sin_port >> 8);
char request[256]; char request[256];
sprintf(request, "GET /en/ HTTP/1.1\r\nHost: %s\r\n\r\n", host); sprintf(request, "GET /en/ HTTP/1.1\r\nHost: %s\r\n\r\n", host);

View File

@ -1,15 +1,17 @@
#include <sys/ksys.h>
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/ksys.h>
#include <time.h> #include <time.h>
int comp(void *a, void *b) { int comp(void* a, void* b)
{
return *(int*)a - *(int*)b; return *(int*)a - *(int*)b;
} }
int main(){ int main()
{
puts("Start testing."); puts("Start testing.");
assert(NULL == ((void*)0)); assert(NULL == ((void*)0));
assert(RAND_MAX == 65535); assert(RAND_MAX == 65535);
@ -45,11 +47,11 @@ int main(){
assert(output3.quot == 6); assert(output3.quot == 6);
assert(output3.rem == 3); assert(output3.rem == 3);
char *st2 = malloc(sizeof(char)*2); char* st2 = malloc(sizeof(char) * 2);
assert(st2 != NULL); assert(st2 != NULL);
st2[0] = 'H'; st2[0] = 'H';
st2[1] = 'i'; st2[1] = 'i';
st2 = realloc(st2, sizeof(char)*3); st2 = realloc(st2, sizeof(char) * 3);
st2[2] = '!'; st2[2] = '!';
assert(!strcmp(st2, "Hi!")); assert(!strcmp(st2, "Hi!"));
free(st2); free(st2);
@ -61,8 +63,8 @@ int main(){
assert(!strcmp(st2, "Hi")); assert(!strcmp(st2, "Hi"));
free(st2); free(st2);
char *start = "100.00 Rub"; char* start = "100.00 Rub";
char *end; char* end;
assert(strtol(start, &end, 10) == 100L); assert(strtol(start, &end, 10) == 100L);
assert(!strcmp(end, ".00 Rub")); assert(!strcmp(end, ".00 Rub"));
@ -70,17 +72,17 @@ int main(){
assert(strtod(start, &end) == 100.0); assert(strtod(start, &end) == 100.0);
assert(!strcmp(end, " Rub")); assert(!strcmp(end, " Rub"));
char *st3 = "21.3e3Hello World!"; char* st3 = "21.3e3Hello World!";
assert(atof(st3) == 21300.0); assert(atof(st3) == 21300.0);
int nums[10] = {5, 3, 9, 1, 8, 4, 2, 0, 7, 6}; int nums[10] = { 5, 3, 9, 1, 8, 4, 2, 0, 7, 6 };
qsort(nums, 10, sizeof(int), (int(*) (const void *, const void *))comp); qsort(nums, 10, sizeof(int), (int (*)(const void*, const void*))comp);
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
assert(nums[i] == i); assert(nums[i] == i);
} }
time_t libc_time = time(NULL); time_t libc_time = time(NULL);
struct tm *libc_tm = localtime(&libc_time); struct tm* libc_tm = localtime(&libc_time);
printf(asctime(libc_tm)); printf(asctime(libc_tm));
puts("End testing."); puts("End testing.");

View File

@ -1,43 +1,41 @@
#include <stdio.h>
#include <math.h> #include <math.h>
#include <stdio.h>
int main() int main()
{ {
int i; int i;
for (i = 0; i < 20; i++) for (i = 0; i < 20; i++) {
{
printf("------------------------------------------------------\n"); printf("------------------------------------------------------\n");
// printf ( "remainder of 5.3 / 2 is %f\n", remainder (5.3,2) ); // printf ( "remainder of 5.3 / 2 is %f\n", remainder (5.3,2) );
// printf ( "remainder of 18.5 / 4.2 is %f\n", remainder (18.5,4.2) ); // printf ( "remainder of 18.5 / 4.2 is %f\n", remainder (18.5,4.2) );
//remainder of 5.3 / 2 is -0.700000 // remainder of 5.3 / 2 is -0.700000
//remainder of 18.5 / 4.2 is 1.700000 // remainder of 18.5 / 4.2 is 1.700000
printf ( "fmod of 5.3 / 2 is %f\n", fmod (5.3,2) ); printf("fmod of 5.3 / 2 is %f\n", fmod(5.3, 2));
printf ( "fmod of 18.5 / 4.2 is %f\n", fmod (18.5,4.2) ); printf("fmod of 18.5 / 4.2 is %f\n", fmod(18.5, 4.2));
// fmod of 5.3 / 2 is 1.300000 // fmod of 5.3 / 2 is 1.300000
// fmod of 18.5 / 4.2 is 1.700000 // fmod of 18.5 / 4.2 is 1.700000
double param, fractpart, intpart, result; double param, fractpart, intpart, result;
int n; int n;
param = 3.14159265; param = 3.14159265;
fractpart = modf (param , &intpart); fractpart = modf(param, &intpart);
printf ("%f = %f + %f \n", param, intpart, fractpart); printf("%f = %f + %f \n", param, intpart, fractpart);
//3.141593 = 3.000000 + 0.141593 // 3.141593 = 3.000000 + 0.141593
param = 0.95; param = 0.95;
n = 4; n = 4;
result = ldexp (param , n); result = ldexp(param, n);
printf ("%f * 2^%d = %f\n", param, n, result); printf("%f * 2^%d = %f\n", param, n, result);
//0.950000 * 2^4 = 15.200000 // 0.950000 * 2^4 = 15.200000
param = 8.0; param = 8.0;
result = frexp (param , &n); result = frexp(param, &n);
printf ("%f = %f * 2^%d\n", param, result, n); printf("%f = %f * 2^%d\n", param, result, n);
//8.000000 = 0.500000 * 2^4 // 8.000000 = 0.500000 * 2^4
param = 50; param = 50;
result = frexp (param , &n); result = frexp(param, &n);
printf ("%f = %f * 2^%d\n", param, result, n); printf("%f = %f * 2^%d\n", param, result, n);
} }
} }

View File

@ -1,22 +1,23 @@
/* /*
* This is an example program for sending a message through a "pipe". * This is an example program for sending a message through a "pipe".
* Created by turbocat (Maxim Logaev) 2022. * Created by turbocat (Maxim Logaev) 2022.
*/ */
#include <sys/ksys.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <assert.h>
#include <string.h> #include <string.h>
#include <sys/ksys.h>
#define TH_STACK_SIZE 1024 #define TH_STACK_SIZE 1024
#define MESSAGE_SIZE 12 #define MESSAGE_SIZE 12
ksys_colors_table_t sys_colors; ksys_colors_table_t sys_colors;
int pipefd[2]; int pipefd[2];
char *send_message = "HELLO PIPE!"; char* send_message = "HELLO PIPE!";
void tmain() { void tmain()
{
char recv_message[MESSAGE_SIZE]; char recv_message[MESSAGE_SIZE];
_ksys_posix_read(pipefd[0], recv_message, MESSAGE_SIZE); _ksys_posix_read(pipefd[0], recv_message, MESSAGE_SIZE);
printf("RECV: %s\n", recv_message); printf("RECV: %s\n", recv_message);
@ -25,14 +26,15 @@ void tmain() {
exit(0); exit(0);
} }
void create_thread(void){ void create_thread(void)
{
unsigned tid; // New thread ID unsigned tid; // New thread ID
void *th_stack = malloc(TH_STACK_SIZE); // Allocate memory for thread stack void* th_stack = malloc(TH_STACK_SIZE); // Allocate memory for thread stack
if (!th_stack) { if (!th_stack) {
puts("Memory allocation error for thread!"); puts("Memory allocation error for thread!");
return; return;
} }
tid = _ksys_create_thread(tmain, th_stack+TH_STACK_SIZE); // Create new thread with entry "main" tid = _ksys_create_thread(tmain, th_stack + TH_STACK_SIZE); // Create new thread with entry "main"
if (tid == -1) { if (tid == -1) {
puts("Unable to create a new thread!"); puts("Unable to create a new thread!");
return; return;
@ -40,7 +42,8 @@ void create_thread(void){
printf("New thread created (TID=%u)\n", tid); printf("New thread created (TID=%u)\n", tid);
} }
void main() { void main()
{
if (_ksys_posix_pipe2(pipefd, 0)) { if (_ksys_posix_pipe2(pipefd, 0)) {
puts("Pipe creation error!"); puts("Pipe creation error!");
return; return;

View File

@ -6,64 +6,58 @@
#define BPP 4 #define BPP 4
#define DEPTH 32 #define DEPTH 32
void setpixel(SDL_Surface *screen, int x, int y, Uint8 r, Uint8 g, Uint8 b) void setpixel(SDL_Surface* screen, int x, int y, Uint8 r, Uint8 g, Uint8 b)
{ {
Uint32 *pixmem32; Uint32* pixmem32;
Uint32 colour; Uint32 colour;
colour = SDL_MapRGB( screen->format, r, g, b ); colour = SDL_MapRGB(screen->format, r, g, b);
pixmem32 = (Uint32*) screen->pixels + y + x; pixmem32 = (Uint32*)screen->pixels + y + x;
*pixmem32 = colour; *pixmem32 = colour;
} }
void DrawScreen(SDL_Surface* screen, int h) void DrawScreen(SDL_Surface* screen, int h)
{ {
int x, y, ytimesw; int x, y, ytimesw;
if(SDL_MUSTLOCK(screen)) if (SDL_MUSTLOCK(screen)) {
{ if (SDL_LockSurface(screen) < 0)
if(SDL_LockSurface(screen) < 0) return; return;
} }
for(y = 0; y < screen->h; y++ ) for (y = 0; y < screen->h; y++) {
{ ytimesw = y * screen->pitch / BPP;
ytimesw = y*screen->pitch/BPP; for (x = 0; x < screen->w; x++) {
for( x = 0; x < screen->w; x++ ) setpixel(screen, x, ytimesw, (x * x) / 256 + 3 * y + h, (y * y) / 256 + x + h, h);
{
setpixel(screen, x, ytimesw, (x*x)/256+3*y+h, (y*y)/256+x+h, h);
} }
} }
if(SDL_MUSTLOCK(screen)) SDL_UnlockSurface(screen); if (SDL_MUSTLOCK(screen))
SDL_UnlockSurface(screen);
SDL_Flip(screen); SDL_Flip(screen);
} }
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
SDL_Surface *screen; SDL_Surface* screen;
SDL_Event event; SDL_Event event;
int keypress = 0; int keypress = 0;
int h=0; int h = 0;
if (SDL_Init(SDL_INIT_VIDEO) < 0 ) return 1; if (SDL_Init(SDL_INIT_VIDEO) < 0)
return 1;
if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_FULLSCREEN|SDL_HWSURFACE))) if (!(screen = SDL_SetVideoMode(WIDTH, HEIGHT, DEPTH, SDL_FULLSCREEN | SDL_HWSURFACE))) {
{
SDL_Quit(); SDL_Quit();
return 1; return 1;
} }
while(!keypress) while (!keypress) {
{ DrawScreen(screen, h++);
DrawScreen(screen,h++); while (SDL_PollEvent(&event)) {
while(SDL_PollEvent(&event)) switch (event.type) {
{
switch (event.type)
{
case SDL_QUIT: case SDL_QUIT:
keypress = 1; keypress = 1;
break; break;

View File

@ -1,8 +1,9 @@
#include "../include/shell_api.h" #include "../include/shell_api.h"
char string[256]; char string[256];
int main(){ int main()
{
shell_cls(); shell_cls();
shell_printf("SHELL PID=%d\n\r", shell_get_pid()); shell_printf("SHELL PID=%d\n\r", shell_get_pid());

View File

@ -1,12 +1,13 @@
#include <sys/ksys.h>
#include <stdio.h>
#include <limits.h> #include <limits.h>
#include <stdio.h>
#include <sys/ksys.h>
char* test_string1 = "Hello world!"; char* test_string1 = "Hello world!";
int a, b; int a, b;
int main(int argc, char** argv){ int main(int argc, char** argv)
sscanf("43 53","%d %d",&a, &b); {
sscanf("43 53", "%d %d", &a, &b);
printf("(43 53) = (%d %d)\n", a, b); printf("(43 53) = (%d %d)\n", a, b);
printf("Hello world! = %s\n", test_string1); printf("Hello world! = %s\n", test_string1);
printf("345.358980 = %f\n", 345.35898); printf("345.358980 = %f\n", 345.35898);

View File

@ -1,17 +1,18 @@
#include <ctype.h>
#include <errno.h> #include <errno.h>
#include <sys/ksys.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <ctype.h> #include <sys/ksys.h>
int main(int argc, char** argv){ int main(int argc, char** argv)
char hello1[]="Hello, KolibriOS!"; {
char hello1[] = "Hello, KolibriOS!";
char hello2[20]; char hello2[20];
memcpy(hello1, hello2, strlen(hello1)); memcpy(hello1, hello2, strlen(hello1));
if(!__strcmp(hello1, hello2)){ if (!__strcmp(hello1, hello2)) {
printf("memcpy: Successfully!\n"); printf("memcpy: Successfully!\n");
return 0; return 0;
} else{ } else {
printf("memcpy: Failure\n"); printf("memcpy: Failure\n");
return -1; return -1;
} }

View File

@ -3,15 +3,15 @@
* Built on top of the /programs/develop/examples/thread/trunk/thread.asm example. * Built on top of the /programs/develop/examples/thread/trunk/thread.asm example.
* *
* Created by turbocat (Maxim Logaev) 2021. * Created by turbocat (Maxim Logaev) 2021.
*/ */
#include <sys/ksys.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/ksys.h>
#define TH_STACK_SIZE 1024 #define TH_STACK_SIZE 1024
enum BUTTONS{ enum BUTTONS {
BTN_QUIT = 1, BTN_QUIT = 1,
BTN_CREATE_TH = 2, BTN_CREATE_TH = 2,
}; };
@ -20,7 +20,8 @@ ksys_colors_table_t sys_colors;
extern int main(); extern int main();
void redraw_window(void){ void redraw_window(void)
{
ksys_pos_t mouse_pos = _ksys_get_mouse_pos(KSYS_MOUSE_SCREEN_POS); ksys_pos_t mouse_pos = _ksys_get_mouse_pos(KSYS_MOUSE_SCREEN_POS);
_ksys_start_draw(); _ksys_start_draw();
_ksys_create_window(mouse_pos.x, mouse_pos.y, 140, 60, "Threads", sys_colors.work_area, 0x14); _ksys_create_window(mouse_pos.x, mouse_pos.y, 140, 60, "Threads", sys_colors.work_area, 0x14);
@ -29,34 +30,36 @@ void redraw_window(void){
_ksys_end_draw(); _ksys_end_draw();
} }
void create_thread(void){ void create_thread(void)
{
unsigned tid; // New thread ID unsigned tid; // New thread ID
void *th_stack = malloc(TH_STACK_SIZE); // Allocate memory for thread stack void* th_stack = malloc(TH_STACK_SIZE); // Allocate memory for thread stack
if(!th_stack){ if (!th_stack) {
_ksys_debug_puts("Memory allocation error for thread!"); _ksys_debug_puts("Memory allocation error for thread!");
return; return;
} }
tid = _ksys_create_thread(main, th_stack+TH_STACK_SIZE); // Create new thread with entry "main" tid = _ksys_create_thread(main, th_stack + TH_STACK_SIZE); // Create new thread with entry "main"
if(tid==-1){ if (tid == -1) {
_ksys_debug_puts("Unable to create a new thread!"); _ksys_debug_puts("Unable to create a new thread!");
return; return;
} }
debug_printf("New thread created (TID=%u)\n", tid); debug_printf("New thread created (TID=%u)\n", tid);
} }
int main(){ int main()
{
_ksys_get_system_colors(&sys_colors); _ksys_get_system_colors(&sys_colors);
int gui_event; int gui_event;
redraw_window(); redraw_window();
while(1){ while (1) {
gui_event = _ksys_get_event(); gui_event = _ksys_get_event();
switch(gui_event){ switch (gui_event) {
case KSYS_EVENT_REDRAW: case KSYS_EVENT_REDRAW:
redraw_window(); redraw_window();
break; break;
case KSYS_EVENT_BUTTON: case KSYS_EVENT_BUTTON:
switch (_ksys_get_button()){ switch (_ksys_get_button()) {
case BTN_CREATE_TH: case BTN_CREATE_TH:
create_thread(); create_thread();
break; break;

View File

@ -1,20 +1,20 @@
#include "stddef.h" #include "stddef.h"
#include <sys/ksys.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/ksys.h>
#define DEV_ADD_DISK 1 #define DEV_ADD_DISK 1
#define TMPDISK_SIZE 10 //Mb #define TMPDISK_SIZE 10 // Mb
#pragma pack(push, 1) #pragma pack(push, 1)
struct{ struct {
unsigned disk_size; unsigned disk_size;
unsigned char disk_id; unsigned char disk_id;
}tmpdisk_add; } tmpdisk_add;
#pragma pack(pop) #pragma pack(pop)
char *tmpdisk_res_text[]={ char* tmpdisk_res_text[] = {
"TmpDisk operation completed successfully", "TmpDisk operation completed successfully",
"Unknown IOCTL code, wrong input/output size...", "Unknown IOCTL code, wrong input/output size...",
"DiskId must be from 0 to 9", "DiskId must be from 0 to 9",
@ -22,19 +22,20 @@ char *tmpdisk_res_text[]={
"DiskSize is too small, might be too little free RAM", "DiskSize is too small, might be too little free RAM",
"Memory allocation failed", "Memory allocation failed",
"Unknown error O_o", "Unknown error O_o",
0}; 0
};
int main()
int main(){ {
ksys_drv_hand_t tmpdisk_drv = _ksys_load_driver("tmpdisk"); ksys_drv_hand_t tmpdisk_drv = _ksys_load_driver("tmpdisk");
if(!tmpdisk_drv){ if (!tmpdisk_drv) {
puts("tmpdisk.sys driver not load!"); puts("tmpdisk.sys driver not load!");
exit(0); exit(0);
}else{ } else {
puts("tmpdisk.sys driver is load!"); puts("tmpdisk.sys driver is load!");
} }
tmpdisk_add.disk_size = TMPDISK_SIZE*1024*1024/512; tmpdisk_add.disk_size = TMPDISK_SIZE * 1024 * 1024 / 512;
tmpdisk_add.disk_id = 5; tmpdisk_add.disk_id = 5;
ksys_ioctl_t ioctl; ksys_ioctl_t ioctl;
@ -46,10 +47,10 @@ int main(){
ioctl.out_data_size = 0; ioctl.out_data_size = 0;
printf("Create '/tmp%u/' disk a %u Mb size...\n", tmpdisk_add.disk_id, TMPDISK_SIZE); printf("Create '/tmp%u/' disk a %u Mb size...\n", tmpdisk_add.disk_id, TMPDISK_SIZE);
unsigned status =_ksys_driver_control(&ioctl); unsigned status = _ksys_driver_control(&ioctl);
if(status<7){ if (status < 7) {
puts(tmpdisk_res_text[status]); puts(tmpdisk_res_text[status]);
}else{ } else {
puts(tmpdisk_res_text[6]); puts(tmpdisk_res_text[6]);
} }
exit(0); exit(0);

View File

@ -4,19 +4,19 @@ The main code is taken from the site:
https://www.binarytides.com/whois-client-code-in-c-with-linux-sockets/ https://www.binarytides.com/whois-client-code-in-c-with-linux-sockets/
*/ */
#include <errno.h>
#include "sys/ksys.h" #include "sys/ksys.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <clayer/network.h> #include <clayer/network.h>
#include <conio.h> #include <conio.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
FILE *out=stdout; FILE* out = stdout;
#ifdef DEBUG #ifdef DEBUG
FILE *out=stderr; FILE* out = stderr;
#endif #endif
#define EXIT_SUCCESS 0 #define EXIT_SUCCESS 0
@ -32,37 +32,36 @@ void show_help()
puts("Example: whois google.com -f my.txt"); puts("Example: whois google.com -f my.txt");
} }
int get_whois_data(char * , char **); int get_whois_data(char*, char**);
int hostname_to_ip(char * , char *); int hostname_to_ip(char*, char*);
int whois_query(char * , char * , char **); int whois_query(char*, char*, char**);
char *str_replace(char *search , char *replace , char *subject ); char* str_replace(char* search, char* replace, char* subject);
char* str_copy(char*); char* str_copy(char*);
int main(int argc, char* argv[])
int main(int argc , char *argv[])
{ {
char *domain , *data = NULL; char *domain, *data = NULL;
int f_flag=0; int f_flag = 0;
if(argc==2){ if (argc == 2) {
domain=strdup(argv[1]); domain = strdup(argv[1]);
} }
else if(!strcmp(argv[2], "-f") && argc==4){ else if (!strcmp(argv[2], "-f") && argc == 4) {
domain=strdup(argv[1]); domain = strdup(argv[1]);
if((out=fopen(argv[3],"w"))==NULL){ if ((out = fopen(argv[3], "w")) == NULL) {
printf("Error writing to file: '%s' !\n", argv[3]); printf("Error writing to file: '%s' !\n", argv[3]);
exit(0); exit(0);
} }
}else{ } else {
show_help(); show_help();
exit(0); exit(0);
} }
if(out==stdout){ if (out == stdout) {
con_init(); con_init();
(*con_set_title)("Whois"); (*con_set_title)("Whois");
} }
get_whois_data(domain , &data); get_whois_data(domain, &data);
exit(0); exit(0);
} }
@ -70,27 +69,27 @@ int main(int argc , char *argv[])
Get the whois data of a domain Get the whois data of a domain
*/ */
int get_whois_data(char *domain , char **data) int get_whois_data(char* domain, char** data)
{ {
char ext[1024] , *pch , *response = NULL , *response_2 = NULL , *wch , *dt; char ext[1024], *pch, *response = NULL, *response_2 = NULL, *wch, *dt;
//remove "http://" and "www." // remove "http://" and "www."
domain = str_replace("http://" , "" , domain); domain = str_replace("http://", "", domain);
domain = str_replace("www." , "" , domain); domain = str_replace("www.", "", domain);
//get the extension , com , org , edu // get the extension , com , org , edu
dt = strdup(domain); dt = strdup(domain);
if(dt == NULL){ if (dt == NULL) {
fprintf(out, "strdup failed"); fprintf(out, "strdup failed");
} }
pch = (char*)strtok(dt , "."); pch = (char*)strtok(dt, ".");
while(pch != NULL){ while (pch != NULL) {
strcpy(ext , pch); strcpy(ext, pch);
pch = strtok(NULL , "."); pch = strtok(NULL, ".");
} }
// This will tell the whois server for the particular TLD like com , org // This will tell the whois server for the particular TLD like com , org
if( whois_query("whois.iana.org" , ext , &response) == EXIT_FAILURE){ if (whois_query("whois.iana.org", ext, &response) == EXIT_FAILURE) {
fprintf(out, "Whois query failed"); fprintf(out, "Whois query failed");
return 1; return 1;
} }
@ -98,68 +97,68 @@ int get_whois_data(char *domain , char **data)
fprintf(out, "%s", response); fprintf(out, "%s", response);
// Now analysze the response // Now analysze the response
pch = strtok(response , "\n"); pch = strtok(response, "\n");
while(pch != NULL){ while (pch != NULL) {
// Check if whois line // Check if whois line
wch = strstr(pch , "whois."); wch = strstr(pch, "whois.");
if(wch != NULL){ if (wch != NULL) {
break; break;
} }
// Next line please // Next line please
pch = strtok(NULL , "\n"); pch = strtok(NULL, "\n");
} }
// Now we have the TLD whois server in wch , query again // Now we have the TLD whois server in wch , query again
//This will provide minimal whois information along with the parent whois server of the specific domain :) // This will provide minimal whois information along with the parent whois server of the specific domain :)
wch = strdup(wch); wch = strdup(wch);
free(response); free(response);
//This should not be necessary , but segmentation fault without this , why ? // This should not be necessary , but segmentation fault without this , why ?
response = NULL; response = NULL;
if(wch != NULL){ if (wch != NULL) {
fprintf(out,"\nTLD Whois server is : %s" , wch); fprintf(out, "\nTLD Whois server is : %s", wch);
if( whois_query(wch , domain , &response) == EXIT_FAILURE){ if (whois_query(wch, domain, &response) == EXIT_FAILURE) {
fprintf(out, "Whois query failed\n"); fprintf(out, "Whois query failed\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
}else{ } else {
fprintf(out, "\nTLD whois server for %s not found\n" , ext); fprintf(out, "\nTLD whois server for %s not found\n", ext);
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
response_2 = strdup(response); response_2 = strdup(response);
// Again search for a whois server in this response. :) // Again search for a whois server in this response. :)
pch = strtok(response , "\n"); pch = strtok(response, "\n");
while(pch != NULL){ while (pch != NULL) {
// Check if whois line // Check if whois line
wch = strstr(pch , "whois."); wch = strstr(pch, "whois.");
if(wch != NULL){ if (wch != NULL) {
break; break;
} }
//Next line please // Next line please
pch = strtok(NULL , "\n"); pch = strtok(NULL, "\n");
} }
/* /*
If a registrar whois server is found then query it If a registrar whois server is found then query it
*/ */
if(wch){ if (wch) {
// Now we have the registrar whois server , this has the direct full information of the particular domain // Now we have the registrar whois server , this has the direct full information of the particular domain
// so lets query again // so lets query again
fprintf(out, "\nRegistrar Whois server is : %s" , wch); fprintf(out, "\nRegistrar Whois server is : %s", wch);
if( whois_query(wch , domain , &response) == EXIT_FAILURE ){ if (whois_query(wch, domain, &response) == EXIT_FAILURE) {
fprintf(out, "Whois query failed"); fprintf(out, "Whois query failed");
}else{ } else {
fprintf(out, "\n%s" , response); fprintf(out, "\n%s", response);
} }
} }
/* /*
otherwise echo the output from the previous whois result otherwise echo the output from the previous whois result
*/ */
else{ else {
fprintf(out, "%s" , response_2); fprintf(out, "%s", response_2);
} }
return 0; return 0;
} }
@ -167,60 +166,60 @@ int get_whois_data(char *domain , char **data)
/* /*
Perform a whois query to a server and record the response Perform a whois query to a server and record the response
*/ */
int whois_query(char *server , char *query , char **response) int whois_query(char* server, char* query, char** response)
{ {
char ip[32] , message[100] , buffer[1500]; char ip[32], message[100], buffer[1500];
int sock , read_size , total_size = 0; int sock, read_size, total_size = 0;
int WHOIS_PORT = 43; int WHOIS_PORT = 43;
struct sockaddr dest; struct sockaddr dest;
sock = socket(AF_INET4 , SOCK_STREAM , IPPROTO_TCP); sock = socket(AF_INET4, SOCK_STREAM, IPPROTO_TCP);
//Prepare connection structures :) // Prepare connection structures :)
memset(&dest , 0 , sizeof(dest) ); memset(&dest, 0, sizeof(dest));
dest.sin_family = AF_INET; dest.sin_family = AF_INET;
server = str_copy(server); server = str_copy(server);
server[strcspn(server, "\r\n")] = '\0'; server[strcspn(server, "\r\n")] = '\0';
fprintf(out, "\nResolving: %s ...\n" , server); fprintf(out, "\nResolving: %s ...\n", server);
if(hostname_to_ip(server , ip) == EXIT_FAILURE ){ if (hostname_to_ip(server, ip) == EXIT_FAILURE) {
fprintf(out, "Failed\n"); fprintf(out, "Failed\n");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
fprintf(out, "Found ip: %s \n" , ip); fprintf(out, "Found ip: %s \n", ip);
dest.sin_addr = inet_addr(ip); dest.sin_addr = inet_addr(ip);
dest.sin_port = PORT(WHOIS_PORT); dest.sin_port = PORT(WHOIS_PORT);
; //Now connect to remote server ; // Now connect to remote server
if(connect(sock , (const struct sockaddr*) &dest , sizeof(dest)) < 0){ if (connect(sock, (const struct sockaddr*)&dest, sizeof(dest)) < 0) {
perror("connect failed"); perror("connect failed");
perror(strerror(errno)); perror(strerror(errno));
return EXIT_FAILURE; return EXIT_FAILURE;
} }
//Now send some data or message // Now send some data or message
fprintf(out, "\nQuerying for: %s ...\n" , query); fprintf(out, "\nQuerying for: %s ...\n", query);
sprintf(message , "%s\r\n" , query); sprintf(message, "%s\r\n", query);
if( send(sock , message , strlen(message) , 0) < 0){ if (send(sock, message, strlen(message), 0) < 0) {
perror("send failed"); perror("send failed");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
//Now receive the response // Now receive the response
while((read_size = recv(sock, buffer, sizeof(buffer), 0))){ while ((read_size = recv(sock, buffer, sizeof(buffer), 0))) {
*response = realloc(*response , read_size + total_size); *response = realloc(*response, read_size + total_size);
if(*response == NULL){ if (*response == NULL) {
fprintf(out, "realloc failed"); fprintf(out, "realloc failed");
return EXIT_FAILURE; return EXIT_FAILURE;
} }
memcpy(*response + total_size , buffer , read_size); memcpy(*response + total_size, buffer, read_size);
total_size += read_size; total_size += read_size;
} }
fprintf(out, "Done\n"); fprintf(out, "Done\n");
*response = realloc(*response , total_size + 1); *response = realloc(*response, total_size + 1);
*(*response + total_size) = '\0'; *(*response + total_size) = '\0';
close(sock); close(sock);
return EXIT_SUCCESS; return EXIT_SUCCESS;
@ -228,10 +227,11 @@ int whois_query(char *server , char *query , char **response)
/* /*
Get the ip address of a given hostname Get the ip address of a given hostname
*/ */
int hostname_to_ip(char *hostname , char *ip) int hostname_to_ip(char* hostname, char* ip)
{ {
struct addrinfo *addr_info; struct addrinfo* addr_info;
char port_str[16]; sprintf(port_str, "%d", 80); char port_str[16];
sprintf(port_str, "%d", 80);
struct addrinfo hints; struct addrinfo hints;
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
hints.ai_family = AF_UNSPEC; // IPv4 or IPv6 doesnt matter hints.ai_family = AF_UNSPEC; // IPv4 or IPv6 doesnt matter
@ -239,7 +239,7 @@ int hostname_to_ip(char *hostname , char *ip)
if (getaddrinfo(hostname, port_str, 0, &addr_info) != 0) { if (getaddrinfo(hostname, port_str, 0, &addr_info) != 0) {
freeaddrinfo(addr_info); freeaddrinfo(addr_info);
return EXIT_FAILURE; return EXIT_FAILURE;
}else{ } else {
strcpy(ip, inet_ntoa(addr_info->ai_addr->sin_addr)); strcpy(ip, inet_ntoa(addr_info->ai_addr->sin_addr));
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
@ -247,51 +247,51 @@ int hostname_to_ip(char *hostname , char *ip)
/* /*
Search and replace a string with another string , in a string Search and replace a string with another string , in a string
*/ */
char *str_replace(char *search , char *replace , char *subject) char* str_replace(char* search, char* replace, char* subject)
{ {
char *p = NULL , *old = NULL , *new_subject = NULL ; char *p = NULL, *old = NULL, *new_subject = NULL;
int c = 0 , search_size; int c = 0, search_size;
search_size = strlen(search); search_size = strlen(search);
//Count how many occurences // Count how many occurences
for(p = strstr(subject , search) ; p != NULL ; p = strstr(p + search_size , search)){ for (p = strstr(subject, search); p != NULL; p = strstr(p + search_size, search)) {
c++; c++;
} }
//Final size // Final size
c = ( strlen(replace) - search_size )*c + strlen(subject); c = (strlen(replace) - search_size) * c + strlen(subject);
//New subject with new size // New subject with new size
new_subject = malloc( c ); new_subject = malloc(c);
//Set it to blank // Set it to blank
strcpy(new_subject , ""); strcpy(new_subject, "");
//The start position // The start position
old = subject; old = subject;
for(p = strstr(subject , search) ; p != NULL ; p = strstr(p + search_size , search)){ for (p = strstr(subject, search); p != NULL; p = strstr(p + search_size, search)) {
//move ahead and copy some text from original subject , from a certain position // move ahead and copy some text from original subject , from a certain position
strncpy(new_subject + strlen(new_subject) , old , p - old); strncpy(new_subject + strlen(new_subject), old, p - old);
//move ahead and copy the replacement text // move ahead and copy the replacement text
strcpy(new_subject + strlen(new_subject) , replace); strcpy(new_subject + strlen(new_subject), replace);
//The new start position after this search match // The new start position after this search match
old = p + search_size; old = p + search_size;
} }
//Copy the part after the last search match // Copy the part after the last search match
strcpy(new_subject + strlen(new_subject) , old); strcpy(new_subject + strlen(new_subject), old);
return new_subject; return new_subject;
} }
char* str_copy(char *source) char* str_copy(char* source)
{ {
char *copy = malloc(strlen(source) + 1); char* copy = malloc(strlen(source) + 1);
if(copy){ if (copy) {
strcpy(copy, source); strcpy(copy, source);
} }
return copy; return copy;