home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / toss-2.c < prev    next >
C/C++ Source or Header  |  1993-06-01  |  2KB  |  55 lines

  1. /******************************************************************************
  2. *
  3. *           Module Name: TOSS.C
  4. *        Classification: Unclassified
  5. *               Version: 1.0
  6. *
  7. *           Environment: IBM OS/2 2.0+
  8. *              Compiler: IBM C-Set/2 1.0 /O+
  9. *
  10. *               Purpose: A filter which deletes lines containing any of the
  11. *                        text passed as command line parameters to this
  12. *                        routine
  13. *
  14. *               Example: icc /Kb xyz.c | toss EDC01234 EDC4321 > xyz.err
  15. *                        this will remove all lines containing the text
  16. *                        "EDC001234" and EDC4321" from the stream.
  17. *
  18. * -- change activity log --
  19. * Ver.  Date     AUTH    Loc.  -  Change
  20. *
  21. * 1.0   92/01/11  IA     10    - program created.
  22. * 1.1   93/05/03  J Furgal     - Multiple message logic added.
  23. * 1.2   92/01/04  J Furgal     - Error string detection and return code added.
  24. ******************************************************************************/
  25.  
  26. #include <stdio.h>
  27. #include <string.h>
  28.  
  29. int main(int argc, char *argv[]);
  30. char line_buff[32768];      /* 32K line length should be enough */
  31.  
  32. int main(int argc, char *argv[])
  33. {
  34.    register int i;  /* use register to enforce no taking the address of i */
  35.    register char *foundMsg;
  36.    int returnCode = 0;
  37.  
  38.    while (gets(line_buff)) {
  39.  
  40.       if ( strstr(line_buff, "error") ) {
  41.           returnCode = 12;
  42.       } /* endif */
  43.  
  44.       for (i = 1, foundMsg = NULL; i < argc ; i++) {
  45.          if ( (foundMsg = strstr(line_buff, argv[i])) )
  46.             break;
  47.       }
  48.       if ( !foundMsg )
  49.          puts(line_buff);
  50.    } /* endwhile */
  51.  
  52.    return returnCode;
  53. }
  54.  
  55.