mirror of
https://forge.fsky.io/lda/Parsee.git
synced 2026-03-13 19:55:10 +00:00
[ADD/MOD] CFLAGS/LDFLAGS and version checks
This commit is contained in:
parent
ad7f4f20e1
commit
0ec028d458
7 changed files with 222 additions and 80 deletions
|
|
@ -211,6 +211,10 @@ Main(Array *args, HashMap *env)
|
|||
conf.maxConnections = conf.threads << 2;
|
||||
conf.handlerArgs = ParseeInitData(jabber);
|
||||
conf.handler = ParseeRequest;
|
||||
if (!conf.handlerArgs)
|
||||
{
|
||||
goto end;
|
||||
}
|
||||
|
||||
Log(LOG_DEBUG, "Verbosity level: %d", verbose);
|
||||
((ParseeData *) conf.handlerArgs)->verbosity = verbose;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
ParseeData *
|
||||
ParseeInitData(XMPPComponent *comp)
|
||||
{
|
||||
char *version;
|
||||
ParseeData *data;
|
||||
DbRef *ref;
|
||||
if (!ParseeConfigGet())
|
||||
|
|
@ -37,7 +38,10 @@ ParseeInitData(XMPPComponent *comp)
|
|||
if (!data->db)
|
||||
{
|
||||
Log(LOG_WARNING, "LMDB doesn't seem to be setup.");
|
||||
Log(LOG_WARNING, "Falling back to flat-file.");
|
||||
if (data->config->db_size)
|
||||
{
|
||||
Log(LOG_WARNING, "Falling back to flat-file.");
|
||||
}
|
||||
data->db = DbOpen(data->config->db_path, 0);
|
||||
}
|
||||
|
||||
|
|
@ -49,6 +53,27 @@ ParseeInitData(XMPPComponent *comp)
|
|||
Free(id);
|
||||
}
|
||||
|
||||
version = GrabString(DbJson(ref), 1, "version");
|
||||
if (!ParseeIsCompatible(VERSION, version))
|
||||
{
|
||||
Log(LOG_WARNING, "Version mismatch(curr=%s db=%s).", VERSION, version);
|
||||
Log(LOG_WARNING, "Yeah. You may want to _not_ do that.");
|
||||
|
||||
DbUnlock(data->db, ref);
|
||||
DbClose(data->db);
|
||||
|
||||
HashMapFree(data->oid_servers);
|
||||
pthread_mutex_destroy(&data->oidl);
|
||||
|
||||
XMPPEndCompStream(data->jabber);
|
||||
|
||||
HttpRouterFree(data->router);
|
||||
CommandFreeRouter(data->handler);
|
||||
|
||||
Free(data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
data->id = StrDuplicate(GrabString(DbJson(ref), 1, "identifier"));
|
||||
DbUnlock(data->db, ref);
|
||||
|
||||
|
|
|
|||
53
src/Parsee/Versions.c
Normal file
53
src/Parsee/Versions.c
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include <Parsee.h>
|
||||
|
||||
#include <Cytoplasm/Memory.h>
|
||||
#include <Cytoplasm/Str.h>
|
||||
|
||||
bool
|
||||
ParseeIsCompatible(char *ver1, char *ver2)
|
||||
{
|
||||
char *major1 = NULL;
|
||||
char *major2 = NULL;
|
||||
char *tmp;
|
||||
if (!ver1 || !ver2)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check if one of them is a "flipped"(joke) version. If so,
|
||||
* then the user should definitely NOT try funny things with
|
||||
* their data. */
|
||||
if (*ver1 == '-' || *ver2 == '-')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#define GetMajor(v) do \
|
||||
{ \
|
||||
while (*ver##v != '.') \
|
||||
{ \
|
||||
char cb[2]; \
|
||||
cb[0] = *ver##v; \
|
||||
cb[1] = '\0'; \
|
||||
tmp = major##v; \
|
||||
major##v = StrConcat(2, major##v, cb); \
|
||||
Free(tmp); \
|
||||
ver##v++; \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
GetMajor(1);
|
||||
GetMajor(2);
|
||||
|
||||
if (!StrEquals(major1, major2))
|
||||
{
|
||||
Free(major1);
|
||||
Free(major2);
|
||||
return false;
|
||||
}
|
||||
|
||||
Free(major1);
|
||||
Free(major2);
|
||||
return true;
|
||||
}
|
||||
|
|
@ -303,9 +303,9 @@ end_error:
|
|||
args->config, mroom_id, encoded,
|
||||
"m.room.message", content
|
||||
);
|
||||
Free(mime);
|
||||
Free(mxc);
|
||||
}
|
||||
Free(mime);
|
||||
}
|
||||
}
|
||||
else if (reactions)
|
||||
|
|
|
|||
|
|
@ -110,6 +110,12 @@ extern const char *parsee_ascii[PARSEE_ASCII_LINES];
|
|||
* Modifies: the logger output */
|
||||
extern void ParseePrintASCII(void);
|
||||
|
||||
/**
|
||||
* Checks if two versions of Parsee can be considered "compatible".
|
||||
* ---------------
|
||||
* Modifies: NOTHING */
|
||||
extern bool ParseeIsCompatible(char *ver1, char *ver2);
|
||||
|
||||
/** Generates a valid, getopt-style argument list from a end-terminated
|
||||
* argument list.
|
||||
* ------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue