[e16e8f2] | 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 objects |
---|
| 49 | #define CREATE_NEW_OBJECT *item = zzjson_create_object(config, NULL); |
---|
| 50 | #define FLUSH_OBJECT flush(config, item); |
---|
| 51 | |
---|
| 52 | // Macros to manipulate integers as objects |
---|
| 53 | #define add_i(name,value) *item = zzjson_object_append(config, *item, name, zzjson_create_number_i(config, value)) |
---|
| 54 | #define add_hi(value) add_i(#value,hardware->value) |
---|
| 55 | |
---|
| 56 | // Macros to manipulate strings as objects |
---|
| 57 | #define add_s(name,value) *item = zzjson_object_append(config, *item, name, zzjson_create_string(config, value)) |
---|
| 58 | #define add_hs(value) add_s(#value,(char *)hardware->value) |
---|
| 59 | |
---|
| 60 | // Macros to manipulate bool as objects |
---|
| 61 | #define add_bool_true(name) *item = zzjson_object_append(config, *item, (char *)name, zzjson_create_true(config)) |
---|
| 62 | #define add_bool_false(name) *item = zzjson_object_append(config, *item, (char*)name, zzjson_create_false(config)) |
---|
| 63 | #define add_b(name,value) if (value==true) {add_bool_true(name);} else {add_bool_false(name);} |
---|
| 64 | #define add_hb(value) add_b(#value,hardware->value) |
---|
| 65 | |
---|
| 66 | extern struct print_buf p_buf; |
---|
| 67 | |
---|
| 68 | void print_and_flush(ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 69 | int dumpprintf(FILE *p, const char *format, ...); |
---|
| 70 | void flush (ZZJSON_CONFIG *config, ZZJSON ** item); |
---|
| 71 | void to_cpio(char *filename); |
---|
| 72 | |
---|
| 73 | void dump_cpu(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 74 | void dump_pxe(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 75 | void dump_syslinux(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 76 | void dump_vpd(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 77 | void dump_vesa(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 78 | void dump_disks(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 79 | void dump_dmi(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 80 | void dump_memory(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 81 | void dump_pci(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 82 | void dump_acpi(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 83 | void dump_kernel(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 84 | void dump_hdt(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item); |
---|
| 85 | void dump(struct s_hardware *hardware); |
---|