diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2009-06-29 10:09:13 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2009-06-29 10:09:13 +0100 |
commit | f450ce75b754fb869b34433c0126f7bb592b141b (patch) | |
tree | d5871faf1cc109629f7df0b59e1eb1403199ccf4 /src | |
parent | 62ccc07e744d5ebfb45d9344827d36f9f61699f4 (diff) | |
download | libguestfs-f450ce75b754fb869b34433c0126f7bb592b141b.tar.gz libguestfs-f450ce75b754fb869b34433c0126f7bb592b141b.tar.xz libguestfs-f450ce75b754fb869b34433c0126f7bb592b141b.zip |
Generated code for 'wc_*' commands.
Diffstat (limited to 'src')
-rw-r--r-- | src/MAX_PROC_NR | 2 | ||||
-rw-r--r-- | src/guestfs-actions.c | 276 | ||||
-rw-r--r-- | src/guestfs-actions.h | 3 | ||||
-rw-r--r-- | src/guestfs_protocol.c | 60 | ||||
-rw-r--r-- | src/guestfs_protocol.h | 47 | ||||
-rw-r--r-- | src/guestfs_protocol.x | 27 |
6 files changed, 413 insertions, 2 deletions
diff --git a/src/MAX_PROC_NR b/src/MAX_PROC_NR index 5bc6609e..52bd8e43 100644 --- a/src/MAX_PROC_NR +++ b/src/MAX_PROC_NR @@ -1 +1 @@ -117 +120 diff --git a/src/guestfs-actions.c b/src/guestfs-actions.c index 791c3874..ce4cfe1e 100644 --- a/src/guestfs-actions.c +++ b/src/guestfs-actions.c @@ -10713,3 +10713,279 @@ char *guestfs_mkdtemp (guestfs_h *g, return ctx.ret.dir; /* caller will free */ } +struct wc_l_ctx { + /* This flag is set by the callbacks, so we know we've done + * the callbacks as expected, and in the right sequence. + * 0 = not called, 1 = reply_cb called. + */ + int cb_sequence; + struct guestfs_message_header hdr; + struct guestfs_message_error err; + struct guestfs_wc_l_ret ret; +}; + +static void wc_l_reply_cb (guestfs_h *g, void *data, XDR *xdr) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct wc_l_ctx *ctx = (struct wc_l_ctx *) data; + + /* This should definitely not happen. */ + if (ctx->cb_sequence != 0) { + ctx->cb_sequence = 9999; + error (g, "%s: internal error: reply callback called twice", "guestfs_wc_l"); + return; + } + + ml->main_loop_quit (ml, g); + + if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) { + error (g, "%s: failed to parse reply header", "guestfs_wc_l"); + return; + } + if (ctx->hdr.status == GUESTFS_STATUS_ERROR) { + if (!xdr_guestfs_message_error (xdr, &ctx->err)) { + error (g, "%s: failed to parse reply error", "guestfs_wc_l"); + return; + } + goto done; + } + if (!xdr_guestfs_wc_l_ret (xdr, &ctx->ret)) { + error (g, "%s: failed to parse reply", "guestfs_wc_l"); + return; + } + done: + ctx->cb_sequence = 1; +} + +int guestfs_wc_l (guestfs_h *g, + const char *path) +{ + struct guestfs_wc_l_args args; + struct wc_l_ctx ctx; + guestfs_main_loop *ml = guestfs_get_main_loop (g); + int serial; + + if (check_state (g, "guestfs_wc_l") == -1) return -1; + guestfs_set_busy (g); + + memset (&ctx, 0, sizeof ctx); + + args.path = (char *) path; + serial = guestfs__send_sync (g, GUESTFS_PROC_WC_L, + (xdrproc_t) xdr_guestfs_wc_l_args, (char *) &args); + if (serial == -1) { + guestfs_end_busy (g); + return -1; + } + + guestfs__switch_to_receiving (g); + ctx.cb_sequence = 0; + guestfs_set_reply_callback (g, wc_l_reply_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_reply_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1) { + error (g, "%s reply failed, see earlier error messages", "guestfs_wc_l"); + guestfs_end_busy (g); + return -1; + } + + if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_WC_L, serial) == -1) { + guestfs_end_busy (g); + return -1; + } + + if (ctx.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", ctx.err.error_message); + free (ctx.err.error_message); + guestfs_end_busy (g); + return -1; + } + + guestfs_end_busy (g); + return ctx.ret.lines; +} + +struct wc_w_ctx { + /* This flag is set by the callbacks, so we know we've done + * the callbacks as expected, and in the right sequence. + * 0 = not called, 1 = reply_cb called. + */ + int cb_sequence; + struct guestfs_message_header hdr; + struct guestfs_message_error err; + struct guestfs_wc_w_ret ret; +}; + +static void wc_w_reply_cb (guestfs_h *g, void *data, XDR *xdr) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct wc_w_ctx *ctx = (struct wc_w_ctx *) data; + + /* This should definitely not happen. */ + if (ctx->cb_sequence != 0) { + ctx->cb_sequence = 9999; + error (g, "%s: internal error: reply callback called twice", "guestfs_wc_w"); + return; + } + + ml->main_loop_quit (ml, g); + + if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) { + error (g, "%s: failed to parse reply header", "guestfs_wc_w"); + return; + } + if (ctx->hdr.status == GUESTFS_STATUS_ERROR) { + if (!xdr_guestfs_message_error (xdr, &ctx->err)) { + error (g, "%s: failed to parse reply error", "guestfs_wc_w"); + return; + } + goto done; + } + if (!xdr_guestfs_wc_w_ret (xdr, &ctx->ret)) { + error (g, "%s: failed to parse reply", "guestfs_wc_w"); + return; + } + done: + ctx->cb_sequence = 1; +} + +int guestfs_wc_w (guestfs_h *g, + const char *path) +{ + struct guestfs_wc_w_args args; + struct wc_w_ctx ctx; + guestfs_main_loop *ml = guestfs_get_main_loop (g); + int serial; + + if (check_state (g, "guestfs_wc_w") == -1) return -1; + guestfs_set_busy (g); + + memset (&ctx, 0, sizeof ctx); + + args.path = (char *) path; + serial = guestfs__send_sync (g, GUESTFS_PROC_WC_W, + (xdrproc_t) xdr_guestfs_wc_w_args, (char *) &args); + if (serial == -1) { + guestfs_end_busy (g); + return -1; + } + + guestfs__switch_to_receiving (g); + ctx.cb_sequence = 0; + guestfs_set_reply_callback (g, wc_w_reply_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_reply_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1) { + error (g, "%s reply failed, see earlier error messages", "guestfs_wc_w"); + guestfs_end_busy (g); + return -1; + } + + if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_WC_W, serial) == -1) { + guestfs_end_busy (g); + return -1; + } + + if (ctx.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", ctx.err.error_message); + free (ctx.err.error_message); + guestfs_end_busy (g); + return -1; + } + + guestfs_end_busy (g); + return ctx.ret.words; +} + +struct wc_c_ctx { + /* This flag is set by the callbacks, so we know we've done + * the callbacks as expected, and in the right sequence. + * 0 = not called, 1 = reply_cb called. + */ + int cb_sequence; + struct guestfs_message_header hdr; + struct guestfs_message_error err; + struct guestfs_wc_c_ret ret; +}; + +static void wc_c_reply_cb (guestfs_h *g, void *data, XDR *xdr) +{ + guestfs_main_loop *ml = guestfs_get_main_loop (g); + struct wc_c_ctx *ctx = (struct wc_c_ctx *) data; + + /* This should definitely not happen. */ + if (ctx->cb_sequence != 0) { + ctx->cb_sequence = 9999; + error (g, "%s: internal error: reply callback called twice", "guestfs_wc_c"); + return; + } + + ml->main_loop_quit (ml, g); + + if (!xdr_guestfs_message_header (xdr, &ctx->hdr)) { + error (g, "%s: failed to parse reply header", "guestfs_wc_c"); + return; + } + if (ctx->hdr.status == GUESTFS_STATUS_ERROR) { + if (!xdr_guestfs_message_error (xdr, &ctx->err)) { + error (g, "%s: failed to parse reply error", "guestfs_wc_c"); + return; + } + goto done; + } + if (!xdr_guestfs_wc_c_ret (xdr, &ctx->ret)) { + error (g, "%s: failed to parse reply", "guestfs_wc_c"); + return; + } + done: + ctx->cb_sequence = 1; +} + +int guestfs_wc_c (guestfs_h *g, + const char *path) +{ + struct guestfs_wc_c_args args; + struct wc_c_ctx ctx; + guestfs_main_loop *ml = guestfs_get_main_loop (g); + int serial; + + if (check_state (g, "guestfs_wc_c") == -1) return -1; + guestfs_set_busy (g); + + memset (&ctx, 0, sizeof ctx); + + args.path = (char *) path; + serial = guestfs__send_sync (g, GUESTFS_PROC_WC_C, + (xdrproc_t) xdr_guestfs_wc_c_args, (char *) &args); + if (serial == -1) { + guestfs_end_busy (g); + return -1; + } + + guestfs__switch_to_receiving (g); + ctx.cb_sequence = 0; + guestfs_set_reply_callback (g, wc_c_reply_cb, &ctx); + (void) ml->main_loop_run (ml, g); + guestfs_set_reply_callback (g, NULL, NULL); + if (ctx.cb_sequence != 1) { + error (g, "%s reply failed, see earlier error messages", "guestfs_wc_c"); + guestfs_end_busy (g); + return -1; + } + + if (check_reply_header (g, &ctx.hdr, GUESTFS_PROC_WC_C, serial) == -1) { + guestfs_end_busy (g); + return -1; + } + + if (ctx.hdr.status == GUESTFS_STATUS_ERROR) { + error (g, "%s", ctx.err.error_message); + free (ctx.err.error_message); + guestfs_end_busy (g); + return -1; + } + + guestfs_end_busy (g); + return ctx.ret.chars; +} + diff --git a/src/guestfs-actions.h b/src/guestfs-actions.h index d2f026c1..cbdf0fbf 100644 --- a/src/guestfs-actions.h +++ b/src/guestfs-actions.h @@ -188,3 +188,6 @@ extern int guestfs_scrub_device (guestfs_h *handle, const char *device); extern int guestfs_scrub_file (guestfs_h *handle, const char *file); extern int guestfs_scrub_freespace (guestfs_h *handle, const char *dir); extern char *guestfs_mkdtemp (guestfs_h *handle, const char *template); +extern int guestfs_wc_l (guestfs_h *handle, const char *path); +extern int guestfs_wc_w (guestfs_h *handle, const char *path); +extern int guestfs_wc_c (guestfs_h *handle, const char *path); diff --git a/src/guestfs_protocol.c b/src/guestfs_protocol.c index e8aea4bf..bdcc2042 100644 --- a/src/guestfs_protocol.c +++ b/src/guestfs_protocol.c @@ -1983,6 +1983,66 @@ xdr_guestfs_mkdtemp_ret (XDR *xdrs, guestfs_mkdtemp_ret *objp) } bool_t +xdr_guestfs_wc_l_args (XDR *xdrs, guestfs_wc_l_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->path, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_guestfs_wc_l_ret (XDR *xdrs, guestfs_wc_l_ret *objp) +{ + register int32_t *buf; + + if (!xdr_int (xdrs, &objp->lines)) + return FALSE; + return TRUE; +} + +bool_t +xdr_guestfs_wc_w_args (XDR *xdrs, guestfs_wc_w_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->path, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_guestfs_wc_w_ret (XDR *xdrs, guestfs_wc_w_ret *objp) +{ + register int32_t *buf; + + if (!xdr_int (xdrs, &objp->words)) + return FALSE; + return TRUE; +} + +bool_t +xdr_guestfs_wc_c_args (XDR *xdrs, guestfs_wc_c_args *objp) +{ + register int32_t *buf; + + if (!xdr_string (xdrs, &objp->path, ~0)) + return FALSE; + return TRUE; +} + +bool_t +xdr_guestfs_wc_c_ret (XDR *xdrs, guestfs_wc_c_ret *objp) +{ + register int32_t *buf; + + if (!xdr_int (xdrs, &objp->chars)) + return FALSE; + return TRUE; +} + +bool_t xdr_guestfs_procedure (XDR *xdrs, guestfs_procedure *objp) { register int32_t *buf; diff --git a/src/guestfs_protocol.h b/src/guestfs_protocol.h index df91dd40..0c31e79e 100644 --- a/src/guestfs_protocol.h +++ b/src/guestfs_protocol.h @@ -1007,6 +1007,36 @@ struct guestfs_mkdtemp_ret { }; typedef struct guestfs_mkdtemp_ret guestfs_mkdtemp_ret; +struct guestfs_wc_l_args { + char *path; +}; +typedef struct guestfs_wc_l_args guestfs_wc_l_args; + +struct guestfs_wc_l_ret { + int lines; +}; +typedef struct guestfs_wc_l_ret guestfs_wc_l_ret; + +struct guestfs_wc_w_args { + char *path; +}; +typedef struct guestfs_wc_w_args guestfs_wc_w_args; + +struct guestfs_wc_w_ret { + int words; +}; +typedef struct guestfs_wc_w_ret guestfs_wc_w_ret; + +struct guestfs_wc_c_args { + char *path; +}; +typedef struct guestfs_wc_c_args guestfs_wc_c_args; + +struct guestfs_wc_c_ret { + int chars; +}; +typedef struct guestfs_wc_c_ret guestfs_wc_c_ret; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -1125,7 +1155,10 @@ enum guestfs_procedure { GUESTFS_PROC_SCRUB_FILE = 115, GUESTFS_PROC_SCRUB_FREESPACE = 116, GUESTFS_PROC_MKDTEMP = 117, - GUESTFS_PROC_NR_PROCS = 117 + 1, + GUESTFS_PROC_WC_L = 118, + GUESTFS_PROC_WC_W = 119, + GUESTFS_PROC_WC_C = 120, + GUESTFS_PROC_NR_PROCS = 120 + 1, }; typedef enum guestfs_procedure guestfs_procedure; #define GUESTFS_MESSAGE_MAX 4194304 @@ -1337,6 +1370,12 @@ extern bool_t xdr_guestfs_scrub_file_args (XDR *, guestfs_scrub_file_args*); extern bool_t xdr_guestfs_scrub_freespace_args (XDR *, guestfs_scrub_freespace_args*); extern bool_t xdr_guestfs_mkdtemp_args (XDR *, guestfs_mkdtemp_args*); extern bool_t xdr_guestfs_mkdtemp_ret (XDR *, guestfs_mkdtemp_ret*); +extern bool_t xdr_guestfs_wc_l_args (XDR *, guestfs_wc_l_args*); +extern bool_t xdr_guestfs_wc_l_ret (XDR *, guestfs_wc_l_ret*); +extern bool_t xdr_guestfs_wc_w_args (XDR *, guestfs_wc_w_args*); +extern bool_t xdr_guestfs_wc_w_ret (XDR *, guestfs_wc_w_ret*); +extern bool_t xdr_guestfs_wc_c_args (XDR *, guestfs_wc_c_args*); +extern bool_t xdr_guestfs_wc_c_ret (XDR *, guestfs_wc_c_ret*); extern bool_t xdr_guestfs_procedure (XDR *, guestfs_procedure*); extern bool_t xdr_guestfs_message_direction (XDR *, guestfs_message_direction*); extern bool_t xdr_guestfs_message_status (XDR *, guestfs_message_status*); @@ -1507,6 +1546,12 @@ extern bool_t xdr_guestfs_scrub_file_args (); extern bool_t xdr_guestfs_scrub_freespace_args (); extern bool_t xdr_guestfs_mkdtemp_args (); extern bool_t xdr_guestfs_mkdtemp_ret (); +extern bool_t xdr_guestfs_wc_l_args (); +extern bool_t xdr_guestfs_wc_l_ret (); +extern bool_t xdr_guestfs_wc_w_args (); +extern bool_t xdr_guestfs_wc_w_ret (); +extern bool_t xdr_guestfs_wc_c_args (); +extern bool_t xdr_guestfs_wc_c_ret (); extern bool_t xdr_guestfs_procedure (); extern bool_t xdr_guestfs_message_direction (); extern bool_t xdr_guestfs_message_status (); diff --git a/src/guestfs_protocol.x b/src/guestfs_protocol.x index 13dbb532..e0f106c0 100644 --- a/src/guestfs_protocol.x +++ b/src/guestfs_protocol.x @@ -776,6 +776,30 @@ struct guestfs_mkdtemp_ret { string dir<>; }; +struct guestfs_wc_l_args { + string path<>; +}; + +struct guestfs_wc_l_ret { + int lines; +}; + +struct guestfs_wc_w_args { + string path<>; +}; + +struct guestfs_wc_w_ret { + int words; +}; + +struct guestfs_wc_c_args { + string path<>; +}; + +struct guestfs_wc_c_ret { + int chars; +}; + enum guestfs_procedure { GUESTFS_PROC_MOUNT = 1, GUESTFS_PROC_SYNC = 2, @@ -894,6 +918,9 @@ enum guestfs_procedure { GUESTFS_PROC_SCRUB_FILE = 115, GUESTFS_PROC_SCRUB_FREESPACE = 116, GUESTFS_PROC_MKDTEMP = 117, + GUESTFS_PROC_WC_L = 118, + GUESTFS_PROC_WC_W = 119, + GUESTFS_PROC_WC_C = 120, GUESTFS_PROC_NR_PROCS }; |