Page 1 of 1

Duplicating workbench pathlist

Posted: Mon Dec 30, 2013 11:23 am
by JosDuchIt
What is presently the recommended way to duplicate the WB pathlist for applications started from WB that do launch CLI commands without the full path ?

Starting from a 2006 thread http://www.amigacoding.de/index.php?topic=142.0 (REf 1)
it seems programmers make use of one of the following approaches

1. Ralph Babel's cloneWorkBenchPath() function (the gui4Cli launcher "Gui" does) (renamed "gui4" to avoid confusion withthe gui oS4 preferences program"
http://aminet.net/package.php?package=d ... wbpath.lha

It is probably described in his Guru book, which i don't possess
In the thread Thomas explains:

It uses WBStartup->sm_Message.mn_ReplyPort->mp_SigTask->pr_CLI->cli_CommandDir to get a pointer to the Workbench's path list and then clones it by calling DupLock for each node.

To be noted: cli_CommandDir has been replaced cli_PathList since ...

2. Using workbench.library/WorkbenchControlA(
WBCTRLA_DuplicateSearchPath (BPTR *) -

Ref 1 geit, mentions that the following fails under OS4
if( WorkbenchBase->lib_Version >= 44 ) {
WorkbenchControl( NULL, WBCTRLA_DuplicateSearchPath, &path, TAG_DONE );
}

SystemTags( name, NP_StackSize, stack,
SYS_Output, ohandle,
SYS_Input, ihandle,
SYS_Asynch, TRUE,
NP_Path, path,
TAG_DONE );

docommands.h
SystemTags(marg[0].str, SYS_Input, NULL, SYS_Output, conout, NP_StackSize, usestack, TAG_END);


3. Using AllocDosObjectTaglis(DOS_CLI,NULL)
Ref 1:oBarthel:
" Here's what all those Workbench programs do which clone the Workbench path list (e.g. the "CLI" program in "SYS:System"):
struct CommandLineInterface *cli;

cli = AllocDosObjectTagList(DOS_CLI,NULL);

process->pr_CLI = MKBADDR(cli);
process->pr_Flags |= PRF_FREECLI;



Just make sure that you don't overwrite an existing CLI structure, or you'll get the shell into big trouble your program was launched from. Put another way, make sure you don't attempt to clone the search path unless you were really launched by Workbench."

If it's method 3 , could an example be given ?

Re: Duplicating workbench pathlist

Posted: Mon Dec 30, 2013 12:11 pm
by salass00
I use the following code in my AutoRun commodity:

Code: Select all

void ExecuteAutoRun (CONST_STRPTR command) {
	BPTR path = ZERO;
	BPTR stdin, stdout, stderr;
	int32 error;
	IWorkbench->WorkbenchControl(NULL,
		WBCTRLA_DuplicateSearchPath, &path,
		TAG_END);
	stdin = IDOS->Open("NIL:", MODE_OLDFILE);
	stdout = IDOS->Open("NIL:", MODE_OLDFILE);
	stderr = IDOS->Open("NIL:", MODE_OLDFILE);
	if (stdin && stdout && stderr) {
		error = IDOS->SystemTags(command,
			NP_Name,		"AutoRun Script",
			SYS_Asynch,		TRUE,
			NP_Path,		path,
			NP_CloseError,	TRUE,
			SYS_Input,		stdin,
			SYS_Output,		stdout,
			SYS_Error,		stderr,
			TAG_END);
		if (error != -1) {
			return;
		}
	}
	if (path != ZERO) {
		IWorkbench->WorkbenchControl(NULL,
			WBCTRLA_FreeSearchPath, path,
			TAG_END);
	}
	IDOS->Close(stdin);
	IDOS->Close(stdout);
	IDOS->Close(stderr);
}
Note that I duplicate the path list mainly for commands inside the AutoRun script. I use full path for the execute command as there is no reason for me not to do so ("C:Execute").

Re: Duplicating workbench pathlist

Posted: Wed Jan 01, 2014 1:52 pm
by JosDuchIt
@salass00

Thanks a lot

Re: Duplicating workbench pathlist

Posted: Wed Jan 01, 2014 10:27 pm
by tonyw
salass00 wrote: Note that I duplicate the path list mainly for commands inside the AutoRun script. I use full path for the execute command as there is no reason for me not to do so ("C:Execute").
Are you sure about that? There is no such thing as "C:Execute". "Execute" is an internal Shell command.

Re: Duplicating workbench pathlist

Posted: Thu Jan 02, 2014 11:01 am
by salass00
Are you sure about that? There is no such thing as "C:Execute". "Execute" is an internal Shell command.
Yes, you are right. Execute is a internal resident command in AmigaOS 4.1. I assume this was a change made in AmigaOS 4.0/4.1 because checking my FS-UAE AmigaOS 3.1 install I do have an Execute command in C: there.

Since the command is resident on AmigaOS 4.1 the path ("C:") doesn't matter at all then as only the file name portion ("Execute") is used when checking for resident commands.

Re: Duplicating workbench pathlist

Posted: Thu Jan 02, 2014 12:04 pm
by tonyw
"Execute" is present also in WB3.9:C, so it must have been absorbed into the Shell in 4.0.

Re: Duplicating workbench pathlist

Posted: Thu Jan 02, 2014 10:31 pm
by nbache
tonyw wrote:"Execute" is present also in WB3.9:C, so it must have been absorbed into the Shell in 4.0.
Yep, 51.24 from 7.1.2005. I believe the first public version with Execute integrated was with 4.0 update 3?

Best regards,

Niels