From 216e671fa012f50890e31620d7df5819f562384a Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 18 Feb 2013 17:08:08 -0800 Subject: [PATCH 1/4] bump MAX_NAME_LENGTH to 255 --- space/src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/space/src/main.cpp b/space/src/main.cpp index 9a6033bdac..1b8a22732b 100644 --- a/space/src/main.cpp +++ b/space/src/main.cpp @@ -12,7 +12,7 @@ const char *CONFIG_FILE = "/Users/birarda/code/worklist/checkouts/hifi/space/example.data.txt"; const unsigned short SPACE_LISTENING_PORT = 55551; -const short MAX_NAME_LENGTH = 63; +const short MAX_NAME_LENGTH = 255; const char ROOT_HOSTNAME[] = "root.highfidelity.co"; const char ROOT_NICKNAME[] = "root"; From 6d4a0b82ceef77b1dcef72de2f33c9a77548f104 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 18 Feb 2013 17:10:41 -0800 Subject: [PATCH 2/4] include cstdio for UNIX build --- space/src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/space/src/main.cpp b/space/src/main.cpp index 1b8a22732b..4f4ae82db2 100644 --- a/space/src/main.cpp +++ b/space/src/main.cpp @@ -7,6 +7,7 @@ // #include +#include #include "TreeNode.h" #include "UDPSocket.h" From b9dafbe5bdde4cc6e077341fda2c5a7433772c2b Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 18 Feb 2013 17:12:09 -0800 Subject: [PATCH 3/4] include stdlib for use of strtoul --- space/src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/space/src/main.cpp b/space/src/main.cpp index 4f4ae82db2..d88c4fd004 100644 --- a/space/src/main.cpp +++ b/space/src/main.cpp @@ -8,6 +8,7 @@ #include #include +#include #include "TreeNode.h" #include "UDPSocket.h" From 3b8bd83c014f9e62dc9db4dd697728b68f1195ec Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 18 Feb 2013 17:14:35 -0800 Subject: [PATCH 4/4] include string for memset and strcpy, use fscanf returns --- space/src/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/space/src/main.cpp b/space/src/main.cpp index d88c4fd004..a3ea710357 100644 --- a/space/src/main.cpp +++ b/space/src/main.cpp @@ -9,6 +9,8 @@ #include #include #include +#include + #include "TreeNode.h" #include "UDPSocket.h" @@ -93,13 +95,13 @@ bool loadSpaceData(void) { // pull as many bits as are left int goodBits = 8 - paddingBits; sprintf(formatString, "%%%dc", goodBits); - fscanf(configFile, formatString, fullByteBitString); + itemsRead = fscanf(configFile, formatString, fullByteBitString); // fill out the rest with zeros memset(fullByteBitString + goodBits, '0', paddingBits); } else { // pull 8 bits (which will be one byte) from the file - fscanf(configFile, "%8c", fullByteBitString); + itemsRead = fscanf(configFile, "%8c", fullByteBitString); } // set the corresponding value in the unsigned char array @@ -108,7 +110,7 @@ bool loadSpaceData(void) { char *nodeHostname = new char[MAX_NAME_LENGTH]; char *nodeNickname = new char[MAX_NAME_LENGTH]; - fscanf(configFile, "%s %s\n", nodeHostname, nodeNickname); + itemsRead = fscanf(configFile, "%s %s\n", nodeHostname, nodeNickname); findOrCreateNode(bitsInAddress, paddedAddress, nodeHostname, nodeNickname, 0); }