isc_expand_dpb()
Go Up to API Function Reference
Dynamically builds or expands a database parameter buffer (DPB) to include database parameters.
Syntax
void isc_expand_dpb(
char **dpb,
unsigned short *dpb_size,
. . .);
Parameter | Type | Description |
---|---|---|
|
|
Pointer to an existing DPB |
|
|
Pointer to the current size, in bytes, of the DPB |
|
|
Pointers to items to insert into the expanded DPB |
Description
isc_expand_dpb()
builds or expands a DPB dynamically. Its main use is to simplify the building of the DPB prior to a call to isc_attach_database()
, or to allow an end user to supply a user name and password combination at run time. In many cases, the DPB must be constructed programmatically, but isc_expand_dpb
() enables an application to pass user names, password, message file, and character set parameters to the function, which then adds them to an existing DPB.
A pointer to a previously allocated and initialized DPB must be passed to isc_expand_dpb
() along with a pointer to a variable containing the amount of space used in the DPB when this function is called. The function allocates a new DPB, preserving its current contents, and adds the new parameters.
To ensure proper memory management, applications that call isc_expand_dpb()
should call isc_free() to release the allocated buffer.
Example
The following code calls isc_expand_dpb()
to create a DPB, then attaches to a database using the newly created DPB. user_name
and user_password
are assumed to be variables whose values have been filled in, for example, after asking the user to specify the name and password to be used.
#include <ibase.h> char *dpb; ISC_STATUS status_vector[20]; isc_db_handle handle = NULL; short dpb_length; /* Build the database parameter buffer. */ dpb = (char *) malloc(50); dpb_length = 0; isc_expand_dpb(&dpb, &dpb_length, isc_dpb_user_name, user_name, isc_dpb_password, user_password, NULL); isc_attach_database(status_vector, 0, "employee.db", &handle, dpb_length, dpb_buffer); if (status_vector[0] == 1 && status_vector[1]) { /* An error occurred. */ isc_print_status(status_vector); return(1); }
Return value
None.