wn_module.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * File : wn_module.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. * 2011-08-06 Bernard add webnet_alias_set declaration
  27. * 2012-06-25 Bernard add SSI and Upload module
  28. */
  29. #ifndef __WN_MODULE_H__
  30. #define __WN_MODULE_H__
  31. #include <wn_session.h>
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /* initialization event */
  36. #define WEBNET_EVENT_INIT (1 << 0)
  37. /* map uri request to physical url */
  38. #define WEBNET_EVENT_URI_PHYSICAL (1 << 1)
  39. /* uri request */
  40. #define WEBNET_EVENT_URI_POST (1 << 2)
  41. /* header of response */
  42. #define WEBNET_EVENT_RSP_HEADER (1 << 3)
  43. /* file content of response */
  44. #define WEBNET_EVENT_RSP_FILE (1 << 4)
  45. /* continue other modules */
  46. #define WEBNET_MODULE_CONTINUE 0
  47. /* this session is finished */
  48. #define WEBNET_MODULE_FINISHED 1
  49. int webnet_module_handle_event(struct webnet_session* session, int event);
  50. int webnet_module_system_dofile(struct webnet_session* session);
  51. int webnet_module_handle_uri(struct webnet_session* session);
  52. /* module function pre-declaration */
  53. int webnet_module_alias(struct webnet_session* sesion, int event);
  54. int webnet_module_auth(struct webnet_session* session, int event);
  55. int webnet_module_asp(struct webnet_session* session, int event);
  56. int webnet_module_cgi(struct webnet_session* session, int event);
  57. int webnet_module_dirindex(struct webnet_session* session, int event);
  58. int webnet_module_log(struct webnet_session* session, int event);
  59. int webnet_module_lua(struct webnet_session* sesion, int event);
  60. int webnet_module_ssl(struct webnet_session* sesion, int event);
  61. int webnet_module_ssi(struct webnet_session* session, int event);
  62. int webnet_module_dav(struct webnet_session* session, int event);
  63. int webnet_module_dmr(struct webnet_session* session, int event);
  64. /* add ASP variable */
  65. void webnet_asp_add_var(const char* name, void (*handler)(struct webnet_session* session));
  66. /* register CGI event */
  67. void webnet_cgi_register(const char* name, void (*handler)(struct webnet_session* session));
  68. void webnet_cgi_set_root(const char* root);
  69. /* set basic authentication configure */
  70. void webnet_auth_set(const char* path, const char* username_password);
  71. /* set directory alias */
  72. void webnet_alias_set(char* old_path, char* new_path);
  73. #if defined(WEBNET_USING_SSI_VIRTUAL_HANDLER)
  74. /* register ssi virtual event */
  75. void webnet_ssi_virtual_register(const char* name, void (*handler)(struct webnet_session* session));
  76. #endif
  77. /* upload module */
  78. struct webnet_module_upload_entry
  79. {
  80. const char* url;
  81. int (*upload_open) (struct webnet_session* session);
  82. int (*upload_close)(struct webnet_session* session);
  83. int (*upload_write)(struct webnet_session* session, const void* data, rt_size_t length);
  84. int (*upload_done) (struct webnet_session* session);
  85. };
  86. int webnet_module_upload(struct webnet_session* session, int event);
  87. void webnet_upload_add(const struct webnet_module_upload_entry* entry);
  88. const char* webnet_upload_get_filename(struct webnet_session* session);
  89. const char* webnet_upload_get_content_type(struct webnet_session* session);
  90. const char* webnet_upload_get_nameentry(struct webnet_session* session, const char* name);
  91. const void* webnet_upload_get_userdata(struct webnet_session* session);
  92. int webnet_upload_file_open(struct webnet_session* session);
  93. int webnet_upload_file_close(struct webnet_session* session);
  94. int webnet_upload_file_write(struct webnet_session* session, const void* data, rt_size_t length);
  95. #ifdef __cplusplus
  96. }
  97. #endif
  98. #endif /* __WN_MODULE_H__ */