2014-08-21 18:02:43 -04:00
|
|
|
/*
|
|
|
|
This file is part of tgl-library
|
2013-10-23 10:26:17 -04:00
|
|
|
|
2014-08-21 18:02:43 -04:00
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
2013-10-23 10:26:17 -04:00
|
|
|
|
2014-08-21 18:02:43 -04:00
|
|
|
This library is distributed in the hope that it will be useful,
|
2013-10-23 10:26:17 -04:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2014-08-21 18:02:43 -04:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
2013-10-23 10:26:17 -04:00
|
|
|
|
2014-08-21 18:02:43 -04:00
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2013-10-23 10:26:17 -04:00
|
|
|
|
2014-08-21 18:02:43 -04:00
|
|
|
Copyright Vitaly Valtman 2013-2014
|
2013-10-23 10:26:17 -04:00
|
|
|
*/
|
2014-08-14 14:03:33 -04:00
|
|
|
//#include "net.h"
|
2013-10-11 16:52:20 -04:00
|
|
|
#ifndef __QUERIES_H__
|
|
|
|
#define __QUERIES_H__
|
2013-10-31 19:18:34 -04:00
|
|
|
#include "structures.h"
|
2014-08-12 05:59:59 -04:00
|
|
|
#include "auto.h"
|
2014-08-13 11:55:16 -04:00
|
|
|
#include "tgl-layout.h"
|
2013-10-11 16:52:20 -04:00
|
|
|
|
2014-08-14 14:03:33 -04:00
|
|
|
struct event;
|
|
|
|
|
2013-10-11 16:52:20 -04:00
|
|
|
#define QUERY_ACK_RECEIVED 1
|
2014-08-29 09:33:15 -04:00
|
|
|
#define QUERY_FORCE_SEND 2
|
2013-10-11 16:52:20 -04:00
|
|
|
|
|
|
|
struct query;
|
|
|
|
struct query_methods {
|
|
|
|
int (*on_answer)(struct query *q);
|
|
|
|
int (*on_error)(struct query *q, int error_code, int len, char *error);
|
|
|
|
int (*on_timeout)(struct query *q);
|
2014-08-12 05:59:59 -04:00
|
|
|
struct paramed_type *type;
|
2013-10-11 16:52:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct query {
|
|
|
|
long long msg_id;
|
|
|
|
int data_len;
|
|
|
|
int flags;
|
2013-10-24 18:32:13 -04:00
|
|
|
int seq_no;
|
2014-08-29 09:33:15 -04:00
|
|
|
long long session_id;
|
2013-10-11 16:52:20 -04:00
|
|
|
void *data;
|
|
|
|
struct query_methods *methods;
|
2014-08-14 14:03:33 -04:00
|
|
|
struct event *ev;
|
2014-08-20 23:24:52 -04:00
|
|
|
struct tgl_dc *DC;
|
|
|
|
struct tgl_session *session;
|
2014-09-10 07:52:42 -04:00
|
|
|
struct paramed_type *type;
|
2013-10-18 15:30:24 -04:00
|
|
|
void *extra;
|
2014-08-13 21:31:24 -04:00
|
|
|
void *callback;
|
|
|
|
void *callback_extra;
|
2013-10-11 16:52:20 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2014-08-20 23:24:52 -04:00
|
|
|
struct query *tglq_send_query (struct tgl_dc *DC, int len, void *data, struct query_methods *methods, void *extra, void *callback, void *callback_extra);
|
2014-08-14 14:03:33 -04:00
|
|
|
void tglq_query_ack (long long id);
|
|
|
|
void tglq_query_error (long long id);
|
|
|
|
void tglq_query_result (long long id);
|
|
|
|
void tglq_query_restart (long long id);
|
2013-10-11 16:52:20 -04:00
|
|
|
|
|
|
|
double next_timer_in (void);
|
|
|
|
void work_timers (void);
|
|
|
|
|
2014-08-13 21:31:24 -04:00
|
|
|
//extern struct query_methods help_get_config_methods;
|
2013-10-11 16:52:20 -04:00
|
|
|
|
|
|
|
double get_double_time (void);
|
|
|
|
|
2014-08-29 09:33:15 -04:00
|
|
|
void tgl_do_send_bind_temp_key (struct tgl_dc *D, long long nonce, int expires_at, void *data, int len, long long msg_id);
|
2013-11-12 19:11:25 -05:00
|
|
|
|
|
|
|
// For binlog
|
|
|
|
|
2014-08-13 21:31:24 -04:00
|
|
|
//int get_dh_config_on_answer (struct query *q);
|
|
|
|
//void fetch_dc_option (void);
|
2013-10-11 16:52:20 -04:00
|
|
|
#endif
|