United States |
Previous | Contents | Index |
Returns the cosine of its radian argument.
#include <math.h>double cos (double x);
x
A radian expressed as a real value.
x The cosine of the argument. HUGE_VAL Indicates that the argument is too large; errno is set to ERANGE.
Returns the hyperbolic cosine of its argument.
#include <math.h>double cosh (double x);
x
A real value.
x The hyperbolic cosine of the argument. HUGE_VAL Indicates that the argument is too large; errno is set to ERANGE.
Returns the cotangent of its radian argument.
#include <math.h>double cot (double x);
x
A radian expressed as a real number.
x The cotangent of the argument. HUGE_VAL Indicates that the argument is zero; errno is set to ERANGE.
Creates a new file.
#include <fcntl.h>int creat (const char *file_spec, mode_t mode); (ISO POSIX-1)
int creat (const char *file_spec, mode_t mode, ...); (DEC C EXTENSION)
file_spec
A null-terminated string containing any valid file specification.mode
An unsigned value that specifies the file-protection mode. The compiler performs a bitwise AND operation on the mode and the complement of the current protection mode.You can construct modes by using the bitwise OR operator (|) to create mode combinations. The modes are as follows:
0400 OWNER:READ 0200 OWNER:WRITE 0100 OWNER:EXECUTE 0040 GROUP:READ 0020 GROUP:WRITE 0010 GROUP:EXECUTE 0004 WORLD:READ 0002 WORLD:WRITE 0001 WORLD:EXECUTE The system is given the same privileges as the owner. A WRITE privilege implies a DELETE privilege.
Note
To create files with OpenVMS RMS default protections using the UNIX system-call functions umask , mkdir , creat , and open , call mkdir , creat , and open with a file-protection mode argument of 0777 in a program that never specifically calls umask . These default protections include correctly establishing protections based on ACLs, previous versions of files, and so on.
In programs that do vfork / exec calls, the new process image inherits whether umask has ever been called or not from the calling process image. The umask setting and whether the umask function has ever been called are both inherited attributes....
An optional argument list of character strings of the following form:
"keyword = value",...,"keyword = value"
Or in the case of "acc" or "err", this form:
"keyword"
Here, keyword is an RMS field in the file access block (FAB) or record access block (RAB); value is valid for assignment to that field. Some fields permit you to specify more than one value. In these cases, the values are separated by commas.
The RMS callback keywords "acc" and "err" are the only keywords that do not take values. Instead, they are followed by a pointer to the callback routine to be used, followed by a pointer to a user-specified value to be used as the first argument of the callback routine. For example, to set up an access callback routine called acc_callback whose first argument is a pointer to the integer variable first_arg in a call to open , you can use the following statement:
open("file.dat", O_RDONLY, 0 ,"acc", acc_callback, &first_arg)The second and third arguments to the callback routine must be pointers to a FAB and RAB, respectively, and the routine must have a return type of int . If the callback retruns a value less than 0, the open , creat , or fopen fails. The error callback can correct the error condition and return a status greater than or equal to 0 to continue the creat call. Assuming the previous open statement, the function prototype for acc_callback would be similar to the following statement:
#include <rms.h> int acc_callback(int *first_arg, struct FAB *fab, struct RAB *rab);FAB and RAB are defined in the <rms.h> header file, and the actual pointers passed to the routine are pointers to the RAB and FAB being used to open the file file.dat.
If an access callback routine is established, then it will be called in the open-type routine immediately before the call to the RMS function sys$create or sys$open. If an error callback routine is established and an error status is returned from the sys$create or sys$open function, then the callback routine will be invoked immediately after the status is checked and the error value is discovered.
Note
Any manipulation of the RAB or FAB in a callback function could lead to serious problems in later calls to the Compaq C RTL I/O functions.Table REF-3 describes the RMS keywords and values.
Table REF-3 RMS Valid Keywords and Values Keyword Value Description "acc" callback Access callback routine. "alq = n" decimal Allocation quantity. "bls = n" decimal Block size. "ctx = bin" string No translation of '\n' to the terminal. Use this for writing binary data to files. "ctx=cvt" string Negates a previous setting of "ctx=nocvt". This is the default. "ctx = nocvt" string No conversion of Fortran carriage-control bytes. "ctx = rec" string Force record mode access. "ctx = stm" string Force stream mode access. "ctx=xplct" string Causes records to be written only when explicitly specified by a call to fflush , close , or fclose . "deq = n" decimal Default extension quantity. "dna = filespec" string Default file-name string. "err" callback Error callback routine. "fop = val, val ,..." File-processing options: ctg
cbt
dfw
dlt
tef
cif
sup
scf
spl
tmd
tmp
nef
rck
wck
mxv
rwo
pos
rwc
sqoContiguous.
Contiguous-best-try.
Deferred write; only applicable to files opened for shared access.
Delete file on close.
Truncate at end-of-file.
Create if nonexistent.
Supersede.
Submit as command file on close.
Spool to system printer on close.
Temporary delete.
Temporary (no file directory).
Not end-of-file.
Read check compare operation.
Write check compare operation.
Maximize version number.
Rewind file on open.
Current position.
Rewind file on close.
File can only be processed in a sequential manner."fsz = n" decimal Fixed header size. "gbc = n" decimal The requested number of global buffers for a file. "mbc = n" decimal Multiblock count. "mbf = n" decimal Multibuffer count. "mrs = n" decimal Maximum record size. "pmt=usr-prmpt" string Prompts for terminal input. Any RMS input from a terminal device will be preceded by "usr-prmpt" when this option and "rop=pmt" are specified. "rat = val, val..." Record attributes: cr
blk
ftn
none
prnCarriage-return control.
Disallow records to span block boundaries.
FORTRAN print control.
Explicitly forces no carriage control.
Print file format."rfm = val" Record format: fix
stm
stmlf
stmcr
var
vfc
udfFixed-length record format.
RMS stream record format.
Stream format with line-feed terminator.
Stream format with carriage-return terminator.
Variable-length record format.
Variable-length record with fixed control.
Undefined."rop = val, val..." Record-processing operations: asy Asynchronous I/O. cco Cancel Ctrl/O (used with Terminal I/O). cvt Capitalizes characters on a read from the terminal. eof Positions the record stream to the end-of-file for the connect operation only. nlk Do not lock record. pmt Enables use of the prompt specified by "pmt=usr-prmpt" on input from the terminal. pta Eliminates any information in the type-ahead buffer on a read from the terminal. rea Locks record for a read operation for this process, while allowing other accessors to read the record. rlk Locks record for write. rne Suppresses echoing of input data on the screen as it is entered on the keyboard. rnf Indicates that Ctrl/U, Ctrl/R, and DELETE are not to be considered control commands on terminal input, but are to be passed to the application program. rrl Reads regardless of lock. syncsts Returns success status of RMS$_SYNCH if the requested service completes its task immediately. tmo Timeout I/O. tpt Allows put/write services using sequential record access mode to occur at any point in the file, truncating the file at that point. ulk Prohibits RMS from automatically unlocking records. wat Wait until record is available, if currently locked by another stream. rah Read ahead. wbh Write behind. "rtv=n" decimal The number of retrieval pointers that RMS has to maintain in memory (0 to 127,255). "shr = val" File sharing options: del
get
mse
nil
put
upd
upiAllows users to delete.
Allows users to read.
Allows mainstream access.
Prohibits file sharing.
Allows users to write.
Allows users to update.
Allows one or more writers."tmo = n" decimal I/O timeout value. In addition to these options, any option that takes a key value (such as "fop" or "rat") can be negated by prefixing the value with "no". For example, specify "fop=notmp" to clear the "tmp" bit in the "fop" field.
Notes
- While these options provide much flexibility and functionality, many of them can also cause severe problems if not used correctly.
- You cannot share the default Compaq C for OpenVMS stream file I/O. If you wish to share files, you must specify "ctx=rec" to force record access mode. You must also specify the appropriate "shr" options depending on the type of access you want.
- If you intend to share a file opened for append, you must specify appropriate share and record-locking options, to allow other accessors to read the record. The reason for doing this: the file is positioned at end-of-file through reading records in a loop until end-of-file is reached.
For more information on these options, see the OpenVMS Record Management Services Reference Manual manual.
The Compaq C RTL opens the new file for reading and writing, and returns the corresponding file descriptor.If the file exists:
- A version number one greater than any existing version is assigned to the newly created file.
- By default, the new file inherits certain attributes from the existing version of the file unless those attributes are specified in the creat call. The following attributes are inherited:
- Record format (fab$b_rfm)
- Maximum record size (fab$w_mrs)
- Carriage control (fab$b_rat)
- File protection
If the file did not previously exist:
- It is given the file protection that results from performing a bitwise AND on the mode argument and the complement of the current protection mask.
- It defaults to stream format with line-feed record separator and implied carriage-return attributes.
See also open , close , read , write , and lseek in this section.
n A file descriptor. --1 Indicates errors, including protection violations, undefined directories, and conflicting file attributes.
In the UNIX system environment, the crmode and nocrmode functions set and unset the terminal from cbreak mode. In cbreak mode, a single input character can be processed without pressing Return. This mode of single-character input is only supported with the Curses input routine getch .
#include <curses.h>crmode()
nocrmode()
/* Program to demonstrate the use of crmod() and curses */ #include <curses.h> main() { WINDOW *win1; char vert = '.', hor = '.', str[80]; /* Initialize standard screen, turn echo off. */ initscr(); noecho(); /* Define a user window. */ win1 = newwin(22, 78, 1, 1); /* Turn on reverse video and draw a box on border. */ setattr(_REVERSE); box(stdscr, vert, hor); mvwaddstr(win1, 2, 2, "Test cbreak input"); refresh(); wrefresh(win1); /* Set cbreak, do some input, and output it. */ crmode(); getch(); nocrmode(); /* Turn off cbreak. */ mvwaddstr(win1, 5, 5, str); mvwaddstr(win1, 7, 7, "Type something to clear the screen"); wrefresh(win1); /* Get another character, then delete the window. */ getch(); wclear(win1); touchwin(stdscr); endwin(); }In this example, the first call to getch returns as soon as one character is entered, because crmode was called before getch was called. The second time getch is called, it waits until the Return key is pressed before processing the character entered, because nocrmode was called before getch was called the second time.
Returns a character string giving the equivalence string of SYS$COMMAND. This is the name of the controlling terminal.
#include <stdio.h>Function Variants This function also has variants named _ctermid32 and _ctermid64 for use with 32-bit and 64-bit pointer sizes, respectively. See Section 1.8 for more information on using pointer-size-specific functions.char *ctermid (char *str);
str
Must be a pointer to an array of characters. If this argument is NULL, the file name is stored internally and might be overwritten by the next ctermid call. Otherwise, the file name is stored beginning at the location indicated by the argument. The argument must point to a storage area of length L_ctermid (defined by the <stdio.h> header file).
pointer Points to a character string.
Previous | Next | Contents | Index |
|