diff --git a/lib/mu-query.h b/lib/mu-query.h index 82b660f7..7885e2a4 100644 --- a/lib/mu-query.h +++ b/lib/mu-query.h @@ -53,16 +53,6 @@ MuQuery* mu_query_new (MuStore *store, GError **err) */ void mu_query_destroy (MuQuery *self); -/** - * get a version string for the database - * - * @param store a valid MuQuery - * - * @return the version string (free with g_free), or NULL in case of error - */ -char* mu_query_version (MuQuery *store) - G_GNUC_MALLOC G_GNUC_WARN_UNUSED_RESULT; - typedef enum { MU_QUERY_FLAG_NONE = 0 << 0, /**< no flags */ diff --git a/lib/utils/mu-str.c b/lib/utils/mu-str.c index 03931552..607d3221 100644 --- a/lib/utils/mu-str.c +++ b/lib/utils/mu-str.c @@ -428,125 +428,6 @@ mu_str_quoted_from_strv (const gchar **params) } -static char* -read_key (const char *str, const char **val, GError **err) -{ - const char *cur; - GString *gstr; - - cur = str; - - gstr = g_string_sized_new (strlen(cur)); - while (*cur && *cur != ':') { - g_string_append_c (gstr, *cur); - ++cur; - } - - if (*cur != ':' || gstr->len == 0) { - g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR, - "expected: '+:' (%s)", - str); - g_string_free (gstr, TRUE); - *val = NULL; - return NULL; - } else { - *val = cur + 1; - return g_string_free (gstr, FALSE); - } -} - - -static char* -read_val (const char *str, const char **endval, GError **err) -{ - const char *cur; - gboolean quoted; - GString *gstr; - - gstr = g_string_sized_new (strlen(str)); - - for (quoted = FALSE, cur = str; *cur; ++cur) { - - if (*cur == '\\') { - if (cur[1] != '"' && cur[1] != '\\') { - g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR, - "invalid escaping"); - goto errexit; - } else { - ++cur; - g_string_append_c (gstr, *cur); - continue; - } - } else if (*cur == '"') { - quoted = !quoted; - continue; - } else if (isblank(*cur) && !quoted) - break; - else - g_string_append_c (gstr, *cur); - } - - if (quoted) { - g_set_error (err, MU_ERROR_DOMAIN, MU_ERROR, - "error in quoting"); - goto errexit; - } - - *endval = cur; - return g_string_free (gstr, FALSE); - -errexit: - g_string_free (gstr, TRUE); - return NULL; -} - - -GHashTable* -mu_str_parse_arglist (const char *args, GError **err) -{ - GHashTable *hash; - const char *cur; - - g_return_val_if_fail (args, NULL); - - hash = g_hash_table_new_full ( - g_str_hash, - g_str_equal, - (GDestroyNotify)g_free, - (GDestroyNotify)g_free); - - cur = args; - while ((isblank(*cur))) - ++cur; - - do { - char *key, *val; - const char *valstart, *valend; - - key = read_key (cur, &valstart, err); - if (!key) - goto errexit; - - val = read_val (valstart, &valend, err); - if (!val) - goto errexit; - - /* g_print ("%s->%s\n", key, val); */ - g_hash_table_insert (hash, key, val); - - cur = valend; - while ((isblank(*cur))) - ++cur; - } while (*cur); - - return hash; - -errexit: - g_hash_table_destroy (hash); - return NULL; -} - - char* mu_str_remove_ctrl_in_place (char *str) { diff --git a/lib/utils/mu-str.h b/lib/utils/mu-str.h index bd985a22..45867d7a 100644 --- a/lib/utils/mu-str.h +++ b/lib/utils/mu-str.h @@ -174,19 +174,6 @@ GSList* mu_str_to_list (const char *str, char sepa, gboolean strip); */ GSList* mu_str_esc_to_list (const char *str); -/** - * Parse a list of : arguments, where supports - * quoting and escaping. - * - * @param args a list of arguments - * @param err receives error information - * - * @return a hash table with key->value, or NULL in case of - * error. Free with g_hash_table_destroy. - */ -GHashTable* mu_str_parse_arglist (const char *args, GError **err) -G_GNUC_WARN_UNUSED_RESULT; - /** * free a GSList consisting of allocated strings * diff --git a/lib/utils/test-mu-str.c b/lib/utils/test-mu-str.c index f8b3cd04..75fc71fb 100644 --- a/lib/utils/test-mu-str.c +++ b/lib/utils/test-mu-str.c @@ -70,34 +70,6 @@ test_mu_str_size_02 (void) g_free (tmp2); } - - -static void -test_parse_arglist (void) -{ - const char *args; - GHashTable *hash; - GError *err; - - args = "cmd:find query:maildir:\"/sent items\" maxnum:500"; - - err = NULL; - hash = mu_str_parse_arglist (args, &err); - g_assert_no_error (err); - g_assert (hash); - - g_assert_cmpstr (g_hash_table_lookup (hash, "cmd"), ==, - "find"); - /* note, mu4e now passes queries as base64 */ - g_assert_cmpstr (g_hash_table_lookup (hash, "query"), ==, - "maildir:/sent items"); - g_assert_cmpstr (g_hash_table_lookup (hash, "maxnum"), ==, - "500"); - - g_hash_table_destroy (hash); -} - - static void test_mu_str_esc_to_list (void) { @@ -289,9 +261,6 @@ main (int argc, char *argv[]) g_test_add_func ("/mu-str/mu-str-to-list-strip", test_mu_str_to_list_strip); - g_test_add_func ("/mu-str/mu-str-parse-arglist", - test_parse_arglist); - g_test_add_func ("/mu-str/mu-str-replace", test_mu_str_replace);