Seconda parte della risistemazione delle dichiarazioni di inclusione.
[gapil.git] / sources / WriteShm.c
index db5b132ff817643621d5cfa03bea3bffb812e009..ce5ea496b357b79d257b6c9c4c066272e5917f09 100644 (file)
  *
  * File WriteShm.c: 
  *
- * An example of POSIX shared memory use: wwrite some content to a
+ * An example of POSIX shared memory use: write some content to a
  * shared memory segment
  *
  * Author: S. Piccardi Jan. 2003
  *
  *****************************************************************************/
-#include <sys/types.h>     /* primitive system data types */
-#include <sys/stat.h>
-#include <dirent.h>        /* directory */
-#include <stdlib.h>        /* C standard library */
-#include <unistd.h>        /* unix standard library */
-#include <stdio.h>         /* standard I/O library */
+#include <sys/types.h>   /* primitive system data types */
+#include <sys/stat.h>    /* file characteristics constants and functions */
+#include <dirent.h>      /* directory operation constants and functions */
+#include <stdlib.h>      /* C standard library */
+#include <unistd.h>      /* unix standard library */
+#include <stdio.h>       /* standard I/O library */
 
 #include "Gapil.h"
 #include "macros.h"
@@ -58,21 +58,21 @@ int main(int argc, char *argv[])
        /* 
         * Handling options 
         */ 
-       case 's':                                     /* set pause (in sec.) */
+       case 's':   /* set pause (in sec.) */
            size = strtol(optarg, NULL, 10);
            break;
-       case 'f':                                     /* set pause (in sec.) */
+       case 'f':   /* set pause (in sec.) */
            file_name = optarg;
            break;
-       case 'h':                                             /* help option */
+       case 'h':   /* help option */
            printf("Wrong -h option use\n");
            usage();
            return -1;
            break;
-       case '?':                                    /* unrecognized options */
+       case '?':   /* unrecognized options */
            printf("Unrecognized options -%c\n",optopt);
            usage();
-       default:                                       /* should not reached */
+       default:    /* should not reached */
            usage();
        }
     }
@@ -83,12 +83,13 @@ int main(int argc, char *argv[])
      *               Main code beginning
      * 
      * ***********************************************************/
-    if ((argc - optind) != 1) {          /* There must be remaing parameters */
+    if ((argc - optind) != 1) {  /* There must be remaing parameters */
        printf("Wrong number of arguments %d\n", argc - optind);
         usage();
     }
+    /* get a Mutex */
     mutex_file = tempnam("/tmp","mutex");
-    if ((mutex = CreateMutex(mutex_file)) == -1) {            /* get a Mutex */
+    if ((mutex = CreateMutex(mutex_file)) == -1) { 
        perror("Cannot create mutex");
        goto errmutex;
     }