(implementation-vicinity), compiles the files name1
name2 ... to an object file name name1<object-suffix>,
where <object-suffix> is the object file suffix for your computer (for
instance, `.o'). name1 must be in the current directory;
name2 ... can be in other directories.
compile-file.
cd ~/scm/
scm -e'(link-named-scm"cute""cube")'
(delete-file "scmflags.h")
(call-with-output-file
"scmflags.h"
(lambda (fp)
(for-each
(lambda (string) (write-line string fp))
'("#define IMPLINIT \"/home/jaffer/scm/Init5c4.scm\""
"#define COMPILED_INITS init_cube();"
"#define BIGNUMS"
"#define FLOATS"
"#define ARRAYS"))))
(system "gcc -Wall -O2 -c continue.c findexec.c time.c
repl.c scl.c eval.c sys.c subr.c unif.c rope.c scm.c")
...
scm.c: In function `scm_init_extensions':
scm.c:95: warning: implicit declaration of function `init_cube'
scm.c: In function `scm_cat_path':
scm.c:589: warning: implicit declaration of function `realloc'
scm.c:594: warning: implicit declaration of function `malloc'
scm.c: In function `scm_try_path':
scm.c:612: warning: implicit declaration of function `free'
(system "cc -o cute continue.o findexec.o time.o repl.o scl.o
eval.o sys.o subr.o unif.o rope.o scm.o cube.o -lm -lc")
Compilation finished at Sun Jul 21 00:59:17
If SCM has been compiled with `dynl.c' then the additional
properties of load and ([SLIB]) require specified here are supported.
The require form is preferred.
require, then the object and library files associated with
feature will be dynamically-linked, and an unspecified value
returned. If feature is not found in *catalog*, then an
error is signaled.
(usr:lib "m") returns "/usr/lib/libm.a", the path of the C
math library.
(x:lib "X11") returns "/usr/X11/lib/libX11.sa", the path
of the X11 library.
load will also
dynamically load/link object files (produced by compile-file, for
instance). The object-suffix need not be given to load. For example,
(load (in-vicinity (implementation-vicinity) "sc2")) or (load (in-vicinity (implementation-vicinity) "sc2.o")) or (require 'rev2-procedures) or (require 'rev3-procedures)
will load/link `sc2.o' if it exists.
The lib1 ... pathnames specify additional libraries which may be needed for object files not produced by the Hobbit compiler. For instance, crs is linked on Linux by
(load (in-vicinity (implementation-vicinity) "crs.o")
(usr:lib "ncurses") (usr:lib "c"))
or (require 'curses)
Turtlegr graphics library is linked by:
(load (in-vicinity (implementation-vicinity) "turtlegr")
(usr:lib "X11") (usr:lib "c") (usr:lib "m"))
or (require 'turtle-graphics)
And the string regular expression (see section Regular Expression Pattern Matching) package is linked by:
(load (in-vicinity (implementation-vicinity) "rgx") (usr:lib "c"))
or
(require 'regex)
The following functions comprise the low-level Scheme interface to dynamic linking. See the file `Link.scm' in the SCM distribution for an example of their use.
dyn:link
procedure links and loads filename into the current SCM session.
If successfull, dyn:link returns a link-token suitable for
passing as the second argument to dyn:call. If not successful,
#f is returned.
dyn:link. name should be the name of C function of no
arguments defined in the file named filename which was succesfully
dyn:linked in the current SCM session. The dyn:call
procedure calls the C function corresponding to name. If
successful, dyn:call returns #t; If not successful,
#f is returned.
dyn:call is used to call the init_... function after
loading SCM object files. The init_... function then makes the
identifiers defined in the file accessible as Scheme procedures.
dyn:link. name should be the name of C function of 2
arguments, (int argc, char **argv), defined in the file named
filename which was succesfully dyn:linked in the current
SCM session. The dyn:main-call procedure calls the C function
corresponding to name with argv style arguments, such as
are given to C main functions. If successful,
dyn:main-call returns the integer returned from the call to
name.
dyn:main-call can be used to call a main procedure from
SCM. For example, I link in and dyn:main-call a large C program,
the low level routines of which callback (see section Callbacks) into SCM
(which emulates PCI hardware).
dyn:link. The dyn:unlink procedure removes the previously
loaded file from the current SCM session. If successful,
dyn:unlink returns #t; If not successful, #f is
returned.
Dump, (also known as unexec), saves the continuation of an entire SCM session to an executable file, which can then be invoked as a program. Dumped executables start very quickly, since no Scheme code has to be loaded.
There are constraints on which sessions are savable using dump
dump.
current-input-port, current-output-port,
current-error-port), X windows, etc. are invalid in subsequent
invocations.
This restriction could be removed; See section Improvements To Make.
Dump should only be called from a loading file when the call to
dump is the last expression in that file.
Dump can be called from the command line.
gc.
dump is #t, argument processing
will continue from the command line passed to the dumping session. If
the second argument is missing or #f then the command line
arguments of the restoring invocation will be processed.
dump may set the values of boot-tail, *argv*,
restart, and *interactive*. dump returns an
unspecified value.
When a dumped executable is invoked, the variable *interactive*
(see section Internal State) has the value it possessed when dump
created it. Calling dump with a single argument sets
*interactive* to #f, which is the state it has at the
beginning of command line processing.
The procedure program-arguments returns the command line
arguments for the curent invocation. More specifically,
program-arguments for the restored session are not saved
from the dumping session. Command line processing is done on
the value of the identifier *argv*.
The thunk boot-tail is called by SCM to process command line
arguments. dump sets boot-tail to the thunk it is
called with.
The following example shows how to create `rscm', which is like regular scm, but which loads faster and has the `random' package alreadly provided.
bash$ scm -rrandom > (dump "rscm") #<unspecified> > (quit) bash$ ./rscm -lpi.scm -e"(pi (random 200) 5)" 00003 14159 26535 89793 23846 26433 83279 50288 41971 69399 37510 58209 74944 59230 78164 06286 20899 86280 34825 34211 70679 82148 08651 32823 06647 09384 46095 50582 23172 53594 08128 48111 74502 84102 70193 85211 05559 64462 29489 bash$
This task can also be accomplished using the `-o' command line option (see section Options).
bash$ scm -rrandom -o rscm > (quit) bash$ ./rscm -lpi.scm -e"(pi (random 200) 5)" 00003 14159 26535 89793 23846 26433 83279 50288 41971 69399 37510 58209 74944 59230 78164 06286 20899 86280 34825 34211 70679 82148 08651 32823 06647 09384 46095 50582 23172 53594 08128 48111 74502 84102 70193 85211 05559 64462 29489 bash$
These procedures augment the standard capabilities in section `Numerical operations' in Revised(4) Scheme.
(angle (make-rectangular x y)) for real numbers y
and x.
$expt
is not real.
Arrays read and write as a # followed by the rank
(number of dimensions) followed by what appear as lists (of lists) of
elements. The lists must be nested to the depth of the rank. For each
depth, all lists must be the same length.
(make-array 'ho 3 3) => #2((ho ho ho) (ho ho ho) (ho ho ho))
Unshared conventional (not uniform) 0-based arrays of rank 1 (dimension) are equivalent to (and can't be distinguished from) vectors.
(make-array 'ho 3) => (ho ho ho)
When constructing an array, bound is either an inclusive range of indices expressed as a two element list, or an upper bound expressed as a single integer. So
(make-array 'foo 3 3) == (make-array 'foo '(0 2) '(0 2))
#t if the obj is an array, and #f if not.
#t if its arguments would be acceptable to array-ref.
array-set! is
unspecified.
make-shared-array can be used to create shared subarrays of other
arrays. The mapper is a function that translates coordinates in
the new array into coordinates in the old array. A mapper must be
linear, and its range must stay within the bounds of the old array, but
it can be otherwise arbitrary. A simple example:
(define fred (make-array #f 8 8)) (define freds-diagonal (make-shared-array fred (lambda (i) (list i i)) 8)) (array-set! freds-diagonal 'foo 3) (array-ref fred 3 3) => foo (define freds-center (make-shared-array fred (lambda (i j) (list (+ 3 i) (+ 3 j))) 2 2)) (array-ref freds-center 0 0) => foo
The values of dim0, dim1, ... correspond to dimensions in the array to be returned, their positions in the argument list to dimensions of array. Several dims may have the same value, in which case the returned array will have smaller rank than array.
examples:
(transpose-array '#2((a b) (c d)) 1 0) => #2((a c) (b d))
(transpose-array '#2((a b) (c d)) 0 0) => #1(a d)
(transpose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 1 0) =>
#2((a 4) (b 5) (c 6))
An enclosed array is not a general Scheme array. Its elements may not
be set using array-set!. Two references to the same element of
an enclosed array will be equal? but will not in general be
eq?. The value returned by array-prototype when given an
enclosed array is unspecified.
examples:
(enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1) => #<enclosed-array (#1(a d) #1(b e) #1(c f)) (#1(1 4) #1(2 5) #1(3 6))> (enclose-array '#3(((a b c) (d e f)) ((1 2 3) (4 5 6))) 1 0) => #<enclosed-array #2((a 1) (d 4)) #2((b 2) (e 5)) #2((c 3) (f 6))>
(array-shape (make-array 'foo '(-1 3) 5)) => ((-1 3) (0 4))
Array-dimensions is similar to array-shape but replaces
elements with a 0 minimum with one greater than the maximum. So:
(array-dimensions (make-array 'foo '(-1 3) 5)) => ((-1 3) 5)
0 is returned.
array-copy! but guaranteed to copy in row-major order.
#t iff all arguments are arrays with the same shape, the
same type, and have corresponding elements which are either
equal? or array-equal?. This function differs from
equal? in that a one dimensional shared array may be
array-equal? but not equal? to a vector or uniform vector.
array-contents returns that shared array, otherwise it returns
#f. All arrays made by make-array and
make-uniform-array may be unrolled, some arrays made by
make-shared-array may not be.
If the optional argument strict is provided, a shared array will be returned only if its elements are stored internally contiguous in memory.
If array1, ... are arrays, they must have the same number of dimensions as array0 and have a range for each index which includes the range for the corresponding index in array0. If they are scalars, that is, not arrays, vectors, or strings, then they will be converted internally to arrays of the appropriate shape. proc is applied to each tuple of elements of array1 ... and the result is stored as the corresponding element in array0. The value returned is unspecified. The order of application is unspecified.
One can implement array-indexes as
(define (array-indexes array)
(let ((ra (apply make-array #f (array-shape array))))
(array-index-map! ra (lambda x x))
ra))
Another example:
(define (apl:index-generator n)
(let ((v (make-uniform-vector n 1)))
(array-index-map! v (lambda (i) i))
v))
eqv? to scalar.
If the optional argument prototype is supplied it will be used
as the prototype for the returned array. Otherwise the returned array
will be of the same type as array if that is possible, and
a conventional array if it is not. This function is used internally
by array-map! and friends to handle scalar arguments.
Uniform Arrays and vectors are arrays whose elements are all of the same type. Uniform vectors occupy less storage than conventional vectors. Uniform Array procedures also work on vectors, uniform-vectors, bit-vectors, and strings.
prototype arguments in the following procedures are interpreted according to the table:
prototype type display prefix #t boolean (bit-vector) #b #\a char (string) #a integer >0 unsigned integer #u integer <0 signed integer #e 1.0 float (single precision) #s 1/3 double (double precision float) #i +i complex (double precision) #c () conventional vector #
Unshared uniform character 0-based arrays of rank 1 (dimension) are equivalent to (and can't be distinguished from) strings.
(make-uniform-array #\a 3) => "$q2"
Unshared uniform boolean 0-based arrays of rank 1 (dimension) are equivalent to (and can't be distinguished from) section Bit Vectors.
(make-uniform-array #t 3) => #*000 == #b(#f #f #f) => #*000 == #1b(#f #f #f) => #*000
Other uniform vectors are written in a form similar to that of vectors,
except that a single character from the above table is put between
# and (. For example, '#e(3 5 9) returns a uniform
vector of signed integers.
uniform-vector-set! is
unspecified.
#t if the obj is an array of type corresponding to
prototype, and #f if not.
make-uniform-array.
uniform-array-read! returns the number of objects read.
port may be omitted, in which case it defaults to the value
returned by (current-input-port).
(current-output-port).
#t if the bit is 1,
and #f if 0. It is an error if this element is not an exact
integer.
(logaref '#(#b1101 #b0010) 0) => #b1101 (logaref '#(#b1101 #b0010) 0 1) => #f (logaref '#2((#b1101 #b0010)) 0 0) => #b1101
#t
and to 0 if bool is #f if 0. In this case it is an error
if the array element is not an exact integer or if val is not
boolean.
Bit vectors can be written and read as a sequence of 0s and
1s prefixed by #*.
#b(#f #f #f #t #f #t #f) => #*0001010
Some of these operations will eventually be generalized to other uniform-arrays.
#f is returned.
#t, uve is OR'ed into bv; If bool is #f, the
inversion of uve is AND'ed into bv.
If uve is a unsigned integer vector all the elements of uve must be
between 0 and the LENGTH of bv. The bits of bv
corresponding to the indexes in uve are set to bool.
The return value is unspecified.
(bit-count (bit-set*! (if bool bv (bit-invert! bv)) uve #t) #t).
bv is not modified.
If 'i/o-extensions is provided (by linking in `ioext.o'),
section `Line I/O' in SLIB, and the following functions are defined:
#f is returned.
The elements of the returned vector are as follows:
file-set-position is unspecified. The result of
file-set-position is unspecified.
reopen-file returns #t if successful,
#f if not.
redirect-port! returns to-port if
successful, #f if not. If unsuccessful, to-port is not
closed.
#f.
readdir returns a
#f.
readdir with
dir will return the first entry in the directory again.
#t. If dir is already
closed,, closedir returns a #f.
(filename:match?? match) would return a non-false value
(see section `Filenames' in SLIB).
(require 'directory-for-each) (directory-for-each print "." "[A-Z]*.scm") -| "Init.scm" "Iedline.scm" "Link.scm" "Macro.scm" "Transcen.scm" "Init5c4.scm"
mkdir function creates a new, empty directory whose name is
path. The integer argument mode specifies the file
permissions for the new directory. See section `The Mode Bits for Access Permission' in Gnu C Library, for more information about this.
mkdir returns if successful, #f if not.
rmdir function deletes the directory path. The
directory must be empty before it can be removed. rmdir returns
if successful, #f if not.
#f is returned. Otherwise, #t is
returned.
getcwd returns a string containing the absolute file
name representing the current working directory. If this string cannot
be obtained, #f is returned.
#t is returned. Otherwise,
#f is returned.
chmod sets the access permission bits for the file
named by file to mode. The file argument may be a
string containing the filename or a port open to the file.
chmod returns if successful, #f if not.
utime returns if successful, #f if not.
umask sets the file creation mask of the current
process to mask, and returns the previous value of the file
creation mask.
#f is returned.
#t if the file named by pathname can be accessed in
the way specified by the how argument. The how argument can
be the logior of the flags:
Or the how argument can be a string of 0 to 3 of the following
characters in any order. The test performed is the and of the
associated tests and file-exists?.
execl, command must be an exact
pathname of an executable file. execlp searches for
command in the list of directories specified by the environment
variable PATH. The convention is that arg0 is the same name
as command.
If successful, this procedure does not return. Otherwise an error
message is printed and the integer errno is returned.
execl and execlp except that the set of arguments to
command is arglist.
Names of environment variables are case-sensitive and must not contain
the character =. System-defined environment variables are
invariably uppercase.
Putenv is used to set up the environment before calls to
execl, execlp, execv, execvp, system,
or open-pipe (see section I/O-Extensions).
To access environment variables, use getenv (see section `System Interface' in SLIB).
If 'posix is provided (by linking in `posix.o'), the
following functions are defined:
#f is
returned.
#f is returned.
#f is returned.
(cons rd wd) where rd and wd are
the read and write (port) ends of a pipe respectively.
fork. Both processes
return from fork, but the calling (parent) process's
fork returns the child process's ID whereas the child
process's fork returns 0.
For a discussion of IDs See section `Process Persona' in libc.
#t if successful, #f if not.
#t if successful, #f if not.
#t if successful, #f if not.
#t if successful, #f if not.
kill function sends the signal signum to the process or
process group specified by pid. Besides the signals listed in
section `Standard Signals' in GNU C Library, signum can also
have a value of zero to check the validity of the pid.
The pid specifies the process or process group to receive the signal:
(abs pid).
A process can send a signal to itself with (kill (getpid)
signum). If kill is used by a process to send a signal to
itself, and the signal is not blocked, then kill delivers at
least one signal (which might be some other pending unblocked signal
instead of the signal signum) to that process before it returns.
The return value from kill is zero if the signal can be sent
successfully. Otherwise, no signal is sent, and a value of -1 is
returned. If pid specifies sending a signal to several processes,
kill succeeds if it can send the signal to at least one of them.
There's no way you can tell which of the processes got the signal or
whether all of them did.
The waitpid function suspends execution of the current process
until a child as specified by the pid argument has exited, or until a
signal is deliverd whose action is to terminate the current process or
to call a signal handling function. If a child as requested by pid has
already exited by the time of the call (a so-called zombie
process), the function returns immediately. Any system resources used
by the child are freed.
The value of pid can be one of:
(abs pid).
The value of options is one of the following:
WNOHANG) which means to return immediately if no child is there
to be waited for.
WUNTRACED) which means to also return for children which are
stopped, and whose status has not been reported.
The return value is normally the process ID of the child process whose
status is reported. If the WNOHANG option was specified and no
child process is waiting to be noticed, the value is zero. A value of
#f is returned in case of error and errno is set. For
information about the errno codes See section `Process Completion' in libc.
uname procedure to find out some information
about the type of computer your program is running on.
Returns a vector of strings. These strings are:
NAME,
UID, or the next entry if no argument is given. The
information is:
#f, in
which case the interpretation is system-dependent.
#f, indicating that the system default should be used.
NAME,
UID, or the next entry if no argument is given. The
information is:
link function makes a new link to the existing file named by
oldname, under the new name newname.
link returns a value of #t if it is successful and
#f on failure.
chown function changes the owner of the file filename
to owner, and its group owner to group.
chown returns a value of #t if it is successful and
#f on failure.
#f.
If 'unix is provided (by linking in `unix.o'), the following
functions are defined:
These priveledged and symbolic link functions are not in Posix:
symlink function makes a symbolic link to oldname named
newname.
symlink returns a value of #t if it is successful and
#f on failure.
#f for
failure.
lstat function is like stat, except that it does not
follow symbolic links. If filename is the name of a symbolic
link, lstat returns information about the link itself; otherwise,
lstat works like stat. See section I/O-Extensions.
chown returns a value of #t if it is successful and
#f on failure.
#f causes
accounting to be turned off.
acct returns a value of #t if it is successful and
#f on failure.
mknod function makes a special file with name filename
and modes mode for device number dev.
mknod returns a value of #t if it is successful and
#f on failure.
sync first commits inodes to buffers, and then buffers to disk.
sync() only schedules the writes, so it may return before the actual
writing is done. The value returned is unspecified.
These functions are defined in `rgx.c' using a POSIX or GNU regex library. If your computer does not support regex, a package is available via ftp from `prep.ai.mit.edu:/pub/gnu/regex-0.12.tar.gz'. For a description of regular expressions, See section `syntax' in "regex" regular expression matching library.
regerror.
flags in regcomp is a string of option letters used to
control the compilation of the regular expression. The letters may
consist of:
. or hat lists; ( [^...] )
regcomp fails.
#f or a vector of integers. These integers are in
doublets. The first of each doublet is the index of string of
the start of the matching expression or sub-expression (delimited by
parentheses in the pattern). The last of each doublet is index of
string of the end of that expression. #f is returned if
the string does not match.
#t if the pattern such that regexp = (regcomp
pattern) matches string as a POSIX extended regular
expressions. Returns #f otherwise.
Regsearch searches for the pattern within the string.
Regmatch anchors the pattern and begins matching it against
string.
Regsearch returns the character position where re starts,
or #f if not found.
Regmatch returns the number of characters matched, #f if
not matched.
Regsearchv and regmatchv return the match vector is
returned if re is found, #f otherwise.
regcomp;
String-split splits a string into substrings that are separated
by re, returning a vector of substrings.
String-splitv returns a vector of string positions that indicate
where the substrings are located.
sed.
string-edit to perform. If
#t, all occurances of re will be replaced. The default is
to perform one substitution.
These procedures provide input line editing and recall.
These functions are defined in `edline.c' and `Iedline.scm' using the editline or GNU readline (see section `Overview' in GNU Readline Library) libraries available from:
When `Iedline.scm' is loaded, if the current input port is the default input port and the environment variable EMACS is not defined, line-editing mode will be entered.
current-input-port SCM was invoked with
(stdin).
current-output-port SCM was invoked with
(stdout).
#f.
(line-editing). If bool is true, sets the current
input and output ports to an edited line port and returns the previous
value of (line-editing).
These functions are defined in `crs.c' using the curses
library. Unless otherwise noted these routines return #t for
successful completion and #f for failure.
endwin before exiting or escaping from
curses mode temporarily, to do a system call, for example. This routine
will restore termio modes, move the cursor to the lower left corner of
the screen and reset the terminal into the proper non-visual mode. To
resume after a temporary escape, call section Window Manipulation.
These routines set options within curses that deal with output. All
options are initially #f, unless otherwise stated. It is not
necessary to turn these options off before calling endwin.
#t), the next call to force-output
or refresh with win will clear the screen completely and
redraw the entire screen from scratch. This is useful when the contents
of the screen are uncertain, or in some cases for a more pleasing visual
effect.
#t), curses will consider using the
hardware "insert/delete-line" feature of terminals so equipped. If
disabled (bf is #f), curses will very seldom use this
feature. The "insert/delete-character" feature is always considered.
This option should be enabled only if your application needs
"insert/delete-line", for example, for a screen editor. It is
disabled by default because
"insert/delete-line" tends to be visually annoying when used in applications where it is not really needed. If "insert/delete-line" cannot be used, curses will redraw the changed portions of all lines.
#f), the cursor is left on the
bottom line at the location where the offending character was entered.
If enabled (bf is #t), force-output is called on the
window win, and then the physical terminal and window win
are scrolled up one line.
Note: in order to get the physical scrolling effect on the
terminal, it is also necessary to call idlok.
These routines set options within curses that deal with input. The
options involve using ioctl(2) and therefore interact with curses
routines. It is not necessary to turn these options off before
calling endwin. The routines in this section all return an
unspecified value.
CBREAK mode,
respectively. In CBREAK mode, characters typed by the user are
immediately available to the program and erase/kill character
processing is not performed. When in NOCBREAK mode, the tty driver
will buffer characters typed until a LFD or RET is typed.
Interrupt and flowcontrol characters are unaffected by this mode.
Initially the terminal may or may not be in CBREAK mode, as it is
inherited, therefore, a program should call cbreak or nocbreak
explicitly. Most interactive programs using curses will set CBREAK
mode.
Note: cbreak overrides raw. For a discussion of
how these routines interact with echo and noecho
See section Input.
RAW mode. RAW mode
is similar to CBREAK mode, in that characters typed are
immediately passed through to the user program. The differences are
that in RAW mode, the interrupt, quit, suspend, and flow control
characters are passed through uninterpreted, instead of generating a
signal. RAW mode also causes 8-bit input and output. The
behavior of the BREAK key depends on other bits in the terminal
driver that are not set by curses.
read-char as they are typed. Echoing by the tty driver is
always disabled, but initially read-char is in ECHO mode,
so characters typed are echoed. Authors of most interactive programs
prefer to do their own echoing in a controlled area of the screen, or
not to echo at all, so they disable echoing by calling noecho.
For a discussion of how these routines interact with echo and
noecho See section Input.
LFD on output, and whether RET is translated into
LFD on input. Initially, the translations do occur. By disabling
these translations using nonl, curses is able to make better use
of the linefeed capability, resulting in faster cursor motion.
savetty saves the current state of the terminal in a buffer and
resetty restores the state to what it was at the last call to
savetty.
LINES-begy and COLS-begx. A new full-screen
window is created by calling newwin(0,0,0,0).
touchwin or touchline on orig
before calling force-output.
force-output copies
the window win to the physical terminal screen, taking into
account what is already there in order to minimize the amount of
information that's sent to the terminal (called optimization). Unless
leaveok has been enabled, the physical cursor of the terminal is
left at the location of window win's cursor. With refresh,
the number of characters output to the terminal is returned.
These routines overlay srcwin on top of dstwin; that is, all
text in srcwin is copied into dstwin. srcwin and
dstwin need not be the same size; only text where the two windows
overlap is copied. The difference is that overlay is
non-destructive (blanks are not copied), while overwrite is
destructive.
touchline only pretends that
count lines have been changed, beginning with line start.
refresh (or force-output) is called. The position
specified is relative to the upper left corner of the window win,
which is (0, 0).
These routines are used to draw text on windows
If ch is a TAB, LFD, or backspace, the cursor will be
moved appropriately within the window win. A LFD also does a
wclrtoeol before moving. TAB characters are considered to
be at every eighth column. If ch is another control character, it
will be drawn in the C-x notation. (Calling winch after
adding a control character will not return the control character, but
instead will return the representation of the control character.)
Video attributes can be combined with a character by or-ing them into
the parameter. This will result in these attributes also being set.
The intent here is that text, including attributes, can be copied from
one place to another using inch and display. See standout,
below.
Note: For wadd ch can be an integer and will insert
the character of the corresponding value.
werase, but it also calls section Output Options Setting, arranging that the screen will be cleared
completely on the next call to refresh or force-output for
window win, and repainted from scratch.
cbreak, this will be
after one character (CBREAK mode), or after the first newline
(NOCBREAK mode). Unless noecho has been set, the
character will also be echoed into win.
When using read-char, do not set both NOCBREAK mode
(nocbreak) and ECHO mode (echo) at the same time.
Depending on the state of the terminal driver when each character is
typed, the program may produce undesirable results.
These functions set the current attributes of the window win. The current attributes of win are applied to all characters that are written into it. Attributes are a property of the character, and move with the character through any scrolling and insert/delete line/character operations. To the extent possible on the particular terminal, they will be displayed as the graphic rendition of characters put on the screen.
wstandout sets the current attributes of the window win to
be visibly different from other text. wstandend turns off the
attributes.
ACS_VLINE and ACS_HLINE, will be used.
Note: vertch and horch can be an integers and will insert the character (with attributes) of the corresponding values.
These procedures (defined in `socket.c') provide a Scheme interface to most of the C socket library. For more information on sockets, See section `Sockets' in The GNU C Library Reference Manual.
HOST-SPEC or the
next entry if HOST-SPEC isn't given. The information is:
AF_INET)
#f queries will be be done
using UDP datagrams. Otherwise, a connected TCP socket
will be used. When called without an argument, the host table is
closed.
AF_INET)
#f the table will be closed
between calls to getnet. Otherwise, the table stays open. When
called without an argument, the network table is closed.
#f the table will be closed
between calls to getproto. Otherwise, the table stays open. When
called without an argument, the protocol table is closed.
#f the table will be closed
between calls to getserv. Otherwise, the table stays open. When
called without an argument, the service table is closed.
#f if not found.
#f if not found.
#f if not found.
The type socket-name is used for inquiries about open sockets in the following procedures:
#f if
unsuccessful or socket is closed.
#f if unsuccessful or socket is closed.
When a port is returned from one of these calls it is unbuffered. This allows both reading and writing to the same port to work. If you want buffered ports you can (assuming sock-port is a socket i/o port):
(require 'i/o-extensions) (define i-port (duplicate-port sock-port "r")) (define o-port (duplicate-port sock-port "w"))
Returns a SOCK_STREAM socket of type family using
protocol. If family has the value AF_INET,
SO_REUSEADDR will be set. The integer argument protocol
corresponds to the integer protocol numbers returned (as vector
elements) from (getproto). If the protocol argument is not
supplied, the default (0) for the specified family is used. SCM
sockets look like ports opened for neither reading nor writing.
Returns a pair (cons) of connected SOCK_STREAM (socket) ports of
type family using protocol. Many systems support only
socketpairs of the af-unix family. The integer argument
protocol corresponds to the integer protocol numbers returned (as
vector elements) from (getproto). If the protocol argument is
not supplied, the default (0) for the specified family is used.
Socket:shutdown returns socket if successful, #f if
not.
#f if not
successful.
#f if not successful. Binding a
unix-socket creates a socket in the file system that must be
deleted by the caller when it is no longer needed (using
delete-file).
#f if not.
socket:listen can
be polled for connections by char-ready? (see section Files and Ports). This avoids blocking on connections by
socket:accept.
The following example is not too complicated, yet shows the use of sockets for multiple connections without input blocking.
;;;; Scheme chat server
;;; This program implements a simple `chat' server which accepts
;;; connections from multiple clients, and sends to all clients any
;;; characters received from any client.
;;; To connect to chat `telnet localhost 8001'
(require 'socket)
(require 'i/o-extensions)
(let ((listener-socket (socket:bind (make-stream-socket af_inet) 8001))
(connections '()))
(socket:listen listener-socket 5)
(do () (#f)
(cond ((char-ready? listener-socket)
(let ((con (socket:accept listener-socket)))
(display "accepting connection from ")
(display (getpeername con))
(newline)
(set! connections (cons con connections))
(display "connected" con)
(newline con))))
(set! connections
(let next ((con-list connections))
(cond ((null? con-list) '())
(else
(let ((con (car con-list)))
(cond ((char-ready? con)
(let ((c (read-char con)))
(cond ((eof-object? c)
(display "closing connection from ")
(display (getpeername con))
(newline)
(close-port con)
(next (cdr con-list)))
(else
(for-each (lambda (con)
(file-set-position con 0)
(write-char c con)
(file-set-position con 0))
connections)
(cons con (next (cdr con-list)))))))
(else (cons con (next (cdr con-list))))))))))))
You can use `telnet localhost 8001' to connect to the chat server, or you can use a client written in scheme:
;;;; Scheme chat client
;;; this program connects to socket 8001. It then sends all
;;; characters from current-input-port to the socket and sends all
;;; characters from the socket to current-output-port.
(require 'socket)
(require 'i/o-extensions)
(define con (make-stream-socket af_inet))
(set! con (socket:connect con (inet:string->address "localhost") 8001))
(do ((cs #f (and (char-ready? con) (read-char con)))
(ct #f (and (char-ready?) (read-char))))
((or (eof-object? cs) (eof-object? ct))
(close-port con))
(cond (cs (display cs)))
(cond (ct (file-set-position con 0)
(display ct con)
(file-set-position con 0))))
Go to the first, previous, next, last section, table of contents.