OpenIndiana and Solaris port
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / oliasdb / c_api_graphic_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_graphic_test.C /main/5 1996/08/21 15:53:03 drk $ */
24
25
26 #include "oliasdb/DtMmdb.h"
27 #include <stdio.h>
28
29 extern "C"
30 void showGraphic(DtMmdbInfoRequest* req)
31 {
32    const char* str;
33    unsigned int l;
34    unsigned int i;
35    DtMmdbGraphicInfo* info ;
36
37    if ( req == 0 ) return ;
38
39    str = DtMmdbGraphicGetData( req, &l);
40    if ( str ) {
41       fprintf(stderr, "  GraphicInfo: data=");
42       for (i=0; i<l; i++ )
43         fprintf(stderr, "%c", str[i]);
44       fprintf(stderr, "\n");
45    }
46
47    info = DtMmdbGraphicGetInfo(req);
48    if ( info ) {
49      fprintf(stderr, "  GraphicInfo: type=%d\n", info -> type);
50      fprintf(stderr, "  GraphicInfo: width=%d\n", info -> width);
51      fprintf(stderr, "  GraphicInfo: height=%d\n", info -> height);
52      fprintf(stderr, "  GraphicInfo: llx=%d\n", info -> llx);
53      fprintf(stderr, "  GraphicInfo: lly=%d\n", info -> lly);
54      fprintf(stderr, "  GraphicInfo: urx=%d\n", info -> urx);
55      fprintf(stderr, "  GraphicInfo: ury=%d\n", info -> ury);
56      DtMmdbFreeGraphicInfo(info);
57    }
58
59 /*
60    str =  DtMmdbGraphicGetLoc(req);
61      fprintf(stderr, "  GraphicInfo: graphic's locator=%s\n", str);
62 */
63
64 }
65
66 extern "C"
67 int test_graphic1(int argc, char** argv)
68 {
69    int j = 0;
70    int i = 0;
71    DtMmdbInfoRequest* req;
72
73    switch ( argc ) {
74      case 5:
75       {
76        i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
77        j = DtMmdbGetBookCaseByName(i, argv[3]);
78
79        req = newDtMmdbInfoRequestWithLoc(j, argv[4]);
80        showGraphic(req);
81
82        DtMmdbFreeInfoRequest(req);
83        DtMmdbCloseInfoLib(i);
84
85        break;
86       }
87       default:
88        fprintf(stderr, "invalid arguments\n");
89    }
90
91    fprintf(stderr, "infolib desc=%d\n", i);
92    return 0;
93 }
94
95
96 extern "C"
97 int test_graphic2(int argc, char** argv)
98 {
99    int j = 0;
100    int i = 0;
101    DtMmdbInfoRequest* req;
102
103    switch ( argc ) {
104      case 5:
105       {
106        i = DtMmdbOpenInfoLib(argv[2], argv[3], DtMmdbFalse);
107        j = DtMmdbGetBookCaseByName(i, argv[3]);
108
109        req = newDtMmdbInfoRequestWithPrimaryOid(j, argv[4]);
110        showGraphic(req);
111
112        DtMmdbFreeInfoRequest(req);
113        DtMmdbCloseInfoLib(i);
114
115        break;
116       }
117       default:
118        fprintf(stderr, "invalid arguments\n");
119    }
120
121    fprintf(stderr, "infolib desc=%d\n", i);
122    return 0;
123 }