/contrib/other/kpm/http.asm |
---|
7,6 → 7,13 |
public _http_receive@4 |
public _http_free@4 |
public _con_init@20 |
public _con_exit@4 |
public _con_get_flags |
public _con_set_flags@4 |
public _con_cls |
public _con_write_asciiz@4 |
section '.text' align 16 |
129,9 → 136,20 |
align 4 |
_http_init: |
push ebx |
mov eax, 40 |
mov ebx, 1 shl 8 |
int 0x40 |
pop ebx |
push @IMPORT |
call dll_load |
test eax, eax |
jnz .fail |
push 1 |
call [con_start] |
xor eax, eax |
.fail: |
ret |
align 4 |
146,6 → 164,24 |
_http_free@4: |
jmp [HTTP_free] |
align 4 |
_con_init@20: |
jmp [con_init] |
align 4 |
_con_exit@4: |
jmp [con_exit] |
align 4 |
_con_write_asciiz@4: |
jmp [con_write_asciiz] |
_con_get_flags: |
_con_set_flags@4: |
_con_cls: |
ret |
proc mem.Alloc, size |
push ebx ecx |
mov ecx, [size] |
224,7 → 260,8 |
align 4 |
@IMPORT: |
library lib_http, 'http.obj' |
library lib_http, 'http.obj', \ |
console, 'console.obj' |
import lib_http, \ |
HTTP_get, 'get', \ |
231,6 → 268,19 |
HTTP_receive, 'receive', \ |
HTTP_free, 'free' |
import console, \ |
con_start, 'START', \ |
con_init, 'con_init', \ |
con_write_asciiz,'con_write_asciiz',\ |
con_exit, 'con_exit', \ |
con_gets, 'con_gets', \ |
con_cls, 'con_cls', \ |
con_getch2, 'con_getch2', \ |
con_set_cursor_pos, 'con_set_cursor_pos',\ |
con_write_string, 'con_write_string',\ |
con_get_flags, 'con_get_flags', \ |
con_set_flags, 'con_set_flags' |
s_libdir: |
db '/sys/lib/' |
.fname rb 32 |
/contrib/other/kpm/http.h |
---|
26,9 → 26,9 |
int http_init(); |
int http_load(char *buf, const char *path); |
http_t* __attribute__ ((stdcall)) http_get(const char *url, http_t *conn, int flags, const char *header); |
int __attribute__ ((stdcall)) http_receive(http_t *conn); |
void __attribute__ ((stdcall)) http_free(http_t *conn); |
http_t* __stdcall http_get(const char *url, http_t *conn, int flags, const char *header); |
int __stdcall http_receive(http_t *conn); |
void __stdcall http_free(http_t *conn); |
static inline int http_receive_with_retry(http_t *http, int retry_count) |
{ |
36,8 → 36,9 |
do |
{ |
if(err = http_receive(http)) |
delay(1); |
err = http_receive(http); |
if(err) |
wait_for_event(1); |
}while(err && --retry_count); |
44,4 → 45,12 |
return err; |
} |
void __stdcall con_init(unsigned w_w, unsigned w_h, unsigned s_w, unsigned s_h, const char* t); |
void __stdcall con_exit(char bCloseWindow); |
unsigned __stdcall con_get_flags(void); |
unsigned __stdcall con_set_flags(unsigned new_flags); |
void __stdcall con_cls(void); |
void __stdcall con_write_asciiz(const char* string); |
#endif /* __HTTP_H__ */ |
/contrib/other/kpm/kpm.c |
---|
12,6 → 12,7 |
#define BUFFSIZE (64*1024) |
char conbuf[256]; |
char *make_url(const char *name) |
{ |
91,6 → 92,10 |
memcpy(buf, http->content_ptr+count, tail); |
offset = tail; |
} |
sprintf(conbuf, "%d bytes loaded\r", http->content_received); |
con_write_asciiz(conbuf); |
} |
received = http->content_received; |
} |
119,7 → 124,6 |
return received; |
} |
int main(int argc, char *argv[]) |
{ |
int count; |
129,6 → 133,8 |
if(http_init()) |
goto err_init; |
con_init(80, 25, 80, 250, "Kolibri package manager"); |
tmp_path = make_tmp_path("packages.xml"); |
count = http_load_file(tmp_path, make_url("packages.xml")); |
151,7 → 157,10 |
remove_missing_packages(&install_list, &download_list); |
list_for_each_entry(pkg, &install_list, list) |
printf("install package %s-%s\n", pkg->name, pkg->version); |
{ |
sprintf(conbuf,"install package %s-%s\n", pkg->name, pkg->version); |
con_write_asciiz(conbuf); |
}; |
set_cwd("/tmp0/1"); |
159,6 → 168,8 |
}; |
} |
con_exit(0); |
return 0; |
err_init: |
227,10 → 238,12 |
list_for_each_entry_safe(pkg, tmp, download_list, list) |
{ |
printf("package %s-%s\n", pkg->name, pkg->version); |
sprintf(conbuf,"package %s-%s\n", pkg->name, pkg->version); |
con_write_asciiz(conbuf); |
cache_path = make_cache_path(pkg->filename); |
count = http_load_file(cache_path, make_url(pkg->filename)); |
printf("%s loaded %d bytes\n",cache_path, count); |
sprintf(conbuf,"%s %d bytes loaded\n",cache_path, count); |
con_write_asciiz(conbuf); |
if( !test_archive(cache_path)) |
list_del_pkg(pkg); |
else |
248,7 → 261,8 |
{ |
if(ipkg->id == mpkg->id) |
{ |
printf("skip missing package %s-%s\n", ipkg->name, ipkg->version); |
sprintf(conbuf,"skip missing package %s-%s\n", ipkg->name, ipkg->version); |
con_write_asciiz(conbuf); |
list_del_pkg(ipkg); |
}; |
} |