home *** CD-ROM | disk | FTP | other *** search
- #include <sys/types.h>
- #include <sys/syslimits.h>
- #include <fcntl.h>
- #include "crtlocal.h"
-
- int close(int fd)
- {
- int res = -1;
- short refnum = crt_fd_tab[fd].fd;
- int i;
- mysleep(1);
- if (crt_fd_tab[fd].flags & O_PIPE)
- {
- crt_fd_tab[fd].flags = 0;
- refnum = 0;
- }
- for (i = 0; i < OPEN_MAX; i++)
- if ((i != fd) && (refnum == crt_fd_tab[i].fd)) res = i;
- if ((res == -1) && refnum)
- {
- FCBPBRec pb;
- pb.ioRefNum = refnum;
- pb.ioCompletion = 0;
- pb.ioVRefNum = crt_ioVRefNum;
- PBCloseSync((ParmBlkPtr)&pb);
- res = pb.ioResult;
- }
- else res = refnum;
- crt_fd_tab[fd].fd = 0;
- return res;
- }
-
- void closeall(void)
- {
- int i;
- for (i = 0; i < OPEN_MAX; i++)
- {
- if (crt_fd_tab[i].fd) close(crt_fd_tab[i].fd);
- }
- }
-