]> andersk Git - moira.git/blobdiff - update/send_file.c
Initial revision
[moira.git] / update / send_file.c
index da007b602b5c0e39f007745c736c651a3ff6b160..2c4932cfca8c76890744b7ca81a1ab5c4045dc8f 100644 (file)
@@ -2,16 +2,20 @@
  *     $Source$
  *     $Header$
  */
+/*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
+/*  For copying and distribution information, please see the file */
+/*  <mit-copyright.h>. */
 
 #ifndef lint
 static char *rcsid_send_file_c = "$Header$";
 #endif lint
 
+#include <mit-copyright.h>
 #include <stdio.h>
 #include <com_err.h>
 #include <gdb.h>
 #include <dcm.h>
-#include <sms.h>
+#include <moira.h>
 #include <sys/file.h>
 #include <sys/stat.h>
 #include <update.h>
@@ -53,12 +57,12 @@ char *target_path;
     fd = open(pathname, O_RDONLY, 0);
     if (fd < 0) {
        com_err(whoami, errno, "unable to open %s for read", pathname);
-       return(SMS_OCONFIG);
+       return(MR_OCONFIG);
     }
     if (fstat(fd, &statb)) {
        com_err(whoami, errno, "unable to stat %s", pathname);
        close(fd);
-       return(SMS_OCONFIG);
+       return(MR_OCONFIG);
     }
     n_to_send = statb.st_size;
     
@@ -94,6 +98,7 @@ char *target_path;
        close(fd);
        return(n);
     }
+
     while (n_to_send > 0) {
 #ifdef DEBUG
        printf("n_to_send = %d\n", n_to_send);
@@ -102,7 +107,7 @@ char *target_path;
        if (n < 0) {
            com_err(whoami, errno, " reading %s for transmission", pathname);
            close(fd);
-           return(SMS_ABORTED);
+           return(MR_ABORTED);
        }
        MAX_STRING_SIZE(data) = n;
        code = send_object(conn, (char *)&data, STRING_T);
@@ -128,6 +133,22 @@ char *target_path;
            return(n);
        }
     }
+    if (statb.st_size == 0) {
+       code = receive_object(conn, (char *)&n, INTEGER_T);
+       if (code) {
+           com_err(whoami, connection_errno(conn),
+                   " awaiting ACK remote server after transmission of %s",
+                   pathname);
+           close(fd);
+           return(code);
+       }
+       if (n) {
+           com_err(whoami, n, " from remote server after transmission of %s",
+                   pathname);
+           close(fd);
+           return(n);
+       }
+    }
     close(fd);
-    return(SMS_SUCCESS);
+    return(MR_SUCCESS);
 }
This page took 0.148197 seconds and 4 git commands to generate.