summaryrefslogtreecommitdiff
path: root/python/apt_instmodule.cc
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2015-07-05 22:06:22 +0300
committerIgor Pashev <pashev.igor@gmail.com>2015-07-05 22:06:22 +0300
commit622812485150fa7864910ee2f710d5aab2fa9e6d (patch)
treeb3bc4fd72bb80e74ba5a60d8b3d47e610dff012e /python/apt_instmodule.cc
parent798846ab8337471998b0a4d796d6d409453faa7d (diff)
parentfdd173dd444098ed533cbcd541a7f10f228bc47e (diff)
downloadpython-apt-622812485150fa7864910ee2f710d5aab2fa9e6d.tar.gz
Merge git://anonscm.debian.org/apt/python-apt
Conflicts: debian/changelog python/apt_pkgmodule.cc
Diffstat (limited to 'python/apt_instmodule.cc')
-rw-r--r--python/apt_instmodule.cc143
1 files changed, 1 insertions, 142 deletions
diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc
index 732f1bd0..8094550a 100644
--- a/python/apt_instmodule.cc
+++ b/python/apt_instmodule.cc
@@ -23,148 +23,7 @@
#include <Python.h>
/*}}}*/
-#ifdef COMPAT_0_7
-
-// debExtractControl - Exctract an arbitary control member /*{{{*/
-// ---------------------------------------------------------------------
-/* This is a common operation so this function will stay, but others that
- expose the full range of the apt-inst .deb processing will join it some
- day. */
-static char *doc_debExtractControl =
-"deb_extract_control(file[,member]) -> String\n"
-"Returns the indicated file from the control tar. The default is 'control'\n";
-static PyObject *debExtractControl(PyObject *Self,PyObject *Args)
-{
- char *Member = "control";
- PyObject *File;
- if (PyArg_ParseTuple(Args,"O|s",&File,&Member) == 0)
- return 0;
-
- // Subscope makes sure any clean up errors are properly handled.
- PyObject *Res = 0;
- {
- // Open the file and associate the .deb
- int fileno = PyObject_AsFileDescriptor(File);
- if (fileno == -1)
- return 0;
- FileFd Fd(fileno,false);
- debDebFile Deb(Fd);
- if (_error->PendingError() == true)
- return HandleErrors();
-
- debDebFile::MemControlExtract Extract(Member);
- if (Extract.Read(Deb) == false)
- return HandleErrors();
-
- // Build the return result
-
- if (Extract.Control == 0)
- {
- Py_INCREF(Py_None);
- Res = Py_None;
- }
- else
- Res = PyString_FromStringAndSize(Extract.Control,Extract.Length+2);
- }
-
- return HandleErrors(Res);
-}
- /*}}}*/
-
-// debExtractArchive - Exctract the archive /*{{{*/
-// ---------------------------------------------------------------------
-static char *doc_debExtractArchive =
-"deb_extract_archive(File,rootdir) -> Bool\n"
-"Extracts the Archive into the given root dir";
-static PyObject *debExtractArchive(PyObject *Self,PyObject *Args)
-{
- char *Rootdir = NULL;
- char cwd[512];
- PyObject *File;
- if (PyArg_ParseTuple(Args,"O|s",&File,&Rootdir) == 0)
- return 0;
-
- // Subscope makes sure any clean up errors are properly handled.
- bool res = false;
- {
- if(Rootdir != NULL)
- {
- getcwd(cwd, sizeof(cwd));
- chdir(Rootdir);
- }
-
- // Open the file and associate the .deb
- int fileno = PyObject_AsFileDescriptor(File);
- if (fileno == -1)
- return 0;
- FileFd Fd(fileno,false);
- debDebFile Deb(Fd);
- if (_error->PendingError() == true) {
- if (Rootdir != NULL)
- chdir (cwd);
- return HandleErrors();
- }
-
- // extracts relative to the current dir
- pkgDirStream Extract;
- res = Deb.ExtractArchive(Extract);
-
- if (Rootdir != NULL)
- chdir (cwd);
- if (res == false)
- return HandleErrors(PyBool_FromLong(res));
- }
- return HandleErrors(PyBool_FromLong(res));
-}
- /*}}}*/
-// arFindMember - Find member in AR archive /*{{{*/
-// ---------------------------------------------------------------------
-static char *doc_arCheckMember =
-"ar_check_member(file, membername) -> Bool\n";
-static PyObject *arCheckMember(PyObject *Self,PyObject *Args)
-{
- char *Member = NULL;
- bool res = false;
- PyObject *File;
- if (PyArg_ParseTuple(Args,"Os",&File,&Member) == 0)
- return 0;
-
- // Open the file and associate the .deb
- int fileno = PyObject_AsFileDescriptor(File);
- if (fileno == -1)
- return 0;
- FileFd Fd(fileno,false);
- ARArchive AR(Fd);
- if (_error->PendingError() == true)
- return HandleErrors();
-
- if(AR.FindMember(Member) != 0)
- res = true;
-
- return HandleErrors(PyBool_FromLong(res));
-}
- /*}}}*/
-
-// initapt_inst - Core Module Initialization /*{{{*/
-// ---------------------------------------------------------------------
-/* */
-static PyMethodDef methods[] =
-{
- // access to ar files
- {"arCheckMember", arCheckMember, METH_VARARGS, doc_arCheckMember},
-
- // access to deb files
- {"debExtractControl",debExtractControl,METH_VARARGS,doc_debExtractControl},
- {"debExtractArchive",debExtractArchive,METH_VARARGS,doc_debExtractArchive},
-
- // access to tar streams
- {"tarExtract",tarExtract,METH_VARARGS,doc_tarExtract},
- {"debExtract",debExtract,METH_VARARGS,doc_debExtract},
- {}
-};
-#else
static PyMethodDef *methods = 0;
-#endif // defined(COMPAT_0_7)
static const char *apt_inst_doc =
@@ -193,7 +52,7 @@ static struct PyModuleDef moduledef = {
extern "C" PyObject * PyInit_apt_inst()
#else
extern "C" void initapt_inst()
-#define RETURN(x)
+#define RETURN(x) return
#endif
{
#if PY_MAJOR_VERSION >= 3