src/siri/db/access.c
/*
 * Make sure 'str' is a pointer to a string which can hold at least
 * SIRIDB_ACCESS_STR_MAX.
 */
Make sure 'str' is a pointer to a string which can hold at least
SIRIDB_ACCESS_STR_MAX.
Make sure ' str ' is a pointer to a string which can hold at least SIRIDB_ACCESS_STR_MAX .
void siridb_access_to_str(char * str, uint32_t access_bit)
{
    char * pt = str;
    for (int i = 0; i < ACCESS_SIZE && access_bit; i++)
    {
        if ((access_bit & access_map[i].access_bit) == access_map[i].access_bit)
        {
            access_bit -= access_map[i].access_bit;
            pt += (pt == str) ? sprintf(pt, "%s", access_map[i].repr) :
                    (access_bit) ? sprintf(pt, ", %s", access_map[i].repr) :
                            sprintf(pt, " and %s", access_map[i].repr);
        }
    }
    if (pt == str)
    {
        sprintf(pt, "no access");
    }
}
void siridb_access_to_str ( char * str , uint32_t access_bit ) { char * pt = str ; for ( int i = 0 ; i < ACCESS_SIZE && access_bit ; i ++ ) { if ( ( access_bit & access_map [ i ] . access_bit ) == access_map [ i ] . access_bit ) { access_bit -= access_map [ i ] . access_bit ; pt += ( pt == str ) ? sprintf ( pt , " " , access_map [ i ] . repr ) : ( access_bit ) ? sprintf ( pt , " " , access_map [ i ] . repr ) : sprintf ( pt , " " , access_map [ i ] . repr ) ; } } if ( pt == str ) { sprintf ( pt , " " ) ; } }
Make sure 'str' is a pointer to a string which can hold at least
 SIRIDB_ACCESS_STR_MAX.
Make sure ' str ' is a pointer to a string which can hold at least SIRIDB_ACCESS_STR_MAX .