libc.obj is now the default libc for tcc

git-svn-id: svn://kolibrios.org@8796 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
turbocat 2021-06-10 14:53:38 +00:00
parent f88a509b93
commit d7eea62637
19 changed files with 1260 additions and 0 deletions

View File

@ -0,0 +1,265 @@
// writed by maxcodehack and superturbocat2001
// adaptation of clayer for ktcc
#ifndef KOLIBRI_BOXLIB_H
#define KOLIBRI_BOXLIB_H
typedef unsigned color_t;
extern int kolibri_boxlib_init(void);
/* 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;
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*);
// 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;
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 *);
// 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;
extern void (*dynamic_button_draw __attribute__((__stdcall__)))(pict_button *);
extern void (*dynamic_button_mouse __attribute__((__stdcall__)))(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)
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 *);
// 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;
extern void (*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;
extern void (*menu_bar_draw)(menubar *);
extern void (*menu_bar_mouse)(menubar *);
extern void (*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;
extern void (*option_box_draw __attribute__((__stdcall__)))(option_box **);
extern void (*option_box_mouse __attribute__((__stdcall__)))(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;
extern void (*path_show_prepare __attribute__((__stdcall__)))(pathview *);
extern void (*path_show_draw __attribute__((__stdcall__)))(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;
extern void (*progressbar_draw __attribute__((__stdcall__)))(progressbar *);
extern void (*progressbar_progress __attribute__((__stdcall__)))(progressbar *);
#endif /* KOLIBRI_BOXLIB_H */

View File

@ -0,0 +1,83 @@
#ifndef KOLIBRI_BUF2D_H
#define KOLIBRI_BUF2D_H
#include <stdint.h>
/*ToDo
* voxel function
*/
extern int kolibri_buf2d_init(void);
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
};
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);
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));
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);
}
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);
#endif /* KOLIBRI_BUF2D_H */

View File

@ -0,0 +1,126 @@
#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[] = "/rd/1";
char sz_start_path[] = "/rd/1/File managers/opendial";
char cd_com_area_name[] = "FFFFFFFF_color_dialog";
char cd_start_path[] = "/rd/1/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;
}
extern void kolibri_dialog_init();
extern void (*OpenDialog_init __attribute__((__stdcall__)))(open_dialog *);
extern void (*OpenDialog_start __attribute__((__stdcall__)))(open_dialog *);
extern void (*ColorDialog_init __attribute__((__stdcall__)))(color_dialog *);
extern void (*ColorDialog_start __attribute__((__stdcall__)))(color_dialog *);
#endif

View File

@ -0,0 +1,19 @@
#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);

View File

@ -0,0 +1,153 @@
/*
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 _HTTP_H_
#define _HTTP_H_
#define cdecl __attribute__ ((cdecl))
#define stdcall __attribute__ ((stdcall))
// 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.
*/
extern 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.
*/
extern 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
*/
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);
/*
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.
*/
extern 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
*/
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);
/*
Free unused data
*/
#define http_long_receive(x) while(http_receive(x)){};
#endif // _HTTP_H_

View File

@ -0,0 +1,17 @@
/*
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 __KOS__INPUTBOX__H________
#define __KOS__INPUTBOX__H________
#define cdecl __attribute__ ((cdecl))
#define stdcall __attribute__ ((stdcall))
extern unsigned stdcall (*InputBox)(void* Buffer, char* Caption, char* Prompt, char* Default,
unsigned long Flags, unsigned long BufferSize, void* RedrawProc);
#endif // __KOS__INPUTBOX__H________

View File

@ -0,0 +1,126 @@
/* Written by turbocat2001 (Logaev Maxim) */
#ifndef KOLIBRI_LIBIMG_H
#define KOLIBRI_LIBIMG_H
#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
#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
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);
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,55 @@
#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;
char texts[2048]; // must be enough ;-)
char msgbox_stack[1024];
uint32_t top_stack;
}__attribute__((packed)) msgbox;
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
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[])
{
(*msgbox_create)(box, &box->top_stack);
if (cb) (*msgbox_setfunctions)(cb);
}
#endif

View File

@ -0,0 +1,11 @@
#ifndef KOLIBRI_RASTERWORKS_H
#define KOLIBRI_RASTERWORKS_H
//extern int kolibri_rasterworks_init(void);
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);
#endif /* KOLIBRI_RASTERWORKS_H */

View File

@ -0,0 +1,123 @@
/*********************************************************************
* Filename: aes.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding AES implementation.
*********************************************************************/
#ifndef AES_H
#define AES_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/****************************** MACROS ******************************/
#define AES_BLOCK_SIZE 16 // AES operates on 16 bytes at a time
/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE; // 8-bit byte
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
/*********************** FUNCTION DECLARATIONS **********************/
///////////////////
// AES
///////////////////
// Key setup must be done before any AES en/de-cryption functions can be used.
void aes_key_setup(const BYTE key[], // The key, must be 128, 192, or 256 bits
WORD w[], // Output key schedule to be used later
int keysize); // Bit length of the key, 128, 192, or 256
void aes_encrypt(const BYTE in[], // 16 bytes of plaintext
BYTE out[], // 16 bytes of ciphertext
const WORD key[], // From the key setup
int keysize); // Bit length of the key, 128, 192, or 256
void aes_decrypt(const BYTE in[], // 16 bytes of ciphertext
BYTE out[], // 16 bytes of plaintext
const WORD key[], // From the key setup
int keysize); // Bit length of the key, 128, 192, or 256
///////////////////
// AES - CBC
///////////////////
int aes_encrypt_cbc(const BYTE in[], // Plaintext
size_t in_len, // Must be a multiple of AES_BLOCK_SIZE
BYTE out[], // Ciphertext, same length as plaintext
const WORD key[], // From the key setup
int keysize, // Bit length of the key, 128, 192, or 256
const BYTE iv[]); // IV, must be AES_BLOCK_SIZE bytes long
// Only output the CBC-MAC of the input.
int aes_encrypt_cbc_mac(const BYTE in[], // plaintext
size_t in_len, // Must be a multiple of AES_BLOCK_SIZE
BYTE out[], // Output MAC
const WORD key[], // From the key setup
int keysize, // Bit length of the key, 128, 192, or 256
const BYTE iv[]); // IV, must be AES_BLOCK_SIZE bytes long
///////////////////
// AES - CTR
///////////////////
void increment_iv(BYTE iv[], // Must be a multiple of AES_BLOCK_SIZE
int counter_size); // Bytes of the IV used for counting (low end)
void aes_encrypt_ctr(const BYTE in[], // Plaintext
size_t in_len, // Any byte length
BYTE out[], // Ciphertext, same length as plaintext
const WORD key[], // From the key setup
int keysize, // Bit length of the key, 128, 192, or 256
const BYTE iv[]); // IV, must be AES_BLOCK_SIZE bytes long
void aes_decrypt_ctr(const BYTE in[], // Ciphertext
size_t in_len, // Any byte length
BYTE out[], // Plaintext, same length as ciphertext
const WORD key[], // From the key setup
int keysize, // Bit length of the key, 128, 192, or 256
const BYTE iv[]); // IV, must be AES_BLOCK_SIZE bytes long
///////////////////
// AES - CCM
///////////////////
// Returns True if the input parameters do not violate any constraint.
int aes_encrypt_ccm(const BYTE plaintext[], // IN - Plaintext.
WORD plaintext_len, // IN - Plaintext length.
const BYTE associated_data[], // IN - Associated Data included in authentication, but not encryption.
unsigned short associated_data_len, // IN - Associated Data length in bytes.
const BYTE nonce[], // IN - The Nonce to be used for encryption.
unsigned short nonce_len, // IN - Nonce length in bytes.
BYTE ciphertext[], // OUT - Ciphertext, a concatination of the plaintext and the MAC.
WORD *ciphertext_len, // OUT - The length of the ciphertext, always plaintext_len + mac_len.
WORD mac_len, // IN - The desired length of the MAC, must be 4, 6, 8, 10, 12, 14, or 16.
const BYTE key[], // IN - The AES key for encryption.
int keysize); // IN - The length of the key in bits. Valid values are 128, 192, 256.
// Returns True if the input parameters do not violate any constraint.
// Use mac_auth to ensure decryption/validation was preformed correctly.
// If authentication does not succeed, the plaintext is zeroed out. To overwride
// this, call with mac_auth = NULL. The proper proceedure is to decrypt with
// authentication enabled (mac_auth != NULL) and make a second call to that
// ignores authentication explicitly if the first call failes.
int aes_decrypt_ccm(const BYTE ciphertext[], // IN - Ciphertext, the concatination of encrypted plaintext and MAC.
WORD ciphertext_len, // IN - Ciphertext length in bytes.
const BYTE assoc[], // IN - The Associated Data, required for authentication.
unsigned short assoc_len, // IN - Associated Data length in bytes.
const BYTE nonce[], // IN - The Nonce to use for decryption, same one as for encryption.
unsigned short nonce_len, // IN - Nonce length in bytes.
BYTE plaintext[], // OUT - The plaintext that was decrypted. Will need to be large enough to hold ciphertext_len - mac_len.
WORD *plaintext_len, // OUT - Length in bytes of the output plaintext, always ciphertext_len - mac_len .
WORD mac_len, // IN - The length of the MAC that was calculated.
int *mac_auth, // OUT - TRUE if authentication succeeded, FALSE if it did not. NULL pointer will ignore the authentication.
const BYTE key[], // IN - The AES key for decryption.
int keysize); // IN - The length of the key in BITS. Valid values are 128, 192, 256.
///////////////////
// Test functions
///////////////////
int aes_test();
int aes_ecb_test();
int aes_cbc_test();
int aes_ctr_test();
int aes_ccm_test();
#endif // AES_H

View File

@ -0,0 +1,30 @@
/*********************************************************************
* Filename: arcfour.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding ARCFOUR implementation.
*********************************************************************/
#ifndef ARCFOUR_H
#define ARCFOUR_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE; // 8-bit byte
/*********************** FUNCTION DECLARATIONS **********************/
// Input: state - the state used to generate the keystream
// key - Key to use to initialize the state
// len - length of key in bytes (valid lenth is 1 to 256)
void arcfour_key_setup(BYTE state[], const BYTE key[], int len);
// Pseudo-Random Generator Algorithm
// Input: state - the state used to generate the keystream
// out - Must be allocated to be of at least "len" length
// len - number of bytes to generate
void arcfour_generate_stream(BYTE state[], BYTE out[], size_t len);
#endif // ARCFOUR_H

View File

@ -0,0 +1,27 @@
/*********************************************************************
* Filename: base64.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding Base64 implementation.
*********************************************************************/
#ifndef BASE64_H
#define BASE64_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE; // 8-bit byte
/*********************** FUNCTION DECLARATIONS **********************/
// Returns the size of the output. If called with out = NULL, will just return
// the size of what the output would have been (without a terminating NULL).
size_t base64_encode(const BYTE in[], BYTE out[], size_t len, int newline_flag);
// Returns the size of the output. If called with out = NULL, will just return
// the size of what the output would have been (without a terminating NULL).
size_t base64_decode(const BYTE in[], BYTE out[], size_t len);
#endif // BASE64_H

View File

@ -0,0 +1,32 @@
/*********************************************************************
* Filename: blowfish.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding Blowfish implementation.
*********************************************************************/
#ifndef BLOWFISH_H
#define BLOWFISH_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/****************************** MACROS ******************************/
#define BLOWFISH_BLOCK_SIZE 8 // Blowfish operates on 8 bytes at a time
/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE; // 8-bit byte
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
typedef struct {
WORD p[18];
WORD s[4][256];
} BLOWFISH_KEY;
/*********************** FUNCTION DECLARATIONS **********************/
void blowfish_key_setup(const BYTE user_key[], BLOWFISH_KEY *keystruct, size_t len);
void blowfish_encrypt(const BYTE in[], BYTE out[], const BLOWFISH_KEY *keystruct);
void blowfish_decrypt(const BYTE in[], BYTE out[], const BLOWFISH_KEY *keystruct);
#endif // BLOWFISH_H

View File

@ -0,0 +1,37 @@
/*********************************************************************
* Filename: des.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding DES implementation.
Note that encryption and decryption are defined by how
the key setup is performed, the actual en/de-cryption is
performed by the same function.
*********************************************************************/
#ifndef DES_H
#define DESH
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/****************************** MACROS ******************************/
#define DES_BLOCK_SIZE 8 // DES operates on 8 bytes at a time
/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE; // 8-bit byte
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
typedef enum {
DES_ENCRYPT,
DES_DECRYPT
} DES_MODE;
/*********************** FUNCTION DECLARATIONS **********************/
void des_key_setup(const BYTE key[], BYTE schedule[][6], DES_MODE mode);
void des_crypt(const BYTE in[], BYTE out[], const BYTE key[][6]);
void three_des_key_setup(const BYTE key[], BYTE schedule[][16][6], DES_MODE mode);
void three_des_crypt(const BYTE in[], BYTE out[], const BYTE key[][16][6]);
#endif // DES_H

View File

@ -0,0 +1,33 @@
/*********************************************************************
* Filename: md2.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding MD2 implementation.
*********************************************************************/
#ifndef MD2_H
#define MD2_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/****************************** MACROS ******************************/
#define MD2_BLOCK_SIZE 16
/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE; // 8-bit byte
typedef struct {
BYTE data[16];
BYTE state[48];
BYTE checksum[16];
int len;
} MD2_CTX;
/*********************** FUNCTION DECLARATIONS **********************/
void md2_init(MD2_CTX *ctx);
void md2_update(MD2_CTX *ctx, const BYTE data[], size_t len);
void md2_final(MD2_CTX *ctx, BYTE hash[]); // size of hash must be MD2_BLOCK_SIZE
#endif // MD2_H

View File

@ -0,0 +1,34 @@
/*********************************************************************
* Filename: md5.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding MD5 implementation.
*********************************************************************/
#ifndef MD5_H
#define MD5_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/****************************** MACROS ******************************/
#define MD5_BLOCK_SIZE 16 // MD5 outputs a 16 byte digest
/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE; // 8-bit byte
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
typedef struct {
BYTE data[64];
WORD datalen;
unsigned long long bitlen;
WORD state[4];
} MD5_CTX;
/*********************** FUNCTION DECLARATIONS **********************/
void md5_init(MD5_CTX *ctx);
void md5_update(MD5_CTX *ctx, const BYTE data[], size_t len);
void md5_final(MD5_CTX *ctx, BYTE hash[]);
#endif // MD5_H

View File

@ -0,0 +1,20 @@
/*********************************************************************
* Filename: rot-13.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding ROT-13 implementation.
*********************************************************************/
#ifndef ROT13_H
#define ROT13_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/*********************** FUNCTION DECLARATIONS **********************/
// Performs IN PLACE rotation of the input. Assumes input is NULL terminated.
// Preserves each charcter's case. Ignores non alphabetic characters.
void rot13(char str[]);
#endif // ROT13_H

View File

@ -0,0 +1,35 @@
/*********************************************************************
* Filename: sha1.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding SHA1 implementation.
*********************************************************************/
#ifndef SHA1_H
#define SHA1_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/****************************** MACROS ******************************/
#define SHA1_BLOCK_SIZE 20 // SHA1 outputs a 20 byte digest
/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE; // 8-bit byte
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
typedef struct {
BYTE data[64];
WORD datalen;
unsigned long long bitlen;
WORD state[5];
WORD k[4];
} SHA1_CTX;
/*********************** FUNCTION DECLARATIONS **********************/
void sha1_init(SHA1_CTX *ctx);
void sha1_update(SHA1_CTX *ctx, const BYTE data[], size_t len);
void sha1_final(SHA1_CTX *ctx, BYTE hash[]);
#endif // SHA1_H

View File

@ -0,0 +1,34 @@
/*********************************************************************
* Filename: sha256.h
* Author: Brad Conte (brad AT bradconte.com)
* Copyright:
* Disclaimer: This code is presented "as is" without any guarantees.
* Details: Defines the API for the corresponding SHA1 implementation.
*********************************************************************/
#ifndef SHA256_H
#define SHA256_H
/*************************** HEADER FILES ***************************/
#include <stddef.h>
/****************************** MACROS ******************************/
#define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest
/**************************** DATA TYPES ****************************/
typedef unsigned char BYTE; // 8-bit byte
typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
typedef struct {
BYTE data[64];
WORD datalen;
unsigned long long bitlen;
WORD state[8];
} SHA256_CTX;
/*********************** FUNCTION DECLARATIONS **********************/
void sha256_init(SHA256_CTX *ctx);
void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len);
void sha256_final(SHA256_CTX *ctx, BYTE hash[]);
#endif // SHA256_H