aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-06-29 12:39:34 +0000
committerOmar Polo <op@omarpolo.com>2021-06-29 12:39:34 +0000
commitf98e9045aef95fe28972d477ee549974c7cefb9f (patch)
tree9f565c5c15d72e6fbb64288b9251a437b439c030
parent3b21cca385c403247960cfe9385dda1d56f28670 (diff)
add -D to define macros from the cmd line
-rw-r--r--ChangeLog2
-rw-r--r--gmid.c9
2 files changed, 9 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 3801306..472bedf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2021-06-29 Omar Polo <op@omarpolo.com>
+ * gmid.c (main): add -D to define macros from the cmd line
+
* parse.y (yylex): allow to define macros in the config file
* gmid.c (main): use getopt_long, add --help as synonym of -h and -V/--version
diff --git a/gmid.c b/gmid.c
index 4fcd5c2..93e1895 100644
--- a/gmid.c
+++ b/gmid.c
@@ -27,7 +27,7 @@
#include <signal.h>
#include <string.h>
-static const char *opts = "6c:d:fH:hnP:p:Vvx:";
+static const char *opts = "6c:D:d:fH:hnP:p:Vvx:";
static struct option longopts[] = {
{"help", no_argument, NULL, 'h'},
@@ -382,7 +382,7 @@ usage(void)
{
fprintf(stderr,
"Version: " GMID_STRING "\n"
- "Usage: %s [-fnv] [-c config] [-P pidfile]\n"
+ "Usage: %s [-fnv] [-c config] [-D macro=value] [-P pidfile]\n"
" %s [-6hVv] [-d certs-dir] [-H hostname] [-p port] [-x cgi] [dir]\n",
getprogname(),
getprogname());
@@ -548,6 +548,11 @@ main(int argc, char **argv)
config_path = absolutify_path(optarg);
break;
+ case 'D':
+ if (cmdline_symset(optarg) == -1)
+ errx(1, "invalid macro: %s", optarg);
+ break;
+
case 'd':
certs_dir = optarg;
configless = 1;