Răsfoiți Sursa

Merge branch 'thirdparty'

Source commit: c9efa5a74d58e1381396a4ae601c983dc4e55385
Martin Prikryl 5 ani în urmă
părinte
comite
ada0647ad1
2 a modificat fișierele cu 17 adăugiri și 0 ștergeri
  1. 11 0
      source/putty/marshal.c
  2. 6 0
      source/putty/marshal.h

+ 11 - 0
source/putty/marshal.c

@@ -235,6 +235,17 @@ ptrlen BinarySource_get_pstring(BinarySource *src)
     return make_ptrlen(consume(len), len);
 }
 
+void BinarySource_REWIND_TO__(BinarySource *src, size_t pos)
+{
+    if (pos <= src->len) {
+        src->pos = pos;
+        src->err = BSE_NO_ERROR;    /* clear any existing error */
+    } else {
+        src->pos = src->len;
+        src->err = BSE_OUT_OF_DATA; /* new error if we rewind out of range */
+    }
+}
+
 static void stdio_sink_write(BinarySink *bs, const void *data, size_t len)
 {
     stdio_sink *sink = BinarySink_DOWNCAST(bs, stdio_sink);

+ 6 - 0
source/putty/marshal.h

@@ -255,6 +255,10 @@ static inline void BinarySource_INIT__(BinarySource *src, ptrlen data)
               (object)->binarysource_)
 #define BinarySource_COPIED(obj) \
     ((obj)->binarysource_->binarysource_ = (obj)->binarysource_)
+#define BinarySource_REWIND_TO(src, pos) \
+    BinarySource_REWIND_TO__((src)->binarysource_, pos)
+#define BinarySource_REWIND(src) \
+    BinarySource_REWIND_TO__((src)->binarysource_, 0)
 
 #define get_data(src, len) \
     BinarySource_get_data(BinarySource_UPCAST(src), len)
@@ -303,6 +307,8 @@ ptrlen BinarySource_get_pstring(BinarySource *);
 mp_int *BinarySource_get_mp_ssh1(BinarySource *src);
 mp_int *BinarySource_get_mp_ssh2(BinarySource *src);
 
+void BinarySource_REWIND_TO__(BinarySource *src, size_t pos);
+
 /*
  * A couple of useful standard BinarySink implementations, which live
  * as sensibly here as anywhere else: one that makes a BinarySink