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.
 
 
 
 
 
 

93 lines
2.2 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 TCP_CACHE_PROTO_H
  9. #define TCP_CACHE_PROTO_H
  10. #include <cppcms/cstdint.h>
  11. #include <time.h>
  12. #include <limits>
  13. namespace cppcms {
  14. namespace impl {
  15. namespace opcodes {
  16. enum { fetch, rise, clear, store ,stats,
  17. error, done, data, no_data, uptodate, out_stats,
  18. session_save, session_load, session_load_data, session_remove};
  19. inline char const *to_name(int v)
  20. {
  21. char const *names[] = {
  22. "fetch","rise", "clear", "store" ,"stats",
  23. "error", "done", "data", "no_data", "uptodate", "out_stats",
  24. "session_save", "session_load", "session_load_data", "session_remove"
  25. };
  26. if(v<0 || v>session_remove)
  27. return "unknown";
  28. return names[v];
  29. }
  30. }
  31. struct tcp_operation_header {
  32. uint32_t opcode;
  33. uint32_t size;
  34. uint32_t filler[2];
  35. union {
  36. struct {
  37. uint64_t current_gen;
  38. uint32_t key_len;
  39. uint32_t transfer_triggers : 1;
  40. uint32_t transfer_if_not_uptodate : 1;
  41. uint32_t reserver : 30;
  42. } fetch;
  43. struct {
  44. uint32_t trigger_len;
  45. } rise;
  46. struct {
  47. int64_t timeout;
  48. uint32_t key_len;
  49. uint32_t data_len;
  50. uint32_t triggers_len;
  51. } store;
  52. struct {
  53. uint64_t generation;
  54. int64_t timeout;
  55. uint32_t data_len;
  56. uint32_t triggers_len;
  57. } data;
  58. struct {
  59. uint32_t keys;
  60. uint32_t triggers;
  61. } out_stats;
  62. struct {
  63. int64_t timeout;
  64. } session_save;
  65. struct {
  66. int64_t timeout;
  67. } session_data;
  68. } operations;
  69. };
  70. inline time_t to_time_t(int64_t v)
  71. {
  72. if(sizeof(time_t) < sizeof(v)) {
  73. if(v > static_cast<int64_t>(std::numeric_limits<time_t>::max())) {
  74. return std::numeric_limits<time_t>::max();
  75. }
  76. else {
  77. return static_cast<time_t>(v);
  78. }
  79. }
  80. else {
  81. return static_cast<time_t>(v);
  82. }
  83. }
  84. } // namespace impl
  85. } // Namespace cppcms
  86. #endif