home *** CD-ROM | disk | FTP | other *** search
/ linuxmafia.com 2016 / linuxmafia.com.tar / linuxmafia.com / waygate / machin.c < prev    next >
C/C++ Source or Header  |  1995-04-26  |  4KB  |  184 lines

  1. /* 
  2.  * Machin Shin Auto-Haunter for the Wheel of Time WWW Archives at 
  3.  * faser.cs.olemiss.edu and polyhymnia.iwr.uni-heidelberg.de
  4.  *
  5.  * compile it and run it in the background from the jordan directory.
  6.  * before starting it, do 'ln no-haunt/* .' in the jordan
  7.  * directory.
  8.  * If you don't like the setup, move all from no-haunt into this directory
  9.  * and don't run it.
  10.  *
  11.  * (c) HG 1995
  12.  */
  13. #include <stdio.h>
  14. #include <stdlib.h>
  15. #include <unistd.h>
  16. #include <time.h>
  17. #include <sys/time.h>
  18. #include <strings.h>
  19. #include <signal.h>
  20.  
  21. #define DIR "no-haunt/"
  22. #define SECONDS 10
  23.  
  24. #define DEBUG 0
  25. #define HAUNTS 10
  26.  
  27. int filenumber[10];
  28. char truename[1024];
  29.  
  30. char *Files[100]={"DOD.html",
  31. "FAQ-1.html",
  32. "FAQ-10.html",
  33. "FAQ-11.html",
  34. "FAQ-2.html",
  35. "FAQ-3.html",
  36. "FAQ-4.html",
  37. "FAQ-5.html",
  38. "FAQ-6.html",
  39. "FAQ-7.html",
  40. "FAQ-8.html",
  41. "FAQ-9.html",
  42. "FAQ.html",
  43. "GH.html",
  44. "GH_OP.html",
  45. "JordanFilk.html",
  46. "Loony_Ideas.html",
  47. "Manetheren_Girls.html",
  48. "MissLoC.html",
  49. "Money_for_nothing.html",
  50. "Old.Humor-1.html",
  51. "Old.Humor-2.html",
  52. "Old.Humor.html",
  53. "RollingAiel.html",
  54. "TheyMight.html",
  55. "Wheel_of_Pooh.html",
  56. "comment-form.html",
  57. "dc-social.html",
  58. "erica-poem.html",
  59. "hoax.expose.html",
  60. "hoax.summary.html",
  61. "homepages.html",
  62. "jordanites.html",
  63. "loc-contest-1.html",
  64. "loc-contest-10.html",
  65. "loc-contest-11.html",
  66. "loc-contest-12.html",
  67. "loc-contest-13.html",
  68. "loc-contest-14.html",
  69. "loc-contest-15.html",
  70. "loc-contest-16.html",
  71. "loc-contest-17.html",
  72. "loc-contest-18.html",
  73. "loc-contest-19.html",
  74. "loc-contest-2.html",
  75. "loc-contest-20.html",
  76. "loc-contest-21.html",
  77. "loc-contest-3.html",
  78. "loc-contest-4.html",
  79. "loc-contest-5.html",
  80. "loc-contest-6.html",
  81. "loc-contest-7.html",
  82. "loc-contest-8.html",
  83. "loc-contest-9.html",
  84. "loc-contest.html",
  85. "mistress-madwen.html",
  86. "preLoC-1.html",
  87. "preLoC-2.html",
  88. "preLoC-3.html",
  89. "preLoC-4.html",
  90. "preLoC-5.html",
  91. "preLoC-6.html",
  92. "preLoC-7.html",
  93. "preLoC-8.html",
  94. "preLoC-9.html",
  95. "preLoC.html",
  96. "second.survey.results.html",
  97. "tfoh.plot.contest-1.html",
  98. "tfoh.plot.contest-10.html",
  99. "tfoh.plot.contest-11.html",
  100. "tfoh.plot.contest-12.html",
  101. "tfoh.plot.contest-13.html",
  102. "tfoh.plot.contest-14.html",
  103. "tfoh.plot.contest-15.html",
  104. "tfoh.plot.contest-2.html",
  105. "tfoh.plot.contest-3.html",
  106. "tfoh.plot.contest-4.html",
  107. "tfoh.plot.contest-5.html",
  108. "tfoh.plot.contest-6.html",
  109. "tfoh.plot.contest-7.html",
  110. "tfoh.plot.contest-8.html",
  111. "tfoh.plot.contest-9.html",
  112. "tfoh.plot.contest.html",
  113. "two.rivers.plot.contest-1.html",
  114. "two.rivers.plot.contest-10.html",
  115. "two.rivers.plot.contest-11.html",
  116. "two.rivers.plot.contest-2.html",
  117. "two.rivers.plot.contest-3.html",
  118. "two.rivers.plot.contest-4.html",
  119. "two.rivers.plot.contest-5.html",
  120. "two.rivers.plot.contest-6.html",
  121. "two.rivers.plot.contest-7.html",
  122. "two.rivers.plot.contest-8.html",
  123. "two.rivers.plot.contest-9.html",
  124. "two.rivers.plot.contest.html" ,
  125. "MachinShin.html"};
  126.  
  127. #define NOFFILES 95
  128.  
  129. void sighandler()
  130. {
  131.   int i;
  132.  
  133.   for (i=0;i<HAUNTS;i++) {
  134.     strcpy(truename,DIR);
  135.     strcat(truename,Files[filenumber[i]]);
  136.     unlink (Files[filenumber[i]]);
  137.     link (truename,Files[filenumber[i]]);
  138.   }
  139.   exit(0);
  140. }
  141.  
  142.  
  143. void main()
  144. {
  145.   int i;
  146.  
  147.   struct sigaction act;
  148.   struct timeval tp;
  149.   struct timezone tzp;
  150.  
  151.   act.sa_handler = sighandler;
  152.   act.sa_mask = 0;
  153.   act.sa_flags = 0;
  154.  
  155.   sigaction(SIGHUP, &act, NULL);
  156.   sigaction(SIGINT, &act, NULL);
  157.   sigaction(SIGQUIT, &act, NULL);
  158.   sigaction(SIGTERM, &act, NULL);
  159.   sigaction(SIGUSR1, &act, NULL);
  160.   sigaction(SIGUSR2, &act, NULL);
  161.  
  162.   i=gettimeofday(&tp,&tzp);
  163.   srand ((int) tp.tv_sec);
  164.   while (1) {
  165.     for (i=0;i<HAUNTS;i++) {
  166.     filenumber[i] = rand() % NOFFILES;
  167.     strcpy(truename,DIR);
  168.     strcat(truename,Files[NOFFILES]);
  169.     unlink (Files[filenumber[i]]);
  170.     link (truename,Files[filenumber[i]]);
  171. #if DEBUG
  172.     fprintf(stderr, "Haunting %s\n", Files[filenumber[i]]);
  173. #endif
  174.       }
  175.     sleep (SECONDS);
  176.     for (i=0;i<HAUNTS;i++) {
  177.     strcpy(truename,DIR);
  178.     strcat(truename,Files[filenumber[i]]);
  179.     unlink (Files[filenumber[i]]);
  180.     link (truename,Files[filenumber[i]]);
  181.       }
  182.   }
  183. }
  184.