summaryrefslogtreecommitdiffstats
path: root/lib/keystroke.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/keystroke.h')
-rw-r--r--lib/keystroke.h30
1 files changed, 17 insertions, 13 deletions
diff --git a/lib/keystroke.h b/lib/keystroke.h
index 76fba15e..70aa120b 100644
--- a/lib/keystroke.h
+++ b/lib/keystroke.h
@@ -22,19 +22,13 @@
#ifndef _ZEBRA_KEYSTROKE_H
#define _ZEBRA_KEYSTROKE_H
-#include <stddef.h>
-#include <stdint.h>
-#include <stdbool.h>
+#include "misc.h"
#include <arpa/telnet.h>
#include "zassert.h"
#include "vio_fifo.h"
-#ifndef Inline
-#define Inline static inline
-#endif
-
/*==============================================================================
* Keystroke buffering
*/
@@ -53,12 +47,14 @@ enum keystroke_type
ks_type_reserved = 0x0F,
} ;
+typedef enum keystroke_type keystroke_type_t ;
CONFIRM(ks_type_count <= ks_type_reserved) ;
enum keystroke_null
{
knull_not_eof,
- knull_eof
+ knull_eof,
+ knull_timed_out,
};
enum keystroke_flags
@@ -74,22 +70,30 @@ enum keystroke_flags
kf_type_mask = 0x0F, /* extraction of type */
} ;
+typedef enum keystroke_type keystroke_flags_t ;
+
+/* The keystroke type and flags are designed so that they can be packed
+ * together as a single byte, the first of a "compound character".
+ */
+typedef uint8_t keystroke_compound_t ;
-CONFIRM(ks_type_reserved == (enum keystroke_type)kf_type_mask) ;
+CONFIRM(ks_type_reserved == (keystroke_type_t)kf_type_mask) ;
+CONFIRM((kf_compound | kf_flag_mask | kf_type_mask) <= 0xFF) ;
typedef struct keystroke* keystroke ;
typedef struct keystroke_stream* keystroke_stream ;
struct keystroke
{
- enum keystroke_type type ;
- uint8_t flags ; /* the kf_flag_mask flags */
+ keystroke_type_t type ;
+ keystroke_flags_t flags ; /* just the kf_flag_mask bits */
uint32_t value ;
unsigned len ;
uint8_t buf[keystroke_max_len] ;
} ;
+typedef struct keystroke keystroke_t[1] ;
#define keystroke_iac_callback_args void* context, keystroke stroke
typedef bool (keystroke_callback)(keystroke_iac_callback_args) ;
@@ -175,7 +179,7 @@ keystroke_stream_new(uint8_t csi_char, keystroke_callback* iac_callback,
void* iac_callback_context) ;
extern void
-keystroke_stream_set_eof(keystroke_stream stream) ;
+keystroke_stream_set_eof(keystroke_stream stream, bool timed_out) ;
extern keystroke_stream
keystroke_stream_free(keystroke_stream stream) ;
@@ -188,7 +192,7 @@ keystroke_stream_eof(keystroke_stream stream) ;
extern void
keystroke_input(keystroke_stream stream, uint8_t* ptr, size_t len,
keystroke steal) ;
-extern int
+extern bool
keystroke_get(keystroke_stream stream, keystroke stroke) ;
#endif /* _ZEBRA_KEYSTROKE_H */