isomorfeus-iodine 0.7.49 → 0.7.50

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ruby.yml +1 -1
  3. data/CHANGELOG.md +17 -3
  4. data/Rakefile +1 -9
  5. data/examples/etag.ru +16 -0
  6. data/ext/{iodine → iodine_ext}/extconf.rb +1 -1
  7. data/ext/{iodine → iodine_ext}/fio.c +0 -0
  8. data/ext/{iodine → iodine_ext}/fio.h +0 -0
  9. data/ext/{iodine → iodine_ext}/fio_cli.c +0 -0
  10. data/ext/{iodine → iodine_ext}/fio_cli.h +189 -189
  11. data/ext/{iodine → iodine_ext}/fio_json_parser.h +687 -687
  12. data/ext/{iodine → iodine_ext}/fio_siphash.c +157 -157
  13. data/ext/{iodine → iodine_ext}/fio_siphash.h +37 -37
  14. data/ext/{iodine → iodine_ext}/fio_tls.h +129 -129
  15. data/ext/{iodine → iodine_ext}/fio_tls_missing.c +0 -0
  16. data/ext/{iodine → iodine_ext}/fio_tls_openssl.c +0 -0
  17. data/ext/{iodine → iodine_ext}/fio_tmpfile.h +0 -0
  18. data/ext/{iodine → iodine_ext}/fiobj.h +44 -44
  19. data/ext/{iodine → iodine_ext}/fiobj4fio.h +21 -21
  20. data/ext/{iodine → iodine_ext}/fiobj_ary.c +333 -333
  21. data/ext/{iodine → iodine_ext}/fiobj_ary.h +139 -139
  22. data/ext/{iodine → iodine_ext}/fiobj_data.c +0 -0
  23. data/ext/{iodine → iodine_ext}/fiobj_data.h +0 -0
  24. data/ext/{iodine → iodine_ext}/fiobj_hash.c +0 -0
  25. data/ext/{iodine → iodine_ext}/fiobj_hash.h +176 -176
  26. data/ext/{iodine → iodine_ext}/fiobj_json.c +622 -622
  27. data/ext/{iodine → iodine_ext}/fiobj_json.h +68 -68
  28. data/ext/{iodine → iodine_ext}/fiobj_mem.h +71 -71
  29. data/ext/{iodine → iodine_ext}/fiobj_mustache.c +0 -0
  30. data/ext/{iodine → iodine_ext}/fiobj_mustache.h +62 -62
  31. data/ext/{iodine → iodine_ext}/fiobj_numbers.c +0 -0
  32. data/ext/{iodine → iodine_ext}/fiobj_numbers.h +127 -127
  33. data/ext/{iodine → iodine_ext}/fiobj_str.c +0 -0
  34. data/ext/{iodine → iodine_ext}/fiobj_str.h +172 -172
  35. data/ext/{iodine → iodine_ext}/fiobject.c +0 -0
  36. data/ext/{iodine → iodine_ext}/fiobject.h +0 -0
  37. data/ext/{iodine → iodine_ext}/hpack.h +1923 -1923
  38. data/ext/{iodine → iodine_ext}/http.c +14 -27
  39. data/ext/{iodine → iodine_ext}/http.h +1002 -1002
  40. data/ext/{iodine → iodine_ext}/http1.c +0 -0
  41. data/ext/{iodine → iodine_ext}/http1.h +29 -29
  42. data/ext/{iodine → iodine_ext}/http1_parser.h +0 -0
  43. data/ext/{iodine → iodine_ext}/http_internal.c +0 -0
  44. data/ext/{iodine → iodine_ext}/http_internal.h +0 -0
  45. data/ext/{iodine → iodine_ext}/http_mime_parser.h +350 -350
  46. data/ext/{iodine → iodine_ext}/iodine.c +1 -1
  47. data/ext/{iodine → iodine_ext}/iodine.h +0 -0
  48. data/ext/{iodine → iodine_ext}/iodine_caller.c +0 -0
  49. data/ext/{iodine → iodine_ext}/iodine_caller.h +0 -0
  50. data/ext/{iodine → iodine_ext}/iodine_connection.c +0 -0
  51. data/ext/{iodine → iodine_ext}/iodine_connection.h +55 -55
  52. data/ext/{iodine → iodine_ext}/iodine_defer.c +0 -0
  53. data/ext/{iodine → iodine_ext}/iodine_defer.h +6 -6
  54. data/ext/{iodine → iodine_ext}/iodine_fiobj2rb.h +120 -120
  55. data/ext/{iodine → iodine_ext}/iodine_helpers.c +0 -0
  56. data/ext/{iodine → iodine_ext}/iodine_helpers.h +12 -12
  57. data/ext/{iodine → iodine_ext}/iodine_http.c +0 -2
  58. data/ext/{iodine → iodine_ext}/iodine_http.h +23 -23
  59. data/ext/{iodine → iodine_ext}/iodine_json.c +302 -302
  60. data/ext/{iodine → iodine_ext}/iodine_json.h +6 -6
  61. data/ext/{iodine → iodine_ext}/iodine_mustache.c +0 -0
  62. data/ext/{iodine → iodine_ext}/iodine_mustache.h +6 -6
  63. data/ext/{iodine → iodine_ext}/iodine_pubsub.c +0 -0
  64. data/ext/{iodine → iodine_ext}/iodine_pubsub.h +26 -26
  65. data/ext/{iodine → iodine_ext}/iodine_rack_io.c +0 -0
  66. data/ext/{iodine → iodine_ext}/iodine_rack_io.h +20 -20
  67. data/ext/{iodine → iodine_ext}/iodine_store.c +0 -0
  68. data/ext/{iodine → iodine_ext}/iodine_store.h +20 -20
  69. data/ext/{iodine → iodine_ext}/iodine_tcp.c +0 -0
  70. data/ext/{iodine → iodine_ext}/iodine_tcp.h +0 -0
  71. data/ext/{iodine → iodine_ext}/iodine_tls.c +0 -0
  72. data/ext/{iodine → iodine_ext}/iodine_tls.h +13 -13
  73. data/ext/{iodine → iodine_ext}/mustache_parser.h +0 -0
  74. data/ext/{iodine → iodine_ext}/redis_engine.c +0 -0
  75. data/ext/{iodine → iodine_ext}/redis_engine.h +0 -0
  76. data/ext/{iodine → iodine_ext}/resp_parser.h +0 -0
  77. data/ext/{iodine → iodine_ext}/websocket_parser.h +505 -505
  78. data/ext/{iodine → iodine_ext}/websockets.c +0 -0
  79. data/ext/{iodine → iodine_ext}/websockets.h +185 -185
  80. data/isomorfeus-iodine.gemspec +1 -2
  81. data/lib/iodine/version.rb +1 -1
  82. data/lib/iodine.rb +1 -1
  83. metadata +79 -78
@@ -1,172 +1,172 @@
1
- #ifndef H_FIOBJ_STR_H
2
- /*
3
- Copyright: Boaz Segev, 2017-2019
4
- License: MIT
5
- */
6
- #define H_FIOBJ_STR_H
7
-
8
- #include <fiobject.h>
9
-
10
- #ifdef __cplusplus
11
- extern "C" {
12
- #endif
13
-
14
- #define FIOBJ_IS_STRING(obj) FIOBJ_TYPE_IS((obj), FIOBJ_T_STRING)
15
-
16
- /* *****************************************************************************
17
- API: Creating a String Object
18
- ***************************************************************************** */
19
-
20
- /** Creates a String object. Remember to use `fiobj_free`. */
21
- FIOBJ fiobj_str_new(const char *str, size_t len);
22
-
23
- /**
24
- * Creates a String object with pre-allocation for Strings up to `capa` long.
25
- *
26
- * If `capa` is zero, a whole memory page will be allocated.
27
- *
28
- * Remember to use `fiobj_free`.
29
- */
30
- FIOBJ fiobj_str_buf(size_t capa);
31
-
32
- /** Creates a copy from an existing String. Remember to use `fiobj_free`. */
33
- static inline __attribute__((unused)) FIOBJ fiobj_str_copy(FIOBJ src) {
34
- fio_str_info_s s = fiobj_obj2cstr(src);
35
- return fiobj_str_new(s.data, s.len);
36
- }
37
-
38
- /**
39
- * Creates a String object. Remember to use `fiobj_free`.
40
- *
41
- * It's possible to wrap a previosly allocated memory block in a FIOBJ String
42
- * object, as long as it was allocated using `fio_malloc`.
43
- *
44
- * The ownership of the memory indicated by `str` will "move" to the object and
45
- * will be freed (using `fio_free`) once the object's reference count drops to
46
- * zero.
47
- *
48
- * Note: The original memory MUST be allocated using `fio_malloc` (NOT the
49
- * system's `malloc`) and it will be freed using `fio_free`.
50
- */
51
- FIOBJ fiobj_str_move(char *str, size_t len, size_t capacity);
52
-
53
- /**
54
- * Returns a thread-static temporary string. Avoid calling `fiobj_dup` or
55
- * `fiobj_free`.
56
- */
57
- FIOBJ fiobj_str_tmp(void);
58
-
59
- /* *****************************************************************************
60
- API: Editing a String
61
- ***************************************************************************** */
62
-
63
- /**
64
- * Prevents the String object from being changed.
65
- *
66
- * When a String is used as a key for a Hash, it is automatically frozen to
67
- * prevent the Hash from becoming broken.
68
- */
69
- void fiobj_str_freeze(FIOBJ str);
70
-
71
- /**
72
- * Confirms the String allows for the requested capacity (counting used space as
73
- * well as free space).
74
- *
75
- * Returns updated capacity.
76
- */
77
- size_t fiobj_str_capa_assert(FIOBJ str, size_t size);
78
-
79
- /** Returns a String's capacity, if any. This should include the NUL byte. */
80
- size_t fiobj_str_capa(FIOBJ str);
81
-
82
- /** Resizes a String object, allocating more memory if required. */
83
- void fiobj_str_resize(FIOBJ str, size_t size);
84
-
85
- /**
86
- * Performs a best attempt at minimizing memory consumption.
87
- *
88
- * Actual effects depend on the underlying memory allocator and it's
89
- * implementation. Not all allocators will free any memory.
90
- */
91
- void fiobj_str_compact(FIOBJ str);
92
-
93
- /** Alias for `fiobj_str_compact`. */
94
- #define fiobj_str_minimize(str) fiobj_str_compact((str))
95
-
96
- /** Empties a String's data. */
97
- void fiobj_str_clear(FIOBJ str);
98
-
99
- /**
100
- * Writes data at the end of the string, resizing the string as required.
101
- * Returns the new length of the String
102
- */
103
- size_t fiobj_str_write(FIOBJ dest, const char *data, size_t len);
104
-
105
- /**
106
- * Writes a number at the end of the String using normal base 10 notation.
107
- *
108
- * Returns the new length of the String
109
- */
110
- size_t fiobj_str_write_i(FIOBJ dest, int64_t num);
111
-
112
- /**
113
- * Writes data at the end of the string using a printf like interface, resizing
114
- * the string as required. Returns the new length of the String
115
- */
116
- __attribute__((format(printf, 2, 3))) size_t
117
- fiobj_str_printf(FIOBJ dest, const char *format, ...);
118
-
119
- /**
120
- * Writes data at the end of the string using a vprintf like interface, resizing
121
- * the string as required.
122
- *
123
- * Returns the new length of the String
124
- */
125
- __attribute__((format(printf, 2, 0))) size_t
126
- fiobj_str_vprintf(FIOBJ dest, const char *format, va_list argv);
127
-
128
- /**
129
- * Writes data at the end of the string, resizing the string as required.
130
- *
131
- * Remember to call `fiobj_free` to free the source (when done with it).
132
- *
133
- * Returns the new length of the String.
134
- */
135
- size_t fiobj_str_concat(FIOBJ dest, FIOBJ source);
136
- #define fiobj_str_join(dest, src) fiobj_str_concat((dest), (src))
137
-
138
- /**
139
- * Dumps the `filename` file's contents at the end of the String.
140
- *
141
- * If `limit == 0`, than the data will be read until EOF.
142
- *
143
- * If the file can't be located, opened or read, or if `start_at` is out of
144
- * bounds (i.e., beyond the EOF position), FIOBJ_INVALID is returned.
145
- *
146
- * If `start_at` is negative, it will be computed from the end of the file.
147
- *
148
- * Remember to use `fiobj_free`.
149
- *
150
- * NOTE: Requires a UNIX system, otherwise always returns FIOBJ_INVALID.
151
- */
152
- size_t fiobj_str_readfile(FIOBJ dest, const char *filename, intptr_t start_at,
153
- intptr_t limit);
154
-
155
- /* *****************************************************************************
156
- API: String Values
157
- ***************************************************************************** */
158
-
159
- /**
160
- * Calculates a String's SipHash value for possible use as a HashMap key.
161
- */
162
- uint64_t fiobj_str_hash(FIOBJ o);
163
-
164
- #if DEBUG
165
- void fiobj_test_string(void);
166
- #endif
167
-
168
- #ifdef __cplusplus
169
- } /* extern "C" */
170
- #endif
171
-
172
- #endif
1
+ #ifndef H_FIOBJ_STR_H
2
+ /*
3
+ Copyright: Boaz Segev, 2017-2019
4
+ License: MIT
5
+ */
6
+ #define H_FIOBJ_STR_H
7
+
8
+ #include <fiobject.h>
9
+
10
+ #ifdef __cplusplus
11
+ extern "C" {
12
+ #endif
13
+
14
+ #define FIOBJ_IS_STRING(obj) FIOBJ_TYPE_IS((obj), FIOBJ_T_STRING)
15
+
16
+ /* *****************************************************************************
17
+ API: Creating a String Object
18
+ ***************************************************************************** */
19
+
20
+ /** Creates a String object. Remember to use `fiobj_free`. */
21
+ FIOBJ fiobj_str_new(const char *str, size_t len);
22
+
23
+ /**
24
+ * Creates a String object with pre-allocation for Strings up to `capa` long.
25
+ *
26
+ * If `capa` is zero, a whole memory page will be allocated.
27
+ *
28
+ * Remember to use `fiobj_free`.
29
+ */
30
+ FIOBJ fiobj_str_buf(size_t capa);
31
+
32
+ /** Creates a copy from an existing String. Remember to use `fiobj_free`. */
33
+ static inline __attribute__((unused)) FIOBJ fiobj_str_copy(FIOBJ src) {
34
+ fio_str_info_s s = fiobj_obj2cstr(src);
35
+ return fiobj_str_new(s.data, s.len);
36
+ }
37
+
38
+ /**
39
+ * Creates a String object. Remember to use `fiobj_free`.
40
+ *
41
+ * It's possible to wrap a previosly allocated memory block in a FIOBJ String
42
+ * object, as long as it was allocated using `fio_malloc`.
43
+ *
44
+ * The ownership of the memory indicated by `str` will "move" to the object and
45
+ * will be freed (using `fio_free`) once the object's reference count drops to
46
+ * zero.
47
+ *
48
+ * Note: The original memory MUST be allocated using `fio_malloc` (NOT the
49
+ * system's `malloc`) and it will be freed using `fio_free`.
50
+ */
51
+ FIOBJ fiobj_str_move(char *str, size_t len, size_t capacity);
52
+
53
+ /**
54
+ * Returns a thread-static temporary string. Avoid calling `fiobj_dup` or
55
+ * `fiobj_free`.
56
+ */
57
+ FIOBJ fiobj_str_tmp(void);
58
+
59
+ /* *****************************************************************************
60
+ API: Editing a String
61
+ ***************************************************************************** */
62
+
63
+ /**
64
+ * Prevents the String object from being changed.
65
+ *
66
+ * When a String is used as a key for a Hash, it is automatically frozen to
67
+ * prevent the Hash from becoming broken.
68
+ */
69
+ void fiobj_str_freeze(FIOBJ str);
70
+
71
+ /**
72
+ * Confirms the String allows for the requested capacity (counting used space as
73
+ * well as free space).
74
+ *
75
+ * Returns updated capacity.
76
+ */
77
+ size_t fiobj_str_capa_assert(FIOBJ str, size_t size);
78
+
79
+ /** Returns a String's capacity, if any. This should include the NUL byte. */
80
+ size_t fiobj_str_capa(FIOBJ str);
81
+
82
+ /** Resizes a String object, allocating more memory if required. */
83
+ void fiobj_str_resize(FIOBJ str, size_t size);
84
+
85
+ /**
86
+ * Performs a best attempt at minimizing memory consumption.
87
+ *
88
+ * Actual effects depend on the underlying memory allocator and it's
89
+ * implementation. Not all allocators will free any memory.
90
+ */
91
+ void fiobj_str_compact(FIOBJ str);
92
+
93
+ /** Alias for `fiobj_str_compact`. */
94
+ #define fiobj_str_minimize(str) fiobj_str_compact((str))
95
+
96
+ /** Empties a String's data. */
97
+ void fiobj_str_clear(FIOBJ str);
98
+
99
+ /**
100
+ * Writes data at the end of the string, resizing the string as required.
101
+ * Returns the new length of the String
102
+ */
103
+ size_t fiobj_str_write(FIOBJ dest, const char *data, size_t len);
104
+
105
+ /**
106
+ * Writes a number at the end of the String using normal base 10 notation.
107
+ *
108
+ * Returns the new length of the String
109
+ */
110
+ size_t fiobj_str_write_i(FIOBJ dest, int64_t num);
111
+
112
+ /**
113
+ * Writes data at the end of the string using a printf like interface, resizing
114
+ * the string as required. Returns the new length of the String
115
+ */
116
+ __attribute__((format(printf, 2, 3))) size_t
117
+ fiobj_str_printf(FIOBJ dest, const char *format, ...);
118
+
119
+ /**
120
+ * Writes data at the end of the string using a vprintf like interface, resizing
121
+ * the string as required.
122
+ *
123
+ * Returns the new length of the String
124
+ */
125
+ __attribute__((format(printf, 2, 0))) size_t
126
+ fiobj_str_vprintf(FIOBJ dest, const char *format, va_list argv);
127
+
128
+ /**
129
+ * Writes data at the end of the string, resizing the string as required.
130
+ *
131
+ * Remember to call `fiobj_free` to free the source (when done with it).
132
+ *
133
+ * Returns the new length of the String.
134
+ */
135
+ size_t fiobj_str_concat(FIOBJ dest, FIOBJ source);
136
+ #define fiobj_str_join(dest, src) fiobj_str_concat((dest), (src))
137
+
138
+ /**
139
+ * Dumps the `filename` file's contents at the end of the String.
140
+ *
141
+ * If `limit == 0`, than the data will be read until EOF.
142
+ *
143
+ * If the file can't be located, opened or read, or if `start_at` is out of
144
+ * bounds (i.e., beyond the EOF position), FIOBJ_INVALID is returned.
145
+ *
146
+ * If `start_at` is negative, it will be computed from the end of the file.
147
+ *
148
+ * Remember to use `fiobj_free`.
149
+ *
150
+ * NOTE: Requires a UNIX system, otherwise always returns FIOBJ_INVALID.
151
+ */
152
+ size_t fiobj_str_readfile(FIOBJ dest, const char *filename, intptr_t start_at,
153
+ intptr_t limit);
154
+
155
+ /* *****************************************************************************
156
+ API: String Values
157
+ ***************************************************************************** */
158
+
159
+ /**
160
+ * Calculates a String's SipHash value for possible use as a HashMap key.
161
+ */
162
+ uint64_t fiobj_str_hash(FIOBJ o);
163
+
164
+ #if DEBUG
165
+ void fiobj_test_string(void);
166
+ #endif
167
+
168
+ #ifdef __cplusplus
169
+ } /* extern "C" */
170
+ #endif
171
+
172
+ #endif
File without changes
File without changes