Release first beta version server

Version 0.1.0 has been released:
- Added a feature for easily sending an http response
- Minor bugs have been fixed
- Updated API for server modules
- Added a readme file
This commit is contained in:
Doczom
2023-12-10 18:21:37 +05:00
committed by GitHub
parent bb92182caf
commit b32a38a071
13 changed files with 774 additions and 99 deletions

View File

@@ -1,10 +1,15 @@
format MS COFF
public @EXPORT as 'EXPORTS'
NO_DEBUG_INPUT = 1
API_VERSION = 0x05
FLAG_KEEP_ALIVE = 0x01
NO_DEBUG_INPUT = 0
include 'D:\kos\programs\macros.inc'
struct EXPORT_DATA
struct IMPORT_DATA
version rd 1 ; dword for check api
sizeof rd 1 ; size struct
netfunc_socket rd 1
netfunc_close rd 1
netfunc_bind rd 1
@@ -16,6 +21,26 @@ struct EXPORT_DATA
FileRead rd 1
Alloc rd 1
Free rd 1
parse_http_query rd 1
;send_resp(RESPD* ptr, char* content, uint32_t length)
;create_resp(CONNECT_DATA* session, uint32_t flags)
; FLAG_KEEP_ALIVE = 0x01
; FLAG_ADD_DATE = 0x02 ;(not supported)
; FLAG_NO_SET_CACHE = 0x04 ;(not supported)
; FLAG_NO_CONTENT_ENCODING = 0x08 ;(not supported)
;
;destruct_resp(RESPD* ptr)
;set_http_status(RESPD* ptr, uint32_t status) ; status in '200' format,
;add_http_header(RESPD* ptr, char* ptr_header)
;del_http_header(RESPD* ptr, char* ptr_header) ; no del std header
;set_http_ver(RESPD* ptr, char* version) ; example: RTSP/1.1
send_resp rd 1
create_resp rd 1
destruct_resp rd 1
set_http_status rd 1
add_http_header rd 1
del_http_header rd 1
set_http_ver rd 1
base_response rd 1
GLOBAL_DATA rd 1
@@ -64,13 +89,25 @@ end if
section '.flat' code readable align 16
unit_init:
mov eax, -1
push esi edi
mov esi, [esp + 4*2 + 4]
mov [import_httpd], esi
mov eax, [esp + 4]
mov [import_httpd], eax
cmp dword[esi + IMPORT_DATA.version], API_VERSION
jne .exit
mov edi, IMPORT
mov ecx, [esi + IMPORT_DATA.sizeof]
shr ecx, 2 ; div 4
rep movsd
xor eax, eax
.exit:
pop edi esi
ret 4
server_entry:
push esi edi
mov esi, [esp + 4*2 + 4]
@@ -106,6 +143,11 @@ server_entry:
cmp dword[ecx], 'txt'
jne .no_args
mov dword[text_message], ' '
mov dword[text_message + 4], ' '
mov dword[text_message + 8], ' '
mov dword[text_message + 12], ' '
push esi edi
mov esi, [eax + 12]
mov edi, text_message
@@ -123,8 +165,7 @@ server_entry:
board_input 'create message'
; create http message
push dword 8*1024
mov eax, [import_httpd]
call [eax + EXPORT_DATA.Alloc]
call [IMPORT + IMPORT_DATA.Alloc]
test eax, eax
jz .exit
@@ -168,13 +209,12 @@ server_entry:
; set httpcode
mov dword[edi + sceleton_resp.code], '200 '
; send http message
mov ecx, [import_httpd]
push dword 0 ; flags
push sceleton_resp.size
push edi
push dword[esi + CONNECT_DATA.socket]
call [ecx + EXPORT_DATA.netfunc_send]
call [IMPORT + IMPORT_DATA.netfunc_send]
board_input 'send'
.exit:
@@ -224,3 +264,6 @@ text_message:
export \
unit_init, 'httpd_init', \
server_entry, 'httpd_serv'
IMPORT IMPORT_DATA ;