mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
[protocol] enum protocol -> protocol_T
This commit is contained in:
parent
ef044a5a62
commit
77c47f0096
@ -95,14 +95,14 @@ static const struct protocol_backend protocol_backends[] = {
|
|||||||
* binary search used currently reduces it to 4400 (meaning fm only has HTTP
|
* binary search used currently reduces it to 4400 (meaning fm only has HTTP
|
||||||
* links). */
|
* links). */
|
||||||
|
|
||||||
enum protocol
|
protocol_T
|
||||||
get_protocol(char *name, int namelen)
|
get_protocol(char *name, int namelen)
|
||||||
{
|
{
|
||||||
/* These are really enum protocol values but can take on negative
|
/* These are really protocol_T values but can take on negative
|
||||||
* values and since 0 <= -1 for enum values it's better to use clean
|
* values and since 0 <= -1 for enum values it's better to use clean
|
||||||
* integer type. */
|
* integer type. */
|
||||||
int start, end;
|
int start, end;
|
||||||
enum protocol protocol;
|
protocol_T protocol;
|
||||||
|
|
||||||
/* Almost dichotomic search is used here */
|
/* Almost dichotomic search is used here */
|
||||||
/* Starting at the HTTP entry which is the most common that will make
|
/* Starting at the HTTP entry which is the most common that will make
|
||||||
@ -153,7 +153,7 @@ get_protocol(char *name, int namelen)
|
|||||||
#define VALID_PROTOCOL(p) (0 <= (p) && (p) < PROTOCOL_BACKENDS)
|
#define VALID_PROTOCOL(p) (0 <= (p) && (p) < PROTOCOL_BACKENDS)
|
||||||
|
|
||||||
int
|
int
|
||||||
get_protocol_port(enum protocol protocol)
|
get_protocol_port(protocol_T protocol)
|
||||||
{
|
{
|
||||||
assert(VALID_PROTOCOL(protocol));
|
assert(VALID_PROTOCOL(protocol));
|
||||||
if_assert_failed return 0;
|
if_assert_failed return 0;
|
||||||
@ -165,7 +165,7 @@ get_protocol_port(enum protocol protocol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get_protocol_need_slashes(enum protocol protocol)
|
get_protocol_need_slashes(protocol_T protocol)
|
||||||
{
|
{
|
||||||
assert(VALID_PROTOCOL(protocol));
|
assert(VALID_PROTOCOL(protocol));
|
||||||
if_assert_failed return 0;
|
if_assert_failed return 0;
|
||||||
@ -173,7 +173,7 @@ get_protocol_need_slashes(enum protocol protocol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get_protocol_need_slash_after_host(enum protocol protocol)
|
get_protocol_need_slash_after_host(protocol_T protocol)
|
||||||
{
|
{
|
||||||
assert(VALID_PROTOCOL(protocol));
|
assert(VALID_PROTOCOL(protocol));
|
||||||
if_assert_failed return 0;
|
if_assert_failed return 0;
|
||||||
@ -181,7 +181,7 @@ get_protocol_need_slash_after_host(enum protocol protocol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get_protocol_keep_double_slashes(enum protocol protocol)
|
get_protocol_keep_double_slashes(protocol_T protocol)
|
||||||
{
|
{
|
||||||
assert(VALID_PROTOCOL(protocol));
|
assert(VALID_PROTOCOL(protocol));
|
||||||
if_assert_failed return 0;
|
if_assert_failed return 0;
|
||||||
@ -189,7 +189,7 @@ get_protocol_keep_double_slashes(enum protocol protocol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get_protocol_free_syntax(enum protocol protocol)
|
get_protocol_free_syntax(protocol_T protocol)
|
||||||
{
|
{
|
||||||
assert(VALID_PROTOCOL(protocol));
|
assert(VALID_PROTOCOL(protocol));
|
||||||
if_assert_failed return 0;
|
if_assert_failed return 0;
|
||||||
@ -197,7 +197,7 @@ get_protocol_free_syntax(enum protocol protocol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
get_protocol_need_ssl(enum protocol protocol)
|
get_protocol_need_ssl(protocol_T protocol)
|
||||||
{
|
{
|
||||||
assert(VALID_PROTOCOL(protocol));
|
assert(VALID_PROTOCOL(protocol));
|
||||||
if_assert_failed return 0;
|
if_assert_failed return 0;
|
||||||
@ -205,7 +205,7 @@ get_protocol_need_ssl(enum protocol protocol)
|
|||||||
}
|
}
|
||||||
|
|
||||||
protocol_handler_T *
|
protocol_handler_T *
|
||||||
get_protocol_handler(enum protocol protocol)
|
get_protocol_handler(protocol_T protocol)
|
||||||
{
|
{
|
||||||
assert(VALID_PROTOCOL(protocol));
|
assert(VALID_PROTOCOL(protocol));
|
||||||
if_assert_failed return NULL;
|
if_assert_failed return NULL;
|
||||||
|
@ -43,26 +43,28 @@ enum protocol {
|
|||||||
PROTOCOL_BACKENDS,
|
PROTOCOL_BACKENDS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef unsigned int protocol_T;
|
||||||
|
|
||||||
/* Besides the session an external handler also takes the url as an argument */
|
/* Besides the session an external handler also takes the url as an argument */
|
||||||
typedef void (protocol_handler_T)(struct connection *);
|
typedef void (protocol_handler_T)(struct connection *);
|
||||||
typedef void (protocol_external_handler_T)(struct session *, struct uri *);
|
typedef void (protocol_external_handler_T)(struct session *, struct uri *);
|
||||||
|
|
||||||
/* Accessors for the protocol backends. */
|
/* Accessors for the protocol backends. */
|
||||||
|
|
||||||
int get_protocol_port(enum protocol protocol);
|
int get_protocol_port(protocol_T protocol);
|
||||||
int get_protocol_need_slashes(enum protocol protocol);
|
int get_protocol_need_slashes(protocol_T protocol);
|
||||||
int get_protocol_keep_double_slashes(enum protocol protocol);
|
int get_protocol_keep_double_slashes(protocol_T protocol);
|
||||||
int get_protocol_need_slash_after_host(enum protocol protocol);
|
int get_protocol_need_slash_after_host(protocol_T protocol);
|
||||||
int get_protocol_free_syntax(enum protocol protocol);
|
int get_protocol_free_syntax(protocol_T protocol);
|
||||||
int get_protocol_need_ssl(enum protocol protocol);
|
int get_protocol_need_ssl(protocol_T protocol);
|
||||||
|
|
||||||
protocol_handler_T *get_protocol_handler(enum protocol protocol);
|
protocol_handler_T *get_protocol_handler(protocol_T protocol);
|
||||||
protocol_external_handler_T *get_protocol_external_handler(struct terminal *, struct uri *);
|
protocol_external_handler_T *get_protocol_external_handler(struct terminal *, struct uri *);
|
||||||
|
|
||||||
/* Resolves the given protocol @name with length @namelen to a known protocol,
|
/* Resolves the given protocol @name with length @namelen to a known protocol,
|
||||||
* PROTOCOL_UNKOWN or PROTOCOL_INVALID if no protocol part could be identified.
|
* PROTOCOL_UNKOWN or PROTOCOL_INVALID if no protocol part could be identified.
|
||||||
* User defined protocols (configurable via protocol.user) takes precedence. */
|
* User defined protocols (configurable via protocol.user) takes precedence. */
|
||||||
enum protocol get_protocol(char *name, int namelen);
|
protocol_T get_protocol(char *name, int namelen);
|
||||||
|
|
||||||
extern struct module protocol_module;
|
extern struct module protocol_module;
|
||||||
|
|
||||||
|
@ -1013,7 +1013,7 @@ join_urls(struct uri *base, char *rel)
|
|||||||
|
|
||||||
/* Tries to figure out what protocol @newurl might be specifying by checking if
|
/* Tries to figure out what protocol @newurl might be specifying by checking if
|
||||||
* it exists as a file locally or by checking parts of the host name. */
|
* it exists as a file locally or by checking parts of the host name. */
|
||||||
static enum protocol
|
static protocol_T
|
||||||
find_uri_protocol(char *newurl)
|
find_uri_protocol(char *newurl)
|
||||||
{
|
{
|
||||||
char *ch;
|
char *ch;
|
||||||
@ -1120,7 +1120,7 @@ parse_uri:
|
|||||||
/* Fix translation of 1.2.3.4:5 so IP address part won't be
|
/* Fix translation of 1.2.3.4:5 so IP address part won't be
|
||||||
* interpreted as the protocol name. */
|
* interpreted as the protocol name. */
|
||||||
if (uri.protocol == PROTOCOL_UNKNOWN) {
|
if (uri.protocol == PROTOCOL_UNKNOWN) {
|
||||||
enum protocol protocol = find_uri_protocol(newurl);
|
protocol_T protocol = find_uri_protocol(newurl);
|
||||||
|
|
||||||
/* Code duplication with the URI_ERRNO_INVALID_PROTOCOL
|
/* Code duplication with the URI_ERRNO_INVALID_PROTOCOL
|
||||||
* case. */
|
* case. */
|
||||||
@ -1242,7 +1242,7 @@ parse_uri:
|
|||||||
case URI_ERRNO_INVALID_PROTOCOL:
|
case URI_ERRNO_INVALID_PROTOCOL:
|
||||||
{
|
{
|
||||||
/* No protocol name */
|
/* No protocol name */
|
||||||
enum protocol protocol = find_uri_protocol(newurl);
|
protocol_T protocol = find_uri_protocol(newurl);
|
||||||
struct string str;
|
struct string str;
|
||||||
|
|
||||||
if (!init_string(&str)) return NULL;
|
if (!init_string(&str)) return NULL;
|
||||||
|
@ -37,7 +37,7 @@ struct uri {
|
|||||||
char *string;
|
char *string;
|
||||||
|
|
||||||
/* The internal type of protocol. Can _never_ be PROTOCOL_UNKNOWN. */
|
/* The internal type of protocol. Can _never_ be PROTOCOL_UNKNOWN. */
|
||||||
enum protocol protocol; /* enum protocol */
|
protocol_T protocol; /* protocol_T */
|
||||||
|
|
||||||
/* A special ELinks extension allows i.e. 'http4' or 'ftp6' protocols,
|
/* A special ELinks extension allows i.e. 'http4' or 'ftp6' protocols,
|
||||||
* forcing the given IP family. 0 means the IP family is not forced. */
|
* forcing the given IP family. 0 means the IP family is not forced. */
|
||||||
|
Loading…
Reference in New Issue
Block a user