This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <errno.h>
+#include <time.h>
#include <sys/time.h>
#include <string.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);
-
-}
-
-int global_id = 0;
-
-void print_list_fn(struct print_job_info *pji)
-{
-
- fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %u, User: %s, Name: %s\n",
- pji->id, pji->priority, pji->size, pji->user, pji->name);
-
- global_id = pji->id;
-
-}
+#include "libsmbclient.h"
+#include "get_auth_data_fn.h"
int main(int argc, char *argv[])
{
- int err, fd, dh1, dh2, dh3, dsize, dirc;
+ 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 *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) {
}
- fprintf(stdout, "Directory handles: %u, %u, %u\n", dh1, dh2, dh3);
+ fprintf(stdout, "Directory handle: %u\n", dh1);
/* Now, list those directories, but in funny ways ... */
((struct smbc_dirent *)dirp)->comment);
dirp += dsize;
- (char *)dirc -= dsize;
+ dirc -= dsize;
}
/* Now, write some date to the file ... */
- bzero(buff, sizeof(buff));
+ memset(buff, '\0', sizeof(buff));
strcpy(buff, "Some test data for the moment ...");
err = smbc_write(fd, buff, sizeof(buff));
}
- fprintf(stdout, "Wrote %d bytes to file: %s\n", sizeof(buff), buff);
+ fprintf(stdout, "Wrote %lu bytes to file: %s\n",
+ (unsigned long) sizeof(buff), buff);
/* Now, seek the file back to offset 0 */
}
fprintf(stdout, "Stat'ed file: %s. Size = %d, mode = %04X\n", file2,
- (int)st2.st_size, st2.st_mode);
+ (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, st1.st_mode);
+ (int)st1.st_size, (unsigned int)st1.st_mode);
fprintf(stdout, " time: %s\n", ctime(&st1.st_atime));
/* Now, make a directory ... */