Merge branch 'v3-2-test' of git://git.samba.org/samba into v3-2-test
[ira/wip.git] / examples / libsmbclient / testsmbc.c
index 888a9c0d4f9e26fb23dced9088bc6eaf5e7be343..c506f5fd64a6e4aa83628c4dd02050a59b333685 100644 (file)
@@ -7,7 +7,7 @@
    
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
    
    This program is distributed in the hope that it will be useful,
@@ -16,8 +16,7 @@
    GNU General Public License for more details.
    
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <libsmbclient.h>
-
-void auth_fn(const char *server, const char *share,
-            char *workgroup, int wgmaxlen, char *username, int unmaxlen,
-            char *password, int pwmaxlen)
-{
-  char temp[128];
-
-  fprintf(stdout, "Need password for //%s/%s\n", server, share);
-
-  fprintf(stdout, "Enter workgroup: [%s] ", workgroup);
-  fgets(temp, sizeof(temp), stdin);
-
-  if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
-    temp[strlen(temp) - 1] = 0x00;
-
-  if (temp[0]) strncpy(workgroup, temp, wgmaxlen - 1);
-
-  fprintf(stdout, "Enter username: [%s] ", username);
-  fgets(temp, sizeof(temp), stdin);
-
-  if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
-    temp[strlen(temp) - 1] = 0x00;
-
-  if (temp[0]) strncpy(username, temp, unmaxlen - 1);
-
-  fprintf(stdout, "Enter password: [%s] ", password);
-  fgets(temp, sizeof(temp), stdin);
-
-  if (temp[strlen(temp) - 1] == 0x0a) /* A new line? */
-    temp[strlen(temp) - 1] = 0x00;
-
-  if (temp[0]) strncpy(password, temp, pwmaxlen - 1);
-
-}
+#include "get_auth_data_fn.h"
 
 int global_id = 0;
 
@@ -84,7 +50,7 @@ int main(int argc, char *argv[])
   char *dirp;
   struct stat st1, st2;
 
-  err = smbc_init(auth_fn,  10); /* Initialize things */
+  err = smbc_init(get_auth_data_fn,  10); /* Initialize things */
 
   if (err < 0) {
 
@@ -132,7 +98,7 @@ int main(int argc, char *argv[])
              ((struct smbc_dirent *)dirp)->comment);
 
       dirp += dsize;
-      (char *)dirc -= dsize;
+      dirc -= dsize;
 
     }