From 17fb1cc33bc5fcf39014bda3bb2e246172e6e71d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 30 Jan 2016 17:31:47 -0300 Subject: [PATCH] test --- crypto777/iguana_utils.c | 14 ++++++++++---- iguana/exchanges/poloniex.c | 15 ++++++++++++--- iguana/iguana_peers.c | 1 + 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/crypto777/iguana_utils.c b/crypto777/iguana_utils.c index 2cb2db3a4..f3a100cb2 100755 --- a/crypto777/iguana_utils.c +++ b/crypto777/iguana_utils.c @@ -542,15 +542,21 @@ void tolowercase(char *str) char *uppercase_str(char *buf,char *str) { - strcpy(buf,str); - touppercase(buf); + if ( str != 0 ) + { + strcpy(buf,str); + touppercase(buf); + } else buf[0] = 0; return(buf); } char *lowercase_str(char *buf,char *str) { - strcpy(buf,str); - tolowercase(buf); + if ( str != 0 ) + { + strcpy(buf,str); + tolowercase(buf); + } else buf[0] = 0; return(buf); } diff --git a/iguana/exchanges/poloniex.c b/iguana/exchanges/poloniex.c index 3b9a27ae1..4c358633b 100755 --- a/iguana/exchanges/poloniex.c +++ b/iguana/exchanges/poloniex.c @@ -34,26 +34,35 @@ static char *(*poloniex_baserels)[][2]; char *ALLPAIRS(struct exchange_info *exchange,cJSON *argjson) { static int32_t num; - char *jsonstr,*baserel; int32_t i; cJSON *json; + char *jsonstr,*baserel; int32_t i; cJSON *json,*item; + printf("ALLPAIRS num.%d %p\n",num,*poloniex_baserels); if ( num == 0 || (*poloniex_baserels) == 0 ) { jsonstr = issue_curl("https://poloniex.com/public?command=returnTicker"); + //jsonstr[0] = '['; + //jsonstr[strlen(jsonstr)-1] = ']'; + i = 0; if ( (json= cJSON_Parse(jsonstr)) != 0 ) { if ( (num= cJSON_GetArraySize(json)) != 0 ) { poloniex_baserels = calloc(num,sizeof(char *) * 2); - for (i=0; ichild; + while ( item != 0 ) { - if ( (baserel= get_cJSON_fieldname(jitem(json,i))) != 0 && strncmp(baserel,"BTC_",4) == 0 ) + if ( (baserel= item->string) != 0 && strncmp(baserel,"BTC_",4) == 0 && strlen(baserel) > 4 ) { (*poloniex_baserels)[i][0] = clonestr(baserel+4); (*poloniex_baserels)[i][1] = "BTC"; + i++; } + item = item->next; } } free_json(json); } + num = i; + printf("(%s) num.%d\n",jsonstr,num); free(jsonstr); } return(jprint(exchanges777_allpairs((*poloniex_baserels),num),1)); diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 86ef98535..fb3345aa9 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -314,6 +314,7 @@ int32_t iguana_socket(int32_t bindflag,char *hostname,uint16_t port) { if ( errno == EADDRINUSE ) { + sleep(5); printf("%s(%s) port.%d try again: %s sock.%d. errno.%d\n",bindflag!=0?"bind":"connect",hostname,port,strerror(errno),sock,errno); if ( bindflag == 1 ) {