Initial import of the CDE 2.1.30 sources from the Open Group.
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / UAS / Test / uasdrv.C
1 // $XConsortium: uasdrv.cc /main/4 1996/06/11 16:45:11 cde-hal $
2 # include <stream.h>
3 # include <stdio.h>
4
5
6 # include "Exceptions.hh"
7 # include "UAS.hh"
8
9 #if 0
10 void
11 printTitles (UAS_Pointer<UAS_Common> doc, int level) {
12     int i;
13     for (i = 0; i < level; i ++)
14         fprintf (stderr, "    ");
15     fprintf (stderr, "%s\n", (char *) doc->title ());
16     UAS_Pointer<UAS_Common> curDoc;
17     if (doc->type() == UAS_BOOK) {
18         curDoc = doc->next();
19         while (curDoc != 0) {
20             fprintf (stderr, "********** %s \n", (char *) curDoc->title ());
21             curDoc = curDoc->next();
22         }
23     } else {
24         UAS_List<UAS_Common> theList = doc->children ();
25         for (i = 0; i < theList.length(); i ++)
26             printTitles (theList[i], level + 1);
27     }
28 }
29
30 #endif
31
32 void
33 printLocs (UAS_Pointer<UAS_Common> doc, int level) {
34     for (int i = 0; i < level; i ++)
35         cerr << "    ";
36     UAS_String theLoc = doc->locator();
37     if (level >= 2) {
38         char buf[1024];
39         UAS_String loc = doc->id();
40         (void) sprintf (buf, "mmdb:LOCATOR=%s", (char *) loc);
41         UAS_Pointer<UAS_Common> theDoc = UAS_Common::create(buf);
42         cerr << (char *) theLoc << ", " << (char *) theDoc->title() << endl;
43     } else {
44         cerr << (char *) theLoc << endl;
45     }
46     UAS_List<UAS_Common> kids = doc->children();
47     for (i = 0; i < kids.length(); i ++) {
48         printLocs (kids[i], level + 1);
49     }
50 }
51
52 int main (int, char *[]) {
53     INIT_EXCEPTIONS();
54     UAS_Common::initialize ();
55     UAS_List<UAS_String> locList = UAS_Common::rootLocators ();
56     for (int i = 0; i < locList.length(); i ++) {
57         UAS_String &cur = locList[i];
58         UAS_Pointer<UAS_Common> curDoc = UAS_Common::create(cur);
59         UAS_Pointer<UAS_Collection> curCol = (UAS_Collection *)
60             ((UAS_Common *) curDoc);
61         printLocs (curCol->root(), 0);
62         curDoc = curCol->root();
63         curCol = 0;
64         UAS_Common::destroy (curDoc);
65     }
66     UAS_Common::finalize ();
67     return 0;
68 }