summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/marshaller.c24
-rw-r--r--common/marshaller.h3
2 files changed, 27 insertions, 0 deletions
diff --git a/common/marshaller.c b/common/marshaller.c
index cedb321..c967371 100644
--- a/common/marshaller.c
+++ b/common/marshaller.c
@@ -19,11 +19,14 @@
#include <config.h>
#endif
+#include "log.h"
#include "marshaller.h"
#include "mem.h"
#include <string.h>
#include <stdlib.h>
#include <assert.h>
+#include <unistd.h>
+#include <stdio.h>
#ifdef WORDS_BIGENDIAN
#define write_int8(ptr,v) (*((int8_t *)(ptr)) = v)
@@ -84,6 +87,7 @@ struct SpiceMarshaller {
MarshallerItem *items;
MarshallerItem static_items[N_STATIC_ITEMS];
+ int fd;
};
struct SpiceMarshallerData {
@@ -111,6 +115,7 @@ static void spice_marshaller_init(SpiceMarshaller *m,
m->n_items = 0;
m->items_size = N_STATIC_ITEMS;
m->items = m->static_items;
+ m->fd = -1;
}
SpiceMarshaller *spice_marshaller_new(void)
@@ -613,3 +618,22 @@ void *spice_marshaller_add_int8(SpiceMarshaller *m, int8_t v)
write_int8(ptr, v);
return (void *)ptr;
}
+
+void spice_marshaller_add_fd(SpiceMarshaller *m, int fd)
+{
+ spice_assert(m->fd == -1);
+
+ m->fd = dup(fd);
+ if (m->fd == -1) {
+ perror("dup");
+ }
+}
+
+int spice_marshaller_get_fd(SpiceMarshaller *m)
+{
+ int fd = m->fd;
+
+ m->fd = -1;
+
+ return fd;
+}
diff --git a/common/marshaller.h b/common/marshaller.h
index e19c0f6..b698b69 100644
--- a/common/marshaller.h
+++ b/common/marshaller.h
@@ -66,6 +66,9 @@ void *spice_marshaller_add_int8(SpiceMarshaller *m, int8_t v);
void spice_marshaller_set_uint32(SpiceMarshaller *m, void *ref, uint32_t v);
+void spice_marshaller_add_fd(SpiceMarshaller *m, int fd);
+int spice_marshaller_get_fd(SpiceMarshaller *m);
+
SPICE_END_DECLS
#endif