summaryrefslogtreecommitdiff
path: root/reference/C/CONTRIB/SNIP/fndislot.c
blob: 29995960f635301726a8f6d9f4a04e9a004b92fa (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
**  Originally published as part of the MicroFirm Function Library
**
**  Copyright 1990, Robert B.Stout
**
**  Subset version released to the public domain, 1992
**
**  Function to locate an unused user interrupt vector.
*/

#ifdef __ZTC__
 #include <int.h>
#else
 #include <dos.h>
 #ifdef __TURBOC__
  #define GETVECT getvect
  #define FAR far
  #define INTERRUPT interrupt
 #else /* assume MSC */
  #define GETVECT _dos_getvect
  #define FAR _far
  #define INTERRUPT _interrupt
 #endif
 #define FNULL (void (FAR *)())(0L)
#endif

unsigned findIslot(void)
{
#ifdef __ZTC__
      unsigned int_no, seg, ofs;

      for (int_no = 0x60; int_no < 0x6f; ++int_no)
      {
            int_getvector(int_no, &seg, &ofs);
            if (0U == (seg | ofs))
                  return int_no;
      }
#else /* MSC/BC/TC */
      unsigned int_no;

      for (int_no = 0x60; int_no < 0x6f; ++int_no)
      {
            if (FNULL != (void (FAR *)())GETVECT(int_no))
                  return int_no;
      }
#endif
      return 0;
}