Another simple command without options which is easy to convert. The
only thing worth noting is that we now fail the command early if more
than 64 arguments are given when previously we only checked that at
least one argument is given.
H: d: by duration
H: a: by audio format
---
H: d: by duration
H: a: by audio format
---
-N: addatt
-P: AFS_READ | AFS_WRITE
-D: Add new attribute(s).
-U: addatt attribute1...
-H: This adds new attributes to the attribute table. At most 64
-H: attributes may be defined.
----
T: add
N: add@member@
O: int com_add@member@(struct command_context *cc);
T: add
N: add@member@
O: int com_add@member@(struct command_context *cc);
static int com_addatt_callback(struct afs_callback_arg *aca)
{
static int com_addatt_callback(struct afs_callback_arg *aca)
{
- char *p;
- int ret = 1;
+ const struct lls_command *cmd = SERVER_CMD_CMD_PTR(ADDATT);
+ int i, ret = 1;
- for (
- p = aca->query.data;
- p < (char *)aca->query.data + aca->query.size;
- p += len + 1
- ) {
+ ret = lls(lls_deserialize_parse_result(aca->query.data, cmd, &aca->lpr));
+ assert(ret >= 0);
+ num_inputs = lls_num_inputs(aca->lpr);
+ for (i = 0; i < num_inputs; i++) {
+ const char *name = lls_input(i, aca->lpr);
struct osl_object objs[NUM_ATT_COLUMNS];
struct osl_row *row;
unsigned char bitnum;
struct addatt_event_data aed;
struct osl_object objs[NUM_ATT_COLUMNS];
struct osl_row *row;
unsigned char bitnum;
struct addatt_event_data aed;
- len = strlen(p);
- if (!len || p[len - 1] == '-' || p[len - 1] == '+') {
- para_printf(&aca->pbout, "invalid attribute name: %s\n", p);
+ len = strlen(name);
+ if (len == 0 || name[len - 1] == '-' || name[len - 1] == '+') {
+ para_printf(&aca->pbout,
+ "invalid attribute name: %s\n", name);
- ret = get_attribute_bitnum_by_name(p, &bitnum);
+ ret = get_attribute_bitnum_by_name(name, &bitnum);
- para_printf(&aca->pbout, "attribute \"%s\" already exists\n", p);
+ para_printf(&aca->pbout,
+ "attribute \"%s\" already exists\n", name);
continue;
}
if (ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) /* error */
continue;
}
if (ret != -OSL_ERRNO_TO_PARA_ERROR(E_OSL_RB_KEY_NOT_FOUND)) /* error */
ret = -E_ATT_TABLE_FULL;
goto out;
}
ret = -E_ATT_TABLE_FULL;
goto out;
}
- objs[ATTCOL_NAME].data = p;
+ objs[ATTCOL_NAME].data = (char *)name;
objs[ATTCOL_NAME].size = len + 1;
ret = osl(osl_add_row(attribute_table, objs));
if (ret < 0)
goto out;
objs[ATTCOL_NAME].size = len + 1;
ret = osl(osl_add_row(attribute_table, objs));
if (ret < 0)
goto out;
aed.bitnum = bitnum;
ret = afs_event(ATTRIBUTE_ADD, &aca->pbout, &aed);
if (ret < 0)
aed.bitnum = bitnum;
ret = afs_event(ATTRIBUTE_ADD, &aca->pbout, &aed);
if (ret < 0)
- para_printf(&aca->pbout, "%s: %s\n", p, para_strerror(-ret));
+ para_printf(&aca->pbout, "error while adding %s\n",
+ lls_input(i, aca->lpr));
-int com_addatt(struct command_context *cc)
+static int com_addatt(struct command_context *cc, struct lls_parse_result *lpr)
+ const struct lls_command *cmd = SERVER_CMD_CMD_PTR(ADDATT);
+ char *errctx;
+ int ret = lls(lls_check_arg_count(lpr, 1, 64, &errctx));
- if (cc->argc < 2)
- return -E_ATTR_SYNTAX;
- ret = send_standard_callback_request(cc->argc - 1, cc->argv + 1,
- com_addatt_callback, afs_cb_result_handler, cc);
- if (ret < 0)
- send_strerror(cc, -ret);
- return ret;
+ if (ret < 0) {
+ send_errctx(cc, errctx);
+ return ret;
+ }
+ return send_lls_callback_request(com_addatt_callback, cmd, lpr, cc);
+EXPORT_SERVER_CMD_HANDLER(addatt);
static int com_mvatt_callback(struct afs_callback_arg *aca)
{
static int com_mvatt_callback(struct afs_callback_arg *aca)
{
Print what is being done.
[/help]
Print what is being done.
[/help]
+[subcommand addatt]
+ purpose = add new attribute(s)
+ non-opts-name = attribute...
+ aux_info = AFS_READ | AFS_WRITE
+ [description]
+ This adds new attributes to the attribute table. At most 64 attributes
+ may be defined.
+ [/description]
+
[subcommand check]
purpose = run integrity checks on database tables
aux_info = AFS_READ
[subcommand check]
purpose = run integrity checks on database tables
aux_info = AFS_READ