int setflags (int fd, unsigned long flags);
int setversion (int fd, unsigned long version);
-char *e2p_feature2string(int compat, unsigned int mask);
+const char *e2p_feature2string(int compat, unsigned int mask);
int e2p_string2feature(char *string, int *compat, unsigned int *mask);
-int e2p_edit_feature(char *str, __u32 *compat_array, __u32 *ok_array);
+int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array);
int e2p_is_null_uuid(void *uu);
void e2p_uuid_to_str(void *uu, char *out);
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include <errno.h>
#include "e2p.h"
struct feature {
int compat;
unsigned int mask;
- char *string;
+ const char *string;
};
struct feature feature_list[] = {
{ 0, 0, 0 },
};
-char *e2p_feature2string(int compat, unsigned int mask)
+const char *e2p_feature2string(int compat, unsigned int mask)
{
struct feature *f;
static char buf[20];
return buf;
}
-int e2p_string2feature(char *string, int *compat, unsigned int *mask)
+int e2p_string2feature(char *string, int *compat_type, unsigned int *mask)
{
struct feature *f;
char *eptr;
for (f = feature_list; f->string; f++) {
if (!strcasecmp(string, f->string)) {
- *compat = f->compat;
+ *compat_type = f->compat;
*mask = f->mask;
return 0;
}
switch (string[8]) {
case 'c':
case 'C':
- *compat = E2P_FEATURE_COMPAT;
+ *compat_type = E2P_FEATURE_COMPAT;
break;
case 'i':
case 'I':
- *compat = E2P_FEATURE_INCOMPAT;
+ *compat_type = E2P_FEATURE_INCOMPAT;
break;
case 'r':
case 'R':
- *compat = E2P_FEATURE_RO_INCOMPAT;
+ *compat_type = E2P_FEATURE_RO_INCOMPAT;
break;
default:
return 1;
return cp;
}
-char *skip_over_word(char *cp)
+static char *skip_over_word(char *cp)
{
while (*cp && !isspace(*cp) && *cp != ',')
cp++;
* if set, allows the application to limit what features the user is
* allowed to set or clear using this function.
*/
-int e2p_edit_feature(char *str, __u32 *compat_array, __u32 *ok_array)
+int e2p_edit_feature(const char *str, __u32 *compat_array, __u32 *ok_array)
{
char *cp, *buf, *next;
int neg;
- unsigned int compat, mask;
+ unsigned int mask;
+ int compat_type;
buf = malloc(strlen(str)+1);
if (!buf)
cp++;
break;
}
- if (e2p_string2feature(cp, &compat, &mask))
+ if (e2p_string2feature(cp, &compat_type, &mask))
return 1;
- if (ok_array && !(ok_array[compat] & mask))
+ if (ok_array && !(ok_array[compat_type] & mask))
return 1;
if (neg)
- compat_array[compat] &= ~mask;
+ compat_array[compat_type] &= ~mask;
else
- compat_array[compat] |= mask;
+ compat_array[compat_type] |= mask;
cp = next ? next+1 : 0;
}
return 0;