diff options
author | dzwdz | 2023-01-25 20:16:22 +0100 |
---|---|---|
committer | dzwdz | 2023-01-25 20:16:22 +0100 |
commit | 17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 (patch) | |
tree | b3d4aed1f408edcb17fe5c86fccaeacaa2a5a48a /src/user/app/init/driver/termcook.c | |
parent | 2ad6ee8ed15d1bf898645a16dbc06991a3c1425e (diff) |
style: typedef structs, shorter namespaces
I've wanted to do this for a while, and since I've just had a relatively
large refactor commit (pcpy), this is as good of a time as any.
Typedefing structs was mostly inspired by Plan 9's coding style. It makes
some lines of code much shorter at basically no expense.
Everything related to userland kept old-style struct definitions, so as not
to force that style onto other people.
I also considered changing SCREAMING_ENUM_FIELDS to NicerLookingCamelcase,
but I didn't, just in case that'd be confusing.
Diffstat (limited to 'src/user/app/init/driver/termcook.c')
-rw-r--r-- | src/user/app/init/driver/termcook.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/user/app/init/driver/termcook.c b/src/user/app/init/driver/termcook.c index 8845839..a76f3a8 100644 --- a/src/user/app/init/driver/termcook.c +++ b/src/user/app/init/driver/termcook.c @@ -10,21 +10,21 @@ enum tstate { CSI, }; -static void w_output(handle_t output, const char *buf, size_t len) { +static void w_output(hid_t output, const char *buf, size_t len) { size_t pos = 0; while (pos < len) { - int ret = _syscall_write(output, buf + pos, len - pos, pos, 0); + int ret = _sys_write(output, buf + pos, len - pos, pos, 0); if (ret < 0) break; pos += ret; } } -static void line_editor(handle_t input, handle_t output) { +static void line_editor(hid_t input, hid_t output) { char readbuf[16], linebuf[256]; size_t linepos = 0; enum tstate state = Normal; for (;;) { - int readlen = _syscall_read(input, readbuf, sizeof readbuf, -1); + int readlen = _sys_read(input, readbuf, sizeof readbuf, -1); if (readlen < 0) return; for (int i = 0; i < readlen; i++) { char c = readbuf[i]; @@ -39,13 +39,13 @@ static void line_editor(handle_t input, handle_t output) { } break; case 3: /* C-c */ - _syscall_exit(1); + _sys_exit(1); case 4: /* EOT, C-d */ if (linepos > 0) { w_output(output, linebuf, linepos); linepos = 0; } else { - _syscall_write(output, NULL, 0, 0, 0); /* EOF */ + _sys_write(output, NULL, 0, 0, 0); /* EOF */ } break; case '\n': @@ -82,14 +82,14 @@ static void line_editor(handle_t input, handle_t output) { } void termcook(void) { - handle_t stdin_pipe[2] = {-1, -1}; - if (_syscall_pipe(stdin_pipe, 0) < 0) + hid_t stdin_pipe[2] = {-1, -1}; + if (_sys_pipe(stdin_pipe, 0) < 0) return; if (!fork()) { /* the caller continues in a child process, * so it can be killed when the line editor quits */ - _syscall_dup(stdin_pipe[0], 0, 0); + _sys_dup(stdin_pipe[0], 0, 0); close(stdin_pipe[0]); close(stdin_pipe[1]); return; @@ -99,5 +99,5 @@ void termcook(void) { line_editor(0, stdin_pipe[1]); exit(0); } - exit(_syscall_await()); + exit(_sys_await()); } |