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.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +1 -1
- data/CHANGELOG.md +17 -3
- data/Rakefile +1 -9
- data/examples/etag.ru +16 -0
- data/ext/{iodine → iodine_ext}/extconf.rb +1 -1
- data/ext/{iodine → iodine_ext}/fio.c +0 -0
- data/ext/{iodine → iodine_ext}/fio.h +0 -0
- data/ext/{iodine → iodine_ext}/fio_cli.c +0 -0
- data/ext/{iodine → iodine_ext}/fio_cli.h +189 -189
- data/ext/{iodine → iodine_ext}/fio_json_parser.h +687 -687
- data/ext/{iodine → iodine_ext}/fio_siphash.c +157 -157
- data/ext/{iodine → iodine_ext}/fio_siphash.h +37 -37
- data/ext/{iodine → iodine_ext}/fio_tls.h +129 -129
- data/ext/{iodine → iodine_ext}/fio_tls_missing.c +0 -0
- data/ext/{iodine → iodine_ext}/fio_tls_openssl.c +0 -0
- data/ext/{iodine → iodine_ext}/fio_tmpfile.h +0 -0
- data/ext/{iodine → iodine_ext}/fiobj.h +44 -44
- data/ext/{iodine → iodine_ext}/fiobj4fio.h +21 -21
- data/ext/{iodine → iodine_ext}/fiobj_ary.c +333 -333
- data/ext/{iodine → iodine_ext}/fiobj_ary.h +139 -139
- data/ext/{iodine → iodine_ext}/fiobj_data.c +0 -0
- data/ext/{iodine → iodine_ext}/fiobj_data.h +0 -0
- data/ext/{iodine → iodine_ext}/fiobj_hash.c +0 -0
- data/ext/{iodine → iodine_ext}/fiobj_hash.h +176 -176
- data/ext/{iodine → iodine_ext}/fiobj_json.c +622 -622
- data/ext/{iodine → iodine_ext}/fiobj_json.h +68 -68
- data/ext/{iodine → iodine_ext}/fiobj_mem.h +71 -71
- data/ext/{iodine → iodine_ext}/fiobj_mustache.c +0 -0
- data/ext/{iodine → iodine_ext}/fiobj_mustache.h +62 -62
- data/ext/{iodine → iodine_ext}/fiobj_numbers.c +0 -0
- data/ext/{iodine → iodine_ext}/fiobj_numbers.h +127 -127
- data/ext/{iodine → iodine_ext}/fiobj_str.c +0 -0
- data/ext/{iodine → iodine_ext}/fiobj_str.h +172 -172
- data/ext/{iodine → iodine_ext}/fiobject.c +0 -0
- data/ext/{iodine → iodine_ext}/fiobject.h +0 -0
- data/ext/{iodine → iodine_ext}/hpack.h +1923 -1923
- data/ext/{iodine → iodine_ext}/http.c +14 -27
- data/ext/{iodine → iodine_ext}/http.h +1002 -1002
- data/ext/{iodine → iodine_ext}/http1.c +0 -0
- data/ext/{iodine → iodine_ext}/http1.h +29 -29
- data/ext/{iodine → iodine_ext}/http1_parser.h +0 -0
- data/ext/{iodine → iodine_ext}/http_internal.c +0 -0
- data/ext/{iodine → iodine_ext}/http_internal.h +0 -0
- data/ext/{iodine → iodine_ext}/http_mime_parser.h +350 -350
- data/ext/{iodine → iodine_ext}/iodine.c +1 -1
- data/ext/{iodine → iodine_ext}/iodine.h +0 -0
- data/ext/{iodine → iodine_ext}/iodine_caller.c +0 -0
- data/ext/{iodine → iodine_ext}/iodine_caller.h +0 -0
- data/ext/{iodine → iodine_ext}/iodine_connection.c +0 -0
- data/ext/{iodine → iodine_ext}/iodine_connection.h +55 -55
- data/ext/{iodine → iodine_ext}/iodine_defer.c +0 -0
- data/ext/{iodine → iodine_ext}/iodine_defer.h +6 -6
- data/ext/{iodine → iodine_ext}/iodine_fiobj2rb.h +120 -120
- data/ext/{iodine → iodine_ext}/iodine_helpers.c +0 -0
- data/ext/{iodine → iodine_ext}/iodine_helpers.h +12 -12
- data/ext/{iodine → iodine_ext}/iodine_http.c +0 -2
- data/ext/{iodine → iodine_ext}/iodine_http.h +23 -23
- data/ext/{iodine → iodine_ext}/iodine_json.c +302 -302
- data/ext/{iodine → iodine_ext}/iodine_json.h +6 -6
- data/ext/{iodine → iodine_ext}/iodine_mustache.c +0 -0
- data/ext/{iodine → iodine_ext}/iodine_mustache.h +6 -6
- data/ext/{iodine → iodine_ext}/iodine_pubsub.c +0 -0
- data/ext/{iodine → iodine_ext}/iodine_pubsub.h +26 -26
- data/ext/{iodine → iodine_ext}/iodine_rack_io.c +0 -0
- data/ext/{iodine → iodine_ext}/iodine_rack_io.h +20 -20
- data/ext/{iodine → iodine_ext}/iodine_store.c +0 -0
- data/ext/{iodine → iodine_ext}/iodine_store.h +20 -20
- data/ext/{iodine → iodine_ext}/iodine_tcp.c +0 -0
- data/ext/{iodine → iodine_ext}/iodine_tcp.h +0 -0
- data/ext/{iodine → iodine_ext}/iodine_tls.c +0 -0
- data/ext/{iodine → iodine_ext}/iodine_tls.h +13 -13
- data/ext/{iodine → iodine_ext}/mustache_parser.h +0 -0
- data/ext/{iodine → iodine_ext}/redis_engine.c +0 -0
- data/ext/{iodine → iodine_ext}/redis_engine.h +0 -0
- data/ext/{iodine → iodine_ext}/resp_parser.h +0 -0
- data/ext/{iodine → iodine_ext}/websocket_parser.h +505 -505
- data/ext/{iodine → iodine_ext}/websockets.c +0 -0
- data/ext/{iodine → iodine_ext}/websockets.h +185 -185
- data/isomorfeus-iodine.gemspec +1 -2
- data/lib/iodine/version.rb +1 -1
- data/lib/iodine.rb +1 -1
- 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
|