home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / iutil / markopen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-18  |  1.5 KB  |  100 lines

  1. # include    <useful.h>
  2. # include    <stdio.h>
  3. # include    <opsys.h>
  4. # include    <sccs.h>
  5.  
  6. SCCSID(@(#)markopen.c    8.2    1/6/85)
  7.  
  8. /*
  9. **  MARKOPEN -- mark all open files
  10. **
  11. **    Marked files will not be closed later.
  12. **
  13. **    Parameters:
  14. **        ovect -- pointer to bitmap of open files.
  15. **
  16. **    Returns:
  17. **        none
  18. **
  19. **    Side Effects:
  20. **        Sets *ovect to represent the open files.
  21. */
  22.  
  23. long    CmOfiles;    /* default set of files, used all over */
  24.  
  25. markopen(ovect)
  26. register long    *ovect;
  27. {
  28.     register int    i;
  29.     register int    j;
  30.     extern int    errno;
  31.     struct stat    sbuf;
  32.  
  33.     if (ovect == NULL)
  34.         ovect = &CmOfiles;
  35.  
  36.     *ovect = 0;
  37.     for (i = 0; i < NOFILE; i++)
  38.     {
  39.         if (fstat(i, &sbuf) >= 0)
  40.             *ovect |= 1 << i;
  41.     }
  42.     errno = 0;
  43. }
  44. /*
  45. **  CLOSEALL -- close all open files (except marked files)
  46. **
  47. **    Parameters:
  48. **        tell -- if set, report files that are open and should
  49. **            not have been.
  50. **        ovect -- vector of files to leave open.
  51. **
  52. **    Returns:
  53. **        none
  54. **
  55. **    Side Effects:
  56. **        none
  57. **
  58. **    Trace Flags:
  59. **        none
  60. */
  61.  
  62. closeall(tell, ovect)
  63. register int    tell;
  64. register long    ovect;
  65. {
  66.     register int    i;
  67.  
  68.     ovect |= CmOfiles;
  69.  
  70.     for (i = 0; i < NOFILE; i++)
  71.     {
  72.         if (!bitset(1 << i, ovect))
  73.             if (close(i) >= 0 && tell)
  74.                 lprintf("File %d open\n", i);
  75.     }
  76. }
  77.  
  78. /*
  79. **    ADDMARKOPEN -- mark individial file descriptors as open
  80. **
  81. **    Marked descriptors will not be closed
  82. **
  83. **    Parameters:
  84. **        long    pvect    pointer to file descriptor vector
  85. **        int    fd    descriptor to mark
  86. **
  87. **    Returns:
  88. **        nothing
  89. **
  90. **    Side effects:
  91. **        none
  92. */
  93.  
  94. addmarkopen(pvect, fd)
  95. register long    *pvect;
  96. int        fd;
  97. {
  98.     *pvect |= 1 << fd;
  99. }
  100.