mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
bitmap to strings
This commit is contained in:
parent
ce24191939
commit
ba5919bcae
@ -1089,3 +1089,73 @@ void split_at_last_component(char *path, char *front, char sep, char *back)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
convert a bit field to a string. if you want multiple bits to be detected
|
||||
set them first, e.g SV_TYPE_ALL to be "All" or "Full Control" for ACB_INFOs.
|
||||
|
||||
strings are expected to contain their own separators, although the code
|
||||
below only assumes that separators are spaces.
|
||||
|
||||
****************************************************************************/
|
||||
char *bit_field_to_str(uint32 type, struct field_info *bs)
|
||||
{
|
||||
static fstring typestr;
|
||||
int i = 0;
|
||||
|
||||
typestr[0] = 0;
|
||||
|
||||
if (type == 0 || bs == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (bs[i].str != NULL && type != 0)
|
||||
{
|
||||
if (IS_BITS_SET_ALL(bs[i].bits, type))
|
||||
{
|
||||
fstrcat(typestr, bs[i].str);
|
||||
type &= ~bs[i].bits;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
i = strlen(typestr)-1;
|
||||
if (i > 0 && typestr[i] == ' ')
|
||||
{
|
||||
typestr[i] = 0;
|
||||
}
|
||||
|
||||
return typestr;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
convert an enumeration to a string. first item is the default.
|
||||
****************************************************************************/
|
||||
char *enum_field_to_str(uint32 type, struct field_info *bs, BOOL first_default)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
if (bs == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
while (bs[i].str != NULL && type != 0)
|
||||
{
|
||||
if (bs[i].bits == type)
|
||||
{
|
||||
return bs[i].str;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
/* oops - none found */
|
||||
|
||||
if (first_default)
|
||||
{
|
||||
return bs[0].str;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
@ -23,27 +23,25 @@
|
||||
#include "includes.h"
|
||||
|
||||
|
||||
struct field_info sid_name_info[] =
|
||||
{
|
||||
{ SID_NAME_UNKNOWN, "UNKNOWN" }, /* default */
|
||||
{ SID_NAME_USER , "User" },
|
||||
{ SID_NAME_DOM_GRP, "Domain Group" },
|
||||
{ SID_NAME_DOMAIN , "Domain" },
|
||||
{ SID_NAME_ALIAS , "Local Group" },
|
||||
{ SID_NAME_WKN_GRP, "Well-known Group"},
|
||||
{ SID_NAME_DELETED, "Deleted" },
|
||||
{ SID_NAME_INVALID, "Invalid" },
|
||||
{ 0 , NULL }
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
convert a SID_NAME_USE to a string
|
||||
****************************************************************************/
|
||||
char *get_sid_name_use_str(uint8 sid_name_use)
|
||||
{
|
||||
static fstring type;
|
||||
|
||||
switch (sid_name_use)
|
||||
{
|
||||
case SID_NAME_USER : fstrcpy(type, "User" ); break;
|
||||
case SID_NAME_DOM_GRP : fstrcpy(type, "Domain Group" ); break;
|
||||
case SID_NAME_DOMAIN : fstrcpy(type, "Domain" ); break;
|
||||
case SID_NAME_ALIAS : fstrcpy(type, "Local Group" ); break;
|
||||
case SID_NAME_WKN_GRP : fstrcpy(type, "Well-known Group"); break;
|
||||
case SID_NAME_DELETED : fstrcpy(type, "Deleted" ); break;
|
||||
case SID_NAME_INVALID : fstrcpy(type, "Invalid" ); break;
|
||||
case SID_NAME_UNKNOWN :
|
||||
default : fstrcpy(type, "UNKNOWN" ); break;
|
||||
}
|
||||
|
||||
return type;
|
||||
return enum_field_to_str((uint32)sid_name_use, sid_name_info, True);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
Loading…
Reference in New Issue
Block a user