Commit 87720b5d authored by stesie's avatar stesie

disabled debug-mode by default, but added -d switch instead; furthermore added -F (fork) switch

parent 0d3e4c86
......@@ -2,6 +2,7 @@
* si - silc improved - minimalistic silc client
*
* Copyright (C) 2006 Christian Dietrich <stettberger@gmx.de>
* Copyright (C) 2006 Stefan Siegl <stesie@brokenpipe.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......@@ -128,7 +129,7 @@ char ircdir[1024];
Channel *channels=NULL;
Query *queries=NULL;
Transfer *transfers=NULL;
int debug=1;
int debug = 0;
int connected=0;
SilcClientOperations ops;
Silc silc_client;
......@@ -182,8 +183,8 @@ static void usage()
fprintf(stderr, "%s",
"si - silc improved - " VERSION "\n"
"(C)opyright 2006 Christian Dietrich\n"
"usage: si [-i <silc dir>] [-s <host>] [-p <port>]\n"
" [-n <nick>] [-f <fullname>] [-x <init-script>] [-h] [-v]\n");
"usage: si [-hvdF] [-i <silc dir>] [-s <host>] [-p <port>]\n"
" [-n <nick>] [-f <fullname>] [-x <init-script>]\n");
exit(EXIT_SUCCESS);
}
static void version() {
......@@ -2052,6 +2053,8 @@ SilcClientOperations ops = {
int main(int argc, char **argv)
{
char c;
int do_fork = 0;
while (1) {
int option_index = 0;
static struct option long_options[] = {
......@@ -2063,10 +2066,12 @@ int main(int argc, char **argv)
{"nick", 1, 0, 'n'},
{"fullname", 1, 0, 'f'},
{"init-script", 1, 0, 'x'},
{"debug", 0, 0, 'd'},
{"fork", 0, 0, 'F'},
{0, 0, 0, 0}
};
c = getopt_long (argc, argv, "x:i:s:p:n:f:vh",
c = getopt_long (argc, argv, "dFx:i:s:p:n:f:vh",
long_options, &option_index);
if (c == -1)
break;
......@@ -2080,17 +2085,41 @@ int main(int argc, char **argv)
case 'n': username = strdup(optarg); break;
case 'f': realname = strdup(optarg); break;
case 'x': init_script = strdup(optarg); break;
case 'F': do_fork = 1; break;
case 'd': debug = 1; break;
default: usage(); break;
}
}
if(!strlen(prefix)){
prefix=malloc(strlen(getenv("HOME"))+5);
NULL_TEST_ARG(prefix,1);
sprintf(prefix, "%s/irc", getenv("HOME"));
}
if (!username)
username=silc_get_username();
if(do_fork) {
pid_t p = fork();
if(p < 0) {
/* fork failed */
perror("si");
return 1;
}
if(p) {
/* parent process */
return 0;
}
/* child process, we're a daemon, therefore close terminal fds */
close(0);
close(1);
close(2);
}
/* Run the Mainloop */
return run();
}
......
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