57 if (!src || (*src ==
'\0'))
128 struct Url *url = *ptr;
153 static const char *hex =
"0123456789ABCDEF";
160 while (src && *src && (buflen != 0))
162 if (strchr(
" /:&%=", *src))
168 *buf++ = hex[(*src >> 4) & 0xf];
169 *buf++ = hex[*src & 0xf];
200 if ((s[1] !=
'\0') && (s[2] !=
'\0') && isxdigit((
unsigned char) s[1]) &&
201 isxdigit((
unsigned char) s[2]) && (
hexval(s[1]) >= 0) && (
hexval(s[2]) >= 0))
309 if ((
mutt_str_atoi(ports, &num) < 0) || (num < 0) || (num > 0xffff))
313 url->
port = (
unsigned short) num;
324 *(--url->
path) =
'/';
367 if (url->
user && (url->
user[0] || !(flags & U_PATH)))
374 if (strchr(url->
host,
':'))
enum UrlScheme url_check_scheme(const char *str)
Check the protocol of a URL.
int mutt_map_get_value_n(const char *name, size_t len, const struct Mapping *map)
Lookup the constant for a string.
int url_pct_decode(char *s)
Decode a percent-encoded string.
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
int mutt_str_atoi(const char *str, int *dst)
Convert ASCII string to an integer.
struct Buffer * mutt_buffer_pool_get(void)
Get a Buffer from the pool.
A parsed URL proto://user:password@host:port/path?a=1&b=2
enum UrlScheme scheme
Scheme, e.g. U_SMTPS.
void mutt_buffer_pool_release(struct Buffer **pbuf)
Free a Buffer from the pool.
static size_t mutt_regmatch_len(const regmatch_t *match)
Return the length of a match.
String manipulation buffer.
char * mutt_str_dup(const char *str)
Copy a string, safely.
Url wasn't recognised.
static struct Url * url_new(void)
Create a Url.
#define STAILQ_INSERT_TAIL(head, elm, field)
#define STAILQ_REMOVE_HEAD(head, field)
void url_free(struct Url **ptr)
Free the contents of a URL.
int mutt_buffer_printf(struct Buffer *buf, const char *fmt,...)
Format a string overwriting a Buffer.
static const char * mutt_buffer_string(const struct Buffer *buf)
Convert a buffer to a const char * "string".
const char * mutt_map_get_name(int val, const struct Mapping *map)
Lookup a string for a constant.
imaps://host.com:[993]/...
int url_tobuffer(struct Url *url, struct Buffer *buf, uint8_t flags)
Output the URL string for a given Url object.
#define STAILQ_INIT(head)
UrlScheme
All recognised Url types.
int mutt_buffer_add_printf(struct Buffer *buf, const char *fmt,...)
Format a string appending a Buffer.
size_t mutt_buffer_addstr(struct Buffer *buf, const char *s)
Add a string to a Buffer.
Constants and macros for managing MIME encoding.
void url_pct_encode(char *buf, size_t buflen, const char *src)
Percent-encode a string.
static bool parse_query_string(struct UrlQueryList *list, char *src)
Parse a URL query string.
struct UrlQueryList query_strings
List of query strings.
regmatch_t * mutt_prex_capture(enum Prex which, const char *str)
match a precompiled regex against a string
https://example.com/?[q=foo]
int url_tostring(struct Url *url, char *dest, size_t len, uint8_t flags)
Output the URL string for a given Url object.
...Inbox?[foo=bar&baz=value]
[imaps://user:pass@example.com/INBOX?foo=bar]
imaps://...[127.0.0.1]...
static enum UrlScheme get_scheme(const char *src, const regmatch_t *match)
Extract the scheme part from a matched URL.
#define STAILQ_FOREACH(var, head, field)
#define STAILQ_NEXT(elm, field)
static regoff_t mutt_regmatch_start(const regmatch_t *match)
Return the start of a match.
size_t mutt_str_copy(char *dest, const char *src, size_t dsize)
Copy a string into a buffer (guaranteeing NUL-termination)
Mapping between user-readable string and a constant.
#define STAILQ_EMPTY(head)
static regoff_t mutt_regmatch_end(const regmatch_t *match)
Return the end of a match.
Convenience wrapper for the library headers.
#define STAILQ_FIRST(head)
mailto:[me@example.com]?foo=bar
Parse and identify different URL schemes.
char * src
Raw URL string.
struct Url * url_parse(const char *src)
Fill in Url.