Annotation of sbbs/sbbs2/msg2ans/msg2ans.c, revision 1.1.1.1

1.1       root        1: /* msg2ans.c */
                      2: 
                      3: /* Developed 1990-1997 by Rob Swindell; PO Box 501, Yorba Linda, CA 92885 */
                      4: 
                      5: /* Converts Synchronet Ctrl-A codes into ANSI escape sequences */
                      6: 
                      7: #include <stdio.h>
                      8: #include <conio.h>
                      9: 
                     10: #define ANSI fprintf(out,"\x1b[")
                     11: 
                     12: int main(int argc, char **argv)
                     13: {
                     14:        int i,ch;
                     15:        FILE *in,*out;
                     16: 
                     17: if(argc<3) {
                     18:        printf("\nMSG2ANS v1.03\n");
                     19:        printf("\nusage: msg2ans infile.msg outfile.ans\n");
                     20:        exit(0); }
                     21: 
                     22: if((in=fopen(argv[1],"rb"))==NULL) {
                     23:        printf("\nerror opening %s\n",argv[1]);
                     24:        exit(1); }
                     25: 
                     26: if((out=fopen(argv[2],"wb"))==NULL) {
                     27:        printf("\nerror opening %s\n",argv[2]);
                     28:        exit(1); }
                     29: 
                     30: while((ch=fgetc(in))!=EOF) {
                     31:        if(ch==1) { /* ctrl-a */
                     32:                ch=fgetc(in);
                     33:                if(ch==EOF)
                     34:                        break;
                     35:                if(ch>=0x7f) {                                  /* move cursor right x columns */
                     36:                        ANSI;
                     37:                        fprintf(out,"%uC",ch-0x7f);
                     38:                        continue; }
                     39:                switch(toupper(ch)) {
                     40:                        case 'A':
                     41:                                fputc('\1',out);
                     42:                                break;
                     43:                        case '<':
                     44:                                fputc('\b',out);
                     45:                                break;
                     46:                        case '>':
                     47:                                ANSI;
                     48:                                fputc('K',out);
                     49:                                break;
                     50:                        case '[':
                     51:                                fputc('\r',out);
                     52:                                break;
                     53:                        case ']':
                     54:                                fputc('\n',out);
                     55:                                break;
                     56:                        case 'L':
                     57:                                ANSI;
                     58:                                fprintf(out,"2J");
                     59:                                break;
                     60:                        case '-':
                     61:                        case '_':
                     62:                        case 'N':
                     63:                                ANSI;
                     64:                                fprintf(out,"0m");
                     65:                                break;
                     66:                        case 'H':
                     67:                                ANSI;
                     68:                                fprintf(out,"1m");
                     69:                 break;
                     70:                        case 'I':
                     71:                                ANSI;
                     72:                                fprintf(out,"5m");
                     73:                                break;
                     74:                        case 'K':
                     75:                                ANSI;
                     76:                                fprintf(out,"30m");
                     77:                                break;
                     78:                        case 'R':
                     79:                                ANSI;
                     80:                                fprintf(out,"31m");
                     81:                 break;
                     82:                        case 'G':
                     83:                                ANSI;
                     84:                                fprintf(out,"32m");
                     85:                 break;
                     86:                        case 'Y':
                     87:                                ANSI;
                     88:                                fprintf(out,"33m");
                     89:                 break;
                     90:                        case 'B':
                     91:                                ANSI;
                     92:                                fprintf(out,"34m");
                     93:                 break;
                     94:                        case 'M':
                     95:                                ANSI;
                     96:                                fprintf(out,"35m");
                     97:                 break;
                     98:                        case 'C':
                     99:                                ANSI;
                    100:                                fprintf(out,"36m");
                    101:                 break;
                    102:                        case 'W':
                    103:                                ANSI;
                    104:                                fprintf(out,"37m");
                    105:                 break;
                    106:                        case '0':
                    107:                                ANSI;
                    108:                                fprintf(out,"40m");
                    109:                 break;
                    110:                        case '1':
                    111:                                ANSI;
                    112:                                fprintf(out,"41m");
                    113:                 break;
                    114:                        case '2':
                    115:                                ANSI;
                    116:                                fprintf(out,"42m");
                    117:                 break;
                    118:                        case '3':
                    119:                                ANSI;
                    120:                                fprintf(out,"43m");
                    121:                 break;
                    122:                        case '4':
                    123:                                ANSI;
                    124:                                fprintf(out,"44m");
                    125:                 break;
                    126:                        case '5':
                    127:                                ANSI;
                    128:                                fprintf(out,"45m");
                    129:                 break;
                    130:                        case '6':
                    131:                                ANSI;
                    132:                                fprintf(out,"46m");
                    133:                 break;
                    134:                        case '7':
                    135:                                ANSI;
                    136:                                fprintf(out,"47m");
                    137:                                break;
                    138:                        default:
                    139:                                fprintf(out,"\1%c",ch);
                    140:                                break; } }
                    141:        else
                    142:                fputc(ch,out); }
                    143: }
                    144: 
                    145: 
                    146: 
                    147: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.