summaryrefslogtreecommitdiffstats
path: root/nserver/src/ncmd.c
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2020-04-14 20:53:33 -0400
committerrsiddharth <s@ricketyspace.net>2020-04-17 20:56:37 -0400
commit6dac5422ab8b390b8e4d6ecf0313c9c9f448f54a (patch)
tree268f8ecb989c81bb227ffbccc79a57a8294e8406 /nserver/src/ncmd.c
parent09f04a6bdd80450ab8a972262cc07c5cbf0aa0fa (diff)
nserver: ncmd.h: Add NS_LOAD.
* nserver/src/ncmd.c (find_function): Add handling to find NS_LOAD. (call_function): Add handling for NS_LOAD. * nserver/src/ncmd.h (FUNCTIONS): Add NS_LOAD * nserver/tests/ncmd_tests.c (test_find_function) (test_call_function, test_process): Update tests to check the correctness of NS_LOAD.
Diffstat (limited to 'nserver/src/ncmd.c')
-rw-r--r--nserver/src/ncmd.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/nserver/src/ncmd.c b/nserver/src/ncmd.c
index 6b9298c..6b0be37 100644
--- a/nserver/src/ncmd.c
+++ b/nserver/src/ncmd.c
@@ -109,6 +109,7 @@ int find_function(struct bstrList *cmd_parts)
struct tagbstring fdelete = bsStatic("/delete");
struct tagbstring flist = bsStatic("/list");
struct tagbstring fstore = bsStatic("/store");
+ struct tagbstring fload = bsStatic("/load");
check(cmd_parts != NULL, "cmd_parts is NULL");
check(cmd_parts->qty > 0, "qty check failed");
@@ -135,6 +136,8 @@ int find_function(struct bstrList *cmd_parts)
return NS_LIST;
} else if (bstricmp(cmd_name, &fstore) == 0) {
return NS_STORE;
+ } else if (bstricmp(cmd_name, &fload) == 0) {
+ return NS_LOAD;
} else {
return NS_NOP;
}
@@ -291,6 +294,20 @@ int call_function(int func, struct bstrList *cmd_parts, char *out)
}
strncpy(out, "OK\n", RSP_SIZE);
break;
+ case NS_LOAD:
+ if(check_args(cmd_parts, 3) != 0) {
+ strncpy(out, "error: command invalid\n", RSP_SIZE);
+
+ return -1;
+ }
+ if (ssload(bdata(cmd_parts->entry[1]),
+ bdata(cmd_parts->entry[2])) < 0) {
+ strncpy(out, "error: load failed\n", RSP_SIZE);
+
+ return -1;
+ }
+ strncpy(out, "OK\n", RSP_SIZE);
+ break;
default:
strncpy(out, "error: function not found\n", RSP_SIZE);