diff --git a/README.md b/README.md index a607694741531adcb60efdc31cda50f7d3a8a6f0..150d4c0b1c04449dae19cabc919663e3cf7f9a8e 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ # Netrunner -is an implementation of a new web browser written in C++ utilizing OpenGL. This is a brand new engine. +is an implementation of a new web browser engine written in C++ utilizing OpenGL. -Status: You can give it a url and it'll download, parser, and render the text from the page +Status: You can give it a url and it'll download, parse, and render the text from the page ## Odilitime's vision A modern web browser is a huge project. I'd like to see this broken into several composable pieces. @@ -32,14 +32,21 @@ I'd like to develop text-based structures for communication between each piece. #### Void `sudo xbps-install -S glew glfw harfbuzz-devel` +#### Gentoo +`sudo emerge freetype harfbuzz glew glfw` + ## Binaries ### Linux -[2017-07-26 binary package](https://my.mixtape.moe/xqvpqc.tar.gz) +[2017-07-31 binary package](https://my.mixtape.moe/imatcb.tar.gz) +GyroNinja.net is temporarily offline. Working with registrar to bring it back online. [nightly binary only (no font files)](https://gyroninja.net:1615/job/NetRunner/lastSuccessfulBuild/artifact/netrunner) ### OSX -[2017-07-27 binary package](https://my.mixtape.moe/gbludd.zip) +[2017-07-31 binary package](https://my.mixtape.moe/ywjanx.zip) + +### Windows +[2017-07-31 binary package](https://my.mixtape.moe/hkpcyu.zip) ## Milestones - Browse 4chan /g/ board @@ -64,6 +71,13 @@ I don't think one on here could ever say they know what their doing without bein - OSX Dev, focused on clean up - Repo: https://gitgud.io/odilitime/netrunner/ +- Nubben + - contributed local file code + - repo: https://github.com/nubben/netrunner + +- Tomleb + - contributed keyboard code + - RetroTech - Web / Sys Admin - Created original website - Helps manage archive of logos and threads @@ -102,6 +116,6 @@ We coordinate on [irc.rizon.net](https://www.rizon.net/chat) #/g/netrunner or [O - element - our DOM tree classes ### Class Types -- Nodes DOM tree objects -- Elements Individual tag types -- Components (gameobjects) renderer entities +- Nodes: DOM tree objects +- Elements: Individual tag types +- Components: (gameobjects) renderer entities diff --git a/reltools/.DS_Store b/reltools/.DS_Store deleted file mode 100644 index 823e177a7803dfcd83850cec4b8346fbec31b076..0000000000000000000000000000000000000000 Binary files a/reltools/.DS_Store and /dev/null differ diff --git a/src/StringUtils.cpp b/src/StringUtils.cpp index 40fc0ca856eec1f9c6a874c101aeed592d49b6b1..bdf225477738b1eb97d79a6d8e745fb1a9675bf8 100644 --- a/src/StringUtils.cpp +++ b/src/StringUtils.cpp @@ -1,16 +1,18 @@ #include "StringUtils.h" +#include <iostream> #include <iterator> #include <algorithm> /** * get an extension from a filename - * @param a filename string + * @param fileName a filename string * @return '' or a string with the found extension */ std::string getFilenameExtension(std::string const& fileName) { auto dotPos = fileName.find_last_of('.'); if (dotPos != std::string::npos && dotPos + 1 != std::string::npos) { + //std::cout << "StringUtils::getFilenameExtension - " << fileName.substr(dotPos + 1) << std::endl; return fileName.substr(dotPos + 1); } return ""; @@ -18,7 +20,7 @@ std::string getFilenameExtension(std::string const& fileName) { /** * get an document from a url - * @param url string + * @param url url string * @return '' or a string with the found document */ const std::string getDocumentFromURL(const std::string &url) { @@ -36,7 +38,7 @@ const std::string getDocumentFromURL(const std::string &url) { /** * get host from a url - * @param url string + * @param url url string * @return '' or a string with the found host */ const std::string getHostFromURL(const std::string &url) { diff --git a/src/WebResource.cpp b/src/WebResource.cpp index 7af980a79ec86ef0c43796d80052b26a7236b254..464732374742146c1125a4109b957eabc2e0f9af 100644 --- a/src/WebResource.cpp +++ b/src/WebResource.cpp @@ -6,6 +6,7 @@ #include "networking/HTTPRequest.h" #include "networking/HTTPResponse.h" #include "StringUtils.h" +#include <iostream> namespace { @@ -34,8 +35,10 @@ WebResource::WebResource(ResourceType rtype, std::string const& rraw) { WebResource getWebResource(std::string resourceName) { if (isOnlineResource(resourceName)) { + //std::cout << "WebReousrce::getWebResource - isOnline" << std::endl; return getOnlineWebResource(resourceName); } + //std::cout << "WebReousrce::getWebResource - isOffline" << std::endl; return getLocalWebResource(resourceName); } @@ -54,7 +57,7 @@ WebResource getLocalWebResource(std::string fileName) { if (strToRT.find(fileExtension) == strToRT.end()) { return WebResource(ResourceType::INVALID, - "Resource type " + fileExtension + " not supported"); + "Local file with extension " + fileExtension + " is not supported. Did you forget a http://?"); } std::ifstream in(fileName, std::ios::in | std::ios::binary); diff --git a/src/graphics/components/AnimeComponent.cpp b/src/graphics/components/AnimeComponent.cpp index b47dec74a9feb5f89333f921d0b1c9d217c951bc..36ac0cb62cba44989ef1a10b015f83ef04bc8a2d 100644 --- a/src/graphics/components/AnimeComponent.cpp +++ b/src/graphics/components/AnimeComponent.cpp @@ -1,13 +1,16 @@ #include "AnimeComponent.h" +#ifndef _MSC_VER #include "../../../anime.h" +#endif #include <cmath> -AnimeComponent::AnimeComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int windowWidth, const int windowHeight) : BoxComponent(rawX, rawY, rawWidth, rawHeight, windowWidth, windowHeight){ +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, passedWindowWidth, passedWindowHeight){ x = rawX; y = rawY; width = rawWidth; height = rawHeight; +#ifndef _MSC_VER if (width == 512) { for (int py = 0; py < 1024; py++) { for (int px = 0; px < 1024; px++) { @@ -17,6 +20,7 @@ AnimeComponent::AnimeComponent(const float rawX, const float rawY, const float r } } } +#endif float vx = rawX; float vy = rawY; diff --git a/src/graphics/components/AnimeComponent.h b/src/graphics/components/AnimeComponent.h index f0ae933d0e71b5e5790d5929e7450f38ab9237bd..89686be312e57036c8299d1c6d558ec909484e62 100644 --- a/src/graphics/components/AnimeComponent.h +++ b/src/graphics/components/AnimeComponent.h @@ -6,7 +6,7 @@ class AnimeComponent : public BoxComponent { public: - AnimeComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int windowWidth, const int windowHeight); + AnimeComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight); }; -#endif \ No newline at end of file +#endif diff --git a/src/graphics/components/BoxComponent.cpp b/src/graphics/components/BoxComponent.cpp index 998b657d7ce2140d6ee9a6c4605a3b7d3f7aeebd..65438cb6144ddf2ad60c4facc6da7c6dbdcc1f2d 100644 --- a/src/graphics/components/BoxComponent.cpp +++ b/src/graphics/components/BoxComponent.cpp @@ -2,7 +2,7 @@ #include <cmath> #include <iostream> -BoxComponent::BoxComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int windowWidth, const int windowHeight) { +BoxComponent::BoxComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight) { x = rawX; y = rawY; width = rawWidth; @@ -115,7 +115,7 @@ void BoxComponent::resize() { verticesDirty = true; } -void BoxComponent::pointToViewport(float &rawX, float &rawY, const int windowWidth, const int windowHeight) const { +void BoxComponent::pointToViewport(float &rawX, float &rawY, const int passedWindowWidth, const int passedWindowHeight) const { if (rawX < 0) { rawX += windowWidth; } @@ -132,7 +132,7 @@ void BoxComponent::pointToViewport(float &rawX, float &rawY, const int windowWid rawY = (rawY * 2) - 1; } -void BoxComponent::distanceToViewport(float &rawX, float &rawY, const int windowWidth, const int windowHeight) const { +void BoxComponent::distanceToViewport(float &rawX, float &rawY, const int passedWindowWidth, const int passedWindowHeight) const { if (std::abs(rawX) > 1) { rawX /= windowWidth; } diff --git a/src/graphics/components/BoxComponent.h b/src/graphics/components/BoxComponent.h index 1bb3b87ddae45456f70509ced25f0c649482ee96..4dc098eee05f41aa40dc553b5f22fab3af66dad3 100644 --- a/src/graphics/components/BoxComponent.h +++ b/src/graphics/components/BoxComponent.h @@ -22,12 +22,12 @@ protected: GLuint elementBufferObject = 0; GLuint texture = 0; public: - BoxComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int windowWidth, const int windowHeight); + BoxComponent(const float rawX, const float rawY, const float rawWidth, const float rawHeight, const int passedWindowWidth, const int passedWindowHeight); ~BoxComponent(); void render(); void resize(); - void pointToViewport(float &rawX, float &rawY, const int windowWidth, const int windowHeight) const ; - void distanceToViewport(float &rawX, float &rawY, const int windowWidth, const int windowHeight) const ; + void pointToViewport(float &rawX, float &rawY, const int passedWindowWidth, const int passedWindowHeight) const ; + void distanceToViewport(float &rawX, float &rawY, const int passedWindowWidth, const int passedWindowHeight) const ; }; #endif diff --git a/src/graphics/components/Component.cpp b/src/graphics/components/Component.cpp index a81c58b443612205514084b63077ac60564f7e3f..1d07d016fd461819098d8a6975e8f017b68e6003 100644 --- a/src/graphics/components/Component.cpp +++ b/src/graphics/components/Component.cpp @@ -1,5 +1,7 @@ #include "Component.h" #include <iostream> +#include <algorithm> +#include "TextComponent.h" Component::~Component() { } @@ -37,16 +39,31 @@ void Component::layout() { // reset position x = 0; y = 0; + + /* + TextComponent *textComponent = dynamic_cast<TextComponent*>(this); + if (textComponent) { + std::cout << "Component::layout[" << textComponent->text << "]" << std::endl; + } + */ // if we're a child, get our parents position if (parent) { //std::cout << "Component::layout - copying position from parent: " << (int)parent->x << "x" << (int)parent->y << std::endl; + x = parent->x; y = parent->y; // if we have sibilings see if they're inline or block if (parent->children.size()) { //std::cout << "Component::layout - parent children: " << parent->children.size() << std::endl; if (previous) { + /* + TextComponent *prevTextComponent = dynamic_cast<TextComponent*>(previous.get()); + if (prevTextComponent) { + std::cout << "Component::layout - previous [" << prevTextComponent->text << "] ending at: " << (int)prevTextComponent->endingX << "x" << (int)prevTextComponent->endingY << "" << std::endl; + } + */ + //std::cout << "Component::layout - previous at: " << (int)previous->x << "x" << (int)previous->y << " size: " << (int)previous->width << "x" << (int)previous->height << " ending at: " << (int)previous->endingX << "x" << (int)previous->endingY << std::endl; // 2nd or last if (previous->isInline) { // last was inline @@ -54,6 +71,12 @@ void Component::layout() { x = previous->x + previous->width; y = previous->y; // keep on same line //std::cout << "Component::layout - inLine (" << (int)previous->width << " wide) inLine" << std::endl; + if (x >= windowWidth) { + //std::cout << "Component::layout - inline inline wrapping because x: " << (int)x << " window: " << windowWidth << std::endl; + x = previous->endingX; + //std::cout << "Component::layout - p.y: " << (int)previous->y << " p.ey: " << previous->endingY << " p.h" << (int)previous->height << std::endl; + y = previous->y - previous->height + previous->endingY; + } } else { // we're block y = previous->y - previous->height; @@ -66,6 +89,7 @@ void Component::layout() { } // really only inline but can't hurt block AFAICT if (x >= windowWidth) { + //std::cout << "Component::layout - wrapping because x: " << (int)x << " window: " << windowWidth << std::endl; x = 0; y -= previous->height; // how far down do we need to wrap?, the previous height? } @@ -130,7 +154,10 @@ void Component::updateParentSize() { // back up current size unsigned int lastParentWidth = parent->width; unsigned int lastParentHeight = parent->height; - + + parent->endingX = endingX; + parent->endingY = endingY; + // find max width of all siblings unsigned int maxWidth = width; // float? unsigned int heightAccum = 0; diff --git a/src/graphics/components/Component.h b/src/graphics/components/Component.h index f4d663be20f4fc12d0ee028367de6a2bb0ad7fe8..caa2752f906852f4ffcacb49fbfe5b550f03eeea 100644 --- a/src/graphics/components/Component.h +++ b/src/graphics/components/Component.h @@ -54,6 +54,9 @@ public: // current placement on screen float x = 0.0f; float y = 0.0f; + // text flow (needed here because parent elements of textnode need to pass this info) + int endingX = 0; + int endingY = 0; // height/width on screen float height = 0.0f; float width = 0.0f; diff --git a/src/graphics/components/TextComponent.cpp b/src/graphics/components/TextComponent.cpp index b9d06be545489849cf1ab17e15392f5c472825df..16c16fadfd06aca5cdaf676f9d5862c978a4c409 100644 --- a/src/graphics/components/TextComponent.cpp +++ b/src/graphics/components/TextComponent.cpp @@ -6,7 +6,7 @@ extern TextRasterizerCache *rasterizerCache; -TextComponent::TextComponent(const std::string &rawText, const int rawX, const int rawY, const unsigned int size, const bool bolded, const unsigned int hexColor, const int windowWidth, const int windowHeight) { +TextComponent::TextComponent(const std::string &rawText, const int rawX, const int rawY, const unsigned int size, const bool bolded, const unsigned int hexColor, const int passedWindowWidth, const int passedWindowHeight) { //const std::clock_t begin = clock(); text = rawText; //x = rawX; @@ -92,7 +92,7 @@ inline void setVerticesColor(std::unique_ptr<float[]> &vertices, int p, unsigned vertices[static_cast<size_t>(posMac(p) + 6)] = (static_cast<float>((color >> 0) & 0xFF)) / 255; } -void TextComponent::rasterize(const int rawX, const int rawY, const int windowWidth, const int windowHeight) { +void TextComponent::rasterize(const int rawX, const int rawY, const int passedWindowWidth, const int passedWindowHeight) { //const std::clock_t begin = clock(); const std::shared_ptr<TextRasterizer> textRasterizer=rasterizerCache->loadFont(fontSize, bold); unsigned int glyphCount; @@ -227,7 +227,7 @@ void TextComponent::resize() { verticesDirty = true; } -void TextComponent::pointToViewport(float &rawX, float &rawY, const int windowWidth, const int windowHeight) const { +void TextComponent::pointToViewport(float &rawX, float &rawY, const int passedWindowWidth, const int passedWindowHeight) const { rawX = ((rawX / windowWidth) * 2) - 1; rawY = ((rawY / windowHeight) * 2) - 1; } diff --git a/src/graphics/components/TextComponent.h b/src/graphics/components/TextComponent.h index b2ac618398711d6d53bee55974510df35d0deb24..50295fab8cfca41ff6327c2b6d6e8c1212e21b9e 100644 --- a/src/graphics/components/TextComponent.h +++ b/src/graphics/components/TextComponent.h @@ -24,17 +24,15 @@ private: std::vector<GLuint> vertexBufferObjects; GLuint elementBufferObject; std::vector<GLuint> textures; - int endingX = 0; - int endingY = 0; public: std::string text; - TextComponent(const std::string &rawText, const int rawX, const int rawY, const unsigned int size, const bool bolded, const unsigned int hexColor, const int windowWidth, const int windowHeight); + TextComponent(const std::string &rawText, const int rawX, const int rawY, const unsigned int size, const bool bolded, const unsigned int hexColor, const int passedWindowWidth, const int passedWindowHeight); ~TextComponent(); - void rasterize(const int rawX, const int rawY, const int windowWidth, const int windowHeight); + void rasterize(const int rawX, const int rawY, const int passedWindowWidth, const int passedWindowHeight); void render(); void resize(); - void pointToViewport(float &rawX, float &rawY, const int windowWidth, const int windowHeight) const; + void pointToViewport(float &rawX, float &rawY, const int passedWindowWidth, const int passedWindowHeight) const; void sanitize(std::string &str); // backgroundColor diff --git a/src/graphics/opengl/Window.cpp b/src/graphics/opengl/Window.cpp index ed1349823936039b3e2f2e5092a83371aca09f9e..a8efb4a71d75d38a91041bb2a05d412f6f8b2cb1 100644 --- a/src/graphics/opengl/Window.cpp +++ b/src/graphics/opengl/Window.cpp @@ -110,7 +110,7 @@ bool Window::initGLFW() { if (thiz->transformMatrix[13]>std::max((thiz->rootComponent->height)/(thiz->windowHeight)*2.0f, 2.0f)) { thiz->transformMatrix[13]=std::max((thiz->rootComponent->height)/(thiz->windowHeight)*2.0f, 2.0f); } - //std::cout << "scroll y is at " << thiz->transformMatrix[13] << "/" << (int)(thiz->transformMatrix[13]*10000) << std::endl; + //std::cout << "scroll y is at " << thiz->transformMatrix[13] << "/" << static_cast<int>((thiz->transformMatrix[13]*10000) << std::endl; thiz->transformMatrixDirty = true; }); glfwSetMouseButtonCallback(window, [](GLFWwindow *win, int button, int action, int mods) { @@ -350,10 +350,10 @@ void Window::printComponentTree(const std::shared_ptr<Component> &component, int } TextComponent *textComponent = dynamic_cast<TextComponent*>(component.get()); if (textComponent) { - std::cout << std::fixed << "X: " << (int)textComponent->x << " Y: " << (int)textComponent->y << " WIDTH: " << (int)textComponent->width << " HEIGHT: " << (int)textComponent->height << " INLINE: " << textComponent->isInline << " TEXT: " << textComponent->text << std::endl; + std::cout << std::fixed << "X: " << static_cast<int>(textComponent->x) << " Y: " << static_cast<int>(textComponent->y) << " WIDTH: " << static_cast<int>(textComponent->width) << " HEIGHT: " << static_cast<int>(textComponent->height) << " INLINE: " << textComponent->isInline << " TEXT: " << textComponent->text << std::endl; } else { - std::cout << std::fixed << "X: " << (int)component->x << " Y: " << (int)component->y << " WIDTH: " << (int)component->width << " HEIGHT: " << (int)component->height << " INLINE: " << component->isInline << std::endl; + std::cout << std::fixed << "X: " << static_cast<int>(component->x) << " Y: " << static_cast<int>(component->y) << " WIDTH: " << static_cast<int>(component->width) << " HEIGHT: " << static_cast<int>(component->height) << " INLINE: " << component->isInline << std::endl; } for (std::shared_ptr<Component> child : component->children) { printComponentTree(child, depth + 1); diff --git a/src/graphics/text/TextRasterizer.cpp b/src/graphics/text/TextRasterizer.cpp index dd6b83370bc84b314b9442bbc1deb7cd10ded708..eedd3193d55f5bbab10ea50f9e97c3222a9ee117 100644 --- a/src/graphics/text/TextRasterizer.cpp +++ b/src/graphics/text/TextRasterizer.cpp @@ -191,6 +191,8 @@ std::unique_ptr<Glyph[]> TextRasterizer::rasterize(const std::string &text, cons //std::cout << "starting at: " << x << std::endl; cx = wrapped ? x : 0; // reset cy = 0; + //int miny0 = 99; + int maxy0 = 0; for (unsigned int i = 0; i < glyphCount; i++) { if (FT_Load_Glyph(*face, glyphInfo[i].codepoint, FT_LOAD_DEFAULT)) { std::cout << "Could not load glyph" << std::endl; @@ -209,6 +211,9 @@ std::unique_ptr<Glyph[]> TextRasterizer::rasterize(const std::string &text, cons const float yo = static_cast<float>(glyphPos[i].y_offset) / 64; int y0 = static_cast<int>(floor(yo + slot->bitmap_top)); + //miny0 = std::min(y0, miny0); + maxy0 = std::max(y0, maxy0); + int bump = y0max - y0; // Y adjust for this glyph const float xa = static_cast<float>(glyphPos[i].x_advance) / 64; // if this char is too width for this line, advance to next line @@ -239,7 +244,10 @@ std::unique_ptr<Glyph[]> TextRasterizer::rasterize(const std::string &text, cons //std::cout << "final size: " << (int)width << "x" << (int)height << std::endl; //std::cout << "at: " << (int)line->x0 << "x" << (int)line->y0 << " to: " << (int)line->x1 << "x" << (int)line->y1 <<std::endl; endingX = cx; // maybe should be one xa less? - endingY = cy + std::ceil(1.2f * fontSize); // definitely should be one lineheight higher + //std::ceil(0.5 * 1.2f * fontSize)+2 + endingY = cy + maxy0; // definitely should be one lineheight higher + //std::cout << "miny0: " << miny0 << " maxy0: " << maxy0 << " fontsize:" << fontSize << std::endl; + //endingY += 2; // report a single glyph (since this one "glyph" represents the entire block of text) glyphCount = 1; diff --git a/src/html/HTMLParser.cpp b/src/html/HTMLParser.cpp index b711b10fc5aff6578be266f489e319be49de50f2..ca421277e1f42ec0d4223662784f17d320e43279 100644 --- a/src/html/HTMLParser.cpp +++ b/src/html/HTMLParser.cpp @@ -4,8 +4,6 @@ #include <iostream> #include <memory> -void printNode(const std::shared_ptr<Node> node, const int indent); - void printNode(const std::shared_ptr<Node> node, const int indent) { for (int i = 0; i < indent; i++) { std::cout << '\t'; diff --git a/src/html/HTMLParser.h b/src/html/HTMLParser.h index ab8bec2da8bc30f9a589905085aee1e5f32abd70..08a4af77dc8cc52443a351a98be0c26447820882 100644 --- a/src/html/HTMLParser.h +++ b/src/html/HTMLParser.h @@ -5,10 +5,12 @@ #include "TagNode.h" #include <string> +void printNode(const std::shared_ptr<Node> node, const int indent); + class HTMLParser { public: std::shared_ptr<Node> parse(const std::string &html) const; void parseTag(const std::string &element, TagNode &tagNode) const; }; -#endif \ No newline at end of file +#endif diff --git a/src/main.cpp b/src/main.cpp index 407aa9c21ad17384a3329de67e1af8e8d9c3fa23..8ebca02573ae363a8a5cf3138fb22fe7620374c3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -132,14 +132,15 @@ int main(int argc, char *argv[]) { initCLParams(argc, argv); std::cout << "/g/ntr - NetRunner build " << __DATE__ << std::endl; currentURL=argv[1]; + std::cout << "loading [" << currentURL << "]" << std::endl; WebResource res = getWebResource(currentURL); if (res.resourceType == ResourceType::INVALID) { - std::cout << "Invalid resource type" << std::endl; + std::cout << "Invalid resource type: " << res.raw << std::endl; return 1; } - const HTMLParser parser; + HTMLParser parser; const std::clock_t begin = clock(); std::shared_ptr<Node> rootNode = parser.parse(res.raw); const std::clock_t end = clock(); diff --git a/src/networking/HTTPRequest.cpp b/src/networking/HTTPRequest.cpp index 87d7d5557b58ac9be42e3b3320c8b20774ee21c5..b71941924097c3a77250943b81533206b44de694 100644 --- a/src/networking/HTTPRequest.cpp +++ b/src/networking/HTTPRequest.cpp @@ -1,13 +1,35 @@ #include "HTTPRequest.h" #include <errno.h> #include <iostream> -#include <netdb.h> #include <string.h> + +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN 1 +#include <winsock2.h> +#include <windows.h> +#include <WS2tcpip.h> +#define ssize_t intptr_t +#else +// unix includes here +#include <netdb.h> #include <sys/types.h> #include <sys/socket.h> +#endif + +#ifdef WIN32 +// Initialize Winsock +WSADATA wsaData; +int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData); +#endif HTTPRequest::HTTPRequest(const std::string &hostName, const std::string &doc) { - document = doc; +#ifdef WIN32 + if (iResult != 0) { + std::cout << "WSAStartup failed: " << iResult << std::endl; + return; + } +#endif + document = doc; version = Version::HTTP10; method = Method::GET; host = hostName; diff --git a/visualc/NetRunner.sln b/visualc/NetRunner.sln new file mode 100644 index 0000000000000000000000000000000000000000..14d27a3dbf8a1df8d4a0c3361883cd09930b5191 --- /dev/null +++ b/visualc/NetRunner.sln @@ -0,0 +1,28 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 15 +VisualStudioVersion = 15.0.26430.16 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NetRunner", "NetRunner\NetRunner.vcxproj", "{0ECC8CA1-2094-4A51-BD89-8AEC9A6B6A43}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0ECC8CA1-2094-4A51-BD89-8AEC9A6B6A43}.Debug|x64.ActiveCfg = Debug|x64 + {0ECC8CA1-2094-4A51-BD89-8AEC9A6B6A43}.Debug|x64.Build.0 = Debug|x64 + {0ECC8CA1-2094-4A51-BD89-8AEC9A6B6A43}.Debug|x86.ActiveCfg = Debug|Win32 + {0ECC8CA1-2094-4A51-BD89-8AEC9A6B6A43}.Debug|x86.Build.0 = Debug|Win32 + {0ECC8CA1-2094-4A51-BD89-8AEC9A6B6A43}.Release|x64.ActiveCfg = Release|x64 + {0ECC8CA1-2094-4A51-BD89-8AEC9A6B6A43}.Release|x64.Build.0 = Release|x64 + {0ECC8CA1-2094-4A51-BD89-8AEC9A6B6A43}.Release|x86.ActiveCfg = Release|Win32 + {0ECC8CA1-2094-4A51-BD89-8AEC9A6B6A43}.Release|x86.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/xcode/.DS_Store b/xcode/.DS_Store deleted file mode 100644 index bb2d6f7fcd64b29396d1cf5883419032628a5d13..0000000000000000000000000000000000000000 Binary files a/xcode/.DS_Store and /dev/null differ