From ee90cbc37c338df5f1e8ca433e8bd6cc35675efc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilja=20Karta=C5=A1ov?= Date: Wed, 17 Apr 2019 10:19:06 +0200 Subject: [PATCH] Introduce set/get function for output event instead of chuncked output ones --- include/aisl/client.h | 4 ++++ include/aisl/stream.h | 8 ++++++++ src/client.c | 16 +++++++++++++++- src/stream.c | 39 ++++++++++++++++++++++----------------- src/stream.h | 8 -------- 5 files changed, 49 insertions(+), 26 deletions(-) diff --git a/include/aisl/client.h b/include/aisl/client.h index c879ad2..f7dd37a 100644 --- a/include/aisl/client.h +++ b/include/aisl/client.h @@ -56,4 +56,8 @@ aisl_client_disconnect(aisl_client_t client); aisl_http_version_t aisl_client_get_http_version(aisl_client_t client); + +void +aisl_client_get_address( aisl_client_t client, struct sockaddr_in * address); + #endif /* !AISL_CLIENT_H */ diff --git a/include/aisl/stream.h b/include/aisl/stream.h index a7c768b..484921e 100644 --- a/include/aisl/stream.h +++ b/include/aisl/stream.h @@ -99,4 +99,12 @@ aisl_write( aisl_stream_t stream, const char * data, int d_len ); int aisl_puts( const char * str_data, aisl_stream_t stream ); + +void +aisl_set_output_event(aisl_stream_t stream, bool value); + + +bool +aisl_get_output_event(aisl_stream_t stream); + #endif /* !AISL_STREAM_H */ diff --git a/src/client.c b/src/client.c index 886e48f..0afae31 100644 --- a/src/client.c +++ b/src/client.c @@ -225,7 +225,7 @@ aisl_client_output(aisl_client_t client) aisl_stream_t s = client->stream; /* while stream is not flushed, we should raise event */ - if( aisl_stream_get_chunked_output(s) ) + if( aisl_get_output_event(s) ) { /* in case of chunked output ( subscription for AISL_STREAM_OUTPUT event ) * stream buffer will be initialized with OUTPUT_BUFFER_SIZE size, but @@ -487,6 +487,7 @@ aisl_client_set_keepalive(aisl_client_t client, bool value) /* API Level ---------------------------------------------------------------- */ +__attribute__ ((visibility ("default") )) aisl_server_t aisl_client_get_server(aisl_client_t client) { @@ -494,6 +495,7 @@ aisl_client_get_server(aisl_client_t client) } +__attribute__ ((visibility ("default") )) bool aisl_client_is_secure(aisl_client_t client) { @@ -505,6 +507,7 @@ aisl_client_is_secure(aisl_client_t client) } +__attribute__ ((visibility ("default") )) bool aisl_client_is_online(aisl_client_t client) { @@ -512,14 +515,25 @@ aisl_client_is_online(aisl_client_t client) } +__attribute__ ((visibility ("default") )) void aisl_client_disconnect(aisl_client_t client) { aisl_client_close(client, AISL_SUCCESS); } + +__attribute__ ((visibility ("default") )) aisl_http_version_t aisl_client_get_http_version(aisl_client_t client) { return client->http_version; } + + +__attribute__ ((visibility ("default") )) +void +aisl_client_get_address( aisl_client_t client, struct sockaddr_in * address) +{ + memcpy(address, &client->address, sizeof(struct sockaddr_in)); +} diff --git a/src/stream.c b/src/stream.c index 564412e..d82595b 100644 --- a/src/stream.c +++ b/src/stream.c @@ -68,23 +68,6 @@ aisl_stream_free(aisl_stream_t stream) } -void -aisl_stream_set_chunked_output(aisl_stream_t stream, bool value) -{ - if (value) - stream->flags |= FLAG_OUTPUT_CHUNKED; - else if (stream->flags & FLAG_OUTPUT_CHUNKED) - stream->flags &= ~FLAG_OUTPUT_CHUNKED; -} - - -bool -aisl_stream_get_chunked_output(aisl_stream_t stream) -{ - return (stream->flags & FLAG_OUTPUT_CHUNKED); -} - - int32_t aisl_stream_get_buffer_space(aisl_stream_t stream) { @@ -670,3 +653,25 @@ aisl_stream_get_instance(aisl_stream_t stream) { return stream->client->server->instance; } + + +__attribute__ ((visibility ("default") )) +void +aisl_set_output_event(aisl_stream_t stream, bool value) +{ + if (value) + stream->flags |= FLAG_OUTPUT_CHUNKED; + else if (stream->flags & FLAG_OUTPUT_CHUNKED) + stream->flags &= ~FLAG_OUTPUT_CHUNKED; +} + + +__attribute__ ((visibility ("default") )) +bool +aisl_get_output_event(aisl_stream_t stream) +{ + return (stream->flags & FLAG_OUTPUT_CHUNKED); +} + + + diff --git a/src/stream.h b/src/stream.h index 7439b37..6dbad30 100644 --- a/src/stream.h +++ b/src/stream.h @@ -50,14 +50,6 @@ void aisl_stream_free(aisl_stream_t stream); -void -aisl_stream_set_chunked_output(aisl_stream_t stream, bool value); - - -bool -aisl_stream_get_chunked_output(aisl_stream_t stream); - - int32_t aisl_stream_get_buffer_space(aisl_stream_t stream);