[comp.sys.atari.st.tech] Cookie Jar

jrhine@cbrown.claremont.edu (09/30/90)

Ok, I can't wait any longer.  Forgive me, but what is a cookie-jar?  Before
recieving access to the net, I had never heard of such a thing.  I can't seem
to pick up its function from the context of messages discussing it.  Anyone
care to fill me in?

entropy@churchy.ai.mit.edu (Nick Castellano) (09/30/90)

In article <1990Sep29.130821.1@cbrown.claremont.edu> jrhine@cbrown.claremont.edu writes:
>Ok, I can't wait any longer.  Forgive me, but what is a cookie-jar?  Before
>recieving access to the net, I had never heard of such a thing.  I can't seem
>to pick up its function from the context of messages discussing it.  Anyone
>care to fill me in?

The cookie jar is an area of memory.  Any program can insert its
cookie into the cookie jar.  Then other programs can scan the cookie
jar to see if that program has been run.  A program which installs
memory-resident code can use this to recognize that it has already
been installed, so it won't install itself twice.  Another program
which relies on features of a specific memory resident programs (for
example, one which extends the Bios) can make sure that program has
been installed.


--
  | | |   ncastellano@{eagle.wesleyan.edu, wesleyan.bitnet}
  | | |   entropy@ai.mit.edu
 /  |  \  Sinkhole!dEADHEAd[@mast.citadel.moundst.mn.org] (call 203-873-8518)
/   |   \ snikt!entropy

jrhine@linus.claremont.edu (09/30/90)

Sounds cool.  Where's this memory located?  I've written five or ten TSR and
I'd like to go back and and this feature to those.  Thanks.

entropy@mole.ai.mit.edu (Nick Castellano) (09/30/90)

Dunno, I've never had to use it.  Anyone else?  The question is:  
Where is the cookie jar, or how does one find out where it is?

     nick

--
  | | |   ncastellano@{eagle.wesleyan.edu, wesleyan.bitnet}
  | | |   entropy@ai.mit.edu
 /  |  \  Sinkhole!dEADHEAd[@mast.citadel.moundst.mn.org] (call 203-873-8518)
/   |   \ snikt!entropy

csbrod@medusa.informatik.uni-erlangen.de (Claus Brod ) (10/02/90)

entropy@mole.ai.mit.edu (Nick Castellano) writes:

>Dunno, I've never had to use it.  Anyone else?  The question is:  
>Where is the cookie jar, or how does one find out where it is?


Look at the contents of $5A0.L to find out the start address of the
current cookie jar. If it's zero, noone has installed it yet, and you
will have to do that yourself. The cookie jar is always terminated
by a special cookie. Like all the other cookies, its length is
8 bytes (4 bytes for identification of your program - much like
XBRA IDs; IDs starting with an underscore are reserved for ATARI;
some program-specific info follows the ID). The ID part of the
last cookie is always a zero longword, and its data part gives
you the size of the current cookie jar in units of cookies (8 bytes).
If you find out that inserting your own cookie would result in

memory overflow you must allocate a cookie jar of your own and
keep it resident.

----------------------------------------------------------------------
Claus Brod, Am Felsenkeller 2,			Things. Take. Time.
D-8772 Marktheidenfeld, West Germany		(Piet Hein)
csbrod@medusa.informatik.uni-erlangen.de
----------------------------------------------------------------------

dbrooks@osf.org (David Brooks) (10/02/90)

In article <3142@medusa.informatik.uni-erlangen.de>, csbrod@medusa.informatik.uni-erlangen.de (Claus Brod ) writes:
> [ a description of the cookie jar ]

How can I distinguish an unallocated slot in the cookie jar?  Does it
have a special tag part, or is its value part (current jar capacity)
some "impossible" number?
-- 
David Brooks				dbrooks@osf.org
Systems Engineering, OSF		uunet!osf.org!dbrooks
"A Loaf of Bread, a Jug of Wine, and Six Spades Redoubled" -- Omar somebody.

csbrod@medusa.informatik.uni-erlangen.de (Claus Brod ) (10/03/90)

dbrooks@osf.org (David Brooks) writes:

>In article <3142@medusa.informatik.uni-erlangen.de>, csbrod@medusa.informatik.uni-erlangen.de (Claus Brod ) writes:
>> [ a description of the cookie jar ]

>How can I distinguish an unallocated slot in the cookie jar?  Does it
>have a special tag part, or is its value part (current jar capacity)
>some "impossible" number?
>-- 
There are no unallocated slots in a cookie jar. If you want to delete
a cookie once installed you must compact the cookie jar.

----------------------------------------------------------------------
Claus Brod, Am Felsenkeller 2,			Things. Take. Time.
D-8772 Marktheidenfeld, West Germany		(Piet Hein)
csbrod@medusa.informatik.uni-erlangen.de
----------------------------------------------------------------------

gt1448b@prism.gatech.EDU (David P. Forrai) (10/18/90)

In article <7204.27062454@uwovax.uwo.ca> 7103_2622@uwovax.uwo.ca
(Eric Smith) writes:

>  ... (some text and source code)
>/*
> * A pointer to the cookie jar is found at 0x5a0. If there is no cookie jar
> * installed, this pointer will be 0. The cookie jar itself is an array
> * of cookies, with the last cookie having a "tag" of 0x00000000. (The value
> * of this cookie is the number of slots left in the cookie jar.)
> */

and in article <3142@medusa.informatik.uni-erlangen.de>
csbrod@medusa.informatik.uni-erlangen.de (Claus Brod ) writes:

> ... (original post and other cookie jar info)
>some program-specific info follows the ID). The ID part of the
>last cookie is always a zero longword, and its data part gives
>you the size of the current cookie jar in units of cookies (8 bytes).

So what is the value/data part of the last cookie "officially" supposed
to be, the number of cookie slots remaining or the size of the cookie
jar in cookies?

---
David P. Forrai
uucp:	  ...!{decvax,hplabs,ncar,purdue,rutgers}!gatech!prism!gt1448b
Internet: gt1448b@prism.gatech.edu

apratt@atari.UUCP (Allan Pratt) (10/19/90)

gt1448b@prism.gatech.EDU (David P. Forrai) writes:
>In article <7204.27062454@uwovax.uwo.ca> 7103_2622@uwovax.uwo.ca
>(Eric Smith) writes:
>>The ID part of the
>>last cookie is always a zero longword, and its data part gives
>>you the size of the current cookie jar in units of cookies (8 bytes).

>So what is the value/data part of the last cookie "officially" supposed
>to be, the number of cookie slots remaining or the size of the cookie
>jar in cookies?

I think it was perfectly obvious from Eric Smith's posting: the "value"
part of the zero cookie contains the size of the cookie jar, in cookies.
Multiply by 8 for the size of the cookie jar in bytes.  This is regardless
of how many slots are actually USED.  To install a cookie into a 
cookie jar which has one or more slots available, you move the zero cookie
down one, and put your new cookie in just before it.  You don't change
the value of the zero cookie, because you didn't change the size of
the cookie jar.

============================================
Opinions expressed above do not necessarily	-- Allan Pratt, Atari Corp.
reflect those of Atari Corp. or anyone else.	  ...ames!atari!apratt

csbrod@medusa.informatik.uni-erlangen.de (Claus Brod ) (10/19/90)

gt1448b@prism.gatech.EDU (David P. Forrai) writes:

>So what is the value/data part of the last cookie "officially" supposed
>to be, the number of cookie slots remaining or the size of the cookie
>jar in cookies?

Sorry if I wasn't clear enough. The value part of the last cookie
contains the size of the cookie jar in cookies.

----------------------------------------------------------------------
Claus Brod, Am Felsenkeller 2,			Things. Take. Time.
D-8772 Marktheidenfeld, West Germany		(Piet Hein)
csbrod@medusa.informatik.uni-erlangen.de
----------------------------------------------------------------------

7103_2622@uwovax.uwo.ca (Eric Smith) (10/20/90)

> In article <7204.27062454@uwovax.uwo.ca> 7103_2622@uwovax.uwo.ca
> (Eric Smith) writes:
> 
>>  ... (some text and source code)
>>/*
>> * A pointer to the cookie jar is found at 0x5a0. If there is no cookie jar
>> * installed, this pointer will be 0. The cookie jar itself is an array
>> * of cookies, with the last cookie having a "tag" of 0x00000000. (The value
>> * of this cookie is the number of slots left in the cookie jar.)
>> */
> 
Aargh! I can't believe I wrote this (but checking, I see a similar comment
in the MiNT source code, so I probably did). As with all comments in source
code, it should be ignored :-).

Claus was right; the value should be the *total* number of slots in the
cookie jar, not the number remaining. (Watch out under MiNT -- MiNT 0.6
gets this wrong, despite clear documentation to the contrary. I made the
mistake of believing my comment. Fortunately, MiNT allocates a completely
new cookie jar with extra room, and it should run after everything in the
AUTO folder, so this probably isn't a problem. It'll be fixed in 0.7).
--
Eric R. Smith                     email:
Dept. of Mathematics            ersmith@uwovax.uwo.ca
University of Western Ontario   ersmith@uwovax.bitnet
London, Ont. Canada N6A 5B7
ph: (519) 661-3638