Skip to content

Commit

Permalink
changed test makefiles
Browse files Browse the repository at this point in the history
  • Loading branch information
pat committed Oct 13, 2015
1 parent a7e600f commit e9363c1
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 268 deletions.
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ tls:TLS=tls
clean-%:
-cd $* && make clean
-cd tests && make clean
-rm -rf obj

clean: $(addprefix clean-,$(MODULES))
-rm -R $(OUTDIR)

$(LIBDIR)/%.a:%
cd $< && make $(TLS)
-mv $</$<.a $@
-mkdir -p obj
-cp $</*.o obj/
mkdir -p $(INCLUDEDIR)/$<
cp $</*.h $(INCLUDEDIR)/$<

Expand All @@ -31,4 +33,5 @@ libs: outdir $(LIBS)

.PHONY: test
test: libs
$(AR) rcs $(LIBDIR)/dumaislib.a obj/*.o
cd tests && make $(TLS)
2 changes: 1 addition & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ clean:
-rm *.out

.cpp.out:
$(CXX) $(CFLAGS) $< ../sdk/lib/*.a -std=c++11 -o $@ $(LDFLAGS)
$(CXX) $(CFLAGS) $< ../sdk/lib/dumaislib.a -std=c++11 -o $@ $(LDFLAGS)

tests: clean $(OBJECTS)

27 changes: 27 additions & 0 deletions utils/Hash.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
Copyright (c) 2015 Patrick Dumais
http://www.dumaisnet.ca
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "Hash.h"

using namespace Dumais::Utils;
Expand Down Expand Up @@ -28,3 +51,7 @@ std::string Hash::toHex()
return output;
}

unsigned char* Hash::getDigest()
{
return (unsigned char*)this->H;
}
24 changes: 24 additions & 0 deletions utils/Hash.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
Copyright (c) 2015 Patrick Dumais
http://www.dumaisnet.ca
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#pragma once
#include <string>

Expand All @@ -17,6 +40,7 @@ namespace Dumais
public:
Hash(unsigned int hashSize, const char* input, unsigned int inputSize);
virtual ~Hash();
unsigned char* getDigest();
std::string toHex();
};
}
Expand Down
23 changes: 23 additions & 0 deletions utils/sha1.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
Copyright (c) 2015 Patrick Dumais
http://www.dumaisnet.ca
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "sha1.h"
#include <string.h>
#include <stdio.h>
Expand Down
23 changes: 23 additions & 0 deletions utils/sha1.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
Copyright (c) 2015 Patrick Dumais
http://www.dumaisnet.ca
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "Hash.h"

namespace Dumais
Expand Down
23 changes: 23 additions & 0 deletions utils/sha256.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
Copyright (c) 2015 Patrick Dumais
http://www.dumaisnet.ca
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "sha256.h"
#include <string.h>
#include <stdio.h>
Expand Down
23 changes: 23 additions & 0 deletions utils/sha256.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*
Copyright (c) 2015 Patrick Dumais
http://www.dumaisnet.ca
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#include "Hash.h"

namespace Dumais
Expand Down
5 changes: 2 additions & 3 deletions websocket/HTTPProtocolParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ SOFTWARE.
*/
#include "HTTPProtocolParser.h"
#include "utils/Logging.h"
#include "sha1.h"
#include "utils/sha1.h"
#include "base64.h"
#include <sstream>
#include <algorithm>
Expand Down Expand Up @@ -168,8 +168,7 @@ std::string HTTPProtocolParser::switchProtocol(const std::string& key, const std
{
std::string accept = key+MAGIC;

SHA1 sha;
sha.addBytes(accept.c_str(),accept.size());
Dumais::Utils::SHA1 sha(accept.c_str(),accept.size());
accept = base64_encode(sha.getDigest(),20);

std::stringstream ss;
Expand Down
2 changes: 1 addition & 1 deletion websocket/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
SOURCES = WebSocketServer.cpp WebSocket.cpp sha1.cpp base64.cpp HTTPProtocolParser.cpp WSProtocolParser.cpp
SOURCES = WebSocketServer.cpp WebSocket.cpp base64.cpp HTTPProtocolParser.cpp WSProtocolParser.cpp
OBJECTS=$(SOURCES:.cpp=.o)
CFLAGS=-I ../ -g -std=c++11
.cpp.o:
Expand Down
Loading

0 comments on commit e9363c1

Please sign in to comment.