]> andersk Git - moira.git/blob - update/xfer_002.c
Solaris changes
[moira.git] / update / xfer_002.c
1 /*
2  *      $Source$
3  *      $Header$
4  */
5 /*  (c) Copyright 1988 by the Massachusetts Institute of Technology. */
6 /*  For copying and distribution information, please see the file */
7 /*  <mit-copyright.h>. */
8
9 #ifndef lint
10 static char *rcsid_xfer_002_c = "$Header$";
11 #endif  lint
12
13 #include <mit-copyright.h>
14 #include <stdio.h>
15 #include <gdb.h>
16 #include <ctype.h>
17 #include <sys/param.h>
18 #include <sys/file.h>
19 #include <strings.h>
20 #include <moira.h>
21
22 extern CONNECTION conn;
23 char buf[BUFSIZ];
24
25 extern int code, errno;
26
27 extern int have_authorization, have_file, done;
28
29 /*
30  *
31  * syntax:
32  * >>> (STRING)"xfer_002" filesize checksum pathname
33  * <<< (int)0
34  * >>> (STRING)data
35  * <<< (int)code
36  * >>> (STRING)data
37  * <<< (int)code
38  * ...
39  * >>> (STRING)data     (last data block)
40  * <<< (int)code        (from read, write, checksum verify)
41  *
42  * function:
43  *      perform initial preparations and receive file as
44  * a single string, storing it into <pathname>.moira_update.
45  *
46  * still to be done: file locking; perform transfers in pieces instead
47  * of all at once; use checksums
48  */
49
50 int
51 xfer_002(str)
52     char *str;
53 {
54     int file_size;
55     int checksum;
56     char *pathname;
57     
58     str += 8;
59     while (*str == ' ')
60         str++;
61     if (!*str) {
62     failure:
63         reject_call(MR_ARGS);
64         return;
65     }
66     file_size = atoi(str);
67     while (isdigit(*str))
68         str++;
69     while (*str == ' ')
70         str++;
71     checksum = atoi(str);
72     while (isdigit(*str))
73         str++;
74     while (*str == ' ')
75         str++;
76     if (*str != '/')
77         goto failure;
78     pathname = str;
79     if (!have_authorization) {
80         reject_call(MR_PERM);
81         return;
82     }
83     if (done)                   /* re-initialize data */
84         initialize();
85     code = send_ok();
86     if (code)
87         lose("sending ok for file xfer (2)");
88     code = get_file(pathname, file_size, checksum, 0700, 0);
89     if (!code) {
90         char buf[BUFSIZ];
91         have_file = 1;
92         strcpy(buf, "transferred file ");
93         strcat(buf, pathname);
94         mr_log_info(buf);
95     }
96     return;
97 }
This page took 0.770448 seconds and 5 git commands to generate.