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
3dedb4ac
Commit
3dedb4ac
authored
Apr 30, 2015
by
vvaltman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enable longopts
parent
c35619f6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
69 additions
and
27 deletions
+69
-27
main.c
main.c
+69
-27
No files found.
main.c
View file @
3dedb4ac
...
@@ -69,6 +69,7 @@
...
@@ -69,6 +69,7 @@
#include "loop.h"
#include "loop.h"
#include "interface.h"
#include "interface.h"
#include <tgl/tools.h>
#include <tgl/tools.h>
#include <getopt.h>
#ifdef USE_LUA
#ifdef USE_LUA
# include "lua-tg.h"
# include "lua-tg.h"
...
@@ -446,35 +447,36 @@ void inner_main (void) {
...
@@ -446,35 +447,36 @@ void inner_main (void) {
void
usage
(
void
)
{
void
usage
(
void
)
{
printf
(
"%s Usage
\n
"
,
PROGNAME
);
printf
(
"%s Usage
\n
"
,
PROGNAME
);
printf
(
" -
u
specify username (would not be asked during authorization)
\n
"
);
printf
(
" -
-phone/-u
specify username (would not be asked during authorization)
\n
"
);
printf
(
" -
k
specify location of public key (possible multiple entries)
\n
"
);
printf
(
" -
-rsa-key/-k
specify location of public key (possible multiple entries)
\n
"
);
printf
(
" -
v
increase verbosity (0-ERROR 1-WARNIN 2-NOTICE 3+-DEBUG-levels)
\n
"
);
printf
(
" -
-verbosity/-v
increase verbosity (0-ERROR 1-WARNIN 2-NOTICE 3+-DEBUG-levels)
\n
"
);
printf
(
" -
N
message num mode
\n
"
);
printf
(
" -
-enable-msg-id/-N
message num mode
\n
"
);
#ifdef HAVE_LIBCONFIG
#ifdef HAVE_LIBCONFIG
printf
(
" -
c
config file name
\n
"
);
printf
(
" -
-config/-c
config file name
\n
"
);
printf
(
" -
p
use specified profile
\n
"
);
printf
(
" -
-profile/-p
use specified profile
\n
"
);
#else
#else
printf
(
" -
B
enable binlog
\n
"
);
printf
(
" -
-enable-binlog/-B
enable binlog
\n
"
);
#endif
#endif
printf
(
" -
l
log level
\n
"
);
printf
(
" -
-log-level/-l
log level
\n
"
);
printf
(
" -
f
during authorization fetch all messages since registration
\n
"
);
printf
(
" -
-sync-from-start/-f
during authorization fetch all messages since registration
\n
"
);
printf
(
" -
E
disable auto accept of encrypted chats
\n
"
);
printf
(
" -
-disable-auto-accept/-E
disable auto accept of encrypted chats
\n
"
);
#ifdef USE_LUA
#ifdef USE_LUA
printf
(
" -
s
lua script file
\n
"
);
printf
(
" -
-lua-script/-s
lua script file
\n
"
);
#endif
#endif
printf
(
" -W send dialog_list query and wait for answer before reading input
\n
"
);
printf
(
" --wait-dialog-list/-W send dialog_list query and wait for answer before reading input
\n
"
);
printf
(
" -C disable color output
\n
"
);
printf
(
" --disable-colors/-C disable color output
\n
"
);
printf
(
" -R disable readline
\n
"
);
printf
(
" --disable-readline/-R disable readline
\n
"
);
printf
(
" -d daemon mode
\n
"
);
printf
(
" --daemonize/-d daemon mode
\n
"
);
printf
(
" -L <log-name> log file name
\n
"
);
printf
(
" --logname/-L <log-name> log file name
\n
"
);
printf
(
" -U <user-name> change uid after start
\n
"
);
printf
(
" --username/-U <user-name> change uid after start
\n
"
);
printf
(
" -G <group-name> change gid after start
\n
"
);
printf
(
" --groupname/-G <group-name> change gid after start
\n
"
);
printf
(
" -D disable output
\n
"
);
printf
(
" --disable-output/-D disable output
\n
"
);
printf
(
" -P <port> port to listen for input commands
\n
"
);
printf
(
" --tcp-port/-P <port> port to listen for input commands
\n
"
);
printf
(
" -S <socket-name> unix socket to create
\n
"
);
printf
(
" --udp-socket/-S <socket-name> unix socket to create
\n
"
);
printf
(
" -e <commands> make commands end exit
\n
"
);
printf
(
" --exec/-e <commands> make commands end exit
\n
"
);
printf
(
" -I use user and chat IDs in updates instead of names
\n
"
);
printf
(
" --disable-names/-I use user and chat IDs in updates instead of names
\n
"
);
printf
(
" -6 use ipv6 (may be unstable)
\n
"
);
printf
(
" --enable-ipv6/-6 use ipv6 (may be unstable)
\n
"
);
printf
(
" --help/-h prints this help
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
...
@@ -582,8 +584,48 @@ char *unix_socket;
...
@@ -582,8 +584,48 @@ char *unix_socket;
void
args_parse
(
int
argc
,
char
**
argv
)
{
void
args_parse
(
int
argc
,
char
**
argv
)
{
TLS
=
tgl_state_alloc
();
TLS
=
tgl_state_alloc
();
static
struct
option
long_options
[]
=
{
{
"debug-allocator"
,
no_argument
,
0
,
1000
},
{
"phone"
,
required_argument
,
0
,
'u'
},
{
"rsa-key"
,
required_argument
,
0
,
'k'
},
{
"verbosity"
,
no_argument
,
0
,
'v'
},
{
"enable-msg-id"
,
no_argument
,
0
,
'N'
},
#ifdef HAVE_LIBCONFIG
{
"config"
,
required_argument
,
0
,
'c'
},
{
"profile"
,
required_argument
,
0
,
'p'
},
#else
{
"enable-binlog"
,
no_argument
,
0
,
'B'
},
#endif
{
"log-level"
,
required_argument
,
0
,
'l'
},
{
"sync-from-start"
,
no_argument
,
0
,
'f'
},
{
"disable-auto-accept"
,
no_argument
,
0
,
'E'
},
{
"allow-weak-random"
,
no_argument
,
0
,
'w'
},
#ifdef USE_LUA
{
"lua-script"
,
required_argument
,
0
,
's'
},
#endif
{
"wait-dialog-list"
,
no_argument
,
0
,
'W'
},
{
"disable-colors"
,
no_argument
,
0
,
'C'
},
{
"disable-readline"
,
no_argument
,
0
,
'R'
},
{
"daemonize"
,
no_argument
,
0
,
'd'
},
{
"logname"
,
required_argument
,
0
,
'L'
},
{
"username"
,
required_argument
,
0
,
'U'
},
{
"groupname"
,
required_argument
,
0
,
'G'
},
{
"disable-output"
,
no_argument
,
0
,
'D'
},
{
"reset-authorization"
,
no_argument
,
0
,
'q'
},
{
"tcp-port"
,
required_argument
,
0
,
'P'
},
{
"unix-socket"
,
required_argument
,
0
,
'S'
},
{
"exec"
,
required_argument
,
0
,
'e'
},
{
"disable-names"
,
no_argument
,
0
,
'I'
},
{
"enable-ipv6"
,
no_argument
,
0
,
'6'
},
{
"help"
,
no_argument
,
0
,
'h'
},
{
0
,
0
,
0
,
0
}
};
int
opt
=
0
;
int
opt
=
0
;
while
((
opt
=
getopt
(
argc
,
argv
,
"u:hk:vNl:fEwWCRdL:DU:G:qP:S:e:I6g
"
while
((
opt
=
getopt
_long
(
argc
,
argv
,
"u:hk:vNl:fEwWCRdL:DU:G:qP:S:e:I6
"
#ifdef HAVE_LIBCONFIG
#ifdef HAVE_LIBCONFIG
"c:p:"
"c:p:"
#else
#else
...
@@ -592,10 +634,10 @@ void args_parse (int argc, char **argv) {
...
@@ -592,10 +634,10 @@ void args_parse (int argc, char **argv) {
#ifdef USE_LUA
#ifdef USE_LUA
"s:"
"s:"
#endif
#endif
,
long_options
,
NULL
))
!=
-
1
)
{
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'g'
:
case
1000
:
tgl_allocator
=
&
tgl_allocator_debug
;
tgl_allocator
=
&
tgl_allocator_debug
;
break
;
break
;
case
'u'
:
case
'u'
:
...
...
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