[syslinux:master] hdt: Using flush() for dumping data

syslinux-bot for Erwan Velu erwanaliasr1 at gmail.com
Mon Apr 25 15:28:10 PDT 2011


Commit-ID:  3ead4c4f5d6cf098174cead7f8981bfe736a19ae
Gitweb:     http://syslinux.zytor.com/commit/3ead4c4f5d6cf098174cead7f8981bfe736a19ae
Author:     Erwan Velu <erwanaliasr1 at gmail.com>
AuthorDate: Mon, 21 Mar 2011 23:04:01 +0100
Committer:  Erwan Velu <erwanaliasr1 at gmail.com>
CommitDate: Mon, 21 Mar 2011 23:04:01 +0100

hdt: Using flush() for dumping data

This function ease the printing & generation of the dumped information &
files


---
 com32/hdt/hdt-dump-cpu.c |    3 ++-
 com32/hdt/hdt-dump.c     |   15 ++++++++++-----
 com32/hdt/hdt-dump.h     |    1 +
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/com32/hdt/hdt-dump-cpu.c b/com32/hdt/hdt-dump-cpu.c
index c0bb952..dc58a6f 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 027a82e..9647eba 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 1ec6aa2..2f9dd6f 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);



More information about the Syslinux-commits mailing list