Using the Xbase For Linux Library

Getting Started

Install the Xbase source code

Execute the following commands to install the Xbase code:

su (if not signed on as root)
cd /usr
mkdir xbase

Set up security for the new directories. The next two commands are set up to define a default level of access to the xbase directories. Actual mileage may vary. Your site may have specific prorocols on directory security which should be addressed here. If you just want to get it going, then the next two commands will work.

  • chown YourUserId.users xbase
  • chmod 775 xbase

    cp /home/of/xbase.tar.gz /usr/xbase
    cd xbase
    gunzip xbase.tar.gz
    tar -xvf xbase.tar
    ls -l

    There should be three directories at this point, src, samples and html

    chown -Rv YourUserId.users *
    exit (if su was used)


    Building the Xbase Library

    Execute the following commands to build the xbase library:

    cd /usr/xbase/src
    make all

    If there are any errors in this step it is probably due to either the compiler not being set up on the machine, or some of the include (.h) files are not where the Makefile expects to find them. After this step completes, a file called xbase.a will be in the xbase/src directory. This is the Xbase library.


    Building a program with the Xbase library

    Create a directory for your project:

    cd /usr/xbase
    mkdir MyProject
    cd MyProject
    vi MySource.cc

    To use the Xbase classes, include the following header file in the program:

    #include "xbase.h"


    Compiling an Application Program

    Execute the following command to compile a program:
    g++ -c -I/usr/include -I/usr/src/linux/include/asm-i386 -I../src myprog.cc

    Execute the following command to link edit the program:
    g++ -o myprog myprog.o xbase.a

    Note: The -I/usr/src/linux/include/asm-i386 option in the above compile command is for Linux running on the Intel platform. Other platforms require the correct include directory.



    System Limitations


    Maximum size of a database file is the size of LONG - 2,147,483,647 bytes
    Total number of fields in a database - 1024
    Total number of characters in all fields - 32767
    Maximum number of characters in a field - 254
    Total number of records in a file - 1 billion
    Maximum index key length - 100 bytes
    Maximum .DBT file memo block size - 32256

    The current NDX indexes only support single field, character keys. Future versions of Xbase will support numeric keys as well as full index key expressions.


    Directory Structure

    The recommended directory structure is automatically created when the X-Base source is installed.

    Recommended Xbase Directory Structure

    DirectoryDescription
    /usr/xbaseBase Directory for X-Base
    /usr/xbase/srcX-Base source code
    /usr/xbase/samplesX-Base samples
    /usr/xbase/MyProject1Your first project
    /usr/xbase/MyProject2Your second project



    Type Defs and Structures

    To effectively make a library as portable across platforms as possible, fields must be consistantly defined in each environment. The types.h file defines the xbase data types. To modify the Xbase code base to function in a different (non Linux) environment, start by modifying the types.h file for your site and recompile.

    Field Types

    TypeDescription
    ULONGUnsigned Long
    UCHARUnsigned Char
    USHORTUnsigned Short Integer
    LONGLong
    CHARChar
    VOIDVoid
    struct SCHEMAUsed for defining record structures



    Xbase Compile Options

    The OPTIONS.H header file contains compile options which impact the Xbase library.

    Options

    OptionDescription
    DEBUGThis define compiles in support for various debugging routines and more extensive error message checking. Use DEBUG mode during application development and to generate smaller production executable programs, comment this define out before building the Xbase library.
    UI_HTML_ONTuns on the option for the HTML generation class.
    INDEX_NDXThis define compiles in support for NDX indexes. Comment this line out to drop support for NDX indexes.
    LOCKING_ONNeeded for multi user configuration. It is safe to remove this option for single user environments.
    UNIXLeave this one on for now.
    MEMO_FIELDSThis define compiles in support for memo (variable length) fields.
    DBT_BLOCK_SIZEThis defines the default block size to use when creating memo .DBT files. It must be an increment of 512 bytes. The maximum block size is 32256.




    Send me mail - xbase@startech.keller.tx.us

    (c)1997 StarTech