]> code.citadel.org Git - citadel.git/blobdiff - citadel/file_ops.c
* file_ops.c: cmd_read() now returns a short read at end-of-file instead of
[citadel.git] / citadel / file_ops.c
index 664a62ff33868a847c0c4cfb14ed738daae02aca..a6ce2f82a931832a7a1929276246d46c56a2c0f2 100644 (file)
@@ -665,7 +665,7 @@ void cmd_ucls(char *cmd)
                        "NEW UPLOAD: '%s'\n %s\n",
                        CC->upl_file, CC->upl_comment);
                quickie_message(CC->curr_user, NULL, CC->quickroom.QRname,
-                               upload_notice);
+                               upload_notice, 0, NULL);
        } else {
                abort_upl(CC);
                cprintf("%d File '%s' aborted.\n", CIT_OK, CC->upl_path);
@@ -680,7 +680,8 @@ void cmd_ucls(char *cmd)
 void cmd_read(char *cmdbuf)
 {
        long start_pos;
-       int bytes;
+       size_t bytes;
+       size_t actual_bytes;
        char buf[4096];
 
        start_pos = extract_long(cmdbuf, 0);
@@ -692,16 +693,12 @@ void cmd_read(char *cmdbuf)
                return;
        }
 
-       if (bytes > 4096) {
-               cprintf("%d You may not read more than 4096 bytes.\n",
-                       ERROR);
-               return;
-       }
+       if (bytes > 4096) bytes = 4096;
 
        fseek(CC->download_fp, start_pos, 0);
-       fread(buf, bytes, 1, CC->download_fp);
-       cprintf("%d %d\n", BINARY_FOLLOWS, bytes);
-       client_write(buf, bytes);
+       actual_bytes = fread(buf, 1, bytes, CC->download_fp);
+       cprintf("%d %d\n", BINARY_FOLLOWS, actual_bytes);
+       client_write(buf, actual_bytes);
 }