Annotation of libwww/Library/src/HTSocket.c, revision 2.30

2.1       frystyk     1: /*                                                                  HTSocket.c
2.29      frystyk     2: **     LOAD A SOCKET
2.1       frystyk     3: **
                      4: **     (c) COPYRIGHT MIT 1995.
                      5: **     Please first read the full copyright statement in the file COPYRIGH.
2.30    ! frystyk     6: **     @(#) $Id: HTSocket.c,v 2.29 1996/04/12 17:48:46 frystyk Exp $
2.1       frystyk     7: **
                      8: **
                      9: ** HISTORY:
2.29      frystyk    10: **     6 June 95  HFN  Written
2.1       frystyk    11: */
                     12: 
                     13: /* Library Include files */
2.25      frystyk    14: #include "sysdep.h"
2.30    ! frystyk    15: #include "WWWUtil.h"
        !            16: #include "WWWCore.h"
        !            17: #include "WWWTrans.h"
2.8       frystyk    18: #include "HTNetMan.h"
2.1       frystyk    19: #include "HTSocket.h"                                   /* Implemented here */
                     20: 
                     21: struct _HTStream {
2.25      frystyk    22:     const HTStreamClass *      isa;
2.1       frystyk    23: };
                     24: 
2.30    ! frystyk    25: struct _HTInputStream {
        !            26:     const HTInputStreamClass * isa;
        !            27: };
        !            28: 
2.1       frystyk    29: /* ------------------------------------------------------------------------- */
2.27      frystyk    30: 
2.17      frystyk    31: /*     HTLoadSocket
                     32: **     ------------
                     33: **     Given an open socket, this routine loads what ever is on the socket
                     34: **
                     35: ** On entry,
                     36: **      request                This is the request structure
                     37: ** On Exit
                     38: **     returns         HT_ERROR        Error has occured in call back
                     39: **                     HT_OK           Call back was OK
                     40: */
                     41: PUBLIC int HTLoadSocket (SOCKET soc, HTRequest * request, SockOps ops)
                     42: {
2.30    ! frystyk    43:     HTNet * net = HTRequest_net(request);
        !            44:     if (!net || !request) {
        !            45:        if (PROT_TRACE) HTTrace("Load Socket. invalid argument\n");
        !            46:        return HT_ERROR;
        !            47:     }
2.17      frystyk    48:     if (ops == FD_NONE) {
                     49:        if (soc==INVSOC) {
2.24      eric       50:            if (PROT_TRACE) HTTrace("Load Socket. invalid socket\n");
2.17      frystyk    51:            return HT_ERROR;
                     52:        }
2.24      eric       53:        if (PROT_TRACE) HTTrace("Load Socket. Loading socket %d\n",soc);
2.30    ! frystyk    54: 
        !            55:        /* 
        !            56:        ** Create the stream pipe FROM the channel to the application.
        !            57:        ** The target for the input stream pipe is set up using the
        !            58:        ** stream stack.
        !            59:        */
        !            60:        {
        !            61:            HTStream * target = HTRequest_outputStream(request);
        !            62:            if (!target) target = HTErrorStream();
        !            63:            HTNet_getInput(net, target, NULL, 0);
        !            64:            HTRequest_setOutputConnected(request, YES);
        !            65:        }
2.17      frystyk    66:     } else if (ops == FD_CLOSE) {                            /* Interrupted */
2.30    ! frystyk    67:        HTNet_delete(net, HT_INTERRUPTED);
2.17      frystyk    68:        return HT_OK;
                     69:     }
                     70: 
                     71:     /* In this load function we only have one state: READ */
                     72:     {
2.30    ! frystyk    73:        int status = (*net->input->isa->read)(net->input);
        !            74:        if (PROT_TRACE) HTTrace("Load Socket. Read returns %d\n", status);
2.17      frystyk    75:     }
                     76:     return HT_OK;
                     77: }
2.27      frystyk    78: 

Webmaster