Skip to content

Commit

Permalink
Removing macros from protocol.h
Browse files Browse the repository at this point in the history
  • Loading branch information
jholloc committed Oct 28, 2024
1 parent 9bee1b7 commit f2af1a6
Show file tree
Hide file tree
Showing 29 changed files with 290 additions and 266 deletions.
4 changes: 2 additions & 2 deletions source/c_api/accAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3433,14 +3433,14 @@ void udaGetClientSerialisedDataBlock(int handle, void** object, size_t* objectSi
XDR xdrs;
xdrstdio_create(&xdrs, memfile, XDR_ENCODE);

int token;
ProtocolId token;

auto userdefinedtypelist = static_cast<UserDefinedTypeList*>(udaGetUserDefinedTypeList(handle));
auto logmalloclist = static_cast<LogMallocList*>(udaGetLogMallocList(handle));
DataBlockList data_block_list;
data_block_list.count = 1;
data_block_list.data = getDataBlock(handle);
protocol2(&xdrs, UDA_PROTOCOL_DATA_BLOCK_LIST, XDR_SEND, &token, logmalloclist, userdefinedtypelist,
protocol2(&xdrs, ProtocolId::DataBlockList, XDR_SEND, &token, logmalloclist, userdefinedtypelist,
&data_block_list, protocolVersion, log_struct_list, private_flags, malloc_source);

#ifdef _WIN32
Expand Down
8 changes: 4 additions & 4 deletions source/cache/cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ void writeCacheData(FILE* fp, LogMallocList* logmalloclist, UserDefinedTypeList*
XDR xdrs;
xdrstdio_create(&xdrs, fp, XDR_ENCODE);

int token;
ProtocolId token;
DataBlockList data_block_list;
data_block_list.count = 1;
data_block_list.data = (DataBlock*)data_block;
protocol2(&xdrs, UDA_PROTOCOL_DATA_BLOCK_LIST, XDR_SEND, &token, logmalloclist, userdefinedtypelist,
protocol2(&xdrs, ProtocolId::DataBlockList, XDR_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 @@ -34,8 +34,8 @@ DataBlock* readCacheData(FILE* fp, LogMallocList* logmalloclist, UserDefinedType
DataBlockList data_block_list;
init_data_block_list(&data_block_list);

int token;
protocol2(&xdrs, UDA_PROTOCOL_DATA_BLOCK_LIST, XDR_RECEIVE, &token, logmalloclist, userdefinedtypelist,
ProtocolId token;
protocol2(&xdrs, ProtocolId::DataBlockList, XDR_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
4 changes: 2 additions & 2 deletions source/client/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int uda::client::reconnect(config::Config& config, XDR** client_input, XDR** cli
auto host = config.get("connection.host").as_or_default(""s);
auto port = config.get("connection.port").as_or_default(56565);

if (get_socket(&client_socketlist, TYPE_UDA_SERVER, &status, host, port, &fh) == 0) {
if (get_socket(&client_socketlist, SocketType::UDA, &status, host, port, &fh) == 0) {
config.set("connection.socket", fh);
config.set("connection.change_socket", true);
} else {
Expand Down Expand Up @@ -583,7 +583,7 @@ int uda::client::createConnection(XDR* client_input, XDR* client_output, time_t*
config_port = config->get("connection.port").as_or_default(0);

// Add New Socket to the Socket's List
add_socket(&client_socketlist, TYPE_UDA_SERVER, 1, config_host, config_port,
add_socket(&client_socketlist, SocketType::UDA, 1, config_host, config_port,
client_socket);
client_socketlist.sockets[get_socket_record_id(&client_socketlist, client_socket)].Input = client_input;
client_socketlist.sockets[get_socket_record_id(&client_socketlist, client_socket)].Output = client_output;
Expand Down
36 changes: 17 additions & 19 deletions source/client/udaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,15 +364,13 @@ static int fetchHierarchicalData(XDR* client_input, DataBlock* data_block, LogSt
{
if (data_block->data_type == UDA_TYPE_COMPOUND && data_block->opaque_type != UDA_OPAQUE_TYPE_UNKNOWN) {

int protocol_id;
ProtocolId protocol_id = ProtocolId::Start;
if (data_block->opaque_type == UDA_OPAQUE_TYPE_XML_DOCUMENT) {
protocol_id = UDA_PROTOCOL_META;
protocol_id = ProtocolId::Meta;
} else if (data_block->opaque_type == UDA_OPAQUE_TYPE_STRUCTURES ||
data_block->opaque_type == UDA_OPAQUE_TYPE_XDRFILE ||
data_block->opaque_type == UDA_OPAQUE_TYPE_XDROBJECT) {
protocol_id = UDA_PROTOCOL_STRUCTURES;
} else {
protocol_id = UDA_PROTOCOL_EFIT;
protocol_id = ProtocolId::Structures;
}

UDA_LOG(UDA_LOG_DEBUG, "Receiving Hierarchical Data Structure from Server");
Expand Down Expand Up @@ -419,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, UDA_PROTOCOL_DATA_SYSTEM, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::DataSystem, XDR_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, UDA_PROTOCOL_SYSTEM_CONFIG, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::SystemConfig, XDR_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, UDA_PROTOCOL_DATA_SOURCE, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::DataSource, XDR_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, UDA_PROTOCOL_SIGNAL, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::Signal, XDR_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, UDA_PROTOCOL_SIGNAL_DESC, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::SignalDesc, XDR_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 +809,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)

// Flush (mark as at EOF) the input socket buffer (before the exchange begins)

int protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; // Send Client Block (proxy for authenticationStep = 6)
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,
g_user_defined_type_list, &client_block, protocol_version, &log_struct_list,
Expand All @@ -838,7 +836,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)
break;
}

protocol_id = UDA_PROTOCOL_SERVER_BLOCK; // Receive Server Block: Server Aknowledgement (proxy for
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,
Expand Down Expand Up @@ -933,7 +931,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)
//-------------------------------------------------------------------------
// Send the Client Block

int protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; // Send Client Block
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,
&client_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) {
Expand All @@ -944,7 +942,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)
//-------------------------------------------------------------------------
// Send the Client Request

protocol_id = UDA_PROTOCOL_REQUEST_BLOCK; // This is what the Client Wants
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,
request_block, protocol_version, &log_struct_list, *private_flags, malloc_source)) != 0) {
Expand All @@ -959,7 +957,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)
RequestData* request = &request_block->requests[i];

if (request->put) {
protocol_id = UDA_PROTOCOL_PUTDATA_BLOCK_LIST;
protocol_id = ProtocolId::PutdataBlockList;

if ((err = protocol2(client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list,
g_user_defined_type_list, &(request->putDataBlockList), protocol_version,
Expand Down Expand Up @@ -996,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, UDA_PROTOCOL_SERVER_BLOCK, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::ServerBlock, XDR_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 @@ -1048,7 +1046,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)

DataBlockList recv_data_block_list;

if ((err = protocol2(client_input, UDA_PROTOCOL_DATA_BLOCK_LIST, XDR_RECEIVE, nullptr, g_log_malloc_list,
if ((err = protocol2(client_input, ProtocolId::DataBlockList, XDR_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 @@ -1555,7 +1553,7 @@ void udaFreeAll()
{
// Free All Heap Memory
#ifndef FATCLIENT
int protocol_id;
ProtocolId protocol_id;
#endif

#ifndef NOLIBMEMCACHED
Expand Down Expand Up @@ -1590,7 +1588,7 @@ void udaFreeAll()
if (connectionOpen()) {
client_block.timeout = 0; // Surrogate CLOSEDOWN instruction
client_block.clientFlags = client_block.clientFlags | CLIENTFLAG_CLOSEDOWN; // Direct CLOSEDOWN instruction
protocol_id = UDA_PROTOCOL_CLIENT_BLOCK;
protocol_id = ProtocolId::ClientBlock;
protocol2(*g_client_output, protocol_id, XDR_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
32 changes: 15 additions & 17 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, UDA_PROTOCOL_DATA_SYSTEM, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::DataSystem, XDR_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, UDA_PROTOCOL_SYSTEM_CONFIG, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::SystemConfig, XDR_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, UDA_PROTOCOL_DATA_SOURCE, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::DataSource, XDR_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, UDA_PROTOCOL_SIGNAL, XDR_RECEIVE, nullptr, _logmalloclist, _userdefinedtypelist,
if ((err = protocol2(_client_input, ProtocolId::Signal, XDR_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, UDA_PROTOCOL_SIGNAL_DESC, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::SignalDesc, XDR_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 All @@ -264,15 +264,13 @@ int uda::client::Client::fetch_hierarchical_data(DataBlock* data_block)
{
if (data_block->data_type == UDA_TYPE_COMPOUND && data_block->opaque_type != UDA_OPAQUE_TYPE_UNKNOWN) {

int protocol_id;
ProtocolId protocol_id = ProtocolId::Start;
if (data_block->opaque_type == UDA_OPAQUE_TYPE_XML_DOCUMENT) {
protocol_id = UDA_PROTOCOL_META;
protocol_id = ProtocolId::Meta;
} else if (data_block->opaque_type == UDA_OPAQUE_TYPE_STRUCTURES ||
data_block->opaque_type == UDA_OPAQUE_TYPE_XDRFILE ||
data_block->opaque_type == UDA_OPAQUE_TYPE_XDROBJECT) {
protocol_id = UDA_PROTOCOL_STRUCTURES;
} else {
protocol_id = UDA_PROTOCOL_EFIT;
protocol_id = ProtocolId::Structures;
}

UDA_LOG(UDA_LOG_DEBUG, "Receiving Hierarchical Data Structure from Server");
Expand Down Expand Up @@ -447,7 +445,7 @@ int uda::client::Client::get_requests(RequestBlock& request_block, int* indices)

DataBlockList recv_data_block_list;

if ((err = protocol2(_client_input, UDA_PROTOCOL_DATA_BLOCK_LIST, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::DataBlockList, XDR_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 +584,7 @@ int uda::client::Client::send_putdata(const RequestBlock& request_block)
RequestData* request = &request_block.requests[i];

if (request->put) {
int protocol_id = UDA_PROTOCOL_PUTDATA_BLOCK_LIST;
ProtocolId protocol_id = ProtocolId::PutdataBlockList;
int err = 0;
if ((err = protocol2(_client_output, protocol_id, XDR_SEND, nullptr, _logmalloclist, _userdefinedtypelist,
&(request->putDataBlockList), _protocol_version, &_log_struct_list, _private_flags,
Expand Down Expand Up @@ -715,7 +713,7 @@ int uda::client::Client::test_connection()

int uda::client::Client::send_request_block(RequestBlock& request_block)
{
int protocol_id = UDA_PROTOCOL_REQUEST_BLOCK; // This is what the Client Wants
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,
&request_block, _protocol_version, &_log_struct_list, _private_flags, _malloc_source)) != 0) {
Expand All @@ -728,7 +726,7 @@ int uda::client::Client::send_request_block(RequestBlock& request_block)

int uda::client::Client::send_client_block()
{
int protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; // 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,
&_client_block, _protocol_version, &_log_struct_list, _private_flags, _malloc_source)) != 0) {
Expand All @@ -743,7 +741,7 @@ int uda::client::Client::perform_handshake()
{
// Flush (mark as at EOF) the input socket buffer (before the exchange begins)

int protocol_id = UDA_PROTOCOL_CLIENT_BLOCK; // Send Client Block (proxy for authenticationStep = 6)
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,
Expand Down Expand Up @@ -771,7 +769,7 @@ int uda::client::Client::perform_handshake()
}

protocol_id =
UDA_PROTOCOL_SERVER_BLOCK; // Receive Server Block: Server Aknowledgement (proxy for authenticationStep = 8)
ProtocolId::ServerBlock; // Receive Server Block: Server Aknowledgement (proxy for authenticationStep = 8)

if ((err = protocol2(_client_input, protocol_id, XDR_RECEIVE, nullptr, _logmalloclist, _userdefinedtypelist,
&_server_block, _protocol_version, &_log_struct_list, _private_flags, _malloc_source)) != 0) {
Expand Down Expand Up @@ -836,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, UDA_PROTOCOL_SERVER_BLOCK, XDR_RECEIVE, nullptr, _logmalloclist,
if ((err = protocol2(_client_input, ProtocolId::ServerBlock, XDR_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 f2af1a6

Please sign in to comment.