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


C++ SvOK函数代码示例

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


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

示例1: _newiterator

void _newiterator(rpmts ts, SV * sv_tagname, SV * sv_tagvalue, int keylen) {
    rpmmi mi;
    int tag = RPMDBI_PACKAGES;
    void * value = NULL;
    int i = 0;
    dSP;
    if (sv_tagname == NULL || !SvOK(sv_tagname)) {
        tag = RPMDBI_PACKAGES; /* Assume search into installed packages */
    } else {
        tag = sv2dbquerytag(sv_tagname);
    }
    if (sv_tagvalue != NULL && SvOK(sv_tagvalue)) {
        switch (tag) {
        case RPMDBI_PACKAGES:
            i = SvIV(sv_tagvalue);
            value = &i;
            keylen = sizeof(i);
            break;
        default:
            value = (void *) SvPV_nolen(sv_tagvalue);
            break;
        }
    }
    mi = rpmtsInitIterator(ts, tag, value, keylen);
    XPUSHs(sv_2mortal(sv_setref_pv(newSVpv("", 0), "RPM::PackageIterator", mi)));
    PUTBACK;
    return;
}
开发者ID:thinhnd8752,项目名称:junkcode,代码行数:28,代码来源:rpmxs.c

示例2: route_sv2c

static RouteEntry *
route_sv2c(SV *h, RouteEntry *ref)
{
   if (ref && h && SvROK(h)) {
      HV *hv = (HV *)SvRV(h);
      memset(ref, 0, sizeof(RouteEntry));
      if (hv_exists(hv, "route_dst", 9)) {
         SV **r = hv_fetch(hv, "route_dst", 9, 0);
         if (SvOK(*r)) {
            struct addr a;
            if (addr_aton(SvPV(*r, PL_na), &a) == 0) {
               memcpy(&(ref->route_dst), &a, sizeof(struct addr));
            }
         }
      }
      if (hv_exists(hv, "route_gw", 8)) {
         SV **r = hv_fetch(hv, "route_gw", 8, 0);
         if (SvOK(*r)) {
            struct addr a;
            if (addr_aton(SvPV(*r, PL_na), &a) == 0) {
               memcpy(&(ref->route_gw), &a, sizeof(struct addr));
            }
         }
      }
   }
   else {
      ref = NULL;
   }
   return ref;
}
开发者ID:gitpan,项目名称:Net-Libdnet,代码行数:30,代码来源:route_entry.c

示例3: pack_intermediate_response_args

void
pack_intermediate_response_args(SV *dest, SV *name, SV *value) {
    STRLEN offset = start_constructed(dest, ASN1_APPLICATION|ASN1_CONSTRUCTED, LDAP_OP_INTERMEDIATE_RESPONSE);
    if (name && SvOK(name))
	pack_raw_utf8(dest, ASN1_CONTEXT_SPECIFIC|ASN1_PRIMITIVE, 0, name);
    if (value && SvOK(value))
	pack_raw_utf8(dest, ASN1_CONTEXT_SPECIFIC|ASN1_PRIMITIVE, 1, value);
    end_constructed(dest, offset);
}
开发者ID:gitpan,项目名称:Net-LDAP-Gateway,代码行数:9,代码来源:pack_intermediate_response.c

示例4: perl_variable_to_json_internal

static void perl_variable_to_json_internal( SV *input, json_writer_t *writer )
{
  char *val;
  int ival;
  STRLEN len;
  double number;
  int type = -1;
  
  if ( SvOK( input ) && SvROK( input ) ) {
    type = SvTYPE( SvRV( input ) );
  }
  else if ( SvOK( input ) ) {
    type = SvTYPE( input );
  }

  switch ( type ) {
  case SVt_IV:
    ival = SvIV( input );
    json_writer_write_integer( writer, ival );
    break;

  case SVt_NV:
    number = SvNV( input );
    json_writer_write_number( writer, number );
    break;

  case SVt_PV:
    val = SvPV( input, len );
    json_writer_write_strn( writer, val, len );
    break;

  case SVt_PVNV:
    if ( input == &PL_sv_yes ) {
      json_writer_write_boolean( writer, TRUE );
    }
    else if ( input == &PL_sv_no ) {
      json_writer_write_boolean( writer, FALSE );
    }
    break;
      
  case SVt_PVAV:
    perl_array_to_json( input, writer );
    break;
      
  case SVt_PVHV:
    perl_hash_to_json( input, writer );
    break;
      
  default:
    break;
  }
}
开发者ID:TheProjecter,项目名称:jxtl,代码行数:52,代码来源:perl_util.c

示例5: Application_fonts

SV*
Application_fonts( Handle self, char * name, char * encoding)
{
   int count, i;
   AV * glo = newAV();
   PFont fmtx = apc_fonts( self, name[0] ? name : nil,
      encoding[0] ? encoding : nil, &count);
   for ( i = 0; i < count; i++) {
      SV * sv      = sv_Font2HV( &fmtx[ i]);
      HV * profile = ( HV*) SvRV( sv);
      if ( fmtx[i]. utf8_flags & FONT_UTF8_NAME) {
         SV ** entry = hv_fetch(( HV*) SvRV( sv), "name", 4, 0);
	 if ( entry && SvOK( *entry))
            SvUTF8_on( *entry);
      }	 
      if ( fmtx[i]. utf8_flags & FONT_UTF8_FAMILY) {
         SV ** entry = hv_fetch(( HV*) SvRV( sv), "family", 6, 0);
	 if ( name && SvOK( *entry))
            SvUTF8_on( *entry);
      }	 
      if ( fmtx[i]. utf8_flags & FONT_UTF8_ENCODING) {
         SV ** entry = hv_fetch(( HV*) SvRV( sv), "encoding", 8, 0);
	 if ( name && SvOK( *entry))
            SvUTF8_on( *entry);
      }	 
      if ( name[0] == 0 && encoding[0] == 0) {
         /* Read specially-coded (const char*) encodings[] vector,
            stored in fmtx[i].encoding. First pointer is filled with 0s,
            except the last byte which is a counter. Such scheme
            allows max 31 encodings per entry to be coded with sizeof(char*)==8.
            The interface must be re-implemented, but this requires
            either change in gencls syntax so arrays can be members of hashes,
            or passing of a dynamic-allocated pointer vector here.
          */
         char ** enc = (char**) fmtx[i].encoding;
         unsigned char * shift = (unsigned char*) enc + sizeof(char *) - 1, j = *shift;
         AV * loc = newAV();
         pset_sv_noinc( encoding, newSVpv(( j > 0) ? *(++enc) : "", 0));
         while ( j--) av_push( loc, newSVpv(*(enc++),0));
         pset_sv_noinc( encodings, newRV_noinc(( SV*) loc));
      }
      pdelete( resolution);
      pdelete( codepage);
      av_push( glo, sv);
   }
   free( fmtx);
   return newRV_noinc(( SV *) glo);
}
开发者ID:Spchelkin,项目名称:Prima,代码行数:48,代码来源:Application.c

示例6: SvFlagsHash

long SvFlagsHash(SV * name, char * optname, HV * o) 
{
	int i;
	int val=0;
	if (!name || !SvOK(name))
		return 0;
	if (SvRV(name) && (SvTYPE(SvRV(name)) == SVt_PVAV)) {
		AV * r = (AV*)SvRV(name);
		for(i=0;i<=av_len(r);i++)
			val |= SvOptsHash(*av_fetch(r, i, 0), optname, o);
	} else if (SvRV(name) && (SvTYPE(SvRV(name)) == SVt_PVHV)) {
		HV * r = (HV*)SvRV(name);
		HE * h;
		hv_iterinit(r);
		while((h = hv_iternext(r))) {
			I32 len;
			char * key = hv_iterkey(h, &len);
			SV ** f;
			if (*key == '-') {
				key++;
				len--;
			}
			f = hv_fetch(o, key, len, 0);
			if (f)
				val |= SvIV(hv_iterval(o, h));
			else
				CroakOptsHash(optname, key, o);
		}
	} else
		val |= SvOptsHash(name, optname, o);
	return val;
}
开发者ID:gitpan,项目名称:Gtk-Perl,代码行数:32,代码来源:MiscTypes.c

示例7: encode_get_type

KHARON_DECL int
encode_get_type(void *data)
{
	SV	*in = data;

	D(fprintf(stderr, "get_type = %p\n", in));

	if (!SvOK(in))
		return STATE_UNDEF;

	if (SvROK(in)) {
		switch (SvTYPE(SvRV(in))) {
		case SVt_PVAV:	return STATE_LIST;
		case SVt_PVHV:	return STATE_MAP;

		/* XXXrcd: memory leaks, likely... */
		case SVt_IV:	croak("Trying to encode SVt_IV");
		case SVt_NV:	croak("Trying to encode SVt_NV");
		case SVt_PV:	croak("Trying to encode SVt_PV");
//		case SVt_RV:	croak("Trying to encode SVt_RV");
		case SVt_PVCV:	croak("Trying to encode SVt_PVCV");
		case SVt_PVGV:	croak("Trying to encode SVt_PVGV");
		case SVt_PVMG:	croak("Trying to encode SVt_PVMG");

		default:
			croak("Encode error: bad data type");
		}
	}

	return STATE_SCALAR;
}
开发者ID:nicowilliams,项目名称:kharon,代码行数:31,代码来源:arrayhash_perl.c

示例8: if

SV *modperl_table_get_set(pTHX_ apr_table_t *table, char *key,
                          SV *sv_val, int do_taint)
{
    SV *retval = &PL_sv_undef;

    if (table == NULL) {
        /* do nothing */
    }
    else if (key == NULL) {
        retval = modperl_hash_tie(aTHX_ "APR::Table",
                                  (SV *)NULL, (void*)table);
    }
    else if (!sv_val) { /* no val was passed */
        char *val;
        if ((val = (char *)apr_table_get(table, key))) {
            retval = newSVpv(val, 0);
        }
        else {
            retval = newSV(0);
        }
        if (do_taint) {
            SvTAINTED_on(retval);
        }
    }
    else if (!SvOK(sv_val)) { /* val was passed in as undef */
        apr_table_unset(table, key);
    }
    else {
        apr_table_set(table, key, SvPV_nolen(sv_val));
    }

    return retval;
}
开发者ID:gitpan,项目名称:mod_perl,代码行数:33,代码来源:modperl_util.c

示例9: modperl_table_get_set

MP_INLINE SV *modperl_dir_config(pTHX_ request_rec *r, server_rec *s,
                                 char *key, SV *sv_val)
{
    SV *retval = &PL_sv_undef;

    if (r && r->per_dir_config) {
        MP_dDCFG;
        retval = modperl_table_get_set(aTHX_ dcfg->configvars,
                                       key, sv_val, FALSE);
    }

    if (!SvOK(retval)) {
        if (s && s->module_config) {
            MP_dSCFG(s);
            SvREFCNT_dec(retval); /* in case above did newSV(0) */
            retval = modperl_table_get_set(aTHX_ scfg->configvars,
                                           key, sv_val, FALSE);
        }
        else {
            retval = &PL_sv_undef;
        }
    }

    return retval;
}
开发者ID:gitpan,项目名称:mod_perl,代码行数:25,代码来源:modperl_util.c

示例10: _amf0_data

static amf0_data_t* _amf0_data(SV* sv) {
    amf0_data_t* d;

    if (NULL == sv || !SvOK(sv)) {
        d = (amf0_data_t*)amf0_null_init();
    }
    else if (SvPOKp(sv)) {
        STRLEN len;
        char*  c = SvPV(sv, len);

        d = (amf0_data_t*)amf0_string_init_len(c, len);
    }
    else if (SvNOKp(sv)) {
        d = (amf0_data_t*)amf0_number_init((double)SvNVX(sv));
    }
    else if (SvIOK_UV(sv)) {
        d = (amf0_data_t*)amf0_number_init((double)SvUV(sv));
    }
    else if (SvIOKp(sv)) {
        d = (amf0_data_t*)amf0_number_init((double)SvIV(sv));
    }
    else if (SvROK(sv)) {
        d = _amf0_data_rv(SvRV(sv));
    }
    else {
        Perl_croak(aTHX_ "Data::AMF::XS doesn't support SvTYPE: %d\n", SvTYPE(sv));
    }

    return d;
}
开发者ID:gitpan,项目名称:Data-AMF-XS,代码行数:30,代码来源:xs.c

示例11: plperl_build_tuple_result

static HeapTuple
plperl_build_tuple_result(HV *perlhash, AttInMetadata *attinmeta)
{
	TupleDesc	td = attinmeta->tupdesc;
	char	  **values;
	SV		   *val;
	char	   *key;
	I32			klen;
	HeapTuple	tup;

	values = (char **) palloc0(td->natts * sizeof(char *));

	hv_iterinit(perlhash);
	while ((val = hv_iternextsv(perlhash, &key, &klen)))
	{
		int			attn = SPI_fnumber(td, key);

		if (attn <= 0 || td->attrs[attn - 1]->attisdropped)
			ereport(ERROR,
					(errcode(ERRCODE_UNDEFINED_COLUMN),
					 errmsg("Perl hash contains nonexistent column \"%s\"",
							key)));
		if (SvOK(val) && SvTYPE(val) != SVt_NULL)
			values[attn - 1] = SvPV(val, PL_na);
	}
	hv_iterinit(perlhash);

	tup = BuildTupleFromCStrings(attinmeta, values);
	pfree(values);
	return tup;
}
开发者ID:shubham2094,项目名称:postgresql_8.1,代码行数:31,代码来源:plperl.c

示例12: sv_to_dimension

static long sv_to_dimension(pTHX_ SV *sv, const char *member)
{
  SV *warning;
  const char *value = NULL;

  assert(sv != NULL);

  SvGETMAGIC(sv);

  if (SvOK(sv) && !SvROK(sv))
  {
    if (looks_like_number(sv))
    {
      return SvIV(sv);
    }

    value = SvPV_nolen(sv);
  }

  warning = newSVpvn("", 0);
  if (value)  sv_catpvf(warning, " ('%s')", value);
  if (member) sv_catpvf(warning, " in '%s'", member);

  WARN((aTHX_ "Cannot use %s%s as dimension", identify_sv(sv), SvPV_nolen(warning)));

  SvREFCNT_dec(warning);

  return 0;
}
开发者ID:gitpan,项目名称:Convert-Binary-C,代码行数:29,代码来源:dimension.c

示例13: execute_perl

/*
  this is used for autoload and shutdown callbacks
*/
static int
execute_perl (SV * function, char *args)
{

	int count, ret_value = 1;

	dSP;
	ENTER;
	SAVETMPS;

	PUSHMARK (SP);
	XPUSHs (sv_2mortal (newSVpv (args, 0)));
	PUTBACK;

	count = call_sv (function, G_EVAL | G_SCALAR);
	SPAGAIN;
	if (SvTRUE (ERRSV)) {
		xchat_printf(ph, "Perl error: %s\n", SvPV_nolen (ERRSV));
		if (!SvOK (POPs)) {}		/* remove undef from the top of the stack */
	} else if (count != 1) {
		xchat_printf (ph, "Perl error: expected 1 value from %s, "
						  "got: %d\n", SvPV_nolen (function), count);
	} else {
		ret_value = POPi;
	}
	PUTBACK;
	FREETMPS;
	LEAVE;

	return ret_value;
}
开发者ID:KhitryyGruzinGivi,项目名称:xchat,代码行数:34,代码来源:perl.c

示例14: sv2int_str

inline int sv2int_str(SV *val, int_str *is,
		      unsigned short *flags, unsigned short strflag) {
	char *s;
	STRLEN len;

	if (!SvOK(val)) {
		LM_ERR("AVP:sv2int_str: Invalid value "
			"(not a scalar).\n");
		return 0;
	}
	
	if (SvIOK(val)) { /* numerical name */
		is->n = SvIV(val);
		*flags = 0;
		return 1;
	} else if (SvPOK(val)) {
		s = SvPV(val, len);
		is->s.len = len;
		is->s.s = s;
		(*flags) |= strflag;
		return 1;
	} else {
		LM_ERR("AVP:sv2int_str: Invalid value "
			"(neither string nor integer).\n");
		return 0;
	}
}
开发者ID:ryzhov,项目名称:ATS0,代码行数:27,代码来源:opensipsxs.c

示例15: pairadd_sv

/*
 *
 *     Verify that a Perl SV is a string and save it in FreeRadius
 *     Value Pair Format
 *
 */
static int pairadd_sv(TALLOC_CTX *ctx, REQUEST *request, VALUE_PAIR **vps, char *key, SV *sv, FR_TOKEN op,
		      const char *hash_name, const char *list_name)
{
	char		*val;
	VALUE_PAIR      *vp;

	if (SvOK(sv)) {
		STRLEN len;
		val = SvPV(sv, len);
		vp = fr_pair_make(ctx, vps, key, NULL, op);
		if (!vp) {
		fail:
			REDEBUG("Failed to create pair %s:%s %s %s", list_name, key,
				fr_int2str(fr_tokens, op, "<INVALID>"), val);
			return -1;
		}

		switch (vp->da->type) {
		case PW_TYPE_STRING:
			fr_pair_value_bstrncpy(vp, val, len);
			break;

		default:
			if (fr_pair_value_from_str(vp, val, len) < 0) goto fail;
		}

		RDEBUG("&%s:%s %s $%s{'%s'} -> '%s'", list_name, key, fr_int2str(fr_tokens, op, "<INVALID>"),
		       hash_name, key, val);
		return 0;
	}
	return -1;
}
开发者ID:xunmengdeganjue,项目名称:workTest,代码行数:38,代码来源:rlm_perl.c


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