OpenSDE Framework (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
992 B

  1. /*
  2. * --- SDE-COPYRIGHT-NOTE-BEGIN ---
  3. * This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. *
  5. * Filename: lib/misc/xline.c
  6. * Copyright (C) 2008 The OpenSDE Project
  7. * Copyright (C) 2004 - 2006 The T2 SDE Project
  8. * Copyright (C) 1998 - 2003 Clifford Wolf
  9. *
  10. * More information can be found in the files COPYING and README.
  11. *
  12. * This program is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; version 2 of the License. A copy of the
  15. * GNU General Public License can be found in the file COPYING.
  16. * --- SDE-COPYRIGHT-NOTE-END ---
  17. */
  18. #include <stdio.h>
  19. #include <time.h>
  20. #include <unistd.h>
  21. int main() {
  22. char ch,line[512];
  23. time_t lasttm=0;
  24. int c=0;
  25. while ( read(0,&ch,1)==1 ) {
  26. line[c++]=ch;
  27. if (ch == '\n')
  28. if (lasttm<time(NULL)-5) {
  29. line[c-1]=c=0; puts(line); time(&lasttm);
  30. } else
  31. c=0;
  32. else
  33. if (c>500) c=500;
  34. }
  35. return 0;
  36. }