1
0

types.h 848 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * types.h
  3. */
  4. /**
  5. \ingroup lub
  6. \defgroup lub_types types
  7. \brief This provides some primative types not found in ANSI-C.
  8. @{
  9. */
  10. #ifndef _lub_types_h
  11. #define _lub_types_h
  12. /**
  13. * A boolean type for ANSI-C
  14. */
  15. typedef enum {
  16. BOOL_FALSE,
  17. BOOL_TRUE
  18. } bool_t;
  19. /**
  20. * A tri-state boolean. The possible values are
  21. * TRI_FALSE, TRI_TRUE, TRI_UNDEFINED.
  22. */
  23. typedef enum {
  24. TRI_UNDEFINED = -1,
  25. TRI_FALSE = 0,
  26. TRI_TRUE = 1
  27. } tri_t;
  28. /**
  29. * Converts a string to a tri
  30. *
  31. * "true" yields TRI_TRUE.
  32. * "false" yields TRI_FALSE.
  33. * Anything else is TRI_FALSE.
  34. */
  35. tri_t lub_tri_from_string(const char *s);
  36. /**
  37. * Reduce a tri to bool using a default value
  38. *
  39. * Will return D if T == TRI_UNDEFINED.
  40. *
  41. * Returns boolean value of T otherwise.
  42. */
  43. bool_t lub_tri_default(tri_t t, bool_t d);
  44. /** @} */
  45. #endif /* _lub_types_h */