X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=attribute.c;h=dc375c1d8dc57aea4e5ed06c7bfdf6092fa16880;hp=30c12f1ca133a0caa98ac581ca1fc31aaf5c4909;hb=343a65bc48b4e0cda4d9a14afcd7e96cca9c5de9;hpb=31233289bedbb596b98eadd411bc6aac54d4ed69 diff --git a/attribute.c b/attribute.c index 30c12f1c..dc375c1d 100644 --- a/attribute.c +++ b/attribute.c @@ -5,6 +5,7 @@ */ /** \file attribute.c Attribute handling functions. */ +#include #include "para.h" #include "error.h" #include "string.h" @@ -89,11 +90,11 @@ int get_attribute_bitnum_by_name(const char *att_name, unsigned char *bitnum) struct osl_object obj = {.data = (char *)att_name, .size = strlen(att_name) + 1}; struct osl_row *row; - int ret = osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row); + int ret = osl(osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row)); if (ret < 0) return ret; - ret = osl_get_object(attribute_table, row, ATTCOL_BITNUM, &obj); + ret = osl(osl_get_object(attribute_table, row, ATTCOL_BITNUM, &obj)); if (ret < 0) return ret; *bitnum = *(unsigned char *)obj.data; @@ -131,7 +132,7 @@ static int print_attribute(struct osl_table *table, struct osl_row *row, if (!(laad->flags & LSATT_FLAG_LONG)) return para_printf(&laad->pb, "%s\n", name); - ret = osl_get_object(table, row, ATTCOL_BITNUM, &bitnum_obj); + ret = osl(osl_get_object(table, row, ATTCOL_BITNUM, &bitnum_obj)); if (ret < 0) { para_printf(&laad->pb, "%s: %s\n", name, para_strerror(-ret)); return ret; @@ -230,11 +231,11 @@ static void com_setatt_callback(__a_unused int fd, const struct osl_object *quer p[len - 1] = '\0'; obj.data = p; obj.size = len + 1; - ret = osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row); + ret = osl(osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row)); if (ret < 0) goto out; - ret = osl_get_object(attribute_table, row, ATTCOL_BITNUM, - &obj); + ret = osl(osl_get_object(attribute_table, row, ATTCOL_BITNUM, + &obj)); if (ret < 0) goto out; if (c == '+') @@ -317,15 +318,15 @@ static void com_addatt_callback(int fd, const struct osl_object *query) goto out; continue; } - if (ret != -E_RB_KEY_NOT_FOUND) /* error */ + if (ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) /* error */ goto out; objs[ATTCOL_BITNUM].size = 1; /* find smallest unused attribute */ for (bitnum = 0; bitnum < 64; bitnum++) { objs[ATTCOL_BITNUM].data = &bitnum; - ret = osl_get_row(attribute_table, ATTCOL_BITNUM, - &objs[ATTCOL_BITNUM], &row); - if (ret == -E_RB_KEY_NOT_FOUND) + ret = osl(osl_get_row(attribute_table, ATTCOL_BITNUM, + &objs[ATTCOL_BITNUM], &row)); + if (ret == -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) break; /* this bitnum is unused, use it */ if (ret < 0) /* error */ goto out; @@ -337,7 +338,7 @@ static void com_addatt_callback(int fd, const struct osl_object *query) } objs[ATTCOL_NAME].data = p; objs[ATTCOL_NAME].size = len + 1; - ret = osl_add_row(attribute_table, objs); + ret = osl(osl_add_row(attribute_table, objs)); if (ret < 0) goto out; aed.name = p; @@ -380,12 +381,12 @@ static void com_mvatt_callback(int fd, const struct osl_object *query) }; int ret; - ret = osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row); + ret = osl(osl_get_row(attribute_table, ATTCOL_NAME, &obj, &row)); if (ret < 0) goto out; obj.data = new; obj.size = strlen(new) + 1; - ret = osl_update_object(attribute_table, row, ATTCOL_NAME, &obj); + ret = osl(osl_update_object(attribute_table, row, ATTCOL_NAME, &obj)); out: if (ret < 0) para_printf(&pb, "%s\n", para_strerror(-ret)); @@ -429,7 +430,7 @@ static int remove_attribute(struct osl_table *table, struct osl_row *row, ret = get_attribute_bitnum_by_name(name, &red.bitnum); if (ret < 0) return para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret)); - ret = osl_del_row(table, row); + ret = osl(osl_del_row(table, row)); if (ret < 0) return para_printf(&raad->pb, "%s: %s\n", name, para_strerror(-ret)); ret = para_printf(&raad->pb, "removed attribute %s\n", name); @@ -533,10 +534,10 @@ int get_attribute_text(uint64_t *atts, const char *delim, char **text) if (!(*atts & (one << i))) continue; - ret = osl_get_row(attribute_table, ATTCOL_BITNUM, &obj, &row); + ret = osl(osl_get_row(attribute_table, ATTCOL_BITNUM, &obj, &row)); if (ret < 0) goto err; - ret = osl_get_object(attribute_table, row, ATTCOL_NAME, &obj); + ret = osl(osl_get_object(attribute_table, row, ATTCOL_NAME, &obj)); if (ret < 0) goto err; if (*text) { @@ -579,14 +580,14 @@ static int attribute_open(const char *dir) int ret; attribute_table_desc.dir = dir; - ret = osl_open_table(&attribute_table_desc, &attribute_table); + ret = osl(osl_open_table(&attribute_table_desc, &attribute_table)); greatest_att_bitnum = -1; /* no atts available */ if (ret >= 0) { find_greatest_att_bitnum(); return ret; } attribute_table = NULL; - if (ret >= 0 || is_errno(-ret, ENOENT)) + if (ret >= 0 || ret == -OSL_ERRNO_TO_PARA_ERROR(E_OSL_NOENT)) return 1; return ret; } @@ -594,7 +595,7 @@ static int attribute_open(const char *dir) static int attribute_create(const char *dir) { attribute_table_desc.dir = dir; - return osl_create_table(&attribute_table_desc); + return osl(osl_create_table(&attribute_table_desc)); } /**