Skip to content

Commit

Permalink
Untabify
Browse files Browse the repository at this point in the history
Used command:
`find . \( -name '*.c' -o -name '*.h' \) -not \( -path "./deps/*" -prune \) ! -type d -exec bash -c 'expand -t 4 "$0" > /tmp/e && mv /tmp/e "$0"' {} \;`
  • Loading branch information
Pro committed May 25, 2019
1 parent 8c7fdf7 commit 6fe8453
Show file tree
Hide file tree
Showing 22 changed files with 165 additions and 165 deletions.
62 changes: 31 additions & 31 deletions arch/network_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ connection_recv(UA_Connection *connection, UA_ByteString *response,
int offset = (int)connection->incompleteChunk.length;
int remaining = connection->config.recvBufferSize - offset;
#else
size_t offset = connection->incompleteChunk.length;
size_t remaining = connection->config.recvBufferSize - offset;
size_t offset = connection->incompleteChunk.length;
size_t remaining = connection->config.recvBufferSize - offset;
#endif

/* Get the received packet(s) */
Expand Down Expand Up @@ -324,16 +324,16 @@ addServerSocket(ServerNetworkLayerTCP *layer, struct addrinfo *ai) {
return;
}

if (layer->port == 0) {
/* Port was automatically chosen. Read it from the OS */
struct sockaddr_in returned_addr;
memset(&returned_addr, 0, sizeof(returned_addr));
socklen_t len = sizeof(returned_addr);
UA_getsockname(newsock, (struct sockaddr *)&returned_addr, &len);
layer->port = ntohs(returned_addr.sin_port);
}
if (layer->port == 0) {
/* Port was automatically chosen. Read it from the OS */
struct sockaddr_in returned_addr;
memset(&returned_addr, 0, sizeof(returned_addr));
socklen_t len = sizeof(returned_addr);
UA_getsockname(newsock, (struct sockaddr *)&returned_addr, &len);
layer->port = ntohs(returned_addr.sin_port);
}

layer->serverSockets[layer->serverSocketsSize] = newsock;
layer->serverSockets[layer->serverSocketsSize] = newsock;
layer->serverSocketsSize++;
}

Expand Down Expand Up @@ -364,26 +364,26 @@ ServerNetworkLayerTCP_start(UA_ServerNetworkLayer *nl, const UA_String *customHo
addServerSocket(layer, ai);
UA_freeaddrinfo(res);

/* Get the discovery url from the hostname */
UA_String du = UA_STRING_NULL;
char discoveryUrlBuffer[256];
char hostnameBuffer[256];
if (customHostname->length) {
du.length = (size_t)UA_snprintf(discoveryUrlBuffer, 255, "opc.tcp://%.*s:%d/",
(int)customHostname->length,
customHostname->data,
layer->port);
du.data = (UA_Byte*)discoveryUrlBuffer;
}else{
if(UA_gethostname(hostnameBuffer, 255) == 0) {
du.length = (size_t)UA_snprintf(discoveryUrlBuffer, 255, "opc.tcp://%s:%d/",
hostnameBuffer, layer->port);
du.data = (UA_Byte*)discoveryUrlBuffer;
} else {
UA_LOG_ERROR(layer->logger, UA_LOGCATEGORY_NETWORK, "Could not get the hostname");
}
}
UA_String_copy(&du, &nl->discoveryUrl);
/* Get the discovery url from the hostname */
UA_String du = UA_STRING_NULL;
char discoveryUrlBuffer[256];
char hostnameBuffer[256];
if (customHostname->length) {
du.length = (size_t)UA_snprintf(discoveryUrlBuffer, 255, "opc.tcp://%.*s:%d/",
(int)customHostname->length,
customHostname->data,
layer->port);
du.data = (UA_Byte*)discoveryUrlBuffer;
}else{
if(UA_gethostname(hostnameBuffer, 255) == 0) {
du.length = (size_t)UA_snprintf(discoveryUrlBuffer, 255, "opc.tcp://%s:%d/",
hostnameBuffer, layer->port);
du.data = (UA_Byte*)discoveryUrlBuffer;
} else {
UA_LOG_ERROR(layer->logger, UA_LOGCATEGORY_NETWORK, "Could not get the hostname");
}
}
UA_String_copy(&du, &nl->discoveryUrl);

UA_LOG_INFO(layer->logger, UA_LOGCATEGORY_NETWORK,
"TCP network layer listening on %.*s",
Expand Down
6 changes: 3 additions & 3 deletions examples/discovery/server_lds.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ int main(void) {
UA_ServerConfig *config = UA_Server_getConfig(server);
UA_ServerConfig_setDefault(config);

// This is an LDS server only. Set the application type to DISCOVERYSERVER.
// NOTE: This will cause UaExpert to not show this instance in the server list.
// See also: https://forum.unified-automation.com/topic1987.html
// This is an LDS server only. Set the application type to DISCOVERYSERVER.
// NOTE: This will cause UaExpert to not show this instance in the server list.
// See also: https://forum.unified-automation.com/topic1987.html
config->applicationDescription.applicationType = UA_APPLICATIONTYPE_DISCOVERYSERVER;
UA_String_clear(&config->applicationDescription.applicationUri);
config->applicationDescription.applicationUri =
Expand Down
42 changes: 21 additions & 21 deletions examples/discovery/server_multicast.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ UA_EndpointDescription *getRegisterEndpointFromServer(const char *discoveryServe
}
UA_Array_delete(endpointArray, endpointArraySize,
&UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION]);
UA_Client_delete(client);
UA_Client_delete(client);
return returnEndpoint;
}

Expand Down Expand Up @@ -236,40 +236,40 @@ int main(int argc, char **argv) {
// use port 0 to dynamically assign port
UA_ServerConfig_setMinimal(config, 0, NULL);

// An LDS server normally has the application type to DISCOVERYSERVER.
// Since this instance implements LDS and other OPC UA services, we set the type to SERVER.
// NOTE: Using DISCOVERYSERVER will cause UaExpert to not show this instance in the server list.
// See also: https://forum.unified-automation.com/topic1987.html
// An LDS server normally has the application type to DISCOVERYSERVER.
// Since this instance implements LDS and other OPC UA services, we set the type to SERVER.
// NOTE: Using DISCOVERYSERVER will cause UaExpert to not show this instance in the server list.
// See also: https://forum.unified-automation.com/topic1987.html

config->applicationDescription.applicationType = UA_APPLICATIONTYPE_SERVER;
UA_String_clear(&config->applicationDescription.applicationUri);
config->applicationDescription.applicationUri =
UA_String_fromChars("urn:open62541.example.server_multicast");

// Enable the mDNS announce and response functionality
config->discovery.mdnsEnable = true;
// Enable the mDNS announce and response functionality
config->discovery.mdnsEnable = true;

config->discovery.mdns.mdnsServerName = UA_String_fromChars("Sample Multicast Server");

// See http://www.opcfoundation.org/UA/schemas/1.03/ServerCapabilities.csv
// For a LDS server, you should only indicate the LDS capability.
// If this instance is an LDS and at the same time a normal OPC UA server, you also have to indicate
// the additional capabilities.
// NOTE: UaExpert does not show LDS-only servers in the list.
// See also: https://forum.unified-automation.com/topic1987.html
// See http://www.opcfoundation.org/UA/schemas/1.03/ServerCapabilities.csv
// For a LDS server, you should only indicate the LDS capability.
// If this instance is an LDS and at the same time a normal OPC UA server, you also have to indicate
// the additional capabilities.
// NOTE: UaExpert does not show LDS-only servers in the list.
// See also: https://forum.unified-automation.com/topic1987.html

config->discovery.mdns.serverCapabilitiesSize = 2;
UA_String *caps = (UA_String *) UA_Array_new(2, &UA_TYPES[UA_TYPES_STRING]);
caps[0] = UA_String_fromChars("LDS");
caps[1] = UA_String_fromChars("NA");
config->discovery.mdns.serverCapabilities = caps;
config->discovery.mdns.serverCapabilitiesSize = 2;
UA_String *caps = (UA_String *) UA_Array_new(2, &UA_TYPES[UA_TYPES_STRING]);
caps[0] = UA_String_fromChars("LDS");
caps[1] = UA_String_fromChars("NA");
config->discovery.mdns.serverCapabilities = caps;

// Start the server and call iterate to wait for the multicast discovery of the LDS
UA_StatusCode retval = UA_Server_run_startup(server);

// callback which is called when a new server is detected through mDNS
// needs to be set after UA_Server_run_startup or UA_Server_run
UA_Server_setServerOnNetworkCallback(server, serverOnNetworkCallback, NULL);
// callback which is called when a new server is detected through mDNS
// needs to be set after UA_Server_run_startup or UA_Server_run
UA_Server_setServerOnNetworkCallback(server, serverOnNetworkCallback, NULL);

if(retval != UA_STATUSCODE_GOOD) {
UA_LOG_ERROR(UA_Log_Stdout, UA_LOGCATEGORY_SERVER,
Expand Down
2 changes: 1 addition & 1 deletion examples/discovery/server_register.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ int main(int argc, char **argv) {

UA_Server *server = UA_Server_new();
UA_ServerConfig *config = UA_Server_getConfig(server);
// use port 0 to dynamically assign port
// use port 0 to dynamically assign port
UA_ServerConfig_setMinimal(config, 0, NULL);

UA_String_clear(&config->applicationDescription.applicationUri);
Expand Down
22 changes: 11 additions & 11 deletions include/open62541/server_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ typedef struct {
#ifdef UA_ENABLE_DISCOVERY
typedef struct {

/* Timeout in seconds when to automatically remove a registered server from
* the list, if it doesn't re-register within the given time frame. A value
* of 0 disables automatic removal. Default is 60 Minutes (60*60). Must be
* bigger than 10 seconds, because cleanup is only triggered approximately
* every 10 seconds. The server will still be removed depending on the
* state of the semaphore file. */
UA_UInt32 cleanupTimeout;
/* Timeout in seconds when to automatically remove a registered server from
* the list, if it doesn't re-register within the given time frame. A value
* of 0 disables automatic removal. Default is 60 Minutes (60*60). Must be
* bigger than 10 seconds, because cleanup is only triggered approximately
* every 10 seconds. The server will still be removed depending on the
* state of the semaphore file. */
UA_UInt32 cleanupTimeout;

/* Enable mDNS announce and response to queries */
bool mdnsEnable;
/* Enable mDNS announce and response to queries */
bool mdnsEnable;

#ifdef UA_ENABLE_DISCOVERY_MULTICAST
UA_MdnsDiscoveryConfiguration mdns;
UA_MdnsDiscoveryConfiguration mdns;
#endif

} UA_ServerConfig_Discovery;
Expand Down Expand Up @@ -188,7 +188,7 @@ struct UA_ServerConfig {

/* Discovery */
#ifdef UA_ENABLE_DISCOVERY
UA_ServerConfig_Discovery discovery;
UA_ServerConfig_Discovery discovery;
#endif

#ifdef UA_ENABLE_SUBSCRIPTIONS
Expand Down
4 changes: 2 additions & 2 deletions plugins/ua_accesscontrol_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ static void deleteMembers_default(UA_AccessControl *ac) {
UA_Array_delete((void*)(uintptr_t)ac->userTokenPolicies,
ac->userTokenPoliciesSize,
&UA_TYPES[UA_TYPES_USERTOKENPOLICY]);
ac->userTokenPolicies = NULL;
ac->userTokenPoliciesSize = 0;
ac->userTokenPolicies = NULL;
ac->userTokenPoliciesSize = 0;

AccessControlContext *context = (AccessControlContext*)ac->context;

Expand Down
8 changes: 4 additions & 4 deletions plugins/ua_config_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ static UA_UsernamePasswordLogin usernamePasswords[2] = {

static UA_StatusCode
setDefaultConfig(UA_ServerConfig *conf) {
if (!conf)
return UA_STATUSCODE_BADINVALIDARGUMENT;
if (!conf)
return UA_STATUSCODE_BADINVALIDARGUMENT;

/* Zero out.. All members have a valid initial value */
UA_ServerConfig_clean(conf);
Expand Down Expand Up @@ -361,8 +361,8 @@ UA_ServerConfig_setMinimalCustomBuffer(UA_ServerConfig *config, UA_UInt16 portNu
const UA_ByteString *certificate,
UA_UInt32 sendBufferSize,
UA_UInt32 recvBufferSize) {
if (!config)
return UA_STATUSCODE_BADINVALIDARGUMENT;
if (!config)
return UA_STATUSCODE_BADINVALIDARGUMENT;

UA_StatusCode retval = setDefaultConfig(config);
if(retval != UA_STATUSCODE_GOOD) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/ua_nodestore_default.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,8 @@ UA_Nodestore_new(void **nsCtx) {

void
UA_Nodestore_delete(void *nsCtx) {
if (!nsCtx)
return;
if (!nsCtx)
return;

NodeMap *ns = (NodeMap*)nsCtx;
#ifdef UA_ENABLE_MULTITHREADING
Expand Down
8 changes: 4 additions & 4 deletions src/server/ua_discovery_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ initMulticastDiscoveryServer(UA_DiscoveryManager *dm, UA_Server* server) {

static void
destroyMulticastDiscoveryServer(UA_DiscoveryManager *dm) {
if (!dm->mdnsDaemon)
return;
if (!dm->mdnsDaemon)
return;

mdnsd_shutdown(dm->mdnsDaemon);
mdnsd_free(dm->mdnsDaemon);
mdnsd_shutdown(dm->mdnsDaemon);
mdnsd_free(dm->mdnsDaemon);

if(dm->mdnsSocket != UA_INVALID_SOCKET) {
UA_close(dm->mdnsSocket);
Expand Down
18 changes: 9 additions & 9 deletions src/server/ua_nodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,17 +283,17 @@ copyStandardAttributes(UA_Node *node, const UA_NodeAttributes *attr) {
/* retval = UA_NodeId_copy(&item->requestedNewNodeId.nodeId, &node->nodeId); */
/* retval |= UA_QualifiedName_copy(&item->browseName, &node->browseName); */

UA_StatusCode retval;
UA_StatusCode retval;
/* The new nodeset format has optional display name.
* See https://github.com/open62541/open62541/issues/2627
* If display name is NULL, then we take the name part of the browse name */
if (attr->displayName.text.length == 0) {
retval = UA_String_copy(&node->browseName.name,
&node->displayName.text);
retval = UA_String_copy(&node->browseName.name,
&node->displayName.text);
} else {
retval = UA_LocalizedText_copy(&attr->displayName,
&node->displayName);
retval |= UA_LocalizedText_copy(&attr->description, &node->description);
retval = UA_LocalizedText_copy(&attr->displayName,
&node->displayName);
retval |= UA_LocalizedText_copy(&attr->description, &node->description);
}

node->writeMask = attr->writeMask;
Expand All @@ -313,8 +313,8 @@ copyCommonVariableAttributes(UA_VariableNode *node,

/* Data type and value rank */
retval = UA_NodeId_copy(&attr->dataType, &node->dataType);
if(retval != UA_STATUSCODE_GOOD)
return retval;
if(retval != UA_STATUSCODE_GOOD)
return retval;
node->valueRank = attr->valueRank;

/* Copy the value */
Expand All @@ -331,7 +331,7 @@ copyCommonVariableAttributes(UA_VariableNode *node,

const UA_ExtensionObject *obj = (const UA_ExtensionObject *)attr->value.data;
if(obj && obj->encoding == UA_EXTENSIONOBJECT_ENCODED_BYTESTRING) {
return UA_STATUSCODE_BADNOTSUPPORTED;
return UA_STATUSCODE_BADNOTSUPPORTED;
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/server/ua_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,10 +216,10 @@ UA_Server_new() {

/* Create Namespaces 0 and 1 */
server->namespaces = (UA_String *)UA_Array_new(2, &UA_TYPES[UA_TYPES_STRING]);
if(!server->namespaces) {
UA_Server_delete(server);
return NULL;
}
if(!server->namespaces) {
UA_Server_delete(server);
return NULL;
}
server->namespaces[0] = UA_STRING_ALLOC("http://opcfoundation.org/UA/");
UA_String_copy(&server->config.applicationDescription.applicationUri, &server->namespaces[1]);
server->namespacesSize = 2;
Expand Down
34 changes: 17 additions & 17 deletions src/server/ua_server_discovery_mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,26 +157,26 @@ mdns_is_self_announce(const UA_Server *server, const struct serverOnNetwork_list
if(UA_String_equal(&entry->serverOnNetwork.discoveryUrl,
&nl->discoveryUrl))
return true;
// check discoveryUrl ignoring tailing slash
// check discoveryUrl ignoring tailing slash
if (((
nl->discoveryUrl.length == entry->serverOnNetwork.discoveryUrl.length +1 &&
nl->discoveryUrl.data[nl->discoveryUrl.length-1] == '/'
) || (
entry->serverOnNetwork.discoveryUrl.length == nl->discoveryUrl.length +1 &&
entry->serverOnNetwork.discoveryUrl.data[entry->serverOnNetwork.discoveryUrl.length-1] == '/'
)
) &&
memcmp(nl->discoveryUrl.data, entry->serverOnNetwork.discoveryUrl.data,
UA_MIN(nl->discoveryUrl.length, entry->serverOnNetwork.discoveryUrl.length)) == 0
nl->discoveryUrl.length == entry->serverOnNetwork.discoveryUrl.length +1 &&
nl->discoveryUrl.data[nl->discoveryUrl.length-1] == '/'
) || (
entry->serverOnNetwork.discoveryUrl.length == nl->discoveryUrl.length +1 &&
entry->serverOnNetwork.discoveryUrl.data[entry->serverOnNetwork.discoveryUrl.length-1] == '/'
)
) &&
memcmp(nl->discoveryUrl.data, entry->serverOnNetwork.discoveryUrl.data,
UA_MIN(nl->discoveryUrl.length, entry->serverOnNetwork.discoveryUrl.length)) == 0
) {
return true;
return true;
}
if (nl->discoveryUrl.length == entry->serverOnNetwork.discoveryUrl.length +1 &&
nl->discoveryUrl.data[nl->discoveryUrl.length-1] == '/' &&
memcmp(nl->discoveryUrl.data, entry->serverOnNetwork.discoveryUrl.data, nl->discoveryUrl.length-1) == 0
) {
return true;
}
if (nl->discoveryUrl.length == entry->serverOnNetwork.discoveryUrl.length +1 &&
nl->discoveryUrl.data[nl->discoveryUrl.length-1] == '/' &&
memcmp(nl->discoveryUrl.data, entry->serverOnNetwork.discoveryUrl.data, nl->discoveryUrl.length-1) == 0
) {
return true;
}
}

/* The discovery URL may also just contain the IP address, but in our
Expand Down
4 changes: 2 additions & 2 deletions src/server/ua_services_discovery.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ void Service_FindServers(UA_Server *server, UA_Session *session,
}

size_t allocSize = foundServersSize;
if(foundSelf)
allocSize++;
if(foundSelf)
allocSize++;

/* Nothing to do? */
if(allocSize == 0)
Expand Down
Loading

0 comments on commit 6fe8453

Please sign in to comment.