summaryrefslogtreecommitdiff
path: root/ftparchive/sources.cc
diff options
context:
space:
mode:
authorMichael Vogt <mvo@debian.org>2015-08-18 11:54:05 +0200
committerMichael Vogt <mvo@debian.org>2015-08-18 11:54:05 +0200
commit21248c0f00ee71412dbadc6ebf84011cf974346d (patch)
tree7dc1f5904399482d2128765b5b86d57a4ac5b3e1 /ftparchive/sources.cc
parente5f34ad3b043abf033c1626eb8449b75955d6760 (diff)
parent4fc6b7570c3e97b65c118b58cdf6729fa94c9b03 (diff)
Merge branch 'debian/experimental' into feature/srv-records
Conflicts: cmdline/apt-helper.cc cmdline/makefile
Diffstat (limited to 'ftparchive/sources.cc')
-rw-r--r--ftparchive/sources.cc60
1 files changed, 60 insertions, 0 deletions
diff --git a/ftparchive/sources.cc b/ftparchive/sources.cc
new file mode 100644
index 000000000..ab976b490
--- /dev/null
+++ b/ftparchive/sources.cc
@@ -0,0 +1,60 @@
+#include <string>
+#include <sstream>
+
+// for memcpy
+#include <cstring>
+
+#include <apt-pkg/error.h>
+#include <apt-pkg/gpgv.h>
+
+#include "sources.h"
+
+bool DscExtract::TakeDsc(const void *newData, unsigned long long newSize)
+{
+ if (newSize == 0)
+ {
+ // adding two newlines 'off record' for pkgTagSection.Scan() calls
+ Data = "\n\n";
+ Length = 0;
+ return true;
+ }
+
+ Data = std::string((const char*)newData, newSize);
+ // adding two newlines 'off record' for pkgTagSection.Scan() calls
+ Data.append("\n\n");
+ Length = newSize;
+
+ return true;
+}
+
+bool DscExtract::Read(std::string FileName)
+{
+ Data.clear();
+ Length = 0;
+
+ FileFd F;
+ if (OpenMaybeClearSignedFile(FileName, F) == false)
+ return false;
+
+ IsClearSigned = (FileName != F.Name());
+
+ std::ostringstream data;
+ char buffer[1024];
+ do {
+ unsigned long long actual = 0;
+ if (F.Read(buffer, sizeof(buffer)-1, &actual) == false)
+ return _error->Errno("read", "Failed to read dsc file %s", FileName.c_str());
+ if (actual == 0)
+ break;
+ Length += actual;
+ buffer[actual] = '\0';
+ data << buffer;
+ } while(true);
+
+ // adding two newlines 'off record' for pkgTagSection.Scan() calls
+ data << "\n\n";
+ Data = data.str();
+ return true;
+}
+
+