/*
- * Copyright (C) 1997-2009 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 1997-2011 Andre Noll <maan@systemlinux.org>
*
* Licensed under the GPL v2. For licencing details see COPYING.
*/
/** \file attribute.c Attribute handling functions. */
+#include <regex.h>
#include <openssl/rc4.h>
+#include <osl.h>
#include "para.h"
#include "error.h"
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;
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;
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 == '+')
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;
}
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;
};
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));
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);
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) {
*
* \sa osl_close_table().
*/
-void attribute_close(void)
+static void attribute_close(void)
{
osl_close_table(attribute_table, OSL_MARK_CLEAN);
attribute_table = NULL;
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;
}
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));
}
/**
*/
void attribute_init(struct afs_table *t)
{
- t->name = attribute_table_desc.name;
t->open = attribute_open;
t->close = attribute_close;
t->create = attribute_create;