/programs/network/netsurf/netsurf/content/fetchers/curl.c |
---|
28,6 → 28,9 |
* ::max_cached_fetch_handles in this ring. |
*/ |
#include "http.c" |
#include <assert.h> |
#include <errno.h> |
#include <inttypes.h> |
155,7 → 158,6 |
bool fetch_curl_initialise(lwc_string *scheme) |
{ |
LOG(("curl initi lwc\n")); |
return true; /* Always succeeds */ |
} |
363,71 → 365,77 |
return error; |
} |
static void fetch_curl_process(struct fetch_curl_context *ctx) { |
char ps[96], str[128]; |
sprintf(ps, "Yay! Path is %s", ctx->path); |
execl ("/sys/@notify", ps, 0); |
int pid=execl ("/sys/network/downloader", ctx->path, 0); |
fetch_msg msg; |
/* ERSATZ DOWNLOADER */ |
/* |
char zapzap[]="<html><body><h1>HOOLE!</h1></body></html>"; |
size_t file_size=strlen(zapzap); |
char *buffer = (char*)malloc(file_size * sizeof(char)); |
memcpy(buffer, zapzap, file_size * sizeof(char)); |
*/ |
// while (is_pid(pid)) { |
kill_pid(pid); |
// } |
pid=execl ("/sys/network/downloader", ctx->path, 0); |
char ps[255]; |
sprintf(ps, "pid %d", pid); |
execl ("/sys/network/@notify", ps, 0); |
while (is_pid(pid)); |
__menuet__debug_out("AHOY!\n"); |
struct http_msg *http_ahoy; |
unsigned int wererat = 0; |
char * pa=ctx->path; |
asm volatile ("pusha"); |
wererat = http_get(pa); |
asm volatile ("popa"); |
__menuet__debug_out("HTTP GOT!\n"); |
int result; |
sprintf(ps, "Yay! Finished"); |
execl ("/sys/network/@notify", ps, 0); |
http_ahoy=wererat; |
sprintf (str, "Header %d bytes, content %d bytes, recieved %d bytes\n", http_ahoy->header_length, http_ahoy->content_length, http_ahoy->content_received); |
__menuet__debug_out(str); |
/* |
char pzz[255]; |
sprintf(pzz, "Pid is %d", pid); |
execl ("/sys/@notify", pzz, 0); */ |
//int status; |
//waitpid(pid, &status, 0); |
asm volatile ("pusha"); |
result = http_process(wererat); |
asm volatile ("popa"); |
while (result == -1) { |
asm volatile ("pusha"); |
result = http_process(wererat); |
asm volatile ("popa"); |
} |
http_ahoy=wererat; |
fetch_msg msg; |
//const char * buf = "<html><body><h1>Hello, file fetcher!</h1></body></html>"; |
sprintf (str, "Header %d bytes, content %d bytes, recieved %d bytes\n", http_ahoy->header_length, http_ahoy->content_length, http_ahoy->content_received); |
__menuet__debug_out(str); |
FILE *infile; |
infile = fopen("/sys/.download", "rb"); |
if (infile == NULL) { |
printf("file does not exist.\n"); |
return -1; |
} |
__menuet__debug_out("All content is here\n"); |
fseek(infile, 0, SEEK_END); |
size_t file_size = ftell(infile); |
rewind(infile); |
size_t file_size=http_ahoy->content_received; |
char *buffer = (char*)malloc(file_size * sizeof(char)); |
if (buffer == NULL) { |
fclose(infile); |
printf("Error allocating %d bytes.\n", file_size * sizeof(char)); |
return -1; |
} |
size_t bytes_read = fread(buffer, sizeof(char), file_size, infile); |
if (bytes_read != file_size) { |
printf("Have read only %d bytes of %d.\n", bytes_read, file_size); |
free(buffer); |
fclose(infile); |
return -1; |
} |
fclose(infile); |
memcpy(buffer, &(http_ahoy->data)+http_ahoy->header_length, file_size); |
// http_free(wererat); |
__menuet__debug_out("memcopied\n==\n"); |
//__menuet__debug_out(buffer); |
//__menuet__debug_out("memcopied\n==\n"); |
//char zapzap[]="<html><body><h1>HOOLE!</h1></body></html>"; |
//file_size=strlen(zapzap); |
//char *buffer = (char*)malloc(file_size * sizeof(char)); |
//memcpy(buffer, zapzap, file_size * sizeof(char)); |
/* fetch is going to be successful */ |
fetch_set_http_code(ctx->fetchh, 200); |
436,8 → 444,6 |
* fetch_file_send_callback(). |
*/ |
__menuet__debug_out(fetch_filetype(ctx->path)); |
__menuet__debug_out("\n"); |
if (fetch_curl_send_header(ctx, "Content-Type: %s", |
fetch_filetype(ctx->path))) |
447,7 → 453,7 |
/* main data loop */ |
msg.type = FETCH_DATA; |
msg.data.header_or_data.buf = (const uint8_t *) buffer; |
msg.data.header_or_data.buf = (const uint8_t *) buffer;//&(http_ahoy->data) ; //buffer; |
msg.data.header_or_data.len = file_size; |
fetch_curl_send_callback(&msg, ctx); |
/programs/network/netsurf/netsurf/content/fetchers/http.c |
---|
0,0 → 1,86 |
#include <menuet/os.h> |
#define NULL 0 |
#define __stdcall __attribute__((stdcall)) |
extern int dll_load(); |
extern int mem_Free(); |
extern int mem_Alloc(); |
extern int mem_ReAlloc(); |
int kol_exit(){ |
__menuet__sys_exit(); |
} |
struct http_msg { |
unsigned int socket; |
unsigned int flags; |
unsigned int write_ptr; |
unsigned int buffer_length; |
unsigned int chunk_ptr; |
unsigned int timestamp; |
unsigned int status; |
unsigned int header_length; |
unsigned int content_length; |
unsigned int content_received; |
char data; //unknown size |
}; |
int (* __stdcall http_init)(); |
unsigned int (* __stdcall http_get) (char * url); //yay, it's NOT uint, but hey, C is stubborn, and I'm dumb |
int (* __stdcall http_process) (unsigned int identifier); |
void (* __stdcall http_free) (unsigned int identifier); |
int HTTP_YAY(){ |
asm volatile ("pusha\n\ |
movl $mem_Alloc, %eax\n\ |
movl $mem_Free, %ebx\n\ |
movl $mem_ReAlloc, %ecx\n\ |
movl $dll_load, %edx\n\ |
movl http_init, %esi\n\ |
call *%esi\n\ |
popa"); |
} |
///=========================== |
void HTTP_INIT() |
{ |
IMP_ENTRY *imp; |
imp = __kolibri__cofflib_load("/sys/lib/http.obj"); |
if (imp == NULL) |
kol_exit(); |
http_init = ( __stdcall int(*)()) |
__kolibri__cofflib_getproc (imp, "lib_init"); |
if (http_init == NULL) |
kol_exit(); |
http_get = ( __stdcall unsigned int (*)(char*)) |
__kolibri__cofflib_getproc (imp, "get"); |
if (http_get == NULL) |
kol_exit(); |
http_free = ( __stdcall void (*)(unsigned int)) |
__kolibri__cofflib_getproc (imp, "free"); |
if (http_free == NULL) |
kol_exit(); |
http_process = ( __stdcall int (*)(unsigned int)) |
__kolibri__cofflib_getproc (imp, "process"); |
if (http_process == NULL) |
kol_exit(); |
__menuet__debug_out("HTTP init...\n"); |
HTTP_YAY(); |
__menuet__debug_out("ok...\n"); |
} |
/programs/network/netsurf/netsurf/framebuffer/gui.c |
---|
435,7 → 435,7 |
fewidth = nsoption_int(window_width); |
feheight = nsoption_int(window_height); |
} else { |
fewidth = 800; //640; |
fewidth = 790; //640; |
feheight = 560; //400; |
} |
541,6 → 541,25 |
freopen( "stdout.log", "w", stdout ); |
char p[256]; |
char **z; |
z=0x20; |
strcpy(p, *z); |
__menuet__debug_out("PATH1...\n"); |
__menuet__debug_out(p); |
__menuet__debug_out("PATH1...\n"); |
*(strrchr(p, '/')+1)='\0'; |
strcpy(strrchr(p, '/')+1, "res/"); |
__menuet__debug_out("PATH1...\n"); |
__menuet__debug_out(p); |
__menuet__debug_out("PATH1...\n"); |
asm volatile ("int $0x40"::"a"(30), "b"(1), "c"(p)); |
LOG(("Registering surfaces for SDL and RAM..")); |
//extern nsfb_surface_rtns_t sdl_rtns; |
553,13 → 572,21 |
_nsfb_register_surface(NSFB_SURFACE_ABLE, &able_rtns, "able"); |
_nsfb_register_surface(NSFB_SURFACE_KOLIBRI, &kolibri_rtns, "kolibri"); |
respaths = fb_init_resource("/hd0/1/res/:/bd0/1/res/:/tmp9/1/netsurf/res/:res/:fonts/"); |
//respaths = fb_init_resource("/kolibrios/:/hd0/1/res/:/bd0/1/res/:/tmp9/1/netsurf/res/:res/:fonts/:"); |
respaths = fb_init_resource(p); |
options = filepath_find(respaths, "Choices"); |
messages = filepath_find(respaths, "messages"); |
netsurf_init(&argc, &argv, options, "res/messages"); |
__menuet__debug_out("===path to msg\n"); |
__menuet__debug_out(messages); |
__menuet__debug_out("\n===path to msg\n"); |
//netsurf_init(&argc, &argv, options, "res/messages"); |
netsurf_init(&argc, &argv, options, messages); |
extern HTTP_INIT(); |
HTTP_INIT(); |
LOG(("NS init okay")); |
free(messages); |
/programs/network/netsurf/netsurf/objs/bitmap.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/box.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/box_construct.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/clipboard.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/curl.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/dll.asm |
---|
0,0 → 1,179 |
include 'proc32.inc' |
macro __mov reg,a,b { ; mike.dld |
if (~a eq)&(~b eq) |
mpack reg,a,b |
else if (~a eq)&(b eq) |
mov reg,a |
end if |
} |
macro mcall a,b,c,d,e,f { ; mike.dld, updated by Ghost for Fast System Calls |
__mov eax,a |
__mov ebx,b |
__mov ecx,c |
__mov edx,d |
__mov esi,e |
__mov edi,f |
int 0x40 |
} |
format ELF |
section '.text' executable |
public dll_load |
public mem_Free |
public mem_Alloc |
public mem_ReAlloc |
;----------------------------------------------------------------------------- |
proc dll_load, import_table:dword |
mov esi, [import_table] |
.next_lib: |
mov edx, [esi] |
or edx, edx |
jz .exit |
push esi |
mov esi, [esi + 4] |
mov edi, s_libdir.fname |
@@: |
lodsb |
stosb |
or al, al |
jnz @b |
mcall 68, 19, s_libdir |
or eax, eax |
jz .fail |
stdcall dll.Link, eax, edx |
push eax |
mov eax, [eax] |
cmp dword[eax], 'lib_' |
pop eax |
jnz @f |
stdcall dll.Init, [eax + 4] |
@@: |
pop esi |
add esi, 8 |
jmp .next_lib |
.exit: |
xor eax, eax |
ret |
.fail: |
add esp, 4 |
xor eax, eax |
inc eax |
ret |
endp |
;----------------------------------------------------------------------------- |
proc dll.Link, exp:dword, imp:dword |
push eax |
mov esi, [imp] |
test esi, esi |
jz .done |
.next: |
lodsd |
test eax, eax |
jz .done |
stdcall dll.GetProcAddress, [exp], eax |
or eax, eax |
jz @f |
mov [esi - 4], eax |
jmp .next |
@@: |
mov dword[esp], 0 |
.done: |
pop eax |
ret |
endp |
;----------------------------------------------------------------------------- |
proc dll.Init, dllentry:dword |
pushad |
mov eax, mem_Alloc |
mov ebx, mem_Free |
mov ecx, mem_ReAlloc |
mov edx, dll_load |
stdcall [dllentry] |
popad |
ret |
endp |
;----------------------------------------------------------------------------- |
proc dll.GetProcAddress, exp:dword, sz_name:dword |
mov edx, [exp] |
xor eax, eax |
.next: |
or edx, edx |
jz .end |
cmp dword[edx], 0 |
jz .end |
stdcall strcmp, [edx], [sz_name] |
test eax, eax |
jz .ok |
add edx, 8 |
jmp .next |
.ok: |
mov eax, [edx + 4] |
.end: |
ret |
endp |
;----------------------------------------------------------------------------- |
proc strcmp, str1:dword, str2:dword |
push esi edi |
mov esi, [str1] |
mov edi, [str2] |
xor eax, eax |
@@: |
lodsb |
scasb |
jne .fail |
or al, al |
jnz @b |
jmp .ok |
.fail: |
or eax, -1 |
.ok: |
pop edi esi |
ret |
endp |
;----------------------------------------------------------------------------- |
s_libdir: |
db '/sys/lib/' |
.fname rb 32 |
;----------------------------------------------------------------------------- |
proc mem_Alloc, size |
push ebx ecx |
mov ecx, [size] |
mcall 68, 12 |
pop ecx ebx |
ret |
endp |
;----------------------------------------------------------------------------- |
proc mem_ReAlloc, mptr, size |
push ebx ecx edx |
mov ecx, [size] |
or ecx, ecx |
jz @f |
@@: |
mov edx, [mptr] |
or edx, edx |
jz @f |
@@: |
mcall 68, 20 |
or eax, eax |
jz @f |
@@: |
pop edx ecx ebx |
ret |
endp |
;----------------------------------------------------------------------------- |
proc mem_Free, mptr |
push ebx ecx |
mov ecx,[mptr] |
or ecx,ecx |
jz @f |
@@: |
mcall 68, 13 |
pop ecx ebx |
ret |
endp |
;----------------------------------------------------------------------------- |
/programs/network/netsurf/netsurf/objs/dll.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes: |
Added: svn:mime-type |
+application/octet-stream |
\ No newline at end of property |
/programs/network/netsurf/netsurf/objs/filetype.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/findfile.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/font_freetype.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/form.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/framebuffer.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/gui.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/html.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/html_forms.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/html_redraw.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/layout.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/list.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/localhistory.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/login.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/misc.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/nsfont_bold.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/nsfont_italic.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/nsfont_italic_bold.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/nsfont_regular.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/schedule.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/system_colour.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/textplain.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/thumbnail.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
/programs/network/netsurf/netsurf/objs/tree.o |
---|
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |