libc.obj:

- Unified stdcall and cdecl;
 - Fixed clayer to use def format;
 - Fixed build examples.


git-svn-id: svn://kolibrios.org@9620 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2022-01-12 18:09:37 +00:00
parent c5f03d0dac
commit 0d9c69c2a0
24 changed files with 290 additions and 251 deletions

View File

@ -3,9 +3,12 @@
#ifndef KOLIBRI_BOXLIB_H
#define KOLIBRI_BOXLIB_H
typedef unsigned color_t;
#include <sys/ksys.h>
#include <stdint.h>
#include <stddef.h>
extern int kolibri_boxlib_init(void);
typedef unsigned color_t;
int kolibri_boxlib_init(void);
/* flags meaning */
#define ed_figure_only 0b1000000000000000 // одни символы
@ -66,10 +69,10 @@ typedef struct {
uint32_t ar_offset;
} __attribute__ ((__packed__)) scrollbar;
extern void (*scrollbar_h_draw __attribute__((__stdcall__)))(scrollbar*);
extern void (*scrollbar_h_mouse __attribute__((__stdcall__)))(scrollbar*);
extern void (*scrollbar_v_draw __attribute__((__stdcall__)))(scrollbar*);
extern void (*scrollbar_v_mouse __attribute__((__stdcall__)))(scrollbar*);
extern void __stdcall (*scrollbar_h_draw)(scrollbar*);
extern void __stdcall (*scrollbar_h_mouse)(scrollbar*);
extern void __stdcall (*scrollbar_v_draw)(scrollbar*);
extern void __stdcall (*scrollbar_v_mouse)(scrollbar*);
// CHECKBOX
typedef struct {
@ -86,9 +89,9 @@ typedef struct {
unsigned int size_of_str;
}check_box;
extern void (*check_box_draw2 __attribute__((__stdcall__)))(check_box *);
extern void (*check_box_mouse2 __attribute__((__stdcall__)))(check_box *);
extern void (*init_checkbox2 __attribute__((__stdcall__)))(check_box *);
extern void __stdcall (*check_box_draw2)(check_box *);
extern void __stdcall (*check_box_mouse2)(check_box *);
extern void __stdcall (*init_checkbox2)(check_box *);
// DBUTTON
typedef struct {
@ -108,8 +111,8 @@ typedef struct {
uint32_t click; // clicked - 1, zero it after tested
} pict_button;
extern void (*dynamic_button_draw __attribute__((__stdcall__)))(pict_button *);
extern void (*dynamic_button_mouse __attribute__((__stdcall__)))(pict_button *);
extern void __stdcall (*dynamic_button_draw)(pict_button *);
extern void __stdcall (*dynamic_button_mouse)(pict_button *);
// EDITBOX
@ -141,10 +144,12 @@ typedef struct edit_box_t {
}edit_box;
#pragma pack(pop)
extern void (*edit_box_draw __attribute__((__stdcall__)))(edit_box *);
extern void edit_box_key (edit_box *, unsigned int key_val)__attribute__((__stdcall__));
extern void (*edit_box_mouse __attribute__((__stdcall__)))(edit_box *);
extern void (*edit_box_set_text __attribute__((__stdcall__)))(edit_box *, char *);
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_mouse)(edit_box *);
extern void __stdcall (*edit_box_set_text)(edit_box *, char *);
extern void __stdcall (*edit_box_key_safe)(edit_box *e, ksys_oskey_t ch);
// FRAME
typedef struct {
@ -162,7 +167,7 @@ typedef struct {
color_t font_bg_color;
}frame;
extern void (*frame_draw)(frame *);
extern void __stdcall (*frame_draw)(frame *);
// MENUBAR
typedef struct
@ -203,9 +208,9 @@ typedef struct
uint32_t get_mouse_flag;
} menubar;
extern void (*menu_bar_draw)(menubar *);
extern void (*menu_bar_mouse)(menubar *);
extern void (*menu_bar_activate)(menubar *);
extern void __stdcall (*menu_bar_draw)(menubar *);
extern void __stdcall (*menu_bar_mouse)(menubar *);
extern void __stdcall (*menu_bar_activate)(menubar *);
// OPTIONBOX
typedef struct option_box_t {
@ -222,8 +227,8 @@ typedef struct option_box_t {
uint32_t flags;
} __attribute__ ((__packed__)) option_box;
extern void (*option_box_draw __attribute__((__stdcall__)))(option_box **);
extern void (*option_box_mouse __attribute__((__stdcall__)))(option_box **);
extern void __stdcall (*option_box_draw)(option_box **);
extern void __stdcall (*option_box_mouse)(option_box **);
// PATHSHOW
typedef struct {
@ -240,8 +245,8 @@ typedef struct {
uint32_t temp_text_length;
} __attribute__ ((__packed__)) pathview;
extern void (*path_show_prepare __attribute__((__stdcall__)))(pathview *);
extern void (*path_show_draw __attribute__((__stdcall__)))(pathview *);
extern void __stdcall (*path_show_prepare)(pathview *);
extern void __stdcall (*path_show_draw)(pathview *);
// PROGRESSBAR
typedef struct {
@ -258,8 +263,7 @@ typedef struct {
unsigned int frame_color;
} progressbar;
extern void (*progressbar_draw __attribute__((__stdcall__)))(progressbar *);
extern void (*progressbar_progress __attribute__((__stdcall__)))(progressbar *);
extern void __stdcall (*progressbar_draw)(progressbar *);
extern void __stdcall (*progressbar_progress)(progressbar *);
#endif /* KOLIBRI_BOXLIB_H */

View File

@ -2,11 +2,8 @@
#define KOLIBRI_BUF2D_H
#include <stdint.h>
/*ToDo
* voxel function
*/
extern int kolibri_buf2d_init(void);
#include <sys/ksys.h>
#include <stddef.h>
typedef struct {
unsigned int *buf_pointer;
@ -16,7 +13,7 @@ typedef struct {
unsigned int height;
unsigned int bgcolor;
uint8_t color_bit;
} __attribute__ ((__packed__))buf2d_struct;
} __attribute__ ((__packed__))buf2d_struct;
enum BUF2D_ALGORITM_FILTR {
SIERRA_LITE,
@ -33,12 +30,14 @@ enum BUF2D_OPT_CROP {
BUF2D_OPT_CROP_RIGHT = 8
};
extern void (*buf2d_create_asm __attribute__((__stdcall__)))(buf2d_struct *);
extern void (*buf2d_curve_bezier_asm __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int);
int kolibri_buf2d_init(void);
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);
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 *)malloc(sizeof(buf2d_struct));
buf2d_struct *new_buf2d_struct = (buf2d_struct *)_ksys_alloc(sizeof(buf2d_struct));
new_buf2d_struct -> left = tlx;
new_buf2d_struct -> top = tly;
new_buf2d_struct -> width = sizex;
@ -54,30 +53,31 @@ void buf2d_curve_bezier(buf2d_struct *buf, unsigned int p0_x, unsigned int p0_y,
buf2d_curve_bezier_asm(buf, (p0_x<<16)+p0_y, (p1_x<<16)+p1_y, (p2_x<<16)+p2_y, color);
}
extern void (*buf2d_draw __attribute__((__stdcall__)))(buf2d_struct *);
extern void (*buf2d_clear __attribute__((__stdcall__)))(buf2d_struct *, unsigned int);
extern void (*buf2d_delete __attribute__((__stdcall__)))(buf2d_struct *);
extern void (*buf2d_rotate __attribute__((__stdcall__)))(buf2d_struct *, unsigned int);
extern void (*buf2d_resize __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int);
extern void (*buf2d_line __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
extern void (*buf2d_line_sm __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int);
extern void (*buf2d_rect_by_size __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
extern void (*buf2d_filled_rect_by_size __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
extern void (*buf2d_circle __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int);
extern void (*buf2d_img_hdiv2 __attribute__((__stdcall__)))(buf2d_struct *);
extern void (*buf2d_img_wdiv2 __attribute__((__stdcall__)))(buf2d_struct *);
extern void (*buf2d_conv_24_to_8 __attribute__((__stdcall__)))(buf2d_struct *, unsigned int);
extern void (*buf2d_conv_24_to_32 __attribute__((__stdcall__)))(buf2d_struct *, unsigned int);
extern void (*buf2d_bit_blt_transp __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, buf2d_struct *);
extern void (*buf2d_bit_blt_alpha __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, buf2d_struct *);
extern void (*buf2d_convert_text_matrix __attribute__((__stdcall__)))(buf2d_struct *);
extern void (*buf2d_draw_text __attribute__((__stdcall__)))(buf2d_struct *, buf2d_struct *, const char *, unsigned int, unsigned int);
extern void (*buf2d_crop_color __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int);
extern void (*buf2d_offset_h __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int);
extern void (*buf2d_flood_fill __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int, unsigned int);
extern void (*buf2d_set_pixel __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int, unsigned int);
extern unsigned int (*buf2d_get_pixel __attribute__((__stdcall__)))(buf2d_struct *, unsigned int, unsigned int);
extern void (*buf2d_flip_h __attribute__((__stdcall__)))(buf2d_struct *);
extern void (*buf2d_flip_v __attribute__((__stdcall__)))(buf2d_struct *);
extern void (*buf2d_filter_dither __attribute__((__stdcall__)))(buf2d_struct *, unsigned int);
extern void __stdcall (*buf2d_draw)(buf2d_struct *);
extern void __stdcall (*buf2d_clear)(buf2d_struct *, unsigned int);
extern void __stdcall (*buf2d_delete)(buf2d_struct *);
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_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_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_img_hdiv2)(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_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_alpha)(buf2d_struct *, unsigned int, unsigned int, 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_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_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 unsigned __stdcall (*buf2d_get_pixel)(buf2d_struct *, unsigned int, unsigned int);
extern void __stdcall (*buf2d_flip_h)(buf2d_struct *);
extern void __stdcall (*buf2d_flip_v)(buf2d_struct *);
extern void __stdcall (*buf2d_filter_dither)(buf2d_struct *, unsigned int);
#endif /* KOLIBRI_BUF2D_H */

View File

@ -2,6 +2,7 @@
#define KOLIBRI_DIALOG_H
#include <stdlib.h>
#define NOT_SUCCESS 0
#define SUCCESS 1
@ -115,12 +116,12 @@ color_dialog* kolibri_new_color_dialog(unsigned int type, unsigned short tlx, un
return new_colordialog;
}
extern void kolibri_dialog_init();
void kolibri_dialog_init();
extern void (*OpenDialog_init __attribute__((__stdcall__)))(open_dialog *);
extern void (*OpenDialog_start __attribute__((__stdcall__)))(open_dialog *);
extern void __stdcall (*OpenDialog_init)(open_dialog *);
extern void __stdcall (*OpenDialog_start)(open_dialog *);
extern void (*ColorDialog_init __attribute__((__stdcall__)))(color_dialog *);
extern void (*ColorDialog_start __attribute__((__stdcall__)))(color_dialog *);
extern void __stdcall (*ColorDialog_init)(color_dialog *);
extern void __stdcall (*ColorDialog_start)(color_dialog *);
#endif

View File

@ -1,11 +1,13 @@
#ifndef KOLIBRI_GB_H
#define KOLIBRI_GB_H
#pragma pack(push, 1)
typedef struct
{
int w;
int h;
char *bmp;
char *alpha;
int w;
int h;
char *bmp;
char *alpha;
} GB_BMP;
#pragma pack(pop)
@ -17,3 +19,5 @@ 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_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);
#endif // KOLIBRI_GB_H

View File

@ -5,11 +5,10 @@
Adapted for TCC's dynamic API by Magomed Kostoev, 2020
*/
#ifndef _HTTP_H_
#define _HTTP_H_
#ifndef KOLIBRI_HTTP_H
#define KOLIBRI_HTTP_H
#define cdecl __attribute__ ((cdecl))
#define stdcall __attribute__ ((stdcall))
#include <stddef.h>
// Bitflags for http_msg.flags
// status
@ -80,7 +79,7 @@ typedef struct http_msg_s {
Initiates a HTTP connection, using 'GET' method.
Returns NULL on error, identifier otherwise.
*/
extern http_msg * stdcall (*http_get)(const char *url, http_msg *identifier, unsigned flags, const char *add_header);
extern http_msg * __stdcall (*http_get)(const char *url, http_msg *identifier, unsigned flags, const char *add_header);
/*
url = pointer to ASCIIZ URL
@ -91,7 +90,7 @@ extern http_msg * stdcall (*http_get)(const char *url, http_msg *identifier, uns
Initiate a HTTP connection, using 'HEAD' method.
Returns NULL on error, identifier otherwise.
*/
extern http_msg * stdcall (*http_head)(const char *url, http_msg *identifier, unsigned flags, const char *add_header);
extern http_msg * __stdcall (*http_head)(const char *url, http_msg *identifier, unsigned flags, const char *add_header);
/*
url = pointer to ASCIIZ URL
@ -106,7 +105,7 @@ extern http_msg * stdcall (*http_head)(const char *url, http_msg *identifier, un
using system function 75, 6.
Returns 0 on error, identifier otherwise
*/
extern http_msg * stdcall (*http_post)(const char *url, http_msg *identifier, unsigned flags, const char *add_header,
extern http_msg * __stdcall (*http_post)(const char *url, http_msg *identifier, unsigned flags, const char *add_header,
const char *content_type, unsigned content_length);
/*
@ -128,7 +127,7 @@ extern http_msg * stdcall (*http_post)(const char *url, http_msg *identifier, un
In content_length you'll find the length of the content.
In content_received, you'll find the number of content bytes already received.
*/
extern int stdcall (*http_receive)(http_msg *identifier);
extern int __stdcall (*http_receive)(http_msg *identifier);
/*
identifier = identifier which one of the previous functions returned
@ -137,17 +136,17 @@ extern int stdcall (*http_receive)(http_msg *identifier);
This procedure can be used to send data to the server (POST)
Returns number of bytes sent, -1 on error
*/
extern int stdcall (*http_send)(http_msg *identifier, void *dataptr, unsigned datalength);
extern int __stdcall (*http_send)(http_msg *identifier, void *dataptr, unsigned datalength);
/*
Sometimes the http_receive function receives incomplete data. If you have the same problem then a macro can help you:
*/
extern int stdcall (*http_free)(http_msg *identifier);
extern int __stdcall (*http_free)(http_msg *identifier);
/*
Free unused data
*/
#define http_long_receive(x) while(http_receive(x)){};
#endif // _HTTP_H_
#endif // KOLIBRI_HTTP_H

View File

@ -5,13 +5,12 @@
Adapted for TCC's dynamic API by Magomed Kostoev, 2020
*/
#ifndef __KOS__INPUTBOX__H________
#define __KOS__INPUTBOX__H________
#ifndef KOLIBRI_INPUTBOX_H
#define KOLIBRI_INPUTBOX_H
#define cdecl __attribute__ ((cdecl))
#define stdcall __attribute__ ((stdcall))
#include <stddef.h>
extern unsigned stdcall (*InputBox)(void* Buffer, char* Caption, char* Prompt, char* Default,
extern unsigned __stdcall (*InputBox)(void* Buffer, char* Caption, char* Prompt, char* Default,
unsigned long Flags, unsigned long BufferSize, void* RedrawProc);
#endif // __KOS__INPUTBOX__H________
#endif // KOLIBRI_INPUTBOX_H

View File

@ -6,10 +6,6 @@
#include <stddef.h>
#include <stdbool.h>
extern int kolibri_libimg_init(void);
#define _stdcall __attribute__((__stdcall__))
//list of format id's
#define LIBIMG_FORMAT_BMP 1
#define LIBIMG_FORMAT_ICO 2
@ -99,23 +95,23 @@ typedef struct{
#define ROTATE_90_CCW ROTATE_270_CW
#define ROTATE_270_CCW ROTATE_90_CW
extern Image* (*img_decode _stdcall)(void* file_data, uint32_t size, uint32_t b_color);
extern Image* (*img_encode _stdcall)(Image* img, uint32_t length, uint32_t option);
extern Image* (*img_create _stdcall)(uint32_t width, uint32_t height, uint32_t type);
extern void (*img_to_rgb2 _stdcall)(Image* img, void *rgb_data);
extern Image* (*img_to_rgb _stdcall)(Image* img);
extern bool (*img_flip _stdcall)(Image* img, uint32_t flip);
extern bool (*img_flip_layer _stdcall)(Image *img, uint32_t flip);
extern bool (*img_rotate _stdcall)(Image *img, uint32_t rotate);
extern bool (*img_rotate_layer _stdcall)(Image* data, uint32_t rotate);
extern void (*img_draw _stdcall)(Image *img, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t xoff, uint32_t yoff);
extern int32_t (*img_count _stdcall)(Image *img);
extern bool (*img_destroy _stdcall)(Image *img);
extern bool (*img_destroy_layer _stdcall)(Image* img);
extern Image* (*img_blend _stdcall)(Image* dst, Image* src, uint32_t out_x, uint32_t out_y, uint32_t in_x, uint32_t in_y, uint32_t width, uint32_t height);
extern Image* (*img_convert _stdcall)(Image *src, Image *dst, uint32_t dst_type, uint32_t, uint32_t);
extern Image* (*img_resize_data _stdcall)(Image *src, uint32_t width, uint32_t height);
extern Image* (*img_scale _stdcall)(Image* src, uint32_t crop_x, uint32_t crop_y, uint32_t crop_width, uint32_t crop_height, Image* dst, uint32_t scale_type, uint32_t inter, uint32_t new_width, uint32_t new_height);
extern Image* __stdcall (*img_decode)(void* file_data, uint32_t size, uint32_t b_color);
extern Image* __stdcall (*img_encode)(Image* img, uint32_t length, uint32_t option);
extern Image* __stdcall (*img_create)(uint32_t width, uint32_t height, uint32_t type);
extern void __stdcall (*img_to_rgb2)(Image* img, void *rgb_data);
extern Image* __stdcall (*img_to_rgb)(Image* img);
extern bool __stdcall (*img_flip)(Image* img, uint32_t flip);
extern bool __stdcall (*img_flip_layer)(Image *img, uint32_t flip);
extern bool __stdcall (*img_rotate)(Image *img, uint32_t rotate);
extern bool __stdcall (*img_rotate_layer)(Image* data, uint32_t rotate);
extern void __stdcall (*img_draw)(Image *img, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t xoff, uint32_t yoff);
extern int32_t __stdcall (*img_count)(Image *img);
extern bool __stdcall (*img_destroy)(Image *img);
extern bool __stdcall (*img_destroy_layer)(Image* img);
extern Image* __stdcall (*img_blend)(Image* dst, Image* src, uint32_t out_x, uint32_t out_y, uint32_t in_x, uint32_t in_y, uint32_t width, uint32_t height);
extern Image* __stdcall (*img_convert)(Image *src, Image *dst, uint32_t dst_type, uint32_t, uint32_t);
extern Image* __stdcall (*img_resize_data)(Image *src, uint32_t width, uint32_t height);
extern Image* __stdcall (*img_scale)(Image* src, uint32_t crop_x, uint32_t crop_y, uint32_t crop_width, uint32_t crop_height, Image* dst, uint32_t scale_type, uint32_t inter, uint32_t new_width, uint32_t new_height);
void img_fill_color(Image* img, uint32_t width, uint32_t height, uint32_t color){
for (uint32_t i = 0; i < width*height; i++) {
@ -123,4 +119,6 @@ void img_fill_color(Image* img, uint32_t width, uint32_t height, uint32_t color)
}
}
int kolibri_libimg_init(void);
#endif /* KOLIBRI_LIBIMG_H */

View File

@ -1,11 +1,11 @@
#ifndef KOLIBRI_MSGBOX_H
#define KOLIBRI_MSGBOX_H
#include <stdarg.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
typedef struct {
uint8_t retval; // 0 - win closed, 1 to n - button num, also default button on start
uint8_t reserv;
@ -16,16 +16,16 @@ typedef struct {
typedef void (*msgbox_callback)(void);
extern void (*msgbox_create __attribute__((__stdcall__)))(msgbox *, void *thread); // clears callbacks, ! if fix lib, we can return eax as of Fn51
extern void (*msgbox_setfunctions __attribute__((__stdcall__)))(msgbox_callback*); // must be called immediately after create, zero-ended array
extern void (*msgbox_reinit __attribute__((__stdcall__)))(msgbox *) ; // recalc sizes when structure changes, called auto when MsgBoxCreate
extern void __stdcall (*mb_create)(msgbox *, void *thread); // clears callbacks, ! if fix lib, we can return eax as of Fn51
extern void __stdcall (*mb_setfunctions)(msgbox_callback*); // must be called immediately after create, zero-ended array
extern void __stdcall (*mb_reinit)(msgbox *); // recalc sizes when structure changes, called auto when MsgBoxCreate
static inline msgbox* kolibri_new_msgbox(char* title, char* text, int def_but, ...)
/// text can be multilined by code 13 = "\r"
/// def_but - highlighted and used on Enter (if zero - default is [X]), user may use Tabs or Arrows
/// last params are buttons text, max 8. last must set as NULL
{
va_list vl=0;
va_list vl = 0;
va_start(vl, def_but);
msgbox* box = calloc(sizeof(msgbox), 1);
box->retval = (uint8_t)def_but;
@ -48,8 +48,8 @@ static inline msgbox* kolibri_new_msgbox(char* title, char* text, int def_but, .
static inline void kolibri_start_msgbox(msgbox* box, msgbox_callback cb[])
{
(*msgbox_create)(box, &box->top_stack);
if (cb) (*msgbox_setfunctions)(cb);
mb_create(box, &box->top_stack);
if (cb) mb_setfunctions(cb);
}
#endif

View File

@ -1,11 +1,9 @@
#ifndef __NETWORK_H
#define __NETWORK_H
#ifndef KOLIBRI_NETWORK_H
#define KOLIBRI_NETWORK_H
#include <sys/socket.h>
#include <sys/ksys.h>
#define stdcall __attribute__ ((stdcall))
#define EAI_ADDRFAMILY 1
#define EAI_AGAIN 2
#define EAI_BADFLAGS 3
@ -48,10 +46,11 @@ struct addrinfo {
};
#pragma pack(pop)
extern int networklib_init ();
extern int stdcall (*inet_addr)(const char* hostname);
extern char* stdcall (*inet_ntoa)(int ip_addr);
extern int stdcall (*getaddrinfo)(const char* hostname, const char* servname, const struct addrinfo* hints, struct addrinfo** res);
extern void stdcall (*freeaddrinfo)(struct addrinfo* ai);
int networklib_init();
extern int __stdcall (*inet_addr)(const char* hostname);
extern char* __stdcall (*inet_ntoa)(int ip_addr);
extern int __stdcall (*getaddrinfo)(const char* hostname, const char* servname, const struct addrinfo* hints, struct addrinfo** res);
extern void __stdcall (*freeaddrinfo)(struct addrinfo* ai);
#endif

View File

@ -1,11 +1,13 @@
#ifndef KOLIBRI_RASTERWORKS_H
#define KOLIBRI_RASTERWORKS_H
//extern int kolibri_rasterworks_init(void);
#include <stddef.h>
extern void (*drawText __attribute__((__stdcall__)))(void *canvas, int x, int y, const char *string, int charQuantity, int fontColor, int params);
extern int (*countUTF8Z __attribute__((__stdcall__)))(const char *string, int byteQuantity);
extern int (*charsFit __attribute__((__stdcall__)))(int areaWidth, int charHeight);
extern int (*strWidth __attribute__((__stdcall__)))(int charQuantity, int charHeight);
int kolibri_rasterworks_init(void);
#endif /* KOLIBRI_RASTERWORKS_H */
extern void __stdcall (*drawText)(void *canvas, int x, int y, const char *string, int charQuantity, int fontColor, int params);
extern int __stdcall (*countUTF8Z)(const char *string, int byteQuantity) __asm__("cntUTF-8");
extern int __stdcall (*charsFit)(int areaWidth, int charHeight);
extern int __stdcall (*strWidth)(int charQuantity, int charHeight);
#endif /* KOLIBRI_RASTERWORKS_H */

View File

@ -11,9 +11,6 @@ Adapted for tcc by Siemargl, 2016
#include <stddef.h>
#define cdecl __attribute__ ((cdecl))
#define stdcall __attribute__ ((stdcall))
/*
console.obj exports the following functions
*/
@ -38,25 +35,25 @@ typedef unsigned short word; /* 16-bit unsigned integer */
extern int _FUNC(con_init)(void);
extern int _FUNC(con_init_opt)(dword wnd_width, dword wnd_height, dword scr_width, dword scr_height, const char* title);
extern void stdcall _FUNC((*con_exit))(int bCloseWindow);
extern void stdcall _FUNC((*con_set_title))(const char* title);
extern void stdcall _FUNC((*con_write_asciiz))(const char* str);
extern void stdcall _FUNC((*con_write_string))(const char* str, dword length);
extern int cdecl _FUNC((*con_printf))(const char* format, ...);
extern dword stdcall _FUNC((*con_get_flags))(void);
extern dword stdcall _FUNC((*con_set_flags))(dword new_flags);
extern int stdcall _FUNC((*con_get_font_height))(void);
extern int stdcall _FUNC((*con_get_cursor_height))(void);
extern int stdcall _FUNC((*con_set_cursor_height))(int new_height);
extern int stdcall _FUNC((*con_getch))(void);
extern word stdcall _FUNC((*con_getch2))(void);
extern int stdcall _FUNC((*con_kbhit))(void);
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);
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_get_cursor_pos))(int* px, int* py);
extern void stdcall _FUNC((*con_set_cursor_pos))(int x, int y);
extern void __stdcall _FUNC((*con_exit))(int bCloseWindow);
extern void __stdcall _FUNC((*con_set_title))(const char* title);
extern void __stdcall _FUNC((*con_write_asciiz))(const char* str);
extern void __stdcall _FUNC((*con_write_string))(const char* str, dword length);
extern int __cdecl _FUNC((*con_printf))(const char* format, ...);
extern dword __stdcall _FUNC((*con_get_flags))(void);
extern dword __stdcall _FUNC((*con_set_flags))(dword new_flags);
extern int __stdcall _FUNC((*con_get_font_height))(void);
extern int __stdcall _FUNC((*con_get_cursor_height))(void);
extern int __stdcall _FUNC((*con_set_cursor_height))(int new_height);
extern int __stdcall _FUNC((*con_getch))(void);
extern word __stdcall _FUNC((*con_getch2))(void);
extern int __stdcall _FUNC((*con_kbhit))(void);
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);
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_get_cursor_pos))(int* px, int* py);
extern void __stdcall _FUNC((*con_set_cursor_pos))(int x, int y);
extern int _FUNC(__con_is_load);
#endif

View File

@ -34,4 +34,12 @@ typedef uint64_t uintmax_t;
#define offsetof(type, field) ((size_t)&((type *)0)->field)
#ifndef __stdcall
#define __stdcall __attribute__((stdcall))
#endif
#ifndef __cdecl
#define __cdecl __attribute__((cdecl))
#endif
#endif /* _STDDEF_H_ */

View File

@ -218,8 +218,8 @@ enum KSYS_FILE_ENCODING{
KSYS_FILE_UTF8 = 3
};
static inline
int _ksys_strcmp(const char * s1, const char * s2 )
static inline
int __strcmp(const char * s1, const char * s2 )
{
while ((*s1) && (*s1 == *s2)){ ++s1; ++s2; }
return(*(unsigned char*)s1 - *(unsigned char *)s2);
@ -1163,7 +1163,7 @@ void* _ksys_dlsym(ksys_dll_t *table, const char* fun_name){
if (!(table+i)->func_name){
break;
}else{
if (!_ksys_strcmp(fun_name, (table+i)->func_name)){
if (!__strcmp(fun_name, (table+i)->func_name)){
return (table+i)->func_ptr;
}
}

View File

@ -1,41 +1,40 @@
KTCC=kos32-tcc
FASM= fasm
KTCC = kos32-tcc
FASM = fasm
KPACK = kpack
CFLAGS = -I../include -I../../../../../../contrib/sdk/sources/SDL-1.2.2_newlib/include
LDFLAGS = -nostdlib -L../../bin/lib ../../bin/lib/crt0.o
BIN= stdio_test.kex \
basic_gui.kex \
http_tcp_demo.kex \
math_test.kex \
string_test.kex \
whois.kex \
file_io.kex \
tmpdisk_work.kex \
consoleio.kex \
assert_test.kex \
fasm/sprintf_test.kex \
clayer/rasterworks.kex \
clayer/libimg.kex \
clayer/dialog.kex \
clayer/msgbox.kex \
clayer/boxlib.kex \
thread_work.kex \
sdltest.kex \
shell_test.kex \
libc_test.kex
LIBS= -lSDL -lshell -ltcc -lsound -ldialog -lrasterworks -limg -lbox -lmsgbox -lnetwork -lc.obj
CFLAGS = -I../include -B../../kx -I../../../../../../contrib/sdk/sources/SDL-1.2.2_newlib/include
LIBS = -lbox_lib -lshell -lSDL -lsound -lnetwork -lrasterworks -limg -ldialog -lmsgbox
BIN = stdio_test.kex \
basic_gui.kex \
http_tcp_demo.kex \
math_test.kex \
string_test.kex \
whois.kex \
file_io.kex \
tmpdisk_work.kex \
consoleio.kex \
assert_test.kex \
clayer/rasterworks.kex \
clayer/libimg.kex \
clayer/dialog.kex \
clayer/msgbox.kex \
clayer/boxlib.kex \
thread_work.kex \
sdltest.kex \
shell_test.kex \
libc_test.kex \
defgen.kex
all: $(BIN)
%.kex : %.c
$(KTCC) $(CFLAGS) $(LDFLAGS) $< -o $@ $(LIBS)
$(KPACK) --nologo $@
%.kex : %.asm
$(FASM) $< $@
$(KPACK) --nologo $@
clean:
rm *.kex clayer/*.kex

View File

@ -1,24 +1,25 @@
#SHS
mkdir /tmp0/1/tcc_samples
../tcc file_io.c -o /tmp0/1/tcc_samples/file_io -lc.obj
../tcc whois.c -o /tmp0/1/tcc_samples/whois -ltcc -lnetwork -lc.obj
../tcc stdio_test.c -o /tmp0/1/tcc_samples/stdio_test -lc.obj
../tcc basic_gui.c -o /tmp0/1/tcc_samples/basic_gui -ltcc -lc.obj
../tcc consoleio.c -o /tmp0/1/tcc_samples/consoleio -lc.obj
../tcc dir_example.c -o /tmp0/1/tcc_samples/ls_dir -lc.obj
../tcc http_tcp_demo.c -o /tmp0/1/tcc_samples/http_tcp_demo -ltcc -lnetwork -lc.obj
../tcc math_test.c -o /tmp0/1/tcc_samples/math_test -ltcc -lc.obj
../tcc string_test.c -o /tmp0/1/tcc_samples/string_test -ltcc -lc.obj
../tcc tmpdisk_work.c -o /tmp0/1/tcc_samples/tmpdisk_work -ltcc -lc.obj
../tcc clayer/boxlib.c -o /tmp0/1/tcc_samples/boxlib -ltcc -lbox -lc.obj
../tcc clayer/dialog.c -o /tmp0/1/tcc_samples/dialog -ltcc -ldialog -lc.obj
cp clayer/logo.png /tmp0/1/tcc_samples/logo.png
../tcc clayer/libimg.c -o /tmp0/1/tcc_samples/libimg -ltcc -limg -lc.obj
../tcc clayer/msgbox.c -o /tmp0/1/tcc_samples/msgbox -ltcc -lmsgbox -lc.obj
../tcc clayer/rasterworks.c -o /tmp0/1/tcc_samples/rasterworks -ltcc -lrasterworks -lc.obj
../tcc thread_work.c -o /tmp0/1/tcc_samples/thread_work -ltcc -lc.obj
../tcc -I../include/SDL sdltest.c -o /tmp0/1/tcc_samples/sdltest -lSDL -lsound -ltcc -lc.obj
../tcc shell_test.c -o /tmp0/1/tcc_samples/shell_test -lshell -ltcc -lc.obj
../tcc libc_test.c -o /tmp0/1/tcc_samples/libc_test -ltcc -lc.obj
../tcc file_io.c -o /tmp0/1/tcc_samples/file_io
../tcc whois.c -o /tmp0/1/tcc_samples/whois -lnetwork
../tcc stdio_test.c -o /tmp0/1/tcc_samples/stdio_test
../tcc basic_gui.c -o /tmp0/1/tcc_samples/basic_gui
../tcc consoleio.c -o /tmp0/1/tcc_samples/consoleio
../tcc dir_example.c -o /tmp0/1/tcc_samples/ls_dir
../tcc http_tcp_demo.c -o /tmp0/1/tcc_samples/http_tcp_demo -lnetwork
../tcc math_test.c -o /tmp0/1/tcc_samples/math_test
../tcc string_test.c -o /tmp0/1/tcc_samples/string_test
../tcc tmpdisk_work.c -o /tmp0/1/tcc_samples/tmpdisk_work
../tcc clayer/boxlib.c -o /tmp0/1/tcc_samples/boxlib -lbox_lib
../tcc clayer/dialog.c -o /tmp0/1/tcc_samples/dialog -ldialog
cp clayer/logo.png /tmp0/1/tcc_samples/logo.png
../tcc clayer/libimg.c -o /tmp0/1/tcc_samples/libimg -limg
../tcc clayer/msgbox.c -o /tmp0/1/tcc_samples/msgbox -lmsgbox
../tcc clayer/rasterworks.c -o /tmp0/1/tcc_samples/rasterworks -lrasterworks
../tcc thread_work.c -o /tmp0/1/tcc_samples/thread_work
../tcc -I../include/SDL sdltest.c -o /tmp0/1/tcc_samples/sdltest -lSDL -lsound
../tcc shell_test.c -o /tmp0/1/tcc_samples/shell_test -lshell
../tcc libc_test.c -o /tmp0/1/tcc_samples/libc_test
../tcc defgen.c -o /tmp0/1/tcc_samples/defgen
"/sys/File managers/Eolite" /tmp0/1/tcc_samples
exit

View File

@ -42,10 +42,8 @@ void draw_window(){
_ksys_end_draw();
}
int main()
{
kolibri_boxlib_init();
init_checkbox2(&output_off);
_ksys_set_event_mask(KSYS_EVM_REDRAW + KSYS_EVM_KEY + KSYS_EVM_BUTTON + KSYS_EVM_MOUSE+ KSYS_EVM_MOUSE_FILTER);
while(1){
@ -55,7 +53,7 @@ int main()
break;
case KSYS_EVENT_KEY:
edit_box_key(&ed, _ksys_get_key().val);
edit_box_key_safe(&ed, _ksys_get_key());
draw_window();
break;
@ -89,4 +87,4 @@ int main()
}
}
return 0;
}
}

View File

@ -4,7 +4,6 @@
int main()
{
kolibri_dialog_init(); // dialog init
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_start(dlg_open); // Show open dialog box

View File

@ -44,18 +44,13 @@ void* load_img(char* fname, uint32_t* read_sz){ // Image file upload function
void draw_gui(){
_ksys_start_draw();
_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
_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
_ksys_end_draw();
}
int main(){
if (kolibri_libimg_init() == -1){
printf("Error loading lib_img.obj\n");
exit(0);
}
_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);
uint32_t img_size;

View File

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

View File

@ -3,11 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
int errno;
int main() {
networklib_init();
char *host = "kolibrios.org";
int port = 80;
printf("Connecting to %s on port %d\n", host, port);

View File

@ -8,7 +8,7 @@ int main(int argc, char** argv){
char hello1[]="Hello, KolibriOS!";
char hello2[20];
memcpy(hello1, hello2, strlen(hello1));
if(!_ksys_strcmp(hello1, hello2)){
if(!__strcmp(hello1, hello2)){
printf("memcpy: Successfully!\n");
return 0;
} else{

View File

@ -5,8 +5,6 @@ https://www.binarytides.com/whois-client-code-in-c-with-linux-sockets/
*/
#include <errno.h>
int errno;
#include "sys/ksys.h"
#include <stdio.h>
#include <string.h>
@ -42,8 +40,7 @@ char* str_copy(char*);
int main(int argc , char *argv[])
{
networklib_init();
{
char *domain , *data = NULL;
int f_flag=0;

View File

@ -7,31 +7,25 @@ static char* __con_dllname = "/sys/lib/console.obj";
int __con_is_load = 0;
void stdcall (*__con_init_hidden)(int wnd_width, unsigned wnd_height, int scr_width, int scr_height, const char* title);
void stdcall (*con_exit)(int);
void stdcall (*con_set_title)(const char* title);
void stdcall (*con_write_asciiz)(const char* str);
void stdcall (*con_write_string)(const char* str, dword length);
int cdecl (*con_printf)(const char* format, ...);
dword stdcall (*con_get_flags)(void);
dword stdcall (*con_set_flags)(dword new_flags);
int stdcall (*con_get_font_height)(void);
int stdcall (*con_get_cursor_height)(void);
int stdcall (*con_set_cursor_height)(int new_height);
int stdcall (*con_getch)(void);
word stdcall (*con_getch2)(void);
int stdcall (*con_kbhit)(void);
char* stdcall (*con_gets)(char* str, int n);
char* stdcall (*con_gets2)(con_gets2_callback callback, char* str, int n);
void stdcall (*con_cls)();
void stdcall (*con_get_cursor_pos)(int* px, int* py);
void stdcall (*con_set_cursor_pos)(int x, int y);
/*static void __con_panic(char* func_name)
{
debug_printf("In console.obj %s=NULL!\n", func_name);
_ksys_exit();
}*/
void __stdcall (*__con_init_hidden)(int wnd_width, unsigned wnd_height, int scr_width, int scr_height, const char* title);
void __stdcall (*con_exit)(int);
void __stdcall (*con_set_title)(const char* title);
void __stdcall (*con_write_asciiz)(const char* str);
void __stdcall (*con_write_string)(const char* str, dword length);
int __cdecl (*con_printf)(const char* format, ...);
dword __stdcall (*con_get_flags)(void);
dword __stdcall (*con_set_flags)(dword new_flags);
int __stdcall (*con_get_font_height)(void);
int __stdcall (*con_get_cursor_height)(void);
int __stdcall (*con_set_cursor_height)(int new_height);
int __stdcall (*con_getch)(void);
word __stdcall (*con_getch2)(void);
int __stdcall (*con_kbhit)(void);
char* __stdcall (*con_gets)(char* str, int n);
char* __stdcall (*con_gets2)(con_gets2_callback callback, char* str, int n);
void __stdcall (*con_cls)();
void __stdcall (*con_get_cursor_pos)(int* px, int* py);
void __stdcall (*con_set_cursor_pos)(int x, int y);
static void __con_lib_link(ksys_dll_t *exp)
{

View File

@ -10,5 +10,5 @@
int strcmp(const char * s1, const char * s2)
{
return _ksys_strcmp(s1, s2);
return __strcmp(s1, s2);
}