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