The OpenNET Project / Index page

[ новости /+++ | форум | теги | ]

Using the Xbase DBMS in a Linux Environment (linux xbase database)


<< Предыдущая ИНДЕКС Поиск в статьях src Установить закладку Перейти на закладку Следующая >>
Ключевые слова: linux, xbase, database,  (найти похожие документы)
_ RU.LINUX (2:5077/15.22) ___________________________________________ RU.LINUX _ From : Boris Tobotras 2:5020/510 04 Oct 98 17:53:52 Subj : Using the Xbase DBMS in a Linux Environment ________________________________________________________________________________ "Linux Gazette...making Linux just a little more fun!" ------------------------------------------------------------------------ Using the Xbase DBMS in a Linux Environment By Gary Kunkel ------------------------------------------------------------------------ Introduction The Xbase file structure has been around quite a while and was one of the first widely available DBMS tools for micro computers. It has become a de-facto industry standard for text based databases and is supported by many vendors to include the Borland Database Engine, Microsoft's FoxPro, Clipper, Sequitor's Codebase and others. Xbase type datafiles will be with us for a while. The Startech Web Server at http://www.startech.keller.tx.us/xbase/xbase.html maintains a public domain, open source C++ library for accessing Xbase type datafiles in a multi-user environment. The library supports automatic record locking, memo fields (both dBase III and IV versions), and .NDX style indices. There is also an API for interfacing the library to an Apache Web Server and providing database access to web pages. Several example programs provide a framework for creating, browsing and updating databases. There are examples which demonstrate how to use the library with an Apache Web Server and using the library in conjunction with the wxWindows library. Some readers of this article will recognize the wxWindows library as a cross platform GUI C++ library. ------------------------------------------------------------------------ System Requirements In order to use the Xbase DBMS library, you'll need to have a C/C++ compiler. The original library was built on a Slackware distribution with the GNU public domain compiler, but there are examples on the site for using the library on other platforms including Windows, SUN, and VMS. ------------------------------------------------------------------------ Getting Sources To downloading the library sources, point your web browser to http://www.startech.keller.tx.us/xbase/xbase.html and select the latest version, which at the time of this writing is version 1.7.4 dated 6/18/98. There are a couple of flavors available, but for the purpose of this article, download the UNIX tar version. Also, you may want to grab the HTML documentation for using the library at the same time. Alternatively, you can get the software via ftp ftp.startech.keller.tx.us and retrieve the software from the pub/xbase directory. ------------------------------------------------------------------------ Installing Sources To install the Xbase library under the /usr/local directory, execute the following commands: cd /usr/local and mkdir xbase. The next step is to set up access rights to the Xbase directory tree. Your site may have specific protocols on directory access rights which you may need to address at this point. If not, then the commands "chown YOURUSERID.users xbase", then "chmod 775 xbase" will get you going. Now create a source directory and copy the source code into it: "cd xbase", "mkdir src", "cp /home/of/xbase.tar.gz /usr/local/xbase/src", "cd /usr/local/xbase/src", "gunzip xbase.tar.gz" and lastly "tar -xvf xbase.tar". At this point the Xbase source code should be in the /usr/local/xbase/src directory and be ready to build the library. ------------------------------------------------------------------------ Building the Library Before building the library, review the options.h file. This file contains any of the Xbase configuration switches you may want or need to change depending on what you are trying to do. To build a DLL library, type "make dll". To build a static library, type "make all". It should compile cleanly. Errors at this point can often be traced to the .h header files currently in use at your site. If you run into errors at this point, notify xbase@startech.keller.tx.us for help building the library. ------------------------------------------------------------------------ Building a Sample Program This sample program demonstrates a simple program which creates a sample database and index. /* sample1.cpp */ #include "xbase.h" main() { Schema MyRecord[] = { { "FIRSTNAME", CHAR_FLD, 15, 0 }, { "LASTNAME", CHAR_FLD, 20, 0 }, { "BIRTHDATE", DATE_FLD, 8, 0 }, { "AMOUNT", NUMERIC_FLD, 9, 2 }, { "SWITCH", LOGICAL_FLD, 1, 0 }, { "FLOAT1", FLOAT_FLD, 9, 2 }, { 0,0,0,0 } }; /* define the classes */ XBASE x; /* initialize xbase */ DBF MyFile( &x ); /* class for table */ NDX MyIndex( &MyFile ); /* class for index 1 */ SHORT rc; /* return code */ if(( rc = MyFile.CreateDatabase( "MYFILE.DBF", MyRecord, OVERLAY )) != NO_ERROR ) cout << "\nError creating database = " << rc << "\n"; else { /* define a simple index */ if(( rc = MyIndex1.CreateIndex( "MYINDEX.NDX", "LASTNAME", 0, 1 )) != NO_ERROR ) cout << "\nError creating index 1 = " << rc << "\n"; } MyFile.CloseDatabase(); /* Close database and associated indexes */ return 0; } Assuming you keyed the program source into directory /usr/local/xbase/myproj, type "g++ -c -I/usr/include -I/usr/src/linux/include/asm-i386 -I../src sample1.cpp" to compile the program and type "g++ -o sample1 sample1.o ../src/xbase.a" to link edit the program. The asm-i386 directory in the above include line is for Linux running on the Intel platform. Other platforsm require the correct include directory. ------------------------------------------------------------------------ Conclusion In conclusion, I'd like to say that although the Xbase library is not a 100% complete Xbase solution, it is a stable and reliable library capable of handling various database requirements. If you are looking for database libraries in general, or need access to Xbase files in particular, give Xbase DBMS a try. If you are a C programmer and new to C++ object oriented programming, the Xbase DBMS is easy to learn and will help transition you to the world of object oriented programming. If you have never programmed in C or C++ before, this library should provide complete enough examples to get you started programming in C/C++ with confidence. ------------------------------------------------------------------------ Copyright (C) 1998, Gary Kunkel Published in Issue 33 of Linux Gazette, October 1998 ------------------------------------------------------------------------ [ TABLE OF CONTENTS ] [ FRONT PAGE ] [ Back ] [ Next ] ------------------------------------------------------------------------ -- Best regards, -- Boris. Never make anything simple and efficient when a way can be found to make it complex and wonderful. --- Gnus v5.5/XEmacs 20.3 - "London" * Origin: Linux inside (2:5020/510@fidonet)

<< Предыдущая ИНДЕКС Поиск в статьях src Установить закладку Перейти на закладку Следующая >>

 Добавить комментарий
Имя:
E-Mail:
Заголовок:
Текст:




Партнёры:
PostgresPro
Inferno Solutions
Hosting by Hoster.ru
Хостинг:

Закладки на сайте
Проследить за страницей
Created 1996-2024 by Maxim Chirkov
Добавить, Поддержать, Вебмастеру