v16i004: mbase - C database engine, Part03/03
Kent Landfield
kent at sparky.IMD.Sterling.COM
Thu Jan 3 17:50:40 AEST 1991
Submitted-by: rpj at pygmy.rice.edu (Richard Parvin Jernigan)
Posting-number: Volume 16, Issue 4
Archive-name: mbase/part03
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: mbase.h stdinc.h sample.s
# Wrapped by rpj at pygmy on Mon Dec 17 19:54:47 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'mbase.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'mbase.h'\"
else
echo shar: Extracting \"'mbase.h'\" \(7063 characters\)
sed "s/^X//" >'mbase.h' <<'END_OF_FILE'
X/* ******************************************************************** *
X *** unix compatible ***
X * MetalBase 3.0.................................................... *
X * *
X * Multi-user simultaneous use of relations (On multi-user hardware) *
X * Users may have many relations open at once, even the same one! *
X * Unlimited length records (Really! Just redefine BUF_LEN!) *
X * Up to 20 indicies per relation, 5 fields max per composite index *
X * Up to 4.2 billion records per relation *
X * Bizzare intermittent bugs, just like the expensive programs *
X * And, unless they're weird, your kids will eat it *
X * /\ *
X * Written starting in August 1989, by Huan-Ti rj / \ *
X * / \ *
X * "Ye hath mushrooms for $1.99 a pound. Ye art \ / *
X * truly a Calvinist." \ / tp *
X * -- II Calvin 7:1 \/ *
X *** ***
X * ******************************************************************** */
X
X#include "stdinc.h"
X
X#ifndef BUF_LEN /* Maximum possible needed buffer (Length = 1 + */
X#define BUF_LEN 256 /* record_length + 13*number_of_indicies */
X#endif /* If needed, redefine before #including */
X
X#ifndef MAX_REL /* Maximum possible # of relations open at once, */
X#define MAX_REL 5 /* for this user. DOES NOT CHANGE STDIO'S # of */
X#endif /* FILES OPEN AT ONCE (#_of_rel + 3) */
X
X#ifndef MAX_FLDS /* Maximum number of fields in any given */
X#define MAX_FLDS 30 /* relation. If you need more than 30, redefine */
X#endif /* before #including <mbase.h> */
X
X#define OKAY 0 /* Generic no-problem number. Thank IBM. */
X#define NOT_ENOUGH_ROOM -1000 /* Too many files are open at once */
X#define CANNOT_OPEN_REL -1001 /* Can't open FILE.REL */
X#define RELATION_HUNG -1002 /* User left during add/del/upd. See dox */
X#define CANNOT_READ_REL -1003 /* FILE.REL is protected (Need rw access) */
X#define RELATION_BUSY -1004 /* 120 users on one relation=max (Hah!) */
X#define RELATION_LOCKED -1005 /* Someone has locked the relation */
X#define LOCK_DENIED -1006 /* Can't lock with other users. See dox */
X#define ILLEGAL_DUPLICATE -1007 /* Record would violate a nodups index */
X#define CORRUPT_INDEX -1008 /* Means you're fucked. Probly not used */
X#define INVALID_FILE_CODE -1009 /* You've passed an unreal relation numb */
X#define NOT_OPEN -1010 /* You've tried to work with a closed rel */
X#define RCD_INVALID -1011 /* Bad-size or # of flds given to add/upd */
X#define INVALID_COMP -1012 /* SELECT's record for comparison is bad */
X#define UNKNOWN_ACTION -1013 /* You'll probly never get this one. */
X#define NOT_FOUND -1014 /* Generic. Can't find the record U want */
X#define NO_CURRENT_RECORD -1015 /* Must select a record before del/upd */
X#define INVALID_INDEX -1016 /* A bad index # has been sent to mb_sel */
X
X#define CURR 1 /* Re-read the current record (4 mb_sel) */
X#define EQUL 2 /* Get rec that matches exactly (see dox) */
X#define FRST 3 /* Get the first record, sequentially */
X#define GTEQ 4 /* If not exact, get the one right after */
X#define GTHN 5 /* Like GTEQ, but won't accept exact one */
X#define LAST 6 /* Get the last record, sequentially */
X#define LTEQ 7 /* If not exact, get the one right before */
X#define LTHN 8 /* Like LTEQ, but won't accept exact one */
X#define NEXT 9 /* Get the next record, sequentially */
X#define PREV 10 /* Get the previous record, sequentially */
X
X#define CURRENT CURR /* These are included to reduce errors */
X#define EQUAL EQUL /* due to stupid humans who insist on */
X#define FIRST FRST /* using long words instead of short ones */
X#define GTHAN GTHN /* */
X#define LTHAN LTHN /* Gee, I'm considerate. */
X#define PREVIOUS PREV /* */
X
X#define ZEROES "\001\001\001\001\001\001\001\001\001\001\001\001."
X
X/****************************************************************************/
X/* */
X/* A reminder of the single rule that applies to EVERYTHING in this file: */
X/* */
X/* If you don't understand it, DON'T SCREW WITH IT. */
X/* */
X/* I'd like to emphasize that this rule is _most_important_ in viewing the */
X/* follow section of definitions. If you wanna change the internal */
X/* structure of the relations, and think you can (successfully, that is), */
X/* go right ahead. And send me a copy of the "better" MetalBase when you */
X/* think you're finished... I'd like to see it. :-) */
X/* */
X/****************************************************************************/
X
X#define _t_top(f,i) 4 + 4*i
X#define _idxs(f) 13*(_list[f].num_idx)
X#define _num_recs(f) 5 + 4*(_list[f].num_idx)
X
X#define _block(f) 11+(4*_list[f].num_idx)
X#define _base(f,r) _block(f)+_list[f].relbase+(r-1)*((13*_list[f].num_idx)+\
X 2+(_list[f].rec_len))
X#define _l_ptr(f,i,r) _base (f, r) + 13*i
X#define _r_ptr(f,i,r) _l_ptr (f, i, r) + 4
X#define _b_ptr(f,i,r) _r_ptr (f, i, r) + 4
X#define _rec(f,r) _base (f, r) + (13*_list[f].num_idx) + 1
X
X#define _len(f) 2 + _idxs (f) + _list[f].rec_len
X
X/* Whew! */
X
Xchar buffer [BUF_LEN];
X
Xint _Started = -1;
X
X#define mb_key(a,b,c) _skey(a,b-1,c)
X
Xstruct
X{ long int pos, relbase;
X int relcode;
X int num_idx, rec_len;
X
X int idx_dups [20];
X int idx_just [MAX_FLDS];
X int idx_num [20][6];
X int idx_start [20][6];
X int idx_stop [20][5];
X
X char filename [80]; } _list [MAX_REL];
X
END_OF_FILE
if test 7063 -ne `wc -c <'mbase.h'`; then
echo shar: \"'mbase.h'\" unpacked with wrong size!
fi
chmod +x 'mbase.h'
# end of 'mbase.h'
fi
if test -f 'stdinc.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'stdinc.h'\"
else
echo shar: Extracting \"'stdinc.h'\" \(588 characters\)
sed "s/^X//" >'stdinc.h' <<'END_OF_FILE'
X#ifndef STDINC_H
X#define STDINC_H
X
X#include <stdio.h>
X#include <fcntl.h>
X
X#ifndef AMIGA
X#define UNIX
X#define CLS "\033[2J\033[1;1H" /* ansi std */
X#else
X#define CLS "\014" /* amiga std */
X#endif
X
X#define ANSI "\033["
X#define NORM "\033[0m"
X#define BOLD "\033[1m"
X#define SUBD "\033[2m"
X#define ITAL "\033[3m"
X#define UNDR "\033[4m"
X#define INVR "\033[7m"
X
X#define sendchar(x) putchar ((char)(x))
X#define fix(x) ((x) < 0) ? ((x)+256) : (x)
X#define until(x) while (!(x))
X
X#ifndef MAX_RPT
X#define MAX_RPT 240
X#endif
X
X#ifndef MAX_CUT
X#define MAX_CUT 80
X#endif
X
X#endif
X
END_OF_FILE
if test 588 -ne `wc -c <'stdinc.h'`; then
echo shar: \"'stdinc.h'\" unpacked with wrong size!
fi
chmod +x 'stdinc.h'
# end of 'stdinc.h'
fi
if test -f 'sample.s' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'sample.s'\"
else
echo shar: Extracting \"'sample.s'\" \(243 characters\)
sed "s/^X//" >'sample.s' <<'END_OF_FILE'
Xrelation sample
X
Xfield question length 2 right ; Two chars is enough for 100 questions. ;
Xfield noun length 20
Xfield goodbad length 1
X
Xindex on noun
Xindex on question|goodbad with duplicates
Xindex on question with duplicates
X
Xend
X
END_OF_FILE
if test 243 -ne `wc -c <'sample.s'`; then
echo shar: \"'sample.s'\" unpacked with wrong size!
fi
chmod +x 'sample.s'
# end of 'sample.s'
fi
echo shar: End of shell archive.
exit 0
--
/ (_________ The man with the hammer __________) \ "Lobbest-thou thy Holy
( ______ _______ ) Hand-Grenade of Antioch
) ( Richid rpj at owlnet.rice.edu ) ( towards thy foe..."
'---` '---` --Monty Python, HG.
exit 0 # Just in case...
--
Kent Landfield INTERNET: kent at sparky.IMD.Sterling.COM
Sterling Software, IMD UUCP: uunet!sparky!kent
Phone: (402) 291-8300 FAX: (402) 291-4362
Please send comp.sources.misc-related mail to kent at uunet.uu.net.
More information about the Comp.sources.misc
mailing list