OpenIndiana and Solaris port
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / oliasdb / c_api_locator.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 // $XConsortium: c_api_locator.cc /main/3 1996/06/11 17:27:38 cde-hal $
24
25 #include "oliasdb/c_api_common.h"
26
27 static locator_smart_ptr*
28 getLocatorUsingLocAndProid(DtMmdbInfoRequest* request, Boolean checkLocOnly = false)
29 {
30    mtry {
31       info_base* x = getBookCase(request -> bookcase_descriptor);
32       if ( x == 0 ) return 0;
33
34       const char* str = getLocator(request);
35
36       if ( str ) {
37          return new locator_smart_ptr(x, str);
38       } else
39          return 0;
40
41 /*
42       if ( checkLocOnly == true ) return 0;
43
44       oid_t * id = getPrimiaryOid(request);
45
46       if ( id == 0 ) return 0;
47
48       return new locator_smart_ptr(x, *id);
49 */
50    }
51
52    mcatch (mmdbException &,e)
53    {
54      return 0;
55    } end_try;
56      return 0;
57 }
58
59 const char*
60 DtMmdbLocatorGetSectionLoc(DtMmdbInfoRequest* request)
61 {
62    mtry {
63       locator_smart_ptr* x = getLocatorUsingLocAndProid(request, false);
64
65       if ( x == 0 ) return 0;
66       const char* y = x -> inside_node_locator_str();
67       delete x;
68       return y;
69    }
70
71    mcatch (mmdbException &,e)
72    {
73      return 0;
74    } end_try;
75      return 0;
76 }
77
78 DtMmdbHandle*
79 DtMmdbLocatorGetSectionObjectId(DtMmdbInfoRequest* request)
80 {
81    mtry {
82       locator_smart_ptr* x = getLocatorUsingLocAndProid(request, true);
83       if ( x == 0 ) return 0;
84       DtMmdbHandle *z = newDtMmdbHandle(x -> node_id());
85       delete x;
86       return z;
87    }
88
89    mcatch (mmdbException &,e)
90    {
91      return 0;
92    } end_try;
93      return 0;
94 }
95