diff options
author | Omar Polo <op@omarpolo.com> | 2021-02-01 11:11:43 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2021-02-01 11:11:43 +0000 |
commit | 2fafa2d23e5607def335902b7a9d10a9de5247a9 (patch) | |
tree | bc8f8e67a3a372511a30cc58a6fc2f515c366fbb /iri.c | |
parent | e17642a7bb0f182c3c6a26c27681d49ca9dce8dc (diff) |
bring the CGI implementation in par with GLV-1.12556
Diffstat (limited to 'iri.c')
-rw-r--r-- | iri.c | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -377,3 +377,31 @@ trim_req_iri(char *iri, const char **err) *i = '\0'; return 1; } + + +int +serialize_iri(struct iri *i, char *buf, size_t len) +{ + size_t l; + + /* in ex.c we receive empty "" strings as NULL */ + if (i->schema == NULL || i->host == NULL) { + memset(buf, 0, len); + return 0; + } + + strlcpy(buf, i->schema, len); + strlcat(buf, "://", len); + strlcat(buf, i->host, len); + strlcat(buf, "/", len); + + if (i->path != NULL) + l = strlcat(buf, i->path, len); + + if (i->query != NULL && *i->query != '\0') { + strlcat(buf, "?", len); + l = strlcat(buf, i->query, len); + } + + return l < len; +} |