Commit 5308d0c6 authored by Vysheng's avatar Vysheng

Added --disable-extf to configure script

parent 84795ec0
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
*/ */
#include "mtproto-common.h" #include "mtproto-common.h"
#include "config.h"
#include <string.h> #include <string.h>
#ifndef DISABLE_EXTF
static int cur_token_len; static int cur_token_len;
static char *cur_token; static char *cur_token;
static int cur_token_real_len; static int cur_token_real_len;
...@@ -435,3 +437,4 @@ char *tglf_extf_fetch (struct paramed_type *T) { ...@@ -435,3 +437,4 @@ char *tglf_extf_fetch (struct paramed_type *T) {
if (fetch_type_any (T) < 0) { return 0; } if (fetch_type_any (T) < 0) { return 0; }
return out_buf; return out_buf;
} }
#endif
/* config.h.in. Generated from configure.ac by autoheader. */ /* config.h.in. Generated from configure.ac by autoheader. */
/* disable extf queries */
#undef DISABLE_EXTF
/* Use libevent v1 */ /* Use libevent v1 */
#undef EVENT_V1 #undef EVENT_V1
......
...@@ -692,6 +692,7 @@ enable_option_checking ...@@ -692,6 +692,7 @@ enable_option_checking
with_openssl with_openssl
with_zlib with_zlib
enable_libconfig enable_libconfig
enable_extf
enable_liblua enable_liblua
with_progname with_progname
' '
...@@ -1317,6 +1318,7 @@ Optional Features: ...@@ -1317,6 +1318,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-libconfig/--disable-libconfig --enable-libconfig/--disable-libconfig
--enable-extf/--disable-extf
--enable-liblua/--disable-liblua --enable-liblua/--disable-liblua
Optional Packages: Optional Packages:
...@@ -4502,6 +4504,18 @@ fi ...@@ -4502,6 +4504,18 @@ fi
fi fi
# Check whether --enable-extf was given.
if test "${enable_extf+set}" = set; then :
enableval=$enable_extf;
if test "x$enableval" = "xno" ; then
$as_echo "#define DISABLE_EXTF 1" >>confdefs.h
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for liblua" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for liblua" >&5
$as_echo_n "checking for liblua... " >&6; } $as_echo_n "checking for liblua... " >&6; }
# Check whether --enable-liblua was given. # Check whether --enable-liblua was given.
......
...@@ -52,6 +52,14 @@ AC_ARG_ENABLE(libconfig,[--enable-libconfig/--disable-libconfig], ...@@ -52,6 +52,14 @@ AC_ARG_ENABLE(libconfig,[--enable-libconfig/--disable-libconfig],
AC_CHECK_LIB([config],[config_init],[],AC_MSG_ERROR([No libconfig found. Try --disable-libconfig])) AC_CHECK_LIB([config],[config_init],[],AC_MSG_ERROR([No libconfig found. Try --disable-libconfig]))
]) ])
AC_ARG_ENABLE(extf,[--enable-extf/--disable-extf],
[
if test "x$enableval" = "xno" ; then
AC_DEFINE([DISABLE_EXTF],[1],[disable extf queries])
fi
],[
])
AC_MSG_CHECKING([for liblua]) AC_MSG_CHECKING([for liblua])
AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua], AC_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua],
[ [
......
...@@ -82,6 +82,11 @@ static char buf[1 << 20]; ...@@ -82,6 +82,11 @@ static char buf[1 << 20];
int buf_size; int buf_size;
int *buf_ptr = (int *)buf; int *buf_ptr = (int *)buf;
int *buf_end; int *buf_end;
#ifndef DISABLE_EXTF
int skip_only = 0;
#else
int skip_only = 1;
#endif
int verbosity; int verbosity;
...@@ -872,6 +877,7 @@ void gen_constructor_store (struct tl_combinator *c) { ...@@ -872,6 +877,7 @@ void gen_constructor_store (struct tl_combinator *c) {
sprintf (s, "T"); sprintf (s, "T");
int *vars = malloc0 (c->var_num * 4);; int *vars = malloc0 (c->var_num * 4);;
assert (c->var_num <= 10);
gen_uni_skip (c->result, s, vars, 1, 0); gen_uni_skip (c->result, s, vars, 1, 0);
if (c->name == NAME_INT) { if (c->name == NAME_INT) {
...@@ -937,6 +943,7 @@ void gen_constructor_autocomplete (struct tl_combinator *c) { ...@@ -937,6 +943,7 @@ void gen_constructor_autocomplete (struct tl_combinator *c) {
sprintf (s, "T"); sprintf (s, "T");
int *vars = malloc0 (c->var_num * 4);; int *vars = malloc0 (c->var_num * 4);;
assert (c->var_num <= 10);
gen_uni_skip (c->result, s, vars, 1, 0); gen_uni_skip (c->result, s, vars, 1, 0);
if (c->name == NAME_INT) { if (c->name == NAME_INT) {
...@@ -1145,6 +1152,7 @@ void gen_function_store (struct tl_combinator *f) { ...@@ -1145,6 +1152,7 @@ void gen_function_store (struct tl_combinator *f) {
int i; int i;
int *vars = malloc0 (f->var_num * 4);; int *vars = malloc0 (f->var_num * 4);;
assert (f->var_num <= 10);
for (i = 0; i < f->args_num; i++) if (!(f->args[i]->flags & FLAG_OPT_VAR)) { for (i = 0; i < f->args_num; i++) if (!(f->args[i]->flags & FLAG_OPT_VAR)) {
if (f->args[i]->flags & FLAG_EXCL) { if (f->args[i]->flags & FLAG_EXCL) {
...@@ -1169,6 +1177,7 @@ void gen_function_autocomplete (struct tl_combinator *f) { ...@@ -1169,6 +1177,7 @@ void gen_function_autocomplete (struct tl_combinator *f) {
int i; int i;
int *vars = malloc0 (f->var_num * 4);; int *vars = malloc0 (f->var_num * 4);;
assert (f->var_num <= 10);
for (i = 0; i < f->args_num; i++) if (!(f->args[i]->flags & FLAG_OPT_VAR)) { for (i = 0; i < f->args_num; i++) if (!(f->args[i]->flags & FLAG_OPT_VAR)) {
if (f->args[i]->flags & FLAG_EXCL) { if (f->args[i]->flags & FLAG_EXCL) {
...@@ -1562,6 +1571,7 @@ int parse_tlo_file (void) { ...@@ -1562,6 +1571,7 @@ int parse_tlo_file (void) {
assert (buf_ptr == buf_end); assert (buf_ptr == buf_end);
int j; int j;
for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type")) { for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type")) {
tps[i]->name = 0; tps[i]->name = 0;
...@@ -1579,22 +1589,28 @@ int parse_tlo_file (void) { ...@@ -1579,22 +1589,28 @@ int parse_tlo_file (void) {
for (i = 0; i < tn; i++) { for (i = 0; i < tn; i++) {
for (j = 0; j < tps[i]->constructors_num; j ++) { for (j = 0; j < tps[i]->constructors_num; j ++) {
gen_constructor_skip (tps[i]->constructors[j]); gen_constructor_skip (tps[i]->constructors[j]);
if (!skip_only) {
gen_constructor_store (tps[i]->constructors[j]); gen_constructor_store (tps[i]->constructors[j]);
gen_constructor_fetch (tps[i]->constructors[j]); gen_constructor_fetch (tps[i]->constructors[j]);
gen_constructor_autocomplete (tps[i]->constructors[j]); gen_constructor_autocomplete (tps[i]->constructors[j]);
} }
} }
}
for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type")) { for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type")) {
gen_type_skip (tps[i]); gen_type_skip (tps[i]);
if (!skip_only) {
gen_type_store (tps[i]); gen_type_store (tps[i]);
gen_type_fetch (tps[i]); gen_type_fetch (tps[i]);
gen_type_autocomplete (tps[i]); gen_type_autocomplete (tps[i]);
gen_type_do_autocomplete (tps[i]); gen_type_do_autocomplete (tps[i]);
} }
}
if (!skip_only) {
for (i = 0; i < fn; i++) { for (i = 0; i < fn; i++) {
gen_function_store (fns[i]); gen_function_store (fns[i]);
gen_function_autocomplete (fns[i]); gen_function_autocomplete (fns[i]);
} }
}
printf ("int skip_type_any (struct paramed_type *T) {\n"); printf ("int skip_type_any (struct paramed_type *T) {\n");
printf (" switch (T->type->name) {\n"); printf (" switch (T->type->name) {\n");
for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type") && tps[i]->name) { for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type") && tps[i]->name) {
...@@ -1603,6 +1619,7 @@ int parse_tlo_file (void) { ...@@ -1603,6 +1619,7 @@ int parse_tlo_file (void) {
} }
printf (" default: return -1; }\n"); printf (" default: return -1; }\n");
printf ("}\n"); printf ("}\n");
if (!skip_only) {
printf ("int store_type_any (struct paramed_type *T) {\n"); printf ("int store_type_any (struct paramed_type *T) {\n");
printf (" switch (T->type->name) {\n"); printf (" switch (T->type->name) {\n");
for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type") && tps[i]->name) { for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type") && tps[i]->name) {
...@@ -1673,6 +1690,7 @@ int parse_tlo_file (void) { ...@@ -1673,6 +1690,7 @@ int parse_tlo_file (void) {
} }
printf (" return 0;\n"); printf (" return 0;\n");
printf ("}\n"); printf ("}\n");
}
} else { } else {
for (i = 0; i < tn; i++) { for (i = 0; i < tn; i++) {
for (j = 0; j < tps[i]->constructors_num; j ++) { for (j = 0; j < tps[i]->constructors_num; j ++) {
...@@ -1726,7 +1744,6 @@ int parse_tlo_file (void) { ...@@ -1726,7 +1744,6 @@ int parse_tlo_file (void) {
} }
return 0; return 0;
} }
......
...@@ -1252,7 +1252,10 @@ int complete_command_list (int index, const char *text, int len, char **R) { ...@@ -1252,7 +1252,10 @@ int complete_command_list (int index, const char *text, int len, char **R) {
} }
char *command_generator (const char *text, int state) { char *command_generator (const char *text, int state) {
static int len, index; #ifndef DISABLE_EXTF
static int len;
#endif
static int index;
static enum command_argument mode; static enum command_argument mode;
static char *command_pos; static char *command_pos;
static int command_len; static int command_len;
...@@ -1267,7 +1270,9 @@ char *command_generator (const char *text, int state) { ...@@ -1267,7 +1270,9 @@ char *command_generator (const char *text, int state) {
c = rl_line_buffer[rl_point]; c = rl_line_buffer[rl_point];
rl_line_buffer[rl_point] = 0; rl_line_buffer[rl_point] = 0;
if (!state) { if (!state) {
#ifndef DISABLE_EXTF
len = strlen (text); len = strlen (text);
#endif
index = -1; index = -1;
mode = get_complete_mode (); mode = get_complete_mode ();
...@@ -1314,10 +1319,12 @@ char *command_generator (const char *text, int state) { ...@@ -1314,10 +1319,12 @@ char *command_generator (const char *text, int state) {
index = complete_string_list (modifiers, index, command_pos, command_len, &R); index = complete_string_list (modifiers, index, command_pos, command_len, &R);
if (c) { rl_line_buffer[rl_point] = c; } if (c) { rl_line_buffer[rl_point] = c; }
return R; return R;
#ifndef DISABLE_EXTF
case ca_extf: case ca_extf:
index = tglf_extf_autocomplete (text, len, index, &R, rl_line_buffer, rl_point); index = tglf_extf_autocomplete (text, len, index, &R, rl_line_buffer, rl_point);
if (c) { rl_line_buffer[rl_point] = c; } if (c) { rl_line_buffer[rl_point] = c; }
return R; return R;
#endif
default: default:
if (c) { rl_line_buffer[rl_point] = c; } if (c) { rl_line_buffer[rl_point] = c; }
return 0; return 0;
......
...@@ -3809,6 +3809,7 @@ void tgl_do_import_card (int size, int *card, void (*callback)(void *callback_ex ...@@ -3809,6 +3809,7 @@ void tgl_do_import_card (int size, int *card, void (*callback)(void *callback_ex
} }
/* }}} */ /* }}} */
#ifndef DISABLE_EXTF
static int ext_query_on_answer (struct query *q UU) { static int ext_query_on_answer (struct query *q UU) {
if (q->callback) { if (q->callback) {
char *buf = tglf_extf_fetch (q->type); char *buf = tglf_extf_fetch (q->type);
...@@ -3831,6 +3832,13 @@ void tgl_do_send_extf (char *data, int data_len, void (*callback)(void *callback ...@@ -3831,6 +3832,13 @@ void tgl_do_send_extf (char *data, int data_len, void (*callback)(void *callback
tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &ext_query_methods, 0, callback, callback_extra); tglq_send_query (tgl_state.DC_working, packet_ptr - packet_buffer, packet_buffer, &ext_query_methods, 0, callback, callback_extra);
} }
} }
#else
void tgl_do_send_extf (char *data, int data_len, void (*callback)(void *callback_extra, int success, char *buf), void *callback_extra) {
if (callback) {
callback (callback_extra, 0, 0);
}
}
#endif
static void set_flag_4 (void *_D, int success) { static void set_flag_4 (void *_D, int success) {
struct tgl_dc *D = _D; struct tgl_dc *D = _D;
......
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