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.

77 lines
1.8 KiB

  1. /* gcc -Wall -O2 scrsav.c -o scrsav
  2. * while : ; do ./scrsav /dev/vcc/a2 /dev/vcc/a3 ; sleep 5 ; done
  3. *
  4. * --- T2-COPYRIGHT-NOTE-BEGIN ---
  5. * This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  6. *
  7. * T2 SDE: misc/archive/scrsav.c
  8. * Copyright (C) 2004 - 2006 The T2 SDE Project
  9. * Copyright (C) 1998 - 2003 Clifford Wolf
  10. *
  11. * More information can be found in the files COPYING and README.
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; version 2 of the License. A copy of the
  16. * GNU General Public License can be found in the file COPYING.
  17. * --- T2-COPYRIGHT-NOTE-END ---
  18. */
  19. #include <stdio.h>
  20. #include <sys/types.h>
  21. #include <sys/stat.h>
  22. #include <fcntl.h>
  23. #include <unistd.h>
  24. #include <time.h>
  25. #include <stdlib.h>
  26. #include <endian.h>
  27. #ifdef iMAC_CON
  28. # define LINES 48
  29. # define CHARS 128
  30. #else
  31. # define LINES 25
  32. # define CHARS 80
  33. #endif
  34. #define BUFSIZE (LINES*CHARS*2)
  35. #define LINESIZE (CHARS*2)
  36. int main(int argc, char ** argv) {
  37. char buffer[BUFSIZE];
  38. char miscdata[4];
  39. int fd,c,i,j;
  40. if (argc != 3) {
  41. fprintf(stderr, "Usage: %s <src-vcs> <trg-vcs>\n", argv[0]);
  42. fprintf(stderr, "E.g.: %s /dev/vcc/a2 /dev/vcc/a3\n", argv[0]);
  43. return 1;
  44. }
  45. fd=open(argv[1], O_RDONLY);
  46. if (fd < 0) { perror(argv[1]); return 1; }
  47. read(fd, miscdata, 4);
  48. read(fd, buffer, BUFSIZE);
  49. close(fd);
  50. srandom( time(NULL) + getpid() );
  51. for (c=0; c<BUFSIZE-1; c+=2) {
  52. #if __BYTE_ORDER == __LITTLE_ENDIAN
  53. i=c+1; j=c;
  54. #else
  55. j=c+1; i=c;
  56. #endif
  57. buffer[i] ^= buffer[j] ^ c ^ random() ;
  58. if ( c/LINESIZE+1 != time(NULL) % LINES )
  59. buffer[i] &= 0x0f;
  60. }
  61. fd=open(argv[2], O_WRONLY);
  62. if (fd < 0) { perror(argv[2]); return 1; }
  63. write(fd, miscdata, 4);
  64. write(fd, buffer, BUFSIZE);
  65. close(fd);
  66. return 0;
  67. }