1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

http_nix.v: remove remaining C code

This commit is contained in:
Alexander Medvednikov 2019-07-31 23:01:06 +02:00
parent 448aaa36f2
commit 8058bf3750
3 changed files with 13 additions and 13 deletions

View File

@ -156,7 +156,7 @@ fn (p mut Parser) parse() {
} }
p.fgenln('\n') p.fgenln('\n')
p.builtin_pkg = p.mod == 'builtin' 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 // Import pass - the first and the smallest pass that only analyzes imports
// fully qualify the module name, eg base64 to encoding.base64 // fully qualify the module name, eg base64 to encoding.base64
fq_mod := p.table.qualify_module(p.mod, p.file_path) fq_mod := p.table.qualify_module(p.mod, p.file_path)

View File

@ -20,11 +20,12 @@ fn download_cb(ptr voidptr, size, nmemb size_t, userp voidptr) int {
mut data := &DownloadStruct(userp) mut data := &DownloadStruct(userp)
written := C.fwrite(ptr, size, nmemb, data.stream) written := C.fwrite(ptr, size, nmemb, data.stream)
data.written += written data.written += written
#data->cb(data->written); // TODO data.cb(data.written)
//#data->cb(data->written); // TODO
return written 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() curl := C.curl_easy_init()
if isnil(curl) { if isnil(curl) {
return 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_perform(curl)
C.curl_easy_cleanup(curl) C.curl_easy_cleanup(curl)
C.fclose(fp) C.fclose(fp)
#cb_finished(); // TODO cb_finished()
} }
fn download_file(url, out string) { fn download_file(url, out string) {

View File

@ -17,7 +17,8 @@ type wsfn fn (s string, ptr voidptr)
struct MemoryStruct { struct MemoryStruct {
size size_t size size_t
ws_func wsfn //ws_func wsfn
ws_func fn(string, voidptr)
user_ptr voidptr // for wsfn user_ptr voidptr // for wsfn
strings []string strings []string
} }
@ -43,15 +44,13 @@ import const (
fn C.curl_easy_strerror(curl voidptr) byteptr 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 { fn write_fn(contents byteptr, size, nmemb int, _mem *MemoryStruct) int {
mut mem := _mem mut mem := _mem
// # printf("size =%d nmemb=%d contents=%s\n", size, nmemb, contents); // # printf("size =%d nmemb=%d contents=%s\n", size, nmemb, contents);
realsize := size * nmemb// TODO size_t ? realsize := size * nmemb// TODO size_t ?
// if !isnil(mem.ws_func) { if !isnil(mem.ws_func) {
# if (mem->ws_func)
{
//C.printf('\n\nhttp_mac.m: GOT WS FUNC. size=%d\n', realsize) //C.printf('\n\nhttp_mac.m: GOT WS FUNC. size=%d\n', realsize)
// Skip negative and 0 junk chars in the WS string // Skip negative and 0 junk chars in the WS string
mut start := 0 mut start := 0
@ -65,8 +64,9 @@ fn write_fn(contents byteptr, size, nmemb int, _mem *MemoryStruct) int {
contents += start + 1 contents += start + 1
// printf("GOOD CONTEnTS=%s\n", contents); // printf("GOOD CONTEnTS=%s\n", contents);
s := string(contents) s := string(contents)
// mem.ws_func('kek', 0) f := mem.ws_func
# mem->ws_func(s, mem->user_ptr); f(s, mem.user_ptr)
//# mem->ws_func(s, mem->user_ptr);
} }
mut c := string(contents) mut c := string(contents)
c = c.trim_space() c = c.trim_space()
@ -139,8 +139,7 @@ pub fn (req &Request) do() Response {
//println('bef easy()') //println('bef easy()')
res := C.curl_easy_perform(curl) res := C.curl_easy_perform(curl)
//println('after easy()') //println('after easy()')
# if (res != CURLE_OK ) if res != CURLE_OK {
{
err := C.curl_easy_strerror(res) err := C.curl_easy_strerror(res)
println('curl_easy_perform() failed: $err') println('curl_easy_perform() failed: $err')
} }