File tree Expand file tree Collapse file tree 2 files changed +40
-22
lines changed
Expand file tree Collapse file tree 2 files changed +40
-22
lines changed Original file line number Diff line number Diff line change @@ -129,44 +129,76 @@ ___
129129## cjlib_json_error_init
130130___
131131### Description
132+ It is used to make the required initializations on the memory where the internal structure representing the errors is stored.
132133
133134### Function signature
134135``` C
135-
136+ int cjlib_json_error_init (void)
136137```
137138
138139### Parameters
140+ No parameters are required.
139141
140142### Return
141- --
143+ An integer indicating whether the initialization succeeded. If succeed, 0 is returned, otherwise -1.
142144
143145### Errors
144- --
146+ No specific error is returned.
145147
146148### Example
147149```C
150+ #include "cjlib_error.h"
151+ #include <stdio.h>
152+ #include <stdlib.h>
153+
154+ int main(void) {
155+ if (-1 == cjlib_json_error_init()) {
156+ (void) printf("Failed to initialize JSON errors\n");
157+ exit(EXIT_FAILURE);
158+ }
159+ return EXIT_SUCCESS;
160+ }
148161```
149162
150163___
151164## cjlib_json_error_destroy
152165___
153166### Description
167+ Is used to release the resources that was allocated for the internal error structure.
154168
155169### Function signature
156170``` C
157-
171+ void cjlib_json_error_destroy (void);
158172```
159173
160174### Parameters
175+ No parameters are required.
161176
162177### Return
163- --
178+ Nothing is returned.
164179
165180### Errors
166- --
181+ No specific error is returned.
167182
168183### Example
169184```C
185+ #include "cjlib_error.h"
186+ #include <stdio.h>
187+ #include <stdlib.h>
188+
189+ int main(void) {
190+ // Initialize the componentes of the error structure.
191+ if (-1 == cjlib_json_error_init()) {
192+ (void) printf("Failed to initialize JSON errors\n");
193+ exit(EXIT_FAILURE);
194+ }
195+
196+ // Code...
197+
198+ // Release the components.
199+ cjlib_json_error_destroy();
200+ return EXIT_SUCCESS
201+ }
170202```
171203
172204___
Original file line number Diff line number Diff line change @@ -59,20 +59,6 @@ int main(void)
5959
6060 (void ) printf ("%s\n" , dst .c_value .c_str );
6161
62- /*
63- struct cjlib_json_data test;
64- CJLIB_LIST_FOR_EACH(test, dst.c_value.c_arr, struct cjlib_json_data) {
65- (void) printf("%s\n", test.c_value.c_str);
66- }
67-
68- if (-1 == cjlib_json_get(&dst, &json_file, "industry")) {
69- (void) printf("Error\n");
70- exit(-1);
71- }
72-
73- (void) printf("%s\n", dst.c_value.c_str);*/
74-
75- /*
7662 if (-1 == cjlib_json_get (& dst , & json_file , "configurations" )) {
7763 (void ) printf ("Error\n" );
7864 exit (-1 );
@@ -83,12 +69,12 @@ int main(void)
8369 exit (-1 );
8470 }
8571
86- if (-1 == cjlib_json_object_get(&dst, dst.c_value.c_obj, "cwd ")) {
72+ if (-1 == cjlib_json_object_get (& dst , dst .c_value .c_obj , "request " )) {
8773 (void ) printf ("Error\n" );
8874 exit (-1 );
8975 }
9076
91- (void) printf("%s\n", dst.c_value.c_str);*/
77+ (void ) printf ("%s\n" , dst .c_value .c_str );
9278
9379
9480 //free((void *) cjlib_json_stringtify(&json_file));
You can’t perform that action at this time.
0 commit comments