summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorstoddard <stoddard@13f79535-47bb-0310-9956-ffa450edef68>2004-08-24 01:43:34 +0000
committerstoddard <stoddard@13f79535-47bb-0310-9956-ffa450edef68>2004-08-24 01:43:34 +0000
commit302f35948231ab849d238df27982731d89dee6b0 (patch)
tree41231039bfd67b8f0dbfcf4c1fcca390c257c28f
parentfc431b5c9db72b6221c3cdd43ba8bc1d2037e2f5 (diff)
downloadlibapr-302f35948231ab849d238df27982731d89dee6b0.tar.gz
Win32: Implement apr_procattr_child_errfn_set()and apr_procattr_error_check_set() on Windows
git-svn-id: http://svn.apache.org/repos/asf/apr/apr/trunk@65307 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--include/arch/win32/apr_arch_threadproc.h2
-rw-r--r--threadproc/win32/proc.c40
2 files changed, 40 insertions, 2 deletions
diff --git a/include/arch/win32/apr_arch_threadproc.h b/include/arch/win32/apr_arch_threadproc.h
index 6e8ac8d54..f752fd7df 100644
--- a/include/arch/win32/apr_arch_threadproc.h
+++ b/include/arch/win32/apr_arch_threadproc.h
@@ -54,6 +54,8 @@ struct apr_procattr_t {
char *currdir;
apr_int32_t cmdtype;
apr_int32_t detached;
+ apr_child_errfn_t *errfn;
+ apr_int32_t errchk;
};
struct apr_thread_once_t {
diff --git a/threadproc/win32/proc.c b/threadproc/win32/proc.c
index e7c21c105..191d682d4 100644
--- a/threadproc/win32/proc.c
+++ b/threadproc/win32/proc.c
@@ -245,14 +245,14 @@ static char *apr_caret_escape_args(apr_pool_t *p, const char *str)
APR_DECLARE(apr_status_t) apr_procattr_child_errfn_set(apr_procattr_t *attr,
apr_child_errfn_t *errfn)
{
- /* won't ever be called on this platform, so don't save the function pointer */
+ attr->errfn = errfn;
return APR_SUCCESS;
}
APR_DECLARE(apr_status_t) apr_procattr_error_check_set(apr_procattr_t *attr,
apr_int32_t chk)
{
- /* won't ever be used on this platform, so don't save the flag */
+ attr->errchk = chk;
return APR_SUCCESS;
}
@@ -311,6 +311,12 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
char *fullpath = NULL;
if ((rv = apr_filepath_merge(&fullpath, attr->currdir, progname,
APR_FILEPATH_NATIVE, pool)) != APR_SUCCESS) {
+ if (attr->errfn) {
+ attr->errfn(pool, rv,
+ apr_pstrcat(pool, "filepath_merge failed.",
+ " currdir: ", attr->currdir,
+ " progname: ", progname, NULL));
+ }
return rv;
}
progname = fullpath;
@@ -352,6 +358,9 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
if (attr->cmdtype == APR_SHELLCMD || attr->cmdtype == APR_SHELLCMD_ENV) {
char *shellcmd = getenv("COMSPEC");
if (!shellcmd) {
+ if (attr->errfn) {
+ attr->errfn(pool, APR_EINVAL, "COMSPEC envar is not set");
+ }
return APR_EINVAL;
}
if (shellcmd[0] == '"') {
@@ -388,6 +397,9 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
{
char *shellcmd = getenv("COMSPEC");
if (!shellcmd) {
+ if (attr->errfn) {
+ attr->errfn(pool, APR_EINVAL, "COMSPEC envar is not set");
+ }
return APR_EINVAL;
}
if (shellcmd[0] == '"') {
@@ -479,6 +491,12 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
if ((rv = apr_conv_utf8_to_ucs2(env[i], &in,
pNext, &iEnvBlockLen))
!= APR_SUCCESS) {
+ if (attr->errfn) {
+ attr->errfn(pool, rv,
+ apr_pstrcat(pool,
+ "utf8 to ucs2 conversion failed"
+ " on this string: ", env[i], NULL));
+ }
return rv;
}
pNext = wcschr(pNext, L'\0') + 1;
@@ -525,6 +543,12 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
wprg = apr_palloc(pool, nwprg * sizeof(wprg[0]));
if ((rv = apr_conv_utf8_to_ucs2(progname, &nprg, wprg, &nwprg))
!= APR_SUCCESS) {
+ if (attr->errfn) {
+ attr->errfn(pool, rv,
+ apr_pstrcat(pool,
+ "utf8 to ucs2 conversion failed"
+ " on progname: ", progname, NULL));
+ }
return rv;
}
}
@@ -535,6 +559,12 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
wcmd = apr_palloc(pool, nwcmd * sizeof(wcmd[0]));
if ((rv = apr_conv_utf8_to_ucs2(cmdline, &ncmd, wcmd, &nwcmd))
!= APR_SUCCESS) {
+ if (attr->errfn) {
+ attr->errfn(pool, rv,
+ apr_pstrcat(pool,
+ "utf8 to ucs2 conversion failed"
+ " on cmdline: ", cmdline, NULL));
+ }
return rv;
}
}
@@ -547,6 +577,12 @@ APR_DECLARE(apr_status_t) apr_proc_create(apr_proc_t *new,
if ((rv = apr_conv_utf8_to_ucs2(attr->currdir, &ncwd,
wcwd, &nwcwd))
!= APR_SUCCESS) {
+ if (attr->errfn) {
+ attr->errfn(pool, rv,
+ apr_pstrcat(pool,
+ "utf8 to ucs2 conversion failed"
+ " on currdir: ", attr->currdir, NULL));
+ }
return rv;
}
}