Merge branch 'master' of ctdb into 'master' of samba
[samba.git] / examples / libsmbclient / tree.c
index da60236e601e7a932126fe0c144351679627fa24..6e34cd05627c4d47ee05b654e0329baeadf6ba4e 100644 (file)
@@ -8,7 +8,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 /* example-gtk+ application, ripped off from the gtk+ tree.c sample */
 
 #include <stdio.h>
 #include <errno.h>
+#include <string.h>
+#include <stdlib.h>
 #include <gtk/gtk.h>
 #include "libsmbclient.h"
 
@@ -51,7 +52,8 @@ void error_message(gchar *message) {
   /* Ensure that the dialog box is destroyed when the user clicks ok. */
      
   gtk_signal_connect_object (GTK_OBJECT (okay_button), "clicked",
-                            GTK_SIGNAL_FUNC (gtk_widget_destroy), dialog);
+                            GTK_SIGNAL_FUNC (gtk_widget_destroy), 
+                            GTK_OBJECT(dialog));
   gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area),
                     okay_button);
 
@@ -293,7 +295,7 @@ static void cb_select_child (GtkWidget *root_tree, GtkWidget *child,
 
       gtk_clist_append(GTK_CLIST(clist), rowdata);
 
-      (char *)dirp += dirlen;
+      dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
       err -= dirlen;
 
     }
@@ -428,7 +430,7 @@ static void cb_itemsignal( GtkWidget *item,
 
        }
 
-       (char *)dirp += dirlen;
+        dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
        err -= dirlen;
 
       }
@@ -563,7 +565,7 @@ static void cb_wholenet(GtkWidget *item, gchar *signame)
        gtk_signal_connect(GTK_OBJECT(subtree), "unselect_child",
                           GTK_SIGNAL_FUNC(cb_unselect_child), real_tree);
 
-       (char *)dirp += dirlen;
+        dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
        err -= dirlen;
 
       }
@@ -705,9 +707,9 @@ int main( int   argc,
 
   /* Now, build the top level display ... */
 
-  if ((dh = smbc_opendir("smb:///")) < 0) {
+  if ((dh = smbc_opendir("smb://")) < 0) {
 
-    fprintf(stderr, "Could not list default workgroup: smb:///: %s\n",
+    fprintf(stderr, "Could not list workgroups: smb://: %s\n",
            strerror(errno));
 
     exit(1);
@@ -744,8 +746,6 @@ int main( int   argc,
 
   /* Now, get the items in smb:/// and add them to the tree */
 
-  dirp = (struct smbc_dirent *)dirbuf;
-
   while ((err = smbc_getdents(dh, (struct smbc_dirent *)dirbuf, 
                              sizeof(dirbuf))) != 0) {
 
@@ -758,6 +758,8 @@ int main( int   argc,
 
     }
 
+    dirp = (struct smbc_dirent *)dirbuf;
+
     fprintf(stdout, "Dir len: %u\n", err);
 
     while (err > 0) { /* Extract each entry and make a sub-tree */
@@ -796,7 +798,7 @@ int main( int   argc,
       gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child",
                          GTK_SIGNAL_FUNC(cb_unselect_child), tree);
 
-      (char *)dirp += dirlen;
+      dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
       err -= dirlen;
 
     }