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/libsmartcols/src/table.c
struct libscols_column* scols_table_new_column(struct libscols_table* tb,
                                               const char* name, double whint,
                                               int flags)
{
    struct libscols_column* cl;
    struct libscols_cell* hr;

    if (!tb)
        return NULL;

    DBG(TAB, ul_debugobj(tb, "new column name=%s, whint=%g, flags=%d", name,
                         whint, flags));
    cl = scols_new_column();
    if (!cl)
        return NULL;

    /* set column name */
    hr = scols_column_get_header(cl);
    if (!hr)
        goto err;
    if (scols_cell_set_data(hr, name))
        goto err;

    scols_column_set_whint(cl, whint);
    scols_column_set_flags(cl, flags);

    if (scols_table_add_column(tb, cl)) /* this increments column ref-counter */
        goto err;

    scols_unref_column(cl);
    return cl;
err:
    scols_unref_column(cl);
    return NULL;
}
/**
 * scols_table_new_column:
 * @tb: table
 * @name: column header
 * @whint: column width hint (absolute width: N > 1; relative width: 0 < N < 1)
 * @flags: flags integer
 *
 * This is shortcut for
 *
 *   cl = scols_new_column();
 *   scols_column_set_....(cl, ...);
 *   scols_table_add_column(tb, cl);
 *
 * The column width is possible to define by:
 *
 *  @whint: 0 < N < 1  : relative width, percent of terminal width
 *
 *  @whint: N >= 1     : absolute width, empty column will be truncated to
 *                     the column header width if no specified STRICTWIDTH flag
 *
 * Note that if table has disabled "maxout" flag (disabled by default) than
 * relative width is used as a hint only. It's possible that column will be
 * narrow if the specified size is too large for column data.
 *
 *
 * If the width of all columns is greater than terminal width then library
 * tries to reduce width of the individual columns. It's done in three stages:
 *
 * #1 reduce columns with SCOLS_FL_TRUNC flag and with relative width if the
 *    width is greater than width defined by @whint (@whint * terminal_width)
 *
 * #2 reduce all columns with SCOLS_FL_TRUNC flag
 *
 * #3 reduce all columns with relative width
 *
 * The next stage is always used if the previous stage is unsuccessful. Note
 * that SCOLS_FL_WRAP is interpreted as SCOLS_FL_TRUNC when calculate column
 * width (if custom wrap function is not specified), but the final text is not
 * truncated, but wrapped to multi-line cell.
 *
 *
 * The column is necessary to address by sequential number. The first defined
 * column has the colnum = 0. For example:
 *
 *	scols_table_new_column(tab, "FOO", 0.5, 0);		// colnum = 0
 *	scols_table_new_column(tab, "BAR", 0.5, 0);		// colnum = 1
 *      .
 *      .
 *	scols_line_get_cell(line, 0);				// FOO column
 *	scols_line_get_cell(line, 1);				// BAR column
 *
 * Returns: newly allocated column
 */


This is shortcut for



The column width is possible to define by.

@whint: 0 < N < 1  : relative width, percent of terminal width

@whint: N >= 1     : absolute width, empty column will be truncated to
the column header width if no specified STRICTWIDTH flag

Note that if table has disabled "maxout" flag (disabled by default) than
relative width is used as a hint only. It's possible that column will be
narrow if the specified size is too large for column data.

If the width of all columns is greater than terminal width then library
tries to reduce width of the individual columns. It's done in three stages.

#1 reduce columns with SCOLS_FL_TRUNC flag and with relative width if the
width is greater than width defined by @whint (@whint * terminal_width)

#2 reduce all columns with SCOLS_FL_TRUNC flag

#3 reduce all columns with relative width

The next stage is always used if the previous stage is unsuccessful. Note
that SCOLS_FL_WRAP is interpreted as SCOLS_FL_TRUNC when calculate column
width (if custom wrap function is not specified), but the final text is not
truncated, but wrapped to multi-line cell.

The column is necessary to address by sequential number. The first defined
column has the colnum = 0. For example.



newly allocated column
This is shortcut for The column width is possible to define by . @whint : 0 < N < 1 : relative width percent of terminal width @whint : N > = 1 : absolute width empty column will be truncated to the column header width if no specified STRICTWIDTH flag Note that if table has disabled " maxout " flag ( disabled by default ) than relative width is used as a hint only . It ' s possible that column will be narrow if the specified size is too large for column data . If the width of all columns is greater than terminal width then library tries to reduce width of the individual columns . It ' s done in three stages . #1 reduce columns with SCOLS_FL_TRUNC flag and with relative width if the width is greater than width defined by @whint ( @whint * terminal_width ) #2 reduce all columns with SCOLS_FL_TRUNC flag #3 reduce all columns with relative width The next stage is always used if the previous stage is unsuccessful . Note that SCOLS_FL_WRAP is interpreted as SCOLS_FL_TRUNC when calculate column width ( if custom wrap function is not specified ) but the final text is not truncated but wrapped to multi - line cell . The column is necessary to address by sequential number . The first defined column has the colnum = 0 . For example . newly allocated column
struct libscols_column* scols_table_new_column(struct libscols_table* tb,
                                               const char* name, double whint,
                                               int flags)
{
    struct libscols_column* cl;
    struct libscols_cell* hr;
    if (!tb)
        return NULL;
    DBG(TAB, ul_debugobj(tb, "new column name=%s, whint=%g, flags=%d", name,
                         whint, flags));
    cl = scols_new_column();
    if (!cl)
        return NULL;
    hr = scols_column_get_header(cl);
    if (!hr)
        goto err;
    if (scols_cell_set_data(hr, name))
        goto err;
    scols_column_set_whint(cl, whint);
    scols_column_set_flags(cl, flags);
    if (scols_table_add_column(tb, cl)) 
        goto err;
    scols_unref_column(cl);
    return cl;
err:
    scols_unref_column(cl);
    return NULL;
}
struct libscols_column * scols_table_new_column ( struct libscols_table * tb , const char * name , double whint , int flags ) { struct libscols_column * cl ; struct libscols_cell * hr ; if ( ! tb ) return NULL ; DBG ( TAB , ul_debugobj ( tb , " " , name , whint , flags ) ) ; cl = scols_new_column ( ) ; if ( ! cl ) return NULL ; hr = scols_column_get_header ( cl ) ; if ( ! hr ) goto err ; if ( scols_cell_set_data ( hr , name ) ) goto err ; scols_column_set_whint ( cl , whint ) ; scols_column_set_flags ( cl , flags ) ; if ( scols_table_add_column ( tb , cl ) ) goto err ; scols_unref_column ( cl ) ; return cl ; err : scols_unref_column ( cl ) ; return NULL ; }
scols_table_new_column:
 @tb: table
 @name: column header
 @whint: column width hint (absolute width: N > 1; relative width: 0 < N < 1)
 @flags: flags integer
scols_table_new_column : @tb : table @name : column header @whint : column width hint ( absolute width : N > 1 ; relative width : 0 < N < 1 ) @flags : flags integer
/* set column name */ /* this increments column ref-counter */