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

📄 nkflib.c

📁 linux上播放midi音乐,但是要一些设置.可网上查找. 软件名称: TiMidity++-2.13.0.tar
💻 C
📖 第 1 页 / 共 5 页
字号:
            sputchar(c1);    }    return VOIDVOID;}#define rot13(c)  ( \      ( c < 'A' ) ? c: \      (c <= 'M')  ? (c + 13): \      (c <= 'Z')  ? (c - 13): \      (c < 'a')   ? (c): \      (c <= 'm')  ? (c + 13): \      (c <= 'z')  ? (c - 13): \      (c) \)#define  rot47(c) ( \      ( c < '!' ) ? c: \      ( c <= 'O' ) ? (c + 47) : \      ( c <= '~' ) ?  (c - 47) : \      c \)/*   Return value of line_fold()       \n  add newline  and output char       \r  add newline  and output nothing       ' ' space       0   skip         1   (or else) normal output   fold state in prev (previous character)      >0x80 Japanese (X0208/X0201)      <0x80 ASCII      \n    new line       ' '   space  This fold algorthm does not preserve heading space in a line.  This is the main difference from fmt.*/intline_fold(int c2, int c1) {     int prev0;    if(c1=='\r')         return 0;               /* ignore cr */    if(c1== 8) {        if(line>0) line--;        return 1;    }    if(c2==EOF && line != 0)    /* close open last line */        return '\n';    /* new line */    if(c1=='\n') {        if(prev == c1) {        /* duplicate newline */            if(line) {                line = 0;                return '\n';    /* output two newline */            } else {                line = 0;                return 1;            }        } else  {            if(prev&0x80) {     /* Japanese? */                prev = c1;                return 0;       /* ignore given single newline */            } else if(prev==' ') {                return 0;            } else {                prev = c1;                if(++line<=fold_len)                     return ' ';                else {                    line = 0;                    return '\r';        /* fold and output nothing */                }            }        }    }    if(c1=='\f') {        prev = '\n';        if(line==0)            return 1;        line = 0;        return '\n';            /* output newline and clear */    }    /* X0208 kankaku or ascii space */    if( (c2==0&&c1==' ')||        (c2==0&&c1=='\t')||        (c2==DOUBLE_SPACE)||        (c2=='!'&& c1=='!')) {        if(prev == ' ') {            return 0;           /* remove duplicate spaces */        }         prev = ' ';            if(++line<=fold_len)             return ' ';         /* output ASCII space only */        else {            prev = ' '; line = 0;            return '\r';        /* fold and output nothing */        }    }     prev0 = prev; /* we still need this one... , but almost done */    prev = c1;    if(c2 || (SSP<=c1 && c1<=0xdf))         prev |= 0x80;  /* this is Japanese */    line += (c2==0)?1:2;    if(line<=fold_len) {   /* normal case */        return 1;    }    if(line>=fold_len+FOLD_MARGIN) { /* too many kinsou suspension */        line = (c2==0)?1:2;        return '\n';       /* We can't wait, do fold now */    }    /* simple kinsoku rules  return 1 means no folding  */    if(c2==0) {        if(c1==0xde) return 1; /* ~*/        if(c1==0xdf) return 1; /* ‖*/        if(c1==0xa4) return 1; /* 。*/        if(c1==0xa3) return 1; /* ·*/        if(c1==0xa1) return 1; /* ∽*/        if(c1==0xb0) return 1; /* - */        if(SSP<=c1 && c1<=0xdf) {               /* X0201 */            line = 1;            return '\n';/* add one new line before this character */        }        /* fold point in ASCII { [ ( */        if(( c1!=')'&&             c1!=']'&&             c1!='}'&&             c1!='.'&&             c1!=','&&             c1!='!'&&             c1!='?'&&             c1!='/'&&             c1!=':'&&             c1!=';')&&            ((prev0=='\n')|| (prev0==' ')||     /* ignored new line */            (prev0&0x80))                       /* X0208 - ASCII */            ) {            line = 1;            return '\n';/* add one new line before this character */        }        return 1;  /* default no fold in ASCII */    } else {        if(c2=='!') {            if(c1=='"')  return 1; /* 、 */            if(c1=='#')  return 1; /* 。 */            if(c1=='$')  return 1; /* · */            if(c1=='%')  return 1; /* ˉ */            if(c1=='\'') return 1; /* ≤ */            if(c1=='(')  return 1; /* 〃 */            if(c1==')')  return 1; /* 々 */            if(c1=='*')  return 1; /* — */            if(c1=='+')  return 1; /* ~ */            if(c1==',')  return 1; /* ‖ */        }        line = 2;        return '\n'; /* add one new line before this character */    }}intpre_convert(int c1, int c2){        if(c2) c1 &= 0x7f;        c1_return = c1;        if(c2==EOF) return c2;        c2 &= 0x7f;        if(rot_f) {            if(c2) {                c1 = rot47(c1);                c2 = rot47(c2);            } else {                if(!(c1 & 0x80))                     c1 = rot13(c1);            }            c1_return = c1;        }        /* JISX0208 Alphabet */        if(alpha_f && c2 == 0x23 ) return 0;         /* JISX0208 Kigou */        if(alpha_f && c2 == 0x21 ) {            if(0x21==c1) {               if(alpha_f&0x2) {                   c1_return = ' ';                   return 0;               } else if(alpha_f&0x4) {                   c1_return = ' ';                   return DOUBLE_SPACE;               } else {                   return c2;               }           } else if(0x20<c1 && c1<0x7f && fv[c1-0x20]) {               c1_return = fv[c1-0x20];               return 0;           }         }        return c2;}#ifdef STRICT_MIME/* This converts  =?ISO-2022-JP?B?HOGE HOGE?= */unsigned char *mime_pattern[] = {   (unsigned char *)"\075?ISO-8859-1?Q?",   (unsigned char *)"\075?ISO-2022-JP?B?",   (unsigned char *)"\075?ISO-2022-JP?Q?",   (unsigned char *)"\075?JAPANESE_EUC?B?",   (unsigned char *)"\075?SHIFT_JIS?B?",   NULL};int      mime_encode[] = {    'Q', 'B', 'Q',    0};#endif#define MAXRECOVER 20int iso8859_f_save;#ifdef STRICT_MIME#define nkf_toupper(c)  (('a'<=c && c<='z')?(c-('a'-'A')):c)/* I don't trust portablity of toupper */intmime_begin(SFILE *f){    int c1;    int i,j,k;    unsigned char *p,*q;    int r[MAXRECOVER];    /* recovery buffer, max mime pattern lenght */    mime_mode = FALSE;    /* =? has been checked */    j = 0;    p = mime_pattern[j];    r[0]='='; r[1]='?';    for(i=2;p[i]>' ';i++) {                   /* start at =? */        if( ((r[i] = c1 = sgetc(f))==EOF) || nkf_toupper(c1) != p[i] ) {            /* pattern fails, try next one */            q = p;            while (p = mime_pattern[++j]) {                for(k=2;k<i;k++)              /* assume length(p) > i */                    if(p[k]!=q[k]) break;                if(k==i && nkf_toupper(c1)==p[k]) break;            }            if(p) continue;  /* found next one, continue */            /* all fails, output from recovery buffer */            sungetc(c1,f);            for(j=0;j<i;j++) {                (*oconv)(0,r[j]);            }            return c1;        }    }    mime_mode = mime_encode[j];    iso8859_f_save = iso8859_f;    if(j==0) {        iso8859_f = TRUE;    }    if(mime_mode=='B') {        mimebuf_f = unbuf_f;        if(!unbuf_f) {            /* do MIME integrity check */            return mime_integrity(f,mime_pattern[j]);        }     }    mimebuf_f = TRUE;    return c1;}#define mime_getc0(f)   (mimebuf_f?sgetc(f):Fifo(mime_input++))#define mime_ungetc0(c,f) (mimebuf_f?sungetc(c,f):mime_input--)#elseintmime_begin(SFILE *f){    int c1;    int i,j;    int r[MAXRECOVER];    /* recovery buffer, max mime pattern lenght */    mime_mode = FALSE;    /* =? has been checked */    j = 0;    r[0]='='; r[1]='?';    for(i=2;i<MAXRECOVER;i++) {                   /* start at =? */	/* We accept any charcter type even if it is breaked by new lines */        if( (r[i] = c1 = sgetc(f))==EOF) break;	if(c1=='=') break;	if(c1<' '&& c1!='\r' && c1!='\n') break;	if(c1=='?') {	    i++;	    if(!(i<MAXRECOVER) || (r[i] = c1 = sgetc(f))==EOF) break;	    if(c1=='b'||c1=='B') {		mime_mode = 'B';	    } else if(c1=='q'||c1=='Q') {		mime_mode = 'Q';	    } else {		break;	    }	    i++;	    if(!(i<MAXRECOVER) || (r[i] = c1 = sgetc(f))==EOF) break;	    if(c1=='?') {		break;	    } else {		mime_mode = FALSE;	    }	    break;	}    }    if(!mime_mode || c1==EOF || i==MAXRECOVER) {	sungetc(c1,f);	for(j=0;j<i;j++) {	    (*oconv)(0,r[j]);	}	return c1;    }    iso8859_f_save = iso8859_f;    /* do no MIME integrity check */    return c1;   /* used only for checking EOF */}#define mime_getc0(f)   sgetc(f)#define mime_ungetc0(c,f) sungetc(c,f)#endifint mime_getc(SFILE *f){    int c1, c2, c3, c4, cc;    int t1, t2, t3, t4, mode, exit_mode;    if(mime_top != mime_last) {  /* Something is in FIFO */        return  Fifo(mime_top++);    }    if(mimebuf_f == FIXED_MIME)        exit_mode = mime_mode;    else        exit_mode = FALSE;    if(mime_mode == 'Q') {        if((c1 = mime_getc0(f)) == EOF) return (EOF);        if(c1=='_') return ' ';        if(c1!='=' && c1!='?')             return c1;        mime_mode = exit_mode; /* prepare for quit */        if(c1<=' ') return c1;        if((c2 = mime_getc0(f)) == EOF) return (EOF);        if(c2<=' ') return c2;        if(c1=='?'&&c2=='=') {            /* end Q encoding */            input_mode = exit_mode;            iso8859_f = iso8859_f_save;            return sgetc(f);        }        if(c1=='?') {            mime_mode = 'Q'; /* still in MIME */            mime_ungetc0(c2,f);            return c1;        }        if((c3 = mime_getc0(f)) == EOF) return (EOF);        if(c2<=' ') return c2;        mime_mode = 'Q'; /* still in MIME */#define hex(c)   (('0'<=c&&c<='9')?(c-'0'):\     ('A'<=c&&c<='F')?(c-'A'+10):('a'<=c&&c<='f')?(c-'a'+10):0)        return ((hex(c2)<<4) + hex(c3));    }    if(mime_mode != 'B') {        mime_mode = FALSE;        return sgetc(f);    }    /* Base64 encoding */    /*         MIME allows line break in the middle of         Base64, but we are very pessimistic in decoding        in unbuf mode because MIME encoded code may broken by         less or editor's control sequence (such as ESC-[-K in unbuffered        mode. ignore incomplete MIME.    */    mode = mime_mode;    mime_mode = exit_mode;  /* prepare for quit */    while ((c1 = mime_getc0(f))<=' ') {        if(c1==EOF)            return (EOF);    }    if((c2 = mime_getc0(f))<=' ') {        if(c2==EOF)            return (EOF);        if(mimebuf_f!=FIXED_MIME) input_mode = ASCII;          return c2;    }    if((c1 == '?') && (c2 == '=')) {        input_mode = ASCII;        while((c1 =  sgetc(f))==' ' /* || c1=='\n' || c1=='\r' */);        return c1;    }    if((c3 = mime_getc0(f))<=' ') {        if(c3==EOF)            return (EOF);        if(mimebuf_f!=FIXED_MIME) input_mode = ASCII;          return c3;    }    if((c4 = mime_getc0(f))<=' ') {        if(c4==EOF)            return (EOF);        if(mimebuf_f!=FIXED_MIME) input_mode = ASCII;          return c4;    }    mime_mode = mode; /* still in MIME sigh... */    /* BASE 64 decoding */    t1 = 0x3f & base64decode(c1);    t2 = 0x3f & base64decode(c2);    t3 = 0x3f & base64decode(c3);    t4 = 0x3f & base64decode(c4);    cc = ((t1 << 2) & 0x0fc) | ((t2 >> 4) & 0x03);    if(c2 != '=') {        Fifo(mime_last++) = cc;        cc = ((t2 << 4) & 0x0f0) | ((t3 >> 2) & 0x0f);        if(c3 != '=') { 

⌨️ 快捷键说明

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