diff options
author | June McEnroe <june@causal.agency> | 2017-09-01 00:08:07 -0400 |
---|---|---|
committer | June McEnroe <june@causal.agency> | 2017-09-01 00:08:07 -0400 |
commit | 9a6c9c91c8092603b914cc0b3085d059e162ca29 (patch) | |
tree | 6cf07a47b23dd20f7c98fdcb729c1ce82969c86b /client.c | |
parent | Clean up merge tool (diff) | |
download | torus-9a6c9c91c8092603b914cc0b3085d059e162ca29.tar.gz torus-9a6c9c91c8092603b914cc0b3085d059e162ca29.zip |
Add client readOnly mode
Diffstat (limited to '')
-rw-r--r-- | client.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/client.c b/client.c index 30a400c..707d50b 100644 --- a/client.c +++ b/client.c @@ -44,6 +44,8 @@ static int client; +static bool readOnly = false; + static void clientMessage(const struct ClientMessage *msg) { ssize_t len = send(client, msg, sizeof(*msg), 0); if (len < 0) err(EX_IOERR, "send"); @@ -58,6 +60,7 @@ static void clientMove(int8_t dx, int8_t dy) { } static void clientPut(uint8_t color, char cell) { + if (readOnly) return; struct ClientMessage msg = { .type = CLIENT_PUT, .data.p = { .color = color, .cell = cell }, @@ -381,7 +384,9 @@ static void initColors(void) { } } -int main() { +int main(int argc, char *argv[] UNUSED) { + if (argc > 1) readOnly = true; + client = socket(PF_LOCAL, SOCK_STREAM, 0); if (client < 0) err(EX_OSERR, "socket"); |