]>
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_inst_001_c = "$Header$"; | |
11 | #endif lint | |
12 | ||
546bc43b | 13 | #include <mit-copyright.h> |
de56407f | 14 | #include <stdio.h> |
891a3c85 | 15 | #include <errno.h> |
16 | #include <ctype.h> | |
dd2e131e | 17 | #include <gdb.h> |
891a3c85 | 18 | #include <moira.h> |
de56407f | 19 | |
20 | STRING instructions = { 0, 0 }; | |
21 | extern CONNECTION conn; | |
891a3c85 | 22 | extern int have_instructions, have_authorization; |
de56407f | 23 | extern int code; |
891a3c85 | 24 | extern char *whoami; |
25 | ||
de56407f | 26 | |
27 | /* | |
28 | * instruction sequence transmission: | |
29 | * syntax: | |
30 | * >>> (STRING) "inst_001" | |
31 | * <<< (int)0 | |
32 | * >>> (STRING) instructions | |
33 | * <<< (int)0 | |
34 | */ | |
35 | ||
36 | inst_001(str) | |
37 | char *str; | |
38 | { | |
891a3c85 | 39 | int file_size; |
40 | int checksum; | |
41 | char *pathname; | |
42 | ||
43 | if (config_lookup("noinstructions")) { | |
44 | code = EPERM; | |
45 | code = send_object(conn, (char *)&code, INTEGER_T); | |
46 | com_err(whoami, EPERM, "Not allowed to receive instructions"); | |
47 | return; | |
48 | } | |
49 | ||
50 | str += 8; | |
51 | while (*str == ' ') | |
52 | str++; | |
53 | if (!*str) { | |
54 | failure: | |
55 | reject_call(MR_ARGS); | |
56 | return; | |
57 | } | |
58 | file_size = atoi(str); | |
59 | while (isdigit(*str)) | |
60 | str++; | |
61 | while (*str == ' ') | |
62 | str++; | |
63 | checksum = atoi(str); | |
64 | while (isdigit(*str)) | |
65 | str++; | |
66 | while (*str == ' ') | |
67 | str++; | |
68 | if (*str != '/') | |
69 | goto failure; | |
70 | pathname = str; | |
71 | if (!have_authorization) { | |
72 | reject_call(MR_PERM); | |
73 | return; | |
74 | } | |
75 | code = send_ok(); | |
76 | if (code) | |
77 | lose("sending ok for file xfer (2)"); | |
dcf02d2f | 78 | code = get_file(pathname, file_size, checksum, 0555, 0); |
891a3c85 | 79 | if (!code) { |
80 | char buf[BUFSIZ]; | |
81 | have_instructions = 1; | |
82 | strcpy(buf, "transferred file "); | |
83 | strcat(buf, pathname); | |
84 | mr_log_info(buf); | |
85 | } | |
dd2e131e | 86 | #ifdef DEBUG |
891a3c85 | 87 | printf("got instructions: %s\n", STRING_DATA(instructions)); |
dd2e131e | 88 | #endif |
de56407f | 89 | } |