287,8 → 287,11 |
struct fetch_curl_context *ctx) |
{ |
ctx->locked = true; |
__menuet__debug_out("Inside curl_send_cb, Calling send_cb()\n"); |
|
fetch_send_callback(msg, ctx->fetchh); |
ctx->locked = false; |
__menuet__debug_out("Returning ctx->aborted.\n"); |
|
return ctx->aborted; |
} |
299,18 → 302,23 |
fetch_msg msg; |
char header[64]; |
va_list ap; |
|
__menuet__debug_out("Inside fetch_curl_send_header\n"); |
va_start(ap, fmt); |
|
vsnprintf(header, sizeof header, fmt, ap); |
|
va_end(ap); |
__menuet__debug_out("Header is : "); |
__menuet__debug_out(header); |
|
msg.type = FETCH_HEADER; |
msg.data.header_or_data.buf = (const uint8_t *) header; |
msg.data.header_or_data.len = strlen(header); |
__menuet__debug_out("\nCalling fetch_curl_send_callback\n"); |
|
fetch_curl_send_callback(&msg, ctx); |
|
__menuet__debug_out("Returning ctx->aborted\n"); |
return ctx->aborted; |
} |
|
350,22 → 358,6 |
} |
|
|
int is_pid(int k) |
{ |
int error; |
asm volatile ("int $0x40":"=a"(error):"a"(18), "b"(21), "c"(k)); |
return error; |
} |
|
|
int kill_pid(int k) |
{ |
int error; |
asm volatile ("int $0x40":"=a"(error):"a"(18), "b"(18), "c"(k)); |
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); |
373,71 → 365,58 |
|
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)); |
*/ |
|
|
|
|
|
__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; |
// asm volatile ("pusha"); // TODO: verify if this is still needed. It used to be an issue with the library but should be fixed now. |
wererat = http_get(pa, NULL); // TODO: a pointer to additional headers (for cookies etc) can be placed here in the future. |
// asm volatile ("popa"); // .... |
|
http_ahoy=wererat; |
if(wererat == 0) /* Error condition : http_get returned 0 */ |
__menuet__debug_out("http_get() failed. [ Return Value 0 ]\n"); |
else |
__menuet__debug_out("http_get() Succeeded!. [ Return Value Non zero ]\n"); |
|
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); |
__menuet__debug_out("HTTP GOT!\n"); |
int result = 1337; |
char result_str[12]; |
char wererat_str[13]; |
|
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; |
|
sprintf (str, "Header %d bytes, content %d bytes, recieved %d bytes\n", http_ahoy->header_length, http_ahoy->content_length, http_ahoy->content_received); |
sprintf (str, "Header %u bytes, content %u bytes, received %u bytes\n", http_ahoy->header_length, http_ahoy->content_length, http_ahoy->content_received); |
__menuet__debug_out(str); |
|
__menuet__debug_out("Going into the do while loop for http_process\n"); |
|
__menuet__debug_out("All content is here\n"); |
do { |
// sprintf(result_str, "%d", result); |
// __menuet__debug_out("Result is : "); |
// __menuet__debug_out(result_str); |
// __menuet__debug_out("\n"); |
|
size_t file_size=http_ahoy->content_received; |
char *buffer = (char*)malloc(file_size * sizeof(char)); |
memcpy(buffer, &(http_ahoy->data)+http_ahoy->header_length, file_size); |
// asm volatile ("pusha"); // TODO: verify if this is still needed. It used to be an issue with the library but should be fixed now. |
result = http_process(wererat); |
// asm volatile ("popa"); // .... |
} while ((result != 0)); |
|
// http_free(wererat); |
__menuet__debug_out("memcopied\n==\n"); |
__menuet__debug_out("After the do while loop for http_process.\n"); |
|
//__menuet__debug_out(buffer); |
//__menuet__debug_out("memcopied\n==\n"); |
if(result == 0) |
__menuet__debug_out("http_process() worked successfully!\n"); |
else |
__menuet__debug_out("http_process() failed!\n"); |
|
// http_ahoy = wererat; // really needed again?? |
sprintf (str, "Header %u bytes, content %u bytes, received %u bytes\n", http_ahoy->header_length, http_ahoy->content_length, http_ahoy->content_received); |
__menuet__debug_out(str); |
|
//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); |
__menuet__debug_out("Calling fetch_set_http_code call\n"); |
fetch_set_http_code(ctx->fetchh, http_ahoy->status); |
__menuet__debug_out("Returned from fetch_set_http_code call\n"); |
|
/* Any callback can result in the fetch being aborted. |
* Therefore, we _must_ check for this after _every_ call to |
444,7 → 423,7 |
* fetch_file_send_callback(). |
*/ |
|
|
__menuet__debug_out("Calling fetch_curl_send_header: 1\n"); |
if (fetch_curl_send_header(ctx, "Content-Type: %s", |
fetch_filetype(ctx->path))) |
goto fetch_file_process_aborted; |
451,25 → 430,36 |
|
|
/* main data loop */ |
__menuet__debug_out("inside main data loop\n"); |
msg.type = FETCH_DATA; |
|
msg.type = FETCH_DATA; |
msg.data.header_or_data.buf = (const uint8_t *) buffer;//&(http_ahoy->data) ; //buffer; |
msg.data.header_or_data.len = file_size; |
msg.data.header_or_data.buf = http_ahoy->content_ptr; // lets pray this works..x2 |
|
msg.data.header_or_data.len = http_ahoy->content_received; |
__menuet__debug_out("Calling fetch_curl_send_callback\n"); |
fetch_curl_send_callback(&msg, ctx); |
|
__menuet__debug_out("Calling http_free with wererat = "); |
sprintf(wererat_str, "%u", wererat); |
__menuet__debug_out(wererat_str); |
__menuet__debug_out("\n"); |
|
http_free(wererat); |
|
if (ctx->aborted == false) { |
__menuet__debug_out("ctx->aborted = false\n"); |
msg.type = FETCH_FINISHED; |
__menuet__debug_out("Calling fetch_curl_send_callback\n"); |
fetch_curl_send_callback(&msg, ctx); |
__menuet__debug_out("After Calling fetch_curl_send_callback\n"); |
} |
|
fetch_file_process_aborted: |
__menuet__debug_out("Inside fetch file_process_aborted label\n"); |
return; |
|
} |
|
|
/** |
* Do some work on current fetches. |
* |