예제 #1
0
// AVS
// ignore long comment [comment] ... [end comment]
// recursive!
int getLongComment(istream& is, char* wbuf, size_t sz) {
	
	int bufLen;
    while ( is ) {
		wbuf[0] = 0;
		getline(is, wbuf, sz);
		if ( wbuf[0]==0 ) return 1;
		bufLen = strlen(wbuf);
		if ( wbuf[0] == '[' && wbuf[bufLen-1] == ']' ) {
			string temps(wbuf);
			
			if (!normalizeSplitter(temps)) {
				//           cerr << "Unexpected line '" << temps << "'\n";
				printm(0, FALSE, MSG_KEYUNEXPLINE, temps.c_str());
				return 0;
			};
			if ( stricmp(temps.c_str(),"[comment]") == 0 ) {
				// do recursive call
				if ( !getLongComment(is, wbuf, sz) ) return 0;
				continue;
			};
			if ( stricmp(temps.c_str(),"[end comment]") == 0 ) return 1;
		};
    };
	// we get a warning if we don't put a return here (Paul Brannan 5/25/98)
	return 0;
};
예제 #2
0
int main()
{
i=0;
lcdini();

DDPCON=0x0000;
mPORTDSetPinsDigitalIn(BIT_7|BIT_13|BIT_6);                           //Set Portd pins DigitalIn
mPORTASetPinsDigitalOut(BIT_0|BIT_1|BIT_2|BIT_3|BIT_4|BIT_5|BIT_6);
mPORTAClearBits(BIT_0|BIT_1|BIT_2|BIT_3|BIT_4|BIT_5|BIT_6);
mPORTASetPinsDigitalIn(BIT_7);
char x;

while(1)
{
    switch(i)                                                                              //Switch case to select function
	{
		case 0:
        mode();
		break;
		case 1:
        batteryv();
		break;
		case 2:
		temps();
        break;
	}
    
    if(i==3)
    {
     lcdcmd(0x01);
     break;
    }
}
}	
예제 #3
0
파일: xml.cpp 프로젝트: maidmaid/maiday
//-----------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------
QByteArray Xml::ecrireReponseSynchronisationHorloge()
{
    texte.clear();

    xml->writeTextElement("reponseSynchronisationHorloge", temps());

    return texte.toUtf8();
}
예제 #4
0
void DOS_Shell::CMD_CHDIR(char * args) {
	HELP("CHDIR");
	StripSpaces(args);
	char sargs[CROSS_LEN];
	if (*args && !DOS_GetSFNPath(args,sargs,false)) {
		WriteOut(MSG_Get("SHELL_ILLEGAL_PATH"));
		return;
	}
	Bit8u drive = DOS_GetDefaultDrive()+'A';
	char dir[DOS_PATHLENGTH];
	if (!*args) {
		DOS_GetCurrentDir(0,dir,true);
		WriteOut("%c:\\%s\n",drive,dir);
	} else if(strlen(args) == 2 && args[1]==':') {
		Bit8u targetdrive = (args[0] | 0x20)-'a' + 1;
		unsigned char targetdisplay = *reinterpret_cast<unsigned char*>(&args[0]);
		if(!DOS_GetCurrentDir(targetdrive,dir,true)) {
			if(drive == 'Z') {
				WriteOut(MSG_Get("SHELL_EXECUTE_DRIVE_NOT_FOUND"),toupper(targetdisplay));
			} else {
				WriteOut(MSG_Get("SHELL_ILLEGAL_PATH"));
			}
			return;
		}
		WriteOut("%c:\\%s\n",toupper(targetdisplay),dir);
		if(drive == 'Z')
			WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT"),toupper(targetdisplay));
	} else 	if (!DOS_ChangeDir(sargs)) {
		/* Changedir failed. Check if the filename is longer then 8 and/or contains spaces */
	   
		std::string temps(args),slashpart;
		std::string::size_type separator = temps.find_first_of("\\/");
		if(!separator) {
			slashpart = temps.substr(0,1);
			temps.erase(0,1);
		}
		separator = temps.find_first_of("\\/");
		if(separator != std::string::npos) temps.erase(separator);
		separator = temps.find_first_of("\"");
		if(separator != std::string::npos) temps.erase(separator);
		separator = temps.rfind('.');
		if(separator != std::string::npos) temps.erase(separator);
		separator = temps.find(' ');
		if(separator != std::string::npos) {/* Contains spaces */
			temps.erase(separator);
			if(temps.size() >6) temps.erase(6);
			temps += "~1";
			WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT_2"),temps.insert(0,slashpart).c_str());
		} else {
			if (drive == 'Z') {
				WriteOut(MSG_Get("SHELL_CMD_CHDIR_HINT_3"));
			} else {
				WriteOut(MSG_Get("SHELL_CMD_CHDIR_ERROR"),args);
			}
		}
	}
}
예제 #5
0
파일: xml.cpp 프로젝트: maidmaid/maiday
//-----------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------
QByteArray Xml::ecrireCollision(int idTireur, int scoreTireur, int idExplose, int vieExplose, int idMissile)
{
    texte.clear();

    xml->writeStartElement("collision");
    xml->writeTextElement("idTireur", QString::number(idTireur));
    xml->writeTextElement("temps", temps());
    xml->writeTextElement("scoreTireur", QString::number(scoreTireur));
    xml->writeTextElement("idExplose", QString::number(idExplose));
    xml->writeTextElement("vieExplose", QString::number(vieExplose));
    xml->writeTextElement("idMissile", QString::number(idMissile));
    xml->writeEndElement(); // </collision>

    return texte.toUtf8();
}
예제 #6
0
파일: xml.cpp 프로젝트: maidmaid/maiday
//-----------------------------------------------------------------------------------------------------------------------------
QByteArray Xml::ecrireTir(int idJoueur, int id, QPointF position, double angle, int type)
{
    texte.clear();

    xml->writeStartElement("tir");
    xml->writeTextElement("idJoueur", QString::number(idJoueur));
    xml->writeTextElement("temps", temps());
    xml->writeTextElement("id", QString::number(id));
    xml->writeTextElement("x", QString::number(position.x()));
    xml->writeTextElement("y", QString::number(position.y()));
    xml->writeTextElement("angle", QString::number(angle));
    xml->writeTextElement("type", QString::number(type));
    xml->writeEndElement(); // </tir>

    return texte.toUtf8();
}
예제 #7
0
파일: xml.cpp 프로젝트: maidmaid/maiday
//-----------------------------------------------------------------------------------------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------
QByteArray Xml::ecrireAction(int id, int action, QPointF pos, double angle, double vitesse)
{
    texte.clear();

    xml->writeStartElement("action");
    xml->writeTextElement("id", QString::number(id));
    xml->writeTextElement("temps", temps());
    xml->writeTextElement("actionAvion", QString::number(action));
    xml->writeTextElement("x", QString::number(pos.x()));
    xml->writeTextElement("y", QString::number(pos.y()));
    xml->writeTextElement("angle", QString::number(angle));
    xml->writeTextElement("vitesse", QString::number(vitesse));
    xml->writeEndElement(); // </action>

    return texte.toUtf8();
}
예제 #8
0
// AVS
// completelly rewrited to support new conceptions
int TMapLoader::Load(const char * filename, const char * szActiveEmul) {
	char buf[256];
	int bufLen;
	
	ifstream inpfile(filename);
	KeyTrans.DeleteAllDefs();
	Charmap.init();
	
	// it is an array for store [...] ... [end ...] parts from file
	stringArray SA(0,0,sizeof(string));
	int AllOk = 0;
	
	while ( inpfile ) {
		
		getline(inpfile, buf, 255);
		bufLen = strlen(buf);
		if ( !bufLen ) continue;
		
		if ( buf[0] == '[' && buf[bufLen-1] == ']' ) {
			// is a part splitter [...]
			string temps(buf);
			
			if (!normalizeSplitter(temps)) {
				printm(0, FALSE, MSG_KEYUNEXPLINE, temps.c_str());
				AllOk = 0;
				break;
			};
			// if a comment
			if ( stricmp(temps.c_str(),"[comment]") == 0 ) {
#ifdef KEYDEBUG
				printit(temps.c_str());
#endif
				if ( !getLongComment(inpfile, buf, sizeof(buf)) ) {
					printm(0, FALSE, MSG_KEYUNEXPEOF);
					break;
				};
#ifdef KEYDEBUG
				printit("\r          \r");
#endif
				continue;
			};
			
			
			string back = temps;
			// prepare line for make it as [end ...]
			// and check it
			if ( strnicmp(back.c_str(), "[global]", 8) == 0 ) {} // do nothing
			else if ( strnicmp(back.c_str(), "[keymap", 7) == 0 ) {
				// DJGPP also uses erase rather than remove (Paul Brannan 6/23/98)
#ifndef __BORLANDC__
				back.erase(7);
#else
				back.remove(7);
#endif
				back += "]";
			}
			else if ( strnicmp(back.c_str(), "[charmap", 8) == 0 ) {
				// Paul Brannan 6/23/98
#ifndef __BORLANDC__
				back.erase(8);
#else
				back.remove(8);
#endif
				back += "]";
			}
			else if ( strnicmp(back.c_str(), "[config", 7) == 0 ) {
				// Paul Brannan 6/23/98
#ifndef __BORLANDC__
				back.erase(7);
#else
				back.remove(7);
#endif
				back += "]";
			}
			else {
				//        cerr << "Unexpected token " << back << endl;
				printm(0, FALSE, MSG_KEYUNEXPTOK, back.c_str());
				break;
			};
			
			back.insert(1,"END "); // now it looks like [END ...]
#ifdef KEYDEBUG
			printit(temps.c_str());
#endif
			
			int ok = 0;
			// fetch it to temps
			while ( 1 ) {
				getline(inpfile, buf, sizeof(buf));
				bufLen = strlen(buf);
				if ( !bufLen ) break;
				if ( buf[0] == '[' && buf[bufLen-1] == ']' ) {
					string t(buf);
					if ( !normalizeSplitter(t) ) break;
					
					if ( stricmp(t.c_str(),back.c_str()) == 0 ) {
						ok = 1;
						break;
					};
					
					// AVS 31.12.97 fix [comment] block inside another block
					if ( stricmp(t.c_str(),"[comment]") == 0 &&
						getLongComment(inpfile, buf, sizeof(buf)) ) continue;
					
					break;
				};
				temps += "\n";
				temps += buf;
			};
			if ( !ok ) {
				//         cerr << "Unexpected end of file or token" << endl;
				printm(0, FALSE, MSG_KEYUNEXP);
				AllOk = 0;
				break;
			};
#ifdef KEYDEBUG
			printit("\r                                                                      \r");
#endif
			AllOk = SA.Add(temps);;
			if ( !AllOk ) break;
		} else {
			//       cerr << "Unexpected line '" << buf << "'\n";
			printm(0, FALSE, MSG_KEYUNEXPLINE, buf);
			AllOk = 0;
			break;
		};
	};
	
	inpfile.close();
	
	if ( !AllOk ) return 0;
	
	// now all file are in SA, comments are stripped
	
	int i = LookForPart(SA, "global", "");
	if ( i == INT_MAX ) {
		//     cerr << "No [GLOBAL] definition!" << endl;
		printm(0, FALSE, MSG_KEYNOGLOBAL);
		return 0;
	};
	if ( !LoadGlobal(SA[i]) ) {
		return 0;
	};
	
	// look for need configuration
	i = LookForPart(SA, "config", szActiveEmul);
	if ( i == INT_MAX ) {
		//     cerr << "No [CONFIG " << szActiveEmul << "]\n";
		printm(0, FALSE, MSG_KEYNOCONFIG, szActiveEmul);
		return 0;
	};
	//  cerr << "use configuration: " << szActiveEmul << endl;
	printm(0, FALSE, MSG_KEYUSECONFIG, szActiveEmul);
	BOOL hadKeys = FALSE;
	
	string config = SA[i];
	// parse it
	while ( config.length() ) {
		buf[0] = 0;
		getline(config,buf,sizeof(buf));
		bufLen = strlen(buf);
		if ( !bufLen || (buf[0] == '[' && buf[bufLen-1] == ']') ) continue;
		if ( strnicmp(buf,"keymap",6) == 0 ) {
			string orig(buf);
			printit("\t"); printit(buf); printit("\n");
			char * mapdef = strtok(buf,":");
			char * switchKey = strtok(NULL,"\n");
			
			if ( !KeyTrans.mapArray.IsEmpty() && switchKey == NULL ) {
				//            cerr << "no switch Key for '" << mapdef
				//                 << "'" << endl;
				printm(0, FALSE, MSG_KEYNOSWKEY, mapdef);
				break;
			};
			if ( KeyTrans.mapArray.IsEmpty() ) {
				if ( switchKey != NULL ) { // create default keymap
					//               cerr << "You cannot define switch key for default keymap -> ignored"
					//                    << endl;
					printm(0, FALSE, MSG_KEYCANNOTDEF);
				};
				TKeyDef empty;
				KeyTrans.mapArray.Add(KeyMap(string(mapdef)));
				KeyTrans.switchMap(empty); // set it as current keymap
				KeyTrans.mainKeyMap = KeyTrans.currentKeyMap;
			}
			else {
				string keydef(switchKey);
				keydef += " !*!*!*"; // just for check
				WORD vk_code;
				DWORD control;
				switchKey = ParseKeyDef(keydef.c_str(),vk_code,control);
				if ( switchKey != NULL ) {
					TKeyDef swi(NULL,control,vk_code);
					if ( KeyTrans.switchMap(swi) > 0 ) {
						//                  cerr << "Duplicate switching key\n";
						printm(0, FALSE, MSG_KEYDUPSWKEY);
						break;
					};
					KeyTrans.mapArray.Add(KeyMap(swi, orig));
					KeyTrans.switchMap(swi); // set it as current keymap
				}
			};
			mapdef+=7; // 'keymap '
			// now load defined keymaps to current
			while ((mapdef != NULL)&&
				(mapdef = strtok(mapdef,TOKEN_DELIMITERS)) != NULL ) {
				i = LookForPart(SA,"keymap",mapdef);
				if ( i == INT_MAX ) {
					//               cerr << "Unknown KEYMAP " << mapdef << endl;
					printm(0, FALSE, MSG_KEYUNKNOWNMAP, mapdef);
				} else {
					mapdef = strtok(NULL,"\n"); // strtok is used in LoadKeyMap
					// so - save pointer!
					hadKeys = LoadKeyMap(SA[i]); // load it
				};
			};
			
		}
		else if ( strnicmp(buf,"charmap",7) == 0 ) {
			printit("\t"); printit(buf); printit("\n");
			char * mapdef = buf + 8;// 'charmap '
			int SuccesLoaded = 0;
			// now load defined charmaps to current
			while ((mapdef != NULL)&&
				(mapdef = strtok(mapdef,TOKEN_DELIMITERS)) != NULL ) {
				i = LookForPart(SA,"charmap",mapdef);
				if ( i == INT_MAX ) {
					//               cerr << "Unknown KEYMAP " << mapdef << endl;
					printm(0, FALSE, MSG_KEYUNKNOWNMAP, mapdef);
				} else {
					mapdef = strtok(NULL,"\n"); // strtok is used in LoadKeyMap
					// so - save pointer!
					if (LoadCharMap(SA[i])) // load it
						SuccesLoaded++;
				};
			};
			if (!SuccesLoaded) {
				//            cerr << "No charmaps loaded\n";
				printm(0, FALSE, MSG_KEYNOCHARMAPS);
				Charmap.init();
			};
			/*         strtok(buf," ");
			
			  char* name = strtok(NULL," ");
			  if ( name == NULL ) {
			  cerr << "No name for CHARMAP" << endl;
			  } else {
			  i = LookForPart(SA,"charmap", name);
			  if ( i == INT_MAX ) {
			  cerr << "Unknown CHARMAP " << name << endl;
			  } else {
			  LoadCharMap(SA[i]);
			  };
			  };
			*/
		}
		else {
			//        cerr << "unexpected token in " << szActiveEmul << endl;
			printm(0, FALSE, MSG_KEYUNEXPTOKIN, szActiveEmul);
		}
	}

	if ( hadKeys) {
		TKeyDef empty;
		KeyTrans.switchMap(empty); // switch to default
		KeyTrans.mainKeyMap = KeyTrans.currentKeyMap; // save it's number
		//     cerr << "There are " << (KeyTrans.mapArray.GetItemsInContainer()) << " maps\n";
		char s[12]; // good enough for a long int (32-bit)
		itoa(KeyTrans.mapArray.GetItemsInContainer(), s, 10);
		printm(0, FALSE, MSG_KEYNUMMAPS, s);
		return 1;
	};
	return 0;
}
예제 #9
0
파일: mstring.cpp 프로젝트: doniexun/UnderC
string operator + (string s1, string s2)
{
   string temps(s1);
   temps += s2;
   return temps;
}
ompl::base::StateStoragePtr ompl_interface::ConstraintsLibrary::constructConstraintApproximation(const ModelBasedPlanningContextPtr &pcontext,
                                                                                                 const moveit_msgs::Constraints &constr_sampling,
                                                                                                 const moveit_msgs::Constraints &constr_hard,
                                                                                                 const ConstraintStateStorageOrderFn &order,
                                                                                                 unsigned int samples, unsigned int edges_per_sample,
                                                                                                 ConstraintApproximationConstructionResults &result)
{
  // state storage structure
  ConstraintApproximationStateStorage *cass = new ConstraintApproximationStateStorage(pcontext->getOMPLStateSpace());
  ob::StateStoragePtr sstor(cass);
  
  // construct a sampler for the sampling constraints
  kinematic_constraints::KinematicConstraintSet kset(pcontext->getRobotModel(), robot_state::TransformsConstPtr(new robot_state::Transforms(pcontext->getRobotModel()->getModelFrame())));
  kset.add(constr_hard);

  const robot_state::RobotState &default_state = pcontext->getCompleteInitialRobotState();
  
  int nthreads = 0;
  unsigned int attempts = 0;
  
  double bounds_val = std::numeric_limits<double>::max() / 2.0 - 1.0;
  pcontext->getOMPLStateSpace()->setPlanningVolume(-bounds_val, bounds_val, -bounds_val, bounds_val, -bounds_val, bounds_val);
  pcontext->getOMPLStateSpace()->setup();
  
  // construct the constrained states
#pragma omp parallel
  { 
#pragma omp master
    {
	nthreads = omp_get_num_threads();    
    }
    
    robot_state::RobotState kstate(default_state);
    const constraint_samplers::ConstraintSamplerManagerPtr &csmng = pcontext->getConstraintSamplerManager();
    ConstrainedSampler *csmp = NULL;
    if (csmng)
    {
      constraint_samplers::ConstraintSamplerPtr cs = csmng->selectSampler(pcontext->getPlanningScene(), pcontext->getJointModelGroup()->getName(), constr_sampling);
      if (cs)
        csmp = new ConstrainedSampler(pcontext.get(), cs);
    }
    
    ob::StateSamplerPtr ss(csmp ? ob::StateSamplerPtr(csmp) : pcontext->getOMPLStateSpace()->allocDefaultStateSampler());
    
    ompl::base::ScopedState<> temp(pcontext->getOMPLStateSpace());
    int done = -1;
    bool slow_warn = false;
    ompl::time::point start = ompl::time::now();
    while (sstor->size() < samples)
    {
      ++attempts;
#pragma omp master
      {      
	int done_now = 100 * sstor->size() / samples;
	if (done != done_now)
	{
	  done = done_now;
	  logInform("%d%% complete (kept %0.1lf%% sampled states)", done, 100.0 * (double)sstor->size() / (double)attempts);
	}

	if (!slow_warn && attempts > 10 && attempts > sstor->size() * 100)
	{
	  slow_warn = true;
	  logWarn("Computation of valid state database is very slow...");
	}
      }

      if (attempts > samples && sstor->size() == 0)
      {
	logError("Unable to generate any samples");
	break;
      }
      
      ss->sampleUniform(temp.get());
      pcontext->getOMPLStateSpace()->copyToRobotState(kstate, temp.get());
      if (kset.decide(kstate).satisfied)
      {
#pragma omp critical
	{
	  if (sstor->size() < samples)
	  {
	    temp->as<ModelBasedStateSpace::StateType>()->tag = sstor->size();
	    sstor->addState(temp.get());
	  }
	}
      }
    }
#pragma omp master
    {
      result.state_sampling_time = ompl::time::seconds(ompl::time::now() - start);
      logInform("Generated %u states in %lf seconds", (unsigned int)sstor->size(), result.state_sampling_time); 
      if (csmp)
      {
        result.sampling_success_rate = csmp->getConstrainedSamplingRate();
        logInform("Constrained sampling rate: %lf", result.sampling_success_rate);
      }
    }
  }
  if (order)
  {
    logInform("Sorting states...");
    sstor->sort(order);
  }
  
  if (edges_per_sample > 0)
  {
    logInform("Computing graph connections (max %u edges per sample) ...", edges_per_sample);
    
    ompl::tools::SelfConfig sc(pcontext->getOMPLSimpleSetup().getSpaceInformation());
    double range = 0.0;
    sc.configurePlannerRange(range);
    
    // construct connexions
    const ob::StateSpacePtr &space = pcontext->getOMPLSimpleSetup().getStateSpace();
    std::vector<robot_state::RobotState> kstates(nthreads, default_state);
    const std::vector<const ompl::base::State*> &states = sstor->getStates();
    std::vector<ompl::base::ScopedState<> > temps(nthreads, ompl::base::ScopedState<>(space));
    
    ompl::time::point start = ompl::time::now();
    int good = 0;
    int done = -1;
    
#pragma omp parallel for schedule(dynamic) 
    for (std::size_t j = 0 ; j < sstor->size() ; ++j)
    {
      int threadid = omp_get_thread_num();
      robot_state::RobotState &kstate = kstates[threadid];
      robot_state::JointStateGroup *jsg = kstate.getJointStateGroup(pcontext->getJointModelGroup()->getName());
      ompl::base::State *temp = temps[threadid].get();
      int done_now = 100 * j / sstor->size();
      if (done != done_now)
      {
	done = done_now;
        logInform("%d%% complete", done);
      }
      
      for (std::size_t i = j + 1 ; i < sstor->size() ; ++i)
      {
	double d = space->distance(states[j], states[i]);

        if (d > range * 3.0 || d < range / 100.0)
          continue;
        
        space->interpolate(states[j], states[i], 0.5, temp);
        pcontext->getOMPLStateSpace()->copyToRobotState(kstate, temp);
        if (kset.decide(kstate).satisfied)
        {
	  space->interpolate(states[j], states[i], 0.25, temp);
	  pcontext->getOMPLStateSpace()->copyToRobotState(kstate, temp);
	  if (kset.decide(kstate).satisfied)
	  {
            space->interpolate(states[j], states[i], 0.75, temp);
            pcontext->getOMPLStateSpace()->copyToRobotState(kstate, temp);
            if (kset.decide(kstate).satisfied)
            {
#pragma omp critical
              {
                cass->getMetadata(i).push_back(j);
                cass->getMetadata(j).push_back(i);
                good++;
              }
              if (cass->getMetadata(j).size() >= edges_per_sample)
                break;
            }
	  }
        }
      }
    }
    result.state_connection_time = ompl::time::seconds(ompl::time::now() - start);
    logInform("Computed possible connexions in %lf seconds. Added %d connexions", result.state_connection_time, good);
  }
  
  return sstor;
}
예제 #11
0
int main(int argc, char ** argv){
  struct timeval start, end;
  Liste * fichiers = fichiers_reguliers(SHAKESPEARE_DIR);
  Liste * mots;
  char * fichier;
  TrieHybride * t = NULL;
  int i,fd,fd2,arg_fusion,res;
  double res_d;
  char buff[128];
  pthread_t tid[NB_THREADS];
  pthread_attr_t attr; 
  briandais_t * br;

  /****************************************************************************
                      BENCHMARK INSERTION NON MULTITHREADE
  ****************************************************************************/
  printf("Insertion de toutes les pieces de Shakespeare \t\t: En cours ...");
  fflush(stdout);
  temps(&start);
  while((fichier=supprimer_debut(fichiers))){
    t=lire_fichier_th(fichier,t);
    free(fichier);
  }
  temps(&end);
  afficher_res(start,end);
  destroy_liste(fichiers);

  /****************************************************************************
                          SUPPRESSION MOTS HAMLET
  ****************************************************************************/
  printf("Suppression des mots de la piece \"Hamlet\" \t\t: En cours ...");  
  fflush(stdout);

  fd=ouvrir_fichier(SHAKESPEARE_DIR"hamlet.txt");
  if(fd<0){
    perror("ouverture fichier");
    exit(EXIT_FAILURE);
  }

  temps(&start);
  while(mot_suivant(fd,buff)>0){
    t=supprimer(t,buff);
  }
  temps(&end);
  afficher_res(start,end);

  if(close(fd)==-1){
    perror("close");
    exit(EXIT_FAILURE);
  }

  /****************************************************************************
                         RECHERCHE ALL'S WELL & HAMLET
  ****************************************************************************/
  printf("Recherche des mots de All's Well et Hamlet \t\t: En cours ...");  
  fflush(stdout);

  fd=ouvrir_fichier(SHAKESPEARE_DIR"hamlet.txt");
  if(fd<0){
    perror("ouverture fichier");
    exit(EXIT_FAILURE);
  }

  fd2=ouvrir_fichier(SHAKESPEARE_DIR"allswell.txt");
  if(fd2<0){
    perror("ouverture fichier");
    exit(EXIT_FAILURE);
  }

  temps(&start);
  while(mot_suivant(fd,buff)>0){
    recherche_trie_hybride(t,buff);
  } 
  while(mot_suivant(fd2,buff)>0){
    recherche_trie_hybride(t,buff);
  }
  temps(&end);

  afficher_res(start,end);
  if(close(fd)==-1){
    perror("close");
    exit(EXIT_FAILURE);
  } 

  if(close(fd2)==-1){
    perror("close");
    exit(EXIT_FAILURE);
  }

  /****************************************************************************
                        DESTRUCTION TRIE HYBRIDE
  ****************************************************************************/
  printf("Destruction du trie hybride \t\t\t\t: En cours ...");  
  fflush(stdout);

  temps(&start);
  free_trie_hybride(t);
  temps(&end);

  afficher_res(start,end);

  /****************************************************************************
                       CREATION SHAKESPEARE MULTITHREADE
  ****************************************************************************/
  fics=fichiers_reguliers(SHAKESPEARE_DIR);
  tries=creer_liste();
  sem_init(&sem,1,0);
  arg_fusion=fics->taille;  
  pthread_attr_init(&attr);
  pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);

  printf("Insertion multithreade des oeuvres de Shakespeare\t: En cours ...");  
  fflush(stdout);


  temps(&start);
  pthread_mutex_lock(&mutex_fics);
  for(i=0;i<NB_THREADS-1;i++){
    if(pthread_create(&(tid[i]),&attr,creation_trie_thread,NULL)==-1){
      perror("pthread_create");
      exit(EXIT_FAILURE);
    }
  }
  
  if(pthread_create(&(tid[NB_THREADS-1]),&attr,fusion_thread,&arg_fusion)==-1){
    perror("pthread_create");
    exit(EXIT_FAILURE);
  }

  pthread_cond_wait(&cond,&mutex_fics);
  temps(&end);

  afficher_res(start,end);

  destroy_liste(fics);
  t=supprimer_debut(tries);
  destroy_liste(tries);

 /****************************************************************************
                                COMPTAGE MOTS
  ****************************************************************************/
  printf("Comptage des mots \t\t\t\t\t: En cours ...");
  fflush(stdout);

  temps(&start);
  res=comptage_mots(t);
  temps(&end);
  afficher_res(start,end);
  printf("\t\t\t\t\t\t\t  %d\n",res);

  /****************************************************************************
                              POINTEURS VERS NULL
  ****************************************************************************/ 
  printf("Comptage des pointeurs vers NULL\t\t\t: En cours ...");
  fflush(stdout);

  temps(&start);
  res=comptage_nil(t);
  temps(&end);
  afficher_res(start,end);
  printf("\t\t\t\t\t\t\t  %d\n",res);

  /****************************************************************************
                 CREATION ET DESTRUCTION DE LA LISTE DES MOTS
  ****************************************************************************/ 
  printf("Creation et destruction de la liste des mots\t\t: En cours ...");
  fflush(stdout);

  temps(&start);
  mots=liste_mots(t);
  while(mots->taille!=0){
    char * tmp=supprimer_debut(mots);
    free(tmp);
  }
  free(mots);
  temps(&end);
  afficher_res(start,end);

  /****************************************************************************
                                   HAUTEUR
  ****************************************************************************/
  printf("Calcul de la hauteur \t\t\t\t\t: En cours ...");
  fflush(stdout);
  temps(&start);
  res=hauteur(t);
  temps(&end);
  afficher_res(start,end);
  printf("\t\t\t\t\t\t\t  %d\n",res);


  /****************************************************************************
                                 EQUILIBRAGE
  ****************************************************************************/
  printf("Equilibrage du trie\t\t\t\t\t: En cours ...");
  fflush(stdout);
  temps(&start);
  t=equilibrer(t);
  temps(&end);
  afficher_res(start,end);

  /****************************************************************************
                              RECALCUL HAUTEUR
  ****************************************************************************/
  printf("Recalcul de la hauteur \t\t\t\t\t: En cours ...");
  fflush(stdout);
  temps(&start);
  res=hauteur(t);
  temps(&end);
  afficher_res(start,end);
  printf("\t\t\t\t\t\t\t  %d\n",res);

  /****************************************************************************
                             PROFONDEUR MOYENNE
  ****************************************************************************/
  printf("Profondeur Moyenne\t\t\t\t\t: En cours ...");
  fflush(stdout);
  temps(&start);
  res_d=profondeur_moyenne(t);
  temps(&end);
  afficher_res(start,end);
  printf("\t\t\t\t\t\t\t  %f\n",res_d);

  /****************************************************************************
                          CONVERSION VERS BRIANDAIS
  ****************************************************************************/
  printf("Conversion vers arbre de la briandais\t\t\t: En cours ...");
  fflush(stdout);
  temps(&start);
  br=conversion(t);
  temps(&end);
  afficher_res(start,end);
  destroy_briandais(&br);

  /****************************************************************************
                        INSERTION D'UN MOT INEXISTANT
  ****************************************************************************/
  printf("Insertion d'un mot inexistant(anticonstitutionnellement): En cours ...");
  fflush(stdout);
  temps(&start);
  t=ajouter_trie_hybride("anticonstitutionnellement",t);
  temps(&end);
  afficher_res(start,end);
 
 /****************************************************************************
                        INSERTION D'UN MOT INEXISTANT
  ****************************************************************************/
  printf("Usage memoire (en octets)\t\t\t\t: En cours ...");
  fflush(stdout);
  temps(&start);
  res=usage_memoire(t);
  temps(&end);
  afficher_res(start,end);
  printf("\t\t\t\t\t\t\t  %d\n",res);

  free_trie_hybride(t);
  return EXIT_SUCCESS;
}