Safe way to list ARexx port list

7 posts / 0 new
Last post
jabirulo
jabirulo's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 2013-05-30 00:53
Safe way to list ARexx port list

Hi, dunnot if there is a safe/"cleaner" way to get the list of (ARexx) ports, now I'm doing this way:

  1. popup_arexxports = IExec->AllocSysObjectTags(ASOT_LIST, TAG_DONE);
  2. {
  3. struct Node *n, *mstate;
  4.  
  5. IExec->Forbid();
  6. for(mstate=((struct ExecBase *)SysBase)->PortList.lh_Head; mstate->ln_Succ; mstate=mstate->ln_Succ)
  7. {
  8. IDOS->Printf("portname: '%s'\n",mstate->ln_Name);
  9. //n = ISelect->AllocSelectNode(SGNA_CopyText,TRUE, SGNA_Text,mstate->ln_Name, TAG_DONE);
  10. //IExec->AddTail(popup_arexxports, n);
  11. }
  12. IExec->Permit();
  13. }
  14. ..
  15. freelistist(popup_arexxports);
hypex
hypex's picture
Offline
Last seen: 2 months 1 week ago
Joined: 2011-09-09 16:20
Re: Safe way to list ARexx port list

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.

thomas
thomas's picture
Offline
Last seen: 1 week 3 days ago
Joined: 2011-05-16 14:23
Re: Safe way to list ARexx port list

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.

jabirulo
jabirulo's picture
Offline
Last seen: 2 weeks 4 days ago
Joined: 2013-05-30 00:53
Re: Safe way to list ARexx port list

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?

AOS4.1/SAM460ex/PPC460EX-1155MHZ/2048MB/RadeonHD6570/SSD120GB/DVDRW :-P

thomas
thomas's picture
Offline
Last seen: 1 week 3 days ago
Joined: 2011-05-16 14:23
Re: Safe way to list ARexx port list

Changing Forbid/Permit with semaphore is a good idea?

Yes, but a semaphore does not exist for this list.

https://os4coding.net/comment/2716#comment-2716

hypex
hypex's picture
Offline
Last seen: 2 months 1 week ago
Joined: 2011-09-09 16:20
Re: Safe way to list ARexx port 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.

MobileConnect
MobileConnect's picture
Offline
Last seen: 2 years 11 months ago
Joined: 2021-03-08 19:05
Re: Safe way to list ARexx port list

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.

Log in or register to post comments