Просмотр исходного кода

added functions to return serialized stream into existing buffer

Vaclav Kubart 18 лет назад
Родитель
Сommit
c8907ced77
3 измененных файлов с 26 добавлено и 0 удалено
  1. 5 0
      lib/cds/ChangeLog
  2. 12 0
      lib/cds/serialize.c
  3. 9 0
      lib/cds/serialize.h

+ 5 - 0
lib/cds/ChangeLog

@@ -1,3 +1,8 @@
+2007-01-18
+	* added functions to return serialized stream into existing buffer
+
+...
+
 2006-11-06
 	* bug correction - output of get_pres_rules initialized - reported by Bogdan
 

+ 12 - 0
lib/cds/serialize.c

@@ -55,6 +55,18 @@ int get_serialized_sstream(sstream_t *ss, str_t *dst)
 	else return -1; /* no output for input stream */
 }
 
+int get_serialized_sstream_data(sstream_t *ss, char *dst)
+{
+	if (ss->type == sstream_out) return dstr_get_data(&ss->out, dst);
+	else return -1; /* no output for input stream */
+}
+
+int get_serialized_sstream_len(sstream_t *ss)
+{
+	if (ss->type == sstream_out) return dstr_get_data_length(&ss->out);
+	else return 0; /* no output for input stream */
+}
+
 int sstream_get(sstream_t *ss, char *c)
 {
 	/* if (!is_input_sstream(ss)) return -1;  */ /* optimalization */

+ 9 - 0
lib/cds/serialize.h

@@ -45,7 +45,16 @@ typedef struct {
 
 int init_input_sstream(sstream_t *ss, char *data_in, int data_len);
 int init_output_sstream(sstream_t *ss, int out_buff_resize);
+
+/** returns serialized data as newly allocated string in shared memory */
 int get_serialized_sstream(sstream_t *ss, str_t *dst);
+
+/** returns the length of serialized data */
+int get_serialized_sstream_len(sstream_t *ss);
+
+/** copies serialized data into given buffer */
+int get_serialized_sstream_data(sstream_t *ss, char *dst);
+
 void destroy_sstream(sstream_t *ss);
 
 int sstream_put(sstream_t *ss, const char *s, int len);