libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit a372d23b4ee68d578a7482f6b2b17018bbe53b5e
parent 324e9852db193ead4a319fc4099baf2b0b8c456d
Author: Christian Grothoff <christian@grothoff.org>
Date:   Tue, 24 Dec 2013 11:28:30 +0000

-hide symbols

Diffstat:
MChangeLog | 4++++
Msrc/include/platform.h | 9+++++++++
Msrc/microhttpd/base64.c | 9+++++----
Msrc/microhttpd/base64.h | 3++-
Msrc/microhttpd/connection.c | 5+++++
Msrc/microhttpd/connection_https.c | 11++++++-----
Msrc/microhttpd/daemon.c | 2++
Msrc/microhttpd/internal.c | 5++++-
Msrc/microhttpd/internal.h | 2+-
Msrc/microhttpd/md5.c | 34+++++++++++++++++-----------------
Msrc/microhttpd/md5.h | 11++++++-----
Msrc/microhttpd/reason_phrase.c | 6++++--
12 files changed, 65 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,7 @@ +Tue Dec 24 12:27:39 CET 2013 + Adding explicit annotations to hide symbols that are not for + export in the C code (gcc 4.0 or higher only). -CG + Sun Dec 22 14:54:30 CET 2013 Adding a few lines to avoid warnings from picky compilers. -CG diff --git a/src/include/platform.h b/src/include/platform.h @@ -111,5 +111,14 @@ #include <plibc.h> +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) +#if GCC_VERSION > 40000 +#define HIDDEN_SYMBOL __attribute__ ((visibility ("hidden"))) +#else +#define HIDDEN_SYMBOL +#endif + #endif diff --git a/src/microhttpd/base64.c b/src/microhttpd/base64.c @@ -26,14 +26,15 @@ static const char base64_digits[] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -char * -BASE64Decode(const char* src) +HIDDEN_SYMBOL +char * +BASE64Decode(const char* src) { size_t in_len = strlen (src); char* dest; char* result; - - if (in_len % 4) + + if (in_len % 4) { /* Wrong base64 string length */ return NULL; diff --git a/src/microhttpd/base64.h b/src/microhttpd/base64.h @@ -11,7 +11,8 @@ #include "platform.h" -char * +HIDDEN_SYMBOL +char * BASE64Decode(const char* src); #endif /* !BASE64_H */ diff --git a/src/microhttpd/connection.c b/src/microhttpd/connection.c @@ -1850,6 +1850,7 @@ update_last_activity (struct MHD_Connection *connection) * @return always #MHD_YES (we should continue to process the * connection) */ +HIDDEN_SYMBOL int MHD_connection_handle_read (struct MHD_Connection *connection) { @@ -1912,6 +1913,7 @@ MHD_connection_handle_read (struct MHD_Connection *connection) * @return always #MHD_YES (we should continue to process the * connection) */ +HIDDEN_SYMBOL int MHD_connection_handle_write (struct MHD_Connection *connection) { @@ -2112,6 +2114,7 @@ cleanup_connection (struct MHD_Connection *connection) * @return #MHD_YES if we should continue to process the * connection (not dead yet), #MHD_NO if it died */ +HIDDEN_SYMBOL int MHD_connection_handle_idle (struct MHD_Connection *connection) { @@ -2548,6 +2551,7 @@ MHD_connection_handle_idle (struct MHD_Connection *connection) * @return #MHD_YES if we should continue to process the * connection (not dead yet), #MHD_NO if it died */ +HIDDEN_SYMBOL int MHD_connection_epoll_update_ (struct MHD_Connection *connection) { @@ -2595,6 +2599,7 @@ MHD_connection_epoll_update_ (struct MHD_Connection *connection) * * @param connection connection to initialize */ +HIDDEN_SYMBOL void MHD_set_http_callbacks_ (struct MHD_Connection *connection) { diff --git a/src/microhttpd/connection_https.c b/src/microhttpd/connection_https.c @@ -35,7 +35,7 @@ /** - * Give gnuTLS chance to work on the TLS handshake. + * Give gnuTLS chance to work on the TLS handshake. * * @param connection connection to handshake on * @return #MHD_YES on error or if the handshake is progressing @@ -51,13 +51,13 @@ run_tls_handshake (struct MHD_Connection *connection) if (connection->state == MHD_TLS_CONNECTION_INIT) { ret = gnutls_handshake (connection->tls_session); - if (ret == GNUTLS_E_SUCCESS) + if (ret == GNUTLS_E_SUCCESS) { /* set connection state to enable HTTP processing */ connection->state = MHD_CONNECTION_INIT; - return MHD_YES; + return MHD_YES; } - if ( (ret == GNUTLS_E_AGAIN) || + if ( (ret == GNUTLS_E_AGAIN) || (ret == GNUTLS_E_INTERRUPTED) ) { /* handshake not done */ @@ -156,7 +156,7 @@ MHD_tls_connection_handle_idle (struct MHD_Connection *connection) return MHD_YES; return MHD_connection_handle_idle (connection); } -#if EPOLL_SUPPORT +#if EPOLL_SUPPORT return MHD_connection_epoll_update_ (connection); #else return MHD_YES; @@ -170,6 +170,7 @@ MHD_tls_connection_handle_idle (struct MHD_Connection *connection) * * @param connection which callbacks should be modified */ +HIDDEN_SYMBOL void MHD_set_https_callbacks (struct MHD_Connection *connection) { diff --git a/src/microhttpd/daemon.c b/src/microhttpd/daemon.c @@ -121,11 +121,13 @@ mhd_panic_std (void *cls, /** * Handler for fatal errors. */ +HIDDEN_SYMBOL MHD_PanicCallback mhd_panic; /** * Closure argument for "mhd_panic". */ +HIDDEN_SYMBOL void *mhd_panic_cls; diff --git a/src/microhttpd/internal.c b/src/microhttpd/internal.c @@ -31,6 +31,7 @@ /** * State to string dictionary. */ +HIDDEN_SYMBOL const char * MHD_state_to_string (enum MHD_CONNECTION_STATE state) { @@ -90,7 +91,7 @@ MHD_state_to_string (enum MHD_CONNECTION_STATE state) * fprintf-like helper function for logging debug * messages. */ -void +void HIDDEN_SYMBOL MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...) { va_list va; @@ -115,6 +116,7 @@ MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...) * @return length of the resulting val (strlen(val) maybe * shorter afterwards due to elimination of escape sequences) */ +HIDDEN_SYMBOL size_t MHD_http_unescape (void *cls, struct MHD_Connection *connection, @@ -165,6 +167,7 @@ MHD_http_unescape (void *cls, } +HIDDEN_SYMBOL time_t MHD_monotonic_time (void) { diff --git a/src/microhttpd/internal.h b/src/microhttpd/internal.h @@ -189,7 +189,7 @@ struct MHD_NonceNc * fprintf-like helper function for logging debug * messages. */ -void +void HIDDEN_SYMBOL MHD_DLOG (const struct MHD_Daemon *daemon, const char *format, ...); #endif diff --git a/src/microhttpd/md5.c b/src/microhttpd/md5.c @@ -28,7 +28,7 @@ /* * Note: this code is harmless on little-endian machines. */ -static void +static void byteReverse(unsigned char *buf, unsigned longs) { @@ -60,7 +60,7 @@ byteReverse(unsigned char *buf, * reflect the addition of 16 longwords of new data. MD5Update blocks * the data and converts bytes into longwords for this routine. */ -static void +static void MD5Transform(uint32_t buf[4], uint32_t in[16]) { @@ -150,7 +150,7 @@ MD5Transform(uint32_t buf[4], * Start MD5 accumulation. Set bit count to 0 and buffer to mysterious * initialization constants. */ -void +void HIDDEN_SYMBOL MD5Init(struct MD5Context *ctx) { ctx->buf[0] = 0x67452301; @@ -166,7 +166,7 @@ MD5Init(struct MD5Context *ctx) * Update context to reflect the concatenation of another buffer full * of bytes. */ -void +void HIDDEN_SYMBOL MD5Update(struct MD5Context *ctx, const void *data, unsigned len) @@ -215,49 +215,49 @@ MD5Update(struct MD5Context *ctx, } /* - * Final wrapup - pad to 64-byte boundary with the bit pattern + * Final wrapup - pad to 64-byte boundary with the bit pattern * 1 0* (64-bit count of bits processed, MSB-first) */ -void -MD5Final(unsigned char digest[16], - struct MD5Context *ctx) +void HIDDEN_SYMBOL +MD5Final (unsigned char digest[16], + struct MD5Context *ctx) { unsigned count; unsigned char *p; /* Compute number of bytes mod 64 */ count = (ctx->bits[0] >> 3) & 0x3F; - + /* Set the first char of padding to 0x80. This is safe since there is always at least one byte free */ p = ctx->in + count; *p++ = 0x80; - + /* Bytes of padding needed to make 64 bytes */ count = 64 - 1 - count; - + /* Pad out to 56 mod 64 */ - if (count < 8) + if (count < 8) { /* Two lots of padding: Pad the first block to 64 bytes */ memset(p, 0, count); byteReverse(ctx->in, 16); MD5Transform(ctx->buf, (uint32_t *) ctx->in); - + /* Now fill the next block with 56 bytes */ memset(ctx->in, 0, 56); - } - else + } + else { /* Pad block to 56 bytes */ memset(p, 0, count - 8); } byteReverse(ctx->in, 14); - + /* Append length in bits and transform */ ((uint32_t *) ctx->in)[14] = ctx->bits[0]; ((uint32_t *) ctx->in)[15] = ctx->bits[1]; - + MD5Transform(ctx->buf, (uint32_t *) ctx->in); byteReverse((unsigned char *) ctx->buf, 4); memcpy(digest, ctx->buf, 16); diff --git a/src/microhttpd/md5.h b/src/microhttpd/md5.h @@ -29,7 +29,7 @@ #define MD5_DIGEST_SIZE 16 -struct MD5Context +struct MD5Context { uint32_t buf[4]; uint32_t bits[2]; @@ -37,15 +37,16 @@ struct MD5Context }; -void +void HIDDEN_SYMBOL MD5Init(struct MD5Context *ctx); -void +void HIDDEN_SYMBOL MD5Update(struct MD5Context *ctx, const void *buf, unsigned len); -void MD5Final(unsigned char digest[MD5_DIGEST_SIZE], - struct MD5Context *ctx); +void HIDDEN_SYMBOL +MD5Final(unsigned char digest[MD5_DIGEST_SIZE], + struct MD5Context *ctx); #endif /* !MD5_H */ diff --git a/src/microhttpd/reason_phrase.c b/src/microhttpd/reason_phrase.c @@ -148,11 +148,13 @@ static const struct MHD_Reason_Block reasons[] = { BLOCK (five_hundred), }; + +HIDDEN_SYMBOL const char * MHD_get_reason_phrase_for (unsigned int code) { - if ( (code >= 100) && - (code < 600) && + if ( (code >= 100) && + (code < 600) && (reasons[code / 100].max > (code % 100)) ) return reasons[code / 100].data[code % 100]; return "Unknown";