3 # openisis - an open implementation of the CDS/ISIS database
4 # Version 0.8.x (patchlevel see file Version)
5 # Copyright (C) 2001-2003 by Erik Grziwotz, erik@openisis.org
7 # This library is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This library is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this library; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 # see README for more information
24 # $Id: OpenIsis.pm,v 1.3 2003/04/08 00:20:53 kripke Exp $
25 # perl module wrapper for openisis perl XSUB
30 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
36 @ISA = qw(Exporter DynaLoader);
37 # Items to export into callers namespace by default. Note: do not export
38 # names by default without a very good reason. Use EXPORT_OK instead.
39 # Do not simply export all your public functions/methods/constants.
45 bootstrap OpenIsis $VERSION;
47 # query mode constants
80 # Preloaded methods go here.
84 s/(<[^=>]*)=[^>]+>/$1>/g; # dump <a=b> substitutions
85 s/></; /g; # replace >< pairs
86 s/[><]//g; # nuke other ><
87 s/^\^.//; # kill initial subfield spec
89 s/\^[b-i]/, /g; # ^[b-i] -> ,
90 s/\^./. /g; # others -> .
94 # Autoload methods go after =cut, and are processed by the autosplit program.
98 # Below is the stub of documentation for the OpenIsis module.
102 OpenIsis - Perl extension for accessing ISIS databases
107 $db = OpenIsis::open( 'basename', '-dbpath', '/home/me/mydb' );
108 $maxmfn = OpenIsis::maxRowid( $db );
109 for (OpenIsis::query( $db, 'plant * water' )) {
110 my $row = OpenIsis::read( $db, $_ ); # get hashref
111 $row = OpenIsis::read( $db, $_, 'MHL V24,V26,V71' ); # read formatted
112 my $v24 = $row->{'24'}; # field tags map to arrayrefs
113 OpenIsis::MHL( @$v24 ); # apply heading mode to array
114 print $row->{'mfn'}, "TITLE :", join("\n ", @$v24 ), "\n";
115 my $v30 = $row->{'30'}->[0]; # contents is like ^ap. 233-238 ^billus.
116 my $subfields = OpenIsis::subfields( $v30 ); # get subfield values
117 print "a = ", $subfields->{'a'}, " b = ", $subfields->{'b'}, "\n";
119 # print terms starting with A
120 print join('; ',OpenIsis::terms( $db, 'a$' )), "\n";
124 The OpenIsis perl extension provides access to ISIS databases
125 based on the openisis C library.
130 =item OpenIsis::open( name [, args ...] )
132 Open a CDS/Isis data base.
134 name: basename of a CDS/Isis database.
135 If given, will be prepended, and the Isis file extensions appended
136 to build the actual filename. Depending on the value of dbname and
137 location of files, this may need to include a path. Dbname may be NULL,
138 if argv includes a dbname argument.
140 args: array of names and values; may be empty.
141 Contains parameters names, which may be prefixed by a dash
142 ('-'). Depending on the actual parameter, the next string may or must
143 contain a corresponding parameter value. An optional parameter value
144 may be omitted, if at end of argv or the next name is prefixed with a
145 dash. To avoid ambiguity, values never start with a dash.
146 Unrecognized parameter names are ignored.
150 -db: basename of database; same as param name;
151 -dbpath: path to database;
152 usefull when opening secondary indexes or other files
153 whose names are not based on the db basename;
154 -v: set verbosity level.
158 non-negative number (dbid)Success
164 $db = OpenIsis::open( 'cds', '-dbpath', '/var/db/cds/' );
165 $db = OpenIsis::open( '/var/db/cds/cds' );
166 $db = OpenIsis::open( '/var/db/cds/cds', '-v', -1 );
169 } elsif ( OpenIsis::ERR_BADF == $db ) {
170 print STDERR "/var/db/cds/cds does not exist\n";
171 } elsif ( OpenIsis::ERR_IO == $db ) {
172 print STDERR "/var/db/cds/cds is not accessible\n";
174 print STDERR "/var/db/cds/cds had strange error $db\n";
177 see also:Query; Terms; Maxrowid
181 =item OpenIsis::maxRowid( $db )
183 Get highest rowid (a.k.a. MFN) in data base.
185 dbid: Data base identifier returned by open
189 positive number correspondent highest rowid
191 negative number Error
195 $db = OpenIsis::open( $base );
196 $maxmfn = OpenIsis::maxRowid( $db );
201 =item OpenIsis::query( $db, $qry )
203 =item OpenIsis::terms( $db, $key )
205 =item OpenIsis::read( $db, $rowid [, pft] )
207 =item OpenIsis::2html( $str )
209 =item OpenIsis::subfields( $str )
211 =item OpenIsis::log( $level, $filename )
213 set logging level to a number between 0 (no logging) and 10 (lots of log).
214 A filename for logging output is currently ignored.
216 =item OpenIsis::MHL( ... )
222 Erik Grziwotz, erik@openisis.org
224 Documentation added by Paulo Cattelan, cattelan@control.com.br