Lots more auto-generation.
[libguestfs.git] / src / guestfs-actions.c
1 /* libguestfs generated file
2  * WARNING: THIS FILE IS GENERATED BY 'src/generator.ml'.
3  * ANY CHANGES YOU MAKE TO THIS FILE WILL BE LOST.
4  *
5  * Copyright (C) 2009 Red Hat Inc.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with this library; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 struct mount_rv {
23   int err_code; /* 0 or -1 */
24   char err_str[256];
25 };
26
27 static void mount_cb (guestfs_h *g, void *data, XDR *xdr)
28 {
29   struct mount_rv *rv = (struct mount_rv *) data;
30
31   /* XXX */ rv.code = 0;
32   main_loop.main_loop_quit (g);
33 }
34
35 int guestfs_mount (guestfs_h *g,
36                 const char *device,
37                 const char *mountpoint)
38 {
39   struct guestfs_mount_args args;
40   struct mount_rv rv;
41
42   if (g->state != READY) {
43     error (g, "guestfs_mount called from the wrong state, %d != READY",
44       g->state);
45     return -1;
46   }
47
48   args.device = (char *) device;
49   args.mountpoint = (char *) mountpoint;
50   if (dispatch (g, (xdrproc_t) xdr_guestfs_mount_args, (char *) &args) == -1)
51     return -1;
52
53   rv.err_code = 42;
54   g->reply_cb_internal = mount_cb;
55   g->reply_cb_internal_data = &rv;
56   main_loop.main_loop_run (g);
57   g->reply_cb_internal = NULL;
58   g->reply_cb_internal_data = NULL;
59   if (rv.err_code == 42) { /* callback wasn't called */
60     error (g, "guestfs_mount failed, see earlier error messages");
61     return -1;
62   }
63   else if (rv.err_code == -1) { /* error from remote end */
64     error (g, "%s", rv.err_str);
65     return -1;
66   }
67
68   return 0;
69 }
70
71 struct sync_rv {
72   int err_code; /* 0 or -1 */
73   char err_str[256];
74 };
75
76 static void sync_cb (guestfs_h *g, void *data, XDR *xdr)
77 {
78   struct sync_rv *rv = (struct sync_rv *) data;
79
80   /* XXX */ rv.code = 0;
81   main_loop.main_loop_quit (g);
82 }
83
84 int guestfs_sync (guestfs_h *g)
85 {
86   struct sync_rv rv;
87
88   if (g->state != READY) {
89     error (g, "guestfs_sync called from the wrong state, %d != READY",
90       g->state);
91     return -1;
92   }
93   rv.err_code = 42;
94   g->reply_cb_internal = sync_cb;
95   g->reply_cb_internal_data = &rv;
96   main_loop.main_loop_run (g);
97   g->reply_cb_internal = NULL;
98   g->reply_cb_internal_data = NULL;
99   if (rv.err_code == 42) { /* callback wasn't called */
100     error (g, "guestfs_sync failed, see earlier error messages");
101     return -1;
102   }
103   else if (rv.err_code == -1) { /* error from remote end */
104     error (g, "%s", rv.err_str);
105     return -1;
106   }
107
108   return 0;
109 }
110
111 struct touch_rv {
112   int err_code; /* 0 or -1 */
113   char err_str[256];
114 };
115
116 static void touch_cb (guestfs_h *g, void *data, XDR *xdr)
117 {
118   struct touch_rv *rv = (struct touch_rv *) data;
119
120   /* XXX */ rv.code = 0;
121   main_loop.main_loop_quit (g);
122 }
123
124 int guestfs_touch (guestfs_h *g,
125                 const char *path)
126 {
127   struct guestfs_touch_args args;
128   struct touch_rv rv;
129
130   if (g->state != READY) {
131     error (g, "guestfs_touch called from the wrong state, %d != READY",
132       g->state);
133     return -1;
134   }
135
136   args.path = (char *) path;
137   if (dispatch (g, (xdrproc_t) xdr_guestfs_touch_args, (char *) &args) == -1)
138     return -1;
139
140   rv.err_code = 42;
141   g->reply_cb_internal = touch_cb;
142   g->reply_cb_internal_data = &rv;
143   main_loop.main_loop_run (g);
144   g->reply_cb_internal = NULL;
145   g->reply_cb_internal_data = NULL;
146   if (rv.err_code == 42) { /* callback wasn't called */
147     error (g, "guestfs_touch failed, see earlier error messages");
148     return -1;
149   }
150   else if (rv.err_code == -1) { /* error from remote end */
151     error (g, "%s", rv.err_str);
152     return -1;
153   }
154
155   return 0;
156 }
157