team AllStuRead's repo
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

115 行
4.0 KiB

  1. /***************************************************************************
  2. * Dr. Evil's Insidious Bomb, Version 1.1
  3. * Copyright 2011, Dr. Evil Incorporated. All rights reserved.
  4. *
  5. * LICENSE:
  6. *
  7. * Dr. Evil Incorporated (the PERPETRATOR) hereby grants you (the
  8. * VICTIM) explicit permission to use this bomb (the BOMB). This is a
  9. * time limited license, which expires on the death of the VICTIM.
  10. * The PERPETRATOR takes no responsibility for damage, frustration,
  11. * insanity, bug-eyes, carpal-tunnel syndrome, loss of sleep, or other
  12. * harm to the VICTIM. Unless the PERPETRATOR wants to take credit,
  13. * that is. The VICTIM may not distribute this bomb source code to
  14. * any enemies of the PERPETRATOR. No VICTIM may debug,
  15. * reverse-engineer, run "strings" on, decompile, decrypt, or use any
  16. * other technique to gain knowledge of and defuse the BOMB. BOMB
  17. * proof clothing may not be worn when handling this program. The
  18. * PERPETRATOR will not apologize for the PERPETRATOR's poor sense of
  19. * humor. This license is null and void where the BOMB is prohibited
  20. * by law.
  21. ***************************************************************************/
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include "support.h"
  25. #include "phases.h"
  26. /*
  27. * Note to self: Remember to erase this file so my victims will have no
  28. * idea what is going on, and so they will all blow up in a
  29. * spectaculary fiendish explosion. -- Dr. Evil
  30. */
  31. FILE *infile;
  32. int main(int argc, char *argv[])
  33. {
  34. char *input;
  35. /* Note to self: remember to port this bomb to Windows and put a
  36. * fantastic GUI on it. */
  37. /* When run with no arguments, the bomb reads its input lines
  38. * from standard input. */
  39. if (argc == 1) {
  40. infile = stdin;
  41. }
  42. /* When run with one argument <file>, the bomb reads from <file>
  43. * until EOF, and then switches to standard input. Thus, as you
  44. * defuse each phase, you can add its defusing string to <file> and
  45. * avoid having to retype it. */
  46. else if (argc == 2) {
  47. if (!(infile = fopen(argv[1], "r"))) {
  48. printf("%s: Error: Couldn't open %s\n", argv[0], argv[1]);
  49. exit(8);
  50. }
  51. }
  52. /* You can't call the bomb with more than 1 command line argument. */
  53. else {
  54. printf("Usage: %s [<input_file>]\n", argv[0]);
  55. exit(8);
  56. }
  57. /* Do all sorts of secret stuff that makes the bomb harder to defuse. */
  58. initialize_bomb();
  59. printf("Welcome to my fiendish little bomb. You have 6 phases with\n");
  60. printf("which to blow yourself up. Have a nice day!\n");
  61. /* Hmm... Six phases must be more secure than one phase! */
  62. input = read_line(); /* Get input */
  63. phase_1(input); /* Run the phase */
  64. phase_defused(); /* Drat! They figured it out!
  65. * Let me know how they did it. */
  66. printf("Phase 1 defused. How about the next one?\n");
  67. /* The second phase is harder. No one will ever figure out
  68. * how to defuse this... */
  69. input = read_line();
  70. phase_2(input);
  71. phase_defused();
  72. printf("That's number 2. Keep going!\n");
  73. /* I guess this is too easy so far. Some more complex code will
  74. * confuse people. */
  75. input = read_line();
  76. phase_3(input);
  77. phase_defused();
  78. printf("Halfway there!\n");
  79. /* Oh yeah? Well, how good is your math? Try on this saucy problem! */
  80. input = read_line();
  81. phase_4(input);
  82. phase_defused();
  83. printf("So you got that one. Try this one.\n");
  84. /* Round and 'round in memory we go, where we stop, the bomb blows! */
  85. input = read_line();
  86. phase_5(input);
  87. phase_defused();
  88. printf("Good work! On to the next...\n");
  89. /* This phase will never be used, since no one will get past the
  90. * earlier ones. But just in case, make this one extra hard. */
  91. input = read_line();
  92. phase_6(input);
  93. phase_defused();
  94. /* Wow, they got it! But isn't something... missing? Perhaps
  95. * something they overlooked? Mua ha ha ha ha! */
  96. return 0;
  97. }