diff -r 40a3b13ffc9d -r 9dfc861273e5 src/lib/url.h --- a/src/lib/url.h Tue Nov 18 02:06:52 2008 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,63 +0,0 @@ -#ifndef LIB_URL_H -#define LIB_URL_H - -/* - * A trivial parser for simple URLs - * - * [ [ "+" [ ... ] ] "://" ] [ [ ":" ] "@" ] [  ] [ ":" ] [ "/" ] [ "?" [ [ "=" ] ] [ "&" [ [ "=" ] ] [ ... ] ] - * - * example.com - * tcp://example.com:7348/ - * psql://postgres@localhost/test_db?charset=utf8 - * - */ - -#include -#include - -/* - * The schema - */ -struct url_schema { - size_t count; - const char *list[]; -}; - -/* - * The options at the end - */ -struct url_opts { - size_t count; - struct url_opt { - const char *key; - const char *value; - } list[]; -}; - -/* - * A parsed URL - */ -struct url { - struct url_schema *schema; - const char *username; - const char *password; - const char *hostname; - const char *service; - const char *path; - struct url_opts *opts; -}; - -/* - * Parse the given `text` as an URL, returning the result in `url`. Optional fields that are missing in the text will - * cause those values to be returned unmodified. - * - * Returns zero if the url was valid and was parsed, nonzero if it was invalid. - */ -int url_parse (struct url *url, const char *text); - -/* - * Prints a url in a debug-output format. - */ -void url_dump (const struct url *url, FILE *stream); - -#endif /* LIB_URL_H */