Compare commits

..

No commits in common. "a7d6dfc8709560f56b21b0022eef19674074ef50" and "f6313101fdde3ab0630e3845774f0dead2756a66" have entirely different histories.

2 changed files with 12 additions and 61 deletions

View file

@ -12,8 +12,14 @@
"type": "struct"
},
"HttpHandler *": { "type": "extern" },
"void *": { "type": "extern" },
"ConfigListener": {
"fields": {
"handler": { "type": "HttpHandler *", "ignore": true },
"handlerArgs": { "type": "void *", "ignore": true },
"port": { "type": "integer", "required": true },
"threads": { "type": "integer", "required": false },
"maxConnections": { "type": "integer", "required": false },

View file

@ -28,17 +28,14 @@
#include <Cytoplasm/Array.h>
#include <Cytoplasm/Str.h>
#include <Cytoplasm/Db.h>
#include <Cytoplasm/HttpServer.h>
#include <Cytoplasm/Log.h>
#include <Cytoplasm/Int64.h>
#include <Cytoplasm/Util.h>
#include <sys/types.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <grp.h>
#include <pwd.h>
#ifndef HOST_NAME_MAX
#define HOST_NAME_MAX _POSIX_HOST_NAME_MAX
@ -48,6 +45,7 @@ Config *
ConfigParse(HashMap * config)
{
Config *tConfig;
JsonValue *value;
size_t i;
@ -76,7 +74,6 @@ ConfigParse(HashMap * config)
tConfig->err = "Couldn't allocate enough memory for 'baseUrl'.";
goto error;
}
snprintf(tConfig->baseUrl, len, "https://%s/", tConfig->serverName);
}
if (!tConfig->log.timestampFormat)
{
@ -116,63 +113,11 @@ ConfigExists(Db * db)
int
ConfigCreateDefault(Db * db)
{
Config config;
ConfigListener *listener;
HashMap *json;
DbRef *ref;
size_t len;
memset(&config, 0, sizeof(Config));
config.log.output = CONFIG_LOG_OUTPUT_FILE;
config.runAs.gid = StrDuplicate(getgrgid(getgid())->gr_name);
config.runAs.uid = StrDuplicate(getpwuid(getuid())->pw_name);
config.registration = 0;
config.federation = 1;
gethostname(config.serverName, HOST_NAME_MAX);
len = strlen(config.serverName) + 10;
config.baseUrl = Malloc(len);
snprintf(config.baseUrl, len, "https://%s/", config.serverName);
config.listen = ArrayCreate();
listener = Malloc(sizeof(ConfigListener));
listener->maxConnections = Int64Create(0, 0);
listener->port = Int64Create(0, 8008);
listener->threads = Int64Create(0, 0);
listener->tls.key = NULL;
listener->tls.cert = NULL;
ArrayAdd(config.listen, listener);
config.serverName = Malloc(HOST_NAME_MAX + 1);
/* TODO: Don't set that field(it has to because otherwise j2s will add
* a NULL byte it seems.) */
config.identityServer = StrDuplicate("");
json = ConfigToJson(&config);
ref = DbCreate(db, 1, "config");
if (!ref)
{
ConfigFree(&config);
return 0;
}
DbJsonSet(ref, json);
DbUnlock(db, ref);
ConfigFree(&config);
JsonFree(json);
return 1;
HashMap *json;
Array *listeners;
HashMap *listen;
return 0;
}
Config *