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;
size_t len;
+ unsigned num_inputs;
- 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;
- 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);
continue;
}
- ret = get_attribute_bitnum_by_name(p, &bitnum);
+ ret = get_attribute_bitnum_by_name(name, &bitnum);
if (ret >= 0) {
- 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 */
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;
- aed.name = p;
+ aed.name = name;
aed.bitnum = bitnum;
ret = afs_event(ATTRIBUTE_ADD, &aca->pbout, &aed);
if (ret < 0)
}
out:
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));
return ret;
}
-int com_addatt(struct command_context *cc)
+static int com_addatt(struct command_context *cc, struct lls_parse_result *lpr)
{
- int ret;
+ 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)
{