diff options
| author | Garrett D'Amore <garrett@damore.org> | 2024-11-18 18:49:01 -0800 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2024-11-18 18:49:01 -0800 |
| commit | 143b6322f8217cfdbef8f3171d55d10348d1be37 (patch) | |
| tree | 60eef8b31cf320c97c1affbbf80a968d6a63e583 /include | |
| parent | dd4695f9492b4f30978e9043d7d6925bfe15a715 (diff) | |
| download | nng-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 'include')
| -rw-r--r-- | include/nng/nng.h | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/include/nng/nng.h b/include/nng/nng.h index 47260b8d..8b56d15a 100644 --- a/include/nng/nng.h +++ b/include/nng/nng.h @@ -1082,20 +1082,7 @@ enum nng_errno_enum { // URL support. We frequently want to process a URL, and these methods // give us a convenient way of doing so. -typedef 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 -} nng_url; +typedef struct nng_url nng_url; // nng_url_parse parses a URL string into a structured form. // Note that the u_port member will be filled out with a numeric @@ -1114,6 +1101,26 @@ NNG_DECL int nng_url_clone(nng_url **, const nng_url *); // snprintf. NNG_DECL int nng_url_sprintf(char *, size_t, const nng_url *); +NNG_DECL const char *nng_url_scheme(const nng_url *); + +// Port (TCP) for a URL, can be zero for ports are not used by the scheme. +NNG_DECL uint16_t nng_url_port(const nng_url *); + +// hostname part of URL, can be NULL if irerelvant to scheme +const char *nng_url_hostname(const nng_url *); + +// user info part (thing before '@') of URL, NULL if absent. +const char *nng_url_userinfo(const nng_url *); + +// path portion of URL, will always non-NULL, but may be empty. +const char *nng_url_path(const nng_url *); + +// query info part of URL, not including '?, NULL if absent' +const char *nng_url_query(const nng_url *); + +// fragment part of URL, not including '#', NULL if absent. +const char *nng_url_fragment(const nng_url *); + // nng_version returns the library version as a human readable string. NNG_DECL const char *nng_version(void); |
