示例#1
0
int dispatch_cmd(otts_synth_plugin_t *synth, char *cmd_line)
{
	char *cmd = NULL;
	size_t cmd_len;
	char *msg = NULL;

	cmd_len = strcspn(cmd_line, " \t\n\r\f");
	cmd = g_strndup(cmd_line, cmd_len);
	pthread_mutex_lock(&module_stdout_mutex);

	if (!strcasecmp("audio", cmd)) {
		msg = do_audio(synth);
	} else if (!strcasecmp("set", cmd)) {
		msg = do_set(synth);
	} else if (!strcasecmp("speak", cmd)) {
		msg = do_speak(synth);
	} else if (!strcasecmp("key", cmd)) {
		msg = do_key(synth);
	} else if (!strcasecmp("sound_icon", cmd)) {
		msg = do_sound_icon(synth);
	} else if (!strcasecmp("char", cmd)) {
		msg = do_char(synth);
	} else if (!strcasecmp("pause", cmd)) {
		do_pause(synth);
	} else if (!strcasecmp("stop", cmd)) {
		do_stop(synth);
	} else if (!strcasecmp("list_voices", cmd)) {
		msg = do_list_voices(synth);
	} else if (!strcasecmp("loglevel", cmd)) {
		msg = do_loglevel(synth);
	} else if (!strcasecmp("debug", cmd)) {
		msg = do_debug(synth, cmd_line);
	} else if (!strcasecmp("quit", cmd)) {
		do_quit(synth);
	} else {
/*should we log?*/
		printf("300 ERR UNKNOWN COMMAND\n");
		fflush(stdout);
	}

	if (msg != NULL) {
		if (0 > printf("%s\n", msg)) {
			log_msg(OTTS_LOG_CRIT, "Broken pipe, exiting...\n");
			synth->close(2);
		}
		fflush(stdout);
		g_free(msg);
	}

	pthread_mutex_unlock(&module_stdout_mutex);
	g_free(cmd);

	return (0);
}
示例#2
0
 std::string speak() const
 {
     return do_speak();
 }