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

📄 man2html.c

📁 很少见的linux下的红外口的工具
💻 C
📖 第 1 页 / 共 5 页
字号:
		    currow->prev->next->prev=currow->prev;		    currow->prev=currow->prev->next;		} else {		    currow->prev=layout=(TABLEROW*) malloc(sizeof(TABLEROW));		    currow->prev->prev=NULL;		    currow->prev->next=currow;		}		curfield=currow->prev->first=		    (TABLEITEM*) malloc(sizeof(TABLEITEM));		*curfield=emptyfield;		curfield->align=*c;		curfield->colspan=maxcol;		curfield=currow->first;		c=c+2;	    } else {		if (curfield) {		    curfield->align=*c;		    do {			curfield=curfield->next;		    } while (curfield && curfield->align=='S');		}		if (c[1]=='\n') {		    currow=next_row(currow);		    curfield=currow->first;		}		c=c+2;	    }	} else if (*c=='T' && c[1]=='{') {	    h=c+2;	    c=strstr(h,"\nT}");	    c++;	    *c='\0';	    g=NULL;	    scan_troff(h,0,&g);	    scan_troff(itemreset, 0,&g);	    *c='T';	    c+=3;	    if (curfield) {		curfield->contents=g;		do {		    curfield=curfield->next;		} while (curfield && curfield->align=='S');	    } else		if (g) free(g);	    if (c[-1]=='\n') {		currow=next_row(currow);		curfield=currow->first;	    }	} else if (*c=='.' && c[1]=='T' && c[2]=='&' && c[-1]=='\n') {	    TABLEROW *hr;	    while (*c++!='\n');	    hr=currow;	    currow=currow->prev;	    hr->prev=NULL;	    c=scan_format(c,&hr, &i);	    hr->prev=currow;	    currow->next=hr;	    currow=hr;	    next_row(currow);	    curfield=currow->first;	} else if (*c=='.' && c[1]=='T' && c[2]=='E' && c[-1]=='\n') {	    finished=1;	    while (*c++!='\n');	    if (currow->prev)		currow->prev->next=NULL;	    currow->prev=NULL;	    clear_table(currow);	} else if (*c=='.' && c[-1]=='\n' && !isdigit(c[1])) {	    /* skip troff request inside table (usually only .sp ) */	    while (*c++!='\n');	} else {	    h=c;	    while (*c && (*c!=itemsep || c[-1]=='\\') &&		   (*c!='\n' || c[-1]=='\\')) c++;	    i=0;	    if (*c==itemsep) {i=1; *c='\n'; }	    if (h[0]=='\\' && h[2]=='\n' &&		(h[1]=='_' || h[1]=='^')) {		if (curfield) {		    curfield->align=h[1];		    do {			curfield=curfield->next;		    } while (curfield && curfield->align=='S');		}		h=h+3;	    } else {		g=NULL;		h=scan_troff(h,1,&g);		scan_troff(itemreset,0,&g);		if (curfield) {		    curfield->contents=g;		    do {			curfield=curfield->next;		    } while (curfield && curfield->align=='S');		} else if (g) free(g);	    }	    if (i) *c=itemsep;	    c=h;	    if (c[-1]=='\n') {		currow=next_row(currow);		curfield=currow->first;	    }	}    }    /* calculate colspan and rowspan */    currow=layout;    while (currow->next) currow=currow->next;    while (currow) {	TABLEITEM *ti, *ti1=NULL, *ti2=NULL;	ti=currow->first;	if (currow->prev) ti1=currow->prev->first;	while (ti) {	    switch (ti->align) {	    case 'S':		if (ti2) {		    ti2->colspan++;		    if (ti2->rowspan<ti->rowspan) ti2->rowspan=ti->rowspan;		}		break;	    case '^':		if (ti1) ti1->rowspan++;	    default:		if (!ti2) ti2=ti;		else {		    do {			ti2=ti2->next;		    } while (ti2 && curfield->align=='S');		}		break;	    }	    ti=ti->next;	    if (ti1) ti1=ti1->next;	}	currow=currow->prev;    }    /* produce html output */    if (center) out_html("<CENTER>");    if (box==2) out_html("<TABLE BORDER><TR><TD>");    out_html("<TABLE");    if (box || border) {	out_html(" BORDER");	if (!border) out_html("><TR><TD><TABLE");	if (expand) out_html(" WIDTH=100%");    }    out_html(">\n");    currow=layout;    while (currow) {	j=0;	out_html("<TR VALIGN=top>");	curfield=currow->first;	while (curfield) {	    if (curfield->align!='S' && curfield->align!='^') {		out_html("<TD");		switch (curfield->align) {		case 'N':		    curfield->space+=4;		case 'R':		    out_html(" ALIGN=right");		    break;		case 'C':		    out_html(" ALIGN=center");		default:		    break;		}		if (!curfield->valign && curfield->rowspan>1)		    out_html(" VALIGN=center");		if (curfield->colspan>1) {		    char buf[5];		    out_html(" COLSPAN=");		    sprintf(buf, "%i", curfield->colspan);		    out_html(buf);		}		if (curfield->rowspan>1) {		    char buf[5];		    out_html(" ROWSPAN=");		    sprintf(buf, "%i", curfield->rowspan);		    out_html(buf);		}		j=j+curfield->colspan;		out_html(">");		if (curfield->size) out_html(change_to_size(curfield->size));		if (curfield->font) out_html(change_to_font(curfield->font));		switch (curfield->align) {		case '=': out_html("<HR><HR>"); break;		case '_': out_html("<HR>"); break;		default:		    if (curfield->contents) out_html(curfield->contents);		    break;		}		if (curfield->space)		    for (i=0; i<curfield->space;i++) out_html("&nbsp;");		if (curfield->font) out_html(change_to_font(0));		if (curfield->size) out_html(change_to_size(0));		if (j>=maxcol && curfield->align>'@' && curfield->align!='_')		    out_html("<BR>");		out_html("</TD>");	    }	    curfield=curfield->next;	}	out_html("</TR>\n");	currow=currow->next;    }    if (box && !border) out_html("</TABLE>");    out_html("</TABLE>");    if (box==2) out_html("</TABLE>");    if (center) out_html("</CENTER>\n");    else out_html("\n");    if (!oldfillout) out_html("<PRE>");    fillout=oldfillout;    out_html(change_to_size(oldsize));    out_html(change_to_font(oldfont));    return c;}char *scan_expression(char *c, int *result){    int value=0,value2,sign=1,opex=0;    char oper='c';    if (*c=='!') {	c=scan_expression(c+1, &value);	value= (!value);    } else if (*c=='n') {	c++;	value=NROFF;    } else if (*c=='t') {	c++;	value=1-NROFF;    } else if (*c=='\'' || *c=='"' || *c<' ' || (*c=='\\' && c[1]=='(')) {	/* ?string1?string2?	** test if string1 equals string2.	*/	char *st1=NULL, *st2=NULL, *h;	char *tcmp=NULL;	char sep;	sep=*c;	if (sep=='\\') {	    tcmp=c;	    c=c+3;	}	c++;	h=c;	while (*c!= sep && (!tcmp || strncmp(c,tcmp,4))) c++;	*c='\n';	scan_troff(h, 1, &st1);	*c=sep;	if (tcmp) c=c+3;	c++;	h=c;	while (*c!=sep && (!tcmp || strncmp(c,tcmp,4))) c++;	*c='\n';	scan_troff(h,1,&st2);	*c=sep;	if (!st1 && !st2) value=1;	else if (!st1 || !st2) value=0;	else value=(!strcmp(st1, st2));	if (st1) free(st1);	if (st2) free(st2);	if (tcmp) c=c+3;	c++;    } else {	while (*c && !isspace(*c) && *c!=')') {	    opex=0;	    switch (*c) {	    case '(':		c=scan_expression(c+1, &value2);		value2=sign*value2;		opex=1;		break;	    case '.':	    case '0': case '1':	    case '2': case '3':	    case '4': case '5':	    case '6': case '7':	    case '8': case '9': {		int num=0,denum=1;		value2=0;		while (isdigit(*c)) value2=value2*10+((*c++)-'0');		if (*c=='.') {		    c++;		    while (isdigit(*c)) {			num=num*10+((*c++)-'0');			denum=denum*10;		    }		}		if (isalpha(*c)) {		    /* scale indicator */		    switch (*c) {		    case 'i': /* inch -> 10pt */			value2=value2*10+(num*10+denum/2)/denum;			num=0;			break;		    default:			break;		    }		    c++;		}		value2=value2+(num+denum/2)/denum;		value2=sign*value2;		opex=1;		break;	    }	    case '\\':		c=scan_escape(c+1);		value2=intresult*sign;		if (isalpha(*c)) c++; /* scale indicator */		opex=1;		break;	    case '-':		if (oper) { sign=-1; c++; break; }	    case '>':	    case '<':	    case '+':	    case '/':	    case '*':	    case '%':	    case '&':	    case '=':	    case ':':		if (c[1]=='=') oper=(*c++) +16; else oper=*c;		c++;		break;	    default: c++; break;	    }	    if (opex) {		sign=1;		switch (oper) {		case 'c': value=value2; break;		case '-': value=value-value2; break;		case '+': value=value+value2; break;		case '*': value=value*value2; break;		case '/': if (value2) value=value/value2; break;		case '%': if (value2) value=value%value2; break;		case '<': value=(value<value2); break;		case '>': 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, "Unknown operator %c.\n", oper);		}		oper=0;	    }	}	if (*c==')') c++;    }    *result=value;    return c;}void trans_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++;    }}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==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;}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 };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;}char *section_list[] = {    "1", "User Commands ",    "1C", "User Commands",    "1G", "User Commands",    "1S", "User Commands",    "1V", "User Commands ",    "2", "System Calls",    "2V", "System Calls",    "3", "C Library Functions",    "3C", "Compatibility Functions",    "3F", "Fortran Library Routines",    "3K", "Kernel VM Library Functions",    "3L", "Lightweight Processes Library",    "3M", "Mathematical Library",    "3N", "Network Functions",    "3R", "RPC Services Library",    "3S", "Standard I/O Functions",    "3V", "C Library Functions",    "3X", "Miscellaneous Library Functions",    "4", "Devices and Network Interfaces",    "4F", "Protocol Families",    "4I", "Devices and Network Interfaces",    "4M", "Devices and Network Interfaces",    "4N", "Devices and Network Interfaces",    "4P", "Protocols",    "4S", "Devices and Network Interfaces",    "4V", "Devices and Network Interfaces",    "5", "File Formats",    "5V", "File Formats",    "6", "Games and Demos",    "7", "Environments, Tables, and Troff Macros",    "7V", "Environments, Tables, and Troff Macros",    "8", "Maintenance Commands",    "8C", "Maintenance Commands",    "8S", "Maintenance Commands",    "8V", "Maintenance Commands",    "L", "Local Commands",/* for Solaris:     "1", "User Commands",    "1B", "SunOS/BSD Compatibility Package Commands",    "1b", "SunOS/BSD Compatibility Package Commands",    "1C", "Communication Commands ",    "1c", "Communication Commands",    "1F", "FMLI Commands ",    "1f", "FMLI Commands",    "1G", "Graphics and CAD Commands ",    "1g", "Graphics and CAD Commands ",    "1M", "Maintenance Commands",    "1m", "Maintenance Commands",    "1S", "SunOS Specific Commands",    "1s", "SunOS Specific Commands",    "2", "System Calls",    "3", "C Library Functions",    "3B", "SunOS/BSD Compatibility Library Functions",    "3b", "SunOS/BSD Compatibility Library Functions",    "3C", "C Library Functions",    "3c", "C Library Functions",    "3E", "C Library Functions",    "3e", "C Library Functions",    "3F", "Fortran Library Routines",    "3f", "Fortran Library Routines",    "3G", "C Library Functions",    "3g", "C Library Functions",    "3I", "Wide Character Functions",    "3i", "Wide Character Functions",    "3K", "Kernel VM Library Functions",    "3k", "Kernel VM Library Functions",    "3L", "Lightweight Processes Library",    "3l", "Lightweight Processes Library",    "3M", "Mathematical Library",    "3m", "Mathematical Library",    "3N", "Network Functions",    "3n", "Network Functions",    "3R", "Realtime Library",    "3r", "Realtime Library",    "3S", "Standard I/O Functions",    "3s", "Standard I/O Functions",    "3T", "Threads Library",    "3t", "Threads Library",    "3W", "C Library Functions",    "3w", "C Library Functions",    "3X", "Miscellaneous Library Functions",    "3x", "Miscellaneous Library Functions",    "4", "File Formats",    "4B", "SunOS/BSD Compatibility Package File Formats",

⌨️ 快捷键说明

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