bug.c 601 B

12345678910111213141516171819202122232425262728
  1. // SPDX-License-Identifier: GPL-2.0 or GPL-3.0
  2. // Copyright © 2018-2019 Ariadne Devos
  3. /* sHT -- bug reporting / crashing */
  4. #include <sHT/bugs.h>
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. __attribute__((nonnull (1)))
  8. _Noreturn
  9. static void
  10. sHT_individual_bug(const char *msg)
  11. {
  12. /* TODO: we should be phoning the control thread, but as there is
  13. no such thing yet ...*/
  14. (void) dprintf(2, "sHT error: %s\n", msg);
  15. _Exit(1);
  16. }
  17. void
  18. sHT_bug(const struct sHT_bug_option *options, int code)
  19. {
  20. while ((options->code != 0) && (options->code != code))
  21. options++;
  22. sHT_individual_bug(options->msg);
  23. }