>From 21434b17986fe45950bb9cac1bb546ea3cd95de7 Mon Sep 17 00:00:00 2001 From: Richard W.M. Jones Date: Fri, 1 Apr 2011 12:17:22 +0100 Subject: [PATCH 2/4] Shared function to send progress messages. This is just code motion. --- src/guestfs-internal.h | 4 +++- src/proto.c | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/guestfs-internal.h b/src/guestfs-internal.h index b5f50c9..2729097 100644 --- a/src/guestfs-internal.h +++ b/src/guestfs-internal.h @@ -1,5 +1,5 @@ /* libguestfs - * Copyright (C) 2009-2010 Red Hat Inc. + * Copyright (C) 2009-2011 Red Hat Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -266,6 +266,7 @@ struct inspect_fstab_entry { struct guestfs_message_header; struct guestfs_message_error; +struct guestfs_progress; extern void guestfs_error (guestfs_h *g, const char *fs, ...) __attribute__((format (printf,2,3))); @@ -299,6 +300,7 @@ extern int guestfs___recv_file (guestfs_h *g, const char *filename); extern int guestfs___send_to_daemon (guestfs_h *g, const void *v_buf, size_t n); extern int guestfs___recv_from_daemon (guestfs_h *g, uint32_t *size_rtn, void **buf_rtn); extern int guestfs___accept_from_daemon (guestfs_h *g); +extern void guestfs___progress_message_callback (guestfs_h *g, const struct guestfs_progress *message); extern int guestfs___build_appliance (guestfs_h *g, char **kernel, char **initrd, char **appliance); extern void guestfs___print_BufferIn (FILE *out, const char *buf, size_t buf_size); extern void guestfs___print_BufferOut (FILE *out, const char *buf, size_t buf_size); diff --git a/src/proto.c b/src/proto.c index cda731e..39f30ae 100644 --- a/src/proto.c +++ b/src/proto.c @@ -326,8 +326,10 @@ really_read_from_socket (guestfs_h *g, int sock, char *buf, size_t n) return (ssize_t) got; } -static void -send_progress_message (guestfs_h *g, const guestfs_progress *message) +/* Convenient wrapper to generate a progress message callback. */ +void +guestfs___progress_message_callback (guestfs_h *g, + const guestfs_progress *message) { uint64_t array[4]; @@ -384,7 +386,7 @@ check_for_daemon_cancellation_or_eof (guestfs_h *g, int fd) xdr_guestfs_progress (&xdr, &message); xdr_destroy (&xdr); - send_progress_message (g, &message); + guestfs___progress_message_callback (g, &message); } return 0; @@ -674,7 +676,7 @@ guestfs___recv_from_daemon (guestfs_h *g, uint32_t *size_rtn, void **buf_rtn) xdr_guestfs_progress (&xdr, &message); xdr_destroy (&xdr); - send_progress_message (g, &message); + guestfs___progress_message_callback (g, &message); } free (*buf_rtn); -- 1.7.4.1