aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--hardinfo/vendor.c37
-rw-r--r--includes/vendor.h2
2 files changed, 39 insertions, 0 deletions
diff --git a/hardinfo/vendor.c b/hardinfo/vendor.c
index 0e661bb9..9cc3a8e4 100644
--- a/hardinfo/vendor.c
+++ b/hardinfo/vendor.c
@@ -371,3 +371,40 @@ const gchar *vendor_get_url(const gchar * id_str) {
return NULL;
}
+
+gchar *vendor_get_link(const gchar *id_str)
+{
+ const Vendor *v = vendor_match(id_str, NULL);
+
+ if (!v) {
+ return g_strdup(id_str);
+ }
+
+ return vendor_get_link_from_vendor(v);
+}
+
+gchar *vendor_get_link_from_vendor(const Vendor *v)
+{
+ if (!v) {
+ return g_strdup(_("Unknown"));
+ }
+
+ if (!v->url) {
+ return g_strdup(v->name);
+ }
+
+ if (params.markup_ok) {
+ const gchar *prefix;
+
+ if (!strncmp(v->url, "http://", sizeof("http://") - 1) ||
+ !strncmp(v->url, "https://", sizeof("https://") - 1)) {
+ prefix = "";
+ } else {
+ prefix = "http://";
+ }
+
+ return g_strdup_printf("<a href=\"%s%s\">%s</a>", prefix, v->url, v->name);
+ }
+
+ return g_strdup_printf("%s (%s)", v->name, v->url);
+}
diff --git a/includes/vendor.h b/includes/vendor.h
index 1688010d..683e7d8a 100644
--- a/includes/vendor.h
+++ b/includes/vendor.h
@@ -35,6 +35,8 @@ const Vendor *vendor_match(const gchar *id_str, ...); /* end list of strings wit
const gchar *vendor_get_name(const gchar *id_str);
const gchar *vendor_get_shortest_name(const gchar *id_str);
const gchar *vendor_get_url(const gchar *id_str);
+gchar *vendor_get_link(const gchar *id_str);
+gchar *vendor_get_link_from_vendor(const Vendor *v);
void vendor_free(Vendor *v);
#endif /* __VENDOR_H__ */