r5735: rest of derrel's patch for BUG 2308; had to move the options structure from...
[samba.git] / source / include / libsmb_internal.h
1 #ifndef _LIBSMB_INTERNAL_H_
2 #define _LIBSMB_INTERNAL_H_
3
4 #define SMBC_MAX_NAME  1023
5 #define SMBC_FILE_MODE (S_IFREG | 0444)
6 #define SMBC_DIR_MODE  (S_IFDIR | 0555)
7
8
9 #include "include/libsmbclient.h"
10
11
12 struct _SMBCSRV {
13         struct cli_state cli;
14         dev_t dev;
15         BOOL no_pathinfo2;
16         BOOL no_nt_session;
17         int server_fd;
18
19         SMBCSRV *next, *prev;
20         
21 };
22
23 /* 
24  * Keep directory entries in a list 
25  */
26 struct smbc_dir_list {
27         struct smbc_dir_list *next;
28         struct smbc_dirent *dirent;
29 };
30
31
32 /*
33  * Structure for open file management
34  */ 
35 struct _SMBCFILE {
36         int cli_fd; 
37         char *fname;
38         off_t offset;
39         struct _SMBCSRV *srv;
40         BOOL file;
41         struct smbc_dir_list *dir_list, *dir_end, *dir_next;
42         int dir_type, dir_error;
43
44         SMBCFILE *next, *prev;
45 };
46
47
48 struct smbc_internal_data {
49
50         /** INTERNAL: is this handle initialized ? 
51          */
52         int     _initialized;
53
54         /** INTERNAL: dirent pointer location
55          *
56          * Leave room for any urlencoded filename and the comment field.
57          *
58          * We really should use sizeof(struct smbc_dirent) plus (NAME_MAX * 3)
59          * plus whatever the max length of a comment is, plus a couple of null
60          * terminators (one after the filename, one after the comment).
61          *
62          * According to <linux/limits.h>, NAME_MAX is 255.  Is it longer
63          * anyplace else?
64          */
65         char    _dirent[1024];
66
67         /** INTERNAL: server connection list
68          */
69         SMBCSRV * _servers;
70         
71         /** INTERNAL: open file/dir list
72          */
73         SMBCFILE * _files;
74         /** user options selections that apply to this session
75          */
76         struct _smbc_options {
77
78                 /*
79                  * From how many local master browsers should the list of
80                  * workgroups be retrieved?  It can take up to 12 minutes or
81                  * longer after a server becomes a local master browser, for
82                  * it to have the entire browse list (the list of
83                  * workgroups/domains) from an entire network.  Since a client
84                  * never knows which local master browser will be found first,
85                  * the one which is found first and used to retrieve a browse
86                  * list may have an incomplete or empty browse list.  By
87                  * requesting the browse list from multiple local master
88                  * browsers, a more complete list can be generated.  For small
89                  * networks (few workgroups), it is recommended that this
90                  * value be set to 0, causing the browse lists from all found
91                  * local master browsers to be retrieved and merged.  For
92                  * networks with many workgroups, a suitable value for this
93                  * variable is probably somewhere around 3. (Default: 3).
94                  */
95                 int browse_max_lmb_count;
96
97                 /*
98                  * There is a difference in the desired return strings from
99                  * smbc_readdir() depending upon whether the filenames are to
100                  * be displayed to the user, or whether they are to be
101                  * appended to the path name passed to smbc_opendir() to call
102                  * a further smbc_ function (e.g. open the file with
103                  * smbc_open()).  In the former case, the filename should be
104                  * in "human readable" form.  In the latter case, the smbc_
105                  * functions expect a URL which must be url-encoded.  Those
106                  * functions decode the URL.  If, for example, smbc_readdir()
107                  * returned a file name of "abc%20def.txt", passing a path
108                  * with this file name attached to smbc_open() would cause
109                  * smbc_open to attempt to open the file "abc def.txt" since
110                  * the %20 is decoded into a space.
111                  *
112                  * Set this option to True if the names returned by
113                  * smbc_readdir() should be url-encoded such that they can be
114                  * passed back to another smbc_ call.  Set it to False if the
115                  * names returned by smbc_readdir() are to be presented to the
116                  * user.
117                  *
118                  * For backwards compatibility, this option defaults to False.
119                  */
120                 int urlencode_readdir_entries;
121
122                 /*
123                  * Some Windows versions appear to have a limit to the number
124                  * of concurrent SESSIONs and/or TREE CONNECTions.  In
125                  * one-shot programs (i.e. the program runs and then quickly
126                  * ends, thereby shutting down all connections), it is
127                  * probably reasonable to establish a new connection for each
128                  * share.  In long-running applications, the limitation can be
129                  * avoided by using only a single connection to each server,
130                  * and issuing a new TREE CONNECT when the share is accessed.
131                  */
132                 int one_share_per_server;
133         } options;
134 };      
135
136
137 #endif