hdt: Dumping memory configuration
[profile/ivi/syslinux.git] / com32 / hdt / hdt-dump.h
1 /* ----------------------------------------------------------------------- *
2  *
3  *   Copyright 20011 Erwan Velu - All Rights Reserved
4  *
5  *   Permission is hereby granted, free of charge, to any person
6  *   obtaining a copy of this software and associated documentation
7  *   files (the "Software"), to deal in the Software without
8  *   restriction, including without limitation the rights to use,
9  *   copy, modify, merge, publish, distribute, sublicense, and/or
10  *   sell copies of the Software, and to permit persons to whom
11  *   the Software is furnished to do so, subject to the following
12  *   conditions:
13  *
14  *   The above copyright notice and this permission notice shall
15  *   be included in all copies or substantial portions of the Software.
16  *
17  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19  *   OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  *   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21  *   HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22  *   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23  *   FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24  *   OTHER DEALINGS IN THE SOFTWARE.
25  *
26  * -----------------------------------------------------------------------
27  */
28
29 #include <stdio.h>
30 #include <string.h>
31 #include <stdlib.h>
32 #include <ctype.h>
33 #include <bufprintf.h>
34 #include <zzjson/zzjson.h>
35 #include "hdt-common.h"
36
37 // Macros to manipulate Arrays
38 #define APPEND_ARRAY ZZJSON *temp_array; temp_array = zzjson_array_append(config, *item, zzjson_create_object(config,
39 #define APPEND_OBJECT_ARRAY(value) ZZJSON *temp_ar; temp_ar = zzjson_array_append(config, *item, value); *item=temp_ar; 
40 #define CREATE_ARRAY *item = zzjson_create_array(config, zzjson_create_object(config, 
41 #define add_ai(name,value) name,zzjson_create_number_i(config,value),
42 #define add_ahi(value) add_ai(#value,hardware->value)
43 #define add_as(name,value) name,zzjson_create_string(config,value),
44 #define add_ahs(value) add_as(#value,hardware->value)
45 #define END_OF_ARRAY NULL),NULL)
46 #define END_OF_APPEND NULL)); *item=temp_array;
47
48 // Macros to manipulate integers as objects
49 #define add_i(name,value) *item = zzjson_object_append(config, *item, name, zzjson_create_number_i(config, value))
50 #define add_hi(value) add_i(#value,hardware->value)
51
52 // Macros to manipulate strings as objects
53 #define add_s(name,value) *item = zzjson_object_append(config, *item, name, zzjson_create_string(config, value))
54 #define add_hs(value) add_s(#value,(char *)hardware->value)
55
56 // Macros to manipulate bool as objects
57 #define add_bool_true(name) *item = zzjson_object_append(config, *item, (char *)name, zzjson_create_true(config))
58 #define add_bool_false(name) *item = zzjson_object_append(config, *item, (char*)name, zzjson_create_false(config))
59 #define add_b(name,value) if (value==true) {add_bool_true(name);} else {add_bool_false(name);}
60 #define add_hb(value) add_b(#value,hardware->value)
61
62 // Macros to Temp Objects
63 #define CREATE_TEMP_OBJECT ZZJSON *temp; temp=zzjson_create_object(config,NULL);
64 #define add_ti(name,value) temp = zzjson_object_append(config, temp, name, zzjson_create_number_i(config, value))
65 #define add_thi(value) add_ti(#value,hardware->value)
66 #define add_ts(name,value) temp= zzjson_object_append(config, temp, name, zzjson_create_string(config, value))
67 #define add_ths(value) add_ts(#value,(char *)hardware->value)
68 #define APPEND_TEMP_OBJECT_ARRAY APPEND_OBJECT_ARRAY(temp);
69
70 extern struct print_buf p_buf;
71
72 void print_and_flush(ZZJSON_CONFIG *config, ZZJSON **item);
73 int dumpprintf(FILE *p, const char *format, ...);
74 void flush (char *filename, ZZJSON_CONFIG *config, ZZJSON ** item);
75
76 void dump_cpu(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
77 void dump_pxe(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
78 void dump_syslinux(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
79 void dump_vpd(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
80 void dump_vesa(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
81 void dump_disks(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
82 void dump_dmi(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);
83 void dump_memory(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);