# HG changeset patch # User Josef 'Jeff' Sipek # Date 1662818292 14400 # Sat Sep 10 09:58:12 2022 -0400 # Node ID 6b4138f24bbca06aa1f5a91fbda3cbb9562428c8 # Parent e5c70f85f8d239b57fa78c5e7c410af20a02b557 hlog: pass an invocation indication to fill_template This way, the function can behave differently based on which binary called it. Signed-off-by: Josef 'Jeff' Sipek diff --git a/hlog/common/config.c b/hlog/common/config.c --- a/hlog/common/config.c +++ b/hlog/common/config.c @@ -42,7 +42,7 @@ lua_typename(L, lua_type(L, -1))); } -static int process_config(lua_State *L, struct qso *template) +static int process_config(lua_State *L, struct qso *template, const char *mode) { char error[128]; int ret; @@ -61,7 +61,9 @@ return ret; } - ret = xlua_call(L, NULL, 1, 0, error, sizeof(error)); + lua_pushstring(L, mode); + + ret = xlua_call(L, NULL, 2, 0, error, sizeof(error)); if (ret) { fprintf(stderr, "Error: 'fill_template' failed " "to execute: %s\n", error); @@ -116,7 +118,7 @@ return 0; } -int load_config(int data_dir_fd, struct qso *template) +int load_config(int data_dir_fd, struct qso *template, const char *mode) { char error[128]; lua_State *L; @@ -136,7 +138,7 @@ switch (lua_type(L, -1)) { case LUA_TTABLE: /* got a table - process it */ - ret = process_config(L, template); + ret = process_config(L, template, mode); if (ret) goto err_lua; break; diff --git a/hlog/common/config.h b/hlog/common/config.h --- a/hlog/common/config.h +++ b/hlog/common/config.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Josef 'Jeff' Sipek + * Copyright (c) 2021-2022 Josef 'Jeff' Sipek * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,6 +23,6 @@ #ifndef __CONFIG_H #define __CONFIG_H -extern int load_config(int data_dir_fd, struct qso *template); +extern int load_config(int data_dir_fd, struct qso *template, const char *mode); #endif diff --git a/hlog/contest.c b/hlog/contest.c --- a/hlog/contest.c +++ b/hlog/contest.c @@ -710,7 +710,7 @@ goto err_free; } - ret = load_config(AT_FDCWD, template); + ret = load_config(AT_FDCWD, template, "contest"); if (ret) goto err_free; diff --git a/hlog/hlog.c b/hlog/hlog.c --- a/hlog/hlog.c +++ b/hlog/hlog.c @@ -2021,7 +2021,7 @@ goto err; /* read the config */ - ret = load_config(AT_FDCWD, template); + ret = load_config(AT_FDCWD, template, "normal"); if (ret) goto err_states; diff --git a/init-data.sh b/init-data.sh --- a/init-data.sh +++ b/init-data.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright (c) 2020-2021 Josef 'Jeff' Sipek +# Copyright (c) 2020-2022 Josef 'Jeff' Sipek # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -40,7 +40,11 @@ mkdir "$DIR/tmp" cat > "$DIR/config.lua" <