diff options
author | Burt P <pburt0@gmail.com> | 2019-12-27 22:12:49 -0600 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-12-27 22:16:36 -0800 |
commit | 79d8b3c8b4f54e17b35cf82fc97af9d8be73d7dc (patch) | |
tree | c3f08fcb3f1174fb5315b1b821d247602ed40906 /deps/sysobj_early/src/format_early.c | |
parent | 9b8122e2c3378966641568f9c12ce10a6a9ec45c (diff) |
usb: vendor tags in list
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'deps/sysobj_early/src/format_early.c')
-rw-r--r-- | deps/sysobj_early/src/format_early.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/deps/sysobj_early/src/format_early.c b/deps/sysobj_early/src/format_early.c index bc5883cc..5f191d60 100644 --- a/deps/sysobj_early/src/format_early.c +++ b/deps/sysobj_early/src/format_early.c @@ -19,7 +19,6 @@ */ #include "format_early.h" -#include "vendor.h" #define ANSI_COLOR_RESET "\x1b[0m" @@ -128,3 +127,32 @@ gchar *vendor_match_tag(const gchar *vendor_str, int fmt_opts) { } return NULL; } + +gchar *vendor_list_ribbon(const vendor_list vl_in, int fmt_opts) { + gchar *ret = NULL; + vendor_list vl = g_slist_copy(vl_in); /* shallow is fine */ + vl = vendor_list_remove_duplicates(vl); + if (vl) { + GSList *l = vl, *n = l ? l->next : NULL; + /* replace each vendor with the vendor tag */ + for(; l; l = n) { + n = l->next; + const Vendor *v = l->data; + if (!v) { + vl = g_slist_delete_link(vl, l); + continue; + } + gchar *ven_tag = v->name_short ? g_strdup(v->name_short) : g_strdup(v->name); + if(ven_tag) { + tag_vendor(&ven_tag, 0, ven_tag, v->ansi_color, fmt_opts); + l->data = ven_tag; + } + } + /* vl is now a regular GSList of formatted vendor tag strings */ + vl = gg_slist_remove_duplicates_custom(vl, (GCompareFunc)g_strcmp0); + for(l = vl; l; l = l->next) + ret = appfsp(ret, "%s", (gchar*)l->data); + } + g_slist_free_full(vl, g_free); + return ret; +} |