]> andersk Git - moira.git/blobdiff - update/xfer_002.c
punt mrgdb
[moira.git] / update / xfer_002.c
index 32562c03d4eaf599a5d441d19cf83fda1ed61f23..df000a0466dfe1e0829675f36280c6651c01d887 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#include <gdb.h>
-
 RCSID("$Header$");
 
-extern CONNECTION conn;
-extern char buf[BUFSIZ];
-
-extern int code;
-
-extern int have_authorization, have_file, done;
-
 /*
  *
  * syntax:
@@ -46,11 +37,10 @@ extern int have_authorization, have_file, done;
  * of all at once; use checksums
  */
 
-int xfer_002(char *str)
+void xfer_002(int conn, char *str)
 {
-  int file_size;
-  int checksum;
-  char *pathname;
+  int file_size, checksum, code;
+  char *pathname, *p;
 
   str += 8;
   while (*str == ' ')
@@ -58,40 +48,46 @@ int xfer_002(char *str)
   if (!*str)
     {
     failure:
-      reject_call(MR_ARGS);
-      return 0;
+      send_int(conn, MR_ARGS);
+      return;
     }
-  file_size = atoi(str);
-  while (isdigit(*str))
-    str++;
+
+  file_size = strtol(str, &p, 10);
+  if (p == str)
+    {
+      send_int(conn, MR_ARGS);
+      return;
+    }
+  else
+    str = p;
   while (*str == ' ')
     str++;
-  checksum = atoi(str);
-  while (isdigit(*str))
-    str++;
+
+  checksum = strtol(str, &p, 10);
+  if (p == str)
+    {
+      send_int(conn, MR_ARGS);
+      return;
+    }
+  else
+    str = p;
   while (*str == ' ')
     str++;
+
   if (*str != '/')
     goto failure;
   pathname = str;
+
   if (!have_authorization)
     {
-      reject_call(MR_PERM);
-      return 0;
+      send_int(conn, MR_PERM);
+      return;
     }
-  if (done)                    /* re-initialize data */
-    initialize();
-  code = send_ok();
-  if (code)
-    lose("sending ok for file xfer (2)");
-  code = get_file(pathname, file_size, checksum, 0700, 0);
+
+  send_ok(conn);
+  code = get_file(conn, pathname, file_size, checksum, 0700, 0);
   if (!code)
-    {
-      char buf[BUFSIZ];
-      have_file = 1;
-      strcpy(buf, "transferred file ");
-      strcat(buf, pathname);
-      mr_log_info(buf);
-    }
-  return 0;
+    com_err(whoami, 0, "Transferred file %s", pathname);
+
+  return;
 }
This page took 0.040385 seconds and 4 git commands to generate.