This sample program reads a (part of) file with qread()
#include <ctype.h>
#include <errno.h>
#include <nwerrno.h>
#include <nwfileio.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define BUFFER_SIZE 1024
int main( int argc, char* argv[]) {
int fhandle;
char buffer[ BUFFER_SIZE];
int bytes_read;
size_t i;
if ( argc != 2) {
puts( "Usage: LOAD QREAD <filename>\n"
"where <filename> - file name to read");
return EXIT_FAILURE;
}
if (( fhandle = open( argv[ 1], O_RDONLY)) == -1) {
printf( "open failed, errno = %d ( %s ), NetWareErrno = %d\n",
errno, strerror( errno), NetWareErrno);
return EXIT_FAILURE;
}
bytes_read = qread( fhandle, buffer, BUFFER_SIZE, 0);
printf( "bytes_read = %d\n", bytes_read);
for ( i = 0; i < bytes_read; ++i) {
printf( "%c", isprint( buffer[ i]) ? buffer[ i] : '.');
}
close( fhandle);
return EXIT_SUCCESS;
}
© 2008 Novell, Inc. All Rights Reserved.