]> andersk Git - moira.git/blame - update/xfer_002.c
Initial revision
[moira.git] / update / xfer_002.c
CommitLineData
de56407f 1/*
2 * $Source$
3 * $Header$
4 */
5
6#ifndef lint
7static 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 "smsu_int.h"
16#include "kludge.h"
17#include <strings.h>
18
19extern CONNECTION conn;
20char buf[BUFSIZ];
21
22extern int code, errno;
23
24extern 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
47int
48xfer_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(SMSU_BAD_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(SMSU_NO_AUTH);
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.055667 seconds and 5 git commands to generate.