[BRLTTY] BrlAPI and dot string <-> dot integer conversion

Samuel Thibault samuel.thibault at ens-lyon.org
Tue Dec 12 19:12:56 EST 2006


Hi,

Dave proposed to add the following macros and functions to BrlAPI:

/* convert a dot number ('2' for instance) into a dot bit (BRL_DOT2) */
#define brlapi_dotNumberToBit(n) ((n) < 1 ? 0 : ((n) > 8 ? 0 : 1 << (n - '1')))

/* convert a dot bit (BRL_DOT2 for instance) into a dot number ('2') */
#define brlapi_dotBitToNumber(n) ((n) ? '0' + ffs(n) : 0)

/* convert a dot number string ("145" for instance) into dot bits
 * (BRL_DOT1|BRL_DOT4|BRL_DOT5) */
unsigned char  brlapi_dotNumbersToBits(unsigned char *numbers)

/* convert dot bits (BRL_DOT1|BRL_DOT4|BRL_DOT5) into a dot string
 * ("145" for instance), caller should free() the string after use. */
unsigned char *brlapi_dotBitsToNumbers(unsigned char bits)

We're a bit reluctant to add such helper functions because
- they are quite trivial and don't add much value (particularly the
  macros).
- the format for dot strings may vary: should it be "134", or "(134)",
  or "1 34    ", etc. ?

What do people think about this?  Would these helpers be useful enough
for adding them to the API ?

Samuel


More information about the BRLTTY mailing list