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
4fe0014a
Commit
4fe0014a
authored
Sep 09, 2014
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added [-D] (disable output) key
parent
98dfe80c
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
13 deletions
+40
-13
interface.c
interface.c
+8
-2
loop.c
loop.c
+6
-0
main.c
main.c
+26
-11
No files found.
interface.c
View file @
4fe0014a
...
...
@@ -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 @
4fe0014a
...
...
@@ -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 @
4fe0014a
...
...
@@ -94,6 +94,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
)
{
...
...
@@ -218,8 +219,10 @@ void running_for_first_time (void) {
//char *downloads_directory = get_downloads_directory ();
if
(
!
mkdir
(
config_directory
,
CONFIG_DIRECTORY_MODE
))
{
if
(
!
disable_output
)
{
printf
(
"[%s] created
\n
"
,
config_directory
);
}
}
tfree_str
(
config_directory
);
config_directory
=
NULL
;
...
...
@@ -351,15 +354,21 @@ void parse_config (void) {
tgl_set_download_directory
(
downloads_directory
);
if
(
!
mkdir
(
config_directory
,
CONFIG_DIRECTORY_MODE
))
{
if
(
!
disable_output
)
{
printf
(
"[%s] created
\n
"
,
config_directory
);
}
}
if
(
!
mkdir
(
downloads_directory
,
CONFIG_DIRECTORY_MODE
))
{
if
(
!
disable_output
)
{
printf
(
"[%s] created
\n
"
,
downloads_directory
);
}
}
}
#else
void
parse_config
(
void
)
{
if
(
!
disable_output
)
{
printf
(
"libconfig not enabled
\n
"
);
}
tasprintf
(
&
downloads_directory
,
"%s/%s/%s"
,
get_home_directory
(),
CONFIG_DIRECTORY
,
DOWNLOADS_DIRECTORY
);
if
(
binlog_enabled
)
{
...
...
@@ -405,6 +414,7 @@ void usage (void) {
printf
(
" -R disable readline
\n
"
);
printf
(
" -d daemon mode
\n
"
);
printf
(
" -L <log-name> log file name
\n
"
);
printf
(
" -D disable output
\n
"
);
exit
(
1
);
}
...
...
@@ -462,7 +472,7 @@ static void sighup_handler (const int sig) {
void
args_parse
(
int
argc
,
char
**
argv
)
{
int
opt
=
0
;
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vNl:fEwWCRdL:"
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vNl:fEwWCRdL:
D
"
#ifdef HAVE_LIBCONFIG
"c:p:"
#else
...
...
@@ -533,6 +543,9 @@ void args_parse (int argc, char **argv) {
case
'L'
:
logname
=
optarg
;
break
;
case
'D'
:
disable_output
++
;
break
;
case
'h'
:
default:
usage
();
...
...
@@ -586,12 +599,14 @@ int main (int argc, char **argv) {
signal
(
SIGUSR1
,
sigusr1_handler
);
reopen_logs
();
}
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
();
...
...
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