aboutsummaryrefslogtreecommitdiff
path: root/include/url.h
blob: c1278eeaf1187d279eb3001ddffad1df3fb57c7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#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