mirror of
https://github.com/ibm-s390-linux/s390-tools.git
synced 2026-08-05 02:14:52 +00:00
Fix issue in the lszdev command where column names if using the --pairs command line switch can contain characters that are not allowed to be used as variable names in a shell environment. Replace bad characters in column names by an underscore if the --shell command line switch is specified along with the --pairs switch. The additional --shell switch mimics what is already available in the lsblk command and thus it shall be used along with the --pairs switch. Signed-off-by: Daniel S. Haischt <modean@linux.ibm.com> Reviewed-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
75 lines
2.1 KiB
C
75 lines
2.1 KiB
C
/*
|
|
* zdev - Modify and display the persistent configuration of devices
|
|
*
|
|
* Copyright IBM Corp. 2016, 2017
|
|
*
|
|
* s390-tools is free software; you can redistribute it and/or modify
|
|
* it under the terms of the MIT license. See LICENSE for details.
|
|
*/
|
|
|
|
#ifndef TABLE_H
|
|
#define TABLE_H
|
|
|
|
#include "exit_code.h"
|
|
|
|
#define COLUMN(a, b, c, d, e) \
|
|
{ \
|
|
.name = (a), \
|
|
.align = (b), \
|
|
.id = (c), \
|
|
.def = (d), \
|
|
.desc = (e), \
|
|
}
|
|
|
|
#define COLUMN_ARRAY(...) \
|
|
((struct column[]) { __VA_ARGS__, { .name = NULL } })
|
|
|
|
/* Alignment of table cell text. */
|
|
typedef enum {
|
|
align_right,
|
|
align_left,
|
|
} align_t;
|
|
|
|
/**
|
|
* column - Definition of a table column
|
|
* @name: Name of column. A name ending with ':' indicates that it can be
|
|
* followed by arbitrary text (e.g. ATTR:online)
|
|
* @desc: Description of column
|
|
* @align: Alignment of column values.
|
|
* @id: ID of column. This value is passed to get_value_cb_t
|
|
* @def: If set, include column in default table
|
|
*/
|
|
struct column {
|
|
const char *name;
|
|
const char *desc;
|
|
align_t align;
|
|
int id;
|
|
unsigned int def:1;
|
|
};
|
|
|
|
struct util_list;
|
|
|
|
/**
|
|
* table_value_cb_t - Retrieve table cell value
|
|
* @item: Item for which a cell value should be retrieved
|
|
* @id: Column ID of the column to retrieve for the item
|
|
* @heading: The full heading of the column
|
|
* @data: Arbitrary data pointer passed to table_print()
|
|
*
|
|
* This callback function should retrieve the specified table cell value
|
|
* and return it as a newly allocated string to the caller. It may return
|
|
* %NULL if no value of the specified type is defined for the specified item.
|
|
*/
|
|
typedef char *(*table_value_cb_t)(void *item, int id, const char *heading,
|
|
void *data);
|
|
|
|
struct column *table_get_column(struct column *, const char *);
|
|
exit_code_t table_print(struct column *, table_value_cb_t, void *,
|
|
struct util_list *, struct util_list *, int, int, int,
|
|
int, int);
|
|
exit_code_t table_check_columns(struct column *, struct util_list *);
|
|
void table_print_columns(struct column *, struct util_list *, int, int);
|
|
void table_set_default(struct column *, int, int);
|
|
|
|
#endif /* TABLE_H */
|