queries.h 2.19 KB
Newer Older
1 2
/* 
    This file is part of tgl-library
3

4 5 6 7
    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.
8

9
    This library is distributed in the hope that it will be useful,
10
    but WITHOUT ANY WARRANTY; without even the implied warranty of
11 12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.
13

14 15 16
    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
17

18
    Copyright Vitaly Valtman 2013-2014
19
*/
Vysheng's avatar
Vysheng committed
20
//#include "net.h"
Vysheng's avatar
Vysheng committed
21 22
#ifndef __QUERIES_H__
#define __QUERIES_H__
23
#include "structures.h"
vysheng's avatar
vysheng committed
24
#include "auto.h"
Vysheng's avatar
Vysheng committed
25
#include "tgl-layout.h"
Vysheng's avatar
Vysheng committed
26

Vysheng's avatar
Vysheng committed
27 28
struct event;

Vysheng's avatar
Vysheng committed
29
#define QUERY_ACK_RECEIVED 1
30
#define QUERY_FORCE_SEND 2
Vysheng's avatar
Vysheng committed
31 32 33 34 35 36

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);
vysheng's avatar
vysheng committed
37
  struct paramed_type *type;
Vysheng's avatar
Vysheng committed
38 39 40 41 42 43
};

struct query {
  long long msg_id;
  int data_len;
  int flags;
44
  int seq_no;
45
  long long session_id;
Vysheng's avatar
Vysheng committed
46 47
  void *data;
  struct query_methods *methods;
Vysheng's avatar
Vysheng committed
48
  struct event *ev;
vvaltman's avatar
vvaltman committed
49 50
  struct tgl_dc *DC;
  struct tgl_session *session;
51
  struct paramed_type *type;
52
  void *extra;
vysheng's avatar
vysheng committed
53 54
  void *callback;
  void *callback_extra;
Vysheng's avatar
Vysheng committed
55 56 57
};


vvaltman's avatar
vvaltman committed
58
struct query *tglq_send_query (struct tgl_dc *DC, int len, void *data, struct query_methods *methods, void *extra, void *callback, void *callback_extra);
Vysheng's avatar
Vysheng committed
59 60 61 62
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);
Vysheng's avatar
Vysheng committed
63 64 65 66

double next_timer_in (void);
void work_timers (void);

vysheng's avatar
vysheng committed
67
//extern struct query_methods help_get_config_methods;
Vysheng's avatar
Vysheng committed
68 69 70

double get_double_time (void);

71
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);
vysheng's avatar
vysheng committed
72 73 74

// For binlog

vysheng's avatar
vysheng committed
75 76
//int get_dh_config_on_answer (struct query *q);
//void fetch_dc_option (void);
Vysheng's avatar
Vysheng committed
77
#endif