•  Back 
  •  Cookie jar 
  •  Index 
  •  Tree View 
  •  Cross references 
  •  Help page 
  •  Show info about hypertext 
  •  View a new file 
Topic       : TOS - The Operating System
Author      : 
Version     : tos.hyp (December 19, 2008)
Subject     : Programmieren/Atari
Nodes       : 3010
Index Size  : 93790
HCP-Version : 5
Compiled on : Atari
@charset    : atarist
@lang       : 
@default    : Title
@help       : 
@options    : +g -i -s +x +zz -t4
@width      : 70
View Ref-File3.7.1  Sample code                                                 TOS

/* 'get_cookie':  Inquires the value of a cookie.
                  The parameters passed for this are the ID of the
                  cookie to be found, as well as a pointer to the
                  found value.

                  The routine returns the value FALSE if the
                  specified cookie does not exist... */

typedef struct
{
    LONG id;             /* Identification code */
    LONG value;          /* Value of the cookie */
} COOKJAR;


WORD get_cookie( LONG cookie, void *value )
{
  static WORD use_ssystem = -1;
  COOKJAR *cookiejar;
  LONG    val = -1l;
  WORD    i=0;

  if( use_ssystem < 0 )
    use_ssystem = (Ssystem(S_INQUIRE, 0l, 0)==E_OK);

  if(use_ssystem)
  {
    if( Ssystem(S_GETCOOKIE, cookie, (LONG)&val)==E_OK )
    {
      if( value!=NULL )
        *(LONG *)value = val;
      return TRUE;
    }
  }
  else
  {
    /* Get pointer to cookie jar */
    cookiejar = (COOKJAR *)(Setexc(0x05A0/4,(const void (*)(void))-1));
    if( cookiejar )
    {
      for( i=0 ; cookiejar[i].id ; i++ )
        if( cookiejar[i].id==cookie )
        {
          if( value )
            *(LONG *)value = cookiejar[i].value;
          return TRUE;
        }
    }
  }

  return FALSE;
}