Skip to content

Commit

Permalink
Replacing REQUEST macros with enum
Browse files Browse the repository at this point in the history
  • Loading branch information
jholloc committed Oct 28, 2024
1 parent f2af1a6 commit d6fefc6
Show file tree
Hide file tree
Showing 25 changed files with 228 additions and 284 deletions.
2 changes: 1 addition & 1 deletion source/c_api/udaPutAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ int udaPutAPI(const char* putInstruction, PUTDATA_BLOCK* inPutData)
//-------------------------------------------------------------------------
// Free Heap

freeClientPutDataBlockList(&request_block.requests[0].putDataBlockList);
free_client_put_data_block_list(&request_block.requests[0].putDataBlockList);

return handle;
}
2 changes: 1 addition & 1 deletion source/client/makeClientRequestBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void uda::client::freeClientRequestBlock(RequestBlock* request_block)
if (request_block != nullptr && request_block->requests != nullptr) {
for (int i = 0; i < request_block->num_requests; i++) {
free_name_value_list(&request_block->requests[i].nameValueList);
freeClientPutDataBlockList(&request_block->requests[i].putDataBlockList);
free_client_put_data_block_list(&request_block->requests[i].putDataBlockList);
}
free(request_block->requests);
request_block->requests = nullptr;
Expand Down
14 changes: 7 additions & 7 deletions source/client/udaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ int getCurrentDataBlockIndex()
return data_blocks.size() - 1;
}

void freeDataBlocks()
void free_data_blocks()
{
data_blocks.clear();
udaPutThreadLastHandle(-1);
Expand Down Expand Up @@ -576,14 +576,14 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)
int rc = check_file_cache(request, &data_block, g_log_malloc_list, g_user_defined_type_list,
&log_struct_list, client_flags, *private_flags, malloc_source);
if (rc >= 0) {
request_block->requests[i].request = REQUEST_CACHED;
request_block->requests[i].request = Request::Cached;
++num_cached;
continue;
}
rc = check_mem_cache(cache, request, &data_block, g_log_malloc_list, g_user_defined_type_list,
&log_struct_list, client_flags, *private_flags, malloc_source);
if (rc >= 0) {
request_block->requests[i].request = REQUEST_CACHED;
request_block->requests[i].request = Request::Cached;
++num_cached;
continue;
}
Expand Down Expand Up @@ -1073,7 +1073,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices)
DataBlock* data_block = getDataBlock(data_block_idx);

// DataBlock* in_data;
// if (request_block->requests[i].request == REQUEST_CACHED) {
// if (request_block->requests[i].request == Request::Cached) {
// in_data = &cached_data_block_list.data[i];
// } else {
// in_data = &recv_data_block_list.data[recv_idx];
Expand Down Expand Up @@ -1563,13 +1563,13 @@ void udaFreeAll()

for (int i = 0; i < getCurrentDataBlockIndex(); ++i) {
#ifndef FATCLIENT
freeDataBlock(getDataBlock(i));
free_data_block(getDataBlock(i));
#else
freeDataBlock(getDataBlock(i));
free_data_block(getDataBlock(i));
#endif
}

freeDataBlocks();
free_data_blocks();

#ifndef FATCLIENT
g_user_defined_type_list = nullptr; // malloc'd within protocolXML
Expand Down
2 changes: 1 addition & 1 deletion source/client2/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ int uda::client::Client::put(std::string_view put_instruction, uda::client_serve
std::vector<int> indices(request_block.num_requests);
get_requests(request_block, indices.data());

freeClientPutDataBlockList(&request_block.requests[0].putDataBlockList);
free_client_put_data_block_list(&request_block.requests[0].putDataBlockList);

return indices[0];
}
Expand Down
34 changes: 17 additions & 17 deletions source/clientserver/makeRequestBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
//------------------------------------------------------------------------------
// Start with ignorance about which plugin to use

request->request = REQUEST_READ_UNKNOWN;
request->request = (int)Request::ReadUnknown;

//------------------------------------------------------------------------------
// Check there is something to work with!
Expand Down Expand Up @@ -142,7 +142,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
bool is_proxy = config.get("server.is_proxy").as_or_default(false);

if (is_proxy) {
request->request = REQUEST_READ_IDAM;
request->request = (int)Request::ReadUDA;
}

//==============================================================================
Expand Down Expand Up @@ -304,7 +304,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
left_trim_string(work2);
trim_string(work2);

request->request = REQUEST_READ_SERVERSIDE;
request->request = (int)Request::ReadServerside;
extract_function_name(work, request);

UDA_LOG(UDA_LOG_DEBUG, "**** Server Side Function ??? ****")
Expand Down Expand Up @@ -379,11 +379,11 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
// configuration file. The request must be a generic lookup of how to access data remotely for the specified
// device. The external server providing access to the foreign device's data will interpret the arguments

if (request->request == REQUEST_READ_UNKNOWN) {
if (request->request == (int)Request::ReadUnknown) {
UDA_LOG(UDA_LOG_DEBUG, "No plugin was identified for the format: {}", work2)
is_foreign = true;
strcpy(request->device_name, work2); // Copy the DEVICE prefix
request->request = REQUEST_READ_GENERIC; // The database will identify the target
request->request = (int)Request::ReadGeneric; // The database will identify the target

break;
}
Expand Down Expand Up @@ -499,7 +499,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
// server) the Plugin Name is synonymous with the Archive Name and takes priority (The archive name is discarded as
// unimportant)

if (request->request == REQUEST_READ_IDAM) {
if (request->request == (int)Request::ReadUDA) {
reduce_signal = false;
err = extract_archive(config, request, reduce_signal);
} else {
Expand Down Expand Up @@ -566,7 +566,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
if (!is_function) { // Must be a default server-side function
for (const auto& plugin : pluginList) {
if (plugin.entry_func_name == "ServerSide" && plugin.library_name.empty()) {
request->request = REQUEST_READ_SERVERSIDE; // Found
request->request = (int)Request::ReadServerside; // Found
copy_string(plugin.name, request->format, STRING_LENGTH);
is_function = true;
break;
Expand All @@ -581,7 +581,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD

} else {
// Select the Generic plugin: No source => no format or protocol or library was specified.
request->request = REQUEST_READ_GENERIC;
request->request = (int)Request::ReadGeneric;
UDA_LOG(UDA_LOG_DEBUG, "C request: {}", request->request)
}

Expand All @@ -595,7 +595,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
if (id >= 0
&& pluginList[id].type == UDA_PLUGIN_CLASS_FUNCTION
&& pluginList[id].entry_func_name != "serverside") {
if (request->request == REQUEST_READ_GENERIC || request->request == REQUEST_READ_UNKNOWN) {
if (request->request == (int)Request::ReadGeneric || request->request == (int)Request::ReadUnknown) {
request->request = id; // Found
copy_string(pluginList[id].name, request->format, STRING_LENGTH);
UDA_LOG(UDA_LOG_DEBUG, "D request: {}", request->request);
Expand All @@ -622,7 +622,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
// MDS+::server
// MDS+::

if (request->request == REQUEST_READ_MDS && !is_proxy) {
if (request->request == (int)Request::ReadMDS && !is_proxy) {

reverse_string(test + ldelim, work); // Drop the delimiters and Reverse the Source String

Expand Down Expand Up @@ -668,7 +668,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
//---------------------------------------------------------------------------------------------------------------------
// UDA and WEB Servers ... parse source modelled as: server:port/source

if (request->request == REQUEST_READ_IDAM || request->request == REQUEST_READ_WEB) {
if (request->request == (int)Request::ReadUDA || request->request == (int)Request::ReadWeb) {
strcpy(work, test + ldelim); // Drop the delimiters

// Isolate the Server from the source UDA::server:port/source or SSL://server:port/source
Expand Down Expand Up @@ -699,7 +699,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD
//---------------------------------------------------------------------------------------------------------------------
// SQL Servers ...

if (request->request == REQUEST_READ_SQL) {
if (request->request == (int)Request::ReadSQL) {
strcpy(request->server, request->path);
if ((test = strchr(request->server, '/')) != nullptr) {
test[0] = '\0';
Expand Down Expand Up @@ -779,7 +779,7 @@ int source_file_format_test(const uda::config::Config& config, const char* sourc

request->format[0] = '\0';
request->file[0] = '\0';
request->request = REQUEST_READ_UNKNOWN;
request->request = (int)Request::ReadUnknown;

if (source[0] == '\0') {
return rc;
Expand Down Expand Up @@ -983,7 +983,7 @@ int source_file_format_test(const uda::config::Config& config, const char* sourc
auto format = config.get("server.default_format").as_or_default(""s);
if (source[0] == '/' && source[1] != '\0' && isdigit(source[1])) { // Default File Format?
if (generic_request_test(&source[1], request)) { // Matches 99999/999
request->request = REQUEST_READ_UNKNOWN;
request->request = (int)Request::ReadUnknown;
strcpy(request->format, format.c_str()); // the default Server File Format
break;
}
Expand Down Expand Up @@ -1035,7 +1035,7 @@ int generic_request_test(const char* source, RequestData* request)

request->format[0] = '\0';
request->file[0] = '\0';
request->request = REQUEST_READ_UNKNOWN;
request->request = (int)Request::ReadUnknown;

if (source[0] == '\0') {
return rc;
Expand All @@ -1052,7 +1052,7 @@ int generic_request_test(const char* source, RequestData* request)

if (is_number((char*)source)) { // Is the source an integer number?
rc = 1;
request->request = REQUEST_READ_GENERIC;
request->request = (int)Request::ReadGeneric;
strcpy(request->path, ""); // Clean the path
request->exp_number = (int)strtol(source, nullptr, 10); // Plasma Shot Number
UDA_LOG(UDA_LOG_DEBUG, "exp number identified, selecting GENERIC plugin.");
Expand All @@ -1061,7 +1061,7 @@ int generic_request_test(const char* source, RequestData* request)
if ((token = strtok(work, "/")) != nullptr) { // Tokenise the remaining string
if (is_number(token)) { // Is the First token an integer number?
rc = 1;
request->request = REQUEST_READ_GENERIC;
request->request = (int)Request::ReadGeneric;
strcpy(request->path, ""); // Clean the path
request->exp_number = (int)strtol(token, nullptr, 10);
if ((token = strtok(nullptr, "/")) != nullptr) { // Next Token
Expand Down
4 changes: 2 additions & 2 deletions source/clientserver/make_request_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ void uda::parse_signal(RequestData& result, const std::string& signal, const std

result.request = find_plugin_id_by_format(plugin, plugin_list);
} else {
result.request = REQUEST_READ_GENERIC;
result.request = (int)Request::ReadGeneric;
}

write_string(result.archive, archive, STRING_LENGTH);
Expand Down Expand Up @@ -437,7 +437,7 @@ RequestData make_request_data(const Config& config, const RequestData& request_d
bool is_proxy = config.get("server.is_proxy").as_or_default(false);

if (is_proxy) {
result.request = REQUEST_READ_IDAM;
result.request = (int)Request::ReadUDA;
}

uda::write_string(result.api_delim, delim, MAXNAME);
Expand Down
4 changes: 2 additions & 2 deletions source/clientserver/parseXML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,14 +1657,14 @@ void uda::client_server::free_actions(Actions* actions)
void* cptr;

UDA_LOG(UDA_LOG_DEBUG, "freeActions: Enter")
UDA_LOG(UDA_LOG_DEBUG, "freeDataBlock: Number of Actions = {} ", actions->nactions)
UDA_LOG(UDA_LOG_DEBUG, "free_data_block: Number of Actions = {} ", actions->nactions)

if (actions->nactions == 0) {
return;
}

for (int i = 0; i < actions->nactions; i++) {
UDA_LOG(UDA_LOG_DEBUG, "freeDataBlock: freeing action Type = {} ", actions->action[i].actionType)
UDA_LOG(UDA_LOG_DEBUG, "free_data_block: freeing action Type = {} ", actions->action[i].actionType)

switch (actions->action[i].actionType) {

Expand Down
2 changes: 1 addition & 1 deletion source/clientserver/socketStructs.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ struct HostData {
//-------------------------------------------------------
// Socket Types

enum class SocketType {
enum class SocketType : int {
Unknown = 0,
UDA = 1,
MDSPLUS = 2,
Expand Down
5 changes: 1 addition & 4 deletions source/clientserver/udaDefines.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#ifndef UDA_CLIENTSERVER_IDAMDEFINES_H
#define UDA_CLIENTSERVER_IDAMDEFINES_H
#pragma once

//--------------------------------------------------------
// Size Definitions
Expand Down Expand Up @@ -140,5 +139,3 @@
// QA Status

#define DEFAULT_STATUS 1 // Default Signal and Data_Source Status value

#endif // UDA_CLIENTSERVER_IDAMDEFINES_H
Loading

0 comments on commit d6fefc6

Please sign in to comment.