Blame SOURCES/0222-report-wrap-more-dump-dir-functions.patch

e7f1a6
From 7b74a0c3f22933da64394972e43bbed4c4fb1b35 Mon Sep 17 00:00:00 2001
e7f1a6
From: Jakub Filak <jfilak@redhat.com>
e7f1a6
Date: Mon, 8 Jun 2015 19:56:41 +0200
e7f1a6
Subject: [PATCH] report: wrap more dump dir functions
e7f1a6
e7f1a6
Signed-off-by: Jakub Filak <jfilak@redhat.com>
e7f1a6
---
e7f1a6
 src/report-python/dump_dir.c | 57 ++++++++++++++++++++++++++++++++++++++++++++
e7f1a6
 1 file changed, 57 insertions(+)
e7f1a6
e7f1a6
diff --git a/src/report-python/dump_dir.c b/src/report-python/dump_dir.c
e7f1a6
index f087563..b4a1e88 100644
e7f1a6
--- a/src/report-python/dump_dir.c
e7f1a6
+++ b/src/report-python/dump_dir.c
e7f1a6
@@ -77,6 +77,42 @@ static PyObject *p_dd_delete(PyObject *pself, PyObject *args)
e7f1a6
     Py_RETURN_NONE;
e7f1a6
 }
e7f1a6
 
e7f1a6
+/* void dd_rename(struct dump_dir *dd, const char *new_name); */
e7f1a6
+static PyObject *p_dd_rename(PyObject *pself, PyObject *args)
e7f1a6
+{
e7f1a6
+    p_dump_dir *self = (p_dump_dir*)pself;
e7f1a6
+    if (!self->dd)
e7f1a6
+    {
e7f1a6
+        PyErr_SetString(ReportError, "dump dir is not open");
e7f1a6
+        return NULL;
e7f1a6
+    }
e7f1a6
+    const char *new_name;
e7f1a6
+    if (!PyArg_ParseTuple(args, "s", &new_name))
e7f1a6
+    {
e7f1a6
+        return NULL;
e7f1a6
+    }
e7f1a6
+    return Py_BuildValue("i", dd_rename(self->dd, new_name));
e7f1a6
+}
e7f1a6
+
e7f1a6
+/* void dd_create_basic_files(struct dump_dir *dd, uid_t uid, const char *chroot_dir); */
e7f1a6
+static PyObject *p_dd_create_basic_files(PyObject *pself, PyObject *args)
e7f1a6
+{
e7f1a6
+    p_dump_dir *self = (p_dump_dir*)pself;
e7f1a6
+    if (!self->dd)
e7f1a6
+    {
e7f1a6
+        PyErr_SetString(ReportError, "dump dir is not open");
e7f1a6
+        return NULL;
e7f1a6
+    }
e7f1a6
+    uid_t uid;
e7f1a6
+    const char *chroot_dir = NULL;
e7f1a6
+    if (!PyArg_ParseTuple(args, "i|z", &uid, &chroot_dir))
e7f1a6
+    {
e7f1a6
+        return NULL;
e7f1a6
+    }
e7f1a6
+    dd_create_basic_files(self->dd, uid, chroot_dir);
e7f1a6
+    Py_RETURN_NONE;
e7f1a6
+}
e7f1a6
+
e7f1a6
 /* int dd_exist(struct dump_dir *dd, const char *path); */
e7f1a6
 static PyObject *p_dd_exist(PyObject *pself, PyObject *args)
e7f1a6
 {
e7f1a6
@@ -160,6 +196,24 @@ static PyObject *p_dd_save_binary(PyObject *pself, PyObject *args)
e7f1a6
     Py_RETURN_NONE;
e7f1a6
 }
e7f1a6
 
e7f1a6
+/* void dd_copy_file(struct dump_dir *dd, const char *name, const char *source_path); */
e7f1a6
+static PyObject *p_dd_copy_file(PyObject *pself, PyObject *args)
e7f1a6
+{
e7f1a6
+    p_dump_dir *self = (p_dump_dir*)pself;
e7f1a6
+    if (!self->dd)
e7f1a6
+    {
e7f1a6
+        PyErr_SetString(ReportError, "dump dir is not open");
e7f1a6
+        return NULL;
e7f1a6
+    }
e7f1a6
+    const char *name;
e7f1a6
+    const char *source_path;
e7f1a6
+    if (!PyArg_ParseTuple(args, "ss", &name, &source_path))
e7f1a6
+    {
e7f1a6
+        return NULL;
e7f1a6
+    }
e7f1a6
+    return Py_BuildValue("i", dd_copy_file(self->dd, name, source_path));
e7f1a6
+}
e7f1a6
+
e7f1a6
 /* int dd_delete_item(struct dump_dir *dd, const char *name); */
e7f1a6
 static PyObject *p_dd_delete_item(PyObject *pself, PyObject *args)
e7f1a6
 {
e7f1a6
@@ -200,10 +254,13 @@ static PyMethodDef p_dump_dir_methods[] = {
e7f1a6
     /* method_name, func, flags, doc_string */
e7f1a6
     { "close"      , p_dd_close, METH_NOARGS, NULL },
e7f1a6
     { "delete"     , p_dd_delete, METH_NOARGS, NULL },
e7f1a6
+    { "rename"     , p_dd_rename, METH_VARARGS, NULL },
e7f1a6
+    { "create_basic_files", p_dd_create_basic_files, METH_VARARGS, NULL },
e7f1a6
     { "exist"      , p_dd_exist, METH_VARARGS, NULL },
e7f1a6
     { "load_text"  , p_dd_load_text, METH_VARARGS, NULL },
e7f1a6
     { "save_text"  , p_dd_save_text, METH_VARARGS, NULL },
e7f1a6
     { "save_binary", p_dd_save_binary, METH_VARARGS, NULL },
e7f1a6
+    { "copy_file"  , p_dd_copy_file, METH_VARARGS, NULL },
e7f1a6
     { "delete_item", p_dd_delete_item, METH_VARARGS, NULL },
e7f1a6
     { NULL }
e7f1a6
 };
e7f1a6
-- 
e7f1a6
1.8.3.1
e7f1a6