*/
void *scols_cell_get_userdata(struct libscols_cell *ce)
{
- return ce ? ce->userdata : NULL;
+ return ce->userdata;
}
/**
*/
const char *scols_cell_get_color(const struct libscols_cell *ce)
{
- return ce ? ce->color : NULL;
+ return ce->color;
}
/**
* scols_cell_get_flags:
* @ce: a pointer to a struct libscols_cell instance
*
- * Returns: the current flags or -1 in case of an error.
+ * Returns: the current flags
*/
int scols_cell_get_flags(const struct libscols_cell *ce)
{
- return ce ? ce->flags : -1;
+ return ce->flags;
}
/**
*/
double scols_column_get_whint(struct libscols_column *cl)
{
- assert(cl);
- return cl ? cl->width_hint : -EINVAL;
+ return cl->width_hint;
}
/**
*/
int scols_column_get_flags(struct libscols_column *cl)
{
- assert(cl);
- return cl ? cl->flags : -EINVAL;
+ return cl->flags;
}
/**
*/
struct libscols_cell *scols_column_get_header(struct libscols_column *cl)
{
- return cl ? &cl->header : NULL;
+ return &cl->header;
}
/**
*/
const char *scols_column_get_color(struct libscols_column *cl)
{
- assert(cl);
- return cl ? cl->color : NULL;
+ return cl->color;
}
*
* Gets the value of @cl's flag hidden.
*
- * Returns: hidden flag value, negative value in case of an error.
+ * Returns: 0 or 1
*
* Since: 2.27
*/
int scols_column_is_hidden(struct libscols_column *cl)
{
- if (!cl)
- return -EINVAL;
- return cl->flags & SCOLS_FL_HIDDEN;
+ return cl->flags & SCOLS_FL_HIDDEN ? 1 : 0;
}
/**
*
* Gets the value of @cl's flag trunc.
*
- * Returns: trunc flag value, negative value in case of an error.
+ * Returns: 0 or 1
*/
int scols_column_is_trunc(struct libscols_column *cl)
{
- if (!cl)
- return -EINVAL;
- return cl->flags & SCOLS_FL_TRUNC;
+ return cl->flags & SCOLS_FL_TRUNC ? 1 : 0;
}
/**
* scols_column_is_tree:
*
* Gets the value of @cl's flag tree.
*
- * Returns: tree flag value, negative value in case of an error.
+ * Returns: 0 or 1
*/
int scols_column_is_tree(struct libscols_column *cl)
{
- if (!cl)
- return -EINVAL;
- return cl->flags & SCOLS_FL_TREE;
+ return cl->flags & SCOLS_FL_TREE ? 1 : 0;
}
/**
* scols_column_is_right:
*
* Gets the value of @cl's flag right.
*
- * Returns: right flag value, negative value in case of an error.
+ * Returns: 0 or 1
*/
int scols_column_is_right(struct libscols_column *cl)
{
- if (!cl)
- return -EINVAL;
- return cl->flags & SCOLS_FL_RIGHT;
+ return cl->flags & SCOLS_FL_RIGHT ? 1 : 0;
}
/**
* scols_column_is_strict_width:
*
* Gets the value of @cl's flag strict_width.
*
- * Returns: strict_width flag value, negative value in case of an error.
+ * Returns: 0 or 1
*/
int scols_column_is_strict_width(struct libscols_column *cl)
{
- if (!cl)
- return -EINVAL;
- return cl->flags & SCOLS_FL_STRICTWIDTH;
+ return cl->flags & SCOLS_FL_STRICTWIDTH ? 1 : 0;
}
/**
* scols_column_is_noextremes:
*
* Gets the value of @cl's flag no_extremes.
*
- * Returns: no_extremes flag value, negative value in case of an error.
+ * Returns: 0 or 1
*/
int scols_column_is_noextremes(struct libscols_column *cl)
{
- if (!cl)
- return -EINVAL;
- return cl->flags & SCOLS_FL_NOEXTREMES;
+ return cl->flags & SCOLS_FL_NOEXTREMES ? 1 : 0;
}
/**
* scols_column_is_wrap:
*
* Gets the value of @cl's flag wrap.
*
- * Returns: wrap flag value, negative value in case of an error.
+ * Returns: 0 or 1
*
* Since: 2.28
*/
int scols_column_is_wrap(struct libscols_column *cl)
{
- if (!cl)
- return -EINVAL;
- return cl->flags & SCOLS_FL_WRAP;
+ return cl->flags & SCOLS_FL_WRAP ? 1 : 0;
}
/**
* scols_column_is_wrapnl:
*
* Gets the value of @cl's flag wrap.
*
- * Returns: wrapnl flag value, negative value in case of an error.
+ * Returns: 0 or 1
*
* Since: 2.29
*/
int scols_column_is_wrapnl(struct libscols_column *cl)
{
- if (!cl)
- return -EINVAL;
- return cl->flags & SCOLS_FL_WRAPNL;
+ return cl->flags & SCOLS_FL_WRAPNL ? 1 : 0;
}
extern int scols_table_next_column(struct libscols_table *tb, struct libscols_iter *itr, struct libscols_column **cl);
extern char *scols_table_get_column_separator(struct libscols_table *tb);
extern char *scols_table_get_line_separator(struct libscols_table *tb);
-extern int scols_table_get_ncols(struct libscols_table *tb);
-extern int scols_table_get_nlines(struct libscols_table *tb);
+extern size_t scols_table_get_ncols(struct libscols_table *tb);
+extern size_t scols_table_get_nlines(struct libscols_table *tb);
extern struct libscols_column *scols_table_get_column(struct libscols_table *tb, size_t n);
extern int scols_table_add_line(struct libscols_table *tb, struct libscols_line *ln);
extern int scols_table_remove_line(struct libscols_table *tb, struct libscols_line *ln);
* scols_line_get_userdata:
* @ln: a pointer to a struct libscols_line instance
*
- * Returns: 0, a negative value in case of an error.
+ * Returns: user data
*/
void *scols_line_get_userdata(struct libscols_line *ln)
{
- assert(ln);
- return ln ? ln->userdata : NULL;
+ return ln->userdata;
}
/**
*/
const char *scols_line_get_color(struct libscols_line *ln)
{
- return ln ? ln->color : NULL;
+ return ln->color;
}
/**
* scols_line_get_ncells:
* @ln: a pointer to a struct libscols_line instance
*
- * Returns: @ln's number of cells
+ * Returns: @ln's number of cells or a negative value in case of an error.
*/
size_t scols_line_get_ncells(struct libscols_line *ln)
{
- return ln ? ln->ncells : 0;
+ return ln->ncells;
}
/**
* scols_table_get_ncols:
* @tb: table
*
- * Returns: the ncols table member, a negative number in case of an error.
+ * Returns: the ncols table member
*/
-int scols_table_get_ncols(struct libscols_table *tb)
+size_t scols_table_get_ncols(struct libscols_table *tb)
{
- return tb ? (int)tb->ncols : -EINVAL;
+ return tb->ncols;
}
/**
*
* Returns: the nlines table member, a negative number in case of an error.
*/
-int scols_table_get_nlines(struct libscols_table *tb)
+size_t scols_table_get_nlines(struct libscols_table *tb)
{
- return tb ? (int)tb->nlines : -EINVAL;
+ return tb->nlines;
}
/**
*/
FILE *scols_table_get_stream(struct libscols_table *tb)
{
- return tb ? tb->out: NULL;
+ return tb->out;
}
/**
*/
void scols_table_remove_lines(struct libscols_table *tb)
{
- assert(tb);
if (!tb)
return;
*/
int scols_table_colors_wanted(struct libscols_table *tb)
{
- return tb && tb->colors_wanted;
+ return tb->colors_wanted;
}
/**
*/
int scols_table_is_empty(struct libscols_table *tb)
{
- return !tb || !tb->nlines;
+ return !tb->nlines;
}
/**
*/
int scols_table_is_ascii(struct libscols_table *tb)
{
- return tb && tb->ascii;
+ return tb->ascii;
}
/**
*/
int scols_table_is_noheadings(struct libscols_table *tb)
{
- return tb && tb->no_headings;
+ return tb->no_headings;
}
/**
*/
int scols_table_is_export(struct libscols_table *tb)
{
- return tb && tb->format == SCOLS_FMT_EXPORT;
+ return tb->format == SCOLS_FMT_EXPORT;
}
/**
*/
int scols_table_is_raw(struct libscols_table *tb)
{
- return tb && tb->format == SCOLS_FMT_RAW;
+ return tb->format == SCOLS_FMT_RAW;
}
/**
*/
int scols_table_is_json(struct libscols_table *tb)
{
- return tb && tb->format == SCOLS_FMT_JSON;
+ return tb->format == SCOLS_FMT_JSON;
}
* scols_table_is_maxout
* @tb: table
*
- * Returns: 1 if output maximization is enabled, negative value in case of an error.
+ * Returns: 1 if output maximization is enabled or 0
*/
int scols_table_is_maxout(struct libscols_table *tb)
{
- return tb && tb->maxout;
+ return tb->maxout;
}
/**
*/
int scols_table_is_tree(struct libscols_table *tb)
{
- return tb && tb->ntreecols > 0;
+ return tb->ntreecols > 0;
}
/**
*/
char *scols_table_get_column_separator(struct libscols_table *tb)
{
- if (!tb)
- return NULL;
return tb->colsep;
}
*/
char *scols_table_get_line_separator(struct libscols_table *tb)
{
- if (!tb)
- return NULL;
return tb->linesep;
}