]> andersk Git - moira.git/blobdiff - update/xfer_003.c
Command line printer manipulation client, and build goo.
[moira.git] / update / xfer_003.c
index 56b3815a518f5b6e72c78020c0f0f34328251b50..5205460655fa0a8bb7be0b85b8229e95ee374d0a 100644 (file)
@@ -1,31 +1,20 @@
-/*
- *     $Source$
- *     $Header$
- */
-/*  (c) Copyright 1988, 1992 by the Massachusetts Institute of Technology.
- *  For copying and distribution information, please see the file
- *  <mit-copyright.h>.
+/* $Id$
+ *
+ * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology.
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_xfer_002_c = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <stdio.h>
-#include <gdb.h>
-#include <ctype.h>
-#include <sys/param.h>
-#include <sys/file.h>
-#include <strings.h>
 #include <moira.h>
+#include "update_server.h"
 
-extern CONNECTION conn;
-char buf[BUFSIZ];
-
-extern int code, errno;
+#include <ctype.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
-extern int have_authorization, have_file, done;
+RCSID("$Header$");
 
 /*
  *
@@ -46,51 +35,57 @@ extern int have_authorization, have_file, done;
  * this version of transfer encrypts the file being transferred.
  */
 
-int
-xfer_003(str)
-    char *str;
+void xfer_003(int conn, char *str)
 {
-    int file_size;
-    int checksum;
-    char *pathname;
-    
-    str += 8;
-    while (*str == ' ')
-       str++;
-    if (!*str) {
+  int file_size, checksum, code;
+  char *pathname, *p;
+
+  str += 8;
+  while (*str == ' ')
+    str++;
+  if (!*str)
+    {
     failure:
-       reject_call(MR_ARGS);
-       return(0);
+      send_int(conn, MR_ARGS);
+      return;
+    }
+
+  file_size = strtol(str, &p, 10);
+  if (p == str)
+    {
+      send_int(conn, MR_ARGS);
+      return;
     }
-    file_size = atoi(str);
-    while (isdigit(*str))
-       str++;
-    while (*str == ' ')
-       str++;
-    checksum = atoi(str);
-    while (isdigit(*str))
-       str++;
-    while (*str == ' ')
-       str++;
-    if (*str != '/')
-       goto failure;
-    pathname = str;
-    if (!have_authorization) {
-       reject_call(MR_PERM);
-       return(0);
+  else
+    str = p;
+  while (*str == ' ')
+    str++;
+
+  checksum = strtol(str, &p, 10);
+  if (p == str)
+    {
+      send_int(conn, MR_ARGS);
+      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, 0444, 1);
-    if (!code) {
-       char buf[BUFSIZ];
-       have_file = 1;
-       strcpy(buf, "transferred file ");
-       strcat(buf, pathname);
-       mr_log_info(buf);
+  else
+    str = p;
+  while (*str == ' ')
+    str++;
+
+  if (*str != '/')
+    goto failure;
+  pathname = str;
+
+  if (!have_authorization)
+    {
+      send_int(conn, MR_PERM);
+      return;
     }
-    return(0);
+
+  send_ok(conn);
+  code = get_file(conn, pathname, file_size, checksum, 0444, 1);
+  if (!code)
+    com_err(whoami, 0, "Transferred file %s", pathname);
+
+  return;
 }
This page took 0.036808 seconds and 4 git commands to generate.