aboutsummaryrefslogtreecommitdiff
path: root/nix/libutil/serialise.hh
blob: 6a6f028aa652f984262258ed37ac8b6d680f1a54 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#pragma once

#include "types.hh"


namespace nix {


/* Abstract destination of binary data. */
struct Sink 
{
    virtual ~Sink() { }
    virtual void operator () (const unsigned char * data, size_t len) = 0;
};


/* A buffered abstract sink. */
struct BufferedSink : Sink
{
    size_t bufSize, bufPos;
    unsigned char * buffer;

    BufferedSink(size_t bufSize = 32 * 1024)
        : bufSize(bufSize), bufPos(0), buffer(0) { }
    ~BufferedSink();

    void operator () (const unsigned char * data, size_t len);
    
    void flush();
    
    virtual void write(const unsigned char * data, size_t len) = 0;
};


/* Abstract source of binary data. */
struct Source
{
    virtual ~Source() { }
    
    /* Store exactly ‘len’ bytes in the buffer pointed to by ‘data’.
       It blocks until all the requested data is available, or throws
       an error if it is not going to be available.   */
    void operator () (unsigned char * data, size_t len);

    /* Store up to ‘len’ in the buffer pointed to by ‘data’, and
       return the number of bytes stored.  If blocks until at least
       one byte is available. */
    virtual size_t read(unsigned char * data, size_t len) = 0;
};


/* A buffered abstract source. */
struct BufferedSource : Source
{
    size_t bufSize, bufPosIn, bufPosOut;
    unsigned char * buffer;

    BufferedSource(size_t bufSize = 32 * 1024)
        : bufSize(bufSize), bufPosIn(0), bufPosOut(0), buffer(0) { }
    ~BufferedSource();
    
    size_t read(unsigned char * data, size_t len);
    
    /* Underlying read call, to be overridden. */
    virtual size_t readUnbuffered(unsigned char * data, size_t len) = 0;

    bool hasData();
};


/* A sink that writes data to a file descriptor. */
struct FdSink : BufferedSink
{
    int fd;
    bool warn;
    size_t written;

    FdSink() : fd(-1), warn(false), written(0) { }
    FdSink(int fd) : fd(fd), warn(false), written(0) { }
    ~FdSink();
    
    void write(const unsigned char * data, size_t len);
};


/* A source that reads data from a file descriptor. */
struct FdSource : BufferedSource
{
    int fd;
    FdSource() : fd(-1) { }
    FdSource(int fd) : fd(fd) { }
    size_t readUnbuffered(unsigned char * data, size_t len);
};


/* A sink that writes data to a string. */
struct StringSink : Sink
{
    string s;
    void operator () (const unsigned char * data, size_t len);
};


/* A source that reads data from a string. */
struct StringSource : Source
{
    const string & s;
    size_t pos;
    StringSource(const string & _s) : s(_s), pos(0) { }
    size_t read(unsigned char * data, size_t len);    
};


void writePadding(size_t len, Sink & sink);
void writeInt(unsigned int n, Sink & sink);
void writeLongLong(unsigned long long n, Sink & sink);
void writeString(const unsigned char * buf, size_t len, Sink & sink);
void writeString(const string & s, Sink & sink);
template<class T> void writeStrings(const T & ss, Sink & sink);

void readPadding(size_t len, Source & source);
unsigned int readInt(Source & source);
unsigned long long readLongLong(Source & source);
size_t readString(unsigned char * buf, size_t max, Source & source);
string readString(Source & source);
template<class T> T readStrings(Source & source);


MakeError(SerialisationError, Error)


}
021-09-12 13:46:14 +0200'>2021-09-12gnu: libxmlplusplus: Fix build.Felix Gruber * gnu/packages/xml.scm (libxmlplusplus)[inputs]: Replace glibmm with glibmm-2.64. Signed-off-by: Guillaume Le Vaillant <glv@posteo.net> 2021-09-12gnu: ruby-tins: Update to 1.29.1.Efraim Flashner * gnu/packages/ruby.scm (ruby-tins): Update to 1.29.1. [propagated-inputs]: Add ruby-sync. 2021-09-12gnu: Add ruby-sync.Efraim Flashner * gnu/packages/ruby.scm (ruby-sync): New variable. 2021-09-12gnu: ruby-multi-json: Update to 1.15.0.Efraim Flashner * gnu/packages/ruby.scm (ruby-multi-json): Update to 1.15.0. [arguments]: Remove custom 'remove-signing-key-reference phase. Add phase to adjust test suite. [native-inputs]: Remove bundler, ruby-yard. 2021-09-12gnu: ruby-json-pure: Update to 2.3.1.Efraim Flashner * gnu/packages/ruby.scm (ruby-json-pure): Update to 2.3.1. [arguments]: Remove custom 'regenerate-gemspec, 'fix-json-java.gemspec phases. Remove part of custom 'fix-rakefile phase. [native-inputs]: Add which. 2021-09-12gnu: ruby-mocha: Update to 1.13.0.Efraim Flashner * gnu/packages/ruby.scm (ruby-mocha): Update to 1.13.0. [home-page]: Adjust to new upstream home-page. 2021-09-12gnu: ruby-pandoc-ruby: Adjust test suite.Efraim Flashner * gnu/packages/ruby.scm (ruby-pandoc-ruby)[arguments]: Adjust test suite to change in ruby behavior and the test suite. 2021-09-12gnu: gnome-maps: Remove obsolete phase.Jonathan Brielmaier * gnu/packages/geo.scm (gnome-maps)[arguments]: Remove 'fix-broken-tests phase as the tests pass now. 2021-09-12gnu: libnet6: Fix build.Felix Gruber * gnu/packages/gobby.scm (libnet6)[inputs]: replace libsigc++ with libsigc++-2. Signed-off-by: Guillaume Le Vaillant <glv@posteo.net> 2021-09-12gnu: chocolate-doom: Fix compilation with GCC 10.Felix Gruber * gnu/packages/games.scm (chocolate-doom)[arguments]: Pass '-fcommon' to CFLAGS. Signed-off-by: Guillaume Le Vaillant <glv@posteo.net> 2021-09-12gnu: global: Fix wrap phase.Efraim Flashner * gnu/packages/code.scm (global)[arguments]: Wrap python script with GUIX_PYTHONPATH. 2021-09-11gnu: librsvg: Simplify custom phase.Efraim Flashner * gnu/packages/gnome.scm (librsvg)[arguments]: Adjust custom 'gnu-configure phase to use more default arguments. 2021-09-11gnu: Don't use older versions of rust.Efraim Flashner * gnu/packages/crates-io.scm (rust-cxx-1, rust-cxx-build-1, rust-cxx-gen-0.7, rust-cxxbridge-macro-1, rust-postgres-0.19, rust-rust-decimal-1,rust-socket2-0.4, rust-tokio-postgres-0.7)[arguments]: Remove rust flag. * gnu/packages/gnome.scm (librsvg)[arguments]: Same. * gnu/packages/rust-apps.scm (hyperfine)[arguments]: Same. * gnu/packages/syndication.scm (newsboat)[arguments]: Same. 2021-09-11gnu: xkbcomp-intermediate: Export variable.Ludovic Courtès * gnu/packages/xorg.scm (xkbcomp-intermediate): Make public. [properties]: New field. (xkbcomp)[properties]: New field. 2021-09-11gnu: netcdf-parallel-openmpi: Allow compilation with GCC 10.Ludovic Courtès * gnu/packages/maths.scm (netcdf)[source]: Add 'modules' and 'snippet'. 2021-09-11gnu: idutils: Skip failing Gnulib tests.Ludovic Courtès * gnu/packages/idutils.scm (idutils)[arguments]: New field. 2021-09-11gnu: mpc123: Allow compilation with GCC 10.Ludovic Courtès * gnu/packages/mp3.scm (mpc123)[arguments]: In 'configure' phase, call 'setenv'. 2021-09-11gnu: mkvtoolnix: Fix build.Guillaume Le Vaillant * gnu/packages/video.scm (mkvtoolnix)[arguments]: Fix 'add-googletest' phase. 2021-09-11gnu: fifo-map: Fix build.Guillaume Le Vaillant * gnu/packages/cpp.scm (fifo-map)[arguments]: Fix 'install' phase. 2021-09-11gnu: electron-cash: Add missing input.Guillaume Le Vaillant * gnu/packages/finance.scm (electron-cash)[inputs]: Add python-qdarkstyle. [arguments]: Add 'relax-requirements' phase. 2021-09-11gnu: python-stem: Fix tests wth python 3.9.Guillaume Le Vaillant * gnu/packages/python-xyz.scm (python-stem)[arguments]: Add 'fix-tests' phase. 2021-09-11gnu: python-faker: Update to 8.12.1.Guillaume Le Vaillant * gnu/packages/python-xyz.scm (python-faker): Update to 8.12.1. 2021-09-11gnu: python-random2: Fix building with python 3.9.Guillaume Le Vaillant * gnu/packages/patches/python-random2-getrandbits-test.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. * gnu/packages/python-xyz.scm (python-random2)[source]: Use it. 2021-09-11gnu: kicad: Fix build.Guillaume Le Vaillant * gnu/packages/engineering.scm (kicad)[arguments]: Add 'fix-python-detection' and 'add-missing-include' phases. 2021-09-11gnu: psm: Fix building with GCC 10.Felix Gruber I had to copy all the CFLAGS that were originally defined by the Makefile as they were otherwise all replaced by '-fcommon'. * gnu/packages/linux.scm (psm)[arguments]: Pass '-fcommon' to CFLAGS. Signed-off-by: Guillaume Le Vaillant <glv@posteo.net> 2021-09-11gnu: materialdecoration: Fix build.Guillaume Le Vaillant * gnu/packages/qt.scm (materialdecoration)[arguments]: Use gexp for 'configure-flags'. 2021-09-11gnu: sdrangel: Fix build.Guillaume Le Vaillant * gnu/packages/radio.scm (sdrangel)[arguments]: Replace references to '%build-inputs' by gexp. 2021-09-11gnu: opencv: Fix build.Guillaume Le Vaillant * gnu/packages/image-processing.scm (opencv)[arguments]: Fix 'unpack-submodule-source' and 'add-ilmbase-include-path' phases. 2021-09-10gnu: gnome-calculator: Update to 3.36.0.Jonathan Brielmaier * gnu/packages/gnome.scm (gnome-calculator): Update to 3.36.0. 2021-09-10gnu: tbb: Update to 2021.3.0.Guillaume Le Vaillant * gnu/packages/tbb.scm (tbb): Update to 2021.3.0. [source]: Update repository URL. Remove snippet. [build-system]: Switch to 'cmake-build-system'. [arguments]: Add 'configure-flags'. Remove 'make-flags'. Remove 'fail-on-test-errors' phase. Remove custom 'configure' and 'install' phases. 2021-09-10gnu: babl: Don't build documentation.Jonathan Brielmaier It would require `scp` from openssh and it was not built before. * gnu/packages/gimp.scm (babl)[arguments]: Add `-Dwith-docs=false` to the configure flags. 2021-09-10gnu: qmapshack: Remove obsolete phase.Guillaume Le Vaillant QTWEBENGINEPROCESS_PATH is now set by the 'qt-wrap' phase. * gnu/packages/geo.scm (qmapshack)[arguments]: Remove 'wrap' phase.