agoo 2.5.5 → 2.5.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of agoo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +1 -1
- data/ext/agoo/agoo.c +4 -3
- data/ext/agoo/atomic.h +120 -0
- data/ext/agoo/bind.c +52 -52
- data/ext/agoo/bind.h +13 -13
- data/ext/agoo/con.c +499 -481
- data/ext/agoo/con.h +47 -39
- data/ext/agoo/debug.c +42 -42
- data/ext/agoo/debug.h +1 -1
- data/ext/agoo/doc.c +17 -17
- data/ext/agoo/doc.h +12 -12
- data/ext/agoo/err.c +18 -18
- data/ext/agoo/err.h +27 -27
- data/ext/agoo/error_stream.c +9 -9
- data/ext/agoo/extconf.rb +3 -0
- data/ext/agoo/gqlintro.c +43 -43
- data/ext/agoo/gqlintro.h +1 -1
- data/ext/agoo/gqlvalue.c +131 -131
- data/ext/agoo/gqlvalue.h +32 -32
- data/ext/agoo/graphql.c +158 -158
- data/ext/agoo/graphql.h +34 -33
- data/ext/agoo/hook.c +15 -14
- data/ext/agoo/hook.h +18 -14
- data/ext/agoo/http.c +14 -14
- data/ext/agoo/http.h +4 -4
- data/ext/agoo/kinds.h +5 -5
- data/ext/agoo/log.c +232 -224
- data/ext/agoo/log.h +93 -93
- data/ext/agoo/method.h +17 -17
- data/ext/agoo/page.c +88 -86
- data/ext/agoo/page.h +21 -21
- data/ext/agoo/pub.c +36 -36
- data/ext/agoo/pub.h +23 -23
- data/ext/agoo/queue.c +37 -38
- data/ext/agoo/queue.h +20 -19
- data/ext/agoo/rack_logger.c +13 -13
- data/ext/agoo/ready.c +357 -0
- data/ext/agoo/ready.h +41 -0
- data/ext/agoo/req.c +11 -11
- data/ext/agoo/req.h +30 -31
- data/ext/agoo/request.c +46 -46
- data/ext/agoo/request.h +2 -2
- data/ext/agoo/res.c +40 -18
- data/ext/agoo/res.h +14 -14
- data/ext/agoo/response.c +6 -6
- data/ext/agoo/response.h +9 -9
- data/ext/agoo/rhook.c +3 -3
- data/ext/agoo/rhook.h +1 -1
- data/ext/agoo/rlog.c +47 -42
- data/ext/agoo/rlog.h +0 -1
- data/ext/agoo/rresponse.c +33 -33
- data/ext/agoo/rresponse.h +1 -1
- data/ext/agoo/rserver.c +184 -175
- data/ext/agoo/rserver.h +2 -2
- data/ext/agoo/rupgraded.c +41 -41
- data/ext/agoo/rupgraded.h +3 -3
- data/ext/agoo/sdl.c +80 -80
- data/ext/agoo/sdl.h +1 -1
- data/ext/agoo/seg.h +2 -2
- data/ext/agoo/server.c +143 -117
- data/ext/agoo/server.h +43 -42
- data/ext/agoo/sse.c +7 -7
- data/ext/agoo/sse.h +4 -4
- data/ext/agoo/subject.c +5 -5
- data/ext/agoo/subject.h +6 -6
- data/ext/agoo/text.c +21 -21
- data/ext/agoo/text.h +14 -13
- data/ext/agoo/upgraded.c +41 -40
- data/ext/agoo/upgraded.h +41 -40
- data/ext/agoo/websocket.c +42 -42
- data/ext/agoo/websocket.h +16 -16
- data/lib/agoo/version.rb +1 -1
- data/test/static_test.rb +2 -0
- metadata +5 -5
- data/ext/agoo/log_queue.h +0 -30
- data/ext/agoo/sub.c +0 -111
- data/ext/agoo/sub.h +0 -36
data/ext/agoo/error_stream.c
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
|
8
8
|
static VALUE es_class = Qundef;
|
9
9
|
|
10
|
-
typedef struct
|
11
|
-
|
12
|
-
|
10
|
+
typedef struct _errorStream {
|
11
|
+
agooServer server;
|
12
|
+
agooText text;
|
13
13
|
} *ErrorStream;
|
14
14
|
|
15
15
|
static void
|
@@ -24,10 +24,10 @@ es_free(void *ptr) {
|
|
24
24
|
|
25
25
|
VALUE
|
26
26
|
error_stream_new() {
|
27
|
-
ErrorStream es = ALLOC(struct
|
27
|
+
ErrorStream es = ALLOC(struct _errorStream);
|
28
28
|
|
29
29
|
DEBUG_ALLOC(mem_err_stream, es)
|
30
|
-
es->text =
|
30
|
+
es->text = agoo_text_allocate(1024);
|
31
31
|
|
32
32
|
return Data_Wrap_Struct(es_class, NULL, es_free, es);
|
33
33
|
}
|
@@ -43,8 +43,8 @@ static VALUE
|
|
43
43
|
es_puts(VALUE self, VALUE str) {
|
44
44
|
ErrorStream es = (ErrorStream)DATA_PTR(self);
|
45
45
|
|
46
|
-
es->text =
|
47
|
-
es->text =
|
46
|
+
es->text = agoo_text_append(es->text, StringValuePtr(str), (int)RSTRING_LEN(str));
|
47
|
+
es->text = agoo_text_append(es->text, "\n", 1);
|
48
48
|
|
49
49
|
return Qnil;
|
50
50
|
}
|
@@ -60,7 +60,7 @@ es_write(VALUE self, VALUE str) {
|
|
60
60
|
ErrorStream es = (ErrorStream)DATA_PTR(self);
|
61
61
|
int cnt = (int)RSTRING_LEN(str);
|
62
62
|
|
63
|
-
es->text =
|
63
|
+
es->text = agoo_text_append(es->text, StringValuePtr(str), cnt);
|
64
64
|
|
65
65
|
return INT2NUM(cnt);
|
66
66
|
}
|
@@ -75,7 +75,7 @@ static VALUE
|
|
75
75
|
es_flush(VALUE self) {
|
76
76
|
ErrorStream es = (ErrorStream)DATA_PTR(self);
|
77
77
|
|
78
|
-
|
78
|
+
agoo_log_cat(&agoo_error_cat, "%s", es->text->text);
|
79
79
|
es->text->len = 0;
|
80
80
|
|
81
81
|
return self;
|
data/ext/agoo/extconf.rb
CHANGED
@@ -10,6 +10,9 @@ $CFLAGS += " -DPLATFORM_LINUX" if 'x86_64-linux' == RUBY_PLATFORM
|
|
10
10
|
# does not work to check args with varargs s just remove the check.
|
11
11
|
CONFIG['warnflags'].slice!(/ -Wsuggest-attribute=format/)
|
12
12
|
|
13
|
+
have_header('stdatomic.h')
|
14
|
+
#have_header('sys/epoll.h')
|
15
|
+
|
13
16
|
create_makefile(File.join(extension_name, extension_name))
|
14
17
|
|
15
18
|
puts ">>>>> Created Makefile for #{RUBY_DESCRIPTION.split(' ')[0]} version #{RUBY_VERSION} on #{RUBY_PLATFORM} <<<<<"
|
data/ext/agoo/gqlintro.c
CHANGED
@@ -39,7 +39,7 @@ schema_query_type_resolve(gqlRef target, const char *fieldName, gqlKeyVal *args)
|
|
39
39
|
}
|
40
40
|
|
41
41
|
static int
|
42
|
-
create_schema_type(
|
42
|
+
create_schema_type(agooErr err) {
|
43
43
|
if (NULL == (schema_type = gql_type_create(err, "__Schema", NULL, -1, true, NULL)) ||
|
44
44
|
NULL == gql_type_field(err, schema_type, "types", type_type, NULL, true, true, true, schema_types_resolve) ||
|
45
45
|
NULL == gql_type_field(err, schema_type, "queryType", type_type, NULL, true, false, false, schema_query_type_resolve) ||
|
@@ -51,7 +51,7 @@ create_schema_type(Err err) {
|
|
51
51
|
}
|
52
52
|
schema_type->core = true;
|
53
53
|
|
54
|
-
return
|
54
|
+
return AGOO_ERR_OK;
|
55
55
|
}
|
56
56
|
|
57
57
|
// type __Type {
|
@@ -66,7 +66,7 @@ create_schema_type(Err err) {
|
|
66
66
|
// ofType: __Type
|
67
67
|
// }
|
68
68
|
static int
|
69
|
-
create_type_type(
|
69
|
+
create_type_type(agooErr err) {
|
70
70
|
gqlField fields = NULL;
|
71
71
|
gqlField enum_values = NULL;
|
72
72
|
gqlValue dv;
|
@@ -93,11 +93,11 @@ create_type_type(Err err) {
|
|
93
93
|
|
94
94
|
return err->code;
|
95
95
|
}
|
96
|
-
return
|
96
|
+
return AGOO_ERR_OK;
|
97
97
|
}
|
98
98
|
|
99
99
|
static int
|
100
|
-
create_type_kind_type(
|
100
|
+
create_type_kind_type(agooErr err) {
|
101
101
|
const char *choices[] = {
|
102
102
|
"SCALAR",
|
103
103
|
"OBJECT",
|
@@ -114,7 +114,7 @@ create_type_kind_type(Err err) {
|
|
114
114
|
type_kind_type = gql_enum_create(err, "__TypeKind", NULL, -1, true);
|
115
115
|
type_kind_type->core = true;
|
116
116
|
for (cp = choices; NULL != *cp; cp++) {
|
117
|
-
if (
|
117
|
+
if (AGOO_ERR_OK != gql_enum_append(err, type_kind_type, *cp, -1)) {
|
118
118
|
return err->code;
|
119
119
|
}
|
120
120
|
}
|
@@ -130,7 +130,7 @@ create_type_kind_type(Err err) {
|
|
130
130
|
// deprecationReason: String
|
131
131
|
// }
|
132
132
|
static int
|
133
|
-
create_field_type(
|
133
|
+
create_field_type(agooErr err) {
|
134
134
|
if (NULL == (field_type = gql_type_create(err, "__Field", NULL, -1, true, NULL)) ||
|
135
135
|
NULL == gql_type_field(err, field_type, "name", &gql_string_type, NULL, true, false, false, NULL) ||
|
136
136
|
NULL == gql_type_field(err, field_type, "description", &gql_string_type, NULL, false, false, false, NULL) ||
|
@@ -143,7 +143,7 @@ create_field_type(Err err) {
|
|
143
143
|
}
|
144
144
|
field_type->core = true;
|
145
145
|
|
146
|
-
return
|
146
|
+
return AGOO_ERR_OK;
|
147
147
|
}
|
148
148
|
|
149
149
|
// type __InputValue {
|
@@ -153,7 +153,7 @@ create_field_type(Err err) {
|
|
153
153
|
// defaultValue: String
|
154
154
|
// }
|
155
155
|
static int
|
156
|
-
create_input_type(
|
156
|
+
create_input_type(agooErr err) {
|
157
157
|
if (NULL == (input_value_type = gql_type_create(err, "__InputValue", NULL, -1, true, NULL)) ||
|
158
158
|
NULL == gql_type_field(err, input_value_type, "name", &gql_string_type, NULL, true, false, false, NULL) ||
|
159
159
|
NULL == gql_type_field(err, input_value_type, "description", &gql_string_type, NULL, false, false, false, NULL) ||
|
@@ -164,7 +164,7 @@ create_input_type(Err err) {
|
|
164
164
|
}
|
165
165
|
input_value_type->core = true;
|
166
166
|
|
167
|
-
return
|
167
|
+
return AGOO_ERR_OK;
|
168
168
|
}
|
169
169
|
|
170
170
|
// type __EnumValue {
|
@@ -174,7 +174,7 @@ create_input_type(Err err) {
|
|
174
174
|
// deprecationReason: String
|
175
175
|
// }
|
176
176
|
static int
|
177
|
-
create_enum_type(
|
177
|
+
create_enum_type(agooErr err) {
|
178
178
|
if (NULL == (enum_value_type = gql_type_create(err, "__EnumValue", NULL, -1, true, NULL)) ||
|
179
179
|
NULL == gql_type_field(err, enum_value_type, "name", &gql_string_type, NULL, true, false, false, NULL) ||
|
180
180
|
NULL == gql_type_field(err, enum_value_type, "description", &gql_string_type, NULL, false, false, false, NULL) ||
|
@@ -185,7 +185,7 @@ create_enum_type(Err err) {
|
|
185
185
|
}
|
186
186
|
enum_value_type->core = true;
|
187
187
|
|
188
|
-
return
|
188
|
+
return AGOO_ERR_OK;
|
189
189
|
}
|
190
190
|
|
191
191
|
// type __Directive {
|
@@ -195,7 +195,7 @@ create_enum_type(Err err) {
|
|
195
195
|
// args: [__InputValue!]!
|
196
196
|
// }
|
197
197
|
static int
|
198
|
-
create_directive_type(
|
198
|
+
create_directive_type(agooErr err) {
|
199
199
|
if (NULL == (directive_type = gql_type_create(err, "__Directive", NULL, -1, true, NULL)) ||
|
200
200
|
NULL == gql_type_field(err, directive_type, "name", &gql_string_type, NULL, true, false, false, NULL) ||
|
201
201
|
NULL == gql_type_field(err, directive_type, "description", &gql_string_type, NULL, false, false, false, NULL) ||
|
@@ -206,11 +206,11 @@ create_directive_type(Err err) {
|
|
206
206
|
}
|
207
207
|
directive_type->core = true;
|
208
208
|
|
209
|
-
return
|
209
|
+
return AGOO_ERR_OK;
|
210
210
|
}
|
211
211
|
|
212
212
|
static int
|
213
|
-
create_directive_location_type(
|
213
|
+
create_directive_location_type(agooErr err) {
|
214
214
|
const char *choices[] = {
|
215
215
|
"QUERY",
|
216
216
|
"MUTATION",
|
@@ -236,7 +236,7 @@ create_directive_location_type(Err err) {
|
|
236
236
|
directive_location_type = gql_enum_create(err, "__DirectiveLocation", NULL, -1, true);
|
237
237
|
directive_location_type->core = true;
|
238
238
|
for (cp = choices; NULL != *cp; cp++) {
|
239
|
-
if (
|
239
|
+
if (AGOO_ERR_OK != gql_enum_append(err, directive_location_type, *cp, -1)) {
|
240
240
|
return err->code;
|
241
241
|
}
|
242
242
|
}
|
@@ -244,72 +244,72 @@ create_directive_location_type(Err err) {
|
|
244
244
|
}
|
245
245
|
|
246
246
|
static int
|
247
|
-
create_dir_skip(
|
247
|
+
create_dir_skip(agooErr err) {
|
248
248
|
gqlDir dir = gql_directive_create(err, "skip", NULL, -1, true);
|
249
249
|
|
250
250
|
if (NULL == dir) {
|
251
251
|
return err->code;
|
252
252
|
}
|
253
|
-
if (
|
254
|
-
|
255
|
-
|
253
|
+
if (AGOO_ERR_OK != gql_directive_on(err, dir, "FIELD", -1) ||
|
254
|
+
AGOO_ERR_OK != gql_directive_on(err, dir, "FRAGMENT_SPREAD", -1) ||
|
255
|
+
AGOO_ERR_OK != gql_directive_on(err, dir, "INLINE_FRAGMENT", -1) ||
|
256
256
|
NULL == gql_dir_arg(err, dir, "if", "Boolean", NULL, -1, NULL, true)) {
|
257
257
|
|
258
258
|
return err->code;
|
259
259
|
}
|
260
|
-
return
|
260
|
+
return AGOO_ERR_OK;
|
261
261
|
}
|
262
262
|
|
263
263
|
static int
|
264
|
-
create_dir_include(
|
264
|
+
create_dir_include(agooErr err) {
|
265
265
|
gqlDir dir = gql_directive_create(err, "include", NULL, -1, true);
|
266
266
|
|
267
267
|
if (NULL == dir) {
|
268
268
|
return err->code;
|
269
269
|
}
|
270
|
-
if (
|
271
|
-
|
272
|
-
|
270
|
+
if (AGOO_ERR_OK != gql_directive_on(err, dir, "FIELD", -1) ||
|
271
|
+
AGOO_ERR_OK != gql_directive_on(err, dir, "FRAGMENT_SPREAD", -1) ||
|
272
|
+
AGOO_ERR_OK != gql_directive_on(err, dir, "INLINE_FRAGMENT", -1) ||
|
273
273
|
NULL == gql_dir_arg(err, dir, "if", "Boolean", NULL, -1, NULL, true)) {
|
274
274
|
|
275
275
|
return err->code;
|
276
276
|
}
|
277
|
-
return
|
277
|
+
return AGOO_ERR_OK;
|
278
278
|
}
|
279
279
|
|
280
280
|
static int
|
281
|
-
create_dir_deprecated(
|
281
|
+
create_dir_deprecated(agooErr err) {
|
282
282
|
gqlDir dir = gql_directive_create(err, "deprecated", NULL, -1, true);
|
283
283
|
gqlValue dv;
|
284
284
|
|
285
285
|
if (NULL == dir) {
|
286
286
|
return err->code;
|
287
287
|
}
|
288
|
-
if (
|
289
|
-
|
288
|
+
if (AGOO_ERR_OK != gql_directive_on(err, dir, "FIELD_DEFINITION", -1) ||
|
289
|
+
AGOO_ERR_OK != gql_directive_on(err, dir, "ENUM_VALUE", -1) ||
|
290
290
|
NULL == (dv = gql_string_create(err, "No longer supported", -1)) ||
|
291
291
|
NULL == gql_dir_arg(err, dir, "reason", "String", NULL, -1, dv, false)) {
|
292
292
|
|
293
293
|
return err->code;
|
294
294
|
}
|
295
|
-
return
|
295
|
+
return AGOO_ERR_OK;
|
296
296
|
}
|
297
297
|
|
298
298
|
int
|
299
|
-
gql_intro_init(
|
299
|
+
gql_intro_init(agooErr err) {
|
300
300
|
gqlField f;
|
301
301
|
|
302
|
-
if (
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
302
|
+
if (AGOO_ERR_OK != create_type_kind_type(err) ||
|
303
|
+
AGOO_ERR_OK != create_input_type(err) ||
|
304
|
+
AGOO_ERR_OK != create_type_type(err) ||
|
305
|
+
AGOO_ERR_OK != create_enum_type(err) ||
|
306
|
+
AGOO_ERR_OK != create_field_type(err) ||
|
307
|
+
AGOO_ERR_OK != create_directive_location_type(err) ||
|
308
|
+
AGOO_ERR_OK != create_directive_type(err) ||
|
309
|
+
AGOO_ERR_OK != create_schema_type(err) ||
|
310
|
+
AGOO_ERR_OK != create_dir_deprecated(err) ||
|
311
|
+
AGOO_ERR_OK != create_dir_include(err) ||
|
312
|
+
AGOO_ERR_OK != create_dir_skip(err)) {
|
313
313
|
|
314
314
|
return err->code;
|
315
315
|
}
|
@@ -329,5 +329,5 @@ gql_intro_init(Err err) {
|
|
329
329
|
break;
|
330
330
|
}
|
331
331
|
}
|
332
|
-
return
|
332
|
+
return AGOO_ERR_OK;
|
333
333
|
}
|
data/ext/agoo/gqlintro.h
CHANGED
data/ext/agoo/gqlvalue.c
CHANGED
@@ -12,9 +12,9 @@
|
|
12
12
|
static const char spaces[256] = "\n ";
|
13
13
|
|
14
14
|
// Int type
|
15
|
-
static
|
16
|
-
null_to_text(
|
17
|
-
return
|
15
|
+
static agooText
|
16
|
+
null_to_text(agooText text, gqlValue value, int indent, int depth) {
|
17
|
+
return agoo_text_append(text, "null", 4);
|
18
18
|
}
|
19
19
|
|
20
20
|
struct _gqlType gql_null_type = {
|
@@ -29,14 +29,14 @@ struct _gqlType gql_null_type = {
|
|
29
29
|
};
|
30
30
|
|
31
31
|
// Int type
|
32
|
-
static
|
33
|
-
int_to_text(
|
32
|
+
static agooText
|
33
|
+
int_to_text(agooText text, gqlValue value, int indent, int depth) {
|
34
34
|
char num[32];
|
35
35
|
int cnt;
|
36
36
|
|
37
37
|
cnt = snprintf(num, sizeof(num), "%lld", (long long)value->i);
|
38
38
|
|
39
|
-
return
|
39
|
+
return agoo_text_append(text, num, cnt);
|
40
40
|
}
|
41
41
|
|
42
42
|
struct _gqlType gql_int_type = {
|
@@ -51,14 +51,14 @@ struct _gqlType gql_int_type = {
|
|
51
51
|
};
|
52
52
|
|
53
53
|
// I64 type, add on type.
|
54
|
-
static
|
55
|
-
i64_to_text(
|
54
|
+
static agooText
|
55
|
+
i64_to_text(agooText text, gqlValue value, int indent, int depth) {
|
56
56
|
char num[32];
|
57
57
|
int cnt;
|
58
58
|
|
59
59
|
cnt = snprintf(num, sizeof(num), "%lld", (long long)value->i64);
|
60
60
|
|
61
|
-
return
|
61
|
+
return agoo_text_append(text, num, cnt);
|
62
62
|
}
|
63
63
|
|
64
64
|
struct _gqlType gql_i64_type = {
|
@@ -78,7 +78,7 @@ string_destroy(gqlValue value) {
|
|
78
78
|
free((char*)value->str);
|
79
79
|
}
|
80
80
|
|
81
|
-
static
|
81
|
+
static agooText string_to_text(agooText text, gqlValue value, int indent, int depth);
|
82
82
|
|
83
83
|
struct _gqlType gql_string_type = {
|
84
84
|
.name = "String",
|
@@ -103,29 +103,29 @@ struct _gqlType gql_str16_type = { // unregistered
|
|
103
103
|
.to_json = string_to_text,
|
104
104
|
};
|
105
105
|
|
106
|
-
static
|
107
|
-
string_to_text(
|
106
|
+
static agooText
|
107
|
+
string_to_text(agooText text, gqlValue value, int indent, int depth) {
|
108
108
|
if (&gql_str16_type == value->type) {
|
109
|
-
text =
|
110
|
-
text =
|
111
|
-
text =
|
109
|
+
text = agoo_text_append(text, "\"", 1);
|
110
|
+
text = agoo_text_append(text, value->str16, -1);
|
111
|
+
text = agoo_text_append(text, "\"", 1);
|
112
112
|
} else if (NULL == value->str) {
|
113
|
-
text =
|
113
|
+
text = agoo_text_append(text, "null", 4);
|
114
114
|
} else {
|
115
|
-
text =
|
116
|
-
text =
|
117
|
-
text =
|
115
|
+
text = agoo_text_append(text, "\"", 1);
|
116
|
+
text = agoo_text_append(text, value->str, -1);
|
117
|
+
text = agoo_text_append(text, "\"", 1);
|
118
118
|
}
|
119
119
|
return text;
|
120
120
|
}
|
121
121
|
|
122
122
|
// Bool type
|
123
|
-
static
|
124
|
-
bool_to_text(
|
123
|
+
static agooText
|
124
|
+
bool_to_text(agooText text, gqlValue value, int indent, int depth) {
|
125
125
|
if (value->b) {
|
126
|
-
text =
|
126
|
+
text = agoo_text_append(text, "true", 4);
|
127
127
|
} else {
|
128
|
-
text =
|
128
|
+
text = agoo_text_append(text, "false", 5);
|
129
129
|
}
|
130
130
|
return text;
|
131
131
|
}
|
@@ -142,14 +142,14 @@ struct _gqlType gql_bool_type = {
|
|
142
142
|
};
|
143
143
|
|
144
144
|
// Float type
|
145
|
-
static
|
146
|
-
float_to_text(
|
145
|
+
static agooText
|
146
|
+
float_to_text(agooText text, gqlValue value, int indent, int depth) {
|
147
147
|
char num[32];
|
148
148
|
int cnt;
|
149
149
|
|
150
150
|
cnt = snprintf(num, sizeof(num), "%g", value->f);
|
151
151
|
|
152
|
-
return
|
152
|
+
return agoo_text_append(text, num, cnt);
|
153
153
|
}
|
154
154
|
|
155
155
|
struct _gqlType gql_float_type = {
|
@@ -201,7 +201,7 @@ read_zone(const char *s, int *vp) {
|
|
201
201
|
}
|
202
202
|
|
203
203
|
static int64_t
|
204
|
-
time_parse(
|
204
|
+
time_parse(agooErr err, const char *str, int len) {
|
205
205
|
const char *s = str;
|
206
206
|
const char *end;
|
207
207
|
struct tm tm;
|
@@ -214,7 +214,7 @@ time_parse(Err err, const char *str, int len) {
|
|
214
214
|
len = (int)strlen(str);
|
215
215
|
}
|
216
216
|
if (len < 10 || 36 < len) {
|
217
|
-
|
217
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
218
218
|
return 0;
|
219
219
|
}
|
220
220
|
end = str + len;
|
@@ -224,7 +224,7 @@ time_parse(Err err, const char *str, int len) {
|
|
224
224
|
neg = true;
|
225
225
|
}
|
226
226
|
if (NULL == (s = read_num(s, 4, &tm.tm_year))) {
|
227
|
-
|
227
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
228
228
|
return 0;
|
229
229
|
}
|
230
230
|
if (neg) {
|
@@ -233,24 +233,24 @@ time_parse(Err err, const char *str, int len) {
|
|
233
233
|
}
|
234
234
|
tm.tm_year -= 1900;
|
235
235
|
if ('-' != *s) {
|
236
|
-
|
236
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
237
237
|
return 0;
|
238
238
|
}
|
239
239
|
s++;
|
240
240
|
|
241
241
|
if (NULL == (s = read_num(s, 2, &tm.tm_mon))) {
|
242
|
-
|
242
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
243
243
|
return 0;
|
244
244
|
}
|
245
245
|
tm.tm_mon--;
|
246
246
|
if ('-' != *s) {
|
247
|
-
|
247
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
248
248
|
return 0;
|
249
249
|
}
|
250
250
|
s++;
|
251
251
|
|
252
252
|
if (NULL == (s = read_num(s, 2, &tm.tm_mday))) {
|
253
|
-
|
253
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
254
254
|
return 0;
|
255
255
|
}
|
256
256
|
|
@@ -263,7 +263,7 @@ time_parse(Err err, const char *str, int len) {
|
|
263
263
|
if (s == end) {
|
264
264
|
return (int64_t)timegm(&tm) * 1000000000LL;
|
265
265
|
}
|
266
|
-
|
266
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
267
267
|
return 0;
|
268
268
|
case '-':
|
269
269
|
neg = true;
|
@@ -272,7 +272,7 @@ time_parse(Err err, const char *str, int len) {
|
|
272
272
|
int v = 0;
|
273
273
|
|
274
274
|
if (NULL == (s = read_zone(s, &v))) {
|
275
|
-
|
275
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
276
276
|
return 0;
|
277
277
|
}
|
278
278
|
if (neg) {
|
@@ -281,41 +281,41 @@ time_parse(Err err, const char *str, int len) {
|
|
281
281
|
if (s == end) {
|
282
282
|
return ((int64_t)timegm(&tm) - (int64_t)v) * 1000000000LL;
|
283
283
|
}
|
284
|
-
|
284
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
285
285
|
return 0;
|
286
286
|
}
|
287
287
|
case 'T':
|
288
288
|
break;
|
289
289
|
default:
|
290
|
-
|
290
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
291
291
|
return 0;
|
292
292
|
}
|
293
293
|
// T encountered, need space for time and zone
|
294
294
|
if (end - s < 9) {
|
295
|
-
|
295
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
296
296
|
return 0;
|
297
297
|
}
|
298
298
|
if (NULL == (s = read_num(s, 2, &tm.tm_hour))) {
|
299
299
|
return 0;
|
300
300
|
}
|
301
301
|
if (':' != *s) {
|
302
|
-
|
302
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
303
303
|
return 0;
|
304
304
|
}
|
305
305
|
s++;
|
306
306
|
|
307
307
|
if (NULL == (s = read_num(s, 2, &tm.tm_min))) {
|
308
|
-
|
308
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
309
309
|
return 0;
|
310
310
|
}
|
311
311
|
if (':' != *s) {
|
312
|
-
|
312
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
313
313
|
return 0;
|
314
314
|
}
|
315
315
|
s++;
|
316
316
|
|
317
317
|
if (NULL == (s = read_num(s, 2, &tm.tm_sec))) {
|
318
|
-
|
318
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
319
319
|
return 0;
|
320
320
|
}
|
321
321
|
switch (*s++) {
|
@@ -323,7 +323,7 @@ time_parse(Err err, const char *str, int len) {
|
|
323
323
|
if (s == end) {
|
324
324
|
return (int64_t)timegm(&tm) * 1000000000LL;
|
325
325
|
}
|
326
|
-
|
326
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
327
327
|
return 0;
|
328
328
|
case '-':
|
329
329
|
neg = true;
|
@@ -332,11 +332,11 @@ time_parse(Err err, const char *str, int len) {
|
|
332
332
|
int v = 0;
|
333
333
|
|
334
334
|
if (end - s < 5) {
|
335
|
-
|
335
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
336
336
|
return 0;
|
337
337
|
}
|
338
338
|
if (NULL == (s = read_zone(s, &v))) {
|
339
|
-
|
339
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
340
340
|
return 0;
|
341
341
|
}
|
342
342
|
if (neg) {
|
@@ -345,18 +345,18 @@ time_parse(Err err, const char *str, int len) {
|
|
345
345
|
if (s == end) {
|
346
346
|
return ((int64_t)timegm(&tm) - (int64_t)v) * 1000000000LL;
|
347
347
|
}
|
348
|
-
|
348
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
349
349
|
return 0;
|
350
350
|
}
|
351
351
|
case '.':
|
352
352
|
break;
|
353
353
|
default:
|
354
|
-
|
354
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
355
355
|
return 0;
|
356
356
|
}
|
357
357
|
for (; 0 < i; i--, s++) {
|
358
358
|
if (end <= s) {
|
359
|
-
|
359
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
360
360
|
return 0;
|
361
361
|
}
|
362
362
|
if ('0' <= *s && *s <= '9') {
|
@@ -373,7 +373,7 @@ time_parse(Err err, const char *str, int len) {
|
|
373
373
|
if (s == end) {
|
374
374
|
break;
|
375
375
|
}
|
376
|
-
|
376
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
377
377
|
return 0;
|
378
378
|
case '-':
|
379
379
|
neg = true;
|
@@ -382,11 +382,11 @@ time_parse(Err err, const char *str, int len) {
|
|
382
382
|
int v = 0;
|
383
383
|
|
384
384
|
if (end - s < 5) {
|
385
|
-
|
385
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
386
386
|
return 0;
|
387
387
|
}
|
388
388
|
if (NULL == (s = read_zone(s, &v))) {
|
389
|
-
|
389
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
390
390
|
return 0;
|
391
391
|
}
|
392
392
|
if (neg) {
|
@@ -395,12 +395,12 @@ time_parse(Err err, const char *str, int len) {
|
|
395
395
|
if (s == end) {
|
396
396
|
return ((int64_t)timegm(&tm) - (int64_t)v) * 1000000000LL + nsecs;
|
397
397
|
}
|
398
|
-
|
398
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
399
399
|
return 0;
|
400
400
|
}
|
401
401
|
default:
|
402
402
|
if (s != end) {
|
403
|
-
|
403
|
+
agoo_err_set(err, AGOO_ERR_PARSE, "Invalid time format.");
|
404
404
|
return 0;
|
405
405
|
}
|
406
406
|
}
|
@@ -410,8 +410,8 @@ time_parse(Err err, const char *str, int len) {
|
|
410
410
|
return secs - nsecs;
|
411
411
|
}
|
412
412
|
|
413
|
-
static
|
414
|
-
time_to_text(
|
413
|
+
static agooText
|
414
|
+
time_to_text(agooText text, gqlValue value, int indent, int depth) {
|
415
415
|
char str[64];
|
416
416
|
int cnt;
|
417
417
|
struct tm tm;
|
@@ -427,7 +427,7 @@ time_to_text(Text text, gqlValue value, int indent, int depth) {
|
|
427
427
|
1900 + tm.tm_year, 1 + tm.tm_mon, tm.tm_mday,
|
428
428
|
tm.tm_hour, tm.tm_min, tm.tm_sec, (long)nsecs);
|
429
429
|
|
430
|
-
return
|
430
|
+
return agoo_text_append(text, str, cnt);
|
431
431
|
}
|
432
432
|
|
433
433
|
struct _gqlType gql_time_type = {
|
@@ -458,7 +458,7 @@ hexVal(int c) {
|
|
458
458
|
|
459
459
|
// 123e4567-e89b-12d3-a456-426655440000
|
460
460
|
static int
|
461
|
-
parse_uuid(
|
461
|
+
parse_uuid(agooErr err, const char *str, int len, uint64_t *hip, uint64_t *lop) {
|
462
462
|
uint64_t hi = 0;
|
463
463
|
uint64_t lo = 0;
|
464
464
|
int i;
|
@@ -468,50 +468,50 @@ parse_uuid(Err err, const char *str, int len, uint64_t *hip, uint64_t *lop) {
|
|
468
468
|
len = (int)strlen(str);
|
469
469
|
}
|
470
470
|
if (36 != len || '-' != str[8] || '-' != str[13] || '-' != str[18] || '-' != str[23]) {
|
471
|
-
return
|
471
|
+
return agoo_err_set(err, AGOO_ERR_PARSE, "not UUID format");
|
472
472
|
}
|
473
473
|
for (i = 0; i < 8; i++, str++) {
|
474
474
|
if (0 > (n = hexVal(*str))) {
|
475
|
-
return
|
475
|
+
return agoo_err_set(err, AGOO_ERR_PARSE, "not UUID format");
|
476
476
|
}
|
477
477
|
hi = (hi << 4) + n;
|
478
478
|
}
|
479
479
|
str++;
|
480
480
|
for (i = 0; i < 4; i++, str++) {
|
481
481
|
if (0 > (n = hexVal(*str))) {
|
482
|
-
return
|
482
|
+
return agoo_err_set(err, AGOO_ERR_PARSE, "not UUID format");
|
483
483
|
}
|
484
484
|
hi = (hi << 4) + n;
|
485
485
|
}
|
486
486
|
str++;
|
487
487
|
for (i = 0; i < 4; i++, str++) {
|
488
488
|
if (0 > (n = hexVal(*str))) {
|
489
|
-
return
|
489
|
+
return agoo_err_set(err, AGOO_ERR_PARSE, "not UUID format");
|
490
490
|
}
|
491
491
|
hi = (hi << 4) + n;
|
492
492
|
}
|
493
493
|
str++;
|
494
494
|
for (i = 0; i < 4; i++, str++) {
|
495
495
|
if (0 > (n = hexVal(*str))) {
|
496
|
-
return
|
496
|
+
return agoo_err_set(err, AGOO_ERR_PARSE, "not UUID format");
|
497
497
|
}
|
498
498
|
lo = (lo << 4) + n;
|
499
499
|
}
|
500
500
|
str++;
|
501
501
|
for (i = 0; i < 12; i++, str++) {
|
502
502
|
if (0 > (n = hexVal(*str))) {
|
503
|
-
return
|
503
|
+
return agoo_err_set(err, AGOO_ERR_PARSE, "not UUID format");
|
504
504
|
}
|
505
505
|
lo = (lo << 4) + n;
|
506
506
|
}
|
507
507
|
*hip = hi;
|
508
508
|
*lop = lo;
|
509
509
|
|
510
|
-
return
|
510
|
+
return AGOO_ERR_OK;
|
511
511
|
}
|
512
512
|
|
513
|
-
static
|
514
|
-
uuid_to_text(
|
513
|
+
static agooText
|
514
|
+
uuid_to_text(agooText text, gqlValue value, int indent, int depth) {
|
515
515
|
char str[64];
|
516
516
|
int cnt = sprintf(str, "\"%08lx-%04lx-%04lx-%04lx-%012lx\"",
|
517
517
|
(unsigned long)(value->uuid.hi >> 32),
|
@@ -520,7 +520,7 @@ uuid_to_text(Text text, gqlValue value, int indent, int depth) {
|
|
520
520
|
(unsigned long)(value->uuid.lo >> 48),
|
521
521
|
(unsigned long)(value->uuid.lo & 0x0000FFFFFFFFFFFFUL));
|
522
522
|
|
523
|
-
return
|
523
|
+
return agoo_text_append(text, str, cnt);
|
524
524
|
}
|
525
525
|
|
526
526
|
struct _gqlType gql_uuid_type = {
|
@@ -540,14 +540,14 @@ url_destroy(gqlValue value) {
|
|
540
540
|
free((char*)value->url);
|
541
541
|
}
|
542
542
|
|
543
|
-
static
|
544
|
-
url_to_text(
|
543
|
+
static agooText
|
544
|
+
url_to_text(agooText text, gqlValue value, int indent, int depth) {
|
545
545
|
if (NULL == value->url) {
|
546
|
-
return
|
546
|
+
return agoo_text_append(text, "null", 4);
|
547
547
|
}
|
548
|
-
text =
|
549
|
-
text =
|
550
|
-
text =
|
548
|
+
text = agoo_text_append(text, "\"", 1);
|
549
|
+
text = agoo_text_append(text, value->url, -1);
|
550
|
+
text = agoo_text_append(text, "\"", 1);
|
551
551
|
|
552
552
|
return text;
|
553
553
|
}
|
@@ -576,8 +576,8 @@ list_destroy(gqlValue value) {
|
|
576
576
|
}
|
577
577
|
}
|
578
578
|
|
579
|
-
static
|
580
|
-
list_to_json(
|
579
|
+
static agooText
|
580
|
+
list_to_json(agooText text, gqlValue value, int indent, int depth) {
|
581
581
|
int i = indent * depth;
|
582
582
|
int i2 = i + indent;
|
583
583
|
int d2 = depth + 1;
|
@@ -591,18 +591,18 @@ list_to_json(Text text, gqlValue value, int indent, int depth) {
|
|
591
591
|
i2 = sizeof(spaces) - 1;
|
592
592
|
i = i2 - indent;
|
593
593
|
}
|
594
|
-
text =
|
594
|
+
text = agoo_text_append(text, "[", 1);
|
595
595
|
for (link = value->members; NULL != link; link = link->next) {
|
596
|
-
text =
|
596
|
+
text = agoo_text_append(text, spaces, i2);
|
597
597
|
text = link->value->type->to_json(text, link->value, indent, d2);
|
598
598
|
if (NULL != link->next) {
|
599
|
-
text =
|
599
|
+
text = agoo_text_append(text, ",", 1);
|
600
600
|
}
|
601
601
|
}
|
602
602
|
if (0 < indent) {
|
603
|
-
text =
|
603
|
+
text = agoo_text_append(text, spaces, i);
|
604
604
|
}
|
605
|
-
text =
|
605
|
+
text = agoo_text_append(text, "]", 1);
|
606
606
|
|
607
607
|
return text;
|
608
608
|
}
|
@@ -632,8 +632,8 @@ object_destroy(gqlValue value) {
|
|
632
632
|
}
|
633
633
|
}
|
634
634
|
|
635
|
-
static
|
636
|
-
object_to_json(
|
635
|
+
static agooText
|
636
|
+
object_to_json(agooText text, gqlValue value, int indent, int depth) {
|
637
637
|
int i = indent * depth;
|
638
638
|
int i2 = i + indent;
|
639
639
|
int d2 = depth + 1;
|
@@ -647,25 +647,25 @@ object_to_json(Text text, gqlValue value, int indent, int depth) {
|
|
647
647
|
i2 = sizeof(spaces) - 1;
|
648
648
|
i = i2 - indent;
|
649
649
|
}
|
650
|
-
text =
|
650
|
+
text = agoo_text_append(text, "{", 1);
|
651
651
|
for (link = value->members; NULL != link; link = link->next) {
|
652
|
-
text =
|
653
|
-
text =
|
654
|
-
text =
|
652
|
+
text = agoo_text_append(text, spaces, i2);
|
653
|
+
text = agoo_text_append(text, "\"", 1);
|
654
|
+
text = agoo_text_append(text, link->key, -1);
|
655
655
|
if (0 < indent) {
|
656
|
-
text =
|
656
|
+
text = agoo_text_append(text, "\": ", 3);
|
657
657
|
} else {
|
658
|
-
text =
|
658
|
+
text = agoo_text_append(text, "\":", 2);
|
659
659
|
}
|
660
660
|
text = link->value->type->to_json(text, link->value, indent, d2);
|
661
661
|
if (NULL != link->next) {
|
662
|
-
text =
|
662
|
+
text = agoo_text_append(text, ",", 1);
|
663
663
|
}
|
664
664
|
}
|
665
665
|
if (0 < indent) {
|
666
|
-
text =
|
666
|
+
text = agoo_text_append(text, spaces, i);
|
667
667
|
}
|
668
|
-
text =
|
668
|
+
text = agoo_text_append(text, "}", 1);
|
669
669
|
|
670
670
|
return text;
|
671
671
|
}
|
@@ -692,18 +692,18 @@ gql_value_destroy(gqlValue value) {
|
|
692
692
|
}
|
693
693
|
|
694
694
|
int
|
695
|
-
gql_value_init(
|
696
|
-
if (
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
702
|
-
|
703
|
-
|
695
|
+
gql_value_init(agooErr err) {
|
696
|
+
if (AGOO_ERR_OK != gql_type_set(err, &gql_int_type) ||
|
697
|
+
AGOO_ERR_OK != gql_type_set(err, &gql_i64_type) ||
|
698
|
+
AGOO_ERR_OK != gql_type_set(err, &gql_bool_type) ||
|
699
|
+
AGOO_ERR_OK != gql_type_set(err, &gql_float_type) ||
|
700
|
+
AGOO_ERR_OK != gql_type_set(err, &gql_time_type) ||
|
701
|
+
AGOO_ERR_OK != gql_type_set(err, &gql_uuid_type) ||
|
702
|
+
AGOO_ERR_OK != gql_type_set(err, &gql_url_type) ||
|
703
|
+
AGOO_ERR_OK != gql_type_set(err, &gql_string_type)) {
|
704
704
|
return err->code;
|
705
705
|
}
|
706
|
-
return
|
706
|
+
return AGOO_ERR_OK;
|
707
707
|
}
|
708
708
|
|
709
709
|
/// set functions /////////////////////////////////////////////////////////////
|
@@ -738,7 +738,7 @@ gql_string_set(gqlValue value, const char *str, int len) {
|
|
738
738
|
}
|
739
739
|
|
740
740
|
int
|
741
|
-
gql_url_set(
|
741
|
+
gql_url_set(agooErr err, gqlValue value, const char *url, int len) {
|
742
742
|
value->type = &gql_url_type;
|
743
743
|
if (NULL == url) {
|
744
744
|
value->url = NULL;
|
@@ -748,7 +748,7 @@ gql_url_set(Err err, gqlValue value, const char *url, int len) {
|
|
748
748
|
}
|
749
749
|
value->url = strndup(url, len);
|
750
750
|
}
|
751
|
-
return
|
751
|
+
return AGOO_ERR_OK;
|
752
752
|
}
|
753
753
|
|
754
754
|
void
|
@@ -767,7 +767,7 @@ gql_time_set(gqlValue value, int64_t t) {
|
|
767
767
|
}
|
768
768
|
|
769
769
|
int
|
770
|
-
gql_time_str_set(
|
770
|
+
gql_time_str_set(agooErr err, gqlValue value, const char *str, int len) {
|
771
771
|
if (0 >= len) {
|
772
772
|
len = (int)strlen(str);
|
773
773
|
}
|
@@ -783,27 +783,27 @@ gql_uuid_set(gqlValue value, uint64_t hi, uint64_t lo) {
|
|
783
783
|
}
|
784
784
|
|
785
785
|
int
|
786
|
-
gql_uuid_str_set(
|
786
|
+
gql_uuid_str_set(agooErr err, gqlValue value, const char *str, int len) {
|
787
787
|
uint64_t hi = 0;
|
788
788
|
uint64_t lo = 0;
|
789
789
|
|
790
|
-
if (
|
790
|
+
if (AGOO_ERR_OK != parse_uuid(err, str, len, &hi, &lo)) {
|
791
791
|
return err->code;
|
792
792
|
}
|
793
793
|
value->uuid.hi = hi;
|
794
794
|
value->uuid.lo = lo;
|
795
795
|
|
796
|
-
return
|
796
|
+
return AGOO_ERR_OK;
|
797
797
|
}
|
798
798
|
|
799
799
|
extern void gql_null_set(gqlValue value);
|
800
800
|
|
801
801
|
gqlLink
|
802
|
-
link_create(
|
802
|
+
link_create(agooErr err, gqlValue item) {
|
803
803
|
gqlLink link = (gqlLink)malloc(sizeof(struct _gqlLink));
|
804
804
|
|
805
805
|
if (NULL == link) {
|
806
|
-
|
806
|
+
agoo_err_set(err, AGOO_ERR_MEMORY, "Failed to allocation memory for a list link.");
|
807
807
|
} else {
|
808
808
|
DEBUG_ALLOC(mem_graphql_link, link);
|
809
809
|
link->next = NULL;
|
@@ -814,7 +814,7 @@ link_create(Err err, gqlValue item) {
|
|
814
814
|
}
|
815
815
|
|
816
816
|
int
|
817
|
-
gql_list_append(
|
817
|
+
gql_list_append(agooErr err, gqlValue list, gqlValue item) {
|
818
818
|
gqlLink link = link_create(err, item);
|
819
819
|
|
820
820
|
if (NULL != link) {
|
@@ -828,22 +828,22 @@ gql_list_append(Err err, gqlValue list, gqlValue item) {
|
|
828
828
|
last->next = link;
|
829
829
|
}
|
830
830
|
}
|
831
|
-
return
|
831
|
+
return AGOO_ERR_OK;
|
832
832
|
}
|
833
833
|
|
834
834
|
int
|
835
|
-
gql_list_prepend(
|
835
|
+
gql_list_prepend(agooErr err, gqlValue list, gqlValue item) {
|
836
836
|
gqlLink link = link_create(err, item);
|
837
837
|
|
838
838
|
if (NULL != link) {
|
839
839
|
link->next = list->members;
|
840
840
|
list->members = link;
|
841
841
|
}
|
842
|
-
return
|
842
|
+
return AGOO_ERR_OK;
|
843
843
|
}
|
844
844
|
|
845
845
|
int
|
846
|
-
gql_object_set(
|
846
|
+
gql_object_set(agooErr err, gqlValue obj, const char *key, gqlValue item) {
|
847
847
|
gqlLink link = link_create(err, item);
|
848
848
|
|
849
849
|
if (NULL != link) {
|
@@ -859,7 +859,7 @@ gql_object_set(Err err, gqlValue obj, const char *key, gqlValue item) {
|
|
859
859
|
last->next = link;
|
860
860
|
}
|
861
861
|
}
|
862
|
-
return
|
862
|
+
return AGOO_ERR_OK;
|
863
863
|
}
|
864
864
|
|
865
865
|
/// create functions //////////////////////////////////////////////////////////
|
@@ -877,7 +877,7 @@ value_create(gqlType type) {
|
|
877
877
|
}
|
878
878
|
|
879
879
|
gqlValue
|
880
|
-
gql_int_create(
|
880
|
+
gql_int_create(agooErr err, int32_t i) {
|
881
881
|
gqlValue v = value_create(&gql_int_type);
|
882
882
|
|
883
883
|
if (NULL != v) {
|
@@ -887,7 +887,7 @@ gql_int_create(Err err, int32_t i) {
|
|
887
887
|
}
|
888
888
|
|
889
889
|
gqlValue
|
890
|
-
gql_i64_create(
|
890
|
+
gql_i64_create(agooErr err, int64_t i) {
|
891
891
|
gqlValue v = value_create(&gql_i64_type);
|
892
892
|
|
893
893
|
if (NULL != v) {
|
@@ -897,7 +897,7 @@ gql_i64_create(Err err, int64_t i) {
|
|
897
897
|
}
|
898
898
|
|
899
899
|
gqlValue
|
900
|
-
gql_string_create(
|
900
|
+
gql_string_create(agooErr err, const char *str, int len) {
|
901
901
|
gqlValue v;
|
902
902
|
|
903
903
|
if (0 >= len) {
|
@@ -917,7 +917,7 @@ gql_string_create(Err err, const char *str, int len) {
|
|
917
917
|
}
|
918
918
|
|
919
919
|
gqlValue
|
920
|
-
gql_url_create(
|
920
|
+
gql_url_create(agooErr err, const char *url, int len) {
|
921
921
|
gqlValue v = value_create(&gql_url_type);
|
922
922
|
|
923
923
|
if (0 >= len) {
|
@@ -930,7 +930,7 @@ gql_url_create(Err err, const char *url, int len) {
|
|
930
930
|
}
|
931
931
|
|
932
932
|
gqlValue
|
933
|
-
gql_bool_create(
|
933
|
+
gql_bool_create(agooErr err, bool b) {
|
934
934
|
gqlValue v = value_create(&gql_bool_type);
|
935
935
|
|
936
936
|
if (NULL != v) {
|
@@ -940,7 +940,7 @@ gql_bool_create(Err err, bool b) {
|
|
940
940
|
}
|
941
941
|
|
942
942
|
gqlValue
|
943
|
-
gql_float_create(
|
943
|
+
gql_float_create(agooErr err, double f) {
|
944
944
|
gqlValue v = value_create(&gql_float_type);
|
945
945
|
|
946
946
|
if (NULL != v) {
|
@@ -950,7 +950,7 @@ gql_float_create(Err err, double f) {
|
|
950
950
|
}
|
951
951
|
|
952
952
|
gqlValue
|
953
|
-
gql_time_create(
|
953
|
+
gql_time_create(agooErr err, int64_t t) {
|
954
954
|
gqlValue v = value_create(&gql_time_type);
|
955
955
|
|
956
956
|
if (NULL != v) {
|
@@ -960,7 +960,7 @@ gql_time_create(Err err, int64_t t) {
|
|
960
960
|
}
|
961
961
|
|
962
962
|
gqlValue
|
963
|
-
gql_time_str_create(
|
963
|
+
gql_time_str_create(agooErr err, const char *str, int len) {
|
964
964
|
gqlValue v = value_create(&gql_time_type);
|
965
965
|
|
966
966
|
if (NULL != v) {
|
@@ -973,7 +973,7 @@ gql_time_str_create(Err err, const char *str, int len) {
|
|
973
973
|
}
|
974
974
|
|
975
975
|
gqlValue
|
976
|
-
gql_uuid_create(
|
976
|
+
gql_uuid_create(agooErr err, uint64_t hi, uint64_t lo) {
|
977
977
|
gqlValue v = value_create(&gql_uuid_type);
|
978
978
|
|
979
979
|
if (NULL != v) {
|
@@ -985,12 +985,12 @@ gql_uuid_create(Err err, uint64_t hi, uint64_t lo) {
|
|
985
985
|
|
986
986
|
// 123e4567-e89b-12d3-a456-426655440000
|
987
987
|
gqlValue
|
988
|
-
gql_uuid_str_create(
|
988
|
+
gql_uuid_str_create(agooErr err, const char *str, int len) {
|
989
989
|
uint64_t hi = 0;
|
990
990
|
uint64_t lo = 0;
|
991
991
|
gqlValue v;
|
992
992
|
|
993
|
-
if (
|
993
|
+
if (AGOO_ERR_OK != parse_uuid(err, str, len, &hi, &lo)) {
|
994
994
|
return NULL;
|
995
995
|
}
|
996
996
|
if (NULL != (v = value_create(&gql_uuid_type))) {
|
@@ -1001,14 +1001,14 @@ gql_uuid_str_create(Err err, const char *str, int len) {
|
|
1001
1001
|
}
|
1002
1002
|
|
1003
1003
|
gqlValue
|
1004
|
-
gql_null_create(
|
1004
|
+
gql_null_create(agooErr err) {
|
1005
1005
|
gqlValue v = value_create(&gql_null_type);
|
1006
1006
|
|
1007
1007
|
return v;
|
1008
1008
|
}
|
1009
1009
|
|
1010
1010
|
gqlValue
|
1011
|
-
gql_list_create(
|
1011
|
+
gql_list_create(agooErr err, gqlType itemType) {
|
1012
1012
|
gqlValue v = value_create(&list_type);
|
1013
1013
|
|
1014
1014
|
if (NULL != v) {
|
@@ -1019,7 +1019,7 @@ gql_list_create(Err err, gqlType itemType) {
|
|
1019
1019
|
}
|
1020
1020
|
|
1021
1021
|
gqlValue
|
1022
|
-
gql_object_create(
|
1022
|
+
gql_object_create(agooErr err) {
|
1023
1023
|
gqlValue v = value_create(&object_type);
|
1024
1024
|
|
1025
1025
|
if (NULL != v) {
|
@@ -1029,7 +1029,7 @@ gql_object_create(Err err) {
|
|
1029
1029
|
return v;
|
1030
1030
|
}
|
1031
1031
|
|
1032
|
-
|
1033
|
-
gql_value_json(
|
1032
|
+
agooText
|
1033
|
+
gql_value_json(agooText text, gqlValue value, int indent, int depth) {
|
1034
1034
|
return value->type->to_json(text, value, indent, depth);
|
1035
1035
|
}
|