Commit 8ba66a86 authored by vvaltman's avatar vvaltman

proper way to handle interface errors

parent f9a7f195
......@@ -126,6 +126,8 @@ int is_same_word (const char *s, size_t l, const char *word) {
return s && word && strlen (word) == l && !memcmp (s, word, l);
}
void fail_interface (struct tgl_state *TLS, struct in_ev *ev, int error_code, const char *format, ...) __attribute__ (( format (printf, 4, 5)));
static void skip_wspc (void) {
while (*line_ptr && ((unsigned char)*line_ptr) <= ' ') {
line_ptr ++;
......@@ -1140,9 +1142,7 @@ void do_send_typing (struct command *command, int arg_num, struct arg args[], st
enum tgl_typing_status status = tgl_typing_typing; //de
if (args[1].num != NOT_FOUND) {
if (args[1].num > 0 && args[1].num > 10) {
TLS->error_code = ENOSYS;
TLS->error = strdup("illegal typing status");
print_fail(ev);
fail_interface (TLS, ev, ENOSYS, "illegal typing status");
return;
}
status = (enum tgl_typing_status) args[1].num; // if the status parameter is given, and is in range.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment