home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / online / source / c / compilers / Tickle-4.0.sit.hqx / Tickle-4.0 / cbtree / src / test.c < prev    next >
C/C++ Source or Header  |  1992-04-25  |  2KB  |  92 lines

  1.  
  2. #include <fcntl.h>
  3. #include <fcntl.h>
  4. #include <ioctl.h>
  5. #include <stdio.h>
  6.  
  7. extern int errno;
  8.  
  9. main(argc, argv)
  10. int        argc;
  11. char    *argv[];
  12.     {
  13.     int        fd, bytes, myerr;
  14.     char    *ptr;
  15. #pragma unused(argc)
  16.  
  17.     fd = open(argv[1], O_RDWR | O_CREAT);
  18.     if (fd == -1)
  19.         {
  20.         fprintf(stderr, "ERROR %d opening '%s'\n", errno, argv[1]);
  21.         }
  22.     else
  23.         {
  24.         ptr = "This is the beginning entry.\n";
  25.         bytes = write(fd, ptr, strlen(ptr));
  26.         fprintf(stderr, "write(%d, ptr, %d) = %d (%d)\n",
  27.                     fd, strlen(ptr), bytes, errno);
  28.         
  29.         myerr = lseek(fd, (10*1024), SEEK_SET);
  30.         fprintf(stderr, "LSEEK(%d, %d, SEEK_SET) = %d (%d)\n",
  31.                     fd, (10*1024), myerr, errno);
  32.         if (myerr == -1)
  33.             {
  34.             fprintf(stderr, "LSEEK FAILED --> DO IOCTL()!\n");
  35.             myerr = ioctl(fd, FIOSETEOF, (long *)(10*1024));
  36.             fprintf(stderr, "IOCTL(%d, FIOSETEOF, %d) = %d (%d)\n",
  37.                             fd, (10*1024), myerr, errno);
  38.             
  39.             myerr = lseek(fd, (10*1024), SEEK_SET);
  40.             fprintf(stderr, "SECOND LSEEK(%d, %d, SEEK_SET) = %d (%d)\n",
  41.                         fd, (10*1024), myerr, errno);
  42.             }
  43.         
  44.         ptr = "This is the LAST entry at 10K.\n";
  45.         bytes = write(fd, ptr, strlen(ptr));
  46.         fprintf(stderr, "write(%d, ptr, %d) = %d (%d)\n",
  47.                     fd, strlen(ptr), bytes, errno);
  48.         
  49.         close(fd);
  50.         }
  51.     
  52.     }
  53.  
  54.  
  55. #ifdef NEVER_DEFINED
  56.  
  57. cd {src}dbm:
  58.  
  59. C -mbg full -b3 {active}
  60. Link -o test -w                ∂
  61.     -t MPST -c 'MPS '        ∂
  62.     {active}.o                ∂
  63.     {libraries}runtime.o    ∂
  64.     {libraries}interface.o    ∂
  65.     {clibraries}stdclib.o
  66. test TESTFILE
  67.  
  68. write(3, ptr, 29) = 29 (0)
  69. LSEEK(3, 10240, SEEK_SET) = -1 (6)
  70. LSEEK FAILED --> DO IOCTL()!
  71. IOCTL(3, FIOSETEOF, 10240) = 0 (6)
  72. SECOND LSEEK(3, 10240, SEEK_SET) = 10240 (6)
  73. write(3, ptr, 31) = 31 (6)
  74.  
  75.  
  76. write(3, ptr, 29) = 29 (0)
  77. LSEEK(3, 10240, SEEK_SET) = -1 (6)
  78. LSEEK FAILED --> DO IOCTL()!
  79. IOCTL(3, FIOSETEOF, 10240) = 0 (6)
  80. write(3, ptr, 31) = 31 (6)
  81.  
  82. write(3, ptr, 29) = 29 (0)
  83. LSEEK(3, 10240, SEEK_SET) = -1 (6)
  84. write(3, ptr, 31) = 31 (6)
  85.  
  86.  
  87. cp ndbm.c.o {clibraries}dbm.o
  88. cp stat.c.o {clibraries}stat.o
  89.  
  90.  
  91. #endif
  92.