home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BSRC_250.LZH / DOSFUNCS.C < prev    next >
Text File  |  1991-09-15  |  9KB  |  328 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*                This module was written by Vince Perriello                */
  14. /*                   OS/2 code contributed by Bill Andrus                   */
  15. /*                                                                          */
  16. /*             DOS and OS/2 kernel routines used by BinkleyTerm             */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50.  
  51. #ifndef OS_2 /* Here's the DOS stuff */
  52.  
  53. void dostime (int *hour, int *min, int *sec, int *hdths)
  54. {
  55.    union REGS r;
  56.  
  57.    r.h.ah = 0x2c;
  58.  
  59.    (void) intdos (&r, &r);
  60.  
  61.    *hour  = r.h.ch;
  62.    *min   = r.h.cl;
  63.    *sec   = r.h.dh;
  64.    *hdths = r.h.dl;
  65. }
  66.  
  67. void dos_break_off (void)
  68. {
  69.    union REGS r;
  70.  
  71.    r.x.ax = 0x3301;
  72.    r.h.dl = 0x00;
  73.  
  74.    (void) intdos (&r, &r);
  75. }
  76.  
  77.  
  78. void mtask_find ()
  79. {
  80.    char *p, *q;
  81.  
  82.    for (;;)
  83.       {
  84.       if (have_ml)
  85.          {
  86.          if ((have_ml = ml_active ()) != 0)
  87.             {
  88.             p = "MultiLink";
  89.             mtask_idle = ml_pause;
  90.             break;
  91.             }
  92.          }
  93.  
  94.       if (have_tv)
  95.          {
  96.          if ((have_tv = tv_get_version ()) != 0)
  97.             {
  98.             p = "T-View";
  99.             mtask_idle = tv_pause;
  100.             break;
  101.             }
  102.          }
  103.  
  104.       if ((have_dv = dv_get_version ()) != 0)
  105.          {
  106.          p = "DESQview";
  107.          mtask_idle = dv_pause;
  108.          break;
  109.          }
  110.  
  111.       if ((have_mos = mos_active ()) != 0)
  112.          {
  113.        p = "PC-MOS";
  114.          mtask_idle = mos_pause;
  115.          break;
  116.          }
  117.  
  118.       if ((have_ddos = ddos_active ()) != 0)
  119.          {
  120.          p = "DoubleDOS";
  121.          mtask_idle = ddos_pause;
  122.          break;
  123.          }
  124.  
  125.       if ((have_windows = windows_active ()) != 0)
  126.          {
  127.          p = "MSWindows";
  128.          if (winslice)
  129.             mtask_idle = windows_pause;
  130.          else
  131.             mtask_idle = msdos_pause;
  132.          break;
  133.          }
  134.   /* else */
  135.          {
  136.          p = "None";
  137.          mtask_idle = msdos_pause;
  138.          break;
  139.          }
  140.     }
  141.  
  142.    if ((q = calloc (1, 1 + strlen (p))) == NULL)
  143.       exit (254);
  144.  
  145.    (void) strcpy (mtask_name = q, p);
  146. }
  147.  
  148. void set_prior (int pclass)
  149. {
  150.     happy_compiler = pclass;  /* This makes compilers happy! */
  151.     return;
  152. }
  153.  
  154. #else /* in other words, here's the OS/2 stuff */
  155. #ifdef Snoop
  156. #include "snserver.h"
  157. HSNOOP hsnoop=(HSNOOP)NULL;
  158. #endif
  159.  
  160. void dostime(int *hour, int *min, int *sec, int *hdths)
  161. {
  162.     DATETIME dt;
  163.  
  164.     DosGetDateTime(&dt);
  165.     *hour      = dt.hours;                        /* current hour */
  166.     *min       = dt.minutes;                      /* current minute */
  167.     *sec       = dt.seconds;                      /* current second */
  168.     *hdths     = dt.hundredths;                   /* current hundredths of a second */
  169. }
  170.  
  171. void dos_break_off (void)
  172. {
  173.  /*
  174.   * The problem which dos_break_off was trying to address
  175.   * was a funny with computers like the Sanyo and the DEC
  176.   * Rainbow, where ^C checking in DOS would screw up the
  177.   * FOSSIL's ability to get keystrokes. So while we could
  178.   * emulate the functionality of the DOS side, there is no
  179.   * need to do so. So we won't.
  180.   */
  181. }
  182.  
  183. void _cdecl os2_pause ()
  184. {
  185.    DosSleep (1L);
  186. }
  187.  
  188. void mtask_find ()
  189. {
  190.    char *p, *q;
  191.  
  192.    if (_osmode == DOS_MODE)
  193.        p = "None";
  194.    else
  195.        p = "OS/2";
  196.    mtask_idle = os2_pause;
  197.  
  198.    if ((q = calloc (1, 1 + strlen (p))) == NULL)
  199.       exit (254);
  200.  
  201.    (void) strcpy (mtask_name = q, p);
  202. }
  203.  
  204. void WRITE_ANSI (char c)
  205. {
  206.    static char s[] = {'\0', '\0'};
  207.  
  208.    *s = c;
  209.  
  210.    (void) VioWrtTTY (s, 1, (HVIO) 0L);
  211. }
  212.  
  213. void set_prior (int pclass)
  214. {
  215.   char *s;
  216.   static USHORT regular = 0;
  217.   static USHORT janus = 0;
  218.   static USHORT modem = 0;
  219.   USHORT priority;
  220.  
  221.   switch (pclass)
  222.     {
  223.     case 2:
  224.       if (regular)
  225.          priority = regular;
  226.       else
  227.          {
  228.          s = getenv("REGULARPRIORITY");
  229.          if (s)
  230.           priority = regular = atoi(s);
  231.          else
  232.           priority = regular = 2;
  233.          }
  234.        break;
  235.  
  236.     case 3:
  237.       if (janus)
  238.          priority = janus;
  239.       else
  240.          {
  241.          s = getenv("JANUSPRIORITY");
  242.          if (s)
  243.           priority = janus = atoi(s);
  244.          else
  245.           priority = janus = 3;
  246.          }
  247.        break;
  248.  
  249.     case 4:
  250.       if (modem)
  251.          priority = modem;
  252.       else
  253.          {
  254.          s = getenv("MODEMPRIORITY");
  255.          if (s)
  256.           priority = modem = atoi(s);
  257.          else
  258.           priority = modem = 4;
  259.          }
  260.       break;
  261.  
  262.     default:
  263.       priority = 2;
  264.       break;
  265.     }
  266.  
  267.    (void) DosSetPrty ((USHORT) 1, priority, (SHORT) 31, (USHORT) 0);
  268. }
  269.  
  270. #ifdef Snoop
  271. #pragma check_stack(off)
  272. static int far pascal _loadds mesgfunc(int error, char far *mesg)
  273. {
  274.   if(!error)
  275.     status_line(":%Fs", mesg);
  276.   else
  277.     status_line("!SYS%04u : %Fs", error, mesg);
  278.   return(0);
  279. }
  280. #pragma check_stack()
  281.  
  282. void snoop_open(char *callpipename)
  283. {
  284.    static char *pipe = NULL;
  285.    if(pipe != NULL)
  286.       free(pipe);
  287. /* if((*callpipename != '\0') && (callpipename != NULL) && (hsnoop == (HSNOOP)NULL)) */
  288.       pipe = strdup(callpipename);
  289.    SnoopOpen(pipe, &hsnoop, xfer_id, (PFNSN)mesgfunc);
  290. }
  291.  
  292. void snoop_close(void)
  293. {
  294.   if(hsnoop != (HSNOOP)NULL)
  295.      SnoopClose(hsnoop);
  296.   hsnoop = (HSNOOP)NULL;
  297. }
  298. #endif /* Snoop */
  299. #endif /* OS_2 */
  300.  
  301. #ifdef NEED_CPUTS
  302. int _cdecl cputs (const char *str)
  303. {
  304.     printf ("%s", str);
  305.     return 0;
  306. }
  307. #endif
  308.  
  309. #ifdef NEED_PUTCH
  310. int _cdecl putch (int ch)
  311. {
  312.     return putchar (ch);
  313. }
  314. #endif
  315.  
  316. #ifdef NEED_CPRINTF
  317. int _cdecl cprintf (const char *format, ...)
  318. {
  319.     va_list arg_ptr;
  320.  
  321.     va_start (arg_ptr, format);
  322.     return vprintf (format, arg_ptr);
  323. }
  324. #endif
  325.  
  326.  
  327. 
  328.