home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / hdf / unix / hdf3_2r2 / src / dfconvrt.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  3.4 KB  |  119 lines

  1. /***************************************************************************
  2. *
  3. *
  4. *                         NCSA HDF version 3.2r2
  5. *                            October 30, 1992
  6. *
  7. * NCSA HDF Version 3.2 source code and documentation are in the public
  8. * domain.  Specifically, we give to the public domain all rights for future
  9. * licensing of the source code, all resale rights, and all publishing rights.
  10. *
  11. * We ask, but do not require, that the following message be included in all
  12. * derived works:
  13. *
  14. * Portions developed at the National Center for Supercomputing Applications at
  15. * the University of Illinois at Urbana-Champaign, in collaboration with the
  16. * Information Technology Institute of Singapore.
  17. *
  18. * THE UNIVERSITY OF ILLINOIS GIVES NO WARRANTY, EXPRESSED OR IMPLIED, FOR THE
  19. * SOFTWARE AND/OR DOCUMENTATION PROVIDED, INCLUDING, WITHOUT LIMITATION,
  20. * WARRANTY OF MERCHANTABILITY AND WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE
  21. *
  22. ****************************************************************************
  23. */
  24.  
  25. /*
  26. $Header: /hdf/hdf/v3.2r2/src/RCS/dfconvrt.h,v 1.1 1992/08/25 21:40:44 koziol beta koziol $
  27.  
  28. $Log: dfconvrt.h,v $
  29.  * Revision 1.1  1992/08/25  21:40:44  koziol
  30.  * Initial revision
  31.  *
  32. */
  33. /* In order to speed the conversion process, eliminate a layer of function
  34.  * calls by making DFconvert into a macro.
  35.  * Peter Webb, Oct 11, 1989
  36.  */
  37. #ifndef DFCONVRT_H
  38. #define DFCONVRT_H
  39.  
  40. #ifndef FUNC_CONV
  41. /* This is the default */
  42. /* using the DFconvert macro instead of function */
  43. #define DFconvert(src,dest,ntype,stype,dtype,size,status)\
  44. { char *s=(src), *d=(dest);\
  45.   int nt=(ntype), st=(stype), dt=(dtype);\
  46.   int sz=((int)size);\
  47.   if (nt==DFNT_FLOAT) {\
  48.     if ((st==DFNTF_IEEE && dt==DFNTF_PC) ||\
  49.         (st==DFNTF_PC && dt==DFNTF_IEEE)) {\
  50.       register int32 i;\
  51.       for (i=0;i<sz*4;i+=4) {\
  52.         d[i] = s[i+3];\
  53.         d[i+1] = s[i+2];\
  54.         d[i+2] = s[i+1];\
  55.         d[i+3] = s[i];\
  56.       }\
  57.       status=0;\
  58.     } else {\
  59.       if (st==DFNTF_PC) {\
  60.         register int i;\
  61.         register char t;\
  62.         for (i=0;i<sz*4;i+=4) {\
  63.           t = s[i];\
  64.           s[i] = s[i+3];\
  65.           s[i+3] = t;\
  66.           t = s[i+1];\
  67.           s[i+1] = s[i+2];\
  68.           s[i+2] = t;\
  69.         }\
  70.         st=DFNTF_IEEE;\
  71.       }\
  72.       if (st==DFNTF_IEEE && dt==DFNTF_CRAY) {\
  73.     int i=1;\
  74.         SCUP32(s,d,&sz,&i);\
  75.       } else if (st==DFNTF_CRAY && (dt==DFNTF_IEEE || dt==DFNTF_PC)) {\
  76.     int i=1;\
  77.         CSPK32(s,d,&sz,&i);\
  78.       } else if (st==DFNTF_IEEE && dt==DFNTF_VAX) {\
  79.         status = DFCVieeeF2vaxF((union float_uint_uchar *)s,(union float_uint_uchar *)d,sz);\
  80.       } else if (st==DFNTF_VAX && (dt==DFNTF_IEEE || dt==DFNTF_PC)) {\
  81.         status = DFCVvaxF2ieeeF((union float_uint_uchar *)s,(union float_uint_uchar *)d,sz);\
  82.       } else {\
  83.         status = -1;\
  84.       }\
  85.       if (dt==DFNTF_PC) {\
  86.         register int i;\
  87.         register char t;\
  88.         for (i=0;i<sz*4;i+=4) {\
  89.           t = d[i];\
  90.           d[i] = d[i+3];\
  91.           d[i+3] = t;\
  92.           t = d[i+1];\
  93.           d[i+1] = d[i+2];\
  94.           d[i+2] = t;\
  95.         }\
  96.       }\
  97.       if ((stype)==DFNTF_PC) {\
  98.         register int i;\
  99.         register char t;\
  100.         for (i=0;i<sz*4;i+=4) {\
  101.           t = s[i];\
  102.           s[i] = s[i+3];\
  103.           s[i+3] = t;\
  104.           t = s[i+1];\
  105.           s[i+1] = s[i+2];\
  106.           s[i+2] = t;\
  107.         }\
  108.         st=DFNTF_IEEE;\
  109.       }\
  110.     }\
  111.   } else {\
  112.   status = -1;\
  113.   }\
  114.   if (status == -1) HERROR(DFE_BADCONV);\
  115. }
  116. #endif /* !FUNC_CONV */
  117.  
  118. #endif /* !DFCONVRT_H */
  119.