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.
This commit is contained in:
William Hubbs 2011-05-05 14:12:40 -05:00
commit 3353241a79
3 changed files with 18 additions and 2 deletions

12
cli.c
View file

@ -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;

View file

@ -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

View file

@ -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;