While I'm thinking about popt features, here is another:

The BSD kernel (iirc) devised a means to map bit files to names
using a %b format.

A string was used to map bit# <-> name. E.g. here's an example
from some rpmdb code that I use for output purposes

static const char * dbtFlags =

The same technique (of nerdy embedded octal in a string) can be used to assign names to bits in a set,
permitting option parsing (using the format string above):

    --option PARTIAL,DUPOK

to save the value 0x48 (i.e. (1 << 3) | (1 << 6)) into the target storage.

OTOH, generating the %b format string can be tedious, and perhaps
a more general table like (this from LZMA):

    typedef struct {
        const char *name;
        uint64_t id;
   } name_id_map;

with name = NULL as table end sentinel should be done.


73 De Jeff

POPT Library                                           http://rpm5.org
Developer Communication List                       popt-devel@rpm5.org

Reply via email to