5 #include <exec/types.h>
6 #include <graphics/gels.h>
7 #include <graphics/rastport.h>
8 #include <intuition/classes.h>
9 #include <intuition/classusr.h>
10 #include <workbench/workbench.h>
11 #include <workbench/startup.h>
12 #include <dos/dostags.h>
16 #include <proto/dos.h>
17 #include <proto/exec.h>
18 #include <proto/intuition.h>
20 #include <proto/scalos.h>
22 #include <clib/alib_protos.h>
24 #include <datatypes/iconobject.h>
32 #include "scalos_structures.h"
34 #include "functions.h"
35 #include "Variables.h"
37 //----------------------------------------------------------------------------
39 // local data structures
41 //----------------------------------------------------------------------------
45 //----------------------------------------------------------------------------
48 BOOL
CLIStart(BPTR dirLock
, CONST_STRPTR PrgName
, Object
*iconObject
, ULONG def_StackSize
)
53 ULONG StackSize
= def_StackSize
;
57 const struct DiskObject
*icon
= NULL
;
59 oldCurrentDir
= CurrentDir(dirLock
);
61 GetAttr(IDTA_DefaultTool
, iconObject
, (APTR
) &defTool
);
62 GetAttr(IDTA_Stacksize
, iconObject
, &StackSize
);
63 GetAttr(AIDTA_Icon
, iconObject
, (APTR
) &icon
);
66 defTool
= (STRPTR
) "";
68 if (StackSize
< def_StackSize
)
69 StackSize
= def_StackSize
;
71 d1(kprintf("%s/%s/%ld: PrgName=<%s> deftool=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, PrgName
, defTool
));
73 GetAttr(IDTA_Type
, iconObject
, (ULONG
*) &IconType
);
74 switch ((ULONG
) IconType
)
77 case WB_TEXTICON_TOOL
:
78 CmdLen
= strlen(PrgName
) + 10;
82 GetAttr(DTA_Name
, iconObject
, (APTR
) &PrgName
);
84 PrgName
= (STRPTR
) "";
86 CmdLen
= strlen(PrgName
) + strlen(defTool
) + 10;
93 d1(kprintf("%s/%s/%ld: PrgName=<%s> deftool=<%s>\n", __FILE__
, __FUNC__
, __LINE__
, PrgName
, defTool
));
95 cmd
= AllocVec(CmdLen
, MEMF_PUBLIC
);
98 BPTR inputFH
, outputFH
;
102 switch ((ULONG
) IconType
)
105 case WB_TEXTICON_TOOL
:
106 ScaFormatStringMaxLength(cmd
, CmdLen
, "\"%s\"", (ULONG
) PrgName
);
109 ScaFormatStringMaxLength(cmd
, CmdLen
, "\"%s\" \"%s\"", (ULONG
) defTool
, (ULONG
) PrgName
);
116 if (icon
&& icon
->do_ToolWindow
&& strlen(icon
->do_ToolWindow
))
117 CliName
= (STRPTR
) icon
->do_ToolWindow
;
119 CliName
= (STRPTR
) CurrentPrefs
.pref_ConsoleName
; // was: "CON:////Scalos CLI/AUTO"
121 outputFH
= (BPTR
)NULL
; // ... see SystemTagList() AutoDoc
122 inputFH
= Open(CliName
, MODE_NEWFILE
);
124 d1(kprintf("%s/%s/%ld: inputFH=%08lx outputFH=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, inputFH
, outputFH
));
127 Error
= SystemTags(cmd
,
129 SYS_Output
, outputFH
,
132 NP_StackSize
, StackSize
,
133 NP_Path
, DupWBPathList(),
136 d1(kprintf("%s/%s/%ld: SystemTags returned %ld\n", __FILE__
, __FUNC__
, __LINE__
, Error
));
138 if (RETURN_OK
== Error
)
144 CurrentDir(oldCurrentDir
);
150 BPTR
DupWBPathList(void)
152 struct Process
*wbProc
= ScalosMainTask
;
153 struct CommandLineInterface
*cli
;
154 struct AssignList
*aList
, *StartList
= NULL
, **nList
= NULL
;
156 d1(KPrintF("%s/%s/%ld: wbProc=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, wbProc
));
159 if (NT_PROCESS
!= wbProc
->pr_Task
.tc_Node
.ln_Type
)
162 cli
= BADDR(wbProc
->pr_CLI
);
166 aList
= BADDR(cli
->cli_CommandDir
);
172 struct AssignList
*nNode
= AllocVec(sizeof(struct AssignList
), MEMF_PUBLIC
);
179 *nList
= (struct AssignList
*) MKBADDR(nNode
);
181 nNode
->al_Next
= NULL
;
182 nNode
->al_Lock
= DupLock(aList
->al_Lock
);
183 nList
= &nNode
->al_Next
;
185 d1(kprintf("%s/%s/%ld: aList=%08lx Next=%08lx Lock=%08lx\n", __FILE__
, __FUNC__
, __LINE__
, \
186 aList
, aList
->al_Next
, aList
->al_Lock
));
188 aList
= BADDR(aList
->al_Next
);
191 return MKBADDR(StartList
);