~ubuntu-branches/ubuntu/trusty/speech-dispatcher/trusty-proposed

« back to all changes in this revision

Viewing changes to src/server/options.c

  • Committer: Package Import Robot
  • Author(s): Luke Yelavich, Samuel Thibault, Luke Yelavich, Jason White, David Henningsson
  • Date: 2013-11-11 16:38:46 UTC
  • mfrom: (1.1.19)
  • Revision ID: package-import@ubuntu.com-20131111163846-lvu37ypp5sy9z5so
Tags: 0.8-0ubuntu1
[ Samuel Thibault ]
* debian/control: Set libspeechd2 multi-arch: same.
* debian/rules: Set multiarch libdir.
* debian/libspeechd-dev.install,libspeechd2.install,
  speech-dispatcher.install: Use multiarch libdir.
* Do not depend on dpkg | install-info, now that we use the install-info
  trigger.
* Bump Standards-Version to 3.9.5.
* Bump dotconf dependency to >= 1.3.

[ Luke Yelavich ]
* New upstream release
* debian/patches/infinite-loop.patch: Refreshed
* Dropped patches:
  - debian/patches/build-doc.patch
  - debian/patches/procname.patch
  - debian/patches/paths+files.patch
  - debian/patches/pthread.patch
* Add libltdl-dev and intltool to build-depends
* Update packaging for speech-dispatcher python 3 bindings.
* Move speech-dispatcher modules to an architecture independant dir, since
  modules can be written in any language, and i386 only modules can be
  used on amd64 systems
* Create separate audio plugins package
* Convert to debhelper 7+ packaging.
* Use dh-autoreconf to handle autotools file rebuilds.
* Update standards version to 3.9.3.
* Add X-Python-Version related fields to debian/control.
* Patch in the speech-dispatcher-cs.texi file since it was forgotten in the
  0.8 tarball
* Add translations to speech-dispatcher
* Merge from debian unreleased git.  Remaining changes:
  - Moved the flite output module to a separate package, and added
    it to suggests, we don't want flite on the Ubuntu CD image
  - Don't build depend on libaudio-dev or libao-dev, Ubuntu CD size is an
    issue, every little bit helps
  - debian/gbp.conf: Adjust for the Ubuntu git branch
  - Python3-speechd needs to conflict against python-speechd

[ Jason White ]
* Raise level of subsection in fdl.texi to correct document structure.

[ David Henningsson ]
* debian/patches/pulse-default-latency.patch:
  Default to 20 ms latency instead of 1 ms latency (LP: #1208826)

[ Luke Yelavich ]
* spd_audio: Expose dlopened library's symbols to libs it loads. Thanks to
  Christopher Brannon <chris@the-brannons.com> for the patch, taken from
  the speech-dispatcher mailing list.

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
/* NOTE: Be careful not to include options.h, we would
25
25
   get repetitive initializations warnings */
26
26
 
 
27
#ifdef HAVE_CONFIG_H
 
28
#include <config.h>
 
29
#endif
 
30
 
27
31
#include <sys/stat.h>
28
32
 
29
33
#include "speechd.h"
30
34
 
31
35
#include "options.h"
32
36
 
33
 
void
34
 
options_print_help(char *argv[])
 
37
#include <i18n.h>
 
38
 
 
39
static const struct option spd_long_options[] = {
 
40
        {"run-daemon", 0, 0, 'd'},
 
41
        {"run-single", 0, 0, 's'},
 
42
        {"spawn", 0, 0, 'a'},
 
43
        {"log-level", 1, 0, 'l'},
 
44
        {"log-dir", required_argument, 0, 'L'},
 
45
        {"communication-method", 1, 0, 'c'},
 
46
        {"socket-path", 1, 0, 'S'},
 
47
        {"port", 1, 0, 'p'},
 
48
        {"pid-file", 1, 0, 'P'},
 
49
        {"config-dir", required_argument, 0, 'C'},
 
50
        {"version", 0, 0, 'v'},
 
51
        {"debug", 0, 0, 'D'},
 
52
        {"help", 0, 0, 'h'},
 
53
        {0, 0, 0, 0}
 
54
};
 
55
 
 
56
static const char *const spd_short_options = "dsal:L:c:S:p:P:C:vDh";
 
57
 
 
58
void options_print_help(char *argv[])
35
59
{
36
 
    assert(argv);
37
 
    assert(argv[0]);
 
60
        assert(argv);
 
61
        assert(argv[0]);
38
62
 
39
 
    printf("Usage: %s [-{d|s}] [-l {1|2|3|4|5}] [-c com_method] [-S socket_path] [-p port] | [-v] | [-h]\n", argv[0]);
40
 
    printf("Speech Dispatcher -- Common interface for Speech Synthesis (GNU GPL)\n\n");
41
 
    printf("-d, --run-daemon     -      Run as a daemon\n"
42
 
    "-s, --run-single     -      Run as single application\n"
43
 
    "-a, --spawn          -      Start only if autospawn is not disabled\n"
44
 
    "-l, --log-level      -      Set log level (1..5)\n"
45
 
    "-c, --communication-method  Communication method to use (unix_socket or inet_socket)\n"
46
 
    "-S, --socket-path    -      Socket path to use for 'unix_socket' method (filesystem path or 'default')\n"
47
 
    "-p, --port           -      Specify a port number for 'inet_socket' method\n"
48
 
    "-P, --pid-file       -      Set path to pid file\n"
49
 
    "-C, --config-dir     -      Set path to configuration\n"
50
 
    "-v, --version        -      Report version of this program\n"
51
 
    "-D, --debug          -      Output debugging information into /tmp/.speech-dispatcher\n"
52
 
    "-h, --help           -      Print this info\n\n"
53
 
    "Copyright (C) 2003, 2004, 2006, 2007, 2008, 2010 Brailcom, o.p.s.\n"
54
 
    "This is free software; you can redistribute it and/or modify it\n"
55
 
    "under the terms of the GNU General Public License as published by\n"
56
 
    "the Free Software Foundation; either version 2, or (at your option)\n"
57
 
    "any later version. Please see COPYING for more details.\n\n"
58
 
    "Please report bugs to <speechd-bugs@freebsoft.org>\n\n");
 
63
        printf(_("Usage: "));
 
64
        printf
 
65
            ("%s [-{d|s}] [-l {1|2|3|4|5}] [-c com_method] [-S socket_path] [-p port] | [-v] | [-h]\n",
 
66
             argv[0]);
 
67
        printf(_("%s -- Common interface for Speech Synthesis %s\n\n"),
 
68
               "Speech Dispatcher", "(GNU GPL)");
 
69
        printf("-d, --run-daemon\t");
 
70
        printf(_("Run as a daemon\n"));
 
71
        printf("-s, --run-single\t");
 
72
        printf(_("Run as single application\n"));
 
73
        printf("-a, --spawn\t\t");
 
74
        printf(_("Start only if autospawn is not disabled\n"));
 
75
        printf("-l, --log-level\t\t");
 
76
        printf(_("Set log level (between %d and %d)\n"), 1, 5);
 
77
        printf("-L, --log-dir\t\t");
 
78
        printf(_("Set path to logging\n"));
 
79
        printf("-c, --communication-method\t");
 
80
        printf(_("Communication method to use ('%s' or '%s')\n"), "unix_socket",
 
81
               "inet_socket");
 
82
        printf("-S, --socket-path\t");
 
83
        printf(_
 
84
               ("Socket path to use for '%s' method (filesystem path or '%s')\n"),
 
85
               "unix_socket", "default");
 
86
        printf("-p, --port\t\t");
 
87
        printf(_("Specify a port number for '%s' method\n"), "inet_socket");
 
88
        printf("-P, --pid-file\t\t");
 
89
        printf(_("Set path to pid file\n"));
 
90
        printf("-C, --config-dir\t");
 
91
        printf(_("Set path to configuration\n"));
 
92
        printf("-v, --version\t\t");
 
93
        printf(_("Report version of this program\n"));
 
94
        printf("-D, --debug\t\t");
 
95
        printf(_("Output debugging information into %s\n"),
 
96
               "/tmp/.speech-dispatcher");
 
97
        printf("-h, --help\t\t");
 
98
        printf(_("Print this info\n"));
 
99
        printf("\n");
 
100
        printf(_
 
101
               ("Copyright (C) %d-%d Brailcom, o.p.s.\n"
 
102
                "This is free software; you can redistribute it and/or modify it\n"
 
103
                "under the terms of the GNU General Public License as published by\n"
 
104
                "the Free Software Foundation; either version 2, or (at your option)\n"
 
105
                "any later version. Please see COPYING for more details.\n\n"
 
106
                "Please report bugs to %s\n\n"), 2002, 2012, PACKAGE_BUGREPORT);
59
107
 
60
108
}
61
109
 
62
 
void
63
 
options_print_version(void)
 
110
void options_print_version(void)
64
111
{
65
 
    printf("%s %s\n", PACKAGE, VERSION);
66
 
    printf("Copyright (C) 2003, 2004, 2006, 2007, 2008, 2010 Brailcom, o.p.s.\n"
67
 
           "Speech Dispatcher comes with ABSOLUTELY NO WARRANTY.\n"
68
 
           "You may redistribute copies of Speech Dispatcher\n"
69
 
           "under the terms of the GNU General Public License.\n"
70
 
           "For more information about these matters, see the file named COPYING.\n"
71
 
           );
 
112
        printf("%s %s\n", PACKAGE, VERSION);
 
113
        printf(_
 
114
               ("Copyright (C) %d-%d Brailcom, o.p.s.\n"
 
115
                "%s comes with ABSOLUTELY NO WARRANTY.\n"
 
116
                "You may redistribute copies of this program\n"
 
117
                "under the terms of the GNU General Public License.\n"
 
118
                "For more information about these matters, see the file named COPYING.\n"),
 
119
               2002, 2012, "Speech Dispatcher");
72
120
}
73
121
 
74
122
#define SPD_OPTION_SET_INT(param) \
79
127
    }
80
128
 
81
129
#define SPD_OPTION_SET_STR(param) \
82
 
    SpeechdOptions.param = strdup(optarg)
 
130
    SpeechdOptions.param = g_strdup(optarg)
83
131
 
84
 
void
85
 
options_parse(int argc, char *argv[])
 
132
void options_parse(int argc, char *argv[])
86
133
{
87
 
    char* tail_ptr;
88
 
    int c_opt;
89
 
    int option_index;
90
 
    int val;
91
 
    int ret;
92
 
 
93
 
    char *tmpdir;
94
 
    char *debug_logfile_path;
95
 
          
96
 
 
97
 
    assert (argc>0);
98
 
    assert(argv);
99
 
 
100
 
    while(1){
101
 
        option_index = 0;
102
 
    
103
 
        c_opt = getopt_long(argc, argv, spd_short_options, spd_long_options,
104
 
                            &option_index);
105
 
        if (c_opt == -1) break;
106
 
        switch(c_opt){
107
 
        case 'd': 
108
 
            spd_mode = SPD_MODE_DAEMON;
109
 
            break;
110
 
        case 's':
111
 
            spd_mode = SPD_MODE_SINGLE;
112
 
            break;
113
 
        case 'l':
114
 
            SPD_OPTION_SET_INT(log_level);         
115
 
            break;
116
 
        case 'c':
117
 
            SPD_OPTION_SET_STR(communication_method);
118
 
            SpeechdOptions.communication_method_set = 1;
119
 
            break;
120
 
        case 'S':
121
 
            SPD_OPTION_SET_STR(socket_path);
122
 
            SpeechdOptions.socket_path_set = 1;
123
 
            break;
124
 
        case 'p':
125
 
            SPD_OPTION_SET_INT(port);
126
 
            break;
127
 
        case 'a':
128
 
            SpeechdOptions.spawn = TRUE;
129
 
            break;
130
 
        case 'P':
131
 
            SPD_OPTION_SET_STR(pid_file);
132
 
            break;
133
 
        case 'C':
134
 
            SPD_OPTION_SET_STR(conf_dir);
135
 
            break;
136
 
        case 'v':
137
 
            options_print_version();
138
 
            exit(0);
139
 
            break;
140
 
        case 'D':
141
 
          tmpdir = g_strdup(getenv("TMPDIR"));
142
 
          if (!tmpdir)
143
 
            tmpdir = g_strdup("/tmp");
144
 
          SpeechdOptions.debug_destination=g_strdup_printf("%s/speechd-debug", tmpdir);
145
 
          spd_free(tmpdir);
146
 
 
147
 
          ret = mkdir(SpeechdOptions.debug_destination, S_IRWXU);
148
 
          if (ret){
149
 
            MSG(1, "Can't create additional debug destination in %s, reason %d-%s",
150
 
                SpeechdOptions.debug_destination, errno, strerror(errno));
151
 
            if (errno == EEXIST){
152
 
              MSG(1, "Debugging directory %s already exists, please delete it first",
153
 
                  SpeechdOptions.debug_destination);
154
 
            }
155
 
            exit(1);
156
 
          }
157
 
            
158
 
          debug_logfile_path = g_strdup_printf("%s/speech-dispatcher.log",
159
 
                                               SpeechdOptions.debug_destination);
160
 
          /* Open logfile for writing */
161
 
          debug_logfile = fopen(debug_logfile_path, "wx");
162
 
          spd_free(debug_logfile_path);
163
 
          if (debug_logfile == NULL){
164
 
            MSG(1, "Error: can't open additional debug logging file %s [%d-%s]!\n",
165
 
                debug_logfile_path, errno, strerror(errno));
166
 
            exit(1);
167
 
          }
168
 
          SpeechdOptions.debug = 1;
169
 
          break;
170
 
        case 'h':
171
 
            options_print_help(argv);
172
 
            exit(0);
173
 
            break;
174
 
        default:
175
 
            MSG(2, "Unrecognized option\n");
176
 
            options_print_help(argv);
177
 
            exit(1);
178
 
        }
179
 
    }
 
134
        char *tail_ptr;
 
135
        int c_opt;
 
136
        int option_index;
 
137
        int val;
 
138
        int ret;
 
139
 
 
140
        char *tmpdir;
 
141
        char *debug_logfile_path;
 
142
 
 
143
        assert(argc > 0);
 
144
        assert(argv);
 
145
 
 
146
        while (1) {
 
147
                option_index = 0;
 
148
 
 
149
                c_opt =
 
150
                    getopt_long(argc, argv, spd_short_options, spd_long_options,
 
151
                                &option_index);
 
152
                if (c_opt == -1)
 
153
                        break;
 
154
                switch (c_opt) {
 
155
                case 'd':
 
156
                        spd_mode = SPD_MODE_DAEMON;
 
157
                        break;
 
158
                case 's':
 
159
                        spd_mode = SPD_MODE_SINGLE;
 
160
                        break;
 
161
                case 'l':
 
162
                        SPD_OPTION_SET_INT(log_level);
 
163
                        break;
 
164
                case 'L':
 
165
                        SPD_OPTION_SET_STR(log_dir);
 
166
                        SpeechdOptions.log_dir_set = 1;
 
167
                        break;
 
168
                case 'c':
 
169
                        SPD_OPTION_SET_STR(communication_method);
 
170
                        SpeechdOptions.communication_method_set = 1;
 
171
                        break;
 
172
                case 'S':
 
173
                        SPD_OPTION_SET_STR(socket_path);
 
174
                        SpeechdOptions.socket_path_set = 1;
 
175
                        break;
 
176
                case 'p':
 
177
                        SPD_OPTION_SET_INT(port);
 
178
                        break;
 
179
                case 'a':
 
180
                        SpeechdOptions.spawn = TRUE;
 
181
                        break;
 
182
                case 'P':
 
183
                        SPD_OPTION_SET_STR(pid_file);
 
184
                        break;
 
185
                case 'C':
 
186
                        SPD_OPTION_SET_STR(conf_dir);
 
187
                        break;
 
188
                case 'v':
 
189
                        options_print_version();
 
190
                        exit(0);
 
191
                        break;
 
192
                case 'D':
 
193
                        tmpdir = g_strdup(getenv("TMPDIR"));
 
194
                        if (!tmpdir)
 
195
                                tmpdir = g_strdup("/tmp");
 
196
                        SpeechdOptions.debug_destination =
 
197
                            g_strdup_printf("%s/speechd-debug", tmpdir);
 
198
                        g_free(tmpdir);
 
199
 
 
200
                        ret = mkdir(SpeechdOptions.debug_destination, S_IRWXU);
 
201
                        if (ret) {
 
202
                                MSG(1,
 
203
                                    "Can't create additional debug destination in %s, reason %d-%s",
 
204
                                    SpeechdOptions.debug_destination, errno,
 
205
                                    strerror(errno));
 
206
                                if (errno == EEXIST) {
 
207
                                        MSG(1,
 
208
                                            "Debugging directory %s already exists, please delete it first",
 
209
                                            SpeechdOptions.debug_destination);
 
210
                                }
 
211
                                exit(1);
 
212
                        }
 
213
 
 
214
                        debug_logfile_path =
 
215
                            g_strdup_printf("%s/speech-dispatcher.log",
 
216
                                            SpeechdOptions.debug_destination);
 
217
                        /* Open logfile for writing */
 
218
                        debug_logfile = fopen(debug_logfile_path, "wx");
 
219
                        g_free(debug_logfile_path);
 
220
                        if (debug_logfile == NULL) {
 
221
                                MSG(1,
 
222
                                    "Error: can't open additional debug logging file %s [%d-%s]!\n",
 
223
                                    debug_logfile_path, errno, strerror(errno));
 
224
                                exit(1);
 
225
                        }
 
226
                        SpeechdOptions.debug = 1;
 
227
                        break;
 
228
                case 'h':
 
229
                        options_print_help(argv);
 
230
                        exit(0);
 
231
                        break;
 
232
                default:
 
233
                        MSG(2, "Unrecognized option\n");
 
234
                        options_print_help(argv);
 
235
                        exit(1);
 
236
                }
 
237
        }
180
238
}
 
239
 
181
240
#undef SPD_OPTION_SET_INT