Determine the channel name for the currently running program.
const char *mtaChannelGetName(char *channel,
size_t *channel_len,
size_t channel_len_max);
|
|
Arguments |
Description |
|---|---|
|
channel |
A pointer to a buffer to receive the NULL terminated channel name. To avoid possible truncation of the channel name, this buffer must be at least CHANLENGTH+1 bytes long. |
|
channel_len |
An optional pointer to a size_t to receive the length in bytes of the returned channel name. This length does not include the NULL terminator that terminates the channel name. |
|
channel_len_max |
The maximum size in bytes of the buffer pointed at by the channel argument. |
A running program can discover its channel name with this routine. The channel name is typically set using the PMDF_CHANNEL environment variable.
In the event of an error, the routine returns NULL. The error status code is set in mta_errno.
|
Error Status Codes |
Description |
|---|---|
|
MTA_BADARGS |
A NULL value passed for the channel argument. |
|
MTA_NO |
Unable to determine the channel name from the runtime environment. |
|
MTA_STRTRUERR |
Channel buffer too small to receive the channel name. The buffer must be at least CHANLENGTH+1 bytes long. |
The following code fragment uses this routine to print the channel name.
char buf[CHANLENGTH+1];
printf("Channel name: %s\n",
mtaChannelGetName(buf, NULL, sizeof(buf)));
|