Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
a37e5f43
Commit
a37e5f43
authored
Aug 12, 2014
by
vysheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
A bit working version
parent
084e5dfe
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
491 additions
and
428 deletions
+491
-428
auto-static.c
auto-static.c
+7
-9
auto.h
auto.h
+0
-2
binlog.c
binlog.c
+344
-290
binlog.h
binlog.h
+8
-32
binlog.tl
binlog.tl
+18
-8
generate.c
generate.c
+42
-20
generate.h
generate.h
+2
-0
lua-tg.h
lua-tg.h
+1
-0
mtproto-client.c
mtproto-client.c
+4
-4
queries.c
queries.c
+42
-41
structures.c
structures.c
+20
-20
structures.h
structures.h
+2
-1
telegram.h
telegram.h
+1
-1
No files found.
auto-static.c
View file @
a37e5f43
...
...
@@ -27,20 +27,18 @@ int skip_string (void) {
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
);
unsigned
size
=
(
len
+
4
)
>>
2
;
if
(
in_ptr
+
size
<=
in_end
)
{
in_ptr
+=
size
;
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
);
len
=
(
*
(
unsigned
*
)
in_ptr
)
>>
8
;
unsigned
size
=
(
len
+
7
)
>>
2
;
if
(
in_ptr
+
size
<=
in_end
)
{
in_ptr
+=
size
;
return
0
;
}
else
{
return
-
1
;
...
...
auto.h
View file @
a37e5f43
...
...
@@ -20,8 +20,6 @@ struct paramed_type {
#define INT2PTR(x) (void *)(long)(((long)x) * 2 + 1)
#define PTR2INT(x) ((((long)x) - 1) / 2)
#define FETCH_COMBINATOR_FUNCTION(NAME)
#include "auto/auto-header.h"
#endif
binlog.c
View file @
a37e5f43
This diff is collapsed.
Click to expand it.
binlog.h
View file @
a37e5f43
...
...
@@ -21,30 +21,6 @@
#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
replay_log
(
void
);
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);
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_
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_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_
set_user_access_token
(
struct
user
*
U
,
long
long
access_token
);
void
bl_do_
set_user
_phone
(
struct
user
*
U
,
const
char
*
p
,
int
pl
);
void
bl_do_
set_user
_friend
(
struct
user
*
U
,
int
friend
);
void
bl_do_
set_user
_full_photo
(
struct
user
*
U
,
const
int
*
start
,
int
len
);
void
bl_do_
set_user
_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
_name
(
struct
user
*
U
,
const
char
*
f
,
int
fl
,
const
char
*
l
,
int
ll
);
void
bl_do_
user_set_access_hash
(
struct
user
*
U
,
long
long
access_token
);
void
bl_do_
user_set
_phone
(
struct
user
*
U
,
const
char
*
p
,
int
pl
);
void
bl_do_
user_set
_friend
(
struct
user
*
U
,
int
friend
);
void
bl_do_
user_set
_full_photo
(
struct
user
*
U
,
const
int
*
start
,
int
len
);
void
bl_do_
user_set
_blocked
(
struct
user
*
U
,
int
blocked
);
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_requested
(
struct
secret_chat
*
U
,
long
long
access_hash
,
int
date
,
int
admin_id
,
int
user_id
,
unsigned
char
g_key
[],
unsigned
char
nonce
[]);
...
...
binlog.tl
View file @
a37e5f43
...
...
@@ -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.start = 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.defaultDc dc:int = binlog.Update;
...
...
@@ -16,14 +17,16 @@ binlog.setQts qts:int = binlog.Update;
binlog.setDate date: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.setUserAccessToken id:int hash:long = binlog.Update;
binlog.setUserPhone id:int phone:string = binlog.Update;
binlog.setUserFriend id:int friend:int = binlog.Update;
binlog.userFullPhoto id:int photo:Photo = binlog.Update;
binlog.userBlocked id:int blocked:int = binlog.Update;
binlog.setUserFullName id:int real_first_name:string real_last_name:string = binlog.Update;
binlog.userSetAccessHash id:int hash:long = binlog.Update;
binlog.userSetPhone id:int phone:string = binlog.Update;
binlog.userSetFriend id:int friend:int = binlog.Update;
binlog.userSetFullPhoto id:int photo:Photo = binlog.Update;
binlog.userSetBlocked id:int blocked:int = 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.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
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.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.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
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.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;
generate.c
View file @
a37e5f43
...
...
@@ -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
;
}
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
{
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
{
assert
(
t
==
NODE_TYPE_ARRAY
);
...
...
@@ -400,7 +400,7 @@ int gen_field_fetch (struct arg *arg, int *vars, int num) {
}
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
];
sprintf
(
s
,
"T"
);
...
...
@@ -439,21 +439,21 @@ void gen_constructor_fetch (struct tl_combinator *c) {
}
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
(
" 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
(
" case 0x%08x: return skip_constructor_%s (T);
\n
"
,
t
->
constructors
[
i
]
->
name
,
t
->
constructors
[
i
]
->
print_
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 skip_type_bare_%s (struct paramed_type *T) {
\n
"
,
t
->
print_
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
(
" if (skip_constructor_%s (T) >= 0) { return 0; }
\n
"
,
t
->
constructors
[
i
]
->
print_
id
);
printf
(
" in_ptr = save;
\n
"
);
}
printf
(
" return -1;
\n
"
);
...
...
@@ -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
*
c
=
malloc0
(
sizeof
(
*
c
));
c
->
name
=
get_int
();
c
->
id
=
get_string
();
char
*
s
=
c
->
id
;
while
(
*
s
)
{
if
(
*
s
==
'.'
)
{
*
s
=
'_'
;
}
;
s
++
;}
c
->
print_id
=
strdup
(
gen_print_id
(
c
->
id
));
//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
));
...
...
@@ -722,8 +745,7 @@ 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
->
print_id
=
strdup
(
gen_print_id
(
t
->
id
));
t
->
constructors_num
=
get_int
();
assert
(
t
->
constructors_num
>=
0
&&
t
->
constructors_num
<=
1000
);
...
...
@@ -870,20 +892,20 @@ int parse_tlo_file (void) {
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
(
" 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
]
->
print_
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
);
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"
))
{
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_%s (struct paramed_type *T);
\n
"
,
tps
[
i
]
->
print_
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
"
);
...
...
@@ -891,13 +913,13 @@ int parse_tlo_file (void) {
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
(
"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
]
->
print_
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
(
"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
]
->
print_
id
);
printf
(
" .name = 0x%08x,
\n
"
,
~
tps
[
i
]
->
name
);
printf
(
" .id =
\"
Bare_%s
\"\n
"
,
tps
[
i
]
->
id
);
printf
(
"};
\n
"
);
...
...
generate.h
View file @
a37e5f43
...
...
@@ -6,6 +6,7 @@ struct tl_combinator;
struct
tl_type
{
// struct tl_type_methods *methods;
char
*
id
;
char
*
print_id
;
unsigned
name
;
int
arity
;
int
flags
;
...
...
@@ -131,6 +132,7 @@ struct arg {
struct
tl_combinator
{
//struct tl_combinator_methods *methods;
char
*
id
;
char
*
print_id
;
unsigned
name
;
int
is_fun
;
int
var_num
;
...
...
lua-tg.h
View file @
a37e5f43
...
...
@@ -14,4 +14,5 @@ void lua_binlog_end (void);
void
lua_diff_end
(
void
);
void
lua_do_all
(
void
);
#define lua_secret_chat_update(x)
#define lua_update_msg(x)
#endif
mtproto-client.c
View file @
a37e5f43
...
...
@@ -839,7 +839,7 @@ void fetch_seq (void) {
bl_do_set_seq
(
seq
);
}
}
/*
void work_update_binlog (void) {
unsigned op = fetch_int ();
switch (op) {
...
...
@@ -901,7 +901,7 @@ void work_update_binlog (void) {
default:
assert (0);
}
}
}
*/
void
work_update
(
struct
connection
*
c
UU
,
long
long
msg_id
UU
)
{
unsigned
op
=
fetch_int
();
...
...
@@ -1018,7 +1018,7 @@ void work_update (struct connection *c UU, long long msg_id UU) {
int
l2
=
prefetch_strlen
();
char
*
l
=
fetch_str
(
l2
);
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
();
push_color
(
COLOR_YELLOW
);
print_date
(
time
(
0
));
...
...
@@ -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
)
{
int
*
save
=
in_ptr
;
assert
(
!
skip_type_any
(
TYPE_TO_PARAM
(
U
pdates
)));
assert
(
!
skip_type_any
(
TYPE_TO_PARAM
(
u
pdates
)));
int
*
save_end
=
in_ptr
;
in_ptr
=
save
;
assert
(
fetch_int
()
==
CODE_updates
);
...
...
queries.c
View file @
a37e5f43
This diff is collapsed.
Click to expand it.
structures.c
View file @
a37e5f43
...
...
@@ -198,7 +198,7 @@ int fetch_user (struct user *U) {
char
*
s2
=
fetch_str
(
l2
);
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
);
}
if
(
x
!=
CODE_user_deleted
)
{
...
...
@@ -213,7 +213,7 @@ int fetch_user (struct user *U) {
assert
(
phone_len
>=
0
);
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_status
(
&
U
->
status
)
<
0
)
{
return
-
1
;
}
...
...
@@ -227,19 +227,19 @@ int fetch_user (struct user *U) {
int
l2
=
prefetch_strlen
();
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
))
{
bl_do_user_delete
(
U
);
}
if
(
x
!=
CODE_user_deleted
)
{
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
)
{
int
l
=
prefetch_strlen
();
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
);
...
...
@@ -249,9 +249,9 @@ int fetch_user (struct user *U) {
}
if
(
x
==
CODE_user_contact
)
{
bl_do_
set_user
_friend
(
U
,
1
);
bl_do_
user_set
_friend
(
U
,
1
);
}
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) {
void
fetch_user_full
(
struct
user
*
U
)
{
assert
(
fetch_int
()
==
CODE_user_full
);
fetch_alloc_user
();
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
contacts_
L
ink
))
>=
0
);
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
contacts_
l
ink
))
>=
0
);
int
*
start
=
in_ptr
;
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
P
hoto
))
>=
0
);
bl_do_
set_user
_full_photo
(
U
,
start
,
4
*
(
in_ptr
-
start
));
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
p
hoto
))
>=
0
);
bl_do_
user_set
_full_photo
(
U
,
start
,
4
*
(
in_ptr
-
start
));
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
PeerNotifyS
ettings
))
>=
0
);
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
peer_notify_s
ettings
))
>=
0
);
bl_do_
set_user
_blocked
(
U
,
fetch_bool
());
bl_do_
user_set
_blocked
(
U
,
fetch_bool
());
int
l1
=
prefetch_strlen
();
char
*
s1
=
fetch_str
(
l1
);
int
l2
=
prefetch_strlen
();
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
)
{
...
...
@@ -470,9 +470,9 @@ void fetch_chat_full (struct chat *C) {
version
=
fetch_int
();
}
int
*
start
=
in_ptr
;
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
P
hoto
))
>=
0
);
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
p
hoto
))
>=
0
);
int
*
end
=
in_ptr
;
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
PeerNotifyS
ettings
))
>=
0
);
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
peer_notify_s
ettings
))
>=
0
);
int
n
,
i
;
assert
(
fetch_int
()
==
CODE_vector
);
...
...
@@ -932,7 +932,7 @@ void fetch_message (struct message *M) {
if
(
x
==
CODE_message_service
)
{
int
*
start
=
in_ptr
;
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
MessageA
ction
))
>=
0
);
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
message_a
ction
))
>=
0
);
if
(
new
)
{
if
(
fwd_from_id
)
{
...
...
@@ -946,7 +946,7 @@ void fetch_message (struct message *M) {
char
*
s
=
fetch_str
(
l
);
int
*
start
=
in_ptr
;
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
MessageM
edia
))
>=
0
);
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
message_m
edia
))
>=
0
);
if
(
new
)
{
if
(
fwd_from_id
)
{
...
...
@@ -1097,11 +1097,11 @@ void fetch_encrypted_message (struct message *M) {
l
=
prefetch_strlen
();
s
=
fetch_str
(
l
);
start
=
in_ptr
;
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
DecryptedMessageM
edia
))
>=
0
);
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
decrypted_message_m
edia
))
>=
0
);
end
=
in_ptr
;
}
else
{
start
=
in_ptr
;
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
DecryptedMessageA
ction
))
>=
0
);
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
decrypted_message_a
ction
))
>=
0
);
end
=
in_ptr
;
}
in_ptr
=
save_in_ptr
;
...
...
@@ -1111,7 +1111,7 @@ void fetch_encrypted_message (struct message *M) {
if
(
sx
==
CODE_encrypted_message
)
{
if
(
ok
)
{
int
*
start_file
=
in_ptr
;
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
EncryptedF
ile
))
>=
0
);
assert
(
skip_type_any
(
TYPE_TO_PARAM
(
encrypted_f
ile
))
>=
0
);
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
);
}
...
...
structures.h
View file @
a37e5f43
...
...
@@ -39,13 +39,14 @@ typedef struct { int type; int id; } peer_id_t;
#define FLAG_ENCRYPTED 4096
#define FLAG_PENDING 8192
#pragma pack(push,4)
struct
file_location
{
int
dc
;
long
long
volume
;
int
local_id
;
long
long
secret
;
};
#pragma pack(pop)
struct
photo_size
{
char
*
type
;
...
...
telegram.h
View file @
a37e5f43
...
...
@@ -20,5 +20,5 @@
#define MAX_PEER_NUM 100000
#ifndef PROG_NAME
#define PROG_NAME "telegram"
#define PROG_NAME "telegram
-cli
"
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment