/*
* call-seq:
* PGconn.unescape_bytea( obj )
*
* Converts an escaped string representation of binary data into binary data --- the
* reverse of #escape_bytea. This is needed when retrieving +bytea+ data in text format,
* but not when retrieving it in binary format.
*
* See the PostgreSQL documentation on PQunescapeBytea[http://www.postgresql.org/docs/current/interactive/libpq-exec.html#LIBPQ-EXEC-ESCAPE-BYTEA] for more information.
*/
static VALUE
pgconn_s_unescape_bytea(self, obj)
VALUE self, obj;
{
unsigned char *from, *to;
size_t to_len;
VALUE ret;
Check_Type(obj, T_STRING);
from = (unsigned char*)StringValuePtr(obj);
to = PQunescapeBytea(from, &to_len);
ret = rb_str_new((char*)to, to_len);
OBJ_INFECT(ret, obj);
PQfreemem(to);
return ret;
}