| 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
 56
 57
 
 |  void analyse ( descStruct *pdescStruct, FILE *cmdFile)
{
  char buf_pipe[20];
  char buf_cmdFile[40];
  char * ptr_tCmd;
  char * position;
  char answer[50];
  //int CmdFind = 0;
 
 
 
  if(NULL != fgets ( buf_pipe, sizeof (buf_pipe) -1, pdescStruct->fd) )
  {
	  buf_pipe[strlen(buf_pipe)] = '\0';
	  printf("\n la valeur de buf_pipe est: <%s>\n", buf_pipe);
	  rewind(cmdFile);
 
	  while(fgets( buf_cmdFile, sizeof (buf_cmdFile) - 1, cmdFile) )
	  {
 
	    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??????????????????????????????????????????????????????????");
 
	    if(NULL != strchr(buf_pipe, '\n')) {
	    printf("\n\n\n\n\nAttention, buf_pipe contient un saut de ligne!!\n\n\n\n\n");
	    }
	    ptr_tCmd = strstr ( buf_cmdFile, buf_pipe);
	    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");
 
	  }
 
  }
 
} |