Corretti i commenti ai listati in una forma piu' leggibile (spero).
[gapil.git] / listati / FortuneServer.c
index 7c45d230c2ead1b7668c3720d50c4e15c9801058..40ee3d95af1838be739085cd56d3c67bf081d030 100644 (file)
@@ -9,12 +9,12 @@ int main(int argc, char *argv[])
     int fifo_server, fifo_client;
     int nread;
     ...
     int fifo_server, fifo_client;
     int nread;
     ...
-    if (n==0) usage();          /* if no pool depth exit printing usage info */
-    Signal(SIGTERM, HandSIGTERM);            /* set handlers for termination */
+    if (n==0) usage();  /* if no pool depth exit printing usage info */
+    Signal(SIGTERM, HandSIGTERM); /* set handlers for termination */
     Signal(SIGINT, HandSIGTERM);
     Signal(SIGQUIT, HandSIGTERM);
     Signal(SIGINT, HandSIGTERM);
     Signal(SIGQUIT, HandSIGTERM);
-    i = FortuneParse(fortunefilename, fortune, n);          /* parse phrases */
-    if (mkfifo(fifoname, 0622)) {  /* create well known fifo if does't exist */
+    i = FortuneParse(fortunefilename, fortune, n); /* parse phrases */
+    if (mkfifo(fifoname, 0622)) { /* create well known fifo if does't exist */
         if (errno!=EEXIST) {
             perror("Cannot create well known fifo");
             exit(1);
         if (errno!=EEXIST) {
             perror("Cannot create well known fifo");
             exit(1);
@@ -33,20 +33,20 @@ int main(int argc, char *argv[])
     }
     /* Main body: loop over requests */
     while (1) {
     }
     /* Main body: loop over requests */
     while (1) {
-        nread = read(fifo_server, line, 79);                 /* read request */
+        nread = read(fifo_server, line, 79); /* read request */
         if (nread < 0) {
             perror("Read Error");
             exit(1);
         }
         if (nread < 0) {
             perror("Read Error");
             exit(1);
         }
-        line[nread] = 0;                       /* terminate fifo name string */
-        n = random() % i;                             /* select random value */
-        fifo_client = open(line, O_WRONLY);              /* open client fifo */
+        line[nread] = 0;                     /* terminate fifo name string */
+        n = random() % i;                    /* select random value */
+        fifo_client = open(line, O_WRONLY);  /* open client fifo */
         if (fifo_client < 0) {
             perror("Cannot open");
             exit(1);
         }
         if (fifo_client < 0) {
             perror("Cannot open");
             exit(1);
         }
-        nread = write(fifo_client,                           /* write phrase */
+        nread = write(fifo_client,           /* write phrase */
                       fortune[n], strlen(fortune[n])+1);
                       fortune[n], strlen(fortune[n])+1);
-        close(fifo_client);                             /* close client fifo */
+        close(fifo_client);                  /* close client fifo */
     }
 }
     }
 }