45 lines
509 B
C
45 lines
509 B
C
#ifndef _PARSE_MODE_H
|
|
#define _PARSE_MODE_H
|
|
|
|
#include <sys/stat.h>
|
|
|
|
int mu_parse_mode(const char *s) {
|
|
char *p = NULL;
|
|
long mode = strtol(s, &p, 8);
|
|
if (!*p)
|
|
return mode;
|
|
|
|
int group = 0;
|
|
int other = 0;
|
|
int user = 0;
|
|
|
|
int i;
|
|
for (i = 0; s[i]; i++) {
|
|
switch (s[i]) {
|
|
case 'u':
|
|
user = 1;
|
|
break;
|
|
|
|
case 'g':
|
|
group = 1;
|
|
break;
|
|
|
|
case 'o':
|
|
other = 1;
|
|
|
|
case 'a':
|
|
group = 1;
|
|
other = 1;
|
|
user = 1;
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
return mode;
|
|
}
|
|
|
|
#endif
|