William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 1 | #include <linux/ctype.h> |
| 2 | #include "spk_types.h" |
| 3 | #include "spk_priv.h" |
| 4 | #include "speakup.h" |
| 5 | |
| 6 | static struct st_var_header var_headers[] = { |
William Hubbs | a1277d8 | 2010-10-15 22:13:39 -0500 | [diff] [blame] | 7 | { "version", VERSION, VAR_PROC, NULL, NULL }, |
| 8 | { "synth_name", SYNTH, VAR_PROC, NULL, NULL }, |
| 9 | { "keymap", KEYMAP, VAR_PROC, NULL, NULL }, |
| 10 | { "silent", SILENT, VAR_PROC, NULL, NULL }, |
| 11 | { "punc_some", PUNC_SOME, VAR_PROC, NULL, NULL }, |
| 12 | { "punc_most", PUNC_MOST, VAR_PROC, NULL, NULL }, |
| 13 | { "punc_all", PUNC_ALL, VAR_PROC, NULL, NULL }, |
| 14 | { "delimiters", DELIM, VAR_PROC, NULL, NULL }, |
| 15 | { "repeats", REPEATS, VAR_PROC, NULL, NULL }, |
| 16 | { "ex_num", EXNUMBER, VAR_PROC, NULL, NULL }, |
| 17 | { "characters", CHARS, VAR_PROC, NULL, NULL }, |
| 18 | { "synth_direct", SYNTH_DIRECT, VAR_PROC, NULL, NULL }, |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 19 | { "caps_start", CAPS_START, VAR_STRING, spk_str_caps_start, NULL }, |
| 20 | { "caps_stop", CAPS_STOP, VAR_STRING, spk_str_caps_stop, NULL }, |
William Hubbs | a1277d8 | 2010-10-15 22:13:39 -0500 | [diff] [blame] | 21 | { "delay_time", DELAY, VAR_TIME, NULL, NULL }, |
| 22 | { "trigger_time", TRIGGER, VAR_TIME, NULL, NULL }, |
| 23 | { "jiffy_delta", JIFFY, VAR_TIME, NULL, NULL }, |
| 24 | { "full_time", FULL, VAR_TIME, NULL, NULL }, |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 25 | { "spell_delay", SPELL_DELAY, VAR_NUM, &spk_spell_delay, NULL }, |
| 26 | { "bleeps", BLEEPS, VAR_NUM, &spk_bleeps, NULL }, |
| 27 | { "attrib_bleep", ATTRIB_BLEEP, VAR_NUM, &spk_attrib_bleep, NULL }, |
| 28 | { "bleep_time", BLEEP_TIME, VAR_TIME, &spk_bleep_time, NULL }, |
William Hubbs | a1277d8 | 2010-10-15 22:13:39 -0500 | [diff] [blame] | 29 | { "cursor_time", CURSOR_TIME, VAR_TIME, NULL, NULL }, |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 30 | { "punc_level", PUNC_LEVEL, VAR_NUM, &spk_punc_level, NULL }, |
| 31 | { "reading_punc", READING_PUNC, VAR_NUM, &spk_reading_punc, NULL }, |
| 32 | { "say_control", SAY_CONTROL, VAR_NUM, &spk_say_ctrl, NULL }, |
| 33 | { "say_word_ctl", SAY_WORD_CTL, VAR_NUM, &spk_say_word_ctl, NULL }, |
| 34 | { "no_interrupt", NO_INTERRUPT, VAR_NUM, &spk_no_intr, NULL }, |
| 35 | { "key_echo", KEY_ECHO, VAR_NUM, &spk_key_echo, NULL }, |
| 36 | { "bell_pos", BELL_POS, VAR_NUM, &spk_bell_pos, NULL }, |
William Hubbs | a1277d8 | 2010-10-15 22:13:39 -0500 | [diff] [blame] | 37 | { "rate", RATE, VAR_NUM, NULL, NULL }, |
| 38 | { "pitch", PITCH, VAR_NUM, NULL, NULL }, |
| 39 | { "vol", VOL, VAR_NUM, NULL, NULL }, |
| 40 | { "tone", TONE, VAR_NUM, NULL, NULL }, |
| 41 | { "punct", PUNCT, VAR_NUM, NULL, NULL }, |
| 42 | { "voice", VOICE, VAR_NUM, NULL, NULL }, |
| 43 | { "freq", FREQUENCY, VAR_NUM, NULL, NULL }, |
| 44 | { "lang", LANG, VAR_NUM, NULL, NULL }, |
| 45 | { "chartab", CHARTAB, VAR_PROC, NULL, NULL }, |
| 46 | { "direct", DIRECT, VAR_NUM, NULL, NULL }, |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 47 | }; |
| 48 | |
Shalin Mehta | ab06e0f | 2013-10-03 01:08:42 -0700 | [diff] [blame] | 49 | static struct st_var_header *var_ptrs[MAXVARS] = { NULL, NULL, NULL }; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 50 | |
| 51 | static struct punc_var_t punc_vars[] = { |
William Hubbs | a1277d8 | 2010-10-15 22:13:39 -0500 | [diff] [blame] | 52 | { PUNC_SOME, 1 }, |
| 53 | { PUNC_MOST, 2 }, |
| 54 | { PUNC_ALL, 3 }, |
| 55 | { DELIM, 4 }, |
| 56 | { REPEATS, 5 }, |
| 57 | { EXNUMBER, 6 }, |
| 58 | { -1, -1 }, |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 59 | }; |
| 60 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 61 | int spk_chartab_get_value(char *keyword) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 62 | { |
| 63 | int value = 0; |
| 64 | |
| 65 | if (!strcmp(keyword, "ALPHA")) |
| 66 | value = ALPHA; |
| 67 | else if (!strcmp(keyword, "B_CTL")) |
| 68 | value = B_CTL; |
| 69 | else if (!strcmp(keyword, "WDLM")) |
| 70 | value = WDLM; |
| 71 | else if (!strcmp(keyword, "A_PUNC")) |
| 72 | value = A_PUNC; |
| 73 | else if (!strcmp(keyword, "PUNC")) |
| 74 | value = PUNC; |
| 75 | else if (!strcmp(keyword, "NUM")) |
| 76 | value = NUM; |
| 77 | else if (!strcmp(keyword, "A_CAP")) |
| 78 | value = A_CAP; |
| 79 | else if (!strcmp(keyword, "B_CAPSYM")) |
| 80 | value = B_CAPSYM; |
| 81 | else if (!strcmp(keyword, "B_SYM")) |
| 82 | value = B_SYM; |
| 83 | return value; |
| 84 | } |
| 85 | |
| 86 | void speakup_register_var(struct var_t *var) |
| 87 | { |
| 88 | static char nothing[2] = "\0"; |
| 89 | int i; |
| 90 | struct st_var_header *p_header; |
| 91 | |
| 92 | BUG_ON(!var || var->var_id < 0 || var->var_id >= MAXVARS); |
| 93 | if (var_ptrs[0] == NULL) { |
| 94 | for (i = 0; i < MAXVARS; i++) { |
| 95 | p_header = &var_headers[i]; |
| 96 | var_ptrs[p_header->var_id] = p_header; |
| 97 | p_header->data = NULL; |
| 98 | } |
| 99 | } |
| 100 | p_header = var_ptrs[var->var_id]; |
| 101 | if (p_header->data != NULL) |
| 102 | return; |
| 103 | p_header->data = var; |
| 104 | switch (p_header->var_type) { |
| 105 | case VAR_STRING: |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 106 | spk_set_string_var(nothing, p_header, 0); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 107 | break; |
| 108 | case VAR_NUM: |
| 109 | case VAR_TIME: |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 110 | spk_set_num_var(0, p_header, E_DEFAULT); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 111 | break; |
| 112 | default: |
| 113 | break; |
| 114 | } |
| 115 | return; |
| 116 | } |
| 117 | |
| 118 | void speakup_unregister_var(enum var_id_t var_id) |
| 119 | { |
| 120 | struct st_var_header *p_header; |
| 121 | BUG_ON(var_id < 0 || var_id >= MAXVARS); |
| 122 | p_header = var_ptrs[var_id]; |
| 123 | p_header->data = NULL; |
| 124 | } |
| 125 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 126 | struct st_var_header *spk_get_var_header(enum var_id_t var_id) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 127 | { |
| 128 | struct st_var_header *p_header; |
| 129 | if (var_id < 0 || var_id >= MAXVARS) |
| 130 | return NULL; |
| 131 | p_header = var_ptrs[var_id]; |
| 132 | if (p_header->data == NULL) |
| 133 | return NULL; |
| 134 | return p_header; |
| 135 | } |
| 136 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 137 | struct st_var_header *spk_var_header_by_name(const char *name) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 138 | { |
| 139 | int i; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 140 | |
Dan Carpenter | 65545ea | 2013-05-09 21:31:59 +0300 | [diff] [blame] | 141 | if (!name) |
| 142 | return NULL; |
| 143 | |
| 144 | for (i = 0; i < MAXVARS; i++) { |
| 145 | if (strcmp(name, var_ptrs[i]->name) == 0) |
| 146 | return var_ptrs[i]; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 147 | } |
Dan Carpenter | 65545ea | 2013-05-09 21:31:59 +0300 | [diff] [blame] | 148 | return NULL; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 149 | } |
| 150 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 151 | struct var_t *spk_get_var(enum var_id_t var_id) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 152 | { |
| 153 | BUG_ON(var_id < 0 || var_id >= MAXVARS); |
William Hubbs | a1277d8 | 2010-10-15 22:13:39 -0500 | [diff] [blame] | 154 | BUG_ON(!var_ptrs[var_id]); |
| 155 | return var_ptrs[var_id]->data; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 156 | } |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 157 | EXPORT_SYMBOL_GPL(spk_get_var); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 158 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 159 | struct punc_var_t *spk_get_punc_var(enum var_id_t var_id) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 160 | { |
| 161 | struct punc_var_t *rv = NULL; |
| 162 | struct punc_var_t *where; |
| 163 | |
| 164 | where = punc_vars; |
| 165 | while ((where->var_id != -1) && (rv == NULL)) { |
| 166 | if (where->var_id == var_id) |
| 167 | rv = where; |
| 168 | else |
| 169 | where++; |
| 170 | } |
| 171 | return rv; |
| 172 | } |
| 173 | |
| 174 | /* handlers for setting vars */ |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 175 | int spk_set_num_var(int input, struct st_var_header *var, int how) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 176 | { |
| 177 | int val; |
| 178 | short ret = 0; |
| 179 | int *p_val = var->p_val; |
| 180 | int l; |
| 181 | char buf[32]; |
| 182 | char *cp; |
| 183 | struct var_t *var_data = var->data; |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 184 | |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 185 | if (var_data == NULL) |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 186 | return -ENODATA; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 187 | |
| 188 | if (how == E_NEW_DEFAULT) { |
| 189 | if (input < var_data->u.n.low || input > var_data->u.n.high) |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 190 | return -ERANGE; |
| 191 | var_data->u.n.default_val = input; |
| 192 | return 0; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 193 | } |
| 194 | if (how == E_DEFAULT) { |
| 195 | val = var_data->u.n.default_val; |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 196 | ret = -ERESTART; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 197 | } else { |
| 198 | if (how == E_SET) |
| 199 | val = input; |
| 200 | else |
| 201 | val = var_data->u.n.value; |
| 202 | if (how == E_INC) |
| 203 | val += input; |
| 204 | else if (how == E_DEC) |
| 205 | val -= input; |
| 206 | if (val < var_data->u.n.low || val > var_data->u.n.high) |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 207 | return -ERANGE; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 208 | } |
| 209 | var_data->u.n.value = val; |
| 210 | if (var->var_type == VAR_TIME && p_val != NULL) { |
| 211 | *p_val = msecs_to_jiffies(val); |
| 212 | return ret; |
| 213 | } |
| 214 | if (p_val != NULL) |
| 215 | *p_val = val; |
| 216 | if (var->var_id == PUNC_LEVEL) { |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 217 | spk_punc_mask = spk_punc_masks[val]; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 218 | return ret; |
| 219 | } |
| 220 | if (var_data->u.n.multiplier != 0) |
| 221 | val *= var_data->u.n.multiplier; |
| 222 | val += var_data->u.n.offset; |
| 223 | if (var->var_id < FIRST_SYNTH_VAR || synth == NULL) |
| 224 | return ret; |
| 225 | if (synth->synth_adjust != NULL) { |
| 226 | int status = synth->synth_adjust(var); |
| 227 | return (status != 0) ? status : ret; |
| 228 | } |
| 229 | if (!var_data->u.n.synth_fmt) |
| 230 | return ret; |
| 231 | if (var->var_id == PITCH) |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 232 | cp = spk_pitch_buff; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 233 | else |
| 234 | cp = buf; |
| 235 | if (!var_data->u.n.out_str) |
| 236 | l = sprintf(cp, var_data->u.n.synth_fmt, (int)val); |
| 237 | else |
William Hubbs | a1277d8 | 2010-10-15 22:13:39 -0500 | [diff] [blame] | 238 | l = sprintf(cp, |
| 239 | var_data->u.n.synth_fmt, var_data->u.n.out_str[val]); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 240 | synth_printf("%s", cp); |
| 241 | return ret; |
| 242 | } |
| 243 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 244 | int spk_set_string_var(const char *page, struct st_var_header *var, int len) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 245 | { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 246 | struct var_t *var_data = var->data; |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 247 | |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 248 | if (var_data == NULL) |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 249 | return -ENODATA; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 250 | if (len > MAXVARLEN) |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 251 | return -E2BIG; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 252 | if (!len) { |
William Hubbs | a1277d8 | 2010-10-15 22:13:39 -0500 | [diff] [blame] | 253 | if (!var_data->u.s.default_val) |
| 254 | return 0; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 255 | if (!var->p_val) |
| 256 | var->p_val = var_data->u.s.default_val; |
| 257 | if (var->p_val != var_data->u.s.default_val) |
| 258 | strcpy((char *)var->p_val, var_data->u.s.default_val); |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 259 | return -ERESTART; |
William Hubbs | a1277d8 | 2010-10-15 22:13:39 -0500 | [diff] [blame] | 260 | } else if (var->p_val) |
| 261 | strcpy((char *)var->p_val, page); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 262 | else |
Andy Shevchenko | 6a48f88 | 2013-03-28 11:02:44 +0200 | [diff] [blame] | 263 | return -E2BIG; |
| 264 | return 0; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 265 | } |
| 266 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 267 | /* spk_set_mask_bits sets or clears the punc/delim/repeat bits, |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 268 | * if input is null uses the defaults. |
| 269 | * values for how: 0 clears bits of chars supplied, |
| 270 | * 1 clears allk, 2 sets bits for chars */ |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 271 | int spk_set_mask_bits(const char *input, const int which, const int how) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 272 | { |
| 273 | u_char *cp; |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 274 | short mask = spk_punc_info[which].mask; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 275 | if (how&1) { |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 276 | for (cp = (u_char *)spk_punc_info[3].value; *cp; cp++) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 277 | spk_chartab[*cp] &= ~mask; |
| 278 | } |
| 279 | cp = (u_char *)input; |
Sachin Kamat | 15ab600 | 2013-05-13 15:30:42 +0530 | [diff] [blame] | 280 | if (!cp) |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 281 | cp = spk_punc_info[which].value; |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 282 | else { |
Nandini Hanumanthagowda | 1f2a55f | 2013-10-13 16:21:07 +0530 | [diff] [blame^] | 283 | for (; *cp; cp++) { |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 284 | if (*cp < SPACE) |
| 285 | break; |
| 286 | if (mask < PUNC) { |
| 287 | if (!(spk_chartab[*cp]&PUNC)) |
| 288 | break; |
| 289 | } else if (spk_chartab[*cp]&B_NUM) |
| 290 | break; |
| 291 | } |
| 292 | if (*cp) |
| 293 | return -EINVAL; |
| 294 | cp = (u_char *)input; |
| 295 | } |
| 296 | if (how&2) { |
Nandini Hanumanthagowda | 1f2a55f | 2013-10-13 16:21:07 +0530 | [diff] [blame^] | 297 | for (; *cp; cp++) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 298 | if (*cp > SPACE) |
| 299 | spk_chartab[*cp] |= mask; |
| 300 | } else { |
Nandini Hanumanthagowda | 1f2a55f | 2013-10-13 16:21:07 +0530 | [diff] [blame^] | 301 | for (; *cp; cp++) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 302 | if (*cp > SPACE) |
| 303 | spk_chartab[*cp] &= ~mask; |
| 304 | } |
| 305 | return 0; |
| 306 | } |
| 307 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 308 | char *spk_strlwr(char *s) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 309 | { |
| 310 | char *p; |
| 311 | if (s == NULL) |
| 312 | return NULL; |
| 313 | |
| 314 | for (p = s; *p; p++) |
| 315 | *p = tolower(*p); |
| 316 | return s; |
| 317 | } |
| 318 | |
Samuel Thibault | ca2beaf | 2013-01-02 02:37:40 +0100 | [diff] [blame] | 319 | char *spk_s2uchar(char *start, char *dest) |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 320 | { |
| 321 | int val = 0; |
Andy Shevchenko | 1627ab9 | 2013-03-28 11:02:43 +0200 | [diff] [blame] | 322 | val = simple_strtoul(skip_spaces(start), &start, 10); |
William Hubbs | c6e3fd2 | 2010-10-07 13:20:02 -0500 | [diff] [blame] | 323 | if (*start == ',') |
| 324 | start++; |
| 325 | *dest = (u_char)val; |
| 326 | return start; |
| 327 | } |