Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F11707949
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/utils/netutils.c b/src/utils/netutils.c
index 0b935e0..227cd1f 100644
--- a/src/utils/netutils.c
+++ b/src/utils/netutils.c
@@ -1,87 +1,87 @@
/* -------------------------------------------------------------
RabbitMQ TCL - Net helper functions
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
___ __ \_____ ___ /____ /____(_)_ /___ |/ /_ __ \
__ /_/ / __ `/_ __ \_ __ \_ /_ __/_ /|_/ /_ / / /
_ _, _// /_/ /_ /_/ / /_/ / / / /_ _ / / / / /_/ /
/_/ |_| \__,_/ /_.___//_.___//_/ \__/ /_/ /_/ \___\_\
_____________________
RabbitMQ C AMQP client library TCL wrapper ___ __/_ ____/__ /
TCL module to connect to AMQP brokers. __ / _ / __ /
_ / / /___ _ /___
(c) 2015, Nasqueron, some rights reserved. /_/ \____/ /_____/
Released under BSD-2-Clause license.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Software: RabbitMQ TCL
Author: Sébastien Santoro aka Dereckson
Filename: netutils.c
Created: 2015-12-08
Licence: BSD-2-Clause
------------------------------------------------------------- */
#include <stdlib.h>
#include <string.h>
#include "strutils.h"
/* -------------------------------------------------------------
Parse host:port expression helper functions
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/**
* Gets host from a host:port expression
*
* @param[in] expression the host:port expression
* @return the hostname
*/
char *get_host(const char *expression, const char *defaultHost) {
char *host = malloc(1024 * sizeof(char));
int pos;
// If the expression is empty, the default host is privileged
if (expression[0] == '\0') {
strcpy(host, defaultHost);
return host;
}
// Gets the host part of an host:port expression
pos = strpos(expression, ":");
if (pos == STR_NOT_FOUND) {
strcpy(host, expression);
} else if (pos == 0) {
- strcpy(host, defaultHost); //Handle ":5000" case
+ strcpy(host, defaultHost); // Handle ":5000" case
} else {
strncpy(host, expression, pos);
host[pos] = '\0';
}
return host;
}
/**
* Gets port from a host:port expression
*
* @param[in] expression the host:port expression
* @param[in] defaultPort the default port if omitted
* @return the hostname
*/
int get_port(const char *expression, int defaultPort) {
int port;
int pos;
pos = strpos(expression, ":");
if (pos == STR_NOT_FOUND) {
return defaultPort;
}
expression += pos + 1;
port = atoi(expression);
if (port <= 0 || port > 65535) {
// mq connect server: should use default port instead of 0
// We ignore gracefully any other error
return defaultPort;
}
return port;
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Mon, Sep 15, 04:16 (7 h, 34 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2983699
Default Alt Text
(3 KB)
Attached To
Mode
rRABBITMQTCL RabbitMQ TCL extension
Attached
Detach File
Event Timeline
Log In to Comment