mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:25:52 +02:00
include string for memset and strcpy, use fscanf returns
This commit is contained in:
parent
b9dafbe5bd
commit
3b8bd83c01
1 changed files with 5 additions and 3 deletions
|
@ -9,6 +9,8 @@
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "TreeNode.h"
|
#include "TreeNode.h"
|
||||||
#include "UDPSocket.h"
|
#include "UDPSocket.h"
|
||||||
|
|
||||||
|
@ -93,13 +95,13 @@ bool loadSpaceData(void) {
|
||||||
// pull as many bits as are left
|
// pull as many bits as are left
|
||||||
int goodBits = 8 - paddingBits;
|
int goodBits = 8 - paddingBits;
|
||||||
sprintf(formatString, "%%%dc", goodBits);
|
sprintf(formatString, "%%%dc", goodBits);
|
||||||
fscanf(configFile, formatString, fullByteBitString);
|
itemsRead = fscanf(configFile, formatString, fullByteBitString);
|
||||||
|
|
||||||
// fill out the rest with zeros
|
// fill out the rest with zeros
|
||||||
memset(fullByteBitString + goodBits, '0', paddingBits);
|
memset(fullByteBitString + goodBits, '0', paddingBits);
|
||||||
} else {
|
} else {
|
||||||
// pull 8 bits (which will be one byte) from the file
|
// 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
|
// set the corresponding value in the unsigned char array
|
||||||
|
@ -108,7 +110,7 @@ bool loadSpaceData(void) {
|
||||||
|
|
||||||
char *nodeHostname = new char[MAX_NAME_LENGTH];
|
char *nodeHostname = new char[MAX_NAME_LENGTH];
|
||||||
char *nodeNickname = 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);
|
findOrCreateNode(bitsInAddress, paddedAddress, nodeHostname, nodeNickname, 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue