home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / hdf / unix / hdf3_2r2 / test / thfile1.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-10-29  |  3.0 KB  |  120 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.3 $";
  27. #endif
  28. /*
  29. $Header: /hdf/hdf/v3.2r2/test/RCS/thfile1.c,v 1.3 1992/07/27 18:40:12 dilg beta koziol $
  30.  
  31. $Log: thfile1.c,v $
  32.  * Revision 1.3  1992/07/27  18:40:12  dilg
  33.  * Changed DFACC_ALL to DFACC_RDWR in appropriate places to conform to new
  34.  * handling of access modes by Hopen().
  35.  *
  36.  * Revision 1.2  1992/06/25  19:41:58  chouck
  37.  * Changed output file names
  38.  *
  39.  * Revision 1.1  1992/02/10  20:59:34  chouck
  40.  * Initial revision
  41.  *
  42. */
  43. /*
  44.   test opening files and access elements until limits are reached
  45. */
  46.  
  47. #include "hdf.h"
  48. #define BIG 600
  49. #define TESTFILE_NAME "thf"
  50.  
  51. int32 files[BIG];
  52. int32 accs[BIG];
  53.  
  54. main()
  55. {
  56.   int i,ret;
  57.  
  58.   puts("Opening many files of same name");
  59.   for (i=0; i< BIG; i++) {
  60.     files[i] = Hopen("thf.hdf", DFACC_RDWR, 0);
  61.     if (files[i] < 0) break;
  62.   }
  63.   printf("Opening stopped at %d/%d files\n", i, BIG);
  64.  
  65.   puts("Closing all files except first open");
  66.   for (i--; i>0; i--) {
  67.     ret = Hclose(files[i]);
  68.     if (ret < 0)
  69.       printf("Error closing file %d\n", i);
  70.   }
  71.   puts("Closed files");
  72.  
  73.   puts("Opening many files of different names");
  74.   for (i=0; i< BIG; i++) {
  75.     char fname[100];
  76.     sprintf(fname, "%s%1d.hdf", TESTFILE_NAME, i);
  77.     files[i] = Hopen(fname, DFACC_ALL, 0);
  78.     if (files[i] < 0) break;
  79.   }
  80.   printf("Opening stopped at %d/%d files\n", i, BIG);
  81.  
  82.   puts("Closing all files except first open");
  83.   for (i--; i>0; i--) {
  84.     ret = Hclose(files[i]);
  85.     if (ret < 0)
  86.       printf("Error closing file %d\n", i);
  87.   }
  88.   puts("Closed files");
  89.  
  90.   puts("Opening write access elements");
  91.   for (i=0; i<BIG; i++) {
  92.     accs[i] = Hstartwrite(files[0], 100, i, 100L);
  93.     if (accs[i] < 0) break;
  94.   }
  95.   printf("Opening stoped at %d element\n", i);
  96.  
  97.   puts("Closing access elements");
  98.   for (i--; i>=0; i--) {
  99.     ret = Hendaccess(accs[i]);
  100.     if (ret < 0)
  101.       printf("Error ending access %d\n", i);
  102.   }
  103.   puts("Ended access");
  104. }
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115. /*
  116.  * Local variables:
  117.  * compile-command: "gcc -O -g thfile1.c libhdf.a -o thfile1"
  118.  * end:
  119.  */
  120.