1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
--- src/plugins/filed/python-fd.c 2019-12-29 01:20:40.033054000 -0500
+++ src/plugins/filed/python-fd.c 2019-12-29 01:27:28.921617000 -0500
@@ -37,6 +37,14 @@
#error "Need at least Python version 2.6 or newer"
#endif
+#if (PY_VERSION_HEX > 0x03050000)
+#define PyInt_AsLong PyLong_AsLong
+#define PyInt_FromLong PyLong_FromLong
+#define PyString_AsString PyUnicode_AsUTF8
+#define PyString_FromString PyUnicode_FromString
+#define PyString_Check PyBytes_Check
+#endif
+
static const int dbglvl = 150;
#define PLUGIN_LICENSE "Bareos AGPLv3"
@@ -162,6 +170,20 @@
*/
static PyThreadState *mainThreadState;
+#if (PY_VERSION_HEX > 0x03050000)
+static struct PyModuleDef BareosFDModuleDef = {
+ PyModuleDef_HEAD_INIT,
+ "bareosfd",
+ NULL,
+ -1,
+ BareosFDMethods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+#endif
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -1225,7 +1247,11 @@
/*
* Make our callback methods available for Python.
*/
+#if (PY_VERSION_HEX > 0x03050000)
+ p_ctx->pInstance = PyModule_Create(&BareosFDModuleDef);
+#else
p_ctx->pInstance = Py_InitModule("bareosfd", BareosFDMethods);
+#endif
/*
* Fill in the slots of PyRestoreObject
@@ -2702,8 +2728,11 @@
}
case bVarFileSeen: {
char *value;
-
+#if (PY_VERSION_HEX > 0x03050000)
+ value = bstrdup(PyString_AsString(pyValue));
+#else
value = PyString_AsString(pyValue);
+#endif
if (value) {
retval = bfuncs->setBareosValue(ctx, (bVariable)var, value);
}
@@ -3090,7 +3119,11 @@
sp.type = pSavePkt->type;
if (pSavePkt->fname) {
if (PyString_Check(pSavePkt->fname)) {
+#if (PY_VERSION_HEX > 0x03050000)
+ sp.fname = bstrdup(PyString_AsString(pSavePkt->fname));
+#else
sp.fname = PyString_AsString(pSavePkt->fname);
+#endif
} else {
goto bail_out;
}
@@ -3099,7 +3132,11 @@
}
if (pSavePkt->link) {
if (PyString_Check(pSavePkt->link)) {
+#if (PY_VERSION_HEX > 0x03050000)
+ sp.link = bstrdup(PyString_AsString(pSavePkt->link));
+#else
sp.link = PyString_AsString(pSavePkt->link);
+#endif
} else {
goto bail_out;
}
@@ -3142,7 +3179,11 @@
*/
if (pSavePkt->fname) {
if (PyString_Check(pSavePkt->fname)) {
+#if (PY_VERSION_HEX > 0x03050000)
+ sp.fname = bstrdup(PyString_AsString(pSavePkt->fname));
+#else
sp.fname = PyString_AsString(pSavePkt->fname);
+#endif
} else {
goto bail_out;
}
@@ -3219,7 +3260,11 @@
return (char *)"";
}
+#if (PY_VERSION_HEX > 0x03050000)
+ return bstrdup(PyString_AsString(object));
+#else
return PyString_AsString(object);
+#endif
}
static inline char *PyGetByteArrayValue(PyObject *object)
|