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);
}
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
**/
};
detect_hardware(hardware);
- dump_cpu(hardware, &config, &json);
/* By now, we only support TFTP reporting */
upload=&upload_tftp;
/* 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);
- }
}
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);