purely cosmetic commit: edited the introductory comments of several files to uniform...
[reactos.git] / posix / lib / psxdll / misc / safeobj.c
1 /* $Id: safeobj.c,v 1.2 2002/02/20 09:17:57 hyperion Exp $
2 */
3 /*
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>
9 * UPDATE HISTORY:
10 * 09/01/2002: Created
11 */
12
13 #include <psx/safeobj.h>
14 #include <psx/debug.h>
15
16 int __safeobj_validate(void *obj, __magic_t refsignature)
17 {
18 if(obj == 0)
19 return (0);
20 else
21 {
22 /* cast the object to a magic number */
23 __magic_t mSignature = *((__magic_t *)obj);
24
25 ERRIF
26 (
27 mSignature != refsignature,
28 "invalid object at %X: signature is \"%c%c%c%c\", should be \"%c%c%c%c\"",
29 obj,
30 MAGIC_DECOMPOSE(refsignature),
31 MAGIC_DECOMPOSE(mSignature)
32 );
33
34 if(mSignature == refsignature)
35 /* signatures match: ok */
36 return (-1);
37 else
38 /* signatures mismatch: fail */
39 return (0);
40
41 }
42 }
43
44 /* EOF */
45