replace command line arguments parser with built-in getopt code
This commit is contained in:
parent
dad8fb8329
commit
ddda04d12f
14
yasnd.c
14
yasnd.c
@ -3,6 +3,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <getopt.h>
|
||||||
#include <confuse.h>
|
#include <confuse.h>
|
||||||
|
|
||||||
#include "yasnd.h"
|
#include "yasnd.h"
|
||||||
@ -373,12 +374,21 @@ void signal_handler(int signum)
|
|||||||
|
|
||||||
void arg_parse(int argc, char *argv[])
|
void arg_parse(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
for (int i=0;i<argc;i++)
|
int c;
|
||||||
|
struct option option_string[] =
|
||||||
{
|
{
|
||||||
if (strcmp(argv[i],"--init")==0)
|
{"init", no_argument, NULL, 'i'},
|
||||||
|
};
|
||||||
|
while ((c = getopt_long(argc, argv,"i", option_string, NULL)) != 0)
|
||||||
{
|
{
|
||||||
|
switch(c)
|
||||||
|
{
|
||||||
|
case 'i':
|
||||||
lpt_lock();
|
lpt_lock();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user