1 #include "cpluscommon.h"
6 #include <Gtk_LdapItem.h>
7 #include <Gtk_LdapServer.h>
9 int main(int argc, char **argv) {
11 Gtk_LdapItem *treeresult;
12 Gtk_Tree *tree, *subtree;
13 Gtk_Tree *machine, *machinetree;
14 Gtk_LdapServer *treeitem;
15 Gtk_Viewport *viewport;
16 char *host = NULL, *prt = NULL;
23 hosts = new G_List<char>();
24 while ((c = getopt(argc, argv, "s:p:h")) != -1) {
28 hosts = hosts->append(strdup(optarg));
31 port = atoi(optarg); break;
34 fprintf(stderr, "Usage: %s ([-s server[:port]])*\n", argv[0]);
38 debug("%i hosts\n", hosts->length());
39 for (int f=0; f<hosts->length(); f++) {
40 debug("%s\n", hosts->nth_data(f));
42 if (hosts->length() == 0) {
44 printf("Supply me with a host please (hint: use -s\n");
47 ldap_get_option(NULL, LDAP_OPT_HOST_NAME, host);
48 hosts = hosts->append(host);
49 #endif /* LDAP_GET_OPT */
51 if (port == 0) port = LDAP_PORT;
53 Gtk_Main m(&argc, &argv);
55 window = new My_Window(GTK_WINDOW_TOPLEVEL);
57 // viewport = new Gtk_Viewport();
59 tree = new Gtk_Tree();
60 for (int f=0; f<hosts->length(); f++) {
61 host = strtok(hosts->nth_data(f), ":");
62 prt = strtok(NULL, "\0");
63 if (prt != NULL) port = atoi(prt);
64 else port = LDAP_PORT;
65 treeitem = new Gtk_LdapServer(window, host, port);
66 subtree = treeitem->getSubtree();
67 tree->append(*treeitem);
68 treeitem->set_subtree(*subtree);
71 window->viewport->add(tree);
75 // window->scroller->add(viewport);
76 window->viewport->show();
77 window->scroller->show();
79 window->set_title("gtk-tool");
81 window->set_usize(600, 500);