Commit a37e5f43 authored by vysheng's avatar vysheng

A bit working version

parent 084e5dfe
...@@ -27,20 +27,18 @@ int skip_string (void) { ...@@ -27,20 +27,18 @@ int skip_string (void) {
unsigned len = *(unsigned char *)in_ptr; unsigned len = *(unsigned char *)in_ptr;
if (len == 0xff) { return -1; } if (len == 0xff) { return -1; }
if (len < 0xfe) { if (len < 0xfe) {
int size = len + 1; unsigned size = (len + 4) >> 2;
size += (-size) & 3; if (in_ptr + size <= in_end) {
if (in_ptr + (size / 4) <= in_end) { in_ptr += size;
in_ptr += (size / 4);
return 0; return 0;
} else { } else {
return -1; return -1;
} }
} else { } else {
len = (*in_ptr) >> 8; len = (*(unsigned *)in_ptr) >> 8;
int size = len + 4; unsigned size = (len + 7) >> 2;
size += (-size) & 3; if (in_ptr + size <= in_end) {
if (in_ptr + (size / 4) <= in_end) { in_ptr += size;
in_ptr += (size / 4);
return 0; return 0;
} else { } else {
return -1; return -1;
......
...@@ -20,8 +20,6 @@ struct paramed_type { ...@@ -20,8 +20,6 @@ struct paramed_type {
#define INT2PTR(x) (void *)(long)(((long)x) * 2 + 1) #define INT2PTR(x) (void *)(long)(((long)x) * 2 + 1)
#define PTR2INT(x) ((((long)x) - 1) / 2) #define PTR2INT(x) ((((long)x) - 1) / 2)
#define FETCH_COMBINATOR_FUNCTION(NAME)
#include "auto/auto-header.h" #include "auto/auto-header.h"
#endif #endif
This diff is collapsed.
...@@ -21,30 +21,6 @@ ...@@ -21,30 +21,6 @@
#include "structures.h" #include "structures.h"
#define LOG_START 0x8948329a
#define LOG_AUTH_KEY 0x984932aa
#define LOG_DEFAULT_DC 0x95382908
#define LOG_OUR_ID 0x8943211a
#define LOG_DC_SIGNED 0x234f9893
#define LOG_DC_SALT 0x92192ffa
#define LOG_DH_CONFIG 0x8983402b
#define LOG_ENCR_CHAT_KEY 0x894320aa
#define LOG_ENCR_CHAT_SEND_ACCEPT 0x12ab01c4
#define LOG_ENCR_CHAT_SEND_CREATE 0xab091e24
#define LOG_ENCR_CHAT_DELETED 0x99481230
#define LOG_ENCR_CHAT_WAITING 0x7102100a
#define LOG_ENCR_CHAT_REQUESTED 0x9011011a
#define LOG_ENCR_CHAT_OK 0x7612ce13
#define CODE_binlog_create_message_service 0xbbe5e94b
#define CODE_binlog_create_message_service_fwd 0xea9c57ae
#define CODE_binlog_create_message_media_fwd 0xbefdc462
#define CODE_binlog_set_unread 0x21d4c909
#define CODE_binlog_set_message_sent 0xc335282b
#define CODE_binlog_set_msg_id 0xf3285b6a
#define CODE_binlog_create_message_service_encr 0x8b4b9395
#define CODE_binlog_delete_msg 0xa1d6ab6d
void *alloc_log_event (int l); void *alloc_log_event (int l);
void replay_log (void); void replay_log (void);
void add_log_event (const int *data, int l); void add_log_event (const int *data, int l);
...@@ -54,16 +30,16 @@ void bl_do_set_auth_key_id (int num, unsigned char *buf); ...@@ -54,16 +30,16 @@ void bl_do_set_auth_key_id (int num, unsigned char *buf);
void bl_do_dc_option (int id, int l1, const char *name, int l2, const char *ip, int port); void bl_do_dc_option (int id, int l1, const char *name, int l2, const char *ip, int port);
void bl_do_set_our_id (int id); void bl_do_set_our_id (int id);
void bl_do_new_user (int id, const char *f, int fl, const char *l, int ll, long long access_token, const char *p, int pl, int contact); void bl_do_user_add (int id, const char *f, int fl, const char *l, int ll, long long access_token, const char *p, int pl, int contact);
void bl_do_user_delete (struct user *U); void bl_do_user_delete (struct user *U);
void bl_do_set_user_profile_photo (struct user *U, long long photo_id, struct file_location *big, struct file_location *small); void bl_do_set_user_profile_photo (struct user *U, long long photo_id, struct file_location *big, struct file_location *small);
void bl_do_set_user_name (struct user *U, const char *f, int fl, const char *l, int ll); void bl_do_user_set_name (struct user *U, const char *f, int fl, const char *l, int ll);
void bl_do_set_user_access_token (struct user *U, long long access_token); void bl_do_user_set_access_hash (struct user *U, long long access_token);
void bl_do_set_user_phone (struct user *U, const char *p, int pl); void bl_do_user_set_phone (struct user *U, const char *p, int pl);
void bl_do_set_user_friend (struct user *U, int friend); void bl_do_user_set_friend (struct user *U, int friend);
void bl_do_set_user_full_photo (struct user *U, const int *start, int len); void bl_do_user_set_full_photo (struct user *U, const int *start, int len);
void bl_do_set_user_blocked (struct user *U, int blocked); void bl_do_user_set_blocked (struct user *U, int blocked);
void bl_do_set_user_real_name (struct user *U, const char *f, int fl, const char *l, int ll); void bl_do_user_set_real_name (struct user *U, const char *f, int fl, const char *l, int ll);
void bl_do_encr_chat_delete (struct secret_chat *U); void bl_do_encr_chat_delete (struct secret_chat *U);
void bl_do_encr_chat_requested (struct secret_chat *U, long long access_hash, int date, int admin_id, int user_id, unsigned char g_key[], unsigned char nonce[]); void bl_do_encr_chat_requested (struct secret_chat *U, long long access_hash, int date, int admin_id, int user_id, unsigned char g_key[], unsigned char nonce[]);
......
...@@ -3,6 +3,7 @@ binlog.fileLocation dc:int volume:long local_id:int secret:long = binlog.FileLoc ...@@ -3,6 +3,7 @@ binlog.fileLocation dc:int volume:long local_id:int secret:long = binlog.FileLoc
binlog.chatParticipant user:int inviter:int date:int = binlog.ChatParticipant; binlog.chatParticipant user:int inviter:int date:int = binlog.ChatParticipant;
binlog.start = binlog.Update; binlog.start = binlog.Update;
binlog.dcOption id:int name:string ip:string port:int = binlog.Update; binlog.dcOption id:int name:string ip:string port:int = binlog.Update;
binlog.authKey dc:int key_id:long key:64*[int] = binlog.Update; binlog.authKey dc:int key_id:long key:64*[int] = binlog.Update;
binlog.defaultDc dc:int = binlog.Update; binlog.defaultDc dc:int = binlog.Update;
...@@ -16,14 +17,16 @@ binlog.setQts qts:int = binlog.Update; ...@@ -16,14 +17,16 @@ binlog.setQts qts:int = binlog.Update;
binlog.setDate date:int = binlog.Update; binlog.setDate date:int = binlog.Update;
binlog.setSeq seq:int = binlog.Update; binlog.setSeq seq:int = binlog.Update;
binlog.newUser id:int first_name:string last_name:string hash:long phone:string is_contact:int = binlog.Update; binlog.userAdd id:int first_name:string last_name:string hash:long phone:string is_contact:int = binlog.Update;
binlog.userDelete id:int = binlog.Update; binlog.userDelete id:int = binlog.Update;
binlog.setUserAccessToken id:int hash:long = binlog.Update; binlog.userSetAccessHash id:int hash:long = binlog.Update;
binlog.setUserPhone id:int phone:string = binlog.Update; binlog.userSetPhone id:int phone:string = binlog.Update;
binlog.setUserFriend id:int friend:int = binlog.Update; binlog.userSetFriend id:int friend:int = binlog.Update;
binlog.userFullPhoto id:int photo:Photo = binlog.Update; binlog.userSetFullPhoto id:int photo:Photo = binlog.Update;
binlog.userBlocked id:int blocked:int = binlog.Update; binlog.userSetBlocked id:int blocked:int = binlog.Update;
binlog.setUserFullName id:int real_first_name:string real_last_name:string = binlog.Update; binlog.userSetRealName id:int real_first_name:string real_last_name:string = binlog.Update;
binlog.userSetName id:int first_name:string last_name:string = binlog.Update;
binlog.userSetPhoto id:int photo:UserProfilePhoto = binlog.Update;
binlog.encrChatDelete id:int = binlog.Update; binlog.encrChatDelete id:int = binlog.Update;
binlog.encrChatRequested id:int hash:long date:int admin:int user:int key:64*[int] nonce:64*[int] = binlog.Update; binlog.encrChatRequested id:int hash:long date:int admin:int user:int key:64*[int] nonce:64*[int] = binlog.Update;
...@@ -34,7 +37,6 @@ binlog.encrChatAccepted id:int key:64*[int] nonce:64*[int] fingerprint:long = bi ...@@ -34,7 +37,6 @@ binlog.encrChatAccepted id:int key:64*[int] nonce:64*[int] fingerprint:long = bi
binlog.setEncrChatKey id:int key:64*[int] fingerprint:long = binlog.Update; binlog.setEncrChatKey id:int key:64*[int] fingerprint:long = binlog.Update;
binlog.encrChatInit id:int user:int key:64*[int] g_key:64*[int] = binlog.Update; binlog.encrChatInit id:int user:int key:64*[int] g_key:64*[int] = binlog.Update;
binlog.chatCreate id:int flags:int title:string user_num:int date:int version:int photo_big:%binlog.FileLocation photo_small:%binlog.FileLocation = binlog.Update; binlog.chatCreate id:int flags:int title:string user_num:int date:int version:int photo_big:%binlog.FileLocation photo_small:%binlog.FileLocation = binlog.Update;
binlog.chatChangeFlags id:int set_flags:int clear_flags:int = binlog.Update; binlog.chatChangeFlags id:int set_flags:int clear_flags:int = binlog.Update;
binlog.setChatTitle id:int title:string = binlog.Update; binlog.setChatTitle id:int title:string = binlog.Update;
...@@ -52,3 +54,11 @@ binlog.sendMessageText id:long from_id:int to_type:int to_id:int date:int text:s ...@@ -52,3 +54,11 @@ binlog.sendMessageText id:long from_id:int to_type:int to_id:int date:int text:s
binlog.createMessageTextFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int text:string = binlog.Update; binlog.createMessageTextFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int text:string = binlog.Update;
binlog.createMessageMedia id:int from_id:int to_type:int to_id:int date:int text:string media:MessageMedia = binlog.Update; binlog.createMessageMedia id:int from_id:int to_type:int to_id:int date:int text:string media:MessageMedia = binlog.Update;
binlog.createMessageMediaEncr id:int from_id:int to_type:int to_id:int date:int text:string media:DecryptedMessageMedia file:EncryptedFile = binlog.Update; binlog.createMessageMediaEncr id:int from_id:int to_type:int to_id:int date:int text:string media:DecryptedMessageMedia file:EncryptedFile = binlog.Update;
binlog.createMessageMediaFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int text:string media:MessageMedia = binlog.Update;
binlog.createMessageService id:int from_id:int to_type:int to_id:int date:int action:MessageAction = binlog.Update;
binlog.createMessageServiceEncr id:int from_id:int to_type:int to_id:int date:int action:DecryptedMessageAction = binlog.Update;
binlog.createMessageServiceFwd id:int from_id:int to_type:int to_id:int date:int fwd_from_id:int fwd_date:int action:MessageAction = binlog.Update;
binlog.messageSetUnread id:int = binlog.Update;
binlog.setMessageSent id:long = binlog.Update;
binlog.setMsgId old_id:long new_id:int = binlog.Update;
binlog.deleteMsg id:long = binlog.Update;
...@@ -376,9 +376,9 @@ int gen_field_fetch (struct arg *arg, int *vars, int num) { ...@@ -376,9 +376,9 @@ int gen_field_fetch (struct arg *arg, int *vars, int num) {
bare = ((struct tl_tree_type *)arg->type)->self.flags & FLAG_BARE; bare = ((struct tl_tree_type *)arg->type)->self.flags & FLAG_BARE;
} }
if (!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); 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->print_id, num);
} else { } 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); 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->print_id, num);
} }
} else { } else {
assert (t == NODE_TYPE_ARRAY); assert (t == NODE_TYPE_ARRAY);
...@@ -400,7 +400,7 @@ int gen_field_fetch (struct arg *arg, int *vars, int num) { ...@@ -400,7 +400,7 @@ int gen_field_fetch (struct arg *arg, int *vars, int num) {
} }
void gen_constructor_fetch (struct tl_combinator *c) { void gen_constructor_fetch (struct tl_combinator *c) {
printf ("int skip_constructor_%s (struct paramed_type *T) {\n", c->id); printf ("int skip_constructor_%s (struct paramed_type *T) {\n", c->print_id);
static char s[10000]; static char s[10000];
sprintf (s, "T"); sprintf (s, "T");
...@@ -439,21 +439,21 @@ void gen_constructor_fetch (struct tl_combinator *c) { ...@@ -439,21 +439,21 @@ void gen_constructor_fetch (struct tl_combinator *c) {
} }
void gen_type_fetch (struct tl_type *t) { void gen_type_fetch (struct tl_type *t) {
printf ("int skip_type_%s (struct paramed_type *T) {\n", t->id); printf ("int skip_type_%s (struct paramed_type *T) {\n", t->print_id);
printf (" int magic = *in_ptr;\n"); printf (" int magic = *in_ptr;\n");
printf (" if (skip_int () < 0) { return -1; }\n"); printf (" if (skip_int () < 0) { return -1; }\n");
printf (" switch (magic) {\n"); printf (" switch (magic) {\n");
int i; int i;
for (i = 0; i < t->constructors_num; 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 (" case 0x%08x: return skip_constructor_%s (T);\n", t->constructors[i]->name, t->constructors[i]->print_id);
} }
printf (" default: return -1;\n"); printf (" default: return -1;\n");
printf (" }\n"); printf (" }\n");
printf ("}\n"); printf ("}\n");
printf ("int skip_type_bare_%s (struct paramed_type *T) {\n", t->id); printf ("int skip_type_bare_%s (struct paramed_type *T) {\n", t->print_id);
printf (" int *save = in_ptr;\n"); printf (" int *save = in_ptr;\n");
for (i = 0; i < t->constructors_num; i++) { for (i = 0; i < t->constructors_num; i++) {
printf (" if (skip_constructor_%s (T) >= 0) { return 0; }\n", t->constructors[i]->id); printf (" if (skip_constructor_%s (T) >= 0) { return 0; }\n", t->constructors[i]->print_id);
printf (" in_ptr = save;\n"); printf (" in_ptr = save;\n");
} }
printf (" return -1;\n"); printf (" return -1;\n");
...@@ -694,12 +694,35 @@ int read_combinator_left (struct tl_combinator *c) { ...@@ -694,12 +694,35 @@ int read_combinator_left (struct tl_combinator *c) {
} }
} }
char *gen_print_id (const char *id) {
static char s[1000];
char *ptr = s;
int first = 1;
while (*id) {
if (*id == '.') {
*(ptr ++) = '_';
} else if (*id >= 'A' && *id <= 'Z') {
if (!first && *(ptr - 1) != '_') {
*(ptr ++) = '_';
}
*(ptr ++) = *id - 'A' + 'a';
} else {
*(ptr ++) = *id;
}
id ++;
first = 0;
}
*ptr = 0;
return s;
}
struct tl_combinator *read_combinators (int v) { struct tl_combinator *read_combinators (int v) {
struct tl_combinator *c = malloc0 (sizeof (*c)); struct tl_combinator *c = malloc0 (sizeof (*c));
c->name = get_int (); c->name = get_int ();
c->id = get_string (); c->id = get_string ();
char *s = c->id; c->print_id = strdup (gen_print_id (c->id));
while (*s) { if (*s == '.') { *s = '_'; } ; s ++;} //char *s = c->id;
//while (*s) { if (*s == '.') { *s = '_'; } ; s ++;}
int x = get_int (); int x = get_int ();
struct tl_type *t = tl_type_get_by_name (x); struct tl_type *t = tl_type_get_by_name (x);
assert (t || (!x && v == 3)); assert (t || (!x && v == 3));
...@@ -722,8 +745,7 @@ struct tl_type *read_types (void) { ...@@ -722,8 +745,7 @@ struct tl_type *read_types (void) {
struct tl_type *t = malloc0 (sizeof (*t)); struct tl_type *t = malloc0 (sizeof (*t));
t->name = get_int (); t->name = get_int ();
t->id = get_string (); t->id = get_string ();
char *s = t->id; t->print_id = strdup (gen_print_id (t->id));
while (*s) { if (*s == '.') { *s = '_'; } ; s++; }
t->constructors_num = get_int (); t->constructors_num = get_int ();
assert (t->constructors_num >= 0 && t->constructors_num <= 1000); assert (t->constructors_num >= 0 && t->constructors_num <= 1000);
...@@ -870,20 +892,20 @@ int parse_tlo_file (void) { ...@@ -870,20 +892,20 @@ int parse_tlo_file (void) {
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")) { 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_%s (T);\n", tps[i]->name, tps[i]->print_id);
printf (" case 0x%08x: return skip_type_bare_%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]->print_id);
} }
printf (" default: return -1; }\n"); printf (" default: return -1; }\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 ++) {
printf ("int skip_constructor_%s (struct paramed_type *T);\n", tps[i]->constructors[j]->id); printf ("int skip_constructor_%s (struct paramed_type *T);\n", tps[i]->constructors[j]->print_id);
} }
} }
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")) {
printf ("int skip_type_%s (struct paramed_type *T);\n", tps[i]->id); printf ("int skip_type_%s (struct paramed_type *T);\n", tps[i]->print_id);
printf ("int skip_type_bare_%s (struct paramed_type *T);\n", tps[i]->id); printf ("int skip_type_bare_%s (struct paramed_type *T);\n", tps[i]->print_id);
} }
printf ("int skip_type_any (struct paramed_type *T);\n"); printf ("int skip_type_any (struct paramed_type *T);\n");
...@@ -891,13 +913,13 @@ int parse_tlo_file (void) { ...@@ -891,13 +913,13 @@ int parse_tlo_file (void) {
printf ("extern struct tl_type tl_type_%s;\n", tps[i]->id); 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")) { 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 __attribute__ ((unused));\n", tps[i]->print_id);
printf ("static struct tl_type tl_type_%s = {\n", tps[i]->id); printf ("static struct tl_type tl_type_%s = {\n", tps[i]->print_id);
printf (" .name = 0x%08x,\n", tps[i]->name); printf (" .name = 0x%08x,\n", tps[i]->name);
printf (" .id = \"%s\"\n", tps[i]->id); printf (" .id = \"%s\"\n", tps[i]->id);
printf ("};\n"); 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 __attribute__ ((unused));\n", tps[i]->print_id);
printf ("static struct tl_type tl_type_bare_%s = {\n", tps[i]->id); printf ("static struct tl_type tl_type_bare_%s = {\n", tps[i]->print_id);
printf (" .name = 0x%08x,\n", ~tps[i]->name); printf (" .name = 0x%08x,\n", ~tps[i]->name);
printf (" .id = \"Bare_%s\"\n", tps[i]->id); printf (" .id = \"Bare_%s\"\n", tps[i]->id);
printf ("};\n"); printf ("};\n");
......
...@@ -6,6 +6,7 @@ struct tl_combinator; ...@@ -6,6 +6,7 @@ struct tl_combinator;
struct tl_type { struct tl_type {
// struct tl_type_methods *methods; // struct tl_type_methods *methods;
char *id; char *id;
char *print_id;
unsigned name; unsigned name;
int arity; int arity;
int flags; int flags;
...@@ -131,6 +132,7 @@ struct arg { ...@@ -131,6 +132,7 @@ struct arg {
struct tl_combinator { struct tl_combinator {
//struct tl_combinator_methods *methods; //struct tl_combinator_methods *methods;
char *id; char *id;
char *print_id;
unsigned name; unsigned name;
int is_fun; int is_fun;
int var_num; int var_num;
......
...@@ -14,4 +14,5 @@ void lua_binlog_end (void); ...@@ -14,4 +14,5 @@ void lua_binlog_end (void);
void lua_diff_end (void); void lua_diff_end (void);
void lua_do_all (void); void lua_do_all (void);
#define lua_secret_chat_update(x) #define lua_secret_chat_update(x)
#define lua_update_msg(x)
#endif #endif
...@@ -839,7 +839,7 @@ void fetch_seq (void) { ...@@ -839,7 +839,7 @@ void fetch_seq (void) {
bl_do_set_seq (seq); bl_do_set_seq (seq);
} }
} }
/*
void work_update_binlog (void) { void work_update_binlog (void) {
unsigned op = fetch_int (); unsigned op = fetch_int ();
switch (op) { switch (op) {
...@@ -901,7 +901,7 @@ void work_update_binlog (void) { ...@@ -901,7 +901,7 @@ void work_update_binlog (void) {
default: default:
assert (0); assert (0);
} }
} }*/
void work_update (struct connection *c UU, long long msg_id UU) { void work_update (struct connection *c UU, long long msg_id UU) {
unsigned op = fetch_int (); unsigned op = fetch_int ();
...@@ -1018,7 +1018,7 @@ void work_update (struct connection *c UU, long long msg_id UU) { ...@@ -1018,7 +1018,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
int l2 = prefetch_strlen (); int l2 = prefetch_strlen ();
char *l = fetch_str (l2); char *l = fetch_str (l2);
struct user *U = &UC->user; struct user *U = &UC->user;
bl_do_set_user_real_name (U, f, l1, l, l2); bl_do_user_set_real_name (U, f, l1, l, l2);
print_start (); print_start ();
push_color (COLOR_YELLOW); push_color (COLOR_YELLOW);
print_date (time (0)); print_date (time (0));
...@@ -1409,7 +1409,7 @@ void work_update_short (struct connection *c, long long msg_id) { ...@@ -1409,7 +1409,7 @@ void work_update_short (struct connection *c, long long msg_id) {
void work_updates (struct connection *c, long long msg_id) { void work_updates (struct connection *c, long long msg_id) {
int *save = in_ptr; int *save = in_ptr;
assert (!skip_type_any (TYPE_TO_PARAM (Updates))); assert (!skip_type_any (TYPE_TO_PARAM (updates)));
int *save_end = in_ptr; int *save_end = in_ptr;
in_ptr = save; in_ptr = save;
assert (fetch_int () == CODE_updates); assert (fetch_int () == CODE_updates);
......
This diff is collapsed.
...@@ -198,7 +198,7 @@ int fetch_user (struct user *U) { ...@@ -198,7 +198,7 @@ int fetch_user (struct user *U) {
char *s2 = fetch_str (l2); char *s2 = fetch_str (l2);
if (x == CODE_user_deleted && !(U->flags & FLAG_DELETED)) { if (x == CODE_user_deleted && !(U->flags & FLAG_DELETED)) {
bl_do_new_user (get_peer_id (U->id), s1, l1, s2, l2, 0, 0, 0, 0); bl_do_user_add (get_peer_id (U->id), s1, l1, s2, l2, 0, 0, 0, 0);
bl_do_user_delete (U); bl_do_user_delete (U);
} }
if (x != CODE_user_deleted) { if (x != CODE_user_deleted) {
...@@ -213,7 +213,7 @@ int fetch_user (struct user *U) { ...@@ -213,7 +213,7 @@ int fetch_user (struct user *U) {
assert (phone_len >= 0); assert (phone_len >= 0);
phone = fetch_str (phone_len); phone = fetch_str (phone_len);
} }
bl_do_new_user (get_peer_id (U->id), s1, l1, s2, l2, access_token, phone, phone_len, x == CODE_user_contact); bl_do_user_add (get_peer_id (U->id), s1, l1, s2, l2, access_token, phone, phone_len, x == CODE_user_contact);
if (fetch_user_photo (U) < 0) { return -1; } if (fetch_user_photo (U) < 0) { return -1; }
if (fetch_user_status (&U->status) < 0) { return -1; } if (fetch_user_status (&U->status) < 0) { return -1; }
...@@ -227,19 +227,19 @@ int fetch_user (struct user *U) { ...@@ -227,19 +227,19 @@ int fetch_user (struct user *U) {
int l2 = prefetch_strlen (); int l2 = prefetch_strlen ();
char *s2 = fetch_str (l2); char *s2 = fetch_str (l2);
bl_do_set_user_name (U, s1, l1, s2, l2); bl_do_user_set_name (U, s1, l1, s2, l2);
if (x == CODE_user_deleted && !(U->flags & FLAG_DELETED)) { if (x == CODE_user_deleted && !(U->flags & FLAG_DELETED)) {
bl_do_user_delete (U); bl_do_user_delete (U);
} }
if (x != CODE_user_deleted) { if (x != CODE_user_deleted) {
if (x != CODE_user_self) { if (x != CODE_user_self) {
bl_do_set_user_access_token (U, fetch_long ()); bl_do_user_set_access_hash (U, fetch_long ());
} }
if (x != CODE_user_foreign) { if (x != CODE_user_foreign) {
int l = prefetch_strlen (); int l = prefetch_strlen ();
char *s = fetch_str (l); char *s = fetch_str (l);
bl_do_set_user_phone (U, s, l); bl_do_user_set_phone (U, s, l);
} }
assert (fetch_user_photo (U) >= 0); assert (fetch_user_photo (U) >= 0);
...@@ -249,9 +249,9 @@ int fetch_user (struct user *U) { ...@@ -249,9 +249,9 @@ int fetch_user (struct user *U) {
} }
if (x == CODE_user_contact) { if (x == CODE_user_contact) {
bl_do_set_user_friend (U, 1); bl_do_user_set_friend (U, 1);
} else { } else {
bl_do_set_user_friend (U, 0); bl_do_user_set_friend (U, 0);
} }
} }
} }
...@@ -340,20 +340,20 @@ void fetch_encrypted_chat (struct secret_chat *U) { ...@@ -340,20 +340,20 @@ void fetch_encrypted_chat (struct secret_chat *U) {
void fetch_user_full (struct user *U) { void fetch_user_full (struct user *U) {
assert (fetch_int () == CODE_user_full); assert (fetch_int () == CODE_user_full);
fetch_alloc_user (); fetch_alloc_user ();
assert (skip_type_any (TYPE_TO_PARAM (contacts_Link)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (contacts_link)) >= 0);
int *start = in_ptr; int *start = in_ptr;
assert (skip_type_any (TYPE_TO_PARAM (Photo)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (photo)) >= 0);
bl_do_set_user_full_photo (U, start, 4 * (in_ptr - start)); bl_do_user_set_full_photo (U, start, 4 * (in_ptr - start));
assert (skip_type_any (TYPE_TO_PARAM (PeerNotifySettings)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (peer_notify_settings)) >= 0);
bl_do_set_user_blocked (U, fetch_bool ()); bl_do_user_set_blocked (U, fetch_bool ());
int l1 = prefetch_strlen (); int l1 = prefetch_strlen ();
char *s1 = fetch_str (l1); char *s1 = fetch_str (l1);
int l2 = prefetch_strlen (); int l2 = prefetch_strlen ();
char *s2 = fetch_str (l2); char *s2 = fetch_str (l2);
bl_do_set_user_real_name (U, s1, l1, s2, l2); bl_do_user_set_real_name (U, s1, l1, s2, l2);
} }
void fetch_chat (struct chat *C) { void fetch_chat (struct chat *C) {
...@@ -470,9 +470,9 @@ void fetch_chat_full (struct chat *C) { ...@@ -470,9 +470,9 @@ void fetch_chat_full (struct chat *C) {
version = fetch_int (); version = fetch_int ();
} }
int *start = in_ptr; int *start = in_ptr;
assert (skip_type_any (TYPE_TO_PARAM (Photo)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (photo)) >= 0);
int *end = in_ptr; int *end = in_ptr;
assert (skip_type_any (TYPE_TO_PARAM (PeerNotifySettings)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (peer_notify_settings)) >= 0);
int n, i; int n, i;
assert (fetch_int () == CODE_vector); assert (fetch_int () == CODE_vector);
...@@ -932,7 +932,7 @@ void fetch_message (struct message *M) { ...@@ -932,7 +932,7 @@ void fetch_message (struct message *M) {
if (x == CODE_message_service) { if (x == CODE_message_service) {
int *start = in_ptr; int *start = in_ptr;
assert (skip_type_any (TYPE_TO_PARAM (MessageAction)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (message_action)) >= 0);
if (new) { if (new) {
if (fwd_from_id) { if (fwd_from_id) {
...@@ -946,7 +946,7 @@ void fetch_message (struct message *M) { ...@@ -946,7 +946,7 @@ void fetch_message (struct message *M) {
char *s = fetch_str (l); char *s = fetch_str (l);
int *start = in_ptr; int *start = in_ptr;
assert (skip_type_any (TYPE_TO_PARAM (MessageMedia)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (message_media)) >= 0);
if (new) { if (new) {
if (fwd_from_id) { if (fwd_from_id) {
...@@ -1097,11 +1097,11 @@ void fetch_encrypted_message (struct message *M) { ...@@ -1097,11 +1097,11 @@ void fetch_encrypted_message (struct message *M) {
l = prefetch_strlen (); l = prefetch_strlen ();
s = fetch_str (l); s = fetch_str (l);
start = in_ptr; start = in_ptr;
assert (skip_type_any (TYPE_TO_PARAM (DecryptedMessageMedia)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (decrypted_message_media)) >= 0);
end = in_ptr; end = in_ptr;
} else { } else {
start = in_ptr; start = in_ptr;
assert (skip_type_any (TYPE_TO_PARAM (DecryptedMessageAction)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (decrypted_message_action)) >= 0);
end = in_ptr; end = in_ptr;
} }
in_ptr = save_in_ptr; in_ptr = save_in_ptr;
...@@ -1111,7 +1111,7 @@ void fetch_encrypted_message (struct message *M) { ...@@ -1111,7 +1111,7 @@ void fetch_encrypted_message (struct message *M) {
if (sx == CODE_encrypted_message) { if (sx == CODE_encrypted_message) {
if (ok) { if (ok) {
int *start_file = in_ptr; int *start_file = in_ptr;
assert (skip_type_any (TYPE_TO_PARAM (EncryptedFile)) >= 0); assert (skip_type_any (TYPE_TO_PARAM (encrypted_file)) >= 0);
if (x == CODE_decrypted_message) { if (x == CODE_decrypted_message) {
bl_do_create_message_media_encr (id, P->encr_chat.user_id, PEER_ENCR_CHAT, to_id, date, l, s, start, end - start, start_file, in_ptr - start_file); bl_do_create_message_media_encr (id, P->encr_chat.user_id, PEER_ENCR_CHAT, to_id, date, l, s, start, end - start, start_file, in_ptr - start_file);
} }
......
...@@ -39,13 +39,14 @@ typedef struct { int type; int id; } peer_id_t; ...@@ -39,13 +39,14 @@ typedef struct { int type; int id; } peer_id_t;
#define FLAG_ENCRYPTED 4096 #define FLAG_ENCRYPTED 4096
#define FLAG_PENDING 8192 #define FLAG_PENDING 8192
#pragma pack(push,4)
struct file_location { struct file_location {
int dc; int dc;
long long volume; long long volume;
int local_id; int local_id;
long long secret; long long secret;
}; };
#pragma pack(pop)
struct photo_size { struct photo_size {
char *type; char *type;
......
...@@ -20,5 +20,5 @@ ...@@ -20,5 +20,5 @@
#define MAX_PEER_NUM 100000 #define MAX_PEER_NUM 100000
#ifndef PROG_NAME #ifndef PROG_NAME
#define PROG_NAME "telegram" #define PROG_NAME "telegram-cli"
#endif #endif
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