-/*********************************************************************
- *
- * Function : permissions_to_text
- *
- * Description : Converts a permissionsfil entry from numeric form
- * ("mask" and "add") to text.
- *
- * Parameters :
- * 1 : mask = As from struct permissions_spec
- * 2 : add = As from struct permissions_spec
- *
- * Returns : A string. Caller must free it.
- *
- *********************************************************************/
-char * permissions_to_text(unsigned mask, unsigned add)
-{
- char * result = strdup("");
-
- /* sanity - prevents "-feature +feature" */
- mask |= add;
-
-#define PERMISSION_TO_TEXT(__bit, __name) \
- if (!(mask & __bit)) \
- { \
- result = strsav(result, " -" __name); \
- } \
- else if (add & __bit) \
- { \
- result = strsav(result, " +" __name); \
- }
-
- PERMISSION_TO_TEXT(PERMIT_COOKIE_SET, "cookies-set");
- PERMISSION_TO_TEXT(PERMIT_COOKIE_READ, "cookies-read");
- PERMISSION_TO_TEXT(PERMIT_RE_FILTER, "filter");
- PERMISSION_TO_TEXT(PERMIT_POPUPS, "popup");
- PERMISSION_TO_TEXT(PERMIT_REFERER, "referer");
- PERMISSION_TO_TEXT(PERMIT_FAST_REDIRECTS, "fast-redirects");
- PERMISSION_TO_TEXT(PERMIT_BLOCK, "block");
- PERMISSION_TO_TEXT(PERMIT_IMAGE, "image");
-
- return result;
-}
-
-