X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=attribute.c;h=acbb8f4d2873ae405a6f091709fdf544709516ee;hp=c4bc0bcaa167d1fca0e302bbdd9331d8add5337c;hb=0a3b9b83;hpb=4a33aa7ad93857d0c6b5ea24983e12b1619b10c0 diff --git a/attribute.c b/attribute.c index c4bc0bca..acbb8f4d 100644 --- a/attribute.c +++ b/attribute.c @@ -168,15 +168,14 @@ static int com_lsatt_callback(const struct osl_object *query, if (!laad.pb.buf) return 0; result->data = laad.pb.buf; - result->size = laad.pb.size; + result->size = laad.pb.offset; return 1; } int com_lsatt(int fd, int argc, char * const * const argv) { unsigned flags = 0; - struct osl_object options = {.data = &flags, .size = sizeof(flags)}, - result; + struct osl_object options = {.data = &flags, .size = sizeof(flags)}; int ret, i; for (i = 1; i < argc; i++) { @@ -201,18 +200,12 @@ int com_lsatt(int fd, int argc, char * const * const argv) } } ret = send_option_arg_callback_request(&options, argc - i, argv + i, - com_lsatt_callback, &result); + com_lsatt_callback, send_result, &fd); if (!ret) { if (argc > 1) ret = send_va_buffer(fd, "no matches\n"); - return ret; - } - if (ret < 0) { + } else if (ret < 0) send_va_buffer(fd, "%s\n", para_strerror(-ret)); - return ret; - } - ret = send_buffer(fd, (char *)result.data); - free(result.data); return ret; } @@ -282,7 +275,7 @@ int com_setatt(__a_unused int fd, int argc, char * const * const argv) if (argc < 3) return -E_ATTR_SYNTAX; return send_standard_callback_request(argc - 1, argv + 1, com_setatt_callback, - NULL); + NULL, NULL); } struct addatt_event_data { @@ -347,27 +340,20 @@ out: if (ret < 0) para_printf(&pb, "%s: %s\n", p, para_strerror(-ret)); result->data = pb.buf; - result->size = pb.size; + result->size = pb.offset; return result->data? 0 : 1; } int com_addatt(int fd, int argc, char * const * const argv) { - struct osl_object result; int ret; if (argc < 2) return -E_ATTR_SYNTAX; ret = send_standard_callback_request(argc - 1, argv + 1, com_addatt_callback, - &result); - if (!ret) - return 1; + send_result, &fd); if (ret < 0) - return ret; - if (!result.data || !result.size) - return 1; - ret = send_va_buffer(fd, "%s", (char *) result.data); - free(result.data); + send_va_buffer(fd, "%s\n", para_strerror(-ret)); return ret; } @@ -396,27 +382,20 @@ out: if (!pb.buf) return 0; result->data = pb.buf; - result->size = pb.size; + result->size = pb.offset; return 1; } int com_mvatt(int fd, int argc, char * const * const argv) { - struct osl_object result; int ret; if (argc != 3) return -E_ATTR_SYNTAX; ret = send_standard_callback_request(argc - 1, argv + 1, com_mvatt_callback, - &result); - if (!ret) - return 1; + send_result, &fd); if (ret < 0) - return ret; - if (!result.data || !result.size) - return 1; - ret = send_va_buffer(fd, "%s", (char *) result.data); - free(result.data); + send_va_buffer(fd, "%s\n", para_strerror(-ret)); return ret; } @@ -473,27 +452,20 @@ static int com_rmatt_callback(const struct osl_object *query, if (!raad.num_removed) para_printf(&raad.pb, "no match -- nothing removed\n"); result->data = raad.pb.buf; - result->size = raad.pb.size; + result->size = raad.pb.offset; return 1; } int com_rmatt(int fd, int argc, char * const * const argv) { int ret; - struct osl_object result; if (argc < 2) return -E_ATTR_SYNTAX; ret = send_standard_callback_request(argc - 1, argv + 1, com_rmatt_callback, - &result); - if (!ret) - return 0; - if (ret < 0) { + send_result, &fd); + if (ret < 0) send_va_buffer(fd, "%s\n", para_strerror(-ret)); - return ret; - } - ret = send_buffer(fd, (char *)result.data); - free(result.data); return ret; }