| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 
 | void analyse( descStruct *pdescStruct, FILE *cmdFile)
{
  char buf_pipe[20];
  char buf_cmdFile[41];
  char * ptr_tCmd;
  char * position;
  char answer[50];
 // int CmdFind = 0;
 
 
 
 
//on cherche la ligne qui contient le mot buf_pipe
  if( NULL != fgets ( buf_pipe, 20, pdescStruct->fd) )
  {
	  printf(" \n la valeur de buf_pipe est: %s\n", buf_pipe);
	  rewind(cmdFile);
	  while(fgets( buf_cmdFile, 40, cmdFile) )
	  {
 
	    //initialization of buf_pipe
	    memset( buf_pipe, 0,sizeof(buf_pipe));
	    printf("\n\n\n");
	    printf("\n???????????????????????????????????????????????????");
	    printf("\n la commande extraite avant la boucle if est: %s ", buf_pipe);
	    printf("\n la ligne extraite avant la boucle if est: %s ",buf_cmdFile);
	    printf("\n???????????????????????????????????????????????????");
 
	    ptr_tCmd = strstr ( buf_cmdFile, buf_pipe);// recherche du mot dans la ligne
	    printf( "\n\n\n la valeur du pointeur sur la ligne est égal à: %p\n", ptr_tCmd );
	    if (ptr_tCmd)
	    {
		printf("\n§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§");
		printf("\n the comande to extract is: %s ", buf_pipe);
		printf("\n the line extracted is: %s ",buf_cmdFile);
		printf("\n§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§§");
		position = strstr (buf_cmdFile,";"); //extract the answer
		strcpy( answer, (char*)(position + 1) );
 
		// copy answer in pipe
		fwrite( answer, strlen( answer),1, pdescStruct->fd);
		printf("\n\n\n");
		printf("\n..........................................");
		printf("\n the answer is: %s ",answer);
		printf("\n...........................................");
		//CmdFind = 1;
	    }
	    else 
	      printf(" the command dosnt exist in the texte file");
 
	  }
 
  }
 
} | 
Partager