]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/stored/pythonsd.c
Make third argument of DEVICE::d_ioctl optionnal to emulate varg
[bacula/bacula] / bacula / src / stored / pythonsd.c
index 9bcfc1b8f40e6c067110be682f28465009772831..d7cb486e13e747969c26834c7b7d2c6a75a71800 100644 (file)
@@ -1,21 +1,12 @@
-/*
- *
- * Bacula interface to Python for the Storage Daemon
- *
- * Kern Sibbald, January MMV
- *
- *   Version $Id$
- *
- */
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2005-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2005-2008 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
    This program is Free Software; you can redistribute it and/or
-   modify it under the terms of version two of the GNU General Public
+   modify it under the terms of version three of the GNU Affero General Public
    License as published by the Free Software Foundation and included
    in the file LICENSE.
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
    General Public License for more details.
 
-   You should have received a copy of the GNU General Public License
+   You should have received a copy of the GNU Affero General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   Bacula® is a registered trademark of John Walker.
+   Bacula® is a registered trademark of Kern Sibbald.
    The licensor of Bacula is the Free Software Foundation Europe
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *
+ * Bacula interface to Python for the Storage Daemon
+ *
+ * Kern Sibbald, January MMV
+ *
+ *   Version $Id$
+ *
+ */
 
 
 #include "bacula.h"
@@ -43,9 +43,7 @@
 #undef _POSIX_C_SOURCE
 #include <Python.h>
 
-extern JCR *get_jcr_from_PyObject(PyObject *self);
-extern PyObject *find_method(PyObject *eventsObject, PyObject *method, 
-         const char *name);
+#include <lib/pythonlib.h>
 
 static PyObject *set_job_events(PyObject *self, PyObject *arg);
 static PyObject *job_write(PyObject *self, PyObject *arg);
@@ -59,7 +57,7 @@ PyMethodDef JobMethods[] = {
 
 struct s_vars {
    const char *name;
-   char *fmt;
+   const char *fmt;
 };
 
 static struct s_vars getvars[] = {
@@ -116,31 +114,31 @@ PyObject *job_getattr(PyObject *self, char *attrname)
    }  
    switch (i) {
    case 0:                            /* Job */
-      return Py_BuildValue(getvars[i].fmt, jcr->job_name);    /* Non-unique name */
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->job_name);    /* Non-unique name */
    case 1:                            /* SD's name */
-      return Py_BuildValue(getvars[i].fmt, my_name);
+      return Py_BuildValue((char *)getvars[i].fmt, my_name);
    case 2:                            /* level */
-      return Py_BuildValue(getvars[i].fmt, job_level_to_str(jcr->JobLevel));
+      return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->getJobLevel()));
    case 3:                            /* type */
-      return Py_BuildValue(getvars[i].fmt, job_type_to_str(jcr->JobType));
+      return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->getJobType()));
    case 4:                            /* JobId */
-      return Py_BuildValue(getvars[i].fmt, jcr->JobId);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->JobId);
    case 5:                            /* Client */
-      return Py_BuildValue(getvars[i].fmt, jcr->client_name);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->client_name);
    case 6:                            /* Pool */
-      return Py_BuildValue(getvars[i].fmt, jcr->dcr->pool_name);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->dcr->pool_name);
    case 7:                            /* MediaType */
-      return Py_BuildValue(getvars[i].fmt, jcr->dcr->media_type);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->dcr->media_type);
    case 8:                            /* JobName */
-      return Py_BuildValue(getvars[i].fmt, jcr->Job);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->Job);
    case 9:                            /* JobStatus */
       buf[1] = 0;
       buf[0] = jcr->JobStatus;
-      return Py_BuildValue(getvars[i].fmt, buf);
+      return Py_BuildValue((char *)getvars[i].fmt, buf);
    case 10:
-      return Py_BuildValue(getvars[i].fmt, jcr->dcr->VolumeName);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->dcr->VolumeName);
    case 11:
-      return Py_BuildValue(getvars[i].fmt, jcr->dcr->dev_name);
+      return Py_BuildValue((char *)getvars[i].fmt, jcr->dcr->dev_name);
    }
    bsnprintf(errmsg, sizeof(errmsg), _("Attribute %s not found."), attrname);
 bail_out:
@@ -181,7 +179,7 @@ int job_setattr(PyObject *self, char *attrname, PyObject *value)
    }
    /* Get argument value ***FIXME*** handle other formats */
    if (setvars[i].fmt != NULL) {
-      if (!PyArg_Parse(value, setvars[i].fmt, &strval)) {
+      if (!PyArg_Parse(value, (char *)setvars[i].fmt, &strval)) {
          PyErr_SetString(PyExc_TypeError, _("Read-only attribute"));
          return -1;
       }
@@ -255,7 +253,7 @@ int generate_job_event(JCR *jcr, const char *event)
    }
 
    bstrncpy(jcr->event, event, sizeof(jcr->event));
-   result = PyObject_CallFunction(method, "O", Job);
+   result = PyObject_CallFunction(method, (char *)"O", Job);
    jcr->event[0] = 0;             /* no event in progress */
    if (result == NULL) {
       if (PyErr_Occurred()) {