summaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authorDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2020-01-19 17:23:24 +0200
committerDirk-Jan C. Binnema <djcb@djcbsoftware.nl>2020-01-22 11:42:15 +0200
commitd2ec85f01c61514e115f66ddb246f7a72aebfaae (patch)
tree85ab266cc739690c70bd45a86d6ddf7d4426bc9b /lib/utils
parentc71f683e396b6a6753d231dfa5df2def1b0e7c88 (diff)
mu4e: use the new command-parser
Update mu4e-proc to use the new mu4e <-> mu protocol
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/mu-utils.cc27
-rw-r--r--lib/utils/mu-utils.hh11
2 files changed, 38 insertions, 0 deletions
diff --git a/lib/utils/mu-utils.cc b/lib/utils/mu-utils.cc
index 9ebe801..5c8e59e 100644
--- a/lib/utils/mu-utils.cc
+++ b/lib/utils/mu-utils.cc
@@ -445,6 +445,33 @@ Mu::size_to_string (const std::string& val, bool is_first)
}
+std::string
+Mu::quoted (const std::string& str)
+{
+ std::string res{"\""};
+ for (auto&& c : str) {
+ if (c == '\\' || c == '\"')
+ res += '\\';
+ res += c;
+ }
+
+ return res + '"';
+}
+
+// std::string
+// Mu::quoted (const char* str)
+// {
+// if (!str)
+// return str;
+
+// char *s{g_strescape(str, NULL)};
+// auto res = format("\"%s\"", s ? s : "");
+// g_free(s);
+
+// return res;
+// }
+
+
void
Mu::assert_equal(const std::string& s1, const std::string& s2)
{
diff --git a/lib/utils/mu-utils.hh b/lib/utils/mu-utils.hh
index f5b2e61..e988065 100644
--- a/lib/utils/mu-utils.hh
+++ b/lib/utils/mu-utils.hh
@@ -94,6 +94,17 @@ std::string format (const char *frm, va_list args) __attribute__((format(printf,
/**
+ * Quote a string -- put in "" and escape any special characters by putting '\'
+ * in front of them.
+ *
+ * @param str
+ *
+ * @return
+ */
+std::string quoted (const std::string& str);
+
+
+/**
* Convert an ISO date to the corresponding time expressed as a string
* with a 10-digit time_t
*