summaryrefslogtreecommitdiff
path: root/xd.ser
blob: 7dd91c6928e6f36a44f3134b4272d28b60c108cd (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
133
134
135
136
137
138
;; -*- Emacs-Lisp -*-

(defmodule xd 3 "xdelta.h" nil)

(defimport "libedsio/edsio.ser")

(defsertype XdeltaChecksum 1
  ((high uint16)
   (low  uint16)
   )
  ()
  )

(defsertype XdeltaIndex 2
  ((file_len uint)
   (file_md5 (bytes 16))
   (index    (array XdeltaChecksum))
   )
  ()
  )

(defsertype XdeltaSourceInfo 3
  ((name string)
   (md5 (bytes 16))
   (len uint)
   (isdata     boolean) ;;; if true, then its source index is 0 and it is the data segment
   (sequential boolean) ;;; if true, then offset field is not persistent, but instead
                        ;;; recomputed when loaded as the sum of
			;;; previous instruction's length fields, to
			;;; indicate a sequential read
   )
  ("guint32       position"
   "guint32       copies"
   "guint32       copy_length"
   "FileHandle   *in")
  )

(defsertype XdeltaControl 7
  ((to_md5         (bytes 16))
   (to_len         uint)
   (has_data       boolean)
   (source_info    (array (ptr XdeltaSourceInfo)))
   (inst           (array XdeltaInstruction))
   )
  ("GArray    *inst_array"
   "GPtrArray *source_info_array"
   )
  )

(defsertype XdeltaInstruction 8
  ((index  uint)
   (offset uint)
   (length uint)
   )
  ("guint32 output_start")
  )

;; rsync stuff

(defsertype RsyncIndexElt 9
  ((md5   (bytes 16))
   (cksum XdeltaChecksum)
   )
  ("SerialRsyncIndexElt* next"
   "gint match_offset")
  )

(defsertype RsyncIndex 10
  ((seg_len  uint)
   (file_len uint)
   (file_md5 (bytes 16))
   (index    (array RsyncIndexElt))
   )
  ("SerialRsyncIndexElt** table"
   "guint table_size")
  )

;; backward compat, these are the 1.0 defs

(defsertype Version0SourceInfo 4
  ((md5 (bytes 16))
   (real_md5 (bytes 16))
   (length uint)
   )
  ()
  )

(defsertype Version0Control 5
  ((normalized boolean)
   (data_len   uint)
   (to_info    Version0SourceInfo)
   (source_info (array (ptr Version0SourceInfo)))
   (inst        (array Version0Instruction))
   )
  ("GArray    *inst_array"
   "GPtrArray *source_info_array"
   )
  )

(defsertype Version0Instruction 6
  ((offset uint)
   (length uint)
   )
  ("guint8 type"  ;; these two fields get packed into length
   "guint8 index"
   )
  )

;; events

(defetype handle "FileHandle*")

(defevent TooFewSources Error () ()
  "Too few input sources")

(defevent TooManySources Error () ()
  "Too many input sources")

(defevent OutOfRangeSourceIndex Error ((index int)) ()
  "Instruction references out-of-range source index: ${INDEX}")

(defevent InvalidControl Error () ()
  "Delta control is corrupt")

(defevent InvalidRsyncCache Error () ()
  "The rsync checksum cache is corrupt")

(defevent IncompatibleDelta Error () ()
  "The delta was not produced according by the `xdelta delta' command")

(defevent StreamChecksumFailed Error ((stream handle) (expected string) (received string)) ()
  "${STREAM}: Checksum validation failed, expected: ${EXPECTED}, received: ${RECEIVED}")

(defevent StreamLengthFailed Error ((stream handle) (expected int) (received int)) ()
  "${STREAM}: Length validation failed, expected: ${EXPECTED}, received: ${RECEIVED}")

(defevent BackwardCompatibilityMode Information ((version string)) ()
  "Reading a version ${VERSION} delta control")