[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MiNT-Lib - getcooki.c



Hi!

Somebody really use this function? Lots of bugs ...

Here is a updated version. Any comments?

---
/*
 * Getcookie for MiNTlib
 * 
 * Author: jerry g geiger
 * 
 * - Ssystem extension Draco
 * - corrected by Frank Naumann, 1998-09-09
 * 
 * returns:
 * 
 * 	- E_OK if cookie was found
 * 	- negative error number if cookie is missing
 * 	
 * 	if p_value is set, cookie value is copied to *p_value
 * 
 */

# include <osbind.h>
# include <mintbind.h>
# include <ssystem.h>
 
static long
getcookieptr (void)
{
	return *((long *) 0x5a0);
}

int
Getcookie (long cookie, long *p_value)
{
	if (Ssystem (-1, 0, 0)) /* better a global _has_ssystem? */
	{
		/* old method */
		
		long *cookieptr = (long *) Supexec (getcookieptr);
		
		if (cookieptr)
		{
			while (*cookieptr)
			{
				if (*cookieptr == cookie)
				{
					if (p_value)
						*p_value = cookieptr [1];
					
					return E_OK;
				}
				
				cookieptr += 2;
			}
		}
		
		return ERROR;
	}
	
	/* Ssystem supported, use it */
	
	return Ssystem (GETCOOKIE, cookie, p_value);
}
---

Tschuess
   ...Frank

--
ATARI FALCON 040
--------------------------------------
Internet: fnaumann@cs.uni-magdeburg.de
Mausnet:  Frank Naumann @ L2