]> andersk Git - moira.git/blame - update/xfer_002.c
correct library name
[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$";
11#endif lint
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>
de56407f 19#include <strings.h>
328656ff 20#include <sms.h>
de56407f 21
22extern CONNECTION conn;
23char buf[BUFSIZ];
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
44 * a single string, storing it into <pathname>.sms_update.
45 *
46 * still to be done: file locking; perform transfers in pieces instead
47 * of all at once; use checksums
48 */
49
50int
51xfer_002(str)
52 char *str;
53{
54 int file_size;
55 int checksum;
56 char *pathname;
57
58 str += 8;
59 while (*str == ' ')
60 str++;
61 if (!*str) {
62 failure:
328656ff 63 reject_call(SMS_ARGS);
de56407f 64 return;
65 }
66 file_size = atoi(str);
67 while (isdigit(*str))
68 str++;
69 while (*str == ' ')
70 str++;
71 checksum = atoi(str);
72 while (isdigit(*str))
73 str++;
74 while (*str == ' ')
75 str++;
76 if (*str != '/')
77 goto failure;
78 pathname = str;
79 if (!have_authorization) {
328656ff 80 reject_call(SMS_PERM);
de56407f 81 return;
82 }
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);
89 if (!code) {
90 char buf[BUFSIZ];
91 have_file = 1;
92 strcpy(buf, "transferred file ");
93 strcat(buf, pathname);
94 sms_log_info(buf);
95 }
96 return;
97}
This page took 0.945212 seconds and 5 git commands to generate.