/*
Copyright 2015 IoT.bzh
+ author: José Bollo <jose.bollo@iot.bzh>
+
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
#define _GNU_SOURCE
#include <errno.h>
-#include <syslog.h>
#include <string.h>
+#include "verbose.h"
#include "wgtpkg.h"
struct permission {
unsigned level: 3;
};
-static const char prefix_of_permissions[] = PREFIXPERMISSION;
+static const char prefix_of_permissions[] = FWK_PREFIX_PERMISSION;
static int nrpermissions = 0;
static struct permission *permissions = NULL;
+static int indexiter = 0;
/* check is the name has the correct prefix for permissions */
int is_standard_permission(const char *name)
iter[n] = 0;
p = add_permission(iter);
if (!p) {
- syslog(LOG_ERR, "Can't allocate permission");
+ ERROR("Can't allocate permission");
exit(1);
}
p->granted = 1;
return 0;
}
+/* iteration over granted and requested permissions */
+const char *first_usable_permission()
+{
+ indexiter = 0;
+ return next_usable_permission();
+}
+
+const char *next_usable_permission()
+{
+ while(indexiter < nrpermissions) {
+ struct permission *p = &permissions[indexiter++];
+ if (p->granted && p->requested)
+ return p->name;
+ }
+ return NULL;
+}
+