#include #include "obsolete/driver.h" #include #include #if (SLANG_VERSION < 10400 ) #define SLsmg_Char_Type unsigned short #endif /* Standard set of integer macros .. */ #define get_int32(s) ((((unsigned char*) (s))[0] << 24) | \ (((unsigned char*) (s))[1] << 16) | \ (((unsigned char*) (s))[2] << 8) | \ (((unsigned char*) (s))[3])) #define put_int32(i, s) {((char*)(s))[0] = (char)((i) >> 24) & 0xff; \ ((char*)(s))[1] = (char)((i) >> 16) & 0xff; \ ((char*)(s))[2] = (char)((i) >> 8) & 0xff; \ ((char*)(s))[3] = (char)((i) & 0xff);} #define get_int16(s) ((((unsigned char*) (s))[0] << 8) | \ (((unsigned char*) (s))[1])) #define put_int16(i, s) {((unsigned char*)(s))[0] = ((i) >> 8) & 0xff; \ ((unsigned char*)(s))[1] = (i) & 0xff;} #define get_int8(s) ((((unsigned char*) (s))[0] )) #define put_int8(i, s) { ((unsigned char*)(s))[0] = (i) & 0xff;} #define INIT_TTY 1 #define SET_ABORT_FUNCTION 2 #define GETKEY 3 #define RESET_TTY 4 #define KP_GETKEY 5 #define UNGETKEY 6 #define SETVAR 7 #define GETVAR 8 #define KP_INIT 9 /* screen mgmt */ #define SMG_FILL_REGION 10 #define SMG_SET_CHAR_SET 11 #define SMG_SUSPEND_SMG 12 #define SMG_RESUME_SMG 13 #define SMG_ERASE_EOL 14 #define SMG_GOTORC 15 #define SMG_ERASE_EOS 16 #define SMG_REVERSE_VIDEO 17 #define SMG_SET_COLOR 18 #define SMG_NORMAL_VIDEO 19 #define SMG_PRINTF 20 #define SMG_VPRINTF 21 #define SMG_WRITE_STRING 22 #define SMG_WRITE_NSTRING 23 #define SMG_WRITE_CHAR 24 #define SMG_WRITE_NCHARS 25 #define SMG_WRITE_WRAPPED_STRING 26 #define SMG_CLS 27 #define SMG_REFRESH 28 #define SMG_TOUCH_LINES 29 #define SMG_TOUCH_SCREEN 30 #define SMG_INIT_SMG 31 #define SMG_REINIT_SMG 32 #define SMG_RESET_SMG 33 #define SMG_CHAR_AT 34 #define SMG_SET_SCREEN_START 35 #define SMG_DRAW_HLINE 36 #define SMG_DRAW_VLINE 37 #define SMG_DRAW_OBJECT 38 #define SMG_DRAW_BOX 39 #define SMG_GET_COLUMN 40 #define SMG_GET_ROW 41 #define SMG_FORWARD 42 #define SMG_WRITE_COLOR_CHARS 43 #define SMG_READ_RAW 44 #define SMG_WRITE_RAW 45 #define SMG_SET_COLOR_IN_REGION 46 /* ops for all the tt_ functions */ #define TT_FLUSH_OUTPUT 50 #define TT_SET_SCROLL_REGION 51 #define TT_RESET_SCROLL_REGION 52 #define TT_REVERSE_VIDEO 53 #define TT_BOLD_VIDEO 54 #define TT_BEGIN_INSERT 55 #define TT_END_INSERT 56 #define TT_DEL_EOL 57 #define TT_GOTO_RC 58 #define TT_DELETE_NLINES 59 #define TT_DELETE_CHAR 60 #define TT_ERASE_LINE 61 #define TT_NORMAL_VIDEO 62 #define TT_CLS 63 #define TT_BEEP 64 #define TT_REVERSE_INDEX 65 #define TT_SMART_PUTS 66 #define TT_WRITE_STRING 67 #define TT_PUTCHAR 68 #define TT_INIT_VIDEO 69 #define TT_RESET_VIDEO 70 #define TT_GET_TERMINFO 71 #define TT_GET_SCREEN_SIZE 72 #define TT_SET_CURSOR_VISIBILITY 73 #define TT_SET_MOUSE_MODE 74 #define TT_INITIALIZE 75 #define TT_ENABLE_CURSOR_KEYS 76 #define TT_SET_TERM_VTXXX 77 #define TT_SET_COLOR_ESC 78 #define TT_WIDE_WIDTH 79 #define TT_NARROW_WIDTH 80 #define TT_SET_ALT_CHAR_SET 81 #define TT_WRITE_TO_STATUS_LINE 82 #define TT_DISABLE_STATUS_LINE 83 #define TT_TGETSTR 84 #define TT_TGETNUM 85 #define TT_TGETFLAG 86 #define TT_TIGETENT 87 #define TT_TIGETSTR 88 #define TT_TIGETNUM 89 #define SLTT_GET_COLOR_OBJECT 90 #define TT_SET_COLOR_OBJECT 91 #define TT_SET_COLOR 92 #define TT_SET_MONO 93 #define TT_ADD_COLOR_ATTRIBUTE 94 #define TT_SET_COLOR_FGBG 95 /* aux tty functions */ #define ISATTY 100 #define EFORMAT 101 #define SIGNAL 102 #define SIGNAL_CHECK 103 /* read/write global variables */ #define esl_baud_rate 1 #define esl_read_fd 2 #define esl_abort_char 3 #define esl_ignore_user_abort 4 #define esl_input_buffer_len 5 #define esl_keyboard_quit 6 #define esl_last_key_char 7 #define esl_rl_eof_char 8 #define esl_rline_quit 9 #define esl_screen_rows 10 #define esl_screen_cols 11 #define esl_tab_width 12 #define esl_newline_behaviour 13 #define esl_error 14 #define esl_version 15 #define esl_backspace_moves 16 #define esl_display_eight_bit 17 /* signals */ #define SL_SIGINT 1 #define SL_SIGTSTP 2 #define SL_SIGQUIT 3 #define SL_SIGTTOU 4 #define SL_SIGTTIN 5 #define SL_SIGWINCH 6 static long sl_start(); static int sl_stop(), sl_read(); static struct driver_entry sl_driver_entry; static int wait_for = 0; static int signal_cought = 0; static int sig_to_x(int x) { switch (x ) { case SIGINT: return SL_SIGINT; case SIGTSTP: return SL_SIGTSTP; case SIGQUIT: return SL_SIGQUIT; case SIGTTOU: return SL_SIGTTOU; case SIGTTIN: return SL_SIGTTIN; case SIGWINCH: return SL_SIGWINCH; default: return -1; } } static void sig_handler(int sig) { signal_cought = sig_to_x(sig); } static int x_to_sig(int x) { switch (x ) { case SL_SIGINT: return SIGINT; case SL_SIGTSTP: return SIGTSTP; case SL_SIGQUIT: return SIGQUIT; case SL_SIGTTOU: return SIGTTOU; case SL_SIGTTIN: return SIGTTIN; case SL_SIGWINCH: return SIGWINCH; default: return -1; } } SLsmg_Char_Type *decode_smg_char_type(char **buf) { static SLsmg_Char_Type mbuf[256]; int i; char *b = *buf; int len = get_int32(*buf); *buf+=4; for(i=0; i