1
+ /* vim: set et sw=4 ts=4 sts=4 : */
1
2
/********************************************************************\
2
3
* This program is free software; you can redistribute it and/or *
3
4
* modify it under the terms of the GNU General Public License as *
18
19
* *
19
20
\********************************************************************/
20
21
21
- /* $Id$ */
22
22
/** @file commandline.c
23
23
@brief Command line argument handling
24
24
@author Copyright (C) 2004 Philippe April <[email protected] >
33
33
#include "debug.h"
34
34
#include "safe.h"
35
35
#include "conf.h"
36
+ #include "commandline.h"
36
37
37
38
#include "../config.h"
38
39
39
40
/*
40
41
* Holds an argv that could be passed to exec*() if we restart ourselves
41
42
*/
42
- /* Declare variable */
43
- extern char * * restartargv ;
44
- /* Define variable */
45
43
char * * restartargv = NULL ;
46
44
47
- static void usage (void );
48
-
49
- void parse_commandline (int argc , char * * argv );
50
-
51
- /*
45
+ /**
52
46
* A flag to denote whether we were restarted via a parent wifidog, or started normally
53
47
* 0 means normally, otherwise it will be populated by the PID of the parent
54
48
*/
55
- extern pid_t restart_orig_pid ;
56
49
pid_t restart_orig_pid = 0 ;
57
50
51
+ static void usage (void );
52
+
58
53
/** @internal
59
54
* @brief Print usage
60
55
*
@@ -81,7 +76,8 @@ usage(void)
81
76
/** Uses getopt() to parse the command line and set configuration values
82
77
* also populates restartargv
83
78
*/
84
- void parse_commandline (int argc , char * * argv ) {
79
+ void
80
+ parse_commandline (int argc , char * * argv ) {
85
81
int c ;
86
82
int skiponrestart ;
87
83
int i ;
@@ -106,7 +102,8 @@ void parse_commandline(int argc, char **argv) {
106
102
107
103
case 'c' :
108
104
if (optarg ) {
109
- strncpy (config -> configfile , optarg , sizeof (config -> configfile ));
105
+ free (config -> configfile );
106
+ config -> configfile = safe_strdup (optarg );
110
107
}
111
108
break ;
112
109
0 commit comments