@@ 36,7 36,7 @@ enum qso_ns {
};
/* pack & unpack whole struct qso */
-extern struct buffer *qso_pack_hlq(const struct qso *qso);
+extern struct buffer *qso_pack_hlq(const struct qso *qso, int ver);
extern int qso_unpack_hlq(struct qso *qso, const void *buf, size_t len);
/* partial parsing helpers */
@@ 81,9 81,9 @@ static const char *get_ns_name(enum qso_
panic("unknown hlq namespace %d", ns);
}
-static int hlq_append_header(struct buffer *buf, const struct xuuid *uuid)
+static int hlq_append_header(struct buffer *buf, const struct xuuid *uuid,
+ int ver)
{
- const int ver = HLQ_VERSION_CUR;
const uint64_t now = gettime();
char id[XUUID_PRINTABLE_STRING_LENGTH];
char rest[32];
@@ 320,8 320,8 @@ static int hlq_append_kv_blob(struct buf
return buffer_append_cstr(buf, "blobend\n");
}
-static int hlq_append_kv(struct buffer *buf, enum qso_ns ns, const char *key,
- struct val *val)
+static int hlq_append_kv(struct buffer *buf, int ver, enum qso_ns ns,
+ const char *key, struct val *val)
{
if (!val)
return hlq_append_kv_null(buf, ns, key);
@@ 349,7 349,7 @@ static int hlq_append_kv(struct buffer *
get_ns_name(ns), key, val->type, val_typename(val->type));
}
-struct buffer *qso_pack_hlq(const struct qso *qso)
+struct buffer *qso_pack_hlq(const struct qso *qso, int ver)
{
const struct {
enum qso_ns ns;
@@ 364,13 364,16 @@ struct buffer *qso_pack_hlq(const struct
size_t i, j;
int ret;
+ if (ver == HLQ_VERSION_USE_DEFAULT)
+ ver = HLQ_VERSION_CUR;
+
time_set_now(&now);
buf = buffer_alloc(1024);
if (IS_ERR(buf))
return buf;
- ret = hlq_append_header(buf, &qso->uuid);
+ ret = hlq_append_header(buf, &qso->uuid, ver);
if (ret)
goto err;
@@ 386,7 389,7 @@ struct buffer *qso_pack_hlq(const struct
struct val *val = (v); \
int ret; \
\
- ret = hlq_append_kv((buf), (ns), (k), val); \
+ ret = hlq_append_kv((buf), (ver), (ns), (k), val); \
val_putref(val); \
ret; \
})
@@ 95,7 95,7 @@ int qso_save(const struct qso *qso, int
ASSERT(!xuuid_is_null(&qso->uuid));
- buf = qso_pack_hlq(qso);
+ buf = qso_pack_hlq(qso, HLQ_VERSION_USE_DEFAULT);
if (IS_ERR(buf))
return PTR_ERR(buf);