本文整理汇总了C++中OBJ_TAINT函数的典型用法代码示例。如果您正苦于以下问题:C++ OBJ_TAINT函数的具体用法?C++ OBJ_TAINT怎么用?C++ OBJ_TAINT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OBJ_TAINT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: name_err_to_s
static VALUE
name_err_to_s(VALUE exc)
{
VALUE mesg = rb_attr_get(exc, rb_intern("mesg"));
VALUE str = mesg;
if (NIL_P(mesg)) return rb_class_name(CLASS_OF(exc));
StringValue(str);
if (str != mesg) {
rb_iv_set(exc, "mesg", mesg = str);
}
if (OBJ_TAINTED(exc)) OBJ_TAINT(mesg);
return mesg;
}
示例2: rb_fiddle_ptr_new2
static VALUE
rb_fiddle_ptr_new2(VALUE klass, void *ptr, long size, freefunc_t func)
{
struct ptr_data *data;
VALUE val;
val = TypedData_Make_Struct(klass, struct ptr_data, &fiddle_ptr_data_type, data);
data->ptr = ptr;
data->free = func;
data->size = size;
OBJ_TAINT(val);
return val;
}
示例3: w_nbyte
static void
w_nbyte(const char *s, int n, struct dump_arg *arg)
{
VALUE buf = arg->str;
rb_bstr_concat(buf, (const uint8_t *)s, n);
#if 0 // unused
if (arg->dest && RSTRING_LEN(buf) >= BUFSIZ) {
if (arg->taint) {
OBJ_TAINT(buf);
}
rb_io_write(arg->dest, buf);
rb_str_resize(buf, 0);
}
#endif
}
示例4: rb_gdbm_fetch
static VALUE
rb_gdbm_fetch(GDBM_FILE dbm, datum key)
{
datum val;
VALUE str;
val = gdbm_fetch(dbm, key);
if (val.dptr == 0)
return Qnil;
str = rb_str_new(val.dptr, val.dsize);
free(val.dptr);
OBJ_TAINT(str);
return str;
}
示例5: rb_gdbm_firstkey
static VALUE
rb_gdbm_firstkey(GDBM_FILE dbm)
{
datum key;
VALUE str;
key = gdbm_firstkey(dbm);
if (key.dptr == 0)
return Qnil;
str = rb_str_new(key.dptr, key.dsize);
free(key.dptr);
OBJ_TAINT(str);
return str;
}
示例6: rg_serialize
static VALUE
rg_serialize(VALUE self)
{
gsize size;
VALUE result;
/* TODO: Is tainting really necessary? Where does the message come
* from? */
size = g_socket_control_message_get_size(_SELF(self));
result = rb_str_new(NULL, size);
g_socket_control_message_serialize(_SELF(self), RSTRING_PTR(result));
OBJ_TAINT(result);
return result;
}
示例7: name_err_mesg_to_str
/* :nodoc: */
static VALUE
name_err_mesg_to_str(VALUE obj, SEL sel)
{
VALUE *ptr, mesg;
Data_Get_Struct(obj, VALUE, ptr);
mesg = ptr[0];
if (NIL_P(mesg)) {
return Qnil;
}
else {
const char *desc = 0;
VALUE d = 0, args[3];
obj = ptr[1];
switch (TYPE(obj)) {
case T_NIL:
desc = "nil";
break;
case T_TRUE:
desc = "true";
break;
case T_FALSE:
desc = "false";
break;
default:
d = rb_protect(safe_inspect, obj, NULL);
if (NIL_P(d) || RSTRING_LEN(d) > 65) {
d = rb_any_to_s(obj);
}
desc = RSTRING_PTR(d);
break;
}
if (desc && desc[0] != '#') {
d = d ? rb_str_dup(d) : rb_str_new2(desc);
rb_str_cat2(d, ":");
rb_str_cat2(d, rb_obj_classname(obj));
}
args[0] = mesg;
args[1] = ptr[2];
args[2] = d;
mesg = rb_f_sprintf(3, args);
}
if (OBJ_TAINTED(obj)) {
OBJ_TAINT(mesg);
}
return mesg;
}
示例8: rb_gdbm_nextkey
static VALUE
rb_gdbm_nextkey(GDBM_FILE dbm, VALUE keystr)
{
datum key, key2;
VALUE str;
key.dptr = RSTRING_PTR(keystr);
key.dsize = RSTRING_LEN(keystr);
key2 = gdbm_nextkey(dbm, key);
if (key2.dptr == 0)
return Qnil;
str = rb_str_new(key2.dptr, key2.dsize);
OBJ_TAINT(str);
return str;
}
示例9: rg_peek
static VALUE
rg_peek(VALUE self, VALUE rboffset, VALUE rbcount)
{
gsize offset = RVAL2GSIZE(rboffset);
gsize count = RVAL2GSIZE(rbcount);
VALUE result = rb_str_new(NULL, count);
gsize bytes_peeked = g_buffered_input_stream_peek(_SELF(self),
RSTRING_PTR(result),
offset,
count);
rb_str_set_len(result, bytes_peeked);
rb_str_resize(result, bytes_peeked);
OBJ_TAINT(result);
return result;
}
示例10: solver_new_var
/*
* call-seq:
* solver.new_var -> Variable
*
* Returns new variable for constructing SAT formula. Raises an exception when
* the SAT is already prove to be always unsatisfiable.
*
*/
static VALUE solver_new_var(VALUE rslv)
{
csolver *cslv;
cvariable *cvar;
VALUE rvar;
Data_Get_Struct(rslv, csolver, cslv);
check_model_available(cslv->result, 1);
rvar =
Data_Make_Struct(rb_cVariable, cvariable, value_mark, value_free, cvar);
cvar->value = wrap_solver_new_var(cslv->solver);
cvar->solver = rslv;
cslv->result = NOT_SOLVED_YET;
if(OBJ_TAINTED(rslv)) OBJ_TAINT(rvar);
return rvar;
}
示例11: proc_to_s
static VALUE
proc_to_s(VALUE self, SEL sel)
{
const char *cname = rb_obj_classname(self);
rb_vm_block_t *proc;
GetProcPtr(self, proc);
const char *is_lambda = (proc->flags & VM_BLOCK_LAMBDA) ? " (lambda)" : "";
VALUE str = rb_sprintf("#<%s:%p%s>", cname, (void *)self, is_lambda);
if (OBJ_TAINTED(self)) {
OBJ_TAINT(str);
}
return str;
}
示例12: rb_singleton_class
VALUE
rb_singleton_class(VALUE obj)
{
VALUE klass;
ID attached;
if (FIXNUM_P(obj) || SYMBOL_P(obj)) {
rb_raise(rb_eTypeError, "can't define singleton");
}
if (rb_special_const_p(obj)) {
SPECIAL_SINGLETON(Qnil, rb_cNilClass);
SPECIAL_SINGLETON(Qfalse, rb_cFalseClass);
SPECIAL_SINGLETON(Qtrue, rb_cTrueClass);
rb_bug("unknown immediate %ld", obj);
}
CONST_ID(attached, "__attached__");
if (FL_TEST(RBASIC(obj)->klass, FL_SINGLETON) &&
rb_ivar_get(RBASIC(obj)->klass, attached) == obj) {
klass = RBASIC(obj)->klass;
}
else {
klass = rb_make_metaclass(obj, RBASIC(obj)->klass);
}
if (BUILTIN_TYPE(obj) == T_CLASS) {
if (rb_iv_get(RBASIC(klass)->klass, "__attached__") != klass)
make_metametaclass(klass);
}
if (OBJ_TAINTED(obj)) {
OBJ_TAINT(klass);
}
else {
FL_UNSET(klass, FL_TAINT);
}
if (OBJ_UNTRUSTED(obj)) {
OBJ_UNTRUST(klass);
}
else {
FL_UNSET(klass, FL_UNTRUSTED);
}
if (OBJ_FROZEN(obj)) OBJ_FREEZE(klass);
return klass;
}
示例13: _receive
static VALUE _receive(int rflags, int argc, VALUE *argv, VALUE self)
{
struct posix_mq *mq = get(self, 1);
struct rw_args x;
VALUE buffer, timeout;
struct timespec expire;
if (mq->attr.mq_msgsize < 0) {
if (mq_getattr(mq->des, &mq->attr) < 0)
rb_sys_fail("mq_getattr");
}
rb_scan_args(argc, argv, "02", &buffer, &timeout);
x.timeout = convert_timeout(&expire, timeout);
if (NIL_P(buffer)) {
buffer = rb_str_new(0, mq->attr.mq_msgsize);
} else {
StringValue(buffer);
rb_str_modify(buffer);
rb_str_resize(buffer, mq->attr.mq_msgsize);
}
OBJ_TAINT(buffer);
x.msg_ptr = RSTRING_PTR(buffer);
x.msg_len = (size_t)mq->attr.mq_msgsize;
x.des = mq->des;
retry:
WITHOUT_GVL(xrecv, &x, RUBY_UBF_IO, 0);
if (x.received < 0) {
if (errno == EINTR)
goto retry;
if (errno == EAGAIN && (rflags & PMQ_TRY))
return Qnil;
rb_sys_fail("mq_receive");
}
rb_str_set_len(buffer, x.received);
if (rflags & PMQ_WANTARRAY)
return rb_ary_new3(2, buffer, UINT2NUM(x.msg_prio));
return buffer;
}
示例14: rb_gdbm_nextkey
static VALUE
rb_gdbm_nextkey(GDBM_FILE dbm, VALUE keystr)
{
datum key, key2;
VALUE str;
long len;
len = RSTRING_LEN(keystr);
if (TOO_LONG(len)) return Qnil;
key.dptr = RSTRING_PTR(keystr);
key.dsize = (int)len;
key2 = gdbm_nextkey(dbm, key);
if (key2.dptr == 0)
return Qnil;
str = rb_str_new(key2.dptr, key2.dsize);
free(key2.dptr);
OBJ_TAINT(str);
return str;
}
示例15: rbcf_dict_convert_to_ruby
VALUE rbcf_dict_convert_to_ruby(CFDictionaryRef dict_ref) {
CFIndex count = CFDictionaryGetCount(dict_ref);
CFIndex i;
CFTypeRef *keys = (CFTypeRef *)malloc(count * sizeof(CFTypeRef));
CFTypeRef *values = (CFTypeRef *)malloc(count * sizeof(CFTypeRef));
CFDictionaryGetKeysAndValues(dict_ref, (const void **)keys, (const void **)values);
VALUE hash = rb_hash_new();
for(i=0; i < count; ++i){
rb_hash_aset(hash, rbcf_string_convert_to_ruby(keys[i]), rbcf_plist_convert_to_ruby(values[i]));
}
free(keys);
free(values);
OBJ_TAINT(hash);
return hash;
}