home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 3 / goldfish_volume_3.bin / files / gfx / 3d / irit / misc_lib / miscatt3.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-10  |  2.0 KB  |  58 lines

  1. /*****************************************************************************
  2. * Copying attributes.                                 *
  3. *                                         *
  4. * Written by:  Gershon Elber                Ver 0.2, Mar. 1990   *
  5. *****************************************************************************/
  6.  
  7. #include <string.h>
  8. #include <stdio.h>
  9. #include <math.h>
  10. #include "irit_sm.h"
  11. #include "imalloc.h"
  12. #include "miscattr.h"
  13.  
  14. /*****************************************************************************
  15. * DESCRIPTION:                                                               *
  16. * Routine to copy one attribute.                         *
  17. *   This routine also exists in attribut.c with object handling. It will be  *
  18. * linked in iff no object handling is used.                     *
  19. *                                                                            *
  20. * PARAMETERS:                                                                *
  21. *   Src:       Attribute to duplicate.                                       *
  22. *                                                                            *
  23. * RETURN VALUE:                                                              *
  24. *   IPAttributeStruct *:   Duplicated attribute.                             *
  25. *****************************************************************************/
  26. IPAttributeStruct *AttrCopyOneAttribute(IPAttributeStruct *Src)
  27. {
  28.     IPAttributeStruct *Dest;
  29.  
  30.     if (Src -> Name[0] == '_')           /* Do not copy internal attributes. */
  31.     return NULL;
  32.  
  33.     Dest = _AttrMallocAttribute(Src -> Name, Src -> Type);
  34.  
  35.     switch (Src -> Type) {
  36.         case IP_ATTR_INT:
  37.         Dest -> U.I = Src -> U.I;
  38.         break;
  39.     case IP_ATTR_REAL:
  40.         Dest -> U.R = Src -> U.R;
  41.         break;
  42.     case IP_ATTR_STR:
  43.         Dest -> U.Str = IritStrdup(Src -> U.Str);
  44.         break;
  45.     case IP_ATTR_OBJ:
  46.         IritFatalError("Attempt to copy an object attribute");
  47.         break;
  48.     case IP_ATTR_PTR:
  49.         IritFatalError("Attempt to copy a pointer attribute");
  50.         break;
  51.     default:
  52.         IritFatalError("Undefined attribute type");
  53.         break;
  54.     }
  55.  
  56.     return Dest;
  57. }
  58.