home *** CD-ROM | disk | FTP | other *** search
/ ftp.wwiv.com / ftp.wwiv.com.zip / ftp.wwiv.com / pub / INTERNET / UPC2S1.ZIP / TIMESTMP.C < prev    next >
C/C++ Source or Header  |  1993-08-10  |  7KB  |  218 lines

  1. /*--------------------------------------------------------------------*/
  2. /*    t i m e s t m p . c                                             */
  3. /*                                                                    */
  4. /*    Compiler timestamps for display at program start-up             */
  5. /*--------------------------------------------------------------------*/
  6.  
  7. /*--------------------------------------------------------------------*/
  8. /*       Changes Copyright (c) 1989-1993 by Kendra Electronic         */
  9. /*       Wonderworks.                                                 */
  10. /*                                                                    */
  11. /*       All rights reserved except those explicitly granted by       */
  12. /*       the UUPC/extended license agreement.                         */
  13. /*--------------------------------------------------------------------*/
  14.  
  15. /*--------------------------------------------------------------------*/
  16. /*                          RCS Information                           */
  17. /*--------------------------------------------------------------------*/
  18.  
  19. /*
  20.  *    $Id: timestmp.c 1.8 1993/08/11 02:31:12 ahd Exp $
  21.  *
  22.  *    Revision history:
  23.  *    $Log: timestmp.c $
  24.  *     Revision 1.8  1993/08/11  02:31:12  ahd
  25.  *     Always display the banner
  26.  *
  27.  *     Revision 1.7  1993/08/03  03:11:49  ahd
  28.  *     Drop _EasyWinInit
  29.  *
  30.  *     Revision 1.6  1993/08/02  03:24:59  ahd
  31.  *     Further changes in support of Robert Denny's Windows 3.x support
  32.  *
  33.  *     Revision 1.5  1993/07/31  16:22:16  ahd
  34.  *     Changes in support of Robert Denny's Windows 3.x support
  35.  *
  36.  */
  37.  
  38. /*--------------------------------------------------------------------*/
  39. /*                        System include files                        */
  40. /*--------------------------------------------------------------------*/
  41.  
  42. #include <dos.h>
  43. #include <direct.h>
  44. #include <io.h>
  45.  
  46. #include <stdio.h>
  47. #include <stdlib.h>
  48. #include <string.h>
  49.  
  50. #ifdef _Windows
  51. #include <windows.h>
  52. #include <time.h>
  53. #endif
  54.  
  55. /*--------------------------------------------------------------------*/
  56. /*                    UUPC/extended include files                     */
  57. /*--------------------------------------------------------------------*/
  58.  
  59. #include "lib.h"
  60. #include "win32ver.h"
  61. #include "timestmp.h"
  62.  
  63. #ifdef _Windows
  64. #include "winutil.h"
  65. #include "ssleep.h"
  66. #endif
  67.  
  68. /*--------------------------------------------------------------------*/
  69. /*                          Global variables                          */
  70. /*--------------------------------------------------------------------*/
  71.  
  72. #ifdef _Windows
  73. currentfile();
  74. #endif
  75.  
  76. char compiled[] = { __DATE__ } ;
  77. char compilet[] = { __TIME__ } ;
  78. char compilev[] = { UUPCV } ;
  79.  
  80. char compilep[] = { "UUPC/extended" } ;
  81. char *compilen  = compilep;
  82.  
  83. #ifdef _Windows
  84. char *compilew = NULL;
  85. #endif
  86.  
  87. /*--------------------------------------------------------------------*/
  88. /*       b a n n e r                                                  */
  89. /*                                                                    */
  90. /*       Report program name and version at startup                   */
  91. /*--------------------------------------------------------------------*/
  92.  
  93. void banner (char **argv)
  94. {
  95.       char dummy[FILENAME_MAX];
  96.       char program[FILENAME_MAX];
  97.  
  98.  
  99. #if defined(_Windows)
  100.    WORD wVersion;
  101.    WORD wMode;
  102.    char *szMode;
  103.  
  104. /*--------------------------------------------------------------------*/
  105. /*                     Determine Windows version                      */
  106. /*--------------------------------------------------------------------*/
  107.  
  108.    wVersion = LOWORD(GetVersion());
  109.    asm {
  110.          MOV      AX,0x400   // DPMI Get Version call
  111.          INT      0x31       // ax=ver,bx=win286/386...
  112.          AND      BX,3       // win386=1,win286=2
  113.          MOV      wMode,BX   // Put in local
  114.    }
  115.  
  116.    switch(wMode)
  117.    {
  118.       case 1:
  119.          szMode = "386 Enhanced";
  120.          break;
  121.  
  122.       case 2:
  123.          szMode = "Standard (286)";
  124.          break;
  125.  
  126.       default:
  127.          szMode = "Unknown";
  128.          break;
  129.    }
  130.  
  131.    if ( wVersion < 0x301 )
  132.    {
  133.       printmsg(0,"This program requires Windows 3.1, running %u.%u",
  134.                   (WORD)(LOBYTE(wVersion)),
  135.                   (WORD)(HIBYTE(wVersion)));
  136.       panic();
  137.    }
  138.  
  139.    sprintf(dummy, "Windows %u.%u %s",
  140.                   (WORD)(LOBYTE(wVersion)),
  141.                   (WORD)(HIBYTE(wVersion)),
  142.                   szMode );
  143.    compilew = newstr( dummy );
  144.  
  145. #endif
  146.  
  147. /*--------------------------------------------------------------------*/
  148. /*                     Deterine the program name                      */
  149. /*--------------------------------------------------------------------*/
  150.  
  151. #ifdef __TURBOC__
  152.       if (  fnsplit(argv[0],dummy,dummy, program,dummy) && FILENAME )
  153.       {
  154. #else
  155.       if (!equal(argv[0],"C"))    /* Microsoft C for no prog name? */
  156.       {
  157.          _splitpath( argv[0], dummy , dummy , program , dummy );
  158. #endif /* __TURBOC__ */
  159.  
  160.          strcpy(argv[0], program);  /* Reset original program name   */
  161.          compilen = argv[0];
  162.  
  163. /*--------------------------------------------------------------------*/
  164. /*                 Return if input is not the console                 */
  165. /*--------------------------------------------------------------------*/
  166.  
  167. #ifndef _Windows
  168.       if (!isatty(fileno(stdout))) /* Is the console I/O redirected?  */
  169.          return;                 /* Yes --> Run quietly              */
  170. #endif
  171.  
  172. /*--------------------------------------------------------------------*/
  173. /*                       Print the program name                       */
  174. /*--------------------------------------------------------------------*/
  175.  
  176.          fprintf(stderr,"%s: ",program);
  177.       } /* if */
  178.  
  179. /*--------------------------------------------------------------------*/
  180. /*    Now print out the version, operating system and time stamp      */
  181. /*--------------------------------------------------------------------*/
  182.  
  183.       fprintf(stderr,"%s %s (%s mode, %2.2s%3.3s%2.2s %5.5s)\n",
  184.                   compilep,
  185.                   compilev,
  186.  
  187. #ifdef WIN32
  188.                   "Windows 32 bit",
  189. #elif defined(_Windows)
  190.                   /* "Windows 16 bit", */ compilew,
  191. #elif defined(__OS2__)
  192.                   "OS/2 2.x",
  193. #elif defined(__TURBOC__)
  194.                   "DOS",
  195. #else
  196.                   (_osmode == DOS_MODE) ? "DOS" : "OS/2 1.x",
  197. #endif
  198.  
  199.                   &compiled[4],
  200.                   &compiled[0],
  201.                   &compiled[9],
  202.                   compilet);
  203.  
  204. #ifdef _Windows
  205.    sprintf( dummy, "%s  (%s %s)", program, compilep, compilev);
  206.  
  207.    hOurTask = GetCurrentTask();
  208.    if ( hOurTask == NULL )
  209.       panic();
  210.    hOurWindow = FindTaskWindow(hOurTask, "BCEasyWin");
  211.    SetWindowText(hOurWindow, dummy);
  212.  
  213.    ddelay(0);           // To insure we yield control at least once;
  214.                         // see comments in winutil.c.
  215. #endif
  216.  
  217. } /* banner */
  218.