I had noticed several times earlier that having a talloc context
passed in would make things more convenient. I'm not exercising
that convenience yet, but the context is there now, (and there's
one fewer item on our TODO list).
-Add a talloc context as the first argument to each command in
-notmuch.c.
-
Write a notmuch man page.
Compile and install a libnotmuch library.
Write a notmuch man page.
Compile and install a libnotmuch library.
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
#define ARRAY_SIZE(arr) (sizeof (arr) / sizeof (arr[0]))
-typedef int (*command_function_t) (int argc, char *argv[]);
+typedef int (*command_function_t) (void *ctx, int argc, char *argv[]);
typedef struct command {
const char *name;
typedef struct command {
const char *name;
-setup_command (unused (int argc), unused (char *argv[]))
+setup_command (unused (void *ctx), unused (int argc), unused (char *argv[]))
{
notmuch_database_t *notmuch = NULL;
char *default_path, *mail_directory = NULL;
{
notmuch_database_t *notmuch = NULL;
char *default_path, *mail_directory = NULL;
-new_command (unused (int argc), unused (char *argv[]))
+new_command (unused (void *ctx), unused (int argc), unused (char *argv[]))
{
notmuch_database_t *notmuch;
const char *mail_directory;
{
notmuch_database_t *notmuch;
const char *mail_directory;
-search_command (int argc, char *argv[])
+search_command (void *ctx, int argc, char *argv[])
- void *local = talloc_new (NULL);
+ void *local = talloc_new (ctx);
notmuch_database_t *notmuch = NULL;
notmuch_query_t *query;
notmuch_threads_t *threads;
notmuch_database_t *notmuch = NULL;
notmuch_query_t *query;
notmuch_threads_t *threads;
-show_command (unused (int argc), unused (char *argv[]))
+show_command (void *ctx, unused (int argc), unused (char *argv[]))
- void *local = talloc_new (NULL);
+ void *local = talloc_new (ctx);
char *query_string;
notmuch_database_t *notmuch = NULL;
notmuch_query_t *query = NULL;
char *query_string;
notmuch_database_t *notmuch = NULL;
notmuch_query_t *query = NULL;
-tag_command (unused (int argc), unused (char *argv[]))
+tag_command (void *ctx, unused (int argc), unused (char *argv[]))
{
void *local;
int *add_tags, *remove_tags;
{
void *local;
int *add_tags, *remove_tags;
- local = talloc_new (NULL);
+ local = talloc_new (ctx);
if (local == NULL) {
ret = 1;
goto DONE;
if (local == NULL) {
ret = 1;
goto DONE;
-dump_command (int argc, char *argv[])
+dump_command (unused (void *ctx), int argc, char *argv[])
{
FILE *output = NULL;
notmuch_database_t *notmuch = NULL;
{
FILE *output = NULL;
notmuch_database_t *notmuch = NULL;
-restore_command (int argc, char *argv[])
+restore_command (unused (void *ctx), int argc, char *argv[])
{
FILE *input = NULL;
notmuch_database_t *notmuch = NULL;
{
FILE *input = NULL;
notmuch_database_t *notmuch = NULL;
-help_command (int argc, char *argv[]);
+help_command (void *ctx, int argc, char *argv[]);
command_t commands[] = {
{ "setup", setup_command,
command_t commands[] = {
{ "setup", setup_command,
-help_command (int argc, char *argv[])
+help_command (unused (void *ctx), int argc, char *argv[])
{
command_t *command;
unsigned int i;
{
command_t *command;
unsigned int i;
int
main (int argc, char *argv[])
{
int
main (int argc, char *argv[])
{
+ void *local = talloc_new (NULL);
command_t *command;
unsigned int i;
if (argc == 1)
command_t *command;
unsigned int i;
if (argc == 1)
- return setup_command (0, NULL);
+ return setup_command (local, 0, NULL);
for (i = 0; i < ARRAY_SIZE (commands); i++) {
command = &commands[i];
if (strcmp (argv[1], command->name) == 0)
for (i = 0; i < ARRAY_SIZE (commands); i++) {
command = &commands[i];
if (strcmp (argv[1], command->name) == 0)
- return (command->function) (argc - 2, &argv[2]);
+ return (command->function) (local, argc - 2, &argv[2]);
}
/* Don't complain about "help" being an unknown command when we're
}
/* Don't complain about "help" being an unknown command when we're
fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",
argv[1]);
fprintf (stderr, "Error: Unknown command '%s' (see \"notmuch help\")\n",
argv[1]);