Dbfilemode()

From Recital Documentation Wiki
Jump to: navigation, search

PURPOSE

specify file operation mode


SYNOPSIS

#include "dbl.h"
 
	int	dbfilemode(shared, readonly)
 
	<input parameters>
	int	shared;	/* 1 for shared file access otherwise 0 */
	int	readonly;	/* 1 for readonly file access otherwise 0 */
 
	<output parameters>
	none


RETURN VALUE

The dbfilemode() function returns 0 for success. See the section on return code values for a detailed list of return codes.


DESCRIPTION

The dbfilemode() function is used to determine how files will be opened. The first parameter specifies if the file is to be opened shared or for exclusive use. The second parameter specifies if the file will be opened read-only or with update privilege.

NOTE: when files are opened in a shareable mode, manual locking using library functions must be implemented.


EXAMPLE

The following example opens a database file with shared access and with read/write privilege.

#include "dbl.h"
 
	int	dbf;	/* .DBF file descriptor */
	int	rc;	/* Return code */
 
	rc = dbfilemode(1,0);
	if (rc = = SUCCESS) printf("database opened \n");
		rc = dbopen("accounts.dbf", &dbf);
		if (rc == SUCCESS) printf("database opened \n");
		else {
			printf("error number %d \n", rc);
		}
	}


SEE ALSO

dbiopen(), dblockf(), dblockr(), dblocki(), dbopen(), dbtlockf(), dbtlockr(), dbunlockf(), dbunlocki(), dbunlockr()