ToolsMenu/toolrun.h

61 lines
2.3 KiB
C
Executable File

/*
ToolsMenu - Add tools to the Workbench Tools menu
Copyright (C) 2015, 2018 Kim Fastrup Larsen
This program is free software: you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation, either ver-
sion 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be use-
ful, but WITHOUT ANY WARRANTY; without even the implied war-
ranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public Li-
cense along with this program. If not, see
<http://www.gnu.org/licenses/>.
The author can be contacted on <kimflarsen@hotmail.com>
*/
#ifndef TOOLRUN_H
#define TOOLRUN_H
#include "common.h"
/* The signature of the function that will be called when a tool quits (see
below). */
typedef void Tr_clean_up(struct WBArg *, LONG num_args, void *user_data);
/* This function must be called once as part of program initialization. Do
not call tr_run_tool() before calling this function. It sets up a message
port, for which the signal bit will be returned as a mask. Whenever you
receive this signal, call tr_handle_signal() to deal with it. */
ULONG tr_set_up(void);
/* Run a tool as if started from Workbench.
arg_list: An array of WBArg structures. The first element must
represent the tool to run, and the rest are its arguments.
num_args: The number of elements in arg_list.
clean_up: A pointer to a function that will be called when the tool
quits - it will be called from within tr_handle_signal() or
tr_clean_up(). arg_list, num_args and user_data will be passed
to clean_up.
user_data: This can be anything. It will be passed to clean_up. */
Bool tr_run_tool(struct WBArg *arg_list, LONG num_args,
Tr_clean_up *clean_up, void *user_data);
/* You must call this function whenever you receive the signal returned by
tr_set_up(). */
void tr_handle_signal(void);
/* You must call this once before quitting. Do not call tr_run_tool() after
calling this function.
NB: This function will wait around for all tools started by tr_run_tool()
to quit before returning. */
void tr_clean_up(void);
#endif