home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-07-21 | 132.0 KB | 2,911 lines |
- from: {A.Appleyard} (email: APPLEYARD@UK.AC.UMIST), Fri, 19 Jul 91 11:03:32 BST
- ======================================================================
- Here is my function info file. It has c.2900 lines. It contains tabulate chars.
- ======================================================================
- [Description of functions etc declared in the #include files of Gnu C]
-
- Examples to show use of the functions etc. The single-letter variables are not
- part of the #include'd matter, but are inserted here as part of the examples.
- Some declared functions and struct fields have single-letter names. Some of
- these #include files #include other files, as stated. Arguments have exactly the
- right type and qualifiers unless stated otherwise. Each example's comment
- contains in {} the type returned, if not void. "def" = "default". "{boolean}" =
- "{int} = 0 if condition is not satisfied and nonzero (usually 1) otherwise".
- "random number" = "equal probability from 0 to 1" unless stated otherwise.
- A few of these functions' bodies (including some that are C++ standard but
- can't be implemented on PC's, such as multi-user stuff and locking files and
- making files read-only) are not present in Gnu C (or I can't find their bodies
- in the source), although their names and parameter patterns are declared in one
- or other of these #include files. Such functions are marked "<missing>".
- The accuracy of Gnu C's time routines depends on you setting your PC's
- internal clock when you switch it on.
-
- Some of these functions etc are written using C++ features. If you want to use
- these functions but otherwise stick to ordinary C and are not otherwise
- concerned with the intricacies of C++, you should note that C++ can declare:-
- (1) Classes, which are like structs but can contain hidden members and other
- special features. Hereinafter I use "Gridref" as an example of a class.
- Warning: set up new store for class variables by e.g. 'Gridref()' (which
- returns a new Gridref (or a null pointer if it can't get the store)).
- Do <not> use e.g. '(Gridref*)malloc(sizeof(Gridref))', as this will not
- set up the Gridref's internal tables and pointers.
- (2) New uses of operators.
- (3) 2 or more functions with the same name but distinguishable in use by their
- argument patterns.
- (4) Function arguments-by-pointer in the usual way; and also in a special way
- so <in those cases> you don't put '&' before the argument.
- This could be called an argument-by-lvalue.
- (5) Functions with zero or more arguments in the usual place, and also with a
- special 'pre-first' argument of a class type which is put before the
- function name with a fullstop between.
- (6) Constructors, i.e. functions with the same name as a class. E.g. a function
- named Gridref would set aside space for a Gridref, then set it up for use.
- A constructor (e.g.) Gridref() with no arguments is automatically obeyed
- when a Gridref variable is declared.
- (7) Special uses of the operator = for particular pairs of arguments.
- If the left and right arg types are the same, it overrides the default use.
- (8) What to do if an (e.g.) Gridref is implicitly converted (by casting or
- allocation etc) to some other mode, and vice versa.
- (9) What to do if an (e.g.) Gridref is subscripted as if it was an array.
- (10) What to do if an (e.g.) Gridref is called as if it was a function.
- (11) Destructors, i.e. a function called (e.g.) ~Gridref() (with tilde). It is
- called automatically when a Gridref variable is destroyed, e.g. at the end
- of the block that it is declared in.
- (12) Default arguments, i.e. if a function is called with too few arguments,
- what to treat the missing trailing arguments as being equal to.
- (13) A type 'void*' (distinguish from 'void'), which can be implicitly converted
- to and from any pointer mode (except pointer to function).
-
- For io_mode and access_mode and state_value in input/output, see FMODES.H
-
- ======================================== ABS.H
- #include <builtin.h>, which see
-
- ======================================== ACG.H
- [ADDITIVE RANDOM NUMBERS]
- #include <_Random.h>, which see
-
- int i,j;
- ACG x; /* declare x to hold the working of a running series of
- additive random numbers, size=55, seed=0 */
- ACG() /* a new {ACG} with seed=0, size=55 */
- ACG(i) /* a new {ACG} with seed=i, size=55 */
- ACG(i,j) /* a new {ACG} with seed=i, size=j */
- i /* used as an {ACG}, same as ACG(i) */
- x.reset() /* reinitialize x */
- x.asLong() /* new 32-bit additive random number */
-
- ======================================== ALLOCRIN.H
- [ALLOCATION RINGS]
-
- int i; void* p;
- AllocRing x; /* declare x to hold a ring of pointers to malloc'ed strings */
- AllocRing(i) /* a new {AllocRing} of i pointers */
- i /* used as an {AllocRing}: ditto */
- x.alloc(i) /* {void*} pointer to malloc'ed string of i bytes. The pointers
- in x are used in rotation, so the oldest mallocs held by x may
- be evicted to make room for new mallocs */
- x.free(p) /* delete the malloc p if it is in x */
- x.contains(p) /* {boolean} if p is in x */
- x.clear() /* delete all mallocs in x */
-
- ======================================== AOUT.H
- /* machine dependent matter used by input & output */
-
- ======================================== AR.H
- struct ar_hdr {char ar_name[16], ar_date[12], ar_uid[6], ar_gid[6], ar_mode[8],
- ar_size[10], ar_fmag[2]; };
-
- ======================================== ASSERT.H
- [A DEBUGGING AID]
- /* These are macros:- */
- #if NDEBUG
- assert(x) /* ignored */
- assertval(x) /* compiled as (x) */
- #else
- assert(x) /* if (x)==0 then error abort else returns 1 */
- assertval(x) /* if (x)==0 then error abort else returns x */
- #endif
-
- ======================================== ATEXIT.H
- struct atexit {
- struct atexit *next; /* next in list */
- int ind; /* next index in this table */
- void (*fns[ATEXIT_SIZE])(); /* the table itself */ };
- struct atexit *__atexit; /* points to head of LIFO stack */
- /* LIFO = "last in, first out" */
-
- ======================================== BINOMIAL.H
- [BINOMIAL RANDOM NUMBERS]
- #include <_Random.h>, which see
-
- int i,j; double x; RNG g;
- Binomial b; /* declare b to hold the working of a running series of binomial
- random numbers. Has hidden members: int pN; double pU; */
- /* b contains a RNG and can be used as a RNG, and also:- */
- Binomial(i,j,*g) /* a new Binomial with pN=n, pU=u, using RNG g */
- b.n() /* {int} = b.pN */
- b.u() /* {double} = b.pU */
- b.n(i) /* b.pN = i; return {int} = old b.pN */
- b.u(x) /* b.pU = x; return {double} = old b.pU */
- b() /* generate b.pN random numbers;
- return {double} = how many of them < b.pU */
-
- ======================================== BITSET.H
- [ARRAYS OF BITS, OF INDEFINITE LENGTH]
-
- BitSet b; /* declare b to hold a bit pattern which is treated as extending
- to right to infinity. The bits are numbered from 0 up. */
- BitSet c,d; int i,j,k; char t,f,a,*s; short y; long z;
- BitSet() /* a new empty {BitSet} */
- BitSet(b) /* a copy of b. Everything is copied, not only pointers */
- c = b /* b is copied into c. (Everything, not only pointers) */
- b == c /* {boolean} = if b has all bits same as c */
- b != c /* {boolean} = if b has any bits not same as c */
- b <= c c >= b /* {boolean} = if b does not have any 1 where c has 0 */
- b < c c > b /* {boolean} = ditto, but also returns 0 if b==c */
- b | c /* {BitSet} logical or */
- b & c /* {BitSet} logical and */
- b - c /* {BitSet} logical: 1-bit wherever the shorter arg has 1 where
- the other has 0 */
- b ^ c /* {BitSet} logical nonequivalence */
- ~ b /* {BitSet} b with sign of every bit changed */
- b &= c /* {void} b = b & c */
- b |= c /* {void} b = b | c */
- b ^= c /* {void} b = b ^ c */
- b -= c /* {void} b = b - c */
- /* NOTE the destination arg is the <first> arg, unlike in BITSTRIN.H */
- and(b,c,d) /* {void} b = c & d */
- or(b,c,d) /* {void} b = c | d */
- xor(b,c,d) /* {void} b = c ^ d */
- diff(b,c,d) /* {void} b = c - d */
- complement(b,c) /* {void} b = ~ c */
- b.complement() /* {void} b = ~ b */
- b.virtual_bit() /* {boolean} = if b has 1's rather than 0's extending right
- to infinity */
-
- int k; /* in these functions is taken as 0 or 1. Other values mean 1 */
- /* Bits are indexed 0 etseq; index as argument < 0 causes error */
- /* Index as result = -1 for 'not found' or 'infinity' */
- /* In the next 5 functions, k = 1 if the k argument is missing */
- b.first(k) /* {int} index of leftmost bit which is k */
- b.last(k) /* {int} index of rightmost bit which is k */
- b.next(i,k) /* {int} lowest j for j>=i and jth bit of b == k */
- b.previous(i,k) /* {int} highest j for j<=i and jth bit of b == k */
- b.count(k) /* {int} how many k-bits in b (-1 = infinity) */
- b.test(i) /* {boolean} = ith bit of b. Error if i < 0 */
- b.empty() /* {boolean} if b is all 0's */
- /* these functions error if i<0 or i>j */
- b.set() /* set b to all 1's */
- b.set(i) /* set ith bit of b = 1 */
- b.set(i,j) /* set ith to jth bits of b = all 1's */
- b.clear() /* set b to all 0's */
- b.clear(i) /* set ith bit of b = 0 */
- b.clear(i,j) /* set ith to jth bits of b = all 0's */
- b.invert(i) /* reverse ith bit of b */
- b.invert(i,j) /* reverse ith to jth bits of b */
- BitSettoa(b) /* {char*} = bits of x: '1' for 1, '0' for 0, '*' at end.
- The bit before the '*' is taken as repeated to infinity */
- BitSettoa(b,f) /* ditto but char f instead of '0' */
- BitSettoa(b,f,t) /* ditto but char t instead of '1' */
- BitSettoa(b,f,t,a) /* ditto but char a instead of '*' */
- shorttoBitSet(y) /* y as a {BitSet} */
- longtoBitSet(z) /* z as a {BitSet} */
- atoBitSet(s) /* {BitSet}: reverse of BitSettoa(b).
- Illegal character or '*' terminates the string */
- atoBitSet(s,f) /* ditto but char f instead of '0' */
- atoBitSet(s,f,t) /* ditto but char t instead of '1' */
- atoBitSet(s,f,t,a) /* ditto but char a instead of '*' */
- b.OK() /* {int} check b for internal faults. If any found, error exit.
- Else return nonzero value */
- ostream S;
- S << b /* {ostream} same as S << BitSettoa(b) */
-
- BitSetBit p; /* declare p as a 'pointer' to a bit of a BitSet */
- BitSetBit(p) /* copy of p. Everything is copied, not just pointers */
- BitSetBit(*b,i) /* {BitSetBit} 'pointer' to ith bit of b */
- p /* used as {boolean}: the bit that p points at */
- p = k /* {void} set (bit that p points at) = k */
- p == k /* {boolean} if (bit that p points at} == k */
- p != k /* {boolean} if (bit that p points at} != k */
- b[i] /* {BitSetBit} pointing to ith bit of b. Error if i<0 */
-
- ======================================== BITSTRIN.H
- [ARRAYS OF BITS]
- BitString s,t; /* declare s and t, each to hold a bit string */
- BitPattern p; /* declare p. It has 2 public elements: BitString pattern, mask;
- BitPatterns are used as args of search routines. Where p.mask
- has a 1-bit, the string being searched must match p.pattern,
- else that bit of the searched string doesn't matter */
- BitStrBit b; /* declare b to point to a bit in a BitString */
- BitSubString S; /* declare S to point to a substring */
-
- unsigned short y; unsigned long z; unsigned int x; int i,j;
- BitString() /* a new empty {BitString} */
- BitString(p) /* a new {BitString} = a copy of p */
- BitString(S) /* a new {BitString) = a copy of S */
- S /* used as a {BitString}: ditto */
- shorttoBitString(y) /* y as a {BitString} */
- longtoBitString(z) /* z as a {BitString} */
- t = s /* {void} complete copy, not only the pointers */
- s = x /* {void} copy x as a {BitString} */
- s = S /* {void} copy S as a {BitString} */
- BitPattern(s,t) /* a new {BitPattern} with pattern s and mask t */
- BitPattern(p) /* a new {BitPattern} = a copy of p */
-
- /* NOTE that unlike in BITSET.H, the <last> arg is the result arg */
- and(s,t,u) /* {void}: u = s & t */
- or(s,t,u) /* {void}: u = s | t */
- xor(s,t,u) /* {void}: u = s ^ t */
- diff(s,t,u) /* {void}: u = s - t */
- cat(s,t,u) /* {void}: u = s + t */
- cat(s,z,u) /* {void}: u = s + z */
- rshift(s,i,u) /* {void}: u = s >> i */
- lshift(s,i,u) /* {void}: u = s << i */
- complement(s,u) /* {void}: u = ~ i */
-
- s &= t /* {void} s = s & t */
- s |= t /* {void} s = s | t */
- s ^= t /* {void} s = s ^ t */
- s -= t /* {void} s = s - t */
- s += t /* {void} s = s + t */
- s += z /* {void} s = s + z */
- s <<= i /* {void} s = s << i */
- s >>= i /* {void} s = s >> i */
- s.complement() /* {void} s = ~ s */
-
- s & t /* {BitString} logical and */
- s | t /* {BitString} logical or */
- s ^ t /* {BitString} logical nonequivalence */
- s << i /* {BitString} s left shifted by i positions */
- s >> i /* {BitString} s right shifted by i positions */
- s - t /* {BitString} logical 'difference' */
- /* 1 where longer arg has 0 where other arg has 1 */
- s + t /* {BitString} s and t concatenated */
- s + x /* {BitString} s and x (as BitString) concatenated */
- ~ s /* {BitString} s with all bits 0 instead of 1 or vice versa */
-
- s.length() /* {int} length of s */
- s.empty() /* {boolean} s has length zero */
- /* -1 for 'not found' in these functions:- */
- s.index(t) /* look in s for t. Returns {int} = place */
- s.index(t,i) /* ditto, but ignore first i bits of s */
- /* also the same two uses with a BitSubString or a BitPattern instead
- of a BitString */
- s.contains(...) /* {boolean} same uses as s.index, but return 0 for 'not found',
- nonzero for 'found' */
- s.matches(...) /* {boolean} same uses as s.index, but return 0 unless t is
- found starting at i-th bit of s (i omitted = 0) */
- S.length() /* {int} length of S */
- S.empty() /* {boolean} if length of S == 0 */
- s == t /* {boolean} if s has all bits same as t */
- s != t /* {boolean} if s has any bits different from t */
- s <= t t >= s /* {boolean} if s has no 1-bit where t has a 0-bit */
- s < t t > s /* {boolean} ditto, but also false if s == t */
- int k; /* any value other than 0 or 1 is taken as 1 */
- s.first(k) /* {int} index of leftmost k-bit in s */
- s.first() /* {int} index of leftmost 1-bit in s */
- s.last(k) /* {int} index of rightmost k-bit in s */
- s.last() /* {int} index of rightmost 1-bit in s */
- s.index(i,k) /* {int} if i>=0, lowest j for j>=i and jth bit of s = k;
- if i<0, highest j for j<=(ith from end) and jth bit of s = k */
- s.index(i) /* ditto, k=1 */
- s.right_trim(k) /* {BitString} = s with all trailing k-bits removed */
- s.left_trim(k) /* {BitString} = s with all leading k-bits removed */
- s.test(i) /* {boolean} = ith bit of s */
-
- s[i] /* {BitStrBit} pointing to the ith bit of s */
- b /* used as {boolean}: the bit pointed to */
- b = k /* {boolean}: set bit b to k; return its <new> value */
- b == k /* {boolean} if bit b == k */
- b != k /* {boolean} if bit b != k */
-
- BitSubString(S) /* a new {BitSubString} = a copy of S */
- BitSubString(s,i,j) /* a {BitSubString} = bits p to (l+p-1) of s */
- s._substr(i,j) /* {BitSubString} = j bits of s, starting at ith bit.
- Returns null substring if array-out-of-bounds */
- s.count(k) /* {int} how many k-bits in s */
- s.count() /* {int} how many 1-bits in s */
- s.set(i) /* {void} set ith bit of s to 1 */
- s.clear(i) /* {void} set ith bit of s to 0 */
- s.assign(i,k) /* {void} set ith bit of s to k */
- s.set() /* {void} set all bits of s to 1 */
- s.clear() /* {void} set all bits of s to 0 */
- s.invert(i) /* {void} reverse ith bit of s */
- /* In the next 4 functions, error if i<0 or i>j */
- s.set(i,j) /* {void} set ith to jth bits of s to 1 */
- s.clear(i,j) /* {void} set ith to jth bits of s to 0 */
- s.invert(i,j) /* {void} reverse ith to jth bits of s */
- s.test(i,j) /* {boolean} if any 1's in ith to jth bits of s ((I think)) */
- s.next(i,k) /* {int} least j for j>=i & jth bit of s == k. -1 = not found */
- s.next(i) /* {int} least j for j>=i & jth bit of s == 1. -1 = not found */
- s.previous(i,k) /* {int} last j for j<=i & jth bit of s == k. -1 = not found */
- s.previous(i) /* {int} last j for j<=i & jth bit of s == 1. -1 = not found */
- S = s /* {void} full copy */
- S = T /* {void} full copy */
-
- s.at(i,j) /* {BitSubString} = j bits starting at ith bit of s */
- s.before(i) /* {BitSubString} = 0th to (i-1) bits of s */
- s.after(i) /* {BitSubString} = (i+1)th to last bits of s */
- s.at(t,i) /* j = s.index(t,i); {BitSubString} = jth to last bits of s */
- s.before(t,i) /* j = s.index(t,i); {BitSubString} = 0th to(j-1)th bits of s */
- s.after(t,i) /* j = s.index(t,i);
- {BitSubString} = (j + length of t)th to last bits of s */
- /* in the last three functions, omitted 'i' argument = 0 */
- /* also the same three with a BitSubString as first arg */
- /* also the same three with a BitPattern as first arg */
-
- common_prefix(s,t) /* {BitString} = from the 0th bit of s to the bit before
- the first bit that is not the same in t */
- common_prefix(s,t,i) /* ditto but start at the ith bit of a and b */
- common_suffix(s,t,i) /* {BitString} = consecutive bits that re same in s and
- in t, ending at ith bit */
- common_suffix(s,t) /* {BitString}, but seems to return without a value */
- reverse(s) /* {BitString} s with the bits all in reverse order */
-
- char *w,u,v,m;
- atoBitString(w) /* w read as a {BitString}, '0' == 0-bit, '1' = 1-bit,
- any other char terminates */
- atoBitString(w,u) /* ditto, but char u instead of '0' */
- atoBitString(w,u,v) /* ditto, but char v instead of '1' */
- atoBitPattern(w) /* w as {BitPattern}, '0' = must be 0-bit, '1' = must be
- 1-bit, 'X' = doesn't matter, other char terminates */
- atoBitPattern(w,u) /* ditto, but char u instead of '0' */
- atoBitPattern(w,u,v) /* ditto, but char v instead of '1' */
- atoBitPattern(w,u,v,m) /* ditto, but char m instead of 'X' */
- BitStringtoa(s) /* (char*) reverse of atoBitString */
- /* likewise with one or two char args */
- BitPatterntoa(S) /* (char*) reverse of atoBitPattern */
- /* likewise with one or two or three char args */
- ostream F;
- F << s /* {ostream} same as F << BitStringtoa(s) */
- F << S /* {ostream} same as F << BitPatterntoa(S) */
- /* these check the arg for internal errors. If any found,
- they error-exit, else {boolean} nonzero value */
- s.OK() /* check a BitString */
- S.OK() /* check a BitSubString */
- p.OK() /* check a BitPattern */
-
- ======================================== BOOL.H
- enum bool { FALSE = 0, TRUE = 1 };
-
- ======================================== BSTRING.H
- #include <std.h>, which see
-
- ======================================== BUILTIN.H
- [SIMPLE PRINTING; POWER; MISC]
- #include <stddef.h>, which see
- #include <std.h>, which see
- #include <math.h>, which see
-
- long m,n; double x,y; int i,j,k; char c,*f,*s;
- gcd(m,n) /* {long} highest +ve number that is a factor of m and of n */
- lg(n) /* {long} how many bits in n, except leading 0-bits */
- pow(x,n) /* {double} power */
- pow(m,n) /* {long} power */
- start_timer() /* {double}
- return_elapsed_time(n) /* {long} n is 'last time' */
- itoa(n) /* {char*} n as decimal string. The argument can be long or
- long long or unsigned long or unsigned long long */
- itoa(n,i) /* ditto, radix = i */
- itoa(n,i,j) /* ditto, string will be at least j chars long */
- dtoa(x) /* {char*} x as decimal string, floating point if necessary,
- with 6 significant figures */
- dtoa(x,'g') /* ditto */
- dtoa(x,'f') /* ditto but always floating point */
- dtoa(x,c) /* if c is not 'f' or 'g', ditto but never floating point */
- dtoa(x,c,i) /* ditto, the string will be at least i chars long */
- dtoa(x,c,i,j) /* ditto, with j significant figures */
- hex(n) /* {char*) n as hexadecimal */
- hex(n,i) /* ditto, at least i chars */
- oct(n) /* {char*) n as octal */
- oct(n,i) /* ditto, at least i chars */
- dec(n) /* {char*) n as decimal */
- dec(n,i) /* ditto, at least i chars */
- form(f,...) /* {char*} the rest of the args printed by the format f */
- chr(c) /* {char*} the character c */
- chr(c,i) /* ditto, left filled to i chars */
- str(s) /* {char*} a copy of the string s */
- str(s,i) /* ditto, left filled to at least i chars */
- hashpjw(s) /* {unsigned int} the string s hashed */
- multiplicativehash(i) /* {unsigned int} i hashed */
- foldhash(x) /* {unsigned int} x hashed */
- abs(x) /* with double or float or short or long arg, returning same type */
- sign(x) /* with double or long arg. {int} = -1 or 0 or 1, sign of x */
- sqr(x) /* with long or double arg, returning same type (x*x) (NOT sqrt!!) */
- even(n) /* {boolean} if the last bit of n == 1 */
- odd(n) /* {boolean} if the last bit of n == 0 */
- lcm(m,n) /* {long} m / gcd(m,n) * n */
- setbit(m,n) /* {void} set 'pow(2,n-1)' bit of m to 1 */
- clearbit(m,n) /* {void} set 'pow(2,n-1)' bit of m to 0 */
- testbit(m,n) /* {boolean} if 'pow(2,n-1)' bit of m == 1 */
-
- ======================================== COMPARE.H
- [<0 IF X<Y; 0 IF X==Y; >0 IF X>Y]
-
- compare(x,y) /* args must be same type; returns {int} */
- /* if args are int or short or char or float or double,
- returns x-y */
- /* if args are unsigned long or unsigned short or unsigned int
- or unsigned char, returns sign(a-b) */
- /* if args are char*, returns strcmp(x,y) */
-
- ======================================== COMPLEX.H
- [COMPLEX ARITHMETIC]
-
- double x,y; long n;
- Complex c,d,e; /* declare complex variables. They have members: double re,im;
- which may or may not be accessible */
- c.real() /* {double} real part of c */
- c.imag() /* {double} imaginary part of c */
- Complex() /* {Complex} with both parts = 0 */
- Complex(c) /* {Complex} = a copy of c */
- Complex(x) /* {Complex}, real part = x, imag part = 0 */
- x /* used as {Complex}: ditto */
- Complex(x,y) /* {Complex}, real part = x, imag part = y */
- c = d /* usual meaning, returns {Complex} */
- + - * / += -= *= /= == != /* but not % %= < > <= >= << >> <<= >>= */
- /* with all Complex arg(s) have the expected mathematical meanings */
- /* += -= *= /= can also have left arg Complex and right arg double */
- /* + - * / can also have either arg Complex and the other arg double */
- cos(c) /* {Complex} cosine */
- /* likewise sin, cosh, sinh, exp, log, sqrt */
- pow(c,n) /* {Complex} power */
- pow(c,x) /* {Complex} power */
- pow(c,d) /* {Complex} power */
- conj(c) /* {Complex} c with sign of imaginary part changed */
- norm(c) /* {double} real part squared + imag part squared */
- abs(c) /* {double} sqrt(norm(c)) */
- polar(x,y) /* Complex(x*cos(y). y*sin(y)) */
- polar(x) /* Complex(x,0.0) */
-
- ======================================== CTYPE.H
- [WHAT SORT OF CHARACTER]
-
- /* these are all macros */
- char c; /* results unpredictable unless c is 0 to 127 */
- /* "letter" does not include '_' or '$' or PC accented letters */
- isalpha(c) /* {boolean} if c is letter */
- isupper(c) /* {boolean} if c is uppercase letter */
- islower(c) /* {boolean} if c is lowercase letter */
- isdigit(c) /* {boolean} if c is one of 0 1 2 3 4 5 6 7 8 9 */
- isxdigit(c) /* {boolean} if c is one of 0123456789abcdefABCDEF */
- isspace(c) /* {boolean} if c is space or ctrl-J to ctrl-M */
- ispunct(c) /* {boolean} if c is printing char, not space/letter/number */
- isalnum(c) /* {boolean} if c is letter or number */
- isprint(c) /* {boolean} if c is printable char or space */
- isgraph(c) /* {boolean} if c is printable char but not space */
- iscntrl(c) /* {boolean} if c is control char or DEL (char 127) */
- isascii(c) /* {boolean} if c is 0 to 127 */
- toupper(c) /* {char} if islower(c) then uppercase for c, else c */
- tolower(c) /* {char} if isupper(c) then lowercase for c, else c */
- toascii(c) /* {char} on PC, ((c)&127) */
- ======================================== CURSES.H
- /* matter used by CURSESW.H & CURSESWI.H, which see */
-
- ======================================== CURSESW.H
- /* same as CURSESWI.H but without these two functions:- */
- w.touchline(j,sx,ex) /* {int} screen control (args are int) */
- w.touchoverlap(u) /* {int} screen control (defined if DGUX) */
-
- ======================================== CURSESWI.H
- [A GRAPHICS PACKAGE CALLED 'CURSES']
-
- /* Sorry, I can't find fully what these functions do; and according to the file
- <wherever your Gnu C is>\DOCS\LIBC.DOC, Gnu C does not contain the bodies of
- these functions, although this #include file declares them. */
-
- #include <curses.h> int i,j,x,y; char c,*s;
- CursesWindow u,w; /* declare windows for Curses */
- WINDOW W; /* declare a standard window */
- CursesWindow(W) /* W as a {CursesWindow}, useful only for stdscr */
- W /* used as a {CursesWindow}: ditto */
- CursesWindow(j,i,y,x) /* a {CursesWindow} of j lines & i columns,
- starting at line y & column x */
- CursesWindow(w,j,i,y,x,'a') /* ditto, parent window = w */
- CursesWindow(w,j,i,y,x,'r') /* ditto, y & x relative to parent window */
- w.lines() /* {int} number of lines on terminal, *not* window */
- w.cols() /* {int} number of cols on terminal, *not* window */
- w.height() /* {int} number of lines in this window */
- w.width() /* {int} number of cols in this window */
- w.begx() /* {int} smallest x coord in window */
- w.begy() /* {int} smallest y coord in window */
- w.maxx() /* {int} largest x coord in window */
- w.maxy() /* {int} largest x coord in window */
- w.move(y,x) /* {int} window positioning */
- w.getyx(y,x) /* coordinate positioning */
- w.mvcur(sy,ey,sx,ex) /* {int} move cursor? (args are int) */
- w.getch() /* {int} read a character */
- w.getstr(s) /* {int} get string */
- w.scanw(s, ...) /* {int} formatted read from window, s is format */
- w.mvgetch(j,i) /* {int} go to line j,col i; read a character */
- w.mvgetstr(j,i,s) /* {int} go to line j,col i; get string */
- w.mvscanw(j,i,s, ...) /* {int} go to line j,col i;
- formatted read from window, s is format */
- w.addch(c) /* {int} output */
- w.addstr(s) /* {int} output */
- w.printw(s, ...) /* {int} output */
- w.inch() /* {int} output */
- w.insch(c) /* {int} output */
- w.insertln() /* {int} output */
- w.mvaddch(j,i,c) /* {int} go to line j, col i; output */
- w.mvaddstr(j,i,s) /* {int} go to line j, col i; output */
- w.mvprintw(j,i,*s,...) /* {int} go to line j, col i; output. s = format */
- w.mvinch(j,i) /* {int} go to line j, col i; output */
- w.mvinsch(j,i,c) /* {int} go to line j, col i; output */
- char v,h; char b; /* b is always (char)0 or (char)1, a char used as boolean */
- w.box(v,h) /* {int} borders. v = vert, h = horiz */
- w.erase() /* {int} erasure */
- w.clear() /* {int} erasure */
- w.clearok(b) /* {int} erasure */
- w.clrtobot() /* {int} erasure */
- w.clrtoeol() /* {int} erasure */
- w.delch() /* {int} erasure */
- w.mvdelch(j,i) /* {int} go to line j, col i; erasure */
- w.deleteln() /* {int} erasure */
- w.scroll() /* {int} screen control */
- w.scrollok(b) /* {int} screen control */
- w.touchwin() /* {int} screen control */
- w.touchline(j,sx,ex) /* {int} screen control (args are int) */
- w.touchoverlap(u) /* {int} screen control (defined if DGUX != 0) */
- w.refresh() /* {int} screen control */
- w.leaveok(b) /* {int} screen control */
- w.flushok(b) /* {int} screen control */
- w.standout() /* {int} screen control */
- w.standend() /* {int} screen control */
- w.overlay(u) /* {int} multiple window control */
- w.overwrite(u) /* {int} multiple window control */
- w.child() /* {CursesWindow} window that w is parent of */
- w.sibling() /* {CursesWindow} traversal support */
- w.parent() /* {CursesWindow} w's parent */
- w.overlay(u) /* {int} multiple window control */
- w.overwrite(u) /* {int} multiple window control */
- w.child() /* {CursesWindow} window that w is parent of */
- w.sibling() /* {CursesWindow} traversal support */
- w.parent() /* {CursesWindow} w's parent */
-
- ======================================== DIR.H
- [READING MSDOS DIRECTORIES]
-
- struct ffblk { /* type declared to decipher a directory entry */
- char ff_reserved[21], ff_attrib; short ff_ftime, ff_fdate, ff_filler;
- long ff_fsize; char ff_name[16]; };
-
- /* bits of n:- */
- #define FA_RDONLY 1
- #define FA_HIDDEN 2
- #define FA_SYSTEM 4
- #define FA_LABEL 8
- #define FA_DIREC 16
- #define FA_ARCH 32
-
- char *s, struct ffblk F; int n;
- findfirst(s,&F,n) /* {int} read into F the first entry of directory named
- s, according to bits set in n */
- findnext(&F) /* {int} read next entry of directory according to F.
- return 0 if end of directory */
-
- ======================================== DIRENT.H
- [READING MSDOS DIRECTORIES]
-
- #include <sys/dirent.h>, which is:-
- struct dirent {unsigned short d_namlen; char d_name[14]; };
- typedef struct {int num_read; char *name; struct ffblk ff; struct dirent de; }
- DIR;
- DIR *opendir(char *name); /* create a DIR to read the directory named */
- struct dirent *readdir(DIR *dir); /* read next entry of directory dir */
- long telldir(DIR *dir); /* return how far I am down directory dir */
- void seekdir(DIR *dir, long i); /* go to ith entry of directory dir */
- void rewinddir(DIR *dir); /* go to start of directory dir */
- int closedir(DIR *dir); /* stop reading directory dir */
-
- ======================================== DISCRETE.H
- /*** same as DISCUNIF.H, which see */
-
- ======================================== DISCUNIF.H
- [UNIFORM RANDOM NUMBERS]
-
- #include <_Random.h> /* which see */
- long i,j; RNG g;
- DiscreteUniform d; /* declare d to hold the working of a running series of
- integer random numbers within a range 'low' (inclusive)
- to 'high' (not inclusive) */
- /* d contains and can be used as a Random see RANDOM.H) , and also:- */
- DiscreteUniform(i,j,&g) /* a new DiscreteUniform, range i to j, using RNG g */
- d.low() /* {long} lower limit of d */
- d.low(i) /* set lower limit of d to i, return {long} old value */
- d.high() /* {long} upper limit of d */
- d.high(j) /* set upper limit of d to j, return {long} old value */
- d() /* {double} next value in d's random series */
-
- ======================================== DOS.H
- [REGISTER INTERFACE BUFFER TYPES; DOS SYSTEM CALLS]
-
- union REGS {
- struct {unsigned long ax, bx, cx, dx, si, di, cflag, flags; } x;
- struct {unsigned char al, ah; unsigned short upper_ax;
- unsigned char bl, bh; unsigned short upper_bx;
- unsigned char cl, ch; unsigned short upper_cx;
- unsigned char dl, dh; unsigned short upper_dx; } h; };
- struct SREGS {unsigned short cs, ds, es, fs, gs, ss; };
-
- /* system calls */
- union REGS r,s; /* declare r etc for interrupts to read the PC registers from
- and/or put them back into */
- int f; unsigned i,j; void* p; struct SREGS t;
- bdos(f,i,j) /* {int}: registers: DS = i, AL = j; call DOS function f */
- bdos(f,p,j) /* ditto but registers DS & AL = pointer p */
- int86(f,&r,&s) /* {int}: registers = r; call 80x86 interrupt f; s = regs */
- int86x(f,&r,&s,&t) /* {int} ditto, but t = results */
- intdos(&r,&s) /* {int}: registers = r; call 80x86 interrupt 21hex; s = regs */
- intdosx(&r,&s,&t) /* {int} ditto, but t = results */
-
- ======================================== ERLANG.H
- [A SORT OF RANDOM NUMBER]
-
- #include <_Random.h> /* which see */
- Erlang e; /* declare e to hold the workings of an 'erlang' type runinng
- series of random numbers */
- /* contains and can be used as a RNG, and also:- */
- double m,v; RNG g;
- Erlang(m,v,*g) /* new Erlang, mean=m, variance=v, using RNG g */
- e.mean() /* {double} mean of e */
- e.mean(m) /* mean of e = m; return {double} old mean */
- e.variance() /* {double} variance of e */
- e.variance(v) /* variance of e = v; return {double} old variance */
- e() /* k = nearest integer to e.mean() * e.mean() / e.variance();
- x = product of k (at least one) random numbers;
- return {double} -log(x) * e.mean / k */
-
- ======================================== ERRNO.H
- [ERROR NUMBERS RETURNED BY FUNCTIONS THAT CALL MS-DOS]
-
- /* 1 = OK */
- #define ENOENT 2 /* No such file or directory */
- #define ENOTDIR 3 /* No path */
- #define EMFILE 4 /* Too many open files */
- #define EACCES 5 /* Permission denied */
- #define EBADF 6 /* Bad file number */
- #define EARENA 7 /* Arena trashed */
- #define ENOMEM 8 /* Not enough core */
- #define ESEGV 9 /* invalid memory address */
- #define EBADENV 10 /* invalid environment */
- #define ENODEV 15 /* No such device */
- #define EINVAL 19 /* Invalid argument */
- #define E2BIG 20 /* Arg list too long */
- #define ENOEXEC 21 /* Exec format error */
- #define EXDEV 22 /* Cross-device link */
- #define EDOM 33 /* Math argument */
- #define ERANGE 34 /* Result too large */
- #define EEXIST 35 /* File already exists */
-
- ======================================== FCNTL.H
- [MODE ARGUMENTS USED BY SOME FILE-OPENING FUNCTIONS]
-
- #define O_RDONLY 0x0001 /* read only */
- #define O_WRONLY 0x0002 /* write only */
- #define O_RDWR 0x0004 /* read and write */
- #define O_CREAT 0x0100 /* create file if it does not exist */
- #define O_TRUNC 0x0200 /* throw away existing contents of file */
- #define O_EXCL 0x0400 /* if O_CREAT set, error if file exists */
- #define O_APPEND 0x0800 /* open at end of file */
- #define O_TEXT 0x4000 /* open file in text = translated mode */
- #define O_BINARY 0x8000 /* open file in binary = untranslated mode */
- /* these values can be or'ed, except those with contradictory meanings */
-
- ======================================== FILE.H and _FILE.H
- [NEW-STYLE FILE VARIABLES FOR C++]
-
- File f; /* declare f to hold file info, with these hidden fields:-
- FILE *fp; pointer to old C-type FILE structure
- char *nm; file name
- long stat; value returned by last call of various reading
- and writing functions that in old-style C FILE's
- return an int value
- (etc). The File will be correctly set up as an unopened File */
- Special values of f.nm:-
- from keyboard "(stdin)"
- to screen "(stdout)"
- to error channel "(stderr)"
- to/from a string "(string)"
-
- char c, *f, *s, *n, *m, *a; FILE *F; int i, j;
- state_value v; int i,j; char c; void *p; long n;
- /* state_value is int that can = 0 for 'all is well', 1 for 'end of file', 2 for
- 'logical or physical input/output error', 4 for 'file unopened or corrupted' */
-
- /* All functions in FILE.H and _FILE.H return {File} = the value of the File
- argument, unless stated otherwise */
-
- /* Values of some int arguments for open etc:-
- io_mode:- 0 = read only; 1 = write only; 2 = read & write; 3 = append only;
- 4 = append and read.
- (old C fopen equivalents are:- 0 = "r", 1 = "w", 2 = "r+", 3 = "a", 4 = "a+")
- access_mode:- 0 = create (fail if exists already); 1 = truncate (create if does
- not exist); 2 = fail if doesn't exist; 3 = create if desn't exist.
- state_value:- 0 = OK; 1 = at end of file; 2 = logical or physical input/output
- error; 4 = unopened or corrupted. */
-
- File() /* a new unopened {File} info table correctly set up */
- File(n,m,a) /* {File}: as File(), then call f.open(n,m,a) on it */
- File(n,m) /* {File}: as File(), then call f.open(n,m) on it */
- File(i,m) /* {File}: as File(), then call f.open(i,m) on it */
- File(F) /* {File}: as File(), then call f.open(F) on it */
- F /* used as a {File}: ditto */
- File(i,m,0) /* a new {File} open to read from the string m of length i */
- File(i,m,1) /* a new {File} open to write to the string m of length i */
- File(i,m,j) /* error if j != 0 and j != 1 */
- ~File() /* Destructor: close the file. Called automatically at end of
- block that the File is declared in */
- f.open(n,m,a) /* open f as file named n with io_mode m, access_mode a */
- f.open(n,m) /* open f as file named n, args as in old-style fopen */
- f.open(F) /* {File} connect f with the old-style FILE *F */
- f.open(i,j) /* {File} = file number i opened in io_mode j */
- f.close() /* {void} close the file */
- f.remove() /* {void} close & delete the file */
- f.setname(n) /* tell C's File system that file f is now named n.
- But the file is not renamed in MSDOS */
- /* all uses of f.setbuf(...) return {File) f */
- f.setbuf(4) /* set f to unbuffered */
- f.setbuf(128) /* setlinebuf(f.fp) */
- f.setbuf(0) /* set f to unbuffered and 'read till buffer full' mode */
- f.setbuf(i) /* set f to unbuffered and 'read to end of line' mode,
- if i is not 0 or 4 or 128 */
- /* in some sytems the last two cases may not work */
- f.setbuf(i,s) /* set f to use buffer s size i */
- f.error() /* put f into failed mode */
- f.check_state() /* error if f.fp & f don't agree about whether file is at eof */
- f.put(s) /* write the string s */
- /* In the next 4 functions, if the last argument is missing, c = '\n' */
- f.get(s,i,c) /* read into s i chars but stop at char c (do not read the c) */
- f.getline(s,i,c)/* ditto but read the terminator if found */
- f.readline(i,c) /* {char*} called by f.gets */
- f.gets(&s,c) /* read chars until c found. s = pointer to new string
- containing chars read. (Terminator c is read but forgotten.)
- s = NULL is end of file met. No length limit. */
- f.scan(f,...) /* formatted read. f.stat = how many values read */
- f.form(f,...) /* formatted write. f.stat = how many values read */
- f.filedesc() /* {int} fileno(f.fp), i.e. FILE number */
- f.name() /* {char*} file name */
- f.iocount() /* {int} value returned by last read/write/etc on this file */
- f.clear(v) /* {void} set file's state to v */
- f.clear() /* {void} set file's state to 'OK' */
- f.set(v) /* {void} set file state bits set in v */
- f.unset(v) /* {void} unset file state bits set in v */
- f.readable() /* {bool} if file readable from and not at end of file or bad */
- f.writable() /* {bool} if file writable to and not bad */
- f.is_open() /* {bool} file is open */
- f.raw() /* {void} set f to unbuffered mode */
- f.failif(i) /* if i!=0, set f's 'failed' pointer */
- f.get(c) /* read a character from file into c */
- f.put(c) /* put the character c */
- f.unget(c) /* put char c back in f's input buffer */
- f.putback(c) /* put char c back in f's input buffer */
- f.read(p,i,j) /* read from f j items of i bytes each.
- f.stat = how many items successfully read. */
- f.write(p,i,j) /* write to f j items of i bytes each.
- f.stat = how many items successfully read. */
- f.flush() /* if write, write f's buffer, else empty it. */
- f.flush(c) /* ditto, then put c into the emptied buffer ? */
- f.fill() /* fill buffer from file and return {int} = first char ? */
- /* f.seek returns {int} = 0 for success, nonzero for failed */
- f.seek(n,0) /* go to nth byte in file */
- f.seek(n,1) /* move n bytes forward in file */
- f.seek(n,2) /* go to nth byte after (-ve = before) end of file */
- f.tell() /* {long} value returned by the last fread etc */
- f.rdstate() /* f.check_state(); {int} = the result */
- f /* if used as a {void*}: return some state info */
- f.eof() /* {boolean} if file is in end of file condition */
- f.fail() /* {boolean} if file is in failed condition */
- f.bad() /* {boolean} if file is in 'bad' condition */
- f.good() /* {boolean} if file is not at and of file or bad or failed */
-
- ======================================== FILEBUF.H
- [ANOTHER WAY OF ACCESSING FILES]
- #include <streambuf.h>, which see
-
- int i,j; char *s,*n;
- filebuf f; /* declare f to hold a way of accessing file numbered fd,
- using a streambuf as buffer */
- /* it has accessible menbers: int fd; char opened;
- /* f contains a streambuf, and can be used as a streambuf */
- filebuf() /* a new {filebuf} with fd=-1, opened=0, with no buffer */
- filebuf(i) /* a new {filebuf} with fd=i, opened=1, with no buffer */
- i /* used as a {filebuf}: ditto */
- filebuf(i,s,j) /* a new {filebuf} with fd=i, opened=1, buffer s (length j) */
- f.is_open() /* {int} f.opened */
- f.close() /* if f.opened, close file numbered f.fd; f.opened=0;
- return {int} old value of f.opened */
- /* f.open returns {streambuf*} a pointer to f's contained streambuf */
- f.open(n,0) /* open f for reading file named n */
- f.open(n,1) /* open f for writing file named n */
- f.open(n,2) /* open f for appending file named n */
- /* the next 4 uses do nothing & return NULL {streambuf*} value */
- f.open(n,i,j) /* i is io_mode, j is access_mode, see FILE.H */
- f.open(n,s) /* s probably = "r" etc as in old-style fopen() */
- f.open(i,s) /* ditto, and i = file number? */
- f.open(F) /* F is an old-style FILE* pointer */
- f.underflow() /* give f a buffer if it hasn't got one; read a bufferful of
- text from file fd; return {int} char at get-pointer */
- /* automatically called by many streambuf.functions when used as
- filebuf.functions, when the filebuf runs out of chars on read */
- f.overflow(EOF) /* give f a buffer if it hasn't got one; write buffer contents
- to file fd; return {int} EOF if fault, else 0 */
- /* automatically called by many streambuf.functions when used as
- filebuf.functions, when the filebuf gets full on write */
- f.overflow(i) /* if i!=EOF, f.sputc(i); then as ditto */
- ~filebuf() /* Destructor: close filebuf at end of block that declared in */
-
- ======================================== FIX.H
- [MULTI-LENGTH FIXED-POINT REAL ARITHMETIC WITH abs(value) < 1]
- #include <Integer.h>, which see
-
- Fix f; /* declare f to hold a variable length fixed point number */
- Fix e,f,g,h; int i; double x;
- f.unique() /* make sure that f does not share info with other Fix'es */
- Fix(i) /* a new {Fix} with length i */
- i /* used as {Fix}: ditto */
- Fix(x) /* a new {Fix} with value x */
- x /* used as {Fix}: ditto */
- Fix(f) /* copy of pointers of f.
- f is marked to say that its info is now pointed to twice */
- /* called automatically when a Fix is copied or allocated etc */
- Fix(i,f) /* a new {Fix} = f but with length i */
- Fix(i,x) /* a new {Fix} with length i, value x */
- ~Fix() /* Destructor. Keeps track of multiple pointers to info part */
- f = g /* If f & g have same length, copy pointers to info.
- Else complete copy. Returns {Fix} = f */
- f = x /* set value of f = x. Returns {Fix} = f */
- + - * / % += -= *= /= %= == != < > <= >= << >> <<= >>=
- /* with Fix argument(s) have usual mathematical meaning */
- f * i i * f f *= i /* ditto */
- /* These next 2 operators only #ifdef __GNUG__ :- */
- f <? g /* {Fix} = smaller of f and g */
- f >? g /* {Fix} = larger of f and g */
- /* note order of args in these functions! */
- negate(f,e) /* {void} e = - f */
- add(f,g,e) /* {void} e = f + g */
- subtract(f,g,e) /* {void} e = f - g */
- multiply(f,g,e) /* {void} e = f * g */
- divide(f,g,e,h) /* {void} e = f / g; h = remainder */
- shift(f,i,e) /* {void} e = f << i */
- abs(f) /* {Fix} = absolute value of f */
- sgn(f) /* {Fix} = -1 or 0 or +1 as sign of f */
- length(f) /* length of f */
- ostream F; istream G;
- F << f /* {ostream}: as F << Ftoa(f) */
- G >> f /* {istream}: read f from file, as usual */
- atoF(s) /* as atoF(s,Fix_default_length) */
- Ftoa(f) /* as Ftoa(s,Fix_default_print_width) */
- atoF(s,i) /* as Fix(i,atof(s)) */
- Ftoa(f,i) /* {char*} = value of f, printed as at least i chars.
- *** value of f printed is shortened to double if longer */
- show(f) /* print to screen f's internal info */
-
- ======================================== FIX16.H
- [16-BIT & 32-BIT FIXED-POINT REAL ARITHMETIC WITH abs(value) < 1]
-
- Fix16 f; /* declare f to hold a real number which can vary from
- -1 to +1-pow(0.5,15) by steps of pow(0.5,15) */
- Fix32 F; /* declare f to hold a real number which can vary from
- -1 to +1-pow(0.5,31) by steps of pow(0.5,31) */
- /* run time error results if calculation generates out of range value */
-
- Fix16 f; Fix32 F; double x; short n; long N;
-
- /* conversions allowed implicitly or by casting:-
- int or short to Fix16 by dividing by pow(2,15)
- int or long to Fix32 by dividing by pow(2,31)
- Fix16 and Fix32 and double to each other */
-
- f.round(x) /* returns {short} = nearest integer to x. f not affected */
- F.round(x) /* returns {long} = nearest integer to x. F not affected */
- Fix16() /* {Fix16} with value = 0 */
- Fix32() /* {Fix32} with value = 0 */
- mantissa(f) /* {short} (value of f) * pow(2,15) */
- /* can be used as lvalue: effect is f = (value allocated)/pow(2,15) */
- mantissa(F) /* {long} (value of F) * pow(2,31) */
- /* can be used as lvalue: effect is F = (value allocated)/pow(2,31) */
- value(f) /* {double} value of f */
- value(F) /* {double} value of F */
- f.assign(x) /* f = x; return {short} mantissa(x) */
-
- + - * / << >> += -= *= /= <<= >>= == != < > <= >=
- /* with Fix16 arguments have usual effect */
- << and >> as I/O operators can have right arg Fix16. Printed as double.
- f * i i * f f *= i /* usual effect */
-
- + - * / << >> += -= *= /= <<= >>= == != < > <= >=
- /* with Fix32 arguments have usual effect */
- << and >> as I/O operators can have right arg Fix32. Printed as double.
- F * i i * F F *= i /* usual effect */
-
- ======================================== FIX24.H
- [24-BIT & 48-BIT FIXED-POINT REAL ARITHMETIC WITH abs(value) < 1]
-
- Fix24 f; /* declare f to hold a real number which can vary from
- -1 to +1-pow(0.5,23) by steps of pow(0.5,23) */
- /* Stored in 4 bytes but only uses 3 of them */
- Fix48 F; /* declare f to hold a real number which can vary from
- -1 to +1-pow(0.5,47) by steps of pow(0.5,47) */
- /* Stored in 8 bytes but only uses 6 of them */
- /* run time error if calculation produces out of range value */
-
- Fix24 f; Fix48 F; int i; long n; double x;
-
- /* conversions allowed implicitly or by casting:-
- int or long to Fix24 by dividing by pow(2,23)
- int or long to Fix48 by dividing by pow(2,47)
- Fix24 and Fix48 and double to each other */
-
- Fix24() /* new {Fix24} = 0 */
- mantissa(f) /* {long} (value of f) * pow(2,23) */
- /* can be used as lvalue: effect is f = (value allocated)/pow(2,23) */
- value(f) /* {double} value of f */
-
- typedef struct {long u; unsigned long l; } twolongs;
- /* 1 bit sign; 23 bits data; 8 bits wasted; 24 bits data; 8 bits wasted */
- twolongs t;
- /* value of t = t.u / pow(2.0,31) + sign(t.u) * t.l / pow(2.0,55) */
-
- Fix48() /* a new {Fix48} = 0 */
- mantissa(F) /* {twolongs} (value of F) * pow(2,47) */
- /* can be used as lvalue: effect is F = (value allocated)/pow(2,47) */
- value(F) /* {double} value of F */
-
- + - * / << >> += -= *= /= <<= >>= == != < > <= >=
- /* with Fix24 arguments have usual effect */
- << and >> as I/O operators can have right arg Fix24. Printed as double.
- f * i i * f f *= i /* usual effect */
-
- + - * / << >> += -= *= /= <<= >>= == != < > <= >=
- /* with Fix24 arguments have usual effect */
- << and >> as I/O operators can have right arg Fix48. Printed as double.
- F * i i * F F *= i /* usual effect */
-
- ======================================== FMODES.H
- /* some #defines used by input/output functions :- */
- enum io_mode { /* known unix file IO modes */
- io_readonly = 0, io_writeonly = 1, io_readwrite = 2, io_appendonly = 3,
- io_append = 4, /* append, plus allow reads */ };
- enum access_mode { /* ways to open a file */
- a_createonly = 0, /* create, fail if file exists */
- a_create = 1, /* create if doesn't exist, else truncate */
- a_useonly = 2, /* use (no truncate) fail if doesn't exist */
- a_use = 3, /* use (no truncate), create if doesn't exist */ };
- enum state_value { /* File states */
- _good = 0, /* all is well */
- _eof = 1, /* at eof */
- _fail = 2, /* logical or physical input/output error */
- _bad = 4} /* unopened/corrupted */
-
- ======================================== GENERIC.H
- /* See the CPP manual, argument prescan section for explanation */
- /* These macros can only occur inside macro definitions */
-
- b,c,d,e must be arguments of the macro definition that these macros
- are called inside.
- They are replaced by the args of that macro's call.
- Within these constructions, tags that meet at joins are concatenated.
- (e.g. after #define joined(x,y) x name(a,b) y
- joined(cat call) compiles as x catcall y )
-
- name2(b,c) b c
- gEnErIc2(b,c) b c
- name3(b,c,d) b c d
- gEnErIc3(b,c,d) b c d
- name4(b,c,d,e) b c d e
- gEnErIc4(b,c,d,e) b c d e
- GENERIC_STRING(b) "b" as string, and inside b adjust '\' etc accordingly
- gEnErIcStRiNg(b) "b" as string, and inside b adjust '\' etc accordingly
- declare(b,c) b declare (c)
- declare2(b,c,d) b declare2 (c,d)
- implement(b,t) b implement (t)
- implement2(b,c,d) b implement2 (c,d)
- set_handler(b,c,d) set_ c b _handler (d)
- errorhandler(b,c) c b handler
- callerror(b,c,d,e) (*c b handler)(d,e)
-
- extern genericerror(int,char*);
- typedef int (*GPT)(int,char*);
-
- ======================================== GEOM.H
- [GEOMETRIC RANDOM NUMBERS]
-
- #include <_Random.h>, which see
- Geometric g; /* declare g to hold workings of a running series of Geometric
- random numbers.
- Contains and can be used as an RNG, and also:- */
- double x; RNG r;
- Geometric(x,&r) /* a new {Geometric} with mean x, using r */
- g.mean() /* {double} mean of x */
- g.mean(x) /* set g's mean = x; return {double} = old mean *?
- g() /* add random numbers until their sum > g's mean.
- return {double} = how many random numbers needed */
-
- ======================================== GEOMETRI.H
- /* same as GEOM.H */
-
- ======================================== GETOPT.H
- [EXAMINING TABLES OF PARAMETERS HELD IN ARRAYS OF STRINGS]
-
- /* This version appears to the user like standard Unix getopt, but it behaves
- differently, since it lets the user mix the options with the other arguments. As
- getopt works, it permutes the elements of argv so that, when it is done, all the
- options precede everything else. This lets all application programs handle
- flexible argument order. Setting the environment variable _POSIX_OPTION_ORDER
- disables permutation. Then the behavior is completely standard. GNU application
- programs can use a third alternative mode in which they can distinguish the
- relative order of options and other arguments. */
-
- int n; char **t /* array of strings */; char *s;
-
- GetOpt g; /* declare g to hold a table of call arguments and info re
- scanning it for options. It has these accessible members:- */
- g.optarg /* {char*} used to return arguments of options */
- g.optind /* {int} index in ARGV of the next element to be scanned */
- g.opterr /* {int} callers store 0 here to inhibit the error message for
- unrecognized options */
- g.nargc /* {int} how many elements in nargv */
- g.nargv /* {char**} array of string arguments */
- g.noptstring /* {char*) option string */
-
- GetOpt(n,t,s) /* a new {GetOpt} with its members set thus:- g.nargc = n;
- g.nargv = t; g.noptstring = s; g.optind = 1;
- t is a table of string arguments in t[1] to t[n-1].
- s is an option string.
- If s[0]=='-', g is set up in RETURN_IN_ORDER mode, else
- if environment variable POSIX_OPTION_ORDER is set nonzero,
- then in REQUIRE_ORDER mode, else in PERMUTE mode */
-
- g() /* returns {int} :-
- Scans array elements t[i] (as set by GetOpt(n,t,s)) (i = between 1 and n-1):-
- Scan t[i]'s for option characters given in s.
- If t[i][0] == '-', and t[i] is not exactly "-" or "--", then t[i] is an
- option element, and t[i]'s characters (except the initial '-') are option chars.
- If g() is called repeatedly, it returns successively each option character
- >from each option element.
- If there are no more option characters, g() returns 'EOF', and t[g.optind] is
- the first t[i] that is not an option. The user must scan the t[i]'s from
- t[g.optind] onwards himself. The t[i]'s will have been permuted so that those
- that are not options now come last.
- If s[j] == ':', s[j-1] is an option that wants an argument. The rest of t[i],
- or the whole of t[i+1], is the required argument, and g.optarg now points to it.
- If an option character is seen that is not in s, g() prints an error message
- and returns '?'. If you set g.opterr = 0, the error message is suppressed but
- g() still returns '?'.
- If also s[j+1] == ':', s[j-1] is an option that wants an optional argument,
- which is the the rest of t[i] if there is any of t[i] unscanned.
- If s[0] == '-', g() handles the non-option t[i]'s differently. See below.
- In PERMUTE mode (the default), g() permutes the t[i]'s as it scans, as above,
- so that eventually all the options are at the end. This allows options to be
- given in any order, even with programs that were not written to expect this.
- In REQUIRE_ORDER mode, g() stops when it finds the first t[i] that is not an
- option. This is what Unix does.
- In RETURN_IN_ORDER mode, the t[i]'s are not permuted, and g() treats each
- non-option t[i] as the argument of an option = (char)0. Using '-' as the first
- character of the list of option characters requests this mode of operation.
- If any t[i] is the special argument "--", scanning for options ends there
- whether or not the t[i]'s are being permuted. In RETURN_IN_ORDER mode, only "--"
- can cause g() to return EOF with g.optind != g.argc */
-
- ======================================== GETPAGES.H
- /* #define's re page size */
-
- ======================================== GRAPHICS.H
- [GRAPHICS]
- You should also #include <mouse.h>
- Also read file <wherever your Gnu C is kept>\DOCS\LIBGR.DOC
-
- GrRegion g; /* set up g to hold details of a graphical region on screen.
- It has these accessible members:-
- g.flags /* {int} re mouse?
- g.color /* {int} color where not drawn on
- g.parent /* {GrRegion*} pointer to GrRegion that it is a subregion of
- g.rel_x, g.rel_y /* {int} coords ref g's origin (units are pixels)
- g.abs_x, g.abs_y /* {int} coords ref screen (units are pixels)
- g.width /* {int} width in pixels
- g.height /* {int} height in pixels
- g.row_scale /* {int} pixels per row
- g.data /* {unsigned_char*} for read/write operations *EXCEPT* bcopy/memcpy
- g.rdata /* {unsigned char*) for read via bcopy/memcpy
- g.wdata /* {unsigned char*) for write via bcopy/memcpy
-
- [GRAPHIC MODES]
-
- These plot routines have modes 0 to 8, which differ from the ordinary CGA /
- EGA / VGA modes with the same numbers. They are:-
- typedef enum {
- GR_80_25_text = 0,
- GR_default_text = 1,
- GR_width_height_text = 2,
- GR_biggest_text = 3,
- GR_320_200_graphics = 4,
- GR_default_graphics = 5,
- GR_width_height_graphics = 6,
- GR_biggest_noninterlaced_graphics = 7,
- GR_biggest_graphics = 8
- } GR_graphics_modes;
- GR_graphics_modes i; int x,y;
- GrSetMode(i,x,y) /* set graphics to mode i.
- width=x and height=y in modes 2 and 6;
- x and y arguments treated as 0 if omitted */
-
- [COPYING AREAS OF SCREEN]
- GrRegion g,G; int x,y,i,j,k,X,Y;
- Blit(*g,i,j, *G,f) /* as Blit(*g,0,0,i,j, *G,0,0,f) */
- Blit(*g,x,y,i,j, *G,X,Y,0) /* copy an area i wide & j high from g (origin
- = (x,y) to G (origin = (X,Y) */
- Blit(*g,x,y,i,j, *G,X,Y,2) /* ditto, but neqv each pixel copied */
- Blit(*g,x,y,i,j, *G,X,Y,1) /* do nothing */
-
- [ORGANIZING PALETTE WITH 256 PLACES]
- extern int _GrCurMode;
- typedef struct {unsigned char n,state,r,g,b; } Color;
- /* n = how many brushes in this palette place */
- /* state: 0=free, 1=shared, 2=writable */
- /* r,g,b = how much red/green/blue (0 = none, 255 = most) */
- Color color[256]; /* the palette */
-
- int r,g,b; /* how much red/green/blue */
- int i,j,n,f;
-
- /* At start of many functions, this function is called if necessary:- */
- init_colormap() /* wash palette out;
- make black in place 0, and white in place 1 */
- GrBlack() /* {int} 0 */
- GrWhite() /* {int} 1 */
- GrAllocColor(r,g,b) /* if this mixture not made already, make it.
- {int} = index of palette place */
- GrAllocCell() /* {int} = index of a spare palette place */
- GrSetColor(n,r,g,b) /* {void} make mixture in place n; tell the system */
- GrQueryColor(n,&r,&g,&b) /* {void} find what nth mixture is */
- GrFreeColor(n) /* {void} throw away mixture n */
- GrRefreshColors() /* on some systems, tell the system again about all the
- color mixtures */
-
- [SCREEN]
- unsigned _GrMaxX; /* current screen width */ unsigned _GrSizeX;
- unsigned _GrMaxY; /* current screen height */ unsigned _GrSizeY;
-
- /* the screen seems to be a byte array (1 per pixel) by rows starting at address
- hex D0000000 = 13 * pow(2,28). Not > pow(2,20) screen positions */
- int x,y,X,Y,c;
- /* plot off screen has no effect */
- GrPlot(x,y,c) /* if c > 63, screen[x][y] is neqv'ed with c */
- /* else screen[x][y] = c */
- /* screen[x][y] may be the number of the color mixture there */
- GrPixel(x,y) /* {int} screen[x][y] (0 if off screen) */
- GrPlot3d(x,y,c) /* if c > screen[x][y], or c < 96, screen[x][y] = c */
- GrMaxX() /* {int} _GrMaxX = maximum screen width */
- GrMaxY() /* {int} _GrMaxY = maximum screen height */
- GrSizeX() /* {int} _GrSizeX; */
- GrSizeY() /* {int} _GrSizeY; */
-
- [DRAW A LINE]
- GrLine(x,y,X,Y,c) /* draw a line of color c from (x,y) to (X,Y) */
-
- [MOUSE]
- [mouse flags:-]
- #define M_LEFT_DOWN 0x001 #define M_LEFT_UP 0x002
- #define M_MIDDLE_DOWN 0x004 #define M_MIDDLE_UP 0x008
- #define M_RIGHT_DOWN 0x010 #define M_RIGHT_UP 0x020
- #define M_MOTION 0x040 #define M_KEYPRESS 0x080
- #define M_POLL 0x100 #define M_NOPAINT 0x200
- #define M_BUTTON_DOWN (M_LEFT_DOWN | M_MIDDLE_DOWN | M_RIGHT_DOWN)
- #define M_BUTTON_UP (M_LEFT_UP | M_MIDDLE_UP | M_RIGHT_UP)
-
- typedef struct {int flags, x, y, buttons, key; } MouseEvent; MouseEvent e;
- (x,y) = where mouse was last;
- (e.buttons & 1) != 0 if left buttom down;
- (e.buttons & 2) != 0 if middle buttom down;
- (e.buttons & 4) != 0 if left buttom down;
- (e.flags & 1) != 0 if left button pressed
- (e.flags & 2) != 0 if left button released
- (e.flags & 4) != 0 if middle button pressed
- (e.flags & 8) != 0 if middle button released
- (e.flags & 16) != 0 if right button pressed
- (e.flags & 32) != 0 if right button released
- (e.flags & 21) != 0 if any button pressed
- (e.flags & 42) != 0 if any button released
- (e.flags & 64) != 0 if mouse moves
- (e.flags & 128) != 0 if a keyboard key pressed
- (e.flags & 256) != 0 if MouseGetEvent has used this MouseEvent variable
- e.key = raw code number (not (char) value) of last (if any) keyboard key pressed
- while MouseGetEvent was using e
-
- MouseSetColors(f,b) /* set mouse symbol foreground & background colors */
- paint_mouse(x, y) /* draw a mouse-symbol at (x,y) */
- unpaint_mouse() /* remove mouse-symbol */
- MouseSetSpeed(i) /* set mouse speed to i (by int33 with ax=15) */
- MouseWarp(x,y) /* move mouse pointer to (x,y) */
- MouseGetEvent(n,*e) /* keep track of the mouse until a mouse event as listed
- above happens, and record the result in e; but ignore
- events whose bits are not also set in n; but always keep
- track of mouse movements in e.x and e.y .
- If (n&512) != 0, mouse symbol does not move with mouse.
-
- [REGIONS]
- GrScreenRegion() /* {GrRegion*} = a GrRegion covering all the screen */
- GrRegion() /* a new {GrRegion} with size = 0 both ways */
- GrRegion(i,j) /* a new {GrRegion} i wide and j high */
- g.SubRegion(x,y,i,j) /* a new {GrRegion} within g, origin at (x,y),
- i wide, j high. NULL if can't be created.
- An empty {GrRegion} if size goes out of size of g */
- g.MaxX() /* {int} g.width-1 */
- g.MaxY() /* {int} g.height-1 */
- g.SizeX() /* {int} g.width */
- g.SizeY() /* {int} g.height */}
- /* in these functions, if c&64!=0, each point neqv'ed by c */
-
- g.Plot(x,y,c) /* draw dot at (x,y), color = c */
- g.Line(x,y,X,Y,c) /* draw line, color = c */
- g.HLine(x,X,y,c) /* draw horizontal line, color = c */
- g.VLine(x,y,Y,c) /* draw vertical line, color = c */
- g.Rectangle(x,y,X,Y,c) /* draw hollow rectangle, color = c */
- g.Box(x,y,X,Y,c) /* draw solid rectangle, color = c */
- char *s;
- g.Text(x,y,s,f,b) /* draw text s starting at (x,y),
- foreground color = f, background color = b */
- g.Text(x,y,s,f,-1) /* ditto, background = what was there before */
- g.Point(x,y) /* {int} = color at point (x,y) */
- GrTextXY(x,y,s,f,b) /* draw text s starting at (x,y),
- foreground color = f, background color = b */
-
- ======================================== GRP.H
- /* #define's, perhaps re graphics? */
-
- ======================================== HYPERGEO.H
- [HYPERGEOMETRIC RANDOM NUMBERS]
-
- #include <_Random.h>, which see
- double x,m,v; RNG r;
- HyperGeometric g; /* declare g to hold workings of s running series of
- hypergeometric random numbers */
- HyperGeometric(m,v,&r) /* a new {HyperGeometric} with mean=m, variance=v,
- using r */
- g.mean() /* {double) = mean of g */
- g.mean(m) /* mean of g = m; {double} = previous mean */
- g.variance() /* {double) = variance of g */
- g.variance(v) /* variance of g = v; {double} = previous variance */
- g() /* x = (variance - mean*mean) / (variance + mean*mean);
- x = (1-sqrt(x))/2; if (random number) > x then x = 1 - x;
- {double) = log((another random number)/2/x) */
-
- ======================================== HYPGEOM.H
- /* same as HYPERGEO.H */
-
- ======================================== INCREMEN.H
- /* for a user initializer file? */
-
- ======================================== INTEGER.H
- [MULTI-LENGTH INTEGER ARITHMETIC]
-
- Integer x,y,z; /* declare multi-length integer variables */
- int i,j,k;
- /* there is automatic conversion between Integer and long int */
- /* fault if value is too big on conversion */
- x.initialized() /* {boolean} = if x has been given a value */
- x.fits_in_long() /* {boolean} = if value of x will fit into long int */
- x.fits_in_double() /* {boolean} = if value of x will fit into double */
- /* the next two functions can also have either argument long int */
- compare(x,y) /* {int) < 0 if x < y, == 0 if x == y, > 0 if x > y */
- ucompare(x,y) /* {int} compare(abs(x),abs(y)) */
- + - * / % += -= *= /= %= == != < > <= >= << >> <<= >>= ++ -- & &= | |= ^ ^= ~
- /* with Integer argument(s) have their usual meanings */
- /* but not ++ -- to <right> of their argument? */
- /* these next two function uses only if #ifdef __GNUG__ :- */
- x <? y /* {Integer} minumum */
- x >? y /* {Integer} maximum */
- abs(x) /* {Integer} absolute value of x */
- sign(x) /* {int} = -1 if x < 0, 0 if x == 0, +1 if x > 0 */
- odd(x) /* {boolean} = if x is odd number */
- even(x) /* {boolean} = if x is even number */
- lg(x) /* {long int}
- sqr(x) /* {Integer} x * x (<not> sqrt!) */
- Integer r; long int I,J,K,R; char *s;
- pow(x,y) /* {Integer} power */
- pow(x,I) /* {Integer} power */
- Ipow(I,J) /* {Integer} power */
- gcd(x,y) /* {Integer} biggest number > 0 that is factor of x and of y */
- ratio(x,y) /* {double} x/y */
- divide(x,y,z,r) /* {void} z = y / y, r = remainder */
- divide(x,J,z,R) /* {void) z = x / J, R = remainder */
- setbit(x,K) /* set '1 << K' bit of x = 1. Lengthen x if necessary */
- clearbit(x,K) /* set '1 << K' bit of x = 0. Lengthen x if necessary */
- testbit(x,K) /* {boolean} = the '1 << K' bit of x */
- sqrt(x) /* {Integer} square root of x */
- lcm(x,y) /* {Integer} x * y / gcd(x,y) */
- Itoa(x) /* {char*} x printed */
- Itoa(x,i) /* {char*} x printed to radix i */
- Itoa(x,i,j) /* {char*} x printed to radix i as >= j chars */
- atoI(s) /* s read as an {Integer} */
- atoI(s,i) /* s read as an {Integer} to radix i */
- << >> /* as input/output operators can be used with Integer */
- dec(x,j) /* {char*} x printed as <= j chars */
- oct(x,j) /* {char*} x printed octal as <= j chars */
- hex(x,j) /* {char*} x printed hexadecimal as <= j chars */
- x.OK() /* {boolean} if x's internal workings are correct */
-
- ======================================== IO.H
- /* this #include file is empty */
-
- ======================================== ISTREAM.H
- [ANOTHER WAY TO ACCESS INPUT FILES]
- /* and see OSTREAM.H */
-
- #include <_File.h>, which see
- #include <streambuf.h>, which see
- #include <filebuf.h>, which see
- #include <_Filebuf.h>, which see
-
- istream F; /* declare an input channel */
- ostream G; /* declare an output channel */ /* see OSTREAM.H */
- /* these have a hidden int member F.state or G.state, which = 0 for OK,
- 1 for end-of-file, 2 for input/output failure, 4 for bad */
- /* F has a hidden char member F.skipws: if F.skipws != 0, at start of
- any reads, the istream's pointer skips over any succession of spaces or
- ctrl-J to ctrl-M's at pointer */
- /* An ostream can be tied to an istream; on any reads on the istream,
- its tied ostream's buffer contents are sent to file */
-
- class whitespace {char filler; }
- /* a class used only to input and discard white space characters */
- int i,j,k; char c,*s,*t; double x; FILE *f; streambuf S; whitespace w;
- istream cin; /* predeclared to mean stdin, i.e. usually the keyboard */
- /* These functions etc return {istream} = F, unless stated otherwise */
- /* all uses of istream(..) return a new {istream}, tied to ostream G,
- with skipws = k, and the rest of the arguments as follows:- */
- /* If k omitted, it = 1. If G omitted, it = 0, i.e. no tied ostream */
- istream(s,k,G) /* buffer = s */
- s /* used as an {istream}: ditto */
- istream(i,s,k,G) /* buffer = s, buffer length = i bytes */
- istream(i,0,k,G) /* with new buffer i bytes long */
- istream(s,i,j,k,G) /* internal name s, io_mode = i, access_mode = j */
- /* see FMODES.H for values of i and j */
- istream(s,t,k,G) /* t = opening mode as old-style C fopen */
- istream(i,j,k,G) /* opened on file numbered i, open_mode j */
- istream(f,k,G) /* opened on old-style C FILE *f */
- f /* used as an {istream}: ditto */
- istream(i,k,G) /* opened on file numbered i */
- i /* used as an {istream}: ditto */
- istream(i,s,j,k,G) /* ditto, buffer = s, buffer length = i */
- istream(S,k,G) /* using streambuf S */
- S /* used as an {istream}: ditto */
-
- /* F.open() returns {istream} F, but NULL if the opening failed */
- F.open(s,i,j) /* open F, name s, io_mode i, access_mode j */
- F.open(s,t) /* ditto but t = opening mode as old-style C fopen() */
- F.open(i,j) /* open F on file numbered i, io_mode j */
- F.open(f) /* open F on old-style C FILE f */
- F.open(s,i) /* open F, name s, open_mode = m */
- F.clear() /* {void} F.state = 0 (== OK) */
- F.clear(i) /* {void} F.state = i */
- F.set(i) /* {void} set to 1 the bits of F.state which are set in i */
- F.unset(i) /* {void} set to 0 the bits of F.state which are set in i */
- F.rdstate() /* {int} F.state */
- F.good() /* {boolean} F.state == 0 (== OK) */
- F.eof() /* {boolean} the 'end of file' bit is set in F.state */
- F.fail() /* {boolean} the 'failed' bit is set in F.state */
- F.bad() /* {boolean} the 'bad channel' bit is set in F.state */
- F /* {coerced to void*}: if F.good(), a pointer to F, else 0 */
- !F /* {boolean} if F.state != 0, i.e. if fault bit is set in F */
- F.failif(i) /* if(i!=0) F.fail() */
- F.is_open() /* {boolean} if F is open */
- F.readable() /* {boolean} if F is open and can be read from */
- F.writable() /* {boolean} false */
- F.bufptr() /* {char*} pointer to F's buffer */
- F.close() /* close F */
- F.skipws(i) /* F.skipws= i; {int} previous value of F.skipws */
- F.unget(c) /* put char c into input buffer, as sputbackc(c) in FILEBUF.H */
- /* Fails if pointer is already at start of buffer */
- F.putback(c) /* ditto */
- eatwhite(F) /* send to file the buffer contents of any ostream tied to F;
- skip F's pointer over spaces and ctrl-J to ctrl-M */
- F.get(c) /* read char from F into c */
- F >> w /* send to file the buffer contents of any ostream tied to F;
- skip F's pointer over spaces and ctrl-J to ctrl-M */
- F >> c /* read a character from F into c */
- F >> s /* read chars into s. Stop at but not including any
- space or ctrl-J to ctrl-M met */
- /* In the next 3 function uses, if the c arg is omitted, it = '\n' */
- F.get(s,i,c) /* read into s i characters but stop at (not including) any
- character == c met */
- F.getline(s,i,c) /* read into s i characters but stop at <and lose> any
- character == c met */
- F.gets(&s,c) /* read characters into s until a character == c is met.
- Loses the terminator. May alter the pointer s */
- F >> i /* read i from F; return {istream} = F */
- /* right arg can be long, unsigned long, int, unsigned int, short,
- unsigned int, float, or double */
- F.name() /* {char*} F's name */
- F.error() /* {void} make an error on F */
- F.tie(G) /* tie ostream G to F; return te previous {ostream} tied to F */
- F.flush() /* {void} send to file the buffer contents of any ostream tied
- to F */
-
- ======================================== LIBC.H
- #include <builtin.h>, which see
-
- ======================================== LIMITS.H
- #define LONG_MAX (0x7fffffff) #define LONG_MIN (0x80000000)
- #define ULONG_MAX (0xffffffff) #define ULONG_MIN (0x00000000)
-
- ======================================== LOGNORM.H
- [LOGNORMAL RANDOM NUMBERS]
-
- #include "Normal.h", which see
- LogNormal x; /* declare x to hold workings of a running series of lognormal
- random numbers */
- /* x contains and can be used as a Normal, and also:- */
- /* but altering the contained Normal's mean or variance directly
- will foul the workings of the LogNormal */
- double m,v; RNG r;
- LogNormal(m,v,&r) /* a new {LogNormal} with mean m, variance v,
- using generator r */
- x.mean() /* {double} mean of x */
- x.mean(m) /* mean of x = m; returns {double} previous mean of x */
- x.variance() /* {double} variance of x */
- x.variance(v) /* variance of x = v; returns {double} previous variance of x */
- x() /* {double} generate & return a new log-of-normal random number */
-
- ======================================== LOGNORMA.H
- /* same as LOGNORM.H */
-
- ======================================== MALLOC.H
- [ALLOCATING MORE STORE AT RUN TIME]
-
- #include <std.h>, which see for the declarations */
- /* the start of (wherever you put your Gnu C)\LIBSRC\C\GPP\MALLOC.C contains a
- useful description of how this malloc() etc works */
-
- int i,n; void *p,*q;
- malloc(n) /* allocates n bytes, and returns {void*} pointer to them */
- /* also uses 8 more bytes per malloc, for links etc */
- free(p) /* free the space that p points to. p must point to the <start>
- of a store area allocated by malloc. Writing to a free()'d area
- may make malloc() or free() crash when either is called again.
- free() may crash if called with a wrong value of p */
- cfree(p,i,n) /* ditto */
- calloc(i,n) /* {void*} malloc(i * n), the store allocated is set to zeros */
- realloc(p,n) /* effect of: q = malloc(n); copy malloc block p into malloc
- block q, or as much as will fit; free(p); return {void*} q */
- malloc_stats() /* print malloc statistics to screen */
-
- ======================================== MATH.H
- [SOME MATHEMATICAL FUNCTIONS]
-
- double x,y; int i;
- acosh(x) /* {double} arccosh(x) */
- asinh(x) /* {double} arcsinh(x) */
- cbrt(x) /* {double} cube root of x? */
- copysign(x,y) /* {double} x with sign of y? y with sign of x? */
- erf(x) /* {double} error function */
- erfc(x) /* {double} 1 - erf(x) */
- finite(x) /* {double} what??? */
- gamma(x) /* {double} gamma function(x) */
- hypot(x,x) /* {double} sqrt(x*x + y*y)(x) */
- infnan(i) /* {boolean} x is machine infinity or illegal value (??) */
- isinf(x) /* {boolean} x is machine infinity */
- isnan(x) /* {boolean} x != x, i.e. x is some sort of illegal value */
- j0(x) /* {double} Bessel functions? */
- j1(x) /* {double}
- jn(i, x) /* {double}
- lgamma(x) /* {double}
- y0(x) /* {double}
- y1(x) /* {double}
- yn(i,x) /* {double}
- /* I am guessing that these 4 functions mean the same as in Fortran */
- aint(x) /* {double} x rounded to integer: towards 0 or -infinity?? */
- anint(x) /* {double} nearest integer to x */
- irint(x) /* {int} x rounded to integer: towards 0 or -infinity?? */
- nint(x) /* {int} nearest integer to x */
-
- #define M_E 2.7182818284590452354 exp(1)
- #define M_LOG2E 1.4426950408889634074 log(e) to base 2
- #define M_LOG10E 0.43429448190325182765 log(e) to base 10
- #define M_LN2 0.69314718055994530942 log(2) to base e
- #define M_LN10 2.30258509299404568402 log(10) to base e
- #define M_PI 3.14159265358979323846 pi
- #define M_PI_2 1.57079632679489661923 pi/2
- #define M_1_PI 0.31830988618379067154 1/pi
- #define M_PI_4 0.78539816339744830962 pi/4
- #define M_2_PI 0.63661977236758134308 2*pi
- #define M_2_SQRTPI 1.12837916709551257390
- #define M_SQRT2 1.41421356237309504880 sqrt(2)
- #define M_SQRT1_2 0.70710678118654752440 1/sqrt(2)
- #define PI M_PI
- #define PI2 M_PI_2
-
- ======================================== MAX.H
- #include <builtin.h>, which see
-
- ======================================== MEMORY.H
- #include <std.h>, which see
-
- ======================================== MIN.H
- #include <builtin.h>, which see
-
- ======================================== MINMAX.H
- #include <builtin.h>, which see
-
- ======================================== MLCG.H
- [MULTIPLICATIVE LINEAR CONGRUENTIAL GENERATOR OF RANDOM NUMBERS]
-
- #include <RNG.h>, which see
- long int i,j,k;
- MLCG m; /* declare m to hold the workings of a running series of that
- sort of random numbers */
- /* m includes and can be used as a RNG, and also:- */
- /* m has accessible members:
- long int initialSeedOne, initialSeedTwo, seedOne, seedTwo; */
-
- m.seed1() /* {long} m.seedOne */
- m.seed1(i) /* {void} m.seedOne = i */
- m.seed2() /* {long} m.seedTwo */
- m.seed2(i) /* {void} m.seedTwo = i */
- m.reseed(i,j) /* {void} m.initialSeedOne = s1;
- m.initialSeedTwo = s2; reset(); */
- MLCG(i,j) /* a new {MLCG}, and call m.reseed(i,j) on it */
- MLCG(i) /* as MLCG(i,1) */
- i /* used as an {MLCG}: ditto */
- MLCG() /* as MLCG(0,1) */
- m.reset() /* m.seedOne = m.initialSeedOne;
- m.seedTwo = m.initialSeedTwo;
- change m.seedOne & m.seedTwo if they naven't got enough bits; */
- m.asLong() /* generate an {unsigned long} random number thus:-
- long k = m.seedOne % 53668;
- m.seedOne = 40014 * (m.seedOne-k * 53668) - k * 12211;
- if (m.seedOne < 0) m.seedOne += 2147483563; k = m.seedTwo % 52774;
- m.seedTwo = 40692 * (m.seedTwo - k * 52774) - k * 3791;
- if (m.seedTwo < 0) m.seedTwo += 2147483399;
- long z = m.seedOne - m.seedTwo; if (z < 1) z += 2147483562;
- return (unsigned long) z; */
-
- ======================================== MOUSE.H
- [MOUSE]
- /* described under GRAPHICS.H in [MOUSE] subsection */
-
- ======================================== NEGATIVE.H
- /* same as NEGEXP.H */
-
- ======================================== NEGEXP.H
- [NEGATIVE EXPONENTIAL RANDOM NUMBERS]
- #include <_Random.h>, which see
-
- double m; RNG r;
- NegativeExpntl z; /* declare z to hold the workings of a running series of
- negative exponential random numbers */
- /* z includes a Random, which it can be used as, and also:- */
- NegativeExpntl(x,&r) /* a new {NegativeExpntl} with mean = x, using r */
- z.mean() /* {double} mean of z */
- z.mean(x) /* mean of z = m; return {double} previous mean of z */
- z() /* {double} = (mean of z) * log(random number) */
-
- ======================================== NEW.H
- [THE C++ STORE ALLOCATION OPERATOR new]
- /* see MALLOC.H */
-
- int i,n; void* p;
- new(n,p) /* {void*} merely return p !! */
- new(n,p,i) /* {void*} realloc(p, n*i) */
- new(n) /* {void*} malloc(n) */
-
- ======================================== NORMAL.H
- [RANDOM NUMBERS BY THE NORMAL-DISTRIBUTION]
- #include <_Random.h>, which see
-
- double m,v,s; RNG r;
- Normal x; /* declare x to hold the workings of a running series of normal
- random numbers */
- /n includes a Random, which it can be used as, and also:- */
- /* n has these accessible members:-
- char haveCachedNormal; double cachedNormal;
- and these hidden members: double pMean, pVariance, pStdDev;
- (x.pStdDeV = standard deviation, it is kept = sqrt(x.Variance)) */
-
- Normal(m,v,&r) /* a new {Normal} with mean = m, variance = v, using r */
- x.mean() /* {double} mean of x */
- x.mean(m) /* mean of x = m; returns {double} previous mean of x */
- x.variance() /* {double} variance of x */
- x.variance(v) /* variance of x = v; returns {double} previous variance of x */
- x() /* {double} generate a normal random number thus:-
- double w,y,z; /* This is the "polar" method */
- if(x.haveCachedNormal == 1) {
- x.haveCachedNormal = 0; return x.cachedNormal * x.pStdDev + x.pMean; }
- else:-
- y & z = uniform random numbers between -1 and +1; w = y*y + z*z;
- repeat last line until w <= 1;
- w = sqrt(-2 * log(w) / w); haveCachedNormal = 1; y *= w; z *= w;
- cachedNormal = z; return y * x.pStdDev + x.pMean; */
-
- ======================================== OBSTACK.H
- [OBJECT STACK MACROS]
-
- #include <_obstack.h>, which I describe here.
- Obstack x; /* declare x to hold a stack of objects. The object on top of
- the stack can be appended to */
-
- /* The start of (wherever you keep your Gnu C)\INCLUDE\OBSTACK.H contains a long
- description of how Obstacks are organized */
-
- /*** These functions are inline, i.e. the body is written out in full at every
- call like with macros. Arguments of these functions must not have side-effects
- (e.g. '*p++' or 'xyz[++i]' or 'get_next_character(file)'), as they may be obeyed
- many times per call of each of these functions. ***/
-
- int i,n; char c,*s; void *p,*q;
- /* p and q are pointers to objects in the stack x */
-
- Obstack() /* as Obstack(4080,4) */
- Obstack(n) /* as Obstack(n,4) */
- n /* used as an Obstack: ditto */
- Obstack(n,i) /* a new {Obstack} with its 'chunk size' = n and its
- 'alignmentmask' = i-1 */
- x.base() /* {void*} base of stack */
- x.next_free() /* {void*} next free address on stack */
- x.alignment_mask() /* {int} */
- x.chunk_size() /* {int} */
- x.size() /* {int} x.next_free() - x.base() */
- x.room() /* {int} how much free space left in x */
- /* All appends are to the object on top of the stack */
- x.grow(p,n) /* {void} append as copy of (n bytes starting at p)
- x.grow(p,n,c) /* {void} ditto, and then append char c as terminator */
- x.grow(s) /* {void} append a copy of object s, including trailing zero */
- x.grow(c) /* {void} append char c */
- x.blank(n) /* {void} append n bytes, not set to anything in particular */
- x.finish() /* finish the object on top of the stack; return {void*} =
- address of a new empty object on top of the stack */
- x.finish(c) /* x.grow(c); {void*} x.finish(); */
- x.copy(p,n) /* x.grow(p,n); {void*} x.finish(); */
- x.copy(p,n,c) /* x.grow(p,n,c); {void*} x.finish(); */
- x.copy(s) /* x.grow(s); {void*} x.finish(); */
- x.copy(c) /* x.grow(c); {void*} x.finish(); */
- x.alloc(n) /* x.blank(n); {void*} x.finish(); */
- x.free(p) /* {void} throw away the object p */
- x.grow_fast(c) /* {void} as x.grow(c) but no stack array overflow check */
- x.blank_fast(n) /* {void} as x.blank(n) but no stack array overflow check */
- x.shrink() /* as x.shrink(1) */
- x.shrink(n) /* {void} remove the top n bytes from the object on top of the
- stack. If not >=n bytes in that object, do nothing */
- x.newchunk(n) /* {void} give x n more bytes for growing objects */
- x.contains(p) /* {boolean} if object p is in x */
- x.OK() /* {boolean} if x's internal details are OK */
-
- ======================================== OSFCN.H
- #include <std.h>, which see
- #include <time.h>, which see
- #include <sys/resource.h>, which is:-
- #include <sys/time.h>, which see
-
- #define RUSAGE_SELF 0 /* calling process */
- #define RUSAGE_CHILDREN -1 /* terminated child processes */
- int n; struct rusage r;
-
- getrusage(n,&r) /* {int} get resource usage info into struct r */
- /* n <might> mean: 0 = usage of self, -1 = usage of a 'child
- process' which has finished */
- /* I don't know what the value returned is */
- struct rusage {
- struct timeval ru_utime; /* user time used */
- struct timeval ru_stime; /* system time used */
- long ru_maxrss; /* integral max resident set size */
- long ru_ixrss; /* integral shared text memory size */
- long ru_idrss; /* integral unshared data size */
- long ru_isrss; /* integral unshared stack size */
- long ru_minflt; /* page reclaims */
- long ru_majflt; /* page faults */
- long ru_nswap; /* swaps */
- long ru_inblock; /* block input operations */
- long ru_oublock; /* block output operations */
- long ru_msgsnd; /* messages sent */
- long ru_msgrcv; /* messages received */
- long ru_nsignals; /* signals received */
- long ru_nvcsw; /* voluntary context switches */
- long ru_nivcsw; /* involuntary context switches */ };
-
- struct timeval { long tv_sec; long tv_usec; };
- struct timezone { int tz_minuteswest; int tz_dsttime; };
-
- ======================================== OSTREAM.H
- #include <_File.h>, which see
- #include <streambuf.h>, which see
- #include <filebuf.h>, which see
- #include <_Filebuf.h>, which see
-
- istream F; /* declare an input channel */ /* see ISTREAM.H */
- ostream G; /* declare an output channel */
- /* they use a streambuf as buffer */
- /* these have a hidden int member F.state or G.state, which = 0 for OK,
- 1 for end-of-file, 2 for input/output failure, 4 for bad */
- /* An ostream can be tied to an istream; on any reads on the istream,
- its tied ostream's buffer contents are sent to file */
-
- /* declared automatically:- */
- extern ostream cout; /* stdout, usually screen */
- extern ostream cerr; /* stderr, usually screen */
-
- int i,j,k; double x; char c,*s,*t; streambuf S; FILE *f;
- ostream(S) /* new {ostream} using streambuf S */
- S /* used as an {ostream}: ditto */
- ostream(i,s) /* new {ostream} with name s, buffer size i */
- ostream(s,i,j) /* new {ostream} opened with name s, io_mode i, access_mode j */
- ostream(s,t) /* new {ostream} opened with name s, old-style C fopen mode t */
- ostream(j,i) /* new {ostream} opened with file numbered j, io_mode i */
- ostream(f) /* new {ostream} opened using old-style C FILE f */
- f /* used as an {ostream}: ditto */
- ostream(j) /* new {ostream} opened with file numbered j */
- j /* used as an {ostream}: ditto */
- ostream(j,s,i) /* new {ostream} opened, file numbered j, buffer s (length i) */
- G.open(s,i,j) /* {ostream} open G with name s, io_mode i, access_mode j */
- G.open(s,t) /* {ostream} open G with name s, old-style C fopen mode t */
- G.open(j,i) /* {ostream} open G with file numbered j, io_mode i */
- G.open(f) /* new {ostream} opened using old-style C FILE f */
- G.open(s,t) /* new {ostream} opened with name s, old-style C fopen mode t */
- G.open(s,t) /* {ostream} open G with name s, old-style C fopen mode t */
- G.clear() /* as G.clear(0) */
- G.clear(i) /* {void} G.state = i; */
- G.set(i) /* {void} set in G.state bits set in i */
- G.unset(i) /* {void} clear in G.state bits set in i */
- G.rdstate() /* {int} G.state */
- G.good() /* {boolean} if G.state == 0 i.e. 'OK' */
- G.eof() /* {boolean} if G.state & 1 == 1, i.e. 'end of file' */
- G.fail() /* {boolean} if G.state & 2 == 2, i.e. 'input/output failure' */
- G.bad() /* {boolean} if G.state & 4 == 4, i.e. 'bad ostream' */
- G /* coerced to {void*}: if G.good(), a pointer to G, else 0 */
- !G /* {boolean} if G.good() */
- /* If these functions return {ostream}, that means G */
- G.failif(i) /* {ostream} if i!=0 set G.state to 'fail' */
- G.is_open() /* {boolean} G is open */
- G.readable() /* {boolean} 0 */
- G.writable() /* {boolean} G has a buffer and is good */
- G.bufptr() /* {char*} G's buffer */
- G.flush() /* {ostream} send buffer contents to file */
- G.close() /* {ostream} ditto, then close G */
- /* These functions return 0 if they failed */
- G.put(c) /* {ostream} send c to file */
- G << c /* {ostream} send c to file */
- G.put(s) /* {ostream} send string s to file */
- G.put(s,i) /* {ostream} ditto, left padded to >= n chars */
- G << s /* {ostream} send string s to file */
- G.form(s,...) /* {ostream} formatted print on file G using format s */
- g << i /* print i on file */
- /* right arg can be short, long, int, unsigned short, unsigned long,
- unsigned int, (on some implementations long long. unsigned long long,)
- float, double, char, char* */
- /* If right arg is a pointer (not char* or pointer to function),
- prints '0x' and pointer address as hexadecimal */
- G.name() /* {char*} name of G */
- G.error() /* {void} error routine */
-
- ======================================== PC.H
- [PRIMARY READ/WRITE TO/FROM PORTS]
-
- unsigned short p; /* address of port */
- unsigned char s,*S; unsigned short i,*I; unsigned long j,*J; unsigned int n;
- inportb(p) /* {unsigned char} read 1 byte from port p */
- inportw(p) /* {unsigned short} read 2 bytes from port p */
- inportl(p) /* {unsigned long} read 4 bytes from port p */
- /* The next 3 functions probably return their second argument */
- inportsb(p,S,n) /* {unsigned char} read n bytes from port p to S */
- inportsw(p,I,n) /* {unsigned short} read 2n bytes from port p to I */
- inportsl(p,J,n) /* {unsigned long} read 4n bytes from port p to J */
- outportb(p,s) /* {void} send 1 byte to port p from s */
- outportw(p,i) /* {void} send 2 bytes to port p from i */
- outportl(p,j) /* {void} send 4 bytes to port p from j */
- outportsb(p,S,n) /* {void} send n bytes to port p from S */
- outportsw(p,I,n) /* {void} send 2n bytes to port p from I */
- outportsl(p,J,n) /* {void} send 4n bytes to port p from J */
- kbhit() /* {boolean} if any keys pressed and waiting to be read */
- getkey() /* {int} raw code (not ASCII!) for keyboard hit */
- sound(i) /* {void} make a sound (i = frequency) */
-
- extern short ScreenPrimary[];
- extern short ScreenSecondary[];
- int x,y,i,j;
- ScreenRows() /* {int} byte (0-255) at hex address e0000484 */
- ScreenCols() /* {int} 2 bytes (unsigned) at hex address e000044a */
- ScreenPutChar(i,j,x,y) /* {void} put (((i & 255) << 8) + (j & 255)) at hex
- address e00b8000 + 2 * (x + y * ScreenCols()), i.e. column x,
- line y, numbered from 0; if x and y are on screen */
- ScreenSetCursor(x,y) /* {void} */
- ScreenGetCursor(&x,&y) /* {void} */
- ScreenClear() /* {void} */
-
- ======================================== PIX.H
- typedef void* Pix;
-
- ======================================== PLOTFILE.H
- [CREATING UNIX "plot" FORMAT PLOTTER FILES]
-
- /* See corresponding unix manual pages for more details */
- #include <_File.h>, <which see>
-
- PlotFile p; /* declare p as a file interface to write that sort of file */
- /* p contains and can be used as a File, and also:- */
- PlotFile(...) /* same as File(...), but creates a {PlotFile} */
- /* functions that return {PlotFile} return p unless stated otherwise */
-
- /* These functions return {PlotFile} = p */
- /* undeclared arguments are int */
- p.arc(xi,yi,x0,y0,x1,y1)
- p.box(x0,y0,x1,y1)
- p.circle(x, y, r)
- p.cont(xi, yi)
- p.dot(xi, yi, dx, n, pat) /* pat is int*, it means pat[0] to pat[n-1] */
- p.erase()
- p.label(s) /* s is char* */
- p.line(x0, y0, x1, y1)
- p.linemod(s) /* s is char* */
- p.move(xi, yi)
- p.point(xi, yi)
- p.space(x0, y0, x1, y1)
-
- ======================================== POISSON.H
- [POISSON RANDOM NUMBERS]
- #include <_Random.h>, which see
-
- double m; int i; RNG r;
- Poisson p; /* declare p to hold workings of a running series of Poisson
- random numbers */
- /* has a hidden field p.pMean == mean of P */
- Poisson(m,&r) /* a new {Poisson} with mean = m, using r */
- p.mean() /* {double} mean of p */
- p.mean(m) /* mean of p = m; return {double} previous mean of p */
- p() /* multiply random numbers until product < exp(-p.pMean);
- return {double} = (how many random numbers) - 1 */
-
- ======================================== PWD.H
- [PASSWORD HANDLING?]
- /* Sorry, this is all the info I have. All probably <missing>. */
- extern struct passwd* getpwent();
- extern struct passwd* getpwuid(int);
- extern struct passwd* getpwnam(char*);
- extern int setpwent();
- extern int endpwent();
-
- ======================================== RANDOM.H
- #include <std.h>, which see
-
- ======================================== RANDOMIN.H
- [RANDOM INTEGERS]
- #include "RNG.h", which see
-
- RandomInteger r; /*declare r to hold the workings of a running series
- of random integers */
- /* r has these hidden fields: long int p.pLow, pHigh; */
- long i,j; RNG g;
- r.RandomInteger(i,j,&g) /* a new {RandomInteger} with range i to j, using g */
- r.RandomInteger(j,&g) /* a new {RandomInteger} with range 0 to j, using g */
- r.RandomInteger(&g) /* a new {RandomInteger} with range 0 to 1, using g */
- &g /* used as a {RandomInteger}: ditto */
- r.generator() /* {RNG*} the RNG that r uses (don't write to this pointer) */
- r.generator(&g) /* r's generator = g; return {RNG*} r's previous generator */
- r.low() /* {long} lower limit of p (inclusive) */
- r.low(i) /* r's lower limit = i; return {long} previous lower limit */
- r.high() /* {long} upper limit of p (not inclusive) */
- r.high(j) /* r's upper limit = j; return {long} previous upper limit */
- /* all these limits are inclusive:- */
- r.asLong() /* {long} random integer within r's current limits */
- r() /* {long} ditto */
- r.asInt() /* {int} ditto */
- r.asLong(j) /* {long} random integer from r's lower limit to j */
- r(j) /* {long} ditto */
- r.asLong(i,j) /* {long} random integer from i to j */
- r(i,j) /* {long} ditto */
-
- ======================================== RANDOMRA.H
- [RANDOM RANGES]
-
- RandomRange r; /* declare r to hold the workings of a running series of random
- ranges */
- RandomRange(x,y,&g) /* a new {RandomRange} with lower limit = x, upper
- limit = x, using generator g */
- /* the limits are swopped if x > y */
- r.low() /* {long} lower limit of p */
- r.low(x) /* r's lower limit = x; return {long} previous lower limit */
- r.high() /* {long} upper limit of p */
- r.high(y) /* r's upper limit = y; return {long} previous upper limit */
- r() /* {double} generate a random range, but I can't find the source
- form, to find what it does. */
-
- ======================================== RATIONAL.H
- [RATIONAL NUMBER ARITHMETIC]
-
- #include <Integer.h>, which see
- Integer i,j; double x;
- Rational r,s,t; /* declare rational numbers.
- Each has hidden members Integer num,den; = numerator & denominator */
- Rational(s) /* {Rational} = copy of s */
- Rational(i) /* {Rational} with num = i, den = 1, i.e. its value = i */
- i /* used as a {Rational}: ditto */
- /* {Rational} values are always normalized after being calculated, i.e.
- kept with the denom > 0, and num & denom divided by any common factor */
- Rational(i,j) /* {Rational} with num = i, den = j, i.e. its value = i/j */
- /* ditto with both arguments long int */
- Rational(x) /* x as a {Rational}, which is always possible with floating
- point numbers held to computer accuracy */
- x /* used as a {Rational}: ditto */
- + - * / == != < > <= >= between Rationals have their usual meaning */
- add(r,s,t) /* {void} t = r + s */
- sub(r,s,t) and mul(r,s,t) and div(r,s,t) likewise.
- sign(r) /* {int} -1 or 0 or +1 according to sign of r */
- r.negate() /* {void} change sign of r */
- += -= *= /= between Rationals have their usual meaning but deliver {void}.
- r.numerator() /* {Integer} numerator of r */
- r.denominator() /* {Integer} deniminator of r */
- /* These next 2 functions may not be defined in some implementations */
- r <? s /* {Rational} minimum of s and t */
- r >? s /* {Rational} maximum of s and t */
- r.error() /* {void} error handler */
- r.invert() /* {void} swop numerator and denominator of r */
- compare(r,s) /* {int} < 0 if r<s, = 0 if r=s, >0 if r>s */
- trunc(r) /* {Integer} integer divide numerator / demininator */
- pow(r,i) /* {Rational} power *//* 2nd arg can be Integer or long int */
- abs(r) /* {Rational} absolute value of r */
- sqr(r) /* {Rational} r * r (NOT sqrt!) */
- floor(r) /* {Integer} truncate towards minus infinity */
- ceil(r) /* {Integer} truncate towards plus infinity */
- round(r) /* {Integer} nearest integer */
-
- istream F; ostream G;
- G << r /* {ostream} printed as two integers with '/' between, if
- denominator of r != 1 */
- F >> r /* {istream} read numerator; if next char (perhaps after
- space) is '/', read denominator, else take denominator as 1 */
- r.OK() /* {boolean} if internal details of r are OK */
-
- ======================================== REGEX.H
- [REGULAR EXPRESSION SEARCH]
-
- Regex r; /* declare r to hold a pattern used for special searching */
- /*** THE DECLARATION OF 'class Regex' AND THE FUNCTIONS WHICH ARE MEMBERS OF IT,
- ARE MISSING IN MY COPY OF REGEX.H ***/
-
- /* Defines a type Regex used for expression searching */
-
- Generalized searching by a string with special characters in, thus:-
- (This information may be inaccurate, as I got it by examining the source code)
- "word" here means "any sequence of alphanumeric characters in the target".
- The special characters are $^+?*.[]()\ and some 2-char sequences starting \
- In string In target
- \w letter or number (not PC accented letter!)
- \W not letter and not number
- \< must be at start of word
- \> must be at end of word
- \b must be at start or end of word
- \B must not be at start or end of word
- \` must be at start of target (?)
- \\ must be at end of target (?)
- \ and a digit If the digit is n, if there have been >=n ( ) substrings
- remembered, match the nth of those substrings;
- else match the digit literally
- \ and any other char that character literally, even if it is ( etc
- . any character except newline
- [ ] any one of the chars between the [ ];
- if - occurs between two chars inside the [ ], it means
- 'either one of those two chars or one of those between
- them in ASCII order'
- [^ ] any one character not between the [ ] ; if - occurs
- between two chars inside the [ ], it means 'not those
- two chars and none of those between them in ASCII order'
- ( ) match the characters inside the ( ) as usual;
- also remember the contents of the ( )
- chars1|chars2 a match to chars1 or a match to chars2
- newline means same as |
- chars? zero or one repetitions of the chars
- chars* zero or more repetitions of the chars
- chars+ one or more repetitions of the chars
- $ at end of string end of line in match
- $| or $) same as | or ) but must be at end of line in match
- ^ start of line in match
- (^ or |^ same as ( or | but must be at start of line in match
- (It is not clear how to search for the \ character.)
-
- If the search string is in a C "string", then of course each \ therein must be
- represented as \\, so e.g. "must be at start of word" becomes \\<
-
- ======================================== RNDINT.H
- /* same as RANDOMIN.H */
-
- ======================================== RNG.H
- [RANDOM NUMBER GENERATORS]
- /* used by several random number packages */
-
- RNG g; /* declare g to hold the workings of a running series of random
- numbers */
- g.asLong() /* {unsigned long} not defined */
- g.reset() /* {void} not defined */
- g.asFloat() /* return a random {Float} between 0 and 1 */
- g.asDouble() /* return a random {Double} between 0 and 1 */
- RNG() /* a new initialized {RNG} */
-
- ======================================== SAMPLEHI.H
- /* same as SMPLHIST.H */
-
- ======================================== SAMPLEST.H
- /* same as SMPLTEST.H */
-
- ======================================== SETJMP.H
- [STORING BLOCK LEVEL INFO FOR USER JUMPS OUT OF BLOCKS]
- typedef struct {unsigned long eax,ebx,ecx,edx,esi,edi,ebp,esp,eip;} jmp_buf[1];
- typeof(jmp_buf[1]) J; /* to store environment info in */
- int n;
- setjmp(J) /* store environment info in J; return {int} 0 */
- longjmp(J,n) /* {void} go to the setjmp(J) call where the environment info
- in J was stored; go out of the end of that call, returning n */
-
- ======================================== SFILE.H
- [STRUCTURED BINARY INPUT/OUTPUT]
- #include <_File.h>, which see
-
- int i,j,k; char *s,*t; FILE *F; void *p;
- SFile S; /* declare S to hold info to use a file as structured binary */
- /* It has a hidden member int sz = unit size */
- /* It includes and can be used as a File, and also:- */
- SFile(s,k,i,j) /* new {SFile} with filename s, io_mode i, access_mode j,
- its .sz member = k */
- SFile(s,k,t) /* ditto but with old-style C fopen() mode t */
- SFile(j,k,i) /* new {SFile} with file number j, .sz member = k, io_mode i */
- SFile(F,k) /* new {SFile) using old-style C FILE F, .sz member = k */
- S.size() /* {int} S.sz */
- S.setsize(int s) /* S.sz = i; return {int} = previous S.sz */
- S.get(p) /* read S.sz bytes into *p etseq; return {SFile} S */
- S.put(p) /* write S.sz bytes from *p etseq; return {SFile} S */
- S[i] /* set file to i*S.sz bytes from its start; return {SFile} S */
-
- ======================================== SIGNAL.H
- [SIGNALS]
-
- /* I can't find what these functions do */
- typedef void (*SignalHandler) ();
- extern SignalHandler signal(int sig, SignalHandler action);
- extern SignalHandler sigset(int sig, SignalHandler action);
- extern SignalHandler ssignal(int sig, SignalHandler action);
- extern int gsignal (int sig);
- extern int kill (int pid, int sig);
- #ifndef hpux /* Interviews folks claim that hpux doesn't like these */
- struct sigvec;
- extern int sigsetmask(int mask);
- extern int sigblock(int mask);
- extern int sigpause(int mask);
- extern int sigvec(int sig, struct sigvec* v, struct sigvec* prev);
- #endif
- #define SignalBad ((SignalHandler)-1)
- #define SignalDefault ((SignalHandler)0)
- #define SignalIgnore ((SignalHandler)1)
-
- ======================================== SMPLHIST.H
- [SAMPLE HISTOGRAMS]
-
- int i; double x,y,w; ostream G;
- /* buckets = subdivisions of the range */
- S.buckets() /* {int} = how many buckets */
- S.bucketThreshold(i) /* {double} = lower boundary of ith bucket */
- S.inBucket(i) /* {int} = how many items in bucket i (numbered from 0) */
- SampleHistogram(x,y,w) /* a new empty {SampleHistogram} with limits x to y,
- width of each bucket = w */
- SampleHistogram(x,y,-1.0) /* ditto, with 10 buckets */
- SampleHistogram(x,y) /* ditto */
- S += x /* {void} add x to the appropriate bucket */
- S.similarSamples(x) /* {int} = how many samples in same bucket as x */
- S.printBuckets(G) /* {void} print what is in each bucket */
- S.reset() /* {void} rezero everything in S */
-
- ======================================== SMPLSTAT.H
- [SAMPLE STATISTICS]
-
- char *s; int i,n; double x;
- SampleStatistic S; /* declare S to hold a sample statistic */
- /* It has these hidden fields:- int n; double x,x2,minValue,maxValue; */
-
- SampleStatistic() /* a new {SampleStatistic} whic has been reset */
- S.samples() /* {int} S.n */
- S.min() /* {double} S.minValue */
- S.max() /* {double} S.maxValue */
- S.error(s) /* {void} error message s */
- S.reset() /* {void} re-initialize everything in S */
- S += x /* {void} S.n+=1; S.x+=x; S.x2+=x*x;
- if(minValue>value) minValue=value; if(maxValue<value) maxValue=value; */
- S.mean() /* {double} = if S.n>0 then S.x/S.n else 0 */
- S.var() /* {double} = if n>1 then x2-(x*x/n)/(n-1) else 0 */
- S.stdDev() /* {double} sqrt(S.var()) (0 if n<=1 or S.var()<=0) */
- S.confidence(i) /* {double} = S.confidence(i * 0.01) */
- S.confidence(x) /* {double} = tval((1+x)/2,S,n-1) * S.stdDev() / sqrt(S.n+.0) */
- /* on some systems this function is not directly callable:- */
- tval(x,n) /* {double} = t-distribution, if p-value = x, n degrees of freedom */
-
- ======================================== STD.H
- [MISCELLANEOUS]
-
- "###" = "I can't find what this function does; its source is in assembler".
- "<missing>" = "I can't find what this function does; it may not exist on PC.".
- Some of these missing functions seem to be only for multi-user systems.
- /* "->" = "points to" */
-
- char *s,*t,*u; int i,j,k,l,m,n; unsigned I,J; unsigned long L,M; void *p,*q;
- short S; double x;
-
- _exit(i) /* {void} exit without flushing file buffers.
- send value of i to MS-DOS as 'error mode' */
- abort() /* {void} print error message; _exit(3); */
- abs(i) /* {int} absolute value of i */
- access(s, 0) /* {boolean} if file named s exists */
- access(s, 2) /* {boolean} if file named s exists and can be written to */
- access(s, 4) /* {boolean} if file named s exists and can be read from */
- access(s, 6) /* {boolean} if file named s exists and can be written & read */
- acct(s) /* {int} ### */
- alarm(I) /* {unsigned} ### */
- atof(s) /* string s read as a {double}. Illegal char ends number */
- atoi(s) /* string s read as an {int} */
- atol(s) /* string s read as a {long int} */
- bind(i, p, j) /* {int} ### */
- brk(p) /* set program's data segment to end at last byte before address
- p. {int} 0 for OK, -1 for "I can't do it". Best use sbrk() */
- bsearch(p,q,L,M,c) /* q -> sorted array of L elements of M bytes each.
- p -> a pattern in same format as one element of array p.
- c(P,Q) is some function returning {int} <0 or 0 or >0 as whether
- P should be to left of, or same as, or to right of, Q, if P & Q
- are in format of elements of array at p. bsearch returns {void*}
- -> first occurence of *q in array p (NULL if not found) */
- bcmp(p,q,j) /* {int} same as memcmp */
- bcopy(p,q,j) /* {void} same as memcpy */
- _bcopy(p,q,i) /* {void} same as bcopy, but doesn't use movsb */
- bzero(p,i) /* {void} write 0 into i bytes at p etseq */
- calloc(I, J) /* {void*} as malloc(I * J) */
- cfree(p) /* {void} as free(p) */
- chdir(s) /* change current directory to s. {int} 0 = OK, -1 = failed */
- chmod(s, 0) /* set file named s to read only. {int} 0 = OK, -1 = failed */
- chmod(s, 1) /* set file named s to write only. {int} 0 = OK, -1 = failed */
- chmod(s, 2) /* ditto, since MS-DOS can't set files write-only */
- chown(s, i, j) /* {int} ### */
- clock() /* {long} time in ticks used by this process (-1 = can't find)*/
- close(i) /* close file numbered i. {int} 0 = OK, -1 = failed */
- creat(s, L) /* if file named s exists, truncate it here, else create it.
- Then as chmod(s,L); {int} 0 = OK, -1 = failed */
- crypt(s, t) /* {char*} <missing> */
- ctermid(s) /* {char*} <missing> */
- cuserid(s) /* {char*} <missing> */
- drand48() /* {double} <missing> */
- dup(i) /* {int} ### */
- dup2(i,j) /* {int} ### */
- dysize(i) /* {int} <missing> (size of directory?? */
- ecvt(x,i,&j,&k) /* {char*} x printed as i digits in system area. After call, jth
- char is '.', kth char is sign. Next call of ecvt overwrites */
- encrypt(s, i) /* {char*} <missing> */
- erand(&S) /* {double} <missing> */
- /* 'xxx' is one or more char* args, followed by a NULL pointer arg */
- char **a; /* points to array of arguments. NULL after pointer to last */
- char **e; /* points to array of environment strings, each is in format
- 'NAME=value'. NULL after pointer to last of these strings */
- execl(s,xxx) /* {int} stop this program; call program named s with arguments
- listed in xxx. This is a "child process". The current process is
- destroyed and can't be returned to. */
- execle(s,xxx,e) /* {int} ditto, with environment strings e */
- execlp(s,xxx) /* {int} as execl(), but use environment variable PATH to find
- directory to lookin for s, as specified in COMMAND.COM */
- exect(s,&t,&u) /* {int} <missing> */
- execv(s,a) /* {int} as execl(), but the args of s are the elements of a */
- execve(s,a,e) /* {int} as execle(), but the args of s are the elements of a */
- execvp(s,a) /* {int} as execlp(), but the args of s are the elements of a */
- exit(i) /* {void} flush file buffers; close files; exit from program */
- fchmod(i,j) /* {int} print "not implemented" & return.
- (should be as chmod() but with file numbered i ?) */
- fchown(i,j,k) /* {int} as chown() but with file numbered i ? */
- fcntl(i,j,...) /* {int} <missing> */
- fcvt(x,i,&j,&k) /* {char*} as ecvt() */
- ffs(i) /* {int} <missing> */
- flock(i,j) /* {int} <missing> (lock file numbered i?) */
- fork() /* {int} <missing> */
- free(p) /* {void} release the malloc'ed area p. See MALLOC.H */
- fsync(i) /* {int} ### */
- ftok(s,i) /* {long} <missing> */
- ftruncate(i,I) /* {int} fseek(i,I,0); write(i,0,0); if file i is then closed
- at once, it is truncated there */
- gcvt(x,i,s) /* {char*} <missing> */
- getcwd(s,i) /* put current directory name in s. i = how many chars
- in s can be used. Returns {char*} = s (NULL if error) */
- getcwd(NULL,i) /* put current directory name in an area which getcwd() provides
- by malloc() and returns {char*} = its address (NULL if error) */
- getdomainname(s,i) /* {int} <missing> */
- getdtablesize() /* {int} = 50 (= how many files can be open at once ??) */
- getegid() /* {int} <missing> */
- getenv(s) /* {char*} <missing> */
- geteuid() /* {int} <missing> */
- getgid() /* {int} <missing> */
- getgroups(i,&j) /* {int} <missing> */
- gethostid() /* {long} <missing> */
- gethostname(s,i) /* {int} <missing> */
- getlogin() /* {char*} <missing> */
- getopt(i,&s,t) /* {int} <missing> */
- getpagesize() /* {int} <missing> */
- getpass(s) /* {char*} <missing> */
- getpgrp() /* {int} <missing> */
- getpid() /* {int} = 42 */
- getppid() /* {int} <missing> */
- getpriority(i,j) /* {int} <missing> */
- getpw(i,s) /* {int} <missing> */
- getuid() /* {unsigned} <missing> */
- getwd(s) /* {char*} ### */
- index(s,i) /* {char*} same as strchr */
- initstate(I,s,i) /* {char*}
- ioctl(i,j,s) /* {int} <missing> */
- isatty(i) /* {boolean} if file numbered i is console/screen/serial port */
- jrand48(&S) /* {long} <missing> */
- kill(i,j) /* {int} <missing> */
- killpg(i,j) /* {int} <missing> */
- lcong48(&S) /* {void} <missing> */
- link(s,t) /* {int} ### */
- listen(i,j) /* {int} <missing> */
- lrand48() /* {long} <missing> */
- lseek(i,I,j) /* {long} ### (look for something in file numbered i ??) */
- malloc(I) /* {void*} provide new space of I bytes, see MALLOC.H */
- malloc_usable_size(p) /* {unsigned int} <missing> */
-
- /* mem-- functions may not work OK if source and destination overlap */
- memalign(I,J) /* {void*}
- memccpy(p,q,i,j)/* copy i bytes from q etseq to p etseq; returns {void*} NULL;
- but if it meets a char == j, it copies that char & exits,
- returning {void*} -> place in array p next after that char */
- memchr(p,i,j) /* look at i chars starting at p for char == j. If found,
- returns {void*} pointer to it; else returns {void*} NULL */
- memcmp(p,q,i) /* {int} as strncmp(p,q,i), but don't stop at null chars */
- memcpy(p,q,i) /* copy i bytes from q etseq to p etseq; returns {void*} p */
- _memcpy(p,q,i) /* {void*} ditto, but don't use movsb */
- memset(p,i,j) /* set i bytes starting at p, to j; return {void*} = p */
-
- mkdir(s,i) /* {int} make directory named s. Use of i not known */
- mknod(s,i,j) /* {int} <missing> */
- mkstemp(s) /* {int} <missing> */
- mktemp(s) /* s must be 1 to 6 chars followed by 6 uppercase X's. Returns
- {char*} unique new filename with XXXXXX replaced by 2 chars,
- then '.', then 3 chars */
- mrand48() /* {long} <missing> */
- nice(i) /* {int} <missing> */
- nrand48(&S) /* {long} <missing> */
- open(s,i) /* open file named s, in mode i as in FCNTL.H . Returns {int}
- = file number (-1 if error) */
- open(s,i,j) /* ditto, for read only if j==0, for write also if j == 1 or 2*/
- pause() /* {void} <missing> */
- perror(s) /* {void} <missing> */
- pipe(&i) /* {int} <missing> */
- profil(s,i,j,k) /* {int} <missing> */
- psignal(I,s) /* {int} <missing> */
- ptrace(i,j,k,l) /* {int} <missing> */
- putenv(s) /* {int} <missing> */
- qsort(p,i,I,c) /* {void} p -> array of i elements of I bytes each.
- Sort array p according to function c, for which see bsearch() */
- rand() /* {int} <missing> (random integer 0 to 32767?) */
- random() /* {long int} <missing> (random integer 0 to pow(2,31-1)??) */
- read(i,p,I) /* on file numbered i, read I bytes to p etseq. Returns {int}
- = how many bytes actually read (-1 if error).
- If file was opened in text mode, CR LF is replaced by '\n'.
- Ctrl-Z is treated as end of file.
- (Negative value may mean 'that value + pow(2,16)) */
- readlink(s,t,i) /* {int} <missing> */
- realloc(p,I) /* {void*} see MALLOC.H */
- rename(s,t) /* rename file s as t; return {int} 0 = OK, -1 = error */
- rindex(s,i) /* {char*} same as strrchr */
- rmdir(s) /* remove directory s; return {int} 0 = OK, -1 = error */
- sbrk(i) /* add (-ve = remove) i bytes to top end of program's data area.
- Returns {void*} -> first of those new bytes */
- seed48(short*) /* {short*} <missing> (ref random numbers?) */
- send(i,s,j,k) /* {int} <missing> */
-
- setgid(i) /* {int} <missing> */
- sethostname(s,i) /* {int} <missing> */
- setkey(s) /* {int} <missing> */
- setpgrp() /* {int} <missing> */
- setpriority(i,j,k) /* {int} <missing> */
- setregid(i,j) /* {int} <missing> */
- setreuid(i,j) /* {int} <missing> */
- setstate(s) /* {char*} <missing> */
- setuid(i) /* {int} <missing> */
-
- sigblock(i) /* {int} <missing> */
- siginterrupt(i,j) /* {int} <missing> */
- sigpause(i) /* {int} <missing> */
- sigsetmask(i) /* {int} <missing> */
-
- sleep(I) /* {unsigned} wait I seconds */
- socket(i,j,k) /* {int} <missing> */
- srand(i) /* {void} <missing> */
- srand48(I) /* {void} <missing> */
- srandom(i) /* {void} <missing> */
- stime(&I) /* set system time to I seconds after midnight GMT at start of
- 1 Jan 1970; returns {int} 0 */
-
- /* String functions. Strings terminated by zero char if not earlier by
- count. Return {char*} = s unless stated otherwise. s,t,u are strings */
- strcat(s,t) /* {char*} append t to s, in space after s in store */
- strchr(s,i) /* {char*} -> first char which == i in s (NULL if not found) */
- strcmp(s,t) /* {int} <0 or 0 or >0 as s is before / same as / after t in
- character order (case sensitive) */
- strcpy(s,t) /* {char*} copy t into s
- strcspn(s,t) /* {int} = index in s of first char matching any char in t
- (strlen(s) if none found) */
- strdup(s) /* {char*} -> a new malloc'ed copy of string s */
- strlen(s) /* {int} = how many chars in s (except terminating null) */
- strncat(s,t,i) /* {char*} append to s the first i chars in t */
- strncmp(s,t,i) /* {int} as strcmp() but first i chars only */
- strncpy(s,t,i) /* {char*} j=strlen(t); overwrite first i chars in s with first
- i chars in t; if j>i append j-i nulls, else append NO nulls */
- strpbrk(s,t) /* {char*} -> first char matching any char in t
- (NULL if none found) */
- strrchr(s,i) /* {char*} -> last char in s which == i {NULL if not found) */
- strspn(s,t) /* {int} = index in s of first char not matching any char in t
- (strlen(s) if none found) */
- strtod(s,&t) /* {double} <missing> */
- strtok(s,t) /* replace by 0 any leading chars in s that match any char in t,
- and the first such char found after the first nonmatching char.
- Return {char*} -> first nonmatching char in s */
- strtok(NULL,t) /* as ditto, using s from previous call, and starting search not
- at start of s but at last matching char found before */
- strtol(s,&t,i) /* {long} <missing> */
-
- swab(p,q,i) /* {void} swop i bytes at p etseq with i bytes at q etseq */
- symlink(s,t) /* {int} <missing> */
- syscall(i,...) /* {int} <missing> */
- system(s) /* call the MSDOS command s. Return {int} 0 = OK, -1 = failed */
- system(NULL) /* {boolean} if COMMAND.COM can be found */
- tempnam(s,t) /* {char*} <missing> */
- tgetent(s,t) /* {int} <missing> */
- tgetnum(s) /* {int} <missing> */
- tgetflag(s) /* {int} <missing> */
- tgetstr(s,&t) /* {char*} <missing> */
- tgoto(s,i,j) /* {char*} <missing> */
- time(&L) /* {unsigned long}
- tmpnam(s) /* put unique temporary file name in s; return {char*} = s */
- tmpnam(NULL) /* ditto, but return it in a new malloc'ed string */
- tputs(s,i,int (*)()) /* {int} <missing> */
- truncate(s,L) /* {int} truncate file named s after L btHytes; close it */
- ttyname(i) /* {char*} <missing> ('filename' given to keyboard?) */
- ttyslot() /* {int} <missing> ('file number' given to keyboard?) */
- ualarm(I,J) /* {unsigned} <missing> */
- ulimit(i,long) /* {long} <missing> */
- umask(i) /* {int} from now on, open files as specified by i as the
- S_-- constants in SYS\TYPES.H */
- unlink(s) /* {int} <<delete file named s>> */
- usleep(I) /* {unsigned} sleep I microseconds */
- vadvise(i) /* {int} <missing> */
- valloc(I) /* {void*} as malloc() ? */
- vfork() /* {int} <missing> */
- vhangup() /* {int} <missing> */
- wait(&i) /* {int} <missing> */
- write(i,p,I) /* on file numbered i, write I bytes from p etseq. Returns {int}
- = how many bytes actually written (-1 if error).
- If file was opened in text mode, '\n' is replaced by CR LF.
- Ctrl-Z is treated as end of file.
- (Negative value may mean 'that value + pow(2,16)) */
-
- /* STD.H also declares these external globals:- */
- extern char** environ;
- extern volatile int errno; /* for system error number */
- extern char* sys_errlist[];
- extern int sys_nerr;
- extern char* optarg;
- extern int opterr;
- extern int optind;
-
- ======================================== STDARG.H
- /* declarations used in argument list processing */
-
- ======================================== STDDEF.H
- /* oddments used by input/output functions, and:- */
- #define NULL 0
-
- ======================================== STDIO.H
- [OLD-STYLE C INPUT AND OUTPUT]
-
- FILE *F; /* declare F as a pointer to a structure which holds the details
- of interface with a file */
- /* the FILE structures themselves are set up by the system as an array _iob */
-
- #define EOF (-1)
- #define NULL 0
- #define stdin (&_iob[0]) /* standard input, usually the keyboard */
- #define stdout (&_iob[1]) /* standard output, usually the screen */
- #define stderr (&_iob[2]) /* standard error output, usually the screen */
-
- long int I; int i,j,k; char c,*s,*t,*f; void* p;
- /* These 8 'functions' are macros:- */
- getc(F) /* {int} get a character from file F */
- putc(i,F) /* put a character = i to file F; return {int} the character */
- clearerr(F) /* clear F's end of file & error flags */
- getchar() /* same as getc(stdin) */
- putchar(i) /* same as putc(i,stdout) */
- feof(F) /* {boolean} if F's end of file flag is set */
- ferror(F) /* {boolean} if F's error flag is set */
- fileno(F) /* {int} F's file number */
-
- /* Hereinunder:-
- argument F = file read from or written to;
- argument t = access mode:-
- "r" = read, file must exist.
- "w" = write, file is wiped if it existed before.
- "a" = append, file is created if it doesn't exist.
- "r+" = read and write, file must exist.
- "w+" = read and write, file is wiped if it existed before.
- "a+" = read and append, file is created if it doesn't exist.
- fclose(F) /* {int} close file F */
- fdopen(i,t) /* {FILE*} = file numbered i opened in mode t */
- fflush(F) /* empty file F's buffer. If writing, write it.
- Returns {int} 0 = OK, else EOF */
- fgets(s,i,F) /* read up to & including next '\n', but not more than i chars.
- Returns {char*} = s (NULL if error) */
- fopen(s,t) /* {FILE*} = file named s opened in mode t */
- fprintf(F,f,...) /* print by format f.
- Returns {int} = how many chars printed */
- fputs(s,F) /* print string s. {int} = last char printed (EOF if error) */
- fread(p,i,j,F) /* read j items each i bytes long.
- Returns {int} = how many items read */
- freopen(s,t,F) /* close file F and reopen it as file named s in mode t. Returns
- {FILE*} F. (stdin & stdout & stderr can be diverted thus) */
- fscanf(F,f,...) /* formatted input by format f.
- Returns {int} = how many items read (EOF if hit end of file) */
- fseek(F,I,0) /* {int} go to Ith byte in file */
- fseek(F,I,1) /* {int} move I bytes forward in file */
- fseek(F,I,2) /* {int} go to Ith byte after (-ve = before) end of file */
- ftell(F) /* {long} = position in bytes from start of file.
- (in text mode, CR LF is counted as one char) */
- fwrite(p,i,j,F) /* write j items each i bytes long.
- Returns {int} = how many items read */
- gets(s) /* read into s a line from stdin, lose the final '\n'.
- Returns {char*} s (NULL if error) */
- getw(F) /* {int} = two bytes read from F */
- pclose(F) /* {int} <missing> */
- popen(s,t) /* {FILE*} <missing> */
- printf(s,...) /* formatted write to stdout. {int} as fprint() */
- puts(s) /* print string s, and a '\n', to stdout.
- Returns {int} last char written (EOF if error) */
- putw(i,F) /* write i as 2 bytes {int}
- rewind(F) /* put pointer to start of file. {int}
- scanf(f,...) /* formatted read from stdin. {int} as fscanf() */
- setbuf(F,s) /* {int} set F's buffer to be s, BUFSIZ bytes long */
- setbuf(F,NULL) /* {int} set F to be unbuffered */
- setbuffer(F,s,i) /* {int} ditto, i bytes long */
- setlinebuf(F) /* {int} <missing> */
- setvbuf(F,t,_IOFBF,i) /* {int} as setbuffer, buffer filled on reading to it */
- setvbuf(F,t,_IOLBF,i) /* {int} ditto but read to buffer stops at '\n' */
- setvbuf(F,t,_IOFBF,i) /* {int} unbuffered */
- sprintf(s,f,...) /* {int} formatted write to string */
- sscanf(s,f,...) /* {int} formatted read from string */
- tmpfile() /* open and return {FILE*} = a temporary file */
- ungetc(i,F) /* put char i into F's buffer. {int} = i (EOF if error) */
- vfprintf(F,f,p) /* {int} like fprintf but p -> list of arguments */
- vprintf(f,p ) /* {int} as vfprintf(stdout,f,p) */
- vsprintf(s,f,p) /* {int} like sprintf but p -> list of arguments */
-
- #define L_ctermid 9
- #define L_cuserid 9
- #define P_tmpdir "/tmp/"
- #define L_tmpnam (sizeof(P_tmpdir) + 15)
-
- ======================================== STDLIB.H
- #include <std.h>
- #define RAND_MAX 65536
- typedef struct {int quot; int rem; } div_t;
- typedef struct {long quot;long rem;} ldiv_t;
-
- ======================================== STRCLASS.H
- #include <_String.h>, which see.
- typedef class String string;
-
- ======================================== STREAM.H
- #include <ostream.h>, which see
- #include <istream.h>, which see
-
- ======================================== STREAMBU.H
- [A WAY OF ACCESSING FILES]
-
- int i,j; char c,*s,*n;
- streambuf b; /* open b as a table relating to a way of accessing files */
- /* It has these accessible members:-
- char* base; start of buffer
- char* pptr; put-pointer (and gptr fence)
- char* gptr; get-pointer
- char* eptr; last valid addr in buffer
- char alloc; true if it owns freestore alloced buffer */
- b.must_overflow(c) /* {boolean} if put-pointer off end of buffer */
- /* on some systems also true if c == '\n' */
- b.allocate() /* {int} if base!=0 then 0 else b.doallocate() */
- /* the next 2 functions return chars as (int)(unsigned char) :- */
- /* Some of these functions return EOF if get-pointer or put-pointer
- are out of the buffer, or if he tries to write EOF to the buffer,
- or if put-pointer >= get-pointer */
- b.sgetc() /* {int} = char that get-pointer pointing at */
- b,snextc() /* add 1 to get-pointer, then as ditto */
- b.stossc() /* if get-pointer is in range, add 1 to get-pointer */
- b.putbackc(i) /* move get-pointer back 1; put i there as char; return {int} c.
- Returns EOF if that would push get-pointer out of the buffer */
- b.sputc(i) /* put i as char at put-pointer; add 1 to put-pointer;
- return {int} c */
- b.sputc() /* b.sputc(EOF); return {int} EOF */
- streambuf() /* a new {streambuf} with all internal info = 0 */
- streambuf(s,i) /* a new {streambuf} using buffer s (length i) */
- b.doallocate() /* give b a new buffer of standard size (here 1024 bytes);
- set pointers accordingly; return {int} = size of new buffer */
- b.setbuf(s,i) /* as setbuf(s,i,0) */
- b.setbuf(s,i,j) /* set string s to be b's buffer (length i); put-pointer =
- address of buffer's jth char; return {streambuf} b */
- b.name() /* {char*} NULL */
- b.overflow() /* {int} EOF */
- b.overflow(EOF) /* {int} EOF */
- b.overflow(i) /* as p.sputc, but return EOF if i==EOF or if bad pointers */
- b.underflow() /* {int} EOF */
- b.sputs(s) /* b.sputs(each char of s in turn);
- return {int} EOF if string won't fit in buffer, else 0 */
- b.sputsn(s,i) /* ditto for first i chars of s.
- No check for zero char in s! */
- b.is_open() /* {int) 1 */
- b.close() /* do nothing; {int} 1 */
- b.error() /* abort() */
-
- ======================================== STRING.H
- #include <std.h>, which see
-
- ======================================== STRINGS.H
- #include <string.h>, which see
-
- ======================================== SWAP.H
- #define swap(a,b) ({ typeof(a) temp = (a); (a) = (b); (b) = temp; })
-
- ======================================== SYS\DIR.H
- #include <dirent.h>, which see
-
- ======================================== SYS\DIRENT.H
- /* #include'd by DIRENT.H, which see */
-
- ======================================== SYS\FCNTL.H
- #include <fcntl.h>, which see
-
- ======================================== SYS\FILE.H
- #include <fcntl.h>, which see
- #define L_SET 0
- #define L_CURR 1
- #define L_XTND 2
-
- ======================================== SYS\PARAM.H
- #define MAXPATHLEN 80
-
- ======================================== SYS\REGISTER.H
- typedef struct {unsigned ax, bx, cx, dx, si, di, bp, f; } REGISTERS;
-
- ======================================== SYS\RESOURCE.H
- /* #include'd by OSFCN.H, which see */
-
- ======================================== SYS\SIGNAL.H
- #define SIG_DFL ((void (*)(int))(-1))
- #define SIG_IGN ((void (*)(int))(-2))
- typedef enum {SIGINT, SIGKILL, SIGPIPE, SIGFPE, SIGHUP, SIGTERM, SIGSEGV,
- SIGTSTP, SIGQUIT} SIGnals;
-
- ======================================== SYS\STAT.H
- [USED BY SOME READ/WRITE FUNCTIONS]
- struct stat {
- short st_dev, st_ino;
- unsigned short st_mode;
- short st_nlink, st_uid, st_gid, st_rdev, st_align_for_word32;
- long st_size, st_atime, st_mtime, st_ctime, st_blksize; };
-
- #define S_IFMT 0xF000 /* file type mask */
- #define S_IFDIR 0x4000 /* directory */
- #define S_IFIFO 0x1000 /* FIFO special */
- #define S_IFCHR 0x2000 /* character special */
- #define S_IFBLK 0x3000 /* block special */
- #define S_IFREG 0x8000 /* or just 0x0000, regular */
- #define S_IREAD 0x0100 /* owner may read */
- #define S_IWRITE 0x0080 /* owner may write */
- #define S_IEXEC 0x0040 /* owner may execute <directory search> */
-
- int stat(const char *, struct stat *);
- int fstat(int, struct stat *);
-
- ======================================== SYS\STDC.H
- #include <sys/types.h>, which see
-
- ======================================== SYS\TIME.H
- struct timeval {long tv_sec; long tv_usec; };
- struct timezone { int tz_minuteswest; int tz_dsttime; };
-
- ======================================== SYS\TIMES.H
- struct tms {long tms_utime, tms_utime2, tms_stime, tms_stime2; };
- #define HZ 100
-
- ======================================== SYS\TYPES.H
- /* special names for some simple types, used by some library routines */
-
- ======================================== SYS\UIO.H
- struct iovec {void *iov_base; unsigned long iov_len; };
-
- ======================================== TIME.H
- [TIME]
-
- struct tm {
- int tm_sec; /* seconds after the minute [0-60] */
- int tm_min; /* minutes after the hour [0-59] */
- int tm_hour; /* hours since midnight [0-23] */
- int tm_mday; /* day of the month [1-31] */
- int tm_mon; /* months since January [0-11] */
- int tm_year; /* years since 1900 */
- int tm_wday; /* days since Sunday [0-6] */
- int tm_yday; /* days since January 1 [0-365] */
- int tm_isdst; /* Daylight Savings Time flag */
- long tm_gmtoff; /* offset from CUT in seconds */
- char *tm_zone; /* timezone abbreviation */ };
-
- int i,j; struct tm T;
- unsigned long int I,J; /* time in seconds since start of yeat 1970 */
- /* The next 2 functions return in same place, & next call overwrites,
- so take a copy at once; and they don't understand years < 1980 */
- localtime(&I) /* {struct tm *} address of I converted to struct tm */
- gmtime(&I) /* {struct tm *} ditto corrected to GMT */
- mktime(&T) /* {unsigned long} T as seconds since start of 1970 ?? */
- time(&I) /* {unsigned long} seconds since start of year 1970 */
- difftime(I,J) /* {double} J - I */
- /* The next 3 functions return in same place, & next call overwrites,
- so take at once a copy of the result */
- asctime(&T) /* {char *} T as string, e.g. "Thu Nov 26 17:02:37 1987\n" */
- ctime(&I) /* {char *} I as string, e.g. "Thu Nov 26 17:02:37 1987\n" */
- timezone(i,j) /* {char *} <missing> */
- tzset() /* {void} set time zone info from environment variable TZ */
- tzsetwall() /* {void} <missing> */
-
- ======================================== TZFILE.H
- (1) "Information about time zone files", but I can't find these files in my
- copy of Gnu C.
-
- (2) Defines these constants:-
- TM_SUNDAY 0 TM_MONDAY 1 TM_TUESDAY 2 TM_WEDNESDAY 3
- TM_THURSDAY 4 TM_FRIDAY 5 TM_SATURDAY 6
- TM_JANUARY 0 TM_FEBRUARY 1 TM_MARCH 2 TM_APRIL 3
- TM_MAY 4 TM_JUNE 5 TM_JULY 6 TM_AUGUST 7
- TM_SEPTEMBER 8 TM_OCTOBER 9 TM_NOVEMBER 10 TM_DECEMBER 11
-
- #define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0)
-
- ======================================== UNIFORM.H
- [UNIFORM RANDOM NUMBERS]
-
- #include <_Random.h>, which see
-
- double x,y; RND g;
- Uniform u; /* declare u to hold workings of a running series of uniform
- random numbers between u.pLow and u.pHigh.
- u has the hidden members double u.pLow, u.pHigh;
- u contains and can be used as a Random, and also:- */
-
- u.low() /* {double} lower limit of p */
- u.low(x) /* u's lower limit = x; return {double} previous lower limit */
- u.high() /* {double} upper limit of p */
- u.high(y) /* u's upper limit = y; return {double} previous upper limit */
- Uniform(x,y,&g) /* a new {Uniform} with range x to y, using generator g */
- u() /* a random {double} uniformly between u's limits */
-
- ======================================== UNISTD.H
- /* assorted #define'd constants re input and output */
-
- ======================================== VALUES.H
- /* How many bits per each basic type */
- /* Maximum and minimum values of arithmetic types */
- #define BITSPERBYTE 8
- #define BITS(type) (BITSPERBYTE * (int)sizeof(type))
- /* The next two seem accurate for my PC */
- #define MAXDOUBLE 1.79769313486231470e+308
- #define MINDOUBLE 4.94065645841246544e-324
- #define MAXFLOAT ((float)3.40282346638528860e+38)
- #define MINFLOAT ((float)1.40129846432481707e-45)
-
- ======================================== VARARGS.H
- #include <stdarg.h>, which see
-
- ======================================== WEIBULL.H
- ['WEIBULL' RANDOM NUMBERS]
- #include <_Random.h>, which see
-
- double x,y; RNG g;
- Weibull w; /* declare w to hold workings of a running series of that sort
- of random number */
- w has two parameters: alpha and beta */
- w contains and can be used as a Random, and also:- */
- w.alpha() /* {double} alpha of p */
- w.alpha(x) /* w's alpha = x; return {double} previous alpha */
- w.beta() /* {double} beta of p */
- w.beta(y) /* w's beta = y; return {double} previous beta */
- Weibull(x,y,&g) /* new {Weibull} with alpha = x, beta = y, using generator g */
- /* See Simulation, Modelling & Analysis by Law & Kelton, pp259 */
- /* This is the 'polar' method */
- w() /* a {double} expression which seems to simplify to
- pow(beta, (1/(1-(random number)) + 1/alpha)) */
- /* '1-random' to stop 1/0 from happening */
-
- ======================================== _FILE.H
- /* #include'd by FILE.H, which see */
-
- ======================================== _FILEBUF.H
- [A WAY TO ACCESS FILES]
- #include <_File.h>, which see
- #include <streambuf.h>, which see
-
- /* Notice the case difference between Filebuf and filebuf */
- char *s,*t; int i,j; FILE *f;
- Filebuf F; /* declare a file access buffer */
- /* F includes and can be used as a streambuf, and also:- */
- Filebuf() /* new {Filebuf} with everything null */
- Filebuf(s,i,j) /* new {Filebuf} opened with name s, io_mode i, access_mode j */
- Filebuf(s,t) /* ditto, but t = opening mode as in old C fopen() */
- Filebuf(i,j) /* new {Filebuf} opened on file numbered i, io_mode j */
- Filebuf(f) /* new {Filebuf) connected with old-style C FILE *f */
- F.open(s,i,j) /* open F with name n, io_mode i, access_mode j (see FMODES.H).
- F.open(s,t) /* ditto, but t = opening mode as in old C fopen() */
- F.open(s,i) /* ditto, but (?) i= 0 read only, 1 write only, 2 append only */
- F.open(i,j) /* open file numbered i, with io_mode j */
- F.open(f) /* connect F with old-style C FILE *f */
- F.fp /* {File*} pointer to the File that F uses */
- F.init_streambuf_ptrs() /* {void} initialize F's internal pointers */
- F.is_open() /* {boolean} F is open */
- /* all uses of F.open(...) return {streambuf*} = pointer to F's
- component streambuf */
- F.close() /* close F; {boolean} = if F was open */
- F.underflow() /* {int}, diverts F's contained streambuf's "attempt to read
- from empty buffer" routine to refill the buffer from file.
- Returns EOF if end of file. Do not call this function yourself. */
- F.overflow() /* {int}, diverts F's contained streambuf's "attempt to write
- to full buffer" routine to send buffer contents to file.
- Do not call this function yourself. */
- F.name() /* {char*} F's name */
- F.setbuf(s,i,0) /* set F's buffer to char* s, its length = i */
-
- ======================================== _OBSTACK.H
- /* #included by source form of functions called by OBSTACK.H, which see */
-
- ======================================== _RANDOM.H
- #include "RNG.h", which see
-
- RNG g;
- Random r; /* declare r to hold workings of a running series of uniform
- random numbers between 0 and 1 */
- /* r includes and can be used as a RNG, and also:- */
- Random(&g) /* a new {Random} using generator g */
- r.generator() /* {RNG*} a pointer to the RNG that r uses */
- r.generator(&g) /* set r to use generator g;
- return {RNG*} a pointer to r's previous generator */
- r() /* {double} random number between 0 and 1 */
-
- ======================================== _RANDOMI.H
- /* Seems to be same as RANDOMRA.H,
- except that it has RandomInterval everywhere instead of RandomRange */
-
- ======================================== _REGEX.H
- /* constants for use when using REGEX.H, which see */
-
- ======================================== _STRING.H
- [SPECIAL STRING HANDLING]
- #include <_Regex.h>, which see
-
- /* <not> the same as an ordinary string which is a char* pointing to
- characters terminated by a null character! */
- String S,T,U,V; /* declare S etc to hold strings */
- SubString X,Y,Z; /* declare X etc to hold info pointing to a substring
- of a String */
- Regex R; /* a Regex type expression, see REGEX.H */
- char c,*s,*t; int i,n; istream F; ostream G;
-
- W /* this arg can be String or SubString or char* or char* */
-
- X.contains(W) /* {boolean} if W is in X */
- X.contains(R) /* {boolean} if R is in X */
- X.matches(R) /* {boolean} if R matches all of X */
- X.length() /* {int} length of text of X */
- X.empty() /* {boolean} if X has zero amount of text */
- X.OK() /* {boolean} if X's internal details are OK */
-
- String() /* a new {String} with null text */
- String(s,i) /* a new {String} containing the first i characters of X */
- /* SubString & char* & char convert automatically to String when necessary,
- e.g. when cast by (String) or String(..), or on right of = */
- = /* with a String as left argument: copies, and returns {void} */
- /* right arg of next 2 can also be SubString or char* or char */
- S += T /* {void} concatenate T to end of S.
- S.prepend(T) /* {void} concatenate T to beginning of S.
- /* In cat(), S and T and U can also be SubString */
- /* In cat(), S and T can also be char* */
- cat(T,U,V) /* {void} set V to T and U concatenated in that order */
- cat(S,T,U,V) /* {void} set V to S and T and U concatenated in that order */
- /* in the next 7 functions, W can also be a Regex */
- S.index(W) /* {int} first index in S of text of W (-1 for 'not found') */
- S.index(W,i) /* {int} ditto, but ignore first i chars of S */
- S.contains(W) /* {boolean} if text of W occurs anywhere in S */
- S.contains(W,i) /* {boolean} ditto, but ignore first i chars of S */
- S.matches(W) /* {boolean} if text of W occurs at start of S */
- S.matches(W,i) /* {boolean} if text of W occurs i chars after start of S */
- S.freq(W) /* {int} how many occurences of W in S */
-
- G << S /* {ostream} print text of S */
- G << X /* {ostream} print text of X */
- F >> S /* {istream} read S, same way as char*. Error if zero length */
- readline(F,S) /* read text into S, up to '\n', discard the '\n',
- return {int} = length of text of S */
- readline(F,S,c) /* ditto, but terminate at char c instead of '\n' */
- readline(F,S,c,i) /* ditto, if i != 0 */
- readline(F,S,c,0) /* ditto, but append the terminator to the text of S */
- S.error(s) /* {void} error exit with message s */
- S.length() /* {int} length of text in S */
- S.empty() /* {boolean} if no text in S */
- S.chars() /* {char*) text of S */
- S.allocation() /* {int} how many bytes allocated to S */
- S.alloc(i) /* {void} allocate i bytes to S? <Don't call this yourself!> */
- reverse(S) /* {String} = S reversed */
- upcase(S) /* {String} = S uppercased */
- downcase(S) /* {String} = S lowercased */
- capitalize(S) /* {String} = S with all words initial-capitalized */
- /* In the next two, S can also be a SubString */
- S + W /* {String} = S and W concatenated */
- s + S /* {String} = s and S concatenated */
- S.prepend(W) /* {void} concatenate W to start of S */
- S.reverse() /* {void) reverse S */
- S.upcase() /* {void) uppercase S */
- S.downcase() /* {void) lowercase S */
- S.capitalize() /* {void) initial-capitalize all words in S */
-
- S[i] /* {char} i-th character in S (counting from 0) */
- S.elem(i) /* {char} ditto */
- S.firstchar() /* {char} first char in S */
- S.lastchar() /* {char} last char in S */
-
- S /* used as {char*}: text of S */
- S.chars() /* {char*} text of S */
- == != < > <= >= /* {boolean} string compare, with left arg String or Substring,
- and right arg String or Substring or char* */
- compare(S,T) /* {int} compare, returns -1 or 0 or +1 like strcmp();
- /* types of arguments as for == etc */
- fcompare(S,T) /* {int} compare, ignoring case */
-
- /* SubString extraction. You can't take a SubString of a const String, else you
- would be able to indirectly modify the String through the SubString */
-
- S.at(i,j) /* {SubString} = j chars starting at i-th char of S */
- S(i,j) /* {SubString} ditto */
- S.before(i) /* {SubString} the 0th to (i-1)th chars of S */
- S.through(i) /* {SubString} the 0th to i-th chars of S */
- S.after(i) /* {SubString} the i-th to last chars of S */
- S.from(i) /* {SubString} the (i+1)th to last chars of S */
- /* In the next 5 functions: i taken as 0 if second arg is omitted;
- the result is an empty substring if W is not found in S;
- W can be a Regex */
- S.at(W,i) /* {SubString} the part of S that matches W */
- S.before(W,i) /* {SubString} the part of S before the part that matches W */
- S.through(W,i) /* {SubString} ditto plus the part of S that matches W */
- S.after(W,i) /* {SubString} the part of S after the part that matches W */
- S.from(W,i) /* {SubString} the part of S that matches S, plus ditto */
- X.length() /* {int} length of text in X */
- X.empty() /* {boolean} if no text in X */
- X.chars() /* {char*) text of X (and of the rest of the string that X is a
- substring of) */
-
- S.del(i,j) /* {void} delete j chars starting at i-th char of S */
- /* in the next 3 uses, W can also be a Regex */
- S.del(W) /* {void} delete first occurence of W in S */
- S.del(W,i) /* {void} ditto, but start looking at i-th char of S */
- S.gsub(W,U) /* {int} replace all occurences of W by U */
- /* in gsub, W can't be a char */
- S.gsub(s,t) /* ditto */
-
- String A[]; /* array of Strings */
- split(S,A,n,T) /* take copy of S; in that copy wipe out all parts that match T;
- copy the remaining detached parts into A[0] A[1] etseq, but not
- more than n parts; return {int} = how many parts found */
- split(S,A,n,R) /* ditto */
- join(A,n,S) /* {String} = the strings A[0] to A[n-1] concatenated in that
- order with a copy of S put between at each join */
- common_prefix(S,T) /* {String} whatever consecutive chars are the same
- starting at the beginning of S and of T */
- common_prefix(S,T,i) /* ditto, ignoring the first i chars in S and T */
- common_suffix(S,T) /* {String} whatever consecutive chars are the same
- ending at the ends of S and of T */
- common_suffix(S,T,i) /* ditto, ignoring the last (1-i) chars in S and T */
-
- ======================================== [END OF FILE]
-
-
-