Browse code

added functions to return serialized stream into existing buffer

Vaclav Kubart authored on 19/02/2007 15:09:15
Showing 3 changed files
... ...
@@ -1,3 +1,8 @@
1
+2007-01-18
2
+	* added functions to return serialized stream into existing buffer
3
+
4
+...
5
+
1 6
 2006-11-06
2 7
 	* bug correction - output of get_pres_rules initialized - reported by Bogdan
3 8
 
... ...
@@ -55,6 +55,18 @@ int get_serialized_sstream(sstream_t *ss, str_t *dst)
55 55
 	else return -1; /* no output for input stream */
56 56
 }
57 57
 
58
+int get_serialized_sstream_data(sstream_t *ss, char *dst)
59
+{
60
+	if (ss->type == sstream_out) return dstr_get_data(&ss->out, dst);
61
+	else return -1; /* no output for input stream */
62
+}
63
+
64
+int get_serialized_sstream_len(sstream_t *ss)
65
+{
66
+	if (ss->type == sstream_out) return dstr_get_data_length(&ss->out);
67
+	else return 0; /* no output for input stream */
68
+}
69
+
58 70
 int sstream_get(sstream_t *ss, char *c)
59 71
 {
60 72
 	/* if (!is_input_sstream(ss)) return -1;  */ /* optimalization */
... ...
@@ -45,7 +45,16 @@ typedef struct {
45 45
 
46 46
 int init_input_sstream(sstream_t *ss, char *data_in, int data_len);
47 47
 int init_output_sstream(sstream_t *ss, int out_buff_resize);
48
+
49
+/** returns serialized data as newly allocated string in shared memory */
48 50
 int get_serialized_sstream(sstream_t *ss, str_t *dst);
51
+
52
+/** returns the length of serialized data */
53
+int get_serialized_sstream_len(sstream_t *ss);
54
+
55
+/** copies serialized data into given buffer */
56
+int get_serialized_sstream_data(sstream_t *ss, char *dst);
57
+
49 58
 void destroy_sstream(sstream_t *ss);
50 59
 
51 60
 int sstream_put(sstream_t *ss, const char *s, int len);