From d6fefc67f28d3f43d760cdf434229f58aedebd92 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Mon, 28 Oct 2024 17:57:20 +0000 Subject: [PATCH] Replacing REQUEST macros with enum --- source/c_api/udaPutAPI.cpp | 2 +- source/client/makeClientRequestBlock.cpp | 2 +- source/client/udaClient.cpp | 14 ++-- source/client2/client.cpp | 2 +- source/clientserver/makeRequestBlock.cpp | 34 ++++---- source/clientserver/make_request_block.cpp | 4 +- source/clientserver/parseXML.cpp | 4 +- source/clientserver/socketStructs.h | 2 +- source/clientserver/udaDefines.h | 5 +- source/clientserver/udaErrors.h | 98 +++------------------- source/clientserver/udaStructs.cpp | 16 ++-- source/clientserver/udaStructs.h | 87 ++++++++++++------- source/clientserver/xdrlib.cpp | 2 +- source/include/uda/legacy.h | 2 +- source/server/fatServer.cpp | 4 +- source/server/serverGetData.cpp | 68 +++++++-------- source/server/serverLegacyPlugin.cpp | 56 ++++++------- source/server/serverPlugin.cpp | 4 +- source/server/serverSubsetData.cpp | 2 +- source/server/udaLegacyServer.cpp | 10 +-- source/server/udaServer.cpp | 8 +- source/server2/get_data.cpp | 74 ++++++++-------- source/server2/server.cpp | 6 +- source/server2/server_plugin.cpp | 4 +- source/server2/server_subset_data.cpp | 2 +- 25 files changed, 228 insertions(+), 284 deletions(-) diff --git a/source/c_api/udaPutAPI.cpp b/source/c_api/udaPutAPI.cpp index d1c0635e..16750939 100644 --- a/source/c_api/udaPutAPI.cpp +++ b/source/c_api/udaPutAPI.cpp @@ -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; } diff --git a/source/client/makeClientRequestBlock.cpp b/source/client/makeClientRequestBlock.cpp index b3547fdc..c6cc9bc8 100644 --- a/source/client/makeClientRequestBlock.cpp +++ b/source/client/makeClientRequestBlock.cpp @@ -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; diff --git a/source/client/udaClient.cpp b/source/client/udaClient.cpp index 2648268b..fe930b02 100644 --- a/source/client/udaClient.cpp +++ b/source/client/udaClient.cpp @@ -110,7 +110,7 @@ int getCurrentDataBlockIndex() return data_blocks.size() - 1; } -void freeDataBlocks() +void free_data_blocks() { data_blocks.clear(); udaPutThreadLastHandle(-1); @@ -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; } @@ -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]; @@ -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 diff --git a/source/client2/client.cpp b/source/client2/client.cpp index 0730e873..6828b0cb 100644 --- a/source/client2/client.cpp +++ b/source/client2/client.cpp @@ -1223,7 +1223,7 @@ int uda::client::Client::put(std::string_view put_instruction, uda::client_serve std::vector 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]; } diff --git a/source/clientserver/makeRequestBlock.cpp b/source/clientserver/makeRequestBlock.cpp index e36ffbcf..6210317e 100644 --- a/source/clientserver/makeRequestBlock.cpp +++ b/source/clientserver/makeRequestBlock.cpp @@ -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! @@ -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; } //============================================================================== @@ -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 ??? ****") @@ -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; } @@ -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 { @@ -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; @@ -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) } @@ -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); @@ -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 @@ -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 @@ -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'; @@ -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; @@ -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; } @@ -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; @@ -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."); @@ -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 diff --git a/source/clientserver/make_request_block.cpp b/source/clientserver/make_request_block.cpp index 4e8dd5ac..1bc0f9fd 100644 --- a/source/clientserver/make_request_block.cpp +++ b/source/clientserver/make_request_block.cpp @@ -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); @@ -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); diff --git a/source/clientserver/parseXML.cpp b/source/clientserver/parseXML.cpp index 3684a5d9..6687af82 100644 --- a/source/clientserver/parseXML.cpp +++ b/source/clientserver/parseXML.cpp @@ -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) { diff --git a/source/clientserver/socketStructs.h b/source/clientserver/socketStructs.h index 8c9dc542..0d7972e0 100644 --- a/source/clientserver/socketStructs.h +++ b/source/clientserver/socketStructs.h @@ -23,7 +23,7 @@ struct HostData { //------------------------------------------------------- // Socket Types -enum class SocketType { +enum class SocketType : int { Unknown = 0, UDA = 1, MDSPLUS = 2, diff --git a/source/clientserver/udaDefines.h b/source/clientserver/udaDefines.h index 9e81cc13..beccf584 100644 --- a/source/clientserver/udaDefines.h +++ b/source/clientserver/udaDefines.h @@ -1,5 +1,4 @@ -#ifndef UDA_CLIENTSERVER_IDAMDEFINES_H -#define UDA_CLIENTSERVER_IDAMDEFINES_H +#pragma once //-------------------------------------------------------- // Size Definitions @@ -140,5 +139,3 @@ // QA Status #define DEFAULT_STATUS 1 // Default Signal and Data_Source Status value - -#endif // UDA_CLIENTSERVER_IDAMDEFINES_H diff --git a/source/clientserver/udaErrors.h b/source/clientserver/udaErrors.h index 895a5e7b..e41bef4b 100644 --- a/source/clientserver/udaErrors.h +++ b/source/clientserver/udaErrors.h @@ -1,5 +1,4 @@ -#ifndef UDA_CLIENTSERVER_UDAERRORS_H -#define UDA_CLIENTSERVER_UDAERRORS_H +#pragma once //------------------------------------------------------- // Request specific errors @@ -16,7 +15,15 @@ #define FATAL_ERROR_LOGS 666 //------------------------------------------------------- -// Client Server Conversaton Protocol XDR Errors +// Client Server Conversation Protocol XDR Errors + +namespace uda::client_server { + +enum class ProtocolError : int { + +}; + +} #define UDA_PROTOCOL_ERROR_1 1 #define UDA_PROTOCOL_ERROR_2 2 @@ -47,95 +54,12 @@ #define UDA_PROTOCOL_ERROR_23 23 #define UDA_PROTOCOL_ERROR_24 24 -#define UDA_PROTOCOL_ERROR_1001 1001 -#define UDA_PROTOCOL_ERROR_1011 1011 -#define UDA_PROTOCOL_ERROR_1012 1012 -#define UDA_PROTOCOL_ERROR_1021 1021 -#define UDA_PROTOCOL_ERROR_1022 1022 -#define UDA_PROTOCOL_ERROR_1031 1031 -#define UDA_PROTOCOL_ERROR_1032 1032 -#define UDA_PROTOCOL_ERROR_1041 1041 -#define UDA_PROTOCOL_ERROR_1042 1042 -#define UDA_PROTOCOL_ERROR_1051 1051 -#define UDA_PROTOCOL_ERROR_1052 1052 -#define UDA_PROTOCOL_ERROR_1061 1061 -#define UDA_PROTOCOL_ERROR_1062 1062 -#define UDA_PROTOCOL_ERROR_1071 1071 -#define UDA_PROTOCOL_ERROR_1072 1072 -#define UDA_PROTOCOL_ERROR_1081 1081 -#define UDA_PROTOCOL_ERROR_1082 1082 -#define UDA_PROTOCOL_ERROR_1091 1091 -#define UDA_PROTOCOL_ERROR_1092 1092 #define UDA_PROTOCOL_ERROR_9999 9999 //------------------------------------------------------- // Server Side Error Codes -#define MDS_ERROR_CONNECTING_TO_SERVER 1 -#define MDS_ERROR_OPENING_TREE 2 -#define MDS_ERROR_ALLOCATING_HEAP_TDI_RANK 3 -#define MDS_ERROR_MDSVALUE_RANK 4 -#define MDS_ERROR_ALLOCATING_HEAP_TDI_SIZE 5 -#define MDS_ERROR_MDSVALUE_SIZE 6 -#define MDS_ERROR_ALLOCATING_HEAP_DATA_BLOCK 7 -#define MDS_ERROR_MDSVALUE_DATA 8 -#define MDS_ERROR_ALLOCATING_HEAP_TDI_LEN_UNITS 9 -#define MDS_ERROR_MDSVALUE_LEN_UNITS 10 -#define MDS_ERROR_UNITS_LENGTH_TOO_LARGE 11 -#define MDS_ERROR_ALLOCATING_HEAP_TDI_UNITS 12 -#define MDS_ERROR_ALLOCATING_HEAP_UNITS 13 -#define MDS_ERROR_MDSVALUE_UNITS 14 -#define MDS_ERROR_READING_DIMENSIONAL_DATA 15 -#define MDS_ERROR_MDSVALUE_TYPE 16 - -#define MDS_ERROR_DIM_DIMENSION_NUMBER_EXCEEDED 17 -#define MDS_ERROR_DIM_ALLOCATING_HEAP_TDI_SIZE 18 -#define MDS_ERROR_DIM_MDSVALUE_SIZE 19 -#define MDS_ERROR_DIM_ALLOCATING_HEAP_DATA_BLOCK 20 -#define MDS_ERROR_DIM_ALLOCATING_HEAP_TDI_DIM_OF 21 -#define MDS_ERROR_DIM_MDSVALUE_DATA 22 -#define MDS_ERROR_DIM_ALLOCATING_HEAP_TDI_LEN_UNITS 23 -#define MDS_ERROR_DIM_MDSVALUE_LEN_UNITS 24 -#define MDS_ERROR_DIM_UNITS_LENGTH_TOO_LARGE 25 -#define MDS_ERROR_DIM_ALLOCATING_HEAP_TDI_UNITS 26 -#define MDS_ERROR_DIM_ALLOCATING_HEAP_DIM_UNITS 27 -#define MDS_ERROR_DIM_MDSVALUE_UNITS 28 - -#define MDS_SERVER_NOT_RESPONDING 30 -#define MDS_SERVER_NOT_KNOWN 31 -#define MDS_SERVER_PING_TEST_PROBLEM 32 - #define UNCOMPRESS_ALLOCATING_HEAP 40 #define UNKNOWN_DATA_TYPE 41 #define ERROR_ALLOCATING_HEAP 42 -#define ERROR_ALLOCATING_META_DATA_HEAP 43 - -//------------------------------------------------------- -#define MDS_ERROR_READING_SERVER_NAME 50 -#define MDS_ERROR_RETURNING_RANK 51 -#define MDS_ERROR_DATA_ARRAY_SIZE 52 -#define MDS_ERROR_XDR_ENDOFRECORD 53 -#define MDS_ERROR_RETURNING_DATA_UNITS 54 -#define MDS_ERROR_RETURNING_DATA_VALUES 55 -#define MDS_ERROR_DIMENSION_ARRAY_SIZE 56 -#define MDS_ERROR_RETURNING_DIMENSION_UNITS 57 -#define MDS_ERROR_RETURNING_DIMENSION_VALUES 58 - -//------------------------------------------------------- - -#define IDA_CLIENT_FILE_NAME_TOO_LONG 100 -#define IDA_CLIENT_SIGNAL_NAME_TOO_LONG 101 -#define IDA_ERROR_OPENING_FILE 102 -#define IDA_ERROR_IDENTIFYING_ITEM 103 -#define IDA_ERROR_READING_DATA 104 -#define IDA_ERROR_RETURNING_RANK 105 -#define IDA_ERROR_DATA_ARRAY_SIZE 106 -#define IDA_ERROR_XDR_ENDOFRECORD 107 -#define IDA_ERROR_ALLOCATING_HEAP 108 -#define IDA_ERROR_RETURNING_DATA_UNITS 109 -#define IDA_ERROR_RETURNING_DATA_VALUES 110 -#define IDA_ERROR_DIMENSION_ARRAY_SIZE 111 -#define IDA_ERROR_RETURNING_DIMENSION_UNITS 112 -#define IDA_ERROR_RETURNING_DIMENSION_VALUES 113 - -#endif // UDA_CLIENTSERVER_UDAERRORS_H +#define ERROR_ALLOCATING_META_DATA_HEAP 43 \ No newline at end of file diff --git a/source/clientserver/udaStructs.cpp b/source/clientserver/udaStructs.cpp index a623e00f..776f9cfc 100644 --- a/source/clientserver/udaStructs.cpp +++ b/source/clientserver/udaStructs.cpp @@ -6,7 +6,7 @@ using namespace uda::logging; -void uda::client_server::freePutDataBlockList(PutDataBlockList* putDataBlockList) +void uda::client_server::free_put_data_block_list(PutDataBlockList* putDataBlockList) { if (putDataBlockList->putDataBlock != nullptr && putDataBlockList->blockListSize > 0) { free(putDataBlockList->putDataBlock); @@ -17,10 +17,10 @@ void uda::client_server::freePutDataBlockList(PutDataBlockList* putDataBlockList // void freeRequestData(RequestData* request_data) //{ // free_name_value_list(&request_data->nameValueList); -// freePutDataBlockList(&request_data->putDataBlockList); +// free_put_data_block_list(&request_data->putDataBlockList); // } -void uda::client_server::freeRequestBlock(RequestBlock* request_block) +void uda::client_server::free_request_block(RequestBlock* request_block) { // for (int i = 0; i < request_block->num_requests; ++i) { // freeRequestData(&request_block->requests[0]); @@ -30,7 +30,7 @@ void uda::client_server::freeRequestBlock(RequestBlock* request_block) // request_block->requests = nullptr; } -void uda::client_server::freeClientPutDataBlockList(PutDataBlockList* putDataBlockList) +void uda::client_server::free_client_put_data_block_list(PutDataBlockList* putDataBlockList) { if (putDataBlockList->putDataBlock != nullptr && putDataBlockList->blockListSize > 0) { free(putDataBlockList->putDataBlock); @@ -38,7 +38,7 @@ void uda::client_server::freeClientPutDataBlockList(PutDataBlockList* putDataBlo // init_put_data_block_list(putDataBlockList); } -void uda::client_server::freeDataBlock(DataBlock* data_block) +void uda::client_server::free_data_block(DataBlock* data_block) { // Free Heap Memory & Zero all Integer values @@ -197,10 +197,10 @@ void uda::client_server::freeDataBlock(DataBlock* data_block) UDA_LOG(UDA_LOG_DEBUG, "Exit"); } -void uda::client_server::freeDataBlockList(DataBlockList* data_block_list) +void uda::client_server::free_data_block_list(DataBlockList* data_block_list) { for (int i = 0; i < data_block_list->count; ++i) { - freeDataBlock(&data_block_list->data[i]); + free_data_block(&data_block_list->data[i]); } free(data_block_list->data); data_block_list->count = 0; @@ -208,7 +208,7 @@ void uda::client_server::freeDataBlockList(DataBlockList* data_block_list) } // Free Heap Memory & Zero all Integer values -void uda::client_server::freeReducedDataBlock(DataBlock* data_block) +void uda::client_server::free_reduced_data_block(DataBlock* data_block) { #ifdef FATCLIENT if (data_block == nullptr) { diff --git a/source/clientserver/udaStructs.h b/source/clientserver/udaStructs.h index 8385c652..53cce4b0 100644 --- a/source/clientserver/udaStructs.h +++ b/source/clientserver/udaStructs.h @@ -345,34 +345,57 @@ struct NameValueList { NameValue* nameValue; // List of individual name value pairs in parse order }; -enum REQUEST { - REQUEST_SHUTDOWN = -30, - REQUEST_READ_GENERIC, // Generic Signal via the UDA Database - REQUEST_READ_IDA, // an IDA File - REQUEST_READ_MDS, // an MDSPlus Server - REQUEST_READ_IDAM, // a Remote UDA server - REQUEST_READ_FORMAT, // Server to Choose Plugin for Requested Format - REQUEST_READ_CDF, // netCDF File - REQUEST_READ_HDF5, // HDF5 FIle - REQUEST_READ_XML, // XML Document defining a Signal - REQUEST_READ_UFILE, // TRANSP UFile - REQUEST_READ_FILE, // Read a File: A Container of Bytes! - REQUEST_READ_SQL, // Read from an SQL Data Source - REQUEST_READ_PPF, // JET PPF - REQUEST_READ_JPF, // JET JPF - REQUEST_READ_NEW_PLUGIN, - REQUEST_READ_NOTHING, // Immediate Return without Error: Client Server Timing Tests - REQUEST_READ_BLOCKED, // Disable Server Option for External Users (Not a client side option) - REQUEST_READ_HDATA, // Hierarchical Data Structures - REQUEST_READ_SERVERSIDE, // Server Side Functions - REQUEST_READ_UNKNOWN, // Plugin Not Known - REQUEST_READ_WEB, // a Remote or Local web server - REQUEST_READ_BIN, // Binary file - REQUEST_READ_HELP, // Help file - REQUEST_READ_DEVICE, // Request to an External Device's data server - REQUEST_CACHED, +enum class Request { + Shutdown = -30, + ReadGeneric, // Generic Signal via the UDA Database + ReadIDA, // an IDA File + ReadMDS, // an MDSPlus Server + ReadUDA, // a Remote UDA server + ReadFormat, // Server to Choose Plugin for Requested Format + ReadCPF, // netCDF File + ReadHDF5, + ReadXML, + ReadUFile, // TRANSP UFile + ReadFile, + ReadSQL, // Read from an SQL Data Source + ReadPPF, // JET PPF + ReadJPF, // JET JPF + ReadNewPlugin, + ReadNothing, // Immediate Return without Error: Client Server Timing Tests + ReadHData, + ReadServerside, // Server Side Functions + ReadUnknown, // Plugin Not Known + ReadWeb, // a Remote or Local web server + Cached, }; +inline std::string format_as(Request request) +{ + switch (request) { + case Request::Shutdown: return "Request::Shutdown"; + case Request::ReadGeneric: return "Request::ReadGeneric"; + case Request::ReadIDA: return "Request::ReadIDA"; + case Request::ReadMDS: return "Request::ReadMDS"; + case Request::ReadUDA: return "Request::ReadUDA"; + case Request::ReadFormat: return "Request::ReadFormat"; + case Request::ReadCPF: return "Request::ReadCPF"; + case Request::ReadHDF5: return "Request::ReadHDF5"; + case Request::ReadXML: return "Request::ReadXML"; + case Request::ReadUFile: return "Request::ReadUFile"; + case Request::ReadFile: return "Request::ReadFile"; + case Request::ReadSQL: return "Request::ReadSQL"; + case Request::ReadPPF: return "Request::ReadPPF"; + case Request::ReadJPF: return "Request::ReadJPF"; + case Request::ReadNewPlugin: return "Request::ReadNewPlugin"; + case Request::ReadNothing: return "Request::ReadNothing"; + case Request::ReadHData: return "Request::ReadHData"; + case Request::ReadServerside: return "Request::ReadServerside"; + case Request::ReadUnknown: return "Request::ReadUnknown"; + case Request::ReadWeb: return "Request::ReadWeb"; + case Request::Cached: return "Request::Cached"; + } +} + struct OptionalLong { bool init; long value; @@ -422,18 +445,18 @@ struct RequestBlock { RequestData* requests; }; -void freeClientPutDataBlockList(PutDataBlockList* putDataBlockList); +void free_client_put_data_block_list(PutDataBlockList* putDataBlockList); -void freeDataBlock(DataBlock* data_block); +void free_data_block(DataBlock* data_block); -void freeDataBlockList(DataBlockList* data_block_list); +void free_data_block_list(DataBlockList* data_block_list); -void freeReducedDataBlock(DataBlock* data_block); +void free_reduced_data_block(DataBlock* data_block); -void freeRequestBlock(RequestBlock* request_block); +void free_request_block(RequestBlock* request_block); // void freeRequestData(RequestData* request_data); -void freePutDataBlockList(PutDataBlockList* putDataBlockList); +void free_put_data_block_list(PutDataBlockList* putDataBlockList); } // namespace uda::client_server diff --git a/source/clientserver/xdrlib.cpp b/source/clientserver/xdrlib.cpp index ec61adba..c854d28a 100644 --- a/source/clientserver/xdrlib.cpp +++ b/source/clientserver/xdrlib.cpp @@ -285,7 +285,7 @@ bool_t uda::client_server::xdr_request_data(XDR* xdrs, RequestData* str, int pro { int request = static_cast(str->request); int rc = xdr_int(xdrs, &request); - str->request = static_cast(request); + str->request = static_cast(request); rc = rc && xdr_int(xdrs, &str->exp_number); rc = rc && xdr_int(xdrs, &str->pass); rc = rc && wrap_xdr_string(xdrs, (char*)str->tpass, STRING_LENGTH); diff --git a/source/include/uda/legacy.h b/source/include/uda/legacy.h index 7488da1f..6eb177d9 100644 --- a/source/include/uda/legacy.h +++ b/source/include/uda/legacy.h @@ -195,7 +195,7 @@ inline int acc_getCurrentDataBlockIndex() return udaGetCurrentDataBlockIndex(); } -inline void acc_freeDataBlocks() +inline void acc_free_data_blocks() { return udaFreeDataBlocks(); } diff --git a/source/server/fatServer.cpp b/source/server/fatServer.cpp index 0ff232f1..7eb64d1b 100644 --- a/source/server/fatServer.cpp +++ b/source/server/fatServer.cpp @@ -225,7 +225,7 @@ static int process_hierarchical_data(DataBlock* data_block, LogStructList* log_s // Free Heap - freeReducedDataBlock(data_block); + free_reduced_data_block(data_block); *data_block = data_block_copy; // Create an input XDR stream @@ -281,7 +281,7 @@ int fat_client_return(ServerBlock* server_block, DataBlockList* data_blocks, Dat } } - freeRequestBlock(request_block); + free_request_block(request_block); return err; } diff --git a/source/server/serverGetData.cpp b/source/server/serverGetData.cpp index 9d0068b0..79b3730d 100644 --- a/source/server/serverGetData.cpp +++ b/source/server/serverGetData.cpp @@ -67,7 +67,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request #ifndef PROXYSERVER if (original_request == 0 || *depth == 0) { original_request = request_data->request; - if (request_data->request != REQUEST_READ_XML) { + if (request_data->request != (int)Request::ReadXML) { if (STR_STARTSWITH(request_data->signal, "archive, "SS") || STR_IEQUALS(request_data->archive, "SERVERSIDE")) { @@ -155,7 +155,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request // Allow Composites (C) or Signal Switch (S) through regardless of request type if (signal_desc->type != 'C' && !serverside && signal_desc->type != 'S' && - (!(request_data->request == REQUEST_READ_GENERIC || request_data->request == REQUEST_READ_XML))) { + (!(request_data->request == (int)Request::ReadGeneric || request_data->request == (int)Request::ReadXML))) { return 0; } @@ -248,13 +248,13 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request // Need to change formats from GENERIC if Composite and Signal Description record only exists and // format Not Generic! - if (request_data->request == REQUEST_READ_GENERIC && request_data->exp_number <= 0) { - request_data->request = REQUEST_READ_XML; + if (request_data->request == (int)Request::ReadGeneric && request_data->exp_number <= 0) { + request_data->request = (int)Request::ReadXML; } //=======>>>========================================================== - if (request_data->request == REQUEST_READ_XML || request_data->exp_number <= 0) { + if (request_data->request == (int)Request::ReadXML || request_data->exp_number <= 0) { if ((strlen(actions_comp_desc.action[compId].composite.file) == 0 || strlen(actions_comp_desc.action[compId].composite.format) == 0) && request_block2.exp_number <= 0) { @@ -269,10 +269,10 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request request_block2.request = findPluginIdByFormat(actions_comp_desc.action[compId].composite.format, plugin_list); - if (request_block2.request == REQUEST_READ_UNKNOWN) { + if (request_block2.request == (int)Request::ReadUnknown) { if (actions_comp_desc.action[compId].composite.format[0] == '\0' && request_block2.exp_number > 0) { - request_block2.request = REQUEST_READ_GENERIC; + request_block2.request = (int)Request::ReadGeneric; } else { free_actions(&actions_comp_desc); free_actions(&actions_comp_sig); @@ -282,7 +282,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request } } - if (request_block2.request == REQUEST_READ_HDF5) { + if (request_block2.request == (int)Request::ReadHDF5) { strcpy(data_source->path, trim_string(request_block2.path)); // HDF5 File Location strcpy(signal_desc->signal_name, trim_string(request_block2.signal)); // HDF5 Variable Name } @@ -415,7 +415,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request free_actions(&actions_comp_sig2); if (rc != 0) { - freeDataBlock(&data_block2); + free_data_block(&data_block2); (*depth)--; return rc; } @@ -423,7 +423,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request // Replace Error Data rc = swap_signal_error(data_block, &data_block2, 0); - freeDataBlock(&data_block2); + free_data_block(&data_block2); if (rc != 0) { (*depth)--; @@ -461,7 +461,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request free_actions(&actions_comp_sig2); if (rc != 0) { - freeDataBlock(&data_block2); + free_data_block(&data_block2); (*depth)--; return rc; } @@ -469,7 +469,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request // Replace Error Data rc = swap_signal_error(data_block, &data_block2, 1); - freeDataBlock(&data_block2); + free_data_block(&data_block2); if (rc != 0) { (*depth)--; @@ -538,7 +538,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request request_block2.request = findPluginIdByFormat(request_block2.format, plugin_list); - if (request_block2.request == REQUEST_READ_UNKNOWN) { + if (request_block2.request == (int)Request::ReadUnknown) { free_actions(&actions_comp_desc2); free_actions(&actions_comp_sig2); (*depth)--; @@ -565,7 +565,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request free_actions(&actions_comp_sig2); if (rc != 0) { - freeDataBlock(&data_block2); + free_data_block(&data_block2); (*depth)--; return rc; } @@ -575,7 +575,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request rc = swap_signal_dim(actions_desc->action[compId].composite.dimensions[i].dimcomposite, data_block, &data_block2); - freeDataBlock(&data_block2); + free_data_block(&data_block2); if (rc != 0) { (*depth)--; @@ -613,7 +613,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request free_actions(&actions_comp_sig2); if (rc != 0) { - freeDataBlock(&data_block2); + free_data_block(&data_block2); (*depth)--; return rc; } @@ -623,7 +623,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request rc = swap_signal_dim_error(actions_desc->action[compId].composite.dimensions[i].dimcomposite, data_block, &data_block2, 0); - freeDataBlock(&data_block2); + free_data_block(&data_block2); if (rc != 0) { (*depth)--; @@ -661,7 +661,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request free_actions(&actions_comp_sig2); if (rc != 0) { - freeDataBlock(&data_block2); + free_data_block(&data_block2); (*depth)--; return rc; } @@ -670,7 +670,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request rc = swap_signal_dim_error(actions_desc->action[compId].composite.dimensions[i].dimcomposite, data_block, &data_block2, 1); - freeDataBlock(&data_block2); + free_data_block(&data_block2); if (rc != 0) { (*depth)--; @@ -979,7 +979,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo // The exception is XML defining Composite signals. These have a specific Request type. //------------------------------------------------------------------------------ #ifndef PROXYSERVER - if (request->request != REQUEST_READ_XML) { + if (request->request != (int)Request::ReadXML) { if (STR_STARTSWITH(request->signal, "type = 'C'; // Composite/Derived Type signal_desc->signal_name[0] = '\0'; // The true signal is contained in the XML @@ -1008,10 +1008,10 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo // the same Rank, then allow normal Generic lookup. //------------------------------------------------------------------------------ #ifndef PROXYSERVER - if (client_block.clientFlags & CLIENTFLAG_ALTDATA && request->request != REQUEST_READ_XML && + if (client_block.clientFlags & CLIENTFLAG_ALTDATA && request->request != (int)Request::ReadXML && STR_STARTSWITH(request->signal, "request != REQUEST_READ_GENERIC) { + if (request->request != (int)Request::ReadGeneric) { // Must be a Private File so switch signal names strcpy(request->signal, signal_desc->signal_name); // Alias or Generic have no context wrt private files signal_desc->xml[0] = '\0'; // No corrections to private data files @@ -1032,7 +1032,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo // Plugin sourced data (type 'P') will fail as there is no entry in the DataSource table so ignore //------------------------------------------------------------------------------ - if (request->request == REQUEST_READ_GENERIC) { + if (request->request == (int)Request::ReadGeneric) { // Identify the required Plugin @@ -1066,7 +1066,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo makeServerRequestData(config, request, plugin_list); } - } // end of REQUEST_READ_GENERIC + } // end of Request::ReadGeneric // Placeholder name-value substitution and additional name-value pairs // Modifies HEAP in request_block @@ -1082,7 +1082,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo // Client XML Specified Composite Signal //------------------------------------------------------------------------------ - if (request->request == REQUEST_READ_XML) { + if (request->request == (int)Request::ReadXML) { if (strlen(request->signal) > 0) { strcpy(signal_desc->xml, request->signal); // XML is passed via the signal string } else if (strlen(request->path) > 0) { // XML is passed via a file @@ -1151,7 +1151,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo int plugin_id; - if (request->request != REQUEST_READ_GENERIC && request->request != REQUEST_READ_UNKNOWN) { + if (request->request != (int)Request::ReadGeneric && request->request != (int)Request::ReadUnknown) { plugin_id = request->request; // User has Specified a Plugin UDA_LOG(UDA_LOG_DEBUG, "Plugin Request ID {}", plugin_id); } else { @@ -1161,7 +1161,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo UDA_LOG(UDA_LOG_DEBUG, "Number of PutData Blocks: {}", request->putDataBlockList.blockCount); - if (plugin_id != REQUEST_READ_UNKNOWN) { + if (plugin_id != (int)Request::ReadUnknown) { int id = plugin_id; @@ -1229,14 +1229,14 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo return 0; } - request->request = REQUEST_READ_GENERIC; // Use a different Plugin + request->request = (int)Request::ReadGeneric; // Use a different Plugin } } } - int plugin_id = REQUEST_READ_UNKNOWN; + int plugin_id = (int)Request::ReadUnknown; - if (request->request != REQUEST_READ_GENERIC) { + if (request->request != (int)Request::ReadGeneric) { plugin_id = request->request; // User API has Specified a Plugin } else { @@ -1268,7 +1268,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo } } - if (plugin_id == REQUEST_READ_UNKNOWN) { + if (plugin_id == (int)Request::ReadUnknown) { UDA_LOG(UDA_LOG_DEBUG, "No Plugin Selected"); } UDA_LOG(UDA_LOG_DEBUG, "Archive : {} ", data_source->archive); @@ -1287,7 +1287,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo //---------------------------------------------------------------------------- // Status values - if (request->request == REQUEST_READ_GENERIC) { + if (request->request == (int)Request::ReadGeneric) { data_block->source_status = data_source->status; data_block->signal_status = signal_rec->status; } diff --git a/source/server/serverLegacyPlugin.cpp b/source/server/serverLegacyPlugin.cpp index d56e3d77..239247f4 100644 --- a/source/server/serverLegacyPlugin.cpp +++ b/source/server/serverLegacyPlugin.cpp @@ -29,36 +29,36 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so //---------------------------------------------------------------------- // Client Requests the Server to Choose Data Access plugin - if (request->request == REQUEST_READ_FORMAT) { - UDA_LOG(UDA_LOG_DEBUG, "Request: REQUEST_READ_FORMAT"); + if (request->request == (int)Request::ReadUDA) { + UDA_LOG(UDA_LOG_DEBUG, "Request: Request::ReadFormat"); UDA_LOG(UDA_LOG_DEBUG, "Format : {} ", request->format); if (STR_IEQUALS(request->format, "IDA") || STR_IEQUALS(request->format, "IDA3")) { - request->request = REQUEST_READ_IDA; + request->request = (int)Request::ReadIDA; // parseIDAPath(request); // Check Path for file details } else if (STR_IEQUALS(request->format, "NETCDF")) { - request->request = REQUEST_READ_CDF; + request->request = (int)Request::ReadCPF; } else if (STR_IEQUALS(request->format, "HDF5")) { - request->request = REQUEST_READ_HDF5; + request->request = (int)Request::ReadHDF5; } else if (STR_IEQUALS(request->format, "XML")) { - request->request = REQUEST_READ_XML; + request->request = (int)Request::ReadXML; // parseXMLPath(request); // Check Path for details } else if (STR_IEQUALS(request->format, "UFILE")) { - request->request = REQUEST_READ_UFILE; + request->request = (int)Request::ReadUFile; } else if (STR_IEQUALS(request->format, "BIN") || STR_IEQUALS(request->format, "BINARY")) { - request->request = REQUEST_READ_FILE; + request->request = (int)Request::ReadFile; } else if (STR_IEQUALS(request->format, "PPF")) { - request->request = REQUEST_READ_PPF; + request->request = (int)Request::ReadPPF; } else if (STR_IEQUALS(request->format, "JPF")) { - request->request = REQUEST_READ_JPF; + request->request = (int)Request::ReadJPF; } else if (STR_IEQUALS(request->format, "TEST")) { - request->request = REQUEST_READ_NEW_PLUGIN; + request->request = (int)Request::ReadNewPlugin; } else if (STR_IEQUALS(request->format, "NOTHING")) { - request->request = REQUEST_READ_NOTHING; + request->request = (int)Request::ReadNothing; } else if (STR_IEQUALS(request->format, "HDATA")) { - request->request = REQUEST_READ_HDATA; + request->request = (int)Request::ReadHData; } else if (STR_IEQUALS(request->format, "SQL")) { - request->request = REQUEST_READ_SQL; + request->request = (int)Request::ReadSQL; } UDA_LOG(UDA_LOG_DEBUG, "Request Selected: {}", request->request); @@ -73,7 +73,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so // Client Identifies the File or Signal via the State Block switch (request->request) { - case REQUEST_READ_IDA: + case (int)Request::ReadIDA: strcpy(data_source->source_alias, trim_string(request->file)); strcpy(data_source->filename, trim_string(request->file)); @@ -93,7 +93,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so UDA_LOG(UDA_LOG_DEBUG, "Pass Number : {} ", request->pass); break; - case REQUEST_READ_NEW_PLUGIN: + case (int)Request::ReadNewPlugin: strcpy(data_source->source_alias, trim_string(request->file)); strcpy(data_source->filename, trim_string(request->file)); strcpy(data_source->path, trim_string(request->path)); @@ -112,7 +112,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so UDA_LOG(UDA_LOG_DEBUG, "Pass Number : {} ", request->pass); break; - case REQUEST_READ_MDS: + case (int)Request::ReadMDS: strcpy(data_source->filename, trim_string(request->file)); // MDS+ Tree strcpy(data_source->server, trim_string(request->server)); // MDS+ Server Name @@ -132,14 +132,14 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so UDA_LOG(UDA_LOG_DEBUG, "Tree Number : {} ", request->exp_number); break; - case REQUEST_READ_IDAM: + case (int)Request::ReadUDA: UDA_LOG(UDA_LOG_DEBUG, "Request: Read Remote IDAM Source"); UDA_LOG(UDA_LOG_DEBUG, "Server : {} ", request->server); UDA_LOG(UDA_LOG_DEBUG, "Source : {} ", request->file); UDA_LOG(UDA_LOG_DEBUG, "Signal : {} ", request->signal); break; - case REQUEST_READ_CDF: + case (int)Request::ReadCPF: strcpy(data_source->path, trim_string(request->path)); // netCDF File Location copy_string(trim_string(request->signal), signal_desc->signal_name, MAXNAME); @@ -148,7 +148,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so UDA_LOG(UDA_LOG_DEBUG, "Signal : {} ", request->signal); break; - case REQUEST_READ_HDF5: + case (int)Request::ReadHDF5: strcpy(data_source->path, trim_string(request->path)); // HDF5 File Location copy_string(trim_string(request->signal), signal_desc->signal_name, MAXNAME); @@ -157,7 +157,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so UDA_LOG(UDA_LOG_DEBUG, "Signal : {} ", request->signal); break; - case REQUEST_READ_XML: + case (int)Request::ReadXML: data_source->exp_number = request->exp_number; data_source->pass = request->pass; @@ -166,28 +166,28 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so UDA_LOG(UDA_LOG_DEBUG, "XML Document : {} ", request->signal); break; - case REQUEST_READ_UFILE: + case (int)Request::ReadUFile: strcpy(data_source->path, trim_string(request->path)); // UFile File Location UDA_LOG(UDA_LOG_DEBUG, "Request: ReadUFile"); UDA_LOG(UDA_LOG_DEBUG, "UFile File : {} ", request->path); break; - case REQUEST_READ_FILE: + case (int)Request::ReadFile: strcpy(data_source->path, trim_string(request->path)); // File Location UDA_LOG(UDA_LOG_DEBUG, "Request: ReadBytes"); UDA_LOG(UDA_LOG_DEBUG, "File : {} ", request->path); break; - case REQUEST_READ_HDATA: + case (int)Request::ReadHData: strcpy(data_source->path, trim_string(request->path)); // File Location UDA_LOG(UDA_LOG_DEBUG, "Request: ReadHData"); UDA_LOG(UDA_LOG_DEBUG, "File : {} ", request->path); break; - case REQUEST_READ_SQL: + case (int)Request::ReadSQL: strcpy(data_source->path, trim_string(request->path)); // SQL database etc. strcpy(data_source->server, trim_string(request->server)); // SQL server host strcpy(data_source->format, trim_string(request->format)); @@ -198,7 +198,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so UDA_LOG(UDA_LOG_DEBUG, "SQL : {} ", request->signal); break; - case REQUEST_READ_NOTHING: + case (int)Request::ReadNothing: data_source->exp_number = request->exp_number; // Size of Data Block data_source->pass = request->pass; // Compressible or Not @@ -223,7 +223,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so UDA_LOG(UDA_LOG_DEBUG, "Request: Read Nothing! (Returns Test Data)"); break; - case REQUEST_READ_PPF: + case (int)Request::ReadPPF: strcpy(data_source->source_alias, trim_string(request->file)); strcpy(data_source->filename, trim_string(request->file)); strcpy(data_source->path, trim_string(request->path)); @@ -240,7 +240,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so UDA_LOG(UDA_LOG_DEBUG, "Pass Number : {} ", request->pass); break; - case REQUEST_READ_JPF: + case (int)Request::ReadJPF: copy_string(trim_string(request->signal), signal_desc->signal_name, MAXNAME); data_source->exp_number = request->exp_number; diff --git a/source/server/serverPlugin.cpp b/source/server/serverPlugin.cpp index 929e509b..2f3fab10 100644 --- a/source/server/serverPlugin.cpp +++ b/source/server/serverPlugin.cpp @@ -250,7 +250,7 @@ int uda::server::udaServerPlugin(const uda::config::Config& config, RequestData* // Does the Path to Private Files contain hierarchical components not seen by the server? // If so make a substitution to resolve path problems. - if (strlen(request->server) == 0 && request->request != REQUEST_READ_SERVERSIDE) { + if (strlen(request->server) == 0 && request->request != (int)Request::ReadServerside) { // Must be a File plugin if ((err = path_replacement(config, request->path)) != 0) { return err; @@ -449,7 +449,7 @@ int uda::server::udaProvenancePlugin(const uda::config::Config& config, ClientBl data_block.opaque_block = nullptr; } - freeDataBlock(&data_block); + free_data_block(&data_block); // Reset Redirected Output diff --git a/source/server/serverSubsetData.cpp b/source/server/serverSubsetData.cpp index 140ae186..bcdc93b6 100644 --- a/source/server/serverSubsetData.cpp +++ b/source/server/serverSubsetData.cpp @@ -1055,7 +1055,7 @@ int apply_count(Subset subset, DataBlock* data_block) auto count = (unsigned int*)malloc(sizeof(unsigned int)); if (p1 == nullptr) { count[0] = (unsigned int)data_block->data_n; - freeDataBlock(data_block); + free_data_block(data_block); init_data_block(data_block); data_block->data_n = 1; data_block->data = (char*)count; diff --git a/source/server/udaLegacyServer.cpp b/source/server/udaLegacyServer.cpp index 439ceb08..d2ae7ba2 100644 --- a/source/server/udaLegacyServer.cpp +++ b/source/server/udaLegacyServer.cpp @@ -723,8 +723,8 @@ int uda::server::legacyServer(config::Config& config, ClientBlock client_block, //---------------------------------------------------------------------------- // Free Data Block Heap Memory - UDA_LOG(UDA_LOG_DEBUG, "freeDataBlock") - freeDataBlock(&data_block); + UDA_LOG(UDA_LOG_DEBUG, "free_data_block") + free_data_block(&data_block); UDA_LOG(UDA_LOG_DEBUG, "freeActions") free_actions(&actions_desc); @@ -732,8 +732,8 @@ int uda::server::legacyServer(config::Config& config, ClientBlock client_block, UDA_LOG(UDA_LOG_DEBUG, "freeActions") free_actions(&actions_sig); - UDA_LOG(UDA_LOG_DEBUG, "freeRequestBlock") - freeRequestBlock(&request_block); + UDA_LOG(UDA_LOG_DEBUG, "free_request_block") + free_request_block(&request_block); //---------------------------------------------------------------------------- // Write the Error Log Record & Free Error Stack Heap @@ -775,7 +775,7 @@ int uda::server::legacyServer(config::Config& config, ClientBlock client_block, //---------------------------------------------------------------------------- // Free Data Block Heap Memory in case by-passed - freeDataBlock(&data_block); + free_data_block(&data_block); //---------------------------------------------------------------------------- // Free Structure Definition List (don't free the structure as stack variable) diff --git a/source/server/udaServer.cpp b/source/server/udaServer.cpp index a7fa643a..bc591523 100644 --- a/source/server/udaServer.cpp +++ b/source/server/udaServer.cpp @@ -966,8 +966,8 @@ int do_server_loop(Config& config, RequestBlock* request_block, DataBlockList* d free(log_malloc_list); log_malloc_list = nullptr; - UDA_LOG(UDA_LOG_DEBUG, "freeDataBlockList"); - freeDataBlockList(data_block_list); + UDA_LOG(UDA_LOG_DEBUG, "free_data_blockList"); + free_data_block_list(data_block_list); UDA_LOG(UDA_LOG_DEBUG, "freeActions"); free_actions(actions_desc); @@ -975,7 +975,7 @@ int do_server_loop(Config& config, RequestBlock* request_block, DataBlockList* d UDA_LOG(UDA_LOG_DEBUG, "freeActions"); free_actions(actions_sig); - freeRequestBlock(request_block); + free_request_block(request_block); //---------------------------------------------------------------------------- // Write the Error Log Record & Free Error Stack Heap @@ -1023,7 +1023,7 @@ int do_server_closedown(ClientBlock* client_block, RequestBlock* request_block, //---------------------------------------------------------------------------- // Free Data Block Heap Memory in case by-passed - freeDataBlockList(data_block_list); + free_data_block_list(data_block_list); //---------------------------------------------------------------------------- // Free Structure Definition List (don't free the structure as stack variable) diff --git a/source/server2/get_data.cpp b/source/server2/get_data.cpp index 9acc14a2..19cbb50f 100644 --- a/source/server2/get_data.cpp +++ b/source/server2/get_data.cpp @@ -247,7 +247,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo #ifndef PROXYSERVER if (original_request == 0 || *depth == 0) { original_request = request_data->request; - if (request_data->request != REQUEST_READ_XML) { + if (request_data->request != (int)Request::ReadXML) { if (STR_STARTSWITH(request_data->signal, "archive, "SS") || STR_IEQUALS(request_data->archive, "SERVERSIDE")) { @@ -339,7 +339,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo // Allow Composites (C) or Signal Switch (S) through regardless of request type if (_metadata_block.signal_desc.type != 'C' && !serverside && _metadata_block.signal_desc.type != 'S' && - (!(request_data->request == REQUEST_READ_GENERIC || request_data->request == REQUEST_READ_XML))) { + (!(request_data->request == (int)Request::ReadGeneric || request_data->request == (int)Request::ReadXML))) { return 0; } @@ -435,13 +435,13 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo // Need to change formats from GENERIC if Composite and Signal Description record only exists and // format Not Generic! - if (request_data->request == REQUEST_READ_GENERIC && request_data->exp_number <= 0) { - request_data->request = REQUEST_READ_XML; + if (request_data->request == (int)Request::ReadGeneric && request_data->exp_number <= 0) { + request_data->request = (int)Request::ReadXML; } //=======>>>========================================================== - if (request_data->request == REQUEST_READ_XML || request_data->exp_number <= 0) { + if (request_data->request == (int)Request::ReadXML || request_data->exp_number <= 0) { if ((strlen(actions_comp_desc.action[comp_id].composite.file) == 0 || strlen(actions_comp_desc.action[comp_id].composite.format) == 0) && request_block2.exp_number <= 0) { @@ -457,13 +457,13 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo if (maybe_plugin) { request_block2.request = id; } else { - request_block2.request = REQUEST_READ_UNKNOWN; + request_block2.request = (int)Request::ReadUnknown; } - if (request_block2.request == REQUEST_READ_UNKNOWN) { + if (request_block2.request == (int)Request::ReadUnknown) { if (actions_comp_desc.action[comp_id].composite.format[0] == '\0' && request_block2.exp_number > 0) { - request_block2.request = REQUEST_READ_GENERIC; + request_block2.request = (int)Request::ReadGeneric; } else { free_actions(&actions_comp_desc); free_actions(&actions_comp_sig); @@ -473,7 +473,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo } } - if (request_block2.request == REQUEST_READ_HDF5) { + if (request_block2.request == (int)Request::ReadHDF5) { strcpy(_metadata_block.data_source.path, trim_string(request_block2.path)); // HDF5 File Location strcpy(_metadata_block.signal_desc.signal_name, @@ -604,7 +604,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo free_actions(&actions_comp_sig2); if (rc != 0) { - freeDataBlock(&data_block2); + free_data_block(&data_block2); (*depth)--; return rc; } @@ -612,7 +612,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo // Replace Error Data rc = swap_signal_error(data_block, &data_block2, 0); - freeDataBlock(&data_block2); + free_data_block(&data_block2); if (rc != 0) { (*depth)--; @@ -648,7 +648,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo free_actions(&actions_comp_sig2); if (rc != 0) { - freeDataBlock(&data_block2); + free_data_block(&data_block2); (*depth)--; return rc; } @@ -656,7 +656,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo // Replace Error Data rc = swap_signal_error(data_block, &data_block2, 1); - freeDataBlock(&data_block2); + free_data_block(&data_block2); if (rc != 0) { (*depth)--; @@ -727,10 +727,10 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo if (maybe_plugin) { request_block2.request = id; } else { - request_block2.request = REQUEST_READ_UNKNOWN; + request_block2.request = (int)Request::ReadUnknown; } - if (request_block2.request == REQUEST_READ_UNKNOWN) { + if (request_block2.request == (int)Request::ReadUnknown) { free_actions(&actions_comp_desc2); free_actions(&actions_comp_sig2); (*depth)--; @@ -755,7 +755,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo free_actions(&actions_comp_sig2); if (rc != 0) { - freeDataBlock(&data_block2); + free_data_block(&data_block2); (*depth)--; return rc; } @@ -765,7 +765,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo rc = swap_signal_dim(_actions_desc.action[comp_id].composite.dimensions[i].dimcomposite, data_block, &data_block2); - freeDataBlock(&data_block2); + free_data_block(&data_block2); if (rc != 0) { (*depth)--; @@ -801,7 +801,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo free_actions(&actions_comp_sig2); if (rc != 0) { - freeDataBlock(&data_block2); + free_data_block(&data_block2); (*depth)--; return rc; } @@ -811,7 +811,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo rc = swap_signal_dim_error(_actions_desc.action[comp_id].composite.dimensions[i].dimcomposite, data_block, &data_block2, 0); - freeDataBlock(&data_block2); + free_data_block(&data_block2); if (rc != 0) { (*depth)--; @@ -847,7 +847,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo free_actions(&actions_comp_sig2); if (rc != 0) { - freeDataBlock(&data_block2); + free_data_block(&data_block2); (*depth)--; return rc; } @@ -856,7 +856,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo rc = swap_signal_dim_error(_actions_desc.action[comp_id].composite.dimensions[i].dimcomposite, data_block, &data_block2, 1); - freeDataBlock(&data_block2); + free_data_block(&data_block2); if (rc != 0) { (*depth)--; @@ -958,7 +958,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) // The exception is XML defining Composite signals. These have a specific Request type. //------------------------------------------------------------------------------ #ifndef PROXYSERVER - if (request->request != REQUEST_READ_XML) { + if (request->request != (int)Request::ReadXML) { if (STR_STARTSWITH(request->signal, "request != REQUEST_READ_XML && + if (_client_block.clientFlags & CLIENTFLAG_ALTDATA && request->request != (int)Request::ReadXML && STR_STARTSWITH(request->signal, "request != REQUEST_READ_GENERIC) { + if (request->request != (int)Request::ReadGeneric) { // Must be a Private File so switch signal names strcpy(request->signal, _metadata_block.signal_desc.signal_name); // Alias or Generic have no context wrt private files @@ -1012,7 +1012,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) // Plugin sourced data (type 'P') will fail as there is no entry in the DataSource table so ignore //------------------------------------------------------------------------------ - if (request->request == REQUEST_READ_GENERIC) { + if (request->request == (int)Request::ReadGeneric) { // Identify the required Plugin @@ -1044,7 +1044,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) make_server_request_data(_config, request, _plugins); } - } // end of REQUEST_READ_GENERIC + } // end of Request::ReadGeneric // Placeholder name-value substitution and additional name-value pairs // Modifies HEAP in request_block @@ -1060,7 +1060,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) // Client XML Specified Composite Signal //------------------------------------------------------------------------------ - if (request->request == REQUEST_READ_XML) { + if (request->request == (int)Request::ReadXML) { if (strlen(request->signal) > 0) { strcpy(_metadata_block.signal_desc.xml, request->signal); // XML is passed via the signal string } else if (strlen(request->path) > 0) { // XML is passed via a file @@ -1122,9 +1122,9 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) plugin_interface.error_stack = {}; plugin_interface.config = &_config; - int plugin_request = REQUEST_READ_UNKNOWN; + int plugin_request = (int)Request::ReadUnknown; - if (request->request != REQUEST_READ_GENERIC && request->request != REQUEST_READ_UNKNOWN) { + if (request->request != (int)Request::ReadGeneric && request->request != (int)Request::ReadUnknown) { plugin_request = request->request; // User has Specified a Plugin UDA_LOG(UDA_LOG_DEBUG, "Plugin Request {}", plugin_request); } else { @@ -1137,7 +1137,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) UDA_LOG(UDA_LOG_DEBUG, "Number of PutData Blocks: {}", request->putDataBlockList.blockCount); - if (plugin_request != REQUEST_READ_UNKNOWN) { + if (plugin_request != (int)Request::ReadUnknown) { auto maybe_plugin = _plugins.find_by_id(plugin_request); if (!maybe_plugin) { @@ -1204,14 +1204,14 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) return 0; } - request->request = REQUEST_READ_GENERIC; // Use a different Plugin + request->request = (int)Request::ReadGeneric; // Use a different Plugin } } } - int plugin_request = REQUEST_READ_UNKNOWN; + int plugin_request = (int)Request::ReadUnknown; - if (request->request != REQUEST_READ_GENERIC) { + if (request->request != (int)Request::ReadGeneric) { plugin_request = request->request; // User API has Specified a Plugin } else { @@ -1240,7 +1240,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) } } - if (plugin_request == REQUEST_READ_UNKNOWN) { + if (plugin_request == (int)Request::ReadUnknown) { UDA_LOG(UDA_LOG_DEBUG, "No Plugin Selected"); } UDA_LOG(UDA_LOG_DEBUG, "Archive : {} ", _metadata_block.data_source.archive); @@ -1259,7 +1259,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) //---------------------------------------------------------------------------- // Status values - if (request->request == REQUEST_READ_GENERIC) { + if (request->request == (int)Request::ReadGeneric) { data_block->source_status = _metadata_block.data_source.status; data_block->signal_status = _metadata_block.signal_rec.status; } diff --git a/source/server2/server.cpp b/source/server2/server.cpp index cf05ebe4..634e4a88 100644 --- a/source/server2/server.cpp +++ b/source/server2/server.cpp @@ -100,7 +100,7 @@ unsigned int count_data_block_list_size(const std::vector& data_blocks) { for (auto& data_block : data_blocks) { - freeDataBlock(&data_block); + free_data_block(&data_block); } data_blocks.clear(); } @@ -378,7 +378,7 @@ void uda::server::Server::loop() udaSetFullNTree(nullptr); udaResetLastMallocIndex(); - UDA_LOG(UDA_LOG_DEBUG, "freeDataBlockList"); + UDA_LOG(UDA_LOG_DEBUG, "free_data_blockList"); free_data_blocks(_data_blocks); UDA_LOG(UDA_LOG_DEBUG, "freeActions"); @@ -387,7 +387,7 @@ void uda::server::Server::loop() UDA_LOG(UDA_LOG_DEBUG, "freeActions"); free_actions(&_actions_sig); - freeRequestBlock(&_request_block); + free_request_block(&_request_block); //---------------------------------------------------------------------------- // Write the Error Log Record & Free Error Stack Heap diff --git a/source/server2/server_plugin.cpp b/source/server2/server_plugin.cpp index a7c0ca3b..c669baa8 100644 --- a/source/server2/server_plugin.cpp +++ b/source/server2/server_plugin.cpp @@ -191,7 +191,7 @@ int uda::server::server_plugin(const Config& config, RequestData *request, DataS // Does the Path to Private Files contain hierarchical components not seen by the server? // If so make a substitution to resolve path problems. - if (strlen(request->server) == 0 && request->request != REQUEST_READ_SERVERSIDE) { + if (strlen(request->server) == 0 && request->request != (int)Request::ReadServerside) { // Must be a File plugin if ((err = path_replacement(config, request->path)) != 0) { return err; @@ -390,7 +390,7 @@ int uda::server::provenance_plugin(const Config& config, ClientBlock *client_blo data_block.opaque_block = nullptr; } - freeDataBlock(&data_block); + free_data_block(&data_block); // Reset Redirected Output diff --git a/source/server2/server_subset_data.cpp b/source/server2/server_subset_data.cpp index 8b55ce3b..3d41db19 100644 --- a/source/server2/server_subset_data.cpp +++ b/source/server2/server_subset_data.cpp @@ -905,7 +905,7 @@ int uda::server::server_subset_data(client_server::DataBlock* data_block, client auto count = (unsigned int*)malloc(sizeof(unsigned int)); if (p1 == nullptr) { count[0] = (unsigned int)data_block->data_n; - freeDataBlock(data_block); + free_data_block(data_block); init_data_block(data_block); data_block->data_n = 1; data_block->data = (char*)count;