From: Michael Schroeder Date: Tue, 25 Aug 2015 14:43:38 +0000 (+0200) Subject: tcl bindings: use Tcl_GetByteArrayFromObj to get the raw binary data X-Git-Tag: 0.6.12~31 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=48368e87785a3bd8c27fabdd3fc17b4d04a7a5c3;p=thirdparty%2Flibsolv.git tcl bindings: use Tcl_GetByteArrayFromObj to get the raw binary data We do not want utf8 encoding of binary data... --- diff --git a/bindings/solv.i b/bindings/solv.i index cc721e20..f490a2d8 100644 --- a/bindings/solv.i +++ b/bindings/solv.i @@ -22,7 +22,22 @@ typedef struct { %} %typemap(in,noblock=1,fragment="SWIG_AsCharPtrAndSize") (const unsigned char *str, size_t len) (int res, char *buf = 0, size_t size = 0, int alloc = 0) { +#if defined(SWIGTCL) + { + int bal; + unsigned char *ba; + res = SWIG_TypeError; + ba = Tcl_GetByteArrayFromObj($input, &bal); + if (ba) { + buf = (char *)ba; + size = bal; + res = SWIG_OK; + alloc = SWIG_OLDOBJ; + } + } +#else res = SWIG_AsCharPtrAndSize($input, &buf, &size, &alloc); +#endif if (!SWIG_IsOK(res)) { #if defined(SWIGPYTHON) const void *pybuf = 0; @@ -946,6 +961,9 @@ typedef struct { int dup() { return $self->fp ? dup(fileno($self->fp)) : -1; } + bool write(const unsigned char *str, size_t len) { + return fwrite(str, len, 1, $self->fp) == 1; + } bool flush() { if (!$self->fp) return 1;