NAME

misc - miscellaneous utilities

SYNOPSIS

#include <basic/string.h>

shell1(str)
struct string *str;

short shell2(str)
struct string *str;

lock(mode, flag, firstrec, lastrec)
short mode, flag;
double firstrec, lastrec;

DESCRIPTION

Shell1 invokes the UNIX shell (see sh(1)) with the command given by the string pointed to by str and waits for its termination.  To facilitate I/O with the userís terminal, this function also temporarily restores the original state of the tty(s) associated with standard input and output (see initty(io)).  This function implements the SHELL statement. 

Shell2 invokes the UNIX shell with the command given by the string pointed to by str and returns its process id.  This function does not wait for the shell to terminate, nor does it alter tty states.  This function implements the BASIC SHELL function. 

Lock locks or unlocks the current file (see initio(io)) depending on mode.  If flag is clear, the entire file is locked or unlocked.  If flag is set, only records firstrec through lastrec of the random file are locked or unlocked.  Records are numbered sequentially starting with one.  If lastrec refers to a record beyond the end of the file, the lock extends to any records subsequently appended to the file.  Locks may overlap or be contiguous: these are coalesced into a single lock by the system.  It is legal to unlock a portion of a previous lock: the portion not specified remains locked.  It is possible to create an addition lock when unlocking if the previously locked region is split in two as a result.  There is a limit to the number of locks that may exist concurrently on a system, but in practice, this limit is large.  This function implements the LOCK and UNLOCK statements within the constraints of the UNIX.  This function resets the current file. 

SEE ALSO

initio(io), initty(io)
shell(func), shell(stmt), lock(stmt)
sh(1), lockf(2) or locking(2), wait(2) in the UNIX Programmerís Manual

DIAGNOSTICS

If flag is set, lock generates error 54 (Bad file mode) if the current file is not open for random I/O and error 5 (Illegal function call) if firstrec is less than one or firstrec is greater than lastrec

Lock also generates error 70 (Disk write protect) if the UNIX locking function fails or is not implemented on this system or if mode is known to be out of range. 

BUGS

The function that implements file locking varies: on Xenix the function is locking(2); on System V it is lockf(2); on other systems, file locking is not implemented.  The meaning of mode is dependent on these functions. 

from The Basmark QuickBASIC Programmerís Manual by Lawrence Leinweber