]> andersk Git - moira.git/blob - update/xfer_003.c
second code style cleanup: void/void * usage, proper #includes. try to
[moira.git] / update / xfer_003.c
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>.
6  */
7
8 #include <mit-copyright.h>
9 #include <moira.h>
10 #include "update_server.h"
11
12 #include <ctype.h>
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16
17 #include <gdb.h>
18
19 RCSID("$Header$");
20
21 extern CONNECTION conn;
22 extern char buf[BUFSIZ];
23
24 extern int code;
25
26 extern int have_authorization, have_file, done;
27
28 /*
29  *
30  * syntax:
31  * >>> (STRING)"xfer_003" filesize checksum pathname
32  * <<< (int)0
33  * >>> (STRING)data
34  * <<< (int)code
35  * >>> (STRING)data
36  * <<< (int)code
37  * ...
38  * >>> (STRING)data     (last data block)
39  * <<< (int)code        (from read, write, checksum verify)
40  *
41  * function:
42  *      perform initial preparations and receive file as
43  * a single string, storing it into <pathname>.moira_update.
44  * this version of transfer encrypts the file being transferred.
45  */
46
47 int xfer_003(char *str)
48 {
49   int file_size;
50   int checksum;
51   char *pathname;
52
53   str += 8;
54   while (*str == ' ')
55     str++;
56   if (!*str)
57     {
58     failure:
59       reject_call(MR_ARGS);
60       return 0;
61     }
62   file_size = atoi(str);
63   while (isdigit(*str))
64     str++;
65   while (*str == ' ')
66     str++;
67   checksum = atoi(str);
68   while (isdigit(*str))
69     str++;
70   while (*str == ' ')
71     str++;
72   if (*str != '/')
73     goto failure;
74   pathname = str;
75   if (!have_authorization)
76     {
77       reject_call(MR_PERM);
78       return 0;
79     }
80   if (done)                     /* re-initialize data */
81     initialize();
82   code = send_ok();
83   if (code)
84     lose("sending ok for file xfer (2)");
85   code = get_file(pathname, file_size, checksum, 0444, 1);
86   if (!code)
87     {
88       char buf[BUFSIZ];
89       have_file = 1;
90       strcpy(buf, "transferred file ");
91       strcat(buf, pathname);
92       mr_log_info(buf);
93     }
94   return 0;
95 }
This page took 0.043512 seconds and 5 git commands to generate.