How complex would it be to use nodejs/http-parser from an Arduino device?
It's small, fast and supposedly portable. It doesn't perform any memory allocations.
I tried setting it up in a sketch and got as far as the compiler not understanding the C function references.
[Starting] Verifying sketch 'ad-irrigation.ino'
Please see the build logs in output path: c:\source\repos\ad-irrigation\bin
c:\source\repos\ad-irrigation\bin\sketch\ad-irrigation.ino.cpp.o: In function
`IrrigationServer::listen()':
c:\source\repos\ad-irrigation/irrigation-server.hpp:45: undefined reference to `http_parser_init'
c:\source\repos\ad-irrigation/irrigation-server.hpp:49: undefined reference to `http_parser_execute
'
collect2.exe: error: ld returned 1 exit status
Error during build: exit status 1
IntelliSense auto-configuration disabled.
[Error] Verifying sketch 'ad-irrigation.ino': Exit with code=1
c:\source\repos\ad-irrigation/irrigation-server.hpp:54: undefined reference to `http_parser_init'
c:\source\repos\ad-irrigation/irrigation-server.hpp:58: undefined reference to `http_parser_execute
The code for the http_parser is 20k+ lines so I can't post it here.
My repo is here.
I'm trying to construct the parser in irrigation-server.hpp:43 within listen().
Edit:
But I am seeing an error coming from http_parser.h about it not finding #include <BaseTsd.h> Include file not found in browse.path.
Which now that I look at it, I don't think those typedefs are needed as we have stdint.h a part of the Arduino framework properly defining primitive int types. Those tyedefs aren't used anywhere in the http_parser anyway.
Another observation: http_parser.h has the following code up top, and my c_cpp_properties.json defines __cplusplus which means I shouldn't need the extern keyword in my code.
#ifdef __cplusplus
extern "C" {
#endif
Edit 2:
Oddly enough, I got it to build by moving the h and c file from the git submodule directory to the main application directory. So it was some kind of build issue.
I see that my include paths got reset and I did not have one defined within the project. So I think the compiler wasn't able to find the definition file.