home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / virus / ddj0491.zip / MORROW.ZIP / UTIL.C < prev    next >
C/C++ Source or Header  |  1989-09-03  |  794b  |  78 lines

  1. /***
  2. *       GASystem
  3. *       Mike Morrow
  4. *       September 1989
  5. ***/
  6.  
  7.  
  8.  
  9. /**
  10. *    Utilities
  11. **/
  12.  
  13.  
  14.  
  15. #include <ctype.h>
  16. #include <stdio.h>
  17. #include "util.h"
  18.  
  19. #if __STDC__
  20. #include <stdlib.h>
  21. #endif
  22.  
  23.  
  24. #ifndef randnum
  25.  
  26. /**
  27. *    Generate a random number between [0, x - 1]
  28. **/
  29. int randnum(x)
  30. int x;
  31. {
  32. #ifdef unix
  33.     return (int) (random() % x);
  34. #else
  35.     return (int) (rand() % x);
  36. #endif
  37. }
  38.  
  39.  
  40. #endif
  41.  
  42.  
  43.  
  44.  
  45. char *eatblanks(s)
  46. char *s;
  47. {
  48.     while(isspace(*s)) s++;
  49.     return s;
  50. }
  51.  
  52.  
  53. void fatal(s)
  54. char *s;
  55. {
  56.     fprintf(stderr, "Fatal error: %s\n", s);
  57.     exit(1);
  58. }
  59.  
  60. void warning(s)
  61. char *s;
  62. {
  63.     fprintf(stderr, "Warning: %s\n", s);
  64.     fflush(stderr);
  65. }
  66.  
  67.  
  68. void strupper(s)
  69. char *s;
  70. {
  71.     while(*s)
  72.     {
  73.         if(islower(*s))
  74.             *s = toupper(*s);
  75.         s++;
  76.     }
  77. }
  78.