1*a466cc55SCy Schubert /* 2*a466cc55SCy Schubert * Copyright (C) 2004-2007 Internet Systems Consortium, Inc. ("ISC") 3*a466cc55SCy Schubert * Copyright (C) 1999-2001 Internet Software Consortium. 4*a466cc55SCy Schubert * 5*a466cc55SCy Schubert * Permission to use, copy, modify, and/or distribute this software for any 6*a466cc55SCy Schubert * purpose with or without fee is hereby granted, provided that the above 7*a466cc55SCy Schubert * copyright notice and this permission notice appear in all copies. 8*a466cc55SCy Schubert * 9*a466cc55SCy Schubert * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 10*a466cc55SCy Schubert * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11*a466cc55SCy Schubert * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 12*a466cc55SCy Schubert * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13*a466cc55SCy Schubert * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14*a466cc55SCy Schubert * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15*a466cc55SCy Schubert * PERFORMANCE OF THIS SOFTWARE. 16*a466cc55SCy Schubert */ 17*a466cc55SCy Schubert 18*a466cc55SCy Schubert /* $Id: magic.h,v 1.18 2007/06/19 23:47:18 tbox Exp $ */ 19*a466cc55SCy Schubert 20*a466cc55SCy Schubert #ifndef ISC_MAGIC_H 21*a466cc55SCy Schubert #define ISC_MAGIC_H 1 22*a466cc55SCy Schubert 23*a466cc55SCy Schubert /*! \file isc/magic.h */ 24*a466cc55SCy Schubert 25*a466cc55SCy Schubert typedef struct { 26*a466cc55SCy Schubert unsigned int magic; 27*a466cc55SCy Schubert } isc__magic_t; 28*a466cc55SCy Schubert 29*a466cc55SCy Schubert 30*a466cc55SCy Schubert /*% 31*a466cc55SCy Schubert * To use this macro the magic number MUST be the first thing in the 32*a466cc55SCy Schubert * structure, and MUST be of type "unsigned int". 33*a466cc55SCy Schubert * The intent of this is to allow magic numbers to be checked even though 34*a466cc55SCy Schubert * the object is otherwise opaque. 35*a466cc55SCy Schubert */ 36*a466cc55SCy Schubert #define ISC_MAGIC_VALID(a,b) (((a) != NULL) && \ 37*a466cc55SCy Schubert (((const isc__magic_t *)(a))->magic == (b))) 38*a466cc55SCy Schubert 39*a466cc55SCy Schubert #define ISC_MAGIC(a, b, c, d) ((a) << 24 | (b) << 16 | (c) << 8 | (d)) 40*a466cc55SCy Schubert 41*a466cc55SCy Schubert #endif /* ISC_MAGIC_H */ 42