⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htprot.h

📁 www工具包. 这是W3C官方支持的www支撑库. 其中提供通用目的的客户端的WebAPI: complete HTTP/1.1 (with caching, pipelining, PUT, POS
💻 H
字号:
/*					W3C Sample Code Library libwww Protocol Class!The Protocol Class!*//***        (c) COPYRIGHT MIT 1995.**        Please first read the full copyright statement in the file COPYRIGH.*//*The Protocol class defines an application level protocol (HTTP, FTP,Gopher, etc.) to be used by libwww. Note that access to the local file systemalso is considered to be an appliaction level protocol treated identically tofor example the HTTP protocol.The Protocol class does only know about the application layer protocol andit relies on the Transport Class to do the actualtcommunication with the network, the local file system etc. The protocol classdefines an access method for both a client and a server. A typical clientapplication would probably only want to use the client method and a serveronly the server method. However, any application can use both which allows itto seemlessly to change between server and client profile as needed.All protocol modules are dynamically bound to an access scheme. Take forexample the address http://www.w3.org which has the access schemehttp and if we have a protocol module capable of handling HTTP then wecan make the binding between http and this module. As mentioned in theintroduction to this chapter, the Library already comes with a large set ofprotocol module, including HTTP so all we have to do in this case is toregister the HTTP module to the Library as being capable of handlinghttp URLs.Libwww comes with a default set of protocols including the ones mentionedabove which can be initiated using the function HTProtocolInit()in HTInit moduleOne special case is the support for access to WAISdatabases. WAIS has its own code Librarycalled freeWAIS which is required in orderto directly access wais URLs. We shall not describe in describe in detail herehow this can be enabled as it is described in the WWW-WAIS gateway.This module is implemented by HTProt.c, and it is apart of the  W3C Sample CodeLibrary.*/#ifndef HTPROT_H#define HTPROT_Htypedef struct _HTProtocol HTProtocol;typedef u_short HTProtocolId;#include "HTReq.h"#include "HTAnchor.h"#include "HTEvent.h"#include "HTTrans.h"/*An access scheme module takes as a parameter a socket (which is an invalidsocket the first time the function is called), a request structure containing details of the request,and the action by which the (valid) socket was selected in the event loop.When the protocol class routine is called, the anchor element in the requestis already valid (made valid by HTAccess)..Creation and Deletion Methods.(Add an Protocol)This functions registers a protocol module and binds it to a specificaccess acheme (the part before the first colon in a URL). For example, theHTTP  client module is bound to http URLs. The callback function is thefunction to be called for loading.*/typedef int HTProtCallback (SOCKET, HTRequest *);extern BOOL HTProtocol_add (const char *               name,                            const char *        transport,                            HTProtocolId        port,                            BOOL                preemptive,                            HTProtCallback *        client,                            HTProtCallback *        server);/*(Delete a Protocol)This functions deletes a registered protocol module so that it can not beused for accessing a resource anymore.*/extern BOOL HTProtocol_delete (const char * name);/*(Remove ALL Registered Protocols)This is the garbage collection function. It is called by HTLibTerminate()*/extern BOOL HTProtocol_deleteAll (void);/*.Protocol Class Methods.(Find a Protocol Object)You can search the list of registered protocol objects as a function of theaccess acheme. If an access scheme is found then the protocol object isreturned.*/extern HTProtocol * HTProtocol_find (HTRequest * request, const char * access);/*(Get the callback functions)You can get the callback functions registered together with a protocolobject using the following methods.*/extern HTProtCallback * HTProtocol_client (HTProtocol * protocol);extern HTProtCallback * HTProtocol_server (HTProtocol * protocol);/*(Get the default Protocol ID)Each protocol is registered with a default protocol ID which is the defaultport number that this protocol is using. In the case of FTP it is 21, forHTTP, it is 80 and for NNTP it is 119.*/extern HTProtocolId HTProtocol_id (HTProtocol * protocol);/*(Get the Protocol Name)Get the protocol name that was registered when the protocol object wascreated*/extern const char * HTProtocol_name (HTProtocol * protocol);/*(Is Access Scheme Preemptive)Returns YES if the implementation of the access scheme supports preemptiveaccess only.*/extern BOOL HTProtocol_preemptive (HTProtocol * protocol);/*(Binding to the Transport Class)An application protocol is registered together with a transport protocol in order to communicate with thethansport layer.*/extern BOOL HTProtocol_setTransport (HTProtocol * protoccol,                                     const char * transport);extern const char * HTProtocol_transport (HTProtocol * protocol);/**/#endif /* HTPROT_H *//*@(#) $Id: HTProt.html,v 2.25 1999/12/01 13:07:07 kahan Exp $ */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -