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

📄 common.h

📁 Dag Erling http library source code
💻 H
字号:
/*- * Copyright (c) 1998-2004 Dag-Erling Co飀an Sm鴕grav * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer *    in this position and unchanged. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. The name of the author may not be used to endorse or promote products *    derived from this software without specific prior written permission * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/lib/libfetch/common.h,v 1.28 2004/09/21 18:35:20 des Exp $ */#ifndef _COMMON_H_INCLUDED#define _COMMON_H_INCLUDED#if 0#define HTTP_DEBUG_ENABLED#endif#ifdef HTTP_DEBUG_ENABLED#define HTTPDEBUG ENABLE#else#define HTTPDEBUG DISABLE#endif#define FTP_DEFAULT_PORT	21#define HTTP_DEFAULT_PORT	80#define FTP_DEFAULT_PROXY_PORT	21#define HTTP_DEFAULT_PROXY_PORT	3128#ifdef WITH_SSL#include <openssl/crypto.h>#include <openssl/x509.h>#include <openssl/pem.h>#include <openssl/ssl.h>#include <openssl/err.h>#endif#define URL_SCHEMELEN 16#define URL_USERLEN 256#define URL_PWDLEN 256struct url {	RMascii		 scheme[URL_SCHEMELEN+1];	RMascii		 user[URL_USERLEN+1];	RMascii		 pwd[URL_PWDLEN+1];	RMascii		 host[MAXHOSTNAMELEN+1];	RMint32		 port;	RMascii		*doc;	RMint64		 offset;	RMint64		 offset_end;	RMuint32	 length;};struct url_stat {	RMint64		 size;	time_t		 atime;	time_t		 mtime;};struct url_ent {	RMascii		 name[PATH_MAX];	struct url_stat	 stat;};/* Connection */typedef struct fetchconn conn_t;struct fetchconn {	RMint32		 sd;		/* socket descriptor */	RMuint8		*buf;		/* buffer */	RMuint32		 bufsize;	/* buffer size */	RMuint32		 buflen;	/* length of buffer contents */	RMint32		 err;		/* last protocol reply code */#ifdef WITH_SSL	SSL		*ssl;		/* SSL handle */	SSL_CTX		*ssl_ctx;	/* SSL context */	X509		*ssl_cert;	/* server certificate */	SSL_METHOD	*ssl_meth;	/* SSL method */#endif	RMint32		 ref;		/* reference count */};/* Structure used for error message lists */struct fetcherr {	const RMint32	 num;	const RMint32	 cat;	const RMascii	*string;};void		 _fetch_seterr(struct fetcherr *, RMint32);void		 _fetch_syserr(void);void		 _fetch_info(const RMascii *, ...);RMint32		 _fetch_default_port(const RMascii *);RMint32		 _fetch_default_proxy_port(const RMascii *);RMint32		 _fetch_bind(RMint32, RMint32, const RMascii *);conn_t		*_fetch_connect(const RMascii *, RMint32, RMint32, RMint32);conn_t		*_fetch_reopen(RMint32);conn_t		*_fetch_ref(conn_t *);RMint32		 _fetch_ssl(conn_t *, RMint32);RMint32		 _fetch_read(conn_t *, RMuint8 *, RMuint32);RMint32		 _fetch_getln(conn_t *);RMint32		 _fetch_write(conn_t *, const RMuint8 *, RMuint32);RMint32		 _fetch_putln(conn_t *, const RMascii *, RMuint32);RMint32		 _fetch_close(conn_t *);/* HTTP-specific functions */HTTPFile	*fetchXGetHTTP(struct url *, struct url_stat *, RMHTTPFlags);HTTPFile	*fetchGetHTTP(struct url *, RMHTTPFlags);RMint32		 fetchStatHTTP(struct url *, struct url_stat *, RMHTTPFlags);/* URL parsing */struct url	*fetchMakeURL(const RMascii *, const RMascii *, RMint32,		     const RMascii *, const RMascii *, const RMascii *);struct url	*fetchParseURL(const RMascii *);void		 fetchFreeURL(struct url *);#define _ftp_seterr(n)	 _fetch_seterr(_ftp_errlist, n)#define _http_seterr(n)	 _fetch_seterr(_http_errlist, n)#define _netdb_seterr(n) _fetch_seterr(_netdb_errlist, n)#define _url_seterr(n)	 _fetch_seterr(_url_errlist, n)#define SAFE(x) 							\{									\	status = (x);							\	if (status < 0){						\		RMDBGLOG((HTTPDEBUG,"Error : %s\n", strerror(errno)));	\		return status; 						\	}								\}#endif

⌨️ 快捷键说明

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