home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / program / lynxlib / getcooki.c < prev    next >
C/C++ Source or Header  |  1993-10-23  |  991b  |  37 lines

  1. /* getcookie(): C procedure to find cookies and values
  2. This is taken from Atari's STE Developer Notes, January 12, 1990.
  3.  
  4. BOOLEAN getcookie(cookie, p_value)
  5. LONG cookie; LONG *p_value;
  6.  
  7. Returns FALSE if 'cookie' is not found in the cookie jar.  If the
  8. cookie is found, it returns TRUE and places the cookie's value into
  9. *p_value.  If p_value == NULL, it doesn't put the value anywhere.
  10.  
  11. */
  12. #include <sysvar.h>
  13.  
  14. COOKIE *get_cookie_ptr(target)
  15. LONG target;        /* Cookie to search for */
  16. {
  17. COOKIE *p;
  18.     p = (COOKIE *)peekl(p_cookies);
  19.     if (p != NULL) do {
  20.         if (p->c == target) return p;
  21.     } while ((p++)->c != 0);
  22.     return NULL;
  23. }
  24. /* ------------------------------------------------------- */
  25. BOOLEAN getcookie(target, p_value)
  26. LONG target;        /* Cookie to search for */
  27. LONG *p_value;        /* Place to store value of cookie */
  28. {
  29. COOKIE *p;
  30.     p = get_cookie_ptr(target);
  31.     if (p == NULL) return FALSE;
  32.     else {
  33.         if (p_value != NULL) *p_value = p->v;
  34.         return TRUE;
  35.     }
  36. }
  37.