Logo 
Search:

Networking Articles

Submit Article
Home » Articles » Networking » TCP/IPRSS Feeds

TCP/IP program to print a single character on a Network Virtual Terminal

Posted By: Milind Mishra     Category: Networking     Views: 2928

TCP/IP program to print a single character on a Network Virtual Terminal.

Code for TCP/IP program to print a single character on a Network Virtual Terminal in Networking

#include <sys/types.h>
#include <stdio.h>
#include "telnet.h"int    tcout(char *cap, FILE *tfp);
int    xputc(char ch, FILE *fp);

/*ARGSUSED*/int
ttputc(FILE *sfp, FILE *tfp, int c)
{
    static    last_char;
    int    tc;

    if (rcvbinary) { 
        (void) xputc(c, tfp);    /* print uninterpretted    */return 0;
    }
    if (synching)            /* no data, if in SYNCH    */return 0;

    if ((last_char == VPCR && c == VPLF) ||
        (last_char == VPLF && c == VPCR)) {
        (void) xputc(VPLF, tfp);
        last_char = 0;
        return 0;
    }
    if (last_char == VPCR)
        (void) tcout("cr", tfp);
    elseif (last_char == VPLF)
        (void) tcout("do", tfp);
    if (c >= ' ' && c < TCIAC)    /* printable ASCII    */
        (void) xputc(c, tfp);
    else {                /* NVT special        */switch (c) {
        case VPLF:         /* see if CR follows    */case VPCR:    tc = 1;    /* see if LF follows    */break;
        case VPBEL:    tc = tcout("bl", tfp);
                break;
        case VPBS:    tc = tcout("bc", tfp);
                break;
        case VPHT:    tc = tcout("ta", tfp);
                break;
        case VPVT:    tc = tcout("do", tfp);
                break;
        case VPFF:    tc = tcout("cl", tfp);
                break;
        default:
            tc = 1;
            break;    /* no action */
        }
        if (!tc)        /* if no termcap, assume ASCII */
            (void) xputc(c, tfp);
    }
    last_char = c;
    return 0;
}
  
Share: 



Milind Mishra
Milind Mishra author of TCP/IP program to print a single character on a Network Virtual Terminal is from India.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!