Deleted Added
full compact
objdump.c (263019) objdump.c (268896)
1/* Copyright (c) 2013, Dmitriy V. Reshetnikov
2 * Copyright (c) 2013, Vsevolod Stakhov
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 14 unchanged lines hidden (view full) ---

23 */
24
25#include <stdio.h>
26#include <errno.h>
27
28#include "ucl.h"
29
30void
1/* Copyright (c) 2013, Dmitriy V. Reshetnikov
2 * Copyright (c) 2013, Vsevolod Stakhov
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.

--- 14 unchanged lines hidden (view full) ---

23 */
24
25#include <stdio.h>
26#include <errno.h>
27
28#include "ucl.h"
29
30void
31ucl_obj_dump(ucl_object_t *obj, unsigned int shift)
31ucl_obj_dump (const ucl_object_t *obj, unsigned int shift)
32{
33 int num = shift * 4 + 5;
34 char *pre = (char *) malloc (num * sizeof(char));
32{
33 int num = shift * 4 + 5;
34 char *pre = (char *) malloc (num * sizeof(char));
35 ucl_object_t *cur, *tmp;
35 const ucl_object_t *cur, *tmp;
36 ucl_object_iter_t it = NULL, it_obj = NULL;
37
38 pre[--num] = 0x00;
39 while (num--)
40 pre[num] = 0x20;
41
42 tmp = obj;
43

--- 15 unchanged lines hidden (view full) ---

59 }
60 else if (obj->type == UCL_ARRAY) {
61 printf ("%stype: UCL_ARRAY\n", pre);
62 printf ("%svalue: %p\n", pre, obj->value.av);
63 ucl_obj_dump (obj->value.av, shift + 2);
64 }
65 else if (obj->type == UCL_INT) {
66 printf ("%stype: UCL_INT\n", pre);
36 ucl_object_iter_t it = NULL, it_obj = NULL;
37
38 pre[--num] = 0x00;
39 while (num--)
40 pre[num] = 0x20;
41
42 tmp = obj;
43

--- 15 unchanged lines hidden (view full) ---

59 }
60 else if (obj->type == UCL_ARRAY) {
61 printf ("%stype: UCL_ARRAY\n", pre);
62 printf ("%svalue: %p\n", pre, obj->value.av);
63 ucl_obj_dump (obj->value.av, shift + 2);
64 }
65 else if (obj->type == UCL_INT) {
66 printf ("%stype: UCL_INT\n", pre);
67 printf ("%svalue: %ld\n", pre, ucl_object_toint (obj));
67 printf ("%svalue: %jd\n", pre, (intmax_t)ucl_object_toint (obj));
68 }
69 else if (obj->type == UCL_FLOAT) {
70 printf ("%stype: UCL_FLOAT\n", pre);
71 printf ("%svalue: %f\n", pre, ucl_object_todouble (obj));
72 }
73 else if (obj->type == UCL_STRING) {
74 printf ("%stype: UCL_STRING\n", pre);
75 printf ("%svalue: \"%s\"\n", pre, ucl_object_tostring (obj));

--- 18 unchanged lines hidden (view full) ---

94int
95main(int argc, char **argv)
96{
97 const char *fn = NULL;
98 char inbuf[8192];
99 struct ucl_parser *parser;
100 int k, ret = 0, r = 0;
101 ucl_object_t *obj = NULL;
68 }
69 else if (obj->type == UCL_FLOAT) {
70 printf ("%stype: UCL_FLOAT\n", pre);
71 printf ("%svalue: %f\n", pre, ucl_object_todouble (obj));
72 }
73 else if (obj->type == UCL_STRING) {
74 printf ("%stype: UCL_STRING\n", pre);
75 printf ("%svalue: \"%s\"\n", pre, ucl_object_tostring (obj));

--- 18 unchanged lines hidden (view full) ---

94int
95main(int argc, char **argv)
96{
97 const char *fn = NULL;
98 char inbuf[8192];
99 struct ucl_parser *parser;
100 int k, ret = 0, r = 0;
101 ucl_object_t *obj = NULL;
102 ucl_object_t *par;
102 const ucl_object_t *par;
103 FILE *in;
104
105 if (argc > 1) {
106 fn = argv[1];
107 }
108
109 if (fn != NULL) {
110 in = fopen (fn, "r");

--- 13 unchanged lines hidden (view full) ---

124 fclose (in);
125 if (ucl_parser_get_error(parser)) {
126 printf ("Error occured: %s\n", ucl_parser_get_error(parser));
127 ret = 1;
128 goto end;
129 }
130
131 obj = ucl_parser_get_object (parser);
103 FILE *in;
104
105 if (argc > 1) {
106 fn = argv[1];
107 }
108
109 if (fn != NULL) {
110 in = fopen (fn, "r");

--- 13 unchanged lines hidden (view full) ---

124 fclose (in);
125 if (ucl_parser_get_error(parser)) {
126 printf ("Error occured: %s\n", ucl_parser_get_error(parser));
127 ret = 1;
128 goto end;
129 }
130
131 obj = ucl_parser_get_object (parser);
132 if (ucl_parser_get_error(parser)) {
132 if (ucl_parser_get_error (parser)) {
133 printf ("Error occured: %s\n", ucl_parser_get_error(parser));
134 ret = 1;
135 goto end;
136 }
137
138 if (argc > 2) {
139 for (k = 2; k < argc; k++) {
140 printf ("search for \"%s\"... ", argv[k]);

--- 19 unchanged lines hidden ---
133 printf ("Error occured: %s\n", ucl_parser_get_error(parser));
134 ret = 1;
135 goto end;
136 }
137
138 if (argc > 2) {
139 for (k = 2; k < argc; k++) {
140 printf ("search for \"%s\"... ", argv[k]);

--- 19 unchanged lines hidden ---