console.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Common pieces between the platform console frontend modules.
  3. */
  4. #include <stdbool.h>
  5. #include <stdarg.h>
  6. #include "putty.h"
  7. #include "misc.h"
  8. #include "console.h"
  9. const char console_abandoned_msg[] = "Connection abandoned.\n";
  10. const SeatDialogPromptDescriptions *console_prompt_descriptions(Seat *seat)
  11. {
  12. static const SeatDialogPromptDescriptions descs = {
  13. .hk_accept_action = "enter \"y\"",
  14. .hk_connect_once_action = "enter \"n\"",
  15. .hk_cancel_action = "press Return",
  16. .hk_cancel_action_Participle = "Pressing Return",
  17. .weak_accept_action = "enter \"y\"",
  18. .weak_cancel_action = "enter \"n\"",
  19. };
  20. return &descs;
  21. }
  22. bool console_batch_mode = false;
  23. /*
  24. * Error message and/or fatal exit functions, all based on
  25. * console_print_error_msg which the platform front end provides.
  26. */
  27. void console_print_error_msg_fmt_v(
  28. const char *prefix, const char *fmt, va_list ap)
  29. {
  30. char *msg = dupvprintf(fmt, ap);
  31. console_print_error_msg(prefix, msg);
  32. sfree(msg);
  33. }
  34. void console_print_error_msg_fmt(const char *prefix, const char *fmt, ...)
  35. {
  36. va_list ap;
  37. va_start(ap, fmt);
  38. console_print_error_msg_fmt_v(prefix, fmt, ap);
  39. va_end(ap);
  40. }
  41. void modalfatalbox(const char *fmt, ...)
  42. {
  43. va_list ap;
  44. va_start(ap, fmt);
  45. console_print_error_msg_fmt_v("FATAL ERROR", fmt, ap);
  46. va_end(ap);
  47. cleanup_exit(1);
  48. }
  49. void nonfatal(const char *fmt, ...)
  50. {
  51. va_list ap;
  52. va_start(ap, fmt);
  53. console_print_error_msg_fmt_v("ERROR", fmt, ap);
  54. va_end(ap);
  55. }
  56. void console_connection_fatal(Seat *seat, const char *msg)
  57. {
  58. console_print_error_msg("FATAL ERROR", msg);
  59. cleanup_exit(1);
  60. }
  61. /*
  62. * Console front ends redo their select() or equivalent every time, so
  63. * they don't need separate timer handling.
  64. */
  65. void timer_change_notify(unsigned long next)
  66. {
  67. }