diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | src/http.cpp | 2 | ||||
-rw-r--r-- | src/singleton.h | 46 | ||||
-rw-r--r-- | src/test/httpsrv/httpconnectionmonitor.cpp | 11 |
4 files changed, 60 insertions, 7 deletions
@@ -26,20 +26,20 @@ clean: | |||
26 | 26 | ||
27 | # This bit I cribbed from the docs, seems to work great though! | 27 | # This bit I cribbed from the docs, seems to work great though! |
28 | %.d: %.cpp | 28 | %.d: %.cpp |
29 | g++ $(CXXFLAGS) -Isrc -M $(CPPFLAGS) $< | sed 's,\($(notdir $*)\)\.o[: ]*,$(dir $*)\1.o $@: ,g' > $@ | ||
30 | echo "$(TXTDEP)$@" | 29 | echo "$(TXTDEP)$@" |
30 | g++ $(CXXFLAGS) -Isrc -M $(CPPFLAGS) $< | sed 's,\($(notdir $*)\)\.o[: ]*,$(dir $*)\1.o $@: ,g' > $@ | ||
31 | 31 | ||
32 | %.o: %.cpp | 32 | %.o: %.cpp |
33 | g++ $(CXXFLAGS) -Isrc $(foreach dr,$(filter $(dir $@),$(foreach ddr,$(TDIRS),$(ddr)/)),-I$(dr)) -ggdb -c -o $@ $< | ||
34 | echo "$(TXTCPP)$@" | 33 | echo "$(TXTCPP)$@" |
34 | g++ $(CXXFLAGS) -Isrc $(foreach dr,$(filter $(dir $@),$(foreach ddr,$(TDIRS),$(ddr)/)),-I$(dr)) -ggdb -c -o $@ $< | ||
35 | 35 | ||
36 | $(LIB): $(OBJS) | 36 | $(LIB): $(OBJS) |
37 | ar cr $(LIB) $(OBJS) | ||
38 | echo "$(TXTARC)$@" | 37 | echo "$(TXTARC)$@" |
38 | ar cr $(LIB) $(OBJS) | ||
39 | 39 | ||
40 | $(TESTS): $(ATOBJS) $(LIB) | 40 | $(TESTS): $(ATOBJS) $(LIB) |
41 | g++ $(LDFLAGS) -ggdb $(filter %$@.o, $(TOBJS) ) $(patsubst %.cpp,%.o,$(wildcard $(filter %$@, $(TDIRS))/*.cpp)) -L. -lbu++ -o $@ | ||
42 | echo "$(TXTLNK)$@" | 41 | echo "$(TXTLNK)$@" |
42 | g++ $(LDFLAGS) -ggdb $(filter %$@.o, $(TOBJS) ) $(patsubst %.cpp,%.o,$(wildcard $(filter %$@, $(TDIRS))/*.cpp)) -L. -lbu++ -o $@ | ||
43 | 43 | ||
44 | tests: $(TESTS) | 44 | tests: $(TESTS) |
45 | 45 | ||
diff --git a/src/http.cpp b/src/http.cpp index 11950b7..19122c3 100644 --- a/src/http.cpp +++ b/src/http.cpp | |||
@@ -146,7 +146,7 @@ bool Http::buildResponse( short nResponseCode, const char *sResponse ) | |||
146 | time( &curTime ); | 146 | time( &curTime ); |
147 | gmtime_r( &curTime, &tResTime ); | 147 | gmtime_r( &curTime, &tResTime ); |
148 | 148 | ||
149 | sServerStr = "YFHttp/0.0.1"; | 149 | sServerStr = "libbu++ Http/0.0.1"; |
150 | bResPersistant = false; | 150 | bResPersistant = false; |
151 | 151 | ||
152 | //char buf[30]; | 152 | //char buf[30]; |
diff --git a/src/singleton.h b/src/singleton.h new file mode 100644 index 0000000..c69e6f1 --- /dev/null +++ b/src/singleton.h | |||
@@ -0,0 +1,46 @@ | |||
1 | #ifndef SINGLETON_H | ||
2 | #define SINGLETON_H | ||
3 | |||
4 | #include <stdio.h> | ||
5 | |||
6 | /** | ||
7 | * Provides singleton functionality in a modular sort of way. Make this the | ||
8 | * base class of any other class and you immediately gain singleton | ||
9 | * functionality. Be sure to make your constructor and various functions use | ||
10 | * intellegent scoping. Cleanup and instantiation are performed automatically | ||
11 | * for you at first use and program exit. There are two things that you must | ||
12 | * do when using this template, first is to inherit from it with the name of | ||
13 | * your class filling in for T and then make this class a friend of your class. | ||
14 | *@code | ||
15 | * // Making the Single Singleton: | ||
16 | * class Single : public Singleton<Single> | ||
17 | * { | ||
18 | * friend class Singleton<Single>; | ||
19 | * protected: | ||
20 | * Single(); | ||
21 | * ... | ||
22 | * }; | ||
23 | @endcode | ||
24 | * You can still add public functions and variables to your new Singleton child | ||
25 | * class, but your constructor should be protected (hence the need for the | ||
26 | * friend decleration). | ||
27 | *@author Mike Buland | ||
28 | */ | ||
29 | template <class T> | ||
30 | class Singleton | ||
31 | { | ||
32 | protected: | ||
33 | Singleton() {}; | ||
34 | |||
35 | private: | ||
36 | Singleton( const Singleton& ); | ||
37 | |||
38 | public: | ||
39 | static T &getInstance() | ||
40 | { | ||
41 | static T i; | ||
42 | return i; | ||
43 | } | ||
44 | }; | ||
45 | |||
46 | #endif | ||
diff --git a/src/test/httpsrv/httpconnectionmonitor.cpp b/src/test/httpsrv/httpconnectionmonitor.cpp index 4eb6817..eaadb36 100644 --- a/src/test/httpsrv/httpconnectionmonitor.cpp +++ b/src/test/httpsrv/httpconnectionmonitor.cpp | |||
@@ -49,15 +49,22 @@ bool HttpConnectionMonitor::onNewConnection( Connection *pCon ) | |||
49 | else | 49 | else |
50 | { | 50 | { |
51 | printf("Non get: %s\n", hp.getRequestTypeStr() ); | 51 | printf("Non get: %s\n", hp.getRequestTypeStr() ); |
52 | pCon->appendOutput("HTTP/1.1 100 Continue\r\n\r\n"); | ||
52 | } | 53 | } |
53 | pCon->writeOutput(); | 54 | pCon->writeOutput(); |
55 | //for( int j = 0; j < 50; j++ ) | ||
56 | { | ||
57 | pCon->readInput( 1, 0 ); | ||
58 | //printf("Size so far: %d\n", pCon->getInputAmnt() ); | ||
59 | } | ||
54 | 60 | ||
55 | if( pCon->hasInput() ) | 61 | if( pCon->hasInput() ) |
56 | { | 62 | { |
57 | std::string s( pCon->getInput(), pCon->getInputAmnt() ); | 63 | std::string s( pCon->getInput(), pCon->getInputAmnt() ); |
58 | 64 | ||
59 | printf("Reamining data\n==============\n%s\n==============\n", | 65 | pCon->printInputDebug(); |
60 | s.c_str() ); | 66 | //printf("Reamining data\n==============\n%s\n==============\n", |
67 | // s.c_str() ); | ||
61 | } | 68 | } |
62 | 69 | ||
63 | pCon->disconnect(); | 70 | pCon->disconnect(); |