- add basic support for command-line options
This commit is contained in:
parent
9d7f047597
commit
96409f2ca6
35
fsipd.c
35
fsipd.c
@ -64,6 +64,7 @@
|
|||||||
*/
|
*/
|
||||||
log_t *lfh;
|
log_t *lfh;
|
||||||
struct pidfh *pfh;
|
struct pidfh *pfh;
|
||||||
|
bool use_syslog = false;
|
||||||
|
|
||||||
struct sockaddr_in t_sa, u_sa;
|
struct sockaddr_in t_sa, u_sa;
|
||||||
int t_sockfd, u_sockfd;
|
int t_sockfd, u_sockfd;
|
||||||
@ -457,8 +458,8 @@ daemon_start()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wait for threads to terminate, which
|
* Wait for threads to terminate, which normally shouldn't ever
|
||||||
* normally shouldn't ever happen
|
* happen
|
||||||
*/
|
*/
|
||||||
pthread_join(tcp4_thread, NULL);
|
pthread_join(tcp4_thread, NULL);
|
||||||
pthread_join(udp4_thread, NULL);
|
pthread_join(udp4_thread, NULL);
|
||||||
@ -470,8 +471,34 @@ daemon_start()
|
|||||||
return (EXIT_SUCCESS);
|
return (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
void
|
||||||
main(void)
|
usage()
|
||||||
{
|
{
|
||||||
|
printf("usage: fsipd [-h] [-s] \n");
|
||||||
|
printf("\t-h: this message\n");
|
||||||
|
printf("\t-s: use syslog instead of local log file\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
int opt;
|
||||||
|
|
||||||
|
while ((opt = getopt(argc, argv, "hs")) != -1) {
|
||||||
|
switch (opt) {
|
||||||
|
case 's':
|
||||||
|
use_syslog = true;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage();
|
||||||
|
exit(0);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
printf("invalid option: %c\n", opt);
|
||||||
|
usage();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (daemon_start());
|
return (daemon_start());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user