ChipMaster's trial hacks on C++CMS starting with v1.2.1. Not sure I'll follow on with the v2 since it looks to be breaking and mostly frivolous.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

66 lines
2.0 KiB

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (C) 2008-2012 Artyom Beilis (Tonkikh) <artyomtnk@yahoo.com>
  4. //
  5. // See accompanying file COPYING.TXT file for licensing details.
  6. //
  7. ///////////////////////////////////////////////////////////////////////////////
  8. #ifndef CPPCMS_SESSION_POSIX_FILE_STORAGE_H
  9. #define CPPCMS_SESSION_POSIX_FILE_STORAGE_H
  10. #include <cppcms/defs.h>
  11. #include <cppcms/session_storage.h>
  12. #include <booster/hold_ptr.h>
  13. #include <vector>
  14. namespace cppcms {
  15. namespace sessions {
  16. class session_file_storage_factory;
  17. class CPPCMS_API session_file_storage : public session_storage {
  18. public:
  19. session_file_storage(std::string path);
  20. virtual ~session_file_storage();
  21. virtual void save(std::string const &sid,time_t timeout,std::string const &in);
  22. virtual bool load(std::string const &sid,time_t &timeout,std::string &out);
  23. virtual void remove(std::string const &sid);
  24. virtual bool is_blocking();
  25. private:
  26. struct locked_file;
  27. struct _data;
  28. bool read_timestamp(void *h);
  29. bool read_from_file(void *h,time_t &timeout,std::string &data);
  30. void save_to_file(void *h,time_t timeout,std::string const &in);
  31. bool read_all(void *,void *vbuf,int n);
  32. bool write_all(void *,void const *vbuf,int n);
  33. void gc();
  34. std::string file_name(std::string const &sid);
  35. // members
  36. booster::hold_ptr<_data> d;
  37. std::string path_;
  38. // friends
  39. friend struct locked_file;
  40. friend class session_file_storage_factory;
  41. };
  42. class CPPCMS_API session_file_storage_factory : public session_storage_factory {
  43. public:
  44. session_file_storage_factory(std::string path);
  45. virtual booster::shared_ptr<session_storage> get();
  46. virtual bool requires_gc();
  47. virtual void gc_job();
  48. virtual ~session_file_storage_factory();
  49. private:
  50. struct _data;
  51. booster::shared_ptr<session_file_storage> storage_;
  52. };
  53. } // sessions
  54. } // cppcms
  55. #endif