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

📄 common.c

📁 代码检索工具GLOBAL源码。可用来浏览分析LINUX源码。
💻 C
📖 第 1 页 / 共 2 页
字号:
}/* * Generate name tag. */const char *gen_name_string(name)	const char *name;{	STATIC_STRBUF(sb);	strbuf_clear(sb);	if (enable_xhtml) {		/*		 * Since some browser cannot understand "<a id='xxx' />",		 * we put both of 'id=' and 'name=' as long as XHTML1.1		 * is not required. XHTML1.1 prohibit 'name='.		 */		if (strict_xhtml)			strbuf_sprintf(sb, "<a id='%s' />", name);		else			strbuf_sprintf(sb, "<a id='%s' name='%s' />", name, name);	} else {		strbuf_sprintf(sb, "<a name='%s'>", name);	}	return strbuf_value(sb);}/* * Generate anchor begin tag. * (complete format) * *	i)	dir	directory *	i)	file	file *	i)	suffix	suffix *	i)	key	key *	i)	title	title='xxx' *	i)	target	target='xxx' *	r)		generated anchor tag */const char *gen_href_begin_with_title_target(dir, file, suffix, key, title, target)	const char *dir;	const char *file;	const char *suffix;	const char *key;	const char *title;	const char *target;{	STATIC_STRBUF(sb);	strbuf_clear(sb);	/*	 * Construct URL.	 * href='dir/file.suffix#key'	 */	strbuf_puts(sb, "<a href='");	if (file) {		if (dir) {			strbuf_puts(sb, dir);			strbuf_putc(sb, '/');		}		strbuf_puts(sb, file);		if (suffix) {			strbuf_putc(sb, '.');			strbuf_puts(sb, suffix);		}	}	if (key) {		strbuf_putc(sb, '#');		/*		 * If the key starts with a digit, it assumed line number.		 * XHTML 1.1 profibits number as an anchor.		 */		if (isdigit(*key))			strbuf_putc(sb, 'L');		strbuf_puts(sb, key);	}	strbuf_putc(sb, '\'');	if (target)		strbuf_sprintf(sb, " target='%s'", target);	if (title)		strbuf_sprintf(sb, " title='%s'", title);	strbuf_putc(sb, '>');	return strbuf_value(sb);}/* * Generate simple anchor begin tag. */const char *gen_href_begin_simple(file)	const char *file;{	return gen_href_begin_with_title_target(NULL, file, NULL, NULL, NULL, NULL);}/* * Generate anchor begin tag without title and target. */const char *gen_href_begin(dir, file, suffix, key)	const char *dir;	const char *file;	const char *suffix;	const char *key;{	return gen_href_begin_with_title_target(dir, file, suffix, key, NULL, NULL);}/* * Generate anchor begin tag without target. */const char *gen_href_begin_with_title(dir, file, suffix, key, title)	const char *dir;	const char *file;	const char *suffix;	const char *key;	const char *title;{	return gen_href_begin_with_title_target(dir, file, suffix, key, title, NULL);}/* * Generate anchor end tag. */const char *gen_href_end(void){	return "</a>";}/* * Generate list begin tag. */const char *gen_list_begin(void){	STATIC_STRBUF(sb);	if (strbuf_empty(sb)) {		strbuf_clear(sb);		if (table_list) {			if (enable_xhtml) {				strbuf_sprintf(sb, "%s\n%s%s%s%s",					table_begin, 					"<tr><th class='tag'>tag</th>",					"<th class='line'>line</th>",					"<th class='file'>file</th>",					"<th class='code'>source code</th></tr>");			} else {				strbuf_sprintf(sb, "%s\n%s%s%s%s",					table_begin, 					"<tr><th nowrap align='left'>tag</th>",					"<th nowrap align='right'>line</th>",					"<th nowrap align='center'>file</th>",					"<th nowrap align='left'>source code</th></tr>");			}		} else {			strbuf_puts(sb, verbatim_begin);		}	}	return strbuf_value(sb);}/* * Generate list body. * * s must be choped. */const char *gen_list_body(srcdir, string)	const char *srcdir;	const char *string;		/* virtually const */{	STATIC_STRBUF(sb);	const char *p, *filename, *fid;	SPLIT ptable;	strbuf_clear(sb);	if (split((char *)string, 4, &ptable) < 4) {		recover(&ptable);		die("too small number of parts in list_body().\n'%s'", string);	}	filename = ptable.part[2].start + 2;		/* remove './' */	fid = path2fid(filename);	if (table_list) {		if (enable_xhtml) {			strbuf_puts(sb, "<tr><td class='tag'>");			strbuf_puts(sb, gen_href_begin(srcdir, fid, HTML, ptable.part[PART_LNO].start));			strbuf_puts(sb, ptable.part[PART_TAG].start);			strbuf_puts(sb, gen_href_end());			strbuf_sprintf(sb, "</td><td class='line'>%s</td><td class='file'>%s</td><td class='code'>",				ptable.part[PART_LNO].start, filename);		} else {			strbuf_puts(sb, "<tr><td nowrap>");			strbuf_puts(sb, gen_href_begin(srcdir, fid, HTML, ptable.part[PART_LNO].start));			strbuf_puts(sb, ptable.part[PART_TAG].start);			strbuf_puts(sb, gen_href_end());			strbuf_sprintf(sb, "</td><td nowrap align='right'>%s</td><td nowrap align='left'>%s</td><td nowrap>",				ptable.part[PART_LNO].start, filename);		}		for (p = ptable.part[PART_LINE].start; *p; p++) {			unsigned char c = *p;			if (c == '&')				strbuf_puts(sb, quote_amp);			else if (c == '<')				strbuf_puts(sb, quote_little);			else if (c == '>')				strbuf_puts(sb, quote_great);			else if (c == ' ')				strbuf_puts(sb, quote_space);			else if (c == '\t') {				strbuf_puts(sb, quote_space);				strbuf_puts(sb, quote_space);			} else				strbuf_putc(sb, c);		}		strbuf_puts(sb, "</td></tr>");		recover(&ptable);	} else {		int done = 0;		strbuf_puts(sb, gen_href_begin(srcdir, fid, HTML, ptable.part[PART_LNO].start));		strbuf_puts(sb, ptable.part[PART_TAG].start);		strbuf_puts(sb, gen_href_end());		p = string + strlen(ptable.part[PART_TAG].start);		recover(&ptable);		for (; *p; p++) {			unsigned char c = *p;			/* ignore "./" in path name */			if (!done && c == '.' && *(p + 1) == '/') {				p++;				done = 1;			} else if (c == '&')				strbuf_puts(sb, quote_amp);			else if (c == '<')				strbuf_puts(sb, quote_little);			else if (c == '>')				strbuf_puts(sb, quote_great);			else				strbuf_putc(sb, c);		}	}	return strbuf_value(sb);}/* * Generate list end tag. */const char *gen_list_end(void){	return table_list ? table_end : verbatim_end;}/* * Generate div begin tag. * *	i)	align	right,left,center */const char *gen_div_begin(align)	const char *align;{	STATIC_STRBUF(sb);	if (strbuf_empty(sb)) {		strbuf_clear(sb);		if (align) {			/*			 * In XHTML, alignment is defined in the file 'style.css'.			 */			if (enable_xhtml)				strbuf_sprintf(sb, "<div class='%s'>", align);			else				strbuf_sprintf(sb, "<div align='%s'>", align);		} else {			strbuf_puts(sb, "<div>");		}	}	return strbuf_value(sb);}/* * Generate div end tag. */const char *gen_div_end(void){	return "</div>";}/* * Generate beginning of form * *	i)	target	target */const char *gen_form_begin(target)	const char *target;{	STATIC_STRBUF(sb);	strbuf_clear(sb);	strbuf_sprintf(sb, "<form method='get' action='%s'", action);	if (target)		strbuf_sprintf(sb, " target='%s'", target);	strbuf_puts(sb, ">");	return strbuf_value(sb);}/* * Generate end of form */const char *gen_form_end(void){	return "</form>";}/* * Generate input tag */const char *gen_input(name, value, type)	const char *name;	const char *value;	const char *type;{	return gen_input_with_title_checked(name, value, type, 0, NULL);}/* * Generate input radiobox tag */const char *gen_input_radio(name, value, checked, title)	const char *name;	const char *value;	int checked;	const char *title;{	return gen_input_with_title_checked(name, value, "radio", checked, title);}/* * Generate input checkbox tag */const char *gen_input_checkbox(name, value, title)	const char *name;	const char *value;	const char *title;{	return gen_input_with_title_checked(name, value, "checkbox", 0, title);}/* * Generate input radio tag */const char *gen_input_with_title_checked(name, value, type, checked, title)	const char *name;	const char *value;	const char *type;	int checked;	const char *title;{	STATIC_STRBUF(sb);	strbuf_clear(sb);	strbuf_puts(sb, "<input");	if (type)		strbuf_sprintf(sb, " type='%s'", type);	if (name)		strbuf_sprintf(sb, " name='%s'", name);	if (value)		strbuf_sprintf(sb, " value='%s'", value);	if (checked) {		if (enable_xhtml)			strbuf_puts(sb, " checked='checked'");		else			strbuf_puts(sb, " checked");	}	if (title)		strbuf_sprintf(sb, " title='%s'", title);	strbuf_sprintf(sb, "%s>", empty_element);	return strbuf_value(sb);}/* * Generate beginning of frameset * *	i)	target	target */const char *gen_frameset_begin(contents)	const char *contents;{	STATIC_STRBUF(sb);	strbuf_clear(sb);	strbuf_sprintf(sb, "<frameset %s>", contents);	return strbuf_value(sb);}/* * Generate end of frameset */const char *gen_frameset_end(void){	return "</frameset>";}/* * Generate beginning of frame * *	i)	target	target */const char *gen_frame(name, src)	const char *name;	const char *src;{	STATIC_STRBUF(sb);	strbuf_clear(sb);	strbuf_sprintf(sb, "<frame name='%s' id='%s' src='%s'%s>", name, name, src, empty_element);	return strbuf_value(sb);}

⌨️ 快捷键说明

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