mirror of https://github.com/BOINC/boinc.git
open files in binary mode (for Win)
svn path=/trunk/boinc/; revision=342
This commit is contained in:
parent
80fd46674a
commit
51366510a6
|
@ -84,10 +84,6 @@ bool CLIENT_STATE::handle_running_apps() {
|
|||
// locally, false otherwise
|
||||
//
|
||||
bool CLIENT_STATE::input_files_available(RESULT* rp) {
|
||||
if(rp==NULL) {
|
||||
fprintf(stderr, "error: CLIENT_STATE.input_files_available: unexpected NULL pointer rp\n");
|
||||
return false;
|
||||
}
|
||||
WORKUNIT* wup = rp->wup;
|
||||
FILE_INFO* fip;
|
||||
unsigned int i;
|
||||
|
|
|
@ -206,14 +206,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
|
|||
FILE* f = fopen(SCHED_OP_REQUEST_FILE, "wb");
|
||||
unsigned int i;
|
||||
RESULT* rp;
|
||||
if(p==NULL) {
|
||||
fprintf(stderr, "error: CLIENT_STATE.make_scheduler_request: unexpected NULL pointer p\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
if(work_req<0) {
|
||||
fprintf(stderr, "error: CLIENT_STATE.make_scheduler_request: negative work_req\n");
|
||||
return ERR_NEG;
|
||||
}
|
||||
|
||||
if (!f) return ERR_FOPEN;
|
||||
fprintf(f,
|
||||
"<scheduler_request>\n"
|
||||
|
|
|
@ -45,28 +45,12 @@ FILE_XFER::~FILE_XFER() {
|
|||
#if 0
|
||||
// Is there any reason to keep this around?
|
||||
int FILE_XFER::init_download(char* url, char* outfile) {
|
||||
if(url==NULL) {
|
||||
fprintf(stderr, "error: FILE_XFER.init_download: unexpected NULL pointer url\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
if(outfile==NULL) {
|
||||
fprintf(stderr, "error: FILE_XFER.init_download: unexpected NULL pointer outfile\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
return HTTP_OP::init_get(url, outfile, file_size);
|
||||
}
|
||||
|
||||
// Is there any reason to keep this around?
|
||||
int FILE_XFER::init_upload(char* url, char* infile) {
|
||||
if(url==NULL) {
|
||||
fprintf(stderr, "error: FILE_XFER.init_upload: unexpected NULL pointer url\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
if(outfile==NULL) {
|
||||
fprintf(stderr, "error: FILE_XFER.init_upload: unexpected NULL pointer infile\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
return HTTP_OP::init_put(url, infile);
|
||||
}
|
||||
#endif
|
||||
|
@ -130,9 +114,6 @@ double FILE_XFER::elapsed_time() {
|
|||
// Create a new empty FILE_XFER_SET
|
||||
//
|
||||
FILE_XFER_SET::FILE_XFER_SET(HTTP_OP_SET* p) {
|
||||
if(p==NULL) {
|
||||
fprintf(stderr, "error: FILE_XFER_SET: unexpected NULL pointer p\n");
|
||||
}
|
||||
http_ops = p;
|
||||
}
|
||||
|
||||
|
@ -140,10 +121,7 @@ FILE_XFER_SET::FILE_XFER_SET(HTTP_OP_SET* p) {
|
|||
//
|
||||
int FILE_XFER_SET::insert(FILE_XFER* fxp) {
|
||||
int retval;
|
||||
if(fxp==NULL) {
|
||||
fprintf(stderr, "error: FILE_XFER_SET.insert: unexpected NULL pointer fxp\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
// record start time.
|
||||
// This could be made more accurate by omitting the connection
|
||||
// setup and initial request times.
|
||||
|
@ -159,10 +137,7 @@ int FILE_XFER_SET::insert(FILE_XFER* fxp) {
|
|||
//
|
||||
int FILE_XFER_SET::remove(FILE_XFER* fxp) {
|
||||
vector<FILE_XFER*>::iterator iter;
|
||||
if(fxp==NULL) {
|
||||
fprintf(stderr, "error: FILE_XFER_SET.remove: unexpected NULL pointer fxp\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
http_ops->remove(fxp);
|
||||
|
||||
iter = file_xfers.begin();
|
||||
|
|
|
@ -28,10 +28,7 @@
|
|||
//
|
||||
int HOST_INFO::parse(FILE* in) {
|
||||
char buf[256];
|
||||
if(in==NULL) {
|
||||
fprintf(stderr, "error: HOST_INFO.parse: unexpected NULL pointer in\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
memset(this, 0, sizeof(HOST_INFO));
|
||||
while (fgets(buf, 256, in)) {
|
||||
if (match_tag(buf, "</host_info>")) return 0;
|
||||
|
@ -60,10 +57,6 @@ int HOST_INFO::parse(FILE* in) {
|
|||
// Write the host information, usually to the client state XML file
|
||||
//
|
||||
int HOST_INFO::write(FILE* out) {
|
||||
if(out==NULL) {
|
||||
fprintf(stderr, "error: HOST_INFO.write: unexpected NULL pointer out\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
fprintf(out,
|
||||
"<host_info>\n"
|
||||
" <timezone>%d</timezone>\n"
|
||||
|
|
131
client/http.C
131
client/http.C
|
@ -48,15 +48,7 @@
|
|||
static void parse_url(char* url, char* host, char* file) {
|
||||
char* p;
|
||||
char buf[256];
|
||||
if(url==NULL) {
|
||||
fprintf(stderr, "error: parse_url: unexpected NULL pointer url\n");
|
||||
}
|
||||
if(host==NULL) {
|
||||
fprintf(stderr, "error: parse_url: unexpected NULL pointer host\n");
|
||||
}
|
||||
if(file==NULL) {
|
||||
fprintf(stderr, "error: parse_url: unexpected NULL pointer file\n");
|
||||
}
|
||||
|
||||
if (strncmp(url, "http://", 7) == 0) strcpy(buf, url+7);
|
||||
else strcpy(buf, url);
|
||||
p = strchr(buf, '/');
|
||||
|
@ -75,18 +67,6 @@ static void parse_url(char* url, char* host, char* file) {
|
|||
static void http_get_request_header(
|
||||
char* buf, char* host, char* file, double offset
|
||||
) {
|
||||
if(buf==NULL) {
|
||||
fprintf(stderr, "error: http_get_request_header: unexpected NULL pointer buf\n");
|
||||
}
|
||||
if(host==NULL) {
|
||||
fprintf(stderr, "error: http_get_request_header: unexpected NULL pointer host\n");
|
||||
}
|
||||
if(file==NULL) {
|
||||
fprintf(stderr, "error: http_get_request_header: unexpected NULL pointer file\n");
|
||||
}
|
||||
if(offset<0) {
|
||||
fprintf(stderr, "error: http_get_request_header: negative offset\n");
|
||||
}
|
||||
if (offset) {
|
||||
sprintf(buf,
|
||||
"GET /%s HTTP/1.1\015\012"
|
||||
|
@ -115,15 +95,6 @@ static void http_get_request_header(
|
|||
// Prints an HTTP 1.1 HEAD request header into buf
|
||||
//
|
||||
static void http_head_request_header(char* buf, char* host, char* file) {
|
||||
if(buf==NULL) {
|
||||
fprintf(stderr, "error: http_head_request_header: unexpected NULL pointer buf\n");
|
||||
}
|
||||
if(host==NULL) {
|
||||
fprintf(stderr, "error: http_head_request_header: unexpected NULL pointer host\n");
|
||||
}
|
||||
if(file==NULL) {
|
||||
fprintf(stderr, "error: http_head_request_header: unexpected NULL pointer file\n");
|
||||
}
|
||||
sprintf(buf,
|
||||
"HEAD /%s HTTP/1.1\015\012"
|
||||
"User-Agent: BOINC client\015\012"
|
||||
|
@ -141,18 +112,6 @@ static void http_head_request_header(char* buf, char* host, char* file) {
|
|||
static void http_post_request_header(
|
||||
char* buf, char* host, char* file, int size
|
||||
) {
|
||||
if(buf==NULL) {
|
||||
fprintf(stderr, "error: http_post_request_header: unexpected NULL pointer buf\n");
|
||||
}
|
||||
if(host==NULL) {
|
||||
fprintf(stderr, "error: http_post_request_header: unexpected NULL pointer host\n");
|
||||
}
|
||||
if(file==NULL) {
|
||||
fprintf(stderr, "error: http_post_request_header: unexpected NULL pointer file\n");
|
||||
}
|
||||
if(size<0) {
|
||||
fprintf(stderr, "error: http_post_request_header: negative size\n");
|
||||
}
|
||||
sprintf(buf,
|
||||
"POST /%s HTTP/1.0\015\012"
|
||||
"Pragma: no-cache\015\012"
|
||||
|
@ -172,21 +131,6 @@ static void http_post_request_header(
|
|||
void http_put_request_header(
|
||||
char* buf, char* host, char* file, int size, int offset
|
||||
) {
|
||||
if(buf==NULL) {
|
||||
fprintf(stderr, "error: http_put_request_header: unexpected NULL pointer buf\n");
|
||||
}
|
||||
if(host==NULL) {
|
||||
fprintf(stderr, "error: http_put_request_header: unexpected NULL pointer host\n");
|
||||
}
|
||||
if(file==NULL) {
|
||||
fprintf(stderr, "error: http_put_request_header: unexpected NULL pointer file\n");
|
||||
}
|
||||
if(size<0) {
|
||||
fprintf(stderr, "error: http_put_request_header: negative size\n");
|
||||
}
|
||||
if(offset<0) {
|
||||
fprintf(stderr, "error: http_put_request_header: negative offset\n");
|
||||
}
|
||||
if (offset) {
|
||||
sprintf(buf,
|
||||
"PUT /%s HTTP/1.1\015\012"
|
||||
|
@ -263,18 +207,6 @@ int read_http_reply_header(int socket, HTTP_REPLY_HEADER& header) {
|
|||
//
|
||||
static int read_reply(int socket, char* buf, int len) {
|
||||
int i, n;
|
||||
if(socket<0) {
|
||||
fprintf(stderr, "error: read_reply: negative socket\n");
|
||||
return ERR_NEG;
|
||||
}
|
||||
if(buf==NULL) {
|
||||
fprintf(stderr, "error: read_reply: unexpected NULL pointer buf\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
if(len<0) {
|
||||
fprintf(stderr, "error: read_reply: negative len\n");
|
||||
return ERR_NEG;
|
||||
}
|
||||
for (i=0; i<len-1; i++) {
|
||||
n = recv(socket, buf+i, 1, 0);
|
||||
if (n != 1) break;
|
||||
|
@ -304,10 +236,6 @@ HTTP_OP::~HTTP_OP() {
|
|||
// Initialize HTTP HEAD operation to url
|
||||
//
|
||||
int HTTP_OP::init_head(char* url) {
|
||||
if(url==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP.init_head: unexpected NULL pointer url\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
parse_url(url, hostname, filename);
|
||||
NET_XFER::init(hostname, 80, HTTP_BLOCKSIZE);
|
||||
http_op_type = HTTP_OP_HEAD;
|
||||
|
@ -319,18 +247,6 @@ int HTTP_OP::init_head(char* url) {
|
|||
// Initialize HTTP GET operation to url
|
||||
//
|
||||
int HTTP_OP::init_get(char* url, char* out, bool del_old_file, double off) {
|
||||
if(url==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP.init_get: unexpected NULL pointer url\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
if(out==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP.init_get: unexpected NULL pointer out\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
if(off<0) {
|
||||
fprintf(stderr, "error: HTTP_OP.init_get: negative off\n");
|
||||
return ERR_NEG;
|
||||
}
|
||||
if (del_old_file) {
|
||||
unlink(out);
|
||||
}
|
||||
|
@ -348,18 +264,7 @@ int HTTP_OP::init_get(char* url, char* out, bool del_old_file, double off) {
|
|||
//
|
||||
int HTTP_OP::init_post(char* url, char* in, char* out) {
|
||||
int retval;
|
||||
if(url==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP.init_post: unexpected NULL pointer url\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
if(in==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP.init_post: unexpected NULL pointer in\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
if(out==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP.init_post: unexpected NULL pointer out\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
parse_url(url, hostname, filename);
|
||||
NET_XFER::init(hostname, 80, HTTP_BLOCKSIZE);
|
||||
strcpy(infile, in);
|
||||
|
@ -380,18 +285,7 @@ int HTTP_OP::init_post2(
|
|||
char* url, char* r1, char* in, double offset
|
||||
) {
|
||||
int retval;
|
||||
if(url==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP.init_post2: unexpected NULL pointer url\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
if(r1==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP.init_post2: unexpected NULL pointer r1\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
if(offset<0) {
|
||||
fprintf(stderr, "error: HTTP_OP.init_post2: negative offset\n");
|
||||
return ERR_NEG;
|
||||
}
|
||||
|
||||
parse_url(url, hostname, filename);
|
||||
NET_XFER::init(hostname, 80, HTTP_BLOCKSIZE);
|
||||
req1 = r1;
|
||||
|
@ -438,9 +332,6 @@ bool HTTP_OP::http_op_done() {
|
|||
}
|
||||
|
||||
HTTP_OP_SET::HTTP_OP_SET(NET_XFER_SET* p) {
|
||||
if(p==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP_SET: unexpected NULL pointer p\n");
|
||||
}
|
||||
net_xfers = p;
|
||||
}
|
||||
|
||||
|
@ -448,10 +339,7 @@ HTTP_OP_SET::HTTP_OP_SET(NET_XFER_SET* p) {
|
|||
//
|
||||
int HTTP_OP_SET::insert(HTTP_OP* ho) {
|
||||
int retval;
|
||||
if(ho==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP_SET.insert: unexpected NULL pointer ho\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
retval = net_xfers->insert(ho);
|
||||
if (retval) return retval;
|
||||
http_ops.push_back(ho);
|
||||
|
@ -492,7 +380,7 @@ bool HTTP_OP_SET::poll() {
|
|||
case HTTP_OP_POST:
|
||||
//case HTTP_OP_PUT:
|
||||
htp->http_op_state = HTTP_STATE_REQUEST_BODY;
|
||||
htp->file = fopen(htp->infile, "r");
|
||||
htp->file = fopen(htp->infile, "rb");
|
||||
if (!htp->file) {
|
||||
fprintf(stderr, "HTTP_OP: no input file %s\n", htp->infile);
|
||||
htp->io_done = true;
|
||||
|
@ -522,7 +410,7 @@ bool HTTP_OP_SET::poll() {
|
|||
// If there's a file we also want to send, then start transferring
|
||||
// it, otherwise, go on to the next step
|
||||
if (htp->infile && strlen(htp->infile) > 0) {
|
||||
htp->file = fopen(htp->infile, "r");
|
||||
htp->file = fopen(htp->infile, "rb");
|
||||
if (!htp->file) {
|
||||
fprintf(stderr, "HTTP_OP: no input2 file %s\n", htp->infile);
|
||||
htp->io_done = true;
|
||||
|
@ -601,7 +489,7 @@ bool HTTP_OP_SET::poll() {
|
|||
// Append to a file if it already exists, otherwise
|
||||
// create a new one. init_get should have already
|
||||
// deleted the file if necessary
|
||||
htp->file = fopen(htp->outfile, "a");
|
||||
htp->file = fopen(htp->outfile, "ab");
|
||||
if (!htp->file) {
|
||||
fprintf(stderr,
|
||||
"HTTP_OP: can't open output file %s\n",
|
||||
|
@ -654,10 +542,7 @@ bool HTTP_OP_SET::poll() {
|
|||
//
|
||||
int HTTP_OP_SET::remove(HTTP_OP* p) {
|
||||
vector<HTTP_OP*>::iterator iter;
|
||||
if(p==NULL) {
|
||||
fprintf(stderr, "error: HTTP_OP_SET.remove: unexpected NULL pointer p\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
net_xfers->remove(p);
|
||||
|
||||
iter = http_ops.begin();
|
||||
|
|
|
@ -38,10 +38,7 @@ LOG_FLAGS::LOG_FLAGS() {
|
|||
//
|
||||
int LOG_FLAGS::parse(FILE* in) {
|
||||
char buf[256];
|
||||
if(in==NULL) {
|
||||
fprintf(stderr, "error: LOG_FLAGS.parse: unexpected NULL pointer in\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
fgets(buf, 256, in);
|
||||
if (!match_tag(buf, "<log_flags>")) return ERR_XML_PARSE;
|
||||
while (fgets(buf, 256, in)) {
|
||||
|
|
|
@ -71,10 +71,6 @@ void NET_STATS::update(bool is_upload, double nbytes, double nsecs) {
|
|||
// Write XML based network statistics
|
||||
//
|
||||
int NET_STATS::write(FILE* out, bool to_server) {
|
||||
if(out==NULL) {
|
||||
fprintf(stderr, "error: NET_STATS.write: unexpected NULL pointer out\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
fprintf(out,
|
||||
"<net_stats>\n"
|
||||
" <bwup>%f</bwup>\n"
|
||||
|
@ -97,10 +93,7 @@ int NET_STATS::write(FILE* out, bool to_server) {
|
|||
//
|
||||
int NET_STATS::parse(FILE* in) {
|
||||
char buf[256];
|
||||
if(in==NULL) {
|
||||
fprintf(stderr, "error: NET_STATS.parse: unexpected NULL pointer in\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
memset(this, 0, sizeof(NET_STATS));
|
||||
while (fgets(buf, 256, in)) {
|
||||
if (match_tag(buf, "</net_stats>")) return 0;
|
||||
|
|
|
@ -228,10 +228,7 @@ bool PERS_FILE_XFER::poll(unsigned int now) {
|
|||
//
|
||||
int PERS_FILE_XFER::parse(FILE* fin) {
|
||||
char buf[256];
|
||||
if(fin==NULL) {
|
||||
fprintf(stderr, "error: PERS_FILE_XFER_SET.parse: unexpected NULL pointer fin\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
while (fgets(buf, 256, fin)) {
|
||||
if (match_tag(buf, "</persistent_file_xfer>")) return 0;
|
||||
else if (parse_int(buf, "<num_retries>", nretry)) continue;
|
||||
|
@ -245,10 +242,6 @@ int PERS_FILE_XFER::parse(FILE* fin) {
|
|||
// Write XML information about a particular persistent file transfer
|
||||
//
|
||||
int PERS_FILE_XFER::write(FILE* fout) {
|
||||
if (fout==NULL) {
|
||||
fprintf(stderr, "error: PERS_FILE_XFER_SET.write: unexpected NULL pointer fout\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
fprintf(fout,
|
||||
" <persistent_file_xfer>\n"
|
||||
" <num_retries>%d</num_retries>\n"
|
||||
|
@ -261,9 +254,6 @@ int PERS_FILE_XFER::write(FILE* fout) {
|
|||
}
|
||||
|
||||
PERS_FILE_XFER_SET::PERS_FILE_XFER_SET(FILE_XFER_SET* p) {
|
||||
if(p==NULL) {
|
||||
fprintf(stderr, "error: PERS_FILE_XFER_SET: unexpected NULL pointer p\n");
|
||||
}
|
||||
file_xfers = p;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,10 +106,7 @@ int TIME_STATS::write(FILE* out, bool to_server) {
|
|||
//
|
||||
int TIME_STATS::parse(FILE* in) {
|
||||
char buf[256];
|
||||
if(in==NULL) {
|
||||
fprintf(stderr, "error: TIME_STATS.parse: unexpected NULL pointer in\n");
|
||||
return ERR_NULL;
|
||||
}
|
||||
|
||||
while (fgets(buf, 256, in)) {
|
||||
if (match_tag(buf, "</time_stats>")) return 0;
|
||||
else if (parse_int(buf, "<last_update>", last_update)) continue;
|
||||
|
|
Loading…
Reference in New Issue