diff options
| author | Burt P <pburt0@gmail.com> | 2017-08-08 20:52:19 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-08-14 01:56:47 -0700 | 
| commit | 90103feadf0fcbe866e82cc6f424b0662f5f5474 (patch) | |
| tree | 326d2a5ac00b87c49570bd069c9b644e567c59c7 /modules | |
| parent | b7086345dc5402ceda5e079fdb9f848f00216e40 (diff) | |
Move hardinfo_clean_label() and hardinfo_clean_value() to util.c
Signed-off-by: Burt P <pburt0@gmail.com>
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/devices/devicetree.c | 57 | 
1 files changed, 1 insertions, 56 deletions
| diff --git a/modules/devices/devicetree.c b/modules/devices/devicetree.c index bae4850e..6fce066a 100644 --- a/modules/devices/devicetree.c +++ b/modules/devices/devicetree.c @@ -24,66 +24,11 @@  #include <unistd.h>  #include <sys/types.h>  #include <stdint.h> +#include "hardinfo.h"  #include "devices.h"  #include "cpu_util.h"  #include "dt_util.h" -/* Hardinfo labels that have # are truncated and/or hidden. - * Labels can't have $ because that is the delimiter in - * moreinfo. */ -gchar *hardinfo_clean_label(const gchar *v, int replacing) { -    gchar *clean, *p; - -    p = clean = g_strdup(v); -    while (*p != 0) { -        switch(*p) { -            case '#': case '$': -                *p = '_'; -                break; -            default: -                break; -        } -        p++; -    } -    if (replacing) -        g_free((gpointer)v); -    return clean; -} - -/* hardinfo uses the values as {ht,x}ml, apparently */ -gchar *hardinfo_clean_value(const gchar *v, int replacing) { -    gchar *clean, *tmp; -    gchar **vl; -    if (v == NULL) return NULL; - -    vl = g_strsplit(v, "&", -1); -    if (g_strv_length(vl) > 1) -        clean = g_strjoinv("&", vl); -    else -        clean = g_strdup(v); -    g_strfreev(vl); - -    vl = g_strsplit(clean, "<", -1); -    if (g_strv_length(vl) > 1) { -        tmp = g_strjoinv("<", vl); -        g_free(clean); -        clean = tmp; -    } -    g_strfreev(vl); - -    vl = g_strsplit(clean, ">", -1); -    if (g_strv_length(vl) > 1) { -        tmp = g_strjoinv(">", vl); -        g_free(clean); -        clean = tmp; -    } -    g_strfreev(vl); - -    if (replacing) -        g_free((gpointer)v); -    return clean; -} -  #include "devicetree/rpi_data.c"  #include "devicetree/pmac_data.c" | 
