Topic : The ATARI Compendium
Author : Scott Sanders / JAY Software
Version : 1.25 (20/6/2003)
Subject : Documentation
Nodes : 1117
Index Size : 32614
HCP-Version : 6
Compiled on : Atari
@charset : UTF-8
@lang : en
@default :
@help : %About
@options : +g -i -t4 +y +z
@width : 100
View Ref-FileFlock()Fopen()Fxattr()Pgetpgrp()Psetpgrp()Fcntl() GEMDOSSyntaxLONG Fcntl( handle, arg, cmd )
WORD handle;
LONG arg;
WORD cmd;
Function Fcntl() performs a command on the specified file.
Opcode 260 (0x104)
Availability This function is available under all MiNTversions integrated with MultiTOS.
Parameters handle specifies the GEMDOS file handle of the file on which
the operation specified by cmd will affect. arg varies with
each command cmd. Valid commands are:
cmd Meaning
F_DUPFD Duplicate the given file handle. Fcntl() will
(0x0000) return a file handle in the range arg - 32. If
no file handles exist within that range, an
error will be returned.
F_GETFD Return the inheritance flag for the specified
(0x0001) file. A value of 1 indicates that child
processes started with Pexec() will inherit
this file handle, otherwise a value of 0 is
returned. arg is ignored.
F_SETFD Set the inheritance flag for the named file.
(0x0002) arg specifies if child processes started with
Pexec() will inherit the file handle. A value
of 0 indicates that they will not. A value of
1 indicates that they will. GEMDOS handles 0-5
default to a value of 1 whereas other handles
default to a value of 0.
F_GETFL Return the file descriptor flags for the
(0x0003) specified file. These are the same flags passed
to Fopen(). arg is ignored.
F_SETFL Set the file decriptor flags for the specified
(0x0004) file to arg. Only user-modifyable bits are
considered. All others should be 0. It is not
possible to change a file's read/write mode or
sharing modes with this call. Attempts to do
this will fail without returning an error code.
F_GETLK Test for the presence of a lock on the
(0x0005) specified file. arg is a pointer to a FLOCK structure defined as follows:
typedef struct flock
{
/* Type of lock
0 = Read-only lock
1 = Write-only lock
2 = Read/Write lock */
WORD l_type;
/* 0 = offset from beginning of file
1 = offset from current position
2 = offset from end of file */
WORD l_whence;
/* Offset to start of lock */
LONG l_start;
/* Length of lock (0 for rest of file) */
LONG l_len;
/* Process ID maybe filled in by call */
WORD l_pid;
} FLOCK;
If a prior lock exists which would prevent the
specified lock from being applied, the
interfering lock is copied into the structure
with the process ID of the locking process.
Otherwise, Fcntl() returns F_UNLCK (3).
F_SETLK Set or remove an advisory lock on the specified
(0x0006) file. arg points to a FLOCK structure as
defined above. Setting l_type to F_RDLOCK or
F_WRLCK will cause a lock to be set. Setting
l_type to F_UNLCK wil attempt to remove the
specified lock. When locking and unlocking
FIFO's, l_whence, l_start, and l_len should be
0. The command returns 0 if successful or
a negative GEMDOS error code otherwise.
F_SETLKW The calling procedure is the same as above,
(0x0007) however, if other processes already have
a conflicting lock set, it will suspend the
calling process until the lock is freed.
FSTAT Get the extended attributes for a file. arg (0x4600) points to a XATTR structure which is filled in
with the file's extended attributes. If
successful, the function returns 0, otherwise
a negative GEMDOS error code is returned. See
Fxattr() for an explanation of the XATTR structure.
FIONREAD Return an estimate of the number of bytes
(0x4601) available for reading from the specified file
without causing the process to block (wait for
more input) in the LONG pointed to by arg.
FIONWRITE Return an estimate of the number of bytes that
(0x4602) may be written from the specified file without
causing the process to block in the LONG
pointed to by arg.
SHMGETBLK Returns the address of a memory block
(0x4D00) associated with the file. arg should be NULL
for future compatibility.
Note: Different processes may receive different
addresses for a shared block.
SHMSETBLK arg points to a block of memory (previously
(0x4D01) allocated) which is to be associated with the
file. The file must have been created at
'U:\SHM\' or the call will fail.
PPROCADDR Return the address of the specified processes'
(0x5001) control structure (opened as a file) in arg.
See the discussion of MiNTprocesses for
information about this structure.
PBASEADDR Return the address of the specified processes'
(0x5002) GEMDOS basepage (opened as a file) in arg.
PCTXTSIZE Return the length of the specified processes'
(0x5003) context structure (opened as a file) in arg.
Seeking to the offset returned by PPROCADDR
minus this number and reading this many bytes
will yield the current user context of the
process. Seeking back this many bytes more and
reading will yield the last system context of
the process. This structure is volatile and is
likely to change from one MiNT version to the
next.
PSETFLAGS arg is a pointer to a LONG from which the
(0x5004) processes' memory allocation flags (PRGFLAGS)
will be set.
PGETFLAGS arg is a pointer to a LONG into which the
(0x5005) processes' memory allocation flags (PRGFLAGS)
will be placed.
PTRACEGFLAGS arg points to a WORD which will be filled in
(0x5006) with the trace flags of a process. Setting bit
#0 of arg causes the parent process to receive
signals destined for the child. See the
discussion on program debugging for more
information.
PTRACESFLAGS arg points to a WORD which will be used to set
(0x5007) the trace flags of a process. See the discussion
on program debugging for more information.
PTRACEGO This call restarts a process which was stopped
(0x5008) because of a signal. arg points to a WORD which
contains 0 to clear all of the child processes'
pending signals or the signal value to send to
the process.
PTRACEFLOW This call restarts a process in a special
(0x5009) tracing mode in which the process is stopped
and a SIGTRACE signal is generated whenever
program flow changes (ex: JSR/BSR/JMP/BEQ). arg should be set to 0 to clear all of the pending
signals of the process being traced or a signal
value which is to be sent to the child.
PTRACESTEP This call restarts a process and allows it to
(0x500A) execute one instruction before a SIGTRAP instruction is generated.
PLOADINFO arg points to a structure as follows:
(0x500C)
struct ploadinfo {
WORD fnamelen;
char * cmdlin;
char * fname;
};
cmd should point to a 128 byte character
buffer into which the processes' command line
will be copied. fname should point to a buffer
fnamelen bytes long into which the complete
path and filename of the process' parent will
be copied. If the buffer is too short the call
will return ENAMETOOLONG.
TIOCGETP Get terminal parameters from the TTY device
(0x5400) with the specified file handle. arg is
a pointer to an sgttyb structure which is
filled in by this command.
struct sgttyb {
/* Reserved */
char sg_ispeed;
/* Reserved */
char sg_ospeed;
/* Erase character */
char sg_erase;
/* Line kill character */
char sg_kill;
/* Terminal control flags */
WORD sg_flags;
};
TIOCSETP Set the terminal parameters of the TTY device
(0x5401) specified. arg is a pointer to an sgyttb
structure as defined above. You should first
get the terminal control parameters, modify
what you wish to change, and then set them with
this call.
TIOCGETC Get the terminal control characters of the TTY (0x5402) device specified. arg is a pointer to a tchars structure filled in by this call which is
defined as follows:
struct tchars {
/* Raises SIGINT */
char t_intrc;
/* Raises SIGKILL */
char t_quitc;
/* Starts terminal output */
char t_startc;
/* Stops terminal output */
char t_stopc;
/* Marks end of file */
char t_eofc;
/* Marks end of line */
char t_brkc;
};
TIOCSETC Set the terminal control characters of the TTY (0x5403) device specified. arg is a pointer to a tchars structure as defined above. Setting any
structure element to 0 disables that feature.
TIOCGLTC Get the extended terminal control characters
(0x5404) from the TTY device specified. arg is a pointer
to a ltchars structure which is filled in by
this call defined as follows:
struct ltchars {
/* Raise SIGTSTP now */
char t_suspc;
/* Raise SIGTSTP when read */
char t_dsuspc;
/* Redraws the input line */
char t_rprntc;
/* Flushes output */
char t_flushc;
/* Erases a word */
char t_werasc;
/* Quotes a character */
char t_lnextc;
};
TIOCSLTC Set the extended terminal control characters
(0x5405) for the TTY device specified from the ltchars structure pointed to by arg.
TIOCGPGRP Return the process group ID for the TTY (0x5406) specified in the LONG pointed to by arg.
TIOCSPGRP Set the process group ID of the TTY specified
(0x5407) in the LONG pointed to by arg.
TIOCSTOP Stop terminal output (as if the user had
(0x5409) pressed ctrl-s). arg is ignored.
TIOCSTART Restart output to the terminal (as if the user
(0x540A) had pressed ctrl-q) if it had been previously
stopped with ctrl-s or a TIOCSTOP command. arg is ignored.
TIOCGWINSZ Get information regarding the window for this
(0x540B) terminal. arg points to a winsize structure
which is filled in by this command.
struct winsize {
/* # of Text Rows */
WORD ws_row;
/* # of Text Columns */
WORD ws_column;
/* Width of window in pixels */
WORD ws_xpixel;
/* Height of window in pixels */
WORD ws_ypixel;
}
TIOCSWINSZ Change the extents of the terminal window for
(0x540C) the specified TTY. arg points to a winsize structure which contains the new window
information. It is up to the window manager to
modify the window extents and raise the
SIGWINCH signal if necessary.
TIOCGXKEY Return the current definition of a system key.
(0x540D) arg points to a structure xkey as follows:
struct xkey {
WORD xk_num;
char xk_def[8];
};
xk_def will be filled in with the NULL
terminated name associated with the key
specified in xk_num as follows:
xk_num Key
0- 9 F1-F10
10-19 F11-F20
20 Cursor up
21 Cursor down
22 Cursor right
23 Cursor left
24 Help
25 Undo
26 Insert
27 Clr/Home
28 Shift+Cursor up
29 Shift+Cursor down
30 Shift+Cursor right
31 Shift+Cursor left
TIOCSXKEY Set the current definition of a system key. arg (0x540E) must point to an xkey structure (as defined
above). xk_num and xk_def are used to set the
text associated with a system key. If a terminal
recognizes special keys (by having its XKEY bit
set in the sg_flags field of its sgttyb structure) then setting a system key will cause
the text specified by xk_def to be sent to
a process whenever the key is struck. Note:
this works only if the terminal is reading
characters using Fread().
TIOCIBAUD Read/Write the input baud rate for the
(0x5412) specified terminal device. If arg points to
a LONG then the input baud rate will be set to
that value. If arg is 0, the DTR on the
terminal will be dropped (if this feature is
supported). If arg is negative, the baud rate
will not be changed. The old baud rate is
returned in the value pointed to by arg. If the
terminal does not support separate input and
output baud rates then this call will set both
rates.
TIOCOBAUD Read/Write the output baud rate for the
(0x5413) specified terminal device. If arg points to
a LONG then the output baud rate will be set to
that value. If arg is 0, the DTR on the
terminal will be dropped (if this feature is
supported). If arg is negative, the baud rate
will not be changed. The old baud rate is
returned in the value pointed to by arg. If the
terminal does not support separate input and
output baud rates then this call will set both
rates.
TIOCCBRK Clear the break condition on the specified
(0x5414) device. arg is ignored.
TIOCSBRK Set the break condition on the specified
(0x5415) device. arg is ignored.
TIOCGFLAGS Return the current stop bit/data bit
(0x5416) configuration for the terminal device in the
lower 16 bits of the LONG pointed to by arg.
See the entry for TIOCSFLAGS for the flags
required to parse arg.
TIOCSFLAGS Set the current stop bit/data bit configuration
(0x5417) for the terminal device. The new configuration
is contained in arg. Valid mask values for arg are as follows:
Name Mask Meaning
TF_1STOP 0x0001 1 stop bit
TF_15STOP 0x0002 1.5 stop bits
TF_2STOP 0x0003 2 stop bits
TF_8BIT 0x0000 8 data bits
TF_7BIT 0x0004 7 data bits
TF_6BIT 0x0008 6 data bits
TF_5BIT 0x000C 5 data bits
TCURSOFF Hide the cursor on the selected terminal
(0x6300) device. arg is ignored.
TCURSON Show the cursor on the selected terminal
(0x6301) device. arg is ignored.
TCURSBLINK Enable cursor blinking on the selected terminal
(0x6302) device. arg is ignored.
TCURSSTEADY Disable cursor blinking on the selected
(0x6303) terminal device. arg is ignored.
TCURSSRATE Set the cursor blink rate to the WORD pointed
(0x6304) to by arg.
TCURSGRATE Return the current cursor blink rate in the
(0x6305) WORD pointed to by arg.
Binding move.w cmd,-(sp)
move.l arg,-(sp)
move.w handle,-(sp)
move.w #$260,-(sp)
trap #1
lea 10(sp),sp
Return Value Unless otherwise noted, Fcntl() returns a 0 if the operation
was successful or a negative GEMDOS error code otherwise.
See Also Flock(), Fopen(), Fxattr(), Pgetpgrp(), Psetpgrp()