Hi, dunnot if there is a safe/"cleaner" way to get the list of (ARexx) ports, now I'm doing this way:
- popup_arexxports = IExec->AllocSysObjectTags(ASOT_LIST, TAG_DONE);
- struct Node *n, *mstate;
- for(mstate=((struct ExecBase *)SysBase)->PortList.lh_Head; mstate->ln_Succ; mstate=mstate->ln_Succ)
- IDOS->Printf("portname: '%s'\n",mstate->ln_Name);
- //n = ISelect->AllocSelectNode(SGNA_CopyText,TRUE, SGNA_Text,mstate->ln_Name, TAG_DONE);
- //IExec->AddTail(popup_arexxports, n);
Do you wish to communicate with the ports or just list them? There is surely a better way as your method is flawed. Your Forbid() cannot be avoided, so that is fine, but your Printf() will surely break it.
I think the best method in this case is to alloc each node on the fly. Then test and copy the name pointer along with it. You can use a preset string length and count total nodes or do it on the fly.
The list can change at any time so really needs to be cached in memory under a Forbid() lock.
To be honest I don't see the use for such a list.
Firstly you get a list of all named ports. There is no way to tell whether a port accepts ARexx messages or not.
Secondly, each program has a different set of ARexx commands. If you want to address a certain program you should alread know its port name, because it is in the same documentation as the commands. There is no use of choosing a different port because that other program accepts completely different commands only.
Just want to get the list of ports (ARexx) to show on a list. I don't wnat to interactuate with them at all.
See OpenURL (https://github.com/jens-maus/libopenurl) it just has a chooser button where it lists the ports so user can choose one of them.
Changing Forbid/Permit with semaphore is a good idea?
Yes, but a semaphore does not exist for this list.
Thomas reminds me, there is no ARexx port list. Only a public port list. You could filter out all port names with "REXX" but I don't know if it's reliable.
You can't avoid the Forbid(), since AFAIK OS4 still doesn't have any OS support functions for acccessing system lists. A bit overdue I think.
But, if you wish to allocate memory and copy list entries under a Forbid() lock, which used to be fine to do, it can now break the Forbid(). So you just need to be aware of that, even though in general it shouldn't be a problem. Would even help if lists had a node count, seems obvious now.
I wish doing "say show(ports)" listed only rexx ports. And that there was something like how python will list all the commands in a module.