diff options
| author | Michael Vogt <egon@bottom> | 2006-11-03 22:07:09 +0100 |
|---|---|---|
| committer | Michael Vogt <egon@bottom> | 2006-11-03 22:07:09 +0100 |
| commit | a231ca12f5fbb6adb55142973eb4d7a284763ace (patch) | |
| tree | 045177085bc0326d3428ab770572e22662c51bf6 | |
| parent | 036d3715da9858ef9c6fdd832934bf64359849bf (diff) | |
| parent | 8d79b99c1a3338e31e8def858cee3209824ae8bf (diff) | |
| download | python-apt-a231ca12f5fbb6adb55142973eb4d7a284763ace.tar.gz | |
* merged with mainline
| -rw-r--r-- | debian/changelog | 4 | ||||
| -rw-r--r-- | python/apt_pkgmodule.cc | 39 |
2 files changed, 42 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog index d8ad9da4..b210fb24 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ python-apt (0.6.19exp1) experimental; urgency=low * doc/examples/print_uris.py: - added a example to show how the indexfile.ArchiveURI() can be used with binary packages + * python/apt_pkgmodule.cc: + - export sha256 generation [ Otavio Salvador ] * apt/cache.py: @@ -13,7 +15,7 @@ python-apt (0.6.19exp1) experimental; urgency=low * python/depcache.cc: - "IsGarbage()" method added (to support auto-mark) - -- Michael Vogt <mvo@debian.org> Wed, 26 Jul 2006 17:30:08 +0200 + -- Michael Vogt <mvo@debian.org> Wed, 26 Jul 2006 18:57:23 +0200 python-apt (0.6.18-0.2) unstable; urgency=low diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index e73628c3..b1c5c2a5 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -19,6 +19,7 @@ #include <apt-pkg/tagfile.h> #include <apt-pkg/md5.h> #include <apt-pkg/sha1.h> +#include <apt-pkg/sha256.h> #include <apt-pkg/init.h> #include <apt-pkg/pkgsystem.h> @@ -236,6 +237,43 @@ static PyObject *sha1sum(PyObject *Self,PyObject *Args) return 0; } /*}}}*/ +// sha256sum - Compute the sha1sum of a file or string /*{{{*/ +// --------------------------------------------------------------------- +static char *doc_sha256sum = "sha256sum(String) -> String or sha256sum(File) -> String"; +static PyObject *sha256sum(PyObject *Self,PyObject *Args) +{ + PyObject *Obj; + if (PyArg_ParseTuple(Args,"O",&Obj) == 0) + return 0; + + // Digest of a string. + if (PyString_Check(Obj) != 0) + { + SHA256Summation Sum; + Sum.Add(PyString_AsString(Obj)); + return CppPyString(Sum.Result().Value()); + } + + // Digest of a file + if (PyFile_Check(Obj) != 0) + { + SHA256Summation Sum; + int Fd = fileno(PyFile_AsFile(Obj)); + struct stat St; + if (fstat(Fd,&St) != 0 || + Sum.AddFD(Fd,St.st_size) == false) + { + PyErr_SetFromErrno(PyExc_SystemError); + return 0; + } + + return CppPyString(Sum.Result().Value()); + } + + PyErr_SetString(PyExc_TypeError,"Only understand strings and files"); + return 0; +} + /*}}}*/ // init - 3 init functions /*{{{*/ // --------------------------------------------------------------------- static char *doc_Init = @@ -370,6 +408,7 @@ static PyMethodDef methods[] = // Stuff {"md5sum",md5sum,METH_VARARGS,doc_md5sum}, {"sha1sum",sha1sum,METH_VARARGS,doc_sha1sum}, + {"sha256sum",sha256sum,METH_VARARGS,doc_sha256sum}, // Strings {"CheckDomainList",StrCheckDomainList,METH_VARARGS,"CheckDomainList(String,String) -> Bool"}, |
