]> andersk Git - moira.git/blob - update/xfer_002.c
updated include files & error codes
[moira.git] / update / xfer_002.c
1 /*
2  *      $Source$
3  *      $Header$
4  */
5
6 #ifndef lint
7 static char *rcsid_xfer_002_c = "$Header$";
8 #endif  lint
9
10 #include <stdio.h>
11 #include <gdb.h>
12 #include <ctype.h>
13 #include <sys/param.h>
14 #include <sys/file.h>
15 #include <strings.h>
16 #include <sms.h>
17 #include "kludge.h"
18
19 extern CONNECTION conn;
20 char buf[BUFSIZ];
21
22 extern int code, errno;
23
24 extern int have_authorization, have_file, done;
25
26 /*
27  *
28  * syntax:
29  * >>> (STRING)"xfer_002" filesize checksum pathname
30  * <<< (int)0
31  * >>> (STRING)data
32  * <<< (int)code
33  * >>> (STRING)data
34  * <<< (int)code
35  * ...
36  * >>> (STRING)data     (last data block)
37  * <<< (int)code        (from read, write, checksum verify)
38  *
39  * function:
40  *      perform initial preparations and receive file as
41  * a single string, storing it into <pathname>.sms_update.
42  *
43  * still to be done: file locking; perform transfers in pieces instead
44  * of all at once; use checksums
45  */
46
47 int
48 xfer_002(str)
49     char *str;
50 {
51     int file_size;
52     int checksum;
53     char *pathname;
54     
55     str += 8;
56     while (*str == ' ')
57         str++;
58     if (!*str) {
59     failure:
60         reject_call(SMS_ARGS);
61         return;
62     }
63     file_size = atoi(str);
64     while (isdigit(*str))
65         str++;
66     while (*str == ' ')
67         str++;
68     checksum = atoi(str);
69     while (isdigit(*str))
70         str++;
71     while (*str == ' ')
72         str++;
73     if (*str != '/')
74         goto failure;
75     pathname = str;
76     if (!have_authorization) {
77         reject_call(SMS_PERM);
78         return;
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);
86     if (!code) {
87         char buf[BUFSIZ];
88         have_file = 1;
89         strcpy(buf, "transferred file ");
90         strcat(buf, pathname);
91         sms_log_info(buf);
92     }
93     return;
94 }
This page took 0.046517 seconds and 5 git commands to generate.