aboutsummaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorBurt P <pburt0@gmail.com>2020-01-06 00:53:51 -0600
committerLeandro A. F. Pereira <leandro@hardinfo.org>2020-01-17 16:15:54 -0800
commit73142b793562158babf717422262bd1011ef17e4 (patch)
treef391c896e77dd23d59d4390387befddaedd2b393 /includes
parentc6f9dfec60f4bb5039e0dbb758313af58725242c (diff)
shell: new flag/funcs for escaping label part in keys
Will allow formerly forbidden characters in a label, "#$=" See: https://github.com/lpereira/hardinfo/issues/509 Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'includes')
-rw-r--r--includes/hardinfo.h7
-rw-r--r--includes/shell.h5
2 files changed, 12 insertions, 0 deletions
diff --git a/includes/hardinfo.h b/includes/hardinfo.h
index 19eb88fb..010af922 100644
--- a/includes/hardinfo.h
+++ b/includes/hardinfo.h
@@ -213,6 +213,13 @@ gboolean hardinfo_spawn_command_line_sync(const gchar *command_line,
/* a marker in text to point out problems, using markup where possible */
const char *problem_marker();
+/* a version of g_strescape() that allows escaping extra characters.
+ * use with g_strcompress() as normal. */
+gchar *
+gg_strescape (const gchar *source,
+ const gchar *exceptions,
+ const gchar *extra);
+
/* hinote helpers */
#define note_max_len 512
#define note_printf(note_buff, fmt, ...) \
diff --git a/includes/shell.h b/includes/shell.h
index b70b963e..927a9adf 100644
--- a/includes/shell.h
+++ b/includes/shell.h
@@ -227,11 +227,16 @@ void shell_set_remote_label(Shell *shell, gchar *label);
* ! = show details (moreinfo) in reports
* * = highlight/select this row
* ^ = value is/has a vendor string
+ * @ = label is escaped with key_label_escape()
*/
gboolean key_is_flagged(const gchar *key); /* has $[<flags>][<tag>]$ at the start of the key */
gboolean key_is_highlighted(const gchar *key); /* flag '*' = select/highlight */
gboolean key_wants_details(const gchar *key); /* flag '!' = report should include the "moreinfo" */
gboolean key_value_has_vendor_string(const gchar *key); /* flag '^' = try and match the value to a vendor */
+#define key_label_escape(LBL) (gg_strescape(LBL, NULL, "=$#"))
+gboolean key_label_is_escaped(const gchar *key); /* flag '@' = the label part is key_label_escape()-d and
+ * needs to be g_strcompress()-ed before use.
+ * key_get_components() will do this automatically for label. */
gchar *key_mi_tag(const gchar *key); /* moreinfo lookup tag */
const gchar *key_get_name(const gchar *key); /* get the key's name, flagged or not */
/*