Handy macro to reply the right way for an unavailable feature.
While generally used so far in generated code, it can shorten that a
bit, and avoid copy&paste when wanting to do manual feature checking.
---
daemon/daemon.h | 6 ++++++
generator/daemon.ml | 6 +-----
2 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/daemon/daemon.h b/daemon/daemon.h
index 94537b7..fb74e91 100644
--- a/daemon/daemon.h
+++ b/daemon/daemon.h
@@ -245,6 +245,12 @@ extern void reply_with_perror_errno (int err, const char *fs, ...)
__attribute__((format (printf,2,3)));
#define reply_with_error(...) reply_with_error_errno(0, __VA_ARGS__)
#define reply_with_perror(...) reply_with_perror_errno(errno, __VA_ARGS__)
+#define reply_with_unavailable_feature(feature) \
+ reply_with_error_errno (ENOTSUP, \
+ "feature '%s' is not available in this\n" \
+ "build of libguestfs. Read 'AVAILABILITY' in the guestfs(3) man page
for\n" \
+ "how to check for the availability of features.", \
+ feature)
/* daemon functions that receive files (FileIn) should call
* receive_file for each FileIn parameter.
diff --git a/generator/daemon.ml b/generator/daemon.ml
index ca748d2..951729c 100644
--- a/generator/daemon.ml
+++ b/generator/daemon.ml
@@ -280,11 +280,7 @@ cleanup_free_mountable (mountable_t *mountable)
pr " if (! optgroup_%s_available ()) {\n" group;
if is_filein then
pr " cancel_receive ();\n";
- pr " reply_with_error_errno (ENOTSUP,\n";
- pr " \"feature '%%s' is not available in
this\\n\"\n";
- pr " \"build of libguestfs. Read 'AVAILABILITY' in the
guestfs(3) man page for\\n\"\n";
- pr " \"how to check for the availability of
features.\",\n";
- pr " \"%s\");\n" group;
+ pr " reply_with_unavailable_feature (\"%s\");\n" group;
pr " goto done_no_free;\n";
pr " }\n";
pr "\n"
--
1.9.3