Basic repl
This commit is contained in:
parent
664a6eb838
commit
96044e3482
|
@ -427,6 +427,8 @@ void writeallx(int fd, unsigned char *buf, size_t length) {
|
|||
}
|
||||
}
|
||||
|
||||
bool check_utf8(const unsigned char *data, size_t data_length, bool newline_allowed);
|
||||
|
||||
void read_status(void) {
|
||||
unsigned char status;
|
||||
readallx(0, &status, 1);
|
||||
|
@ -437,8 +439,14 @@ void read_status(void) {
|
|||
unsigned char length;
|
||||
readallx(0, &length, 1);
|
||||
|
||||
readallx(0, own_nick, length);
|
||||
unsigned char nick[256];
|
||||
readallx(0, nick, length);
|
||||
|
||||
if (!check_utf8(nick, length, false)) {
|
||||
errx(1, "Frontend sent a nick with malformed utf-8 or control characters");
|
||||
}
|
||||
|
||||
memcpy(own_nick, nick, length);
|
||||
own_nick_length = length;
|
||||
}
|
||||
|
||||
|
|
24
ethermess.py
24
ethermess.py
|
@ -1,2 +1,26 @@
|
|||
#!/usr/bin/env python3
|
||||
libexec_dir = __LIBEXECDIR__
|
||||
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
|
||||
nick = input('nick> ').encode('utf-8')
|
||||
|
||||
proc = subprocess.Popen(['sudo', libexec_dir + '/ethermess-backend', *sys.argv[1:]], stdin = subprocess.PIPE, stdout = sys.stdout)
|
||||
|
||||
proc.stdin.write(bytes([0, len(nick)]) + nick)
|
||||
proc.stdin.flush()
|
||||
|
||||
print('s - request status, i - request msgid, m - send message, ^D - quit')
|
||||
|
||||
try:
|
||||
while True:
|
||||
proc.stdin.write(input('').encode('utf-8'))
|
||||
proc.stdin.flush()
|
||||
|
||||
except EOFError:
|
||||
proc.stdin.write(b'q')
|
||||
proc.stdin.flush()
|
||||
|
||||
sys.exit(proc.wait())
|
||||
|
|
Loading…
Reference in New Issue