OpenIndiana and Solaris port
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / oliasdb / c_api_section_test.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_section_test.C /main/5 1996/08/21 15:53:20 drk $ */
24
25 #include "oliasdb/DtMmdb.h"
26 #include <stdio.h>
27
28 extern "C"
29 void showSection(DtMmdbInfoRequest* req)
30 {
31     const char* str = 0;
32     int size = 0;
33     DtMmdbHandle* id = 0;
34
35    if ( req == 0 ) return ;
36
37     str = DtMmdbSectionGetLongTitle(req, 0);
38     if (str) {
39     fprintf(stderr, "        SectionInfo: LongTitle=%s\n", str);
40     }
41
42     str = DtMmdbSectionGetShortTitle(req, 0);
43     if (str) {
44     fprintf(stderr, "        SectionInfo: ShortTitle=%s\n", str);
45     }
46
47     str = DtMmdbSectionGetData(req, 0);
48     if (str) {
49     fprintf(stderr, "        SectionInfo: data=%s\n", str);
50     }
51
52     size = DtMmdbSectionGetDataSize(req);
53     fprintf(stderr, "        SectionInfo: dataSize=%d\n", size);
54
55
56     str = DtMmdbSectionGetTocLoc(req);
57     if (str) {
58     fprintf(stderr, "        SectionInfo: TocLoc=%s\n", str);
59     }
60
61     id = DtMmdbSectionGetBookId(req);
62     if (id) {
63     fprintf(stderr, "        SectionInfo: BookId=%s\n", DtMmdbHandleToString(id));
64     }
65     DtMmdbFreeHandle(id);
66
67     id = DtMmdbSectionGetStyleSheetId(req);
68     if (id) {
69     fprintf(stderr, "        SectionInfo: StyleSheetId=%s\n", DtMmdbHandleToString(id));
70     }
71     DtMmdbFreeHandle(id);
72 }
73
74 extern "C"
75 int test2(int argc, char** argv)
76 {
77    int j = 0;
78    int i = -1;
79    DtMmdbInfoRequest* req = 0;
80
81    switch ( argc ) {
82      case 5:
83       {
84        i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
85        j = DtMmdbGetBookCaseByLoc(i, argv[4]);
86
87        req = newDtMmdbInfoRequestWithLoc(j, argv[4]);
88        showSection(req);
89
90        DtMmdbFreeInfoRequest(req);
91        DtMmdbCloseInfoLib(i);
92
93        break;
94       }
95      default:
96        fprintf(stderr, "invalid arguments\n");
97    }
98
99    fprintf(stderr, "infolib desc=%d\n", i);
100    return 0;
101 }
102
103 extern "C"
104 int test3(int argc, char** argv)
105 {
106    int j = 0;
107    int i = -1;
108    DtMmdbInfoRequest* req = 0;
109
110    switch ( argc ) {
111      case 5:
112       {
113        i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
114        j = DtMmdbGetBookCaseByName(i, argv[3]);
115
116        req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
117        showSection(req);
118
119        DtMmdbFreeInfoRequest(req);
120        DtMmdbCloseInfoLib(i);
121
122        break;
123       }
124       default:
125        fprintf(stderr, "invalid arguments\n");
126    }
127
128    fprintf(stderr, "infolib desc=%d\n", i);
129    return 0;
130 }