Corretti i commenti ai listati in una forma piu' leggibile (spero).
[gapil.git] / listati / FortuneClient.c
index f0c1030..6baad61 100644 (file)
@@ -9,28 +9,28 @@ int main(int argc, char *argv[])
     int nread;
     char buffer[PIPE_BUF];
     ...
-    snprintf(fifoname, 80, "/tmp/fortune.%d", getpid());     /* compose name */
-    if (mkfifo(fifoname, 0622)) {                        /* open client fifo */
+    snprintf(fifoname, 80, "/tmp/fortune.%d", getpid()); /* compose name */
+    if (mkfifo(fifoname, 0622)) { /* open client fifo */
         if (errno!=EEXIST) {
             perror("Cannot create well known fifo");
             exit(-1);
         }
     }
-    fifo_server = open(fortunefilename, O_WRONLY);       /* open server fifo */
+    fifo_server = open(fortunefilename, O_WRONLY); /* open server fifo */
     if (fifo_server < 0) {
         perror("Cannot open well known fifo");
         exit(-1);
     }
-    nread = write(fifo_server, fifoname, strlen(fifoname)+1);  /* write name */
-    close(fifo_server);                                 /* close server fifo */
-    fifo_client = open(fifoname, O_RDONLY);              /* open client fifo */
+    nread = write(fifo_server, fifoname, strlen(fifoname)+1); /* write name */
+    close(fifo_server);                     /* close server fifo */
+    fifo_client = open(fifoname, O_RDONLY); /* open client fifo */
     if (fifo_client < 0) {
         perror("Cannot open well known fifo");
         exit(-1);
     }
-    nread = read(fifo_client, buffer, sizeof(buffer));        /* read answer */
-    printf("%s", buffer);                                   /* print fortune */
-    close(fifo_client);                                      /* close client */
-    close(fifo_server);                                      /* close server */
-    unlink(fifoname);                                  /* remove client fifo */
+    nread = read(fifo_client, buffer, sizeof(buffer)); /* read answer */
+    printf("%s", buffer);   /* print fortune */
+    close(fifo_client);     /* close client */
+    close(fifo_server);     /* close server */
+    unlink(fifoname);       /* remove client fifo */
 }