aboutsummaryrefslogtreecommitdiffstats
path: root/com32/hdt
diff options
context:
space:
mode:
authorErwan Velu <erwanaliasr1@gmail.com>2011-03-21 23:04:01 +0100
committerErwan Velu <erwanaliasr1@gmail.com>2011-03-21 23:04:01 +0100
commit3ead4c4f5d6cf098174cead7f8981bfe736a19ae (patch)
tree3a6267d792df22ee6d05c8e0c8a7d2b50344f107 /com32/hdt
parentffc891cd9c3eb846f4ef3ae83ad04f9ad7b976ac (diff)
downloadsyslinux-3ead4c4f5d6cf098174cead7f8981bfe736a19ae.tar.gz
syslinux-3ead4c4f5d6cf098174cead7f8981bfe736a19ae.tar.xz
syslinux-3ead4c4f5d6cf098174cead7f8981bfe736a19ae.zip
hdt: Using flush() for dumping data
This function ease the printing & generation of the dumped information & files
Diffstat (limited to 'com32/hdt')
-rw-r--r--com32/hdt/hdt-dump-cpu.c3
-rw-r--r--com32/hdt/hdt-dump.c15
-rw-r--r--com32/hdt/hdt-dump.h1
3 files changed, 13 insertions, 6 deletions
diff --git a/com32/hdt/hdt-dump-cpu.c b/com32/hdt/hdt-dump-cpu.c
index c0bb952e..dc58a6f8 100644
--- a/com32/hdt/hdt-dump-cpu.c
+++ b/com32/hdt/hdt-dump-cpu.c
@@ -48,5 +48,6 @@ void dump_cpu(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item)
snprintf(temp,sizeof(temp),"cpu.flags.%s",cpu_flags_names[i]);
add_b(temp,get_cpu_flag_value_from_name(&hardware->cpu,cpu_flags_names[i]));
}
- print_and_flush(config,item);
+
+ flush("cpu",config,item);
}
diff --git a/com32/hdt/hdt-dump.c b/com32/hdt/hdt-dump.c
index 027a82e1..9647ebaf 100644
--- a/com32/hdt/hdt-dump.c
+++ b/com32/hdt/hdt-dump.c
@@ -75,6 +75,15 @@ int dumpprintf(FILE *p, const char *format, ...) {
return rv;
}
+void flush (char *filename, ZZJSON_CONFIG *config, ZZJSON ** item) {
+ print_and_flush(config,item);
+ cpio_writefile(upload,filename,p_buf.buf,p_buf.len);
+ if (p_buf.buf) {
+ memset(p_buf.buf,0,p_buf.size);
+ free(p_buf.buf);
+ }
+}
+
/**
* dump - dump info
**/
@@ -91,7 +100,6 @@ void dump(struct s_hardware *hardware)
};
detect_hardware(hardware);
- dump_cpu(hardware, &config, &json);
/* By now, we only support TFTP reporting */
upload=&upload_tftp;
@@ -110,12 +118,9 @@ void dump(struct s_hardware *hardware)
/* We initiate the cpio to send */
cpio_init(upload,(const char **)arg);
- cpio_writefile(upload,"cpu",p_buf.buf,p_buf.len);
+ dump_cpu(hardware, &config, &json);
/* We close & flush the file to send */
cpio_close(upload);
flush_data(upload);
- if (p_buf.buf) {
- free(p_buf.buf);
- }
}
diff --git a/com32/hdt/hdt-dump.h b/com32/hdt/hdt-dump.h
index 1ec6aa2e..2f9dd6f2 100644
--- a/com32/hdt/hdt-dump.h
+++ b/com32/hdt/hdt-dump.h
@@ -46,5 +46,6 @@ extern struct print_buf p_buf;
void print_and_flush(ZZJSON_CONFIG *config, ZZJSON **item);
int dumpprintf(FILE *p, const char *format, ...);
+void flush (char *filename, ZZJSON_CONFIG *config, ZZJSON ** item);
void dump_cpu(struct s_hardware *hardware, ZZJSON_CONFIG *config, ZZJSON **item);