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

📄 man2html.c

📁 很少见的linux下的红外口的工具
💻 C
📖 第 1 页 / 共 5 页
字号:
	    g=f=idtest[0];	    while (g>c && isalpha(g[-1]) && islower(g[-1])) g--;	    h=f+3;	    while (*h && !isspace(*h) && *h!='<' && *h!='>' && *h!='"' &&		   *h!='&') h++;	    if (f-g>2 && f-g<7 && h-f>3) {		char t;		t=*g;		*g='\0';		printf("%s", c);		*g=t; t=*h; *h='\0';		printf("<A HREF=\"%s\">%s</A>", g,g);		*h=t;		c=h;	    } else {		f[1]='\0';		printf("%s", c);		f[1]='/';		c=f+1;	    }	    break;	default:	    break;	}	nr=0;	if (idtest[0] && idtest[0]<c) idtest[0]=strstr(c+1,"://");	if (idtest[1] && idtest[1]<c) idtest[1]=strchr(c+1,'@');	if (idtest[2] && idtest[2]<c) idtest[2]=strstr(c,"www.");	if (idtest[3] && idtest[3]<c) idtest[3]=strstr(c,"ftp.");	if (idtest[4] && idtest[4]<c) idtest[4]=strchr(c+1,'(');	if (idtest[5] && idtest[5]<c) idtest[5]=strstr(c+1,".h&gt;");	for (i=0; i<6; i++) nr += (idtest[i]!=NULL);    }    printf("%s", c);}int current_font=0;int current_size=0;int fillout=1;void out_html(char *c){  if (!c) return;  if (no_newline_output) {      int i=0;      no_newline_output=1;      while (c[i]) {	  if (!no_newline_output) c[i-1]=c[i];	  if (c[i]=='\n') no_newline_output=0;	  i++;      }      if (!no_newline_output) c[i-1]=0;  }  if (scaninbuff) {      while (*c) {	  if (buffpos>=buffmax) {	      char *h;	      h=realloc(buffer, buffmax*2);	      if (!h) return;	      buffer=h;	      buffmax=buffmax*2;	  }	  buffer[buffpos++]=*c++;      }  } else      if (output_possible) {	  while (*c) {	      outbuffer[obp++]=*c;	      if (*c=='\n' || obp>1000) {		  outbuffer[obp]='\0';		  add_links(outbuffer);		  obp=0;	      }	      c++;	  }      }}#define FO0 ""#define FC0 ""#define FO1 "<I>"#define FC1 "</I>"#define FO2 "<B>"#define FC2 "</B>"#define FO3 "<TT>"#define FC3 "</TT>"char *switchfont[16] = { ""     , FC0 FO1, FC0 FO2, FC0 FO3,			 FC1 FO0, ""     , FC1 FO2, FC1 FO3,			 FC2 FO0, FC2 FO1, ""     , FC2 FO3,			 FC3 FO0, FC3 FO1, FC3 FO2, ""      };char *change_to_font(int nr){  int i;  switch (nr) {  case '0': nr++;  case '1': case '2': case '3': case '4': nr=nr-'1'; break;  case V('C','W'): nr=3; break;  case 'L': nr=3; break;  case 'B': nr=2; break;  case 'I': nr=1; break;  case 'P': case 'R': nr=0; break;  case 0: case 1: case 2: case 3: break;  default: nr=0; break;  }  i= current_font*4+nr%4;  current_font=nr%4;  return switchfont[i];}static char sizebuf[200];char *change_to_size(int nr){  int i;  switch (nr) {  case '0': case '1': case '2': case '3': case '4': case '5': case '6':  case '7': case '8': case '9': nr=nr-'0'; break;  case '\0': break;  default: nr=current_size+nr; if (nr>9) nr=9; if (nr< -9) nr=-9; break;  }  if (nr==current_size) return "";  i=current_font;  sizebuf[0]='\0';  strcat(sizebuf, change_to_font(0));  if (current_size) strcat(sizebuf, "</FONT>");  current_size=nr;  if (nr) {    int l;    strcat(sizebuf, "<FONT SIZE=");    l=strlen(sizebuf);    if (nr>0) sizebuf[l++]='+'; else sizebuf[l++]='-',nr=-nr;    sizebuf[l++]=nr+'0';    sizebuf[l++]='>';    sizebuf[l]='\0';  }  strcat(sizebuf, change_to_font(i));  return sizebuf;}int asint=0;int intresult=0;#define SKIPEOL while (*c && *c++!='\n')static int skip_escape=0;static int single_escape=0;char *scan_escape(char *c){    char *h=NULL;    char b[5];    INTDEF *intd;    int exoutputp,exskipescape;    int i,j;    intresult=0;    switch (*c) {    case 'e': h="\\"; curpos++;break;    case '0':    case ' ': h="&nbsp;";curpos++; break;    case '|': h=""; break;    case '"': SKIPEOL; c--; h=""; break;    case '$':	if (argument) {	    c++;	    i=(*c -'1');	    if (!(h=argument[i])) h="";	}	break;    case 'z':	c++;	if (*c=='\\') { c=scan_escape(c+1); c--;h=""; }	else {	    b[0]=*c;	    b[1]='\0';	    h="";	}	break;    case 'k': c++; if (*c=='(') c+=2;    case '^':    case '!':    case '%':    case 'a':    case 'd':    case 'r':    case 'u':    case '\n':    case '&': h=""; break;    case '(':	c++;	i= c[0]*256+c[1];	c++;	h = expand_char(i);	break;    case '*':	c++;	if (*c=='(') {	    c++;	    i= c[0]*256+c[1];	    c++;	} else	    i= *c *256+' ';	h = expand_string(i);	break;    case 'f':	c++;		if (*c=='\\') {	    c++;	    c=scan_escape(c);	    c--;	    i=intresult;	} else 	if (*c != '(')	    i=*c;	else {	    c++;	    i=c[0]*256+c[1];	    c++;	}	if (!skip_escape) h=change_to_font(i); else h="";	break;    case 's':	c++;	j=0;i=0;	if (*c=='-') {j= -1; c++;} else if (*c=='+') {j=1; c++;}	if (*c=='0') c++; else if (*c=='\\') {	    c++;	    c=scan_escape(c);	    i=intresult; if (!j) j=1;	} else	    while (isdigit(*c) && (!i || (!j && i<4))) i=i*10+(*c++)-'0';	if (!j) { j=1; if (i) i=i-10; }	if (!skip_escape) h=change_to_size(i*j); else h="";	c--;	break;    case 'n':	c++;	j=0;	switch (*c) {	case '+': j=1; c++; break;	case '-': j=-1; c++; break;	default: break;	}	if (*c=='(') {	    c++;	    i=V(c[0],c[1]);	    c=c+1;	} else {	    i=V(c[0],' ');	}	intd=intdef;	while (intd && intd->nr!=i) intd=intd->next;	if (intd) {	    intd->val=intd->val+j*intd->incr;	    intresult=intd->val;	} else {	    switch (i) {	    case V('.','s'): intresult=current_size; break;	    case V('.','f'): intresult=current_font; break;	    default: intresult=0; break;	    }	}	h="";	break;    case 'w':	c++;	i=*c;	c++;	exoutputp=output_possible;	exskipescape=skip_escape;	output_possible=0;	skip_escape=1;	j=0;	while (*c!=i) {	    j++;	    if (*c==escapesym) c=scan_escape(c+1); else c++;	}	output_possible=exoutputp;	skip_escape=exskipescape;	intresult=j;	break;    case 'l': h="<HR>"; curpos=0;    case 'b':    case 'v':    case 'x':    case 'o':    case 'L':    case 'h':	c++;	i=*c;	c++;	exoutputp=output_possible;	exskipescape=skip_escape;	output_possible=0;	skip_escape=1;	while (*c != i)	    if (*c==escapesym) c=scan_escape(c+1);	    else c++;	output_possible=exoutputp;	skip_escape=exskipescape;	break;    case 'c': no_newline_output=1; break;    case '{': newline_for_fun++; h="";break;    case '}': if (newline_for_fun) newline_for_fun--; h="";break;    case 'p': h="<BR>\n";curpos=0; break;    case 't': h="\t";curpos=(curpos+8)&0xfff8; break;    case '<': h="&lt;";curpos++; break;    case '>': h="&gt;";curpos++; break;    case '\\': if (single_escape) { c--; break;}    default: b[0]=*c; b[1]=0; h=b; curpos++; break;    }    c++;    if (!skip_escape) out_html(h);    return c;}typedef struct TABLEITEM TABLEITEM;struct TABLEITEM {    char *contents;    int size,align,valign,colspan,rowspan,font,vleft,vright,space,width;    TABLEITEM *next;};static TABLEITEM emptyfield = {NULL,0,0,0,1,1,0,0,0,0,0,NULL};typedef struct TABLEROW TABLEROW;struct TABLEROW {    TABLEITEM *first;    TABLEROW *prev, *next;};static char *tableopt[]= { "center", "expand", "box", "allbox", "doublebox",			   "tab", "linesize", "delim", NULL };static int tableoptl[] = { 6,6,3,6,9,3,8,5,0};static void clear_table(TABLEROW *table){    TABLEROW *tr1,*tr2;    TABLEITEM *ti1,*ti2;    tr1=table;    while (tr1->prev) tr1=tr1->prev;    while (tr1) {	ti1=tr1->first;	while (ti1) {	    ti2=ti1->next;	    if (ti1->contents) free(ti1->contents);	    free(ti1);	    ti1=ti2;	}	tr2=tr1;	tr1=tr1->next;	free(tr2);    }}char *scan_expression(char *c, int *result);static char *scan_format(char *c, TABLEROW **result, int *maxcol){    TABLEROW *layout, *currow;    TABLEITEM *curfield;    int i,j;    if (*result) {	clear_table(*result);    }    layout= currow=(TABLEROW*) malloc(sizeof(TABLEROW));    currow->next=currow->prev=NULL;    currow->first=curfield=(TABLEITEM*) malloc(sizeof(TABLEITEM));    *curfield=emptyfield;    while (*c && *c!='.') {	switch (*c) {	case 'C': case 'c': case 'N': case 'n':	case 'R': case 'r': case 'A': case 'a':	case 'L': case 'l': case 'S': case 's':	case '^': case '_':	    if (curfield->align) {		curfield->next=(TABLEITEM*)malloc(sizeof(TABLEITEM));		curfield=curfield->next;		*curfield=emptyfield;	    }	    curfield->align=toupper(*c);	    c++;	    break;	case 'i': case 'I': case 'B': case 'b':	    curfield->font = toupper(*c);	    c++;	    break;	case 'f': case 'F':	    c++;	    curfield->font = toupper(*c);	    c++;	    if (!isspace(*c)) c++;	    break;	case 't': case 'T': curfield->valign='t'; c++; break;	case 'p': case 'P':	    c++;	    i=j=0;	    if (*c=='+') { j=1; c++; }	    if (*c=='-') { j=-1; c++; }	    while (isdigit(*c)) i=i*10+(*c++)-'0';	    if (j) curfield->size= i*j; else curfield->size=j-10;	    break;	case 'v': case 'V':	case 'w': case 'W':	    c=scan_expression(c+2,&curfield->width);	    break;	case '|':	    if (curfield->align) curfield->vleft++;	    else curfield->vright++;	    c++;	    break;	case 'e': case 'E':	    c++;	    break;	case '0': case '1': case '2': case '3': case '4':	case '5': case '6': case '7': case '8': case '9':	    i=0;	    while (isdigit(*c)) i=i*10+(*c++)-'0';	    curfield->space=i;	    break;	case ',': case '\n':	    currow->next=(TABLEROW*)malloc(sizeof(TABLEROW));	    currow->next->prev=currow;	    currow=currow->next;	    currow->next=NULL;	    curfield=currow->first=(TABLEITEM*)malloc(sizeof(TABLEITEM));	    *curfield=emptyfield;	    c++;	    break;	default:	    c++;	    break;	}    }    if (*c=='.') while (*c++!='\n');    *maxcol=0;    currow=layout;    while (currow) {	curfield=layout->first;	i=0;	while (curfield) {	    i++;	    curfield=curfield->next;	}	if (i>*maxcol) *maxcol=i;	currow=currow->next;    }    *result=layout;    return c;}TABLEROW *next_row(TABLEROW *tr){    if (tr->next) {	tr=tr->next;	if (!tr->next) next_row(tr);	return tr;    } else {	TABLEITEM *ti, *ti2;	tr->next=(TABLEROW*)malloc(sizeof(TABLEROW));	tr->next->prev=tr;	ti=tr->first;	tr=tr->next;	tr->next=NULL;	if (ti) tr->first=ti2=(TABLEITEM*) malloc(sizeof(TABLEITEM));	else tr->first=ti2=NULL;	while (ti!=ti2) {	    *ti2=*ti;	    ti2->contents=NULL;	    if ((ti=ti->next)) {		ti2->next=(TABLEITEM*) malloc(sizeof(TABLEITEM));	    }	    ti2=ti2->next;	}	return tr;    }}char itemreset[20]="\\fR\\s0";char *scan_table(char *c){    char *h, *g;    int center=0, expand=0, box=0, border=0, linesize=1;    int i,j,maxcol=0, finished=0;    int oldfont, oldsize,oldfillout;    char itemsep='\t';    TABLEROW *layout=NULL, *currow;    TABLEITEM *curfield;    while (*c++!='\n');    h=c;    if (*h=='.') return c-1;    oldfont=current_font;    oldsize=current_size;    oldfillout=fillout;    out_html(change_to_font(0));    out_html(change_to_size(0));    if (!fillout) {	fillout=1;	out_html("</PRE>");    }    while (*h && *h!='\n') h++;    if (h[-1]==';') {	/* scan table options */	while (c<h) {	    while (isspace(*c)) c++;	    for (i=0; tableopt[i] && strncmp(tableopt[i],c,tableoptl[i]);i++);	    c=c+tableoptl[i];	    switch (i) {	    case 0: center=1; break;	    case 1: expand=1; break;	    case 2: box=1; break;	    case 3: border=1; break;	    case 4: box=2; break;	    case 5: while (*c++!='('); itemsep=*c++; break;	    case 6: while (*c++!='('); linesize=0;		while (isdigit(*c)) linesize=linesize*10+(*c++)-'0';		break;	    case 7: while (*c!=')') c++;	    default: break;	    }	    c++;	}	c=h+1;    }    /* scan layout */    c=scan_format(c,&layout, &maxcol);    currow=layout;    next_row(currow);    curfield=layout->first;    i=0;    while (!finished) {	/* search item */	h=c;	if ((*c=='_' || *c=='=') && (c[1]==itemsep || c[1]=='\n')) {	    if (c[-1]=='\n' && c[1]=='\n') {		if (currow->prev) {		    currow->prev->next=(TABLEROW*) malloc(sizeof(TABLEROW));		    currow->prev->next->next=currow;

⌨️ 快捷键说明

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