X-Git-Url: http://git.tuebingen.mpg.de/?a=blobdiff_plain;ds=sidebyside;f=attribute.c;h=51630b257f7d88829c657361b06c1fd09d008326;hb=HEAD;hp=2ea73a6ab41fed2dcd18c8ca077b661e9809a3b7;hpb=7649f22106cec2c6eb8bb10f279401e1af5451d0;p=paraslash.git diff --git a/attribute.c b/attribute.c index 2ea73a6a..51630b25 100644 --- a/attribute.c +++ b/attribute.c @@ -1,8 +1,4 @@ -/* - * Copyright (C) 1997 Andre Noll - * - * Licensed under the GPL v2. For licencing details see COPYING. - */ +/* Copyright (C) 1997 Andre Noll , see file COPYING. */ /** \file attribute.c Attribute handling functions. */ @@ -108,7 +104,7 @@ int get_attribute_bitnum_by_name(const char *att_name, unsigned char *bitnum) return 1; } -/** Data passed to the action function of lsatt */ +/* Data passed to the action function of lsatt */ static int print_attribute(struct osl_table *table, struct osl_row *row, const char *name, void *data) { @@ -123,7 +119,7 @@ static int print_attribute(struct osl_table *table, struct osl_row *row, } ret = osl(osl_get_object(table, row, ATTCOL_BITNUM, &bitnum_obj)); if (ret < 0) { - para_printf(&aca->pbout, "%s: %s\n", name, para_strerror(-ret)); + afs_error(aca, "%s: %s\n", name, para_strerror(-ret)); return ret; } para_printf(&aca->pbout, "%u\t%s\n", *(unsigned char*)bitnum_obj.data, @@ -172,11 +168,6 @@ static int com_lsatt(struct command_context *cc, struct lls_parse_result *lpr) } EXPORT_SERVER_CMD_HANDLER(lsatt); -struct addatt_event_data { - const char *name; - unsigned char bitnum; -}; - static int com_addatt_callback(struct afs_callback_arg *aca) { const struct lls_command *cmd = SERVER_CMD_CMD_PTR(ADDATT); @@ -192,12 +183,10 @@ static int com_addatt_callback(struct afs_callback_arg *aca) struct osl_object objs[NUM_ATT_COLUMNS]; struct osl_row *row; unsigned char bitnum; - struct addatt_event_data aed; len = strlen(name); if (len == 0 || name[len - 1] == '-' || name[len - 1] == '+') { - para_printf(&aca->pbout, - "invalid attribute name: %s\n", name); + afs_error(aca, "invalid attribute name: %s\n", name); continue; } ret = get_attribute_bitnum_by_name(name, &bitnum); @@ -229,17 +218,16 @@ static int com_addatt_callback(struct afs_callback_arg *aca) ret = osl(osl_add_row(attribute_table, objs)); if (ret < 0) goto out; - aed.name = name; - aed.bitnum = bitnum; - ret = afs_event(ATTRIBUTE_ADD, &aca->pbout, &aed); + ret = afs_event(ATTRIBUTE_ADD, &aca->pbout, NULL); if (ret < 0) goto out; greatest_att_bitnum = PARA_MAX(greatest_att_bitnum, (int)bitnum); } out: if (ret < 0) - para_printf(&aca->pbout, "error while adding %s\n", + afs_error(aca, "error while adding %s\n", lls_input(i, aca->lpr)); + lls_free_parse_result(aca->lpr, cmd); return ret; } @@ -280,7 +268,7 @@ static int com_mvatt_callback(struct afs_callback_arg *aca) ret = osl(osl_update_object(attribute_table, row, ATTCOL_NAME, &obj)); out: if (ret < 0) - para_printf(&aca->pbout, "cannot rename %s to %s\n", old, new); + afs_error(aca, "cannot rename %s to %s\n", old, new); else ret = afs_event(ATTRIBUTE_RENAME, &aca->pbout, NULL); lls_free_parse_result(aca->lpr, cmd); @@ -309,13 +297,13 @@ static int remove_attribute(struct osl_table *table, struct osl_row *row, ret = get_attribute_bitnum_by_name(name, &red.bitnum); if (ret < 0) { - para_printf(&aca->pbout, "cannot remove %s\n", name); + afs_error(aca, "cannot remove %s\n", name); return ret; } para_printf(&aca->pbout, "removing attribute %s\n", name); ret = osl(osl_del_row(table, row)); if (ret < 0) { - para_printf(&aca->pbout, "cannot remove %s\n", name); + afs_error(aca, "cannot remove %s\n", name); return ret; } return afs_event(ATTRIBUTE_REMOVE, &aca->pbout, &red); @@ -473,26 +461,12 @@ int attribute_check_callback(struct afs_callback_arg *aca) return aft_check_attributes(att_mask, &aca->pbout); } -/** - * Close the attribute table. - * - * \sa \ref osl_close_table(). - */ static void attribute_close(void) { osl_close_table(attribute_table, OSL_MARK_CLEAN); attribute_table = NULL; } -/** - * Open the attribute table. - * - * \param dir The database directory. - * - * \return Positive on success, negative on errors. - * - * \sa \ref osl_open_table(). - */ static int attribute_open(const char *dir) { int ret; @@ -516,14 +490,9 @@ static int attribute_create(const char *dir) return osl(osl_create_table(&attribute_table_desc)); } -/** - * Initialize the attribute table structure. - * - * \param t The table structure to initialize. - */ -void attribute_init(struct afs_table *t) -{ - t->open = attribute_open; - t->close = attribute_close; - t->create = attribute_create; -} +/** The attribute table stores name/bitnum pairs. */ +const struct afs_table_operations attr_ops = { /* no event handler */ + .open = attribute_open, + .close = attribute_close, + .create = attribute_create, +};