Index: libsmb/libsmbclient.c =================================================================== --- libsmb/libsmbclient.c (revision 5744) +++ libsmb/libsmbclient.c (working copy) @@ -571,7 +571,7 @@ * If we found a connection and we're only allowed one share per * server... */ - if (srv && *share != '\0' && context->internal->options.one_share_per_server) { + if (srv && *share != '\0' && context->options.one_share_per_server) { /* * ... then if there's no current connection to the share, @@ -629,10 +629,10 @@ return NULL; } - if (context->flags & SMB_CTX_FLAG_USE_KERBEROS) { + if (context->options.use_kerberos) { c.use_kerberos = True; } - if (context->flags & SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS) { + if (context->options.fallback_after_kerberos) { c.fallback_after_kerberos = True; } @@ -714,7 +714,7 @@ password, strlen(password), workgroup) && /* Try an anonymous login if it failed and this was allowed by flags. */ - ((context->flags & SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON) || + ((context->options.no_auto_anonymous_login) || !cli_session_setup(&c, "", "", 1,"", 0, workgroup))) { cli_shutdown(&c); errno = EPERM; @@ -1932,9 +1932,9 @@ } /* Determine how many local master browsers to query */ - max_lmb_count = (context->internal->options.browse_max_lmb_count == 0 + max_lmb_count = (context->options.browse_max_lmb_count == 0 ? INT_MAX - : context->internal->options.browse_max_lmb_count); + : context->options.browse_max_lmb_count); pstrcpy(u_info.username, user); pstrcpy(u_info.password, password); @@ -2216,7 +2216,7 @@ struct smbc_dirent *src, int max_namebuf_len) { - if (context->internal->options.urlencode_readdir_entries) { + if (context->options.urlencode_readdir_entries) { /* url-encode the name. get back remaining buffer space */ max_namebuf_len = @@ -3245,7 +3245,7 @@ } /* Obtain the DOS attributes */ - if (!smbc_getatr(context, srv, filename, &mode, &size, + if (!smbc_getatr(context, srv, (char *) filename, &mode, &size, &c_time, &a_time, &m_time, &inode)) { errno = smbc_errno(context, &srv->cli); @@ -3840,7 +3840,7 @@ the_acl = p + 1; } - sd = sec_desc_parse(ctx, ipc_cli, pol, numeric, the_acl); + sd = sec_desc_parse(ctx, ipc_cli, pol, numeric, (char *) the_acl); if (!sd) { errno = EINVAL; @@ -4370,7 +4370,7 @@ /* Yup. */ ret = cacl_get(context, ctx, srv, ipc_srv == NULL ? NULL : &ipc_srv->cli, - &pol, path, name, (const char *) value, size); + &pol, path, (char *) name, (char *) value, size); if (ret < 0 && errno == 0) { errno = smbc_errno(context, &srv->cli); } @@ -4804,8 +4804,6 @@ return NULL; } - context->flags = SMBCCTX_FLAG_CTXVER; - ZERO_STRUCTP(context->internal); @@ -4813,9 +4811,13 @@ context->debug = 0; context->timeout = 20000; /* 20 seconds */ - context->internal->options.browse_max_lmb_count = 3; /* # LMBs to query */ - context->internal->options.urlencode_readdir_entries = False;/* backward compat */ - context->internal->options.one_share_per_server = False;/* backward compat */ + context->options.context_version = 1; + context->options.browse_max_lmb_count = 3; /* # LMBs to query */ + context->options.urlencode_readdir_entries = False;/* backward compat */ + context->options.one_share_per_server = False;/* backward compat */ + context->options.use_kerberos = False; + context->options.fallback_after_kerberos = False; + context->options.no_auto_anonymous_login = False; context->open = smbc_open_ctx; context->creat = smbc_creat_ctx; Index: libsmb/libsmb_cache.c =================================================================== --- libsmb/libsmb_cache.c (revision 5744) +++ libsmb/libsmb_cache.c (working copy) @@ -143,7 +143,7 @@ * a connection to the server (other than the * attribute server connection) is cool. */ - if (context->internal->options.one_share_per_server) { + if (context->options.one_share_per_server) { /* * The currently connected share name * doesn't match the requested share, so Index: include/libsmb_internal.h =================================================================== --- include/libsmb_internal.h (revision 5744) +++ include/libsmb_internal.h (working copy) @@ -73,64 +73,6 @@ SMBCFILE * _files; /** user options selections that apply to this session */ - struct _smbc_options { - - /* - * From how many local master browsers should the list of - * workgroups be retrieved? It can take up to 12 minutes or - * longer after a server becomes a local master browser, for - * it to have the entire browse list (the list of - * workgroups/domains) from an entire network. Since a client - * never knows which local master browser will be found first, - * the one which is found first and used to retrieve a browse - * list may have an incomplete or empty browse list. By - * requesting the browse list from multiple local master - * browsers, a more complete list can be generated. For small - * networks (few workgroups), it is recommended that this - * value be set to 0, causing the browse lists from all found - * local master browsers to be retrieved and merged. For - * networks with many workgroups, a suitable value for this - * variable is probably somewhere around 3. (Default: 3). - */ - int browse_max_lmb_count; - - /* - * There is a difference in the desired return strings from - * smbc_readdir() depending upon whether the filenames are to - * be displayed to the user, or whether they are to be - * appended to the path name passed to smbc_opendir() to call - * a further smbc_ function (e.g. open the file with - * smbc_open()). In the former case, the filename should be - * in "human readable" form. In the latter case, the smbc_ - * functions expect a URL which must be url-encoded. Those - * functions decode the URL. If, for example, smbc_readdir() - * returned a file name of "abc%20def.txt", passing a path - * with this file name attached to smbc_open() would cause - * smbc_open to attempt to open the file "abc def.txt" since - * the %20 is decoded into a space. - * - * Set this option to True if the names returned by - * smbc_readdir() should be url-encoded such that they can be - * passed back to another smbc_ call. Set it to False if the - * names returned by smbc_readdir() are to be presented to the - * user. - * - * For backwards compatibility, this option defaults to False. - */ - int urlencode_readdir_entries; - - /* - * Some Windows versions appear to have a limit to the number - * of concurrent SESSIONs and/or TREE CONNECTions. In - * one-shot programs (i.e. the program runs and then quickly - * ends, thereby shutting down all connections), it is - * probably reasonable to establish a new connection for each - * share. In long-running applications, the limitation can be - * avoided by using only a single connection to each server, - * and issuing a new TREE CONNECT when the share is accessed. - */ - int one_share_per_server; - } options; }; Index: include/libsmbclient.h =================================================================== --- include/libsmbclient.h (revision 5744) +++ include/libsmbclient.h (working copy) @@ -466,19 +466,91 @@ */ struct smbc_server_cache * server_cache; + struct _smbc_options { + + /* + * Context structure version + */ + int context_version; + + /* + * From how many local master browsers should the list of + * workgroups be retrieved? It can take up to 12 minutes or + * longer after a server becomes a local master browser, for + * it to have the entire browse list (the list of + * workgroups/domains) from an entire network. Since a client + * never knows which local master browser will be found first, + * the one which is found first and used to retrieve a browse + * list may have an incomplete or empty browse list. By + * requesting the browse list from multiple local master + * browsers, a more complete list can be generated. For small + * networks (few workgroups), it is recommended that this + * value be set to 0, causing the browse lists from all found + * local master browsers to be retrieved and merged. For + * networks with many workgroups, a suitable value for this + * variable is probably somewhere around 3. (Default: 3). + */ + int browse_max_lmb_count; + + /* + * There is a difference in the desired return strings from + * smbc_readdir() depending upon whether the filenames are to + * be displayed to the user, or whether they are to be + * appended to the path name passed to smbc_opendir() to call + * a further smbc_ function (e.g. open the file with + * smbc_open()). In the former case, the filename should be + * in "human readable" form. In the latter case, the smbc_ + * functions expect a URL which must be url-encoded. Those + * functions decode the URL. If, for example, smbc_readdir() + * returned a file name of "abc%20def.txt", passing a path + * with this file name attached to smbc_open() would cause + * smbc_open to attempt to open the file "abc def.txt" since + * the %20 is decoded into a space. + * + * Set this option to True if the names returned by + * smbc_readdir() should be url-encoded such that they can be + * passed back to another smbc_ call. Set it to False if the + * names returned by smbc_readdir() are to be presented to the + * user. + * + * For backwards compatibility, this option defaults to False. + */ + int urlencode_readdir_entries; + + /* + * Some Windows versions appear to have a limit to the number + * of concurrent SESSIONs and/or TREE CONNECTions. In + * one-shot programs (i.e. the program runs and then quickly + * ends, thereby shutting down all connections), it is + * probably reasonable to establish a new connection for each + * share. In long-running applications, the limitation can be + * avoided by using only a single connection to each server, + * and issuing a new TREE CONNECT when the share is accessed. + */ + int one_share_per_server; + + /* + * Use kerberos + */ + int use_kerberos; + + /* + * Fallback after kerberos + */ + int fallback_after_kerberos; + + /* + * Do not try to do automatic anonymous login + */ + int no_auto_anonymous_login; + } options; + /** INTERNAL DATA * do _NOT_ touch this from your program ! */ struct smbc_internal_data * internal; - - int flags; }; -/* Flags for SMBCCTX->flags */ -#define SMB_CTX_FLAG_USE_KERBEROS (1 << 0) -#define SMB_CTX_FLAG_FALLBACK_AFTER_KERBEROS (1 << 1) -#define SMBCCTX_FLAG_NO_AUTO_ANONYMOUS_LOGON (1 << 2) /* don't try to do automatic anon login */ -#define SMBCCTX_FLAG_CTXVER (1 << 3 ) /* internal flag used to define _SMBCCTX version */ /**@ingroup misc * Create a new SBMCCTX (a context).