1/* Copyright (c) 2013, Vsevolod Stakhov
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
--- 7 unchanged lines hidden (view full) ---
16 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 */
23
24#include <stdio.h>
25#include <errno.h>
26#include <unistd.h>
27#include "ucl.h"
28
29int
30main (int argc, char **argv)
31{
32 char inbuf[8192], *test_in = NULL;
33 struct ucl_parser *parser = NULL, *parser2 = NULL;
34 ucl_object_t *obj;
35 FILE *in, *out;
--- 56 unchanged lines hidden (view full) ---
92 out = fopen (fname_out, "w");
93 if (out == NULL) {
94 exit (-errno);
95 }
96 }
97 else {
98 out = stdout;
99 }
100 if (ucl_parser_get_error(parser) != NULL) {
101 fprintf (out, "Error occurred: %s\n", ucl_parser_get_error(parser));
102 ret = 1;
103 goto end;
104 }
105 obj = ucl_parser_get_object (parser);
106 if (json) {
107 emitted = ucl_object_emit (obj, UCL_EMIT_JSON);
108 }
109 else {
110 emitted = ucl_object_emit (obj, UCL_EMIT_CONFIG);
111 }
112 ucl_parser_free (parser);
113 ucl_object_unref (obj);
114 parser2 = ucl_parser_new (UCL_PARSER_KEY_LOWERCASE);
115 ucl_parser_add_chunk (parser2, emitted, strlen (emitted));
116
117 if (ucl_parser_get_error(parser2) != NULL) {
118 fprintf (out, "Error occurred: %s\n", ucl_parser_get_error(parser2));
119 fprintf (out, "%s\n", emitted);
120 ret = 1;
121 goto end;
122 }
123 if (emitted != NULL) {
--- 28 unchanged lines hidden ---
2 * All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * * Redistributions of source code must retain the above copyright
7 * notice, this list of conditions and the following disclaimer.
8 * * Redistributions in binary form must reproduce the above copyright
--- 7 unchanged lines hidden (view full) ---
16 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 */
23
24#include <stdio.h>
25#include <errno.h>
26#include <unistd.h>
27#include "ucl.h"
28
29int
30main (int argc, char **argv)
31{
32 char inbuf[8192], *test_in = NULL;
33 struct ucl_parser *parser = NULL, *parser2 = NULL;
34 ucl_object_t *obj;
35 FILE *in, *out;
--- 56 unchanged lines hidden (view full) ---
92 out = fopen (fname_out, "w");
93 if (out == NULL) {
94 exit (-errno);
95 }
96 }
97 else {
98 out = stdout;
99 }
100 if (ucl_parser_get_error(parser) != NULL) {
101 fprintf (out, "Error occurred: %s\n", ucl_parser_get_error(parser));
102 ret = 1;
103 goto end;
104 }
105 obj = ucl_parser_get_object (parser);
106 if (json) {
107 emitted = ucl_object_emit (obj, UCL_EMIT_JSON);
108 }
109 else {
110 emitted = ucl_object_emit (obj, UCL_EMIT_CONFIG);
111 }
112 ucl_parser_free (parser);
113 ucl_object_unref (obj);
114 parser2 = ucl_parser_new (UCL_PARSER_KEY_LOWERCASE);
115 ucl_parser_add_chunk (parser2, emitted, strlen (emitted));
116
117 if (ucl_parser_get_error(parser2) != NULL) {
118 fprintf (out, "Error occurred: %s\n", ucl_parser_get_error(parser2));
119 fprintf (out, "%s\n", emitted);
120 ret = 1;
121 goto end;
122 }
123 if (emitted != NULL) {
--- 28 unchanged lines hidden ---