summaryrefslogtreecommitdiff
path: root/examples/libsmbclient
diff options
context:
space:
mode:
Diffstat (limited to 'examples/libsmbclient')
-rw-r--r--examples/libsmbclient/README11
-rw-r--r--examples/libsmbclient/testacl.c54
-rw-r--r--examples/libsmbclient/testbrowse.c62
-rw-r--r--examples/libsmbclient/testsmbc.c37
-rw-r--r--examples/libsmbclient/teststat.c60
5 files changed, 16 insertions, 208 deletions
diff --git a/examples/libsmbclient/README b/examples/libsmbclient/README
index d9a9f82917..c45dd8b9d6 100644
--- a/examples/libsmbclient/README
+++ b/examples/libsmbclient/README
@@ -2,7 +2,16 @@ Some simple example programs for libsmbclient ...
testsmbc.c is kinda broken as it has many hardcoded bits in it
+testbrowse.c opens a remote folder and displays its contents
+
+teststat.c allows comparing the results of smbc_stat() against a local stat() of
+the same file.
+
tree.c is an example of how you might do some of these things with GTK+
It needs lots of work but shows you some ways to use libsmbclient.
-Richard Sharpe, 17-May-2001 ...
+smbwrapper implements the old smbsh/smbwrapper mechanism using libsmbclient, in
+such a way that it works on Linux
+
+Richard Sharpe, 17 May 2001
+Derrell Lipman, 30 Mar 2005
diff --git a/examples/libsmbclient/testacl.c b/examples/libsmbclient/testacl.c
index 47668f7c9c..ce5694b331 100644
--- a/examples/libsmbclient/testacl.c
+++ b/examples/libsmbclient/testacl.c
@@ -3,6 +3,7 @@
#include <errno.h>
#include <popt.h>
#include "libsmbclient.h"
+#include "get_auth_data_fn.h"
enum acl_mode
{
@@ -15,59 +16,6 @@ enum acl_mode
SMB_ACL_CHGRP
};
-static void
-get_auth_data_fn(const char * pServer,
- const char * pShare,
- char * pWorkgroup,
- int maxLenWorkgroup,
- char * pUsername,
- int maxLenUsername,
- char * pPassword,
- int maxLenPassword)
-
-{
- char temp[128];
-
- fprintf(stdout, "Workgroup: [%s] ", pWorkgroup);
- fgets(temp, sizeof(temp), stdin);
-
- 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);
- fgets(temp, sizeof(temp), stdin);
-
- 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: ");
- fgets(temp, sizeof(temp), stdin);
-
- if (temp[strlen(temp) - 1] == '\n') /* A new line? */
- {
- temp[strlen(temp) - 1] = '\0';
- }
-
- if (temp[0] != '\0')
- {
- strncpy(pPassword, temp, maxLenPassword - 1);
- }
-}
-
int main(int argc, const char *argv[])
{
diff --git a/examples/libsmbclient/testbrowse.c b/examples/libsmbclient/testbrowse.c
index 8122df5e2e..27d6a69738 100644
--- a/examples/libsmbclient/testbrowse.c
+++ b/examples/libsmbclient/testbrowse.c
@@ -5,8 +5,9 @@
#include <stdio.h>
#include <string.h>
#include <popt.h>
-#include <libsmbclient.h>
#include <stdlib.h>
+#include <libsmbclient.h>
+#include "get_auth_data_fn.h"
void error_message(char * pMessage)
{
@@ -14,65 +15,6 @@ void error_message(char * pMessage)
}
-static void
-get_auth_data_fn(const char * pServer,
- const char * pShare,
- char * pWorkgroup,
- int maxLenWorkgroup,
- char * pUsername,
- int maxLenUsername,
- char * pPassword,
- int maxLenPassword)
-
-{
- char temp[128];
-
- printf("Entered get_auth_data_fn\n");
-
- fprintf(stdout, "Need password for //%s/%s\n", pServer, pShare);
-
- fprintf(stdout, "Username: [%s] ", pUsername);
- fgets(temp, sizeof(temp), stdin);
-
- if (temp[strlen(temp) - 1] == '\n') /* A new line? */
- {
- temp[strlen(temp) - 1] = '\0';
- }
-
- if (temp[0] != '\0')
- {
- strncpy(pUsername, temp, maxLenUsername - 1);
- }
-
- strcpy(temp, getpass("Password: "));
-
- 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: ");
- fgets(temp, sizeof(temp), stdin);
-
- if (temp[strlen(temp) - 1] == '\n') /* A new line? */
- {
- temp[strlen(temp) - 1] = '\0';
- }
-
- if (temp[0] != '\0')
- {
- strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
- }
-
- putchar('\n');
-}
-
-
int
main(int argc, char * argv[])
{
diff --git a/examples/libsmbclient/testsmbc.c b/examples/libsmbclient/testsmbc.c
index 9f5e6148ee..45e67bee62 100644
--- a/examples/libsmbclient/testsmbc.c
+++ b/examples/libsmbclient/testsmbc.c
@@ -27,40 +27,7 @@
#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 +51,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) {
diff --git a/examples/libsmbclient/teststat.c b/examples/libsmbclient/teststat.c
index 46eeb13985..bea34cfc09 100644
--- a/examples/libsmbclient/teststat.c
+++ b/examples/libsmbclient/teststat.c
@@ -3,65 +3,7 @@
#include <string.h>
#include <time.h>
#include <libsmbclient.h>
-
-static void
-get_auth_data_fn(const char * pServer,
- const char * pShare,
- char * pWorkgroup,
- int maxLenWorkgroup,
- char * pUsername,
- int maxLenUsername,
- char * pPassword,
- int maxLenPassword)
-
-{
- char temp[128];
-
- printf("Entered get_auth_data_fn\n");
-
- fprintf(stdout, "Need password for //%s/%s\n", pServer, pShare);
-
- fprintf(stdout, "Username: [%s] ", pUsername);
- fgets(temp, sizeof(temp), stdin);
-
- if (temp[strlen(temp) - 1] == '\n') /* A new line? */
- {
- temp[strlen(temp) - 1] = '\0';
- }
-
- if (temp[0] != '\0')
- {
- strncpy(pUsername, temp, maxLenUsername - 1);
- }
-
- strcpy(temp, getpass("Password: "));
-
- 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: ");
- fgets(temp, sizeof(temp), stdin);
-
- if (temp[strlen(temp) - 1] == '\n') /* A new line? */
- {
- temp[strlen(temp) - 1] = '\0';
- }
-
- if (temp[0] != '\0')
- {
- strncpy(pWorkgroup, temp, maxLenWorkgroup - 1);
- }
-
- putchar('\n');
-}
-
+#include "get_auth_data_fn.h"
int main(int argc, char * argv[])