espelhamento de https://frontier.innolan.net/rainlance/ToolsMenu.git
97 linhas
2.5 KiB
C
Arquivo executável
97 linhas
2.5 KiB
C
Arquivo executável
/*
|
|
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>
|
|
*/
|
|
|
|
#include <dos/dos.h>
|
|
#include <dos/rdargs.h>
|
|
#include <workbench/startup.h>
|
|
|
|
#include <clib/alib_protos.h>
|
|
#include <clib/dos_protos.h>
|
|
#include <clib/exec_protos.h>
|
|
|
|
#ifdef USE_PRAGMAS
|
|
#include <proto/dos.h>
|
|
#include <proto/exec.h>
|
|
#endif
|
|
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
|
|
#include "args.h"
|
|
|
|
#define DEF_CX_PRIORITY 0
|
|
#define DEF_CX_POPUP YES
|
|
#define DEF_CX_POPKEY "control alt t"
|
|
|
|
Args args;
|
|
|
|
static UBYTE **tool_types;
|
|
static struct RDArgs *rdargs;
|
|
|
|
static void get_wb_args(char **argv)
|
|
{
|
|
struct WBArg *wb_arg = ((struct WBStartup *) argv)->sm_ArgList;
|
|
|
|
args.exe.dir = wb_arg->wa_Lock;
|
|
args.exe.filename = wb_arg->wa_Name;
|
|
if ((tool_types = ArgArrayInit(0, argv)) == NULL)
|
|
exit(RETURN_FAIL);
|
|
args.cx_priority = ArgInt(tool_types, "CX_PRIORITY", DEF_CX_PRIORITY);
|
|
args.cx_popup = strcmp(ArgString(tool_types, "CX_POPUP", DEF_CX_POPUP ?
|
|
"YES" : "NO"), "NO") != 0;
|
|
args.cx_popkey = ArgString(tool_types, "CX_POPKEY", DEF_CX_POPKEY);
|
|
}
|
|
|
|
static void get_shell_args(char **argv)
|
|
{
|
|
LONG sh_args[3];
|
|
|
|
args.exe.dir = ((struct Process *) FindTask(NULL))->pr_CurrentDir;
|
|
args.exe.filename = argv[0];
|
|
sh_args[0] = DEF_CX_PRIORITY;
|
|
sh_args[1] = (LONG) DEF_CX_POPKEY;
|
|
sh_args[2] = DEF_CX_POPUP ? (LONG) "YES" : (LONG) "NO";
|
|
if ((rdargs = ReadArgs(TEMPLATE, sh_args, NULL)) == NULL) {
|
|
PrintFault(IoErr(), argv[0]);
|
|
exit(RETURN_ERROR);
|
|
}
|
|
args.cx_priority = sh_args[0];
|
|
args.cx_popkey = (STRPTR) sh_args[1];
|
|
args.cx_popup = strcmp((char *) sh_args[2], "YES") == 0;
|
|
}
|
|
|
|
void args_set_up(int argc, char **argv)
|
|
{
|
|
if (argc == 0)
|
|
get_wb_args(argv);
|
|
else
|
|
get_shell_args(argv);
|
|
}
|
|
|
|
void args_clean_up()
|
|
{
|
|
if (rdargs != NULL)
|
|
FreeArgs(rdargs);
|
|
if (tool_types != NULL)
|
|
ArgArrayDone();
|
|
}
|