Skip to content

Commit 75590f8

Browse files
committed
Update readme.
1 parent 9bff327 commit 75590f8

1 file changed

Lines changed: 44 additions & 12 deletions

File tree

README.md

Lines changed: 44 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,12 @@ History and output buffering can be disabled to reduce memory requirements for u
2727
- Default commands (`help`, `clear`, `login`, and `logout`)
2828

2929
Users can be registered so that only certain commands are available to certain users.
30-
Login is possibly with either password only or with usernames and optional passwords.
30+
Login is possible with either password only or with usernames and optional passwords.
3131
Only users with a level matching the minimum required level for a command can execute the command.
3232

33-
Commands are registered with a command, the minimum user level required (if users are enabled),
34-
the minimum and maximum number of arguments that are allowed, and a description.
35-
The description is automatically printed when the command is invoked with "-h/--help" flags or when the built-in
36-
help command is called.
33+
Commands are registered with a command, the minimum user level required (if users are enabled), a description, and
34+
optionally a pattern with some options (if pattern matching is enabled).
35+
The description along with any pattern and options (if used) are automatically printed when the built-in help command is called.
3736

3837
#### Pattern Matching
3938

@@ -50,7 +49,8 @@ The following syntax can be used in patterns:
5049
| `a\|(b c)` or `a\|{b c}` | Matches `a` or `b c`. |
5150
| `...` | Matches none or all remaining tokens. |
5251

53-
The pattern matching system currently only supports matching word-tokens (i.e. no matches inside words).
52+
- The pattern matching system currently only supports matching word-tokens (i.e. no matches inside words).
53+
- The pattern matcher is recursive and stack requirements will increase with pattern complexity.
5454

5555
## Usage
5656

@@ -61,7 +61,7 @@ The pattern matching system currently only supports matching word-tokens (i.e. n
6161

6262
void output(void * arg, const char * str)
6363
{
64-
printf("%s", str);
64+
printf("%s", str); // Or send through serial interface
6565
}
6666

6767
tclie_t tclie;
@@ -72,9 +72,9 @@ tclie_init(&tclie, output, NULL);
7272
7373
```c
7474
static const tclie_user_t users[] = {
75-
// Name, password, level
76-
{"debug", NULL, 1},
77-
{"admin", "12345", 2}
75+
// Name, password, level
76+
{"debug", NULL, 1}, // No password required
77+
{"admin", "12345", 2}
7878
};
7979
8080
tclie_reg_users(&tclie, users, 2);
@@ -92,7 +92,7 @@ int echo(void * arg, int argc, const char ** argv)
9292
}
9393

9494
static const tclie_cmd_t cmds[] = {
95-
// Name, callback, min user level, min args, max args, description (for help)
95+
// Name, callback, minimum user level, description (for help)
9696
{"echo", echo, 1, "Echo input."}
9797
};
9898

@@ -110,6 +110,17 @@ while (1) {
110110

111111
See the examples directory for more details.
112112

113+
### Logging
114+
115+
In a multithreaded environment it can be useful to be able to log stuff without disturbing the prompt:
116+
117+
```c
118+
tclie_log(&tclie, "Some message...\r\n");
119+
120+
char buf[64];
121+
tclie_log_printf(&tclie, buf, sizeof(buf), "Hello %s\r\n", "world!");
122+
```
123+
113124
## Supported Keyboard Shortcuts
114125
115126
| Shortcut | Description |
@@ -136,5 +147,26 @@ See the examples directory for more details.
136147
| Alt+f | Move cursor forward one word. |
137148
| Alt+r | Cancel changes to history line. |
138149
| Tab | Tab-complete at cursor or select from multiple matches. |
139-
| Esc | Exit tab-completion or reverse search mode. |
150+
| Esc | Exit tab-completion or reverse search mode. |
151+
152+
*Note! `Esc` needs to be pressed twice since it is impossible to differentiate from an escape sequence otherwise.*
140153
154+
## Miscellaneous
155+
156+
### Telnet
157+
158+
Telnet newlines (`<CR><NUL>`) are automatically handled but it may be necessary to tell connecting clients (e.g.
159+
PuTTY) how to behave.
160+
This can be done by sending the following sequences to the client:
161+
162+
- `IAC DO ECHO`: Tell client to echo received characters from server.
163+
- `IAC WILL ECHO`: Tell client that the server will echo back received characters.
164+
- `IAC DO SUPPRESS-GO-AHEAD`: Tell client to not send `GO AHEAD` when transmitting.
165+
- `IAC WILL SUPPRESS-GO-AHEAD`: Tell client that the server won't send `GO AHEAD` when transmitting.
166+
167+
```c
168+
const char options[] = {255, 253, 1, // IAC DO ECHO
169+
255, 251, 1, // IAC WILL ECHO
170+
255, 253, 3, // IAC DO SUPPRESS-GO-AHEAD
171+
255, 251, 3}; // IAC WILL SUPPRESS-GO-AHEAD
172+
```

0 commit comments

Comments
 (0)