]> git.notmuchmail.org Git - notmuch/blobdiff - notmuch-config.c
lib: strip trailing '/' from pathnames (sexp queries).
[notmuch] / notmuch-config.c
index 16e869162e5397e4972b9d2e444a8b5c8822b1f1..e9456d794456c080e81abbd6a00efcb6b123c3c4 100644 (file)
@@ -24,6 +24,7 @@
 #include <netdb.h>
 #include <assert.h>
 
+#include "path-util.h"
 #include "unicode-util.h"
 
 static const char toplevel_config_comment[] =
@@ -31,7 +32,7 @@ static const char toplevel_config_comment[] =
     "\n"
     " For more information about notmuch, see https://notmuchmail.org";
 
-struct config_group {
+static const struct config_group {
     const char *group_name;
     const char *comment;
 } group_comment_table [] = {
@@ -327,7 +328,7 @@ notmuch_conffile_save (notmuch_conffile_t *config)
     }
 
     /* Try not to overwrite symlinks. */
-    filename = canonicalize_file_name (config->filename);
+    filename = notmuch_canonicalize_file_name (config->filename);
     if (! filename) {
        if (errno == ENOENT) {
            filename = strdup (config->filename);
@@ -382,7 +383,10 @@ _config_set_list (notmuch_conffile_t *config,
                  const char *list[],
                  size_t length)
 {
-    g_key_file_set_string_list (config->key_file, group, key, list, length);
+    if (length > 1)
+       g_key_file_set_string_list (config->key_file, group, key, list, length);
+    else
+       g_key_file_set_string (config->key_file, group, key, list[0]);
 }
 
 void
@@ -511,14 +515,15 @@ typedef struct config_key {
     bool (*validate)(const char *);
 } config_key_info_t;
 
-static struct config_key
+static const struct config_key
     config_key_table[] = {
     { "index.decrypt",   false,  NULL },
     { "index.header.",   true,   validate_field_name },
     { "query.",          true,   NULL },
+    { "squery.",         true,   validate_field_name },
 };
 
-static config_key_info_t *
+static const config_key_info_t *
 _config_key_info (const char *item)
 {
     for (size_t i = 0; i < ARRAY_SIZE (config_key_table); i++) {
@@ -537,11 +542,18 @@ notmuch_config_command_get (notmuch_database_t *notmuch, char *item)
 {
     notmuch_config_values_t *list;
 
-    for (list = notmuch_config_get_values_string (notmuch, item);
-        notmuch_config_values_valid (list);
-        notmuch_config_values_move_to_next (list)) {
-       const char *val = notmuch_config_values_get (list);
-       puts (val);
+    if (STRNCMP_LITERAL (item, BUILT_WITH_PREFIX) == 0) {
+       if (notmuch_built_with (item + strlen (BUILT_WITH_PREFIX)))
+           puts ("true");
+       else
+           puts ("false");
+    } else {
+       for (list = notmuch_config_get_values_string (notmuch, item);
+            notmuch_config_values_valid (list);
+            notmuch_config_values_move_to_next (list)) {
+           const char *val = notmuch_config_values_get (list);
+           puts (val);
+       }
     }
     return EXIT_SUCCESS;
 }
@@ -582,7 +594,7 @@ notmuch_config_command_set (notmuch_database_t *notmuch,
                            int argc, char *argv[])
 {
     char *group, *key;
-    config_key_info_t *key_info;
+    const config_key_info_t *key_info;
     notmuch_conffile_t *config;
     bool update_database = false;
     int opt_index, ret;
@@ -671,6 +683,9 @@ _notmuch_config_list_built_with ()
     printf ("%sretry_lock=%s\n",
            BUILT_WITH_PREFIX,
            notmuch_built_with ("retry_lock") ? "true" : "false");
+    printf ("%ssexp_queries=%s\n",
+           BUILT_WITH_PREFIX,
+           notmuch_built_with ("sexp_queries") ? "true" : "false");
 }
 
 static int
@@ -700,10 +715,6 @@ notmuch_config_command (notmuch_database_t *notmuch, int argc, char *argv[])
     if (opt_index < 0)
        return EXIT_FAILURE;
 
-    if (notmuch_requested_db_uuid)
-       fprintf (stderr, "Warning: ignoring --uuid=%s\n",
-                notmuch_requested_db_uuid);
-
     /* skip at least subcommand argument */
     argc -= opt_index;
     argv += opt_index;