Imported Upstream version 2.10
[debian/cpmtools] / cpmchattr.c
index 9fbf074ca1934bcacb5ad72304e45cbe4467bd48..aaecdc7328151c7b41025dc1e0ab27fdf902ea00 100644 (file)
@@ -1,12 +1,17 @@
 /* #includes */ /*{{{C}}}*//*{{{*/
+#include "config.h"
+
 #include <ctype.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
-#include "config.h"
 
-#include "getopt.h"
+#include "getopt_.h"
 #include "cpmfs.h"
+
+#ifdef USE_DMALLOC
+#include <dmalloc.h>
+#endif
 /*}}}*/
 
 const char cmd[]="cpmchattr";
@@ -38,8 +43,8 @@ int main(int argc, char *argv[]) /*{{{*/
   if (optind>=(argc-2)) usage=1;
   else 
   {
-    image=argv[optind];
-    attrs = argv[optind+1];
+    image=argv[optind++];
+    attrs = argv[optind++];
   }    
 
   if (usage)
@@ -60,12 +65,12 @@ int main(int argc, char *argv[]) /*{{{*/
   for (i=0; i<gargc; ++i)
   {
     struct cpmInode ino;
-    int err;
+    int rc;
     cpm_attr_t attrib;
 
-    err = cpmNamei(&root,gargv[i], &ino)==-1;
-    if (!err) err = cpmAttrGet(&ino, &attrib);
-    if (!err)
+    rc = cpmNamei(&root,gargv[i], &ino)==-1;
+    if (!rc) rc = cpmAttrGet(&ino, &attrib);
+    if (!rc)
     {
         int n, m;
         m = 0;
@@ -93,9 +98,9 @@ int main(int argc, char *argv[]) /*{{{*/
           } 
           if (m) attrib &= ~mask; else attrib |= mask;
        }
-        err = cpmAttrSet(&ino, attrib);
+        rc = cpmAttrSet(&ino, attrib);
     }
-    if (err)
+    if (rc)
     {
       fprintf(stderr,"%s: can not set attributes for %s: %s\n",cmd,gargv[i],boo);
       exitcode=1;