Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!sundc!pitstop!sun!amdcad!ames!ucbcad!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga Subject: Re: Help on Access to Exec system lists in C Message-ID: <8711020235.AA22207@cory.Berkeley.EDU> Date: Sun, 1-Nov-87 21:35:25 EST Article-I.D.: cory.8711020235.AA22207 Posted: Sun Nov 1 21:35:25 1987 Date-Received: Thu, 5-Nov-87 22:17:01 EST Sender: daemon@ucbvax.BERKELEY.EDU Lines: 53 >Does anybody out there know how to get access to the system lists that >Exec keeps? I know about the list routines provided by exec, but I >want to get pointers to the head of certain lists. I'd also like to >be able to get access to any lists held in Intuition. For example, The lists are kept in the library structures for EXEC and INTUITION. Take a look at EXEC/EXECBASE.H, and INTUITION/INTUITIONBASE.H . As far as EXEC goes, you can get a pointer to ExecBase simply by looking at the global variable SysBase (extern struct ExecBase *SysBase;). As far as INTUITION goes, you open the intuition.library, and the returned pointer is actually a pointer to IntuitionBase. It should be obvious how to get to various structures, such as the screen list Intuition is keeping (and subsequent window lists), by simply looking at the include files mentioned above. WARNING: In many cases these lists are changing continuously, and cannot be assumed to be stable unless accessed in a Forbid()'n state. You must be Forbiden for the entire list traversal, and cannot assume any of the nodes will stay around after you have Permit()'d again. LISTS: (EXEC/LISTS.H, EXEC/NODES.H) The major components of a list header structure are lh_Head, lh_Tail, and lh_TailPred. lh_Tail is always NULL and serves to terminate the list. That is, an empty list would have lh_Head pointing to lh_Tail, and lh_TailPred pointing to lh_Head. Non-empty lists have lh_Head pointing to the first node in the list, lh_Tail is always NULL, and lh_TailPred pointing to the last node in the list (which might be the first if there is only one node) The major components of a list node (specific list entries) are ln_Succ and ln_Pred. ln_Succ points to the next node in the list OR lh_Tail of the list header if the particular node is the last node in the list. ln_Pred points to the previous node in the list OR lh_Head of the list header if the particular node is the first node in the list. This may seem complicated, but has the following advantages: -A fully doubly linked list allowing random insertion, deletion, and scanning in both directions. -No special cases when adding a node to the front of the list, the end of the list, or anywhere within the list. -No special cases when removing a node. When traversing the list, the end of the list is detected when ln_Succ points to a NULL value (NOT when ln_Succ is NULL). Similarly, when traversing the list in reverse, the first node is detected when offset 4 from where ln_Prev points to is NULL. This NULL of course is the lh_Tail entry in the list header. -Matt