当前位置: 首页>>代码示例>>C++>>正文


C++ rb_tainted_str_new函数代码示例

本文整理汇总了C++中rb_tainted_str_new函数的典型用法代码示例。如果您正苦于以下问题:C++ rb_tainted_str_new函数的具体用法?C++ rb_tainted_str_new怎么用?C++ rb_tainted_str_new使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了rb_tainted_str_new函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fetch_hash2

/*	fetch_hash2 (internal)	*/
static VALUE fetch_hash2(VALUE obj, VALUE with_table)
{
    MYSQL_RES* res = GetMysqlRes(obj);
    unsigned int n = mysql_num_fields(res);
    MYSQL_ROW row = mysql_fetch_row(res);
    unsigned long* lengths = mysql_fetch_lengths(res);
    MYSQL_FIELD* fields = mysql_fetch_fields(res);
    unsigned int i;
    VALUE hash;
    if (row == NULL)
	return Qnil;
    hash = rb_hash_new();
    for (i=0; i<n; i++) {
	VALUE col;
	if (row[i] == NULL)
	    continue;
	if (with_table == Qnil || with_table == Qfalse)
	    col = rb_tainted_str_new2(fields[i].name);
	else {
	    col = rb_tainted_str_new(fields[i].table, strlen(fields[i].table)+strlen(fields[i].name)+1);
	    RSTRING(col)->ptr[strlen(fields[i].table)] = '.';
	    strcpy(RSTRING(col)->ptr+strlen(fields[i].table)+1, fields[i].name);
	}
	rb_hash_aset(hash, col, row[i]? rb_tainted_str_new(row[i], lengths[i]): Qnil);
    }
    return hash;
}
开发者ID:BackupTheBerlios,项目名称:dryon-svn,代码行数:28,代码来源:mysql.c

示例2: rb_yp_next

VALUE
rb_yp_next(VALUE self, VALUE domain, VALUE map, VALUE inkey)
{
    char *key, *val;
    int keylen, vallen;
    int res;
    VALUE vkey, vval;

    if( domain == Qnil ) {
        domain = rb_yp_get_default_domain(self);
    };

    res = yp_next(STR2CSTR(domain), STR2CSTR(map),
                  STR2CSTR(inkey), RSTRING(inkey)->len,
                  &key, &keylen, &val, &vallen);
    rb_yp_check_yperr(res);

    if( keylen > 0 ) {
        vkey = rb_tainted_str_new(key, keylen);
    }
    else {
        vkey = Qnil;
    };

    if( vallen > 0 ) {
        vval = rb_tainted_str_new(val, vallen);
    }
    else {
        vval = Qnil;
    };

    return rb_assoc_new(vkey, vval);
};
开发者ID:flavorjones,项目名称:nis,代码行数:33,代码来源:yp.c

示例3: rb_ypall_callback

static int
rb_ypall_callback(int status, char *inkey, int inkeylen, char *inval,
                  int invallen, char *indata)
{
    VALUE cb = (VALUE)indata;
    VALUE res, key, val;

    if( inkeylen > 0 ) {
        key = rb_tainted_str_new(inkey, inkeylen);
    }
    else {
        key = Qnil;
    };

    if( invallen > 0 ) {
        val = rb_tainted_str_new(inval, invallen);
    }
    else {
        val = Qnil;
    };

    if( SYMBOL_P(cb) ) {
        res = rb_funcall(rb_mKernel, SYM2ID(cb), 3,
                         INT2NUM(status), key, val);
    }
    else if( cb == Qnil ) {
        res = rb_yield(rb_ary_new3(3, INT2NUM(status), key, val));
    }
    else {
        res = rb_funcall(cb, rb_intern("call"), 3,
                         INT2NUM(status), key, val);
    };

    /* return value:
     * 0: call again for additional key-value pair
     * nonzero: don't call again
     */
    if( TYPE(res) != T_FIXNUM ) {
        if( res == Qfalse || res == Qnil ) {
            return 0;
        }
        else {
            return 1;
        };
    }
    else {
        return FIX2INT(res);
    };
};
开发者ID:flavorjones,项目名称:nis,代码行数:49,代码来源:yp.c

示例4: jpeg_buf_internal

static VALUE
jpeg_buf_internal(VALUE obj, VALUE quality)
{
    char *buf = NULL;
    int length;

    GetImg(obj, data, im);

#if ATLEAST_VIPS( 7, 28 )
{
    size_t len;

    if (vips_jpegsave_buffer(im, &buf, &len,
        "Q", NUM2INT(quality),
	NULL))
        vips_lib_error();

    /* Argh.
     */
    length = len;
}
#else
    if (im_vips2bufjpeg(im, NULL, NUM2INT(quality), &buf, &length)) 
        vips_lib_error();
#endif

    return rb_tainted_str_new(buf, length);
}
开发者ID:ZeroPivot,项目名称:ruby-vips,代码行数:28,代码来源:writer.c

示例5: env_str_new

static VALUE
env_str_new(const char *ptr, long len)
{
    VALUE str = rb_tainted_str_new(ptr, len);
    rb_obj_freeze(str);
    return str;
}
开发者ID:Hunter-Dolan,项目名称:MacRuby,代码行数:7,代码来源:env.c

示例6: multival_init

/*
 * Apache::MultiVal#initialize( *values )
 * --
 * Create a new MultiVal object with the specified +values+. The first of
 * the values given will be the value used for String operations.
 */
static VALUE
multival_init( VALUE self, VALUE args )
{
    VALUE collect;
    long len, i;

    /* Make sure there's at least one argument to work with */
    if ( RARRAY_LEN(args) == 0 )
        rb_ary_push( args, rb_tainted_str_new("", 0) );

    /* Stringify all arguments */
    len = RARRAY_LEN(args);
    collect = rb_ary_new2(len);
    for ( i = 0; i < len; i++ ) {
        VALUE str;
		
        str = rb_str_dup( rb_obj_as_string(RARRAY_PTR(args)[i]) );
        OBJ_INFECT( str, RARRAY_PTR(args)[i] );
		
        rb_ary_push( collect, str );
    }
	
    rb_iv_set( self, "@args", collect );
    return self;
}
开发者ID:ged,项目名称:mod_ruby,代码行数:31,代码来源:multival.c

示例7: fdbm_fetch

static VALUE
fdbm_fetch(VALUE obj, VALUE keystr, VALUE ifnone)
{
    datum key, value;
    struct dbmdata *dbmp;
    DBM *dbm;
    long len;

    ExportStringValue(keystr);
    len = RSTRING_LEN(keystr);
    if (TOO_LONG(len)) goto not_found;
    key.dptr = RSTRING_PTR(keystr);
    key.dsize = (DSIZE_TYPE)len;

    GetDBM2(obj, dbmp, dbm);
    value = dbm_fetch(dbm, key);
    if (value.dptr == 0) {
      not_found:
	if (NIL_P(ifnone) && rb_block_given_p()) {
	    keystr = rb_str_dup(keystr);
	    OBJ_TAINT(keystr);
	    return rb_yield(keystr);
	}
	return ifnone;
    }
    return rb_tainted_str_new(value.dptr, value.dsize);
}
开发者ID:0x00evil,项目名称:ruby,代码行数:27,代码来源:dbm.c

示例8: pg_text_dec_string

/*
 * Document-class: PG::TextDecoder::String < PG::SimpleDecoder
 *
 * This is a decoder class for conversion of PostgreSQL text output to
 * to Ruby String object. The output value will have the character encoding
 * set with PG::Connection#internal_encoding= .
 *
 */
VALUE
pg_text_dec_string(t_pg_coder *conv, char *val, int len, int tuple, int field, int enc_idx)
{
    VALUE ret = rb_tainted_str_new( val, len );
    PG_ENCODING_SET_NOCHECK( ret, enc_idx );
    return ret;
}
开发者ID:sugananth2003,项目名称:Sugananth_myapp_new,代码行数:15,代码来源:pg_text_decoder.c

示例9: pgresult_getvalue

/*
 * call-seq:
 *    res.getvalue( tup_num, field_num )
 *
 * Returns the value in tuple number _tup_num_, field _field_num_,
 * or +nil+ if the field is +NULL+.
 */
static VALUE
pgresult_getvalue(VALUE self, VALUE tup_num, VALUE field_num)
{
	VALUE val;
	PGresult *result;
	int i = NUM2INT(tup_num);
	int j = NUM2INT(field_num);

	result = pgresult_get(self);
	if(i < 0 || i >= PQntuples(result)) {
		rb_raise(rb_eArgError,"invalid tuple number %d", i);
	}
	if(j < 0 || j >= PQnfields(result)) {
		rb_raise(rb_eArgError,"invalid field number %d", j);
	}
	if(PQgetisnull(result, i, j))
		return Qnil;
	val = rb_tainted_str_new(PQgetvalue(result, i, j),
				PQgetlength(result, i, j));

#ifdef M17N_SUPPORTED
	/* associate client encoding for text format only */
	if ( 0 == PQfformat(result, j) ) {
		ASSOCIATE_INDEX( val, self );
	} else {
		rb_enc_associate( val, rb_ascii8bit_encoding() );
	}
#endif

	return val;
}
开发者ID:danielcode,项目名称:ruby-pg,代码行数:38,代码来源:pg_result.c

示例10: str_from_tok

/* Gobal Helper Functions {{{1 */
static VALUE
str_from_tok(struct rcstoken *tok)
{
	if (tok == NULL)
		rb_raise(rb_eRuntimeError, "Token is NULL");
	return rb_tainted_str_new(tok->str, tok->len);
}
开发者ID:comutt,项目名称:rcsparse,代码行数:8,代码来源:rb-rcsparse.c

示例11: str_from_tok2

static VALUE
str_from_tok2(struct rcstoken *tok)
{
	if (tok == NULL)
		return Qnil;
	return rb_tainted_str_new(tok->str, tok->len);
}
开发者ID:comutt,项目名称:rcsparse,代码行数:7,代码来源:rb-rcsparse.c

示例12: bdb_env_log_get

static VALUE
bdb_env_log_get(VALUE obj, VALUE a)
{
    bdb_ENV *envst;
    DBT data;
    struct dblsnst *lsnst;
    VALUE res, lsn;
    int ret, flag;

    GetEnvDB(obj, envst);
    flag = NUM2INT(a);
    MEMZERO(&data, DBT, 1);
    data.flags |= DB_DBT_MALLOC;
    lsn = bdb_makelsn(obj);
    Data_Get_Struct(lsn, struct dblsnst, lsnst);
#if HAVE_ST_DB_ENV_LG_INFO
    if (!envst->envp->lg_info) {
	rb_raise(bdb_eFatal, "log region not open");
    }
    ret = bdb_test_error(log_get(envst->envp->lg_info, lsnst->lsn, &data, flag));
#else
    ret = bdb_test_error(log_get(envst->envp, lsnst->lsn, &data, flag));
#endif
    if (ret == DB_NOTFOUND) {
	return Qnil;
    }
    res = rb_tainted_str_new(data.data, data.size);
    free(data.data);
    return rb_assoc_new(res, lsn);
}
开发者ID:mallowlabs,项目名称:ruby-bdb,代码行数:30,代码来源:log.c

示例13: png_buf_internal

static VALUE
png_buf_internal(VALUE obj, VALUE compression, VALUE interlace)
{
#if IM_MAJOR_VERSION > 7 || IM_MINOR_VERSION >= 23
    VipsImage *im_out;
    char *buf;
    int length;
    GetImg(obj, data, im);

    if (!(im_out = im_open("writer_png_buf", "p")))
        vips_lib_error();

    if (im_vips2bufpng(im, im_out, NUM2INT(compression), NUM2INT(interlace),
        &buf, &length)) {
		im_close(im_out);
        vips_lib_error();
	}

    im_close(im_out);

    return rb_tainted_str_new(buf, length);
#else
    rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
#endif
}
开发者ID:ender672,项目名称:ruby-vips,代码行数:25,代码来源:writer.c

示例14: rb_ldap_entry_get_values

/*
 * call-seq:
 * entry.get_values(attr)  => Array of String
 * entry.vals(attr)        => Array of String
 * entry[attr]             => Array of String
 *
 * Return an array of all the values belonging to the attribute, +attr+, of
 * the entry.
 */
VALUE
rb_ldap_entry_get_values (VALUE self, VALUE attr)
{
  RB_LDAPENTRY_DATA *edata;
  char *c_attr;
  struct berval **c_vals;
  int i;
  int count;
  VALUE vals;

  GET_LDAPENTRY_DATA (self, edata);
  c_attr = StringValueCStr (attr);

  c_vals = ldap_get_values_len (edata->ldap, edata->msg, c_attr);
  if (c_vals)
    {
      vals = rb_ary_new ();
      count = ldap_count_values_len (c_vals);
      for (i = 0; i < count; i++)
	{
	  VALUE str;
	  str = rb_tainted_str_new (c_vals[i]->bv_val, c_vals[i]->bv_len);
	  rb_ary_push (vals, str);
	}
      ldap_value_free_len (c_vals);
    }
  else
    {
      vals = Qnil;
    }

  return vals;
}
开发者ID:mahlonsmith,项目名称:ruby-ldap,代码行数:42,代码来源:entry.c

示例15: make_column_result_array

/*
 * Make a Ruby array out of the encoded values from the specified
 * column in the given result.
 */
static VALUE
make_column_result_array( VALUE self, int col )
{
	PGresult *result = pgresult_get( self );
	int rows = PQntuples( result );
	int i;
	VALUE val = Qnil;
	VALUE results = rb_ary_new2( rows );

	if ( col >= PQnfields(result) )
		rb_raise( rb_eIndexError, "no column %d in result", col );

	for ( i=0; i < rows; i++ ) {
		val = rb_tainted_str_new( PQgetvalue(result, i, col),
		                          PQgetlength(result, i, col) );

#ifdef M17N_SUPPORTED
		/* associate client encoding for text format only */
		if ( 0 == PQfformat(result, col) ) {
			ASSOCIATE_INDEX( val, self );
		} else {
			rb_enc_associate( val, rb_ascii8bit_encoding() );
		}
#endif

		rb_ary_store( results, i, val );
	}

	return results;
}
开发者ID:ldmosquera,项目名称:ruby-pg,代码行数:34,代码来源:pg_result.c


注:本文中的rb_tainted_str_new函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。