kpm: initialize console
git-svn-id: svn://kolibrios.org@5731 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
4e5ae9b95e
commit
1a4da7ef10
@ -7,6 +7,13 @@ public _http_get@16
|
||||
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 @@ dll_load:
|
||||
|
||||
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
|
||||
@ -140,11 +158,29 @@ _http_get@16:
|
||||
|
||||
align 4
|
||||
_http_receive@4:
|
||||
jmp [HTTP_receive]
|
||||
jmp [HTTP_receive]
|
||||
|
||||
align 4
|
||||
_http_free@4:
|
||||
jmp [HTTP_free]
|
||||
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
|
||||
@ -224,13 +260,27 @@ macro import lname,[name,sname]
|
||||
align 4
|
||||
@IMPORT:
|
||||
|
||||
library lib_http, 'http.obj'
|
||||
library lib_http, 'http.obj', \
|
||||
console, 'console.obj'
|
||||
|
||||
import lib_http, \
|
||||
HTTP_get, 'get', \
|
||||
HTTP_receive, 'receive', \
|
||||
import lib_http, \
|
||||
HTTP_get, 'get', \
|
||||
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
|
||||
|
@ -26,9 +26,9 @@ typedef struct
|
||||
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,12 +36,21 @@ static inline int http_receive_with_retry(http_t *http, int retry_count)
|
||||
|
||||
do
|
||||
{
|
||||
if(err = http_receive(http))
|
||||
delay(1);
|
||||
err = http_receive(http);
|
||||
if(err)
|
||||
wait_for_event(1);
|
||||
|
||||
}while(err && --retry_count);
|
||||
|
||||
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__ */
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
#define BUFFSIZE (64*1024)
|
||||
|
||||
char conbuf[256];
|
||||
|
||||
char *make_url(const char *name)
|
||||
{
|
||||
@ -90,6 +91,10 @@ int http_load_file(const char *path, const char *url)
|
||||
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;
|
||||
}
|
||||
@ -118,7 +123,6 @@ err_get:
|
||||
return received;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int count;
|
||||
@ -128,6 +132,8 @@ int main(int argc, char *argv[])
|
||||
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"));
|
||||
@ -150,13 +156,18 @@ int main(int argc, char *argv[])
|
||||
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");
|
||||
|
||||
do_install(&install_list);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
con_exit(0);
|
||||
|
||||
return 0;
|
||||
|
||||
@ -226,10 +237,12 @@ void do_download(list_t *download_list)
|
||||
|
||||
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
|
||||
@ -247,7 +260,8 @@ void remove_missing_packages(list_t *install, list_t *missed)
|
||||
{
|
||||
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);
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user