Browse Source

Merge branch 'master' into 'master'

New namespace ntr

See merge request !5
master
R Odili 5 years ago
parent
commit
a5ab4e7bd8
  1. 12
      .gitignore
  2. 70
      DJMakefile
  3. 16
      Makefile
  4. 93
      NTMakefile
  5. 7
      README.md
  6. 23
      data.enc
  7. 4
      deps/include/mbedtls/cipher.h
  8. 2
      deps/include/mbedtls/ssl_ciphersuites.h
  9. BIN
      deps/lib/nt_amd64/glew32.dll
  10. BIN
      deps/lib/nt_amd64/libbz2.a
  11. BIN
      deps/lib/nt_amd64/libfreetype.a
  12. BIN
      deps/lib/nt_amd64/libglfw.a
  13. BIN
      deps/lib/nt_amd64/libharfbuzz.a
  14. BIN
      deps/lib/nt_amd64/libpng.a
  15. BIN
      deps/lib/nt_amd64/libpolarssl.a
  16. BIN
      deps/lib/nt_amd64/libz.a
  17. BIN
      deps/lib/nt_amd64/release/glew32.dll
  18. BIN
      deps/lib/nt_amd64/release/libbz2.a
  19. BIN
      deps/lib/nt_amd64/release/libfreetype.a
  20. BIN
      deps/lib/nt_amd64/release/libglfw.a
  21. BIN
      deps/lib/nt_amd64/release/libharfbuzz.a
  22. BIN
      deps/lib/nt_amd64/release/libpng.a
  23. BIN
      deps/lib/nt_amd64/release/libpolarssl.a
  24. BIN
      deps/lib/nt_amd64/release/libz.a
  25. 0
      deps/lib/nt_i386/glew32.dll
  26. 0
      deps/lib/nt_i386/libbz2.a
  27. 0
      deps/lib/nt_i386/libfreetype.a
  28. 0
      deps/lib/nt_i386/libglfw.a
  29. 0
      deps/lib/nt_i386/libharfbuzz.a
  30. 0
      deps/lib/nt_i386/libpng.a
  31. BIN
      deps/lib/nt_i386/libpolarssl.a
  32. 0
      deps/lib/nt_i386/libz.a
  33. BIN
      deps/lib/nt_i386/release/glew32.dll
  34. BIN
      deps/lib/nt_i386/release/libbz2.a
  35. BIN
      deps/lib/nt_i386/release/libfreetype.a
  36. BIN
      deps/lib/nt_i386/release/libglfw-nt.a
  37. BIN
      deps/lib/nt_i386/release/libglfw3.a
  38. BIN
      deps/lib/nt_i386/release/libharfbuzz.a
  39. BIN
      deps/lib/nt_i386/release/libpng.a
  40. BIN
      deps/lib/nt_i386/release/libpolarssl.a
  41. BIN
      deps/lib/nt_i386/release/libz.a
  42. 2
      legacy-ci.sh
  43. BIN
      netrunner.ico
  44. 60
      netrunner.rc
  45. BIN
      netrunner.zip
  46. BIN
      netrunner_ssl.zip
  47. BIN
      reltools/winnt/amd64/glew32.dll
  48. BIN
      reltools/winnt/amd64/libgcc_s_seh-1.dll
  49. BIN
      reltools/winnt/amd64/libssp-0.dll
  50. BIN
      reltools/winnt/amd64/libstdc++-6.dll
  51. BIN
      reltools/winnt/amd64/libwinpthread-1.dll
  52. BIN
      reltools/winnt/i386/glew32.dll
  53. 0
      reltools/winnt/i386/libgcc_s_sjlj-1.dll
  54. 0
      reltools/winnt/i386/libssp-0.dll
  55. 0
      reltools/winnt/i386/libstdc++-6.dll
  56. 17
      resource.h
  57. 42
      src/CFGFileParser.cpp
  58. 55
      src/CFGFileParser.h
  59. 334
      src/Murmur3.cpp
  60. 37
      src/Murmur3.h
  61. 84
      src/TLSFAlloc.h
  62. 20
      src/graphics/components/AnimeComponent.cpp
  63. 23
      src/main.cpp
  64. 157
      src/networking/HTTPSRequest.cpp
  65. 5
      src/networking/HTTPSRequest.h
  66. 2
      src/pnm.cpp
  67. 11
      src/pnm.h
  68. 12
      src/target.h
  69. 85
      src/tlsf-winnt.h
  70. 1238
      src/tlsf.c
  71. 44
      src/tlsf.h
  72. 24
      visualc/NetRunner2008.sln
  73. 400
      visualc/NetRunner2008.vcproj
  74. 20
      winnt-ci.sh

12
.gitignore vendored

@ -10,3 +10,15 @@ src/networking/URI @@ -10,3 +10,15 @@ src/networking/URI
*.user
NetRunner2008.ncb
*.suo
*.id*
*.nam
*.til
*.dbg
/glew32.dll
/libgcc_s_sjlj-1.dll
/libssp-0.dll
/libstdc++-6.dll
/netrunner.exe
.vscode
*.res*
*.aps

70
DJMakefile

@ -0,0 +1,70 @@ @@ -0,0 +1,70 @@
UNAME := $(shell uname)
CXX = gpp
CC = gcc
GIT_VERSION := $(shell git describe --abbrev=4 --always --tags)
PLATFORM := $(shell gpp -dumpmachine)
CXXFLAGS = -O3 -march=i486 -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\" -DPLATFORM=\"$(PLATFORM)\"
CFLAGS = -O3 -flto=8 -march=i486 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
CWARN = -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused
WARNINGS = -Werror -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wzero-as-null-pointer-constant -Wuseless-cast
LIBS = -lglfw -lGL -lGLEW -lfreetype -lharfbuzz -lpolarssl
LDFLAGS = -O3 -flto=8
INCPATH = -I /usr/include/freetype2 -I /usr/include/harfbuzz
MD5SUM = md5sum
EXECUTABLE = netrunner
LINK = gpp
SRCDIR = src
OBJDIR = gen
DEPDIR = d
SOURCES = $(subst ./,,$(shell find src -name \*.cpp))
OBJECTS = $(subst $(SRCDIR),$(OBJDIR),$(SOURCES:.cpp=.o))
all: $(SOURCES) netrunner
netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
# make make 3.81 happy (since it can't parse any echo parameters)
shaders:
ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | $(MD5SUM)), $(shell cat src/graphics/opengl/shaders/gen/hashsum))
@mkdir -p "src/graphics/opengl/shaders/gen"
@cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | $(MD5SUM) > src/graphics/opengl/shaders/gen/hashsum;
@/bin/echo -ne "#ifndef FONTSHADER_H\n#define FONTSHADER_H\n\nconst char *fontVertexShaderSource =\n" > src/graphics/opengl/shaders/gen/FontShader.h;
@cat src/graphics/opengl/shaders/FontShader.vert | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/FontShader.h;
@/bin/echo -ne "const char *fontFragmentShaderSource =\n" >> src/graphics/opengl/shaders/gen/FontShader.h;
@cat src/graphics/opengl/shaders/FontShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/FontShader.h;
@/bin/echo -ne "#endif\n" >> src/graphics/opengl/shaders/gen/FontShader.h;
@/bin/echo -ne "#ifndef TEXTURESHADER_H\n#define TEXTURESHADER_H\n\nconst char *textureVertexShaderSource =\n" > src/graphics/opengl/shaders/gen/TextureShader.h;
@cat src/graphics/opengl/shaders/TextureShader.vert | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
@/bin/echo -ne "const char *textureFragmentShaderSource =\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
@cat src/graphics/opengl/shaders/TextureShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
@/bin/echo -ne "#endif\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
endif
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp | shaders
@mkdir -p $(@D)
@mkdir -p $(subst gen,d,$(@D))
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARNINGS) -c -o $@ $<
@mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
$(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
$(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_SBRK=1 -c -o $@ $<
$(DEPDIR)/%d: ;
.PRECIOUS: $(DEPDIR)/%.d
test-url.o: tests/testPrograms/URLtest.cpp
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARINGS) -c -o $@ $<
ntr-run-tests: test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o
$(LINK) $(LDFLAGS) -o $@ test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o $(LIBS)
clean:
-@rm -rf src/graphics/opengl/shaders/gen $(OBJDIR) $(EXECUTABLE) 2>/dev/null || true
include $(addsuffix .d,$(subst $(SRCDIR),$(DEPDIR),$(basename $(SOURCES))))

16
Makefile

@ -1,9 +1,13 @@ @@ -1,9 +1,13 @@
UNAME := $(shell uname)
CXX = g++
CC = gcc
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
PLATFORM := $(shell g++ -dumpmachine)
CXXFLAGS = -O3 -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CXXFLAGS = -O3 -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\" -DPLATFORM=\"$(PLATFORM)\"
CFLAGS = -O3 -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
CWARN = -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused
WARNINGS = -Werror -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wzero-as-null-pointer-constant -Wuseless-cast
LIBS = -lglfw -lGL -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
LDFLAGS = -O3 -flto=8
@ -11,10 +15,11 @@ INCPATH = -I /usr/include/freetype2 -I /usr/include/harfbuzz @@ -11,10 +15,11 @@ INCPATH = -I /usr/include/freetype2 -I /usr/include/harfbuzz
MD5SUM = md5sum
ifeq ($(UNAME), Darwin)
CXXFLAGS = -O3 -std=c++1y -DVERSION=\"$(GIT_VERSION)\"
CXXFLAGS = -O3 -std=c++1y -DVERSION=\"$(GIT_VERSION)\" -DPLATFORM=\"$(PLATFORM)\"
CFLAGS = -O3 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
WARNINGS =
ifneq ("$(wildcard /usr/local/lib/libglfw3.a)","")
LIBS = -lglfw3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
LIBS = -lglfw3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509 \
else
LIBS = -lglfw.3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
endif
@ -39,7 +44,7 @@ RES = res/ @@ -39,7 +44,7 @@ RES = res/
all: $(SOURCES) netrunner
netrunner: $(OBJECTS)
netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
@ -48,6 +53,9 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp @@ -48,6 +53,9 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARNINGS) -c -o $@ $<
@mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
$(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
$(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_MMAP=1 -DUSE_SBRK=1 -c -o $@ $<
$(DEPDIR)/%d: ;
.PRECIOUS: $(DEPDIR)/%.d

93
NTMakefile

@ -1,21 +1,69 @@ @@ -1,21 +1,69 @@
UNAME := $(shell uname)
CXX = g++
CC = gcc
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
ifdef DEBUG
CXXFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\"
else
ifdef RELEASE_PACK
CXXFLAGS = -O3 -march=i686 -mtune=generic -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -O3 -march=i686 -mtune=generic -fstack-protector-strong -fPIE -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
else
CXXFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
endif
endif
ifdef AMD64_DEBUG
CXXFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\"
else
ifdef AMD64_RELEASE
CXXFLAGS = -O3 -march=opteron -mtune=opteron -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -O3 -march=opteron -mtune=opteron -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
else
ifdef AMD64
CXXFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\" -flto=8
endif
endif
endif
WARNINGS = -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wzero-as-null-pointer-constant -Wuseless-cast
CWARN = -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused
# i686 builds
ifdef DEBUG
LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
ifndef DEBUG
LDFLAGS = -L ./deps/lib -O3 -flto=8 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE
LDFLAGS = -L ./deps/lib/nt_i386 -Og -g3 -fstack-protector-strong -fPIE
else
ifdef RELEASE_PACK
LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_i386/release -O3 -flto=8 -march=i686 -mtune=generic -fstack-protector-strong -fPIE
else
LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_i386 -O3 -flto=8 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE
endif
endif
ifdef AMD64_DEBUG
LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_amd64 -Og -g3 -fstack-protector-strong -fPIE
else
LDFLAGS = -L ./deps/lib -Og -g3 -fstack-protector-strong -fPIE
ifdef AMD64_RELEASE
LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_amd64/release -O3 -flto=8 -march=opteron -mtune=opteron -mfpmath=sse -fstack-protector-strong -fPIE
else
ifdef AMD64
LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_amd64 -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8
endif
endif
endif
INCPATH = -I ./deps/include
EXECUTABLE = netrunner
@ -25,32 +73,19 @@ SRCDIR = src @@ -25,32 +73,19 @@ SRCDIR = src
OBJDIR = gen
DEPDIR = d
SOURCES = $(subst ./,,$(shell find . -name *.cpp))
SOURCES = $(subst ./,,$(shell find src -name \*.cpp))
OBJECTS = $(subst $(SRCDIR),$(OBJDIR),$(SOURCES:.cpp=.o))
all: $(SOURCES) netrunner
netrunner: $(OBJECTS)
netrunner.res.o: netrunner.rc
@openssl des3 -d -in data.enc -out favicon.ico -k exdf8OWpNn -a
windres $^ -o $@
@rm favicon.ico
netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o netrunner.res.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
# make make 3.81 happy (since it can't parse any echo parameters)
ifeq ($(UNAME), Darwin)
shaders:
ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum), $(shell cat src/graphics/opengl/shaders/gen/hashsum))
@mkdir -p "src/graphics/opengl/shaders/gen"
@echo "#ifndef FONTSHADER_H\n#define FONTSHADER_H\n\nconst char *fontVertexShaderSource =\n" > src/graphics/opengl/shaders/gen/FontShader.h;
@cat src/graphics/opengl/shaders/FontShader.vert | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/FontShader.h;
@echo "const char *fontFragmentShaderSource =\n" >> src/graphics/opengl/shaders/gen/FontShader.h;
@cat src/graphics/opengl/shaders/FontShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/FontShader.h;
@echo "#endif\n" >> src/graphics/opengl/shaders/gen/FontShader.h;
@echo "#ifndef TEXTURESHADER_H\n#define TEXTURESHADER_H\n\nconst char *textureVertexShaderSource =\n" > src/graphics/opengl/shaders/gen/TextureShader.h;
@cat src/graphics/opengl/shaders/TextureShader.vert | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
@echo "const char *textureFragmentShaderSource =\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
@cat src/graphics/opengl/shaders/TextureShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
@echo "#endif\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
@cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum > src/graphics/opengl/shaders/gen/hashsum;
endif
else
shaders:
ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum), $(shell cat src/graphics/opengl/shaders/gen/hashsum))
@mkdir -p "src/graphics/opengl/shaders/gen"
@ -66,17 +101,25 @@ ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/open @@ -66,17 +101,25 @@ ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/open
@cat src/graphics/opengl/shaders/TextureShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
@/bin/echo -ne "#endif\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
endif
endif
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp | shaders
@mkdir -p $(@D)
@mkdir -p $(subst gen,d,$(@D))
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) -c -o $@ $<
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARNINGS) -c -o $@ $<
@mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
$(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
$(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_SBRK=1 -c -o $@ $<
$(DEPDIR)/%d: ;
.PRECIOUS: $(DEPDIR)/%.d
test-url.o: tests/testPrograms/URLtest.cpp
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARINGS) -c -o $@ $<
ntr-run-tests: test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o
$(LINK) $(LDFLAGS) -o $@ test-url.o $(OBJDIR)/URL.o $(OBJDIR)/StringUtils.o $(LIBS)
clean:
-@rm -rf src/graphics/opengl/shaders/gen $(OBJDIR) $(EXECUTABLE) 2>/dev/null || true

7
README.md

@ -1,3 +1,6 @@ @@ -1,3 +1,6 @@
NT5+ (i386): [![Build Status](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-i686/badge/icon)](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-i686/)
.NET Server+ (AMD64): [![Build Status](https://nt-build-bot.rvx86.net:7421/buildStatus/icon?job=netrunner-winnt-amd64)](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-amd64/)
# Netrunner
is an implementation of a new web browser engine written in C++ utilizing OpenGL.
@ -54,7 +57,9 @@ GyroNinja.net is back online @@ -54,7 +57,9 @@ GyroNinja.net is back online
### Windows
[2017-08-20 binary package](https://my.mixtape.moe/exebyr.zip)
[Jenkins 32bit](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-i686/)
[Jenkins 64bit](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-amd64/)
## Milestones
@ -132,4 +137,4 @@ We coordinate on [irc.rizon.net](https://www.rizon.net/chat) #/g/netrunner or [O @@ -132,4 +137,4 @@ We coordinate on [irc.rizon.net](https://www.rizon.net/chat) #/g/netrunner or [O
### Class Types
- Nodes: DOM tree objects
- Elements: Individual tag types
- Components: (gameobjects) renderer entities
- Components: (gameobjects) renderer entities

23
data.enc

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
U2FsdGVkX1/4+8vApHbadOQy2u2pTKM/QdBEzFjwwY3Irl8pUdduxTC2Oi/iusTu
7ERNdrinJBcvrWfU8PhWP9CcpTvq3b93OO/i0wBTyrrQk4MdETdb8xiH/JwnxfpT
yAOTKTNL8iLKXqXcIU8pVDlnrVQqCyY1xX+HJ8P6b82Y6d5Du0E6VucuCkwpWzI8
Wl/9FsFqJ0ODGB3TGzVzXGcYqKmbgDjed8eNxJcwghQ3WfADR9Cbhu2KvQepc7hM
PtKsHYi85iy3yqX9gS3+Mue/0LIaRJv84QnPYcBcs0+FokYYqt76O95ZF17/9jlf
yRXDH1MVg7C+VBJJj6NLAdKK8tYZgJbQKk7fecEWRiyjCPeFfWoLFwq1YIOujkzE
7QAfBuiCucG3L2TfIZnThfP1qHoXsxExTwT0nInJEudcMQsXliJFBGpri4+VrXvN
uIJltZv3e4XCMZrm3USi++KO42SQI+ngUzPwysHoOOSkgroOIETlhd3Vgy7pxDcH
s8ubehYxQvfE1lEOTwR37v3IcI3ruZtZZ8cPu00D2UXR64ByJ3NjCnFgcPF4Rw4B
QSEVJ6YAdlB5qL3W8WOgPmhiCKWu2X9pYech4x7TL4h3xf7gjVitH/W5IC6ez/dD
iFGaCACMYGaqvuEd/rg7oeh0oecbQYVvA4+C6ZKSD9a5Y2RqrySJiUpyu3cO783Z
uQ9npfkG4/rpLspktumoiG4eQq9cfP33UtnfUyCmmVGRwndCdU2kAhjWN/n3tO1L
oGTV9VdUjovK1mp6Yqod2PatsUmhIrsYI1YaRFzoTKpapKbpRtheKdwFlDtMSKlS
MZVQPEenzKm9AQq4858Fj7BVJCqDrgahhRrSXSNvUimykRNkjx8ZGAgNRUmgNWLQ
JnzEqPXeRBqKW+YB2C7nbdpGiQdlYzrE3zWnDZk7e8IddhZHZEzpgcNiwq2FhJlM
qfsEh+AIJQrvtoJgOz/i4k0P/WEb7rBWeQpf91juA+AqubfL1Zdx2ARbeK25FW+D
UhwPaC1HFmHFCoPF2yBg62ijRURRQ8SFtc6vrqA7j4CCygix6MrQq/dyba1KY//9
Blmg9QrF8JQQ9V7QkIxwXn+FfIesG04CLijhFAd/TreA6xgShQASPjyXOwYvosSq
aYyF/i1m1UjDEH+GAsw+1KuPnZCtyb8aCDgYB4XfgTfNYqEsNZ1D7FtwLeBItWJc
3IGNpmHJLcIlfXYd/BCX8nSRNwYyvpjqT9jRIPtgLygO3D1Mbg8F4GB00FPovxXr
jl0nhsGBbH0jELEPQErxl/uhroBJjss3p9lKHAC2syXrUh/UnA8Y9VdA49bm8oGj
kdkGRbebqgs2NauKdRy739ecQm8ALhNlYDYGuBio4RN4iVYIDV57mSqOCAQKb8af
mTmWKmsZSVe52hZdRNxl7U834+2ICWvKWkkzv5ot6Z4qj8fClU8mqw==

4
deps/include/mbedtls/cipher.h vendored

@ -408,7 +408,11 @@ static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( const mbedtls_ciphe @@ -408,7 +408,11 @@ static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( const mbedtls_ciphe
static inline const char *mbedtls_cipher_get_name( const mbedtls_cipher_context_t *ctx )
{
if( NULL == ctx || NULL == ctx->cipher_info )
#ifdef __cplusplus
return nullptr;
#else
return 0;
#endif
return ctx->cipher_info->name;
}

2
deps/include/mbedtls/ssl_ciphersuites.h vendored

@ -349,7 +349,7 @@ struct mbedtls_ssl_ciphersuite_t @@ -349,7 +349,7 @@ struct mbedtls_ssl_ciphersuite_t
unsigned char flags;
};
const int *mbedtls_ssl_list_ciphersuites( void );
//const int *mbedtls_ssl_list_ciphersuites( void );
const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_string( const char *ciphersuite_name );
const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_id( int ciphersuite_id );

BIN
deps/lib/nt_amd64/glew32.dll vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/libbz2.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/libfreetype.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/libglfw.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/libharfbuzz.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/libpng.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/libpolarssl.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/libz.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/release/glew32.dll vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/release/libbz2.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/release/libfreetype.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/release/libglfw.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/release/libharfbuzz.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/release/libpng.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/release/libpolarssl.a vendored

Binary file not shown.

BIN
deps/lib/nt_amd64/release/libz.a vendored

Binary file not shown.

0
deps/lib/glew32.dll → deps/lib/nt_i386/glew32.dll vendored

0
deps/lib/libbz2.a → deps/lib/nt_i386/libbz2.a vendored

0
deps/lib/libfreetype.a → deps/lib/nt_i386/libfreetype.a vendored

0
deps/lib/libglfw.a → deps/lib/nt_i386/libglfw.a vendored

0
deps/lib/libharfbuzz.a → deps/lib/nt_i386/libharfbuzz.a vendored

0
deps/lib/libpng.a → deps/lib/nt_i386/libpng.a vendored

BIN
deps/lib/libpolarssl.a → deps/lib/nt_i386/libpolarssl.a vendored

Binary file not shown.

0
deps/lib/libz.a → deps/lib/nt_i386/libz.a vendored

BIN
reltools/winnt/glew32.dll → deps/lib/nt_i386/release/glew32.dll vendored

Binary file not shown.

BIN
deps/lib/nt_i386/release/libbz2.a vendored

Binary file not shown.

BIN
deps/lib/nt_i386/release/libfreetype.a vendored

Binary file not shown.

BIN
deps/lib/nt_i386/release/libglfw-nt.a vendored

Binary file not shown.

BIN
deps/lib/nt_i386/release/libglfw3.a vendored

Binary file not shown.

BIN
deps/lib/nt_i386/release/libharfbuzz.a vendored

Binary file not shown.

BIN
deps/lib/nt_i386/release/libpng.a vendored

Binary file not shown.

BIN
deps/lib/nt_i386/release/libpolarssl.a vendored

Binary file not shown.

BIN
deps/lib/nt_i386/release/libz.a vendored

Binary file not shown.

2
legacy-ci.sh

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
#!/usr/bin/sh
ssh -p 2738 rick@68.203.167.111 ./build-msdos

BIN
netrunner.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

60
netrunner.rc

@ -0,0 +1,60 @@ @@ -0,0 +1,60 @@
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
#ifdef _WIN32
#pragma code_page(1252)
#endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"\0"
END
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Icon
//
// Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems.
IDI_ICON1 ICON "netrunner.ico"
IDI_ICON2 ICON "favicon.ico"
#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

BIN
netrunner.zip

Binary file not shown.

BIN
netrunner_ssl.zip

Binary file not shown.

BIN
reltools/winnt/amd64/glew32.dll

Binary file not shown.

BIN
reltools/winnt/amd64/libgcc_s_seh-1.dll

Binary file not shown.

BIN
reltools/winnt/amd64/libssp-0.dll

Binary file not shown.

BIN
reltools/winnt/amd64/libstdc++-6.dll

Binary file not shown.

BIN
reltools/winnt/amd64/libwinpthread-1.dll

Binary file not shown.

BIN
reltools/winnt/i386/glew32.dll

Binary file not shown.

0
reltools/winnt/libgcc_s_sjlj-1.dll → reltools/winnt/i386/libgcc_s_sjlj-1.dll

0
reltools/winnt/libssp-0.dll → reltools/winnt/i386/libssp-0.dll

0
reltools/winnt/libstdc++-6.dll → reltools/winnt/i386/libstdc++-6.dll

17
resource.h

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by netrunner.rc
//
#define IDI_ICON1 102
#define IDI_ICON2 104
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 105
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1000
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

42
src/CFGFileParser.cpp

@ -0,0 +1,42 @@ @@ -0,0 +1,42 @@
#include "CFGFileParser.h"
CFGFileParser::CFGFileParser(const char* filename){
// Open the config file, get its size,
// allocate the buffer, read it into
// the buffer, close the file
cfg_file = fopen(filename, "r");
stat(filename, cfg_fileinfo);
buffer = static_cast<char*>(tlsf_calloc(cfg_fileinfo->st_size,sizeof(char)));
fread(buffer,sizeof(char),cfg_fileinfo->st_size,cfg_file);
fclose(cfg_file);
}
CFGFileParser::~CFGFileParser(){
// clean up!
tlsf_free(buffer);
}
namespace ntr{
size_t string_hash(const fast_string &str){
size_t out = 0;
// instead of tying this to i386/amd64, because someone is eventually going to
// port this to ARM or some RISC nonsense
#if UINTPTR_MAX == 0xffffffff
MurmurHash3_x86_128 ( &str, sizeof(str), 7904542L, &out );
#elif UINTPTR_MAX == 0xffffffffffffffff
MurmurHash3_x64_128 ( &str, sizeof(str), 5484754L, &out );
#else
#endif
return out;
}
bool fast_string_compare(fast_string t1, fast_string t2){
int i = strcmp(t1.c_str(),t2.c_str());
if (!i){
return true;
}
else{
return false;
}
}
}

55
src/CFGFileParser.h

@ -0,0 +1,55 @@ @@ -0,0 +1,55 @@
#ifndef __CFGFILEPARSER_H__
#define __CFGFILEPARSER_H__
#include <string>
#include <unordered_map>
#include <utility>
#include <functional>
#include <algorithm>
#include "TLSFAlloc.h"
#include "Murmur3.h"
#include "tlsf.h"
#include <sys/stat.h>
#include <cstdint>
// let's try fast strings
namespace ntr{
typedef std::basic_string<char, std::char_traits<char>, TLSFAlloc<char>> fast_string;
size_t string_hash(const fast_string &str);
bool fast_string_compare(fast_string t1, fast_string t2);
typedef std::unordered_map<fast_string,fast_string,std::function<decltype(string_hash)>,std::function<decltype(fast_string_compare)>,TLSFAlloc<std::pair<const fast_string, fast_string>>> stringmap;
}
// Class which holds the parsed configuration options after
// being processed by CFGFileParser. No longer a "trivial class"
// just select by cfg->GlobalSettings....
struct BrowserConfiguration{
ntr::stringmap GlobalSettings;
// fast allocation!
static void* operator new(std::size_t n){
if (void *mem = tlsf_malloc(n)){
return mem;
} throw std::bad_alloc {};
}
static void operator delete(void *p){
tlsf_free(p);
}
void clear();
};
class CFGFileParser {
public:
CFGFileParser(const char* filename);
~CFGFileParser();
static void* operator new(std::size_t n){
if (void *mem = tlsf_malloc(n)){
return mem;
} throw std::bad_alloc {};
}
static void operator delete(void *p){
tlsf_free(p);
}
private:
FILE *cfg_file;
char *buffer;
struct stat *cfg_fileinfo;
};
#endif // __CFGFILEPARSER_H__

334
src/Murmur3.cpp

@ -0,0 +1,334 @@ @@ -0,0 +1,334 @@
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
// Note - The x86 and x64 versions do _not_ produce the same results, as the
// algorithms are optimized for their respective platforms. You can still
// compile and run any of them on any platform, but your performance with the
// non-native version will be less than optimal.
#include "Murmur3.h"
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
// Microsoft Visual Studio
#if defined(_MSC_VER)
#define FORCE_INLINE __forceinline
#include <stdlib.h>
#define ROTL32(x,y) _rotl(x,y)
#define ROTL64(x,y) _rotl64(x,y)
#define BIG_CONSTANT(x) (x)
// Other compilers
#else // defined(_MSC_VER)
#define FORCE_INLINE inline __attribute__((always_inline))
inline uint32_t rotl32 ( uint32_t x, int8_t r )
{
return (x << r) | (x >> (32 - r));
}
inline uint64_t rotl64 ( uint64_t x, int8_t r )
{
return (x << r) | (x >> (64 - r));
}
#define ROTL32(x,y) rotl32(x,y)
#define ROTL64(x,y) rotl64(x,y)
#define BIG_CONSTANT(x) (x##LLU)
#endif // !defined(_MSC_VER)
//-----------------------------------------------------------------------------
// Block read - if your platform needs to do endian-swapping or can only
// handle aligned reads, do the conversion here
FORCE_INLINE uint32_t getblock32 ( const uint32_t * p, int i )
{
return p[i];
}
FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )
{
return p[i];
}
//-----------------------------------------------------------------------------
// Finalization mix - force all bits of a hash block to avalanche
FORCE_INLINE uint32_t fmix32 ( uint32_t h )
{
h ^= h >> 16;
h *= 0x85ebca6b;
h ^= h >> 13;
h *= 0xc2b2ae35;
h ^= h >> 16;
return h;
}
//----------
FORCE_INLINE uint64_t fmix64 ( uint64_t k )
{
k ^= k >> 33;
k *= BIG_CONSTANT(0xff51afd7ed558ccd);
k ^= k >> 33;
k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53);
k ^= k >> 33;
return k;
}
//-----------------------------------------------------------------------------
void MurmurHash3_x86_32 ( const void * key, int len,
uint32_t seed, void * out )
{
const uint8_t * data = (const uint8_t*)key;
const int nblocks = len / 4;
uint32_t h1 = seed;
const uint32_t c1 = 0xcc9e2d51;
const uint32_t c2 = 0x1b873593;
//----------
// body
const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
for(int i = -nblocks; i; i++)
{
uint32_t k1 = getblock32(blocks,i);
k1 *= c1;
k1 = ROTL32(k1,15);
k1 *= c2;
h1 ^= k1;
h1 = ROTL32(h1,13);
h1 = h1*5+0xe6546b64;
}
//----------
// tail
const uint8_t * tail = (const uint8_t*)(data + nblocks*4);
uint32_t k1 = 0;
switch(len & 3)
{
case 3: k1 ^= tail[2] << 16;
case 2: k1 ^= tail[1] << 8;
case 1: k1 ^= tail[0];
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
};
//----------
// finalization
h1 ^= len;
h1 = fmix32(h1);
*(uint32_t*)out = h1;
}
//-----------------------------------------------------------------------------
void MurmurHash3_x86_128 ( const void * key, const int len,
uint32_t seed, void * out )
{
const uint8_t * data = (const uint8_t*)key;
const int nblocks = len / 16;
uint32_t h1 = seed;
uint32_t h2 = seed;
uint32_t h3 = seed;
uint32_t h4 = seed;
const uint32_t c1 = 0x239b961b;
const uint32_t c2 = 0xab0e9789;
const uint32_t c3 = 0x38b34ae5;
const uint32_t c4 = 0xa1e38b93;
//----------
// body
const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);
for(int i = -nblocks; i; i++)
{
uint32_t k1 = getblock32(blocks,i*4+0);
uint32_t k2 = getblock32(blocks,i*4+1);
uint32_t k3 = getblock32(blocks,i*4+2);
uint32_t k4 = getblock32(blocks,i*4+3);
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b;
k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747;
k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35;
k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17;
}
//----------
// tail
const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
uint32_t k1 = 0;
uint32_t k2 = 0;
uint32_t k3 = 0;
uint32_t k4 = 0;
switch(len & 15)
{
case 15: k4 ^= tail[14] << 16;
case 14: k4 ^= tail[13] << 8;
case 13: k4 ^= tail[12] << 0;
k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
case 12: k3 ^= tail[11] << 24;
case 11: k3 ^= tail[10] << 16;
case 10: k3 ^= tail[ 9] << 8;
case 9: k3 ^= tail[ 8] << 0;
k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
case 8: k2 ^= tail[ 7] << 24;
case 7: k2 ^= tail[ 6] << 16;
case 6: k2 ^= tail[ 5] << 8;
case 5: k2 ^= tail[ 4] << 0;
k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
case 4: k1 ^= tail[ 3] << 24;
case 3: k1 ^= tail[ 2] << 16;
case 2: k1 ^= tail[ 1] << 8;
case 1: k1 ^= tail[ 0] << 0;
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
};
//----------
// finalization
h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len;
h1 += h2; h1 += h3; h1 += h4;
h2 += h1; h3 += h1; h4 += h1;
h1 = fmix32(h1);
h2 = fmix32(h2);
h3 = fmix32(h3);
h4 = fmix32(h4);
h1 += h2; h1 += h3; h1 += h4;
h2 += h1; h3 += h1; h4 += h1;
((uint32_t*)out)[0] = h1;
((uint32_t*)out)[1] = h2;
((uint32_t*)out)[2] = h3;
((uint32_t*)out)[3] = h4;
}
//-----------------------------------------------------------------------------
void MurmurHash3_x64_128 ( const void * key, const int len,
const uint32_t seed, void * out )
{
const uint8_t * data = (const uint8_t*)key;
const int nblocks = len / 16;
uint64_t h1 = seed;
uint64_t h2 = seed;
const uint64_t c1 = BIG_CONSTANT(0x87c37b91114253d5);
const uint64_t c2 = BIG_CONSTANT(0x4cf5ad432745937f);
//----------
// body
const uint64_t * blocks = (const uint64_t *)(data);
for(int i = 0; i < nblocks; i++)
{
uint64_t k1 = getblock64(blocks,i*2+0);
uint64_t k2 = getblock64(blocks,i*2+1);
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
h1 = ROTL64(h1,27); h1 += h2; h1 = h1*5+0x52dce729;
k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
h2 = ROTL64(h2,31); h2 += h1; h2 = h2*5+0x38495ab5;
}
//----------
// tail
const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
uint64_t k1 = 0;
uint64_t k2 = 0;
switch(len & 15)
{
case 15: k2 ^= ((uint64_t)tail[14]) << 48;
case 14: k2 ^= ((uint64_t)tail[13]) << 40;
case 13: k2 ^= ((uint64_t)tail[12]) << 32;
case 12: k2 ^= ((uint64_t)tail[11]) << 24;
case 11: k2 ^= ((uint64_t)tail[10]) << 16;
case 10: k2 ^= ((uint64_t)tail[ 9]) << 8;
case 9: k2 ^= ((uint64_t)tail[ 8]) << 0;
k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
case 8: k1 ^= ((uint64_t)tail[ 7]) << 56;
case 7: k1 ^= ((uint64_t)tail[ 6]) << 48;
case 6: k1 ^= ((uint64_t)tail[ 5]) << 40;
case 5: k1 ^= ((uint64_t)tail[ 4]) << 32;
case 4: k1 ^= ((uint64_t)tail[ 3]) << 24;
case 3: k1 ^= ((uint64_t)tail[ 2]) << 16;
case 2: k1 ^= ((uint64_t)tail[ 1]) << 8;
case 1: k1 ^= ((uint64_t)tail[ 0]) << 0;
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
};
//----------
// finalization
h1 ^= len; h2 ^= len;
h1 += h2;
h2 += h1;
h1 = fmix64(h1);
h2 = fmix64(h2);
h1 += h2;
h2 += h1;
((uint64_t*)out)[0] = h1;
((uint64_t*)out)[1] = h2;
}
//-----------------------------------------------------------------------------

37
src/Murmur3.h

@ -0,0 +1,37 @@ @@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
#ifndef _MURMURHASH3_H_
#define _MURMURHASH3_H_
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
// Microsoft Visual Studio
#if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
// Other compilers
#else // defined(_MSC_VER)
#include <stdint.h>
#endif // !defined(_MSC_VER)
//-----------------------------------------------------------------------------
void MurmurHash3_x86_32 ( const void * key, int len, uint32_t seed, void * out );
void MurmurHash3_x86_128 ( const void * key, int len, uint32_t seed, void * out );
void MurmurHash3_x64_128 ( const void * key, int len, uint32_t seed, void * out );
//-----------------------------------------------------------------------------
#endif // _MURMURHASH3_H_

84
src/TLSFAlloc.h

@ -0,0 +1,84 @@ @@ -0,0 +1,84 @@
// This is a custom C++ allocator that wraps the 2LSF C heap allocator
// -despair
// in case of emergency, set DEBUG_TLSF_CPP somewhere before including this header
#include <limits>
#include <iostream>
#include "tlsf.h"
namespace ntr {
template <class T>
class TLSFAlloc {
public:
typedef T value_type;
typedef T* ptr;
typedef const T* const_ptr;
typedef T& ref;
typedef const T& const_ref;
typedef std::size_t size_type;
typedef std::ptrdiff_t diff_type;
template <class U>
struct rebind {
typedef TLSFAlloc<U> other;
};
ptr address (ref value) const {
return &value;
}
const_ptr address (const_ref value) const {
return &value;
}
// these are the constructors for same: had I not ported sbrk(2) to winnt,
// the constructor would have generated a memory pool from above.
TLSFAlloc() throw() {}
TLSFAlloc(const TLSFAlloc&) throw() {}
template <class U> TLSFAlloc(const TLSFAlloc<U>&) throw() {}
~TLSFAlloc() throw() {}
// return maximum number of elements that can be allocated
size_type max_size() const throw() {
return std::numeric_limits<std::size_t>::max() / sizeof(T);
}
// allocate but don't initialize num elements of type T
ptr allocate(size_type num, const void* = 0) {
#ifdef DEBUG_TLSF_CPP
// print message and allocate memory with 2LSF
std::cerr << "allocate " << num << " element(s)" << " of size " << sizeof(T) << std::endl;
ptr ret = (ptr)(tlsf_malloc(num*sizeof(T)));
std::cerr << " allocated at: " << (void*)ret << std::endl; return ret;
#else
ptr ret = static_cast<ptr>(tlsf_malloc(num*sizeof(T))); return ret;
#endif
}
// initialize elements of allocated storage p with value value
// using placement new (defined here)
void construct (ptr p, const T& value) {
new (reinterpret_cast<void*>(p))T(value);
}
// placement new
void* operator new (std::size_t size, void*){
return allocate(size);
}
// destroy elements of initialized storage p
void destroy (ptr p) {
p->~T();
}
// deallocate storage p of deleted elements
void deallocate(ptr p, size_type num) {
#ifdef DEBUG_TLSF_CPP
// print message and deallocate memory with global delete
std::cerr << "deallocate " << num << " element(s)" << " of size " << sizeof(T) << " at: " << (void*)p << std::endl;
#endif
tlsf_free(reinterpret_cast<void*>(p));
}
};
// return that all specializations of this allocator are interchangeable
template <class T1, class T2> bool operator== (const TLSFAlloc<T1>&,const TLSFAlloc<T2>&) throw() { return true; }
template <class T1, class T2> bool operator!= (const TLSFAlloc<T1>&, const TLSFAlloc<T2>&) throw() { return false; }
}

20
src/graphics/components/AnimeComponent.cpp

@ -2,6 +2,9 @@ @@ -2,6 +2,9 @@
#include <cmath>
#include <iostream>
#include "../../pnm.h"
#ifdef __MINGW32__
#include "../../../anime.h"
#endif
AnimeComponent::AnimeComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight) : BoxComponent(rawX, rawY, rawWidth, rawHeight, 0x00000000, passedWindowWidth, passedWindowHeight) {
//std::cout << "AnimeComponent::AnimeComponent" << std::endl;
@ -14,11 +17,20 @@ AnimeComponent::AnimeComponent(const float rawX, const float rawY, const float r @@ -14,11 +17,20 @@ AnimeComponent::AnimeComponent(const float rawX, const float rawY, const float r
width = rawWidth;
height = rawHeight;
#ifdef __MINGW32__ // the old "huge string" works fine with mingw
for (int py = 0; py < 1024; py++) {
for (int px = 0; px < 1024; px++) {
for (int i = 0; i < 4; i++) {
data[1023 - py][px][i] = anime.pixel_data[((px * 4) + (py * 4 * 1024)) + i];
}
}
}
#else // this is either non-Windows or Microsoft C/C++
RGBAPNMObject *anime = readPPM("anime.pnm");
if (!anime) {
std::cout << "Can't set up anime component, couldn't read anime.pnm" << std::endl;
}
for (int py = 0; py < 1024; py++) {
for (int px = 0; px < 1024; px++) {
if (anime) {
@ -31,6 +43,7 @@ AnimeComponent::AnimeComponent(const float rawX, const float rawY, const float r @@ -31,6 +43,7 @@ AnimeComponent::AnimeComponent(const float rawX, const float rawY, const float r
}
}
}
#endif
float vx = rawX;
float vy = rawY;
@ -71,6 +84,9 @@ AnimeComponent::AnimeComponent(const float rawX, const float rawY, const float r @@ -71,6 +84,9 @@ AnimeComponent::AnimeComponent(const float rawX, const float rawY, const float r
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glGenerateMipmap(GL_TEXTURE_2D);
delete[] anime->m_Ptr;
#ifndef __MINGW32__
tlsf_free(anime->m_Ptr);
delete anime;
#endif
}

23
src/main.cpp

@ -5,11 +5,23 @@ @@ -5,11 +5,23 @@
#include "Log.h"
#include "URL.h"
#include "WebResource.h"
#include "tlsf.h"
#include "scheduler.h"
#include <ctime>
#include <iostream>
#include <sys/stat.h>
#ifdef _WIN32
extern "C"{
void init_heap();
}
#endif
#if defined(_WIN32) && !defined(_WIN64)
#define PLATFORM "i686-pc-winnt"
#endif
#ifdef _WIN64
#define PLATFORM "amd64-pc-winnt"
#endif
const std::unique_ptr<Window> window = std::make_unique<Window>();
// why can't I const this?
@ -74,14 +86,15 @@ bool fileExists(const std::string s) { @@ -74,14 +86,15 @@ bool fileExists(const std::string s) {
}
int main(int argc, char *argv[]) {
// no longer require a URL
/*
if (argc == 1) {
// show help msg when "--help" appears
if (argv[1] && (strcmp(argv[1], "--help")==0)) {
std::cout << "./netrunner [http://host.tld/|/path/to/file.html] [-log <error|warning|notice|info|debug>]" << std::endl;
return 1;
}
*/
std::cout << "/g/ntr - NetRunner build " << __DATE__ << std::endl;
# ifdef _WIN32
init_heap(); // the NT port requires it. We do it at startup now, to allow 2LSF to run at any time
# endif
std::cout << "/g/ntr - NetRunner build " << __DATE__ << ": rev-" << VERSION << " for " << PLATFORM << std::endl;
Environment::init();
// we need to set up OGL before we can setDOM (because component can't be constructed (currently) without OGL)

157
src/networking/HTTPSRequest.cpp

@ -12,11 +12,10 @@ mbedtls_ssl_config conf; @@ -12,11 +12,10 @@ mbedtls_ssl_config conf;
mbedtls_x509_crt cacert;
HTTPSRequest::HTTPSRequest(const std::shared_ptr<URL> u) {
if (!initTLS())
{
printf("failed to start TLS!");
return;
}
if (!initTLS()){
printf("failed to start TLS!");
return;
}
uri = u;
version = Version::HTTP10;
method = Method::GET;
@ -25,79 +24,73 @@ HTTPSRequest::HTTPSRequest(const std::shared_ptr<URL> u) { @@ -25,79 +24,73 @@ HTTPSRequest::HTTPSRequest(const std::shared_ptr<URL> u) {
bool HTTPSRequest::sendRequest(std::function<void(const HTTPResponse&)> responseCallback) const {
std::string response;
std::string document = uri->path;
std::string host = uri->host;
std::string port = std::to_string(uri->port);
std::string document = uri->path;
std::string host = uri->host;
std::string port = std::to_string(uri->port);
char buffer[512];
int ret;
unsigned flags;
if(mbedtls_net_connect(&server_fd, host.c_str(),port.c_str(), MBEDTLS_NET_PROTO_TCP) != 0 )
{
return false;
}
if (mbedtls_ssl_config_defaults(&conf,MBEDTLS_SSL_IS_CLIENT,MBEDTLS_SSL_TRANSPORT_STREAM,MBEDTLS_SSL_PRESET_DEFAULT) != 0)
{
return false;
}
mbedtls_ssl_conf_authmode(&conf, MBEDTLS_SSL_VERIFY_REQUIRED);
mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &ctr_drbg);
mbedtls_ssl_conf_ca_chain( &conf, &cacert, nullptr );
int ret;
unsigned flags;
if(mbedtls_net_connect(&server_fd, host.c_str(),port.c_str(), MBEDTLS_NET_PROTO_TCP) != 0 ){
return false;
}
if (mbedtls_ssl_config_defaults(&conf,MBEDTLS_SSL_IS_CLIENT,MBEDTLS_SSL_TRANSPORT_STREAM,MBEDTLS_SSL_PRESET_DEFAULT) != 0){
return false;
}
mbedtls_ssl_conf_authmode(&conf, MBEDTLS_SSL_VERIFY_REQUIRED);
mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &ctr_drbg);
mbedtls_ssl_conf_ca_chain( &conf, &cacert, nullptr );
if( mbedtls_ssl_setup( &ssl, &conf ) != 0 )
{
if( mbedtls_ssl_setup( &ssl, &conf ) != 0 ){
return false;
}
if(mbedtls_ssl_set_hostname( &ssl, uri->host.c_str() ) != 0 ){
return false;
}
if(mbedtls_ssl_set_hostname( &ssl, uri->host.c_str() ) != 0 )
{
return false;
}
mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, nullptr );
int state = mbedtls_ssl_handshake( &ssl );
while(state != 0)
{
if( state != MBEDTLS_ERR_SSL_WANT_READ && state != MBEDTLS_ERR_SSL_WANT_WRITE )
{
}
mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, nullptr );
int state = mbedtls_ssl_handshake( &ssl );
while(state != 0){
if( state != MBEDTLS_ERR_SSL_WANT_READ && state != MBEDTLS_ERR_SSL_WANT_WRITE ){
printf( " failed\n ! mbedtls_ssl_handshake returned -0x%x\n\n", -state );
return false;
return false;
}
}
if( ( flags = mbedtls_ssl_get_verify_result( &ssl ) ) != 0 )
{
printf("Invalid server cert!");
return false;
}
const std::string request = methodToString(method) + std::string(" ") + document + std::string(" ") + versionToString(version) + std::string("\r\nHost: ") + host + std::string("\r\nUser-Agent: ") + userAgent + std::string("\r\n\r\n");
while( ( state = mbedtls_ssl_write( &ssl, reinterpret_cast<const unsigned char*>(request.c_str()), request.length() ) ) <= 0 )
{
if( state != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE )
{
}
if( ( flags = mbedtls_ssl_get_verify_result( &ssl ) ) != 0 ){
printf("Invalid server cert!");
return false;
}
const std::string request = methodToString(method) + std::string(" ") + document + std::string(" ") + versionToString(version) + std::string("\r\nHost: ") + host + std::string("\r\nUser-Agent: ") + userAgent + std::string("\r\n\r\n");
while( ( state = mbedtls_ssl_write( &ssl, reinterpret_cast<const unsigned char*>(request.c_str()), request.length() ) ) <= 0 ){
if( state != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ){
printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", state );
return false;
return false;
}
}
}
do
{
do{
ret = mbedtls_ssl_read( &ssl, reinterpret_cast<unsigned char *>(buffer), 512 );
if (ret <= 0)
break;
else
response += std::string(buffer, static_cast<unsigned int>(ret));
if (ret <= 0){
break;
}
else{
response += std::string(buffer, static_cast<unsigned int>(ret));
}
}
while( ret != 0 );
// clean up after the request
mbedtls_ssl_close_notify( &ssl );
// clean up after the request
mbedtls_ssl_close_notify( &ssl );
responseCallback(HTTPResponse(response));
mbedtls_net_free( &server_fd );
mbedtls_net_free( &server_fd );
mbedtls_x509_crt_free( &cacert );
mbedtls_ssl_free( &ssl );
mbedtls_ssl_config_free( &conf );
@ -128,24 +121,22 @@ const std::string HTTPSRequest::methodToString(const Method meth) const { @@ -128,24 +121,22 @@ const std::string HTTPSRequest::methodToString(const Method meth) const {
bool HTTPSRequest::initTLS()
{
mbedtls_net_init( &server_fd );
mbedtls_ssl_init( &ssl );
mbedtls_ssl_config_init( &conf );
mbedtls_x509_crt_init( &cacert );
mbedtls_ctr_drbg_init( &ctr_drbg );
const char *seed = "netrunner_ssl_seed$%?rvx86_despair^^%$#@";
mbedtls_entropy_init( &entropy );
if(mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, reinterpret_cast<const unsigned char*>(seed), strlen(seed) ) != 0 )
{
return false;
}
int ret = mbedtls_x509_crt_parse_file( &cacert, "ca-bundle.crt");
if( ret < 0 )
{
mbedtls_net_init( &server_fd );
mbedtls_ssl_init( &ssl );
mbedtls_ssl_config_init( &conf );
mbedtls_x509_crt_init( &cacert );
mbedtls_ctr_drbg_init( &ctr_drbg );
const char *seed = "!@netrunner_ssl_seed$%?rvx86_despair##^^%$#@";
mbedtls_entropy_init( &entropy );
if(mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, reinterpret_cast<const unsigned char*>(seed), strlen(seed) ) != 0 ){
return false;
}
int ret = mbedtls_x509_crt_parse_file( &cacert, "ca-bundle.crt");
if( ret < 0 ){
printf( " failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", -ret );
return false;
return false;
}
return true;
return true;
}

5
src/networking/HTTPSRequest.h

@ -6,6 +6,11 @@ @@ -6,6 +6,11 @@
#include "../URL.h"
#include <functional>
#include <string>
#ifdef NULL
#undef NULL
#define NULL nullptr
#endif
// PolarSSL
#include <mbedtls/ssl.h>
#include <mbedtls/entropy.h>

2
src/pnm.cpp

@ -61,7 +61,7 @@ RGBAPNMObject * readPPM(const char* fileName) { @@ -61,7 +61,7 @@ RGBAPNMObject * readPPM(const char* fileName) {
}
// allocate array for pixels
char* pixels = new char[size];