Implement RString and RStringList return types.
[libguestfs.git] / daemon / stubs.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 program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program 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
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along
18  * with this program; if not, write to the Free Software Foundation, Inc.,
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20  */
21
22 #include <rpc/types.h>
23 #include <rpc/xdr.h>
24 #include "daemon.h"
25 #include "../src/guestfs_protocol.h"
26 #include "actions.h"
27
28 static void cat_stub (XDR *xdr_in)
29 {
30   char *r;
31   struct guestfs_cat_args args;
32   const char *path;
33
34   memset (&args, 0, sizeof args);
35
36   if (!xdr_guestfs_cat_args (xdr_in, &args)) {
37     reply_with_error ("cat: daemon failed to decode procedure arguments");
38     return;
39   }
40   path = args.path;
41
42   r = do_cat (path);
43   if (r == NULL)
44     /* do_cat has already called reply_with_error, so just return */
45     return;
46
47   struct guestfs_cat_ret ret;
48   ret.content = r;
49   reply ((xdrproc_t) &xdr_guestfs_cat_ret, (char *) &ret);
50   free (r);
51 }
52
53 static void ll_stub (XDR *xdr_in)
54 {
55   char *r;
56   struct guestfs_ll_args args;
57   const char *directory;
58
59   memset (&args, 0, sizeof args);
60
61   if (!xdr_guestfs_ll_args (xdr_in, &args)) {
62     reply_with_error ("ll: daemon failed to decode procedure arguments");
63     return;
64   }
65   directory = args.directory;
66
67   r = do_ll (directory);
68   if (r == NULL)
69     /* do_ll has already called reply_with_error, so just return */
70     return;
71
72   struct guestfs_ll_ret ret;
73   ret.listing = r;
74   reply ((xdrproc_t) &xdr_guestfs_ll_ret, (char *) &ret);
75   free (r);
76 }
77
78 static void ls_stub (XDR *xdr_in)
79 {
80   char **r;
81   struct guestfs_ls_args args;
82   const char *directory;
83
84   memset (&args, 0, sizeof args);
85
86   if (!xdr_guestfs_ls_args (xdr_in, &args)) {
87     reply_with_error ("ls: daemon failed to decode procedure arguments");
88     return;
89   }
90   directory = args.directory;
91
92   r = do_ls (directory);
93   if (r == NULL)
94     /* do_ls has already called reply_with_error, so just return */
95     return;
96
97   struct guestfs_ls_ret ret;
98   ret.listing.listing_len = count_strings (r);
99   ret.listing.listing_val = r;
100   reply ((xdrproc_t) &xdr_guestfs_ls_ret, (char *) &ret);
101   free_strings (r);
102 }
103
104 static void mount_stub (XDR *xdr_in)
105 {
106   int r;
107   struct guestfs_mount_args args;
108   const char *device;
109   const char *mountpoint;
110
111   memset (&args, 0, sizeof args);
112
113   if (!xdr_guestfs_mount_args (xdr_in, &args)) {
114     reply_with_error ("mount: daemon failed to decode procedure arguments");
115     return;
116   }
117   device = args.device;
118   mountpoint = args.mountpoint;
119
120   r = do_mount (device, mountpoint);
121   if (r == -1)
122     /* do_mount has already called reply_with_error, so just return */
123     return;
124
125   reply (NULL, NULL);
126 }
127
128 static void sync_stub (XDR *xdr_in)
129 {
130   int r;
131
132   r = do_sync ();
133   if (r == -1)
134     /* do_sync has already called reply_with_error, so just return */
135     return;
136
137   reply (NULL, NULL);
138 }
139
140 static void touch_stub (XDR *xdr_in)
141 {
142   int r;
143   struct guestfs_touch_args args;
144   const char *path;
145
146   memset (&args, 0, sizeof args);
147
148   if (!xdr_guestfs_touch_args (xdr_in, &args)) {
149     reply_with_error ("touch: daemon failed to decode procedure arguments");
150     return;
151   }
152   path = args.path;
153
154   r = do_touch (path);
155   if (r == -1)
156     /* do_touch has already called reply_with_error, so just return */
157     return;
158
159   reply (NULL, NULL);
160 }
161
162 void dispatch_incoming_message (XDR *xdr_in)
163 {
164   switch (proc_nr) {
165     case GUESTFS_PROC_CAT:
166       cat_stub (xdr_in);
167       break;
168     case GUESTFS_PROC_LL:
169       ll_stub (xdr_in);
170       break;
171     case GUESTFS_PROC_LS:
172       ls_stub (xdr_in);
173       break;
174     case GUESTFS_PROC_MOUNT:
175       mount_stub (xdr_in);
176       break;
177     case GUESTFS_PROC_SYNC:
178       sync_stub (xdr_in);
179       break;
180     case GUESTFS_PROC_TOUCH:
181       touch_stub (xdr_in);
182       break;
183     default:
184       reply_with_error ("dispatch_incoming_message: unknown procedure number %d", proc_nr);
185   }
186 }