;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2013, 2014, 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu packages libdaemon) #:use-module (guix licenses) #:use-module (guix packages) #:use-module (guix download) #:use-module (guix build-system gnu)) (define-public libdaemon (package (name "libdaemon") (version "0.14") (source (origin (method url-fetch) (uri (list (string-append "mirror://debian/pool/main/libd/libdaemon/libdaemon_" version ".orig.tar.gz") "http://pkgs.fedoraproject.org/repo/pkgs/libdaemon/libdaemon-0.14.tar.gz/509dc27107c21bcd9fbf2f95f5669563/libdaemon-0.14.tar.gz" ;; This used to be the canonical URL but it vanished. ;; See . ;; (string-append ;; "http://0pointer.de/lennart/projects/libdaemon/libdaemon-" ;; version ".tar.gz") )) (sha256 (base32 "0d5qlq5ab95wh1xc87rqrh1vx6i8lddka1w3f1zcqvcqdxgyn8zx")) (file-name (string-append name "-" version ".tar.gz")))) (build-system gnu-build-sy#include "references.hh" #include "hash.hh" #include "util.hh" #include "archive.hh" #include <map> #include <cstdlib> namespace nix { static unsigned int refLength = 32; /* characters */ static void search(const unsigned char * s, unsigned int len, StringSet & hashes, StringSet & seen) { static bool initialised = false; static bool isBase32[256]; if (!initialised) { for (unsigned int i = 0; i < 256; ++i) isBase32[i] = false; for (unsigned int i = 0; i < base32Chars.size(); ++i) isBase32[(unsigned char) base32Chars[i]] = true; initialised = true; } for (unsigned int i = 0; i + refLength <= len; ) { int j; bool match = true; for (j = refLength - 1; j >= 0; --j) if (!isBase32[(unsigned char) s[i + j]]) { i += j + 1; match = false; break; } if (!match) continue; string ref((const char *) s + i, refLength); if (hashes.find(ref) != hashes.end()) { debug(format("found reference to `%1%' at offset `%2%'") % ref % i); seen.insert(ref); hashes.erase(ref); } ++i; } } struct RefScanSink : Sink { HashSink hashSink; StringSet hashes; StringSet seen; string tail; RefScanSink() : hashSink(htSHA256) { } void operator () (const unsigned char * data, size_t len); }; void RefScanSink::operator () (const unsigned char * data, size_t len) { hashSink(data,