diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..bf98cda --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required (VERSION 2.6) +project (miniweb) + +add_executable(miniweb + miniweb.c + httppil.c http.c httpxml.c httphandler.c httppost.c httpauth.c loadplugin.c + win32/win_compat.h httpint.h httpapi.h httpxml.h + ) + +add_subdirectory(plugin) + +if(UNIX) + add_compile_options("-pthread" "-DHAS_POSIX_TIMERS") + target_link_libraries(miniweb dl pthread rt) +elseif(WIN32) + target_link_libraries(miniweb Iphlpapi WSock32 Shell32) + add_compile_options("-D_CRT_SECURE_NO_WARNINGS") +endif(UNIX) diff --git a/Makefile.mak b/Makefile.mak new file mode 100644 index 0000000..715a284 --- /dev/null +++ b/Makefile.mak @@ -0,0 +1,52 @@ +CC=cl +LD=link +ALLFLAGS=/O2 /W3 /Ilibctb/include /nologo /MT /DNDEBUG +CFLAGS=$(ALLFLAGS) /TC +CPPFLAGS=$(ALLFLAGS) /TP /EHsc +HTTPOBJ=httppil.obj http.obj httpxml.obj httphandler.obj httppost.obj httpauth.obj loadplugin.obj +HEADERS=httpint.h httpapi.h httpxml.h + +OUTDIR=bin\\ + +DEFINES= /D_CRT_SECURE_NO_DEPRECATE /DNDEBUG /DNODEBUG /DWIN32 +LDFLAGS= WSock32.Lib shell32.lib Iphlpapi.lib + +!ifdef ENABLE_SERIAL +HTTPOBJ=$(HTTPOBJ) httpserial.obj libctb/src/fifo.obj libctb/src/serportx.obj +HEADERS=$(HEADERS) httpserial.h +DEFINES=$(DEFINES) /Ilibctb/include +!endif + +default: miniweb + +miniweb: miniweb.exe + +min: $(HTTPOBJ) httpmin.obj + $(LD) $(LDFLAGS) $(HTTPOBJ) httpmin.obj /OUT:$(OUTDIR)httpmin.exe + +miniweb.exe: $(HTTPOBJ) miniweb.obj + $(LD) $(LDFLAGS) $(HTTPOBJ) miniweb.obj /OUT:$(OUTDIR)miniweb.exe + +all : miniweb postfile plugin + +must_build: + +postfile : must_build + $(CC) $(CFLAGS) $(DEFINES) /Ipostfile postfile/*.c /link $(LDFLAGS) /OUT:$(OUTDIR)postfile.exe + +plugin : must_build + $(CC) $(CFLAGS) /I. $(DEFINES) plugin/plugin.c /link $(LDFLAGS) /DLL /OUT:$(OUTDIR)plugin.dll + +.c.obj:: + $(CC) $(DEFINES) $(CFLAGS) $< + +.cpp.obj:: + $(CC) $(DEFINES) $(CPPFLAGS) $< + +clean: + del /Q *.obj + del /Q $(OUTDIR)*.exe + del /Q $(OUTDIR)*.obj + del /Q $(OUTDIR)*.dll + del /Q $(OUTDIR)*.lib + diff --git a/Plugin.md b/Plugin.md new file mode 100644 index 0000000..255ab49 --- /dev/null +++ b/Plugin.md @@ -0,0 +1,36 @@ +# Miniweb plugin sytem +To add a plugin just use a C dynamic library interface. +See `PFNEVENTHANDLER` and `PFNEVENTHANDLER` in `loadplugin.h` +or `httpapi.h` or example: `plugin/plugin.c` + +## How to write plugin +Compile your plugin in a separate binary. + +The C interface: + + int YourUrlHandler(UrlHandlerParam* param); // PFNURLCALLBACK + int YourUrlHandlerEvent(MW_EVENT msg, int argi, void* argp) // PFNEVENTHANDLER + +The second is optional. + +## Usage +From command line: + + miniweb.exe -c "myplugin:plugin.dll:MyUrlHandler|MyUrlHandlerEvent" + +This start the default `miniweb` but loads your plugin. +You can have many `-c` arguments. See `miniweb -h` + +The plugin is registered with prefix `myplugin` which means that you can access it at http://localhost/myplugin + +### func1 +An other simple plugin example: + + miniweb.exe -c "func1:plugin.dll:func1" + +Go to http://localhost/func?v=dQw4w9WgXcQ + +This will parse and print the http request parameters. + + [624] request path: func1?v=ZgQMW4eVrzw + v: "ZgQMW4eVrzw" diff --git a/bin/htdocs/demodyn.htm b/bin/htdocs/demodyn.htm index 4939ff8..f003234 100644 --- a/bin/htdocs/demodyn.htm +++ b/bin/htdocs/demodyn.htm @@ -8,7 +8,7 @@
-
+