about summary refs log tree commit diff homepage
path: root/client.c
diff options
context:
space:
mode:
authorJune McEnroe <programble@gmail.com>2017-09-01 00:08:07 -0400
committerJune McEnroe <programble@gmail.com>2017-09-01 00:08:07 -0400
commit34f25ae40a3db9369e9d98b3814f2b93bbc21451 (patch)
tree784b74c846ae47f4453c32270f4af6e20a4a70a4 /client.c
parentClean up merge tool (diff)
downloadtorus-34f25ae40a3db9369e9d98b3814f2b93bbc21451.tar.gz
torus-34f25ae40a3db9369e9d98b3814f2b93bbc21451.zip
Add client readOnly mode
Diffstat (limited to 'client.c')
-rw-r--r--client.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/client.c b/client.c
index e674ba2..db03db3 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");
 
mmit/txt/books.txt?id=7b4690a71b68a9de10cded6c3ca96a54eae106f1&follow=1'>Add Maiden, Mother, CroneJune McEnroe 2022-06-05FIRST SHOW IN 2.5 YEARS BABEY!!!June McEnroe 2022-06-03Set line number on File linesJune McEnroe 2022-06-03Stop polling stdin after EOFJune McEnroe 2022-06-02Set TABSIZE=4June McEnroe 2022-06-02Do basic match highlightingJune McEnroe 2022-06-02Clean up parsing a littleJune McEnroe 2022-06-02Don't duplicate path stringJune McEnroe 2022-06-02Use stderr instead of /dev/tty, realloc buffer if lines too longJune McEnroe 2022-06-02Add initial working version of qfJune McEnroe 2022-05-29Set prompt for okshJune McEnroe