mirror of
https://github.com/moparisthebest/wget
synced 2024-07-03 16:38:41 -04:00
Change function params to const in src/iri.[ch]
* iri.h, iri.c: Added const attribute for params of parse_charsset(), check_encoding_name(), idn_encode(), idn_decode(), remote_to_utf8(), set_uri_encoding(), set_content_encoding().
This commit is contained in:
parent
77f5a27e65
commit
25c9b462bf
25
src/iri.c
25
src/iri.c
@ -53,8 +53,9 @@ as that of the covered work. */
|
|||||||
/* Given a string containing "charset=XXX", return the encoding if found,
|
/* Given a string containing "charset=XXX", return the encoding if found,
|
||||||
or NULL otherwise */
|
or NULL otherwise */
|
||||||
char *
|
char *
|
||||||
parse_charset (char *str)
|
parse_charset (const char *str)
|
||||||
{
|
{
|
||||||
|
const char *end;
|
||||||
char *charset;
|
char *charset;
|
||||||
|
|
||||||
if (!str || !*str)
|
if (!str || !*str)
|
||||||
@ -65,14 +66,14 @@ parse_charset (char *str)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
str += 8;
|
str += 8;
|
||||||
charset = str;
|
end = str;
|
||||||
|
|
||||||
/* sXXXav: which chars should be banned ??? */
|
/* sXXXav: which chars should be banned ??? */
|
||||||
while (*charset && !c_isspace (*charset))
|
while (*end && !c_isspace (*end))
|
||||||
charset++;
|
end++;
|
||||||
|
|
||||||
/* sXXXav: could strdupdelim return NULL ? */
|
/* sXXXav: could strdupdelim return NULL ? */
|
||||||
charset = strdupdelim (str, charset);
|
charset = strdupdelim (str, end);
|
||||||
|
|
||||||
/* Do a minimum check on the charset value */
|
/* Do a minimum check on the charset value */
|
||||||
if (!check_encoding_name (charset))
|
if (!check_encoding_name (charset))
|
||||||
@ -95,9 +96,9 @@ find_locale (void)
|
|||||||
|
|
||||||
/* Basic check of an encoding name. */
|
/* Basic check of an encoding name. */
|
||||||
bool
|
bool
|
||||||
check_encoding_name (char *encoding)
|
check_encoding_name (const char *encoding)
|
||||||
{
|
{
|
||||||
char *s = encoding;
|
const char *s = encoding;
|
||||||
|
|
||||||
while (*s)
|
while (*s)
|
||||||
{
|
{
|
||||||
@ -266,7 +267,7 @@ _utf8_is_valid(const char *utf8)
|
|||||||
/* Try to "ASCII encode" UTF-8 host. Return the new domain on success or NULL
|
/* Try to "ASCII encode" UTF-8 host. Return the new domain on success or NULL
|
||||||
on error. */
|
on error. */
|
||||||
char *
|
char *
|
||||||
idn_encode (struct iri *i, char *host)
|
idn_encode (const struct iri *i, const char *host)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char *ascii_encoded;
|
char *ascii_encoded;
|
||||||
@ -304,7 +305,7 @@ idn_encode (struct iri *i, char *host)
|
|||||||
/* Try to decode an "ASCII encoded" host. Return the new domain in the locale
|
/* Try to decode an "ASCII encoded" host. Return the new domain in the locale
|
||||||
on success or NULL on error. */
|
on success or NULL on error. */
|
||||||
char *
|
char *
|
||||||
idn_decode (char *host)
|
idn_decode (const char *host)
|
||||||
{
|
{
|
||||||
char *new;
|
char *new;
|
||||||
int ret;
|
int ret;
|
||||||
@ -323,7 +324,7 @@ idn_decode (char *host)
|
|||||||
/* Try to transcode string str from remote encoding to UTF-8. On success, *new
|
/* Try to transcode string str from remote encoding to UTF-8. On success, *new
|
||||||
contains the transcoded string. *new content is unspecified otherwise. */
|
contains the transcoded string. *new content is unspecified otherwise. */
|
||||||
bool
|
bool
|
||||||
remote_to_utf8 (struct iri *iri, const char *str, char **new)
|
remote_to_utf8 (const struct iri *iri, const char *str, char **new)
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
@ -397,7 +398,7 @@ iri_free (struct iri *i)
|
|||||||
/* Set uri_encoding of struct iri i. If a remote encoding was specified, use
|
/* Set uri_encoding of struct iri i. If a remote encoding was specified, use
|
||||||
it unless force is true. */
|
it unless force is true. */
|
||||||
void
|
void
|
||||||
set_uri_encoding (struct iri *i, char *charset, bool force)
|
set_uri_encoding (struct iri *i, const char *charset, bool force)
|
||||||
{
|
{
|
||||||
DEBUGP (("URI encoding = %s\n", charset ? quote (charset) : "None"));
|
DEBUGP (("URI encoding = %s\n", charset ? quote (charset) : "None"));
|
||||||
if (!force && opt.encoding_remote)
|
if (!force && opt.encoding_remote)
|
||||||
@ -414,7 +415,7 @@ set_uri_encoding (struct iri *i, char *charset, bool force)
|
|||||||
|
|
||||||
/* Set content_encoding of struct iri i. */
|
/* Set content_encoding of struct iri i. */
|
||||||
void
|
void
|
||||||
set_content_encoding (struct iri *i, char *charset)
|
set_content_encoding (struct iri *i, const char *charset)
|
||||||
{
|
{
|
||||||
DEBUGP (("URI content encoding = %s\n", charset ? quote (charset) : "None"));
|
DEBUGP (("URI content encoding = %s\n", charset ? quote (charset) : "None"));
|
||||||
if (opt.encoding_remote)
|
if (opt.encoding_remote)
|
||||||
|
14
src/iri.h
14
src/iri.h
@ -43,18 +43,18 @@ struct iri {
|
|||||||
# include <idna.h>
|
# include <idna.h>
|
||||||
# include <idn-free.h>
|
# include <idn-free.h>
|
||||||
|
|
||||||
char *parse_charset (char *str);
|
char *parse_charset (const char *str);
|
||||||
char *find_locale (void);
|
char *find_locale (void);
|
||||||
bool check_encoding_name (char *encoding);
|
bool check_encoding_name (const char *encoding);
|
||||||
const char *locale_to_utf8 (const char *str);
|
const char *locale_to_utf8 (const char *str);
|
||||||
char *idn_encode (struct iri *i, char *host);
|
char *idn_encode (const struct iri *i, const char *host);
|
||||||
char *idn_decode (char *host);
|
char *idn_decode (const char *host);
|
||||||
bool remote_to_utf8 (struct iri *i, const char *str, char **new);
|
bool remote_to_utf8 (const struct iri *i, const char *str, char **new);
|
||||||
struct iri *iri_new (void);
|
struct iri *iri_new (void);
|
||||||
struct iri *iri_dup (const struct iri *);
|
struct iri *iri_dup (const struct iri *);
|
||||||
void iri_free (struct iri *i);
|
void iri_free (struct iri *i);
|
||||||
void set_uri_encoding (struct iri *i, char *charset, bool force);
|
void set_uri_encoding (struct iri *i, const char *charset, bool force);
|
||||||
void set_content_encoding (struct iri *i, char *charset);
|
void set_content_encoding (struct iri *i, const char *charset);
|
||||||
|
|
||||||
#else /* ENABLE_IRI */
|
#else /* ENABLE_IRI */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user