--- a/ftp/ftps.c Mon Jan 18 14:10:13 2010 +0530
+++ b/ftp/ftps.c Mon Jan 18 17:21:39 2010 +0530
@@ -6,46 +6,43 @@
readfile_res* retrieve_file_1_svc(request *req, struct svc_req *rqstp)
{
- FILE *file;
- char data[1024];
- int bytes;
- static readfile_res res;
+ FILE *file;
+ filechunk data;
+ static readfile_res res;
- file = fopen(req->name, "r");
+ file = fopen(req->name, "rb");
if (file == NULL) {
- res.errno = errno;
- return (&res);
+ res.errno = errno;
+ return (&res);
}
xdr_free((xdrproc_t)xdr_readfile_res, (char *)&res);
fseek (file, req->start, SEEK_SET);
- bytes = fread(data, 1, MAXLEN, file);
- res.readfile_res_u.chunk.data = data;
- res.readfile_res_u.chunk.bytes = bytes;
+ res.readfile_res_u.chunk.items = fread(res.readfile_res_u.chunk.data, sizeof(int), MAXLEN, file);
- /*
+ /*
* Return the result
*/
res.errno = 0;
fclose(file);
- return (&res);
+ return (&res);
}
int* send_file_1_svc(chunksend *rec, struct svc_req *rqstp)
{
- FILE *file;
- int write_bytes;
+ FILE *file;
+ int write_items;
static int result;
- file = fopen(rec->name, "a");
- if (file == NULL) {
- result = errno;
- return &result;
- }
+ file = fopen(rec->name, "ab");
+ if (file == NULL) {
+ result = errno;
+ return &result;
+ }
- write_bytes = fwrite(rec->data, 1, rec->bytes, file);
- fclose(file);
+ write_items = fwrite(rec->data, sizeof(int), rec->items, file);
+ fclose(file);
result = 0;
return &result;