home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a016 / 1.ddi / C / SWAPDEMO.C < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-15  |  2.3 KB  |  96 lines

  1. /*
  2.  *  Blinker 2.0 Swap demo
  3.  *
  4.  *          C version
  5.  *
  6.  *  Copyright (c) Blink inc, 1992
  7.  *
  8.  *
  9.  *  cl -AL -c swapdemo.c ;
  10.  *
  11.  */
  12.  
  13. #include "blinker.h"
  14.  
  15. #define TRUE    1
  16. #define FALSE   0
  17.  
  18. void yesno(int) ;
  19.  
  20. void main()
  21. {
  22.  int status ;
  23.  
  24.  printf("--------------------------------------------\n");
  25.  printf("C Swap function Example\n");
  26.  printf("=======================\n");
  27.  printf("\n");
  28.  
  29.  printf("Default settings:\n\n");
  30.  printf("Use EMS                        : "); yesno(SWPUSEEMS(FALSE));
  31.  printf("Use XMS                        : "); yesno(SWPUSEXMS(FALSE));
  32.  printf("Use UMB                        : "); yesno(SWPUSEUMB(FALSE));
  33.  printf("Save/restore video mode        : "); yesno(SWPVIDMDE(FALSE));
  34.  printf("Save/restore directory         : "); yesno(SWPCURDIR(FALSE));
  35.  printf("Prevent reboots                : "); yesno(SWPNOBOOT(FALSE));
  36.  printf("Wait for keypress              : "); yesno(SWPGETKEY(FALSE));
  37.  printf("Display message                : "); yesno(SWPDISMSG(FALSE));
  38.  printf("Program already running        : "); yesno(SWPGETPID("test.c"));
  39.  printf("\n");
  40.  
  41.  /* enable use of EMS / XMS / UMBs */
  42.  
  43.  SWPUSEEMS(TRUE);
  44.  SWPUSEXMS(TRUE);
  45.  SWPUSEUMB(TRUE);
  46.  
  47.  /* save / restore current directory */
  48.  
  49.  SWPCURDIR(TRUE);
  50.  
  51.  
  52.  if (SWPGETPID("test.c"))
  53.     {
  54.      printf("Terminating with code 255 (previous 'swapdemo.c' already running)\n");
  55.      printf("Type (EXIT) to return to previous 'swapdemo.c'\n");
  56.      exit(255);
  57.     }
  58.  else
  59.     {
  60.  
  61.      /* Set a program ID */
  62.  
  63.      printf("Set program ID to 'test.c'     : "); yesno(SWPSETPID("test.c"));
  64.      printf("\n\n");
  65.  
  66.      printf("Shelling to DOS...(EXIT to return)\n\n");
  67.      printf("** Now run this program again to see SWPGETPID() **\n");
  68.  
  69.      status = SWPRUNCMD("",0,"","");
  70.  
  71.      printf("Back from shell - status is    : %d\n",status);
  72.      printf("Major error code               : %d\n",SWPERRMAJ());
  73.      printf("Minor error code               : %d\n",SWPERRMIN());
  74.  
  75.      printf("Child return code              : %d\n\n",SWPERRLEV());
  76.  
  77.      printf("End of test.\n");
  78.      printf("--------------------------------------------\n");
  79.      exit(47);
  80.     }
  81. }
  82.  
  83. void yesno(flag)
  84. int flag;
  85. {
  86.   if (flag)
  87.   {
  88.     printf("Yes\n");
  89.   }
  90.   else
  91.   {
  92.     printf("No \n");
  93.   }
  94. }
  95.  
  96.