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 <stdarg.h>
#include <assert.h>
#include "smbw.h"
+#include "bsd-strlfunc.h"
+
+typedef enum StartupType
+{
+ StartupType_Fake,
+ StartupType_Real
+} StartupType;
int smbw_fd_map[__FD_SETSIZE];
int smbw_ref_count[__FD_SETSIZE];
extern int smbw_debug;
+/*****************************************************
+smbw_ref -- manipulate reference counts
+******************************************************/
int smbw_ref(int client_fd, Ref_Count_Type type, ...)
{
va_list ap;
p = getenv("PASSWORD");
if (p == NULL) p = "";
- strncpy(wg, w, wglen);
- strncpy(un, u, unlen);
- strncpy(pw, p, pwlen);
+ smbw_strlcpy(wg, w, wglen);
+ smbw_strlcpy(un, u, unlen);
+ smbw_strlcpy(pw, p, pwlen);
}
static smbc_get_auth_data_fn get_auth_data_fn = get_envvar_auth_data;
/*****************************************************
initialise structures
*******************************************************/
-static void do_init(int is_real_startup)
+static void do_init(StartupType startupType)
{
int i;
char *p;
/* See if we've been told to start in a particular directory */
if ((p=getenv("SMBW_DIR")) != NULL) {
- strncpy(smbw_cwd, p, PATH_MAX);
+ smbw_strlcpy(smbw_cwd, p, PATH_MAX);
/* we don't want the old directory to be busy */
(* smbw_libc.chdir)("/");
}
if ((smbw_ctx = smbc_new_context()) == NULL) {
+ fprintf(stderr, "Could not create a context.\n");
exit(1);
}
smbw_ctx->options.browse_max_lmb_count = 0;
smbw_ctx->options.urlencode_readdir_entries = 1;
smbw_ctx->options.one_share_per_server = 1;
-// smbw_cache_functions(smbw_ctx);
if (smbc_init_context(smbw_ctx) == NULL) {
+ fprintf(stderr, "Could not initialize context.\n");
exit(1);
}
smbc_set_context(smbw_ctx);
/* if not real startup, exit handler has already been established */
- if (is_real_startup) {
+ if (startupType == StartupType_Real) {
atexit(do_shutdown);
}
}
*******************************************************/
void smbw_init(void)
{
- do_init(1);
+ do_init(StartupType_Real);
}
int saved_errno;
SMBW_OFF_T old_ofs;
+ if (count == 0) {
+ return 0;
+ }
+
client_fd = smbw_fd_map[smbw_fd];
if ((old_ofs = smbc_lseek(client_fd, 0, SEEK_CUR)) < 0 ||
ssize_t ret;
SMBW_OFF_T old_ofs;
+ if (count == 0) {
+ return 0;
+ }
+
client_fd = smbw_fd_map[smbw_fd];
if ((old_ofs = smbc_lseek(client_fd, 0, SEEK_CUR)) < 0 ||
}
/* Re-initialize this library for the child */
- do_init(0);
+ do_init(StartupType_Fake);
/* and continue in the child */
return 0;