File: fdsetconv.c

package info (click to toggle)
speech-dispatcher 0.7-6.1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 6,224 kB
  • ctags: 2,250
  • sloc: ansic: 17,857; sh: 10,533; python: 1,148; lisp: 579; makefile: 333
file content (165 lines) | stat: -rw-r--r-- 4,060 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165

/*
 * fdsetconv.c - Conversion of types for Speech Dispatcher
 *
 * Copyright (C) 2001, 2002, 2003 Brailcom, o.p.s.
 *
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this package; see the file COPYING.  If not, write to
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 *
 * $Id: fdsetconv.c,v 1.5 2007-06-21 20:09:45 hanke Exp $
 */

#include "fdsetconv.h"

char*
EVoice2str(EVoiceType voice)
{
    char *str;

    switch (voice)
        {
        case MALE1: str = strdup("male1"); break;
        case MALE2: str = strdup("male2"); break;
        case MALE3: str = strdup("male3"); break;
        case FEMALE1: str = strdup("female1"); break;
        case FEMALE2: str = strdup("female2"); break;
        case FEMALE3: str = strdup("female3"); break;
        case CHILD_MALE: str = strdup("child_male"); break;
        case CHILD_FEMALE: str = strdup("child_female"); break;
        default: str = NULL;
        }

    return str;
}

EVoiceType
str2EVoice(char* str)
{
    EVoiceType voice;

    if (!strcmp(str, "male1")) voice = MALE1;
    else if (!strcmp(str, "male2")) voice = MALE2;
    else if (!strcmp(str, "male3")) voice = MALE3;
    else if (!strcmp(str, "female1")) voice = FEMALE1;
    else if (!strcmp(str, "female2")) voice = FEMALE2;
    else if (!strcmp(str, "female3")) voice = FEMALE3;
    else if (!strcmp(str, "child_male")) voice = CHILD_MALE;
    else if (!strcmp(str, "child_female")) voice = CHILD_FEMALE;
    else voice = NO_VOICE;

    return voice;
}

char*
EPunctMode2str(EPunctMode punct)
{
    char *str;

    switch (punct)
        {
        case PUNCT_NONE: str = strdup("none"); break;
        case PUNCT_ALL: str = strdup("all"); break;
        case PUNCT_SOME: str = strdup("some"); break;
        default: str = NULL;
        }

    return str;
}

EPunctMode
str2EPunctMode(char* str)
{
    EPunctMode punct;

    if (!strcmp(str, "none")) punct = PUNCT_NONE;
    else if (!strcmp(str, "all")) punct = PUNCT_ALL;
    else if (!strcmp(str, "some")) punct = PUNCT_SOME;
    else punct = -1;

    return punct;
}

char*
ESpellMode2str(ESpellMode spell)
{
    char *str;

    switch (spell)
        {
        case SPELLING_ON: str = strdup("on"); break;
        case SPELLING_OFF: str = strdup("off"); break;
        default: str = NULL;
        }

    return str;
}

ESpellMode
str2ESpellMode(char* str)
{
    ESpellMode spell;

    if (!strcmp(str, "on")) spell = SPELLING_ON;
    else if (!strcmp(str, "off")) spell = SPELLING_OFF;
    else spell = -1;

    return spell;
}

char*
ECapLetRecogn2str(ECapLetRecogn recogn)
{
    char *str;

    switch (recogn)
        {
        case RECOGN_NONE: str = strdup("none"); break;
        case RECOGN_SPELL: str = strdup("spell"); break;
        case RECOGN_ICON: str = strdup("icon"); break;
        default: str = NULL;
        }

    return str;
}

ECapLetRecogn
str2ECapLetRecogn(char* str)
{
    ECapLetRecogn recogn;

    if (!strcmp(str, "none")) recogn = RECOGN_NONE;
    else if (!strcmp(str, "spell")) recogn = RECOGN_SPELL;
    else if (!strcmp(str, "icon")) recogn = RECOGN_ICON;
    else recogn = -1;

    return recogn;
}


EVoiceType
str2intpriority(char* str)
{
    int priority;

    if (!strcmp(str, "important"))  priority = 1;
    else if (!strcmp(str, "text")) priority = 2;
    else if (!strcmp(str, "message")) priority = 3;
    else if (!strcmp(str, "notification")) priority = 4;
    else if (!strcmp(str, "progress")) priority = 5;
    else priority = -1;

    return priority;
}