URI header now returns pointers with ownership.

I've put `.release()` at most of the callsites, but this
gives me something to search for when taking the next
steps.
This commit is contained in:
2025-04-13 15:05:21 -04:00
parent c18a12d223
commit 61c879c218
23 changed files with 151 additions and 156 deletions

View File

@ -19,6 +19,7 @@ extern "C++"
{
#include <string>
#include <optional>
#include <memory>
}
@ -57,8 +58,8 @@ extern "C++"
#define URL_PATH_(u) (u)->path
#define URL_QUERY_(u) (u)->query
#define URL_FRAGMENT_(u) (u)->fragment
#define URL_HOST_(u) a_Url_hostname(u)
#define URL_STR_(u) a_Url_str(u)
#define URL_HOST_(u) a_Url_hostname(*(u))
#define URL_STR_(u) a_Url_str(*(u))
/* this returns a Dstr* */
#define URL_DATA_(u) (u)->data
/* these return an integer */
@ -72,7 +73,8 @@ extern "C++"
* When the "empty" and "undefined" concepts of RFC-2396 are irrelevant to
* the caller, and a string is required, use these methods instead:
*/
#define NPTR2STR(p) ((p) ? (p) : "")
//#define NPTR2STR(p) ((p) ? (p) : "")
inline const char *NPTR2STR( const char *const p ) { return p ? p : ""; }
#define URL_SCHEME(u) NPTR2STR(URL_SCHEME_(u))
#define URL_AUTHORITY(u) NPTR2STR(URL_AUTHORITY_(u))
#define URL_PATH(u) NPTR2STR(URL_PATH_(u))
@ -113,20 +115,21 @@ struct DilloUrl {
};
DilloUrl* a_Url_new(const char *url_str, const char *base_url);
std::unique_ptr< DilloUrl > a_Url_new(const char *url_str, const char *base_url);
char *a_Url_str(const DilloUrl *url);
const char *a_Url_hostname(const DilloUrl *u);
DilloUrl* a_Url_dup(const DilloUrl *u);
int a_Url_cmp(const DilloUrl *A, const DilloUrl *B);
void a_Url_set_flags(DilloUrl *u, int flags);
void a_Url_set_data(DilloUrl *u, std::string_view data);
char *a_Url_str(const DilloUrl &url);
const char *a_Url_hostname(const DilloUrl &u);
std::unique_ptr< DilloUrl > a_Url_dup(const DilloUrl &u);
int a_Url_cmp(const DilloUrl &A, const DilloUrl &B);
inline int a_Url_cmp_c( const DilloUrl *const A, const DilloUrl *const B ) { return a_Url_cmp( *A, *B ); }
void a_Url_set_flags(DilloUrl &u, int flags);
void a_Url_set_data(DilloUrl &u, std::string_view data);
void a_Url_set_ismap_coords(DilloUrl *u, char *coord_str);
char *a_Url_decode_hex_str(const char *str);
char *a_Url_encode_hex_str(const char *str);
char *a_Url_string_strip_delimiters(const char *str);
int a_Url_host_type(const char *host);
bool_t a_Url_same_organization(const DilloUrl *u1, const DilloUrl *u2);
bool_t a_Url_same_organization(const DilloUrl &u1, const DilloUrl &u2);
#ifdef __cplusplus
}
#endif /* __cplusplus */