nserver

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

commit bb9cfab26a859a0bd2fa7b8d05b91156d066d6d0
parent 99e51b54078080c000c5520b56030aceb3678f34
Author: rsiddharth <s@ricketyspace.net>
Date:   Mon,  2 Dec 2019 20:56:15 -0500

nserver: Add check_args.

* nserver/src/ncmd.c (check_args): New function.

Diffstat:
nserver/src/ncmd.c | 17+++++++++++++++++
1 file changed, 17 insertions(+), 0 deletions(-)

diff --git a/nserver/src/ncmd.c b/nserver/src/ncmd.c @@ -151,3 +151,20 @@ int find_function(struct bstrList *cmd_parts) return NS_NOP; } +int check_args(struct bstrList *cmd_parts, int argc) +{ + check(cmd_parts != NULL, "cmd_parts is NULL"); + check(cmd_parts->qty == argc, "qty check failed"); + + bstring part = NULL; + for (int i = 0; i < argc; i++) { + part = cmd_parts->entry[i]; + + check(blength(part) > 0, "part %d empty", i); + } + + return 0; + error: + return -1; +} +