Defines messages in a flat (unformatted) file or memory block.
DWORD vceDefineMessages ( VCEHD vh, VCE_SEGMENT *segments[], unsigned msgcount)
|
Argument |
Description |
|
vh |
Handle of an open voice object. |
|
segments |
Pointer to an array of VCE_SEGMENT structures. Each element defines the corresponding message number. The VCE_SEGMENT structure is: typedef struct Refer to the Details section for a description of these fields. |
|
msgcount |
Number of elements in the segments array. |
|
Return value |
Description |
|
SUCCESS |
|
|
CTAERR_BAD_ARGUMENT |
segments is NULL or msgcount is zero (0). |
|
CTAERR_INVALID_HANDLE |
vh is not a valid handle to an open voice object. |
|
CTAERR_SVR_COMM |
Server communication error. |
|
VCEERR_INVALID_MESSAGE |
Messages overlap or extend beyond the end of the file or memory block. |
vceDefineMessages defines multiple messages in the file or memory block that vh specified. This function tells the Voice Message service how the file or memory is partitioned.
The VCE_SEGMENT structure contains the following fields:
|
Field |
Description |
|
offset |
Starting offset in bytes from the beginning of the file or memory block. |
|
size |
Number of bytes in the message. |
To skip a message number, set both offset and size to zero (0) in the element of the segments array that the message number indexed.
Messages must not overlap one another or extend beyond the size of the file or memory block.
vceCreateMemory, vceOpenFile, vceOpenMemory
/*
* Open a file that contains a simple header, then assign message numbers to
* segments of the file.
*
* Assume the file's header structure is:
* unsigned count = number of messages
* unsigned encoding = voice encoding of all messages
* VCE_SEGMENT msg[count] = array of "count" structures
* containing offset and size
*/
extern CTAHD CtaHd;
void myOpen (char *filename, VCEHD *returnedvh)
{
FILE *filep;
unsigned msgcount;
unsigned encoding;
VCE_SEGMENT *segments;
VCEHD vh;
/* Read the count, allocate a buffer, read the msg list */
filep = fopen (filename, "rb");
fread (&msgcount, sizeof msgcount, 1, filep);
fread (&encoding, sizeof encoding, 1, filep);
segments = malloc (msgcount * sizeof (VCE_SEGMENT));
fread (segments, sizeof (VCE_SEGMENT), msgcount, filep);
fclose (filep);
/* Re-open the file with VCE and define the messages */
vceOpenFile (CtaHd, filename, VCE_FILETYPE_FLAT, VCE_PLAY_ONLY,
encoding, &vh);
vceDefineMessages (vh, segments, msgcount);
*returnedvh = vh;
}