openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/util-linux/2.33.2-r0/util-linux-2.33.2/sys-utils/lscpu.c
static void print_parsable(struct lscpu_desc* desc, int cols[], int ncols,
                           struct lscpu_modifier* mod)
{
    char buf[BUFSIZ], *data;
    int i;

    /*
     * Header
     */
    printf(
        _("# The following is the parsable format, which can be fed to other\n"
          "# programs. Each different item in every column has an unique ID\n"
          "# starting from zero.\n"));

    fputs("# ", stdout);
    for (i = 0; i < ncols; i++)
    {
        int col = cols[i];

        if (col == COL_CACHE)
        {
            if (mod->compat && !desc->ncaches)
                continue;
            if (mod->compat && i != 0)
                putchar(',');
        }
        if (i > 0)
            putchar(',');

        data = get_cell_header(desc, col, mod, buf, sizeof(buf));

        if (data && *data && col != COL_CACHE && !coldescs[col].is_abbr)
        {
            /*
             * For normal column names use mixed case (e.g. "Socket")
             */
            char* p = data + 1;

            while (p && *p != '\0')
            {
                *p = tolower((unsigned int)*p);
                p++;
            }
        }
        fputs(data && *data ? data : "", stdout);
    }
    putchar('\n');

    /*
     * Data
     */
    for (i = 0; i < desc->ncpuspos; i++)
    {
        int c;
        int cpu = real_cpu_num(desc, i);

        if (!mod->offline && desc->online && !is_cpu_online(desc, cpu))
            continue;
        if (!mod->online && desc->online && is_cpu_online(desc, cpu))
            continue;
        if (desc->present && !is_cpu_present(desc, cpu))
            continue;
        for (c = 0; c < ncols; c++)
        {
            if (mod->compat && cols[c] == COL_CACHE)
            {
                if (!desc->ncaches)
                    continue;
                if (c > 0)
                    putchar(',');
            }
            if (c > 0)
                putchar(',');

            data = get_cell_data(desc, i, cols[c], mod, buf, sizeof(buf));
            fputs(data && *data ? data : "", stdout);
        }
        putchar('\n');
    }
}
/*
 * [-p] backend, we support two parsable formats:
 *
 * 1) "compatible" -- this format is compatible with the original lscpu(1)
 * output and it contains fixed set of the columns. The CACHE columns are at
 * the end of the line and the CACHE is not printed if the number of the caches
 * is zero. The CACHE columns are separated by two commas, for example:
 *
 *    $ lscpu --parse
 *    # CPU,Core,Socket,Node,,L1d,L1i,L2
 *    0,0,0,0,,0,0,0
 *    1,1,0,0,,1,1,0
 *
 * 2) "user defined output" -- this format prints always all columns without
 * special prefix for CACHE column. If there are not CACHEs then the column is
 * empty and the header "Cache" is printed rather than a real name of the cache.
 * The CACHE columns are separated by ':'.
 *
 *	$ lscpu --parse=CPU,CORE,SOCKET,NODE,CACHE
 *	# CPU,Core,Socket,Node,L1d:L1i:L2
 *	0,0,0,0,0:0:0
 *	1,1,0,0,1:1:0
 */
[-p] backend, we support two parsable formats:
1) "compatible" -- this format is compatible with the original lscpu(1)
output and it contains fixed set of the columns. The CACHE columns are at
the end of the line and the CACHE is not printed if the number of the caches
is zero. The CACHE columns are separated by two commas, for example.



2) "user defined output" -- this format prints always all columns without
special prefix for CACHE column. If there are not CACHEs then the column is
empty and the header "Cache" is printed rather than a real name of the cache.
The CACHE columns are separated by ':'.


[ - p ] backend we support two parsable formats : 1 ) " compatible " -- this format is compatible with the original lscpu ( 1 ) output and it contains fixed set of the columns . The CACHE columns are at the end of the line and the CACHE is not printed if the number of the caches is zero . The CACHE columns are separated by two commas for example . 2 ) " user defined output " -- this format prints always all columns without special prefix for CACHE column . If there are not CACHEs then the column is empty and the header " Cache " is printed rather than a real name of the cache . The CACHE columns are separated by ' : ' .
static void print_parsable(struct lscpu_desc* desc, int cols[], int ncols,
                           struct lscpu_modifier* mod)
{
    char buf[BUFSIZ], *data;
    int i;
    printf(
        _("# The following is the parsable format, which can be fed to other\n"
          "# programs. Each different item in every column has an unique ID\n"
          "# starting from zero.\n"));
    fputs("# ", stdout);
    for (i = 0; i < ncols; i++)
    {
        int col = cols[i];
        if (col == COL_CACHE)
        {
            if (mod->compat && !desc->ncaches)
                continue;
            if (mod->compat && i != 0)
                putchar(',');
        }
        if (i > 0)
            putchar(',');
        data = get_cell_header(desc, col, mod, buf, sizeof(buf));
        if (data && *data && col != COL_CACHE && !coldescs[col].is_abbr)
        {
            char* p = data + 1;
            while (p && *p != '\0')
            {
                *p = tolower((unsigned int)*p);
                p++;
            }
        }
        fputs(data && *data ? data : "", stdout);
    }
    putchar('\n');
    for (i = 0; i < desc->ncpuspos; i++)
    {
        int c;
        int cpu = real_cpu_num(desc, i);
        if (!mod->offline && desc->online && !is_cpu_online(desc, cpu))
            continue;
        if (!mod->online && desc->online && is_cpu_online(desc, cpu))
            continue;
        if (desc->present && !is_cpu_present(desc, cpu))
            continue;
        for (c = 0; c < ncols; c++)
        {
            if (mod->compat && cols[c] == COL_CACHE)
            {
                if (!desc->ncaches)
                    continue;
                if (c > 0)
                    putchar(',');
            }
            if (c > 0)
                putchar(',');
            data = get_cell_data(desc, i, cols[c], mod, buf, sizeof(buf));
            fputs(data && *data ? data : "", stdout);
        }
        putchar('\n');
    }
}
static void print_parsable ( struct lscpu_desc * desc , int cols [ ] , int ncols , struct lscpu_modifier * mod ) { char buf [ BUFSIZ ] , * data ; int i ; printf ( _ ( " \n " " \n " " \n " ) ) ; fputs ( " " , stdout ) ; for ( i = 0 ; i < ncols ; i ++ ) { int col = cols [ i ] ; if ( col == COL_CACHE ) { if ( mod -> compat && ! desc -> ncaches ) continue ; if ( mod -> compat && i != 0 ) putchar ( ' ' ) ; } if ( i > 0 ) putchar ( ' ' ) ; data = get_cell_header ( desc , col , mod , buf , sizeof ( buf ) ) ; if ( data && * data && col != COL_CACHE && ! coldescs [ col ] . is_abbr ) { char * p = data + 1 ; while ( p && * p != ' \0 ' ) { * p = tolower ( ( unsigned int ) * p ) ; p ++ ; } } fputs ( data && * data ? data : " " , stdout ) ; } putchar ( ' \n ' ) ; for ( i = 0 ; i < desc -> ncpuspos ; i ++ ) { int c ; int cpu = real_cpu_num ( desc , i ) ; if ( ! mod -> offline && desc -> online && ! is_cpu_online ( desc , cpu ) ) continue ; if ( ! mod -> online && desc -> online && is_cpu_online ( desc , cpu ) ) continue ; if ( desc -> present && ! is_cpu_present ( desc , cpu ) ) continue ; for ( c = 0 ; c < ncols ; c ++ ) { if ( mod -> compat && cols [ c ] == COL_CACHE ) { if ( ! desc -> ncaches ) continue ; if ( c > 0 ) putchar ( ' ' ) ; } if ( c > 0 ) putchar ( ' ' ) ; data = get_cell_data ( desc , i , cols [ c ] , mod , buf , sizeof ( buf ) ) ; fputs ( data && * data ? data : " " , stdout ) ; } putchar ( ' \n ' ) ; } }
[-p] backend, we support two parsable formats:
 1) "compatible" -- this format is compatible with the original lscpu(1)
 output and it contains fixed set of the columns.
[ - p ] backend we support two parsable formats : 1 ) " compatible " -- this format is compatible with the original lscpu ( 1 ) output and it contains fixed set of the columns .
/*
     * Header
     */ /*
             * For normal column names use mixed case (e.g. "Socket")
             */ /*
     * Data
     */