1/** 2 * \file 3 * \brief General definitions for terminal client library. 4 */ 5 6/* 7 * Copyright (c) 2012, ETH Zurich. 8 * All rights reserved. 9 * 10 * This file is distributed under the terms in the attached LICENSE file. 11 * If you do not find this file, copies can be found by writing to: 12 * ETH Zurich D-INFK, CAB F.78, Universitaetstrasse 6, CH-8092 Zurich, 13 * Attn: Systems Group. 14 */ 15 16#ifndef LIBTERM_CLIENT_DEFS_H 17#define LIBTERM_CLIENT_DEFS_H 18 19#include <barrelfish/waitset.h> 20#include <collections/list.h> 21#include <errors/errno.h> 22#include <term/defs.h> 23 24#include <stdbool.h> 25#include <stdint.h> 26 27typedef uint32_t term_filter_id_t; 28typedef void term_filter_fn(char **data, size_t *length); 29 30typedef uint32_t term_trigger_id_t; 31 32/** 33 * Terminal client state. 34 */ 35struct term_client { 36 /** 37 * Arbitraty user state pointer. Passed to callback functions. 38 */ 39 void *st; 40 41 /** 42 * \note read-only 43 * Waitset used for incoming characters. 44 */ 45 struct waitset *read_ws; 46 47 /** 48 * \note read-only 49 * Waitset used for outgoing characters. 50 */ 51 struct waitset *write_ws; 52 53 /** 54 * \note read-only 55 * Waitset used for configuration messages. 56 */ 57 struct waitset *conf_ws; 58 59 /** 60 * Are received characters echoed? Default: true. 61 */ 62 bool echo; 63 64 /** 65 * Does a term_client_read return at most one line? Default: true. 66 */ 67 bool line_mode; 68 69 /** 70 * Whether or not read is non-blocking. 71 */ 72 bool non_blocking_read; 73 74 /** 75 * \internal 76 * Callback when characters arrive and we are in non_blocking_read. 77 */ 78 term_characters_handler_fn *chars_cb; 79 80 /** 81 * \internal 82 * Callback when a asynchronous error happens. 83 */ 84 term_async_err_handler_fn *err_cb; 85 86 /** 87 * \internal 88 * Is the connection to the terminal server established. 89 */ 90 bool connected; 91 92 /** 93 * \internal 94 * Binding used for incoming characters. 95 */ 96 struct terminal_binding *in_binding; 97 98 /** 99 * \internal 100 * Binding used for outgoing characters. 101 */ 102 struct terminal_binding *out_binding; 103 104 /** 105 * \internal 106 * Binding used for configuration messages. 107 */ 108 struct terminal_config_binding *conf_binding; 109 110 /** 111 * \internal 112 * If we receive more characters in a single flounder message than the 113 * user requested via term_client_blocking_read, the characters are buffered 114 * in this buffer. Subsequent reads are first served from this buffer. 115 */ 116 char *readbuf; 117 118 /** 119 * \internal 120 * If the readbuf is not NULL, contains the number of characters in the 121 * readbuf. 122 */ 123 size_t readbuf_len; 124 125 /** 126 * \internal 127 * If the readbuf is not NULL, points the next character not yet read by 128 * the user domain via term_client_blocking_read. 129 */ 130 char *readbuf_pos; 131 132 /** 133 * \internal 134 * Linked-list of input filters that are applied to the raw characters 135 * received via flounder. 136 */ 137 collections_listnode *input_filters; 138 139 /** 140 * \internal 141 * Linked-list of output filters that are applied to the characters 142 * supplied by the user via term_client_write() or 143 * term_client_write_non_block() before they are sent via flounder. 144 */ 145 collections_listnode *output_filters; 146 147 /** 148 * \internal 149 * Linked-list of echo filters that are applied to the raw characters 150 * recevied via flounder before they are sent out via flounder again. 151 * Note that neither the input nor the output filters are applied to the 152 * characters echoed. 153 */ 154 collections_listnode *echo_filters; 155 156 /** 157 * \internal 158 * Maximum input filter id ever assigned. 159 */ 160 term_filter_id_t max_input_filter_id; 161 162 /** 163 * \internal 164 * Maximum output filter id ever assigned. 165 */ 166 term_filter_id_t max_output_filter_id; 167 168 /** 169 * \internal 170 * Maximum echo filter id ever assigned. 171 */ 172 term_filter_id_t max_echo_filter_id; 173 174 /** 175 * \internal 176 * Linked-list of character triggers. The triggers are processed on the 177 * raw characters received via the flounder interface. 178 */ 179 collections_listnode *triggers; 180 181 /** 182 * \internal 183 * Maximum trigger id ever assigned. 184 */ 185 term_trigger_id_t max_trigger_id; 186 187 term_filter_id_t cr2lf_id; 188 term_filter_id_t lf2crlf_id; 189 term_filter_id_t ctrlhat_id; 190 term_trigger_id_t ctrlc_id; 191}; 192 193#endif // LIBTERM_CLIENT_DEFS_H 194