Exemplo n.º 1
0
// Fonction indiquant la présence de la chaine_a_trouver dans la chaine_source
int locate(char chaine_a_trouver[], char chaine_source[])
{
    int i=0, indice_dbt = -1;
    char buffer[20];

    if ( strstr(chaine_source, chaine_a_trouver) != NULL)
    {
        if (strcmp(chaine_a_trouver, "+CMTI:") == 0)
        {
            if((indice_dbt = str_istr(chaine_source, "+CMTI:")) == -1)
                return 0;
            else
            {
                for (i = 0; i < 15; i++)
                {
                    buffer[i] = chaine_source[i+indice_dbt];
                }
                strcpy(info_SMS_recu, buffer);
            }
        }
        return 1;
    }
    else
        return 0;
}
Exemplo n.º 2
0
int optionW(char *string, char *stringRef, char *args) // function necessary to obtain the result with the w option
{
  int isW = 0, result = 0;

  if (strstr(args, "i"))
    {
      strcpy(string, ConverInMinuscule(string));
      strcpy(stringRef, ConverInMinuscule(stringRef));
      result = str_istr(string, stringRef);

      if(result == 0)
        {
          if (string[result + strlen(stringRef)] == ' ')
            isW = 1;
          if ((string[result + strlen(stringRef)] == '\0') || (string[result + strlen(stringRef)] == '\n'))
            isW = 1;
        }
      else
        {
          if ((string[result + strlen(stringRef)] == ' ') && (string[result -1] == ' '))
            isW = 1;
          if (((string[result + strlen(stringRef)] == '\0') || (string[result + strlen(stringRef)] == '\n')) && (string[result -1] == ' '))
            isW = 1;
        }
    }

  else
    {
      result = str_istr(string, stringRef);

      if(result == 0)
        {
          if (string[result + strlen(stringRef)] == ' ')
            isW = 1;
          if ((string[result + strlen(stringRef)] == '\0') || (string[result + strlen(stringRef)] == '\n'))
            isW = 1;
        }
      else
        {
          if ((string[result + strlen(stringRef)] == ' ') && (string[result -1] == ' '))
            isW = 1;
          if (((string[result + strlen(stringRef)] == '\0') || (string[result + strlen(stringRef)] == '\n')) && (string[result -1] == ' '))
            isW = 1;
        }
    }
  return isW;
}
Exemplo n.º 3
0
char* fctO(char *string, char *stringRef, char *args)
{
  int result = 0, i = 0, j = 0;
  if (strstr(args, "i"))
    {
      strcpy(string, ConverInMinuscule(string));
      strcpy(stringRef, ConverInMinuscule(stringRef));
    }
  result = str_istr(string, stringRef);
  char stringToReturn[strlen(stringRef)];
  for (i = result; i < (result + strlen(stringRef)); i++)
    {
      stringToReturn[j] = string[i];
      j++;
    }

  return stringToReturn;
}
Exemplo n.º 4
0
char* mylib_find_and_replace(const char *string1, FILE* file1, char* change){
	char* string3 = (char*)malloc(10*sizeof(char));
	char* string = (char*)malloc(10*sizeof(char));
	long int  start, length;
	int i=0;
	fseek(file1, 0, SEEK_SET);
	while(fgets(string, 10, file1)!=NULL){
		string[strlen(string)-1] = '\0';
		start = str_istr(string1, string);
		if(start>=0){
			length = strlen(string);
			string = str_replace(string1, start, length, change);
			return string;
		}
		else i++;
	}
	return "";
}