Annotation of sbbs/sbbs3/telnet.c, revision 1.1.1.2

1.1       root        1: /* telnet.c */
                      2: 
                      3: /* Synchronet telnet command/option functions */
                      4: 
1.1.1.2 ! root        5: /* $Id: telnet.c,v 1.4 2004/10/14 03:28:22 rswindell Exp $ */
1.1       root        6: 
                      7: /****************************************************************************
                      8:  * @format.tab-size 4          (Plain Text/Source Code File Header)                    *
                      9:  * @format.use-tabs true       (see http://www.synchro.net/ptsc_hdr.html)              *
                     10:  *                                                                                                                                                     *
1.1.1.2 ! root       11:  * Copyright 2004 Rob Swindell - http://www.synchro.net/copyright.html         *
1.1       root       12:  *                                                                                                                                                     *
                     13:  * This program is free software; you can redistribute it and/or                       *
                     14:  * modify it under the terms of the GNU General Public License                         *
                     15:  * as published by the Free Software Foundation; either version 2                      *
                     16:  * of the License, or (at your option) any later version.                                      *
                     17:  * See the GNU General Public License for more details: gpl.txt or                     *
                     18:  * http://www.fsf.org/copyleft/gpl.html                                                                                *
                     19:  *                                                                                                                                                     *
                     20:  * Anonymous FTP access to the most recent released source is available at     *
                     21:  * ftp://vert.synchro.net, ftp://cvs.synchro.net and ftp://ftp.synchro.net     *
                     22:  *                                                                                                                                                     *
                     23:  * Anonymous CVS access to the development source and modification history     *
                     24:  * is available at cvs.synchro.net:/cvsroot/sbbs, example:                                     *
                     25:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs login                       *
                     26:  *     (just hit return, no password is necessary)                                                     *
                     27:  * cvs -d :pserver:[email protected]:/cvsroot/sbbs checkout src                *
                     28:  *                                                                                                                                                     *
                     29:  * For Synchronet coding style and modification guidelines, see                                *
                     30:  * http://www.synchro.net/source.html                                                                          *
                     31:  *                                                                                                                                                     *
                     32:  * You are encouraged to submit any modifications (preferably in Unix diff     *
                     33:  * format) via e-mail to [email protected]                                                                      *
                     34:  *                                                                                                                                                     *
                     35:  * Note: If this box doesn't appear square, then you need to fix your tabs.    *
                     36:  ****************************************************************************/
                     37: 
                     38: #include <stdio.h>             /* sprintf */
                     39: #include "gen_defs.h"
                     40: #include "telnet.h"
                     41: 
1.1.1.2 ! root       42: const char* DLLCALL telnet_cmd_desc(uchar cmd)
1.1       root       43: {
                     44:        static char unknown[32];
                     45: 
                     46:        switch(cmd) {
                     47:        case TELNET_IAC:        return("IAC");
                     48:        case TELNET_DONT:       return("DON'T");
                     49:        case TELNET_DO:         return("DO");
                     50:        case TELNET_WONT:       return("WON'T");
                     51:        case TELNET_WILL:       return("WILL");
                     52: 
                     53:        case TELNET_SB:         return("SB");
                     54:        case TELNET_GA:         return("GA");
                     55:        case TELNET_EL:         return("EL");
                     56:        case TELNET_EC:         return("EC");
                     57:        case TELNET_AYT:        return("AYT");
                     58:        case TELNET_AO:         return("AO");
                     59:        case TELNET_IP:         return("IP");
                     60:        case TELNET_BRK:        return("BRK");
                     61:        case TELNET_SYNC:       return("SYNC");
                     62:        case TELNET_NOP:        return("NOP");
                     63: 
                     64:         default:
                     65:                        sprintf(unknown,"%d",cmd);
                     66:             return(unknown);
                     67:        }
                     68: }
                     69: 
                     70: char* telnet_option_descriptions[]={
                     71:        
                     72:         "Binary Transmission"
                     73:        ,"Echo"
                     74:        ,"Reconnection"
                     75:        ,"Suppress Go Ahead"                   
                     76:        ,"Approx Message Size Negotiation"
                     77:        ,"Status"                               
                     78:        ,"Timing Mark"                          
                     79:        ,"Remote Controlled Trans and Echo"     
                     80:        ,"Output Line Width"                   
                     81:        ,"Output Page Size"                     
1.1.1.2 ! root       82:        ,"Output Carriage-Return Disposition"   /* 10 */
1.1       root       83:        ,"Output Horizontal Tab Stops"          
                     84:        ,"Output Horizontal Tab Disposition"    
                     85:        ,"Output Formfeed Disposition"          
1.1.1.2 ! root       86:        ,"Output Vertical Tab Stops"             
1.1       root       87:        ,"Output Vertical Tab Disposition"      
                     88:        ,"Output Linefeed Disposition"          
                     89:        ,"Extended ASCII"                       
                     90:        ,"Logout"                               
1.1.1.2 ! root       91:        ,"Byte Macro"                                                   
        !            92:        ,"Data Entry Terminal"                                  /* 20 */
1.1       root       93:        ,"SUPDUP"
                     94:        ,"SUPDUP Output"
                     95:        ,"Send Location"
                     96:        ,"Terminal Type"
                     97:        ,"End of Record"
                     98:        ,"TACACS User Identification"
                     99:        ,"Output Marking"
                    100:        ,"Terminal Location Number"
1.1.1.2 ! root      101:        ,"Telnet 3270 Regime"                                   
        !           102:        ,"X.3 PAD"                                                              /* 30 */
1.1       root      103:        ,"Negotiate About Window Size"
                    104:        ,"Terminal Speed"
                    105:        ,"Remote Flow Control"
                    106:        ,"Linemode"
                    107:        ,"X Display Location"
                    108:        ,"Environment Option"
                    109:        ,"Authentication Option"
                    110:        ,"Encryption Option"
1.1.1.2 ! root      111:        ,"New Environment Option"                               
        !           112:        ,"TN3270E"                                                              /* 40 */
1.1       root      113: };
                    114: 
1.1.1.2 ! root      115: const char* DLLCALL telnet_opt_desc(uchar opt)
1.1       root      116: {
                    117:        static char unknown[32];
                    118: 
                    119:        if(opt<sizeof(telnet_option_descriptions)/sizeof(char*))
                    120:                return(telnet_option_descriptions[opt]);
                    121: 
                    122:        if(opt==TELNET_EXOPL)
                    123:                return("Extended Options List");
                    124: 
                    125:        sprintf(unknown,"%d",opt);
                    126:     return(unknown);
                    127: }
1.1.1.2 ! root      128: 
        !           129: const uchar DLLCALL telnet_opt_ack(uchar cmd)
        !           130: {
        !           131:        switch(cmd) {
        !           132:                case TELNET_DO:         return TELNET_WILL;
        !           133:                case TELNET_DONT:       return TELNET_WONT;
        !           134:                case TELNET_WILL:       return TELNET_DO;
        !           135:                case TELNET_WONT:       return TELNET_DONT;
        !           136:        }
        !           137:        return 0;
        !           138: }
        !           139: 
        !           140: const uchar DLLCALL telnet_opt_nak(uchar cmd)
        !           141: {
        !           142:        switch(cmd) {
        !           143:                case TELNET_DO:         return TELNET_WONT;
        !           144:                case TELNET_DONT:       return TELNET_WILL;
        !           145:                case TELNET_WILL:       return TELNET_DONT;
        !           146:                case TELNET_WONT:       return TELNET_DO;
        !           147:        }
        !           148:        return 0;
        !           149: }

unix.superglobalmegacorp.com

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