Skip to content

Commit

Permalink
Removing last macros from client_server code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jholloc committed Nov 5, 2024
1 parent 939b1cb commit be0c858
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 22 deletions.
3 changes: 0 additions & 3 deletions source/clientserver/makeRequestBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@
# define chdir _chdir
#endif

#define MAXMAPDEPTH 10 // Maximum number of chained signal name mappings (Recursive depth)
#define MAXREQDEPTH 4 // Maximum number of Device Name to Server Protocol and Host substitution

using namespace uda::client_server;
using namespace uda::logging;

Expand Down
13 changes: 10 additions & 3 deletions source/clientserver/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,19 @@ using namespace uda::client_server;
using namespace uda::logging;
using namespace uda::structures;

namespace {

constexpr int MinBlockTime = 1000;
constexpr int MaxBlockTime = 10000;

} // anon namespace

void uda::client_server::set_select_params(int fd, fd_set* rfds, struct timeval* tv, int* server_tot_block_time)
{
FD_ZERO(rfds); // Initialise the File Descriptor set
FD_SET(fd, rfds); // Identify the Socket in the FD set
tv->tv_sec = 0;
tv->tv_usec = MIN_BLOCK_TIME; // minimum wait microsecs (1ms)
tv->tv_usec = MinBlockTime; // minimum wait microsecs (1ms)
*server_tot_block_time = 0;
}

Expand All @@ -58,10 +65,10 @@ void uda::client_server::update_select_params(int fd, fd_set* rfds, struct timev
if (server_tot_block_time < MaxBlock) {
// (ms) For the First blocking period have rapid response (clientserver/udaDefines.h == 1000)
tv->tv_sec = 0;
tv->tv_usec = MIN_BLOCK_TIME; // minimum wait (1ms)
tv->tv_usec = MinBlockTime; // minimum wait (1ms)
} else {
tv->tv_sec = 0;
tv->tv_usec = MAX_BLOCK_TIME; // maximum wait (10ms)
tv->tv_usec = MaxBlockTime; // maximum wait (10ms)
}
}

Expand Down
3 changes: 0 additions & 3 deletions source/clientserver/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ inline std::string format_as(ProtocolId protocol)

}

#define MIN_BLOCK_TIME 1000
#define MAX_BLOCK_TIME 10000

//---------------------------------------------------------------------------------------------------
// Client Server XDR data Streams (DON'T CHANGE ORDER or Legacy client won't work!)

Expand Down
22 changes: 9 additions & 13 deletions source/clientserver/protocolXML2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@
#include <fmt/format.h>
#include <openssl/sha.h>

#define PARTBLOCKINIT 1
#define PARTBLOCKUPDATE 2
#define PARTBLOCKOUTPUT 3

using namespace uda::client_server;
using namespace uda::structures;
using namespace uda::logging;
Expand All @@ -95,7 +91,7 @@ void sha1Block(unsigned char* block, size_t blockSize, unsigned char* md);
int sha1File(char* name, FILE* fh, unsigned char* md);
}

#define MAX_ELEMENT_SHA1 20
constexpr int MaxElementSha1 = 20;

int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, XDRStreamDirection direction, ProtocolId* token,
LogMallocList* logmalloclist, UserDefinedTypeList* userdefinedtypelist, void* str,
Expand All @@ -118,11 +114,11 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, XDRStre
std::string temp_file = "/tmp/idamXDRXXXXXX";
char* env = nullptr;

unsigned char md[MAX_ELEMENT_SHA1 + 1]; // SHA1 Hash
md[MAX_ELEMENT_SHA1] = '\0';
unsigned char md[MaxElementSha1 + 1]; // SHA1 Hash
md[MaxElementSha1] = '\0';
strcpy((char*)md, "12345678901234567890");
int hashSize = MAX_ELEMENT_SHA1;
unsigned char mdr[MAX_ELEMENT_SHA1]; // SHA1 Hash of data received
int hashSize = MaxElementSha1;
unsigned char mdr[MaxElementSha1]; // SHA1 Hash of data received

if ((private_flags & private_flags::XdrFile) && protocolVersion >= 5) { // Intermediate XDR File, not stream
if ((env = getenv("UDA_WORK_DIR")) != nullptr) {
Expand Down Expand Up @@ -594,7 +590,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, XDRStre
// Check the hash
sha1Block(object, objectSize, mdr);
rc = 1;
for (int i = 0; i < MAX_ELEMENT_SHA1; i++) {
for (int i = 0; i < MaxElementSha1; i++) {
rc = rc && (md[i] == mdr[i]);
}
if (!rc) {
Expand Down Expand Up @@ -678,7 +674,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, XDRStre
// Check the hash
sha1Block(object, objectSize, mdr);
rc = 1;
for (int i = 0; i < MAX_ELEMENT_SHA1; i++) {
for (int i = 0; i < MaxElementSha1; i++) {
rc = rc && (md[i] == mdr[i]);
}
if (!rc) {
Expand Down Expand Up @@ -831,7 +827,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, XDRStre
// Check the hash
sha1Block(object, objectSize, mdr);
rc = 1;
for (int i = 0; i < MAX_ELEMENT_SHA1; i++) {
for (int i = 0; i < MaxElementSha1; i++) {
rc = rc && (md[i] == mdr[i]);
}
if (!rc) {
Expand All @@ -858,7 +854,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, XDRStre
// Check the hash
sha1Block(object, objectSize, mdr);
rc = 1;
for (int i = 0; i < MAX_ELEMENT_SHA1; i++) {
for (int i = 0; i < MaxElementSha1; i++) {
rc = rc && (md[i] == mdr[i]);
}
if (!rc) {
Expand Down

0 comments on commit be0c858

Please sign in to comment.