Annotation of libwww/Library/src/HTSocket.html, revision 2.4

2.1       frystyk     1: <HTML>
                      2: <HEAD>
2.4     ! frystyk     3: <TITLE>Socket I/O Manager</TITLE>
        !             4: <!-- Changed by: Henrik Frystyk Nielsen, 14-Aug-1995 -->
2.1       frystyk     5: <NEXTID N="z18">
                      6: </HEAD>
                      7: <BODY>
                      8: 
                      9: <H1>Manages Read and Write to and from the Network</H1>
                     10: 
                     11: <PRE>
                     12: /*
                     13: **     (c) COPYRIGHT MIT 1995.
                     14: **     Please first read the full copyright statement in the file COPYRIGH.
                     15: */
                     16: </PRE>
                     17: 
                     18: This module defines the read and write functions to and from the
                     19: network. As we are having reentrant function and a smarter network I/O
                     20: this will get very small :-) <P>
                     21: 
                     22: This module is implemented by <A HREF="HTSocket.c">HTSocket.c</A>, and
                     23: it is a part of the <A NAME="z10"
2.3       frystyk    24: HREF="http://www.w3.org/hypertext/WWW/Library/">
                     25: W3C Reference Library</A>.
2.1       frystyk    26: 
                     27: <PRE>
                     28: #ifndef HTSOCKET_H
                     29: #define HTSOCKET_H
                     30: 
                     31: #include <A HREF="HTAccess.html">"HTAccess.h"</A>
                     32: #include <A HREF="HTStream.html">"HTStream.h"</A>
                     33: #include <A HREF="HTAnchor.html">"HTAnchor.h"</A>
                     34: </PRE>
                     35: 
                     36: <H2>Create an Input Buffer</H2>
                     37: 
                     38: This function allocates a input buffer and binds it to the socket
                     39: descriptor given as parameter.
                     40: 
                     41: <PRE>
                     42: extern HTInputSocket* HTInputSocket_new PARAMS((SOCKFD file_number));
                     43: </PRE>
                     44: 
                     45: <H2>Free an Input Buffer</H2>
                     46: 
                     47: <PRE>
                     48: extern void HTInputSocket_free PARAMS((HTInputSocket * isoc));
                     49: </PRE>
                     50: 
                     51: <A NAME="Read"><H2>Read Data from a Socket</H2></A>
                     52: 
                     53: This function has replaced many other functions for doing read from a
                     54: socket. It automaticly converts from ASCII if we are on a NON-ASCII
                     55: machine. This assumes that we do <B>not</B> use this function to read
                     56: a local file on a NON-ASCII machine. The following type definition is
                     57: to make life easier when having a state machine looking for a
                     58: <CODE>&lt;CRLF&gt;</CODE> sequence.
                     59: 
                     60: <PRE>
                     61: typedef enum _HTSocketEOL {
                     62:     EOL_ERR = -1,
                     63:     EOL_BEGIN = 0,
                     64:     EOL_FCR,
                     65:     EOL_FLF,
                     66:     EOL_DOT,
                     67:     EOL_SCR,
                     68:     EOL_SLF
                     69: } HTSocketEOL;
                     70: 
                     71: extern int HTSocketRead        PARAMS((HTRequest * request, HTStream * target));
                     72: </PRE>
                     73: 
2.2       frystyk    74: <H2>Read from an ANSI file Descriptor</H2>
                     75: 
                     76: This function has replaced the HTParseFile() and HTFileCopy functions
                     77: for read from an ANSI file descriptor.
                     78: 
                     79: <PRE>
                     80: extern int HTFileRead  PARAMS((FILE * fp, HTRequest * request,
                     81:                                HTStream * target));
                     82: </PRE>
                     83: 
2.1       frystyk    84: <HR>
                     85: 
                     86: <B><IMG ALIGN=middle SRC="http://www.w3.org/hypertext/WWW/Icons/32x32/caution.gif"> THE REST OF THE FUNCTION DEFINED IN THIS MODULE ARE GOING TO BE
                     87: OBSOLETE SO DO NOT USE THEM - THEY ARE NOT REENTRANT. </B>
                     88: 
                     89: <HR>
                     90: 
                     91: <H2><A
                     92: NAME="z1">HTCopy:  Copy a socket to a stream</A></H2>This is used by the protocol engines
                     93: to send data down a stream, typically
                     94: one which has been generated by HTStreamStack.
                     95: Returns the number of bytes transferred.
                     96: 
                     97: <PRE>
                     98: extern int HTCopy      PARAMS((SOCKFD          file_number,
                     99:                                HTStream *      sink));
                    100: </PRE>
                    101: 
                    102: <H2><A
                    103: NAME="c6">HTFileCopy:  Copy a file to a stream</A></H2>This is used by the protocol engines
                    104: to send data down a stream, typically
                    105: one which has been generated by HTStreamStack.
                    106: It is currently called by <A
                    107: NAME="z9" HREF="#c7">HTParseFile</A>
2.2       frystyk   108: <PRE>
                    109: extern void HTFileCopy PARAMS((
2.1       frystyk   110:        FILE*                   fp,
                    111:        HTStream*               sink));
                    112: </PRE>
                    113: <H2><A
                    114: NAME="c2">HTCopyNoCR: Copy a socket to a stream,
                    115: stripping CR characters.</A></H2>It is slower than <A
                    116: NAME="z2" HREF="#z1">HTCopy</A> .
                    117: <PRE>
                    118: extern void HTCopyNoCR PARAMS((
                    119:        SOCKFD                  file_number,
                    120:        HTStream*               sink));
                    121: 
                    122: 
                    123: </PRE>
                    124: <H2>HTParseSocket: Parse a socket given
                    125: its format</H2>This routine is called by protocol
                    126: modules to load an object.  uses<A
                    127: NAME="z4" HREF="#z3">
                    128: HTStreamStack</A> and the copy routines
                    129: above.  Returns HT_LOADED if succesful,
                    130: &lt;0 if not.
                    131: <PRE>extern int HTParseSocket PARAMS((
                    132:        HTFormat        format_in,
                    133:        SOCKFD          file_number,
                    134:        HTRequest *     request));
                    135: 
                    136: </PRE>
2.2       frystyk   137: 
2.1       frystyk   138: <H2><A
                    139: NAME="c1">HTParseFile: Parse a File through
                    140: a file pointer</A></H2>This routine is called by protocols
                    141: modules to load an object. uses<A
                    142: NAME="z4" HREF="#z3"> HTStreamStack</A>
                    143: and <A
                    144: NAME="c7" HREF="#c6">HTFileCopy</A> .  Returns HT_LOADED
                    145: if succesful, &lt;0 if not.
2.2       frystyk   146: <PRE>
                    147: #if 0
                    148: extern int HTParseFile PARAMS((
2.1       frystyk   149:        HTFormat        format_in,
                    150:        FILE            *fp,
                    151:        HTRequest *     request));
2.2       frystyk   152: #endif
2.1       frystyk   153: </PRE>
                    154: 
                    155: 
                    156: <H3>Get next character from buffer</H3>
                    157: 
                    158: <PRE>extern int HTInputSocket_getCharacter PARAMS((HTInputSocket* isoc));
                    159: </PRE>
                    160: 
                    161: <H3>Read block from input socket</H3>Read *len characters and return a
                    162: buffer (don't free) containing *len
                    163: characters ( *len may have changed).
                    164: Buffer is not NULL-terminated.
                    165: <PRE>extern char * HTInputSocket_getBlock PARAMS((HTInputSocket * isoc,
                    166:                                                  int *           len));
                    167: 
                    168: extern char * HTInputSocket_getLine PARAMS((HTInputSocket * isoc));
                    169: extern char * HTInputSocket_getUnfoldedLine PARAMS((HTInputSocket * isoc));
                    170: extern char * HTInputSocket_getStatusLine PARAMS((HTInputSocket * isoc));
                    171: extern BOOL   HTInputSocket_seemsBinary PARAMS((HTInputSocket * isoc));
                    172: 
                    173: #endif
                    174: 
                    175: </PRE>
                    176: 
                    177: End of definition module
                    178: 
                    179: </BODY>
                    180: </HTML>

Webmaster