2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: c_api_bookcase.cc /main/5 1996/07/18 16:00:51 drk $ */
25 #include "oliasdb/c_api_common.h"
27 //extern void_ptr_array* infolib_array;
28 extern void_ptr_array* bookcase_array;
29 //extern olias_server* oserver_ptr;
30 extern OLIAS_DB* mmdb_ptr;
33 ///////////////////////////////////////////////////////////////
36 DtMmdbGetBookCaseByName(int infolib_descriptor, const char* name)
39 info_lib* x = mmdb_ptr -> getInfoLib(infolib_descriptor);
41 if ( x == 0 ) return -1;
43 info_base* base = x -> get_info_base(name);
48 return base -> index_id();
51 catch (mmdbException &,e)
59 DtMmdbGetBookCaseByIndex(int infolib_descriptor, int index)
62 info_lib* x = mmdb_ptr -> getInfoLib(infolib_descriptor);
64 if ( x == 0 ) return -1;
66 if ( 0 <= index && index < x -> num_of_bases() ) {
70 long ind = x -> first();
71 for ( int i=0; i<index; i++ )
79 return base -> index_id();
84 catch (mmdbException &,e)
92 DtMmdbGetBookCaseByLoc(int infolib_descriptor, const char* locator)
95 info_lib* x = mmdb_ptr -> getInfoLib(infolib_descriptor);
97 if ( x == 0 ) return -1;
99 //info_base* base = oserver_ptr -> get_infobase(locator, olias_server::LOC);
100 info_base* base = x -> getInfobaseByComponent(locator, info_lib::LOC);
105 return base -> index_id();
108 catch (mmdbException &,e)
117 DtMmdbGetBookCaseByLocs(int infolib_descriptor, const char** locators,
122 info_lib* x = mmdb_ptr -> getInfoLib(infolib_descriptor);
124 if ( x == 0 ) return 0;
127 while ( locators[count] )
131 x -> getInfobasesByComponent((char**)locators, count, info_lib::LOC);
134 while ( bases[count] )
137 int* ds = (int*) malloc(sizeof(int)*(count+1));
139 for ( int i=0; i<count; i++ )
140 ds[i] = bases[i] -> index_id();
144 if (count_ptr) *count_ptr = count;
149 catch (mmdbException &,e)
151 if (count_ptr) *count_ptr = 0;
160 DtMmdbBookCaseGetInfo(int bookcase_descriptor)
163 info_base* x = getBookCase(bookcase_descriptor);
165 if ( x == 0 ) return 0;
167 DtMmdbBookCaseInfo *y =
168 (DtMmdbBookCaseInfo*)malloc(sizeof(DtMmdbBookCaseInfo));
170 if ( y == 0 ) return 0;
172 y -> name = x -> get_base_name();
173 y -> num_books = x -> num_of_docs();
178 catch (mmdbException &,e)
186 void DtMmdbBookCaseFreeInfo(DtMmdbBookCaseInfo* x)