Debian Codegraph @

plugins/wfx/samba/src/libsmbclient.pas

raw
1 unit libsmbclient;
2
3 {$mode delphi}
4
5 interface
6
7 uses
8 Classes, SysUtils,
9 Unix, BaseUnix, UnixType;
10
11 const
12 SMBC_WORKGROUP = 1;
13 SMBC_SERVER = 2;
14 SMBC_FILE_SHARE = 3;
15 SMBC_PRINTER_SHARE = 4;
16 SMBC_COMMS_SHARE = 5;
17 SMBC_IPC_SHARE = 6;
18 SMBC_DIR = 7;
19 SMBC_FILE = 8;
20 SMBC_LINK = 9;
21
22 const
23 SMBC_DOS_MODE_READONLY = $01;
24 SMBC_DOS_MODE_HIDDEN = $02;
25 SMBC_DOS_MODE_SYSTEM = $04;
26 SMBC_DOS_MODE_VOLUME_ID = $08;
27 SMBC_DOS_MODE_DIRECTORY = $10;
28 SMBC_DOS_MODE_ARCHIVE = $20;
29
30 type
31 (**@ingroup structure
32 * Structure that represents a directory entry.
33 *
34 *)
35 psmbc_dirent = ^smbc_dirent;
36 smbc_dirent = record
37 (** Type of entity.
38 SMBC_WORKGROUP=1,
39 SMBC_SERVER=2,
40 SMBC_FILE_SHARE=3,
41 SMBC_PRINTER_SHARE=4,
42 SMBC_COMMS_SHARE=5,
43 SMBC_IPC_SHARE=6,
44 SMBC_DIR=7,
45 SMBC_FILE=8,
46 SMBC_LINK=9,*)
47 smbc_type: LongWord;
48
49 (** Length of this smbc_dirent in bytes
50 *)
51 dirlen: LongWord;
52 (** The length of the comment string in bytes (does not include
53 * null terminator)
54 *)
55 commentlen: LongWord;
56 (** Points to the null terminated comment string
57 *)
58 comment: PAnsiChar;
59 (** The length of the name string in bytes (does not include
60 * null terminator)
61 *)
62 namelen: LongWord;
63 (** Points to the null terminated name string
64 *)
65 name: array[0..0] of AnsiChar;
66 end;
67
68 smbc_get_auth_data_fn = procedure(server, share: PAnsiChar;
69 wg: PAnsiChar; wglen: LongInt;
70 un: PAnsiChar; unlen: LongInt;
71 pw: PAnsiChar; pwlen: LongInt); cdecl;
72
73 smbc_init_fn = function (fn: smbc_get_auth_data_fn; debug: LongInt): LongInt; cdecl;
74 smbc_open_fn = function(furl: PAnsiChar; flags: LongInt; mode: mode_t): LongInt; cdecl;
75 smbc_read_fn = function(fd: LongInt; buf: Pointer; bufsize: size_t): ssize_t; cdecl;
76 smbc_write_fn = function(fd: LongInt; buf: Pointer; bufsize: size_t): ssize_t; cdecl;
77 smbc_lseek_fn = function(fd: LongInt; offset: off_t; whence: LongInt): off_t; cdecl;
78 smbc_close_fn = function(fd: LongInt): LongInt; cdecl;
79 smbc_unlink_fn = function(furl: PAnsiChar): LongInt; cdecl;
80 smbc_rename_fn = function(ourl: PAnsiChar; nurl: PAnsiChar): LongInt; cdecl;
81 smbc_opendir_fn = function(durl: PAnsiChar): LongInt; cdecl;
82 smbc_closedir_fn = function(dh: LongInt): LongInt; cdecl;
83 smbc_readdir_fn = function(dh: LongInt): psmbc_dirent; cdecl;
84 smbc_mkdir_fn = function(durl: PAnsiChar; mode: mode_t): LongInt; cdecl;
85 smbc_rmdir_fn = function(durl: PAnsiChar): LongInt; cdecl;
86 smbc_stat_fn = function(url: PAnsiChar; st: PStat): LongInt; cdecl;
87 smbc_getxattr_fn = function(url, name: PAnsiChar; value: Pointer; size: size_t): LongInt; cdecl;
88 smbc_setxattr_fn = function(url, name: PAnsiChar; value: Pointer; size: size_t; flags: LongInt): LongInt; cdecl;
89 smbc_utimes_fn = function(url: PAnsiChar; tbuf: ptimeval): LongInt; cdecl;
90
91 var
92 smbc_init: smbc_init_fn;
93 smbc_open: smbc_open_fn;
94 smbc_read: smbc_read_fn;
95 smbc_write: smbc_write_fn;
96 smbc_lseek: smbc_lseek_fn;
97 smbc_close: smbc_close_fn;
98 smbc_unlink: smbc_unlink_fn;
99 smbc_rename: smbc_rename_fn;
100 smbc_opendir: smbc_opendir_fn;
101 smbc_closedir: smbc_closedir_fn;
102 smbc_readdir: smbc_readdir_fn;
103 smbc_mkdir: smbc_mkdir_fn;
104 smbc_rmdir: smbc_rmdir_fn;
105 smbc_stat: smbc_stat_fn;
106 smbc_getxattr: smbc_getxattr_fn;
107 smbc_setxattr: smbc_setxattr_fn;
108 smbc_utimes: smbc_utimes_fn;
109
110 function LoadSambaLibrary: Boolean;
111
112 implementation
113
114 uses dynlibs;
115
116 var
117 hSamba: TLibHandle = 0;
118
119 function LoadSambaLibrary: Boolean;
120 begin
121 if (hSamba = 0) then
122 begin
123 hSamba:= LoadLibrary('libsmbclient.so.0');
124 if (hSamba <> 0) then
125 begin
126 @smbc_init:= GetProcAddress(hSamba, 'smbc_init');
127 @smbc_opendir:= GetProcAddress(hSamba, 'smbc_opendir');
128 @smbc_readdir:= GetProcAddress(hSamba, 'smbc_readdir');
129 @smbc_closedir:= GetProcAddress(hSamba, 'smbc_closedir');
130 @smbc_mkdir:= GetProcAddress(hSamba, 'smbc_mkdir');
131 @smbc_rmdir:= GetProcAddress(hSamba, 'smbc_rmdir');
132 @smbc_open:= GetProcAddress(hSamba, 'smbc_open');
133 @smbc_read:= GetProcAddress(hSamba, 'smbc_read');
134 @smbc_write:= GetProcAddress(hSamba, 'smbc_write');
135 @smbc_lseek:= GetProcAddress(hSamba, 'smbc_lseek');
136 @smbc_close:= GetProcAddress(hSamba, 'smbc_close');
137 @smbc_unlink:= GetProcAddress(hSamba, 'smbc_unlink');
138 @smbc_rename:= GetProcAddress(hSamba, 'smbc_rename');
139 @smbc_stat:= GetProcAddress(hSamba, 'smbc_stat');
140 @smbc_getxattr:= GetProcAddress(hSamba, 'smbc_getxattr');
141 @smbc_setxattr:= GetProcAddress(hSamba, 'smbc_setxattr');
142 @smbc_utimes:= GetProcAddress(hSamba, 'smbc_utimes');
143 end;
144 end;
145 Result:= (hSamba <> 0);
146 end;
147
148 end.
149