Hacker News new | past | comments | ask | show | jobs | submit login

Seems like it should be pretty straightforward. curl_easy_init(), ..._setopt(), ..._perform(), ..._cleanup() covers the use cases I think.

libcurl only gets weird when you're threading multiple fetches or integrating with a GUI toolkit or something. Even then it's not hard at all to integrate with GTK unless you need absolute peak performance or are handling tens of thousands of simultaneous connections.




Re-using curl's C code and compiling to WASM is the dream.

libcurl does stuff like open files for reading, so you would have to at least modify the code to just pass the file name, you also have to modify the struct.

libcurl parses an array of strings, but curlconverter gets a Bash AST (or a list of strings if you use it from the command line). When there's a bash variable in the command, we want to generate code that gets that environment variable at runtime, e.g. `os.environ['MY_VARIABLE']` in Python so the struct needs to store pointers to AST nodes instead of strings/booleans/ints. Though to be fair curlconverter doesn't work this way either (yet), we convert AST nodes to strings/booleans/ints after command parsing and store that, then when we're generating the code if we see a $ in a string we assume that was a variable in the input AST.


Sorry, it's too late to delete my comment but I realize now that you were asking about generating C code, not which language the project should be implemented in. "Curl already has argument parsing code, why can't we just call it?" is something I've thought a lot so I assumed someone would also suggest it here.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: