httpUtil.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * @file httpUtil.c
  3. * @brief HTTP Server Utilities
  4. * @version 1.0
  5. * @date 2014/07/15
  6. * @par Revision
  7. * 2014/07/15 - 1.0 Release
  8. * @author
  9. * \n\n @par Copyright (C) 1998 - 2014 WIZnet. All rights reserved.
  10. */
  11. #include <stdio.h>
  12. #include <string.h>
  13. #include <stdlib.h>
  14. #include "httpUtil.h"
  15. uint8_t http_get_cgi_handler(uint8_t * uri_name, uint8_t * buf, uint32_t * file_len)
  16. {
  17. uint8_t ret = HTTP_OK;
  18. uint16_t len = 0;
  19. if(predefined_get_cgi_processor(uri_name, buf, &len))
  20. {
  21. ;
  22. }
  23. else if(strcmp((const char *)uri_name, "example.cgi") == 0)
  24. {
  25. // To do
  26. ;
  27. }
  28. else
  29. {
  30. // CGI file not found
  31. ret = HTTP_FAILED;
  32. }
  33. if(ret) *file_len = len;
  34. return ret;
  35. }
  36. uint8_t http_post_cgi_handler(uint8_t * uri_name, st_http_request * p_http_request, uint8_t * buf, uint32_t * file_len)
  37. {
  38. uint8_t ret = HTTP_OK;
  39. uint16_t len = 0;
  40. uint8_t val = 0;
  41. if(predefined_set_cgi_processor(uri_name, p_http_request->URI, buf, &len))
  42. {
  43. ;
  44. }
  45. else if(strcmp((const char *)uri_name, "example.cgi") == 0)
  46. {
  47. // To do
  48. val = 1;
  49. len = sprintf((char *)buf, "%d", val);
  50. }
  51. else
  52. {
  53. // CGI file not found
  54. ret = HTTP_FAILED;
  55. }
  56. if(ret) *file_len = len;
  57. return ret;
  58. }
  59. uint8_t predefined_get_cgi_processor(uint8_t * uri_name, uint8_t * buf, uint16_t * len)
  60. {
  61. ;
  62. }
  63. uint8_t predefined_set_cgi_processor(uint8_t * uri_name, uint8_t * uri, uint8_t * buf, uint16_t * en)
  64. {
  65. ;
  66. }