PageRenderTime 48ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/EQEmuServer/common/SocketLib/HttpdCookies.h

http://projecteqemu.googlecode.com/
C Header | 91 lines | 39 code | 15 blank | 37 comment | 0 complexity | 9edf4d100406fb1a74591be1d18396f5 MD5 | raw file
Possible License(s): GPL-2.0
  1. /** \file HttpdCookies.h
  2. */
  3. /*
  4. Copyright (C) 2003-2005 Anders Hedstrom
  5. This library is made available under the terms of the GNU GPL.
  6. If you would like to use this library in a closed-source application,
  7. a separate license agreement is available. For information about
  8. the closed-source license agreement for the C++ sockets library,
  9. please visit http://www.alhem.net/Sockets/license.html and/or
  10. email license@alhem.net.
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. as published by the Free Software Foundation; either version 2
  14. of the License, or (at your option) any later version.
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. GNU General Public License for more details.
  19. You should have received a copy of the GNU General Public License
  20. along with this program; if not, write to the Free Software
  21. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22. */
  23. #ifndef _COOKIES_H
  24. #define _COOKIES_H
  25. #include <list>
  26. #include <string>
  27. #ifdef SOCKETS_NAMESPACE
  28. namespace SOCKETS_NAMESPACE {
  29. #endif
  30. //! Store the cookies name/value pairs.
  31. //! Retrieve and manage cookies during a cgi call.
  32. class HTTPSocket;
  33. /** HTTP Cookie parse/container class.
  34. \sa HttpdSocket
  35. \sa HttpdForm
  36. \ingroup webserver */
  37. class HttpdCookies
  38. {
  39. /** Name/value pair store struct.
  40. \ingroup webserver */
  41. struct COOKIE
  42. {
  43. COOKIE(const std::string& n,const std::string& v) : name(n),value(v) {}
  44. std::string name;
  45. std::string value;
  46. };
  47. /** list of key/value structs. */
  48. typedef std::list<COOKIE *> cookie_v;
  49. public:
  50. HttpdCookies();
  51. HttpdCookies(const std::string& query_string);
  52. ~HttpdCookies();
  53. // int getvalue(const std::string& ,char *,size_t); // (name, buffer, length)
  54. bool getvalue(const std::string&,std::string&);
  55. void replacevalue(const std::string& ,const std::string& );
  56. void replacevalue(const std::string& ,long);
  57. void replacevalue(const std::string& ,int);
  58. size_t getlength(const std::string& );
  59. void setcookie(HTTPSocket *,const std::string& d,const std::string& p,const std::string& c,const std::string& v);
  60. void setcookie(HTTPSocket *,const std::string& d,const std::string& p,const std::string& c,long v);
  61. void setcookie(HTTPSocket *,const std::string& d,const std::string& p,const std::string& c,int v);
  62. const std::string& expiredatetime();
  63. cookie_v& GetHttpdCookies() { return m_cookies; }
  64. private:
  65. cookie_v m_cookies;
  66. std::string m_date;
  67. };
  68. #ifdef SOCKETS_NAMESPACE
  69. }
  70. #endif
  71. #endif // _COOKIES_H