molehole/include/url.h

43 lines
695 B
C
Raw Permalink Normal View History

2024-07-23 21:48:28 +00:00
#ifndef _URL_H_
#define _URL_H_
#define MAX_URL_LENGTH 2048
/**
* Molerat URL.
*
* Holds all relevant for molehole to make requests.
*/
struct url {
char *scheme;
char *host;
int port;
char *path;
char *query;
char *fragment;
};
/**
* Parses a `*s` into `*url` as a molerat URL.
*/
int parse_url(struct url *url, char *s);
/**
* Deallocates `struct url *url`.
*/
void free_url(struct url *url);
/**
* Initializes a `struct url*` with sensible defaults.
*/
struct url *init_url(void);
/**
* Get's the strlen of a `struct url*`
*/
int len_url(struct url *url);
/* Error codes */
enum UrlError { INVALID_CHARACTER = -1, MISSING_HOST = -2, MISSING_PORT = -3 };
#endif