From 5c682b73371c22e3e9abb620d4cdab10f7a78646 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Sat, 13 Jul 2002 05:13:02 +0000 Subject: Add these two files I forgot. (This used to be commit 5706e6af168b14a40cb1e306c2911182260ff0d3) --- source3/libsmb/libsmb_compat.c | 285 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 source3/libsmb/libsmb_compat.c (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c new file mode 100644 index 0000000000..dbfd860358 --- /dev/null +++ b/source3/libsmb/libsmb_compat.c @@ -0,0 +1,285 @@ +/* + Unix SMB/CIFS implementation. + SMB client library implementation (Old interface compatibility) + Copyright (C) Andrew Tridgell 1998 + Copyright (C) Richard Sharpe 2000 + Copyright (C) John Terpstra 2000 + Copyright (C) Tom Jansen (Ninja ISD) 2002 + + 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 + (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, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + + +#include "includes.h" + +/* + * Define this to get the real SMBCFILE and SMBCSRV structures + */ +#define _SMBC_INTERNAL +#include "libsmbclient.h" + +struct smbc_compat_fdlist { + SMBCFILE * file; + int fd; + struct smbc_compat_fdlist *next, *prev; +}; + +static SMBCCTX * statcont = NULL; +static int smbc_compat_initialized = 0; +static int smbc_currentfd = 10000; +static struct smbc_compat_fdlist * smbc_compat_fdlist = NULL; + + +/* Find an fd and return the SMBCFILE * or NULL on failure */ +static SMBCFILE * find_fd(int fd) +{ + struct smbc_compat_fdlist * f = smbc_compat_fdlist; + while (f) { + if (f->fd == fd) + return f->file; + f = f->next; + } + return NULL; +} + +/* Add an fd, returns 0 on success, -1 on error with errno set */ +static int add_fd(SMBCFILE * file) +{ + struct smbc_compat_fdlist * f = malloc(sizeof(struct smbc_compat_fdlist)); + if (!f) { + errno = ENOMEM; + return -1; + } + + f->fd = smbc_currentfd++; + f->file = file; + + DLIST_ADD(smbc_compat_fdlist, f); + + return f->fd; +} + + + +/* Delete an fd, returns 0 on success */ +static int del_fd(int fd) +{ + struct smbc_compat_fdlist * f = smbc_compat_fdlist; + while (f) { + if (f->fd == fd) + break; + f = f->next; + } + if (f) { + /* found */ + DLIST_REMOVE(smbc_compat_fdlist, f); + SAFE_FREE(f); + return 0; + } + return 1; +} + + + +int smbc_init(smbc_get_auth_data_fn fn, int debug) +{ + if (!smbc_compat_initialized) { + statcont = smbc_new_context(); + if (!statcont) + return -1; + + statcont->debug = debug; + statcont->callbacks.auth_fn = fn; + + if (!smbc_init_context(statcont)) { + smbc_free_context(statcont, False); + return -1; + } + + smbc_compat_initialized = 1; + + return 0; + } + return 0; +} + + +int smbc_open(const char *furl, int flags, mode_t mode) +{ + SMBCFILE * file; + int fd; + + file = statcont->open(statcont, furl, flags, mode); + if (!file) + return -1; + + fd = add_fd(file); + if (fd == -1) + statcont->close(statcont, file); + return fd; +} + + +int smbc_creat(const char *furl, mode_t mode) +{ + SMBCFILE * file; + int fd; + + file = statcont->creat(statcont, furl, mode); + if (!file) + return -1; + + fd = add_fd(file); + if (fd == -1) { + /* Hmm... should we delete the file too ? I guess we could try */ + statcont->close(statcont, file); + statcont->unlink(statcont, furl); + } + return fd; +} + + +ssize_t smbc_read(int fd, void *buf, size_t bufsize) +{ + SMBCFILE * file = find_fd(fd); + return statcont->read(statcont, file, buf, bufsize); +} + +ssize_t smbc_write(int fd, void *buf, size_t bufsize) +{ + SMBCFILE * file = find_fd(fd); + return statcont->write(statcont, file, buf, bufsize); +} + +off_t smbc_lseek(int fd, off_t offset, int whence) +{ + SMBCFILE * file = find_fd(fd); + return statcont->lseek(statcont, file, offset, whence); +} + +int smbc_close(int fd) +{ + SMBCFILE * file = find_fd(fd); + del_fd(fd); + return statcont->close(statcont, file); +} + +int smbc_unlink(const char *fname) +{ + return statcont->unlink(statcont, fname); +} + +int smbc_rename(const char *ourl, const char *nurl) +{ + return statcont->rename(statcont, ourl, statcont, nurl); +} + +int smbc_opendir(const char *durl) +{ + SMBCFILE * file; + int fd; + + file = statcont->opendir(statcont, durl); + if (!file) + return -1; + + fd = add_fd(file); + if (fd == -1) + statcont->closedir(statcont, file); + + return fd; +} + +int smbc_closedir(int dh) +{ + SMBCFILE * file = find_fd(dh); + del_fd(dh); + return statcont->closedir(statcont, file); +} + +int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count) +{ + SMBCFILE * file = find_fd(dh); + return statcont->getdents(statcont, file,dirp, count); +} + +struct smbc_dirent* smbc_readdir(unsigned int dh) +{ + SMBCFILE * file = find_fd(dh); + return statcont->readdir(statcont, file); +} + +off_t smbc_telldir(int dh) +{ + SMBCFILE * file = find_fd(dh); + return statcont->telldir(statcont, file); +} + +int smbc_lseekdir(int fd, off_t offset) +{ + SMBCFILE * file = find_fd(fd); + return statcont->lseekdir(statcont, file, offset); +} + +int smbc_mkdir(const char *durl, mode_t mode) +{ + return statcont->mkdir(statcont, durl, mode); +} + +int smbc_rmdir(const char *durl) +{ + return statcont->rmdir(statcont, durl); +} + +int smbc_stat(const char *url, struct stat *st) +{ + return statcont->stat(statcont, url, st); +} + +int smbc_fstat(int fd, struct stat *st) +{ + SMBCFILE * file = find_fd(fd); + return statcont->fstat(statcont, file, st); +} + +int smbc_chmod(const char *url, mode_t mode) +{ + /* NOT IMPLEMENTED IN LIBSMBCLIENT YET */ + return -1; +} + +int smbc_print_file(const char *fname, const char *printq) +{ + return statcont->print_file(statcont, fname, statcont, printq); +} + +int smbc_open_print_job(const char *fname) +{ + SMBCFILE * file = statcont->open_print_job(statcont, fname); + if (!file) return -1; + return (int) file; +} + +int smbc_list_print_jobs(const char *purl, smbc_get_print_job_info fn) +{ + return statcont->list_print_jobs(statcont, purl, fn); +} + +int smbc_unlink_print_job(const char *purl, int id) +{ + return statcont->unlink_print_job(statcont, purl, id); +} + + -- cgit From f9789eb987f5cec9a9b5125815cb3de4ea88349b Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Sat, 28 Sep 2002 21:42:51 +0000 Subject: Change libsmbclient.h -> ../include/libsmbclient.h in 3.0 as well (This used to be commit 5b451ce6f096d699a80c10f48bde5ee224e29ccf) --- source3/libsmb/libsmb_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index dbfd860358..bba90c648e 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -28,7 +28,7 @@ * Define this to get the real SMBCFILE and SMBCSRV structures */ #define _SMBC_INTERNAL -#include "libsmbclient.h" +#include "../include/libsmbclient.h" struct smbc_compat_fdlist { SMBCFILE * file; -- cgit From 16925589eb1f12ebe6e493774fd4306a827feb73 Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Mon, 13 Jan 2003 20:04:40 +0000 Subject: Now that I am running config.developer, I decided to get rif of some warnings: 1. reboot in parse_reg and cli_reg was shadowing a definition on FreeBSD 4.3 from system includes. 2. Added a bit of const to places. 3. Made sure internal functions were declared where needed. (This used to be commit fd847aa93690eb72f0437a8d22c03b222eb2a016) --- source3/libsmb/libsmb_compat.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index bba90c648e..27b274953a 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -24,11 +24,7 @@ #include "includes.h" -/* - * Define this to get the real SMBCFILE and SMBCSRV structures - */ -#define _SMBC_INTERNAL -#include "../include/libsmbclient.h" +#include "../include/libsmb_internal.h" struct smbc_compat_fdlist { SMBCFILE * file; @@ -272,7 +268,7 @@ int smbc_open_print_job(const char *fname) return (int) file; } -int smbc_list_print_jobs(const char *purl, smbc_get_print_job_info fn) +int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn) { return statcont->list_print_jobs(statcont, purl, fn); } -- cgit From 2f84a990bcfae7acaee0759359dd8867b24f600c Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Fri, 24 Oct 2003 17:01:19 +0000 Subject: Commit Derrell's changes to libsmbclient plus a small change to configure.in to see if SGI and other platforms will build. (This used to be commit cf9311044c372695592db1b95b814b0870b8cf29) --- source3/libsmb/libsmb_compat.c | 190 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 173 insertions(+), 17 deletions(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 27b274953a..4c96c41c56 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -5,6 +5,7 @@ Copyright (C) Richard Sharpe 2000 Copyright (C) John Terpstra 2000 Copyright (C) Tom Jansen (Ninja ISD) 2002 + Copyright (C) Derrell Lipman 2003 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 @@ -34,14 +35,14 @@ struct smbc_compat_fdlist { static SMBCCTX * statcont = NULL; static int smbc_compat_initialized = 0; -static int smbc_currentfd = 10000; -static struct smbc_compat_fdlist * smbc_compat_fdlist = NULL; - +static int smbc_compat_nextfd = 0; +static struct smbc_compat_fdlist * smbc_compat_fd_in_use = NULL; +static struct smbc_compat_fdlist * smbc_compat_fd_avail = NULL; /* Find an fd and return the SMBCFILE * or NULL on failure */ static SMBCFILE * find_fd(int fd) { - struct smbc_compat_fdlist * f = smbc_compat_fdlist; + struct smbc_compat_fdlist * f = smbc_compat_fd_in_use; while (f) { if (f->fd == fd) return f->file; @@ -53,16 +54,36 @@ static SMBCFILE * find_fd(int fd) /* Add an fd, returns 0 on success, -1 on error with errno set */ static int add_fd(SMBCFILE * file) { - struct smbc_compat_fdlist * f = malloc(sizeof(struct smbc_compat_fdlist)); - if (!f) { - errno = ENOMEM; - return -1; - } + struct smbc_compat_fdlist * f = smbc_compat_fd_avail; + + if (f) { + /* We found one that's available */ + DLIST_REMOVE(smbc_compat_fd_avail, f); + + } else { + /* + * None were available, so allocate one. Keep the number of + * file descriptors determinate. This allows the application + * to allocate bitmaps or mapping of file descriptors based on + * a known maximum number of file descriptors that will ever + * be returned. + */ + if (smbc_compat_nextfd >= FD_SETSIZE) { + errno = EMFILE; + return -1; + } + + f = malloc(sizeof(struct smbc_compat_fdlist)); + if (!f) { + errno = ENOMEM; + return -1; + } - f->fd = smbc_currentfd++; + f->fd = SMBC_BASE_FD + smbc_compat_nextfd++; + } + f->file = file; - - DLIST_ADD(smbc_compat_fdlist, f); + DLIST_ADD(smbc_compat_fd_in_use, f); return f->fd; } @@ -72,16 +93,19 @@ static int add_fd(SMBCFILE * file) /* Delete an fd, returns 0 on success */ static int del_fd(int fd) { - struct smbc_compat_fdlist * f = smbc_compat_fdlist; + struct smbc_compat_fdlist * f = smbc_compat_fd_in_use; + while (f) { if (f->fd == fd) break; f = f->next; } + if (f) { /* found */ - DLIST_REMOVE(smbc_compat_fdlist, f); - SAFE_FREE(f); + DLIST_REMOVE(smbc_compat_fd_in_use, f); + f->file = NULL; + DLIST_ADD(smbc_compat_fd_avail, f); return 0; } return 1; @@ -91,6 +115,9 @@ static int del_fd(int fd) int smbc_init(smbc_get_auth_data_fn fn, int debug) { + int i; + struct smbc_compat_fdlist * f; + if (!smbc_compat_initialized) { statcont = smbc_new_context(); if (!statcont) @@ -112,6 +139,22 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug) } +SMBCCTX *smbc_set_context(SMBCCTX * context) +{ + SMBCCTX *old_context = statcont; + + if (context) { + /* Save provided context. It must have been initialized! */ + statcont = context; + + /* You'd better know what you're doing. We won't help you. */ + smbc_compat_initialized = 1; + } + + return old_context; +} + + int smbc_open(const char *furl, int flags, mode_t mode) { SMBCFILE * file; @@ -252,8 +295,121 @@ int smbc_fstat(int fd, struct stat *st) int smbc_chmod(const char *url, mode_t mode) { - /* NOT IMPLEMENTED IN LIBSMBCLIENT YET */ - return -1; + return statcont->chmod(statcont, url, mode); +} + +int smbc_utimes(const char *fname, struct timeval *tbuf) +{ + return statcont->utimes(statcont, fname, tbuf); +} + +#ifdef HAVE_UTIME_H +int smbc_utime(const char *fname, struct utimbuf *utbuf) +{ + struct timeval tv; + + if (utbuf == NULL) + return statcont->utimes(statcont, fname, NULL); + + tv.tv_sec = utbuf->modtime; + tv.tv_usec = 0; + return statcont->utimes(statcont, fname, &tv); +} +#endif + +int smbc_setxattr(const char *fname, + const char *name, + const void *value, + size_t size, + int flags) +{ + return statcont->setxattr(statcont, fname, name, value, size, flags); +} + +int smbc_lsetxattr(const char *fname, + const char *name, + const void *value, + size_t size, + int flags) +{ + return statcont->setxattr(statcont, fname, name, value, size, flags); +} + +int smbc_fsetxattr(int fd, + const char *name, + const void *value, + size_t size, + int flags) +{ + SMBCFILE * file = find_fd(fd); + return statcont->setxattr(statcont, file->fname, + name, value, size, flags); +} + +int smbc_getxattr(const char *fname, + const char *name, + const void *value, + size_t size) +{ + return statcont->getxattr(statcont, fname, name, value, size); +} + +int smbc_lgetxattr(const char *fname, + const char *name, + const void *value, + size_t size) +{ + return statcont->getxattr(statcont, fname, name, value, size); +} + +int smbc_fgetxattr(int fd, + const char *name, + const void *value, + size_t size) +{ + SMBCFILE * file = find_fd(fd); + return statcont->getxattr(statcont, file->fname, name, value, size); +} + +int smbc_removexattr(const char *fname, + const char *name) +{ + return statcont->removexattr(statcont, fname, name); +} + +int smbc_lremovexattr(const char *fname, + const char *name) +{ + return statcont->removexattr(statcont, fname, name); +} + +int smbc_fremovexattr(int fd, + const char *name) +{ + SMBCFILE * file = find_fd(fd); + return statcont->removexattr(statcont, file->fname, name); +} + +int smbc_listxattr(const char *fname, + char *list, + size_t size) +{ + return statcont->listxattr(statcont, fname, list, size); +} + +int smbc_llistxattr(const char *fname, + char *list, + size_t size) +{ + return statcont->listxattr(statcont, fname, list, size); +} + +int smbc_flistxattr(int fd, + char *list, + size_t size) +{ + SMBCFILE * file = find_fd(fd); + return statcont->listxattr(statcont, file->fname, list, size); } int smbc_print_file(const char *fname, const char *printq) -- cgit From 55f8ca432b60a8e85a6c68eaedaabf45615484af Mon Sep 17 00:00:00 2001 From: Richard Sharpe Date: Mon, 27 Oct 2003 06:51:39 +0000 Subject: Remove some unused variables uncovered by the build farm. (This used to be commit 084e4678c0876ebd6e756192866103ae037f3258) --- source3/libsmb/libsmb_compat.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 4c96c41c56..cc23835ae3 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -115,9 +115,6 @@ static int del_fd(int fd) int smbc_init(smbc_get_auth_data_fn fn, int debug) { - int i; - struct smbc_compat_fdlist * f; - if (!smbc_compat_initialized) { statcont = smbc_new_context(); if (!statcont) -- cgit From b4cf9e95059071df49b34ff8574e48cb96f42da1 Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Thu, 7 Oct 2004 04:01:18 +0000 Subject: r2835: Since we always have -I. and -I$(srcdir) in CFLAGS, we can get rid of '..' from all #include preprocessor commands. This fixes bugzilla #1880 where OpenVMS gets confused about the '.' characters. (This used to be commit 7f161702fa4916979602cc0295919b541912acd6) --- source3/libsmb/libsmb_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index cc23835ae3..c4be848cc1 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -25,7 +25,7 @@ #include "includes.h" -#include "../include/libsmb_internal.h" +#include "include/libsmb_internal.h" struct smbc_compat_fdlist { SMBCFILE * file; -- cgit From acf9d61421faa6c0055d57fdee7db300dc5431aa Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 7 Dec 2004 18:25:53 +0000 Subject: r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation functions so we can funnel through some well known functions. Should help greatly with malloc checking. HEAD patch to follow. Jeremy. (This used to be commit 620f2e608f70ba92f032720c031283d295c5c06a) --- source3/libsmb/libsmb_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index c4be848cc1..83088a14de 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -73,7 +73,7 @@ static int add_fd(SMBCFILE * file) return -1; } - f = malloc(sizeof(struct smbc_compat_fdlist)); + f = SMB_MALLOC_P(struct smbc_compat_fdlist); if (!f) { errno = ENOMEM; return -1; -- cgit From e317034997bbeab447298070afdb1b78c60e0e69 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 1 Jun 2005 17:40:40 +0000 Subject: r7168: Updating file times from libsmbclient was not working for win98. Although the function that was being used to set attributes is a core protocol function (SMBsetatr = 0x09), it does not appear to work on win98. As a temporary measure, when file times are to be set, this version opens the file and uses SMBsetattrE = 0x22 instead. (The other advantage of this function over the original one is that it supports setting access time as well as modification time.) The next step, the proper solution if it can be made to work, is to write functions that use TRANS2_SET_PATH_INFO instead. (This used to be commit bab0bf7f4f9d2a4b6fcee4429094349302bbeb33) --- source3/libsmb/libsmb_compat.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 83088a14de..3dc60f7240 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -303,14 +303,16 @@ int smbc_utimes(const char *fname, struct timeval *tbuf) #ifdef HAVE_UTIME_H int smbc_utime(const char *fname, struct utimbuf *utbuf) { - struct timeval tv; + struct timeval tv[2]; if (utbuf == NULL) return statcont->utimes(statcont, fname, NULL); - tv.tv_sec = utbuf->modtime; - tv.tv_usec = 0; - return statcont->utimes(statcont, fname, &tv); + tv[0].tv_sec = utbuf->actime; + tv[1].tv_sec = utbuf->modtime; + tv[0].tv_usec = tv[1].tv_usec = 0; + + return statcont->utimes(statcont, fname, tv); } #endif -- cgit From 3a8af94424c8d60dd80f6b57806ef0b79465badc Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 3 Jul 2005 12:05:07 +0000 Subject: r8093: Next round. Now it compiles with --enable-socket-wrapper. Volker (This used to be commit 25cbcfba30f534f3fb31627ba43421c42ccd5b0f) --- source3/libsmb/libsmb_compat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 3dc60f7240..f9461f9368 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -163,7 +163,7 @@ int smbc_open(const char *furl, int flags, mode_t mode) fd = add_fd(file); if (fd == -1) - statcont->close(statcont, file); + statcont->close_fn(statcont, file); return fd; } @@ -180,7 +180,7 @@ int smbc_creat(const char *furl, mode_t mode) fd = add_fd(file); if (fd == -1) { /* Hmm... should we delete the file too ? I guess we could try */ - statcont->close(statcont, file); + statcont->close_fn(statcont, file); statcont->unlink(statcont, furl); } return fd; @@ -209,7 +209,7 @@ int smbc_close(int fd) { SMBCFILE * file = find_fd(fd); del_fd(fd); - return statcont->close(statcont, file); + return statcont->close_fn(statcont, file); } int smbc_unlink(const char *fname) -- cgit From 54abd2aa66069e6baf7769c496f46d9dba18db39 Mon Sep 17 00:00:00 2001 From: Gerald Carter Date: Fri, 30 Sep 2005 17:13:37 +0000 Subject: r10656: BIG merge from trunk. Features not copied over * \PIPE\unixinfo * winbindd's {group,alias}membership new functions * winbindd's lookupsids() functionality * swat (trunk changes to be reverted as per discussion with Deryck) (This used to be commit 939c3cb5d78e3a2236209b296aa8aba8bdce32d3) --- source3/libsmb/libsmb_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index f9461f9368..5699e153bb 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -420,7 +420,7 @@ int smbc_open_print_job(const char *fname) { SMBCFILE * file = statcont->open_print_job(statcont, fname); if (!file) return -1; - return (int) file; + return file->cli_fd; } int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn) -- cgit From e7fc37cf0f4bd2c0f25865fb07d1bff27b239130 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 19 Jun 2006 19:07:39 +0000 Subject: r16360: Fix Klocwork ID 136 520 521 522 523 542 574 575 576 607 in net_rpc.c: 715 716 732 734 735 736 737 738 739 749 in net_rpc_audit.c: 754 755 756 in net_rpc_join.c: 757 in net_rpc_registry: 766 767 in net_rpc_samsync.c: 771 773 in net_sam.c: 797 798 Volker (This used to be commit 3df0bf7d6050fd7c9ace72487d4f74d92e30a584) --- source3/libsmb/libsmb_compat.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 5699e153bb..cfd5948e26 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -341,6 +341,10 @@ int smbc_fsetxattr(int fd, int flags) { SMBCFILE * file = find_fd(fd); + if (file == NULL) { + errno = EBADF; + return -1; + } return statcont->setxattr(statcont, file->fname, name, value, size, flags); } @@ -367,6 +371,10 @@ int smbc_fgetxattr(int fd, size_t size) { SMBCFILE * file = find_fd(fd); + if (file == NULL) { + errno = EBADF; + return -1; + } return statcont->getxattr(statcont, file->fname, name, value, size); } @@ -386,6 +394,10 @@ int smbc_fremovexattr(int fd, const char *name) { SMBCFILE * file = find_fd(fd); + if (file == NULL) { + errno = EBADF; + return -1; + } return statcont->removexattr(statcont, file->fname, name); } @@ -408,6 +420,10 @@ int smbc_flistxattr(int fd, size_t size) { SMBCFILE * file = find_fd(fd); + if (file == NULL) { + errno = EBADF; + return -1; + } return statcont->listxattr(statcont, file->fname, list, size); } -- cgit From d824b98f80ba186030cbb70b3a1e5daf80469ecd Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 9 Jul 2007 19:25:36 +0000 Subject: r23779: Change from v2 or later to v3 or later. Jeremy. (This used to be commit 407e6e695b8366369b7c76af1ff76869b45347b3) --- source3/libsmb/libsmb_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index cfd5948e26..7b8993a19a 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -9,7 +9,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, -- cgit From 5e54558c6dea67b56bbfaba5698f3a434d3dffb6 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Tue, 10 Jul 2007 00:52:41 +0000 Subject: r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text (This used to be commit b0132e94fc5fef936aa766fb99a306b3628e9f07) --- source3/libsmb/libsmb_compat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 7b8993a19a..e0f2a90bd6 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -18,8 +18,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 . */ -- cgit From 274e35f36e55ff215cef26d44d35627cb9c97924 Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 5 Sep 2007 12:53:56 +0000 Subject: r24969: Fwd port "open" patch (This used to be commit 113d62682ae8b045ff0132a743a32f3bc4856d54) --- source3/libsmb/libsmb_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index e0f2a90bd6..d6c2fe2109 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -156,7 +156,7 @@ int smbc_open(const char *furl, int flags, mode_t mode) SMBCFILE * file; int fd; - file = statcont->open(statcont, furl, flags, mode); + file = (statcont->open)(statcont, furl, flags, mode); if (!file) return -1; -- cgit From 9044d034892ea7f21082bf915fa5dd531043b473 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Thu, 6 Sep 2007 13:21:31 +0000 Subject: r24981: - Use the formal syntax for calling functions through pointers. I've wanted to make this change for ages, but now with the issue of "open" requiring it, this is the time to just do all of them. Derrell (This used to be commit e746aaaf4db7099252ef048da7857bd488cb681f) --- source3/libsmb/libsmb_compat.c | 84 +++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 42 deletions(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index d6c2fe2109..573d087d6e 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -162,7 +162,7 @@ int smbc_open(const char *furl, int flags, mode_t mode) fd = add_fd(file); if (fd == -1) - statcont->close_fn(statcont, file); + (statcont->close_fn)(statcont, file); return fd; } @@ -172,15 +172,15 @@ int smbc_creat(const char *furl, mode_t mode) SMBCFILE * file; int fd; - file = statcont->creat(statcont, furl, mode); + file = (statcont->creat)(statcont, furl, mode); if (!file) return -1; fd = add_fd(file); if (fd == -1) { /* Hmm... should we delete the file too ? I guess we could try */ - statcont->close_fn(statcont, file); - statcont->unlink(statcont, furl); + (statcont->close_fn)(statcont, file); + (statcont->unlink)(statcont, furl); } return fd; } @@ -189,36 +189,36 @@ int smbc_creat(const char *furl, mode_t mode) ssize_t smbc_read(int fd, void *buf, size_t bufsize) { SMBCFILE * file = find_fd(fd); - return statcont->read(statcont, file, buf, bufsize); + return (statcont->read)(statcont, file, buf, bufsize); } ssize_t smbc_write(int fd, void *buf, size_t bufsize) { SMBCFILE * file = find_fd(fd); - return statcont->write(statcont, file, buf, bufsize); + return (statcont->write)(statcont, file, buf, bufsize); } off_t smbc_lseek(int fd, off_t offset, int whence) { SMBCFILE * file = find_fd(fd); - return statcont->lseek(statcont, file, offset, whence); + return (statcont->lseek)(statcont, file, offset, whence); } int smbc_close(int fd) { SMBCFILE * file = find_fd(fd); del_fd(fd); - return statcont->close_fn(statcont, file); + return (statcont->close_fn)(statcont, file); } int smbc_unlink(const char *fname) { - return statcont->unlink(statcont, fname); + return (statcont->unlink)(statcont, fname); } int smbc_rename(const char *ourl, const char *nurl) { - return statcont->rename(statcont, ourl, statcont, nurl); + return (statcont->rename)(statcont, ourl, statcont, nurl); } int smbc_opendir(const char *durl) @@ -226,13 +226,13 @@ int smbc_opendir(const char *durl) SMBCFILE * file; int fd; - file = statcont->opendir(statcont, durl); + file = (statcont->opendir)(statcont, durl); if (!file) return -1; fd = add_fd(file); if (fd == -1) - statcont->closedir(statcont, file); + (statcont->closedir)(statcont, file); return fd; } @@ -241,62 +241,62 @@ int smbc_closedir(int dh) { SMBCFILE * file = find_fd(dh); del_fd(dh); - return statcont->closedir(statcont, file); + return (statcont->closedir)(statcont, file); } int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count) { SMBCFILE * file = find_fd(dh); - return statcont->getdents(statcont, file,dirp, count); + return (statcont->getdents)(statcont, file,dirp, count); } struct smbc_dirent* smbc_readdir(unsigned int dh) { SMBCFILE * file = find_fd(dh); - return statcont->readdir(statcont, file); + return (statcont->readdir)(statcont, file); } off_t smbc_telldir(int dh) { SMBCFILE * file = find_fd(dh); - return statcont->telldir(statcont, file); + return (statcont->telldir)(statcont, file); } int smbc_lseekdir(int fd, off_t offset) { SMBCFILE * file = find_fd(fd); - return statcont->lseekdir(statcont, file, offset); + return (statcont->lseekdir)(statcont, file, offset); } int smbc_mkdir(const char *durl, mode_t mode) { - return statcont->mkdir(statcont, durl, mode); + return (statcont->mkdir)(statcont, durl, mode); } int smbc_rmdir(const char *durl) { - return statcont->rmdir(statcont, durl); + return (statcont->rmdir)(statcont, durl); } int smbc_stat(const char *url, struct stat *st) { - return statcont->stat(statcont, url, st); + return (statcont->stat)(statcont, url, st); } int smbc_fstat(int fd, struct stat *st) { SMBCFILE * file = find_fd(fd); - return statcont->fstat(statcont, file, st); + return (statcont->fstat)(statcont, file, st); } int smbc_chmod(const char *url, mode_t mode) { - return statcont->chmod(statcont, url, mode); + return (statcont->chmod)(statcont, url, mode); } int smbc_utimes(const char *fname, struct timeval *tbuf) { - return statcont->utimes(statcont, fname, tbuf); + return (statcont->utimes)(statcont, fname, tbuf); } #ifdef HAVE_UTIME_H @@ -305,13 +305,13 @@ int smbc_utime(const char *fname, struct utimbuf *utbuf) struct timeval tv[2]; if (utbuf == NULL) - return statcont->utimes(statcont, fname, NULL); + return (statcont->utimes)(statcont, fname, NULL); tv[0].tv_sec = utbuf->actime; tv[1].tv_sec = utbuf->modtime; tv[0].tv_usec = tv[1].tv_usec = 0; - return statcont->utimes(statcont, fname, tv); + return (statcont->utimes)(statcont, fname, tv); } #endif @@ -321,7 +321,7 @@ int smbc_setxattr(const char *fname, size_t size, int flags) { - return statcont->setxattr(statcont, fname, name, value, size, flags); + return (statcont->setxattr)(statcont, fname, name, value, size, flags); } int smbc_lsetxattr(const char *fname, @@ -330,7 +330,7 @@ int smbc_lsetxattr(const char *fname, size_t size, int flags) { - return statcont->setxattr(statcont, fname, name, value, size, flags); + return (statcont->setxattr)(statcont, fname, name, value, size, flags); } int smbc_fsetxattr(int fd, @@ -344,8 +344,8 @@ int smbc_fsetxattr(int fd, errno = EBADF; return -1; } - return statcont->setxattr(statcont, file->fname, - name, value, size, flags); + return (statcont->setxattr)(statcont, file->fname, + name, value, size, flags); } int smbc_getxattr(const char *fname, @@ -353,7 +353,7 @@ int smbc_getxattr(const char *fname, const void *value, size_t size) { - return statcont->getxattr(statcont, fname, name, value, size); + return (statcont->getxattr)(statcont, fname, name, value, size); } int smbc_lgetxattr(const char *fname, @@ -361,7 +361,7 @@ int smbc_lgetxattr(const char *fname, const void *value, size_t size) { - return statcont->getxattr(statcont, fname, name, value, size); + return (statcont->getxattr)(statcont, fname, name, value, size); } int smbc_fgetxattr(int fd, @@ -374,19 +374,19 @@ int smbc_fgetxattr(int fd, errno = EBADF; return -1; } - return statcont->getxattr(statcont, file->fname, name, value, size); + return (statcont->getxattr)(statcont, file->fname, name, value, size); } int smbc_removexattr(const char *fname, const char *name) { - return statcont->removexattr(statcont, fname, name); + return (statcont->removexattr)(statcont, fname, name); } int smbc_lremovexattr(const char *fname, const char *name) { - return statcont->removexattr(statcont, fname, name); + return (statcont->removexattr)(statcont, fname, name); } int smbc_fremovexattr(int fd, @@ -397,21 +397,21 @@ int smbc_fremovexattr(int fd, errno = EBADF; return -1; } - return statcont->removexattr(statcont, file->fname, name); + return (statcont->removexattr)(statcont, file->fname, name); } int smbc_listxattr(const char *fname, char *list, size_t size) { - return statcont->listxattr(statcont, fname, list, size); + return (statcont->listxattr)(statcont, fname, list, size); } int smbc_llistxattr(const char *fname, char *list, size_t size) { - return statcont->listxattr(statcont, fname, list, size); + return (statcont->listxattr)(statcont, fname, list, size); } int smbc_flistxattr(int fd, @@ -423,29 +423,29 @@ int smbc_flistxattr(int fd, errno = EBADF; return -1; } - return statcont->listxattr(statcont, file->fname, list, size); + return (statcont->listxattr)(statcont, file->fname, list, size); } int smbc_print_file(const char *fname, const char *printq) { - return statcont->print_file(statcont, fname, statcont, printq); + return (statcont->print_file)(statcont, fname, statcont, printq); } int smbc_open_print_job(const char *fname) { - SMBCFILE * file = statcont->open_print_job(statcont, fname); + SMBCFILE * file = (statcont->open_print_job)(statcont, fname); if (!file) return -1; return file->cli_fd; } int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn) { - return statcont->list_print_jobs(statcont, purl, fn); + return (statcont->list_print_jobs)(statcont, purl, fn); } int smbc_unlink_print_job(const char *purl, int id) { - return statcont->unlink_print_job(statcont, purl, id); + return (statcont->unlink_print_job)(statcont, purl, id); } -- cgit From fa341d526293f4d986f2f3d838a728ce4223ee88 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Tue, 26 Feb 2008 21:44:51 -0500 Subject: add smbc_ftruncate() to emulate POSIX ftruncate() (This used to be commit 6f5051b9c1405ab1dc3e697419ceedb3acac46d8) --- source3/libsmb/libsmb_compat.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 573d087d6e..6042464fd2 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -289,6 +289,12 @@ int smbc_fstat(int fd, struct stat *st) return (statcont->fstat)(statcont, file, st); } +int smbc_ftruncate(int fd, off_t size) +{ + SMBCFILE * file = find_fd(fd); + return (statcont->ftruncate)(statcont, file, size); +} + int smbc_chmod(const char *url, mode_t mode) { return (statcont->chmod)(statcont, url, mode); -- cgit From 257b7b09298f7cb983b2f31b87fc5e46e0f62f0c Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Thu, 28 Feb 2008 11:23:20 -0500 Subject: Initial revamp of the libsmbclient interface. The libsmbclient interface has suffered from difficulty of improvement and feature enrichment without causing ABI breakage. Although there were a number of issues, the primary ones were: (a) the user of the library would manually manipulate the context structure members, meaning that nothing in the context structure could change other than adding stuff at the end; (b) there were three methods of setting options: setting bits in a flags field within the context structure, setting explicit options variables within an options structure in the context structure, and by calling the smbc_option_set() function; (c) the authentication callback did not traditionally provide enough information to the callee which required adding an option for a callback with a different signature, and now there are requests for even more information at the callback, requiring yet a third signature and option to set it (if we implement that feature). This commit provides a reorganization of the code which fixes (a) and (b). The context structure is now entirely opaque, and there are setter and getter functions for manipulating it. This makes maintaining ABI consistency much, much easier. Additionally, the options setting/getting has been unified into a single mechanism using smbc_option_set() and smbc_option_get(). Yet to be completed is a refactoring of the authentication callback (c). The test programs in examples/libsmbclient have been modified (if necessary; some applications require no changes at all) for the new API and a few have been minimally tested. Derrell (This used to be commit d4b4bae8ded824d06ad5ab0e219f71187ee5c771) --- source3/libsmb/libsmb_compat.c | 329 ++++++++++++++++++++++++++--------------- 1 file changed, 207 insertions(+), 122 deletions(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 6042464fd2..7a0536a92d 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -5,7 +5,7 @@ Copyright (C) Richard Sharpe 2000 Copyright (C) John Terpstra 2000 Copyright (C) Tom Jansen (Ninja ISD) 2002 - Copyright (C) Derrell Lipman 2003 + Copyright (C) Derrell Lipman 2003, 2008 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 @@ -23,8 +23,7 @@ #include "includes.h" - -#include "include/libsmb_internal.h" +#include "libsmb_internal.h" struct smbc_compat_fdlist { SMBCFILE * file; @@ -39,7 +38,8 @@ static struct smbc_compat_fdlist * smbc_compat_fd_in_use = NULL; static struct smbc_compat_fdlist * smbc_compat_fd_avail = NULL; /* Find an fd and return the SMBCFILE * or NULL on failure */ -static SMBCFILE * find_fd(int fd) +static SMBCFILE * +find_fd(int fd) { struct smbc_compat_fdlist * f = smbc_compat_fd_in_use; while (f) { @@ -51,7 +51,8 @@ static SMBCFILE * find_fd(int fd) } /* Add an fd, returns 0 on success, -1 on error with errno set */ -static int add_fd(SMBCFILE * file) +static int +add_fd(SMBCFILE * file) { struct smbc_compat_fdlist * f = smbc_compat_fd_avail; @@ -90,7 +91,8 @@ static int add_fd(SMBCFILE * file) /* Delete an fd, returns 0 on success */ -static int del_fd(int fd) +static int +del_fd(int fd) { struct smbc_compat_fdlist * f = smbc_compat_fd_in_use; @@ -112,15 +114,17 @@ static int del_fd(int fd) -int smbc_init(smbc_get_auth_data_fn fn, int debug) +int +smbc_init(smbc_get_auth_data_fn fn, + int debug) { if (!smbc_compat_initialized) { statcont = smbc_new_context(); if (!statcont) return -1; - statcont->debug = debug; - statcont->callbacks.auth_fn = fn; + smbc_setDebug(statcont, debug); + smbc_setFunctionAuthData(statcont, fn); if (!smbc_init_context(statcont)) { smbc_free_context(statcont, False); @@ -135,7 +139,8 @@ int smbc_init(smbc_get_auth_data_fn fn, int debug) } -SMBCCTX *smbc_set_context(SMBCCTX * context) +SMBCCTX * +smbc_set_context(SMBCCTX * context) { SMBCCTX *old_context = statcont; @@ -151,307 +156,387 @@ SMBCCTX *smbc_set_context(SMBCCTX * context) } -int smbc_open(const char *furl, int flags, mode_t mode) +int +smbc_open(const char *furl, + int flags, + mode_t mode) { SMBCFILE * file; int fd; - file = (statcont->open)(statcont, furl, flags, mode); + file = smbc_getFunctionOpen(statcont)(statcont, furl, flags, mode); if (!file) return -1; fd = add_fd(file); if (fd == -1) - (statcont->close_fn)(statcont, file); + smbc_getFunctionClose(statcont)(statcont, file); return fd; } -int smbc_creat(const char *furl, mode_t mode) +int +smbc_creat(const char *furl, + mode_t mode) { SMBCFILE * file; int fd; - file = (statcont->creat)(statcont, furl, mode); + file = smbc_getFunctionCreat(statcont)(statcont, furl, mode); if (!file) return -1; fd = add_fd(file); if (fd == -1) { /* Hmm... should we delete the file too ? I guess we could try */ - (statcont->close_fn)(statcont, file); - (statcont->unlink)(statcont, furl); + smbc_getFunctionClose(statcont)(statcont, file); + smbc_getFunctionUnlink(statcont)(statcont, furl); } return fd; } -ssize_t smbc_read(int fd, void *buf, size_t bufsize) +ssize_t +smbc_read(int fd, + void *buf, + size_t bufsize) { SMBCFILE * file = find_fd(fd); - return (statcont->read)(statcont, file, buf, bufsize); + return smbc_getFunctionRead(statcont)(statcont, file, buf, bufsize); } -ssize_t smbc_write(int fd, void *buf, size_t bufsize) +ssize_t +smbc_write(int fd, + void *buf, + size_t bufsize) { SMBCFILE * file = find_fd(fd); - return (statcont->write)(statcont, file, buf, bufsize); + return smbc_getFunctionWrite(statcont)(statcont, file, buf, bufsize); } -off_t smbc_lseek(int fd, off_t offset, int whence) +off_t +smbc_lseek(int fd, + off_t offset, + int whence) { SMBCFILE * file = find_fd(fd); - return (statcont->lseek)(statcont, file, offset, whence); + return smbc_getFunctionLseek(statcont)(statcont, file, offset, whence); } -int smbc_close(int fd) +int +smbc_close(int fd) { SMBCFILE * file = find_fd(fd); del_fd(fd); - return (statcont->close_fn)(statcont, file); + return smbc_getFunctionClose(statcont)(statcont, file); } -int smbc_unlink(const char *fname) +int +smbc_unlink(const char *fname) { - return (statcont->unlink)(statcont, fname); + return smbc_getFunctionUnlink(statcont)(statcont, fname); } -int smbc_rename(const char *ourl, const char *nurl) +int +smbc_rename(const char *ourl, + const char *nurl) { - return (statcont->rename)(statcont, ourl, statcont, nurl); + return smbc_getFunctionRename(statcont)(statcont, ourl, + statcont, nurl); } -int smbc_opendir(const char *durl) +int +smbc_opendir(const char *durl) { SMBCFILE * file; int fd; - file = (statcont->opendir)(statcont, durl); + file = smbc_getFunctionOpendir(statcont)(statcont, durl); if (!file) return -1; fd = add_fd(file); if (fd == -1) - (statcont->closedir)(statcont, file); + smbc_getFunctionClosedir(statcont)(statcont, file); return fd; } -int smbc_closedir(int dh) +int +smbc_closedir(int dh) { SMBCFILE * file = find_fd(dh); del_fd(dh); - return (statcont->closedir)(statcont, file); + return smbc_getFunctionClosedir(statcont)(statcont, file); } -int smbc_getdents(unsigned int dh, struct smbc_dirent *dirp, int count) +int +smbc_getdents(unsigned int dh, + struct smbc_dirent *dirp, + int count) { SMBCFILE * file = find_fd(dh); - return (statcont->getdents)(statcont, file,dirp, count); + return smbc_getFunctionGetdents(statcont)(statcont, file, dirp, count); } -struct smbc_dirent* smbc_readdir(unsigned int dh) +struct smbc_dirent * +smbc_readdir(unsigned int dh) { SMBCFILE * file = find_fd(dh); - return (statcont->readdir)(statcont, file); + return smbc_getFunctionReaddir(statcont)(statcont, file); } -off_t smbc_telldir(int dh) +off_t +smbc_telldir(int dh) { SMBCFILE * file = find_fd(dh); - return (statcont->telldir)(statcont, file); + return smbc_getFunctionTelldir(statcont)(statcont, file); } -int smbc_lseekdir(int fd, off_t offset) +int +smbc_lseekdir(int fd, + off_t offset) { SMBCFILE * file = find_fd(fd); - return (statcont->lseekdir)(statcont, file, offset); + return smbc_getFunctionLseekdir(statcont)(statcont, file, offset); } -int smbc_mkdir(const char *durl, mode_t mode) +int +smbc_mkdir(const char *durl, + mode_t mode) { - return (statcont->mkdir)(statcont, durl, mode); + return smbc_getFunctionMkdir(statcont)(statcont, durl, mode); } -int smbc_rmdir(const char *durl) +int +smbc_rmdir(const char *durl) { - return (statcont->rmdir)(statcont, durl); + return smbc_getFunctionRmdir(statcont)(statcont, durl); } -int smbc_stat(const char *url, struct stat *st) +int +smbc_stat(const char *url, + struct stat *st) { - return (statcont->stat)(statcont, url, st); + return smbc_getFunctionStat(statcont)(statcont, url, st); } -int smbc_fstat(int fd, struct stat *st) +int +smbc_fstat(int fd, + struct stat *st) { SMBCFILE * file = find_fd(fd); - return (statcont->fstat)(statcont, file, st); + return smbc_getFunctionFstat(statcont)(statcont, file, st); } -int smbc_ftruncate(int fd, off_t size) +int +smbc_ftruncate(int fd, + off_t size) { SMBCFILE * file = find_fd(fd); - return (statcont->ftruncate)(statcont, file, size); + return smbc_getFunctionFtruncate(statcont)(statcont, file, size); } -int smbc_chmod(const char *url, mode_t mode) +int +smbc_chmod(const char *url, + mode_t mode) { - return (statcont->chmod)(statcont, url, mode); + return smbc_getFunctionChmod(statcont)(statcont, url, mode); } -int smbc_utimes(const char *fname, struct timeval *tbuf) +int +smbc_utimes(const char *fname, + struct timeval *tbuf) { - return (statcont->utimes)(statcont, fname, tbuf); + return smbc_getFunctionUtimes(statcont)(statcont, fname, tbuf); } #ifdef HAVE_UTIME_H -int smbc_utime(const char *fname, struct utimbuf *utbuf) +int +smbc_utime(const char *fname, + struct utimbuf *utbuf) { struct timeval tv[2]; if (utbuf == NULL) - return (statcont->utimes)(statcont, fname, NULL); + return smbc_getFunctionUtimes(statcont)(statcont, fname, NULL); tv[0].tv_sec = utbuf->actime; tv[1].tv_sec = utbuf->modtime; tv[0].tv_usec = tv[1].tv_usec = 0; - return (statcont->utimes)(statcont, fname, tv); + return smbc_getFunctionUtimes(statcont)(statcont, fname, tv); } #endif -int smbc_setxattr(const char *fname, - const char *name, - const void *value, - size_t size, - int flags) +int +smbc_setxattr(const char *fname, + const char *name, + const void *value, + size_t size, + int flags) { - return (statcont->setxattr)(statcont, fname, name, value, size, flags); + return smbc_getFunctionSetxattr(statcont)(statcont, + fname, name, + value, size, flags); } -int smbc_lsetxattr(const char *fname, - const char *name, - const void *value, - size_t size, - int flags) +int +smbc_lsetxattr(const char *fname, + const char *name, + const void *value, + size_t size, + int flags) { - return (statcont->setxattr)(statcont, fname, name, value, size, flags); + return smbc_getFunctionSetxattr(statcont)(statcont, + fname, name, + value, size, flags); } -int smbc_fsetxattr(int fd, - const char *name, - const void *value, - size_t size, - int flags) +int +smbc_fsetxattr(int fd, + const char *name, + const void *value, + size_t size, + int flags) { SMBCFILE * file = find_fd(fd); if (file == NULL) { errno = EBADF; return -1; } - return (statcont->setxattr)(statcont, file->fname, - name, value, size, flags); + return smbc_getFunctionSetxattr(statcont)(statcont, + file->fname, name, + value, size, flags); } -int smbc_getxattr(const char *fname, - const char *name, - const void *value, - size_t size) +int +smbc_getxattr(const char *fname, + const char *name, + const void *value, + size_t size) { - return (statcont->getxattr)(statcont, fname, name, value, size); + return smbc_getFunctionGetxattr(statcont)(statcont, + fname, name, + value, size); } -int smbc_lgetxattr(const char *fname, - const char *name, - const void *value, - size_t size) +int +smbc_lgetxattr(const char *fname, + const char *name, + const void *value, + size_t size) { - return (statcont->getxattr)(statcont, fname, name, value, size); + return smbc_getFunctionGetxattr(statcont)(statcont, + fname, name, + value, size); } -int smbc_fgetxattr(int fd, - const char *name, - const void *value, - size_t size) +int +smbc_fgetxattr(int fd, + const char *name, + const void *value, + size_t size) { SMBCFILE * file = find_fd(fd); if (file == NULL) { errno = EBADF; return -1; } - return (statcont->getxattr)(statcont, file->fname, name, value, size); + return smbc_getFunctionGetxattr(statcont)(statcont, + file->fname, name, + value, size); } -int smbc_removexattr(const char *fname, - const char *name) +int +smbc_removexattr(const char *fname, + const char *name) { - return (statcont->removexattr)(statcont, fname, name); + return smbc_getFunctionRemovexattr(statcont)(statcont, fname, name); } -int smbc_lremovexattr(const char *fname, - const char *name) +int +smbc_lremovexattr(const char *fname, + const char *name) { - return (statcont->removexattr)(statcont, fname, name); + return smbc_getFunctionRemovexattr(statcont)(statcont, fname, name); } -int smbc_fremovexattr(int fd, - const char *name) +int +smbc_fremovexattr(int fd, + const char *name) { SMBCFILE * file = find_fd(fd); if (file == NULL) { errno = EBADF; return -1; } - return (statcont->removexattr)(statcont, file->fname, name); + return smbc_getFunctionRemovexattr(statcont)(statcont, + file->fname, name); } -int smbc_listxattr(const char *fname, - char *list, - size_t size) +int +smbc_listxattr(const char *fname, + char *list, + size_t size) { - return (statcont->listxattr)(statcont, fname, list, size); + return smbc_getFunctionListxattr(statcont)(statcont, + fname, list, size); } -int smbc_llistxattr(const char *fname, - char *list, - size_t size) +int +smbc_llistxattr(const char *fname, + char *list, + size_t size) { - return (statcont->listxattr)(statcont, fname, list, size); + return smbc_getFunctionListxattr(statcont)(statcont, + fname, list, size); } -int smbc_flistxattr(int fd, - char *list, - size_t size) +int +smbc_flistxattr(int fd, + char *list, + size_t size) { SMBCFILE * file = find_fd(fd); if (file == NULL) { errno = EBADF; return -1; } - return (statcont->listxattr)(statcont, file->fname, list, size); + return smbc_getFunctionListxattr(statcont)(statcont, + file->fname, list, size); } -int smbc_print_file(const char *fname, const char *printq) +int +smbc_print_file(const char *fname, + const char *printq) { - return (statcont->print_file)(statcont, fname, statcont, printq); + return smbc_getFunctionPrintFile(statcont)(statcont, fname, + statcont, printq); } -int smbc_open_print_job(const char *fname) +int +smbc_open_print_job(const char *fname) { - SMBCFILE * file = (statcont->open_print_job)(statcont, fname); + SMBCFILE * file; + + file = smbc_getFunctionOpenPrintJob(statcont)(statcont, fname); if (!file) return -1; return file->cli_fd; } -int smbc_list_print_jobs(const char *purl, smbc_list_print_job_fn fn) +int +smbc_list_print_jobs(const char *purl, + smbc_list_print_job_fn fn) { - return (statcont->list_print_jobs)(statcont, purl, fn); + return smbc_getFunctionListPrintJobs(statcont)(statcont, purl, fn); } -int smbc_unlink_print_job(const char *purl, int id) +int +smbc_unlink_print_job(const char *purl, + int id) { - return (statcont->unlink_print_job)(statcont, purl, id); + return smbc_getFunctionUnlinkPrintJob(statcont)(statcont, purl, id); } -- cgit From 223940d9a887c5b98a5c873797302a6a9407ad7f Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Sat, 1 Mar 2008 20:44:21 -0500 Subject: Additional revamped libsmbclient documentation - Ensured that all public functions have documentation in libsmbclient.h - Reformatted for "proper" indentation - Re-added temporarily-disabled alternate authentication function capability Derrell (This used to be commit 64b7150d92849a1e1e2416b9dcc12fae8d6bea99) --- source3/libsmb/libsmb_compat.c | 52 +++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 7a0536a92d..9ef5e51fa9 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -55,11 +55,11 @@ static int add_fd(SMBCFILE * file) { struct smbc_compat_fdlist * f = smbc_compat_fd_avail; - + if (f) { /* We found one that's available */ DLIST_REMOVE(smbc_compat_fd_avail, f); - + } else { /* * None were available, so allocate one. Keep the number of @@ -72,19 +72,19 @@ add_fd(SMBCFILE * file) errno = EMFILE; return -1; } - + f = SMB_MALLOC_P(struct smbc_compat_fdlist); if (!f) { errno = ENOMEM; return -1; } - + f->fd = SMBC_BASE_FD + smbc_compat_nextfd++; } - + f->file = file; DLIST_ADD(smbc_compat_fd_in_use, f); - + return f->fd; } @@ -95,13 +95,13 @@ static int del_fd(int fd) { struct smbc_compat_fdlist * f = smbc_compat_fd_in_use; - + while (f) { if (f->fd == fd) break; f = f->next; } - + if (f) { /* found */ DLIST_REMOVE(smbc_compat_fd_in_use, f); @@ -111,7 +111,7 @@ del_fd(int fd) } return 1; } - + int @@ -122,17 +122,17 @@ smbc_init(smbc_get_auth_data_fn fn, statcont = smbc_new_context(); if (!statcont) return -1; - + smbc_setDebug(statcont, debug); smbc_setFunctionAuthData(statcont, fn); - + if (!smbc_init_context(statcont)) { smbc_free_context(statcont, False); return -1; } - + smbc_compat_initialized = 1; - + return 0; } return 0; @@ -143,11 +143,11 @@ SMBCCTX * smbc_set_context(SMBCCTX * context) { SMBCCTX *old_context = statcont; - + if (context) { /* Save provided context. It must have been initialized! */ statcont = context; - + /* You'd better know what you're doing. We won't help you. */ smbc_compat_initialized = 1; } @@ -163,11 +163,11 @@ smbc_open(const char *furl, { SMBCFILE * file; int fd; - + file = smbc_getFunctionOpen(statcont)(statcont, furl, flags, mode); if (!file) return -1; - + fd = add_fd(file); if (fd == -1) smbc_getFunctionClose(statcont)(statcont, file); @@ -181,11 +181,11 @@ smbc_creat(const char *furl, { SMBCFILE * file; int fd; - + file = smbc_getFunctionCreat(statcont)(statcont, furl, mode); if (!file) return -1; - + fd = add_fd(file); if (fd == -1) { /* Hmm... should we delete the file too ? I guess we could try */ @@ -250,15 +250,15 @@ smbc_opendir(const char *durl) { SMBCFILE * file; int fd; - + file = smbc_getFunctionOpendir(statcont)(statcont, durl); if (!file) return -1; - + fd = add_fd(file); if (fd == -1) smbc_getFunctionClosedir(statcont)(statcont, file); - + return fd; } @@ -357,14 +357,14 @@ smbc_utime(const char *fname, struct utimbuf *utbuf) { struct timeval tv[2]; - + if (utbuf == NULL) return smbc_getFunctionUtimes(statcont)(statcont, fname, NULL); - + tv[0].tv_sec = utbuf->actime; tv[1].tv_sec = utbuf->modtime; tv[0].tv_usec = tv[1].tv_usec = 0; - + return smbc_getFunctionUtimes(statcont)(statcont, fname, tv); } #endif @@ -519,7 +519,7 @@ int smbc_open_print_job(const char *fname) { SMBCFILE * file; - + file = smbc_getFunctionOpenPrintJob(statcont)(statcont, fname); if (!file) return -1; return file->cli_fd; -- cgit From cd90c85bab1fbe8e731a5a694aba708e4396c2f2 Mon Sep 17 00:00:00 2001 From: Derrell Lipman Date: Wed, 16 Jul 2008 10:45:09 -0400 Subject: The compatibility function also should have a const buffer pointer (This used to be commit b731447ec539d454002300fd755dddcad2351d6c) --- source3/libsmb/libsmb_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'source3/libsmb/libsmb_compat.c') diff --git a/source3/libsmb/libsmb_compat.c b/source3/libsmb/libsmb_compat.c index 9ef5e51fa9..ad8fd922db 100644 --- a/source3/libsmb/libsmb_compat.c +++ b/source3/libsmb/libsmb_compat.c @@ -207,7 +207,7 @@ smbc_read(int fd, ssize_t smbc_write(int fd, - void *buf, + const void *buf, size_t bufsize) { SMBCFILE * file = find_fd(fd); -- cgit