mirror of https://git.kore.io/kore.git
Add kore_default_getopt().
This handles the default option parsing in Kore and should be called by single_binary=yes builds in kore_parent_configure() unless they want to handle their own argument parsing.
This commit is contained in:
parent
4313c0eab5
commit
67cf3e872b
|
@ -718,6 +718,7 @@ void kore_signal(int);
|
||||||
void kore_shutdown(void);
|
void kore_shutdown(void);
|
||||||
void kore_signal_setup(void);
|
void kore_signal_setup(void);
|
||||||
void kore_proctitle(const char *);
|
void kore_proctitle(const char *);
|
||||||
|
void kore_default_getopt(int, char **);
|
||||||
|
|
||||||
void kore_worker_reap(void);
|
void kore_worker_reap(void);
|
||||||
void kore_worker_init(void);
|
void kore_worker_init(void);
|
||||||
|
|
91
src/kore.c
91
src/kore.c
|
@ -73,10 +73,8 @@ extern char **environ;
|
||||||
extern char *__progname;
|
extern char *__progname;
|
||||||
static size_t proctitle_maxlen = 0;
|
static size_t proctitle_maxlen = 0;
|
||||||
|
|
||||||
#if !defined(KORE_SINGLE_BINARY)
|
|
||||||
static void usage(void);
|
static void usage(void);
|
||||||
static void version(void);
|
static void version(void);
|
||||||
#endif
|
|
||||||
|
|
||||||
static void kore_write_kore_pid(void);
|
static void kore_write_kore_pid(void);
|
||||||
static void kore_proctitle_setup(void);
|
static void kore_proctitle_setup(void);
|
||||||
|
@ -95,7 +93,6 @@ static const char *parent_daemonized_hook = KORE_DAEMONIZED_HOOK;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(KORE_SINGLE_BINARY)
|
|
||||||
static void
|
static void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
|
@ -107,7 +104,9 @@ usage(void)
|
||||||
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("Available options:\n");
|
printf("Available options:\n");
|
||||||
|
#if !defined(KORE_SINGLE_BINARY)
|
||||||
printf("\t-c\tconfiguration to use\n");
|
printf("\t-c\tconfiguration to use\n");
|
||||||
|
#endif
|
||||||
#if defined(KORE_DEBUG)
|
#if defined(KORE_DEBUG)
|
||||||
printf("\t-d\trun with debug on\n");
|
printf("\t-d\trun with debug on\n");
|
||||||
#endif
|
#endif
|
||||||
|
@ -151,15 +150,11 @@ version(void)
|
||||||
printf("\n");
|
printf("\n");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
struct kore_runtime_call *rcall;
|
struct kore_runtime_call *rcall;
|
||||||
#if !defined(KORE_SINGLE_BINARY)
|
|
||||||
int ch;
|
|
||||||
#endif
|
|
||||||
#if !defined(KORE_SINGLE_BINARY) && defined(KORE_USE_PYTHON)
|
#if !defined(KORE_SINGLE_BINARY) && defined(KORE_USE_PYTHON)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
#endif
|
#endif
|
||||||
|
@ -168,40 +163,7 @@ main(int argc, char *argv[])
|
||||||
kore_argv = argv;
|
kore_argv = argv;
|
||||||
|
|
||||||
#if !defined(KORE_SINGLE_BINARY)
|
#if !defined(KORE_SINGLE_BINARY)
|
||||||
while ((ch = getopt(argc, argv, "c:dfhnqrv")) != -1) {
|
kore_default_getopt(argc, argv);
|
||||||
switch (ch) {
|
|
||||||
case 'c':
|
|
||||||
free(config_file);
|
|
||||||
if ((config_file = strdup(optarg)) == NULL)
|
|
||||||
fatal("strdup");
|
|
||||||
break;
|
|
||||||
#if defined(KORE_DEBUG)
|
|
||||||
case 'd':
|
|
||||||
kore_debug = 1;
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
case 'f':
|
|
||||||
foreground = 1;
|
|
||||||
break;
|
|
||||||
case 'h':
|
|
||||||
usage();
|
|
||||||
break;
|
|
||||||
case 'n':
|
|
||||||
skip_chroot = 1;
|
|
||||||
break;
|
|
||||||
case 'q':
|
|
||||||
kore_quiet = 1;
|
|
||||||
break;
|
|
||||||
case 'r':
|
|
||||||
skip_runas = 1;
|
|
||||||
break;
|
|
||||||
case 'v':
|
|
||||||
version();
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
kore_mem_init();
|
kore_mem_init();
|
||||||
|
@ -340,6 +302,53 @@ main(int argc, char *argv[])
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
kore_default_getopt(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
|
||||||
|
#if !defined(KORE_SINGLE_BINARY)
|
||||||
|
while ((ch = getopt(argc, argv, "c:dfhnqrv")) != -1) {
|
||||||
|
#else
|
||||||
|
while ((ch = getopt(argc, argv, "dfhnqrv")) != -1) {
|
||||||
|
#endif
|
||||||
|
switch (ch) {
|
||||||
|
#if !defined(KORE_SINGLE_BINARY)
|
||||||
|
case 'c':
|
||||||
|
free(config_file);
|
||||||
|
if ((config_file = strdup(optarg)) == NULL)
|
||||||
|
fatal("strdup");
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#if defined(KORE_DEBUG)
|
||||||
|
case 'd':
|
||||||
|
kore_debug = 1;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
case 'f':
|
||||||
|
foreground = 1;
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
usage();
|
||||||
|
break;
|
||||||
|
case 'n':
|
||||||
|
skip_chroot = 1;
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
kore_quiet = 1;
|
||||||
|
break;
|
||||||
|
case 'r':
|
||||||
|
skip_runas = 1;
|
||||||
|
break;
|
||||||
|
case 'v':
|
||||||
|
version();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
kore_tls_sni_cb(SSL *ssl, int *ad, void *arg)
|
kore_tls_sni_cb(SSL *ssl, int *ad, void *arg)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue