Beispiel #1
0
/// Returns the string after the nth comma in the string s. If that
/// string is quoted, the quotes are removed. If there is no valid 
/// string to be found, returns TRUE. Otherwise, returns FALSE 
int find_comma_separated_string(char *s, unsigned int n)
{
  int start = 0, end;
  unsigned int count = 0; 
  while (count < n)
    {
      if ((start = find_next_comma(s,start)) == -1)
	return TRUE;
      ++count;
      // Advance the pointer past the current comma
      ++start;
    }

  // It's okay if there is no next comma, it just means that this is
  // the last comma separated value in the string 
  if ((end = find_next_comma(s,start)) == -1)
    end = strlen(s);

  // Strip off the quotation marks, if necessary. We don't have to worry
  // about uneven quotation marks (i.e quotes at the start but not the end
  // as they are handled by the the find_next_comma function.
  if (s[start] == '"')
    ++start;
  if (s[end - 1] == '"')
    end--;

  s[end] = 0;
  shift_string(s,0,start);
  
  return FALSE;
}
Beispiel #2
0
void	remove_comment_and_name(char *file)
{
    int	i;

    i = -1;
    while (file[++i])
    {
        if (!my_strncmp(&file[i], NAME_CMD_STRING, my_strlen(NAME_CMD_STRING)))
            while (file[i] != '\n' && file[i])
                shift_string(file, i);
        if (!my_strncmp(&file[i], COMMENT_CMD_STRING,
                        my_strlen(COMMENT_CMD_STRING)))
            while (file[i] != '\n' && file[i])
                shift_string(file, i);
    }
}
void char_stream(char *buffer, SWSpecification *swspec, char *text) {
   int size = strlen(text);
   //char *streaming = (char *)malloc(sizeof(char) * (size+1));

   strcpy(buffer, text);

   if (swspec->encrypt == true) {
      encrypt_caesar_cipher(buffer);
      printf("encrypt:  %s\n", buffer);
   }
   if (swspec->shift == true) {
      shift_string(buffer);
      printf("shift:    %s\n", buffer);
   }

   if (swspec->inverter == true) {
      invert_string(buffer);
      printf("inverter: %s\n", buffer);
   }

   if (swspec->decrypt == true) {
      decrypt_caesar_cipher(buffer);
      printf("decrypt:  %s\n", buffer);
   }
}
Beispiel #4
0
int main() {
    char str[20];
    char *p;
    printf("Digite a palavra: ");
    scanf("%s",str);
    getchar();
    p=shift_string (str);
    printf("Antiga: %s\nNova: %s ",str,p);
    return (EXIT_SUCCESS);
}
Beispiel #5
0
int remove_escaped_quotes(char * str)
{
  if (NULL == str)
    return TRUE;
  
  size_t pos = 0;
  while (str[pos] != 0)
  {
    if ('\\' == str[pos] && '"' == str[pos+1])
      shift_string(str,pos,pos+1);
    
    ++pos;
  }
  
  return FALSE;
}