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