]>
Commit | Line | Data |
---|---|---|
7ac48069 | 1 | /* $Id$ |
2 | * | |
3 | * Copyright (C) 1988-1998 by the Massachusetts Institute of Technology. | |
4 | * For copying and distribution information, please see the file | |
5 | * <mit-copyright.h>. | |
de56407f | 6 | */ |
de56407f | 7 | |
546bc43b | 8 | #include <mit-copyright.h> |
7ac48069 | 9 | #include <moira.h> |
10 | #include "update_server.h" | |
11 | ||
de56407f | 12 | #include <ctype.h> |
7ac48069 | 13 | #include <stdio.h> |
14 | #include <stdlib.h> | |
7b48c9f9 | 15 | #include <string.h> |
7ac48069 | 16 | |
7ac48069 | 17 | RCSID("$Header$"); |
de56407f | 18 | |
de56407f | 19 | /* |
20 | * | |
21 | * syntax: | |
22 | * >>> (STRING)"xfer_002" filesize checksum pathname | |
23 | * <<< (int)0 | |
24 | * >>> (STRING)data | |
25 | * <<< (int)code | |
26 | * >>> (STRING)data | |
27 | * <<< (int)code | |
28 | * ... | |
29 | * >>> (STRING)data (last data block) | |
30 | * <<< (int)code (from read, write, checksum verify) | |
31 | * | |
32 | * function: | |
33 | * perform initial preparations and receive file as | |
2ad0a777 | 34 | * a single string, storing it into <pathname>.moira_update. |
de56407f | 35 | * |
36 | * still to be done: file locking; perform transfers in pieces instead | |
37 | * of all at once; use checksums | |
38 | */ | |
39 | ||
85330553 | 40 | void xfer_002(int conn, char *str) |
de56407f | 41 | { |
85330553 | 42 | int file_size, checksum, code; |
43 | char *pathname, *p; | |
5eaef520 | 44 | |
45 | str += 8; | |
46 | while (*str == ' ') | |
47 | str++; | |
48 | if (!*str) | |
49 | { | |
de56407f | 50 | failure: |
85330553 | 51 | send_int(conn, MR_ARGS); |
52 | return; | |
de56407f | 53 | } |
85330553 | 54 | |
55 | file_size = strtol(str, &p, 10); | |
56 | if (p == str) | |
57 | { | |
58 | send_int(conn, MR_ARGS); | |
59 | return; | |
60 | } | |
61 | else | |
62 | str = p; | |
5eaef520 | 63 | while (*str == ' ') |
64 | str++; | |
85330553 | 65 | |
66 | checksum = strtol(str, &p, 10); | |
67 | if (p == str) | |
68 | { | |
69 | send_int(conn, MR_ARGS); | |
70 | return; | |
71 | } | |
72 | else | |
73 | str = p; | |
5eaef520 | 74 | while (*str == ' ') |
75 | str++; | |
85330553 | 76 | |
5eaef520 | 77 | if (*str != '/') |
78 | goto failure; | |
79 | pathname = str; | |
85330553 | 80 | |
5eaef520 | 81 | if (!have_authorization) |
82 | { | |
85330553 | 83 | send_int(conn, MR_PERM); |
84 | return; | |
de56407f | 85 | } |
85330553 | 86 | |
87 | send_ok(conn); | |
88 | code = get_file(conn, pathname, file_size, checksum, 0700, 0); | |
5eaef520 | 89 | if (!code) |
85330553 | 90 | com_err(whoami, 0, "Transferred file %s", pathname); |
91 | ||
92 | return; | |
de56407f | 93 | } |