getopt: don't modify argv as it breaks restart()
This commit is contained in:
parent
c173a8ad44
commit
5adde7a4ed
4 changed files with 11 additions and 13 deletions
|
@ -37,7 +37,7 @@ struct lgetopt
|
|||
|
||||
extern struct lgetopt myopts[];
|
||||
|
||||
void usage(char *);
|
||||
void parseargs(int *, char ***, struct lgetopt *);
|
||||
void usage(const char *);
|
||||
void parseargs(int *, char * const **, struct lgetopt *);
|
||||
|
||||
#endif /* __GETOPT_H_INCLUDED__ */
|
||||
|
|
|
@ -29,10 +29,10 @@
|
|||
# define OPTCHAR '-'
|
||||
|
||||
void
|
||||
parseargs(int *argc, char ***argv, struct lgetopt *opts)
|
||||
parseargs(int *argc, char * const **argv, struct lgetopt *opts)
|
||||
{
|
||||
int i;
|
||||
char *progname = (*argv)[0];
|
||||
const char *progname = (*argv)[0];
|
||||
|
||||
/* loop through each argument */
|
||||
for (;;)
|
||||
|
@ -53,12 +53,10 @@ parseargs(int *argc, char ***argv, struct lgetopt *opts)
|
|||
return;
|
||||
}
|
||||
|
||||
(*argv)[0]++;
|
||||
|
||||
/* search through our argument list, and see if it matches */
|
||||
for (i = 0; opts[i].opt; i++)
|
||||
{
|
||||
if(!strcmp(opts[i].opt, (*argv)[0]))
|
||||
if(!strcmp(opts[i].opt, &(*argv)[0][1]))
|
||||
{
|
||||
/* found our argument */
|
||||
found = 1;
|
||||
|
@ -74,7 +72,7 @@ parseargs(int *argc, char ***argv, struct lgetopt *opts)
|
|||
fprintf(stderr,
|
||||
"Error: option '%c%s' requires an argument\n",
|
||||
OPTCHAR, opts[i].opt);
|
||||
usage((*argv)[0]);
|
||||
usage(progname);
|
||||
}
|
||||
|
||||
*((int *) opts[i].argloc) = atoi((*argv)[1]);
|
||||
|
@ -111,14 +109,14 @@ parseargs(int *argc, char ***argv, struct lgetopt *opts)
|
|||
}
|
||||
if(!found)
|
||||
{
|
||||
fprintf(stderr, "error: unknown argument '%c%s'\n", OPTCHAR, (*argv)[0]);
|
||||
fprintf(stderr, "error: unknown argument '%c%s'\n", OPTCHAR, &(*argv)[0][1]);
|
||||
usage(progname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
usage(char *name)
|
||||
usage(const char *name)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ rb_dlink_list global_serv_list; /* global servers on the network */
|
|||
rb_dlink_list local_oper_list; /* our opers, duplicated in lclient_list */
|
||||
rb_dlink_list oper_list; /* network opers */
|
||||
|
||||
char **myargv;
|
||||
char * const *myargv;
|
||||
volatile sig_atomic_t dorehash = false;
|
||||
volatile sig_atomic_t dorehashbans = false;
|
||||
volatile sig_atomic_t doremotd = false;
|
||||
|
@ -645,7 +645,7 @@ seed_random(void *unused)
|
|||
* Side Effects - this is where the ircd gets going right now
|
||||
*/
|
||||
int
|
||||
charybdis_main(int argc, char *argv[])
|
||||
charybdis_main(int argc, char * const argv[])
|
||||
{
|
||||
int fd;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include "ircd_signal.h"
|
||||
|
||||
/* external var */
|
||||
extern char **myargv;
|
||||
extern char * const *myargv;
|
||||
|
||||
void
|
||||
restart(const char *mesg)
|
||||
|
|
Loading…
Reference in a new issue