A tool for adding anime to your anidb list.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.1KB

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <signal.h>
  4. #include <errno.h>
  5. #include <string.h>
  6. #include "config.h"
  7. #include "error.h"
  8. #include "uio.h"
  9. #include "cmd.h"
  10. #include "globals.h"
  11. bool should_exit = false;
  12. static void signal_handler(int signum, siginfo_t *info, void *ctx)
  13. {
  14. should_exit = true;
  15. printf("\033[0GGot C-c. Press again to force exit\n");
  16. }
  17. int main(int argc, char **argv)
  18. {
  19. int exit_code = EXIT_SUCCESS;
  20. enum error err;
  21. struct sigaction sact = {
  22. .sa_flags = SA_SIGINFO | SA_RESETHAND,
  23. //.sa_flags = SA_SIGINFO,
  24. .sa_sigaction = signal_handler,
  25. };
  26. if (sigaction(SIGINT, &sact, NULL) != 0) {
  27. uio_error("Cannot set up signal handler: %s", strerror(errno));
  28. return EXIT_FAILURE;
  29. }
  30. err = config_parse(argc, argv);
  31. if (err == ERR_OPT_EXIT)
  32. return EXIT_SUCCESS;
  33. else if (err != NOERR)
  34. return EXIT_FAILURE;
  35. //config_dump();
  36. err = cmd_main();
  37. if (err == ERR_SHOULD_EXIT)
  38. uio_debug("Exiting as requested orz");
  39. else if (err != NOERR)
  40. exit_code = EXIT_FAILURE;
  41. config_free();
  42. return exit_code;
  43. }