You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by jo...@apache.org on 2005/04/15 17:22:50 UTC
svn commit: r161485 - httpd/httpd/trunk/support/ab.c
Author: jorton
Date: Fri Apr 15 08:22:50 2005
New Revision: 161485
URL: http://svn.apache.org/viewcvs?view=rev&rev=161485
Log:
* support/ab.c (open_postfile): Use apr_file_read_full, tidy up error
messages, remove redundant variable.s
Modified:
httpd/httpd/trunk/support/ab.c
Modified: httpd/httpd/trunk/support/ab.c
URL: http://svn.apache.org/viewcvs/httpd/httpd/trunk/support/ab.c?view=diff&r1=161484&r2=161485
==============================================================================
--- httpd/httpd/trunk/support/ab.c (original)
+++ httpd/httpd/trunk/support/ab.c Fri Apr 15 08:22:50 2005
@@ -1928,39 +1928,30 @@
static int open_postfile(const char *pfile)
{
- apr_file_t *postfd = NULL;
+ apr_file_t *postfd;
apr_finfo_t finfo;
- apr_fileperms_t mode = APR_OS_DEFAULT;
- apr_size_t length;
apr_status_t rv;
char errmsg[120];
- rv = apr_file_open(&postfd, pfile, APR_READ, mode, cntxt);
+ rv = apr_file_open(&postfd, pfile, APR_READ, APR_OS_DEFAULT, cntxt);
if (rv != APR_SUCCESS) {
- printf("Invalid postfile name (%s): %s\n", pfile,
- apr_strerror(rv, errmsg, sizeof errmsg));
+ fprintf(stderr, "ab: Could not open POST data file (%s): %s\n", pfile,
+ apr_strerror(rv, errmsg, sizeof errmsg));
return rv;
}
apr_file_info_get(&finfo, APR_FINFO_NORM, postfd);
postlen = (apr_size_t)finfo.size;
- postdata = (char *) malloc(postlen);
+ postdata = malloc(postlen);
if (!postdata) {
- printf("Can\'t alloc postfile buffer\n");
+ fprintf(stderr, "ab: Could not allocate POST data buffer\n");
return APR_ENOMEM;
}
- length = postlen;
- rv = apr_file_read(postfd, postdata, &length);
+ rv = apr_file_read_full(postfd, postdata, postlen, NULL);
if (rv != APR_SUCCESS) {
- printf("error reading postfile: %s\n",
- apr_strerror(rv, errmsg, sizeof errmsg));
+ fprintf(stderr, "ab: Could not read POST data file: %s\n",
+ apr_strerror(rv, errmsg, sizeof errmsg));
return rv;
- }
- if (length != postlen) {
- printf("error reading postfile: read only %"
- APR_SIZE_T_FMT " bytes",
- length);
- return APR_EINVAL;
}
apr_file_close(postfd);
return 0;