From 28a263eac7358e17564f1876efcd67b4f97abd65 Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Fri, 28 Jan 2022 15:56:59 +0100 Subject: [PATCH] [uri] enum uri_component -> uri_component_T --- src/document/html/parser/forms.c | 2 +- src/document/renderer.c | 2 +- src/document/xml/tags.c | 2 +- src/protocol/http/http.c | 2 +- src/protocol/uri.c | 12 ++++++------ src/protocol/uri.h | 13 +++++++------ 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/document/html/parser/forms.c b/src/document/html/parser/forms.c index c765d71d8..a7a7539e2 100644 --- a/src/document/html/parser/forms.c +++ b/src/document/html/parser/forms.c @@ -84,7 +84,7 @@ html_form(struct html_context *html_context, char *a, mem_free(al); } else { - enum uri_component components = URI_ORIGINAL; + uri_component_T components = URI_ORIGINAL; mem_free_if(al); diff --git a/src/document/renderer.c b/src/document/renderer.c index 8c0f53a20..1f9c529e9 100644 --- a/src/document/renderer.c +++ b/src/document/renderer.c @@ -380,7 +380,7 @@ render_document(struct view_state *vs, struct document_view *doc_view, render_encoded_document(cached, document); sort_links(document); if (!document->title) { - enum uri_component components; + uri_component_T components; if (document->uri->protocol == PROTOCOL_FILE) { components = URI_PATH; diff --git a/src/document/xml/tags.c b/src/document/xml/tags.c index 3676da5aa..08483cd9a 100644 --- a/src/document/xml/tags.c +++ b/src/document/xml/tags.c @@ -1260,7 +1260,7 @@ tags_html_form(struct source_renderer *renderer, void *node, unsigned char *a, form->action = join_urls(html_context->base_href, trim_chars(al, ' ', NULL)); mem_free(al); } else { - enum uri_component components = URI_ORIGINAL; + uri_component_T components = URI_ORIGINAL; mem_free_if(al); diff --git a/src/protocol/http/http.c b/src/protocol/http/http.c index 3355a2b23..5e1c3db2b 100644 --- a/src/protocol/http/http.c +++ b/src/protocol/http/http.c @@ -339,7 +339,7 @@ subst_user_agent(char *fmt, char *version, } static void -add_url_to_http_string(struct string *header, struct uri *uri, enum uri_component components) +add_url_to_http_string(struct string *header, struct uri *uri, uri_component_T components) { /* This block substitues spaces in URL by %20s. This is * certainly not the right place where to do it, but now the diff --git a/src/protocol/uri.c b/src/protocol/uri.c index 31bf2b6b8..b4047cf84 100644 --- a/src/protocol/uri.c +++ b/src/protocol/uri.c @@ -459,7 +459,7 @@ compare_component(const char *a, int alen, int compare_uri(const struct uri *a, const struct uri *b, - enum uri_component components) + uri_component_T components) { if (a == b) return 1; if (!components) return 0; @@ -489,7 +489,7 @@ compare_uri(const struct uri *a, const struct uri *b, /* We might need something more intelligent than this Swiss army knife. */ struct string * add_uri_to_string(struct string *string, const struct uri *uri, - enum uri_component components) + uri_component_T components) { /* Custom or unknown keep the URI untouched. */ if (uri->protocol == PROTOCOL_UNKNOWN) @@ -671,7 +671,7 @@ add_uri_to_string(struct string *string, const struct uri *uri, #undef wants char * -get_uri_string(const struct uri *uri, enum uri_component components) +get_uri_string(const struct uri *uri, uri_component_T components) { struct string string; @@ -686,7 +686,7 @@ get_uri_string(const struct uri *uri, enum uri_component components) struct string * add_string_uri_to_string(struct string *string, char *uristring, - enum uri_component components) + uri_component_T components) { struct uri uri; @@ -1298,7 +1298,7 @@ parse_uri: struct uri * -get_composed_uri(struct uri *uri, enum uri_component components) +get_composed_uri(struct uri *uri, uri_component_T components) { char *string; @@ -1597,7 +1597,7 @@ get_uri_cache_entry(char *string, int length) } struct uri * -get_uri(char *string, enum uri_component components) +get_uri(char *string, uri_component_T components) { struct uri_cache_entry *entry; diff --git a/src/protocol/uri.h b/src/protocol/uri.h index 2f76bbc28..86b1ffd82 100644 --- a/src/protocol/uri.h +++ b/src/protocol/uri.h @@ -216,6 +216,7 @@ enum uri_component { URI_FORM_GET = URI_SERVER | URI_PATH, }; +typedef unsigned int uri_component_T; /* List for maintaining multiple URIs. Free it with mem_free() */ struct uri_list { @@ -251,7 +252,7 @@ void free_uri_list(struct uri_list *list); /* Register a new URI in the cache where @components controls which parts are * added to the returned URI. */ -struct uri *get_uri(char *string, enum uri_component components); +struct uri *get_uri(char *string, uri_component_T components); /* Dereference an URI from the cache */ void done_uri(struct uri *uri); @@ -265,7 +266,7 @@ get_uri_reference(struct uri *uri) } /* Get URI using the string returned by get_uri_string(@uri, @components) */ -struct uri *get_composed_uri(struct uri *uri, enum uri_component components); +struct uri *get_composed_uri(struct uri *uri, uri_component_T components); /* Resolves an URI relative to a current working directory (CWD) and possibly * extracts the fragment. It is possible to just use it to extract fragment @@ -282,7 +283,7 @@ char *normalize_uri(struct uri *uri, char *uristring); /* Check if two URIs are equal. If @components are 0 simply compare the whole * URI else only compare the specific parts. */ int compare_uri(const struct uri *uri1, const struct uri *uri2, - enum uri_component components); + uri_component_T components); /* These functions recreate the URI string part by part. */ /* The @components bitmask describes the set of URI components used for @@ -290,15 +291,15 @@ int compare_uri(const struct uri *uri1, const struct uri *uri2, /* Adds the components to an already initialized string. */ struct string *add_uri_to_string(struct string *string, const struct uri *uri, - enum uri_component components); + uri_component_T components); /* Takes an uri string, parses it and adds the desired components. Useful if * there is no struct uri around. */ -struct string *add_string_uri_to_string(struct string *string, char *uristring, enum uri_component components); +struct string *add_string_uri_to_string(struct string *string, char *uristring, uri_component_T components); /* Returns the new URI string or NULL upon an error. */ char *get_uri_string(const struct uri *uri, - enum uri_component components); + uri_component_T components); /* Returns either the uri's port number if available or the protocol's * default port. It is zarro for user protocols. */