Rev | Line | |
---|
[1] | 1 | #include "api.h"
|
---|
| 2 | #include <stdlib.h>
|
---|
| 3 | #include "string.h"
|
---|
| 4 | #include "JSON.h"
|
---|
| 5 | #include "commands.h"
|
---|
| 6 |
|
---|
| 7 | char *cookie_out;
|
---|
| 8 |
|
---|
| 9 | void json_parse(request_typDef *json_request, char *json_response, uint16_t json_response_len, char *response_cookie)
|
---|
| 10 | {
|
---|
| 11 | json_config_t config;
|
---|
| 12 | config.json_malloc = malloc;
|
---|
| 13 | config.json_free = free;
|
---|
| 14 |
|
---|
| 15 | json_size_t tokens_count = 256;
|
---|
| 16 | json_parser_t parser;
|
---|
| 17 | json_token_t *tokens = config.json_malloc(sizeof(json_token_t) * tokens_count);
|
---|
| 18 | if(tokens == NULL) return;
|
---|
| 19 |
|
---|
| 20 | json_init_parser(&parser, &config);
|
---|
| 21 | json_parse_tokens(&parser, json_request->json_data, json_request->json_len, tokens, &tokens_count); // tokens_count - âîçâðàùàåòñÿ êîëëè÷åñòâî íàéäåííûõ òîêåíîâ
|
---|
| 22 |
|
---|
| 23 | json_tokens_data_t json_token_data = {0};
|
---|
| 24 | json_token_data.remote_addr = json_request->remote_addr;
|
---|
| 25 | json_token_data.json_data = json_request->json_data;
|
---|
| 26 | json_token_data.tokens = tokens;
|
---|
| 27 | json_token_data.tokens_count = tokens_count;
|
---|
| 28 | json_token_data.current_token = 0;
|
---|
| 29 |
|
---|
| 30 | json_response_t response = {0};
|
---|
| 31 | response.json_data = json_response;
|
---|
| 32 | response.json_data_length = json_response_len;
|
---|
| 33 |
|
---|
| 34 | cookie_out = response_cookie;
|
---|
| 35 | execute_cmd(&json_token_data, &response, json_request->cookie, cookie_out);
|
---|
| 36 | config.json_free(tokens);
|
---|
| 37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.