flagprocs.c 921 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* markdown: a C implementation of John Gruber's Markdown markup language.
  2. *
  3. * Copyright (C) 2007-2011 David L Parsons.
  4. * The redistribution terms are provided in the COPYRIGHT file that must
  5. * be distributed with this source code.
  6. */
  7. #include <stdio.h>
  8. #include <stdlib.h>
  9. #include <limits.h>
  10. #include <errno.h>
  11. #include <string.h>
  12. #include <stdarg.h>
  13. #include "config.h"
  14. #include "markdown.h"
  15. #include "amalloc.h"
  16. #if HAVE_LIBGEN_H
  17. #include <libgen.h>
  18. #endif
  19. void
  20. mkd_set_flag_num(mkd_flag_t *p, unsigned long bit)
  21. {
  22. if ( p && (bit < MKD_NR_FLAGS) )
  23. set_mkd_flag(p, bit);
  24. }
  25. void
  26. mkd_clr_flag_num(mkd_flag_t *p, unsigned long bit)
  27. {
  28. if ( p && (bit < MKD_NR_FLAGS) )
  29. clear_mkd_flag(p, bit);
  30. }
  31. void
  32. mkd_set_flag_bitmap(mkd_flag_t *p, long bits)
  33. {
  34. int i;
  35. if ( p == 0 )
  36. return;
  37. for (i=0; i < 8*sizeof(long) && i < MKD_NR_FLAGS; i++)
  38. if ( bits & (1<<i) )
  39. set_mkd_flag(p, i);
  40. }