diff --git a/SConscript b/SConscript index 1b2c2fa..86086e9 100644 --- a/SConscript +++ b/SConscript @@ -1,9 +1,13 @@ from building import * -cwd = GetCurrentDir() -src = Glob('*.c') -CPPPATH = [cwd] +cwd = GetCurrentDir() +path = [cwd + '/inc'] -group = DefineGroup('WebClient', src, depend = ['PKG_USING_WEBCLIENT'], CPPPATH = CPPPATH) +src = Glob('src/*.c') + +if GetDepend(['WEBCLIENT_USING_SAMPLES']): + src += Glob('samples/*.c') + +group = DefineGroup('WebClient', src, depend = ['PKG_USING_WEBCLIENT'], CPPPATH = path) Return('group') diff --git a/webclient.h b/inc/webclient.h similarity index 95% rename from webclient.h rename to inc/webclient.h index cb97e06..4e40a66 100644 --- a/webclient.h +++ b/inc/webclient.h @@ -1,6 +1,6 @@ /* - * File : webclient.h - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * File : webclient.h + * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -160,8 +160,8 @@ int webclient_read(struct webclient_session *session, unsigned char *buffer, siz int webclient_write(struct webclient_session *session, const unsigned char *buffer, size_t size); /* send HTTP POST/GET request, and get response data */ -int webclient_response(struct webclient_session *session, void **response); -int webclient_request(const char *URI, const char *header, const char *post_data, unsigned char **result); +int webclient_response(struct webclient_session *session, unsigned char **response); +int webclient_request(const char *URI, const char *header, const char *post_data, unsigned char **response); #ifdef RT_USING_DFS /* file related operations */ diff --git a/webclient.c b/src/webclient.c similarity index 99% rename from webclient.c rename to src/webclient.c index 9b47ddc..939fe59 100644 --- a/webclient.c +++ b/src/webclient.c @@ -1,6 +1,6 @@ /* - * File : webclient.c - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * File : webclient.c + * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,7 +29,7 @@ #include #include -#include "webclient.h" +#include #if defined(RT_USING_DFS_NET) || defined(SAL_USING_POSIX) #include @@ -407,7 +407,7 @@ static int webclient_connect(struct webclient_session *session, const char *URI) rc = webclient_resolve_address(session, &res, URI, &request); if (rc != WEBCLIENT_OK) { - LOG_E("connect failed, resolve address error."); + LOG_E("connect failed, resolve address error(%d).", rc); goto __exit; } @@ -1318,7 +1318,7 @@ int webclient_close(struct webclient_session *session) * * @return response data size */ -int webclient_response(struct webclient_session *session, void **response) +int webclient_response(struct webclient_session *session, unsigned char **response) { unsigned char *buf_ptr; unsigned char *response_buf = 0; @@ -1447,7 +1447,7 @@ int webclient_request(const char *URI, const char *header, const char *post_data goto __exit; } - totle_length = webclient_response(session, (void **)response); + totle_length = webclient_response(session, response); if(totle_length <= 0) { rc = -WEBCLIENT_ERROR; diff --git a/webclient_file.c b/src/webclient_file.c similarity index 98% rename from webclient_file.c rename to src/webclient_file.c index 883ca67..ac066f0 100644 --- a/webclient_file.c +++ b/src/webclient_file.c @@ -1,6 +1,6 @@ /* - * File : webclient_file.c - * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team + * File : webclient_file.c + * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -25,7 +25,7 @@ #include #include -#include "webclient.h" +#include #ifdef RT_USING_DFS #include