mirror of the now-defunct rocklinux.org
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.

84 lines
2.2 KiB

  1. /* gcc -Wall -O2 scrsav.c -o scrsav
  2. * while : ; do ./scrsav /dev/vcc/a2 /dev/vcc/a3 ; sleep 5 ; done
  3. *
  4. * --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  5. *
  6. * This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  7. * Please add additional copyright information _after_ the line containing
  8. * the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  9. * the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  10. *
  11. * ROCK Linux: rock-src/misc/archive/scrsav.c
  12. * ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  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; either version 2 of the License, or
  17. * (at your option) any later version. A copy of the GNU General Public
  18. * License can be found at Documentation/COPYING.
  19. *
  20. * Many people helped and are helping developing ROCK Linux. Please
  21. * have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  22. * file for details.
  23. *
  24. * --- ROCK-COPYRIGHT-NOTE-END ---
  25. */
  26. #include <stdio.h>
  27. #include <sys/types.h>
  28. #include <sys/stat.h>
  29. #include <fcntl.h>
  30. #include <unistd.h>
  31. #include <time.h>
  32. #include <stdlib.h>
  33. #include <endian.h>
  34. #ifdef iMAC_CON
  35. # define LINES 48
  36. # define CHARS 128
  37. #else
  38. # define LINES 25
  39. # define CHARS 80
  40. #endif
  41. #define BUFSIZE (LINES*CHARS*2)
  42. #define LINESIZE (CHARS*2)
  43. int main(int argc, char ** argv) {
  44. char buffer[BUFSIZE];
  45. char miscdata[4];
  46. int fd,c,i,j;
  47. if (argc != 3) {
  48. fprintf(stderr, "Usage: %s <src-vcs> <trg-vcs>\n", argv[0]);
  49. fprintf(stderr, "E.g.: %s /dev/vcc/a2 /dev/vcc/a3\n", argv[0]);
  50. return 1;
  51. }
  52. fd=open(argv[1], O_RDONLY);
  53. if (fd < 0) { perror(argv[1]); return 1; }
  54. read(fd, miscdata, 4);
  55. read(fd, buffer, BUFSIZE);
  56. close(fd);
  57. srandom( time(NULL) + getpid() );
  58. for (c=0; c<BUFSIZE-1; c+=2) {
  59. #if __BYTE_ORDER == __LITTLE_ENDIAN
  60. i=c+1; j=c;
  61. #else
  62. j=c+1; i=c;
  63. #endif
  64. buffer[i] ^= buffer[j] ^ c ^ random() ;
  65. if ( c/LINESIZE+1 != time(NULL) % LINES )
  66. buffer[i] &= 0x0f;
  67. }
  68. fd=open(argv[2], O_WRONLY);
  69. if (fd < 0) { perror(argv[2]); return 1; }
  70. write(fd, miscdata, 4);
  71. write(fd, buffer, BUFSIZE);
  72. close(fd);
  73. return 0;
  74. }