Spelling fixes
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / oliasdb / c_api_infolib_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 libraries 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_infolib_test.C /main/5 1996/08/21 15:53:07 drk $ */
24
25 #include "oliasdb/DtMmdb.h"
26 #include <stdio.h>
27
28
29 extern "C" void showBookCaseInfo(int i);
30
31 extern "C"
32 int showInfoLibInfo(int i)
33 {
34    int n = 0;
35    DtMmdbInfoLibInfo* info = DtMmdbInfoLibGetInfo(i);
36    if ( info ) {
37       if ( info -> path )
38         fprintf(stderr, "infolibInfo: path= %s\n", info -> path);
39       if ( info -> name )
40         fprintf(stderr, "infolibInfo: name= %s\n", info -> name);
41       fprintf(stderr, "infolibInfo: num_bookcases= %d\n", info -> num_bookcases);
42
43       n = info -> num_bookcases;
44
45       DtMmdbInfoLibFreeInfo(info);
46    } else
47       fprintf(stderr, "no infolibInfo\n");
48
49    return n;
50 }
51
52 extern "C"
53 int test0(int argc, char** argv)
54 {
55    int j = 0;
56    int n = 0;
57    int i = -1;
58    switch ( argc ) {
59      case 4:
60        i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
61        n = showInfoLibInfo(i);
62        for ( j=0; j<n; j++ )
63           showBookCaseInfo(DtMmdbGetBookCaseByIndex(i, j));
64        break;
65      case 3:
66        i = DtMmdbOpenInfoLib(argv[2], 0, DtMmdbFalse);
67        showInfoLibInfo(i);
68        n = showInfoLibInfo(i);
69        for ( j=0; j<n; j++ )
70           showBookCaseInfo(DtMmdbGetBookCaseByIndex(i, j));
71        break;
72      default:
73        fprintf(stderr, "bad argument list\n");
74    }
75
76    fprintf(stderr, "infolib desc=%d\n", i);
77    return 0;
78 }
79
80 extern "C"
81 int test1(int argc, char** argv)
82 {
83    int j = 0;
84    int n = 0;
85    int i = -1;
86    switch ( argc ) {
87      case 5:
88        i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
89        n = showInfoLibInfo(i);
90        for ( j=0; j<n; j++ )
91           showBookCaseInfo(DtMmdbGetBookCaseByLoc(i, argv[4]));
92        break;
93      default:
94        fprintf(stderr, "bad argument list\n");
95    }
96
97    fprintf(stderr, "infolib desc=%d\n", i);
98    return 0;
99 }
100