Added --disable-extf to configure script
This commit is contained in:
parent
84795ec066
commit
5308d0c6af
@ -19,8 +19,10 @@
|
||||
*/
|
||||
|
||||
#include "mtproto-common.h"
|
||||
#include "config.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifndef DISABLE_EXTF
|
||||
static int cur_token_len;
|
||||
static char *cur_token;
|
||||
static int cur_token_real_len;
|
||||
@ -435,3 +437,4 @@ char *tglf_extf_fetch (struct paramed_type *T) {
|
||||
if (fetch_type_any (T) < 0) { return 0; }
|
||||
return out_buf;
|
||||
}
|
||||
#endif
|
||||
|
@ -1,5 +1,8 @@
|
||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||
|
||||
/* disable extf queries */
|
||||
#undef DISABLE_EXTF
|
||||
|
||||
/* Use libevent v1 */
|
||||
#undef EVENT_V1
|
||||
|
||||
|
14
configure
vendored
14
configure
vendored
@ -692,6 +692,7 @@ enable_option_checking
|
||||
with_openssl
|
||||
with_zlib
|
||||
enable_libconfig
|
||||
enable_extf
|
||||
enable_liblua
|
||||
with_progname
|
||||
'
|
||||
@ -1317,6 +1318,7 @@ Optional Features:
|
||||
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
|
||||
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
|
||||
--enable-libconfig/--disable-libconfig
|
||||
--enable-extf/--disable-extf
|
||||
--enable-liblua/--disable-liblua
|
||||
|
||||
Optional Packages:
|
||||
@ -4502,6 +4504,18 @@ 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_n "checking for liblua... " >&6; }
|
||||
# Check whether --enable-liblua was given.
|
||||
|
@ -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_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_ARG_ENABLE(liblua,[--enable-liblua/--disable-liblua],
|
||||
[
|
||||
|
175
generate.c
175
generate.c
@ -82,6 +82,11 @@ static char buf[1 << 20];
|
||||
int buf_size;
|
||||
int *buf_ptr = (int *)buf;
|
||||
int *buf_end;
|
||||
#ifndef DISABLE_EXTF
|
||||
int skip_only = 0;
|
||||
#else
|
||||
int skip_only = 1;
|
||||
#endif
|
||||
|
||||
int verbosity;
|
||||
|
||||
@ -872,6 +877,7 @@ void gen_constructor_store (struct tl_combinator *c) {
|
||||
sprintf (s, "T");
|
||||
|
||||
int *vars = malloc0 (c->var_num * 4);;
|
||||
assert (c->var_num <= 10);
|
||||
gen_uni_skip (c->result, s, vars, 1, 0);
|
||||
|
||||
if (c->name == NAME_INT) {
|
||||
@ -937,6 +943,7 @@ void gen_constructor_autocomplete (struct tl_combinator *c) {
|
||||
sprintf (s, "T");
|
||||
|
||||
int *vars = malloc0 (c->var_num * 4);;
|
||||
assert (c->var_num <= 10);
|
||||
gen_uni_skip (c->result, s, vars, 1, 0);
|
||||
|
||||
if (c->name == NAME_INT) {
|
||||
@ -1145,6 +1152,7 @@ void gen_function_store (struct tl_combinator *f) {
|
||||
int i;
|
||||
|
||||
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)) {
|
||||
if (f->args[i]->flags & FLAG_EXCL) {
|
||||
@ -1169,6 +1177,7 @@ void gen_function_autocomplete (struct tl_combinator *f) {
|
||||
int i;
|
||||
|
||||
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)) {
|
||||
if (f->args[i]->flags & FLAG_EXCL) {
|
||||
@ -1561,7 +1570,8 @@ int parse_tlo_file (void) {
|
||||
}
|
||||
|
||||
assert (buf_ptr == buf_end);
|
||||
|
||||
|
||||
|
||||
int j;
|
||||
for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type")) {
|
||||
tps[i]->name = 0;
|
||||
@ -1579,21 +1589,27 @@ int parse_tlo_file (void) {
|
||||
for (i = 0; i < tn; i++) {
|
||||
for (j = 0; j < tps[i]->constructors_num; j ++) {
|
||||
gen_constructor_skip (tps[i]->constructors[j]);
|
||||
gen_constructor_store (tps[i]->constructors[j]);
|
||||
gen_constructor_fetch (tps[i]->constructors[j]);
|
||||
gen_constructor_autocomplete (tps[i]->constructors[j]);
|
||||
if (!skip_only) {
|
||||
gen_constructor_store (tps[i]->constructors[j]);
|
||||
gen_constructor_fetch (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")) {
|
||||
gen_type_skip (tps[i]);
|
||||
gen_type_store (tps[i]);
|
||||
gen_type_fetch (tps[i]);
|
||||
gen_type_autocomplete (tps[i]);
|
||||
gen_type_do_autocomplete (tps[i]);
|
||||
if (!skip_only) {
|
||||
gen_type_store (tps[i]);
|
||||
gen_type_fetch (tps[i]);
|
||||
gen_type_autocomplete (tps[i]);
|
||||
gen_type_do_autocomplete (tps[i]);
|
||||
}
|
||||
}
|
||||
for (i = 0; i < fn; i++) {
|
||||
gen_function_store (fns[i]);
|
||||
gen_function_autocomplete (fns[i]);
|
||||
if (!skip_only) {
|
||||
for (i = 0; i < fn; i++) {
|
||||
gen_function_store (fns[i]);
|
||||
gen_function_autocomplete (fns[i]);
|
||||
}
|
||||
}
|
||||
printf ("int skip_type_any (struct paramed_type *T) {\n");
|
||||
printf (" switch (T->type->name) {\n");
|
||||
@ -1603,76 +1619,78 @@ int parse_tlo_file (void) {
|
||||
}
|
||||
printf (" default: return -1; }\n");
|
||||
printf ("}\n");
|
||||
printf ("int store_type_any (struct paramed_type *T) {\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) {
|
||||
printf (" case 0x%08x: return store_type_%s (T);\n", tps[i]->name, tps[i]->print_id);
|
||||
printf (" case 0x%08x: return store_type_bare_%s (T);\n", ~tps[i]->name, tps[i]->print_id);
|
||||
}
|
||||
printf (" default: return -1; }\n");
|
||||
printf ("}\n");
|
||||
printf ("int fetch_type_any (struct paramed_type *T) {\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) {
|
||||
printf (" case 0x%08x: return fetch_type_%s (T);\n", tps[i]->name, tps[i]->print_id);
|
||||
printf (" case 0x%08x: return fetch_type_bare_%s (T);\n", ~tps[i]->name, tps[i]->print_id);
|
||||
}
|
||||
printf (" default: return -1; }\n");
|
||||
printf ("}\n");
|
||||
printf ("int autocomplete_type_any (struct paramed_type *T) {\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) {
|
||||
printf (" case 0x%08x: return autocomplete_type_%s (T);\n", tps[i]->name, tps[i]->print_id);
|
||||
printf (" case 0x%08x: return autocomplete_type_bare_%s (T);\n", ~tps[i]->name, tps[i]->print_id);
|
||||
}
|
||||
printf (" default: return -1; }\n");
|
||||
printf ("}\n");
|
||||
printf ("struct paramed_type *store_function_any (void) {\n");
|
||||
printf (" if (cur_token_len != 1 || *cur_token != '(') { return 0; }\n");
|
||||
printf (" local_next_token ();\n");
|
||||
printf (" if (cur_token_len == 1 || *cur_token == '.') { \n");
|
||||
printf (" local_next_token ();\n");
|
||||
printf (" if (cur_token_len != 1 || *cur_token != '=') { return 0; }\n");
|
||||
printf (" local_next_token ();\n");
|
||||
printf (" };\n");
|
||||
printf (" if (cur_token_len < 0) { return 0; }\n");
|
||||
for (i = 0; i < fn; i++) {
|
||||
printf (" if (cur_token_len == %d && !memcmp (cur_token, \"%s\", cur_token_len)) {\n", (int)strlen (fns[i]->id), fns[i]->id);
|
||||
printf (" out_int (0x%08x);\n", fns[i]->name);
|
||||
if (!skip_only) {
|
||||
printf ("int store_type_any (struct paramed_type *T) {\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) {
|
||||
printf (" case 0x%08x: return store_type_%s (T);\n", tps[i]->name, tps[i]->print_id);
|
||||
printf (" case 0x%08x: return store_type_bare_%s (T);\n", ~tps[i]->name, tps[i]->print_id);
|
||||
}
|
||||
printf (" default: return -1; }\n");
|
||||
printf ("}\n");
|
||||
printf ("int fetch_type_any (struct paramed_type *T) {\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) {
|
||||
printf (" case 0x%08x: return fetch_type_%s (T);\n", tps[i]->name, tps[i]->print_id);
|
||||
printf (" case 0x%08x: return fetch_type_bare_%s (T);\n", ~tps[i]->name, tps[i]->print_id);
|
||||
}
|
||||
printf (" default: return -1; }\n");
|
||||
printf ("}\n");
|
||||
printf ("int autocomplete_type_any (struct paramed_type *T) {\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) {
|
||||
printf (" case 0x%08x: return autocomplete_type_%s (T);\n", tps[i]->name, tps[i]->print_id);
|
||||
printf (" case 0x%08x: return autocomplete_type_bare_%s (T);\n", ~tps[i]->name, tps[i]->print_id);
|
||||
}
|
||||
printf (" default: return -1; }\n");
|
||||
printf ("}\n");
|
||||
printf ("struct paramed_type *store_function_any (void) {\n");
|
||||
printf (" if (cur_token_len != 1 || *cur_token != '(') { return 0; }\n");
|
||||
printf (" local_next_token ();\n");
|
||||
printf (" if (cur_token_len == 1 || *cur_token == '.') { \n");
|
||||
printf (" local_next_token ();\n");
|
||||
printf (" struct paramed_type *P = store_function_%s ();\n", fns[i]->print_id);
|
||||
printf (" if (!P) { return 0; }\n");
|
||||
printf (" if (cur_token_len != 1 || *cur_token != ')') { return 0; }\n");
|
||||
printf (" if (cur_token_len != 1 || *cur_token != '=') { return 0; }\n");
|
||||
printf (" local_next_token ();\n");
|
||||
printf (" return P;\n");
|
||||
printf (" }\n");
|
||||
printf (" };\n");
|
||||
printf (" if (cur_token_len < 0) { return 0; }\n");
|
||||
for (i = 0; i < fn; i++) {
|
||||
printf (" if (cur_token_len == %d && !memcmp (cur_token, \"%s\", cur_token_len)) {\n", (int)strlen (fns[i]->id), fns[i]->id);
|
||||
printf (" out_int (0x%08x);\n", fns[i]->name);
|
||||
printf (" local_next_token ();\n");
|
||||
printf (" struct paramed_type *P = store_function_%s ();\n", fns[i]->print_id);
|
||||
printf (" if (!P) { return 0; }\n");
|
||||
printf (" if (cur_token_len != 1 || *cur_token != ')') { return 0; }\n");
|
||||
printf (" local_next_token ();\n");
|
||||
printf (" return P;\n");
|
||||
printf (" }\n");
|
||||
}
|
||||
printf (" return 0;\n");
|
||||
printf ("}\n");
|
||||
printf ("int do_autocomplete_function (const char *text, int text_len, int index, char **R) {\n");
|
||||
printf (" index ++;\n");
|
||||
int i;
|
||||
for (i = 0; i < fn; i++) {
|
||||
printf (" if (index == %d) { if (!strncmp (text, \"%s\", text_len)) { *R = tstrdup (\"%s\"); return index; } else { index ++; }}\n", i, fns[i]->id, fns[i]->id);
|
||||
}
|
||||
printf (" *R = 0;\n");
|
||||
printf (" return 0;\n");
|
||||
printf ("}\n");
|
||||
printf ("struct paramed_type *autocomplete_function_any (void) {\n");
|
||||
printf (" expect_token_ptr_autocomplete (\"(\", 1);\n");
|
||||
printf (" if (cur_token_len == -3) { set_autocomplete_type (do_autocomplete_function); }\n");
|
||||
printf (" if (cur_token_len < 0) { return 0; }\n");
|
||||
for (i = 0; i < fn; i++) {
|
||||
printf (" if (cur_token_len == %d && !memcmp (cur_token, \"%s\", cur_token_len)) {\n", (int)strlen (fns[i]->id), fns[i]->id);
|
||||
printf (" local_next_token ();\n");
|
||||
printf (" struct paramed_type *P = autocomplete_function_%s ();\n", fns[i]->print_id);
|
||||
printf (" if (!P) { return 0; }\n");
|
||||
printf (" expect_token_ptr_autocomplete (\")\", 1);\n");
|
||||
printf (" return P;\n");
|
||||
printf (" }\n");
|
||||
}
|
||||
printf (" return 0;\n");
|
||||
printf ("}\n");
|
||||
}
|
||||
printf (" return 0;\n");
|
||||
printf ("}\n");
|
||||
printf ("int do_autocomplete_function (const char *text, int text_len, int index, char **R) {\n");
|
||||
printf (" index ++;\n");
|
||||
int i;
|
||||
for (i = 0; i < fn; i++) {
|
||||
printf (" if (index == %d) { if (!strncmp (text, \"%s\", text_len)) { *R = tstrdup (\"%s\"); return index; } else { index ++; }}\n", i, fns[i]->id, fns[i]->id);
|
||||
}
|
||||
printf (" *R = 0;\n");
|
||||
printf (" return 0;\n");
|
||||
printf ("}\n");
|
||||
printf ("struct paramed_type *autocomplete_function_any (void) {\n");
|
||||
printf (" expect_token_ptr_autocomplete (\"(\", 1);\n");
|
||||
printf (" if (cur_token_len == -3) { set_autocomplete_type (do_autocomplete_function); }\n");
|
||||
printf (" if (cur_token_len < 0) { return 0; }\n");
|
||||
for (i = 0; i < fn; i++) {
|
||||
printf (" if (cur_token_len == %d && !memcmp (cur_token, \"%s\", cur_token_len)) {\n", (int)strlen (fns[i]->id), fns[i]->id);
|
||||
printf (" local_next_token ();\n");
|
||||
printf (" struct paramed_type *P = autocomplete_function_%s ();\n", fns[i]->print_id);
|
||||
printf (" if (!P) { return 0; }\n");
|
||||
printf (" expect_token_ptr_autocomplete (\")\", 1);\n");
|
||||
printf (" return P;\n");
|
||||
printf (" }\n");
|
||||
}
|
||||
printf (" return 0;\n");
|
||||
printf ("}\n");
|
||||
} else {
|
||||
for (i = 0; i < tn; i++) {
|
||||
for (j = 0; j < tps[i]->constructors_num; j ++) {
|
||||
@ -1725,7 +1743,6 @@ int parse_tlo_file (void) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -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) {
|
||||
static int len, index;
|
||||
#ifndef DISABLE_EXTF
|
||||
static int len;
|
||||
#endif
|
||||
static int index;
|
||||
static enum command_argument mode;
|
||||
static char *command_pos;
|
||||
static int command_len;
|
||||
@ -1267,7 +1270,9 @@ char *command_generator (const char *text, int state) {
|
||||
c = rl_line_buffer[rl_point];
|
||||
rl_line_buffer[rl_point] = 0;
|
||||
if (!state) {
|
||||
#ifndef DISABLE_EXTF
|
||||
len = strlen (text);
|
||||
#endif
|
||||
index = -1;
|
||||
|
||||
mode = get_complete_mode ();
|
||||
@ -1314,10 +1319,12 @@ char *command_generator (const char *text, int state) {
|
||||
index = complete_string_list (modifiers, index, command_pos, command_len, &R);
|
||||
if (c) { rl_line_buffer[rl_point] = c; }
|
||||
return R;
|
||||
#ifndef DISABLE_EXTF
|
||||
case ca_extf:
|
||||
index = tglf_extf_autocomplete (text, len, index, &R, rl_line_buffer, rl_point);
|
||||
if (c) { rl_line_buffer[rl_point] = c; }
|
||||
return R;
|
||||
#endif
|
||||
default:
|
||||
if (c) { rl_line_buffer[rl_point] = c; }
|
||||
return 0;
|
||||
|
@ -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) {
|
||||
if (q->callback) {
|
||||
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
|
||||
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) {
|
||||
struct tgl_dc *D = _D;
|
||||
|
Loading…
Reference in New Issue
Block a user