From 4904d076906c4d42bd99c34f2b4a9e8482764a94 Mon Sep 17 00:00:00 2001 From: Jonathan Hollocombe Date: Tue, 5 Nov 2024 10:43:54 +0000 Subject: [PATCH] Removing remaining macros from udaDefines.h --- source/authentication/udaClientSSL.cpp | 2 +- source/c_api/accAPI.cpp | 38 ++-- source/cache/memcache.cpp | 2 +- source/client/clientXDRStream.cpp | 25 +-- source/client/connection.cpp | 4 +- source/client/generateErrors.cpp | 8 +- source/client/makeClientRequestBlock.cpp | 16 +- source/client/udaClient.cpp | 40 ++-- source/client2/client.cpp | 46 ++--- source/client2/client_xdr_stream.cpp | 25 +-- source/client2/connection.cpp | 4 +- source/client2/generate_errors.cpp | 8 +- source/client2/make_request_block.cpp | 8 +- source/client2/thread_client.cpp | 4 +- source/clientserver/allocData.cpp | 4 +- source/clientserver/errorLog.cpp | 19 +- source/clientserver/errorLog.h | 2 - source/clientserver/expand_path.cpp | 70 +++---- source/clientserver/expand_path.h | 2 +- source/clientserver/initStructs.cpp | 16 +- source/clientserver/makeRequestBlock.cpp | 40 ++-- source/clientserver/make_request_block.cpp | 30 +-- source/clientserver/parseXML.cpp | 94 ++++----- source/clientserver/parseXML.h | 50 ++--- source/clientserver/protocol.cpp | 2 +- source/clientserver/protocolXML.cpp | 28 +-- source/clientserver/protocolXML2.cpp | 48 ++--- source/clientserver/protocolXML2Put.cpp | 2 +- source/clientserver/socketStructs.h | 2 +- source/clientserver/udaDefines.h | 178 ++++++++---------- source/clientserver/udaStructs.h | 174 ++++++++--------- source/clientserver/userid.cpp | 6 +- source/clientserver/xdrlib.cpp | 142 +++++++------- source/include/uda/plugins.h | 2 +- source/plugins/bytes/md5Sum.cpp | 10 +- source/plugins/uda/uda_plugin.cpp | 30 +-- source/plugins/udaPluginFiles.h | 4 +- source/server/applyXML.cpp | 18 +- source/server/createXDRStream.cpp | 26 +-- source/server/fatServer.cpp | 10 +- source/server/initPluginList.cpp | 4 +- source/server/plugin_api.cpp | 28 +-- source/server/serverGetData.cpp | 26 +-- source/server/serverLegacyPlugin.cpp | 20 +- source/server/serverPlugin.cpp | 12 +- source/server/serverStartup.cpp | 4 +- source/server/serverSubsetData.cpp | 22 +-- source/server/udaLegacyServer.cpp | 8 +- source/server/udaServer.cpp | 18 +- source/server/writer.cpp | 4 +- source/server/writer.h | 4 +- source/server2/apply_XML.cpp | 19 +- source/server2/get_data.cpp | 26 +-- source/server2/plugin_api.cpp | 32 ++-- source/server2/server.cpp | 28 +-- source/server2/server.hpp | 2 +- source/server2/server_plugin.cpp | 12 +- source/server2/server_subset_data.cpp | 44 ++--- source/server2/xdr_protocol.cpp | 30 +-- source/structures/parseIncludeFile.cpp | 6 +- source/structures/struct.cpp | 4 +- source/wrappers/idl/idam_dlm.c | 2 +- .../wrappers/python/pyuda/cpyuda/client.pyx | 2 +- 63 files changed, 796 insertions(+), 800 deletions(-) diff --git a/source/authentication/udaClientSSL.cpp b/source/authentication/udaClientSSL.cpp index f804ef24..7dbfeb61 100644 --- a/source/authentication/udaClientSSL.cpp +++ b/source/authentication/udaClientSSL.cpp @@ -563,7 +563,7 @@ int uda::authentication::readUdaClientSSL(void* iohandle, char* buf, int count) udaUpdateSelectParms(g_sslSocket, &rfds, &tv); - while (((rc = select(g_sslSocket + 1, &rfds, nullptr, nullptr, &tv)) <= 0) && maxloop++ < MAXLOOP) { + while (((rc = select(g_sslSocket + 1, &rfds, nullptr, nullptr, &tv)) <= 0) && maxloop++ < MaxLoop) { if (rc < 0) { // Error int serrno = errno; diff --git a/source/c_api/accAPI.cpp b/source/c_api/accAPI.cpp index 5039fa43..beb1b8a0 100644 --- a/source/c_api/accAPI.cpp +++ b/source/c_api/accAPI.cpp @@ -230,7 +230,7 @@ void udaSetProperty(const char* property) set_log_level(UDA_LOG_DEBUG); } if (STR_IEQUALS(property, "altData")) { - client_flags->flags = client_flags->flags | CLIENTFLAG_ALTDATA; + client_flags->flags = client_flags->flags | client_flags::AltData; } if (!strncasecmp(property, "altRank", 7)) { copy_string(property, name, 56); @@ -247,13 +247,13 @@ void udaSetProperty(const char* property) } } if (STR_IEQUALS(property, "reuseLastHandle")) { - client_flags->flags = client_flags->flags | CLIENTFLAG_REUSELASTHANDLE; + client_flags->flags = client_flags->flags | client_flags::ReuseLastHandle; } if (STR_IEQUALS(property, "freeAndReuseLastHandle")) { - client_flags->flags = client_flags->flags | CLIENTFLAG_FREEREUSELASTHANDLE; + client_flags->flags = client_flags->flags | client_flags::FreeReuseLastHandle; } if (STR_IEQUALS(property, "fileCache")) { - client_flags->flags = client_flags->flags | CLIENTFLAG_FILECACHE; + client_flags->flags = client_flags->flags | client_flags::FileCache; } } } @@ -314,10 +314,10 @@ int udaGetProperty(const char* property) return client_flags->alt_rank; } if (STR_IEQUALS(property, "reuseLastHandle")) { - return (int)(client_flags->flags & CLIENTFLAG_REUSELASTHANDLE); + return (int)(client_flags->flags & client_flags::ReuseLastHandle); } if (STR_IEQUALS(property, "freeAndReuseLastHandle")) { - return (int)(client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE); + return (int)(client_flags->flags & client_flags::FreeReuseLastHandle); } if (STR_IEQUALS(property, "verbose")) { return get_log_level() == UDA_LOG_INFO; @@ -326,10 +326,10 @@ int udaGetProperty(const char* property) return get_log_level() == UDA_LOG_DEBUG; } if (STR_IEQUALS(property, "altData")) { - return (int)(client_flags->flags & CLIENTFLAG_ALTDATA); + return (int)(client_flags->flags & client_flags::AltData); } if (STR_IEQUALS(property, "fileCache")) { - return (int)(client_flags->flags & CLIENTFLAG_FILECACHE); + return (int)(client_flags->flags & client_flags::FileCache); } } return 0; @@ -392,19 +392,19 @@ void udaResetProperty(const char* property) set_log_level(UDA_LOG_NONE); } if (STR_IEQUALS(property, "altData")) { - client_flags->flags &= !CLIENTFLAG_ALTDATA; + client_flags->flags &= !client_flags::AltData; } if (STR_IEQUALS(property, "altRank")) { client_flags->alt_rank = 0; } if (STR_IEQUALS(property, "reuseLastHandle")) { - client_flags->flags &= !CLIENTFLAG_REUSELASTHANDLE; + client_flags->flags &= !client_flags::ReuseLastHandle; } if (STR_IEQUALS(property, "freeAndReuseLastHandle")) { - client_flags->flags &= !CLIENTFLAG_FREEREUSELASTHANDLE; + client_flags->flags &= !client_flags::FreeReuseLastHandle; } if (STR_IEQUALS(property, "fileCache")) { - client_flags->flags &= !CLIENTFLAG_FILECACHE; + client_flags->flags &= !client_flags::FileCache; } } } @@ -432,7 +432,7 @@ void udaResetProperties() client_flags->get_bytes = 0; client_flags->get_nodimdata = 0; set_log_level(UDA_LOG_NONE); - client_flags->user_timeout = TIMEOUT; + client_flags->user_timeout = TimeOut; if (getenv("UDA_TIMEOUT")) { client_flags->user_timeout = atoi(getenv("UDA_TIMEOUT")); } @@ -507,8 +507,8 @@ void udaPutErrorModel(int handle, int model, int param_n, const float* params) data_block->error_model = model; // Model ID data_block->error_param_n = param_n; // Number of parameters - if (param_n > MAXERRPARAMS) { - data_block->error_param_n = MAXERRPARAMS; + if (param_n > MaxErrParams) { + data_block->error_param_n = MaxErrParams; } for (int i = 0; i < data_block->error_param_n; i++) { @@ -532,8 +532,8 @@ void udaPutDimErrorModel(int handle, int ndim, int model, int param_n, const flo data_block->dims[ndim].error_model = model; // Model ID data_block->dims[ndim].error_param_n = param_n; // Number of parameters - if (param_n > MAXERRPARAMS) { - data_block->dims[ndim].error_param_n = MAXERRPARAMS; + if (param_n > MaxErrParams) { + data_block->dims[ndim].error_param_n = MaxErrParams; } for (int i = 0; i < data_block->dims[ndim].error_param_n; i++) { data_block->dims[ndim].errparams[i] = params[i]; @@ -690,7 +690,7 @@ int udaGetDataStatus(int handle) if (data_block == nullptr) { return 0; } - if (udaGetSignalStatus(handle) == DEFAULT_STATUS) { + if (udaGetSignalStatus(handle) == DefaultStatus) { // Signal Status Not Changed from Default - use Data Source Value return data_block->source_status; } else { @@ -753,7 +753,7 @@ unsigned int udaGetCachePermission(int handle) // Permission to cache? auto data_block = getDataBlock(handle); if (data_block == nullptr) { - return UDA_PLUGIN_NOT_OK_TO_CACHE; + return (int)PluginCachePermission::NotOkToCache; } return data_block->cachePermission; } diff --git a/source/cache/memcache.cpp b/source/cache/memcache.cpp index 94bf171a..c927fa73 100644 --- a/source/cache/memcache.cpp +++ b/source/cache/memcache.cpp @@ -100,7 +100,7 @@ std::string generate_cache_key(const RequestData* request, Environment environme unsigned int private_flags) { // Check Properties for permission and requested method - if (!(flags & CLIENTFLAG_CACHE)) { + if (!(flags & client_flags::Cache)) { return {}; } diff --git a/source/client/clientXDRStream.cpp b/source/client/clientXDRStream.cpp index 524ecb54..d5a10c53 100644 --- a/source/client/clientXDRStream.cpp +++ b/source/client/clientXDRStream.cpp @@ -15,6 +15,7 @@ using namespace uda::authentication; #endif using namespace uda::logging; +using namespace uda::client_server; std::pair uda::client::clientCreateXDRStream() { @@ -30,37 +31,37 @@ std::pair uda::client::clientCreateXDRStream() if (getUdaClientSSLDisabled()) { # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(uda::client::clientReadin), reinterpret_cast(uda::client::clientWriteout)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(uda::client::clientReadin), reinterpret_cast(uda::client::clientWriteout)); # else - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(clientReadin), reinterpret_cast(clientWriteout)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(clientReadin), reinterpret_cast(clientWriteout)); # endif } else { # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(readUdaClientSSL), reinterpret_cast(writeUdaClientSSL)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(readUdaClientSSL), reinterpret_cast(writeUdaClientSSL)); # else - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(readUdaClientSSL), reinterpret_cast(writeUdaClientSSL)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(readUdaClientSSL), reinterpret_cast(writeUdaClientSSL)); # endif @@ -68,19 +69,19 @@ std::pair uda::client::clientCreateXDRStream() #else # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(uda::client::clientReadin), reinterpret_cast(uda::client::clientWriteout)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(uda::client::clientReadin), reinterpret_cast(uda::client::clientWriteout)); # else - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(uda::client::clientReadin), reinterpret_cast(uda::client::clientWriteout)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, nullptr, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, nullptr, reinterpret_cast(uda::client::clientReadin), reinterpret_cast(uda::client::clientWriteout)); # endif diff --git a/source/client/connection.cpp b/source/client/connection.cpp index 24322520..2d8f0e07 100644 --- a/source/client/connection.cpp +++ b/source/client/connection.cpp @@ -220,7 +220,7 @@ void setHints(struct addrinfo* hints, const char* hostname) int uda::client::createConnection(XDR* client_input, XDR* client_output, time_t* tv_server_start, int user_timeout) { - int window_size = DB_READ_BLOCK_SIZE; // 128K + int window_size = DBReadBlockSize; // 128K int rc; static int max_socket_delay = -1; @@ -712,7 +712,7 @@ int uda::client::clientReadin(void* iohandle ALLOW_UNUSED_TYPE, char* buf, int c udaUpdateSelectParms(client_socket, &rfds, &tv); - while ((select(client_socket + 1, &rfds, nullptr, nullptr, &tv) <= 0) && maxloop++ < MAXLOOP) { + while ((select(client_socket + 1, &rfds, nullptr, nullptr, &tv) <= 0) && maxloop++ < MaxLoop) { udaUpdateSelectParms(client_socket, &rfds, &tv); // Keep trying ... } diff --git a/source/client/generateErrors.cpp b/source/client/generateErrors.cpp index 744870f1..74d9e1e2 100644 --- a/source/client/generateErrors.cpp +++ b/source/client/generateErrors.cpp @@ -162,7 +162,7 @@ int uda::client::generate_synthetic_data(int handle) int model; int param_n; - float params[MAXERRPARAMS]; + float params[MaxErrParams]; udaGetErrorModel(handle, &model, ¶m_n, params); @@ -417,7 +417,7 @@ int uda::client::generate_synthetic_dim_data(int handle, int ndim) int model; int param_n; - float params[MAXERRPARAMS]; + float params[MaxErrParams]; udaGetErrorModel(handle, &model, ¶m_n, params); @@ -671,7 +671,7 @@ int uda::client::generate_data_error(int handle) int model; int param_n; - float params[MAXERRPARAMS]; + float params[MaxErrParams]; udaGetErrorModel(handle, &model, ¶m_n, params); @@ -989,7 +989,7 @@ int uda::client::generate_dim_data_error(int handle, int ndim) int model; int param_n; - float params[MAXERRPARAMS]; + float params[MaxErrParams]; udaGetErrorModel(handle, &model, ¶m_n, params); diff --git a/source/client/makeClientRequestBlock.cpp b/source/client/makeClientRequestBlock.cpp index c6cc9bc8..1cb4c424 100644 --- a/source/client/makeClientRequestBlock.cpp +++ b/source/client/makeClientRequestBlock.cpp @@ -42,13 +42,13 @@ int make_request_data(const char* data_object, const char* data_source, RequestD //------------------------------------------------------------------------------------------------------------------ //! Test Input Arguments comply with string length limits, then copy to the request structure without modification - if (strlen(data_object) >= MAXMETA) { + if (strlen(data_object) >= MaxMeta) { UDA_THROW_ERROR(SIGNAL_ARG_TOO_LONG, "The Signal/Data Object Argument string is too long!"); } else { strcpy(request->signal, data_object); // Passed to the server without modification } - if (strlen(data_source) >= STRING_LENGTH) { + if (strlen(data_source) >= StringLength) { UDA_THROW_ERROR(SOURCE_ARG_TOO_LONG, "The Data Source Argument string is too long!"); } else { strcpy(request->source, data_source); // Passed to the server without modification @@ -79,9 +79,8 @@ int make_request_data(const char* data_object, const char* data_source, RequestD */ if (!device.empty() && strstr(request->source, request->api_delim) == nullptr) { - int lstr = - (int) strlen(request->source) + (int) device.size() + (int) strlen(request->api_delim); - if (lstr >= STRING_LENGTH) { + size_t lstr = strlen(request->source) + device.size() + strlen(request->api_delim); + if (lstr >= StringLength) { UDA_THROW_ERROR(SOURCE_ARG_TOO_LONG, "The Data Source Argument, prefixed with the Device Name, is too long!"); } @@ -90,9 +89,8 @@ int make_request_data(const char* data_object, const char* data_source, RequestD } if (!archive.empty() && strstr(request->signal, request->api_delim) == nullptr) { - int lstr = - (int) strlen(request->signal) + (int) archive.size() + (int) strlen(request->api_delim); - if (lstr >= STRING_LENGTH) { + size_t lstr = strlen(request->signal) + archive.size() + strlen(request->api_delim); + if (lstr >= StringLength) { UDA_THROW_ERROR(SIGNAL_ARG_TOO_LONG, "The Signal/Data Object Argument, prefixed with the Archive Name, is too long!"); } @@ -185,7 +183,7 @@ int shotRequestTest(const char* source) // Return 1 (TRUE) if the source is shot nuumber based , 0 (FALSE) otherwise char* token = nullptr; - char work[STRING_LENGTH]; + char work[StringLength]; if (source[0] == '\0') { return 0; diff --git a/source/client/udaClient.cpp b/source/client/udaClient.cpp index fe930b02..87b0091e 100644 --- a/source/client/udaClient.cpp +++ b/source/client/udaClient.cpp @@ -75,7 +75,7 @@ ServerBlock server_block; time_t tv_server_start = 0; time_t tv_server_end = 0; -char client_username[STRING_LENGTH] = "client"; +char client_username[StringLength] = "client"; int authentication_needed = 1; // Enable the mutual authentication conversation at startup @@ -103,7 +103,7 @@ static std::vector data_blocks = {}; int getCurrentDataBlockIndex() { auto client_flags = udaClientFlags(); - if ((client_flags->flags & CLIENTFLAG_REUSELASTHANDLE || client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) && + if ((client_flags->flags & client_flags::ReuseLastHandle || client_flags->flags & client_flags::FreeReuseLastHandle) && udaGetThreadLastHandle() >= 0) { return udaGetThreadLastHandle(); } @@ -119,7 +119,7 @@ void free_data_blocks() int growDataBlocks() { auto client_flags = udaClientFlags(); - if ((client_flags->flags & CLIENTFLAG_REUSELASTHANDLE || client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) && + if ((client_flags->flags & client_flags::ReuseLastHandle || client_flags->flags & client_flags::FreeReuseLastHandle) && udaGetThreadLastHandle() >= 0) { return 0; } @@ -148,9 +148,9 @@ int getNewDataHandle() auto client_flags = udaClientFlags(); int newHandleIndex = -1; - if ((client_flags->flags & CLIENTFLAG_REUSELASTHANDLE || client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) && + if ((client_flags->flags & client_flags::ReuseLastHandle || client_flags->flags & client_flags::FreeReuseLastHandle) && (newHandleIndex = udaGetThreadLastHandle()) >= 0) { - if (client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) { + if (client_flags->flags & client_flags::FreeReuseLastHandle) { udaFree(newHandleIndex); } else { // Application has responsibility for freeing heap in the Data Block @@ -187,9 +187,9 @@ int newDataHandle() int newHandleIndex = -1; auto client_flags = udaClientFlags(); - if ((client_flags->flags & CLIENTFLAG_REUSELASTHANDLE || client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) && + if ((client_flags->flags & client_flags::ReuseLastHandle || client_flags->flags & client_flags::FreeReuseLastHandle) && (newHandleIndex = udaGetThreadLastHandle()) >= 0) { - if (client_flags->flags & CLIENTFLAG_FREEREUSELASTHANDLE) { + if (client_flags->flags & client_flags::FreeReuseLastHandle) { udaFree(newHandleIndex); } else { // Application has responsibility for freeing heap in the Data Block @@ -248,7 +248,7 @@ int check_file_cache(const RequestData* request_data, DataBlock** p_data_block, UserDefinedTypeList* user_defined_type_list, LogStructList* log_struct_list, CLIENT_FLAGS* client_flags, unsigned int private_flags, int malloc_source) { - if (client_flags->flags & CLIENTFLAG_FILECACHE && !request_data->put) { + if (client_flags->flags & client_flags::FileCache && !request_data->put) { // Query the cache for the Data DataBlock* data = udaFileCacheRead(request_data, log_malloc_list, user_defined_type_list, protocol_version, log_struct_list, private_flags, malloc_source); @@ -279,7 +279,7 @@ int check_mem_cache(uda::cache::UdaCache* cache, RequestData* request_data, Data int malloc_source) { // Check Client Properties for permission to cache - if ((client_flags->flags & CLIENTFLAG_CACHE) && !request_data->put) { + if ((client_flags->flags & client_flags::Cache) && !request_data->put) { // Open the Cache if (cache == nullptr) { @@ -315,11 +315,11 @@ int check_mem_cache(uda::cache::UdaCache* cache, RequestData* request_data, Data void copyDataBlock(DataBlock* str, DataBlock* in) { *str = *in; - memcpy(str->errparams, in->errparams, MAXERRPARAMS); - memcpy(str->data_units, in->data_units, STRING_LENGTH); - memcpy(str->data_label, in->data_label, STRING_LENGTH); - memcpy(str->data_desc, in->data_desc, STRING_LENGTH); - memcpy(str->error_msg, in->error_msg, STRING_LENGTH); + memcpy(str->errparams, in->errparams, MaxErrParams); + memcpy(str->data_units, in->data_units, StringLength); + memcpy(str->data_label, in->data_label, StringLength); + memcpy(str->data_desc, in->data_desc, StringLength); + memcpy(str->error_msg, in->error_msg, StringLength); init_client_block(&str->client_block, 0, ""); } @@ -507,7 +507,7 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices) unsigned int* private_flags = udaPrivateFlags(); CLIENT_FLAGS* client_flags = udaClientFlags(); client_flags->alt_rank = 0; - client_flags->user_timeout = TIMEOUT; + client_flags->user_timeout = TimeOut; time_t protocol_time; // Time a Conversation Occured @@ -1099,17 +1099,17 @@ int uda::client::udaClient(RequestBlock* request_block, int* indices) //------------------------------------------------------------------------------ // Cache the data if the server has passed permission and the application (client) has enabled caching - if (client_flags->flags & CLIENTFLAG_FILECACHE) { + if (client_flags->flags & client_flags::FileCache) { udaFileCacheWrite(data_block, request_block, g_log_malloc_list, g_user_defined_type_list, protocol_version, &log_struct_list, *private_flags, malloc_source); } # ifndef NOLIBMEMCACHED # ifdef CACHEDEV - if (cache != nullptr && clientFlags & CLIENTFLAG_CACHE && - data_block.cachePermission == UDA_PLUGIN_OK_TO_CACHE) { + if (cache != nullptr && clientFlags & client_flags::Cache && + data_block.cachePermission == PluginCachePermission::OkToCache) { # else - if (cache != nullptr && client_flags->flags & CLIENTFLAG_CACHE) { + if (cache != nullptr && client_flags->flags & client_flags::Cache) { # endif cache_write(cache, &request_block->requests[i], data_block, g_log_malloc_list, g_user_defined_type_list, *environment, protocol_version, client_flags->flags, &log_struct_list, *private_flags, @@ -1587,7 +1587,7 @@ void udaFreeAll() if (connectionOpen()) { client_block.timeout = 0; // Surrogate CLOSEDOWN instruction - client_block.clientFlags = client_block.clientFlags | CLIENTFLAG_CLOSEDOWN; // Direct CLOSEDOWN instruction + client_block.clientFlags = client_block.clientFlags | client_flags::CloseDown; // Direct CLOSEDOWN instruction protocol_id = ProtocolId::ClientBlock; protocol2(*g_client_output, protocol_id, XDR_SEND, nullptr, g_log_malloc_list, g_user_defined_type_list, &client_block, protocol_version, g_log_struct_list, *udaPrivateFlags(), UDA_MALLOC_SOURCE_NONE); diff --git a/source/client2/client.cpp b/source/client2/client.cpp index 6828b0cb..e18ce74c 100644 --- a/source/client2/client.cpp +++ b/source/client2/client.cpp @@ -31,11 +31,11 @@ namespace void copy_data_block(DataBlock* str, DataBlock* in) { *str = *in; - memcpy(str->errparams, in->errparams, MAXERRPARAMS); - memcpy(str->data_units, in->data_units, STRING_LENGTH); - memcpy(str->data_label, in->data_label, STRING_LENGTH); - memcpy(str->data_desc, in->data_desc, STRING_LENGTH); - memcpy(str->error_msg, in->error_msg, STRING_LENGTH); + memcpy(str->errparams, in->errparams, MaxErrParams); + memcpy(str->data_units, in->data_units, StringLength); + memcpy(str->data_label, in->data_label, StringLength); + memcpy(str->data_desc, in->data_desc, StringLength); + memcpy(str->error_msg, in->error_msg, StringLength); init_client_block(&str->client_block, 0, ""); } @@ -122,7 +122,7 @@ uda::client::Client::Client() : _connection{_config}, _protocol_version{ClientVe _client_flags = {}; _client_flags.alt_rank = 0; - _client_flags.user_timeout = TIMEOUT; + _client_flags.user_timeout = TimeOut; const char* timeout = getenv("UDA_TIMEOUT"); if (timeout != nullptr) { @@ -158,7 +158,7 @@ uda::client::Client::Client() : _connection{_config}, _protocol_version{ClientVe _cache = uda::cache::open_cache(); - char username[STRING_LENGTH]; + char username[StringLength]; user_id(username); _client_username = username; @@ -321,7 +321,7 @@ int get_data_status(DataBlock* data_block) if (data_block == nullptr) { return 0; } - if (get_signal_status(data_block) == DEFAULT_STATUS) { + if (get_signal_status(data_block) == DefaultStatus) { // Signal Status Not Changed from Default - use Data Source Value return data_block->source_status; } else { @@ -488,12 +488,12 @@ int uda::client::Client::get_requests(RequestBlock& request_block, int* indices) //------------------------------------------------------------------------------ // Cache the data if the server has passed permission and the application (client) has enabled caching - if (_client_flags.flags & CLIENTFLAG_FILECACHE) { + if (_client_flags.flags & client_flags::FileCache) { udaFileCacheWrite(data_block, &request_block, _logmalloclist, _userdefinedtypelist, _protocol_version, &_log_struct_list, _private_flags, _malloc_source); } - if (_cache != nullptr && _client_flags.flags & CLIENTFLAG_CACHE) { + if (_cache != nullptr && _client_flags.flags & client_flags::Cache) { cache_write(_config, _cache, &request_block.requests[i], data_block, _logmalloclist, _userdefinedtypelist, _protocol_version, _client_flags.flags, &_log_struct_list, _private_flags, _malloc_source); @@ -944,7 +944,7 @@ void uda::client::Client::set_property(const char* property) set_log_level(UDA_LOG_DEBUG); } if (STR_IEQUALS(property, "altData")) { - _client_flags.flags = _client_flags.flags | CLIENTFLAG_ALTDATA; + _client_flags.flags = _client_flags.flags | client_flags::AltData; } if (!strncasecmp(property, "altRank", 7)) { copy_string(property, name, 56); @@ -961,13 +961,13 @@ void uda::client::Client::set_property(const char* property) } } if (STR_IEQUALS(property, "reuseLastHandle")) { - _client_flags.flags = _client_flags.flags | CLIENTFLAG_REUSELASTHANDLE; + _client_flags.flags = _client_flags.flags | client_flags::ReuseLastHandle; } if (STR_IEQUALS(property, "freeAndReuseLastHandle")) { - _client_flags.flags = _client_flags.flags | CLIENTFLAG_FREEREUSELASTHANDLE; + _client_flags.flags = _client_flags.flags | client_flags::FreeReuseLastHandle; } if (STR_IEQUALS(property, "fileCache")) { - _client_flags.flags = _client_flags.flags | CLIENTFLAG_FILECACHE; + _client_flags.flags = _client_flags.flags | client_flags::FileCache; } } } @@ -1021,10 +1021,10 @@ int uda::client::Client::get_property(const char* property) return _alt_rank; } if (STR_IEQUALS(property, "reuseLastHandle")) { - return (int)(_client_flags.flags & CLIENTFLAG_REUSELASTHANDLE); + return (int)(_client_flags.flags & client_flags::ReuseLastHandle); } if (STR_IEQUALS(property, "freeAndReuseLastHandle")) { - return (int)(_client_flags.flags & CLIENTFLAG_FREEREUSELASTHANDLE); + return (int)(_client_flags.flags & client_flags::FreeReuseLastHandle); } if (STR_IEQUALS(property, "verbose")) { return get_log_level() == UDA_LOG_INFO; @@ -1033,10 +1033,10 @@ int uda::client::Client::get_property(const char* property) return get_log_level() == UDA_LOG_DEBUG; } if (STR_IEQUALS(property, "altData")) { - return (int)(_client_flags.flags & CLIENTFLAG_ALTDATA); + return (int)(_client_flags.flags & client_flags::AltData); } if (STR_IEQUALS(property, "fileCache")) { - return (int)(_client_flags.flags & CLIENTFLAG_FILECACHE); + return (int)(_client_flags.flags & client_flags::FileCache); } } return 0; @@ -1091,19 +1091,19 @@ void uda::client::Client::reset_property(const char* property) set_log_level(UDA_LOG_NONE); } if (STR_IEQUALS(property, "altData")) { - _client_flags.flags &= !CLIENTFLAG_ALTDATA; + _client_flags.flags &= !client_flags::AltData; } if (STR_IEQUALS(property, "altRank")) { _client_flags.alt_rank = 0; } if (STR_IEQUALS(property, "reuseLastHandle")) { - _client_flags.flags &= !CLIENTFLAG_REUSELASTHANDLE; + _client_flags.flags &= !client_flags::ReuseLastHandle; } if (STR_IEQUALS(property, "freeAndReuseLastHandle")) { - _client_flags.flags &= !CLIENTFLAG_FREEREUSELASTHANDLE; + _client_flags.flags &= !client_flags::FreeReuseLastHandle; } if (STR_IEQUALS(property, "fileCache")) { - _client_flags.flags &= !CLIENTFLAG_FILECACHE; + _client_flags.flags &= !client_flags::FileCache; } } } @@ -1125,7 +1125,7 @@ void uda::client::Client::reset_properties() _client_flags.get_bytes = 0; _client_flags.get_nodimdata = 0; set_log_level(UDA_LOG_NONE); - _client_flags.user_timeout = TIMEOUT; + _client_flags.user_timeout = TimeOut; if (getenv("UDA_TIMEOUT")) { _client_flags.user_timeout = atoi(getenv("UDA_TIMEOUT")); } diff --git a/source/client2/client_xdr_stream.cpp b/source/client2/client_xdr_stream.cpp index d0936693..7378cbdc 100644 --- a/source/client2/client_xdr_stream.cpp +++ b/source/client2/client_xdr_stream.cpp @@ -15,6 +15,7 @@ using namespace uda::authentication; #endif using namespace uda::logging; +using namespace uda::client_server; std::pair uda::client::createXDRStream(IoData* io_data) { @@ -29,37 +30,37 @@ std::pair uda::client::createXDRStream(IoData* io_data) #if defined(SSLAUTHENTICATION) && !defined(FATCLIENT) if (getUdaClientSSLDisabled()) { # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(uda::client::readin), reinterpret_cast(uda::client::writeout)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(uda::client::readin), reinterpret_cast(uda::client::writeout)); # else - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(uda::client::readin), reinterpret_cast(uda::client::writeout)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(uda::client::readin), reinterpret_cast(uda::client::writeout)); # endif } else { # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(readUdaClientSSL), reinterpret_cast(writeUdaClientSSL)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(readUdaClientSSL), reinterpret_cast(writeUdaClientSSL)); # else - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(readUdaClientSSL), reinterpret_cast(writeUdaClientSSL)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(readUdaClientSSL), reinterpret_cast(writeUdaClientSSL)); # endif @@ -67,19 +68,19 @@ std::pair uda::client::createXDRStream(IoData* io_data) #else # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(uda::client::readin), reinterpret_cast(uda::client::writeout)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(uda::client::readin), reinterpret_cast(uda::client::writeout)); # else - xdrrec_create(&client_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&client_output, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(uda::client::readin), reinterpret_cast(uda::client::writeout)); - xdrrec_create(&client_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&client_input, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(uda::client::readin), reinterpret_cast(uda::client::writeout)); # endif diff --git a/source/client2/connection.cpp b/source/client2/connection.cpp index 8d6bdf37..3c5dbaa4 100644 --- a/source/client2/connection.cpp +++ b/source/client2/connection.cpp @@ -211,7 +211,7 @@ void setHints(struct addrinfo* hints, const char* host_name) int uda::client::Connection::create(XDR* client_input, XDR* client_output, const HostList& host_list) { - int window_size = DB_READ_BLOCK_SIZE; // 128K + int window_size = DBReadBlockSize; // 128K int rc; static int max_socket_delay = -1; @@ -695,7 +695,7 @@ int uda::client::readin(void* iohandle, char* buf, int count) update_select_params(*io_data->client_socket, &rfds, &tv); - while ((select(*io_data->client_socket + 1, &rfds, nullptr, nullptr, &tv) <= 0) && maxloop++ < MAXLOOP) { + while ((select(*io_data->client_socket + 1, &rfds, nullptr, nullptr, &tv) <= 0) && maxloop++ < MaxLoop) { update_select_params(*io_data->client_socket, &rfds, &tv); // Keep trying ... } diff --git a/source/client2/generate_errors.cpp b/source/client2/generate_errors.cpp index 28b4dea0..71174c46 100644 --- a/source/client2/generate_errors.cpp +++ b/source/client2/generate_errors.cpp @@ -157,7 +157,7 @@ int uda::client::generate_synthetic_data(int handle) int model; int param_n; - float params[MAXERRPARAMS]; + float params[MaxErrParams]; get_error_model(handle, &model, ¶m_n, params); @@ -412,7 +412,7 @@ int uda::client::generate_synthetic_dim_data(int handle, int ndim) int model; int param_n; - float params[MAXERRPARAMS]; + float params[MaxErrParams]; get_error_model(handle, &model, ¶m_n, params); @@ -666,7 +666,7 @@ int uda::client::generate_data_error(int handle) int model; int param_n; - float params[MAXERRPARAMS]; + float params[MaxErrParams]; get_error_model(handle, &model, ¶m_n, params); @@ -984,7 +984,7 @@ int uda::client::generate_dim_data_error(int handle, int ndim) int model; int param_n; - float params[MAXERRPARAMS]; + float params[MaxErrParams]; get_error_model(handle, &model, ¶m_n, params); diff --git a/source/client2/make_request_block.cpp b/source/client2/make_request_block.cpp index c2401da1..54f5ba34 100644 --- a/source/client2/make_request_block.cpp +++ b/source/client2/make_request_block.cpp @@ -19,13 +19,13 @@ int make_request_data(const Config& config, const char* data_object, const char* //------------------------------------------------------------------------------------------------------------------ //! Test Input Arguments comply with string length limits, then copy to the request structure without modification - if (strlen(data_object) >= MAXMETA) { + if (strlen(data_object) >= MaxMeta) { UDA_THROW_ERROR(SIGNAL_ARG_TOO_LONG, "The Signal/Data Object Argument string is too long!"); } else { strcpy(request->signal, data_object); // Passed to the server without modification } - if (strlen(data_source) >= STRING_LENGTH) { + if (strlen(data_source) >= StringLength) { UDA_THROW_ERROR(SOURCE_ARG_TOO_LONG, "The Data Source Argument string is too long!"); } else { strcpy(request->source, data_source); // Passed to the server without modification @@ -55,7 +55,7 @@ int make_request_data(const Config& config, const char* data_object, const char* if (!device.empty() && strstr(request->source, request->api_delim) == nullptr) { auto source = fmt::format("{}{}{}", device, request->api_delim, request->source); - if (source.length() >= STRING_LENGTH) { + if (source.length() >= StringLength) { UDA_THROW_ERROR(SOURCE_ARG_TOO_LONG, "The Data Source Argument, prefixed with the Device Name, is too long!"); } @@ -64,7 +64,7 @@ int make_request_data(const Config& config, const char* data_object, const char* if (!archive.empty() && strstr(request->signal, request->api_delim) == nullptr) { auto signal = fmt::format("{}{}{}", archive, request->api_delim, request->signal); - if (signal.length() >= STRING_LENGTH) { + if (signal.length() >= StringLength) { UDA_THROW_ERROR(SIGNAL_ARG_TOO_LONG, "The Signal/Data Object Argument, prefixed with the Archive Name, is too long!"); } diff --git a/source/client2/thread_client.cpp b/source/client2/thread_client.cpp index 1a80feb6..5de70531 100644 --- a/source/client2/thread_client.cpp +++ b/source/client2/thread_client.cpp @@ -40,7 +40,7 @@ int get_data_status(int handle) if (data_block == nullptr) { return 0; } - if (get_signal_status(handle) == DEFAULT_STATUS) { + if (get_signal_status(handle) == DefaultStatus) { // Signal Status Not Changed from Default - use Data Source Value return data_block->source_status; } else { @@ -182,7 +182,7 @@ int uda::client::get_data_status(int handle) if (data_block == nullptr) { return 0; } - if (get_signal_status(handle) == DEFAULT_STATUS) { + if (get_signal_status(handle) == DefaultStatus) { // Signal Status Not Changed from Default - use Data Source Value return data_block->source_status; } else { diff --git a/source/clientserver/allocData.cpp b/source/clientserver/allocData.cpp index bb5b9564..d764073c 100644 --- a/source/clientserver/allocData.cpp +++ b/source/clientserver/allocData.cpp @@ -265,8 +265,8 @@ void uda::client_server::add_put_data_block_list(PutDataBlock* putDataBlock, Put putDataBlockList->blockCount + 1 >= putDataBlockList->blockListSize) { putDataBlockList->putDataBlock = (PutDataBlock*)realloc((void*)putDataBlockList->putDataBlock, - (putDataBlockList->blockListSize + GROWPUTDATABLOCKLIST) * sizeof(PutDataBlock)); - putDataBlockList->blockListSize = putDataBlockList->blockListSize + GROWPUTDATABLOCKLIST; + (putDataBlockList->blockListSize + GrowPutdataBlockList) * sizeof(PutDataBlock)); + putDataBlockList->blockListSize = putDataBlockList->blockListSize + GrowPutdataBlockList; } putDataBlockList->putDataBlock[putDataBlockList->blockCount++] = *putDataBlock; } diff --git a/source/clientserver/errorLog.cpp b/source/clientserver/errorLog.cpp index fbaef224..39f53d14 100644 --- a/source/clientserver/errorLog.cpp +++ b/source/clientserver/errorLog.cpp @@ -54,12 +54,13 @@ void uda::client_server::error_log(ClientBlock client_block, RequestBlock reques struct tm* broken = gmtime(&calendar); - static char access_date[DateLength]; // The Calendar Time as a formatted String + constexpr size_t access_date_length = 27; + static char access_date[access_date_length]; // The Calendar Time as a formatted String #ifndef _WIN32 asctime_r(broken, access_date); #else - asctime_s(accessdate, UDA_DATE_LENGTH, broken); + asctime_s(accessdate, access_date_length, broken); #endif convert_non_printable2(access_date); @@ -122,8 +123,8 @@ uda::client_server::UdaError uda::client_server::create_error(ErrorType type, co error.type = type; error.code = code; - copy_string(location, error.location, STRING_LENGTH); - copy_string(msg, error.msg, STRING_LENGTH); + copy_string(location, error.location, StringLength); + copy_string(msg, error.msg, StringLength); size_t lmsg0 = strlen(error.msg); @@ -131,15 +132,15 @@ uda::client_server::UdaError uda::client_server::create_error(ErrorType type, co const char* errmsg = strerror(code); size_t lmsg1 = strlen(errmsg); if (lmsg0 == 0) { - copy_string(errmsg, error.msg, STRING_LENGTH); + copy_string(errmsg, error.msg, StringLength); } else { - if ((lmsg0 + 2) < STRING_LENGTH) { + if ((lmsg0 + 2) < StringLength) { strcat(error.msg, "; "); - if ((lmsg0 + lmsg1 + 2) < STRING_LENGTH) { + if ((lmsg0 + lmsg1 + 2) < StringLength) { strcat(error.msg, errmsg); } else { - strncat(error.msg, errmsg, ((unsigned int)(STRING_LENGTH - 1 - (lmsg0 + 2)))); - error.msg[STRING_LENGTH - 1] = '\0'; + strncat(error.msg, errmsg, ((unsigned int)(StringLength - 1 - (lmsg0 + 2)))); + error.msg[StringLength - 1] = '\0'; } } } diff --git a/source/clientserver/errorLog.h b/source/clientserver/errorLog.h index 735a7707..6d25e118 100644 --- a/source/clientserver/errorLog.h +++ b/source/clientserver/errorLog.h @@ -4,8 +4,6 @@ namespace uda::client_server { -constexpr size_t DateLength = 27; - enum class ErrorType : int { None = 0, System = 1, diff --git a/source/clientserver/expand_path.cpp b/source/clientserver/expand_path.cpp index c18ce768..3a9a3e11 100644 --- a/source/clientserver/expand_path.cpp +++ b/source/clientserver/expand_path.cpp @@ -65,14 +65,14 @@ using namespace uda::logging; /** * The workstation (client host) name is obtained using the operating system command 'hostname'. * - * @param host The name of the client host workstation. The string is pre-allocated with length STRING_LENGTH + * @param host The name of the client host workstation. The string is pre-allocated with length StringLength * @return A pointer to the host string (Identical to the argument). */ char* uda::client_server::host_id(char* host) { # ifdef _WIN32 - DWORD size = STRING_LENGTH - 1; + DWORD size = StringLength - 1; GetComputerName(host, &size); return host; # else @@ -80,19 +80,19 @@ char* uda::client_server::host_id(char* host) host[0] = '\0'; # ifndef USEHOSTDOMAINNAME - if ((gethostname(host, STRING_LENGTH - 1)) != 0) { + if ((gethostname(host, StringLength - 1)) != 0) { char* env = getenv("HOSTNAME"); if (env != nullptr) { - copy_string(env, host, STRING_LENGTH); + copy_string(env, host, StringLength); } } # else - if ((gethostname(host, STRING_LENGTH - 1)) == 0) { - char domain[STRING_LENGTH]; - if ((getdomainname(domain, STRING_LENGTH - 1)) == 0) { + if ((gethostname(host, StringLength - 1)) == 0) { + char domain[StringLength]; + if ((getdomainname(domain, StringLength - 1)) == 0) { int l1 = (int)strlen(host); int l2 = (int)strlen(domain); - if (l1 + l2 + 1 < STRING_LENGTH - 1) { + if (l1 + l2 + 1 < StringLength - 1) { strcat(host, "."); strcat(host, domain); } @@ -100,7 +100,7 @@ char* uda::client_server::host_id(char* host) } else { char* env = getenv("HOSTNAME"); if (env != nullptr) { - copy_string(env, host, STRING_LENGTH); + copy_string(env, host, StringLength); } } # endif @@ -199,8 +199,8 @@ int uda::client_server::path_replacement(const uda::config::Config& config, char std::vector path_tokens; std::vector sub_tokens; - boost::split(target_tokens, targets[i], boost::is_any_of(PATH_SEPARATOR), boost::token_compress_on); - boost::split(path_tokens, path, boost::is_any_of(PATH_SEPARATOR), boost::token_compress_on); + boost::split(target_tokens, targets[i], boost::is_any_of(PathSeparator), boost::token_compress_on); + boost::split(path_tokens, path, boost::is_any_of(PathSeparator), boost::token_compress_on); if (path_tokens.size() < target_tokens.size()) { // Impossible substitution, so ignore this target @@ -209,7 +209,7 @@ int uda::client_server::path_replacement(const uda::config::Config& config, char if (substitutes[i] == "*") { // Wildcard found - boost::split(sub_tokens, substitutes[i], boost::is_any_of(PATH_SEPARATOR), + boost::split(sub_tokens, substitutes[i], boost::is_any_of(PathSeparator), boost::token_compress_on); auto is_wild = [](const std::string& token) { return token[0] == '0'; }; @@ -241,7 +241,7 @@ int uda::client_server::path_replacement(const uda::config::Config& config, char size_t kstart = 0; path[0] = '\0'; for (size_t j = 0; j < substitutes.size(); j++) { - strcat(path, PATH_SEPARATOR); + strcat(path, PathSeparator); if (substitutes[j][0] == '*') { // Substitute actual path element for (size_t k = kstart; k < target_tokens.size(); k++) { @@ -327,9 +327,9 @@ int uda::client_server::link_replacement(char* path) return err; } - char buffer[STRING_LENGTH]; + char buffer[StringLength]; if (!feof(ph)) { - if (fgets(buffer, STRING_LENGTH - 1, ph) == nullptr) { + if (fgets(buffer, StringLength - 1, ph) == nullptr) { UDA_THROW_ERROR(999, "failed to read line from command"); } } @@ -394,21 +394,21 @@ int uda::client_server::expand_file_path(const uda::config::Config& config, char //---------------------------------------------------------------------------------------------- char *fp = nullptr, *fp1 = nullptr, *env = nullptr; - char file[STRING_LENGTH]; + char file[StringLength]; # ifndef NOHOSTPREFIX - char host[STRING_LENGTH]; + char host[StringLength]; # endif - char cwd[STRING_LENGTH]; - char ocwd[STRING_LENGTH]; // Current Working Directory - char opath[STRING_LENGTH]; // Original Path string - char work[STRING_LENGTH]; - char work1[STRING_LENGTH]; - char scratch[STRING_LENGTH]; - char netname[STRING_LENGTH]; + char cwd[StringLength]; + char ocwd[StringLength]; // Current Working Directory + char opath[StringLength]; // Original Path string + char work[StringLength]; + char work1[StringLength]; + char scratch[StringLength]; + char netname[StringLength]; char* pcwd = cwd; char* token = nullptr; - int lcwd = STRING_LENGTH - 1; + int lcwd = StringLength - 1; int lpath, err = 0; size_t lscratch; int t1, t2, t3, t4, t5, t6; @@ -459,7 +459,7 @@ int uda::client_server::expand_file_path(const uda::config::Config& config, char // Override compiler options if ((env = getenv("UDA_SCRATCHNAME")) != nullptr) { // Check for Environment Variable - snprintf(scratch, STRING_LENGTH, "/%s/", env); + snprintf(scratch, StringLength, "/%s/", env); lscratch = (int)strlen(scratch); } @@ -558,7 +558,7 @@ int uda::client_server::expand_file_path(const uda::config::Config& config, char if ((fp = strrchr(path, '/')) == nullptr) { // Search backwards - extract filename strcpy(work1, path); - snprintf(path, STRING_LENGTH, "%s/%s", cwd, work1); // prepend the CWD and return + snprintf(path, StringLength, "%s/%s", cwd, work1); // prepend the CWD and return if ((err = link_replacement(path)) != 0) { return err; } @@ -679,7 +679,7 @@ int uda::client_server::expand_file_path(const uda::config::Config& config, char //! Prepend the expanded/resolved directory name to the File Name - snprintf(path, STRING_LENGTH, "%s/%s", work1, file); // Prepend the path to the filename + snprintf(path, StringLength, "%s/%s", work1, file); // Prepend the path to the filename } // End of t1 - t5 tests @@ -715,14 +715,14 @@ int uda::client_server::expand_file_path(const uda::config::Config& config, char // TODO: refactor this function so that we do not have to guess the path size if (strlen(netname) > 0 && strlen(host) > 0) { - snprintf(path, STRING_LENGTH, "/%s/%s%s", netname, host, + snprintf(path, StringLength, "/%s/%s%s", netname, host, work); // prepend /netname/hostname to /scratch/... } else { if (strlen(netname) > 0) { - snprintf(path, STRING_LENGTH, "/%s%s", netname, work); + snprintf(path, StringLength, "/%s%s", netname, work); } else { if (strlen(host) > 0) { - snprintf(path, STRING_LENGTH, "/%s%s", host, work); + snprintf(path, StringLength, "/%s%s", host, work); } } } @@ -757,8 +757,8 @@ char* uda::client_server::path_id(char* path) # else char* p; - char work[STRING_LENGTH]; // Are these consistent with the system MAX_PATH? - char pwd[STRING_LENGTH]; + char work[StringLength]; // Are these consistent with the system MAX_PATH? + char pwd[StringLength]; strcpy(work, path); // the path string may contain malign embedded linux commands: is chdir secure? @@ -770,10 +770,10 @@ char* uda::client_server::path_id(char* path) return path; } - if (getcwd(pwd, STRING_LENGTH - 1) != nullptr) { + if (getcwd(pwd, StringLength - 1) != nullptr) { errno = 0; if (chdir(path) == 0) { - if ((p = getcwd(pwd, STRING_LENGTH - 1)) != nullptr) { + if ((p = getcwd(pwd, StringLength - 1)) != nullptr) { strcpy(path, p); if (chdir(pwd) != 0) { add_error(ErrorType::System, __func__, errno, ""); diff --git a/source/clientserver/expand_path.h b/source/clientserver/expand_path.h index 4006e06c..8289211c 100644 --- a/source/clientserver/expand_path.h +++ b/source/clientserver/expand_path.h @@ -12,7 +12,7 @@ namespace uda::client_server /*! The workstation (client host) name is obtained using the operating system command 'hostname'. -@param host The name of the client host workstation. The string is pre-allocated with length STRING_LENGTH +@param host The name of the client host workstation. The string is pre-allocated with length StringLength @returns A pointer to the host string (Identical to the argument). */ char* host_id(char* host); diff --git a/source/clientserver/initStructs.cpp b/source/clientserver/initStructs.cpp index 84b8bed1..617e9680 100644 --- a/source/clientserver/initStructs.cpp +++ b/source/clientserver/initStructs.cpp @@ -58,13 +58,13 @@ void uda::client_server::init_request_block(RequestBlock* str) void uda::client_server::init_client_block(ClientBlock* str, int version, const char* clientname) { str->version = version; - str->timeout = TIMEOUT; + str->timeout = TimeOut; if (getenv("UDA_TIMEOUT")) { str->timeout = (int)strtol(getenv("UDA_TIMEOUT"), nullptr, 10); } str->pid = (int)getpid(); strcpy(str->uid, clientname); // Global userid - str->compressDim = COMPRESS_DIM; + str->compressDim = CompressDim; str->clientFlags = 0; str->altRank = 0; @@ -132,17 +132,17 @@ void uda::client_server::init_data_block(DataBlock* str) str->synthetic = nullptr; str->errhi = nullptr; str->errlo = nullptr; - memset(str->errparams, '\0', sizeof(str->errparams[0]) * MAXERRPARAMS); + memset(str->errparams, '\0', sizeof(str->errparams[0]) * MaxErrParams); str->dims = nullptr; str->data_system = nullptr; str->system_config = nullptr; str->data_source = nullptr; str->signal_rec = nullptr; str->signal_desc = nullptr; - memset(str->data_units, '\0', STRING_LENGTH); - memset(str->data_label, '\0', STRING_LENGTH); - memset(str->data_desc, '\0', STRING_LENGTH); - memset(str->error_msg, '\0', STRING_LENGTH); + memset(str->data_units, '\0', StringLength); + memset(str->data_label, '\0', StringLength); + memset(str->data_desc, '\0', StringLength); + memset(str->error_msg, '\0', StringLength); init_client_block(&(str->client_block), 0, ""); } @@ -166,7 +166,7 @@ void uda::client_server::init_dim_block(Dims* str) str->ints = nullptr; str->errhi = nullptr; str->errlo = nullptr; - for (int i = 0; i < MAXERRPARAMS; i++) { + for (int i = 0; i < MaxErrParams; i++) { str->errparams[i] = 0.0; } str->dim_units[0] = '\0'; diff --git a/source/clientserver/makeRequestBlock.cpp b/source/clientserver/makeRequestBlock.cpp index 6210317e..508d8e56 100644 --- a/source/clientserver/makeRequestBlock.cpp +++ b/source/clientserver/makeRequestBlock.cpp @@ -82,8 +82,8 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD { int ldelim; int err = 0; - char work[MAXMETA]; - char work2[MAXMETA]; + char work[MaxMeta]; + char work2[MaxMeta]; unsigned short strip = 1; // Remove enclosing quotes from name value pairs UDA_LOG(UDA_LOG_DEBUG, "Source Argument") @@ -108,8 +108,8 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD auto archive = config.get("request.default_archive").as_or_default(""s); auto device = config.get("request.default_device").as_or_default(""s); - snprintf(work, MAXMETA, "%s%s", archive.c_str(), delim.c_str()); // default archive - snprintf(work2, MAXMETA, "%s%s", device.c_str(), delim.c_str()); // default device + snprintf(work, MaxMeta, "%s%s", archive.c_str(), delim.c_str()); // default archive + snprintf(work2, MaxMeta, "%s%s", device.c_str(), delim.c_str()); // default device left_trim_string(request->signal); trim_string(request->signal); @@ -324,7 +324,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD for (const auto& plugin : pluginList) { if (plugin.name == request->archive) { request->request = id; - copy_string(plugin.name, request->format, STRING_LENGTH); + copy_string(plugin.name, request->format, StringLength); } ++id; } @@ -349,7 +349,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD if (plugin.name == work2) { if (plugin.type != UDA_PLUGIN_CLASS_DEVICE) { request->request = id; // Found - copy_string(plugin.name, request->format, STRING_LENGTH); + copy_string(plugin.name, request->format, StringLength); if (plugin.type != UDA_PLUGIN_CLASS_FILE) { // The full file path fully resolved by the client strcpy(request->path, test + ldelim); // Complete String following :: delimiter @@ -553,7 +553,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD if (plugin.name == name) { request->request = id; - copy_string(plugin.name, request->format, STRING_LENGTH); + copy_string(plugin.name, request->format, StringLength); is_function = plugin.type == UDA_PLUGIN_CLASS_FUNCTION; break; } @@ -567,7 +567,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD for (const auto& plugin : pluginList) { if (plugin.entry_func_name == "ServerSide" && plugin.library_name.empty()) { request->request = (int)Request::ReadServerside; // Found - copy_string(plugin.name, request->format, STRING_LENGTH); + copy_string(plugin.name, request->format, StringLength); is_function = true; break; } @@ -597,7 +597,7 @@ int uda::client_server::make_request_data(const config::Config& config, RequestD && pluginList[id].entry_func_name != "serverside") { if (request->request == (int)Request::ReadGeneric || request->request == (int)Request::ReadUnknown) { request->request = id; // Found - copy_string(pluginList[id].name, request->format, STRING_LENGTH); + copy_string(pluginList[id].name, request->format, StringLength); UDA_LOG(UDA_LOG_DEBUG, "D request: {}", request->request); } else if (request->request != id) { // Inconsistent // Let Source have priority over the Signal? @@ -805,7 +805,7 @@ int source_file_format_test(const uda::config::Config& config, const char* sourc const char* ida = " 99"; const char* blank = " "; FILE* ph = nullptr; - int lstr = STRING_LENGTH; + int lstr = StringLength; std::string cmd; cmd = fmt::format("head -c10 {} 2>/dev/null", source); errno = 0; @@ -817,7 +817,7 @@ int source_file_format_test(const uda::config::Config& config, const char* sourc return -999; } - char buffer[STRING_LENGTH]; + char buffer[StringLength]; if (!feof(ph)) { if (fgets(buffer, lstr - 1, ph) == nullptr) { UDA_THROW_ERROR(-999, "failed to read command") @@ -936,7 +936,7 @@ int source_file_format_test(const uda::config::Config& config, const char* sourc bool break_again = false; for (const auto& plugin : pluginList) { if (plugin.extension == &test[1]) { - copy_string(plugin.name, request->format, STRING_LENGTH); + copy_string(plugin.name, request->format, StringLength); break_again = true; break; } @@ -1011,7 +1011,7 @@ int source_file_format_test(const uda::config::Config& config, const char* sourc #else char* base = basename(request->source); #endif - copy_string(base, request->file, STRING_LENGTH); + copy_string(base, request->file, StringLength); } break; } @@ -1028,7 +1028,7 @@ int generic_request_test(const char* source, RequestData* request) { int rc = 0; char* token = nullptr; - char work[STRING_LENGTH]; + char work[StringLength]; //------------------------------------------------------------------------------ // Start with ignorance about which plugin to use @@ -1107,7 +1107,7 @@ int extract_archive(const uda::config::Config& config, RequestData* request, int if ((test = strstr(request->signal, request->api_delim)) != nullptr) { - if (test - request->signal >= STRING_LENGTH - 1 || strlen(test + ldelim) >= MAXMETA - 1) { + if (test - request->signal >= StringLength - 1 || strlen(test + ldelim) >= MaxMeta - 1) { UDA_ADD_ERROR(ARCHIVE_NAME_TOO_LONG, "The ARCHIVE Name is too long!"); return err; } @@ -1170,10 +1170,10 @@ int extract_archive(const uda::config::Config& config, RequestData* request, int void udaExpandEnvironmentalVariables(char* path) { - size_t lcwd = STRING_LENGTH - 1; - char work[STRING_LENGTH]; - char cwd[STRING_LENGTH]; - char ocwd[STRING_LENGTH]; + size_t lcwd = StringLength - 1; + char work[StringLength]; + char cwd[StringLength]; + char ocwd[StringLength]; if (strchr(path, '$') == nullptr) { UDA_LOG(UDA_LOG_DEBUG, "No embedded environment variables detected") @@ -1204,7 +1204,7 @@ void udaExpandEnvironmentalVariables(char* path) UDA_LOG(UDA_LOG_DEBUG, "expandEnvironmentvariables: Direct substitution!") char *fp = nullptr, *env, *fp1; - char work1[STRING_LENGTH]; + char work1[StringLength]; if (path[0] == '$' || (fp = strchr(&path[1], '$')) != nullptr) { // Search for a $ character diff --git a/source/clientserver/make_request_block.cpp b/source/clientserver/make_request_block.cpp index 1bc0f9fd..702ff541 100644 --- a/source/clientserver/make_request_block.cpp +++ b/source/clientserver/make_request_block.cpp @@ -211,8 +211,8 @@ std::string udaExpandEnvironmentalVariables(const std::string& path) return new_path; } - char old_cwd[STRING_LENGTH]; - size_t old_cwd_sz = STRING_LENGTH - 1; + char old_cwd[StringLength]; + size_t old_cwd_sz = StringLength - 1; if (getcwd(old_cwd, old_cwd_sz) == nullptr) { // Current Working Directory UDA_LOG(UDA_LOG_DEBUG, "Unable to identify PWD!"); return new_path; @@ -221,8 +221,8 @@ std::string udaExpandEnvironmentalVariables(const std::string& path) if (chdir(path.c_str()) == 0) { // Change to path directory // The Current Working Directory is now the resolved directory name - char cwd[STRING_LENGTH]; - size_t cwd_sz = STRING_LENGTH - 1; + char cwd[StringLength]; + size_t cwd_sz = StringLength - 1; char* p_cwd = getcwd(cwd, cwd_sz); UDA_LOG(UDA_LOG_DEBUG, "Expanding embedded environment variable:"); @@ -285,7 +285,7 @@ void uda::parse_signal(RequestData& result, const std::string& signal, const std std::string function = signal_match["function"]; bool is_function = !function.empty(); - write_string(result.function, function, STRING_LENGTH); + write_string(result.function, function, StringLength); std::string archive = signal_match["archive"]; boost::trim_right_if(archive, boost::is_any_of(":")); @@ -300,7 +300,7 @@ void uda::parse_signal(RequestData& result, const std::string& signal, const std result.request = (int)Request::ReadGeneric; } - write_string(result.archive, archive, STRING_LENGTH); + write_string(result.archive, archive, StringLength); std::string args = signal_match["args"]; auto name_values = uda::parse_args(args, true); @@ -308,7 +308,7 @@ void uda::parse_signal(RequestData& result, const std::string& signal, const std write_name_values(result.nameValueList, name_values); std::string subsets = signal_match["subsets"]; - write_string(result.subset, subsets, STRING_LENGTH); + write_string(result.subset, subsets, StringLength); std::vector tokens; boost::split(tokens, subsets, boost::is_any_of("[]"), boost::algorithm::token_compress_on); @@ -332,13 +332,13 @@ void uda::parse_source(RequestData& result, const std::string& source) std::string function = source_match["function"]; bool is_function = !function.empty(); - write_string(result.function, function, STRING_LENGTH); + write_string(result.function, function, StringLength); std::string path = source_match["path"]; bool is_file = !path.empty(); path = udaExpandEnvironmentalVariables(path); - write_string(result.path, path, STRING_LENGTH); + write_string(result.path, path, StringLength); std::string s_pulse = source_match["pulse"]; long pulse = std::stol(s_pulse); @@ -351,7 +351,7 @@ void uda::parse_source(RequestData& result, const std::string& source) write_int(&result.pass, pass); if (*end == '\0') { - write_string(result.tpass, s_pass, STRING_LENGTH); + write_string(result.tpass, s_pass, StringLength); } std::string device = source_match["device"]; @@ -381,8 +381,8 @@ void uda::parse_source(RequestData& result, const std::string& source) throw std::runtime_error{"invalid source - too many prefixes"}; } - write_string(result.function, function, STRING_LENGTH); - write_string(result.format, format, STRING_LENGTH); + write_string(result.function, function, StringLength); + write_string(result.format, format, StringLength); } void uda::write_string(char* out, std::string in, size_t len) @@ -440,9 +440,9 @@ RequestData make_request_data(const Config& config, const RequestData& request_d result.request = (int)Request::ReadUDA; } - uda::write_string(result.api_delim, delim, MAXNAME); - uda::write_string(result.signal, signal, MAXMETA); - uda::write_string(result.source, source, STRING_LENGTH); + uda::write_string(result.api_delim, delim, MaxName); + uda::write_string(result.signal, signal, MaxMeta); + uda::write_string(result.source, source, StringLength); uda::parse_source(result, source); uda::parse_signal(result, signal, plugin_list); diff --git a/source/clientserver/parseXML.cpp b/source/clientserver/parseXML.cpp index f6d35563..79b8c2a1 100644 --- a/source/clientserver/parseXML.cpp +++ b/source/clientserver/parseXML.cpp @@ -88,7 +88,7 @@ float* parse_float_array(xmlDocPtr doc, xmlNodePtr cur, const char* target, int* value = (float*)realloc((void*)value, nco * sizeof(float)); value[nco - 1] = atof(item); UDA_LOG(UDA_LOG_DEBUG, "parseFloatArray: [{}] {} {}", nco, item, value[nco - 1]) - while ((item = strtok(nullptr, delim)) != nullptr && nco <= UDA_XML_MAX_LOOP) { + while ((item = strtok(nullptr, delim)) != nullptr && nco <= XmlMaxLoop) { nco++; value = (float*)realloc((void*)value, nco * sizeof(float)); value[nco - 1] = atof(item); @@ -125,7 +125,7 @@ template void parse_fixed_length_array(xmlNodePtr cur, const char* std::stringstream ss{item}; ss >> p[nco - 1]; - while ((item = strtok(nullptr, delim)) != nullptr && nco <= UDA_MAX_DATA_RANK) { + while ((item = strtok(nullptr, delim)) != nullptr && nco <= MaxDataRank) { nco++; ss = std::stringstream{item}; ss >> p[nco - 1]; @@ -208,7 +208,7 @@ void parse_fixed_length_array(xmlNodePtr cur, const char* target, void* array, i return; } - while ((item = strtok(nullptr, delim)) != nullptr && nco <= UDA_MAX_DATA_RANK) { + while ((item = strtok(nullptr, delim)) != nullptr && nco <= MaxDataRank) { nco++; switch (arraytype) { case UDA_TYPE_FLOAT: { @@ -273,7 +273,7 @@ void parse_fixed_length_array(xmlNodePtr cur, const char* target, void* array, i } void parse_fixed_length_str_array(xmlNodePtr cur, const char* target, - char array[UDA_MAX_DATA_RANK][UDA_SXML_MAX_STRING], int* n) + char array[MaxDataRank][SxmlMaxString], int* n) { xmlChar* att = nullptr; *n = 0; @@ -288,20 +288,20 @@ void parse_fixed_length_str_array(xmlNodePtr cur, const char* target, item = strtok((char*)att, delim); if (item != nullptr) { nco++; - if (strlen(item) < UDA_SXML_MAX_STRING) { + if (strlen(item) < SxmlMaxString) { strcpy(array[nco - 1], item); } else { - strncpy(array[nco - 1], item, UDA_SXML_MAX_STRING - 1); - array[nco - 1][UDA_SXML_MAX_STRING - 1] = '\0'; + strncpy(array[nco - 1], item, SxmlMaxString - 1); + array[nco - 1][SxmlMaxString - 1] = '\0'; } - while ((item = strtok(nullptr, delim)) != nullptr && nco <= UDA_MAX_DATA_RANK) { + while ((item = strtok(nullptr, delim)) != nullptr && nco <= MaxDataRank) { nco++; - if (strlen(item) < UDA_SXML_MAX_STRING) { + if (strlen(item) < SxmlMaxString) { strcpy(array[nco - 1], item); } else { - strncpy(array[nco - 1], item, UDA_SXML_MAX_STRING - 1); - array[nco - 1][UDA_SXML_MAX_STRING - 1] = '\0'; + strncpy(array[nco - 1], item, SxmlMaxString - 1); + array[nco - 1][SxmlMaxString - 1] = '\0'; } } } @@ -391,7 +391,7 @@ void parse_time_offset(xmlDocPtr doc, xmlNodePtr cur, Actions* actions) str = (Action*)realloc((void*)str, n * sizeof(Action)); init_action(&str[n - 1]); - str[n - 1].actionType = UDA_TIME_OFFSET_TYPE; + str[n - 1].actionType = (int)ActionType::Offset; init_time_offset(&str[n - 1].timeoffset); // Attributes @@ -588,7 +588,7 @@ void parse_dim_composite(xmlDocPtr doc, xmlNodePtr cur, Composite* comp) str = (Dimension*)realloc((void*)str, n * sizeof(Dimension)); init_dimension(&str[n - 1]); - str[n - 1].dimType = UDA_DIM_COMPOSITE_TYPE; + str[n - 1].dimType = (int)ActionDimType::Composite; init_dim_composite(&str[n - 1].dimcomposite); // Attributes @@ -671,7 +671,7 @@ void parse_composite(xmlDocPtr doc, xmlNodePtr cur, Actions* actions) str = (Action*)realloc((void*)str, n * sizeof(Action)); init_action(&str[n - 1]); - str[n - 1].actionType = UDA_COMPOSITE_TYPE; + str[n - 1].actionType = (int)ActionType::Composite; init_composite(&str[n - 1].composite); // Attributes @@ -806,7 +806,7 @@ void parse_dim_error_model(xmlDocPtr doc, xmlNodePtr cur, ErrorModel* mod) str = (Dimension*)realloc((void*)str, n * sizeof(Dimension)); init_dimension(&str[n - 1]); - str[n - 1].dimType = UDA_DIM_ERROR_MODEL_TYPE; + str[n - 1].dimType = (int)ActionDimType::ErrorModel; init_dim_error_model(&str[n - 1].dimerrormodel); // Attributes @@ -830,8 +830,8 @@ void parse_dim_error_model(xmlDocPtr doc, xmlNodePtr cur, ErrorModel* mod) params = parse_float_array(doc, cur, "params", &str[n - 1].dimerrormodel.param_n); if (params != nullptr) { - if (str[n - 1].dimerrormodel.param_n > MAXERRPARAMS) { - str[n - 1].dimerrormodel.param_n = MAXERRPARAMS; + if (str[n - 1].dimerrormodel.param_n > MaxErrParams) { + str[n - 1].dimerrormodel.param_n = MaxErrParams; } for (int i = 0; i < str[n - 1].dimerrormodel.param_n; i++) { str[n - 1].dimerrormodel.params[i] = params[i]; @@ -861,7 +861,7 @@ void parse_error_model(xmlDocPtr doc, xmlNodePtr cur, Actions* actions) str = (Action*)realloc((void*)str, n * sizeof(Action)); init_action(&str[n - 1]); - str[n - 1].actionType = UDA_ERROR_MODEL_TYPE; + str[n - 1].actionType = (int)ActionType::ErrorModel; init_error_model(&str[n - 1].errormodel); // Attributes @@ -918,8 +918,8 @@ void parse_error_model(xmlDocPtr doc, xmlNodePtr cur, Actions* actions) params = parse_float_array(doc, cur, "params", &str[n - 1].errormodel.param_n); if (params != nullptr) { - if (str[n - 1].errormodel.param_n > MAXERRPARAMS) { - str[n - 1].errormodel.param_n = MAXERRPARAMS; + if (str[n - 1].errormodel.param_n > MaxErrParams) { + str[n - 1].errormodel.param_n = MaxErrParams; } for (int i = 0; i < str[n - 1].errormodel.param_n; i++) { str[n - 1].errormodel.params[i] = params[i]; @@ -950,7 +950,7 @@ void parse_dim_documentation(xmlDocPtr doc, xmlNodePtr cur, Documentation* docum str = (Dimension*)realloc((void*)str, n * sizeof(Dimension)); init_dimension(&str[n - 1]); - str[n - 1].dimType = UDA_DIM_DOCUMENTATION_TYPE; + str[n - 1].dimType = (int)ActionDimType::Documentation; init_dim_documentation(&str[n - 1].dimdocumentation); // Attributes @@ -989,7 +989,7 @@ void parse_documentation(xmlDocPtr doc, xmlNodePtr cur, Actions* actions) str = (Action*)realloc((void*)str, n * sizeof(Action)); init_action(&str[n - 1]); - str[n - 1].actionType = UDA_DOCUMENTATION_TYPE; + str[n - 1].actionType = (int)ActionType::Documentation; init_documentation(&str[n - 1].documentation); // Attributes @@ -1063,7 +1063,7 @@ void parse_dim_calibration(xmlDocPtr doc, xmlNodePtr cur, Calibration* cal) str = (Dimension*)realloc((void*)str, n * sizeof(Dimension)); init_dimension(&str[n - 1]); - str[n - 1].dimType = UDA_DIM_CALIBRATION_TYPE; + str[n - 1].dimType = (int)ActionDimType::Calibration; init_dim_calibration(&str[n - 1].dimcalibration); // Attributes @@ -1115,7 +1115,7 @@ void parse_calibration(xmlDocPtr doc, xmlNodePtr cur, Actions* actions) str = (Action*)realloc((void*)str, n * sizeof(Action)); init_action(&str[n - 1]); - str[n - 1].actionType = UDA_CALIBRATION_TYPE; + str[n - 1].actionType = (int)ActionType::Calibration; init_calibration(&str[n - 1].calibration); // Attributes @@ -1211,7 +1211,7 @@ void parse_subset(xmlDocPtr doc, xmlNodePtr cur, Actions* actions) str = (Action*)realloc((void*)str, n * sizeof(Action)); init_action(&str[n - 1]); - str[n - 1].actionType = UDA_SUBSET_TYPE; + str[n - 1].actionType = (int)ActionType::Subset; sub = &str[n - 1].subset; init_subset(sub); @@ -1370,15 +1370,15 @@ void print_dimensions(int ndim, Dimension* dims) { for (int i = 0; i < ndim; i++) { UDA_LOG(UDA_LOG_DEBUG, "Dim id : {}", dims[i].dimid) - switch (dims[i].dimType) { + switch ((ActionDimType)dims[i].dimType) { - case UDA_DIM_CALIBRATION_TYPE: + case ActionDimType::Calibration: UDA_LOG(UDA_LOG_DEBUG, "factor : {}", dims[i].dimcalibration.factor) UDA_LOG(UDA_LOG_DEBUG, "Offset : {}", dims[i].dimcalibration.offset) UDA_LOG(UDA_LOG_DEBUG, "Units : {}", dims[i].dimcalibration.units) break; - case UDA_DIM_COMPOSITE_TYPE: + case ActionDimType::Composite: UDA_LOG(UDA_LOG_DEBUG, "to Dim : {}", dims[i].dimcomposite.to_dim) UDA_LOG(UDA_LOG_DEBUG, "from Dim : {}", dims[i].dimcomposite.from_dim) UDA_LOG(UDA_LOG_DEBUG, "Dim signal : {}", dims[i].dimcomposite.dim_signal) @@ -1389,12 +1389,12 @@ void print_dimensions(int ndim, Dimension* dims) { break; - case UDA_DIM_DOCUMENTATION_TYPE: + case ActionDimType::Documentation: UDA_LOG(UDA_LOG_DEBUG, "Dim Label : {}", dims[i].dimdocumentation.label) UDA_LOG(UDA_LOG_DEBUG, "Dim Units : {}", dims[i].dimdocumentation.units) break; - case UDA_DIM_ERROR_MODEL_TYPE: + case ActionDimType::ErrorModel: UDA_LOG(UDA_LOG_DEBUG, "Error Model Id : {}", dims[i].dimerrormodel.model) UDA_LOG(UDA_LOG_DEBUG, "Number of Model Parameters: {}", dims[i].dimerrormodel.param_n) for (int j = 0; j < dims[i].dimerrormodel.param_n; j++) { @@ -1418,21 +1418,21 @@ void uda::client_server::print_action(Action action) UDA_LOG(UDA_LOG_DEBUG, "Exp Number Range : {} -> {}", action.exp_range[0], action.exp_range[1]) UDA_LOG(UDA_LOG_DEBUG, "Pass Number Range: {} -> {}", action.pass_range[0], action.pass_range[1]) - switch (action.actionType) { - case UDA_TIME_OFFSET_TYPE: + switch ((ActionType)action.actionType) { + case ActionType::Offset: UDA_LOG(UDA_LOG_DEBUG, "TimeOffset xml") UDA_LOG(UDA_LOG_DEBUG, "Method : {}", action.timeoffset.method) UDA_LOG(UDA_LOG_DEBUG, "Time Offset : {}", action.timeoffset.offset) UDA_LOG(UDA_LOG_DEBUG, "Time Interval : {}", action.timeoffset.interval) break; - case UDA_DOCUMENTATION_TYPE: + case ActionType::Documentation: UDA_LOG(UDA_LOG_DEBUG, "Documentation xml") UDA_LOG(UDA_LOG_DEBUG, "Description: {}", action.documentation.description) UDA_LOG(UDA_LOG_DEBUG, "Data Label : {}", action.documentation.label) UDA_LOG(UDA_LOG_DEBUG, "Data Units : {}", action.documentation.units) print_dimensions(action.documentation.ndimensions, action.documentation.dimensions); break; - case UDA_CALIBRATION_TYPE: + case ActionType::Calibration: UDA_LOG(UDA_LOG_DEBUG, "Calibration xml") UDA_LOG(UDA_LOG_DEBUG, "Target : {}", action.calibration.target) UDA_LOG(UDA_LOG_DEBUG, "Factor : {}", action.calibration.factor) @@ -1441,7 +1441,7 @@ void uda::client_server::print_action(Action action) UDA_LOG(UDA_LOG_DEBUG, "Data Units : {}", action.calibration.units) print_dimensions(action.calibration.ndimensions, action.calibration.dimensions); break; - case UDA_COMPOSITE_TYPE: + case ActionType::Composite: UDA_LOG(UDA_LOG_DEBUG, "Composite xml") UDA_LOG(UDA_LOG_DEBUG, "Composite Data Signal : {}", action.composite.data_signal) UDA_LOG(UDA_LOG_DEBUG, "Composite Error Signal : {}", action.composite.error_signal) @@ -1452,7 +1452,7 @@ void uda::client_server::print_action(Action action) UDA_LOG(UDA_LOG_DEBUG, "Composite Time Dimension : {}", action.composite.order) print_dimensions(action.composite.ndimensions, action.composite.dimensions); break; - case UDA_ERROR_MODEL_TYPE: + case ActionType::ErrorModel: UDA_LOG(UDA_LOG_DEBUG, "ErrorModel xml") UDA_LOG(UDA_LOG_DEBUG, "Error Model Id : {}", action.errormodel.model) UDA_LOG(UDA_LOG_DEBUG, "Number of Model Parameters: {}", action.errormodel.param_n) @@ -1462,7 +1462,7 @@ void uda::client_server::print_action(Action action) print_dimensions(action.errormodel.ndimensions, action.errormodel.dimensions); break; - case UDA_SERVER_SIDE_TYPE: + case ActionType::ServerSide: UDA_LOG(UDA_LOG_DEBUG, "ServerSide Actions") UDA_LOG(UDA_LOG_DEBUG, "Number of Serverside Subsets: {}", action.serverside.nsubsets) for (int i = 0; i < action.serverside.nsubsets; i++) { @@ -1481,7 +1481,7 @@ void uda::client_server::print_action(Action action) } UDA_LOG(UDA_LOG_DEBUG, "Number of Serverside mappings: {}", action.serverside.nmaps) break; - case UDA_SUBSET_TYPE: + case ActionType::Subset: UDA_LOG(UDA_LOG_DEBUG, "Subset Actions") UDA_LOG(UDA_LOG_DEBUG, "Number of Subsets: 1") UDA_LOG(UDA_LOG_DEBUG, "Number of Subsetting Operations: {}", action.subset.nbound) @@ -1540,7 +1540,7 @@ void init_dim_documentation(DimDocumentation* act) { void init_dim_error_model(DimErrorModel* act) { act->model = (int)ErrorModelType::Unknown; // No Error Model act->param_n = 0; // No. Model parameters - for (int i = 0; i < MAXERRPARAMS; i++) { + for (int i = 0; i < MaxErrParams; i++) { act->params[i] = 0.0; } } @@ -1594,7 +1594,7 @@ void init_error_model(ErrorModel* act) { act->model = (int)ErrorModelType::Unknown; // No Error Model act->param_n = 0; // No. Model parameters - for (int i = 0; i < MAXERRPARAMS; i++) { + for (int i = 0; i < MaxErrParams; i++) { act->params[i] = 0.0; } act->ndimensions = 0; @@ -1613,7 +1613,7 @@ void uda::client_server::init_server_side(ServerSide* act) void uda::client_server::init_subset(Subset* act) { - for (int i = 0; i < UDA_MAX_DATA_RANK; i++) { + for (int i = 0; i < MaxDataRank; i++) { act->bound[i] = 0.0; // Subsetting Float Bounds act->ubindex[i] = {.init = false, .value = 0}; // Subsetting Integer Bounds (Upper Index) act->lbindex[i] = {.init = false, .value = 0}; // Lower Index @@ -1666,9 +1666,9 @@ void uda::client_server::free_actions(Actions* actions) for (int i = 0; i < actions->nactions; i++) { UDA_LOG(UDA_LOG_DEBUG, "free_data_block: freeing action Type = {} ", actions->action[i].actionType) - switch (actions->action[i].actionType) { + switch ((ActionType)actions->action[i].actionType) { - case UDA_COMPOSITE_TYPE: + case ActionType::Composite: if ((cptr = (void*)actions->action[i].composite.dimensions) != nullptr) { free(cptr); actions->action[i].composite.dimensions = nullptr; @@ -1690,7 +1690,7 @@ void uda::client_server::free_actions(Actions* actions) } break; - case UDA_ERROR_MODEL_TYPE: + case ActionType::ErrorModel: actions->action[i].errormodel.param_n = 0; for (int j = 0; j < actions->action[i].errormodel.ndimensions; j++) { @@ -1703,7 +1703,7 @@ void uda::client_server::free_actions(Actions* actions) break; - case UDA_CALIBRATION_TYPE: + case ActionType::Calibration: if ((cptr = (void*)actions->action[i].calibration.dimensions) != nullptr) { free(cptr); actions->action[i].calibration.dimensions = nullptr; @@ -1711,7 +1711,7 @@ void uda::client_server::free_actions(Actions* actions) } break; - case UDA_DOCUMENTATION_TYPE: + case ActionType::Documentation: if ((cptr = (void*)actions->action[i].documentation.dimensions) != nullptr) { free(cptr); actions->action[i].documentation.dimensions = nullptr; @@ -1719,7 +1719,7 @@ void uda::client_server::free_actions(Actions* actions) } break; - case UDA_SERVER_SIDE_TYPE: + case ActionType::ServerSide: if (actions->action[i].serverside.nsubsets > 0) { if ((cptr = (void*)actions->action[i].serverside.subsets) != nullptr) { free(cptr); diff --git a/source/clientserver/parseXML.h b/source/clientserver/parseXML.h index 05263a22..9b149457 100644 --- a/source/clientserver/parseXML.h +++ b/source/clientserver/parseXML.h @@ -8,39 +8,39 @@ namespace uda::client_server struct Map { int nmap; // the Number of Mapping Operations - double value[UDA_MAX_DATA_RANK]; // Array of values to Map to - char mapping[UDA_MAX_DATA_RANK][UDA_SXML_MAX_STRING]; // Array of Mapping Operations - int dimid[UDA_MAX_DATA_RANK]; // Array of Dimension IDs to Map to - char data_signal[UDA_SXML_MAX_STRING]; // Name of Signal + double value[MaxDataRank]; // Array of values to Map to + char mapping[MaxDataRank][SxmlMaxString]; // Array of Mapping Operations + int dimid[MaxDataRank]; // Array of Dimension IDs to Map to + char data_signal[SxmlMaxString]; // Name of Signal }; struct DimCalibration { double factor; double offset; int invert; - char units[UDA_SXML_MAX_STRING]; + char units[SxmlMaxString]; }; struct DimComposite { int to_dim; // duplicated as dimid // Swap to Dimension ID int from_dim; // Swap from Dimension ID - char file[UDA_SXML_MAX_STRING]; - char format[UDA_SXML_MAX_STRING]; - char dim_signal[UDA_SXML_MAX_STRING]; // Dimension Source Signal Name - char dim_error[UDA_SXML_MAX_STRING]; // Dimension Error Source Signal Name - char dim_aserror[UDA_SXML_MAX_STRING]; // Dimension Asymmetric Error Source Signal Name + char file[SxmlMaxString]; + char format[SxmlMaxString]; + char dim_signal[SxmlMaxString]; // Dimension Source Signal Name + char dim_error[SxmlMaxString]; // Dimension Error Source Signal Name + char dim_aserror[SxmlMaxString]; // Dimension Asymmetric Error Source Signal Name }; struct DimDocumentation { - char label[UDA_SXML_MAX_STRING]; - char units[UDA_SXML_MAX_STRING]; + char label[SxmlMaxString]; + char units[SxmlMaxString]; }; struct DimErrorModel { int model; // Error Model Id int param_n; // The number of parameters // float *params; // Parameter Array - float params[MAXERRPARAMS]; + float params[MaxErrParams]; }; struct Dimension { @@ -64,27 +64,27 @@ struct Calibration { double factor; double offset; int invert; - char units[UDA_SXML_MAX_STRING]; - char target[UDA_SXML_MAX_STRING]; + char units[SxmlMaxString]; + char target[SxmlMaxString]; int ndimensions; Dimension* dimensions; }; struct Documentation { - char label[UDA_SXML_MAX_STRING]; - char units[UDA_SXML_MAX_STRING]; - char description[UDA_XML_MAX_DESC]; + char label[SxmlMaxString]; + char units[SxmlMaxString]; + char description[XmlMaxDesc]; int ndimensions; Dimension* dimensions; }; struct Composite { - char file[UDA_SXML_MAX_STRING]; // Complete file name - char format[UDA_SXML_MAX_STRING]; // File Format - char data_signal[UDA_SXML_MAX_STRING]; - char error_signal[UDA_SXML_MAX_STRING]; - char aserror_signal[UDA_SXML_MAX_STRING]; // Asymmetric Error Source Signal Name - char map_to_signal[UDA_SXML_MAX_STRING]; // straight replacement of signals (useful only if pass range is necessary) + char file[SxmlMaxString]; // Complete file name + char format[SxmlMaxString]; // File Format + char data_signal[SxmlMaxString]; + char error_signal[SxmlMaxString]; + char aserror_signal[SxmlMaxString]; // Asymmetric Error Source Signal Name + char map_to_signal[SxmlMaxString]; // straight replacement of signals (useful only if pass range is necessary) int order; // Identify the Time Dimension int ndimensions; int nsubsets; @@ -98,7 +98,7 @@ struct ErrorModel { int model; // Error Model Id int param_n; // The number of parameters // float *params; // Parameter Array - float params[MAXERRPARAMS]; + float params[MaxErrParams]; int ndimensions; Dimension* dimensions; }; diff --git a/source/clientserver/protocol.cpp b/source/clientserver/protocol.cpp index 4f8439b3..ee867054 100644 --- a/source/clientserver/protocol.cpp +++ b/source/clientserver/protocol.cpp @@ -55,7 +55,7 @@ void uda::client_server::update_select_params(int fd, fd_set* rfds, struct timev { FD_ZERO(rfds); FD_SET(fd, rfds); - if (server_tot_block_time < MAXBLOCK) { + if (server_tot_block_time < MaxBlock) { // (ms) For the First blocking period have rapid response (clientserver/udaDefines.h == 1000) tv->tv_sec = 0; tv->tv_usec = MIN_BLOCK_TIME; // minimum wait (1ms) diff --git a/source/clientserver/protocolXML.cpp b/source/clientserver/protocolXML.cpp index afc62b3c..54508088 100644 --- a/source/clientserver/protocolXML.cpp +++ b/source/clientserver/protocolXML.cpp @@ -170,7 +170,7 @@ int uda::client_server::protocol_xml(XDR* xdrs, ProtocolId protocol_id, int dire UDA_LOG(UDA_LOG_DEBUG, "protocolXML: private_flags : {} ", private_flags); UDA_LOG(UDA_LOG_DEBUG, "protocolXML: protocolVersion: {} ", protocolVersion); - if ((private_flags & PRIVATEFLAG_XDRFILE) && protocolVersion >= 5) { + if ((private_flags & private_flags::XdrFile) && protocolVersion >= 5) { char* env; if ((env = getenv("UDA_WORK_DIR")) != nullptr) { // File to record XDR encoded data @@ -241,7 +241,7 @@ int uda::client_server::protocol_xml(XDR* xdrs, ProtocolId protocol_id, int dire #ifndef FATCLIENT - if ((private_flags & PRIVATEFLAG_XDRFILE) && + if ((private_flags & private_flags::XdrFile) && protocolVersion >= 5) { // Server calling another server // Close the stream and file @@ -277,11 +277,11 @@ int uda::client_server::protocol_xml(XDR* xdrs, ProtocolId protocol_id, int dire UDA_LOG(UDA_LOG_DEBUG, "protocolXML: Receiving from Server"); // 3 valid options: - // 1> unpack structures, no xdr file involved => private_flags & PRIVATEFLAG_XDRFILE == 0 && + // 1> unpack structures, no xdr file involved => private_flags & private_flags::XdrFile == 0 && // packageType == PACKAGE_STRUCTDATA 2> unpack structures, from an xdr file => - // private_flags & PRIVATEFLAG_XDRFILE == 0 && packageType == PACKAGE_XDRFILE 3> xdr file only, - // no unpacking, passforward => private_flags & PRIVATEFLAG_XDRFILE == 1 && packageType == - // PACKAGE_XDRFILE 4> Error => private_flags & PRIVATEFLAG_XDRFILE == 1 && + // private_flags & private_flags::XdrFile == 0 && packageType == PACKAGE_XDRFILE 3> xdr file only, + // no unpacking, passforward => private_flags & private_flags::XdrFile == 1 && packageType == + // PACKAGE_XDRFILE 4> Error => private_flags & private_flags::XdrFile == 1 && // packageType == PACKAGE_STRUCTDATA // // Option 3 does not include intermediate file caching - option 2 only @@ -297,25 +297,25 @@ int uda::client_server::protocol_xml(XDR* xdrs, ProtocolId protocol_id, int dire #else rc = 1; - if (private_flags & PRIVATEFLAG_XDRFILE) { + if (private_flags & private_flags::XdrFile) { packageType = UDA_PACKAGE_XDRFILE; } else { packageType = UDA_PACKAGE_STRUCTDATA; } #endif - if ((private_flags & PRIVATEFLAG_XDRFILE) == 0 && packageType == UDA_PACKAGE_STRUCTDATA) { + if ((private_flags & private_flags::XdrFile) == 0 && packageType == UDA_PACKAGE_STRUCTDATA) { option = 1; - } else if ((private_flags & PRIVATEFLAG_XDRFILE) == 0 && packageType == UDA_PACKAGE_XDRFILE && + } else if ((private_flags & private_flags::XdrFile) == 0 && packageType == UDA_PACKAGE_XDRFILE && protocolVersion >= 5) { option = 2; } - if ((private_flags & PRIVATEFLAG_XDRFILE) == 1 && packageType == UDA_PACKAGE_XDRFILE && + if ((private_flags & private_flags::XdrFile) == 1 && packageType == UDA_PACKAGE_XDRFILE && protocolVersion >= 5) { option = 3; } - UDA_LOG(UDA_LOG_DEBUG, "protocolXML: {} {}", private_flags & PRIVATEFLAG_XDRFILE, + UDA_LOG(UDA_LOG_DEBUG, "protocolXML: {} {}", private_flags & private_flags::XdrFile, packageType == UDA_PACKAGE_STRUCTDATA); UDA_LOG(UDA_LOG_DEBUG, "protocolXML: Receive data option : {}", option); UDA_LOG(UDA_LOG_DEBUG, "protocolXML: Receive package Type: {}", packageType); @@ -328,7 +328,7 @@ int uda::client_server::protocol_xml(XDR* xdrs, ProtocolId protocol_id, int dire // Read xdr file without unpacking the structures - char tempFile[MAXPATH] = "/tmp/idamXDRXXXXXX"; + char tempFile[MaxPath] = "/tmp/idamXDRXXXXXX"; if (option == 3) { @@ -518,7 +518,7 @@ int uda::client_server::protocol_xml(XDR* xdrs, ProtocolId protocol_id, int dire // Create a temporary XDR file, receive and write data to the file - char tempFile[MAXPATH] = "/tmp/idamXDRXXXXXX"; + char tempFile[MaxPath] = "/tmp/idamXDRXXXXXX"; errno = 0; if (mkstemp(tempFile) < 0 || errno != 0) { @@ -536,7 +536,7 @@ int uda::client_server::protocol_xml(XDR* xdrs, ProtocolId protocol_id, int dire err = receive_xdr_file(xdrs, tempFile); // Receive and write the file - if (private_flags & PRIVATEFLAG_XDRFILE) { // Forward the file (option 3) again + if (private_flags & private_flags::XdrFile) { // Forward the file (option 3) again // If this is an intermediate client then read the file without unpacking the structures diff --git a/source/clientserver/protocolXML2.cpp b/source/clientserver/protocolXML2.cpp index 7aa744c0..03c45358 100644 --- a/source/clientserver/protocolXML2.cpp +++ b/source/clientserver/protocolXML2.cpp @@ -124,7 +124,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, int dir int hashSize = MAX_ELEMENT_SHA1; unsigned char mdr[MAX_ELEMENT_SHA1]; // SHA1 Hash of data received - if ((private_flags & PRIVATEFLAG_XDRFILE) && protocolVersion >= 5) { // Intermediate XDR File, not stream + if ((private_flags & private_flags::XdrFile) && protocolVersion >= 5) { // Intermediate XDR File, not stream if ((env = getenv("UDA_WORK_DIR")) != nullptr) { // File to record XDR encoded data temp_file = fmt::format("{}/idamXDRXXXXXX", env); @@ -215,7 +215,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, int dir UDA_LOG(UDA_LOG_DEBUG, "private_flags : {} ", private_flags); UDA_LOG(UDA_LOG_DEBUG, "protocolVersion: {} ", protocolVersion); - if ((private_flags & PRIVATEFLAG_XDRFILE) && + if ((private_flags & private_flags::XdrFile) && protocolVersion >= 5) { // Server calling another server // Create a temporary or cached XDR file @@ -252,7 +252,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, int dir xdrstdio_create(&XDROutput, xdrfile, XDR_ENCODE); xdrs = &XDROutput; // Switch from TCP stream to file based object - } else if ((private_flags & PRIVATEFLAG_XDROBJECT) && protocolVersion >= 7) { + } else if ((private_flags & private_flags::XdrObject) && protocolVersion >= 7) { // Create a memory stream file // Write the serialised data into a data object using a stdio xdr stream @@ -355,7 +355,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, int dir #ifndef FATCLIENT - if ((private_flags & PRIVATEFLAG_XDRFILE) && + if ((private_flags & private_flags::XdrFile) && protocolVersion >= 5) { // Server calling another server // Close the stream and file @@ -382,7 +382,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, int dir break; } - } else if ((private_flags & PRIVATEFLAG_XDROBJECT) && + } else if ((private_flags & private_flags::XdrObject) && protocolVersion >= 7) { // Server calling another server // Close the stream and file @@ -446,16 +446,16 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, int dir UDA_LOG(UDA_LOG_DEBUG, "Receiving from Server"); // 5 valid options: - // 1> unpack structures, no xdr file involved => private_flags & PRIVATEFLAG_XDRFILE == 0 && + // 1> unpack structures, no xdr file involved => private_flags & private_flags::XdrFile == 0 && // packageType == PACKAGE_STRUCTDATA 2> unpack structures, from an xdr file => - // private_flags & PRIVATEFLAG_XDRFILE == 0 && packageType == PACKAGE_XDRFILE 3> xdr file only, - // no unpacking, passforward => private_flags & PRIVATEFLAG_XDRFILE && packageType == - // PACKAGE_XDRFILE 4> Error => private_flags & PRIVATEFLAG_XDRFILE && + // private_flags & private_flags::XdrFile == 0 && packageType == PACKAGE_XDRFILE 3> xdr file only, + // no unpacking, passforward => private_flags & private_flags::XdrFile && packageType == + // PACKAGE_XDRFILE 4> Error => private_flags & private_flags::XdrFile && // (packageType == PACKAGE_STRUCTDATA || packageType == PACKAGE_XDROBJECT) 5> unpack structures, - // from an xdr object => private_flags & PRIVATEFLAG_XDROBJECT == 0 && packageType == + // from an xdr object => private_flags & private_flags::XdrObject == 0 && packageType == // PACKAGE_XDROBJECT 6> xdr object only, no unpacking, passforward => private_flags & - // PRIVATEFLAG_XDROBJECT && packageType == PACKAGE_XDROBJECT 4> Error => - // private_flags & PRIVATEFLAG_XDROBJECT && (packageType == PACKAGE_STRUCTDATA || + // private_flags::XdrObject && packageType == PACKAGE_XDROBJECT 4> Error => + // private_flags & private_flags::XdrObject && (packageType == PACKAGE_STRUCTDATA || // packageType == PACKAGE_XDRFILE) // Data Object Caching rules: @@ -487,39 +487,39 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, int dir #else rc = 1; - if (private_flags & PRIVATEFLAG_XDRFILE) { + if (private_flags & private_flags::XdrFile) { packageType = UDA_PACKAGE_XDRFILE; - } else if (private_flags & PRIVATEFLAG_XDROBJECT) { + } else if (private_flags & private_flags::XdrObject) { packageType = UDA_PACKAGE_XDROBJECT; - } else if (private_flags & PRIVATEFLAG_XDROBJECT) { + } else if (private_flags & private_flags::XdrObject) { packageType = UDA_PACKAGE_XDROBJECT; } else { packageType = UDA_PACKAGE_STRUCTDATA; } #endif - if ((private_flags & PRIVATEFLAG_XDRFILE) == 0 && packageType == UDA_PACKAGE_STRUCTDATA) { + if ((private_flags & private_flags::XdrFile) == 0 && packageType == UDA_PACKAGE_STRUCTDATA) { option = 1; } - if ((private_flags & PRIVATEFLAG_XDRFILE) == 0 && packageType == UDA_PACKAGE_XDRFILE && + if ((private_flags & private_flags::XdrFile) == 0 && packageType == UDA_PACKAGE_XDRFILE && protocolVersion >= 5) { option = 2; } - if ((private_flags & PRIVATEFLAG_XDRFILE) == PRIVATEFLAG_XDRFILE && + if ((private_flags & private_flags::XdrFile) == private_flags::XdrFile && packageType == UDA_PACKAGE_XDRFILE && protocolVersion >= 5) { option = 3; } - if ((private_flags & PRIVATEFLAG_XDROBJECT) == 0 && packageType == UDA_PACKAGE_XDROBJECT && + if ((private_flags & private_flags::XdrObject) == 0 && packageType == UDA_PACKAGE_XDROBJECT && protocolVersion >= 7) { option = 5; } - if ((private_flags & PRIVATEFLAG_XDROBJECT) == PRIVATEFLAG_XDROBJECT && + if ((private_flags & private_flags::XdrObject) == private_flags::XdrObject && packageType == UDA_PACKAGE_XDROBJECT && protocolVersion >= 7) { option = 6; } - UDA_LOG(UDA_LOG_DEBUG, "{} {} {}", private_flags & PRIVATEFLAG_XDRFILE, - packageType == UDA_PACKAGE_STRUCTDATA, private_flags & PRIVATEFLAG_XDROBJECT); + UDA_LOG(UDA_LOG_DEBUG, "{} {} {}", private_flags & private_flags::XdrFile, + packageType == UDA_PACKAGE_STRUCTDATA, private_flags & private_flags::XdrObject); UDA_LOG(UDA_LOG_DEBUG, "Receive data option : {}", option); UDA_LOG(UDA_LOG_DEBUG, "Receive package Type: {}", packageType); @@ -865,7 +865,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, int dir // ERROR } - if (private_flags & PRIVATEFLAG_XDROBJECT) { // Forward the object again + if (private_flags & private_flags::XdrObject) { // Forward the object again data_block->data = nullptr; // No Data - not unpacked data_block->opaque_block = @@ -992,7 +992,7 @@ int uda::client_server::protocol_xml2(XDR* xdrs, ProtocolId protocol_id, int dir err = receive_xdr_file(xdrs, temp_file.c_str()); // Receive and write the file - if (private_flags & PRIVATEFLAG_XDRFILE) { // Forward the file (option 3) again + if (private_flags & private_flags::XdrFile) { // Forward the file (option 3) again // If this is an intermediate client then read the file without unpacking the structures diff --git a/source/clientserver/protocolXML2Put.cpp b/source/clientserver/protocolXML2Put.cpp index 7c8988f1..d65ded35 100644 --- a/source/clientserver/protocolXML2Put.cpp +++ b/source/clientserver/protocolXML2Put.cpp @@ -1646,7 +1646,7 @@ int uda::client_server::protocol_xml2_put(XDR* xdrs, ProtocolId protocol_id, int rc = rc && xdr_int(xdrs, &packageType); // Receive data package type - if ((private_flags & PRIVATEFLAG_XDRFILE) == 0 && packageType == UDA_PACKAGE_STRUCTDATA) { + if ((private_flags & private_flags::XdrFile) == 0 && packageType == UDA_PACKAGE_STRUCTDATA) { option = 1; } diff --git a/source/clientserver/socketStructs.h b/source/clientserver/socketStructs.h index 0d7972e0..e4bc517a 100644 --- a/source/clientserver/socketStructs.h +++ b/source/clientserver/socketStructs.h @@ -34,7 +34,7 @@ enum class SocketType : int { typedef struct Sockets { SocketType type; // Type Code - char host[MAXSERVER]; // Server's Host Name or IP Address + char host[MaxServer]; // Server's Host Name or IP Address int port; int status; // Open (1) or Closed (0) int fh; // Socket to Server File Handle diff --git a/source/clientserver/udaDefines.h b/source/clientserver/udaDefines.h index 3df51081..4370a57b 100644 --- a/source/clientserver/udaDefines.h +++ b/source/clientserver/udaDefines.h @@ -1,115 +1,100 @@ #pragma once +namespace uda::client_server { + //-------------------------------------------------------- // Size Definitions -#define WORKDIR tmp // Location of the Work Directories - -#define MAXDATE 12 // Ensure same as DATE_LENGTH -#define MAXNAME 1024 // Same as STRING_LENGTH -#define MAXFILENAME 1024 // Same as STRING_LENGTH -#define MAXSERVER 1024 // Same as STRING_LENGTH -#define MAXPATH 1024 // Same as STRING_LENGTH -#define MAXMODE 8 -#define MAXFORMAT 1024 // Same as STRING_LENGTH - -#define MAXDESC 1024 // Same as STRING_LENGTH -#define MAXNAMELISTREC 1024 - -#define MAXKEY 56 -#define MAXSQL 21 * 1024 -#define MAXRECLENGTH 256 - -#define MAXMETA 10 * 1024 - -#define MAXERRPARAMS 8 - -#define MAXRANK2 10 // Number of subsetting dimensions - -#define UDA_SXML_MAX_STRING 1024 -#define UDA_MAX_DATA_RANK 8 -#define UDA_XML_MAX_DESC 1024 -#define UDA_XML_MAX_RECURSIVE 10 -#define UDA_XML_MAX_LOOP 1024 - -#define UDA_DIM_CALIBRATION_TYPE 1 // Identifies Dimension Union Structures -#define UDA_DIM_COMPOSITE_TYPE 2 -#define UDA_DIM_DOCUMENTATION_TYPE 3 -#define UDA_DIM_ERROR_MODEL_TYPE 4 - -#define UDA_TIME_OFFSET_TYPE 1 // Identifies Action Union Structures -#define UDA_DOCUMENTATION_TYPE 2 -#define UDA_CALIBRATION_TYPE 3 -#define UDA_COMPOSITE_TYPE 4 -#define UDA_ERROR_MODEL_TYPE 5 -#define UDA_SERVER_SIDE_TYPE 6 -#define UDA_SUBSET_TYPE 7 -#define UDA_MAP_TYPE 8 - -#define NUMSIGNALS 2048 -#define NUMPULSES 2048 - -#define MAXNAMARRAY 1024 -#define MAXVARNAME 56 -#define MAXVARVALUE 56 - -#define MAXFILES 2048 -#define MAXDIRS 2048 -#define MAXITEM 12 - -// #define MINYEAR "1980" // for Date Problems +constexpr unsigned int StringLength = 1024; +constexpr unsigned int MaxStringLength = StringLength; // Ensure same as StringLength +constexpr unsigned int DateLength = 1024; + +constexpr int MaxDate = 12; +constexpr int MaxName = StringLength; +constexpr int MaxFilename = StringLength; +constexpr int MaxServer = StringLength; +constexpr int MaxPath = StringLength; +constexpr int MaxFormat = StringLength; +constexpr int MaxDesc = StringLength; +constexpr int MaxMeta = 10 * StringLength; + +constexpr int MaxErrParams = 8; + +constexpr int MaxRank2 = 10; // Number of sub-setting dimensions + +constexpr int SxmlMaxString = 1024; +constexpr int MaxDataRank = 8; +constexpr int XmlMaxDesc = 1024; +constexpr int XmlMaxRecursive = 10; +constexpr int XmlMaxLoop = 1024; + +enum class ActionDimType { + Calibration = 1, + Composite = 2, + Documentation = 3, + ErrorModel = 4, +}; -#define MD5_SIZE 16 +enum class ActionType { + Offset = 1, + Documentation = 2, + Calibration = 3, + Composite = 4, + ErrorModel = 5, + ServerSide = 6, + Subset = 7, + Map = 8, +}; -#define STRING_LENGTH 1024 -#define MAX_STRING_LENGTH 1024 // Ensure same as STRING_LENGTH -#define DATE_LENGTH 12 +constexpr int Md5Size = 16; -#define MAXLOOP 10000 -#define MAXBLOCK 1000 // msecs +constexpr int MaxLoop = 10'000; +constexpr int MaxBlock = 1'000; // msecs -#define DB_READ_BLOCK_SIZE 32 * 1024 // 16384 -#define DB_WRITE_BLOCK_SIZE 32 * 1024 // 16384 +constexpr int DBReadBlockSize = 32 * 1024; // 16384 +constexpr int DBWriteBlockSize = 32 * 1024; // 16384 -#define GROWPUTDATABLOCKLIST 10 +constexpr int GrowPutdataBlockList = 10; //-------------------------------------------------------- // Client Specified Properties -#define TIMEOUT 600 // Server Shutdown after this time (Secs) -#define COMPRESS_DIM 1 // Compress regular dimensional data +constexpr int TimeOut = 600; // Server Shutdown after this time (Secs) +constexpr bool CompressDim = true; // Compress regular dimensional data //-------------------------------------------------------- // Private Flags: Properties passed to IDAM clients called by servers (32 bits) -#define PRIVATEFLAG_FULLRESET (unsigned int)-1 // ffff - 0010 Reset flags except EXTERNAL -#define PRIVATEFLAG_XDRFILE \ - (unsigned int)1 // 0001 Use an intermediate file containing the XDR data rather than a data stream -#define PRIVATEFLAG_EXTERNAL (unsigned int)2 // 0010 The originating server is an External Facing server -#define PRIVATEFLAG_CACHE (unsigned int)4 // 0100 Cache all data +namespace private_flags { -#define PRIVATEFLAG_XDROBJECT 8 // 1000 Use an intermediate XDR data object rather than a data stream +constexpr unsigned char FullReset = 0b1111'1101; // Reset flags except EXTERNAL +constexpr unsigned char XdrFile = 0b0000'0001; // Use an intermediate file containing the XDR data rather than a data stream +constexpr unsigned char External = 0b0000'0010; // The originating server is an External Facing server +constexpr unsigned char Cache = 0b0000'0100; // Cache all data +constexpr unsigned char XdrObject = 0b0000'1000; // Use an intermediate XDR data object rather than a data stream + +} //-------------------------------------------------------- -// Client Flags: Client specified local properties (32 bits) - -#define CLIENTFLAG_FULLRESET -1 // ffff Reset flags -#define CLIENTFLAG_ALTDATA 1u // 0000 0001 -#define CLIENTFLAG_XDRFILE 2u // 0000 0010 Use an intermediate file with the XDR data rather than a data stream -#define CLIENTFLAG_CACHE 4u // 0000 0100 Access data from the local cache and write new data to cache -#define CLIENTFLAG_CLOSEDOWN 8u // 0000 1000 Immediate Closedown -#define CLIENTFLAG_XDROBJECT 16u // 0001 0000 Use a XDR object in memory -#define CLIENTFLAG_REUSELASTHANDLE \ - 32u // 0010 0000 Reuse the last issued handle value (for this thread) - assume application has freed heap -#define CLIENTFLAG_FREEREUSELASTHANDLE \ - 64u // 0100 0000 Free the heap associated with the last issued handle and reuse the handle value -#define CLIENTFLAG_FILECACHE 128u // 1000 0000 Access data from and save data to local cache files +// Client Flags: Client specified local properties (32 bit) + +namespace client_flags { + +constexpr unsigned char FullReset = 0b1111'1111; // Reset flags +constexpr unsigned char AltData = 0b0000'0001; +constexpr unsigned char XdrFile = 0b0000'0010; // Use an intermediate file with the XDR data rather than a data stream +constexpr unsigned char Cache = 0b0000'0100; // Access data from the local cache and write new data to cache +constexpr unsigned char CloseDown = 0b0000'1000; // Immediate Closedown +constexpr unsigned char XdrObject = 0b0001'0000; // Use a XDR object in memory +constexpr unsigned char ReuseLastHandle = 0b0010'0000; // Reuse the last issued handle value (for this thread) - assume application has freed heap +constexpr unsigned char FreeReuseLastHandle = 0b0100'0000; // Free the heap associated with the last issued handle and reuse the handle value +constexpr unsigned char FileCache = 0b1000'0000; // Access data from and save data to local cache files + +} //-------------------------------------------------------- // Error Models -namespace uda::client_server { - constexpr unsigned long int ErrorModelSeed = 12345; enum class ErrorModelType : int { @@ -123,26 +108,29 @@ enum class ErrorModelType : int { Undefined = 7, }; -} - //-------------------------------------------------------- // Caching -#define UDA_PLUGIN_NOT_OK_TO_CACHE 0 // Plugin state management incompatible with client side cacheing -#define UDA_PLUGIN_OK_TO_CACHE 1 // Data are OK for the Client to Cache +enum class PluginCachePermission { + NotOkToCache = 0, // Plugin state management incompatible with client side cacheing + OkToCache = 1, // Data are OK for the Client to Cache +}; -#define UDA_PLUGIN_CACHE_DEFAULT UDA_PLUGIN_NOT_OK_TO_CACHE // The cache permission to use as the default +// The cache permission to use as the default +constexpr PluginCachePermission CachePermissionDefault = PluginCachePermission::NotOkToCache; //-------------------------------------------------------- // Character used to separate directory file path elements #ifndef _WIN32 -# define PATH_SEPARATOR "/" +constexpr const char* PathSeparator = "/"; #else -# define PATH_SEPARATOR "\\" +constexpr const char* PathSeparator = r"\\"; #endif //-------------------------------------------------------- // QA Status -#define DEFAULT_STATUS 1 // Default Signal and Data_Source Status value +constexpr int DefaultStatus = 1; // Default Signal and Data_Source Status value + +} diff --git a/source/clientserver/udaStructs.h b/source/clientserver/udaStructs.h index 53cce4b0..9e02c996 100644 --- a/source/clientserver/udaStructs.h +++ b/source/clientserver/udaStructs.h @@ -25,11 +25,11 @@ namespace uda::client_server struct DataSubset { int subsetCount; // Number of defined dimensions to subset - int subset[MAXRANK2]; // If 1 then subset to apply - int start[MAXRANK2]; // Starting Index of each dimension - int stop[MAXRANK2]; // Ending Index of each dimension - int count[MAXRANK2]; // The number of values (sub-samples) read from each dimension - int stride[MAXRANK2]; // The step stride along each dimension + int subset[MaxRank2]; // If 1 then subset to apply + int start[MaxRank2]; // Starting Index of each dimension + int stop[MaxRank2]; // Ending Index of each dimension + int count[MaxRank2]; // The number of values (sub-samples) read from each dimension + int stride[MaxRank2]; // The step stride along each dimension }; struct VLen { @@ -53,12 +53,12 @@ struct DataSystem { int version; int meta_id; char type; - char device_name[MAXNAME]; - char system_name[MAXNAME]; - char system_desc[MAXDESC]; - char creation[MAXDATE]; - char xml[MAXMETA]; - char xml_creation[MAXDATE]; + char device_name[MaxName]; + char system_name[MaxName]; + char system_desc[MaxDesc]; + char creation[MaxDate]; + char xml[MaxMeta]; + char xml_creation[MaxDate]; char _padding[3]; }; @@ -66,11 +66,11 @@ struct SystemConfig { int config_id; int system_id; int meta_id; - char config_name[MAXNAME]; - char config_desc[MAXDESC]; - char creation[MAXDATE]; - char xml[MAXMETA]; - char xml_creation[MAXDATE]; + char config_name[MaxName]; + char config_desc[MaxDesc]; + char creation[MaxDate]; + char xml[MaxMeta]; + char xml_creation[MaxDate]; }; struct DataSource { @@ -88,22 +88,22 @@ struct DataSource { char access; char reprocess; char type; - char source_alias[MAXNAME]; - char pass_date[MAXDATE]; - char archive[MAXNAME]; - char device_name[MAXNAME]; - char format[MAXFORMAT]; - char path[MAXPATH]; - char filename[MAXFILENAME]; - char server[MAXSERVER]; - char userid[MAXNAME]; - char reason_desc[MAXDESC]; - char run_desc[MAXMETA]; - char status_desc[MAXMETA]; - char creation[MAXDATE]; - char modified[MAXDATE]; - char xml[MAXMETA]; - char xml_creation[MAXDATE]; + char source_alias[MaxName]; + char pass_date[MaxDate]; + char archive[MaxName]; + char device_name[MaxName]; + char format[MaxFormat]; + char path[MaxPath]; + char filename[MaxFilename]; + char server[MaxServer]; + char userid[MaxName]; + char reason_desc[MaxDesc]; + char run_desc[MaxMeta]; + char status_desc[MaxMeta]; + char creation[MaxDate]; + char modified[MaxDate]; + char xml[MaxMeta]; + char xml_creation[MaxDate]; char _padding[1]; }; @@ -117,11 +117,11 @@ struct Signal { int status_impact_code; char access; char reprocess; - char status_desc[MAXMETA]; - char creation[MAXDATE]; - char modified[MAXDATE]; - char xml[MAXMETA]; - char xml_creation[MAXDATE]; + char status_desc[MaxMeta]; + char creation[MaxDate]; + char modified[MaxDate]; + char xml[MaxMeta]; + char xml_creation[MaxDate]; char _padding[2]; }; @@ -132,17 +132,17 @@ struct SignalDesc { int range_start; int range_stop; char type; - char source_alias[MAXNAME]; - char signal_alias[MAXNAME]; - char signal_name[MAXNAME]; - char generic_name[MAXNAME]; - char description[MAXDESC]; - char signal_class[MAXDESC]; - char signal_owner[MAXDESC]; - char creation[MAXDATE]; - char modified[MAXDATE]; - char xml[MAXMETA]; - char xml_creation[MAXDATE]; + char source_alias[MaxName]; + char signal_alias[MaxName]; + char signal_name[MaxName]; + char generic_name[MaxName]; + char description[MaxDesc]; + char signal_class[MaxDesc]; + char signal_owner[MaxDesc]; + char creation[MaxDate]; + char modified[MaxDate]; + char xml[MaxMeta]; + char xml_creation[MaxDate]; char _padding[3]; int signal_alias_type; int signal_map_id; @@ -171,10 +171,10 @@ struct Dims { char* errhi; // Dimension Error Array (Errors above the line: data + error) char* errlo; // Dimension Error Array (Errors below the line: data - error) - float errparams[MAXERRPARAMS]; // the array of model parameters + float errparams[MaxErrParams]; // the array of model parameters - char dim_units[STRING_LENGTH]; - char dim_label[STRING_LENGTH]; + char dim_units[StringLength]; + char dim_label[StringLength]; }; struct SecurityBlock { @@ -196,7 +196,7 @@ struct SecurityBlock { struct ClientBlock { int version; int pid; // Client Application process id - char uid[STRING_LENGTH]; // Who the Client is (claim of identity to the first server) + char uid[StringLength]; // Who the Client is (claim of identity to the first server) // Server properties set by the client @@ -221,10 +221,10 @@ struct ClientBlock { unsigned int privateFlags; // set of private flags used to communicate server to server - char OSName[STRING_LENGTH]; // Name of the Client side Operating System, e.g. OSX - char DOI[STRING_LENGTH]; // User's research DOI - to be logged with all data access requests + char OSName[StringLength]; // Name of the Client side Operating System, e.g. OSX + char DOI[StringLength]; // User's research DOI - to be logged with all data access requests - char uid2[STRING_LENGTH]; // Who the Client is (claim of identity to the last server) + char uid2[StringLength]; // Who the Client is (claim of identity to the last server) SecurityBlock securityBlock; // Contains encrypted tokens exchanged between client and server for mutual authentication }; @@ -249,13 +249,13 @@ struct DataBlock { char* errhi; // Error Array (Errors above the line: data + error) char* errlo; // Error Array (Errors below the line: data - error) - float errparams[MAXERRPARAMS]; // the array of model parameters + float errparams[MaxErrParams]; // the array of model parameters - char data_units[STRING_LENGTH]; - char data_label[STRING_LENGTH]; - char data_desc[STRING_LENGTH]; + char data_units[StringLength]; + char data_label[StringLength]; + char data_desc[StringLength]; - char error_msg[STRING_LENGTH]; + char error_msg[StringLength]; Dims* dims; DataSystem* data_system; @@ -312,8 +312,8 @@ enum class ErrorType; struct UdaError { ErrorType type; // Error Classification int code; // Error Code - char location[STRING_LENGTH]; // Where this Error is Located - char msg[STRING_LENGTH]; // Message + char location[StringLength]; // Where this Error is Located + char msg[StringLength]; // Message }; struct ErrorStack : UDA_ERROR_STACK { @@ -324,11 +324,11 @@ struct ErrorStack : UDA_ERROR_STACK { struct ServerBlock { int version; int error; - char msg[STRING_LENGTH]; + char msg[StringLength]; int pid; // Server Application process id ErrorStack idamerrorstack; - char OSName[STRING_LENGTH]; // Name of the Server's Operating System, e.g. OSX - char DOI[STRING_LENGTH]; // Server version/implementation DOI - to be logged with all data consumers + char OSName[StringLength]; // Name of the Server's Operating System, e.g. OSX + char DOI[StringLength]; // Server version/implementation DOI - to be logged with all data consumers SecurityBlock securityBlock; // Contains encrypted tokens exchanged between client and server for mutual authentication }; @@ -405,34 +405,34 @@ struct Subset { int nbound; // the Number of Subsetting Operations int reform; // reduce Rank if any dimension has length 1 int order; // Time Dimension order - double bound[UDA_MAX_DATA_RANK]; // Array of Floating point Bounding values - OptionalLong stride[UDA_MAX_DATA_RANK]; // Array of Integer values: Striding values - OptionalLong ubindex[UDA_MAX_DATA_RANK]; // Array of Integer values: Bounding or Upper Index - OptionalLong lbindex[UDA_MAX_DATA_RANK]; // Array of Integer values: Lower Index - char operation[UDA_MAX_DATA_RANK][UDA_SXML_MAX_STRING]; // Array of Subsetting Operations - int dimid[UDA_MAX_DATA_RANK]; // Array of Dimension IDs to subset - bool isindex[UDA_MAX_DATA_RANK]; // Flag the Operation Bound is an Integer Type - char data_signal[UDA_SXML_MAX_STRING]; // Name of Signal to subset - char member[UDA_SXML_MAX_STRING]; // Name of Structure Member to extract and to subset - char function[UDA_SXML_MAX_STRING]; // Apply this named function to the subsetted data + double bound[MaxDataRank]; // Array of Floating point Bounding values + OptionalLong stride[MaxDataRank]; // Array of Integer values: Striding values + OptionalLong ubindex[MaxDataRank]; // Array of Integer values: Bounding or Upper Index + OptionalLong lbindex[MaxDataRank]; // Array of Integer values: Lower Index + char operation[MaxDataRank][SxmlMaxString]; // Array of Subsetting Operations + int dimid[MaxDataRank]; // Array of Dimension IDs to subset + bool isindex[MaxDataRank]; // Flag the Operation Bound is an Integer Type + char data_signal[SxmlMaxString]; // Name of Signal to subset + char member[SxmlMaxString]; // Name of Structure Member to extract and to subset + char function[SxmlMaxString]; // Apply this named function to the subsetted data }; struct RequestData { int request; // Plugin or Shutdown Server int exp_number; // Pulse No.,Tree No., etc int pass; // Pass, Sequence, etc - char tpass[STRING_LENGTH]; // - char path[STRING_LENGTH]; // Path to File, Path to Node - char file[STRING_LENGTH]; // File name, Tree name - char format[STRING_LENGTH]; // File Format - char signal[MAXMETA]; // Signal, Node etc - char archive[STRING_LENGTH]; // Archive: pr98, transp, etc - char device_name[STRING_LENGTH]; // Device name: Mast, Jet, etc - char server[STRING_LENGTH]; // UDA, MDS+ Server - char source[STRING_LENGTH]; // Data Source, Server Host, URL etc - char function[STRING_LENGTH]; // Server-Side function or attached plugin function - char api_delim[MAXNAME]; // Delimiter string to use decoding the signal and source arguments - char subset[STRING_LENGTH]; // Subset instructions + char tpass[StringLength]; // + char path[StringLength]; // Path to File, Path to Node + char file[StringLength]; // File name, Tree name + char format[StringLength]; // File Format + char signal[MaxMeta]; // Signal, Node etc + char archive[StringLength]; // Archive: pr98, transp, etc + char device_name[StringLength]; // Device name: Mast, Jet, etc + char server[StringLength]; // UDA, MDS+ Server + char source[StringLength]; // Data Source, Server Host, URL etc + char function[StringLength]; // Server-Side function or attached plugin function + char api_delim[MaxName]; // Delimiter string to use decoding the signal and source arguments + char subset[StringLength]; // Subset instructions Subset datasubset; // Parsed subset instructions (Server Side) NameValueList nameValueList; // Set of Name-Value pairs (Server Side Function) diff --git a/source/clientserver/userid.cpp b/source/clientserver/userid.cpp index 969aa1fd..de6b127b 100644 --- a/source/clientserver/userid.cpp +++ b/source/clientserver/userid.cpp @@ -20,7 +20,7 @@ using namespace uda::client_server; void uda::client_server::user_id(char* uid) { #ifdef _WIN32 - DWORD size = STRING_LENGTH - 1; + DWORD size = StringLength - 1; GetUserName(uid, &size); return; #else @@ -28,13 +28,13 @@ void uda::client_server::user_id(char* uid) uid[0] = '\0'; # if defined(cuserid) if ((user = cuserid(nullptr)) != nullptr) { - copy_string(user, uid, STRING_LENGTH); + copy_string(user, uid, StringLength); return; } else # endif if ((user = getlogin()) != nullptr || (user = getenv("USER")) != nullptr || (user = getenv("LOGNAME")) != nullptr) { - copy_string(user, uid, STRING_LENGTH); + copy_string(user, uid, StringLength); return; } #endif // _WIN32 diff --git a/source/clientserver/xdrlib.cpp b/source/clientserver/xdrlib.cpp index c854d28a..ff5ab88f 100644 --- a/source/clientserver/xdrlib.cpp +++ b/source/clientserver/xdrlib.cpp @@ -65,7 +65,7 @@ int uda::client_server::protocol_version_type_test(int protocol_version, int typ int uda::client_server::wrap_string(XDR* xdrs, char* sp) { - return xdr_string(xdrs, &sp, MAX_STRING_LENGTH); + return xdr_string(xdrs, &sp, MaxStringLength); } int uda::client_server::wrap_xdr_string(XDR* xdrs, const char* sp, int maxlen) @@ -151,7 +151,7 @@ bool_t uda::client_server::xdr_security_block2(XDR* xdrs, SecurityBlock* str) bool_t uda::client_server::xdr_client(XDR* xdrs, ClientBlock* str, int protocolVersion) { int rc = xdr_int(xdrs, &str->version) && xdr_int(xdrs, &str->pid) && xdr_int(xdrs, &str->timeout) && - wrap_xdr_string(xdrs, (char*)str->uid, STRING_LENGTH); + wrap_xdr_string(xdrs, (char*)str->uid, StringLength); if (str->version < protocolVersion) { protocolVersion = str->version; @@ -191,11 +191,11 @@ bool_t uda::client_server::xdr_client(XDR* xdrs, ClientBlock* str, int protocolV } if (protocolVersion >= 7) { - rc = rc && wrap_xdr_string(xdrs, (char*)str->OSName, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->DOI, STRING_LENGTH); + rc = rc && wrap_xdr_string(xdrs, (char*)str->OSName, StringLength) && + wrap_xdr_string(xdrs, (char*)str->DOI, StringLength); #ifdef SECURITYENABLED - rc = rc && wrap_xdr_string(xdrs, (char*)str->uid2, STRING_LENGTH); + rc = rc && wrap_xdr_string(xdrs, (char*)str->uid2, StringLength); #endif } @@ -234,17 +234,17 @@ bool_t uda::client_server::xdr_server1(XDR* xdrs, ServerBlock* str, int protocol rc = rc && xdr_u_int(xdrs, &str->idamerrorstack.nerrors); UDA_LOG(UDA_LOG_DEBUG, "Server #1 rc[3] = {}, error = {}", rc, str->idamerrorstack.nerrors); - rc = rc && wrap_xdr_string(xdrs, (char*)str->msg, STRING_LENGTH); + rc = rc && wrap_xdr_string(xdrs, (char*)str->msg, StringLength); UDA_LOG(UDA_LOG_DEBUG, "Server #1 rc[4] = {}, strlen = {}", rc, strlen(str->msg)); UDA_LOG(UDA_LOG_DEBUG, "str->msg = {}", str->msg); UDA_LOG(UDA_LOG_DEBUG, "str->msg[0] = {}", str->msg[0]); - UDA_LOG(UDA_LOG_DEBUG, "maxsize = {}", STRING_LENGTH); + UDA_LOG(UDA_LOG_DEBUG, "maxsize = {}", StringLength); UDA_LOG(UDA_LOG_DEBUG, "Server #1 protocolVersion {} [rc = {}]", protocolVersion, rc); if ((xdrs->x_op == XDR_DECODE && protocolVersion >= 7) || (xdrs->x_op == XDR_ENCODE && protocolVersion >= 7)) { - rc = rc && wrap_xdr_string(xdrs, (char*)str->OSName, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->DOI, STRING_LENGTH); + rc = rc && wrap_xdr_string(xdrs, (char*)str->OSName, StringLength) && + wrap_xdr_string(xdrs, (char*)str->DOI, StringLength); #ifdef SECURITYENABLED // rc = rc && xdr_securityBlock(xdrs, &str->securityBlock); #endif @@ -261,8 +261,8 @@ bool_t uda::client_server::xdr_server2(XDR* xdrs, ServerBlock* str) for (unsigned int i = 0; i < str->idamerrorstack.nerrors; i++) { rc = rc && xdr_int(xdrs, (int*)&str->idamerrorstack.idamerror[i].type) && xdr_int(xdrs, &str->idamerrorstack.idamerror[i].code) && - wrap_xdr_string(xdrs, (char*)str->idamerrorstack.idamerror[i].location, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->idamerrorstack.idamerror[i].msg, STRING_LENGTH); + wrap_xdr_string(xdrs, (char*)str->idamerrorstack.idamerror[i].location, StringLength) && + wrap_xdr_string(xdrs, (char*)str->idamerrorstack.idamerror[i].msg, StringLength); UDA_LOG(UDA_LOG_DEBUG, "xdr_server2 [{}] {}", i, str->idamerrorstack.idamerror[i].msg); } @@ -275,7 +275,7 @@ bool_t uda::client_server::xdr_server2(XDR* xdrs, ServerBlock* str) bool_t uda::client_server::xdr_server(XDR* xdrs, ServerBlock* str) { return xdr_int(xdrs, &str->version) && xdr_int(xdrs, &str->error) && - wrap_xdr_string(xdrs, (char*)str->msg, STRING_LENGTH); + wrap_xdr_string(xdrs, (char*)str->msg, StringLength); } //----------------------------------------------------------------------- @@ -288,19 +288,19 @@ bool_t uda::client_server::xdr_request_data(XDR* xdrs, RequestData* str, int pro 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); - rc = rc && wrap_xdr_string(xdrs, (char*)str->archive, STRING_LENGTH); - rc = rc && wrap_xdr_string(xdrs, (char*)str->device_name, STRING_LENGTH); - rc = rc && wrap_xdr_string(xdrs, (char*)str->server, STRING_LENGTH); - rc = rc && wrap_xdr_string(xdrs, (char*)str->path, STRING_LENGTH); - rc = rc && wrap_xdr_string(xdrs, (char*)str->file, STRING_LENGTH); - rc = rc && wrap_xdr_string(xdrs, (char*)str->format, STRING_LENGTH); + rc = rc && wrap_xdr_string(xdrs, (char*)str->tpass, StringLength); + rc = rc && wrap_xdr_string(xdrs, (char*)str->archive, StringLength); + rc = rc && wrap_xdr_string(xdrs, (char*)str->device_name, StringLength); + rc = rc && wrap_xdr_string(xdrs, (char*)str->server, StringLength); + rc = rc && wrap_xdr_string(xdrs, (char*)str->path, StringLength); + rc = rc && wrap_xdr_string(xdrs, (char*)str->file, StringLength); + rc = rc && wrap_xdr_string(xdrs, (char*)str->format, StringLength); - rc = rc && wrap_xdr_string(xdrs, (char*)str->signal, MAXMETA); + rc = rc && wrap_xdr_string(xdrs, (char*)str->signal, MaxMeta); if ((xdrs->x_op == XDR_DECODE && protocolVersion >= 6) || (xdrs->x_op == XDR_ENCODE && protocolVersion >= 6)) { - rc = rc && wrap_xdr_string(xdrs, (char*)str->source, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->api_delim, MAXNAME); + rc = rc && wrap_xdr_string(xdrs, (char*)str->source, StringLength) && + wrap_xdr_string(xdrs, (char*)str->api_delim, MaxName); } if (protocolVersion >= 7) { @@ -577,10 +577,10 @@ bool_t uda::client_server::xdr_data_block1(XDR* xdrs, DataBlock* str, int protoc rc = rc && xdr_int(xdrs, &str->errcode); rc = rc && xdr_int(xdrs, &str->source_status); rc = rc && xdr_int(xdrs, &str->signal_status); - rc = rc && wrap_xdr_string(xdrs, (char*)str->data_units, STRING_LENGTH); - rc = rc && wrap_xdr_string(xdrs, (char*)str->data_label, STRING_LENGTH); - rc = rc && wrap_xdr_string(xdrs, (char*)str->data_desc, STRING_LENGTH); - rc = rc && wrap_xdr_string(xdrs, (char*)str->error_msg, STRING_LENGTH); + rc = rc && wrap_xdr_string(xdrs, (char*)str->data_units, StringLength); + rc = rc && wrap_xdr_string(xdrs, (char*)str->data_label, StringLength); + rc = rc && wrap_xdr_string(xdrs, (char*)str->data_desc, StringLength); + rc = rc && wrap_xdr_string(xdrs, (char*)str->error_msg, StringLength); // output (ENCODE) means written by the server // input (DECODE) means read by the client @@ -754,8 +754,8 @@ bool_t uda::client_server::xdr_data_dim1(XDR* xdrs, DataBlock* str) xdr_int(xdrs, &str->dims[i].compressed) && xdr_double(xdrs, &str->dims[i].dim0) && xdr_double(xdrs, &str->dims[i].diff) && xdr_int(xdrs, &str->dims[i].method) && xdr_u_int(xdrs, &str->dims[i].udoms) && - wrap_xdr_string(xdrs, (char*)str->dims[i].dim_units, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->dims[i].dim_label, STRING_LENGTH); + wrap_xdr_string(xdrs, (char*)str->dims[i].dim_units, StringLength) && + wrap_xdr_string(xdrs, (char*)str->dims[i].dim_label, StringLength); } return rc; @@ -1384,12 +1384,12 @@ bool_t uda::client_server::xdr_data_dim4(XDR* xdrs, DataBlock* str) bool_t uda::client_server::xdr_data_system(XDR* xdrs, DataSystem* str) { return xdr_int(xdrs, &str->system_id) && xdr_int(xdrs, &str->version) && xdr_int(xdrs, &str->meta_id) && - xdr_char(xdrs, &str->type) && wrap_xdr_string(xdrs, (char*)str->device_name, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->system_name, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->system_desc, MAX_STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->creation, DATE_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->xml, MAXMETA) && - wrap_xdr_string(xdrs, (char*)str->xml_creation, DATE_LENGTH); + xdr_char(xdrs, &str->type) && wrap_xdr_string(xdrs, (char*)str->device_name, StringLength) && + wrap_xdr_string(xdrs, (char*)str->system_name, StringLength) && + wrap_xdr_string(xdrs, (char*)str->system_desc, MaxStringLength) && + wrap_xdr_string(xdrs, (char*)str->creation, DateLength) && + wrap_xdr_string(xdrs, (char*)str->xml, MaxMeta) && + wrap_xdr_string(xdrs, (char*)str->xml_creation, DateLength); } //----------------------------------------------------------------------- @@ -1398,11 +1398,11 @@ bool_t uda::client_server::xdr_data_system(XDR* xdrs, DataSystem* str) bool_t uda::client_server::xdr_system_config(XDR* xdrs, SystemConfig* str) { return xdr_int(xdrs, &str->config_id) && xdr_int(xdrs, &str->system_id) && xdr_int(xdrs, &str->meta_id) && - wrap_xdr_string(xdrs, (char*)str->config_name, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->config_desc, MAX_STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->creation, DATE_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->xml, MAXMETA) && - wrap_xdr_string(xdrs, (char*)str->xml_creation, DATE_LENGTH); + wrap_xdr_string(xdrs, (char*)str->config_name, StringLength) && + wrap_xdr_string(xdrs, (char*)str->config_desc, MaxStringLength) && + wrap_xdr_string(xdrs, (char*)str->creation, DateLength) && + wrap_xdr_string(xdrs, (char*)str->xml, MaxMeta) && + wrap_xdr_string(xdrs, (char*)str->xml_creation, DateLength); } //----------------------------------------------------------------------- @@ -1415,22 +1415,22 @@ bool_t uda::client_server::xdr_data_source(XDR* xdrs, DataSource* str) xdr_int(xdrs, &str->exp_number) && xdr_int(xdrs, &str->pass) && xdr_int(xdrs, &str->status) && xdr_int(xdrs, &str->status_reason_code) && xdr_int(xdrs, &str->status_impact_code) && xdr_char(xdrs, &str->access) && xdr_char(xdrs, &str->reprocess) && xdr_char(xdrs, &str->type) && - wrap_xdr_string(xdrs, (char*)str->source_alias, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->pass_date, DATE_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->archive, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->device_name, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->format, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->path, MAX_STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->filename, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->server, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->userid, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->reason_desc, MAX_STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->status_desc, MAXMETA) && - wrap_xdr_string(xdrs, (char*)str->run_desc, MAXMETA) && - wrap_xdr_string(xdrs, (char*)str->creation, DATE_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->modified, DATE_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->xml, MAXMETA) && - wrap_xdr_string(xdrs, (char*)str->xml_creation, DATE_LENGTH); + wrap_xdr_string(xdrs, (char*)str->source_alias, StringLength) && + wrap_xdr_string(xdrs, (char*)str->pass_date, DateLength) && + wrap_xdr_string(xdrs, (char*)str->archive, StringLength) && + wrap_xdr_string(xdrs, (char*)str->device_name, StringLength) && + wrap_xdr_string(xdrs, (char*)str->format, StringLength) && + wrap_xdr_string(xdrs, (char*)str->path, MaxStringLength) && + wrap_xdr_string(xdrs, (char*)str->filename, StringLength) && + wrap_xdr_string(xdrs, (char*)str->server, StringLength) && + wrap_xdr_string(xdrs, (char*)str->userid, StringLength) && + wrap_xdr_string(xdrs, (char*)str->reason_desc, MaxStringLength) && + wrap_xdr_string(xdrs, (char*)str->status_desc, MaxMeta) && + wrap_xdr_string(xdrs, (char*)str->run_desc, MaxMeta) && + wrap_xdr_string(xdrs, (char*)str->creation, DateLength) && + wrap_xdr_string(xdrs, (char*)str->modified, DateLength) && + wrap_xdr_string(xdrs, (char*)str->xml, MaxMeta) && + wrap_xdr_string(xdrs, (char*)str->xml_creation, DateLength); } //----------------------------------------------------------------------- @@ -1442,11 +1442,11 @@ bool_t uda::client_server::xdr_signal(XDR* xdrs, Signal* str) xdr_int(xdrs, &str->status_desc_id) && xdr_int(xdrs, &str->status) && xdr_int(xdrs, &str->status_reason_code) && xdr_int(xdrs, &str->status_impact_code) && xdr_char(xdrs, &str->access) && xdr_char(xdrs, &str->reprocess) && - wrap_xdr_string(xdrs, (char*)str->status_desc, MAXMETA) && - wrap_xdr_string(xdrs, (char*)str->creation, DATE_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->modified, DATE_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->xml, MAXMETA) && - wrap_xdr_string(xdrs, (char*)str->xml_creation, DATE_LENGTH); + wrap_xdr_string(xdrs, (char*)str->status_desc, MaxMeta) && + wrap_xdr_string(xdrs, (char*)str->creation, DateLength) && + wrap_xdr_string(xdrs, (char*)str->modified, DateLength) && + wrap_xdr_string(xdrs, (char*)str->xml, MaxMeta) && + wrap_xdr_string(xdrs, (char*)str->xml_creation, DateLength); } //----------------------------------------------------------------------- @@ -1456,15 +1456,15 @@ bool_t uda::client_server::xdr_signal_desc(XDR* xdrs, SignalDesc* str) { return xdr_int(xdrs, &str->signal_desc_id) && xdr_int(xdrs, &str->meta_id) && xdr_int(xdrs, &str->rank) && xdr_int(xdrs, &str->range_start) && xdr_int(xdrs, &str->range_stop) && xdr_char(xdrs, &str->type) && - wrap_xdr_string(xdrs, (char*)str->source_alias, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->signal_alias, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->signal_name, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->generic_name, STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->description, MAX_STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->signal_class, MAX_STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->signal_owner, MAX_STRING_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->creation, DATE_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->modified, DATE_LENGTH) && - wrap_xdr_string(xdrs, (char*)str->xml, MAXMETA) && - wrap_xdr_string(xdrs, (char*)str->xml_creation, DATE_LENGTH); + wrap_xdr_string(xdrs, (char*)str->source_alias, StringLength) && + wrap_xdr_string(xdrs, (char*)str->signal_alias, StringLength) && + wrap_xdr_string(xdrs, (char*)str->signal_name, StringLength) && + wrap_xdr_string(xdrs, (char*)str->generic_name, StringLength) && + wrap_xdr_string(xdrs, (char*)str->description, MaxStringLength) && + wrap_xdr_string(xdrs, (char*)str->signal_class, MaxStringLength) && + wrap_xdr_string(xdrs, (char*)str->signal_owner, MaxStringLength) && + wrap_xdr_string(xdrs, (char*)str->creation, DateLength) && + wrap_xdr_string(xdrs, (char*)str->modified, DateLength) && + wrap_xdr_string(xdrs, (char*)str->xml, MaxMeta) && + wrap_xdr_string(xdrs, (char*)str->xml_creation, DateLength); } diff --git a/source/include/uda/plugins.h b/source/include/uda/plugins.h index ba9da541..f21dc11d 100644 --- a/source/include/uda/plugins.h +++ b/source/include/uda/plugins.h @@ -53,7 +53,7 @@ typedef void (*ADDIDAMERRORFUNP)(UDA_ERROR_STACK*, int, char*, int, char*); // W // Prototypes -#define UDA_MAX_PATH 1024 // Same as STRING_LENGTH +#define UDA_MAX_PATH 1024 // Same as StringLength LIBRARY_API void udaExpandEnvironmentalVariables(char* path); diff --git a/source/plugins/bytes/md5Sum.cpp b/source/plugins/bytes/md5Sum.cpp index 93c8ade9..65670ec8 100644 --- a/source/plugins/bytes/md5Sum.cpp +++ b/source/plugins/bytes/md5Sum.cpp @@ -4,9 +4,9 @@ * Input Arguments: char *bp Pointer to a Block of Memory * int size Size of the Memory block in Bytes * - * Returns: md5check checksum String of Minimum Length 2*MD5_SIZE+1 + * Returns: md5check checksum String of Minimum Length 2*Md5Size+1 * allocated in the calling routine, e.g., - * char md5check[2*MD5_SIZE+1]=""; + * char md5check[2*Md5Size+1]=""; * * Calls * @@ -26,16 +26,16 @@ void md5Sum(char* bp, int size, char* md5check) { - unsigned char signature[MD5_SIZE] = ""; + unsigned char signature[Md5Size] = ""; MD5_CTX context; MD5_Init(&context); MD5_Update(&context, bp, size); MD5_Final(signature, &context); - md5check[2 * MD5_SIZE] = '\0'; + md5check[2 * Md5Size] = '\0'; - for (i = 0; i < MD5_SIZE; i++) { + for (i = 0; i < Md5Size; i++) { sprintf(md5check + 2 * i, "%02x", signature[i]); } } diff --git a/source/plugins/uda/uda_plugin.cpp b/source/plugins/uda/uda_plugin.cpp index 9985f4e3..f92d8b7f 100644 --- a/source/plugins/uda/uda_plugin.cpp +++ b/source/plugins/uda/uda_plugin.cpp @@ -63,7 +63,7 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface) int version; int pid; // Client Application process id - char uid[STRING_LENGTH]; // Who the Client is + char uid[StringLength]; // Who the Client is // Server properties set by the client @@ -110,13 +110,13 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface) char* errhi; // Error Array (Errors above the line: data + error) char* errlo; // Error Array (Errors below the line: data - error) - float errparams[MAXERRPARAMS]; // the array of model parameters + float errparams[MaxErrParams]; // the array of model parameters - char data_units[STRING_LENGTH]; - char data_label[STRING_LENGTH]; - char data_desc[STRING_LENGTH]; + char data_units[StringLength]; + char data_label[StringLength]; + char data_desc[StringLength]; - char error_msg[STRING_LENGTH]; + char error_msg[StringLength]; Dims* dims; DataSystem* data_system; @@ -173,13 +173,13 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface) //---------------------------------------------------------------------- // Private Flags, User Specified Flags and Properties for the Remote Server - udaResetPrivateFlag(PRIVATEFLAG_FULLRESET); + udaResetPrivateFlag(private_flags::FullReset); // Ensure Hierarchical Data are passed as an opaque object/file - udaSetPrivateFlag(PRIVATEFLAG_XDRFILE); + udaSetPrivateFlag(private_flags::XdrFile); // This fails if the legacy UDA plugin is called by a server in the forward chain and it set marked a 'private' // For IMAS development, this has been disabled - // if(environment.external_user) udaSetPrivateFlag(PRIVATEFLAG_EXTERNAL); // Maintain external user status + // if(environment.external_user) udaSetPrivateFlag(private_flags::External); // Maintain external user status // Set Userid @@ -230,7 +230,7 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface) // Client Flags ... - udaResetClientFlag(CLIENTFLAG_FULLRESET); + udaResetClientFlag(client_flags::FullReset); udaSetClientFlag(client_block->clientFlags); // Client application provenance @@ -304,7 +304,7 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface) } else if (pathway == 2) { - char source[2 * MAXNAME + 2]; + char source[2 * MaxName + 2]; //---------------------------------------------------------------------- // Device redirect or server protocol @@ -422,7 +422,7 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface) } } else if (pathway == 4) { - char source[2 * MAXNAME + 2]; + char source[2 * MaxName + 2]; //---------------------------------------------------------------------- // Server protocol @@ -479,8 +479,8 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface) handle = udaGetAPI(request->signal, source); } - udaResetPrivateFlag(PRIVATEFLAG_FULLRESET); - udaResetClientFlag(CLIENTFLAG_FULLRESET); + udaResetPrivateFlag(private_flags::FullReset); + udaResetClientFlag(client_flags::FullReset); //---------------------------------------------------------------------- // Test for Errors: Close Socket and Free heap @@ -543,7 +543,7 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface) db.errhi = odb->errhi; db.errlo = odb->errlo; - for (int i = 0; i < MAXERRPARAMS; i++) { + for (int i = 0; i < MaxErrParams; i++) { db.errparams[i] = odb->errparams[i]; } diff --git a/source/plugins/udaPluginFiles.h b/source/plugins/udaPluginFiles.h index ff1331e2..53816df0 100644 --- a/source/plugins/udaPluginFiles.h +++ b/source/plugins/udaPluginFiles.h @@ -14,6 +14,8 @@ extern "C" { #endif +#define UDA_FILENAME_LENGTH 1024 + //------------------------------------------------------------------------------------------------------------------------ // Plugins opening files can maintain state by recording file handles in a list. // Two usage patterns are assumed: the file opening function returns an integer or a pointer @@ -23,7 +25,7 @@ extern "C" { typedef struct UdaPluginFile { int status; // Open (1) or Closed (0) - char filename[STRING_LENGTH]; // Full Data Source Filename + char filename[UDA_FILENAME_LENGTH]; // Full Data Source Filename long handleInt; // Integer File Handle void* handlePtr; // Pointer file handle struct timeval file_open; // File Open Clock Time diff --git a/source/server/applyXML.cpp b/source/server/applyXML.cpp index b7c73685..ee178784 100644 --- a/source/server/applyXML.cpp +++ b/source/server/applyXML.cpp @@ -17,11 +17,13 @@ #include #include +#include "clientserver/udaDefines.h" #include "common/stringUtils.h" #include "logging/logging.h" #include using namespace uda::logging; +using namespace uda::client_server; int uda::server::serverParseSignalXML(uda::client_server::DataSource data_source, uda::client_server::Signal signal, uda::client_server::SignalDesc signal_desc, @@ -312,12 +314,12 @@ void uda::server::serverApplySignalXML(uda::client_server::ClientBlock client_bl continue; // Out of Pulse/Pass Range } - switch (actions.action[i].actionType) { + switch ((ActionType)actions.action[i].actionType) { //---------------------------------------------------------------------------------------------- // Documentation Changes: Label/Units Corrections - case UDA_DOCUMENTATION_TYPE: + case ActionType::Documentation: if (strlen(actions.action[i].documentation.label) > 0) { strcpy(data_block->data_label, actions.action[i].documentation.label); } @@ -331,7 +333,7 @@ void uda::server::serverApplySignalXML(uda::client_server::ClientBlock client_bl } for (int j = 0; j < actions.action[i].documentation.ndimensions; j++) { - if (actions.action[i].documentation.dimensions[j].dimType == UDA_DIM_DOCUMENTATION_TYPE) { + if (actions.action[i].documentation.dimensions[j].dimType == (int)ActionDimType::Documentation) { if (actions.action[i].documentation.dimensions[j].dimid > -1 && (unsigned int)actions.action[i].documentation.dimensions[j].dimid < data_block->rank) { if (strlen(actions.action[i].documentation.dimensions[j].dimdocumentation.label) > 0) { @@ -350,7 +352,7 @@ void uda::server::serverApplySignalXML(uda::client_server::ClientBlock client_bl //---------------------------------------------------------------------------------------------- // Error Models (Asymmetry is decided by the model's properties, not by the XML) - case UDA_ERROR_MODEL_TYPE: + case ActionType::ErrorModel: data_block->error_model = actions.action[i].errormodel.model; data_block->error_param_n = actions.action[i].errormodel.param_n; for (int j = 0; j < data_block->error_param_n; j++) { @@ -358,7 +360,7 @@ void uda::server::serverApplySignalXML(uda::client_server::ClientBlock client_bl } for (int j = 0; j < actions.action[i].errormodel.ndimensions; j++) { - if (actions.action[i].errormodel.dimensions[j].dimType == UDA_DIM_ERROR_MODEL_TYPE) { + if (actions.action[i].errormodel.dimensions[j].dimType == (int)ActionDimType::ErrorModel) { if (actions.action[i].errormodel.dimensions[j].dimid > -1 && (unsigned int)actions.action[i].errormodel.dimensions[j].dimid < data_block->rank) { data_block->dims[actions.action[i].errormodel.dimensions[j].dimid].error_model = @@ -385,7 +387,7 @@ void uda::server::serverApplySignalXML(uda::client_server::ClientBlock client_bl // timeoffset.method == 2 => Create a New Time Vector using an interval value only. Use the Original // Starting value if possible. - case UDA_TIME_OFFSET_TYPE: + case ActionType::Offset: if (client_block.get_notoff || data_block->order < 0) { break; @@ -763,7 +765,7 @@ void uda::server::serverApplySignalXML(uda::client_server::ClientBlock client_bl //---------------------------------------------------------------------------------------------- // Calibration Corrections - case UDA_CALIBRATION_TYPE: + case ActionType::Calibration: if (!client_block.get_uncal) { @@ -801,7 +803,7 @@ void uda::server::serverApplySignalXML(uda::client_server::ClientBlock client_bl dimid = actions.action[i].calibration.dimensions[j].dimid; - if (actions.action[i].calibration.dimensions[j].dimType == UDA_DIM_CALIBRATION_TYPE && + if (actions.action[i].calibration.dimensions[j].dimType == (int)ActionDimType::Calibration && actions.action[i].actionId != 0 && dimid > -1 && (unsigned int)dimid < data_block->rank) { if (strlen(actions.action[i].calibration.dimensions[j].dimcalibration.units) > 0) { diff --git a/source/server/createXDRStream.cpp b/source/server/createXDRStream.cpp index 005facc7..03fc646d 100644 --- a/source/server/createXDRStream.cpp +++ b/source/server/createXDRStream.cpp @@ -10,6 +10,8 @@ using namespace uda::authentication; #endif +using namespace uda::client_server; + std::pair uda::server::serverCreateXDRStream(uda::client_server::IoData* io_data) { static XDR server_input = {}; @@ -21,37 +23,37 @@ std::pair uda::server::serverCreateXDRStream(uda::client_server::IoD #if !defined(FATCLIENT) && defined(SSLAUTHENTICATION) if (getUdaServerSSLDisabled()) { # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&server_output, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(server_read), reinterpret_cast(server_write)); - xdrrec_create(&server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&server_input, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(server_read), reinterpret_cast(server_write)); # else - xdrrec_create(&server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&server_output, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(server_read), reinterpret_cast(server_write)); - xdrrec_create(&server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&server_input, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(server_read), reinterpret_cast(server_write)); # endif } else { # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&server_output, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(readUdaServerSSL), reinterpret_cast(writeUdaServerSSL)); - xdrrec_create(&server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&server_input, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(readUdaServerSSL), reinterpret_cast(writeUdaServerSSL)); # else - xdrrec_create(&server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&server_output, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(readUdaServerSSL), reinterpret_cast(writeUdaServerSSL)); - xdrrec_create(&server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&server_input, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(readUdaServerSSL), reinterpret_cast(writeUdaServerSSL)); # endif @@ -59,19 +61,19 @@ std::pair uda::server::serverCreateXDRStream(uda::client_server::IoD #else // SSLAUTHENTICATION # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&server_output, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(server_read), reinterpret_cast(server_write)); - xdrrec_create(&server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, io_data, + xdrrec_create(&server_input, DBReadBlockSize, DBWriteBlockSize, io_data, reinterpret_cast(server_read), reinterpret_cast(server_write)); # else - xdrrec_create(&server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&server_output, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(server_read), reinterpret_cast(server_write)); - xdrrec_create(&server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)io_data, + xdrrec_create(&server_input, DBReadBlockSize, DBWriteBlockSize, (char*)io_data, reinterpret_cast(server_read), reinterpret_cast(server_write)); # endif diff --git a/source/server/fatServer.cpp b/source/server/fatServer.cpp index 7eb64d1b..31a5285b 100644 --- a/source/server/fatServer.cpp +++ b/source/server/fatServer.cpp @@ -109,7 +109,7 @@ int uda::server::fat_server(const Config& config, ClientBlock client_block, Serv init_log_struct_list(&log_struct_list); int server_tot_block_time = 0; - int server_timeout = TIMEOUT; // user specified Server Lifetime + int server_timeout = TimeOut; // user specified Server Lifetime IoData io_data = {}; io_data.server_tot_block_time = &server_tot_block_time; @@ -190,10 +190,10 @@ static int process_hierarchical_data(DataBlock* data_block, LogStructList* log_s // Create an output XDR stream FILE* xdrfile; - char tempFile[MAXPATH]; + char tempFile[MaxPath]; char* env; if ((env = getenv("UDA_WORK_DIR")) != nullptr) { - snprintf(tempFile, MAXPATH, "%s/idamXDRXXXXXX", env); + snprintf(tempFile, MaxPath, "%s/idamXDRXXXXXX", env); } else { strcpy(tempFile, "/tmp/idamXDRXXXXXX"); } @@ -215,7 +215,7 @@ static int process_hierarchical_data(DataBlock* data_block, LogStructList* log_s ProtocolId protocol_id = ProtocolId::Structures; protocol_xml(&xdr_server_output, protocol_id, XDR_SEND, nullptr, log_malloc_list, user_defined_type_list, - data_block, protocol_version, log_struct_list, io_data, private_flags, malloc_source, + data_block, protocol_version, log_struct_list, io_data, ::private_flags, malloc_source, serverCreateXDRStream); // Close the stream and file @@ -241,7 +241,7 @@ static int process_hierarchical_data(DataBlock* data_block, LogStructList* log_s protocol_id = ProtocolId::Structures; err = protocol_xml(&xdr_server_input, protocol_id, XDR_RECEIVE, nullptr, log_malloc_list, user_defined_type_list, - data_block, protocol_version, log_struct_list, io_data, private_flags, malloc_source, + data_block, protocol_version, log_struct_list, io_data, ::private_flags, malloc_source, serverCreateXDRStream); // Close the stream and file diff --git a/source/server/initPluginList.cpp b/source/server/initPluginList.cpp index 56e6c059..c9610415 100644 --- a/source/server/initPluginList.cpp +++ b/source/server/initPluginList.cpp @@ -46,7 +46,7 @@ void uda::server::initPluginList(std::vector& plugin_list) { int rc = 0; char csv_char = ','; - char buffer[STRING_LENGTH]; + char buffer[StringLength]; char* root; char* config = getenv("UDA_PLUGIN_CONFIG"); // Server plugin configuration file FILE* conf = nullptr; @@ -99,7 +99,7 @@ void uda::server::initPluginList(std::vector& plugin_list) cachePermission and publicUse may use one of the following values: "Y|N,1|0,T|F,True|False" */ - while (fgets(buffer, STRING_LENGTH - 1, conf) != nullptr) { + while (fgets(buffer, StringLength - 1, conf) != nullptr) { convert_non_printable2(buffer); left_trim_string(trim_string(buffer)); do { diff --git a/source/server/plugin_api.cpp b/source/server/plugin_api.cpp index 853cb8ce..d4cf47bc 100644 --- a/source/server/plugin_api.cpp +++ b/source/server/plugin_api.cpp @@ -35,7 +35,7 @@ UDA_PLUGIN_INTERFACE* udaCreatePluginInterface(UDA_PLUGIN_INTERFACE* plugin_inte auto plugin_list = old_plugin_interface->pluginList; auto request_data = (RequestData*)calloc(1, sizeof(RequestData)); - copy_string(request, request_data->signal, MAXMETA); + copy_string(request, request_data->signal, MaxMeta); make_request_data(*config, request_data, *plugin_list); auto user_defined_type_list = (UserDefinedTypeList*)calloc(1, sizeof(UserDefinedTypeList)); @@ -78,8 +78,8 @@ template int setReturnDataScalar(UDA_PLUGIN_INTERFACE* plugin_inter data[0] = value; if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } data_block->rank = 0; @@ -99,8 +99,8 @@ int setReturnDataArray(UDA_PLUGIN_INTERFACE* plugin_interface, const T* values, init_data_block(data_block); if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } data_block->rank = (int)rank; @@ -173,8 +173,8 @@ int udaPluginReturnDataStringScalar(UDA_PLUGIN_INTERFACE* plugin_interface, cons } if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } data_block->dims[0].data_type = UDA_TYPE_UNSIGNED_INT; @@ -209,8 +209,8 @@ int udaPluginReturnData(UDA_PLUGIN_INTERFACE* plugin_interface, void* value, siz } if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } for (unsigned int i = 0; i < data_block->rank; i++) { @@ -387,7 +387,7 @@ int udaCallPlugin2(UDA_PLUGIN_INTERFACE* plugin_interface, const char* request, if (request_data.datasubset.nbound > 0) { Action action = {}; init_action(&action); - action.actionType = UDA_SUBSET_TYPE; + action.actionType = (int)ActionType::Subset; action.subset = request_data.datasubset; err = serverSubsetData(new_plugin_interface.data_block, action, new_plugin_interface.logmalloclist); } @@ -416,8 +416,8 @@ int udaPluginReturnCompoundData(UDA_PLUGIN_INTERFACE* plugin_interface, char* da data_block->opaque_block = (void*)udaFindUserDefinedType(interface->userdefinedtypelist, user_type, 0); if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } return 0; @@ -461,8 +461,8 @@ int udaPluginReturnCompoundArrayData(UDA_PLUGIN_INTERFACE* plugin_interface, cha data_block->opaque_block = (void*)udaFindUserDefinedType(interface->userdefinedtypelist, user_type, 0); if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } return 0; diff --git a/source/server/serverGetData.cpp b/source/server/serverGetData.cpp index 79b3730d..2b4ba3be 100644 --- a/source/server/serverGetData.cpp +++ b/source/server/serverGetData.cpp @@ -82,7 +82,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request //-------------------------------------------------------------------------------------------------------------------------- // Limit the Recursive Depth - if (*depth == UDA_XML_MAX_RECURSIVE) { + if (*depth == XmlMaxRecursive) { UDA_THROW_ERROR(7777, "Recursive Depth (Derived or Substitute Data) Exceeds Internal Limit"); } @@ -103,7 +103,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request return rc; } // Erase original Subset request - copy_string(trim_string(request_data->signal), signal_desc->signal_name, MAXNAME); + copy_string(trim_string(request_data->signal), signal_desc->signal_name, MaxName); } } } else if (STR_IEQUALS(request_data->function, "subset")) { @@ -117,7 +117,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request return rc; } // Erase original Subset request - copy_string(trim_string(request_data->signal), signal_desc->signal_name, MAXNAME); + copy_string(trim_string(request_data->signal), signal_desc->signal_name, MaxName); } } } @@ -142,7 +142,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request UDA_LOG(UDA_LOG_DEBUG, "Calling serverSubsetData (Subset) {}", *depth); Action action = {}; init_action(&action); - action.actionType = UDA_SUBSET_TYPE; + action.actionType = (int)ActionType::Subset; action.subset = request_data->datasubset; if ((rc = serverSubsetData(data_block, action, logmalloclist)) != 0) { (*depth)--; @@ -199,7 +199,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request compId = -1; if (rc == 0) { for (int i = 0; i < actions_comp_desc.nactions; i++) { - if (actions_comp_desc.action[i].actionType == UDA_COMPOSITE_TYPE && + if (actions_comp_desc.action[i].actionType == (int)ActionType::Composite && actions_comp_desc.action[i].inRange) { compId = i; break; // First Record found only! @@ -483,7 +483,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request if (isDerived && compId > -1) { for (int i = 0; i < actions_desc->action[compId].composite.ndimensions; i++) { - if (actions_desc->action[compId].composite.dimensions[i].dimType == UDA_DIM_COMPOSITE_TYPE) { + if (actions_desc->action[compId].composite.dimensions[i].dimType == (int)ActionDimType::Composite) { if (strlen(actions_desc->action[compId].composite.dimensions[i].dimcomposite.dim_signal) > 0) { UDA_LOG(UDA_LOG_DEBUG, "Substituting Dimension Data"); @@ -719,7 +719,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request if (!serverside && !isDerived && signal_desc->type == 'S') { for (int i = 0; i < actions_desc->nactions; i++) { - if (actions_desc->action[i].actionType == UDA_SUBSET_TYPE) { + if (actions_desc->action[i].actionType == (int)ActionType::Subset) { UDA_LOG(UDA_LOG_DEBUG, "Calling serverSubsetData (Subset) {}", *depth); print_data_block(*data_block); @@ -736,7 +736,7 @@ int uda::server::get_data(const Config& config, int* depth, RequestData* request if (serverside) { for (int i = 0; i < actions_serverside.nactions; i++) { - if (actions_serverside.action[i].actionType == UDA_SERVER_SIDE_TYPE) { + if (actions_serverside.action[i].actionType == (int)ActionType::ServerSide) { for (int j = 0; j < actions_serverside.action[i].serverside.nsubsets; j++) { UDA_LOG(UDA_LOG_DEBUG, "Calling serverSubsetData (Serverside) {}", *depth); print_data_block(*data_block); @@ -970,7 +970,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo // If err > 0 then an error occured // If err < 0 then unable to read signal because it is a derived type and details are in XML format - char mapping[MAXMETA] = ""; + char mapping[MaxMeta] = ""; print_request_data(*request); @@ -1008,7 +1008,7 @@ 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 != (int)Request::ReadXML && + if (client_block.clientFlags & client_flags::AltData && request->request != (int)Request::ReadXML && STR_STARTSWITH(request->signal, "request != (int)Request::ReadGeneric) { @@ -1047,7 +1047,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo // If the plugin is registered as a FILE or LIBRARY type then call the default method as no method will have // been specified - copy_string(plugin_list[plugin_id].default_method, request->function, STRING_LENGTH); + copy_string(plugin_list[plugin_id].default_method, request->function, StringLength); // Execute the plugin to resolve the identity of the data requested @@ -1101,7 +1101,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo UDA_THROW_ERROR(122, "Unable to Open the XML File defining the signal"); } nchar = 0; - while (!feof(xmlfile) && nchar < MAXMETA) { + while (!feof(xmlfile) && nchar < MaxMeta) { request->signal[nchar++] = (char)getc(xmlfile); } request->signal[nchar - 2] = '\0'; // Remove EOF Character and replace with String Terminator @@ -1264,7 +1264,7 @@ int read_data(const Config& config, RequestData* request, ClientBlock client_blo if (path.string().find(data_source->filename) == std::string::npos) { path /= data_source->filename; - copy_string(path.c_str(), data_source->path, MAXPATH); + copy_string(path.c_str(), data_source->path, MaxPath); } } diff --git a/source/server/serverLegacyPlugin.cpp b/source/server/serverLegacyPlugin.cpp index 239247f4..ef885e9d 100644 --- a/source/server/serverLegacyPlugin.cpp +++ b/source/server/serverLegacyPlugin.cpp @@ -17,7 +17,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so { int err = 0; char* token = nullptr; - char work[STRING_LENGTH]; + char work[StringLength]; UDA_LOG(UDA_LOG_DEBUG, "Start"); @@ -79,7 +79,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so strcpy(data_source->filename, trim_string(request->file)); strcpy(data_source->path, trim_string(request->path)); - copy_string(trim_string(request->signal), signal_desc->signal_name, MAXNAME); + copy_string(trim_string(request->signal), signal_desc->signal_name, MaxName); data_source->exp_number = request->exp_number; data_source->pass = request->pass; @@ -98,7 +98,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so strcpy(data_source->filename, trim_string(request->file)); strcpy(data_source->path, trim_string(request->path)); - copy_string(trim_string(request->signal), signal_desc->signal_name, MAXNAME); + copy_string(trim_string(request->signal), signal_desc->signal_name, MaxName); data_source->exp_number = request->exp_number; data_source->pass = request->pass; @@ -116,10 +116,10 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so strcpy(data_source->filename, trim_string(request->file)); // MDS+ Tree strcpy(data_source->server, trim_string(request->server)); // MDS+ Server Name - copy_string(trim_string(request->signal), signal_desc->signal_name, MAXNAME); + copy_string(trim_string(request->signal), signal_desc->signal_name, MaxName); - if (strlen(signal_desc->signal_name) == MAXNAME - 1) { - copy_string(trim_string(request->signal), signal_desc->xml, MAXMETA); // Pass via XML member + if (strlen(signal_desc->signal_name) == MaxName - 1) { + copy_string(trim_string(request->signal), signal_desc->xml, MaxMeta); // Pass via XML member signal_desc->signal_name[0] = '\0'; } @@ -141,7 +141,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so 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); + copy_string(trim_string(request->signal), signal_desc->signal_name, MaxName); UDA_LOG(UDA_LOG_DEBUG, "Request: readnetCDF"); UDA_LOG(UDA_LOG_DEBUG, "netCDF File : {} ", request->path); @@ -150,7 +150,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so 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); + copy_string(trim_string(request->signal), signal_desc->signal_name, MaxName); UDA_LOG(UDA_LOG_DEBUG, "Request: ReadHDF5"); UDA_LOG(UDA_LOG_DEBUG, "HDF5 File : {} ", request->path); @@ -227,7 +227,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so 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)); - copy_string(trim_string(request->signal), signal_desc->signal_name, MAXNAME); + copy_string(trim_string(request->signal), signal_desc->signal_name, MaxName); data_source->exp_number = request->exp_number; data_source->pass = request->pass; data_source->type = ' '; @@ -241,7 +241,7 @@ int uda::server::udaServerLegacyPlugin(RequestData* request, DataSource* data_so break; case (int)Request::ReadJPF: - copy_string(trim_string(request->signal), signal_desc->signal_name, MAXNAME); + copy_string(trim_string(request->signal), signal_desc->signal_name, MaxName); data_source->exp_number = request->exp_number; UDA_LOG(UDA_LOG_DEBUG, "Request: Read JPF"); diff --git a/source/server/serverPlugin.cpp b/source/server/serverPlugin.cpp index 2f3fab10..6cef1ea7 100644 --- a/source/server/serverPlugin.cpp +++ b/source/server/serverPlugin.cpp @@ -104,8 +104,8 @@ int uda::server::udaServerRedirectStdStreams(int reset) static int original_err_fh = 0; static FILE* mdsmsg_fh = nullptr; - static char mksdir_template[MAXPATH] = {0}; - static char temp_file[MAXPATH] = {0}; + static char mksdir_template[MaxPath] = {0}; + static char temp_file[MaxPath] = {0}; static bool single_file = false; @@ -140,7 +140,7 @@ int uda::server::udaServerRedirectStdStreams(int reset) if (env == nullptr) { if ((env = getenv("UDA_WORK_DIR")) != nullptr) { - snprintf(mksdir_template, MAXPATH, "%s/idamPLUGINXXXXXX", env); + snprintf(mksdir_template, MaxPath, "%s/idamPLUGINXXXXXX", env); } else { strcpy(mksdir_template, "/tmp/idamPLUGINXXXXXX"); } @@ -264,7 +264,7 @@ int uda::server::udaServerPlugin(const uda::config::Config& config, RequestData* strcpy(data_source->filename, trim_string(request->file)); strcpy(data_source->path, trim_string(request->path)); - copy_string(trim_string(request->signal), signal_desc->signal_name, MAXNAME); + copy_string(trim_string(request->signal), signal_desc->signal_name, MaxName); strcpy(data_source->server, trim_string(request->server)); @@ -364,7 +364,7 @@ int uda::server::udaProvenancePlugin(const uda::config::Config& config, ClientBl // mimic a client request if (logRecord == nullptr || strlen(logRecord) == 0) { - snprintf(request.signal, MAXMETA, + snprintf(request.signal, MaxMeta, "%s::putSignal(uuid='%s',requestedSignal='%s',requestedSource='%s', " "trueSignal='%s', trueSource='%s', trueSourceDOI='%s', execMethod=%d, status=new)", plugin_list[plugin_id].name.c_str(), client_block->DOI, original_request->signal, @@ -373,7 +373,7 @@ int uda::server::udaProvenancePlugin(const uda::config::Config& config, ClientBl // need 2> record the server log record - snprintf(request.signal, MAXMETA, "%s::putSignal(uuid='%s',logRecord='%s', execMethod=%d, status=update)", + snprintf(request.signal, MaxMeta, "%s::putSignal(uuid='%s',logRecord='%s', execMethod=%d, status=update)", plugin_list[plugin_id].name.c_str(), client_block->DOI, logRecord, exec_method); } diff --git a/source/server/serverStartup.cpp b/source/server/serverStartup.cpp index 4a52f785..b2e7a436 100644 --- a/source/server/serverStartup.cpp +++ b/source/server/serverStartup.cpp @@ -34,8 +34,8 @@ int uda::server::startup() auto log_mode = config->get("logging.mode").as_or_default("w"s); if (log_level <= UDA_LOG_ACCESS) { - char cmd[STRING_LENGTH]; - snprintf(cmd, STRING_LENGTH, "mkdir -p %s 2>/dev/null", log_dir.c_str()); + char cmd[StringLength]; + snprintf(cmd, StringLength, "mkdir -p %s 2>/dev/null", log_dir.c_str()); if (system(cmd) != 0) { UDA_THROW_ERROR(999, "mkdir command failed"); } diff --git a/source/server/serverSubsetData.cpp b/source/server/serverSubsetData.cpp index bcdc93b6..db81771d 100644 --- a/source/server/serverSubsetData.cpp +++ b/source/server/serverSubsetData.cpp @@ -62,20 +62,20 @@ int apply_sub_setting(Dims* dims, int rank, int dim_id, char* data, int ndata, i int number_of_subsetting_operations(const Action* action) { - switch (action->actionType) { - case UDA_COMPOSITE_TYPE: + switch ((ActionType)action->actionType) { + case ActionType::Composite: // XML Based sub-setting if (action->composite.nsubsets == 0) { return 0; // Nothing to Subset } return action->composite.nsubsets; - case UDA_SERVER_SIDE_TYPE: + case ActionType::ServerSide: // Client Requested sub-setting if (action->serverside.nsubsets == 0) { return 0; // Nothing to Subset } return action->serverside.nsubsets; - case UDA_SUBSET_TYPE: + case ActionType::Subset: // Client Requested sub-setting return 1; default: @@ -1134,7 +1134,7 @@ int apply_count(Subset subset, DataBlock* data_block) } data_block->data = (char*)count; data_block->data_units[0] = '\0'; - snprintf(data_block->data_label, STRING_LENGTH, "count(dim_id=%d)", dim_id); + snprintf(data_block->data_label, StringLength, "count(dim_id=%d)", dim_id); } return 0; @@ -1390,7 +1390,7 @@ int uda::server::serverSubsetData(DataBlock* data_block, const Action& action, L // Check Rank if (data_block->rank > 2 && - !(action.actionType == UDA_SUBSET_TYPE && !strncasecmp(action.subset.function, "rotateRZ", 8))) { + !(action.actionType == (int)ActionType::Subset && !strncasecmp(action.subset.function, "rotateRZ", 8))) { UDA_THROW_ERROR(9999, "Not Configured to Subset Data with Rank Higher than 2"); } @@ -1399,13 +1399,13 @@ int uda::server::serverSubsetData(DataBlock* data_block, const Action& action, L for (int i = 0; i < n_subsets; i++) { // the number of sets of Subset Operations Subset subset; - if (action.actionType == UDA_COMPOSITE_TYPE) { + if (action.actionType == (int)ActionType::Composite) { subset = action.composite.subsets[i]; // the set of Subset Operations } else { - if (action.actionType == UDA_SERVER_SIDE_TYPE) { + if (action.actionType == (int)ActionType::ServerSide) { subset = action.serverside.subsets[i]; } else { - if (action.actionType == UDA_SUBSET_TYPE) { + if (action.actionType == (int)ActionType::Subset) { subset = action.subset; } } @@ -1555,7 +1555,7 @@ int uda::server::serverParseServerSide(RequestData* request_block, Actions* acti init_action(&action[nactions - 1]); - action[nactions - 1].actionType = UDA_SERVER_SIDE_TYPE; + action[nactions - 1].actionType = (int)ActionType::ServerSide; action[nactions - 1].inRange = 1; action[nactions - 1].actionId = nactions; @@ -1629,7 +1629,7 @@ int uda::server::serverParseServerSide(RequestData* request_block, Actions* acti std::vector tokens; boost::split(tokens, op_string, boost::is_any_of(","), boost::token_compress_off); - if (tokens.size() > UDA_MAX_DATA_RANK) { + if (tokens.size() > MaxDataRank) { UDA_THROW_ERROR(9999, "The number of Dimensional Operations exceeds the Internal Limit"); } diff --git a/source/server/udaLegacyServer.cpp b/source/server/udaLegacyServer.cpp index d2ae7ba2..735dd950 100644 --- a/source/server/udaLegacyServer.cpp +++ b/source/server/udaLegacyServer.cpp @@ -69,7 +69,7 @@ int uda::server::legacyServer(config::Config& config, ClientBlock client_block, init_log_struct_list(&log_struct_list); int server_tot_block_time = 0; - int server_timeout = TIMEOUT; // user specified Server Lifetime + int server_timeout = TimeOut; // user specified Server Lifetime uda::server::IoData io_data = {}; io_data.server_tot_block_time = &server_tot_block_time; @@ -161,7 +161,7 @@ int uda::server::legacyServer(config::Config& config, ClientBlock client_block, bool external_user = config.get("server.external_user").as_or_default(false); - if (!external_user && (private_flags & PRIVATEFLAG_EXTERNAL)) { + if (!external_user && (private_flags & private_flags::External)) { config.set("server.external_user", true); } @@ -239,7 +239,7 @@ int uda::server::legacyServer(config::Config& config, ClientBlock client_block, # ifdef PROXYSERVER - char work[STRING_LENGTH]; + char work[StringLength]; if (request_block.api_delim[0] != '\0') { sprintf(work, "UDA%s", request_block.api_delim); @@ -280,7 +280,7 @@ int uda::server::legacyServer(config::Config& config, ClientBlock client_block, // Check string length compatibility if (strlen(request_block.source) >= - (STRING_LENGTH - 1 - strlen(environment->server_proxy) - 4 + strlen(request_block.api_delim))) { + (StringLength - 1 - strlen(environment->server_proxy) - 4 + strlen(request_block.api_delim))) { err = 999; add_error(ErrorType::Code, __func__, err, "PROXY redirection: The source argument string is too long!"); diff --git a/source/server/udaServer.cpp b/source/server/udaServer.cpp index bc591523..40f1a0ed 100644 --- a/source/server/udaServer.cpp +++ b/source/server/udaServer.cpp @@ -199,7 +199,7 @@ int uda::server::uda_server(uda::config::Config& config, uda::client_server::Cli init_log_struct_list(&log_struct_list); int server_tot_block_time = 0; - int server_timeout = TIMEOUT; // user specified Server Lifetime + int server_timeout = TimeOut; // user specified Server Lifetime IoData io_data = {}; io_data.server_tot_block_time = &server_tot_block_time; @@ -507,7 +507,7 @@ int handle_request(Config& config, RequestBlock* request_block, ClientBlock* cli auto external_user = config.get("server.external_user").as_or_default(false); - if (!external_user && (private_flags & PRIVATEFLAG_EXTERNAL)) { + if (!external_user && (private_flags & private_flags::External)) { config.set("server.external_user", true); } @@ -539,7 +539,7 @@ int handle_request(Config& config, RequestBlock* request_block, ClientBlock* cli // Test for an immediate CLOSEDOWN instruction - if (client_block->timeout == 0 || (client_block->clientFlags & CLIENTFLAG_CLOSEDOWN)) { + if (client_block->timeout == 0 || (client_block->clientFlags & client_flags::CloseDown)) { *server_closedown = 1; return err; } @@ -590,7 +590,7 @@ int handle_request(Config& config, RequestBlock* request_block, ClientBlock* cli char* proxyNameDefault = "UDA"; char* proxyName = nullptr; - char work[STRING_LENGTH]; + char work[StringLength]; if ((proxyName = getenv("UDA_PROXYPLUGINNAME")) == nullptr) { proxyName = proxyNameDefault; @@ -599,7 +599,7 @@ int handle_request(Config& config, RequestBlock* request_block, ClientBlock* cli // Check string length compatibility if (strlen(request_block->source) >= - (STRING_LENGTH - 1 - strlen(proxyName) - strlen(environment.server_proxy) - strlen(request_block->api_delim))) { + (StringLength - 1 - strlen(proxyName) - strlen(environment.server_proxy) - strlen(request_block->api_delim))) { UDA_THROW_ERROR(999, "PROXY redirection: The source argument string is too long!"); } @@ -728,7 +728,7 @@ int handle_request(Config& config, RequestBlock* request_block, ClientBlock* cli // Check string length compatibility if (strlen(request->source) >= - (STRING_LENGTH - 1 - server_proxy.size() - 4 + strlen(request->api_delim))) { + (StringLength - 1 - server_proxy.size() - 4 + strlen(request->api_delim))) { UDA_THROW_ERROR(999, "PROXY redirection: The source argument string is too long!"); } @@ -814,7 +814,7 @@ int handle_request(Config& config, RequestBlock* request_block, ClientBlock* cli auto request = &request_block->requests[i]; auto cache_block = cache_read(config, cache, request, log_malloc_list, user_defined_type_list, protocol_version, - CLIENTFLAG_CACHE, log_struct_list, private_flags, malloc_source); + client_flags::Cache, log_struct_list, private_flags, malloc_source); if (cache_block != nullptr) { data_block_list->data[i] = *cache_block; continue; @@ -827,7 +827,7 @@ int handle_request(Config& config, RequestBlock* request_block, ClientBlock* cli plugin_list, log_malloc_list, user_defined_type_list, &socket_list, protocol_version); cache_write(config, cache, request, data_block, log_malloc_list, user_defined_type_list, protocol_version, - CLIENTFLAG_CACHE, log_struct_list, private_flags, malloc_source); + client_flags::Cache, log_struct_list, private_flags, malloc_source); } for (int i = 0; i < request_block->num_requests; ++i) { @@ -1148,7 +1148,7 @@ int handshake_client(Config& config, ClientBlock* client_block, ServerBlock* ser // Test for an immediate CLOSEDOWN instruction - if (client_block->timeout == 0 || client_block->clientFlags & CLIENTFLAG_CLOSEDOWN) { + if (client_block->timeout == 0 || client_block->clientFlags & client_flags::CloseDown) { *server_closedown = 1; return err; } diff --git a/source/server/writer.cpp b/source/server/writer.cpp index ffa944c4..389c7726 100644 --- a/source/server/writer.cpp +++ b/source/server/writer.cpp @@ -22,7 +22,7 @@ int server_socket = 0; // There are two time constraints: // // The Maximum Blocking period is 1ms when reading -// A Maximum number (MAXLOOP) of blocking periods is allowed before this time +// A Maximum number (MaxLoop) of blocking periods is allowed before this time // is modified: It is extended to 100ms to minimise server resource consumption. // // When the Server is in a Holding state, it is listening to the Socket for either a @@ -34,7 +34,7 @@ int server_socket = 0; // max_block_time // tot_block_time // -// A Maximum time (MAXBLOCK) from the last Data Request is permitted before the Server Automatically +// A Maximum time (MaxBlock) from the last Data Request is permitted before the Server Automatically // closes down. //----------------------------------------------------------------------------------------- */ diff --git a/source/server/writer.h b/source/server/writer.h index 4dd74b51..beffaf37 100644 --- a/source/server/writer.h +++ b/source/server/writer.h @@ -23,7 +23,7 @@ int server_write(void* iohandle, char* buf, int count); // There are two time constraints: // // The Maximum Blocking period is 1ms when reading -// A Maximum number (MAXLOOP) of blocking periods is allowed before this time +// A Maximum number (MaxLoop) of blocking periods is allowed before this time // is modified: It is extended to 100ms to minimise server resource consumption. // // When the Server is in a Holding state, it is listening to the Socket for either a @@ -35,7 +35,7 @@ int server_write(void* iohandle, char* buf, int count); // max_block_time // tot_block_time // -// A Maximum time (MAXBLOCK in seconds) from the last Data Request is permitted before the Server Automatically +// A Maximum time (MaxBlock in seconds) from the last Data Request is permitted before the Server Automatically // closes down. //----------------------------------------------------------------------------------------- */ diff --git a/source/server2/apply_XML.cpp b/source/server2/apply_XML.cpp index c287da4a..071c643f 100644 --- a/source/server2/apply_XML.cpp +++ b/source/server2/apply_XML.cpp @@ -17,11 +17,14 @@ #include #include +#include "clientserver/udaDefines.h" #include "common/stringUtils.h" #include "logging/logging.h" + #include using namespace uda::logging; +using namespace uda::client_server; int uda::server_parse_signal_xml(uda::client_server::DataSource data_source, uda::client_server::Signal signal, uda::client_server::SignalDesc signal_desc, uda::client_server::Actions* actions_desc, @@ -316,12 +319,12 @@ void uda::server_apply_signal_xml(uda::client_server::ClientBlock client_block, continue; // Out of Pulse/Pass Range } - switch (actions.action[i].actionType) { + switch ((ActionType)actions.action[i].actionType) { //---------------------------------------------------------------------------------------------- // Documentation Changes: Label/Units Corrections - case UDA_DOCUMENTATION_TYPE: + case ActionType::Documentation: if (strlen(actions.action[i].documentation.label) > 0) { strcpy(data_block->data_label, actions.action[i].documentation.label); } @@ -335,7 +338,7 @@ void uda::server_apply_signal_xml(uda::client_server::ClientBlock client_block, } for (int j = 0; j < actions.action[i].documentation.ndimensions; j++) { - if (actions.action[i].documentation.dimensions[j].dimType == UDA_DIM_DOCUMENTATION_TYPE) { + if (actions.action[i].documentation.dimensions[j].dimType == (int)ActionDimType::Documentation) { if (actions.action[i].documentation.dimensions[j].dimid > -1 && (unsigned int)actions.action[i].documentation.dimensions[j].dimid < data_block->rank) { if (strlen(actions.action[i].documentation.dimensions[j].dimdocumentation.label) > 0) { @@ -354,7 +357,7 @@ void uda::server_apply_signal_xml(uda::client_server::ClientBlock client_block, //---------------------------------------------------------------------------------------------- // Error Models (Asymmetry is decided by the model's properties, not by the XML) - case UDA_ERROR_MODEL_TYPE: + case ActionType::ErrorModel: data_block->error_model = actions.action[i].errormodel.model; data_block->error_param_n = actions.action[i].errormodel.param_n; for (int j = 0; j < data_block->error_param_n; j++) { @@ -362,7 +365,7 @@ void uda::server_apply_signal_xml(uda::client_server::ClientBlock client_block, } for (int j = 0; j < actions.action[i].errormodel.ndimensions; j++) { - if (actions.action[i].errormodel.dimensions[j].dimType == UDA_DIM_ERROR_MODEL_TYPE) { + if (actions.action[i].errormodel.dimensions[j].dimType == (int)ActionDimType::ErrorModel) { if (actions.action[i].errormodel.dimensions[j].dimid > -1 && (unsigned int)actions.action[i].errormodel.dimensions[j].dimid < data_block->rank) { data_block->dims[actions.action[i].errormodel.dimensions[j].dimid].error_model = @@ -389,7 +392,7 @@ void uda::server_apply_signal_xml(uda::client_server::ClientBlock client_block, // timeoffset.method == 2 => Create a New Time Vector using an interval value only. Use the Original // Starting value if possible. - case UDA_TIME_OFFSET_TYPE: + case ActionType::Offset: if (client_block.get_notoff || data_block->order < 0) { break; @@ -767,7 +770,7 @@ void uda::server_apply_signal_xml(uda::client_server::ClientBlock client_block, //---------------------------------------------------------------------------------------------- // Calibration Corrections - case UDA_CALIBRATION_TYPE: + case ActionType::Calibration: if (!client_block.get_uncal) { @@ -805,7 +808,7 @@ void uda::server_apply_signal_xml(uda::client_server::ClientBlock client_block, dimid = actions.action[i].calibration.dimensions[j].dimid; - if (actions.action[i].calibration.dimensions[j].dimType == UDA_DIM_CALIBRATION_TYPE && + if (actions.action[i].calibration.dimensions[j].dimType == (int)ActionDimType::Calibration && actions.action[i].actionId != 0 && dimid > -1 && (unsigned int)dimid < data_block->rank) { if (strlen(actions.action[i].calibration.dimensions[j].dimcalibration.units) > 0) { diff --git a/source/server2/get_data.cpp b/source/server2/get_data.cpp index 19cbb50f..c81db844 100644 --- a/source/server2/get_data.cpp +++ b/source/server2/get_data.cpp @@ -264,7 +264,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo //-------------------------------------------------------------------------------------------------------------------------- // Limit the Recursive Depth - if (*depth == UDA_XML_MAX_RECURSIVE) { + if (*depth == XmlMaxRecursive) { UDA_THROW_ERROR(7777, "Recursive Depth (Derived or Substitute Data) Exceeds Internal Limit"); } @@ -285,7 +285,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo return rc; } // Erase original Subset request - copy_string(trim_string(request_data->signal), _metadata_block.signal_desc.signal_name, MAXNAME); + copy_string(trim_string(request_data->signal), _metadata_block.signal_desc.signal_name, MaxName); } } } else if (STR_IEQUALS(request_data->function, "subset")) { @@ -299,7 +299,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo return rc; } // Erase original Subset request - copy_string(trim_string(request_data->signal), _metadata_block.signal_desc.signal_name, MAXNAME); + copy_string(trim_string(request_data->signal), _metadata_block.signal_desc.signal_name, MaxName); } } } @@ -326,7 +326,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo UDA_LOG(UDA_LOG_DEBUG, "Calling serverSubsetData (Subset) {}", *depth); Action action = {}; init_action(&action); - action.actionType = UDA_SUBSET_TYPE; + action.actionType = (int)ActionType::Subset; action.subset = request_data->datasubset; if ((rc = server_subset_data(data_block, action, _log_malloc_list)) != 0) { (*depth)--; @@ -384,7 +384,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo comp_id = -1; if (rc == 0) { for (int i = 0; i < actions_comp_desc.nactions; i++) { - if (actions_comp_desc.action[i].actionType == UDA_COMPOSITE_TYPE && + if (actions_comp_desc.action[i].actionType == (int)ActionType::Composite && actions_comp_desc.action[i].inRange) { comp_id = i; break; // First Record found only! @@ -670,7 +670,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo if (is_derived && comp_id > -1) { for (int i = 0; i < _actions_desc.action[comp_id].composite.ndimensions; i++) { - if (_actions_desc.action[comp_id].composite.dimensions[i].dimType == UDA_DIM_COMPOSITE_TYPE) { + if (_actions_desc.action[comp_id].composite.dimensions[i].dimType == (int)ActionDimType::Composite) { if (strlen(_actions_desc.action[comp_id].composite.dimensions[i].dimcomposite.dim_signal) > 0) { UDA_LOG(UDA_LOG_DEBUG, "Substituting Dimension Data"); @@ -905,7 +905,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo if (!serverside && !is_derived && _metadata_block.signal_desc.type == 'S') { for (int i = 0; i < _actions_desc.nactions; i++) { - if (_actions_desc.action[i].actionType == UDA_SUBSET_TYPE) { + if (_actions_desc.action[i].actionType == (int)ActionType::Subset) { UDA_LOG(UDA_LOG_DEBUG, "Calling server_subset_data (Subset) {}", *depth); print_data_block(*data_block); @@ -922,7 +922,7 @@ int uda::server::Server::get_data(int* depth, RequestData* request_data, DataBlo if (serverside) { for (int i = 0; i < actions_serverside.nactions; i++) { - if (actions_serverside.action[i].actionType == UDA_SERVER_SIDE_TYPE) { + if (actions_serverside.action[i].actionType == (int)ActionType::ServerSide) { for (int j = 0; j < actions_serverside.action[i].serverside.nsubsets; j++) { UDA_LOG(UDA_LOG_DEBUG, "Calling server_subset_data (Serverside) {}", *depth); print_data_block(*data_block); @@ -949,7 +949,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) // If err > 0 then an error occured // If err < 0 then unable to read signal because it is a derived type and details are in XML format - char mapping[MAXMETA] = ""; + char mapping[MaxMeta] = ""; print_request_data(*request); @@ -987,7 +987,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) // the same Rank, then allow normal Generic lookup. //------------------------------------------------------------------------------ #ifndef PROXYSERVER - if (_client_block.clientFlags & CLIENTFLAG_ALTDATA && request->request != (int)Request::ReadXML && + if (_client_block.clientFlags & client_flags::AltData && request->request != (int)Request::ReadXML && STR_STARTSWITH(request->signal, "request != (int)Request::ReadGeneric) { @@ -1025,7 +1025,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) // If the plugin is registered as a FILE or LIBRARY type then call the default method as no method will have // been specified - copy_string(maybe_plugin->default_method, request->function, STRING_LENGTH); + copy_string(maybe_plugin->default_method, request->function, StringLength); // Execute the plugin to resolve the identity of the data requested @@ -1079,7 +1079,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) UDA_THROW_ERROR(122, "Unable to Open the XML File defining the signal"); } nchar = 0; - while (!feof(xmlfile) && nchar < MAXMETA) { + while (!feof(xmlfile) && nchar < MaxMeta) { request->signal[nchar++] = (char)getc(xmlfile); } request->signal[nchar - 2] = '\0'; // Remove EOF Character and replace with String Terminator @@ -1227,7 +1227,7 @@ int uda::server::Server::read_data(RequestData* request, DataBlock* data_block) // Don't append the file name to the path - if it's already present! if (strstr(_metadata_block.data_source.path, _metadata_block.data_source.filename) == nullptr) { - if (strlen(_metadata_block.data_source.path) + strlen(_metadata_block.data_source.filename) + 1 < MAXPATH) { + if (strlen(_metadata_block.data_source.path) + strlen(_metadata_block.data_source.filename) + 1 < MaxPath) { strcat(_metadata_block.data_source.path, "/"); strcat(_metadata_block.data_source.path, _metadata_block.data_source.filename); } else { diff --git a/source/server2/plugin_api.cpp b/source/server2/plugin_api.cpp index c8b63b98..b952ead4 100644 --- a/source/server2/plugin_api.cpp +++ b/source/server2/plugin_api.cpp @@ -47,7 +47,7 @@ UDA_PLUGIN_INTERFACE* udaCreatePluginInterface(UDA_PLUGIN_INTERFACE* plugin_inte auto plugin_list = old_plugin_interface->pluginList; auto request_data = (RequestData*)calloc(1, sizeof(RequestData)); - copy_string(request, request_data->signal, MAXMETA); + copy_string(request, request_data->signal, MaxMeta); make_request_data(*config, request_data, *plugin_list); auto user_defined_type_list = (UserDefinedTypeList*)calloc(1, sizeof(UserDefinedTypeList)); @@ -88,8 +88,8 @@ template int setReturnDataScalar(UDA_PLUGIN_INTERFACE* plugin_inter data[0] = value; if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } data_block->rank = 0; @@ -109,8 +109,8 @@ int setReturnDataArray(UDA_PLUGIN_INTERFACE* plugin_interface, const T* values, init_data_block(data_block); if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } data_block->rank = (int)rank; @@ -183,8 +183,8 @@ int udaPluginReturnDataStringScalar(UDA_PLUGIN_INTERFACE* plugin_interface, cons } if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } data_block->dims[0].data_type = UDA_TYPE_UNSIGNED_INT; @@ -234,8 +234,8 @@ int udaPluginReturnDataStringArray(UDA_PLUGIN_INTERFACE* plugin_interface, const } if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } data_block->dims[0].data_type = UDA_TYPE_UNSIGNED_INT; @@ -278,8 +278,8 @@ int udaPluginReturnData(UDA_PLUGIN_INTERFACE* plugin_interface, void* value, siz } if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } for (unsigned int i = 0; i < data_block->rank; i++) { @@ -454,7 +454,7 @@ int udaCallPlugin2(UDA_PLUGIN_INTERFACE* plugin_interface, const char* request, if (request_data.datasubset.nbound > 0) { Action action = {}; init_action(&action); - action.actionType = UDA_SUBSET_TYPE; + action.actionType = (int)ActionType::Subset; action.subset = request_data.datasubset; err = server_subset_data(new_plugin_interface.data_block, action, new_plugin_interface.log_malloc_list); } @@ -483,8 +483,8 @@ int udaPluginReturnCompoundData(UDA_PLUGIN_INTERFACE* plugin_interface, char* da data_block->opaque_block = (void*)udaFindUserDefinedType(interface->user_defined_type_list, user_type, 0); if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } return 0; @@ -528,8 +528,8 @@ int udaPluginReturnCompoundArrayData(UDA_PLUGIN_INTERFACE* plugin_interface, cha data_block->opaque_block = (void*)udaFindUserDefinedType(interface->user_defined_type_list, user_type, 0); if (description != nullptr) { - strncpy(data_block->data_desc, description, STRING_LENGTH); - data_block->data_desc[STRING_LENGTH - 1] = '\0'; + strncpy(data_block->data_desc, description, StringLength); + data_block->data_desc[StringLength - 1] = '\0'; } return 0; diff --git a/source/server2/server.cpp b/source/server2/server.cpp index 634e4a88..18139524 100644 --- a/source/server2/server.cpp +++ b/source/server2/server.cpp @@ -194,7 +194,7 @@ void uda::server::Server::start_logs() void uda::server::Server::initialise() { - _server_timeout = TIMEOUT; + _server_timeout = TimeOut; _fatal_error = false; auto log_level = (LogLevel)_config.get("logging.level").as_or_default((int)UDA_LOG_NONE); @@ -453,7 +453,7 @@ int uda::server::Server::handle_request() // policy auto external_user = _config.get("server.external_user").as_or_default(false); - if (!external_user && (private_flags & PRIVATEFLAG_EXTERNAL)) { + if (!external_user && (private_flags & private_flags::External)) { _config.set("server.external_user", true); external_user = true; } @@ -486,7 +486,7 @@ int uda::server::Server::handle_request() // Test for an immediate CLOSEDOWN instruction - if (_client_block.timeout == 0 || (_client_block.clientFlags & CLIENTFLAG_CLOSEDOWN)) { + if (_client_block.timeout == 0 || (_client_block.clientFlags & client_flags::CloseDown)) { _server_closedown = true; return err; } @@ -537,14 +537,14 @@ int uda::server::Server::handle_request() // Check string length compatibility - if (strlen(request_block_.source) >= (STRING_LENGTH - 1 - proxy_name.size() - strlen(environment_->server_proxy) - + if (strlen(request_block_.source) >= (StringLength - 1 - proxy_name.size() - strlen(environment_->server_proxy) - strlen(request_block_.api_delim))) { UDA_THROW_ERROR(999, "PROXY redirection: The source argument string is too long!"); } // Prepend the client request and test for a redirection request via the proxy's plugin - char work[STRING_LENGTH]; + char work[StringLength]; if (request_block_.api_delim[0] != '\0') { sprintf(work, "%s%s", proxy_name.c_str(), request_block_.api_delim); @@ -633,11 +633,11 @@ int uda::server::Server::handle_request() for (int i = 0; i < _request_block.num_requests; ++i) { RequestData* request = &_request_block.requests[0]; - char work[STRING_LENGTH]; + char work[StringLength]; if (request->api_delim[0] != '\0') { - snprintf(work, STRING_LENGTH, "UDA%s", request->api_delim); + snprintf(work, StringLength, "UDA%s", request->api_delim); } else { - snprintf(work, STRING_LENGTH, "UDA%s", delim.c_str()); + snprintf(work, StringLength, "UDA%s", delim.c_str()); } if (!proxy_target.empty() && strncasecmp(request->source, work, strlen(work)) != 0) { @@ -655,9 +655,9 @@ int uda::server::Server::handle_request() // never passed. if (request->api_delim[0] != '\0') { - snprintf(work, STRING_LENGTH, "UDA%s%s", request->api_delim, server.c_str()); + snprintf(work, StringLength, "UDA%s%s", request->api_delim, server.c_str()); } else { - snprintf(work, STRING_LENGTH, "UDA%s%s", delim.c_str(), server.c_str()); + snprintf(work, StringLength, "UDA%s%s", delim.c_str(), server.c_str()); } if (strstr(request->source, work) != nullptr) { @@ -668,17 +668,17 @@ int uda::server::Server::handle_request() // Check string length compatibility if (strlen(request->source) >= - (STRING_LENGTH - 1 - proxy_target.size() - 4 + strlen(request->api_delim))) { + (StringLength - 1 - proxy_target.size() - 4 + strlen(request->api_delim))) { UDA_THROW_ERROR(999, "PROXY redirection: The source argument string is too long!"); } // Prepend the redirection UDA server details if (request->api_delim[0] != '\0') { - snprintf(work, STRING_LENGTH, "UDA%s%s/%s", request->api_delim, proxy_target.c_str(), + snprintf(work, StringLength, "UDA%s%s/%s", request->api_delim, proxy_target.c_str(), request->source); } else { - snprintf(work, STRING_LENGTH, "UDA%s%s/%s", delim.c_str(), proxy_target.c_str(), + snprintf(work, StringLength, "UDA%s%s/%s", delim.c_str(), proxy_target.c_str(), request->source); } @@ -946,7 +946,7 @@ void uda::server::Server::handshake_client() err = _protocol.read_client_block(&_client_block, _log_malloc_list, _user_defined_type_list); - if (_client_block.timeout == 0 || _client_block.clientFlags & CLIENTFLAG_CLOSEDOWN) { + if (_client_block.timeout == 0 || _client_block.clientFlags & client_flags::CloseDown) { _server_closedown = true; return; } diff --git a/source/server2/server.hpp b/source/server2/server.hpp index 19664bd8..5fe275c6 100644 --- a/source/server2/server.hpp +++ b/source/server2/server.hpp @@ -63,7 +63,7 @@ class Server std::vector _data_blocks; size_t _total_data_block_size; MetadataBlock _metadata_block; - int _server_timeout = TIMEOUT; + int _server_timeout = client_server::TimeOut; int _server_tot_block_time; bool _fatal_error = false; structures::LogMallocList* _log_malloc_list = nullptr; diff --git a/source/server2/server_plugin.cpp b/source/server2/server_plugin.cpp index c669baa8..24d02377 100644 --- a/source/server2/server_plugin.cpp +++ b/source/server2/server_plugin.cpp @@ -47,8 +47,8 @@ int uda::server::server_redirect_std_streams(const Config& config, int reset) static int original_err_fh = 0; static FILE* mdsmsg_fh = nullptr; - static char mksdir_template[MAXPATH] = {0}; - static char temp_file[MAXPATH] = {0}; + static char mksdir_template[MaxPath] = {0}; + static char temp_file[MaxPath] = {0}; static bool single_file = false; @@ -79,7 +79,7 @@ int uda::server::server_redirect_std_streams(const Config& config, int reset) if (!redirect) { auto work_dir = config.get("plugins.work_dir"); if (work_dir) { - snprintf(mksdir_template, MAXPATH, "%s/idamPLUGINXXXXXX", work_dir.as().c_str()); + snprintf(mksdir_template, MaxPath, "%s/idamPLUGINXXXXXX", work_dir.as().c_str()); } else { strcpy(mksdir_template, "/tmp/idamPLUGINXXXXXX"); } @@ -205,7 +205,7 @@ int uda::server::server_plugin(const Config& config, RequestData *request, DataS strcpy(data_source->filename, trim_string(request->file)); strcpy(data_source->path, trim_string(request->path)); - copy_string(trim_string(request->signal), signal_desc->signal_name, MAXNAME); + copy_string(trim_string(request->signal), signal_desc->signal_name, MaxName); strcpy(data_source->server, trim_string(request->server)); @@ -306,7 +306,7 @@ int uda::server::provenance_plugin(const Config& config, ClientBlock *client_blo // mimic a client request if (logRecord == nullptr || strlen(logRecord) == 0) { - snprintf(request.signal, MAXMETA, + snprintf(request.signal, MaxMeta, "%s::putSignal(uuid='%s',requestedSignal='%s',requestedSource='%s', " "trueSignal='%s', trueSource='%s', trueSourceDOI='%s', execMethod=%d, status=new)", plugin->name.c_str(), client_block->DOI, original_request->signal, original_request->source, @@ -315,7 +315,7 @@ int uda::server::provenance_plugin(const Config& config, ClientBlock *client_blo // need 2> record the server log record - snprintf(request.signal, MAXMETA, "%s::putSignal(uuid='%s',logRecord='%s', execMethod=%d, status=update)", + snprintf(request.signal, MaxMeta, "%s::putSignal(uuid='%s',logRecord='%s', execMethod=%d, status=update)", plugin->name.c_str(), client_block->DOI, logRecord, exec_method); } diff --git a/source/server2/server_subset_data.cpp b/source/server2/server_subset_data.cpp index 3d41db19..c1def909 100644 --- a/source/server2/server_subset_data.cpp +++ b/source/server2/server_subset_data.cpp @@ -74,19 +74,19 @@ int uda::server::server_subset_data(client_server::DataBlock* data_block, client int n_subsets = 0; - if (action.actionType == UDA_COMPOSITE_TYPE) { // XML Based subsetting + if (action.actionType == (int)ActionType::Composite) { // XML Based subsetting if (action.composite.nsubsets == 0) { return 0; // Nothing to Subset } n_subsets = action.composite.nsubsets; } else { - if (action.actionType == UDA_SERVER_SIDE_TYPE) { // Client Requested subsetting + if (action.actionType == (int)ActionType::ServerSide) { // Client Requested subsetting if (action.serverside.nsubsets == 0) { return 0; // Nothing to Subset } n_subsets = action.serverside.nsubsets; } else { - if (action.actionType == UDA_SUBSET_TYPE) { // Client Requested subsetting + if (action.actionType == (int)ActionType::Subset) { // Client Requested subsetting n_subsets = 1; } else { return 0; @@ -98,13 +98,13 @@ int uda::server::server_subset_data(client_server::DataBlock* data_block, client // Check Rank if (data_block->rank > 2 && - !(action.actionType == UDA_SUBSET_TYPE && !strncasecmp(action.subset.function, "rotateRZ", 8))) { + !(action.actionType == (int)ActionType::Subset && !strncasecmp(action.subset.function, "rotateRZ", 8))) { UDA_THROW_ERROR(9999, "Not Configured to Subset Data with Rank Higher than 2"); } // Check for special case of rank 0 data indexed by [0] - if (data_block->rank == 0 && n_subsets == 1 && action.actionType == UDA_SUBSET_TYPE + if (data_block->rank == 0 && n_subsets == 1 && action.actionType == (int)ActionType::Subset && action.subset.nbound == 1 && action.subset.operation[0][0] == ':' && action.subset.lbindex[0].init && action.subset.lbindex[0].value == 0 && action.subset.ubindex[0].init && action.subset.ubindex[0].value == 1) { @@ -118,13 +118,13 @@ int uda::server::server_subset_data(client_server::DataBlock* data_block, client for (int i = 0; i < n_subsets; i++) { // the number of sets of Subset Operations - if (action.actionType == UDA_COMPOSITE_TYPE) { + if (action.actionType == (int)ActionType::Composite) { subset = action.composite.subsets[i]; // the set of Subset Operations } else { - if (action.actionType == UDA_SERVER_SIDE_TYPE) { + if (action.actionType == (int)ActionType::ServerSide) { subset = action.serverside.subsets[i]; } else { - if (action.actionType == UDA_SUBSET_TYPE) { + if (action.actionType == (int)ActionType::Subset) { subset = action.subset; } } @@ -978,7 +978,7 @@ int uda::server::server_subset_data(client_server::DataBlock* data_block, client } data_block->data = (char*)count; data_block->data_units[0] = '\0'; - snprintf(data_block->data_label, STRING_LENGTH, "count(dim_id=%d)", dim_id); + snprintf(data_block->data_label, StringLength, "count(dim_id=%d)", dim_id); } } @@ -1210,14 +1210,14 @@ int uda::server::server_parse_server_side(config::Config& config, client_server: char *p = nullptr, *t1 = nullptr, *t2 = nullptr; char api_delim[3] = "::"; // ********** TO DO: This should be an Environment Variable compatible with the Client delimiter - char archive[STRING_LENGTH] = ""; - char signal[STRING_LENGTH] = ""; - char options[STRING_LENGTH] = ""; - char operation[STRING_LENGTH]; - char opcopy[STRING_LENGTH]; + char archive[StringLength] = ""; + char signal[StringLength] = ""; + char options[StringLength] = ""; + char operation[StringLength]; + char opcopy[StringLength]; char* endp = nullptr; - int lsignal, nactions, n_subsets, n_bound, ierr, lop; + int nactions, n_subsets, n_bound, ierr, lop; Action* action = nullptr; Subset* subsets = nullptr; @@ -1236,9 +1236,9 @@ int uda::server::server_parse_server_side(config::Config& config, client_server: UDA_THROW_ERROR(9999, "Syntax Error: The Signal Name has no Terminating Quotation character!"); } - lsignal = (int)(p - request_block->signal) - 8; // Signal name Length - if (lsignal >= STRING_LENGTH) { - lsignal = STRING_LENGTH - 1; + size_t lsignal = (size_t)(p - request_block->signal) - 8; // Signal name Length + if (lsignal >= StringLength) { + lsignal = StringLength - 1; } strncpy(signal, request_block->signal + 8, lsignal); signal[lsignal] = '\0'; @@ -1300,7 +1300,7 @@ int uda::server::server_parse_server_side(config::Config& config, client_server: init_action(&action[nactions - 1]); - action[nactions - 1].actionType = UDA_SERVER_SIDE_TYPE; + action[nactions - 1].actionType = (int)ActionType::ServerSide; action[nactions - 1].inRange = 1; action[nactions - 1].actionId = nactions; @@ -1366,7 +1366,7 @@ int uda::server::server_parse_server_side(config::Config& config, client_server: if ((p = strtok(opcopy, ",")) != nullptr) { // Tokenise into Individual Operations on each Dimension subsets[n_subsets - 1].dimid[n_bound] = n_bound; // Identify the Dimension to apply the operation on n_bound++; - if (strlen(p) < UDA_SXML_MAX_STRING) { + if (strlen(p) < SxmlMaxString) { strcpy(subsets[n_subsets - 1].operation[n_bound - 1], p); mid_trim_string(subsets[n_subsets - 1].operation[n_bound - 1]); // Remove internal white space } else { @@ -1377,11 +1377,11 @@ int uda::server::server_parse_server_side(config::Config& config, client_server: while ((p = strtok(nullptr, ",")) != nullptr) { subsets[n_subsets - 1].dimid[n_bound] = n_bound; n_bound++; - if (n_bound > UDA_MAX_DATA_RANK) { + if (n_bound > MaxDataRank) { free(subsets); UDA_THROW_ERROR(9999, "The number of Dimensional Operations exceeds the Internal Limit"); } - if (strlen(p) < UDA_SXML_MAX_STRING) { + if (strlen(p) < SxmlMaxString) { strcpy(subsets[n_subsets - 1].operation[n_bound - 1], p); mid_trim_string(subsets[n_subsets - 1].operation[n_bound - 1]); // Remove white space } else { diff --git a/source/server2/xdr_protocol.cpp b/source/server2/xdr_protocol.cpp index 48efd273..f3e75741 100644 --- a/source/server2/xdr_protocol.cpp +++ b/source/server2/xdr_protocol.cpp @@ -131,7 +131,7 @@ uda::server::XdrProtocol::XdrProtocol() : _server_input{} , _server_output{} , _server_tot_block_time{0} - , _server_timeout{TIMEOUT} + , _server_timeout{TimeOut} , _io_data{} { _io_data.server_socket = 0; @@ -147,37 +147,37 @@ void uda::server::XdrProtocol::create_streams() #if defined(SSLAUTHENTICATION) if (getUdaServerSSLDisabled()) { # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&_server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, &_io_data, + xdrrec_create(&_server_output, DBReadBlockSize, DBWriteBlockSize, &_io_data, reinterpret_cast(uda::server::read), reinterpret_cast(uda::server::write)); - xdrrec_create(&_server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, &_io_data, + xdrrec_create(&_server_input, DBReadBlockSize, DBWriteBlockSize, &_io_data, reinterpret_cast(uda::server::read), reinterpret_cast(uda::server::write)); # else - xdrrec_create(&_server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)&_io_data, + xdrrec_create(&_server_output, DBReadBlockSize, DBWriteBlockSize, (char*)&_io_data, reinterpret_cast(uda::server::read), reinterpret_cast(uda::server::write)); - xdrrec_create(&_server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)&_io_data, + xdrrec_create(&_server_input, DBReadBlockSize, DBWriteBlockSize, (char*)&_io_data, reinterpret_cast(uda::server::read), reinterpret_cast(uda::server::write)); # endif } else { # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&_server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, &_io_data, + xdrrec_create(&_server_output, DBReadBlockSize, DBWriteBlockSize, &_io_data, reinterpret_cast(readUdaServerSSL), reinterpret_cast(writeUdaServerSSL)); - xdrrec_create(&_server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, &_io_data, + xdrrec_create(&_server_input, DBReadBlockSize, DBWriteBlockSize, &_io_data, reinterpret_cast(readUdaServerSSL), reinterpret_cast(writeUdaServerSSL)); # else - xdrrec_create(&_server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)&_io_data, + xdrrec_create(&_server_output, DBReadBlockSize, DBWriteBlockSize, (char*)&_io_data, reinterpret_cast(readUdaServerSSL), reinterpret_cast(writeUdaServerSSL)); - xdrrec_create(&_server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)&_io_data, + xdrrec_create(&_server_input, DBReadBlockSize, DBWriteBlockSize, (char*)&_io_data, reinterpret_cast(readUdaServerSSL), reinterpret_cast(writeUdaServerSSL)); # endif @@ -185,19 +185,19 @@ void uda::server::XdrProtocol::create_streams() #else // SSLAUTHENTICATION # if defined(__APPLE__) || defined(__TIRPC__) - xdrrec_create(&_server_output, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, &_io_data, + xdrrec_create(&_server_output, DBReadBlockSize, DBWriteBlockSize, &_io_data, reinterpret_cast(uda::server::read), reinterpret_cast(uda::server::write)); - xdrrec_create(&_server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, &_io_data, + xdrrec_create(&_server_input, DBReadBlockSize, DBWriteBlockSize, &_io_data, reinterpret_cast(uda::server::read), reinterpret_cast(uda::server::write)); # else - xdrrec_create(&server_output_, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)&_io_data, + xdrrec_create(&server_output_, DBReadBlockSize, DBWriteBlockSize, (char*)&_io_data, reinterpret_cast(uda::server::read), reinterpret_cast(uda::server::write)); - xdrrec_create(&_server_input, DB_READ_BLOCK_SIZE, DB_WRITE_BLOCK_SIZE, (char*)&_io_data, + xdrrec_create(&_server_input, DBReadBlockSize, DBWriteBlockSize, (char*)&_io_data, reinterpret_cast(uda::server::read), reinterpret_cast(uda::server::write)); # endif @@ -481,7 +481,7 @@ DataBlock* uda::server::XdrProtocol::read_from_cache(config::Config& config, cac UserDefinedTypeList* user_defined_type_list) { return cache_read(config, cache, request, log_malloc_list, user_defined_type_list, _protocol_version, - CLIENTFLAG_CACHE, &_log_struct_list, _private_flags, _malloc_source); + client_flags::Cache, &_log_struct_list, _private_flags, _malloc_source); } void uda::server::XdrProtocol::write_to_cache(config::Config& config, cache::UdaCache* cache, RequestData* request, @@ -490,5 +490,5 @@ void uda::server::XdrProtocol::write_to_cache(config::Config& config, cache::Uda UserDefinedTypeList* user_defined_type_list) { cache_write(config, cache, request, data_block, log_malloc_list, user_defined_type_list, 8, - CLIENTFLAG_CACHE, &_log_struct_list, _private_flags, _malloc_source); + client_flags::Cache, &_log_struct_list, _private_flags, _malloc_source); } diff --git a/source/structures/parseIncludeFile.cpp b/source/structures/parseIncludeFile.cpp index 531c86d5..ce55006b 100644 --- a/source/structures/parseIncludeFile.cpp +++ b/source/structures/parseIncludeFile.cpp @@ -40,8 +40,8 @@ int parseIncludeFile(UserDefinedTypeList* userdefinedtypelist, const char* heade maxAlign = 0; FILE* fh = nullptr; - char buffer[STRING_LENGTH]; - char work[STRING_LENGTH]; + char buffer[StringLength]; + char work[StringLength]; char name[MAXELEMENTNAME]; char name1[MAXELEMENTNAME], name2[MAXELEMENTNAME], name3[MAXELEMENTNAME]; char* p = nullptr; @@ -153,7 +153,7 @@ int parseIncludeFile(UserDefinedTypeList* userdefinedtypelist, const char* heade // // // - while (fgets(buffer, STRING_LENGTH, fh) != nullptr) { + while (fgets(buffer, StringLength, fh) != nullptr) { left_trim_string(trim_string(buffer)); diff --git a/source/structures/struct.cpp b/source/structures/struct.cpp index 2a1e11e1..092e6056 100644 --- a/source/structures/struct.cpp +++ b/source/structures/struct.cpp @@ -233,7 +233,7 @@ void udaExpandImage(char* buffer, char defnames[MAXELEMENTS][MAXELEMENTNAME], in { // Insert values with #define names int len, lstr; - char work[STRING_LENGTH]; + char work[StringLength]; char *p1, *p2, *p3; if (buffer[0] != '\t' || buffer[0] != ' ') { @@ -260,7 +260,7 @@ void udaExpandImage(char* buffer, char defnames[MAXELEMENTS][MAXELEMENTNAME], in } else { for (int j = 0; j < defCount; j++) { if (!strcmp((char*)defnames[j], work)) { - snprintf(work, STRING_LENGTH, " = %d]", defvalues[j]); // Array size + snprintf(work, StringLength, " = %d]", defvalues[j]); // Array size strncat(expand, &p1[1], p2 - &p1[1]); len = len + (int)(p2 - &p1[1]); expand[len] = '\0'; diff --git a/source/wrappers/idl/idam_dlm.c b/source/wrappers/idl/idam_dlm.c index a8e74baf..90d470e7 100755 --- a/source/wrappers/idl/idam_dlm.c +++ b/source/wrappers/idl/idam_dlm.c @@ -1293,7 +1293,7 @@ IDL_VPTR IDL_CDECL callidam2(int argc, IDL_VPTR argv[], char* argk) //------------------------------------------------------------------------- char* signal; - char source[STRING_LENGTH]; + char source[StringLength]; int exp_number = 0; CLIENT_FLAGS* client_flags = udaClientFlags(); diff --git a/source/wrappers/python/pyuda/cpyuda/client.pyx b/source/wrappers/python/pyuda/cpyuda/client.pyx index 7df5879d..0ff14486 100644 --- a/source/wrappers/python/pyuda/cpyuda/client.pyx +++ b/source/wrappers/python/pyuda/cpyuda/client.pyx @@ -22,7 +22,7 @@ _properties = { "get_scalar": ("GET_SCALAR", False), "get_nodimdata": ("GET_NO_DIM_DATA", False), "get_meta": ("META", False), - "timeout": ("TIMEOUT", True), + "timeout": ("TimeOut", True), "verbose": ("VERBOSE", False), "debug": ("DEBUG", False), "altdata": ("ALT_DATA", True),