availability: Add guestfs_available.
Start a new API allowing groups of functions to be tested for
availability.
There are two reasons for this:
(1) If libguestfs is built with missing dependencies (eg. no Augeas lib)
then the corresponding functions are disabled in the appliance. Up till
now there has been no way to test for this except to speculatively
issue commands and check for errors.
(2) When we port the daemon to Win32 it is likely that major pieces of
functionality won't be available (eg. LVM support). This API gives
a way to test for that.
There is no change for existing clients: you still have to check for
errors from individual API calls.
For new clients, you will be able to test for availability of particular
APIs.
Usage scenario (A): An LVM editing tool which requires
both the LVM API and inotify in order to function at all:
char *apis[] = { "inotify", "lvm2", NULL };
r = guestfs_available (g, apis);
if (r == -1) {
/* print an error and exit */
}
Usage scenario (B): A general purpose tool which optionally provides
configuration file editing, but this can be disabled, the result
merely being reduced functionality:
char *apis[] = { "augeas", NULL };
r = guestfs_available (g, apis);
enable_config_edit_menus = r == 0;