/* IBM_PROLOG_BEGIN_TAG */ /* This is an automatically generated prolog. */ /* */ /* bos720 src/bos/usr/ccs/lib/libmio/samples/example.c 1.3 */ /* */ /* Licensed Materials - Property of IBM */ /* */ /* Restricted Materials of IBM */ /* */ /* COPYRIGHT International Business Machines Corp. 2005,2006 */ /* All Rights Reserved */ /* */ /* US Government Users Restricted Rights - Use, duplication or */ /* disclosure restricted by GSA ADP Schedule Contract with IBM Corp. */ /* */ /* IBM_PROLOG_END_TAG */ static char sccsid[] = "@(#)52 1.3 src/bos/usr/ccs/lib/libmio/samples/example.c, libmio, bos720 1/3/06 08:42:22"; #define _LARGE_FILES #include #include #include #define USE_MIO_DEFINES #include /* Note that we define open64, lseek64, ftruncate64, and not the * open, lseek, and ftruncate that are used in the code. This is * because libmio.h defines _LARGE_FILES which forces to * redefine open, lseek, and ftruncate as open64, lseek64, and * ftruncate64 */ #define RECSIZE 16384 #define NREC 100 main(int argc, char **argv) { int i, fd, status ; char *name ; char *buffer ; int64 ret64 ; if( argc < 2 ){ fprintf(stderr,"Usage : example file_name\n"); exit(-1); } name = argv[1] ; buffer = (char *)malloc(RECSIZE); memset( buffer, 0, RECSIZE ) ; fd = open(name, O_RDWR|O_TRUNC|O_CREAT, 0640 ) ; if( fd < 0 ){ fprintf(stderr,"Unable to open file %s errno=%d\n",name,errno); exit(-1); } /* write the file */ for(i=0;i