Ruby
2.0.0p247(2013-06-27revision41674)
|
#include "ruby/ruby.h"
#include "ruby/encoding.h"
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
Go to the source code of this file.
Macros | |
#define | GCC_VERSION_SINCE(major, minor, patchlevel) |
#define | NATINT_PACK |
#define | BIGENDIAN_P() 0 |
#define | NATINT_LEN(type, len) (natint?(int)sizeof(type):(int)(len)) |
#define | define_swapx(x, xtype) |
#define | swap16(x) ((uint16_t)((((x)&0xFF)<<8) | (((x)>>8)&0xFF))) |
#define | swap32(x) |
#define | rb_ntohf(x) (BIGENDIAN_P()?(x):swapf(x)) |
#define | rb_ntohd(x) (BIGENDIAN_P()?(x):swapd(x)) |
#define | rb_htonf(x) (BIGENDIAN_P()?(x):swapf(x)) |
#define | rb_htond(x) (BIGENDIAN_P()?(x):swapd(x)) |
#define | rb_htovf(x) (BIGENDIAN_P()?swapf(x):(x)) |
#define | rb_htovd(x) (BIGENDIAN_P()?swapd(x):(x)) |
#define | rb_vtohf(x) (BIGENDIAN_P()?swapf(x):(x)) |
#define | rb_vtohd(x) (BIGENDIAN_P()?swapd(x):(x)) |
#define | FLOAT_CONVWITH(y) |
#define | HTONF(x, y) rb_htonf(x) |
#define | HTOVF(x, y) rb_htovf(x) |
#define | NTOHF(x, y) rb_ntohf(x) |
#define | VTOHF(x, y) rb_vtohf(x) |
#define | DOUBLE_CONVWITH(y) |
#define | HTOND(x, y) rb_htond(x) |
#define | HTOVD(x, y) rb_htovd(x) |
#define | NTOHD(x, y) rb_ntohd(x) |
#define | VTOHD(x, y) rb_vtohd(x) |
#define | MAX_INTEGER_PACK_SIZE 8 |
#define | TOO_FEW (rb_raise(rb_eArgError, toofew), 0) |
#define | THISFROM (items > 0 ? RARRAY_PTR(ary)[idx] : TOO_FEW) |
#define | NEXTFROM (items-- > 0 ? RARRAY_PTR(ary)[idx++] : TOO_FEW) |
#define | castchar(from) (char)((from) & 0xff) |
#define | PACK_LENGTH_ADJUST_SIZE(sz) |
#define | PACK_ITEM_ADJUST() |
#define | UNPACK_PUSH(item) |
#define | BYTEWIDTH 8 |
Functions | |
static unsigned long | num2i32 (VALUE x) |
static void | encodes (VALUE, const char *, long, int, int) |
static void | qpencode (VALUE, VALUE, long) |
static unsigned long | utf8_to_uv (const char *, long *) |
static VALUE | pack_pack (VALUE ary, VALUE fmt) |
static int | hex2num (char c) |
static VALUE | infected_str_new (const char *ptr, long len, VALUE str) |
static VALUE | pack_unpack (VALUE str, VALUE fmt) |
int | rb_uv_to_utf8 (char buf[6], unsigned long uv) |
void | Init_pack (void) |
Variables | |
static const char | toofew [] = "too few arguments" |
static const char | uu_table [] |
static const char | b64_table [] |
static const char | hex_table [] = "0123456789ABCDEF" |
static const unsigned long | utf8_limits [] |
#define BIGENDIAN_P | ( | ) | 0 |
Definition at line 46 of file pack.c.
Referenced by pack_pack(), and pack_unpack().
#define castchar | ( | from | ) | (char)((from) & 0xff) |
Referenced by pack_pack(), pack_unpack(), and rb_uv_to_utf8().
#define define_swapx | ( | x, | |
xtype | |||
) |
#define DOUBLE_CONVWITH | ( | y | ) |
Definition at line 233 of file pack.c.
Referenced by pack_pack(), and pack_unpack().
#define FLOAT_CONVWITH | ( | y | ) |
Definition at line 207 of file pack.c.
Referenced by pack_pack(), and pack_unpack().
#define GCC_VERSION_SINCE | ( | major, | |
minor, | |||
patchlevel | |||
) |
#define HTOND | ( | x, | |
y | |||
) | rb_htond(x) |
Definition at line 234 of file pack.c.
Referenced by pack_pack().
#define HTONF | ( | x, | |
y | |||
) | rb_htonf(x) |
Definition at line 208 of file pack.c.
Referenced by pack_pack().
#define HTOVD | ( | x, | |
y | |||
) | rb_htovd(x) |
Definition at line 235 of file pack.c.
Referenced by pack_pack().
#define HTOVF | ( | x, | |
y | |||
) | rb_htovf(x) |
Definition at line 209 of file pack.c.
Referenced by pack_pack().
#define MAX_INTEGER_PACK_SIZE 8 |
Definition at line 254 of file pack.c.
Referenced by pack_pack(), and pack_unpack().
Definition at line 50 of file pack.c.
Referenced by pack_pack(), and pack_unpack().
#define NEXTFROM (items-- > 0 ? RARRAY_PTR(ary)[idx++] : TOO_FEW) |
Referenced by pack_pack().
#define NTOHD | ( | x, | |
y | |||
) | rb_ntohd(x) |
Definition at line 236 of file pack.c.
Referenced by pack_unpack().
#define NTOHF | ( | x, | |
y | |||
) | rb_ntohf(x) |
Definition at line 210 of file pack.c.
Referenced by pack_unpack().
#define PACK_ITEM_ADJUST | ( | ) |
Definition at line 1192 of file pack.c.
Referenced by pack_unpack().
#define PACK_LENGTH_ADJUST_SIZE | ( | sz | ) |
#define rb_htond | ( | x | ) | (BIGENDIAN_P()?(x):swapd(x)) |
#define rb_htonf | ( | x | ) | (BIGENDIAN_P()?(x):swapf(x)) |
#define rb_htovd | ( | x | ) | (BIGENDIAN_P()?swapd(x):(x)) |
#define rb_htovf | ( | x | ) | (BIGENDIAN_P()?swapf(x):(x)) |
#define rb_ntohd | ( | x | ) | (BIGENDIAN_P()?(x):swapd(x)) |
#define rb_ntohf | ( | x | ) | (BIGENDIAN_P()?(x):swapf(x)) |
#define rb_vtohd | ( | x | ) | (BIGENDIAN_P()?swapd(x):(x)) |
#define rb_vtohf | ( | x | ) | (BIGENDIAN_P()?swapf(x):(x)) |
#define swap16 | ( | x | ) | ((uint16_t)((((x)&0xFF)<<8) | (((x)>>8)&0xFF))) |
Definition at line 91 of file pack.c.
Referenced by pack_pack(), and pack_unpack().
#define swap32 | ( | x | ) |
Definition at line 95 of file pack.c.
Referenced by pack_pack(), and pack_unpack().
#define THISFROM (items > 0 ? RARRAY_PTR(ary)[idx] : TOO_FEW) |
Referenced by pack_pack().
#define TOO_FEW (rb_raise(rb_eArgError, toofew), 0) |
#define UNPACK_PUSH | ( | item | ) |
Referenced by pack_unpack().
#define VTOHD | ( | x, | |
y | |||
) | rb_vtohd(x) |
Definition at line 237 of file pack.c.
Referenced by pack_unpack().
#define VTOHF | ( | x, | |
y | |||
) | rb_vtohf(x) |
Definition at line 211 of file pack.c.
Referenced by pack_unpack().
Definition at line 1064 of file pack.c.
References b64_table, i, and rb_str_buf_cat().
Referenced by pack_pack().
|
inlinestatic |
Definition at line 1165 of file pack.c.
Referenced by pack_unpack().
Definition at line 1198 of file pack.c.
References OBJ_INFECT, rb_str_new(), and s.
Referenced by pack_unpack().
Definition at line 2272 of file pack.c.
References pack_pack(), pack_unpack(), rb_cArray, rb_cString, and rb_define_method().
|
static |
Definition at line 241 of file pack.c.
References FIX2LONG, FIXNUM_P, rb_big2ulong_pack(), rb_eTypeError, rb_obj_classname(), rb_raise(), rb_to_int(), RB_TYPE_P, T_BIGNUM, and UNREACHABLE.
Referenced by pack_pack().
Definition at line 369 of file pack.c.
References a, BIGENDIAN_P, buf, c, castchar, d, DOUBLE_CONVWITH, ENC_CODERANGE_7BIT, encodes(), ENCODING_CODERANGE_SET, errno, f, FLOAT_CONVWITH, HTOND, HTONF, HTOVD, HTOVF, i, idx, int, ISALPHA, ISDIGIT, ISSPACE, le, len, MAX_INTEGER_PACK_SIZE, NATINT_LEN, NEXTFROM, NIL_P(), num2i32(), NUM2INT, NUM2LONG, OBJ_INFECT, p, ptr, qpencode(), RARRAY_LEN, RARRAY_PTR(), rb_ary_new(), rb_ary_push(), rb_big_divmod(), rb_big_pack(), rb_bug(), rb_eArgError, rb_enc_set_index(), rb_eRangeError, rb_eRuntimeError, rb_obj_as_string(), rb_obj_taint(), rb_raise(), rb_str_associate(), rb_str_buf_cat(), rb_str_buf_new(), rb_str_new(), rb_str_set_len(), rb_to_float(), rb_to_int(), RB_TYPE_P, rb_uint2big(), rb_usascii_encindex(), rb_utf8_encindex(), rb_uv_to_utf8(), rb_warning(), res, RFLOAT_VALUE, RSTRING_LEN, RSTRING_PTR, SIGNED_VALUE, strchr(), StringValue, StringValuePtr, STRTOUL, swap16, swap32, t, T_BIGNUM, THISFROM, type, and v.
Referenced by Init_pack().
Definition at line 1315 of file pack.c.
References a, ary, b, BIGENDIAN_P, buf, c, castchar, d, DBL2NUM, DOUBLE_CONVWITH, ENC_CODERANGE_VALID, ENCODING_CODERANGE_SET, end, errno, FLOAT_CONVWITH, hex2num(), i, infected_str_new(), int, INT2FIX, INT2NUM, ISDIGIT, ISSPACE, len, MAX_INTEGER_PACK_SIZE, memcpy(), memset(), NATINT_LEN, NTOHD, NTOHF, p, PACK_ITEM_ADJUST, PACK_LENGTH_ADJUST_SIZE, ptr, Qnil, RARRAY_LEN, RARRAY_PTR(), rb_ary_new(), rb_ascii8bit_encindex(), rb_big_mul(), rb_big_plus(), rb_big_unpack(), rb_block_given_p(), rb_bug(), rb_eArgError, rb_eRangeError, rb_raise(), rb_str_associate(), rb_str_associated(), rb_str_buf_cat(), rb_str_set_len(), rb_tainted_str_new(), RB_TYPE_P, rb_uint2big(), rb_usascii_str_new(), rb_warning(), RSTRING_LEN, RSTRING_PTR, s, strchr(), StringValue, STRTOUL, swap16, swap32, t, T_STRING, tmp, type, UINT2NUM, ULONG2NUM, UNPACK_PUSH, utf8_to_uv(), v, VTOHD, and VTOHF.
Referenced by Init_pack().
Definition at line 1112 of file pack.c.
References EOF, i, n, rb_str_buf_cat(), RSTRING_LEN, RSTRING_PTR, and s.
Referenced by pack_pack().
int rb_uv_to_utf8 | ( | char | buf[6], |
unsigned long | uv | ||
) |
Definition at line 2165 of file pack.c.
References castchar, rb_eRangeError, rb_raise(), and UNREACHABLE.
Referenced by append_utf8(), and pack_pack().
|
static |
Definition at line 2222 of file pack.c.
References c, n, rb_eArgError, and rb_raise().
Referenced by pack_unpack().
|
static |
|
static |