• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ decode_hex函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: load_json_key

static void load_json_key(json_t *wallet, struct bp_key *key)
{
	json_t *keys_a = json_object_get(wallet, "keys");
	assert(json_is_array(keys_a));

	json_t *key_o = json_array_get(keys_a, 0);
	assert(json_is_object(key_o));

	const char *address_str = json_string_value(json_object_get(key_o, "address"));
	assert(address_str != NULL);

	const char *privkey_address_str = json_string_value(json_object_get(key_o, "privkey_address"));
	assert(privkey_address_str);

	const char *pubkey_str = json_string_value(json_object_get(key_o, "pubkey"));
	assert(pubkey_str != NULL);

	const char *privkey_str = json_string_value(json_object_get(key_o, "privkey"));
	assert(privkey_str != NULL);

	char rawbuf[strlen(privkey_str)];
	size_t buf_len = 0;

	/* decode privkey */
	assert(decode_hex(rawbuf, sizeof(rawbuf), privkey_str, &buf_len) == true);

	assert(bp_privkey_set(key, rawbuf, buf_len) == true);

	/* decode pubkey */
	assert(decode_hex(rawbuf, sizeof(rawbuf), pubkey_str, &buf_len) == true);

	void *pk = NULL;
	size_t pk_len = 0;

	/* verify pubkey matches expected */
	assert(bp_pubkey_get(key, &pk, &pk_len) == true);
	assert(pk_len == buf_len);
	assert(memcmp(rawbuf, pk, pk_len) == 0);

	free(pk);

	/* verify pubkey hash (bitcoin address) matches expected */
	cstring *btc_addr = bp_pubkey_get_address(key, PUBKEY_ADDRESS_TEST);
	assert(strlen(address_str) == btc_addr->len);
	assert(memcmp(address_str, btc_addr->str, btc_addr->len) == 0);

	/* verify the private key address (WIF) */
	cstring *privkey_addr = bp_privkey_get_address(key, PRIVKEY_ADDRESS_TEST);
	assert(strlen(privkey_address_str) == privkey_addr->len);
	assert(memcmp(privkey_address_str, privkey_addr->str, privkey_addr->len) == 0);

	cstr_free(privkey_addr, true);
	cstr_free(btc_addr, true);
}
开发者ID:aido,项目名称:picocoin,代码行数:54,代码来源:wallet-basics.c


示例2: copy_cJSON

char *telepod_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr)
{
    uint64_t satoshis;
    struct coin_info *cp;
    uint32_t crc,ind,height,vout,totalcrc,sharei,M,N;
    char NXTACCTSECRET[1024],coinstr[512],coinaddr[512],otherpubaddr[512],txid[512],pubkey[512],privkey[2048],privkeyhex[2048],*retstr = 0;
    copy_cJSON(NXTACCTSECRET,objs[1]);
    if ( NXTACCTSECRET[0] == 0 && (cp= get_coin_info("BTCD")) != 0 )
        safecopy(NXTACCTSECRET,cp->NXTACCTSECRET,sizeof(NXTACCTSECRET));
    crc = get_API_uint(objs[2],0);
    ind = get_API_uint(objs[3],0);
    height = get_API_uint(objs[4],0);
    copy_cJSON(coinstr,objs[5]);
    satoshis = SATOSHIDEN * get_API_float(objs[6]);
    copy_cJSON(coinaddr,objs[7]);
    copy_cJSON(txid,objs[8]);
    vout = get_API_uint(objs[9],0);
    copy_cJSON(pubkey,objs[10]);
    copy_cJSON(privkeyhex,objs[11]);
    decode_hex((unsigned char *)privkey,(int32_t)strlen(privkeyhex)/2,privkeyhex);
    privkey[strlen(privkeyhex)/2] = 0;
    totalcrc = get_API_uint(objs[12],0);
    sharei = get_API_uint(objs[13],0);
    M = get_API_uint(objs[14],1);
    N = get_API_uint(objs[15],1);
    copy_cJSON(otherpubaddr,objs[16]);
    if ( coinstr[0] != 0 && sender[0] != 0 && valid != 0 )
        retstr = telepod_received(sender,NXTACCTSECRET,coinstr,crc,ind,height,satoshis,coinaddr,txid,vout,pubkey,privkey,totalcrc,sharei,M,N,otherpubaddr);
    else retstr = clonestr("{\"error\":\"invalid telepod received\"}");
    return(retstr);
}
开发者ID:Bitcoinsulting,项目名称:libjl777,代码行数:31,代码来源:jl777.cpp


示例3: cJSON_Parse

char *SuperNET_parsemainargs(struct supernet_info *myinfo,bits256 *wallethashp,bits256 *wallet2privp,char *argjsonstr)
{
    cJSON *exchanges=0,*json = 0;
    char *wallet2fname,*coinargs=0,*secret,*filestr;
    long allocsize;
    bits256 wallethash,wallet2priv;
    int32_t n,len;
    uint8_t secretbuf[8192];
    wallethash = wallet2priv = GENESIS_PRIVKEY;
    if ( argjsonstr != 0 )
    {
        if ( (filestr= OS_filestr(&allocsize,argjsonstr)) != 0 )
        {
            json = cJSON_Parse(filestr);
            free(filestr);
        }
        if ( json != 0 || (json= cJSON_Parse(argjsonstr)) != 0 )
        {
            printf("ARGSTR.(%s)\n",argjsonstr);
            if ( jobj(json,"numhelpers") != 0 )
                IGUANA_NUMHELPERS = juint(json,"numhelpers");
            if ( (secret= jstr(json,"passphrase")) != 0 )
            {
                len = (int32_t)strlen(secret);
                if ( is_hexstr(secret,0) != 0 && len == 128 )
                {
                    len >>= 1;
                    decode_hex(secretbuf,len,secret);
                } else vcalc_sha256(0,secretbuf,(void *)secret,len), len = sizeof(bits256);
开发者ID:satindergrewal,项目名称:SuperNET,代码行数:29,代码来源:SuperNET_keys.c


示例4: get_heart_data

static void get_heart_data(p16_tcp_heart_data* ptcp_heart_data)
{
	ptcp_heart_data->identify_code = 0x01;		
	get_order_array_by_int(p16pos.cfgverno, ptcp_heart_data->cfgverno, 4);
	decode_hex(p16pos.devphyid, 8, ptcp_heart_data->machine_no);
	//get_order_array_by_int(5,ptcp_heart_data->machine_no,4);//就是devphyid
}
开发者ID:pennwin2014,项目名称:purchase_machine,代码行数:7,代码来源:p16main.c


示例5: test_decode

static void test_decode(const char *hexstr, const char *base58_str)
{
	size_t hs_len = strlen(hexstr) / 2;
	unsigned char *raw = calloc(1, hs_len);
	size_t out_len;

	bool rc = decode_hex(raw, hs_len, hexstr, &out_len);
	if (!rc) {
		fprintf(stderr, "raw %p, sizeof(raw) %lu, hexstr %p %s\n",
			raw, hs_len, hexstr, hexstr);
		assert(rc);
	}

	cstring *s = base58_decode(base58_str);
	if (memcmp(s->str, raw, out_len < s->len ? out_len : s->len)) {
		dumphex("decode have", s->str, s->len);
		dumphex("decode want", raw, out_len);
		assert(memcmp(s->str, raw, out_len) == 0);
	}
	if (s->len != out_len) {
		fprintf(stderr, "decode len: have %u, want %u\n",
			(unsigned int) s->len,
			(unsigned int) out_len);
		dumphex("decode have", s->str, s->len);
		dumphex("decode want", raw, out_len);
		assert(s->len == out_len);
	}

	free(raw);
	cstr_free(s, true);
}
开发者ID:libbitc,项目名称:libbitc,代码行数:31,代码来源:base58.c


示例6: test_application_entry_decode

static void test_application_entry_decode(void)
{
	unsigned char *ef_dir;
	long len;
	GSList *entries;
	struct sim_app_record *app[2];

	ef_dir = decode_hex(at_cuad_response, -1, &len, 0);
	entries = sim_parse_app_template_entries(ef_dir, len);

	g_assert(g_slist_length(entries) == 2);

	app[0] = entries->next->data;
	app[1] = entries->data;

	g_assert(app[0]->aid_len == 0x10);
	g_assert(!memcmp(app[0]->aid, &ef_dir[4], 0x10));
	g_assert(app[0]->label == NULL);

	g_assert(app[1]->aid_len == 0x0c);
	g_assert(!memcmp(app[1]->aid, &ef_dir[37], 0x0c));
	g_assert(app[1]->label != NULL);
	g_assert(!strcmp(app[1]->label, "MIDPfiles"));

	g_free(ef_dir);
}
开发者ID:Informatic,项目名称:ofono,代码行数:26,代码来源:test-simutil.c


示例7: SuperNET_str2hex

int32_t SuperNET_str2hex(uint8_t *hex,char *str)
{
    int32_t len;
    len = (int32_t)strlen(str)+1;
    decode_hex(hex,len,str);
    return(len);
}
开发者ID:botvs,项目名称:SuperNET,代码行数:7,代码来源:main.c


示例8: bitcoin_parseunspent

uint64_t bitcoin_parseunspent(struct iguana_info *coin,struct bitcoin_unspent *unspent,double minconfirms,char *account,cJSON *item)
{
    char *hexstr,coinaddr[64];
    memset(unspent,0,sizeof(*unspent));
    if ( jstr(item,"address") != 0 )
    {
        safecopy(coinaddr,jstr(item,"address"),sizeof(coinaddr));
        bitcoin_addr2rmd160(&unspent->addrtype,unspent->rmd160,coinaddr);
        /*sprintf(args,"[\"%s\"]",coinaddr);
        wifstr = bitcoind_RPC(0,coin->symbol,coin->chain->serverport,coin->chain->userpass,"dumpprivkey",args);
        if ( wifstr != 0 )
        {
            bitcoin_wif2priv(&addrtype,&unspent->privkeys[0],wifstr);
            //printf("wifstr.(%s) -> %s\n",wifstr,bits256_str(str,unspent->privkeys[0]));
            free(wifstr);
        } else fprintf(stderr,"error (%s) cant find privkey\n",coinaddr);*/
    }
    if ( (account == 0 || jstr(item,"account") == 0 || strcmp(account,jstr(item,"account")) == 0) && (minconfirms <= 0 || juint(item,"confirmations") >= minconfirms-SMALLVAL) )
    {
        if ( (hexstr= jstr(item,"scriptPubKey")) != 0 )
        {
            unspent->spendlen = (int32_t)strlen(hexstr) >> 1;
            if ( unspent->spendlen < sizeof(unspent->spendscript) )
                decode_hex(unspent->spendscript,unspent->spendlen,hexstr);
        }
        unspent->txid = jbits256(item,"txid");
        unspent->value = SATOSHIDEN * jdouble(item,"amount");
        unspent->vout = jint(item,"vout");
        //char str[65]; printf("(%s) -> %s %.8f scriptlen.%d\n",jprint(item,0),bits256_str(str,unspent->txid),dstr(unspent->value),unspent->scriptlen);
    } else printf("skip.(%s) minconfirms.%f\n",jprint(item,0),minconfirms);
开发者ID:tpoonach,项目名称:SuperNET,代码行数:30,代码来源:bitcoin.c


示例9: strlen

char *single_xor_decode(char *chex) {
    int chexlen = strlen(chex);

    byte *cbytes = decode_hex(chex, chexlen);

    /* Way bigger than any possible score from freq analysis */
    double best = 1000;
    char *best_text = malloc(sizeof(char));
    for (int key = 0; key < 256; key++) {
        byte *dec_bytes = single_xor(cbytes, (char) key, chexlen / 2);
        char *dec_text = as_string(dec_bytes, chexlen / 2);
        double score = fa_score(dec_text);

        if (score < best && (int) strlen(dec_text) == chexlen / 2) {
            free(best_text);
            best = score;
            best_text = dec_text;
        }
        else {
            free(dec_text);
        }

        free(dec_bytes);
    }

    free(cbytes);
    return best_text;
}
开发者ID:rpinkerton,项目名称:cryptopals-c,代码行数:28,代码来源:cipher.c


示例10: get_rt_transdtl_data

static int get_rt_transdtl_data(p16_tcp_transdtl* ptcp_rt_transdtl)
{
	int ret = 0;
	p16_transdtl_t transdtl;
	memset(&transdtl,0,sizeof transdtl);
	ret = trans_get_last_record(&transdtl);
	if(ret == 0)
	{
		//LOG((LOG_DEBUG,"无可取的消费流水"));
		return -1;
	}
	//将该条记录设为已读取
	transdtl.confirm = 1;
	ret = trans_update_record(&transdtl);
	if(ret)
	{
		//LOG((LOG_ERROR,"更新交易流水失败"));
		return -2;
	}
	ptcp_rt_transdtl->devseqno= transdtl.devseqno;//表里的devseqno
	get_order_array_by_int(transdtl.cardbefbal, ptcp_rt_transdtl->cardbefbal, 4);
	get_order_array_by_int(transdtl.paycnt, ptcp_rt_transdtl->paycnt, 2);
	get_order_array_by_int(transdtl.cardno, ptcp_rt_transdtl->cardno, 4);
	if(transdtl.transflag == TRANS_WRITE_CARD_OK)
	{
		ptcp_rt_transdtl->transflag = 0x81;//10000001
	}
	else if(transdtl.transflag == TRANS_WRITE_CARD_FAILED)
	{
		ptcp_rt_transdtl->transflag = 0x83;//10000011
	}
	get_order_array_by_int(0, ptcp_rt_transdtl->additional, 3);//附加金额暂时为0
	get_order_array_by_int(transdtl.amount, ptcp_rt_transdtl->transamt, 4);
	decode_hex(transdtl.termno, 12, ptcp_rt_transdtl->termno);
	get_order_array_by_int(0, ptcp_rt_transdtl->machine_no, 4);//机器号暂时填0
	char transdatetime[15] = {0};
	SAFE_GET_DATETIME("%y%m%d%H%M%S", transdatetime);
	get_std_trans_datetime(transdatetime, ptcp_rt_transdtl->transdatetime, 6);
	//decode_hex(transdatetime, 12, ptcp_rt_transdtl->transdatetime);//日期时间
	
		//打印日期时间
	decode_hex(transdtl.tac, 8, ptcp_rt_transdtl->tac);
	int buffer_len = sizeof(p16_tcp_transdtl)-2;
	LOG((LOG_DEBUG,"参与crc的buffer_len=%d",buffer_len));
	pb_protocol_crc((const uint8 *)ptcp_rt_transdtl, buffer_len, ptcp_rt_transdtl->crc);
	return 0;
}
开发者ID:pennwin2014,项目名称:purchase_machine,代码行数:47,代码来源:p16main.c


示例11: serdes777_convstr

int32_t serdes777_convstr(int32_t encoding,void *dest,void *src,int32_t len)
{
    if ( encoding == 16 )
    {
        len >>= 1;
        decode_hex(dest,len,src);
        return(8 * len);
    }
开发者ID:apitests,项目名称:libjl777,代码行数:8,代码来源:serdes777.c


示例12: get_blacklist_data

//}}}
/////////////////////////////组包函数////////////////////////////////////////
static void get_blacklist_data(p16_tcp_blacklist_data* ptcp_blacklist_data)
{
	//get_order_array_by_int(0,ptcp_blacklist_data->machine_no,4);
	//memset(ptcp_blacklist_data->pos_blacklist_version,0,6);

	decode_hex(p16pos.devphyid, 8, ptcp_blacklist_data->machine_no);
	memcpy(ptcp_blacklist_data->pos_blacklist_version,p16pos.pos_blacklist_version, 6);
}
开发者ID:pennwin2014,项目名称:purchase_machine,代码行数:10,代码来源:p16main.c


示例13: load_sys_config

// }}}
// {{{ load_sys_config
static int load_sys_config()
{
    if (SAFE_GET_CONFIG("dev.devphyid", p16pos.devphyid))
        return -1;
	//读取黑名单版本号
	char pos_blacklist_version[13] = {0};
	if(SAFE_GET_CONFIG("dev.pos_blacklist_version",pos_blacklist_version))
		return -1;
	decode_hex(pos_blacklist_version, 12,p16pos.pos_blacklist_version);
    //LOG((LOG_DEBUG,"devphyid: %s",p16pos.devphyid));
    if (SAFE_GET_CONFIG("sys.appid", p16pos.appid))
        return -1;
    if (SAFE_GET_CONFIG("sys.appsecret", p16pos.appsecret))
        return -1;
	//获取前置的ip和端口号
    if (SAFE_GET_CONFIG("svc.remotename", p16pos.remote[REMOTE_WIRE].u.host.host_name))
    {
        return -1;
    }
    if (get_config_int("svc.remoteport", &(p16pos.remote[REMOTE_WIRE].u.host.host_port)))
    {
        return -1;
    }
    if (SAFE_GET_CONFIG("svc.remoteurl", p16pos.service_path))
    {
        return -1;
    }
    int pages;
    if (get_config_int("sys.printerpages", &pages))
    {
        return -1;
    }
    int cfgverno;
    if (get_config_int("sys.cfgverno", &cfgverno))
    {
        p16pos.cfgverno = 0;
		LOG((LOG_DEBUG,"获取sys.cfgverno失败"));
    }
    else
    {
        p16pos.cfgverno = cfgverno;
    }
    p16pos.printer_pages = (uint8)pages;

    if (get_config_int("sys.workmode", &(p16pos.work_mode)))
    {
        p16pos.work_mode = 0;
    }

    if (get_config_int("sys.heartbeatminutes", &(p16pos.heartbeat_minutes)))
    {
        p16pos.heartbeat_minutes = 0;
    }
    //memset( p16pos.termno, 0, sizeof p16pos.termno );
    //memcpy(p16pos.termno,"\x00\x00\x00\x05\x00\x04",6);
    setup_svc_url();
    return 0;
}
开发者ID:pennwin2014,项目名称:purchase_machine,代码行数:60,代码来源:p16main.c


示例14: ril_sms_notify

static void ril_sms_notify(GRilIoChannel *io, guint ril_event,
				const void *data, guint len, void *user_data)
{
	struct ril_sms *sd = user_data;
	GRilIoParser rilp;
	char *ril_pdu;
	int ril_pdu_len;
	unsigned int smsc_len;
	long ril_buf_len;
	guchar *ril_data;

	ril_pdu = NULL;
	ril_data = NULL;

	DBG("event: %d; data_len: %d", ril_event, len);

	grilio_parser_init(&rilp, data, len);
	ril_pdu = grilio_parser_get_utf8(&rilp);
	if (ril_pdu == NULL)
		goto error;

	ril_pdu_len = strlen(ril_pdu);

	DBG("ril_pdu_len is %d", ril_pdu_len);
	ril_data = decode_hex(ril_pdu, ril_pdu_len, &ril_buf_len, -1);
	if (ril_data == NULL)
		goto error;

	/* The first octect in the pdu contains the SMSC address length
	 * which is the X following octects it reads. We add 1 octet to
	 * the read length to take into account this read octet in order
	 * to calculate the proper tpdu length.
	 */
	smsc_len = ril_data[0] + 1;
	ofono_info("sms received, smsc_len is %d", smsc_len);
	DBG("(%s)", ril_pdu);

	if (ril_event == RIL_UNSOL_RESPONSE_NEW_SMS) {
		/* Last parameter is 'tpdu_len' ( substract SMSC length ) */
		ofono_sms_deliver_notify(sd->sms, ril_data, ril_buf_len,
						ril_buf_len - smsc_len);
	} else {
		GASSERT(ril_event == RIL_UNSOL_RESPONSE_NEW_SMS_STATUS_REPORT);
		ofono_sms_status_notify(sd->sms, ril_data, ril_buf_len,
						ril_buf_len - smsc_len);
	}

	g_free(ril_pdu);
	g_free(ril_data);
	ril_ack_delivery(sd, TRUE);
	return;

error:
	g_free(ril_pdu);
	g_free(ril_data);
	ril_ack_delivery(sd, FALSE);
	ofono_error("Unable to parse NEW_SMS notification");
}
开发者ID:Herrie82,项目名称:ofono-fix2,代码行数:58,代码来源:ril_sms.c


示例15: test_hex

static void test_hex(void)
{
  int       i;
  char      raw_data[32];
  size_t    raw_length;
  uint8_t  *encoded_data;
  uint64_t  encoded_length;
  uint8_t  *decoded_data;
  uint64_t  decoded_length;
  uint8_t   expected_data[32];
  uint64_t  expected_length;

  for(i = 0; i < 256; i++)
  {
    raw_length = sprintf(raw_data, "%c%c%c", i, i, i);
    encoded_data = encode_hex((uint8_t*)raw_data, raw_length, &encoded_length);
    expected_length = sprintf((char*)expected_data, "%02x%02x%02x", i, i, i);
    test_check_memory("encode_hex", expected_data, expected_length, encoded_data, encoded_length);
    free(encoded_data);
  }

  for(i = 0; i < 256; i++)
  {
    raw_length = sprintf(raw_data, "%02x%02x%02x", (uint8_t)(i - 1), (uint8_t)(i), (uint8_t)(i + 1));
    decoded_data = decode_hex((uint8_t*)raw_data, raw_length, &decoded_length);
    expected_length = sprintf((char*)expected_data, "%c%c%c", i - 1, i, i + 1);
    test_check_memory("decode_hex", expected_data, expected_length, decoded_data, decoded_length);
    free(decoded_data);
  }

  /* Side-case: odd numbers of hex digits. */
  decoded_data = decode_hex((uint8_t*)"41424", 5, &decoded_length);
  test_check_memory("decode_hex ('41424')", (uint8_t*)"AB", 2, decoded_data, decoded_length);
  free(decoded_data);

  /* Side-case: non-hex characters in the string. */
  decoded_data = decode_hex((uint8_t*)"414z4", 5, &decoded_length);
  test_check_memory("decode_hex ('414z4')", (uint8_t*)"A", 1, decoded_data, decoded_length);
  free(decoded_data);

  decoded_data = decode_hex((uint8_t*)"4141z4141", 9, &decoded_length);
  test_check_memory("decode_hex ('4141z4141')", (uint8_t*)"AAAA", 4, decoded_data, decoded_length);
  free(decoded_data);
}
开发者ID:5up3rc,项目名称:hash_extender,代码行数:44,代码来源:formats.c


示例16: return

char *SuperNET_gotpacket(char *msg,int32_t duration,char *ip_port)
{
    static int flood,duplicates;
    cJSON *json;
    uint16_t p2pport;
    struct pserver_info *pserver;
    uint64_t txid;
    struct sockaddr prevaddr;
    int32_t len,createdflag,valid;
    unsigned char packet[2*MAX_JSON_FIELD];
    char ipaddr[64],txidstr[64],retjsonstr[2*MAX_JSON_FIELD],verifiedNXTaddr[64],*cmdstr,*retstr;
    if ( SUPERNET_PORT != _SUPERNET_PORT )
        return(clonestr("{\"error\":private SuperNET}"));
    strcpy(retjsonstr,"{\"result\":null}");
    if ( Debuglevel > 2 )
        printf("gotpacket.(%s) duration.%d from (%s)\n",msg,duration,ip_port);
    if ( Finished_loading == 0 )
    {
        if ( is_hexstr(msg) == 0 )
        {
            //printf("QUEUE.(%s)\n",msg);
            return(block_on_SuperNET(0,msg));
        }
        return(clonestr(retjsonstr));
    }
    p2pport = parse_ipaddr(ipaddr,ip_port);
    uv_ip4_addr(ipaddr,0,(struct sockaddr_in *)&prevaddr);
    pserver = get_pserver(0,ipaddr,0,p2pport);
    len = (int32_t)strlen(msg);
    if ( is_hexstr(msg) != 0 )
    {
        len >>= 1;
        len = decode_hex(packet,len,msg);
        txid = calc_txid(packet,len);//hash,sizeof(hash));
        sprintf(txidstr,"%llu",(long long)txid);
        MTadd_hashtable(&createdflag,&Global_pNXT->msg_txids,txidstr);
        if ( createdflag == 0 )
        {
            duplicates++;
            return(clonestr("{\"error\":\"duplicate msg\"}"));
        }
        if ( (len<<1) == 30 ) // hack against flood
            flood++;
        if ( Debuglevel > 0 )
            printf("gotpacket %d | Finished_loading.%d | flood.%d duplicates.%d\n",duration,Finished_loading,flood,duplicates);
        if ( is_encrypted_packet(packet,len) != 0 )
            process_packet(0,retjsonstr,packet,len,0,&prevaddr,ipaddr,0);
        /*else if ( (obookid= is_orderbook_tx(packet,len)) != 0 )
        {
            if ( update_orderbook_tx(1,obookid,(struct orderbook_tx *)packet,txid) == 0 )
            {
                ((struct orderbook_tx *)packet)->txid = txid;
                sprintf(retjsonstr,"{\"result\":\"SuperNET_gotpacket got obbokid.%llu packet txid.%llu\"}",(long long)obookid,(long long)txid);
            } else sprintf(retjsonstr,"{\"result\":\"SuperNET_gotpacket error updating obookid.%llu\"}",(long long)obookid);
        }*/ else sprintf(retjsonstr,"{\"error\":\"SuperNET_gotpacket cant find obookid\"}");
    }
开发者ID:apex944,项目名称:btcd,代码行数:56,代码来源:libjl777.c


示例17: decode_hex

char *dpow_passthru(struct iguana_info *coin,char *function,char *hex)
{
    char params[32768]; int32_t len = 0;
    if ( hex != 0 && hex[0] != 0 )
    {
        len = (int32_t)strlen(hex) >> 1;
        if ( len < sizeof(params)-1 )
            decode_hex((uint8_t *)params,(int32_t)strlen(hex),hex);
        else len = 0;
    }
开发者ID:flamingice,项目名称:SuperNET,代码行数:10,代码来源:iguana_notary.c


示例18: tstring_hex

struct tstring *
tstring_hex(const char *hex)
{
  struct tstring *s;
  unsigned length = decode_hex_length(hex);

  s = tstring_alloc(length);

  decode_hex(s->data, hex);
  return s;
}
开发者ID:AllardJ,项目名称:Tomato,代码行数:11,代码来源:testutils.c


示例19: get_API_bits256

bits256 get_API_bits256(cJSON *obj)
{
    bits256 hash; char *str;
    memset(hash.bytes,0,sizeof(hash));
    if ( obj != 0 )
    {
        if ( is_cJSON_String(obj) != 0 && (str= obj->valuestring) != 0 && strlen(str) == 64 )
            decode_hex(hash.bytes,sizeof(hash),str);
    }
    return(hash);
}
开发者ID:rohvsh,项目名称:SuperNET,代码行数:11,代码来源:cJSON.c


示例20: ofono_error

struct reply_sim_io *g_ril_reply_parse_sim_io(GRil *gril,
						const struct ril_msg *message)
{
	struct parcel rilp;
	char *response = NULL;
	struct reply_sim_io *reply;

	/*
	 * Minimum length of SIM_IO_Response is 12:
	 * sw1 (int32)
	 * sw2 (int32)
	 * simResponse (string)
	 */
	if (message->buf_len < 12) {
		ofono_error("Invalid SIM IO reply: size too small (< 12): %d ",
			    (int) message->buf_len);
		return NULL;
	}

	reply =	g_new0(struct reply_sim_io, 1);

	g_ril_init_parcel(message, &rilp);
	reply->sw1 = parcel_r_int32(&rilp);
	reply->sw2 = parcel_r_int32(&rilp);

	response = parcel_r_string(&rilp);

	g_ril_append_print_buf(gril,
				"(sw1=0x%.2X,sw2=0x%.2X,%s)",
				reply->sw1,
				reply->sw2,
				response);
	g_ril_print_response(gril, message);

	if (rilp.malformed)
		goto error;

	if (response != NULL) {
		reply->hex_response =
			decode_hex(response, strlen(response),
					(long *) &reply->hex_len, -1);
		g_free(response);

		if (reply->hex_response == NULL)
			goto error;
	}

	return reply;

error:
	g_free(reply);

	return NULL;
}
开发者ID:morphis,项目名称:ofono,代码行数:54,代码来源:grilreply.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ decode_string函数代码示例发布时间:2022-05-30
下一篇:
C++ decode_fh函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap