3 * fhopen.c - open level 1 file from an AmigaDOS file handle (SAS/C)
5 * Copyright © 1994 AmiTCP/IP Group,
6 * Network Solutions Development Inc.
17 #include <proto/dos.h>
19 #include <bsdsocket.h>
21 extern int (*__closefunc
)(int);
24 fhopen(long file
, int mode
)
31 * Set up __closefunc (which is used at cleanup)
33 __closefunc
= __close
;
35 * Check for the break signals
41 ufb
= __allocufb(&fd
);
43 return -1; /* errno is set by the __allocufb() */
46 * Translate mode to ufb flags
48 switch (mode
& (O_WRONLY
| O_RDWR
)) {
50 if (mode
& (O_APPEND
| O_CREAT
| O_TRUNC
| O_EXCL
)) {
60 flags
= UFB_RA
| UFB_WA
;
74 ufb
->ufbfh
= (long)file
;
78 if (Dup2Socket(-1, fd
) < 0) /* mark the fd as used in the AmiTCP's dTable */
79 perror("Dup2Socket failed on " __FILE__
);