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.

78 lines
1.9 KiB

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