This commit is contained in:
vysheng 2014-08-12 09:59:59 +00:00
parent 35f100b95a
commit 811df367cd
13 changed files with 1635 additions and 36 deletions

View File

@ -14,21 +14,29 @@ HEADERS= ${srcdir}/constants.h ${srcdir}/include.h ${srcdir}/interface.h ${sr
INCLUDE=-I. -I${srcdir}
CC=@CC@
OBJECTS=main.o loop.o interface.o net.o mtproto-common.o mtproto-client.o queries.o structures.o binlog.o tools.o lua-tg.o
TLC_OBJECTS=tlc.o tl-parser.o tools.o crc32.o
GENERATE_OBJECTS=generate.o tools.o
.SUFFIXES:
.SUFFIXES: .c .h .o
all: telegram
all: telegram tlc generate
${OBJECTS}: ${HEADERS}
${OBJECTS} ${TLC_OBJECTS}: ${HEADERS}
telegram: ${OBJECTS}
${CC} ${OBJECTS} ${LINK_FLAGS} -o $@
tlc: ${TLC_OBJECTS}
${CC} ${TLC_OBJECTS} ${LINK_FLAGS} -o $@
.c.o :
${CC} ${COMPILE_FLAGS} ${INCLUDE} -c $< -o $@
tlc: ${GENERATE_OBJECTS}
${CC} ${GENERATE_OBJECTS} ${LINK_FLAGS} -o $@
clean:
rm -rf *.o telegram config.log config.status > /dev/null || echo "all clean"

49
auto-static.c Normal file
View File

@ -0,0 +1,49 @@
int skip_double (void) {
if (in_ptr + 2 <= in_end) {
in_ptr += 2;
return 0;
} else {
return -1;
}
}
int skip_long (void) {
if (in_ptr + 2 <= in_end) {
in_ptr += 2;
return 0;
} else {
return -1;
}
}
int skip_int (void) {
if (in_ptr + 1 <= in_end) {
in_ptr += 1;
return 0;
} else {
return -1;
}
}
int skip_string (void) {
if (in_ptr == in_end) { return -1; }
unsigned len = *(unsigned char *)in_ptr;
if (len == 0xff) { return -1; }
if (len < 0xfe) {
int size = len + 1;
size += (-size) & 3;
if (in_ptr + (size / 4) <= in_end) {
in_ptr += (size / 4);
return 0;
} else {
return -1;
}
} else {
len = (*in_ptr) >> 8;
int size = len + 4;
size += (-size) & 3;
if (in_ptr + (size / 4) <= in_end) {
in_ptr += (size / 4);
return 0;
} else {
return -1;
}
}
}

24
auto.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef __AUTO_H__
#define __AUTO_H__
struct tl_type {
unsigned name;
char *id;
};
struct paramed_type {
struct tl_type *type;
struct paramed_type **params;
};
#define NAME_ARRAY 0x89932ad9
#define TYPE_TO_PARAM(NAME) (&(struct paramed_type) {.type = &tl_type_## NAME, .params=0})
#define ODDP(x) (((long)(x)) & 1)
#define EVENP(x) (!ODDP(x))
#define INT2PTR(x) (void *)(long)(((long)x) * 2 + 1)
#define PTR2INT(x) ((((long)x) - 1) / 2)
#include "auto-header.h"
#endif

View File

@ -7,8 +7,38 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <assert.h>
#include <string.h>
#include "tl-tl.h"
#include "generate.h"
#include "tree.h"
#include "config.h"
int header;
#define tl_type_name_cmp(a,b) (a->name > b->name ? 1 : a->name < b->name ? -1 : 0)
DEFINE_TREE (tl_type, struct tl_type *, tl_type_name_cmp, 0)
DEFINE_TREE (tl_combinator, struct tl_combinator *, tl_type_name_cmp, 0)
struct tree_tl_type *type_tree;
struct tree_tl_combinator *function_tree;
void tl_function_insert_by_name (struct tl_combinator *c) {
function_tree = tree_insert_tl_combinator (function_tree, c, lrand48 ());
}
struct tl_type *tl_type_get_by_name (int name) {
static struct tl_type t;
t.name = name;
return tree_lookup_tl_type (type_tree, &t);
}
void tl_type_insert_by_name (struct tl_type *t) {
type_tree = tree_insert_tl_type (type_tree, t, lrand48 ());
}
static char buf[1 << 20];
int buf_size;
@ -29,7 +59,13 @@ long long get_long (void) {
return r;
}
char *get_string (int *len) {
static void *malloc0 (int size) {
void *r = malloc (size);
memset (r, 0, size);
return r;
}
char *get_string (void) {
int l = *(unsigned char *)buf_ptr;
assert (l != 0xff);
@ -43,7 +79,8 @@ char *get_string (int *len) {
res = ((char *)buf_ptr) + 1;
tlen = 1 + l;
}
*len = l;
int len = l;
tlen += ((-tlen) & 3);
assert (!(tlen & 3));
@ -51,27 +88,657 @@ char *get_string (int *len) {
buf_ptr += tlen / 4;
assert (buf_ptr <= buf_end);
return res;
return strndup (res, len);
}
int parse_type (void) {
assert (get_int () == TLS_TYPE);
int name = get_int ();
int l;
char *name = get_string (&l);
int flags = get_int ();
int arity = get_int ();
long long params_types = get_long ();
int tn, fn, cn;
struct tl_type **tps;
struct tl_combinator **fns;
printf ("int fetch_type_%s (struct paramed_type *T) {\n");
printf (" if (arity) { assert (T); }\n");
struct tl_tree *read_tree (int *var_num);
struct tl_tree *read_nat_expr (int *var_num);
struct tl_tree *read_type_expr (int *var_num);
int read_args_list (struct arg **args, int args_num, int *var_num);
printf ("\n");
#define use_var_nat_full_form(x) 0
void *int_to_var_nat_const_init (long long x) {
if (use_var_nat_full_form (x)) {
struct tl_tree_nat_const *T = malloc (sizeof (*T));
T->self.flags = 0;
T->self.methods = &tl_pnat_const_full_methods;
T->value = x;
return T;
} else {
return (void *)(long)(x * 2 - 0x80000001l);
}
}
long long var_nat_const_to_int (void *x) {
if (((long)x) & 1) {
return (((long)x) + 0x80000001l) / 2;
} else {
return ((struct tl_tree_nat_const *)x)->value;
}
}
int tl_tree_type_type (struct tl_tree *x) {
return NODE_TYPE_TYPE;
}
int tl_tree_type_array (struct tl_tree *x) {
return NODE_TYPE_ARRAY;
}
int tl_tree_type_nat_const (struct tl_tree *x) {
return NODE_TYPE_NAT_CONST;
}
int tl_tree_type_var_num (struct tl_tree *x) {
return NODE_TYPE_VAR_NUM;
}
int tl_tree_type_var_type (struct tl_tree *x) {
return NODE_TYPE_VAR_TYPE;
}
struct tl_tree_methods tl_var_num_methods = {
.type = tl_tree_type_var_num
};
struct tl_tree_methods tl_var_type_methods = {
.type = tl_tree_type_var_type
};
struct tl_tree_methods tl_type_methods = {
.type = tl_tree_type_type
};
struct tl_tree_methods tl_nat_const_methods = {
.type = tl_tree_type_nat_const
};
struct tl_tree_methods tl_array_methods = {
.type = tl_tree_type_array
};
struct tl_tree_methods tl_ptype_methods = {
.type = tl_tree_type_type
};
struct tl_tree_methods tl_parray_methods = {
.type = tl_tree_type_array
};
struct tl_tree_methods tl_pvar_num_methods = {
.type = tl_tree_type_var_num
};
struct tl_tree_methods tl_pvar_type_methods = {
.type = tl_tree_type_var_type
};
struct tl_tree_methods tl_nat_const_full_methods = {
.type = tl_tree_type_nat_const
};
struct tl_tree_methods tl_pnat_const_full_methods = {
.type = tl_tree_type_nat_const
};
struct tl_tree *read_num_const (int *var_num) {
return (void *)int_to_var_nat_const_init (get_int ());
}
int gen_uni (struct tl_tree *t, char *cur_name, int *vars, int first) {
assert (t);
int x = TL_TREE_METHODS (t)->type (t);
int l = 0;
int i;
int j;
struct tl_tree_type *t1;
struct tl_tree_array *t2;
int y;
int L = strlen (cur_name);
switch (x) {
case NODE_TYPE_TYPE:
t1 = (void *)t;
if (!first) {
printf (" if (ODDP(%s) || %s->type->name != 0x%08x) { return -1; }\n", cur_name, cur_name, t1->type->name);
} else {
printf (" if (ODDP(%s) || (%s->type->name != 0x%08x && %s->type->name != 0x%08x)) { return -1; }\n", cur_name, cur_name, t1->type->name, cur_name, ~t1->type->name);
}
for (i = 0; i < t1->children_num; i++) {
sprintf (cur_name + L, "->params[%d]", i);
gen_uni (t1->children[i], cur_name, vars, 0);
cur_name[L] = 0;
}
return 0;
case NODE_TYPE_NAT_CONST:
printf (" if (EVENP(%s) || ((long)%s) != %lld) { return -1; }\n", cur_name, cur_name, var_nat_const_to_int (t) * 2 + 1);
return 0;
case NODE_TYPE_ARRAY:
printf (" if (ODDP(%s) || %s->type->name != TL_TYPE_ARRAY) { return -1; }\n", cur_name, cur_name);
t2 = (void *)t;
sprintf (cur_name + L, "->params[0]");
y = gen_uni (t2->multiplicity, cur_name, vars, 0);
cur_name[L] = 0;
sprintf (cur_name + L, "->params[1]");
y += gen_uni (t2->args[0]->type, cur_name, vars, 0);
cur_name[L] = 0;
return 0;
case NODE_TYPE_VAR_TYPE:
printf (" if (ODDP(%s)) { return -1; }\n", cur_name);
i = ((struct tl_tree_var_type *)t)->var_num;
if (!vars[i]) {
printf (" struct paramed_type *var%d = %s; assert (var%d);\n", i, cur_name, i);
vars[i] = 1;
} else if (vars[i] == 1) {
printf (" if (compare_types (var%d, %s) < 0) { return -1; }\n", i, cur_name);
} else {
assert (0);
return -1;
}
return l;
case NODE_TYPE_VAR_NUM:
printf (" if (EVENP(%s)) { return -1; }\n", cur_name);
i = ((struct tl_tree_var_num *)t)->var_num;
j = ((struct tl_tree_var_num *)t)->dif;
if (!vars[i]) {
printf (" struct paramed_type *var%d = ((void *)%s) + %d; assert (var%d);\n", i, cur_name, 2 * j, i);
vars[i] = 2;
} else if (vars[i] == 2) {
printf (" if (var%d != ((void *)%s) + %d) { return -1; }\n", i, cur_name, 2 * j);
} else {
assert (0);
return -1;
}
return 0;
default:
assert (0);
return -1;
}
}
void print_offset (int len) {
int i;
for (i = 0; i < len; i++) { printf (" "); }
}
int gen_create (struct tl_tree *t, int *vars, int offset) {
int x = TL_TREE_METHODS (t)->type (t);
int i;
struct tl_tree_type *t1;
struct tl_tree_array *t2;
switch (x) {
case NODE_TYPE_TYPE:
print_offset (offset);
printf ("&(struct paramed_type){\n");
print_offset (offset + 2);
t1 = (void *)t;
if (t1->self.flags & FLAG_BARE) {
printf (".type = &(struct tl_type) {.name = 0x%08x, .id = \"Bare_%s\"},\n", ~t1->type->name, t1->type->id);
} else {
printf (".type = &(struct tl_type) {.name = 0x%08x, .id = \"%s\"},\n", t1->type->name, t1->type->id);
}
if (t1->children_num) {
print_offset (offset + 2);
printf (".params = (struct paramed_type *[]){\n");
for (i = 0; i < t1->children_num; i++) {
assert (gen_create (t1->children[i], vars, offset + 4) >= 0);
printf (",\n");
}
print_offset (offset + 2);
printf ("}\n");
} else {
print_offset (offset + 2);
printf (".params = 0,\n");
}
print_offset (offset);
printf ("}");
return 0;
case NODE_TYPE_NAT_CONST:
print_offset (offset);
printf ("INT2PTR (%d)", (int)var_nat_const_to_int (t));
return 0;
case NODE_TYPE_ARRAY:
print_offset (offset);
printf ("&(struct paramed_type){\n");
print_offset (offset + 2);
t2 = (void *)t;
printf (".type = &(struct tl_type) {.name = NAME_ARRAY, .id = \"array\"},\n");
print_offset (offset + 2);
printf (".params = (struct paramed_type **){\n");
gen_create (t2->multiplicity, vars, offset + 4);
printf (",\n");
gen_create (t2->args[0]->type, vars, offset + 4);
printf (",\n");
print_offset (offset + 2);
printf ("}\n");
print_offset (offset);
printf ("}");
return 0;
case NODE_TYPE_VAR_TYPE:
print_offset (offset);
printf ("var%d", ((struct tl_tree_var_type *)t)->var_num);
return 0;
case NODE_TYPE_VAR_NUM:
print_offset (offset);
printf ("((void *)var%d) + %d", ((struct tl_tree_var_type *)t)->var_num, 2 * ((struct tl_tree_var_num *)t)->dif);
return 0;
default:
assert (0);
return -1;
}
}
int gen_field_fetch (struct arg *arg, int *vars, int num) {
assert (arg);
char *offset = " ";
int o = 0;
if (arg->exist_var_num >= 0) {
printf (" if (PTR2INT (var%d) & (1 << %d)) {\n", arg->exist_var_num, arg->exist_var_bit);
offset = " ";
o = 2;
}
if (arg->var_num >= 0) {
assert (TL_TREE_METHODS (arg->type)->type (arg->type) == NODE_TYPE_TYPE);
int t = ((struct tl_tree_type *)arg->type)->type->name;
if (t == NAME_VAR_TYPE) {
fprintf (stderr, "Not supported yet\n");
assert (0);
} else {
assert (t == NAME_VAR_NUM);
if (vars[arg->var_num] == 0) {
printf ("%sstruct paramed_type *var%d = INT2PTR (*in_ptr);\n", offset, arg->var_num);
printf ("%sif (skip_int () < 0) { return -1;}\n", offset);
vars[arg->var_num] = 2;
} else if (vars[arg->var_num] == 2) {
printf ("%sif (vars%d != INT2PTR (*in_ptr)) { return -1; }\n", offset, arg->var_num);
printf ("%sif (skip_int () < 0) { return -1;}\n", offset);
} else {
assert (0);
return -1;
}
}
} else {
int t = TL_TREE_METHODS (arg->type)->type (arg->type);
if (t == NODE_TYPE_TYPE || t == NODE_TYPE_VAR_TYPE) {
printf ("%sstruct paramed_type *field%d = \n", offset, num);
assert (gen_create (arg->type, vars, 2 + o) >= 0);
printf (";\n");
int bare = arg->flags & FLAG_BARE;
if (!bare && t == NODE_TYPE_TYPE) {
bare = ((struct tl_tree_type *)arg->type)->self.flags & FLAG_BARE;
}
if (!bare) {
printf ("%sif (skip_type_%s (field%d) < 0) { return -1;}\n", offset, t == NODE_TYPE_VAR_TYPE ? "any" : ((struct tl_tree_type *)arg->type)->type->id, num);
} else {
printf ("%sif (skip_type_bare_%s (field%d) < 0) { return -1;}\n", offset, t == NODE_TYPE_VAR_TYPE ? "any" : ((struct tl_tree_type *)arg->type)->type->id, num);
}
} else {
assert (t == NODE_TYPE_ARRAY);
printf ("%sint multiplicity%d = PTR2INT (\n", offset, num);
assert (gen_create (((struct tl_tree_array *)arg->type)->multiplicity, vars, 2 + o) >= 0);
printf ("%s);\n", offset);
printf ("%sstruct paramed_type *field%d = \n", offset, num);
assert (gen_create (((struct tl_tree_array *)arg->type)->args[0]->type, vars, 2 + o) >= 0);
printf (";\n");
printf ("%swhile (multiplicity%d -- > 0) {\n", offset, num);
printf ("%s if (skip_type_%s (field%d) < 0) { return -1;}\n", offset, "any", num);
printf ("%s}\n", offset);
}
}
if (arg->exist_var_num >= 0) {
printf (" }\n");
}
return 0;
}
void gen_constructor_fetch (struct tl_combinator *c) {
printf ("int skip_constructor_%s (struct paramed_type *T) {\n", c->id);
static char s[10000];
sprintf (s, "T");
int *vars = malloc0 (c->var_num * 4);;
gen_uni (c->result, s, vars, 1);
if (c->name == NAME_INT) {
printf (" if (skip_int () < 0) { return -1; }\n");
printf (" return 0;\n");
printf ("}\n");
return;
} else if (c->name == NAME_LONG) {
printf (" if (skip_long () < 0) { return -1; }\n");
printf (" return 0;\n");
printf ("}\n");
return;
} else if (c->name == NAME_STRING) {
printf (" if (skip_string () < 0) { return -1; }\n");
printf (" return 0;\n");
printf ("}\n");
return;
} else if (c->name == NAME_DOUBLE) {
printf (" if (skip_double () < 0) { return -1; }\n");
printf (" return 0;\n");
printf ("}\n");
return;
}
int i;
for (i = 0; i < c->args_num; i++) if (!(c->args[i]->flags & FLAG_OPT_VAR)) {
assert (gen_field_fetch (c->args[i], vars, i + 1) >= 0);
}
free (vars);
printf (" return 0;\n");
printf ("}\n");
}
void gen_type_fetch (struct tl_type *t) {
printf ("int skip_type_%s (struct paramed_type *T) {\n", t->id);
printf (" int magic = *in_ptr;\n");
printf (" if (skip_int () < 0) { return -1; }\n");
printf (" switch (magic) {\n");
int i;
for (i = 0; i < t->constructors_num; i++) {
printf (" case 0x%08x: return skip_constructor_%s (T);\n", t->constructors[i]->name, t->constructors[i]->id);
}
printf (" default: return -1;\n");
printf (" }\n");
printf ("}\n");
printf ("int skip_type_bare_%s (struct paramed_type *T) {\n", t->id);
printf (" int *save = in_ptr;\n");
for (i = 0; i < t->constructors_num; i++) {
printf (" if (skip_constructor_%s (T) >= 0) { return 0; }\n", t->constructors[i]->id);
printf (" in_ptr = save;\n");
}
printf (" return -1;\n");
printf ("}\n");
}
struct tl_tree *read_num_var (int *var_num) {
struct tl_tree_var_num *T = malloc0 (sizeof (*T));
T->self.flags = 0;
T->self.methods = &tl_pvar_num_methods;;
T->dif = get_int ();
T->var_num = get_int ();
if (T->var_num >= *var_num) {
*var_num = T->var_num + 1;
}
assert (!(T->self.flags & FLAG_NOVAR));
return (void *)T;
}
struct tl_tree *read_type_var (int *var_num) {
struct tl_tree_var_type *T = malloc0 (sizeof (*T));
T->self.methods = &tl_pvar_type_methods;
T->var_num = get_int ();
T->self.flags = get_int ();
if (T->var_num >= *var_num) {
*var_num = T->var_num + 1;
}
assert (!(T->self.flags & (FLAG_NOVAR | FLAG_BARE)));
return (void *)T;
}
struct tl_tree *read_array (int *var_num) {
struct tl_tree_array *T = malloc0 (sizeof (*T));
T->self.methods = &tl_parray_methods;
T->self.flags = 0;
T->multiplicity = read_nat_expr (var_num);
assert (T->multiplicity);
T->args_num = get_int ();
assert (T->args_num >= 0 && T->args_num <= 1000);
T->args = malloc0 (sizeof (void *) * T->args_num);
assert (read_args_list (T->args, T->args_num, var_num) >= 0);
T->self.flags |= FLAG_NOVAR;
int i;
for (i = 0; i < T->args_num; i++) {
if (!(T->args[i]->flags & FLAG_NOVAR)) {
T->self.flags &= ~FLAG_NOVAR;
}
}
return (void *)T;
}
struct tl_tree *read_type (int *var_num) {
struct tl_tree_type *T = malloc0 (sizeof (*T));
T->self.methods = &tl_ptype_methods;
T->type = tl_type_get_by_name (get_int ());
assert (T->type);
T->self.flags = get_int ();
T->children_num = get_int ();
assert (T->type->arity == T->children_num);
T->children = malloc0 (sizeof (void *) * T->children_num);
int i;
T->self.flags |= FLAG_NOVAR;
for (i = 0; i < T->children_num; i++) {
int t = get_int ();
if (t == (int)TLS_EXPR_NAT) {
assert ((T->type->params_types & (1 << i)));
T->children[i] = read_nat_expr (var_num);
} else if (t == (int)TLS_EXPR_TYPE) {
assert (!(T->type->params_types & (1 << i)));
T->children[i] = read_type_expr (var_num);
} else {
assert (0);
}
if (!TL_IS_NAT_VAR (T->children[i]) && !(T->children[i]->flags & FLAG_NOVAR)) {
T->self.flags &= ~FLAG_NOVAR;
}
}
return (void *)T;
}
struct tl_tree *read_tree (int *var_num) {
int x = get_int ();
if (verbosity >= 2) {
fprintf (stderr, "read_tree: constructor = 0x%08x\n", x);
}
switch (x) {
case TLS_TREE_NAT_CONST:
return read_num_const (var_num);
case TLS_TREE_NAT_VAR:
return read_num_var (var_num);
case TLS_TREE_TYPE_VAR:
return read_type_var (var_num);
case TLS_TREE_TYPE:
return read_type (var_num);
case TLS_TREE_ARRAY:
return read_array (var_num);
default:
if (verbosity) {
fprintf (stderr, "x = %d\n", x);
}
assert (0);
return 0;
}
}
struct tl_tree *read_type_expr (int *var_num) {
int x = get_int ();
if (verbosity >= 2) {
fprintf (stderr, "read_type_expr: constructor = 0x%08x\n", x);
}
switch (x) {
case TLS_TYPE_VAR:
return read_type_var (var_num);
case TLS_TYPE_EXPR:
return read_type (var_num);
case TLS_ARRAY:
return read_array (var_num);
default:
if (verbosity) {
fprintf (stderr, "x = %d\n", x);
}
assert (0);
return 0;
}
}
struct tl_tree *read_nat_expr (int *var_num) {
int x = get_int ();
if (verbosity >= 2) {
fprintf (stderr, "read_nat_expr: constructor = 0x%08x\n", x);
}
switch (x) {
case TLS_NAT_CONST:
return read_num_const (var_num);
case TLS_NAT_VAR:
return read_num_var (var_num);
default:
if (verbosity) {
fprintf (stderr, "x = %d\n", x);
}
assert (0);
return 0;
}
}
struct tl_tree *read_expr (int *var_num) {
int x = get_int ();
if (verbosity >= 2) {
fprintf (stderr, "read_nat_expr: constructor = 0x%08x\n", x);
}
switch (x) {
case TLS_EXPR_NAT:
return read_nat_expr (var_num);
case TLS_EXPR_TYPE:
return read_type_expr (var_num);
default:
if (verbosity) {
fprintf (stderr, "x = %d\n", x);
}
assert (0);
return 0;
}
}
int read_args_list (struct arg **args, int args_num, int *var_num) {
int i;
for (i = 0; i < args_num; i++) {
args[i] = malloc0 (sizeof (struct arg));
args[i]->exist_var_num = -1;
args[i]->exist_var_bit = 0;
assert (get_int () == TLS_ARG_V2);
args[i]->id = get_string ();
args[i]->flags = get_int ();
if (args[i]->flags & 2) {
args[i]->flags &= ~2;
args[i]->flags |= (1 << 20);
}
if (args[i]->flags & 4) {
args[i]->flags &= ~4;
args[i]->var_num = get_int ();
} else {
args[i]->var_num = -1;
}
if (args[i]->var_num >= *var_num) {
*var_num = args[i]->var_num + 1;
}
if (args[i]->flags & FLAG_OPT_FIELD) {
args[i]->exist_var_num = get_int ();
args[i]->exist_var_bit = get_int ();
}
args[i]->type = read_type_expr (var_num);
assert (args[i]->type);
if (args[i]->var_num < 0 && args[i]->exist_var_num < 0 && (TL_IS_NAT_VAR(args[i]->type) || (args[i]->type->flags & FLAG_NOVAR))) {
args[i]->flags |= FLAG_NOVAR;
}
}
return 1;
}
int read_combinator_args_list (struct tl_combinator *c) {
c->args_num = get_int ();
if (verbosity >= 2) {
fprintf (stderr, "c->id = %s, c->args_num = %d\n", c->id, c->args_num);
}
assert (c->args_num >= 0 && c->args_num <= 1000);
c->args = malloc0 (sizeof (void *) * c->args_num);
c->var_num = 0;
return read_args_list (c->args, c->args_num, &c->var_num);
}
int read_combinator_right (struct tl_combinator *c) {
assert (get_int () == TLS_COMBINATOR_RIGHT_V2);
c->result = read_type_expr (&c->var_num);
assert (c->result);
return 1;
}
int read_combinator_left (struct tl_combinator *c) {
int x = get_int ();
if (x == (int)TLS_COMBINATOR_LEFT_BUILTIN) {
c->args_num = 0;
c->var_num = 0;
c->args = 0;
return 1;
} else if (x == TLS_COMBINATOR_LEFT) {
return read_combinator_args_list (c);
} else {
assert (0);
return -1;
}
}
struct tl_combinator *read_combinators (int v) {
struct tl_combinator *c = malloc0 (sizeof (*c));
c->name = get_int ();
c->id = get_string ();
char *s = c->id;
while (*s) { if (*s == '.') { *s = '_'; } ; s ++;}
int x = get_int ();
struct tl_type *t = tl_type_get_by_name (x);
assert (t || (!x && v == 3));
if (v == 2) {
assert (t->extra < t->constructors_num);
t->constructors[t->extra ++] = c;
c->is_fun = 0;
} else {
assert (v == 3);
tl_function_insert_by_name (c);
c->is_fun = 1;
}
assert (read_combinator_left (c) >= 0);
assert (read_combinator_right (c) >= 0);
return c;
}
struct tl_type *read_types (void) {
struct tl_type *t = malloc0 (sizeof (*t));
t->name = get_int ();
t->id = get_string ();
char *s = t->id;
while (*s) { if (*s == '.') { *s = '_'; } ; s++; }
t->constructors_num = get_int ();
assert (t->constructors_num >= 0 && t->constructors_num <= 1000);
t->constructors = malloc0 (sizeof (void *) * t->constructors_num);
t->flags = get_int ();
t->arity = get_int ();
t->params_types = get_long (); // params_types
t->extra = 0;
tl_type_insert_by_name (t);
return t;
}
int parse_tlo_file (void) {
buf_end = buf_ptr + (buf_size / 4);
assert (get_int () == TLS_SCHEMA_V2);
@ -79,12 +746,162 @@ int parse_tlo_file (void) {
get_int (); // version
get_int (); // date
tn = 0;
fn = 0;
cn = 0;
int i;
tn = get_int ();
assert (tn >= 0 && tn < 10000);
tps = malloc0 (sizeof (void *) * tn);
if (verbosity >= 2) {
fprintf (stderr, "Found %d types\n", tn);
}
for (i = 0; i < tn; i++) {
assert (get_int () == TLS_TYPE);
tps[i] = read_types ();
assert (tps[i]);
}
cn = get_int ();
assert (cn >= 0);
if (verbosity >= 2) {
fprintf (stderr, "Found %d constructors\n", cn);
}
for (i = 0; i < cn; i++) {
assert (get_int () == TLS_COMBINATOR);
assert (read_combinators (2));
}
fn = get_int ();
assert (fn >= 0 && fn < 10000);
fns = malloc0 (sizeof (void *) * fn);
if (verbosity >= 2) {
fprintf (stderr, "Found %d functions\n", fn);
}
for (i = 0; i < fn; i++) {
assert (get_int () == TLS_COMBINATOR);
fns[i] = read_combinators (3);
assert (fns[i]);
}
assert (buf_ptr == buf_end);
/*
static void *IP[10000];
if (gen_function_fetch (IP, 100) < 0) {
return -2;
}
for (i = 0; i < tn; i++) {
if (tps[i]->extra < tps[i]->constructors_num) {
tl_config_back ();
return -1;
}
}
int j;
for (i = 0; i < tn; i++) {
for (j = 0; j < tps[i]->constructors_num; j ++) {
if (gen_constructor_store (tps[i]->constructors[j], IP, 10000) < 0) {
return -2;
}
if (gen_constructor_fetch (tps[i]->constructors[j], IP, 10000) < 0) {
return -2;
}
}
}
for (i = 0; i < fn; i++) {
if (gen_function_store (fns[i], IP, 10000) < 0) {
return -2;
}
}
if (tl_config_name) {
ADD_PFREE (strlen (tl_config_name));
zzstrfree (tl_config_name);
}
tl_config_name = 0;
config_crc64 = new_crc64;
tl_config_version = new_tl_config_version ;
tl_config_date = new_tl_config_date;
int i;
int types_num = get_int ();
for (i = 0; i < types_num; i++) {
if (parse_type () < 0) { return -1; }
}*/
int j;
for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type")) {
tps[i]->name = 0;
for (j = 0; j < tps[i]->constructors_num; j ++) {
tps[i]->name ^= tps[i]->constructors[j]->name;
}
}
if (!header) {
printf ("#include \"auto.h\"\n");
printf ("#include <assert.h>\n");
printf ("extern int *in_ptr, *in_end;\n");
printf ("#include \"auto-static.c\"\n");
for (i = 0; i < tn; i++) {
for (j = 0; j < tps[i]->constructors_num; j ++) {
gen_constructor_fetch (tps[i]->constructors[j]);
}
}
for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type")) {
gen_type_fetch (tps[i]);
}
/*for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#') {
printf ("struct tl_type tl_type_%s = {\n", tps[i]->id);
printf (" .name = 0x%08x,\n", tps[i]->name);
printf (" .id = \"%s\"\n", tps[i]->id);
printf ("};\n");
}*/
printf ("int skip_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")) {
printf (" case 0x%08x: return skip_type_%s (T);\n", tps[i]->name, tps[i]->id);
printf (" case 0x%08x: return skip_type_bare_%s (T);\n", ~tps[i]->name, tps[i]->id);
}
printf (" default: return -1; }\n");
printf ("}\n");
} else {
for (i = 0; i < tn; i++) {
for (j = 0; j < tps[i]->constructors_num; j ++) {
printf ("int skip_constructor_%s (struct paramed_type *T);\n", tps[i]->constructors[j]->id);
}
}
for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type")) {
printf ("int skip_type_%s (struct paramed_type *T);\n", tps[i]->id);
printf ("int skip_type_bare_%s (struct paramed_type *T);\n", tps[i]->id);
}
printf ("int skip_type_any (struct paramed_type *T);\n");
/*for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#') {
printf ("extern struct tl_type tl_type_%s;\n", tps[i]->id);
}*/
for (i = 0; i < tn; i++) if (tps[i]->id[0] != '#' && strcmp (tps[i]->id, "Type")) {
printf ("static struct tl_type tl_type_%s __attribute__ ((unused));\n", tps[i]->id);
printf ("static struct tl_type tl_type_%s = {\n", tps[i]->id);
printf (" .name = 0x%08x,\n", tps[i]->name);
printf (" .id = \"%s\"\n", tps[i]->id);
printf ("};\n");
printf ("static struct tl_type tl_type_bare_%s __attribute__ ((unused));\n", tps[i]->id);
printf ("static struct tl_type tl_type_bare_%s = {\n", tps[i]->id);
printf (" .name = 0x%08x,\n", ~tps[i]->name);
printf (" .id = \"Bare_%s\"\n", tps[i]->id);
printf ("};\n");
}
}
@ -142,7 +959,7 @@ int main (int argc, char **argv) {
signal (SIGSEGV, sig_segv_handler);
signal (SIGABRT, sig_abrt_handler);
int i;
while ((i = getopt (argc, argv, "vh")) != -1) {
while ((i = getopt (argc, argv, "vhH")) != -1) {
switch (i) {
case 'h':
usage ();
@ -150,6 +967,9 @@ int main (int argc, char **argv) {
case 'v':
verbosity++;
break;
case 'H':
header ++;
break;
}
}

146
generate.h Normal file
View File

@ -0,0 +1,146 @@
#ifndef __GENERATE_H__
#define __GENERATE_H__
struct tl_combinator;
struct tl_type {
// struct tl_type_methods *methods;
char *id;
unsigned name;
int arity;
int flags;
int constructors_num;
struct tl_combinator **constructors;
long long params_types;
int extra;
};
#define NODE_TYPE_TYPE 1
#define NODE_TYPE_NAT_CONST 2
#define NODE_TYPE_VAR_TYPE 3
#define NODE_TYPE_VAR_NUM 4
#define NODE_TYPE_ARRAY 5
#define MAX_COMBINATOR_VARS 64
#define NAME_VAR_NUM 0x70659eff
#define NAME_VAR_TYPE 0x2cecf817
#define NAME_INT 0xa8509bda
#define NAME_LONG 0x22076cba
#define NAME_DOUBLE 0x2210c154
#define NAME_STRING 0xb5286e24
#define NAME_VECTOR 0x1cb5c415
#define NAME_MAYBE_TRUE 0x3f9c8ef8
#define NAME_MAYBE_FALSE 0x27930a7b
#define NAME_BOOL_FALSE 0xbc799737
#define NAME_BOOL_TRUE 0x997275b5
#define FLAG_OPT_VAR (1 << 17)
#define FLAG_EXCL (1 << 18)
#define FLAG_OPT_FIELD (1 << 20)
#define FLAG_NOVAR (1 << 21)
#define FLAG_BARE 1
#define FLAGS_MASK ((1 << 16) - 1)
#define FLAG_DEFAULT_CONSTRUCTOR (1 << 25)
#define FLAG_NOCONS (1 << 1)
extern struct tl_tree_methods tl_nat_const_methods;
extern struct tl_tree_methods tl_nat_const_full_methods;
extern struct tl_tree_methods tl_pnat_const_full_methods;
extern struct tl_tree_methods tl_array_methods;
extern struct tl_tree_methods tl_type_methods;
extern struct tl_tree_methods tl_parray_methods;
extern struct tl_tree_methods tl_ptype_methods;
extern struct tl_tree_methods tl_var_num_methods;
extern struct tl_tree_methods tl_var_type_methods;
extern struct tl_tree_methods tl_pvar_num_methods;
extern struct tl_tree_methods tl_pvar_type_methods;
#define TL_IS_NAT_VAR(x) (((long)x) & 1)
#define TL_TREE_METHODS(x) (TL_IS_NAT_VAR (x) ? &tl_nat_const_methods : ((struct tl_tree *)(x))->methods)
#define DEC_REF(x) (TL_TREE_METHODS(x)->dec_ref ((void *)x))
#define INC_REF(x) (TL_TREE_METHODS(x)->inc_ref ((void *)x))
#define TYPE(x) (TL_TREE_METHODS(x)->type ((void *)x))
typedef unsigned long long tl_tree_hash_t;
struct tl_tree;
struct tl_tree_methods {
int (*type)(struct tl_tree *T);
int (*eq)(struct tl_tree *T, struct tl_tree *U);
void (*inc_ref)(struct tl_tree *T);
void (*dec_ref)(struct tl_tree *T);
};
struct tl_tree {
int ref_cnt;
int flags;
//tl_tree_hash_t hash;
struct tl_tree_methods *methods;
};
/*
struct tl_tree_nat_const {
struct tl_tree self;
int value;
};*/
struct tl_tree_type {
struct tl_tree self;
struct tl_type *type;
int children_num;
struct tl_tree **children;
};
struct tl_tree_array {
struct tl_tree self;
struct tl_tree *multiplicity;
int args_num;
struct arg **args;
};
struct tl_tree_var_type {
struct tl_tree self;
int var_num;
};
struct tl_tree_var_num {
struct tl_tree self;
int var_num;
int dif;
};
struct tl_tree_nat_const {
struct tl_tree self;
long long value;
};
struct arg {
char *id;
int var_num;
int flags;
int exist_var_num;
int exist_var_bit;
struct tl_tree *type;
};
struct tl_combinator {
//struct tl_combinator_methods *methods;
char *id;
unsigned name;
int is_fun;
int var_num;
int args_num;
struct arg **args;
struct tl_tree *result;
void **IP;
void **fIP;
int IP_len;
int fIP_len;
};
#endif

2
loop.c
View File

@ -53,6 +53,8 @@
#include "binlog.h"
#include "lua-tg.h"
#include "auto.h"
extern char *default_username;
extern char *auth_token;
extern int test_dc;

View File

@ -53,6 +53,7 @@
#include "interface.h"
#include "structures.h"
#include "binlog.h"
#include "auto.h"
#if defined(__FreeBSD__)
#define __builtin_bswap32(x) bswap32(x)
@ -1407,6 +1408,10 @@ void work_update_short (struct connection *c, long long msg_id) {
}
void work_updates (struct connection *c, long long msg_id) {
int *save = in_ptr;
assert (!skip_type_any (&(struct paramed_type) {.type = &tl_type_Updates, .params=0}));
int *save_end = in_ptr;
in_ptr = save;
assert (fetch_int () == CODE_updates);
assert (fetch_int () == CODE_vector);
int n = fetch_int ();
@ -1426,6 +1431,7 @@ void work_updates (struct connection *c, long long msg_id) {
}
bl_do_set_date (fetch_int ());
bl_do_set_seq (fetch_int ());
assert (save_end == in_ptr);
}
void work_update_short_message (struct connection *c UU, long long msg_id UU) {

View File

@ -53,6 +53,7 @@
#include "no-preview.h"
#include "binlog.h"
#include "auto.h"
#define sha1 SHA1
@ -242,6 +243,16 @@ void query_result (long long id UU) {
}
queries_tree = tree_delete_query (queries_tree, q);
if (q->methods && q->methods->on_answer) {
if (q->methods->type) {
int *save = in_ptr;
if (skip_type_any (q->methods->type) < 0) {
logprintf ("Skipped %ld int out of %ld (type %s)\n", in_ptr - save, in_end - save, q->methods->type->type->id);
assert (0);
}
assert (in_ptr == in_end);
in_ptr = save;
}
q->methods->on_answer (q);
assert (in_ptr == in_end);
}
@ -376,7 +387,8 @@ int help_get_config_on_answer (struct query *q UU) {
}
struct query_methods help_get_config_methods = {
.on_answer = help_get_config_on_answer
.on_answer = help_get_config_on_answer,
.type = TYPE_TO_PARAM(Config)
};
void do_help_get_config (void) {
@ -421,7 +433,8 @@ int send_code_on_error (struct query *q UU, int error_code, int l, char *error)
struct query_methods send_code_methods = {
.on_answer = send_code_on_answer,
.on_error = send_code_on_error
.on_error = send_code_on_error,
.type = TYPE_TO_PARAM(auth_SentCode)
};
int code_is_sent (void) {
@ -490,7 +503,8 @@ int phone_call_on_error (struct query *q UU, int error_code, int l, char *error)
struct query_methods phone_call_methods = {
.on_answer = phone_call_on_answer,
.on_error = phone_call_on_error
.on_error = phone_call_on_error,
.type = TYPE_TO_PARAM(Bool)
};
void do_phone_call (const char *user) {
@ -554,7 +568,8 @@ int check_phone_on_error (struct query *q UU, int error_code, int l, char *error
struct query_methods check_phone_methods = {
.on_answer = check_phone_on_answer,
.on_error = check_phone_on_error
.on_error = check_phone_on_error,
.type = TYPE_TO_PARAM(auth_CheckedPhone)
};
int do_auth_check_phone (const char *user) {
@ -598,7 +613,8 @@ int fail_on_error (struct query *q UU, int error_code UU, int l UU, char *error
struct query_methods nearest_dc_methods = {
.on_answer = nearest_dc_on_answer,
.on_error = fail_on_error
.on_error = fail_on_error,
.type = TYPE_TO_PARAM(NearestDc)
};
int do_get_nearest_dc (void) {
@ -649,7 +665,8 @@ int sign_in_on_error (struct query *q UU, int error_code, int l, char *error) {
struct query_methods sign_in_methods = {
.on_answer = sign_in_on_answer,
.on_error = sign_in_on_error
.on_error = sign_in_on_error,
.type = TYPE_TO_PARAM(auth_Authorization)
};
int do_send_code_result (const char *code) {
@ -684,6 +701,7 @@ extern char *user_list[];
int get_contacts_on_answer (struct query *q UU) {
int i;
assert (fetch_int () == (int)CODE_contacts_contacts);
assert (fetch_int () == CODE_vector);
int n = fetch_int ();
@ -728,6 +746,7 @@ int get_contacts_on_answer (struct query *q UU) {
struct query_methods get_contacts_methods = {
.on_answer = get_contacts_on_answer,
.type = TYPE_TO_PARAM(contacts_Contacts)
};
@ -893,11 +912,13 @@ int msg_send_on_error (struct query *q, int error_code, int error_len, char *err
struct query_methods msg_send_methods = {
.on_answer = msg_send_on_answer,
.on_error = msg_send_on_error
.on_error = msg_send_on_error,
.type = TYPE_TO_PARAM(messages_SentMessage)
};
struct query_methods msg_send_encr_methods = {
.on_answer = msg_send_encr_on_answer
.on_answer = msg_send_encr_on_answer,
.type = TYPE_TO_PARAM(messages_SentEncryptedMessage)
};
int out_message_num;
@ -1001,11 +1022,13 @@ int mark_read_encr_on_receive (struct query *q UU) {
}
struct query_methods mark_read_methods = {
.on_answer = mark_read_on_receive
.on_answer = mark_read_on_receive,
.type = TYPE_TO_PARAM(messages_AffectedHistory)
};
struct query_methods mark_read_encr_methods = {
.on_answer = mark_read_encr_on_receive
.on_answer = mark_read_encr_on_receive,
.type = TYPE_TO_PARAM(Bool)
};
void do_messages_mark_read (peer_id_t id, int max_id) {
@ -1093,6 +1116,7 @@ int get_history_on_answer (struct query *q UU) {
struct query_methods get_history_methods = {
.on_answer = get_history_on_answer,
.type = TYPE_TO_PARAM(messages_Messages)
};
void do_get_local_history (peer_id_t id, int limit) {
@ -1196,6 +1220,7 @@ int get_dialogs_on_answer (struct query *q UU) {
struct query_methods get_dialogs_methods = {
.on_answer = get_dialogs_on_answer,
.type = TYPE_TO_PARAM(messages_Dialogs)
};
@ -2085,7 +2110,7 @@ int import_auth_on_answer (struct query *q UU) {
assert (fetch_int () == (int)CODE_auth_authorization);
fetch_int (); // expires
fetch_alloc_user ();
tfree_str (export_auth_str);
tfree (export_auth_str, export_auth_str_len);
export_auth_str = 0;
return 0;
}

View File

@ -20,6 +20,7 @@
#ifndef __QUERIES_H__
#define __QUERIES_H__
#include "structures.h"
#include "auto.h"
#define QUERY_ACK_RECEIVED 1
@ -28,6 +29,7 @@ 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);
struct paramed_type *type;
};
struct event_timer {

505
scheme12.tl Normal file
View File

@ -0,0 +1,505 @@
int ?= Int;
long ?= Long;
double ?= Double;
string ?= String;
bytes string = Bytes;
boolFalse#bc799737 = Bool;
boolTrue#997275b5 = Bool;
vector#1cb5c415 {t:Type} # [ t ] = Vector t;
error#c4b9f9bb code:int text:string = Error;
null#56730bcc = Null;
inputPeerEmpty#7f3b18ea = InputPeer;
inputPeerSelf#7da07ec9 = InputPeer;
inputPeerContact#1023dbe8 user_id:int = InputPeer;
inputPeerForeign#9b447325 user_id:int access_hash:long = InputPeer;
inputPeerChat#179be863 chat_id:int = InputPeer;
inputUserEmpty#b98886cf = InputUser;
inputUserSelf#f7c1b13f = InputUser;
inputUserContact#86e94f65 user_id:int = InputUser;
inputUserForeign#655e74ff user_id:int access_hash:long = InputUser;
inputPhoneContact#f392b7f4 client_id:long phone:string first_name:string last_name:string = InputContact;
inputFile#f52ff27f id:long parts:int name:string md5_checksum:string = InputFile;
inputMediaEmpty#9664f57f = InputMedia;
inputMediaUploadedPhoto#2dc53a7d file:InputFile = InputMedia;
inputMediaPhoto#8f2ab2ec id:InputPhoto = InputMedia;
inputMediaGeoPoint#f9c44144 geo_point:InputGeoPoint = InputMedia;
inputMediaContact#a6e45987 phone_number:string first_name:string last_name:string = InputMedia;
inputMediaUploadedVideo#4847d92a file:InputFile duration:int w:int h:int = InputMedia;
inputMediaUploadedThumbVideo#e628a145 file:InputFile thumb:InputFile duration:int w:int h:int = InputMedia;
inputMediaVideo#7f023ae6 id:InputVideo = InputMedia;
inputChatPhotoEmpty#1ca48f57 = InputChatPhoto;
inputChatUploadedPhoto#94254732 file:InputFile crop:InputPhotoCrop = InputChatPhoto;
inputChatPhoto#b2e1bf08 id:InputPhoto crop:InputPhotoCrop = InputChatPhoto;
inputGeoPointEmpty#e4c123d6 = InputGeoPoint;
inputGeoPoint#f3b7acc9 lat:double long:double = InputGeoPoint;
inputPhotoEmpty#1cd7bf0d = InputPhoto;
inputPhoto#fb95c6c4 id:long access_hash:long = InputPhoto;
inputVideoEmpty#5508ec75 = InputVideo;
inputVideo#ee579652 id:long access_hash:long = InputVideo;
inputFileLocation#14637196 volume_id:long local_id:int secret:long = InputFileLocation;
inputVideoFileLocation#3d0364ec id:long access_hash:long = InputFileLocation;
inputPhotoCropAuto#ade6b004 = InputPhotoCrop;
inputPhotoCrop#d9915325 crop_left:double crop_top:double crop_width:double = InputPhotoCrop;
inputAppEvent#770656a8 time:double type:string peer:long data:string = InputAppEvent;
peerUser#9db1bc6d user_id:int = Peer;
peerChat#bad0e5bb chat_id:int = Peer;
storage.fileUnknown#aa963b05 = storage.FileType;
storage.fileJpeg#7efe0e = storage.FileType;
storage.fileGif#cae1aadf = storage.FileType;
storage.filePng#a4f63c0 = storage.FileType;
storage.filePdf#ae1e508d = storage.FileType;
storage.fileMp3#528a0677 = storage.FileType;
storage.fileMov#4b09ebbc = storage.FileType;
storage.filePartial#40bc6f52 = storage.FileType;
storage.fileMp4#b3cea0e4 = storage.FileType;
storage.fileWebp#1081464c = storage.FileType;
fileLocationUnavailable#7c596b46 volume_id:long local_id:int secret:long = FileLocation;
fileLocation#53d69076 dc_id:int volume_id:long local_id:int secret:long = FileLocation;
userEmpty#200250ba id:int = User;
userSelf#720535ec id:int first_name:string last_name:string phone:string photo:UserProfilePhoto status:UserStatus inactive:Bool = User;
userContact#f2fb8319 id:int first_name:string last_name:string access_hash:long phone:string photo:UserProfilePhoto status:UserStatus = User;
userRequest#22e8ceb0 id:int first_name:string last_name:string access_hash:long phone:string photo:UserProfilePhoto status:UserStatus = User;
userForeign#5214c89d id:int first_name:string last_name:string access_hash:long photo:UserProfilePhoto status:UserStatus = User;
userDeleted#b29ad7cc id:int first_name:string last_name:string = User;
userProfilePhotoEmpty#4f11bae1 = UserProfilePhoto;
userProfilePhoto#d559d8c8 photo_id:long photo_small:FileLocation photo_big:FileLocation = UserProfilePhoto;
userStatusEmpty#9d05049 = UserStatus;
userStatusOnline#edb93949 expires:int = UserStatus;
userStatusOffline#8c703f was_online:int = UserStatus;
chatEmpty#9ba2d800 id:int = Chat;
chat#6e9c9bc7 id:int title:string photo:ChatPhoto participants_count:int date:int left:Bool version:int = Chat;
chatForbidden#fb0ccc41 id:int title:string date:int = Chat;
chatFull#630e61be id:int participants:ChatParticipants chat_photo:Photo notify_settings:PeerNotifySettings = ChatFull;
chatParticipant#c8d7493e user_id:int inviter_id:int date:int = ChatParticipant;
chatParticipantsForbidden#fd2bb8a chat_id:int = ChatParticipants;
chatParticipants#7841b415 chat_id:int admin_id:int participants:Vector<ChatParticipant> version:int = ChatParticipants;
chatPhotoEmpty#37c1011c = ChatPhoto;
chatPhoto#6153276a photo_small:FileLocation photo_big:FileLocation = ChatPhoto;
messageEmpty#83e5de54 id:int = Message;
message#22eb6aba id:int from_id:int to_id:Peer out:Bool unread:Bool date:int message:string media:MessageMedia = Message;
messageForwarded#5f46804 id:int fwd_from_id:int fwd_date:int from_id:int to_id:Peer out:Bool unread:Bool date:int message:string media:MessageMedia = Message;
messageService#9f8d60bb id:int from_id:int to_id:Peer out:Bool unread:Bool date:int action:MessageAction = Message;
messageMediaEmpty#3ded6320 = MessageMedia;
messageMediaPhoto#c8c45a2a photo:Photo = MessageMedia;
messageMediaVideo#a2d24290 video:Video = MessageMedia;
messageMediaGeo#56e0d474 geo:GeoPoint = MessageMedia;
messageMediaContact#5e7d2f39 phone_number:string first_name:string last_name:string user_id:int = MessageMedia;
messageMediaUnsupported#29632a36 bytes:bytes = MessageMedia;
messageActionEmpty#b6aef7b0 = MessageAction;
messageActionChatCreate#a6638b9a title:string users:Vector<int> = MessageAction;
messageActionChatEditTitle#b5a1ce5a title:string = MessageAction;
messageActionChatEditPhoto#7fcb13a8 photo:Photo = MessageAction;
messageActionChatDeletePhoto#95e3fbef = MessageAction;
messageActionChatAddUser#5e3cfc4b user_id:int = MessageAction;
messageActionChatDeleteUser#b2ae9b0c user_id:int = MessageAction;
dialog#214a8cdf peer:Peer top_message:int unread_count:int = Dialog;
photoEmpty#2331b22d id:long = Photo;
photo#22b56751 id:long access_hash:long user_id:int date:int caption:string geo:GeoPoint sizes:Vector<PhotoSize> = Photo;
photoSizeEmpty#e17e23c type:string = PhotoSize;
photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize;
photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize;
videoEmpty#c10658a8 id:long = Video;
video#5a04a49f id:long access_hash:long user_id:int date:int caption:string duration:int size:int thumb:PhotoSize dc_id:int w:int h:int = Video;
geoPointEmpty#1117dd5f = GeoPoint;
geoPoint#2049d70c long:double lat:double = GeoPoint;
auth.checkedPhone#e300cc3b phone_registered:Bool phone_invited:Bool = auth.CheckedPhone;
auth.sentCode#efed51d9 phone_registered:Bool phone_code_hash:string send_call_timeout:int is_password:Bool = auth.SentCode;
auth.authorization#f6b673a4 expires:int user:User = auth.Authorization;
auth.exportedAuthorization#df969c2d id:int bytes:bytes = auth.ExportedAuthorization;
inputNotifyPeer#b8bc5b0c peer:InputPeer = InputNotifyPeer;
inputNotifyUsers#193b4417 = InputNotifyPeer;
inputNotifyChats#4a95e84e = InputNotifyPeer;
inputNotifyAll#a429b886 = InputNotifyPeer;
inputPeerNotifyEventsEmpty#f03064d8 = InputPeerNotifyEvents;
inputPeerNotifyEventsAll#e86a2c74 = InputPeerNotifyEvents;
inputPeerNotifySettings#46a2ce98 mute_until:int sound:string show_previews:Bool events_mask:int = InputPeerNotifySettings;
peerNotifyEventsEmpty#add53cb3 = PeerNotifyEvents;
peerNotifyEventsAll#6d1ded88 = PeerNotifyEvents;
peerNotifySettingsEmpty#70a68512 = PeerNotifySettings;
peerNotifySettings#8d5e11ee mute_until:int sound:string show_previews:Bool events_mask:int = PeerNotifySettings;
wallPaper#ccb03657 id:int title:string sizes:Vector<PhotoSize> color:int = WallPaper;
userFull#771095da user:User link:contacts.Link profile_photo:Photo notify_settings:PeerNotifySettings blocked:Bool real_first_name:string real_last_name:string = UserFull;
contact#f911c994 user_id:int mutual:Bool = Contact;
importedContact#d0028438 user_id:int client_id:long = ImportedContact;
contactBlocked#561bc879 user_id:int date:int = ContactBlocked;
contactFound#ea879f95 user_id:int = ContactFound;
contactSuggested#3de191a1 user_id:int mutual_contacts:int = ContactSuggested;
contactStatus#aa77b873 user_id:int expires:int = ContactStatus;
chatLocated#3631cf4c chat_id:int distance:int = ChatLocated;
contacts.foreignLinkUnknown#133421f8 = contacts.ForeignLink;
contacts.foreignLinkRequested#a7801f47 has_phone:Bool = contacts.ForeignLink;
contacts.foreignLinkMutual#1bea8ce1 = contacts.ForeignLink;
contacts.myLinkEmpty#d22a1c60 = contacts.MyLink;
contacts.myLinkRequested#6c69efee contact:Bool = contacts.MyLink;
contacts.myLinkContact#c240ebd9 = contacts.MyLink;
contacts.link#eccea3f5 my_link:contacts.MyLink foreign_link:contacts.ForeignLink user:User = contacts.Link;
contacts.contacts#6f8b8cb2 contacts:Vector<Contact> users:Vector<User> = contacts.Contacts;
contacts.contactsNotModified#b74ba9d2 = contacts.Contacts;
contacts.importedContacts#d1cd0a4c imported:Vector<ImportedContact> users:Vector<User> = contacts.ImportedContacts;
contacts.blocked#1c138d15 blocked:Vector<ContactBlocked> users:Vector<User> = contacts.Blocked;
contacts.blockedSlice#900802a1 count:int blocked:Vector<ContactBlocked> users:Vector<User> = contacts.Blocked;
contacts.found#566000e results:Vector<ContactFound> users:Vector<User> = contacts.Found;
contacts.suggested#5649dcc5 results:Vector<ContactSuggested> users:Vector<User> = contacts.Suggested;
messages.dialogs#15ba6c40 dialogs:Vector<Dialog> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Dialogs;
messages.dialogsSlice#71e094f3 count:int dialogs:Vector<Dialog> messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Dialogs;
messages.messages#8c718e87 messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.messagesSlice#b446ae3 count:int messages:Vector<Message> chats:Vector<Chat> users:Vector<User> = messages.Messages;
messages.messageEmpty#3f4e0648 = messages.Message;
messages.message#ff90c417 message:Message chats:Vector<Chat> users:Vector<User> = messages.Message;
messages.statedMessages#969478bb messages:Vector<Message> chats:Vector<Chat> users:Vector<User> pts:int seq:int = messages.StatedMessages;
messages.statedMessage#d07ae726 message:Message chats:Vector<Chat> users:Vector<User> pts:int seq:int = messages.StatedMessage;
messages.sentMessage#d1f4d35c id:int date:int pts:int seq:int = messages.SentMessage;
messages.chat#40e9002a chat:Chat users:Vector<User> = messages.Chat;
messages.chats#8150cbd8 chats:Vector<Chat> users:Vector<User> = messages.Chats;
messages.chatFull#e5d7d19c full_chat:ChatFull chats:Vector<Chat> users:Vector<User> = messages.ChatFull;
messages.affectedHistory#b7de36f2 pts:int seq:int offset:int = messages.AffectedHistory;
inputMessagesFilterEmpty#57e2f66c = MessagesFilter;
inputMessagesFilterPhotos#9609a51c = MessagesFilter;
inputMessagesFilterVideo#9fc00e65 = MessagesFilter;
inputMessagesFilterPhotoVideo#56e9f0e4 = MessagesFilter;
inputMessagesFilterDocument#9eddf188 = MessagesFilter;
inputMessagesFilterAudio#cfc87522 = MessagesFilter;
updateNewMessage#13abdb3 message:Message pts:int = Update;
updateMessageID#4e90bfd6 id:int random_id:long = Update;
updateReadMessages#c6649e31 messages:Vector<int> pts:int = Update;
updateDeleteMessages#a92bfe26 messages:Vector<int> pts:int = Update;
updateRestoreMessages#d15de04d messages:Vector<int> pts:int = Update;
updateUserTyping#6baa8508 user_id:int = Update;
updateChatUserTyping#3c46cfe6 chat_id:int user_id:int = Update;
updateChatParticipants#7761198 participants:ChatParticipants = Update;
updateUserStatus#1bfbd823 user_id:int status:UserStatus = Update;
updateUserName#da22d9ad user_id:int first_name:string last_name:string = Update;
updateUserPhoto#95313b0c user_id:int date:int photo:UserProfilePhoto previous:Bool = Update;
updateContactRegistered#2575bbb9 user_id:int date:int = Update;
updateContactLink#51a48a9a user_id:int my_link:contacts.MyLink foreign_link:contacts.ForeignLink = Update;
updateActivation#6f690963 user_id:int = Update;
updateNewAuthorization#8f06529a auth_key_id:long date:int device:string location:string = Update;
updates.state#a56c2a3e pts:int qts:int date:int seq:int unread_count:int = updates.State;
updates.differenceEmpty#5d75a138 date:int seq:int = updates.Difference;
updates.difference#f49ca0 new_messages:Vector<Message> new_encrypted_messages:Vector<EncryptedMessage> other_updates:Vector<Update> chats:Vector<Chat> users:Vector<User> state:updates.State = updates.Difference;
updates.differenceSlice#a8fb1981 new_messages:Vector<Message> new_encrypted_messages:Vector<EncryptedMessage> other_updates:Vector<Update> chats:Vector<Chat> users:Vector<User> intermediate_state:updates.State = updates.Difference;
updatesTooLong#e317af7e = Updates;
updateShortMessage#d3f45784 id:int from_id:int message:string pts:int date:int seq:int = Updates;
updateShortChatMessage#2b2fbd4e id:int from_id:int chat_id:int message:string pts:int date:int seq:int = Updates;
updateShort#78d4dec1 update:Update date:int = Updates;
updatesCombined#725b04c3 updates:Vector<Update> users:Vector<User> chats:Vector<Chat> date:int seq_start:int seq:int = Updates;
updates#74ae4240 updates:Vector<Update> users:Vector<User> chats:Vector<Chat> date:int seq:int = Updates;
photos.photos#8dca6aa5 photos:Vector<Photo> users:Vector<User> = photos.Photos;
photos.photosSlice#15051f54 count:int photos:Vector<Photo> users:Vector<User> = photos.Photos;
photos.photo#20212ca8 photo:Photo users:Vector<User> = photos.Photo;
upload.file#96a18d5 type:storage.FileType mtime:int bytes:bytes = upload.File;
dcOption#2ec2a43c id:int hostname:string ip_address:string port:int = DcOption;
config#2e54dd74 date:int test_mode:Bool this_dc:int dc_options:Vector<DcOption> chat_size_max:int broadcast_size_max:int = Config;
nearestDc#8e1a1775 country:string this_dc:int nearest_dc:int = NearestDc;
help.appUpdate#8987f311 id:int critical:Bool url:string text:string = help.AppUpdate;
help.noAppUpdate#c45a6536 = help.AppUpdate;
help.inviteText#18cb9f78 message:string = help.InviteText;
messages.statedMessagesLinks#3e74f5c6 messages:Vector<Message> chats:Vector<Chat> users:Vector<User> links:Vector<contacts.Link> pts:int seq:int = messages.StatedMessages;
messages.statedMessageLink#a9af2881 message:Message chats:Vector<Chat> users:Vector<User> links:Vector<contacts.Link> pts:int seq:int = messages.StatedMessage;
messages.sentMessageLink#e9db4a3f id:int date:int pts:int seq:int links:Vector<contacts.Link> = messages.SentMessage;
inputGeoChat#74d456fa chat_id:int access_hash:long = InputGeoChat;
inputNotifyGeoChatPeer#4d8ddec8 peer:InputGeoChat = InputNotifyPeer;
geoChat#75eaea5a id:int access_hash:long title:string address:string venue:string geo:GeoPoint photo:ChatPhoto participants_count:int date:int checked_in:Bool version:int = Chat;
geoChatMessageEmpty#60311a9b chat_id:int id:int = GeoChatMessage;
geoChatMessage#4505f8e1 chat_id:int id:int from_id:int date:int message:string media:MessageMedia = GeoChatMessage;
geoChatMessageService#d34fa24e chat_id:int id:int from_id:int date:int action:MessageAction = GeoChatMessage;
geochats.statedMessage#17b1578b message:GeoChatMessage chats:Vector<Chat> users:Vector<User> seq:int = geochats.StatedMessage;
geochats.located#48feb267 results:Vector<ChatLocated> messages:Vector<GeoChatMessage> chats:Vector<Chat> users:Vector<User> = geochats.Located;
geochats.messages#d1526db1 messages:Vector<GeoChatMessage> chats:Vector<Chat> users:Vector<User> = geochats.Messages;
geochats.messagesSlice#bc5863e8 count:int messages:Vector<GeoChatMessage> chats:Vector<Chat> users:Vector<User> = geochats.Messages;
messageActionGeoChatCreate#6f038ebc title:string address:string = MessageAction;
messageActionGeoChatCheckin#c7d53de = MessageAction;
updateNewGeoChatMessage#5a68e3f7 message:GeoChatMessage = Update;
wallPaperSolid#63117f24 id:int title:string bg_color:int color:int = WallPaper;
updateNewEncryptedMessage#12bcbd9a message:EncryptedMessage qts:int = Update;
updateEncryptedChatTyping#1710f156 chat_id:int = Update;
updateEncryption#b4a2e88d chat:EncryptedChat date:int = Update;
updateEncryptedMessagesRead#38fe25b7 chat_id:int max_date:int date:int = Update;
encryptedChatEmpty#ab7ec0a0 id:int = EncryptedChat;
encryptedChatWaiting#3bf703dc id:int access_hash:long date:int admin_id:int participant_id:int = EncryptedChat;
encryptedChatRequested#c878527e id:int access_hash:long date:int admin_id:int participant_id:int g_a:bytes = EncryptedChat;
encryptedChat#fa56ce36 id:int access_hash:long date:int admin_id:int participant_id:int g_a_or_b:bytes key_fingerprint:long = EncryptedChat;
encryptedChatDiscarded#13d6dd27 id:int = EncryptedChat;
inputEncryptedChat#f141b5e1 chat_id:int access_hash:long = InputEncryptedChat;
encryptedFileEmpty#c21f497e = EncryptedFile;
encryptedFile#4a70994c id:long access_hash:long size:int dc_id:int key_fingerprint:int = EncryptedFile;
inputEncryptedFileEmpty#1837c364 = InputEncryptedFile;
inputEncryptedFileUploaded#64bd0306 id:long parts:int md5_checksum:string key_fingerprint:int = InputEncryptedFile;
inputEncryptedFile#5a17b5e5 id:long access_hash:long = InputEncryptedFile;
inputEncryptedFileLocation#f5235d55 id:long access_hash:long = InputFileLocation;
encryptedMessage#ed18c118 random_id:long chat_id:int date:int bytes:bytes file:EncryptedFile = EncryptedMessage;
encryptedMessageService#23734b06 random_id:long chat_id:int date:int bytes:bytes = EncryptedMessage;
decryptedMessageLayer#99a438cf layer:int message:DecryptedMessage = DecryptedMessageLayer;
decryptedMessage#1f814f1f random_id:long random_bytes:bytes message:string media:DecryptedMessageMedia = DecryptedMessage;
decryptedMessageService#aa48327d random_id:long random_bytes:bytes action:DecryptedMessageAction = DecryptedMessage;
decryptedMessageMediaEmpty#89f5c4a = DecryptedMessageMedia;
decryptedMessageMediaPhoto#32798a8c thumb:bytes thumb_w:int thumb_h:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaVideo#4cee6ef3 thumb:bytes thumb_w:int thumb_h:int duration:int w:int h:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaGeoPoint#35480a59 lat:double long:double = DecryptedMessageMedia;
decryptedMessageMediaContact#588a0a97 phone_number:string first_name:string last_name:string user_id:int = DecryptedMessageMedia;
decryptedMessageActionSetMessageTTL#a1733aec ttl_seconds:int = DecryptedMessageAction;
messages.dhConfigNotModified#c0e24635 random:bytes = messages.DhConfig;
messages.dhConfig#2c221edd g:int p:bytes version:int random:bytes = messages.DhConfig;
messages.sentEncryptedMessage#560f8935 date:int = messages.SentEncryptedMessage;
messages.sentEncryptedFile#9493ff32 date:int file:EncryptedFile = messages.SentEncryptedMessage;
inputFileBig#fa4f0bb5 id:long parts:int name:string = InputFile;
inputEncryptedFileBigUploaded#2dc173c8 id:long parts:int key_fingerprint:int = InputEncryptedFile;
updateChatParticipantAdd#3a0eeb22 chat_id:int user_id:int inviter_id:int version:int = Update;
updateChatParticipantDelete#6e5f8c22 chat_id:int user_id:int version:int = Update;
updateDcOptions#8e5e9873 dc_options:Vector<DcOption> = Update;
inputMediaUploadedAudio#61a6d436 file:InputFile duration:int = InputMedia;
inputMediaAudio#89938781 id:InputAudio = InputMedia;
inputMediaUploadedDocument#34e794bd file:InputFile file_name:string mime_type:string = InputMedia;
inputMediaUploadedThumbDocument#3e46de5d file:InputFile thumb:InputFile file_name:string mime_type:string = InputMedia;
inputMediaDocument#d184e841 id:InputDocument = InputMedia;
messageMediaDocument#2fda2204 document:Document = MessageMedia;
messageMediaAudio#c6b68300 audio:Audio = MessageMedia;
inputAudioEmpty#d95adc84 = InputAudio;
inputAudio#77d440ff id:long access_hash:long = InputAudio;
inputDocumentEmpty#72f0eaae = InputDocument;
inputDocument#18798952 id:long access_hash:long = InputDocument;
inputAudioFileLocation#74dc404d id:long access_hash:long = InputFileLocation;
inputDocumentFileLocation#4e45abe9 id:long access_hash:long = InputFileLocation;
decryptedMessageMediaDocument#b095434b thumb:bytes thumb_w:int thumb_h:int file_name:string mime_type:string size:int key:bytes iv:bytes = DecryptedMessageMedia;
decryptedMessageMediaAudio#6080758f duration:int size:int key:bytes iv:bytes = DecryptedMessageMedia;
audioEmpty#586988d8 id:long = Audio;
audio#427425e7 id:long access_hash:long user_id:int date:int duration:int size:int dc_id:int = Audio;
documentEmpty#36f8c871 id:long = Document;
document#9efc6326 id:long access_hash:long user_id:int date:int file_name:string mime_type:string size:int thumb:PhotoSize dc_id:int = Document;
help.support#17c6b5f6 phone_number:string user:User = help.Support;
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;
invokeAfterMsgs#3dc4b4f0 {X:Type} msg_ids:Vector<long> query:!X = X;
auth.checkPhone#6fe51dfb phone_number:string = auth.CheckedPhone;
auth.sendCode#768d5f4d phone_number:string sms_type:int api_id:int api_hash:string lang_code:string = auth.SentCode;
auth.sendCall#3c51564 phone_number:string phone_code_hash:string = Bool;
auth.signUp#1b067634 phone_number:string phone_code_hash:string phone_code:string first_name:string last_name:string = auth.Authorization;
auth.signIn#bcd51581 phone_number:string phone_code_hash:string phone_code:string = auth.Authorization;
auth.logOut#5717da40 = Bool;
auth.resetAuthorizations#9fab0d1a = Bool;
auth.sendInvites#771c1d97 phone_numbers:Vector<string> message:string = Bool;
auth.exportAuthorization#e5bfffcd dc_id:int = auth.ExportedAuthorization;
auth.importAuthorization#e3ef9613 id:int bytes:bytes = auth.Authorization;
account.registerDevice#446c712c token_type:int token:string device_model:string system_version:string app_version:string app_sandbox:Bool lang_code:string = Bool;
account.unregisterDevice#65c55b40 token_type:int token:string = Bool;
account.updateNotifySettings#84be5b93 peer:InputNotifyPeer settings:InputPeerNotifySettings = Bool;
account.getNotifySettings#12b3ad31 peer:InputNotifyPeer = PeerNotifySettings;
account.resetNotifySettings#db7e1747 = Bool;
account.updateProfile#f0888d68 first_name:string last_name:string = User;
account.updateStatus#6628562c offline:Bool = Bool;
account.getWallPapers#c04cfac2 = Vector<WallPaper>;
users.getUsers#d91a548 id:Vector<InputUser> = Vector<User>;
users.getFullUser#ca30a5b1 id:InputUser = UserFull;
contacts.getStatuses#c4a353ee = Vector<ContactStatus>;
contacts.getContacts#22c6aa08 hash:string = contacts.Contacts;
contacts.importContacts#da30b32d contacts:Vector<InputContact> replace:Bool = contacts.ImportedContacts;
contacts.search#11f812d8 q:string limit:int = contacts.Found;
contacts.getSuggested#cd773428 limit:int = contacts.Suggested;
contacts.deleteContact#8e953744 id:InputUser = contacts.Link;
contacts.deleteContacts#59ab389e id:Vector<InputUser> = Bool;
contacts.block#332b49fc id:InputUser = Bool;
contacts.unblock#e54100bd id:InputUser = Bool;
contacts.getBlocked#f57c350f offset:int limit:int = contacts.Blocked;
messages.getMessages#4222fa74 id:Vector<int> = messages.Messages;
messages.getDialogs#eccf1df6 offset:int max_id:int limit:int = messages.Dialogs;
messages.getHistory#92a1df2f peer:InputPeer offset:int max_id:int limit:int = messages.Messages;
messages.search#7e9f2ab peer:InputPeer q:string filter:MessagesFilter min_date:int max_date:int offset:int max_id:int limit:int = messages.Messages;
messages.readHistory#b04f2510 peer:InputPeer max_id:int offset:int = messages.AffectedHistory;
messages.deleteHistory#f4f8fb61 peer:InputPeer offset:int = messages.AffectedHistory;
messages.deleteMessages#14f2dd0a id:Vector<int> = Vector<int>;
messages.restoreMessages#395f9d7e id:Vector<int> = Vector<int>;
messages.receivedMessages#28abcb68 max_id:int = Vector<int>;
messages.setTyping#719839e9 peer:InputPeer typing:Bool = Bool;
messages.sendMessage#4cde0aab peer:InputPeer message:string random_id:long = messages.SentMessage;
messages.sendMedia#a3c85d76 peer:InputPeer media:InputMedia random_id:long = messages.StatedMessage;
messages.forwardMessages#514cd10f peer:InputPeer id:Vector<int> = messages.StatedMessages;
messages.getChats#3c6aa187 id:Vector<int> = messages.Chats;
messages.getFullChat#3b831c66 chat_id:int = messages.ChatFull;
messages.editChatTitle#b4bc68b5 chat_id:int title:string = messages.StatedMessage;
messages.editChatPhoto#d881821d chat_id:int photo:InputChatPhoto = messages.StatedMessage;
messages.addChatUser#2ee9ee9e chat_id:int user_id:InputUser fwd_limit:int = messages.StatedMessage;
messages.deleteChatUser#c3c5cd23 chat_id:int user_id:InputUser = messages.StatedMessage;
messages.createChat#419d9aee users:Vector<InputUser> title:string = messages.StatedMessage;
updates.getState#edd4882a = updates.State;
updates.getDifference#a041495 pts:int date:int qts:int = updates.Difference;
photos.updateProfilePhoto#eef579a0 id:InputPhoto crop:InputPhotoCrop = UserProfilePhoto;
photos.uploadProfilePhoto#d50f9c88 file:InputFile caption:string geo_point:InputGeoPoint crop:InputPhotoCrop = photos.Photo;
upload.saveFilePart#b304a621 file_id:long file_part:int bytes:bytes = Bool;
upload.getFile#e3a6cfb5 location:InputFileLocation offset:int limit:int = upload.File;
help.getConfig#c4f9186b = Config;
help.getNearestDc#1fb33026 = NearestDc;
help.getAppUpdate#c812ac7e device_model:string system_version:string app_version:string lang_code:string = help.AppUpdate;
help.saveAppLog#6f02f748 events:Vector<InputAppEvent> = Bool;
help.getInviteText#a4a95186 lang_code:string = help.InviteText;
photos.getUserPhotos#b7ee553c user_id:InputUser offset:int max_id:int limit:int = photos.Photos;
messages.forwardMessage#3f3f4f2 peer:InputPeer id:int random_id:long = messages.StatedMessage;
messages.sendBroadcast#41bb0972 contacts:Vector<InputUser> message:string media:InputMedia = messages.StatedMessages;
geochats.getLocated#7f192d8f geo_point:InputGeoPoint radius:int limit:int = geochats.Located;
geochats.getRecents#e1427e6f offset:int limit:int = geochats.Messages;
geochats.checkin#55b3e8fb peer:InputGeoChat = geochats.StatedMessage;
geochats.getFullChat#6722dd6f peer:InputGeoChat = messages.ChatFull;
geochats.editChatTitle#4c8e2273 peer:InputGeoChat title:string address:string = geochats.StatedMessage;
geochats.editChatPhoto#35d81a95 peer:InputGeoChat photo:InputChatPhoto = geochats.StatedMessage;
geochats.search#cfcdc44d peer:InputGeoChat q:string filter:MessagesFilter min_date:int max_date:int offset:int max_id:int limit:int = geochats.Messages;
geochats.getHistory#b53f7a68 peer:InputGeoChat offset:int max_id:int limit:int = geochats.Messages;
geochats.setTyping#8b8a729 peer:InputGeoChat typing:Bool = Bool;
geochats.sendMessage#61b0044 peer:InputGeoChat message:string random_id:long = geochats.StatedMessage;
geochats.sendMedia#b8f0deff peer:InputGeoChat media:InputMedia random_id:long = geochats.StatedMessage;
geochats.createGeoChat#e092e16 title:string geo_point:InputGeoPoint address:string venue:string = geochats.StatedMessage;
messages.getDhConfig#26cf8950 version:int random_length:int = messages.DhConfig;
messages.requestEncryption#f64daf43 user_id:InputUser random_id:int g_a:bytes = EncryptedChat;
messages.acceptEncryption#3dbc0415 peer:InputEncryptedChat g_b:bytes key_fingerprint:long = EncryptedChat;
messages.discardEncryption#edd923c5 chat_id:int = Bool;
messages.setEncryptedTyping#791451ed peer:InputEncryptedChat typing:Bool = Bool;
messages.readEncryptedHistory#7f4b690a peer:InputEncryptedChat max_date:int = Bool;
messages.sendEncrypted#a9776773 peer:InputEncryptedChat random_id:long data:bytes = messages.SentEncryptedMessage;
messages.sendEncryptedFile#9a901b66 peer:InputEncryptedChat random_id:long data:bytes file:InputEncryptedFile = messages.SentEncryptedMessage;
messages.sendEncryptedService#32d439a4 peer:InputEncryptedChat random_id:long data:bytes = messages.SentEncryptedMessage;
messages.receivedQueue#55a5bb66 max_qts:int = Vector<long>;
upload.saveBigFilePart#de7b673d file_id:long file_part:int file_total_parts:int bytes:bytes = Bool;
initConnection#69796de9 {X:Type} api_id:int device_model:string system_version:string app_version:string lang_code:string query:!X = X;
help.getSupport#9cdf08cd = help.Support;
invokeWithLayer12#dda60d3c {X:Type} query:!X = X;

View File

@ -405,6 +405,9 @@ notifyAll#74d07c60 = NotifyPeer;
updateUserBlocked#80ece81a user_id:int blocked:Bool = Update;
updateNotifySettings#bec268ef peer:NotifyPeer notify_settings:PeerNotifySettings = Update;
za int = Z 0;
zb {n:#} int %(Vector int) = Z (n + 1);
---functions---
invokeAfterMsg#cb9f372d {X:Type} msg_id:long query:!X = X;

View File

@ -272,14 +272,22 @@ char *parse_lex (void) {
if (curch == '#') {
parse.lex.flags |= 2;
int i;
int ok = 1;
for (i = 0; i < 8; i++) {
if (!is_hexdigit (nextch())) {
parse_error ("Hex digit expected");
parse.lex.type = lex_error;
return (parse.lex.ptr = (void *)-1);
if (curch == ' ' && i >= 5) {
ok = 2;
break;
} else {
parse_error ("Hex digit expected");
parse.lex.type = lex_error;
return (parse.lex.ptr = (void *)-1);
}
}
}
nextch ();
if (ok == 1) {
nextch ();
}
}
parse.lex.len = parse.text + parse.pos - p;
parse.lex.type = lex_lc_ident;
@ -1117,9 +1125,9 @@ struct tl_constructor *tl_add_constructor (struct tl_type *a, const char *_id, i
unsigned magic = 0;
if (x < len) {
assert (len - x == 9);
assert (len - x >= 6 && len - x <= 9);
int i;
for (i = 1; i <= 8; i++) {
for (i = 1; i < len - x; i++) {
magic = (magic << 4) + (_id[x + i] <= '9' ? _id[x + i] - '0' : _id[x + i] - 'a' + 10);
}
assert (magic && magic != (unsigned)-1);
@ -1178,9 +1186,9 @@ struct tl_constructor *tl_add_function (struct tl_type *a, const char *_id, int
unsigned magic = 0;
if (x < len) {
assert (len - x == 9);
assert (len - x >= 6 && len - x <= 9);
int i;
for (i = 1; i <= 8; i++) {
for (i = 1; i < len - x; i++) {
magic = (magic << 4) + (_id[x + i] <= '9' ? _id[x + i] - '0' : _id[x + i] - 'a' + 10);
}
assert (magic && magic != (unsigned)-1);

1
tlc.c
View File

@ -129,6 +129,7 @@ int main (int argc, char **argv) {
usage ();
}
struct parse *P = tl_init_parse_file (argv[optind]);
if (!P) {
return 0;