home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / compsrcs / misc / volume06 / gbcount2 < prev    next >
Encoding:
Internet Message Format  |  1991-08-27  |  2.8 KB

  1. From decwrl!wyse!uunet!allbery Sun Jan 29 20:30:41 PST 1989
  2. Article 800 of comp.sources.misc:
  3. Path: granite!decwrl!wyse!uunet!allbery
  4. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  5. Newsgroups: comp.sources.misc
  6. Subject: v06i027: Bush in '92 countdown program
  7. Message-ID: <47760@uunet.UU.NET>
  8. Date: 29 Jan 89 21:21:51 GMT
  9. Sender: allbery@uunet.UU.NET
  10. Reply-To: kscott@cca.ucsf.EDU (Kevin Scott)
  11. Lines: 86
  12. Approved: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  13. X-Arch-Keywords: portable, c, politics, fun
  14.  
  15. Posting-number: Volume 6, Issue 27
  16. Submitted-by: kscott@cca.ucsf.EDU (Kevin Scott)
  17. Archive-name: gbcount2
  18.  
  19. [This silly politics stuff is making me violently sick.  ++bsa]
  20.  
  21. #! /bin/sh
  22. # This file was wrapped with "dummyshar".  "sh" this file to extract.
  23. # Contents:  gbcount.c
  24. echo extracting 'gbcount.c'
  25. if test -f 'gbcount.c' -a -z "$1"; then echo Not overwriting 'gbcount.c'; else
  26. sed 's/^X//' << \EOF > 'gbcount.c'
  27. X/*
  28. X * gbcount.c: George Bush Countdown program
  29. X * Paul Heckbert, ph@degas.berkeley.edu        9 Mar 1988
  30. X * Kevin Scott, kscott@cca.ucsf.edu        20 Jan 1989
  31. X */
  32. X
  33. X#define BSD                /* use BSD rng */
  34. X/*#define USG                /* use USG rng; otherwise V7 */
  35. X
  36. X#include <stdio.h>
  37. X#define SEC_PER_DAY (24*3600)
  38. X#define BUSH_TIMEOUT 727300800    /* inauguration day
  39. X                    noon, 20 Jan 1993: time to rejoice! 
  40. X                    (anticipating one term) */
  41. X
  42. Xstatic char *wimpname[] = {
  43. X    "The French Connection",
  44. X    "George Bush",
  45. X    "Mister Skull and Bones",
  46. X    "The Quayle Hunter",
  47. X    "Noriega's blackmailee",
  48. X    "Dan Quayle jokes",
  49. X    "BU--SH--",
  50. X    "a kindler, gentler aristocracy",
  51. X    "1000 points of light",
  52. X    "Son of the Gipper",
  53. X    "the Wimp",
  54. X};
  55. X#define WIMPNUM (sizeof wimpname/sizeof wimpname[0])
  56. X
  57. Xdouble frandom();
  58. X
  59. Xmain(argc, argv)
  60. Xint argc;
  61. Xchar *argv[];
  62. X{
  63. X    long t;
  64. X    int i;
  65. X
  66. X    t = time(0);
  67. X    srandom(t);
  68. X    for (i=0; i<30; i++) random();
  69. X    if (argc == 1) t = BUSH_TIMEOUT-t;
  70. X    else if (*(argv[1]+1) == 'p') t = BUSH_TIMEOUT -t -10800;
  71. X    else if (*(argv[1]+1) == 'm') t = BUSH_TIMEOUT -t -7200;
  72. X    else if (*(argv[1]+1) == 'c') t = BUSH_TIMEOUT -t -3600;
  73. X    else if (*(argv[1]+1) == 'e') t = BUSH_TIMEOUT -t;
  74. X    else printf("By Eastern Standard Time there are ");
  75. X    printf("%d more days of %s\n", t/SEC_PER_DAY,
  76. X    wimpname[(int)(WIMPNUM*frandom())] );
  77. X}
  78. X
  79. Xdouble frandom()        /* random number between 0 and 1 */
  80. X{
  81. X#ifdef BSD
  82. X    return random()/2147483647.;
  83. X#endif
  84. X#ifdef SYSV
  85. X    extern double drand48();
  86. X
  87. X    srand48(time(0) + getpid());
  88. X    return drand48();
  89. X#endif
  90. X#if !(defined(BSD) || defined(SYSV))
  91. X    srand((unsigned) time((long *) 0) + getpid());
  92. X    return rand() / ((double) (2 << 15) - 1);
  93. X#endif
  94. X}
  95. X
  96. EOF
  97. chars=`wc -c < 'gbcount.c'`
  98. if test $chars !=     1779; then echo 'gbcount.c' is $chars characters, should be     1779 characters!; fi
  99. fi
  100. exit 0
  101.  
  102.  
  103.