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

📄 man2html.c

📁 android-w.song.android.widget
💻 C
📖 第 1 页 / 共 5 页
字号:
					value = (value > value2);					break;				case '>' + 16:					value = (value >= value2);					break;				case '<' + 16:					value = (value <= value2);					break;				case '=':				case '=' + 16:					value = (value == value2);					break;				case '&':					value = (value && value2);					break;				case ':':					value = (value || value2);					break;				default:					fprintf(stderr, "man2html: unknown operator %c.\n", oper);				}				oper = 0;			}		}		if (*c == ')')			c++;	}	*result = value;	return c;}static voidtrans_char(char *c, char s, char t){	char   *sl = c;	int     slash = 0;	while (*sl != '\n' || slash) {		if (!slash) {			if (*sl == escapesym)				slash = 1;			else if (*sl == s)				*sl = t;		} else			slash = 0;		sl++;	}}/* Remove \a from C in place.  Return modified C. */static char *unescape (char *c){	int	i, l;	l = strlen (c);	i = 0;	while (i < l && c[i]) {		if (c[i] == '\a') {			if (c[i+1])				strcpy(c + i, c + i + 1);	/* should be memmove */			else {				c[i] = '\0';				break;			}		}		i++;	}	return c;}	static char *fill_words(char *c, char *words[], int *n){	char   *sl = c;	int     slash = 0;	int     skipspace = 0;	*n = 0;	words[*n] = sl;	while (*sl && (*sl != '\n' || slash)) {		if (!slash) {			if (*sl == '"') {				*sl = '\a';				skipspace = !skipspace;			} else if (*sl == '\a') {				/* handle already-translated " */				skipspace = !skipspace;			} else if (*sl == escapesym)				slash = 1;			else if ((*sl == ' ' || *sl == '\t') && !skipspace) {				*sl = '\n';				if (words[*n] != sl)					(*n)++;				words[*n] = sl + 1;			}		} else {			if (*sl == '"') {				sl--;				*sl = '\n';				if (words[*n] != sl)					(*n)++;				sl++;				while (*sl && *sl != '\n')					sl++;				words[*n] = sl;				sl--;			}			slash = 0;		}		sl++;	}	if (sl != words[*n])		(*n)++;	return sl;}static char *abbrev_list[] = {	"GSBG", "Getting Started ",	"SUBG", "Customizing SunOS",	"SHBG", "Basic Troubleshooting",	"SVBG", "SunView User's Guide",	"MMBG", "Mail and Messages",	"DMBG", "Doing More with SunOS",	"UNBG", "Using the Network",	"GDBG", "Games, Demos &amp; Other Pursuits",	"CHANGE", "SunOS 4.1 Release Manual",	"INSTALL", "Installing SunOS 4.1",	"ADMIN", "System and Network Administration",	"SECUR", "Security Features Guide",	"PROM", "PROM User's Manual",	"DIAG", "Sun System Diagnostics",	"SUNDIAG", "Sundiag User's Guide",	"MANPAGES", "SunOS Reference Manual",	"REFMAN", "SunOS Reference Manual",	"SSI", "Sun System Introduction",	"SSO", "System Services Overview",	"TEXT", "Editing Text Files",	"DOCS", "Formatting Documents",	"TROFF", "Using <B>nroff</B> and <B>troff</B>",	"INDEX", "Global Index",	"CPG", "C Programmer's Guide",	"CREF", "C Reference Manual",	"ASSY", "Assembly Language Reference",	"PUL", "Programming Utilities and Libraries",	"DEBUG", "Debugging Tools",	"NETP", "Network Programming",	"DRIVER", "Writing Device Drivers",	"STREAMS", "STREAMS Programming",	"SBDK", "SBus Developer's Kit",	"WDDS", "Writing Device Drivers for the SBus",	"FPOINT", "Floating-Point Programmer's Guide",	"SVPG", "SunView 1 Programmer's Guide",	"SVSPG", "SunView 1 System Programmer's Guide",	"PIXRCT", "Pixrect Reference Manual",	"CGI", "SunCGI Reference Manual",	"CORE", "SunCore Reference Manual",	"4ASSY", "Sun-4 Assembly Language Reference",	"SARCH", "<FONT SIZE=-1>SPARC</FONT> Architecture Manual",	"KR", "The C Programming Language",NULL, NULL};static char *lookup_abbrev(char *c){	int     i = 0;	if (!c)		return "";	while (abbrev_list[i] && strcmp(c, abbrev_list[i]))		i = i + 2;	if (abbrev_list[i])		return abbrev_list[i + 1];	else		return c;}static char manidx[NULL_TERMINATED(HUGE_STR_MAX)];static int subs = 0;static int mip = 0;static char label[5] = "lbAA";static voidadd_to_index(int level, char *item){	char   *c = NULL;	label[3]++;	if (label[3] > 'Z') {		label[3] = 'A';		label[2]++;	}	if (level != subs) {		if (subs) {			strmaxcpy(manidx + mip, "</DL>\n", HUGE_STR_MAX - mip);			mip += 6;		} else {			strmaxcpy(manidx + mip, "<DL>\n", HUGE_STR_MAX - mip);			mip += 5;		}	}	subs = level;	scan_troff(item, 1, &c);	sprintf(manidx + mip, "<DT><A HREF=\"#%s\">%s</A><DD>\n", label, c);	if (c)		free(c);	while (manidx[mip])		mip++;}static char *skip_till_newline(char *c){	int     lvl = 0;	while (*c && *c != '\n' || lvl > 0) {		if (*c == '\\') {			c++;			if (*c == '}')				lvl--;			else if (*c == '{')				lvl++;		}		c++;	}	c++;	if (lvl < 0 && newline_for_fun) {		newline_for_fun = newline_for_fun + lvl;		if (newline_for_fun < 0)			newline_for_fun = 0;	}	return c;}static voidoutputPageHeader(char *l, char *c, char *r){	out_html("<TABLE WIDTH=100%>\n<TR>\n");	out_html("<TH ALIGN=LEFT width=33%>");	out_html(l);	out_html("<TH ALIGN=CENTER width=33%>");	out_html(c);	out_html("<TH ALIGN=RIGHT width=33%>");	out_html(r);	out_html("\n</TR>\n</TABLE>\n");}static voidoutputPageFooter(char *l, char *c, char *r){	out_html("<HR>\n");	outputPageHeader(l, c, r);}static int ifelseval = 0;static char *scan_request(char *c){	/* BSD Mandoc stuff */	static int mandoc_synopsis = 0;	/* True if we are in the synopsis					 * section */	static int mandoc_command = 0;	/* True if this is mandoc page */	static int mandoc_bd_options;	/* Only copes with non-nested Bd's */	int     i, j, mode = 0;	char   *h;	char   *wordlist[MAX_WORDLIST];	int     words;	char   *sl;	STRDEF *owndef;	while (*c == ' ' || *c == '\t')		c++;	if (c[0] == '\n')		return c + 1;	if (c[1] == '\n')		j = 1;	else		j = 2;	while (c[j] == ' ' || c[j] == '\t')		j++;	if (c[0] == escapesym) {		/* some pages use .\" .\$1 .\} */		/* .\$1 is too difficult/stupid */		if (c[1] == '$')			c = skip_till_newline(c);		else			c = scan_escape(c + 1);	} else {		i = V(c[0], c[1]);		switch (i) {		case V('a', 'b'):			h = c + j;			while (*h && *h != '\n')				h++;			*h = '\0';			if (scaninbuff && buffpos) {				buffer[buffpos] = '\0';				puts(buffer);			}			/* fprintf(stderr, "%s\n", c+2); */			exit(0);			break;		case V('d', 'i'):			{				STRDEF *de;				int     oldcurpos = curpos;				c = c + j;				i = V(c[0], c[1]);				if (*c == '\n') {					c++;					break;				}				while (*c && *c != '\n')					c++;				c++;				h = c;				while (*c && strncmp(c, ".di", 3))					while (*c && *c++ != '\n');				*c = '\0';				de = strdef;				while (de && de->nr != i)					de = de->next;				if (!de) {					de = (STRDEF *) malloc(sizeof(STRDEF));					de->nr = i;					de->slen = 0;					de->next = strdef;					de->st = NULL;					strdef = de;				} else {					if (de->st)						free(de->st);					de->slen = 0;					de->st = NULL;				}				scan_troff(h, 0, &de->st);				*c = '.';				while (*c && *c++ != '\n');				break;			}		case V('d', 's'):			mode = 1;		case V('a', 's'):			{				STRDEF *de;				int     oldcurpos = curpos;				c = c + j;				i = V(c[0], c[1]);				j = 0;				while (c[j] && c[j] != '\n')					j++;				if (j < 3) {					c = c + j;					break;				}				if (c[1] == ' ')					c = c + 1;				else					c = c + 2;				while (isspace(*c))					c++;				if (*c == '"')					c++;				de = strdef;				while (de && de->nr != i)					de = de->next;				single_escape = 1;				curpos = 0;				if (!de) {					char   *h;					de = (STRDEF *) malloc(sizeof(STRDEF));					de->nr = i;					de->slen = 0;					de->next = strdef;					de->st = NULL;					strdef = de;					h = NULL;					c = scan_troff(c, 1, &h);					de->st = h;					de->slen = curpos;				} else {					if (mode) {						char   *h = NULL;						c = scan_troff(c, 1, &h);						free(de->st);						de->slen = 0;						de->st = h;					} else						c = scan_troff(c, 1, &de->st);					de->slen += curpos;				}				single_escape = 0;				curpos = oldcurpos;			}			break;		case V('b', 'r'):			if (still_dd)				out_html("<DD>");			else				out_html("<BR>\n");			curpos = 0;			c = c + j;			if (c[0] == escapesym) {				c = scan_escape(c + 1);			}			c = skip_till_newline(c);			break;		case V('c', '2'):			c = c + j;			if (*c != '\n') {				nobreaksym = *c;			} else				nobreaksym = '\'';			c = skip_till_newline(c);			break;		case V('c', 'c'):			c = c + j;			if (*c != '\n') {				controlsym = *c;			} else				controlsym = '.';			c = skip_till_newline(c);			break;		case V('c', 'e'):			c = c + j;			if (*c == '\n') {				i = 1;			} else {				i = 0;				while ('0' <= *c && *c <= '9') {					i = i * 10 + *c - '0';					c++;				}			}			c = skip_till_newline(c);			/* center next i lines */			if (i > 0) {				out_html("<CENTER>\n");				while (i && *c) {					char   *line = NULL;					c = scan_troff(c, 1, &line);					if (line && strncmp(line, "<BR>", 4)) {						out_html(line);						out_html("<BR>\n");						i--;					}				}				out_html("</CENTER>\n");				curpos = 0;			}			break;		case V('e', 'c'):			c = c + j;			if (*c != '\n') {				escapesym = *c;			} else				escapesym = '\\';			break;			c = skip_till_newline(c);		case V('e', 'o'):			escapesym = '\0';			c = skip_till_newline(c);			break;		case V('e', 'x'):			exit(0);			break;		case V('f', 'c'):			c = c + j;			if (*c == '\n') {				fieldsym = padsym = '\0';			} else {				fieldsym = c[0];				padsym = c[1];			}			c = skip_till_newline(c);			break;		case V('f', 'i'):			if (!fillout) {				out_html(change_to_font(0));				out_html(change_to_size('0'));				out_html("</PRE>\n");			}			curpos = 0;			fillout = 1;			c = skip_till_newline(c);			break;		case V('f', 't'):			c = c + j;			if (*c == '\n') {				out_html(change_to_font(0));			} else {				if (*c == escapesym) {					int     fn;					c = scan_expression(c, &fn);					c--;					out_html(change_to_font(fn));				} else {					out_html(change_to_font(*c));					c++;				}			}			c = skip_till_newline(c);			break;		case V('e', 'l'):			/* .el anything : else part of if else */			if (ifelseval) {				c = c + j;				c[-1] = '\n';				c = scan_troff(c, 1, NULL);			} else				c = skip_till_newline(c + j);			break;		case V('i', 'e'):			/* .ie c anything : then part of if else */		case V('i', 'f'):			/*			 * .if c anything .if !c anything .if N anything .if			 * !N anything .if 'string1'string2' anything .if			 * !'string1'string2' anything			 */			c = c + j;			c = scan_expression(c, &i);			ifelseval = !i;			if (i) {				*c = '\n';				c++;				c = scan_troff(c, 1, NULL);			} else				c = skip_till_newline(c);			break;		case V('i', 'g'):			{				char   *endwith = "..\n";				i = 3;				c = c + j;				if (*c != '\n') {					endwith = c - 1;					i = 1;					c[-1] = '.';					while (*c && *c != '\n')						c++, i++;				}				c++;				while (*c && strncmp(c, endwith, i))					while (*c++ != '\n');				while (*c++ != '\n');				break;			}		case V('n', 'f'):			if (fillout) {				out_html(change_to_font(0));				out_html(change_to_size('0'));				out_html("<PRE>\n");			}			curpos = 0;			fillout = 0;			c = skip_till_newline(c);			break;		case V('p', 's'):			c = c + j;			if (*c == '\n') {				out_html(change_to_size('0'));			} else {				j = 0;				i = 0;				if (*c == '-') {					j = -1;					c++;				} else if (*c == '+') {					j = 1;					c++;				}				c = scan_expression(c, &i);				if (!j) {					j = 1;					if (i > 5)						i = i - 10;				}				out_html(change_to_size(i * j));			}			c = skip_till_newline(c);			break;		case V('s', 'p'):			c = c + j;			if (fillout)				out_html("<P>");			else {				out_html(NEWLINE);				NEWLINE[0] = '\n';			}			curpos = 0;			c = skip_till_newline(c);			break;		case V('s', 'o'):			{				FILE   *f;				struct stat stbuf;				int     l = 0;				char   *buf;				char   *name = NULL;				curpos = 0;				c = c + j;				if (*c == '/') {					h = c;				} else {					h = c - 3;					h[0] = '.';					h[1] = '.';					h[2] = '/';				}				while (*c != '\n')					c++;				*c = '\0';				scan_troff(h, 1, &name);				if (name[3] == '/')					h = name + 3;				else					h = name;				if (stat(h, &stbuf) != -1)					l = stbuf.st_size;				buf = stralloc(l + 4);#if NOCGI				if (!out_length) {					char   *t, *s;					t = strrchr(fname, '/');					if (!t)						t = fname;					fprintf(stderr, "ln -s %s.html %s.html\n", h, t);					s = strrchr(t, '.');

⌨️ 快捷键说明

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