git add -f bin/default/librpc/gen_ndr/*.[ch] bin/default/source*/librpc/gen_ndr/...
[metze/samba/wip.git] / bin.gen_ndr / default / librpc / gen_ndr / py_atsvc.c
1
2 /* Python wrapper functions auto-generated by pidl */
3 #include <Python.h>
4 #include "includes.h"
5 #include <pytalloc.h>
6 #include "librpc/rpc/pyrpc.h"
7 #include "librpc/rpc/pyrpc_util.h"
8 #include "bin/default/librpc/gen_ndr/ndr_atsvc.h"
9 #include "bin/default/librpc/gen_ndr/ndr_atsvc_c.h"
10
11 staticforward PyTypeObject atsvc_JobInfo_Type;
12 staticforward PyTypeObject atsvc_JobEnumInfo_Type;
13 staticforward PyTypeObject atsvc_enum_ctr_Type;
14 staticforward PyTypeObject atsvc_InterfaceType;
15
16 void initatsvc(void);static PyTypeObject *Object_Type;
17 static PyTypeObject *ClientConnection_Type;
18
19 static PyObject *py_atsvc_JobInfo_get_job_time(PyObject *obj, void *closure)
20 {
21         struct atsvc_JobInfo *object = (struct atsvc_JobInfo *)pytalloc_get_ptr(obj);
22         PyObject *py_job_time;
23         py_job_time = PyInt_FromLong(object->job_time);
24         return py_job_time;
25 }
26
27 static int py_atsvc_JobInfo_set_job_time(PyObject *py_obj, PyObject *value, void *closure)
28 {
29         struct atsvc_JobInfo *object = (struct atsvc_JobInfo *)pytalloc_get_ptr(py_obj);
30         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
31         object->job_time = PyInt_AsLong(value);
32         return 0;
33 }
34
35 static PyObject *py_atsvc_JobInfo_get_days_of_month(PyObject *obj, void *closure)
36 {
37         struct atsvc_JobInfo *object = (struct atsvc_JobInfo *)pytalloc_get_ptr(obj);
38         PyObject *py_days_of_month;
39         py_days_of_month = PyInt_FromLong(object->days_of_month);
40         return py_days_of_month;
41 }
42
43 static int py_atsvc_JobInfo_set_days_of_month(PyObject *py_obj, PyObject *value, void *closure)
44 {
45         struct atsvc_JobInfo *object = (struct atsvc_JobInfo *)pytalloc_get_ptr(py_obj);
46         if (PyLong_Check(value)) {
47                 object->days_of_month = PyLong_AsLongLong(value);
48         } else if (PyInt_Check(value)) {
49                 object->days_of_month = PyInt_AsLong(value);
50         } else {
51                 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
52                   PyInt_Type.tp_name, PyLong_Type.tp_name);
53                 return -1;
54         }
55         return 0;
56 }
57
58 static PyObject *py_atsvc_JobInfo_get_days_of_week(PyObject *obj, void *closure)
59 {
60         struct atsvc_JobInfo *object = (struct atsvc_JobInfo *)pytalloc_get_ptr(obj);
61         PyObject *py_days_of_week;
62         py_days_of_week = PyInt_FromLong(object->days_of_week);
63         return py_days_of_week;
64 }
65
66 static int py_atsvc_JobInfo_set_days_of_week(PyObject *py_obj, PyObject *value, void *closure)
67 {
68         struct atsvc_JobInfo *object = (struct atsvc_JobInfo *)pytalloc_get_ptr(py_obj);
69         if (PyLong_Check(value)) {
70                 object->days_of_week = PyLong_AsLongLong(value);
71         } else if (PyInt_Check(value)) {
72                 object->days_of_week = PyInt_AsLong(value);
73         } else {
74                 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
75                   PyInt_Type.tp_name, PyLong_Type.tp_name);
76                 return -1;
77         }
78         return 0;
79 }
80
81 static PyObject *py_atsvc_JobInfo_get_flags(PyObject *obj, void *closure)
82 {
83         struct atsvc_JobInfo *object = (struct atsvc_JobInfo *)pytalloc_get_ptr(obj);
84         PyObject *py_flags;
85         py_flags = PyInt_FromLong(object->flags);
86         return py_flags;
87 }
88
89 static int py_atsvc_JobInfo_set_flags(PyObject *py_obj, PyObject *value, void *closure)
90 {
91         struct atsvc_JobInfo *object = (struct atsvc_JobInfo *)pytalloc_get_ptr(py_obj);
92         if (PyLong_Check(value)) {
93                 object->flags = PyLong_AsLongLong(value);
94         } else if (PyInt_Check(value)) {
95                 object->flags = PyInt_AsLong(value);
96         } else {
97                 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
98                   PyInt_Type.tp_name, PyLong_Type.tp_name);
99                 return -1;
100         }
101         return 0;
102 }
103
104 static PyObject *py_atsvc_JobInfo_get_command(PyObject *obj, void *closure)
105 {
106         struct atsvc_JobInfo *object = (struct atsvc_JobInfo *)pytalloc_get_ptr(obj);
107         PyObject *py_command;
108         if (object->command == NULL) {
109                 py_command = Py_None;
110                 Py_INCREF(py_command);
111         } else {
112                 if (object->command == NULL) {
113                         py_command = Py_None;
114                         Py_INCREF(py_command);
115                 } else {
116                         py_command = PyUnicode_Decode(object->command, strlen(object->command), "utf-8", "ignore");
117                 }
118         }
119         return py_command;
120 }
121
122 static int py_atsvc_JobInfo_set_command(PyObject *py_obj, PyObject *value, void *closure)
123 {
124         struct atsvc_JobInfo *object = (struct atsvc_JobInfo *)pytalloc_get_ptr(py_obj);
125         if (value == Py_None) {
126                 object->command = NULL;
127         } else {
128                 object->command = NULL;
129                 if (PyUnicode_Check(value)) {
130                         object->command = PyString_AS_STRING(PyUnicode_AsEncodedString(value, "utf-8", "ignore"));
131                 } else if (PyString_Check(value)) {
132                         object->command = PyString_AS_STRING(value);
133                 } else {
134                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
135                         return -1;
136                 }
137         }
138         return 0;
139 }
140
141 static PyGetSetDef py_atsvc_JobInfo_getsetters[] = {
142         { discard_const_p(char, "job_time"), py_atsvc_JobInfo_get_job_time, py_atsvc_JobInfo_set_job_time },
143         { discard_const_p(char, "days_of_month"), py_atsvc_JobInfo_get_days_of_month, py_atsvc_JobInfo_set_days_of_month },
144         { discard_const_p(char, "days_of_week"), py_atsvc_JobInfo_get_days_of_week, py_atsvc_JobInfo_set_days_of_week },
145         { discard_const_p(char, "flags"), py_atsvc_JobInfo_get_flags, py_atsvc_JobInfo_set_flags },
146         { discard_const_p(char, "command"), py_atsvc_JobInfo_get_command, py_atsvc_JobInfo_set_command },
147         { NULL }
148 };
149
150 static PyObject *py_atsvc_JobInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
151 {
152         return pytalloc_new(struct atsvc_JobInfo, type);
153 }
154
155
156 static PyTypeObject atsvc_JobInfo_Type = {
157         PyObject_HEAD_INIT(NULL) 0,
158         .tp_name = "atsvc.JobInfo",
159         .tp_getset = py_atsvc_JobInfo_getsetters,
160         .tp_methods = NULL,
161         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
162         .tp_basicsize = sizeof(pytalloc_Object),
163         .tp_new = py_atsvc_JobInfo_new,
164 };
165
166
167 static PyObject *py_atsvc_JobEnumInfo_get_job_id(PyObject *obj, void *closure)
168 {
169         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(obj);
170         PyObject *py_job_id;
171         py_job_id = PyInt_FromLong(object->job_id);
172         return py_job_id;
173 }
174
175 static int py_atsvc_JobEnumInfo_set_job_id(PyObject *py_obj, PyObject *value, void *closure)
176 {
177         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(py_obj);
178         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
179         object->job_id = PyInt_AsLong(value);
180         return 0;
181 }
182
183 static PyObject *py_atsvc_JobEnumInfo_get_job_time(PyObject *obj, void *closure)
184 {
185         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(obj);
186         PyObject *py_job_time;
187         py_job_time = PyInt_FromLong(object->job_time);
188         return py_job_time;
189 }
190
191 static int py_atsvc_JobEnumInfo_set_job_time(PyObject *py_obj, PyObject *value, void *closure)
192 {
193         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(py_obj);
194         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
195         object->job_time = PyInt_AsLong(value);
196         return 0;
197 }
198
199 static PyObject *py_atsvc_JobEnumInfo_get_days_of_month(PyObject *obj, void *closure)
200 {
201         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(obj);
202         PyObject *py_days_of_month;
203         py_days_of_month = PyInt_FromLong(object->days_of_month);
204         return py_days_of_month;
205 }
206
207 static int py_atsvc_JobEnumInfo_set_days_of_month(PyObject *py_obj, PyObject *value, void *closure)
208 {
209         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(py_obj);
210         if (PyLong_Check(value)) {
211                 object->days_of_month = PyLong_AsLongLong(value);
212         } else if (PyInt_Check(value)) {
213                 object->days_of_month = PyInt_AsLong(value);
214         } else {
215                 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
216                   PyInt_Type.tp_name, PyLong_Type.tp_name);
217                 return -1;
218         }
219         return 0;
220 }
221
222 static PyObject *py_atsvc_JobEnumInfo_get_days_of_week(PyObject *obj, void *closure)
223 {
224         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(obj);
225         PyObject *py_days_of_week;
226         py_days_of_week = PyInt_FromLong(object->days_of_week);
227         return py_days_of_week;
228 }
229
230 static int py_atsvc_JobEnumInfo_set_days_of_week(PyObject *py_obj, PyObject *value, void *closure)
231 {
232         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(py_obj);
233         if (PyLong_Check(value)) {
234                 object->days_of_week = PyLong_AsLongLong(value);
235         } else if (PyInt_Check(value)) {
236                 object->days_of_week = PyInt_AsLong(value);
237         } else {
238                 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
239                   PyInt_Type.tp_name, PyLong_Type.tp_name);
240                 return -1;
241         }
242         return 0;
243 }
244
245 static PyObject *py_atsvc_JobEnumInfo_get_flags(PyObject *obj, void *closure)
246 {
247         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(obj);
248         PyObject *py_flags;
249         py_flags = PyInt_FromLong(object->flags);
250         return py_flags;
251 }
252
253 static int py_atsvc_JobEnumInfo_set_flags(PyObject *py_obj, PyObject *value, void *closure)
254 {
255         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(py_obj);
256         if (PyLong_Check(value)) {
257                 object->flags = PyLong_AsLongLong(value);
258         } else if (PyInt_Check(value)) {
259                 object->flags = PyInt_AsLong(value);
260         } else {
261                 PyErr_Format(PyExc_TypeError, "Expected type %s or %s",\
262                   PyInt_Type.tp_name, PyLong_Type.tp_name);
263                 return -1;
264         }
265         return 0;
266 }
267
268 static PyObject *py_atsvc_JobEnumInfo_get_command(PyObject *obj, void *closure)
269 {
270         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(obj);
271         PyObject *py_command;
272         if (object->command == NULL) {
273                 py_command = Py_None;
274                 Py_INCREF(py_command);
275         } else {
276                 if (object->command == NULL) {
277                         py_command = Py_None;
278                         Py_INCREF(py_command);
279                 } else {
280                         py_command = PyUnicode_Decode(object->command, strlen(object->command), "utf-8", "ignore");
281                 }
282         }
283         return py_command;
284 }
285
286 static int py_atsvc_JobEnumInfo_set_command(PyObject *py_obj, PyObject *value, void *closure)
287 {
288         struct atsvc_JobEnumInfo *object = (struct atsvc_JobEnumInfo *)pytalloc_get_ptr(py_obj);
289         if (value == Py_None) {
290                 object->command = NULL;
291         } else {
292                 object->command = NULL;
293                 if (PyUnicode_Check(value)) {
294                         object->command = PyString_AS_STRING(PyUnicode_AsEncodedString(value, "utf-8", "ignore"));
295                 } else if (PyString_Check(value)) {
296                         object->command = PyString_AS_STRING(value);
297                 } else {
298                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
299                         return -1;
300                 }
301         }
302         return 0;
303 }
304
305 static PyGetSetDef py_atsvc_JobEnumInfo_getsetters[] = {
306         { discard_const_p(char, "job_id"), py_atsvc_JobEnumInfo_get_job_id, py_atsvc_JobEnumInfo_set_job_id },
307         { discard_const_p(char, "job_time"), py_atsvc_JobEnumInfo_get_job_time, py_atsvc_JobEnumInfo_set_job_time },
308         { discard_const_p(char, "days_of_month"), py_atsvc_JobEnumInfo_get_days_of_month, py_atsvc_JobEnumInfo_set_days_of_month },
309         { discard_const_p(char, "days_of_week"), py_atsvc_JobEnumInfo_get_days_of_week, py_atsvc_JobEnumInfo_set_days_of_week },
310         { discard_const_p(char, "flags"), py_atsvc_JobEnumInfo_get_flags, py_atsvc_JobEnumInfo_set_flags },
311         { discard_const_p(char, "command"), py_atsvc_JobEnumInfo_get_command, py_atsvc_JobEnumInfo_set_command },
312         { NULL }
313 };
314
315 static PyObject *py_atsvc_JobEnumInfo_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
316 {
317         return pytalloc_new(struct atsvc_JobEnumInfo, type);
318 }
319
320
321 static PyTypeObject atsvc_JobEnumInfo_Type = {
322         PyObject_HEAD_INIT(NULL) 0,
323         .tp_name = "atsvc.JobEnumInfo",
324         .tp_getset = py_atsvc_JobEnumInfo_getsetters,
325         .tp_methods = NULL,
326         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
327         .tp_basicsize = sizeof(pytalloc_Object),
328         .tp_new = py_atsvc_JobEnumInfo_new,
329 };
330
331
332 static PyObject *py_atsvc_enum_ctr_get_entries_read(PyObject *obj, void *closure)
333 {
334         struct atsvc_enum_ctr *object = (struct atsvc_enum_ctr *)pytalloc_get_ptr(obj);
335         PyObject *py_entries_read;
336         py_entries_read = PyInt_FromLong(object->entries_read);
337         return py_entries_read;
338 }
339
340 static int py_atsvc_enum_ctr_set_entries_read(PyObject *py_obj, PyObject *value, void *closure)
341 {
342         struct atsvc_enum_ctr *object = (struct atsvc_enum_ctr *)pytalloc_get_ptr(py_obj);
343         PY_CHECK_TYPE(&PyInt_Type, value, return -1;);
344         object->entries_read = PyInt_AsLong(value);
345         return 0;
346 }
347
348 static PyObject *py_atsvc_enum_ctr_get_first_entry(PyObject *obj, void *closure)
349 {
350         struct atsvc_enum_ctr *object = (struct atsvc_enum_ctr *)pytalloc_get_ptr(obj);
351         PyObject *py_first_entry;
352         if (object->first_entry == NULL) {
353                 py_first_entry = Py_None;
354                 Py_INCREF(py_first_entry);
355         } else {
356                 py_first_entry = PyList_New(object->entries_read);
357                 if (py_first_entry == NULL) {
358                         return NULL;
359                 }
360                 {
361                         int first_entry_cntr_1;
362                         for (first_entry_cntr_1 = 0; first_entry_cntr_1 < object->entries_read; first_entry_cntr_1++) {
363                                 PyObject *py_first_entry_1;
364                                 py_first_entry_1 = pytalloc_reference_ex(&atsvc_JobEnumInfo_Type, object->first_entry, &object->first_entry[first_entry_cntr_1]);
365                                 PyList_SetItem(py_first_entry, first_entry_cntr_1, py_first_entry_1);
366                         }
367                 }
368         }
369         return py_first_entry;
370 }
371
372 static int py_atsvc_enum_ctr_set_first_entry(PyObject *py_obj, PyObject *value, void *closure)
373 {
374         struct atsvc_enum_ctr *object = (struct atsvc_enum_ctr *)pytalloc_get_ptr(py_obj);
375         talloc_unlink(pytalloc_get_mem_ctx(py_obj), object->first_entry);
376         if (value == Py_None) {
377                 object->first_entry = NULL;
378         } else {
379                 object->first_entry = NULL;
380                 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
381                 {
382                         int first_entry_cntr_1;
383                         object->first_entry = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->first_entry, PyList_GET_SIZE(value));
384                         if (!object->first_entry) { return -1;; }
385                         talloc_set_name_const(object->first_entry, "ARRAY: object->first_entry");
386                         for (first_entry_cntr_1 = 0; first_entry_cntr_1 < PyList_GET_SIZE(value); first_entry_cntr_1++) {
387                                 PY_CHECK_TYPE(&atsvc_JobEnumInfo_Type, PyList_GET_ITEM(value, first_entry_cntr_1), return -1;);
388                                 if (talloc_reference(object->first_entry, pytalloc_get_mem_ctx(PyList_GET_ITEM(value, first_entry_cntr_1))) == NULL) {
389                                         PyErr_NoMemory();
390                                         return -1;
391                                 }
392                                 object->first_entry[first_entry_cntr_1] = *(struct atsvc_JobEnumInfo *)pytalloc_get_ptr(PyList_GET_ITEM(value, first_entry_cntr_1));
393                         }
394                 }
395         }
396         return 0;
397 }
398
399 static PyGetSetDef py_atsvc_enum_ctr_getsetters[] = {
400         { discard_const_p(char, "entries_read"), py_atsvc_enum_ctr_get_entries_read, py_atsvc_enum_ctr_set_entries_read },
401         { discard_const_p(char, "first_entry"), py_atsvc_enum_ctr_get_first_entry, py_atsvc_enum_ctr_set_first_entry },
402         { NULL }
403 };
404
405 static PyObject *py_atsvc_enum_ctr_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
406 {
407         return pytalloc_new(struct atsvc_enum_ctr, type);
408 }
409
410
411 static PyTypeObject atsvc_enum_ctr_Type = {
412         PyObject_HEAD_INIT(NULL) 0,
413         .tp_name = "atsvc.enum_ctr",
414         .tp_getset = py_atsvc_enum_ctr_getsetters,
415         .tp_methods = NULL,
416         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
417         .tp_basicsize = sizeof(pytalloc_Object),
418         .tp_new = py_atsvc_enum_ctr_new,
419 };
420
421
422 static bool pack_py_atsvc_JobAdd_args_in(PyObject *args, PyObject *kwargs, struct atsvc_JobAdd *r)
423 {
424         PyObject *py_servername;
425         PyObject *py_job_info;
426         const char *kwnames[] = {
427                 "servername", "job_info", NULL
428         };
429
430         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:atsvc_JobAdd", discard_const_p(char *, kwnames), &py_servername, &py_job_info)) {
431                 return false;
432         }
433
434         if (py_servername == Py_None) {
435                 r->in.servername = NULL;
436         } else {
437                 r->in.servername = NULL;
438                 if (PyUnicode_Check(py_servername)) {
439                         r->in.servername = PyString_AS_STRING(PyUnicode_AsEncodedString(py_servername, "utf-8", "ignore"));
440                 } else if (PyString_Check(py_servername)) {
441                         r->in.servername = PyString_AS_STRING(py_servername);
442                 } else {
443                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_servername)->tp_name);
444                         return false;
445                 }
446         }
447         r->in.job_info = talloc_ptrtype(r, r->in.job_info);
448         PY_CHECK_TYPE(&atsvc_JobInfo_Type, py_job_info, return false;);
449         if (talloc_reference(r, pytalloc_get_mem_ctx(py_job_info)) == NULL) {
450                 PyErr_NoMemory();
451                 return false;
452         }
453         r->in.job_info = (struct atsvc_JobInfo *)pytalloc_get_ptr(py_job_info);
454         return true;
455 }
456
457 static PyObject *unpack_py_atsvc_JobAdd_args_out(struct atsvc_JobAdd *r)
458 {
459         PyObject *result;
460         PyObject *py_job_id;
461         py_job_id = PyInt_FromLong(*r->out.job_id);
462         result = py_job_id;
463         if (NT_STATUS_IS_ERR(r->out.result)) {
464                 PyErr_SetNTSTATUS(r->out.result);
465                 return NULL;
466         }
467
468         return result;
469 }
470
471 static bool pack_py_atsvc_JobDel_args_in(PyObject *args, PyObject *kwargs, struct atsvc_JobDel *r)
472 {
473         PyObject *py_servername;
474         PyObject *py_min_job_id;
475         PyObject *py_max_job_id;
476         const char *kwnames[] = {
477                 "servername", "min_job_id", "max_job_id", NULL
478         };
479
480         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:atsvc_JobDel", discard_const_p(char *, kwnames), &py_servername, &py_min_job_id, &py_max_job_id)) {
481                 return false;
482         }
483
484         if (py_servername == Py_None) {
485                 r->in.servername = NULL;
486         } else {
487                 r->in.servername = NULL;
488                 if (PyUnicode_Check(py_servername)) {
489                         r->in.servername = PyString_AS_STRING(PyUnicode_AsEncodedString(py_servername, "utf-8", "ignore"));
490                 } else if (PyString_Check(py_servername)) {
491                         r->in.servername = PyString_AS_STRING(py_servername);
492                 } else {
493                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_servername)->tp_name);
494                         return false;
495                 }
496         }
497         PY_CHECK_TYPE(&PyInt_Type, py_min_job_id, return false;);
498         r->in.min_job_id = PyInt_AsLong(py_min_job_id);
499         PY_CHECK_TYPE(&PyInt_Type, py_max_job_id, return false;);
500         r->in.max_job_id = PyInt_AsLong(py_max_job_id);
501         return true;
502 }
503
504 static PyObject *unpack_py_atsvc_JobDel_args_out(struct atsvc_JobDel *r)
505 {
506         PyObject *result;
507         result = Py_None;
508         Py_INCREF(result);
509         if (NT_STATUS_IS_ERR(r->out.result)) {
510                 PyErr_SetNTSTATUS(r->out.result);
511                 return NULL;
512         }
513
514         return result;
515 }
516
517 static bool pack_py_atsvc_JobEnum_args_in(PyObject *args, PyObject *kwargs, struct atsvc_JobEnum *r)
518 {
519         PyObject *py_servername;
520         PyObject *py_ctr;
521         PyObject *py_preferred_max_len;
522         PyObject *py_resume_handle;
523         const char *kwnames[] = {
524                 "servername", "ctr", "preferred_max_len", "resume_handle", NULL
525         };
526
527         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOO:atsvc_JobEnum", discard_const_p(char *, kwnames), &py_servername, &py_ctr, &py_preferred_max_len, &py_resume_handle)) {
528                 return false;
529         }
530
531         if (py_servername == Py_None) {
532                 r->in.servername = NULL;
533         } else {
534                 r->in.servername = NULL;
535                 if (PyUnicode_Check(py_servername)) {
536                         r->in.servername = PyString_AS_STRING(PyUnicode_AsEncodedString(py_servername, "utf-8", "ignore"));
537                 } else if (PyString_Check(py_servername)) {
538                         r->in.servername = PyString_AS_STRING(py_servername);
539                 } else {
540                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_servername)->tp_name);
541                         return false;
542                 }
543         }
544         r->in.ctr = talloc_ptrtype(r, r->in.ctr);
545         PY_CHECK_TYPE(&atsvc_enum_ctr_Type, py_ctr, return false;);
546         if (talloc_reference(r, pytalloc_get_mem_ctx(py_ctr)) == NULL) {
547                 PyErr_NoMemory();
548                 return false;
549         }
550         r->in.ctr = (struct atsvc_enum_ctr *)pytalloc_get_ptr(py_ctr);
551         PY_CHECK_TYPE(&PyInt_Type, py_preferred_max_len, return false;);
552         r->in.preferred_max_len = PyInt_AsLong(py_preferred_max_len);
553         if (py_resume_handle == Py_None) {
554                 r->in.resume_handle = NULL;
555         } else {
556                 r->in.resume_handle = talloc_ptrtype(r, r->in.resume_handle);
557                 PY_CHECK_TYPE(&PyInt_Type, py_resume_handle, return false;);
558                 *r->in.resume_handle = PyInt_AsLong(py_resume_handle);
559         }
560         return true;
561 }
562
563 static PyObject *unpack_py_atsvc_JobEnum_args_out(struct atsvc_JobEnum *r)
564 {
565         PyObject *result;
566         PyObject *py_ctr;
567         PyObject *py_total_entries;
568         PyObject *py_resume_handle;
569         result = PyTuple_New(3);
570         py_ctr = pytalloc_reference_ex(&atsvc_enum_ctr_Type, r->out.ctr, r->out.ctr);
571         PyTuple_SetItem(result, 0, py_ctr);
572         py_total_entries = PyInt_FromLong(*r->out.total_entries);
573         PyTuple_SetItem(result, 1, py_total_entries);
574         if (r->out.resume_handle == NULL) {
575                 py_resume_handle = Py_None;
576                 Py_INCREF(py_resume_handle);
577         } else {
578                 py_resume_handle = PyInt_FromLong(*r->out.resume_handle);
579         }
580         PyTuple_SetItem(result, 2, py_resume_handle);
581         if (NT_STATUS_IS_ERR(r->out.result)) {
582                 PyErr_SetNTSTATUS(r->out.result);
583                 return NULL;
584         }
585
586         return result;
587 }
588
589 static bool pack_py_atsvc_JobGetInfo_args_in(PyObject *args, PyObject *kwargs, struct atsvc_JobGetInfo *r)
590 {
591         PyObject *py_servername;
592         PyObject *py_job_id;
593         const char *kwnames[] = {
594                 "servername", "job_id", NULL
595         };
596
597         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:atsvc_JobGetInfo", discard_const_p(char *, kwnames), &py_servername, &py_job_id)) {
598                 return false;
599         }
600
601         if (py_servername == Py_None) {
602                 r->in.servername = NULL;
603         } else {
604                 r->in.servername = NULL;
605                 if (PyUnicode_Check(py_servername)) {
606                         r->in.servername = PyString_AS_STRING(PyUnicode_AsEncodedString(py_servername, "utf-8", "ignore"));
607                 } else if (PyString_Check(py_servername)) {
608                         r->in.servername = PyString_AS_STRING(py_servername);
609                 } else {
610                         PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(py_servername)->tp_name);
611                         return false;
612                 }
613         }
614         PY_CHECK_TYPE(&PyInt_Type, py_job_id, return false;);
615         r->in.job_id = PyInt_AsLong(py_job_id);
616         return true;
617 }
618
619 static PyObject *unpack_py_atsvc_JobGetInfo_args_out(struct atsvc_JobGetInfo *r)
620 {
621         PyObject *result;
622         PyObject *py_job_info;
623         if (*r->out.job_info == NULL) {
624                 py_job_info = Py_None;
625                 Py_INCREF(py_job_info);
626         } else {
627                 py_job_info = pytalloc_reference_ex(&atsvc_JobInfo_Type, *r->out.job_info, *r->out.job_info);
628         }
629         result = py_job_info;
630         if (NT_STATUS_IS_ERR(r->out.result)) {
631                 PyErr_SetNTSTATUS(r->out.result);
632                 return NULL;
633         }
634
635         return result;
636 }
637
638 const struct PyNdrRpcMethodDef py_ndr_atsvc_methods[] = {
639         { "JobAdd", "S.JobAdd(servername, job_info) -> job_id", (py_dcerpc_call_fn)dcerpc_atsvc_JobAdd_r, (py_data_pack_fn)pack_py_atsvc_JobAdd_args_in, (py_data_unpack_fn)unpack_py_atsvc_JobAdd_args_out, 0, &ndr_table_atsvc },
640         { "JobDel", "S.JobDel(servername, min_job_id, max_job_id) -> None", (py_dcerpc_call_fn)dcerpc_atsvc_JobDel_r, (py_data_pack_fn)pack_py_atsvc_JobDel_args_in, (py_data_unpack_fn)unpack_py_atsvc_JobDel_args_out, 1, &ndr_table_atsvc },
641         { "JobEnum", "S.JobEnum(servername, ctr, preferred_max_len, resume_handle) -> (ctr, total_entries, resume_handle)", (py_dcerpc_call_fn)dcerpc_atsvc_JobEnum_r, (py_data_pack_fn)pack_py_atsvc_JobEnum_args_in, (py_data_unpack_fn)unpack_py_atsvc_JobEnum_args_out, 2, &ndr_table_atsvc },
642         { "JobGetInfo", "S.JobGetInfo(servername, job_id) -> job_info", (py_dcerpc_call_fn)dcerpc_atsvc_JobGetInfo_r, (py_data_pack_fn)pack_py_atsvc_JobGetInfo_args_in, (py_data_unpack_fn)unpack_py_atsvc_JobGetInfo_args_out, 3, &ndr_table_atsvc },
643         { NULL }
644 };
645
646 static PyObject *interface_atsvc_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
647 {
648         return py_dcerpc_interface_init_helper(type, args, kwargs, &ndr_table_atsvc);
649 }
650
651 #define PY_DOC_ATSVC "Microsoft AT-Scheduler Service"
652 static PyTypeObject atsvc_InterfaceType = {
653         PyObject_HEAD_INIT(NULL) 0,
654         .tp_name = "atsvc.atsvc",
655         .tp_basicsize = sizeof(dcerpc_InterfaceObject),
656         .tp_doc = "atsvc(binding, lp_ctx=None, credentials=None) -> connection\n"
657 "\n"
658 "binding should be a DCE/RPC binding string (for example: ncacn_ip_tcp:127.0.0.1)\n"
659 "lp_ctx should be a path to a smb.conf file or a param.LoadParm object\n"
660 "credentials should be a credentials.Credentials object.\n\n"PY_DOC_ATSVC,
661         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
662         .tp_new = interface_atsvc_new,
663 };
664
665 static PyMethodDef atsvc_methods[] = {
666         { NULL, NULL, 0, NULL }
667 };
668
669 void initatsvc(void)
670 {
671         PyObject *m;
672         PyObject *dep_talloc;
673         PyObject *dep_samba_dcerpc_base;
674
675         dep_talloc = PyImport_ImportModule("talloc");
676         if (dep_talloc == NULL)
677                 return;
678
679         dep_samba_dcerpc_base = PyImport_ImportModule("samba.dcerpc.base");
680         if (dep_samba_dcerpc_base == NULL)
681                 return;
682
683         Object_Type = (PyTypeObject *)PyObject_GetAttrString(dep_talloc, "Object");
684         if (Object_Type == NULL)
685                 return;
686
687         ClientConnection_Type = (PyTypeObject *)PyObject_GetAttrString(dep_samba_dcerpc_base, "ClientConnection");
688         if (ClientConnection_Type == NULL)
689                 return;
690
691         atsvc_JobInfo_Type.tp_base = Object_Type;
692
693         atsvc_JobEnumInfo_Type.tp_base = Object_Type;
694
695         atsvc_enum_ctr_Type.tp_base = Object_Type;
696
697         atsvc_InterfaceType.tp_base = ClientConnection_Type;
698
699         if (PyType_Ready(&atsvc_JobInfo_Type) < 0)
700                 return;
701         if (PyType_Ready(&atsvc_JobEnumInfo_Type) < 0)
702                 return;
703         if (PyType_Ready(&atsvc_enum_ctr_Type) < 0)
704                 return;
705         if (PyType_Ready(&atsvc_InterfaceType) < 0)
706                 return;
707         if (!PyInterface_AddNdrRpcMethods(&atsvc_InterfaceType, py_ndr_atsvc_methods))
708                 return;
709
710 #ifdef PY_JOBINFO_PATCH
711         PY_JOBINFO_PATCH(&atsvc_JobInfo_Type);
712 #endif
713 #ifdef PY_JOBENUMINFO_PATCH
714         PY_JOBENUMINFO_PATCH(&atsvc_JobEnumInfo_Type);
715 #endif
716 #ifdef PY_ENUM_CTR_PATCH
717         PY_ENUM_CTR_PATCH(&atsvc_enum_ctr_Type);
718 #endif
719 #ifdef PY_ATSVC_PATCH
720         PY_ATSVC_PATCH(&atsvc_InterfaceType);
721 #endif
722
723         m = Py_InitModule3("atsvc", atsvc_methods, "atsvc DCE/RPC");
724         if (m == NULL)
725                 return;
726
727         PyModule_AddObject(m, "Twentyeighth", PyInt_FromLong(Twentyeighth));
728         PyModule_AddObject(m, "Twentythird", PyInt_FromLong(Twentythird));
729         PyModule_AddObject(m, "Fifth", PyInt_FromLong(Fifth));
730         PyModule_AddObject(m, "Thitteenth", PyInt_FromLong(Thitteenth));
731         PyModule_AddObject(m, "Fourteenth", PyInt_FromLong(Fourteenth));
732         PyModule_AddObject(m, "JOB_EXEC_ERROR", PyInt_FromLong(JOB_EXEC_ERROR));
733         PyModule_AddObject(m, "Seventh", PyInt_FromLong(Seventh));
734         PyModule_AddObject(m, "DAYSOFWEEK_WEDNESDAY", PyInt_FromLong(DAYSOFWEEK_WEDNESDAY));
735         PyModule_AddObject(m, "Twentysecond", PyInt_FromLong(Twentysecond));
736         PyModule_AddObject(m, "Ninteenth", PyInt_FromLong(Ninteenth));
737         PyModule_AddObject(m, "DAYSOFWEEK_FRIDAY", PyInt_FromLong(DAYSOFWEEK_FRIDAY));
738         PyModule_AddObject(m, "Twentysixth", PyInt_FromLong(Twentysixth));
739         PyModule_AddObject(m, "Sixth", PyInt_FromLong(Sixth));
740         PyModule_AddObject(m, "JOB_RUNS_TODAY", PyInt_FromLong(JOB_RUNS_TODAY));
741         PyModule_AddObject(m, "Twelfth", PyInt_FromLong(Twelfth));
742         PyModule_AddObject(m, "Fifteenth", PyInt_FromLong(Fifteenth));
743         PyModule_AddObject(m, "JOB_ADD_CURRENT_DATE", PyInt_FromLong(JOB_ADD_CURRENT_DATE));
744         PyModule_AddObject(m, "Thirtyfirst", PyInt_FromLong(Thirtyfirst));
745         PyModule_AddObject(m, "Eighteenth", PyInt_FromLong(Eighteenth));
746         PyModule_AddObject(m, "Eight", PyInt_FromLong(Eight));
747         PyModule_AddObject(m, "JOB_RUN_PERIODICALLY", PyInt_FromLong(JOB_RUN_PERIODICALLY));
748         PyModule_AddObject(m, "Second", PyInt_FromLong(Second));
749         PyModule_AddObject(m, "Ninth", PyInt_FromLong(Ninth));
750         PyModule_AddObject(m, "Tenth", PyInt_FromLong(Tenth));
751         PyModule_AddObject(m, "Twentyfirst", PyInt_FromLong(Twentyfirst));
752         PyModule_AddObject(m, "Twentyth", PyInt_FromLong(Twentyth));
753         PyModule_AddObject(m, "DAYSOFWEEK_THURSDAY", PyInt_FromLong(DAYSOFWEEK_THURSDAY));
754         PyModule_AddObject(m, "DAYSOFWEEK_MONDAY", PyInt_FromLong(DAYSOFWEEK_MONDAY));
755         PyModule_AddObject(m, "JOB_NONINTERACTIVE", PyInt_FromLong(JOB_NONINTERACTIVE));
756         PyModule_AddObject(m, "Fourth", PyInt_FromLong(Fourth));
757         PyModule_AddObject(m, "Twentyfifth", PyInt_FromLong(Twentyfifth));
758         PyModule_AddObject(m, "Sixteenth", PyInt_FromLong(Sixteenth));
759         PyModule_AddObject(m, "DAYSOFWEEK_SUNDAY", PyInt_FromLong(DAYSOFWEEK_SUNDAY));
760         PyModule_AddObject(m, "DAYSOFWEEK_SATURDAY", PyInt_FromLong(DAYSOFWEEK_SATURDAY));
761         PyModule_AddObject(m, "Eleventh", PyInt_FromLong(Eleventh));
762         PyModule_AddObject(m, "Twentyseventh", PyInt_FromLong(Twentyseventh));
763         PyModule_AddObject(m, "Seventeenth", PyInt_FromLong(Seventeenth));
764         PyModule_AddObject(m, "Twentyfourth", PyInt_FromLong(Twentyfourth));
765         PyModule_AddObject(m, "DAYSOFWEEK_TUESDAY", PyInt_FromLong(DAYSOFWEEK_TUESDAY));
766         PyModule_AddObject(m, "Thirtieth", PyInt_FromLong(Thirtieth));
767         PyModule_AddObject(m, "First", PyInt_FromLong(First));
768         PyModule_AddObject(m, "Third", PyInt_FromLong(Third));
769         PyModule_AddObject(m, "Twentyninth", PyInt_FromLong(Twentyninth));
770         Py_INCREF((PyObject *)(void *)&atsvc_JobInfo_Type);
771         PyModule_AddObject(m, "JobInfo", (PyObject *)(void *)&atsvc_JobInfo_Type);
772         Py_INCREF((PyObject *)(void *)&atsvc_JobEnumInfo_Type);
773         PyModule_AddObject(m, "JobEnumInfo", (PyObject *)(void *)&atsvc_JobEnumInfo_Type);
774         Py_INCREF((PyObject *)(void *)&atsvc_enum_ctr_Type);
775         PyModule_AddObject(m, "enum_ctr", (PyObject *)(void *)&atsvc_enum_ctr_Type);
776         Py_INCREF((PyObject *)(void *)&atsvc_InterfaceType);
777         PyModule_AddObject(m, "atsvc", (PyObject *)(void *)&atsvc_InterfaceType);
778 #ifdef PY_MOD_ATSVC_PATCH
779         PY_MOD_ATSVC_PATCH(m);
780 #endif
781
782 }