develop/ktcc: Post-SVN tidy
Some checks failed
Build system / Check kernel codestyle (pull_request) Successful in 25s
Build system / Build (pull_request) Failing after 27s

- Move source code from `trunk` into program root directory.
- Update build files.
This commit is contained in:
2025-05-23 17:49:05 +01:00
parent 46bcaca0b0
commit 42e77931bf
688 changed files with 17 additions and 17 deletions

View File

@@ -0,0 +1,268 @@
// writed by maxcodehack and superturbocat2001
// adaptation of clayer for ktcc
#ifndef KOLIBRI_BOXLIB_H
#define KOLIBRI_BOXLIB_H
#include <stddef.h>
#include <stdint.h>
#include <sys/ksys.h>
typedef unsigned color_t;
/* flags meaning */
#define ed_figure_only 0b1000000000000000 // одни символы
#define ed_always_focus 0b100000000000000 // всегда с курсором (фокусом)
#define ed_focus 0b10 // фокус ввода приложения, мышится самостоятельно
#define ed_pass 0b1 // поле с паролем
#define ed_shift_on 0b1000 // если не установлен -значит впервые нажат shift,если был установлен, значит мы уже что - то делали удерживая //shift
#define ed_shift_on_off 0b1111111111110111
#define ed_shift 0b100 //включается при нажатии на shift т.е. если нажимаю
#define ed_shift_off 0b1111111111111011
#define ed_shift_bac 0b10000 //бит для очистки выделеного shift т.е. при установке говорит что есть выделение
#define ed_shift_bac_cl 0b1111111111101111 //очистка при удалении выделения
#define ed_shift_cl 0b1111111111100011
#define ed_shift_mcl 0b1111111111111011
#define ed_left_fl 0b100000
#define ed_right_fl 0b1111111111011111
#define ed_offset_fl 0b1000000
#define ed_offset_cl 0b1111111110111111
#define ed_insert 0b10000000
#define ed_insert_cl 0b1111111101111111
#define ed_mouse_on 0b100000000
#define ed_mous_adn_b 0b100011000
#define ed_mouse_off ~ed_mouse_on
#define ed_ctrl_on 0b1000000000
#define ed_ctrl_off ~ed_ctrl_on
#define ed_alt_on 0b10000000000
#define ed_alt_off ~ed_alt_on
#define ed_disabled 0b100000000000
// SCROLLBAR
typedef struct {
uint16_t xsize;
uint16_t xpos;
uint16_t ysize;
uint16_t ypos;
uint32_t btn_height;
uint32_t type; // type 1 - stylish frame, type 2 - ?, type 0 - ?
uint32_t max_area;
uint32_t cur_area;
uint32_t position;
uint32_t back_color;
uint32_t front_color;
uint32_t line_color;
uint32_t redraw;
uint16_t delta;
uint16_t delta2;
uint16_t r_size_x;
uint16_t r_start_x;
uint16_t r_size_y;
uint16_t r_start_y;
uint32_t m_pos;
uint32_t m_pos2;
uint32_t m_keys;
uint32_t run_size;
uint32_t position2;
uint32_t work_size;
uint32_t all_redraw; // need to be set =1 before each redraw
uint32_t ar_offset;
} __attribute__((__packed__)) scrollbar;
DLLAPI void __stdcall scrollbar_h_draw(scrollbar*);
DLLAPI void __stdcall scrollbar_h_mouse(scrollbar*);
DLLAPI void __stdcall scrollbar_v_draw(scrollbar*);
DLLAPI void __stdcall scrollbar_v_mouse(scrollbar*);
// CHECKBOX
typedef struct {
unsigned int left_s;
unsigned int top_s;
unsigned int ch_text_margin;
unsigned int color;
unsigned int border_color;
unsigned int text_color;
char* text;
unsigned int flags;
/* Users can use members above this */
unsigned int size_of_str;
} check_box;
DLLAPI void __stdcall check_box_draw2(check_box*);
DLLAPI void __stdcall check_box_mouse2(check_box*);
DLLAPI void __stdcall init_checkbox2(check_box*);
// DBUTTON
typedef struct {
uint32_t type;
uint32_t x_w;
uint32_t y_h;
uint32_t mouse_pos;
uint32_t mouse_keys;
uint32_t mouse_keys_old;
void* active_raw; //active bitmap
void* passive_raw; //passive bitmap
void* click_raw; //pressed bitmap
uint32_t resolution_raw; // bpp, as esi fn65
void* palette_raw; // palette, as edi fn65
uint32_t offset_raw; // width as ebp fn65
uint32_t select; // internal state: 0 - passive, 2 - pressed, 1 - clicked
uint32_t click; // clicked - 1, zero it after tested
} pict_button;
DLLAPI void __stdcall dynamic_button_draw(pict_button*);
DLLAPI void __stdcall dynamic_button_mouse(pict_button*);
// EDITBOX
#pragma pack(push, 1)
typedef struct edit_box_t {
unsigned int width;
unsigned int left;
unsigned int top;
unsigned int color;
unsigned int shift_color; // selected text color
unsigned int focus_border_color;
unsigned int blur_border_color;
unsigned int text_color;
unsigned int max;
char* text;
void* mouse_variable; // must be pointer edit_box** to save focused editbox
unsigned int flags;
unsigned int size; // used symbols in buffer without trailing zero
unsigned int pos; // cursor position
/* The following struct members are not used by the users of API */
unsigned int offset;
unsigned int cl_curs_x;
unsigned int cl_curs_y;
unsigned int shift;
unsigned int shift_old;
unsigned int height;
unsigned int char_width;
} edit_box;
#pragma pack(pop)
DLLAPI void __stdcall edit_box_draw(edit_box*);
DLLAPI void __stdcall edit_box_key(edit_box*, unsigned int key_val);
DLLAPI void __stdcall edit_box_mouse(edit_box*);
DLLAPI void __stdcall edit_box_set_text(edit_box*, char*);
DLLAPI void __stdcall edit_box_key_safe(edit_box* e, ksys_oskey_t ch);
// FRAME
typedef struct {
uint32_t type;
uint32_t x_w;
uint32_t y_h;
color_t ext_col;
color_t int_col;
uint32_t flags;
char* text_pointer;
uint32_t text_position;
uint32_t font_number;
uint32_t font_size_y;
color_t font_color;
color_t font_bg_color;
} frame;
DLLAPI void __stdcall frame_draw(frame*);
// MENUBAR
typedef struct
{
uint32_t type; // 1 åñëè íåò ïîäìåíþ, ïðîñòî ïóíêò
uint32_t x_w; // âåðõíèé ïóíêò
uint32_t y_h;
char* text_pointer;
char* pos_pointer;
char* text_end;
uint32_t mouse_pos;
uint32_t mouse_keys;
uint32_t x_w1; // ïîäìåíþ
uint32_t y_h1;
color_t bckg_col; // ôîí âåðõíåãî ïóêòà
color_t frnt_col; // ôîí âûáðàííîãî âåðõíåãî ïóíêòà
color_t menu_col; // ôîí âûïàäàþùåé ÷àñòè (ïîäïóêòû)
uint32_t select;
uint32_t out_select;
char* buf_adress;
char* procinfo;
uint32_t click;
uint32_t cursor;
uint32_t cursor_old;
uint32_t interval;
uint32_t cursor_max;
uint32_t extended_key;
color_t menu_sel_col; // öâåò ôîíà âûáðàííîãî ïîäïóíêòà
color_t bckg_text_col; // öâåò øðèôòà íåâûáðàííîãî ïóíêòà
color_t frnt_text_col; // öâåò øðèôòà âûáðàííîãî ïóíêòà
uint32_t mouse_keys_old;
uint32_t font_height;
uint32_t cursor_out;
uint32_t get_mouse_flag;
} menubar;
DLLAPI void __stdcall menu_bar_draw(menubar*);
DLLAPI void __stdcall menu_bar_mouse(menubar*);
DLLAPI void __stdcall menu_bar_activate(menubar*);
// OPTIONBOX
typedef struct option_box_t {
struct option_box_t** selected;
uint16_t posx;
uint16_t posy;
uint32_t text_margin; // = 4 ðàññòîÿíèå îò ïðÿìîóãîëüíèêà ÷åê áîêñà äî íàäïèñè
uint32_t size; // 12 ðàçìåð êâàäðàòà ÷åê áîêñà
color_t color;
color_t border_color; // individual border
color_t text_color;
char* text;
uint32_t text_len;
uint32_t flags;
} __attribute__((__packed__)) option_box;
DLLAPI void __stdcall option_box_draw(option_box**);
DLLAPI void __stdcall option_box_mouse(option_box**);
// PATHSHOW
typedef struct {
uint32_t type;
uint32_t x_y;
uint16_t font_size_x; // 6 - for font 0, 8 - for font 1
uint16_t area_size_x;
uint32_t font_number; // 0 - monospace, 1 - variable, as fn4 (2bit only 0-3)
uint32_t background_flag; // as fn4, if 0, bk_color unneeded
color_t font_color; // as fn4
color_t background_color; // as fn4
char* text_pointer; // 4096 ?
char* work_area_pointer; // 4096 ?
uint32_t temp_text_length;
} __attribute__((__packed__)) pathview;
DLLAPI void __stdcall path_show_prepare(pathview*);
DLLAPI void __stdcall path_show_draw(pathview*);
// PROGRESSBAR
typedef struct {
unsigned int value;
unsigned int left;
unsigned int top;
unsigned int width;
unsigned int height;
unsigned int style;
unsigned int min;
unsigned int max;
unsigned int back_color;
unsigned int progress_color;
unsigned int frame_color;
} progressbar;
DLLAPI void __stdcall progressbar_draw(progressbar*);
DLLAPI void __stdcall progressbar_progress(progressbar*);
#endif /* KOLIBRI_BOXLIB_H */

View File

@@ -0,0 +1,81 @@
#ifndef KOLIBRI_BUF2D_H
#define KOLIBRI_BUF2D_H
#include <stddef.h>
#include <stdint.h>
#include <sys/ksys.h>
typedef struct {
unsigned int* buf_pointer;
uint16_t left;
uint16_t top;
unsigned int width;
unsigned int height;
unsigned int bgcolor;
uint8_t color_bit;
} __attribute__((__packed__)) buf2d_struct;
enum BUF2D_ALGORITM_FILTR {
SIERRA_LITE,
FLOYD_STEINBERG,
BURKERS,
HEAVYIRON_MOD,
ATKINSON
};
enum BUF2D_OPT_CROP {
BUF2D_OPT_CROP_TOP = 1,
BUF2D_OPT_CROP_LEFT = 2,
BUF2D_OPT_CROP_BOTTOM = 4,
BUF2D_OPT_CROP_RIGHT = 8
};
DLLAPI void __stdcall buf2d_create_asm(buf2d_struct*);
DLLAPI 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*)_ksys_alloc(sizeof(buf2d_struct));
new_buf2d_struct->left = tlx;
new_buf2d_struct->top = tly;
new_buf2d_struct->width = sizex;
new_buf2d_struct->height = sizey;
new_buf2d_struct->bgcolor = font_bgcolor;
new_buf2d_struct->color_bit = color_bit;
buf2d_create_asm(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)
{
buf2d_curve_bezier_asm(buf, (p0_x << 16) + p0_y, (p1_x << 16) + p1_y, (p2_x << 16) + p2_y, color);
}
DLLAPI void __stdcall buf2d_draw(buf2d_struct*);
DLLAPI void __stdcall buf2d_clear(buf2d_struct*, unsigned int);
DLLAPI void __stdcall buf2d_delete(buf2d_struct*);
DLLAPI void __stdcall buf2d_rotate(buf2d_struct*, unsigned int);
DLLAPI void __stdcall buf2d_resize(buf2d_struct*, unsigned int, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_line(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_line_sm(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_rect_by_size(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_filled_rect_by_size(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_circle(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_img_hdiv2(buf2d_struct*);
DLLAPI void __stdcall buf2d_img_wdiv2(buf2d_struct*);
DLLAPI void __stdcall buf2d_conv_24_to_8(buf2d_struct*, unsigned int);
DLLAPI void __stdcall buf2d_conv_24_to_32(buf2d_struct*, unsigned int);
DLLAPI void __stdcall buf2d_bit_blt_transp(buf2d_struct*, unsigned int, unsigned int, buf2d_struct*);
DLLAPI void __stdcall buf2d_bit_blt_alpha(buf2d_struct*, unsigned int, unsigned int, buf2d_struct*);
DLLAPI void __stdcall buf2d_convert_text_matrix(buf2d_struct*);
DLLAPI void __stdcall buf2d_draw_text(buf2d_struct*, buf2d_struct*, const char*, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_crop_color(buf2d_struct*, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_offset_h(buf2d_struct*, unsigned int, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_flood_fill(buf2d_struct*, unsigned int, unsigned int, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_set_pixel(buf2d_struct*, unsigned int, unsigned int, unsigned int);
DLLAPI unsigned __stdcall buf2d_get_pixel(buf2d_struct*, unsigned int, unsigned int);
DLLAPI void __stdcall buf2d_flip_h(buf2d_struct*);
DLLAPI void __stdcall buf2d_flip_v(buf2d_struct*);
DLLAPI void __stdcall buf2d_filter_dither(buf2d_struct*, unsigned int);
#endif /* KOLIBRI_BUF2D_H */

View File

@@ -0,0 +1,124 @@
#ifndef KOLIBRI_DIALOG_H
#define KOLIBRI_DIALOG_H
#include <stdlib.h>
#define NOT_SUCCESS 0
#define SUCCESS 1
char sz_com_area_name[] = "FFFFFFFF_open_dialog";
char sz_dir_default_path[] = "/sys";
char sz_start_path[] = "/sys/File managers/opendial";
char cd_com_area_name[] = "FFFFFFFF_color_dialog";
char cd_start_path[] = "/sys/colrdial";
enum open_dialog_mode {
OPEN,
SAVE,
SELECT
};
typedef struct {
unsigned int size;
unsigned char end;
} od_filter __attribute__((__packed__));
typedef struct {
unsigned int mode;
char* procinfo;
char* com_area_name;
unsigned int com_area;
char* opendir_path;
char* dir_default_path;
char* start_path;
void (*draw_window)();
unsigned int status;
char* openfile_path;
char* filename_area;
od_filter* filter_area;
unsigned short x_size;
unsigned short x_start;
unsigned short y_size;
unsigned short y_start;
} open_dialog __attribute__((__packed__));
typedef struct {
unsigned int type;
char* procinfo;
char* com_area_name;
unsigned int com_area;
char* start_path;
void (*draw_window)(void);
unsigned int status;
unsigned short x_size;
unsigned short x_start;
unsigned short y_size;
unsigned short y_start;
unsigned int color_type;
unsigned int color;
} color_dialog __attribute__((__packed__));
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* new_opendialog = (open_dialog*)malloc(sizeof(open_dialog));
od_filter* new_od_filter = (od_filter*)malloc(sizeof(od_filter));
char* plugin_path = (char*)calloc(4096, sizeof(char));
char* openfile_path = (char*)calloc(4096, sizeof(char));
char* proc_info = (char*)calloc(1024, sizeof(char));
char* filename_area = (char*)calloc(256, sizeof(char));
new_od_filter->size = 0;
new_od_filter->end = 0;
new_opendialog->mode = mode;
new_opendialog->procinfo = proc_info;
new_opendialog->com_area_name = sz_com_area_name;
new_opendialog->com_area = 0;
new_opendialog->opendir_path = plugin_path;
new_opendialog->dir_default_path = sz_dir_default_path;
new_opendialog->start_path = sz_start_path;
new_opendialog->draw_window = &fake_on_redraw;
new_opendialog->status = 0;
new_opendialog->openfile_path = openfile_path;
new_opendialog->filename_area = filename_area;
new_opendialog->filter_area = new_od_filter;
new_opendialog->x_size = x_size;
new_opendialog->x_start = tlx;
new_opendialog->y_size = y_size;
new_opendialog->y_start = tly;
return new_opendialog;
}
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* new_colordialog = (color_dialog*)malloc(sizeof(color_dialog));
char* proc_info = (char*)calloc(1024, sizeof(char));
new_colordialog->type = type;
new_colordialog->procinfo = proc_info;
new_colordialog->com_area_name = cd_com_area_name;
new_colordialog->com_area = 0;
new_colordialog->start_path = cd_start_path;
new_colordialog->draw_window = &cd_fake_on_redraw;
new_colordialog->status = 0;
new_colordialog->x_size = x_size;
new_colordialog->x_start = tlx;
new_colordialog->y_size = y_size;
new_colordialog->y_start = tly;
new_colordialog->color_type = 0;
new_colordialog->color = 0;
return new_colordialog;
}
DLLAPI void __stdcall OpenDialog_init(open_dialog*);
DLLAPI void __stdcall OpenDialog_start(open_dialog*);
DLLAPI void __stdcall ColorDialog_init(color_dialog*);
DLLAPI void __stdcall ColorDialog_start(color_dialog*);
#endif

View File

@@ -0,0 +1,23 @@
#ifndef KOLIBRI_GB_H
#define KOLIBRI_GB_H
#pragma pack(push, 1)
typedef struct
{
int w;
int h;
char* bmp;
char* alpha;
} GB_BMP;
#pragma pack(pop)
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);
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_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

@@ -0,0 +1,152 @@
/*
This is adapded thunk for http.obj sys library
.h is equal to svn:\\programs\develop\libraries\http\http_en.txt
Adapted for TCC's dynamic API by Magomed Kostoev, 2020
*/
#ifndef KOLIBRI_HTTP_H
#define KOLIBRI_HTTP_H
#include <stddef.h>
// Bitflags for http_msg.flags
// status
#define HTTP_FLAG_HTTP11 1 << 0
#define HTTP_FLAG_GOT_HEADER 1 << 1
#define HTTP_FLAG_GOT_ALL_DATA 1 << 2
#define HTTP_FLAG_CONTENT_LENGTH 1 << 3
#define HTTP_FLAG_CHUNKED 1 << 4
#define HTTP_FLAG_CONNECTED 1 << 5
// user options
#define HTTP_FLAG_KEEPALIVE 1 << 8
#define HTTP_FLAG_STREAM 1 << 9
#define HTTP_FLAG_REUSE_BUFFER 1 << 10
#define HTTP_FLAG_BLOCK 1 << 11
// error
#define HTTP_FLAG_INVALID_HEADER 1 << 16
#define HTTP_FLAG_NO_RAM 1 << 17
#define HTTP_FLAG_SOCKET_ERROR 1 << 18
#define HTTP_FLAG_TIMEOUT_ERROR 1 << 19
#define HTTP_FLAG_TRANSFER_FAILED 1 << 20
/*
User flags:
For the flag codes themselves, see http.inc file.
FLAG_KEEPALIVE will keep the connection open after first GET/POST/.. so you can send a second request on the same TCP session.
In this case, the session must be closed manually when done by using the exported disconnect() function.
FLAG_STREAM will force receive() to put the received content in a series of fixed size buffers, instead of everything in one big buffer.
This can be used for example to receive an internet radio stream,
but also to download larger files for which it does not make sense to put them completely in RAM first.
FLAG_REUSE_BUFFER is to be used in combination with FLAG_STREAM and will make receive() function re-use the same buffer.
This, for example, can be used when downloading a file straight to disk.
FLAG_BLOCK will make receive() function blocking. This is only to be used when receiving one file from a thread that has no other work.
If however, you want to receive multiple files, or do other things in the program mainloop, you should call the receive function periodically.
You may use system function 10 or 23 to wait for network event before calling one or more receive() functions.
*/
#pragma pack(push,1)
typedef struct http_msg_s {
unsigned socket; // socket on which the actual transfer happens
unsigned flags; // flags, reflects status of the transfer using bitflags
unsigned write_ptr; // internal use only (where to write new data in buffer)
unsigned buffer_length; // internal use only (number of available bytes in buffer)
unsigned chunk_ptr; // internal use only (where the next chunk begins)
unsigned timestamp; // internal use only (when last data was received)
unsigned status; // HTTP status
unsigned header_length; // length of HTTP header
void * content_ptr; // ptr to content
unsigned content_length; // total length of HTTP content
unsigned content_received; // number of currently received content bytes
char * http_header;
} http_msg;
#pragma pack(pop)
/*
url = pointer to ASCIIZ URL
identifier = identifier of previously opened connection (keep-alive), or 0 to open a new one.
flags = bit flags (see end of this document).
add_header = pointer to ASCIIZ additional header parameters, or null for none.
Every additional parameter must end with CR LF bytes, including the last line.
Initiates a HTTP connection, using 'GET' method.
Returns NULL on error, identifier otherwise.
*/
DLLAPI http_msg * __stdcall http_get(const char *url, http_msg *identifier, unsigned flags, const char *add_header);
/*
url = pointer to ASCIIZ URL
identifier = identifier of previously opened connection (keep-alive), or 0 to open a new one.
flags = bit flags (see end of this document).
add_header = pointer to ASCIIZ additional header parameters, or null for none.
Every additional parameter must end with CR LF bytes, including the last line.
Initiate a HTTP connection, using 'HEAD' method.
Returns NULL on error, identifier otherwise.
*/
DLLAPI http_msg * __stdcall http_head(const char *url, http_msg *identifier, unsigned flags, const char *add_header);
/*
url = pointer to ASCIIZ URL
identifier = identifier of previously opened connection (keep-alive), or 0 to open a new one.
flags = bit flags (see end of this document).
add_header = pointer to ASCIIZ additional header parameters, or null for none.
Every additional parameter must end with CR LF bytes, including the last line.
content-type = pointer to ASCIIZ string containing content type.
content-length = length of the content (in bytes).
Initiate a HTTP connection, using 'POST' method.
The content itself must be send to the socket (which you can find in the structure),
using system function 75, 6.
Returns 0 on error, identifier otherwise
*/
DLLAPI http_msg * __stdcall http_post(const char *url, http_msg *identifier, unsigned flags, const char *add_header,
const char *content_type, unsigned content_length);
/*
identifier = identifier which one of the previous functions returned
This procedure will handle all incoming data for a connection and place it in the buffer.
As long as the procedure expects more data, -1 is returned and the procedure must be called again.
When transfer is done, the procedure will return 0.
The receive procedure is non-blocking by default, but can be made to block by setting FLAG_BLOCK.
The HTTP header is placed together with some flags and other attributes in the http_msg structure.
This structure is defined in http.inc (and not copied here because it might still change.)
The identifier used by the functions is actually a pointer to this structure.
In the dword named .flags, the library will set various bit-flags indicating the status of the process.
(When a transfer is done, one should check these bit-flags to find out if the transfer was error-free.)
The HTTP header is placed at the end of this structure. The content is placed in another buffer.
The dword .status contains the status code received from the server (e.g. 200 for OK).
In header_length you'll find the length of the header as soon as it has been received.
In content_ptr you'll find a pointer to the actual content.
In content_length you'll find the length of the content.
In content_received, you'll find the number of content bytes already received.
*/
DLLAPI int __stdcall http_receive(http_msg *identifier);
/*
identifier = identifier which one of the previous functions returned
dataptr = pointer to the data you want to send
datalength = length of the data to send (in bytes)
This procedure can be used to send data to the server (POST)
Returns number of bytes sent, -1 on error
*/
DLLAPI 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:
*/
DLLAPI int __stdcall http_free(http_msg *identifier);
/*
Free unused data
*/
#define http_long_receive(x) while(http_receive(x)){};
#endif // KOLIBRI_HTTP_H

View File

@@ -0,0 +1,16 @@
/*
This is wrapper for Inputbox.obj sys library
https://board.kolibrios.org/viewtopic.php?f=24&t=3767&sid=fd2ca95b24eec430db0c61d977f5d8ba#p71585
Adapted for TCC's dynamic API by Magomed Kostoev, 2020
*/
#ifndef KOLIBRI_INPUTBOX_H
#define KOLIBRI_INPUTBOX_H
#include <stddef.h>
DLLAPI unsigned __stdcall InputBox(void* Buffer, char* Caption, char* Prompt, char* Default,
unsigned long Flags, unsigned long BufferSize, void* RedrawProc);
#endif // KOLIBRI_INPUTBOX_H

View File

@@ -0,0 +1,124 @@
/* Written by turbocat2001 (Logaev Maxim) */
#ifndef KOLIBRI_LIBIMG_H
#define KOLIBRI_LIBIMG_H
#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>
//list of format id's
#define LIBIMG_FORMAT_BMP 1
#define LIBIMG_FORMAT_ICO 2
#define LIBIMG_FORMAT_CUR 3
#define LIBIMG_FORMAT_GIF 4
#define LIBIMG_FORMAT_PNG 5
#define LIBIMG_FORMAT_JPEG 6
#define LIBIMG_FORMAT_TGA 7
#define LIBIMG_FORMAT_PCX 8
#define LIBIMG_FORMAT_XCF 9
#define LIBIMG_FORMAT_TIFF 10
#define LIBIMG_FORMAT_PNM 11
#define LIBIMG_FORMAT_WBMP 12
#define LIBIMG_FORMAT_XBM 13
#define LIBIMG_FORMAT_Z80 14
#pragma pack(push, 1)
typedef struct{
uint32_t Checksum; // ((Width ROL 16) OR Height) XOR Data[0] ; ignored so far
uint32_t Width;
uint32_t Height;
uint32_t Next;
uint32_t Previous;
uint32_t Type; // one of Image.bppN
uint32_t* Data;
uint32_t Palette; // used iff Type eq Image.bpp1, Image.bpp2, Image.bpp4 or Image.bpp8i
uint32_t Extended;
uint32_t Flags; // bitfield
uint32_t Delay; // used iff Image.IsAnimated is set in Flags
} Image;
#pragma pack(pop)
#define IMAGE_BPP8i 1 // indexed
#define IMAGE_BPP24 2
#define IMAGE_BPP32 3
#define IMAGE_BPP15 4
#define IMAGE_BPP16 5
#define IMAGE_BPP1 6
#define IMAGE_BPP8g 7 // grayscale
#define IMAGE_BPP2i 8
#define IMAGE_BPP4i 9
#define IMAGE_BPP8a 10
// scale type
#define LIBIMG_SCALE_NONE 0
#define LIBIMG_SCALE_INTEGER 1
#define LIBIMG_SCALE_TILE 2
#define LIBIMG_SCALE_STRETCH 3
#define LIBIMG_SCALE_FIT_BOTH LIBIMG_SCALE_STRETCH
#define LIBIMG_SCALE_FIT_MIN 4
#define LIBIMG_SCALE_FIT_RECT LIBIMG_SCALE_FIT_MIN
#define LIBIMG_SCALE_FIT_WIDTH 5
#define LIBIMG_SCALE_FIT_HEIGHT 6
#define LIBIMG_SCALE_FIT_MAX 7
// interpolation algorithm
#define LIBIMG_INTER_NONE 0 // use it with LIBIMG_SCALE_INTEGER, LIBIMG_SCALE_TILE, etc
#define LIBIMG_INTER_BILINEAR 1
#define LIBIMG_INTER_BICUBIC 2
#define LIBIMG_INTER_LANCZOS 3
#define LIBIMG_INTER_DEFAULT LIBIMG_INTER_BILINEAR
//error codes
#define LIBIMG_ERROR_OUT_OF_MEMORY 1
#define LIBIMG_ERROR_FORMAT 2
#define LIBIMG_ERROR_CONDITIONS 3
#define LIBIMG_ERROR_BIT_DEPTH 4
#define LIBIMG_ERROR_ENCODER 5
#define LIBIMG_ERROR_SRC_TYPE 6
#define LIBIMG_ERROR_SCALE 7
#define LIBIMG_ERROR_INTER 8
#define LIBIMG_ERROR_NOT_INPLEMENTED 9
#define LIBIMG_ERROR_INVALID_INPUT 10
//encode flags (byte 0x02 of _common option)
#define LIBIMG_ENCODE_STRICT_SPECIFIC 0x01
#define LIBIMG_ENCODE_STRICT_BIT_DEPTH 0x02
#define LIBIMG_ENCODE_DELETE_ALPHA 0x08
#define LIBIMG_ENCODE_FLUSH_ALPHA 0x10
#define FLIP_VERTICAL 0x01
#define FLIP_HORIZONTAL 0x02
#define ROTATE_90_CW 0x01
#define ROTATE_180 0x02
#define ROTATE_270_CW 0x03
#define ROTATE_90_CCW ROTATE_270_CW
#define ROTATE_270_CCW ROTATE_90_CW
DLLAPI Image* __stdcall img_decode(void* file_data, uint32_t size, uint32_t b_color);
DLLAPI Image* __stdcall img_encode(Image* img, uint32_t length, uint32_t option);
DLLAPI Image* __stdcall img_create(uint32_t width, uint32_t height, uint32_t type);
DLLAPI void __stdcall img_to_rgb2(Image* img, void *rgb_data);
DLLAPI Image* __stdcall img_to_rgb(Image* img);
DLLAPI bool __stdcall img_flip(Image* img, uint32_t flip);
DLLAPI bool __stdcall img_flip_layer(Image *img, uint32_t flip);
DLLAPI bool __stdcall img_rotate(Image *img, uint32_t rotate);
DLLAPI bool __stdcall img_rotate_layer(Image* data, uint32_t rotate);
DLLAPI void __stdcall img_draw(Image *img, uint32_t x, uint32_t y, uint32_t w, uint32_t h, uint32_t xoff, uint32_t yoff);
DLLAPI int32_t __stdcall img_count(Image *img);
DLLAPI bool __stdcall img_destroy(Image *img);
DLLAPI bool __stdcall img_destroy_layer(Image* img);
DLLAPI 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);
DLLAPI Image* __stdcall img_convert(Image *src, Image *dst, uint32_t dst_type, uint32_t, uint32_t);
DLLAPI Image* __stdcall img_resize_data(Image *src, uint32_t width, uint32_t height);
DLLAPI 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);
static void img_fill_color(Image* img, uint32_t width, uint32_t height, uint32_t color){
for (uint32_t i = 0; i < width*height; i++) {
img->Data[i] = color;
}
}
#endif /* KOLIBRI_LIBIMG_H */

View File

@@ -0,0 +1,56 @@
#ifndef KOLIBRI_MSGBOX_H
#define KOLIBRI_MSGBOX_H
#include <stdarg.h>
#include <stddef.h>
#include <stdint.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;
char texts[2048]; // must be enough ;-)
char msgbox_stack[1024];
uint32_t top_stack;
}__attribute__((packed)) msgbox;
typedef void (*msgbox_callback)(void);
DLLAPI void __stdcall mb_create(msgbox *, void *thread); // clears callbacks, ! if fix lib, we can return eax as of Fn51
DLLAPI void __stdcall mb_setfunctions(msgbox_callback*); // must be called immediately after create, zero-ended array
DLLAPI 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_start(vl, def_but);
msgbox* box = calloc(sizeof(msgbox), 1);
box->retval = (uint8_t)def_but;
char *pc = box->texts;
strcpy(pc, title);
pc += strlen(title) + 1;
strcpy(pc, text);
pc += strlen(text) + 1;
char *but_text = va_arg(vl, char*);
while (but_text)
{
strcpy(pc, but_text);
pc += strlen(but_text) + 1;
but_text = va_arg(vl, char*);
}
va_end(vl);
return box;
}
static inline void kolibri_start_msgbox(msgbox* box, msgbox_callback cb[])
{
mb_create(box, &box->top_stack);
if (cb) mb_setfunctions(cb);
}
#endif

View File

@@ -0,0 +1,54 @@
#ifndef KOLIBRI_NETWORK_H
#define KOLIBRI_NETWORK_H
#include <sys/socket.h>
#include <sys/ksys.h>
#define EAI_ADDRFAMILY 1
#define EAI_AGAIN 2
#define EAI_BADFLAGS 3
#define EAI_FAIL 4
#define EAI_FAMILY 5
#define EAI_MEMORY 6
#define EAI_NONAME 8
#define EAI_SERVICE 9
#define EAI_SOCKTYPE 10
#define EAI_BADHINTS 12
#define EAI_PROTOCOL 13
#define EAI_OVERFLOW 14
// Flags for addrinfo
#define AI_PASSIVE 1
#define AI_CANONNAME 2
#define AI_NUMERICHOST 4
#define AI_NUMERICSERV 8
#define AI_ADDRCONFIG 0x400
#pragma pack(push, 1)
struct ARP_entry{
unsigned int IP;
unsigned char MAC[6];
unsigned short status;
unsigned short TTL;
};
#pragma pack(pop)
#pragma pack(push, 1)
struct addrinfo {
int ai_flags;
int ai_family;
int ai_socktype;
int ai_protocol;
int ai_addrlen;
char *ai_canonname;
struct sockaddr *ai_addr;
struct addrinfo *ai_next;
};
#pragma pack(pop)
DLLAPI int __stdcall inet_addr(const char* hostname);
DLLAPI char* __stdcall inet_ntoa(int ip_addr);
DLLAPI int __stdcall getaddrinfo(const char* hostname, const char* servname, const struct addrinfo* hints, struct addrinfo** res);
DLLAPI void __stdcall freeaddrinfo(struct addrinfo* ai);
#endif

View File

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