Преглед изворни кода

【修改】 代码结构及 SConscript 定义。

chenyong пре 7 година
родитељ
комит
e5aa73f714
4 измењених фајлова са 21 додато и 17 уклоњено
  1. 8 4
      SConscript
  2. 4 4
      inc/webclient.h
  3. 6 6
      src/webclient.c
  4. 3 3
      src/webclient_file.c

+ 8 - 4
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')

+ 4 - 4
webclient.h → 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 */

+ 6 - 6
webclient.c → 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 <string.h>
 #include <sys/time.h>
 
-#include "webclient.h"
+#include <webclient.h>
 
 #if defined(RT_USING_DFS_NET) || defined(SAL_USING_POSIX)
 #include <netdb.h>
@@ -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;

+ 3 - 3
webclient_file.c → 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 <stdlib.h>
 
 #include <rtthread.h>
-#include "webclient.h"
+#include <webclient.h>
 
 #ifdef RT_USING_DFS
 #include <dfs_posix.h>