1
0
mirror of https://github.com/lammertb/libhttp.git synced 2025-07-29 21:01:13 +03:00

Regorganized directories to make them more intuitive

This commit is contained in:
Thomas Davis
2013-08-23 19:36:42 -04:00
parent 1bef635908
commit b2aee90d14
149 changed files with 836 additions and 669 deletions

View File

@ -7,7 +7,7 @@
# For help try, "make help" # For help try, "make help"
# #
include build/Makefile.in-os include resources/Makefile.in-os
CPROG = civetweb CPROG = civetweb
#CXXPROG = civetweb #CXXPROG = civetweb
@ -23,32 +23,30 @@ DATAROOTDIR = $(PREFIX)/share
DOCDIR = $(DATAROOTDIR)/doc/$(CPROG) DOCDIR = $(DATAROOTDIR)/doc/$(CPROG)
SYSCONFDIR = $(PREFIX)/etc SYSCONFDIR = $(PREFIX)/etc
BUILD_DIRS += $(BUILD_DIR) BUILD_DIRS += $(BUILD_DIR) $(BUILD_DIR)/src
LIB_SOURCES = civetweb.c LIB_SOURCES = src/civetweb.c
APP_SOURCES = main.c APP_SOURCES = src/main.c
SOURCE_DIRS = SOURCE_DIRS =
OBJECTS = $(LIB_SOURCES:.c=.o) $(APP_SOURCES:.c=.o) OBJECTS = $(LIB_SOURCES:.c=.o) $(APP_SOURCES:.c=.o)
# only set main compile options if none were chosen # only set main compile options if none were chosen
CFLAGS += -W -Wall -O2 -D$(TARGET_OS) -I. $(COPT) CFLAGS += -W -Wall -O2 -D$(TARGET_OS) -Iinclude $(COPT)
ifdef WITH_DEBUG ifdef WITH_DEBUG
CFLAGS += -g -DDEBUG_ENABLED CFLAGS += -g -DDEBUG_ENABLED
endif endif
ifdef WITH_CPP ifdef WITH_CPP
OBJECTS += cpp/CivetServer.o OBJECTS += src/CivetServer.o
BUILD_DIRS += $(BUILD_DIR)/cpp
CFLAGS += -Icpp
LCC = $(CXX) LCC = $(CXX)
else else
LCC = $(CC) LCC = $(CC)
endif endif
ifdef WITH_LUA ifdef WITH_LUA
include build/Makefile.in-lua include resources/Makefile.in-lua
endif endif
ifdef WITH_IPV6 ifdef WITH_IPV6
@ -142,12 +140,18 @@ slib: lib$(CPROG).so
clean: clean:
rm -rf $(BUILD_DIR) rm -rf $(BUILD_DIR)
distclean: clean
@rm -rf VS2012/Debug VS2012/*/Debug VS2012/*/*/Debug
@rm -rf VS2012/Release VS2012/*/Release VS2012/*/*/Release
rm -f $(CPROG) lib$(CPROG).so lib$(CPROG).a *.dmg
lib$(CPROG).a: $(BUILD_DIRS) $(LIB_OBJECTS) lib$(CPROG).a: $(BUILD_DIRS) $(LIB_OBJECTS)
@rm -f $@ @rm -f $@
ar cq $@ $(LIB_OBJECTS) ar cq $@ $(LIB_OBJECTS)
lib$(CPROG).so: CFLAGS += -fPIC
lib$(CPROG).so: $(BUILD_DIRS) $(LIB_OBJECTS) lib$(CPROG).so: $(BUILD_DIRS) $(LIB_OBJECTS)
$(LCC) -fPIC -shared -o $@ $(CFLAGS) $(LDFLAGS) $(LIB_OBJECTS) $(LCC) -shared -o $@ $(CFLAGS) $(LDFLAGS) $(LIB_OBJECTS)
$(CPROG): $(BUILD_DIRS) $(BUILD_OBJECTS) $(CPROG): $(BUILD_DIRS) $(BUILD_OBJECTS)
$(LCC) -o $@ $(CFLAGS) $(LDFLAGS) $(BUILD_OBJECTS) $(LIBS) $(LCC) -o $@ $(CFLAGS) $(LDFLAGS) $(BUILD_OBJECTS) $(LIBS)

View File

@ -17,11 +17,11 @@
# -DUSE_LUA - embed Lua in Civetweb (+100kb) # -DUSE_LUA - embed Lua in Civetweb (+100kb)
PROG = civetweb PROG = civetweb
CFLAGS = -std=c99 -O2 -W -Wall -pedantic -pthread -pipe $(COPT) CFLAGS = -std=c99 -O2 -W -Wall -pedantic -pthread -pipe -Iinclude $(COPT)
# To build with Lua, download and unzip Lua 5.2.1 source code into the # To build with Lua, download and unzip Lua 5.2.2 source code into the
# civetweb directory, and then add $(LUA_SOURCES) to CFLAGS # civetweb directory, and then add $(LUA_SOURCES) to CFLAGS
LUA = lua-5.2.1/src LUA = src/third_party/lua-5.2.2/src
LUA_FLAGS = -I$(LUA) -DLUA_COMPAT_ALL LUA_FLAGS = -I$(LUA) -DLUA_COMPAT_ALL
LUA_SOURCES = $(LUA)/lapi.c $(LUA)/lcode.c $(LUA)/lctype.c \ LUA_SOURCES = $(LUA)/lapi.c $(LUA)/lcode.c $(LUA)/lctype.c \
$(LUA)/ldebug.c $(LUA)/ldo.c $(LUA)/ldump.c \ $(LUA)/ldebug.c $(LUA)/ldo.c $(LUA)/ldump.c \
@ -40,9 +40,9 @@ ifneq ($(OS), Windows_NT)
LUA_FLAGS += -DLUA_USE_DLOPEN LUA_FLAGS += -DLUA_USE_DLOPEN
endif endif
LIB_SOURCES = civetweb.c md5.c LIB_SOURCES = src/civetweb.c
ALL_SOURCES = main.c $(LIB_SOURCES) build/sqlite3.c build/lsqlite3.c \ ALL_SOURCES = src/main.c $(LIB_SOURCES) src/third_party/sqlite3.c src/third_party/lsqlite3.c \
$(LUA_SOURCES) $(YASSL_SOURCES) $(LUA_SOURCES) $(YASSL_SOURCES)
SQLITE_FLAGS = -DTHREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS SQLITE_FLAGS = -DTHREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_FTS3_PARENTHESIS
@ -114,28 +114,28 @@ all:
lua.lib: $(LUA_WINOBJS) lua.lib: $(LUA_WINOBJS)
$(MSVC)/bin/lib /out:$@ $(LUA_WINOBJS) $(MSVC)/bin/lib /out:$@ $(LUA_WINOBJS)
# To build with lua, make sure you have Lua unpacked into lua-5.2.1 directory # To build with lua, make sure you have Lua unpacked into src/third_party/lua-5.2.1 directory
linux_lua: $(ALL_OBJECTS) linux_lua: $(ALL_OBJECTS)
$(CC) $(ALL_OBJECTS) -o $(PROG) -ldl $(CC) $(ALL_OBJECTS) -o $(PROG) -ldl
civetweb.o: mod_lua.inl civetweb.o: src/mod_lua.inl
# Make sure that the compiler flags come last in the compilation string. # Make sure that the compiler flags come last in the compilation string.
# If not so, this can break some on some Linux distros which use # If not so, this can break some on some Linux distros which use
# "-Wl,--as-needed" turned on by default in cc command. # "-Wl,--as-needed" turned on by default in cc command.
# Also, this is turned in many other distros in static linkage builds. # Also, this is turned in many other distros in static linkage builds.
linux: linux:
$(CC) $(LIB_SOURCES) main.c -o $(PROG) -ldl $(CFLAGS) $(CC) $(LIB_SOURCES) src/main.c -o $(PROG) -ldl $(CFLAGS)
mac: bsd mac: bsd
bsd: bsd:
$(CC) $(LIB_SOURCES) main.c -o $(PROG) $(CFLAGS) $(CC) $(LIB_SOURCES) src/main.c -o $(PROG) $(CFLAGS)
bsd_lua: $(ALL_OBJECTS) bsd_lua: $(ALL_OBJECTS)
$(CC) $(ALL_OBJECTS) -o $@ $(CC) $(ALL_OBJECTS) -o $@
solaris: solaris:
$(CC) $(LIB_SOURCES) main.c -lnsl -lsocket -o $(PROG) $(CFLAGS) $(CC) $(LIB_SOURCES) src/main.c -lnsl -lsocket -o $(PROG) $(CFLAGS)
lib$(PROG).a: $(ALL_OBJECTS) lib$(PROG).a: $(ALL_OBJECTS)
ar cr $@ $(ALL_OBJECTS) ar cr $@ $(ALL_OBJECTS)
@ -146,14 +146,14 @@ $(PROG).lib: $(ALL_WINOBJS)
# For codesign to work in non-interactive mode, unlock login keychain: # For codesign to work in non-interactive mode, unlock login keychain:
# security unlock ~/Library/Keychains/login.keychain # security unlock ~/Library/Keychains/login.keychain
# See e.g. http://lists.apple.com/archives/apple-cdsa/2008/Jan/msg00027.html # See e.g. http://lists.apple.com/archives/apple-cdsa/2008/Jan/msg00027.html
Civetweb: $(LIB_SOURCES) main.c Civetweb: $(LIB_SOURCES) src/main.c
$(CC) $(LIB_SOURCES) main.c build/lsqlite3.c build/sqlite3.c \ $(CC) $(LIB_SOURCES) src/main.c src/third_party/lsqlite3.c src/third_party/sqlite3.c \
-DUSE_COCOA $(CFLAGS) $(FLAGS) -mmacosx-version-min=10.4 \ -DUSE_COCOA $(CFLAGS) $(FLAGS) -mmacosx-version-min=10.4 \
$(YASSL_SOURCES) $(LUA_SOURCES) \ $(YASSL_SOURCES) $(LUA_SOURCES) \
-framework Cocoa -ObjC -arch i386 -arch x86_64 -o Civetweb -framework Cocoa -ObjC -arch i386 -arch x86_64 -o Civetweb
cocoa: Civetweb cocoa: Civetweb
V=`perl -lne '/define\s+CIVETWEB_VERSION\s+"(\S+)"/ and print $$1' $(LIB_SOURCES)`; DIR=dmg/Civetweb.app && rm -rf $$DIR && mkdir -p $$DIR/Contents/{MacOS,Resources} && install -m 644 build/civetweb_*.png build/civetweb.icns $$DIR/Contents/Resources/ && install -m 644 build/Info.plist $$DIR/Contents/ && install -m 755 Civetweb $$DIR/Contents/MacOS/ && ln -fs /Applications dmg/ ; hdiutil create Civetweb_$$V.dmg -volname "Civetweb $$V" -srcfolder dmg -ov #; rm -rf dmg V=`perl -lne '/define\s+CIVETWEB_VERSION\s+"(\S+)"/ and print $$1' $(LIB_SOURCES)`; DIR=dmg/Civetweb.app && rm -rf $$DIR && mkdir -p $$DIR/Contents/{MacOS,Resources} && install -m 644 resources/civetweb_*.png resources/civetweb.icns $$DIR/Contents/Resources/ && install -m 644 resources/Info.plist $$DIR/Contents/ && install -m 755 Civetweb $$DIR/Contents/MacOS/ && ln -fs /Applications dmg/ ; hdiutil create Civetweb_$$V.dmg -volname "Civetweb $$V" -srcfolder dmg -ov #; rm -rf dmg
un: un:
$(CC) test/unit_test.c -o unit_test -I. -I$(LUA) $(LUA_SOURCES) \ $(CC) test/unit_test.c -o unit_test -I. -I$(LUA) $(LUA_SOURCES) \
@ -167,18 +167,18 @@ wi:
./unit_test.exe ./unit_test.exe
windows: $(ALL_WINOBJS) windows: $(ALL_WINOBJS)
$(MSVC)/bin/rc build/res.rc $(MSVC)/bin/rc resources/res.rc
$(LINK) /nologo $(ALL_WINOBJS) build/res.res /out:$(PROG).exe $(LINK) /nologo $(ALL_WINOBJS) resources/res.res /out:$(PROG).exe
# Build for Windows under MinGW # Build for Windows under MinGW
#MINGWDBG= -DDEBUG -O0 -ggdb #MINGWDBG= -DDEBUG -O0 -ggdb
MINGWDBG= -DNDEBUG -Os MINGWDBG= -DNDEBUG -Os
MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT) MINGWOPT= -W -Wall -mthreads -Wl,--subsystem,console $(MINGWDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
mingw: mingw:
windres build\res.rc build\res.o windres resources\res.rc resources\res.o
$(CC) $(MINGWOPT) $(LIB_SOURCES) -lws2_32 \ $(CC) $(MINGWOPT) $(LIB_SOURCES) -lws2_32 \
-shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll -shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll
$(CC) $(MINGWOPT) $(LIB_SOURCES) main.c build\res.o \ $(CC) $(MINGWOPT) $(LIB_SOURCES) src/main.c resources\res.o \
-lws2_32 -ladvapi32 -lcomdlg32 -o $(PROG).exe -lws2_32 -ladvapi32 -lcomdlg32 -o $(PROG).exe
# Build for Windows under Cygwin # Build for Windows under Cygwin
@ -186,24 +186,23 @@ mingw:
CYGWINDBG= -DNDEBUG -Os CYGWINDBG= -DNDEBUG -Os
CYGWINOPT= -W -Wall -mthreads -Wl,--subsystem,console $(CYGWINDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT) CYGWINOPT= -W -Wall -mthreads -Wl,--subsystem,console $(CYGWINDBG) -DHAVE_STDINT $(GCC_WARNINGS) $(COPT)
cygwin: cygwin:
windres ./build/res.rc ./build/res.o windres ./resources/res.rc ./resources/res.o
$(CC) $(CYGWINOPT) $(LIB_SOURCES) -lws2_32 \ $(CC) $(CYGWINOPT) $(LIB_SOURCES) -lws2_32 \
-shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll -shared -Wl,--out-implib=$(PROG).lib -o $(PROG).dll
$(CC) $(CYGWINOPT) -Ibuild $(LIB_SOURCES) main.c ./build/res.o \ $(CC) $(CYGWINOPT) -Iinclude $(LIB_SOURCES) src/main.c ./resources/res.o \
-lws2_32 -ladvapi32 -o $(PROG).exe -lws2_32 -ladvapi32 -o $(PROG).exe
tests: tests:
perl test/test.pl $(TEST) perl test/test.pl $(TEST)
tarball: clean tarball: clean
F=civetweb-`perl -lne '/define\s+CIVETWEB_VERSION\s+"(\S+)"/ and print $$1' $(LIB_SOURCES)`.tgz ; cd .. && tar -czf x civetweb/{LICENSE.md,Makefile,examples,test,build,*.[ch],*.md} && mv x civetweb/$$F F=civetweb-`perl -lne '/define\s+CIVETWEB_VERSION\s+"(\S+)"/ and print $$1' $(LIB_SOURCES)`.tgz ; cd .. && tar -czf x civetweb/{LICENSE.md,Makefile,examples,test,resources,*.[ch],*.md} && mv x civetweb/$$F
release: tarball cocoa release: tarball cocoa
wine make windows wine make windows
V=`perl -lne '/define\s+CIVETWEB_VERSION\s+"(\S+)"/ and print $$1' $(LIB_SOURCES)`; upx civetweb.exe; cp civetweb.exe civetweb-$$V.exe; cp civetweb.exe civetweb_php_bundle/; zip -r civetweb_php_bundle_$$V.zip civetweb_php_bundle/ V=`perl -lne '/define\s+CIVETWEB_VERSION\s+"(\S+)"/ and print $$1' $(LIB_SOURCES)`; upx civetweb.exe; cp civetweb.exe civetweb-$$V.exe; cp civetweb.exe civetweb_php_bundle/; zip -r civetweb_php_bundle_$$V.zip civetweb_php_bundle/
clean: clean:
cd examples && $(MAKE) clean
rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz \ rm -rf *.o *.core $(PROG) *.obj *.so $(PROG).txt *.dSYM *.tgz \
$(PROG).exe *.dll *.lib build/res.o build/res.RES *.dSYM *.zip *.pdb \ $(PROG).exe *.dll *.lib resources/res.o resources/res.RES *.dSYM *.zip *.pdb \
*.exe *.dmg $(ALL_OBJECTS) $(ALL_WINOBJS) *.exe *.dmg $(ALL_OBJECTS) $(ALL_WINOBJS)

View File

@ -18,15 +18,15 @@ CONTENTS_DIR = $(DMG_DIR)/$(PACKAGE).app/Contents
RESOURCES_DIR = $(CONTENTS_DIR)/Resources RESOURCES_DIR = $(CONTENTS_DIR)/Resources
OSXBIN_DIR = $(CONTENTS_DIR)/MacOS OSXBIN_DIR = $(CONTENTS_DIR)/MacOS
CIVETWEB_VERSION = $(shell perl -lne '/define\s+CIVETWEB_VERSION\s+"(\S+)"/ and print $$1' civetweb.c) CIVETWEB_VERSION = $(shell perl -lne '/define\s+CIVETWEB_VERSION\s+"(\S+)"/ and print $$1' src/civetweb.c)
include Makefile include Makefile
package: build package: build
@rm -rf $(DMG_DIR) @rm -rf $(DMG_DIR)
install -d -m 755 $(CONTENTS_DIR) $(RESOURCES_DIR) $(OSXBIN_DIR) install -d -m 755 $(CONTENTS_DIR) $(RESOURCES_DIR) $(OSXBIN_DIR)
install -m 644 build/Info.plist $(CONTENTS_DIR)/ install -m 644 resources/Info.plist $(CONTENTS_DIR)/
install -m 644 build/civetweb_*.png build/civetweb.icns $(RESOURCES_DIR)/ install -m 644 resources/civetweb_*.png resources/civetweb.icns $(RESOURCES_DIR)/
install -m 755 $(CPROG) $(OSXBIN_DIR)/$(PACKAGE) install -m 755 $(CPROG) $(OSXBIN_DIR)/$(PACKAGE)
ln -fs /Applications $(DMG_DIR)/ ln -fs /Applications $(DMG_DIR)/
hdiutil create $(PACKAGE)_$(CIVETWEB_VERSION).dmg -volname "$(PACKAGE) $(CIVETWEB_VERSION)" -srcfolder $(DMG_DIR) -ov hdiutil create $(PACKAGE)_$(CIVETWEB_VERSION).dmg -volname "$(PACKAGE) $(CIVETWEB_VERSION)" -srcfolder $(DMG_DIR) -ov

View File

@ -18,7 +18,7 @@ https://groups.google.com/d/forum/civetweb
# Quick start documentation # Quick start documentation
- [ReleaseNotes.md](https://github.com/sunsetbrew/civetweb/blob/master/ReleaseNotes.md) - Release Notes - [RELEASE_NOTES.md](https://github.com/sunsetbrew/civetweb/blob/master/RELEASE_NOTES.md) - Release Notes
- [docs/UserManual.md](https://github.com/sunsetbrew/civetweb/blob/master/docs/UserManual.md) - End User Guide - [docs/UserManual.md](https://github.com/sunsetbrew/civetweb/blob/master/docs/UserManual.md) - End User Guide
- [docs/Building.md](https://github.com/sunsetbrew/civetweb/blob/master/docs/Building.md) - Buildiing the Server Quick Start - [docs/Building.md](https://github.com/sunsetbrew/civetweb/blob/master/docs/Building.md) - Buildiing the Server Quick Start
- [docs/Embedding.md](https://github.com/sunsetbrew/civetweb/blob/master/docs/Embedding.md) - Embedding Quick Start - [docs/Embedding.md](https://github.com/sunsetbrew/civetweb/blob/master/docs/Embedding.md) - Embedding Quick Start

View File

@ -6,11 +6,12 @@ The objective of this release is to establish a maintable code base, ensure MIT
Changes Changes
------- -------
- Reorangized build directories to make them more intuitive
- Added new build rules for lib and slib with option to include C++ class - Added new build rules for lib and slib with option to include C++ class
- Upgraded LUA from 5.2.1 to 5.2.2 - Upgraded LUA from 5.2.1 to 5.2.2
- Added fallback configuration file path for Linux systems. - Added fallback configuration file path for Linux systems.
+ Good for having a system wide default configuration /etc/civetweb/civetweb.conf + Good for having a system wide default configuration /usr/local/etc/civetweb.conf
- Added new C++ abstraction class cpp/CivetServer - Added new C++ abstraction class CivetServer
- Added thread safety for and fixed websocket defects (Morgan McGuire) - Added thread safety for and fixed websocket defects (Morgan McGuire)
- Created PKGBUILD to use Arch distribution (Daniel Oaks) - Created PKGBUILD to use Arch distribution (Daniel Oaks)
- Created new documentation on Embeddeding, Building and yaSSL (see docs/). - Created new documentation on Embeddeding, Building and yaSSL (see docs/).

View File

@ -52,7 +52,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -68,7 +68,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -78,20 +78,17 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\civetweb.c" /> <ClCompile Include="..\..\src\civetweb.c" />
<ClCompile Include="..\..\main.c" /> <ClCompile Include="..\..\src\main.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\..\build\systray.ico" /> <Image Include="..\..\resources\systray.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\build\res.rc" /> <ResourceCompile Include="..\..\resources\res.rc" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\civetweb.h" /> <ClInclude Include="..\..\include\civetweb.h" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\md5.inl" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -15,31 +15,26 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\main.c"> <ClCompile Include="..\..\src\main.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\civetweb.c"> <ClCompile Include="..\..\src\civetweb.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\..\build\systray.ico"> <Image Include="..\..\resources\systray.ico">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</Image> </Image>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\build\res.rc"> <ResourceCompile Include="..\..\resources\res.rc">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\civetweb.h"> <ClInclude Include="..\..\include\civetweb.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\..\md5.inl">
<Filter>Header Files</Filter>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -52,7 +52,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..;$(ProjectDir)..\..\lua-5.2.2\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.2\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -68,7 +68,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>LUA_COMPAT_ALL;USE_LUA;USE_LUA_SQLITE3;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..;$(ProjectDir)..\..\lua-5.2.2\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\include;$(ProjectDir)..\..\src\third_party\lua-5.2.2\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -81,30 +81,26 @@
<Text Include="ReadMe.txt" /> <Text Include="ReadMe.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\civetweb.h" /> <ClInclude Include="..\..\include\civetweb.h" />
<ClInclude Include="..\..\lua-5.2.2\src\lauxlib.h" /> <ClInclude Include="..\..\src\third_party\lua-5.2.2\src\lauxlib.h" />
<ClInclude Include="..\..\lua-5.2.2\src\lua.h" /> <ClInclude Include="..\..\src\third_party\lua-5.2.2\src\lua.h" />
<ClInclude Include="Resource.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\civetweb.c" /> <ClCompile Include="..\..\src\civetweb.c" />
<ClCompile Include="..\..\main.c" /> <ClCompile Include="..\..\src\main.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\build\res.rc" /> <ResourceCompile Include="..\..\resources\res.rc" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\..\build\systray.ico" /> <Image Include="..\..\resources\systray.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\lua_lib\lua_lib.vcxproj"> <ProjectReference Include="..\lua_lib\lua_lib.vcxproj">
<Project>{8f5e5d77-d269-4665-9e27-1045da6cf0d8}</Project> <Project>{8f5e5d77-d269-4665-9e27-1045da6cf0d8}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\..\md5.inl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@ -18,40 +18,32 @@
<Text Include="ReadMe.txt" /> <Text Include="ReadMe.txt" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="Resource.h"> <ClInclude Include="..\..\include\civetweb.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\civetweb.h"> <ClInclude Include="..\..\src\third_party\lua-5.2.2\src\lua.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\lua-5.2.2\src\lua.h"> <ClInclude Include="..\..\src\third_party\lua-5.2.2\src\lauxlib.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\lua-5.2.2\src\lauxlib.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\civetweb.c"> <ClCompile Include="..\..\src\civetweb.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\main.c"> <ClCompile Include="..\..\src\main.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\build\res.rc"> <ResourceCompile Include="..\..\resources\res.rc">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\..\build\systray.ico"> <Image Include="..\..\resources\systray.ico">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</Image> </Image>
</ItemGroup> </ItemGroup>
<ItemGroup> </Project>
<None Include="..\..\md5.inl">
<Filter>Header Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -52,7 +52,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>USE_YASSL;NO_SSL_DL;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>USE_YASSL;NO_SSL_DL;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\cyassl-2.7.0\;$(ProjectDir)..\..\..\..\cyassl-2.7.0\cyassl\</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\include;$(ProjectDir)..\..\..\..\cyassl-2.7.0\;$(ProjectDir)..\..\..\..\cyassl-2.7.0\cyassl\</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -68,7 +68,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>USE_YASSL;NO_SSL_DL;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>USE_YASSL;NO_SSL_DL;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\..\..\cyassl-2.7.0\;$(ProjectDir)..\..\..\..\cyassl-2.7.0\cyassl\</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\..\include;$(ProjectDir)..\..\..\..\cyassl-2.7.0\;$(ProjectDir)..\..\..\..\cyassl-2.7.0\cyassl\</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -78,26 +78,23 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\civetweb.h" /> <ClInclude Include="..\..\..\include\civetweb.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\civetweb.c" /> <ClCompile Include="..\..\..\src\civetweb.c" />
<ClCompile Include="..\..\..\main.c" /> <ClCompile Include="..\..\..\src\main.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\..\build\res.rc" /> <ResourceCompile Include="..\..\..\resources\res.rc" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\..\..\build\systray.ico" /> <Image Include="..\..\..\resources\systray.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\yassl_lib\yassl_lib.vcxproj"> <ProjectReference Include="..\yassl_lib\yassl_lib.vcxproj">
<Project>{8c0c878b-bbd6-4241-bca6-61753ffcc7f1}</Project> <Project>{8c0c878b-bbd6-4241-bca6-61753ffcc7f1}</Project>
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\..\..\md5.inl" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>

View File

@ -15,31 +15,26 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\..\civetweb.h"> <ClInclude Include="..\..\..\include\civetweb.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\civetweb.c"> <ClCompile Include="..\..\..\src\civetweb.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\..\main.c"> <ClCompile Include="..\..\..\src\main.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\..\..\build\res.rc"> <ResourceCompile Include="..\..\..\resources\res.rc">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</ResourceCompile> </ResourceCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="..\..\..\build\systray.ico"> <Image Include="..\..\..\resources\systray.ico">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</Image> </Image>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\..\..\md5.inl">
<Filter>Header Files</Filter>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -52,7 +52,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -68,7 +68,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -78,18 +78,15 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\civetweb.h" /> <ClInclude Include="..\..\include\civetweb.h" />
<ClInclude Include="..\..\cpp\CivetServer.h" /> <ClInclude Include="..\..\include\CivetServer.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\civetweb.c" /> <ClCompile Include="..\..\src\civetweb.c" />
<ClCompile Include="..\..\cpp\CivetServer.cpp" /> <ClCompile Include="..\..\src\CivetServer.cpp" />
<ClCompile Include="..\..\cpp\example.cpp" /> <ClCompile Include="..\..\examples\embedded_cpp\embedded_cpp.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\md5.inl" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">
</ImportGroup> </ImportGroup>
</Project> </Project>

View File

@ -15,27 +15,22 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\civetweb.h"> <ClInclude Include="..\..\include\civetweb.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="..\..\cpp\CivetServer.h"> <ClInclude Include="..\..\include\CivetServer.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\cpp\example.cpp"> <ClCompile Include="..\..\examples\embedded_cpp\embedded_cpp.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\civetweb.c"> <ClCompile Include="..\..\src\civetweb.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\cpp\CivetServer.cpp"> <ClCompile Include="..\..\src\CivetServer.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> </Project>
<None Include="..\..\md5.inl">
<Filter>Header Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@ -52,7 +52,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>USE_WEBSOCKET;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>USE_WEBSOCKET;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -68,7 +68,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>USE_WEBSOCKET;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>USE_WEBSOCKET;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
@ -78,14 +78,11 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\civetweb.h" /> <ClInclude Include="..\..\include\civetweb.h" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\civetweb.c" /> <ClCompile Include="..\..\src\civetweb.c" />
<ClCompile Include="..\..\examples\websocket.c" /> <ClCompile Include="..\..\examples\websocket\websocket.c" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\md5.inl" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -15,21 +15,16 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\civetweb.h"> <ClInclude Include="..\..\include\civetweb.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\examples\websocket.c"> <ClCompile Include="..\..\examples\websocket\websocket.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\civetweb.c"> <ClCompile Include="..\..\src\civetweb.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup>
<None Include="..\..\md5.inl">
<Filter>Header Files</Filter>
</None>
</ItemGroup>
</Project> </Project>

View File

@ -47,7 +47,7 @@
<WarningLevel>Level3</WarningLevel> <WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<PreprocessorDefinitions>LUA_COMPAT_ALL;THREADSAFE=1;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_FTS3_PARENTHESIS;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>LUA_COMPAT_ALL;THREADSAFE=1;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_FTS3_PARENTHESIS;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\lua-5.2.2\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\src\third_party\lua-5.2.2\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -63,7 +63,7 @@
<FunctionLevelLinking>true</FunctionLevelLinking> <FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions> <IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>LUA_COMPAT_ALL;THREADSAFE=1;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_FTS3_PARENTHESIS;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>LUA_COMPAT_ALL;THREADSAFE=1;SQLITE_ENABLE_FTS3;SQLITE_ENABLE_FTS3_PARENTHESIS;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(ProjectDir)..\..\lua-5.2.2\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <AdditionalIncludeDirectories>$(ProjectDir)..\..\src\third_party\lua-5.2.2\src;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile> </ClCompile>
<Link> <Link>
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
@ -73,43 +73,43 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\lua-5.2.2\src\lapi.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lapi.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lauxlib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lauxlib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lbaselib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lbaselib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lbitlib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lbitlib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lcode.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lcode.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lcorolib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lcorolib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lctype.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lctype.c" />
<ClCompile Include="..\..\lua-5.2.2\src\ldblib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ldblib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\ldebug.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ldebug.c" />
<ClCompile Include="..\..\lua-5.2.2\src\ldo.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ldo.c" />
<ClCompile Include="..\..\lua-5.2.2\src\ldump.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ldump.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lfunc.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lfunc.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lgc.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lgc.c" />
<ClCompile Include="..\..\lua-5.2.2\src\linit.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\linit.c" />
<ClCompile Include="..\..\lua-5.2.2\src\liolib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\liolib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\llex.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\llex.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lmathlib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lmathlib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lmem.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lmem.c" />
<ClCompile Include="..\..\lua-5.2.2\src\loadlib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\loadlib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lobject.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lobject.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lopcodes.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lopcodes.c" />
<ClCompile Include="..\..\lua-5.2.2\src\loslib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\loslib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lparser.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lparser.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lstate.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lstate.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lstring.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lstring.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lstrlib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lstrlib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\ltable.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ltable.c" />
<ClCompile Include="..\..\lua-5.2.2\src\ltablib.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ltablib.c" />
<ClCompile Include="..\..\lua-5.2.2\src\ltm.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ltm.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lundump.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lundump.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lvm.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lvm.c" />
<ClCompile Include="..\..\lua-5.2.2\src\lzio.c" /> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lzio.c" />
<ClCompile Include="..\..\build\lsqlite3.c" /> <ClCompile Include="..\..\src\third_party\lsqlite3.c" />
<ClCompile Include="..\..\build\sqlite3.c" /> <ClCompile Include="..\..\src\third_party\sqlite3.c" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\build\sqlite3.h" /> <ClInclude Include="..\..\src\third_party\sqlite3.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets"> <ImportGroup Label="ExtensionTargets">

View File

@ -15,111 +15,111 @@
</Filter> </Filter>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\lua-5.2.2\src\lapi.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lapi.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lcode.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lcode.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lctype.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lctype.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\ldebug.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ldebug.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\ldo.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ldo.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\ldump.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ldump.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lfunc.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lfunc.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lgc.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lgc.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\llex.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\llex.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lmem.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lmem.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lobject.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lobject.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lopcodes.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lopcodes.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lparser.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lparser.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lstate.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lstate.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lstring.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lstring.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\ltable.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ltable.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\ltm.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ltm.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lundump.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lundump.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lauxlib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lauxlib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lbaselib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lbaselib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lbitlib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lbitlib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lcorolib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lcorolib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lvm.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lvm.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lzio.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lzio.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\ldblib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ldblib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\linit.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\linit.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\liolib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\liolib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lmathlib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lmathlib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\loadlib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\loadlib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\loslib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\loslib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\lstrlib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\lstrlib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\lua-5.2.2\src\ltablib.c"> <ClCompile Include="..\..\src\third_party\lua-5.2.2\src\ltablib.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\build\lsqlite3.c"> <ClCompile Include="..\..\src\third_party\lsqlite3.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="..\..\build\sqlite3.c"> <ClCompile Include="..\..\src\third_party\sqlite3.c">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="..\..\build\sqlite3.h"> <ClInclude Include="..\..\src\third_party\sqlite3.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
</ItemGroup> </ItemGroup>

View File

@ -1,127 +0,0 @@
/*
* Copyright (c) 2013 No Face Press, LLC
* License http://opensource.org/licenses/mit-license.php MIT License
*/
#include "CivetServer.h"
#include <stdlib.h>
#include <string.h>
int CivetServer::begin_request_callback(struct mg_connection *conn) {
struct mg_request_info *request_info = mg_get_request_info(conn);
if (!request_info->user_data)
return 0;
CivetServer *me = (CivetServer*) (request_info->user_data);
if (me->handleRequest(conn)) {
return 1; // Mark as processed
}
return 0;
}
bool CivetServer::handleRequest(struct mg_connection *conn) {
struct mg_request_info *request_info = mg_get_request_info(conn);
CivetHandler *handler = getHandler(request_info->uri);
if (handler) {
if (strcmp(request_info->request_method, "GET") == 0) {
return handler->handleGet(this, conn);
} else if (strcmp(request_info->request_method, "POST") == 0) {
return handler->handlePost(this, conn);
} else if (strcmp(request_info->request_method, "PUT") == 0) {
return !handler->handlePost(this, conn);
} else if (strcmp(request_info->request_method, "DELETE") == 0) {
return !handler->handlePost(this, conn);
}
}
return false; // No handler found
}
CivetServer::CivetServer(const char **options,
const struct mg_callbacks *_callbacks) :
context(0) {
struct mg_callbacks callbacks;
if (_callbacks) {
memcpy(&callbacks, _callbacks, sizeof(callbacks));
} else {
memset(&callbacks, 0, sizeof(callbacks));
}
callbacks.begin_request = &begin_request_callback;
context = mg_start(&callbacks, this, options);
}
CivetServer::~CivetServer() {
close();
}
CivetHandler *CivetServer::getHandler(const char *uri, unsigned urilen) const {
for (unsigned index = 0; index < uris.size(); index++) {
const std::string &handlerURI = uris[index];
// first try for an exact match
if (handlerURI == uri) {
return handlers[index];
}
// next try for a partial match
// we will accept uri/something
if (handlerURI.length() < urilen
&& uri[handlerURI.length()] == '/'
&& handlerURI.compare(0, handlerURI.length(), uri, handlerURI.length()) == 0) {
return handlers[index];
}
}
return 0; // none found
}
void CivetServer::addHandler(const std::string &uri, CivetHandler *handler) {
int index = getIndex(uri);
if (index < 0) {
uris.push_back(uri);
handlers.push_back(handler);
} else if (handlers[index] != handler) {
delete handlers[index];
handlers[index] = handler;
}
}
void CivetServer::removeHandler(const std::string &uri) {
int index = getIndex(uri);
if (index >= 0) {
uris.erase(uris.begin() + index, uris.begin() + index + 1);
handlers.erase(handlers.begin() + index, handlers.begin() + index + 1);
}
}
int CivetServer::getIndex(const std::string &uri) const {
for (unsigned index = 0; index < uris.size(); index++) {
if (uris[index].compare(uri) == 0)
return index;
}
return -1;
}
void CivetServer::close() {
if (context) {
mg_stop (context);
context = 0;
}
for (int i = handlers.size() - 1; i >= 0; i--) {
delete handlers[i];
}
handlers.clear();
uris.clear();
}

View File

@ -1,193 +0,0 @@
/*
* Copyright (c) 2013 No Face Press, LLC
* License http://opensource.org/licenses/mit-license.php MIT License
*/
#ifndef _CIVETWEB_SERVER_H_
#define _CIVETWEB_SERVER_H_
#ifdef __cplusplus
#include "civetweb.h"
#include <vector>
#include <string>
class CivetServer; // forward declaration
/**
* Basic interface for a URI request handler. Handlers implementations
* must be reentrant.
*/
class CivetHandler {
public:
/**
* Destructor
*/
virtual ~CivetHandler() {
}
/**
* Callback method for GET request.
*
* @param server - the calling server
* @param conn - the connection information
* @returns true if implemented, false otherwise
*/
virtual bool handleGet(CivetServer *server, struct mg_connection *conn) {
return false;
}
/**
* Callback method for POST request.
*
* @param server - the calling server
* @param conn - the connection information
* @returns true if implemented, false otherwise
*/
virtual bool handlePost(CivetServer *server, struct mg_connection *conn) {
return false;
}
/**
* Callback method for PUT request.
*
* @param server - the calling server
* @param conn - the connection information
* @returns true if implemented, false otherwise
*/
virtual bool handlePut(CivetServer *server, struct mg_connection *conn) {
return false;
}
/**
* Callback method for DELETE request.
*
* @param server - the calling server
* @param conn - the connection information
* @returns true if implemented, false otherwise
*/
virtual bool handleDelete(CivetServer *server, struct mg_connection *conn) {
return false;
}
};
/**
* CivetServer
*
* Basic class for embedded web server. This has a URL mapping built-in.
*/
class CivetServer {
public:
/**
* Constructor
*
* This automatically starts the sever.
* It is good practice to call getContext() after this in case there
* were errors starting the server.
*
* @param options - the web server options.
* @param callbacks - optional web server callback methods.
* Note that this class overrides begin_request callback.
*/
CivetServer(const char **options, const struct mg_callbacks *callbacks = 0);
/**
* Destructor
*/
virtual ~CivetServer();
/**
* close()
*
* Stops server and frees resources.
*/
void close();
/**
* getContext()
*
* @return the context or 0 if not running.
*/
const struct mg_context *getContext() const {
return context;
}
/**
* addHandler(const std::string &, CivetHandler *)
*
* Adds a URI handler. If there is existing URI handler, it will
* be replaced with this one. The handler is "owned" by this server
* and will be deallocated with it.
*
* URI's are ordered and partcial URI's are supported. For example,
* consider two URIs in order: /a/b and /a; /a matches
* /a, /a/b matches /a/b, /a/c matches /a. Reversing the order to
* /a and /a/b; /a matches /a/b, /a/b matches /a. /a/c matches /a.
*
* @param uri - URI to match.
* @param handler - handler instance to use. This will be free'ed
* when the server closes and instances cannot be reused.
*/
void addHandler(const std::string &uri, CivetHandler *handler);
/**
* removeHandler(const std::string &)
*
* Removes a handler, deleting it if found.
*
* @param - the exact URL used in addHandler().
*/
void removeHandler(const std::string &uri);
/**
* getHandler(const std::string &uri)
*
* @param uri - the URI
* @returns the handler that matches the requested URI or 0 if none were found.
*/
CivetHandler *getHandler(const std::string &uri) const {
return getHandler(uri.data(), uri.length());
}
/**
* getHandler(const char *uri, unsigned urilen)
*
* @param uri - the URI
* @param urilen - the length of the URI
* @returns the handler that matches the requested URI or 0 if none were found.
*/
CivetHandler *getHandler(const char *uri, unsigned urilen) const;
protected:
/**
* handleRequest(struct mg_connection *)
*
* Handles the incomming request.
*
* @param conn - the connection information
* @returns true if implemented, false otherwise
*/
virtual bool handleRequest(struct mg_connection *conn);
/**
* Returns the index of the handler that matches the
* URI exactly.
*
* @param uri - the url to match
*/
int getIndex(const std::string &uri) const;
std::vector<std::string> uris;
std::vector<CivetHandler *> handlers;
struct mg_context *context;
private:
static int begin_request_callback(struct mg_connection *conn);
};
#endif /* __cplusplus */
#endif /* _CIVETWEB_SERVER_H_ */

View File

@ -1,23 +0,0 @@
#
# Copyright (c) 2013 No Face Press, LLC
# License http://opensource.org/licenses/mit-license.php MIT License
#
CFLAGS= -W -Wall -Wno-unused-parameter -I.. -I. -g
LIB_SOURCES = CivetServer.cpp ../civetweb.c ../md5.c
LIBS = -lpthread
all:
$(CXX) $(CFLAGS) example.cpp $(LIB_SOURCES) $(LIBS) -o example;
MSVC = e:/vc6
CL = $(MSVC)/bin/cl
CLFLAGS = /MD /TC /nologo $(DBG) /W3 /DNO_SSL \
/I$(MSVC)/include /I.. /I. /Dsnprintf=_snprintf \
/link /incremental:no /libpath:$(MSVC)/lib /machine:IX86
windows:
$(CL) example.cpp $(LIB_SOURCES) $(CLFLAGS)
clean:
rm -rf example *.exe *.dSYM *.obj

View File

@ -38,12 +38,16 @@ Install on the system, Linux only.
``` ```
make lib WITH_CPP=1 WITH_IPV6=1 make lib WITH_CPP=1 WITH_IPV6=1
make slib WITH_CPP=1 WITH_LUA=1 WITH_WEBSOCKET=1 make clean slib WITH_CPP=1 WITH_LUA=1 WITH_WEBSOCKET=1
``` ```
Build the static and shared libraries. Build the static and shared libraries.
The *WITH_CPP* make option is to include the CivetServer class. The *WITH_CPP* make option is to include the CivetServer class.
The additional make options configure the library just as it would the application. The additional make options configure the library just as it would the application.
The *slib* option should be done on a separate clean build as position
independent code (PIC) is required for it. Trying to run it after
building the static library or the server will result in a link error.
``` ```
make clean make clean
``` ```
@ -90,7 +94,7 @@ make build COPT="-DNDEBUG -DNO_CGI"
Take total control with *CC*, *COPTS* and *TARGET_OS* as make options. Take total control with *CC*, *COPTS* and *TARGET_OS* as make options.
TARGET_OS is used to determine some compile details as will as code function. TARGET_OS is used to determine some compile details as will as code function.
TARGET_OS values should be be one found in *build/Makefile.in-os*. TARGET_OS values should be be one found in *resources/Makefile.in-os*.
``` ```
make CC=arm-none-linux-gnueabi-gcc COPT="-march=armv7-a -mfpu=vfp -mfloat-abi=softfp" TARGET_OS=FROG make CC=arm-none-linux-gnueabi-gcc COPT="-march=armv7-a -mfpu=vfp -mfloat-abi=softfp" TARGET_OS=FROG
@ -119,7 +123,7 @@ Note : You dont need root access to run civetweb on Android.
- Download the source from the Downloads page. - Download the source from the Downloads page.
- Download the Android NDK from [http://developer.android.com/tools/sdk/ndk/index.html](http://developer.android.com/tools/sdk/ndk/index.html) - Download the Android NDK from [http://developer.android.com/tools/sdk/ndk/index.html](http://developer.android.com/tools/sdk/ndk/index.html)
- Run `/path-to-ndk/ndk-build -C /path-to-civetweb/build` - Run `/path-to-ndk/ndk-build -C /path-to-civetweb/resources`
That should generate civetweb/lib/armeabi/civetweb That should generate civetweb/lib/armeabi/civetweb
- Using the adb tool (you need to have Android SDK installed for that), - Using the adb tool (you need to have Android SDK installed for that),
push the generated civetweb binary to `/data/local` folder on device. push the generated civetweb binary to `/data/local` folder on device.

View File

@ -15,20 +15,20 @@ The *INL* file extension represents code that is statically included inline in a
#### Required Files #### Required Files
1. HTTP Server API 1. HTTP Server API
- civetweb.c - src/civetweb.c
- civetweb.h - include/civetweb.h
2. MD5 API 2. MD5 API
- md5.inl - src/md5.inl
3. C++ Wrapper (Optional) 3. C++ Wrapper (Optional)
- cpp/CivetServer.cpp - src/CivetServer.cpp
- cpp/CivetServer.h - include/CivetServer.h
#### Other Files #### Other Files
1. Reference C Server 1. Reference C Server
- main.c - src/main.c
2. Reference C++ Server 2. Reference C++ Server
- cpp/example.cpp - examples/embedded_cpp/embedded_cpp.cpp
Quick Start Quick Start
------ ------
@ -61,8 +61,8 @@ LUA is a server side include functionality. Files ending in .la will be process
##### Add the following sources ##### Add the following sources
- mod_lua.inl - src/mod_lua.inl
- lua-5.2.2/src - src/third_party/lua-5.2.2/src
+ lapi.c + lapi.c
+ lauxlib.c + lauxlib.c
+ lbaselib.c + lbaselib.c
@ -95,9 +95,9 @@ LUA is a server side include functionality. Files ending in .la will be process
+ lundump.c + lundump.c
+ lvm.c + lvm.c
+ lzio.c + lzio.c
- build/sqlite3.c - src/third_party/sqlite3.c
- build/sqlite3.h - src/third_party/sqlite3.h
- build/lsqlite3.c - src/third_party/lsqlite3.c
Civetweb internals Civetweb internals

View File

@ -258,7 +258,7 @@ directory is commonly referenced as dot (`.`).
Path to SSL certificate file. This option is only required when at least one Path to SSL certificate file. This option is only required when at least one
of the `listening_ports` is SSL. The file must be in PEM format, of the `listening_ports` is SSL. The file must be in PEM format,
and it must have both private key and certificate, see for example and it must have both private key and certificate, see for example
[ssl_cert.pem](https://github.com/sunsetbrew/civetweb/blob/master/build/ssl_cert.pem) [ssl_cert.pem](https://github.com/sunsetbrew/civetweb/blob/master/resources/ssl_cert.pem)
### num_threads `50` ### num_threads `50`
Number of worker threads. Civetweb handles each incoming connection in a Number of worker threads. Civetweb handles each incoming connection in a
@ -332,10 +332,10 @@ are accessible from the Lua code (please check reference manual for details),
and also information about the request is available in `mg.request_info` object, and also information about the request is available in `mg.request_info` object,
like request method, all headers, etcetera. Please refer to like request method, all headers, etcetera. Please refer to
`struct mg_request_info` definition in `struct mg_request_info` definition in
[civetweb.h](https://github.com/sunsetbrew/civetweb/blob/master/civetweb.h) [civetweb.h](https://github.com/sunsetbrew/civetweb/blob/master/include/civetweb.h)
to see what kind of information is present in `mg.request_info` object. Also, to see what kind of information is present in `mg.request_info` object. Also,
[page.lp](https://github.com/sunsetbrew/civetweb/blob/master/test/page.lp) and [page.lp](https://github.com/sunsetbrew/civetweb/blob/master/test/page.lp) and
[prime_numbers.lp](https://github.com/sunsetbrew/civetweb/blob/master/examples/lua/prime_numbers.lp) [prime_numbers.lp](https://github.com/sunsetbrew/civetweb/blob/master/examples/docroot/prime_numbers.lp)
contains some example code that uses `request_info` and other functions(form submitting for example). contains some example code that uses `request_info` and other functions(form submitting for example).
Civetweb exports the following to the Lua server page: Civetweb exports the following to the Lua server page:

View File

@ -1,26 +0,0 @@
CFLAGS= -W -Wall -I.. -pthread -g
LIB_SOURCE = ../civetweb.c
all:
OS=`uname`; \
test "$$OS" = Linux && LIBS="-ldl" ; \
$(CC) $(CFLAGS) hello.c $(LIB_SOURCE) $$LIBS $(ADD) -o hello;
$(CC) $(CFLAGS) upload.c $(LIB_SOURCE) $$LIBS $(ADD) -o upload;
$(CC) $(CFLAGS) post.c $(LIB_SOURCE) $$LIBS $(ADD) -o post;
$(CC) $(CFLAGS) -DUSE_WEBSOCKET websocket.c $(LIB_SOURCE) $$LIBS $(ADD) -o websocket;
$(CC) $(CFLAGS) chat.c $(LIB_SOURCE) $$LIBS $(ADD) -o chat
MSVC = e:/vc6
CL = $(MSVC)/bin/cl
CLFLAGS = /MD /TC /nologo $(DBG) /W3 /DNO_SSL \
/I$(MSVC)/include /I.. /Dsnprintf=_snprintf \
/link /incremental:no /libpath:$(MSVC)/lib /machine:IX86
windows:
$(CL) upload.c $(LIB_SOURCE) $(CLFLAGS)
$(CL) hello.c $(LIB_SOURCE) $(CLFLAGS)
$(CL) post.c $(LIB_SOURCE) $(CLFLAGS)
$(CL) /DUSE_WEBSOCKET websocket.c $(LIB_SOURCE) $(CLFLAGS)
clean:
rm -rf hello upload post websocket chat *.exe *.dSYM *.obj

40
examples/chat/Makefile Normal file
View File

@ -0,0 +1,40 @@
#
# Copyright (c) 2013 No Face Press, LLC
# License http://opensource.org/licenses/mit-license.php MIT License
#
#This makefile is used to test the other Makefiles
PROG = chat
SRC = chat.c
TOP = ../..
CIVETWEB_LIB = libcivetweb.a
SSL_CERT = ssl_cert.pem
CFLAGS = -I$(TOP)/include $(COPT)
LIBS = -lpthread
include $(TOP)/resources/Makefile.in-os
ifeq ($(TARGET_OS),LINUX)
LIBS += -ldl
endif
all: $(PROG) $(SSL_CERT)
$(PROG): $(CIVETWEB_LIB) $(SRC)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(SRC) $(CIVETWEB_LIB) $(LIBS)
$(CIVETWEB_LIB):
$(MAKE) -C $(TOP) clean lib
cp $(TOP)/$(CIVETWEB_LIB) .
$(SSL_CERT):
cp $(TOP)/resources/$(SSL_CERT) .
clean:
rm -f $(CIVETWEB_LIB) $(PROG) $(SSL_CERT)
.PHONY: all clean

View File

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,36 @@
#
# Copyright (c) 2013 No Face Press, LLC
# License http://opensource.org/licenses/mit-license.php MIT License
#
#This makefile is used to test the other Makefiles
PROG = embedded_cpp
SRC = embedded_cpp.cpp
TOP = ../..
CIVETWEB_LIB = libcivetweb.a
CFLAGS = -I$(TOP)/include $(COPT)
LIBS = -lpthread
include $(TOP)/resources/Makefile.in-os
ifeq ($(TARGET_OS),LINUX)
LIBS += -ldl
endif
all: $(PROG)
$(PROG): $(CIVETWEB_LIB) $(SRC)
$(CXX) -o $@ $(CFLAGS) $(LDFLAGS) $(SRC) $(CIVETWEB_LIB) $(LIBS)
$(CIVETWEB_LIB):
$(MAKE) -C $(TOP) clean lib WITH_CPP=1
cp $(TOP)/$(CIVETWEB_LIB) .
clean:
rm -f $(CIVETWEB_LIB) $(PROG)
.PHONY: all clean

36
examples/hello/Makefile Normal file
View File

@ -0,0 +1,36 @@
#
# Copyright (c) 2013 No Face Press, LLC
# License http://opensource.org/licenses/mit-license.php MIT License
#
#This makefile is used to test the other Makefiles
PROG = hello
SRC = hello.c
TOP = ../..
CIVETWEB_LIB = libcivetweb.a
CFLAGS = -I$(TOP)/include $(COPT)
LIBS = -lpthread
include $(TOP)/resources/Makefile.in-os
ifeq ($(TARGET_OS),LINUX)
LIBS += -ldl
endif
all: $(PROG)
$(PROG): $(CIVETWEB_LIB) $(SRC)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(SRC) $(CIVETWEB_LIB) $(LIBS)
$(CIVETWEB_LIB):
$(MAKE) -C $(TOP) clean lib
cp $(TOP)/$(CIVETWEB_LIB) .
clean:
rm -f $(CIVETWEB_LIB) $(PROG)
.PHONY: all clean

36
examples/post/Makefile Normal file
View File

@ -0,0 +1,36 @@
#
# Copyright (c) 2013 No Face Press, LLC
# License http://opensource.org/licenses/mit-license.php MIT License
#
#This makefile is used to test the other Makefiles
PROG = post
SRC = post.c
TOP = ../..
CIVETWEB_LIB = libcivetweb.a
CFLAGS = -I$(TOP)/include $(COPT)
LIBS = -lpthread
include $(TOP)/resources/Makefile.in-os
ifeq ($(TARGET_OS),LINUX)
LIBS += -ldl
endif
all: $(PROG)
$(PROG): $(CIVETWEB_LIB) $(SRC)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(SRC) $(CIVETWEB_LIB) $(LIBS)
$(CIVETWEB_LIB):
$(MAKE) -C $(TOP) clean lib
cp $(TOP)/$(CIVETWEB_LIB) .
clean:
rm -f $(CIVETWEB_LIB) $(PROG)
.PHONY: all clean

View File

@ -1,50 +0,0 @@
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAwONaLOP7EdegqjRuQKSDXzvHmFMZfBufjhELhNjo5KsL4ieH
hMSGCcSV6y32hzhqR5lvTViaQez+xhc58NZRu+OUgEhodRBW/vAOjpz/xdMz5HaC
EhP3E9W1pkitVseS8B5rrgJo1BfCGai1fPav1nutPq2Kj7vMy24+g460Lonf6ln1
di4aTIRtAqXtUU6RFpPJP35PkCXbTK65O8HJSxxt/XtfoezHCU5+UIwmZGYx46UB
Wzg3IfK6bGPSiHU3pdiTol0uMPt/GUK+x4NyZJ4/ImsNAicRwMBdja4ywHKXJehH
gXBthsVIHbL21x+4ibsg9eVM/XioTV6tW3IrdwIDAQABAoIBACFfdLutmkQFBcRN
HAJNNHmmsyr0vcUOVnXTFyYeDXV67qxrYHQlOHe6LqIpKq1Mon7O2kYMnWvooFAP
trOnsS6L+qaTYJdYg2TKjgo4ubw1hZXytyB/mdExuaMSkgMgtpia+tB5lD+V+LxN
x1DesZ+veFMO3Zluyckswt4qM5yVa04YFrt31H0E1rJfIen61lidXIKYmHHWuRxK
SadjFfbcqJ6P9ZF22BOkleg5Fm5NaxJmyQynOWaAkSZa5w1XySFfRjRfsbDr64G6
+LSG8YtRuvfxnvUNhynVPHcpE40eiPo6v8Ho6yZKXpV5klCKciodXAORsswSoGJa
N3nnu/ECgYEA6Yb2rM3QUEPIALdL8f/OzZ1GBSdiQB2WSAxzl9pR/dLF2H+0pitS
to0830mk92ppVmRVD3JGxYDRZQ56tlFXyGaCzJBMRIcsotAhBoNbjV0i9n5bLJYf
BmjU9yvWcgsTt0tr3B0FrtYyp2tCvwHqlxvFpFdUCj2oRw2uGpkhmNkCgYEA03M6
WxFhsix3y6eVCVvShfbLBSOqp8l0qiTEty+dgVQcWN4CO/5eyaZXKxlCG9KMmKxy
Yx+YgxZrDhfaZ0cxhHGPRKEAxM3IKwT2C8/wCaSiLWXZZpTifnSD99vtOt4wEfrG
+AghNd5kamFiM9tU0AyvhJc2vdJFuXrfeC7ntM8CgYBGDA+t4cZcbRhu7ow/OKYF
kulP3nJgHP/Y+LMrl3cEldZ2jEfZmCElVNQvfd2XwTl7injhOzvzPiKRF3jDez7D
g8w0JAxceddvttJRK9GoY4l7OoeKpjUELSnEQkf+yUfOsTbXPXVY7jMfeNL6jE6b
qN7t3qv8rmXtejMBE3G6cQKBgGR5W2BMiRSlxqKx1cKlrApV87BUe1HRCyuR3xuA
d6Item7Lx1oEi7vb242yKdSYnpApWQ06xTh83Y/Ly87JaIEbiM0+h+P8OEIg0F1a
iB+86AcUX1I8KseVy+Np0HbpfwP8GrFfA5DaRPK7pXMopEtby8cAJ1XZZaI1/ZvZ
BebHAoGAcQU9WvCkT+nIp9FpXfBybYUsvgkaizMIqp66/l3GYgYAq8p1VLGvN4v5
ec0dW58SJrCpqsM3NP78DtEzQf9OOsk+FsjBFzDU2RkeUreyt2/nQBj/2mN/+hEy
hYN0Zii2yTb63jGxKY6gH1R/r9dL8kXaJmcZrfSa3AgywnteJWg=
-----END RSA PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIDBjCCAe4CCQCX05m0b053QzANBgkqhkiG9w0BAQQFADBFMQswCQYDVQQGEwJB
VTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0
cyBQdHkgTHRkMB4XDTA4MTIwNzEwMjUyMloXDTE4MTIwNTEwMjUyMlowRTELMAkG
A1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNVBAoTGEludGVybmV0
IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB
AMDjWizj+xHXoKo0bkCkg187x5hTGXwbn44RC4TY6OSrC+Inh4TEhgnElest9oc4
akeZb01YmkHs/sYXOfDWUbvjlIBIaHUQVv7wDo6c/8XTM+R2ghIT9xPVtaZIrVbH
kvAea64CaNQXwhmotXz2r9Z7rT6tio+7zMtuPoOOtC6J3+pZ9XYuGkyEbQKl7VFO
kRaTyT9+T5Al20yuuTvByUscbf17X6HsxwlOflCMJmRmMeOlAVs4NyHyumxj0oh1
N6XYk6JdLjD7fxlCvseDcmSePyJrDQInEcDAXY2uMsBylyXoR4FwbYbFSB2y9tcf
uIm7IPXlTP14qE1erVtyK3cCAwEAATANBgkqhkiG9w0BAQQFAAOCAQEAW4yZdqpB
oIdiuXRosr86Sg9FiMg/cn+2OwQ0QIaA8ZBwKsc+wIIHEgXCS8J6316BGQeUvMD+
plNe0r4GWzzmlDMdobeQ5arPRB89qd9skE6pAMdLg3FyyfEjz3A0VpskolW5VBMr
P5R7uJ1FLgH12RyAjZCWYcCRqEMOffqvyMCH6oAjyDmQOA5IssRKX/HsHntSH/HW
W7slTcP45ty1b44Nq22/ubYk0CJRQgqKOIQ3cLgPomN1jNFQbAbfVTaK1DpEysrQ
5V8a8gNW+3sVZmV6d1Mj3pN2Le62wUKuV2g6BNU7iiwcoY8HI68aRxz2hVMS+t5f
SEGI4JSxV56lYg==
-----END CERTIFICATE-----
-----BEGIN DH PARAMETERS-----
MEYCQQD+ef8hZ4XbdoyIpJyCTF2UrUEfX6mYDvxuS5O1UNYcslUqlj6JkA11e/yS
6DK8Z86W6mSj5CEk4IjbyEOECXH7AgEC
-----END DH PARAMETERS-----

36
examples/upload/Makefile Normal file
View File

@ -0,0 +1,36 @@
#
# Copyright (c) 2013 No Face Press, LLC
# License http://opensource.org/licenses/mit-license.php MIT License
#
#This makefile is used to test the other Makefiles
PROG = upload
SRC = upload.c
TOP = ../..
CIVETWEB_LIB = libcivetweb.a
CFLAGS = -I$(TOP)/include $(COPT)
LIBS = -lpthread
include $(TOP)/resources/Makefile.in-os
ifeq ($(TARGET_OS),LINUX)
LIBS += -ldl
endif
all: $(PROG)
$(PROG): $(CIVETWEB_LIB) $(SRC)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(SRC) $(CIVETWEB_LIB) $(LIBS)
$(CIVETWEB_LIB):
$(MAKE) -C $(TOP) clean lib
cp $(TOP)/$(CIVETWEB_LIB) .
clean:
rm -f $(CIVETWEB_LIB) $(PROG)
.PHONY: all clean

View File

@ -0,0 +1,36 @@
#
# Copyright (c) 2013 No Face Press, LLC
# License http://opensource.org/licenses/mit-license.php MIT License
#
#This makefile is used to test the other Makefiles
PROG = websocket
SRC = websocket.c
TOP = ../..
CIVETWEB_LIB = libcivetweb.a
CFLAGS = -I$(TOP)/include $(COPT)
LIBS = -lpthread
include $(TOP)/resources/Makefile.in-os
ifeq ($(TARGET_OS),LINUX)
LIBS += -ldl
endif
all: $(PROG)
$(PROG): $(CIVETWEB_LIB) $(SRC)
$(CC) -o $@ $(CFLAGS) $(LDFLAGS) $(SRC) $(CIVETWEB_LIB) $(LIBS)
$(CIVETWEB_LIB):
$(MAKE) -C $(TOP) clean lib WITH_WEBSOCKET=1
cp $(TOP)/$(CIVETWEB_LIB) .
clean:
rm -f $(CIVETWEB_LIB) $(PROG)
.PHONY: all clean

185
include/CivetServer.h Normal file
View File

@ -0,0 +1,185 @@
/*
* Copyright (c) 2013 No Face Press, LLC
* License http://opensource.org/licenses/mit-license.php MIT License
*/
#ifndef _CIVETWEB_SERVER_H_
#define _CIVETWEB_SERVER_H_
#ifdef __cplusplus
#include "civetweb.h"
#include <vector>
#include <string>
class CivetServer; // forward declaration
/**
* Basic interface for a URI request handler. Handlers implementations
* must be reentrant.
*/
class CivetHandler {
public:
/**
* Destructor
*/
virtual ~CivetHandler() {
}
/**
* Callback method for GET request.
*
* @param server - the calling server
* @param conn - the connection information
* @returns true if implemented, false otherwise
*/
virtual bool handleGet(CivetServer *server, struct mg_connection *conn);
/**
* Callback method for POST request.
*
* @param server - the calling server
* @param conn - the connection information
* @returns true if implemented, false otherwise
*/
virtual bool handlePost(CivetServer *server, struct mg_connection *conn);
/**
* Callback method for PUT request.
*
* @param server - the calling server
* @param conn - the connection information
* @returns true if implemented, false otherwise
*/
virtual bool handlePut(CivetServer *server, struct mg_connection *conn);
/**
* Callback method for DELETE request.
*
* @param server - the calling server
* @param conn - the connection information
* @returns true if implemented, false otherwise
*/
virtual bool handleDelete(CivetServer *server, struct mg_connection *conn);
};
/**
* CivetServer
*
* Basic class for embedded web server. This has a URL mapping built-in.
*/
class CivetServer {
public:
/**
* Constructor
*
* This automatically starts the sever.
* It is good practice to call getContext() after this in case there
* were errors starting the server.
*
* @param options - the web server options.
* @param callbacks - optional web server callback methods.
* Note that this class overrides begin_request callback.
*/
CivetServer(const char **options, const struct mg_callbacks *callbacks = 0);
/**
* Destructor
*/
virtual ~CivetServer();
/**
* close()
*
* Stops server and frees resources.
*/
void close();
/**
* getContext()
*
* @return the context or 0 if not running.
*/
const struct mg_context *getContext() const {
return context;
}
/**
* addHandler(const std::string &, CivetHandler *)
*
* Adds a URI handler. If there is existing URI handler, it will
* be replaced with this one. The handler is "owned" by this server
* and will be deallocated with it.
*
* URI's are ordered and partcial URI's are supported. For example,
* consider two URIs in order: /a/b and /a; /a matches
* /a, /a/b matches /a/b, /a/c matches /a. Reversing the order to
* /a and /a/b; /a matches /a/b, /a/b matches /a. /a/c matches /a.
*
* @param uri - URI to match.
* @param handler - handler instance to use. This will be free'ed
* when the server closes and instances cannot be reused.
*/
void addHandler(const std::string &uri, CivetHandler *handler);
/**
* removeHandler(const std::string &)
*
* Removes a handler, deleting it if found.
*
* @param - the exact URL used in addHandler().
*/
void removeHandler(const std::string &uri);
/**
* getHandler(const std::string &uri)
*
* @param uri - the URI
* @returns the handler that matches the requested URI or 0 if none were found.
*/
CivetHandler *getHandler(const std::string &uri) const {
return getHandler(uri.data(), uri.length());
}
/**
* getHandler(const char *uri, unsigned urilen)
*
* @param uri - the URI
* @param urilen - the length of the URI
* @returns the handler that matches the requested URI or 0 if none were found.
*/
CivetHandler *getHandler(const char *uri, unsigned urilen) const;
protected:
/**
* handleRequest(struct mg_connection *)
*
* Handles the incomming request.
*
* @param conn - the connection information
* @returns true if implemented, false otherwise
*/
virtual bool handleRequest(struct mg_connection *conn);
/**
* Returns the index of the handler that matches the
* URI exactly.
*
* @param uri - the url to match
*/
int getIndex(const std::string &uri) const;
std::vector<std::string> uris;
std::vector<CivetHandler *> handlers;
struct mg_context *context;
private:
static int begin_request_callback(struct mg_connection *conn);
};
#endif /* __cplusplus */
#endif /* _CIVETWEB_SERVER_H_ */

View File

@ -190,7 +190,7 @@ const char **mg_get_valid_option_names(void);
// This function allows an application to manipulate .htpasswd files on the // This function allows an application to manipulate .htpasswd files on the
// fly by adding, deleting and changing user records. This is one of the // fly by adding, deleting and changing user records. This is one of the
// several ways of implementing authentication on the server side. For another, // several ways of implementing authentication on the server side. For another,
// cookie-based way please refer to the examples/chat.c in the source tree. // cookie-based way please refer to the examples/chat in the source tree.
// //
// If password is not NULL, entry is added (or modified if already exists). // If password is not NULL, entry is added (or modified if already exists).
// If password is NULL, entry is deleted. // If password is NULL, entry is deleted.

View File

@ -3,7 +3,7 @@
# License http://opensource.org/licenses/mit-license.php MIT License # License http://opensource.org/licenses/mit-license.php MIT License
# #
LUA_DIR = lua-5.2.2/src LUA_DIR = src/third_party/lua-5.2.2/src
LUA_SOURCE_FILES = lapi.c \ LUA_SOURCE_FILES = lapi.c \
lauxlib.c \ lauxlib.c \
@ -42,7 +42,7 @@ LUA_SOURCES = $(addprefix $(LUA_DIR)/, $(LUA_SOURCE_FILES))
LUA_OBJECTS = $(LUA_SOURCES:.c=.o) LUA_OBJECTS = $(LUA_SOURCES:.c=.o)
LUA_CFLAGS = -I$(LUA_DIR) -DLUA_COMPAT_ALL LUA_CFLAGS = -I$(LUA_DIR) -DLUA_COMPAT_ALL
SQLITE_DIR = build SQLITE_DIR = src/third_party
SQLITE_SOURCE_FILES = sqlite3.c lsqlite3.c SQLITE_SOURCE_FILES = sqlite3.c lsqlite3.c
SQLITE_SOURCES = $(addprefix $(SQLITE_DIR)/, $(SQLITE_SOURCE_FILES)) SQLITE_SOURCES = $(addprefix $(SQLITE_DIR)/, $(SQLITE_SOURCE_FILES))
SQLITE_OBJECTS = $(SQLITE_SOURCES:.c=.o) SQLITE_OBJECTS = $(SQLITE_SOURCES:.c=.o)

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

Before

Width:  |  Height:  |  Size: 9.9 KiB

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@ -2,5 +2,5 @@ LOCAL_PATH := $(call my-dir)/../..
include $(CLEAR_VARS) include $(CLEAR_VARS)
LOCAL_CFLAGS := -std=c99 -O2 -W -Wall -pthread -pipe $(COPT) LOCAL_CFLAGS := -std=c99 -O2 -W -Wall -pthread -pipe $(COPT)
LOCAL_MODULE := civetweb LOCAL_MODULE := civetweb
LOCAL_SRC_FILES := main.c civetweb.c LOCAL_SRC_FILES := src\main.c src\civetweb.c
include $(BUILD_EXECUTABLE) include $(BUILD_EXECUTABLE)

View File

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

155
src/CivetServer.cpp Normal file
View File

@ -0,0 +1,155 @@
/*
* Copyright (c) 2013 No Face Press, LLC
* License http://opensource.org/licenses/mit-license.php MIT License
*/
#include "CivetServer.h"
#include <stdlib.h>
#include <string.h>
#ifndef UNUSED_PARAMETER
#define UNUSED_PARAMETER(x) (void)(x)
#endif
bool CivetHandler::handleGet(CivetServer *server, struct mg_connection *conn) {
UNUSED_PARAMETER(server);
UNUSED_PARAMETER(conn);
return false;
}
bool CivetHandler::handlePost(CivetServer *server, struct mg_connection *conn) {
UNUSED_PARAMETER(server);
UNUSED_PARAMETER(conn);
return false;
}
bool CivetHandler::handlePut(CivetServer *server, struct mg_connection *conn) {
UNUSED_PARAMETER(server);
UNUSED_PARAMETER(conn);
return false;
}
bool CivetHandler::handleDelete(CivetServer *server, struct mg_connection *conn) {
UNUSED_PARAMETER(server);
UNUSED_PARAMETER(conn);
return false;
}
int CivetServer::begin_request_callback(struct mg_connection *conn) {
struct mg_request_info *request_info = mg_get_request_info(conn);
if (!request_info->user_data)
return 0;
CivetServer *me = (CivetServer*) (request_info->user_data);
if (me->handleRequest(conn)) {
return 1; // Mark as processed
}
return 0;
}
bool CivetServer::handleRequest(struct mg_connection *conn) {
struct mg_request_info *request_info = mg_get_request_info(conn);
CivetHandler *handler = getHandler(request_info->uri);
if (handler) {
if (strcmp(request_info->request_method, "GET") == 0) {
return handler->handleGet(this, conn);
} else if (strcmp(request_info->request_method, "POST") == 0) {
return handler->handlePost(this, conn);
} else if (strcmp(request_info->request_method, "PUT") == 0) {
return !handler->handlePost(this, conn);
} else if (strcmp(request_info->request_method, "DELETE") == 0) {
return !handler->handlePost(this, conn);
}
}
return false; // No handler found
}
CivetServer::CivetServer(const char **options,
const struct mg_callbacks *_callbacks) :
context(0) {
struct mg_callbacks callbacks;
if (_callbacks) {
memcpy(&callbacks, _callbacks, sizeof(callbacks));
} else {
memset(&callbacks, 0, sizeof(callbacks));
}
callbacks.begin_request = &begin_request_callback;
context = mg_start(&callbacks, this, options);
}
CivetServer::~CivetServer() {
close();
}
CivetHandler *CivetServer::getHandler(const char *uri, unsigned urilen) const {
for (unsigned index = 0; index < uris.size(); index++) {
const std::string &handlerURI = uris[index];
// first try for an exact match
if (handlerURI == uri) {
return handlers[index];
}
// next try for a partial match
// we will accept uri/something
if (handlerURI.length() < urilen
&& uri[handlerURI.length()] == '/'
&& handlerURI.compare(0, handlerURI.length(), uri, handlerURI.length()) == 0) {
return handlers[index];
}
}
return 0; // none found
}
void CivetServer::addHandler(const std::string &uri, CivetHandler *handler) {
int index = getIndex(uri);
if (index < 0) {
uris.push_back(uri);
handlers.push_back(handler);
} else if (handlers[index] != handler) {
delete handlers[index];
handlers[index] = handler;
}
}
void CivetServer::removeHandler(const std::string &uri) {
int index = getIndex(uri);
if (index >= 0) {
uris.erase(uris.begin() + index, uris.begin() + index + 1);
handlers.erase(handlers.begin() + index, handlers.begin() + index + 1);
}
}
int CivetServer::getIndex(const std::string &uri) const {
for (unsigned index = 0; index < uris.size(); index++) {
if (uris[index].compare(uri) == 0)
return index;
}
return -1;
}
void CivetServer::close() {
if (context) {
mg_stop (context);
context = 0;
}
for (int i = handlers.size() - 1; i >= 0; i--) {
delete handlers[i];
}
handlers.clear();
uris.clear();
}

View File

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

Some files were not shown because too many files have changed in this diff Show More