allquestions.c 936 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * \file allquestions.c
  3. *
  4. * \brief Quetions controller.
  5. *
  6. * Implements procedures for addign and removing questions from the global \ref
  7. * questions variable.
  8. */
  9. #include <assert.h>
  10. #include <string.h>
  11. #include <bsd/sys/queue.h>
  12. #include "qa/questions/questions.h"
  13. /**
  14. * \brief Select a single question to be used.
  15. *
  16. */
  17. void select_question(const char *sq)
  18. {
  19. qa_question_t *q, *tmpq;
  20. select_all_questions();
  21. assert(questions.lh_first);
  22. LIST_FOREACH_SAFE(q, &questions, qs, tmpq)
  23. if (strcmp(q->name, sq))
  24. LIST_REMOVE(q, qs);
  25. }
  26. /**
  27. * \brief Puts registered questions into \ref questions.
  28. *
  29. * Disposes all registered questions into a global linked list, so that future
  30. * procedures can iterate over all possible tests.
  31. */
  32. void select_all_questions(void)
  33. {
  34. LIST_INIT(&questions);
  35. REGISTER_QUESTION(ExampleQuestion);
  36. REGISTER_QUESTION(WienerQuestion);
  37. REGISTER_QUESTION(PollardQuestion);
  38. }