aboutsummaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/platform.h4
-rw-r--r--src/core/sockfd.c10
-rw-r--r--src/core/sockfd.h8
-rw-r--r--src/core/stream.c4
-rw-r--r--src/core/tcp.c14
-rw-r--r--src/core/tcp.h6
-rw-r--r--src/core/url.c52
-rw-r--r--src/core/url.h12
8 files changed, 55 insertions, 55 deletions
diff --git a/src/core/platform.h b/src/core/platform.h
index 3b6f4db5..a13ae9f2 100644
--- a/src/core/platform.h
+++ b/src/core/platform.h
@@ -340,8 +340,8 @@ typedef struct nni_ipc_listener nni_ipc_listener;
// IPC is so different from platform to platform. The following should
// be implemented. If IPC isn't supported, all of these functions should
// be stubs that just return NNG_ENOTSUP.
-extern int nni_ipc_dialer_alloc(nng_stream_dialer **, const nng_url *);
-extern int nni_ipc_listener_alloc(nng_stream_listener **, const nng_url *);
+extern nng_err nni_ipc_dialer_alloc(nng_stream_dialer **, const nng_url *);
+extern nng_err nni_ipc_listener_alloc(nng_stream_listener **, const nng_url *);
//
// UDP support. UDP is not connection oriented, and only has the notion
diff --git a/src/core/sockfd.c b/src/core/sockfd.c
index 758cb755..f67ab64f 100644
--- a/src/core/sockfd.c
+++ b/src/core/sockfd.c
@@ -1,5 +1,5 @@
//
-// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -20,7 +20,7 @@
// accept is performed, then another slot is available.
#define NNG_SFD_LISTEN_QUEUE 16
-int
+nng_err
nni_sfd_dialer_alloc(nng_stream_dialer **dp, const nng_url *url)
{
NNI_ARG_UNUSED(dp);
@@ -81,7 +81,7 @@ static void
sfd_start_conn(sfd_listener *l, nni_aio *aio)
{
int fd;
- int rv;
+ nng_err rv;
nni_sfd_conn *c;
NNI_ASSERT(l->listen_cnt > 0);
fd = l->listen_q[0];
@@ -209,7 +209,7 @@ sfd_listener_set(
return (nni_setopt(sfd_listener_options, name, l, buf, sz, t));
}
-int
+nng_err
nni_sfd_listener_alloc(nng_stream_listener **lp, const nng_url *url)
{
sfd_listener *l;
@@ -233,5 +233,5 @@ nni_sfd_listener_alloc(nng_stream_listener **lp, const nng_url *url)
l->ops.sl_set = sfd_listener_set;
*lp = (void *) l;
- return (0);
+ return (NNG_OK);
}
diff --git a/src/core/sockfd.h b/src/core/sockfd.h
index ca37f0e1..8985c009 100644
--- a/src/core/sockfd.h
+++ b/src/core/sockfd.h
@@ -1,5 +1,5 @@
//
-// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -16,9 +16,9 @@
// an arbitrary byte stream file descriptor (UNIX) or handle (Windows)
// with a nng_stream.
typedef struct nni_sfd_conn nni_sfd_conn;
-extern int nni_sfd_conn_alloc(nni_sfd_conn **cp, int fd);
-extern int nni_sfd_dialer_alloc(nng_stream_dialer **, const nng_url *);
-extern int nni_sfd_listener_alloc(nng_stream_listener **, const nng_url *);
+extern nng_err nni_sfd_conn_alloc(nni_sfd_conn **cp, int fd);
+extern nng_err nni_sfd_dialer_alloc(nng_stream_dialer **, const nng_url *);
+extern nng_err nni_sfd_listener_alloc(nng_stream_listener **, const nng_url *);
// this is used to close a file descriptor, in case we cannot
// create a connection (or if the listener is closed before the
diff --git a/src/core/stream.c b/src/core/stream.c
index 1af8e572..d8111c7a 100644
--- a/src/core/stream.c
+++ b/src/core/stream.c
@@ -21,8 +21,8 @@
static struct {
const char *scheme;
- int (*dialer_alloc)(nng_stream_dialer **, const nng_url *);
- int (*listener_alloc)(nng_stream_listener **, const nng_url *);
+ nng_err (*dialer_alloc)(nng_stream_dialer **, const nng_url *);
+ nng_err (*listener_alloc)(nng_stream_listener **, const nng_url *);
} stream_drivers[] = {
{
diff --git a/src/core/tcp.c b/src/core/tcp.c
index f7a30ed2..2017452b 100644
--- a/src/core/tcp.c
+++ b/src/core/tcp.c
@@ -219,10 +219,10 @@ tcp_dialer_set(
return (nni_tcp_dialer_set(d->d, name, buf, sz, t));
}
-static int
+static nng_err
tcp_dialer_alloc(tcp_dialer **dp)
{
- int rv;
+ nng_err rv;
tcp_dialer *d;
if ((d = NNI_ALLOC_STRUCT(d)) == NULL) {
@@ -234,7 +234,7 @@ tcp_dialer_alloc(tcp_dialer **dp)
nni_aio_init(&d->resaio, tcp_dial_res_cb, d);
nni_aio_init(&d->conaio, tcp_dial_con_cb, d);
- if ((rv = nni_tcp_dialer_init(&d->d)) != 0) {
+ if ((rv = nni_tcp_dialer_init(&d->d)) != NNG_OK) {
tcp_dialer_free(d);
return (rv);
}
@@ -247,16 +247,16 @@ tcp_dialer_alloc(tcp_dialer **dp)
d->ops.sd_set = tcp_dialer_set;
*dp = d;
- return (0);
+ return (NNG_OK);
}
-int
+nng_err
nni_tcp_dialer_alloc(nng_stream_dialer **dp, const nng_url *url)
{
tcp_dialer *d;
int rv;
- if ((rv = tcp_dialer_alloc(&d)) != 0) {
+ if ((rv = tcp_dialer_alloc(&d)) != NNG_OK) {
return (rv);
}
@@ -279,5 +279,5 @@ nni_tcp_dialer_alloc(nng_stream_dialer **dp, const nng_url *url)
d->port = url->u_port;
*dp = (void *) d;
- return (0);
+ return (NNG_OK);
}
diff --git a/src/core/tcp.h b/src/core/tcp.h
index 6e1829dc..cc41dfac 100644
--- a/src/core/tcp.h
+++ b/src/core/tcp.h
@@ -1,5 +1,5 @@
//
-// Copyright 2020 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
//
// This software is supplied under the terms of the MIT License, a
// copy of which should be located in the distribution where this
@@ -15,7 +15,7 @@
// These are interfaces we use for TCP internally. These are not exposed
// to the public API.
-extern int nni_tcp_dialer_alloc(nng_stream_dialer **, const nng_url *);
-extern int nni_tcp_listener_alloc(nng_stream_listener **, const nng_url *);
+extern nng_err nni_tcp_dialer_alloc(nng_stream_dialer **, const nng_url *);
+extern nng_err nni_tcp_listener_alloc(nng_stream_listener **, const nng_url *);
#endif // CORE_TCP_H
diff --git a/src/core/url.c b/src/core/url.c
index 9ee8c9a9..9db92992 100644
--- a/src/core/url.c
+++ b/src/core/url.c
@@ -1,5 +1,5 @@
//
-// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2025 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
//
// This software is supplied under the terms of the MIT License, a
@@ -39,7 +39,7 @@ url_hex_val(char c)
// is malformed UTF-8. We consider UTF-8 malformed when the sequence
// is an invalid code point, not the shortest possible code point, or
// incomplete.
-static int
+static nng_err
url_utf8_validate(void *arg)
{
uint8_t *s = arg;
@@ -88,7 +88,7 @@ url_utf8_validate(void *arg)
return (NNG_EINVAL);
}
}
- return (0);
+ return (NNG_OK);
}
size_t
@@ -119,7 +119,7 @@ nni_url_decode(uint8_t *out, const char *in, size_t max_len)
return (len);
}
-int
+nng_err
nni_url_canonify_uri(char *out)
{
size_t src, dst;
@@ -217,11 +217,11 @@ nni_url_canonify_uri(char *out)
// Finally lets make sure that the results are valid UTF-8.
// This guards against using UTF-8 redundancy to break security.
- if ((rv = url_utf8_validate(out)) != 0) {
+ if ((rv = url_utf8_validate(out)) != NNG_OK) {
return (rv);
}
- return (0);
+ return (NNG_OK);
}
static struct {
@@ -325,7 +325,7 @@ nni_url_default_port(const char *scheme)
// Nanomsg URLs are always of the first form, we always require a
// scheme with a leading //, such as http:// or tcp://. So our parser
// is a bit more restricted, but sufficient for our needs.
-static int
+static nng_err
nni_url_parse_inline_inner(nng_url *url, const char *raw)
{
size_t len;
@@ -392,7 +392,7 @@ nni_url_parse_inline_inner(nng_url *url, const char *raw)
url->u_query = NULL;
url->u_fragment = NULL;
url->u_userinfo = NULL;
- return (0);
+ return (NNG_OK);
}
// Look for host part (including colon). Will be terminated by
@@ -504,24 +504,24 @@ nni_url_parse_inline_inner(nng_url *url, const char *raw)
url->u_port = nni_url_default_port(url->u_scheme);
}
- return (0);
+ return (NNG_OK);
}
-int
+nng_err
nni_url_parse_inline(nng_url *url, const char *raw)
{
- int rv = nni_url_parse_inline_inner(url, raw);
- if (rv != 0) {
+ nng_err rv = nni_url_parse_inline_inner(url, raw);
+ if (rv != NNG_OK) {
nni_url_fini(url);
}
return (rv);
}
-int
+nng_err
nng_url_parse(nng_url **urlp, const char *raw)
{
nng_url *url;
- int rv;
+ nng_err rv;
if ((url = NNI_ALLOC_STRUCT(url)) == NULL) {
return (NNG_ENOMEM);
@@ -531,7 +531,7 @@ nng_url_parse(nng_url **urlp, const char *raw)
return (rv);
}
*urlp = url;
- return (0);
+ return (NNG_OK);
}
void
@@ -590,7 +590,7 @@ nng_url_sprintf(char *str, size_t size, const nng_url *url)
url->u_fragment != NULL ? url->u_fragment : ""));
}
-int
+nng_err
nni_url_asprintf(char **str, const nng_url *url)
{
char *result;
@@ -602,13 +602,13 @@ nni_url_asprintf(char **str, const nng_url *url)
}
nng_url_sprintf(result, sz, url);
*str = result;
- return (0);
+ return (NNG_OK);
}
// nni_url_asprintf_port is like nni_url_asprintf, but includes a port
// override. If non-zero, this port number replaces the port number
// in the port string.
-int
+nng_err
nni_url_asprintf_port(char **str, const nng_url *url, int port)
{
nng_url myurl = *url;
@@ -621,7 +621,7 @@ nni_url_asprintf_port(char **str, const nng_url *url, int port)
#define URL_COPYSTR(d, s) ((s != NULL) && ((d = nni_strdup(s)) == NULL))
-int
+nng_err
nni_url_clone_inline(nng_url *dst, const nng_url *src)
{
if (src->u_bufsz != 0) {
@@ -652,36 +652,36 @@ nni_url_clone_inline(nng_url *dst, const nng_url *src)
}
dst->u_scheme = src->u_scheme;
dst->u_port = src->u_port;
- return (0);
+ return (NNG_OK);
}
#undef URL_COPYSTR
-int
+nng_err
nng_url_clone(nng_url **dstp, const nng_url *src)
{
nng_url *dst;
- int rv;
+ nng_err rv;
if ((dst = NNI_ALLOC_STRUCT(dst)) == NULL) {
return (NNG_ENOMEM);
}
- if ((rv = nni_url_clone_inline(dst, src) != 0)) {
+ if ((rv = nni_url_clone_inline(dst, src) != NNG_OK)) {
NNI_FREE_STRUCT(dst);
return (rv);
}
*dstp = dst;
- return (0);
+ return (NNG_OK);
}
// nni_url_to_address resolves a URL into a sockaddr, assuming the URL is for
// an IP address.
-int
+nng_err
nni_url_to_address(nng_sockaddr *sa, const nng_url *url)
{
int af;
nni_aio aio;
const char *h;
- int rv;
+ nng_err rv;
nni_resolv_item ri;
// This assumes the scheme is one that uses TCP/IP addresses.
diff --git a/src/core/url.h b/src/core/url.h
index c74749c6..4f387c5d 100644
--- a/src/core/url.h
+++ b/src/core/url.h
@@ -28,13 +28,13 @@ struct nng_url {
};
extern uint16_t nni_url_default_port(const char *);
-extern int nni_url_asprintf(char **, const nng_url *);
-extern int nni_url_asprintf_port(char **, const nng_url *, int);
+extern nng_err nni_url_asprintf(char **, const nng_url *);
+extern nng_err nni_url_asprintf_port(char **, const nng_url *, int);
extern size_t nni_url_decode(uint8_t *, const char *, size_t);
-extern int nni_url_to_address(nng_sockaddr *, const nng_url *);
-extern int nni_url_parse_inline(nng_url *, const char *);
-extern int nni_url_clone_inline(nng_url *, const nng_url *);
+extern nng_err nni_url_to_address(nng_sockaddr *, const nng_url *);
+extern nng_err nni_url_parse_inline(nng_url *, const char *);
+extern nng_err nni_url_clone_inline(nng_url *, const nng_url *);
extern void nni_url_fini(nng_url *);
-extern int nni_url_canonify_uri(char *);
+extern nng_err nni_url_canonify_uri(char *);
#endif // CORE_URL_H