mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 03:20:11 +01:00
systemd: add nm_sd_dns_name_normalize() accessor
This commit is contained in:
parent
e12e4ef849
commit
1e15ea9dd5
2 changed files with 20 additions and 0 deletions
|
|
@ -93,6 +93,24 @@ nm_sd_hostname_is_valid(const char *s, bool allow_trailing_dot)
|
|||
: (ValidHostnameFlags) 0);
|
||||
}
|
||||
|
||||
char *
|
||||
nm_sd_dns_name_normalize(const char *s)
|
||||
{
|
||||
nm_auto_free char *n = NULL;
|
||||
int r;
|
||||
|
||||
r = dns_name_normalize(s, 0, &n);
|
||||
if (r < 0)
|
||||
return NULL;
|
||||
|
||||
nm_assert(n);
|
||||
|
||||
/* usually we try not to mix malloc/g_malloc and free/g_free. In practice,
|
||||
* they are the same. So here we return a buffer allocated with malloc(),
|
||||
* and the caller should free it with g_free(). */
|
||||
return g_steal_pointer(&n);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
static gboolean
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ nm_sd_dns_name_to_wire_format(const char *domain, guint8 *buffer, size_t len, gb
|
|||
int nm_sd_dns_name_is_valid(const char *s);
|
||||
gboolean nm_sd_hostname_is_valid(const char *s, bool allow_trailing_dot);
|
||||
|
||||
char *nm_sd_dns_name_normalize(const char *s);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
gboolean nm_sd_http_url_is_valid_https(const char *url);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue