home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD2.mdf / c / library / os2 / remind / src / os2func.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-11-05  |  3.1 KB  |  149 lines

  1. /***************************************************************/
  2. /*                                                             */
  3. /*  OS2FUNC.C                                                  */
  4. /*                                                             */
  5. /*  Functions to support OS/2.                                 */
  6. /*                                                             */
  7. /*  This file is part of REMIND.                               */
  8. /*                                                             */
  9. /*  This file is Copyright (C) 1993 by Russ Herman.            */
  10. /*  REMIND is Copyright (C) 1993 by David F. Skoll.            */
  11. /*                                                             */
  12. /***************************************************************/
  13. #ifdef OS2_POPUP
  14. #define INCL_VIO
  15. #define INCL_KBD
  16. #endif
  17.  
  18. #ifdef _MSC_VER
  19. #define INCL_DOSPROCESS
  20. #endif
  21.  
  22. #if defined(OS2_POPUP) || defined(_MSC_VER)
  23. #include <os2.h>
  24. #endif
  25.  
  26. #ifdef OS2_POPUP
  27. #include <stdio.h>
  28. #include <stdlib.h>
  29. #include <string.h>
  30. #ifdef OS2DBG
  31. #include <dos.h>
  32. #include <stdlib.h>
  33. #endif
  34. #include "config.h"
  35. #include "globals.h"
  36. #include "types.h"
  37. #include "protos.h"
  38.  
  39. #ifdef _MSC_VER
  40. typedef USHORT APIRET;
  41. #endif
  42.  
  43. static APIRET apiret = 0;
  44. static KBDKEYINFO kbci;
  45. static char *pszPressAny = "\r\nPress any key to continue";
  46. static USHORT pflags = VP_WAIT;  /* | VP_TRANSPARENT; */
  47. static HKBD hkbd = 0;
  48. static char VioSubstBuffer[SHELLSIZE + 1];
  49.  
  50. void StartPopUp()
  51. {
  52.   if (OS2MODE)
  53.     if (!(DebugFlag & DB_ECHO_LINE))
  54.        VioPopUp(&pflags, 0);
  55. }
  56.  
  57. void EndPopUp()
  58. {
  59.     if (DebugFlag & DB_ECHO_LINE)
  60.     return;
  61.     if (OS2MODE) {
  62.       VioWrtTTY(pszPressAny, strlen(pszPressAny), 0);
  63.       KbdCharIn(&kbci, IO_WAIT, hkbd);
  64.       VioEndPopUp(0);
  65.     }
  66. }
  67.  
  68. int PutsPopUp(char *s)
  69. {
  70.     char c, *os = VioSubstBuffer;
  71.  
  72.     if (DebugFlag & DB_ECHO_LINE)
  73.     printf("%s", s);
  74.     else {
  75.     do {
  76.         /* Convert \n to \r\n in auxiliary buffer for VIO */
  77.         if ((c= *s++) == '\n')
  78.         *os++ = '\r';
  79.         *os++ = c;
  80.     } while (c > 0);
  81.     VioWrtTTY(VioSubstBuffer, strlen(VioSubstBuffer), 0);
  82.     }
  83.     return(0);
  84. }
  85.  
  86. int PutlPopUp(char *s)
  87. {
  88.     StartPopUp();
  89.     PutsPopUp(s);
  90.     if (DebugFlag & DB_ECHO_LINE)
  91.     fputc('\n', stdout);
  92.     else
  93.     VioWrtTTY("\r\n", 2, 0);
  94.     EndPopUp();
  95.     return(0);
  96. }
  97.  
  98.  
  99. int PutcPopUp(int c)
  100. {
  101.     char *s = " ";
  102.  
  103.     if (DebugFlag & DB_ECHO_LINE)
  104.     fputc(c, stdout);
  105.     else {
  106.     switch (c) {
  107.     case '\n':
  108.         VioWrtTTY("\r\n", 2, 0);
  109.         break;
  110.     default:
  111.         s[0] = c;
  112.         VioWrtTTY(s, 1, 0);
  113.         break;
  114.     }
  115.     }
  116.     return(0);
  117. }
  118.  
  119. #ifdef OS2DBG
  120. #define DB_ECHO_LINE 16
  121. int DebugFlag = 0;
  122. void main(/* int argc, char **argv */)
  123. {
  124.     int ret;
  125.  
  126.     ret = os2fputs("Test VIO PopUp Writing");
  127.     if (ret)
  128.     fprintf(stderr, "Test VIO PopUP Writing returned %d %ld",
  129.         ret, apiret);
  130.     exit(ret);
  131. }
  132. #endif
  133. #endif
  134.  
  135. #ifdef _MSC_VER
  136. unsigned sleep(unsigned sec)
  137. {
  138.   return DosSleep(sec * 1000L);
  139. }
  140. #endif
  141.  
  142. #ifndef __EMX__ 
  143. int fork()
  144. {
  145.     return(-1);
  146. }
  147. #endif
  148.  
  149.