]> andersk Git - moira.git/blame - update/xfer_002.c
Code style cleanup. (No functional changes)
[moira.git] / update / xfer_002.c
CommitLineData
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
10static char *rcsid_xfer_002_c = "$Header$";
7da203a3 11#endif
de56407f 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>
7b48c9f9 19#include <string.h>
2ad0a777 20#include <moira.h>
de56407f 21
22extern CONNECTION conn;
7da203a3 23extern char buf[BUFSIZ];
de56407f 24
25extern int code, errno;
26
27extern 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
5eaef520 50int xfer_002(char *str)
de56407f 51{
5eaef520 52 int file_size;
53 int checksum;
54 char *pathname;
55
56 str += 8;
57 while (*str == ' ')
58 str++;
59 if (!*str)
60 {
de56407f 61 failure:
5eaef520 62 reject_call(MR_ARGS);
63 return 0;
de56407f 64 }
5eaef520 65 file_size = atoi(str);
66 while (isdigit(*str))
67 str++;
68 while (*str == ' ')
69 str++;
70 checksum = atoi(str);
71 while (isdigit(*str))
72 str++;
73 while (*str == ' ')
74 str++;
75 if (*str != '/')
76 goto failure;
77 pathname = str;
78 if (!have_authorization)
79 {
80 reject_call(MR_PERM);
81 return 0;
de56407f 82 }
5eaef520 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 {
91 char buf[BUFSIZ];
92 have_file = 1;
93 strcpy(buf, "transferred file ");
94 strcat(buf, pathname);
95 mr_log_info(buf);
de56407f 96 }
5eaef520 97 return 0;
de56407f 98}
This page took 0.091383 seconds and 5 git commands to generate.