Message IDs are apparently generated from the latin1 encoding of a message. Added a command to check/fix that.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3833 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-02-10 03:58:33 +00:00
parent 557ae6ee5a
commit d4135f7133
6 changed files with 205 additions and 13 deletions

View File

@ -1,4 +1,6 @@
#include "ssb.h"
#include "ssb.db.h"
#include "ssb.import.h"
#include "ssb.import.h"
#include "ssb.export.h"
#include "task.h"
@ -57,6 +59,7 @@ static int _tf_command_export(const char* file, int argc, char* argv[]);
static int _tf_command_run(const char* file, int argc, char* argv[]);
static int _tf_command_sandbox(const char* file, int argc, char* argv[]);
static int _tf_command_post(const char* file, int argc, char* argv[]);
static int _tf_command_check(const char* file, int argc, char* argv[]);
static int _tf_command_usage(const char* file, int argc, char* argv[]);
typedef struct _command_t {
@ -72,6 +75,7 @@ const command_t k_commands[] = {
{ "import", _tf_command_import, "Import apps to SSB." },
{ "export", _tf_command_export, "Export apps from SSB." },
{ "test", _tf_command_test, "Test SSB." },
{ "check", _tf_command_check, "Validate messages in the SSB database." },
};
void shedPrivileges()
@ -549,6 +553,46 @@ xopt_help:
return 1;
}
static int _tf_command_check(const char* file, int argc, char* argv[])
{
typedef struct args_t {
bool help;
} args_t;
xoptOption options[] = {
{ "help", 'h', offsetof(args_t, help), NULL, XOPT_TYPE_BOOL, NULL, "Shows this help message." },
XOPT_NULLOPTION,
};
args_t args = { 0 };
const char** extras = NULL;
int extra_count = 0;
const char *err = NULL;
XOPT_PARSE(file, XOPT_CTX_KEEPFIRST | XOPT_CTX_STRICT, options, &args, argc, (const char**)argv, &extra_count, &extras, &err, stderr, "post [options]", "options:", NULL, 15);
if (extras)
{
free((void*)extras);
}
if (err)
{
fprintf(stderr, "Error: %s\n", err);
return 2;
}
sqlite3* db = NULL;
sqlite3_open("db.sqlite", &db);
bool result = tf_ssb_db_check(db);
sqlite3_close(db);
return result ? EXIT_SUCCESS : EXIT_FAILURE;
xopt_help:
if (extras)
{
free((void*)extras);
}
return 1;
}
static int _tf_command_usage(const char* file, int argc, char* argv[])
{
printf("Usage: %s command [command-options]\n", file);