Ejemplo n.º 1
0
/*{{{  update -- update an obscured window*/
void update(WINDOW *win, rect *clipp)
{
  /* generate clip list */

  if (!(W(flags) & W_CLIPDONE)) {
    if (W(clip_list) != NULL) /* free old list (we could reuse it) */
      zap_cliplist(win);
    gen_list(win);
    W(flags) |= W_CLIPDONE;
  }

  /* update the window */

  do_update(win, clipp); /* do the update */
}
Ejemplo n.º 2
0
//read the mobility file and generates a hashtable of linked list with key pointing to vehicle id
hash_table_t* read_mobility_file(char mobility_file[]){
		FILE *fp;
	    char str[128];
	    hash_table_t *table = hash_table_new(MODE_ALLREF);
	    if((fp=fopen(mobility_file, "r"))==NULL) {
	      printf("Cannot open file. %s\n",mobility_file);
	      exit(1);
	    }
	    Exnode* headRef;
	    node_info* Node_info=NULL;

	    head_node_info=Node_info;
	    int *keyholder[10];
	    int i=0;
	    while(!feof(fp)) {
	      if(fgets(str, 126, fp)) { // happy go for small mobility file :-)
	    	  char * pch;
	      	  int fmt=0;

	      	  pch = strtok (str," "); // the separator between the items in the list is a space
	      	  Exnode* node = malloc(sizeof(Exnode));

	      	  while (pch != NULL)
	      	  {	  node->visit=0;
	      		  switch(fmt){
	      						  case 0:
	      							node->time=atof(pch);
	      							break;
	      						  case 1:
	      							node->vid =atoi(pch);
	      							break;
	      						  case 2:
	      							node->x=atof(pch);
	      							break;
	      						  case 3:
	      							node->y=atof(pch);
	      							break;
	      						  case 4:
	      							node->speed=atof(pch);
	      							break;
	      						  default:
	      							  //need a log statement here
	      							  break;
	      		  }
	      		fmt +=1;

	          pch = strtok (NULL, " ");

	      	  }
	      	  node->next=NULL;

	      	  //check in the hash table if the key exist node->vid if exist ? initialize headRef
	      	  int *value = NULL;
	      	  value = (int *)HT_LOOKUP(table, &node->vid);
	      	  if (value==NULL){
	      		if (Node_info==NULL){
	      			Node_info=build_node_info(Node_info,node->vid,&(node->vid));
	      			head_node_info=Node_info;
	      		}
	      		else{
	      			build_node_info(Node_info,node->vid,&(node->vid));
	      		}
	      		keyholder[i]=&node->vid;i++;
	      		//printf("Before to hash %p %d %lf\n",node,(node->vid),(node->time));
	      		hash_table_add(table, &(node->vid), sizeof(node->vid), node, sizeof(&node));
	      		//puts("NO node doesnt exist");
	      		headRef=gen_list();

	      	  }
	      	  else{
	      		 //puts("Yes node exist");
	      		 headRef = (Exnode *)value;
	      		 //printf("After from hash %p %d\n",headRef, headRef->vid );

	      	  }
	      	  if (headRef!=NULL){
	      		  	  AppendNode(headRef, node);
	      	  	  	 }

	      }
	    }

	    fclose(fp);
	    return table;
}