Difference between revisions of "Dbfilemode()"

From Recital Documentation Wiki
Jump to: navigation, search
 
Line 11: Line 11:
  
 
<input parameters>
 
<input parameters>
int shared; /* 1 for shared file access otherwise 0 */
+
int shared; /* 1 for shared file access otherwise 0 */
int readonly; /* 1 for readonly file access otherwise 0 */
+
int readonly; /* 1 for readonly file access otherwise 0 */
  
 
<output parameters>
 
<output parameters>
Line 39: Line 39:
 
#include "dbl.h"
 
#include "dbl.h"
  
int dbf; /* .DBF file descriptor */
+
int dbf; /* .DBF file descriptor */
int rc; /* Return code */
+
int rc; /* Return code */
  
 
rc = dbfilemode(1,0);
 
rc = dbfilemode(1,0);
if (rc = = SUCCESS) printf("database opened n");
+
if (rc = = SUCCESS) printf("database opened \n");
 
rc = dbopen("accounts.dbf", &dbf);
 
rc = dbopen("accounts.dbf", &dbf);
if (rc = = SUCCESS) printf("database opened n");
+
if (rc = = SUCCESS) printf("database opened \n");
 
else {
 
else {
printf("error number %d n", rc);
+
printf("error number %d \n", rc);
 
}
 
}
 
}
 
}

Revision as of 16:07, 3 April 2009

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()