Format code, remove dataDir from sample production.conf

This commit is contained in:
Jordan Bancino 2023-04-19 02:07:38 +00:00
parent 0cca38115a
commit ae38791df2
14 changed files with 53 additions and 25 deletions

View file

@ -2,7 +2,6 @@
"log": {
"output": "file"
},
"dataDir": "/var/telodendria",
"listen": [
{
"port": 8008,

View file

@ -323,7 +323,7 @@ ConfigFree(Config * tConfig)
}
Config *
ConfigParse(HashMap *config)
ConfigParse(HashMap * config)
{
Config *tConfig;
JsonValue *value;
@ -416,13 +416,13 @@ error:
}
int
ConfigExists(Db *db)
ConfigExists(Db * db)
{
return DbExists(db, 1, "config");
}
int
ConfigCreateDefault(Db *db)
ConfigCreateDefault(Db * db)
{
DbRef *ref;
HashMap *json;
@ -466,7 +466,7 @@ ConfigCreateDefault(Db *db)
}
Config *
ConfigLock(Db *db)
ConfigLock(Db * db)
{
Config *config;
DbRef *ref = DbLock(db, 1, "config");
@ -487,7 +487,7 @@ ConfigLock(Db *db)
}
int
ConfigUnlock(Config *config)
ConfigUnlock(Config * config)
{
Db *db;
DbRef *dbRef;

View file

@ -715,7 +715,7 @@ JsonFree(HashMap * object)
}
JsonValue *
JsonValueDuplicate(JsonValue *val)
JsonValueDuplicate(JsonValue * val)
{
JsonValue *new;
size_t i;
@ -733,7 +733,7 @@ JsonValueDuplicate(JsonValue *val)
new->type = val->type;
switch(val->type)
switch (val->type)
{
case JSON_OBJECT:
new->as.object = JsonDuplicate(val->as.object);

View file

@ -292,7 +292,8 @@ start:
Log(LOG_ERR, "Please restore from a backup.");
exit = EXIT_FAILURE;
goto finish;
} else if (!tConfig->ok)
}
else if (!tConfig->ok)
{
Log(LOG_ERR, tConfig->err);
exit = EXIT_FAILURE;

View file

@ -66,6 +66,7 @@ ROUTE_IMPL(RouteChangePwd, path, argp)
char *newPassword;
Config *config = ConfigLock(db);
if (!config)
{
Log(LOG_ERR, "Password endpoint failed to lock configuration.");

View file

@ -58,6 +58,7 @@ ROUTE_IMPL(RouteLogin, path, argp)
char *fullUsername;
Config *config = ConfigLock(db);
if (!config)
{
Log(LOG_ERR, "Login endpoint failed to lock configuration.");

View file

@ -78,6 +78,7 @@ ROUTE_IMPL(RouteRegister, path, argp)
DbRef *sessionRef;
Config *config = ConfigLock(db);
if (!config)
{
Log(LOG_ERR, "Registration endpoint failed to lock configuration.");

View file

@ -49,6 +49,7 @@ ROUTE_IMPL(RouteUserProfile, path, argp)
char *value = NULL;
Config *config = ConfigLock(db);
if (!config)
{
Log(LOG_ERR, "User profile endpoint failed to lock configuration.");

View file

@ -36,6 +36,7 @@ ROUTE_IMPL(RouteWellKnown, path, argp)
HashMap *response;
Config *config = ConfigLock(args->matrixArgs->db);
if (!config)
{
Log(LOG_ERR, "Well-known endpoint failed to lock configuration.");

View file

@ -46,6 +46,7 @@ ROUTE_IMPL(RouteWhoami, path, argp)
char *deviceID;
Config *config = ConfigLock(db);
if (!config)
{
Log(LOG_ERR, "Who am I endpoint failed to lock configuration.");

View file

@ -197,4 +197,3 @@ TelodendriaPrintHeader(void)
"Documentation/Support: https://telodendria.io");
Log(LOG_INFO, "");
}

View file

@ -65,21 +65,21 @@ typedef struct Config
} Config;
Config *
ConfigParse(HashMap *);
ConfigParse(HashMap *);
void
ConfigFree(Config *);
ConfigFree(Config *);
extern int
ConfigExists(Db *);
ConfigExists(Db *);
extern int
ConfigCreateDefault(Db *);
ConfigCreateDefault(Db *);
extern Config *
ConfigLock(Db *);
ConfigLock(Db *);
extern int
ConfigUnlock(Config *);
ConfigUnlock(Config *);
#endif /* TELODENDRIA_CONFIG_H */

View file

@ -36,7 +36,7 @@ extern Db *
DbOpen(char *, size_t);
extern void
DbMaxCacheSet(Db *, size_t);
DbMaxCacheSet(Db *, size_t);
extern void
DbClose(Db *);

View file

@ -1,16 +1,39 @@
/*
* Copyright (C) 2022-2023 Jordan Bancino <@jordan:bancino.net>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation files
* (the "Software"), to deal in the Software without restriction,
* including without limitation the rights to use, copy, modify, merge,
* publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
#ifndef TELODENDRIA_MAIN_H
#define TELODENDRIA_MAIN_H
extern void
Restart(void);
Restart(void);
extern void
Shutdown(void);
Shutdown(void);
extern unsigned long
Uptime(void);
Uptime(void);
extern int
main(int argc, char **argv);
main(int argc, char **argv);
#endif /* TELODENDRIA_MAIN_H */