From a0c85e329c448a16fccceaa70e215c8d61561d8a Mon Sep 17 00:00:00 2001 From: trawick Date: Thu, 29 Nov 2001 01:21:37 +0000 Subject: get the xml test program to build on systems without sys_nerr/sys_errlist (or systems like AIX which have them but don't provide declarations) there is still a bit of errno wonkiness due to the use of tmpnam() git-svn-id: http://svn.apache.org/repos/asf/apr/apr-util/trunk@58465 13f79535-47bb-0310-9956-ffa450edef68 --- test/testxml.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'test/testxml.c') diff --git a/test/testxml.c b/test/testxml.c index 68ea5cc4..82e66dee 100644 --- a/test/testxml.c +++ b/test/testxml.c @@ -90,7 +90,7 @@ static apr_status_t create_dummy_file_error(apr_pool_t *p, apr_file_t **fd) errno = ENOENT; } perror("tmpnam"); - return APR_EGENERAL; + return APR_ENOENT; } rv = apr_file_open(fd, tmpfile, APR_CREATE|APR_TRUNCATE|APR_DELONCLOSE| APR_READ|APR_WRITE|APR_EXCL, APR_OS_DEFAULT, p); @@ -130,7 +130,7 @@ static apr_status_t create_dummy_file(apr_pool_t *p, apr_file_t **fd) errno = ENOENT; } perror("tmpnam"); - return APR_EGENERAL; + return APR_ENOENT; } rv = apr_file_open(fd, tmpfile, APR_CREATE|APR_TRUNCATE|APR_DELONCLOSE| APR_READ|APR_WRITE|APR_EXCL, APR_OS_DEFAULT, p); @@ -181,13 +181,16 @@ static void dump_xml(apr_xml_elem *e, int level) } } -static void oops(const char *s1, const char *s2) +static void oops(const char *s1, const char *s2, apr_status_t rv) { if (progname) fprintf(stderr, "%s: ", progname); fprintf(stderr, s1, s2); - if (errno > 0 && errno < sys_nerr) - fprintf(stderr, " (%s)", sys_errlist[errno]); + if (rv != APR_SUCCESS) { + char buf[120]; + + fprintf(stderr, " (%s)", apr_strerror(rv, buf, sizeof buf)); + } fprintf(stderr, "\n"); exit(1); } @@ -208,18 +211,18 @@ int main(int argc, const char *const * argv) if (argc == 1) { rv = create_dummy_file(pool, &fd); if (rv != APR_SUCCESS) { - oops("cannot create dummy file", "oops"); + oops("cannot create dummy file", "oops", rv); } } else { if (argc == 2) { rv = apr_file_open(&fd, argv[1], APR_READ, APR_OS_DEFAULT, pool); if (rv != APR_SUCCESS) { - oops("cannot open: %s", argv[1]); + oops("cannot open: %s", argv[1], rv); } } else { - oops("usage: %s", usage); + oops("usage: %s", usage, 0); } } rv = apr_xml_parse_file(pool, &parser, &doc, fd, 2000); @@ -234,7 +237,7 @@ int main(int argc, const char *const * argv) if (argc == 1) { rv = create_dummy_file_error(pool, &fd); if (rv != APR_SUCCESS) { - oops("cannot create error dummy file", "oops"); + oops("cannot create error dummy file", "oops", rv); } rv = apr_xml_parse_file(pool, &parser, &doc, fd, 2000); if (rv != APR_SUCCESS) { -- cgit v1.2.1