Add tools to the Workbench Tools menu
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.

61 lines

  1. /*
  2. ToolsMenu - Add tools to the Workbench Tools menu
  3. Copyright (C) 2015, 2018 Kim Fastrup Larsen
  4. This program is free software: you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation, either ver-
  7. sion 3 of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be use-
  9. ful, but WITHOUT ANY WARRANTY; without even the implied war-
  11. See the GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public Li-
  13. cense along with this program. If not, see
  14. <>.
  15. The author can be contacted on <>
  16. */
  17. #ifndef TOOLRUN_H
  18. #define TOOLRUN_H
  19. #include "common.h"
  20. /* The signature of the function that will be called when a tool quits (see
  21. below). */
  22. typedef void Tr_clean_up(struct WBArg *, LONG num_args, void *user_data);
  23. /* This function must be called once as part of program initialization. Do
  24. not call tr_run_tool() before calling this function. It sets up a message
  25. port, for which the signal bit will be returned as a mask. Whenever you
  26. receive this signal, call tr_handle_signal() to deal with it. */
  27. ULONG tr_set_up(void);
  28. /* Run a tool as if started from Workbench.
  29. arg_list: An array of WBArg structures. The first element must
  30. represent the tool to run, and the rest are its arguments.
  31. num_args: The number of elements in arg_list.
  32. clean_up: A pointer to a function that will be called when the tool
  33. quits - it will be called from within tr_handle_signal() or
  34. tr_clean_up(). arg_list, num_args and user_data will be passed
  35. to clean_up.
  36. user_data: This can be anything. It will be passed to clean_up. */
  37. Bool tr_run_tool(struct WBArg *arg_list, LONG num_args,
  38. Tr_clean_up *clean_up, void *user_data);
  39. /* You must call this function whenever you receive the signal returned by
  40. tr_set_up(). */
  41. void tr_handle_signal(void);
  42. /* You must call this once before quitting. Do not call tr_run_tool() after
  43. calling this function.
  44. NB: This function will wait around for all tools started by tr_run_tool()
  45. to quit before returning. */
  46. void tr_clean_up(void);
  47. #endif