| [414] | 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | SMB client library test program
|
|---|
| 4 | Copyright (C) Andrew Tridgell 1998
|
|---|
| 5 | Copyright (C) Richard Sharpe 2000
|
|---|
| 6 | Copyright (C) John Terpsra 2000
|
|---|
| 7 |
|
|---|
| 8 | This program is free software; you can redistribute it and/or modify
|
|---|
| 9 | it under the terms of the GNU General Public License as published by
|
|---|
| 10 | the Free Software Foundation; either version 3 of the License, or
|
|---|
| 11 | (at your option) any later version.
|
|---|
| 12 |
|
|---|
| 13 | This program is distributed in the hope that it will be useful,
|
|---|
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 16 | GNU General Public License for more details.
|
|---|
| 17 |
|
|---|
| 18 | You should have received a copy of the GNU General Public License
|
|---|
| 19 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 20 | */
|
|---|
| 21 |
|
|---|
| 22 | #include <stdio.h>
|
|---|
| 23 | #include <errno.h>
|
|---|
| 24 | #include <time.h>
|
|---|
| 25 | #include <sys/time.h>
|
|---|
| 26 | #include <string.h>
|
|---|
| 27 | #include <unistd.h>
|
|---|
| 28 | #include <stdlib.h>
|
|---|
| 29 | #include "libsmbclient.h"
|
|---|
| 30 | #include "get_auth_data_fn.h"
|
|---|
| 31 |
|
|---|
| 32 | int global_id = 0;
|
|---|
| 33 |
|
|---|
| 34 | void print_list_fn(struct print_job_info *pji)
|
|---|
| 35 | {
|
|---|
| 36 |
|
|---|
| 37 | fprintf(stdout, "Print job: ID: %u, Prio: %u, Size: %lu, User: %s, Name: %s\n",
|
|---|
| 38 | pji->id,
|
|---|
| 39 | pji->priority,
|
|---|
| 40 | (unsigned long) pji->size,
|
|---|
| 41 | pji->user,
|
|---|
| 42 | pji->name);
|
|---|
| 43 |
|
|---|
| 44 | global_id = pji->id;
|
|---|
| 45 |
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | int main(int argc, char *argv[])
|
|---|
| 49 | {
|
|---|
| 50 | int err, fd, dh1, dh2, dh3, dsize, dirc;
|
|---|
| 51 | const char *file = "smb://samba/public/testfile.txt";
|
|---|
| 52 | const char *file2 = "smb://samba/public/testfile2.txt";
|
|---|
| 53 | char buff[256];
|
|---|
| 54 | char dirbuf[512];
|
|---|
| 55 | char *dirp;
|
|---|
| 56 | struct stat st1, st2;
|
|---|
| 57 |
|
|---|
| 58 | err = smbc_init(get_auth_data_fn, 10); /* Initialize things */
|
|---|
| 59 |
|
|---|
| 60 | if (err < 0) {
|
|---|
| 61 |
|
|---|
| 62 | fprintf(stderr, "Initializing the smbclient library ...: %s\n", strerror(errno));
|
|---|
| 63 |
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 | if (argc > 1) {
|
|---|
| 67 |
|
|---|
| 68 | if ((dh1 = smbc_opendir(argv[1]))<1) {
|
|---|
| 69 |
|
|---|
| 70 | fprintf(stderr, "Could not open directory: %s: %s\n",
|
|---|
| 71 | argv[1], strerror(errno));
|
|---|
| 72 |
|
|---|
| 73 | exit(1);
|
|---|
| 74 |
|
|---|
| 75 | }
|
|---|
| 76 |
|
|---|
| 77 | fprintf(stdout, "Directory handles: %u, %u, %u\n", dh1, dh2, dh3);
|
|---|
| 78 |
|
|---|
| 79 | /* Now, list those directories, but in funny ways ... */
|
|---|
| 80 |
|
|---|
| 81 | dirp = (char *)dirbuf;
|
|---|
| 82 |
|
|---|
| 83 | if ((dirc = smbc_getdents(dh1, (struct smbc_dirent *)dirp,
|
|---|
| 84 | sizeof(dirbuf))) < 0) {
|
|---|
| 85 |
|
|---|
| 86 | fprintf(stderr, "Problems getting directory entries: %s\n",
|
|---|
| |
|---|