📄 ln03of.c
字号:
while(filestorage[globi++] != '\n'){ if(globi - j > 255){ return(DATA_FILE); } if(globi >= in) goto notc; } if(ccom() == 0) goto notc; }check: if(lookup(c) == 1){ while((ch = filestorage[globi++]) != ';' && ch != '{') if(globi >= in) goto notc; return(CTEXT_FILE); } nl = 0; while(filestorage[globi] != '('){ if(filestorage[globi] <= 0) goto notas; if(filestorage[globi] == ';'){ globi++; goto check; } if(filestorage[globi++] == '\n') if(nl++ > 6) goto notc; if(globi >= in) goto notc; } while(filestorage[globi] != ')'){ if(filestorage[globi++] == '\n') if(nl++ > 6) goto notc; if(globi >= in) goto notc; } while(filestorage[globi] != '{'){ if(filestorage[globi++] == '\n') if(nl++ > 6) goto notc; if(globi >= in) goto notc; } return(CTEXT_FILE);notc: globi = 0; while(filestorage[globi] == 'c' || filestorage[globi] == '#'){ while(filestorage[globi++] != '\n') if(globi >= in) goto notfort; } if(lookup(fort) == 1){ return(FTEXT_FILE); }notfort: globi=0; if(ascom() == 0) goto notas; j = globi-1; if(filestorage[globi] == '.'){ globi++; if(lookup(as) == 1){ return(ATEXT_FILE); } else if(filestorage[j] == '\n' && isalpha(filestorage[j+2])){ return(RTEXT_FILE); } } while(lookup(asc) == 0){ if(ascom() == 0) goto notas; while(filestorage[globi] != '\n' && filestorage[globi++] != ':') if(globi >= in) goto notas; while(filestorage[globi] == '\n' || filestorage[globi] == ' ' || filestorage[globi] == '\t') if(globi++ >= in) goto notas; j = globi-1; if(filestorage[globi] == '.'){ globi++; if(lookup(as) == 1){ return(ATEXT_FILE); } else if(filestorage[j] == '\n' && isalpha(filestorage[j+2])){ return(RTEXT_FILE); } } } return(ATEXT_FILE);notas: for(globi=0; globi < in; globi++)if(filestorage[globi]&0200){ if ((unsigned)filestorage[0]==(unsigned)'\100' && (unsigned)filestorage[1]==(unsigned)'\357') { return(CAT_FILE); } } return(TEXT_FILE);}lookup(tab)register char *tab[];{ register char r; register int k,j,l; while(filestorage[globi] == ' ' || filestorage[globi] == '\t' || filestorage[globi] == '\n')globi++; for(j=0; tab[j] != 0; j++){ l=0; for(k=globi; ((r=tab[j][l++]) == filestorage[k] && r != '\0');k++); if(r == '\0') if(filestorage[k] == ' ' || filestorage[k] == '\n' || filestorage[k] == '\t' || filestorage[k] == '{' || filestorage[k] == '/'){ globi=k; return(1); } } return(0);}ccom(){ register char cc; while((cc = filestorage[globi]) == ' ' || cc == '\t' || cc == '\n') if(globi++ >= in) return(0); if(filestorage[globi] == '/' && filestorage[globi+1] == '*'){ globi += 2; while(filestorage[globi] != '*' || filestorage[globi+1] != '/'){ if(filestorage[globi] == '\\') globi += 2; else globi++; if(globi >= in) return(0); } if((globi += 2) >= in) return(0); } if(filestorage[globi] == '\n') if(ccom() == 0) return(0); return(1);}ascom(){ while(filestorage[globi] == '/') { globi++; while(filestorage[globi++] != '\n') if(globi >= in) return(0); while(filestorage[globi] == '\n') if(globi++ >= in) return(0); } return(1);}/* Here is where all the real output work begins. We switch to the appropriate code for the determined file type stream.*/ln03of(){ register int i = 0; register char *cp; register int ch; register short *tmpptr, *tmp; unsigned int temp; int done, linedone; char *limit; switch(kindofile) { case EMPTY_FILE: break; case EXECUTABLE_FILE: case ARCHIVE_FILE: case DATA_FILE: case CAT_FILE: syslog(LOG_INFO,"Unprintable data"); return(1); break; case XIMAGE_FILE: error = readXimghdr(); if(error) { syslog(LOG_INFO,"Failed to use image header"); return(1); } error = readXimgcmp(); if(error) { syslog(LOG_INFO,"Failed to use image colormap"); return(1); } if(im.format != ITS) { /* do RGB to YIQ conversion */ tmpptr=cmpptr; for(i=0;i!=256;i++) { tmp=tmpptr; temp= *tmpptr * .30; tmpptr++; temp+= *tmpptr * .59; tmpptr++; temp+= *tmpptr * .11; tmpptr++; *tmp=(255-temp); } } error = readXimgdat(); if(error) { syslog(LOG_INFO,"Failed to use image data"); return(1); } if(im.spbxnm > MAXP_PIX_WIDTH) { fprintf(output,"\033[11h\033[7 I"); fprintf(output,"\033[?21 J"); fprintf(output,"\033[?52l"); fprintf(output,"\033[1;3150s"); fprintf(output,"\033P9;0;1q\"1;1-"); rotated++; if(im.spbxnm > MAXL_PIX_WIDTH) { im.spbxnm = MAXL_PIX_WIDTH; } if(im.spbynm > MAXL_PIX_WIDTH) { tmppagecount = im.spbynm/MAXP_PIX_WIDTH; tmplinecount = MAXP_PIX_WIDTH; } } if(im.spbxnm <= MAXP_PIX_WIDTH) { fprintf(output,"\033[11h\033[7 I"); fprintf(output,"\033[?20 J"); fprintf(output,"\033[?52l"); fprintf(output,"\033[1;2400s"); fprintf(output,"\033P9;0;1q\"1;1-"); if(im.spbynm > MAXP_PIX_HEIGHT) { tmppagecount = im.spbynm/MAXP_PIX_HEIGHT; tmplinecount = MAXP_PIX_HEIGHT; } } error = dosixel(); if(error) { syslog(LOG_INFO,"Failed to 'sixelize' data"); fprintf(output, "\033\\"); fprintf(output, "\033c"); sleep(5); fprintf(output, "\014"); fflush(output); return(1); } break; case TEXT_FILE: case CTEXT_FILE: case ATEXT_FILE: case RTEXT_FILE: case FTEXT_FILE: default: for (cp = buf[0], limit = buf[MAXREP]; cp < limit; *cp++ = ' '); done = 0; escflg = 0; /* is escape/control sequence in progress? */ globi = 0; while (!done) { col = indent; esclen = 0; maxrep = -1; linedone = 0; while (!linedone) { ch = globi < in ? filestorage[globi++] : getc(input); if (((escflg==0)&&(ch==ESC))||escflg) eschdl(output,ch); /* deal with escape character */ else /* chetal: literal code added follows */ if ( literal && iscntrl(ch) && ( (ch != '\n') && (ch != EOF) ) ){ cp = &buf[0][col]; /* Since literal mode..everything is the first row itself.*/ maxrep = 0; if (is_7bit_cntrl(ch)){ if (ch == 0177){ *cp++ = '^'; *cp = '?'; col ++; } else{ /* It is < 040 */ *cp++ = '^'; *cp = ch + '@'; col ++; } } else{ /* It is 8bit cntrl */ if ((unsigned char)ch < 0240){ *cp++ = 'M'; *cp++ = '-'; ch &= 0177; *cp = ch + '@'; col += 2; } else { *cp++ = 'M'; *cp++ = '-'; *cp = '?'; col += 2; } } if ( col > maxcol[0] ) maxcol[0] = col; col++; /* col points to next blank entry in buf */ } else { /* regular characters */ switch (ch) { case EOF: linedone = done = 1; ch = '\n'; break; case '\f': /* new page on form feed */ lineno = length; case '\n': /* new line */ if (maxrep < 0) maxrep = 0; putc('\r',output); /* LITOUT eight bit fix */ linedone = 1; break; case '\b': /* backspace */ if (--col < indent) col = indent; break; case '\r': /* carriage return */ col = indent; break; case '\t': /* tab */ col = ((col - indent) | 07) + indent + 1; break; case '\031': /* end media */ /* * lpd needs to use a different filter to * print data so stop what we are doing and * wait for lpd to restart us. */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -