binio.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* Vis5D version 5.0 */
  2. /*
  3. Vis5D system for visualizing five dimensional gridded data sets
  4. Copyright (C) 1990 - 1997 Bill Hibbard, Brian Paul, Dave Santek,
  5. and Andre Battaiola.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 1, or (at your option)
  9. any later version.
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with this program; if not, write to the Free Software
  16. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. /*
  19. * Functions to do binary I/O of floats, ints, etc. with byte swapping
  20. * as needed.
  21. */
  22. #ifndef BINIO_H
  23. #define BINIO_H
  24. /* Include files which define SEEK_SET, O_RD_ONLY, etc. */
  25. /* and prototype open(), close(), lseek(), etc. */
  26. #include <unistd.h>
  27. #include <fcntl.h>
  28. extern void flip4(const unsigned int *src, unsigned int *dest, int n);
  29. extern void flip2(const unsigned short *src, unsigned short *dest, int n);
  30. #ifdef _CRAY
  31. extern void cray_to_ieee_array(long *dest, const float *source, int n);
  32. extern void ieee_to_cray_array(float *dest, const long *source, int n);
  33. #endif
  34. /**********************************************************************/
  35. /***** Read Functions *****/
  36. /**********************************************************************/
  37. extern int read_bytes(int f, void *b, int n);
  38. extern int read_int2_array(int f, short *iarray, int n);
  39. extern int read_uint2_array(int f, unsigned short *iarray, int n);
  40. extern int read_int4(int f, int *i);
  41. extern int read_int4_array(int f, int *iarray, int n);
  42. extern int read_float4(int f, float *x);
  43. extern int read_float4_array(int f, float *x, int n);
  44. extern int read_block(int f, void *data, int elements, int elsize);
  45. /**********************************************************************/
  46. /***** Write Functions *****/
  47. /**********************************************************************/
  48. extern int write_bytes(int f, const void *b, int n);
  49. extern int write_int2_array(int f, const short *iarray, int n);
  50. extern int write_uint2_array(int f, const unsigned short *iarray, int n);
  51. extern int write_int4(int f, int i);
  52. extern int write_int4_array(int f, const int *iarray, int n);
  53. extern int write_float4(int f, float x);
  54. extern int write_float4_array(int f, const float *x, int n);
  55. extern int write_block(int f, const void *data, int elements, int elsize);
  56. #endif