summary refs log tree commit diff
path: root/net.h
blob: fa1ac873a5a43d7eefde27d2bc799c26c49136a4 (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
#ifndef NET_H
#define NET_H

#include "str.h"
#include "doc.h"

#define HOST_MAX 255
#define PATH_MAX 255

enum protocol {
	PROT_UNKNOWN,
	PROT_FILE,
	PROT_GOPHER,
	PROT_GEMINI,
};

struct addr {
	char host[HOST_MAX + 1];
	char path[PATH_MAX + 1];
	size_t host_len, path_len;
	enum protocol prot;
	int port;
};

int net_addr(const char *url, struct addr *adr, enum protocol prot_default);
int net_fetch(const struct addr *adr, struct buf *buf, enum doc_type *doct);

#endif