webnet.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /*
  2. * File : webnet.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2006 - 2018, RT-Thread Development Team
  5. *
  6. * This software is dual-licensed: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 as
  8. * published by the Free Software Foundation. For the terms of this
  9. * license, see <http://www.gnu.org/licenses/>.
  10. *
  11. * You are free to use this software under the terms of the GNU General
  12. * Public License, but WITHOUT ANY WARRANTY; without even the implied
  13. * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. * See the GNU General Public License for more details.
  15. *
  16. * Alternatively for commercial application, you can contact us
  17. * by email <business@rt-thread.com> for commercial license.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  22. *
  23. * Change Logs:
  24. * Date Author Notes
  25. * 2011-08-02 Bernard the first version
  26. *
  27. * Release 1.0.3
  28. * 2012-09-15 Bernard fixed basic authentication issue in Safari.
  29. * Release 1.0.4
  30. * 2012-11-08 Bernard fixed the buffer issue in FireFox upload.
  31. * Release 1.0.5
  32. * 2012-12-10 aozima fixed small file upload issue.
  33. * Release 1.0.6
  34. * 2012-12-17 Bernard fixed the content multi-transmission issue in POST.
  35. * Release 1.0.7
  36. * 2013-03-01 aozima add feature: add Last-Modified and Cache-Control.
  37. * Release 1.0.8
  38. * 2015-04-17 Bernard Use select for write socket
  39. * Release 1.1.0
  40. * 2015-05-01 aozima support deflate gzip.
  41. * Release 2.0.0
  42. * 2016-07-31 Bernard Rewrite http read handling and change version to 2.0.0
  43. */
  44. #ifndef __WEBNET_H__
  45. #define __WEBNET_H__
  46. #include <rtthread.h>
  47. #ifdef __cplusplus
  48. extern "C" {
  49. #endif
  50. #ifndef wn_malloc
  51. #define wn_malloc rt_malloc
  52. #endif
  53. #ifndef wn_free
  54. #define wn_free rt_free
  55. #endif
  56. #ifndef wn_realloc
  57. #define wn_realloc rt_realloc
  58. #endif
  59. #ifndef wn_strdup
  60. #define wn_strdup rt_strdup
  61. #endif
  62. #ifndef WEBNET_USING_RANGE
  63. #define WEBNET_USING_RANGE
  64. #endif
  65. #ifndef WEBNET_USING_KEEPALIVE
  66. #define WEBNET_USING_KEEPALIVE
  67. #endif
  68. #ifndef WEBNET_USING_COOKIE
  69. #define WEBNET_USING_COOKIE
  70. #endif
  71. #define WEBNET_VERSION "2.0.3" /* webnet version string */
  72. #define WEBNET_VERSION_NUM 0x20003 /* webnet version number */
  73. #define WEBNET_THREAD_NAME "webnet" /* webnet thread name */
  74. #define WEBNET_THREAD_STACKSIZE (4 * 1024) /* webnet thread stack size */
  75. #define WEBNET_PRIORITY 20 /* webnet thread priority */
  76. #define WEBNET_PATH_MAX 256 /* maxiaml path length in webnet */
  77. #define WEBNET_SERVER "Server: webnet "WEBNET_VERSION"\r\n"
  78. /* Pre-declaration */
  79. struct webnet_session;
  80. /* webnet query item definitions */
  81. struct webnet_query_item
  82. {
  83. char* name;
  84. char* value;
  85. };
  86. /* get mimetype according to URL */
  87. const char* mime_get_type(const char* url);
  88. /* set and get listen socket port */
  89. void webnet_set_port(int port);
  90. int webnet_get_port(void);
  91. /* set and get root directory path */
  92. void webnet_set_root(const char* webroot_path);
  93. const char* webnet_get_root(void);
  94. /* webnet initialize */
  95. int webnet_init(void);
  96. #ifdef __cplusplus
  97. }
  98. #endif
  99. #endif /* __WEBNET_H__ */