dtinfo subtree dtinfo
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / UAS / Test / uasdrv.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: uasdrv.cc /main/4 1996/06/11 16:45:11 cde-hal $
24 # include <sstream>
25 using namespace std;
26 # include <stdio.h>
27
28
29 # include "Exceptions.hh"
30 # include "UAS.hh"
31
32 #if 0
33 void
34 printTitles (UAS_Pointer<UAS_Common> doc, int level) {
35     int i;
36     for (i = 0; i < level; i ++)
37         fprintf (stderr, "    ");
38     fprintf (stderr, "%s\n", (char *) doc->title ());
39     UAS_Pointer<UAS_Common> curDoc;
40     if (doc->type() == UAS_BOOK) {
41         curDoc = doc->next();
42         while (curDoc != 0) {
43             fprintf (stderr, "********** %s \n", (char *) curDoc->title ());
44             curDoc = curDoc->next();
45         }
46     } else {
47         UAS_List<UAS_Common> theList = doc->children ();
48         for (i = 0; i < theList.length(); i ++)
49             printTitles (theList[i], level + 1);
50     }
51 }
52
53 #endif
54
55 void
56 printLocs (UAS_Pointer<UAS_Common> doc, int level) {
57     for (int i = 0; i < level; i ++)
58         cerr << "    ";
59     UAS_String theLoc = doc->locator();
60     if (level >= 2) {
61         char buf[1024];
62         UAS_String loc = doc->id();
63         (void) sprintf (buf, "mmdb:LOCATOR=%s", (char *) loc);
64         UAS_Pointer<UAS_Common> theDoc = UAS_Common::create(buf);
65         cerr << (char *) theLoc << ", " << (char *) theDoc->title() << endl;
66     } else {
67         cerr << (char *) theLoc << endl;
68     }
69     UAS_List<UAS_Common> kids = doc->children();
70     for (i = 0; i < kids.length(); i ++) {
71         printLocs (kids[i], level + 1);
72     }
73 }
74
75 int main (int, char *[]) {
76     INIT_EXCEPTIONS();
77     UAS_Common::initialize ();
78     UAS_List<UAS_String> locList = UAS_Common::rootLocators ();
79     for (int i = 0; i < locList.length(); i ++) {
80         UAS_String &cur = locList[i];
81         UAS_Pointer<UAS_Common> curDoc = UAS_Common::create(cur);
82         UAS_Pointer<UAS_Collection> curCol = (UAS_Collection *)
83             ((UAS_Common *) curDoc);
84         printLocs (curCol->root(), 0);
85         curDoc = curCol->root();
86         curCol = 0;
87         UAS_Common::destroy (curDoc);
88     }
89     UAS_Common::finalize ();
90     return 0;
91 }