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;