Skip to content

Commit

Permalink
Replacing XDR macros with enum class.
Browse files Browse the repository at this point in the history
  • Loading branch information
jholloc committed Nov 5, 2024
1 parent 4904d07 commit f84b0d6
Show file tree
Hide file tree
Showing 21 changed files with 225 additions and 222 deletions.
2 changes: 1 addition & 1 deletion source/c_api/accAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3440,7 +3440,7 @@ void udaGetClientSerialisedDataBlock(int handle, void** object, size_t* objectSi
DataBlockList data_block_list;
data_block_list.count = 1;
data_block_list.data = getDataBlock(handle);
protocol2(&xdrs, ProtocolId::DataBlockList, XDR_SEND, &token, logmalloclist, userdefinedtypelist,
protocol2(&xdrs, ProtocolId::DataBlockList, XDRStreamDirection::Send, &token, logmalloclist, userdefinedtypelist,
&data_block_list, protocolVersion, log_struct_list, private_flags, malloc_source);

#ifdef _WIN32
Expand Down
4 changes: 2 additions & 2 deletions source/cache/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void writeCacheData(FILE* fp, LogMallocList* logmalloclist, UserDefinedTypeList*
DataBlockList data_block_list;
data_block_list.count = 1;
data_block_list.data = (DataBlock*)data_block;
protocol2(&xdrs, ProtocolId::DataBlockList, XDR_SEND, &token, logmalloclist, userdefinedtypelist,
protocol2(&xdrs, ProtocolId::DataBlockList, XDRStreamDirection::Send, &token, logmalloclist, userdefinedtypelist,
&data_block_list, protocolVersion, log_struct_list, private_flags, malloc_source);

xdr_destroy(&xdrs); // Destroy before the file otherwise a segmentation error occurs
Expand All @@ -35,7 +35,7 @@ DataBlock* readCacheData(FILE* fp, LogMallocList* logmalloclist, UserDefinedType
init_data_block_list(&data_block_list);

ProtocolId token;
protocol2(&xdrs, ProtocolId::DataBlockList, XDR_RECEIVE, &token, logmalloclist, userdefinedtypelist,
protocol2(&xdrs, ProtocolId::DataBlockList, XDRStreamDirection::Receive, &token, logmalloclist, userdefinedtypelist,
&data_block_list, protocolVersion, log_struct_list, private_flags, malloc_source);

xdr_destroy(&xdrs); // Destroy before the file otherwise a segmentation error occurs
Expand Down
28 changes: 14 additions & 14 deletions source/client/udaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ static int fetchHierarchicalData(XDR* client_input, DataBlock* data_block, LogSt

int err = 0;
if ((err =
protocol2(client_input, protocol_id, XDR_RECEIVE, nullptr, g_log_malloc_list, g_user_defined_type_list,
protocol2(client_input, protocol_id, XDRStreamDirection::Receive, nullptr, g_log_malloc_list, g_user_defined_type_list,
data_block, protocol_version, log_struct_list, private_flags, malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Client Side Protocol Error (Opaque Structure Type)");
return err;
Expand Down Expand Up @@ -417,39 +417,39 @@ static int fetchMeta(XDR* client_input, DataSystem* data_system, SystemConfig* s
int err = 0;

#ifndef FATCLIENT // <========================== Client Server Code Only
if ((err = protocol2(client_input, ProtocolId::DataSystem, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::DataSystem, XDRStreamDirection::Receive, nullptr, g_log_malloc_list,
g_user_defined_type_list, data_system, protocol_version, log_struct_list, private_flags,
malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 4 Error (Data System)");
return err;
}
print_data_system(*data_system);

if ((err = protocol2(client_input, ProtocolId::SystemConfig, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::SystemConfig, XDRStreamDirection::Receive, nullptr, g_log_malloc_list,
g_user_defined_type_list, system_config, protocol_version, log_struct_list, private_flags,
malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 5 Error (System Config)");
return err;
}
print_system_config(*system_config);

if ((err = protocol2(client_input, ProtocolId::DataSource, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::DataSource, XDRStreamDirection::Receive, nullptr, g_log_malloc_list,
g_user_defined_type_list, data_source, protocol_version, log_struct_list, private_flags,
malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 6 Error (Data Source)");
return err;
}
print_data_source(*data_source);

if ((err = protocol2(client_input, ProtocolId::Signal, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::Signal, XDRStreamDirection::Receive, nullptr, g_log_malloc_list,
g_user_defined_type_list, signal_rec, protocol_version, log_struct_list, private_flags,
malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 7 Error (Signal)");
return err;
}
print_signal(*signal_rec);

if ((err = protocol2(client_input, ProtocolId::SignalDesc, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::SignalDesc, XDRStreamDirection::Receive, nullptr, g_log_malloc_list,
g_user_defined_type_list, signal_desc, protocol_version, log_struct_list, private_flags,
malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 8 Error (Signal Desc)");
Expand Down Expand Up @@ -811,7 +811,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)

ProtocolId protocol_id = ProtocolId::ClientBlock; // Send Client Block (proxy for authenticationStep = 6)

if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list,
if ((err = protocol2(client_output, protocol_id, XDRStreamDirection::Send, nullptr, g_log_malloc_list,
g_user_defined_type_list, &client_block, protocol_version, &log_struct_list,
*private_flags, malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 10 Error (Client Block)");
Expand Down Expand Up @@ -839,7 +839,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)
protocol_id = ProtocolId::ServerBlock; // Receive Server Block: Server Aknowledgement (proxy for
// authenticationStep = 8)

if ((err = protocol2(client_input, protocol_id, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, protocol_id, XDRStreamDirection::Receive, nullptr, g_log_malloc_list,
g_user_defined_type_list, &server_block, protocol_version, &log_struct_list,
*private_flags, malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 11 Error (Server Block #1)");
Expand Down Expand Up @@ -933,7 +933,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)

ProtocolId protocol_id = ProtocolId::ClientBlock; // Send Client Block

if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list,
if ((err = protocol2(client_output, protocol_id, XDRStreamDirection::Send, nullptr, g_log_malloc_list, g_user_defined_type_list,
&client_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 10 Error (Client Block)");
break;
Expand All @@ -944,7 +944,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)

protocol_id = ProtocolId::RequestBlock; // This is what the Client Wants

if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list,
if ((err = protocol2(client_output, protocol_id, XDRStreamDirection::Send, nullptr, g_log_malloc_list, g_user_defined_type_list,
request_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 1 Error (Request Block)");
break;
Expand All @@ -959,7 +959,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)
if (request->put) {
protocol_id = ProtocolId::PutdataBlockList;

if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list,
if ((err = protocol2(client_output, protocol_id, XDRStreamDirection::Send, nullptr, g_log_malloc_list,
g_user_defined_type_list, &(request->putDataBlockList), protocol_version,
&log_struct_list, *private_flags, malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err,
Expand Down Expand Up @@ -994,7 +994,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)

UDA_LOG(UDA_LOG_DEBUG, "Waiting for Server Status Block");

if ((err = protocol2(client_input, ProtocolId::ServerBlock, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::ServerBlock, XDRStreamDirection::Receive, nullptr, g_log_malloc_list,
g_user_defined_type_list, &server_block, protocol_version, &log_struct_list,
*private_flags, malloc_source)) != 0) {
UDA_LOG(UDA_LOG_DEBUG, "Protocol 11 Error (Server Block #2) = {}", err);
Expand Down Expand Up @@ -1046,7 +1046,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)

DataBlockList recv_data_block_list;

if ((err = protocol2(client_input, ProtocolId::DataBlockList, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::DataBlockList, XDRStreamDirection::Receive, nullptr, g_log_malloc_list,
g_user_defined_type_list, &recv_data_block_list, protocol_version, &log_struct_list,
*private_flags, malloc_source)) != 0) {
UDA_LOG(UDA_LOG_DEBUG, "Protocol 2 Error (Failure Receiving Data Block)");
Expand Down Expand Up @@ -1589,7 +1589,7 @@ void udaFreeAll()
client_block.timeout = 0; // Surrogate CLOSEDOWN instruction
client_block.clientFlags = client_block.clientFlags | client_flags::CloseDown; // Direct CLOSEDOWN instruction
protocol_id = ProtocolId::ClientBlock;
protocol2(*g_client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list,
protocol2(*g_client_output, protocol_id, XDRStreamDirection::Send, nullptr, g_log_malloc_list, g_user_defined_type_list,
&client_block, protocol_version, g_log_struct_list, *udaPrivateFlags(), UDA_MALLOC_SOURCE_NONE);
xdrrec_endofrecord(*g_client_output, 1);
}
Expand Down
26 changes: 13 additions & 13 deletions source/client2/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,38 +217,38 @@ int uda::client::Client::fetch_meta()
Signal* signal_rec = &_metadata.signal_rec;
SignalDesc* signal_desc = &_metadata.signal_desc;

if ((err = protocol2(_client_input, ProtocolId::DataSystem, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::DataSystem, XDRStreamDirection::Receive, nullptr, _logmalloclist,
_userdefinedtypelist, data_system, _protocol_version, &_log_struct_list, _private_flags,
_malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 4 Error (Data System)");
return err;
}
print_data_system(*data_system);

if ((err = protocol2(_client_input, ProtocolId::SystemConfig, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::SystemConfig, XDRStreamDirection::Receive, nullptr, _logmalloclist,
_userdefinedtypelist, system_config, _protocol_version, &_log_struct_list, _private_flags,
_malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 5 Error (System Config)");
return err;
}
print_system_config(*system_config);

if ((err = protocol2(_client_input, ProtocolId::DataSource, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::DataSource, XDRStreamDirection::Receive, nullptr, _logmalloclist,
_userdefinedtypelist, data_source, _protocol_version, &_log_struct_list, _private_flags,
_malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 6 Error (Data Source)");
return err;
}
print_data_source(*data_source);

if ((err = protocol2(_client_input, ProtocolId::Signal, XDR_RECEIVE, nullptr, _logmalloclist, _userdefinedtypelist,
if ((err = protocol2(_client_input, ProtocolId::Signal, XDRStreamDirection::Receive, nullptr, _logmalloclist, _userdefinedtypelist,
signal_rec, _protocol_version, &_log_struct_list, _private_flags, _malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 7 Error (Signal)");
return err;
}
print_signal(*signal_rec);

if ((err = protocol2(_client_input, ProtocolId::SignalDesc, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::SignalDesc, XDRStreamDirection::Receive, nullptr, _logmalloclist,
_userdefinedtypelist, signal_desc, _protocol_version, &_log_struct_list, _private_flags,
_malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 8 Error (Signal Desc)");
Expand Down Expand Up @@ -276,7 +276,7 @@ int uda::client::Client::fetch_hierarchical_data(DataBlock* data_block)
UDA_LOG(UDA_LOG_DEBUG, "Receiving Hierarchical Data Structure from Server");

int err = 0;
if ((err = protocol2(_client_input, protocol_id, XDR_RECEIVE, nullptr, _logmalloclist, _userdefinedtypelist,
if ((err = protocol2(_client_input, protocol_id, XDRStreamDirection::Receive, nullptr, _logmalloclist, _userdefinedtypelist,
data_block, _protocol_version, &_log_struct_list, _private_flags, _malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Client Side Protocol Error (Opaque Structure Type)");
return err;
Expand Down Expand Up @@ -445,7 +445,7 @@ int uda::client::Client::get_requests(RequestBlock& request_block, int* indices)

DataBlockList recv_data_block_list;

if ((err = protocol2(_client_input, ProtocolId::DataBlockList, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::DataBlockList, XDRStreamDirection::Receive, nullptr, _logmalloclist,
_userdefinedtypelist, &recv_data_block_list, _protocol_version, &_log_struct_list,
_private_flags, _malloc_source)) != 0) {
UDA_LOG(UDA_LOG_DEBUG, "Protocol 2 Error (Failure Receiving Data Block)");
Expand Down Expand Up @@ -586,7 +586,7 @@ int uda::client::Client::send_putdata(const RequestBlock& request_block)
if (request->put) {
ProtocolId protocol_id = ProtocolId::PutdataBlockList;
int err = 0;
if ((err = protocol2(_client_output, protocol_id, XDR_SEND, nullptr, _logmalloclist, _userdefinedtypelist,
if ((err = protocol2(_client_output, protocol_id, XDRStreamDirection::Send, nullptr, _logmalloclist, _userdefinedtypelist,
&(request->putDataBlockList), _protocol_version, &_log_struct_list, _private_flags,
_malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err,
Expand Down Expand Up @@ -715,7 +715,7 @@ int uda::client::Client::send_request_block(RequestBlock& request_block)
{
ProtocolId protocol_id = ProtocolId::RequestBlock; // This is what the Client Wants
int err = 0;
if ((err = protocol2(_client_output, protocol_id, XDR_SEND, nullptr, _logmalloclist, _userdefinedtypelist,
if ((err = protocol2(_client_output, protocol_id, XDRStreamDirection::Send, nullptr, _logmalloclist, _userdefinedtypelist,
&request_block, _protocol_version, &_log_struct_list, _private_flags, _malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 1 Error (Request Block)");
throw uda::exceptions::ClientError("Protocol 1 Error (Request Block)");
Expand All @@ -728,7 +728,7 @@ int uda::client::Client::send_client_block()
{
ProtocolId protocol_id = ProtocolId::ClientBlock; // Send Client Block
int err = 0;
if ((err = protocol2(_client_output, protocol_id, XDR_SEND, nullptr, _logmalloclist, _userdefinedtypelist,
if ((err = protocol2(_client_output, protocol_id, XDRStreamDirection::Send, nullptr, _logmalloclist, _userdefinedtypelist,
&_client_block, _protocol_version, &_log_struct_list, _private_flags, _malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 10 Error (Client Block)");
throw uda::exceptions::ClientError("Protocol 10 Error (Client Block)");
Expand All @@ -744,7 +744,7 @@ int uda::client::Client::perform_handshake()
ProtocolId protocol_id = ProtocolId::ClientBlock; // Send Client Block (proxy for authenticationStep = 6)

int err = 0;
if ((err = protocol2(_client_output, protocol_id, XDR_SEND, nullptr, _logmalloclist, _userdefinedtypelist,
if ((err = protocol2(_client_output, protocol_id, XDRStreamDirection::Send, nullptr, _logmalloclist, _userdefinedtypelist,
&_client_block, _protocol_version, &_log_struct_list, _private_flags, _malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 10 Error (Client Block)");
UDA_LOG(UDA_LOG_DEBUG, "Error Sending Client Block");
Expand All @@ -771,7 +771,7 @@ int uda::client::Client::perform_handshake()
protocol_id =
ProtocolId::ServerBlock; // Receive Server Block: Server Aknowledgement (proxy for authenticationStep = 8)

if ((err = protocol2(_client_input, protocol_id, XDR_RECEIVE, nullptr, _logmalloclist, _userdefinedtypelist,
if ((err = protocol2(_client_input, protocol_id, XDRStreamDirection::Receive, nullptr, _logmalloclist, _userdefinedtypelist,
&_server_block, _protocol_version, &_log_struct_list, _private_flags, _malloc_source)) != 0) {
add_error(ErrorType::Code, __func__, err, "Protocol 11 Error (Server Block #1)");
// Assuming the server_block is corrupted, replace with a clean copy to avoid concatonation problems
Expand Down Expand Up @@ -834,7 +834,7 @@ int uda::client::Client::receive_server_block()
UDA_LOG(UDA_LOG_DEBUG, "Waiting for Server Status Block");

int err = 0;
if ((err = protocol2(_client_input, ProtocolId::ServerBlock, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::ServerBlock, XDRStreamDirection::Receive, nullptr, _logmalloclist,
_userdefinedtypelist, &_server_block, _protocol_version, &_log_struct_list, _private_flags,
_malloc_source)) != 0) {
UDA_LOG(UDA_LOG_DEBUG, "Protocol 11 Error (Server Block #2) = {}", err);
Expand Down
Loading

0 comments on commit f84b0d6

Please sign in to comment.