Delete some code that doesn't need to exist.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@4319 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2023-06-01 22:53:44 +00:00
parent 19e26c1759
commit ca28b5ca82
7 changed files with 66 additions and 218 deletions

View File

@ -62,10 +62,8 @@ static int _tf_command_import(const char* file, int argc, char* argv[]);
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[]);
static int _tf_command_private(const char* file, int argc, char* argv[]);
typedef struct _command_t {
const char* name;
@ -76,12 +74,10 @@ typedef struct _command_t {
const command_t k_commands[] = {
{ "run", _tf_command_run, "Run tildefriends (default)." },
{ "sandbox", _tf_command_sandbox, "Run a sandboxed tildefriends sandbox process (used internally)." },
{ "post", _tf_command_post, "Create an SSB post." },
{ "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." },
{ "private", _tf_command_private, "Check for private messages the SSB database (just an experiment)." },
};
const char* k_db_path_default = "db.sqlite";
@ -522,48 +518,6 @@ xopt_help:
return 1;
}
static int _tf_command_post(const char* file, int argc, char* argv[])
{
typedef struct args_t {
char* message;
bool help;
} args_t;
xoptOption options[] = {
{ "message", 'm', offsetof(args_t, message), NULL, XOPT_REQUIRED | XOPT_TYPE_STRING, "TEXT", "Text to post." },
{ "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;
}
tf_ssb_t* ssb = tf_ssb_create(NULL, NULL, k_db_path_default);
tf_ssb_broadcast_listener_start(ssb, false);
tf_ssb_append_post(ssb, args.message);
tf_ssb_destroy(ssb);
return 0;
xopt_help:
if (extras)
{
free((void*)extras);
}
return 1;
}
static int _tf_command_check(const char* file, int argc, char* argv[])
{
typedef struct args_t {
@ -619,51 +573,6 @@ xopt_help:
return 1;
}
static int _tf_command_private(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, "private [options]", "options:", NULL, 15);
if (err)
{
if (extras)
{
free((void*)extras);
}
fprintf(stderr, "Error: %s\n", err);
return 2;
}
bool result = true;
sqlite3* db = NULL;
sqlite3_open(k_db_path_default, &db);
tf_ssb_db_private(db);
sqlite3_close(db);
if (extras)
{
free((void*)extras);
}
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[])
{
tf_printf("Usage: %s command [command-options]\n", file);