home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume44
/
typhoon
/
part07
< prev
next >
Wrap
Internet Message Format
|
1994-09-17
|
62KB
From: zeppelin@login.dknet.dk (Thomas B. Pedersen)
Newsgroups: comp.sources.misc
Subject: v44i063: typhoon - Typhoon Relational Database Management System, Part07/09
Date: 17 Sep 1994 21:45:52 -0500
Organization: Sterling Software
Sender: kent@sparky.sterling.com
Approved: kent@sparky.sterling.com
Message-ID: <35g9l0$oj9@sparky.sterling.com>
X-Md4-Signature: d7cb176b74a98827291c741689971fa4
Submitted-by: zeppelin@login.dknet.dk (Thomas B. Pedersen)
Posting-number: Volume 44, Issue 63
Archive-name: typhoon/part07
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/ChangeLog typhoon/README typhoon/src/catalog.ddl
# typhoon/src/h/environ.h typhoon/src/os.c typhoon/src/readdbd.c
# typhoon/src/ty_log.c typhoon/src/ty_log.h typhoon/src/util/ddlp.h
# typhoon/src/util/ddlpglob.h typhoon/src/util/ddlplex.c
# typhoon/src/util/ddlpsym.h typhoon/src/util/exportlx.c
# typhoon/src/util/importlx.c
# Wrapped by kent@sparky on Sat Sep 17 21:38:18 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 7 (of 9)."'
if test -f 'typhoon/ChangeLog' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/ChangeLog'\"
else
echo shar: Extracting \"'typhoon/ChangeLog'\" \(139 characters\)
sed "s/^X//" >'typhoon/ChangeLog' <<'END_OF_FILE'
XVersion 1.01
X
X Just after releasing version 1.0 I was informed about two missing
X include files. Stupid mistake which has now been fixed.
END_OF_FILE
if test 139 -ne `wc -c <'typhoon/ChangeLog'`; then
echo shar: \"'typhoon/ChangeLog'\" unpacked with wrong size!
fi
# end of 'typhoon/ChangeLog'
fi
if test -f 'typhoon/README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/README'\"
else
echo shar: Extracting \"'typhoon/README'\" \(4237 characters\)
sed "s/^X//" >'typhoon/README' <<'END_OF_FILE'
X
X Typhoon Relational Database Management System v1.0
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-------------------------------------------------------------------------------
X
XTyphoon is a freely available relational database management system for
Xthe UNIX and OS/2 environments.
X
XThis release has been prepared in a hurry to get it out as quickly as
Xpossible. This means that the documentation is rather sparse, since I
Xhaven't had the time to write extensive documentation yet. However, most
Xof you out there are pretty clever, so you'll probably do fine with the
Xman pages and the examples.
X
XThe system works fine and is currently used in a number of professional
Xapplications in Denmark, some of them mission critical.
X
XThe system was originally inspired by Raima's db_VISTA (today Raima Data
XManager) but is relational rather than network based. Typhoon lacks some of
Xdb_VISTA's features, but also contains a number of nice features not found in
Xdb_VISTA.
X
XAll relations are defined in a so called Data Definition Language (ddl) file.
XYou define the database relations like you would write a C structure with
Xchars, ints, strings, multidimensional arrays, nested union and structures,
Xetc. Then you define primary, alternate and foreign keys for each relation.
XThe Data Definition Language Processor (ddlp) compiles the database defintion
Xinto a binary file which constitutes the database description. The database
Xrelations are accessed via C subroutines which manipulate individual records
Xwithin a table.
X
X - Multiple open database
X - Multi-field keys
X - Nested structures in records
X - Controlled unions
X - Referential integrity
X - Variable length fields
X - Null keys (optional keys in db_VISTA, but easier to use)
X - Dynamic opening and closing of database files
X
XAt present the database has no locking mechanism, believe it or not! The
Xprojects I have used it in, simply didn't need it, even though they were
Xmulti-user environments. But it's in the works!
X
XI am currently working on extending the library to support the following:
X
X - Locking
X - Logging
X - Transactions
X - Paging (to improve performance)
X
XThe library functions will remain intact, except for a number of new functions.
XI expect these things to be ready before the end of the year. Beta testers
Xare welcome.
X
XThe library comes with three additional utilities:
X
X dbdview - Displayes the database definitions.
X tyexport - Exports tables from a database.
X tyimport - Imports tables into a database.
X
XOriginally the library also contained online backup, restore and a replication
Xserver. These tools would need a lot of extra documentation, so I have left
Xthem out for now (the code still contains support for these utilities).
XHowever, if enough people show interest I will probably release them also.
X
X
X-------------------------------------------------------------------------------
X
XBug reports and mail should be sent to
X
X Thomas B. Pedersen
X zeppelin@login.dkuug.dk
X
XAlso, if you have any suggestions as to how I can improve the library,
Xdocumentation or anything else, please don't hesitate to mail me.
X
X
XRegards,
X
XThomas B. Pedersen
END_OF_FILE
if test 4237 -ne `wc -c <'typhoon/README'`; then
echo shar: \"'typhoon/README'\" unpacked with wrong size!
fi
# end of 'typhoon/README'
fi
if test -f 'typhoon/src/catalog.ddl' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/catalog.ddl'\"
else
echo shar: Extracting \"'typhoon/src/catalog.ddl'\" \(3814 characters\)
sed "s/^X//" >'typhoon/src/catalog.ddl' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : @(#)catalog.ddl 94/06/07 Copyright (c) 1993-94 Belle Systems
X * Library : typhoon
X * Version : 1.0
X * OS : UNIX, Solaris
X * Compiler: ddlp
X * Author : Thomas B. Pedersen
X *
X * Description:
X * Typhoon Database Definition Language file for System Catalog.
X *
X * Version control:
X * $Header: /usr/c/src_repository/CVSROOT/typhoon/src/catalog.ddl,v 1.1 1994/09/13 21:28:30 tbp Exp $
X * $Log: catalog.ddl,v $
X# Revision 1.1 1994/09/13 21:28:30 tbp
X# Added to repository.
X#
X *
X * History
X * ------------------------------
X * 10-Sep-1993 tbp Initial version.
X * 8-Dec-1993 tbp Added identification tag to sys_distab.
X * 13-Dec-1993 tbp Added sys_disfull table.
X * 20-Dec-1993 tbp Now udata need not be ASCIIZ.
X * 7-Jun-1994 tbp sys_dischange_key modified to avoid unnecessary resending
X * of records.
X *
X *--------------------------------------------------------------------------*/
X
Xdatabase catalog {
X
X data file "dissite.dat" contains sys_dissite;
X key file "dissite.ix1" contains sys_dissite.id;
X data file "distable.dat" contains sys_distab;
X key file "distable.ix1" contains sys_distab.sys_distab_key;
X data file "dischg.dat" contains sys_dischange;
X key file "dischg.ix1" contains sys_dischange.sys_dischange_key;
X data file "disprkey.dat" contains sys_disprkey;
X
X data file "disfultb.dat" contains sys_disfulltab;
X key file "disfultb.ix1" contains sys_disfulltab.fulltab_key;
X
X define SITES_MAX 296
X define SITEBITMAP_SIZE ((SITES_MAX+7)/8)
X define SITENAME_LEN 20
X define NUA_LEN 16
X define UDATA_LEN 16
X define KEYSIZE_MAX 255
X
X record sys_dissite {
X ulong id; // Site ID
X long last_call; // Time of last call.
X ushort tables; // Number of distributed tables on
X // this site
X char name[SITENAME_LEN+1]; // Mnemonic
X char nua[NUA_LEN+1]; // X.25 address
X char udata_len;
X char udata[UDATA_LEN]; // X.25 Call User Data
X char up_to_date; // 1=Site is completely up-to-date
X char in_error; // 1=Site is malfunctioning
X char spare[99];
X
X primary key id;
X }
X
X record sys_distab {
X long id; // Table ID
X long site_id; // Site ID
X long last_seqno; // Last seqno sent
X char tag; // Record identification tag
X char up_to_date; // 1=Table is up-to-date on site
X char spare[10];
X
X primary key sys_distab_key { site_id, id };
X }
X
X record sys_dischange {
X ulong seqno; // Sequence number
X long table_id; // Table ID
X long recno; // action='u': address of record
X // action='d': address of primary key
X // in sys_disprkey
X ushort sites; // Number of 1-bits in site[]
X uchar prog_id; // Program ID
X char action; // 'u'=update, 'd'=delete
X // Bitmap of unupdated sites, indexes
X // by Site ID. 0=up-to-date
X uchar site[SITEBITMAP_SIZE];
X
X// primary key sys_dischange_key { table_id, seqno };
X primary key sys_dischange_key { table_id, recno };
X }
X
X record sys_disprkey {
X ushort size;
X uchar buf[KEYSIZE_MAX];
X }
X
X /*
X * When a new site is inserted in the catalog, a record of type
X * <sys_disfulltab> is created for each record inserted in <sys_distab>.
X *
X * The <sys_disfulltab> is used to control that the site receives all tables
X * from scratch, before being updated from <sys_dischg>. When entries
X * are present in the <sys_disfulltab>, the <updatable> flags in
X * <sys_dissite> must be 0.
X */
X
X record sys_disfulltab {
X long site_id; // Site ID
X ulong table_id; // Table ID
X ulong curr_rec; // Last record read in seq. scan
X
X primary key fulltab_key { site_id, table_id };
X }
X
X}
X
X/* end-of-file */
END_OF_FILE
if test 3814 -ne `wc -c <'typhoon/src/catalog.ddl'`; then
echo shar: \"'typhoon/src/catalog.ddl'\" unpacked with wrong size!
fi
# end of 'typhoon/src/catalog.ddl'
fi
if test -f 'typhoon/src/h/environ.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/h/environ.h'\"
else
echo shar: Extracting \"'typhoon/src/h/environ.h'\" \(4190 characters\)
sed "s/^X//" >'typhoon/src/h/environ.h' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : environ.h
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 * Multi Operating System compatibility include file.
X *
X * $Id: environ.h,v 1.1 1994/09/17 15:59:13 tbp Exp $
X *
X * $Log: environ.h,v $
X * Revision 1.1 1994/09/17 15:59:13 tbp
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
X#ifndef _ENVIRON_INCLUDED
X#define _ENVIRON_INCLUDED
X
X
X/*--------------------------------------------------------------------------*/
X/* UNIX System V */
X/*--------------------------------------------------------------------------*/
X
X#ifdef UNIX
X
X#define CREATMASK 0666
X#ifndef O_BINARY
X#define O_BINARY 0
X#endif
X#define DIR_SWITCH '/'
X
X#if defined(sun)
X# define PROTOTYPES 1
X# define BIG_ENDIAN 1
X# define RISC 1
X#elif defined(__nonstopux)
X# define PROTOTYPES 1
X# define BIG_ENDIAN 1
X# define RISC 1
X#elif defined(__linux__)
X# define PROTOTYPES 1
X# define LITTLE_ENDIAN 1
X#else /* presumably Intel */
X# define SCO 1
X# define PROTOTYPES 1
X# define LITTLE_ENDIAN 1
X#endif
X
Xtypedef unsigned char uchar;
X#ifndef _SYS_TYPES_H
X typedef unsigned short ushort;
X typedef unsigned long ulong;
X#endif
X
X#endif
X
X/*--------------------------------------------------------------------------*/
X/* OS/2 v2.0 */
X/*--------------------------------------------------------------------------*/
X
X#ifdef OS2
X#ifdef __BORLANDC__
X# define __STDC__ 1
X#endif
X#define DIR_SWITCH '\\'
X#define CREATMASK (S_IREAD|S_IWRITE)
X#define PROTOTYPES 1
X#define LITTLE_ENDIAN 1
X
Xtypedef unsigned char uchar;
Xtypedef unsigned short ushort;
Xtypedef unsigned long ulong;
X
X#endif
X
X
X/*--------------------------------------------------------------------------*/
X/* DOS */
X/*--------------------------------------------------------------------------*/
X
X#ifdef DOS
X
X#define DIR_SWITCH '\\'
X#define CREATMASK (S_IREAD|S_IWRITE)
X#define PROTOTYPES 1
X#define LITTLE_ENDIAN 1
X
Xtypedef unsigned char uchar;
Xtypedef unsigned short ushort;
Xtypedef unsigned long ulong;
X
X#endif
X
X
X#ifdef PROTOTYPES
X# define PRM(x) x
X# define _PRM(x) x
X# define ELLIPSIS ,...
X#else
X# define PRM(x) ();
X# define _PRM(x) ()
X# define ELLIPSIS /**/
X#endif
X
X#ifndef offsetof
X# define offsetof(s,m) ((int)&(((s *)0))->m)
X#endif
X
X#ifdef BIG_ENDIAN
X# define SWAPTOSHORT(i) (((i) >> 8) & 0xff | (i & 0xff) << 8)
X# define SWAPTOLONG(l) ((((l) & 0xff) << 24) | (((l) & 0xff00) << 8) | \
X (((l) >> 8) & 0xff00) | (((l) >> 24) & 0xff))
X# define SWAPSHORT(i) i = SWAPTOSHORT(i)
X# define SWAPLONG(l) l = SWAPTOLONG(l)
X#else
X# define SWAPTOSHORT(i) i
X# define SWAPTOLONG(l) l
X# define SWAPSHORT(i) (void)0
X# define SWAPLONG(l) (void)0
X# define SWAP(l) (void)0
X#endif
X
X
X#endif
X
X/* end-of-file */
END_OF_FILE
if test 4190 -ne `wc -c <'typhoon/src/h/environ.h'`; then
echo shar: \"'typhoon/src/h/environ.h'\" unpacked with wrong size!
fi
# end of 'typhoon/src/h/environ.h'
fi
if test -f 'typhoon/src/os.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/os.c'\"
else
echo shar: Extracting \"'typhoon/src/os.c'\" \(4356 characters\)
sed "s/^X//" >'typhoon/src/os.c' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : os.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 that may vary between different operating systems
X * such as opening and locking files.
X *
X * Functions:
X * os_lock Get exclusive access to the database.
X * os_unlock Release the lock.
X *
X * $Log: os.c,v $
X * Revision 1.1 1994/09/13 21:28:31 tbp
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
Xstatic char rcsid[] = "$Id";
X
X#ifdef UNIX
X# include <sys/types.h>
X# include <sys/stat.h>
X# include <unistd.h>
X#endif
X#ifdef __linux__
X# include <sys/file.h>
X# define F_TLOCK LOCK_NB
X# define F_LOCK LOCK_EX
X# define F_ULOCK LOCK_UN
X# define lockf(fd,op,len) flock(fd,op)
X#endif
X#ifdef _MSC_VER
X# include <sys/types.h>
X# include <sys/stat.h>
X# include <sys/locking.h>
X#endif
X#ifdef __BORLANDC__
X# include <sys\locking.h>
X# include <io.h>
X#endif
X#ifdef __IBMC__
X#include <io.h>
X#include <share.h>
X#endif
X#include <fcntl.h>
X#include <stdio.h>
X
X
X/*--------------------------------- os_lock --------------------------------*\
X *
X * Purpose : Lock a region of a file.
X *
X * Parameters: fh - File handle.
X * offset - Offset from start of file.
X * bytes - Number of bytes to lock.
X * type - Lock type. 't'=test and lock, 'w'=wait and lock
X *
X *
X * Returns : -1 - The region could not be locked.
X * 0 - Region locked.
X *
X */
X
Xos_lock(fh, offset, bytes, type)
Xint fh;
Xlong offset;
Xunsigned bytes;
X{
X lseek(fh, offset, SEEK_SET);
X#ifdef DOS
X /* Microsoft C */
X# ifdef _MSC_VER
X if( locking(fh, type == 't' ? LK_NBLCK : LK_LOCK, bytes) == -1 )
X return -1;
X# endif
X#endif
X#ifdef UNIX
X if( lockf(fh, type == 't' ? F_TLOCK : F_LOCK, bytes) == -1 )
X puts("lockf failed");
X#endif
X#ifdef OS2
X# ifdef __BORLANDC__
X if( locking(fh, type == 't' ? LK_NBLCK : LK_LOCK, bytes) == -1 )
X return -1;
X# endif
X#endif
X
X return 0;
X}
X
X/*-------------------------------- os_unlock -------------------------------*\
X *
X * Purpose : Unlock a region of a file.
X *
X * Parameters: fh - File handle.
X * offset - Offset from start of file.
X * bytes - Number of bytes to lock.
X * type - Lock type. 't'=test and lock, 'w'=wait and lock
X *
X *
X * Returns : -1 - The region could not be unlocked.
X * 0 - Region unlocked.
X *
X */
X
Xos_unlock(fh, offset, bytes)
Xint fh;
Xlong offset;
Xunsigned bytes;
X{
X lseek(fh, offset, SEEK_SET);
X#ifdef DOS
X /* Microsoft C */
X# ifdef _MSC_VER
X return locking(fh, LK_UNLCK, bytes);
X# endif
X#endif
X#ifdef UNIX
X return lockf(fh, F_ULOCK, bytes);
X#endif
X#ifdef OS2
X# ifdef __BORLANDC__
X return locking(fh, LK_UNLCK, bytes);
X# endif
X#endif
X}
X
X
X
X
Xos_open(fname, flags, creatflags)
Xchar *fname;
Xint flags, creatflags;
X{
X#ifdef __IBMC__
X return sopen(fname, flags, SH_DENYNO, creatflags);
X#else
X return open(fname, flags, creatflags);
X#endif
X}
X
X
X
Xos_close(fh)
Xint fh;
X{
X return close(fh);
X}
X
X
Xos_access(fname, mode)
Xchar *fname;
Xint mode;
X{
X#ifdef __IBMC__
X return _access(fname, mode);
X#else
X return access(fname, mode);
X#endif
X}
X
X/* end-of-file */
END_OF_FILE
if test 4356 -ne `wc -c <'typhoon/src/os.c'`; then
echo shar: \"'typhoon/src/os.c'\" unpacked with wrong size!
fi
# end of 'typhoon/src/os.c'
fi
if test -f 'typhoon/src/readdbd.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/readdbd.c'\"
else
echo shar: Extracting \"'typhoon/src/readdbd.c'\" \(3894 characters\)
sed "s/^X//" >'typhoon/src/readdbd.c' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : readdbd.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 a function that reads the dbd-file.
X *
X * Functions:
X * read_dbdfile - Read the database description file.
X *
X * $Log: readdbd.c,v $
X * Revision 1.2 1994/09/17 16:00:14 tbp
X * typhoon.h and environ.h are now included from <>.
X *
X * Revision 1.1 1994/09/13 21:28:32 tbp
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
Xstatic char rcsid[] = "$Id: readdbd.c,v 1.2 1994/09/17 16:00:14 tbp Exp $";
X
X#ifdef UNIX
X# include <unistd.h>
X# include <stdio.h>
X# ifdef __STDC__
X# include <stdlib.h>
X# endif
X#else
X# include <stdlib.h>
X# include <io.h>
X#endif
X#include <stdio.h>
X#include <fcntl.h>
X#include <errno.h>
X#include <typhoon.h>
X#include "ty_dbd.h"
X#include "ty_type.h"
X#include "ty_glob.h"
X
X
X/*------------------------------ read_dbdfile ------------------------------*\
X *
X * Purpose : Reads the dbd-file into a available database slot provided
X * by the calling function. The table pointers in the slot are
X * also set up.
X *
X * Parameters: _db - Pointer to database entry slot.
X * fname - The name of the dbd-file.
X *
X * Returns : S_OKAY - dbd-file successfully read.
X * S_NOMEM - Not enough memory to allocate tables.
X * S_INVDB - Cannot find dbd-file.
X * S_IOFATAL - The dbd-file is corrupted.
X *
X */
X
Xread_dbdfile(_db, fname)
XDbentry *_db;
Xchar *fname;
X{
X int dbdfile, size;
X
X if( (dbdfile = os_open(fname, O_RDONLY|O_BINARY)) == -1 )
X RETURN S_INVDB;
X
X /*
X * Get the size of the dbd-file, read the header and expand to buffer
X * to hold a table of file handles.
X */
X size = lseek(dbdfile, 0, SEEK_END);
X lseek(dbdfile, 0, SEEK_SET);
X
X if( read(dbdfile, &_db->header, sizeof _db->header) < sizeof(_db->header) )
X RETURN S_IOFATAL;
X
X if( strcmp(_db->header.version, DBD_VERSION) )
X RETURN S_VERSION;
X
X size -= sizeof _db->header;
X
X if( !(_db->dbd = (void *)malloc(size + _db->header.files * sizeof(Fh))) )
X {
X close(dbdfile);
X RETURN S_NOMEM;
X }
X
X read(dbdfile, _db->dbd, size);
X close(dbdfile);
X
X /* Set up pointers to tables */
X _db->file = (File *)_db->dbd;
X _db->key = (Key *)(_db->file + _db->header.files);
X _db->keyfield = (KeyField *)(_db->key + _db->header.keys);
X _db->record = (Record *)(_db->keyfield + _db->header.keyfields);
X _db->field = (Field *)(_db->record + _db->header.records);
X _db->structdef = (Structdef*)(_db->field + _db->header.fields);
X _db->fh = (Fh *)(_db->structdef+ _db->header.structdefs);
X
X return S_OKAY;
X}
X
X
X/* end-of-file */
END_OF_FILE
if test 3894 -ne `wc -c <'typhoon/src/readdbd.c'`; then
echo shar: \"'typhoon/src/readdbd.c'\" unpacked with wrong size!
fi
# end of 'typhoon/src/readdbd.c'
fi
if test -f 'typhoon/src/ty_log.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/ty_log.c'\"
else
echo shar: Extracting \"'typhoon/src/ty_log.c'\" \(4653 characters\)
sed "s/^X//" >'typhoon/src/ty_log.c' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : ty_log.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 function that write to the Replication Server log.
X *
X * Functions:
X *
X * $Log: ty_log.c,v $
X * Revision 1.2 1994/09/17 16:00:18 tbp
X * typhoon.h and environ.h are now included from <>.
X *
X * Revision 1.1 1994/09/13 21:28:35 tbp
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
Xstatic char rcsid[] = "$Id: ty_log.c,v 1.2 1994/09/17 16:00:18 tbp Exp $";
X
X#include <sys/types.h>
X#include <unistd.h>
X#include <stdio.h>
X#include <fcntl.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/*-------------------------- Function prototypes ---------------------------*/
Xstatic do_log PRM( (ulong, ulong); )
X
X
X/*---------------------------- Global variables ----------------------------*/
Xstatic int log_fh = -1; /* Log file handle */
Xstatic int log_trans = 0; /* True if the current transaction was */
X /* started during backup */
X
X/*--------------------------------------------------------------------------*\
X *
X * Function : do_log
X *
X * Purpose : This function checks whether an operation should be logged or
X * not. If yes, the log file is opened if not already open.
X * If the backup is no longer active, the log file is closed.
X *
X * Parameters:
X *
X * Returns :
X *
X */
Xstatic do_log(recid, recno)
Xulong recid, recno;
X{
X if( !DB->shm->backup_active && !log_trans )
X {
X if( log_fh != -1 )
X {
X close(log_fh);
X log_fh = -1;
X }
X return -1;
X }
X
X if( recid > DB->shm->curr_recid && recno > DB->shm->curr_recno )
X return -1;
X
X if( log_fh == -1 )
X {
X log_fh = os_open(LOG_FNAME, O_RDWR|O_APPEND|O_CREAT, CREATMASK);
X
X if( log_fh == -1 )
X {
X puts("cannot open log");
X return -1;
X }
X }
X
X return 0;
X}
X
X
X
X/*--------------------------------------------------------------------------*\
X *
X * Function : Log a record update.
X *
X * Purpose :
X *
X * Parameters:
X *
X * Returns :
X *
X */
Xlog_update(recid, recno, size, data)
Xulong recid;
Xulong recno;
Xunsigned size;
Xvoid *data;
X{
X LogUpdate update;
X
X if( do_log(recid, recno) == -1 )
X return 0;
X
X os_lock(log_fh, 0, 1, 'u');
X
X#ifdef RISC
X if( size & 3 )
X size += 4 - (size & 3);
X#endif
X
X update.id = LOG_UPDATE;
X update.len = size + sizeof update;
X update.recid = recid;
X update.recno = recno;
X
X write(log_fh, &update, sizeof update);
X write(log_fh, data, size);
X
X os_unlock(log_fh, 0, 1);
X}
X
X
Xlog_delete(recid, recno)
Xulong recid, recno;
X{
X LogDelete delete;
X
X if( do_log(recid, recno) == -1 )
X return 0;
X
X os_lock(log_fh, 0, 1, 'u');
X
X delete.id = LOG_UPDATE;
X delete.len = sizeof delete;
X delete.recid = recid;
X delete.recno = recno;
X
X write(log_fh, &delete, sizeof delete);
X
X os_unlock(log_fh, 0, 1);
X}
X
X
X/*--------------------------------------------------------------------------*\
X *
X * Function :
X *
X * Purpose :
X *
X * Parameters:
X *
X * Returns :
X *
X */
XFNCLASS d_beginwork()
X{
X if( DB->shm->backup_active )
X {
X DB->shm->num_trans_active++;
X log_trans = 1;
X }
X
X return S_OKAY;
X}
X
X
X
XFNCLASS d_commitwork()
X{
X if( log_trans )
X {
X log_trans = 0;
X DB->shm->num_trans_active--;
X }
X}
X
X
X
XFNCLASS d_abortwork()
X{
X if( log_trans )
X {
X log_trans =0 ;
X DB->shm->num_trans_active--;
X }
X}
X
X/* end-of-file */
END_OF_FILE
if test 4653 -ne `wc -c <'typhoon/src/ty_log.c'`; then
echo shar: \"'typhoon/src/ty_log.c'\" unpacked with wrong size!
fi
# end of 'typhoon/src/ty_log.c'
fi
if test -f 'typhoon/src/ty_log.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/ty_log.h'\"
else
echo shar: Extracting \"'typhoon/src/ty_log.h'\" \(3637 characters\)
sed "s/^X//" >'typhoon/src/ty_log.h' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : ty_log.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 used for online backup.
X *
X * $Id: ty_log.h,v 1.1 1994/09/13 21:28:36 tbp Exp $
X *
X * $Log: ty_log.h,v $
X * Revision 1.1 1994/09/13 21:28:36 tbp
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
X#define LOG_FNAME "typhoon.log"
X#define LOG_UPDATE 1
X#define LOG_DELETE 2
X
Xtypedef struct {
X short id; /* = LOG_INSERT */
X ushort len; /* Length of entire block */
X ulong recid;
X ulong recno;
X/* char data[1];*/
X} LogUpdate;
X
Xtypedef struct {
X short id; /* = LOG_DELETE */
X ushort len; /* Length of entire block */
X ulong recid;
X ulong recno;
X} LogDelete;
X
X
X#define ARCHIVE_MEDIA 1
X#define ARCHIVE_RECORD 2
X#define ARCHIVE_FILE 3
X#define ARCHIVE_FILEDATA 4
X#define ARCHIVE_TABLE 5
X#define ARCHIVE_END 6
X
X#define ARCHIVE_BLOCK 99
X
Xtypedef struct {
X ulong id; /* = ARCHIVE_MEDIA */
X char dbname[DBNAME_LEN+1];
X char spare[3];
X long date; /* Date of backup */
X ulong seqno; /* Media number in backup */
X char spare2[512];
X} ArchiveMediaHeader;
X
Xtypedef struct {
X ulong id; /* = ARCHIVE_RECORD */
X ulong recid;
X ulong recno;
X} ArchiveRecordHeader;
X
Xtypedef struct {
X ulong id; /* = ARCHIVE_FILE */
X ulong recsize;
X char table[IDENT_LEN+1];
X char fname[128];
X} ArchiveTableHeader;
X
Xtypedef struct {
X ulong id; /* = ARCHIVE_FILE */
X char fname[128];
X} ArchiveFileHeader;
X
Xtypedef struct {
X ulong id; /* = ARCHIVE_FILEDATA */
X ulong size;
X} ArchiveFileDataHeader;
X
Xtypedef struct {
X ulong id; /* = ARCHIVE_END */
X} ArchiveEnd;
X
Xtypedef struct {
X ulong id;
X ulong size;
X} ArchiveBlockHeader;
X
X
X/*
X Archive structure
X ==============================
X
X [MediaHeader]
X
X [FileHeader] ----+
X [FileDataHeader] |
X data +--- dbd-file
X [FileDataHeader] |
X data |
X ... |
X [FileDataHeader size=0] ----+
X
X [TableHeader] ----+
X [RecordHeader] |
X record |
X [RecordHeader] +--- database
X record |
X ... |
X [RecordHeader] |
X record ----+
X
X [FileHeader] ----+
X [FileDataHeader] |
X data +--- log file
X [FileDataHeader] |
X data |
X ... |
X [FileDataHeader size=0] ----+
X
X [End]
X*/
X
X
X/* end-of-file */
END_OF_FILE
if test 3637 -ne `wc -c <'typhoon/src/ty_log.h'`; then
echo shar: \"'typhoon/src/ty_log.h'\" unpacked with wrong size!
fi
# end of 'typhoon/src/ty_log.h'
fi
if test -f 'typhoon/src/util/ddlp.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/util/ddlp.h'\"
else
echo shar: Extracting \"'typhoon/src/util/ddlp.h'\" \(3235 characters\)
sed "s/^X//" >'typhoon/src/util/ddlp.h' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : ddlp.h
X * Program : ddlp
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 * ddlp header file.
X *
X * $Id: ddlp.h,v 1.1 1994/09/13 21:28:52 tbp Exp $
X *
X * $Log: ddlp.h,v $
X * Revision 1.1 1994/09/13 21:28:52 tbp
X * Added to repository.
X *
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
X/*-------------------------------- Constants -------------------------------*/
X#define RECORDS_MAX 256 /* Maximum number of records */
X#define STRUCTDEFS_MAX 256 /* Maximum number of structure definitions */
X#define FIELDS_MAX 512 /* Maximum number of fields */
X#define FILES_MAX 512 /* Maximum number of files */
X#define KEYS_MAX 256 /* Maximum number of keys */
X#define KEYFIELDS_MAX 1024 /* Maximum number of key fields */
X#define DEFINES_MAX 200 /* Maximum number of defines */
X#define CONTAINS_MAX 512 /* Maximum number of contains statements */
X
X/*
X * This structure contains integer constants defined in the database
X * definition. These definitions are exported to the header file.
X */
X
Xtypedef struct {
X int value;
X char name[IDENT_LEN+1];
X} Define;
X
X
X/*------------------------------- ddlp.c -----------------------------------*/
Xvoid err_quit PRM( (char * ELLIPSIS); )
Xvoid align_offset PRM( (unsigned *, int); )
Xvoid add_key PRM( (char *); )
Xvoid add_keyfield PRM( (Id, int); )
Xvoid add_define PRM( (char *, int); )
Xvoid add_file PRM( (int, char *, unsigned); )
Xvoid add_contains PRM( (int, char *, char *); )
Xvoid add_record PRM( (char *); )
Xvoid add_field PRM( (char *, int); )
Xvoid add_structdef PRM( (char *, int, int); )
Xvoid check_foreign_key PRM( (char *, Key *); )
X
X/*-------------------------------- ddl.y -----------------------------------*/
Xint yyerror PRM( (char * ELLIPSIS); )
X
X/*------------------------------- ddlplex.c --------------------------------*/
Xvoid init_lex PRM( (void); )
X
X
X/* end-of-file */
END_OF_FILE
if test 3235 -ne `wc -c <'typhoon/src/util/ddlp.h'`; then
echo shar: \"'typhoon/src/util/ddlp.h'\" unpacked with wrong size!
fi
# end of 'typhoon/src/util/ddlp.h'
fi
if test -f 'typhoon/src/util/ddlpglob.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/util/ddlpglob.h'\"
else
echo shar: Extracting \"'typhoon/src/util/ddlpglob.h'\" \(4316 characters\)
sed "s/^X//" >'typhoon/src/util/ddlpglob.h' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : ddlpglob.h
X * Program : ddlp
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 global variables for ddlp.
X *
X * $Id: ddlpglob.h,v 1.1 1994/09/13 21:28:53 tbp Exp $
X *
X * $Log: ddlpglob.h,v $
X * Revision 1.1 1994/09/13 21:28:53 tbp
X * Added to repository.
X *
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
X#ifdef DEFINE_GLOBALS
X#define CLASS
X#define I(x) = x
X#else
X#define CLASS extern
X#define I(x)
X#endif
X
XCLASS int varlen_field_occurred /* True if a varlen field */
X I( 0 ); /* has occurred in the rec */
XCLASS sym_member*size_field I( NULL ); /* This var contains the */
X /* name of the size field */
X /* of a varlen field */
XCLASS int only_keys I( 0 ); /* Only extract key consts? */
XCLASS int warnholes I( 0 ); /* Warn about align. holes */
XCLASS int lex_lineno I( 1 ); /* Current line number */
XCLASS int errors I( 0 ); /* Number of errors */
XCLASS int dbpg_size I( 512 ); /* Database page size */
XCLASS int align I( 1 ); /* Structure alignment */
XCLASS int conts I( 0 ); /* Number of contains */
XCLASS int defines I( 0 ); /* Number of defines */
XCLASS unsigned dims I( 0 ); /* Number of dimensions */
XCLASS unsigned dim[20]; /* Array dimension */
XCLASS char dbname[DBNAME_LEN+1]; /* Database name */
XCLASS char dbdname[256]; /* .dbd file name */
XCLASS char ddlname[256]; /* .ddl file name */
XCLASS char hname[256]; /* Header file name */
XCLASS Define define[DEFINES_MAX];
XCLASS Contains contains[CONTAINS_MAX];
X
X
X/*------------------- These tables go into the .dbd-file -------------------*/
XCLASS Header header; /* .dbd file header */
XCLASS Record *record; /* Record table */
XCLASS Field *field; /* Field table */
XCLASS File *file; /* File table */
XCLASS Key *key; /* Key table */
XCLASS KeyField *keyfield; /* Key field table */
XCLASS Structdef *structdef; /* Struct definition table */
X
XCLASS int records I( 0 ); /* Number of records in db */
XCLASS int fields I( 0 ); /* Number of fields in db */
XCLASS int files I( 0 ); /* Number of files in dbase */
XCLASS int keys I( 0 ); /* # of entries in key */
XCLASS int keyfields I( 0 ); /* # of entries in keyfield */
XCLASS int structdefs I( 0 ); /* # of entries in structdef*/
X
X#ifdef DEFINE_GLOBALS
X
Xstruct {
X char type;
X short size;
X char *name;
X} typeinfo[] = {
X FT_CHAR, sizeof(char), "char",
X FT_CHARSTR, sizeof(char), "char",
X FT_SHORT, sizeof(short), "short",
X FT_INT, sizeof(int), "int",
X FT_LONG, sizeof(long), "long",
X FT_FLOAT, sizeof(float), "float",
X FT_DOUBLE, sizeof(double), "double",
X#ifdef __STDC__
X FT_LDOUBLE, sizeof(long double),"long double",
X#else
X FT_LDOUBLE, sizeof(double), "double"
X#endif
X};
X
X#else
X
Xextern struct {
X char type;
X short size;
X char *name;
X} typeinfo[];
X
X
X
X#endif
X
X/* end-of-file */
END_OF_FILE
if test 4316 -ne `wc -c <'typhoon/src/util/ddlpglob.h'`; then
echo shar: \"'typhoon/src/util/ddlpglob.h'\" unpacked with wrong size!
fi
# end of 'typhoon/src/util/ddlpglob.h'
fi
if test -f 'typhoon/src/util/ddlplex.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/util/ddlplex.c'\"
else
echo shar: Extracting \"'typhoon/src/util/ddlplex.c'\" \(4382 characters\)
sed "s/^X//" >'typhoon/src/util/ddlplex.c' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : ddlplex.c
X * Program : ddlp
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 * Lexical analyser for ddlp.
X *
X * $Log: ddlplex.c,v $
X * Revision 1.2 1994/09/17 16:00:51 tbp
X * typhoon.h and environ.h are now included from <>.
X *
X * Revision 1.1 1994/09/13 21:28:53 tbp
X * Added to repository.
X *
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
Xstatic char rcsid[] = "$Id: ddlplex.c,v 1.2 1994/09/17 16:00:51 tbp Exp $";
X
X#include <ctype.h>
X#include <stdio.h>
X#include <string.h>
X#ifndef UNIX
X# include <stdlib.h>
X#endif
X
X#include <typhoon.h>
X#include "../ty_dbd.h"
X#include "ddlp.h"
X#include "ddl_y.h"
X#include "ddlpsym.h"
X#include "ddlpglob.h"
X#include "lex.h"
X#include "lex.c"
X
X/*---------------------------- Global variables ----------------------------*/
Xextern FILE *lex_file; /* input file */
Xextern int lex_lineno; /* current line number */
X
XLEX_KEYWORD lex_keywordtab[] = {
X T_ALTERNATE, "alternate",
X T_ASC, "asc",
X T_BY, "by",
X T_CASCADE, "cascade",
X T_CHAR, "char",
X T_CONTAINS, "contains",
X T_CONTROLLED, "controlled",
X T_DATA, "data",
X T_DATABASE, "database",
X T_DEFINE, "define",
X T_DELETE, "delete",
X T_DESC, "desc",
X T_DOUBLE, "double",
X T_FILE, "file",
X T_FLOAT, "float",
X T_FOREIGN, "foreign",
X T_INT, "int",
X T_KEY, "key",
X T_LONG, "long",
X T_MAP, "map",
X T_NULL, "null",
X T_ON, "on",
X T_PRIMARY, "primary",
X T_RECORD, "record",
X T_REFERENCES, "references",
X T_RESTRICT, "restrict",
X T_SHORT, "short",
X T_SIGNED, "signed",
X T_STRUCT, "struct",
X T_UCHAR, "uchar",
X T_ULONG, "ulong",
X T_UNION, "union",
X T_UNIQUE, "unique",
X T_UNSIGNED, "unsigned",
X T_UPDATE, "update",
X T_USHORT, "ushort",
X T_VARIABLE, "variable"
X};
X
Xint lex_keywords = sizeof(lex_keywordtab) / sizeof(lex_keywordtab[0]);
X
Xyylex()
X{
X int c, i;
X
X for( ;; )
X {
X c = getc(lex_file);
X
X if( c == ' ' || c == '\t' ) /* skip whitespace */
X ;
X else if( isalpha(c) ) /* keyword */
X return lex_parse_keyword(c);
X else if( isdigit(c) ) /* number */
X return lex_parse_number(c);
X else if( c == '"' ) /* string */
X return lex_parse_string();
X else if ( c== '\'' )
X return lex_parse_charconst(); /* character constant */
X else if( c == '\n' ) /* increase line count */
X lex_lineno++;
X else if( c == EOF )
X return EOF;
X else if( c == '/' )
X {
X if( (c = getc(lex_file)) == '*' ) /* C comment */
X lex_skip_comment();
X else if( c == '/' ) /* C++ comment */
X {
X while( getc(lex_file) != '\n' && !feof(lex_file) )
X ;
X lex_lineno++;
X }
X else
X {
X ungetc(c, lex_file);
X return '/';
X }
X }
X else if( c == '-' )
X {
X if( (c=getc(lex_file)) == '>' )
X return T_ARROW;
X ungetc(c, lex_file);
X return '-';
X }
X else if( strchr("[]{};,+*().", c) )
X return c;
X else if( c == '#' )
X {
X while( getc(lex_file) != '\n' && !feof(lex_file) )
X ;
X lex_lineno++;
X }
X else
X yyerror("syntax error");
X }
X}
X
X/* end-of-file */
END_OF_FILE
if test 4382 -ne `wc -c <'typhoon/src/util/ddlplex.c'`; then
echo shar: \"'typhoon/src/util/ddlplex.c'\" unpacked with wrong size!
fi
# end of 'typhoon/src/util/ddlplex.c'
fi
if test -f 'typhoon/src/util/ddlpsym.h' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/util/ddlpsym.h'\"
else
echo shar: Extracting \"'typhoon/src/util/ddlpsym.h'\" \(4337 characters\)
sed "s/^X//" >'typhoon/src/util/ddlpsym.h' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : ddlpsym.h
X * Program : ddlp
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 * Symbol table definitions.
X *
X * $Id: ddlpsym.h,v 1.1 1994/09/13 21:28:54 tbp Exp $
X *
X * $Log: ddlpsym.h,v $
X * Revision 1.1 1994/09/13 21:28:54 tbp
X * Added to repository.
X *
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
X/* The following constants define translation limits of the parser according to
X * ISO/IEC DIS 9899 section 2.2.41.
X */
X
X#define NEST_MAX 15 /* Max nesting level */
X#define NAME_LEN 31 /* Number of significant initial*/
X /* characters in a name */
X
Xtypedef struct sym_member {
X char type; /* See FT_.. constants */
X char name[NAME_LEN+1]; /* Member name */
X unsigned elemsize; /* Size of each element */
X unsigned size; /* sizeof (total size incl. dim)*/
X unsigned offset; /* Offset from start of struct */
X struct sym_member *next; /* Next member */
X struct sym_struct *struc; /* If type is FT_STRUCT this */
X /* points to the structdef that */
X /* defines the struct type */
X /*---------- ddlp extensions -------------------------------------------*/
X Id id; /* Field id */
X /*----------------------------------------------------------------------*/
X unsigned dims; /* Number of dimensions */
X unsigned dim[1]; /* Dimensions if <dims> > 0 */
X} sym_member;
X
Xtypedef struct sym_struct {
X char name[NAME_LEN+1]; /* Struct name */
X char printed; /* This field ensures that the */
X /* full structure definition is */
X /* printed once only. */
X char is_union; /* True if this is a union */
X unsigned size; /* sizeof */
X unsigned members; /* Number of members */
X sym_member *first_member; /* First member */
X sym_member *last_member; /* Last member */
X struct sym_struct *next; /* Next structdef */
X /*---------- ddlp extensions -------------------------------------------*/
X Id fieldid; /* Field id */
X /*----------------------------------------------------------------------*/
X} sym_struct;
X
X
X
X/*
X +--------+ +--------+ +--------+ +--------+
X | struct |--->| member |--->| member |--->| member |--->NULL
X +--------+ +--------+ +--------+ +--------+
X |
X |
X v
X +--------+ +--------+ +--------+ +--------+
X | struct |--->| member |--->| member |--->| member |--->NULL
X +--------+ +--------+ +--------+ +--------+
X |
X |
X v
X +--------+ +--------+
X | struct |--->| member |
X +--------+ +--------+
X |
X |
X v
X NULL
X*/
X
Xextern sym_struct *structnest[], *cur_str, *last_str;
Xextern int curnest;
X
Xvoid sym_addmember PRM( (char *, int, sym_struct *); )
Xvoid sym_addstruct PRM( (char *, int); )
Xvoid sym_endstruct PRM( (void); )
Xsym_struct *sym_findstruct PRM( (char *, int); )
Xsym_member *sym_findmember PRM( (sym_struct *, char *); )
Xvoid print_structures PRM( (void); )
X
X
X/* end-of-file */
END_OF_FILE
if test 4337 -ne `wc -c <'typhoon/src/util/ddlpsym.h'`; then
echo shar: \"'typhoon/src/util/ddlpsym.h'\" unpacked with wrong size!
fi
# end of 'typhoon/src/util/ddlpsym.h'
fi
if test -f 'typhoon/src/util/exportlx.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/util/exportlx.c'\"
else
echo shar: Extracting \"'typhoon/src/util/exportlx.c'\" \(3344 characters\)
sed "s/^X//" >'typhoon/src/util/exportlx.c' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : exportlx.c
X * Program : tyexport
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 * Lexical analyser for export utility.
X *
X * $Log: exportlx.c,v $
X * Revision 1.2 1994/09/17 16:00:53 tbp
X * typhoon.h and environ.h are now included from <>.
X *
X * Revision 1.1 1994/09/13 21:28:56 tbp
X * Added to repository.
X *
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
Xstatic char rcsid[] = "$Id: exportlx.c,v 1.2 1994/09/17 16:00:53 tbp Exp $";
X
X#include <ctype.h>
X#include <stdio.h>
X#include <string.h>
X#ifndef UNIX
X# include <stdlib.h>
X#endif
X
X#include <environ.h>
X#include "../ty_dbd.h"
X#include "ddlp.h"
X#include "exp_y.h"
X#include "ddlpsym.h"
X#include "ddlpglob.h"
X#include "lex.h"
X#include "lex.c"
X
X/*---------------------------- Global variables ----------------------------*/
XFILE *lex_file; /* input file */
X
X
XLEX_KEYWORD lex_keywordtab[] = {
X T_EXPORT, "export",
X T_IN, "in",
X T_RECORD, "record",
X T_STRUCT, "struct",
X T_UNION, "union"
X};
Xint lex_keywords = sizeof(lex_keywordtab) / sizeof(lex_keywordtab[0]);
X
X
X
Xyylex()
X{
X int c, i;
X
X for( ;; )
X {
X c = getc(lex_file);
X
X if( c == ' ' || c == '\t' ) /* skip whitespace */
X ;
X else if( isalpha(c) ) /* keyword */
X return lex_parse_keyword(c);
X#if 0
X else if( isdigit(c) ) /* number */
X return lex_parse_number(c);
X#endif
X else if( c == '"' ) /* string */
X return lex_parse_string();
X else if( c == '\n' ) /* increase line count */
X lex_lineno++;
X else if( c == EOF )
X return EOF;
X else if( strchr("[]{};,+*-().", c) )
X return c;
X else if( c == '/' )
X {
X if( (c = getc(lex_file)) == '*' )/* C comment */
X lex_skip_comment();
X else if( c == '/' ) /* C++ comment */
X {
X while( getc(lex_file) != '\n' && !feof(lex_file) )
X ;
X lex_lineno++;
X }
X else
X {
X ungetc(c, lex_file);
X return '/';
X }
X }
X else
X yyerror("unexpected character '%s'", c);
X }
X}
X
X/* end-of-file */
X
END_OF_FILE
if test 3344 -ne `wc -c <'typhoon/src/util/exportlx.c'`; then
echo shar: \"'typhoon/src/util/exportlx.c'\" unpacked with wrong size!
fi
# end of 'typhoon/src/util/exportlx.c'
fi
if test -f 'typhoon/src/util/importlx.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'typhoon/src/util/importlx.c'\"
else
echo shar: Extracting \"'typhoon/src/util/importlx.c'\" \(3383 characters\)
sed "s/^X//" >'typhoon/src/util/importlx.c' <<'END_OF_FILE'
X/*----------------------------------------------------------------------------
X * File : importlx.c
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 * Lexical analyser for import utility.
X *
X * $Log: importlx.c,v $
X * Revision 1.2 1994/09/17 16:00:55 tbp
X * typhoon.h and environ.h are now included from <>.
X *
X * Revision 1.1 1994/09/13 21:28:58 tbp
X * Added to repository.
X *
X * Added to repository.
X *
X *
X *--------------------------------------------------------------------------*/
X
Xstatic char rcsid[] = "$Id: importlx.c,v 1.2 1994/09/17 16:00:55 tbp Exp $";
X
X#include <ctype.h>
X#include <stdio.h>
X#include <string.h>
X#ifndef UNIX
X#include <stdlib.h>
X#endif
X
X#include <environ.h>
X#include "../ty_dbd.h"
X#include "ddlp.h"
X#include "imp_y.h"
X#include "ddlpsym.h"
X#include "ddlpglob.h"
X#include "lex.h"
X#include "lex.c"
X
X#if YYDEBUG
X#define D(x) x
X#else
X#define D(x)
X#endif
X
X
X
X/*---------------------------- Global variables ----------------------------*/
XFILE *lex_file; /* input file */
X
X
XLEX_KEYWORD lex_keywordtab[] = {
X T_IMPORT, "import",
X T_IN, "in",
X T_RECORD, "record",
X T_STRUCT, "struct",
X T_UNION, "union"
X};
Xint lex_keywords = sizeof(lex_keywordtab) / sizeof(lex_keywordtab[0]);
X
X
X
Xyylex()
X{
X int c, i;
X
X for( ;; )
X {
X c = getc(lex_file);
X
X if( c == ' ' || c == '\t' ) /* skip whitespace */
X ;
X else if( isalpha(c) ) /* keyword */
X return lex_parse_keyword(c);
X#if 0
X else if( isdigit(c) ) /* number */
X return lex_parse_number(c);
X#endif
X else if( c == '"' ) /* string */
X return lex_parse_string();
X else if( c == '\n' ) /* increase line count */
X lex_lineno++;
X else if( c == EOF )
X return EOF;
X else if( strchr("[]{};,+*-().", c) )
X return c;
X else if( c == '/' )
X {
X if( (c = getc(lex_file)) == '*' )/* C comment */
X lex_skip_comment();
X else if( c == '/' ) /* C++ comment */
X {
X while( getc(lex_file) != '\n' && !feof(lex_file) )
X ;
X lex_lineno++;
X }
X else
X {
X ungetc(c, lex_file);
X return '/';
X }
X }
X else
X yyerror("syntax error");
X }
X}
X
X/* end-of-file */
X
END_OF_FILE
if test 3383 -ne `wc -c <'typhoon/src/util/importlx.c'`; then
echo shar: \"'typhoon/src/util/importlx.c'\" unpacked with wrong size!
fi
# end of 'typhoon/src/util/importlx.c'
fi
echo shar: End of archive 7 \(of 9\).
cp /dev/null ark7isdone
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...