#include "ruby/ruby.h"
#include "ruby/encoding.h"
#include "internal.h"
#include <sys/types.h>
#include <ctype.h>
#include <errno.h>
Go to the source code of this file.
|
| #define | NATINT_LEN_Q 8 |
| |
| #define | NATINT_PACK |
| |
| #define | BIGENDIAN_P() 0 |
| |
| #define | NATINT_LEN(type, len) (natint?(int)sizeof(type):(int)(len)) |
| |
| #define | define_swapx(x, xtype) |
| |
| #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_AREF(ary, idx) : TOO_FEW) |
| |
| #define | NEXTFROM (items-- > 0 ? RARRAY_AREF(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 |
| |
|
| | define_swapx (s, short) |
| |
| static void | encodes (VALUE str, const char *s, long len, int type, int tail_lf) |
| |
| static void | qpencode (VALUE str, VALUE from, long len) |
| |
| 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) |
| |
| static unsigned long | utf8_to_uv (const char *p, long *lenp) |
| |
| void | Init_pack (void) |
| |
| #define BIGENDIAN_P |
( |
| ) |
0 |
| #define castchar |
( |
|
from | ) |
(char)((from) & 0xff) |
| #define define_swapx |
( |
|
x, |
|
|
|
xtype |
|
) |
| |
Value:static xtype \
TOKEN_PASTE(swap,x)(xtype z) \
{ \
xtype r; \
xtype *zp; \
unsigned char *s, *t; \
int i; \
\
*zp = z; \
s = (unsigned char*)zp; \
for (i=0; i<sizeof(xtype); i++) { \
t[sizeof(xtype)-i-1] = s[i]; \
} \
return r; \
}
Definition at line 81 of file pack.c.
| #define DOUBLE_CONVWITH |
( |
|
y | ) |
|
| #define FLOAT_CONVWITH |
( |
|
y | ) |
|
| #define MAX_INTEGER_PACK_SIZE 8 |
| #define NATINT_LEN |
( |
|
type, |
|
|
|
len |
|
) |
| (natint?(int)sizeof(type):(int)(len)) |
| #define PACK_ITEM_ADJUST |
( |
| ) |
|
Value:
if (tmp_len > 0 && !block_p)
\
} while (0)
void rb_ary_store(VALUE ary, long idx, VALUE val)
if((ID)(DISPID) nameid!=nameid)
Definition at line 1069 of file pack.c.
Referenced by pack_unpack().
| #define PACK_LENGTH_ADJUST_SIZE |
( |
|
sz | ) |
|
Value:do { \
if (len > (
long)((send-s)/(sz))) {
\
tmp_len = len-(send-s)/(sz); \
} \
len = (send-s)/(sz); \
} \
} while (0)
if((ID)(DISPID) nameid!=nameid)
Definition at line 1059 of file pack.c.
Referenced by pack_unpack().
| #define UNPACK_PUSH |
( |
|
item | ) |
|
Value:
}\
}\
} while (0)
VALUE rb_ary_push(VALUE ary, VALUE item)
if((ID)(DISPID) nameid!=nameid)
Referenced by pack_unpack().
| define_swapx |
( |
s |
, |
|
|
short |
|
|
) |
| |
| static void encodes |
( |
VALUE |
str, |
|
|
const char * |
s, |
|
|
long |
len, |
|
|
int |
type, |
|
|
int |
tail_lf |
|
) |
| |
|
static |
| static int hex2num |
( |
char |
c | ) |
|
|
inlinestatic |
Definition at line 1198 of file pack.c.
References BIGENDIAN_P, castchar, DBL2NUM, DOUBLE_CONVWITH, ENC_CODERANGE_VALID, ENCODING_CODERANGE_SET, endstr, errno, FLOAT_CONVWITH, hex2num(), infected_str_new(), INTEGER_PACK_2COMP, INTEGER_PACK_BIG_ENDIAN, INTEGER_PACK_LITTLE_ENDIAN, ISDIGIT, ISSPACE, NATINT_LEN, NATINT_LEN_Q, natstr, NTOHD, NTOHF, PACK_ITEM_ADJUST, PACK_LENGTH_ADJUST_SIZE, Qnil, RARRAY_CONST_PTR, RARRAY_LEN, rb_ary_new(), rb_ascii8bit_encindex, rb_block_given_p(), rb_eArgError, rb_eRangeError, rb_integer_unpack(), rb_raise(), rb_str_associate(), rb_str_associated(), rb_str_buf_cat(), rb_str_set_len(), rb_tainted_str_new(), RB_TYPE_P, rb_usascii_str_new(), rb_warning(), RSTRING_LEN, RSTRING_PTR, strchr(), StringValue, STRTOUL, T_STRING, type, ULONG2NUM, UNPACK_PUSH, utf8_to_uv(), val, VTOHD, and VTOHF.
Referenced by Init_pack().
| static void qpencode |
( |
VALUE |
str, |
|
|
VALUE |
from, |
|
|
long |
len |
|
) |
| |
|
static |
| int rb_uv_to_utf8 |
( |
char |
buf[6], |
|
|
unsigned long |
uv |
|
) |
| |
| static unsigned long utf8_to_uv |
( |
const char * |
p, |
|
|
long * |
lenp |
|
) |
| |
|
static |
Initial value:=
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
Definition at line 943 of file pack.c.
Referenced by encodes().
| const char endstr[] = "sSiIlLqQ" |
|
static |
| const char hex_table[] = "0123456789ABCDEF" |
|
static |
| const char natstr[] = "sSiIlL" |
|
static |
| const unsigned long utf8_limits[] |
|
static |
Initial value:= {
0x0,
0x80,
0x800,
0x10000,
0x200000,
0x4000000,
0x80000000,
}
Definition at line 1946 of file pack.c.
Initial value:=
"`!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_"
Definition at line 941 of file pack.c.