Added safe_quit query. Useful in pipe mode
This commit is contained in:
parent
649efc2737
commit
069fe471ed
@ -49,6 +49,8 @@ char *default_prompt = "> ";
|
||||
int unread_messages;
|
||||
int msg_num_mode;
|
||||
|
||||
int safe_quit;
|
||||
|
||||
int in_readline;
|
||||
int readline_active;
|
||||
|
||||
@ -304,6 +306,7 @@ char *commands[] = {
|
||||
"status_offline",
|
||||
"contacts_search",
|
||||
"quit",
|
||||
"safe_quit",
|
||||
"send_audio",
|
||||
"load_audio",
|
||||
"view_audio",
|
||||
@ -1062,6 +1065,8 @@ void interpreter (char *line UU) {
|
||||
chat_mode_id = id;
|
||||
} else if (IS_WORD ("quit")) {
|
||||
exit (0);
|
||||
} else if (IS_WORD ("safe_quit")) {
|
||||
safe_quit = 1;
|
||||
}
|
||||
}
|
||||
#undef IS_WORD
|
||||
|
7
loop.c
7
loop.c
@ -59,6 +59,8 @@ extern int binlog_enabled;
|
||||
extern int unknown_user_list_pos;
|
||||
extern int unknown_user_list[];
|
||||
int register_mode;
|
||||
extern int safe_quit;
|
||||
extern int queries_num;
|
||||
|
||||
int unread_messages;
|
||||
void got_it (char *line, int len);
|
||||
@ -93,6 +95,11 @@ void net_loop (int flags, int (*is_end)(void)) {
|
||||
}
|
||||
}
|
||||
connections_poll_result (fds + cc, x - cc);
|
||||
if (safe_quit && !queries_num) {
|
||||
printf ("All done. Exit\n");
|
||||
rl_callback_handler_remove ();
|
||||
exit (0);
|
||||
}
|
||||
if (unknown_user_list_pos) {
|
||||
do_get_user_list_info_silent (unknown_user_list_pos, unknown_user_list);
|
||||
unknown_user_list_pos = 0;
|
||||
|
@ -66,6 +66,8 @@ long long cur_downloaded_bytes;
|
||||
extern int binlog_enabled;
|
||||
extern int sync_from_start;
|
||||
|
||||
int queries_num;
|
||||
|
||||
void out_peer_id (peer_id_t id);
|
||||
#define QUERY_TIMEOUT 6.0
|
||||
|
||||
@ -150,6 +152,7 @@ struct query *send_query (struct dc *DC, int ints, void *data, struct query_meth
|
||||
insert_event_timer (&q->ev);
|
||||
|
||||
q->extra = extra;
|
||||
queries_num ++;
|
||||
return q;
|
||||
}
|
||||
|
||||
@ -188,6 +191,7 @@ void query_error (long long id) {
|
||||
free (q->data);
|
||||
free (q);
|
||||
}
|
||||
queries_num --;
|
||||
}
|
||||
|
||||
#define MAX_PACKED_SIZE (1 << 24)
|
||||
@ -255,6 +259,7 @@ void query_result (long long id UU) {
|
||||
in_ptr = end;
|
||||
in_end = eend;
|
||||
}
|
||||
queries_num --;
|
||||
}
|
||||
|
||||
#define event_timer_cmp(a,b) ((a)->timeout > (b)->timeout ? 1 : ((a)->timeout < (b)->timeout ? -1 : (memcmp (a, b, sizeof (struct event_timer)))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user