home *** CD-ROM | disk | FTP | other *** search
- /**
- *
- * Name flopen -- Open a file
- *
- * Synopsis ercode = flopen(pfile,phandle,mode);
- *
- * int ercode Returned DOS error code
- * char *pfile File path name
- * int *phandle File handle associated with the file
- * int mode Mode value: includes access rights,
- * sharing mode, and inheritance flag.
- *
- * Description This function opens a file with the specified file path
- * name and returns a file handle with which the file may
- * be accessed.
- *
- * The file is opened as specified in mode. This mode
- * value is a combination of the access code, the sharing
- * mode, and the inheritance flag. The values for the
- * access code are as follows:
- *
- * RDONLY (0) - Open for reading only
- * WRTONLY (1) - Open for writing only
- * RDWRT (2) - Open for reading and writing.
- *
- * The values for the sharing mode limit the ways in which
- * the file may be opened by other processes:
- *
- * COMPATIBILITY ( 0) - DOS 2.x style
- * DENY_RW (16) - Exclusive
- * DENY_WRITE (32) - Cannot be opened for writing
- * DENY_READ (48) - Cannot be opened for reading
- * DENY_NONE (64) - No restrictions
- *
- * The values for the inheritance flag are as follows:
- *
- * INHERIT ( 0) - DOS 2.x style (file handle is
- * inherited by child programs)
- * NO_INHERIT (128) - File handle is private to this
- * program.
- *
- * Note that DOS 2.x requires the COMPATIBILITY and INHERIT
- * attributes.
- *
- * Returns ercode DOS function error code
- * *phandle Associated file handle. If an error is
- * encountered, -1 is returned.
- *
- * Version 3.0 (C)Copyright Blaise Computing Inc. 1983, 1984, 1986
- *
- **/
-
- #include <bfile.h>
-
- int flopen(pfile,phandle,access)
- char *pfile;
- int *phandle,access;
- {
- DOSREG dos_reg;
- int ercode;
- ADS file_ads;
-
- dos_reg.ax = utbyword(0x3d,access);
- utabsptr(pfile,&file_ads);
- dos_reg.ds = file_ads.s;
- dos_reg.dx = file_ads.r;
-
- ercode = dos(&dos_reg);
- if (ercode == 0)
- *phandle = dos_reg.ax;
- else
- *phandle = -1;
-
- return(ercode);
- }