Module: ReadUnpack
- Included in:
- PostgresPR::Utils::NativeBuffer
- Defined in:
- ext/postgres-pr/utils/string_unpack_single.c
Instance Method Summary collapse
Instance Method Details
#read_int16_network ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'ext/postgres-pr/utils/string_unpack_single.c', line 35
static VALUE rb_read_int16_network(VALUE self)
{
VALUE B1, B2;
long byte1, byte2, res;
B1 = rb_funcall(self, id_readbyte, 0);
B2 = rb_funcall(self, id_readbyte, 0);
byte1 = FIX2LONG(B1);
byte2 = FIX2LONG(B2);
res = (byte1 < 128 ? byte1 : byte1 - 256) * 256 + byte2;
return LONG2FIX(res);
}
|
#read_int32_network ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'ext/postgres-pr/utils/string_unpack_single.c', line 47
static VALUE rb_read_int32_network(VALUE self)
{
VALUE B1, B2, B3, B4;
long byte1, byte2, byte3, byte4, res;
B1 = rb_funcall(self, id_readbyte, 0);
B2 = rb_funcall(self, id_readbyte, 0);
B3 = rb_funcall(self, id_readbyte, 0);
B4 = rb_funcall(self, id_readbyte, 0);
byte1 = FIX2LONG(B1);
byte2 = FIX2LONG(B2);
byte3 = FIX2LONG(B3);
byte4 = FIX2LONG(B4);
res = (((byte1 < 128 ? byte1 : byte1 - 256) * 256 + byte2) * 256 +
byte3) * 256 + byte4;
return LONG2NUM(res);
}
|