mirror of https://git.kore.io/kore.git
Redo config parsing a bit.
No longer just call kore_string_split() on the line but separate out the configuration directive and let the appropriate callbacks parse things on their own.
This commit is contained in:
parent
82a9e6ef59
commit
c8484ee9ab
|
@ -515,6 +515,7 @@ long long kore_strtonum(const char *, int, long long, long long, int *);
|
||||||
int kore_base64_encode(u_int8_t *, u_int32_t, char **);
|
int kore_base64_encode(u_int8_t *, u_int32_t, char **);
|
||||||
int kore_base64_decode(char *, u_int8_t **, u_int32_t *);
|
int kore_base64_decode(char *, u_int8_t **, u_int32_t *);
|
||||||
void *kore_mem_find(void *, size_t, void *, u_int32_t);
|
void *kore_mem_find(void *, size_t, void *, u_int32_t);
|
||||||
|
char *kore_text_trim(char *, size_t);
|
||||||
|
|
||||||
#if !defined(KORE_NO_HTTP)
|
#if !defined(KORE_NO_HTTP)
|
||||||
void kore_websocket_handshake(struct http_request *,
|
void kore_websocket_handshake(struct http_request *,
|
||||||
|
|
34
src/cli.c
34
src/cli.c
|
@ -97,7 +97,6 @@ static void cli_run_kore(void *);
|
||||||
static void cli_generate_certs(void);
|
static void cli_generate_certs(void);
|
||||||
static void cli_link_library(void *);
|
static void cli_link_library(void *);
|
||||||
static void cli_compile_cfile(void *);
|
static void cli_compile_cfile(void *);
|
||||||
static char *cli_trim(char *, size_t);
|
|
||||||
static void cli_mkdir(const char *, int);
|
static void cli_mkdir(const char *, int);
|
||||||
static int cli_dir_exists(const char *);
|
static int cli_dir_exists(const char *);
|
||||||
static int cli_file_exists(const char *);
|
static int cli_file_exists(const char *);
|
||||||
|
@ -1047,7 +1046,7 @@ cli_buildopt_parse(const char *path)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
struct buildopt *bopt;
|
struct buildopt *bopt;
|
||||||
char buf[BUFSIZ], *p, *t, *s;
|
char buf[BUFSIZ], *p, *t;
|
||||||
|
|
||||||
if ((fp = fopen(path, "r")) == NULL)
|
if ((fp = fopen(path, "r")) == NULL)
|
||||||
cli_fatal("cli_buildopt_parse: fopen(%s): %s", path, errno_s);
|
cli_fatal("cli_buildopt_parse: fopen(%s): %s", path, errno_s);
|
||||||
|
@ -1093,20 +1092,8 @@ cli_buildopt_parse(const char *path)
|
||||||
parse_option:
|
parse_option:
|
||||||
*(t)++ = '\0';
|
*(t)++ = '\0';
|
||||||
|
|
||||||
cli_trim(p, strlen(p));
|
p = kore_text_trim(p, strlen(p));
|
||||||
cli_trim(t, strlen(t));
|
t = kore_text_trim(t, strlen(t));
|
||||||
|
|
||||||
while (isspace(*p))
|
|
||||||
p++;
|
|
||||||
s = p + strlen(p) - 1;
|
|
||||||
while (isspace(*s))
|
|
||||||
*(s)-- = '\0';
|
|
||||||
|
|
||||||
while (isspace(*t))
|
|
||||||
t++;
|
|
||||||
s = t + strlen(t) - 1;
|
|
||||||
while (isspace(*s))
|
|
||||||
*(s)-- = '\0';
|
|
||||||
|
|
||||||
if (!strcasecmp(p, "cflags")) {
|
if (!strcasecmp(p, "cflags")) {
|
||||||
cli_buildopt_cflags(bopt, t);
|
cli_buildopt_cflags(bopt, t);
|
||||||
|
@ -1370,21 +1357,6 @@ cli_cleanup_files(const char *spath)
|
||||||
printf("couldn't rmdir %s\n", spath);
|
printf("couldn't rmdir %s\n", spath);
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *
|
|
||||||
cli_trim(char *string, size_t len)
|
|
||||||
{
|
|
||||||
char *end;
|
|
||||||
|
|
||||||
end = string + strlen(string) - 1;
|
|
||||||
while (isspace(*string))
|
|
||||||
string++;
|
|
||||||
|
|
||||||
while (isspace(*end) && end > string)
|
|
||||||
*(end)-- = '\0';
|
|
||||||
|
|
||||||
return (string);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
cli_fatal(const char *fmt, ...)
|
cli_fatal(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
|
686
src/config.c
686
src/config.c
File diff suppressed because it is too large
Load Diff
16
src/utils.c
16
src/utils.c
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -497,6 +498,21 @@ kore_mem_find(void *src, size_t slen, void *needle, u_int32_t len)
|
||||||
return (NULL);
|
return (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *
|
||||||
|
kore_text_trim(char *string, size_t len)
|
||||||
|
{
|
||||||
|
char *end;
|
||||||
|
|
||||||
|
end = string + strlen(string) - 1;
|
||||||
|
while (isspace(*string))
|
||||||
|
string++;
|
||||||
|
|
||||||
|
while (isspace(*end) && end > string)
|
||||||
|
*(end)-- = '\0';
|
||||||
|
|
||||||
|
return (string);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
fatal(const char *fmt, ...)
|
fatal(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue