]> code.citadel.org Git - citadel.git/blobdiff - citadel/file_ops.c
* partialy revert r8246; we're working in units of one here, so the number of units...
[citadel.git] / citadel / file_ops.c
index 2544077bd41b0a50101f6a13c3a02a0457ce255d..ced5a31d568c3fef6f83466c7e51313abfdd4fbc 100644 (file)
@@ -326,7 +326,7 @@ void cmd_oimg(char *cmdbuf)
 
        if (!strcasecmp(filename, "_userpic_")) {
                extract_token(which_user, cmdbuf, 1, '|', sizeof which_user);
-               if (getuser(&usbuf, which_user) != 0) {
+               if (CtdlGetUser(&usbuf, which_user) != 0) {
                        cprintf("%d No such user.\n",
                                ERROR + NO_SUCH_USER);
                        return;
@@ -549,7 +549,7 @@ void cmd_clos(char *cmdbuf)
 /*
  * abort an upload
  */
-void abort_upl(struct CitContext *who)
+void abort_upl(CitContext *who)
 {
        if (who->upload_fp != NULL) {
                fclose(who->upload_fp);
@@ -637,9 +637,15 @@ void cmd_read(char *cmdbuf)
        buf = malloc(bytes + 1);
 
        fseek(CC->download_fp, start_pos, 0);
+
        actual_bytes = fread(buf, 1, bytes, CC->download_fp);
-       cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes);
-       client_write(buf, actual_bytes);
+       if (actual_bytes > 0) {
+               cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes);
+               client_write(buf, bytes);
+       }
+       else {
+               cprintf("%d %s\n", ERROR, strerror(errno));
+       }
        free(buf);
 }
 
@@ -782,18 +788,20 @@ void cmd_nuop(char *cmdbuf)
 
 CTDL_MODULE_INIT(file_ops)
 {
-       CtdlRegisterProtoHook(cmd_delf, "DELF", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_movf, "MOVF", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_open, "OPEN", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_clos, "CLOS", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_uopn, "UOPN", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_ucls, "UCLS", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_read, "READ", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_writ, "WRIT", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_oimg, "OIMG", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_ndop, "NDOP", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_nuop, "NUOP", "Autoconverted. TODO: document me.");
-       CtdlRegisterProtoHook(cmd_uimg, "UIMG", "Autoconverted. TODO: document me.");
+       if (!threading) {
+               CtdlRegisterProtoHook(cmd_delf, "DELF", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_movf, "MOVF", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_open, "OPEN", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_clos, "CLOS", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_uopn, "UOPN", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_ucls, "UCLS", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_read, "READ", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_writ, "WRIT", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_oimg, "OIMG", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_ndop, "NDOP", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_nuop, "NUOP", "Autoconverted. TODO: document me.");
+               CtdlRegisterProtoHook(cmd_uimg, "UIMG", "Autoconverted. TODO: document me.");
+       }
         /* return our Subversion id for the Log */
        return "$Id$";
 }