*/
int scols_cell_set_data(struct libscols_cell *ce, const char *data)
{
+ if (!ce)
+ return -EINVAL;
+
return strdup_to_struct_member(ce, data, data);
}
*/
void *scols_cell_get_userdata(struct libscols_cell *ce)
{
- return ce->userdata;
+ return ce ? ce->userdata : NULL;
}
/**
*/
int scols_cell_set_color(struct libscols_cell *ce, const char *color)
{
+ if (!ce)
+ return -EINVAL;
+
if (color && !color_is_sequence(color)) {
char *seq = color_get_sequence(color);
if (!seq)
*/
const char *scols_cell_get_color(const struct libscols_cell *ce)
{
+ if (!ce)
+ return NULL;
+
return ce->color;
}
*/
int scols_cell_get_flags(const struct libscols_cell *ce)
{
- return ce->flags;
+ return ce ? ce->flags : 0;
}
/**
*/
int scols_cell_get_alignment(const struct libscols_cell *ce)
{
- if (ce->flags & SCOLS_CELL_FL_RIGHT)
+ int flags = scols_cell_get_flags(ce);
+
+ if (flags & SCOLS_CELL_FL_RIGHT)
return SCOLS_CELL_FL_RIGHT;
- if (ce->flags & SCOLS_CELL_FL_CENTER)
+ if (flags & SCOLS_CELL_FL_CENTER)
return SCOLS_CELL_FL_CENTER;
return SCOLS_CELL_FL_LEFT; /* default */
{
int rc;
+ if (!dest || !src)
+ return -EINVAL;
+
rc = scols_cell_set_data(dest, scols_cell_get_data(src));
if (!rc)
rc = scols_cell_set_color(dest, scols_cell_get_color(src));