diff options
author | Burt P <pburt0@gmail.com> | 2019-07-02 17:16:21 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-07-06 13:08:54 -0700 |
commit | 285664ed7e706d731e20064b40746204db72fbc4 (patch) | |
tree | 5159a3d238b28d2cb90e5824c2c1c371d9444d5b /hardinfo | |
parent | cf3983370bfa97a123699338b43af524619fff6e (diff) |
struct info: add morinfo() tag and flags support
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'hardinfo')
-rw-r--r-- | hardinfo/info.c | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/hardinfo/info.c b/hardinfo/info.c index 90a86148..368470b4 100644 --- a/hardinfo/info.c +++ b/hardinfo/info.c @@ -170,16 +170,27 @@ static void flatten_group(GString *output, const struct InfoGroup *group, guint if (group->fields) { for (i = 0; i < group->fields->len; i++) { struct InfoField field; + gchar tag[256] = ""; field = g_array_index(group->fields, struct InfoField, i); - if (field.icon) - g_string_append_printf(output, "$ITEM%d-%d$", group_count, i); + if (field.tag) + strncpy(tag, field.tag, 255); + else + snprintf(tag, 255, "ITEM%d-%d", group_count, i); + + if (*tag != 0 || field.flags) + g_string_append_printf(output, "$%s%s%s$", + field.flags & INFO_FIELD_SELECTED ? "*" : "", + field.flags & INFO_FIELD_SELECTED ? "!" : "", + tag); g_string_append_printf(output, "%s=%s\n", field.name, field.value); if (field.free_value_on_flatten) g_free((gchar *)field.value); + + g_free(field.tag); } } else if (group->computed) { g_string_append_printf(output, "%s\n", group->computed); |