home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / hdf / unix / hdf3_2r2 / test / terr.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  3.8 KB  |  129 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.5 $";
  27. #endif
  28. /*
  29. $Header: /hdf/hdf/v3.2r2/test/RCS/terr.c,v 1.5 1992/05/31 19:07:09 mfolk beta koziol $
  30.  
  31. $Log: terr.c,v $
  32.  * Revision 1.5  1992/05/31  19:07:09  mfolk
  33.  * *** empty log message ***
  34.  *
  35.  * Revision 1.4  1992/05/31  17:43:29  mfolk
  36.  * Put in a semicolon I accidentally deleted in last change.
  37.  *
  38.  * Revision 1.3  1992/05/29  21:52:19  mfolk
  39.  * Added some casts to make it compile without warnings on Convex.
  40.  *
  41.  * Revision 1.2  1992/05/28  14:24:01  chouck
  42.  * Added casts for calls to Hinquire()
  43.  *
  44.  * Revision 1.1  1992/02/10  20:59:34  chouck
  45.  * Initial revision
  46.  *
  47. */
  48. /*
  49. ** TERR
  50. **  Attempt to do something that HDF doesn't like so that we can test
  51. **  error handling
  52. */
  53.  
  54. #include "hdf.h"
  55. #define TESTFILE_LOCAL "terr.hdf"
  56. #define TESTFILE_STUPID_PATH "/foo/bar/HDF/.empty/terr.hdf"
  57. uint8 outbuf[4096], inbuf[4096];
  58.  
  59. /*
  60. ** Test a status value.  If an error has occurred, add an error
  61. **  record (code: return_code) for the current routine and return FAIL
  62. */
  63. #define N_VERIFY(status, return_code, n) \
  64. {if(status == n) {HERROR(return_code); return(FAIL);}}
  65.  
  66. #define ZERO_VERIFY(status, return_code) N_VERIFY(status, return_code, 0);
  67. #define VERIFY(status, return_code)      N_VERIFY(status, return_code, FAIL);
  68.  
  69. /*
  70. ** Test a status value and print error dump if an error has
  71. **  occurred
  72. */
  73. #define N_CHECK(status, n) {if(status == n) HEprint(stdout, 0);}
  74. #define CHECK(status)      N_CHECK(status, FAIL);
  75. #define ZERO_CHECK(status) N_CHECK(status, 0);
  76.  
  77. main(argc, argv)
  78.     int argc;
  79.     char *argv[];
  80. {
  81.     int32 fid, fid1;
  82.     int32 aid1, aid2;
  83.     int32 fileid, length, offset, posn;
  84.     uint16 tag, ref;
  85.     int16 access, special;
  86.     int   ret, i, status;
  87.  
  88.     printf(" -------- \n");
  89.  
  90.     printf("Creating (good) file %s\n", TESTFILE_LOCAL);
  91.     fid = Hopen(TESTFILE_LOCAL, DFACC_CREATE, 0);
  92.     CHECK(fid);
  93.  
  94.     printf("Creating (bad) file %s\n", TESTFILE_STUPID_PATH);
  95.     status = Hopen(TESTFILE_STUPID_PATH, DFACC_CREATE, 0);
  96.     CHECK(status);
  97.  
  98.     printf("Attempt to open the executable (bad)\n");
  99.     status = Hopen(argv[0], DFACC_READ, 0);
  100.     CHECK(status);
  101.  
  102.     printf(" -------- \n");
  103.  
  104.     puts("checking (good) newref");
  105.     status = Hnewref(fid);
  106.     ZERO_CHECK(status);
  107.  
  108.     puts("checking (bad) newref");
  109.     status = Hnewref((int32)2700173);
  110.     ZERO_CHECK(status);
  111.  
  112.     printf(" -------- \n");
  113.  
  114.     puts("putting some data elements into a (good) file");
  115.     status = Hputelement(fid, (uint16) 100, (uint16) 1, 
  116.                        (uint8 *) "test 100 1", strlen("test 100 1")+1);
  117.     CHECK(status);
  118.  
  119.     puts("putting some data elements into a (bad) file");
  120.     status = 
  121.       Hputelement((int32) 23578, (uint16) 100, (uint16) 1, 
  122.                        (uint8 *)"test 100 1", strlen("test 100 1")+1);
  123.     CHECK(status);
  124.  
  125.     printf(" -------- \n");
  126.     exit(0);
  127.  
  128. }
  129.