コード例 #1
0
bool Bitmaszyna::getAccountInfo()
{
    struct json_object *json,*jtmp,*jtmp2,*jtmp3;
    struct array_list *arr,*arr2;
    int i,j;

    curl_mutex.lock();
    if (makeApiCall("accountInfo",&json,string("nonce=")+to_stringl(getctime()).toStdString()))
    {
        if (!fetchData(&json,&jtmp)) return(false);
        log(string(chunk.memory)+"\n");
        json_object_object_get_ex(json,"deposits",&jtmp);
        arr=json_object_get_array(jtmp);
        deposits.clear();
        for(i=0;i<arr->length;i++)
        {
            Deposit d;

            jtmp2=(struct json_object *)array_list_get_idx(arr,i);
            json_object_object_get_ex(jtmp2,"currency",&jtmp3);
            d.currency=json_object_get_string(jtmp3);
            json_object_object_get_ex(jtmp2,"bank_name",&jtmp3);
            d.bank_name=json_object_get_string(jtmp3);
            json_object_object_get_ex(jtmp2,"pay_to",&jtmp3);
            d.pay_to=json_object_get_string(jtmp3);
            json_object_object_get_ex(jtmp2,"acc_num",&jtmp3);
            d.acc_num=json_object_get_string(jtmp3);
            json_object_object_get_ex(jtmp2,"swift_code",&jtmp3);
            d.swift_code=json_object_get_string(jtmp3);
            json_object_object_get_ex(jtmp2,"transfer_title",&jtmp3);
            d.transfer_title=json_object_get_string(jtmp3);
            deposits.push_back(d);
        }
        json_object_object_get_ex(json,"withdrawalAccounts",&jtmp);
        arr=json_object_get_array(jtmp);
        for(j=0;j<arr->length;j++)
        {
            withdrawalaccounts[j].clear();
            arr2=json_object_get_array((struct json_object *)array_list_get_idx(arr,j));
            for(i=0;i<arr2->length;)
            {
                WithdrawalAccount w;
                jtmp2=(struct json_object *)array_list_get_idx(arr2,i);
                w.account=json_object_get_string(jtmp2);
                i++;
                jtmp2=(struct json_object *)array_list_get_idx(arr2,i);
                w.name=json_object_get_string(jtmp2);
                i++;
                if (w.account.size()>0) withdrawalaccounts[adjustCurrency(j)].push_back(w);
            }
        }
        json_object_put(json);
        logged=true;
        curl_mutex.unlock();
        return(true);
    }
    curl_mutex.unlock();
    return(false);
}
コード例 #2
0
ファイル: metaparser.cpp プロジェクト: 4doe/enigma2-old
int eDVBMetaParser::parseRecordings(const std::string &filename)
{
	std::string::size_type slash = filename.rfind('/');
	if (slash == std::string::npos)
		return -1;
	
	std::string recordings = filename.substr(0, slash) + "/recordings.epl";
	
	FILE *f = fopen(recordings.c_str(), "r");
	if (!f)
	{
//		eDebug("no recordings.epl found: %s: %m", recordings.c_str());
		return -1;
	}
	
	std::string description;
	eServiceReferenceDVB ref;
	
//	eDebug("parsing recordings.epl..");
	
	while (1)
	{
		char line[1024];
		if (!fgets(line, 1024, f))
			break;
		
		size_t len = strlen(line);
		if (len < 2)
			// Lines with less than one char aren't meaningful
			continue;
		// Remove trailing \r\n
		--len;
		line[len] = 0;
		if (line[len-1] == '\r')
			line[len-1] = 0;
		
		if (strncmp(line, "#SERVICE: ", 10) == 0)
			ref = eServiceReferenceDVB(line + 10);
		else if (strncmp(line, "#DESCRIPTION: ", 14) == 0)
			description = line + 14;
		else if ((line[0] == '/') && (ref.path.substr(ref.path.find_last_of('/')) == filename.substr(filename.find_last_of('/'))))
		{
//			eDebug("hit! ref %s descr %s", m_ref.toString().c_str(), m_name.c_str());
			m_ref = ref;
			m_name = description;
			m_description = "";
			m_time_create = getctime(filename);
			m_length = 0;
			m_filesize = fileSize(filename);
			m_data_ok = 1;
			m_scrambled = 0;
			fclose(f);
			updateMeta(filename);
			return 0;
		}
	}
	fclose(f);
	return -1;
}
コード例 #3
0
bool Bitmaszyna::cancelorder(string id)
{
#ifdef ARMED
    return(makeSimpleApiCall("canceloffer",string("nonce=")+to_stringl(getctime()).toStdString()+"&id="+id));
#else
    Q_UNUSED(id);
    return(true);
#endif
}
コード例 #4
0
void
rwrite(struct rtpp_session *sp, void *rrc, struct sockaddr *saddr, void *buf, int len)
{
    struct iovec v[2];
    struct pkt_hdr hdr;
    int rval;

    if (RRC_CAST(rrc)->fd == -1)
        return;

    memset(&hdr, 0, sizeof(hdr));

    hdr.time = getctime();
    if (hdr.time == -1) {
	rtpp_log_ewrite(RTPP_LOG_ERR, sp->log, "can't get current time");
	goto fatal_error;
    }

    switch (saddr->sa_family) {
    case AF_INET:
	hdr.addr.in4.sin_family = saddr->sa_family;
	hdr.addr.in4.sin_port = satosin(saddr)->sin_port;
	hdr.addr.in4.sin_addr = satosin(saddr)->sin_addr;
	break;

    case AF_INET6:
	hdr.addr.in6.sin_family = saddr->sa_family;
	hdr.addr.in6.sin_port = satosin6(saddr)->sin6_port;
	hdr.addr.in6.sin_addr = satosin6(saddr)->sin6_addr;
	break;

    default:
	abort();
    }

    hdr.plen = len;

    v[0].iov_base = (void *)&hdr;
    v[0].iov_len = sizeof(hdr);
    v[1].iov_base = buf;
    v[1].iov_len = len;

    rval = writev(RRC_CAST(rrc)->fd, v, 2);
    if (rval != -1)
	return;

    rtpp_log_ewrite(RTPP_LOG_ERR, sp->log, "error while recording session (%s)",
      (sp->rtcp != NULL) ? "RTP" : "RTCP");
fatal_error:
    /* Prevent futher writing if error happens */
    close(RRC_CAST(rrc)->fd);
    RRC_CAST(rrc)->fd = -1;
}
コード例 #5
0
bool Bitmaszyna::withdraw(double amount,const string& currency,const string& address,const string& swift,const string& note,bool test,bool fast,double& fee)
{
    Q_UNUSED(swift);
    Q_UNUSED(note);
    Q_UNUSED(test);
    Q_UNUSED(fee);
    string ex;

    if (test) return(true);
    if (fast) ex="true";
    else ex="false";
    return(makeSimpleApiCall("withdrawal",string("nonce=")+to_stringl(getctime()).toStdString()+"&account="+address+"&amount="+to_stringd(amount).toStdString()+"&cur="+currency+"&express="+ex));
}
コード例 #6
0
ファイル: aho.c プロジェクト: kengonakajima/snippets
int test()
{
#define WINDOWSIZ 100
	
	char buf[WINDOWSIZ];
	char ttt[100];
	int i;


	getctime( ttt );
	printf( "start 1 %s\n" ,ttt);
	for(i=0;i<BUFSZ/1024;i+=100 ){
		buf[0] = i;
		memWrite( buf , i * 1024   , WINDOWSIZ );
	}

	for(i=0;i<BUFSZ/1024;i+=100 ){
		buf[0] = i;
		memRead( buf , (i + 50) * 1024   , WINDOWSIZ );
	}
	getctime(ttt);
	printf( "start 2 %s\n" ,ttt);

	for(i=0;i<BUFSZ/1024;i+=100 ){
		buf[0] = i;
		memWrite( buf , (i + 10 )* 1024   , WINDOWSIZ );
	}

	for(i=0;i<BUFSZ/1024;i+=100 ){
		buf[0] = i;
		memRead( buf , (i + 10) * 1024   , WINDOWSIZ );
	}
	getctime(ttt);
	printf( "start 3 %s\n" ,ttt);

	
	
	
}
コード例 #7
0
ファイル: metaparser.cpp プロジェクト: andistudio/enigma2
int eDVBMetaParser::parseFile(const std::string &basename)
{
		/* first, try parsing the .meta file */
	if (!parseMeta(basename))
		return 0;

		/* otherwise, use recordings.epl */
	if (!parseRecordings(basename))
		return 0;
	m_filesize = fileSize(basename);
	m_time_create = getctime(basename);
	return -1;
}
コード例 #8
0
bool Bitmaszyna::tradepair(double price,double amount,char type,string market)
{
#ifdef ARMED
    string b;

    if (type==BUY) b="buy";
    else if (type==SELL) b="sell";

    return(makeSimpleApiCall(market+"/"+b,string("nonce=")+to_stringl(getctime()).toStdString()+"&price="+to_stringp(price).toStdString()+"&amount="+to_stringd(amount).toStdString()+"&offer=true"));
#else
    Q_UNUSED(price);
    Q_UNUSED(amount);
    Q_UNUSED(type);
    Q_UNUSED(market);
    return(true);
#endif
}
コード例 #9
0
bool Bitmaszyna::getfunds()
{    
    struct json_object *json,*jtmp,*jtmp2;

    curl_mutex.lock();
    if (makeApiCall("funds",&json,string("nonce=")+to_stringl(getctime()).toStdString()))
    {
        if (!fetchData(&json,&jtmp)) return(false);
        log(string(chunk.memory)+"\n");
        json_object_object_get_ex(json,"funds",&jtmp);
        json_object_object_get_ex(jtmp,"available_btc",&jtmp2);
        balance.balance[BTC]=json_object_get_double(jtmp2);
        json_object_object_get_ex(jtmp,"blocked_btc",&jtmp2);
        balance.blocked[BTC]=json_object_get_double(jtmp2);
        json_object_object_get_ex(jtmp,"available_ltc",&jtmp2);
        balance.balance[LTC]=json_object_get_double(jtmp2);
        json_object_object_get_ex(jtmp,"blocked_ltc",&jtmp2);
        balance.blocked[LTC]=json_object_get_double(jtmp2);
        json_object_object_get_ex(jtmp,"available_kbm",&jtmp2);
        balance.balance[KBM]=json_object_get_double(jtmp2);
        json_object_object_get_ex(jtmp,"blocked_kbm",&jtmp2);
        balance.blocked[KBM]=json_object_get_double(jtmp2);
        json_object_object_get_ex(jtmp,"available_pln",&jtmp2);
        balance.balance[PLN]=json_object_get_double(jtmp2);
        json_object_object_get_ex(jtmp,"blocked_pln",&jtmp2);
        balance.blocked[PLN]=json_object_get_double(jtmp2);
        json_object_object_get_ex(jtmp,"takerfee",&jtmp2);
        fees.taker=json_object_get_double(jtmp2);
        json_object_object_get_ex(jtmp,"makerfee",&jtmp2);
        fees.maker=json_object_get_double(jtmp2);
        json_object_put(json);
        logged=true;
        curl_mutex.unlock();
        return(getAccountInfo());
    }
    curl_mutex.unlock();
    return(false);
}
コード例 #10
0
bool Bitmaszyna::getopenorders(string)
{
    struct json_object *json,*jtmp;
    struct array_list *arr;
    int i;
    Offer o;

    curl_mutex.lock();
    orders.clear();
    if (makeApiCall("offers",&json,string("nonce=")+to_stringl(getctime()).toStdString()))
    {
        if (!fetchData(&json,&jtmp)) return(false);
        json_object_object_get_ex(json,"orders",&jtmp);
        arr=json_object_get_array(jtmp);
        for(i=0;i<arr->length;i++)
        {
            struct json_object *jtmp3,*jtmp4;

            jtmp3=(struct json_object *)array_list_get_idx(arr,i);
            json_object_object_get_ex(jtmp3,"id",&jtmp4);
            o.id=to_stringl(json_object_get_int(jtmp4)).toStdString();
            json_object_object_get_ex(jtmp3,"price",&jtmp4);
            o.price=json_object_get_double(jtmp4);
            json_object_object_get_ex(jtmp3,"amount",&jtmp4);
            o.amount=json_object_get_double(jtmp4);
            json_object_object_get_ex(jtmp3,"type",&jtmp4);
            o.type=json_object_get_double(jtmp4);
            orders.push_back(o);
        }
        json_object_put(json);
        curl_mutex.unlock();
        return(true);
    }
    curl_mutex.unlock();
    return(false);
}
コード例 #11
0
ファイル: metaparser.cpp プロジェクト: andistudio/enigma2
int eDVBMetaParser::parseMeta(const std::string &tsname)
{
	/* if it's a PVR channel, recover service id. */
	std::string filename = tsname + ".meta";
	CFile f(filename.c_str(), "r");

	if (!f)
		return -ENOENT;

	int linecnt = 0;

	m_time_create = 0;

	while (1)
	{
		char line[4096];
		if (!fgets(line, 4096, f))
			break;
		size_t len = strlen(line);
		if (len && line[len-1] == '\n')
		{
			--len;
			line[len] = 0;
		}
 		if (len && line[len-1] == '\r')
		{
			--len;
			line[len] = 0;
		}

		switch (linecnt)
		{
		case 0:
			m_ref = eServiceReferenceDVB(line);
			break;
		case 1:
			m_name = line;
			break;
		case 2:
			m_description = line;
			break;
		case 3:
			m_time_create = atoi(line);
			if (m_time_create == 0)
			{
				m_time_create = getctime(tsname);
			}
			break;
		case 4:
			m_tags = line;
			break;
		case 5:
			m_length = atoi(line);  //movielength in pts
			break;
		case 6:
			m_filesize = atoll(line);
			break;
		case 7:
			m_service_data = line;
			break;
		case 8:
			m_packet_size = atoi(line);
			if (m_packet_size <= 0)
			{
				/* invalid value, use default */
				m_packet_size = 188;
			}
			break;
		case 9:
			m_scrambled = atoi(line);
			break;
		default:
			break;
		}
		++linecnt;
	}
	m_data_ok = 1;
	return 0;
}