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

📄 htanchor.c

📁 elinks下lynx是最重要的二个文本浏览器, 在linux下非常实用, lynx比elinks早的多, 目前好像停止开发, 这是lynx源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
		    UCH(me->title[i]) == 2) {		    me->title[i] = ' ';		}	    }	} else {	    CTRACE((tfp,"HTAnchor_setTitle: New title is NULL! "));	    if (me->title) {		CTRACE((tfp,"Old title was \"%s\".\n", me->title));		FREE(me->title);	    } else {		CTRACE((tfp,"Old title was NULL.\n"));	    }	}    }}PUBLIC void HTAnchor_appendTitle ARGS2(	HTParentAnchor *,	me,	CONST char *,		title){    int i;    if (me) {	StrAllocCat(me->title, title);	for (i = 0; me->title[i]; i++) {	    if (UCH(me->title[i]) == 1 ||		UCH(me->title[i]) == 2) {		me->title[i] = ' ';	    }	}    }}/*	Bookmark handling.*/PUBLIC CONST char * HTAnchor_bookmark ARGS1(	HTParentAnchor *,	me){    return( me ? me->bookmark : NULL);}PUBLIC void HTAnchor_setBookmark ARGS2(	HTParentAnchor *,	me,	CONST char *,		bookmark){    if (me)	StrAllocCopy(me->bookmark, bookmark);}/*	Owner handling.*/PUBLIC CONST char * HTAnchor_owner ARGS1(	HTParentAnchor *,	me){    return( me ? me->owner : NULL);}PUBLIC void HTAnchor_setOwner ARGS2(	HTParentAnchor *,	me,	CONST char *,		owner){    if (me) {	StrAllocCopy(me->owner, owner);    }}/*	TITLE handling in LINKs with REV="made" or REV="owner". - FM*/PUBLIC CONST char * HTAnchor_RevTitle ARGS1(	HTParentAnchor *,	me){    return( me ? me->RevTitle : NULL);}PUBLIC void HTAnchor_setRevTitle ARGS2(	HTParentAnchor *,	me,	CONST char *,		title){    int i;    if (me) {	StrAllocCopy(me->RevTitle, title);	for (i = 0; me->RevTitle[i]; i++) {	    if (UCH(me->RevTitle[i]) == 1 ||		UCH(me->RevTitle[i]) == 2) {		me->RevTitle[i] = ' ';	    }	}    }}#ifndef DISABLE_BIBP/*	Citehost for bibp links from LINKs with REL="citehost". - RDC*/PUBLIC CONST char * HTAnchor_citehost ARGS1(	HTParentAnchor *,	me){    return( me ? me->citehost : NULL);}PUBLIC void HTAnchor_setCitehost ARGS2(	HTParentAnchor *,	me,	CONST char *,		citehost){    if (me) {	StrAllocCopy(me->citehost, citehost);    }}#endif /* !DISABLE_BIBP *//*	Suggested filename handling. - FM**	(will be loaded if we had a Content-Disposition**	 header or META element with filename=name.suffix)*/PUBLIC CONST char * HTAnchor_SugFname ARGS1(	HTParentAnchor *,	me){    return( me ? me->SugFname : NULL);}/*	Content-Encoding handling. - FM**	(will be loaded if we had a Content-Encoding**	 header.)*/PUBLIC CONST char * HTAnchor_content_encoding ARGS1(	HTParentAnchor *,	me){    return( me ? me->content_encoding : NULL);}/*	Content-Type handling. - FM*/PUBLIC CONST char * HTAnchor_content_type ARGS1(	HTParentAnchor *,	me){    return( me ? me->content_type : NULL);}/*	Last-Modified header handling. - FM*/PUBLIC CONST char * HTAnchor_last_modified ARGS1(	HTParentAnchor *,	me){    return( me ? me->last_modified : NULL);}/*	Date header handling. - FM*/PUBLIC CONST char * HTAnchor_date ARGS1(	HTParentAnchor *,	me){    return( me ? me->date : NULL);}/*	Server header handling. - FM*/PUBLIC CONST char * HTAnchor_server ARGS1(	HTParentAnchor *,	me){    return( me ? me->server : NULL);}/*	Safe header handling. - FM*/PUBLIC BOOL HTAnchor_safe ARGS1(	HTParentAnchor *,	me){    return (BOOL) ( me ? me->safe : FALSE);}/*	Content-Base header handling. - FM*/PUBLIC CONST char * HTAnchor_content_base ARGS1(	HTParentAnchor *,	me){    return( me ? me->content_base : NULL);}/*	Content-Location header handling. - FM*/PUBLIC CONST char * HTAnchor_content_location ARGS1(	HTParentAnchor *,	me){    return( me ? me->content_location : NULL);}/*	Message-ID, used for mail replies - kw*/PUBLIC CONST char * HTAnchor_messageID ARGS1(	HTParentAnchor *,	me){    return( me ? me->message_id : NULL);}PUBLIC BOOL HTAnchor_setMessageID ARGS2(	HTParentAnchor *,	me,	CONST char *,		messageid){    if (!(me && messageid && *messageid)) {	return FALSE;    }    StrAllocCopy(me->message_id, messageid);    return TRUE;}/*	Subject, used for mail replies - kw*/PUBLIC CONST char * HTAnchor_subject ARGS1(	HTParentAnchor *,	me){    return( me ? me->subject : NULL);}PUBLIC BOOL HTAnchor_setSubject ARGS2(	HTParentAnchor *,	me,	CONST char *,		subject){    if (!(me && subject && *subject)) {	return FALSE;    }    StrAllocCopy(me->subject, subject);    return TRUE;}/*	Manipulation of links**	---------------------*/PUBLIC HTAnchor * HTAnchor_followLink ARGS1(	HTChildAnchor *,	me){    return( me->dest);}PUBLIC HTAnchor * HTAnchor_followTypedLink ARGS2(	HTChildAnchor *,	me,	HTLinkType *,		type){    if (me->type == type)	return( me->dest);    return(NULL);  /* No link of me type */}/*	Methods List**	------------*/PUBLIC HTList * HTAnchor_methods ARGS1(	HTParentAnchor *,	me){    if (!me->methods) {	me->methods = HTList_new();    }    return( me->methods);}/*	Protocol**	--------*/PUBLIC void * HTAnchor_protocol ARGS1(	HTParentAnchor *,	me){    return( me->protocol);}PUBLIC void HTAnchor_setProtocol ARGS2(	HTParentAnchor *,	me,	void*,			protocol){    me->protocol = protocol;}/*	Physical Address**	----------------*/PUBLIC char * HTAnchor_physical ARGS1(	HTParentAnchor *,	me){    return( me->physical);}PUBLIC void HTAnchor_setPhysical ARGS2(	HTParentAnchor *,	me,	char *,			physical){    if (me) {	StrAllocCopy(me->physical, physical);    }}/***  We store charset info in the HTParentAnchor object, for several**  "stages".  (See UCDefs.h)**  A stream method is supposed to know what stage in the model it is.****  General model	MIME	 ->  parser  ->  structured  ->  HText**  e.g., text/html**	from HTTP:	HTMIME.c ->  SGML.c  ->  HTML.c      ->  GridText.c**     text/plain**	from file:	HTFile.c ->  HTPlain.c		     ->  GridText.c****  The lock/set_by is used to lock e.g. a charset set by an explicit**  HTTP MIME header against overriding by a HTML META tag - the MIME**  header has higher priority.  Defaults (from -assume_.. options etc.)**  will not override charset explicitly given by server.****  Some advantages of keeping this in the HTAnchor:**  - Global variables are bad.**  - Can remember a charset given by META tag when toggling to SOURCE view.**  - Can remember a charset given by <A CHARSET=...> href in another doc.****  We don't modify the HTParentAnchor's charset element**  here, that one will only be set when explicitly given.*/PUBLIC LYUCcharset * HTAnchor_getUCInfoStage ARGS2(	HTParentAnchor *,	me,	int,			which_stage){    if (me && !me->UCStages) {	int i;	int chndl = UCLYhndl_for_unspec;  /* always >= 0 */	UCAnchorInfo * stages = typecalloc(UCAnchorInfo);	if (stages == NULL)	    outofmem(__FILE__, "HTAnchor_getUCInfoStage");	for (i = 0; i < UCT_STAGEMAX; i++) {	    stages->s[i].C.MIMEname = "";	    stages->s[i].LYhndl = -1;	}	if (me->charset) {	    chndl = UCGetLYhndl_byMIME(me->charset);	    if (chndl < 0)		chndl = UCLYhndl_for_unrec;	    if (chndl < 0)		/*		**  UCLYhndl_for_unrec not defined :-(		**  fallback to UCLYhndl_for_unspec which always valid.		*/		chndl = UCLYhndl_for_unspec;  /* always >= 0 */	}	memcpy(&stages->s[UCT_STAGE_MIME].C, &LYCharSet_UC[chndl],	       sizeof(LYUCcharset));	stages->s[UCT_STAGE_MIME].lock = UCT_SETBY_DEFAULT;	stages->s[UCT_STAGE_MIME].LYhndl = chndl;	me->UCStages = stages;    }    if (me) {	return( &me->UCStages->s[which_stage].C);    }    return(NULL);}PUBLIC int HTAnchor_getUCLYhndl ARGS2(	HTParentAnchor *,	me,	int,			which_stage){    if (me) {	if (!me->UCStages) {	    /*	     *	This will allocate and initialize, if not yet done.	     */	    (void) HTAnchor_getUCInfoStage(me, which_stage);	}	if (me->UCStages->s[which_stage].lock > UCT_SETBY_NONE) {	    return( me->UCStages->s[which_stage].LYhndl);	}    }    return( -1);}#ifdef CAN_SWITCH_DISPLAY_CHARSETPRIVATE void setup_switch_display_charset ARGS2(HTParentAnchor *, me, int, h){    if (!Switch_Display_Charset(h,SWITCH_DISPLAY_CHARSET_MAYBE))	return;    HTAnchor_setUCInfoStage(me, current_char_set,			    UCT_STAGE_HTEXT, UCT_SETBY_MIME); /* highest priorty! */    HTAnchor_setUCInfoStage(me, current_char_set,			    UCT_STAGE_STRUCTURED, UCT_SETBY_MIME); /* highest priorty! */    CTRACE((tfp, "changing UCInfoStage: HTEXT/STRUCTURED stages charset='%s'.\n",	    LYCharSet_UC[current_char_set].MIMEname));}#endifPUBLIC LYUCcharset * HTAnchor_setUCInfoStage ARGS4(	HTParentAnchor *,	me,	int,			LYhndl,	int,			which_stage,	int,			set_by){    if (me) {	/*	 *  This will allocate and initialize, if not yet done.	 */	LYUCcharset * p = HTAnchor_getUCInfoStage(me, which_stage);	/*	 *  Can we override?	 */	if (set_by >= me->UCStages->s[which_stage].lock) {#ifdef CAN_SWITCH_DISPLAY_CHARSET	    int ohandle = me->UCStages->s[which_stage].LYhndl;#endif	    me->UCStages->s[which_stage].lock = set_by;	    me->UCStages->s[which_stage].LYhndl = LYhndl;	    if (LYhndl >= 0) {		memcpy(p, &LYCharSet_UC[LYhndl], sizeof(LYUCcharset));#ifdef CAN_SWITCH_DISPLAY_CHARSET		/* Allow a switch to a more suitable display charset */		if ( LYhndl != ohandle && which_stage == UCT_STAGE_PARSER )		    setup_switch_display_charset(me, LYhndl);#endif	    }	    else {		p->UChndl = -1;	    }	    return(p);	}    }    return(NULL);}PUBLIC LYUCcharset * HTAnchor_resetUCInfoStage ARGS4(	HTParentAnchor *,	me,	int,			LYhndl,	int,			which_stage,	int,			set_by){    int ohandle;    if (!me || !me->UCStages)	return(NULL);    me->UCStages->s[which_stage].lock = set_by;    ohandle = me->UCStages->s[which_stage].LYhndl;    me->UCStages->s[which_stage].LYhndl = LYhndl;#ifdef CAN_SWITCH_DISPLAY_CHARSET    /* Allow a switch to a more suitable display charset */    if (LYhndl >= 0 && LYhndl != ohandle && which_stage == UCT_STAGE_PARSER)	setup_switch_display_charset(me, LYhndl);#endif    return( &me->UCStages->s[which_stage].C);}/***  A set_by of (-1) means use the lock value from the from_stage.*/PUBLIC LYUCcharset * HTAnchor_copyUCInfoStage ARGS4(	HTParentAnchor *,	me,	int,			to_stage,	int,			from_stage,	int,			set_by){    if (me) {	/*	 *  This will allocate and initialize, if not yet done.	 */	LYUCcharset * p_from = HTAnchor_getUCInfoStage(me, from_stage);	LYUCcharset * p_to = HTAnchor_getUCInfoStage(me, to_stage);	/*	 *  Can we override?	 */	if (set_by == -1)	    set_by = me->UCStages->s[from_stage].lock;	if (set_by == UCT_SETBY_NONE)	    set_by = UCT_SETBY_DEFAULT;	if (set_by >= me->UCStages->s[to_stage].lock) {#ifdef CAN_SWITCH_DISPLAY_CHARSET	    int ohandle = me->UCStages->s[to_stage].LYhndl;#endif	    me->UCStages->s[to_stage].lock = set_by;	    me->UCStages->s[to_stage].LYhndl =		me->UCStages->s[from_stage].LYhndl;#ifdef CAN_SWITCH_DISPLAY_CHARSET	    /* Allow a switch to a more suitable display charset */	    if ( me->UCStages->s[to_stage].LYhndl >= 0		 && me->UCStages->s[to_stage].LYhndl != ohandle		 && to_stage == UCT_STAGE_PARSER )		setup_switch_display_charset(me,					     me->UCStages->s[to_stage].LYhndl);#endif	    if (p_to != p_from)		memcpy(p_to, p_from, sizeof(LYUCcharset));	    return(p_to);	}    }    return(NULL);}

⌨️ 快捷键说明

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