Fixed inconsistent socket io.
[tlb/tomd.git] / src / tomc / main.c
index 3dd16c1..46f44a7 100644 (file)
@@ -47,7 +47,7 @@ static void init(void)
   struct sockaddr_un addr;
   addr.sun_family = AF_LOCAL;
   sprintf(addr.sun_path, "/run/user/1000/tomd/socket");
-  
+
   if(connect(sfd, (struct sockaddr *) &addr, SUN_LEN(&addr)) != 0){
     perror("connect");
     exit(EXIT_FAILURE);
@@ -74,7 +74,7 @@ static void extract_options(int argc, char **argv)
   }
 
   options.name = NULL;
-  
+
   for(int i = 1;
       i < argc;
       i++){
@@ -117,13 +117,13 @@ static char socket_buf[100];
     if(wrote != write_len){                                         \
       perror("[tomc] write size mismatch");                         \
       exit(EXIT_FAILURE);                                           \
-    }}                                                               
-    
+    }}
+
 int last_read_size = 0;
 
 static void do_read(char *line)
 {
-  printf("got %s as input.\n", line);
+  /* printf("got %s as input.\n", line); */
   strcpy(socket_buf, line);
   /* printf("socket_buf: %s\n", socket_buf); */
 }
@@ -156,7 +156,7 @@ static void do_read(char *line)
     SOCK_WRITE(options.name);                   \
     SOCK_ACK;                                   \
   }
-  
+
 static void write_client(void)
 {
   SOCK_WRITE("client:tomc");
@@ -192,13 +192,14 @@ static void write_requests(void)
   }
 
   while(1){
-    printf("looking for that last ack.\n");
+    /* printf("looking for that last ack.\n"); */
     SOCK_READ;
     if(strcmp(socket_buf, "ACK") == 0){
-      tomc_p("got the ending ack.");
+      /* tomc_p("got the ending ack."); */
+      write(sfd, "ACK", sizeof "ACK");
       break;
     }else{
-      printf("in else.\n");
+      /* printf("in else.\n"); */
       /* int len = strlen(socket_buf); */
       /* int total = len; */
       /* if(last_read_size == 0){ */
@@ -223,7 +224,7 @@ int main(int argc, char **argv)
   init();
   write_requests();
 
-  tomc_p("dying of our own accord.");
-  
+  /* tomc_p("dying of our own accord."); */
+
   return EXIT_SUCCESS;
 }