I'd like to propose a new function in the apr_filepath module, to be
added for 0.9.2 and/or httpd-2.0.45:
/**
* Split a search path defined in an environment variable (e.g., @c $PATH)
* into separate components
* @ingroup apr_filepath
* @param pathelts the returned components of the search path
* @param envvar the name of the environment variable with the search path
* @param p the pool to allocate the array and path components from
* @deffunc apr_status_t apr_filepath_splitenv(apr_array_header_t **pathelts,
const char *envvar, apr_pool_t *p)
* @remark if the environment variable does not exist, the result code will
* be @c APR_ENOENT; other codes are implementation-specific.
*/
APR_DECLARE(apr_status_t) apr_filepath_splitenv(apr_array_header_t **pathelts,
const char *envvar,
apr_pool_t *p);
The apr-iconv module would use this to interpret the APR_ICONV_PATH
variable in a way that's compatible with other functions that accept
paths (e.g., the returned path components would be in UTF-8 on most
Windows variants). For example, the module loading code in
iconv-module.c would look like the following, instead of the apr_strtok
based implementation we have now:
status = apr_filepath_splitenv(&pathelts, "APR_ICONV_PATH", subpool);
if (!status)
{
int i;
char **elts = (char **)pathelts->elts;
for (i = 0; i < pathelts->nelts; ++i)
{
if (iconv_getpathname(buf, elts[i], buffer, subpool) == 0)
{
apr_pool_destroy(subpool);
return APR_SUCCESS;
}
}
}
I have a workinng Windows and Unix implementation, but would like to get
some feedback on the proposed interface before checking in the code.
--
Brane Äibej <[EMAIL PROTECTED]> http://www.xbc.nu/brane/