]> git.notmuchmail.org Git - notmuch/blobdiff - test/random-corpus.c
emacs: Add new option notmuch-search-hide-excluded
[notmuch] / test / random-corpus.c
index d74271d932312d77ea66a02131a753ea4b931762..8ae08971478a2a639b249a08b1fd96c1c432b8ec 100644 (file)
@@ -19,7 +19,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see http://www.gnu.org/licenses/ .
+ * along with this program.  If not, see https://www.gnu.org/licenses/ .
  *
  * Author: David Bremner <david@tethera.net>
  */
@@ -50,7 +50,7 @@ typedef struct {
 
 /*
  *  Choose about half ascii as test characters, as ascii
- *  punctation and whitespace is the main cause of problems for
+ *  punctuation and whitespace is the main cause of problems for
  *  the (old) restore parser.
  *
  *  We then favour code points with 2 byte encodings. Note that
@@ -116,13 +116,14 @@ random_utf8_string (void *ctx, size_t char_count)
 
 /* stubs since we cannot link with notmuch.o */
 const notmuch_opt_desc_t notmuch_shared_options[] = {
-       { 0, 0, 0, 0, 0 }
+    { }
 };
 
-char *notmuch_requested_db_uuid = NULL;
+const char *notmuch_requested_db_uuid = NULL;
 
 void
-notmuch_process_shared_options (unused (const char *dummy))
+notmuch_process_shared_options (unused (notmuch_database_t *notmuch),
+                               unused (const char *dummy))
 {
 }
 
@@ -140,8 +141,7 @@ main (int argc, char **argv)
 
     void *ctx = talloc_new (NULL);
 
-    char *config_path  = NULL;
-    notmuch_config_t *config;
+    const char *config_path = NULL;
     notmuch_database_t *notmuch;
 
     int num_messages = 500;
@@ -155,13 +155,13 @@ main (int argc, char **argv)
     int seed = 734569;
 
     notmuch_opt_desc_t options[] = {
-       { NOTMUCH_OPT_STRING, &config_path, "config-path", 'c', 0 },
-       { NOTMUCH_OPT_INT, &num_messages, "num-messages", 'n', 0 },
-       { NOTMUCH_OPT_INT, &max_tags, "max-tags", 'm', 0 },
-       { NOTMUCH_OPT_INT, &message_id_len, "message-id-len", 'M', 0 },
-       { NOTMUCH_OPT_INT, &tag_len, "tag-len", 't', 0 },
-       { NOTMUCH_OPT_INT, &seed, "seed", 's', 0 },
-       { 0, 0, 0, 0, 0 }
+       { .opt_string = &config_path, .name = "config-path" },
+       { .opt_int = &num_messages, .name = "num-messages" },
+       { .opt_int = &max_tags, .name = "max-tags" },
+       { .opt_int = &message_id_len, .name = "message-id-len" },
+       { .opt_int = &tag_len, .name = "tag-len" },
+       { .opt_int = &seed, .name = "seed" },
+       { }
     };
 
     int opt_index = parse_arguments (argc, argv, options, 1);
@@ -179,17 +179,18 @@ main (int argc, char **argv)
        exit (1);
     }
 
-    config = notmuch_config_open (ctx, config_path, FALSE);
-    if (config == NULL)
-       return 1;
-
-    if (notmuch_database_open (notmuch_config_get_database_path (config),
-                              NOTMUCH_DATABASE_MODE_READ_WRITE, &notmuch))
+    if (notmuch_database_open_with_config (NULL,
+                                          NOTMUCH_DATABASE_MODE_READ_WRITE,
+                                          config_path,
+                                          NULL,
+                                          &notmuch,
+                                          NULL))
        return 1;
 
     srandom (seed);
 
     int count;
+
     for (count = 0; count < num_messages; count++) {
        int j;
        /* explicitly allow zero tags */