From ddfadf9a674212d8fb1d02a76347aece402b8172 Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 12 Apr 2022 14:54:07 +0200 Subject: [PATCH] /say /sieste --- floatimg.h | 13 +++++++------ lib/fimg-core.c | 4 ++-- lib/metadata.c | 25 +++++++++++++++++++++++-- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/floatimg.h b/floatimg.h index e8227204..257f8c52 100644 --- a/floatimg.h +++ b/floatimg.h @@ -4,8 +4,8 @@ * http://la.buvette.org/photos/cumul */ -#define FIMG_VERSION 179 - +#define FIMG_VERSION (181) +#define RELEASE_NAME ("noname") /* * in memory descriptor */ @@ -25,16 +25,17 @@ typedef struct { * fimg file header (short version) */ typedef struct { - char magic[8]; + char magic[8]; // this is not an asciiz ! int32_t w, h, t; } FimgFileHead; /* - * new 11 mars 2022 + * new 11 mars 2022, and a lot of iterations + * around the concept of metadata for my work. */ typedef struct { - char magic[8]; + char magic[8]; // this is not an asciiz ! struct timeval timestamp; - uint64_t pid; // WTF ? + uint64_t pid; // process id of the creator int32_t count; float fval; char idcam[32]; diff --git a/lib/fimg-core.c b/lib/fimg-core.c index c8fcea43..6812ba0c 100644 --- a/lib/fimg-core.c +++ b/lib/fimg-core.c @@ -39,8 +39,8 @@ return "???"; /* --------------------------------------------------------------------- */ int fimg_print_version(int k) { -fprintf(stderr, "*** FloatImg library, alpha %d (%s, %s)\n", - FIMG_VERSION, __DATE__, __TIME__); +fprintf(stderr, "*** FloatImg library, v%d '%s' (%s, %s)\n", + FIMG_VERSION, RELEASE_NAME, __DATE__, __TIME__); if (51 == k) { puts("+------------------------+"); diff --git a/lib/metadata.c b/lib/metadata.c index 03b47ad7..346fde1a 100644 --- a/lib/metadata.c +++ b/lib/metadata.c @@ -6,7 +6,8 @@ #include #include #include -#include "string.h" +#include +#include #include "../floatimg.h" @@ -29,6 +30,7 @@ fflush(fp); int fimg_show_metadata(FimgMetaData *pmd, char *title, int notused) { int foo; +double doubletime; fprintf(stderr, ">>> %s ( %p '%s' 0x%08x )\n", __func__, pmd, title, notused); @@ -40,6 +42,10 @@ if (verbosity) { } /* SHOW TIMESTAMP HERE */ +fprintf(stderr, "seconds sc. epoch = %ld\n", pmd->timestamp.tv_sec); +doubletime = (double)pmd->timestamp.tv_sec + \ + (double)pmd->timestamp.tv_usec / 1e6; +fprintf(stderr, "dtime of day = %e\n", doubletime); fprintf(stderr, "creator pid = %ld\n", pmd->pid); fprintf(stderr, "counter = %d\n", pmd->count); fprintf(stderr, "float value = %.3f\n", pmd->fval); @@ -48,7 +54,7 @@ fprintf(stderr, "origin = 0x%x\n", pmd->origin); fputs("reserved words are:\n ", stderr); for (foo=0; foo<8; foo++) { - fprintf(stderr, " 0x%08x", pmd->reserved[foo]); + fprintf(stderr, " 0x%08x", pmd->reserved[foo]); if (3 == foo) fputs("\n ", stderr); } fputc('\n', stderr); @@ -57,10 +63,25 @@ return 0; /* ---------------------------------------------------------------- */ int fimg_default_metadata(FimgMetaData *pmd) { +int foo; +struct timeval tvl; memset(pmd, 0, sizeof(FimgMetaData)); memcpy(pmd->magic, "metadata", 8); + /* set timestamp here ? */ +/* CHALLENGE ACCEPTED */ +memset(&tvl, 0, sizeof(struct timeval)); +foo = gettimeofday(&tvl, NULL); +if (foo) { + /* error on get time of day ? */ + perror("omg"); + } +else { + fprintf(stderr, "Time of day %12ld %12ld\n", tvl.tv_sec, tvl.tv_usec); + memcpy(&(pmd->timestamp), &tvl, sizeof(struct timeval)); + } + pmd->pid = getpid(); pmd->count = 0; pmd->fval = 255.0;