Sun Java System Messaging Server 6 2005Q4 MTA Developer's Reference


Return an option’s value as a string.


int mtaOptionString(mta_opt_t  *opt_ctx,
                    const char *name,
                    size_t      len,
                    const char *str,
                    size_t     *str_len,
                    size_t      str_len_max);





An option context created by mtaOptionStart(). A NULL value is permitted for this argument. When a NULL is passed, then no option value is returned.


Name of the option to obtain the value for. The length of this string should not exceed ALFA_SIZE bytes. This string must be NULL terminated if a value of zero is passed for len.


Length in bytes, not including any NULL terminator, of the option name supplied with name. If a value of zero is supplied, then the option name string must be NULL terminated. 


A pointer to a buffer to receive the NULL terminated value of the specified option. The MTA allows channel options to have a maximum length of BIGALFA_SIZE bytes. As a result, this buffer should in general have a length of at least BIGALFA_SIZE+1 bytes. If the option was not specified in the option file, then the contents of the buffer is left untouched.


An optional pointer to a size_t to receive the length in bytes of the returned option value string, str. A value of NULL may be passed for this call argument.


The maximum size in bytes of the buffer pointed at by str.


Use mtaOptionString() to retrieve the string representation of an option’s value. If the option is specified in the option file, then its value and length will be returned via the str and str_len call arguments. If the option is not specified then no value is returned and the memory pointed at by str and str_len are left unchanged. This routine can be called with a NULL value for the opt_ctx argument. When this is done, mtaOptionString() immediately returns with a status code of zero and no option value is returned.

Return Values

Return Values  



Normal, successful completion. 


Supplied buffer pointed at by buf is too small. The returned value has been truncated to fit. Truncated value is NULL terminated. The buffer should have a length of at least BIGALFA_SIZE+1 bytes.


The supplied option name is too long. Its length must not exceed ALFA_SIZE bytes.


In the code example that follows, the value of an option named mail_url is retrieved. Before calling mtaOptionString(), a default value is set for the variable to receive the value of the option. If the option was not specified, then the variable will retain that default setting. If the option was specified, then the variable will assume the value set by that specification.

char url[1024];

strcpy(url, "");
mtaOptionString(opt, "mail_url", 0, url, NULL, sizeof(url));