]> andersk Git - moira.git/blame - update/xfer_003.c
Command line printer manipulation client, and build goo.
[moira.git] / update / xfer_003.c
CommitLineData
7ac48069 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>.
1dc4aaf1 6 */
7
1dc4aaf1 8#include <mit-copyright.h>
7ac48069 9#include <moira.h>
10#include "update_server.h"
11
1dc4aaf1 12#include <ctype.h>
7ac48069 13#include <stdio.h>
14#include <stdlib.h>
7b48c9f9 15#include <string.h>
7ac48069 16
7ac48069 17RCSID("$Header$");
1dc4aaf1 18
1dc4aaf1 19/*
20 *
21 * syntax:
22 * >>> (STRING)"xfer_003" filesize checksum pathname
23 * <<< (int)0
24 * >>> (STRING)data
25 * <<< (int)code
26 * >>> (STRING)data
27 * <<< (int)code
28 * ...
29 * >>> (STRING)data (last data block)
30 * <<< (int)code (from read, write, checksum verify)
31 *
32 * function:
33 * perform initial preparations and receive file as
34 * a single string, storing it into <pathname>.moira_update.
35 * this version of transfer encrypts the file being transferred.
36 */
37
85330553 38void xfer_003(int conn, char *str)
1dc4aaf1 39{
85330553 40 int file_size, checksum, code;
41 char *pathname, *p;
5eaef520 42
43 str += 8;
44 while (*str == ' ')
45 str++;
46 if (!*str)
47 {
1dc4aaf1 48 failure:
85330553 49 send_int(conn, MR_ARGS);
50 return;
1dc4aaf1 51 }
85330553 52
53 file_size = strtol(str, &p, 10);
54 if (p == str)
55 {
56 send_int(conn, MR_ARGS);
57 return;
58 }
59 else
60 str = p;
5eaef520 61 while (*str == ' ')
62 str++;
85330553 63
64 checksum = strtol(str, &p, 10);
65 if (p == str)
66 {
67 send_int(conn, MR_ARGS);
68 return;
69 }
70 else
71 str = p;
5eaef520 72 while (*str == ' ')
73 str++;
85330553 74
5eaef520 75 if (*str != '/')
76 goto failure;
77 pathname = str;
85330553 78
5eaef520 79 if (!have_authorization)
80 {
85330553 81 send_int(conn, MR_PERM);
82 return;
1dc4aaf1 83 }
85330553 84
85 send_ok(conn);
86 code = get_file(conn, pathname, file_size, checksum, 0444, 1);
5eaef520 87 if (!code)
85330553 88 com_err(whoami, 0, "Transferred file %s", pathname);
89
90 return;
1dc4aaf1 91}
This page took 0.12191 seconds and 5 git commands to generate.