flash/nor: move variable's declaration in C file
[fw/openocd] / src / server / telnet_server.h
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2
3 /***************************************************************************
4  *   Copyright (C) 2005 by Dominic Rath                                    *
5  *   Dominic.Rath@gmx.de                                                   *
6  *                                                                         *
7  *   Copyright (C) 2007,2008 Ã˜yvind Harboe                                 *
8  *   oyvind.harboe@zylin.com                                               *
9  *                                                                         *
10  *   Copyright (C) 2008 by Spencer Oliver                                  *
11  *   spen@spen-soft.co.uk                                                  *
12  ***************************************************************************/
13
14 #ifndef OPENOCD_SERVER_TELNET_SERVER_H
15 #define OPENOCD_SERVER_TELNET_SERVER_H
16
17 #include <server/server.h>
18
19 #define TELNET_BUFFER_SIZE (10*1024)
20
21 #define TELNET_LINE_HISTORY_SIZE (128)
22 #define TELNET_LINE_MAX_SIZE (10*256)
23
24 enum telnet_states {
25         TELNET_STATE_DATA,
26         TELNET_STATE_IAC,
27         TELNET_STATE_SB,
28         TELNET_STATE_SE,
29         TELNET_STATE_WILL,
30         TELNET_STATE_WONT,
31         TELNET_STATE_DO,
32         TELNET_STATE_DONT,
33         TELNET_STATE_ESCAPE,
34 };
35
36 struct telnet_connection {
37         char *prompt;
38         bool prompt_visible;
39         enum telnet_states state;
40         char line[TELNET_LINE_MAX_SIZE];
41         size_t line_size;
42         size_t line_cursor;
43         char last_escape;
44         char *history[TELNET_LINE_HISTORY_SIZE];
45         size_t next_history;
46         size_t current_history;
47         bool closed;
48 };
49
50 struct telnet_service {
51         char *banner;
52 };
53
54 int telnet_init(char *banner);
55 int telnet_register_commands(struct command_context *command_context);
56 void telnet_service_free(void);
57
58 #endif /* OPENOCD_SERVER_TELNET_SERVER_H */