sopen man page on Xenix

Man page or keyword search:  
man Server   1130 pages
apropos Keyword Search (all sections)
Output format
Xenix logo
[printable version]



     SOPEN(DOS)		      XENIX System V		    SOPEN(DOS)

     Name
	  sopen - Opens a file for shared reading and writing.

     Syntax
	  #include <fcntl.h>
	  #include <sys/types.h>
	  #include <sys/stat.h>
	  #include <share.h>
	  #include <io.h>

	  int sopen (pathname, oflag, shflag[, pmode]);
	  char *pathname;
	  int oflag;
	  int shflag;
	  int pmode;

     Description
	  The sopen function opens the file specified by pathname and
	  prepares the file for subsequent shared reading or writing
	  as defined by oflag and shflag.  oflag is an integer
	  expression formed by combining one or more of the following
	  manifest constants, defined in fcntl.h.  When more than one
	  manifest constant is given, the constants are joined with
	  the OR operator (|).

	    Oflag	Meaning

	    O_APPEND   Reposition the file pointer to the
		       end of the file before every write
		       operation.

	    O_CREAT    Create and open a new file; this
		       has no effect if the file specified
		       by pathname exists.

	    O_EXCL     Return an error value if the file
		       specified by pathname exists.  Only
		       applies when used with O_CREAT.

	    O_RDONLY   Open file for reading only; if this
		       flag is given, neither O_RDWR nor
		       O_WRONLY may be given.

	    O_RDWR     Open file for both reading and
		       writing; if this flag is given,
		       neither O_RDONLY nor O_WRONLY may
		       be given.

     Page 1					      (printed 8/7/87)

     SOPEN(DOS)		      XENIX System V		    SOPEN(DOS)

	    O_TRUNC    Open and truncate an existing file
		       to 0 length; the file must have
		       write permission, and the contents
		       of the file are destroyed.

	    O_WRONLY   Open file for writing only; if this
		       flag is given, neither O_RDONLY nor
		       O_RDWR may be given.

	    O_BINARY   Open file in binary (untranslated)
		       mode.  (See fopen for a description
		       of binary mode.)

	    O_TEXT     Open file in text (translated)
		       mode.  (See fopen for a description
		       of text mode.)

	  _TRUNC destroys the complete contents of an existing file.
	  Use with care.

	  Shflag is a constant expression consisting of one of the
	  following manifest constants, defined in share.h. See your
	  MS-DOS documentation for detailed information on sharing
	  modes.

	    Shflag	  Meaning

	    SH_COMPAT	  Set compatibility mode.

	    SH_DENYRW	  Deny read and write access to file.

	    SH_DENYWR	  Deny write access to file.

	    SH_DENYRD	  Deny read access to file.

	    SH_DENYNONE	  Permit read and write access.

	  The pmode argument is required only when _CREAT is
	  specified.  If the file does not exist, pmode specifies the
	  file's permission settings, which are set when the new file
	  is closed for the first time.	 Otherwise, the pmode argument
	  is ignored.  The pmode argument is an integer expression
	  containing one or both of the manifest constants S_IWRITE
	  and S_IREAD, defined in sys/stat.h. When both constants are
	  given, they are joined with the OR operator (|).  The
	  meaning of the pmode argument is as follows:

	    Value		 Meaning
	    S_IWRITE		 Writing permitted

	    S_IREAD		 Reading permitted

     Page 2					      (printed 8/7/87)

     SOPEN(DOS)		      XENIX System V		    SOPEN(DOS)

	    S_IREAD | S_IWRITE	 Reading and writing permitted

	  If write permission is not given, the file is read-only.
	  Under MS-DOS all files are readable; it is not possible to
	  give write-only permission.  Thus, the modes S_IWRITE and
	  S_IREAD | S_IWRITE are equivalent.

	  sopen applies the current file permission mask to pmode
	  before setting the permissions (see umask).

     Return Value
	  sopen returns a file handle for the opened file.  A return
	  value of -1 indicates an error, and errno is set to one of
	  the following values:

	    Value Meaning

	    EACCES	    Given pathname is a directory; or
			    the file is read-only but an open
			    for writing was attempted; or a
			    sharing violation occurred (the
			    file's sharing mode does not allow
			    the specified operations; MS-DOS
			    versions 3.0 or later only).

	    EEXIST	    The _CREAT and _EXCL flags are
			    specified but the named file
			    already exists.

	    EINVAL	    SHARE.COM not installed.

	    EMFILE	    No more file handles available (too
			    many open files).

	    ENOENT	    File or pathname not found.

     See  Also
	  close(S), creat(S), fopen(S), open(S), umask(S)

     Page 3					      (printed 8/7/87)

     SOPEN(DOS)		      XENIX System V		    SOPEN(DOS)

     Example
	  #include <fcntl.h> #include <sys/types.h> #include
	  <sys/stat.h> #include <share.h> #include <io.h>

	  extern unsigned char _osmajor; int fh;

		       /* The _osmajor variable is used to test
		       ** the MS-DOS version number before
		       ** calling sopen.	       */

	  if (_osmajor >= 3)		  fh = sopen ("data", O_RDWR |
	  O_BINARY, SH_DENYRW); else		  fh = open ("data",
	  O_RDWR | O_BINARY);

     Notes
	  The sopen function should be used only under MS-DOS version
	  3.0 or later.	 Under earlier versions of MS-DOS, the shflag
	  argument is ignored.

	  File sharing modes will not work correctly for buffered
	  files, so do not use fdopen to associate a file opened for
	  sharing (or locking) with a stream.

	  This call must be compiled with the -dos flag.

     Page 4					      (printed 8/7/87)

[top]
                             _         _         _ 
                            | |       | |       | |     
                            | |       | |       | |     
                         __ | | __ __ | | __ __ | | __  
                         \ \| |/ / \ \| |/ / \ \| |/ /  
                          \ \ / /   \ \ / /   \ \ / /   
                           \   /     \   /     \   /    
                            \_/       \_/       \_/ 
More information is available in HTML format for server Xenix

List of man pages available for Xenix

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net