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

C++ clonestr函数代码示例

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

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



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

示例1: return

char *nn_loadbalanced(uint8_t *data,int32_t len)
{
    char *msg,*jsonstr = 0;
    int32_t sendlen,i,lbsock,recvlen = 0;
    if ( (lbsock= RELAYS.lbclient) < 0 )
        return(clonestr("{\"error\":\"invalid load balanced socket\"}"));
    for (i=0; i<10; i++)
        if ( (nn_socket_status(lbsock,1) & NN_POLLOUT) != 0 )
            break;
    if ( Debuglevel > 2 )
        printf("sock.%d NN_LBSEND.(%s)\n",lbsock,data);
    //fprintf(stderr,"send to network\n");
    if ( (sendlen= nn_send(lbsock,data,len,0)) == len )
    {
        for (i=0; i<10; i++)
            if ( (nn_socket_status(lbsock,1) & NN_POLLIN) != 0 )
                break;
        if ( (recvlen= nn_recv(lbsock,&msg,NN_MSG,0)) > 0 )
        {
            if ( Debuglevel > 2 )
                printf("LBRECV.(%s)\n",msg);
            jsonstr = clonestr((char *)msg);
            nn_freemsg(msg);
        }
        else
        {
            printf("nn_loadbalanced got recvlen.%d %s\n",recvlen,nn_errstr());
            jsonstr = clonestr("{\"error\":\"lb recv error, probably timeout\"}");
        }
    } else printf("got sendlen.%d instead of %d %s\n",sendlen,len,nn_errstr()), jsonstr = clonestr("{\"error\":\"lb send error\"}");
    return(jsonstr);
}
开发者ID:satindergrewal,项目名称:btcd,代码行数:32,代码来源:relays777.c


示例2: calloc

char *block_on_SuperNET(int32_t blockflag,char *JSONstr)
{
    char **ptrs,*retstr,retbuf[1024];
    uint64_t txid = 0;
    ptrs = calloc(3,sizeof(*ptrs));
    ptrs[0] = clonestr(JSONstr);
    if ( blockflag == 0 )
    {
        txid = calc_txid((uint8_t *)JSONstr,(int32_t)strlen(JSONstr));
        ptrs[2] = (char *)txid;
    }
    if ( Debuglevel > 2 )
        printf("block.%d QUEUE.(%s)\n",blockflag,JSONstr);
    queue_enqueue(&JSON_Q,ptrs);
    if ( blockflag != 0 )
    {
        while ( (retstr= ptrs[1]) == 0 )
            usleep(1000);
        if ( ptrs[0] != 0 )
            free(ptrs[0]);
        free(ptrs);
        //printf("block.%d returned.(%s)\n",blockflag,retstr);
        return(retstr);
    }
    else
    {
        sprintf(retbuf,"{\"result\":\"pending SuperNET API call\",\"txid\":\"%llu\"}",(long long)txid);
        //printf("queue.%d returned.(%s)\n",blockflag,retbuf);
        return(clonestr(retbuf));
    }
}
开发者ID:apex944,项目名称:btcd,代码行数:31,代码来源:libjl777.c


示例3: memset

char *instantdex_sendcmd(struct supernet_info *myinfo,cJSON *argjson,char *cmdstr,char *ipaddr,int32_t hops)
{
    char *reqstr,hexstr[8192]; uint8_t _msg[4096]; uint64_t nxt64bits; int32_t datalen;
    bits256 instantdexhash; struct instantdex_msghdr *msg;
    msg = (struct instantdex_msghdr *)_msg;
    memset(msg,0,sizeof(*msg));
    instantdexhash = calc_categoryhashes(0,"InstantDEX",0);
    category_subscribe(myinfo,instantdexhash,GENESIS_PUBKEY);
    if ( ipaddr == 0 || ipaddr[0] == 0 || strncmp(ipaddr,"127.0.0.1",strlen("127.0.0.1")) == 0 )
        return(clonestr("{\"error\":\"no ipaddr, need to send your ipaddr for now\"}"));
    jaddstr(argjson,"cmd",cmdstr);
    jaddstr(argjson,"agent","SuperNET");
    jaddstr(argjson,"method","DHT");
    jaddstr(argjson,"traderip",ipaddr);
    jaddbits256(argjson,"categoryhash",instantdexhash);
    jaddbits256(argjson,"traderpub",myinfo->myaddr.persistent);
    nxt64bits = acct777_nxt64bits(myinfo->myaddr.persistent);
    reqstr = jprint(argjson,1);
    datalen = (int32_t)(strlen(reqstr) + 1);
    memcpy(msg->serialized,reqstr,datalen);
    free(reqstr);
    if ( (datalen+sizeof(*msg))*2+1 < sizeof(hexstr) && instantdex_msgcreate(myinfo,msg,datalen) != 0 )
    {
        printf("instantdex send.(%s)\n",cmdstr);
        init_hexbytes_noT(hexstr,(uint8_t *)msg,msg->sig.allocsize);
        return(SuperNET_categorymulticast(myinfo,0,instantdexhash,GENESIS_PUBKEY,hexstr,0,hops,1));
    }
    else
    {
        printf("cant msgcreate\n");
        return(clonestr("{\"error\":\"couldnt create instantdex message\"}"));
    }
}
开发者ID:ceda018,项目名称:SuperNET,代码行数:33,代码来源:iguana_instantdex.c


示例4: jdouble

char *WITHDRAW(struct exchange_info *exchange,cJSON *argjson)
{
    char payload[1024],*method,*base,*destaddr,*type,*retstr = 0; cJSON *json; double amount;
    amount = jdouble(argjson,"amount");
    if ( (destaddr= jstr(argjson,"destaddr")) == 0 || amount < SMALLVAL )
        return(clonestr("{\"error\":\"no destaddr specified or amount too small\"}"));
    if ( (base= jstr(argjson,"base")) == 0 )
        base = "bitcoin";
    else if ( strcmp(base,"BTC") == 0 )
        base = "bitcoin";
    else if ( strcmp(base,"LTC") == 0 )
        base = "litecoin";
    else if ( strcmp(base,"DRK") == 0 )
        base = "darkcoin";
    else return(clonestr("{\"error\":\"invalid base specified\"}"));
    if ( (type= jstr(argjson,"extra")) == 0 )
        type = "exchange";
    else if ( strcmp(type,"exchange") != 0 && strcmp(type,"trading") != 0 && strcmp(type,"deposit") != 0 )
        return(clonestr("{\"error\":\"invalid wallet type specified\"}"));
    method = "withdraw";
    sprintf(payload,"{\"request\":\"/v1/%s\",\"nonce\":\"%llu\",\"amount\":\"%.6f\",\"withdraw_type\":\"%s\",\"walletselected\":\"%s\",\"address\":\"%s\"}",method,(long long)exchange_nonce(exchange),amount,base,type,destaddr);
    if ( (json= SIGNPOST(&retstr,exchange,payload,method)) != 0 )
    {
        free_json(json);
    }
    return(retstr); // return standardized withdraw
}
开发者ID:jonesnxt,项目名称:SuperNET_API,代码行数:27,代码来源:bitfinex.c


示例5: STRING_ARG

STRING_ARG(iguana,addcoin,newcoin)
{
    char *symbol,*seedip; int32_t retval;
    if ( (symbol= newcoin) == 0 && coin != 0 )
        symbol = coin->symbol;
    if ( symbol != 0 )
    {
        if ( (seedip= jstr(json,"seedipaddr")) != 0 )
            safecopy(myinfo->seedipaddr,seedip,sizeof(myinfo->seedipaddr));
        printf(">> addcoin.%s seedipaddr.%s\n",symbol,myinfo->seedipaddr);
#ifdef __PNACL__
        //        if ( strcmp(symbol,"BTC") == 0 )
        //            return(clonestr("{\"result\":\"BTC for chrome app is not yet\"}"));
#endif
        if ( (retval= iguana_launchcoin(myinfo,symbol,json,0)) > 0 )
        {
            if ( myinfo->rpcsymbol[0] == 0 )
                safecopy(myinfo->rpcsymbol,symbol,sizeof(myinfo->rpcsymbol));
            return(clonestr("{\"result\":\"coin added\"}"));
        }
        else if ( retval == 0 )
            return(clonestr("{\"result\":\"coin already there\"}"));
        else return(clonestr("{\"error\":\"error adding coin\"}"));
    } else return(clonestr("{\"error\":\"addcoin needs newcoin\"}"));
}
开发者ID:flamingice,项目名称:SuperNET,代码行数:25,代码来源:ramchain_api.c


示例6: return

char *instantdex_confirmed(struct supernet_info *myinfo,struct instantdex_msghdr *msg,cJSON *argjson,char *remoteaddr,uint64_t signerbits,uint8_t *data,int32_t datalen)
{
    if ( argjson != 0 )
    {
        return(clonestr("{\"result\":\"proposal was confirmed\"}"));
    } else return(clonestr("{\"error\":\"response needs argjson\"}"));
}
开发者ID:ceda018,项目名称:SuperNET,代码行数:7,代码来源:iguana_instantdex.c


示例7: return

char *teleport_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr)
{
    //static char *teleport[] = { (char *)teleport_func, "teleport", "V", "NXT", "secret", "amount", "dest", "coin", "minage", 0 };
    double amount;
    int32_t M,N;
    struct coin_info *cp;
    char NXTACCTSECRET[512],destaddr[512],minage[512],coinstr[512],*retstr = 0;
    if ( Historical_done == 0 )
        return(clonestr("historical processing is not done yet"));
    copy_cJSON(NXTACCTSECRET,objs[1]);
    amount = get_API_float(objs[2]);
    copy_cJSON(destaddr,objs[3]);
    copy_cJSON(coinstr,objs[4]);
    copy_cJSON(minage,objs[5]);
    M = get_API_int(objs[6],1);
    N = get_API_int(objs[7],1);
    if ( M > N || N >= 0xff || M <= 0 )
        M = N = 1;
    printf("amount.(%.8f) minage.(%s) %d | M.%d N.%d\n",amount,minage,atoi(minage),M,N);
    cp = get_coin_info(coinstr);
    if ( cp != 0 && sender[0] != 0 && amount > 0 && valid != 0 && destaddr[0] != 0 )
        retstr = teleport(sender,NXTACCTSECRET,(uint64_t)(SATOSHIDEN * amount),destaddr,cp,atoi(minage),M,N);
    else retstr = clonestr("{\"error\":\"invalid teleport request\"}");
    return(retstr);
}
开发者ID:Bitcoinsulting,项目名称:libjl777,代码行数:25,代码来源:jl777.cpp


示例8: printf

char *gecko_headersarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 firsthash2)
{
    bits256 hash2,prevhash2; struct iguana_block *block; int32_t height,firstheight,i,len=0,n,num; struct iguana_msgzblock zmsgB; char str[65],str2[65];
    num = (int32_t)(datalen / 84);
    printf("headers.%s arrived.%d from %s\n",virt->symbol,num,bits256_str(str,firsthash2));
    if ( (block= iguana_blockfind("geckohdrs",virt,firsthash2)) != 0 && (firstheight= block->height) >= 0 )
    {
        gecko_blockhashupdate(virt,firsthash2,firstheight);
        prevhash2 = firsthash2;
        for (i=0; i<num; i++)
        {
            if ( (n= iguana_rwblock(myinfo,virt->symbol,virt->chain->zcash,virt->chain->auxpow,virt->chain->hashalgo,0,&hash2,&data[len],&zmsgB,datalen-len)) > 0 )
            {
                if ( bits256_cmp(zmsgB.zH.prev_block,prevhash2) == 0 )
                {
                    height = (firstheight + i + 1);
                    gecko_blockhashupdate(virt,hash2,height);
                    printf("ht.%d %s\n",height,bits256_str(str,hash2));
                } else printf("ht.%d non prevhash i.%d %s %s\n",height,i,bits256_str(str,prevhash2),bits256_str(str2,zmsgB.zH.prev_block));
                len += n;
                prevhash2 = hash2;
            }
        }
        return(clonestr("{\"result\":\"gecko headers processed\"}"));
    } else return(clonestr("{\"error\":\"gecko headers couldnt find firsthash2\"}"));
}
开发者ID:jl777,项目名称:SuperNET,代码行数:26,代码来源:gecko_headers.c


示例9: TWO_STRINGS

TWO_STRINGS(iguana,oneshot,activecoin,ipaddr)
{
    if ( coin != 0 && ipaddr != 0 )
    {
        iguana_possible_peer(coin,ipaddr);
        return(clonestr("{\"result\":\"addnode submitted\"}"));
    } else return(clonestr("{\"error\":\"addnode needs coin and ipaddr\"}"));
}
开发者ID:flamingice,项目名称:SuperNET,代码行数:8,代码来源:ramchain_api.c


示例10: STRING_ARG

STRING_ARG(iguana,initfastfind,activecoin)
{
    if ( (coin= iguana_coinfind(activecoin)) != 0 )
    {
        iguana_fastfindcreate(coin);
        return(clonestr("{\"result\":\"fast find initialized\"}"));
    } else return(clonestr("{\"error\":\"no coin to initialize\"}"));
}
开发者ID:yangli123,项目名称:SuperNET,代码行数:8,代码来源:ramchain_api.c


示例11: calc_nxt64bits

char *placequote_func(int32_t dir,char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr)
{
    int32_t polarity;
    uint64_t obookid,nxt64bits,assetA,assetB,txid;
    double price,volume;
    struct orderbook_tx tx;
    char buf[1024],txidstr[512],*retstr = 0;
    nxt64bits = calc_nxt64bits(sender);
    obookid = get_API_nxt64bits(objs[1]);
    polarity = get_API_int(objs[2],1);
    if ( polarity == 0 )
        polarity = 1;
    volume = get_API_float(objs[3]);
    price = get_API_float(objs[4]);
    assetA = get_API_nxt64bits(objs[5]);
    assetB = get_API_nxt64bits(objs[6]);
    printf("PLACE QUOTE polarity.%d dir.%d\n",polarity,dir);
    if ( sender[0] != 0 && find_raw_orders(obookid) != 0 && valid != 0 )
    {
        if ( price != 0. && volume != 0. && dir != 0 )
        {
            if ( dir*polarity > 0 )
                bid_orderbook_tx(&tx,0,nxt64bits,obookid,price,volume);
            else ask_orderbook_tx(&tx,0,nxt64bits,obookid,price,volume);
            txid = pNXT_submit_tx(Global_pNXT->core,Global_pNXT->wallet,(unsigned char *)&tx,sizeof(tx));
            if ( txid != 0 )
            {
                expand_nxt64bits(txidstr,txid);
                sprintf(buf,"{\"txid\":\"%s\"}",txidstr);
                retstr = clonestr(buf);
            }
        }
        if ( retstr == 0 )
        {
            sprintf(buf,"{\"error submitting\":\"place%s error obookid.%llx polarity.%d volume %f price %f\"}",dir>0?"bid":"ask",(long long)obookid,polarity,volume,price);
            retstr = clonestr(buf);
        }
    }
    else if ( assetA != 0 && assetB != 0 && assetA != assetB )
    {
        if ( (obookid= create_raw_orders(assetA,assetB)) != 0 )
        {
            sprintf(buf,"{\"obookid\":\"%llu\"}",(long long)obookid);
            retstr = clonestr(buf);
        }
        else
        {
            sprintf(buf,"{\"error\":\"couldnt create orderbook for assets %llu and %llu\"}",(long long)assetA,(long long)assetB);
            retstr = clonestr(buf);
        }
    }
    else
    {
        sprintf(buf,"{\"error\":\"place%s error obookid.%llx polarity.%d volume %f price %f\"}",polarity>0?"bid":"ask",(long long)obookid,polarity,volume,price);
        retstr = clonestr(buf);
    }
    return(retstr);
}
开发者ID:Bitcoinsulting,项目名称:libjl777,代码行数:58,代码来源:jl777.cpp


示例12: ZERO_ARGS

ZERO_ARGS(bitcoinrpc,getdifficulty)
{
    char buf[512];
    if ( coin != 0 )
    {
        sprintf(buf,"{\"result\":\"success\",\"proof-of-work\":\"%.8f\",\"search-interval\": 0}",PoW_from_compact(coin->blocks.hwmchain.RO.bits,coin->chain->unitval));
        return(clonestr(buf));
    } else return(clonestr("{\"error\":\"getdifficulty needs coin\"}"));
}
开发者ID:flamingice,项目名称:SuperNET,代码行数:9,代码来源:ramchain_api.c


示例13: 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


示例14: SS_D_I_S

SS_D_I_S(bitcoinrpc,move,fromaccount,toaccount,amount,minconf,comment)
{
    cJSON *retjson;
    if ( remoteaddr != 0 )
        return(clonestr("{\"error\":\"no remote\"}"));
    if ( myinfo->expiration == 0 )
        return(clonestr("{\"error\":\"need to unlock wallet\"}"));
    retjson = cJSON_CreateObject();
    return(jprint(retjson,1));
}
开发者ID:yangli123,项目名称:SuperNET,代码行数:10,代码来源:ramchain_api.c


示例15: return

char *WITHDRAW(void **cHandlep,struct exchange_info *exchange,cJSON *argjson)
{
    char buf[1024],*base,*destaddr; double amount;
    if ( (base= jstr(argjson,"base")) == 0 || strcmp(base,"BTC") != 0 )
        return(clonestr("{\"error\":\"base not specified or base != BTC\"}"));
    if ( (destaddr= jstr(argjson,"destaddr")) == 0 )
        return(clonestr("{\"error\":\"destaddr not specified\"}"));
    if ( (amount= jdouble(argjson,"amount")) < SMALLVAL )
        return(clonestr("{\"error\":\"amount not specified\"}"));
    sprintf(buf,"\"amount\":%.4f,\"address\":\"%s\",",amount,destaddr);
    printf("submit.(%s)\n",buf);
    return(jprint(SIGNPOST(cHandlep,1,0,exchange,"","bitcoin_withdrawal"),1));
}
开发者ID:Miyurz,项目名称:SuperNET,代码行数:13,代码来源:quadriga.c


示例16: return

char *WITHDRAW(struct exchange_info *exchange,char *base,double amount,char *destaddr,cJSON *argjson)
{
    char payload[1024],*method;
    if ( base == 0 || base[0] == 0 )
        return(clonestr("{\"error\":\"base not specified\"}"));
    if ( destaddr == 0 || destaddr[0] == 0 )
        return(clonestr("{\"error\":\"destaddr not specified\"}"));
    if ( amount < SMALLVAL )
        return(clonestr("{\"error\":\"amount not specified\"}"));
    method = "withdraw_coin";
    sprintf(payload,"&coin_type=1&withdraw_address=%s&withdraw_amount=%.4f",destaddr,amount);
    return(jprint(huobi_issue_auth(&exchange->cHandle,exchange,method,payload),1));
}
开发者ID:Miyurz,项目名称:SuperNET,代码行数:13,代码来源:huobi.c


示例17: return

char *WITHDRAW(struct exchange_info *exchange,cJSON *argjson)
{
    char payload[1024],*base,*destaddr,*method; double amount;
    if ( (base= jstr(argjson,"base")) == 0 || strcmp(base,"BTC") != 0 )
        return(clonestr("{\"error\":\"base not specified or base != BTC\"}"));
    if ( (destaddr= jstr(argjson,"destaddr")) == 0 )
        return(clonestr("{\"error\":\"destaddr not specified\"}"));
    if ( (amount= jdouble(argjson,"amount")) < SMALLVAL )
        return(clonestr("{\"error\":\"amount not specified\"}"));
    method = "withdraw_coin";
    sprintf(payload,"&coin_type=1&withdraw_address=%s&withdraw_amount=%.4f",destaddr,amount);
    return(jprint(huobi_issue_auth(exchange,method,payload),1));
}
开发者ID:jonesnxt,项目名称:SuperNET_API,代码行数:13,代码来源:huobi.c


示例18: copy_cJSON

char *tradebot_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr)
{
    static char *buf;
    static int64_t filelen,allocsize;
    long len;
    cJSON *botjson;
    char NXTACCTSECRET[512],code[4096],retbuf[4096],*str,*retstr = 0;
    copy_cJSON(NXTACCTSECRET,objs[1]);
    copy_cJSON(code,objs[2]);
    printf("tradebotfunc.(%s) sender.(%s) valid.%d code.(%s)\n",origargstr,sender,valid,code);
    if ( sender[0] != 0 && valid != 0 && code[0] != 0 )
    {
        len = strlen(code);
        if ( code[0] == '(' && code[len-1] == ')' )
        {
            code[len-1] = 0;
            str = load_file(code+1,&buf,&filelen,&allocsize);
            if ( str == 0 )
            {
                sprintf(retbuf,"{\"error\":\"cant open (%s)\"}",code+1);
                return(clonestr(retbuf));
            }
        }
        else
        {
            str = code;
            //printf("str is (%s)\n",str);
        }
        if ( str != 0 )
        {
            //printf("before.(%s) ",str);
            replace_singlequotes(str);
            //printf("after.(%s)\n",str);
            if ( (botjson= cJSON_Parse(str)) != 0 )
            {
                retstr = start_tradebot(sender,NXTACCTSECRET,botjson);
                free_json(botjson);
            }
            else
            {
                str[sizeof(retbuf)-128] = 0;
                sprintf(retbuf,"{\"error\":\"couldnt parse (%s)\"}",str);
                printf("%s\n",retbuf);
            }
            if ( str != code )
                free(str);
        }
    }
    else retstr = clonestr("{\"result\":\"invalid tradebot request\"}");
    return(retstr);
}
开发者ID:Bitcoinsulting,项目名称:libjl777,代码行数:51,代码来源:jl777.cpp


示例19: get_API_nxt64bits

char *orderbook_func(char *sender,int32_t valid,cJSON **objs,int32_t numobjs,char *origargstr)
{
    int32_t i,polarity,allflag;
    uint64_t obookid;
    cJSON *json,*bids,*asks,*item;
    struct orderbook *op;
    char obook[512],buf[512],assetA[64],assetB[64],*retstr = 0;
    obookid = get_API_nxt64bits(objs[1]);
    expand_nxt64bits(obook,obookid);
    polarity = get_API_int(objs[2],1);
    if ( polarity == 0 )
        polarity = 1;
    allflag = get_API_int(objs[3],0);
    if ( obookid != 0 && (op= create_orderbook(obookid,polarity,0,0)) != 0 )
    {
        if ( op->numbids == 0 && op->numasks == 0 )
            retstr = clonestr("{\"error\":\"no bids or asks\"}");
        else
        {
            json = cJSON_CreateObject();
            bids = cJSON_CreateArray();
            for (i=0; i<op->numbids; i++)
            {
                item = create_order_json(&op->bids[i],1,allflag);
                cJSON_AddItemToArray(bids,item);
            }
            asks = cJSON_CreateArray();
            for (i=0; i<op->numasks; i++)
            {
                item = create_order_json(&op->asks[i],1,allflag);
                cJSON_AddItemToArray(asks,item);
            }
            expand_nxt64bits(assetA,op->assetA);
            expand_nxt64bits(assetB,op->assetB);
            cJSON_AddItemToObject(json,"orderbook",cJSON_CreateString(obook));
            cJSON_AddItemToObject(json,"assetA",cJSON_CreateString(assetA));
            cJSON_AddItemToObject(json,"assetB",cJSON_CreateString(assetB));
            cJSON_AddItemToObject(json,"polarity",cJSON_CreateNumber(polarity));
            cJSON_AddItemToObject(json,"bids",bids);
            cJSON_AddItemToObject(json,"asks",asks);
            retstr = cJSON_Print(json);
        }
        free_orderbook(op);
    } else
    {
        sprintf(buf,"{\"error\":\"no such orderbook.(%llu)\"}",(long long)obookid);
        retstr = clonestr(buf);
    }
    return(retstr);
}
开发者ID:Bitcoinsulting,项目名称:libjl777,代码行数:50,代码来源:jl777.cpp


示例20: parse_option

static void parse_option(config_ptr config, char *s1, char *s2)
{
    if (!strcmp(s1, "showmoves")) {
	config->showmoves = atoi(s2);
    }
    if (!strcmp(s1, "fontsize")) {
	config->fontsize = atoi(s2);
    }
    if (!strcmp(s1, "font")) {
	config->fontname = clonestr(s2);
    }
    if (!strcmp(s1, "hiscores")) {
	config->hsfile = clonestr(s2);
    }
}
开发者ID:0265727207,项目名称:evandrix.github.com,代码行数:15,代码来源:config.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ close函数代码示例发布时间:2022-05-30
下一篇:
C++ clonep函数代码示例发布时间: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