📄 sty_tn.c
字号:
/* $Header: /usr/cvsroot/target/src/wrn/wm/demo/lib/sty_tn.c,v 1.2 2001/11/08 15:56:30 tneale Exp $ *//* * Copyright (C) 1999-2005 Wind River Systems, Inc. * All rights reserved. Provided under license only. * Distribution or other use of this software is only * permitted pursuant to the terms of a license agreement * from Wind River Systems (and is otherwise prohibited). * Refer to that license agreement for terms of use. *//**************************************************************************** * Copyright 1993-1997 Epilogue Technology Corporation. * Copyright 1998 Integrated Systems, Inc. * All rights reserved. ****************************************************************************//* * $Log: sty_tn.c,v $ * Revision 1.2 2001/11/08 15:56:30 tneale * Updated for newest file layout * * Revision 1.1.1.1 2001/11/05 17:48:43 tneale * Tornado shuffle * * Revision 2.11 2001/01/19 22:23:55 paul * Update copyright. * * Revision 2.10 2000/03/17 00:12:48 meister * Update copyright message * * Revision 2.9 2000/03/13 21:22:11 paul * Removed some code that we are no longer working on. * * Revision 2.8 1999/02/18 04:41:36 wes * fixed printf format problem * * Revision 2.7 1998/07/02 06:55:40 sra * Make Snark restartable under pSOS, and other minor cleanups. * * Revision 2.6 1998/02/25 04:57:43 sra * Update copyrights. * * Revision 2.5 1997/03/20 06:53:16 sra * DFARS-safe copyright text. Zap! * * Revision 2.4 1997/02/25 10:58:16 sra * Update copyright notice, dust under the bed. * * Revision 2.3 1996/10/29 03:03:14 sra * Duh, maybe we should free the sty when we close the connection? * Another ancient bug nailed thanks to Purify.... * * Revision 2.2 1996/10/26 08:03:42 sra * Fiddle things so that we always include attache/h/glue.h. * * Revision 2.1 1996/03/22 10:05:39 sra * Update copyrights prior to Attache 3.2 release. * * Revision 2.0 1995/05/10 22:38:15 sra * Attache release 3.0. * * Revision 1.5 1995/04/23 01:10:39 sra * More header files. * * Revision 1.4 1995/01/06 00:52:48 sra * Update copyright notice for 2.1 release. * * Revision 1.3 1994/09/04 06:13:38 sra * Clean up antique type names and install macros. * * Revision 1.2 1993/07/30 23:45:23 sra * Cosmetic changes to make Borland C++ 3.1 happy. * * Revision 1.1 1993/07/05 21:53:30 sra * Initial revision * *//* [clearcase]modification history-------------------01a,19apr05,job update copyright notices*//* * Sty driver code for Attache telnet. */#include <stdlib.h>#include <wrn/wm/attache/config.h>#include <wrn/wm/attache/timer.h>#include <wrn/wm/attache/net.h>#include <wrn/wm/attache/packet.h>#if INSTALL_ATTACHE_TCP#include <wrn/wm/attache/route.h>#include <wrn/wm/attache/ip.h>#include <wrn/wm/attache/tcp.h>#endif#include <wrn/wm/attache/tn.h>#include <wrn/wm/attache/glue.h>#include <wrn/wm/demo/sty.h>/* Debugging frob */#ifndef TNSTY_COUNT_BLOCKAGES#define TNSTY_COUNT_BLOCKAGES 0#endifstatic void stytn_driver_write (struct sty *sty, unsigned char *text, size_t length, void *tn){ if (tn && text && length) (void) tn_send_text(tn, text, length);}static void stytn_driver_close(struct sty *sty, void *tn){ if (tn) (void) tn_send_close(tn);}static struct sty_driver stytn_driver = { stytn_driver_write, stytn_driver_close};/* Just collect characters from the keyboard. */static void stytn_text (struct tn_connection *tn, unsigned char text[], unsigned length){ sty_receive(tn_get_cookie(tn), text, length);}/* Window control stuff for TELNET. */unsigned stytn_space_initial = STY_RING_SIZE;unsigned stytn_space_left(struct tn_connection *tn){ return sty_window(tn_get_cookie(tn));}static void stytn_open(struct tn_connection *tn){ struct sty *sty = (struct sty *) GLUE_ALLOC(sizeof(*sty)); if (!sty) { tn_abort(tn); } else { tn_set_cookie(tn, sty); sty_open(sty, &stytn_driver, 0, tn); (void) tn_send_negotiation(tn, TN_OPT_ECHO, 0, 1); }}static void stytn_ip(struct tn_connection *tn){ struct sty *sty = tn_get_cookie(tn); if (sty) sty->flags |= STY_FLAG_INTERRUPTED;}static void stytn_ao(struct tn_connection *tn){ struct sty *sty = tn_get_cookie(tn); if (sty) sty->flags |= STY_FLAG_ABORTED;}static void stytn_ayt(struct tn_connection *tn){ struct sty *sty = tn_get_cookie(tn); if (sty) { bits32_t now = GLUE_NOW(); sty_printf(sty, "[It's now %lu:%02lu:%02lu.%03lu Beandorfian Standard Time]\n", (now/3600000L), (now/60000L)%60, (now/1000L)%60, now%1000L); }}static void stytn_close(struct tn_connection *tn){ struct sty *sty = tn_get_cookie(tn); if (sty) { sty_close(sty); GLUE_FREE(sty); tn_set_cookie(tn, 0); }}#if TNSTY_COUNT_BLOCKAGESlong stytn_blockages = 0;#endifstatic void stytn_error(struct tn_connection *tn, enum tn_error code){ struct sty *sty = tn_get_cookie(tn); switch (code) { case TN_ERROR_WINDOW_CLOSED: sty->flags |= STY_FLAG_BLOCKED;#if STYTN_COUNT_BLOCKAGES stytn_blockages++;#endif return; case TN_ERROR_WINDOW_OPENED: sty->flags &= ~STY_FLAG_BLOCKED;#if STYTN_COUNT_BLOCKAGES stytn_blockages--;#endif return; default: return; }}static int stytn_echo (struct tn_connection *tn, enum tn_ctl control, enum tn_opt option, unsigned char *text, unsigned text_length, int entire){ struct sty *sty = tn_get_cookie(tn); if (sty) { switch (control) { case TN_CTL_DO: sty->flags |= STY_FLAG_ECHOING; return 1; case TN_CTL_DONT: sty->flags &= ~STY_FLAG_ECHOING; return 0; default: /* Make GCC -Wall happy */ break; } } return 0;}static tn_option_dispatch_vector stytn_options = { tn_handle_transmit_binary, /* TN_OPT_TRANSMIT_BINARY */ stytn_echo, /* TN_OPT_ECHO */ 0, /* TN_OPT_RCP */ tn_handle_suppress_go_ahead, /* TN_OPT_SUPPRESS_GO_AHEAD */ 0, /* TN_OPT_NAMS */ tn_handle_status, /* TN_OPT_STATUS */ 0, /* TN_OPT_TIMING_MARK */ 0, /* TN_OPT_RCTE */ 0, /* TN_OPT_NAOL */ 0, /* TN_OPT_NAOP */ 0, /* TN_OPT_NAOCRD */ 0, /* TN_OPT_NAOHTS */ 0, /* TN_OPT_HAOHTD */ 0, /* TN_OPT_NAOFFD */ 0, /* TN_OPT_NAOVTS */ 0, /* TN_OPT_NAOVTD */ 0, /* TN_OPT_NAOLFD */ 0, /* TN_OPT_EXTEND_ASCII */ 0, /* TN_OPT_LOGOUT */ 0, /* TN_OPT_BM */ 0, /* TN_OPT_DET */ 0, /* TN_OPT_SUPDUP */ 0, /* TN_OPT_SUPDUP_OUTPUT */ 0, /* TN_OPT_SEND_LOCATION */ 0, /* TN_OPT_TERMINAL_TYPE */ tn_handle_end_of_record, /* TN_OPT_END_OF_RECORD */ 0, /* TN_OPT_TUID */ 0, /* TN_OPT_OUTMRK */ 0, /* TN_OPT_TTYLOC */ 0, /* TN_OPT_3270_REGIME */ 0, /* TN_OPT_X3_PAD */ 0, /* TN_OPT_NAWS */ 0, /* TN_OPT_TERMINAL_SPEED */ 0, /* TN_OPT_TOGGLE_FLOW_CONTROL */ 0, /* TN_OPT_LINEMODE */ 0 /* TN_OPT_XDISPLOC */};struct tn_dispatch stytn_dispatch = { stytn_text, /* Text */ stytn_ip, /* IP */ stytn_ao, /* AO */ stytn_ayt, /* AYT */ 0, /* EL */ 0, /* EC */ 0, /* EOR */ 0, /* BRK */ 0, /* GA */ stytn_open, /* Open */ stytn_close, /* Close */ stytn_error, /* Error */ stytn_options /* Option dispatch vector */};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -