Skip to content
Snippets Groups Projects
Unverified Commit 46488d1b authored by Irene Zhang's avatar Irene Zhang Committed by GitHub
Browse files

Merge pull request #8 from mwhittaker/lockserver_client_fixes

A couple small lockserver client improvements.
parents 177425b0 679fcb9f
No related branches found
No related tags found
No related merge requests found
......@@ -30,6 +30,17 @@
#include "lockserver/client.h"
namespace {
void
usage()
{
printf("Unknown command.. Try again!\n");
printf("Usage: exit | q | lock <key> | unlock <key>\n");
}
} // namespace
int
main(int argc, char **argv)
{
......@@ -68,14 +79,18 @@ main(int argc, char **argv)
cmd[clen++] = c;
cmd[clen] = '\0';
if (clen == 0) continue;
tok = strtok(cmd, " ,.-");
if (tok == NULL) continue;
if (strcasecmp(tok, "exit") == 0 || strcasecmp(tok, "q") == 0) {
printf("Exiting..\n");
break;
} else if (strcasecmp(tok, "lock") == 0) {
tok = strtok(NULL, " ,.-");
if (tok == NULL) {
usage();
continue;
}
key = string(tok);
status = locker.lock(key);
......@@ -86,11 +101,15 @@ main(int argc, char **argv)
}
} else if (strcasecmp(tok, "unlock") == 0) {
tok = strtok(NULL, " ,.-");
if (tok == NULL) {
usage();
continue;
}
key = string(tok);
locker.unlock(key);
printf("Unlock Successful\n");
} else {
printf("Unknown command.. Try again!\n");
usage();
}
fflush(stdout);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment