examples: Make libsmbclient samples look a *bit* less ugly
authorVolker Lendecke <vl@samba.org>
Wed, 17 Aug 2022 08:51:06 +0000 (10:51 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 26 Aug 2022 18:54:37 +0000 (18:54 +0000)
Remove trailing whitespace, indent to tabs. Yes, this introduces long
lines, but makes review with "git show -w" trivial.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
19 files changed:
examples/libsmbclient/get_auth_data_fn.h
examples/libsmbclient/testacl.c
examples/libsmbclient/testacl2.c
examples/libsmbclient/testacl3.c
examples/libsmbclient/testbrowse.c
examples/libsmbclient/testbrowse2.c
examples/libsmbclient/testchmod.c
examples/libsmbclient/testctx.c
examples/libsmbclient/testfstatvfs.c
examples/libsmbclient/testread.c
examples/libsmbclient/testsmbc.c
examples/libsmbclient/teststat.c
examples/libsmbclient/teststat2.c
examples/libsmbclient/teststat3.c
examples/libsmbclient/teststatvfs.c
examples/libsmbclient/testtruncate.c
examples/libsmbclient/testutime.c
examples/libsmbclient/testwrite.c
examples/libsmbclient/tree.c

index 5f2be72a633603766b897630cce4075ac0e563fb..9adb74511762552a31793f7e89d46e22100bde75 100644 (file)
@@ -10,83 +10,83 @@ get_auth_data_fn(const char * pServer,
                  char * pPassword,
                  int maxLenPassword)
 {
-    char            temp[128];
-    char            server[256] = { '\0' };
-    char            share[256] = { '\0' };
-    char            workgroup[256] = { '\0' };
-    char            username[256] = { '\0' };
-    char            password[256] = { '\0' };
-    char           *ret;
+       char            temp[128];
+       char            server[256] = { '\0' };
+       char            share[256] = { '\0' };
+       char            workgroup[256] = { '\0' };
+       char            username[256] = { '\0' };
+       char            password[256] = { '\0' };
+       char           *ret;
 
-    static int krb5_set = 1;
+       static int krb5_set = 1;
 
-    if (strcmp(server, pServer) == 0 &&
-        strcmp(share, pShare) == 0 &&
-        *workgroup != '\0' &&
-        *username != '\0')
-    {
-        strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1);
-        strncpy(pUsername, username, maxLenUsername - 1);
-        strncpy(pPassword, password, maxLenPassword - 1);
-        return;
-    }
+       if (strcmp(server, pServer) == 0 &&
+           strcmp(share, pShare) == 0 &&
+           *workgroup != '\0' &&
+           *username != '\0')
+       {
+               strncpy(pWorkgroup, workgroup, maxLenWorkgroup - 1);
+               strncpy(pUsername, username, maxLenUsername - 1);
+               strncpy(pPassword, password, maxLenPassword - 1);
+               return;
+       }
 
-    if (krb5_set && getenv("KRB5CCNAME")) {
-      krb5_set = 0;
-      return;
-    }
+       if (krb5_set && getenv("KRB5CCNAME")) {
+               krb5_set = 0;
+               return;
+       }
 
-    fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
-    ret = fgets(temp, sizeof(temp), stdin);
-    if (ret == NULL) {
-           return;
-    }
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
-    }
-    
-    fprintf(stdout, "Username: [%s] ", pUsername);
-    ret = fgets(temp, sizeof(temp), stdin);
-    if (ret == NULL) {
-           return;
-    }
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pUsername, temp, maxLenUsername - 1);
-    }
-    
-    fprintf(stdout, "Password: ");
-    ret = fgets(temp, sizeof(temp), stdin);
-    if (ret == NULL) {
-           return;
-    }
-    
-    if (temp[strlen(temp) - 1] == '\n') /* A new line? */
-    {
-        temp[strlen(temp) - 1] = '\0';
-    }
-    
-    if (temp[0] != '\0')
-    {
-        strncpy(pPassword, temp, maxLenPassword - 1);
-    }
+       fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
+       ret = fgets(temp, sizeof(temp), stdin);
+       if (ret == NULL) {
+               return;
+       }
 
-    strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1);
-    strncpy(username, pUsername, sizeof(username) - 1);
-    strncpy(password, pPassword, sizeof(password) - 1);
+       if (temp[strlen(temp) - 1] == '\n') /* A new line? */
+       {
+               temp[strlen(temp) - 1] = '\0';
+       }
 
-    krb5_set = 1;
+       if (temp[0] != '\0')
+       {
+               strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
+       }
+
+       fprintf(stdout, "Username: [%s] ", pUsername);
+       ret = fgets(temp, sizeof(temp), stdin);
+       if (ret == NULL) {
+               return;
+       }
+
+       if (temp[strlen(temp) - 1] == '\n') /* A new line? */
+       {
+               temp[strlen(temp) - 1] = '\0';
+       }
+
+       if (temp[0] != '\0')
+       {
+               strncpy(pUsername, temp, maxLenUsername - 1);
+       }
+
+       fprintf(stdout, "Password: ");
+       ret = fgets(temp, sizeof(temp), stdin);
+       if (ret == NULL) {
+               return;
+       }
+
+       if (temp[strlen(temp) - 1] == '\n') /* A new line? */
+       {
+               temp[strlen(temp) - 1] = '\0';
+       }
+
+       if (temp[0] != '\0')
+       {
+               strncpy(pPassword, temp, maxLenPassword - 1);
+       }
+
+       strncpy(workgroup, pWorkgroup, sizeof(workgroup) - 1);
+       strncpy(username, pUsername, sizeof(username) - 1);
+       strncpy(password, pPassword, sizeof(password) - 1);
+
+       krb5_set = 1;
 }
index 0f6e0acb0c31120fd761abed1610ca95b6d94059..e0e4eeb24d0676b4969556c06d8df77366f675dd 100644 (file)
@@ -36,105 +36,105 @@ int main(int argc, const char *argv[])
        poptContext pc;
        struct stat st;
        struct poptOption long_options[] =
-       {
-               POPT_AUTOHELP
-               {
-                       .longName   = "numeric",
-                       .shortName  = 'n',
-                       .argInfo    = POPT_ARG_NONE,
-                       .arg        = &numeric,
-                       .val        = 1,
-                       .descrip    = "Don't resolve sids or masks to names"
-               },
-               {
-                       .longName   = "debug",
-                       .shortName  = 'd',
-                       .argInfo    = POPT_ARG_INT,
-                       .arg        = &debug,
-                       .val        = 0,
-                       .descrip    = "Set debug level (0-100)"
-               },
-               {
-                       .longName   = "full_time_names",
-                       .shortName  = 'f',
-                       .argInfo    = POPT_ARG_NONE,
-                       .arg        = &full_time_names,
-                       .val        = 1,
-                       .descrip    = "Use new style xattr names, which include CREATE_TIME"
-               },
-               {
-                       .longName   = "delete",
-                       .shortName  = 'D',
-                       .argInfo    = POPT_ARG_STRING,
-                       .arg        = NULL,
-                       .val        = 'D',
-                       .descrip    = "Delete an acl",
-                       .argDescrip = "ACL"
-               },
-               {
-                       .longName   = "modify",
-                       .shortName  = 'M',
-                       .argInfo    = POPT_ARG_STRING,
-                       .arg        = NULL,
-                       .val        = 'M',
-                       .descrip    = "Modify an acl",
-                       .argDescrip = "ACL"
-               },
-               {
-                       .longName   = "add",
-                       .shortName  = 'a',
-                       .argInfo    = POPT_ARG_STRING,
-                       .arg        = NULL,
-                       .val        = 'a',
-                       .descrip    = "Add an acl",
-                       .argDescrip = "ACL"
-               },
-               {
-                       .longName   = "set",
-                       .shortName  = 'S',
-                       .argInfo    = POPT_ARG_STRING,
-                       .arg        = NULL,
-                       .val        = 'S',
-                       .descrip    = "Set acls",
-                       .argDescrip = "ACLS"
-               },
-               {
-                       .longName   = "chown",
-                       .shortName  = 'C',
-                       .argInfo    = POPT_ARG_STRING,
-                       .arg        = NULL,
-                       .val        = 'C',
-                       .descrip    = "Change ownership of a file",
-                       .argDescrip = "USERNAME"
-               },
-               {
-                       .longName   = "chgrp",
-                       .shortName  = 'G',
-                       .argInfo    = POPT_ARG_STRING,
-                       .arg        = NULL,
-                       .val        = 'G',
-                       .descrip    = "Change group ownership of a file",
-                       .argDescrip = "GROUPNAME"
-               },
-               {
-                       .longName   = "get",
-                       .shortName  = 'g',
-                       .argInfo    = POPT_ARG_STRING,
-                       .arg        = NULL,
-                       .val        = 'g',
-                       .descrip    = "Get a specific acl attribute",
-                       .argDescrip = "ACL"
-               },
                {
-                       .longName   = "stat_and_retry",
-                       .shortName  = 'R',
-                       .argInfo    = POPT_ARG_NONE,
-                       .arg        = &stat_and_retry,
-                       .val        = 1,
-                       .descrip    = "After 'get' do 'stat' and another 'get'"
-               },
-               POPT_TABLEEND
-       };
+                       POPT_AUTOHELP
+                       {
+                               .longName   = "numeric",
+                               .shortName  = 'n',
+                               .argInfo    = POPT_ARG_NONE,
+                               .arg        = &numeric,
+                               .val        = 1,
+                               .descrip    = "Don't resolve sids or masks to names"
+                       },
+                       {
+                               .longName   = "debug",
+                               .shortName  = 'd',
+                               .argInfo    = POPT_ARG_INT,
+                               .arg        = &debug,
+                               .val        = 0,
+                               .descrip    = "Set debug level (0-100)"
+                       },
+                       {
+                               .longName   = "full_time_names",
+                               .shortName  = 'f',
+                               .argInfo    = POPT_ARG_NONE,
+                               .arg        = &full_time_names,
+                               .val        = 1,
+                               .descrip    = "Use new style xattr names, which include CREATE_TIME"
+                       },
+                       {
+                               .longName   = "delete",
+                               .shortName  = 'D',
+                               .argInfo    = POPT_ARG_STRING,
+                               .arg        = NULL,
+                               .val        = 'D',
+                               .descrip    = "Delete an acl",
+                               .argDescrip = "ACL"
+                       },
+                       {
+                               .longName   = "modify",
+                               .shortName  = 'M',
+                               .argInfo    = POPT_ARG_STRING,
+                               .arg        = NULL,
+                               .val        = 'M',
+                               .descrip    = "Modify an acl",
+                               .argDescrip = "ACL"
+                       },
+                       {
+                               .longName   = "add",
+                               .shortName  = 'a',
+                               .argInfo    = POPT_ARG_STRING,
+                               .arg        = NULL,
+                               .val        = 'a',
+                               .descrip    = "Add an acl",
+                               .argDescrip = "ACL"
+                       },
+                       {
+                               .longName   = "set",
+                               .shortName  = 'S',
+                               .argInfo    = POPT_ARG_STRING,
+                               .arg        = NULL,
+                               .val        = 'S',
+                               .descrip    = "Set acls",
+                               .argDescrip = "ACLS"
+                       },
+                       {
+                               .longName   = "chown",
+                               .shortName  = 'C',
+                               .argInfo    = POPT_ARG_STRING,
+                               .arg        = NULL,
+                               .val        = 'C',
+                               .descrip    = "Change ownership of a file",
+                               .argDescrip = "USERNAME"
+                       },
+                       {
+                               .longName   = "chgrp",
+                               .shortName  = 'G',
+                               .argInfo    = POPT_ARG_STRING,
+                               .arg        = NULL,
+                               .val        = 'G',
+                               .descrip    = "Change group ownership of a file",
+                               .argDescrip = "GROUPNAME"
+                       },
+                       {
+                               .longName   = "get",
+                               .shortName  = 'g',
+                               .argInfo    = POPT_ARG_STRING,
+                               .arg        = NULL,
+                               .val        = 'g',
+                               .descrip    = "Get a specific acl attribute",
+                               .argDescrip = "ACL"
+                       },
+                       {
+                               .longName   = "stat_and_retry",
+                               .shortName  = 'R',
+                               .argInfo    = POPT_ARG_NONE,
+                               .arg        = &stat_and_retry,
+                               .val        = 1,
+                               .descrip    = "After 'get' do 'stat' and another 'get'"
+                       },
+                       POPT_TABLEEND
+               };
 
        setbuf(stdout, NULL);
 
@@ -210,7 +210,7 @@ int main(int argc, const char *argv[])
                if (ret < 0)
                {
                        printf("Could not get attribute list for [%s] %d: %s\n",
-                                       path, errno, strerror(errno));
+                              path, errno, strerror(errno));
                        return 1;
                }
 
@@ -247,7 +247,7 @@ int main(int argc, const char *argv[])
                        if (ret < 0)
                        {
                                printf("Could not get attributes for [%s] %d: %s\n",
-                                               path, errno, strerror(errno));
+                                      path, errno, strerror(errno));
                                return 1;
                        }
 
@@ -278,16 +278,16 @@ int main(int argc, const char *argv[])
 
        case SMB_ACL_CHOWN:
                snprintf(value, sizeof(value),
-                               "system.nt_sec_desc.owner%s:%s",
-                               numeric ? "" : "+", the_acl);
+                        "system.nt_sec_desc.owner%s:%s",
+                        numeric ? "" : "+", the_acl);
                the_acl = value;
                debugstr = "chown owner";
                goto do_set;
 
        case SMB_ACL_CHGRP:
                snprintf(value, sizeof(value),
-                               "system.nt_sec_desc.group%s:%s",
-                               numeric ? "" : "+", the_acl);
+                        "system.nt_sec_desc.group%s:%s",
+                        numeric ? "" : "+", the_acl);
                the_acl = value;
                debugstr = "change group";
                goto do_set;
@@ -296,7 +296,7 @@ int main(int argc, const char *argv[])
                flags = 0;
                debugstr = "set attributes";
 
-do_set:
+       do_set:
                if ((p = strchr(the_acl, ':')) == NULL)
                {
                        printf("Missing value.  ACL must be name:value pair\n");
@@ -309,7 +309,7 @@ do_set:
                if (ret < 0)
                {
                        printf("Could not %s for [%s] %d: %s\n",
-                                       debugstr, path, errno, strerror(errno));
+                              debugstr, path, errno, strerror(errno));
                        return 1;
                }
                break;
@@ -319,7 +319,7 @@ do_set:
                if (ret < 0)
                {
                        printf("Could not remove attribute %s for [%s] %d:%s\n",
-                                       the_acl, path, errno, strerror(errno));
+                              the_acl, path, errno, strerror(errno));
                        return 1;
                }
                break;
index a74a72d794c3fac235d567ac315457f32d158426..ee48b7b30594432b3858fa5b1b1916c9093fd2e4 100644 (file)
@@ -19,55 +19,55 @@ enum acl_mode
 
 int main(int argc, const char *argv[])
 {
-    int flags;
-    int debug = 0;
-    static char *the_acl = NULL;
-    int ret;
-    const char *debugstr;
-    char value[1024];
-    SMBCCTX *context;
+       int flags;
+       int debug = 0;
+       static char *the_acl = NULL;
+       int ret;
+       const char *debugstr;
+       char value[1024];
+       SMBCCTX *context;
 
-    if (smbc_init(get_auth_data_fn, debug) != 0)
-    {
-        printf("Could not initialize smbc_ library\n");
-        return 1;
-    }
+       if (smbc_init(get_auth_data_fn, debug) != 0)
+       {
+               printf("Could not initialize smbc_ library\n");
+               return 1;
+       }
 
-    context = smbc_set_context(NULL);
-    smbc_setOptionFullTimeNames(context, 1);
-    
-    the_acl = strdup("system.nt_sec_desc.*");
-    ret = smbc_getxattr(argv[1], the_acl, value, sizeof(value));
-    if (ret < 0)
-    {
-        printf("Could not get attributes for [%s] %d: %s\n",
-               argv[1], errno, strerror(errno));
-        return 1;
-    }
-    
-    printf("Attributes for [%s] are:\n%s\n", argv[1], value);
+       context = smbc_set_context(NULL);
+       smbc_setOptionFullTimeNames(context, 1);
 
-    flags = 0;
-    debugstr = "set attributes (1st time)";
-        
-    ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
-    if (ret < 0)
-    {
-        printf("Could not %s for [%s] %d: %s\n",
-               debugstr, argv[1], errno, strerror(errno));
-        return 1;
-    }
-    
-    flags = 0;
-    debugstr = "set attributes (2nd time)";
-        
-    ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
-    if (ret < 0)
-    {
-        printf("Could not %s for [%s] %d: %s\n",
-               debugstr, argv[1], errno, strerror(errno));
-        return 1;
-    }
-    
-    return 0;
+       the_acl = strdup("system.nt_sec_desc.*");
+       ret = smbc_getxattr(argv[1], the_acl, value, sizeof(value));
+       if (ret < 0)
+       {
+               printf("Could not get attributes for [%s] %d: %s\n",
+                      argv[1], errno, strerror(errno));
+               return 1;
+       }
+
+       printf("Attributes for [%s] are:\n%s\n", argv[1], value);
+
+       flags = 0;
+       debugstr = "set attributes (1st time)";
+
+       ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
+       if (ret < 0)
+       {
+               printf("Could not %s for [%s] %d: %s\n",
+                      debugstr, argv[1], errno, strerror(errno));
+               return 1;
+       }
+
+       flags = 0;
+       debugstr = "set attributes (2nd time)";
+
+       ret = smbc_setxattr(argv[1], the_acl, value, strlen(value), flags);
+       if (ret < 0)
+       {
+               printf("Could not %s for [%s] %d: %s\n",
+                      debugstr, argv[1], errno, strerror(errno));
+               return 1;
+       }
+
+       return 0;
 }
index 59d9994ef39f6158cea415292c3448e97995a489..e5ec2c88b95b6e5c22a98fc1468fdfd27aac0d2c 100644 (file)
@@ -1,59 +1,59 @@
 #include <sys/types.h>
-#include <stdio.h> 
+#include <stdio.h>
 #include <unistd.h>
-#include <string.h> 
-#include <time.h> 
+#include <string.h>
+#include <time.h>
 #include <errno.h>
-#include <libsmbclient.h> 
+#include <libsmbclient.h>
 #include "get_auth_data_fn.h"
 
 
-int main(int argc, char * argv[]) 
-{ 
-    int             ret;
-    int             debug = 0;
-    char            value[2048]; 
-    char            path[2048];
-    char *          the_acl;
-    char *          p;
-    SMBCCTX *       context;
-    
-    smbc_init(get_auth_data_fn, debug); 
-    
-    context = smbc_set_context(NULL);
-    smbc_setOptionFullTimeNames(context, 1);
-    
-    for (;;)
-    {
-        fprintf(stdout, "Path: ");
-        *path = '\0';
-        p = fgets(path, sizeof(path) - 1, stdin);
-       if (p == NULL) {
-               printf("Error reading from stdin\n");
-               return 1;
+int main(int argc, char * argv[])
+{
+       int             ret;
+       int             debug = 0;
+       char            value[2048];
+       char            path[2048];
+       char *          the_acl;
+       char *          p;
+       SMBCCTX *       context;
+
+       smbc_init(get_auth_data_fn, debug);
+
+       context = smbc_set_context(NULL);
+       smbc_setOptionFullTimeNames(context, 1);
+
+       for (;;)
+       {
+               fprintf(stdout, "Path: ");
+               *path = '\0';
+               p = fgets(path, sizeof(path) - 1, stdin);
+               if (p == NULL) {
+                       printf("Error reading from stdin\n");
+                       return 1;
+               }
+               if (strlen(path) == 0)
+               {
+                       return 0;
+               }
+
+               p = path + strlen(path) - 1;
+               if (*p == '\n')
+               {
+                       *p = '\0';
+               }
+
+               the_acl = strdup("system.nt_sec_desc.*+");
+               ret = smbc_getxattr(path, the_acl, value, sizeof(value));
+               if (ret < 0)
+               {
+                       printf("Could not get attributes for [%s] %d: %s\n",
+                              path, errno, strerror(errno));
+                       return 1;
+               }
+
+               printf("Attributes for [%s] are:\n%s\n", path, value);
        }
-        if (strlen(path) == 0)
-        {
-            return 0;
-        }
-
-        p = path + strlen(path) - 1;
-        if (*p == '\n')
-        {
-            *p = '\0';
-        }
-    
-        the_acl = strdup("system.nt_sec_desc.*+");
-        ret = smbc_getxattr(path, the_acl, value, sizeof(value));
-        if (ret < 0)
-        {
-            printf("Could not get attributes for [%s] %d: %s\n",
-                   path, errno, strerror(errno));
-            return 1;
-        }
-    
-        printf("Attributes for [%s] are:\n%s\n", path, value);
-    }
-
-    return 0; 
+
+       return 0;
 }
index 1609e2f4f9153e37996d0a0c8181c498b63fd389..2f2f54e61cdb385406ea3b6a5e222fdb1b14b7b8 100644 (file)
@@ -27,135 +27,135 @@ get_auth_data_with_context_fn(SMBCCTX * context,
 
 int main(int argc, const char *argv[])
 {
-    int                         debug = 0;
-    int                         debug_stderr = 0;
-    int                         no_auth = 0;
-    int                         context_auth = 0;
-    int                         scan = 0;
-    int                         iterations = -1;
-    int                         opt;
-    char *                      p;
-    char                        buf[1024];
-    poptContext                 pc;
-    SMBCCTX *                   context;
-    struct poptOption           long_options[] =
-        {
-            POPT_AUTOHELP
-            {
-                "debug", 'd', POPT_ARG_INT, &debug,
-                0, "Set debug level", "integer"
-            },
-            {
-                "stderr", 'e', POPT_ARG_NONE, &debug_stderr,
-                0, "Debug log to stderr instead of stdout", "integer"
-            },
-            {
-                "scan", 's', POPT_ARG_NONE, &scan,
-                0, "Scan for servers and shares", "integer"
-            },
-            {
-                "iterations", 'i', POPT_ARG_INT, &iterations,
-                0, "Iterations", "integer"
-            },
-            {
-                "noauth", 'A', POPT_ARG_NONE, &no_auth,
-                0, "Do not request authentication data", "integer"
-            },
-            {
-                "contextauth", 'C', POPT_ARG_NONE, &context_auth,
-                0, "Use new authentication function with context", "integer"
-            },
-            {0}
-        };
-    
-    setbuf(stdout, NULL);
-
-    pc = poptGetContext("opendir", argc, argv, long_options, 0);
-    
-    poptSetOtherOptionHelp(pc, "");
-    
-    while ((opt = poptGetNextOpt(pc)) != -1) {
-        printf("Got option %d = %c\n", opt, opt);
-        switch (opt) {
-        }
-    }
-
-    /* Allocate a new context */
-    context = smbc_new_context();
-    if (!context) {
-        printf("Could not allocate new smbc context\n");
-        return 1;
-    }
-        
-    /* If we're scanning, do no requests for authentication data */
-    if (scan) {
-        no_auth = 1;
-    }
-
-    /* Set mandatory options (is that a contradiction in terms?) */
-    smbc_setDebug(context, debug);
-    if (context_auth) {
-        smbc_setFunctionAuthDataWithContext(context,
-                                            get_auth_data_with_context_fn);
-        smbc_setOptionUserData(context, strdup("hello world"));
-    } else {
-        smbc_setFunctionAuthData(context, get_auth_data_fn);
-    }
-
-    smbc_setOptionUseKerberos(context, 1);
-    smbc_setOptionFallbackAfterKerberos(context, 1);
-
-    /* If we've been asked to log to stderr instead of stdout, ... */
-    if (debug_stderr) {
-        /* ... then set the option to do so */
-        smbc_setOptionDebugToStderr(context, 1);
-    }
-
-    /* Initialize the context using the previously specified options */
-    if (!smbc_init_context(context)) {
-        smbc_free_context(context, 0);
-        printf("Could not initialize smbc context\n");
-        return 1;
-    }
-
-    /* Tell the compatibility layer to use this context */
-    smbc_set_context(context);
-
-    if (scan)
-    {
-        for (; iterations != 0;) {
-            if (iterations > 0) {
-                iterations--;
-            }
-
-            snprintf(buf, sizeof(buf), "smb://");
-            browse(buf, scan, 0);
-        }
-    }
-    else
-    {
-        for (; iterations != 0;) {
-            if (iterations > 0) {
-                iterations--;
-            }
-
-            fputs("url: ", stdout);
-            p = fgets(buf, sizeof(buf), stdin);
-            if (! p)
-            {
-                break;
-            }
-
-            if ((p = strchr(buf, '\n')) != NULL)
-            {
-                *p = '\0';
-            }
-            
-            browse(buf, scan, 0);
-        }
-    }
-
-    exit(0);
+       int                         debug = 0;
+       int                         debug_stderr = 0;
+       int                         no_auth = 0;
+       int                         context_auth = 0;
+       int                         scan = 0;
+       int                         iterations = -1;
+       int                         opt;
+       char *                      p;
+       char                        buf[1024];
+       poptContext                 pc;
+       SMBCCTX *                   context;
+       struct poptOption           long_options[] =
+               {
+                       POPT_AUTOHELP
+                       {
+                               "debug", 'd', POPT_ARG_INT, &debug,
+                               0, "Set debug level", "integer"
+                       },
+                       {
+                               "stderr", 'e', POPT_ARG_NONE, &debug_stderr,
+                               0, "Debug log to stderr instead of stdout", "integer"
+                       },
+                       {
+                               "scan", 's', POPT_ARG_NONE, &scan,
+                               0, "Scan for servers and shares", "integer"
+                       },
+                       {
+                               "iterations", 'i', POPT_ARG_INT, &iterations,
+                               0, "Iterations", "integer"
+                       },
+                       {
+                               "noauth", 'A', POPT_ARG_NONE, &no_auth,
+                               0, "Do not request authentication data", "integer"
+                       },
+                       {
+                               "contextauth", 'C', POPT_ARG_NONE, &context_auth,
+                               0, "Use new authentication function with context", "integer"
+                       },
+                       {0}
+               };
+
+       setbuf(stdout, NULL);
+
+       pc = poptGetContext("opendir", argc, argv, long_options, 0);
+
+       poptSetOtherOptionHelp(pc, "");
+
+       while ((opt = poptGetNextOpt(pc)) != -1) {
+               printf("Got option %d = %c\n", opt, opt);
+               switch (opt) {
+               }
+       }
+
+       /* Allocate a new context */
+       context = smbc_new_context();
+       if (!context) {
+               printf("Could not allocate new smbc context\n");
+               return 1;
+       }
+
+       /* If we're scanning, do no requests for authentication data */
+       if (scan) {
+               no_auth = 1;
+       }
+
+       /* Set mandatory options (is that a contradiction in terms?) */
+       smbc_setDebug(context, debug);
+       if (context_auth) {
+               smbc_setFunctionAuthDataWithContext(context,
+                                                   get_auth_data_with_context_fn);
+               smbc_setOptionUserData(context, strdup("hello world"));
+       } else {
+               smbc_setFunctionAuthData(context, get_auth_data_fn);
+       }
+
+       smbc_setOptionUseKerberos(context, 1);
+       smbc_setOptionFallbackAfterKerberos(context, 1);
+
+       /* If we've been asked to log to stderr instead of stdout, ... */
+       if (debug_stderr) {
+               /* ... then set the option to do so */
+               smbc_setOptionDebugToStderr(context, 1);
+       }
+
+       /* Initialize the context using the previously specified options */
+       if (!smbc_init_context(context)) {
+               smbc_free_context(context, 0);
+               printf("Could not initialize smbc context\n");
+               return 1;
+       }
+
+       /* Tell the compatibility layer to use this context */
+       smbc_set_context(context);
+
+       if (scan)
+       {
+               for (; iterations != 0;) {
+                       if (iterations > 0) {
+                               iterations--;
+                       }
+
+                       snprintf(buf, sizeof(buf), "smb://");
+                       browse(buf, scan, 0);
+               }
+       }
+       else
+       {
+               for (; iterations != 0;) {
+                       if (iterations > 0) {
+                               iterations--;
+                       }
+
+                       fputs("url: ", stdout);
+                       p = fgets(buf, sizeof(buf), stdin);
+                       if (! p)
+                       {
+                               break;
+                       }
+
+                       if ((p = strchr(buf, '\n')) != NULL)
+                       {
+                               *p = '\0';
+                       }
+
+                       browse(buf, scan, 0);
+               }
+       }
+
+       exit(0);
 }
 
 static void
@@ -169,114 +169,113 @@ get_auth_data_with_context_fn(SMBCCTX * context,
                               char * pPassword,
                               int maxLenPassword)
 {
-    printf("Authenticating with context %p", context);
-    if (context != NULL) {
-        char *user_data = smbc_getOptionUserData(context);
-        printf(" with user data %s", user_data);
-    }
-    printf("\n");
-
-    get_auth_data_fn(pServer, pShare, pWorkgroup, maxLenWorkgroup,
-                     pUsername, maxLenUsername, pPassword, maxLenPassword);
+       printf("Authenticating with context %p", context);
+       if (context != NULL) {
+               char *user_data = smbc_getOptionUserData(context);
+               printf(" with user data %s", user_data);
+       }
+       printf("\n");
+
+       get_auth_data_fn(pServer, pShare, pWorkgroup, maxLenWorkgroup,
+                        pUsername, maxLenUsername, pPassword, maxLenPassword);
 }
 
 static void browse(char * path, int scan, int indent)
 {
-    char *                      p;
-    char                        buf[1024];
-    int                         dir;
-    struct stat                 st;
-    struct smbc_dirent *        dirent;
-
-    if (! scan)
-    {
-        printf("Opening (%s)...\n", path);
-    }
-        
-    if ((dir = smbc_opendir(path)) < 0)
-    {
-        printf("Could not open directory [%s] (%d:%s)\n",
-               path, errno, strerror(errno));
-        return;
-    }
-
-    while ((dirent = smbc_readdir(dir)) != NULL)
-    {
-        printf("%*.*s%-30s", indent, indent, "", dirent->name);
-
-        switch(dirent->smbc_type)
-        {
-        case SMBC_WORKGROUP:
-            printf("WORKGROUP");
-            break;
-            
-        case SMBC_SERVER:
-            printf("SERVER");
-            break;
-            
-        case SMBC_FILE_SHARE:
-            printf("FILE_SHARE");
-            break;
-            
-        case SMBC_PRINTER_SHARE:
-            printf("PRINTER_SHARE");
-            break;
-            
-        case SMBC_COMMS_SHARE:
-            printf("COMMS_SHARE");
-            break;
-            
-        case SMBC_IPC_SHARE:
-            printf("IPC_SHARE");
-            break;
-            
-        case SMBC_DIR:
-            printf("DIR");
-            break;
-            
-        case SMBC_FILE:
-            printf("FILE");
-
-            p = path + strlen(path);
-            strcat(p, "/");
-            strcat(p+1, dirent->name);
-            if (smbc_stat(path, &st) < 0)
-            {
-                printf(" unknown size (reason %d: %s)",
-                       errno, strerror(errno));
-            }
-            else
-            {
-                printf(" size %lu", (unsigned long) st.st_size);
-            }
-            *p = '\0';
-
-            break;
-            
-        case SMBC_LINK:
-            printf("LINK");
-            break;
-        }
-
-        printf("\n");
-
-        if (scan &&
-            (dirent->smbc_type == SMBC_WORKGROUP ||
-             dirent->smbc_type == SMBC_SERVER))
-        {
-            /*
-             * don't append server name to workgroup; what we want is:
-             *
-             *   smb://workgroup_name
-             * or
-             *   smb://server_name
-             *
-             */
-            snprintf(buf, sizeof(buf), "smb://%s", dirent->name);
-            browse(buf, scan, indent + 2);
-        }
-    }
-
-    smbc_closedir(dir);
+       char *                      p;
+       char                        buf[1024];
+       int                         dir;
+       struct stat                 st;
+       struct smbc_dirent *        dirent;
+
+       if (! scan)
+       {
+               printf("Opening (%s)...\n", path);
+       }
+
+       if ((dir = smbc_opendir(path)) < 0)
+       {
+               printf("Could not open directory [%s] (%d:%s)\n",
+                      path, errno, strerror(errno));
+               return;
+       }
+
+       while ((dirent = smbc_readdir(dir)) != NULL)
+       {
+               printf("%*.*s%-30s", indent, indent, "", dirent->name);
+
+               switch(dirent->smbc_type)
+               {
+               case SMBC_WORKGROUP:
+                       printf("WORKGROUP");
+                       break;
+
+               case SMBC_SERVER:
+                       printf("SERVER");
+                       break;
+
+               case SMBC_FILE_SHARE:
+                       printf("FILE_SHARE");
+                       break;
+
+               case SMBC_PRINTER_SHARE:
+                       printf("PRINTER_SHARE");
+                       break;
+
+               case SMBC_COMMS_SHARE:
+                       printf("COMMS_SHARE");
+                       break;
+
+               case SMBC_IPC_SHARE:
+                       printf("IPC_SHARE");
+                       break;
+
+               case SMBC_DIR:
+                       printf("DIR");
+                       break;
+
+               case SMBC_FILE:
+                       printf("FILE");
+
+                       p = path + strlen(path);
+                       strcat(p, "/");
+                       strcat(p+1, dirent->name);
+                       if (smbc_stat(path, &st) < 0)
+                       {
+                               printf(" unknown size (reason %d: %s)",
+                                      errno, strerror(errno));
+                       }
+                       else
+                       {
+                               printf(" size %lu", (unsigned long) st.st_size);
+                       }
+                       *p = '\0';
+
+                       break;
+
+               case SMBC_LINK:
+                       printf("LINK");
+                       break;
+               }
+
+               printf("\n");
+
+               if (scan &&
+                   (dirent->smbc_type == SMBC_WORKGROUP ||
+                    dirent->smbc_type == SMBC_SERVER))
+               {
+                       /*
+                        * don't append server name to workgroup; what we want is:
+                        *
+                        *   smb://workgroup_name
+                        * or
+                        *   smb://server_name
+                        *
+                        */
+                       snprintf(buf, sizeof(buf), "smb://%s", dirent->name);
+                       browse(buf, scan, indent + 2);
+               }
+       }
+
+       smbc_closedir(dir);
 }
-    
index ac2063d613d3f0c3d947be78324c6b090a2ce7dc..d858ba96312074c9abbafe16f8aa57fa7d80a583 100644 (file)
@@ -28,143 +28,142 @@ static void smbc_auth_fn(
                char            *wrkgrp, int wrkgrplen,
                char            *user,   int userlen,
                char            *passwd, int passwdlen){
-               
-    (void) server;
-    (void) share;
-    (void) wrkgrp;
-    (void) wrkgrplen;
-
-    strncpy(wrkgrp, workgroup, wrkgrplen - 1); wrkgrp[wrkgrplen - 1] = 0;
-    strncpy(user, username, userlen - 1); user[userlen - 1] = 0;
-    strncpy(passwd, password, passwdlen - 1); passwd[passwdlen - 1] = 0;
+
+       (void) server;
+       (void) share;
+       (void) wrkgrp;
+       (void) wrkgrplen;
+
+       strncpy(wrkgrp, workgroup, wrkgrplen - 1); wrkgrp[wrkgrplen - 1] = 0;
+       strncpy(user, username, userlen - 1); user[userlen - 1] = 0;
+       strncpy(passwd, password, passwdlen - 1); passwd[passwdlen - 1] = 0;
 }
 
 static SMBCCTX* create_smbctx(void){
-    SMBCCTX    *ctx;
+       SMBCCTX *ctx;
 
-    if ((ctx = smbc_new_context()) == NULL) return NULL;
+       if ((ctx = smbc_new_context()) == NULL) return NULL;
 
-    smbc_setDebug(ctx, debuglevel);
-    smbc_setFunctionAuthData(ctx, smbc_auth_fn);
+       smbc_setDebug(ctx, debuglevel);
+       smbc_setFunctionAuthData(ctx, smbc_auth_fn);
 
-    if (smbc_init_context(ctx) == NULL){
-       smbc_free_context(ctx, 1);
-       return NULL;
-    }
+       if (smbc_init_context(ctx) == NULL){
+               smbc_free_context(ctx, 1);
+               return NULL;
+       }
 
-    return ctx;
+       return ctx;
 }
 
 static void delete_smbctx(SMBCCTX* ctx){
-    smbc_getFunctionPurgeCachedServers(ctx)(ctx);
-    smbc_free_context(ctx, 1);
+       smbc_getFunctionPurgeCachedServers(ctx)(ctx);
+       smbc_free_context(ctx, 1);
 }
 
 static smbitem* get_smbitem_list(SMBCCTX *ctx, char *smb_path){
-    SMBCFILE           *fd;
-    struct smbc_dirent *dirent;
-    smbitem            *list = NULL, *item;
-
-    if ((fd = smbc_getFunctionOpendir(ctx)(ctx, smb_path)) == NULL)
-        return NULL;
-    while((dirent = smbc_getFunctionReaddir(ctx)(ctx, fd)) != NULL){
-       size_t slen;
-       if (strcmp(dirent->name, "") == 0) continue;
-       if (strcmp(dirent->name, ".") == 0) continue;
-       if (strcmp(dirent->name, "..") == 0) continue;
-       
-       slen = strlen(dirent->name)+1;
-       if ((item = malloc(sizeof(smbitem) + slen)) == NULL)
-           continue;
-       
-       item->next = list;
-       item->type = dirent->smbc_type;
-       memcpy(item->name, dirent->name, slen);
-       list = item;
-    }
-    smbc_getFunctionClose(ctx)(ctx, fd);
-    return /* smbitem_list_sort */ (list);    
-        
+       SMBCFILE                *fd;
+       struct smbc_dirent      *dirent;
+       smbitem         *list = NULL, *item;
+
+       if ((fd = smbc_getFunctionOpendir(ctx)(ctx, smb_path)) == NULL)
+               return NULL;
+       while((dirent = smbc_getFunctionReaddir(ctx)(ctx, fd)) != NULL){
+               size_t slen;
+               if (strcmp(dirent->name, "") == 0) continue;
+               if (strcmp(dirent->name, ".") == 0) continue;
+               if (strcmp(dirent->name, "..") == 0) continue;
+
+               slen = strlen(dirent->name)+1;
+               if ((item = malloc(sizeof(smbitem) + slen)) == NULL)
+                       continue;
+
+               item->next = list;
+               item->type = dirent->smbc_type;
+               memcpy(item->name, dirent->name, slen);
+               list = item;
+       }
+       smbc_getFunctionClose(ctx)(ctx, fd);
+       return /* smbitem_list_sort */ (list);
 }
 
 static void print_smb_path(const char *group, const char *path){
-    if ((strlen(group) == 0) && (strlen(path) == 0)) printf("/\n");
-    else if (strlen(path) == 0) printf("/%s\n", group);
-    else{
-       if (strlen(group) == 0) group = "(unknown_group)";
-       printf("/%s/%s\n", group, path);
-    }
+       if ((strlen(group) == 0) && (strlen(path) == 0)) printf("/\n");
+       else if (strlen(path) == 0) printf("/%s\n", group);
+       else{
+               if (strlen(group) == 0) group = "(unknown_group)";
+               printf("/%s/%s\n", group, path);
+       }
 }
 
 static void recurse(SMBCCTX *ctx, const char *smb_group, char *smb_path, int maxlen){
-    int        len;
-    smbitem    *list, *item;
-    SMBCCTX    *ctx1;
-    
-    len = strlen(smb_path);
-    
-    list = get_smbitem_list(ctx, smb_path);
-    while(list != NULL){
-       switch(list->type){
-           case SMBC_WORKGROUP:
-           case SMBC_SERVER:
-               if (list->type == SMBC_WORKGROUP){
-                   print_smb_path(list->name, "");
-                   smb_group = list->name;
+       int     len;
+       smbitem *list, *item;
+       SMBCCTX *ctx1;
+
+       len = strlen(smb_path);
+
+       list = get_smbitem_list(ctx, smb_path);
+       while(list != NULL){
+               switch(list->type){
+               case SMBC_WORKGROUP:
+               case SMBC_SERVER:
+                       if (list->type == SMBC_WORKGROUP){
+                               print_smb_path(list->name, "");
+                               smb_group = list->name;
+                       }
+                       else print_smb_path(smb_group, list->name);
+
+                       if (maxlen < 7 + strlen(list->name)) break;
+                       strncpy(smb_path + 6, list->name, maxlen - 6);
+                       smb_path[maxlen-1] = '\0';
+                       if ((ctx1 = create_smbctx()) != NULL){
+                               recurse(ctx1, smb_group, smb_path, maxlen);
+                               delete_smbctx(ctx1);
+                       }else{
+                               recurse(ctx, smb_group, smb_path, maxlen);
+                               smbc_getFunctionPurgeCachedServers(ctx)(ctx);
+                       }
+                       break;
+               case SMBC_FILE_SHARE:
+               case SMBC_DIR:
+               case SMBC_FILE:
+                       if (maxlen < len + strlen(list->name) + 2) break;
+
+                       smb_path[len] = '/';
+                       strncpy(smb_path + len + 1, list->name, maxlen - len - 1);
+                       smb_path[maxlen-1] = '\0';
+                       print_smb_path(smb_group, smb_path + 6);
+                       if (list->type != SMBC_FILE){
+                               recurse(ctx, smb_group, smb_path, maxlen);
+                               if (list->type == SMBC_FILE_SHARE)
+                                       smbc_getFunctionPurgeCachedServers(ctx)(ctx);
+                       }
+                       break;
                }
-               else print_smb_path(smb_group, list->name);
-               
-               if (maxlen < 7 + strlen(list->name)) break;
-               strncpy(smb_path + 6, list->name, maxlen - 6);
-               smb_path[maxlen-1] = '\0';
-               if ((ctx1 = create_smbctx()) != NULL){
-                   recurse(ctx1, smb_group, smb_path, maxlen);
-                   delete_smbctx(ctx1);
-               }else{
-                   recurse(ctx, smb_group, smb_path, maxlen);
-                   smbc_getFunctionPurgeCachedServers(ctx)(ctx);
-               }
-               break;
-           case SMBC_FILE_SHARE:
-           case SMBC_DIR:
-           case SMBC_FILE:
-               if (maxlen < len + strlen(list->name) + 2) break;
-               
-               smb_path[len] = '/';
-               strncpy(smb_path + len + 1, list->name, maxlen - len - 1);
-               smb_path[maxlen-1] = '\0';
-               print_smb_path(smb_group, smb_path + 6);
-               if (list->type != SMBC_FILE){
-                   recurse(ctx, smb_group, smb_path, maxlen);
-                   if (list->type == SMBC_FILE_SHARE)
-                       smbc_getFunctionPurgeCachedServers(ctx)(ctx);
-               }
-               break;
+               item = list;
+               list = list->next;
+               free(item);
        }
-       item = list;
-       list = list->next;
-       free(item);
-    }
-    smb_path[len] = '\0';
+       smb_path[len] = '\0';
 }
 
 int main(int argc, char *argv[]){
-    int                i;
-    SMBCCTX    *ctx;
-    char       smb_path[32768] = "smb://";
-
-    if ((ctx = create_smbctx()) == NULL){
-       perror("Cant create samba context.");
-       return 1;
-    }
-
-    if (argc == 1) recurse(ctx, "", smb_path, sizeof(smb_path));
-    else for(i = 1; i < argc; i++){
-       strncpy(smb_path + 6, argv[i], sizeof(smb_path) - 7);
-       smb_path[sizeof(smb_path) - 1] = '\0';
-       recurse(ctx, "", smb_path, sizeof(smb_path));
-    }
-    
-    delete_smbctx(ctx);
-    return 0;  
+       int             i;
+       SMBCCTX *ctx;
+       char    smb_path[32768] = "smb://";
+
+       if ((ctx = create_smbctx()) == NULL){
+               perror("Cant create samba context.");
+               return 1;
+       }
+
+       if (argc == 1) recurse(ctx, "", smb_path, sizeof(smb_path));
+       else for(i = 1; i < argc; i++){
+                       strncpy(smb_path + 6, argv[i], sizeof(smb_path) - 7);
+                       smb_path[sizeof(smb_path) - 1] = '\0';
+                       recurse(ctx, "", smb_path, sizeof(smb_path));
+               }
+
+       delete_smbctx(ctx);
+       return 0;
 }
index b285a81a1907be60344b9e0b84c877fdb72c508b..2341e8125e6efd2353cf9ef23c080c263a65667c 100644 (file)
@@ -1,62 +1,62 @@
-#include <stdio.h> 
+#include <stdio.h>
 #include <unistd.h>
-#include <string.h> 
-#include <time.h> 
-#include <libsmbclient.h> 
+#include <string.h>
+#include <time.h>
+#include <libsmbclient.h>
 #include "get_auth_data_fn.h"
 
 
-int main(int argc, char * argv[]) 
-{ 
-    int             debug = 0;
-    int             mode = 0666;
-    const char *          pSmbPath = NULL;
-    struct stat     st; 
-    
-    if (argc == 1)
-    {
-        pSmbPath = "smb://RANDOM/Public/small";
-    }
-    else if (argc == 2)
-    {
-        pSmbPath = argv[1];
-    }
-    else if (argc == 3)
-    {
-        pSmbPath = argv[1];
-        mode = (int) strtol(argv[2], NULL, 8);
-    }
-    else
-    {
-        printf("usage: "
-               "%s [ smb://path/to/file [ octal_mode ] ]\n",
-               argv[0]);
-        return 1;
-    }
-
-    smbc_init(get_auth_data_fn, debug); 
-    
-    if (smbc_stat(pSmbPath, &st) < 0)
-    {
-        perror("smbc_stat");
-        return 1;
-    }
-    
-    printf("\nBefore chmod: mode = %04o\n", (unsigned int)st.st_mode);
-    
-    if (smbc_chmod(pSmbPath, mode) < 0)
-    {
-        perror("smbc_chmod");
-        return 1;
-    }
-
-    if (smbc_stat(pSmbPath, &st) < 0)
-    {
-        perror("smbc_stat");
-        return 1;
-    }
-    
-    printf("After chmod: mode = %04o\n", (unsigned int)st.st_mode);
-    
-    return 0; 
+int main(int argc, char * argv[])
+{
+       int             debug = 0;
+       int             mode = 0666;
+       const char *          pSmbPath = NULL;
+       struct stat     st;
+
+       if (argc == 1)
+       {
+               pSmbPath = "smb://RANDOM/Public/small";
+       }
+       else if (argc == 2)
+       {
+               pSmbPath = argv[1];
+       }
+       else if (argc == 3)
+       {
+               pSmbPath = argv[1];
+               mode = (int) strtol(argv[2], NULL, 8);
+       }
+       else
+       {
+               printf("usage: "
+                      "%s [ smb://path/to/file [ octal_mode ] ]\n",
+                      argv[0]);
+               return 1;
+       }
+
+       smbc_init(get_auth_data_fn, debug);
+
+       if (smbc_stat(pSmbPath, &st) < 0)
+       {
+               perror("smbc_stat");
+               return 1;
+       }
+
+       printf("\nBefore chmod: mode = %04o\n", (unsigned int)st.st_mode);
+
+       if (smbc_chmod(pSmbPath, mode) < 0)
+       {
+               perror("smbc_chmod");
+               return 1;
+       }
+
+       if (smbc_stat(pSmbPath, &st) < 0)
+       {
+               perror("smbc_stat");
+               return 1;
+       }
+
+       printf("After chmod: mode = %04o\n", (unsigned int)st.st_mode);
+
+       return 0;
 }
index 7f27fbd7c9cfbdbe7c252f654de7d2cd0f42b44e..e410731739a9a54dd31733adf2b79a65b75026c4 100644 (file)
@@ -5,29 +5,29 @@
 
 static void create_and_destroy_context (void)
 {
-  int i;
-  SMBCCTX *ctx;
-  ctx = smbc_new_context ();
-  /* Both should do the same thing */
-  smbc_setOptionDebugToStderr(ctx, 1);
-  smbc_option_set(ctx, strdup("debug_to_stderr"), 1);
-  smbc_setDebug(ctx, 1);
-  i = smbc_getDebug(ctx);
-  if (i != 1) { 
-         printf("smbc_getDebug() did not return debug level set\n");
-         exit(1);
-  }
-  if (!smbc_getOptionDebugToStderr(ctx)) {
-         printf("smbc_setOptionDebugToStderr() did not stick\n");
-         exit(1);
-  }
-  smbc_init_context (ctx);
-  smbc_free_context (ctx, 1);
+       int i;
+       SMBCCTX *ctx;
+       ctx = smbc_new_context ();
+       /* Both should do the same thing */
+       smbc_setOptionDebugToStderr(ctx, 1);
+       smbc_option_set(ctx, strdup("debug_to_stderr"), 1);
+       smbc_setDebug(ctx, 1);
+       i = smbc_getDebug(ctx);
+       if (i != 1) {
+               printf("smbc_getDebug() did not return debug level set\n");
+               exit(1);
+       }
+       if (!smbc_getOptionDebugToStderr(ctx)) {
+               printf("smbc_setOptionDebugToStderr() did not stick\n");
+               exit(1);
+       }
+       smbc_init_context (ctx);
+       smbc_free_context (ctx, 1);
 }
 
 int main (int argc, char **argv)
 {
-  create_and_destroy_context ();
-  create_and_destroy_context ();
-  return 0;
+       create_and_destroy_context ();
+       create_and_destroy_context ();
+       return 0;
 }
index b2396e3fa1bedc74a5b1e4350f0c2e72bc88cf3e..9a4063e490c65035a0ff58b72f6c0255fff38949 100644 (file)
 #include <sys/types.h>
 #include <sys/statvfs.h>
-#include <stdio.h> 
+#include <stdio.h>
 #include <unistd.h>
-#include <string.h> 
-#include <time.h> 
+#include <string.h>
+#include <time.h>
 #include <errno.h>
-#include <libsmbclient.h> 
+#include <libsmbclient.h>
 #include "get_auth_data_fn.h"
 
 
-int main(int argc, char * argv[]) 
-{ 
-    int             fd;
-    int             ret;
-    int             debug = 0;
-    char *          p;
-    char            path[2048];
-    struct stat     statbuf;
-    struct statvfs  statvfsbuf;
-    
-    smbc_init(get_auth_data_fn, debug); 
-    
-    for (;;)
-    {
-        fprintf(stdout, "Path: ");
-        *path = '\0';
-       p = fgets(path, sizeof(path) - 1, stdin);
-       if (p == NULL) {
-               fprintf(stderr, "failed to read from stdin\n");
-               return 1;
-       }
-        if (strlen(path) == 0)
-        {
-            return 0;
-        }
-
-        p = path + strlen(path) - 1;
-        if (*p == '\n')
-        {
-            *p = '\0';
-        }
-    
-        /* Determine if it's a file or a folder */
-        if (smbc_stat(path, &statbuf) < 0)
-        {
-            perror("smbc_stat");
-            continue;
-        }
-
-        if (S_ISREG(statbuf.st_mode))
-        {
-            if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
-            {
-                perror("smbc_open");
-                continue;
-            }
-        }
-        else
-        {
-            if ((fd = smbc_opendir(path)) < 0)
-            {
-                perror("smbc_opendir");
-                continue;
-            }
-        }
-
-        ret = smbc_fstatvfs(fd, &statvfsbuf);
-
-        smbc_close(fd);
-
-        if (ret < 0)
-        {
-            perror("fstatvfs");
-        }
-        else
-        {
-            printf("\n");
-            printf("Block Size: %lu\n", statvfsbuf.f_bsize);
-            printf("Fragment Size: %lu\n", statvfsbuf.f_frsize);
-            printf("Blocks: %llu\n",
-                   (unsigned long long) statvfsbuf.f_blocks);
-            printf("Free Blocks: %llu\n",
-                   (unsigned long long) statvfsbuf.f_bfree);
-            printf("Available Blocks: %llu\n",
-                   (unsigned long long) statvfsbuf.f_bavail);
-            printf("Files : %llu\n",
-                   (unsigned long long) statvfsbuf.f_files);
-            printf("Free Files: %llu\n",
-                   (unsigned long long) statvfsbuf.f_ffree);
-            printf("Available Files: %llu\n",
-                   (unsigned long long) statvfsbuf.f_favail);
+int main(int argc, char * argv[])
+{
+       int             fd;
+       int             ret;
+       int             debug = 0;
+       char *          p;
+       char            path[2048];
+       struct stat     statbuf;
+       struct statvfs  statvfsbuf;
+
+       smbc_init(get_auth_data_fn, debug);
+
+       for (;;)
+       {
+               fprintf(stdout, "Path: ");
+               *path = '\0';
+               p = fgets(path, sizeof(path) - 1, stdin);
+               if (p == NULL) {
+                       fprintf(stderr, "failed to read from stdin\n");
+                       return 1;
+               }
+               if (strlen(path) == 0)
+               {
+                       return 0;
+               }
+
+               p = path + strlen(path) - 1;
+               if (*p == '\n')
+               {
+                       *p = '\0';
+               }
+
+               /* Determine if it's a file or a folder */
+               if (smbc_stat(path, &statbuf) < 0)
+               {
+                       perror("smbc_stat");
+                       continue;
+               }
+
+               if (S_ISREG(statbuf.st_mode))
+               {
+                       if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
+                       {
+                               perror("smbc_open");
+                               continue;
+                       }
+               }
+               else
+               {
+                       if ((fd = smbc_opendir(path)) < 0)
+                       {
+                               perror("smbc_opendir");
+                               continue;
+                       }
+               }
+
+               ret = smbc_fstatvfs(fd, &statvfsbuf);
+
+               smbc_close(fd);
+
+               if (ret < 0)
+               {
+                       perror("fstatvfs");
+               }
+               else
+               {
+                       printf("\n");
+                       printf("Block Size: %lu\n", statvfsbuf.f_bsize);
+                       printf("Fragment Size: %lu\n", statvfsbuf.f_frsize);
+                       printf("Blocks: %llu\n",
+                              (unsigned long long) statvfsbuf.f_blocks);
+                       printf("Free Blocks: %llu\n",
+                              (unsigned long long) statvfsbuf.f_bfree);
+                       printf("Available Blocks: %llu\n",
+                              (unsigned long long) statvfsbuf.f_bavail);
+                       printf("Files : %llu\n",
+                              (unsigned long long) statvfsbuf.f_files);
+                       printf("Free Files: %llu\n",
+                              (unsigned long long) statvfsbuf.f_ffree);
+                       printf("Available Files: %llu\n",
+                              (unsigned long long) statvfsbuf.f_favail);
 #ifdef HAVE_FSID_INT
-            printf("File System ID: %lu\n",
-                   (unsigned long) statvfsbuf.f_fsid);
+                       printf("File System ID: %lu\n",
+                              (unsigned long) statvfsbuf.f_fsid);
 #endif
-            printf("\n");
-
-            printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
-            printf("Extended Features: ");
-
-            if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
-            {
-                printf("NO_UNIXCIFS ");
-            }
-            else
-            {
-                printf("unixcifs ");
-            }
-
-            if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
-            {
-                printf("CASE_INSENSITIVE ");
-            }
-            else
-            {
-                printf("case_sensitive ");
-            }
-
-            if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
-            {
-                printf("DFS ");
-            }
-            else
-            {
-                printf("no_dfs ");
-            }
-
-            printf("\n");
-        }
-    }
-
-    return 0; 
+                       printf("\n");
+
+                       printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
+                       printf("Extended Features: ");
+
+                       if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
+                       {
+                               printf("NO_UNIXCIFS ");
+                       }
+                       else
+                       {
+                               printf("unixcifs ");
+                       }
+
+                       if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
+                       {
+                               printf("CASE_INSENSITIVE ");
+                       }
+                       else
+                       {
+                               printf("case_sensitive ");
+                       }
+
+                       if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
+                       {
+                               printf("DFS ");
+                       }
+                       else
+                       {
+                               printf("no_dfs ");
+                       }
+
+                       printf("\n");
+               }
+       }
+
+       return 0;
 }
index e6d9bf869ab9afc54c66586c27482b8caeb3d01b..d9722adae2fd44630cec576a344be625628e587f 100644 (file)
@@ -1,66 +1,66 @@
 #include <sys/types.h>
-#include <stdio.h> 
+#include <stdio.h>
 #include <unistd.h>
-#include <string.h> 
-#include <time.h> 
+#include <string.h>
+#include <time.h>
 #include <errno.h>
-#include <libsmbclient.h> 
+#include <libsmbclient.h>
 #include "get_auth_data_fn.h"
 
 
-int main(int argc, char * argv[]) 
-{ 
-    int             fd;
-    int             ret;
-    int             debug = 0;
-    int             savedErrno;
-    char            buffer[2048]; 
-    char            path[2048];
-    char *          p;
-    
-    smbc_init(get_auth_data_fn, debug); 
-    
-    for (;;)
-    {
-        fprintf(stdout, "Path: ");
-        *path = '\0';
-       p = fgets(path, sizeof(path) - 1, stdin);
-       if (p == NULL) {
-               fprintf(stderr, "failed to read from stdin\n");
-               return 1;
-       }
-        if (strlen(path) == 0)
-        {
-            return 0;
-        }
+int main(int argc, char * argv[])
+{
+       int             fd;
+       int             ret;
+       int             debug = 0;
+       int             savedErrno;
+       char            buffer[2048];
+       char            path[2048];
+       char *          p;
+
+       smbc_init(get_auth_data_fn, debug);
+
+       for (;;)
+       {
+               fprintf(stdout, "Path: ");
+               *path = '\0';
+               p = fgets(path, sizeof(path) - 1, stdin);
+               if (p == NULL) {
+                       fprintf(stderr, "failed to read from stdin\n");
+                       return 1;
+               }
+               if (strlen(path) == 0)
+               {
+                       return 0;
+               }
 
-        p = path + strlen(path) - 1;
-        if (*p == '\n')
-        {
-            *p = '\0';
-        }
-    
-        if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
-        {
-            perror("smbc_open");
-            continue;
-        }
+               p = path + strlen(path) - 1;
+               if (*p == '\n')
+               {
+                       *p = '\0';
+               }
 
-        do
-        {
-            ret = smbc_read(fd, buffer, sizeof(buffer));
-            savedErrno = errno;
-            if (ret > 0) fwrite(buffer, 1, ret, stdout);
-        } while (ret > 0);
+               if ((fd = smbc_open(path, O_RDONLY, 0)) < 0)
+               {
+                       perror("smbc_open");
+                       continue;
+               }
 
-        smbc_close(fd);
+               do
+               {
+                       ret = smbc_read(fd, buffer, sizeof(buffer));
+                       savedErrno = errno;
+                       if (ret > 0) fwrite(buffer, 1, ret, stdout);
+               } while (ret > 0);
 
-        if (ret < 0)
-        {
-            errno = savedErrno;
-            perror("read");
-        }
-    }
+               smbc_close(fd);
+
+               if (ret < 0)
+               {
+                       errno = savedErrno;
+                       perror("read");
+               }
+       }
 
-    return 0; 
+       return 0;
 }
index 3c9aa5674cdaab40cd988a72abadcb6c081952b3..a61d38ecaba330640d6921c2698e9571100de401 100644 (file)
@@ -1,20 +1,20 @@
-/* 
+/*
    Unix SMB/CIFS implementation.
    SMB client library test program
    Copyright (C) Andrew Tridgell 1998
    Copyright (C) Richard Sharpe 2000
    Copyright (C) John Terpsra 2000
-   
+
    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 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    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, see <http://www.gnu.org/licenses/>.
 */
 
 int main(int argc, char *argv[])
 {
-  int err, fd, dh1, dsize, dirc;
-  const char *file = "smb://samba/public/testfile.txt";
-  const char *file2 = "smb://samba/public/testfile2.txt";
-  char buff[256];
-  char dirbuf[512];
-  char *dirp;
-  struct stat st1, st2;
+       int err, fd, dh1, dsize, dirc;
+       const char *file = "smb://samba/public/testfile.txt";
+       const char *file2 = "smb://samba/public/testfile2.txt";
+       char buff[256];
+       char dirbuf[512];
+       char *dirp;
+       struct stat st1, st2;
+
+       err = smbc_init(get_auth_data_fn,  10); /* Initialize things */
+
+       if (err < 0) {
+
+               fprintf(stderr, "Initializing the smbclient library ...: %s\n", strerror(errno));
 
-  err = smbc_init(get_auth_data_fn,  10); /* Initialize things */
+       }
 
-  if (err < 0) {
+       if (argc > 1) {
 
-    fprintf(stderr, "Initializing the smbclient library ...: %s\n", strerror(errno));
+               if ((dh1 = smbc_opendir(argv[1]))<1) {
 
-  }
+                       fprintf(stderr, "Could not open directory: %s: %s\n",
+                               argv[1], strerror(errno));
 
-  if (argc > 1) {
+                       exit(1);
 
-    if ((dh1 = smbc_opendir(argv[1]))<1) {
+               }
 
-      fprintf(stderr, "Could not open directory: %s: %s\n",
-             argv[1], strerror(errno));
+               fprintf(stdout, "Directory handle: %u\n", dh1);
 
-      exit(1);
+               /* Now, list those directories, but in funny ways ... */
 
-    }
+               dirp = (char *)dirbuf;
 
-    fprintf(stdout, "Directory handle: %u\n", dh1);
+               if ((dirc = smbc_getdents(dh1, (struct smbc_dirent *)dirp,
+                                         sizeof(dirbuf))) < 0) {
 
-    /* Now, list those directories, but in funny ways ... */
+                       fprintf(stderr, "Problems getting directory entries: %s\n",
+                               strerror(errno));
 
-    dirp = (char *)dirbuf;
+                       exit(1);
 
-    if ((dirc = smbc_getdents(dh1, (struct smbc_dirent *)dirp, 
-                             sizeof(dirbuf))) < 0) {
+               }
 
-      fprintf(stderr, "Problems getting directory entries: %s\n",
-             strerror(errno));
+               /* Now, process the list of names ... */
 
-      exit(1);
+               fprintf(stdout, "Directory listing, size = %u\n", dirc);
 
-    }
+               while (dirc > 0) {
 
-    /* Now, process the list of names ... */
+                       dsize = ((struct smbc_dirent *)dirp)->dirlen;
+                       fprintf(stdout, "Dir Ent, Type: %u, Name: %s, Comment: %s\n",
+                               ((struct smbc_dirent *)dirp)->smbc_type,
+                               ((struct smbc_dirent *)dirp)->name,
+                               ((struct smbc_dirent *)dirp)->comment);
 
-    fprintf(stdout, "Directory listing, size = %u\n", dirc);
+                       dirp += dsize;
+                       dirc -= dsize;
 
-    while (dirc > 0) {
+               }
 
-      dsize = ((struct smbc_dirent *)dirp)->dirlen;
-      fprintf(stdout, "Dir Ent, Type: %u, Name: %s, Comment: %s\n",
-             ((struct smbc_dirent *)dirp)->smbc_type, 
-             ((struct smbc_dirent *)dirp)->name, 
-             ((struct smbc_dirent *)dirp)->comment);
+               dirp = (char *)dirbuf;
 
-      dirp += dsize;
-      dirc -= dsize;
+               exit(1);
 
-    }
+       }
 
-    dirp = (char *)dirbuf;
+       /* For now, open a file on a server that is hard coded ... later will
+        * read from the command line ...
+        */
 
-    exit(1);
+       fd = smbc_open(file, O_RDWR | O_CREAT | O_TRUNC, 0666);
 
-  }
+       if (fd < 0) {
 
-  /* For now, open a file on a server that is hard coded ... later will
-   * read from the command line ...
-   */
+               fprintf(stderr, "Creating file: %s: %s\n", file, strerror(errno));
+               exit(0);
 
-  fd = smbc_open(file, O_RDWR | O_CREAT | O_TRUNC, 0666);
+       }
 
-  if (fd < 0) {
+       fprintf(stdout, "Opened or created file: %s\n", file);
 
-    fprintf(stderr, "Creating file: %s: %s\n", file, strerror(errno));
-    exit(0);
+       /* Now, write some date to the file ... */
 
-  }
+       memset(buff, '\0', sizeof(buff));
+       snprintf(buff, sizeof(buff), "%s", "Some test data for the moment ...");
 
-  fprintf(stdout, "Opened or created file: %s\n", file);
+       err = smbc_write(fd, buff, sizeof(buff));
 
-  /* Now, write some date to the file ... */
+       if (err < 0) {
 
-  memset(buff, '\0', sizeof(buff));
-  snprintf(buff, sizeof(buff), "%s", "Some test data for the moment ...");
+               fprintf(stderr, "writing file: %s: %s\n", file, strerror(errno));
+               exit(0);
 
-  err = smbc_write(fd, buff, sizeof(buff));
+       }
 
-  if (err < 0) {
-    
-    fprintf(stderr, "writing file: %s: %s\n", file, strerror(errno));
-    exit(0);
+       fprintf(stdout, "Wrote %lu bytes to file: %s\n",
+               (unsigned long) sizeof(buff), buff);
 
-  }
+       /* Now, seek the file back to offset 0 */
 
-  fprintf(stdout, "Wrote %lu bytes to file: %s\n",
-          (unsigned long) sizeof(buff), buff);
+       err = smbc_lseek(fd, SEEK_SET, 0);
 
-  /* Now, seek the file back to offset 0 */
+       if (err < 0) {
 
-  err = smbc_lseek(fd, SEEK_SET, 0);
+               fprintf(stderr, "Seeking file: %s: %s\n", file, strerror(errno));
+               exit(0);
 
-  if (err < 0) {
+       }
 
-    fprintf(stderr, "Seeking file: %s: %s\n", file, strerror(errno));
-    exit(0);
+       fprintf(stdout, "Completed lseek on file: %s\n", file);
 
-  }
+       /* Now, read the file contents back ... */
 
-  fprintf(stdout, "Completed lseek on file: %s\n", file);
+       err = smbc_read(fd, buff, sizeof(buff));
 
-  /* Now, read the file contents back ... */
+       if (err < 0) {
 
-  err = smbc_read(fd, buff, sizeof(buff));
+               fprintf(stderr, "Reading file: %s: %s\n", file, strerror(errno));
+               exit(0);
 
-  if (err < 0) {
+       }
 
-    fprintf(stderr, "Reading file: %s: %s\n", file, strerror(errno));
-    exit(0);
+       fprintf(stdout, "Read file: %s\n", buff);  /* Should check the contents */
 
-  }
+       fprintf(stdout, "Now fstat'ing file: %s\n", file);
 
-  fprintf(stdout, "Read file: %s\n", buff);  /* Should check the contents */
+       err = smbc_fstat(fd, &st1);
 
-  fprintf(stdout, "Now fstat'ing file: %s\n", file);
+       if (err < 0) {
 
-  err = smbc_fstat(fd, &st1);
+               fprintf(stderr, "Fstat'ing file: %s: %s\n", file, strerror(errno));
+               exit(0);
 
-  if (err < 0) {
+       }
 
-    fprintf(stderr, "Fstat'ing file: %s: %s\n", file, strerror(errno));
-    exit(0);
 
-  }
+       /* Now, close the file ... */
 
+       err = smbc_close(fd);
 
-  /* Now, close the file ... */
+       if (err < 0) {
 
-  err = smbc_close(fd);
+               fprintf(stderr, "Closing file: %s: %s\n", file, strerror(errno));
 
-  if (err < 0) {
+       }
 
-    fprintf(stderr, "Closing file: %s: %s\n", file, strerror(errno));
+       /* Now, rename the file ... */
 
-  }
+       err = smbc_rename(file, file2);
 
-  /* Now, rename the file ... */
+       if (err < 0) {
 
-  err = smbc_rename(file, file2);
+               fprintf(stderr, "Renaming file: %s to %s: %s\n", file, file2, strerror(errno));
 
-  if (err < 0) {
+       }
 
-    fprintf(stderr, "Renaming file: %s to %s: %s\n", file, file2, strerror(errno));
+       fprintf(stdout, "Renamed file %s to %s\n", file, file2);
 
-  }
+       /* Now, create a file and delete it ... */
 
-  fprintf(stdout, "Renamed file %s to %s\n", file, file2);
+       fprintf(stdout, "Now, creating file: %s so we can delete it.\n", file);
 
-  /* Now, create a file and delete it ... */
+       fd = smbc_open(file, O_RDWR | O_CREAT, 0666);
 
-  fprintf(stdout, "Now, creating file: %s so we can delete it.\n", file);
+       if (fd < 0) {
 
-  fd = smbc_open(file, O_RDWR | O_CREAT, 0666);
+               fprintf(stderr, "Creating file: %s: %s\n", file, strerror(errno));
+               exit(0);
 
-  if (fd < 0) {
+       }
 
-    fprintf(stderr, "Creating file: %s: %s\n", file, strerror(errno));
-    exit(0);
+       fprintf(stdout, "Opened or created file: %s\n", file);
 
-  }
+       err = smbc_close(fd);
 
-  fprintf(stdout, "Opened or created file: %s\n", file);
+       if (err < 0) {
 
-  err = smbc_close(fd);
+               fprintf(stderr, "Closing file: %s: %s\n", file, strerror(errno));
+               exit(0);
 
-  if (err < 0) {
+       }
 
-    fprintf(stderr, "Closing file: %s: %s\n", file, strerror(errno));
-    exit(0);
+       /* Now, delete the file ... */
 
-  }
-  
-  /* Now, delete the file ... */
+       fprintf(stdout, "File %s created, now deleting ...\n", file);
 
-  fprintf(stdout, "File %s created, now deleting ...\n", file);
+       err = smbc_unlink(file);
 
-  err = smbc_unlink(file);
+       if (err < 0) {
 
-  if (err < 0) {
+               fprintf(stderr, "Deleting file: %s: %s\n", file, strerror(errno));
+               exit(0);
 
-    fprintf(stderr, "Deleting file: %s: %s\n", file, strerror(errno));
-    exit(0);
+       }
 
-  }
+       /* Now, stat the file, file 2 ... */
 
-  /* Now, stat the file, file 2 ... */
+       fprintf(stdout, "Now stat'ing file: %s\n", file);
 
-  fprintf(stdout, "Now stat'ing file: %s\n", file);
+       err = smbc_stat(file2, &st2);
 
-  err = smbc_stat(file2, &st2);
+       if (err < 0) {
 
-  if (err < 0) {
+               fprintf(stderr, "Stat'ing file: %s: %s\n", file, strerror(errno));
+               exit(0);
 
-    fprintf(stderr, "Stat'ing file: %s: %s\n", file, strerror(errno));
-    exit(0);
+       }
 
-  }
+       fprintf(stdout, "Stat'ed file:   %s. Size = %d, mode = %04X\n", file2,
+               (int)st2.st_size, (unsigned int)st2.st_mode);
+       fprintf(stdout, "    time: %s\n", ctime(&st2.st_atime));
+       fprintf(stdout, "Earlier stat:   %s, Size = %d, mode = %04X\n", file,
+               (int)st1.st_size, (unsigned int)st1.st_mode);
+       fprintf(stdout, "    time: %s\n", ctime(&st1.st_atime));
 
-  fprintf(stdout, "Stat'ed file:   %s. Size = %d, mode = %04X\n", file2, 
-         (int)st2.st_size, (unsigned int)st2.st_mode);
-  fprintf(stdout, "    time: %s\n", ctime(&st2.st_atime));
-  fprintf(stdout, "Earlier stat:   %s, Size = %d, mode = %04X\n", file, 
-         (int)st1.st_size, (unsigned int)st1.st_mode);
-  fprintf(stdout, "    time: %s\n", ctime(&st1.st_atime));
+       /* Now, make a directory ... */
 
-  /* Now, make a directory ... */
+       fprintf(stdout, "Making directory smb://samba/public/make-dir\n");
 
-  fprintf(stdout, "Making directory smb://samba/public/make-dir\n");
+       if (smbc_mkdir("smb://samba/public/make-dir", 0666) < 0) {
 
-  if (smbc_mkdir("smb://samba/public/make-dir", 0666) < 0) {
+               fprintf(stderr, "Error making directory: smb://samba/public/make-dir: %s\n",
+                       strerror(errno));
 
-    fprintf(stderr, "Error making directory: smb://samba/public/make-dir: %s\n", 
-           strerror(errno));
+               if (errno == EEXIST) { /* Try to delete the directory */
 
-    if (errno == EEXIST) { /* Try to delete the directory */
+                       fprintf(stdout, "Trying to delete directory: smb://samba/public/make-dir\n");
 
-      fprintf(stdout, "Trying to delete directory: smb://samba/public/make-dir\n");
+                       if (smbc_rmdir("smb://samba/public/make-dir") < 0) { /* Error */
 
-      if (smbc_rmdir("smb://samba/public/make-dir") < 0) { /* Error */
+                               fprintf(stderr, "Error removing directory: smb://samba/public/make-dir: %s\n", strerror(errno));
 
-       fprintf(stderr, "Error removing directory: smb://samba/public/make-dir: %s\n", strerror(errno));
+                               exit(0);
 
-       exit(0);
+                       }
 
-      }
+                       fprintf(stdout, "Making directory: smb://samba/public/make-dir\n");
 
-      fprintf(stdout, "Making directory: smb://samba/public/make-dir\n");
+                       if (smbc_mkdir("smb://samba/public/make-dir", 666) < 0) {
 
-      if (smbc_mkdir("smb://samba/public/make-dir", 666) < 0) {
+                               fprintf(stderr, "Error making directory: smb://samba/public/make-dir: %s\n",
+                                       strerror(errno));
 
-       fprintf(stderr, "Error making directory: smb://samba/public/make-dir: %s\n",
-               strerror(errno));
+                               fprintf(stderr, "I give up!\n");
 
-       fprintf(stderr, "I give up!\n");
+                               exit(1);
 
-       exit(1);
+                       }
 
-      }
+               }
 
-    }
+               exit(0);
 
-    exit(0);
-    
-  }
+       }
 
-  fprintf(stdout, "Made dir: make-dir\n");
-  return 0;
+       fprintf(stdout, "Made dir: make-dir\n");
+       return 0;
 }
index 4084fd08e61fcf84ac7c35b3ba0835725a0ebb58..c75ce8c01a3aaf1f4b06ea141d026f0e3daba4b5 100644 (file)
@@ -1,70 +1,70 @@
-#include <stdio.h> 
+#include <stdio.h>
 #include <unistd.h>
-#include <string.h> 
-#include <time.h> 
-#include <libsmbclient.h> 
+#include <string.h>
+#include <time.h>
+#include <libsmbclient.h>
 #include "get_auth_data_fn.h"
 
 
-int main(int argc, char * argv[]) 
-{ 
-    int             debug = 0;
-    char            m_time[32];
-    char            c_time[32];
-    char            a_time[32];
-    const char *          pSmbPath = NULL;
-    const char *          pLocalPath = NULL;
-    struct stat     st; 
-    
-    if (argc == 1)
-    {
-        pSmbPath = "smb://RANDOM/Public/small";
-        pLocalPath = "/random/home/samba/small";
-    }
-    else if (argc == 2)
-    {
-        pSmbPath = argv[1];
-        pLocalPath = NULL;
-    }
-    else if (argc == 3)
-    {
-        pSmbPath = argv[1];
-        pLocalPath = argv[2];
-    }
-    else
-    {
-        printf("usage: "
-               "%s [ smb://path/to/file [ /nfs/or/local/path/to/file ] ]\n",
-               argv[0]);
-        return 1;
-    }
+int main(int argc, char * argv[])
+{
+       int             debug = 0;
+       char            m_time[32];
+       char            c_time[32];
+       char            a_time[32];
+       const char *          pSmbPath = NULL;
+       const char *          pLocalPath = NULL;
+       struct stat     st;
 
-    smbc_init(get_auth_data_fn, debug); 
-    
-    if (smbc_stat(pSmbPath, &st) < 0)
-    {
-        perror("smbc_stat");
-        return 1;
-    }
-    
-    printf("\nSAMBA\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
-           (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
-           (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
-           (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
-    
-    if (pLocalPath != NULL)
-    {
-        if (stat(pLocalPath, &st) < 0)
-        {
-            perror("stat");
-            return 1;
-        }
-        
-        printf("LOCAL\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
-               (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
-               (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
-               (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
-    }
+       if (argc == 1)
+       {
+               pSmbPath = "smb://RANDOM/Public/small";
+               pLocalPath = "/random/home/samba/small";
+       }
+       else if (argc == 2)
+       {
+               pSmbPath = argv[1];
+               pLocalPath = NULL;
+       }
+       else if (argc == 3)
+       {
+               pSmbPath = argv[1];
+               pLocalPath = argv[2];
+       }
+       else
+       {
+               printf("usage: "
+                      "%s [ smb://path/to/file [ /nfs/or/local/path/to/file ] ]\n",
+                      argv[0]);
+               return 1;
+       }
 
-    return 0; 
+       smbc_init(get_auth_data_fn, debug);
+
+       if (smbc_stat(pSmbPath, &st) < 0)
+       {
+               perror("smbc_stat");
+               return 1;
+       }
+
+       printf("\nSAMBA\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
+              (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
+              (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
+              (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
+
+       if (pLocalPath != NULL)
+       {
+               if (stat(pLocalPath, &st) < 0)
+               {
+                       perror("stat");
+                       return 1;
+               }
+
+               printf("LOCAL\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
+                      (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
+                      (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
+                      (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
+       }
+
+       return 0;
 }
index 963cd2709d27692f49833f778a5419f0a536f2b9..04994b75f7037384bd914300936e8a2b20a97085 100644 (file)
@@ -38,33 +38,33 @@ static int gettime(const char * pUrl,
         char m_time[32];
         char c_time[32];
         char a_time[32];
-        
+
         smbc_init(get_auth_data_fn, 0);
-        
+
         if (smbc_stat(pUrl, &st) < 0)
         {
                 perror("smbc_stat");
                 return 1;
         }
-        
+
         printf("SAMBA\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
                (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
                (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
                (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
-        
-        
+
+
         /* check the stat on this file */
         if (stat(pLocalPath, &st) < 0)
         {
                 perror("stat");
                 return 1;
         }
-        
+
         printf("LOCAL\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
                (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
                (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
                (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
-        
-        
+
+
         return 0;
 }
index 3efe51dffa7b381b0ee99c5bd8c4b1a63a60571e..3669d70de19c614e72ff17849ae24006428a9e57 100644 (file)
@@ -25,15 +25,15 @@ int main(int argc, char* argv[])
                 return 1;
         }
 
-        
+
         smbc_init(get_auth_data_fn, 0);
-        
+
         if (smbc_stat(pUrl, &st1) < 0)
         {
                 perror("smbc_stat");
                 return 1;
         }
-        
+
         if ((fd = smbc_open(pUrl, O_RDONLY, 0)) < 0)
         {
                 perror("smbc_open");
@@ -45,7 +45,7 @@ int main(int argc, char* argv[])
                 perror("smbc_fstat");
                 return 1;
         }
-        
+
         smbc_close(fd);
 
 #define COMPARE(name, field)                                            \
@@ -72,4 +72,3 @@ int main(int argc, char* argv[])
 
         return 0;
 }
-
index 9a8e5392763501b2b576825eb6aea8c4eea42250..44d4ed27364bf5ee34cfe865b3b217e928f1cef2 100644 (file)
 #include <sys/types.h>
 #include <sys/statvfs.h>
-#include <stdio.h> 
+#include <stdio.h>
 #include <unistd.h>
-#include <string.h> 
-#include <time.h> 
+#include <string.h>
+#include <time.h>
 #include <errno.h>
-#include <libsmbclient.h> 
+#include <libsmbclient.h>
 #include "get_auth_data_fn.h"
 
 
-int main(int argc, char * argv[]) 
-{ 
-    int             ret;
-    int             debug = 0;
-    char *          p;
-    char            path[2048];
-    struct statvfs  statvfsbuf;
-    
-    smbc_init(get_auth_data_fn, debug); 
-    
-    for (;;)
-    {
-        fprintf(stdout, "Path: ");
-        *path = '\0';
-       p = fgets(path, sizeof(path) - 1, stdin);
-       if (p == NULL) {
-               fprintf(stderr, "failed to read from stdin\n");
-               return 1;
-       }
-        if (strlen(path) == 0)
-        {
-            return 0;
-        }
+int main(int argc, char * argv[])
+{
+       int             ret;
+       int             debug = 0;
+       char *          p;
+       char            path[2048];
+       struct statvfs  statvfsbuf;
+
+       smbc_init(get_auth_data_fn, debug);
+
+       for (;;)
+       {
+               fprintf(stdout, "Path: ");
+               *path = '\0';
+               p = fgets(path, sizeof(path) - 1, stdin);
+               if (p == NULL) {
+                       fprintf(stderr, "failed to read from stdin\n");
+                       return 1;
+               }
+               if (strlen(path) == 0)
+               {
+                       return 0;
+               }
 
-        p = path + strlen(path) - 1;
-        if (*p == '\n')
-        {
-            *p = '\0';
-        }
-    
-        ret = smbc_statvfs(path, &statvfsbuf);
+               p = path + strlen(path) - 1;
+               if (*p == '\n')
+               {
+                       *p = '\0';
+               }
 
-        if (ret < 0)
-        {
-            perror("fstatvfs");
-        }
-        else
-        {
-            printf("\n");
-            printf("Block Size: %lu\n", statvfsbuf.f_bsize);
-            printf("Fragment Size: %lu\n", statvfsbuf.f_frsize);
-            printf("Blocks: %llu\n",
-                   (unsigned long long) statvfsbuf.f_blocks);
-            printf("Free Blocks: %llu\n",
-                   (unsigned long long) statvfsbuf.f_bfree);
-            printf("Available Blocks: %llu\n",
-                   (unsigned long long) statvfsbuf.f_bavail);
-            printf("Files : %llu\n",
-                   (unsigned long long) statvfsbuf.f_files);
-            printf("Free Files: %llu\n",
-                   (unsigned long long) statvfsbuf.f_ffree);
-            printf("Available Files: %llu\n",
-                   (unsigned long long) statvfsbuf.f_favail);
+               ret = smbc_statvfs(path, &statvfsbuf);
+
+               if (ret < 0)
+               {
+                       perror("fstatvfs");
+               }
+               else
+               {
+                       printf("\n");
+                       printf("Block Size: %lu\n", statvfsbuf.f_bsize);
+                       printf("Fragment Size: %lu\n", statvfsbuf.f_frsize);
+                       printf("Blocks: %llu\n",
+                              (unsigned long long) statvfsbuf.f_blocks);
+                       printf("Free Blocks: %llu\n",
+                              (unsigned long long) statvfsbuf.f_bfree);
+                       printf("Available Blocks: %llu\n",
+                              (unsigned long long) statvfsbuf.f_bavail);
+                       printf("Files : %llu\n",
+                              (unsigned long long) statvfsbuf.f_files);
+                       printf("Free Files: %llu\n",
+                              (unsigned long long) statvfsbuf.f_ffree);
+                       printf("Available Files: %llu\n",
+                              (unsigned long long) statvfsbuf.f_favail);
 #ifdef HAVE_FSID_INT
-            printf("File System ID: %lu\n",
-                   (unsigned long) statvfsbuf.f_fsid);
+                       printf("File System ID: %lu\n",
+                              (unsigned long) statvfsbuf.f_fsid);
 #endif
-            printf("\n");
+                       printf("\n");
 
-            printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
-            printf("Extended Features: ");
+                       printf("Flags: 0x%lx\n", statvfsbuf.f_flag);
+                       printf("Extended Features: ");
 
-            if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
-            {
-                printf("NO_UNIXCIFS ");
-            }
-            else
-            {
-                printf("unixcifs ");
-            }
+                       if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_NO_UNIXCIFS)
+                       {
+                               printf("NO_UNIXCIFS ");
+                       }
+                       else
+                       {
+                               printf("unixcifs ");
+                       }
 
-            if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
-            {
-                printf("CASE_INSENSITIVE ");
-            }
-            else
-            {
-                printf("case_sensitive ");
-            }
+                       if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_CASE_INSENSITIVE)
+                       {
+                               printf("CASE_INSENSITIVE ");
+                       }
+                       else
+                       {
+                               printf("case_sensitive ");
+                       }
 
-            if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
-            {
-                printf("DFS ");
-            }
-            else
-            {
-                printf("no_dfs ");
-            }
+                       if (statvfsbuf.f_flag & SMBC_VFS_FEATURE_DFS)
+                       {
+                               printf("DFS ");
+                       }
+                       else
+                       {
+                               printf("no_dfs ");
+                       }
 
-            printf("\n");
-        }
-    }
+                       printf("\n");
+               }
+       }
 
-    return 0; 
+       return 0;
 }
index 1b4298db26ceae68f311d666a513c65df8c55af9..bbc70e9bb3110b03414008e4f3b9eabc94b06683 100644 (file)
@@ -1,80 +1,80 @@
-#include <stdio.h> 
+#include <stdio.h>
 #include <unistd.h>
-#include <string.h> 
-#include <time.h> 
+#include <string.h>
+#include <time.h>
 #include <errno.h>
-#include <libsmbclient.h> 
+#include <libsmbclient.h>
 #include "get_auth_data_fn.h"
 
 
-int main(int argc, char * argv[]) 
-{ 
-    int             fd;
-    int             ret;
-    int             debug = 0;
-    int             savedErrno;
-    char            buffer[128];
-    struct stat     st; 
-    
-    if (argc != 2)
-    {
-        printf("usage: "
-               "%s smb://path/to/file\n",
-               argv[0]);
-        return 1;
-    }
+int main(int argc, char * argv[])
+{
+       int             fd;
+       int             ret;
+       int             debug = 0;
+       int             savedErrno;
+       char            buffer[128];
+       struct stat     st;
 
-    smbc_init(get_auth_data_fn, debug); 
-    
-    if ((fd = smbc_open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0)
-    {
-        perror("smbc_open");
-        return 1;
-    }
+       if (argc != 2)
+       {
+               printf("usage: "
+                      "%s smb://path/to/file\n",
+                      argv[0]);
+               return 1;
+       }
 
-    snprintf(buffer, sizeof(buffer), "%s", "Hello world.\nThis is a test.\n");
+       smbc_init(get_auth_data_fn, debug);
 
-    ret = smbc_write(fd, buffer, strlen(buffer));
-    savedErrno = errno;
-    smbc_close(fd);
+       if ((fd = smbc_open(argv[1], O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0)
+       {
+               perror("smbc_open");
+               return 1;
+       }
 
-    if (ret < 0)
-    {
-        errno = savedErrno;
-        perror("write");
-    }
+       snprintf(buffer, sizeof(buffer), "%s", "Hello world.\nThis is a test.\n");
 
-    if (smbc_stat(argv[1], &st) < 0)
-    {
-        perror("smbc_stat");
-        return 1;
-    }
-    
-    printf("Original size: %lu\n", (unsigned long) st.st_size);
-    
-    if ((fd = smbc_open(argv[1], O_WRONLY, 0)) < 0)
-    {
-        perror("smbc_open");
-        return 1;
-    }
+       ret = smbc_write(fd, buffer, strlen(buffer));
+       savedErrno = errno;
+       smbc_close(fd);
 
-    ret = smbc_ftruncate(fd, 13);
-    savedErrno = errno;
-    smbc_close(fd);
-    if (ret < 0)
-    {
-        errno = savedErrno;
-        perror("smbc_ftruncate");
-        return 1;
-    }
-    
-    if (smbc_stat(argv[1], &st) < 0)
-    {
-        perror("smbc_stat");
-        return 1;
-    }
-    
-    printf("New size: %lu\n", (unsigned long) st.st_size);
-    
-    return 0; 
+       if (ret < 0)
+       {
+               errno = savedErrno;
+               perror("write");
+       }
+
+       if (smbc_stat(argv[1], &st) < 0)
+       {
+               perror("smbc_stat");
+               return 1;
+       }
+
+       printf("Original size: %lu\n", (unsigned long) st.st_size);
+
+       if ((fd = smbc_open(argv[1], O_WRONLY, 0)) < 0)
+       {
+               perror("smbc_open");
+               return 1;
+       }
+
+       ret = smbc_ftruncate(fd, 13);
+       savedErrno = errno;
+       smbc_close(fd);
+       if (ret < 0)
+       {
+               errno = savedErrno;
+               perror("smbc_ftruncate");
+               return 1;
+       }
+
+       if (smbc_stat(argv[1], &st) < 0)
+       {
+               perror("smbc_stat");
+               return 1;
+       }
+
+       printf("New size: %lu\n", (unsigned long) st.st_size);
+
+       return 0;
 }
index 662bd866a59c8be71e70f59f648968aa353ed886..378b0e9798b44b0373a3c636e2149ae81bcf714e 100644 (file)
@@ -1,75 +1,75 @@
 #include "config.h"
-#include <stdio.h> 
+#include <stdio.h>
 #include <unistd.h>
-#include <string.h> 
-#include <time.h> 
-#include <libsmbclient.h> 
+#include <string.h>
+#include <time.h>
+#include <libsmbclient.h>
 #include "get_auth_data_fn.h"
 
 
-int main(int argc, char * argv[]) 
-{ 
-    int             debug = 0;
-    char            m_time[32];
-    char            c_time[32];
-    char            a_time[32];
-    const char *          pSmbPath = NULL;
-    time_t          t = time(NULL);
-    struct stat     st;
-    struct utimbuf  utimbuf;
-    
-    if (argc == 1)
-    {
-        pSmbPath = "smb://RANDOM/Public/small";
-    }
-    else if (argc == 2)
-    {
-        pSmbPath = argv[1];
-    }
-    else if (argc == 3)
-    {
-        pSmbPath = argv[1];
-        t = (time_t) strtol(argv[2], NULL, 10);
-    }
-    else
-    {
-        printf("usage: "
-               "%s [ smb://path/to/file [ mtime ] ]\n",
-               argv[0]);
-        return 1;
-    }
+int main(int argc, char * argv[])
+{
+       int             debug = 0;
+       char            m_time[32];
+       char            c_time[32];
+       char            a_time[32];
+       const char *          pSmbPath = NULL;
+       time_t          t = time(NULL);
+       struct stat     st;
+       struct utimbuf  utimbuf;
 
-    smbc_init(get_auth_data_fn, debug); 
-    
-    if (smbc_stat(pSmbPath, &st) < 0)
-    {
-        perror("smbc_stat");
-        return 1;
-    }
-    
-    printf("Before\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
-           (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
-           (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
-           (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
-    
-    utimbuf.actime = t;         /* unchangeable (won't change) */
-    utimbuf.modtime = t;        /* this one should succeed */
-    if (smbc_utime(pSmbPath, &utimbuf) < 0)
-    {
-        perror("smbc_utime");
-        return 1;
-    }
+       if (argc == 1)
+       {
+               pSmbPath = "smb://RANDOM/Public/small";
+       }
+       else if (argc == 2)
+       {
+               pSmbPath = argv[1];
+       }
+       else if (argc == 3)
+       {
+               pSmbPath = argv[1];
+               t = (time_t) strtol(argv[2], NULL, 10);
+       }
+       else
+       {
+               printf("usage: "
+                      "%s [ smb://path/to/file [ mtime ] ]\n",
+                      argv[0]);
+               return 1;
+       }
 
-    if (smbc_stat(pSmbPath, &st) < 0)
-    {
-        perror("smbc_stat");
-        return 1;
-    }
-    
-    printf("After\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
-           (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
-           (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
-           (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
-    
-    return 0; 
+       smbc_init(get_auth_data_fn, debug);
+
+       if (smbc_stat(pSmbPath, &st) < 0)
+       {
+               perror("smbc_stat");
+               return 1;
+       }
+
+       printf("Before\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
+              (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
+              (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
+              (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
+
+       utimbuf.actime = t;         /* unchangeable (won't change) */
+       utimbuf.modtime = t;        /* this one should succeed */
+       if (smbc_utime(pSmbPath, &utimbuf) < 0)
+       {
+               perror("smbc_utime");
+               return 1;
+       }
+
+       if (smbc_stat(pSmbPath, &st) < 0)
+       {
+               perror("smbc_stat");
+               return 1;
+       }
+
+       printf("After\n mtime:%lld/%s ctime:%lld/%s atime:%lld/%s\n",
+              (long long)st.st_mtime, ctime_r(&st.st_mtime, m_time),
+              (long long)st.st_ctime, ctime_r(&st.st_ctime, c_time),
+              (long long)st.st_atime, ctime_r(&st.st_atime, a_time));
+
+       return 0;
 }
index 1837839d298127bbe6b21710ca34d18a6b676336..0e728e058636790b9d6e97527c821ae36e0efb69 100644 (file)
@@ -1,72 +1,72 @@
 #include <sys/types.h>
-#include <stdio.h> 
+#include <stdio.h>
 #include <unistd.h>
-#include <string.h> 
-#include <time.h> 
+#include <string.h>
+#include <time.h>
 #include <errno.h>
-#include <libsmbclient.h> 
+#include <libsmbclient.h>
 #include "get_auth_data_fn.h"
 
 
-int main(int argc, char * argv[]) 
-{ 
-    int             fd;
-    int             ret;
-    int             debug = 0;
-    int             savedErrno;
-    char            buffer[2048]; 
-    char            path[2048];
-    char *          p;
-    
-    smbc_init(get_auth_data_fn, debug); 
-    
-    printf("CAUTION: This program will overwrite a file.  "
-           "Press ENTER to continue.");
-    p = fgets(buffer, sizeof(buffer), stdin);
-    if (p == NULL) {
-        fprintf(stderr, "failed to read from stdin\n");
-        return 1;
-    }
-           
+int main(int argc, char * argv[])
+{
+       int             fd;
+       int             ret;
+       int             debug = 0;
+       int             savedErrno;
+       char            buffer[2048];
+       char            path[2048];
+       char *          p;
 
-    for (;;)
-    {
-        fprintf(stdout, "\nPath: ");
-        *path = '\0';
-        p = fgets(path, sizeof(path) - 1, stdin);
-        if (p == NULL) {
-            fprintf(stderr, "failed to read from stdin\n");
-            return 1;
-        }
-        if (strlen(path) == 0)
-        {
-            return 0;
-        }
+       smbc_init(get_auth_data_fn, debug);
 
-        p = path + strlen(path) - 1;
-        if (*p == '\n')
-        {
-            *p = '\0';
-        }
-    
-        if ((fd = smbc_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0)
-        {
-            perror("smbc_open");
-            continue;
-        }
+       printf("CAUTION: This program will overwrite a file.  "
+              "Press ENTER to continue.");
+       p = fgets(buffer, sizeof(buffer), stdin);
+       if (p == NULL) {
+               fprintf(stderr, "failed to read from stdin\n");
+               return 1;
+       }
 
-        snprintf(buffer, sizeof(buffer), "%s", "Hello world\n");
 
-        ret = smbc_write(fd, buffer, strlen(buffer));
-        savedErrno = errno;
-        smbc_close(fd);
+       for (;;)
+       {
+               fprintf(stdout, "\nPath: ");
+               *path = '\0';
+               p = fgets(path, sizeof(path) - 1, stdin);
+               if (p == NULL) {
+                       fprintf(stderr, "failed to read from stdin\n");
+                       return 1;
+               }
+               if (strlen(path) == 0)
+               {
+                       return 0;
+               }
 
-        if (ret < 0)
-        {
-            errno = savedErrno;
-            perror("write");
-        }
-    }
+               p = path + strlen(path) - 1;
+               if (*p == '\n')
+               {
+                       *p = '\0';
+               }
 
-    return 0; 
+               if ((fd = smbc_open(path, O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0)
+               {
+                       perror("smbc_open");
+                       continue;
+               }
+
+               snprintf(buffer, sizeof(buffer), "%s", "Hello world\n");
+
+               ret = smbc_write(fd, buffer, strlen(buffer));
+               savedErrno = errno;
+               smbc_close(fd);
+
+               if (ret < 0)
+               {
+                       errno = savedErrno;
+                       perror("write");
+               }
+       }
+
+       return 0;
 }
index 6e34cd05627c4d47ee05b654e0329baeadf6ba4e..07847c8b4a7c40988f6c6d6bf3047217082c72a3 100644 (file)
@@ -1,21 +1,21 @@
-/* 
+/*
    Unix SMB/Netbios implementation.
    Version 2.0
    SMB client GTK+ tree-based application
    Copyright (C) Andrew Tridgell 1998
    Copyright (C) Richard Sharpe 2001
    Copyright (C) John Terpstra 2001
-   
+
    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 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    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, see <http://www.gnu.org/licenses/>.
 */
@@ -33,39 +33,39 @@ static GtkWidget *clist;
 
 struct tree_data {
 
-  guint32 type;    /* Type of tree item, an SMBC_TYPE */
-  char name[256];  /* May need to change this later   */
+       guint32 type;    /* Type of tree item, an SMBC_TYPE */
+       char name[256];  /* May need to change this later   */
 
 };
 
 void error_message(gchar *message) {
 
-  GtkWidget *dialog, *label, *okay_button;
-     
-  /* Create the widgets */
-     
-  dialog = gtk_dialog_new();
-  gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
-  label = gtk_label_new (message);
-  okay_button = gtk_button_new_with_label("Okay");
-     
-  /* 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), 
-                            GTK_OBJECT(dialog));
-  gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area),
-                    okay_button);
-
-  /* Add the label, and show everything we've added to the dialog. */
-
-  gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
-                    label);
-  gtk_widget_show_all (dialog);
+       GtkWidget *dialog, *label, *okay_button;
+
+       /* Create the widgets */
+
+       dialog = gtk_dialog_new();
+       gtk_window_set_modal(GTK_WINDOW(dialog), TRUE);
+       label = gtk_label_new (message);
+       okay_button = gtk_button_new_with_label("Okay");
+
+       /* 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),
+                                  GTK_OBJECT(dialog));
+       gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->action_area),
+                          okay_button);
+
+       /* Add the label, and show everything we've added to the dialog. */
+
+       gtk_container_add (GTK_CONTAINER (GTK_DIALOG(dialog)->vbox),
+                          label);
+       gtk_widget_show_all (dialog);
 }
 
 /*
- * We are given a widget, and we want to retrieve its URL so we 
+ * We are given a widget, and we want to retrieve its URL so we
  * can do a directory listing.
  *
  * We walk back up the tree, picking up pieces until we hit a server or
@@ -76,72 +76,72 @@ static char path_string[1024];
 
 char *get_path(GtkWidget *item)
 {
-  GtkWidget *p = item;
-  struct tree_data *pd;
-  char *comps[1024];  /* We keep pointers to the components here */
-  int i = 0, j, level,type;
+       GtkWidget *p = item;
+       struct tree_data *pd;
+       char *comps[1024];  /* We keep pointers to the components here */
+       int i = 0, j, level,type;
 
-  /* Walk back up the tree, getting the private data */
+       /* Walk back up the tree, getting the private data */
 
-  level = GTK_TREE(item->parent)->level;
+       level = GTK_TREE(item->parent)->level;
 
-  /* Pick up this item's component info */
+       /* Pick up this item's component info */
 
-  pd = (struct tree_data *)gtk_object_get_user_data(GTK_OBJECT(item));
+       pd = (struct tree_data *)gtk_object_get_user_data(GTK_OBJECT(item));
 
-  comps[i++] = pd->name;
-  type = pd->type;
+       comps[i++] = pd->name;
+       type = pd->type;
 
-  while (level > 0 && type != SMBC_SERVER && type != SMBC_WORKGROUP) {
+       while (level > 0 && type != SMBC_SERVER && type != SMBC_WORKGROUP) {
 
-    /* Find the parent and extract the data etc ... */
+               /* Find the parent and extract the data etc ... */
 
-    p = GTK_WIDGET(p->parent);    
-    p = GTK_WIDGET(GTK_TREE(p)->tree_owner);
+               p = GTK_WIDGET(p->parent);
+               p = GTK_WIDGET(GTK_TREE(p)->tree_owner);
 
-    pd = (struct tree_data *)gtk_object_get_user_data(GTK_OBJECT(p));
+               pd = (struct tree_data *)gtk_object_get_user_data(GTK_OBJECT(p));
 
-    level = GTK_TREE(item->parent)->level;
+               level = GTK_TREE(item->parent)->level;
 
-    comps[i++] = pd->name;
-    type = pd->type;
+               comps[i++] = pd->name;
+               type = pd->type;
 
-  }
+       }
 
-  /* 
-   * Got a list of comps now, should check that we did not hit a workgroup
-   * when we got other things as well ... Later
-   *
-   * Now, build the path
-   */
+       /*
+        * Got a list of comps now, should check that we did not hit a workgroup
+        * when we got other things as well ... Later
+        *
+        * Now, build the path
+        */
 
-  snprintf(path_string, sizeof(path_string), "smb:/");
+       snprintf(path_string, sizeof(path_string), "smb:/");
 
-  for (j = i - 1; j >= 0; j--) {
+       for (j = i - 1; j >= 0; j--) {
 
-    strncat(path_string, "/", sizeof(path_string) - strlen(path_string));
-    strncat(path_string, comps[j], sizeof(path_string) - strlen(path_string));
+               strncat(path_string, "/", sizeof(path_string) - strlen(path_string));
+               strncat(path_string, comps[j], sizeof(path_string) - strlen(path_string));
 
-  }
-  
-  fprintf(stdout, "Path string = %s\n", path_string);
+       }
 
-  return path_string;
+       fprintf(stdout, "Path string = %s\n", path_string);
+
+       return path_string;
 
 }
 
 struct tree_data *make_tree_data(guint32 type, const char *name)
 {
-  struct tree_data *p = (struct tree_data *)malloc(sizeof(struct tree_data));
+       struct tree_data *p = (struct tree_data *)malloc(sizeof(struct tree_data));
 
-  if (p) {
+       if (p) {
 
-    p->type = type;
-    strncpy(p->name, name, sizeof(p->name));
+               p->type = type;
+               strncpy(p->name, name, sizeof(p->name));
 
-  }
+       }
 
-  return p;
+       return p;
 
 }
 
@@ -150,157 +150,157 @@ struct tree_data *make_tree_data(guint32 type, const char *name)
 static void cb_select_child (GtkWidget *root_tree, GtkWidget *child,
                             GtkWidget *subtree)
 {
-  gint dh, err, dirlen;
-  char dirbuf[512];
-  struct smbc_dirent *dirp;
-  struct stat st1;
-  char path[1024], path1[1024];
+       gint dh, err, dirlen;
+       char dirbuf[512];
+       struct smbc_dirent *dirp;
+       struct stat st1;
+       char path[1024], path1[1024];
+
+       g_print ("select_child called for root tree %p, subtree %p, child %p\n",
+                root_tree, subtree, child);
 
-  g_print ("select_child called for root tree %p, subtree %p, child %p\n",
-          root_tree, subtree, child);
+       /* Now, figure out what it is, and display it in the clist ... */
 
-  /* Now, figure out what it is, and display it in the clist ... */
+       gtk_clist_clear(GTK_CLIST(clist));  /* Clear the CLIST */
 
-  gtk_clist_clear(GTK_CLIST(clist));  /* Clear the CLIST */
+       /* Now, get the private data for the subtree */
 
-  /* Now, get the private data for the subtree */
+       strncpy(path, get_path(child), 1024);
 
-  strncpy(path, get_path(child), 1024);
+       if ((dh = smbc_opendir(path)) < 0) { /* Handle error */
 
-  if ((dh = smbc_opendir(path)) < 0) { /* Handle error */
+               g_print("cb_select_child: Could not open dir %s, %s\n", path,
+                       strerror(errno));
 
-    g_print("cb_select_child: Could not open dir %s, %s\n", path,
-           strerror(errno));
+               gtk_main_quit();
 
-    gtk_main_quit();
+               return;
 
-    return;
+       }
 
-  }
+       while ((err = smbc_getdents(dh, (struct smbc_dirent *)dirbuf,
+                                   sizeof(dirbuf))) != 0) {
 
-  while ((err = smbc_getdents(dh, (struct smbc_dirent *)dirbuf,
-                             sizeof(dirbuf))) != 0) {
+               if (err < 0) {
 
-    if (err < 0) {
+                       g_print("cb_select_child: Could not read dir %s, %s\n", path,
+                               strerror(errno));
 
-      g_print("cb_select_child: Could not read dir %s, %s\n", path,
-             strerror(errno));
+                       gtk_main_quit();
 
-      gtk_main_quit();
+                       return;
 
-      return;
+               }
 
-    }
+               dirp = (struct smbc_dirent *)dirbuf;
 
-    dirp = (struct smbc_dirent *)dirbuf;
+               while (err > 0) {
+                       gchar col1[128], col2[128], col3[128], col4[128];
+                       gchar *rowdata[4] = {col1, col2, col3, col4};
 
-    while (err > 0) {
-      gchar col1[128], col2[128], col3[128], col4[128];
-      gchar *rowdata[4] = {col1, col2, col3, col4};
+                       dirlen = dirp->dirlen;
 
-      dirlen = dirp->dirlen;
+                       /* Format each of the items ... */
 
-      /* Format each of the items ... */
+                       strncpy(col1, dirp->name, 128);
 
-      strncpy(col1, dirp->name, 128);
+                       col2[0] = col3[0] = col4[0] = (char)0;
 
-      col2[0] = col3[0] = col4[0] = (char)0;
+                       switch (dirp->smbc_type) {
 
-      switch (dirp->smbc_type) {
+                       case SMBC_WORKGROUP:
 
-      case SMBC_WORKGROUP:
+                               break;
 
-       break;
+                       case SMBC_SERVER:
 
-      case SMBC_SERVER:
+                               strncpy(col2, (dirp->comment?dirp->comment:""), 128);
 
-       strncpy(col2, (dirp->comment?dirp->comment:""), 128);
+                               break;
 
-       break;
+                       case SMBC_FILE_SHARE:
 
-      case SMBC_FILE_SHARE:
+                               strncpy(col2, (dirp->comment?dirp->comment:""), 128);
 
-       strncpy(col2, (dirp->comment?dirp->comment:""), 128);
+                               break;
 
-       break;
+                       case SMBC_PRINTER_SHARE:
 
-      case SMBC_PRINTER_SHARE:
+                               strncpy(col2, (dirp->comment?dirp->comment:""), 128);
+                               break;
 
-       strncpy(col2, (dirp->comment?dirp->comment:""), 128);
-       break;
+                       case SMBC_COMMS_SHARE:
 
-      case SMBC_COMMS_SHARE:
+                               break;
 
-       break;
+                       case SMBC_IPC_SHARE:
 
-      case SMBC_IPC_SHARE:
+                               break;
 
-       break;
+                       case SMBC_DIR:
+                       case SMBC_FILE:
 
-      case SMBC_DIR:
-      case SMBC_FILE:
+                               /* Get stats on the file/dir and see what we have */
 
-       /* Get stats on the file/dir and see what we have */
+                               if ((strcmp(dirp->name, ".") != 0) &&
+                                   (strcmp(dirp->name, "..") != 0)) {
 
-       if ((strcmp(dirp->name, ".") != 0) &&
-           (strcmp(dirp->name, "..") != 0)) {
+                                       strncpy(path1, path, sizeof(path1));
+                                       strncat(path1, "/", sizeof(path) - strlen(path));
+                                       strncat(path1, dirp->name, sizeof(path) - strlen(path));
 
-         strncpy(path1, path, sizeof(path1));
-         strncat(path1, "/", sizeof(path) - strlen(path));
-         strncat(path1, dirp->name, sizeof(path) - strlen(path));
+                                       if (smbc_stat(path1, &st1) < 0) {
 
-         if (smbc_stat(path1, &st1) < 0) {
-           
-           if (errno != EBUSY) {
-             
-             g_print("cb_select_child: Could not stat file %s, %s\n", path1, 
-                     strerror(errno));
-           
-             gtk_main_quit();
+                                               if (errno != EBUSY) {
 
-             return;
+                                                       g_print("cb_select_child: Could not stat file %s, %s\n", path1,
+                                                               strerror(errno));
 
-           }
-           else {
+                                                       gtk_main_quit();
 
-             strncpy(col2, "Device or resource busy", sizeof(col2));
+                                                       return;
 
-           }
-         }
-         else {
-           /* Now format each of the relevant things ... */
+                                               }
+                                               else {
 
-           snprintf(col2, sizeof(col2), "%c%c%c%c%c%c%c%c%c(%0X)",
-                    (st1.st_mode&S_IRUSR?'r':'-'),
-                    (st1.st_mode&S_IWUSR?'w':'-'),
-                    (st1.st_mode&S_IXUSR?'x':'-'),
-                    (st1.st_mode&S_IRGRP?'r':'-'),
-                    (st1.st_mode&S_IWGRP?'w':'-'),
-                    (st1.st_mode&S_IXGRP?'x':'-'),
-                    (st1.st_mode&S_IROTH?'r':'-'),
-                    (st1.st_mode&S_IWOTH?'w':'-'),
-                    (st1.st_mode&S_IXOTH?'x':'-'),
-                    st1.st_mode); 
-           snprintf(col3, sizeof(col3), "%u", st1.st_size);
-           snprintf(col4, sizeof(col4), "%s", ctime(&st1.st_mtime));
-         }
-       }
+                                                       strncpy(col2, "Device or resource busy", sizeof(col2));
+
+                                               }
+                                       }
+                                       else {
+                                               /* Now format each of the relevant things ... */
+
+                                               snprintf(col2, sizeof(col2), "%c%c%c%c%c%c%c%c%c(%0X)",
+                                                        (st1.st_mode&S_IRUSR?'r':'-'),
+                                                        (st1.st_mode&S_IWUSR?'w':'-'),
+                                                        (st1.st_mode&S_IXUSR?'x':'-'),
+                                                        (st1.st_mode&S_IRGRP?'r':'-'),
+                                                        (st1.st_mode&S_IWGRP?'w':'-'),
+                                                        (st1.st_mode&S_IXGRP?'x':'-'),
+                                                        (st1.st_mode&S_IROTH?'r':'-'),
+                                                        (st1.st_mode&S_IWOTH?'w':'-'),
+                                                        (st1.st_mode&S_IXOTH?'x':'-'),
+                                                        st1.st_mode);
+                                               snprintf(col3, sizeof(col3), "%u", st1.st_size);
+                                               snprintf(col4, sizeof(col4), "%s", ctime(&st1.st_mtime));
+                                       }
+                               }
 
-       break;
+                               break;
 
-      default:
+                       default:
 
-       break;
-      }
+                               break;
+                       }
 
-      gtk_clist_append(GTK_CLIST(clist), rowdata);
+                       gtk_clist_append(GTK_CLIST(clist), rowdata);
 
-      dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
-      err -= dirlen;
+                       dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
+                       err -= dirlen;
 
-    }
+               }
 
-  }
+       }
 
 }
 
@@ -309,174 +309,174 @@ static void cb_unselect_child( GtkWidget *root_tree,
                                GtkWidget *child,
                                GtkWidget *subtree )
 {
-  g_print ("unselect_child called for root tree %p, subtree %p, child %p\n",
-          root_tree, subtree, child);
+       g_print ("unselect_child called for root tree %p, subtree %p, child %p\n",
+                root_tree, subtree, child);
 }
 
 /* for all the GtkItem:: and GtkTreeItem:: signals */
 static void cb_itemsignal( GtkWidget *item,
                            gchar     *signame )
 {
-  GtkWidget *real_tree, *aitem, *subtree;
-  gchar *name;
-  GtkLabel *label;
-  gint dh, err, dirlen, level;
-  char dirbuf[512];
-  struct smbc_dirent *dirp;
-  
-  label = GTK_LABEL (GTK_BIN (item)->child);
-  /* Get the text of the label */
-  gtk_label_get (label, &name);
+       GtkWidget *real_tree, *aitem, *subtree;
+       gchar *name;
+       GtkLabel *label;
+       gint dh, err, dirlen, level;
+       char dirbuf[512];
+       struct smbc_dirent *dirp;
 
-  level = GTK_TREE(item->parent)->level;
+       label = GTK_LABEL (GTK_BIN (item)->child);
+       /* Get the text of the label */
+       gtk_label_get (label, &name);
 
-  /* Get the level of the tree which the item is in */
-  g_print ("%s called for item %s->%p, level %d\n", signame, name,
-          item, GTK_TREE (item->parent)->level);
+       level = GTK_TREE(item->parent)->level;
 
-  real_tree = GTK_TREE_ITEM_SUBTREE(item);  /* Get the subtree */
+       /* Get the level of the tree which the item is in */
+       g_print ("%s called for item %s->%p, level %d\n", signame, name,
+                item, GTK_TREE (item->parent)->level);
 
-  if (strncmp(signame, "expand", 6) == 0) { /* Expand called */
-    char server[128];
+       real_tree = GTK_TREE_ITEM_SUBTREE(item);  /* Get the subtree */
 
-    if ((dh = smbc_opendir(get_path(item))) < 0) { /* Handle error */
-      gchar errmsg[256];
+       if (strncmp(signame, "expand", 6) == 0) { /* Expand called */
+               char server[128];
 
-      g_print("cb_itemsignal: Could not open dir %s, %s\n", get_path(item), 
-             strerror(errno));
+               if ((dh = smbc_opendir(get_path(item))) < 0) { /* Handle error */
+                       gchar errmsg[256];
 
-      snprintf(errmsg, sizeof(errmsg), "cb_itemsignal: Could not open dir %s, %s\n", get_path(item), strerror(errno));
+                       g_print("cb_itemsignal: Could not open dir %s, %s\n", get_path(item),
+                               strerror(errno));
 
-      error_message(errmsg);
+                       snprintf(errmsg, sizeof(errmsg), "cb_itemsignal: Could not open dir %s, %s\n", get_path(item), strerror(errno));
 
-      /*      gtk_main_quit();*/
+                       error_message(errmsg);
 
-      return;
+                       /*      gtk_main_quit();*/
 
-    }
+                       return;
 
-    while ((err = smbc_getdents(dh, (struct smbc_dirent *)dirbuf, 
-                               sizeof(dirbuf))) != 0) {
+               }
 
-      if (err < 0) { /* An error, report it */
-       gchar errmsg[256];
+               while ((err = smbc_getdents(dh, (struct smbc_dirent *)dirbuf,
+                                           sizeof(dirbuf))) != 0) {
 
-       g_print("cb_itemsignal: Could not read dir smbc://, %s\n",
-               strerror(errno));
+                       if (err < 0) { /* An error, report it */
+                               gchar errmsg[256];
 
-       snprintf(errmsg, sizeof(errmsg), "cb_itemsignal: Could not read dir smbc://, %s\n", strerror(errno));
+                               g_print("cb_itemsignal: Could not read dir smbc://, %s\n",
+                                       strerror(errno));
 
-       error_message(errmsg);
+                               snprintf(errmsg, sizeof(errmsg), "cb_itemsignal: Could not read dir smbc://, %s\n", strerror(errno));
 
-       /*      gtk_main_quit();*/
+                               error_message(errmsg);
 
-       return;
+                               /*      gtk_main_quit();*/
 
-      }
+                               return;
 
-      dirp = (struct smbc_dirent *)dirbuf;
+                       }
 
-      while (err > 0) {
-       struct tree_data *my_data;
+                       dirp = (struct smbc_dirent *)dirbuf;
 
-       dirlen = dirp->dirlen;
+                       while (err > 0) {
+                               struct tree_data *my_data;
 
-       my_data = make_tree_data(dirp->smbc_type, dirp->name);
+                               dirlen = dirp->dirlen;
 
-       if (!my_data) {
+                               my_data = make_tree_data(dirp->smbc_type, dirp->name);
 
-         g_print("Could not allocate space for tree_data: %s\n",
-                 dirp->name);
+                               if (!my_data) {
 
-         gtk_main_quit();
-         return;
+                                       g_print("Could not allocate space for tree_data: %s\n",
+                                               dirp->name);
 
-       }
+                                       gtk_main_quit();
+                                       return;
 
-       aitem = gtk_tree_item_new_with_label(dirp->name);
+                               }
 
-       /* Connect all GtkItem:: and GtkTreeItem:: signals */
-       gtk_signal_connect (GTK_OBJECT(aitem), "select",
-                           GTK_SIGNAL_FUNC(cb_itemsignal), "select");
-       gtk_signal_connect (GTK_OBJECT(aitem), "deselect",
-                           GTK_SIGNAL_FUNC(cb_itemsignal), "deselect");
-       gtk_signal_connect (GTK_OBJECT(aitem), "toggle",
-                           GTK_SIGNAL_FUNC(cb_itemsignal), "toggle");
-       gtk_signal_connect (GTK_OBJECT(aitem), "expand",
-                           GTK_SIGNAL_FUNC(cb_itemsignal), "expand");
-       gtk_signal_connect (GTK_OBJECT(aitem), "collapse",
-                           GTK_SIGNAL_FUNC(cb_itemsignal), "collapse");
-       /* Add it to the parent tree */
-       gtk_tree_append (GTK_TREE(real_tree), aitem);
+                               aitem = gtk_tree_item_new_with_label(dirp->name);
 
-       gtk_widget_show (aitem);
+                               /* Connect all GtkItem:: and GtkTreeItem:: signals */
+                               gtk_signal_connect (GTK_OBJECT(aitem), "select",
+                                                   GTK_SIGNAL_FUNC(cb_itemsignal), "select");
+                               gtk_signal_connect (GTK_OBJECT(aitem), "deselect",
+                                                   GTK_SIGNAL_FUNC(cb_itemsignal), "deselect");
+                               gtk_signal_connect (GTK_OBJECT(aitem), "toggle",
+                                                   GTK_SIGNAL_FUNC(cb_itemsignal), "toggle");
+                               gtk_signal_connect (GTK_OBJECT(aitem), "expand",
+                                                   GTK_SIGNAL_FUNC(cb_itemsignal), "expand");
+                               gtk_signal_connect (GTK_OBJECT(aitem), "collapse",
+                                                   GTK_SIGNAL_FUNC(cb_itemsignal), "collapse");
+                               /* Add it to the parent tree */
+                               gtk_tree_append (GTK_TREE(real_tree), aitem);
 
-       gtk_object_set_user_data(GTK_OBJECT(aitem), (gpointer)my_data);
+                               gtk_widget_show (aitem);
 
-       fprintf(stdout, "Added: %s, len: %u\n", dirp->name, dirlen);
+                               gtk_object_set_user_data(GTK_OBJECT(aitem), (gpointer)my_data);
 
-       if (dirp->smbc_type != SMBC_FILE &&
-           dirp->smbc_type != SMBC_IPC_SHARE &&
-           (strcmp(dirp->name, ".") != 0) && 
-           (strcmp(dirp->name, "..") !=0)){
-         
-         subtree = gtk_tree_new();
-         gtk_tree_item_set_subtree(GTK_TREE_ITEM(aitem), subtree);
+                               fprintf(stdout, "Added: %s, len: %u\n", dirp->name, dirlen);
 
-         gtk_signal_connect(GTK_OBJECT(subtree), "select_child",
-                            GTK_SIGNAL_FUNC(cb_select_child), real_tree);
-         gtk_signal_connect(GTK_OBJECT(subtree), "unselect_child",
-                            GTK_SIGNAL_FUNC(cb_unselect_child), real_tree);
+                               if (dirp->smbc_type != SMBC_FILE &&
+                                   dirp->smbc_type != SMBC_IPC_SHARE &&
+                                   (strcmp(dirp->name, ".") != 0) &&
+                                   (strcmp(dirp->name, "..") !=0)){
 
-       }
+                                       subtree = gtk_tree_new();
+                                       gtk_tree_item_set_subtree(GTK_TREE_ITEM(aitem), subtree);
 
-        dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
-       err -= dirlen;
+                                       gtk_signal_connect(GTK_OBJECT(subtree), "select_child",
+                                                          GTK_SIGNAL_FUNC(cb_select_child), real_tree);
+                                       gtk_signal_connect(GTK_OBJECT(subtree), "unselect_child",
+                                                          GTK_SIGNAL_FUNC(cb_unselect_child), real_tree);
 
-      }
+                               }
 
-    }
+                               dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
+                               err -= dirlen;
 
-    smbc_closedir(dh);   
+                       }
 
-  }
-  else if (strncmp(signame, "collapse", 8) == 0) {
-    GtkWidget *subtree = gtk_tree_new();
+               }
 
-    gtk_tree_remove_items(GTK_TREE(real_tree), GTK_TREE(real_tree)->children);
+               smbc_closedir(dh);
 
-    gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);
+       }
+       else if (strncmp(signame, "collapse", 8) == 0) {
+               GtkWidget *subtree = gtk_tree_new();
+
+               gtk_tree_remove_items(GTK_TREE(real_tree), GTK_TREE(real_tree)->children);
 
-    gtk_signal_connect (GTK_OBJECT(subtree), "select_child",
-                       GTK_SIGNAL_FUNC(cb_select_child), real_tree);
-    gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child",
-                       GTK_SIGNAL_FUNC(cb_unselect_child), real_tree);
+               gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);
 
-  }
+               gtk_signal_connect (GTK_OBJECT(subtree), "select_child",
+                                   GTK_SIGNAL_FUNC(cb_select_child), real_tree);
+               gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child",
+                                   GTK_SIGNAL_FUNC(cb_unselect_child), real_tree);
+
+       }
 
 }
 
 static void cb_selection_changed( GtkWidget *tree )
 {
-  GList *i;
-  
-  g_print ("selection_change called for tree %p\n", tree);
-  g_print ("selected objects are:\n");
-
-  i = GTK_TREE_SELECTION(tree);
-  while (i){
-    gchar *name;
-    GtkLabel *label;
-    GtkWidget *item;
-
-    /* Get a GtkWidget pointer from the list node */
-    item = GTK_WIDGET (i->data);
-    label = GTK_LABEL (GTK_BIN (item)->child);
-    gtk_label_get (label, &name);
-    g_print ("\t%s on level %d\n", name, GTK_TREE
-            (item->parent)->level);
-    i = i->next;
-  }
+       GList *i;
+
+       g_print ("selection_change called for tree %p\n", tree);
+       g_print ("selected objects are:\n");
+
+       i = GTK_TREE_SELECTION(tree);
+       while (i){
+               gchar *name;
+               GtkLabel *label;
+               GtkWidget *item;
+
+               /* Get a GtkWidget pointer from the list node */
+               item = GTK_WIDGET (i->data);
+               label = GTK_LABEL (GTK_BIN (item)->child);
+               gtk_label_get (label, &name);
+               g_print ("\t%s on level %d\n", name, GTK_TREE
+                        (item->parent)->level);
+               i = i->next;
+       }
 }
 
 /*
@@ -484,331 +484,329 @@ static void cb_selection_changed( GtkWidget *tree )
  */
 static void cb_wholenet(GtkWidget *item, gchar *signame)
 {
-  GtkWidget *real_tree, *aitem, *subtree;
-  gchar *name;
-  GtkLabel *label;
-  gint dh, err, dirlen;
-  char dirbuf[512];
-  struct smbc_dirent *dirp;
-  
-  label = GTK_LABEL (GTK_BIN (item)->child);
-  gtk_label_get (label, &name);
-  g_print ("%s called for item %s->%p, level %d\n", signame, name,
-          item, GTK_TREE (item->parent)->level);
+       GtkWidget *real_tree, *aitem, *subtree;
+       gchar *name;
+       GtkLabel *label;
+       gint dh, err, dirlen;
+       char dirbuf[512];
+       struct smbc_dirent *dirp;
 
-  real_tree = GTK_TREE_ITEM_SUBTREE(item);  /* Get the subtree */
+       label = GTK_LABEL (GTK_BIN (item)->child);
+       gtk_label_get (label, &name);
+       g_print ("%s called for item %s->%p, level %d\n", signame, name,
+                item, GTK_TREE (item->parent)->level);
 
-  if (strncmp(signame, "expand", 6) == 0) { /* Expand called */
+       real_tree = GTK_TREE_ITEM_SUBTREE(item);  /* Get the subtree */
 
-    if ((dh = smbc_opendir("smb://")) < 0) { /* Handle error */
+       if (strncmp(signame, "expand", 6) == 0) { /* Expand called */
 
-      g_print("cb_wholenet: Could not open dir smbc://, %s\n",
-             strerror(errno));
+               if ((dh = smbc_opendir("smb://")) < 0) { /* Handle error */
 
-      gtk_main_quit();
+                       g_print("cb_wholenet: Could not open dir smbc://, %s\n",
+                               strerror(errno));
 
-      return;
+                       gtk_main_quit();
 
-    }
+                       return;
 
-    while ((err = smbc_getdents(dh, (struct smbc_dirent *)dirbuf, 
-                               sizeof(dirbuf))) != 0) {
+               }
 
-      if (err < 0) { /* An error, report it */
+               while ((err = smbc_getdents(dh, (struct smbc_dirent *)dirbuf,
+                                           sizeof(dirbuf))) != 0) {
 
-       g_print("cb_wholenet: Could not read dir smbc://, %s\n",
-               strerror(errno));
+                       if (err < 0) { /* An error, report it */
 
-       gtk_main_quit();
+                               g_print("cb_wholenet: Could not read dir smbc://, %s\n",
+                                       strerror(errno));
 
-       return;
+                               gtk_main_quit();
 
-      }
+                               return;
 
-      dirp = (struct smbc_dirent *)dirbuf;
+                       }
 
-      while (err > 0) {
-       struct tree_data *my_data;
+                       dirp = (struct smbc_dirent *)dirbuf;
 
-       dirlen = dirp->dirlen;
+                       while (err > 0) {
+                               struct tree_data *my_data;
 
-       my_data = make_tree_data(dirp->smbc_type, dirp->name);
+                               dirlen = dirp->dirlen;
 
-       aitem = gtk_tree_item_new_with_label(dirp->name);
+                               my_data = make_tree_data(dirp->smbc_type, dirp->name);
 
-       /* Connect all GtkItem:: and GtkTreeItem:: signals */
-       gtk_signal_connect (GTK_OBJECT(aitem), "select",
-                           GTK_SIGNAL_FUNC(cb_itemsignal), "select");
-       gtk_signal_connect (GTK_OBJECT(aitem), "deselect",
-                           GTK_SIGNAL_FUNC(cb_itemsignal), "deselect");
-       gtk_signal_connect (GTK_OBJECT(aitem), "toggle",
-                           GTK_SIGNAL_FUNC(cb_itemsignal), "toggle");
-       gtk_signal_connect (GTK_OBJECT(aitem), "expand",
-                           GTK_SIGNAL_FUNC(cb_itemsignal), "expand");
-       gtk_signal_connect (GTK_OBJECT(aitem), "collapse",
-                           GTK_SIGNAL_FUNC(cb_itemsignal), "collapse");
+                               aitem = gtk_tree_item_new_with_label(dirp->name);
 
-       gtk_tree_append (GTK_TREE(real_tree), aitem);
-       /* Show it - this can be done at any time */
-       gtk_widget_show (aitem);
+                               /* Connect all GtkItem:: and GtkTreeItem:: signals */
+                               gtk_signal_connect (GTK_OBJECT(aitem), "select",
+                                                   GTK_SIGNAL_FUNC(cb_itemsignal), "select");
+                               gtk_signal_connect (GTK_OBJECT(aitem), "deselect",
+                                                   GTK_SIGNAL_FUNC(cb_itemsignal), "deselect");
+                               gtk_signal_connect (GTK_OBJECT(aitem), "toggle",
+                                                   GTK_SIGNAL_FUNC(cb_itemsignal), "toggle");
+                               gtk_signal_connect (GTK_OBJECT(aitem), "expand",
+                                                   GTK_SIGNAL_FUNC(cb_itemsignal), "expand");
+                               gtk_signal_connect (GTK_OBJECT(aitem), "collapse",
+                                                   GTK_SIGNAL_FUNC(cb_itemsignal), "collapse");
 
-       gtk_object_set_user_data(GTK_OBJECT(aitem), (gpointer)my_data);
+                               gtk_tree_append (GTK_TREE(real_tree), aitem);
+                               /* Show it - this can be done at any time */
+                               gtk_widget_show (aitem);
 
-       fprintf(stdout, "Added: %s, len: %u\n", dirp->name, dirlen);
+                               gtk_object_set_user_data(GTK_OBJECT(aitem), (gpointer)my_data);
 
-       subtree = gtk_tree_new();
+                               fprintf(stdout, "Added: %s, len: %u\n", dirp->name, dirlen);
 
-       gtk_tree_item_set_subtree(GTK_TREE_ITEM(aitem), subtree);
+                               subtree = gtk_tree_new();
 
-       gtk_signal_connect(GTK_OBJECT(subtree), "select_child",
-                          GTK_SIGNAL_FUNC(cb_select_child), real_tree);
-       gtk_signal_connect(GTK_OBJECT(subtree), "unselect_child",
-                          GTK_SIGNAL_FUNC(cb_unselect_child), real_tree);
+                               gtk_tree_item_set_subtree(GTK_TREE_ITEM(aitem), subtree);
 
-        dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
-       err -= dirlen;
+                               gtk_signal_connect(GTK_OBJECT(subtree), "select_child",
+                                                  GTK_SIGNAL_FUNC(cb_select_child), real_tree);
+                               gtk_signal_connect(GTK_OBJECT(subtree), "unselect_child",
+                                                  GTK_SIGNAL_FUNC(cb_unselect_child), real_tree);
 
-      }
+                               dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
+                               err -= dirlen;
 
-    }
+                       }
 
-    smbc_closedir(dh);   
+               }
 
-  }
-  else { /* Must be collapse ... FIXME ... */
-    GtkWidget *subtree = gtk_tree_new();
+               smbc_closedir(dh);
 
-    gtk_tree_remove_items(GTK_TREE(real_tree), GTK_TREE(real_tree)->children);
+       }
+       else { /* Must be collapse ... FIXME ... */
+               GtkWidget *subtree = gtk_tree_new();
 
-    gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);
+               gtk_tree_remove_items(GTK_TREE(real_tree), GTK_TREE(real_tree)->children);
 
-    gtk_signal_connect (GTK_OBJECT(subtree), "select_child",
-                       GTK_SIGNAL_FUNC(cb_select_child), real_tree);
-    gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child",
-                       GTK_SIGNAL_FUNC(cb_unselect_child), real_tree);
+               gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);
 
+               gtk_signal_connect (GTK_OBJECT(subtree), "select_child",
+                                   GTK_SIGNAL_FUNC(cb_select_child), real_tree);
+               gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child",
+                                   GTK_SIGNAL_FUNC(cb_unselect_child), real_tree);
 
-  }
+
+       }
 
 }
 
 /* Should put up a dialog box to ask the user for username and password */
 
-static void 
+static void
 auth_fn(const char *server, const char *share,
        char *workgroup, int wgmaxlen, char *username, int unmaxlen,
        char *password, int pwmaxlen)
 {
-
-   strncpy(username, "test", unmaxlen);
-   strncpy(password, "test", pwmaxlen);
-
+       strncpy(username, "test", unmaxlen);
+       strncpy(password, "test", pwmaxlen);
 }
 
 static char *col_titles[] = {
-  "Name", "Attributes", "Size", "Modification Date",
+       "Name", "Attributes", "Size", "Modification Date",
 };
 
 int main( int   argc,
           char *argv[] )
 {
-  GtkWidget *window, *scrolled_win, *scrolled_win2, *tree;
-  GtkWidget *subtree, *item, *main_hbox, *r_pane, *l_pane;
-  gint err, dh;
-  gint i;
-  char dirbuf[512];
-  struct smbc_dirent *dirp;
+       GtkWidget *window, *scrolled_win, *scrolled_win2, *tree;
+       GtkWidget *subtree, *item, *main_hbox, *r_pane, *l_pane;
+       gint err, dh;
+       gint i;
+       char dirbuf[512];
+       struct smbc_dirent *dirp;
 
-  gtk_init (&argc, &argv);
-
-  /* Init the smbclient library */
-
-  err = smbc_init(auth_fn, 10);
-
-  /* Print an error response ... */
-
-  if (err < 0) {
-
-    fprintf(stderr, "smbc_init returned %s (%i)\nDo you have a ~/.smb/smb.conf file?\n", strerror(errno), errno);
-    exit(1);
-
-  }
-
-  /* a generic toplevel window */
-  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
-  gtk_widget_set_name(window, "main browser window");
-  gtk_signal_connect (GTK_OBJECT(window), "delete_event",
-                     GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
-  gtk_window_set_title(GTK_WINDOW(window), "The Linux Windows Network Browser");
-  gtk_widget_set_usize(GTK_WIDGET(window), 750, -1);
-  gtk_container_set_border_width (GTK_CONTAINER(window), 5);
-
-  gtk_widget_show (window);
-
-  /* A container for the two panes ... */
-
-  main_hbox = gtk_hbox_new(FALSE, 1);
-  gtk_container_border_width(GTK_CONTAINER(main_hbox), 1);
-  gtk_container_add(GTK_CONTAINER(window), main_hbox);
-
-  gtk_widget_show(main_hbox);
-
-  l_pane = gtk_hpaned_new();
-  gtk_paned_gutter_size(GTK_PANED(l_pane), (GTK_PANED(l_pane))->handle_size);
-  r_pane = gtk_hpaned_new();
-  gtk_paned_gutter_size(GTK_PANED(r_pane), (GTK_PANED(r_pane))->handle_size);
-  gtk_container_add(GTK_CONTAINER(main_hbox), l_pane);
-  gtk_widget_show(l_pane);
+       gtk_init (&argc, &argv);
 
-  /* A generic scrolled window */
-  scrolled_win = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
-                                 GTK_POLICY_AUTOMATIC,
-                                 GTK_POLICY_AUTOMATIC);
-  gtk_widget_set_usize (scrolled_win, 150, 200);
-  gtk_container_add (GTK_CONTAINER(l_pane), scrolled_win);
-  gtk_widget_show (scrolled_win);
+       /* Init the smbclient library */
 
-  /* Another generic scrolled window */
-  scrolled_win2 = gtk_scrolled_window_new (NULL, NULL);
-  gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win2),
-                                 GTK_POLICY_AUTOMATIC,
-                                 GTK_POLICY_AUTOMATIC);
-  gtk_widget_set_usize (scrolled_win2, 150, 200);
-  gtk_paned_add2 (GTK_PANED(l_pane), scrolled_win2);
-  gtk_widget_show (scrolled_win2);
-  
-  /* Create the root tree */
-  tree = gtk_tree_new();
-  g_print ("root tree is %p\n", tree);
-  /* connect all GtkTree:: signals */
-  gtk_signal_connect (GTK_OBJECT(tree), "select_child",
-                     GTK_SIGNAL_FUNC(cb_select_child), tree);
-  gtk_signal_connect (GTK_OBJECT(tree), "unselect_child",
-                     GTK_SIGNAL_FUNC(cb_unselect_child), tree);
-  gtk_signal_connect (GTK_OBJECT(tree), "selection_changed",
-                     GTK_SIGNAL_FUNC(cb_selection_changed), tree);
-  /* Add it to the scrolled window */
-  gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrolled_win),
-                                         tree);
-  /* Set the selection mode */
-  gtk_tree_set_selection_mode (GTK_TREE(tree),
-                              GTK_SELECTION_MULTIPLE);
-  /* Show it */
-  gtk_widget_show (tree);
-
-  /* Now, create a clist and attach it to the second pane */
+       err = smbc_init(auth_fn, 10);
 
-  clist = gtk_clist_new_with_titles(4, col_titles);
+       /* Print an error response ... */
 
-  gtk_container_add (GTK_CONTAINER(scrolled_win2), clist);
+       if (err < 0) {
 
-  gtk_widget_show(clist);
+               fprintf(stderr, "smbc_init returned %s (%i)\nDo you have a ~/.smb/smb.conf file?\n", strerror(errno), errno);
+               exit(1);
 
-  /* Now, build the top level display ... */
+       }
 
-  if ((dh = smbc_opendir("smb://")) < 0) {
+       /* a generic toplevel window */
+       window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+       gtk_widget_set_name(window, "main browser window");
+       gtk_signal_connect (GTK_OBJECT(window), "delete_event",
+                           GTK_SIGNAL_FUNC (gtk_main_quit), NULL);
+       gtk_window_set_title(GTK_WINDOW(window), "The Linux Windows Network Browser");
+       gtk_widget_set_usize(GTK_WIDGET(window), 750, -1);
+       gtk_container_set_border_width (GTK_CONTAINER(window), 5);
+
+       gtk_widget_show (window);
+
+       /* A container for the two panes ... */
+
+       main_hbox = gtk_hbox_new(FALSE, 1);
+       gtk_container_border_width(GTK_CONTAINER(main_hbox), 1);
+       gtk_container_add(GTK_CONTAINER(window), main_hbox);
+
+       gtk_widget_show(main_hbox);
+
+       l_pane = gtk_hpaned_new();
+       gtk_paned_gutter_size(GTK_PANED(l_pane), (GTK_PANED(l_pane))->handle_size);
+       r_pane = gtk_hpaned_new();
+       gtk_paned_gutter_size(GTK_PANED(r_pane), (GTK_PANED(r_pane))->handle_size);
+       gtk_container_add(GTK_CONTAINER(main_hbox), l_pane);
+       gtk_widget_show(l_pane);
+
+       /* A generic scrolled window */
+       scrolled_win = gtk_scrolled_window_new (NULL, NULL);
+       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win),
+                                       GTK_POLICY_AUTOMATIC,
+                                       GTK_POLICY_AUTOMATIC);
+       gtk_widget_set_usize (scrolled_win, 150, 200);
+       gtk_container_add (GTK_CONTAINER(l_pane), scrolled_win);
+       gtk_widget_show (scrolled_win);
+
+       /* Another generic scrolled window */
+       scrolled_win2 = gtk_scrolled_window_new (NULL, NULL);
+       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled_win2),
+                                       GTK_POLICY_AUTOMATIC,
+                                       GTK_POLICY_AUTOMATIC);
+       gtk_widget_set_usize (scrolled_win2, 150, 200);
+       gtk_paned_add2 (GTK_PANED(l_pane), scrolled_win2);
+       gtk_widget_show (scrolled_win2);
+
+       /* Create the root tree */
+       tree = gtk_tree_new();
+       g_print ("root tree is %p\n", tree);
+       /* connect all GtkTree:: signals */
+       gtk_signal_connect (GTK_OBJECT(tree), "select_child",
+                           GTK_SIGNAL_FUNC(cb_select_child), tree);
+       gtk_signal_connect (GTK_OBJECT(tree), "unselect_child",
+                           GTK_SIGNAL_FUNC(cb_unselect_child), tree);
+       gtk_signal_connect (GTK_OBJECT(tree), "selection_changed",
+                           GTK_SIGNAL_FUNC(cb_selection_changed), tree);
+       /* Add it to the scrolled window */
+       gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW(scrolled_win),
+                                              tree);
+       /* Set the selection mode */
+       gtk_tree_set_selection_mode (GTK_TREE(tree),
+                                    GTK_SELECTION_MULTIPLE);
+       /* Show it */
+       gtk_widget_show (tree);
+
+       /* Now, create a clist and attach it to the second pane */
+
+       clist = gtk_clist_new_with_titles(4, col_titles);
+
+       gtk_container_add (GTK_CONTAINER(scrolled_win2), clist);
+
+       gtk_widget_show(clist);
+
+       /* Now, build the top level display ... */
+
+       if ((dh = smbc_opendir("smb://")) < 0) {
+
+               fprintf(stderr, "Could not list workgroups: smb://: %s\n",
+                       strerror(errno));
+
+               exit(1);
 
-    fprintf(stderr, "Could not list workgroups: smb://: %s\n",
-           strerror(errno));
+       }
 
-    exit(1);
+       /* Create a tree item for Whole Network */
 
-  }
+       item = gtk_tree_item_new_with_label ("Whole Network");
+       /* Connect all GtkItem:: and GtkTreeItem:: signals */
+       gtk_signal_connect (GTK_OBJECT(item), "select",
+                           GTK_SIGNAL_FUNC(cb_itemsignal), "select");
+       gtk_signal_connect (GTK_OBJECT(item), "deselect",
+                           GTK_SIGNAL_FUNC(cb_itemsignal), "deselect");
+       gtk_signal_connect (GTK_OBJECT(item), "toggle",
+                           GTK_SIGNAL_FUNC(cb_itemsignal), "toggle");
+       gtk_signal_connect (GTK_OBJECT(item), "expand",
+                           GTK_SIGNAL_FUNC(cb_wholenet), "expand");
+       gtk_signal_connect (GTK_OBJECT(item), "collapse",
+                           GTK_SIGNAL_FUNC(cb_wholenet), "collapse");
+       /* Add it to the parent tree */
+       gtk_tree_append (GTK_TREE(tree), item);
+       /* Show it - this can be done at any time */
+       gtk_widget_show (item);
+
+       subtree = gtk_tree_new();  /* A subtree for Whole Network */
+
+       gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);
 
-  /* Create a tree item for Whole Network */
+       gtk_signal_connect (GTK_OBJECT(subtree), "select_child",
+                           GTK_SIGNAL_FUNC(cb_select_child), tree);
+       gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child",
+                           GTK_SIGNAL_FUNC(cb_unselect_child), tree);
 
-  item = gtk_tree_item_new_with_label ("Whole Network");
-  /* Connect all GtkItem:: and GtkTreeItem:: signals */
-  gtk_signal_connect (GTK_OBJECT(item), "select",
-                     GTK_SIGNAL_FUNC(cb_itemsignal), "select");
-  gtk_signal_connect (GTK_OBJECT(item), "deselect",
-                     GTK_SIGNAL_FUNC(cb_itemsignal), "deselect");
-  gtk_signal_connect (GTK_OBJECT(item), "toggle",
-                     GTK_SIGNAL_FUNC(cb_itemsignal), "toggle");
-  gtk_signal_connect (GTK_OBJECT(item), "expand",
-                     GTK_SIGNAL_FUNC(cb_wholenet), "expand");
-  gtk_signal_connect (GTK_OBJECT(item), "collapse",
-                     GTK_SIGNAL_FUNC(cb_wholenet), "collapse");
-  /* Add it to the parent tree */
-  gtk_tree_append (GTK_TREE(tree), item);
-  /* Show it - this can be done at any time */
-  gtk_widget_show (item);
-
-  subtree = gtk_tree_new();  /* A subtree for Whole Network */
-
-  gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);
-
-  gtk_signal_connect (GTK_OBJECT(subtree), "select_child",
-                     GTK_SIGNAL_FUNC(cb_select_child), tree);
-  gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child",
-                     GTK_SIGNAL_FUNC(cb_unselect_child), tree);
+       /* Now, get the items in smb:/// and add them to the tree */
 
-  /* Now, get the items in smb:/// and add them to the tree */
-
-  while ((err = smbc_getdents(dh, (struct smbc_dirent *)dirbuf, 
-                             sizeof(dirbuf))) != 0) {
-
-    if (err < 0) { /* Handle the error */
-
-      fprintf(stderr, "Could not read directory for smbc:///: %s\n",
-             strerror(errno));
-
-      exit(1);
-
-    }
-
-    dirp = (struct smbc_dirent *)dirbuf;
+       while ((err = smbc_getdents(dh, (struct smbc_dirent *)dirbuf,
+                                   sizeof(dirbuf))) != 0) {
 
-    fprintf(stdout, "Dir len: %u\n", err);
-
-    while (err > 0) { /* Extract each entry and make a sub-tree */
-      struct tree_data *my_data;
-      int dirlen = dirp->dirlen;
+               if (err < 0) { /* Handle the error */
 
-      my_data = make_tree_data(dirp->smbc_type, dirp->name);
+                       fprintf(stderr, "Could not read directory for smbc:///: %s\n",
+                               strerror(errno));
 
-      item = gtk_tree_item_new_with_label(dirp->name);
-      /* Connect all GtkItem:: and GtkTreeItem:: signals */
-      gtk_signal_connect (GTK_OBJECT(item), "select",
-                         GTK_SIGNAL_FUNC(cb_itemsignal), "select");
-      gtk_signal_connect (GTK_OBJECT(item), "deselect",
-                         GTK_SIGNAL_FUNC(cb_itemsignal), "deselect");
-      gtk_signal_connect (GTK_OBJECT(item), "toggle",
-                         GTK_SIGNAL_FUNC(cb_itemsignal), "toggle");
-      gtk_signal_connect (GTK_OBJECT(item), "expand",
-                         GTK_SIGNAL_FUNC(cb_itemsignal), "expand");
-      gtk_signal_connect (GTK_OBJECT(item), "collapse",
-                         GTK_SIGNAL_FUNC(cb_itemsignal), "collapse");
-      /* Add it to the parent tree */
-      gtk_tree_append (GTK_TREE(tree), item);
-      /* Show it - this can be done at any time */
-      gtk_widget_show (item);
+                       exit(1);
 
-      gtk_object_set_user_data(GTK_OBJECT(item), (gpointer)my_data);
+               }
 
-      fprintf(stdout, "Added: %s, len: %u\n", dirp->name, dirlen);
+               dirp = (struct smbc_dirent *)dirbuf;
 
-      subtree = gtk_tree_new();
+               fprintf(stdout, "Dir len: %u\n", err);
 
-      gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);
+               while (err > 0) { /* Extract each entry and make a sub-tree */
+                       struct tree_data *my_data;
+                       int dirlen = dirp->dirlen;
 
-      gtk_signal_connect (GTK_OBJECT(subtree), "select_child",
-                         GTK_SIGNAL_FUNC(cb_select_child), tree);
-      gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child",
-                         GTK_SIGNAL_FUNC(cb_unselect_child), tree);
+                       my_data = make_tree_data(dirp->smbc_type, dirp->name);
 
-      dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
-      err -= dirlen;
+                       item = gtk_tree_item_new_with_label(dirp->name);
+                       /* Connect all GtkItem:: and GtkTreeItem:: signals */
+                       gtk_signal_connect (GTK_OBJECT(item), "select",
+                                           GTK_SIGNAL_FUNC(cb_itemsignal), "select");
+                       gtk_signal_connect (GTK_OBJECT(item), "deselect",
+                                           GTK_SIGNAL_FUNC(cb_itemsignal), "deselect");
+                       gtk_signal_connect (GTK_OBJECT(item), "toggle",
+                                           GTK_SIGNAL_FUNC(cb_itemsignal), "toggle");
+                       gtk_signal_connect (GTK_OBJECT(item), "expand",
+                                           GTK_SIGNAL_FUNC(cb_itemsignal), "expand");
+                       gtk_signal_connect (GTK_OBJECT(item), "collapse",
+                                           GTK_SIGNAL_FUNC(cb_itemsignal), "collapse");
+                       /* Add it to the parent tree */
+                       gtk_tree_append (GTK_TREE(tree), item);
+                       /* Show it - this can be done at any time */
+                       gtk_widget_show (item);
 
-    }
+                       gtk_object_set_user_data(GTK_OBJECT(item), (gpointer)my_data);
 
-  }
+                       fprintf(stdout, "Added: %s, len: %u\n", dirp->name, dirlen);
+
+                       subtree = gtk_tree_new();
+
+                       gtk_tree_item_set_subtree(GTK_TREE_ITEM(item), subtree);
+
+                       gtk_signal_connect (GTK_OBJECT(subtree), "select_child",
+                                           GTK_SIGNAL_FUNC(cb_select_child), tree);
+                       gtk_signal_connect (GTK_OBJECT(subtree), "unselect_child",
+                                           GTK_SIGNAL_FUNC(cb_unselect_child), tree);
+
+                       dirp = (struct smbc_dirent *) ((char *) dirp + dirlen);
+                       err -= dirlen;
+
+               }
+
+       }
 
-  smbc_closedir(dh); /* FIXME, check for error :-) */
+       smbc_closedir(dh); /* FIXME, check for error :-) */
 
-  /* Show the window and loop endlessly */
-  gtk_main();
-  return 0;
+       /* Show the window and loop endlessly */
+       gtk_main();
+       return 0;
 }
 /* example-end */