]>
Commit | Line | Data |
---|---|---|
de56407f | 1 | /* |
2 | * $Source$ | |
3 | * $Header$ | |
4 | */ | |
546bc43b | 5 | /* (c) Copyright 1988 by the Massachusetts Institute of Technology. */ |
6 | /* For copying and distribution information, please see the file */ | |
7 | /* <mit-copyright.h>. */ | |
de56407f | 8 | |
9 | #ifndef lint | |
10 | static char *rcsid_xfer_002_c = "$Header$"; | |
11 | #endif lint | |
12 | ||
546bc43b | 13 | #include <mit-copyright.h> |
de56407f | 14 | #include <stdio.h> |
328656ff | 15 | #include <gdb.h> |
de56407f | 16 | #include <ctype.h> |
17 | #include <sys/param.h> | |
18 | #include <sys/file.h> | |
de56407f | 19 | #include <strings.h> |
2ad0a777 | 20 | #include <moira.h> |
de56407f | 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 | |
2ad0a777 | 44 | * a single string, storing it into <pathname>.moira_update. |
de56407f | 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: | |
2ad0a777 | 63 | reject_call(MR_ARGS); |
f416d13d | 64 | return(0); |
de56407f | 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) { | |
2ad0a777 | 80 | reject_call(MR_PERM); |
f416d13d | 81 | return(0); |
de56407f | 82 | } |
83 | if (done) /* re-initialize data */ | |
84 | initialize(); | |
85 | code = send_ok(); | |
86 | if (code) | |
87 | lose("sending ok for file xfer (2)"); | |
cc23a8c9 | 88 | code = get_file(pathname, file_size, checksum, 0700, 0); |
de56407f | 89 | if (!code) { |
90 | char buf[BUFSIZ]; | |
91 | have_file = 1; | |
92 | strcpy(buf, "transferred file "); | |
93 | strcat(buf, pathname); | |
2ad0a777 | 94 | mr_log_info(buf); |
de56407f | 95 | } |
f416d13d | 96 | return(0); |
de56407f | 97 | } |