ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

int find_str ( char sz,
FILE p,
int  invert_search,
int  count_lines,
int  number_output,
int  ignore_case,
int  at_start,
int  literal_search,
int  at_end,
int  reg_express,
int  exact_match,
int  sub_dirs,
int  only_fname 
)

Definition at line 51 of file findstr.c.

{
  int i, length;
  long line_number = 0, total_lines = 0;
  char *c, temp_str[MAX_STR], this_line[MAX_STR];

  /* Convert to upper if needed */
  if (ignore_case)
    {
      length = strlen (sz);
      for (i = 0; i < length; i++)
    sz[i] = toupper (sz[i]);
    }

  /* Scan the file until EOF */
  while (fgets (temp_str, MAX_STR, p) != NULL)
    {
      /* Remove the trailing newline */
      length = strlen (temp_str);
      if (temp_str[length-1] == '\n')
    {
      temp_str[length-1] = '\0';
    }

      /* Increment number of lines */
      line_number++;
      strcpy (this_line, temp_str);

      /* Convert to upper if needed */
      if (ignore_case)
    {
      for (i = 0; i < length; i++)
        {
          temp_str[i] = toupper (temp_str[i]);
        }
    }

      /* Locate the substring */

      /* strstr() returns a pointer to the first occurrence in the
       string of the substring */
      c = strstr (temp_str, sz);

      if ( ((invert_search) ? (c == NULL) : (c != NULL)) )
    {
      if (!count_lines)
        {
          if (number_output)
        printf ("%ld:", line_number);

          /* Print the line of text */
          puts (this_line);
        }

      total_lines++;
    } /* long if */
    } /* while fgets */

  if (count_lines)
    {
      /* Just show num. lines that contain the string */
      printf ("%ld\n", total_lines);
    }


 /* RETURN: If the string was found at least once, returns 1.
  * If the string was not found at all, returns 0.
  */
  return (total_lines > 0 ? 1 : 0);
}

Generated on Sat May 26 2012 04:38:58 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.