From 2141b2f238ea098c63b7bb1b51706e9e701453b9 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Thu, 4 Apr 2019 10:16:23 -0700 Subject: [PATCH] changed proc names for better isolation --- DPlusAuthenticator.cpp | 14 +++++++------- TCPReaderWriterClient.cpp | 30 +++++++++++++++--------------- TCPReaderWriterClient.h | 16 ++++++++-------- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/DPlusAuthenticator.cpp b/DPlusAuthenticator.cpp index 4734cdf..4afed65 100644 --- a/DPlusAuthenticator.cpp +++ b/DPlusAuthenticator.cpp @@ -46,7 +46,7 @@ CDPlusAuthenticator::~CDPlusAuthenticator() bool CDPlusAuthenticator::Process(std::map &gwy_map, const bool reflectors, const bool repeaters) // return true if everything went okay { - int result = client.open(m_address, AF_UNSPEC, "20001"); + int result = client.Open(m_address, AF_UNSPEC, "20001"); if (result) { fprintf(stderr, "DPlus Authorization failed: %s\n", gai_strerror(result)); return true; @@ -69,21 +69,21 @@ bool CDPlusAuthenticator::authenticate(const std::string &callsign, std::map ret) { fprintf(stderr, "Problem reading line, it returned %d\n", errno); return true; @@ -114,12 +114,12 @@ bool CDPlusAuthenticator::authenticate(const std::string &callsign, std::mapai_addr, rp->ai_addrlen)) { - close(); + Close(); continue; } else { char buf[INET6_ADDRSTRLEN]; @@ -113,22 +113,22 @@ bool CTCPReaderWriterClient::open() return false; } -int readExact(unsigned char *buf, unsigned int length) +int CTCPReaderWriterClient::ReadExact(unsigned char *buf, const unsigned int length) { unsigned int offset = 0U; do { - int n = socket.read(buffer + offset, len - offset, 10U); + int n = Read(buf + offset, length - offset); if (n < 0) return n; offset += n; - } while ((len - offset) > 0U); + } while ((length - offset) > 0U); return true; } -int CTCPReaderWriterClient::read(unsigned char* buffer, unsigned int length) +int CTCPReaderWriterClient::Read(unsigned char* buffer, const unsigned int length) { assert(buffer != NULL); assert(length > 0U); @@ -159,7 +159,7 @@ int CTCPReaderWriterClient::read(unsigned char* buffer, unsigned int length) return len; } -int CTCPReaderWriterClient::readLine(std::string& line) +int CTCPReaderWriterClient::ReadLine(std::string& line) { //maybe there is a better way to do this like reading blocks, pushing them for later calls //Nevermind, we'll read one char at a time for the time being. @@ -170,7 +170,7 @@ int CTCPReaderWriterClient::readLine(std::string& line) do { - resultCode = read(&c, 1); + resultCode = Read(&c, 1); if(resultCode == 1) { line += c; len++; @@ -180,7 +180,7 @@ int CTCPReaderWriterClient::readLine(std::string& line) return resultCode <= 0 ? resultCode : len; } -bool CTCPReaderWriterClient::write(const unsigned char* buffer, unsigned int length) +bool CTCPReaderWriterClient::Write(const unsigned char* buffer, const unsigned int length) { assert(buffer != NULL); assert(length > 0U); @@ -198,7 +198,7 @@ bool CTCPReaderWriterClient::write(const unsigned char* buffer, unsigned int len return false; } -bool CTCPReaderWriterClient::writeLine(const std::string& line) +bool CTCPReaderWriterClient::WriteLine(const std::string& line) { std::string lineCopy(line); if(lineCopy.size() > 0 && lineCopy.at(lineCopy.size() - 1) != '\n') @@ -208,16 +208,16 @@ bool CTCPReaderWriterClient::writeLine(const std::string& line) bool result = true; for(size_t i = 0; i < len && result; i++){ unsigned char c = lineCopy.at(i); - result = write(&c , 1); + result = Write(&c , 1); } return result; } -void CTCPReaderWriterClient::close() +void CTCPReaderWriterClient::Close() { if (m_fd != -1) { - ::close(m_fd); + close(m_fd); m_fd = -1; } } diff --git a/TCPReaderWriterClient.h b/TCPReaderWriterClient.h index b5205c5..0aed516 100644 --- a/TCPReaderWriterClient.h +++ b/TCPReaderWriterClient.h @@ -39,17 +39,17 @@ public: CTCPReaderWriterClient(); ~CTCPReaderWriterClient(); - bool open(const std::string &address, int family, const std::string &port); - bool open(); + bool Open(const std::string &address, int family, const std::string &port); + bool Open(); - int readExact(unsigned char *buf, unsigned int length); - int read(unsigned char *buffer, unsigned int length); - int readLine(std::string &line); - bool write(const unsigned char* buffer, unsigned int length); - bool writeLine(const std::string &line); + int ReadExact(unsigned char *buffer, const unsigned int length); + int Read(unsigned char *buffer, const unsigned int length); + int ReadLine(std::string &line); + bool Write(const unsigned char* buffer, const unsigned int length); + bool WriteLine(const std::string &line); int GetFD() { return m_fd; } - void close(); + void Close(); private: std::string m_address;