Added initial unfs3 sources for version 0.9.22+dfsg-1maemo2
[unfs3] / unfs3 / contrib / nfsotpclient / mountclient / mounttypes.py
1 # Generated by rpcgen.py at Mon Mar  8 11:09:57 2004
2
3 from mountconstants import *
4 from mountpacker import *
5 import rpc
6
7 __all__ = ['BadDiscriminant', 'fhstatus', 'mountres3_ok', 'mountres3', 'mountbody', 'groupnode', 'exportnode']
8
9 def init_type_class(klass, ncl):
10     # Initilize type class
11     klass.ncl = ncl
12     klass.packer = ncl.packer
13     klass.unpacker = ncl.unpacker
14
15 def assert_not_none(klass, *args):
16     for arg in args:
17         if arg == None:
18             raise TypeError(repr(klass) + " has uninitialized data")
19
20 def pack_objarray(ncl, list):
21     # FIXME: Support for length assertion. 
22     ncl.packer.pack_uint(len(list))
23     for item in list:
24         item.pack()
25
26 def unpack_objarray(ncl, klass):
27     n = ncl.unpacker.unpack_uint()
28     list = []
29     for i in range(n):
30         obj = klass(ncl)
31         obj.unpack()
32         list.append(obj)
33     return list
34
35
36 class BadDiscriminant(rpc.RPCException):
37     def __init__(self, value, klass):
38         self.value = value
39         self.klass = klass
40
41     def __str__(self):
42         return "Bad Discriminant %s in %s" % (self.value, self.klass)
43
44 class fhstatus:
45     # XDR definition:
46     # union fhstatus switch (unsigned fhs_status) {
47     #     case 0:
48     #         fhandle2    fhs_fhandle;
49     #     default:
50     #         void;
51     # };
52     def __init__(self, ncl, fhs_status=None, fhs_fhandle=None):
53         init_type_class(self, ncl)
54         self.fhs_status = fhs_status
55         self.fhs_fhandle = fhs_fhandle
56         # Shortcut to current arm
57         self.arm = None
58
59     def __repr__(self):
60         s = " fhs_status=%s fhs_fhandle=%s" % (str(self.fhs_status), str(self.fhs_fhandle))
61         if len(s) > 70: s = s[:70] + "..."
62         return "<fhstatus:%s>" % s
63
64     def pack(self, dummy=None):
65         assert_not_none(self, self.fhs_status)
66         self.packer.pack_unsigned(self.fhs_status)
67         if self.fhs_status == 0:
68             assert_not_none(self, self.fhs_fhandle)
69             self.packer.pack_fhandle2(self.fhs_fhandle)
70             self.arm = self.fhs_fhandle
71         else:
72             pass
73             
74
75     def unpack(self):
76         self.fhs_status = self.unpacker.unpack_unsigned()
77         if self.fhs_status == 0:
78             self.fhs_fhandle = self.unpacker.unpack_fhandle2()
79             self.arm = self.fhs_fhandle
80         else:
81             pass
82             
83
84 class mountres3_ok:
85     # XDR definition:
86     # struct mountres3_ok {
87     #     fhandle3 fhandle;
88     #     int auth_flavors<>;
89     # };
90     def __init__(self, ncl, fhandle=None, auth_flavors=None):
91         init_type_class(self, ncl)
92         self.fhandle = fhandle
93         self.auth_flavors = auth_flavors
94
95     def __repr__(self):
96         s = " fhandle=%s auth_flavors=%s" % (str(self.fhandle), str(self.auth_flavors))
97         if len(s) > 70: s = s[:70] + "..."
98         return "<mountres3_ok:%s>" % s
99
100     def pack(self, dummy=None):
101         assert_not_none(self, self.fhandle, self.auth_flavors)
102         self.packer.pack_fhandle3(self.fhandle)
103         self.packer.pack_int(self.auth_flavors)
104
105     def unpack(self):
106         self.fhandle = self.unpacker.unpack_fhandle3()
107         self.auth_flavors = self.unpacker.unpack_array(self.unpacker.unpack_int)
108
109 class mountres3:
110     # XDR definition:
111     # union mountres3 switch (mountstat3 fhs_status) {
112     #     case MNT3_OK:
113     #         mountres3_ok    mountinfo;
114     #     default:
115     #         void;
116     # };
117     def __init__(self, ncl, fhs_status=None, mountinfo=None):
118         init_type_class(self, ncl)
119         self.fhs_status = fhs_status
120         self.mountinfo = mountinfo
121         # Shortcut to current arm
122         self.arm = None
123
124     def __repr__(self):
125         s = " fhs_status=%s mountinfo=%s" % (str(self.fhs_status), str(self.mountinfo))
126         if len(s) > 70: s = s[:70] + "..."
127         return "<mountres3:%s>" % s
128
129     def pack(self, dummy=None):
130         assert_not_none(self, self.fhs_status)
131         self.packer.pack_mountstat3(self.fhs_status)
132         if self.fhs_status == MNT3_OK:
133             assert_not_none(self, self.mountinfo)
134             self.mountinfo.pack()
135             self.arm = self.mountinfo
136         else:
137             pass
138             
139
140     def unpack(self):
141         self.fhs_status = self.unpacker.unpack_mountstat3()
142         if self.fhs_status == MNT3_OK:
143             self.mountinfo = mountres3_ok(self)
144             self.mountinfo.unpack()
145             self.arm = self.mountinfo
146         else:
147             pass
148             
149
150 class mountbody:
151     # XDR definition:
152     # struct mountbody {
153     #     name ml_hostname;
154     #     dirpath ml_directory;
155     #     mountlist ml_next;
156     # };
157     def __init__(self, ncl, ml_hostname=None, ml_directory=None, ml_next=None):
158         init_type_class(self, ncl)
159         self.ml_hostname = ml_hostname
160         self.ml_directory = ml_directory
161         self.ml_next = ml_next
162
163     def __repr__(self):
164         s = " ml_hostname=%s ml_directory=%s ml_next=%s" % (str(self.ml_hostname), str(self.ml_directory), str(self.ml_next))
165         if len(s) > 70: s = s[:70] + "..."
166         return "<mountbody:%s>" % s
167
168     def pack(self, dummy=None):
169         assert_not_none(self, self.ml_hostname, self.ml_directory, self.ml_next)
170         self.packer.pack_name(self.ml_hostname)
171         self.packer.pack_dirpath(self.ml_directory)
172         self.packer.pack_mountlist(self.ml_next)
173
174     def unpack(self):
175         self.ml_hostname = self.unpacker.unpack_name()
176         self.ml_directory = self.unpacker.unpack_dirpath()
177         self.ml_next = self.unpacker.unpack_mountlist()
178
179 class groupnode:
180     # XDR definition:
181     # struct groupnode {
182     #     name gr_name;
183     #     groups gr_next;
184     # };
185     def __init__(self, ncl, gr_name=None, gr_next=None):
186         init_type_class(self, ncl)
187         self.gr_name = gr_name
188         self.gr_next = gr_next
189
190     def __repr__(self):
191         s = " gr_name=%s gr_next=%s" % (str(self.gr_name), str(self.gr_next))
192         if len(s) > 70: s = s[:70] + "..."
193         return "<groupnode:%s>" % s
194
195     def pack(self, dummy=None):
196         assert_not_none(self, self.gr_name, self.gr_next)
197         self.packer.pack_name(self.gr_name)
198         self.packer.pack_groups(self.gr_next)
199
200     def unpack(self):
201         self.gr_name = self.unpacker.unpack_name()
202         self.gr_next = self.unpacker.unpack_groups()
203
204 class exportnode:
205     # XDR definition:
206     # struct exportnode {
207     #     dirpath ex_dir;
208     #     groups ex_groups;
209     #     exports ex_next;
210     # };
211     def __init__(self, ncl, ex_dir=None, ex_groups=None, ex_next=None):
212         init_type_class(self, ncl)
213         self.ex_dir = ex_dir
214         self.ex_groups = ex_groups
215         self.ex_next = ex_next
216
217     def __repr__(self):
218         s = " ex_dir=%s ex_groups=%s ex_next=%s" % (str(self.ex_dir), str(self.ex_groups), str(self.ex_next))
219         if len(s) > 70: s = s[:70] + "..."
220         return "<exportnode:%s>" % s
221
222     def pack(self, dummy=None):
223         assert_not_none(self, self.ex_dir, self.ex_groups, self.ex_next)
224         self.packer.pack_dirpath(self.ex_dir)
225         self.packer.pack_groups(self.ex_groups)
226         self.packer.pack_exports(self.ex_next)
227
228     def unpack(self):
229         self.ex_dir = self.unpacker.unpack_dirpath()
230         self.ex_groups = self.unpacker.unpack_groups()
231         self.ex_next = self.unpacker.unpack_exports()
232