nserver

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit c4b34755401eae260c5090588db056b2a2ad49ce
parent d1e7a3a05bedb507275ee7ca24b6b3bd2325e782
Author: rsiddharth <s@ricketyspace.net>
Date:   Mon, 23 Dec 2019 21:20:19 -0500

nserver/src/nserve.c: Update nserve.

* nserver/src/nserve.c (nserve): Use `process` to do the actual thing
instead of just barfing out the cmd.

Diffstat:
nserver/src/nserve.c | 14+++++---------
1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/nserver/src/nserve.c b/nserver/src/nserve.c @@ -33,7 +33,7 @@ void nserve(int sock) char *cmd = (char *) calloc(sizeof(char), CMD_MAX_SIZE + 1); check_mem(cmd); - int rc = 0; + int rc = 0, done = 0; do { // clear out, cmd. memset(out, '\0', RSP_SIZE + 1); @@ -43,19 +43,15 @@ void nserve(int sock) ssize_t bytes = slurpsock(cmd, CMD_MAX_SIZE, sock); check(bytes >= 0, "nserve: slurpsock failed"); - rc = check_cmd(cmd, out); + rc = process(cmd, out); if (rc < 0) { - // cmd invalid; quit. - rc = barfsock(out, strlen(out), sock); - check(rc != -1, "barfsock failed"); - - break; + done = 1; } // Write response to socket. - rc = barfsock(cmd, bytes, sock); + rc = barfsock(out, strlen(out), sock); check(rc != -1, "nserve: echo failed"); - } while(1); + } while(done != 1); // Close socket. rc = close(sock);