Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 89 lines (72 sloc) 2.696 kb
cd8c974 @residuum First commit.
authored
1 #include "m_pd.h"
2 #include <stdio.h>
3 #include <stdlib.h>
00e39e9 @residuum Better check for numeric value of string (thanks, Mathieu Bouchard);
authored
4 #include <ctype.h>
cd8c974 @residuum First commit.
authored
5 #include <string.h>
6 #include <curl/curl.h>
7 #include <json/json.h>
fc6e108 @residuum Removed blocking via pthread.
authored
8 #include <pthread.h>
cd8c974 @residuum First commit.
authored
9
5854491 @residuum rest-json is now working again.
authored
10 #define LIBRARY_VERSION "0.7"
cd8c974 @residuum First commit.
authored
11
b9931e7 @residuum Key value pair as struct.
authored
12 typedef struct memory_struct {
13 char *memory;
14 size_t size;
15 } t_memory_struct;
16
fc6e108 @residuum Removed blocking via pthread.
authored
17 typedef struct key_value_pair {
5854491 @residuum rest-json is now working again.
authored
18 char *key;
19 char *value;
43f0537 @residuum [json-encode] now also creates JSON arrays with the [array( message.
authored
20 short is_array;
5854491 @residuum rest-json is now working again.
authored
21 struct key_value_pair *next;
b9931e7 @residuum Key value pair as struct.
authored
22 } t_key_value_pair;
23
4596bdf @residuum Renamed library to purest_json;
authored
24 typedef struct rest {
cd8c974 @residuum First commit.
authored
25 t_object x_ob;
7cfd381 @residuum Output JSON data as several lists, followed by a bang.
authored
26 t_outlet *done_outlet;
cd8c974 @residuum First commit.
authored
27 int out_count;
5854491 @residuum rest-json is now working again.
authored
28 char *base_url;
29 t_atom *out;
91985ed @residuum Improved threading:
authored
30 /* Used for threading */
68efd0b @residuum Do not show unused parameter warning.
authored
31 char request_type[7]; /*One of GET, PUT, POST; DELETE*/
5854491 @residuum rest-json is now working again.
authored
32 char parameters[MAXPDSTRING];
33 char complete_url[MAXPDSTRING];
91985ed @residuum Improved threading:
authored
34 short is_data_locked;
4596bdf @residuum Renamed library to purest_json;
authored
35 } t_rest;
cd8c974 @residuum First commit.
authored
36
bc06d4b @residuum Implemented json-decode
authored
37 typedef struct json_encode {
075c75a @residuum Beginning of implementation of [json-encode] external.
authored
38 t_object x_ob;
5854491 @residuum rest-json is now working again.
authored
39 t_key_value_pair *data;
075c75a @residuum Beginning of implementation of [json-encode] external.
authored
40 int data_count;
41 } t_json_encode;
bc06d4b @residuum Implemented json-decode
authored
42
43 typedef struct json_decode {
44 t_object x_ob;
7cfd381 @residuum Output JSON data as several lists, followed by a bang.
authored
45 t_outlet *done_outlet;
bc06d4b @residuum Implemented json-decode
authored
46 } t_json_decode;
cd8c974 @residuum First commit.
authored
47
4596bdf @residuum Renamed library to purest_json;
authored
48 /* rest */
5a9caf9 @eighthave update Makefile and arrange files to match the Library Template:
eighthave authored
49 void setup_rest0x2djson(void);
4596bdf @residuum Renamed library to purest_json;
authored
50 void *rest_new(t_symbol *selector, int argcount, t_atom *argvec);
5854491 @residuum rest-json is now working again.
authored
51 void rest_free(t_rest *x, t_symbol *selector, int argcount, t_atom *argvec);
075c75a @residuum Beginning of implementation of [json-encode] external.
authored
52
4596bdf @residuum Renamed library to purest_json;
authored
53 void rest_command(t_rest *x, t_symbol *selector, int argcount, t_atom *argvec);
54 void rest_oauth(t_rest *x, t_symbol *selector, int argcount, t_atom *argvec);
55 void rest_url(t_rest *x, t_symbol *selector, int argcount, t_atom *argvec);
cd8c974 @residuum First commit.
authored
56
31bd302 @residuum Fixed threading issues, refactoring of methods
authored
57 void execute_rest(t_rest *x);
77b53cf @residuum Removed connection test.
authored
58
59 /* pthread functions */
fc6e108 @residuum Removed blocking via pthread.
authored
60 void *execute_rest_thread(void *thread_args);
cd8c974 @residuum First commit.
authored
61
075c75a @residuum Beginning of implementation of [json-encode] external.
authored
62 /* json-encode */
5a9caf9 @eighthave update Makefile and arrange files to match the Library Template:
eighthave authored
63 void setup_json0x2dencode(void);
075c75a @residuum Beginning of implementation of [json-encode] external.
authored
64 void *json_encode_new(t_symbol *selector, int argcount, t_atom *argvec);
5854491 @residuum rest-json is now working again.
authored
65 void json_encode_free(t_json_encode *x, t_symbol *selector, int argcount, t_atom *argvec);
075c75a @residuum Beginning of implementation of [json-encode] external.
authored
66
67 void json_encode_bang(t_json_encode *x);
68 void json_encode_add(t_json_encode *x, t_symbol *selector, int argcount, t_atom *argvec);
43f0537 @residuum [json-encode] now also creates JSON arrays with the [array( message.
authored
69 void json_encode_array_add(t_json_encode *x, t_symbol *selector, int argcount, t_atom *argvec);
075c75a @residuum Beginning of implementation of [json-encode] external.
authored
70 void json_encode_clear(t_json_encode *x, t_symbol *selector, int argcount, t_atom *argvec);
71
43f0537 @residuum [json-encode] now also creates JSON arrays with the [array( message.
authored
72 json_object *create_object(char *value);
5854491 @residuum rest-json is now working again.
authored
73 void json_encode_free_memory(t_json_encode *x);
43f0537 @residuum [json-encode] now also creates JSON arrays with the [array( message.
authored
74
76dfd69 @residuum JSON decoding working.
authored
75 /* json-decode */
5a9caf9 @eighthave update Makefile and arrange files to match the Library Template:
eighthave authored
76 void setup_json0x2ddecode(void);
bc06d4b @residuum Implemented json-decode
authored
77 void *json_decode_new(t_symbol *selector, int argcount, t_atom *argvec);
78
79 void json_decode_string(t_json_decode *x, t_symbol *data);
6624bc6 @residuum Fixing issue #4:
authored
80 void json_decode_list(t_json_decode *x, t_symbol *selector, int argcount, t_atom *argvec);
7cfd381 @residuum Output JSON data as several lists, followed by a bang.
authored
81 void output_json(json_object *jobj, t_outlet *data_outlet, t_outlet *done_outlet);
5f000f9 @residuum Fix for issue #5: Unicode characters are converted to lowercase.
authored
82 void output_json_string(char *json_string, t_outlet *data_outlet, t_outlet *done_outlet);
76dfd69 @residuum JSON decoding working.
authored
83
075c75a @residuum Beginning of implementation of [json-encode] external.
authored
84 /* general */
4596bdf @residuum Renamed library to purest_json;
authored
85 void purest_json_setup(void);
5854491 @residuum rest-json is now working again.
authored
86 char *remove_backslashes(char *source_string, size_t memsize);
00e39e9 @residuum Better check for numeric value of string (thanks, Mathieu Bouchard);
authored
87 int str_ccmp(const char *s1, const char *s2);
5854491 @residuum rest-json is now working again.
authored
88 char *lowercase_unicode(char *orig, size_t memsize);
Something went wrong with that request. Please try again.