diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-03-10 12:32:22 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-03-15 12:16:50 +0000 |
commit | 4e0cf4dbf8a8a96288f70114fdc3939da0aa7ad1 (patch) | |
tree | 2418e32479a965eb392d08f2e648c53714118a91 /fish | |
parent | 6d6b7edd1102f8383643866bf358e494e0d518ef (diff) | |
download | libguestfs-4e0cf4dbf8a8a96288f70114fdc3939da0aa7ad1.tar.gz libguestfs-4e0cf4dbf8a8a96288f70114fdc3939da0aa7ad1.tar.xz libguestfs-4e0cf4dbf8a8a96288f70114fdc3939da0aa7ad1.zip |
New event API (RHBZ#664558).
This API allows more than one callback to be registered for each
event, makes it possible to call the API from other languages, and
allows [nearly all] log, debug and trace messages to be rerouted from
stderr.
An older version of this API was discussed on the mailing list here:
https://www.redhat.com/archives/libguestfs/2010-December/msg00081.html
https://www.redhat.com/archives/libguestfs/2011-January/msg00012.html
This also updates guestfish to use the new API for its progress bars.
Diffstat (limited to 'fish')
-rw-r--r-- | fish/fish.c | 3 | ||||
-rw-r--r-- | fish/fish.h | 2 | ||||
-rw-r--r-- | fish/progress.c | 13 | ||||
-rw-r--r-- | fish/reopen.c | 3 |
4 files changed, 16 insertions, 5 deletions
diff --git a/fish/fish.c b/fish/fish.c index b62c0988..3ed200c8 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -499,7 +499,8 @@ main (int argc, char *argv[]) : (optind >= argc && isatty (0)); if (progress_bars) - guestfs_set_progress_callback (g, progress_callback, NULL); + guestfs_set_event_callback (g, progress_callback, + GUESTFS_EVENT_PROGRESS, 0, NULL); /* Interactive, shell script, or command(s) on the command line? */ if (optind >= argc) { diff --git a/fish/fish.h b/fish/fish.h index da0c6a73..114e8a87 100644 --- a/fish/fish.h +++ b/fish/fish.h @@ -146,7 +146,7 @@ extern int vg_lv_parse (const char *device, char **vg, char **lv); /* in progress.c */ extern void reset_progress_bar (void); -extern void progress_callback (guestfs_h *g, void *data, int proc_nr, int serial, uint64_t position, uint64_t total); +extern void progress_callback (guestfs_h *g, void *data, uint64_t event, int event_handle, int flags, const char *buf, size_t buf_len, const uint64_t *array, size_t array_len); /* in rc.c (remote control) */ extern void rc_listen (void) __attribute__((noreturn)); diff --git a/fish/progress.c b/fish/progress.c index 27dfbece..6a89ae00 100644 --- a/fish/progress.c +++ b/fish/progress.c @@ -167,9 +167,18 @@ estimate_remaining_time (double ratio) /* Callback which displays a progress bar. */ void progress_callback (guestfs_h *g, void *data, - int proc_nr, int serial, - uint64_t position, uint64_t total) + uint64_t event, int event_handle, int flags, + const char *buf, size_t buf_len, + const uint64_t *array, size_t array_len) { + if (array_len < 4) + return; + + /*uint64_t proc_nr = array[0];*/ + /*uint64_t serial = array[1];*/ + uint64_t position = array[2]; + uint64_t total = array[3]; + if (have_terminfo == 0) { dumb: printf ("%" PRIu64 "/%" PRIu64 "\n", position, total); diff --git a/fish/reopen.c b/fish/reopen.c index b0769826..67a845ce 100644 --- a/fish/reopen.c +++ b/fish/reopen.c @@ -67,7 +67,8 @@ run_reopen (const char *cmd, size_t argc, char *argv[]) guestfs_set_path (g2, p); if (progress_bars) - guestfs_set_progress_callback (g2, progress_callback, NULL); + guestfs_set_event_callback (g2, progress_callback, + GUESTFS_EVENT_PROGRESS, 0, NULL); /* Close the original handle. */ guestfs_close (g); |