add option to daemonize fiche
This commit is contained in:
27
fiche.c
27
fiche.c
@@ -9,11 +9,13 @@ Live example: http://code.solusipse.net/
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
usage: fiche [-epbsdolBuw].
|
usage: fiche [-DepbsdolBuw].
|
||||||
[-e] [-d domain] [-p port] [-s slug size]
|
[-D] [-e] [-d domain] [-p port] [-s slug size]
|
||||||
[-o output directory] [-B buffer size] [-u user name]
|
[-o output directory] [-B buffer size] [-u user name]
|
||||||
[-l log file] [-b banlist] [-w whitelist]
|
[-l log file] [-b banlist] [-w whitelist]
|
||||||
|
|
||||||
|
-D option is for daemonizing fiche
|
||||||
|
|
||||||
-e option is for using an extended character set for the URL
|
-e option is for using an extended character set for the URL
|
||||||
|
|
||||||
Compile with Makefile or manually with -O2 and -pthread flags.
|
Compile with Makefile or manually with -O2 and -pthread flags.
|
||||||
@@ -48,6 +50,17 @@ int main(int argc, char **argv)
|
|||||||
server_address = set_address(server_address);
|
server_address = set_address(server_address);
|
||||||
bind_to_port(listen_socket, server_address);
|
bind_to_port(listen_socket, server_address);
|
||||||
|
|
||||||
|
if (DAEMON)
|
||||||
|
{
|
||||||
|
pid_t pid;
|
||||||
|
|
||||||
|
pid = fork();
|
||||||
|
if (pid == -1)
|
||||||
|
error("ERROR: Failed to fork");
|
||||||
|
if (pid == 0)
|
||||||
|
while (1) perform_connection(listen_socket);
|
||||||
|
}
|
||||||
|
else
|
||||||
while (1) perform_connection(listen_socket);
|
while (1) perform_connection(listen_socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,6 +384,9 @@ void startup_message()
|
|||||||
|
|
||||||
void info(char *buffer, ...)
|
void info(char *buffer, ...)
|
||||||
{
|
{
|
||||||
|
if (DAEMON)
|
||||||
|
return;
|
||||||
|
|
||||||
printf(buffer);
|
printf(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -378,9 +394,14 @@ void parse_parameters(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
|
|
||||||
while ((c = getopt (argc, argv, "ep:b:s:d:o:l:B:u:w:")) != -1)
|
if (strcmp(*argv, "-D"))
|
||||||
|
DAEMON = 1;
|
||||||
|
|
||||||
|
while ((c = getopt (argc, argv, "Dep:b:s:d:o:l:B:u:w:")) != -1)
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
|
case 'D':
|
||||||
|
break;
|
||||||
case 'e':
|
case 'e':
|
||||||
snprintf(symbols, sizeof symbols, "%s", "abcdefghijklmnopqrstuvwxyz0123456789-+_=.ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
snprintf(symbols, sizeof symbols, "%s", "abcdefghijklmnopqrstuvwxyz0123456789-+_=.ABCDEFGHIJKLMNOPQRSTUVWXYZ");
|
||||||
break;
|
break;
|
||||||
|
|||||||
7
fiche.h
7
fiche.h
@@ -9,11 +9,13 @@ Live example: http://code.solusipse.net/
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
usage: fiche [-epbsdolBuw].
|
usage: fiche [-DepbsdolBuw].
|
||||||
[-e] [-d domain] [-p port] [-s slug size]
|
[-D] [-e] [-d domain] [-p port] [-s slug size]
|
||||||
[-o output directory] [-B buffer size] [-u user name]
|
[-o output directory] [-B buffer size] [-u user name]
|
||||||
[-l log file] [-b banlist] [-w whitelist]
|
[-l log file] [-b banlist] [-w whitelist]
|
||||||
|
|
||||||
|
-D option is for daemonizing fiche
|
||||||
|
|
||||||
-e option is for using an extended character set for the URL
|
-e option is for using an extended character set for the URL
|
||||||
|
|
||||||
Compile with Makefile or manually with -O2 and -pthread flags.
|
Compile with Makefile or manually with -O2 and -pthread flags.
|
||||||
@@ -51,6 +53,7 @@ char *BANLIST;
|
|||||||
char *BANFILE;
|
char *BANFILE;
|
||||||
char *WHITEFILE;
|
char *WHITEFILE;
|
||||||
char *WHITELIST;
|
char *WHITELIST;
|
||||||
|
int DAEMON = 0;
|
||||||
int PORT = 9999;
|
int PORT = 9999;
|
||||||
int SLUG_SIZE = 4;
|
int SLUG_SIZE = 4;
|
||||||
int BUFSIZE = 32768;
|
int BUFSIZE = 32768;
|
||||||
|
|||||||
Reference in New Issue
Block a user