aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2024-11-18 18:49:01 -0800
committerGarrett D'Amore <garrett@damore.org>2024-11-18 18:49:01 -0800
commitdd4695f9492b4f30978e9043d7d6925bfe15a715 (patch)
tree84569362574fabe4b984a82e3232e1b75397bb8f /src
parentca6cfe359fa55a5a7f4b6ae73500ffd98e6ee968 (diff)
downloadnng-dd4695f9492b4f30978e9043d7d6925bfe15a715.tar.gz
nng-dd4695f9492b4f30978e9043d7d6925bfe15a715.tar.bz2
nng-dd4695f9492b4f30978e9043d7d6925bfe15a715.zip
Merge internal and external URL APIs. No need for
the separation of nni_url and nng_url.
Diffstat (limited to 'src')
-rw-r--r--src/core/defs.h1
-rw-r--r--src/core/dialer.c10
-rw-r--r--src/core/listener.c10
-rw-r--r--src/core/sockimpl.h4
-rw-r--r--src/core/url.c24
-rw-r--r--src/core/url.h10
-rw-r--r--src/nng.c24
-rw-r--r--src/sp/transport.c2
-rw-r--r--src/sp/transport.h6
-rw-r--r--src/sp/transport/inproc/inproc.c4
-rw-r--r--src/sp/transport/ipc/ipc.c4
-rw-r--r--src/sp/transport/tls/tls.c6
-rw-r--r--src/supplemental/http/http_api.h6
-rw-r--r--src/supplemental/http/http_client.c2
-rw-r--r--src/supplemental/http/http_msg.c2
-rw-r--r--src/supplemental/http/http_server.c6
-rw-r--r--src/supplemental/websocket/websocket.h4
17 files changed, 48 insertions, 77 deletions
diff --git a/src/core/defs.h b/src/core/defs.h
index 6d6e3ff6..46a32ef5 100644
--- a/src/core/defs.h
+++ b/src/core/defs.h
@@ -36,7 +36,6 @@
// Internal code should use these names when possible.
typedef nng_msg nni_msg;
typedef nng_sockaddr nni_sockaddr;
-typedef nng_url nni_url;
typedef nng_iov nni_iov;
typedef nng_aio nni_aio;
diff --git a/src/core/dialer.c b/src/core/dialer.c
index d39eb99a..2eb02471 100644
--- a/src/core/dialer.c
+++ b/src/core/dialer.c
@@ -42,7 +42,7 @@ nni_dialer_destroy(nni_dialer *d)
d->d_ops.d_fini(d->d_data);
}
nni_mtx_fini(&d->d_mtx);
- nni_url_free(d->d_url);
+ nng_url_free(d->d_url);
NNI_FREE_STRUCT(d);
}
@@ -214,19 +214,19 @@ nni_dialer_create(nni_dialer **dp, nni_sock *s, const char *url_str)
nni_sp_tran *tran;
nni_dialer *d;
int rv;
- nni_url *url;
+ nng_url *url;
- if ((rv = nni_url_parse(&url, url_str)) != 0) {
+ if ((rv = nng_url_parse(&url, url_str)) != 0) {
return (rv);
}
if (((tran = nni_sp_tran_find(url)) == NULL) ||
(tran->tran_dialer == NULL)) {
- nni_url_free(url);
+ nng_url_free(url);
return (NNG_ENOTSUP);
}
if ((d = NNI_ALLOC_STRUCT(d)) == NULL) {
- nni_url_free(url);
+ nng_url_free(url);
return (NNG_ENOMEM);
}
d->d_url = url;
diff --git a/src/core/listener.c b/src/core/listener.c
index e1cdf833..8fa50a4f 100644
--- a/src/core/listener.c
+++ b/src/core/listener.c
@@ -43,7 +43,7 @@ nni_listener_destroy(nni_listener *l)
if (l->l_data != NULL) {
l->l_ops.l_fini(l->l_data);
}
- nni_url_free(l->l_url);
+ nng_url_free(l->l_url);
NNI_FREE_STRUCT(l);
}
@@ -203,19 +203,19 @@ nni_listener_create(nni_listener **lp, nni_sock *s, const char *url_str)
nni_sp_tran *tran;
nni_listener *l;
int rv;
- nni_url *url;
+ nng_url *url;
- if ((rv = nni_url_parse(&url, url_str)) != 0) {
+ if ((rv = nng_url_parse(&url, url_str)) != 0) {
return (rv);
}
if (((tran = nni_sp_tran_find(url)) == NULL) ||
(tran->tran_listener == NULL)) {
- nni_url_free(url);
+ nng_url_free(url);
return (NNG_ENOTSUP);
}
if ((l = NNI_ALLOC_STRUCT(l)) == NULL) {
- nni_url_free(url);
+ nng_url_free(url);
return (NNG_ENOMEM);
}
l->l_url = url;
diff --git a/src/core/sockimpl.h b/src/core/sockimpl.h
index 0a5114c0..deb226e4 100644
--- a/src/core/sockimpl.h
+++ b/src/core/sockimpl.h
@@ -22,7 +22,7 @@ struct nni_dialer {
uint32_t d_id; // endpoint id
nni_list_node d_node; // per socket list
nni_sock *d_sock;
- nni_url *d_url;
+ nng_url *d_url;
nni_pipe *d_pipe; // active pipe (for re-dialer)
int d_ref;
bool d_closed; // full shutdown
@@ -63,7 +63,7 @@ struct nni_listener {
uint32_t l_id; // endpoint id
nni_list_node l_node; // per socket list
nni_sock *l_sock;
- nni_url *l_url;
+ nng_url *l_url;
int l_ref;
bool l_closed; // full shutdown
nni_atomic_flag l_closing; // close started (shutdown)
diff --git a/src/core/url.c b/src/core/url.c
index c5be4f83..6e17e8c7 100644
--- a/src/core/url.c
+++ b/src/core/url.c
@@ -326,9 +326,9 @@ nni_url_default_port(const char *scheme)
// scheme with a leading //, such as http:// or tcp://. So our parser
// is a bit more restricted, but sufficient for our needs.
int
-nni_url_parse(nni_url **urlp, const char *raw)
+nng_url_parse(nng_url **urlp, const char *raw)
{
- nni_url *url;
+ nng_url *url;
size_t len;
const char *s;
char *p;
@@ -523,12 +523,12 @@ nni_url_parse(nni_url **urlp, const char *raw)
return (0);
error:
- nni_url_free(url);
+ nng_url_free(url);
return (rv);
}
void
-nni_url_free(nni_url *url)
+nng_url_free(nng_url *url)
{
if (url != NULL) {
nni_strfree(url->u_rawurl);
@@ -540,7 +540,7 @@ nni_url_free(nni_url *url)
}
int
-nni_url_sprintf(char *str, size_t size, const nni_url *url)
+nng_url_sprintf(char *str, size_t size, const nng_url *url)
{
const char *scheme = url->u_scheme;
const char *host = url->u_hostname;
@@ -576,16 +576,16 @@ nni_url_sprintf(char *str, size_t size, const nni_url *url)
}
int
-nni_url_asprintf(char **str, const nni_url *url)
+nni_url_asprintf(char **str, const nng_url *url)
{
char *result;
size_t sz;
- sz = nni_url_sprintf(NULL, 0, url) + 1;
+ sz = nng_url_sprintf(NULL, 0, url) + 1;
if ((result = nni_alloc(sz)) == NULL) {
return (NNG_ENOMEM);
}
- nni_url_sprintf(result, sz, url);
+ nng_url_sprintf(result, sz, url);
*str = result;
return (0);
}
@@ -594,9 +594,9 @@ nni_url_asprintf(char **str, const nni_url *url)
// override. If non-zero, this port number replaces the port number
// in the port string.
int
-nni_url_asprintf_port(char **str, const nni_url *url, int port)
+nni_url_asprintf_port(char **str, const nng_url *url, int port)
{
- nni_url myurl = *url;
+ nng_url myurl = *url;
if (port > 0) {
myurl.u_port = (uint16_t) port;
@@ -607,9 +607,9 @@ nni_url_asprintf_port(char **str, const nni_url *url, int port)
#define URL_COPYSTR(d, s) ((s != NULL) && ((d = nni_strdup(s)) == NULL))
int
-nni_url_clone(nni_url **dstp, const nni_url *src)
+nng_url_clone(nng_url **dstp, const nng_url *src)
{
- nni_url *dst;
+ nng_url *dst;
if ((dst = NNI_ALLOC_STRUCT(dst)) == NULL) {
return (NNG_ENOMEM);
diff --git a/src/core/url.h b/src/core/url.h
index f43d3db6..2eb3ed46 100644
--- a/src/core/url.h
+++ b/src/core/url.h
@@ -13,14 +13,10 @@
#include "core/defs.h"
-extern int nni_url_parse(nni_url **, const char *path);
-extern void nni_url_free(nni_url *);
-extern int nni_url_clone(nni_url **, const nni_url *);
extern uint16_t nni_url_default_port(const char *);
-extern int nni_url_sprintf(char *, size_t, const nni_url *);
-extern int nni_url_asprintf(char **, const nni_url *);
-extern int nni_url_asprintf_port(char **, const nni_url *, int);
+extern int nni_url_asprintf(char **, const nng_url *);
+extern int 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 nni_url *);
+extern int nni_url_to_address(nng_sockaddr *, const nng_url *);
#endif // CORE_URL_H
diff --git a/src/nng.c b/src/nng.c
index dd8a98f1..9ed2a0ab 100644
--- a/src/nng.c
+++ b/src/nng.c
@@ -2020,30 +2020,6 @@ nng_aio_begin(nng_aio *aio)
return (true);
}
-int
-nng_url_parse(nng_url **result, const char *ustr)
-{
- return (nni_url_parse(result, ustr));
-}
-
-void
-nng_url_free(nng_url *url)
-{
- nni_url_free(url);
-}
-
-int
-nng_url_clone(nng_url **dstp, const nng_url *src)
-{
- return (nni_url_clone(dstp, src));
-}
-
-int
-nng_url_sprintf(char *buf, size_t bufsz, const nng_url *src)
-{
- return (nni_url_sprintf(buf, bufsz, src));
-}
-
#define xstr(a) str(a)
#define str(a) #a
diff --git a/src/sp/transport.c b/src/sp/transport.c
index 973be40b..61192e82 100644
--- a/src/sp/transport.c
+++ b/src/sp/transport.c
@@ -32,7 +32,7 @@ nni_sp_tran_register(nni_sp_tran *tran)
}
nni_sp_tran *
-nni_sp_tran_find(nni_url *url)
+nni_sp_tran_find(nng_url *url)
{
// address is of the form "<scheme>://blah..."
nni_sp_tran *t;
diff --git a/src/sp/transport.h b/src/sp/transport.h
index 8fd47483..34584328 100644
--- a/src/sp/transport.h
+++ b/src/sp/transport.h
@@ -27,7 +27,7 @@
struct nni_sp_dialer_ops {
// d_init creates a vanilla dialer. The value created is
// used for the first argument for all other dialer functions.
- int (*d_init)(void **, nni_url *, nni_dialer *);
+ int (*d_init)(void **, nng_url *, nni_dialer *);
// d_fini frees the resources associated with the dialer.
// The dialer will already have been closed.
@@ -66,7 +66,7 @@ struct nni_sp_dialer_ops {
struct nni_sp_listener_ops {
// l_init creates a vanilla listener. The value created is
// used for the first argument for all other listener functions.
- int (*l_init)(void **, nni_url *, nni_listener *);
+ int (*l_init)(void **, nng_url *, nni_listener *);
// l_fini frees the resources associated with the listener.
// The listener will already have been closed.
@@ -184,7 +184,7 @@ struct nni_sp_tran {
// These APIs are used by the framework internally, and not for use by
// transport implementations.
-extern nni_sp_tran *nni_sp_tran_find(nni_url *);
+extern nni_sp_tran *nni_sp_tran_find(nng_url *);
extern void nni_sp_tran_sys_init(void);
extern void nni_sp_tran_sys_fini(void);
extern void nni_sp_tran_register(nni_sp_tran *);
diff --git a/src/sp/transport/inproc/inproc.c b/src/sp/transport/inproc/inproc.c
index b7ead07c..b759ccc0 100644
--- a/src/sp/transport/inproc/inproc.c
+++ b/src/sp/transport/inproc/inproc.c
@@ -283,7 +283,7 @@ inproc_pipe_get_addr(void *arg, void *buf, size_t *szp, nni_opt_type t)
}
static int
-inproc_dialer_init(void **epp, nni_url *url, nni_dialer *ndialer)
+inproc_dialer_init(void **epp, nng_url *url, nni_dialer *ndialer)
{
inproc_ep *ep;
nni_sock *sock = nni_dialer_sock(ndialer);
@@ -306,7 +306,7 @@ inproc_dialer_init(void **epp, nni_url *url, nni_dialer *ndialer)
}
static int
-inproc_listener_init(void **epp, nni_url *url, nni_listener *nlistener)
+inproc_listener_init(void **epp, nng_url *url, nni_listener *nlistener)
{
inproc_ep *ep;
nni_sock *sock = nni_listener_sock(nlistener);
diff --git a/src/sp/transport/ipc/ipc.c b/src/sp/transport/ipc/ipc.c
index 82af6925..aefd82ce 100644
--- a/src/sp/transport/ipc/ipc.c
+++ b/src/sp/transport/ipc/ipc.c
@@ -851,7 +851,7 @@ ipc_ep_init(ipc_ep **epp, nni_sock *sock)
}
static int
-ipc_ep_init_dialer(void **dp, nni_url *url, nni_dialer *dialer)
+ipc_ep_init_dialer(void **dp, nng_url *url, nni_dialer *dialer)
{
ipc_ep *ep;
int rv;
@@ -874,7 +874,7 @@ ipc_ep_init_dialer(void **dp, nni_url *url, nni_dialer *dialer)
}
static int
-ipc_ep_init_listener(void **dp, nni_url *url, nni_listener *listener)
+ipc_ep_init_listener(void **dp, nng_url *url, nni_listener *listener)
{
ipc_ep *ep;
int rv;
diff --git a/src/sp/transport/tls/tls.c b/src/sp/transport/tls/tls.c
index b1aea7b3..394eb561 100644
--- a/src/sp/transport/tls/tls.c
+++ b/src/sp/transport/tls/tls.c
@@ -61,7 +61,7 @@ struct tlstran_ep {
bool closed;
bool fini;
int refcnt;
- nni_url *url;
+ nng_url *url;
nni_list pipes;
nni_reap_node reap;
nng_stream_dialer *dialer;
@@ -825,7 +825,7 @@ tlstran_ep_init(tlstran_ep **epp, nng_url *url, nni_sock *sock)
}
static int
-tlstran_ep_init_dialer(void **dp, nni_url *url, nni_dialer *ndialer)
+tlstran_ep_init_dialer(void **dp, nng_url *url, nni_dialer *ndialer)
{
tlstran_ep *ep;
int rv;
@@ -859,7 +859,7 @@ tlstran_ep_init_dialer(void **dp, nni_url *url, nni_dialer *ndialer)
}
static int
-tlstran_ep_init_listener(void **lp, nni_url *url, nni_listener *nlistener)
+tlstran_ep_init_listener(void **lp, nng_url *url, nni_listener *nlistener)
{
tlstran_ep *ep;
int rv;
diff --git a/src/supplemental/http/http_api.h b/src/supplemental/http/http_api.h
index 813f9fe6..dbda53ae 100644
--- a/src/supplemental/http/http_api.h
+++ b/src/supplemental/http/http_api.h
@@ -108,7 +108,7 @@ extern int nni_http_conn_getopt(
// Note that the iovs of the aio's are clobbered by these methods -- callers
// must not use them for any other purpose.
-extern int nni_http_req_alloc(nni_http_req **, const nni_url *);
+extern int nni_http_req_alloc(nni_http_req **, const nng_url *);
extern int nni_http_res_alloc(nni_http_res **);
extern int nni_http_res_alloc_error(nni_http_res **, uint16_t);
extern void nni_http_req_free(nni_http_req *);
@@ -170,7 +170,7 @@ extern void nni_http_write_full(nni_http_conn *, nni_aio *);
// a restricted binding is required, we recommend using a URL consisting
// of an empty host name, such as http:// or https:// -- this would
// convert to binding to the default port on all interfaces on the host.
-extern int nni_http_server_init(nni_http_server **, const nni_url *);
+extern int nni_http_server_init(nni_http_server **, const nng_url *);
// nni_http_server_fini drops the reference count on the server, and
// if this was the last reference, closes down the server and frees
@@ -349,7 +349,7 @@ extern const char *nni_http_handler_get_uri(nni_http_handler *);
// Client stuff.
-extern int nni_http_client_init(nni_http_client **, const nni_url *);
+extern int nni_http_client_init(nni_http_client **, const nng_url *);
extern void nni_http_client_fini(nni_http_client *);
// nni_http_client_set_tls sets the TLS configuration. This wipes out
diff --git a/src/supplemental/http/http_client.c b/src/supplemental/http/http_client.c
index 0fbe3ef9..af5bc717 100644
--- a/src/supplemental/http/http_client.c
+++ b/src/supplemental/http/http_client.c
@@ -96,7 +96,7 @@ nni_http_client_fini(nni_http_client *c)
}
int
-nni_http_client_init(nni_http_client **cp, const nni_url *url)
+nni_http_client_init(nni_http_client **cp, const nng_url *url)
{
int rv;
nni_http_client *c;
diff --git a/src/supplemental/http/http_msg.c b/src/supplemental/http/http_msg.c
index a2ab218f..2c258e2c 100644
--- a/src/supplemental/http/http_msg.c
+++ b/src/supplemental/http/http_msg.c
@@ -600,7 +600,7 @@ nni_http_res_get_buf(nni_http_res *res, void **data, size_t *szp)
}
int
-nni_http_req_alloc(nni_http_req **reqp, const nni_url *url)
+nni_http_req_alloc(nni_http_req **reqp, const nng_url *url)
{
nni_http_req *req;
if ((req = NNI_ALLOC_STRUCT(req)) == NULL) {
diff --git a/src/supplemental/http/http_server.c b/src/supplemental/http/http_server.c
index 03b3cf68..0f0d2d80 100644
--- a/src/supplemental/http/http_server.c
+++ b/src/supplemental/http/http_server.c
@@ -1,5 +1,5 @@
//
-// Copyright 2023 Staysail Systems, Inc. <info@staysail.tech>
+// Copyright 2024 Staysail Systems, Inc. <info@staysail.tech>
// Copyright 2018 Capitar IT Group BV <info@capitar.com>
// Copyright 2018 QXSoftware <lh563566994@126.com>
// Copyright 2019 Devolutions <info@devolutions.net>
@@ -932,7 +932,7 @@ http_server_fini(nni_http_server *s)
}
static int
-http_server_init(nni_http_server **serverp, const nni_url *url)
+http_server_init(nni_http_server **serverp, const nng_url *url)
{
nni_http_server *s;
int rv;
@@ -980,7 +980,7 @@ http_server_init(nni_http_server **serverp, const nni_url *url)
}
int
-nni_http_server_init(nni_http_server **serverp, const nni_url *url)
+nni_http_server_init(nni_http_server **serverp, const nng_url *url)
{
int rv;
nni_http_server *s;
diff --git a/src/supplemental/websocket/websocket.h b/src/supplemental/websocket/websocket.h
index ea4975ff..fab716bf 100644
--- a/src/supplemental/websocket/websocket.h
+++ b/src/supplemental/websocket/websocket.h
@@ -31,7 +31,7 @@ typedef struct nni_ws_dialer nni_ws_dialer;
// Much of the websocket API is still "private", meaning you should not
// rely upon it being around.
-extern int nni_ws_listener_alloc(nng_stream_listener **, const nni_url *);
-extern int nni_ws_dialer_alloc(nng_stream_dialer **, const nni_url *);
+extern int nni_ws_listener_alloc(nng_stream_listener **, const nng_url *);
+extern int nni_ws_dialer_alloc(nng_stream_dialer **, const nng_url *);
#endif // NNG_SUPPLEMENTAL_WEBSOCKET_WEBSOCKET_H