home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / hdf / unix / hdf3_2r2 / src / dfpf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  9.5 KB  |  334 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. #ifdef RCSID
  26. static char RcsId[] = "@(#)$Revision: 1.2 $";
  27. #endif
  28. /*
  29. $Header: /hdf/hdf/v3.2r2/src/RCS/dfpf.c,v 1.2 1992/09/11 14:15:04 koziol beta koziol $
  30.  
  31. $Log: dfpf.c,v $
  32.  * Revision 1.2  1992/09/11  14:15:04  koziol
  33.  * Changed Fortran stubs' parameter passing to use a new typedef, intf,
  34.  * which should be typed to the size of an INTEGER*4 in whatever Fortran
  35.  * compiler the C functions need to be compatible with.  (This is mostly
  36.  * for the PC and possibly for the Mac)
  37.  *
  38.  * Revision 1.1  1992/08/25  21:40:44  koziol
  39.  * Initial revision
  40.  *
  41. */
  42. /*-----------------------------------------------------------------------------
  43.  * File:    dfpF.c
  44.  * Purpose: C stubs for Palette Fortran routines
  45.  * Invokes: dfp.c dfkit.c
  46.  * Contents: 
  47.  *  dpigpal_:   Call DFPgetpal to get palette
  48.  *  dpippal_:   Call DFPputpal to write/overwrite palette in file
  49.  *  dpinpal_:   Call DFPnpals to get number of palettes in file
  50.  *  dpiwref_:    Call DFPwriteref to set ref of pal to write next
  51.  *  dpirref_:    Call DFPreadref to set ref of pal to read next
  52.  *  dprest_:    Call DFPrestart to get palettes afresh in file
  53.  *  dplref_:    Call DFPlastref to get ref of last pal read/written
  54.  *  DFPrestart_:    Call DFPrestart to get palettes afresh in file
  55.  *  DFPlastref_:    Call DFPlastref to get ref of last pal read/written
  56.  * Remarks: none
  57.  *---------------------------------------------------------------------------*/
  58.  
  59. #include "hdf.h"
  60.  
  61. #ifndef DFP_FNAMES
  62. #   define DFP_FNAMES
  63. #ifdef DF_CAPFNAMES
  64. #   define ndpigpal  FNAME(DPIGPAL)
  65. #   define ndpippal  FNAME(DPIPPAL)
  66. #   define ndpinpal  FNAME(DPINPAL)
  67. #   define ndpiwref  FNAME(DPIWREF)
  68. #   define ndpirref  FNAME(DPIRREF)
  69. #   define ndprest   FNAME(DPREST)
  70. #   define ndplref   FNAME(DPLREF)
  71. #   define ndfprestart   FNAME(DFPRESTART)
  72. #   define ndfplastref   FNAME(DFPLASTREF)
  73. #else   /* !DF_CAPNAMES */
  74. #   define ndpigpal  FNAME(dpigpal)
  75. #   define ndpippal  FNAME(dpippal)
  76. #   define ndpinpal  FNAME(dpinpal)
  77. #   define ndpiwref  FNAME(dpiwref)
  78. #   define ndpirref  FNAME(dpirref)
  79. #   define ndprest   FNAME(dprest)
  80. #   define ndplref   FNAME(dplref)
  81. #   define ndfprestart   FNAME(dfprestart)
  82. #   define ndfplastref   FNAME(dfplastref)
  83. #endif /* DF_CAPFNAMES */
  84. #endif /* DFP_FNAMES */
  85.  
  86. /*-----------------------------------------------------------------------------
  87.  * Name:    dpigpal
  88.  * Purpose: call DFPgetpal, get palette
  89.  * Inputs:  filename, fnlen: filename, length of name
  90.  *          pal: space to put palette
  91.  * Returns: 0 on success, -1 on failure with DFerror set
  92.  * Users:   Fortran stub routine
  93.  * Invokes: DFPgetpal
  94.  *---------------------------------------------------------------------------*/
  95.  
  96.     FRETVAL(intf)
  97. #ifdef PROTOTYPE
  98. ndpigpal(_fcd filename, _fcd pal, intf *fnlen)
  99. #else
  100. ndpigpal(filename, pal, fnlen)
  101.     _fcd filename;
  102.     _fcd pal;
  103.     intf *fnlen;
  104. #endif /* PROTOTYPE */
  105. {
  106.     char *fn;
  107.     intf ret;
  108.  
  109.     fn = HDf2cstring(filename, *fnlen);
  110.     ret =  DFPgetpal(fn, (VOIDP)_fcdtocp(pal));
  111.     HDfreespace(fn);
  112.     return(ret);
  113. }
  114.  
  115.  
  116. /*-----------------------------------------------------------------------------
  117.  * Name:    dpippal
  118.  * Purpose: Write palette to file
  119.  * Inputs:  filename: name of HDF file
  120.  *          palette: palette to be written to file
  121.  *          overwrite: if 1, overwrite last palette read or written
  122.  *                     if 0, write it as a fresh palette
  123.  *          filemode: if "a", append palette to file
  124.  *                    if "w", create new file
  125.  *          fnlen:  length of filename
  126.  * Returns: 0 on success, -1 on failure with DFerror set
  127.  * Users:   HDF users, programmers, utilities
  128.  * Invokes: DFPputpal
  129.  * Remarks: To overwrite, the filename must be the same as for the previous
  130.  *          call
  131.  *---------------------------------------------------------------------------*/
  132.  
  133.     FRETVAL(intf)
  134. #ifdef PROTOTYPE
  135. ndpippal(_fcd filename, _fcd pal, intf *overwrite, _fcd filemode, intf *fnlen)
  136. #else
  137. ndpippal(filename, pal, overwrite, filemode, fnlen)
  138.     _fcd filename;
  139.     _fcd pal;
  140.     intf *overwrite;
  141.     _fcd filemode;
  142.     intf *fnlen;
  143. #endif /* PROTOTYPE */
  144. {
  145.     char *fn;
  146.     intf ret;
  147.  
  148.     fn = HDf2cstring(filename, *fnlen);
  149.     ret =  DFPputpal(fn, (VOIDP)_fcdtocp(pal), *overwrite,
  150.             (char*)_fcdtocp(filemode));
  151.     HDfreespace(fn);
  152.     return(ret);
  153. }
  154.  
  155.  
  156. /*-----------------------------------------------------------------------------
  157.  * Name:    dpinpal
  158.  * Purpose: How many palettes are present in this file?
  159.  * Inputs:  filename, fnlen: name, length of HDF file
  160.  * Returns: number of palettes on success, -1 on failure with DFerror set
  161.  * Users:   HDF programmers, other routines and utilities
  162.  * Invokes: DFPnpals
  163.  *---------------------------------------------------------------------------*/
  164.  
  165.     FRETVAL(intf)
  166. #ifdef PROTOTYPE
  167. ndpinpal(_fcd filename, intf *fnlen)
  168. #else
  169. ndpinpal(filename, fnlen)
  170.     _fcd filename;
  171.     intf *fnlen;
  172. #endif /* PROTOTYPE */
  173. {
  174.     char *fn;
  175.     intf ret;
  176.  
  177.     fn = HDf2cstring(filename, *fnlen);
  178.     ret =  DFPnpals(fn);
  179.     HDfreespace(fn);
  180.     return(ret);
  181. }
  182.  
  183.  
  184. /*-----------------------------------------------------------------------------
  185.  * Name:    dpirref
  186.  * Purpose: Set ref of palette to get next
  187.  * Inputs:  filename: file to which this applies
  188.  *          ref: reference number of next get
  189.  * Returns: 0 on success, -1 on failure
  190.  * Users:   HDF programmers, other routines and utilities
  191.  * Invokes: DFPreadref
  192.  * Remarks: checks if palette with this ref exists
  193.  *---------------------------------------------------------------------------*/
  194.  
  195.     FRETVAL(intf)
  196. #ifdef PROTOTYPE
  197. ndpirref(_fcd filename, uint16 *ref, intf *fnlen)
  198. #else
  199. ndpirref(filename, ref, fnlen)
  200.     _fcd filename;
  201.     uint16 *ref;
  202.     intf *fnlen;
  203. #endif /* PROTOTYPE */
  204. {
  205.     char *fn;
  206.     intf ret;
  207.  
  208.     fn = HDf2cstring(filename, *fnlen);
  209.     ret =  DFPreadref(fn, *ref);
  210.     HDfreespace(fn);
  211.     return(ret);
  212. }
  213.  
  214.  
  215. /*-----------------------------------------------------------------------------
  216.  * Name:    dpiwref
  217.  * Purpose: Set ref of palette to put next
  218.  * Inputs:  filename: file to which this applies
  219.  *          ref: reference number of next put
  220.  *          fnlen: length of filename
  221.  * Returns: 0 on success, -1 on failure
  222.  * Users:   HDF programmers, other routines and utilities
  223.  * Invokes: DFPwriteref
  224.  *---------------------------------------------------------------------------*/
  225.  
  226.  
  227.     FRETVAL(intf)
  228. #ifdef PROTOTYPE
  229. ndpiwref(_fcd filename, uint16 *ref, intf *fnlen)
  230. #else
  231. ndpiwref(filename, ref, fnlen)
  232.     _fcd filename;
  233.     uint16 *ref;
  234.     intf *fnlen;
  235. #endif /* PROTOTYPE */
  236. {
  237.  
  238.     char *fn;
  239.     intf ret;
  240.  
  241.     fn = HDf2cstring(filename, *fnlen);
  242.     ret =  DFPreadref(fn, *ref);
  243.     HDfreespace(fn);
  244.     return(ret);
  245. }
  246.  
  247.  
  248. /*-----------------------------------------------------------------------------
  249.  * Name:    dprest
  250.  * Purpose: Do not remember info about file - get again from first palette
  251.  * Inputs:  none
  252.  * Returns: 0 on success
  253.  * Users:   HDF programmers
  254.  * Remarks: Invokes DFPrestart
  255.  *---------------------------------------------------------------------------*/
  256.  
  257.     FRETVAL(intf)
  258. #ifdef PROTOTYPE
  259. ndprest(void)
  260. #else
  261. ndprest()
  262. #endif /* PROTOTYPE */
  263. {
  264.  
  265.     return(DFPrestart());
  266. }
  267.  
  268.  
  269. /*-----------------------------------------------------------------------------
  270.  * Name:    dplref
  271.  * Purpose: Return last ref written or read
  272.  * Inputs:  none
  273.  * Globals: Lastref
  274.  * Returns: ref on success, -1 on error with DFerror set
  275.  * Users:   HDF users, utilities, other routines
  276.  * Invokes: DFPlastref
  277.  * Remarks: none
  278.  *---------------------------------------------------------------------------*/
  279.  
  280.     FRETVAL(intf)
  281. #ifdef PROTOTYPE
  282. ndplref(void)
  283. #else
  284. ndplref()
  285. #endif /* PROTOTYPE */
  286. {
  287.  
  288.     return(DFPlastref());
  289. }
  290.  
  291.  
  292. /*-----------------------------------------------------------------------------
  293.  * Name:    dfprestart
  294.  * Purpose: Do not remember info about file - get again from first palette
  295.  * Inputs:  none
  296.  * Returns: 0 on success
  297.  * Users:   HDF programmers
  298.  * Remarks: Invokes DFPrestart
  299.  *---------------------------------------------------------------------------*/
  300.  
  301.     FRETVAL(intf)
  302. #ifdef PROTOTYPE
  303. ndfprestart(void)
  304. #else
  305. ndfprestart()
  306. #endif /* PROTOTYPE */
  307. {
  308.  
  309.     return(DFPrestart());
  310. }
  311.  
  312.  
  313. /*-----------------------------------------------------------------------------
  314.  * Name:    dfplastref
  315.  * Purpose: Return last ref written or read
  316.  * Inputs:  none
  317.  * Globals: Lastref
  318.  * Returns: ref on success, -1 on error with DFerror set
  319.  * Users:   HDF users, utilities, other routines
  320.  * Invokes: DFPlastref
  321.  * Remarks: none
  322.  *---------------------------------------------------------------------------*/
  323.  
  324.     FRETVAL(intf)
  325. #ifdef PROTOTYPE
  326. ndfplastref(void)
  327. #else
  328. ndfplastref()
  329. #endif /* PROTOTYPE */
  330. {
  331.  
  332.     return(DFPlastref());
  333. }
  334.