Hide private library symbols
authorPeter Pentchev <roam@ringlet.net>
Sat, 30 Mar 2013 01:52:21 +0000 (09:52 +0800)
committerAndy Green <andy.green@linaro.org>
Sat, 30 Mar 2013 01:52:21 +0000 (09:52 +0800)
Signed-off-by: Peter Pentchev <roam@ringlet.net>
CMakeLists.txt
lib/base64-decode.c
lib/client-handshake.c
lib/daemonize.c
lib/extension.c
lib/handshake.c
lib/libwebsockets.c
lib/libwebsockets.h
lib/output.c
lib/parsers.c
scripts/kernel-doc

index 9c18df6..df9b698 100644 (file)
@@ -303,7 +303,7 @@ endif(UNIX)
 
 
 if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
-       set( CMAKE_C_FLAGS "-Wall -Werror -O4 " )
+       set( CMAKE_C_FLAGS "-Wall -Werror -O4 -fvisibility=hidden " )
 endif ()
 
 source_group("Headers Private"  FILES ${HDR_PRIVATE})
index 2545d40..51db267 100644 (file)
@@ -48,7 +48,7 @@ static const char encode[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
 static const char decode[] = "|$$$}rstuvwxyz{$$$$$$$>?@ABCDEFGHIJKLMNOPQRSTUVW"
                             "$$$$$$XYZ[\\]^_`abcdefghijklmnopq";
 
-int
+LWS_VISIBLE int
 lws_b64_encode_string(const char *in, int in_len, char *out, int out_size)
 {
        unsigned char triple[3];
@@ -97,7 +97,7 @@ lws_b64_encode_string(const char *in, int in_len, char *out, int out_size)
  * according to out_size
  */
 
-int
+LWS_VISIBLE int
 lws_b64_decode_string(const char *in, char *out, int out_size)
 {
        int len;
index 79dba7b..de99a20 100644 (file)
@@ -154,7 +154,7 @@ oom4:
  *     This function creates a connection to a remote server
  */
 
-struct libwebsocket *
+LWS_VISIBLE struct libwebsocket *
 libwebsocket_client_connect(struct libwebsocket_context *context,
                              const char *address,
                              int port,
@@ -304,7 +304,7 @@ bail:
  *     This function creates a connection to a remote server
  */
 
-struct libwebsocket *
+LWS_VISIBLE struct libwebsocket *
 libwebsocket_client_connect_extended(struct libwebsocket_context *context,
                              const char *address,
                              int port,
index 5e3af8e..4130764 100644 (file)
@@ -21,6 +21,8 @@
 #include <unistd.h>
 #include <errno.h>
 
+#include "private-libwebsockets.h"
+
 int pid_daemon;
 static char *lock_path;
 
@@ -89,7 +91,7 @@ static void lws_daemon_closing(int sigact)
  * The process context you called from has been terminated then.
  */
 
-int
+LWS_VISIBLE int
 lws_daemonize(const char *_lock_path)
 {
        pid_t sid, parent;
index 3d255b3..d4660c0 100644 (file)
@@ -27,7 +27,7 @@ struct libwebsocket_extension libwebsocket_internal_extensions[] = {
        }
 };
 
-struct libwebsocket_extension *libwebsocket_get_internal_extensions()
+LWS_VISIBLE struct libwebsocket_extension *libwebsocket_get_internal_extensions()
 {
        return libwebsocket_internal_extensions;
 }
index 3fa30f1..d2c9e1e 100644 (file)
@@ -53,7 +53,7 @@
  * machine that is completely independent of packet size.
  */
 
-int
+LWS_VISIBLE int
 libwebsocket_read(struct libwebsocket_context *context,
                     struct libwebsocket *wsi, unsigned char *buf, size_t len)
 {
index 7bcc110..3e9f761 100644 (file)
@@ -91,7 +91,7 @@ static const char * const log_level_names[] = {
  *     was built from
  */
 
-const char *
+LWS_VISIBLE const char *
 lws_get_library_version(void)
 {
        return library_version;
@@ -447,7 +447,7 @@ just_kill_connection:
  *     determined, they will be returned as valid zero-length strings.
  */
 
-void
+LWS_VISIBLE void
 libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
        struct libwebsocket *wsi, int fd, char *name, int name_len,
                                        char *rip, int rip_len)
@@ -520,7 +520,7 @@ bail:
        lws_latency(context, wsi, "libwebsockets_get_peer_addresses", ret, 1);
 }
 
-int libwebsockets_get_random(struct libwebsocket_context *context,
+LWS_VISIBLE int libwebsockets_get_random(struct libwebsocket_context *context,
                                                             void *buf, int len)
 {
        int n;
@@ -610,7 +610,7 @@ int lws_set_socket_options(struct libwebsocket_context *context, int fd)
        return 0;
 }
 
-int lws_send_pipe_choked(struct libwebsocket *wsi)
+LWS_VISIBLE int lws_send_pipe_choked(struct libwebsocket *wsi)
 {
        struct pollfd fds;
 
@@ -830,7 +830,7 @@ libwebsocket_service_timeout_check(struct libwebsocket_context *context,
  *     after letting lws try to service it.
  */
 
-int
+LWS_VISIBLE int
 libwebsocket_service_fd(struct libwebsocket_context *context,
                                                          struct pollfd *pollfd)
 {
@@ -1138,7 +1138,7 @@ handled:
  *     context.  After calling this, any further use of the context is
  *     undefined.
  */
-void
+LWS_VISIBLE void
 libwebsocket_context_destroy(struct libwebsocket_context *context)
 {
 #ifndef LWS_NO_EXTENSIONS
@@ -1265,7 +1265,7 @@ libwebsocket_context_user(struct libwebsocket_context *context)
  *     nothing is pending, or as soon as it services whatever was pending.
  */
 
-int
+LWS_VISIBLE int
 libwebsocket_service(struct libwebsocket_context *context, int timeout_ms)
 {
        int n;
@@ -1356,7 +1356,7 @@ lws_get_extension_user_matching_ext(struct libwebsocket *wsi,
  * @wsi:       Websocket connection instance to get callback for
  */
 
-int
+LWS_VISIBLE int
 libwebsocket_callback_on_writable(struct libwebsocket_context *context,
                                                      struct libwebsocket *wsi)
 {
@@ -1404,7 +1404,7 @@ libwebsocket_callback_on_writable(struct libwebsocket_context *context,
  * @protocol:  Protocol whose connections will get callbacks
  */
 
-int
+LWS_VISIBLE int
 libwebsocket_callback_on_writable_all_protocol(
                                  const struct libwebsocket_protocols *protocol)
 {
@@ -1454,7 +1454,7 @@ libwebsocket_set_timeout(struct libwebsocket *wsi,
  * @wsi:       Websocket connection instance
  */
 
-int
+LWS_VISIBLE int
 libwebsocket_get_socket_fd(struct libwebsocket *wsi)
 {
        return wsi->sock;
@@ -1567,7 +1567,7 @@ _libwebsocket_rx_flow_control(struct libwebsocket *wsi)
  * @enable:    0 = disable read servicing for this connection, 1 = enable
  */
 
-int
+LWS_VISIBLE int
 libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable)
 {
        if (enable == (wsi->u.ws.rxflow_change_to & LWS_RXFLOW_ALLOW))
@@ -1589,7 +1589,7 @@ libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable)
  * @protocol:  all connections using this protocol will be allowed to receive
  */
 
-void
+LWS_VISIBLE void
 libwebsocket_rx_flow_allow_all_protocol(
                                const struct libwebsocket_protocols *protocol)
 {
@@ -1618,7 +1618,7 @@ libwebsocket_rx_flow_allow_all_protocol(
  */
 
 
-extern const char *
+LWS_VISIBLE extern const char *
 libwebsocket_canonical_hostname(struct libwebsocket_context *context)
 {
        return (const char *)context->canonical_hostname;
@@ -1708,7 +1708,7 @@ int user_callback_handle_rxflow(callback_function callback_function,
  *     one place; they're all handled in the user callback.
  */
 
-struct libwebsocket_context *
+LWS_VISIBLE struct libwebsocket_context *
 libwebsocket_create_context(struct lws_context_creation_info *info)
 {
        struct libwebsocket_context *context = NULL;
@@ -2250,19 +2250,19 @@ bail:
  *     this is how you can get a pointer to the active protocol if needed.
  */
 
-const struct libwebsocket_protocols *
+LWS_VISIBLE const struct libwebsocket_protocols *
 libwebsockets_get_protocol(struct libwebsocket *wsi)
 {
        return wsi->protocol;
 }
 
-int
+LWS_VISIBLE int
 libwebsocket_is_final_fragment(struct libwebsocket *wsi)
 {
        return wsi->u.ws.final;
 }
 
-unsigned char
+LWS_VISIBLE unsigned char
 libwebsocket_get_reserved_bits(struct libwebsocket *wsi)
 {
        return wsi->u.ws.rsv;
@@ -2309,12 +2309,12 @@ static void lwsl_emit_stderr(int level, const char *line)
 }
 
 #ifdef WIN32
-void lwsl_emit_syslog(int level, const char *line)
+LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
 {
        lwsl_emit_stderr(level, line);
 }
 #else
-void lwsl_emit_syslog(int level, const char *line)
+LWS_VISIBLE void lwsl_emit_syslog(int level, const char *line)
 {
        int syslog_level = LOG_DEBUG;
 
@@ -2336,7 +2336,7 @@ void lwsl_emit_syslog(int level, const char *line)
 }
 #endif
 
-void _lws_log(int filter, const char *format, ...)
+LWS_VISIBLE void _lws_log(int filter, const char *format, ...)
 {
        char buf[256];
        va_list ap;
@@ -2363,7 +2363,7 @@ void _lws_log(int filter, const char *format, ...)
  *     emission on stderr.
  */
 
-void lws_set_log_level(int level, void (*log_emit_function)(int level,
+LWS_VISIBLE void lws_set_log_level(int level, void (*log_emit_function)(int level,
                                                              const char *line))
 {
        log_level = level;
index b7eaa41..f7da4d0 100644 (file)
@@ -46,8 +46,10 @@ typedef int ssize_t;
 
 #ifdef LWS_DLL
 #ifdef LWS_INTERNAL
+#define LWS_VISIBLE
 #define LWS_EXTERN extern __declspec(dllexport)
 #else
+#define LWS_VISIBLE
 #define LWS_EXTERN extern __declspec(dllimport)
 #endif
 #endif
@@ -55,6 +57,13 @@ typedef int ssize_t;
 #else // NOT WIN32
 #include <poll.h>
 #include <unistd.h>
+
+#if defined(__GNUC__)
+#define LWS_VISIBLE __attribute__((visibility("default")))
+#else
+#define LWS_VISIBLE
+#endif
+
 #endif
 
 #include <assert.h>
@@ -81,7 +90,7 @@ enum lws_log_levels {
        LLL_COUNT = 10 /* set to count of valid flags */
 };
 
-LWS_EXTERN void _lws_log(int filter, const char *format, ...);
+LWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...);
 
 /* notice, warn and log are always compiled in */
 #define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__)
@@ -101,7 +110,7 @@ LWS_EXTERN void _lws_log(int filter, const char *format, ...);
 #define lwsl_ext(...)  _lws_log(LLL_EXT, __VA_ARGS__)
 #define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__)
 #define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__)
-LWS_EXTERN void lwsl_hexdump(void *buf, size_t len);
+LWS_VISIBLE LWS_EXTERN void lwsl_hexdump(void *buf, size_t len);
 
 #else /* no debug */
 
@@ -590,7 +599,7 @@ struct libwebsocket_extension;
  *             pollfd struct for this socket descriptor.  If you are using the
  *             internal polling loop, you can just ignore it.
  */
-LWS_EXTERN int callback(struct libwebsocket_context *context,
+LWS_VISIBLE LWS_EXTERN int callback(struct libwebsocket_context *context,
                        struct libwebsocket *wsi,
                         enum libwebsocket_callback_reasons reason, void *user,
                                                          void *in, size_t len);
@@ -659,7 +668,7 @@ typedef int (callback_function)(struct libwebsocket_context *context,
  *             buffer safely, it should copy the data into its own buffer and
  *             set the lws_tokens token pointer to it.
  */
-LWS_EXTERN int extension_callback(struct libwebsocket_context *context,
+LWS_VISIBLE LWS_EXTERN int extension_callback(struct libwebsocket_context *context,
                        struct libwebsocket_extension *ext,
                        struct libwebsocket *wsi,
                        enum libwebsocket_extension_callback_reasons reason,
@@ -795,27 +804,27 @@ struct lws_context_creation_info {
 
 };
 
-LWS_EXTERN
+LWS_VISIBLE LWS_EXTERN
 void lws_set_log_level(int level,
                        void (*log_emit_function)(int level, const char *line));
 
-LWS_EXTERN void
+LWS_VISIBLE LWS_EXTERN void
 lwsl_emit_syslog(int level, const char *line);
 
-LWS_EXTERN struct libwebsocket_context *
+LWS_VISIBLE LWS_EXTERN struct libwebsocket_context *
 libwebsocket_create_context(struct lws_context_creation_info *info);
 
-LWS_EXTERN void
+LWS_VISIBLE LWS_EXTERN void
 libwebsocket_context_destroy(struct libwebsocket_context *context);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsocket_service(struct libwebsocket_context *context, int timeout_ms);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsocket_service_fd(struct libwebsocket_context *context,
                                                         struct pollfd *pollfd);
 
-LWS_EXTERN void *
+LWS_VISIBLE LWS_EXTERN void *
 libwebsocket_context_user(struct libwebsocket_context *context);
 
 /*
@@ -853,49 +862,49 @@ libwebsocket_context_user(struct libwebsocket_context *context);
 #define LWS_SEND_BUFFER_PRE_PADDING (4 + 10 + (2 * MAX_MUX_RECURSION))
 #define LWS_SEND_BUFFER_POST_PADDING 4
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf, size_t len,
                                     enum libwebsocket_write_protocol protocol);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsockets_serve_http_file(struct libwebsocket_context *context,
                        struct libwebsocket *wsi, const char *file,
                                                     const char *content_type);
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsockets_serve_http_file_fragment(struct libwebsocket_context *context,
                        struct libwebsocket *wsi);
 
-LWS_EXTERN const struct libwebsocket_protocols *
+LWS_VISIBLE LWS_EXTERN const struct libwebsocket_protocols *
 libwebsockets_get_protocol(struct libwebsocket *wsi);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsocket_callback_on_writable(struct libwebsocket_context *context,
                                                      struct libwebsocket *wsi);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsocket_callback_on_writable_all_protocol(
                                 const struct libwebsocket_protocols *protocol);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsocket_get_socket_fd(struct libwebsocket *wsi);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsocket_is_final_fragment(struct libwebsocket *wsi);
 
-LWS_EXTERN unsigned char
+LWS_VISIBLE LWS_EXTERN unsigned char
 libwebsocket_get_reserved_bits(struct libwebsocket *wsi);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsocket_rx_flow_control(struct libwebsocket *wsi, int enable);
 
-LWS_EXTERN void
+LWS_VISIBLE LWS_EXTERN void
 libwebsocket_rx_flow_allow_all_protocol(
                                const struct libwebsocket_protocols *protocol);
 
-LWS_EXTERN size_t
+LWS_VISIBLE LWS_EXTERN size_t
 libwebsockets_remaining_packet_payload(struct libwebsocket *wsi);
 
-LWS_EXTERN struct libwebsocket *
+LWS_VISIBLE LWS_EXTERN struct libwebsocket *
 libwebsocket_client_connect(struct libwebsocket_context *clients,
                              const char *address,
                              int port,
@@ -906,7 +915,7 @@ libwebsocket_client_connect(struct libwebsocket_context *clients,
                              const char *protocol,
                              int ietf_version_or_minus_one);
 
-LWS_EXTERN struct libwebsocket *
+LWS_VISIBLE LWS_EXTERN struct libwebsocket *
 libwebsocket_client_connect_extended(struct libwebsocket_context *clients,
                              const char *address,
                              int port,
@@ -918,46 +927,46 @@ libwebsocket_client_connect_extended(struct libwebsocket_context *clients,
                              int ietf_version_or_minus_one,
                              void *userdata);
 
-LWS_EXTERN const char *
+LWS_VISIBLE LWS_EXTERN const char *
 libwebsocket_canonical_hostname(struct libwebsocket_context *context);
 
 
-LWS_EXTERN void
+LWS_VISIBLE LWS_EXTERN void
 libwebsockets_get_peer_addresses(struct libwebsocket_context *context,
                struct libwebsocket *wsi, int fd, char *name, int name_len,
                                        char *rip, int rip_len);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsockets_get_random(struct libwebsocket_context *context,
                                                            void *buf, int len);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 lws_daemonize(const char *_lock_path);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 lws_send_pipe_choked(struct libwebsocket *wsi);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 lws_frame_is_binary(struct libwebsocket *wsi);
 
-LWS_EXTERN unsigned char *
+LWS_VISIBLE LWS_EXTERN unsigned char *
 libwebsockets_SHA1(const unsigned char *d, size_t n, unsigned char *md);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 lws_b64_encode_string(const char *in, int in_len, char *out, int out_size);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 lws_b64_decode_string(const char *in, char *out, int out_size);
 
-LWS_EXTERN const char *
+LWS_VISIBLE LWS_EXTERN const char *
 lws_get_library_version(void);
 
 /* access to headers... only valid while headers valid */
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h);
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
                                                enum lws_token_indexes h);
 
@@ -966,13 +975,13 @@ lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
  * useful when integrating with other app poll loop service code.
  */
 
-LWS_EXTERN int
+LWS_VISIBLE LWS_EXTERN int
 libwebsocket_read(struct libwebsocket_context *context,
                                struct libwebsocket *wsi,
                                               unsigned char *buf, size_t len);
 
 #ifndef LWS_NO_EXTENSIONS
-LWS_EXTERN struct libwebsocket_extension *libwebsocket_get_internal_extensions();
+LWS_VISIBLE LWS_EXTERN struct libwebsocket_extension *libwebsocket_get_internal_extensions();
 #endif
 
 #ifdef __cplusplus
index 90d0030..8ff3d64 100644 (file)
@@ -48,7 +48,7 @@ libwebsocket_0405_frame_mask_generate(struct libwebsocket *wsi)
 
 #ifdef _DEBUG
 
-void lwsl_hexdump(void *vbuf, size_t len)
+LWS_VISIBLE void lwsl_hexdump(void *vbuf, size_t len)
 {
        int n;
        int m;
@@ -296,7 +296,7 @@ lws_issue_raw_ext_access(struct libwebsocket *wsi,
  *     pressure at any given time.
  */
 
-int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
+LWS_VISIBLE int libwebsocket_write(struct libwebsocket *wsi, unsigned char *buf,
                          size_t len, enum libwebsocket_write_protocol protocol)
 {
        int n;
@@ -501,7 +501,7 @@ send_raw:
        return orig_len - ((len - pre + post) -n );
 }
 
-int libwebsockets_serve_http_file_fragment(
+LWS_VISIBLE int libwebsockets_serve_http_file_fragment(
                struct libwebsocket_context *context, struct libwebsocket *wsi)
 {
        int ret = 0;
@@ -561,7 +561,7 @@ int libwebsockets_serve_http_file_fragment(
  *     the wsi should be left alone.
  */
 
-int libwebsockets_serve_http_file(struct libwebsocket_context *context,
+LWS_VISIBLE int libwebsockets_serve_http_file(struct libwebsocket_context *context,
                        struct libwebsocket *wsi, const char *file,
                                                       const char *content_type)
 {
index f9f078d..c1d6730 100644 (file)
@@ -321,7 +321,7 @@ int lws_allocate_header_table(struct libwebsocket *wsi)
        return 0;
 }
 
-int lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h)
+LWS_VISIBLE int lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h)
 {
        int n;
        int len = 0;
@@ -338,7 +338,7 @@ int lws_hdr_total_length(struct libwebsocket *wsi, enum lws_token_indexes h)
        return len;
 }
 
-int lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
+LWS_VISIBLE int lws_hdr_copy(struct libwebsocket *wsi, char *dest, int len,
                                                enum lws_token_indexes h)
 {
        int toklen = lws_hdr_total_length(wsi, h);
@@ -610,7 +610,7 @@ set_parsing_complete:
  * mode.
  */
 
-int lws_frame_is_binary(struct libwebsocket *wsi)
+LWS_VISIBLE int lws_frame_is_binary(struct libwebsocket *wsi)
 {
        return wsi->u.ws.frame_is_binary;
 }
@@ -1111,7 +1111,7 @@ int libwebsocket_interpret_incoming_packet(struct libwebsocket *wsi,
  *  Many protocols won't care becuse their packets are always small.
  */
 
-size_t
+LWS_VISIBLE size_t
 libwebsockets_remaining_packet_payload(struct libwebsocket *wsi)
 {
        return wsi->u.ws.rx_packet_length;
index 241310e..a355d81 100755 (executable)
@@ -1722,6 +1722,7 @@ sub dump_function($$) {
     my $prototype = shift;
     my $file = shift;
 
+    $prototype =~ s/LWS_VISIBLE +//;
     $prototype =~ s/^static +//;
     $prototype =~ s/^extern +//;
     $prototype =~ s/^asmlinkage +//;