diff options
author | Patrick <Patrick.Murphy@multitech.com> | 2020-03-30 12:33:11 -0500 |
---|---|---|
committer | Patrick <Patrick.Murphy@multitech.com> | 2020-03-30 12:33:11 -0500 |
commit | 5b441749fb3525c54453b9fe8a0c2e5bb37cf53a (patch) | |
tree | 36aeceb528ae03b5613b9148ec5120ca6feeca2f | |
parent | 1a8133dc057302d1a026e177ec21f80df8d91f8e (diff) | |
download | commissioning-5b441749fb3525c54453b9fe8a0c2e5bb37cf53a.tar.gz commissioning-5b441749fb3525c54453b9fe8a0c2e5bb37cf53a.tar.bz2 commissioning-5b441749fb3525c54453b9fe8a0c2e5bb37cf53a.zip |
early experiments of integrating w/ yocto toolchain
-rw-r--r-- | src/Makefile | 19 | ||||
-rw-r--r-- | src/fcgi_commission.cpp | 44 |
2 files changed, 63 insertions, 0 deletions
diff --git a/src/Makefile b/src/Makefile new file mode 100644 index 0000000..94e823d --- /dev/null +++ b/src/Makefile @@ -0,0 +1,19 @@ +ARCH=$(shell uname -m) + +CC := g++ +SRCDIR := . +BUILDDIR := $(ARCH) +DEPLOYDIR := . +# DEPLOYDIR := deploy +# TARGET := $(DEPLOYDIR)/commissioning_$(ARCH).fcgi + +CCFLAGS := -std=c++11 -g -Wall -Werror -pedantic -pedantic-errors +LIB := -ljsoncpp -lfcgi++ -lfcgi +INC := -I ../include + +fcgi_commission.fcgi: fcgi_commission.o + $(CC) -o fcgi_commission.fcgi fcgi_commission.o + +clean: + @echo " $(RM) fcgi_commission.fcgi + diff --git a/src/fcgi_commission.cpp b/src/fcgi_commission.cpp new file mode 100644 index 0000000..bd082ff --- /dev/null +++ b/src/fcgi_commission.cpp @@ -0,0 +1,44 @@ +#include "fcgio.h" +#include <iostream> + +int main(void) { + // Backup the stdio streambufs + streambuf * cin_streambuf = cin.rdbuf(); + streambuf * cout_streambuf = cout.rdbuf(); + streambuf * cerr_streambuf = cerr.rdbuf(); + + FCGX_Request request; + + FCGX_Init(); + FCGX_InitRequest(&request, 0, 0); + + while (FCGX_Accept_r(&request) == 0) { + fcgi_streambuf cin_fcgi_streambuf(request.in); + fcgi_streambuf cout_fcgi_streambuf(request.out); + fcgi_streambuf cerr_fcgi_streambuf(request.err); + + cin.rdbuf(&cin_fcgi_streambuf); + cout.rdbuf(&cout_fcgi_streambuf); + cerr.rdbuf(&cerr_fcgi_streambuf); + + cout << "Content-type: text/html\r\n" + << "\r\n" + << "<html>\n" + << " <head>\n" + << " <title>Hello, World!</title>\n" + << " </head>\n" + << " <body>\n" + << " <h1>Hello, World!</h1>\n" + << " </body>\n" + << "</html>\n"; + + // Note: the fcgi_streambuf destructor will auto flush + } + + // restore stdio streambufs + cin.rdbuf(cin_streambuf); + cout.rdbuf(cout_streambuf); + cerr.rdbuf(cerr_streambuf); + + return 0; +}
\ No newline at end of file |