Meco Man 4 лет назад
Родитель
Сommit
fc9f6dcb89

+ 3 - 3
inc/webnet.h

@@ -1,7 +1,7 @@
 /*
  * File      : webnet.h
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -70,7 +70,7 @@ extern "C" {
 #ifndef WEBNET_USING_RANGE
 #define WEBNET_USING_RANGE
 #endif
-    
+
 #ifndef WEBNET_USING_KEEPALIVE
 #define WEBNET_USING_KEEPALIVE
 #endif
@@ -81,7 +81,7 @@ extern "C" {
 
 #define WEBNET_VERSION                 "2.0.3"      /* webnet version string */
 #define WEBNET_VERSION_NUM             0x20003      /* webnet version number */
-#define WEBNET_THREAD_NAME             "webnet"	    /* webnet thread name */
+#define WEBNET_THREAD_NAME             "webnet"     /* webnet thread name */
 
 #define WEBNET_THREAD_STACKSIZE        (4 * 1024)   /* webnet thread stack size */
 #define WEBNET_PRIORITY                20           /* webnet thread priority */

+ 8 - 8
inc/wn_module.h

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module.h
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -37,21 +37,21 @@ extern "C" {
 #endif
 
 /* initialization event */
-#define WEBNET_EVENT_INIT			(1 << 0)
+#define WEBNET_EVENT_INIT           (1 << 0)
 /* map uri request to physical url */
-#define WEBNET_EVENT_URI_PHYSICAL	(1 << 1)
+#define WEBNET_EVENT_URI_PHYSICAL   (1 << 1)
 /* uri request */
-#define WEBNET_EVENT_URI_POST		(1 << 2)
+#define WEBNET_EVENT_URI_POST       (1 << 2)
 /* header of response */
-#define WEBNET_EVENT_RSP_HEADER		(1 << 3)
+#define WEBNET_EVENT_RSP_HEADER     (1 << 3)
 /* file content of response */
-#define WEBNET_EVENT_RSP_FILE		(1 << 4)
+#define WEBNET_EVENT_RSP_FILE       (1 << 4)
 
 
 /* continue other modules */
-#define WEBNET_MODULE_CONTINUE		0
+#define WEBNET_MODULE_CONTINUE      0
 /* this session is finished */
-#define WEBNET_MODULE_FINISHED		1
+#define WEBNET_MODULE_FINISHED      1
 
 int webnet_module_handle_event(struct webnet_session* session, int event);
 int webnet_module_system_dofile(struct webnet_session* session);

+ 12 - 12
inc/wn_request.h

@@ -1,7 +1,7 @@
 /*
  * File      : wn_request.h
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -41,14 +41,14 @@ enum webnet_method
     WEBNET_POST,
     WEBNET_HEADER,
     WEBNET_HEAD,
-	WEBNET_PUT,
-	WEBNET_OPTIONS,
-	WEBNET_PROPFIND,
-	WEBNET_PROPPATCH,
-	WEBNET_DELETE,
-	WEBNET_CONNECT,
-	WEBNET_MKCOL,
-	WEBNET_MOVE,
+    WEBNET_PUT,
+    WEBNET_OPTIONS,
+    WEBNET_PROPFIND,
+    WEBNET_PROPPATCH,
+    WEBNET_DELETE,
+    WEBNET_CONNECT,
+    WEBNET_MKCOL,
+    WEBNET_MOVE,
     WEBNET_SUBSCRIBE,
     WEBNET_UNSUBSCRIBE,
     WEBNET_NOTIFY,
@@ -92,8 +92,8 @@ struct webnet_request
     size_t pos_end;
 #endif /* WEBNET_USING_RANGE */
 #ifdef WEBNET_USING_DAV
-	char* depth;
-	char* destination;
+    char* depth;
+    char* destination;
 #endif /* WEBNET_USING_DAV */
 
     /* DMR */
@@ -106,7 +106,7 @@ struct webnet_request
 
     /* query information */
     char* query;
-	int query_offset;
+    int query_offset;
     struct webnet_query_item* query_items;
     rt_uint16_t query_counter;
 

+ 14 - 14
inc/wn_session.h

@@ -1,7 +1,7 @@
 /*
  * File      : wn_session.h
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -29,7 +29,7 @@
 
 #ifdef RT_USING_SAL
 #include <sys/socket.h>
-#else 
+#else
 #include <lwip/sockets.h>
 #endif
 
@@ -37,14 +37,14 @@
 extern "C" {
 #endif
 
-#define WEBNET_SESSION_BUFSZ	(4 * 1024)
+#define WEBNET_SESSION_BUFSZ    (4 * 1024)
 
 /* close session */
-#define WEBNET_EVENT_CLOSE			(1 << 5)
+#define WEBNET_EVENT_CLOSE          (1 << 5)
 /* read  session */
-#define WEBNET_EVENT_READ			(1 << 6)
+#define WEBNET_EVENT_READ           (1 << 6)
 /* write session */
-#define WEBNET_EVENT_WRITE			(1 << 7)
+#define WEBNET_EVENT_WRITE          (1 << 7)
 
 
 struct webnet_session_ops
@@ -55,11 +55,11 @@ struct webnet_session_ops
 
 enum webnet_session_phase
 {
-	WEB_PHASE_METHOD = 0, 	/* parse method */
-	WEB_PHASE_HEADER, 		/* handle web request header */
-	WEB_PHASE_QUERY,        /* handle web query */
-	WEB_PHASE_RESPONSE,		/* handle web response */
-	WEB_PHASE_CLOSE,		/* to close session */
+    WEB_PHASE_METHOD = 0,   /* parse method */
+    WEB_PHASE_HEADER,       /* handle web request header */
+    WEB_PHASE_QUERY,        /* handle web query */
+    WEB_PHASE_RESPONSE,     /* handle web response */
+    WEB_PHASE_CLOSE,        /* to close session */
 };
 
 struct webnet_session
@@ -78,10 +78,10 @@ struct webnet_session
     rt_uint16_t buffer_offset;
     rt_uint8_t  buffer[WEBNET_SESSION_BUFSZ];
 
-	/* session phase */
-	rt_uint32_t  session_phase;
+    /* session phase */
+    rt_uint32_t  session_phase;
 
-	rt_uint32_t  session_event_mask;
+    rt_uint32_t  session_event_mask;
     const struct webnet_session_ops* session_ops;
     rt_uint32_t user_data;
 };

+ 1 - 1
inc/wn_utils.h

@@ -1,7 +1,7 @@
 /*
  * File      : wn_utils.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as

+ 1 - 1
module/wn_module_alias.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module_alias.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as

+ 2 - 2
module/wn_module_asp.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module_asp.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -126,7 +126,7 @@ static void _default_asp_handler(struct webnet_session* session, const char* nam
         total = 1024*32;
         used = 1024*16;
         max_used = 1024*24;
-		
+
         webnet_session_printf(session, "current %d/maximal used %d/total %d", used, max_used, total);
     }
     else if (strncmp(name, "TICK", 4) == 0)

+ 1 - 1
module/wn_module_auth.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module_auth.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as

+ 2 - 2
module/wn_module_cgi.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module_cgi.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -33,7 +33,7 @@
 
 #ifdef WEBNET_USING_CGI
 
-#define CGI_ROOT_PATH_MAX	64
+#define CGI_ROOT_PATH_MAX   64
 
 static char _cgi_root[CGI_ROOT_PATH_MAX] = {0};
 struct webnet_cgi_item

+ 1 - 1
module/wn_module_dav.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module_dav.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as

+ 2 - 2
module/wn_module_index.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module_index.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -56,7 +56,7 @@ int webnet_module_dirindex(struct webnet_session* session, int event)
         {
             return WEBNET_MODULE_CONTINUE;
         }
-        
+
         dir = opendir(request->path);
         if (dir != RT_NULL)
         {

+ 1 - 1
module/wn_module_log.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module_log.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as

+ 1 - 1
module/wn_module_lua.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module_lua.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as

+ 7 - 7
module/wn_module_ssi.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module_ssi.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -30,12 +30,12 @@
 
 #if defined(WEBNET_USING_SSI)
 
-#define SSI_INCLUDE_STRING	"<!--#include "
-#define SSI_EXEC_STRING		"<!--#exec "
-#define SSI_VIRTUAL_STRING	"virtual=\""
-#define SSI_FILE_STRING		"file=\""
-#define SSI_CGI_STRING		"cgi=\""
-#define SSI_END_STRING		"\" -->"
+#define SSI_INCLUDE_STRING  "<!--#include "
+#define SSI_EXEC_STRING     "<!--#exec "
+#define SSI_VIRTUAL_STRING  "virtual=\""
+#define SSI_FILE_STRING     "file=\""
+#define SSI_CGI_STRING      "cgi=\""
+#define SSI_END_STRING      "\" -->"
 
 static void _webnet_ssi_sendfile(struct webnet_session* session, const char* filename)
 {

+ 1 - 1
module/wn_module_upload.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module_upload.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as

+ 1 - 1
samples/wn_sample.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_sample.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as

+ 4 - 4
samples/wn_sample_upload.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_sample_upload.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -43,7 +43,7 @@ static int file_size = 0;
 const char *get_file_name(struct webnet_session *session)
 {
     const char *path = RT_NULL, *path_last = RT_NULL;
-    
+
     path_last = webnet_upload_get_filename(session);
     if (path_last == RT_NULL)
     {
@@ -64,7 +64,7 @@ const char *get_file_name(struct webnet_session *session)
         path++;
         path_last = path;
     }
-    
+
     return path_last;
 }
 
@@ -72,7 +72,7 @@ static int upload_open(struct webnet_session *session)
 {
     int fd;
     const char *file_name = RT_NULL;
-    
+
     file_name = get_file_name(session);
     rt_kprintf("Upload FileName: %s\n", file_name);
     rt_kprintf("Content-Type   : %s\n", webnet_upload_get_content_type(session));

+ 1 - 1
src/webnet.c

@@ -1,7 +1,7 @@
 /*
  * File      : webnet.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as

+ 22 - 22
src/wn_mimetype.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_mimetype.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -35,27 +35,27 @@ struct webnet_mime_entry
 
 static const struct webnet_mime_entry mime_tables[] =
 {
-    { "any",	"application/binary" }, /* default. */
-    { "html",	"text/html" },
-    { "htm",	"text/html" },
-    { "css",	"text/css" },
-    { "txt",	"text/plain" },
-    { "pdf",	"application/pdf" },
-    { "gif",	"image/gif" },
-    { "png",	"image/png" },
-    { "jpeg",	"image/jpeg" },
-    { "jpg",	"image/jpeg" },
-    { "svg",	"image/svg+xml" },
-    { "avi",	"video/x-msvideo" },
-    { "mp3",	"audio/mpeg" },
-    { "ogg",	"audio/x-oggvorbis" },
-    { "wav",	"audio/x-wav" },
-    { "class",	"application/octet-stream" },
-    { "js",		"application/x-javascript" },
-    { "tar",	"application/x-tar" },
-    { "zip",	"application/zip" },
-    { "xml",	"text/xml" },
-    { "json",	"application/json" },
+    { "any",    "application/binary" }, /* default. */
+    { "html",   "text/html" },
+    { "htm",    "text/html" },
+    { "css",    "text/css" },
+    { "txt",    "text/plain" },
+    { "pdf",    "application/pdf" },
+    { "gif",    "image/gif" },
+    { "png",    "image/png" },
+    { "jpeg",   "image/jpeg" },
+    { "jpg",    "image/jpeg" },
+    { "svg",    "image/svg+xml" },
+    { "avi",    "video/x-msvideo" },
+    { "mp3",    "audio/mpeg" },
+    { "ogg",    "audio/x-oggvorbis" },
+    { "wav",    "audio/x-wav" },
+    { "class",  "application/octet-stream" },
+    { "js",     "application/x-javascript" },
+    { "tar",    "application/x-tar" },
+    { "zip",    "application/zip" },
+    { "xml",    "text/xml" },
+    { "json",   "application/json" },
     { RT_NULL,  RT_NULL }
 };
 

+ 14 - 14
src/wn_module.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_module.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -108,7 +108,7 @@ static void _webnet_dofile_handle(struct webnet_session *session, int event)
             {
                 goto __exit;
             }
-       
+
             if(length > WEBNET_SESSION_BUFSZ)
             {
                 length = WEBNET_SESSION_BUFSZ;
@@ -116,7 +116,7 @@ static void _webnet_dofile_handle(struct webnet_session *session, int event)
            lseek(fd, session->request->pos_start, SEEK_SET);
            session->request->pos_start += length;
         }
-#endif            
+#endif
         readbytes = read(fd, session->buffer, length);
         if (readbytes <= 0) /* end of file */
             goto __exit;
@@ -209,7 +209,7 @@ int webnet_module_system_dofile(struct webnet_session *session)
             info = localtime((time_t *)&file_stat.st_mtime);
             rt_memset(gmtime_str,0,32);
             strftime(gmtime_str,sizeof(ctime_str),"%a, %d %b %Y %H:%M:%S GMT",info);
-            
+
             strcpy(ctime_str, ctime((time_t *)&file_stat.st_mtime));
             rt_exit_critical();
 
@@ -358,20 +358,20 @@ int webnet_module_system_dofile(struct webnet_session *session)
                           file_length);
 
 #ifdef WEBNET_USING_KEEPALIVE
-	if(session->request->connection == WEBNET_CONN_KEEPALIVE)
-	{
-		webnet_session_printf(session,
+    if(session->request->connection == WEBNET_CONN_KEEPALIVE)
+    {
+        webnet_session_printf(session,
                           "Connection: %s\r\n",
                           "Keep-Alive");
-	}
-	else
-	{
-		webnet_session_printf(session,
+    }
+    else
+    {
+        webnet_session_printf(session,
                           "Connection: %s\r\n",
                           "close");
-	}
+    }
 #else
-	webnet_session_printf(session,
+    webnet_session_printf(session,
                         "Connection: %s\r\n",
                         "close");
 #endif
@@ -545,7 +545,7 @@ int webnet_module_handle_uri(struct webnet_session *session)
     while (default_files[index] != RT_NULL)
     {
         struct stat file_stat;
-        
+
         /* made a full path */
         rt_snprintf(full_path, WEBNET_PATH_MAX, "%s/%s%s",
                     webnet_get_root(), request->path, default_files[index]);

+ 1 - 1
src/wn_request.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_request.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as

+ 5 - 5
src/wn_session.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_session.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
@@ -50,7 +50,7 @@ struct webnet_session* webnet_session_create(int listenfd)
     if (session != RT_NULL)
     {
         socklen_t clilen;
-		
+
         rt_memset(session, 0x0, sizeof(struct webnet_session));
         session->session_ops = RT_NULL;
 
@@ -309,7 +309,7 @@ void webnet_session_set_header(struct webnet_session *session, const char* mimet
     }
     /* get the total length */
     length = ptr - (char*)session->buffer;
-	
+
     /* invoke webnet event */
     if (webnet_module_handle_event(session, WEBNET_EVENT_RSP_HEADER) == WEBNET_MODULE_CONTINUE)
     {
@@ -327,7 +327,7 @@ static void _webnet_session_handle_read(struct webnet_session* session)
     buffer_ptr = &session->buffer[session->buffer_offset];
     /* to read data from the socket */
     read_length = webnet_session_read(session, (char*)buffer_ptr, session->buffer_length - session->buffer_offset);
-	
+
     if (read_length > 0) session->buffer_offset += read_length;
 
     if (session->buffer_offset)
@@ -588,7 +588,7 @@ void webnet_sessions_handle_fds(fd_set *readset, fd_set *writeset)
 
             /* whether close this session */
             if (session->session_ops == RT_NULL || session->session_phase == WEB_PHASE_CLOSE)
-            {	
+            {
                 /* close this session */
                 webnet_session_close(session);
             }

+ 1 - 1
src/wn_utils.c

@@ -1,7 +1,7 @@
 /*
  * File      : wn_utils.c
  * This file is part of RT-Thread RTOS
- * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
+ * COPYRIGHT (C) 2006 - 2022, RT-Thread Development Team
  *
  * This software is dual-licensed: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as