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 >
Wrap
C/C++ Source or Header
|
1992-04-25
|
2KB
|
92 lines
#include <fcntl.h>
#include <fcntl.h>
#include <ioctl.h>
#include <stdio.h>
extern int errno;
main(argc, argv)
int argc;
char *argv[];
{
int fd, bytes, myerr;
char *ptr;
#pragma unused(argc)
fd = open(argv[1], O_RDWR | O_CREAT);
if (fd == -1)
{
fprintf(stderr, "ERROR %d opening '%s'\n", errno, argv[1]);
}
else
{
ptr = "This is the beginning entry.\n";
bytes = write(fd, ptr, strlen(ptr));
fprintf(stderr, "write(%d, ptr, %d) = %d (%d)\n",
fd, strlen(ptr), bytes, errno);
myerr = lseek(fd, (10*1024), SEEK_SET);
fprintf(stderr, "LSEEK(%d, %d, SEEK_SET) = %d (%d)\n",
fd, (10*1024), myerr, errno);
if (myerr == -1)
{
fprintf(stderr, "LSEEK FAILED --> DO IOCTL()!\n");
myerr = ioctl(fd, FIOSETEOF, (long *)(10*1024));
fprintf(stderr, "IOCTL(%d, FIOSETEOF, %d) = %d (%d)\n",
fd, (10*1024), myerr, errno);
myerr = lseek(fd, (10*1024), SEEK_SET);
fprintf(stderr, "SECOND LSEEK(%d, %d, SEEK_SET) = %d (%d)\n",
fd, (10*1024), myerr, errno);
}
ptr = "This is the LAST entry at 10K.\n";
bytes = write(fd, ptr, strlen(ptr));
fprintf(stderr, "write(%d, ptr, %d) = %d (%d)\n",
fd, strlen(ptr), bytes, errno);
close(fd);
}
}
#ifdef NEVER_DEFINED
cd {src}dbm:
C -mbg full -b3 {active}
Link -o test -w ∂
-t MPST -c 'MPS ' ∂
{active}.o ∂
{libraries}runtime.o ∂
{libraries}interface.o ∂
{clibraries}stdclib.o
test TESTFILE
write(3, ptr, 29) = 29 (0)
LSEEK(3, 10240, SEEK_SET) = -1 (6)
LSEEK FAILED --> DO IOCTL()!
IOCTL(3, FIOSETEOF, 10240) = 0 (6)
SECOND LSEEK(3, 10240, SEEK_SET) = 10240 (6)
write(3, ptr, 31) = 31 (6)
write(3, ptr, 29) = 29 (0)
LSEEK(3, 10240, SEEK_SET) = -1 (6)
LSEEK FAILED --> DO IOCTL()!
IOCTL(3, FIOSETEOF, 10240) = 0 (6)
write(3, ptr, 31) = 31 (6)
write(3, ptr, 29) = 29 (0)
LSEEK(3, 10240, SEEK_SET) = -1 (6)
write(3, ptr, 31) = 31 (6)
cp ndbm.c.o {clibraries}dbm.o
cp stat.c.o {clibraries}stat.o
#endif