]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/filed/pythonfd.c
kes Generally clean up the manual tape loading code. The main
[bacula/bacula] / bacula / src / filed / pythonfd.c
index 8e4469956d68ad8222c194ed2b6395d5913623aa..08b1736cde2ff10d8cbfd86f912ee2b00806833f 100644 (file)
@@ -1,23 +1,14 @@
-/*
- *
- * Bacula interface to Python for the File Daemon
- *
- * Kern Sibbald, March 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
-   License as published by the Free Software Foundation plus additions
-   that are listed in the file LICENSE.
+   License as published by the Free Software Foundation and included
+   in the file LICENSE.
 
    This program is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
    Switzerland, email:ftf@fsfeurope.org.
 */
+/*
+ *
+ * Bacula interface to Python for the File Daemon
+ *
+ * Kern Sibbald, March MMV
+ *
+ *   Version $Id$
+ *
+ */
 
 #include "bacula.h"
 #include "filed.h"
 #undef _POSIX_C_SOURCE
 #include <Python.h>
 
-/* External function pointers to be set */
-extern bool    (*python_set_prog)(JCR *jcr, const char *prog);
-extern int     (*python_open)(BFILE *bfd, const char *fname, int flags, mode_t mode);
-extern int     (*python_close)(BFILE *bfd);
-extern ssize_t (*python_read)(BFILE *bfd, void *buf, size_t count);
-
 
 extern JCR *get_jcr_from_PyObject(PyObject *self);
 extern PyObject *find_method(PyObject *eventsObject, PyObject *method, 
@@ -64,12 +58,6 @@ PyMethodDef JobMethods[] = {
 };
 
 
-bool my_python_set_prog(JCR *jcr, const char *prog);
-int my_python_open(BFILE *bfd, const char *fname, int flags, mode_t mode);
-int my_python_close(BFILE *bfd);
-ssize_t my_python_read(BFILE *bfd, void *buf, size_t count);
-
-
 struct s_vars {
    const char *name;
    char *fmt;
@@ -201,7 +189,7 @@ static PyObject *job_write(PyObject *self, PyObject *args)
    char *text = NULL;
 
    if (!PyArg_ParseTuple(args, "s:write", &text)) {
-      Dmsg0(000, "Parse tuple error in job_write\n");
+      Pmsg0(000, "Parse tuple error in job_write\n");
       return NULL;
    }
    if (text) {
@@ -219,7 +207,7 @@ static PyObject *set_job_events(PyObject *self, PyObject *arg)
 
    Dmsg0(100, "In set_job_events.\n");
    if (!PyArg_ParseTuple(arg, "O", &eObject)) {
-      Dmsg0(000, "Parse error looking for Object argument\n");
+      Pmsg0(000, "Parse error looking for Object argument\n");
       return NULL;
    }
    jcr = get_jcr_from_PyObject(self);
@@ -231,12 +219,6 @@ static PyObject *set_job_events(PyObject *self, PyObject *arg)
    Py_INCREF(eObject);
    jcr->Python_events = (void *)eObject;        /* set new events */
 
-   /* Set function pointers to call here */
-   python_set_prog = my_python_set_prog;
-   python_open     = my_python_open;
-   python_close    = my_python_close;
-   python_read     = my_python_read;
-
    Py_INCREF(Py_None);
    return Py_None;
 }
@@ -268,7 +250,7 @@ int generate_job_event(JCR *jcr, const char *event)
    if (result == NULL) {
       if (PyErr_Occurred()) {
          PyErr_Print();
-         Dmsg1(000, "Error in Python method %s\n", event);
+         Pmsg1(000, "Error in Python method %s\n", event);
       }
    } else {
       stat = 1;
@@ -282,45 +264,6 @@ bail_out:
 }
 
 
-bool my_python_set_prog(JCR *jcr, const char *prog)
-{
-   PyObject *events = (PyObject *)jcr->Python_events;
-   BFILE *bfd = &jcr->ff->bfd;
-   char method[MAX_NAME_LENGTH];
-
-   if (!events) {
-      return false;
-   }
-   bstrncpy(method, prog, sizeof(method));
-   bstrncat(method, "_", sizeof(method));
-   bstrncat(method, "open", sizeof(method));
-   bfd->pio.fo = find_method(events, bfd->pio.fo, method);
-   bstrncpy(method, prog, sizeof(method));
-   bstrncat(method, "_", sizeof(method));
-   bstrncat(method, "read", sizeof(method));
-   bfd->pio.fr = find_method(events, bfd->pio.fr, method);
-   bstrncpy(method, prog, sizeof(method));
-   bstrncat(method, "_", sizeof(method));
-   bstrncat(method, "close", sizeof(method));
-   bfd->pio.fc = find_method(events, bfd->pio.fc, method);
-   return bfd->pio.fo && bfd->pio.fr && bfd->pio.fc;
-}
-
-int my_python_open(BFILE *bfd, const char *fname, int flags, mode_t mode)
-{
-   return -1;
-}
-
-int my_python_close(BFILE *bfd) 
-{
-   return 0;
-}
-
-ssize_t my_python_read(BFILE *bfd, void *buf, size_t count)
-{
-   return -1;
-}
-
 #else
 
 /* Dummy if Python not configured */