11 December 2021, 12:40 | #1 |
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
|
input/output file handles and wb startup
Hi all,
I'm in the process of adding complete wb startup support for all my programs so i need to be cautious. Here it's about input/output file handles normal cli processes all have : if run from wb i see null value for both. If would however be handly for me to be able to continue using things such as PutStr directly. Would remove lots of special cases. Can i just open a console window and set them ? Any particular precaution to take ? (Most notably : is same handle allowed for both, must i restore anything upon exit and if so, is simple clearing ok to do.) In addition if i open a console window, is there a simple and clean way to duplicate the "output window" wb opens by itself when running a program from a pseudo-icon ? (Instead of using hard-coded values.) |
11 December 2021, 16:24 | #2 | ||||
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,245
|
Quote:
Quote:
Quote:
Again, just be careful to only close what you opened. The workbench does not care about the handles there, it neither touches them, so in principle, dangling pointers in there are allowed - but I'd still call this "bad style". Clean up after you. Quote:
Thus, that is the very same thing you get when your program is run from an "interactive" shell, no difference. If you want to open a stream in both cases, one possibility is to open "*" in the shell startup instead of the workbench startup, but this always gives you the console, and not the output file handle (i.e. there will be a difference if your output has been redirected). There is unfortunately no generally valid way how to "clone" a file handle, only for interactive handles (such as the console, SER: or AUX: A generally nice way to have a unique startup code is to create from the tool types array arguments and create a ReadArgs structure from them, then pass the same thing into the shell startup. This way, you don't have to write two argument parsers. (This is one of the unorthonogalities of AmigaOs I consider an issue of bad design, i.e. such a function should be somewhere in the Os rather than having to rewrite it every time again). |
||||
11 December 2021, 17:26 | #3 | |||||||
son of 68k
Join Date: Nov 2007
Location: Lyon / France
Age: 51
Posts: 5,335
|
Quote:
Workbench won't automatically parse that tooltype and open the console window with safe default values, especially the title bar using the system's locale. Quote:
Quote:
Quote:
Quote:
Quote:
Opening "*" is of no use - if run from cli i already have everything at hand, and from WB it doesn't work (gives a valid handle but output goes nowhere). Quote:
ReadArgs is great, tooltypes are great, but we really lack a unified scheme... |
|||||||
11 December 2021, 19:39 | #4 | |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,245
|
Quote:
Strangely, there is a field do_ToolWindow in the disk object (see workbench/icon.h), which is read and written by the icon.library as a 0-terminated string, but the workbench provides no means to edit it and neither populates or uses it. Thus, potentially, there was quite a long way ago a plan to provide something like this, but the idea apparently got lost. |
|
11 December 2021, 19:56 | #5 | ||
Registered User
Join Date: Oct 2008
Location: EU
Posts: 163
|
Quote:
Quote:
It basically says, the field contains a pointer to a string with a CON:/RAW: window definition which should be used for standard in/output of the program and the window pointer will be written to some other structures automatically. Edit: Some further research shows, that Directory Opus 5 obviously respected do_ToolWindow also with other values than NULL, file dopus5allamigas/source/Library/wb.c:1639 at github.com Code:
// Tool window? if (icon->do_ToolWindow && (copy->doc_DiskObject.do_ToolWindow = L_AllocMemH(data->memory, strlen(icon->do_ToolWindow) + 1))) strcpy(copy->doc_DiskObject.do_ToolWindow, icon->do_ToolWindow); Last edited by a4k-oerx; 11 December 2021 at 21:57. Reason: Directory Opus 5 sourcecode |
||
12 December 2021, 00:17 | #6 |
Registered User
Join Date: Jan 2019
Location: Germany
Posts: 3,245
|
What you see there in the German manual is just a direct copy/translation of what the RKRMs 1st edition stated about the field, literally. The 3rd edition just states (correctly) that this field is "reserved for future use". Actually, it was never used and was always reserved.
What DOpus does here is pretty much the same what the icon.library does: It carries the field around, but it doesn't touch or interpret it. Even the llatest icon.library copies the data, and the data is also part of the .info file and will be written and read back from disk. Just that it's of no particular use, and cannot be set from the user. |
12 December 2021, 17:35 | #7 | |
Registered User
Join Date: Oct 2008
Location: EU
Posts: 163
|
My RKRMs 1st edition actually state something different (did not even bother to look there first), main difference marked in quote.
Quote:
So I guess nothing besides the field in structure was implemented at any time on OS side. On the other hand, especially with Amiga you never know, what has actually been done but later dropped due to ROM space or similar etc. or if/where this "startup script" was actually available or wasn't Last edited by a4k-oerx; 12 December 2021 at 17:46. |
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Is there some compiler providing resource tracking for malloc/free/FILE* handles? | jotd | Coders. C/C++ | 3 | 29 December 2018 11:58 |
Two input, Single Output - Mouse/Joystick Auto Switching | solidcore | Hardware mods | 14 | 24 May 2018 22:33 |
Two input, Single Output - Mouse/Joystick Auto Switch | solidcore | MarketPlace | 0 | 02 April 2018 01:30 |
startup-sequence file help | sb1987 | New to Emulation or Amiga scene | 3 | 04 January 2012 06:56 |
File input with Blitz | MelOtt | Coders. General | 0 | 05 January 2005 17:48 |
|
|