OSF DCE Application Development Guide--Introduction and Style Guide

A Sample Application
/* Build the full pathname string for the db_acl database... */
acl_path_string = malloc(MAX_ACL_PATH_SIZE);
strcpy((char *)acl_path_string, (char *)db_acl_path);
strcat((char *)acl_path_string, (char *)"/");
strncat((char *)acl_path_string, "db_acl", strlen("db_acl"));
/* Find out if the database already exists... */
if (access((char *)acl_path_string, R_OK) != 0)
if (errno == ENOENT)
need_init = 1;
/********************************************************************/
/* Create the indexed-by-UUID databases. There are two of these: */
/* One for the ACL UUID-indexed store, and */
/* One for the Object UUID-indexed store... */
dbflags = db_c_index_by_uuid;
/* If the thing doesn’t exist yet, then we need to do some init- */
/* ialization... */
if (need_init)
dbflags |= db_c_create;
/* Open (or create) the "db_acl" ACL UUID-indexed backing store. */
/* Note that no header type is specified among the dbflags, so the */
/* database will be created with no header-- that’s the default... */
DCE_SVC_DEBUG((smp_svc_handle, smp_s_server, svc_c_debug4,
"Calling dce_db_open()"));
dce_db_open(
(char *)acl_path_string, /* Filename of backing store. */
NULL, /* Backing store "backend type" default == hash. */
dbflags, /* We already specified index by UUID for this. */
(dce_db_convert_func_t)dce_rdacl_convert, /* Serialization */
/* function (generated by IDL). */
db_acl, /* The returned backing store handle. */
status);
if (*status != error_status_ok)
{
print_server_error("dce_db_open()", *status);
free(acl_path_string);
return;
}
/* Set the global variable that records whether we actually have */
/* opened the databases; this enables us to avoid calling the */
/* dce_db_close() routine for unopened databases, which will cause */
/* a core dump... */
databases_open = TRUE;
124246 Tandem Computers Incorporated A 43