home *** CD-ROM | disk | FTP | other *** search
- From: zeppelin@login.dknet.dk (Thomas B. Pedersen)
- Newsgroups: comp.sources.misc
- Subject: v44i061: typhoon - Typhoon Relational Database Management System, Part05/09
- Date: 17 Sep 1994 21:45:38 -0500
- Organization: Sterling Software
- Sender: kent@sparky.sterling.com
- Approved: kent@sparky.sterling.com
- Message-ID: <35g9ki$oi9@sparky.sterling.com>
- X-Md4-Signature: d73d96ed61a73ba445edf3b092f7997a
-
- Submitted-by: zeppelin@login.dknet.dk (Thomas B. Pedersen)
- Posting-number: Volume 44, Issue 61
- Archive-name: typhoon/part05
- Environment: SCO UNIX, Tandem NonStop UNIX, Sun Solaris, AIX, Linux, OS/2
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # Contents: typhoon/src/ty_dbd.h typhoon/src/ty_prot.h
- # typhoon/src/ty_type.h typhoon/src/util/dbdview.c
- # typhoon/src/util/fixlog.c typhoon/src/util/imp.y typhoon/src/vlr.c
- # Wrapped by kent@sparky on Sat Sep 17 21:38:17 1994
- PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 5 (of 9)."'
- if test -f 'typhoon/src/ty_dbd.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'typhoon/src/ty_dbd.h'\"
- else
- echo shar: Extracting \"'typhoon/src/ty_dbd.h'\" \(8076 characters\)
- sed "s/^X//" >'typhoon/src/ty_dbd.h' <<'END_OF_FILE'
- X/*----------------------------------------------------------------------------
- X * File : ty_dbd.h
- X * Library : typhoon
- X * OS : UNIX, OS/2, DOS
- X * Author : Thomas B. Pedersen
- X *
- X * Copyright (c) 1994 Thomas B. Pedersen. All rights reserved.
- X *
- X * Permission is hereby granted, without written agreement and without
- X * license or royalty fees, to use, copy, modify, and distribute this
- X * software and its documentation for any purpose, provided that the above
- X * copyright notice and the following two paragraphs appear (1) in all
- X * source copies of this software and (2) in accompanying documentation
- X * wherever the programatic interface of this software, or any derivative
- X * of it, is described.
- X *
- X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
- X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
- X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN
- X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- X *
- X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
- X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- X * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
- X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- X *
- X * Description:
- X * Contains the definitions for the dbd-file.
- X *
- X * $Id: ty_dbd.h,v 1.1 1994/09/13 21:28:33 tbp Exp $
- X *
- X * $Log: ty_dbd.h,v $
- X * Revision 1.1 1994/09/13 21:28:33 tbp
- X * Added to repository.
- X *
- X *
- X *--------------------------------------------------------------------------*/
- X
- X/*-------------------------------- Constants -------------------------------*/
- X#define DBD_VERSION "Typhoon 2.02"
- X#define DBDVERSION_LEN 20 /* Version name of dbd-file */
- X#define DBNAME_LEN 8 /* Maximum database name length */
- X#define IDENT_LEN 32 /* Identifier length */
- X#define FILENAME_LEN 12 /* OS dependent file name length */
- X#define KEYSIZE_MAX 255 /* Maximum size of a key */
- X#define RECSIZE_MAX 64000 /* Maximum size of a record */
- X#define RECKEYS_MAX 32 /* Maximum number of keys per record */
- X#define REC_FACTOR 1000L /* rec 1 is 1000, rec 2 is 2000 etc. */
- X#define SORTTABLE_SIZE 256 /* Number of entries in sort table */
- X
- X/*------------------------------- Field types ------------------------------*/
- X#define FT_CHAR 0x01 /* The first three bits are for type */
- X#define FT_CHARSTR 0x02 /* char string */
- X#define FT_SHORT 0x03 /* short */
- X#define FT_INT 0x04 /* int */
- X#define FT_LONG 0x05 /* long */
- X#define FT_FLOAT 0x06 /* float */
- X#define FT_DOUBLE 0x07 /* double */
- X#define FT_LDOUBLE 0x08 /* long double (not used) */
- X#define FT_STRUCT 0x09 /* The type is a structure */
- X#define FT_UNSIGNED 0x10 /* Bit 4 is unsigned bit */
- X#define FT_KEY 0x20 /* Field is a key field */
- X#define FT_UNIQUE 0x40 /* Field is a unique key field */
- X#define FT_VARIABLE 0x80 /* Field has variable length (only 1-arrays)*/
- X
- X#define FT_BASIC 0x0f /* Bits occupied by integral types */
- X#define FT_GETBASIC(f) ((f)& FT_BASIC) /* Extracts the integral type */
- X#define FT_GETSIGNEDBASIC(f) ((f) & (FT_BASIC|FT_UNSIGNED))
- X
- X/*-------------------------------- Key types -------------------------------*/
- X#define KT_PRIMARY 0x01 /* Primary key (preceedes alternate in key[]*/
- X#define KT_ALTERNATE 0x02 /* Alternate key (preceedes foreign in key[]*/
- X#define KT_FOREIGN 0x03 /* Foreign key */
- X#define KT_CASCADE 0x08 /* Used with KT_FOREIGN */
- X#define KT_RESTRICT 0x10 /* Used with KT_FOREIGN */
- X#define KT_OPTIONAL 0x20 /* Used with KT_FOREIGN and KT_ALTERNATE */
- X#define KT_UNIQUE FT_UNIQUE /* Must be the same bit as FT_UNIQUE */
- X
- X#define KT_BASIC 0x03 /* The bits occupied by basic types */
- X#define KT_GETBASIC(k) ((k)&KT_BASIC) /* Extracts the type of the key */
- X
- X
- X#define KEY_ISFOREIGN(key) (KT_GETBASIC(key->type) == KT_FOREIGN)
- X#define KEY_ISALTERNATE(key) (KT_GETBASIC(key->type) == KT_ALTERNATE)
- X#define KEY_ISOPTIONAL(key) (key->type & KT_OPTIONAL)
- X
- X
- X#define RECID_TO_INTERN(id) ((id)/REC_FACTOR-1)
- X#define INTERN_TO_RECID(id) (((id)+1)*REC_FACTOR)
- X
- X
- Xtypedef unsigned long Id; /* Identifies an element in the dbd file */
- X
- Xtypedef struct {
- X uchar version[DBDVERSION_LEN]; /* Version of dbd-file */
- X ushort files; /* Number of files in database */
- X ushort keys; /* Number of key definitions */
- X ushort keyfields; /* Number of key fields */
- X ushort records; /* Number of records in database */
- X ushort fields; /* Number of fields in database */
- X ushort structdefs; /* Number of structdefs in database */
- X uchar sorttable[SORTTABLE_SIZE];
- X char alignment; /* Structure alignment */
- X char spare[19]; /* Not used */
- X} Header;
- X
- Xtypedef struct {
- X Id fileid; /* File id */
- X ushort entry; /* Entry in field[] or record[] */
- X ushort line; /* The line where it was defined */
- X char type; /* 'd'=data, 'k'=key, 'r'=ref */
- X char record[IDENT_LEN+1];/* Record name */
- X char key[IDENT_LEN+1]; /* Key name. Only applicable if type is 'k' */
- X} Contains;
- X
- X
- Xtypedef struct {
- X Id id; /* Record/Key id */
- X ushort pagesize; /* Page size */
- X char type; /* 'd'=data, 'v'=vlr, 'k'=key, 'r'=ref file */
- X char name[FILENAME_LEN+1];/* Name of file */
- X char spare[16];
- X} File;
- X
- Xtypedef struct {
- X Id recid; /* The record it is a member of */
- X Id keyid; /* a) Key ID if field is a key */
- X /* b) If the field is of variable length */
- X /* keyid denotes the size field (since a */
- X /* variable length field cannot be a key)*/
- X /* field.type & FT_VARIABLE */
- X Id structid; /* ID of struct if type is FT_STRUCT */
- X ushort offset; /* Byte offset in record */
- X ushort size; /* Size of field */
- X ushort elemsize; /* Size of each element */
- X ushort type; /* Field type. See FT_.. constants */
- X uchar nesting; /* Structure nesting. 0=first level */
- X uchar spare2[4];
- X char name[IDENT_LEN+1]; /* Field name */
- X} Field;
- X
- Xtypedef struct {
- X Id fileid;
- X Id first_keyfield; /* Index of KeyField */
- X Id parent; /* Only applicable if type = KT_FOREIGN */
- X ushort fields; /* Number of fields in compound key */
- X ushort size; /* Total key size */
- X ushort null_indicator; /* ID of null indicator field of FT_OPTIONAL*/
- X uchar spare[14];
- X uchar type; /* See KT_... flags */
- X char name[IDENT_LEN+1]; /* Name of key */
- X} Key;
- X
- Xtypedef struct {
- X Id field; /* Field id */
- X ushort offset; /* Offset in compound key */
- X short asc; /* 1=ascending, '0'=descending */
- X uchar spare[4];
- X} KeyField;
- X
- Xtypedef struct {
- X Id fileid; /* Id of file record is contained in */
- X Id first_field; /* Id of first field */
- X Id first_key; /* Id of first key */
- X Id first_foreign; /* Id of first foreign key (-1 = no foreign)*/
- X Id ref_file; /* Id of reference file (-1 = no ref file) */
- X Id structid; /* Id of structure defining record */
- X ushort dependents; /* Number of dependent tables */
- X ushort fields; /* Number of fields */
- X ushort keys; /* Number of keys */
- X ushort size; /* Size of record */
- X ushort preamble; /* Number of bytes used preamble information*/
- X uchar aux; /* Not used by Typhoon */
- X uchar spare[15];
- X char is_vlr; /* Is record of variable length? */
- X char name[IDENT_LEN+1];
- X} Record;
- X
- Xtypedef struct {
- X Id first_member; /* First struct member (Field[]) */
- X Id members; /* First struct member (Field[]) */
- X Id control_field; /* If is_union this is the control field */
- X ushort size; /* Struct size */
- X char is_union; /* Is the structure a union? */
- X char name[IDENT_LEN+1]; /* Structure name */
- X} Structdef;
- X
- X/* end-of-file */
- END_OF_FILE
- if test 8076 -ne `wc -c <'typhoon/src/ty_dbd.h'`; then
- echo shar: \"'typhoon/src/ty_dbd.h'\" unpacked with wrong size!
- fi
- # end of 'typhoon/src/ty_dbd.h'
- fi
- if test -f 'typhoon/src/ty_prot.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'typhoon/src/ty_prot.h'\"
- else
- echo shar: Extracting \"'typhoon/src/ty_prot.h'\" \(8130 characters\)
- sed "s/^X//" >'typhoon/src/ty_prot.h' <<'END_OF_FILE'
- X/*----------------------------------------------------------------------------
- X * File : ty_prot.h
- X * Library : typhoon
- X * OS : UNIX, OS/2, DOS
- X * Author : Thomas B. Pedersen
- X *
- X * Copyright (c) 1994 Thomas B. Pedersen. All rights reserved.
- X *
- X * Permission is hereby granted, without written agreement and without
- X * license or royalty fees, to use, copy, modify, and distribute this
- X * software and its documentation for any purpose, provided that the above
- X * copyright notice and the following two paragraphs appear (1) in all
- X * source copies of this software and (2) in accompanying documentation
- X * wherever the programatic interface of this software, or any derivative
- X * of it, is described.
- X *
- X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
- X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
- X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN
- X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- X *
- X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
- X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- X * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
- X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- X *
- X * Description:
- X * Contains function prototypes.
- X *
- X * $Id: ty_prot.h,v 1.1 1994/09/13 21:28:37 tbp Exp $
- X *
- X * $Log: ty_prot.h,v $
- X * Revision 1.1 1994/09/13 21:28:37 tbp
- X * Added to repository.
- X *
- X *
- X *--------------------------------------------------------------------------*/
- X
- X/*-------------------------------- Constants -------------------------------*/
- X#define UNCOMPRESS 0 /* Command to compress_vlr() */
- X#define COMPRESS 1 /* Command to compress_vlr() */
- X
- X/*------------------------------- ty_auxfn.c -------------------------------*/
- Xint aux_getkey PRM( (Id, Key **); )
- Xint report_err PRM( (int); )
- Xvoid set_subcode PRM( (Key *); )
- Xint set_recfld PRM( (Id, Record **, Field **); )
- Xvoid *set_keyptr PRM( (Key *, void *); )
- Xint keyfind PRM( (Key *, void *, ulong *); )
- Xint keyadd PRM( (Key *, void *, ulong); )
- Xint keydel PRM( (Key *, void *, ulong); )
- Xint reckeycmp PRM( (Key *, void *, void *); )
- Xint compress_vlr PRM( (int, Record *, void *, void *, unsigned *);)
- Xint null_indicator PRM( (Key *, void *); )
- Xint update_recbuf PRM( (void); )
- X
- X
- X/*------------------------------- ty_refin.c -------------------------------*/
- Xvoid update_foreign_keys PRM( (Record *, int); )
- Xint check_foreign_keys PRM( (Record *, void *, int); )
- Xvoid delete_foreign_keys PRM( (Record *); )
- Xint check_dependent_tables PRM( (Record *, void *, int); )
- X
- X
- X/*--------------------------------- ty_io.c --------------------------------*/
- Xint ty_openfile PRM( (File *, Fh *, int); )
- Xint ty_closefile PRM( (Fh *); )
- Xint ty_keyadd PRM( (Key *, void *, ulong); )
- Xint ty_keydel PRM( (Key *, void *, ulong); )
- Xint ty_keyfind PRM( (Key *, void *, ulong *); )
- Xint ty_keyread PRM( (Key *, void *); )
- Xint ty_keyfrst PRM( (Key *, ulong *); )
- Xint ty_keylast PRM( (Key *, ulong *); )
- Xint ty_keynext PRM( (Key *, ulong *); )
- Xint ty_keyprev PRM( (Key *, ulong *); )
- Xint ty_recadd PRM( (Record *, void *, ulong *); )
- Xint ty_recwrite PRM( (Record *, void *, ulong); )
- Xint ty_recread PRM( (Record *, void *, ulong); )
- Xint ty_recread PRM( (Record *, void *, ulong); )
- Xint ty_recdelete PRM( (Record *, ulong); )
- Xulong ty_numrecords PRM( (Record *, ulong *); )
- Xint ty_recfrst PRM( (Record *, void *); )
- Xint ty_reclast PRM( (Record *, void *); )
- Xint ty_recnext PRM( (Record *, void *); )
- Xint ty_recprev PRM( (Record *, void *); )
- Xint ty_vlradd PRM( (Record *, void *, unsigned, ulong *); )
- Xint ty_vlrwrite PRM( (Record *, void *, unsigned, ulong); )
- Xunsigned ty_vlrread PRM( (Record *, void *, ulong, unsigned *); )
- Xint ty_vlrdel PRM( (Record *, ulong); )
- Xint ty_reccurr PRM( (Record *, ulong *); )
- Xint ty_closeafile PRM( (void); )
- X
- Xvoid ty_logerror PRM( (char *, ...); )
- X
- X/*------------------------------- ty_repl.c --------------------------------*/
- Xvoid ty_log PRM( (int); )
- X
- X
- X/*--------------------------------- bt_open --------------------------------*/
- Xvoid btree_getheader PRM( (INDEX *); )
- Xvoid btree_putheader PRM( (INDEX *); )
- XINDEX *btree_open PRM( (char *, int, int, CMPFUNC, int, int); )
- Xvoid btree_close PRM( (INDEX *); )
- Xint btree_dynopen PRM( (INDEX *); )
- Xint keydynclose PRM( (INDEX *); )
- Xint nodesearch PRM( (INDEX *, void *, int *); )
- Xint d_search PRM( (INDEX *, void *, ix_addr *, int *); )
- X
- X/*------------------------------- bt_fucns.c -------------------------------*/
- Xint btree_add PRM( (INDEX *, void *, ulong); )
- Xint btree_find PRM( (INDEX *, void *, ulong *); )
- Xint btree_read PRM( (INDEX *, void *); )
- Xint btree_write PRM( (INDEX *, void *); )
- Xint btree_delall PRM( (INDEX *); )
- Xint btree_frst PRM( (INDEX *, ulong *); )
- Xint btree_last PRM( (INDEX *, ulong *); )
- Xint btree_next PRM( (INDEX *, ulong *); )
- Xint btree_prev PRM( (INDEX *, ulong *); )
- Xint btree_exist PRM( (INDEX *, void *, ulong); )
- X
- X/*-------------------------------- bt_del.c --------------------------------*/
- Xint btree_del PRM( (INDEX *, void *, ulong); )
- X
- X/*--------------------------------- bt_io.c --------------------------------*/
- Xix_addr noderead PRM( (INDEX *, char *, ix_addr); )
- Xix_addr nodewrite PRM( (INDEX *, char *, ix_addr); )
- X
- X/*-------------------------------- record.c --------------------------------*/
- XRECORD *rec_open PRM( (char *, unsigned, int); )
- Xint rec_close PRM( (RECORD *); )
- Xint rec_add PRM( (RECORD *, void *, ulong *); )
- Xint rec_write PRM( (RECORD *, void *, ulong); )
- Xint rec_read PRM( (RECORD *, void *, ulong); )
- Xint rec_delete PRM( (RECORD *, ulong); )
- Xint rec_curr PRM( (RECORD *, ulong *); )
- Xulong rec_numrecords PRM( (RECORD *, ulong *); )
- Xint rec_frst PRM( (RECORD *, void *); )
- Xint rec_last PRM( (RECORD *, void *); )
- Xint rec_next PRM( (RECORD *, void *); )
- Xint rec_prev PRM( (RECORD *, void *); )
- Xint rec_lock PRM( (RECORD *, ulong, int); )
- Xint rec_unlock PRM( (RECORD *, ulong); )
- X
- X/*---------------------------------- vlr.c ---------------------------------*/
- Xvoid vlr_close PRM( (VLR *); )
- XVLR *vlr_open PRM( (char *, unsigned, int); )
- Xint vlr_add PRM( (VLR *, void *, unsigned, ulong *); )
- Xint vlr_write PRM( (VLR *, void *, unsigned, ulong); )
- Xint vlr_read PRM( (VLR *, void *, ulong, unsigned *); )
- Xint vlr_del PRM( (VLR *, ulong); )
- X
- X/*---------------------------------- os.c ----------------------------------*/
- Xint os_lock PRM( (int, long, unsigned, int); )
- Xint os_unlock PRM( (int, long, unsigned); )
- Xint os_open PRM( (char *, int, int); )
- Xint os_close PRM( (int); )
- X
- X
- X/*--------------------------------- osxxx.c --------------------------------*/
- Xint ty_openlock PRM( (void); )
- Xint ty_closelock PRM( (void); )
- Xint ty_lock PRM( (void); )
- Xint ty_unlock PRM( (void); )
- Xint shm_alloc PRM( (Dbentry *); )
- Xint shm_free PRM( (Dbentry *); )
- X
- X
- X/*------------------------------- cmpfuncs.c -------------------------------*/
- Xint compoundkeycmp PRM( (void *, void *); )
- Xint refentrycmp PRM( (REF_ENTRY *, REF_ENTRY *); )
- Xvoid InitLowerTable PRM( (void); )
- X
- X/* end-of-file */
- END_OF_FILE
- if test 8130 -ne `wc -c <'typhoon/src/ty_prot.h'`; then
- echo shar: \"'typhoon/src/ty_prot.h'\" unpacked with wrong size!
- fi
- # end of 'typhoon/src/ty_prot.h'
- fi
- if test -f 'typhoon/src/ty_type.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'typhoon/src/ty_type.h'\"
- else
- echo shar: Extracting \"'typhoon/src/ty_type.h'\" \(9030 characters\)
- sed "s/^X//" >'typhoon/src/ty_type.h' <<'END_OF_FILE'
- X/*----------------------------------------------------------------------------
- X * File : ty_type.h
- X * Library : typhoon
- X * OS : UNIX, OS/2, DOS
- X * Author : Thomas B. Pedersen
- X *
- X * Copyright (c) 1994 Thomas B. Pedersen. All rights reserved.
- X *
- X * Permission is hereby granted, without written agreement and without
- X * license or royalty fees, to use, copy, modify, and distribute this
- X * software and its documentation for any purpose, provided that the above
- X * copyright notice and the following two paragraphs appear (1) in all
- X * source copies of this software and (2) in accompanying documentation
- X * wherever the programatic interface of this software, or any derivative
- X * of it, is described.
- X *
- X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
- X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
- X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN
- X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- X *
- X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
- X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- X * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
- X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- X *
- X * Description:
- X * Contains file descriptor definition for the B-tree, record and vlr
- X * modules.
- X *
- X * $Id: ty_type.h,v 1.2 1994/09/17 16:00:20 tbp Exp $
- X *
- X * $Log: ty_type.h,v $
- X * Revision 1.2 1994/09/17 16:00:20 tbp
- X * typhoon.h and environ.h are now included from <>.
- X *
- X * Revision 1.1 1994/09/13 21:28:38 tbp
- X * Added to repository.
- X *
- X *
- X *--------------------------------------------------------------------------*/
- X
- X#include <environ.h>
- X
- X/*---------- Internal constants --------------------------------------------*/
- X#define DB_MAX 10 /* Maximum number of concurrent databases */
- X#define BTREE_DEPTH_MAX 10 /* Maximum B-tree depth */
- X#define BIT_DELETED 0x01
- X
- X/*---------- Macros --------------------------------------------------------*/
- X#define FREE(p) if( p ) free(p)
- X#define RETURN return db_status =
- X#define RETURN_RAP(v) return report_err(v);
- X
- X/*---------- Structures ----------------------------------------------------*/
- Xtypedef ulong ix_addr;
- Xtypedef int (*CMPFUNC)PRM((void *, void *));
- Xtypedef struct {
- X char type; /* = 'k' */
- X ulong seqno; /* Sequence number */
- X int fh; /* File handle */
- X char fname[80]; /* File name */
- X struct { /* Index file header */
- X char id[16]; /* Version id */
- X ushort version; /* Version number */
- X ix_addr first_deleted; /* Pointer to first node in delete list */
- X ushort nodesize; /* Node size */
- X ushort keysize; /* Size of key in bytes */
- X ushort order; /* Node order */
- X ushort dups; /* Duplicate keys allowed? */
- X ulong keys; /* Number of keys in index */
- X ulong timestamp; /* Timestamp. Changed by d_keyadd/del() */
- X char spare[2]; /* Not used */
- X } H;
- X CMPFUNC cmpfunc; /* Comparison function */
- X struct { /* Path to current node and key */
- X ix_addr a; /* Node address */
- X ushort i; /* Node index */
- X } path[BTREE_DEPTH_MAX+1];
- X int level; /* Path level */
- X int shared; /* Opened in shared mode? */
- X int tsize; /* Tuple size */
- X int aligned_keysize; /* Aligned keysize */
- X int curr; /* Do we have a current key? */
- X int hold; /* Used by d_keynext and d_keyprev */
- X char *curkey; /* 'current key' buffer */
- X char node[1]; /* This array is size nodesize */
- X} INDEX;
- X
- Xtypedef struct { /* Record head (found in every record) */
- X ulong prev; /* Pointer to previous record */
- X ulong next; /* Pointer to next record */
- X char flags; /* Delete bit */
- X char data[1]; /* Record data. this field MUST be the */
- X} RECORDHEAD; /* Last field in the RECORD structure */
- X
- Xtypedef struct {
- X char type; /* = 'd' */
- X ulong seqno; /* Sequence number */
- X int fh; /* File handle */
- X char fname[80]; /* File name */
- X struct {
- X char id[16]; /* Version id */
- X ushort version; /* Record file version number */
- X ulong first_deleted; /* Pointer to first deleted record */
- X ulong first; /* Pointer to first record in chain */
- X ulong last; /* Pointer to last record in chain */
- X ulong numrecords; /* Number of records in file */
- X ushort datasize; /* Size of data block */
- X ushort recsize; /* Size of record (and chain) */
- X } H;
- X int first_possible_rec; /* Record number of the first */
- X /* record in the file */
- X int share; /* Opened in shared mode? */
- X ulong recno; /* Current record number. 0 = no current*/
- X RECORDHEAD rec;
- X} RECORD;
- X
- X/*--------------------------------------------------------------------------*/
- X/* Variable Length Record file structures */
- X/*--------------------------------------------------------------------------*/
- Xtypedef struct {
- X ulong nextblock; /* Pointer to next block */
- X unsigned recsize; /* Size of record */
- X char data[1]; /* Data */
- X} VLRBLOCK;
- X
- Xtypedef struct {
- X char type; /* = 'v' */
- X ulong seqno; /* Sequence number */
- X int fh; /* File handle */
- X char fname[80]; /* File name */
- X int shared; /* Opened in shared mode? */
- X unsigned datasize; /* Number of bytes in each block */
- X VLRBLOCK *block; /* Pointer to buffer */
- X struct {
- X char version[32]; /* VLR version number */
- X char id[32]; /* User provided ID */
- X unsigned blocksize; /* Block size */
- X ulong firstfree; /* First free data block */
- X ulong numrecords; /* Number of records in file */
- X } header;
- X} VLR;
- X
- Xtypedef union {
- X struct {
- X char type; /* 'd' = data,, 'k' = key, 'v'=vlr file */
- X ulong seqno; /* Sequence number */
- X int fh;
- X } *any;
- X INDEX *key; /* Index File Descriptor */
- X RECORD *rec; /* Record File Descriptor */
- X VLR *vlr; /* Variable Length Record Descriptor */
- X} Fh;
- X
- Xtypedef struct {
- X int use_count; /* First remove shared memory when 0 */
- X int backup_active;
- X int restore_active;
- X ulong curr_recid;
- X ulong curr_recno;
- X ulong num_trans_active;
- X char spare[96];
- X} SharedMemory;
- X
- Xtypedef struct { /* Database table entry */
- X char name[15]; /* Database name */
- X char mode; /* [s]hared, [o]ne user, e[x]clusive */
- X char clients; /* Number of clients using this database*/
- X char dbfpath[256]; /* Database file path */
- X char logging; /* Is replication logging on? */
- X uchar prog_id; /* Program ID (used with logging) */
- X ulong curr_rec; /* These 4 fields hold curr_ variables */
- X ulong curr_recid; /* when the database is not the current */
- X ulong curr_bufrec;
- X ulong curr_bufrecid;
- X int db_status;
- X Header header;
- X void *dbd;
- X Fh *fh; /* Array [dbentry.files] of handles */
- X File *file;
- X Record *record;
- X Field *field;
- X Key *key;
- X KeyField *keyfield;
- X Structdef *structdef;
- X SharedMemory *shm;
- X int shm_id;
- X char *recbuf; /* This points to where the actual data */
- X /* starts (bypassing foreign key refs) */
- X char *real_recbuf; /* This points to the real start of the */
- X /* buffer */
- X} Dbentry;
- X
- Xtypedef struct {
- X ulong parent; /* Address of parent record */
- X DB_ADDR dependent; /* Address of dependent record */
- X} REF_ENTRY;
- X
- X
- X
- Xtypedef struct {
- X Dbentry dbtab[DB_MAX]; /* Database table */
- X Dbentry *db; /* Current database */
- X
- X int do_rebuild; /* Rebuild indexes on d_open()? */
- X int dbs_open;
- X
- X int cur_open; /* Current number of open files */
- X int max_open; /* Maximum number of open files */
- X
- X ulong curr_keybuf[KEYSIZE_MAX/sizeof(long)];
- X
- X Id curr_key; /* Current key. It is */
- X /* used to tell compoundkeycmp */
- X /* which key is being compared */
- X int curr_db; /* Current database */
- X void (*ty_errfn) PRM( (int,long); )
- X
- X char dbfpath[256];
- X char dbdpath[256];
- X} TyphoonGlobals;
- X
- X
- X/* end-of-file */
- X
- END_OF_FILE
- if test 9030 -ne `wc -c <'typhoon/src/ty_type.h'`; then
- echo shar: \"'typhoon/src/ty_type.h'\" unpacked with wrong size!
- fi
- # end of 'typhoon/src/ty_type.h'
- fi
- if test -f 'typhoon/src/util/dbdview.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'typhoon/src/util/dbdview.c'\"
- else
- echo shar: Extracting \"'typhoon/src/util/dbdview.c'\" \(8730 characters\)
- sed "s/^X//" >'typhoon/src/util/dbdview.c' <<'END_OF_FILE'
- X/*----------------------------------------------------------------------------
- X * File : dbdview.c
- X * Program : dbdview
- X * OS : UNIX, OS/2, DOS
- X * Author : Thomas B. Pedersen
- X *
- X * Copyright (c) 1994 Thomas B. Pedersen. All rights reserved.
- X *
- X * Permission is hereby granted, without written agreement and without
- X * license or royalty fees, to use, copy, modify, and distribute this
- X * software and its documentation for any purpose, provided that the above
- X * copyright notice and the following two paragraphs appear (1) in all
- X * source copies of this software and (2) in accompanying documentation
- X * wherever the programatic interface of this software, or any derivative
- X * of it, is described.
- X *
- X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
- X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
- X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN
- X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- X *
- X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
- X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- X * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
- X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- X *
- X * Description:
- X * Small utility that dumps a dbd-file.
- X *
- X * $Log: dbdview.c,v $
- X * Revision 1.2 1994/09/17 16:00:50 tbp
- X * typhoon.h and environ.h are now included from <>.
- X *
- X * Revision 1.1 1994/09/13 21:28:50 tbp
- X * Added to repository.
- X *
- X * Added to repository.
- X *
- X *
- X *--------------------------------------------------------------------------*/
- X
- Xstatic char rcsid[] = "$Id: dbdview.c,v 1.2 1994/09/17 16:00:50 tbp Exp $";
- X
- X#ifdef UNIX
- X# include <malloc.h>
- X#else
- X# include <stdlib.h>
- X# include <io.h>
- X#endif
- X#include <stdio.h>
- X#include <fcntl.h>
- X#include <string.h>
- X#include <environ.h>
- X#include "../ty_dbd.h"
- X#include "ddlp.h"
- X#define FREE(p) if( p ) free(p)
- X
- X
- X/*-------------------------- Function prototypes ---------------------------*/
- Xstatic void viewdbd PRM( (int); )
- X
- X/*---------------------------- Global variables ----------------------------*/
- Xstatic Header header;
- Xstatic Field *fieldtab;
- Xstatic Record *recordtab;
- Xstatic File *filetab;
- Xstatic Key *keytab;
- Xstatic KeyField *keyfieldtab;
- Xstatic Structdef *structtab;
- X
- X
- X
- X/*--------------------------------------------------------------------------*\
- X *
- X * Function : strstr
- X *
- X * Purpose : ANSI C strstr() implementation.
- X *
- X * Parameters: s1 - String to search.
- X * s2 - String to search for.
- X *
- X * Returns : A pointer to the found substring otherwise NULL.
- X *
- X */
- X#ifdef UNIX
- X#ifndef __STDC__
- Xstatic char *strstr(s1, s2)
- Xchar *s1, *s2;
- X{
- X int len = strlen(s2);
- X
- X while( *s1 )
- X {
- X if( *s2 == *s1 )
- X if( !memcmp(*s1,s2,len) )
- X return s1;
- X s1++;
- X }
- X return NULL;
- X}
- X#endif
- X#endif
- X
- X
- X/*--------------------------------------------------------------------------*\
- X *
- X * Function : viewdbd
- X *
- X * Purpose : View the tables in the dbd-file.
- X *
- X * Parameters: dbdfile - File handle.
- X *
- X * Returns : Nothing.
- X *
- X */
- Xstatic void viewdbd(dbdfile)
- Xint dbdfile;
- X{
- X static char *key_type[] = {
- X "primary",
- X "altern.",
- X "foreign",
- X "referen"
- X };
- X char type[50];
- X int i, j, n;
- X Key *key;
- X Field *field;
- X Record *record;
- X Structdef *struc;
- X
- X read(dbdfile, &header, sizeof header);
- X
- X if( strcmp(header.version, DBD_VERSION) )
- X {
- X puts("Illegal version ID");
- X return;
- X }
- X
- X
- X printf("%d files\n", header.files);
- X printf("%d keys\n", header.keys);
- X printf("%d keyfields\n", header.keyfields);
- X printf("%d records\n", header.records);
- X printf("%d fields\n", header.fields);
- X printf("%d structdefs\n", header.structdefs);
- X
- X /*---------- allocate memory for tables ----------*/
- X filetab = (void *)malloc(sizeof(File) * header.files);
- X keytab = (void *)malloc(sizeof(Key) * header.keys);
- X keyfieldtab = (void *)malloc(sizeof(KeyField) * header.keyfields);
- X fieldtab = (void *)malloc(sizeof(Field) * header.fields);
- X recordtab = (void *)malloc(sizeof(Record) * header.records);
- X structtab = (void *)malloc(sizeof(Structdef) * header.structdefs);
- X
- X if( (header.files && !filetab) ||
- X (header.keys && !keytab) ||
- X (header.keyfields && !keyfieldtab) ||
- X (header.fields && !fieldtab) ||
- X (header.records && !recordtab) ||
- X (header.structdefs && !structtab) )
- X {
- X puts("out of memory");
- X FREE(filetab);
- X FREE(fieldtab);
- X FREE(recordtab);
- X FREE(keytab);
- X FREE(keyfieldtab);
- X FREE(structtab);
- X return;
- X }
- X
- X /*---------- read tables ----------*/
- X read(dbdfile, filetab, sizeof(File) * header.files);
- X read(dbdfile, keytab, sizeof(Key) * header.keys);
- X read(dbdfile, keyfieldtab, sizeof(KeyField) * header.keyfields);
- X read(dbdfile, recordtab, sizeof(Record) * header.records);
- X read(dbdfile, fieldtab, sizeof(Field) * header.fields);
- X read(dbdfile, structtab, sizeof(Structdef) * header.structdefs);
- X
- X puts("----------------------------------- FILES -------------------------------------");
- X printf(" ID NAME PGSIZE REC/KEY ID TYPE\n");
- X for( i=0; i<header.files; i++ )
- X printf("%3d %-20s %6u %10ld %4c\n",
- X i,
- X filetab[i].name,
- X filetab[i].pagesize,
- X filetab[i].id,
- X filetab[i].type);
- X printf("\n");
- X
- X puts("----------------------------------- KEYS --------------------------------------");
- X printf(" ID NAME TYPE FILE SIZE 1ST_KEYFLD FIELDS PARENT\n");
- X for( i=0, key=keytab; i<header.keys; i++, key++ )
- X {
- X strcpy(type, key_type[KT_GETBASIC(key->type)-1]);
- X
- X if( key->type & KT_OPTIONAL )
- X strcat(type, " opt");
- X
- X if( KT_GETBASIC(key->type) == KT_ALTERNATE && (key->type & KT_UNIQUE) )
- X strcat(type, " unique");
- X
- X printf("%3d %-20s %-18s %4ld %4u %10ld %6d",
- X i,
- X key->name,
- X type,
- X key->fileid,
- X key->size,
- X key->first_keyfield,
- X key->fields);
- X if( KT_GETBASIC(key->type) == KT_FOREIGN )
- X printf(" %d", key->parent);
- X puts("");
- X }
- X
- X puts("");
- X puts("--------------------------------- KEY FIELDS ----------------------------------");
- X printf(" ID FIELD OFFSET ASCENDING\n");
- X for( i=0; i<header.keyfields; i++ )
- X {
- X printf("%3d %-5ld %6u %s\n",
- X i,
- X keyfieldtab[i].field,
- X keyfieldtab[i].offset,
- X keyfieldtab[i].asc ? "Yes" : "No");
- X }
- X
- X puts("\n----------------------------------- RECORDS -----------------------------------");
- X puts(" ID NAME SIZE VLR FILE 1ST_FLD FIELDS KEYS 1ST_KEY STR 1ST_FOR");
- X for( i=0, record=recordtab; i<header.records; i++, record++ )
- X {
- X printf("%3d %-20s %5u %-3s %4ld %7ld %6u %4u %7ld %3d",
- X i,
- X record->name,
- X record->size,
- X record->is_vlr ? "Yes" : "No",
- X record->fileid,
- X record->first_field,
- X record->fields,
- X record->keys,
- X record->first_key,
- X record->structid);
- X if( record->first_foreign != -1 )
- X printf(" %10d", record->first_foreign);
- X puts("");
- X }
- X
- X puts("\n----------------------------------- STRUCTS -----------------------------------");
- X puts(" ID NAME SIZE 1ST_MEMBER MEMBERS UNION CONTROL");
- X for( i=0, struc=structtab; i<header.structdefs; i++, struc++ )
- X {
- X printf("%3d %-20s %4u %10u %7u %5s",
- X i,
- X struc->name,
- X struc->size,
- X struc->first_member,
- X struc->members,
- X struc->is_union ? "yes" : "no");
- X
- X if( struc->is_union )
- X printf(" %7lu", struc->control_field);
- X
- X puts("");
- X }
- X
- X
- X puts("\n----------------------------------- FIELDS ------------------------------------");
- X puts(" ID NAME REC NEST OFFSET ELEMSZ SIZE TYPE STRID KEYID SIZE_FLD");
- X for( i=0, field=fieldtab; i<header.fields; i++, field++ )
- X {
- X printf("%3d %-20s %3ld %4u %6d %6d %5u %4X",
- X i,
- X field->name,
- X field->recid,
- X field->nesting,
- X field->offset,
- X field->elemsize,
- X field->size,
- X field->type);
- X
- X if( field->type == FT_STRUCT )
- X printf(" %5ld", field->structid);
- X else
- X printf(" ");
- X
- X if( field->type & FT_KEY )
- X printf(" %5ld", field->keyid);
- X else
- X if( fieldtab[i].type & FT_VARIABLE )
- X printf(" %8u", field->keyid);
- X puts("");
- X }
- X
- X free(filetab);
- X free(fieldtab);
- X free(recordtab);
- X free(keytab);
- X free(keyfieldtab);
- X free(structtab);
- X}
- X
- X
- Xvoid main(argc, argv)
- Xchar *argv[];
- X{
- X int dbdfile;
- X char fname[80];
- X
- X if( argc < 2 )
- X {
- X puts("Syntax: dbdview dbd-file");
- X exit(1);
- X }
- X
- X /* check extension */
- X strcpy(fname, argv[argc-1]);
- X if( strstr(fname, ".dbd") == NULL )
- X strcat(fname, ".dbd");
- X
- X if( (dbdfile=open(fname, O_RDONLY|O_BINARY)) == -1 )
- X {
- X printf("cannot open %s\n", fname);
- X exit(1);
- X }
- X
- X viewdbd(dbdfile);
- X
- X close(dbdfile);
- X}
- X
- X/* end-of-file */
- X
- END_OF_FILE
- if test 8730 -ne `wc -c <'typhoon/src/util/dbdview.c'`; then
- echo shar: \"'typhoon/src/util/dbdview.c'\" unpacked with wrong size!
- fi
- # end of 'typhoon/src/util/dbdview.c'
- fi
- if test -f 'typhoon/src/util/fixlog.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'typhoon/src/util/fixlog.c'\"
- else
- echo shar: Extracting \"'typhoon/src/util/fixlog.c'\" \(7892 characters\)
- sed "s/^X//" >'typhoon/src/util/fixlog.c' <<'END_OF_FILE'
- X/*----------------------------------------------------------------------------
- X * File : fixlog.c
- X * Program : tyrestore
- X * OS : UNIX, OS/2, DOS
- X * Author : Thomas B. Pedersen
- X *
- X * Copyright (c) 1994 Thomas B. Pedersen. All rights reserved.
- X *
- X * Permission is hereby granted, without written agreement and without
- X * license or royalty fees, to use, copy, modify, and distribute this
- X * software and its documentation for any purpose, provided that the above
- X * copyright notice and the following two paragraphs appear (1) in all
- X * source copies of this software and (2) in accompanying documentation
- X * wherever the programatic interface of this software, or any derivative
- X * of it, is described.
- X *
- X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
- X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
- X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN
- X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- X *
- X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
- X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- X * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
- X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- X *
- X * Description:
- X * Contains functions used to applying the log to the database after a
- X * restore.
- X *
- X * Functions:
- X *
- X * $Log: fixlog.c,v $
- X * Revision 1.2 1994/09/17 16:00:54 tbp
- X * typhoon.h and environ.h are now included from <>.
- X *
- X * Revision 1.1 1994/09/13 21:28:57 tbp
- X * Added to repository.
- X *
- X * Added to repository.
- X *
- X *
- X *--------------------------------------------------------------------------*/
- X
- Xstatic char rcsid[] = "$Id: fixlog.c,v 1.2 1994/09/17 16:00:54 tbp Exp $";
- X
- X#include <fcntl.h>
- X#include <stdio.h>
- X#include <setjmp.h>
- X#include <limits.h>
- X#include <errno.h>
- X#include <unistd.h>
- X#include <typhoon.h>
- X#include "../ty_dbd.h"
- X#include "../ty_type.h"
- X#include "../ty_glob.h"
- X#include "../ty_prot.h"
- X#include "../ty_log.h"
- X
- X
- X
- X/*------------------------------- Constants --------------------------------*/
- X#define LOGBUF_SIZE (64 * 1024)
- X#define RECHEAD_SIZE offsetof(RECORDHEAD, data[0])
- X#define FILES_MAX 512
- X
- X
- X/*-------------------------- Function prototypes ---------------------------*/
- Xstatic void *ReadLog PRM( (ulong); )
- Xstatic void insert_in_lru PRM( (ulong); )
- Xstatic void delete_from_lru PRM( (ulong); )
- Xstatic void update_in_lru PRM( (ulong); )
- X
- X/*---------------------------- Global variables ----------------------------*/
- Xstatic char *logbuf; /* Log buffer */
- Xstatic ulong logbytes = 0; /* Number of bytes in buffer */
- Xstatic ulong logreadpos = 0; /* Read position in log buffer */
- Xstatic int log_fh; /* Log file handle */
- Xstatic Dbentry dbd; /* DBD-anchor */
- Xextern jmp_buf err_jmpbuf;
- Xextern int verbose;
- Xextern char *datapath;
- X
- Xstatic struct file_t {
- X int fh;
- X unsigned recsize;
- X unsigned blocksize;
- X unsigned preamble;
- X int prev_in_lru;
- X int next_in_lru;
- X} file[FILES_MAX];
- Xstatic int mru_file = -1;
- Xstatic int lru_file = -1;
- Xstatic int r_cur_open = 0;
- Xstatic int r_max_open = 40;
- X
- X
- X/*--------------------------------------------------------------------------*\
- X *
- X * Function : ReadLog
- X *
- X * Purpose : Returns a pointer to the next x bytes in the log.
- X *
- X * Parameters: bytes - Number of bytes requested.
- X *
- X * Returns : Nothing.
- X *
- X */
- Xstatic void *ReadLog(bytes)
- Xulong bytes;
- X{
- X ulong numread;
- X char *p;
- X
- X if( bytes > logbytes - logreadpos )
- X {
- X memmove(logbuf, logbuf+logreadpos, logbytes - logreadpos);
- X logbytes -= logreadpos;
- X logreadpos = 0;
- X
- X numread = read(log_fh, logbuf + logbytes, LOGBUF_SIZE - logbytes);
- X
- X if( numread <= 0 )
- X return NULL;
- X
- X logbytes += numread;
- X }
- X
- X p = logbuf + logreadpos;
- X logreadpos += bytes;
- X
- X return p;
- X}
- X
- X
- Xstatic void insert_in_lru(id)
- Xulong id;
- X{
- X struct file_t *f = file + id;
- X
- X f->prev_in_lru = -1;
- X
- X if( mru_file != -1 )
- X {
- X f->next_in_lru = mru_file;
- X file[mru_file].prev_in_lru = id;
- X }
- X else
- X {
- X lru_file = id;
- X f->prev_in_lru = -1;
- X }
- X
- X mru_file = id;
- X}
- X
- Xstatic void delete_from_lru(id)
- Xulong id;
- X{
- X struct file_t *f = file + id;
- X
- X if( f->next_in_lru != -1 )
- X file[f->next_in_lru].prev_in_lru = f->prev_in_lru;
- X
- X if( f->prev_in_lru != -1 )
- X file[f->prev_in_lru].next_in_lru = f->next_in_lru;
- X
- X if( mru_file == id )
- X mru_file = f->next_in_lru;
- X
- X if( lru_file == id )
- X lru_file = f->prev_in_lru;
- X}
- X
- X
- Xstatic void update_in_lru(id)
- Xulong id;
- X{
- X delete_from_lru(id);
- X insert_in_lru(id);
- X}
- X
- X
- X
- Xstatic void CheckFile(fileid)
- Xulong fileid;
- X{
- X char fname[128];
- X
- X if( file[fileid].fh == -1 )
- X {
- X if( r_cur_open == r_max_open )
- X {
- X /* Close least recently used file */
- X close(file[lru_file].fh);
- X file[lru_file].fh = -1;
- X
- X delete_from_lru(lru_file);
- X r_cur_open--;
- X }
- X
- X sprintf(fname, "%s/%s", datapath, dbd.file[fileid].name);
- X if( (file[fileid].fh = os_open(fname, O_RDWR, 0)) == -1 )
- X {
- X printf("Cannot open '%s' (errno %d)\n", dbd.file[fileid].name, errno);
- X longjmp(err_jmpbuf, 1);
- X }
- X
- X insert_in_lru(fileid);
- X r_cur_open++;
- X }
- X}
- X
- X
- X/*--------------------------------------------------------------------------*\
- X *
- X * Function : FixLog
- X *
- X * Purpose : Copies all the updates from the log to the database tables.
- X *
- X * Parameters: dbname - Database name.
- X *
- X * Returns : Nothing.
- X *
- X */
- Xvoid FixLog(dbname)
- Xchar *dbname;
- X{
- X ushort *logblock;
- X char dbdname[DBNAME_LEN+5];
- X unsigned i, fileid;
- X RECORDHEAD recordhd = { 0 };
- X char fname[128];
- X
- X /* Open log file */
- X if( (log_fh = open(LOG_FNAME, O_RDONLY)) == -1 )
- X {
- X if( verbose )
- X puts("No log");
- X return;
- X }
- X
- X if( verbose )
- X printf("Fixing log");
- X
- X /* Read dbd-file */
- X sprintf(dbdname, "%s.dbd", dbname);
- X if( read_dbdfile(&dbd, dbdname) != S_OKAY )
- X {
- X printf("Cannot open '%s'\n", dbdname);
- X longjmp(err_jmpbuf, 1);
- X }
- X
- X /* Allocate log buffer */
- X if( !(logbuf = (char *)malloc(LOGBUF_SIZE)) )
- X {
- X puts("out of memory");
- X longjmp(err_jmpbuf, 1);
- X }
- X
- X for( i=0; i<dbd.header.records; i++ )
- X {
- X ulong foreign_keys, preamble, datasize;
- X Record *rec = dbd.record + i;
- X
- X if( rec->first_foreign == -1 )
- X foreign_keys = 0;
- X else
- X foreign_keys = rec->keys - (rec->first_foreign - rec->first_key);
- X preamble= sizeof(long) * foreign_keys;
- X
- X fileid = dbd.record[i].fileid;
- X file[fileid].fh = -1;
- X file[fileid].next_in_lru = -1;
- X file[fileid].recsize = dbd.record[i].size;
- X file[fileid].blocksize = dbd.record[i].size + RECHEAD_SIZE +
- X preamble;
- X file[fileid].preamble = preamble;
- X }
- X
- X while( logblock = (ushort *)ReadLog(sizeof *logblock) )
- X {
- X switch( *logblock )
- X {
- X case LOG_UPDATE: {
- X LogUpdate *update = (void *)logblock;
- X
- X /* Skip rest of LogUpdate structure and record */
- X ReadLog(update->len - sizeof(update->id));
- X
- X fileid = dbd.record[update->recid].fileid;
- X CheckFile(fileid);
- X
- X recordhd.flags = 0;
- X
- X lseek(file[fileid].fh, update->recno * file[fileid].blocksize, SEEK_SET);
- X write(file[fileid].fh, &recordhd, RECHEAD_SIZE);
- X
- X lseek(file[fileid].fh, file[fileid].preamble, SEEK_CUR);
- X write(file[fileid].fh, update+1, file[fileid].recsize);
- X }
- X break;
- X
- X case LOG_DELETE: {
- X LogDelete *delete = (void *)logblock;
- X
- X /* Skip rest of LogDelete structure */
- X ReadLog(delete->len - sizeof(delete->id));
- X
- X fileid = dbd.record[delete->recid].fileid;
- X CheckFile(fileid);
- X
- X recordhd.flags = BIT_DELETED;
- X
- X lseek(file[fileid].fh, delete->recno * file[fileid].blocksize, SEEK_SET);
- X write(file[fileid].fh, &recordhd, RECHEAD_SIZE);
- X }
- X break;
- X }
- X }
- X
- X close(log_fh);
- X free(logbuf);
- X free(dbd.dbd);
- X
- X if( verbose )
- X puts("");
- X}
- X
- X/* end-of-file */
- END_OF_FILE
- if test 7892 -ne `wc -c <'typhoon/src/util/fixlog.c'`; then
- echo shar: \"'typhoon/src/util/fixlog.c'\" unpacked with wrong size!
- fi
- # end of 'typhoon/src/util/fixlog.c'
- fi
- if test -f 'typhoon/src/util/imp.y' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'typhoon/src/util/imp.y'\"
- else
- echo shar: Extracting \"'typhoon/src/util/imp.y'\" \(4986 characters\)
- sed "s/^X//" >'typhoon/src/util/imp.y' <<'END_OF_FILE'
- X/*----------------------------------------------------------------------------
- X * File : imp.y
- X * Program : tyimport
- X * OS : UNIX, OS/2, DOS
- X * Author : Thomas B. Pedersen
- X *
- X * Copyright (c) 1994 Thomas B. Pedersen. All rights reserved.
- X *
- X * Permission is hereby granted, without written agreement and without
- X * license or royalty fees, to use, copy, modify, and distribute this
- X * software and its documentation for any purpose, provided that the above
- X * copyright notice and the following two paragraphs appear (1) in all
- X * source copies of this software and (2) in accompanying documentation
- X * wherever the programatic interface of this software, or any derivative
- X * of it, is described.
- X *
- X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
- X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
- X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN
- X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- X *
- X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
- X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- X * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
- X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- X *
- X * Description:
- X * Grammar for import specification.
- X *
- X * $Id: imp.y,v 1.2 1994/09/17 16:11:14 tbp Exp $
- X *
- X * $Log: imp.y,v $
- X * Revision 1.2 1994/09/17 16:11:14 tbp
- X * Added include directive.
- X *
- X * Added included directive.
- X *
- X * Added include directive.
- X *
- X * Revision 1.1 1994/09/13 21:28:57 tbp
- X * Added to repository.
- X *
- X * Added to repository.
- X *
- X *
- X *--------------------------------------------------------------------------*/
- X
- X%{
- X
- X#include <string.h>
- X#include <stdarg.h>
- X#include <typhoon.h>
- X#include "../ty_dbd.h"
- X#include "../ty_type.h"
- X#include "import.h"
- X
- X#define NEST_MAX 15
- X
- X/*--------------------------- Function prototypes --------------------------*/
- XRecord *GetRecord PRM( (char *); )
- XField *GetField PRM( (Structdef *, char *); )
- XStructdef *GetStruct PRM( (Structdef *, char *); )
- X
- X/*---------------------------- Global variables ----------------------------*/
- Xstatic Record *cur_rec = NULL; /* Current record */
- Xstatic Field *cur_fld = NULL; /* Current field */
- Xstatic Structdef *cur_str = NULL; /* Current structure */
- Xstatic Structdef *strnest[NEST_MAX]; /* Pointers to structures */
- Xstatic int cur_nest = -1; /* Current nesting */
- X
- X%}
- X
- X%union {
- X char s[IDENT_LEN+1];
- X}
- X
- X%start import_spec
- X
- X%token T_IMPORT T_RECORD T_STRUCT T_UNION T_IN
- X%token <s> T_IDENT T_STRING
- X%token '{' '}' ';'
- X
- X%%
- X
- Ximport_spec : T_IMPORT T_IDENT '{' record_list '}'
- X ;
- X
- Xrecord_list : record
- X | record_list record
- X ;
- X
- Xrecord : record_head '{' field_list '}'
- X {
- X cur_nest--;
- X }
- X ;
- X
- Xrecord_head : T_RECORD T_IDENT T_IN T_STRING
- X {
- X if( cur_rec = GetRecord($2) )
- X {
- X cur_rec->aux = 1;
- X cur_str = &dbd.structdef[cur_rec->structid];
- X }
- X else
- X cur_str = NULL;
- X strnest[++cur_nest] = cur_str;
- X }
- X ;
- X
- Xfield_list : field
- X | field_list field
- X ;
- X
- Xfield : T_IDENT ';'
- X {
- X if( cur_str )
- X cur_fld = GetField(cur_str, $1);
- X }
- X
- X | struct_head '{' field_list '}' ';'
- X {
- X cur_str = strnest[--cur_nest];
- X }
- X ;
- X
- Xstruct_head : struct_or_union T_IDENT
- X {
- X if( cur_str )
- X cur_str = GetStruct(cur_str, $2);
- X strnest[++cur_nest] = cur_str;
- X }
- X ;
- X
- Xstruct_or_union : T_STRUCT
- X | T_UNION
- X ;
- X
- X
- X%%
- X
- X
- X#include <stdio.h>
- X
- Xextern errors;
- X
- Xyyerror(char *fmt ELLIPSIS)
- X{
- X va_list ap;
- X
- X printf("%s %d: ", spec_fname, lex_lineno);
- X va_start(ap, fmt);
- X vprintf(fmt, ap);
- X puts("");
- X va_end(ap);
- X errors++;
- X return 0;
- X}
- X
- X
- X
- X
- XRecord *GetRecord(name)
- Xchar *name;
- X{
- X int i;
- X
- X for( i=0; i<dbd.header.records; i++ )
- X if( !strcmp(dbd.record[i].name, name) )
- X return &dbd.record[i];
- X
- X yyerror("unknown record '%s'", name);
- X exit(1);
- X return NULL;
- X}
- X
- X
- X
- XField *GetField(str, name)
- XStructdef *str;
- Xchar *name;
- X{
- X Field *fld = &dbd.field[str->first_member];
- X int n = str->members;
- X
- X while( n )
- X {
- X if( fld->nesting == cur_nest )
- X {
- X if( !strcmp(fld->name, name) )
- X {
- X fld->type |= FT_INCLUDE;
- X return fld;
- X }
- X n--;
- X }
- X fld++;
- X }
- X
- X yyerror("'%s' is not a member of '%s'", name, str->name);
- X exit(1);
- X return NULL;
- X}
- X
- X
- XStructdef *GetStruct(str, name)
- XStructdef *str;
- Xchar *name;
- X{
- X Field *fld;
- X Structdef *struc;
- X
- X if( !(fld = GetField(str, name)) ||
- X FT_GETBASIC(fld->type) != FT_STRUCT )
- X return NULL;
- X
- X struc = &dbd.structdef[fld->structid];
- X
- X /* If the structure is a union the control field must also have been
- X * specified
- X */
- X if( struc->is_union )
- X {
- X if( !(dbd.field[struc->control_field].type & FT_INCLUDE) )
- X {
- X yyerror("The control field of the union '%s' is not included",
- X name);
- X exit(1);
- X }
- X }
- X
- X return struc;
- X}
- X
- X/* end-of-file */
- X
- END_OF_FILE
- if test 4986 -ne `wc -c <'typhoon/src/util/imp.y'`; then
- echo shar: \"'typhoon/src/util/imp.y'\" unpacked with wrong size!
- fi
- # end of 'typhoon/src/util/imp.y'
- fi
- if test -f 'typhoon/src/vlr.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'typhoon/src/vlr.c'\"
- else
- echo shar: Extracting \"'typhoon/src/vlr.c'\" \(8439 characters\)
- sed "s/^X//" >'typhoon/src/vlr.c' <<'END_OF_FILE'
- X/*----------------------------------------------------------------------------
- X * File : vlr.c
- X * Library : typhoon
- X * OS : UNIX, OS/2, DOS
- X * Author : Thomas B. Pedersen
- X *
- X * Copyright (c) 1994 Thomas B. Pedersen. All rights reserved.
- X *
- X * Permission is hereby granted, without written agreement and without
- X * license or royalty fees, to use, copy, modify, and distribute this
- X * software and its documentation for any purpose, provided that the above
- X * copyright notice and the following two paragraphs appear (1) in all
- X * source copies of this software and (2) in accompanying documentation
- X * wherever the programatic interface of this software, or any derivative
- X * of it, is described.
- X *
- X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
- X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
- X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN
- X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- X *
- X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
- X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- X * A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
- X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
- X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
- X *
- X * Description:
- X * Contains functions for Variable Length Records.
- X *
- X * Functions:
- X *
- X * $Log: vlr.c,v $
- X * Revision 1.2 1994/09/17 16:00:22 tbp
- X * typhoon.h and environ.h are now included from <>.
- X *
- X * Revision 1.1 1994/09/13 21:28:40 tbp
- X * Added to repository.
- X *
- X *
- X *--------------------------------------------------------------------------*/
- X
- Xstatic char rcsid[] = "$Id: vlr.c,v 1.2 1994/09/17 16:00:22 tbp Exp $";
- X
- X#include <sys/types.h>
- X#include <sys/stat.h>
- X#include <fcntl.h>
- X#include <errno.h>
- X#ifdef UNIX
- X# include <unistd.h>
- X# ifdef __STDC__
- X# include <stdlib.h>
- X# endif
- X#else
- X# include <io.h>
- X# include <stdlib.h>
- X#endif
- X#include <stdio.h>
- X#include <string.h>
- X#include <stddef.h>
- X
- X#include <typhoon.h>
- X#include "ty_dbd.h"
- X#include "ty_type.h"
- X#include "ty_prot.h"
- X#include "ty_glob.h"
- X
- X#define VLR_VERSION "1.00"
- X#define SEM_LEN 0
- X
- X#define _BLOCKSIZE (vlr->header.blocksize)
- X#define _FIRSTFREE (vlr->header.firstfree)
- X#define _NEXTBLOCK (vlr->block->nextblock)
- X#define _RECSIZE (vlr->block->recsize)
- X#define filelength(fd) lseek(fd, 0, SEEK_END)
- X
- X
- X/*-------------------------- Function prototypes ---------------------------*/
- Xstatic void get_block PRM( (VLR *, ulong); )
- Xstatic void put_block PRM( (VLR *, ulong); )
- Xstatic ulong get_nextblock PRM( (VLR *, ulong); )
- Xstatic void get_header PRM( (VLR *); )
- Xstatic void put_header PRM( (VLR *); )
- X
- X
- X
- Xstatic void get_block(vlr, blockno)
- XVLR *vlr;
- Xulong blockno;
- X{
- X lseek(vlr->fh, blockno * vlr->header.blocksize, SEEK_SET);
- X read(vlr->fh, vlr->block, vlr->header.blocksize - SEM_LEN);
- X}
- X
- Xstatic void put_block(vlr, blockno)
- XVLR *vlr;
- Xulong blockno;
- X{
- X lseek(vlr->fh, blockno * vlr->header.blocksize, SEEK_SET);
- X write(vlr->fh, vlr->block, vlr->header.blocksize - SEM_LEN);
- X}
- X
- X
- Xstatic ulong get_nextblock(vlr, blockno)
- XVLR *vlr;
- Xulong blockno;
- X{
- X ulong nextblock;
- X
- X lseek(vlr->fh, blockno * vlr->header.blocksize, SEEK_SET);
- X read(vlr->fh, &nextblock, sizeof nextblock);
- X
- X return nextblock;
- X}
- X
- X
- X/*------------------------------- get_header -------------------------------*\
- X *
- X * Read header from VLR file.
- X *
- X */
- X
- Xstatic void get_header(vlr)
- XVLR *vlr;
- X{
- X lseek(vlr->fh, 0, SEEK_SET);
- X read(vlr->fh, &vlr->header, sizeof vlr->header);
- X}
- X
- X
- X/*------------------------------- put_header -------------------------------*\
- X *
- X * Write header to VLR file.
- X *
- X */
- X
- Xstatic void put_header(vlr)
- XVLR *vlr;
- X{
- X lseek(vlr->fh, 0, SEEK_SET);
- X write(vlr->fh, &vlr->header, sizeof vlr->header);
- X}
- X
- X
- X/*------------------------------- vlr_close -------------------------------*\
- X *
- X * Write header to VLR file and close file.
- X *
- X */
- X
- Xvoid vlr_close(vlr)
- XVLR *vlr;
- X{
- X put_header(vlr);
- X free(vlr->block);
- X if( vlr->fh != -1 )
- X os_close(vlr->fh);
- X free(vlr);
- X}
- X
- X
- X/*------------------------------- vlr_open --------------------------------*\
- X *
- X * Open VRL file. If the file does not already exist it is created.
- X *
- X */
- X
- XVLR *vlr_open(fname, blocksize, shared)
- Xchar *fname;
- Xunsigned blocksize;
- Xint shared;
- X{
- X VLR *vlr;
- X int fh, isnew;
- X
- X isnew = access(fname, 0);
- X if( (fh = os_open(fname, O_BINARY|O_CREAT|O_RDWR, CREATMASK)) == -1 )
- X {
- X db_status = S_IOFATAL;
- X return NULL;
- X }
- X
- X if( !(vlr = (VLR *)calloc(sizeof *vlr, 1)) )
- X {
- X os_close(fh);
- X db_status = S_NOMEM;
- X return NULL;
- X }
- X
- X vlr->fh = fh;
- X
- X if( !(vlr->block = (VLRBLOCK *)malloc(blocksize)) )
- X {
- X os_close(fh);
- X free(vlr);
- X db_status = S_NOMEM;
- X return NULL;
- X }
- X
- X if( isnew )
- X {
- X strcpy(vlr->header.version, VLR_VERSION);
- X vlr->header.id[0] = 0;
- X vlr->header.blocksize = blocksize;
- X vlr->header.firstfree = 1;
- X vlr->header.numrecords = 0;
- X put_header(vlr);
- X lseek(vlr->fh, blocksize-1L, SEEK_SET);
- X write(vlr->fh, "", 1);
- X }
- X else
- X get_header(vlr);
- X
- X vlr->datasize = blocksize - offsetof(VLRBLOCK, data[0]) - SEM_LEN;
- X vlr->shared = shared;
- X strcpy(vlr->fname, fname);
- X
- X db_status = S_OKAY;
- X
- X return vlr;
- X}
- X
- X
- Xvlr_dynclose(vlr)
- XVLR *vlr;
- X{
- X if( vlr->fh != -1 )
- X {
- X close(vlr->fh);
- X vlr->fh = -1;
- X }
- X
- X RETURN S_OKAY;
- X}
- X
- X
- Xvlr_dynopen(vlr)
- XVLR *vlr;
- X{
- X if( vlr->fh == -1 )
- X if( (vlr->fh = os_open(vlr->fname, O_BINARY|O_CREAT|O_RDWR, CREATMASK)) == -1 )
- X RETURN S_IOFATAL;
- X
- X RETURN S_OKAY;
- X}
- X
- X
- X
- X/*------------------------------- vlr_add ---------------------------------*\
- X *
- X * Add a record to vlr file. If the delete-chain is non-empty, blocks are
- X * taken from there, otherwise blocks are appended to the file.
- X *
- X */
- X
- Xvlr_add(vlr, buf, bufsize, recno)
- XVLR *vlr;
- Xvoid *buf;
- Xunsigned bufsize;
- Xulong *recno;
- X{
- X unsigned num_blocks, i;
- X ulong old_firstfree = _FIRSTFREE;
- X ulong tmp_firstfree = _FIRSTFREE;
- X
- X get_header(vlr);
- X
- X num_blocks = bufsize / vlr->datasize;
- X
- X if( bufsize % vlr->datasize )
- X num_blocks++;
- X
- X _RECSIZE = bufsize;
- X
- X while( num_blocks-- )
- X {
- X memcpy(vlr->block->data, buf, vlr->datasize); /* trap prone */
- X
- X if( (vlr->header.firstfree) == filelength(vlr->fh)/vlr->header.blocksize )
- X {
- X _NEXTBLOCK = num_blocks ? filelength(vlr->fh) / _BLOCKSIZE + 1 : 0;
- X put_block(vlr, _FIRSTFREE);
- X _FIRSTFREE = filelength(vlr->fh)/_BLOCKSIZE;
- X }
- X else
- X {
- X tmp_firstfree = get_nextblock(vlr, _FIRSTFREE);
- X _NEXTBLOCK = num_blocks ? tmp_firstfree : 0;
- X put_block(vlr, _FIRSTFREE);
- X _FIRSTFREE = tmp_firstfree;
- X }
- X buf = (void *)((char *)buf + vlr->datasize);
- X _RECSIZE = 0;
- X }
- X
- X vlr->header.numrecords++;
- X put_header(vlr);
- X
- X *recno = old_firstfree;
- X
- X return S_OKAY;
- X}
- X
- X
- X
- X/*------------------------------- vlr_write -------------------------------*\
- X *
- X * Update a record. The record is first deleted then inserted. This is not
- X * the most efficient way to do it, but it works!
- X *
- X */
- X
- Xvlr_write(vlr, buf, bufsize, blockno)
- XVLR *vlr;
- Xvoid *buf;
- Xunsigned bufsize;
- Xulong blockno;
- X{
- X ulong dummy;
- X
- X vlr_del(vlr, blockno);
- X vlr_add(vlr, buf, bufsize, &dummy);
- X
- X RETURN S_OKAY;
- X}
- X
- X
- X/*------------------------------- vlr_read --------------------------------*\
- X *
- X * Read a record.
- X *
- X */
- X
- Xvlr_read(vlr, buf, blockno, sizeptr)
- XVLR *vlr;
- Xvoid *buf;
- Xulong blockno;
- Xunsigned *sizeptr;
- X{
- X unsigned size = 0;
- X
- X get_header(vlr);
- X _NEXTBLOCK = blockno;
- X
- X if( (blockno+1) * _BLOCKSIZE > filelength(vlr->fh) )
- X return 0;
- X
- X while( _NEXTBLOCK )
- X {
- X get_block(vlr, _NEXTBLOCK);
- X
- X if( _RECSIZE > 0 )
- X size = _RECSIZE;
- X
- X if( !size )
- X break;
- X
- X memcpy(buf, vlr->block->data, _NEXTBLOCK ? vlr->datasize : size % vlr->datasize);
- X buf = (void *)((char *)buf + vlr->datasize);
- X/* (char *)buf += vlr->datasize;*/
- X }
- X
- X *sizeptr = size;
- X
- X RETURN S_OKAY;
- X}
- X
- X/*-------------------------------- vlr_del --------------------------------*\
- X *
- X * Delete a record. The blocks used by the record deleted, are inserted in
- X * front of the delete chain.
- X *
- X */
- X
- Xvlr_del(vlr, blockno)
- XVLR *vlr;
- Xulong blockno;
- X{
- X ulong tmp_firstfree = _FIRSTFREE;
- X ulong cur_block = blockno;
- X
- X get_header(vlr);
- X
- X _FIRSTFREE = blockno;
- X get_block(vlr, blockno);
- X
- X _RECSIZE = 0;
- X put_block(vlr, blockno);
- X
- X while( _NEXTBLOCK > 0 )
- X {
- X cur_block = _NEXTBLOCK;
- X _NEXTBLOCK = get_nextblock(vlr, _NEXTBLOCK);
- X }
- X
- X _NEXTBLOCK = tmp_firstfree;
- X put_block(vlr, cur_block);
- X
- X vlr->header.numrecords--;
- X put_header(vlr);
- X
- X RETURN S_OKAY;
- X}
- X
- X/* end-of-file */
- END_OF_FILE
- if test 8439 -ne `wc -c <'typhoon/src/vlr.c'`; then
- echo shar: \"'typhoon/src/vlr.c'\" unpacked with wrong size!
- fi
- # end of 'typhoon/src/vlr.c'
- fi
- echo shar: End of archive 5 \(of 9\).
- cp /dev/null ark5isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 9 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
- exit 0 # Just in case...
-