mirror of
https://gitee.com/zlgopen/awtk.git
synced 2024-11-30 02:58:26 +08:00
format code
This commit is contained in:
parent
acfbb49056
commit
bacae3e2ce
@ -96,7 +96,8 @@ uint32_t timer_next_time(void) {
|
||||
|
||||
#include "base/main_loop.h"
|
||||
|
||||
ret_t timer_queue_ex(timer_func_t on_timer, void* ctx, uint32_t duration, tk_destroy_t on_destroy, void* on_destroy_ctx) {
|
||||
ret_t timer_queue_ex(timer_func_t on_timer, void* ctx, uint32_t duration, tk_destroy_t on_destroy,
|
||||
void* on_destroy_ctx) {
|
||||
#ifdef AWTK_WEB
|
||||
timer_add(on_timer, ctx, duration);
|
||||
|
||||
|
@ -98,7 +98,8 @@ ret_t timer_queue(timer_func_t on_timer, void* ctx, uint32_t duration);
|
||||
*
|
||||
* @return {ret_t} 返回RET_OK表示成功,否则表示失败。
|
||||
*/
|
||||
ret_t timer_queue_ex(timer_func_t on_timer, void* ctx, uint32_t duration, tk_destroy_t on_destroy, void* on_destroy_ctx);
|
||||
ret_t timer_queue_ex(timer_func_t on_timer, void* ctx, uint32_t duration, tk_destroy_t on_destroy,
|
||||
void* on_destroy_ctx);
|
||||
|
||||
/**
|
||||
* @method timer_remove
|
||||
|
@ -4510,48 +4510,48 @@ bool_t widget_is_direct_parent_of(widget_t* widget, widget_t* child) {
|
||||
|
||||
bool_t widget_get_enable(widget_t* widget) {
|
||||
return_value_if_fail(widget != NULL, FALSE);
|
||||
|
||||
|
||||
return widget->enable;
|
||||
}
|
||||
|
||||
bool_t widget_get_floating(widget_t* widget) {
|
||||
return_value_if_fail(widget != NULL, FALSE);
|
||||
|
||||
|
||||
return widget->floating;
|
||||
}
|
||||
|
||||
bool_t widget_get_auto_adjust_size(widget_t* widget) {
|
||||
return_value_if_fail(widget != NULL, FALSE);
|
||||
|
||||
|
||||
return widget->auto_adjust_size;
|
||||
}
|
||||
|
||||
bool_t widget_get_with_focus_state(widget_t* widget) {
|
||||
return_value_if_fail(widget != NULL, FALSE);
|
||||
|
||||
|
||||
return widget->with_focus_state;
|
||||
}
|
||||
|
||||
bool_t widget_get_focusable(widget_t* widget) {
|
||||
return_value_if_fail(widget != NULL, FALSE);
|
||||
|
||||
|
||||
return widget->focusable;
|
||||
}
|
||||
|
||||
bool_t widget_get_sensitive(widget_t* widget) {
|
||||
return_value_if_fail(widget != NULL, FALSE);
|
||||
|
||||
|
||||
return widget->sensitive;
|
||||
}
|
||||
|
||||
bool_t widget_get_visible(widget_t* widget) {
|
||||
return_value_if_fail(widget != NULL, FALSE);
|
||||
|
||||
|
||||
return widget->visible;
|
||||
}
|
||||
|
||||
bool_t widget_get_feedback(widget_t* widget) {
|
||||
return_value_if_fail(widget != NULL, FALSE);
|
||||
|
||||
|
||||
return widget->feedback;
|
||||
}
|
||||
|
@ -1417,7 +1417,7 @@ widget_t* widget_lookup_by_type(widget_t* widget, const char* type, bool_t recur
|
||||
ret_t widget_set_visible(widget_t* widget, bool_t visible);
|
||||
#else
|
||||
ret_t widget_set_visible(widget_t* widget, bool_t visible, ...);
|
||||
#endif/*AWTK_GO*/
|
||||
#endif /*AWTK_GO*/
|
||||
|
||||
/**
|
||||
* @method widget_set_visible_only
|
||||
|
@ -33,7 +33,7 @@ static ret_t image_animation_play_to_done(image_animation_t* image_animation) {
|
||||
image_animation->index = -1;
|
||||
}
|
||||
image_animation->playing = FALSE;
|
||||
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
@ -44,12 +44,13 @@ ret_t image_animation_get_image_name(image_animation_t* image_animation,
|
||||
if (image_animation->sequence != NULL) {
|
||||
uint32_t len = strlen(image_animation->sequence);
|
||||
tk_strncpy(name, image_animation->image, TK_NAME_LEN);
|
||||
image_animation->index =
|
||||
image_animation->index >= len ? 0 : image_animation->index;
|
||||
index = image_animation->reverse ? len - image_animation->index - 1: image_animation->index;
|
||||
image_animation->index = image_animation->index >= len ? 0 : image_animation->index;
|
||||
index = image_animation->reverse ? len - image_animation->index - 1 : image_animation->index;
|
||||
name[strlen(name)] = image_animation->sequence[index];
|
||||
} else {
|
||||
index = image_animation->reverse ? image_animation->end_index + image_animation->start_index - image_animation->index : image_animation->index;
|
||||
index = image_animation->reverse
|
||||
? image_animation->end_index + image_animation->start_index - image_animation->index
|
||||
: image_animation->index;
|
||||
const char* format = image_animation->format ? image_animation->format : "%s%d";
|
||||
tk_snprintf(name, TK_NAME_LEN, format, image_animation->image, index);
|
||||
}
|
||||
|
@ -69,7 +69,8 @@ static ret_t font_ft_get_glyph(font_t* f, wchar_t c, font_size_t font_size, glyp
|
||||
ft_fontinfo* sf = &(font->ft_font);
|
||||
FT_Glyph glyph;
|
||||
FT_GlyphSlot glyf;
|
||||
uint32_t flags = FT_LOAD_DEFAULT | FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT | FT_OUTLINE_HIGH_PRECISION;
|
||||
uint32_t flags =
|
||||
FT_LOAD_DEFAULT | FT_LOAD_RENDER | FT_LOAD_NO_AUTOHINT | FT_OUTLINE_HIGH_PRECISION;
|
||||
|
||||
g->data = NULL;
|
||||
if (glyph_cache_lookup(&(font->cache), c, font_size, g) == RET_OK) {
|
||||
|
@ -64,8 +64,7 @@ ret_t native_window_fb_gl_set_make_current_func(native_window_t* win,
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
ret_t native_window_fb_gl_set_destroy_func(native_window_t* win,
|
||||
native_window_destroy_t destroy) {
|
||||
ret_t native_window_fb_gl_set_destroy_func(native_window_t* win, native_window_destroy_t destroy) {
|
||||
native_window_fb_gl_t* fb_gl = NATIVE_WINDOW_FB_GL(win);
|
||||
return_value_if_fail(fb_gl != NULL && destroy != NULL, RET_BAD_PARAMS);
|
||||
fb_gl->destroy = destroy;
|
||||
|
@ -38,8 +38,7 @@ ret_t native_window_fb_gl_set_swap_buffer_func(native_window_t* win,
|
||||
ret_t native_window_fb_gl_set_make_current_func(native_window_t* win,
|
||||
native_window_gl_make_current_t make_current);
|
||||
|
||||
ret_t native_window_fb_gl_set_destroy_func(native_window_t* win,
|
||||
native_window_destroy_t destroy);
|
||||
ret_t native_window_fb_gl_set_destroy_func(native_window_t* win, native_window_destroy_t destroy);
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
|
@ -54,7 +54,7 @@ static ret_t tk_iostream_mbedtls_get_prop(object_t* obj, const char* name, value
|
||||
static ret_t tk_iostream_mbedtls_on_destroy(object_t* obj) {
|
||||
tk_iostream_mbedtls_t* iostream_mbedtls = TK_IOSTREAM_MBEDTLS(obj);
|
||||
|
||||
if(iostream_mbedtls->conn != NULL) {
|
||||
if (iostream_mbedtls->conn != NULL) {
|
||||
mbedtls_conn_destroy(iostream_mbedtls->conn);
|
||||
}
|
||||
|
||||
@ -99,4 +99,4 @@ tk_iostream_t* tk_iostream_mbedtls_create(mbedtls_conn_t* conn) {
|
||||
|
||||
return TK_IOSTREAM(obj);
|
||||
}
|
||||
#endif/*WITH_MBEDTLS*/
|
||||
#endif /*WITH_MBEDTLS*/
|
||||
|
@ -40,7 +40,7 @@ typedef struct _tk_iostream_mbedtls_t tk_iostream_mbedtls_t;
|
||||
struct _tk_iostream_mbedtls_t {
|
||||
tk_iostream_t iostream;
|
||||
|
||||
mbedtls_conn_t* conn;
|
||||
mbedtls_conn_t* conn;
|
||||
tk_istream_t* istream;
|
||||
tk_ostream_t* ostream;
|
||||
};
|
||||
@ -57,10 +57,8 @@ struct _tk_iostream_mbedtls_t {
|
||||
*/
|
||||
tk_iostream_t* tk_iostream_mbedtls_create(mbedtls_conn_t* conn);
|
||||
|
||||
|
||||
#define TK_IOSTREAM_MBEDTLS(obj) ((tk_iostream_mbedtls_t*)(obj))
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
#endif /*TK_IOSTREAM_MBEDTLS_H*/
|
||||
|
||||
|
@ -64,10 +64,11 @@ static ret_t tk_istream_mbedtls_get_prop(object_t* obj, const char* name, value_
|
||||
return RET_NOT_FOUND;
|
||||
}
|
||||
|
||||
static const object_vtable_t s_tk_istream_mbedtls_vtable = {.type = "tk_istream_mbedtls",
|
||||
.desc = "tk_istream_mbedtls",
|
||||
.size = sizeof(tk_istream_mbedtls_t),
|
||||
.get_prop = tk_istream_mbedtls_get_prop};
|
||||
static const object_vtable_t s_tk_istream_mbedtls_vtable = {
|
||||
.type = "tk_istream_mbedtls",
|
||||
.desc = "tk_istream_mbedtls",
|
||||
.size = sizeof(tk_istream_mbedtls_t),
|
||||
.get_prop = tk_istream_mbedtls_get_prop};
|
||||
|
||||
tk_istream_t* tk_istream_mbedtls_create(mbedtls_ssl_context* ssl) {
|
||||
object_t* obj = NULL;
|
||||
@ -94,4 +95,4 @@ tk_istream_mbedtls_t* tk_istream_mbedtls_cast(tk_istream_t* s) {
|
||||
return (tk_istream_mbedtls_t*)s;
|
||||
}
|
||||
|
||||
#endif/*WITH_MBEDTLS*/
|
||||
#endif /*WITH_MBEDTLS*/
|
||||
|
@ -18,19 +18,19 @@ static ret_t mbedtls_conn_client_destroy(mbedtls_conn_t* conn) {
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, const uint8_t* cas_pem,
|
||||
uint32_t cas_pem_len) {
|
||||
int ret = 0;
|
||||
int flags = 0;
|
||||
mbedtls_conn_t* conn = NULL;
|
||||
const char* pers = TK_MBEDTLS_PERS;
|
||||
mbedtls_conn_client_t* client = NULL;
|
||||
return_value_if_fail(host != NULL && port != NULL, NULL);
|
||||
client = TKMEM_ZALLOC(mbedtls_conn_client_t);
|
||||
return_value_if_fail(client != NULL, NULL);
|
||||
conn = (mbedtls_conn_t*)client;
|
||||
mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port,
|
||||
const uint8_t* cas_pem, uint32_t cas_pem_len) {
|
||||
int ret = 0;
|
||||
int flags = 0;
|
||||
mbedtls_conn_t* conn = NULL;
|
||||
const char* pers = TK_MBEDTLS_PERS;
|
||||
mbedtls_conn_client_t* client = NULL;
|
||||
return_value_if_fail(host != NULL && port != NULL, NULL);
|
||||
client = TKMEM_ZALLOC(mbedtls_conn_client_t);
|
||||
return_value_if_fail(client != NULL, NULL);
|
||||
conn = (mbedtls_conn_t*)client;
|
||||
|
||||
conn->destroy = mbedtls_conn_client_destroy;
|
||||
conn->destroy = mbedtls_conn_client_destroy;
|
||||
|
||||
#if defined(MBEDTLS_DEBUG_C)
|
||||
mbedtls_debug_set_threshold(DEBUG_LEVEL);
|
||||
@ -59,10 +59,9 @@ mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, c
|
||||
/*
|
||||
* 0. Initialize certificates
|
||||
*/
|
||||
if(cas_pem != NULL) {
|
||||
if (cas_pem != NULL) {
|
||||
log_debug(" . Loading the CA root certificate ...");
|
||||
ret = mbedtls_x509_crt_parse(&(client->cacert), (const unsigned char*)cas_pem,
|
||||
cas_pem_len);
|
||||
ret = mbedtls_x509_crt_parse(&(client->cacert), (const unsigned char*)cas_pem, cas_pem_len);
|
||||
if (ret < 0) {
|
||||
log_debug(" failed\n ! mbedtls_x509_crt_parse returned -0x%x\n\n", (unsigned int)-ret);
|
||||
goto error;
|
||||
@ -74,8 +73,7 @@ mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, c
|
||||
* 1. Start the connection
|
||||
*/
|
||||
log_debug(" . Connecting to tcp/%s/%s...", host, port);
|
||||
if ((ret = mbedtls_net_connect(&(client->server_fd), host, port, MBEDTLS_NET_PROTO_TCP)) !=
|
||||
0) {
|
||||
if ((ret = mbedtls_net_connect(&(client->server_fd), host, port, MBEDTLS_NET_PROTO_TCP)) != 0) {
|
||||
log_debug(" failed\n ! mbedtls_net_connect returned %d\n\n", ret);
|
||||
goto error;
|
||||
}
|
||||
@ -87,7 +85,8 @@ mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, c
|
||||
*/
|
||||
log_debug(" . Setting up the SSL/TLS structure...");
|
||||
|
||||
if ((ret = mbedtls_ssl_config_defaults(&(client->conf), MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||
if ((ret = mbedtls_ssl_config_defaults(&(client->conf), MBEDTLS_SSL_IS_CLIENT,
|
||||
MBEDTLS_SSL_TRANSPORT_STREAM,
|
||||
MBEDTLS_SSL_PRESET_DEFAULT)) != 0) {
|
||||
log_debug(" failed\n ! mbedtls_ssl_config_defaults returned %d\n\n", ret);
|
||||
goto error;
|
||||
@ -150,4 +149,4 @@ error:
|
||||
|
||||
return NULL;
|
||||
}
|
||||
#endif/*WITH_MBEDTLS*/
|
||||
#endif /*WITH_MBEDTLS*/
|
||||
|
@ -13,6 +13,7 @@ typedef struct _mbedtls_conn_client_t {
|
||||
mbedtls_x509_crt cacert;
|
||||
} mbedtls_conn_client_t;
|
||||
|
||||
mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port, const uint8_t* cas_pem, uint32_t cas_len);
|
||||
mbedtls_conn_t* mbedtls_conn_client_create(const char* host, const char* port,
|
||||
const uint8_t* cas_pem, uint32_t cas_len);
|
||||
|
||||
#endif /* TK_MBEDTLS_CLIENT_H */
|
||||
|
@ -16,11 +16,11 @@ void mbedtls_awtk_debug(void* ctx, int level, const char* file, int line, const
|
||||
ret_t mbedtls_conn_destroy(mbedtls_conn_t* conn) {
|
||||
return_value_if_fail(conn != NULL, RET_BAD_PARAMS);
|
||||
|
||||
if(conn->destroy != NULL) {
|
||||
if (conn->destroy != NULL) {
|
||||
conn->destroy(conn);
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
#endif/*WITH_MBEDTLS*/
|
||||
#endif /*WITH_MBEDTLS*/
|
||||
|
@ -31,16 +31,16 @@
|
||||
#else
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#define mbedtls_time time
|
||||
#define mbedtls_time_t time_t
|
||||
#define mbedtls_printf printf
|
||||
#define mbedtls_fprintf fprintf
|
||||
#define mbedtls_snprintf snprintf
|
||||
#define mbedtls_exit exit
|
||||
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#define mbedtls_calloc calloc
|
||||
#define mbedtls_free free
|
||||
#define mbedtls_time time
|
||||
#define mbedtls_time_t time_t
|
||||
#define mbedtls_printf printf
|
||||
#define mbedtls_fprintf fprintf
|
||||
#define mbedtls_snprintf snprintf
|
||||
#define mbedtls_exit exit
|
||||
#define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
|
||||
#define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
|
||||
#endif
|
||||
|
||||
#include "mbedtls/net_sockets.h"
|
||||
@ -83,7 +83,7 @@ ret_t mbedtls_conn_destroy(mbedtls_conn_t* conn);
|
||||
|
||||
#ifndef TK_MBEDTLS_PERS
|
||||
#define TK_MBEDTLS_PERS "awtk_pers"
|
||||
#endif/*TK_MBEDTLS_PERS*/
|
||||
#endif /*TK_MBEDTLS_PERS*/
|
||||
|
||||
void mbedtls_awtk_debug(void* ctx, int level, const char* file, int line, const char* str);
|
||||
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include "tkc/utils.h"
|
||||
#include "mbedtls_server.h"
|
||||
|
||||
|
||||
static ret_t mbedtls_conn_server_destroy(mbedtls_conn_t* conn) {
|
||||
int ret = 0;
|
||||
mbedtls_conn_server_t* server_conn = (mbedtls_conn_server_t*)conn;
|
||||
@ -34,7 +33,7 @@ mbedtls_conn_t* mbedtls_server_accept(mbedtls_server_t* server) {
|
||||
|
||||
mbedtls_net_init(&(server_conn->client_fd));
|
||||
mbedtls_ssl_init(&(conn->ssl));
|
||||
|
||||
|
||||
if ((ret = mbedtls_ssl_setup(&(conn->ssl), &(server->conf))) != 0) {
|
||||
log_debug(" failed\n ! mbedtls_ssl_setup returned %d\n\n", ret);
|
||||
goto error;
|
||||
@ -61,16 +60,17 @@ mbedtls_conn_t* mbedtls_server_accept(mbedtls_server_t* server) {
|
||||
|
||||
log_debug(" ok\n");
|
||||
return conn;
|
||||
|
||||
|
||||
error:
|
||||
mbedtls_conn_server_destroy(conn);
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mbedtls_server_t* mbedtls_server_create(const char* port, const uint8_t* srv_crt, uint32_t srv_crt_len,
|
||||
const uint8_t* srv_key, uint32_t srv_key_len,
|
||||
const uint8_t* cas_pem, uint32_t cas_pem_len) {
|
||||
mbedtls_server_t* mbedtls_server_create(const char* port, const uint8_t* srv_crt,
|
||||
uint32_t srv_crt_len, const uint8_t* srv_key,
|
||||
uint32_t srv_key_len, const uint8_t* cas_pem,
|
||||
uint32_t cas_pem_len) {
|
||||
int ret = 0;
|
||||
mbedtls_server_t* server = NULL;
|
||||
const char* pers = TK_MBEDTLS_PERS;
|
||||
@ -193,4 +193,4 @@ ret_t mbedtls_server_destroy(mbedtls_server_t* server) {
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
#endif/*WITH_MBEDTLS*/
|
||||
#endif /*WITH_MBEDTLS*/
|
||||
|
@ -25,10 +25,10 @@ typedef struct _mbedtls_conn_server_t {
|
||||
mbedtls_server_t* server;
|
||||
} mbedtls_conn_server_t;
|
||||
|
||||
mbedtls_server_t* mbedtls_server_create(const char* port,
|
||||
const uint8_t* srv_crt, uint32_t srv_crt_len,
|
||||
const uint8_t* srv_key, uint32_t srv_key_len,
|
||||
const uint8_t* cas_pem, uint32_t cas_pem_len);
|
||||
mbedtls_server_t* mbedtls_server_create(const char* port, const uint8_t* srv_crt,
|
||||
uint32_t srv_crt_len, const uint8_t* srv_key,
|
||||
uint32_t srv_key_len, const uint8_t* cas_pem,
|
||||
uint32_t cas_pem_len);
|
||||
|
||||
mbedtls_conn_t* mbedtls_server_accept(mbedtls_server_t* server);
|
||||
|
||||
|
@ -27,13 +27,14 @@
|
||||
#include "tkc/mem.h"
|
||||
#include "streams/inet/ostream_mbedtls.h"
|
||||
|
||||
static int32_t tk_ostream_mbedtls_write(tk_ostream_t* stream, const uint8_t* buff, uint32_t max_size) {
|
||||
static int32_t tk_ostream_mbedtls_write(tk_ostream_t* stream, const uint8_t* buff,
|
||||
uint32_t max_size) {
|
||||
int32_t ret = 0;
|
||||
tk_ostream_mbedtls_t* ostream_mbedtls = TK_OSTREAM_MBEDTLS(stream);
|
||||
|
||||
ret = mbedtls_ssl_write(ostream_mbedtls->ssl, buff, max_size);
|
||||
if (ret <= 0) {
|
||||
if( ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE ) {
|
||||
if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE) {
|
||||
perror("send");
|
||||
ostream_mbedtls->is_broken = TRUE;
|
||||
}
|
||||
@ -56,10 +57,11 @@ static ret_t tk_ostream_mbedtls_get_prop(object_t* obj, const char* name, value_
|
||||
return RET_NOT_FOUND;
|
||||
}
|
||||
|
||||
static const object_vtable_t s_tk_ostream_mbedtls_vtable = {.type = "tk_ostream_mbedtls",
|
||||
.desc = "tk_ostream_mbedtls",
|
||||
.size = sizeof(tk_ostream_mbedtls_t),
|
||||
.get_prop = tk_ostream_mbedtls_get_prop};
|
||||
static const object_vtable_t s_tk_ostream_mbedtls_vtable = {
|
||||
.type = "tk_ostream_mbedtls",
|
||||
.desc = "tk_ostream_mbedtls",
|
||||
.size = sizeof(tk_ostream_mbedtls_t),
|
||||
.get_prop = tk_ostream_mbedtls_get_prop};
|
||||
|
||||
tk_ostream_t* tk_ostream_mbedtls_create(mbedtls_ssl_context* ssl) {
|
||||
object_t* obj = NULL;
|
||||
@ -73,7 +75,7 @@ tk_ostream_t* tk_ostream_mbedtls_create(mbedtls_ssl_context* ssl) {
|
||||
return_value_if_fail(ostream_mbedtls != NULL, NULL);
|
||||
|
||||
ostream_mbedtls->ssl = ssl;
|
||||
ostream_mbedtls->sock = bio->fd;
|
||||
ostream_mbedtls->sock = bio->fd;
|
||||
TK_OSTREAM(obj)->write = tk_ostream_mbedtls_write;
|
||||
|
||||
return TK_OSTREAM(obj);
|
||||
@ -85,4 +87,4 @@ tk_ostream_mbedtls_t* tk_ostream_mbedtls_cast(tk_ostream_t* s) {
|
||||
return (tk_ostream_mbedtls_t*)s;
|
||||
}
|
||||
|
||||
#endif/*WITH_MBEDTLS*/
|
||||
#endif /*WITH_MBEDTLS*/
|
||||
|
@ -8,10 +8,10 @@ int main(int argc, char* argv[]) {
|
||||
const char* request = "GET / HTTP/1.1\r\nHost: localhost\r\n";
|
||||
|
||||
platform_prepare();
|
||||
conn = mbedtls_conn_client_create("localhost", "4433",
|
||||
(const uint8_t*)mbedtls_test_cas_pem, mbedtls_test_cas_pem_len);
|
||||
conn = mbedtls_conn_client_create("localhost", "4433", (const uint8_t*)mbedtls_test_cas_pem,
|
||||
mbedtls_test_cas_pem_len);
|
||||
|
||||
if(conn != NULL) {
|
||||
if (conn != NULL) {
|
||||
char buff[1024] = {0};
|
||||
tk_iostream_t* io = tk_iostream_mbedtls_create(conn);
|
||||
tk_istream_t* in = tk_iostream_get_istream(io);
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "streams/inet/iostream_mbedtls.h"
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -7,19 +7,19 @@ int main(int argc, char* argv[]) {
|
||||
mbedtls_server_t* server = NULL;
|
||||
|
||||
platform_prepare();
|
||||
server = mbedtls_server_create("4433",
|
||||
(const uint8_t*)mbedtls_test_srv_crt, mbedtls_test_srv_crt_len,
|
||||
(const uint8_t*)mbedtls_test_srv_key, mbedtls_test_srv_key_len,
|
||||
(const uint8_t*)mbedtls_test_cas_pem, mbedtls_test_cas_pem_len);
|
||||
server =
|
||||
mbedtls_server_create("4433", (const uint8_t*)mbedtls_test_srv_crt, mbedtls_test_srv_crt_len,
|
||||
(const uint8_t*)mbedtls_test_srv_key, mbedtls_test_srv_key_len,
|
||||
(const uint8_t*)mbedtls_test_cas_pem, mbedtls_test_cas_pem_len);
|
||||
|
||||
if(server != NULL) {
|
||||
if (server != NULL) {
|
||||
char buff[1024];
|
||||
mbedtls_conn_t* conn = mbedtls_server_accept(server);
|
||||
tk_iostream_t* io = tk_iostream_mbedtls_create(conn);
|
||||
tk_istream_t* in = tk_iostream_get_istream(io);
|
||||
tk_ostream_t* out = tk_iostream_get_ostream(io);
|
||||
ret = tk_istream_read(in, buff, sizeof(buff));
|
||||
ret = tk_ostream_write(out, "hello\r\n", 7);
|
||||
ret = tk_ostream_write(out, "hello\r\n", 7);
|
||||
|
||||
OBJECT_UNREF(io);
|
||||
mbedtls_server_destroy(server);
|
||||
|
@ -160,7 +160,6 @@ event_t* event_cast(event_t* event);
|
||||
*/
|
||||
int event_get_type(event_t* event);
|
||||
|
||||
|
||||
/**
|
||||
* @method event_create
|
||||
* @annotation ["constructor", "scriptable", "gc"]
|
||||
|
@ -62,7 +62,7 @@ struct _idle_info_t {
|
||||
* idle回调函数上下文。
|
||||
*/
|
||||
void* ctx;
|
||||
|
||||
|
||||
/**
|
||||
* @property {void*} extra_ctx
|
||||
* @annotation ["readable", "scriptable"]
|
||||
|
@ -64,7 +64,7 @@ struct _timer_info_t {
|
||||
*
|
||||
*/
|
||||
void* ctx;
|
||||
|
||||
|
||||
/**
|
||||
* @property {void*} extra_ctx
|
||||
* @annotation ["readable", "scriptable"]
|
||||
|
@ -365,7 +365,7 @@ wchar_t* wcs_dup(const wchar_t* s);
|
||||
|
||||
#ifdef WITH_WCSXXX
|
||||
wchar_t* wcsdup(const wchar_t* s);
|
||||
#endif/*WITH_WCSXXX*/
|
||||
#endif /*WITH_WCSXXX*/
|
||||
|
||||
END_C_DECLS
|
||||
|
||||
|
@ -233,8 +233,7 @@ TEST(input_engine, add_candidates) {
|
||||
ARRAY_SIZE(s_pinyin_chinese_items), key_str, FALSE);
|
||||
ASSERT_EQ(im->engine->candidates_nr, 63);
|
||||
ASSERT_EQ(im->engine->candidates.data != NULL, TRUE);
|
||||
ASSERT_EQ(check_candidates_from_char((const char*)(im->engine->candidates.data), py_ji,
|
||||
63),
|
||||
ASSERT_EQ(check_candidates_from_char((const char*)(im->engine->candidates.data), py_ji, 63),
|
||||
TRUE);
|
||||
#endif
|
||||
|
||||
|
@ -361,23 +361,22 @@ TEST(WStr, set_utf8_with_len) {
|
||||
ASSERT_EQ(wstr_set_utf8_with_len(&str, "123123", 0), RET_OK);
|
||||
ASSERT_EQ(str.size, 0);
|
||||
ASSERT_EQ(wcscmp(str.str, L""), 0);
|
||||
|
||||
|
||||
ASSERT_EQ(wstr_set_utf8_with_len(&str, "123123", 1), RET_OK);
|
||||
ASSERT_EQ(str.size, 1);
|
||||
ASSERT_EQ(wcscmp(str.str, L"1"), 0);
|
||||
|
||||
|
||||
ASSERT_EQ(wstr_set_utf8_with_len(&str, "123123", 3), RET_OK);
|
||||
ASSERT_EQ(str.size, 3);
|
||||
ASSERT_EQ(wcscmp(str.str, L"123"), 0);
|
||||
|
||||
|
||||
ASSERT_EQ(wstr_set_utf8_with_len(&str, "123123", 6), RET_OK);
|
||||
ASSERT_EQ(str.size, 6);
|
||||
ASSERT_EQ(wcscmp(str.str, L"123123"), 0);
|
||||
|
||||
|
||||
ASSERT_EQ(wstr_set_utf8_with_len(&str, "123123", 6), RET_OK);
|
||||
ASSERT_EQ(str.size, 6);
|
||||
ASSERT_EQ(wcscmp(str.str, L"123123"), 0);
|
||||
|
||||
wstr_reset(&str);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user