home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume44 / typhoon / part07 < prev    next >
Internet Message Format  |  1994-09-17  |  62KB

  1. From: zeppelin@login.dknet.dk (Thomas B. Pedersen)
  2. Newsgroups: comp.sources.misc
  3. Subject: v44i063:  typhoon - Typhoon Relational Database Management System, Part07/09
  4. Date: 17 Sep 1994 21:45:52 -0500
  5. Organization: Sterling Software
  6. Sender: kent@sparky.sterling.com
  7. Approved: kent@sparky.sterling.com
  8. Message-ID: <35g9l0$oj9@sparky.sterling.com>
  9. X-Md4-Signature: d7cb176b74a98827291c741689971fa4
  10.  
  11. Submitted-by: zeppelin@login.dknet.dk (Thomas B. Pedersen)
  12. Posting-number: Volume 44, Issue 63
  13. Archive-name: typhoon/part07
  14. Environment: SCO UNIX, Tandem NonStop UNIX, Sun Solaris, AIX, Linux, OS/2
  15.  
  16. #! /bin/sh
  17. # This is a shell archive.  Remove anything before this line, then feed it
  18. # into a shell via "sh file" or similar.  To overwrite existing files,
  19. # type "sh file -c".
  20. # Contents:  typhoon/ChangeLog typhoon/README typhoon/src/catalog.ddl
  21. #   typhoon/src/h/environ.h typhoon/src/os.c typhoon/src/readdbd.c
  22. #   typhoon/src/ty_log.c typhoon/src/ty_log.h typhoon/src/util/ddlp.h
  23. #   typhoon/src/util/ddlpglob.h typhoon/src/util/ddlplex.c
  24. #   typhoon/src/util/ddlpsym.h typhoon/src/util/exportlx.c
  25. #   typhoon/src/util/importlx.c
  26. # Wrapped by kent@sparky on Sat Sep 17 21:38:18 1994
  27. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin:$PATH ; export PATH
  28. echo If this archive is complete, you will see the following message:
  29. echo '          "shar: End of archive 7 (of 9)."'
  30. if test -f 'typhoon/ChangeLog' -a "${1}" != "-c" ; then 
  31.   echo shar: Will not clobber existing file \"'typhoon/ChangeLog'\"
  32. else
  33.   echo shar: Extracting \"'typhoon/ChangeLog'\" \(139 characters\)
  34.   sed "s/^X//" >'typhoon/ChangeLog' <<'END_OF_FILE'
  35. XVersion 1.01
  36. X
  37. X    Just after releasing version 1.0 I was informed about two missing 
  38. X    include files. Stupid mistake which has now been fixed.
  39. END_OF_FILE
  40.   if test 139 -ne `wc -c <'typhoon/ChangeLog'`; then
  41.     echo shar: \"'typhoon/ChangeLog'\" unpacked with wrong size!
  42.   fi
  43.   # end of 'typhoon/ChangeLog'
  44. fi
  45. if test -f 'typhoon/README' -a "${1}" != "-c" ; then 
  46.   echo shar: Will not clobber existing file \"'typhoon/README'\"
  47. else
  48.   echo shar: Extracting \"'typhoon/README'\" \(4237 characters\)
  49.   sed "s/^X//" >'typhoon/README' <<'END_OF_FILE'
  50. X
  51. X            Typhoon Relational Database Management System v1.0
  52. X       Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  53. X
  54. X Permission is hereby granted, without written agreement and without
  55. X license or royalty fees, to use, copy, modify, and distribute this
  56. X software and its documentation for any purpose, provided that the above
  57. X copyright notice and the following two  paragraphs appear (1) in all 
  58. X source copies of this software and (2) in accompanying documentation
  59. X wherever the programatic interface of this software, or any derivative
  60. X of it, is described.
  61. X
  62. X IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  63. X INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  64. X THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  65. X ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  66. X
  67. X THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  68. X NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  69. X A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  70. X BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  71. X SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  72. X-------------------------------------------------------------------------------
  73. X
  74. XTyphoon is a freely available relational database management system for
  75. Xthe UNIX and OS/2 environments. 
  76. X
  77. XThis release has been prepared in a hurry to get it out as quickly as 
  78. Xpossible. This means that the documentation is rather sparse, since I
  79. Xhaven't had the time to write extensive documentation yet. However, most
  80. Xof you out there are pretty clever, so you'll probably do fine with the
  81. Xman pages and the examples.
  82. X
  83. XThe system works fine and is currently used in a number of professional
  84. Xapplications in Denmark, some of them mission critical.
  85. X
  86. XThe system was originally inspired by Raima's db_VISTA (today Raima Data
  87. XManager) but is relational rather than network based. Typhoon lacks some of
  88. Xdb_VISTA's features, but also contains a number of nice features not found in 
  89. Xdb_VISTA.
  90. X
  91. XAll relations are defined in a so called Data Definition Language (ddl) file.
  92. XYou define the database relations like you would write a C structure with
  93. Xchars, ints, strings, multidimensional arrays, nested union and structures,
  94. Xetc. Then you define primary, alternate and foreign keys for each relation.
  95. XThe Data Definition Language Processor (ddlp) compiles the database defintion
  96. Xinto a binary file which constitutes the database description. The database
  97. Xrelations are accessed via C subroutines which manipulate individual records
  98. Xwithin a table.
  99. X
  100. X    - Multiple open database
  101. X    - Multi-field keys
  102. X    - Nested structures in records
  103. X    - Controlled unions
  104. X    - Referential integrity
  105. X    - Variable length fields
  106. X    - Null keys (optional keys in db_VISTA, but easier to use)
  107. X    - Dynamic opening and closing of database files
  108. X
  109. XAt present the database has no locking mechanism, believe it or not! The
  110. Xprojects I have used it in, simply didn't need it, even though they were
  111. Xmulti-user environments. But it's in the works!
  112. X
  113. XI am currently working on extending the library to support the following:
  114. X
  115. X    - Locking
  116. X    - Logging
  117. X    - Transactions 
  118. X    - Paging (to improve performance)
  119. X
  120. XThe library functions will remain intact, except for a number of new functions.
  121. XI expect these things to be ready before the end of the year. Beta testers
  122. Xare welcome.
  123. X
  124. XThe library comes with three additional utilities:
  125. X
  126. X    dbdview        - Displayes the database definitions.
  127. X    tyexport    - Exports tables from a database.
  128. X    tyimport    - Imports tables into a database.
  129. X
  130. XOriginally the library also contained online backup, restore and a replication
  131. Xserver. These tools would need a lot of extra documentation, so I have left
  132. Xthem out for now (the code still contains support for these utilities).
  133. XHowever, if enough people show interest I will probably release them also.
  134. X
  135. X
  136. X-------------------------------------------------------------------------------
  137. X
  138. XBug reports and mail should be sent to 
  139. X
  140. X    Thomas B. Pedersen
  141. X    zeppelin@login.dkuug.dk
  142. X
  143. XAlso, if you have any suggestions as to how I can improve the library, 
  144. Xdocumentation or anything else, please don't hesitate to mail me.
  145. X
  146. X
  147. XRegards,
  148. X
  149. XThomas B. Pedersen
  150. END_OF_FILE
  151.   if test 4237 -ne `wc -c <'typhoon/README'`; then
  152.     echo shar: \"'typhoon/README'\" unpacked with wrong size!
  153.   fi
  154.   # end of 'typhoon/README'
  155. fi
  156. if test -f 'typhoon/src/catalog.ddl' -a "${1}" != "-c" ; then 
  157.   echo shar: Will not clobber existing file \"'typhoon/src/catalog.ddl'\"
  158. else
  159.   echo shar: Extracting \"'typhoon/src/catalog.ddl'\" \(3814 characters\)
  160.   sed "s/^X//" >'typhoon/src/catalog.ddl' <<'END_OF_FILE'
  161. X/*----------------------------------------------------------------------------
  162. X * File    : @(#)catalog.ddl 94/06/07      Copyright (c) 1993-94 Belle Systems
  163. X * Library : typhoon
  164. X * Version : 1.0
  165. X * OS      : UNIX, Solaris
  166. X * Compiler: ddlp
  167. X * Author  : Thomas B. Pedersen
  168. X *
  169. X * Description:
  170. X *     Typhoon Database Definition Language file for System Catalog.
  171. X *
  172. X * Version control:
  173. X *      $Header: /usr/c/src_repository/CVSROOT/typhoon/src/catalog.ddl,v 1.1 1994/09/13 21:28:30 tbp Exp $
  174. X *      $Log: catalog.ddl,v $
  175. X# Revision 1.1  1994/09/13  21:28:30  tbp
  176. X# Added to repository.
  177. X#
  178. X *
  179. X * History
  180. X * ------------------------------
  181. X * 10-Sep-1993 tbp  Initial version.
  182. X *  8-Dec-1993 tbp  Added identification tag to sys_distab.
  183. X * 13-Dec-1993 tbp  Added sys_disfull table.
  184. X * 20-Dec-1993 tbp  Now udata need not be ASCIIZ.
  185. X *  7-Jun-1994 tbp  sys_dischange_key modified to avoid unnecessary resending
  186. X *                    of records.
  187. X *
  188. X *--------------------------------------------------------------------------*/
  189. X
  190. Xdatabase catalog {
  191. X
  192. X    data file "dissite.dat"  contains sys_dissite;
  193. X    key  file "dissite.ix1"  contains sys_dissite.id;
  194. X    data file "distable.dat" contains sys_distab;
  195. X    key  file "distable.ix1" contains sys_distab.sys_distab_key;
  196. X    data file "dischg.dat"   contains sys_dischange;
  197. X    key  file "dischg.ix1"   contains sys_dischange.sys_dischange_key;
  198. X    data file "disprkey.dat" contains sys_disprkey;
  199. X
  200. X    data file "disfultb.dat" contains sys_disfulltab;
  201. X    key  file "disfultb.ix1" contains sys_disfulltab.fulltab_key;
  202. X
  203. X    define SITES_MAX        296
  204. X    define SITEBITMAP_SIZE    ((SITES_MAX+7)/8)
  205. X    define SITENAME_LEN        20
  206. X    define NUA_LEN            16
  207. X    define UDATA_LEN        16
  208. X    define KEYSIZE_MAX        255
  209. X
  210. X    record sys_dissite {
  211. X        ulong    id;                        // Site ID
  212. X        long    last_call;                // Time of last call.
  213. X        ushort    tables;                    // Number of distributed tables on
  214. X                                        // this site
  215. X        char    name[SITENAME_LEN+1];    // Mnemonic
  216. X        char    nua[NUA_LEN+1];            // X.25 address
  217. X        char    udata_len;
  218. X        char    udata[UDATA_LEN];        // X.25 Call User Data
  219. X        char    up_to_date;                // 1=Site is completely up-to-date
  220. X        char    in_error;                // 1=Site is malfunctioning
  221. X        char    spare[99];
  222. X    
  223. X        primary key id;
  224. X    }
  225. X
  226. X    record sys_distab {
  227. X        long    id;                        // Table ID
  228. X        long    site_id;                // Site ID
  229. X        long    last_seqno;                // Last seqno sent
  230. X        char    tag;                    // Record identification tag
  231. X        char    up_to_date;                // 1=Table is up-to-date on site
  232. X        char    spare[10];
  233. X
  234. X        primary key sys_distab_key { site_id, id };
  235. X    }
  236. X
  237. X    record sys_dischange {
  238. X        ulong        seqno;                // Sequence number
  239. X        long        table_id;            // Table ID
  240. X        long        recno;                // action='u': address of record
  241. X                                        // action='d': address of primary key
  242. X                                        // in sys_disprkey
  243. X        ushort        sites;                // Number of 1-bits in site[]
  244. X        uchar        prog_id;            // Program ID
  245. X        char        action;                // 'u'=update, 'd'=delete
  246. X                                        // Bitmap of unupdated sites, indexes
  247. X                                        // by Site ID. 0=up-to-date
  248. X        uchar        site[SITEBITMAP_SIZE];
  249. X
  250. X//        primary key sys_dischange_key { table_id, seqno };
  251. X        primary key sys_dischange_key { table_id, recno };
  252. X    }
  253. X
  254. X    record sys_disprkey {
  255. X        ushort        size;
  256. X        uchar        buf[KEYSIZE_MAX];
  257. X    }
  258. X
  259. X    /*
  260. X     * When a new site is inserted in the catalog, a record of type 
  261. X     * <sys_disfulltab> is created for each record inserted in <sys_distab>.
  262. X     * 
  263. X     * The <sys_disfulltab> is used to control that the site receives all tables
  264. X     * from scratch, before being updated from <sys_dischg>. When entries
  265. X     * are present in the <sys_disfulltab>, the <updatable> flags in
  266. X     * <sys_dissite> must be 0. 
  267. X    */
  268. X
  269. X    record sys_disfulltab {
  270. X        long        site_id;                // Site ID
  271. X        ulong        table_id;                // Table ID
  272. X        ulong        curr_rec;                // Last record read in seq. scan
  273. X
  274. X        primary key fulltab_key { site_id, table_id };
  275. X    }
  276. X
  277. X}
  278. X
  279. X/* end-of-file */
  280. END_OF_FILE
  281.   if test 3814 -ne `wc -c <'typhoon/src/catalog.ddl'`; then
  282.     echo shar: \"'typhoon/src/catalog.ddl'\" unpacked with wrong size!
  283.   fi
  284.   # end of 'typhoon/src/catalog.ddl'
  285. fi
  286. if test -f 'typhoon/src/h/environ.h' -a "${1}" != "-c" ; then 
  287.   echo shar: Will not clobber existing file \"'typhoon/src/h/environ.h'\"
  288. else
  289.   echo shar: Extracting \"'typhoon/src/h/environ.h'\" \(4190 characters\)
  290.   sed "s/^X//" >'typhoon/src/h/environ.h' <<'END_OF_FILE'
  291. X/*----------------------------------------------------------------------------
  292. X * File    : environ.h
  293. X * OS      : UNIX, OS/2, DOS
  294. X * Author  : Thomas B. Pedersen
  295. X *
  296. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  297. X *
  298. X * Permission is hereby granted, without written agreement and without
  299. X * license or royalty fees, to use, copy, modify, and distribute this
  300. X * software and its documentation for any purpose, provided that the above
  301. X * copyright notice and the following two  paragraphs appear (1) in all 
  302. X * source copies of this software and (2) in accompanying documentation
  303. X * wherever the programatic interface of this software, or any derivative
  304. X * of it, is described.
  305. X *
  306. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  307. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  308. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  309. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  310. X *
  311. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  312. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  313. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  314. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  315. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  316. X *
  317. X * Description:
  318. X *   Multi Operating System compatibility include file.
  319. X *
  320. X * $Id: environ.h,v 1.1 1994/09/17 15:59:13 tbp Exp $
  321. X *
  322. X * $Log: environ.h,v $
  323. X * Revision 1.1  1994/09/17  15:59:13  tbp
  324. X * Added to repository.
  325. X *
  326. X *
  327. X *--------------------------------------------------------------------------*/
  328. X
  329. X#ifndef _ENVIRON_INCLUDED
  330. X#define _ENVIRON_INCLUDED
  331. X
  332. X
  333. X/*--------------------------------------------------------------------------*/
  334. X/*                              UNIX System V                               */
  335. X/*--------------------------------------------------------------------------*/
  336. X
  337. X#ifdef UNIX
  338. X
  339. X#define CREATMASK        0666
  340. X#ifndef O_BINARY
  341. X#define O_BINARY        0
  342. X#endif
  343. X#define DIR_SWITCH        '/'
  344. X
  345. X#if defined(sun)
  346. X#    define PROTOTYPES        1
  347. X#    define BIG_ENDIAN        1
  348. X#    define RISC                1
  349. X#elif defined(__nonstopux)
  350. X#    define PROTOTYPES        1
  351. X#    define BIG_ENDIAN        1
  352. X#    define RISC                1
  353. X#elif defined(__linux__)
  354. X#    define PROTOTYPES        1
  355. X#    define LITTLE_ENDIAN    1
  356. X#else /* presumably Intel */
  357. X#    define SCO                1
  358. X#    define PROTOTYPES        1
  359. X#    define LITTLE_ENDIAN    1
  360. X#endif
  361. X
  362. Xtypedef unsigned char   uchar;
  363. X#ifndef _SYS_TYPES_H
  364. X    typedef unsigned short  ushort;
  365. X    typedef unsigned long   ulong;
  366. X#endif
  367. X
  368. X#endif
  369. X
  370. X/*--------------------------------------------------------------------------*/
  371. X/*                               OS/2 v2.0                                  */
  372. X/*--------------------------------------------------------------------------*/
  373. X
  374. X#ifdef OS2
  375. X#ifdef __BORLANDC__
  376. X#   define __STDC__ 1
  377. X#endif
  378. X#define DIR_SWITCH        '\\'
  379. X#define CREATMASK        (S_IREAD|S_IWRITE)
  380. X#define PROTOTYPES        1
  381. X#define LITTLE_ENDIAN    1
  382. X
  383. Xtypedef unsigned char   uchar;
  384. Xtypedef unsigned short  ushort;
  385. Xtypedef unsigned long   ulong;
  386. X
  387. X#endif
  388. X
  389. X
  390. X/*--------------------------------------------------------------------------*/
  391. X/*                                    DOS                                   */
  392. X/*--------------------------------------------------------------------------*/
  393. X
  394. X#ifdef DOS
  395. X
  396. X#define DIR_SWITCH        '\\'
  397. X#define CREATMASK        (S_IREAD|S_IWRITE)
  398. X#define PROTOTYPES        1
  399. X#define LITTLE_ENDIAN    1
  400. X
  401. Xtypedef unsigned char   uchar;
  402. Xtypedef unsigned short  ushort;
  403. Xtypedef unsigned long   ulong;
  404. X
  405. X#endif
  406. X
  407. X
  408. X#ifdef PROTOTYPES
  409. X#    define PRM(x)        x
  410. X#    define _PRM(x)        x
  411. X#    define ELLIPSIS        ,...
  412. X#else
  413. X#    define PRM(x)        ();
  414. X#    define _PRM(x)        ()
  415. X#    define ELLIPSIS        /**/
  416. X#endif
  417. X
  418. X#ifndef offsetof
  419. X#    define offsetof(s,m)        ((int)&(((s *)0))->m)
  420. X#endif
  421. X
  422. X#ifdef BIG_ENDIAN
  423. X#    define SWAPTOSHORT(i)    (((i) >> 8) & 0xff | (i & 0xff) << 8)
  424. X#    define SWAPTOLONG(l)    ((((l) & 0xff) << 24) | (((l) & 0xff00) << 8) | \
  425. X                            (((l) >> 8) & 0xff00) | (((l) >> 24) & 0xff))
  426. X#    define SWAPSHORT(i)        i = SWAPTOSHORT(i)
  427. X#    define SWAPLONG(l)        l = SWAPTOLONG(l)
  428. X#else
  429. X#    define SWAPTOSHORT(i)    i
  430. X#    define SWAPTOLONG(l)    l
  431. X#    define SWAPSHORT(i)        (void)0
  432. X#    define SWAPLONG(l)        (void)0
  433. X#    define SWAP(l)            (void)0
  434. X#endif
  435. X
  436. X
  437. X#endif
  438. X
  439. X/* end-of-file */
  440. END_OF_FILE
  441.   if test 4190 -ne `wc -c <'typhoon/src/h/environ.h'`; then
  442.     echo shar: \"'typhoon/src/h/environ.h'\" unpacked with wrong size!
  443.   fi
  444.   # end of 'typhoon/src/h/environ.h'
  445. fi
  446. if test -f 'typhoon/src/os.c' -a "${1}" != "-c" ; then 
  447.   echo shar: Will not clobber existing file \"'typhoon/src/os.c'\"
  448. else
  449.   echo shar: Extracting \"'typhoon/src/os.c'\" \(4356 characters\)
  450.   sed "s/^X//" >'typhoon/src/os.c' <<'END_OF_FILE'
  451. X/*----------------------------------------------------------------------------
  452. X * File    : os.c
  453. X * Library : typhoon
  454. X * OS      : UNIX, OS/2, DOS
  455. X * Author  : Thomas B. Pedersen
  456. X *
  457. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  458. X *
  459. X * Permission is hereby granted, without written agreement and without
  460. X * license or royalty fees, to use, copy, modify, and distribute this
  461. X * software and its documentation for any purpose, provided that the above
  462. X * copyright notice and the following two  paragraphs appear (1) in all 
  463. X * source copies of this software and (2) in accompanying documentation
  464. X * wherever the programatic interface of this software, or any derivative
  465. X * of it, is described.
  466. X *
  467. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  468. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  469. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  470. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  471. X *
  472. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  473. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  474. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  475. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  476. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  477. X *
  478. X * Description:
  479. X *   Contains functions that may vary between different operating systems
  480. X *   such as opening and locking files.
  481. X *
  482. X * Functions:
  483. X *   os_lock        Get exclusive access to the database.
  484. X *   os_unlock        Release the lock.
  485. X *
  486. X * $Log: os.c,v $
  487. X * Revision 1.1  1994/09/13  21:28:31  tbp
  488. X * Added to repository.
  489. X * 
  490. X *
  491. X *--------------------------------------------------------------------------*/
  492. X
  493. Xstatic char rcsid[] = "$Id";
  494. X
  495. X#ifdef UNIX
  496. X#  include <sys/types.h>
  497. X#  include <sys/stat.h>
  498. X#  include <unistd.h>
  499. X#endif
  500. X#ifdef __linux__
  501. X#    include <sys/file.h>
  502. X#    define F_TLOCK    LOCK_NB
  503. X#    define F_LOCK    LOCK_EX
  504. X#    define F_ULOCK    LOCK_UN
  505. X#    define lockf(fd,op,len)    flock(fd,op)
  506. X#endif
  507. X#ifdef _MSC_VER
  508. X#  include <sys/types.h>
  509. X#  include <sys/stat.h>
  510. X#  include <sys/locking.h>
  511. X#endif
  512. X#ifdef __BORLANDC__
  513. X#  include <sys\locking.h>
  514. X#  include <io.h>
  515. X#endif
  516. X#ifdef __IBMC__
  517. X#include <io.h>
  518. X#include <share.h>
  519. X#endif
  520. X#include <fcntl.h>
  521. X#include <stdio.h>
  522. X
  523. X
  524. X/*--------------------------------- os_lock --------------------------------*\
  525. X *
  526. X * Purpose     : Lock a region of a file.
  527. X *
  528. X * Parameters: fh        - File handle.
  529. X *               offset    - Offset from start of file.
  530. X *               bytes    - Number of bytes to lock.
  531. X *               type        - Lock type. 't'=test and lock, 'w'=wait and lock
  532. X *
  533. X *
  534. X * Returns     : -1         - The region could not be locked.
  535. X *               0        - Region locked.
  536. X *
  537. X */
  538. X
  539. Xos_lock(fh, offset, bytes, type)
  540. Xint fh;
  541. Xlong offset;
  542. Xunsigned bytes;
  543. X{
  544. X    lseek(fh, offset, SEEK_SET);
  545. X#ifdef DOS
  546. X    /* Microsoft C */
  547. X#    ifdef _MSC_VER
  548. X    if( locking(fh, type == 't' ? LK_NBLCK : LK_LOCK, bytes) == -1 )
  549. X        return -1;
  550. X#    endif
  551. X#endif
  552. X#ifdef UNIX
  553. X    if( lockf(fh, type == 't' ? F_TLOCK : F_LOCK, bytes) == -1 )
  554. X        puts("lockf failed");
  555. X#endif
  556. X#ifdef OS2
  557. X#    ifdef __BORLANDC__
  558. X    if( locking(fh, type == 't' ? LK_NBLCK : LK_LOCK, bytes) == -1 )
  559. X        return -1;
  560. X#    endif
  561. X#endif
  562. X
  563. X    return 0;
  564. X}
  565. X
  566. X/*-------------------------------- os_unlock -------------------------------*\
  567. X *
  568. X * Purpose     : Unlock a region of a file.
  569. X *
  570. X * Parameters: fh        - File handle.
  571. X *               offset    - Offset from start of file.
  572. X *               bytes    - Number of bytes to lock.
  573. X *               type        - Lock type. 't'=test and lock, 'w'=wait and lock
  574. X *
  575. X *
  576. X * Returns     : -1         - The region could not be unlocked.
  577. X *               0        - Region unlocked.
  578. X *
  579. X */
  580. X
  581. Xos_unlock(fh, offset, bytes)
  582. Xint fh;
  583. Xlong offset;
  584. Xunsigned bytes;
  585. X{
  586. X    lseek(fh, offset, SEEK_SET);
  587. X#ifdef DOS
  588. X    /* Microsoft C */
  589. X#    ifdef _MSC_VER
  590. X    return locking(fh, LK_UNLCK, bytes);
  591. X#    endif
  592. X#endif
  593. X#ifdef UNIX
  594. X    return lockf(fh, F_ULOCK, bytes);
  595. X#endif
  596. X#ifdef OS2
  597. X#    ifdef __BORLANDC__
  598. X    return locking(fh, LK_UNLCK, bytes);
  599. X#    endif
  600. X#endif
  601. X}
  602. X
  603. X
  604. X
  605. X
  606. Xos_open(fname, flags, creatflags)
  607. Xchar *fname;
  608. Xint flags, creatflags;
  609. X{
  610. X#ifdef __IBMC__
  611. X    return sopen(fname, flags, SH_DENYNO, creatflags);
  612. X#else
  613. X    return open(fname, flags, creatflags);
  614. X#endif
  615. X}
  616. X
  617. X
  618. X
  619. Xos_close(fh)
  620. Xint fh;
  621. X{
  622. X    return close(fh);
  623. X}
  624. X
  625. X
  626. Xos_access(fname, mode)
  627. Xchar *fname;
  628. Xint mode;
  629. X{
  630. X#ifdef __IBMC__
  631. X    return _access(fname, mode);
  632. X#else
  633. X    return access(fname, mode);
  634. X#endif
  635. X}
  636. X
  637. X/* end-of-file */
  638. END_OF_FILE
  639.   if test 4356 -ne `wc -c <'typhoon/src/os.c'`; then
  640.     echo shar: \"'typhoon/src/os.c'\" unpacked with wrong size!
  641.   fi
  642.   # end of 'typhoon/src/os.c'
  643. fi
  644. if test -f 'typhoon/src/readdbd.c' -a "${1}" != "-c" ; then 
  645.   echo shar: Will not clobber existing file \"'typhoon/src/readdbd.c'\"
  646. else
  647.   echo shar: Extracting \"'typhoon/src/readdbd.c'\" \(3894 characters\)
  648.   sed "s/^X//" >'typhoon/src/readdbd.c' <<'END_OF_FILE'
  649. X/*----------------------------------------------------------------------------
  650. X * File    : readdbd.c
  651. X * Library : typhoon
  652. X * OS      : UNIX, OS/2, DOS
  653. X * Author  : Thomas B. Pedersen
  654. X *
  655. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  656. X *
  657. X * Permission is hereby granted, without written agreement and without
  658. X * license or royalty fees, to use, copy, modify, and distribute this
  659. X * software and its documentation for any purpose, provided that the above
  660. X * copyright notice and the following two  paragraphs appear (1) in all 
  661. X * source copies of this software and (2) in accompanying documentation
  662. X * wherever the programatic interface of this software, or any derivative
  663. X * of it, is described.
  664. X *
  665. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  666. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  667. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  668. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  669. X *
  670. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  671. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  672. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  673. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  674. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  675. X *
  676. X * Description:
  677. X *   Contains a function that reads the dbd-file.
  678. X *
  679. X * Functions:
  680. X *   read_dbdfile    - Read the database description file.
  681. X *
  682. X * $Log: readdbd.c,v $
  683. X * Revision 1.2  1994/09/17  16:00:14  tbp
  684. X * typhoon.h and environ.h are now included from <>.
  685. X *
  686. X * Revision 1.1  1994/09/13  21:28:32  tbp
  687. X * Added to repository.
  688. X * 
  689. X *
  690. X *--------------------------------------------------------------------------*/
  691. X
  692. Xstatic char rcsid[] = "$Id: readdbd.c,v 1.2 1994/09/17 16:00:14 tbp Exp $";
  693. X
  694. X#ifdef UNIX
  695. X#  include <unistd.h>
  696. X#  include <stdio.h>
  697. X#  ifdef __STDC__
  698. X#    include <stdlib.h>
  699. X#  endif
  700. X#else
  701. X#  include <stdlib.h>
  702. X#  include <io.h>
  703. X#endif
  704. X#include <stdio.h>
  705. X#include <fcntl.h>
  706. X#include <errno.h>
  707. X#include <typhoon.h>
  708. X#include "ty_dbd.h"
  709. X#include "ty_type.h"
  710. X#include "ty_glob.h"
  711. X
  712. X
  713. X/*------------------------------ read_dbdfile ------------------------------*\
  714. X *
  715. X * Purpose     : Reads the dbd-file into a available database slot provided
  716. X *               by the calling function. The table pointers in the slot are
  717. X *               also set up.
  718. X *
  719. X * Parameters: _db            - Pointer to database entry slot.
  720. X *               fname        - The name of the dbd-file.
  721. X *
  722. X * Returns     : S_OKAY        - dbd-file successfully read.
  723. X *               S_NOMEM        - Not enough memory to allocate tables.
  724. X *               S_INVDB        - Cannot find dbd-file.
  725. X *               S_IOFATAL    - The dbd-file is corrupted.
  726. X *
  727. X */
  728. X
  729. Xread_dbdfile(_db, fname)
  730. XDbentry *_db;
  731. Xchar *fname;
  732. X{
  733. X    int dbdfile, size;
  734. X
  735. X    if( (dbdfile = os_open(fname, O_RDONLY|O_BINARY)) == -1 )
  736. X        RETURN S_INVDB;
  737. X
  738. X    /*
  739. X     * Get the size of the dbd-file, read the header and expand to buffer
  740. X     * to hold a table of file handles.
  741. X     */
  742. X    size = lseek(dbdfile, 0, SEEK_END);
  743. X    lseek(dbdfile, 0, SEEK_SET);
  744. X
  745. X    if( read(dbdfile, &_db->header, sizeof _db->header) < sizeof(_db->header) )
  746. X        RETURN S_IOFATAL;
  747. X
  748. X    if( strcmp(_db->header.version, DBD_VERSION) )
  749. X        RETURN S_VERSION;
  750. X
  751. X    size -= sizeof _db->header;
  752. X
  753. X    if( !(_db->dbd = (void *)malloc(size + _db->header.files * sizeof(Fh))) )
  754. X    {
  755. X        close(dbdfile);
  756. X        RETURN S_NOMEM;
  757. X    }
  758. X
  759. X    read(dbdfile, _db->dbd, size);
  760. X    close(dbdfile);
  761. X
  762. X    /* Set up pointers to tables */
  763. X    _db->file        = (File     *)_db->dbd;
  764. X    _db->key        = (Key      *)(_db->file     + _db->header.files);
  765. X    _db->keyfield    = (KeyField *)(_db->key         + _db->header.keys);
  766. X    _db->record     = (Record   *)(_db->keyfield + _db->header.keyfields);
  767. X    _db->field        = (Field    *)(_db->record     + _db->header.records);
  768. X    _db->structdef    = (Structdef*)(_db->field     + _db->header.fields);
  769. X    _db->fh         = (Fh       *)(_db->structdef+ _db->header.structdefs);
  770. X
  771. X    return S_OKAY;
  772. X}
  773. X
  774. X
  775. X/* end-of-file */
  776. END_OF_FILE
  777.   if test 3894 -ne `wc -c <'typhoon/src/readdbd.c'`; then
  778.     echo shar: \"'typhoon/src/readdbd.c'\" unpacked with wrong size!
  779.   fi
  780.   # end of 'typhoon/src/readdbd.c'
  781. fi
  782. if test -f 'typhoon/src/ty_log.c' -a "${1}" != "-c" ; then 
  783.   echo shar: Will not clobber existing file \"'typhoon/src/ty_log.c'\"
  784. else
  785.   echo shar: Extracting \"'typhoon/src/ty_log.c'\" \(4653 characters\)
  786.   sed "s/^X//" >'typhoon/src/ty_log.c' <<'END_OF_FILE'
  787. X/*----------------------------------------------------------------------------
  788. X * File    : ty_log.c
  789. X * Library : typhoon
  790. X * OS      : UNIX, OS/2, DOS
  791. X * Author  : Thomas B. Pedersen
  792. X *
  793. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  794. X *
  795. X * Permission is hereby granted, without written agreement and without
  796. X * license or royalty fees, to use, copy, modify, and distribute this
  797. X * software and its documentation for any purpose, provided that the above
  798. X * copyright notice and the following two  paragraphs appear (1) in all 
  799. X * source copies of this software and (2) in accompanying documentation
  800. X * wherever the programatic interface of this software, or any derivative
  801. X * of it, is described.
  802. X *
  803. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  804. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  805. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  806. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  807. X *
  808. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  809. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  810. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  811. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  812. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  813. X *
  814. X * Description:
  815. X *   Contains function that write to the Replication Server log.
  816. X *
  817. X * Functions:
  818. X *
  819. X * $Log: ty_log.c,v $
  820. X * Revision 1.2  1994/09/17  16:00:18  tbp
  821. X * typhoon.h and environ.h are now included from <>.
  822. X *
  823. X * Revision 1.1  1994/09/13  21:28:35  tbp
  824. X * Added to repository.
  825. X * 
  826. X *
  827. X *--------------------------------------------------------------------------*/
  828. X
  829. Xstatic char rcsid[] = "$Id: ty_log.c,v 1.2 1994/09/17 16:00:18 tbp Exp $";
  830. X
  831. X#include <sys/types.h>
  832. X#include <unistd.h>
  833. X#include <stdio.h>
  834. X#include <fcntl.h>
  835. X#include <typhoon.h>
  836. X#include "ty_dbd.h"
  837. X#include "ty_type.h"
  838. X#include "ty_glob.h"
  839. X#include "ty_prot.h"
  840. X#include "ty_log.h"
  841. X
  842. X/*-------------------------- Function prototypes ---------------------------*/
  843. Xstatic do_log            PRM( (ulong, ulong); )
  844. X
  845. X
  846. X/*---------------------------- Global variables ----------------------------*/
  847. Xstatic int log_fh = -1;            /* Log file handle                            */
  848. Xstatic int log_trans = 0;        /* True if the current transaction was        */
  849. X                                /* started during backup                    */
  850. X
  851. X/*--------------------------------------------------------------------------*\
  852. X *
  853. X * Function  : do_log
  854. X *
  855. X * Purpose   : This function checks whether an operation should be logged or
  856. X *               not. If yes, the log file is opened if not already open.
  857. X *               If the backup is no longer active, the log file is closed.
  858. X *
  859. X * Parameters: 
  860. X *
  861. X * Returns   : 
  862. X *    
  863. X */            
  864. Xstatic do_log(recid, recno)
  865. Xulong recid, recno;
  866. X{
  867. X    if( !DB->shm->backup_active && !log_trans )
  868. X    {
  869. X        if( log_fh != -1 )
  870. X        {
  871. X            close(log_fh);
  872. X            log_fh = -1;
  873. X        }
  874. X        return -1;
  875. X    }
  876. X
  877. X    if( recid > DB->shm->curr_recid && recno > DB->shm->curr_recno )
  878. X        return -1;
  879. X    
  880. X    if( log_fh == -1 )
  881. X    {
  882. X        log_fh = os_open(LOG_FNAME, O_RDWR|O_APPEND|O_CREAT, CREATMASK);
  883. X        
  884. X        if( log_fh == -1 )
  885. X        {
  886. X            puts("cannot open log");
  887. X            return -1;
  888. X        }
  889. X    }
  890. X    
  891. X    return 0;
  892. X}
  893. X
  894. X
  895. X
  896. X/*--------------------------------------------------------------------------*\
  897. X *
  898. X * Function  : Log a record update.
  899. X *
  900. X * Purpose   : 
  901. X *
  902. X * Parameters: 
  903. X *
  904. X * Returns   : 
  905. X *    
  906. X */            
  907. Xlog_update(recid, recno, size, data)
  908. Xulong recid;
  909. Xulong recno;
  910. Xunsigned size;
  911. Xvoid *data;
  912. X{
  913. X    LogUpdate update;
  914. X
  915. X    if( do_log(recid, recno) == -1 )
  916. X        return 0;
  917. X
  918. X    os_lock(log_fh, 0, 1, 'u');
  919. X
  920. X#ifdef RISC
  921. X    if( size & 3 )
  922. X        size += 4 - (size & 3);
  923. X#endif
  924. X
  925. X    update.id        = LOG_UPDATE;
  926. X    update.len        = size + sizeof update;
  927. X    update.recid    = recid;
  928. X    update.recno    = recno;
  929. X
  930. X    write(log_fh, &update, sizeof update);
  931. X    write(log_fh, data, size);
  932. X
  933. X    os_unlock(log_fh, 0, 1);
  934. X}
  935. X
  936. X
  937. Xlog_delete(recid, recno)
  938. Xulong recid, recno;
  939. X{
  940. X    LogDelete delete;
  941. X
  942. X    if( do_log(recid, recno) == -1 )
  943. X        return 0;
  944. X
  945. X    os_lock(log_fh, 0, 1, 'u');
  946. X
  947. X    delete.id        = LOG_UPDATE;
  948. X    delete.len        = sizeof delete;
  949. X    delete.recid    = recid;
  950. X    delete.recno    = recno;
  951. X
  952. X    write(log_fh, &delete, sizeof delete);
  953. X
  954. X    os_unlock(log_fh, 0, 1);
  955. X}
  956. X
  957. X
  958. X/*--------------------------------------------------------------------------*\
  959. X *
  960. X * Function  : 
  961. X *
  962. X * Purpose   : 
  963. X *
  964. X * Parameters: 
  965. X *
  966. X * Returns   : 
  967. X *
  968. X */
  969. XFNCLASS d_beginwork()
  970. X{
  971. X    if( DB->shm->backup_active )
  972. X    {
  973. X        DB->shm->num_trans_active++;
  974. X        log_trans = 1;        
  975. X    }
  976. X
  977. X    return S_OKAY;
  978. X}
  979. X
  980. X
  981. X
  982. XFNCLASS d_commitwork()
  983. X{
  984. X    if( log_trans )
  985. X    {
  986. X        log_trans = 0;
  987. X        DB->shm->num_trans_active--;
  988. X    }
  989. X}
  990. X
  991. X
  992. X
  993. XFNCLASS d_abortwork()
  994. X{
  995. X    if( log_trans )
  996. X    {
  997. X        log_trans =0 ;
  998. X        DB->shm->num_trans_active--;
  999. X    }        
  1000. X}
  1001. X
  1002. X/* end-of-file */
  1003. END_OF_FILE
  1004.   if test 4653 -ne `wc -c <'typhoon/src/ty_log.c'`; then
  1005.     echo shar: \"'typhoon/src/ty_log.c'\" unpacked with wrong size!
  1006.   fi
  1007.   # end of 'typhoon/src/ty_log.c'
  1008. fi
  1009. if test -f 'typhoon/src/ty_log.h' -a "${1}" != "-c" ; then 
  1010.   echo shar: Will not clobber existing file \"'typhoon/src/ty_log.h'\"
  1011. else
  1012.   echo shar: Extracting \"'typhoon/src/ty_log.h'\" \(3637 characters\)
  1013.   sed "s/^X//" >'typhoon/src/ty_log.h' <<'END_OF_FILE'
  1014. X/*----------------------------------------------------------------------------
  1015. X * File    : ty_log.h
  1016. X * Library : typhoon
  1017. X * OS      : UNIX, OS/2, DOS
  1018. X * Author  : Thomas B. Pedersen
  1019. X *
  1020. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  1021. X *
  1022. X * Permission is hereby granted, without written agreement and without
  1023. X * license or royalty fees, to use, copy, modify, and distribute this
  1024. X * software and its documentation for any purpose, provided that the above
  1025. X * copyright notice and the following two  paragraphs appear (1) in all 
  1026. X * source copies of this software and (2) in accompanying documentation
  1027. X * wherever the programatic interface of this software, or any derivative
  1028. X * of it, is described.
  1029. X *
  1030. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  1031. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  1032. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  1033. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1034. X *
  1035. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  1036. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  1037. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  1038. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  1039. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  1040. X *
  1041. X * Description:
  1042. X *   Contains the definitions used for online backup.
  1043. X *
  1044. X * $Id: ty_log.h,v 1.1 1994/09/13 21:28:36 tbp Exp $
  1045. X *
  1046. X * $Log: ty_log.h,v $
  1047. X * Revision 1.1  1994/09/13  21:28:36  tbp
  1048. X * Added to repository.
  1049. X * 
  1050. X *
  1051. X *--------------------------------------------------------------------------*/
  1052. X
  1053. X#define LOG_FNAME    "typhoon.log"
  1054. X#define LOG_UPDATE    1
  1055. X#define LOG_DELETE    2
  1056. X
  1057. Xtypedef struct {
  1058. X    short    id;                            /* = LOG_INSERT                        */
  1059. X    ushort    len;                        /* Length of entire block            */
  1060. X    ulong    recid;
  1061. X    ulong    recno;
  1062. X/*    char    data[1];*/
  1063. X} LogUpdate;
  1064. X
  1065. Xtypedef struct {
  1066. X    short    id;                            /* = LOG_DELETE                        */
  1067. X    ushort    len;                        /* Length of entire block            */
  1068. X    ulong    recid;
  1069. X    ulong    recno;
  1070. X} LogDelete;
  1071. X
  1072. X
  1073. X#define ARCHIVE_MEDIA        1
  1074. X#define ARCHIVE_RECORD        2
  1075. X#define ARCHIVE_FILE        3
  1076. X#define ARCHIVE_FILEDATA    4
  1077. X#define ARCHIVE_TABLE        5
  1078. X#define ARCHIVE_END            6
  1079. X
  1080. X#define ARCHIVE_BLOCK        99
  1081. X
  1082. Xtypedef struct {
  1083. X    ulong    id;                            /* = ARCHIVE_MEDIA                    */
  1084. X    char    dbname[DBNAME_LEN+1];
  1085. X    char    spare[3];
  1086. X    long    date;                        /* Date of backup                    */
  1087. X    ulong    seqno;                        /* Media number in backup            */
  1088. X    char    spare2[512];
  1089. X} ArchiveMediaHeader;
  1090. X
  1091. Xtypedef struct {
  1092. X    ulong    id;                            /* = ARCHIVE_RECORD                    */
  1093. X    ulong    recid;
  1094. X    ulong    recno;
  1095. X} ArchiveRecordHeader;
  1096. X
  1097. Xtypedef struct {
  1098. X    ulong    id;                            /* = ARCHIVE_FILE                    */
  1099. X    ulong    recsize;
  1100. X    char    table[IDENT_LEN+1];
  1101. X    char    fname[128];
  1102. X} ArchiveTableHeader;
  1103. X
  1104. Xtypedef struct {
  1105. X    ulong    id;                            /* = ARCHIVE_FILE                    */
  1106. X    char    fname[128];
  1107. X} ArchiveFileHeader;
  1108. X
  1109. Xtypedef struct {
  1110. X    ulong    id;                            /* = ARCHIVE_FILEDATA                */
  1111. X    ulong    size;
  1112. X} ArchiveFileDataHeader;
  1113. X
  1114. Xtypedef struct {
  1115. X    ulong    id;                            /* = ARCHIVE_END                    */
  1116. X} ArchiveEnd;
  1117. X
  1118. Xtypedef struct {
  1119. X    ulong    id;
  1120. X    ulong    size;
  1121. X} ArchiveBlockHeader;
  1122. X
  1123. X
  1124. X/* 
  1125. X    Archive structure
  1126. X    ==============================
  1127. X    
  1128. X    [MediaHeader]
  1129. X
  1130. X    [FileHeader]                ----+
  1131. X    [FileDataHeader]                |
  1132. X    data                            +---    dbd-file
  1133. X    [FileDataHeader]                |
  1134. X    data                            |
  1135. X    ...                                |
  1136. X    [FileDataHeader size=0]        ----+
  1137. X
  1138. X    [TableHeader]                ----+
  1139. X    [RecordHeader]                    |
  1140. X    record                            |
  1141. X    [RecordHeader]                    +---    database
  1142. X    record                            |
  1143. X    ...                                |
  1144. X    [RecordHeader]                    |
  1145. X    record                        ----+
  1146. X
  1147. X    [FileHeader]                ----+
  1148. X    [FileDataHeader]                |
  1149. X    data                            +---    log file
  1150. X    [FileDataHeader]                |
  1151. X    data                            |
  1152. X    ...                                |
  1153. X    [FileDataHeader size=0]        ----+
  1154. X    
  1155. X    [End]
  1156. X*/
  1157. X
  1158. X
  1159. X/* end-of-file */
  1160. END_OF_FILE
  1161.   if test 3637 -ne `wc -c <'typhoon/src/ty_log.h'`; then
  1162.     echo shar: \"'typhoon/src/ty_log.h'\" unpacked with wrong size!
  1163.   fi
  1164.   # end of 'typhoon/src/ty_log.h'
  1165. fi
  1166. if test -f 'typhoon/src/util/ddlp.h' -a "${1}" != "-c" ; then 
  1167.   echo shar: Will not clobber existing file \"'typhoon/src/util/ddlp.h'\"
  1168. else
  1169.   echo shar: Extracting \"'typhoon/src/util/ddlp.h'\" \(3235 characters\)
  1170.   sed "s/^X//" >'typhoon/src/util/ddlp.h' <<'END_OF_FILE'
  1171. X/*----------------------------------------------------------------------------
  1172. X * File    : ddlp.h
  1173. X * Program : ddlp
  1174. X * OS      : UNIX, OS/2, DOS
  1175. X * Author  : Thomas B. Pedersen
  1176. X *
  1177. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  1178. X *
  1179. X * Permission is hereby granted, without written agreement and without
  1180. X * license or royalty fees, to use, copy, modify, and distribute this
  1181. X * software and its documentation for any purpose, provided that the above
  1182. X * copyright notice and the following two  paragraphs appear (1) in all 
  1183. X * source copies of this software and (2) in accompanying documentation
  1184. X * wherever the programatic interface of this software, or any derivative
  1185. X * of it, is described.
  1186. X *
  1187. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  1188. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  1189. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  1190. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1191. X *
  1192. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  1193. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  1194. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  1195. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  1196. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  1197. X *
  1198. X * Description:
  1199. X *   ddlp header file.
  1200. X *
  1201. X * $Id: ddlp.h,v 1.1 1994/09/13 21:28:52 tbp Exp $
  1202. X *
  1203. X * $Log: ddlp.h,v $
  1204. X * Revision 1.1  1994/09/13  21:28:52  tbp
  1205. X * Added to repository.
  1206. X *
  1207. X * Added to repository.
  1208. X * 
  1209. X *
  1210. X *--------------------------------------------------------------------------*/
  1211. X
  1212. X/*-------------------------------- Constants -------------------------------*/
  1213. X#define RECORDS_MAX        256        /* Maximum number of records                */
  1214. X#define STRUCTDEFS_MAX    256        /* Maximum number of structure definitions    */
  1215. X#define FIELDS_MAX        512        /* Maximum number of fields                    */
  1216. X#define FILES_MAX        512        /* Maximum number of files                    */
  1217. X#define KEYS_MAX        256        /* Maximum number of keys                    */
  1218. X#define KEYFIELDS_MAX    1024    /* Maximum number of key fields                */
  1219. X#define DEFINES_MAX        200        /* Maximum number of defines                */
  1220. X#define CONTAINS_MAX    512        /* Maximum number of contains statements    */
  1221. X
  1222. X/*
  1223. X * This structure contains integer constants defined in the database
  1224. X * definition. These definitions are exported to the header file.
  1225. X */
  1226. X
  1227. Xtypedef struct {
  1228. X    int        value;
  1229. X    char    name[IDENT_LEN+1];
  1230. X} Define;
  1231. X
  1232. X
  1233. X/*------------------------------- ddlp.c -----------------------------------*/
  1234. Xvoid    err_quit               PRM( (char * ELLIPSIS);       )
  1235. Xvoid    align_offset        PRM( (unsigned *, int); )
  1236. Xvoid    add_key                PRM( (char *); )
  1237. Xvoid    add_keyfield        PRM( (Id, int); )
  1238. Xvoid    add_define            PRM( (char *, int); )
  1239. Xvoid    add_file            PRM( (int, char *, unsigned); )
  1240. Xvoid    add_contains        PRM( (int, char *, char *); )
  1241. Xvoid    add_record            PRM( (char *); )
  1242. Xvoid    add_field            PRM( (char *, int); )
  1243. Xvoid    add_structdef        PRM( (char *, int, int); )
  1244. Xvoid    check_foreign_key    PRM( (char *, Key *); )
  1245. X
  1246. X/*-------------------------------- ddl.y -----------------------------------*/
  1247. Xint        yyerror                PRM( (char * ELLIPSIS); )
  1248. X
  1249. X/*------------------------------- ddlplex.c --------------------------------*/
  1250. Xvoid    init_lex            PRM( (void); )
  1251. X
  1252. X
  1253. X/* end-of-file */
  1254. END_OF_FILE
  1255.   if test 3235 -ne `wc -c <'typhoon/src/util/ddlp.h'`; then
  1256.     echo shar: \"'typhoon/src/util/ddlp.h'\" unpacked with wrong size!
  1257.   fi
  1258.   # end of 'typhoon/src/util/ddlp.h'
  1259. fi
  1260. if test -f 'typhoon/src/util/ddlpglob.h' -a "${1}" != "-c" ; then 
  1261.   echo shar: Will not clobber existing file \"'typhoon/src/util/ddlpglob.h'\"
  1262. else
  1263.   echo shar: Extracting \"'typhoon/src/util/ddlpglob.h'\" \(4316 characters\)
  1264.   sed "s/^X//" >'typhoon/src/util/ddlpglob.h' <<'END_OF_FILE'
  1265. X/*----------------------------------------------------------------------------
  1266. X * File    : ddlpglob.h
  1267. X * Program : ddlp
  1268. X * OS      : UNIX, OS/2, DOS
  1269. X * Author  : Thomas B. Pedersen
  1270. X *
  1271. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  1272. X *
  1273. X * Permission is hereby granted, without written agreement and without
  1274. X * license or royalty fees, to use, copy, modify, and distribute this
  1275. X * software and its documentation for any purpose, provided that the above
  1276. X * copyright notice and the following two  paragraphs appear (1) in all 
  1277. X * source copies of this software and (2) in accompanying documentation
  1278. X * wherever the programatic interface of this software, or any derivative
  1279. X * of it, is described.
  1280. X *
  1281. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  1282. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  1283. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  1284. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1285. X *
  1286. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  1287. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  1288. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  1289. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  1290. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  1291. X *
  1292. X * Description:
  1293. X *   Contains global variables for ddlp.
  1294. X *
  1295. X * $Id: ddlpglob.h,v 1.1 1994/09/13 21:28:53 tbp Exp $
  1296. X *
  1297. X * $Log: ddlpglob.h,v $
  1298. X * Revision 1.1  1994/09/13  21:28:53  tbp
  1299. X * Added to repository.
  1300. X *
  1301. X * Added to repository.
  1302. X * 
  1303. X *
  1304. X *--------------------------------------------------------------------------*/
  1305. X
  1306. X#ifdef DEFINE_GLOBALS
  1307. X#define CLASS
  1308. X#define I(x)    = x
  1309. X#else
  1310. X#define CLASS    extern
  1311. X#define I(x)
  1312. X#endif
  1313. X
  1314. XCLASS int       varlen_field_occurred            /* True if a varlen field   */
  1315. X                            I( 0        );        /* has occurred in the rec  */
  1316. XCLASS sym_member*size_field    I( NULL        );      /* This var contains the    */
  1317. X                                                /* name of the size field   */
  1318. X                                                /* of a varlen field        */
  1319. XCLASS int        only_keys    I( 0        );        /* Only extract key consts?    */
  1320. XCLASS int        warnholes    I( 0        );        /* Warn about align. holes    */
  1321. XCLASS int        lex_lineno     I( 1        );        /* Current line number        */
  1322. XCLASS int        errors        I( 0        );        /* Number of errors            */
  1323. XCLASS int        dbpg_size    I( 512       );        /* Database page size        */
  1324. XCLASS int        align        I( 1        );        /* Structure alignment        */
  1325. XCLASS int        conts        I( 0        );        /* Number of contains        */
  1326. XCLASS int        defines        I( 0        );        /* Number of defines        */
  1327. XCLASS unsigned    dims        I( 0        );        /* Number of dimensions        */
  1328. XCLASS unsigned    dim[20];                        /* Array dimension            */
  1329. XCLASS char        dbname[DBNAME_LEN+1];            /* Database name            */
  1330. XCLASS char        dbdname[256];                    /* .dbd file name            */
  1331. XCLASS char        ddlname[256];                    /* .ddl file name            */
  1332. XCLASS char        hname[256];                        /* Header file name            */
  1333. XCLASS Define    define[DEFINES_MAX];
  1334. XCLASS Contains    contains[CONTAINS_MAX];
  1335. X
  1336. X
  1337. X/*------------------- These tables go into the .dbd-file -------------------*/
  1338. XCLASS Header    header;                            /* .dbd file header            */
  1339. XCLASS Record    *record;                        /* Record table                */
  1340. XCLASS Field        *field;                            /* Field table                */
  1341. XCLASS File        *file;                            /* File table                */
  1342. XCLASS Key        *key;                            /* Key table                */
  1343. XCLASS KeyField    *keyfield;                        /* Key field table            */
  1344. XCLASS Structdef *structdef;                        /* Struct definition table    */
  1345. X
  1346. XCLASS int        records        I( 0        );        /* Number of records in db    */
  1347. XCLASS int        fields        I( 0        );        /* Number of fields in db    */
  1348. XCLASS int        files        I( 0        );        /* Number of files in dbase    */
  1349. XCLASS int        keys          I( 0        );         /* # of entries in key      */
  1350. XCLASS int        keyfields     I( 0        );         /* # of entries in keyfield */
  1351. XCLASS int        structdefs    I( 0        );        /* # of entries in structdef*/
  1352. X
  1353. X#ifdef DEFINE_GLOBALS
  1354. X
  1355. Xstruct {
  1356. X    char type;
  1357. X    short size;
  1358. X    char *name;
  1359. X} typeinfo[] = {
  1360. X    FT_CHAR,    sizeof(char),        "char",
  1361. X    FT_CHARSTR,    sizeof(char),        "char",
  1362. X    FT_SHORT,    sizeof(short),        "short",
  1363. X    FT_INT,        sizeof(int),        "int",
  1364. X    FT_LONG,    sizeof(long),        "long",
  1365. X    FT_FLOAT,    sizeof(float),        "float",
  1366. X    FT_DOUBLE,    sizeof(double),        "double",
  1367. X#ifdef __STDC__
  1368. X    FT_LDOUBLE,    sizeof(long double),"long double",
  1369. X#else
  1370. X    FT_LDOUBLE,    sizeof(double),        "double"
  1371. X#endif
  1372. X};
  1373. X
  1374. X#else
  1375. X
  1376. Xextern struct {
  1377. X    char type;
  1378. X    short size;
  1379. X    char *name;
  1380. X} typeinfo[];
  1381. X
  1382. X
  1383. X
  1384. X#endif
  1385. X
  1386. X/* end-of-file */
  1387. END_OF_FILE
  1388.   if test 4316 -ne `wc -c <'typhoon/src/util/ddlpglob.h'`; then
  1389.     echo shar: \"'typhoon/src/util/ddlpglob.h'\" unpacked with wrong size!
  1390.   fi
  1391.   # end of 'typhoon/src/util/ddlpglob.h'
  1392. fi
  1393. if test -f 'typhoon/src/util/ddlplex.c' -a "${1}" != "-c" ; then 
  1394.   echo shar: Will not clobber existing file \"'typhoon/src/util/ddlplex.c'\"
  1395. else
  1396.   echo shar: Extracting \"'typhoon/src/util/ddlplex.c'\" \(4382 characters\)
  1397.   sed "s/^X//" >'typhoon/src/util/ddlplex.c' <<'END_OF_FILE'
  1398. X/*----------------------------------------------------------------------------
  1399. X * File    : ddlplex.c
  1400. X * Program : ddlp
  1401. X * OS      : UNIX, OS/2, DOS
  1402. X * Author  : Thomas B. Pedersen
  1403. X *
  1404. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  1405. X *
  1406. X * Permission is hereby granted, without written agreement and without
  1407. X * license or royalty fees, to use, copy, modify, and distribute this
  1408. X * software and its documentation for any purpose, provided that the above
  1409. X * copyright notice and the following two  paragraphs appear (1) in all 
  1410. X * source copies of this software and (2) in accompanying documentation
  1411. X * wherever the programatic interface of this software, or any derivative
  1412. X * of it, is described.
  1413. X *
  1414. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  1415. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  1416. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  1417. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1418. X *
  1419. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  1420. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  1421. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  1422. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  1423. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  1424. X *
  1425. X * Description:
  1426. X *   Lexical analyser for ddlp.
  1427. X *
  1428. X * $Log: ddlplex.c,v $
  1429. X * Revision 1.2  1994/09/17  16:00:51  tbp
  1430. X * typhoon.h and environ.h are now included from <>.
  1431. X *
  1432. X * Revision 1.1  1994/09/13  21:28:53  tbp
  1433. X * Added to repository.
  1434. X *
  1435. X * Added to repository.
  1436. X * 
  1437. X *
  1438. X *--------------------------------------------------------------------------*/
  1439. X
  1440. Xstatic char rcsid[] = "$Id: ddlplex.c,v 1.2 1994/09/17 16:00:51 tbp Exp $";
  1441. X
  1442. X#include <ctype.h>
  1443. X#include <stdio.h>
  1444. X#include <string.h>
  1445. X#ifndef UNIX
  1446. X#    include <stdlib.h>
  1447. X#endif
  1448. X
  1449. X#include <typhoon.h>
  1450. X#include "../ty_dbd.h"
  1451. X#include "ddlp.h"
  1452. X#include "ddl_y.h"
  1453. X#include "ddlpsym.h"
  1454. X#include "ddlpglob.h"
  1455. X#include "lex.h"
  1456. X#include "lex.c"
  1457. X
  1458. X/*---------------------------- Global variables ----------------------------*/
  1459. Xextern FILE *lex_file;                   /* input file                            */
  1460. Xextern int      lex_lineno;               /* current line number                    */
  1461. X
  1462. XLEX_KEYWORD lex_keywordtab[] = {
  1463. X    T_ALTERNATE,    "alternate",
  1464. X    T_ASC,            "asc",
  1465. X    T_BY,           "by",
  1466. X    T_CASCADE,        "cascade",
  1467. X    T_CHAR,            "char",
  1468. X    T_CONTAINS,        "contains",
  1469. X    T_CONTROLLED,    "controlled",
  1470. X    T_DATA,            "data",
  1471. X    T_DATABASE,        "database",
  1472. X    T_DEFINE,        "define",
  1473. X    T_DELETE,        "delete",
  1474. X    T_DESC,            "desc",
  1475. X    T_DOUBLE,        "double",
  1476. X    T_FILE,            "file",
  1477. X    T_FLOAT,        "float",
  1478. X    T_FOREIGN,        "foreign",
  1479. X    T_INT,            "int",
  1480. X    T_KEY,            "key",
  1481. X    T_LONG,            "long",
  1482. X    T_MAP,            "map",
  1483. X    T_NULL,            "null",
  1484. X    T_ON,            "on",
  1485. X    T_PRIMARY,        "primary",
  1486. X    T_RECORD,        "record",
  1487. X    T_REFERENCES,    "references",
  1488. X    T_RESTRICT,        "restrict",
  1489. X    T_SHORT,        "short",
  1490. X    T_SIGNED,        "signed",
  1491. X    T_STRUCT,        "struct",
  1492. X    T_UCHAR,        "uchar",
  1493. X    T_ULONG,        "ulong",
  1494. X    T_UNION,        "union",
  1495. X    T_UNIQUE,        "unique",
  1496. X    T_UNSIGNED,        "unsigned",
  1497. X    T_UPDATE,        "update",
  1498. X    T_USHORT,        "ushort",
  1499. X    T_VARIABLE,     "variable"
  1500. X};
  1501. X
  1502. Xint lex_keywords = sizeof(lex_keywordtab) / sizeof(lex_keywordtab[0]);
  1503. X
  1504. Xyylex()
  1505. X{
  1506. X    int c, i;
  1507. X
  1508. X    for( ;; )
  1509. X    {
  1510. X        c = getc(lex_file);
  1511. X
  1512. X        if( c == ' ' || c == '\t' )         /* skip whitespace                 */
  1513. X            ;
  1514. X        else if( isalpha(c) )                /* keyword                      */
  1515. X            return lex_parse_keyword(c);
  1516. X        else if( isdigit(c) )                /* number                        */
  1517. X            return lex_parse_number(c);
  1518. X        else if( c == '"' )                 /* string                       */
  1519. X            return lex_parse_string();
  1520. X        else if ( c== '\'' )
  1521. X            return lex_parse_charconst();    /* character constant            */
  1522. X        else if( c == '\n' )                /* increase line count            */
  1523. X            lex_lineno++;
  1524. X        else if( c == EOF )
  1525. X            return EOF;
  1526. X        else if( c == '/' )
  1527. X        {
  1528. X            if( (c = getc(lex_file)) == '*' )    /* C comment                   */
  1529. X                lex_skip_comment();
  1530. X            else if( c == '/' )                   /* C++ comment                     */
  1531. X            {
  1532. X                while( getc(lex_file) != '\n' && !feof(lex_file) )
  1533. X                    ;
  1534. X                lex_lineno++;
  1535. X            }
  1536. X            else
  1537. X            {
  1538. X                ungetc(c, lex_file);
  1539. X                return '/';
  1540. X            }
  1541. X        }
  1542. X        else if( c == '-' )
  1543. X        {
  1544. X            if( (c=getc(lex_file)) == '>' )
  1545. X                return T_ARROW;
  1546. X            ungetc(c, lex_file);
  1547. X            return '-';
  1548. X        }
  1549. X        else if( strchr("[]{};,+*().", c) )
  1550. X            return c;
  1551. X        else if( c == '#' )
  1552. X        {
  1553. X            while( getc(lex_file) != '\n' && !feof(lex_file) )
  1554. X                ;
  1555. X            lex_lineno++;
  1556. X        }
  1557. X        else
  1558. X            yyerror("syntax error");
  1559. X    }
  1560. X}
  1561. X
  1562. X/* end-of-file */
  1563. END_OF_FILE
  1564.   if test 4382 -ne `wc -c <'typhoon/src/util/ddlplex.c'`; then
  1565.     echo shar: \"'typhoon/src/util/ddlplex.c'\" unpacked with wrong size!
  1566.   fi
  1567.   # end of 'typhoon/src/util/ddlplex.c'
  1568. fi
  1569. if test -f 'typhoon/src/util/ddlpsym.h' -a "${1}" != "-c" ; then 
  1570.   echo shar: Will not clobber existing file \"'typhoon/src/util/ddlpsym.h'\"
  1571. else
  1572.   echo shar: Extracting \"'typhoon/src/util/ddlpsym.h'\" \(4337 characters\)
  1573.   sed "s/^X//" >'typhoon/src/util/ddlpsym.h' <<'END_OF_FILE'
  1574. X/*----------------------------------------------------------------------------
  1575. X * File    : ddlpsym.h
  1576. X * Program : ddlp
  1577. X * OS      : UNIX, OS/2, DOS
  1578. X * Author  : Thomas B. Pedersen
  1579. X *
  1580. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  1581. X *
  1582. X * Permission is hereby granted, without written agreement and without
  1583. X * license or royalty fees, to use, copy, modify, and distribute this
  1584. X * software and its documentation for any purpose, provided that the above
  1585. X * copyright notice and the following two  paragraphs appear (1) in all 
  1586. X * source copies of this software and (2) in accompanying documentation
  1587. X * wherever the programatic interface of this software, or any derivative
  1588. X * of it, is described.
  1589. X *
  1590. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  1591. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  1592. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  1593. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1594. X *
  1595. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  1596. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  1597. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  1598. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  1599. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  1600. X *
  1601. X * Description:
  1602. X *   Symbol table definitions.
  1603. X *
  1604. X * $Id: ddlpsym.h,v 1.1 1994/09/13 21:28:54 tbp Exp $
  1605. X *
  1606. X * $Log: ddlpsym.h,v $
  1607. X * Revision 1.1  1994/09/13  21:28:54  tbp
  1608. X * Added to repository.
  1609. X *
  1610. X * Added to repository.
  1611. X * 
  1612. X *
  1613. X *--------------------------------------------------------------------------*/
  1614. X
  1615. X/* The following constants define translation limits of the parser according to
  1616. X * ISO/IEC DIS 9899 section 2.2.41.
  1617. X */
  1618. X
  1619. X#define NEST_MAX        15                    /* Max nesting level            */
  1620. X#define NAME_LEN        31                    /* Number of significant initial*/
  1621. X                                            /* characters in a name            */
  1622. X
  1623. Xtypedef struct sym_member {
  1624. X    char                type;                /* See FT_.. constants            */
  1625. X    char                name[NAME_LEN+1];    /* Member name                    */
  1626. X    unsigned            elemsize;           /* Size of each element         */
  1627. X    unsigned            size;                /* sizeof (total size incl. dim)*/
  1628. X    unsigned            offset;                /* Offset from start of struct    */
  1629. X    struct sym_member    *next;                /* Next member                    */
  1630. X    struct sym_struct    *struc;                /* If type is FT_STRUCT this    */
  1631. X                                            /* points to the structdef that    */
  1632. X                                            /* defines the struct type        */
  1633. X    /*---------- ddlp extensions -------------------------------------------*/
  1634. X    Id                    id;                    /* Field id                        */
  1635. X    /*----------------------------------------------------------------------*/
  1636. X    unsigned            dims;                /* Number of dimensions            */
  1637. X    unsigned            dim[1];                /* Dimensions if <dims> > 0        */
  1638. X} sym_member;
  1639. X
  1640. Xtypedef struct sym_struct {
  1641. X    char                name[NAME_LEN+1];    /* Struct name                    */
  1642. X    char                printed;            /* This field ensures that the    */
  1643. X                                            /* full structure definition is */
  1644. X                                            /* printed once only.            */
  1645. X    char                is_union;            /* True if this is a union        */
  1646. X    unsigned            size;                /* sizeof                        */
  1647. X    unsigned            members;            /* Number of members            */
  1648. X    sym_member             *first_member;        /* First member                    */
  1649. X    sym_member             *last_member;        /* Last member                    */
  1650. X    struct sym_struct    *next;                /* Next structdef                */
  1651. X    /*---------- ddlp extensions -------------------------------------------*/
  1652. X    Id                    fieldid;               /* Field id                        */
  1653. X    /*----------------------------------------------------------------------*/
  1654. X} sym_struct;
  1655. X
  1656. X
  1657. X
  1658. X/*
  1659. X    +--------+    +--------+    +--------+    +--------+
  1660. X    | struct |--->| member |--->| member |--->| member |--->NULL
  1661. X    +--------+    +--------+    +--------+    +--------+
  1662. X         |
  1663. X         |
  1664. X         v
  1665. X    +--------+    +--------+    +--------+    +--------+
  1666. X    | struct |--->| member |--->| member |--->| member |--->NULL
  1667. X    +--------+    +--------+    +--------+    +--------+
  1668. X         |
  1669. X         |
  1670. X         v
  1671. X    +--------+    +--------+
  1672. X    | struct |--->| member |
  1673. X    +--------+    +--------+
  1674. X         |
  1675. X         |
  1676. X         v
  1677. X       NULL
  1678. X*/
  1679. X
  1680. Xextern sym_struct *structnest[], *cur_str, *last_str;
  1681. Xextern int curnest;
  1682. X
  1683. Xvoid         sym_addmember        PRM( (char *, int, sym_struct *); )
  1684. Xvoid         sym_addstruct        PRM( (char *, int); )
  1685. Xvoid         sym_endstruct        PRM( (void); )
  1686. Xsym_struct    *sym_findstruct        PRM( (char *, int); )
  1687. Xsym_member    *sym_findmember        PRM( (sym_struct *, char *); )
  1688. Xvoid         print_structures    PRM( (void); )
  1689. X
  1690. X
  1691. X/* end-of-file */
  1692. END_OF_FILE
  1693.   if test 4337 -ne `wc -c <'typhoon/src/util/ddlpsym.h'`; then
  1694.     echo shar: \"'typhoon/src/util/ddlpsym.h'\" unpacked with wrong size!
  1695.   fi
  1696.   # end of 'typhoon/src/util/ddlpsym.h'
  1697. fi
  1698. if test -f 'typhoon/src/util/exportlx.c' -a "${1}" != "-c" ; then 
  1699.   echo shar: Will not clobber existing file \"'typhoon/src/util/exportlx.c'\"
  1700. else
  1701.   echo shar: Extracting \"'typhoon/src/util/exportlx.c'\" \(3344 characters\)
  1702.   sed "s/^X//" >'typhoon/src/util/exportlx.c' <<'END_OF_FILE'
  1703. X/*----------------------------------------------------------------------------
  1704. X * File    : exportlx.c
  1705. X * Program : tyexport
  1706. X * OS      : UNIX, OS/2, DOS
  1707. X * Author  : Thomas B. Pedersen
  1708. X *
  1709. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  1710. X *
  1711. X * Permission is hereby granted, without written agreement and without
  1712. X * license or royalty fees, to use, copy, modify, and distribute this
  1713. X * software and its documentation for any purpose, provided that the above
  1714. X * copyright notice and the following two  paragraphs appear (1) in all 
  1715. X * source copies of this software and (2) in accompanying documentation
  1716. X * wherever the programatic interface of this software, or any derivative
  1717. X * of it, is described.
  1718. X *
  1719. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  1720. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  1721. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  1722. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1723. X *
  1724. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  1725. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  1726. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  1727. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  1728. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  1729. X *
  1730. X * Description:
  1731. X *   Lexical analyser for export utility.
  1732. X *
  1733. X * $Log: exportlx.c,v $
  1734. X * Revision 1.2  1994/09/17  16:00:53  tbp
  1735. X * typhoon.h and environ.h are now included from <>.
  1736. X *
  1737. X * Revision 1.1  1994/09/13  21:28:56  tbp
  1738. X * Added to repository.
  1739. X *
  1740. X * Added to repository.
  1741. X * 
  1742. X *
  1743. X *--------------------------------------------------------------------------*/
  1744. X
  1745. Xstatic char rcsid[] = "$Id: exportlx.c,v 1.2 1994/09/17 16:00:53 tbp Exp $";
  1746. X
  1747. X#include <ctype.h>
  1748. X#include <stdio.h>
  1749. X#include <string.h>
  1750. X#ifndef UNIX
  1751. X#    include <stdlib.h>
  1752. X#endif
  1753. X
  1754. X#include <environ.h>
  1755. X#include "../ty_dbd.h"
  1756. X#include "ddlp.h"
  1757. X#include "exp_y.h"
  1758. X#include "ddlpsym.h"
  1759. X#include "ddlpglob.h"
  1760. X#include "lex.h"
  1761. X#include "lex.c"
  1762. X
  1763. X/*---------------------------- Global variables ----------------------------*/
  1764. XFILE    *lex_file;                    /* input file                            */
  1765. X
  1766. X
  1767. XLEX_KEYWORD lex_keywordtab[] = {
  1768. X    T_EXPORT,        "export",
  1769. X    T_IN,            "in",
  1770. X    T_RECORD,        "record",
  1771. X    T_STRUCT,        "struct",
  1772. X    T_UNION,        "union"
  1773. X};
  1774. Xint lex_keywords = sizeof(lex_keywordtab) / sizeof(lex_keywordtab[0]);
  1775. X
  1776. X
  1777. X
  1778. Xyylex()
  1779. X{
  1780. X    int c, i;
  1781. X
  1782. X    for( ;; )
  1783. X    {
  1784. X        c = getc(lex_file);
  1785. X
  1786. X        if( c == ' ' || c == '\t' )         /* skip whitespace                 */
  1787. X            ;
  1788. X        else if( isalpha(c) )                /* keyword                      */
  1789. X            return lex_parse_keyword(c);
  1790. X#if 0
  1791. X        else if( isdigit(c) )                /* number                        */
  1792. X            return lex_parse_number(c);
  1793. X#endif
  1794. X        else if( c == '"' )                 /* string                       */
  1795. X            return lex_parse_string();
  1796. X        else if( c == '\n' )                /* increase line count            */
  1797. X            lex_lineno++;
  1798. X        else if( c == EOF )
  1799. X            return EOF;
  1800. X         else if( strchr("[]{};,+*-().", c) )
  1801. X            return c;
  1802. X        else if( c == '/' )
  1803. X        {
  1804. X            if( (c = getc(lex_file)) == '*' )/* C comment                     */
  1805. X                lex_skip_comment();
  1806. X            else if( c == '/' )                   /* C++ comment                     */
  1807. X            {
  1808. X                while( getc(lex_file) != '\n' && !feof(lex_file) )
  1809. X                    ;
  1810. X                lex_lineno++;
  1811. X            }
  1812. X            else
  1813. X            {
  1814. X                ungetc(c, lex_file);
  1815. X                return '/';
  1816. X            }
  1817. X        }
  1818. X        else
  1819. X            yyerror("unexpected character '%s'", c);
  1820. X    }
  1821. X}
  1822. X
  1823. X/* end-of-file */
  1824. X
  1825. END_OF_FILE
  1826.   if test 3344 -ne `wc -c <'typhoon/src/util/exportlx.c'`; then
  1827.     echo shar: \"'typhoon/src/util/exportlx.c'\" unpacked with wrong size!
  1828.   fi
  1829.   # end of 'typhoon/src/util/exportlx.c'
  1830. fi
  1831. if test -f 'typhoon/src/util/importlx.c' -a "${1}" != "-c" ; then 
  1832.   echo shar: Will not clobber existing file \"'typhoon/src/util/importlx.c'\"
  1833. else
  1834.   echo shar: Extracting \"'typhoon/src/util/importlx.c'\" \(3383 characters\)
  1835.   sed "s/^X//" >'typhoon/src/util/importlx.c' <<'END_OF_FILE'
  1836. X/*----------------------------------------------------------------------------
  1837. X * File    : importlx.c
  1838. X * Program : tyimport
  1839. X * OS      : UNIX, OS/2, DOS
  1840. X * Author  : Thomas B. Pedersen
  1841. X *
  1842. X * Copyright (c) 1994 Thomas B. Pedersen.  All rights reserved.
  1843. X *
  1844. X * Permission is hereby granted, without written agreement and without
  1845. X * license or royalty fees, to use, copy, modify, and distribute this
  1846. X * software and its documentation for any purpose, provided that the above
  1847. X * copyright notice and the following two  paragraphs appear (1) in all 
  1848. X * source copies of this software and (2) in accompanying documentation
  1849. X * wherever the programatic interface of this software, or any derivative
  1850. X * of it, is described.
  1851. X *
  1852. X * IN NO EVENT SHALL THOMAS B. PEDERSEN BE LIABLE TO ANY PARTY FOR DIRECT,
  1853. X * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
  1854. X * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF HE HAS BEEN 
  1855. X * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  1856. X *
  1857. X * THOMAS B. PEDERSEN SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
  1858. X * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  1859. X * A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" 
  1860. X * BASIS, AND THOMAS B. PEDERSEN HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
  1861. X * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
  1862. X *
  1863. X * Description:
  1864. X *   Lexical analyser for import utility.
  1865. X *
  1866. X * $Log: importlx.c,v $
  1867. X * Revision 1.2  1994/09/17  16:00:55  tbp
  1868. X * typhoon.h and environ.h are now included from <>.
  1869. X *
  1870. X * Revision 1.1  1994/09/13  21:28:58  tbp
  1871. X * Added to repository.
  1872. X *
  1873. X * Added to repository.
  1874. X * 
  1875. X *
  1876. X *--------------------------------------------------------------------------*/
  1877. X
  1878. Xstatic char rcsid[] = "$Id: importlx.c,v 1.2 1994/09/17 16:00:55 tbp Exp $";
  1879. X
  1880. X#include <ctype.h>
  1881. X#include <stdio.h>
  1882. X#include <string.h>
  1883. X#ifndef UNIX
  1884. X#include <stdlib.h>
  1885. X#endif
  1886. X
  1887. X#include <environ.h>
  1888. X#include "../ty_dbd.h"
  1889. X#include "ddlp.h"
  1890. X#include "imp_y.h"
  1891. X#include "ddlpsym.h"
  1892. X#include "ddlpglob.h"
  1893. X#include "lex.h"
  1894. X#include "lex.c"
  1895. X
  1896. X#if YYDEBUG
  1897. X#define D(x) x
  1898. X#else
  1899. X#define D(x)
  1900. X#endif
  1901. X
  1902. X
  1903. X
  1904. X/*---------------------------- Global variables ----------------------------*/
  1905. XFILE    *lex_file;                    /* input file                            */
  1906. X
  1907. X
  1908. XLEX_KEYWORD lex_keywordtab[] = {
  1909. X    T_IMPORT,        "import",
  1910. X    T_IN,            "in",
  1911. X    T_RECORD,        "record",
  1912. X    T_STRUCT,        "struct",
  1913. X    T_UNION,        "union"
  1914. X};
  1915. Xint lex_keywords = sizeof(lex_keywordtab) / sizeof(lex_keywordtab[0]);
  1916. X
  1917. X
  1918. X
  1919. Xyylex()
  1920. X{
  1921. X    int c, i;
  1922. X
  1923. X    for( ;; )
  1924. X    {
  1925. X        c = getc(lex_file);
  1926. X
  1927. X        if( c == ' ' || c == '\t' )         /* skip whitespace                 */
  1928. X            ;
  1929. X        else if( isalpha(c) )                /* keyword                      */
  1930. X            return lex_parse_keyword(c);
  1931. X#if 0
  1932. X        else if( isdigit(c) )                /* number                        */
  1933. X            return lex_parse_number(c);
  1934. X#endif
  1935. X        else if( c == '"' )                 /* string                       */
  1936. X            return lex_parse_string();
  1937. X        else if( c == '\n' )                /* increase line count            */
  1938. X            lex_lineno++;
  1939. X        else if( c == EOF )
  1940. X            return EOF;
  1941. X         else if( strchr("[]{};,+*-().", c) )
  1942. X            return c;
  1943. X        else if( c == '/' )
  1944. X        {
  1945. X            if( (c = getc(lex_file)) == '*' )/* C comment                     */
  1946. X                lex_skip_comment();
  1947. X            else if( c == '/' )                   /* C++ comment                     */
  1948. X            {
  1949. X                while( getc(lex_file) != '\n' && !feof(lex_file) )
  1950. X                    ;
  1951. X                lex_lineno++;
  1952. X            }
  1953. X            else
  1954. X            {
  1955. X                ungetc(c, lex_file);
  1956. X                return '/';
  1957. X            }
  1958. X        }
  1959. X        else
  1960. X            yyerror("syntax error");
  1961. X    }
  1962. X}
  1963. X
  1964. X/* end-of-file */
  1965. X
  1966. END_OF_FILE
  1967.   if test 3383 -ne `wc -c <'typhoon/src/util/importlx.c'`; then
  1968.     echo shar: \"'typhoon/src/util/importlx.c'\" unpacked with wrong size!
  1969.   fi
  1970.   # end of 'typhoon/src/util/importlx.c'
  1971. fi
  1972. echo shar: End of archive 7 \(of 9\).
  1973. cp /dev/null ark7isdone
  1974. MISSING=""
  1975. for I in 1 2 3 4 5 6 7 8 9 ; do
  1976.     if test ! -f ark${I}isdone ; then
  1977.     MISSING="${MISSING} ${I}"
  1978.     fi
  1979. done
  1980. if test "${MISSING}" = "" ; then
  1981.     echo You have unpacked all 9 archives.
  1982.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1983. else
  1984.     echo You still must unpack the following archives:
  1985.     echo "        " ${MISSING}
  1986. fi
  1987. exit 0
  1988. exit 0 # Just in case...
  1989.