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