OpenIndiana and Solaris port
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / oliasdb / c_api_dlp.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_dlp.cc /main/4 1996/06/11 17:27:07 cde-hal $
24
25 #include "oliasdb/c_api_common.h"
26
27 static dlp_smart_ptr*
28 getDlpUsingProid(DtMmdbInfoRequest* request)
29 {
30    mtry {
31       info_base* x = getBookCase(request -> bookcase_descriptor);
32       if ( x == 0 ) return 0;
33
34       oid_t * id = getPrimiaryOid(request);
35
36       if ( id ) {
37          return new dlp_smart_ptr(x, *id);
38       }
39
40       return 0;
41    }
42
43    mcatch (mmdbException &,e)
44    {
45      return 0;
46    } end_try;
47      return 0;
48 }
49
50 DtMmdbHandle*
51 DtMmdbDlpGetPrevSectionId(DtMmdbInfoRequest* request)
52 {
53    mtry {
54       dlp_smart_ptr* x = getDlpUsingProid(request);
55       if ( x == 0 ) return 0;
56       DtMmdbHandle *z = 0;
57
58       if ( x -> prev_node_oid() == ground )
59         z = DtMmdbGroundId;
60       else
61         z = newDtMmdbHandle(x -> prev_node_oid());
62
63       delete x;
64       return z;
65    }
66
67    mcatch (mmdbException &,e)
68    {
69      return 0;
70    } end_try;
71      return 0;
72 }
73
74 DtMmdbHandle*
75 DtMmdbDlpGetNextSectionId(DtMmdbInfoRequest* request)
76 {
77    mtry {
78       dlp_smart_ptr* x = getDlpUsingProid(request);
79       if ( x == 0 ) return 0;
80
81       DtMmdbHandle *z = 0;
82
83       if ( x -> next_node_oid() == ground)
84         z = DtMmdbGroundId;
85       else
86         z = newDtMmdbHandle(x -> next_node_oid());
87
88       delete x;
89       return z;
90    }
91
92    mcatch (mmdbException &,e)
93    {
94      return 0;
95    } end_try;
96      return 0;
97 }
98