1 /* $Id: safeobj.c,v 1.2 2002/02/20 09:17:57 hyperion Exp $
4 * COPYRIGHT: See COPYING in the top level directory
5 * PROJECT: ReactOS POSIX+ Subsystem
6 * FILE: subsys/psx/lib/psxdll/misc/safeobj.c
7 * PURPOSE: safe checking of user-provided objects
8 * PROGRAMMER: KJK::Hyperion <noog@libero.it>
13 #include <psx/safeobj.h>
14 #include <psx/debug.h>
16 int __safeobj_validate(void *obj
, __magic_t refsignature
)
22 /* cast the object to a magic number */
23 __magic_t mSignature
= *((__magic_t
*)obj
);
27 mSignature
!= refsignature
,
28 "invalid object at %X: signature is \"%c%c%c%c\", should be \"%c%c%c%c\"",
30 MAGIC_DECOMPOSE(refsignature
),
31 MAGIC_DECOMPOSE(mSignature
)
34 if(mSignature
== refsignature
)
35 /* signatures match: ok */
38 /* signatures mismatch: fail */