*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> f90/ffopen (3)              
Title
Content
Arch
Section
 

Contents


FFOPEN(3C)					       Last changed: 2-5-98

NAME    [Toc]    [Back]

     ffopen, ffopens, ffclose, ffopenf,	ffclosef - Opens or closes a file
     using flexible file I/O

SYNOPSIS    [Toc]    [Back]

     #include <fcntl.h>
     #include <ffio.h>

     UNICOS and	UNICOS/mk systems:

	int ffopen (const char *name, int oflag	[, int mode
	[, long	cbits [, struct	ffsw *stat]]]);

	int ffopens (const char	*name, int oflag, int mode,
	long cbits, [int cblks,] struct	ffsw *stat, const char *str);

	ffclose	(int fd	[, struct ffsw *stat]);

     IRIX systems:

	int ffopen (const char *name, int oflag	[,mode_t mode]);

	int ffopens (const char	*name, int oflag, mode_t mode,
	long cbits, int	cblks, struct ffsw *stat, const	char *str);

	int ffclose (int fd);

     All systems:

	ffclosef (int fd, struct ffsw *stat);

	int ffopenf (const char	*name, int oflag , int ,mode_t mode long
	cbits, int cblks, struct ffsw *stat);

IMPLEMENTATION    [Toc]    [Back]

     UNICOS, UNICOS/mk,	and IRIX systems

DESCRIPTION    [Toc]    [Back]

     The ffopen	and ffopens functions open a file using	flexible file I/O
     (FFIO).  These functions are modeled after	the open(2) system call.
     The file associated with name is opened, and appropriate structures
     are built to do special handling on the file.  For	ffopen,	the
     processing	layers to be used are as requested with	the asgcmd(1) or
     assign(1) commands.  For ffopens, the layers are specified	by the
     string at str.

     The ffopen	function returns an integer.  Although it is not a file
     descriptor, it is used in much the	same way when passed to	the other
     functions such as ffread, ffwrite,	or ffclose.

     The oflag,	mode, and cbits	parameters are exactly as in open(2).

     On	IRIX systems, the cbits	and cblks parameters are ignored.

     The stat parameter	is a pointer to	a status return	structure
     containing	a flag,	an error indication, a transfer	count, and an
     indication	of the condition that terminated the request.

     The ffclose and ffclosef functions	close the file associated with fd.
     It	does any necessary flushing and	termination for	that file.  Files
     opened using ffopen(3C) are not guaranteed	to be flushed at program
     termination; call ffclose or ffclosef to ensure this.

NOTES    [Toc]    [Back]

     On	IRIX systems, the FFIO routines	are stored in libffio.so, and are
     available in the N32 and N64 ABIs.

RETURN VALUES    [Toc]    [Back]

     Upon successful completion, a non-negative	integer	is returned; this
     integer is	currently a pointer to a control block.	 Otherwise, -1 is
     returned, and, if the stat	parameter is passed, the error value is
     found in stat.sw_error.  If the stat parameter is not provided, the
     error code	is found in errno.  The	stat parameter is required for
     ffopens() and ffclosef.

EXAMPLES    [Toc]    [Back]

     To	write a	C program that will read the records of	a COS blocked file
     named indata and copy the data from the file (without blocking
     information) to stdout, compile the following program:

	  #include <stdio.h>
	  #include <fcntl.h>
	  #include <ffio.h>

	  #define BSZ 10000

	  main()
	  {
		int fd,	ret;
		char buf[BSZ];
		struct ffsw stat;
		int ubc	= 0;

		fd = ffopen("indata", O_RDONLY);
		do
		{
		      ret = ffreadf(fd,	buf, BSZ, &stat, PARTIAL, &ubc);
		      fwrite(buf, 1, ret, stdout);
		 } while (FFSTAT(stat) != FFEOD);
		 ret = ffclose(fd);
	  }

     Use the following commands	to compile, link, and run this program on
     UNICOS and	UNICOS/mk systems:

	  $ cc cpy.c
	  $ eval `assign -F cos	indata`	# declare "indata" is COS blocked
	  $ a.out

     Use the following commands	to compile, link, and run this program on
     IRIX systems:

	  $ cc cpy.c -lffio
	  $ eval `assign -F cos	indata`	# declare "indata" is COS blocked
	  $ a.out

     The same example program could be written to use the ffopens entry
     point.  The layers	to use in decoding the blocking	information are
     specified in the call, and	not in the shell command asgcmd(1), as
     follows:

	  #include <stdio.h>
	  #include <fcntl.h>
	  #include <ffio.h>

	  #define BSZ 10000

	  main()
	  {
		int fd,	ret;
		char buf[BSZ];
		char *str;
		struct ffsw stat;
		int ubc	= 0;

		/* Set up to process COS blocked file. */
		str = "cos";
		fd = ffopens("indata", O_RDONLY, 0, 0L,	0, &stat, str);
		do
		{
		      ret = ffreadf(fd,	buf, BSZ, &stat, PARTIAL, &ubc);
		      fwrite(buf, 1, ret, stdout);
		} while	(FFSTAT(stat) != FFEOD);
		ret = ffclose(fd);
	  }

     Use the following commands	on UNICOS and UNICOS/mk	systems	to compile,
     link, and run this	program:

	  $ cc cpy.c
	  $ a.out

     Use the following commands	on IRIX	systems	to compile, link, and run
     this program:

	  $ cc cpy.c -lffio

SEE ALSO    [Toc]    [Back]

      
      
     ffread(3C), ffseek(3C)

     asgcmd(1)

     open(2) in	the UNICOS System Calls	Reference Manual, publication
     SR-2012

     Application Programmer's I/O Guide, publication SG-2168

     Application Programmer's Library Reference	Manual,	publication
     SR-2165, for the printed version of this man page.
[ Back ]
 Similar pages
Name OS Title
ffseek IRIX Repositions a flexible file I/O file
ffread IRIX Provides flexible file I/O
ffpos IRIX Positions files opened using flexible file I/O
fffcntl IRIX Performs functions on files opened using flexible file I/O
DtMsgLogOpenFile HP-UX opens a log file
MrmOpenHierarchyFromBuffer HP-UX Allocates a hierarchy ID and opens a buffer containing a memory image of a UID file
AFclosefile IRIX close an audio file, update file header if file was opened for write access.
fdetach Tru64 Detach a STREAMS-based file descriptor from a file in the file system name space
fattach Tru64 Attach a STREAMS-based file descriptor to a file in the file system name space
floppy HP-UX direct flexible or ``floppy'' disk access
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service