replace command line arguments parser with built-in getopt code

This commit is contained in:
Sergey Popov 2012-03-13 15:56:43 +04:00
parent dad8fb8329
commit ddda04d12f

14
yasnd.c
View File

@ -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;
} }
} }
} }