Skip to content

Commit

Permalink
Adding namespace to server headers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jholloc committed Feb 13, 2024
1 parent 8f9289a commit 518e87a
Show file tree
Hide file tree
Showing 59 changed files with 530 additions and 468 deletions.
5 changes: 3 additions & 2 deletions source/authentication/udaServerSSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
# define X509STRINGSIZE 256

using namespace uda::client_server;
using namespace uda::server;

/*
Note on initialisation:
Expand Down Expand Up @@ -416,7 +417,7 @@ int writeUdaServerSSL(void* iohandle, const char* buf, int count)
fd_set wfds; // File Descriptor Set for Writing to the Socket
struct timeval tv = {};

auto io_data = reinterpret_cast<IoData*>(iohandle);
auto io_data = reinterpret_cast<uda::server::IoData*>(iohandle);

// Block till it's possible to write to the socket or timeout

Expand Down Expand Up @@ -493,7 +494,7 @@ int readUdaServerSSL(void* iohandle, char* buf, int count)

// Wait till it's possible to read from the socket
// Set the blocking period before a timeout
auto io_data = reinterpret_cast<IoData*>(iohandle);
auto io_data = reinterpret_cast<uda::server::IoData*>(iohandle);

setSelectParms(g_sslSocket, &rfds, &tv, io_data->server_tot_block_time);
tvc = tv;
Expand Down
1 change: 1 addition & 0 deletions source/client/closedown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#ifdef FATCLIENT
# include "server/closeServerSockets.h"
# include "server/udaServer.h"
using namespace uda::server;
#else
# include "connection.h"
# include "getEnvironment.h"
Expand Down
2 changes: 1 addition & 1 deletion source/client/udaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1122,7 +1122,7 @@ int uda::client::idamClient(REQUEST_BLOCK* request_block, int* indices)

DATA_BLOCK_LIST data_block_list0;
initDataBlockList(&data_block_list0);
err = fat_server(client_block, &server_block, request_block, &data_block_list0);
err = uda::server::fat_server(client_block, &server_block, request_block, &data_block_list0);

for (int i = 0; i < data_block_list0.count; ++i) {
DATA_BLOCK* data_block0 = &data_block_list0.data[i];
Expand Down
34 changes: 17 additions & 17 deletions source/clientserver/makeRequestBlock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ using namespace uda::client_server;

static void extract_function_name(const char* str, REQUEST_DATA* request);

static int source_file_format_test(const char* source, REQUEST_DATA* request, const PLUGINLIST* pluginList,
const ENVIRONMENT* environment);
static int source_file_format_test(const char* source, REQUEST_DATA* request,
const uda::plugins::PluginList* pluginList, const ENVIRONMENT* environment);

static int extract_archive(REQUEST_DATA* request, int reduceSignal, const ENVIRONMENT* environment);

Expand All @@ -60,7 +60,7 @@ struct NameValue {
std::vector<uda::NameValue> name_value_pairs(std::string_view input, bool strip);
} // namespace uda

static int find_plugin_id_by_format(const char* format, const PLUGINLIST* plugin_list)
static int find_plugin_id_by_format(const char* format, const uda::plugins::PluginList* plugin_list)
{
for (int i = 0; i < plugin_list->count; i++) {
if (STR_IEQUALS(plugin_list->plugin[i].format, format)) {
Expand All @@ -70,7 +70,7 @@ static int find_plugin_id_by_format(const char* format, const PLUGINLIST* plugin
return -1;
}

int uda::client_server::makeRequestData(REQUEST_DATA* request, const PLUGINLIST* pluginList,
int uda::client_server::makeRequestData(REQUEST_DATA* request, const uda::plugins::PluginList* pluginList,
const ENVIRONMENT* environment)
{
int ldelim;
Expand Down Expand Up @@ -336,15 +336,15 @@ int uda::client_server::makeRequestData(REQUEST_DATA* request, const PLUGINLIST*

for (int i = 0; i < pluginList->count; i++) {
if (STR_IEQUALS(work2, pluginList->plugin[i].format)) {
if (pluginList->plugin[i].plugin_class != UDA_PLUGIN_CLASS_DEVICE) {
if (pluginList->plugin[i].plugin_class != uda::plugins::UDA_PLUGIN_CLASS_DEVICE) {
request->request = pluginList->plugin[i].request; // Found
strcpy(request->format, pluginList->plugin[i].format);
if (pluginList->plugin[i].plugin_class !=
UDA_PLUGIN_CLASS_FILE) { // The full file path fully resolved by the client
uda::plugins::UDA_PLUGIN_CLASS_FILE) { // The full file path fully resolved by the client
strcpy(request->path,
test + ldelim); // Complete String following :: delimiter
strcpy(request->file, ""); // Clean the filename
if (pluginList->plugin[i].plugin_class == UDA_PLUGIN_CLASS_FUNCTION) {
if (pluginList->plugin[i].plugin_class == uda::plugins::UDA_PLUGIN_CLASS_FUNCTION) {
isFunction = true;
extract_function_name(work, request);
}
Expand All @@ -357,8 +357,8 @@ int uda::client_server::makeRequestData(REQUEST_DATA* request, const PLUGINLIST*
#endif
strcpy(request->file, base); // Final token
}
isFile = pluginList->plugin[i].plugin_class == UDA_PLUGIN_CLASS_FILE;
isServer = pluginList->plugin[i].plugin_class == UDA_PLUGIN_CLASS_SERVER;
isFile = pluginList->plugin[i].plugin_class == uda::plugins::UDA_PLUGIN_CLASS_FILE;
isServer = pluginList->plugin[i].plugin_class == uda::plugins::UDA_PLUGIN_CLASS_SERVER;
break;
} else {

Expand All @@ -369,7 +369,7 @@ int uda::client_server::makeRequestData(REQUEST_DATA* request, const PLUGINLIST*
static int depth = 0;
// int id = findPluginRequestByFormat(pluginList->plugin[i].deviceProtocol, &pluginList);
int id = find_plugin_id_by_format(pluginList->plugin[i].deviceProtocol, pluginList);
if (id >= 0 && pluginList->plugin[id].plugin_class == UDA_PLUGIN_CLASS_SERVER) {
if (id >= 0 && pluginList->plugin[id].plugin_class == uda::plugins::UDA_PLUGIN_CLASS_SERVER) {

snprintf(work, MAXMETA, "%s%s%s", pluginList->plugin[i].deviceProtocol, request->api_delim,
pluginList->plugin[i].deviceHost);
Expand Down Expand Up @@ -581,8 +581,8 @@ int uda::client_server::makeRequestData(REQUEST_DATA* request, const PLUGINLIST*
if (STR_IEQUALS(request->archive, pluginList->plugin[i].format)) {
request->request = pluginList->plugin[i].request; // Found
strcpy(request->format, pluginList->plugin[i].format);
isFunction =
(pluginList->plugin[i].plugin_class == UDA_PLUGIN_CLASS_FUNCTION); // Must be a known Library
isFunction = (pluginList->plugin[i].plugin_class ==
uda::plugins::UDA_PLUGIN_CLASS_FUNCTION); // Must be a known Library
break;
}
}
Expand Down Expand Up @@ -620,7 +620,7 @@ int uda::client_server::makeRequestData(REQUEST_DATA* request, const PLUGINLIST*

if (isFunction && strcasecmp(request->archive, environment->api_archive) != 0) {
int id = find_plugin_id_by_format(request->archive, pluginList);
if (id >= 0 && pluginList->plugin[id].plugin_class == UDA_PLUGIN_CLASS_FUNCTION &&
if (id >= 0 && pluginList->plugin[id].plugin_class == uda::plugins::UDA_PLUGIN_CLASS_FUNCTION &&
strcasecmp(pluginList->plugin[id].symbol, "serverside") != 0) {
if (request->request == REQUEST_READ_GENERIC || request->request == REQUEST_READ_UNKNOWN) {
request->request = pluginList->plugin[id].request; // Found
Expand Down Expand Up @@ -741,7 +741,7 @@ int uda::client_server::makeRequestData(REQUEST_DATA* request, const PLUGINLIST*
return 0;
}

int uda::client_server::make_request_block(REQUEST_BLOCK* request_block, const PLUGINLIST* pluginList,
int uda::client_server::make_request_block(REQUEST_BLOCK* request_block, const uda::plugins::PluginList* pluginList,
const ENVIRONMENT* environment)
{
int rc = 0;
Expand Down Expand Up @@ -788,7 +788,7 @@ void extract_function_name(const char* str, REQUEST_DATA* request)
/**
* returns true if a format was identified, false otherwise.
*/
int source_file_format_test(const char* source, REQUEST_DATA* request, const PLUGINLIST* pluginList,
int source_file_format_test(const char* source, REQUEST_DATA* request, const uda::plugins::PluginList* pluginList,
const ENVIRONMENT* environment)
{
int rc = 0;
Expand Down Expand Up @@ -1029,8 +1029,8 @@ int source_file_format_test(const char* source, REQUEST_DATA* request, const PLU
UDA_LOG(UDA_LOG_DEBUG, "Format identified, selecting specific plugin for %s\n", request->format);
request->request = pluginList->plugin[i].request; // Found
if (pluginList->plugin[i].plugin_class !=
UDA_PLUGIN_CLASS_FILE) { // The full file path fully resolved by the client
strcpy(request->file, ""); // Clean the filename
uda::plugins::UDA_PLUGIN_CLASS_FILE) { // The full file path fully resolved by the client
strcpy(request->file, ""); // Clean the filename
} else {
#ifndef __GNUC__
char base[1024] = {0};
Expand Down
6 changes: 4 additions & 2 deletions source/clientserver/makeRequestBlock.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
#pragma once

#include "plugins/udaPlugin.h"
#include "udaStructs.h"

typedef struct PluginList PLUGINLIST;

namespace uda::client_server
{

int make_request_block(REQUEST_BLOCK* request_block, const PLUGINLIST* pluginList, const ENVIRONMENT* environment);
int make_request_block(REQUEST_BLOCK* request_block, const uda::plugins::PluginList* pluginList,
const ENVIRONMENT* environment);

int makeRequestData(REQUEST_DATA* request, const PLUGINLIST* pluginList, const ENVIRONMENT* environment);
int makeRequestData(REQUEST_DATA* request, const uda::plugins::PluginList* pluginList, const ENVIRONMENT* environment);

int name_value_pairs(const char* pairList, NAMEVALUELIST* nameValueList, unsigned short strip);

Expand Down
1 change: 1 addition & 0 deletions source/clientserver/make_request_block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <string>

using namespace uda::client_server;
using namespace uda::plugins;

static const boost::regex SOURCE_RE(
R"(^(?<device>(?:[a-z]+::)*)(((?<pulse>[0-9]+)(\/(?<pass>[0-9a-z]+))?)|(?<path>\/[a-z0-9\/\.]+)|((?<function>[a-z]+)\((?<args>.*)\)))$)",
Expand Down
23 changes: 23 additions & 0 deletions source/clientserver/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,29 @@

using namespace uda::client_server;

void uda::client_server::setSelectParms(int fd, fd_set* rfds, struct timeval* tv, int* server_tot_block_time)
{
FD_ZERO(rfds); // Initialise the File Descriptor set
FD_SET(fd, rfds); // Identify the Socket in the FD set
tv->tv_sec = 0;
tv->tv_usec = MIN_BLOCK_TIME; // minimum wait microsecs (1ms)
*server_tot_block_time = 0;
}

void uda::client_server::updateSelectParms(int fd, fd_set* rfds, struct timeval* tv, int server_tot_block_time)
{
FD_ZERO(rfds);
FD_SET(fd, rfds);
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)
} else {
tv->tv_sec = 0;
tv->tv_usec = MAX_BLOCK_TIME; // maximum wait (10ms)
}
}

int uda::client_server::protocol(XDR* xdrs, int protocol_id, int direction, int* token, LOGMALLOCLIST* logmalloclist,
USERDEFINEDTYPELIST* userdefinedtypelist, void* str, int protocolVersion,
LOGSTRUCTLIST* log_struct_list, IoData* io_data, unsigned int private_flags,
Expand Down
10 changes: 9 additions & 1 deletion source/clientserver/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,22 @@
#define UDA_PROTOCOL_LIMITER 113
#define UDA_PROTOCOL_OPAQUE_STOP 200

struct IoData;
#define MIN_BLOCK_TIME 1000
#define MAX_BLOCK_TIME 10000

//---------------------------------------------------------------------------------------------------
// Client Server XDR data Streams (DON'T CHANGE ORDER or Legacy client won't work!)

namespace uda::client_server
{

struct IoData {
};

void setSelectParms(int fd, fd_set* rfds, struct timeval* tv, int* server_tot_block_time);

void updateSelectParms(int fd, fd_set* rfds, struct timeval* tv, int server_tot_block_time);

int protocol(XDR* xdrs, int protocol_id, int direction, int* token, LOGMALLOCLIST* logmalloclist,
USERDEFINEDTYPELIST* userdefinedtypelist, void* str, int protocolVersion, LOGSTRUCTLIST* log_struct_list,
IoData* io_data, unsigned int private_flags, int malloc_source);
Expand Down
10 changes: 5 additions & 5 deletions source/clientserver/protocolXML.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@
# define protocolXML protocolXMLFat
#endif

struct IoData;

using CreateXDRStreams = std::pair<XDR*, XDR*> (*)(IoData*);

namespace uda::client_server
{

struct IoData;

using CreateXDRStreams = std::pair<XDR*, XDR*> (*)(uda::client_server::IoData*);

int protocolXML(XDR* xdrs, int protocol_id, int direction, int* token, LOGMALLOCLIST* logmalloclist,
USERDEFINEDTYPELIST* userdefinedtypelist, void* str, int protocolVersion,
LOGSTRUCTLIST* log_struct_list, IoData* io_data, unsigned int private_flags, int malloc_source,
CreateXDRStreams create_xdr_streams);

}
} // namespace uda::client_server
2 changes: 1 addition & 1 deletion source/include/uda/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ typedef struct LogStructList LOGSTRUCTLIST;
typedef struct CompoundField COMPOUNDFIELD;
typedef struct UserDefinedType USERDEFINEDTYPE;
typedef struct UserDefinedTypeList USERDEFINEDTYPELIST;
typedef struct UdaPluginInterface UDA_PLUGIN_INTERFACE;
typedef struct CUdaPluginInterface UDA_PLUGIN_INTERFACE;
typedef struct CompoundField COMPOUNDFIELD;
typedef struct UserDefinedType USERDEFINEDTYPE;

Expand Down
4 changes: 2 additions & 2 deletions source/include/uda/uda_plugin_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class UDAPluginBase {

// Helper methods
template <typename... Args>
void debug(UdaPluginInterface* plugin_interface, const std::string& message, Args... args)
void debug(UDA_PLUGIN_INTERFACE* plugin_interface, const std::string& message, Args... args)
{
auto msg = fmt::format(message, args...);
udaPluginLog(plugin_interface, "%s", msg.c_str());
}

template <typename... Args>
void error(UdaPluginInterface* plugin_interface, const std::string& message, Args... args)
void error(UDA_PLUGIN_INTERFACE* plugin_interface, const std::string& message, Args... args)
{
auto msg = fmt::format(message, args...);
udaPluginLog(plugin_interface, "%s", msg.c_str());
Expand Down
11 changes: 6 additions & 5 deletions source/plugins/uda/uda_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,10 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface)

int pathway = 0;

DATA_SOURCE* data_source = plugin_interface->data_source;
SIGNAL_DESC* signal_desc = plugin_interface->signal_desc;
REQUEST_DATA* request = plugin_interface->request_data;
auto interface = static_cast<::uda::plugins::UdaPluginInterface*>(plugin_interface);
DATA_SOURCE* data_source = interface->data_source;
SIGNAL_DESC* signal_desc = interface->signal_desc;
REQUEST_DATA* request = interface->request_data;

if (data_source->source_id > 0 && signal_desc->signal_desc_id > 0) {
pathway = 1;
Expand Down Expand Up @@ -186,7 +187,7 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface)

// Set Properties

CLIENT_BLOCK* client_block = plugin_interface->client_block;
CLIENT_BLOCK* client_block = interface->client_block;

if (client_block->get_nodimdata) {
udaSetProperty("get_nodimdata");
Expand Down Expand Up @@ -504,7 +505,7 @@ int uda::plugins::uda::Plugin::get(UDA_PLUGIN_INTERFACE* plugin_interface)
// Check the originals have no XML action definitions before replacement
// Why should a plugin have this concern?

DATA_BLOCK* data_block = plugin_interface->data_block;
DATA_BLOCK* data_block = interface->data_block;

if (udaGetClientVersion() >= 7) {
// This should contain everything!
Expand Down
Loading

0 comments on commit 518e87a

Please sign in to comment.