예제 #1
0
파일: btc38.c 프로젝트: jl777/SuperNET_API
char *PARSEBALANCE(struct exchange_info *exchange,double *balancep,char *coinstr)
{
    char field[128],*str,*itemstr = 0;
    cJSON *obj;
    double lockbalance,imma;
    *balancep = 0.;
    strcpy(field,coinstr);
    tolowercase(field);
    strcat(field,"_balance");
    if ( exchange->balancejson != 0 && (str= jstr(exchange->balancejson,field)) != 0 )
    {
        *balancep = jdouble(exchange->balancejson,field);
        strcpy(field,coinstr), tolowercase(field), strcat(field,"_balance_lock");
        lockbalance = jdouble(exchange->balancejson,field);
        strcpy(field,coinstr), tolowercase(field), strcat(field,"_balance_imma");
        imma = jdouble(exchange->balancejson,field);
        obj = cJSON_CreateObject();
        jaddnum(obj,"balance",*balancep);
        jaddnum(obj,"locked_balance",lockbalance);
        jaddnum(obj,"imma_balance",imma);
        itemstr = jprint(obj,1);
    }
    if ( itemstr == 0 )
        return(clonestr("{\"error\":\"cant find coin balance\"}"));
    return(itemstr);
}
예제 #2
0
파일: quadriga.c 프로젝트: Miyurz/SuperNET
char *PARSEBALANCE(struct exchange_info *exchange,double *balancep,char *coinstr)
{
    //[{"btc_available":"0.00000000","btc_reserved":"0.00000000","btc_balance":"0.00000000","cad_available":"0.00","cad_reserved":"0.00","cad_balance":"0.00","usd_available":"0.00","usd_reserved":"0.00","usd_balance":"0.00","xau_available":"0.000000","xau_reserved":"0.000000","xau_balance":"0.000000","fee":"0.5000"}]
    char field[128],*str,*itemstr = 0; cJSON *obj; double reserv,total;
    *balancep = 0.;
    strcpy(field,coinstr);
    tolowercase(field);
    strcat(field,"_available");
    if ( exchange->balancejson != 0 && (str= jstr(exchange->balancejson,field)) != 0 )
    {
        *balancep = jdouble(exchange->balancejson,field);
        strcpy(field,coinstr), tolowercase(field), strcat(field,"_reserved");
        reserv = jdouble(exchange->balancejson,field);
        strcpy(field,coinstr), tolowercase(field), strcat(field,"_balance");
        total = jdouble(exchange->balancejson,field);
        obj = cJSON_CreateObject();
        jaddnum(obj,"balance",*balancep);
        jaddnum(obj,"locked_balance",reserv);
        jaddnum(obj,"total",total);
        itemstr = jprint(obj,1);
    }
    if ( itemstr == 0 )
        return(clonestr("{\"error\":\"cant find coin balance\"}"));
    return(itemstr);
}
예제 #3
0
파일: yahoo.c 프로젝트: ceda018/SuperNET
double UPDATE(struct exchange_info *exchange,char *base,char *rel,struct exchange_quote *quotes,int32_t maxdepth,double commission,cJSON *argjson,int32_t invert)
{
    char url[1024],lrel[16],lbase[16];
    strcpy(lrel,rel), strcpy(lbase,base);
    tolowercase(lrel), tolowercase(lbase);
    sprintf(url,"http://api.quadrigacx.com/v2/order_book?book=%s_%s",lbase,lrel);
    return(exchanges777_standardprices(exchange,commission,base,rel,url,quotes,0,0,maxdepth,0,invert));
}
예제 #4
0
 std::vector<std::string> ParserLibrary::removeElementsFromStringVector(std::vector<std::string> origin, std::vector<std::string> list) {
     for (size_t i = 0; i < list.size(); i++) {
         for (size_t j = 0; j < origin.size(); j++) {
             if (tolowercase(origin.at(j)) == tolowercase(list.at(i))) {
                 origin.erase(origin.begin() + j);
             }
         }
     }
     return origin;
 }
예제 #5
0
/*!
 * Case-insensitive string comparison between the strings
 * referenced by the pointers s1 and s2.
 *
 * @param s input string
 * @return positive integer if, disregarding case, string s1 is
 * lexically greater than string s2; zero if, other than case the two strings
 * are identical; and a negative integer if, disregarding case, string s1 is
 * lexically less than string s2.
 */
int strcasecmp(char *s1, char *s2) {
	char* t1;
	char* t2;
	t1 = s1;
	t2 = s2;
	/* characters are compared until 1st string ends or characters do not match */
	while(*t1 != '\0' && tolowercase(*(unsigned char *) t1) == tolowercase(*(unsigned char *) t2)) {
      		t1++;
      		t2++;
    	}
    	/* convert characters into ASCII codes and compare them */
        return tolowercase(*(unsigned char *) t1) - tolowercase(*(unsigned char *) t2);
}
예제 #6
0
double UPDATE(struct exchange_info *exchange,char *base,char *rel,struct exchange_quote *quotes,int32_t maxdepth,double commission,cJSON *argjson,int32_t invert)
{
    char url[1024],lrel[16],lbase[16];
    strcpy(lrel,rel), strcpy(lbase,base);
    tolowercase(lrel), tolowercase(lbase);
    sprintf(url,"https://www.okcoin.com/api/v1/depth.do?symbol=%s_%s",lbase,lrel);
    if ( strcmp(rel,"USD") != 0 && strcmp(rel,"BTC") != 0 )
    {
        fprintf(stderr,">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> FATAL ERROR OKCOIN.(%s) only supports USD\n",url);
        printf(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> FATAL ERROR OKCOIN.(%s) only supports USD\n",url);
        //exit(-1);
        return(0);
    }
    return(exchanges777_standardprices(exchange,commission,base,rel,url,quotes,0,0,maxdepth,0,invert));
}
bool CUnitDefLoader::HasUnit(string name){
	//
	string n = name;
	trim(n);
	tolowercase(n);
	return (defs.find(n) != defs.end());
}
예제 #8
0
파일: huobi.c 프로젝트: Miyurz/SuperNET
double UPDATE(struct exchange_info *exchange,char *base,char *rel,struct exchange_quote *quotes,int32_t maxdepth,double commission,cJSON *argjson,int32_t invert)
{
    char url[1024],lbase[16];
    strcpy(lbase,base), tolowercase(lbase);
    sprintf(url,"http://api.huobi.com/staticmarket/depth_%s_json.js ",lbase);
    return(exchanges777_standardprices(exchange,commission,base,rel,url,quotes,0,0,maxdepth,0,invert));
}
예제 #9
0
int8_t parseHexDigit(uint8_t digit)
{
    digit = tolowercase(digit);
    if (isdigit(digit))
        return (int8_t)digit - '0';
    if ((digit >= 'a') && (digit <= 'f'))
        return (int8_t)digit + 0xA - 'a';
    return -1;      // Error case - input wasn't a valid hex digit
}
const UnitDef* CUnitDefLoader::GetUnitDef(string name){
	string n = name;
	trim(n);
	tolowercase(n);
	if(defs.find(n) != defs.end()){
		const UnitDef* u = GetUnitDefByIndex(defs[n]);
		return u;
	}
	return 0;
}
int CUnitDefLoader::GetIdByName(string name){
	//
	string n = name;
	trim(n);
	tolowercase(n);
	if(defs.find(n) != defs.end()){
		return defs[n];
	}else{
		return -1;
	}
}
예제 #12
0
char *PARSEBALANCE(struct exchange_info *exchange,double *balancep,char *coinstr)
{
    //[[{"type":"deposit","currency":"btc","amount":"0.0","available":"0.0"},{"type":"deposit","currency":"usd","amount":"0.0","available":"0.0"},{"type":"exchange","currency":"btc","amount":"0.01065851","available":"0.01065851"},{"type":"exchange","currency":"usd","amount":"23386.37278962","available":"0.00378962"},{"type":"trading","currency":"btc","amount":"0.0","available":"0.0"},{"type":"trading","currency":"usd","amount":"0.0","available":"0.0"}]]
    int32_t i,n,ind; char field[64],*str,*typestr,*itemstr = 0; cJSON *item,*obj,*array; double amounts[3],avail[3],val0,val1;
    *balancep = 0.;
    strcpy(field,coinstr), tolowercase(field);
    memset(amounts,0,sizeof(amounts));
    memset(avail,0,sizeof(avail));
    if ( exchange->balancejson != 0 && is_cJSON_Array(exchange->balancejson) != 0 && (n= cJSON_GetArraySize(exchange->balancejson)) > 0 )
    {
        for (i=0; i<n; i++)
        {
            if ( (item= jitem(exchange->balancejson,i)) != 0 )
            {
                if ( (str= jstr(item,"currency")) != 0 && strcmp(field,str) == 0 )
                {
                    val0 = jdouble(item,"amount");
                    val1 = jdouble(item,"available");
                    if ( (typestr= jstr(item,"type")) != 0 )
                    {
                        if ( strcmp(typestr,"deposit") == 0 )
                            ind = 0;
                        else if ( strcmp(typestr,"exchange") == 0 )
                            ind = 1;
                        else if ( strcmp(typestr,"trading") == 0 )
                            ind = 2;
                        else ind = -1;
                        if ( ind >= 0 )
                        {
                            amounts[ind] = val0;
                            avail[ind] = val1;
                        }
                    }
                }
            }
        }
        if ( (obj= cJSON_CreateObject()) != 0 )
        {
            touppercase(field);
            *balancep = avail[0] + avail[1] + avail[2];
            jaddstr(obj,"base",field);
            jaddnum(obj,"balance",*balancep);
            jaddnum(obj,"total",amounts[0]+amounts[1]+amounts[2]);
            array = cJSON_CreateArray(), jaddinum(array,avail[0]), jaddinum(array,amounts[0]), jadd(obj,"deposit",array);
            array = cJSON_CreateArray(), jaddinum(array,avail[1]), jaddinum(array,amounts[1]), jadd(obj,"exchange",array);
            array = cJSON_CreateArray(), jaddinum(array,avail[2]), jaddinum(array,amounts[2]), jadd(obj,"trading",array);
            itemstr = jprint(obj,1);
        }
    }
    if ( itemstr == 0 )
        return(clonestr("{\"error\":\"cant find coin balance\"}"));
    return(itemstr);
}
int main(){

	char str[] = "hELlo";
	char *p = "hELlo";

	tolowercase(str);

	printf("%s\n", str);
	printf("%s\n", p);


	return 0;
}
void ServeurLabyrinthe::Start()
{
	std::string message;
	while (true)
	{
		while(est_invalide(m_socketClient))
		{
			accepter_client();
		}

		message = tolowercase(recevoir());

		switch (message[0])
		{
			case DROITE: 
            m_Carte.tryMoveRight();
				break;
			case GAUCHE:
            m_Carte.tryMoveLeft();
				break;
			case HAUT:
            m_Carte.tryMoveUp();
            break;
         case BAS:
            m_Carte.tryMoveDown();
				break;
			default:
				break;
		}

      if (m_Carte.is_PartieFinie())
      {
         envoyer("*");
      }
      else
      {
         // Envoyer nouveau vecteur.
         std::vector<std::vector<char>> vector = m_Carte.getVec();

         for (int y = 0; y < m_Carte.height(); ++y)
         {
            std::string s(vector[y].begin(), vector[y].end());

            envoyer(s);
         }

         envoyer("@");
      }
	}
}
예제 #15
0
파일: test_heap.c 프로젝트: MintPaw/College
int main(int argc, char *argv[])
{
	char buf[LEN];
	char *t = NULL;

	char **list = NULL;
	int word = 1;
	int i;
	FILE *fp;

	fp = fopen(argv[1], "r");
	assert(fp);

	/* this leaks  you need to fix*/
	while(fgets(buf, LEN, fp)) {
		/* remove new line */
		rstrip(buf); 
		tolowercase(buf);
		t = malloc((strlen(buf) + 1) * sizeof(char));
		assert(t);
		strncpy(t, buf, strlen(buf) + 1);
		/* printf("%s\n", t);  */
		list = realloc(list, word * sizeof(char *)); 
		list[word - 1] = t; 
		word++;
	}
	/* overcounted */
	word--;

	/* print the list */
	for(i = 0; i < word; i++) 
		printf("%s\n", list[i]);

	printf("\n");

	heapsort(list, word, sizeof(list[0]), genericStrcmp);

	/* print the sorted list */
	for(i = 0; i < word; i++) {
		printf("%s\n", list[i]);
		free(list[i]);
	}
	
	free(list);
	fclose(fp);

	return 0; 
}
예제 #16
0
char *PARSEBALANCE(struct exchange_info *exchange,double *balancep,char *coinstr)
{
    char field[128],*itemstr = 0; cJSON *obj,*item;
    *balancep = 0.;
    strcpy(field,coinstr);
    tolowercase(field);
    if ( exchange->balancejson != 0 && (obj= jobj(exchange->balancejson,"return")) != 0 && (item= jobj(obj,"funds")) != 0 )
    {
        *balancep = jdouble(item,field);
        obj = cJSON_CreateObject();
        touppercase(field);
        jaddstr(obj,"base",field);
        jaddnum(obj,"balance",*balancep);
        itemstr = jprint(obj,1);
    }
    if ( itemstr == 0 )
        return(clonestr("{\"error\":\"cant find coin balance\"}"));
    return(itemstr);
}
예제 #17
0
파일: LP_NXT.c 프로젝트: tpoonach/SuperNET
void LP_sendtoaddress_line(char *validaddress,char *assetname,uint64_t satoshis,uint64_t txnum)
{
    char line[1024],lowerstr[64];
    if ( strcmp(assetname,"SUPERNETx2") == 0 )
    {
        sprintf(line,"fiat/supernet sendtoaddress %s %.8f # txnum.%llu",validaddress,dstr(satoshis),(long long)txnum);
        printf("%s\n",line);
        sprintf(line,"fiat/revs sendtoaddress %s %.8f # txnum.%llu",validaddress,dstr(satoshis),(long long)txnum);
    }
    else
    {
        if ( strcmp(assetname,"TOKEN") == 0 )
            strcpy(lowerstr,"supernet");
        else strcpy(lowerstr,assetname);
        tolowercase(lowerstr);
        sprintf(line,"sleep 1; fiat/%s sendtoaddress %s %.8f # txnum.%llu",lowerstr,validaddress,dstr(satoshis),(long long)txnum);
    }
    printf("%s\n",line);
}
예제 #18
0
파일: sdb.c 프로젝트: bjfbm/SDB
static struct sdb* sdb_alloc(char* path){
    int len=strlen(path);
	char* path_name=malloc(len+5);
	if(path_name==NULL) return NULL;
	strcpy(path_name,path);
	tolowercase(path_name);
	strcpy(path_name+len,".log");
	int fd=open(path_name,O_RDONLY);
	if(fd>0) {
        fprintf(stderr,"detect log file exist.you should repair it.\n");
        free(path_name);
        exit(1);
    }
	struct sdb* db=calloc(1,sizeof(sdb));
	if(db==NULL) return NULL;
	db->auto_commit=1;
	db->path=path_name;
	return db;
}
예제 #19
0
파일: okcoin.c 프로젝트: Miyurz/SuperNET
char *PARSEBALANCE(struct exchange_info *exchange,double *balancep,char *coinstr)
{
    //okcoin.({"info":{"funds":{"asset":{"net":"0","total":"0"},"free":{"btc":"0","ltc":"0","usd":"0"},"freezed":{"btc":"0","ltc":"0","usd":"0"}}},"result":true})
    char field[128],*itemstr = 0; cJSON *obj,*item,*avail,*locked; double lockval = 0;
    *balancep = 0.;
    strcpy(field,coinstr);
    tolowercase(field);
    if ( exchange->balancejson != 0 && (obj= jobj(exchange->balancejson,"info")) != 0 && (item= jobj(obj,"funds")) != 0 )
    {
        if ( (avail= jobj(item,"free")) != 0 )
            *balancep = jdouble(avail,field);
        if ( (locked= jobj(item,"freezed")) != 0 )
            lockval = jdouble(locked,field);
        obj = cJSON_CreateObject();
        touppercase(field);
        jaddstr(obj,"base",field);
        jaddnum(obj,"balance",*balancep);
        jaddnum(obj,"locked",lockval);
        itemstr = jprint(obj,1);
    }
    if ( itemstr == 0 )
        return(clonestr("{\"error\":\"cant find coin balance\"}"));
    return(itemstr);
}
CUnitDefLoader::CUnitDefLoader(Global* GL){

	// Initialize pointer to the Global class
	G = GL;
	
	// retrieve the number of unit definitions
	unum = G->cb->GetNumUnitDefs();

	// for debugging purposes:
	//G->L.iprint("AI interface says this mod has this many units! :: "+to_string(unum));
	
	// Check if a horrific error has occured
	if(unum < 1){
		// omgwtf this should never happen!
		G->L.eprint("URGENT! GetNumUnitDefs returned ZERO!! This means that there are no unit definitions of any kind!!! Unrecoverable error!");

		// A horrible event has occurred somewhere in the spring engine for this to have happened.
		// Even if the AI could recover from this, the engine could not.
		// Exit this method immediatly. A crash is likely but if the crash was fixed, the engine
		// or another AI, would crash afterwards anyway.
		return;

		
	}

	// initialize arrays

	// The unitdeflist array will be passed to the engine where it will be filled with pointers
	UnitDefList = new const UnitDef*[unum];

	// retrieve the list of unit definition pointers from the engine
	G->cb->GetUnitDefList(UnitDefList);

	// for each definition
	for(int n=0; n < unum; n++){

		// retrieve the units definition
		const UnitDef* pud = UnitDefList[n];

		// initialize a UnitTypeData object
		CUnitTypeData* cutd = new CUnitTypeData();
		
		// now initialize the newly added object with the unit definition
		cutd->Init(G,pud);

		
		

		// add it into the main array
		type_data[pud->id] = cutd;


		// check if the unit definition is zero, if so skip
		//if(pud == 0) continue;

		// make sure the name is in the correct format and add it to the map container
		string na = pud->name;
		trim(na);
		tolowercase(na);
		defs[na] = pud->id;
	}
}
예제 #21
0
	bool CUnit::LoadBehaviours(){
		string d = G->Get_mod_tdf()->SGetValueDef("auto","AI\\behaviours\\"+utd->GetName());

		vector<string> v;
		CTokenizer<CIsComma>::Tokenize(v, d, CIsComma());

		if(!v.empty()){
			for(vector<string>::iterator vi = v.begin(); vi != v.end(); ++vi){

				string s = *vi;

				trim(s);
				tolowercase(s);

				if(s == "none"){
					return true;
				} else if(s == "metalmaker"){
					CMetalMakerBehaviour* m = new CMetalMakerBehaviour(G, GetID());
					boost::shared_ptr<IBehaviour> t(m);
					
					behaviours.push_back(t);
					t->Init();

					G->RegisterMessageHandler(t);
				} else if(s == "attacker"){
					CAttackBehaviour* a = new CAttackBehaviour(G, GetID());
					boost::shared_ptr<IBehaviour> t(a);
					
					behaviours.push_back(t);
					t->Init();

					G->RegisterMessageHandler(t);
				} else if(s == "dgun"){
					CDGunBehaviour* a = new CDGunBehaviour(G, GetID());
					boost::shared_ptr<IBehaviour> t(a);
					
					behaviours.push_back(t);
					t->Init();

					G->RegisterMessageHandler(t);
				} else if(s == "retreat"){
					CRetreatBehaviour* a = new CRetreatBehaviour(G, GetID());
					boost::shared_ptr<IBehaviour> t(a);
					
					behaviours.push_back(t);
					t->Init();

					G->RegisterMessageHandler(t);
				} else if(s == "kamikaze"){
					CKamikazeBehaviour* a = new CKamikazeBehaviour(G, GetID());
					boost::shared_ptr<IBehaviour> t(a);
					
					behaviours.push_back(t);
					t->Init();

					G->RegisterMessageHandler(t);
				} else if(s == "staticdefence"){
					CStaticDefenceBehaviour* a = new CStaticDefenceBehaviour(G, GetID());
					boost::shared_ptr<IBehaviour> t(a);
					
					behaviours.push_back(t);
					t->Init();

					G->RegisterMessageHandler(t);
				} else if(s == "movefailreclaim"){
					CMoveFailReclaimBehaviour* a = new CMoveFailReclaimBehaviour(G, GetID());
					boost::shared_ptr<IBehaviour> t(a);
					
					behaviours.push_back(t);
					t->Init();

					G->RegisterMessageHandler(t);
				} else if(s == "auto"){
					// we have to decide what this units behaviours should be automatically
					// check each type of unit for pre-requisites and then assign the behaviour
					// accordingly.

					if(utd->IsAttacker()){
						CAttackBehaviour* a = new CAttackBehaviour(G, GetID());
						boost::shared_ptr<IBehaviour> t(a);

						behaviours.push_back(t);
						t->Init();

						G->RegisterMessageHandler(t);
					}

					if(utd->IsMetalMaker()||(utd->IsMex() && utd->GetUnitDef()->onoffable ) ){
						CMetalMakerBehaviour* m = new CMetalMakerBehaviour(G, GetID());
						boost::shared_ptr<IBehaviour> t(m);

						behaviours.push_back(t);
						t->Init();

						G->RegisterMessageHandler(t);
						
					}
					
					if(utd->CanDGun()){
						CDGunBehaviour* a = new CDGunBehaviour(G, GetID());
						boost::shared_ptr<IBehaviour> t(a);
						
						behaviours.push_back(t);
						t->Init();

						G->RegisterMessageHandler(t);
					}

					

					if(utd->GetUnitDef()->canmove || utd->GetUnitDef()->canfly){
						CRetreatBehaviour* a = new CRetreatBehaviour(G, GetID());
						boost::shared_ptr<IBehaviour> t(a);
						
						behaviours.push_back(t);
						t->Init();

						G->RegisterMessageHandler(t);

						if(utd->GetUnitDef()->canReclaim){
							CMoveFailReclaimBehaviour* a = new CMoveFailReclaimBehaviour(G, GetID());
							boost::shared_ptr<IBehaviour> t(a);
							
							behaviours.push_back(t);
							t->Init();

							G->RegisterMessageHandler(t);
						}

					}else{
						/* this unit can't move, if it can fire a weapon though give it
						   the static defence behaviour*/

						if(utd->GetUnitDef()->weapons.empty()==false){
							CStaticDefenceBehaviour* a = new CStaticDefenceBehaviour(G, GetID());
							boost::shared_ptr<IBehaviour> t(a);
							
							behaviours.push_back(t);
							t->Init();

							G->RegisterMessageHandler(t);
						}
					}

					/*At the moment I can't think of a viable way of testing for the kamakaze
					  behaviour. It's usually a specialized behaviour though so a modder is
					  likely to mark it out in toolkit as a kamikaze unit
					*/

				}
			}
		}
		return true;
	}
int main(int argc, char **argv) {
  struct timeval start, end;

  if (argc != 5) {
    printf("Wrong arguments.\nUsage: program textfile.txt get_word insert_word delete_word\n");
    return 0;
  }

  char * filename = argv[1];
 
  FILE * input = fopen(filename, "r");

  char buffer [BUFFER_SIZE];

  node * tree = NULL;

  clock_t begin, endd;
  double time_spent;


  // insert all 
  begin = clock();
  gettimeofday(&start, NULL);

  while(fscanf(input, "%s", buffer) != EOF) {

    char * word = malloc((strlen(buffer) + 1) * sizeof(char));
    if (word == NULL) {
      printf("Memory Error.\n");
      return 1;
    }
  
    strcpy(word, buffer);
    tolowercase(word);
    tree = add_word(tree, word);
  }
  endd = clock();
  gettimeofday(&end, NULL);
  time_spent = ((double) (endd - begin)) / CLOCKS_PER_SEC;
  time_spent *= 1000000;
  printf("Tree created. Time taken: %f * 10^(-6) secs.\n", time_spent);
  time_print(start, end);

  // search
  gettimeofday(&start, NULL);
  int s = search(tree, argv[2]);
  gettimeofday(&end, NULL);
  printf("Search for: (%s, %d)\n", argv[2], s);
  time_print(start, end);

  // insert one
  gettimeofday(&start, NULL);
  tree = add_word(tree, argv[3]);
  gettimeofday(&end, NULL);
  printf("Insert: %s\n", argv[3]);
  time_print(start, end);

  // delete

  gettimeofday(&start, NULL);
  tree = delete(tree, argv[4]);
  gettimeofday(&end, NULL);
  printf("Delete word: %s\n", argv[4]);
  time_print(start, end);

  // max
  begin = clock();
  gettimeofday(&start, NULL);
  node * max = find_max_value(tree);
  gettimeofday(&end, NULL);
  endd = clock();
  time_spent = ((double) (endd - begin)) / CLOCKS_PER_SEC;
  time_spent *= 1000000;
  printf("Max: (%s, %d). Time taken: %f * 10^(-6) secs\n", 
         max->key, max->value, time_spent);
  time_print(start, end);

  //print_tree(tree);

  return 0;
}
	bool CConfigTaskManager::LoadTaskList(){
		NLOG("CConfigTaskManager::LoadTaskList");

		CUnit* u = G->unit_array[unit];

		CUnitTypeData* utd = u->GetUnitDataType();

		vector<string> vl;
		string sl;
		if(G->Cached->cheating){
			sl= G->Get_mod_tdf()->SGetValueMSG(string("TASKLISTS\\CHEAT\\")+utd->GetName());
		}else{
			sl = G->Get_mod_tdf()->SGetValueMSG(string("TASKLISTS\\NORMAL\\")+utd->GetName());
		}

		tolowercase(sl);
		trim(sl);
		string us = utd->GetName();
		if(sl != string("")){
			CTokenizer<CIsComma>::Tokenize(vl, sl, CIsComma());
			if(vl.empty() == false){
				int randnum = G->mrand()%vl.size();
				us = vl.at(min(randnum,max(int(vl.size()-1),1)));
			}
		}

		string s = G->Get_mod_tdf()->SGetValueMSG(string("TASKLISTS\\LISTS\\")+us);

		if(s.empty()){
			G->L.print(" error loading tasklist for unit :: \"" + us + "\" :: buffer empty, most likely because of an empty list");
			nolist=true;
			return false;
		}

		tolowercase(s);
		trim(s);

		vector<string> v;

		CTokenizer<CIsComma>::Tokenize(v, s, CIsComma());

		if(v.empty() == false){
			G->L.print("loading contents of  tasklist :: " + us + " :: filling tasklist with #" + to_string(v.size()) + " items");
			bool polate=false;
			bool polation = G->info->rule_extreme_interpolate;
			btype bt = G->Manufacturer->GetTaskType(G->Get_mod_tdf()->SGetValueDef("b_na","AI\\interpolate_tag"));

			if(utd->IsFactory()){
				polation = false;
			}

			if(bt == B_NA){
				polation = false;
			}


			// TASKS LOADING
			
			for(std::vector<string>::iterator vi = v.begin(); vi != v.end(); ++vi){
				if(polation){
					if(polate){
						boost::shared_ptr<IModule> t(new CKeywordConstructionTask(G,u->GetID(),bt));
						tasks.push_back(t);
					}
					polate = !polate;
				}
				std::string q = *vi;

				trim(q);
				tolowercase(q);

				CUnitTypeData* b = G->UnitDefLoader->GetUnitTypeDataByName(q);
				if(b != 0){
					boost::shared_ptr<IModule> t(new CUnitConstructionTask(G,u->GetID(),utd,b));
					tasks.push_back(t);
				}else if(q == string("")){
					continue;
				}else if(q == string("b_na")){
					continue;
				} else if(q == string("no_rule_interpolation")){
					polation=false;
				} else if(q == string("rule_interpolate")){
					polation=true;
				}else if(q == string("base_pos")){
					G->Map->base_positions.push_back(G->GetUnitPos(u->GetID()));
				} else if(q == string("gaia")){
					G->info->gaia = true;
				} else if(q == string("not_gaia")){
					G->info->gaia = false;
				} else if(q == string("switch_gaia")){
					G->info->gaia = !G->info->gaia;
				} else if(q == string("b_factory")){
					boost::shared_ptr<IModule> t(new CKeywordConstructionTask(G,u->GetID(),B_FACTORY));
					tasks.push_back(t);
				} else if(q == string("b_power")){
					boost::shared_ptr<IModule> t(new CKeywordConstructionTask(G,u->GetID(),B_POWER));
					tasks.push_back(t);
				} else if(q == string("b_defence")){
					boost::shared_ptr<IModule> t(new CKeywordConstructionTask(G,u->GetID(),B_DEFENCE));
					tasks.push_back(t);
				}  else if(q == string("b_mex")){
					boost::shared_ptr<IModule> t(new CKeywordConstructionTask(G,u->GetID(),B_MEX));
					tasks.push_back(t);
				} else{
					btype x = G->Manufacturer->GetTaskType(q);
					if( x != B_NA){
						boost::shared_ptr<IModule> t(new CKeywordConstructionTask(G,u->GetID(),x));
						tasks.push_back(t);
					}else{
						G->L.print("error :: a value :: " + *vi +" :: was parsed in :: "+us + " :: this does not have a valid UnitDef according to the engine, and is not a Task keyword such as repair or b_mex");
					}
				}

			}
			if(utd->GetUnitDef()->isCommander){
				G->Map->basepos = G->GetUnitPos(u->GetID());
			}

			G->L.print("loaded contents of  tasklist :: " + us + " :: loaded tasklist at " + to_string(tasks.size()) + " items");
			return !tasks.empty();
		} else{
			G->L.print(" error loading contents of  tasklist :: " + us + " :: buffer empty, most likely because of an empty tasklist");
			return false;
		}
	}