From 6cb5af487fc0f414dc3467370c26ebd399df481a Mon Sep 17 00:00:00 2001 From: Thomas Porzelt Date: Mon, 3 Aug 2009 20:33:17 +0200 Subject: [PATCH] [core] Add li-prefix to structs, enums and function names for encoding helpers --- include/lighttpd/encoding.h | 12 ++++++------ src/common/encoding.c | 18 +++++++++--------- src/modules/mod_dirlist.c | 8 ++++---- src/modules/mod_redirect.c | 2 +- src/modules/mod_rewrite.c | 2 +- 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/include/lighttpd/encoding.h b/include/lighttpd/encoding.h index 7f22eca..cefa7c0 100644 --- a/include/lighttpd/encoding.h +++ b/include/lighttpd/encoding.h @@ -4,14 +4,14 @@ #include typedef enum { - ENCODING_HEX, /* a => 61 */ - ENCODING_HTML, /* HTML special chars. & => & e.g. */ - ENCODING_URI /* relative URI */ -} encoding_t; + LI_ENCODING_HEX, /* a => 61 */ + LI_ENCODING_HTML, /* HTML special chars. & => & e.g. */ + LI_ENCODING_URI /* relative URI */ +} liEncoding; /* encodes special characters in a string and returns the new string */ -GString *string_encode_append(const gchar *str, GString *dest, encoding_t encoding); -GString *string_encode(const gchar *str, GString *dest, encoding_t encoding); +LI_API GString *li_string_encode_append(const gchar *str, GString *dest, liEncoding encoding); +LI_API GString *li_string_encode(const gchar *str, GString *dest, liEncoding encoding); #endif diff --git a/src/common/encoding.c b/src/common/encoding.c index 1c9d687..899a483 100644 --- a/src/common/encoding.c +++ b/src/common/encoding.c @@ -72,7 +72,7 @@ static const gchar encode_map_uri[] = { 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* F0 - FF */ }; -GString *string_encode_append(const gchar *str, GString *dest, encoding_t encoding) { +GString *li_string_encode_append(const gchar *str, GString *dest, liEncoding encoding) { GString *result; guchar *c; guchar *pos = NULL; @@ -81,16 +81,16 @@ GString *string_encode_append(const gchar *str, GString *dest, encoding_t encodi const gchar *map = NULL; switch (encoding) { - case ENCODING_HTML: + case LI_ENCODING_HTML: /* replace html chars with &#xHH; */ map = encode_map_html; encoded_len = 6; break; - case ENCODING_HEX: + case LI_ENCODING_HEX: map = encode_map_hex; encoded_len = 2; break; - case ENCODING_URI: + case LI_ENCODING_URI: /* ? => %HH */ map = encode_map_uri; encoded_len = 3; @@ -116,7 +116,7 @@ GString *string_encode_append(const gchar *str, GString *dest, encoding_t encodi } switch (encoding) { - case ENCODING_HTML: + case LI_ENCODING_HTML: for (c = (guchar*)str; *c != '\0'; c++) { if (map[*c]) { /* char needs to be encoded */ @@ -133,7 +133,7 @@ GString *string_encode_append(const gchar *str, GString *dest, encoding_t encodi } } break; - case ENCODING_HEX: + case LI_ENCODING_HEX: for (c = (guchar*)str; *c != '\0'; c++) { if (map[*c]) { /* char needs to be encoded */ @@ -145,7 +145,7 @@ GString *string_encode_append(const gchar *str, GString *dest, encoding_t encodi } } break; - case ENCODING_URI: + case LI_ENCODING_URI: for (c = (guchar*)str; *c != '\0'; c++) { if (map[*c]) { /* char needs to be encoded */ @@ -165,7 +165,7 @@ GString *string_encode_append(const gchar *str, GString *dest, encoding_t encodi return result; } -GString *string_encode(const gchar *str, GString *dest, encoding_t encoding) { +GString *li_string_encode(const gchar *str, GString *dest, liEncoding encoding) { if (dest) g_string_truncate(dest, 0); - return string_encode_append(str, dest, encoding); + return li_string_encode_append(str, dest, encoding); } diff --git a/src/modules/mod_dirlist.c b/src/modules/mod_dirlist.c index c35cc51..17c1533 100644 --- a/src/modules/mod_dirlist.c +++ b/src/modules/mod_dirlist.c @@ -337,10 +337,10 @@ static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context datebuf[datebuflen] = '\0'; g_string_append_len(listing, CONST_STR_LEN(" path->str, encoded, ENCODING_URI); + li_string_encode(sced->path->str, encoded, LI_ENCODING_URI); g_string_append_len(listing, GSTR_LEN(encoded)); g_string_append_len(listing, CONST_STR_LEN("/\">")); - string_encode(sced->path->str, encoded, ENCODING_HTML); + li_string_encode(sced->path->str, encoded, LI_ENCODING_HTML); g_string_append_len(listing, GSTR_LEN(encoded)); g_string_append_len(listing, CONST_STR_LEN("st.st_mtime); @@ -366,10 +366,10 @@ static liHandlerResult dirlist(liVRequest *vr, gpointer param, gpointer *context dirlist_format_size(sizebuf, sced->st.st_size); g_string_append_len(listing, CONST_STR_LEN(" path->str, encoded, ENCODING_URI); + li_string_encode(sced->path->str, encoded, LI_ENCODING_URI); g_string_append_len(listing, GSTR_LEN(encoded)); g_string_append_len(listing, CONST_STR_LEN("\">")); - string_encode(sced->path->str, encoded, ENCODING_HTML); + li_string_encode(sced->path->str, encoded, LI_ENCODING_HTML); g_string_append_len(listing, GSTR_LEN(encoded)); g_string_append_len(listing, CONST_STR_LEN( "" diff --git a/src/modules/mod_redirect.c b/src/modules/mod_redirect.c index 9dd6f07..530a982 100644 --- a/src/modules/mod_redirect.c +++ b/src/modules/mod_redirect.c @@ -318,7 +318,7 @@ static gboolean redirect_internal(liVRequest *vr, GString *dest, redirect_rule * g_string_append_len(dest, CONST_STR_LEN("http")); } else { if (encoded) - string_encode_append(str->str, dest, ENCODING_URI); + li_string_encode_append(str->str, dest, LI_ENCODING_URI); else g_string_append_len(dest, GSTR_LEN(str)); } diff --git a/src/modules/mod_rewrite.c b/src/modules/mod_rewrite.c index db42aaf..d80b46f 100644 --- a/src/modules/mod_rewrite.c +++ b/src/modules/mod_rewrite.c @@ -302,7 +302,7 @@ static gboolean rewrite_internal(liVRequest *vr, GString *dest_path, GString *de g_string_append_len(dest, CONST_STR_LEN("http")); } else { if (encoded) - string_encode_append(str->str, dest, ENCODING_URI); + li_string_encode_append(str->str, dest, LI_ENCODING_URI); else g_string_append_len(dest, GSTR_LEN(str)); }