diff --git a/compiler/parser.v b/compiler/parser.v index cf641698e0..9ae076ef51 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -156,7 +156,7 @@ fn (p mut Parser) parse() { } p.fgenln('\n') p.builtin_pkg = p.mod == 'builtin' - p.can_chash = p.mod == 'ft' || p.mod == 'http' || p.mod == 'glfw' || p.mod=='ui' // TODO tmp remove + p.can_chash = p.mod == 'ft' || p.mod == 'glfw' || p.mod=='ui' // TODO tmp remove // Import pass - the first and the smallest pass that only analyzes imports // fully qualify the module name, eg base64 to encoding.base64 fq_mod := p.table.qualify_module(p.mod, p.file_path) diff --git a/vlib/http/download_nix.v b/vlib/http/download_nix.v index 8a5ffbec5b..477a6c05b4 100644 --- a/vlib/http/download_nix.v +++ b/vlib/http/download_nix.v @@ -20,11 +20,12 @@ fn download_cb(ptr voidptr, size, nmemb size_t, userp voidptr) int { mut data := &DownloadStruct(userp) written := C.fwrite(ptr, size, nmemb, data.stream) data.written += written - #data->cb(data->written); // TODO + data.cb(data.written) + //#data->cb(data->written); // TODO return written } -fn download_file_with_progress(url, out string, cb downloadfn, cb_finished download_finished_fn) { +fn download_file_with_progress(url, out string, cb downloadfn, cb_finished fn()) { curl := C.curl_easy_init() if isnil(curl) { return @@ -43,7 +44,7 @@ fn download_file_with_progress(url, out string, cb downloadfn, cb_finished downl C.curl_easy_perform(curl) C.curl_easy_cleanup(curl) C.fclose(fp) - #cb_finished(); // TODO + cb_finished() } fn download_file(url, out string) { diff --git a/vlib/http/http_nix.v b/vlib/http/http_nix.v index 4705530a7c..3c911ada12 100644 --- a/vlib/http/http_nix.v +++ b/vlib/http/http_nix.v @@ -17,7 +17,8 @@ type wsfn fn (s string, ptr voidptr) struct MemoryStruct { size size_t - ws_func wsfn + //ws_func wsfn + ws_func fn(string, voidptr) user_ptr voidptr // for wsfn strings []string } @@ -43,15 +44,13 @@ import const ( fn C.curl_easy_strerror(curl voidptr) byteptr -fn C.curl_easy_perform(curl voidptr) C.CURLcode +fn C.curl_easy_perform(curl voidptr) int// C.CURLcode fn write_fn(contents byteptr, size, nmemb int, _mem *MemoryStruct) int { mut mem := _mem // # printf("size =%d nmemb=%d contents=%s\n", size, nmemb, contents); realsize := size * nmemb// TODO size_t ? - // if !isnil(mem.ws_func) { - # if (mem->ws_func) - { + if !isnil(mem.ws_func) { //C.printf('\n\nhttp_mac.m: GOT WS FUNC. size=%d\n', realsize) // Skip negative and 0 junk chars in the WS string mut start := 0 @@ -65,8 +64,9 @@ fn write_fn(contents byteptr, size, nmemb int, _mem *MemoryStruct) int { contents += start + 1 // printf("GOOD CONTEnTS=%s\n", contents); s := string(contents) - // mem.ws_func('kek', 0) - # mem->ws_func(s, mem->user_ptr); + f := mem.ws_func + f(s, mem.user_ptr) + //# mem->ws_func(s, mem->user_ptr); } mut c := string(contents) c = c.trim_space() @@ -139,8 +139,7 @@ pub fn (req &Request) do() Response { //println('bef easy()') res := C.curl_easy_perform(curl) //println('after easy()') - # if (res != CURLE_OK ) - { + if res != CURLE_OK { err := C.curl_easy_strerror(res) println('curl_easy_perform() failed: $err') }