aboutsummaryrefslogtreecommitdiff
path: root/src/core/url.h
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
commit143b6322f8217cfdbef8f3171d55d10348d1be37 (patch)
tree60eef8b31cf320c97c1affbbf80a968d6a63e583 /src/core/url.h
parentdd4695f9492b4f30978e9043d7d6925bfe15a715 (diff)
downloadnng-143b6322f8217cfdbef8f3171d55d10348d1be37.tar.gz
nng-143b6322f8217cfdbef8f3171d55d10348d1be37.tar.bz2
nng-143b6322f8217cfdbef8f3171d55d10348d1be37.zip
Introduce accessors for nng_url struct and make it opaque.
This provides safety by ensuring that applications do not depend on the size or layout of nng_url itself.
Diffstat (limited to 'src/core/url.h')
-rw-r--r--src/core/url.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/core/url.h b/src/core/url.h
index 2eb3ed46..f8a141ac 100644
--- a/src/core/url.h
+++ b/src/core/url.h
@@ -13,6 +13,21 @@
#include "core/defs.h"
+struct nng_url {
+ char *u_rawurl; // never NULL
+ const char *u_scheme; // never NULL
+ const char *u_userinfo; // will be NULL if not specified
+ char *u_hostname; // name only, will be "" if not specified
+ uint16_t u_port; // port, may be zero for schemes that do not use
+ char *u_path; // path, will be "" if not specified
+ char *u_query; // without '?', will be NULL if not specified
+ char *u_fragment; // without '#', will be NULL if not specified
+ // these members are private
+ char *u_buffer;
+ size_t u_bufsz;
+ char u_static[NNG_MAXADDRLEN]; // Most URLs fit within this
+};
+
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);