# ctaFormatEventEx

Formats an event on a specified server into a string for print diagnostics.

#### Prototype

DWORD ctaFormatEventEx ( CTAHD ctahd, char *lineprefix, CTA_EVENT *ctaevt, char *buffer, unsigned size)

Argument | Description
ctahd | Context handle that specifies the server on which commands are executed. ctahd can be a void context handle.
lineprefix | Pointer to a character string that is placed at the beginning of every new line in the formatted event string.
ctaevt | Pointer to an event structure to be formatted. The CTA_EVENT structure is typedef struct { DWORD id; /* Event code and source service ID */ CTAHD ctahd; /* Natural Access context handle */ DWORD timestamp; /* Timestamp */ DWORD userid; /* Userid (defined by ctaCreateContext) */ DWORD size; /* Size of buffer if buffer != NULL */ void *buffer; /* Buffer pointer */ DWORD value; /* Event status or event-specific data */ DWORD objHD; /* Service object handle */ } CTA_EVENT;
buffer | Pointer to the buffer to receive the event string.
size | Size of the buffer in bytes.

#### Return values

Return value | Description
SUCCESS |
CTAERR_BAD_ARGUMENT | buffer is NULL.
CTAERR_BAD_SIZE | size is not big enough to fit the formatted event.
CTAERR_INVALID_CTAHD | Context handle is invalid.
CTAERR_NOT_FOUND | Service to format the event is not found.
CTAERR_NOT_INITIALIZED | Natural Access is not initialized. Call ctaInitialize first.
CTAERR_SVR_COMM | Server communication error.

#### Details

ctaFormatEventEx creates a detailed textual description of the event.

ctahd can be a void context handle. A void context handle refers only to the server on which the commands are executed and not to any real context object. Each server has a unique void context handle. If the void context handle is equal to NULL_CTAHD, it refers to the default server.

Use ctaCreateContext to obtain the void context handle that corresponds to a server.

Note: If you are working with OAM service events, refer to the NMS OAM Service Developer's Reference Manual for information on formatting events.

#### See also

ctaCreateContextEx, ctaGetText

#### Example

void DemoShowEvent( CTA_EVENT *event )
{
char format_buffer[CTA_MAX_FORMAT_SIZE];
char *prefix = "\t\t\t"; /* default demo indent */
CTAHD void_ctahd;
/* Server name descriptor */
char server_desc[] = "host.nmss.com:2244";
/* Create a void context handle */
ctaCreateContext(NULL_CTAQUEUEHD, 0, server_desc, &void_ctahd);
format_buffer[0] = '\0';
ctaFormatEventEx( void_ctahd, prefix, event, format_buffer,
CTA_MAX_FORMAT_SIZE );
printf( "%s", format_buffer );
}