[hackers] [sbase] make parsemode() generic || Hiltjo Posthuma

From: <git_AT_suckless.org>
Date: Wed, 09 Apr 2014 16:40:37 +0200

commit 560340341fffe3a5798421cb9ed82d9b09276743
Author: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
Date: Wed Apr 9 15:17:20 2014 +0200

    make parsemode() generic
    
    use for uudecode and chmod
    
    Signed-off-by: Hiltjo Posthuma <hiltjo_AT_codemadness.org>

diff --git a/Makefile b/Makefile
index ceed44f..ad1e43b 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -17,6 +17,7 @@ LIB = \
         util/fnck.o \
         util/getlines.o \
         util/md5.o \
+ util/mode.o \
         util/putword.o \
         util/recurse.o \
         util/rm.o \
diff --git a/chmod.c b/chmod.c
index 74d7c15..901363e 100644
--- a/chmod.c
+++ b/chmod.c
_AT_@ -7,10 +7,9 @@
 #include "util.h"
 
 static void chmodr(const char *);
-static void parsemode(const char *);
 
 static bool rflag = false;
-static char oper = '=';
+static int oper = '=';
 static mode_t mode = 0;
 
 static void
_AT_@ -46,7 +45,7 @@ main(int argc, char *argv[])
         }
 
 done:
- parsemode(argv[0]);
+ parsemode(argv[0], &mode, &oper);
         argv++;
         argc--;
 
_AT_@ -82,73 +81,3 @@ chmodr(const char *path)
         if(rflag)
                 recurse(path, chmodr);
 }
-
-void
-parsemode(const char *str)
-{
- char *end;
- const char *p;
- int octal;
- mode_t mask = 0;
-
- octal = strtol(str, &end, 8);
- if(*end == '
Received on Wed Apr 09 2014 - 16:40:37 CEST

This archive was generated by hypermail 2.3.0 : Wed Apr 09 2014 - 16:48:27 CEST