summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--mico-store.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/mico-store.c b/mico-store.c
index 8bccad1..6ee1833 100644
--- a/mico-store.c
+++ b/mico-store.c
@@ -115,8 +115,6 @@ zip_t *zip;
 void
 reset_stream()
 {
-	printf("RESET\n");
-
 	ts = (struct bitfile){ 0 };
 	vs = (struct bitfile){ 0 };
 	ts.output = open_memstream(&ts.mem, &ts.memlen);
@@ -131,6 +129,8 @@ reset_stream()
         putbits1_msb(&vs, 32, 0);
 }
 
+#define htonll(x) ((1==htonl(1)) ? (x) : ((uint64_t)htonl((x) & 0xFFFFFFFF) << 32) | htonl((x) >> 32))
+
 void
 write_stream(char *name)
 {
@@ -149,16 +149,10 @@ write_stream(char *name)
 	if (s)
 		*s = 0;
 
-	fprintf(stderr, "%s: %ld + %ld\n", name, ts.memlen, vs.memlen);
-	fprintf(stderr, "name=%s\n", path);
-
 	/* patch in length */
-	uint32_t h = htonl((uint32_t)(ts.nevents >> 32));
-	uint32_t l = htonl((uint32_t)(ts.nevents & 0xffffffff));
-	memcpy(ts.mem + 8, &h, sizeof h);
-	memcpy(ts.mem + 8 + sizeof h, &l, sizeof l);
-	memcpy(vs.mem + 8, &h, sizeof h);
-	memcpy(vs.mem + 8 + sizeof h, &l, sizeof l);
+	uint64_t nevents = htonll(ts.nevents);
+	memcpy(ts.mem + 8, &nevents, sizeof nevents);
+	memcpy(vs.mem + 8, &nevents, sizeof nevents);
 
 	// time_t mtime = metrics[m].value[0].t / 1000;
 	snprintf(path, sizeof path, "%s/time.dd", prefix);
@@ -238,8 +232,6 @@ main(int argc, char *argv[])
 		memcpy(name, line, start-line);
 		name[start-line] = 0;
 
-		printf("LINE |%s| |%s| |%s|\n", line, name, lastname);
-
 		if (strcmp(name, lastname) != 0) {
 			if (*lastname)
 				write_stream(lastname);