From: Ondrej Oprala Date: Thu, 27 Mar 2014 13:04:58 +0000 (+0100) Subject: libsmartcols: add scols_table_is_empty() X-Git-Tag: v2.25-rc1~365 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c0070f8187dd09671317b1462d99311ac582bc90;p=thirdparty%2Futil-linux.git libsmartcols: add scols_table_is_empty() Signed-off-by: Ondrej Oprala --- diff --git a/libsmartcols/docs/libsmartcols-sections.txt b/libsmartcols/docs/libsmartcols-sections.txt index c60d16b641..85a9feb149 100644 --- a/libsmartcols/docs/libsmartcols-sections.txt +++ b/libsmartcols/docs/libsmartcols-sections.txt @@ -92,6 +92,7 @@ scols_table_get_ncols scols_table_get_nlines scols_table_get_stream scols_table_is_ascii +scols_table_is_empty scols_table_is_export scols_table_is_max scols_table_is_no_headings diff --git a/libsmartcols/src/libsmartcols.h.in b/libsmartcols/src/libsmartcols.h.in index e40aad4cde..c8b0966a31 100644 --- a/libsmartcols/src/libsmartcols.h.in +++ b/libsmartcols/src/libsmartcols.h.in @@ -149,6 +149,7 @@ extern int scols_table_colors_wanted(struct libscols_table *tb); extern int scols_table_is_raw(struct libscols_table *tb); extern int scols_table_is_ascii(struct libscols_table *tb); extern int scols_table_is_no_headings(struct libscols_table *tb); +extern int scols_table_is_empty(struct libscols_table *tb); extern int scols_table_is_export(struct libscols_table *tb); extern int scols_table_is_max(struct libscols_table *tb); extern int scols_table_is_tree(struct libscols_table *tb); diff --git a/libsmartcols/src/libsmartcols.sym b/libsmartcols/src/libsmartcols.sym index 90ecd771c4..19c260198e 100644 --- a/libsmartcols/src/libsmartcols.sym +++ b/libsmartcols/src/libsmartcols.sym @@ -68,6 +68,7 @@ global: scols_table_get_nlines; scols_table_get_stream; scols_table_is_ascii; + scols_table_is_empty; scols_table_is_export; scols_table_is_max; scols_table_is_no_headings; diff --git a/libsmartcols/src/table.c b/libsmartcols/src/table.c index d26eee8e61..d05c1435f7 100644 --- a/libsmartcols/src/table.c +++ b/libsmartcols/src/table.c @@ -793,6 +793,17 @@ int scols_table_colors_wanted(struct libscols_table *tb) return -EINVAL; return tb->colors_wanted; } + +/** + * scols_table_is_empty: + * @tb: table + * + * Returns: 1 if empty, 0 if not (or in case of an error). + */ +int scols_table_is_empty(struct libscols_table *tb) +{ + return !tb || !tb->nlines; +} /** * scols_table_is_raw: * @tb: table