status 1.58 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
/* Copyright 1998 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*
 * Generic (c.status)
 *
 * © Acorn Computers Ltd. 1997
 */
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include <string.h>
#include "sys/errno.h"
#include "module.h"
#include "protocol.h"

_kernel_oserror *generic_status(_kernel_swi_regs *r)
{
Stewart Brodie's avatar
Stewart Brodie committed
31 32
        int *pollword=(int *)r->r[1];
        Session *ses;
33

Stewart Brodie's avatar
Stewart Brodie committed
34 35
        ses = find_session(r->r[1]);
        if (ses == NULL) {
36
                r->r[0] = r->r[2] = r->r[3] = r->r[4] = 0;
Stewart Brodie's avatar
Stewart Brodie committed
37 38
                return NULL;
        }
39

Stewart Brodie's avatar
Stewart Brodie committed
40 41
        r->r[0] = *pollword = ses->reported_state;
        r->r[3] = ses->sent;
42

Stewart Brodie's avatar
Stewart Brodie committed
43 44 45 46 47 48
        /* Note.  The following condition is CORRECT.  We don't want to confuse the caller
         * into thinking that there is no more data left just because we've seen a
         * Content-Length: 0   header.  We need it to continue to read the header information.
         * Only once we are into body transfers can be legally set this to zero
         */
        r->r[4] = ses->size > 0 ? ses->size : -1;
49

Stewart Brodie's avatar
Stewart Brodie committed
50
        return NULL;
51
}