aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-02-12 23:51:36 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-02-12 23:51:36 -0500
commita09f506ff3ed6a47eb7b3cb045164defd6b8d198 (patch)
tree191edf8dd4ceb479bcce7da7f0c9d983a78a417f
parentca6fb164907c3fb530f049864d6a986f85b22cdf (diff)
downloadstasis-a09f506ff3ed6a47eb7b3cb045164defd6b8d198.tar.gz
Add Delivery.info.time_str_epoch member to store Unix epoch as a string.
-rw-r--r--include/deliverable.h7
-rw-r--r--include/omc.h1
-rw-r--r--src/deliverable.c6
-rw-r--r--src/main.c1
4 files changed, 12 insertions, 3 deletions
diff --git a/include/deliverable.h b/include/deliverable.h
index d0186d7..ed9d12a 100644
--- a/include/deliverable.h
+++ b/include/deliverable.h
@@ -86,9 +86,10 @@ struct Delivery {
* \brief Release information (name & datetime)
*/
struct Info {
- char *release_name; ///< The fully combined release string
- struct tm *time_info;
- time_t time_now; ///< Time stamp for when OMC execution started
+ char *release_name; ///< The fully combined release string
+ struct tm *time_info; ///< Delivery time structure
+ time_t time_now; ///< Time stamp for when OMC execution started
+ char *time_str_epoch; ///< String representation of Unix epoch
} info;
/*! \struct Conda
diff --git a/include/omc.h b/include/omc.h
index 36ab676..21ffd0a 100644
--- a/include/omc.h
+++ b/include/omc.h
@@ -13,6 +13,7 @@
#define OMC_BUFSIZ 8192
#define OMC_NAME_MAX 255
#define OMC_DIRSTACK_MAX 1024
+#define OMC_TIME_STR_MAX 128
#define HTTP_ERROR(X) X >= 400
#include "config.h"
diff --git a/src/deliverable.c b/src/deliverable.c
index 6d868e0..72e4eff 100644
--- a/src/deliverable.c
+++ b/src/deliverable.c
@@ -277,6 +277,12 @@ int delivery_init(struct Delivery *ctx, struct INIFILE *ini, struct INIFILE *cfg
// Record timestamp used for release
time(&ctx->info.time_now);
ctx->info.time_info = localtime(&ctx->info.time_now);
+ ctx->info.time_str_epoch = calloc(OMC_TIME_STR_MAX, sizeof(*ctx->info.time_str_epoch));
+ if (!ctx->info.time_str_epoch) {
+ msg(OMC_MSG_ERROR, "Unable to allocate memory for Unix epoch string\n");
+ return -1;
+ }
+ snprintf(ctx->info.time_str_epoch, OMC_TIME_STR_MAX - 1, "%li", ctx->info.time_now);
if (cfg) {
getter(cfg, "default", "conda_staging_dir", INIVAL_TYPE_STR)
diff --git a/src/main.c b/src/main.c
index c7ab362..2a0125d 100644
--- a/src/main.c
+++ b/src/main.c
@@ -199,6 +199,7 @@ int main(int argc, char *argv[], char *arge[]) {
tpl_register("meta.mission", &ctx.meta.mission);
tpl_register("meta.python", &ctx.meta.python);
tpl_register("meta.python_compact", &ctx.meta.python_compact);
+ tpl_register("info.time_str_epoch", &ctx.info.time_str_epoch);
tpl_register("info.release_name", &ctx.info.release_name);
tpl_register("conda.installer_baseurl", &ctx.conda.installer_baseurl);
tpl_register("conda.installer_name", &ctx.conda.installer_name);