From 3353241a79f0e2b130dce5e98d656284a7da84f8 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Thu, 5 May 2011 14:12:40 -0500 Subject: [PATCH] add command line option to change the pid path This adds a -P or --pid-path option to the command line which allows the user to change the path and the name of the pid file created when espeakup is running as a daemon. I would like to thank Chris Brannon for the original idea for this. --- cli.c | 12 +++++++++++- espeakup.8 | 6 ++++++ espeakup.c | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/cli.c b/cli.c index 64cfd6b..1ad291c 100644 --- a/cli.c +++ b/cli.c @@ -24,12 +24,16 @@ #include "espeakup.h" +/* pid path */ +extern char *pidPath; + /* default voice */ extern char *defaultVoice; /* command line options */ -const char *shortOptions = "dhV:v"; +const char *shortOptions = "P:V:dhv"; const struct option longOptions[] = { + {"pid-path", required_argument, NULL, 'P'}, {"default-voice", required_argument, NULL, 'V'}, {"debug", no_argument, NULL, 'd'}, {"help", no_argument, NULL, 'h'}, @@ -61,10 +65,16 @@ static void show_version(void) void process_cli(int argc, char **argv) { int opt; + char *cp; do { opt = getopt_long(argc, argv, shortOptions, longOptions, NULL); switch (opt) { + case 'p': + cp = strdup(optarg); + if (cp != NULL) + pidPath = cp; + break; case 'V': defaultVoice = strdup(optarg); break; diff --git a/espeakup.8 b/espeakup.8 index 314aed7..092c776 100644 --- a/espeakup.8 +++ b/espeakup.8 @@ -9,6 +9,9 @@ espeakup \(em connect Speakup to the ESpeak TTS engine .SH SYNOPSIS .B espeakup [ +.B \-\^\-pid-path=path +] +[ .B \-\^\-default-voice=voicename ] [ @@ -22,6 +25,9 @@ espeakup \(em connect Speakup to the ESpeak TTS engine ] .SH OPTIONS .TP +.B \-P path, \-\^\-pid-path=path +Set the full path for the pid file espeakup uses when in daemon mode. +.TP .B \-V voicename, \-\^\-default-voice=voicename Set the espeak voice to be used by default. .TP diff --git a/espeakup.c b/espeakup.c index e059b84..40b4a64 100644 --- a/espeakup.c +++ b/espeakup.c @@ -27,7 +27,7 @@ #include "espeakup.h" /* path to our pid file */ -const char *pidPath = "/var/run/espeakup.pid"; +char *pidPath = "/var/run/espeakup.pid"; int debug = 0; struct queue_t *synth_queue = NULL;