petsciiconv_toascii(telnetline, sizeof(telnetline)); ptr = telnetline + strlen(telnetline); *ptr++ = ISO_CR; *ptr++ = ISO_NL; if(telnet_send(&ts_appstate, telnetline, ptr - telnetline)) {
strcpy(sendline, telnetline); sendlen = strlen(sendline); petsciiconv_toascii(sendline, sendlen); sendline[sendlen++] = ISO_CR; sendline[sendlen++] = ISO_NL; if(telnet_send(&ts_appstate, sendline, sendlen)) {
EK_EVENTHANDLER(simpletelnet_eventhandler, ev, data){  struct ctk_widget *w;  char *ptr;  EK_EVENTHANDLER_ARGS(ev, data);  if(ev == EK_EVENT_INIT) {    /* Create Telnet window. */    ctk_window_new(&telnetwindow, 38, 20, "Simple telnet");        CTK_WIDGET_ADD(&telnetwindow, &telnethostlabel);    CTK_WIDGET_ADD(&telnetwindow, &telnetportlabel);    CTK_WIDGET_ADD(&telnetwindow, &telnethosttextentry);    CTK_WIDGET_ADD(&telnetwindow, &telnetporttextentry);    CTK_WIDGET_ADD(&telnetwindow, &telnetconnectbutton);    CTK_WIDGET_ADD(&telnetwindow, &telnetdisconnectbutton);    CTK_WIDGET_ADD(&telnetwindow, &telnetlinetextentry);    CTK_WIDGET_ADD(&telnetwindow, &telnetsendbutton);        CTK_WIDGET_ADD(&telnetwindow, &telnetsep1);    CTK_WIDGET_ADD(&telnetwindow, &telnettextarea);        CTK_WIDGET_ADD(&telnetwindow, &telnetsep2);    CTK_WIDGET_ADD(&telnetwindow, &telnetstatus);    CTK_WIDGET_FOCUS(&telnetwindow, &telnethosttextentry);           /* Attach as a listener to the CTK button press signal. */    /*    dispatcher_listen(ctk_signal_button_activate);    dispatcher_listen(ctk_signal_window_close);    dispatcher_listen(resolv_signal_found);*/        ctk_window_open(&telnetwindow);  } else if(ev == ctk_signal_button_activate) {        w = (struct ctk_widget *)data;    if(w == (struct ctk_widget *)&telnetsendbutton) {      petsciiconv_toascii(telnetline, sizeof(telnetline));      ptr = telnetline + strlen(telnetline);      *ptr++ = ISO_CR;           *ptr++ = ISO_NL;      if(telnet_send(&ts_appstate, telnetline, ptr - telnetline)) {	/* Could not send. */	ctk_label_set_text(&telnetstatus, "Could not send");	ctk_window_redraw(&telnetwindow);	/*      } else {*/	/* Could send */      }    } else if(w == (struct ctk_widget *)&telnetdisconnectbutton) {      telnet_close(&ts_appstate);      show("Closing...");    } else if(w == (struct ctk_widget *)&telnetconnectbutton) {      connect();      ctk_window_redraw(&telnetwindow);    }  } else if(ev == resolv_event_found) {    if(strcmp(data, telnethost) == 0) {      if(resolv_lookup(telnethost) != NULL) {	connect();      } else {	show("Host not found");      }    }  } else if(ev == ctk_signal_window_close ||	    ev == EK_EVENT_REQUEST_EXIT) {    ek_exit();    ctk_window_close(&telnetwindow);    id = EK_ID_NONE;    LOADER_UNLOAD();  } else if(ev == tcpip_event) {    telnet_app(data);  }}