+ struct iscz1_code_info *p = (struct iscz1_code_info *) vp;
+ struct it_key tkey;
+ zint d;
+ int i;
+
+ /* 1
+ 3, 2, 9, 12
+ 3, 2, 10, 2
+ 4, 1
+
+ if diff is 0, then there is more ...
+ if diff is non-zero, then _may_ be more
+ */
+ memcpy (&tkey, *src, sizeof(struct it_key));
+
+ /* deal with leader + delta encoding .. */
+ d = 0;
+ assert(tkey.len > 0 && tkey.len <= 4);
+ for (i = 0; i < tkey.len; i++)
+ {
+ d = tkey.mem[i] - p->key.mem[i];
+ if (d || i == tkey.len-1)
+ { /* all have been equal until now, now make delta .. */
+ p->key.mem[i] = tkey.mem[i];
+ if (d > 0)
+ {
+ iscz1_encode_int (i + (tkey.len << 3) + 64, dst);
+ i++;
+ iscz1_encode_int (d, dst);
+ }
+ else
+ {
+ iscz1_encode_int (i + (tkey.len << 3), dst);
+ }
+ break;
+ }
+ }
+ /* rest uses absolute encoding ... */
+ for (; i < tkey.len; i++)
+ {
+ iscz1_encode_int (tkey.mem[i], dst);
+ p->key.mem[i] = tkey.mem[i];
+ }
+ (*src) += sizeof(struct it_key);
+}
+
+void iscz1_decode (void *vp, char **dst, const char **src)
+{
+ struct iscz1_code_info *p = (struct iscz1_code_info *) vp;
+ int i;
+
+ int leader = (int) iscz1_decode_int ((unsigned char **) src);
+ i = leader & 7;
+ if (leader & 64)
+ p->key.mem[i] += iscz1_decode_int ((unsigned char **) src);
+ else
+ p->key.mem[i] = iscz1_decode_int ((unsigned char **) src);
+ p->key.len = (leader >> 3) & 7;
+ while (++i < p->key.len)
+ p->key.mem[i] = iscz1_decode_int ((unsigned char **) src);
+ memcpy (*dst, &p->key, sizeof(struct it_key));
+ (*dst) += sizeof(struct it_key);