1 #ifndef EL__PROTOCOL_PROTOCOL_H
2 #define EL__PROTOCOL_PROTOCOL_H
3 
4 #include "main/module.h"
5 
6 struct connection;
7 struct session;
8 struct terminal;
9 struct uri;
10 
11 enum protocol {
12 	PROTOCOL_ABOUT,
13 	PROTOCOL_BITTORRENT,
14 	PROTOCOL_DATA,
15 	PROTOCOL_FILE,
16 	PROTOCOL_FINGER,
17 	PROTOCOL_FSP,
18 	PROTOCOL_FTP,
19 	PROTOCOL_GOPHER,
20 	PROTOCOL_HTTP,
21 	PROTOCOL_HTTPS,
22 	PROTOCOL_JAVASCRIPT,
23 	PROTOCOL_NEWS,
24 	PROTOCOL_NNTP,
25 	PROTOCOL_NNTPS,
26 	PROTOCOL_PROXY,
27 	PROTOCOL_SMB,
28 	PROTOCOL_SNEWS,
29 
30 	/* Keep these last! */
31 	PROTOCOL_UNKNOWN,
32 	PROTOCOL_USER,
33 	PROTOCOL_LUA,
34 
35 	/* For protocol backend index checking */
36 	PROTOCOL_BACKENDS,
37 };
38 
39 /* Besides the session an external handler also takes the url as an argument */
40 typedef void (protocol_handler_T)(struct connection *);
41 typedef void (protocol_external_handler_T)(struct session *, struct uri *);
42 
43 /* Accessors for the protocol backends. */
44 
45 int get_protocol_port(enum protocol protocol);
46 int get_protocol_need_slashes(enum protocol protocol);
47 int get_protocol_need_slash_after_host(enum protocol protocol);
48 int get_protocol_free_syntax(enum protocol protocol);
49 int get_protocol_need_ssl(enum protocol protocol);
50 
51 protocol_handler_T *get_protocol_handler(enum protocol protocol);
52 protocol_external_handler_T *get_protocol_external_handler(struct terminal *, struct uri *);
53 
54 /* Resolves the given protocol @name with length @namelen to a known protocol,
55  * PROTOCOL_UNKOWN or PROTOCOL_INVALID if no protocol part could be identified.
56  * User defined protocols (configurable via protocol.user) takes precedence. */
57 enum protocol get_protocol(unsigned char *name, int namelen);
58 
59 extern struct module protocol_module;
60 
61 #endif
62