magic.c

Go to the documentation of this file.
00001 /*                         M A G I C . C
00002  * BRL-CAD
00003  *
00004  * Copyright (c) 2004-2006 United States Government as represented by
00005  * the U.S. Army Research Laboratory.
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public License
00009  * as published by the Free Software Foundation; either version 2 of
00010  * the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public
00018  * License along with this file; see the file named COPYING for more
00019  * information.
00020  */
00021 
00022 /** \addtogroup magic */
00023 /*@{*/
00024 /** @file magic.c
00025  *
00026  *@brief routines for looking up magic numbers
00027  *
00028  *  Routines involved with handling "magic numbers" used to identify
00029  *  various in-memory data structures.
00030  *
00031  *  The one ugly thing about this strategy is that every BRL-CAD
00032  *  library needs to have it's magic numbers registered here.
00033  *  XXX What is needed is an extension mechanism.
00034  *  It is a shame that C does not provide a wextern (weak extern) declaration.
00035  *
00036  *
00037  *  @author     Lee A. Butler
00038  *  @author     Michael John Muuss
00039  *
00040  *  @par Source -
00041  *      SECAD/VLD Computing Consortium, Bldg 394
00042  * @n   The U. S. Army Ballistic Research Laboratory
00043  * @n   Aberdeen Proving Ground, Maryland  21005-5066
00044  */
00045 
00046 #ifndef lint
00047 static const char RCSmagic[] = "@(#)$Header: /cvsroot/brlcad/brlcad/src/libbu/magic.c,v 14.12 2006/09/03 15:14:07 lbutler Exp $ (BRL)";
00048 #endif
00049 
00050 #include "common.h"
00051 
00052 #include <stdio.h>
00053 #include "machine.h"
00054 #include "vmath.h"
00055 #include "nmg.h"
00056 #include "bu.h"
00057 #include "bn.h"
00058 #include "raytrace.h"
00059 #include "rtgeom.h"
00060 #include "msr.h"
00061 #include "wdb.h"
00062 #include "spm.h"
00063 #include "../libbu/rb_internals.h"
00064 
00065 /**
00066  *                      B U _ I D E N T I F Y _ M A G I C
00067  *
00068  *  Given a number which has been found in the magic number field of
00069  *  a structure (which is typically the first entry),
00070  *  determine what kind of structure this magic number pertains to.
00071  *  This is called by the macro BU_CK_MAGIC() to provide a "hint"
00072  *  as to what sort of pointer error might have been made.
00073  */
00074 const char *
00075 bu_identify_magic(register long int magic)
00076 {
00077         switch(magic)  {
00078         case 0:
00079                 return "Zero_Magic_Number";
00080         default:
00081                 return "Unknown_Magic";
00082         /*
00083          *  tabdata.h
00084          */
00085         case BN_TABLE_MAGIC:
00086                 return "bn_table";
00087         case BN_TABDATA_MAGIC:
00088                 return "bn_tabdata";
00089         /*
00090          *  bu.h
00091          */
00092         case BU_LIST_HEAD_MAGIC:
00093                 return "bu_list";
00094         case BU_BITV_MAGIC:
00095                 return "bu_bitv";
00096         case BU_HIST_MAGIC:
00097                 return "bu_hist";
00098         case BU_PTBL_MAGIC:
00099                 return "bu_ptbl";
00100         case BU_MAPPED_FILE_MAGIC:
00101                 return "bu_mapped_file";
00102         case BU_AVS_MAGIC:
00103                 return "bu_attribute_value_set";
00104         case BU_VLS_MAGIC:
00105                 return "bu_vls";
00106         case BU_EXTERNAL_MAGIC:
00107                 return "bu_external";
00108         case BU_COLOR_MAGIC:
00109                 return "bu_color";
00110         case BU_RB_TREE_MAGIC:
00111                 return "bu_rb_tree";
00112 
00113         /*
00114          *  bn.h
00115          */
00116         case BN_TOL_MAGIC:
00117                 return "bn_tol";
00118         case BN_POLY_MAGIC:
00119                 return "bn_poly";
00120         case BN_UNIF_MAGIC:
00121                 return "bn_unif";
00122         case BN_GAUSS_MAGIC:
00123                 return "bn_gauss";
00124         case BN_VLIST_MAGIC:
00125                 return("bn_vlist");
00126         case BN_VLBLOCK_MAGIC:
00127                 return("bn_vlblock");
00128 
00129         /*
00130          *  nmg.h:  NMG magic numbers
00131          */
00132         case NMG_MODEL_MAGIC:
00133                 return("model");
00134         case NMG_REGION_MAGIC:
00135                 return("region");
00136         case NMG_REGION_A_MAGIC:
00137                 return("region_a");
00138         case NMG_SHELL_MAGIC:
00139                 return("shell");
00140         case NMG_SHELL_A_MAGIC:
00141                 return("shell_a");
00142         case NMG_FACE_MAGIC:
00143                 return("face");
00144         case NMG_FACE_G_PLANE_MAGIC:
00145                 return("face_g_plane");
00146         case NMG_FACE_G_SNURB_MAGIC:
00147                 return("face_g_snurb");
00148         case NMG_FACEUSE_MAGIC:
00149                 return("faceuse");
00150         case NMG_LOOP_MAGIC:
00151                 return("loop");
00152         case NMG_LOOP_G_MAGIC:
00153                 return("loop_g");
00154         case NMG_LOOPUSE_MAGIC:
00155                 return("loopuse");
00156         case NMG_EDGE_MAGIC:
00157                 return("edge");
00158         case NMG_EDGE_G_LSEG_MAGIC:
00159                 return("edge_g_lseg");
00160         case NMG_EDGE_G_CNURB_MAGIC:
00161                 return("edge_g_cnurb");
00162         case NMG_KNOT_VECTOR_MAGIC:
00163                 return("knot_vector");
00164         case NMG_EDGEUSE_MAGIC:
00165                 return("edgeuse");
00166         case NMG_EDGEUSE2_MAGIC:
00167                 return("edgeuse2 [midway into edgeuse]");
00168         case NMG_VERTEX_MAGIC:
00169                 return("vertex");
00170         case NMG_VERTEX_G_MAGIC:
00171                 return("vertex_g");
00172         case NMG_VERTEXUSE_MAGIC:
00173                 return("vertexuse");
00174         case NMG_VERTEXUSE_A_PLANE_MAGIC:
00175                 return("vertexuse_a_plane");
00176         case NMG_VERTEXUSE_A_CNURB_MAGIC:
00177                 return("vertexuse_a_cnurb");
00178         /*
00179          *  raytrace.h
00180          */
00181         case RT_TESS_TOL_MAGIC:
00182                 return("rt_tess_tol");
00183         case RT_DB_INTERNAL_MAGIC:
00184                 return("rt_db_internal");
00185         case RT_RAY_MAGIC:
00186                 return "librt xray";
00187         case RT_HIT_MAGIC:
00188                 return "librt hit";
00189         case RT_SEG_MAGIC:
00190                 return("librt seg");
00191         case RT_SOLTAB_MAGIC:
00192                 return("librt soltab");
00193         case RT_REGION_MAGIC:
00194                 return("librt region");
00195         case PT_MAGIC:
00196                 return("librt partition");
00197         case DBI_MAGIC:
00198                 return("librt db_i");
00199         case RT_DIR_MAGIC:
00200                 return "librt directory";
00201         case DB_FULL_PATH_MAGIC:
00202                 return "librt db_full_path";
00203         case RT_CTS_MAGIC:
00204                 return "librt combined_tree_state";
00205         case RT_TREE_MAGIC:
00206                 return "librt union tree";
00207         case RT_WDB_MAGIC:
00208                 return "rt_wdb";
00209         case ANIMATE_MAGIC:
00210                 return("librt animate");
00211         case RESOURCE_MAGIC:
00212                 return("librt resource");
00213         case PIXEL_EXT_MAGIC:
00214                 return "librt pixel_ext";
00215         case RT_AP_MAGIC:
00216                 return "librt application";
00217         case RTI_MAGIC:
00218                 return("rt_i");
00219         case RT_FUNCTAB_MAGIC:
00220                 return "rt_functab";
00221         case RT_HTBL_MAGIC:
00222                 return "rt_htbl";
00223 
00224         /*
00225          *  rtgeom.h
00226          */
00227         case RT_TOR_INTERNAL_MAGIC:
00228                 return("rt_tor_internal");
00229         case RT_TGC_INTERNAL_MAGIC:
00230                 return("rt_tgc_internal");
00231         case RT_ELL_INTERNAL_MAGIC:
00232                 return("rt_ell_internal");
00233         case RT_ARB_INTERNAL_MAGIC:
00234                 return("rt_arb_internal");
00235         case RT_ARS_INTERNAL_MAGIC:
00236                 return("rt_ars_internal");
00237         case RT_HALF_INTERNAL_MAGIC:
00238                 return("rt_half_internal");
00239         case RT_PG_INTERNAL_MAGIC:
00240                 return("rt_pg_internal");
00241         case RT_EBM_INTERNAL_MAGIC:
00242                 return("rt_ebm_internal");
00243         case RT_VOL_INTERNAL_MAGIC:
00244                 return("rt_vol_internal");
00245         case RT_ARBN_INTERNAL_MAGIC:
00246                 return("rt_arbn_internal");
00247         case RT_PIPE_INTERNAL_MAGIC:
00248                 return("rt_pipe_internal");
00249         case RT_PART_INTERNAL_MAGIC:
00250                 return("rt_part_internal");
00251         /*
00252          * wdb.h
00253          */
00254         case WMEMBER_MAGIC:
00255                 return("wdb.h wmember_magic");
00256         case WDB_PIPESEG_MAGIC:
00257                 return("wdb.h wdb_pipeseg_magic");
00258 
00259         /*
00260          * fb.h -- not a good idea to include for real. (lib dependency)
00261          */
00262         case 0xfbfb00fb /* FB_MAGIC */:
00263                 return("fb.h fb_magic");
00264 
00265         /*
00266          *  spm.h
00267          */
00268         case SPM_MAGIC:
00269                 return "spm.h spm_map_t";
00270 
00271         /*
00272          *  ../libbu/rb_internals.h
00273          */
00274         case BU_RB_NODE_MAGIC:
00275                 return "red-black node";
00276         case BU_RB_PKG_MAGIC:
00277                 return "red-black package";
00278 
00279         }
00280 
00281 }
00282 
00283 /*@}*/
00284 /*
00285  * Local Variables:
00286  * mode: C
00287  * tab-width: 8
00288  * c-basic-offset: 4
00289  * indent-tabs-mode: t
00290  * End:
00291  * ex: shiftwidth=4 tabstop=8
00292  */

Generated on Mon Sep 18 01:24:48 2006 for BRL-CAD by  doxygen 1.4.6