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
c85f0852
Commit
c85f0852
authored
Sep 09, 2014
by
Vysheng
Browse files
Options
Browse Files
Download
Plain Diff
Merge github.com:vysheng/tg
Conflicts: main.c
parents
e23f4e33
4fe0014a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
14 deletions
+46
-14
interface.c
interface.c
+8
-2
loop.c
loop.c
+6
-0
main.c
main.c
+26
-11
mtproto-client.c
mtproto-client.c
+6
-1
No files found.
interface.c
View file @
c85f0852
...
...
@@ -94,6 +94,8 @@ int in_chat_mode;
tgl_peer_id_t
chat_mode_id
;
extern
int
readline_disabled
;
extern
int
disable_output
;
int
is_same_word
(
const
char
*
s
,
size_t
l
,
const
char
*
word
)
{
return
s
&&
word
&&
strlen
(
word
)
==
l
&&
!
memcmp
(
s
,
word
,
l
);
}
...
...
@@ -848,7 +850,7 @@ void mark_read_upd (int num, struct tgl_message *list[]) {
}
void
type_notification_upd
(
struct
tgl_user
*
U
)
{
if
(
log_level
<
2
)
{
return
;
}
if
(
log_level
<
2
||
disable_output
)
{
return
;
}
print_start
();
push_color
(
COLOR_YELLOW
);
printf
(
"User "
);
...
...
@@ -859,7 +861,7 @@ void type_notification_upd (struct tgl_user *U) {
}
void
type_in_chat_notification_upd
(
struct
tgl_user
*
U
,
struct
tgl_chat
*
C
)
{
if
(
log_level
<
2
)
{
return
;
}
if
(
log_level
<
2
||
disable_output
)
{
return
;
}
print_start
();
push_color
(
COLOR_YELLOW
);
printf
(
"User "
);
...
...
@@ -876,6 +878,7 @@ void print_message_gw (struct tgl_message *M) {
#ifdef USE_LUA
lua_new_msg
(
M
);
#endif
if
(
disable_output
)
{
return
;
}
if
(
!
binlog_read
)
{
return
;
}
print_start
();
print_message
(
M
);
...
...
@@ -935,6 +938,7 @@ void user_update_gw (struct tgl_user *U, unsigned flags) {
lua_user_update
(
U
,
flags
);
#endif
if
(
disable_output
)
{
return
;
}
if
(
!
binlog_read
)
{
return
;
}
if
(
!
(
flags
&
TGL_UPDATE_CREATED
))
{
...
...
@@ -959,6 +963,7 @@ void chat_update_gw (struct tgl_chat *U, unsigned flags) {
lua_chat_update
(
U
,
flags
);
#endif
if
(
disable_output
)
{
return
;
}
if
(
!
binlog_read
)
{
return
;
}
if
(
!
(
flags
&
TGL_UPDATE_CREATED
))
{
...
...
@@ -983,6 +988,7 @@ void secret_chat_update_gw (struct tgl_secret_chat *U, unsigned flags) {
lua_secret_chat_update
(
U
,
flags
);
#endif
if
(
disable_output
)
{
return
;
}
if
(
!
binlog_read
)
{
return
;
}
if
((
flags
&
TGL_UPDATE_WORKING
)
||
(
flags
&
TGL_UPDATE_DELETED
))
{
...
...
loop.c
View file @
c85f0852
...
...
@@ -72,6 +72,8 @@ int register_mode;
extern
int
safe_quit
;
extern
int
sync_from_start
;
extern
int
disable_output
;
void
got_it
(
char
*
line
,
int
len
);
void
write_state_file
(
void
);
...
...
@@ -613,6 +615,10 @@ int loop (void) {
}
if
(
!
tgl_signed_dc
(
tgl_state
.
DC_working
))
{
if
(
disable_output
)
{
fprintf
(
stderr
,
"Can not login without output
\n
"
);
exit
(
2
);
}
if
(
!
default_username
)
{
size_t
size
=
0
;
char
*
user
=
0
;
...
...
main.c
View file @
c85f0852
...
...
@@ -96,6 +96,7 @@ int allow_weak_random;
char
*
lua_file
;
int
disable_colors
;
int
readline_disabled
;
int
disable_output
;
void
set_default_username
(
const
char
*
s
)
{
if
(
default_username
)
{
...
...
@@ -220,7 +221,9 @@ void running_for_first_time (void) {
//char *downloads_directory = get_downloads_directory ();
if
(
!
mkdir
(
config_directory
,
CONFIG_DIRECTORY_MODE
))
{
printf
(
"[%s] created
\n
"
,
config_directory
);
if
(
!
disable_output
)
{
printf
(
"[%s] created
\n
"
,
config_directory
);
}
}
tfree_str
(
config_directory
);
...
...
@@ -353,15 +356,21 @@ void parse_config (void) {
tgl_set_download_directory
(
downloads_directory
);
if
(
!
mkdir
(
config_directory
,
CONFIG_DIRECTORY_MODE
))
{
printf
(
"[%s] created
\n
"
,
config_directory
);
if
(
!
disable_output
)
{
printf
(
"[%s] created
\n
"
,
config_directory
);
}
}
if
(
!
mkdir
(
downloads_directory
,
CONFIG_DIRECTORY_MODE
))
{
printf
(
"[%s] created
\n
"
,
downloads_directory
);
if
(
!
disable_output
)
{
printf
(
"[%s] created
\n
"
,
downloads_directory
);
}
}
}
#else
void
parse_config
(
void
)
{
printf
(
"libconfig not enabled
\n
"
);
if
(
!
disable_output
)
{
printf
(
"libconfig not enabled
\n
"
);
}
tasprintf
(
&
downloads_directory
,
"%s/%s/%s"
,
get_home_directory
(),
CONFIG_DIRECTORY
,
DOWNLOADS_DIRECTORY
);
if
(
binlog_enabled
)
{
...
...
@@ -409,6 +418,7 @@ void usage (void) {
printf
(
" -L <log-name> log file name
\n
"
);
printf
(
" -U <user-name> change uid after start
\n
"
);
printf
(
" -G <group-name> change gid after start
\n
"
);
printf
(
" -D disable output
\n
"
);
exit
(
1
);
}
...
...
@@ -509,7 +519,7 @@ int change_user_group () {
void
args_parse
(
int
argc
,
char
**
argv
)
{
int
opt
=
0
;
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vNl:fEwWCRdL:U:G:"
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vNl:fEwWCRdL:
D
U:G:"
#ifdef HAVE_LIBCONFIG
"c:p:"
#else
...
...
@@ -586,6 +596,9 @@ void args_parse (int argc, char **argv) {
case
'G'
:
set_group_name
=
optarg
;
break
;
case
'D'
:
disable_output
++
;
break
;
case
'h'
:
default:
usage
();
...
...
@@ -640,12 +653,14 @@ int main (int argc, char **argv) {
signal
(
SIGUSR1
,
sigusr1_handler
);
reopen_logs
();
}
printf
(
"Telegram-cli version "
TGL_VERSION
", Copyright (C) 2013-2014 Vitaly Valtman
\n
"
"Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
\n
"
"This is free software, and you are welcome to redistribute it
\n
"
"under certain conditions; type `show_license' for details.
\n
"
);
if
(
!
disable_output
)
{
printf
(
"Telegram-cli version "
TGL_VERSION
", Copyright (C) 2013-2014 Vitaly Valtman
\n
"
"Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
\n
"
"This is free software, and you are welcome to redistribute it
\n
"
"under certain conditions; type `show_license' for details.
\n
"
);
}
running_for_first_time
();
parse_config
();
...
...
mtproto-client.c
View file @
c85f0852
...
...
@@ -617,7 +617,12 @@ static int process_dh_answer (struct connection *c, char *packet, int len, int t
l
=
BN_num_bytes
(
&
auth_key_num
);
assert
(
l
>=
250
&&
l
<=
256
);
assert
(
BN_bn2bin
(
&
auth_key_num
,
(
unsigned
char
*
)(
temp_key
?
D
->
temp_auth_key
:
D
->
auth_key
)));
memset
(
temp_key
?
D
->
temp_auth_key
+
l
:
D
->
auth_key
+
l
,
0
,
256
-
l
);
if
(
l
<
256
)
{
char
*
key
=
temp_key
?
D
->
temp_auth_key
:
D
->
auth_key
;
memmove
(
key
+
256
-
l
,
key
,
l
);
memset
(
key
,
0
,
256
-
l
);
}
BN_free
(
dh_power
);
BN_free
(
&
auth_key_num
);
BN_free
(
&
dh_g
);
...
...
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